@suveren/gateway 0.7.4 → 0.7.6

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 (171) hide show
  1. package/dist/control-plane/index.mjs +248 -58
  2. package/dist/mcp-server/http.mjs +408 -65
  3. package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
  4. package/dist/ui/assets/index-CsrM6RQr.js +110 -0
  5. package/dist/ui/index.html +2 -2
  6. package/node_modules/@hap/core/dist/index.d.mts +258 -9
  7. package/node_modules/@hap/core/dist/index.d.ts +258 -9
  8. package/node_modules/@hap/core/dist/index.js +227 -5
  9. package/node_modules/@hap/core/dist/index.mjs +213 -4
  10. package/node_modules/@hap/core/package.json +3 -2
  11. package/node_modules/@hap/core/src/did-key.ts +126 -0
  12. package/node_modules/@hap/core/src/identity.ts +21 -5
  13. package/node_modules/@hap/core/src/index.ts +3 -0
  14. package/node_modules/@hap/core/src/mandate.ts +207 -0
  15. package/node_modules/@hap/core/src/receipt.ts +74 -0
  16. package/node_modules/@hap/core/src/types.ts +81 -5
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
  19. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
  29. package/node_modules/@types/node/README.md +1 -1
  30. package/node_modules/@types/node/buffer.buffer.d.ts +5 -5
  31. package/node_modules/@types/node/crypto.d.ts +2 -2
  32. package/node_modules/@types/node/http.d.ts +16 -0
  33. package/node_modules/@types/node/http2.d.ts +10 -2
  34. package/node_modules/@types/node/package.json +2 -2
  35. package/node_modules/@types/node/process.d.ts +52 -0
  36. package/node_modules/@types/node/quic.d.ts +210 -28
  37. package/node_modules/@types/node/sqlite.d.ts +6 -2
  38. package/node_modules/@types/node/test.d.ts +36 -0
  39. package/node_modules/fast-uri/index.js +201 -48
  40. package/node_modules/fast-uri/lib/schemes.js +9 -4
  41. package/node_modules/fast-uri/lib/utils.js +388 -91
  42. package/node_modules/fast-uri/package.json +1 -1
  43. package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
  44. package/node_modules/fast-uri/test/equal.test.js +31 -3
  45. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
  46. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  47. package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
  48. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  49. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  50. package/node_modules/fast-uri/test/parse.test.js +7 -3
  51. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  52. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  53. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  54. package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
  55. package/node_modules/fast-uri/test/security.test.js +75 -3
  56. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  57. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  58. package/node_modules/hono/dist/cjs/client/client.js +25 -11
  59. package/node_modules/hono/dist/cjs/client/utils.js +4 -1
  60. package/node_modules/hono/dist/cjs/context.js +4 -0
  61. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
  62. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
  63. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
  64. package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
  65. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  66. package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
  67. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  68. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
  69. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
  70. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  71. package/node_modules/hono/dist/cjs/request.js +8 -4
  72. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  73. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  74. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
  75. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
  76. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
  77. package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
  78. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  79. package/node_modules/hono/dist/cjs/router/utils.js +27 -0
  80. package/node_modules/hono/dist/cjs/utils/body.js +15 -3
  81. package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
  82. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  83. package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
  84. package/node_modules/hono/dist/cjs/utils/url.js +9 -1
  85. package/node_modules/hono/dist/client/client.js +25 -11
  86. package/node_modules/hono/dist/client/utils.js +4 -1
  87. package/node_modules/hono/dist/context.js +4 -0
  88. package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
  89. package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
  90. package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
  91. package/node_modules/hono/dist/jsx/dom/render.js +2 -0
  92. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  93. package/node_modules/hono/dist/middleware/cors/index.js +1 -1
  94. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  95. package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
  96. package/node_modules/hono/dist/middleware/etag/index.js +3 -3
  97. package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
  98. package/node_modules/hono/dist/request.js +8 -4
  99. package/node_modules/hono/dist/router/linear-router/router.js +7 -2
  100. package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
  101. package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
  102. package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
  103. package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
  104. package/node_modules/hono/dist/router/trie-router/node.js +46 -69
  105. package/node_modules/hono/dist/router/trie-router/router.js +3 -11
  106. package/node_modules/hono/dist/router/utils.js +5 -0
  107. package/node_modules/hono/dist/types/context.d.ts +4 -0
  108. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
  109. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
  110. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
  111. package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
  112. package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
  113. package/node_modules/hono/dist/utils/body.js +15 -3
  114. package/node_modules/hono/dist/utils/cookie.js +1 -1
  115. package/node_modules/hono/dist/utils/ipaddr.js +5 -3
  116. package/node_modules/hono/dist/utils/stream.js +7 -1
  117. package/node_modules/hono/dist/utils/url.js +9 -1
  118. package/node_modules/hono/package.json +1 -1
  119. package/node_modules/is-plain-object/README.md +39 -95
  120. package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
  121. package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
  122. package/node_modules/is-plain-object/package.json +8 -34
  123. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
  124. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
  125. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
  126. package/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
  127. package/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
  128. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +12 -17
  129. package/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
  130. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
  131. package/node_modules/jose/dist/types/types.d.ts +4 -2
  132. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
  133. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
  134. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
  135. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
  136. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +32 -21
  137. package/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
  138. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
  139. package/node_modules/jose/dist/webapi/jwks/local.js +45 -53
  140. package/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
  141. package/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
  142. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
  143. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
  144. package/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
  145. package/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
  146. package/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
  147. package/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
  148. package/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
  149. package/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
  150. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
  151. package/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
  152. package/node_modules/jose/dist/webapi/key/import.js +16 -12
  153. package/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
  154. package/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
  155. package/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
  156. package/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
  157. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
  158. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +45 -13
  159. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
  160. package/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
  161. package/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
  162. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
  163. package/node_modules/jose/dist/webapi/lib/key.js +24 -9
  164. package/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
  165. package/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
  166. package/node_modules/jose/dist/webapi/lib/options.js +26 -0
  167. package/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
  168. package/node_modules/jose/package.json +1 -1
  169. package/package.json +2 -2
  170. package/dist/ui/assets/index-0Q2eNytX.js +0 -110
  171. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
@@ -8,8 +8,8 @@
8
8
  because tab chrome does. -->
9
9
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
10
10
  <title>Suveren</title>
11
- <script type="module" crossorigin src="/assets/index-0Q2eNytX.js"></script>
12
- <link rel="stylesheet" crossorigin href="/assets/index-CkWaRck1.css">
11
+ <script type="module" crossorigin src="/assets/index-CsrM6RQr.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-BYVb_0oG.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
@@ -14,7 +14,7 @@ interface ResolvedDomain {
14
14
  }
15
15
  interface AttestationPayload {
16
16
  attestation_id: string;
17
- version: '0.3' | '0.4' | '0.5';
17
+ version: '0.3' | '0.4' | '0.5' | '0.6';
18
18
  profile_id: string;
19
19
  /** v0.3 (deprecated) — hash of the authorization frame */
20
20
  frame_hash?: string;
@@ -62,11 +62,51 @@ interface AttestationPayload {
62
62
  *
63
63
  * Cryptographically bound in the signed payload so a compromised SP cannot
64
64
  * silently flip 'review' → 'automatic'. Absent on v0.3 attestations.
65
+ * `review_above_cap` (v0.5): automatic below the signed caps, proposal above.
65
66
  */
66
- commitment_mode?: 'automatic' | 'review';
67
+ commitment_mode?: 'automatic' | 'review' | 'review_above_cap';
68
+ /**
69
+ * v0.6 (Owner Mandate Signatures) — the Decision Owner's own signature(s)
70
+ * over the mandate projection ({@link MandateProjection}), one entry per
71
+ * co-signing owner. Carried INSIDE the AS-signed payload, so the AS attests
72
+ * to having received it and cannot strip it without invalidating its own
73
+ * signature. Optional and additive: an attestation without it behaves as
74
+ * before (the v0.5 posture — the AS asserts, nobody co-signs).
75
+ */
76
+ owner_mandates?: OwnerMandate[];
67
77
  issued_at: number;
68
78
  expires_at: number;
69
79
  }
80
+ /** Mandate-assurance axis — what custody signed the mandate. Independent of
81
+ * identity assurance ({@link Subject.method}). */
82
+ type MandateBinding = 'raw' | 'webauthn' | 'eudi';
83
+ /** Which surface showed the owner what they signed. A DECLARATION, not a proof
84
+ * — no verifier can check it; see protocol.md → Owner Mandate Signatures. */
85
+ type SigningSurface = 'gatekeeper_local' | 'as_web' | 'wallet_display';
86
+ /**
87
+ * v0.6 — one owner's signature over the mandate projection.
88
+ *
89
+ * There is deliberately NO `public_key` field, and it MUST NOT be added: the
90
+ * verification key is carried in the DID itself (key-bearing `did:key`), so a
91
+ * non-key-bearing DID fails STRUCTURALLY instead of validating against a key
92
+ * the AS could have substituted. `alg` is kept only as curve-confusion
93
+ * hygiene; if it disagrees with the DID's key type, the DID is authoritative.
94
+ */
95
+ interface OwnerMandate {
96
+ /** The signing owner's key-bearing DID. MUST be a member of `resolved_owners`. */
97
+ did: string;
98
+ /** Signature algorithm hint. The DID's multicodec wins on any disagreement. */
99
+ alg: 'EdDSA' | 'ES256';
100
+ /** base64url (no padding) signature over the JCS bytes of the mandate projection. */
101
+ signature: string;
102
+ /** When the owner signed (unix seconds). */
103
+ signed_at: number;
104
+ /** Defence-in-depth against duplicate issuance by an HONEST AS only —
105
+ * AS-side nonce enforcement is no defence against the AS itself. */
106
+ nonce: string;
107
+ binding: MandateBinding;
108
+ signing_surface?: SigningSurface;
109
+ }
70
110
  /**
71
111
  * v0.6 Identity Assurance — a signed overlay binding a Decision Owner's verified
72
112
  * real-world identity to the attestation, gated by HOW the identity was verified.
@@ -94,8 +134,11 @@ interface Subject {
94
134
  /** When the underlying verification was performed (unix seconds). */
95
135
  verified_at?: number;
96
136
  /**
97
- * eudi only (Phase 2) the owner's per-event wallet signature, making the
98
- * identity claim non-repudiable independent of the AS. Null/absent otherwise.
137
+ * @deprecated v0.6replaced by {@link AttestationPayload.owner_mandates}.
138
+ * This field signed the wrong object (the identity claim, not what was
139
+ * committed to) and was welded to one method. Implementations MUST NOT emit
140
+ * it; verifiers MAY ignore it on artifacts that carry it. Kept readable for
141
+ * audit of pre-0.6 artifacts only.
99
142
  */
100
143
  owner_signature?: string | null;
101
144
  }
@@ -334,6 +377,15 @@ interface ProfileContextField {
334
377
  description?: string;
335
378
  displayName?: string;
336
379
  format?: 'email' | 'domain' | 'url' | 'currency';
380
+ /**
381
+ * v0.6 — what this field NAMES on the read path. `counterparty` = the other
382
+ * party to a communication (matched against an item's participants);
383
+ * `resource` = the container an item belongs to (a direct attribute match —
384
+ * and a resource scope enforced on writes MUST also bind reads). Absent →
385
+ * implementations MAY infer `counterparty` from `format: email|domain`
386
+ * (transitional; the explicit declaration is normative).
387
+ */
388
+ scopeKind?: 'counterparty' | 'resource';
337
389
  constraint?: FieldConstraint;
338
390
  enum?: string[];
339
391
  }
@@ -604,7 +656,7 @@ interface GatekeeperRequest {
604
656
  * Structured error from Gatekeeper verification.
605
657
  */
606
658
  interface GatekeeperError {
607
- code: 'BOUND_EXCEEDED' | 'CUMULATIVE_LIMIT_EXCEEDED' | 'INVALID_SIGNATURE' | 'TTL_EXPIRED' | 'FRAME_MISMATCH' | 'BOUNDS_MISMATCH' | 'CONTEXT_MISMATCH' | 'DOMAIN_NOT_COVERED' | 'INVALID_PROFILE' | 'MALFORMED_ATTESTATION';
659
+ code: 'BOUND_EXCEEDED' | 'CUMULATIVE_LIMIT_EXCEEDED' | 'INVALID_SIGNATURE' | 'TTL_EXPIRED' | 'FRAME_MISMATCH' | 'BOUNDS_MISMATCH' | 'CONTEXT_MISMATCH' | 'DOMAIN_NOT_COVERED' | 'INVALID_PROFILE' | 'MALFORMED_ATTESTATION' | 'INVALID_ACTION_TYPE' | 'ATTESTATION_REVOKED' | 'APPROVAL_REQUIRED' | 'IDEMPOTENCY_MISMATCH' | 'MANDATE_SIGNATURE_REQUIRED' | 'MANDATE_SIGNATURE_INVALID' | 'APPROVAL_SIGNATURE_REQUIRED' | 'APPROVAL_SIGNATURE_INVALID';
608
660
  field?: string;
609
661
  message: string;
610
662
  bound?: string | number;
@@ -824,10 +876,22 @@ interface SubjectValidation {
824
876
  * Enforce the Identity-Assurance invariants on a single subject:
825
877
  * - `self_declared` ⇒ `low` / `self`, no disclosed name.
826
878
  * - `as_vouched` ⇒ `high` / `as`, `verifier` required.
827
- * - `eudi` ⇒ `high` / `external`, `verifier` + `owner_signature` required.
879
+ * - `eudi` ⇒ `high` / `external`, `verifier` required and, when the
880
+ * carrying attestation's `owner_mandates` are supplied, a corresponding
881
+ * entry with `binding:"eudi"` for this subject's DID.
828
882
  * - `disclose.name` only at `assurance:"high"`.
829
- */
830
- declare function validateSubject(subject: Subject): SubjectValidation;
883
+ *
884
+ * v0.6: `Subject.owner_signature` is deprecated and IGNORED here — it signed
885
+ * the identity claim, not the mandate (see the field's deprecation note). The
886
+ * signature-bearing object is the attestation's `owner_mandates` entry, which
887
+ * is payload-level context this per-subject check cannot see on its own; pass
888
+ * `opts.ownerMandates` to enforce the eudi ⇒ mandate-entry rule, omit it to
889
+ * validate subject shape alone (pre-0.6 callers keep their behaviour minus
890
+ * the retired owner_signature requirement).
891
+ */
892
+ declare function validateSubject(subject: Subject, opts?: {
893
+ ownerMandates?: OwnerMandate[];
894
+ }): SubjectValidation;
831
895
  /**
832
896
  * The footer line for a subject — the ONE place this wording lives.
833
897
  * The name appears only at `high` with a disclosed name; otherwise no name.
@@ -1050,4 +1114,189 @@ declare function listProfiles(): string[];
1050
1114
  declare function getAllProfiles(): AgentProfile[];
1051
1115
  declare function clearProfiles(): void;
1052
1116
 
1053
- export { type AgentBoundsParams, type AgentContextParams, type AgentFrameParams, type AgentProfile, type Attestation, type AttestationHeader, type AttestationPayload, type BoundType, type ContentBinding, ContentBindingError, type ContentBindingErrorCode, type CumulativeFieldDef, type CumulativeWindow, type DeclaredFieldDef, type ExecutionContextFieldDef, type ExecutionLogEntry, type ExecutionLogQuery, type ExecutionMappingTransform, type ExecutionMappingValue, type ExecutionPath, type FieldConstraint, type FieldUnit, type GateQuestion, type GatekeeperError, type GatekeeperRequest, type GatekeeperResult, type ProfileBoundsField, type ProfileContextField, type ProfileFrameField, type ProfileToolGating, type ProfileToolGatingEntry, type ResolvedDomain, type Subject, type SubjectValidation, attestationId, bindingAppliesTo, canonicalBounds, canonicalContext, canonicalFrame, canonicalize, canonicalizeText, checkAttestationExpiry, clearProfiles, computeBoundsHash, computeContentHash, computeContextHash, computeFieldsContentHash, computeFrameHash, computeIntentDisclosureHash, computeIntentHash, contentCanonicalBytes, decodeAttestationBlob, deriveIdentityLine, encodeAttestationBlob, frameHash, getAllProfiles, getProfile, intentDisclosureCanonicalBytes, isFieldBinding, isV4Attestation, listProfiles, registerProfile, selectBoundFields, validateBoundsParams, validateContextParams, validateFrameParams, validateSubject, verify, verifyAttestation, verifyAttestationSignature, verifyAttestationV4, verifyBoundsHash, verifyContextHash, verifyFrameHash };
1117
+ /**
1118
+ * did:key — encode/decode for KEY-BEARING DIDs (HAP v0.6).
1119
+ *
1120
+ * A real `did:key` is self-certifying: the public key IS the identifier, so
1121
+ * substituting the key produces a DIFFERENT DID and no key directory is ever
1122
+ * consulted. That property is what the Owner Mandate design stands on
1123
+ * (protocol.md → "Identity DIDs vs signing DIDs"): a signing DID MUST be
1124
+ * key-bearing, and verification uses the key carried in the identifier —
1125
+ * deliberately, there is no `public_key` field anywhere on the wire.
1126
+ *
1127
+ * Format (W3C did:key method, Ed25519):
1128
+ * did:key:z<base58btc( 0xed 0x01 ‖ 32-byte-public-key )>
1129
+ * `z` is the multibase prefix for base58btc; `0xed 0x01` is the multicodec
1130
+ * varint for ed25519-pub. The result always starts `did:key:z6Mk`.
1131
+ *
1132
+ * Scope: Ed25519 only — the one signing curve this protocol version uses.
1133
+ * Anything else (including the reference implementation's legacy decorative
1134
+ * `did:key:<uuid-fragment>` identifiers) decodes as NOT key-bearing.
1135
+ */
1136
+ /** Encode a 32-byte Ed25519 public key as a key-bearing `did:key:z6Mk…`. */
1137
+ declare function encodeDidKey(publicKey: Uint8Array): string;
1138
+ /**
1139
+ * Decode a key-bearing `did:key` to its Ed25519 public key bytes.
1140
+ *
1141
+ * @throws Error prefixed `NOT_KEY_BEARING:` for anything that is not a valid
1142
+ * base58btc-multibase Ed25519 did:key — including the legacy decorative
1143
+ * `did:key:<uuid-fragment>` identifiers, other multibase prefixes, and other
1144
+ * key types. The error name is the point: under the mandate design, a
1145
+ * non-key-bearing signing DID must fail STRUCTURALLY, never fall back.
1146
+ */
1147
+ declare function decodeDidKey(did: string): Uint8Array;
1148
+ /** True iff the DID decodes as a key-bearing Ed25519 did:key. Never throws. */
1149
+ declare function isKeyBearingDid(did: string): boolean;
1150
+
1151
+ /**
1152
+ * Owner Mandate Signatures (HAP v0.6) — the `HAP-mandate` projection, the
1153
+ * `HAP-approval` object, and their verification.
1154
+ *
1155
+ * The human signs BEFORE the AS does, so they cannot sign the finished
1156
+ * attestation (`attestation_id`/`issued_at` do not exist yet). They sign a
1157
+ * mandate PROJECTION: a canonical object every field of which is known at
1158
+ * approval time and reconstructible from the finished attestation — so a
1159
+ * verifier rebuilds it from the attestation it already holds and checks the
1160
+ * signature with the key carried in the owner's DID. No side channel, no
1161
+ * second fetch, no key directory. See protocol.md → "Owner Mandate Signatures".
1162
+ *
1163
+ * Verification here requires NO trust in the AS. What it cannot do is tell the
1164
+ * verifier WHOSE key signed — confirming the DID belongs to the expected
1165
+ * person is the out-of-band step (protocol.md → "Identity DIDs vs signing
1166
+ * DIDs"), and it is the honest cost of cold verification.
1167
+ */
1168
+
1169
+ /** The object the owner signs — a canonical projection of the mandate. */
1170
+ interface MandateProjection {
1171
+ typ: 'HAP-mandate';
1172
+ /** Projection/canonicalization version. A verifier MUST pin it. */
1173
+ version: '0.6';
1174
+ profile_id: string;
1175
+ /** The signing owner's own DID. MUST be a member of `resolved_owners`. */
1176
+ owner_did: string;
1177
+ bounds_hash: string;
1178
+ context_hash: string;
1179
+ execution_context_hash: string;
1180
+ gate_content_hashes: Record<string, string>;
1181
+ /** Included iff the attestation carries one — binds ciphertext AND the
1182
+ * frozen approver set, the swap this mechanism exists to stop. */
1183
+ intent_disclosure_hash?: string;
1184
+ commitment_mode: string;
1185
+ /** The replay defence: the human signs how long the authority lives. */
1186
+ expires_at: number;
1187
+ nonce: string;
1188
+ }
1189
+ /** Per-action approval, signed by the owner in `review` mode. Signing a
1190
+ * `reject` matters as much as a `commit`: a rejection the AS can discard is a
1191
+ * rejection that never happened. */
1192
+ interface ApprovalObject {
1193
+ typ: 'HAP-approval';
1194
+ version: '0.6';
1195
+ proposal_id: string;
1196
+ attestation_id: string;
1197
+ decision: 'commit' | 'reject';
1198
+ /** What was approved: the receipt's contentHash where the profile binds
1199
+ * content; otherwise sha256 over the JCS of the proposal's argument set. */
1200
+ content_hash: string;
1201
+ decided_at: number;
1202
+ nonce: string;
1203
+ }
1204
+ declare class MandateError extends Error {
1205
+ code: 'MANDATE_SIGNATURE_INVALID' | 'APPROVAL_SIGNATURE_INVALID' | 'NOT_KEY_BEARING' | 'OWNER_NOT_RESOLVED' | 'MALFORMED_ATTESTATION';
1206
+ constructor(code: 'MANDATE_SIGNATURE_INVALID' | 'APPROVAL_SIGNATURE_INVALID' | 'NOT_KEY_BEARING' | 'OWNER_NOT_RESOLVED' | 'MALFORMED_ATTESTATION', message: string);
1207
+ }
1208
+ /**
1209
+ * Rebuild the projection a given `owner_mandates` entry signed, from the
1210
+ * attestation's own signed fields. Field absence is defined, not incidental:
1211
+ * `intent_disclosure_hash` is included iff the attestation carries one.
1212
+ */
1213
+ declare function buildMandateProjection(payload: AttestationPayload, entry: Pick<OwnerMandate, 'did' | 'nonce'>): MandateProjection;
1214
+ /** The exact bytes an owner signs: RFC 8785 (JCS) canonical UTF-8. */
1215
+ declare function mandateSigningBytes(projection: MandateProjection): Uint8Array;
1216
+ /** The exact bytes an owner signs for a per-action approval. */
1217
+ declare function approvalSigningBytes(approval: ApprovalObject): Uint8Array;
1218
+ /**
1219
+ * Sign a mandate projection with a raw Ed25519 private key — the `raw`
1220
+ * binding: tests and CI only, no custody claim. WebAuthn (`webauthn`) and
1221
+ * wallet (`eudi`) bindings sign the same bytes through their own custody;
1222
+ * they are implemented by the platforms that hold those keys, not here.
1223
+ */
1224
+ declare function signMandateProjection(projection: MandateProjection, privateKey: Uint8Array): Promise<string>;
1225
+ /** Sign an approval object with a raw Ed25519 private key (`raw` binding). */
1226
+ declare function signApproval(approval: ApprovalObject, privateKey: Uint8Array): Promise<string>;
1227
+ /**
1228
+ * Verify ONE `owner_mandates` entry against the attestation that carries it.
1229
+ *
1230
+ * Steps (protocol.md → "Verification procedure", steps 4 of 6): membership in
1231
+ * `resolved_owners`, key-bearing DID, projection reconstruction, Ed25519 over
1232
+ * JCS bytes. The DID is authoritative over `alg` — a disagreement is
1233
+ * MANDATE_SIGNATURE_INVALID, never a fallback to the claimed algorithm.
1234
+ *
1235
+ * What this deliberately does NOT verify: that the DID belongs to the person
1236
+ * the verifier expects (out-of-band, step 5) and the AS's own signature over
1237
+ * the attestation (verifyAttestationSignature, step 1).
1238
+ */
1239
+ declare function verifyOwnerMandate(attestation: Attestation, entry: OwnerMandate): Promise<void>;
1240
+ /** Verify every `owner_mandates` entry an attestation carries. Resolves to the
1241
+ * verified entries; an attestation with none resolves to `[]` (the v0.5
1242
+ * posture — nothing to check, and nothing claimed). */
1243
+ declare function verifyOwnerMandates(attestation: Attestation): Promise<OwnerMandate[]>;
1244
+ /** Verify an approval signature against a signer's key-bearing DID. */
1245
+ declare function verifyApproval(approval: ApprovalObject, signature: string, signerDid: string): Promise<void>;
1246
+
1247
+ /**
1248
+ * Execution receipts (HAP v0.5/v0.6) — the wire type and holder-side
1249
+ * verification. Until v0.6 this library had no receipt surface at all; every
1250
+ * verifier hand-assembled the strip→canonicalize→verify dance. This module is
1251
+ * that dance, once.
1252
+ *
1253
+ * Receipt payloads are camelCase on the wire (unlike the snake_case
1254
+ * attestation payload) — a shipped inconsistency v0.6 chose to document
1255
+ * rather than break (changelog.md → "Renames and terminology").
1256
+ */
1257
+
1258
+ /** Signed execution receipt — protocol.md → "Receipt Payload Schema". */
1259
+ interface ReceiptPayload {
1260
+ id: string;
1261
+ groupId?: string | null;
1262
+ userId?: string;
1263
+ boundsHash: string;
1264
+ profileId: string;
1265
+ /** Downstream tool name. Audit metadata only — never a dispatch key. */
1266
+ action: string;
1267
+ /** Semantic category — drives cumulative bucketing and bounds dispatch. */
1268
+ actionType: string;
1269
+ executionContext: Record<string, unknown>;
1270
+ cumulativeState?: Record<string, unknown>;
1271
+ limits?: Record<string, unknown>;
1272
+ timestamp: number;
1273
+ /** v0.6 — hash of the bound content, computed by the Gatekeeper, copied
1274
+ * verbatim by the AS. The AS never sees the content. */
1275
+ contentHash?: string;
1276
+ /** v0.6 — the binding declaration echoed into the signed receipt, so a
1277
+ * verifier knows exactly what `contentHash` covers. */
1278
+ contentBinding?: Pick<ContentBinding, 'version' | 'kind' | 'fields' | 'required_fields' | 'appliesTo'>;
1279
+ /** v0.6 — disclosed subset of the attestation's identity overlay. */
1280
+ subjects?: Subject[];
1281
+ /** v0.6 — review path: the proposal this receipt executed. */
1282
+ proposalId?: string;
1283
+ /** v0.6 — review path: the owner's HAP-approval signature (or its sha256)
1284
+ * for the executed proposal. */
1285
+ approvalSignature?: string;
1286
+ /** Ed25519 over the JCS-canonical payload (this field excluded), base64url. */
1287
+ signature: string;
1288
+ }
1289
+ /**
1290
+ * Verify a receipt's AS signature: strip `signature`, JCS-canonicalize the
1291
+ * rest, Ed25519-verify against the AS public key (hex). This is holder-side
1292
+ * verification — it needs the COMPLETE receipt; a redacted public view cannot
1293
+ * be re-verified this way (protocol.md → "Receipt Verification").
1294
+ *
1295
+ * Content is checked separately: where `contentHash` is present, recompute it
1296
+ * from the held artifact via the content-binding module and compare.
1297
+ *
1298
+ * @throws Error prefixed `INVALID_SIGNATURE:` when verification fails.
1299
+ */
1300
+ declare function verifyReceiptSignature(receipt: ReceiptPayload, publicKeyHex: string): Promise<void>;
1301
+
1302
+ export { type AgentBoundsParams, type AgentContextParams, type AgentFrameParams, type AgentProfile, type ApprovalObject, type Attestation, type AttestationHeader, type AttestationPayload, type BoundType, type ContentBinding, ContentBindingError, type ContentBindingErrorCode, type CumulativeFieldDef, type CumulativeWindow, type DeclaredFieldDef, type ExecutionContextFieldDef, type ExecutionLogEntry, type ExecutionLogQuery, type ExecutionMappingTransform, type ExecutionMappingValue, type ExecutionPath, type FieldConstraint, type FieldUnit, type GateQuestion, type GatekeeperError, type GatekeeperRequest, type GatekeeperResult, type MandateBinding, MandateError, type MandateProjection, type OwnerMandate, type ProfileBoundsField, type ProfileContextField, type ProfileFrameField, type ProfileToolGating, type ProfileToolGatingEntry, type ReceiptPayload, type ResolvedDomain, type SigningSurface, type Subject, type SubjectValidation, approvalSigningBytes, attestationId, bindingAppliesTo, buildMandateProjection, canonicalBounds, canonicalContext, canonicalFrame, canonicalize, canonicalizeText, checkAttestationExpiry, clearProfiles, computeBoundsHash, computeContentHash, computeContextHash, computeFieldsContentHash, computeFrameHash, computeIntentDisclosureHash, computeIntentHash, contentCanonicalBytes, decodeAttestationBlob, decodeDidKey, deriveIdentityLine, encodeAttestationBlob, encodeDidKey, frameHash, getAllProfiles, getProfile, intentDisclosureCanonicalBytes, isFieldBinding, isKeyBearingDid, isV4Attestation, listProfiles, mandateSigningBytes, registerProfile, selectBoundFields, signApproval, signMandateProjection, validateBoundsParams, validateContextParams, validateFrameParams, validateSubject, verify, verifyApproval, verifyAttestation, verifyAttestationSignature, verifyAttestationV4, verifyBoundsHash, verifyContextHash, verifyFrameHash, verifyOwnerMandate, verifyOwnerMandates, verifyReceiptSignature };
@@ -14,7 +14,7 @@ interface ResolvedDomain {
14
14
  }
15
15
  interface AttestationPayload {
16
16
  attestation_id: string;
17
- version: '0.3' | '0.4' | '0.5';
17
+ version: '0.3' | '0.4' | '0.5' | '0.6';
18
18
  profile_id: string;
19
19
  /** v0.3 (deprecated) — hash of the authorization frame */
20
20
  frame_hash?: string;
@@ -62,11 +62,51 @@ interface AttestationPayload {
62
62
  *
63
63
  * Cryptographically bound in the signed payload so a compromised SP cannot
64
64
  * silently flip 'review' → 'automatic'. Absent on v0.3 attestations.
65
+ * `review_above_cap` (v0.5): automatic below the signed caps, proposal above.
65
66
  */
66
- commitment_mode?: 'automatic' | 'review';
67
+ commitment_mode?: 'automatic' | 'review' | 'review_above_cap';
68
+ /**
69
+ * v0.6 (Owner Mandate Signatures) — the Decision Owner's own signature(s)
70
+ * over the mandate projection ({@link MandateProjection}), one entry per
71
+ * co-signing owner. Carried INSIDE the AS-signed payload, so the AS attests
72
+ * to having received it and cannot strip it without invalidating its own
73
+ * signature. Optional and additive: an attestation without it behaves as
74
+ * before (the v0.5 posture — the AS asserts, nobody co-signs).
75
+ */
76
+ owner_mandates?: OwnerMandate[];
67
77
  issued_at: number;
68
78
  expires_at: number;
69
79
  }
80
+ /** Mandate-assurance axis — what custody signed the mandate. Independent of
81
+ * identity assurance ({@link Subject.method}). */
82
+ type MandateBinding = 'raw' | 'webauthn' | 'eudi';
83
+ /** Which surface showed the owner what they signed. A DECLARATION, not a proof
84
+ * — no verifier can check it; see protocol.md → Owner Mandate Signatures. */
85
+ type SigningSurface = 'gatekeeper_local' | 'as_web' | 'wallet_display';
86
+ /**
87
+ * v0.6 — one owner's signature over the mandate projection.
88
+ *
89
+ * There is deliberately NO `public_key` field, and it MUST NOT be added: the
90
+ * verification key is carried in the DID itself (key-bearing `did:key`), so a
91
+ * non-key-bearing DID fails STRUCTURALLY instead of validating against a key
92
+ * the AS could have substituted. `alg` is kept only as curve-confusion
93
+ * hygiene; if it disagrees with the DID's key type, the DID is authoritative.
94
+ */
95
+ interface OwnerMandate {
96
+ /** The signing owner's key-bearing DID. MUST be a member of `resolved_owners`. */
97
+ did: string;
98
+ /** Signature algorithm hint. The DID's multicodec wins on any disagreement. */
99
+ alg: 'EdDSA' | 'ES256';
100
+ /** base64url (no padding) signature over the JCS bytes of the mandate projection. */
101
+ signature: string;
102
+ /** When the owner signed (unix seconds). */
103
+ signed_at: number;
104
+ /** Defence-in-depth against duplicate issuance by an HONEST AS only —
105
+ * AS-side nonce enforcement is no defence against the AS itself. */
106
+ nonce: string;
107
+ binding: MandateBinding;
108
+ signing_surface?: SigningSurface;
109
+ }
70
110
  /**
71
111
  * v0.6 Identity Assurance — a signed overlay binding a Decision Owner's verified
72
112
  * real-world identity to the attestation, gated by HOW the identity was verified.
@@ -94,8 +134,11 @@ interface Subject {
94
134
  /** When the underlying verification was performed (unix seconds). */
95
135
  verified_at?: number;
96
136
  /**
97
- * eudi only (Phase 2) the owner's per-event wallet signature, making the
98
- * identity claim non-repudiable independent of the AS. Null/absent otherwise.
137
+ * @deprecated v0.6replaced by {@link AttestationPayload.owner_mandates}.
138
+ * This field signed the wrong object (the identity claim, not what was
139
+ * committed to) and was welded to one method. Implementations MUST NOT emit
140
+ * it; verifiers MAY ignore it on artifacts that carry it. Kept readable for
141
+ * audit of pre-0.6 artifacts only.
99
142
  */
100
143
  owner_signature?: string | null;
101
144
  }
@@ -334,6 +377,15 @@ interface ProfileContextField {
334
377
  description?: string;
335
378
  displayName?: string;
336
379
  format?: 'email' | 'domain' | 'url' | 'currency';
380
+ /**
381
+ * v0.6 — what this field NAMES on the read path. `counterparty` = the other
382
+ * party to a communication (matched against an item's participants);
383
+ * `resource` = the container an item belongs to (a direct attribute match —
384
+ * and a resource scope enforced on writes MUST also bind reads). Absent →
385
+ * implementations MAY infer `counterparty` from `format: email|domain`
386
+ * (transitional; the explicit declaration is normative).
387
+ */
388
+ scopeKind?: 'counterparty' | 'resource';
337
389
  constraint?: FieldConstraint;
338
390
  enum?: string[];
339
391
  }
@@ -604,7 +656,7 @@ interface GatekeeperRequest {
604
656
  * Structured error from Gatekeeper verification.
605
657
  */
606
658
  interface GatekeeperError {
607
- code: 'BOUND_EXCEEDED' | 'CUMULATIVE_LIMIT_EXCEEDED' | 'INVALID_SIGNATURE' | 'TTL_EXPIRED' | 'FRAME_MISMATCH' | 'BOUNDS_MISMATCH' | 'CONTEXT_MISMATCH' | 'DOMAIN_NOT_COVERED' | 'INVALID_PROFILE' | 'MALFORMED_ATTESTATION';
659
+ code: 'BOUND_EXCEEDED' | 'CUMULATIVE_LIMIT_EXCEEDED' | 'INVALID_SIGNATURE' | 'TTL_EXPIRED' | 'FRAME_MISMATCH' | 'BOUNDS_MISMATCH' | 'CONTEXT_MISMATCH' | 'DOMAIN_NOT_COVERED' | 'INVALID_PROFILE' | 'MALFORMED_ATTESTATION' | 'INVALID_ACTION_TYPE' | 'ATTESTATION_REVOKED' | 'APPROVAL_REQUIRED' | 'IDEMPOTENCY_MISMATCH' | 'MANDATE_SIGNATURE_REQUIRED' | 'MANDATE_SIGNATURE_INVALID' | 'APPROVAL_SIGNATURE_REQUIRED' | 'APPROVAL_SIGNATURE_INVALID';
608
660
  field?: string;
609
661
  message: string;
610
662
  bound?: string | number;
@@ -824,10 +876,22 @@ interface SubjectValidation {
824
876
  * Enforce the Identity-Assurance invariants on a single subject:
825
877
  * - `self_declared` ⇒ `low` / `self`, no disclosed name.
826
878
  * - `as_vouched` ⇒ `high` / `as`, `verifier` required.
827
- * - `eudi` ⇒ `high` / `external`, `verifier` + `owner_signature` required.
879
+ * - `eudi` ⇒ `high` / `external`, `verifier` required and, when the
880
+ * carrying attestation's `owner_mandates` are supplied, a corresponding
881
+ * entry with `binding:"eudi"` for this subject's DID.
828
882
  * - `disclose.name` only at `assurance:"high"`.
829
- */
830
- declare function validateSubject(subject: Subject): SubjectValidation;
883
+ *
884
+ * v0.6: `Subject.owner_signature` is deprecated and IGNORED here — it signed
885
+ * the identity claim, not the mandate (see the field's deprecation note). The
886
+ * signature-bearing object is the attestation's `owner_mandates` entry, which
887
+ * is payload-level context this per-subject check cannot see on its own; pass
888
+ * `opts.ownerMandates` to enforce the eudi ⇒ mandate-entry rule, omit it to
889
+ * validate subject shape alone (pre-0.6 callers keep their behaviour minus
890
+ * the retired owner_signature requirement).
891
+ */
892
+ declare function validateSubject(subject: Subject, opts?: {
893
+ ownerMandates?: OwnerMandate[];
894
+ }): SubjectValidation;
831
895
  /**
832
896
  * The footer line for a subject — the ONE place this wording lives.
833
897
  * The name appears only at `high` with a disclosed name; otherwise no name.
@@ -1050,4 +1114,189 @@ declare function listProfiles(): string[];
1050
1114
  declare function getAllProfiles(): AgentProfile[];
1051
1115
  declare function clearProfiles(): void;
1052
1116
 
1053
- export { type AgentBoundsParams, type AgentContextParams, type AgentFrameParams, type AgentProfile, type Attestation, type AttestationHeader, type AttestationPayload, type BoundType, type ContentBinding, ContentBindingError, type ContentBindingErrorCode, type CumulativeFieldDef, type CumulativeWindow, type DeclaredFieldDef, type ExecutionContextFieldDef, type ExecutionLogEntry, type ExecutionLogQuery, type ExecutionMappingTransform, type ExecutionMappingValue, type ExecutionPath, type FieldConstraint, type FieldUnit, type GateQuestion, type GatekeeperError, type GatekeeperRequest, type GatekeeperResult, type ProfileBoundsField, type ProfileContextField, type ProfileFrameField, type ProfileToolGating, type ProfileToolGatingEntry, type ResolvedDomain, type Subject, type SubjectValidation, attestationId, bindingAppliesTo, canonicalBounds, canonicalContext, canonicalFrame, canonicalize, canonicalizeText, checkAttestationExpiry, clearProfiles, computeBoundsHash, computeContentHash, computeContextHash, computeFieldsContentHash, computeFrameHash, computeIntentDisclosureHash, computeIntentHash, contentCanonicalBytes, decodeAttestationBlob, deriveIdentityLine, encodeAttestationBlob, frameHash, getAllProfiles, getProfile, intentDisclosureCanonicalBytes, isFieldBinding, isV4Attestation, listProfiles, registerProfile, selectBoundFields, validateBoundsParams, validateContextParams, validateFrameParams, validateSubject, verify, verifyAttestation, verifyAttestationSignature, verifyAttestationV4, verifyBoundsHash, verifyContextHash, verifyFrameHash };
1117
+ /**
1118
+ * did:key — encode/decode for KEY-BEARING DIDs (HAP v0.6).
1119
+ *
1120
+ * A real `did:key` is self-certifying: the public key IS the identifier, so
1121
+ * substituting the key produces a DIFFERENT DID and no key directory is ever
1122
+ * consulted. That property is what the Owner Mandate design stands on
1123
+ * (protocol.md → "Identity DIDs vs signing DIDs"): a signing DID MUST be
1124
+ * key-bearing, and verification uses the key carried in the identifier —
1125
+ * deliberately, there is no `public_key` field anywhere on the wire.
1126
+ *
1127
+ * Format (W3C did:key method, Ed25519):
1128
+ * did:key:z<base58btc( 0xed 0x01 ‖ 32-byte-public-key )>
1129
+ * `z` is the multibase prefix for base58btc; `0xed 0x01` is the multicodec
1130
+ * varint for ed25519-pub. The result always starts `did:key:z6Mk`.
1131
+ *
1132
+ * Scope: Ed25519 only — the one signing curve this protocol version uses.
1133
+ * Anything else (including the reference implementation's legacy decorative
1134
+ * `did:key:<uuid-fragment>` identifiers) decodes as NOT key-bearing.
1135
+ */
1136
+ /** Encode a 32-byte Ed25519 public key as a key-bearing `did:key:z6Mk…`. */
1137
+ declare function encodeDidKey(publicKey: Uint8Array): string;
1138
+ /**
1139
+ * Decode a key-bearing `did:key` to its Ed25519 public key bytes.
1140
+ *
1141
+ * @throws Error prefixed `NOT_KEY_BEARING:` for anything that is not a valid
1142
+ * base58btc-multibase Ed25519 did:key — including the legacy decorative
1143
+ * `did:key:<uuid-fragment>` identifiers, other multibase prefixes, and other
1144
+ * key types. The error name is the point: under the mandate design, a
1145
+ * non-key-bearing signing DID must fail STRUCTURALLY, never fall back.
1146
+ */
1147
+ declare function decodeDidKey(did: string): Uint8Array;
1148
+ /** True iff the DID decodes as a key-bearing Ed25519 did:key. Never throws. */
1149
+ declare function isKeyBearingDid(did: string): boolean;
1150
+
1151
+ /**
1152
+ * Owner Mandate Signatures (HAP v0.6) — the `HAP-mandate` projection, the
1153
+ * `HAP-approval` object, and their verification.
1154
+ *
1155
+ * The human signs BEFORE the AS does, so they cannot sign the finished
1156
+ * attestation (`attestation_id`/`issued_at` do not exist yet). They sign a
1157
+ * mandate PROJECTION: a canonical object every field of which is known at
1158
+ * approval time and reconstructible from the finished attestation — so a
1159
+ * verifier rebuilds it from the attestation it already holds and checks the
1160
+ * signature with the key carried in the owner's DID. No side channel, no
1161
+ * second fetch, no key directory. See protocol.md → "Owner Mandate Signatures".
1162
+ *
1163
+ * Verification here requires NO trust in the AS. What it cannot do is tell the
1164
+ * verifier WHOSE key signed — confirming the DID belongs to the expected
1165
+ * person is the out-of-band step (protocol.md → "Identity DIDs vs signing
1166
+ * DIDs"), and it is the honest cost of cold verification.
1167
+ */
1168
+
1169
+ /** The object the owner signs — a canonical projection of the mandate. */
1170
+ interface MandateProjection {
1171
+ typ: 'HAP-mandate';
1172
+ /** Projection/canonicalization version. A verifier MUST pin it. */
1173
+ version: '0.6';
1174
+ profile_id: string;
1175
+ /** The signing owner's own DID. MUST be a member of `resolved_owners`. */
1176
+ owner_did: string;
1177
+ bounds_hash: string;
1178
+ context_hash: string;
1179
+ execution_context_hash: string;
1180
+ gate_content_hashes: Record<string, string>;
1181
+ /** Included iff the attestation carries one — binds ciphertext AND the
1182
+ * frozen approver set, the swap this mechanism exists to stop. */
1183
+ intent_disclosure_hash?: string;
1184
+ commitment_mode: string;
1185
+ /** The replay defence: the human signs how long the authority lives. */
1186
+ expires_at: number;
1187
+ nonce: string;
1188
+ }
1189
+ /** Per-action approval, signed by the owner in `review` mode. Signing a
1190
+ * `reject` matters as much as a `commit`: a rejection the AS can discard is a
1191
+ * rejection that never happened. */
1192
+ interface ApprovalObject {
1193
+ typ: 'HAP-approval';
1194
+ version: '0.6';
1195
+ proposal_id: string;
1196
+ attestation_id: string;
1197
+ decision: 'commit' | 'reject';
1198
+ /** What was approved: the receipt's contentHash where the profile binds
1199
+ * content; otherwise sha256 over the JCS of the proposal's argument set. */
1200
+ content_hash: string;
1201
+ decided_at: number;
1202
+ nonce: string;
1203
+ }
1204
+ declare class MandateError extends Error {
1205
+ code: 'MANDATE_SIGNATURE_INVALID' | 'APPROVAL_SIGNATURE_INVALID' | 'NOT_KEY_BEARING' | 'OWNER_NOT_RESOLVED' | 'MALFORMED_ATTESTATION';
1206
+ constructor(code: 'MANDATE_SIGNATURE_INVALID' | 'APPROVAL_SIGNATURE_INVALID' | 'NOT_KEY_BEARING' | 'OWNER_NOT_RESOLVED' | 'MALFORMED_ATTESTATION', message: string);
1207
+ }
1208
+ /**
1209
+ * Rebuild the projection a given `owner_mandates` entry signed, from the
1210
+ * attestation's own signed fields. Field absence is defined, not incidental:
1211
+ * `intent_disclosure_hash` is included iff the attestation carries one.
1212
+ */
1213
+ declare function buildMandateProjection(payload: AttestationPayload, entry: Pick<OwnerMandate, 'did' | 'nonce'>): MandateProjection;
1214
+ /** The exact bytes an owner signs: RFC 8785 (JCS) canonical UTF-8. */
1215
+ declare function mandateSigningBytes(projection: MandateProjection): Uint8Array;
1216
+ /** The exact bytes an owner signs for a per-action approval. */
1217
+ declare function approvalSigningBytes(approval: ApprovalObject): Uint8Array;
1218
+ /**
1219
+ * Sign a mandate projection with a raw Ed25519 private key — the `raw`
1220
+ * binding: tests and CI only, no custody claim. WebAuthn (`webauthn`) and
1221
+ * wallet (`eudi`) bindings sign the same bytes through their own custody;
1222
+ * they are implemented by the platforms that hold those keys, not here.
1223
+ */
1224
+ declare function signMandateProjection(projection: MandateProjection, privateKey: Uint8Array): Promise<string>;
1225
+ /** Sign an approval object with a raw Ed25519 private key (`raw` binding). */
1226
+ declare function signApproval(approval: ApprovalObject, privateKey: Uint8Array): Promise<string>;
1227
+ /**
1228
+ * Verify ONE `owner_mandates` entry against the attestation that carries it.
1229
+ *
1230
+ * Steps (protocol.md → "Verification procedure", steps 4 of 6): membership in
1231
+ * `resolved_owners`, key-bearing DID, projection reconstruction, Ed25519 over
1232
+ * JCS bytes. The DID is authoritative over `alg` — a disagreement is
1233
+ * MANDATE_SIGNATURE_INVALID, never a fallback to the claimed algorithm.
1234
+ *
1235
+ * What this deliberately does NOT verify: that the DID belongs to the person
1236
+ * the verifier expects (out-of-band, step 5) and the AS's own signature over
1237
+ * the attestation (verifyAttestationSignature, step 1).
1238
+ */
1239
+ declare function verifyOwnerMandate(attestation: Attestation, entry: OwnerMandate): Promise<void>;
1240
+ /** Verify every `owner_mandates` entry an attestation carries. Resolves to the
1241
+ * verified entries; an attestation with none resolves to `[]` (the v0.5
1242
+ * posture — nothing to check, and nothing claimed). */
1243
+ declare function verifyOwnerMandates(attestation: Attestation): Promise<OwnerMandate[]>;
1244
+ /** Verify an approval signature against a signer's key-bearing DID. */
1245
+ declare function verifyApproval(approval: ApprovalObject, signature: string, signerDid: string): Promise<void>;
1246
+
1247
+ /**
1248
+ * Execution receipts (HAP v0.5/v0.6) — the wire type and holder-side
1249
+ * verification. Until v0.6 this library had no receipt surface at all; every
1250
+ * verifier hand-assembled the strip→canonicalize→verify dance. This module is
1251
+ * that dance, once.
1252
+ *
1253
+ * Receipt payloads are camelCase on the wire (unlike the snake_case
1254
+ * attestation payload) — a shipped inconsistency v0.6 chose to document
1255
+ * rather than break (changelog.md → "Renames and terminology").
1256
+ */
1257
+
1258
+ /** Signed execution receipt — protocol.md → "Receipt Payload Schema". */
1259
+ interface ReceiptPayload {
1260
+ id: string;
1261
+ groupId?: string | null;
1262
+ userId?: string;
1263
+ boundsHash: string;
1264
+ profileId: string;
1265
+ /** Downstream tool name. Audit metadata only — never a dispatch key. */
1266
+ action: string;
1267
+ /** Semantic category — drives cumulative bucketing and bounds dispatch. */
1268
+ actionType: string;
1269
+ executionContext: Record<string, unknown>;
1270
+ cumulativeState?: Record<string, unknown>;
1271
+ limits?: Record<string, unknown>;
1272
+ timestamp: number;
1273
+ /** v0.6 — hash of the bound content, computed by the Gatekeeper, copied
1274
+ * verbatim by the AS. The AS never sees the content. */
1275
+ contentHash?: string;
1276
+ /** v0.6 — the binding declaration echoed into the signed receipt, so a
1277
+ * verifier knows exactly what `contentHash` covers. */
1278
+ contentBinding?: Pick<ContentBinding, 'version' | 'kind' | 'fields' | 'required_fields' | 'appliesTo'>;
1279
+ /** v0.6 — disclosed subset of the attestation's identity overlay. */
1280
+ subjects?: Subject[];
1281
+ /** v0.6 — review path: the proposal this receipt executed. */
1282
+ proposalId?: string;
1283
+ /** v0.6 — review path: the owner's HAP-approval signature (or its sha256)
1284
+ * for the executed proposal. */
1285
+ approvalSignature?: string;
1286
+ /** Ed25519 over the JCS-canonical payload (this field excluded), base64url. */
1287
+ signature: string;
1288
+ }
1289
+ /**
1290
+ * Verify a receipt's AS signature: strip `signature`, JCS-canonicalize the
1291
+ * rest, Ed25519-verify against the AS public key (hex). This is holder-side
1292
+ * verification — it needs the COMPLETE receipt; a redacted public view cannot
1293
+ * be re-verified this way (protocol.md → "Receipt Verification").
1294
+ *
1295
+ * Content is checked separately: where `contentHash` is present, recompute it
1296
+ * from the held artifact via the content-binding module and compare.
1297
+ *
1298
+ * @throws Error prefixed `INVALID_SIGNATURE:` when verification fails.
1299
+ */
1300
+ declare function verifyReceiptSignature(receipt: ReceiptPayload, publicKeyHex: string): Promise<void>;
1301
+
1302
+ export { type AgentBoundsParams, type AgentContextParams, type AgentFrameParams, type AgentProfile, type ApprovalObject, type Attestation, type AttestationHeader, type AttestationPayload, type BoundType, type ContentBinding, ContentBindingError, type ContentBindingErrorCode, type CumulativeFieldDef, type CumulativeWindow, type DeclaredFieldDef, type ExecutionContextFieldDef, type ExecutionLogEntry, type ExecutionLogQuery, type ExecutionMappingTransform, type ExecutionMappingValue, type ExecutionPath, type FieldConstraint, type FieldUnit, type GateQuestion, type GatekeeperError, type GatekeeperRequest, type GatekeeperResult, type MandateBinding, MandateError, type MandateProjection, type OwnerMandate, type ProfileBoundsField, type ProfileContextField, type ProfileFrameField, type ProfileToolGating, type ProfileToolGatingEntry, type ReceiptPayload, type ResolvedDomain, type SigningSurface, type Subject, type SubjectValidation, approvalSigningBytes, attestationId, bindingAppliesTo, buildMandateProjection, canonicalBounds, canonicalContext, canonicalFrame, canonicalize, canonicalizeText, checkAttestationExpiry, clearProfiles, computeBoundsHash, computeContentHash, computeContextHash, computeFieldsContentHash, computeFrameHash, computeIntentDisclosureHash, computeIntentHash, contentCanonicalBytes, decodeAttestationBlob, decodeDidKey, deriveIdentityLine, encodeAttestationBlob, encodeDidKey, frameHash, getAllProfiles, getProfile, intentDisclosureCanonicalBytes, isFieldBinding, isKeyBearingDid, isV4Attestation, listProfiles, mandateSigningBytes, registerProfile, selectBoundFields, signApproval, signMandateProjection, validateBoundsParams, validateContextParams, validateFrameParams, validateSubject, verify, verifyApproval, verifyAttestation, verifyAttestationSignature, verifyAttestationV4, verifyBoundsHash, verifyContextHash, verifyFrameHash, verifyOwnerMandate, verifyOwnerMandates, verifyReceiptSignature };