@real-life/trust-protocol 0.3.2 → 0.4.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 +32 -0
- package/README.md +187 -78
- package/dist/ack.d.ts +84 -0
- package/dist/ack.d.ts.map +1 -0
- package/dist/ack.js +114 -0
- package/dist/ack.js.map +1 -0
- package/dist/adapters/vti-mediator.d.ts +154 -0
- package/dist/adapters/vti-mediator.d.ts.map +1 -0
- package/dist/adapters/vti-mediator.js +621 -0
- package/dist/adapters/vti-mediator.js.map +1 -0
- package/dist/anchor.d.ts +226 -0
- package/dist/anchor.d.ts.map +1 -0
- package/dist/anchor.js +347 -0
- package/dist/anchor.js.map +1 -0
- package/dist/{holder.d.ts → carrier-holder.d.ts} +1 -1
- package/dist/carrier-holder.d.ts.map +1 -0
- package/dist/{holder.js → carrier-holder.js} +5 -4
- package/dist/carrier-holder.js.map +1 -0
- package/dist/carrier-identity.js +4 -4
- package/dist/carrier-identity.js.map +1 -1
- package/dist/carrier.d.ts.map +1 -1
- package/dist/carrier.js +4 -3
- package/dist/carrier.js.map +1 -1
- package/dist/ceremony.d.ts +3 -2
- package/dist/ceremony.d.ts.map +1 -1
- package/dist/ceremony.js +16 -26
- package/dist/ceremony.js.map +1 -1
- package/dist/codec.d.ts +46 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +410 -0
- package/dist/codec.js.map +1 -0
- package/dist/continuity.d.ts +67 -0
- package/dist/continuity.d.ts.map +1 -0
- package/dist/continuity.js +110 -0
- package/dist/continuity.js.map +1 -0
- package/dist/core.d.ts +4 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/crypto.d.ts +23 -7
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +54 -20
- package/dist/crypto.js.map +1 -1
- package/dist/delivery.d.ts +31 -3
- package/dist/delivery.d.ts.map +1 -1
- package/dist/delivery.js +75 -28
- package/dist/delivery.js.map +1 -1
- package/dist/encounter/ceremony.d.ts +37 -0
- package/dist/encounter/ceremony.d.ts.map +1 -0
- package/dist/encounter/ceremony.js +662 -0
- package/dist/encounter/ceremony.js.map +1 -0
- package/dist/encounter.d.ts +91 -1
- package/dist/encounter.d.ts.map +1 -1
- package/dist/encounter.js +191 -12
- package/dist/encounter.js.map +1 -1
- package/dist/engine.d.ts +291 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +1395 -0
- package/dist/engine.js.map +1 -0
- package/dist/entropy.d.ts +28 -0
- package/dist/entropy.d.ts.map +1 -0
- package/dist/entropy.js +96 -0
- package/dist/entropy.js.map +1 -0
- package/dist/events.d.ts +177 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/fixtures.d.ts +30 -0
- package/dist/fixtures.d.ts.map +1 -0
- package/dist/fixtures.js +155 -0
- package/dist/fixtures.js.map +1 -0
- package/dist/forge.d.ts +47 -0
- package/dist/forge.d.ts.map +1 -0
- package/dist/forge.js +20 -0
- package/dist/forge.js.map +1 -0
- package/dist/group-star.d.ts +251 -0
- package/dist/group-star.d.ts.map +1 -0
- package/dist/group-star.js +348 -0
- package/dist/group-star.js.map +1 -0
- package/dist/holder-api.d.ts +137 -0
- package/dist/holder-api.d.ts.map +1 -0
- package/dist/holder-api.js +132 -0
- package/dist/holder-api.js.map +1 -0
- package/dist/holder-state-v1.d.ts +801 -0
- package/dist/holder-state-v1.d.ts.map +1 -0
- package/dist/holder-state-v1.js +2 -0
- package/dist/holder-state-v1.js.map +1 -0
- package/dist/identity-state.d.ts +43 -0
- package/dist/identity-state.d.ts.map +1 -0
- package/dist/identity-state.js +345 -0
- package/dist/identity-state.js.map +1 -0
- package/dist/identity.d.ts +24 -2
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +70 -11
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +77 -29
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +36 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +22 -0
- package/dist/internal.js.map +1 -0
- package/dist/introduction/holder.d.ts +18 -0
- package/dist/introduction/holder.d.ts.map +1 -0
- package/dist/introduction/holder.js +757 -0
- package/dist/introduction/holder.js.map +1 -0
- package/dist/introduction.d.ts +101 -0
- package/dist/introduction.d.ts.map +1 -0
- package/dist/introduction.js +132 -0
- package/dist/introduction.js.map +1 -0
- package/dist/invariants.d.ts +43 -0
- package/dist/invariants.d.ts.map +1 -0
- package/dist/invariants.js +883 -0
- package/dist/invariants.js.map +1 -0
- package/dist/keys-seed.d.ts +7 -0
- package/dist/keys-seed.d.ts.map +1 -0
- package/dist/keys-seed.js +133 -0
- package/dist/keys-seed.js.map +1 -0
- package/dist/log-memory.d.ts +12 -0
- package/dist/log-memory.d.ts.map +1 -0
- package/dist/log-memory.js +101 -0
- package/dist/log-memory.js.map +1 -0
- package/dist/membership/holder.d.ts +35 -0
- package/dist/membership/holder.d.ts.map +1 -0
- package/dist/membership/holder.js +852 -0
- package/dist/membership/holder.js.map +1 -0
- package/dist/membership.d.ts +92 -0
- package/dist/membership.d.ts.map +1 -0
- package/dist/membership.js +157 -0
- package/dist/membership.js.map +1 -0
- package/dist/ports.d.ts +237 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +2 -0
- package/dist/ports.js.map +1 -0
- package/dist/profile.d.ts +56 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +193 -0
- package/dist/profile.js.map +1 -0
- package/dist/prompts.d.ts +14 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +69 -0
- package/dist/prompts.js.map +1 -0
- package/dist/receive.d.ts +133 -0
- package/dist/receive.d.ts.map +1 -0
- package/dist/receive.js +298 -0
- package/dist/receive.js.map +1 -0
- package/dist/results.d.ts +158 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +21 -0
- package/dist/results.js.map +1 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +42 -38
- package/dist/schemas.js.map +1 -1
- package/dist/sha256.d.ts +3 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +69 -0
- package/dist/sha256.js.map +1 -0
- package/dist/star.d.ts +31 -0
- package/dist/star.d.ts.map +1 -0
- package/dist/star.js +56 -0
- package/dist/star.js.map +1 -0
- package/dist/state-builder.d.ts +42 -0
- package/dist/state-builder.d.ts.map +1 -0
- package/dist/state-builder.js +100 -0
- package/dist/state-builder.js.map +1 -0
- package/dist/state.d.ts +853 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +36 -0
- package/dist/state.js.map +1 -0
- package/dist/store-contract.d.ts +11 -0
- package/dist/store-contract.d.ts.map +1 -0
- package/dist/store-contract.js +189 -0
- package/dist/store-contract.js.map +1 -0
- package/dist/store-memory.d.ts +8 -0
- package/dist/store-memory.d.ts.map +1 -0
- package/dist/store-memory.js +17 -0
- package/dist/store-memory.js.map +1 -0
- package/dist/testing.d.ts +22 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +21 -0
- package/dist/testing.js.map +1 -0
- package/dist/trust/continuity.d.ts +71 -0
- package/dist/trust/continuity.d.ts.map +1 -0
- package/dist/trust/continuity.js +1216 -0
- package/dist/trust/continuity.js.map +1 -0
- package/dist/trust/duties.d.ts +67 -0
- package/dist/trust/duties.d.ts.map +1 -0
- package/dist/trust/duties.js +179 -0
- package/dist/trust/duties.js.map +1 -0
- package/dist/trust/entries.d.ts +139 -0
- package/dist/trust/entries.d.ts.map +1 -0
- package/dist/trust/entries.js +694 -0
- package/dist/trust/entries.js.map +1 -0
- package/dist/trust/group-star.d.ts +43 -0
- package/dist/trust/group-star.d.ts.map +1 -0
- package/dist/trust/group-star.js +188 -0
- package/dist/trust/group-star.js.map +1 -0
- package/dist/trust/mapping.d.ts +56 -0
- package/dist/trust/mapping.d.ts.map +1 -0
- package/dist/trust/mapping.js +584 -0
- package/dist/trust/mapping.js.map +1 -0
- package/dist/trust/profile.d.ts +25 -0
- package/dist/trust/profile.d.ts.map +1 -0
- package/dist/trust/profile.js +249 -0
- package/dist/trust/profile.js.map +1 -0
- package/dist/trust/star.d.ts +208 -0
- package/dist/trust/star.d.ts.map +1 -0
- package/dist/trust/star.js +588 -0
- package/dist/trust/star.js.map +1 -0
- package/dist/trust/state.d.ts +83 -0
- package/dist/trust/state.d.ts.map +1 -0
- package/dist/trust/state.js +154 -0
- package/dist/trust/state.js.map +1 -0
- package/dist/util-freeze.d.ts +3 -0
- package/dist/util-freeze.d.ts.map +1 -0
- package/dist/util-freeze.js +11 -0
- package/dist/util-freeze.js.map +1 -0
- package/dist/views.d.ts +147 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +268 -0
- package/dist/views.js.map +1 -0
- package/dist/visibility.d.ts +5 -5
- package/dist/visibility.d.ts.map +1 -1
- package/dist/visibility.js +22 -28
- package/dist/visibility.js.map +1 -1
- package/dist/wire.d.ts +178 -84
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js.map +1 -1
- package/package.json +56 -10
- package/schemas/holder-state-v1.schema.json +3880 -0
- package/dist/holder.d.ts.map +0 -1
- package/dist/holder.js.map +0 -1
- package/dist/probe/acks.d.ts +0 -27
- package/dist/probe/acks.d.ts.map +0 -1
- package/dist/probe/acks.js +0 -152
- package/dist/probe/acks.js.map +0 -1
- package/dist/probe/continuity.d.ts +0 -20
- package/dist/probe/continuity.d.ts.map +0 -1
- package/dist/probe/continuity.js +0 -805
- package/dist/probe/continuity.js.map +0 -1
- package/dist/probe/deps.d.ts +0 -61
- package/dist/probe/deps.d.ts.map +0 -1
- package/dist/probe/deps.js +0 -54
- package/dist/probe/deps.js.map +0 -1
- package/dist/probe/encounter.d.ts +0 -26
- package/dist/probe/encounter.d.ts.map +0 -1
- package/dist/probe/encounter.js +0 -938
- package/dist/probe/encounter.js.map +0 -1
- package/dist/probe/introduce.d.ts +0 -62
- package/dist/probe/introduce.d.ts.map +0 -1
- package/dist/probe/introduce.js +0 -306
- package/dist/probe/introduce.js.map +0 -1
- package/dist/probe/membership.d.ts +0 -96
- package/dist/probe/membership.d.ts.map +0 -1
- package/dist/probe/membership.js +0 -467
- package/dist/probe/membership.js.map +0 -1
- package/dist/probe/trust.d.ts +0 -156
- package/dist/probe/trust.d.ts.map +0 -1
- package/dist/probe/trust.js +0 -1233
- package/dist/probe/trust.js.map +0 -1
- package/dist/probe.d.ts +0 -7
- package/dist/probe.d.ts.map +0 -1
- package/dist/probe.js +0 -42
- package/dist/probe.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-star.js","sourceRoot":"","sources":["../src/group-star.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,gCAAgC;AAChC,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,qCAAqC;AACrC,EAAE;AACF,yDAAyD;AACzD,4GAA4G;AAC5G,4BAA4B;AAC5B,uHAAuH;AACvH,8GAA8G;AAC9G,2CAA2C;AAC3C,uEAAuE;AACvE,2HAA2H;AAC3H,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,oEAAoE;AACpE,wEAAwE;AACxE,sEAAsE;AACtE,iDAAiD;AACjD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,MAAM,EAAE,GAAG,IAAI,WAAW,EAAE,CAAA;AAC5B,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;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K,UAAU,iBAAiB,CAAE,CAA0E;IACjH,OAAO,qBAAqB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;AACtI,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAE,CAA8I;IACjL,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC;QAClC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW;QAC9I,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;YAClC,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAA;YACtC,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QACrD,CAAC;KACF,CAAC,CAAA;IACF,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["// group-star — group-star@1, the sender's groups blinded to every\n// contact and sealed to the chosen ones (Trust Layer 0.31 §5.2b, task\n// group-star/0.1): the pure wire constructions over raw X25519 shared\n// secrets (lib Stage 2, PR 4b).\n//\n// Byte-identical with vectors/group-star.json (check:generators:lib). The\n// holder's trust module (trust/group-star.ts) builds on these functions\n// with secrets from its KeyProvider.\n//\n// k_g = HKDF(X25519(pairX_sender, pairX_recipient),\n// \"rltp/visibility/blind/group-star/\" || senderPair || \"/\" || recipientPair || \"/\" || salt)\n// k_e(G) = HKDF(same ikm,\n// \"rltp/visibility/seal/group-star/\" || senderPair || \"/\" || recipientPair || \"/\" || salt || \"/\" || G)\n// entry = { d: HMAC(k_g, UTF-8 of G), c: AES-256-GCM(k_e(G), nonce, AAD = bytes of d, JCS(group-pair@1)) }\n// proof = { mac: HMAC(k_g, JCS(body)) }\n// group-pair@1 = { type, group, member, memberOp, to, salt, proof },\n// proof = HMAC(HKDF(ECDH(memberX_sender, pairX_recipient), \"rltp/visibility/mac/group-pair\"), JCS(pair without proof))\n//\n// A `c` that is not a real pair is FILLER: random bytes of exactly the\n// length a real c has in this star. The list is padded with filler\n// entries to the next multiple of 16 (an empty list to 16: the all-\n// filler star), sorted by d once, and sliced in order into chunks of at\n// most 64 (5.2a). Entropy comes from the caller's `draw`, by kind, so\n// vectors replay; this module draws none itself.\nimport { jcs, makeValidator } from './core.js'\nimport { SCHEMAS } from './schemas.js'\nimport { b64uOf, ecdh, fromB64u, hkdf, platformSubtle, xRawOfMk } from './crypto.js'\nimport type { Context } from './identity.js'\nimport { macU } from './anchor.js'\n\nconst te = new TextEncoder()\nconst td = new TextDecoder('utf-8', { fatal: true })\nconst VAL = makeValidator(SCHEMAS)\nconst schemaOk = (file: string, data: unknown): boolean => VAL.validate(data, SCHEMAS[file]!, SCHEMAS[file]!).length === 0\n\n/** Entries are padded to the next positive multiple of this (§5.2b). */\nexport const GROUP_STAR_PAD = 16\n/**\n * Chunks hold at most 64 entries (§5.2b): a real entry is about 570\n * bytes JCS, so a full chunk stays well inside the Delivery Contract's\n * 65 536-byte plaintext bound at the longest salt.\n */\nexport const GROUP_STAR_CHUNK = 64\nconst NONCE = 12\nconst TAG = 16\n\n/** The kinds of randomness a group star draws: AEAD nonces of sealed\n * pairs, and filler (d and c of filler entries, c of unsealed ones). */\nexport type GroupStarRandKind = 'nonce' | 'filler'\n/** The caller's entropy: n fresh bytes of one kind. */\nexport type GroupStarDraw = (n: number, kind: GroupStarRandKind) => Uint8Array\n\nconst isZero = (b: Uint8Array): boolean => b.every((x) => x === 0)\n\n/** k_g of one direction from the pair secret: `sender` and `recipient` are the two pair anchors, salt in its wire string form. */\nexport async function groupStarKeyOf (shared: Uint8Array, sender: string, recipient: string, salt: string, subtle: SubtleCrypto = platformSubtle()): Promise<Uint8Array> {\n if (isZero(shared)) throw new Error('all-zero shared secret (Trust §2.1)')\n return hkdf(shared, `rltp/visibility/blind/group-star/${sender}/${recipient}/${salt}`, 32, subtle)\n}\n/** k_e(G) from the pair secret: the sealing key of one group's entry; G is the canonical u form of the genesis digest. */\nexport async function groupSealKeyOf (shared: Uint8Array, sender: string, recipient: string, salt: string, group: string, subtle: SubtleCrypto = platformSubtle()): Promise<Uint8Array> {\n if (isZero(shared)) throw new Error('all-zero shared secret (Trust §2.1)')\n return hkdf(shared, `rltp/visibility/seal/group-star/${sender}/${recipient}/${salt}/${group}`, 32, subtle)\n}\n\n// ── AEAD (§2.1): AES-256-GCM, 128-bit tag, 96-bit nonce; u + base64url(nonce || ct || tag) ──\nasync function seal (key: Uint8Array, aad: string, plaintext: string, nonce: Uint8Array, S: SubtleCrypto): Promise<string> {\n const k = await S.importKey('raw', key, 'AES-GCM', false, ['encrypt'])\n const ct = new Uint8Array(await S.encrypt({ name: 'AES-GCM', iv: nonce, additionalData: te.encode(aad), tagLength: 128 }, k, te.encode(plaintext)))\n const out = new Uint8Array(NONCE + ct.length); out.set(nonce); out.set(ct, NONCE)\n return 'u' + b64uOf(out)\n}\nasync function open (key: Uint8Array, aad: string, c: string, S: SubtleCrypto): Promise<string | null> {\n try {\n const raw = fromB64u(c.slice(1))\n if (raw.length <= NONCE + TAG) return null\n const k = await S.importKey('raw', key, 'AES-GCM', false, ['decrypt'])\n const pt = await S.decrypt({ name: 'AES-GCM', iv: raw.subarray(0, NONCE), additionalData: te.encode(aad), tagLength: 128 }, k, raw.subarray(NONCE))\n return td.decode(pt)\n } catch { return null }\n}\n\n// ── group-pair@1 ────────────────────────────────────────────────────────\nexport interface GroupPairFields {\n /** the genesis digest G, canonical u form */\n group: string\n /** the sender's member anchor in G (for a founder: its founding pair anchor) */\n member: string\n /** oid: of the canonical admission of member, or of the genesis where the sender founded G */\n memberOp: string\n to: string\n salt: string\n}\n/** The opened body of a sealed entry; `memberShared` = X25519(memberX_sender, pairX_recipient). */\nexport async function buildGroupPairWith (i: GroupPairFields, memberShared: Uint8Array, subtle: SubtleCrypto = platformSubtle()) {\n if (isZero(memberShared)) throw new Error('all-zero shared secret (Trust §2.1)')\n const unproved = { type: 'group-pair@1', group: i.group, member: i.member, memberOp: i.memberOp, to: i.to, salt: i.salt }\n const k = await hkdf(memberShared, 'rltp/visibility/mac/group-pair', 32, subtle)\n return { ...unproved, proof: await macU(k, jcs(unproved), subtle) }\n}\n// every field of a group pair but salt has a fixed length on the wire\n// (did:key 56, digest 47, oid 47, mac 44), so a real c's length is a\n// function of the salt alone — the filler length of this star\nconst sealedLength = (to: string, salt: string): number => NONCE + TAG + te.encode(jcs({\n type: 'group-pair@1', group: 'u' + 'A'.repeat(46), member: to, memberOp: 'oid:' + 'A'.repeat(43), to, salt, proof: 'u' + 'A'.repeat(43),\n})).length\n\n// ── the sender ──────────────────────────────────────────────────────────\nexport interface GroupStarEntryInput {\n group: string\n /** a real sealed pair; otherwise c is filler */\n sealed: boolean\n /** the sender's member anchor in G (sealed only) */\n member?: string\n memberOp?: string\n /** X25519(memberX_sender, pairX_recipient), asked for only when sealed */\n memberShared?: () => Promise<Uint8Array>\n}\nexport interface GroupStarWithInput {\n /** X25519(pairX_sender, pairX_recipient) */\n shared: Uint8Array\n /** the sender's pair anchor */\n sender: string\n /** the recipient's pair anchor */\n to: string\n salt: string\n /** every group the sender lists toward this recipient */\n groups: GroupStarEntryInput[]\n draw: GroupStarDraw\n subtle?: SubtleCrypto\n}\nexport type GroupStarChunk = { body: { type: 'group-star@1', salt: string, seq: string, last: boolean, groups: { d: string, c: string }[] }, proof: { mac: string } }\n\n/** The chunks of one group-star delivery toward one recipient. */\nexport async function buildGroupStarWith (i: GroupStarWithInput): Promise<{ chunks: GroupStarChunk[] }> {\n const S = i.subtle ?? platformSubtle()\n const kg = await groupStarKeyOf(i.shared, i.sender, i.to, i.salt, S)\n const cLen = sealedLength(i.to, i.salt)\n const ds = new Set<string>(), cs = new Set<string>()\n const entries: { d: string, c: string }[] = []\n const fillerC = (): string => { for (;;) { const c = 'u' + b64uOf(i.draw(cLen, 'filler')); if (!cs.has(c)) return c } }\n for (const g of i.groups) {\n const d = await macU(kg, g.group, S)\n if (ds.has(d)) continue // one entry per group\n let c: string\n if (g.sealed) {\n if (!g.member || !g.memberOp || !g.memberShared) throw new Error('a sealed group pair needs member and memberOp')\n const pair = await buildGroupPairWith({ group: g.group, member: g.member, memberOp: g.memberOp, to: i.to, salt: i.salt }, await g.memberShared(), S)\n c = await seal(await groupSealKeyOf(i.shared, i.sender, i.to, i.salt, g.group, S), d, jcs(pair), i.draw(NONCE, 'nonce'), S)\n if (c.length !== 'u'.length + Math.ceil(cLen * 4 / 3)) throw new Error('group pair of unexpected length — filler would be distinguishable')\n } else c = fillerC()\n ds.add(d); cs.add(c); entries.push({ d, c })\n }\n const target = Math.max(GROUP_STAR_PAD, Math.ceil(entries.length / GROUP_STAR_PAD) * GROUP_STAR_PAD)\n while (entries.length < target) {\n let d: string\n do d = 'u' + b64uOf(i.draw(32, 'filler')); while (ds.has(d)) // collisions with any value are resampled\n const c = fillerC()\n ds.add(d); cs.add(c); entries.push({ d, c })\n }\n entries.sort((x, y) => (x.d < y.d ? -1 : x.d > y.d ? 1 : 0))\n const n = Math.ceil(entries.length / GROUP_STAR_CHUNK)\n const chunks: GroupStarChunk[] = []\n for (let k = 0; k < n; k++) {\n const body = { type: 'group-star@1' as const, salt: i.salt, seq: String(k + 1), last: k === n - 1, groups: entries.slice(k * GROUP_STAR_CHUNK, (k + 1) * GROUP_STAR_CHUNK) }\n chunks.push({ body, proof: { mac: await macU(kg, jcs(body), S) } })\n }\n return { chunks }\n}\n\n// ── the recipient ───────────────────────────────────────────────────────\n\n/** Is this a schema-valid group-star@1 chunk (visibility-group-star.schema.json)? */\nexport const groupStarChunkOk = (chunk: unknown): boolean => schemaOk('visibility-group-star.schema.json', chunk)\n\n/** The §5.2b checks of a completed union: a positive multiple of 16\n * entries, strictly ascending by d, every c of the same length. */\nexport function groupStarUnionOk (entries: readonly { d: string, c: string }[]): 'order' | 'size' | 'c length' | null {\n if (!entries.every((e, k) => k === 0 || entries[k - 1]!.d < e.d)) return 'order'\n if (entries.length === 0 || entries.length % GROUP_STAR_PAD !== 0) return 'size'\n if (entries.some((e) => e.c.length !== entries[0]!.c.length)) return 'c length'\n return null\n}\n\n/**\n * One delivery's chunks → its entry union (5.2a under the group star's\n * own salt): every chunk schema-valid and MAC-valid under k_g of the\n * arrival tuple, one salt, seq 1..n each once, exactly the n-th last,\n * the union strictly ascending by d — and the §5.2b reception rules on\n * the completed assembly: a positive multiple of 16 entries, every c of\n * the same length. A failing assembly rejects the delivery.\n */\nexport async function assembleGroupStarWith (i: { shared: () => Promise<Uint8Array>, from: string, own: string, chunks: any[], subtle?: SubtleCrypto }): Promise<{ ok: true, salt: string, entries: { d: string, c: string }[] } | { ok: false, reason: string }> {\n const S = i.subtle ?? platformSubtle()\n if (!Array.isArray(i.chunks) || !i.chunks.length) return { ok: false, reason: 'no chunk' }\n for (const ch of i.chunks) if (!groupStarChunkOk(ch)) return { ok: false, reason: 'schema' }\n const salt = i.chunks[0].body.salt\n if (i.chunks.some((ch) => ch.body.salt !== salt)) return { ok: false, reason: 'salt' }\n let kg: Uint8Array\n try { kg = await groupStarKeyOf(await i.shared(), i.from, i.own, salt, S) } catch { return { ok: false, reason: 'ecdh' } }\n for (const ch of i.chunks) if ((await macU(kg, jcs(ch.body), S)) !== ch.proof.mac) return { ok: false, reason: 'mac' }\n const bySeq = new Map<string, any>()\n for (const ch of i.chunks) { if (bySeq.has(ch.body.seq)) return { ok: false, reason: 'seq repeated' }; bySeq.set(ch.body.seq, ch.body) }\n const lasts = i.chunks.filter((ch) => ch.body.last)\n if (lasts.length !== 1) return { ok: false, reason: 'last' }\n const n = Number(lasts[0].body.seq)\n if (bySeq.size !== n) return { ok: false, reason: 'incomplete' }\n const entries: { d: string, c: string }[] = []\n for (let k = 1; k <= n; k++) { const b = bySeq.get(String(k)); if (!b) return { ok: false, reason: 'incomplete' }; entries.push(...b.groups) }\n const bad = groupStarUnionOk(entries)\n if (bad !== null) return { ok: false, reason: bad }\n return { ok: true, salt, entries }\n}\n\n/** A group the recipient is a CURRENT member of, with its materialized state. */\nexport interface GroupMembership {\n group: string\n /** is this anchor a current member of the recipient's materialized state of the group? */\n isMember: (anchor: string) => boolean\n /** the canonical admission (or the genesis) an oid: names: its subject (genesis: body.members[0]) and its card's key-agreement key */\n resolve: (oid: string) => { subject: string, keyAgreement: string } | null\n}\nexport interface GroupStarResult { group: string, hit: boolean, opened: boolean, accepted: boolean, member?: string, memberOp?: string, reason?: string }\n\n/**\n * Reception (§5.2b): for each group the recipient is a current member\n * of, compute d and test the union; on a hit derive k_e(G) and try to\n * open c — a c that does not open is a miss, not an error. An opened\n * pair is accepted only if, in order: schema · group = G · to = the\n * own pair anchor and salt = the assembly's · memberOp names a\n * canonical admission of member (or the genesis) and member is current\n * · the MAC verifies under that operation's card key, non-zero ECDH\n * (`agreeMember(cardKeyAgreement)` = X25519(own pairX, that key), null\n * where it cannot agree). An accepted pair is class V: merged\n * holder-locally, never republished.\n */\nexport async function openGroupStarWith (i: {\n shared: Uint8Array, from: string, own: string, salt: string, entries: { d: string, c: string }[], memberships: GroupMembership[],\n agreeMember: (keyAgreement: string) => Promise<Uint8Array | null>, subtle?: SubtleCrypto,\n}): Promise<GroupStarResult[]> {\n const S = i.subtle ?? platformSubtle()\n const kg = await groupStarKeyOf(i.shared, i.from, i.own, i.salt, S)\n const byD = new Map(i.entries.map((e) => [e.d, e.c]))\n const out: GroupStarResult[] = []\n for (const m of i.memberships) {\n const d = await macU(kg, m.group, S)\n const c = byD.get(d)\n if (c === undefined) { out.push({ group: m.group, hit: false, opened: false, accepted: false }); continue }\n const pt = await open(await groupSealKeyOf(i.shared, i.from, i.own, i.salt, m.group, S), d, c, S)\n if (pt === null) { out.push({ group: m.group, hit: true, opened: false, accepted: false }); continue }\n const reject = (reason: string) => out.push({ group: m.group, hit: true, opened: true, accepted: false, reason })\n let pair: any\n try { pair = JSON.parse(pt) } catch { reject('schema'); continue }\n if (!schemaOk('visibility-group-pair.schema.json', pair)) { reject('schema'); continue }\n if (pair.group !== m.group) { reject('group'); continue }\n if (pair.to !== i.own || pair.salt !== i.salt) { reject('to'); continue }\n const op = m.resolve(pair.memberOp)\n if (!op || op.subject !== pair.member || !m.isMember(pair.member)) { reject('member'); continue }\n const sh = await i.agreeMember(op.keyAgreement)\n if (!sh || isZero(sh)) { reject('mac'); continue }\n const { proof, ...unproved } = pair\n if ((await macU(await hkdf(sh, 'rltp/visibility/mac/group-pair', 32, S), jcs(unproved), S)) !== proof) { reject('mac'); continue }\n out.push({ group: m.group, hit: true, opened: true, accepted: true, member: pair.member, memberOp: pair.memberOp })\n }\n return out\n}\n\n// ── over identity Contexts ─────────────────────────────────────────────\n// The same constructions with the private keys of identity Contexts (the\n// form vectors, generators and tests use); the holder goes through the\n// *With forms with secrets from its KeyProvider. Entropy (AEAD nonces,\n// filler) is the caller's `rand`, so the vectors replay.\n\nconst shared = async (own: Context, peerKeyAgreement: string): Promise<Uint8Array> => {\n const x = xRawOfMk(peerKeyAgreement)\n if (!x) throw new Error('peer key agreement is not a multikey')\n const sh = await ecdh(own.x.priv, x)\n if (sh.every((b) => b === 0)) throw new Error('all-zero shared secret (Trust §2.1)') // rejected before key derivation\n return sh\n}\n/** k_g of one direction: `sender` and `recipient` are the two pair anchors, salt in its wire string form. */\nexport async function groupStarKey (own: Context, peerKeyAgreement: string, sender: string, recipient: string, salt: string): Promise<Uint8Array> {\n return groupStarKeyOf(await shared(own, peerKeyAgreement), sender, recipient, salt)\n}\n/** k_e(G): the sealing key of one group's entry; G is the canonical u form of the genesis digest. */\nexport async function groupSealKey (own: Context, peerKeyAgreement: string, sender: string, recipient: string, salt: string, group: string): Promise<Uint8Array> {\n return groupSealKeyOf(await shared(own, peerKeyAgreement), sender, recipient, salt, group)\n}\n\n// ── group-pair@1 ────────────────────────────────────────────────────────\nexport interface GroupPairInput {\n /** the genesis digest G, canonical u form */\n group: string\n /** the sender's member context in G (for a founder: its founding pair context) */\n member: Context\n /** oid: of the canonical admission of member, or of the genesis where the sender founded G */\n memberOp: string\n to: string\n toKeyAgreement: string\n salt: string\n}\n/** The opened body of a sealed entry; proof under memberX × pairX of the recipient. */\nexport async function buildGroupPair (i: GroupPairInput) {\n return buildGroupPairWith({ group: i.group, member: i.member.anchor, memberOp: i.memberOp, to: i.to, salt: i.salt }, await shared(i.member, i.toKeyAgreement))\n}\n\n// ── the sender ──────────────────────────────────────────────────────────\nexport interface GroupStarGroup {\n group: string\n /** a real sealed pair (the recipient is trusted, or this group is switched on for it); otherwise c is filler */\n sealed: boolean\n member?: Context\n memberOp?: string\n}\nexport interface GroupStarInput {\n /** the sender's pair context of the relationship */\n own: Context\n to: string\n toKeyAgreement: string\n salt: string\n /** every group the sender lists toward this recipient (its current groups not switched off) */\n groups: GroupStarGroup[]\n /** the entropy source (nonces, filler): the caller's, so vectors replay */\n rand: (n: number) => Uint8Array\n}\n/** The chunks of one group-star delivery toward one recipient. */\nexport async function buildGroupStar (i: GroupStarInput) {\n const rnd = i.rand\n return buildGroupStarWith({\n shared: await shared(i.own, i.toKeyAgreement), sender: i.own.anchor, to: i.to, salt: i.salt,\n groups: i.groups.map((g) => ({\n group: g.group, sealed: g.sealed, member: g.member?.anchor, memberOp: g.memberOp,\n memberShared: g.member ? () => shared(g.member!, i.toKeyAgreement) : undefined,\n })),\n draw: (n) => rnd(n),\n })\n}\n\n// ── the recipient ───────────────────────────────────────────────────────\n/**\n * One delivery's chunks → its entry union (5.2a under the group star's\n * own salt): every chunk schema-valid and MAC-valid under k_g of the\n * arrival tuple, one salt, seq 1..n each once, exactly the n-th last,\n * the union strictly ascending by d — and the §5.2b reception rules on\n * the completed assembly: a positive multiple of 16 entries, every c of\n * the same length. A failing assembly rejects the delivery.\n */\nexport async function assembleGroupStar (i: { own: Context, from: string, fromKeyAgreement: string, chunks: any[] }): Promise<{ ok: true, salt: string, entries: { d: string, c: string }[] } | { ok: false, reason: string }> {\n return assembleGroupStarWith({ shared: () => shared(i.own, i.fromKeyAgreement), from: i.from, own: i.own.anchor, chunks: i.chunks })\n}\n\n/**\n * Reception (§5.2b): for each group the recipient is a current member\n * of, compute d and test the union; on a hit derive k_e(G) and try to\n * open c — a c that does not open is a miss, not an error. An opened\n * pair is accepted only if, in order: schema · group = G · to = the\n * own pair anchor and salt = the assembly's · memberOp names a\n * canonical admission of member (or the genesis) and member is current\n * · the MAC verifies under that operation's card key, non-zero ECDH.\n * An accepted pair is class V: merged holder-locally, never republished.\n */\nexport async function openGroupStar (i: { own: Context, from: string, fromKeyAgreement: string, salt: string, entries: { d: string, c: string }[], memberships: GroupMembership[] }): Promise<GroupStarResult[]> {\n const res = await openGroupStarWith({\n shared: await shared(i.own, i.fromKeyAgreement), from: i.from, own: i.own.anchor, salt: i.salt, entries: i.entries, memberships: i.memberships,\n agreeMember: async (keyAgreement) => {\n const memberX = xRawOfMk(keyAgreement)\n return memberX ? ecdh(i.own.x.priv, memberX) : null\n },\n })\n return res.map(({ memberOp: _, ...r }) => r)\n}\n"]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { CommitListener, EnginePorts, HolderModule } from './engine.js';
|
|
2
|
+
import type { DeliveryReport } from './ports.js';
|
|
3
|
+
import type { ActResult, ReceiveResult, ResumeResult } from './results.js';
|
|
4
|
+
import type { DeviceKeyResult } from './identity-state.js';
|
|
5
|
+
import type { ProfileContent } from './profile.js';
|
|
6
|
+
import type { Dec, Millis, OpaqueHolderState, PromptChoice, Setting, TrustClass } from './state.js';
|
|
7
|
+
import type { Json } from './core.js';
|
|
8
|
+
import type { ContactView, DeliveryStatusView, GroupView, ProfileView, PromptView } from './views.js';
|
|
9
|
+
/** The committed state and its commitSeq; the state is opaque (note §4.5):
|
|
10
|
+
* apps read the views, store tooling may persist it. */
|
|
11
|
+
export interface HolderSnapshot {
|
|
12
|
+
commitSeq: Dec;
|
|
13
|
+
state: OpaqueHolderState;
|
|
14
|
+
}
|
|
15
|
+
export interface HolderOptions {
|
|
16
|
+
/** domain modules to register beside the built-ins, the prompts and the trust module */
|
|
17
|
+
modules?: readonly HolderModule[];
|
|
18
|
+
/** testing mode: check the invariants of invariants.ts on every commit,
|
|
19
|
+
* before the store's CAS; a violation throws InfraError
|
|
20
|
+
* 'invariant-violated' (cause: the violations) and nothing commits */
|
|
21
|
+
invariants?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** The options of a human act (note §4.2): its time and the actId the app
|
|
24
|
+
* mints when the human acts. */
|
|
25
|
+
export interface HumanActOptions {
|
|
26
|
+
when: Millis;
|
|
27
|
+
actId: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Holder {
|
|
30
|
+
/** any registered command by name, for modules and tests; apps use the typed acts */
|
|
31
|
+
act(command: string, input: unknown, when: Millis, opts?: {
|
|
32
|
+
actId?: string;
|
|
33
|
+
}): Promise<ActResult>;
|
|
34
|
+
/** the human's decision on an open prompt: a human act under the app's
|
|
35
|
+
* actId (note §4.2); a missing actId is also refused at runtime */
|
|
36
|
+
decide(promptId: string, choice: PromptChoice, opts: HumanActOptions): Promise<ActResult>;
|
|
37
|
+
/** the Trust act: the anchor mapping class on toward the contact (2770); human */
|
|
38
|
+
trust(contactId: string, opts: HumanActOptions): Promise<ActResult>;
|
|
39
|
+
/** trust withdrawn: the anchor mapping class off (2840, 2850); human */
|
|
40
|
+
untrust(contactId: string, opts: HumanActOptions): Promise<ActResult>;
|
|
41
|
+
/** the pause of 5.4: star and blinded group star off, or back to default; human */
|
|
42
|
+
pauseTrust(contactId: string, paused: boolean, opts: HumanActOptions): Promise<ActResult>;
|
|
43
|
+
/** one class's setting toward the contact (2780, 2810); human */
|
|
44
|
+
setClass(contactId: string, cls: TrustClass, setting: Setting, opts: HumanActOptions): Promise<ActResult>;
|
|
45
|
+
/** the sealed group star's setting for one group toward the contact (2830); human */
|
|
46
|
+
setGroupClass(contactId: string, groupId: string, setting: Setting, opts: HumanActOptions): Promise<ActResult>;
|
|
47
|
+
/** the manual merge (6640): at most one of them holds an entry; human */
|
|
48
|
+
merge(contactIds: string[], opts: HumanActOptions): Promise<ActResult>;
|
|
49
|
+
/** departure (2260): the entry, the relationships of an alias, or one
|
|
50
|
+
* relationship (relationshipId); human */
|
|
51
|
+
depart(contactId: string, opts: HumanActOptions & {
|
|
52
|
+
relationshipId?: string;
|
|
53
|
+
}): Promise<ActResult>;
|
|
54
|
+
/** 2240: entries re-commit from verified mappings recovered without them; not human */
|
|
55
|
+
recover(opts: {
|
|
56
|
+
when: Millis;
|
|
57
|
+
}): Promise<ActResult>;
|
|
58
|
+
/** a device name into the register before any key derived from it is presented (Identity §5.5); human */
|
|
59
|
+
addDevice(name: string, opts: HumanActOptions): Promise<ActResult>;
|
|
60
|
+
/** the name's revocation mark: never removed, the name never given again (Identity §5.5); human */
|
|
61
|
+
revokeDevice(name: string, opts: HumanActOptions): Promise<ActResult>;
|
|
62
|
+
/** the community anchor's rotation (Identity §5.4): step 1 (label,
|
|
63
|
+
* closure, 6596 decided) when none runs, else step 2 of the running one
|
|
64
|
+
* through the Log port; resume carries step 2 on its own (identity-state.ts) */
|
|
65
|
+
rotateAnchor(opts: HumanActOptions): Promise<ActResult>;
|
|
66
|
+
/** the own profile (Trust 6b): validated (6430, 6435, 6475), the next
|
|
67
|
+
* revision of the one counter (6450), delivered on every relationship
|
|
68
|
+
* the profile class is on for (6455); human */
|
|
69
|
+
setProfile(content: ProfileContent, opts: HumanActOptions): Promise<ActResult>;
|
|
70
|
+
/** a displayed card with a fresh own challenge under a fresh pair
|
|
71
|
+
* anchor (Encounter 5.3, 4.4): the event encounter.shown carries the
|
|
72
|
+
* card to display; `name` the card's display name (default: the own
|
|
73
|
+
* profile's); human */
|
|
74
|
+
show(opts: HumanActOptions & {
|
|
75
|
+
name?: string;
|
|
76
|
+
}): Promise<ActResult>;
|
|
77
|
+
/** the scanner's step on a displayed card (Encounter 5.8): the record,
|
|
78
|
+
* the fresh tuple, the bundle; encounter.scanned carries the sent card
|
|
79
|
+
* for the optical leg; human */
|
|
80
|
+
scan(card: Json, opts: HumanActOptions & {
|
|
81
|
+
name?: string;
|
|
82
|
+
}): Promise<ActResult>;
|
|
83
|
+
/** the optical leg (Encounter 5.8, 5710): a sent card shown by the scanner; human */
|
|
84
|
+
captureSentCard(card: Json, opts: HumanActOptions): Promise<ActResult>;
|
|
85
|
+
/** the counter-step toward a contact met as displayer (Encounter 5.8 step 4); human */
|
|
86
|
+
counter(contactId: string, opts: HumanActOptions): Promise<ActResult>;
|
|
87
|
+
/** a group founded under a fresh pair anchor (Access 3.4.1); its rule
|
|
88
|
+
* vouchThreshold (default "1") is group state; event group.founded; human */
|
|
89
|
+
foundGroup(group: {
|
|
90
|
+
name: string;
|
|
91
|
+
vouchThreshold?: string;
|
|
92
|
+
listed?: boolean;
|
|
93
|
+
}, opts: HumanActOptions): Promise<ActResult>;
|
|
94
|
+
/** invite a contact into a group: the prelude, then the invite on its
|
|
95
|
+
* answer (Membership 1.2, 3.1); the contact decides on a group-invite
|
|
96
|
+
* prompt; human */
|
|
97
|
+
invite(groupId: string, contactId: string, opts: HumanActOptions): Promise<ActResult>;
|
|
98
|
+
/** the mediator's act (Trust §8, this library's start of it): the
|
|
99
|
+
* requester gets an offer naming the target by an opaque designator and
|
|
100
|
+
* at most the `label` the human types here, with the mediator's
|
|
101
|
+
* ack-delay declaration; the requester decides on an
|
|
102
|
+
* `introduction` prompt, the target on another; human */
|
|
103
|
+
introduce(requesterId: string, targetId: string, opts: HumanActOptions & {
|
|
104
|
+
label?: string;
|
|
105
|
+
}): Promise<ActResult>;
|
|
106
|
+
/** a vouch@2 for a member anchor whose consent pair this holder holds
|
|
107
|
+
* (Access 5.3, Membership 3.4); human */
|
|
108
|
+
vouchFor(groupId: string, member: string, opts: HumanActOptions & {
|
|
109
|
+
provenance?: 'met' | 'introduced';
|
|
110
|
+
}): Promise<ActResult>;
|
|
111
|
+
/** the device key of a held, unrevoked device name under an own anchor
|
|
112
|
+
* context (Identity §5.5); reads, changes nothing */
|
|
113
|
+
deviceKey(name: string, contextLabel: string): Promise<DeviceKeyResult>;
|
|
114
|
+
tick(when: Millis): Promise<ActResult>;
|
|
115
|
+
resume(when: Millis): Promise<ResumeResult>;
|
|
116
|
+
report(report: DeliveryReport, when: Millis): Promise<ActResult>;
|
|
117
|
+
/** an arriving envelope, as the app's transport delivered it (non-human,
|
|
118
|
+
* no actId; idempotent over the document digest) */
|
|
119
|
+
receive(env: unknown, when: Millis): Promise<ReceiveResult>;
|
|
120
|
+
/** after every commit: its commitSeq and events, the cue to re-read the views */
|
|
121
|
+
subscribe(listener: CommitListener): () => void;
|
|
122
|
+
snapshot(): Promise<HolderSnapshot>;
|
|
123
|
+
contacts(): Promise<ContactView[]>;
|
|
124
|
+
/** by entry id or alias */
|
|
125
|
+
contact(id: string): Promise<ContactView | undefined>;
|
|
126
|
+
groups(): Promise<GroupView[]>;
|
|
127
|
+
profile(): Promise<ProfileView>;
|
|
128
|
+
prompts(): Promise<PromptView[]>;
|
|
129
|
+
/** by document digest or threadId */
|
|
130
|
+
deliveryStatus(digestOrThreadId: string): Promise<DeliveryStatusView>;
|
|
131
|
+
}
|
|
132
|
+
/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.
|
|
133
|
+
* The crypto handle (default globalThis.crypto) is resolved and probed
|
|
134
|
+
* here and also feeds the default entropy; an app that injects one
|
|
135
|
+
* passes the same handle to seedKeys(seed, crypto). */
|
|
136
|
+
export declare function createHolder(ports: EnginePorts, opts?: HolderOptions): Promise<Holder>;
|
|
137
|
+
//# sourceMappingURL=holder-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holder-api.d.ts","sourceRoot":"","sources":["../src/holder-api.ts"],"names":[],"mappings":"AA4DA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAQ1E,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;AAMnG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAErG;yDACyD;AACzD,MAAM,WAAW,cAAc;IAAG,SAAS,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE;AAE5E,MAAM,WAAW,aAAa;IAC5B,wFAAwF;IACxF,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IACjC;;2EAEuE;IACvE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;iCACiC;AACjC,MAAM,WAAW,eAAe;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,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AAK,OAAO,CAAC,cAAc,CAAC,CAAA;IACpC,QAAQ,IAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;IACnC,2BAA2B;IAC3B,OAAO,CAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAA;IACtD,MAAM,IAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAA;IAC/B,OAAO,IAAK,OAAO,CAAC,WAAW,CAAC,CAAA;IAChC,OAAO,IAAK,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACjC,qCAAqC;IACrC,cAAc,CAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;CACvE;AAED;;;wDAGwD;AACxD,wBAAsB,YAAY,CAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDjG"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// holder-api — createHolder, the facade over the engine (lib Stage 2,
|
|
2
|
+
// note §4.1, §4.5). Domain modules (identity, encounter, trust, continuity,
|
|
3
|
+
// membership, profile) register with the engine as they graduate; today
|
|
4
|
+
// the facade carries the engine's built-ins, the prompts module, the
|
|
5
|
+
// encounter module (encounter/ceremony.ts: show, scan, the optical leg, the
|
|
6
|
+
// counter-step, the bundle and the credential delivery), the membership
|
|
7
|
+
// module (membership/holder.ts: founding, the prelude and invite, the
|
|
8
|
+
// accept on a group-invite prompt, admission and welcome, evidence and
|
|
9
|
+
// vouches; and the in-library Access over the holder's groups where no
|
|
10
|
+
// Access port is given), the introduction module (introduction/holder.ts:
|
|
11
|
+
// the three roles of Trust §8 and the mediator's start), the identity module (identity-state.ts: device names, the rotation), the trust
|
|
12
|
+
// module (trust/mapping.ts: the Trust act, the class settings, the anchor
|
|
13
|
+
// mapping's issuance and reception, the entry commit; trust/star.ts and
|
|
14
|
+
// trust/group-star.ts: the star and the group star, reconciled on resume
|
|
15
|
+
// and received with their assemblies; trust/entries.ts: merge, split and
|
|
16
|
+
// departure; trust/continuity.ts: the probe, the continuity mapping and
|
|
17
|
+
// the chaining; trust/profile.ts: profile@1) and the modules given.
|
|
18
|
+
//
|
|
19
|
+
// The human acts (note §4.2) are typed methods with an options object
|
|
20
|
+
// `{when, actId}`; actId is required, minted by the app when the human
|
|
21
|
+
// acts, and journaled with the act's result (a repeat with the same actId
|
|
22
|
+
// replays it, another input under it is actid-conflict). They wrap `act`
|
|
23
|
+
// with the trust module's command names, which stays for modules and
|
|
24
|
+
// tests:
|
|
25
|
+
// trust(contactId, opts) trust.set {on: true} human
|
|
26
|
+
// untrust(contactId, opts) trust.set {on: false} human
|
|
27
|
+
// pauseTrust(contactId, paused, opts) trust.pause human
|
|
28
|
+
// setClass(contactId, cls, setting, opts) trust.setClass human
|
|
29
|
+
// setGroupClass(contactId, groupId, setting, opts) trust.setGroupClass human
|
|
30
|
+
// merge(contactIds, opts) trust.merge human
|
|
31
|
+
// depart(contactId, opts{relationshipId?}) trust.depart human
|
|
32
|
+
// decide(promptId, choice, opts) prompt.decide human
|
|
33
|
+
// addDevice(name, opts) identity.addDevice human
|
|
34
|
+
// revokeDevice(name, opts) identity.revokeDevice human
|
|
35
|
+
// rotateAnchor(opts) identity.rotate human
|
|
36
|
+
// setProfile({name, image?, text?}, opts) profile.set human
|
|
37
|
+
// show(opts{name?}) encounter.show human
|
|
38
|
+
// scan(card, opts{name?}) encounter.scan human
|
|
39
|
+
// captureSentCard(card, opts) encounter.capture human
|
|
40
|
+
// counter(contactId, opts) encounter.counter human
|
|
41
|
+
// foundGroup({name, vouchThreshold?, listed?}, opts) membership.found human
|
|
42
|
+
// invite(groupId, contactId, opts) membership.invite human
|
|
43
|
+
// vouchFor(groupId, member, opts{provenance?}) membership.vouch human
|
|
44
|
+
// introduce(requesterId, targetId, opts) introduction.introduce human
|
|
45
|
+
// recover({when}) trust.recover not human
|
|
46
|
+
// and the read deviceKey(name, contextLabel): the device key of a held,
|
|
47
|
+
// unrevoked name under an own anchor context (identity-state.ts).
|
|
48
|
+
// A missing actId is refused at runtime as actid-missing.
|
|
49
|
+
//
|
|
50
|
+
// Reading: the views (views.ts) over one snapshot each, carrying its
|
|
51
|
+
// commitSeq. `subscribe` announces every commit with its commitSeq and
|
|
52
|
+
// events; the app re-reads the views it shows, and a view read after the
|
|
53
|
+
// announcement is at that commitSeq or later.
|
|
54
|
+
//
|
|
55
|
+
// Delivery: `receive(env, when)` runs Delivery §6.2 in the core and
|
|
56
|
+
// dispatches through the task register (receive.ts); `report` takes the
|
|
57
|
+
// adapter's reports (on an ack's digest it marks the ack sent); `resume`
|
|
58
|
+
// re-emits, runs due duties and re-emits unsent acks; `tick` expires and
|
|
59
|
+
// retains (engine.ts).
|
|
60
|
+
import { createEngine } from './engine.js';
|
|
61
|
+
import { DECIDE, collectDecisions, promptsModule } from './prompts.js';
|
|
62
|
+
import { InfraError } from './results.js';
|
|
63
|
+
import { commitViolations } from './invariants.js';
|
|
64
|
+
import { toOpaque } from './state.js';
|
|
65
|
+
import { trustModule } from './trust/mapping.js';
|
|
66
|
+
import { IDENTITY_COMMANDS, deviceKeyOf, identityModule } from './identity-state.js';
|
|
67
|
+
import { PROFILE_SET } from './trust/profile.js';
|
|
68
|
+
import { TRUST_COMMANDS } from './trust/mapping.js';
|
|
69
|
+
import { ENTRY_COMMANDS } from './trust/entries.js';
|
|
70
|
+
import { ENCOUNTER_COMMANDS, encounterModule } from './encounter/ceremony.js';
|
|
71
|
+
import { MEMBERSHIP_COMMANDS, localAccess, membershipModule } from './membership/holder.js';
|
|
72
|
+
import { INTRODUCTION_COMMANDS, introductionModule } from './introduction/holder.js';
|
|
73
|
+
import { contactView, contactsView, deliveryStatusView, groupsView, profileView, promptsView } from './views.js';
|
|
74
|
+
/** A holder over its ports: `{store, keys, entropy?, log?, access?, retry?, crypto?}`.
|
|
75
|
+
* The crypto handle (default globalThis.crypto) is resolved and probed
|
|
76
|
+
* here and also feeds the default entropy; an app that injects one
|
|
77
|
+
* passes the same handle to seedKeys(seed, crypto). */
|
|
78
|
+
export async function createHolder(ports, opts = {}) {
|
|
79
|
+
const modules = [identityModule(), trustModule(), encounterModule(), membershipModule(), introductionModule(), ...(opts.modules ?? [])];
|
|
80
|
+
const check = opts.invariants === true
|
|
81
|
+
? (before, after, op) => {
|
|
82
|
+
const v = commitViolations(before, after, op);
|
|
83
|
+
if (v.length)
|
|
84
|
+
throw new InfraError('invariant-violated', `invariants broken by ${op.kind}: ${v.map((x) => `[${x.invariant}] ${x.detail}`).join('; ')}`, { cause: v });
|
|
85
|
+
}
|
|
86
|
+
: undefined;
|
|
87
|
+
const engine = await createEngine(ports, [promptsModule(collectDecisions(modules)), ...modules], { ...(check ? { check } : {}), accessFrom: localAccess });
|
|
88
|
+
const read = async () => (await engine.snapshot()).state;
|
|
89
|
+
/** a human act: `when` and actId from the options, a missing actId refused by the engine */
|
|
90
|
+
const human = (command, input, o) => engine.act(command, input, o?.when, o?.actId === undefined ? {} : { actId: o.actId });
|
|
91
|
+
return Object.freeze({
|
|
92
|
+
act: (command, input, when, o) => engine.act(command, input, when, o),
|
|
93
|
+
decide: (promptId, choice, o) => human(DECIDE, { promptId, choice }, o),
|
|
94
|
+
trust: (contactId, o) => human(TRUST_COMMANDS.set, { contactId, on: true }, o),
|
|
95
|
+
untrust: (contactId, o) => human(TRUST_COMMANDS.set, { contactId, on: false }, o),
|
|
96
|
+
pauseTrust: (contactId, paused, o) => human(TRUST_COMMANDS.pause, { contactId, paused }, o),
|
|
97
|
+
setClass: (contactId, cls, setting, o) => human(TRUST_COMMANDS.setClass, { contactId, cls, setting }, o),
|
|
98
|
+
setGroupClass: (contactId, groupId, setting, o) => human(TRUST_COMMANDS.setGroupClass, { contactId, groupId, setting }, o),
|
|
99
|
+
merge: (contactIds, o) => human(ENTRY_COMMANDS.merge, { contactIds }, o),
|
|
100
|
+
depart: (contactId, o) => human(ENTRY_COMMANDS.depart, o?.relationshipId === undefined ? { contactId } : { contactId, relationshipId: o.relationshipId }, o),
|
|
101
|
+
recover: (o) => engine.act(TRUST_COMMANDS.recover, {}, o?.when),
|
|
102
|
+
rotateAnchor: (o) => human(IDENTITY_COMMANDS.rotate, {}, o),
|
|
103
|
+
setProfile: (content, o) => human(PROFILE_SET, content, o),
|
|
104
|
+
show: (o) => human(ENCOUNTER_COMMANDS.show, o?.name === undefined ? {} : { name: o.name }, o),
|
|
105
|
+
scan: (card, o) => human(ENCOUNTER_COMMANDS.scan, o?.name === undefined ? { card } : { card, name: o.name }, o),
|
|
106
|
+
captureSentCard: (card, o) => human(ENCOUNTER_COMMANDS.capture, { card }, o),
|
|
107
|
+
counter: (contactId, o) => human(ENCOUNTER_COMMANDS.counter, { contactId }, o),
|
|
108
|
+
foundGroup: (g, o) => human(MEMBERSHIP_COMMANDS.found, g, o),
|
|
109
|
+
invite: (groupId, contactId, o) => human(MEMBERSHIP_COMMANDS.invite, { groupId, contactId }, o),
|
|
110
|
+
vouchFor: (groupId, member, o) => human(MEMBERSHIP_COMMANDS.vouch, o?.provenance === undefined ? { groupId, member } : { groupId, member, provenance: o.provenance }, o),
|
|
111
|
+
introduce: (requesterId, targetId, o) => human(INTRODUCTION_COMMANDS.introduce, o?.label === undefined ? { requesterId, targetId } : { requesterId, targetId, label: o.label }, o),
|
|
112
|
+
addDevice: (name, o) => human(IDENTITY_COMMANDS.addDevice, { name }, o),
|
|
113
|
+
revokeDevice: (name, o) => human(IDENTITY_COMMANDS.revokeDevice, { name }, o),
|
|
114
|
+
deviceKey: async (name, contextLabel) => deviceKeyOf(await read(), ports.keys, name, contextLabel),
|
|
115
|
+
tick: (when) => engine.tick(when),
|
|
116
|
+
resume: (when) => engine.resume(when),
|
|
117
|
+
report: (report, when) => engine.report(report, when),
|
|
118
|
+
receive: (env, when) => engine.receive(env, when),
|
|
119
|
+
subscribe: (listener) => engine.subscribe(listener),
|
|
120
|
+
snapshot: async () => {
|
|
121
|
+
const s = await engine.snapshot();
|
|
122
|
+
return Object.freeze({ commitSeq: s.commitSeq, state: toOpaque(s.state) });
|
|
123
|
+
},
|
|
124
|
+
contacts: async () => contactsView(await read()),
|
|
125
|
+
contact: async (id) => contactView(await read(), id),
|
|
126
|
+
groups: async () => groupsView(await read()),
|
|
127
|
+
profile: async () => profileView(await read()),
|
|
128
|
+
prompts: async () => promptsView(await read()),
|
|
129
|
+
deliveryStatus: async (x) => deliveryStatusView(await read(), x),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=holder-api.js.map
|
|
@@ -0,0 +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,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,sEAAsE;AACtE,uEAAuE;AACvE,0EAA0E;AAC1E,yEAAyE;AACzE,qEAAqE;AACrE,SAAS;AACT,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,kEAAkE;AAClE,0DAA0D;AAC1D,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,yEAAyE;AACzE,8CAA8C;AAC9C,EAAE;A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K,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;QAC5C,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC;QAC9C,cAAc,EAAE,KAAK,EAAE,CAAS,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;KACzE,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// recover({when}) trust.recover 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// 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 it marks the ack sent); `resume`\n// re-emits, runs due duties and re-emits unsent acks; `tick` expires and\n// retains (engine.ts).\nimport { createEngine } from './engine.js'\nimport type { CommitListener, EnginePorts, HolderModule } from './engine.js'\nimport type { DeliveryReport } from './ports.js'\nimport { DECIDE, collectDecisions, promptsModule } from './prompts.js'\nimport type { ActResult, ReceiveResult, 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 type { Json } from './core.js'\nimport { contactView, contactsView, deliveryStatusView, groupsView, profileView, promptsView } from './views.js'\nimport type { ContactView, DeliveryStatusView, GroupView, 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 /** 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 /** by document digest or threadId */\n deliveryStatus (digestOrThreadId: string): Promise<DeliveryStatusView>\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(), ...(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 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 deliveryStatus: async (x: string) => deliveryStatusView(await read(), x),\n })\n}\n"]}
|