@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/views.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views.js","sourceRoot":"","sources":["../src/views.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,4BAA4B;AAC5B,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,mEAAmE;AACnE,qEAAqE;AACrE,qEAAqE;AACrE,oDAAoD;AACpD,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,2DAA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E,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,OAAO,EAAE,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAChE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpF,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS;SAC/E,CAAA;IACH,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACtF,OAAO,UAAU,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC","sourcesContent":["// views — what an app reads: pure projections of the holder's state\n// (lib Stage 2, note §4.5).\n//\n// `state → View`, synchronous, without the engine: every function here\n// reads one state and returns fresh, deep-frozen objects that share no\n// reference with it, so a UI can keep them and the state stays untouched.\n// Each view carries the commitSeq of the state it was read from; views of\n// one snapshot belong together. The holder hands them out over its\n// snapshot (holder-api.ts); after a `subscribe` announcement the app\n// re-reads them. Views never write: whatever ages state (expiry, the\n// encounter's aging latch) is an act, never a read.\n//\n// Rule numbers: bare four-digit numbers are RLTP-TRU (trust-layer.md).\n//\n// Choices this file makes where the note leaves them open:\n// - contacts are listed in entry-commit order (2120); entries without a\n// position (2060) follow, by id. A contact is found by its entry id or\n// by any of its aliases (2140)\n// - provenance and via come from the contact's oldest relationship (by\n// its provenance time, then id): how the person came, not how often\n// - tuples belong to the entry their entryId names (2145): an entry's\n// tuples are those whose entryId is its id or one of its aliases, over\n// its own relationships and any relationship that stands behind two\n// entries. Its heads are the active-head tuples among them of live\n// relationships (not chained into another), not deactivated; under\n// 2146 the appended tuple's entry takes the chain's active head\n// - verification is the edge of Encounter 4.2 over all of the entry's\n// tuples, deactivated and older ones included (historical evidence;\n// one edge per relationship, carried along its chain): `outgoing` an\n// own step credential was issued, `incoming` the counterparty's was\n// accepted (5.6), `mutual` both, `met` neither — read from the\n// enactment records of those tuples (encounter/ceremony.ts). An entry\n// with no record at all (built without a ceremony: introduced, or a\n// test state) reads the anchor mappings instead: `outgoing` one was\n// issued (mappingOut), `incoming` one was verified (mappingIn)\n// - displayName: the profile's name (6425), else the self-declared name\n// on the counterparty card of the entry's newest record (Encounter\n// 6120: the app binds its own local name to the anchor)\n// - trust.given is the anchor mapping class on (the Trust act, 2770);\n// trust.received a verified anchor mapping from the contact, whose\n// class has no default recipient (2760); trust.paused the pause of 5.4,\n// star and blinded group star both `off` (2780); trust.pending: given,\n// but not yet out on every head (no mapping issued on it, or its\n// relationship lags (6595)), or a re-issue or class-on duty for the\n// anchor mapping is open at a version this library handles (a duty of\n// an unhandled version is opaque, note §2.1). Delivery of the documents is not part of\n// it; deliveryStatus answers that\n// - classes give the setting and whether the class is on toward the\n// contact (2760, 2840); the sealed group star also per group (2830):\n// every group of the holder and every group the contact holds a\n// per-group setting for, by id, with the setting (`default` where none\n// is held) and whether it is on for (group, contact) — the per-group\n// setting first, else the class (trust/group-star.ts sealedOn)\n// - sharedGroups: the union of the groups the last accepted group star\n// on each of the entry's heads hit (5520, trust/group-star.ts), lagging\n// heads included (the group star travels on them, 6595); undefined\n// where no head ever accepted one\n// - a contact's profile (6425): among the verified profile@1 bodies\n// (6b.2) on its heads whose relationship does not lag (6461, 6595),\n// the highest revision, among equal ones the one verified last\n// (highest verifiedSeq); displayName is that profile's name\n// - deliveryStatus(x) lists the outbox items whose digest or threadId is\n// x, by first submission, then digest; an unknown x lists none\n// - relationships: the entry's own (relIds), in that order; chainedFrom\n// the husks chained into each (chainedInto), by id\n// - a contact without a relationship breaks an invariant and throws\nimport { freezeDeep } from './util-freeze.js'\nimport type { Json } from './core.js'\nimport { triasOf } from './state.js'\nimport { CLASSES, activeTuple, classOn, findContact, lags, trusted as isTrusted, tupleByLabel } from './trust/state.js'\nimport { sealedOn } from './trust/group-star.js'\nimport { classOfDuty } from './trust/duties.js'\nimport { messageChannel } from './message/holder.js'\nimport type {\n EnactmentRecord,\n Contact, Dec, HolderState, Millis, OutboxItem, OutboxStatus, PromptKind, Relationship, Setting, TrustClass, Tuple,\n} from './state.js'\nimport type { DeliveryFailure, PreTransportReason, ReceiverRefusalCode } from './ports.js'\n\n/** One trust class toward one contact: its setting (2810) and whether it is on (2760). */\nexport interface ClassView { setting: Setting, on: boolean }\n\n/** The sealed group star toward one contact: the class, and per group\n * (2830) the per-group setting and whether it is on for (group, contact). */\nexport interface SealedClassView extends ClassView { groups: Record<string, ClassView> }\n\n/** Every class toward one contact (2720), the sealed group star per group too. */\nexport type ClassesView = Record<Exclude<TrustClass, 'sealedGroupStar'>, ClassView> & { sealedGroupStar: SealedClassView }\n\n/** A contact's verified profile (6b.2): string fields only. */\nexport interface ContactProfileView { revision: Dec, name?: string, image?: string, text?: string }\n\n/** One contact, i.e. one entry of the deliverable set (2120, 2140). */\nexport interface ContactView {\n /** the commitSeq of the state this view was read from */\n commitSeq: Dec\n /** the entry id: stable across aliases (2140) and chains (6a.4) */\n id: string\n /** identities merged into this entry (2140) and the fresh contacts its\n * chains took in (6a.4); contact(alias) finds it too */\n aliases: string[]\n /** its relationships (Contact.relIds), each with the number of tuples\n * its chain holds (one per enactment that continued it, 6.4) and the\n * fresh relationships chained into it (6a.4); a relationship that\n * stands behind two entries (2145) is listed under both */\n relationships: RelationshipView[]\n /** the verified profile's name (6425); the ceremony card's name enters\n * the state only when Encounter graduates (PR 7), so without a profile\n * it is undefined */\n displayName?: string\n provenance: 'ceremony' | 'introduced'\n /** the introducer, for an introduced contact */\n via?: string\n verification: 'mutual' | 'outgoing' | 'incoming' | 'met'\n trust: { given: boolean, received: boolean, paused: boolean, pending: boolean }\n classes: ClassesView\n /** groups shared with the contact: the groups of the holder whose\n * digest hit in the contact's last completed group star (5520), over\n * its heads, sorted. A hit is the contact's claim (5.2, no veracity).\n * Undefined while no group star was ever accepted on a head, never a\n * claimed empty list. */\n sharedGroups?: string[]\n profile?: ContactProfileView\n /** a block holds on the contact's relationships (Message Tasks 6.1): an\n * application shows no content and no offer of it, and shows group\n * state and removal notices as without a block (6230) */\n blocked: boolean\n /** a message to the contact goes out now (Message Tasks 5.1): an\n * unblocked relationship whose active head is ready; false, sendMessage\n * answers not-ready, blocked or no-own-channel */\n canMessage: boolean\n}\n\n/** One message in the inbox (Message Tasks 4.5): accepted, not yet taken\n * over by the application (takeMessages). */\nexport interface InboxMessageView {\n commitSeq: Dec\n /** the inbox id, the accepted document's digest; takeMessages names it */\n id: string\n /** the contact of the relationship it arrived on; absent once that\n * relationship departed */\n contactId?: string\n /** the relationship is blocked now (it was not at acceptance): an\n * application shows nothing of it (6230) */\n blocked: boolean\n mid: string\n text: string\n replyTo?: string\n /** the sender's statement, distinct from receivedAt (4430) */\n sentAt: Millis\n /** t_ref of the acceptance (4410) */\n receivedAt: Millis\n /** min(sentAt, receivedAt), fixed at acceptance: the order of 4430 with mid */\n displayAt: Millis\n}\n\n/** One relationship of a contact, as its chain stands. */\nexport interface RelationshipView { id: string, tuples: number, chainedFrom: string[] }\n\n/** One group the holder is a member of. */\nexport interface GroupView {\n commitSeq: Dec\n /** genesis digest */\n id: string\n /** the group's name, as its genesis names it */\n name: string\n /** listed in the blinded group star (5.2b per-group switch) */\n listed: boolean\n vouchThreshold: Dec\n /** the members this holder knows of, by member anchor (its roster);\n * `self` marks the own one, `contactId` a member it knows as a contact */\n members: Array<{ anchor: string, name?: string, contactId?: string, self: boolean }>\n /** consent pairs held toward an admission (Membership 3.4), by subject */\n pending: Array<{ member: string, name?: string, vouches: number }>\n}\n\n/** The holder's own profile (6450). */\nexport interface ProfileView { commitSeq: Dec, revision: Dec, name?: string, image?: string, text?: string }\n\n/** One open decision of the human. */\nexport interface PromptView {\n commitSeq: Dec\n id: string\n kind: PromptKind\n contactId?: string\n groupId?: string\n openedAt: Millis\n expiresAt?: Millis\n}\n\n/** One issued document's sender status (Delivery §6.1). */\nexport interface DeliveryItemView {\n digest: string\n type: string\n threadId: string\n contactId: string\n /** the trias position */\n status: OutboxStatus\n /** the adapter holds the item before the trias (last step awaiting-transport) */\n awaiting?: PreTransportReason\n /** for delivered: after a failure (the holder's own give-up included) */\n late?: boolean\n /** for failed; task-expired: the sender lifetime its type declares ran out (Delivery 6110) */\n reason?: DeliveryFailure | 'task-expired'\n code?: ReceiverRefusalCode\n attempt: number\n submittedAt: Millis\n updatedAt: Millis\n nextAttemptAt?: Millis\n}\n\nexport interface DeliveryStatusView { commitSeq: Dec, items: DeliveryItemView[] }\n\n// ── helpers ────────────────────────────────────────────────────────────\n\nconst cmp = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0)\nconst cmpDec = (a: Dec, b: Dec): number => { const x = BigInt(a), y = BigInt(b); return x < y ? -1 : x > y ? 1 : 0 }\nconst isObj = (x: unknown): x is Record<string, Json> => x !== null && typeof x === 'object' && !Array.isArray(x)\n\n/** The string fields of a profile body that a view shows. */\nconst profileFields = (body: Json | null): { name?: string, image?: string, text?: string } => {\n const out: { name?: string, image?: string, text?: string } = {}\n if (!isObj(body)) return out\n for (const k of ['name', 'image', 'text'] as const) if (typeof body[k] === 'string') out[k] = body[k] as string\n return out\n}\n\n/** own pair label → its enactment record (encounter.records) */\ntype RecordIndex = Map<string, EnactmentRecord>\n\nconst recordIndex = (state: Readonly<HolderState>): RecordIndex => {\n const ix: RecordIndex = new Map()\n for (const r of Object.values(state.encounter.records)) ix.set(r.label, r)\n return ix\n}\n\n/** entry id → the relationships holding a tuple of that entry (2145) */\ntype EntryIndex = Map<string, Set<string>>\n\nconst entryIndex = (state: Readonly<HolderState>): EntryIndex => {\n const ix: EntryIndex = new Map()\n for (const r of Object.values(state.relationships)) {\n for (const t of r.tuples) {\n let s = ix.get(t.entryId)\n if (!s) ix.set(t.entryId, (s = new Set()))\n s.add(r.id)\n }\n }\n return ix\n}\n\n/** The contact's own relationships, then those holding a tuple of its entry. */\nconst relationshipsOf = (state: Readonly<HolderState>, c: Readonly<Contact>, ids: ReadonlySet<string>, ix: EntryIndex): { own: Relationship[], all: Relationship[] } => {\n const own = c.relIds.filter((id) => Object.hasOwn(state.relationships, id)).map((id) => state.relationships[id])\n if (!own.length) throw new Error(`views: contact ${c.id} has no relationship`)\n const seen = new Set(own.map((r) => r.id))\n const all = [...own]\n for (const id of ids) {\n for (const rid of ix.get(id) ?? []) {\n if (!seen.has(rid)) { seen.add(rid); all.push(state.relationships[rid]) }\n }\n }\n return { own, all }\n}\n\nconst project = (state: Readonly<HolderState>, c: Readonly<Contact>, ix: EntryIndex, rix: RecordIndex): ContactView => {\n const ids = new Set([c.id, ...c.aliases])\n const { own, all: rels } = relationshipsOf(state, c, ids, ix)\n const mine = (t: Tuple): boolean => ids.has(t.entryId)\n const tuples = rels.flatMap((r) => r.tuples.filter(mine))\n const origin = [...own].sort((a, b) => (a.provenance.at - b.provenance.at) || cmp(a.id, b.id))[0]\n const records = tuples.map((t) => rix.get(t.ownPairLabel)).filter((r): r is EnactmentRecord => r !== undefined)\n const out = records.length ? records.some((r) => r.out !== null) : tuples.some((t) => t.mappingOut.body !== null)\n const inn = records.length ? records.some((r) => r.in !== null) : tuples.some((t) => t.mappingIn.body !== null)\n const newest = [...records].sort((a, b) => b.at - a.at)[0]\n const introduced = own.map((r) => r.memory.introducedName).find((n): n is string => typeof n === 'string')\n const cardName = typeof (newest?.card as { name?: unknown } | undefined)?.name === 'string' ? (newest.card as { name: string }).name : introduced\n const trusted = isTrusted(c)\n const classes = {} as Record<TrustClass, ClassView>\n for (const cls of CLASSES) classes[cls] = { setting: c.settings[cls], on: classOn(cls, c.settings[cls], trusted) }\n const groups: Record<string, ClassView> = {}\n for (const g of [...new Set([...Object.keys(state.groups), ...Object.keys(c.groupSettings)])].sort(cmp)) {\n groups[g] = { setting: Object.hasOwn(c.groupSettings, g) ? c.groupSettings[g] : 'default', on: sealedOn(c, g) }\n }\n const heads: Array<{ r: Relationship, t: Tuple, lagging: boolean }> = []\n for (const r of rels) {\n if (r.chainedInto !== null) continue\n const t = activeTuple(r)\n if (t && !t.deactivated && mine(t)) heads.push({ r, t, lagging: lags(r, rels) })\n }\n // a class-on or re-issue of the anchor mapping, at a version this library\n // handles (classOfDuty: an unhandled version is opaque and owes nothing here)\n const owed = Object.values(state.duties).some((d) =>\n classOfDuty(d) === 'anchorMapping' && (d as { contactId?: unknown }).contactId === c.id)\n const pending = trusted && (owed || heads.some((h) => h.t.mappingOut.body === null || h.lagging))\n let best: Tuple | undefined\n for (const { t, lagging } of heads) {\n if (lagging || t.profileIn.body === null) continue\n if (!best || cmpDec(t.profileIn.rev, best.profileIn.rev) > 0 ||\n (cmpDec(t.profileIn.rev, best.profileIn.rev) === 0 && cmpDec(t.profileIn.verifiedSeq, best.profileIn.verifiedSeq) > 0)) best = t\n }\n const profile = best ? { revision: best.profileIn.rev, ...profileFields(best.profileIn.body) } : undefined\n const received = heads.map((h) => h.t.groupStarIn.accepted).filter((a) => a !== null)\n const sharedGroups = received.length ? [...new Set(received.flatMap((a) => a.groups))].sort(cmp) : undefined\n return {\n commitSeq: state.commitSeq,\n id: c.id,\n aliases: [...c.aliases],\n relationships: own.map((r) => ({\n id: r.id, tuples: r.tuples.length,\n chainedFrom: Object.values(state.relationships).filter((x) => x.chainedInto === r.id).map((x) => x.id).sort(cmp),\n })),\n ...(profile?.name !== undefined ? { displayName: profile.name } : cardName !== undefined ? { displayName: cardName } : {}),\n provenance: origin.provenance.kind,\n ...(origin.provenance.kind === 'introduced' && origin.provenance.via !== undefined ? { via: origin.provenance.via } : {}),\n verification: out && inn ? 'mutual' : out ? 'outgoing' : inn ? 'incoming' : 'met',\n trust: {\n given: trusted,\n received: tuples.some((t) => t.mappingIn.body !== null),\n paused: c.settings.star === 'off' && c.settings.groupStar === 'off',\n pending,\n },\n classes: { ...classes, sealedGroupStar: { ...classes.sealedGroupStar, groups } } as ClassesView,\n ...(sharedGroups ? { sharedGroups } : {}),\n ...(profile ? { profile } : {}),\n blocked: own.some((r) => state.messages.blocked.includes(r.id)),\n canMessage: !('ok' in messageChannel(state, c.id)),\n }\n}\n\nconst itemView = (digest: string, it: Readonly<OutboxItem>): DeliveryItemView => {\n const status = triasOf(it)\n const last = it.history[it.history.length - 1]\n let decisive: OutboxItem['history'][number] | undefined\n for (let i = it.history.length - 1; i >= 0 && !decisive; i--) if (it.history[i].status !== 'awaiting-transport') decisive = it.history[i]\n const v: DeliveryItemView = {\n digest, type: it.type, threadId: it.threadId, contactId: it.recipient.contactId, status,\n attempt: it.attempt, submittedAt: it.history[0]?.at ?? 0, updatedAt: last?.at ?? 0,\n }\n if (last?.status === 'awaiting-transport') v.awaiting = last.reason\n if (decisive?.status === 'delivered') v.late = decisive.late\n if (decisive?.status === 'failed') {\n v.reason = decisive.reason\n if (decisive.reason === 'rejected-by-receiver') v.code = decisive.code\n }\n if (it.nextAttemptAt !== undefined) v.nextAttemptAt = it.nextAttemptAt\n return v\n}\n\n// ── the views ──────────────────────────────────────────────────────────\n\n/** Every contact, in entry-commit order (2120), then by id. */\nexport function contactsView (state: Readonly<HolderState>): ContactView[] {\n const order = Object.values(state.contacts).sort((a, b) => {\n if (a.pos !== null && b.pos !== null) return cmpDec(a.pos, b.pos) || cmp(a.id, b.id)\n if (a.pos !== null) return -1\n if (b.pos !== null) return 1\n return cmp(a.id, b.id)\n })\n const ix = entryIndex(state)\n const rix = recordIndex(state)\n return freezeDeep(order.map((c) => project(state, c, ix, rix)))\n}\n\n/** One contact by entry id or alias; undefined if there is none. */\nexport function contactView (state: Readonly<HolderState>, id: string): ContactView | undefined {\n const c = findContact(state, id)\n return c ? freezeDeep(project(state, c, entryIndex(state), recordIndex(state))) : undefined\n}\n\n/** The holder's groups, by genesis digest. */\nexport function groupsView (state: Readonly<HolderState>): GroupView[] {\n return freezeDeep(Object.values(state.groups).sort((a, b) => cmp(a.id, b.id)).map((g) => ({\n commitSeq: state.commitSeq, id: g.id, name: g.name, listed: g.listed, vouchThreshold: g.rules.vouchThreshold,\n members: Object.values(g.roster).sort((a, b) => cmp(a.anchor, b.anchor)).map((m) => ({\n anchor: m.anchor, ...(m.name !== undefined ? { name: m.name } : {}), ...(m.contactId !== undefined ? { contactId: m.contactId } : {}), self: m.anchor === g.memberAnchor,\n })),\n pending: Object.values(g.evidence).map((e) => {\n const acc = (e.accept as { payload?: { accept?: { subject?: string, card?: { name?: string } } } }).payload?.accept\n return { member: acc?.subject ?? '', ...(typeof acc?.card?.name === 'string' ? { name: acc.card.name } : {}), vouches: e.vouches.length }\n }).sort((a, b) => cmp(a.member, b.member)),\n })))\n}\n\n/** The holder's own profile. */\nexport function profileView (state: Readonly<HolderState>): ProfileView {\n return freezeDeep({ commitSeq: state.commitSeq, revision: state.profile.revision, ...profileFields(state.profile.body) })\n}\n\n/** The open prompts, by opening time, then id. Expired prompts stay\n * listed until tick removes them; deciding one is refused. */\nexport function promptsView (state: Readonly<HolderState>): PromptView[] {\n return freezeDeep(Object.values(state.prompts).sort((a, b) => (a.openedAt - b.openedAt) || cmp(a.id, b.id)).map((p) => ({\n commitSeq: state.commitSeq, id: p.id, kind: p.kind,\n ...(p.contactId !== undefined ? { contactId: p.contactId } : {}),\n ...(p.groupId !== undefined ? { groupId: p.groupId } : {}),\n openedAt: p.openedAt,\n ...(p.expiresAt !== undefined ? { expiresAt: p.expiresAt } : {}),\n })))\n}\n\n/** The sender status of the documents whose digest or threadId is `x`. */\nexport function deliveryStatusView (state: Readonly<HolderState>, x: string): DeliveryStatusView {\n const items = Object.entries(state.outbox)\n .filter(([digest, it]) => digest === x || it.threadId === x)\n .map(([digest, it]) => itemView(digest, it))\n .sort((a, b) => (a.submittedAt - b.submittedAt) || cmp(a.digest, b.digest))\n return freezeDeep({ commitSeq: state.commitSeq, items })\n}\n\n/** The inbox (Message Tasks 4.5), ordered by display time, then mid (4430). */\nexport function inboxView (state: Readonly<HolderState>): InboxMessageView[] {\n const out = Object.values(state.messages.inbox).map((e) => {\n const t = tupleByLabel(state, e.tuple)\n const c = t ? (findContact(state, t.tuple.entryId) ?? findContact(state, t.rel.contactId)) : undefined\n const b = e.body as { text: string, replyTo?: string, sentAt: string }\n return {\n commitSeq: state.commitSeq, id: e.id, ...(c ? { contactId: c.id } : {}),\n blocked: t !== null && state.messages.blocked.includes(t.rel.id),\n mid: e.mid, text: b.text, ...(b.replyTo !== undefined ? { replyTo: b.replyTo } : {}),\n sentAt: Date.parse(b.sentAt), receivedAt: e.receivedAt, displayAt: e.displayAt,\n }\n }).sort((a, b) => (a.displayAt - b.displayAt) || cmp(a.mid, b.mid) || cmp(a.id, b.id))\n return freezeDeep(out)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../src/views.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,4BAA4B;AAC5B,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,mEAAmE;AACnE,qEAAqE;AACrE,qEAAqE;AACrE,oDAAoD;AACpD,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,2DAA2D;AAC3D,0EAA0E;AAC1E,2EAA2E;AAC3E,mCAAmC;AACnC,yEAAyE;AACzE,wEAAwE;AACxE,wEAAwE;AACxE,2EAA2E;AAC3E,wEAA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A;QACtE,OAAO;YACL,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,OAAO,EAAE,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAChE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpF,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS;SAC/E,CAAA;IACH,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACtF,OAAO,UAAU,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC","sourcesContent":["// views — what an app reads: pure projections of the holder's state\n// (lib Stage 2, note §4.5).\n//\n// `state → View`, synchronous, without the engine: every function here\n// reads one state and returns fresh, deep-frozen objects that share no\n// reference with it, so a UI can keep them and the state stays untouched.\n// Each view carries the commitSeq of the state it was read from; views of\n// one snapshot belong together. The holder hands them out over its\n// snapshot (holder-api.ts); after a `subscribe` announcement the app\n// re-reads them. Views never write: whatever ages state (expiry, the\n// encounter's aging latch) is an act, never a read.\n//\n// Rule numbers: bare four-digit numbers are RLTP-TRU (trust-layer.md).\n//\n// Choices this file makes where the note leaves them open:\n// - contacts are listed in entry-commit order (2120); entries without a\n// position (2060) follow, by id. A contact is found by its entry id or\n// by any of its aliases (2140)\n// - provenance and via come from the contact's oldest relationship (by\n// its provenance time, then id): how the person came, not how often\n// - tuples belong to the entry their entryId names (2145): an entry's\n// tuples are those whose entryId is its id or one of its aliases, over\n// its own relationships and any relationship that stands behind two\n// entries. Its heads are the active-head tuples among them of live\n// relationships (not chained into another), not deactivated; under\n// 2146 the appended tuple's entry takes the chain's active head\n// - verification is the edge of Encounter 4.2 over all of the entry's\n// tuples, deactivated and older ones included (historical evidence;\n// one edge per relationship, carried along its chain): `outgoing` an\n// own step credential was issued, `incoming` the counterparty's was\n// accepted (5.6), `mutual` both, `met` neither — read from the\n// enactment records of those tuples (encounter/ceremony.ts). An entry\n// with no record at all (built without a ceremony: introduced, or a\n// test state) reads the anchor mappings instead: `outgoing` one was\n// issued (mappingOut), `incoming` one was verified (mappingIn)\n// - displayName: the profile's name (6425), else the self-declared name\n// on the counterparty card of the entry's newest record (Encounter\n// 6120: the app binds its own local name to the anchor)\n// - trust.given is the anchor mapping class on (the Trust act, 2770);\n// trust.received a verified anchor mapping from the contact, whose\n// class has no default recipient (2760); trust.paused the pause of 5.4,\n// star and blinded group star both `off` (2780); trust.pending: given,\n// but not yet out on every head (no mapping issued on it, or its\n// relationship lags (6595)), or a re-issue or class-on duty for the\n// anchor mapping is open at a version this library handles (a duty of\n// an unhandled version is opaque, note §2.1). Delivery of the documents is not part of\n// it; deliveryStatus answers that\n// - classes give the setting and whether the class is on toward the\n// contact (2760, 2840); the sealed group star also per group (2830):\n// every group of the holder and every group the contact holds a\n// per-group setting for, by id, with the setting (`default` where none\n// is held) and whether it is on for (group, contact) — the per-group\n// setting first, else the class (trust/group-star.ts sealedOn)\n// - sharedGroups: the union of the groups the last accepted group star\n// on each of the entry's heads hit (5520, trust/group-star.ts), lagging\n// heads included (the group star travels on them, 6595); undefined\n// where no head ever accepted one\n// - a contact's profile (6425): among the verified profile@1 bodies\n// (6b.2) on its heads whose relationship does not lag (6461, 6595),\n// the highest revision, among equal ones the one verified last\n// (highest verifiedSeq); displayName is that profile's name\n// - deliveryStatus(x) lists the outbox items whose digest or threadId is\n// x, by first submission, then digest; an unknown x lists none\n// - relationships: the entry's own (relIds), in that order; chainedFrom\n// the husks chained into each (chainedInto), by id; carrierNonce the\n// canonical register entry under the relationship's id;\n// counterpartDeliveryHints the deliveryHints of the counterparty card\n// on the record of the relationship's first tuple, whose relId is the\n// relationship's id (the enactment that opened it): a re-encounter's\n// record names the husk it opened, so its card never replaces the\n// first contact's hints. A chained relationship (a husk) is no\n// RelationshipView of its own, only an id in chainedFrom: it shows no\n// carrierNonce, because no adapter instance runs for it (profile\n// RLTP-VTI-1230)\n// - a contact without a relationship breaks an invariant and throws\nimport { freezeDeep } from './util-freeze.js'\nimport type { Json } from './core.js'\nimport { triasOf } from './state.js'\nimport { CLASSES, activeTuple, classOn, findContact, lags, trusted as isTrusted, tupleByLabel } from './trust/state.js'\nimport { sealedOn } from './trust/group-star.js'\nimport { classOfDuty } from './trust/duties.js'\nimport { messageChannel } from './message/holder.js'\nimport { canonicalCarrierNonce } from './identity-state.js'\nimport type {\n EnactmentRecord,\n Contact, Dec, HolderState, Millis, OutboxItem, OutboxStatus, PromptKind, Relationship, Setting, TrustClass, Tuple,\n} from './state.js'\nimport type { DeliveryFailure, PreTransportReason, ReceiverRefusalCode } from './ports.js'\n\n/** One trust class toward one contact: its setting (2810) and whether it is on (2760). */\nexport interface ClassView { setting: Setting, on: boolean }\n\n/** The sealed group star toward one contact: the class, and per group\n * (2830) the per-group setting and whether it is on for (group, contact). */\nexport interface SealedClassView extends ClassView { groups: Record<string, ClassView> }\n\n/** Every class toward one contact (2720), the sealed group star per group too. */\nexport type ClassesView = Record<Exclude<TrustClass, 'sealedGroupStar'>, ClassView> & { sealedGroupStar: SealedClassView }\n\n/** A contact's verified profile (6b.2): string fields only. */\nexport interface ContactProfileView { revision: Dec, name?: string, image?: string, text?: string }\n\n/** One contact, i.e. one entry of the deliverable set (2120, 2140). */\nexport interface ContactView {\n /** the commitSeq of the state this view was read from */\n commitSeq: Dec\n /** the entry id: stable across aliases (2140) and chains (6a.4) */\n id: string\n /** identities merged into this entry (2140) and the fresh contacts its\n * chains took in (6a.4); contact(alias) finds it too */\n aliases: string[]\n /** its relationships (Contact.relIds), each with the number of tuples\n * its chain holds (one per enactment that continued it, 6.4) and the\n * fresh relationships chained into it (6a.4); a relationship that\n * stands behind two entries (2145) is listed under both */\n relationships: RelationshipView[]\n /** the verified profile's name (6425); the ceremony card's name enters\n * the state only when Encounter graduates (PR 7), so without a profile\n * it is undefined */\n displayName?: string\n provenance: 'ceremony' | 'introduced'\n /** the introducer, for an introduced contact */\n via?: string\n verification: 'mutual' | 'outgoing' | 'incoming' | 'met'\n trust: { given: boolean, received: boolean, paused: boolean, pending: boolean }\n classes: ClassesView\n /** groups shared with the contact: the groups of the holder whose\n * digest hit in the contact's last completed group star (5520), over\n * its heads, sorted. A hit is the contact's claim (5.2, no veracity).\n * Undefined while no group star was ever accepted on a head, never a\n * claimed empty list. */\n sharedGroups?: string[]\n profile?: ContactProfileView\n /** a block holds on the contact's relationships (Message Tasks 6.1): an\n * application shows no content and no offer of it, and shows group\n * state and removal notices as without a block (6230) */\n blocked: boolean\n /** a message to the contact goes out now (Message Tasks 5.1): an\n * unblocked relationship whose active head is ready; false, sendMessage\n * answers not-ready, blocked or no-own-channel */\n canMessage: boolean\n}\n\n/** One message in the inbox (Message Tasks 4.5): accepted, not yet taken\n * over by the application (takeMessages). */\nexport interface InboxMessageView {\n commitSeq: Dec\n /** the inbox id, the accepted document's digest; takeMessages names it */\n id: string\n /** the contact of the relationship it arrived on; absent once that\n * relationship departed */\n contactId?: string\n /** the relationship is blocked now (it was not at acceptance): an\n * application shows nothing of it (6230) */\n blocked: boolean\n mid: string\n text: string\n replyTo?: string\n /** the sender's statement, distinct from receivedAt (4430) */\n sentAt: Millis\n /** t_ref of the acceptance (4410) */\n receivedAt: Millis\n /** min(sentAt, receivedAt), fixed at acceptance: the order of 4430 with mid */\n displayAt: Millis\n}\n\n/** One relationship of a contact, as its chain stands. */\nexport interface RelationshipView {\n id: string\n tuples: number\n chainedFrom: string[]\n /** the relationship's canonical carrier-nonce entry (Identity §7a.3):\n * N in base64url and its generation, from which an adapter derives this\n * side's wire identities; absent where none is held. A relationship\n * chained into this one is listed only in chainedFrom and shows none:\n * the chain is carried under this N (profile RLTP-VTI-1230) */\n carrierNonce?: { nonce: string, generation: Dec }\n /** the counterpart's delivery hints from the card of the enactment that\n * opened this relationship (its first contact; Encounter 6080), as\n * signed, uninterpreted; absent where that card carried none. A card of\n * a later enactment chained into the relationship changes nothing */\n counterpartDeliveryHints?: string[]\n}\n\n/** One group the holder is a member of. */\nexport interface GroupView {\n commitSeq: Dec\n /** genesis digest */\n id: string\n /** the group's name, as its genesis names it */\n name: string\n /** listed in the blinded group star (5.2b per-group switch) */\n listed: boolean\n vouchThreshold: Dec\n /** the members this holder knows of, by member anchor (its roster);\n * `self` marks the own one, `contactId` a member it knows as a contact */\n members: Array<{ anchor: string, name?: string, contactId?: string, self: boolean }>\n /** consent pairs held toward an admission (Membership 3.4), by subject */\n pending: Array<{ member: string, name?: string, vouches: number }>\n}\n\n/** The holder's own profile (6450). */\nexport interface ProfileView { commitSeq: Dec, revision: Dec, name?: string, image?: string, text?: string }\n\n/** One open decision of the human. */\nexport interface PromptView {\n commitSeq: Dec\n id: string\n kind: PromptKind\n contactId?: string\n groupId?: string\n openedAt: Millis\n expiresAt?: Millis\n}\n\n/** One issued document's sender status (Delivery §6.1). */\nexport interface DeliveryItemView {\n digest: string\n type: string\n threadId: string\n contactId: string\n /** the trias position */\n status: OutboxStatus\n /** the adapter holds the item before the trias (last step awaiting-transport) */\n awaiting?: PreTransportReason\n /** for delivered: after a failure (the holder's own give-up included) */\n late?: boolean\n /** for failed; task-expired: the sender lifetime its type declares ran out (Delivery 6110) */\n reason?: DeliveryFailure | 'task-expired'\n code?: ReceiverRefusalCode\n attempt: number\n submittedAt: Millis\n updatedAt: Millis\n nextAttemptAt?: Millis\n}\n\nexport interface DeliveryStatusView { commitSeq: Dec, items: DeliveryItemView[] }\n\n// ── helpers ────────────────────────────────────────────────────────────\n\nconst cmp = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0)\nconst cmpDec = (a: Dec, b: Dec): number => { const x = BigInt(a), y = BigInt(b); return x < y ? -1 : x > y ? 1 : 0 }\nconst isObj = (x: unknown): x is Record<string, Json> => x !== null && typeof x === 'object' && !Array.isArray(x)\n\n/** The string fields of a profile body that a view shows. */\nconst profileFields = (body: Json | null): { name?: string, image?: string, text?: string } => {\n const out: { name?: string, image?: string, text?: string } = {}\n if (!isObj(body)) return out\n for (const k of ['name', 'image', 'text'] as const) if (typeof body[k] === 'string') out[k] = body[k] as string\n return out\n}\n\n/** own pair label → its enactment record (encounter.records) */\ntype RecordIndex = Map<string, EnactmentRecord>\n\nconst recordIndex = (state: Readonly<HolderState>): RecordIndex => {\n const ix: RecordIndex = new Map()\n for (const r of Object.values(state.encounter.records)) ix.set(r.label, r)\n return ix\n}\n\n/** entry id → the relationships holding a tuple of that entry (2145) */\ntype EntryIndex = Map<string, Set<string>>\n\nconst entryIndex = (state: Readonly<HolderState>): EntryIndex => {\n const ix: EntryIndex = new Map()\n for (const r of Object.values(state.relationships)) {\n for (const t of r.tuples) {\n let s = ix.get(t.entryId)\n if (!s) ix.set(t.entryId, (s = new Set()))\n s.add(r.id)\n }\n }\n return ix\n}\n\n/** The contact's own relationships, then those holding a tuple of its entry. */\nconst relationshipsOf = (state: Readonly<HolderState>, c: Readonly<Contact>, ids: ReadonlySet<string>, ix: EntryIndex): { own: Relationship[], all: Relationship[] } => {\n const own = c.relIds.filter((id) => Object.hasOwn(state.relationships, id)).map((id) => state.relationships[id])\n if (!own.length) throw new Error(`views: contact ${c.id} has no relationship`)\n const seen = new Set(own.map((r) => r.id))\n const all = [...own]\n for (const id of ids) {\n for (const rid of ix.get(id) ?? []) {\n if (!seen.has(rid)) { seen.add(rid); all.push(state.relationships[rid]) }\n }\n }\n return { own, all }\n}\n\n/** The counterparty card's delivery hints on the record that opened\n * relationship `r`: the record of its first tuple's label (a chaining\n * appends, so the first tuple stays the one the relationship opened with),\n * found in the per-read label index. */\nconst firstHints = (r: Readonly<Relationship>, rix: RecordIndex): string[] | undefined => {\n const first = r.tuples[0]\n const rec = first ? rix.get(first.ownPairLabel) : undefined\n if (!rec || rec.relId !== r.id) return undefined\n const h = (rec.card as { deliveryHints?: unknown } | undefined)?.deliveryHints\n return Array.isArray(h) && h.length ? h.filter((x): x is string => typeof x === 'string') : undefined\n}\n\nconst relationshipView = (state: Readonly<HolderState>, r: Readonly<Relationship>, rix: RecordIndex): RelationshipView => {\n const n = canonicalCarrierNonce(state.register, r.id)\n const hints = firstHints(r, rix)\n return {\n id: r.id, tuples: r.tuples.length,\n chainedFrom: Object.values(state.relationships).filter((x) => x.chainedInto === r.id).map((x) => x.id).sort(cmp),\n ...(n ? { carrierNonce: { nonce: n.nonce, generation: n.generation } } : {}),\n ...(hints ? { counterpartDeliveryHints: hints } : {}),\n }\n}\n\nconst project = (state: Readonly<HolderState>, c: Readonly<Contact>, ix: EntryIndex, rix: RecordIndex): ContactView => {\n const ids = new Set([c.id, ...c.aliases])\n const { own, all: rels } = relationshipsOf(state, c, ids, ix)\n const mine = (t: Tuple): boolean => ids.has(t.entryId)\n const tuples = rels.flatMap((r) => r.tuples.filter(mine))\n const origin = [...own].sort((a, b) => (a.provenance.at - b.provenance.at) || cmp(a.id, b.id))[0]\n const records = tuples.map((t) => rix.get(t.ownPairLabel)).filter((r): r is EnactmentRecord => r !== undefined)\n const out = records.length ? records.some((r) => r.out !== null) : tuples.some((t) => t.mappingOut.body !== null)\n const inn = records.length ? records.some((r) => r.in !== null) : tuples.some((t) => t.mappingIn.body !== null)\n const newest = [...records].sort((a, b) => b.at - a.at)[0]\n const introduced = own.map((r) => r.memory.introducedName).find((n): n is string => typeof n === 'string')\n const cardName = typeof (newest?.card as { name?: unknown } | undefined)?.name === 'string' ? (newest.card as { name: string }).name : introduced\n const trusted = isTrusted(c)\n const classes = {} as Record<TrustClass, ClassView>\n for (const cls of CLASSES) classes[cls] = { setting: c.settings[cls], on: classOn(cls, c.settings[cls], trusted) }\n const groups: Record<string, ClassView> = {}\n for (const g of [...new Set([...Object.keys(state.groups), ...Object.keys(c.groupSettings)])].sort(cmp)) {\n groups[g] = { setting: Object.hasOwn(c.groupSettings, g) ? c.groupSettings[g] : 'default', on: sealedOn(c, g) }\n }\n const heads: Array<{ r: Relationship, t: Tuple, lagging: boolean }> = []\n for (const r of rels) {\n if (r.chainedInto !== null) continue\n const t = activeTuple(r)\n if (t && !t.deactivated && mine(t)) heads.push({ r, t, lagging: lags(r, rels) })\n }\n // a class-on or re-issue of the anchor mapping, at a version this library\n // handles (classOfDuty: an unhandled version is opaque and owes nothing here)\n const owed = Object.values(state.duties).some((d) =>\n classOfDuty(d) === 'anchorMapping' && (d as { contactId?: unknown }).contactId === c.id)\n const pending = trusted && (owed || heads.some((h) => h.t.mappingOut.body === null || h.lagging))\n let best: Tuple | undefined\n for (const { t, lagging } of heads) {\n if (lagging || t.profileIn.body === null) continue\n if (!best || cmpDec(t.profileIn.rev, best.profileIn.rev) > 0 ||\n (cmpDec(t.profileIn.rev, best.profileIn.rev) === 0 && cmpDec(t.profileIn.verifiedSeq, best.profileIn.verifiedSeq) > 0)) best = t\n }\n const profile = best ? { revision: best.profileIn.rev, ...profileFields(best.profileIn.body) } : undefined\n const received = heads.map((h) => h.t.groupStarIn.accepted).filter((a) => a !== null)\n const sharedGroups = received.length ? [...new Set(received.flatMap((a) => a.groups))].sort(cmp) : undefined\n return {\n commitSeq: state.commitSeq,\n id: c.id,\n aliases: [...c.aliases],\n relationships: own.map((r) => relationshipView(state, r, rix)),\n ...(profile?.name !== undefined ? { displayName: profile.name } : cardName !== undefined ? { displayName: cardName } : {}),\n provenance: origin.provenance.kind,\n ...(origin.provenance.kind === 'introduced' && origin.provenance.via !== undefined ? { via: origin.provenance.via } : {}),\n verification: out && inn ? 'mutual' : out ? 'outgoing' : inn ? 'incoming' : 'met',\n trust: {\n given: trusted,\n received: tuples.some((t) => t.mappingIn.body !== null),\n paused: c.settings.star === 'off' && c.settings.groupStar === 'off',\n pending,\n },\n classes: { ...classes, sealedGroupStar: { ...classes.sealedGroupStar, groups } } as ClassesView,\n ...(sharedGroups ? { sharedGroups } : {}),\n ...(profile ? { profile } : {}),\n blocked: own.some((r) => state.messages.blocked.includes(r.id)),\n canMessage: !('ok' in messageChannel(state, c.id)),\n }\n}\n\nconst itemView = (digest: string, it: Readonly<OutboxItem>): DeliveryItemView => {\n const status = triasOf(it)\n const last = it.history[it.history.length - 1]\n let decisive: OutboxItem['history'][number] | undefined\n for (let i = it.history.length - 1; i >= 0 && !decisive; i--) if (it.history[i].status !== 'awaiting-transport') decisive = it.history[i]\n const v: DeliveryItemView = {\n digest, type: it.type, threadId: it.threadId, contactId: it.recipient.contactId, status,\n attempt: it.attempt, submittedAt: it.history[0]?.at ?? 0, updatedAt: last?.at ?? 0,\n }\n if (last?.status === 'awaiting-transport') v.awaiting = last.reason\n if (decisive?.status === 'delivered') v.late = decisive.late\n if (decisive?.status === 'failed') {\n v.reason = decisive.reason\n if (decisive.reason === 'rejected-by-receiver') v.code = decisive.code\n }\n if (it.nextAttemptAt !== undefined) v.nextAttemptAt = it.nextAttemptAt\n return v\n}\n\n// ── the views ──────────────────────────────────────────────────────────\n\n/** Every contact, in entry-commit order (2120), then by id. */\nexport function contactsView (state: Readonly<HolderState>): ContactView[] {\n const order = Object.values(state.contacts).sort((a, b) => {\n if (a.pos !== null && b.pos !== null) return cmpDec(a.pos, b.pos) || cmp(a.id, b.id)\n if (a.pos !== null) return -1\n if (b.pos !== null) return 1\n return cmp(a.id, b.id)\n })\n const ix = entryIndex(state)\n const rix = recordIndex(state)\n return freezeDeep(order.map((c) => project(state, c, ix, rix)))\n}\n\n/** One contact by entry id or alias; undefined if there is none. */\nexport function contactView (state: Readonly<HolderState>, id: string): ContactView | undefined {\n const c = findContact(state, id)\n return c ? freezeDeep(project(state, c, entryIndex(state), recordIndex(state))) : undefined\n}\n\n/** The holder's groups, by genesis digest. */\nexport function groupsView (state: Readonly<HolderState>): GroupView[] {\n return freezeDeep(Object.values(state.groups).sort((a, b) => cmp(a.id, b.id)).map((g) => ({\n commitSeq: state.commitSeq, id: g.id, name: g.name, listed: g.listed, vouchThreshold: g.rules.vouchThreshold,\n members: Object.values(g.roster).sort((a, b) => cmp(a.anchor, b.anchor)).map((m) => ({\n anchor: m.anchor, ...(m.name !== undefined ? { name: m.name } : {}), ...(m.contactId !== undefined ? { contactId: m.contactId } : {}), self: m.anchor === g.memberAnchor,\n })),\n pending: Object.values(g.evidence).map((e) => {\n const acc = (e.accept as { payload?: { accept?: { subject?: string, card?: { name?: string } } } }).payload?.accept\n return { member: acc?.subject ?? '', ...(typeof acc?.card?.name === 'string' ? { name: acc.card.name } : {}), vouches: e.vouches.length }\n }).sort((a, b) => cmp(a.member, b.member)),\n })))\n}\n\n/** The holder's own profile. */\nexport function profileView (state: Readonly<HolderState>): ProfileView {\n return freezeDeep({ commitSeq: state.commitSeq, revision: state.profile.revision, ...profileFields(state.profile.body) })\n}\n\n/** The open prompts, by opening time, then id. Expired prompts stay\n * listed until tick removes them; deciding one is refused. */\nexport function promptsView (state: Readonly<HolderState>): PromptView[] {\n return freezeDeep(Object.values(state.prompts).sort((a, b) => (a.openedAt - b.openedAt) || cmp(a.id, b.id)).map((p) => ({\n commitSeq: state.commitSeq, id: p.id, kind: p.kind,\n ...(p.contactId !== undefined ? { contactId: p.contactId } : {}),\n ...(p.groupId !== undefined ? { groupId: p.groupId } : {}),\n openedAt: p.openedAt,\n ...(p.expiresAt !== undefined ? { expiresAt: p.expiresAt } : {}),\n })))\n}\n\n/** The sender status of the documents whose digest or threadId is `x`. */\nexport function deliveryStatusView (state: Readonly<HolderState>, x: string): DeliveryStatusView {\n const items = Object.entries(state.outbox)\n .filter(([digest, it]) => digest === x || it.threadId === x)\n .map(([digest, it]) => itemView(digest, it))\n .sort((a, b) => (a.submittedAt - b.submittedAt) || cmp(a.digest, b.digest))\n return freezeDeep({ commitSeq: state.commitSeq, items })\n}\n\n/** The inbox (Message Tasks 4.5), ordered by display time, then mid (4430). */\nexport function inboxView (state: Readonly<HolderState>): InboxMessageView[] {\n const out = Object.values(state.messages.inbox).map((e) => {\n const t = tupleByLabel(state, e.tuple)\n const c = t ? (findContact(state, t.tuple.entryId) ?? findContact(state, t.rel.contactId)) : undefined\n const b = e.body as { text: string, replyTo?: string, sentAt: string }\n return {\n commitSeq: state.commitSeq, id: e.id, ...(c ? { contactId: c.id } : {}),\n blocked: t !== null && state.messages.blocked.includes(t.rel.id),\n mid: e.mid, text: b.text, ...(b.replyTo !== undefined ? { replyTo: b.replyTo } : {}),\n sentAt: Date.parse(b.sentAt), receivedAt: e.receivedAt, displayAt: e.displayAt,\n }\n }).sort((a, b) => (a.displayAt - b.displayAt) || cmp(a.mid, b.mid) || cmp(a.id, b.id))\n return freezeDeep(out)\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-life/trust-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "The Real Life Trust Protocol (RLTP) \u2014 the executable form of the specification: encounters, introductions, trust disclosure, groups, continuity, and the delivery channel. Zero dependencies, WebCrypto only.",
|
|
5
5
|
"license": "CC-BY-4.0",
|
|
6
6
|
"type": "module",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "tsc -p tsconfig.json",
|
|
87
|
-
"test": "node --test test/vectors.test.mjs test/vectors2.test.mjs test/vectors3.test.mjs test/vectors4.test.mjs test/carrier.test.mjs test/loopback.test.mjs test/adapter-vti-mediator.test.mjs test/anchor.test.mjs test/codec.test.mjs test/codec-fixture.test.mjs test/holder-state-schema.test.mjs test/entropy.test.mjs test/entropy-lint.test.mjs test/store.test.mjs test/keys-seed.test.mjs test/engine.test.mjs test/views.test.mjs test/prompts.test.mjs test/receive.test.mjs test/duties.test.mjs test/retention.test.mjs test/crypto-lazy.test.mjs test/trust-mapping.test.mjs test/trust-admission.test.mjs test/trust-classes.test.mjs test/trust-star.test.mjs test/trust-group-star.test.mjs test/trust-continuity.test.mjs test/trust-entries.test.mjs test/trust-ported.test.mjs test/trust-duties.test.mjs test/invariants.test.mjs test/invariants-generator.test.mjs test/invariants-coverage.test.mjs test/identity.test.mjs test/profile.test.mjs test/sha256.test.mjs test/encounter-holder.test.mjs test/encounter-ported.test.mjs test/membership-holder.test.mjs test/introduction-holder.test.mjs test/block-holder.test.mjs test/message-vectors.test.mjs test/message-holder.test.mjs test/message-interleavings.test.mjs test/transport-custody.test.mjs test/transport-interleavings.test.mjs test/act-replay.test.mjs",
|
|
87
|
+
"test": "node --test test/vectors.test.mjs test/vectors2.test.mjs test/vectors3.test.mjs test/vectors4.test.mjs test/carrier.test.mjs test/loopback.test.mjs test/adapter-vti-mediator.test.mjs test/anchor.test.mjs test/codec.test.mjs test/codec-fixture.test.mjs test/holder-state-schema.test.mjs test/entropy.test.mjs test/entropy-lint.test.mjs test/store.test.mjs test/keys-seed.test.mjs test/engine.test.mjs test/views.test.mjs test/prompts.test.mjs test/receive.test.mjs test/duties.test.mjs test/retention.test.mjs test/crypto-lazy.test.mjs test/trust-mapping.test.mjs test/trust-admission.test.mjs test/trust-classes.test.mjs test/trust-star.test.mjs test/trust-group-star.test.mjs test/trust-continuity.test.mjs test/trust-entries.test.mjs test/trust-ported.test.mjs test/trust-duties.test.mjs test/invariants.test.mjs test/invariants-generator.test.mjs test/invariants-coverage.test.mjs test/identity.test.mjs test/profile.test.mjs test/sha256.test.mjs test/encounter-holder.test.mjs test/encounter-ported.test.mjs test/delivery-hints.test.mjs test/membership-holder.test.mjs test/introduction-holder.test.mjs test/block-holder.test.mjs test/message-vectors.test.mjs test/message-holder.test.mjs test/message-interleavings.test.mjs test/transport-custody.test.mjs test/transport-interleavings.test.mjs test/act-replay.test.mjs",
|
|
88
88
|
"prepack": "npm run build && npm test"
|
|
89
89
|
},
|
|
90
90
|
"keywords": [
|