@real-life/trust-protocol 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/README.md +41 -3
- package/dist/adapters/vti-mediator.d.ts +32 -0
- package/dist/adapters/vti-mediator.d.ts.map +1 -1
- package/dist/adapters/vti-mediator.js +91 -3
- package/dist/adapters/vti-mediator.js.map +1 -1
- package/dist/encounter/ceremony.d.ts +10 -0
- package/dist/encounter/ceremony.d.ts.map +1 -1
- package/dist/encounter/ceremony.js +70 -13
- package/dist/encounter/ceremony.js.map +1 -1
- package/dist/encounter.d.ts +4 -0
- package/dist/encounter.d.ts.map +1 -1
- package/dist/encounter.js +3 -1
- package/dist/encounter.js.map +1 -1
- package/dist/holder-api.d.ts +18 -2
- package/dist/holder-api.d.ts.map +1 -1
- package/dist/holder-api.js +16 -4
- package/dist/holder-api.js.map +1 -1
- package/dist/identity-state.d.ts +13 -1
- package/dist/identity-state.d.ts.map +1 -1
- package/dist/identity-state.js +36 -1
- package/dist/identity-state.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/results.d.ts +4 -0
- package/dist/results.d.ts.map +1 -1
- package/dist/results.js.map +1 -1
- package/dist/views.d.ts +14 -0
- package/dist/views.d.ts.map +1 -1
- package/dist/views.js +34 -5
- package/dist/views.js.map +1 -1
- package/package.json +2 -2
package/dist/encounter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encounter.d.ts","sourceRoot":"","sources":["../src/encounter.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAiB,GAAG,EAA6B,MAAM,WAAW,CAAA;AAEzE,OAAO,EAAE,GAAG,EAAE,CAAA;AAGd,eAAO,MAAM,QAAQ,wBAAwB,CAAA;AAC7C,eA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,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAQrH;AAED;mCACmC;AACnC,eAAO,MAAM,aAAa,GAAI,GAAG,SAAS,KAAG,gBAAgB,GAAG,mBAA4F,CAAA;AAE5J;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAE,GAAG,EAAE,GAAG,GAAG;IAAE,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAc5G;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAOrD"}
|
package/dist/encounter.js
CHANGED
|
@@ -46,7 +46,7 @@ const challengeOfUnchecked = (bytes17) => b64uOf(bytes17).slice(0, 22);
|
|
|
46
46
|
// cards carry no @context (the proof carries none either — W3C-true)
|
|
47
47
|
export const signCard = (ctx, body, created) => diSign(ctx, body, created);
|
|
48
48
|
export function cardBody(ctx, fields = {}) {
|
|
49
|
-
const { name, challenge, sentTo, boundTo } = fields;
|
|
49
|
+
const { name, deliveryHints, challenge, sentTo, boundTo } = fields;
|
|
50
50
|
// runtime guard for JS callers the union cannot reach: the sent-card
|
|
51
51
|
// profile is atomic — half of it is not a card of either profile
|
|
52
52
|
if ((sentTo === undefined) !== (boundTo === undefined))
|
|
@@ -54,6 +54,8 @@ export function cardBody(ctx, fields = {}) {
|
|
|
54
54
|
const b = { version: CARD_VERSION, anchor: ctx.anchor, keyAgreement: ctx.keyAgreement };
|
|
55
55
|
if (name !== undefined)
|
|
56
56
|
b.name = name;
|
|
57
|
+
if (deliveryHints !== undefined)
|
|
58
|
+
b.deliveryHints = [...deliveryHints];
|
|
57
59
|
if (challenge !== undefined)
|
|
58
60
|
b.challenge = challenge;
|
|
59
61
|
if (sentTo !== undefined) {
|
package/dist/encounter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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,yBAAyB,CAAC,CAAA;IACpG,MAAM,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACvC,IAAI,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA;IAClD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAE,GAAQ;IACpC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAA;IACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,2BAA2B,CAAA;IAC5D,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAAE,OAAO,4CAA4C,CAAA;IACnF,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,GAAG,CAAC,SAAS;QAAE,OAAO,qCAAqC,CAAA;IAC9F,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC;QAAE,OAAO,mCAAmC,CAAA;IACrK,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// encounter — the Encounter Layer: how two people record that they met.\n//\n// The one registered ceremony (encounter-scan), the contact card each\n// side displays, the challenge that makes an enactment fresh, the\n// enactment binding both sides compute independently, and the encounter\n// credential each issues about the other.\n//\n// The binding is what makes the pair an enactment rather than two\n// unrelated claims: both sides derive it from the same two challenges,\n// sorted, so neither can steer it.\nimport { digestDoc, diSign, diVerify, edRawOfAnchor, xRawOfMk } from './crypto.js'\nimport type { Signer } from './crypto.js'\nimport { b64uOf, calOK, iso, makeValidator, sameDigest } from './core.js'\nimport { SCHEMAS } from './schemas.js'\nexport { iso }\n\n// ── wire builders (Encounter 0.31: card 0.25, credential 0.26) ─────────\nexport const CEREMONY = 'encounter-scan@0.25'\nexport const CARD_VERSION = 'rltp-card/0.25'\n/** The credential form this library issues (Encounter 7.2). */\nexport const CRED_FORMAT = 'rltp-encounter-credential/0.26'\n/** The DTG credential context, DTG Credentials WD 0.6.0 (exact bytes; the\n * document is pinned by SHA-256 in contexts/dtg-v1.jsonld). */\nexport const DTG_CONTEXT = 'https://registry.trustoverip.org/dtg/context/v1'\n/** The pinned context set of the 0.26 credential (Encounter 2.3, RLTP-ENC-2250). */\nexport const CRED_CONTEXT: readonly string[] = Object.freeze(['https://www.w3.org/ns/credentials/v2', DTG_CONTEXT, 'https://real-life.org/rltp/v1'])\n/** Every credential format a verifier of this version knows, with its schema\n * file. A held 0.25 credential stays valid under its own format (7.3, 12). */\nexport const CRED_FORMATS: Readonly<Record<string, string>> = Object.freeze({\n 'rltp-encounter-credential/0.26': 'encounter-credential-0.26.schema.json',\n 'rltp-encounter-credential/0.25': 'encounter-credential-0.25.schema.json',\n})\n/** The schema file a credential is validated against, by the format it\n * names — null for an unknown format (ERR_VERSION at 5.6 step 1). */\nexport const credentialSchemaOf = (cred: unknown): string | null => {\n const f = (cred as { credentialSubject?: { format?: unknown } } | null)?.credentialSubject?.format\n return typeof f === 'string' && Object.prototype.hasOwnProperty.call(CRED_FORMATS, f) ? CRED_FORMATS[f] : null\n}\nexport const binding = (ceremony: string, c1: string, c2: string): Promise<string> => digestDoc({ ceremony, challenges: [c1, c2].sort() })\nexport const challengeOf = (bytes17: Uint8Array): string => {\n // a producer never emits what every conformant receiver must reject:\n // the challenge is EXACTLY 17 random bytes (>= 128 bits, Encounter §5)\n if (!(bytes17 instanceof Uint8Array) || bytes17.length !== 17) throw new Error('challenge entropy must be exactly 17 bytes')\n return challengeOfUnchecked(bytes17)\n}\nconst challengeOfUnchecked = (bytes17: Uint8Array): string => b64uOf(bytes17).slice(0, 22)\n\n// cards carry no @context (the proof carries none either — W3C-true)\nexport const signCard = (ctx: Signer, body: CardBody, created: string) => diSign(ctx, body, created)\n\n/** The challenge a displayed card carries: fresh value, whole-second issue time. */\nexport interface Challenge { value: string, issuedAt: string }\n\n/**\n * The spec knows exactly two disjoint card profiles (Encounter §5):\n * a DISPLAYED card offers a challenge; a SENT card names its recipient\n * AND the challenge it answers — always both, never one (M-2, review 1:\n * the fields travel together or the card is neither profile).\n */\nexport type CardFields =\n | { name?: string, challenge?: Challenge, sentTo?: undefined, boundTo?: undefined }\n | { name?: string, challenge?: Challenge, sentTo: string, boundTo: string }\n\n/** A card body as it goes under the signature. */\nexport interface CardBody {\n version: string\n anchor: string\n keyAgreement: string\n name?: string\n challenge?: Challenge\n sentTo?: string\n boundTo?: string\n}\n\nexport function cardBody (ctx: { anchor: string, keyAgreement: string }, fields: CardFields = {}): CardBody {\n const { name, challenge, sentTo, boundTo } = fields as { name?: string, challenge?: Challenge, sentTo?: string, boundTo?: string }\n // runtime guard for JS callers the union cannot reach: the sent-card\n // profile is atomic — half of it is not a card of either profile\n if ((sentTo === undefined) !== (boundTo === undefined)) throw new Error('a sent card carries sentTo AND boundTo together (Encounter §5)')\n const b: CardBody = { version: CARD_VERSION, anchor: ctx.anchor, keyAgreement: ctx.keyAgreement }\n if (name !== undefined) b.name = name\n if (challenge !== undefined) b.challenge = challenge\n if (sentTo !== undefined) { b.sentTo = sentTo; b.boundTo = boundTo }\n return b\n}\n/** The unsigned body of a step credential (Encounter 7.2): issuer, the\n * subject, the subject's challenge and the enactment binding. */\nexport const credentialBody = (\n issuerAnchor: string, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) => ({\n '@context': [...CRED_CONTEXT],\n type: ['VerifiableCredential', 'DTGCredential', 'RelationshipCredential', 'EncounterCredential'],\n issuer: issuerAnchor,\n // the issuer is a fresh pair anchor, known to exactly one counterparty (4.4)\n issuerScope: 'pairwise',\n validFrom: whenIso,\n credentialSubject: { id: subjectAnchor, format: CRED_FORMAT, ceremony, challenge: subjectChallenge, enactmentBinding },\n})\nexport async function issueCredential (\n ctx: Signer, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) {\n return diSign(ctx, credentialBody(ctx.anchor, subjectAnchor, ceremony, subjectChallenge, enactmentBinding, whenIso), whenIso)\n}\n\n\n// ── the ceremony's pure checks (Encounter 0.31 §5–§7, Delivery 4.1/4.3) ──\n// The task types, the §9 constants, the whole-second time rules, the card\n// check, the 5.6 credential checks in their normative order, and the\n// outer/inner forms of the two carriers. State-free: what needs the\n// own-challenge state or the records is the holder's (encounter/ceremony.ts).\nconst TT = 'https://real-life.org/trust-tasks/'\n/** The scanner's sent card and step credential (Delivery 4.1). */\nexport const BUNDLE_TYPE = TT + 'encounter-bundle/0.1'\n/** The counter-step or a standalone credential delivery (Delivery 4.3). */\nexport const DELIVERY_TYPE = TT + 'encounter-credential-delivery/0.1'\n// Encounter §9 operational constants (ms)\nexport const CHALLENGE_MAX_AGE = 5 * 60_000 // PT5M\nexport const ISSUANCE_WINDOW = 24 * 3_600_000 // PT24H\nexport const SKEW_TOLERANCE = 5 * 60_000 // PT5M\n\nconst VAL = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => VAL.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\n\n/** Whole seconds (2.3). */\nconst sec = (ms: number): number => Math.floor(ms / 1000)\nconst secIso = (t: string): number => Math.floor(Date.parse(t) / 1000)\n/** 5.5's explicit future check: t_ch ≤ now + skew, whole seconds. */\nexport const futureOk = (tCh: number, now: number): boolean => sec(tCh) <= sec(now) + SKEW_TOLERANCE / 1000\n/** Is a challenge issued at tCh past its age bound at `now` (5190)? */\nexport const challengeAged = (tCh: number, now: number): boolean => sec(now) > sec(tCh) + (CHALLENGE_MAX_AGE + SKEW_TOLERANCE) / 1000\n/** The producer's mirror of 5.6 step 6: may a credential binding a\n * challenge issued at tChMs still be issued now? */\nexport const issuanceOpen = (tChMs: number, now: number): boolean => {\n const skew = SKEW_TOLERANCE / 1000\n return sec(now) >= sec(tChMs) - skew && sec(now) <= sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n}\n/** The last millisecond a credential binding a challenge issued at tChMs may carry (5.6 step 6). */\nexport const issuanceEnd = (tChMs: number): number => (sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW + SKEW_TOLERANCE) / 1000) * 1000 + 999\n\n/** Producer-side profile discipline (Delivery 3): UUID v4 ids and threads. */\nconst UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\nexport const uuidOk = (v: unknown): boolean => typeof v === 'string' && UUID_V4.test(v)\n\nexport const CARD_SCHEMA = 'contact-card-0.25.schema.json'\n/** A card for an enactment (Encounter 6): schema-valid, its version known,\n * a challenge, calendar-valid times, keys that decode, the proof under the\n * anchor. null when it passes, else the reason. */\nexport async function cardOk (card: any, subtle?: SubtleCrypto): Promise<string | null> {\n if (!schemaOk(CARD_SCHEMA, card)) return 'card fails contact-card-0.25 schema'\n if (card.version !== CARD_VERSION) return 'card version unknown'\n if (!card.challenge) return 'card without challenge (enactment use requires one)'\n if (!calOK(card.challenge.issuedAt) || !calOK(card.proof?.created)) return 'card: calendar-invalid timestamp'\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return 'card keyAgreement does not decode (x25519-pub + 32 bytes, 2.3)'\n if (!(await diVerify(card, card.anchor, subtle))) return 'card proof'\n return null\n}\n\n/** The 5.6 rejection codes. */\nexport type CredError = 'ERR_VERSION' | 'ERR_SIG' | 'ERR_ADDRESSEE' | 'ERR_NO_RECORD' | 'ERR_CEREMONY' | 'ERR_STALE_ISSUANCE' | 'ERR_BINDING' | 'ERR_CONFLICT'\n\n/** 5.6 step 1, format: a KNOWN format validated against ITS schema (0.26,\n * or a held 0.25 — 7.3, 12), ceremony and version known, calendar-valid\n * times, the digest a multihash, keys that decode (2.3). `ceremonyHere`:\n * 5.6 checks the ceremony at step 1; a bundle checks it at Delivery 4.1's\n * check 5. */\nexport function credFormat (cred: any, ceremonyHere = true): CredError | null {\n const schema = credentialSchemaOf(cred)\n if (schema === null || !schemaOk(schema, cred)) return 'ERR_VERSION'\n if (ceremonyHere && cred.credentialSubject.ceremony !== CEREMONY) return 'ERR_VERSION'\n if (!calOK(cred.validFrom) || !calOK(cred.proof?.created)) return 'ERR_VERSION'\n if (!sameDigest(cred.credentialSubject.enactmentBinding, cred.credentialSubject.enactmentBinding)) return 'ERR_VERSION'\n if (!edRawOfAnchor(cred.issuer) || !edRawOfAnchor(cred.credentialSubject.id)) return 'ERR_VERSION'\n const vm = String(cred.proof?.verificationMethod ?? ''), hash = vm.indexOf('#')\n if (hash < 0 || !edRawOfAnchor(vm.slice(0, hash)) || !edRawOfAnchor('did:key:' + vm.slice(hash + 1))) return 'ERR_VERSION'\n return null\n}\n\n/** 5.6 steps 1–3: format, signature, addressee (`localAnchor`). */\nexport async function credHead (cred: any, localAnchor: string, ceremonyHere = true, subtle?: SubtleCrypto): Promise<CredError | null> {\n const f = credFormat(cred, ceremonyHere)\n if (f) return f\n if (!(await diVerify(cred, cred.issuer, subtle))) return 'ERR_SIG'\n if (cred.credentialSubject.id !== localAnchor) return 'ERR_ADDRESSEE'\n return null\n}\n\n/** 5.6 step 6: the issuance window, whole seconds, inclusive, skew widens. */\nexport function windowOk (cred: any, tChMs: number): boolean {\n const tCh = sec(tChMs), vf = secIso(cred.validFrom), cr = secIso(cred.proof.created), skew = SKEW_TOLERANCE / 1000\n const lo = tCh - skew, hi = tCh + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n return !(vf < lo || vf > hi || cr < lo || cr > hi || cr < vf - skew)\n}\n\n/** What 5.6 steps 4–7 read of a record. */\nexport interface RecordFacts { counterpart: string, ceremony: string, tCh: number, bind: string }\n\n/** 5.6 steps 4–7 against a record, synchronous. `order`: 'credential' —\n * 5.6: record, ceremony, window, binding; 'bundle' — Delivery 4.1:\n * record, ceremony, binding, window. */\nexport function acceptTail (cred: any, rec: RecordFacts | undefined, order: 'credential' | 'bundle'): CredError | null {\n if (!rec || rec.counterpart !== cred.issuer) return 'ERR_NO_RECORD'\n if (cred.credentialSubject.ceremony !== rec.ceremony) return 'ERR_CEREMONY'\n const bindOk = sameDigest(cred.credentialSubject.enactmentBinding, rec.bind)\n if (order === 'bundle' && !bindOk) return 'ERR_BINDING'\n if (!windowOk(cred, rec.tCh)) return 'ERR_STALE_ISSUANCE'\n if (!bindOk) return 'ERR_BINDING'\n return null\n}\n\n/** Delivery 4.1/4.3: ERR_STALE_ISSUANCE is stale-issuance, every other\n * rejection validation-failed. */\nexport const dispositionOf = (e: CredError): 'stale-issuance' | 'validation-failed' => (e === 'ERR_STALE_ISSUANCE' ? 'stale-issuance' : 'validation-failed')\n\n/**\n * The bundle's context-free checks of Delivery 4.1 check 1 (stage 8,\n * after the payload schema): calendars, the outer/inner equalities, the\n * sent card's binding, a present ceremony.enactment, the card's version\n * and keys, the credential's format (its ceremony at check 5). null when\n * they pass, else the reason, with the 4.1 disposition.\n */\nexport function bundleForm (doc: any): { reason: 'validation-failed' | 'stale-issuance', why: string } | null {\n const { card, credential } = doc.payload\n const v = (why: string) => ({ reason: 'validation-failed' as const, why })\n if (!calOK(doc.issuedAt) || !calOK(card.challenge?.issuedAt) || !calOK(card.proof?.created)) return v('calendar-invalid issuedAt')\n if (doc.issuer !== card.anchor || card.anchor !== credential.issuer) return v('outer binding (issuer = card.anchor = credential.issuer)')\n if (credential.credentialSubject?.id !== doc.recipient) return v('outer binding (recipient = subject)')\n if (card.sentTo !== doc.recipient || card.boundTo !== credential.credentialSubject.challenge) return v('sent card binding (sentTo/boundTo)')\n if (card.challenge.value === card.boundTo) return v('sent challenge equals the displayed challenge (5.3)')\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, credential.credentialSubject.enactmentBinding)) return v('ceremony.enactment recomputes not')\n if (card.version !== CARD_VERSION || !card.challenge) return v('card version/challenge')\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return v('card keys do not decode')\n const f = credFormat(credential, false)\n if (f) return { reason: dispositionOf(f), why: f }\n return null\n}\n\n/** The credential delivery's outer/inner consistency (Delivery 4.3). */\nexport function deliveryForm (doc: any): string | null {\n const cred = doc.payload.credential\n if (!calOK(doc.issuedAt)) return 'calendar-invalid issuedAt'\n if (doc.issuer !== cred.issuer) return 'outer binding (issuer = credential.issuer)'\n if (cred.credentialSubject?.id !== doc.recipient) return 'outer binding (recipient = subject)'\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, cred.credentialSubject.enactmentBinding)) return 'ceremony.enactment recomputes not'\n return null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"encounter.js","sourceRoot":"","sources":["../src/encounter.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,kEAAkE;AAClE,wEAAwE;AACxE,0CAA0C;AAC1C,EAAE;AACF,kEAAkE;AAClE,uEAAuE;AACvE,mCAAmC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAElF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,CAAA;AAEd,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,qBAAqB,CAAA;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAA;AAC5C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC,CAAA;AAC3D;gEACgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,iDAAiD,CAAA;AAC5E,oFAAoF;AACpF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E,SAAS,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC;QAAE,OAAO,mCAAmC,CAAA;IACrK,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["// encounter — the Encounter Layer: how two people record that they met.\n//\n// The one registered ceremony (encounter-scan), the contact card each\n// side displays, the challenge that makes an enactment fresh, the\n// enactment binding both sides compute independently, and the encounter\n// credential each issues about the other.\n//\n// The binding is what makes the pair an enactment rather than two\n// unrelated claims: both sides derive it from the same two challenges,\n// sorted, so neither can steer it.\nimport { digestDoc, diSign, diVerify, edRawOfAnchor, xRawOfMk } from './crypto.js'\nimport type { Signer } from './crypto.js'\nimport { b64uOf, calOK, iso, makeValidator, sameDigest } from './core.js'\nimport { SCHEMAS } from './schemas.js'\nexport { iso }\n\n// ── wire builders (Encounter 0.31: card 0.25, credential 0.26) ─────────\nexport const CEREMONY = 'encounter-scan@0.25'\nexport const CARD_VERSION = 'rltp-card/0.25'\n/** The credential form this library issues (Encounter 7.2). */\nexport const CRED_FORMAT = 'rltp-encounter-credential/0.26'\n/** The DTG credential context, DTG Credentials WD 0.6.0 (exact bytes; the\n * document is pinned by SHA-256 in contexts/dtg-v1.jsonld). */\nexport const DTG_CONTEXT = 'https://registry.trustoverip.org/dtg/context/v1'\n/** The pinned context set of the 0.26 credential (Encounter 2.3, RLTP-ENC-2250). */\nexport const CRED_CONTEXT: readonly string[] = Object.freeze(['https://www.w3.org/ns/credentials/v2', DTG_CONTEXT, 'https://real-life.org/rltp/v1'])\n/** Every credential format a verifier of this version knows, with its schema\n * file. A held 0.25 credential stays valid under its own format (7.3, 12). */\nexport const CRED_FORMATS: Readonly<Record<string, string>> = Object.freeze({\n 'rltp-encounter-credential/0.26': 'encounter-credential-0.26.schema.json',\n 'rltp-encounter-credential/0.25': 'encounter-credential-0.25.schema.json',\n})\n/** The schema file a credential is validated against, by the format it\n * names — null for an unknown format (ERR_VERSION at 5.6 step 1). */\nexport const credentialSchemaOf = (cred: unknown): string | null => {\n const f = (cred as { credentialSubject?: { format?: unknown } } | null)?.credentialSubject?.format\n return typeof f === 'string' && Object.prototype.hasOwnProperty.call(CRED_FORMATS, f) ? CRED_FORMATS[f] : null\n}\nexport const binding = (ceremony: string, c1: string, c2: string): Promise<string> => digestDoc({ ceremony, challenges: [c1, c2].sort() })\nexport const challengeOf = (bytes17: Uint8Array): string => {\n // a producer never emits what every conformant receiver must reject:\n // the challenge is EXACTLY 17 random bytes (>= 128 bits, Encounter §5)\n if (!(bytes17 instanceof Uint8Array) || bytes17.length !== 17) throw new Error('challenge entropy must be exactly 17 bytes')\n return challengeOfUnchecked(bytes17)\n}\nconst challengeOfUnchecked = (bytes17: Uint8Array): string => b64uOf(bytes17).slice(0, 22)\n\n// cards carry no @context (the proof carries none either — W3C-true)\nexport const signCard = (ctx: Signer, body: CardBody, created: string) => diSign(ctx, body, created)\n\n/** The challenge a displayed card carries: fresh value, whole-second issue time. */\nexport interface Challenge { value: string, issuedAt: string }\n\n/**\n * The spec knows exactly two disjoint card profiles (Encounter §5):\n * a DISPLAYED card offers a challenge; a SENT card names its recipient\n * AND the challenge it answers — always both, never one (M-2, review 1:\n * the fields travel together or the card is neither profile).\n */\nexport type CardFields =\n | { name?: string, deliveryHints?: string[], challenge?: Challenge, sentTo?: undefined, boundTo?: undefined }\n | { name?: string, deliveryHints?: string[], challenge?: Challenge, sentTo: string, boundTo: string }\n\n/** A card body as it goes under the signature. */\nexport interface CardBody {\n version: string\n anchor: string\n keyAgreement: string\n name?: string\n /** Encounter 6080, 6090: opaque strings whose form the carrier profile that names them defines */\n deliveryHints?: string[]\n challenge?: Challenge\n sentTo?: string\n boundTo?: string\n}\n\nexport function cardBody (ctx: { anchor: string, keyAgreement: string }, fields: CardFields = {}): CardBody {\n const { name, deliveryHints, challenge, sentTo, boundTo } = fields as { name?: string, deliveryHints?: string[], challenge?: Challenge, sentTo?: string, boundTo?: string }\n // runtime guard for JS callers the union cannot reach: the sent-card\n // profile is atomic — half of it is not a card of either profile\n if ((sentTo === undefined) !== (boundTo === undefined)) throw new Error('a sent card carries sentTo AND boundTo together (Encounter §5)')\n const b: CardBody = { version: CARD_VERSION, anchor: ctx.anchor, keyAgreement: ctx.keyAgreement }\n if (name !== undefined) b.name = name\n if (deliveryHints !== undefined) b.deliveryHints = [...deliveryHints]\n if (challenge !== undefined) b.challenge = challenge\n if (sentTo !== undefined) { b.sentTo = sentTo; b.boundTo = boundTo }\n return b\n}\n/** The unsigned body of a step credential (Encounter 7.2): issuer, the\n * subject, the subject's challenge and the enactment binding. */\nexport const credentialBody = (\n issuerAnchor: string, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) => ({\n '@context': [...CRED_CONTEXT],\n type: ['VerifiableCredential', 'DTGCredential', 'RelationshipCredential', 'EncounterCredential'],\n issuer: issuerAnchor,\n // the issuer is a fresh pair anchor, known to exactly one counterparty (4.4)\n issuerScope: 'pairwise',\n validFrom: whenIso,\n credentialSubject: { id: subjectAnchor, format: CRED_FORMAT, ceremony, challenge: subjectChallenge, enactmentBinding },\n})\nexport async function issueCredential (\n ctx: Signer, subjectAnchor: string, ceremony: string,\n subjectChallenge: string, enactmentBinding: string, whenIso: string,\n) {\n return diSign(ctx, credentialBody(ctx.anchor, subjectAnchor, ceremony, subjectChallenge, enactmentBinding, whenIso), whenIso)\n}\n\n\n// ── the ceremony's pure checks (Encounter 0.31 §5–§7, Delivery 4.1/4.3) ──\n// The task types, the §9 constants, the whole-second time rules, the card\n// check, the 5.6 credential checks in their normative order, and the\n// outer/inner forms of the two carriers. State-free: what needs the\n// own-challenge state or the records is the holder's (encounter/ceremony.ts).\nconst TT = 'https://real-life.org/trust-tasks/'\n/** The scanner's sent card and step credential (Delivery 4.1). */\nexport const BUNDLE_TYPE = TT + 'encounter-bundle/0.1'\n/** The counter-step or a standalone credential delivery (Delivery 4.3). */\nexport const DELIVERY_TYPE = TT + 'encounter-credential-delivery/0.1'\n// Encounter §9 operational constants (ms)\nexport const CHALLENGE_MAX_AGE = 5 * 60_000 // PT5M\nexport const ISSUANCE_WINDOW = 24 * 3_600_000 // PT24H\nexport const SKEW_TOLERANCE = 5 * 60_000 // PT5M\n\nconst VAL = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => VAL.validate(data, SCHEMAS[file], SCHEMAS[file]).length === 0\n\n/** Whole seconds (2.3). */\nconst sec = (ms: number): number => Math.floor(ms / 1000)\nconst secIso = (t: string): number => Math.floor(Date.parse(t) / 1000)\n/** 5.5's explicit future check: t_ch ≤ now + skew, whole seconds. */\nexport const futureOk = (tCh: number, now: number): boolean => sec(tCh) <= sec(now) + SKEW_TOLERANCE / 1000\n/** Is a challenge issued at tCh past its age bound at `now` (5190)? */\nexport const challengeAged = (tCh: number, now: number): boolean => sec(now) > sec(tCh) + (CHALLENGE_MAX_AGE + SKEW_TOLERANCE) / 1000\n/** The producer's mirror of 5.6 step 6: may a credential binding a\n * challenge issued at tChMs still be issued now? */\nexport const issuanceOpen = (tChMs: number, now: number): boolean => {\n const skew = SKEW_TOLERANCE / 1000\n return sec(now) >= sec(tChMs) - skew && sec(now) <= sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n}\n/** The last millisecond a credential binding a challenge issued at tChMs may carry (5.6 step 6). */\nexport const issuanceEnd = (tChMs: number): number => (sec(tChMs) + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW + SKEW_TOLERANCE) / 1000) * 1000 + 999\n\n/** Producer-side profile discipline (Delivery 3): UUID v4 ids and threads. */\nconst UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\nexport const uuidOk = (v: unknown): boolean => typeof v === 'string' && UUID_V4.test(v)\n\nexport const CARD_SCHEMA = 'contact-card-0.25.schema.json'\n/** A card for an enactment (Encounter 6): schema-valid, its version known,\n * a challenge, calendar-valid times, keys that decode, the proof under the\n * anchor. null when it passes, else the reason. */\nexport async function cardOk (card: any, subtle?: SubtleCrypto): Promise<string | null> {\n if (!schemaOk(CARD_SCHEMA, card)) return 'card fails contact-card-0.25 schema'\n if (card.version !== CARD_VERSION) return 'card version unknown'\n if (!card.challenge) return 'card without challenge (enactment use requires one)'\n if (!calOK(card.challenge.issuedAt) || !calOK(card.proof?.created)) return 'card: calendar-invalid timestamp'\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return 'card keyAgreement does not decode (x25519-pub + 32 bytes, 2.3)'\n if (!(await diVerify(card, card.anchor, subtle))) return 'card proof'\n return null\n}\n\n/** The 5.6 rejection codes. */\nexport type CredError = 'ERR_VERSION' | 'ERR_SIG' | 'ERR_ADDRESSEE' | 'ERR_NO_RECORD' | 'ERR_CEREMONY' | 'ERR_STALE_ISSUANCE' | 'ERR_BINDING' | 'ERR_CONFLICT'\n\n/** 5.6 step 1, format: a KNOWN format validated against ITS schema (0.26,\n * or a held 0.25 — 7.3, 12), ceremony and version known, calendar-valid\n * times, the digest a multihash, keys that decode (2.3). `ceremonyHere`:\n * 5.6 checks the ceremony at step 1; a bundle checks it at Delivery 4.1's\n * check 5. */\nexport function credFormat (cred: any, ceremonyHere = true): CredError | null {\n const schema = credentialSchemaOf(cred)\n if (schema === null || !schemaOk(schema, cred)) return 'ERR_VERSION'\n if (ceremonyHere && cred.credentialSubject.ceremony !== CEREMONY) return 'ERR_VERSION'\n if (!calOK(cred.validFrom) || !calOK(cred.proof?.created)) return 'ERR_VERSION'\n if (!sameDigest(cred.credentialSubject.enactmentBinding, cred.credentialSubject.enactmentBinding)) return 'ERR_VERSION'\n if (!edRawOfAnchor(cred.issuer) || !edRawOfAnchor(cred.credentialSubject.id)) return 'ERR_VERSION'\n const vm = String(cred.proof?.verificationMethod ?? ''), hash = vm.indexOf('#')\n if (hash < 0 || !edRawOfAnchor(vm.slice(0, hash)) || !edRawOfAnchor('did:key:' + vm.slice(hash + 1))) return 'ERR_VERSION'\n return null\n}\n\n/** 5.6 steps 1–3: format, signature, addressee (`localAnchor`). */\nexport async function credHead (cred: any, localAnchor: string, ceremonyHere = true, subtle?: SubtleCrypto): Promise<CredError | null> {\n const f = credFormat(cred, ceremonyHere)\n if (f) return f\n if (!(await diVerify(cred, cred.issuer, subtle))) return 'ERR_SIG'\n if (cred.credentialSubject.id !== localAnchor) return 'ERR_ADDRESSEE'\n return null\n}\n\n/** 5.6 step 6: the issuance window, whole seconds, inclusive, skew widens. */\nexport function windowOk (cred: any, tChMs: number): boolean {\n const tCh = sec(tChMs), vf = secIso(cred.validFrom), cr = secIso(cred.proof.created), skew = SKEW_TOLERANCE / 1000\n const lo = tCh - skew, hi = tCh + (CHALLENGE_MAX_AGE + ISSUANCE_WINDOW) / 1000 + skew\n return !(vf < lo || vf > hi || cr < lo || cr > hi || cr < vf - skew)\n}\n\n/** What 5.6 steps 4–7 read of a record. */\nexport interface RecordFacts { counterpart: string, ceremony: string, tCh: number, bind: string }\n\n/** 5.6 steps 4–7 against a record, synchronous. `order`: 'credential' —\n * 5.6: record, ceremony, window, binding; 'bundle' — Delivery 4.1:\n * record, ceremony, binding, window. */\nexport function acceptTail (cred: any, rec: RecordFacts | undefined, order: 'credential' | 'bundle'): CredError | null {\n if (!rec || rec.counterpart !== cred.issuer) return 'ERR_NO_RECORD'\n if (cred.credentialSubject.ceremony !== rec.ceremony) return 'ERR_CEREMONY'\n const bindOk = sameDigest(cred.credentialSubject.enactmentBinding, rec.bind)\n if (order === 'bundle' && !bindOk) return 'ERR_BINDING'\n if (!windowOk(cred, rec.tCh)) return 'ERR_STALE_ISSUANCE'\n if (!bindOk) return 'ERR_BINDING'\n return null\n}\n\n/** Delivery 4.1/4.3: ERR_STALE_ISSUANCE is stale-issuance, every other\n * rejection validation-failed. */\nexport const dispositionOf = (e: CredError): 'stale-issuance' | 'validation-failed' => (e === 'ERR_STALE_ISSUANCE' ? 'stale-issuance' : 'validation-failed')\n\n/**\n * The bundle's context-free checks of Delivery 4.1 check 1 (stage 8,\n * after the payload schema): calendars, the outer/inner equalities, the\n * sent card's binding, a present ceremony.enactment, the card's version\n * and keys, the credential's format (its ceremony at check 5). null when\n * they pass, else the reason, with the 4.1 disposition.\n */\nexport function bundleForm (doc: any): { reason: 'validation-failed' | 'stale-issuance', why: string } | null {\n const { card, credential } = doc.payload\n const v = (why: string) => ({ reason: 'validation-failed' as const, why })\n if (!calOK(doc.issuedAt) || !calOK(card.challenge?.issuedAt) || !calOK(card.proof?.created)) return v('calendar-invalid issuedAt')\n if (doc.issuer !== card.anchor || card.anchor !== credential.issuer) return v('outer binding (issuer = card.anchor = credential.issuer)')\n if (credential.credentialSubject?.id !== doc.recipient) return v('outer binding (recipient = subject)')\n if (card.sentTo !== doc.recipient || card.boundTo !== credential.credentialSubject.challenge) return v('sent card binding (sentTo/boundTo)')\n if (card.challenge.value === card.boundTo) return v('sent challenge equals the displayed challenge (5.3)')\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, credential.credentialSubject.enactmentBinding)) return v('ceremony.enactment recomputes not')\n if (card.version !== CARD_VERSION || !card.challenge) return v('card version/challenge')\n if (!xRawOfMk(card.keyAgreement) || !edRawOfAnchor(card.anchor)) return v('card keys do not decode')\n const f = credFormat(credential, false)\n if (f) return { reason: dispositionOf(f), why: f }\n return null\n}\n\n/** The credential delivery's outer/inner consistency (Delivery 4.3). */\nexport function deliveryForm (doc: any): string | null {\n const cred = doc.payload.credential\n if (!calOK(doc.issuedAt)) return 'calendar-invalid issuedAt'\n if (doc.issuer !== cred.issuer) return 'outer binding (issuer = credential.issuer)'\n if (cred.credentialSubject?.id !== doc.recipient) return 'outer binding (recipient = subject)'\n if (doc.ceremony?.enactment !== undefined && !sameDigest(doc.ceremony.enactment, cred.credentialSubject.enactmentBinding)) return 'ceremony.enactment recomputes not'\n return null\n}\n"]}
|
package/dist/holder-api.d.ts
CHANGED
|
@@ -26,6 +26,17 @@ export interface HumanActOptions {
|
|
|
26
26
|
when: Millis;
|
|
27
27
|
actId: string;
|
|
28
28
|
}
|
|
29
|
+
/** A carrier offer for the card of show or scan: the relationship's
|
|
30
|
+
* carrier nonce N, 32 bytes the app draws fresh (Identity §7a.3), and the
|
|
31
|
+
* delivery hints it built from N for the card (at least one; Encounter
|
|
32
|
+
* 6090: at most eight, each at most 512 characters; their form is the carrier
|
|
33
|
+
* profile's, e.g. the VTI mediator adapter profile §1b). The library
|
|
34
|
+
* signs the hints into the card, records N in the register under the
|
|
35
|
+
* relationship the card opens, and interprets neither. */
|
|
36
|
+
export interface CarrierOffer {
|
|
37
|
+
nonce: Uint8Array;
|
|
38
|
+
deliveryHints: readonly string[];
|
|
39
|
+
}
|
|
29
40
|
export interface Holder {
|
|
30
41
|
/** any registered command by name, for modules and tests; apps use the typed acts */
|
|
31
42
|
act(command: string, input: unknown, when: Millis, opts?: {
|
|
@@ -70,15 +81,20 @@ export interface Holder {
|
|
|
70
81
|
/** a displayed card with a fresh own challenge under a fresh pair
|
|
71
82
|
* anchor (Encounter 5.3, 4.4): the event encounter.shown carries the
|
|
72
83
|
* card to display; `name` the card's display name (default: the own
|
|
73
|
-
* profile's);
|
|
84
|
+
* profile's); `carrier` the delivery hints the card carries and the
|
|
85
|
+
* carrier nonce of the relationship it opens (card-invalid with ref
|
|
86
|
+
* RLTP-ENC-6090, carrier-nonce-invalid); human */
|
|
74
87
|
show(opts: HumanActOptions & {
|
|
75
88
|
name?: string;
|
|
89
|
+
carrier?: CarrierOffer;
|
|
76
90
|
}): Promise<ActResult>;
|
|
77
91
|
/** the scanner's step on a displayed card (Encounter 5.8): the record,
|
|
78
92
|
* the fresh tuple, the bundle; encounter.scanned carries the sent card
|
|
79
|
-
* for the optical leg;
|
|
93
|
+
* for the optical leg; `carrier` as with show, its hints in the sent
|
|
94
|
+
* card; human */
|
|
80
95
|
scan(card: Json, opts: HumanActOptions & {
|
|
81
96
|
name?: string;
|
|
97
|
+
carrier?: CarrierOffer;
|
|
82
98
|
}): Promise<ActResult>;
|
|
83
99
|
/** the optical leg (Encounter 5.8, 5710): a sent card shown by the scanner; human */
|
|
84
100
|
captureSentCard(card: Json, opts: HumanActOptions): Promise<ActResult>;
|
package/dist/holder-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holder-api.d.ts","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAkGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAQxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAOnG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"holder-api.d.ts","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAkGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAQxF,OAAO,KAAK,EAAE,eAAe,EAA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IAC3D,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED;;;wDAGwD;AACxD,wBAAsB,YAAY,CAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2EjG"}
|
package/dist/holder-api.js
CHANGED
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
// revokeDevice(name, opts) identity.revokeDevice human
|
|
35
35
|
// rotateAnchor(opts) identity.rotate human
|
|
36
36
|
// setProfile({name, image?, text?}, opts) profile.set human
|
|
37
|
-
// show(opts{name?})
|
|
38
|
-
// scan(card, opts{name?})
|
|
37
|
+
// show(opts{name?, carrier?}) encounter.show human
|
|
38
|
+
// scan(card, opts{name?, carrier?}) encounter.scan human
|
|
39
39
|
// captureSentCard(card, opts) encounter.capture human
|
|
40
40
|
// counter(contactId, opts) encounter.counter human
|
|
41
41
|
// foundGroup({name, vouchThreshold?, listed?}, opts) membership.found human
|
|
@@ -109,7 +109,13 @@ import { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js';
|
|
|
109
109
|
import { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js';
|
|
110
110
|
import { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js';
|
|
111
111
|
import { MESSAGE_COMMANDS, messageModule } from './message/holder.js';
|
|
112
|
+
import { b64uOf } from './core.js';
|
|
112
113
|
import { contactView, contactsView, deliveryStatusView, groupsView, inboxView, profileView, promptsView } from './views.js';
|
|
114
|
+
/** The offer as act input: N in canonical base64url (bound and journaled with the act). */
|
|
115
|
+
const offerInput = (c) => c === undefined ? undefined : {
|
|
116
|
+
nonce: c?.nonce instanceof Uint8Array ? b64uOf(c.nonce) : null,
|
|
117
|
+
deliveryHints: Array.isArray(c?.deliveryHints) ? [...c.deliveryHints] : null,
|
|
118
|
+
};
|
|
113
119
|
/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.
|
|
114
120
|
* The crypto handle (default globalThis.crypto) is resolved and probed
|
|
115
121
|
* here and also feeds the default entropy; an app that injects one
|
|
@@ -140,8 +146,14 @@ export async function createHolder(ports, opts = {}) {
|
|
|
140
146
|
recover: (o) => engine.act(TRUST_COMMANDS.recover, {}, o?.when),
|
|
141
147
|
rotateAnchor: (o) => human(IDENTITY_COMMANDS.rotate, {}, o),
|
|
142
148
|
setProfile: (content, o) => human(PROFILE_SET, content, o),
|
|
143
|
-
show: (o) =>
|
|
144
|
-
|
|
149
|
+
show: (o) => {
|
|
150
|
+
const carrier = offerInput(o?.carrier);
|
|
151
|
+
return human(ENCOUNTER_COMMANDS.show, { ...(o?.name === undefined ? {} : { name: o.name }), ...(carrier === undefined ? {} : { carrier }) }, o);
|
|
152
|
+
},
|
|
153
|
+
scan: (card, o) => {
|
|
154
|
+
const carrier = offerInput(o?.carrier);
|
|
155
|
+
return human(ENCOUNTER_COMMANDS.scan, { card, ...(o?.name === undefined ? {} : { name: o.name }), ...(carrier === undefined ? {} : { carrier }) }, o);
|
|
156
|
+
},
|
|
145
157
|
captureSentCard: (card, o) => human(ENCOUNTER_COMMANDS.capture, { card }, o),
|
|
146
158
|
counter: (contactId, o) => human(ENCOUNTER_COMMANDS.counter, { contactId }, o),
|
|
147
159
|
foundGroup: (g, o) => human(MEMBERSHIP_COMMANDS.found, g, o),
|
package/dist/holder-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holder-api.js","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,4EAA4E;AAC5E,wEAAwE;AACxE,sEAAsE;AACtE,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,wIAAwI;AACxI,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,wEAAw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C,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC;QACnE,gBAAgB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACjE,WAAW,EAAE,CAAC,KAAqB,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC;QACrF,QAAQ,EAAE,CAAC,KAAqB,EAAE,IAAY,EAAE,KAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;QAC5G,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;QAC3B,IAAI,MAAM,KAAM,OAAO,MAAM,CAAC,MAAM,CAAA,CAAC,CAAC;KACvC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// holder-api — createHolder, the facade over the engine (lib Stage 2,\n// note §4.1, §4.5). Domain modules (identity, encounter, trust, continuity,\n// membership, profile) register with the engine as they graduate; today\n// the facade carries the engine's built-ins, the prompts module, the\n// encounter module (encounter/ceremony.ts: show, scan, the optical leg, the\n// counter-step, the bundle and the credential delivery), the membership\n// module (membership/holder.ts: founding, the prelude and invite, the\n// accept on a group-invite prompt, admission and welcome, evidence and\n// vouches; and the in-library Access over the holder's groups where no\n// Access port is given), the introduction module (introduction/holder.ts:\n// the three roles of Trust §8 and the mediator's start), the identity module (identity-state.ts: device names, the rotation), the trust\n// module (trust/mapping.ts: the Trust act, the class settings, the anchor\n// mapping's issuance and reception, the entry commit; trust/star.ts and\n// trust/group-star.ts: the star and the group star, reconciled on resume\n// and received with their assemblies; trust/entries.ts: merge, split and\n// departure; trust/continuity.ts: the probe, the continuity mapping and\n// the chaining; trust/profile.ts: profile@1) and the modules given.\n//\n// The human acts (note §4.2) are typed methods with an options object\n// `{when, actId}`; actId is required, minted by the app when the human\n// acts, and journaled with the act's result (a repeat with the same actId\n// replays it, another input under it is actid-conflict). They wrap `act`\n// with the trust module's command names, which stays for modules and\n// tests:\n// trust(contactId, opts) trust.set {on: true} human\n// untrust(contactId, opts) trust.set {on: false} human\n// pauseTrust(contactId, paused, opts) trust.pause human\n// setClass(contactId, cls, setting, opts) trust.setClass human\n// setGroupClass(contactId, groupId, setting, opts) trust.setGroupClass human\n// merge(contactIds, opts) trust.merge human\n// depart(contactId, opts{relationshipId?}) trust.depart human\n// decide(promptId, choice, opts) prompt.decide human\n// addDevice(name, opts) identity.addDevice human\n// revokeDevice(name, opts) identity.revokeDevice human\n// rotateAnchor(opts) identity.rotate human\n// setProfile({name, image?, text?}, opts) profile.set human\n// show(opts{name?}) encounter.show human\n// scan(card, opts{name?}) encounter.scan human\n// captureSentCard(card, opts) encounter.capture human\n// counter(contactId, opts) encounter.counter human\n// foundGroup({name, vouchThreshold?, listed?}, opts) membership.found human\n// invite(groupId, contactId, opts) membership.invite human\n// vouchFor(groupId, member, opts{provenance?}) membership.vouch human\n// introduce(requesterId, targetId, opts) introduction.introduce human\n// sendMessage(contactId, text, opts{replyTo?}) message.send human\n// block(contactId, opts) message.block {blocked: true} human\n// unblock(contactId, opts) message.block {blocked: false} human\n// recover({when}) trust.recover not human\n// takeMessages(ids, {when}) message.take not human\n// and the read deviceKey(name, contextLabel): the device key of a held,\n// unrevoked name under an own anchor context (identity-state.ts).\n// A missing actId is refused at runtime as actid-missing.\n//\n// One actId, one result: replay(actId, when) reads the journaled result of\n// any of the human acts above (its events: for sendMessage `message.sent`\n// with mid and digest; its commit time; its documents and whether a repeat\n// would hand them out at `when`), or answers unknown-act. It runs nothing\n// and commits nothing, needs no keys, and works on every opening over the\n// store. A repeat of the act under the same actId answers the same events\n// at any clock, across a lock and a new opening; the journal holds an act\n// for the retention max(P90D, retry.horizonMs) after its commit and after\n// the last step of each of its documents, in holder time (engine.ts),\n// after which the actId is unknown. An app that does not\n// know whether an act committed (a crash, an unknown-commit-outcome, a\n// lock) asks replay; on unknown-act the act did not commit or has left\n// the journal, and only the human decides to act anew.\n//\n// Reading: the views (views.ts) over one snapshot each, carrying its\n// commitSeq. `subscribe` announces every commit with its commitSeq and\n// events; the app re-reads the views it shows, and a view read after the\n// announcement is at that commitSeq or later.\n//\n// Delivery: `receive(env, when)` runs Delivery §6.2 in the core and\n// dispatches through the task register (receive.ts); `report` takes the\n// adapter's reports (on an ack's digest: accepted or delivered marks it\n// sent, failed gives it up, awaiting-transport records that the adapter\n// holds it); `resume` re-emits, runs due duties and re-emits unsent acks;\n// `tick` expires and retains (engine.ts).\n//\n// Custody (Delivery 0.83 RLTP-DEL-6120 to 6135): the holder keeps every\n// outbound document until a service takes it or the holder gives it up,\n// across a lock and the end of a process. One createHolder is one opening.\n// After its first resume, `pendingTransport(when)` names what is to be\n// handed over: the outbox items neither terminal nor accepted (held ones\n// included) and the unsent acks, each with its envelope, its first\n// submission and its deadline, none past it. A transport hands over only\n// such entries, through `handOver(entry, when, start)`: the check of\n// `mayHandOver` and the start of the deposit in one step of the holder's\n// queue, true only for an entry this opening issued that is still pending,\n// unchanged, before its deadline. A duplicate's stored ack past its retries\n// appears once as a `resend` entry (Delivery RLTP-DEL-6330). A document missing from the\n// view is no longer to be sent. `await close()` ends the opening at a lock or\n// the end of a process (resolved once the running operation finished, the\n// moment the next opening may start): every later call rejects with InfraError\n// 'closed', mayHandOver answers false, and nothing issued before\n// authorizes anything; the next opening is a new createHolder over the\n// same store, resumed first.\nimport { createEngine } from './engine.js'\nimport type { CommitListener, EnginePorts, HolderModule, TransportEntry, TransportRefusal, TransportView } from './engine.js'\nimport type { DeliveryReport } from './ports.js'\nimport { DECIDE, collectDecisions, promptsModule } from './prompts.js'\nimport type { ActResult, ReceiveResult, ReplayResult, ResumeResult } from './results.js'\nimport { InfraError } from './results.js'\nimport { commitViolations } from './invariants.js'\nimport type { CommitOp } from './invariants.js'\nimport type { HolderState } from './state.js'\nimport { toOpaque } from './state.js'\nimport { trustModule } from './trust/mapping.js'\nimport { IDENTITY_COMMANDS, deviceKeyOf, identityModule } from './identity-state.js'\nimport type { DeviceKeyResult } from './identity-state.js'\nimport { PROFILE_SET } from './trust/profile.js'\nimport type { ProfileContent } from './profile.js'\nimport type { Dec, Millis, OpaqueHolderState, PromptChoice, Setting, TrustClass } from './state.js'\nimport { TRUST_COMMANDS } from './trust/mapping.js'\nimport { ENTRY_COMMANDS } from './trust/entries.js'\nimport { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js'\nimport { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js'\nimport { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js'\nimport { MESSAGE_COMMANDS, messageModule } from './message/holder.js'\nimport type { Json } from './core.js'\nimport { contactView, contactsView, deliveryStatusView, groupsView, inboxView, profileView, promptsView } from './views.js'\nimport type { ContactView, DeliveryStatusView, GroupView, InboxMessageView, ProfileView, PromptView } from './views.js'\n\n/** The committed state and its commitSeq; the state is opaque (note §4.5):\n * apps read the views, store tooling may persist it. */\nexport interface HolderSnapshot { commitSeq: Dec, state: OpaqueHolderState }\n\nexport interface HolderOptions {\n /** domain modules to register beside the built-ins, the prompts and the trust module */\n modules?: readonly HolderModule[]\n /** testing mode: check the invariants of invariants.ts on every commit,\n * before the store's CAS; a violation throws InfraError\n * 'invariant-violated' (cause: the violations) and nothing commits */\n invariants?: boolean\n}\n\n/** The options of a human act (note §4.2): its time and the actId the app\n * mints when the human acts. */\nexport interface HumanActOptions { when: Millis, actId: string }\n\nexport interface Holder {\n /** any registered command by name, for modules and tests; apps use the typed acts */\n act (command: string, input: unknown, when: Millis, opts?: { actId?: string }): Promise<ActResult>\n /** the human's decision on an open prompt: a human act under the app's\n * actId (note §4.2); a missing actId is also refused at runtime */\n decide (promptId: string, choice: PromptChoice, opts: HumanActOptions): Promise<ActResult>\n /** the Trust act: the anchor mapping class on toward the contact (2770); human */\n trust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** trust withdrawn: the anchor mapping class off (2840, 2850); human */\n untrust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the pause of 5.4: star and blinded group star off, or back to default; human */\n pauseTrust (contactId: string, paused: boolean, opts: HumanActOptions): Promise<ActResult>\n /** one class's setting toward the contact (2780, 2810); human */\n setClass (contactId: string, cls: TrustClass, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the sealed group star's setting for one group toward the contact (2830); human */\n setGroupClass (contactId: string, groupId: string, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the manual merge (6640): at most one of them holds an entry; human */\n merge (contactIds: string[], opts: HumanActOptions): Promise<ActResult>\n /** departure (2260): the entry, the relationships of an alias, or one\n * relationship (relationshipId); human */\n depart (contactId: string, opts: HumanActOptions & { relationshipId?: string }): Promise<ActResult>\n /** 2240: entries re-commit from verified mappings recovered without them; not human */\n recover (opts: { when: Millis }): Promise<ActResult>\n /** a device name into the register before any key derived from it is presented (Identity §5.5); human */\n addDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the name's revocation mark: never removed, the name never given again (Identity §5.5); human */\n revokeDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the community anchor's rotation (Identity §5.4): step 1 (label,\n * closure, 6596 decided) when none runs, else step 2 of the running one\n * through the Log port; resume carries step 2 on its own (identity-state.ts) */\n rotateAnchor (opts: HumanActOptions): Promise<ActResult>\n /** the own profile (Trust 6b): validated (6430, 6435, 6475), the next\n * revision of the one counter (6450), delivered on every relationship\n * the profile class is on for (6455); human */\n setProfile (content: ProfileContent, opts: HumanActOptions): Promise<ActResult>\n /** a displayed card with a fresh own challenge under a fresh pair\n * anchor (Encounter 5.3, 4.4): the event encounter.shown carries the\n * card to display; `name` the card's display name (default: the own\n * profile's); human */\n show (opts: HumanActOptions & { name?: string }): Promise<ActResult>\n /** the scanner's step on a displayed card (Encounter 5.8): the record,\n * the fresh tuple, the bundle; encounter.scanned carries the sent card\n * for the optical leg; human */\n scan (card: Json, opts: HumanActOptions & { name?: string }): Promise<ActResult>\n /** the optical leg (Encounter 5.8, 5710): a sent card shown by the scanner; human */\n captureSentCard (card: Json, opts: HumanActOptions): Promise<ActResult>\n /** the counter-step toward a contact met as displayer (Encounter 5.8 step 4); human */\n counter (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** a group founded under a fresh pair anchor (Access 3.4.1); its rule\n * vouchThreshold (default \"1\") is group state; event group.founded; human */\n foundGroup (group: { name: string, vouchThreshold?: string, listed?: boolean }, opts: HumanActOptions): Promise<ActResult>\n /** invite a contact into a group: the prelude, then the invite on its\n * answer (Membership 1.2, 3.1); the contact decides on a group-invite\n * prompt; human */\n invite (groupId: string, contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the mediator's act (Trust §8, this library's start of it): the\n * requester gets an offer naming the target by an opaque designator and\n * at most the `label` the human types here, with the mediator's\n * ack-delay declaration; the requester decides on an\n * `introduction` prompt, the target on another; human */\n introduce (requesterId: string, targetId: string, opts: HumanActOptions & { label?: string }): Promise<ActResult>\n /** a vouch@2 for a member anchor whose consent pair this holder holds\n * (Access 5.3, Membership 3.4); human */\n vouchFor (groupId: string, member: string, opts: HumanActOptions & { provenance?: 'met' | 'introduced' }): Promise<ActResult>\n /** a text message to the contact (Message Tasks 3, 5): 1 to 4096 code\n * points, replyTo the mid of an earlier message of the relationship. It\n * goes on a ready, unblocked relationship (canMessage); otherwise refused\n * as not-ready, blocked or no-own-channel, and the app keeps it unsent.\n * Event message.sent {mid, digest}; deliveryStatus(digest) is its sender\n * status. Undelivered, it ends as failed(expired-by-adapter-policy) at\n * the retry horizon (P7D by default, P90D at most), before its sender\n * lifetime sentAt + P179D: failed(task-expired) is not reached for a\n * message under any horizon the engine admits; human */\n sendMessage (contactId: string, text: string, opts: HumanActOptions & { replyTo?: string }): Promise<ActResult>\n /** the inbox entries the app has durably taken over leave the inbox\n * (4420); their completion record stays (4350); not human */\n takeMessages (ids: string[], opts: { when: Millis }): Promise<ActResult>\n /** the block (Message Tasks 6): set on every relationship of the\n * contact's entry. Messages, invitations and the holder's own offers on\n * them stop; the protocol steps owed continue; the contact observes\n * nothing it would not without the block. Event contact.blocked; human */\n block (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the block cleared on every relationship of the entry: nothing that\n * was discarded under it reappears (6510); human */\n unblock (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the device key of a held, unrevoked device name under an own anchor\n * context (Identity §5.5); reads, changes nothing */\n deviceKey (name: string, contextLabel: string): Promise<DeviceKeyResult>\n tick (when: Millis): Promise<ActResult>\n resume (when: Millis): Promise<ResumeResult>\n report (report: DeliveryReport, when: Millis): Promise<ActResult>\n /** an arriving envelope, as the app's transport delivered it (non-human,\n * no actId; idempotent over the document digest) */\n receive (env: unknown, when: Millis): Promise<ReceiveResult>\n /** after every commit: its commitSeq and events, the cue to re-read the views */\n subscribe (listener: CommitListener): () => void\n snapshot (): Promise<HolderSnapshot>\n contacts (): Promise<ContactView[]>\n /** by entry id or alias */\n contact (id: string): Promise<ContactView | undefined>\n groups (): Promise<GroupView[]>\n profile (): Promise<ProfileView>\n prompts (): Promise<PromptView[]>\n /** the messages accepted and not yet taken over (Message Tasks 4.5),\n * by display time; event message.received announces each */\n inbox (): Promise<InboxMessageView[]>\n /** by document digest or threadId */\n deliveryStatus (digestOrThreadId: string): Promise<DeliveryStatusView>\n /** the journaled result of the human act `actId` (any of the acts above:\n * for sendMessage its `message.sent` event with `mid` and `digest`), or\n * `{ok: false, code: 'unknown-act'}`; a pure read that never runs the\n * act, never mints a mid, commits nothing. The question an app asks\n * after a crash or a lock instead of repeating the act blind */\n replay (actId: string, when: Millis): Promise<ReplayResult>\n /** what the holder keeps for transport at `when`, after this opening's\n * first completed resume (else `{ok: false, code: 'not-resumed'}`) */\n pendingTransport (when: Millis): Promise<TransportView | TransportRefusal>\n /** right before a hand-over: whether this opening's `entry` may go now */\n mayHandOver (entry: TransportEntry, when: Millis): Promise<boolean>\n /** the hand-over: the same check, then `start()` (which starts the\n * deposit synchronously and says whether it did) inside the holder's\n * queue; true when both said yes */\n handOver (entry: TransportEntry, when: Millis, start: () => boolean): Promise<boolean>\n /** ends this opening (a lock, the end of a process); resolves once the\n * operation running at the call has finished: after that the opening\n * commits nothing more, and the next opening may start */\n close (): Promise<void>\n readonly closed: boolean\n}\n\n/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.\n * The crypto handle (default globalThis.crypto) is resolved and probed\n * here and also feeds the default entropy; an app that injects one\n * passes the same handle to seedKeys(seed, crypto). */\nexport async function createHolder (ports: EnginePorts, opts: HolderOptions = {}): Promise<Holder> {\n const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), messageModule(), ...(opts.modules ?? [])]\n const check = opts.invariants === true\n ? (before: Readonly<HolderState>, after: Readonly<HolderState>, op: CommitOp) => {\n const v = commitViolations(before, after, op)\n if (v.length) throw new InfraError('invariant-violated', `invariants broken by ${op.kind}: ${v.map((x) => `[${x.invariant}] ${x.detail}`).join('; ')}`, { cause: v })\n }\n : undefined\n const engine = await createEngine(ports, [promptsModule(collectDecisions(modules)), ...modules], { ...(check ? { check } : {}), accessFrom: localAccess })\n const read = async () => (await engine.snapshot()).state\n /** a human act: `when` and actId from the options, a missing actId refused by the engine */\n const human = (command: string, input: unknown, o: HumanActOptions | undefined) =>\n engine.act(command, input, o?.when as Millis, o?.actId === undefined ? {} : { actId: o.actId })\n return Object.freeze({\n act: (command: string, input: unknown, when: Millis, o?: { actId?: string }) => engine.act(command, input, when, o),\n decide: (promptId: string, choice: PromptChoice, o: HumanActOptions) => human(DECIDE, { promptId, choice }, o),\n trust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: true }, o),\n untrust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: false }, o),\n pauseTrust: (contactId: string, paused: boolean, o: HumanActOptions) => human(TRUST_COMMANDS.pause, { contactId, paused }, o),\n setClass: (contactId: string, cls: TrustClass, setting: Setting, o: HumanActOptions) => human(TRUST_COMMANDS.setClass, { contactId, cls, setting }, o),\n setGroupClass: (contactId: string, groupId: string, setting: Setting, o: HumanActOptions) =>\n human(TRUST_COMMANDS.setGroupClass, { contactId, groupId, setting }, o),\n merge: (contactIds: string[], o: HumanActOptions) => human(ENTRY_COMMANDS.merge, { contactIds }, o),\n depart: (contactId: string, o: HumanActOptions & { relationshipId?: string }) =>\n human(ENTRY_COMMANDS.depart, o?.relationshipId === undefined ? { contactId } : { contactId, relationshipId: o.relationshipId }, o),\n recover: (o: { when: Millis }) => engine.act(TRUST_COMMANDS.recover, {}, o?.when as Millis),\n rotateAnchor: (o: HumanActOptions) => human(IDENTITY_COMMANDS.rotate, {}, o),\n setProfile: (content: ProfileContent, o: HumanActOptions) => human(PROFILE_SET, content, o),\n show: (o: HumanActOptions & { name?: string }) => human(ENCOUNTER_COMMANDS.show, o?.name === undefined ? {} : { name: o.name }, o),\n scan: (card: Json, o: HumanActOptions & { name?: string }) => human(ENCOUNTER_COMMANDS.scan, o?.name === undefined ? { card } : { card, name: o.name }, o),\n captureSentCard: (card: Json, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.capture, { card }, o),\n counter: (contactId: string, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.counter, { contactId }, o),\n foundGroup: (g: { name: string, vouchThreshold?: string, listed?: boolean }, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.found, g, o),\n invite: (groupId: string, contactId: string, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.invite, { groupId, contactId }, o),\n vouchFor: (groupId: string, member: string, o: HumanActOptions & { provenance?: 'met' | 'introduced' }) =>\n human(MEMBERSHIP_COMMANDS.vouch, o?.provenance === undefined ? { groupId, member } : { groupId, member, provenance: o.provenance }, o),\n introduce: (requesterId: string, targetId: string, o: HumanActOptions & { label?: string }) =>\n human(INTRODUCTION_COMMANDS.introduce, o?.label === undefined ? { requesterId, targetId } : { requesterId, targetId, label: o.label }, o),\n sendMessage: (contactId: string, text: string, o: HumanActOptions & { replyTo?: string }) =>\n human(MESSAGE_COMMANDS.send, o?.replyTo === undefined ? { contactId, text } : { contactId, text, replyTo: o.replyTo }, o),\n takeMessages: (ids: string[], o: { when: Millis }) => engine.act(MESSAGE_COMMANDS.take, { ids }, o?.when as Millis),\n block: (contactId: string, o: HumanActOptions) => human(MESSAGE_COMMANDS.block, { contactId, blocked: true }, o),\n unblock: (contactId: string, o: HumanActOptions) => human(MESSAGE_COMMANDS.block, { contactId, blocked: false }, o),\n addDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.addDevice, { name }, o),\n revokeDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.revokeDevice, { name }, o),\n deviceKey: async (name: string, contextLabel: string) => deviceKeyOf(await read(), ports.keys, name, contextLabel),\n tick: (when: Millis) => engine.tick(when),\n resume: (when: Millis) => engine.resume(when),\n report: (report: DeliveryReport, when: Millis) => engine.report(report, when),\n receive: (env: unknown, when: Millis) => engine.receive(env, when),\n subscribe: (listener: CommitListener) => engine.subscribe(listener),\n snapshot: async (): Promise<HolderSnapshot> => {\n const s = await engine.snapshot()\n return Object.freeze({ commitSeq: s.commitSeq, state: toOpaque(s.state) })\n },\n contacts: async () => contactsView(await read()),\n contact: async (id: string) => contactView(await read(), id),\n groups: async () => groupsView(await read()),\n profile: async () => profileView(await read()),\n prompts: async () => promptsView(await read()),\n inbox: async () => inboxView(await read()),\n deliveryStatus: async (x: string) => deliveryStatusView(await read(), x),\n replay: (actId: string, when: Millis) => engine.replay(actId, when),\n pendingTransport: (when: Millis) => engine.pendingTransport(when),\n mayHandOver: (entry: TransportEntry, when: Millis) => engine.mayHandOver(entry, when),\n handOver: (entry: TransportEntry, when: Millis, start: () => boolean) => engine.handOver(entry, when, start),\n close: () => engine.close(),\n get closed () { return engine.closed },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"holder-api.js","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,4EAA4E;AAC5E,wEAAwE;A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AW,EAAE,CAAC,KAAqB,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC;QACrF,QAAQ,EAAE,CAAC,KAAqB,EAAE,IAAY,EAAE,KAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;QAC5G,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;QAC3B,IAAI,MAAM,KAAM,OAAO,MAAM,CAAC,MAAM,CAAA,CAAC,CAAC;KACvC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// holder-api — createHolder, the facade over the engine (lib Stage 2,\n// note §4.1, §4.5). Domain modules (identity, encounter, trust, continuity,\n// membership, profile) register with the engine as they graduate; today\n// the facade carries the engine's built-ins, the prompts module, the\n// encounter module (encounter/ceremony.ts: show, scan, the optical leg, the\n// counter-step, the bundle and the credential delivery), the membership\n// module (membership/holder.ts: founding, the prelude and invite, the\n// accept on a group-invite prompt, admission and welcome, evidence and\n// vouches; and the in-library Access over the holder's groups where no\n// Access port is given), the introduction module (introduction/holder.ts:\n// the three roles of Trust §8 and the mediator's start), the identity module (identity-state.ts: device names, the rotation), the trust\n// module (trust/mapping.ts: the Trust act, the class settings, the anchor\n// mapping's issuance and reception, the entry commit; trust/star.ts and\n// trust/group-star.ts: the star and the group star, reconciled on resume\n// and received with their assemblies; trust/entries.ts: merge, split and\n// departure; trust/continuity.ts: the probe, the continuity mapping and\n// the chaining; trust/profile.ts: profile@1) and the modules given.\n//\n// The human acts (note §4.2) are typed methods with an options object\n// `{when, actId}`; actId is required, minted by the app when the human\n// acts, and journaled with the act's result (a repeat with the same actId\n// replays it, another input under it is actid-conflict). They wrap `act`\n// with the trust module's command names, which stays for modules and\n// tests:\n// trust(contactId, opts) trust.set {on: true} human\n// untrust(contactId, opts) trust.set {on: false} human\n// pauseTrust(contactId, paused, opts) trust.pause human\n// setClass(contactId, cls, setting, opts) trust.setClass human\n// setGroupClass(contactId, groupId, setting, opts) trust.setGroupClass human\n// merge(contactIds, opts) trust.merge human\n// depart(contactId, opts{relationshipId?}) trust.depart human\n// decide(promptId, choice, opts) prompt.decide human\n// addDevice(name, opts) identity.addDevice human\n// revokeDevice(name, opts) identity.revokeDevice human\n// rotateAnchor(opts) identity.rotate human\n// setProfile({name, image?, text?}, opts) profile.set human\n// show(opts{name?, carrier?}) encounter.show human\n// scan(card, opts{name?, carrier?}) encounter.scan human\n// captureSentCard(card, opts) encounter.capture human\n// counter(contactId, opts) encounter.counter human\n// foundGroup({name, vouchThreshold?, listed?}, opts) membership.found human\n// invite(groupId, contactId, opts) membership.invite human\n// vouchFor(groupId, member, opts{provenance?}) membership.vouch human\n// introduce(requesterId, targetId, opts) introduction.introduce human\n// sendMessage(contactId, text, opts{replyTo?}) message.send human\n// block(contactId, opts) message.block {blocked: true} human\n// unblock(contactId, opts) message.block {blocked: false} human\n// recover({when}) trust.recover not human\n// takeMessages(ids, {when}) message.take not human\n// and the read deviceKey(name, contextLabel): the device key of a held,\n// unrevoked name under an own anchor context (identity-state.ts).\n// A missing actId is refused at runtime as actid-missing.\n//\n// One actId, one result: replay(actId, when) reads the journaled result of\n// any of the human acts above (its events: for sendMessage `message.sent`\n// with mid and digest; its commit time; its documents and whether a repeat\n// would hand them out at `when`), or answers unknown-act. It runs nothing\n// and commits nothing, needs no keys, and works on every opening over the\n// store. A repeat of the act under the same actId answers the same events\n// at any clock, across a lock and a new opening; the journal holds an act\n// for the retention max(P90D, retry.horizonMs) after its commit and after\n// the last step of each of its documents, in holder time (engine.ts),\n// after which the actId is unknown. An app that does not\n// know whether an act committed (a crash, an unknown-commit-outcome, a\n// lock) asks replay; on unknown-act the act did not commit or has left\n// the journal, and only the human decides to act anew.\n//\n// Reading: the views (views.ts) over one snapshot each, carrying its\n// commitSeq. `subscribe` announces every commit with its commitSeq and\n// events; the app re-reads the views it shows, and a view read after the\n// announcement is at that commitSeq or later.\n//\n// Delivery: `receive(env, when)` runs Delivery §6.2 in the core and\n// dispatches through the task register (receive.ts); `report` takes the\n// adapter's reports (on an ack's digest: accepted or delivered marks it\n// sent, failed gives it up, awaiting-transport records that the adapter\n// holds it); `resume` re-emits, runs due duties and re-emits unsent acks;\n// `tick` expires and retains (engine.ts).\n//\n// Custody (Delivery 0.83 RLTP-DEL-6120 to 6135): the holder keeps every\n// outbound document until a service takes it or the holder gives it up,\n// across a lock and the end of a process. One createHolder is one opening.\n// After its first resume, `pendingTransport(when)` names what is to be\n// handed over: the outbox items neither terminal nor accepted (held ones\n// included) and the unsent acks, each with its envelope, its first\n// submission and its deadline, none past it. A transport hands over only\n// such entries, through `handOver(entry, when, start)`: the check of\n// `mayHandOver` and the start of the deposit in one step of the holder's\n// queue, true only for an entry this opening issued that is still pending,\n// unchanged, before its deadline. A duplicate's stored ack past its retries\n// appears once as a `resend` entry (Delivery RLTP-DEL-6330). A document missing from the\n// view is no longer to be sent. `await close()` ends the opening at a lock or\n// the end of a process (resolved once the running operation finished, the\n// moment the next opening may start): every later call rejects with InfraError\n// 'closed', mayHandOver answers false, and nothing issued before\n// authorizes anything; the next opening is a new createHolder over the\n// same store, resumed first.\nimport { createEngine } from './engine.js'\nimport type { CommitListener, EnginePorts, HolderModule, TransportEntry, TransportRefusal, TransportView } from './engine.js'\nimport type { DeliveryReport } from './ports.js'\nimport { DECIDE, collectDecisions, promptsModule } from './prompts.js'\nimport type { ActResult, ReceiveResult, ReplayResult, ResumeResult } from './results.js'\nimport { InfraError } from './results.js'\nimport { commitViolations } from './invariants.js'\nimport type { CommitOp } from './invariants.js'\nimport type { HolderState } from './state.js'\nimport { toOpaque } from './state.js'\nimport { trustModule } from './trust/mapping.js'\nimport { IDENTITY_COMMANDS, deviceKeyOf, identityModule } from './identity-state.js'\nimport type { DeviceKeyResult } from './identity-state.js'\nimport { PROFILE_SET } from './trust/profile.js'\nimport type { ProfileContent } from './profile.js'\nimport type { Dec, Millis, OpaqueHolderState, PromptChoice, Setting, TrustClass } from './state.js'\nimport { TRUST_COMMANDS } from './trust/mapping.js'\nimport { ENTRY_COMMANDS } from './trust/entries.js'\nimport { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js'\nimport { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js'\nimport { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js'\nimport { MESSAGE_COMMANDS, messageModule } from './message/holder.js'\nimport type { Json } from './core.js'\nimport { b64uOf } from './core.js'\nimport { contactView, contactsView, deliveryStatusView, groupsView, inboxView, profileView, promptsView } from './views.js'\nimport type { ContactView, DeliveryStatusView, GroupView, InboxMessageView, ProfileView, PromptView } from './views.js'\n\n/** The committed state and its commitSeq; the state is opaque (note §4.5):\n * apps read the views, store tooling may persist it. */\nexport interface HolderSnapshot { commitSeq: Dec, state: OpaqueHolderState }\n\nexport interface HolderOptions {\n /** domain modules to register beside the built-ins, the prompts and the trust module */\n modules?: readonly HolderModule[]\n /** testing mode: check the invariants of invariants.ts on every commit,\n * before the store's CAS; a violation throws InfraError\n * 'invariant-violated' (cause: the violations) and nothing commits */\n invariants?: boolean\n}\n\n/** The options of a human act (note §4.2): its time and the actId the app\n * mints when the human acts. */\nexport interface HumanActOptions { when: Millis, actId: string }\n\n/** A carrier offer for the card of show or scan: the relationship's\n * carrier nonce N, 32 bytes the app draws fresh (Identity §7a.3), and the\n * delivery hints it built from N for the card (at least one; Encounter\n * 6090: at most eight, each at most 512 characters; their form is the carrier\n * profile's, e.g. the VTI mediator adapter profile §1b). The library\n * signs the hints into the card, records N in the register under the\n * relationship the card opens, and interprets neither. */\nexport interface CarrierOffer { nonce: Uint8Array, deliveryHints: readonly string[] }\n\n/** The offer as act input: N in canonical base64url (bound and journaled with the act). */\nconst offerInput = (c: CarrierOffer | undefined): Record<string, Json> | undefined => c === undefined ? undefined : {\n nonce: c?.nonce instanceof Uint8Array ? b64uOf(c.nonce) : null,\n deliveryHints: Array.isArray(c?.deliveryHints) ? [...c.deliveryHints] : null,\n}\n\nexport interface Holder {\n /** any registered command by name, for modules and tests; apps use the typed acts */\n act (command: string, input: unknown, when: Millis, opts?: { actId?: string }): Promise<ActResult>\n /** the human's decision on an open prompt: a human act under the app's\n * actId (note §4.2); a missing actId is also refused at runtime */\n decide (promptId: string, choice: PromptChoice, opts: HumanActOptions): Promise<ActResult>\n /** the Trust act: the anchor mapping class on toward the contact (2770); human */\n trust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** trust withdrawn: the anchor mapping class off (2840, 2850); human */\n untrust (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the pause of 5.4: star and blinded group star off, or back to default; human */\n pauseTrust (contactId: string, paused: boolean, opts: HumanActOptions): Promise<ActResult>\n /** one class's setting toward the contact (2780, 2810); human */\n setClass (contactId: string, cls: TrustClass, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the sealed group star's setting for one group toward the contact (2830); human */\n setGroupClass (contactId: string, groupId: string, setting: Setting, opts: HumanActOptions): Promise<ActResult>\n /** the manual merge (6640): at most one of them holds an entry; human */\n merge (contactIds: string[], opts: HumanActOptions): Promise<ActResult>\n /** departure (2260): the entry, the relationships of an alias, or one\n * relationship (relationshipId); human */\n depart (contactId: string, opts: HumanActOptions & { relationshipId?: string }): Promise<ActResult>\n /** 2240: entries re-commit from verified mappings recovered without them; not human */\n recover (opts: { when: Millis }): Promise<ActResult>\n /** a device name into the register before any key derived from it is presented (Identity §5.5); human */\n addDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the name's revocation mark: never removed, the name never given again (Identity §5.5); human */\n revokeDevice (name: string, opts: HumanActOptions): Promise<ActResult>\n /** the community anchor's rotation (Identity §5.4): step 1 (label,\n * closure, 6596 decided) when none runs, else step 2 of the running one\n * through the Log port; resume carries step 2 on its own (identity-state.ts) */\n rotateAnchor (opts: HumanActOptions): Promise<ActResult>\n /** the own profile (Trust 6b): validated (6430, 6435, 6475), the next\n * revision of the one counter (6450), delivered on every relationship\n * the profile class is on for (6455); human */\n setProfile (content: ProfileContent, opts: HumanActOptions): Promise<ActResult>\n /** a displayed card with a fresh own challenge under a fresh pair\n * anchor (Encounter 5.3, 4.4): the event encounter.shown carries the\n * card to display; `name` the card's display name (default: the own\n * profile's); `carrier` the delivery hints the card carries and the\n * carrier nonce of the relationship it opens (card-invalid with ref\n * RLTP-ENC-6090, carrier-nonce-invalid); human */\n show (opts: HumanActOptions & { name?: string, carrier?: CarrierOffer }): Promise<ActResult>\n /** the scanner's step on a displayed card (Encounter 5.8): the record,\n * the fresh tuple, the bundle; encounter.scanned carries the sent card\n * for the optical leg; `carrier` as with show, its hints in the sent\n * card; human */\n scan (card: Json, opts: HumanActOptions & { name?: string, carrier?: CarrierOffer }): Promise<ActResult>\n /** the optical leg (Encounter 5.8, 5710): a sent card shown by the scanner; human */\n captureSentCard (card: Json, opts: HumanActOptions): Promise<ActResult>\n /** the counter-step toward a contact met as displayer (Encounter 5.8 step 4); human */\n counter (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** a group founded under a fresh pair anchor (Access 3.4.1); its rule\n * vouchThreshold (default \"1\") is group state; event group.founded; human */\n foundGroup (group: { name: string, vouchThreshold?: string, listed?: boolean }, opts: HumanActOptions): Promise<ActResult>\n /** invite a contact into a group: the prelude, then the invite on its\n * answer (Membership 1.2, 3.1); the contact decides on a group-invite\n * prompt; human */\n invite (groupId: string, contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the mediator's act (Trust §8, this library's start of it): the\n * requester gets an offer naming the target by an opaque designator and\n * at most the `label` the human types here, with the mediator's\n * ack-delay declaration; the requester decides on an\n * `introduction` prompt, the target on another; human */\n introduce (requesterId: string, targetId: string, opts: HumanActOptions & { label?: string }): Promise<ActResult>\n /** a vouch@2 for a member anchor whose consent pair this holder holds\n * (Access 5.3, Membership 3.4); human */\n vouchFor (groupId: string, member: string, opts: HumanActOptions & { provenance?: 'met' | 'introduced' }): Promise<ActResult>\n /** a text message to the contact (Message Tasks 3, 5): 1 to 4096 code\n * points, replyTo the mid of an earlier message of the relationship. It\n * goes on a ready, unblocked relationship (canMessage); otherwise refused\n * as not-ready, blocked or no-own-channel, and the app keeps it unsent.\n * Event message.sent {mid, digest}; deliveryStatus(digest) is its sender\n * status. Undelivered, it ends as failed(expired-by-adapter-policy) at\n * the retry horizon (P7D by default, P90D at most), before its sender\n * lifetime sentAt + P179D: failed(task-expired) is not reached for a\n * message under any horizon the engine admits; human */\n sendMessage (contactId: string, text: string, opts: HumanActOptions & { replyTo?: string }): Promise<ActResult>\n /** the inbox entries the app has durably taken over leave the inbox\n * (4420); their completion record stays (4350); not human */\n takeMessages (ids: string[], opts: { when: Millis }): Promise<ActResult>\n /** the block (Message Tasks 6): set on every relationship of the\n * contact's entry. Messages, invitations and the holder's own offers on\n * them stop; the protocol steps owed continue; the contact observes\n * nothing it would not without the block. Event contact.blocked; human */\n block (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the block cleared on every relationship of the entry: nothing that\n * was discarded under it reappears (6510); human */\n unblock (contactId: string, opts: HumanActOptions): Promise<ActResult>\n /** the device key of a held, unrevoked device name under an own anchor\n * context (Identity §5.5); reads, changes nothing */\n deviceKey (name: string, contextLabel: string): Promise<DeviceKeyResult>\n tick (when: Millis): Promise<ActResult>\n resume (when: Millis): Promise<ResumeResult>\n report (report: DeliveryReport, when: Millis): Promise<ActResult>\n /** an arriving envelope, as the app's transport delivered it (non-human,\n * no actId; idempotent over the document digest) */\n receive (env: unknown, when: Millis): Promise<ReceiveResult>\n /** after every commit: its commitSeq and events, the cue to re-read the views */\n subscribe (listener: CommitListener): () => void\n snapshot (): Promise<HolderSnapshot>\n contacts (): Promise<ContactView[]>\n /** by entry id or alias */\n contact (id: string): Promise<ContactView | undefined>\n groups (): Promise<GroupView[]>\n profile (): Promise<ProfileView>\n prompts (): Promise<PromptView[]>\n /** the messages accepted and not yet taken over (Message Tasks 4.5),\n * by display time; event message.received announces each */\n inbox (): Promise<InboxMessageView[]>\n /** by document digest or threadId */\n deliveryStatus (digestOrThreadId: string): Promise<DeliveryStatusView>\n /** the journaled result of the human act `actId` (any of the acts above:\n * for sendMessage its `message.sent` event with `mid` and `digest`), or\n * `{ok: false, code: 'unknown-act'}`; a pure read that never runs the\n * act, never mints a mid, commits nothing. The question an app asks\n * after a crash or a lock instead of repeating the act blind */\n replay (actId: string, when: Millis): Promise<ReplayResult>\n /** what the holder keeps for transport at `when`, after this opening's\n * first completed resume (else `{ok: false, code: 'not-resumed'}`) */\n pendingTransport (when: Millis): Promise<TransportView | TransportRefusal>\n /** right before a hand-over: whether this opening's `entry` may go now */\n mayHandOver (entry: TransportEntry, when: Millis): Promise<boolean>\n /** the hand-over: the same check, then `start()` (which starts the\n * deposit synchronously and says whether it did) inside the holder's\n * queue; true when both said yes */\n handOver (entry: TransportEntry, when: Millis, start: () => boolean): Promise<boolean>\n /** ends this opening (a lock, the end of a process); resolves once the\n * operation running at the call has finished: after that the opening\n * commits nothing more, and the next opening may start */\n close (): Promise<void>\n readonly closed: boolean\n}\n\n/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.\n * The crypto handle (default globalThis.crypto) is resolved and probed\n * here and also feeds the default entropy; an app that injects one\n * passes the same handle to seedKeys(seed, crypto). */\nexport async function createHolder (ports: EnginePorts, opts: HolderOptions = {}): Promise<Holder> {\n const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), messageModule(), ...(opts.modules ?? [])]\n const check = opts.invariants === true\n ? (before: Readonly<HolderState>, after: Readonly<HolderState>, op: CommitOp) => {\n const v = commitViolations(before, after, op)\n if (v.length) throw new InfraError('invariant-violated', `invariants broken by ${op.kind}: ${v.map((x) => `[${x.invariant}] ${x.detail}`).join('; ')}`, { cause: v })\n }\n : undefined\n const engine = await createEngine(ports, [promptsModule(collectDecisions(modules)), ...modules], { ...(check ? { check } : {}), accessFrom: localAccess })\n const read = async () => (await engine.snapshot()).state\n /** a human act: `when` and actId from the options, a missing actId refused by the engine */\n const human = (command: string, input: unknown, o: HumanActOptions | undefined) =>\n engine.act(command, input, o?.when as Millis, o?.actId === undefined ? {} : { actId: o.actId })\n return Object.freeze({\n act: (command: string, input: unknown, when: Millis, o?: { actId?: string }) => engine.act(command, input, when, o),\n decide: (promptId: string, choice: PromptChoice, o: HumanActOptions) => human(DECIDE, { promptId, choice }, o),\n trust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: true }, o),\n untrust: (contactId: string, o: HumanActOptions) => human(TRUST_COMMANDS.set, { contactId, on: false }, o),\n pauseTrust: (contactId: string, paused: boolean, o: HumanActOptions) => human(TRUST_COMMANDS.pause, { contactId, paused }, o),\n setClass: (contactId: string, cls: TrustClass, setting: Setting, o: HumanActOptions) => human(TRUST_COMMANDS.setClass, { contactId, cls, setting }, o),\n setGroupClass: (contactId: string, groupId: string, setting: Setting, o: HumanActOptions) =>\n human(TRUST_COMMANDS.setGroupClass, { contactId, groupId, setting }, o),\n merge: (contactIds: string[], o: HumanActOptions) => human(ENTRY_COMMANDS.merge, { contactIds }, o),\n depart: (contactId: string, o: HumanActOptions & { relationshipId?: string }) =>\n human(ENTRY_COMMANDS.depart, o?.relationshipId === undefined ? { contactId } : { contactId, relationshipId: o.relationshipId }, o),\n recover: (o: { when: Millis }) => engine.act(TRUST_COMMANDS.recover, {}, o?.when as Millis),\n rotateAnchor: (o: HumanActOptions) => human(IDENTITY_COMMANDS.rotate, {}, o),\n setProfile: (content: ProfileContent, o: HumanActOptions) => human(PROFILE_SET, content, o),\n show: (o: HumanActOptions & { name?: string, carrier?: CarrierOffer }) => {\n const carrier = offerInput(o?.carrier)\n return human(ENCOUNTER_COMMANDS.show, { ...(o?.name === undefined ? {} : { name: o.name }), ...(carrier === undefined ? {} : { carrier }) }, o)\n },\n scan: (card: Json, o: HumanActOptions & { name?: string, carrier?: CarrierOffer }) => {\n const carrier = offerInput(o?.carrier)\n return human(ENCOUNTER_COMMANDS.scan, { card, ...(o?.name === undefined ? {} : { name: o.name }), ...(carrier === undefined ? {} : { carrier }) }, o)\n },\n captureSentCard: (card: Json, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.capture, { card }, o),\n counter: (contactId: string, o: HumanActOptions) => human(ENCOUNTER_COMMANDS.counter, { contactId }, o),\n foundGroup: (g: { name: string, vouchThreshold?: string, listed?: boolean }, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.found, g, o),\n invite: (groupId: string, contactId: string, o: HumanActOptions) => human(MEMBERSHIP_COMMANDS.invite, { groupId, contactId }, o),\n vouchFor: (groupId: string, member: string, o: HumanActOptions & { provenance?: 'met' | 'introduced' }) =>\n human(MEMBERSHIP_COMMANDS.vouch, o?.provenance === undefined ? { groupId, member } : { groupId, member, provenance: o.provenance }, o),\n introduce: (requesterId: string, targetId: string, o: HumanActOptions & { label?: string }) =>\n human(INTRODUCTION_COMMANDS.introduce, o?.label === undefined ? { requesterId, targetId } : { requesterId, targetId, label: o.label }, o),\n sendMessage: (contactId: string, text: string, o: HumanActOptions & { replyTo?: string }) =>\n human(MESSAGE_COMMANDS.send, o?.replyTo === undefined ? { contactId, text } : { contactId, text, replyTo: o.replyTo }, o),\n takeMessages: (ids: string[], o: { when: Millis }) => engine.act(MESSAGE_COMMANDS.take, { ids }, o?.when as Millis),\n block: (contactId: string, o: HumanActOptions) => human(MESSAGE_COMMANDS.block, { contactId, blocked: true }, o),\n unblock: (contactId: string, o: HumanActOptions) => human(MESSAGE_COMMANDS.block, { contactId, blocked: false }, o),\n addDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.addDevice, { name }, o),\n revokeDevice: (name: string, o: HumanActOptions) => human(IDENTITY_COMMANDS.revokeDevice, { name }, o),\n deviceKey: async (name: string, contextLabel: string) => deviceKeyOf(await read(), ports.keys, name, contextLabel),\n tick: (when: Millis) => engine.tick(when),\n resume: (when: Millis) => engine.resume(when),\n report: (report: DeliveryReport, when: Millis) => engine.report(report, when),\n receive: (env: unknown, when: Millis) => engine.receive(env, when),\n subscribe: (listener: CommitListener) => engine.subscribe(listener),\n snapshot: async (): Promise<HolderSnapshot> => {\n const s = await engine.snapshot()\n return Object.freeze({ commitSeq: s.commitSeq, state: toOpaque(s.state) })\n },\n contacts: async () => contactsView(await read()),\n contact: async (id: string) => contactView(await read(), id),\n groups: async () => groupsView(await read()),\n profile: async () => profileView(await read()),\n prompts: async () => promptsView(await read()),\n inbox: async () => inboxView(await read()),\n deliveryStatus: async (x: string) => deliveryStatusView(await read(), x),\n replay: (actId: string, when: Millis) => engine.replay(actId, when),\n pendingTransport: (when: Millis) => engine.pendingTransport(when),\n mayHandOver: (entry: TransportEntry, when: Millis) => engine.mayHandOver(entry, when),\n handOver: (entry: TransportEntry, when: Millis, start: () => boolean) => engine.handOver(entry, when, start),\n close: () => engine.close(),\n get closed () { return engine.closed },\n })\n}\n"]}
|
package/dist/identity-state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HolderModule } from './engine.js';
|
|
2
|
-
import type { Dec, HolderState, Register } from './state.js';
|
|
2
|
+
import type { CarrierNonce, Dec, HolderState, Register } from './state.js';
|
|
3
3
|
import type { KeyProvider } from './ports.js';
|
|
4
4
|
/** The identity module's command names. */
|
|
5
5
|
export declare const IDENTITY_COMMANDS: Readonly<{
|
|
@@ -17,6 +17,18 @@ export declare const withLabel: (r: Readonly<Register>, label: string) => Regist
|
|
|
17
17
|
/** The register with a pair label and its relationship nonce (Identity
|
|
18
18
|
* §6.1): the nonce is recorded alongside the label and never changes. */
|
|
19
19
|
export declare function withPairNonce(r: Readonly<Register>, label: string, nonce: string): Register;
|
|
20
|
+
/** Does the register hold `nonce` (canonical base64url) as a carrier
|
|
21
|
+
* nonce of any relationship, or as a pair nonce (Identity §7a.3: N is
|
|
22
|
+
* fresh and never a pair nonce)? */
|
|
23
|
+
export declare const carrierNonceHeld: (r: Readonly<Register>, nonce: string) => boolean;
|
|
24
|
+
/** The register with the first carrier-nonce entry of relationship
|
|
25
|
+
* `relId`, generation 1 (Identity §7a.3). A relationship that already
|
|
26
|
+
* holds an entry is not given a second one here: rotation is not this. */
|
|
27
|
+
export declare function withCarrierNonce(r: Readonly<Register>, relId: string, nonce: string): Register;
|
|
28
|
+
/** The canonical carrier-nonce entry of a relationship (Identity §7a.3):
|
|
29
|
+
* the highest generation, among equal ones the nonce whose bytes are
|
|
30
|
+
* smallest in unsigned bytewise order; undefined where none is held. */
|
|
31
|
+
export declare function canonicalCarrierNonce(r: Readonly<Register>, relId: string): CarrierNonce | undefined;
|
|
20
32
|
/** The rotation duty's id for a rotation. */
|
|
21
33
|
export declare const rotationDutyId: (rotationId: string) => string;
|
|
22
34
|
/** A re-issue duty's id after the rotation to generation `to` (6370). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-state.d.ts","sourceRoot":"","sources":["../src/identity-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity-state.d.ts","sourceRoot":"","sources":["../src/identity-state.ts"],"names":[],"mappings":"AA8FA,OAAO,KAAK,EAAoC,YAAY,EAAuB,MAAM,aAAa,CAAA;AACtG,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAQ,WAAW,EAAU,QAAQ,EAA8C,MAAM,YAAY,CAAA;AAEpI,OAAO,KAAK,EAAE,WAAW,EAAW,MAAM,YAAY,CAAA;AAMtD,2CAA2C;AAC3C,eAAO,MAAM,iBAAiB;;;;EAEnB,CAAA;AAEX,yEAAyE;AACzE,eAAO,MAAM,eAAe,QAA8B,CAAA;AAE1D,MAAM,WAAW,WAAW;IAAG,IAAI,EAAE,MAAM,CAAA;CAAE;AAE7C,sEAAsE;AACtE,eAAO,MAAM,SAAS,GAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,MAAM,KAAG,QACkB,CAAA;AAEnF;0EAC0E;AAC1E,wBAAgB,aAAa,CAAE,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,E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viceLabel, deviceName } from './identity.js';
|
|
2
|
-
import { jcs } from './core.js';
|
|
2
|
+
import { fromB64u, jcs } from './core.js';
|
|
3
3
|
import { bindingOf, rawProofValue } from './anchor.js';
|
|
4
4
|
import { classOnToward, entryOf, entryRelationships, lags, liveRel } from './trust/state.js';
|
|
5
5
|
/** The identity module's command names. */
|
|
@@ -20,6 +20,41 @@ export function withPairNonce(r, label, nonce) {
|
|
|
20
20
|
}
|
|
21
21
|
return { ...withLabel(r, label), pairNonces: { ...r.pairNonces, [label]: nonce } };
|
|
22
22
|
}
|
|
23
|
+
/** Does the register hold `nonce` (canonical base64url) as a carrier
|
|
24
|
+
* nonce of any relationship, or as a pair nonce (Identity §7a.3: N is
|
|
25
|
+
* fresh and never a pair nonce)? */
|
|
26
|
+
export const carrierNonceHeld = (r, nonce) => Object.values(r.carriers).some((list) => list.some((e) => e.nonce === nonce)) || Object.values(r.pairNonces).includes(nonce);
|
|
27
|
+
/** The register with the first carrier-nonce entry of relationship
|
|
28
|
+
* `relId`, generation 1 (Identity §7a.3). A relationship that already
|
|
29
|
+
* holds an entry is not given a second one here: rotation is not this. */
|
|
30
|
+
export function withCarrierNonce(r, relId, nonce) {
|
|
31
|
+
if (Object.hasOwn(r.carriers, relId))
|
|
32
|
+
throw new Error(`identity: ${relId} already holds a carrier nonce (§7a.3)`);
|
|
33
|
+
return { ...r, carriers: { ...r.carriers, [relId]: [{ nonce, generation: '1' }] } };
|
|
34
|
+
}
|
|
35
|
+
/** The canonical carrier-nonce entry of a relationship (Identity §7a.3):
|
|
36
|
+
* the highest generation, among equal ones the nonce whose bytes are
|
|
37
|
+
* smallest in unsigned bytewise order; undefined where none is held. */
|
|
38
|
+
export function canonicalCarrierNonce(r, relId) {
|
|
39
|
+
const list = Object.hasOwn(r.carriers, relId) ? r.carriers[relId] : [];
|
|
40
|
+
let best;
|
|
41
|
+
for (const e of list) {
|
|
42
|
+
if (!best) {
|
|
43
|
+
best = e;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const g = BigInt(e.generation) - BigInt(best.generation);
|
|
47
|
+
if (g > 0n || (g === 0n && bytewiseLess(fromB64u(e.nonce), fromB64u(best.nonce))))
|
|
48
|
+
best = e;
|
|
49
|
+
}
|
|
50
|
+
return best;
|
|
51
|
+
}
|
|
52
|
+
const bytewiseLess = (a, b) => {
|
|
53
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++)
|
|
54
|
+
if (a[i] !== b[i])
|
|
55
|
+
return a[i] < b[i];
|
|
56
|
+
return a.length < b.length;
|
|
57
|
+
};
|
|
23
58
|
const needName = (x, cmd) => {
|
|
24
59
|
if (x === null || typeof x !== 'object' || Array.isArray(x))
|
|
25
60
|
throw new TypeError(`${cmd} needs an input object`);
|