@enactprotocol/trust 2.0.0 → 2.0.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 (58) hide show
  1. package/dist/hash.d.ts +53 -0
  2. package/dist/hash.d.ts.map +1 -0
  3. package/dist/hash.js +104 -0
  4. package/dist/hash.js.map +1 -0
  5. package/dist/index.d.ts +12 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +14 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/keys.d.ts +41 -0
  10. package/dist/keys.d.ts.map +1 -0
  11. package/dist/keys.js +130 -0
  12. package/dist/keys.js.map +1 -0
  13. package/dist/sigstore/attestation.d.ts +245 -0
  14. package/dist/sigstore/attestation.d.ts.map +1 -0
  15. package/dist/sigstore/attestation.js +324 -0
  16. package/dist/sigstore/attestation.js.map +1 -0
  17. package/dist/sigstore/cosign.d.ts +90 -0
  18. package/dist/sigstore/cosign.d.ts.map +1 -0
  19. package/dist/sigstore/cosign.js +457 -0
  20. package/dist/sigstore/cosign.js.map +1 -0
  21. package/dist/sigstore/index.d.ts +17 -0
  22. package/dist/sigstore/index.d.ts.map +1 -0
  23. package/dist/sigstore/index.js +21 -0
  24. package/dist/sigstore/index.js.map +1 -0
  25. package/dist/sigstore/oauth/client.d.ts +38 -0
  26. package/dist/sigstore/oauth/client.d.ts.map +1 -0
  27. package/dist/sigstore/oauth/client.js +71 -0
  28. package/dist/sigstore/oauth/client.js.map +1 -0
  29. package/dist/sigstore/oauth/index.d.ts +47 -0
  30. package/dist/sigstore/oauth/index.d.ts.map +1 -0
  31. package/dist/sigstore/oauth/index.js +66 -0
  32. package/dist/sigstore/oauth/index.js.map +1 -0
  33. package/dist/sigstore/oauth/server.d.ts +29 -0
  34. package/dist/sigstore/oauth/server.d.ts.map +1 -0
  35. package/dist/sigstore/oauth/server.js +145 -0
  36. package/dist/sigstore/oauth/server.js.map +1 -0
  37. package/dist/sigstore/policy.d.ts +85 -0
  38. package/dist/sigstore/policy.d.ts.map +1 -0
  39. package/dist/sigstore/policy.js +351 -0
  40. package/dist/sigstore/policy.js.map +1 -0
  41. package/dist/sigstore/signing.d.ts +94 -0
  42. package/dist/sigstore/signing.d.ts.map +1 -0
  43. package/dist/sigstore/signing.js +477 -0
  44. package/dist/sigstore/signing.js.map +1 -0
  45. package/dist/sigstore/types.d.ts +541 -0
  46. package/dist/sigstore/types.d.ts.map +1 -0
  47. package/dist/sigstore/types.js +5 -0
  48. package/dist/sigstore/types.js.map +1 -0
  49. package/dist/sigstore/verification.d.ts +66 -0
  50. package/dist/sigstore/verification.d.ts.map +1 -0
  51. package/dist/sigstore/verification.js +317 -0
  52. package/dist/sigstore/verification.js.map +1 -0
  53. package/dist/types.d.ts +61 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +5 -0
  56. package/dist/types.js.map +1 -0
  57. package/package.json +1 -1
  58. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,324 @@
1
+ /**
2
+ * Attestation generation module
3
+ *
4
+ * This module provides functions for creating in-toto attestations and SLSA provenance
5
+ * statements that can be signed using Sigstore.
6
+ */
7
+ import { hashContent, hashFile } from "../hash";
8
+ // ============================================================================
9
+ // Constants
10
+ // ============================================================================
11
+ /**
12
+ * The primary Enact website/registry URL
13
+ * Used for attestation types, tool URLs, and documentation references
14
+ */
15
+ export const ENACT_BASE_URL = "https://enact.tools";
16
+ /** in-toto statement type */
17
+ export const INTOTO_STATEMENT_TYPE = "https://in-toto.io/Statement/v1";
18
+ /** SLSA Provenance predicate type v1.0 */
19
+ export const SLSA_PROVENANCE_TYPE = "https://slsa.dev/provenance/v1";
20
+ /** Enact tool attestation predicate type */
21
+ export const ENACT_TOOL_TYPE = `${ENACT_BASE_URL}/attestation/tool/v1`;
22
+ /** Enact audit attestation predicate type */
23
+ export const ENACT_AUDIT_TYPE = `${ENACT_BASE_URL}/attestation/audit/v1`;
24
+ /** Enact build type for SLSA provenance */
25
+ export const ENACT_BUILD_TYPE = `${ENACT_BASE_URL}/build/v1`;
26
+ // ============================================================================
27
+ // Subject Creation
28
+ // ============================================================================
29
+ /**
30
+ * Create an in-toto subject from content
31
+ *
32
+ * @param name - The subject name (e.g., file path or artifact identifier)
33
+ * @param content - The content to hash
34
+ * @returns The in-toto subject with sha256 digest
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const subject = createSubjectFromContent("tool.yaml", yamlContent);
39
+ * // { name: "tool.yaml", digest: { sha256: "abc123..." } }
40
+ * ```
41
+ */
42
+ export function createSubjectFromContent(name, content) {
43
+ const hash = hashContent(content, "sha256");
44
+ return {
45
+ name,
46
+ digest: {
47
+ sha256: hash.digest,
48
+ },
49
+ };
50
+ }
51
+ /**
52
+ * Create an in-toto subject from a file
53
+ *
54
+ * @param name - The subject name (can differ from file path)
55
+ * @param filePath - Path to the file to hash
56
+ * @returns Promise resolving to the in-toto subject
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const subject = await createSubjectFromFile("my-tool@1.0.0", "/path/to/tool.yaml");
61
+ * ```
62
+ */
63
+ export async function createSubjectFromFile(name, filePath) {
64
+ const hash = await hashFile(filePath, { algorithm: "sha256" });
65
+ return {
66
+ name,
67
+ digest: {
68
+ sha256: hash.digest,
69
+ },
70
+ };
71
+ }
72
+ /**
73
+ * Create an in-toto subject with multiple digest algorithms
74
+ *
75
+ * @param name - The subject name
76
+ * @param content - The content to hash
77
+ * @returns Subject with both sha256 and sha512 digests
78
+ */
79
+ export function createSubjectWithMultipleDigests(name, content) {
80
+ const sha256 = hashContent(content, "sha256");
81
+ const sha512 = hashContent(content, "sha512");
82
+ return {
83
+ name,
84
+ digest: {
85
+ sha256: sha256.digest,
86
+ sha512: sha512.digest,
87
+ },
88
+ };
89
+ }
90
+ // ============================================================================
91
+ // Statement Creation
92
+ // ============================================================================
93
+ /**
94
+ * Create a generic in-toto statement
95
+ *
96
+ * @param subjects - The subjects (artifacts) covered by this attestation
97
+ * @param predicateType - The predicate type URI
98
+ * @param predicate - The predicate content
99
+ * @returns The in-toto statement
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const statement = createStatement(
104
+ * [subject],
105
+ * "https://example.com/predicate/v1",
106
+ * { customField: "value" }
107
+ * );
108
+ * ```
109
+ */
110
+ export function createStatement(subjects, predicateType, predicate) {
111
+ return {
112
+ _type: INTOTO_STATEMENT_TYPE,
113
+ subject: subjects,
114
+ predicateType,
115
+ predicate,
116
+ };
117
+ }
118
+ /**
119
+ * Create a SLSA provenance predicate
120
+ *
121
+ * @param options - Provenance options
122
+ * @returns The SLSA provenance predicate
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const provenance = createSLSAProvenance({
127
+ * buildType: "https://enact.tools/build/v1",
128
+ * builderId: "https://github.com/enact-dev/enact-cli@v2.0.0",
129
+ * externalParameters: {
130
+ * manifestPath: "tool.yaml"
131
+ * }
132
+ * });
133
+ * ```
134
+ */
135
+ export function createSLSAProvenance(options) {
136
+ const provenance = {
137
+ buildDefinition: {
138
+ buildType: options.buildType,
139
+ externalParameters: options.externalParameters || {},
140
+ },
141
+ runDetails: {
142
+ builder: {
143
+ id: options.builderId,
144
+ },
145
+ },
146
+ };
147
+ // Add optional fields
148
+ if (options.internalParameters) {
149
+ provenance.buildDefinition.internalParameters = options.internalParameters;
150
+ }
151
+ if (options.resolvedDependencies) {
152
+ provenance.buildDefinition.resolvedDependencies = options.resolvedDependencies;
153
+ }
154
+ // Add metadata if any timestamps are provided
155
+ if (options.invocationId || options.startedOn || options.finishedOn) {
156
+ provenance.runDetails.metadata = {};
157
+ if (options.invocationId) {
158
+ provenance.runDetails.metadata.invocationId = options.invocationId;
159
+ }
160
+ if (options.startedOn) {
161
+ provenance.runDetails.metadata.startedOn = options.startedOn.toISOString();
162
+ }
163
+ if (options.finishedOn) {
164
+ provenance.runDetails.metadata.finishedOn = options.finishedOn.toISOString();
165
+ }
166
+ }
167
+ return provenance;
168
+ }
169
+ /**
170
+ * Create a SLSA provenance statement for an artifact
171
+ *
172
+ * @param subjects - The artifacts to attest
173
+ * @param options - Provenance options
174
+ * @returns The complete in-toto statement with SLSA provenance
175
+ */
176
+ export function createSLSAProvenanceStatement(subjects, options) {
177
+ const provenance = createSLSAProvenance(options);
178
+ return createStatement(subjects, SLSA_PROVENANCE_TYPE, provenance);
179
+ }
180
+ /**
181
+ * Create an Enact tool attestation predicate
182
+ *
183
+ * @param options - Tool attestation options
184
+ * @returns The Enact tool predicate
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * const toolPredicate = createEnactToolPredicate({
189
+ * name: "my-tool",
190
+ * version: "1.0.0",
191
+ * publisher: "user@example.com",
192
+ * description: "A useful tool"
193
+ * });
194
+ * ```
195
+ */
196
+ export function createEnactToolPredicate(options) {
197
+ const predicate = {
198
+ type: ENACT_TOOL_TYPE,
199
+ tool: {
200
+ name: options.name,
201
+ version: options.version,
202
+ publisher: options.publisher,
203
+ },
204
+ };
205
+ // Add optional tool fields
206
+ if (options.description) {
207
+ predicate.tool.description = options.description;
208
+ }
209
+ if (options.repository) {
210
+ predicate.tool.repository = options.repository;
211
+ }
212
+ // Add build information if provided
213
+ if (options.buildTimestamp || options.buildEnvironment || options.sourceCommit) {
214
+ predicate.build = {
215
+ timestamp: (options.buildTimestamp || new Date()).toISOString(),
216
+ };
217
+ if (options.buildEnvironment) {
218
+ predicate.build.environment = options.buildEnvironment;
219
+ }
220
+ if (options.sourceCommit) {
221
+ predicate.build.sourceCommit = options.sourceCommit;
222
+ }
223
+ }
224
+ return predicate;
225
+ }
226
+ /**
227
+ * Create an Enact tool attestation statement
228
+ *
229
+ * @param manifestContent - The tool manifest content
230
+ * @param options - Tool attestation options
231
+ * @returns The complete in-toto statement for the tool
232
+ */
233
+ export function createEnactToolStatement(manifestContent, options) {
234
+ const subject = createSubjectFromContent(`${options.name}@${options.version}`, manifestContent);
235
+ const predicate = createEnactToolPredicate(options);
236
+ return createStatement([subject], ENACT_TOOL_TYPE, predicate);
237
+ }
238
+ /**
239
+ * Create an Enact audit attestation predicate
240
+ *
241
+ * @param options - Audit attestation options
242
+ * @returns The Enact audit predicate
243
+ */
244
+ export function createEnactAuditPredicate(options) {
245
+ const predicate = {
246
+ type: ENACT_AUDIT_TYPE,
247
+ tool: {
248
+ name: options.toolName,
249
+ version: options.toolVersion,
250
+ },
251
+ audit: {
252
+ auditor: options.auditor,
253
+ timestamp: (options.timestamp || new Date()).toISOString(),
254
+ result: options.result,
255
+ },
256
+ };
257
+ if (options.notes) {
258
+ predicate.audit.notes = options.notes;
259
+ }
260
+ return predicate;
261
+ }
262
+ /**
263
+ * Create an Enact audit attestation statement
264
+ *
265
+ * @param manifestContent - The tool manifest content being audited
266
+ * @param options - Audit attestation options
267
+ * @returns The complete in-toto statement for the audit
268
+ */
269
+ export function createEnactAuditStatement(manifestContent, options) {
270
+ const subject = createSubjectFromContent(`${options.toolName}@${options.toolVersion}`, manifestContent);
271
+ const predicate = createEnactAuditPredicate(options);
272
+ return createStatement([subject], ENACT_AUDIT_TYPE, predicate);
273
+ }
274
+ // ============================================================================
275
+ // Resource Descriptors
276
+ // ============================================================================
277
+ /**
278
+ * Create a SLSA resource descriptor for a file
279
+ *
280
+ * @param filePath - Path to the file
281
+ * @param options - Additional descriptor options
282
+ * @returns Promise resolving to the resource descriptor
283
+ */
284
+ export async function createResourceDescriptorFromFile(filePath, options = {}) {
285
+ const hash = await hashFile(filePath, { algorithm: "sha256" });
286
+ const descriptor = {
287
+ name: options.name || filePath,
288
+ digest: {
289
+ sha256: hash.digest,
290
+ },
291
+ };
292
+ if (options.uri)
293
+ descriptor.uri = options.uri;
294
+ if (options.downloadLocation)
295
+ descriptor.downloadLocation = options.downloadLocation;
296
+ if (options.mediaType)
297
+ descriptor.mediaType = options.mediaType;
298
+ return descriptor;
299
+ }
300
+ /**
301
+ * Create a SLSA resource descriptor from content
302
+ *
303
+ * @param content - The content
304
+ * @param options - Descriptor options
305
+ * @returns The resource descriptor
306
+ */
307
+ export function createResourceDescriptorFromContent(content, options = {}) {
308
+ const hash = hashContent(content, "sha256");
309
+ const descriptor = {
310
+ digest: {
311
+ sha256: hash.digest,
312
+ },
313
+ };
314
+ if (options.uri)
315
+ descriptor.uri = options.uri;
316
+ if (options.name)
317
+ descriptor.name = options.name;
318
+ if (options.downloadLocation)
319
+ descriptor.downloadLocation = options.downloadLocation;
320
+ if (options.mediaType)
321
+ descriptor.mediaType = options.mediaType;
322
+ return descriptor;
323
+ }
324
+ //# sourceMappingURL=attestation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestation.js","sourceRoot":"","sources":["../../src/sigstore/attestation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAShD,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD,6BAA6B;AAC7B,MAAM,CAAC,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAEvE,0CAA0C;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAErE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,cAAc,sBAAsB,CAAC;AAEvE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,cAAc,uBAAuB,CAAC;AAEzE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,cAAc,WAAW,CAAC;AAE7D,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,OAAwB;IAC7E,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5C,OAAO;QACL,IAAI;QACJ,MAAM,EAAE;YACN,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB;KACF,CAA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E;YACN,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB;KACF,CAAC;IAEF,IAAI,OAAO,CAAC,GAAG;QAAE,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAC9C,IAAI,OAAO,CAAC,gBAAgB;QAAE,UAAU,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACrF,IAAI,OAAO,CAAC,SAAS;QAAE,UAAU,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAEhE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mCAAmC,CACjD,OAAwB,EACxB,UAKI,EAAE;IAEN,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE5C,MAAM,UAAU,GAA2B;QACzC,MAAM,EAAE;YACN,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB;KACF,CAAC;IAEF,IAAI,OAAO,CAAC,GAAG;QAAE,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAC9C,IAAI,OAAO,CAAC,IAAI;QAAE,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IACjD,IAAI,OAAO,CAAC,gBAAgB;QAAE,UAAU,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACrF,IAAI,OAAO,CAAC,SAAS;QAAE,UAAU,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAEhE,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Cosign CLI integration for interactive OIDC signing
3
+ *
4
+ * The sigstore-js library is designed for CI environments where OIDC tokens
5
+ * are available via environment variables. For interactive local signing,
6
+ * we shell out to the cosign CLI which handles the browser-based OAuth flow.
7
+ */
8
+ import type { SigstoreBundle } from "./types";
9
+ /**
10
+ * Check if cosign CLI is available
11
+ */
12
+ export declare function isCosignAvailable(): boolean;
13
+ /**
14
+ * Get cosign version information
15
+ */
16
+ export declare function getCosignVersion(): string | undefined;
17
+ /**
18
+ * Options for cosign signing
19
+ */
20
+ export interface CosignSignOptions {
21
+ /** Timeout in milliseconds for the OIDC flow */
22
+ timeout?: number;
23
+ /** Output bundle path (if not provided, a temp file is used) */
24
+ outputPath?: string;
25
+ /** Whether to run in verbose mode */
26
+ verbose?: boolean;
27
+ }
28
+ /**
29
+ * Result of cosign signing
30
+ */
31
+ export interface CosignSignResult {
32
+ /** The Sigstore bundle */
33
+ bundle: SigstoreBundle;
34
+ /** Path where the bundle was saved */
35
+ bundlePath: string;
36
+ /** Signer identity (email) extracted from the bundle */
37
+ signerIdentity: string | undefined;
38
+ }
39
+ /**
40
+ * Sign a blob (file or buffer) using cosign with interactive OIDC
41
+ *
42
+ * This opens a browser for OAuth authentication with Sigstore's public
43
+ * OIDC provider. The signature, certificate, and Rekor entry are bundled
44
+ * together in the Sigstore bundle format.
45
+ *
46
+ * @param data - The data to sign (Buffer or path to file)
47
+ * @param options - Signing options
48
+ * @returns The signing result with bundle
49
+ */
50
+ export declare function signWithCosign(data: Buffer | string, options?: CosignSignOptions): Promise<CosignSignResult>;
51
+ /**
52
+ * Sign an in-toto attestation using cosign
53
+ *
54
+ * For in-toto attestations, we use cosign attest-blob which wraps the
55
+ * attestation in a DSSE envelope.
56
+ *
57
+ * @param attestation - The in-toto statement to sign
58
+ * @param options - Signing options
59
+ * @returns The signing result with bundle
60
+ */
61
+ export declare function attestWithCosign(attestation: Record<string, unknown>, options?: CosignSignOptions): Promise<CosignSignResult>;
62
+ /**
63
+ * Verify a blob signature using cosign
64
+ *
65
+ * @param data - The data that was signed
66
+ * @param bundle - The Sigstore bundle
67
+ * @param expectedIdentity - Expected signer identity (email)
68
+ * @param expectedIssuer - Expected OIDC issuer
69
+ * @returns Whether verification succeeded
70
+ */
71
+ export declare function verifyWithCosign(data: Buffer | string, bundle: SigstoreBundle, expectedIdentity?: string, expectedIssuer?: string): Promise<{
72
+ verified: boolean;
73
+ error?: string | undefined;
74
+ identity?: string | undefined;
75
+ }>;
76
+ /**
77
+ * Verify an attestation bundle using cosign
78
+ *
79
+ * @param bundle - The Sigstore bundle containing a DSSE-wrapped attestation
80
+ * @param expectedIdentity - Expected signer identity (email)
81
+ * @param expectedIssuer - Expected OIDC issuer
82
+ * @param predicateType - The attestation predicate type (optional)
83
+ * @returns Verification result
84
+ */
85
+ export declare function verifyAttestationWithCosign(bundle: SigstoreBundle, expectedIdentity?: string, expectedIssuer?: string, predicateType?: string): Promise<{
86
+ verified: boolean;
87
+ error?: string | undefined;
88
+ identity?: string | undefined;
89
+ }>;
90
+ //# sourceMappingURL=cosign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosign.d.ts","sourceRoot":"","sources":["../../src/sigstore/cosign.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAQrD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,MAAM,EAAE,cAAc,CAAC;IACvB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAA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