1id 0.5.0 → 0.7.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/dist/auth.d.ts +21 -13
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +126 -19
- package/dist/auth.js.map +1 -1
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -0
- package/dist/client.js.map +1 -1
- package/dist/credentials.d.ts +2 -0
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +4 -0
- package/dist/credentials.js.map +1 -1
- package/dist/devices.d.ts +76 -0
- package/dist/devices.d.ts.map +1 -0
- package/dist/devices.js +103 -0
- package/dist/devices.js.map +1 -0
- package/dist/exceptions.d.ts +14 -0
- package/dist/exceptions.d.ts.map +1 -1
- package/dist/exceptions.js +19 -0
- package/dist/exceptions.js.map +1 -1
- package/dist/index.d.ts +43 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -4
- package/dist/index.js.map +1 -1
- package/dist/test/test_peer_verification.d.ts +15 -0
- package/dist/test/test_peer_verification.d.ts.map +1 -0
- package/dist/test/test_peer_verification.js +481 -0
- package/dist/test/test_peer_verification.js.map +1 -0
- package/dist/trustRoots.d.ts +38 -0
- package/dist/trustRoots.d.ts.map +1 -0
- package/dist/trustRoots.js +145 -0
- package/dist/trustRoots.js.map +1 -0
- package/dist/verify.d.ts +71 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +315 -0
- package/dist/verify.js.map +1 -0
- package/dist/world.d.ts +83 -0
- package/dist/world.d.ts.map +1 -0
- package/dist/world.js +122 -0
- package/dist/world.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1id Trust Root Certificate Cache
|
|
3
|
+
*
|
|
4
|
+
* Manages the local cache of 1ID CA root certificates used for offline
|
|
5
|
+
* peer identity verification. The verifier never needs to contact 1ID
|
|
6
|
+
* during verification -- only to refresh the root cache.
|
|
7
|
+
*
|
|
8
|
+
* Cache lifecycle:
|
|
9
|
+
* 1. First call to get_trust_roots() auto-fetches from /api/v1/trust/roots
|
|
10
|
+
* 2. Roots are cached on disk (alongside credentials.json)
|
|
11
|
+
* 3. Subsequent calls use the cache (no network)
|
|
12
|
+
* 4. refresh_trust_roots() explicitly refetches and updates the cache
|
|
13
|
+
* 5. Cache has no expiry -- roots are long-lived (30+ years)
|
|
14
|
+
*/
|
|
15
|
+
import * as crypto from "node:crypto";
|
|
16
|
+
import * as fs from "node:fs";
|
|
17
|
+
import * as https from "node:https";
|
|
18
|
+
import * as http from "node:http";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
import { get_credentials_directory } from "./credentials.js";
|
|
21
|
+
const TRUST_ROOTS_CACHE_FILENAME = "trust-roots.pem";
|
|
22
|
+
const TRUST_ROOTS_API_PATH = "/api/v1/trust/roots";
|
|
23
|
+
const DEFAULT_API_BASE_URL = "https://1id.com";
|
|
24
|
+
const FETCH_TIMEOUT_MILLISECONDS = 15_000;
|
|
25
|
+
let cached_root_certificates = null;
|
|
26
|
+
let cached_root_pem = null;
|
|
27
|
+
function get_trust_roots_cache_path() {
|
|
28
|
+
return path.join(get_credentials_directory(), TRUST_ROOTS_CACHE_FILENAME);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Split a PEM bundle into individual X509Certificate objects.
|
|
32
|
+
*/
|
|
33
|
+
export function parse_pem_bundle_into_certificates(pem_bundle) {
|
|
34
|
+
const certificates = [];
|
|
35
|
+
const pem_regex = /-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g;
|
|
36
|
+
let match;
|
|
37
|
+
while ((match = pem_regex.exec(pem_bundle)) !== null) {
|
|
38
|
+
try {
|
|
39
|
+
certificates.push(new crypto.X509Certificate(match[0]));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// skip unparseable blocks
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return certificates;
|
|
46
|
+
}
|
|
47
|
+
function load_from_cache() {
|
|
48
|
+
const cache_path = get_trust_roots_cache_path();
|
|
49
|
+
try {
|
|
50
|
+
if (fs.existsSync(cache_path)) {
|
|
51
|
+
const content = fs.readFileSync(cache_path, "utf-8");
|
|
52
|
+
if (content.trim()) {
|
|
53
|
+
return content;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// cache miss
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function save_to_cache(pem_bundle) {
|
|
63
|
+
const cache_path = get_trust_roots_cache_path();
|
|
64
|
+
try {
|
|
65
|
+
fs.mkdirSync(path.dirname(cache_path), { recursive: true });
|
|
66
|
+
fs.writeFileSync(cache_path, pem_bundle, "utf-8");
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// best-effort
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function fetch_from_server(api_base_url) {
|
|
73
|
+
const base_url = api_base_url ?? DEFAULT_API_BASE_URL;
|
|
74
|
+
const url = new URL(TRUST_ROOTS_API_PATH, base_url);
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const transport_module = url.protocol === "https:" ? https : http;
|
|
77
|
+
const request = transport_module.get(url, { timeout: FETCH_TIMEOUT_MILLISECONDS }, (response) => {
|
|
78
|
+
if (response.statusCode !== 200) {
|
|
79
|
+
reject(new Error(`Trust roots fetch failed: HTTP ${response.statusCode}`));
|
|
80
|
+
response.resume();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const chunks = [];
|
|
84
|
+
response.on("data", (chunk) => chunks.push(chunk));
|
|
85
|
+
response.on("end", () => {
|
|
86
|
+
const pem_bundle = Buffer.concat(chunks).toString("utf-8");
|
|
87
|
+
if (!pem_bundle.includes("-----BEGIN CERTIFICATE-----")) {
|
|
88
|
+
reject(new Error("Server returned invalid trust roots (no PEM certificates found)"));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
resolve(pem_bundle);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
request.on("error", reject);
|
|
95
|
+
request.on("timeout", () => {
|
|
96
|
+
request.destroy();
|
|
97
|
+
reject(new Error("Trust roots fetch timed out"));
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Fetch current 1ID root certificates from the server and update the local cache.
|
|
103
|
+
*
|
|
104
|
+
* Called automatically on first use of verify_peer_identity(). Can also be
|
|
105
|
+
* called manually to force a refresh.
|
|
106
|
+
*/
|
|
107
|
+
export async function refresh_trust_roots(api_base_url) {
|
|
108
|
+
const pem_bundle = await fetch_from_server(api_base_url);
|
|
109
|
+
const certificates = parse_pem_bundle_into_certificates(pem_bundle);
|
|
110
|
+
if (certificates.length === 0) {
|
|
111
|
+
throw new Error("Trust roots PEM bundle contains no parseable certificates");
|
|
112
|
+
}
|
|
113
|
+
save_to_cache(pem_bundle);
|
|
114
|
+
cached_root_pem = pem_bundle;
|
|
115
|
+
cached_root_certificates = certificates;
|
|
116
|
+
return certificates;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the locally cached 1ID root certificates.
|
|
120
|
+
*
|
|
121
|
+
* If no cache exists, auto-fetches from the server (one-time).
|
|
122
|
+
* Subsequent calls return from the local cache (no network).
|
|
123
|
+
*/
|
|
124
|
+
export async function get_trust_roots(api_base_url) {
|
|
125
|
+
if (cached_root_certificates !== null) {
|
|
126
|
+
return cached_root_certificates;
|
|
127
|
+
}
|
|
128
|
+
const cached_pem = load_from_cache();
|
|
129
|
+
if (cached_pem) {
|
|
130
|
+
const certificates = parse_pem_bundle_into_certificates(cached_pem);
|
|
131
|
+
if (certificates.length > 0) {
|
|
132
|
+
cached_root_pem = cached_pem;
|
|
133
|
+
cached_root_certificates = certificates;
|
|
134
|
+
return certificates;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return refresh_trust_roots(api_base_url);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Return the raw PEM bundle of cached trust roots, or null if not loaded.
|
|
141
|
+
*/
|
|
142
|
+
export function get_trust_roots_pem() {
|
|
143
|
+
return cached_root_pem;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=trustRoots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trustRoots.js","sourceRoot":"","sources":["../src/trustRoots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AACrD,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AACnD,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAC/C,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,IAAI,wBAAwB,GAAoC,IAAI,CAAC;AACrE,IAAI,eAAe,GAAkB,IAAI,CAAC;AAE1C,SAAS,0BAA0B;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,0BAA0B,CAAC,CAAC;AAC5E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kCAAkC,CAAC,UAAkB;IACnE,MAAM,YAAY,GAA6B,EAAE,CAAC;IAClD,MAAM,SAAS,GAAG,+DAA+D,CAAC;IAClF,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,IAAI,EAAE,CAA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ACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,YAAqB;IAC7D,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAEpE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IAED,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1B,eAAe,GAAG,UAAU,CAAC;IAC7B,wBAAwB,GAAG,YAAY,CAAC;IAExC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,YAAqB;IACzD,IAAI,wBAAwB,KAAK,IAAI,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;IACrC,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,kCAAkC,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,eAAe,GAAG,UAAU,CAAC;YAC7B,wBAAwB,GAAG,YAAY,CAAC;YACxC,OAAO,YAAY,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1id Peer Identity Verification
|
|
3
|
+
*
|
|
4
|
+
* Assembles and validates proof bundles for offline, privacy-preserving
|
|
5
|
+
* agent-to-agent identity verification.
|
|
6
|
+
*
|
|
7
|
+
* Protocol:
|
|
8
|
+
* 1. Verifier generates a random nonce (32+ bytes)
|
|
9
|
+
* 2. Agent calls signChallenge(nonce) -> IdentityProofBundle
|
|
10
|
+
* 3. Verifier calls verifyPeerIdentity(nonce, bundle)
|
|
11
|
+
* -> VerifiedPeerIdentity
|
|
12
|
+
*
|
|
13
|
+
* No secrets are exchanged. The verifier never contacts 1ID. Once the
|
|
14
|
+
* trust root is cached locally, verification is entirely offline.
|
|
15
|
+
*/
|
|
16
|
+
import { OneIDError } from "./exceptions.js";
|
|
17
|
+
export declare class PeerVerificationError extends OneIDError {
|
|
18
|
+
constructor(message: string, error_code?: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class CertificateChainValidationError extends PeerVerificationError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class SignatureVerificationError extends PeerVerificationError {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class MissingIdentityCertificateError extends PeerVerificationError {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
export interface IdentityProofBundle {
|
|
30
|
+
signature_b64: string;
|
|
31
|
+
certificate_chain_pem: string;
|
|
32
|
+
agent_id: string;
|
|
33
|
+
trust_tier: string;
|
|
34
|
+
algorithm: string;
|
|
35
|
+
}
|
|
36
|
+
export interface VerifiedPeerIdentity {
|
|
37
|
+
agent_id: string;
|
|
38
|
+
trust_tier: string;
|
|
39
|
+
enrolled_at: string;
|
|
40
|
+
hardware_locked: boolean;
|
|
41
|
+
chain_valid: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Sign a verifier-provided nonce and assemble a proof bundle.
|
|
45
|
+
*
|
|
46
|
+
* Dispatches to the appropriate signing mechanism based on trust tier:
|
|
47
|
+
* - sovereign (TPM): delegates to oneid-enroll sign
|
|
48
|
+
* - portable (YubiKey): delegates to oneid-enroll piv-sign
|
|
49
|
+
* - declared (software): signs with local private key
|
|
50
|
+
*
|
|
51
|
+
* @param nonce_bytes Raw bytes of the verifier-generated nonce.
|
|
52
|
+
* @returns IdentityProofBundle ready to send to the verifier.
|
|
53
|
+
*/
|
|
54
|
+
export declare function signChallenge(nonce_bytes: Buffer): Promise<IdentityProofBundle>;
|
|
55
|
+
/**
|
|
56
|
+
* Validate another agent's proof bundle. Entirely offline after first trust root fetch.
|
|
57
|
+
*
|
|
58
|
+
* Steps:
|
|
59
|
+
* 1. Parse the certificate chain from the proof bundle
|
|
60
|
+
* 2. Validate the chain (each cert signed by its parent)
|
|
61
|
+
* 3. Verify the chain terminates at a locally cached 1ID root
|
|
62
|
+
* 4. Verify the nonce signature against the leaf certificate's public key
|
|
63
|
+
* 5. Extract identity claims from the leaf cert extensions
|
|
64
|
+
*
|
|
65
|
+
* @param nonce_bytes The original nonce bytes that the prover was asked to sign.
|
|
66
|
+
* @param proof_bundle The IdentityProofBundle from the prover.
|
|
67
|
+
* @param api_base_url Override for trust root server URL (only on first call if no cache).
|
|
68
|
+
* @returns VerifiedPeerIdentity with verified agent_id, trust_tier, etc.
|
|
69
|
+
*/
|
|
70
|
+
export declare function verifyPeerIdentity(nonce_bytes: Buffer, proof_bundle: IdentityProofBundle, api_base_url?: string): Promise<VerifiedPeerIdentity>;
|
|
71
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAoB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ/D,qBAAa,qBAAsB,SAAQ,UAAU;gBACvC,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,MAAkC;CAI5E;AAED,qBAAa,+BAAgC,SAAQ,qBAAqB;gBAC5D,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,0BAA2B,SAAQ,qBAAqB;gBACvD,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,+BAAgC,SAAQ,qBAAqB;gBAC5D,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB;AA+BD;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA0CrF;AAwJD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,mBAAmB,EACjC,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC,CAsD/B"}
|
package/dist/verify.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1id Peer Identity Verification
|
|
3
|
+
*
|
|
4
|
+
* Assembles and validates proof bundles for offline, privacy-preserving
|
|
5
|
+
* agent-to-agent identity verification.
|
|
6
|
+
*
|
|
7
|
+
* Protocol:
|
|
8
|
+
* 1. Verifier generates a random nonce (32+ bytes)
|
|
9
|
+
* 2. Agent calls signChallenge(nonce) -> IdentityProofBundle
|
|
10
|
+
* 3. Verifier calls verifyPeerIdentity(nonce, bundle)
|
|
11
|
+
* -> VerifiedPeerIdentity
|
|
12
|
+
*
|
|
13
|
+
* No secrets are exchanged. The verifier never contacts 1ID. Once the
|
|
14
|
+
* trust root is cached locally, verification is entirely offline.
|
|
15
|
+
*/
|
|
16
|
+
import * as crypto from "node:crypto";
|
|
17
|
+
import { load_credentials } from "./credentials.js";
|
|
18
|
+
import { NotEnrolledError, OneIDError } from "./exceptions.js";
|
|
19
|
+
import { sign_challenge_with_private_key } from "./keys.js";
|
|
20
|
+
import { get_trust_roots, parse_pem_bundle_into_certificates } from "./trustRoots.js";
|
|
21
|
+
const ONEID_OID_TRUST_TIER = "1.3.6.1.4.1.59999.1.1";
|
|
22
|
+
const ONEID_OID_ENROLLED_AT = "1.3.6.1.4.1.59999.1.2";
|
|
23
|
+
const ONEID_OID_HARDWARE_LOCKED = "1.3.6.1.4.1.59999.1.3";
|
|
24
|
+
export class PeerVerificationError extends OneIDError {
|
|
25
|
+
constructor(message, error_code = "PEER_VERIFICATION_ERROR") {
|
|
26
|
+
super(message, error_code);
|
|
27
|
+
this.name = "PeerVerificationError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class CertificateChainValidationError extends PeerVerificationError {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message, "CERTIFICATE_CHAIN_VALIDATION_ERROR");
|
|
33
|
+
this.name = "CertificateChainValidationError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class SignatureVerificationError extends PeerVerificationError {
|
|
37
|
+
constructor(message) {
|
|
38
|
+
super(message, "SIGNATURE_VERIFICATION_ERROR");
|
|
39
|
+
this.name = "SignatureVerificationError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class MissingIdentityCertificateError extends PeerVerificationError {
|
|
43
|
+
constructor(message) {
|
|
44
|
+
super(message, "MISSING_IDENTITY_CERTIFICATE");
|
|
45
|
+
this.name = "MissingIdentityCertificateError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function determine_signing_algorithm_name(creds) {
|
|
49
|
+
const algo = (creds.key_algorithm ?? "").toLowerCase();
|
|
50
|
+
if (algo.includes("ed25519")) {
|
|
51
|
+
return "EdDSA";
|
|
52
|
+
}
|
|
53
|
+
if (algo.includes("p-384") || algo.includes("p384") || algo.includes("ecdsa-p384")) {
|
|
54
|
+
return "ES384";
|
|
55
|
+
}
|
|
56
|
+
if (algo.includes("p-256") || algo.includes("p256") || algo.includes("ecdsa") || algo.includes("piv")) {
|
|
57
|
+
return "ES256";
|
|
58
|
+
}
|
|
59
|
+
if (algo.includes("rsa") || algo.includes("tpm-ak")) {
|
|
60
|
+
return "RS256";
|
|
61
|
+
}
|
|
62
|
+
return "RS256";
|
|
63
|
+
}
|
|
64
|
+
async function sign_with_tpm(nonce_bytes, ak_handle) {
|
|
65
|
+
const { sign_challenge_with_tpm } = await import("./helper.js");
|
|
66
|
+
const nonce_b64 = nonce_bytes.toString("base64");
|
|
67
|
+
const result = await sign_challenge_with_tpm(nonce_b64, ak_handle);
|
|
68
|
+
const signature_b64 = result["signature_b64"] ?? "";
|
|
69
|
+
const algorithm_raw = result["algorithm"] ?? "RSASSA-SHA256";
|
|
70
|
+
const algorithm = algorithm_raw.toUpperCase().includes("RSA") ? "RS256" : algorithm_raw;
|
|
71
|
+
return { signature_bytes: Buffer.from(signature_b64, "base64"), algorithm };
|
|
72
|
+
}
|
|
73
|
+
async function sign_with_piv(nonce_bytes) {
|
|
74
|
+
const { sign_challenge_with_piv } = await import("./helper.js");
|
|
75
|
+
const nonce_b64 = nonce_bytes.toString("base64");
|
|
76
|
+
const result = await sign_challenge_with_piv(nonce_b64);
|
|
77
|
+
const signature_b64 = result["signature_b64"] ?? "";
|
|
78
|
+
const algorithm_raw = result["algorithm"] ?? "ECDSA-SHA256";
|
|
79
|
+
const algorithm = algorithm_raw.toUpperCase().includes("ECDSA") ? "ES256" : algorithm_raw;
|
|
80
|
+
return { signature_bytes: Buffer.from(signature_b64, "base64"), algorithm };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Sign a verifier-provided nonce and assemble a proof bundle.
|
|
84
|
+
*
|
|
85
|
+
* Dispatches to the appropriate signing mechanism based on trust tier:
|
|
86
|
+
* - sovereign (TPM): delegates to oneid-enroll sign
|
|
87
|
+
* - portable (YubiKey): delegates to oneid-enroll piv-sign
|
|
88
|
+
* - declared (software): signs with local private key
|
|
89
|
+
*
|
|
90
|
+
* @param nonce_bytes Raw bytes of the verifier-generated nonce.
|
|
91
|
+
* @returns IdentityProofBundle ready to send to the verifier.
|
|
92
|
+
*/
|
|
93
|
+
export async function signChallenge(nonce_bytes) {
|
|
94
|
+
const creds = load_credentials();
|
|
95
|
+
if (!creds.identity_certificate_chain_pem) {
|
|
96
|
+
throw new MissingIdentityCertificateError("No identity certificate chain found in credentials. " +
|
|
97
|
+
"This agent was enrolled before certificate issuance was available. " +
|
|
98
|
+
"Re-enroll or recover your identity to obtain a certificate.");
|
|
99
|
+
}
|
|
100
|
+
const trust_tier = creds.trust_tier ?? "declared";
|
|
101
|
+
const agent_id = creds.client_id;
|
|
102
|
+
let signature_bytes;
|
|
103
|
+
let algorithm;
|
|
104
|
+
if (trust_tier === "sovereign" || trust_tier === "virtual" || creds.key_algorithm === "tpm-ak") {
|
|
105
|
+
const ak_handle = creds.hsm_key_reference ?? "";
|
|
106
|
+
const result = await sign_with_tpm(nonce_bytes, ak_handle);
|
|
107
|
+
signature_bytes = result.signature_bytes;
|
|
108
|
+
algorithm = result.algorithm;
|
|
109
|
+
}
|
|
110
|
+
else if (trust_tier === "portable" || creds.hsm_key_reference === "piv-slot-9a") {
|
|
111
|
+
const result = await sign_with_piv(nonce_bytes);
|
|
112
|
+
signature_bytes = result.signature_bytes;
|
|
113
|
+
algorithm = result.algorithm;
|
|
114
|
+
}
|
|
115
|
+
else if (creds.private_key_pem) {
|
|
116
|
+
signature_bytes = sign_challenge_with_private_key(creds.private_key_pem, nonce_bytes);
|
|
117
|
+
algorithm = determine_signing_algorithm_name(creds);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new NotEnrolledError("Cannot sign challenge: no signing key available. " +
|
|
121
|
+
"Credentials exist but contain neither a private key nor an HSM reference.");
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
signature_b64: signature_bytes.toString("base64"),
|
|
125
|
+
certificate_chain_pem: creds.identity_certificate_chain_pem,
|
|
126
|
+
agent_id,
|
|
127
|
+
trust_tier,
|
|
128
|
+
algorithm,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Extract the value of a custom extension by OID from a certificate.
|
|
133
|
+
* Node.js X509Certificate doesn't expose arbitrary extensions directly,
|
|
134
|
+
* so we parse the raw DER to find it.
|
|
135
|
+
*/
|
|
136
|
+
function extract_custom_extension_value_from_raw_der(cert, target_oid) {
|
|
137
|
+
const info_access = cert.infoAccess;
|
|
138
|
+
// Node.js X509Certificate doesn't expose custom OIDs through its API.
|
|
139
|
+
// We look for the OID in the raw DER data as a fallback.
|
|
140
|
+
const raw = cert.raw;
|
|
141
|
+
const oid_parts = target_oid.split(".").map(Number);
|
|
142
|
+
// Encode the OID in DER format for searching
|
|
143
|
+
const encoded_oid_bytes = [];
|
|
144
|
+
encoded_oid_bytes.push(40 * oid_parts[0] + oid_parts[1]);
|
|
145
|
+
for (let i = 2; i < oid_parts.length; i++) {
|
|
146
|
+
let value = oid_parts[i];
|
|
147
|
+
if (value < 128) {
|
|
148
|
+
encoded_oid_bytes.push(value);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const temp = [];
|
|
152
|
+
temp.push(value & 0x7f);
|
|
153
|
+
value >>= 7;
|
|
154
|
+
while (value > 0) {
|
|
155
|
+
temp.push((value & 0x7f) | 0x80);
|
|
156
|
+
value >>= 7;
|
|
157
|
+
}
|
|
158
|
+
temp.reverse();
|
|
159
|
+
encoded_oid_bytes.push(...temp);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const oid_buffer = Buffer.from(encoded_oid_bytes);
|
|
163
|
+
// Search for the OID in the raw DER
|
|
164
|
+
let search_offset = 0;
|
|
165
|
+
while (search_offset < raw.length - oid_buffer.length) {
|
|
166
|
+
const found_at = raw.indexOf(oid_buffer, search_offset);
|
|
167
|
+
if (found_at === -1) {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
// The extension value follows: OID -> critical flag -> OCTET STRING wrapping the value
|
|
171
|
+
// Walk past the OID to find the OCTET STRING (tag 0x04) containing the value
|
|
172
|
+
let pos = found_at + oid_buffer.length;
|
|
173
|
+
// Skip past remaining TLV structures until we find the OCTET STRING
|
|
174
|
+
let depth = 0;
|
|
175
|
+
while (pos < raw.length && depth < 20) {
|
|
176
|
+
const tag = raw[pos];
|
|
177
|
+
if (tag === 0x04) { // OCTET STRING
|
|
178
|
+
pos++;
|
|
179
|
+
let octet_length = raw[pos];
|
|
180
|
+
pos++;
|
|
181
|
+
if (octet_length > 127) {
|
|
182
|
+
const num_length_bytes = octet_length & 0x7f;
|
|
183
|
+
octet_length = 0;
|
|
184
|
+
for (let j = 0; j < num_length_bytes; j++) {
|
|
185
|
+
octet_length = (octet_length << 8) | raw[pos];
|
|
186
|
+
pos++;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return raw.subarray(pos, pos + octet_length);
|
|
190
|
+
}
|
|
191
|
+
// Skip this TLV
|
|
192
|
+
pos++;
|
|
193
|
+
if (pos >= raw.length) {
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
let skip_length = raw[pos];
|
|
197
|
+
pos++;
|
|
198
|
+
if (skip_length > 127) {
|
|
199
|
+
const num_bytes = skip_length & 0x7f;
|
|
200
|
+
skip_length = 0;
|
|
201
|
+
for (let j = 0; j < num_bytes; j++) {
|
|
202
|
+
skip_length = (skip_length << 8) | raw[pos];
|
|
203
|
+
pos++;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
pos += skip_length;
|
|
207
|
+
depth++;
|
|
208
|
+
}
|
|
209
|
+
search_offset = found_at + 1;
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
function verify_certificate_chain_signatures(chain) {
|
|
214
|
+
for (let i = 0; i < chain.length - 1; i++) {
|
|
215
|
+
const child = chain[i];
|
|
216
|
+
const parent = chain[i + 1];
|
|
217
|
+
if (!child.checkIssued(parent)) {
|
|
218
|
+
throw new CertificateChainValidationError(`Certificate at position ${i} is not issued by certificate at position ${i + 1}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function verify_chain_terminates_at_trusted_root(chain, trusted_roots) {
|
|
223
|
+
if (chain.length === 0) {
|
|
224
|
+
throw new CertificateChainValidationError("Certificate chain is empty");
|
|
225
|
+
}
|
|
226
|
+
const chain_root = chain[chain.length - 1];
|
|
227
|
+
const chain_root_fingerprint = chain_root.fingerprint256;
|
|
228
|
+
const root_is_trusted = trusted_roots.some((root) => root.fingerprint256 === chain_root_fingerprint);
|
|
229
|
+
if (!root_is_trusted) {
|
|
230
|
+
throw new CertificateChainValidationError(`Chain root '${chain_root.subject}' is not in the set of trusted 1ID roots`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function verify_nonce_signature(nonce_bytes, signature_bytes, leaf_cert) {
|
|
234
|
+
const public_key = leaf_cert.publicKey;
|
|
235
|
+
const key_type = public_key.asymmetricKeyType;
|
|
236
|
+
let signature_is_valid = false;
|
|
237
|
+
if (key_type === "ed25519") {
|
|
238
|
+
signature_is_valid = crypto.verify(null, nonce_bytes, public_key, signature_bytes);
|
|
239
|
+
}
|
|
240
|
+
else if (key_type === "ec") {
|
|
241
|
+
const curve_name = public_key.asymmetricKeyDetails?.namedCurve;
|
|
242
|
+
const hash_algorithm = curve_name === "P-384" ? "sha384" : "sha256";
|
|
243
|
+
signature_is_valid = crypto.verify(hash_algorithm, nonce_bytes, public_key, signature_bytes);
|
|
244
|
+
}
|
|
245
|
+
else if (key_type === "rsa") {
|
|
246
|
+
signature_is_valid = crypto.verify("sha256", nonce_bytes, {
|
|
247
|
+
key: public_key,
|
|
248
|
+
padding: crypto.constants.RSA_PKCS1_PADDING,
|
|
249
|
+
}, signature_bytes);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
throw new SignatureVerificationError(`Unsupported public key type: ${key_type}`);
|
|
253
|
+
}
|
|
254
|
+
if (!signature_is_valid) {
|
|
255
|
+
throw new SignatureVerificationError("Nonce signature does not match the leaf certificate's public key");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Validate another agent's proof bundle. Entirely offline after first trust root fetch.
|
|
260
|
+
*
|
|
261
|
+
* Steps:
|
|
262
|
+
* 1. Parse the certificate chain from the proof bundle
|
|
263
|
+
* 2. Validate the chain (each cert signed by its parent)
|
|
264
|
+
* 3. Verify the chain terminates at a locally cached 1ID root
|
|
265
|
+
* 4. Verify the nonce signature against the leaf certificate's public key
|
|
266
|
+
* 5. Extract identity claims from the leaf cert extensions
|
|
267
|
+
*
|
|
268
|
+
* @param nonce_bytes The original nonce bytes that the prover was asked to sign.
|
|
269
|
+
* @param proof_bundle The IdentityProofBundle from the prover.
|
|
270
|
+
* @param api_base_url Override for trust root server URL (only on first call if no cache).
|
|
271
|
+
* @returns VerifiedPeerIdentity with verified agent_id, trust_tier, etc.
|
|
272
|
+
*/
|
|
273
|
+
export async function verifyPeerIdentity(nonce_bytes, proof_bundle, api_base_url) {
|
|
274
|
+
const chain = parse_pem_bundle_into_certificates(proof_bundle.certificate_chain_pem);
|
|
275
|
+
if (chain.length === 0) {
|
|
276
|
+
throw new CertificateChainValidationError("Proof bundle contains no parseable certificates");
|
|
277
|
+
}
|
|
278
|
+
const trusted_roots = await get_trust_roots(api_base_url);
|
|
279
|
+
verify_certificate_chain_signatures(chain);
|
|
280
|
+
verify_chain_terminates_at_trusted_root(chain, trusted_roots);
|
|
281
|
+
const leaf_cert = chain[0];
|
|
282
|
+
const now = new Date();
|
|
283
|
+
const not_before = new Date(leaf_cert.validFrom);
|
|
284
|
+
const not_after = new Date(leaf_cert.validTo);
|
|
285
|
+
if (not_before > now) {
|
|
286
|
+
throw new CertificateChainValidationError(`Leaf certificate is not yet valid (not_before: ${leaf_cert.validFrom})`);
|
|
287
|
+
}
|
|
288
|
+
if (not_after < now) {
|
|
289
|
+
throw new CertificateChainValidationError(`Leaf certificate has expired (not_after: ${leaf_cert.validTo})`);
|
|
290
|
+
}
|
|
291
|
+
const signature_bytes = Buffer.from(proof_bundle.signature_b64, "base64");
|
|
292
|
+
verify_nonce_signature(nonce_bytes, signature_bytes, leaf_cert);
|
|
293
|
+
// Extract custom extensions from the leaf certificate
|
|
294
|
+
const trust_tier_raw = extract_custom_extension_value_from_raw_der(leaf_cert, ONEID_OID_TRUST_TIER);
|
|
295
|
+
const enrolled_at_raw = extract_custom_extension_value_from_raw_der(leaf_cert, ONEID_OID_ENROLLED_AT);
|
|
296
|
+
const hardware_locked_raw = extract_custom_extension_value_from_raw_der(leaf_cert, ONEID_OID_HARDWARE_LOCKED);
|
|
297
|
+
const verified_trust_tier = trust_tier_raw ? trust_tier_raw.toString("utf-8") : proof_bundle.trust_tier;
|
|
298
|
+
const verified_enrolled_at = enrolled_at_raw ? enrolled_at_raw.toString("utf-8") : "";
|
|
299
|
+
const verified_hardware_locked = hardware_locked_raw ? hardware_locked_raw[0] === 0x01 : false;
|
|
300
|
+
// Try to extract agent_id from SAN URI
|
|
301
|
+
let verified_agent_id = proof_bundle.agent_id;
|
|
302
|
+
const san_string = leaf_cert.subjectAltName ?? "";
|
|
303
|
+
const uri_match = san_string.match(/URI:urn:oneid:agent:([^\s,]+)/);
|
|
304
|
+
if (uri_match) {
|
|
305
|
+
verified_agent_id = uri_match[1];
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
agent_id: verified_agent_id,
|
|
309
|
+
trust_tier: verified_trust_tier,
|
|
310
|
+
enrolled_at: verified_enrolled_at,
|
|
311
|
+
hardware_locked: verified_hardware_locked,
|
|
312
|
+
chain_valid: true,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/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M,eAAe,GAAG,2CAA2C,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IACtG,MAAM,mBAAmB,GAAG,2CAA2C,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;IAE9G,MAAM,mBAAmB,GAAG,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC;IACxG,MAAM,oBAAoB,GAAG,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAE/F,uCAAuC;IACvC,IAAI,iBAAiB,GAAG,YAAY,CAAC,QAAQ,CAAC;IAC9C,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,IAAI,EAAE,CAAC;IAClD,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACpE,IAAI,SAAS,EAAE,CAAC;QACd,iBAAiB,GAAG,SAAS,CAAC,CAAC,CAAE,CAAC;IACpC,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,iBAAiB;QAC3B,UAAU,EAAE,mBAAmB;QAC/B,WAAW,EAAE,oBAAoB;QACjC,eAAe,EAAE,wBAAwB;QACzC,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
package/dist/world.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* World/status endpoint for the 1id.com Node.js SDK.
|
|
3
|
+
*
|
|
4
|
+
* Fetches the full identity state from the server's world endpoint:
|
|
5
|
+
* identity, devices, connected services, available services, and operator guidance.
|
|
6
|
+
*
|
|
7
|
+
* Results are cached for 5 minutes. Call invalidate_world_cache() to force a fresh fetch.
|
|
8
|
+
*/
|
|
9
|
+
import { type StoredCredentials } from "./credentials.js";
|
|
10
|
+
export interface WorldIdentitySection {
|
|
11
|
+
internal_id: string;
|
|
12
|
+
handle: string;
|
|
13
|
+
trust_tier: string;
|
|
14
|
+
display_name: string | null;
|
|
15
|
+
agent_identity_urn: string | null;
|
|
16
|
+
enrolled_at: string | null;
|
|
17
|
+
hardware_locked: boolean;
|
|
18
|
+
locked_at: string | null;
|
|
19
|
+
hardware_lock_notice: string | null;
|
|
20
|
+
operator_email_registered: boolean;
|
|
21
|
+
credential_pointer_count: number;
|
|
22
|
+
}
|
|
23
|
+
export interface WorldDeviceEntry {
|
|
24
|
+
device_type: string;
|
|
25
|
+
device_fingerprint: string;
|
|
26
|
+
device_status: string;
|
|
27
|
+
trust_tier: string | null;
|
|
28
|
+
tpm_manufacturer: string | null;
|
|
29
|
+
piv_serial: string | null;
|
|
30
|
+
bound_at: string | null;
|
|
31
|
+
burned_at: string | null;
|
|
32
|
+
burn_reason: string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface WorldServiceEntry {
|
|
35
|
+
service_id: string;
|
|
36
|
+
service_name: string;
|
|
37
|
+
service_type: string | null;
|
|
38
|
+
category: string | null;
|
|
39
|
+
status: string | null;
|
|
40
|
+
primary_identifier: string | null;
|
|
41
|
+
aliases: string[] | null;
|
|
42
|
+
dashboard_url: string | null;
|
|
43
|
+
description: string | null;
|
|
44
|
+
minimum_trust_tier: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface WorldGuidanceItem {
|
|
47
|
+
id: string;
|
|
48
|
+
priority: string;
|
|
49
|
+
title: string;
|
|
50
|
+
description: string;
|
|
51
|
+
human_action_url: string | null;
|
|
52
|
+
agent_api_endpoint: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface WorldOperatorGuidance {
|
|
55
|
+
message_for_human: string;
|
|
56
|
+
items: WorldGuidanceItem[];
|
|
57
|
+
}
|
|
58
|
+
export interface WorldStatus {
|
|
59
|
+
identity: WorldIdentitySection;
|
|
60
|
+
devices: WorldDeviceEntry[];
|
|
61
|
+
connected_services: WorldServiceEntry[];
|
|
62
|
+
available_services: WorldServiceEntry[];
|
|
63
|
+
operator_guidance: WorldOperatorGuidance | null;
|
|
64
|
+
raw_data: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Fetch the full world state from the server.
|
|
68
|
+
*
|
|
69
|
+
* Returns everything: identity, devices, connected services, available services,
|
|
70
|
+
* and operator guidance. Results are cached for 5 minutes.
|
|
71
|
+
*
|
|
72
|
+
* @param credentials Optional pre-loaded credentials.
|
|
73
|
+
* @returns WorldStatus with complete identity state.
|
|
74
|
+
* @throws NotEnrolledError if no credentials exist.
|
|
75
|
+
* @throws AuthenticationError if the token is invalid or expired.
|
|
76
|
+
* @throws NetworkError if the server cannot be reached.
|
|
77
|
+
*/
|
|
78
|
+
export declare function fetch_world_status_from_server(credentials?: StoredCredentials | null): Promise<WorldStatus>;
|
|
79
|
+
/**
|
|
80
|
+
* Clear the cached world status, forcing a fresh fetch on next call.
|
|
81
|
+
*/
|
|
82
|
+
export declare function invalidate_world_cache(): void;
|
|
83
|
+
//# sourceMappingURL=world.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../src/world.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAO5E,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CA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