toip.tools

class · Browser and Node

GroupIssuer

Runs one group: enrolls members, removes leavers, and signs one root per epoch in a hash chain. It holds DIDs and commitments, never a member's secret.

@toip-tools/anon-membershipView source
TypeScriptImport
import { GroupIssuer } from "@toip-tools/anon-membership";

Constructor

TypeScriptConstructor
new (opts: {
    identity: Identity;
    clock: Clock;
    name: string;
    depth?: number;
    period?: number;
    keepSnapshots?: number;
    state?: GroupIssuerState;
}): GroupIssuer;

Parameters

optsrequired
{ identity: Identity; clock: Clock; name: string; depth?: number; period?: number; keepSnapshots?: number; state?: GroupIssuerState; }
Fields of opts
identityrequired
Identity
clockrequired
Clock
namerequired
string
depthoptional
number | undefined
periodoptional
number | undefined

Seconds per epoch. Default: one day.

keepSnapshotsoptional
number | undefined

How many recent epochs' snapshots to keep. Default 30.

stateoptional
GroupIssuerState | undefined

Returns

Properties

groupIdrequired · readonly
string
groupFieldrequired · readonly
bigint
periodrequired · readonly
number

Methods

enroll

Adds or replaces subject's leaf. The old leaf, if any, becomes 0 and a new index is used. fields sets the leaf's schema, days and attributes; the default is a plain leaf.

TypeScriptSignature
enroll(subject: string, commitment: Field, fields?: LeafFields): {
    index: number;
    leaf: Leaf;
};

Parameters

subjectrequired
string
commitmentrequired
bigint
fieldsoptional
LeafFields | undefined

Returns

{ index: number; leaf: Leaf; }

revoke

TypeScriptSignature
revoke(subject: string): void;

Parameters

subjectrequired
string

Returns

void

member

TypeScriptSignature
member(subject: string): {
    index: number;
    leaf: Leaf;
} | undefined;

Parameters

subjectrequired
string

Returns

{ index: number; leaf: Leaf; } | undefined

tree

The live tree. Treat it as read-only.

TypeScriptSignature
tree(): GroupTree;

No parameters.

Returns

nextEpoch

The epoch the next root will be for.

TypeScriptSignature
nextEpoch(): string;

No parameters.

Returns

string

publish

Signs this epoch's root. Throws if this epoch already has one.

TypeScriptSignature
publish(ext?: Record<string, unknown>): {
    root: GroupRoot;
    snapshot: Uint8Array;
};

Parameters

extoptional
Record<string, unknown> | undefined

Returns

{ root: GroupRoot; snapshot: Uint8Array; }

log

TypeScriptSignature
log(): GroupRoot[];

No parameters.

Returns

snapshot

TypeScriptSignature
snapshot(epoch: string): Uint8Array | undefined;

Parameters

epochrequired
string

Returns

Uint8Array<ArrayBufferLike> | undefined

serve

Answers anon-membership/enroll. admit decides whether the sending DID may join: false refuses, a Refusal refuses with its own code, true admits with a plain leaf, and leaf fields admit with those attributes.

TypeScriptSignature
serve(endpoint: Endpoint, admit: (did: string, request: EnrollRequest) => boolean | LeafFields | Refusal | Promise<boolean | LeafFields | Refusal>): void;

Parameters

endpointrequired
Endpoint
admitrequired
(did: string, request: EnrollRequest) => boolean | LeafFields | Refusal | Promise<boolean | LeafFields | Refusal>

Returns

void

state

TypeScriptSignature
state(): GroupIssuerState;

No parameters.

Returns