Variables
MAX_SECRET_BYTES
const MAX_SECRET_BYTES: number;
The largest secret a wallet keeps (40 KB), the same on every device, so any secret travels in one message.
Functions
bondingNotice()
function bondingNotice( mine, theirs, iShowed ): BondingNotice;
What bonding two devices' personas will do, from the lines each sent (prd.md §4.10, "Before the holder
confirms"), as planMerge will do it once the seeds travel: personas on one side only are that side's; a side
whose own personas have all gone unused folds them, when the other's have been used, or, neither used, when
the other side's were made first; where both have, nothing folds and the holder is told. The default is that
of the device that showed the code (iShowed), unless it folds.
Parameters
| Parameter | Type |
|---|---|
mine | readonly PersonaLine[] |
theirs | readonly PersonaLine[] |
iShowed | boolean |
Returns
BondingNotice
exportConsentRecords()
function exportConsentRecords( records, subject, exportedAt? ): object;
The records as a JSON-LD document: subject is who they're about (the holder's did:key, say), records
any mix of this device's and other devices' (with device). Values shared are never in a record, so
never here; single-use key aliases stay behind.
Parameters
| Parameter | Type |
|---|---|
records | Exportable[] |
subject | string |
exportedAt | Date |
Returns
object
| Name | Type | Default value |
|---|---|---|
@context | object | CONTEXT |
@context.dct | string | 'http://purl.org/dc/terms/' |
@context.dpv | string | 'https://w3id.org/dpv#' |
@context.kivi | string | 'https://kivi.wellknown.id/ns#' |
@context.xsd | string | 'http://www.w3.org/2001/XMLSchema#' |
@graph | ( | { @id: string; @type: string; dct:conformsTo: string; dct:created: { @type: string; @value: string; }; dct:identifier: string; dpv:hasDataController: { @id: string; dct:title: string | undefined; }; dpv:hasDataSubject: { @id: string; }; dpv:hasRight: { @id: string; }; dpv:hasStatus: { @id: string; }; kivi:device?: string; kivi:organisationSaid: | { reason?: string; status?: "open" | "in_progress" | "fulfilled" | "denied"; } | undefined; } | { @id: string; @type: string; dct:conformsTo: string; dct:identifier: string; dpv:hasConsentStatus: { @type: string; dpv:isIndicatedAtTime: { @type: string; @value: string; }; dpv:isIndicatedBy: { @id: string; }; }; dpv:hasDataController: { @id: string; dct:title: string | undefined; }; dpv:hasDataSubject: { @id: string; }; dpv:hasNotice: | { @id: string; dct:hasVersion: string; kivi:sha256: string; } | undefined; dpv:hasPersonalData: object[] | undefined; dpv:hasPurpose: { @type: string; dct:description: string; }; dpv:hasStorageCondition: | { @type: string; dpv:hasDuration: string; } | undefined; kivi:askedBy: string | undefined; kivi:device?: string; kivi:how: | "digital-credentials-api" | "bonded-device" | "in-app" | "fedcm" | "redirect" | "for-another-device" | undefined; })[] | graph |
dct:created | string | - |
offerNameAmong()
function offerNameAmong(typed, taken): object;
A name as the holder typed it, against the names of their other personas (taken): name normalised,
offered the one it would take ("Work 2" if "Work" is taken, ignoring case), taken if they differ.
Throws NameError if it can't be a name.
Parameters
| Parameter | Type |
|---|---|
typed | string |
taken | Iterable<string> |
Returns
object
| Name | Type |
|---|---|
name | string |
offered | string |
taken | boolean |
otherPersons()
function otherPersons(b): boolean;
Whether a bond is with another person's device (prd.md §7.10), whichever side showed the code: who a custodian can be (§7.11).
Parameters
| Parameter | Type |
|---|---|
b | Pick<Bond, "kind" | "as"> |
Returns
boolean
pairingMailbox()
function pairingMailbox(secret): string;
The relay mailbox two devices meet at to pair, named by a hash of the pairing secret (the secret never leaves the link).
Parameters
| Parameter | Type |
|---|---|
secret | Uint8Array |
Returns
string
parseHandoverUrl()
function parseHandoverUrl(url): Uint8Array<ArrayBufferLike> | undefined;
The secret in a link handing the holder's wellknown.id to a browser (…/take#1.<secret>), or undefined if url isn't one.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
Uint8Array<ArrayBufferLike> | undefined
parsePairingUrl()
function parsePairingUrl(url): Uint8Array<ArrayBufferLike> | undefined;
The bonding secret in a pairing link (…/bond#1.<secret>), or undefined if url isn't one.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
Uint8Array<ArrayBufferLike> | undefined
parseRecoveryCode()
function parseRecoveryCode(typed): Uint8Array;
A recovery code as typed (any case, with or without dashes or spaces; O for 0, I and L for 1). A code
printed with its persona's name (Persona Work · 7K3P-…, prd.md §4.10) is read after the last ·: the
name is a label, not part of the code.
Parameters
| Parameter | Type |
|---|---|
typed | string |
Returns
Uint8Array
parseRecoveryUrl()
function parseRecoveryUrl(url): Uint8Array<ArrayBufferLike> | undefined;
The secret in a recovery link (…/recover#1.<S>), or undefined if url isn't one.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
Uint8Array<ArrayBufferLike> | undefined
parseSignInUrl()
function parseSignInUrl(url): Uint8Array<ArrayBufferLike> | undefined;
The secret in a link asking a wallet to sign in for another device (…/signin#1.<secret>), or undefined if url isn't one.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
Uint8Array<ArrayBufferLike> | undefined
toBase64()
function toBase64(bytes): string;
Standard base64 (RFC 4648 §4, padded), with no dependency on Buffer or btoa.
Parameters
| Parameter | Type |
|---|---|
bytes | Uint8Array |
Returns
string
verifyDidKeySignature()
function verifyDidKeySignature( did, data, signature ): boolean;
Verifies a signature by a did:key, as the IdP does (apps/idp/lib/did-key.ts): Ed25519, or P-256 ECDSA with SHA-256 as raw r||s. Never throws.
Parameters
| Parameter | Type |
|---|---|
did | string |
data | Uint8Array |
signature | Uint8Array |
Returns
boolean
whoSigned()
function whoSigned(
entry,
here,
known
):
| {
kind: "here";
}
| {
kind: "device";
name: string;
}
| {
kind: "unknown";
}
| {
kind: "page";
};
Who made a record, for people: this device (here, its did:key), one of the devices known by name
(did:key to name), a device this one doesn't know, or (unsigned) one of the holder's browsers.
Parameters
| Parameter | Type |
|---|---|
entry | { signer?: string; } |
entry.signer? | string |
here | string |
known | ReadonlyMap<string, string> |
Returns
| {
kind: "here";
}
| {
kind: "device";
name: string;
}
| {
kind: "unknown";
}
| {
kind: "page";
}