@framers/agentos-ext-anchor-providers 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +98 -0
  2. package/README.md +38 -16
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/providers/EthereumProvider.d.ts +48 -4
  7. package/dist/providers/EthereumProvider.d.ts.map +1 -1
  8. package/dist/providers/EthereumProvider.js +261 -27
  9. package/dist/providers/EthereumProvider.js.map +1 -1
  10. package/dist/providers/OpenTimestampsProvider.d.ts +26 -2
  11. package/dist/providers/OpenTimestampsProvider.d.ts.map +1 -1
  12. package/dist/providers/OpenTimestampsProvider.js +141 -26
  13. package/dist/providers/OpenTimestampsProvider.js.map +1 -1
  14. package/dist/providers/RekorProvider.d.ts +32 -3
  15. package/dist/providers/RekorProvider.d.ts.map +1 -1
  16. package/dist/providers/RekorProvider.js +212 -25
  17. package/dist/providers/RekorProvider.js.map +1 -1
  18. package/dist/providers/SolanaProvider.d.ts +58 -4
  19. package/dist/providers/SolanaProvider.d.ts.map +1 -1
  20. package/dist/providers/SolanaProvider.js +310 -25
  21. package/dist/providers/SolanaProvider.js.map +1 -1
  22. package/dist/providers/WormSnapshotProvider.d.ts +30 -2
  23. package/dist/providers/WormSnapshotProvider.d.ts.map +1 -1
  24. package/dist/providers/WormSnapshotProvider.js +176 -27
  25. package/dist/providers/WormSnapshotProvider.js.map +1 -1
  26. package/dist/register.d.ts.map +1 -1
  27. package/dist/register.js +1 -0
  28. package/dist/register.js.map +1 -1
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js +1 -0
  31. package/dist/types.js.map +1 -1
  32. package/dist/utils/http-client.d.ts.map +1 -1
  33. package/dist/utils/http-client.js +1 -0
  34. package/dist/utils/http-client.js.map +1 -1
  35. package/dist/utils/index.d.ts.map +1 -1
  36. package/dist/utils/index.js +1 -0
  37. package/dist/utils/index.js.map +1 -1
  38. package/dist/utils/serialization.d.ts.map +1 -1
  39. package/dist/utils/serialization.js +1 -0
  40. package/dist/utils/serialization.js.map +1 -1
  41. package/manifest.json +5 -5
  42. package/package.json +26 -21
  43. package/CHANGELOG.md +0 -16
  44. package/src/index.ts +0 -59
  45. package/src/providers/EthereumProvider.ts +0 -87
  46. package/src/providers/OpenTimestampsProvider.ts +0 -86
  47. package/src/providers/RekorProvider.ts +0 -82
  48. package/src/providers/SolanaProvider.ts +0 -439
  49. package/src/providers/WormSnapshotProvider.ts +0 -84
  50. package/src/register.ts +0 -69
  51. package/src/types.ts +0 -27
  52. package/src/utils/http-client.ts +0 -75
  53. package/src/utils/index.ts +0 -3
  54. package/src/utils/serialization.ts +0 -33
  55. package/test/integration.spec.ts +0 -175
  56. package/test/providers.spec.ts +0 -163
  57. package/test/register.spec.ts +0 -69
  58. package/test/types.spec.ts +0 -55
  59. package/test/utils.spec.ts +0 -225
  60. package/tsconfig.json +0 -21
@@ -1,16 +1,62 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * @file RekorProvider.ts
3
- * @description Sigstore Rekor transparency log anchor provider.
4
- * Publishes anchor Merkle roots as hashedrekord entries to Rekor.
4
+ * @description Sigstore Rekor transparency-log anchor provider.
5
+ *
6
+ * Submits a `hashedrekord` entry to Rekor so each anchor is recorded
7
+ * in a public append-only log keyed by SHA-256 of the canonical
8
+ * anchor. Rekor cryptographically verifies the supplied signature
9
+ * against the supplied hash before accepting the entry, so the caller
10
+ * must provide an Ed25519 `signArtifact` function that signs over the
11
+ * raw hash bytes (Rekor's verification target) — **not** the
12
+ * AgentKeyManager's sign-over-merkleRoot-string output, which is the
13
+ * wrong byte sequence for Rekor's verifier.
5
14
  *
6
15
  * Proof level: `publicly-auditable`
7
- * Required peer dependency: `sigstore`
16
+ * Required dependencies: none for `publish` (uses global `fetch`).
8
17
  *
9
18
  * @module @framers/agentos-ext-anchor-providers
10
19
  */
11
20
  import { resolveBaseConfig } from '../types.js';
21
+ import { fetchWithRetry } from '../utils/http-client.js';
12
22
  import { hashCanonicalAnchor } from '../utils/serialization.js';
13
23
  const DEFAULT_SERVER_URL = 'https://rekor.sigstore.dev';
24
+ /**
25
+ * Encode the Rekor server URL into the externalRef so verify() reaches the
26
+ * same server that recorded the entry, even if config.serverUrl has been
27
+ * changed since publish. The serverUrl is base64-encoded so a `:` character
28
+ * in the URL doesn't collide with the externalRef field separator.
29
+ */
30
+ function encodeExternalRef(serverUrl, logIndex, uuid) {
31
+ const encodedServer = Buffer.from(serverUrl, 'utf-8').toString('base64url');
32
+ return `rekor:${encodedServer}:${logIndex}:${uuid}`;
33
+ }
34
+ /** Decode an externalRef back to { serverUrl, uuid }. Tolerates the old
35
+ * two-field `rekor:${logIndex}:${uuid}` shape by falling back to
36
+ * `fallbackServerUrl` (typically `this.config.serverUrl`).
37
+ */
38
+ function decodeExternalRef(externalRef, fallbackServerUrl) {
39
+ if (!externalRef.startsWith('rekor:'))
40
+ return null;
41
+ const parts = externalRef.split(':');
42
+ // New format: rekor:<base64url(serverUrl)>:<logIndex>:<uuid> (>= 4 parts)
43
+ if (parts.length >= 4) {
44
+ try {
45
+ const serverUrl = Buffer.from(parts[1] ?? '', 'base64url').toString('utf-8');
46
+ const uuid = parts.slice(3).join(':');
47
+ if (serverUrl && uuid)
48
+ return { serverUrl, uuid };
49
+ }
50
+ catch {
51
+ // Falls through to legacy format check.
52
+ }
53
+ }
54
+ // Legacy format: rekor:<logIndex>:<uuid> (exactly 3 parts)
55
+ if (parts.length === 3) {
56
+ return { serverUrl: fallbackServerUrl, uuid: parts[2] ?? '' };
57
+ }
58
+ return null;
59
+ }
14
60
  export class RekorProvider {
15
61
  id = 'rekor';
16
62
  name = 'Sigstore Rekor Transparency Log';
@@ -23,46 +69,187 @@ export class RekorProvider {
23
69
  timeoutMs: config.timeoutMs ?? 30_000,
24
70
  retries: config.retries ?? 3,
25
71
  retryDelayMs: config.retryDelayMs ?? 1_000,
72
+ publicKeyPem: config.publicKeyPem,
73
+ signArtifact: config.signArtifact,
26
74
  };
27
75
  this.baseConfig = resolveBaseConfig(config);
28
76
  }
29
77
  async publish(anchor) {
30
- // TODO: Implement using sigstore SDK or direct HTTP to Rekor API
31
- //
32
- // Implementation outline:
33
- // 1. Compute SHA-256 hash of canonical anchor: hashCanonicalAnchor(anchor)
34
- // 2. Create a hashedrekord entry:
35
- // POST ${serverUrl}/api/v1/log/entries
36
- // Body: { kind: 'hashedrekord', apiVersion: '0.0.1',
37
- // spec: { data: { hash: { algorithm: 'sha256', value: anchorHash } },
38
- // signature: { content: anchor.signature, publicKey: { content: ... } } } }
39
- // 3. Parse response for log index and entry UUID
40
- // 4. Return { success: true, externalRef: `rekor:${logIndex}:${entryUUID}`,
41
- // metadata: { logIndex, serverUrl, inclusionProof } }
78
+ if (!this.config.publicKeyPem || !this.config.signArtifact) {
79
+ return {
80
+ providerId: this.id,
81
+ success: false,
82
+ error: 'RekorProvider.publish requires both publicKeyPem (PEM-encoded Ed25519 public key) and signArtifact (function signing the raw hash bytes).',
83
+ metadata: { serverUrl: this.config.serverUrl },
84
+ };
85
+ }
86
+ const digestHex = await hashCanonicalAnchor(anchor);
87
+ const digestBytes = Buffer.from(digestHex, 'hex');
88
+ let signatureBytes;
89
+ try {
90
+ const raw = await this.config.signArtifact(new Uint8Array(digestBytes));
91
+ signatureBytes = raw instanceof Uint8Array ? raw : new Uint8Array(raw);
92
+ }
93
+ catch (e) {
94
+ return {
95
+ providerId: this.id,
96
+ success: false,
97
+ error: `RekorProvider signArtifact failed: ${e instanceof Error ? e.message : String(e)}`,
98
+ metadata: { serverUrl: this.config.serverUrl },
99
+ };
100
+ }
101
+ // hashedrekord v0.0.1 entry. The signature MUST be valid for
102
+ // (publicKey, digestBytes) under Ed25519; Rekor refuses entries
103
+ // whose signature does not verify against the supplied hash.
104
+ const entry = {
105
+ apiVersion: '0.0.1',
106
+ kind: 'hashedrekord',
107
+ spec: {
108
+ data: {
109
+ hash: {
110
+ algorithm: 'sha256',
111
+ value: digestHex,
112
+ },
113
+ },
114
+ signature: {
115
+ content: Buffer.from(signatureBytes).toString('base64'),
116
+ publicKey: {
117
+ content: Buffer.from(this.config.publicKeyPem, 'utf-8').toString('base64'),
118
+ },
119
+ },
120
+ },
121
+ };
122
+ let response;
123
+ try {
124
+ response = await fetchWithRetry(`${this.config.serverUrl.replace(/\/$/, '')}/api/v1/log/entries`, {
125
+ method: 'POST',
126
+ headers: {
127
+ 'Content-Type': 'application/json',
128
+ Accept: 'application/json',
129
+ },
130
+ body: JSON.stringify(entry),
131
+ }, {
132
+ timeoutMs: this.config.timeoutMs,
133
+ retries: this.config.retries,
134
+ retryDelayMs: this.config.retryDelayMs,
135
+ });
136
+ }
137
+ catch (e) {
138
+ return {
139
+ providerId: this.id,
140
+ success: false,
141
+ error: `Rekor submit failed: ${e instanceof Error ? e.message : String(e)}`,
142
+ metadata: { serverUrl: this.config.serverUrl },
143
+ };
144
+ }
145
+ if (!response.ok) {
146
+ let body = '';
147
+ try {
148
+ body = (await response.text()).slice(0, 500);
149
+ }
150
+ catch {
151
+ // ignore
152
+ }
153
+ return {
154
+ providerId: this.id,
155
+ success: false,
156
+ error: `Rekor rejected entry: HTTP ${response.status} ${response.statusText}${body ? ` — ${body}` : ''}`,
157
+ metadata: { serverUrl: this.config.serverUrl, status: response.status },
158
+ };
159
+ }
160
+ let entryMap;
42
161
  try {
43
- const _hash = await hashCanonicalAnchor(anchor);
44
- throw new Error('RekorProvider is not yet implemented. ' +
45
- 'Install sigstore SDK and implement the Rekor transparency log integration.');
162
+ entryMap = (await response.json());
46
163
  }
47
164
  catch (e) {
48
165
  return {
49
166
  providerId: this.id,
50
167
  success: false,
51
- error: e instanceof Error ? e.message : String(e),
168
+ error: `Rekor returned unparseable JSON: ${e instanceof Error ? e.message : String(e)}`,
169
+ metadata: { serverUrl: this.config.serverUrl },
52
170
  };
53
171
  }
172
+ // Rekor responses are keyed by entry UUID with the entry as the
173
+ // value. There's exactly one key in a single-submit response.
174
+ const uuid = Object.keys(entryMap)[0];
175
+ const entryData = uuid ? entryMap[uuid] : undefined;
176
+ if (!uuid || !entryData) {
177
+ return {
178
+ providerId: this.id,
179
+ success: false,
180
+ error: 'Rekor returned a response without an entry UUID',
181
+ metadata: { serverUrl: this.config.serverUrl },
182
+ };
183
+ }
184
+ const logIndex = entryData.logIndex;
185
+ return {
186
+ providerId: this.id,
187
+ success: true,
188
+ externalRef: encodeExternalRef(this.config.serverUrl, logIndex, uuid),
189
+ publishedAt: new Date().toISOString(),
190
+ metadata: {
191
+ serverUrl: this.config.serverUrl,
192
+ logIndex,
193
+ uuid,
194
+ integratedTime: entryData.integratedTime,
195
+ hasInclusionProof: Boolean(entryData.verification?.inclusionProof),
196
+ },
197
+ };
54
198
  }
199
+ /**
200
+ * Confirm the anchor's Rekor entry exists and its body hash matches a
201
+ * fresh canonical anchor digest. Does NOT cryptographically verify
202
+ * the inclusion proof against the signed tree head — that needs the
203
+ * sigstore SDK; for compliance workflows wire up
204
+ * `sigstore.verify(bundle)` after this method returns true.
205
+ */
55
206
  async verify(anchor) {
56
- // TODO: Retrieve entry from Rekor by externalRef and verify inclusion proof
57
- // GET ${serverUrl}/api/v1/log/entries/${entryUUID}
58
- // Verify inclusion proof against the transparency log root
59
207
  if (!anchor.externalRef)
60
208
  return false;
61
- console.warn('[RekorProvider] verify() is not yet implemented');
62
- return false;
209
+ const decoded = decodeExternalRef(anchor.externalRef, this.config.serverUrl);
210
+ if (!decoded)
211
+ return false;
212
+ try {
213
+ const response = await fetchWithRetry(`${decoded.serverUrl.replace(/\/$/, '')}/api/v1/log/entries/${decoded.uuid}`, undefined, {
214
+ timeoutMs: this.config.timeoutMs,
215
+ retries: this.config.retries,
216
+ retryDelayMs: this.config.retryDelayMs,
217
+ });
218
+ if (!response.ok)
219
+ return false;
220
+ const entryMap = (await response.json());
221
+ const entry = entryMap[decoded.uuid];
222
+ if (!entry?.body)
223
+ return false;
224
+ // Body is base64-encoded JSON of the hashedrekord spec.
225
+ const bodyJson = Buffer.from(entry.body, 'base64').toString('utf-8');
226
+ const body = JSON.parse(bodyJson);
227
+ const storedHash = body.spec?.data?.hash?.value;
228
+ if (typeof storedHash !== 'string')
229
+ return false;
230
+ const recomputed = await hashCanonicalAnchor(anchor);
231
+ // Compare hashes; canonical equality of the SHA-256 hex is the
232
+ // integrity signal for the recorded artifact.
233
+ return constantTimeEqual(storedHash.toLowerCase(), recomputed.toLowerCase());
234
+ }
235
+ catch {
236
+ return false;
237
+ }
63
238
  }
64
239
  async dispose() {
65
- // No persistent resources in current implementation
240
+ // No persistent resources.
66
241
  }
67
242
  }
243
+ /**
244
+ * Constant-time string equality (over hex digests) to avoid leaking
245
+ * digest prefixes via timing differences when called in a tight loop.
246
+ */
247
+ function constantTimeEqual(a, b) {
248
+ if (a.length !== b.length)
249
+ return false;
250
+ let diff = 0;
251
+ for (let i = 0; i < a.length; i++)
252
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
253
+ return diff === 0;
254
+ }
68
255
  //# sourceMappingURL=RekorProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RekorProvider.js","sourceRoot":"","sources":["../../src/providers/RekorProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAOhE,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAExD,MAAM,OAAO,aAAa;IACf,EAAE,GAAG,OAAO,CAAC;IACb,IAAI,GAAG,iCAAiC,CAAC;IACzC,UAAU,GAAe,oBAAoB,CAAC;IAEtC,MAAM,CAAgC;IACtC,UAAU,CAA+B;IAE1D,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,kBAAkB;YACjD,SAAS,EAAE,MAAM,CAAC,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QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACrE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAwD,CAAC;YACzF,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;YAChD,IAAI,OAAO,UAAU,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAEjD,MAAM,UAAU,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;YACrD,+DAA+D;YAC/D,8CAA8C;YAC9C,OAAO,iBAAiB,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,2BAA2B;IAC7B,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,CAAS,EAAE,CAAS;IAC7C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7E,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC"}
@@ -20,21 +20,71 @@ export interface SolanaProviderConfig extends BaseProviderConfig {
20
20
  /** Wunderland on-chain program ID. */
21
21
  programId: string;
22
22
  /**
23
- * Signer secret key (Solana Keypair secretKey bytes) as a JSON number array.
23
+ * Owner wallet signer used for agent registration (`initialize_agent`).
24
+ *
25
+ * This wallet:
26
+ * - signs `initialize_agent`
27
+ * - pays the mint fee + rent
28
+ *
29
+ * Notes:
30
+ * - Registration is permissionless (not registrar-gated).
31
+ * - The owner wallet must be different from the agent signer (on-chain invariant).
32
+ */
33
+ ownerSecretKeyJson?: number[];
34
+ ownerKeypairPath?: string;
35
+ ownerPrivateKeyBase58?: string;
36
+ /**
37
+ * @deprecated Use `owner*` fields instead.
38
+ *
39
+ * Legacy alias for the owner wallet used for agent registration.
40
+ *
41
+ * Kept for backward compatibility with older configs that used the term "registrar".
42
+ */
43
+ registrarSecretKeyJson?: number[];
44
+ registrarKeypairPath?: string;
45
+ registrarPrivateKeyBase58?: string;
46
+ /**
47
+ * Agent signer wallet secret key (Solana Keypair secretKey bytes) as a JSON number array.
48
+ *
49
+ * This keypair is used to:
50
+ * - pay transaction fees/rent (fee payer)
51
+ * - ed25519-sign Wunderland payload messages (agent signer)
52
+ *
24
53
  * Example: the contents of a Solana CLI keypair file.
25
54
  */
26
55
  signerSecretKeyJson?: number[];
27
- /** Path to Solana keypair JSON file (array of numbers). */
56
+ /** Path to agent signer wallet keypair JSON file (array of numbers). */
28
57
  signerKeypairPath?: string;
29
- /** Base58-encoded signer secret key bytes (64 bytes). */
58
+ /** Base58-encoded agent signer wallet secret key bytes (64 bytes). */
30
59
  signerPrivateKeyBase58?: string;
31
60
  /** Solana cluster label used only for `externalRef` formatting. */
32
61
  cluster?: 'devnet' | 'testnet' | 'mainnet-beta' | 'localnet';
33
62
  /** Commitment level (e.g. 'confirmed', 'finalized'). Default: 'confirmed'. */
34
63
  commitment?: string;
64
+ /**
65
+ * Enclave name to publish into.
66
+ *
67
+ * Default: 'wunderland'
68
+ */
69
+ enclaveName?: string;
70
+ /**
71
+ * If true, automatically creates the enclave (create_enclave) when missing.
72
+ *
73
+ * Default: false
74
+ */
75
+ autoCreateEnclave?: boolean;
76
+ /**
77
+ * Optional explicit agent_id (32-byte hex string).
78
+ *
79
+ * If omitted, a deterministic id is derived from the signer public key.
80
+ */
81
+ agentIdHex?: string;
35
82
  /**
36
83
  * If true, automatically initializes the agent (initialize_agent) when missing.
37
- * Default: true
84
+ *
85
+ * Requires owner wallet signer configuration (see `owner*` fields).
86
+ *
87
+ * Default: false
38
88
  */
39
89
  autoInitializeAgent?: boolean;
40
90
  /** Display name used when auto-initializing the agent. Default: 'AgentOS'. */
@@ -57,6 +107,10 @@ export declare class SolanaProvider implements AnchorProvider {
57
107
  dispose(): Promise<void>;
58
108
  private loadWeb3;
59
109
  private loadSigner;
110
+ private loadRegistrarSigner;
60
111
  private loadBs58;
112
+ private tryLoadOwnerSigner;
113
+ private loadOwnerSigner;
114
+ private findAgentIdentityBySearch;
61
115
  }
62
116
  //# sourceMappingURL=SolanaProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SolanaProvider.d.ts","sourceRoot":"","sources":["../../src/providers/SolanaProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,yDAAyD;IACzD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,mEAAmE;IACnE,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,cAAc,GAAG,UAAU,CAAC;IAE7D,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,8EAA8E;IAC9E,gBAAgB,CAAC,E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