@synoi/sraid 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -50
- package/SPEC.md +2 -2
- package/dist/attestation.d.ts +8 -49
- package/dist/attestation.d.ts.map +1 -1
- package/dist/attestation.js +15 -46
- package/dist/attestation.js.map +1 -1
- package/dist/capability.d.ts +59 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +44 -0
- package/dist/capability.js.map +1 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -18
- package/dist/index.js.map +1 -1
- package/dist/internal/attestation-core.d.ts +85 -0
- package/dist/internal/attestation-core.d.ts.map +1 -0
- package/dist/internal/attestation-core.js +78 -0
- package/dist/internal/attestation-core.js.map +1 -0
- package/dist/internal/base64-browser.d.ts +31 -0
- package/dist/internal/base64-browser.d.ts.map +1 -0
- package/dist/internal/base64-browser.js +39 -0
- package/dist/internal/base64-browser.js.map +1 -0
- package/dist/internal/base64-validate.d.ts +19 -0
- package/dist/internal/base64-validate.d.ts.map +1 -0
- package/dist/internal/base64-validate.js +33 -0
- package/dist/internal/base64-validate.js.map +1 -0
- package/dist/internal/base64.d.ts +7 -5
- package/dist/internal/base64.d.ts.map +1 -1
- package/dist/internal/base64.js +7 -19
- package/dist/internal/base64.js.map +1 -1
- package/dist/internal/content-core.d.ts +68 -0
- package/dist/internal/content-core.d.ts.map +1 -0
- package/dist/internal/content-core.js +87 -0
- package/dist/internal/content-core.js.map +1 -0
- package/dist/internal/ed25519-browser.d.ts +33 -0
- package/dist/internal/ed25519-browser.d.ts.map +1 -0
- package/dist/internal/ed25519-browser.js +79 -0
- package/dist/internal/ed25519-browser.js.map +1 -0
- package/dist/internal/mldsa-browser.d.ts +27 -0
- package/dist/internal/mldsa-browser.d.ts.map +1 -0
- package/dist/internal/mldsa-browser.js +35 -0
- package/dist/internal/mldsa-browser.js.map +1 -0
- package/dist/internal/sha256-browser.d.ts +17 -0
- package/dist/internal/sha256-browser.d.ts.map +1 -0
- package/dist/internal/sha256-browser.js +27 -0
- package/dist/internal/sha256-browser.js.map +1 -0
- package/dist/lineage.js +0 -0
- package/dist/lineage.js.map +1 -1
- package/dist/oid.d.ts +2 -52
- package/dist/oid.d.ts.map +1 -1
- package/dist/oid.js +9 -71
- package/dist/oid.js.map +1 -1
- package/dist/types.d.ts +4 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -1
- package/dist/validate.d.ts +2 -17
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +0 -57
- package/dist/validate.js.map +1 -1
- package/dist/verify-browser.d.ts +80 -0
- package/dist/verify-browser.d.ts.map +1 -0
- package/dist/verify-browser.js +157 -0
- package/dist/verify-browser.js.map +1 -0
- package/package.json +22 -3
- package/src/attestation.ts +29 -88
- package/src/capability.ts +69 -0
- package/src/index.ts +27 -36
- package/src/internal/attestation-core.ts +122 -0
- package/src/internal/base64-browser.ts +39 -0
- package/src/internal/base64-validate.ts +31 -0
- package/src/internal/base64.ts +7 -16
- package/src/internal/content-core.ts +88 -0
- package/src/internal/ed25519-browser.ts +85 -0
- package/src/internal/mldsa-browser.ts +39 -0
- package/src/internal/sha256-browser.ts +28 -0
- package/src/lineage.ts +0 -0
- package/src/oid.ts +10 -73
- package/src/types.ts +23 -31
- package/src/validate.ts +1 -64
- package/src/verify-browser.ts +185 -0
- package/dist/authority.d.ts +0 -351
- package/dist/authority.d.ts.map +0 -1
- package/dist/authority.js +0 -563
- package/dist/authority.js.map +0 -1
- package/src/authority.ts +0 -849
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synoi/sraid — internal/ed25519-browser.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe Ed25519 verification. NO node:crypto.
|
|
5
|
+
*
|
|
6
|
+
* Primary path: WebCrypto (`globalThis.crypto.subtle`), which uses RFC 8032
|
|
7
|
+
* cofactored verification — the SAME rule OpenSSL/node:crypto uses on the node
|
|
8
|
+
* default entry, so the browser verifier accepts/rejects exactly what the node
|
|
9
|
+
* verifier does for every real signature.
|
|
10
|
+
*
|
|
11
|
+
* Fallback path: `@noble/curves` ed25519 (pure JS), used only when WebCrypto
|
|
12
|
+
* Ed25519 is unavailable (older embedded webviews / Chrome extensions below the
|
|
13
|
+
* WebCrypto-Ed25519 support floor, ~Chrome 137). @noble defaults to ZIP-215
|
|
14
|
+
* verification rules, which agree with cofactored on every well-formed
|
|
15
|
+
* signature and can differ only on deliberately malformed/malleable points that
|
|
16
|
+
* real signers never produce (see ed25519.ts for the same note). SynOI signs
|
|
17
|
+
* canonically, so the fallback is behavior-equivalent for legitimate inputs.
|
|
18
|
+
*
|
|
19
|
+
* ASYNC: WebCrypto verify is Promise-based, so this returns a Promise<boolean>.
|
|
20
|
+
* The browser attestation verifier is async as a result; the node path stays
|
|
21
|
+
* synchronous and unchanged.
|
|
22
|
+
*
|
|
23
|
+
* Returns false (never throws) on any malformed input or verification failure,
|
|
24
|
+
* matching the node `verifyEd25519` contract, so callers get a clean boolean.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Verify a raw 64-byte Ed25519 signature over `message` against a raw 32-byte
|
|
28
|
+
* public key. Prefers WebCrypto (cofactored, matching the node path); falls
|
|
29
|
+
* back to @noble/curves only when WebCrypto Ed25519 is not supported. Returns
|
|
30
|
+
* false on any malformed input or verification failure; never throws.
|
|
31
|
+
*/
|
|
32
|
+
export declare function verifyEd25519Browser(signature: Uint8Array, message: Uint8Array, publicKeyRaw: Uint8Array): Promise<boolean>;
|
|
33
|
+
//# sourceMappingURL=ed25519-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519-browser.d.ts","sourceRoot":"","sources":["../../src/internal/ed25519-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA8BH;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,UAAU,GACvB,OAAO,CAAC,OAAO,CAAC,CAoBlB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synoi/sraid — internal/ed25519-browser.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe Ed25519 verification. NO node:crypto.
|
|
5
|
+
*
|
|
6
|
+
* Primary path: WebCrypto (`globalThis.crypto.subtle`), which uses RFC 8032
|
|
7
|
+
* cofactored verification — the SAME rule OpenSSL/node:crypto uses on the node
|
|
8
|
+
* default entry, so the browser verifier accepts/rejects exactly what the node
|
|
9
|
+
* verifier does for every real signature.
|
|
10
|
+
*
|
|
11
|
+
* Fallback path: `@noble/curves` ed25519 (pure JS), used only when WebCrypto
|
|
12
|
+
* Ed25519 is unavailable (older embedded webviews / Chrome extensions below the
|
|
13
|
+
* WebCrypto-Ed25519 support floor, ~Chrome 137). @noble defaults to ZIP-215
|
|
14
|
+
* verification rules, which agree with cofactored on every well-formed
|
|
15
|
+
* signature and can differ only on deliberately malformed/malleable points that
|
|
16
|
+
* real signers never produce (see ed25519.ts for the same note). SynOI signs
|
|
17
|
+
* canonically, so the fallback is behavior-equivalent for legitimate inputs.
|
|
18
|
+
*
|
|
19
|
+
* ASYNC: WebCrypto verify is Promise-based, so this returns a Promise<boolean>.
|
|
20
|
+
* The browser attestation verifier is async as a result; the node path stays
|
|
21
|
+
* synchronous and unchanged.
|
|
22
|
+
*
|
|
23
|
+
* Returns false (never throws) on any malformed input or verification failure,
|
|
24
|
+
* matching the node `verifyEd25519` contract, so callers get a clean boolean.
|
|
25
|
+
*/
|
|
26
|
+
import { ed25519 } from '@noble/curves/ed25519.js';
|
|
27
|
+
// Fixed DER prefix for an Ed25519 SubjectPublicKeyInfo (RFC 8410):
|
|
28
|
+
// SEQUENCE { SEQUENCE { OID 1.3.101.112 } BIT STRING (32 raw bytes) }
|
|
29
|
+
// A plain Uint8Array literal (NOT Buffer, which is undefined in browsers). Used
|
|
30
|
+
// only for the SPKI import fallback below.
|
|
31
|
+
const ED25519_SPKI_PREFIX = new Uint8Array([
|
|
32
|
+
0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,
|
|
33
|
+
]);
|
|
34
|
+
const ED25519_ALG = { name: 'Ed25519' };
|
|
35
|
+
// Return type is inferred (webcrypto.CryptoKey); the bare `CryptoKey` global is
|
|
36
|
+
// not declared by @types/node ^20, so it is deliberately left un-annotated.
|
|
37
|
+
async function importPublicKey(publicKeyRaw) {
|
|
38
|
+
const subtle = globalThis.crypto.subtle;
|
|
39
|
+
try {
|
|
40
|
+
// Preferred: raw 32-byte import (Secure Curves spec).
|
|
41
|
+
return await subtle.importKey('raw', publicKeyRaw, ED25519_ALG, false, ['verify']);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Some engines only accept SPKI for Ed25519 import; wrap the raw key.
|
|
45
|
+
const spki = new Uint8Array(ED25519_SPKI_PREFIX.length + publicKeyRaw.length);
|
|
46
|
+
spki.set(ED25519_SPKI_PREFIX, 0);
|
|
47
|
+
spki.set(publicKeyRaw, ED25519_SPKI_PREFIX.length);
|
|
48
|
+
return await subtle.importKey('spki', spki, ED25519_ALG, false, ['verify']);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Verify a raw 64-byte Ed25519 signature over `message` against a raw 32-byte
|
|
53
|
+
* public key. Prefers WebCrypto (cofactored, matching the node path); falls
|
|
54
|
+
* back to @noble/curves only when WebCrypto Ed25519 is not supported. Returns
|
|
55
|
+
* false on any malformed input or verification failure; never throws.
|
|
56
|
+
*/
|
|
57
|
+
export async function verifyEd25519Browser(signature, message, publicKeyRaw) {
|
|
58
|
+
if (publicKeyRaw.length !== 32)
|
|
59
|
+
return false;
|
|
60
|
+
const subtle = globalThis.crypto?.subtle;
|
|
61
|
+
if (subtle) {
|
|
62
|
+
try {
|
|
63
|
+
const key = await importPublicKey(publicKeyRaw);
|
|
64
|
+
return await subtle.verify(ED25519_ALG, key, signature, message);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Fall through to @noble. A WebCrypto throw here is either an
|
|
68
|
+
// unsupported-algorithm signal or a malformed input; @noble resolves both
|
|
69
|
+
// correctly (a real bad signature/key verifies as false there too).
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return ed25519.verify(signature, message, publicKeyRaw);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=ed25519-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519-browser.js","sourceRoot":"","sources":["../../src/internal/ed25519-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAElD,mEAAmE;AACnE,wEAAwE;AACxE,gFAAgF;AAChF,2CAA2C;AAC3C,MAAM,mBAAmB,GAAG,IAAI,UAAU,CAAC;IACzC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CACvE,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,SAAS,EAAW,CAAA;AAEhD,gFAAgF;AAChF,4EAA4E;AAC5E,KAAK,UAAU,eAAe,CAAC,YAAwB;IACrD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAA;IACvC,IAAI,CAAC;QACH,sDAAsD;QACtD,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,Y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
|
+
* @synoi/sraid — internal/mldsa-browser.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe ML-DSA-65 (FIPS 204) verification. NO node:crypto.
|
|
5
|
+
*
|
|
6
|
+
* Browsers ship no native ML-DSA, so there is only one path here: the pure-JS
|
|
7
|
+
* `@noble/post-quantum` implementation, which is fully browser-safe. The node
|
|
8
|
+
* default entry (mldsa.ts) uses a native OpenSSL fast path with this same
|
|
9
|
+
* @noble impl as its fallback, so both entries are byte-for-byte interoperable.
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: import `ml_dsa65` DIRECTLY from `@noble/post-quantum/ml-dsa.js`,
|
|
12
|
+
* NOT from ./mldsa.ts — that module statically imports `node:crypto` (for its
|
|
13
|
+
* native fast path and the globalThis.crypto polyfill), which would poison a
|
|
14
|
+
* browser bundle. No globalThis.crypto polyfill is needed here: browsers,
|
|
15
|
+
* workers, and MV3 service workers all provide it natively, and ml_dsa65.verify
|
|
16
|
+
* is deterministic (it never calls getRandomValues; only keygen/sign do).
|
|
17
|
+
*
|
|
18
|
+
* Verification is SYNCHRONOUS. Returns false (never throws) on any malformed
|
|
19
|
+
* input or verification failure, matching the node `verifyMlDsa65` contract.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Verify a raw ML-DSA-65 signature over `message` against a raw 1952-byte
|
|
23
|
+
* public key using @noble/post-quantum. Returns false on any malformed input or
|
|
24
|
+
* verification failure; never throws.
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifyMlDsa65Browser(signature: Uint8Array, message: Uint8Array, publicKeyRaw: Uint8Array): boolean;
|
|
27
|
+
//# sourceMappingURL=mldsa-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mldsa-browser.d.ts","sourceRoot":"","sources":["../../src/internal/mldsa-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,UAAU,GACvB,OAAO,CAMT"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synoi/sraid — internal/mldsa-browser.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe ML-DSA-65 (FIPS 204) verification. NO node:crypto.
|
|
5
|
+
*
|
|
6
|
+
* Browsers ship no native ML-DSA, so there is only one path here: the pure-JS
|
|
7
|
+
* `@noble/post-quantum` implementation, which is fully browser-safe. The node
|
|
8
|
+
* default entry (mldsa.ts) uses a native OpenSSL fast path with this same
|
|
9
|
+
* @noble impl as its fallback, so both entries are byte-for-byte interoperable.
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: import `ml_dsa65` DIRECTLY from `@noble/post-quantum/ml-dsa.js`,
|
|
12
|
+
* NOT from ./mldsa.ts — that module statically imports `node:crypto` (for its
|
|
13
|
+
* native fast path and the globalThis.crypto polyfill), which would poison a
|
|
14
|
+
* browser bundle. No globalThis.crypto polyfill is needed here: browsers,
|
|
15
|
+
* workers, and MV3 service workers all provide it natively, and ml_dsa65.verify
|
|
16
|
+
* is deterministic (it never calls getRandomValues; only keygen/sign do).
|
|
17
|
+
*
|
|
18
|
+
* Verification is SYNCHRONOUS. Returns false (never throws) on any malformed
|
|
19
|
+
* input or verification failure, matching the node `verifyMlDsa65` contract.
|
|
20
|
+
*/
|
|
21
|
+
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';
|
|
22
|
+
/**
|
|
23
|
+
* Verify a raw ML-DSA-65 signature over `message` against a raw 1952-byte
|
|
24
|
+
* public key using @noble/post-quantum. Returns false on any malformed input or
|
|
25
|
+
* verification failure; never throws.
|
|
26
|
+
*/
|
|
27
|
+
export function verifyMlDsa65Browser(signature, message, publicKeyRaw) {
|
|
28
|
+
try {
|
|
29
|
+
return ml_dsa65.verify(signature, message, publicKeyRaw);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=mldsa-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mldsa-browser.js","sourceRoot":"","sources":["../../src/internal/mldsa-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAqB,EACrB,OAAmB,EACnB,YAAwB;IAExB,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synoi/sraid — internal/sha256-browser.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe SHA-256 via WebCrypto (`globalThis.crypto.subtle.digest`). NO
|
|
5
|
+
* node:crypto. Used by the browser OID helpers in verify-browser.ts.
|
|
6
|
+
*
|
|
7
|
+
* ASYNC: subtle.digest is Promise-based, so the browser OID helpers are async
|
|
8
|
+
* (the node oid.ts helpers stay synchronous via node:crypto createHash and are
|
|
9
|
+
* unchanged). SHA-256 is byte-identical across any conformant implementation,
|
|
10
|
+
* so a browser-computed OID equals the node-computed one for the same input.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Compute `sha256:` + lowercase hex of SHA-256(bytes) using WebCrypto. Mirrors
|
|
14
|
+
* the `sha256:`-prefixed output of the node oid.ts helpers.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sha256HexPrefixed(bytes: Uint8Array): Promise<string>;
|
|
17
|
+
//# sourceMappingURL=sha256-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256-browser.d.ts","sourceRoot":"","sources":["../../src/internal/sha256-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAG1E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synoi/sraid — internal/sha256-browser.ts
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe SHA-256 via WebCrypto (`globalThis.crypto.subtle.digest`). NO
|
|
5
|
+
* node:crypto. Used by the browser OID helpers in verify-browser.ts.
|
|
6
|
+
*
|
|
7
|
+
* ASYNC: subtle.digest is Promise-based, so the browser OID helpers are async
|
|
8
|
+
* (the node oid.ts helpers stay synchronous via node:crypto createHash and are
|
|
9
|
+
* unchanged). SHA-256 is byte-identical across any conformant implementation,
|
|
10
|
+
* so a browser-computed OID equals the node-computed one for the same input.
|
|
11
|
+
*/
|
|
12
|
+
function toHex(bytes) {
|
|
13
|
+
let out = '';
|
|
14
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
15
|
+
out += bytes[i].toString(16).padStart(2, '0');
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compute `sha256:` + lowercase hex of SHA-256(bytes) using WebCrypto. Mirrors
|
|
21
|
+
* the `sha256:`-prefixed output of the node oid.ts helpers.
|
|
22
|
+
*/
|
|
23
|
+
export async function sha256HexPrefixed(bytes) {
|
|
24
|
+
const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
|
|
25
|
+
return 'sha256:' + toHex(new Uint8Array(digest));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=sha256-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256-browser.js","sourceRoot":"","sources":["../../src/internal/sha256-browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,SAAS,KAAK,CAAC,KAAiB;IAC9B,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,GAAG,IAAK,KAAK,CAAC,CAAC,CAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAAiB;IACvD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IACtE,OAAO,SAAS,GAAG,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;AAClD,CAAC"}
|
package/dist/lineage.js
CHANGED
|
Binary file
|
package/dist/lineage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineage.js","sourceRoot":"","sources":["../src/lineage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,IAAiD;IAC5E,MAAM,GAAG,GAAkB,EAAE,CAAA;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,IAAI,GAAG,CAAC,GAAY,EAAE,GAAW,EAAQ,EAAE;QAC/C,MAAM,GAAG,GAAG,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"lineage.js","sourceRoot":"","sources":["../src/lineage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,Y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CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9E,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK;YAC1C,OAAO,EAAE,CAAC,yBAAyB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;IAClE,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;AAC5D,CAAC"}
|
package/dist/oid.d.ts
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* This matches the gateway's `computeGapOid` (src/gap/oid.ts) and
|
|
20
20
|
* `payloadOid` (src/inference/receipts.ts) byte-for-byte.
|
|
21
21
|
*/
|
|
22
|
+
import { CDRO_ENVELOPE_FIELDS, cdroContentCore } from './internal/content-core.js';
|
|
23
|
+
export { CDRO_ENVELOPE_FIELDS, cdroContentCore };
|
|
22
24
|
/**
|
|
23
25
|
* Compute an OID over an arbitrary canonical-compatible value.
|
|
24
26
|
*
|
|
@@ -38,58 +40,6 @@ export declare function oidOf(canonical: unknown): string;
|
|
|
38
40
|
* canonicalizing twice.
|
|
39
41
|
*/
|
|
40
42
|
export declare function oidOfCanonical(canonical: string | Uint8Array): string;
|
|
41
|
-
/**
|
|
42
|
-
* The detached-signature / envelope fields removed by `cdroContentCore`
|
|
43
|
-
* before hashing. This is the SINGLE NORMATIVE strip-set for the CDRO OID
|
|
44
|
-
* projection (ADR_019 decision 1); every other surface (GAP SDKs, the
|
|
45
|
-
* gateway signer, IMPLEMENTING.md) derives from THIS set, never re-lists it.
|
|
46
|
-
*
|
|
47
|
-
* The set is defined SEMANTICALLY: it is "every field produced BY the signer
|
|
48
|
-
* after canonicalization, plus the OID output itself." Concretely:
|
|
49
|
-
*
|
|
50
|
-
* oid — the projection OUTPUT (cannot be an input to itself).
|
|
51
|
-
* signature — legacy hybrid SignatureEnvelope (attaches after hash).
|
|
52
|
-
* ml_dsa_signature — detached PQ signature (attaches after hash).
|
|
53
|
-
* signature_key_id — signer-stamped key id (produced by the signer).
|
|
54
|
-
* signature_algorithm — signer-stamped alg id (produced by the signer).
|
|
55
|
-
* attestation — DSSE AttestationEnvelope (attaches after hash).
|
|
56
|
-
*
|
|
57
|
-
* EVERYTHING ELSE IS KEPT and hashed into the OID, including in particular:
|
|
58
|
-
* - `gap_version` — IN identity so a protocol downgrade is OID-detectable.
|
|
59
|
-
* - `supersedes` — IN identity because the SRAID Merkle-DAG head-proves-
|
|
60
|
-
* history property requires every lineage edge inside the
|
|
61
|
-
* hash. Superseding mints a NEW object; it never mutates
|
|
62
|
-
* the old one's bytes, so keeping it here is safe and
|
|
63
|
-
* makes the lineage edge tamper-evident.
|
|
64
|
-
* - `type`, `sraid_version`, `tenant_id`, `created_at_ms`, `created_by`,
|
|
65
|
-
* `body`, `authority`, `sensitivity`, `prev`, `links`, and any other
|
|
66
|
-
* content field.
|
|
67
|
-
*
|
|
68
|
-
* This is the ONE projection that yields the SAME OID whether the object is
|
|
69
|
-
* pre- or post-attestation: attaching an `attestation` (or `signature`,
|
|
70
|
-
* `ml_dsa_signature`, `signature_key_id`, `signature_algorithm`) after hashing
|
|
71
|
-
* is stripped back out here, so `cdroOid(obj)` is invariant across signing.
|
|
72
|
-
*
|
|
73
|
-
* It is FROZEN so no caller can mutate the normative set at runtime.
|
|
74
|
-
*/
|
|
75
|
-
export declare const CDRO_ENVELOPE_FIELDS: readonly string[];
|
|
76
|
-
/**
|
|
77
|
-
* Build the OID content core of a full CDRO: the object with EXACTLY the six
|
|
78
|
-
* detached-signature / envelope fields in `CDRO_ENVELOPE_FIELDS` removed at
|
|
79
|
-
* the top level, and everything else kept.
|
|
80
|
-
*
|
|
81
|
-
* This is the mechanism that makes the L4 `authority` block, the L3 lineage
|
|
82
|
-
* edges (`prev`, `links`, `supersedes`), the propagating `sensitivity` tier,
|
|
83
|
-
* and `gap_version` tamper-evident: they are hashed into identity by
|
|
84
|
-
* construction, so a field cannot be added, stripped, re-pointed, or
|
|
85
|
-
* downgraded without producing a different OID (and invalidating the
|
|
86
|
-
* signature, which is computed over these same bytes). Because `prev`/`links`/
|
|
87
|
-
* `supersedes` OIDs are inside the hash, a node's OID transitively commits its
|
|
88
|
-
* whole reachable history (the Merkle-DAG "head proves history" property).
|
|
89
|
-
*
|
|
90
|
-
* Returns a plain object suitable for `canonicalize` / `oidOf`.
|
|
91
|
-
*/
|
|
92
|
-
export declare function cdroContentCore(cdro: unknown): Record<string, unknown>;
|
|
93
43
|
/**
|
|
94
44
|
* Compute the OID of a full CDRO over its content core (see
|
|
95
45
|
* `cdroContentCore`). This is the correct way to derive identity for a
|
package/dist/oid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oid.d.ts","sourceRoot":"","sources":["../src/oid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"oid.d.ts","sourceRoot":"","sources":["../src/oid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AASlF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAGhD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAMrE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAE7C"}
|
package/dist/oid.js
CHANGED
|
@@ -21,6 +21,15 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { createHash } from 'node:crypto';
|
|
23
23
|
import { canonicalize } from './canonicalize.js';
|
|
24
|
+
import { CDRO_ENVELOPE_FIELDS, cdroContentCore } from './internal/content-core.js';
|
|
25
|
+
// The CDRO strip-set and its content-core projection are the SINGLE NORMATIVE
|
|
26
|
+
// SOURCE (ADR_019) and live in the PURE ./internal/content-core module (no
|
|
27
|
+
// node:crypto), so the browser verify surface can share them byte-for-byte.
|
|
28
|
+
// oid.ts re-exports them and layers the SHA-256 hashing (below) on top; this
|
|
29
|
+
// keeps the public surface (`import { cdroContentCore, CDRO_ENVELOPE_FIELDS }
|
|
30
|
+
// from '@synoi/sraid'`) unchanged. See ./internal/content-core.ts for the
|
|
31
|
+
// normative strip-set documentation; do not re-list it here.
|
|
32
|
+
export { CDRO_ENVELOPE_FIELDS, cdroContentCore };
|
|
24
33
|
/**
|
|
25
34
|
* Compute an OID over an arbitrary canonical-compatible value.
|
|
26
35
|
*
|
|
@@ -48,77 +57,6 @@ export function oidOfCanonical(canonical) {
|
|
|
48
57
|
: canonical;
|
|
49
58
|
return 'sha256:' + createHash('sha256').update(bytes).digest('hex');
|
|
50
59
|
}
|
|
51
|
-
/**
|
|
52
|
-
* The detached-signature / envelope fields removed by `cdroContentCore`
|
|
53
|
-
* before hashing. This is the SINGLE NORMATIVE strip-set for the CDRO OID
|
|
54
|
-
* projection (ADR_019 decision 1); every other surface (GAP SDKs, the
|
|
55
|
-
* gateway signer, IMPLEMENTING.md) derives from THIS set, never re-lists it.
|
|
56
|
-
*
|
|
57
|
-
* The set is defined SEMANTICALLY: it is "every field produced BY the signer
|
|
58
|
-
* after canonicalization, plus the OID output itself." Concretely:
|
|
59
|
-
*
|
|
60
|
-
* oid — the projection OUTPUT (cannot be an input to itself).
|
|
61
|
-
* signature — legacy hybrid SignatureEnvelope (attaches after hash).
|
|
62
|
-
* ml_dsa_signature — detached PQ signature (attaches after hash).
|
|
63
|
-
* signature_key_id — signer-stamped key id (produced by the signer).
|
|
64
|
-
* signature_algorithm — signer-stamped alg id (produced by the signer).
|
|
65
|
-
* attestation — DSSE AttestationEnvelope (attaches after hash).
|
|
66
|
-
*
|
|
67
|
-
* EVERYTHING ELSE IS KEPT and hashed into the OID, including in particular:
|
|
68
|
-
* - `gap_version` — IN identity so a protocol downgrade is OID-detectable.
|
|
69
|
-
* - `supersedes` — IN identity because the SRAID Merkle-DAG head-proves-
|
|
70
|
-
* history property requires every lineage edge inside the
|
|
71
|
-
* hash. Superseding mints a NEW object; it never mutates
|
|
72
|
-
* the old one's bytes, so keeping it here is safe and
|
|
73
|
-
* makes the lineage edge tamper-evident.
|
|
74
|
-
* - `type`, `sraid_version`, `tenant_id`, `created_at_ms`, `created_by`,
|
|
75
|
-
* `body`, `authority`, `sensitivity`, `prev`, `links`, and any other
|
|
76
|
-
* content field.
|
|
77
|
-
*
|
|
78
|
-
* This is the ONE projection that yields the SAME OID whether the object is
|
|
79
|
-
* pre- or post-attestation: attaching an `attestation` (or `signature`,
|
|
80
|
-
* `ml_dsa_signature`, `signature_key_id`, `signature_algorithm`) after hashing
|
|
81
|
-
* is stripped back out here, so `cdroOid(obj)` is invariant across signing.
|
|
82
|
-
*
|
|
83
|
-
* It is FROZEN so no caller can mutate the normative set at runtime.
|
|
84
|
-
*/
|
|
85
|
-
export const CDRO_ENVELOPE_FIELDS = Object.freeze([
|
|
86
|
-
'oid',
|
|
87
|
-
'signature',
|
|
88
|
-
'ml_dsa_signature',
|
|
89
|
-
'signature_key_id',
|
|
90
|
-
'signature_algorithm',
|
|
91
|
-
'attestation',
|
|
92
|
-
]);
|
|
93
|
-
const CDRO_ENVELOPE_FIELD_SET = new Set(CDRO_ENVELOPE_FIELDS);
|
|
94
|
-
/**
|
|
95
|
-
* Build the OID content core of a full CDRO: the object with EXACTLY the six
|
|
96
|
-
* detached-signature / envelope fields in `CDRO_ENVELOPE_FIELDS` removed at
|
|
97
|
-
* the top level, and everything else kept.
|
|
98
|
-
*
|
|
99
|
-
* This is the mechanism that makes the L4 `authority` block, the L3 lineage
|
|
100
|
-
* edges (`prev`, `links`, `supersedes`), the propagating `sensitivity` tier,
|
|
101
|
-
* and `gap_version` tamper-evident: they are hashed into identity by
|
|
102
|
-
* construction, so a field cannot be added, stripped, re-pointed, or
|
|
103
|
-
* downgraded without producing a different OID (and invalidating the
|
|
104
|
-
* signature, which is computed over these same bytes). Because `prev`/`links`/
|
|
105
|
-
* `supersedes` OIDs are inside the hash, a node's OID transitively commits its
|
|
106
|
-
* whole reachable history (the Merkle-DAG "head proves history" property).
|
|
107
|
-
*
|
|
108
|
-
* Returns a plain object suitable for `canonicalize` / `oidOf`.
|
|
109
|
-
*/
|
|
110
|
-
export function cdroContentCore(cdro) {
|
|
111
|
-
if (cdro === null || typeof cdro !== 'object' || Array.isArray(cdro)) {
|
|
112
|
-
throw new TypeError('cdroContentCore: argument must be a CDRO object');
|
|
113
|
-
}
|
|
114
|
-
const core = {};
|
|
115
|
-
for (const [k, v] of Object.entries(cdro)) {
|
|
116
|
-
if (CDRO_ENVELOPE_FIELD_SET.has(k))
|
|
117
|
-
continue;
|
|
118
|
-
core[k] = v;
|
|
119
|
-
}
|
|
120
|
-
return core;
|
|
121
|
-
}
|
|
122
60
|
/**
|
|
123
61
|
* Compute the OID of a full CDRO over its content core (see
|
|
124
62
|
* `cdroContentCore`). This is the correct way to derive identity for a
|
package/dist/oid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oid.js","sourceRoot":"","sources":["../src/oid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,KAAK,CAAC,SAAkB;IACtC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC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;IAC3D,MAAM,KAAK,GACT,OAAO,SAAS,KAAK,QAAQ;QAC3B,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,SAAS,CAAA;IACf,OAAO,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACrE,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAA;AACrC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -196,14 +196,15 @@ export interface AttestationEnvelope {
|
|
|
196
196
|
* CDRO — Canonical Data Record Object.
|
|
197
197
|
*
|
|
198
198
|
* The base shape every signed CDRO object takes. The `oid` field is
|
|
199
|
-
* `sha256:` + hex(sha256(canonicalize(
|
|
200
|
-
* minus the
|
|
199
|
+
* `sha256:` + hex(sha256(canonicalize(cdroContentCore(obj)))) — the WHOLE
|
|
200
|
+
* object minus the six detached envelope fields (`CDRO_ENVELOPE_FIELDS`).
|
|
201
|
+
* It is NOT a hash of `body` alone: use `cdroOid`, not `oidOf(cdro.body)`.
|
|
201
202
|
*
|
|
202
203
|
* Mirrors `GapCdroEnvelope` in synoi-gateway so a GAP object IS a CDRO.
|
|
203
204
|
* Higher-layer packages narrow `body` with their own type.
|
|
204
205
|
*/
|
|
205
206
|
export interface CDRO<TBody = unknown> {
|
|
206
|
-
/** "sha256:" + hex(sha256(canonicalize(
|
|
207
|
+
/** "sha256:" + hex(sha256(canonicalize(cdroContentCore(this)))). */
|
|
207
208
|
oid: string;
|
|
208
209
|
/** Object type discriminator (e.g. "gap:capability_grant"). */
|
|
209
210
|
type: string;
|
|
@@ -283,31 +284,4 @@ export interface CDRO<TBody = unknown> {
|
|
|
283
284
|
*/
|
|
284
285
|
signature?: SignatureEnvelope;
|
|
285
286
|
}
|
|
286
|
-
/**
|
|
287
|
-
* SRO — Mutation / Supersession Record.
|
|
288
|
-
*
|
|
289
|
-
* Links a successor CDRO to its predecessor and the actor that authorized
|
|
290
|
-
* the supersession. SROs are themselves CDRO objects (so they're CDROs with
|
|
291
|
-
* an `oid` and `signature`), but they have a specific body shape.
|
|
292
|
-
*
|
|
293
|
-
* Where CDROs are the "what" of the system, SROs are the "what changed."
|
|
294
|
-
* They form an append-only chain: every supersedes pointer in a CDRO is
|
|
295
|
-
* accompanied by an SRO that explains and witnesses the change.
|
|
296
|
-
*/
|
|
297
|
-
export interface SROBody {
|
|
298
|
-
/** OID of the predecessor object being superseded. */
|
|
299
|
-
predecessor_oid: string;
|
|
300
|
-
/** OID of the successor object that supersedes it. */
|
|
301
|
-
successor_oid: string;
|
|
302
|
-
/** Why the predecessor was superseded. Free-form short string. */
|
|
303
|
-
reason: string;
|
|
304
|
-
/** OID of the actor that authorized this mutation. */
|
|
305
|
-
authorized_by: string;
|
|
306
|
-
/** Optional list of supporting evidence OIDs (audit trail). */
|
|
307
|
-
evidence_oids?: string[];
|
|
308
|
-
}
|
|
309
|
-
/** SRO is just a CDRO with a fixed body type. */
|
|
310
|
-
export type SRO = CDRO<SROBody> & {
|
|
311
|
-
type: 'sraid:sro';
|
|
312
|
-
};
|
|
313
287
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,UAAU,GACV,QAAQ,CAAA;AAEZ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MA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change the OID.
|
|
14
14
|
*/
|
|
15
15
|
export {};
|
|
16
|
+
// ── Supersession ──────────────────────────────────────────────────────────────
|
|
17
|
+
//
|
|
18
|
+
// The standalone SRO (Supersession Record Object, `type: 'sraid:sro'`) was
|
|
19
|
+
// REMOVED in 0.4.0. It was the third of three overlapping supersession
|
|
20
|
+
// mechanisms and the only one nothing consumed: `lineage.ts` never handled it,
|
|
21
|
+
// no repo in the SynOI stack referenced it in any language, and the canon had
|
|
22
|
+
// already retired the term (ADR_022 section 0: "an earlier, retired
|
|
23
|
+
// object-format term").
|
|
24
|
+
//
|
|
25
|
+
// Supersession is now expressed by exactly two things, both identity-bound
|
|
26
|
+
// because `cdroContentCore` hashes them:
|
|
27
|
+
//
|
|
28
|
+
// prev / links[] the Merkle edges - a head OID commits its whole reachable
|
|
29
|
+
// history. Resolve a version set with `latestWins`.
|
|
30
|
+
// supersedes the legacy self-asserted string, kept for compatibility.
|
|
31
|
+
//
|
|
32
|
+
// A caller that needs to record WHY something was superseded should put that
|
|
33
|
+
// in the successor's own `body`, where it is hashed and signed, rather than in
|
|
34
|
+
// a separate object whose linkage was never verified.
|
|
16
35
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AAuTH,iFAAiF;AACjF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,+EAA+E;AAC/E,8EAA8E;AAC9E,oEAAoE;AACpE,wBAAwB;AACxB,EAAE;AACF,2EAA2E;AAC3E,yCAAyC;AACzC,EAAE;AACF,8EAA8E;AAC9E,sEAAsE;AACtE,6EAA6E;AAC7E,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,sDAAsD"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Style mirrors the hand-rolled validators in synoi-mcp-server (no zod,
|
|
12
12
|
* no heavy validation library) — kept tiny on purpose.
|
|
13
13
|
*/
|
|
14
|
-
import type { AttestationEnvelope, AttestationSignature, AuthorityBlock, CDRO, LineageLink, LinkRel, SignatureEnvelope
|
|
14
|
+
import type { AttestationEnvelope, AttestationSignature, AuthorityBlock, CDRO, LineageLink, LinkRel, SignatureEnvelope } from './types.js';
|
|
15
15
|
export interface ValidationResult {
|
|
16
16
|
ok: boolean;
|
|
17
17
|
errors: string[];
|
|
@@ -69,20 +69,5 @@ export declare function validateSignatureEnvelope(x: unknown): ValidationResult;
|
|
|
69
69
|
* entries.
|
|
70
70
|
*/
|
|
71
71
|
export declare function validateAttestationEnvelope(x: unknown): ValidationResult;
|
|
72
|
-
|
|
73
|
-
* Validate that `x` matches the SRO shape — a CDRO whose `type` is
|
|
74
|
-
* "sraid:sro" and whose `body` carries predecessor/successor pointers and
|
|
75
|
-
* an authorizer. Reuses validateCdro and layers SRO-specific checks on
|
|
76
|
-
* top.
|
|
77
|
-
*
|
|
78
|
-
* [S01] envelope is not a valid CDRO
|
|
79
|
-
* [S02] type is not "sraid:sro"
|
|
80
|
-
* [S03] body.predecessor_oid not a canonical OID (sha256:<64 hex>)
|
|
81
|
-
* [S04] body.successor_oid not a canonical OID (sha256:<64 hex>)
|
|
82
|
-
* [S05] body.reason not a non-empty string
|
|
83
|
-
* [S06] body.authorized_by not a non-empty string
|
|
84
|
-
* [S07] body.evidence_oids, if present, not an array of non-empty strings
|
|
85
|
-
*/
|
|
86
|
-
export declare function validateSro(x: unknown): ValidationResult;
|
|
87
|
-
export type { AttestationEnvelope, AttestationSignature, AuthorityBlock, CDRO, LineageLink, LinkRel, SRO, SignatureEnvelope, };
|
|
72
|
+
export type { AttestationEnvelope, AttestationSignature, AuthorityBlock, CDRO, LineageLink, LinkRel, SignatureEnvelope, };
|
|
88
73
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,IAAI,EACJ,WAAW,EACX,OAAO,EACP,iBAAiB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,IAAI,EACJ,WAAW,EACX,OAAO,EACP,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAkBnB,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAID;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAmFzD;AAID;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAGnE;AA0CD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAGhE;AA+BD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAGtE;AAsBD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAGxE;AAyCD,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,IAAI,EACJ,WAAW,EACX,OAAO,EACP,iBAAiB,GAClB,CAAA"}
|