@motebit/protocol 1.1.0 → 1.3.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.
Files changed (49) hide show
  1. package/dist/artifact-type.d.ts +118 -0
  2. package/dist/artifact-type.d.ts.map +1 -0
  3. package/dist/artifact-type.js +97 -0
  4. package/dist/artifact-type.js.map +1 -0
  5. package/dist/audience.d.ts +108 -0
  6. package/dist/audience.d.ts.map +1 -0
  7. package/dist/audience.js +104 -0
  8. package/dist/audience.js.map +1 -0
  9. package/dist/co-browse.d.ts +369 -0
  10. package/dist/co-browse.d.ts.map +1 -0
  11. package/dist/co-browse.js +64 -0
  12. package/dist/co-browse.js.map +1 -0
  13. package/dist/computer-use.d.ts +463 -3
  14. package/dist/computer-use.d.ts.map +1 -1
  15. package/dist/computer-use.js +40 -0
  16. package/dist/computer-use.js.map +1 -1
  17. package/dist/dispute.d.ts +150 -4
  18. package/dist/dispute.d.ts.map +1 -1
  19. package/dist/index.d.ts +311 -7
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +73 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/memory-events.d.ts +1 -1
  24. package/dist/memory-events.js +1 -1
  25. package/dist/money.d.ts +33 -0
  26. package/dist/money.d.ts.map +1 -0
  27. package/dist/money.js +41 -0
  28. package/dist/money.js.map +1 -0
  29. package/dist/perception.d.ts +308 -0
  30. package/dist/perception.d.ts.map +1 -0
  31. package/dist/perception.js +9 -0
  32. package/dist/perception.js.map +1 -0
  33. package/dist/retention-policy.d.ts +464 -0
  34. package/dist/retention-policy.d.ts.map +1 -0
  35. package/dist/retention-policy.js +128 -0
  36. package/dist/retention-policy.js.map +1 -0
  37. package/dist/sensitivity.d.ts +73 -0
  38. package/dist/sensitivity.d.ts.map +1 -0
  39. package/dist/sensitivity.js +97 -0
  40. package/dist/sensitivity.js.map +1 -0
  41. package/dist/skills.d.ts +334 -0
  42. package/dist/skills.d.ts.map +1 -0
  43. package/dist/skills.js +44 -0
  44. package/dist/skills.js.map +1 -0
  45. package/dist/transparency.d.ts +116 -0
  46. package/dist/transparency.d.ts.map +1 -0
  47. package/dist/transparency.js +67 -0
  48. package/dist/transparency.js.map +1 -0
  49. package/package.json +1 -1
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Content-artifact types — the closed registry of `artifact_type` claim
3
+ * values for the C2PA-shape content-provenance primitive
4
+ * (`ContentArtifactManifest` in `@motebit/crypto`).
5
+ *
6
+ * Provenance binding (per `docs/doctrine/self-attesting-system.md` and
7
+ * `docs/doctrine/nist-alignment.md` §8) requires every signed motebit
8
+ * artifact to carry a producer-declared category so a verifier can
9
+ * route, audit, or display the artifact without parsing its bytes.
10
+ * Pre-registry, the category was a free string in the manifest —
11
+ * a typo at a producer site (`artifact_type: "audit_trail"` instead
12
+ * of `"audit-trail"`) became a verifier-side classification miss
13
+ * with no compile-time signal. Locking the registry as a closed
14
+ * union makes the typo a compile error AND a CI error.
15
+ *
16
+ * **Closed registry shape** — same closure pattern as `TokenAudience`,
17
+ * `SuiteId`, `SettlementRail`, `ToolMode`, `ComputerActionKind`. The
18
+ * `ContentArtifactType` literal union is the wire law; named
19
+ * constants are the developer ergonomics. The drift gate
20
+ * `check-artifact-type-canonical` scans every `artifact_type:
21
+ * "<literal>"` and `artifactType: "<literal>"` call against
22
+ * `ALL_CONTENT_ARTIFACT_TYPES`.
23
+ *
24
+ * Adding a category is intentional protocol-level work: a new entry
25
+ * here, a new producer site, the doctrine reference at
26
+ * `docs/doctrine/nist-alignment.md` §8 updated. Same governance as
27
+ * cryptosuite agility (`SuiteId` registry) and audience binding
28
+ * (`TokenAudience` registry).
29
+ *
30
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
31
+ */
32
+ /**
33
+ * The closed set of content-artifact categories motebit currently
34
+ * signs. Today's set covers the twelve state-export endpoints at
35
+ * `services/relay/src/state-export.ts`, each wrapped in a
36
+ * relay-asserted `ContentArtifactManifest` per the doctrine §8
37
+ * recognition note (`docs/doctrine/nist-alignment.md`).
38
+ *
39
+ * - `state-snapshot` — relay's stored state vector for a motebit
40
+ * (`/api/v1/state/:motebitId`)
41
+ * - `memory-export` — memory-graph snapshot (nodes + edges) with
42
+ * optional sensitivity redaction (`/api/v1/memory/:motebitId`)
43
+ * - `goal-list` — motebit's declared goals
44
+ * (`/api/v1/goals/:motebitId`)
45
+ * - `conversation-list` — conversation index for a motebit
46
+ * (`/api/v1/conversations/:motebitId`)
47
+ * - `conversation-messages` — message history for a specific
48
+ * conversation
49
+ * (`/api/v1/conversations/:motebitId/:conversationId/messages`)
50
+ * - `device-list` — registered devices for a motebit
51
+ * (`/api/v1/devices/:motebitId`)
52
+ * - `audit-trail` — `ToolAuditEntry[]` for a motebit's session
53
+ * window (`/api/v1/audit/:motebitId`)
54
+ * - `plan-list` — plans for a motebit, each carrying its steps
55
+ * (`/api/v1/plans/:motebitId`)
56
+ * - `plan-detail` — a single plan with its steps
57
+ * (`/api/v1/plans/:motebitId/:planId`)
58
+ * - `gradient-history` — intelligence-gradient snapshots
59
+ * (`/api/v1/gradient/:motebitId`)
60
+ * - `sync-pull` — event-log pull beyond a clock cursor
61
+ * (`/api/v1/sync/:motebitId/pull`)
62
+ * - `execution-ledger` — execution timeline for a goal, including
63
+ * inner motebit-signed delegation receipt summaries; the
64
+ * canonical layered-signing consumer
65
+ * (`/api/v1/execution/:motebitId/:goalId`)
66
+ *
67
+ * Adding an endpoint is intentional protocol-level work: a new
68
+ * `ContentArtifactType` entry here, a new named constant, a new
69
+ * `ALL_CONTENT_ARTIFACT_TYPES` member, gate-side `CANONICAL_ARTIFACT_TYPES`
70
+ * update in `scripts/check-artifact-type-canonical.ts`. Drift gate
71
+ * `check-state-export-signed` enforces that every new `app.get(...)`
72
+ * in `services/relay/src/state-export.ts` emits a manifest before
73
+ * returning.
74
+ */
75
+ export type ContentArtifactType = "state-snapshot" | "memory-export" | "goal-list" | "conversation-list" | "conversation-messages" | "device-list" | "audit-trail" | "plan-list" | "plan-detail" | "gradient-history" | "sync-pull" | "execution-ledger";
76
+ /** Relay's stored state-vector snapshot for a motebit. */
77
+ export declare const STATE_SNAPSHOT_ARTIFACT: ContentArtifactType;
78
+ /** Relay-assembled memory-graph snapshot (nodes + edges). */
79
+ export declare const MEMORY_EXPORT_ARTIFACT: ContentArtifactType;
80
+ /** Relay-assembled goal list for a motebit. */
81
+ export declare const GOAL_LIST_ARTIFACT: ContentArtifactType;
82
+ /** Relay-assembled conversation index for a motebit. */
83
+ export declare const CONVERSATION_LIST_ARTIFACT: ContentArtifactType;
84
+ /** Relay-assembled message history for a specific conversation. */
85
+ export declare const CONVERSATION_MESSAGES_ARTIFACT: ContentArtifactType;
86
+ /** Relay-assembled list of devices registered to a motebit. */
87
+ export declare const DEVICE_LIST_ARTIFACT: ContentArtifactType;
88
+ /** Relay-assembled tool-audit-trail export. */
89
+ export declare const AUDIT_TRAIL_ARTIFACT: ContentArtifactType;
90
+ /** Relay-assembled list of plans for a motebit, each with embedded steps. */
91
+ export declare const PLAN_LIST_ARTIFACT: ContentArtifactType;
92
+ /** Relay-assembled single-plan export with its steps. */
93
+ export declare const PLAN_DETAIL_ARTIFACT: ContentArtifactType;
94
+ /** Relay-assembled intelligence-gradient-history export. */
95
+ export declare const GRADIENT_HISTORY_ARTIFACT: ContentArtifactType;
96
+ /** Relay-assembled event-log pull beyond a `version_clock` cursor. */
97
+ export declare const SYNC_PULL_ARTIFACT: ContentArtifactType;
98
+ /**
99
+ * Relay-assembled execution-timeline export with embedded motebit-signed
100
+ * delegation receipts. Canonical layered-signing consumer — outer relay
101
+ * manifest attests bundle assembly, inner motebit signatures pass through
102
+ * byte-identical. See `spec/execution-ledger-v1.md`.
103
+ */
104
+ export declare const EXECUTION_LEDGER_ARTIFACT: ContentArtifactType;
105
+ /**
106
+ * Canonical iteration order, frozen. Consumers that need to iterate
107
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
108
+ * union rather than `string[]`.
109
+ */
110
+ export declare const ALL_CONTENT_ARTIFACT_TYPES: readonly ContentArtifactType[];
111
+ /**
112
+ * Type guard — narrows `unknown` to `ContentArtifactType`. Drift-gate-driven
113
+ * literal scanners use this to validate strings; verifiers that want to
114
+ * dispatch on category call this before the switch so an unchecked cast
115
+ * is a fail-open path the gate will flag.
116
+ */
117
+ export declare function isContentArtifactType(value: unknown): value is ContentArtifactType;
118
+ //# sourceMappingURL=artifact-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-type.d.ts","sourceRoot":"","sources":["../src/artifact-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,MAAM,mBAAmB,GAC3B,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,mBAAmB,GACnB,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,WAAW,GACX,aAAa,GACb,kBAAkB,GAClB,WAAW,GACX,kBAAkB,CAAC;AAUvB,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,EAAE,mBAAsC,CAAC;AAE7E,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,EAAE,mBAAqC,CAAC;AAE3E,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB,EAAE,mBAAiC,CAAC;AAEnE,wDAAwD;AACxD,eAAO,MAAM,0BAA0B,EAAE,mBAAyC,CAAC;AAEnF,mEAAmE;AACnE,eAAO,MAAM,8BAA8B,EAAE,mBAA6C,CAAC;AAE3F,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAEvE,+CAA+C;AAC/C,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAEvE,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,EAAE,mBAAiC,CAAC;AAEnE,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAEvE,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,EAAE,mBAAwC,CAAC;AAEjF,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,EAAE,mBAAiC,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAAwC,CAAC;AAIjF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,mBAAmB,EAanE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAIlF"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Content-artifact types — the closed registry of `artifact_type` claim
3
+ * values for the C2PA-shape content-provenance primitive
4
+ * (`ContentArtifactManifest` in `@motebit/crypto`).
5
+ *
6
+ * Provenance binding (per `docs/doctrine/self-attesting-system.md` and
7
+ * `docs/doctrine/nist-alignment.md` §8) requires every signed motebit
8
+ * artifact to carry a producer-declared category so a verifier can
9
+ * route, audit, or display the artifact without parsing its bytes.
10
+ * Pre-registry, the category was a free string in the manifest —
11
+ * a typo at a producer site (`artifact_type: "audit_trail"` instead
12
+ * of `"audit-trail"`) became a verifier-side classification miss
13
+ * with no compile-time signal. Locking the registry as a closed
14
+ * union makes the typo a compile error AND a CI error.
15
+ *
16
+ * **Closed registry shape** — same closure pattern as `TokenAudience`,
17
+ * `SuiteId`, `SettlementRail`, `ToolMode`, `ComputerActionKind`. The
18
+ * `ContentArtifactType` literal union is the wire law; named
19
+ * constants are the developer ergonomics. The drift gate
20
+ * `check-artifact-type-canonical` scans every `artifact_type:
21
+ * "<literal>"` and `artifactType: "<literal>"` call against
22
+ * `ALL_CONTENT_ARTIFACT_TYPES`.
23
+ *
24
+ * Adding a category is intentional protocol-level work: a new entry
25
+ * here, a new producer site, the doctrine reference at
26
+ * `docs/doctrine/nist-alignment.md` §8 updated. Same governance as
27
+ * cryptosuite agility (`SuiteId` registry) and audience binding
28
+ * (`TokenAudience` registry).
29
+ *
30
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
31
+ */
32
+ // === Named constants — same value, narrower type ============================
33
+ //
34
+ // Callers that import these get `ContentArtifactType` typing without the
35
+ // union being inferred from a string-literal at every site. Two ergonomic
36
+ // shapes: pass a constant (`EXECUTION_LEDGER_ARTIFACT`) for documentation +
37
+ // grep affordance, or inline the literal — the union narrowing catches typos
38
+ // in either case.
39
+ /** Relay's stored state-vector snapshot for a motebit. */
40
+ export const STATE_SNAPSHOT_ARTIFACT = "state-snapshot";
41
+ /** Relay-assembled memory-graph snapshot (nodes + edges). */
42
+ export const MEMORY_EXPORT_ARTIFACT = "memory-export";
43
+ /** Relay-assembled goal list for a motebit. */
44
+ export const GOAL_LIST_ARTIFACT = "goal-list";
45
+ /** Relay-assembled conversation index for a motebit. */
46
+ export const CONVERSATION_LIST_ARTIFACT = "conversation-list";
47
+ /** Relay-assembled message history for a specific conversation. */
48
+ export const CONVERSATION_MESSAGES_ARTIFACT = "conversation-messages";
49
+ /** Relay-assembled list of devices registered to a motebit. */
50
+ export const DEVICE_LIST_ARTIFACT = "device-list";
51
+ /** Relay-assembled tool-audit-trail export. */
52
+ export const AUDIT_TRAIL_ARTIFACT = "audit-trail";
53
+ /** Relay-assembled list of plans for a motebit, each with embedded steps. */
54
+ export const PLAN_LIST_ARTIFACT = "plan-list";
55
+ /** Relay-assembled single-plan export with its steps. */
56
+ export const PLAN_DETAIL_ARTIFACT = "plan-detail";
57
+ /** Relay-assembled intelligence-gradient-history export. */
58
+ export const GRADIENT_HISTORY_ARTIFACT = "gradient-history";
59
+ /** Relay-assembled event-log pull beyond a `version_clock` cursor. */
60
+ export const SYNC_PULL_ARTIFACT = "sync-pull";
61
+ /**
62
+ * Relay-assembled execution-timeline export with embedded motebit-signed
63
+ * delegation receipts. Canonical layered-signing consumer — outer relay
64
+ * manifest attests bundle assembly, inner motebit signatures pass through
65
+ * byte-identical. See `spec/execution-ledger-v1.md`.
66
+ */
67
+ export const EXECUTION_LEDGER_ARTIFACT = "execution-ledger";
68
+ // === Iteration + type guard =================================================
69
+ /**
70
+ * Canonical iteration order, frozen. Consumers that need to iterate
71
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
72
+ * union rather than `string[]`.
73
+ */
74
+ export const ALL_CONTENT_ARTIFACT_TYPES = Object.freeze([
75
+ "state-snapshot",
76
+ "memory-export",
77
+ "goal-list",
78
+ "conversation-list",
79
+ "conversation-messages",
80
+ "device-list",
81
+ "audit-trail",
82
+ "plan-list",
83
+ "plan-detail",
84
+ "gradient-history",
85
+ "sync-pull",
86
+ "execution-ledger",
87
+ ]);
88
+ /**
89
+ * Type guard — narrows `unknown` to `ContentArtifactType`. Drift-gate-driven
90
+ * literal scanners use this to validate strings; verifiers that want to
91
+ * dispatch on category call this before the switch so an unchecked cast
92
+ * is a fail-open path the gate will flag.
93
+ */
94
+ export function isContentArtifactType(value) {
95
+ return (typeof value === "string" && ALL_CONTENT_ARTIFACT_TYPES.includes(value));
96
+ }
97
+ //# sourceMappingURL=artifact-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-type.js","sourceRoot":"","sources":["../src/artifact-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA2DH,+EAA+E;AAC/E,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,kBAAkB;AAElB,0DAA0D;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAwB,gBAAgB,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAwB,eAAe,CAAC;AAE3E,+CAA+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAwB,WAAW,CAAC;AAEnE,wDAAwD;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAwB,mBAAmB,CAAC;AAEnF,mEAAmE;AACnE,MAAM,CAAC,MAAM,8BAA8B,GAAwB,uBAAuB,CAAC;AAE3F,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAwB,WAAW,CAAC;AAEnE,yDAAyD;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,yBAAyB,GAAwB,kBAAkB,CAAC;AAEjF,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAwB,WAAW,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,kBAAkB,CAAC;AAEjF,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAmC,MAAM,CAAC,MAAM,CAAC;IACtF,gBAAgB;IAChB,eAAe;IACf,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,aAAa;IACb,aAAa;IACb,WAAW;IACX,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,kBAAkB;CACnB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAK,0BAAgD,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC/F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Token audiences — the closed registry of `aud` claim values for the
3
+ * audience-bound signed-token primitive (`SignedTokenPayload`).
4
+ *
5
+ * Audience binding (per `docs/doctrine/security-boundaries.md` and
6
+ * `services/relay/CLAUDE.md` Rule 5) prevents cross-endpoint replay:
7
+ * a token minted for one purpose cannot be reused for another. Every
8
+ * signed bearer in motebit carries `aud`; verifiers reject a missing
9
+ * or unexpected value fail-closed.
10
+ *
11
+ * **Closed registry shape** — same closure pattern as `SuiteId`,
12
+ * `SettlementRail`, `ToolMode`, `ComputerActionKind`. The `TokenAudience`
13
+ * literal union is the wire law; named constants are the developer
14
+ * ergonomics. A typo at a signing site (`"task:sumbit"`) is rejected
15
+ * by the union narrowing AND by the `check-audience-canonical` drift
16
+ * gate, which scans every `aud: "<literal>"` and
17
+ * `createSyncToken("<literal>")` call against `ALL_TOKEN_AUDIENCES`.
18
+ *
19
+ * Adding an audience is intentional protocol-level work: a new entry
20
+ * here, a new caller-or-route registration, a doctrine update at
21
+ * `services/relay/CLAUDE.md` Rule 5. Renaming a literal is a wire
22
+ * break (verifiers reject the old value); deletions break running
23
+ * deployments. Same-shape decisions as cryptosuite agility.
24
+ *
25
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
26
+ */
27
+ /**
28
+ * The closed set of audience identifiers motebit currently uses.
29
+ *
30
+ * Categories (organizational; the union is flat):
31
+ *
32
+ * **Multi-device + identity lifecycle**
33
+ * - `sync` — websocket sync + general relay state operations
34
+ * - `device:auth` — per-device auth headers on relay calls
35
+ * - `pair` — device-pairing flow (claim, transfer)
36
+ * - `rotate-key` — key rotation requests
37
+ * - `push:register` — push-notification token registration
38
+ *
39
+ * **Task routing**
40
+ * - `task:submit` — submitting a task to a peer via the relay
41
+ * - `admin:query` — admin-bound read paths (transparency, etc.)
42
+ * - `proposal` — collaborative proposal lifecycle
43
+ *
44
+ * **Virtual accounts (the relay-mediated economic loop)**
45
+ * - `account:balance` — read balance
46
+ * - `account:deposit` — deposit endpoint (Stripe / x402 / Solana)
47
+ * - `account:withdraw` — withdraw endpoint
48
+ * - `account:withdrawals` — list withdrawals
49
+ * - `account:checkout` — Stripe checkout session create
50
+ *
51
+ * **Browser-sandbox dispatcher token (relay-mediated auth)**
52
+ * - `browser-sandbox-grant` — motebit→relay grant request
53
+ * - `browser-sandbox` — relay→motebit→sandbox dispatcher token
54
+ */
55
+ export type TokenAudience = "sync" | "device:auth" | "pair" | "rotate-key" | "push:register" | "task:submit" | "admin:query" | "proposal" | "account:balance" | "account:deposit" | "account:withdraw" | "account:withdrawals" | "account:checkout" | "browser-sandbox-grant" | "browser-sandbox";
56
+ /** Multi-device sync + general relay state operations. */
57
+ export declare const SYNC_AUDIENCE: TokenAudience;
58
+ /** Per-device auth headers on relay calls. Apps mint this for ad-hoc reads. */
59
+ export declare const DEVICE_AUTH_AUDIENCE: TokenAudience;
60
+ /** Device-pairing flow — claim + transfer. */
61
+ export declare const PAIR_AUDIENCE: TokenAudience;
62
+ /** Key rotation requests against the relay. */
63
+ export declare const ROTATE_KEY_AUDIENCE: TokenAudience;
64
+ /** Push-notification token registration (APNs / FCM). */
65
+ export declare const PUSH_REGISTER_AUDIENCE: TokenAudience;
66
+ /** Submitting a task to a peer via the relay. */
67
+ export declare const TASK_SUBMIT_AUDIENCE: TokenAudience;
68
+ /** Admin-bound read paths (transparency, etc.). */
69
+ export declare const ADMIN_QUERY_AUDIENCE: TokenAudience;
70
+ /** Collaborative proposal lifecycle. */
71
+ export declare const PROPOSAL_AUDIENCE: TokenAudience;
72
+ /** Read virtual-account balance. */
73
+ export declare const ACCOUNT_BALANCE_AUDIENCE: TokenAudience;
74
+ /** Deposit endpoint (Stripe / x402 / Solana). */
75
+ export declare const ACCOUNT_DEPOSIT_AUDIENCE: TokenAudience;
76
+ /** Withdraw endpoint. */
77
+ export declare const ACCOUNT_WITHDRAW_AUDIENCE: TokenAudience;
78
+ /** List withdrawals (history). */
79
+ export declare const ACCOUNT_WITHDRAWALS_AUDIENCE: TokenAudience;
80
+ /** Stripe checkout session create. */
81
+ export declare const ACCOUNT_CHECKOUT_AUDIENCE: TokenAudience;
82
+ /**
83
+ * Audience for the motebit-signed grant request to the relay's
84
+ * `POST /api/v1/browser-sandbox/token` endpoint. Verified by the relay
85
+ * via `verifySignedTokenForDevice`.
86
+ */
87
+ export declare const BROWSER_SANDBOX_GRANT_AUDIENCE: TokenAudience;
88
+ /**
89
+ * Audience for the relay-signed sandbox token. Verified by
90
+ * `services/browser-sandbox` against the pinned relay public key.
91
+ *
92
+ * See `spec/computer-use-v1.md` §8.2 for the wire-format binding.
93
+ */
94
+ export declare const BROWSER_SANDBOX_AUDIENCE: TokenAudience;
95
+ /**
96
+ * Canonical iteration order, frozen. Consumers that need to iterate
97
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
98
+ * union rather than `string[]`.
99
+ */
100
+ export declare const ALL_TOKEN_AUDIENCES: readonly TokenAudience[];
101
+ /**
102
+ * Type guard — narrows `unknown` to `TokenAudience`. Drift-gate-driven
103
+ * audience-string scanners use this to validate literals; verifiers
104
+ * call this before dispatch so an unchecked cast is a fail-open path
105
+ * the gate will flag.
106
+ */
107
+ export declare function isTokenAudience(value: unknown): value is TokenAudience;
108
+ //# sourceMappingURL=audience.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,aAAa,GACb,MAAM,GACN,YAAY,GACZ,eAAe,GACf,aAAa,GACb,aAAa,GACb,UAAU,GACV,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,qBAAqB,GACrB,kBAAkB,GAClB,uBAAuB,GACvB,iBAAiB,CAAC;AAStB,0DAA0D;AAC1D,eAAO,MAAM,aAAa,EAAE,aAAsB,CAAC;AAEnD,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,EAAE,aAA6B,CAAC;AAEjE,8CAA8C;AAC9C,eAAO,MAAM,aAAa,EAAE,aAAsB,CAAC;AAEnD,+CAA+C;AAC/C,eAAO,MAAM,mBAAmB,EAAE,aAA4B,CAAC;AAE/D,yDAAyD;AACzD,eAAO,MAAM,sBAAsB,EAAE,aAA+B,CAAC;AAErE,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,EAAE,aAA6B,CAAC;AAEjE,mDAAmD;AACnD,eAAO,MAAM,oBAAoB,EAAE,aAA6B,CAAC;AAEjE,wCAAwC;AACxC,eAAO,MAAM,iBAAiB,EAAE,aAA0B,CAAC;AAE3D,oCAAoC;AACpC,eAAO,MAAM,wBAAwB,EAAE,aAAiC,CAAC;AAEzE,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,EAAE,aAAiC,CAAC;AAEzE,yBAAyB;AACzB,eAAO,MAAM,yBAAyB,EAAE,aAAkC,CAAC;AAE3E,kCAAkC;AAClC,eAAO,MAAM,4BAA4B,EAAE,aAAqC,CAAC;AAEjF,sCAAsC;AACtC,eAAO,MAAM,yBAAyB,EAAE,aAAkC,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,aAAuC,CAAC;AAErF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAAiC,CAAC;AAIzE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,aAAa,EAgBtD,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Token audiences — the closed registry of `aud` claim values for the
3
+ * audience-bound signed-token primitive (`SignedTokenPayload`).
4
+ *
5
+ * Audience binding (per `docs/doctrine/security-boundaries.md` and
6
+ * `services/relay/CLAUDE.md` Rule 5) prevents cross-endpoint replay:
7
+ * a token minted for one purpose cannot be reused for another. Every
8
+ * signed bearer in motebit carries `aud`; verifiers reject a missing
9
+ * or unexpected value fail-closed.
10
+ *
11
+ * **Closed registry shape** — same closure pattern as `SuiteId`,
12
+ * `SettlementRail`, `ToolMode`, `ComputerActionKind`. The `TokenAudience`
13
+ * literal union is the wire law; named constants are the developer
14
+ * ergonomics. A typo at a signing site (`"task:sumbit"`) is rejected
15
+ * by the union narrowing AND by the `check-audience-canonical` drift
16
+ * gate, which scans every `aud: "<literal>"` and
17
+ * `createSyncToken("<literal>")` call against `ALL_TOKEN_AUDIENCES`.
18
+ *
19
+ * Adding an audience is intentional protocol-level work: a new entry
20
+ * here, a new caller-or-route registration, a doctrine update at
21
+ * `services/relay/CLAUDE.md` Rule 5. Renaming a literal is a wire
22
+ * break (verifiers reject the old value); deletions break running
23
+ * deployments. Same-shape decisions as cryptosuite agility.
24
+ *
25
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
26
+ */
27
+ // === Named constants — same value, narrower type ============================
28
+ //
29
+ // Callers that import these get `TokenAudience` typing without the union
30
+ // being inferred from a string-literal at every site. Two ergonomic shapes:
31
+ // pass a constant (`SYNC_AUDIENCE`) for documentation + grep affordance, or
32
+ // inline the literal — the union narrowing catches typos in either case.
33
+ /** Multi-device sync + general relay state operations. */
34
+ export const SYNC_AUDIENCE = "sync";
35
+ /** Per-device auth headers on relay calls. Apps mint this for ad-hoc reads. */
36
+ export const DEVICE_AUTH_AUDIENCE = "device:auth";
37
+ /** Device-pairing flow — claim + transfer. */
38
+ export const PAIR_AUDIENCE = "pair";
39
+ /** Key rotation requests against the relay. */
40
+ export const ROTATE_KEY_AUDIENCE = "rotate-key";
41
+ /** Push-notification token registration (APNs / FCM). */
42
+ export const PUSH_REGISTER_AUDIENCE = "push:register";
43
+ /** Submitting a task to a peer via the relay. */
44
+ export const TASK_SUBMIT_AUDIENCE = "task:submit";
45
+ /** Admin-bound read paths (transparency, etc.). */
46
+ export const ADMIN_QUERY_AUDIENCE = "admin:query";
47
+ /** Collaborative proposal lifecycle. */
48
+ export const PROPOSAL_AUDIENCE = "proposal";
49
+ /** Read virtual-account balance. */
50
+ export const ACCOUNT_BALANCE_AUDIENCE = "account:balance";
51
+ /** Deposit endpoint (Stripe / x402 / Solana). */
52
+ export const ACCOUNT_DEPOSIT_AUDIENCE = "account:deposit";
53
+ /** Withdraw endpoint. */
54
+ export const ACCOUNT_WITHDRAW_AUDIENCE = "account:withdraw";
55
+ /** List withdrawals (history). */
56
+ export const ACCOUNT_WITHDRAWALS_AUDIENCE = "account:withdrawals";
57
+ /** Stripe checkout session create. */
58
+ export const ACCOUNT_CHECKOUT_AUDIENCE = "account:checkout";
59
+ /**
60
+ * Audience for the motebit-signed grant request to the relay's
61
+ * `POST /api/v1/browser-sandbox/token` endpoint. Verified by the relay
62
+ * via `verifySignedTokenForDevice`.
63
+ */
64
+ export const BROWSER_SANDBOX_GRANT_AUDIENCE = "browser-sandbox-grant";
65
+ /**
66
+ * Audience for the relay-signed sandbox token. Verified by
67
+ * `services/browser-sandbox` against the pinned relay public key.
68
+ *
69
+ * See `spec/computer-use-v1.md` §8.2 for the wire-format binding.
70
+ */
71
+ export const BROWSER_SANDBOX_AUDIENCE = "browser-sandbox";
72
+ // === Iteration + type guard =================================================
73
+ /**
74
+ * Canonical iteration order, frozen. Consumers that need to iterate
75
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
76
+ * union rather than `string[]`.
77
+ */
78
+ export const ALL_TOKEN_AUDIENCES = Object.freeze([
79
+ "sync",
80
+ "device:auth",
81
+ "pair",
82
+ "rotate-key",
83
+ "push:register",
84
+ "task:submit",
85
+ "admin:query",
86
+ "proposal",
87
+ "account:balance",
88
+ "account:deposit",
89
+ "account:withdraw",
90
+ "account:withdrawals",
91
+ "account:checkout",
92
+ "browser-sandbox-grant",
93
+ "browser-sandbox",
94
+ ]);
95
+ /**
96
+ * Type guard — narrows `unknown` to `TokenAudience`. Drift-gate-driven
97
+ * audience-string scanners use this to validate literals; verifiers
98
+ * call this before dispatch so an unchecked cast is a fail-open path
99
+ * the gate will flag.
100
+ */
101
+ export function isTokenAudience(value) {
102
+ return typeof value === "string" && ALL_TOKEN_AUDIENCES.includes(value);
103
+ }
104
+ //# sourceMappingURL=audience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AA+CH,+EAA+E;AAC/E,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AAEzE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAkB,aAAa,CAAC;AAEjE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC;AAEnD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAkB,YAAY,CAAC;AAE/D,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAkB,eAAe,CAAC;AAErE,iDAAiD;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAkB,aAAa,CAAC;AAEjE,mDAAmD;AACnD,MAAM,CAAC,MAAM,oBAAoB,GAAkB,aAAa,CAAC;AAEjE,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAkB,UAAU,CAAC;AAE3D,oCAAoC;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAkB,iBAAiB,CAAC;AAEzE,iDAAiD;AACjD,MAAM,CAAC,MAAM,wBAAwB,GAAkB,iBAAiB,CAAC;AAEzE,yBAAyB;AACzB,MAAM,CAAC,MAAM,yBAAyB,GAAkB,kBAAkB,CAAC;AAE3E,kCAAkC;AAClC,MAAM,CAAC,MAAM,4BAA4B,GAAkB,qBAAqB,CAAC;AAEjF,sCAAsC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAkB,kBAAkB,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAkB,uBAAuB,CAAC;AAErF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkB,iBAAiB,CAAC;AAEzE,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA6B,MAAM,CAAC,MAAM,CAAC;IACzE,MAAM;IACN,aAAa;IACb,MAAM;IACN,YAAY;IACZ,eAAe;IACf,aAAa;IACb,aAAa;IACb,UAAU;IACV,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,kBAAkB;IAClB,uBAAuB;IACvB,iBAAiB;CAClB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,mBAAyC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjG,CAAC"}