UserHasher
Defined in: packages/core/src/hash.ts:35
Pseudonymises Discord user IDs inside the bot process: HMAC-SHA-256(period salt, userId), truncated to 16 bytes
and formatted as h1:<period>:<32 hex>. Keyed, because snowflakes are guessable and a plain hash could be reversed.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new UserHasher():
UserHasher
Returns
Section titled “Returns”UserHasher
Methods
Section titled “Methods”deleteSalt()
Section titled “deleteSalt()”deleteSalt(
label):void
Defined in: packages/core/src/hash.ts:56
Removes a period’s salt, such as one the collector has destroyed, and every hash computed with it.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
hash()
Section titled “hash()”hash(
userId,label):Promise<string|undefined>
Defined in: packages/core/src/hash.ts:69
The user hash, or undefined when no salt is installed for the period.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
string
Returns
Section titled “Returns”Promise<string | undefined>
hasSalt()
Section titled “hasSalt()”hasSalt(
label):boolean
Defined in: packages/core/src/hash.ts:64
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
labels()
Section titled “labels()”labels():
string[]
Defined in: packages/core/src/hash.ts:60
Returns
Section titled “Returns”string[]
setSalt()
Section titled “setSalt()”setSalt(
label,salt):Promise<void>
Defined in: packages/core/src/hash.ts:41
Installs a period’s salt (32 bytes). Only the three most recently added periods are kept.
Parameters
Section titled “Parameters”string
Uint8Array
Returns
Section titled “Returns”Promise<void>