Skip to content
API reference

ear-tag

Import
import * as api from "@fungi.computer/ear-tag";
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”
Signature
type GenerateKeyOptions = Readonly<{
length?: number;
prefix?: string;
}>;

Options for generating a bearer key.


GeneratedKeytype alias

Section titled “GeneratedKey”
Signature
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()”
Signature
function generateKey(options?): string;

Generate a cryptographically random bearer key.

Parameter Type
options GenerateKeyOptions

string


Signature
function hashKey(key): Promise<string>;

Hash a bearer key with Worker-compatible Web Crypto.

Parameter Type
key string

Promise<string>


generateKeyAndHash()function

Section titled “generateKeyAndHash()”
Signature
function generateKeyAndHash(options?): Promise<
Readonly<{
digest: string;
key: string;
}>
>;

Generate a bearer key and the digest its owner should persist.

Parameter Type
options GenerateKeyOptions

Promise<Readonly<{ digest: string; key: string; }>>