@suveren/gateway 0.7.3 → 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.
- package/content/integrations/gmail.json +3 -6
- package/dist/control-plane/index.mjs +294 -62
- package/dist/mcp-server/http.mjs +467 -73
- package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
- package/dist/ui/assets/index-CsrM6RQr.js +110 -0
- package/dist/ui/index.html +2 -2
- package/node_modules/@hap/core/dist/index.d.mts +258 -9
- package/node_modules/@hap/core/dist/index.d.ts +258 -9
- package/node_modules/@hap/core/dist/index.js +227 -5
- package/node_modules/@hap/core/dist/index.mjs +213 -4
- package/node_modules/@hap/core/package.json +3 -2
- package/node_modules/@hap/core/src/did-key.ts +126 -0
- package/node_modules/@hap/core/src/identity.ts +21 -5
- package/node_modules/@hap/core/src/index.ts +3 -0
- package/node_modules/@hap/core/src/mandate.ts +207 -0
- package/node_modules/@hap/core/src/receipt.ts +74 -0
- package/node_modules/@hap/core/src/types.ts +81 -5
- package/node_modules/@hono/node-server/dist/index.cjs +151 -9
- package/node_modules/@hono/node-server/dist/index.mjs +151 -9
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
- package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.buffer.d.ts +5 -5
- package/node_modules/@types/node/crypto.d.ts +2 -2
- package/node_modules/@types/node/http.d.ts +16 -0
- package/node_modules/@types/node/http2.d.ts +10 -2
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/process.d.ts +52 -0
- package/node_modules/@types/node/quic.d.ts +210 -28
- package/node_modules/@types/node/sqlite.d.ts +6 -2
- package/node_modules/@types/node/test.d.ts +36 -0
- package/node_modules/eventsource-parser/dist/index.cjs +2 -2
- package/node_modules/eventsource-parser/dist/index.cjs.map +1 -1
- package/node_modules/eventsource-parser/dist/index.js +2 -2
- package/node_modules/eventsource-parser/dist/index.js.map +1 -1
- package/node_modules/eventsource-parser/package.json +1 -1
- package/node_modules/eventsource-parser/src/parse.ts +4 -2
- package/node_modules/fast-uri/index.js +201 -48
- package/node_modules/fast-uri/lib/schemes.js +9 -4
- package/node_modules/fast-uri/lib/utils.js +388 -91
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
- package/node_modules/fast-uri/test/equal.test.js +31 -3
- package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
- package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
- package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
- package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
- package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
- package/node_modules/fast-uri/test/parse.test.js +7 -3
- package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
- package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
- package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
- package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
- package/node_modules/fast-uri/test/security.test.js +75 -3
- package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
- package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
- package/node_modules/hono/dist/cjs/client/client.js +27 -13
- package/node_modules/hono/dist/cjs/client/utils.js +4 -1
- package/node_modules/hono/dist/cjs/context.js +4 -0
- package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
- package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
- package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
- package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +16 -13
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/cjs/request.js +8 -4
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/cjs/router/utils.js +27 -0
- package/node_modules/hono/dist/cjs/utils/body.js +15 -3
- package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
- package/node_modules/hono/dist/cjs/utils/url.js +11 -3
- package/node_modules/hono/dist/client/client.js +27 -13
- package/node_modules/hono/dist/client/utils.js +4 -1
- package/node_modules/hono/dist/context.js +4 -0
- package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
- package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
- package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
- package/node_modules/hono/dist/jsx/dom/render.js +2 -0
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/middleware/cache/index.js +1 -1
- package/node_modules/hono/dist/middleware/cors/index.js +16 -13
- package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/middleware/etag/index.js +3 -3
- package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/request.js +8 -4
- package/node_modules/hono/dist/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
- package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
- package/node_modules/hono/dist/router/trie-router/node.js +46 -69
- package/node_modules/hono/dist/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/router/utils.js +5 -0
- package/node_modules/hono/dist/types/context.d.ts +4 -0
- package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
- package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
- package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
- package/node_modules/hono/dist/utils/body.js +15 -3
- package/node_modules/hono/dist/utils/cookie.js +1 -1
- package/node_modules/hono/dist/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/utils/stream.js +7 -1
- package/node_modules/hono/dist/utils/url.js +11 -3
- package/node_modules/hono/package.json +1 -1
- package/node_modules/ip-address/README.md +134 -134
- package/node_modules/ip-address/dist/address-error.d.ts +11 -0
- package/node_modules/ip-address/dist/address-error.js.map +1 -1
- package/node_modules/ip-address/dist/ipv4.d.ts +22 -6
- package/node_modules/ip-address/dist/ipv4.js +22 -6
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.d.ts +10 -3
- package/node_modules/ip-address/dist/ipv6.js +26 -17
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/package.json +1 -1
- package/node_modules/is-plain-object/README.md +39 -95
- package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
- package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
- package/node_modules/is-plain-object/package.json +8 -34
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +12 -17
- package/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
- package/node_modules/jose/dist/types/types.d.ts +4 -2
- package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +32 -21
- package/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
- package/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
- package/node_modules/jose/dist/webapi/jwks/local.js +45 -53
- package/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
- package/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
- package/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
- package/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
- package/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
- package/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
- package/node_modules/jose/dist/webapi/key/import.js +16 -12
- package/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
- package/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
- package/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +45 -13
- package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
- package/node_modules/jose/dist/webapi/lib/key.js +24 -9
- package/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
- package/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
- package/node_modules/jose/dist/webapi/lib/options.js +26 -0
- package/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
- package/node_modules/jose/package.json +1 -1
- package/package.json +2 -2
- package/dist/ui/assets/index-DdJeSfV9.js +0 -110
- package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* did:key — encode/decode for KEY-BEARING DIDs (HAP v0.6).
|
|
3
|
+
*
|
|
4
|
+
* A real `did:key` is self-certifying: the public key IS the identifier, so
|
|
5
|
+
* substituting the key produces a DIFFERENT DID and no key directory is ever
|
|
6
|
+
* consulted. That property is what the Owner Mandate design stands on
|
|
7
|
+
* (protocol.md → "Identity DIDs vs signing DIDs"): a signing DID MUST be
|
|
8
|
+
* key-bearing, and verification uses the key carried in the identifier —
|
|
9
|
+
* deliberately, there is no `public_key` field anywhere on the wire.
|
|
10
|
+
*
|
|
11
|
+
* Format (W3C did:key method, Ed25519):
|
|
12
|
+
* did:key:z<base58btc( 0xed 0x01 ‖ 32-byte-public-key )>
|
|
13
|
+
* `z` is the multibase prefix for base58btc; `0xed 0x01` is the multicodec
|
|
14
|
+
* varint for ed25519-pub. The result always starts `did:key:z6Mk`.
|
|
15
|
+
*
|
|
16
|
+
* Scope: Ed25519 only — the one signing curve this protocol version uses.
|
|
17
|
+
* Anything else (including the reference implementation's legacy decorative
|
|
18
|
+
* `did:key:<uuid-fragment>` identifiers) decodes as NOT key-bearing.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const B58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
22
|
+
const B58_MAP: Record<string, number> = {};
|
|
23
|
+
for (let i = 0; i < B58_ALPHABET.length; i++) B58_MAP[B58_ALPHABET[i]] = i;
|
|
24
|
+
|
|
25
|
+
/** multicodec ed25519-pub (0xed) as unsigned varint, followed by key bytes. */
|
|
26
|
+
const ED25519_MULTICODEC = Uint8Array.from([0xed, 0x01]);
|
|
27
|
+
const ED25519_KEY_BYTES = 32;
|
|
28
|
+
|
|
29
|
+
function base58btcEncode(bytes: Uint8Array): string {
|
|
30
|
+
// Count leading zero bytes — they encode as leading '1's.
|
|
31
|
+
let zeros = 0;
|
|
32
|
+
while (zeros < bytes.length && bytes[zeros] === 0) zeros++;
|
|
33
|
+
|
|
34
|
+
const digits: number[] = [];
|
|
35
|
+
for (let i = zeros; i < bytes.length; i++) {
|
|
36
|
+
let carry = bytes[i];
|
|
37
|
+
for (let j = 0; j < digits.length; j++) {
|
|
38
|
+
carry += digits[j] * 256;
|
|
39
|
+
digits[j] = carry % 58;
|
|
40
|
+
carry = (carry / 58) | 0;
|
|
41
|
+
}
|
|
42
|
+
while (carry > 0) {
|
|
43
|
+
digits.push(carry % 58);
|
|
44
|
+
carry = (carry / 58) | 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let out = '1'.repeat(zeros);
|
|
49
|
+
for (let i = digits.length - 1; i >= 0; i--) out += B58_ALPHABET[digits[i]];
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function base58btcDecode(s: string): Uint8Array {
|
|
54
|
+
let zeros = 0;
|
|
55
|
+
while (zeros < s.length && s[zeros] === '1') zeros++;
|
|
56
|
+
|
|
57
|
+
const bytes: number[] = [];
|
|
58
|
+
for (let i = zeros; i < s.length; i++) {
|
|
59
|
+
const val = B58_MAP[s[i]];
|
|
60
|
+
if (val === undefined) throw new Error(`invalid base58 character "${s[i]}"`);
|
|
61
|
+
let carry = val;
|
|
62
|
+
for (let j = 0; j < bytes.length; j++) {
|
|
63
|
+
carry += bytes[j] * 58;
|
|
64
|
+
bytes[j] = carry & 0xff;
|
|
65
|
+
carry >>= 8;
|
|
66
|
+
}
|
|
67
|
+
while (carry > 0) {
|
|
68
|
+
bytes.push(carry & 0xff);
|
|
69
|
+
carry >>= 8;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const out = new Uint8Array(zeros + bytes.length);
|
|
74
|
+
for (let i = 0; i < bytes.length; i++) out[zeros + i] = bytes[bytes.length - 1 - i];
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Encode a 32-byte Ed25519 public key as a key-bearing `did:key:z6Mk…`. */
|
|
79
|
+
export function encodeDidKey(publicKey: Uint8Array): string {
|
|
80
|
+
if (publicKey.length !== ED25519_KEY_BYTES) {
|
|
81
|
+
throw new Error(`INVALID_KEY: expected ${ED25519_KEY_BYTES} bytes, got ${publicKey.length}`);
|
|
82
|
+
}
|
|
83
|
+
const prefixed = new Uint8Array(ED25519_MULTICODEC.length + publicKey.length);
|
|
84
|
+
prefixed.set(ED25519_MULTICODEC, 0);
|
|
85
|
+
prefixed.set(publicKey, ED25519_MULTICODEC.length);
|
|
86
|
+
return `did:key:z${base58btcEncode(prefixed)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Decode a key-bearing `did:key` to its Ed25519 public key bytes.
|
|
91
|
+
*
|
|
92
|
+
* @throws Error prefixed `NOT_KEY_BEARING:` for anything that is not a valid
|
|
93
|
+
* base58btc-multibase Ed25519 did:key — including the legacy decorative
|
|
94
|
+
* `did:key:<uuid-fragment>` identifiers, other multibase prefixes, and other
|
|
95
|
+
* key types. The error name is the point: under the mandate design, a
|
|
96
|
+
* non-key-bearing signing DID must fail STRUCTURALLY, never fall back.
|
|
97
|
+
*/
|
|
98
|
+
export function decodeDidKey(did: string): Uint8Array {
|
|
99
|
+
if (!did.startsWith('did:key:z')) {
|
|
100
|
+
throw new Error(`NOT_KEY_BEARING: ${JSON.stringify(did)} is not a base58btc did:key`);
|
|
101
|
+
}
|
|
102
|
+
let decoded: Uint8Array;
|
|
103
|
+
try {
|
|
104
|
+
decoded = base58btcDecode(did.slice('did:key:z'.length));
|
|
105
|
+
} catch (err) {
|
|
106
|
+
throw new Error(`NOT_KEY_BEARING: ${(err as Error).message}`);
|
|
107
|
+
}
|
|
108
|
+
if (
|
|
109
|
+
decoded.length !== ED25519_MULTICODEC.length + ED25519_KEY_BYTES ||
|
|
110
|
+
decoded[0] !== ED25519_MULTICODEC[0] ||
|
|
111
|
+
decoded[1] !== ED25519_MULTICODEC[1]
|
|
112
|
+
) {
|
|
113
|
+
throw new Error('NOT_KEY_BEARING: not an ed25519-pub multicodec payload');
|
|
114
|
+
}
|
|
115
|
+
return decoded.slice(ED25519_MULTICODEC.length);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** True iff the DID decodes as a key-bearing Ed25519 did:key. Never throws. */
|
|
119
|
+
export function isKeyBearingDid(did: string): boolean {
|
|
120
|
+
try {
|
|
121
|
+
decodeDidKey(did);
|
|
122
|
+
return true;
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - {@link deriveIdentityLine} — the human-readable footer line for a subject.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type { Subject } from './types';
|
|
11
|
+
import type { OwnerMandate, Subject } from './types';
|
|
12
12
|
|
|
13
13
|
export interface SubjectValidation {
|
|
14
14
|
valid: boolean;
|
|
@@ -19,12 +19,25 @@ export interface SubjectValidation {
|
|
|
19
19
|
* Enforce the Identity-Assurance invariants on a single subject:
|
|
20
20
|
* - `self_declared` ⇒ `low` / `self`, no disclosed name.
|
|
21
21
|
* - `as_vouched` ⇒ `high` / `as`, `verifier` required.
|
|
22
|
-
* - `eudi` ⇒ `high` / `external`, `verifier`
|
|
22
|
+
* - `eudi` ⇒ `high` / `external`, `verifier` required — and, when the
|
|
23
|
+
* carrying attestation's `owner_mandates` are supplied, a corresponding
|
|
24
|
+
* entry with `binding:"eudi"` for this subject's DID.
|
|
23
25
|
* - `disclose.name` only at `assurance:"high"`.
|
|
26
|
+
*
|
|
27
|
+
* v0.6: `Subject.owner_signature` is deprecated and IGNORED here — it signed
|
|
28
|
+
* the identity claim, not the mandate (see the field's deprecation note). The
|
|
29
|
+
* signature-bearing object is the attestation's `owner_mandates` entry, which
|
|
30
|
+
* is payload-level context this per-subject check cannot see on its own; pass
|
|
31
|
+
* `opts.ownerMandates` to enforce the eudi ⇒ mandate-entry rule, omit it to
|
|
32
|
+
* validate subject shape alone (pre-0.6 callers keep their behaviour minus
|
|
33
|
+
* the retired owner_signature requirement).
|
|
24
34
|
*/
|
|
25
|
-
export function validateSubject(
|
|
35
|
+
export function validateSubject(
|
|
36
|
+
subject: Subject,
|
|
37
|
+
opts?: { ownerMandates?: OwnerMandate[] },
|
|
38
|
+
): SubjectValidation {
|
|
26
39
|
const errors: string[] = [];
|
|
27
|
-
const { did, assurance, method, trust_root, verifier, disclose
|
|
40
|
+
const { did, assurance, method, trust_root, verifier, disclose } = subject;
|
|
28
41
|
|
|
29
42
|
if (!did) errors.push('subject.did is required');
|
|
30
43
|
|
|
@@ -39,7 +52,10 @@ export function validateSubject(subject: Subject): SubjectValidation {
|
|
|
39
52
|
} else if (method === 'eudi') {
|
|
40
53
|
if (trust_root !== 'external') errors.push('eudi requires trust_root "external"');
|
|
41
54
|
if (!verifier) errors.push('eudi requires a verifier');
|
|
42
|
-
if (
|
|
55
|
+
if (opts?.ownerMandates !== undefined) {
|
|
56
|
+
const entry = opts.ownerMandates.find(m => m.did === did && m.binding === 'eudi');
|
|
57
|
+
if (!entry) errors.push('eudi requires an owner_mandates entry with binding "eudi" for this DID');
|
|
58
|
+
}
|
|
43
59
|
} else {
|
|
44
60
|
errors.push(`high assurance requires method "as_vouched" or "eudi", got "${method}"`);
|
|
45
61
|
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owner Mandate Signatures (HAP v0.6) — the `HAP-mandate` projection, the
|
|
3
|
+
* `HAP-approval` object, and their verification.
|
|
4
|
+
*
|
|
5
|
+
* The human signs BEFORE the AS does, so they cannot sign the finished
|
|
6
|
+
* attestation (`attestation_id`/`issued_at` do not exist yet). They sign a
|
|
7
|
+
* mandate PROJECTION: a canonical object every field of which is known at
|
|
8
|
+
* approval time and reconstructible from the finished attestation — so a
|
|
9
|
+
* verifier rebuilds it from the attestation it already holds and checks the
|
|
10
|
+
* signature with the key carried in the owner's DID. No side channel, no
|
|
11
|
+
* second fetch, no key directory. See protocol.md → "Owner Mandate Signatures".
|
|
12
|
+
*
|
|
13
|
+
* Verification here requires NO trust in the AS. What it cannot do is tell the
|
|
14
|
+
* verifier WHOSE key signed — confirming the DID belongs to the expected
|
|
15
|
+
* person is the out-of-band step (protocol.md → "Identity DIDs vs signing
|
|
16
|
+
* DIDs"), and it is the honest cost of cold verification.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import * as ed from '@noble/ed25519';
|
|
20
|
+
import type { Attestation, AttestationPayload, OwnerMandate } from './types';
|
|
21
|
+
import { canonicalize } from './canonicalize';
|
|
22
|
+
import { decodeDidKey } from './did-key';
|
|
23
|
+
|
|
24
|
+
/** The object the owner signs — a canonical projection of the mandate. */
|
|
25
|
+
export interface MandateProjection {
|
|
26
|
+
typ: 'HAP-mandate';
|
|
27
|
+
/** Projection/canonicalization version. A verifier MUST pin it. */
|
|
28
|
+
version: '0.6';
|
|
29
|
+
profile_id: string;
|
|
30
|
+
/** The signing owner's own DID. MUST be a member of `resolved_owners`. */
|
|
31
|
+
owner_did: string;
|
|
32
|
+
bounds_hash: string;
|
|
33
|
+
context_hash: string;
|
|
34
|
+
execution_context_hash: string;
|
|
35
|
+
gate_content_hashes: Record<string, string>;
|
|
36
|
+
/** Included iff the attestation carries one — binds ciphertext AND the
|
|
37
|
+
* frozen approver set, the swap this mechanism exists to stop. */
|
|
38
|
+
intent_disclosure_hash?: string;
|
|
39
|
+
commitment_mode: string;
|
|
40
|
+
/** The replay defence: the human signs how long the authority lives. */
|
|
41
|
+
expires_at: number;
|
|
42
|
+
nonce: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Per-action approval, signed by the owner in `review` mode. Signing a
|
|
46
|
+
* `reject` matters as much as a `commit`: a rejection the AS can discard is a
|
|
47
|
+
* rejection that never happened. */
|
|
48
|
+
export interface ApprovalObject {
|
|
49
|
+
typ: 'HAP-approval';
|
|
50
|
+
version: '0.6';
|
|
51
|
+
proposal_id: string;
|
|
52
|
+
attestation_id: string;
|
|
53
|
+
decision: 'commit' | 'reject';
|
|
54
|
+
/** What was approved: the receipt's contentHash where the profile binds
|
|
55
|
+
* content; otherwise sha256 over the JCS of the proposal's argument set. */
|
|
56
|
+
content_hash: string;
|
|
57
|
+
decided_at: number;
|
|
58
|
+
nonce: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class MandateError extends Error {
|
|
62
|
+
constructor(
|
|
63
|
+
public code:
|
|
64
|
+
| 'MANDATE_SIGNATURE_INVALID'
|
|
65
|
+
| 'APPROVAL_SIGNATURE_INVALID'
|
|
66
|
+
| 'NOT_KEY_BEARING'
|
|
67
|
+
| 'OWNER_NOT_RESOLVED'
|
|
68
|
+
| 'MALFORMED_ATTESTATION',
|
|
69
|
+
message: string,
|
|
70
|
+
) {
|
|
71
|
+
super(`${code}: ${message}`);
|
|
72
|
+
this.name = 'MandateError';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Rebuild the projection a given `owner_mandates` entry signed, from the
|
|
78
|
+
* attestation's own signed fields. Field absence is defined, not incidental:
|
|
79
|
+
* `intent_disclosure_hash` is included iff the attestation carries one.
|
|
80
|
+
*/
|
|
81
|
+
export function buildMandateProjection(
|
|
82
|
+
payload: AttestationPayload,
|
|
83
|
+
entry: Pick<OwnerMandate, 'did' | 'nonce'>,
|
|
84
|
+
): MandateProjection {
|
|
85
|
+
const { profile_id, bounds_hash, context_hash, execution_context_hash, gate_content_hashes, commitment_mode, expires_at } = payload;
|
|
86
|
+
if (!bounds_hash || !context_hash || !commitment_mode) {
|
|
87
|
+
throw new MandateError('MALFORMED_ATTESTATION', 'mandate projection requires bounds_hash, context_hash and commitment_mode');
|
|
88
|
+
}
|
|
89
|
+
const projection: MandateProjection = {
|
|
90
|
+
typ: 'HAP-mandate',
|
|
91
|
+
version: '0.6',
|
|
92
|
+
profile_id,
|
|
93
|
+
owner_did: entry.did,
|
|
94
|
+
bounds_hash,
|
|
95
|
+
context_hash,
|
|
96
|
+
execution_context_hash,
|
|
97
|
+
gate_content_hashes,
|
|
98
|
+
commitment_mode,
|
|
99
|
+
expires_at,
|
|
100
|
+
nonce: entry.nonce,
|
|
101
|
+
};
|
|
102
|
+
if (payload.intent_disclosure_hash !== undefined) {
|
|
103
|
+
projection.intent_disclosure_hash = payload.intent_disclosure_hash;
|
|
104
|
+
}
|
|
105
|
+
return projection;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The exact bytes an owner signs: RFC 8785 (JCS) canonical UTF-8. */
|
|
109
|
+
export function mandateSigningBytes(projection: MandateProjection): Uint8Array {
|
|
110
|
+
return new TextEncoder().encode(canonicalize(projection));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The exact bytes an owner signs for a per-action approval. */
|
|
114
|
+
export function approvalSigningBytes(approval: ApprovalObject): Uint8Array {
|
|
115
|
+
return new TextEncoder().encode(canonicalize(approval));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function base64urlToBytes(s: string): Uint8Array {
|
|
119
|
+
const base64 = s.replace(/-/g, '+').replace(/_/g, '/');
|
|
120
|
+
const padding = base64.length % 4 === 0 ? '' : '='.repeat(4 - (base64.length % 4));
|
|
121
|
+
return new Uint8Array(Buffer.from(base64 + padding, 'base64'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function bytesToBase64url(bytes: Uint8Array): string {
|
|
125
|
+
return Buffer.from(bytes).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Sign a mandate projection with a raw Ed25519 private key — the `raw`
|
|
130
|
+
* binding: tests and CI only, no custody claim. WebAuthn (`webauthn`) and
|
|
131
|
+
* wallet (`eudi`) bindings sign the same bytes through their own custody;
|
|
132
|
+
* they are implemented by the platforms that hold those keys, not here.
|
|
133
|
+
*/
|
|
134
|
+
export async function signMandateProjection(
|
|
135
|
+
projection: MandateProjection,
|
|
136
|
+
privateKey: Uint8Array,
|
|
137
|
+
): Promise<string> {
|
|
138
|
+
const sig = await ed.signAsync(mandateSigningBytes(projection), privateKey);
|
|
139
|
+
return bytesToBase64url(sig);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Sign an approval object with a raw Ed25519 private key (`raw` binding). */
|
|
143
|
+
export async function signApproval(approval: ApprovalObject, privateKey: Uint8Array): Promise<string> {
|
|
144
|
+
const sig = await ed.signAsync(approvalSigningBytes(approval), privateKey);
|
|
145
|
+
return bytesToBase64url(sig);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Verify ONE `owner_mandates` entry against the attestation that carries it.
|
|
150
|
+
*
|
|
151
|
+
* Steps (protocol.md → "Verification procedure", steps 4 of 6): membership in
|
|
152
|
+
* `resolved_owners`, key-bearing DID, projection reconstruction, Ed25519 over
|
|
153
|
+
* JCS bytes. The DID is authoritative over `alg` — a disagreement is
|
|
154
|
+
* MANDATE_SIGNATURE_INVALID, never a fallback to the claimed algorithm.
|
|
155
|
+
*
|
|
156
|
+
* What this deliberately does NOT verify: that the DID belongs to the person
|
|
157
|
+
* the verifier expects (out-of-band, step 5) and the AS's own signature over
|
|
158
|
+
* the attestation (verifyAttestationSignature, step 1).
|
|
159
|
+
*/
|
|
160
|
+
export async function verifyOwnerMandate(attestation: Attestation, entry: OwnerMandate): Promise<void> {
|
|
161
|
+
const owners = attestation.payload.resolved_owners ?? [];
|
|
162
|
+
if (!owners.includes(entry.did)) {
|
|
163
|
+
throw new MandateError('OWNER_NOT_RESOLVED', `signing DID ${entry.did} is not in resolved_owners`);
|
|
164
|
+
}
|
|
165
|
+
if (entry.alg !== 'EdDSA') {
|
|
166
|
+
// The only key type a did:key carries in this protocol version is Ed25519;
|
|
167
|
+
// an entry claiming otherwise disagrees with its own DID.
|
|
168
|
+
throw new MandateError('MANDATE_SIGNATURE_INVALID', `alg ${entry.alg} disagrees with the DID's key type (DID is authoritative)`);
|
|
169
|
+
}
|
|
170
|
+
let publicKey: Uint8Array;
|
|
171
|
+
try {
|
|
172
|
+
publicKey = decodeDidKey(entry.did);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
throw new MandateError('NOT_KEY_BEARING', (err as Error).message);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const projection = buildMandateProjection(attestation.payload, entry);
|
|
178
|
+
const ok = await ed.verifyAsync(base64urlToBytes(entry.signature), mandateSigningBytes(projection), publicKey);
|
|
179
|
+
if (!ok) {
|
|
180
|
+
throw new MandateError('MANDATE_SIGNATURE_INVALID', `owner mandate signature by ${entry.did} does not verify`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Verify every `owner_mandates` entry an attestation carries. Resolves to the
|
|
185
|
+
* verified entries; an attestation with none resolves to `[]` (the v0.5
|
|
186
|
+
* posture — nothing to check, and nothing claimed). */
|
|
187
|
+
export async function verifyOwnerMandates(attestation: Attestation): Promise<OwnerMandate[]> {
|
|
188
|
+
const entries = attestation.payload.owner_mandates ?? [];
|
|
189
|
+
for (const entry of entries) {
|
|
190
|
+
await verifyOwnerMandate(attestation, entry);
|
|
191
|
+
}
|
|
192
|
+
return entries;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Verify an approval signature against a signer's key-bearing DID. */
|
|
196
|
+
export async function verifyApproval(approval: ApprovalObject, signature: string, signerDid: string): Promise<void> {
|
|
197
|
+
let publicKey: Uint8Array;
|
|
198
|
+
try {
|
|
199
|
+
publicKey = decodeDidKey(signerDid);
|
|
200
|
+
} catch (err) {
|
|
201
|
+
throw new MandateError('NOT_KEY_BEARING', (err as Error).message);
|
|
202
|
+
}
|
|
203
|
+
const ok = await ed.verifyAsync(base64urlToBytes(signature), approvalSigningBytes(approval), publicKey);
|
|
204
|
+
if (!ok) {
|
|
205
|
+
throw new MandateError('APPROVAL_SIGNATURE_INVALID', `approval signature by ${signerDid} does not verify`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution receipts (HAP v0.5/v0.6) — the wire type and holder-side
|
|
3
|
+
* verification. Until v0.6 this library had no receipt surface at all; every
|
|
4
|
+
* verifier hand-assembled the strip→canonicalize→verify dance. This module is
|
|
5
|
+
* that dance, once.
|
|
6
|
+
*
|
|
7
|
+
* Receipt payloads are camelCase on the wire (unlike the snake_case
|
|
8
|
+
* attestation payload) — a shipped inconsistency v0.6 chose to document
|
|
9
|
+
* rather than break (changelog.md → "Renames and terminology").
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import * as ed from '@noble/ed25519';
|
|
13
|
+
import type { ContentBinding, Subject } from './types';
|
|
14
|
+
import { canonicalize } from './canonicalize';
|
|
15
|
+
|
|
16
|
+
/** Signed execution receipt — protocol.md → "Receipt Payload Schema". */
|
|
17
|
+
export interface ReceiptPayload {
|
|
18
|
+
id: string;
|
|
19
|
+
groupId?: string | null;
|
|
20
|
+
userId?: string;
|
|
21
|
+
boundsHash: string;
|
|
22
|
+
profileId: string;
|
|
23
|
+
/** Downstream tool name. Audit metadata only — never a dispatch key. */
|
|
24
|
+
action: string;
|
|
25
|
+
/** Semantic category — drives cumulative bucketing and bounds dispatch. */
|
|
26
|
+
actionType: string;
|
|
27
|
+
executionContext: Record<string, unknown>;
|
|
28
|
+
cumulativeState?: Record<string, unknown>;
|
|
29
|
+
limits?: Record<string, unknown>;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
/** v0.6 — hash of the bound content, computed by the Gatekeeper, copied
|
|
32
|
+
* verbatim by the AS. The AS never sees the content. */
|
|
33
|
+
contentHash?: string;
|
|
34
|
+
/** v0.6 — the binding declaration echoed into the signed receipt, so a
|
|
35
|
+
* verifier knows exactly what `contentHash` covers. */
|
|
36
|
+
contentBinding?: Pick<ContentBinding, 'version' | 'kind' | 'fields' | 'required_fields' | 'appliesTo'>;
|
|
37
|
+
/** v0.6 — disclosed subset of the attestation's identity overlay. */
|
|
38
|
+
subjects?: Subject[];
|
|
39
|
+
/** v0.6 — review path: the proposal this receipt executed. */
|
|
40
|
+
proposalId?: string;
|
|
41
|
+
/** v0.6 — review path: the owner's HAP-approval signature (or its sha256)
|
|
42
|
+
* for the executed proposal. */
|
|
43
|
+
approvalSignature?: string;
|
|
44
|
+
/** Ed25519 over the JCS-canonical payload (this field excluded), base64url. */
|
|
45
|
+
signature: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Verify a receipt's AS signature: strip `signature`, JCS-canonicalize the
|
|
50
|
+
* rest, Ed25519-verify against the AS public key (hex). This is holder-side
|
|
51
|
+
* verification — it needs the COMPLETE receipt; a redacted public view cannot
|
|
52
|
+
* be re-verified this way (protocol.md → "Receipt Verification").
|
|
53
|
+
*
|
|
54
|
+
* Content is checked separately: where `contentHash` is present, recompute it
|
|
55
|
+
* from the held artifact via the content-binding module and compare.
|
|
56
|
+
*
|
|
57
|
+
* @throws Error prefixed `INVALID_SIGNATURE:` when verification fails.
|
|
58
|
+
*/
|
|
59
|
+
export async function verifyReceiptSignature(receipt: ReceiptPayload, publicKeyHex: string): Promise<void> {
|
|
60
|
+
const { signature, ...unsigned } = receipt;
|
|
61
|
+
if (!signature) {
|
|
62
|
+
throw new Error('INVALID_SIGNATURE: receipt carries no signature');
|
|
63
|
+
}
|
|
64
|
+
const bytes = new TextEncoder().encode(canonicalize(unsigned));
|
|
65
|
+
const base64 = signature.replace(/-/g, '+').replace(/_/g, '/');
|
|
66
|
+
const padding = base64.length % 4 === 0 ? '' : '='.repeat(4 - (base64.length % 4));
|
|
67
|
+
const sigBytes = new Uint8Array(Buffer.from(base64 + padding, 'base64'));
|
|
68
|
+
const publicKeyBytes = new Uint8Array(Buffer.from(publicKeyHex, 'hex'));
|
|
69
|
+
|
|
70
|
+
const ok = await ed.verifyAsync(sigBytes, bytes, publicKeyBytes).catch(() => false);
|
|
71
|
+
if (!ok) {
|
|
72
|
+
throw new Error('INVALID_SIGNATURE: receipt signature verification failed');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -19,7 +19,7 @@ export interface ResolvedDomain {
|
|
|
19
19
|
|
|
20
20
|
export interface AttestationPayload {
|
|
21
21
|
attestation_id: string;
|
|
22
|
-
version: '0.3' | '0.4' | '0.5';
|
|
22
|
+
version: '0.3' | '0.4' | '0.5' | '0.6';
|
|
23
23
|
profile_id: string;
|
|
24
24
|
/** v0.3 (deprecated) — hash of the authorization frame */
|
|
25
25
|
frame_hash?: string;
|
|
@@ -67,12 +67,55 @@ export interface AttestationPayload {
|
|
|
67
67
|
*
|
|
68
68
|
* Cryptographically bound in the signed payload so a compromised SP cannot
|
|
69
69
|
* silently flip 'review' → 'automatic'. Absent on v0.3 attestations.
|
|
70
|
+
* `review_above_cap` (v0.5): automatic below the signed caps, proposal above.
|
|
70
71
|
*/
|
|
71
|
-
commitment_mode?: 'automatic' | 'review';
|
|
72
|
+
commitment_mode?: 'automatic' | 'review' | 'review_above_cap';
|
|
73
|
+
/**
|
|
74
|
+
* v0.6 (Owner Mandate Signatures) — the Decision Owner's own signature(s)
|
|
75
|
+
* over the mandate projection ({@link MandateProjection}), one entry per
|
|
76
|
+
* co-signing owner. Carried INSIDE the AS-signed payload, so the AS attests
|
|
77
|
+
* to having received it and cannot strip it without invalidating its own
|
|
78
|
+
* signature. Optional and additive: an attestation without it behaves as
|
|
79
|
+
* before (the v0.5 posture — the AS asserts, nobody co-signs).
|
|
80
|
+
*/
|
|
81
|
+
owner_mandates?: OwnerMandate[];
|
|
72
82
|
issued_at: number;
|
|
73
83
|
expires_at: number;
|
|
74
84
|
}
|
|
75
85
|
|
|
86
|
+
/** Mandate-assurance axis — what custody signed the mandate. Independent of
|
|
87
|
+
* identity assurance ({@link Subject.method}). */
|
|
88
|
+
export type MandateBinding = 'raw' | 'webauthn' | 'eudi';
|
|
89
|
+
|
|
90
|
+
/** Which surface showed the owner what they signed. A DECLARATION, not a proof
|
|
91
|
+
* — no verifier can check it; see protocol.md → Owner Mandate Signatures. */
|
|
92
|
+
export type SigningSurface = 'gatekeeper_local' | 'as_web' | 'wallet_display';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* v0.6 — one owner's signature over the mandate projection.
|
|
96
|
+
*
|
|
97
|
+
* There is deliberately NO `public_key` field, and it MUST NOT be added: the
|
|
98
|
+
* verification key is carried in the DID itself (key-bearing `did:key`), so a
|
|
99
|
+
* non-key-bearing DID fails STRUCTURALLY instead of validating against a key
|
|
100
|
+
* the AS could have substituted. `alg` is kept only as curve-confusion
|
|
101
|
+
* hygiene; if it disagrees with the DID's key type, the DID is authoritative.
|
|
102
|
+
*/
|
|
103
|
+
export interface OwnerMandate {
|
|
104
|
+
/** The signing owner's key-bearing DID. MUST be a member of `resolved_owners`. */
|
|
105
|
+
did: string;
|
|
106
|
+
/** Signature algorithm hint. The DID's multicodec wins on any disagreement. */
|
|
107
|
+
alg: 'EdDSA' | 'ES256';
|
|
108
|
+
/** base64url (no padding) signature over the JCS bytes of the mandate projection. */
|
|
109
|
+
signature: string;
|
|
110
|
+
/** When the owner signed (unix seconds). */
|
|
111
|
+
signed_at: number;
|
|
112
|
+
/** Defence-in-depth against duplicate issuance by an HONEST AS only —
|
|
113
|
+
* AS-side nonce enforcement is no defence against the AS itself. */
|
|
114
|
+
nonce: string;
|
|
115
|
+
binding: MandateBinding;
|
|
116
|
+
signing_surface?: SigningSurface;
|
|
117
|
+
}
|
|
118
|
+
|
|
76
119
|
/**
|
|
77
120
|
* v0.6 Identity Assurance — a signed overlay binding a Decision Owner's verified
|
|
78
121
|
* real-world identity to the attestation, gated by HOW the identity was verified.
|
|
@@ -98,8 +141,11 @@ export interface Subject {
|
|
|
98
141
|
/** When the underlying verification was performed (unix seconds). */
|
|
99
142
|
verified_at?: number;
|
|
100
143
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
144
|
+
* @deprecated v0.6 — replaced by {@link AttestationPayload.owner_mandates}.
|
|
145
|
+
* This field signed the wrong object (the identity claim, not what was
|
|
146
|
+
* committed to) and was welded to one method. Implementations MUST NOT emit
|
|
147
|
+
* it; verifiers MAY ignore it on artifacts that carry it. Kept readable for
|
|
148
|
+
* audit of pre-0.6 artifacts only.
|
|
103
149
|
*/
|
|
104
150
|
owner_signature?: string | null;
|
|
105
151
|
}
|
|
@@ -340,6 +386,15 @@ export interface ProfileContextField {
|
|
|
340
386
|
description?: string;
|
|
341
387
|
displayName?: string;
|
|
342
388
|
format?: 'email' | 'domain' | 'url' | 'currency';
|
|
389
|
+
/**
|
|
390
|
+
* v0.6 — what this field NAMES on the read path. `counterparty` = the other
|
|
391
|
+
* party to a communication (matched against an item's participants);
|
|
392
|
+
* `resource` = the container an item belongs to (a direct attribute match —
|
|
393
|
+
* and a resource scope enforced on writes MUST also bind reads). Absent →
|
|
394
|
+
* implementations MAY infer `counterparty` from `format: email|domain`
|
|
395
|
+
* (transitional; the explicit declaration is normative).
|
|
396
|
+
*/
|
|
397
|
+
scopeKind?: 'counterparty' | 'resource';
|
|
343
398
|
constraint?: FieldConstraint;
|
|
344
399
|
enum?: string[];
|
|
345
400
|
}
|
|
@@ -636,7 +691,28 @@ export interface GatekeeperRequest {
|
|
|
636
691
|
* Structured error from Gatekeeper verification.
|
|
637
692
|
*/
|
|
638
693
|
export interface GatekeeperError {
|
|
639
|
-
code:
|
|
694
|
+
code:
|
|
695
|
+
| 'BOUND_EXCEEDED'
|
|
696
|
+
| 'CUMULATIVE_LIMIT_EXCEEDED'
|
|
697
|
+
| 'INVALID_SIGNATURE'
|
|
698
|
+
| 'TTL_EXPIRED'
|
|
699
|
+
| 'FRAME_MISMATCH'
|
|
700
|
+
| 'BOUNDS_MISMATCH'
|
|
701
|
+
| 'CONTEXT_MISMATCH'
|
|
702
|
+
| 'DOMAIN_NOT_COVERED'
|
|
703
|
+
| 'INVALID_PROFILE'
|
|
704
|
+
| 'MALFORMED_ATTESTATION'
|
|
705
|
+
// v0.5/v0.6 receipt-path codes a Gatekeeper must recognize as definitive
|
|
706
|
+
// rejections (protocol.md → Pre-flight Receipt Request):
|
|
707
|
+
| 'INVALID_ACTION_TYPE'
|
|
708
|
+
| 'ATTESTATION_REVOKED'
|
|
709
|
+
| 'APPROVAL_REQUIRED'
|
|
710
|
+
| 'IDEMPOTENCY_MISMATCH'
|
|
711
|
+
// v0.6 owner-mandate codes (protocol.md → Owner Mandate Signatures):
|
|
712
|
+
| 'MANDATE_SIGNATURE_REQUIRED'
|
|
713
|
+
| 'MANDATE_SIGNATURE_INVALID'
|
|
714
|
+
| 'APPROVAL_SIGNATURE_REQUIRED'
|
|
715
|
+
| 'APPROVAL_SIGNATURE_INVALID';
|
|
640
716
|
field?: string;
|
|
641
717
|
message: string;
|
|
642
718
|
bound?: string | number;
|