API reference
ear-tag
Import
Section titled “Import”import * as api from "@fungi.computer/ear-tag";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| type alias | GenerateKeyOptions | Options for generating a bearer key. |
| type alias | GeneratedKey | A newly generated bearer key and the digest safe to retain in storage. |
| function | generateKey() | Generate a cryptographically random bearer key. |
| function | hashKey() | Hash a bearer key with Worker-compatible Web Crypto. |
| function | generateKeyAndHash() | Generate a bearer key and the digest its owner should persist. |
GenerateKeyOptionstype alias
Section titled “GenerateKeyOptions”type GenerateKeyOptions = Readonly<{ length?: number; prefix?: string;}>;Options for generating a bearer key.
GeneratedKeytype alias
Section titled “GeneratedKey”type GeneratedKey = Readonly<{ digest: string; key: string;}>;A newly generated bearer key and the digest safe to retain in storage.
generateKey()function
Section titled “generateKey()”function generateKey(options?): string;Generate a cryptographically random bearer key.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
GenerateKeyOptions |
Returns
Section titled “Returns”string
hashKey()function
Section titled “hashKey()”function hashKey(key): Promise<string>;Hash a bearer key with Worker-compatible Web Crypto.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key |
string |
Returns
Section titled “Returns”Promise<string>
generateKeyAndHash()function
Section titled “generateKeyAndHash()”function generateKeyAndHash(options?): Promise< Readonly<{ digest: string; key: string; }>>;Generate a bearer key and the digest its owner should persist.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
GenerateKeyOptions |
Returns
Section titled “Returns”Promise<Readonly<{ digest: string; key: string; }>>