@aztec/wallet-sdk 0.0.1-commit.3469e52 → 0.0.1-commit.59e663cd
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 +217 -294
- package/dest/base-wallet/base_wallet.d.ts +4 -5
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +10 -9
- package/dest/crypto.d.ts +59 -50
- package/dest/crypto.d.ts.map +1 -1
- package/dest/crypto.js +202 -108
- package/dest/emoji_alphabet.d.ts +35 -0
- package/dest/emoji_alphabet.d.ts.map +1 -0
- package/dest/emoji_alphabet.js +299 -0
- package/dest/extension/handlers/background_connection_handler.d.ts +158 -0
- package/dest/extension/handlers/background_connection_handler.d.ts.map +1 -0
- package/dest/extension/handlers/background_connection_handler.js +258 -0
- package/dest/extension/handlers/content_script_connection_handler.d.ts +56 -0
- package/dest/extension/handlers/content_script_connection_handler.d.ts.map +1 -0
- package/dest/extension/handlers/content_script_connection_handler.js +174 -0
- package/dest/extension/handlers/index.d.ts +12 -0
- package/dest/extension/handlers/index.d.ts.map +1 -0
- package/dest/extension/handlers/index.js +10 -0
- package/dest/extension/handlers/internal_message_types.d.ts +63 -0
- package/dest/extension/handlers/internal_message_types.d.ts.map +1 -0
- package/dest/extension/handlers/internal_message_types.js +22 -0
- package/dest/extension/provider/extension_provider.d.ts +107 -0
- package/dest/extension/provider/extension_provider.d.ts.map +1 -0
- package/dest/extension/provider/extension_provider.js +160 -0
- package/dest/extension/provider/extension_wallet.d.ts +131 -0
- package/dest/extension/provider/extension_wallet.d.ts.map +1 -0
- package/dest/{providers/extension → extension/provider}/extension_wallet.js +48 -95
- package/dest/extension/provider/index.d.ts +3 -0
- package/dest/extension/provider/index.d.ts.map +1 -0
- package/dest/{providers/extension → extension/provider}/index.js +0 -2
- package/dest/manager/index.d.ts +2 -8
- package/dest/manager/index.d.ts.map +1 -1
- package/dest/manager/index.js +0 -6
- package/dest/manager/types.d.ts +88 -6
- package/dest/manager/types.d.ts.map +1 -1
- package/dest/manager/types.js +17 -1
- package/dest/manager/wallet_manager.d.ts +50 -7
- package/dest/manager/wallet_manager.d.ts.map +1 -1
- package/dest/manager/wallet_manager.js +174 -44
- package/dest/types.d.ts +43 -12
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -2
- package/package.json +10 -9
- package/src/base-wallet/base_wallet.ts +16 -17
- package/src/crypto.ts +237 -113
- package/src/emoji_alphabet.ts +317 -0
- package/src/extension/handlers/background_connection_handler.ts +423 -0
- package/src/extension/handlers/content_script_connection_handler.ts +246 -0
- package/src/extension/handlers/index.ts +25 -0
- package/src/extension/handlers/internal_message_types.ts +69 -0
- package/src/extension/provider/extension_provider.ts +233 -0
- package/src/{providers/extension → extension/provider}/extension_wallet.ts +52 -110
- package/src/extension/provider/index.ts +7 -0
- package/src/manager/index.ts +2 -10
- package/src/manager/types.ts +91 -5
- package/src/manager/wallet_manager.ts +192 -46
- package/src/types.ts +44 -10
- package/dest/providers/extension/extension_provider.d.ts +0 -63
- package/dest/providers/extension/extension_provider.d.ts.map +0 -1
- package/dest/providers/extension/extension_provider.js +0 -124
- package/dest/providers/extension/extension_wallet.d.ts +0 -155
- package/dest/providers/extension/extension_wallet.d.ts.map +0 -1
- package/dest/providers/extension/index.d.ts +0 -6
- package/dest/providers/extension/index.d.ts.map +0 -1
- package/src/providers/extension/extension_provider.ts +0 -167
- package/src/providers/extension/index.ts +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"base_w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AAE,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAE9F;IAEK,gBAAgB,CAAC,CAAC,EACtB,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAe5B;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;OAe9C;IAEK,wBAAwB,CAAC,EAAE,EAAE,EAAE;;;OAMpC;CACF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
1
3
|
import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
2
4
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
3
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -190,7 +192,13 @@ import { inspect } from 'util';
|
|
|
190
192
|
throw this.contextualizeError(err, inspect(tx));
|
|
191
193
|
});
|
|
192
194
|
this.log.info(`Sent transaction ${txHash}`);
|
|
193
|
-
return txHash
|
|
195
|
+
// If wait is NO_WAIT, return txHash immediately
|
|
196
|
+
if (opts.wait === NO_WAIT) {
|
|
197
|
+
return txHash;
|
|
198
|
+
}
|
|
199
|
+
// Otherwise, wait for the full receipt (default behavior on wait: undefined)
|
|
200
|
+
const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
|
|
201
|
+
return await waitForTx(this.aztecNode, txHash, waitOpts);
|
|
194
202
|
}
|
|
195
203
|
contextualizeError(err, ...context) {
|
|
196
204
|
let contextStr = '';
|
|
@@ -208,9 +216,6 @@ import { inspect } from 'util';
|
|
|
208
216
|
simulateUtility(call, authwits) {
|
|
209
217
|
return this.pxe.simulateUtility(call, authwits);
|
|
210
218
|
}
|
|
211
|
-
getTxReceipt(txHash) {
|
|
212
|
-
return this.aztecNode.getTxReceipt(txHash);
|
|
213
|
-
}
|
|
214
219
|
async getPrivateEvents(eventDef, eventFilter) {
|
|
215
220
|
const pxeEvents = await this.pxe.getPrivateEvents(eventDef.eventSelector, eventFilter);
|
|
216
221
|
const decodedEvents = pxeEvents.map((pxeEvent)=>{
|
|
@@ -231,16 +236,12 @@ import { inspect } from 'util';
|
|
|
231
236
|
const instance = await this.pxe.getContractInstance(address);
|
|
232
237
|
const initNullifier = await siloNullifier(address, address.toField());
|
|
233
238
|
const publiclyRegisteredContract = await this.aztecNode.getContract(address);
|
|
234
|
-
const
|
|
235
|
-
this.aztecNode.getNullifierMembershipWitness('latest', initNullifier),
|
|
236
|
-
publiclyRegisteredContract ? this.aztecNode.getContractClass(publiclyRegisteredContract.currentContractClassId || instance?.currentContractClassId) : undefined
|
|
237
|
-
]);
|
|
239
|
+
const initNullifierMembershipWitness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
|
|
238
240
|
const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
|
|
239
241
|
return {
|
|
240
242
|
instance: instance ?? undefined,
|
|
241
243
|
isContractInitialized: !!initNullifierMembershipWitness,
|
|
242
244
|
isContractPublished: !!publiclyRegisteredContract,
|
|
243
|
-
isContractClassPubliclyRegistered: !!publiclyRegisteredContractClass,
|
|
244
245
|
isContractUpdated: !!isContractUpdated,
|
|
245
246
|
updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
|
|
246
247
|
};
|
package/dest/crypto.d.ts
CHANGED
|
@@ -36,11 +36,23 @@ export interface SecureKeyPair {
|
|
|
36
36
|
/** Private key - keep secret, used for key derivation */
|
|
37
37
|
privateKey: CryptoKey;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Session keys derived from ECDH key exchange.
|
|
41
|
+
*
|
|
42
|
+
* Contains both the encryption key and the verification hash (verificationHash)
|
|
43
|
+
* computed from a separate HMAC key.
|
|
44
|
+
*/
|
|
45
|
+
export interface SessionKeys {
|
|
46
|
+
/** AES-256-GCM key for message encryption/decryption */
|
|
47
|
+
encryptionKey: CryptoKey;
|
|
48
|
+
/** Hex-encoded verificationHash for verification */
|
|
49
|
+
verificationHash: string;
|
|
50
|
+
}
|
|
39
51
|
/**
|
|
40
52
|
* Generates an ECDH P-256 key pair for key exchange.
|
|
41
53
|
*
|
|
42
|
-
* The generated key pair can be used to derive
|
|
43
|
-
* party's public key using {@link
|
|
54
|
+
* The generated key pair can be used to derive session keys with another
|
|
55
|
+
* party's public key using {@link deriveSessionKeys}.
|
|
44
56
|
*
|
|
45
57
|
* @returns A new ECDH key pair
|
|
46
58
|
*
|
|
@@ -72,65 +84,71 @@ export declare function exportPublicKey(publicKey: CryptoKey): Promise<ExportedP
|
|
|
72
84
|
/**
|
|
73
85
|
* Imports a public key from JWK format.
|
|
74
86
|
*
|
|
75
|
-
* Used to import the other party's public key for deriving
|
|
87
|
+
* Used to import the other party's public key for deriving session keys.
|
|
76
88
|
*
|
|
77
89
|
* @param exported - The public key in JWK format
|
|
78
|
-
* @returns A CryptoKey that can be used with {@link
|
|
90
|
+
* @returns A CryptoKey that can be used with {@link deriveSessionKeys}
|
|
79
91
|
*
|
|
80
92
|
* @example
|
|
81
93
|
* ```typescript
|
|
82
|
-
* //
|
|
83
|
-
* const
|
|
84
|
-
* const
|
|
94
|
+
* // App side: receive wallet's public key and derive session
|
|
95
|
+
* const walletPublicKey = await importPublicKey(receivedWalletKey);
|
|
96
|
+
* const session = await deriveSessionKeys(appKeyPair, walletPublicKey, true);
|
|
85
97
|
* ```
|
|
86
98
|
*/
|
|
87
99
|
export declare function importPublicKey(exported: ExportedPublicKey): Promise<CryptoKey>;
|
|
88
100
|
/**
|
|
89
|
-
* Derives
|
|
101
|
+
* Derives session keys from ECDH key exchange using HKDF.
|
|
102
|
+
*
|
|
103
|
+
* This is the main key derivation function that produces:
|
|
104
|
+
* 1. An AES-256-GCM encryption key (first 256 bits)
|
|
105
|
+
* 2. An HMAC key for verificationHash computation (second 256 bits)
|
|
106
|
+
* 3. A verificationHash computed as HMAC(hmacKey, "aztec-wallet-verification-verificationHash")
|
|
90
107
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
108
|
+
* The keys are derived using a single HKDF call that produces 512 bits,
|
|
109
|
+
* then split into the two keys.
|
|
93
110
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
96
|
-
* @
|
|
111
|
+
* @param ownKeyPair - The caller's ECDH key pair (private for ECDH, public for salt)
|
|
112
|
+
* @param peerPublicKey - The peer's ECDH public key (for ECDH and salt)
|
|
113
|
+
* @param isApp - true if caller is the app, false if caller is the wallet
|
|
114
|
+
* @returns Session keys containing encryption key and verificationHash
|
|
97
115
|
*
|
|
98
116
|
* @example
|
|
99
117
|
* ```typescript
|
|
100
|
-
* //
|
|
101
|
-
* const
|
|
102
|
-
*
|
|
103
|
-
*
|
|
118
|
+
* // App side
|
|
119
|
+
* const sessionA = await deriveSessionKeys(appKeyPair, walletPublicKey, true);
|
|
120
|
+
* // Wallet side
|
|
121
|
+
* const sessionB = await deriveSessionKeys(walletKeyPair, appPublicKey, false);
|
|
122
|
+
* // sessionA.verificationHash === sessionB.verificationHash
|
|
104
123
|
* ```
|
|
105
124
|
*/
|
|
106
|
-
export declare function
|
|
125
|
+
export declare function deriveSessionKeys(ownKeyPair: SecureKeyPair, peerPublicKey: CryptoKey, isApp: boolean): Promise<SessionKeys>;
|
|
107
126
|
/**
|
|
108
127
|
* Encrypts data using AES-256-GCM.
|
|
109
128
|
*
|
|
110
|
-
*
|
|
111
|
-
* generated for each encryption operation.
|
|
129
|
+
* A random 12-byte IV is generated for each encryption operation.
|
|
112
130
|
*
|
|
113
131
|
* AES-GCM provides both confidentiality and authenticity - any tampering
|
|
114
132
|
* with the ciphertext will cause decryption to fail.
|
|
115
133
|
*
|
|
116
|
-
* @param key - The AES-GCM key (from {@link
|
|
117
|
-
* @param data - The data to encrypt (
|
|
134
|
+
* @param key - The AES-GCM key (from {@link deriveSessionKeys})
|
|
135
|
+
* @param data - The string data to encrypt (caller is responsible for serialization)
|
|
118
136
|
* @returns The encrypted payload with IV and ciphertext
|
|
119
137
|
*
|
|
120
138
|
* @example
|
|
121
139
|
* ```typescript
|
|
122
|
-
* const encrypted = await encrypt(
|
|
140
|
+
* const encrypted = await encrypt(session.encryptionKey, JSON.stringify({ action: 'transfer', amount: 100 }));
|
|
123
141
|
* // encrypted.iv and encrypted.ciphertext are base64 strings
|
|
124
142
|
* ```
|
|
125
143
|
*/
|
|
126
|
-
export declare function encrypt(key: CryptoKey, data:
|
|
144
|
+
export declare function encrypt(key: CryptoKey, data: string): Promise<EncryptedPayload>;
|
|
127
145
|
/**
|
|
128
146
|
* Decrypts data using AES-256-GCM.
|
|
129
147
|
*
|
|
130
148
|
* The decrypted data is JSON parsed before returning.
|
|
131
149
|
*
|
|
132
150
|
* @typeParam T - The expected type of the decrypted data
|
|
133
|
-
* @param key - The AES-GCM key (from {@link
|
|
151
|
+
* @param key - The AES-GCM key (from {@link deriveSessionKeys})
|
|
134
152
|
* @param payload - The encrypted payload from {@link encrypt}
|
|
135
153
|
* @returns The decrypted and parsed data
|
|
136
154
|
*
|
|
@@ -138,46 +156,37 @@ export declare function encrypt(key: CryptoKey, data: unknown): Promise<Encrypte
|
|
|
138
156
|
*
|
|
139
157
|
* @example
|
|
140
158
|
* ```typescript
|
|
141
|
-
* const decrypted = await decrypt<{ action: string; amount: number }>(
|
|
159
|
+
* const decrypted = await decrypt<{ action: string; amount: number }>(session.encryptionKey, encrypted);
|
|
142
160
|
* console.log(decrypted.action); // 'transfer'
|
|
143
161
|
* ```
|
|
144
162
|
*/
|
|
145
163
|
export declare function decrypt<T = unknown>(key: CryptoKey, payload: EncryptedPayload): Promise<T>;
|
|
146
164
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* This extracts the raw key material and hashes it with SHA-256,
|
|
150
|
-
* returning the first 16 bytes as a hex string.
|
|
151
|
-
*
|
|
152
|
-
* @param sharedKey - The AES-GCM shared key (must be extractable)
|
|
153
|
-
* @returns A hex string representation of the hash
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* const hash = await hashSharedSecret(sharedKey);
|
|
158
|
-
* const emoji = hashToEmoji(hash);
|
|
159
|
-
* ```
|
|
165
|
+
* Default grid size for emoji verification display.
|
|
166
|
+
* 3x3 grid = 9 emojis = 72 bits of security.
|
|
160
167
|
*/
|
|
161
|
-
export declare
|
|
168
|
+
export declare const DEFAULT_EMOJI_GRID_SIZE = 9;
|
|
162
169
|
/**
|
|
163
170
|
* Converts a hex hash to an emoji sequence for visual verification.
|
|
164
171
|
*
|
|
165
|
-
* This is used for
|
|
166
|
-
* independently compute the same emoji sequence from the
|
|
172
|
+
* This is used for verification - both the dApp and wallet
|
|
173
|
+
* independently compute the same emoji sequence from the derived keys.
|
|
167
174
|
* Users can visually compare the sequences to detect interception.
|
|
168
175
|
*
|
|
169
|
-
*
|
|
176
|
+
* With a 256-emoji alphabet and 9 emojis (3x3 grid), this provides
|
|
177
|
+
* 72 bits of security (9 * 8 = 72 bits), making brute-force attacks
|
|
178
|
+
* computationally infeasible.
|
|
170
179
|
*
|
|
171
|
-
* @param hash - Hex string from
|
|
172
|
-
* @param
|
|
180
|
+
* @param hash - Hex string from verification hash (64 chars = 32 bytes)
|
|
181
|
+
* @param count - Number of emojis to generate (default: 9 for 3x3 grid)
|
|
173
182
|
* @returns A string of emojis representing the hash
|
|
174
183
|
*
|
|
175
184
|
* @example
|
|
176
185
|
* ```typescript
|
|
177
|
-
* const
|
|
178
|
-
* const emoji = hashToEmoji(
|
|
179
|
-
* // Display to user for verification
|
|
186
|
+
* const session = await deriveSessionKeys(...);
|
|
187
|
+
* const emoji = hashToEmoji(session.verificationHash); // e.g., "🔵🦋🎯🐼🌟🎲🦊🐸💎"
|
|
188
|
+
* // Display as 3x3 grid to user for verification
|
|
180
189
|
* ```
|
|
181
190
|
*/
|
|
182
|
-
export declare function hashToEmoji(hash: string,
|
|
183
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
191
|
+
export declare function hashToEmoji(hash: string, count?: number): string;
|
|
192
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3J5cHRvLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY3J5cHRvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQThEQTs7OztHQUlHO0FBQ0gsTUFBTSxXQUFXLGlCQUFpQjtJQUNoQyxnREFBZ0Q7SUFDaEQsR0FBRyxFQUFFLE1BQU0sQ0FBQztJQUNaLGtDQUFrQztJQUNsQyxHQUFHLEVBQUUsTUFBTSxDQUFDO0lBQ1osdUNBQXVDO0lBQ3ZDLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDVix1Q0FBdUM7SUFDdkMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUNYO0FBRUQ7Ozs7R0FJRztBQUNILE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsdURBQXVEO0lBQ3ZELEVBQUUsRUFBRSxNQUFNLENBQUM7SUFDWCxrQ0FBa0M7SUFDbEMsVUFBVSxFQUFFLE1BQU0sQ0FBQztDQUNwQjtBQUVEOzs7OztHQUtHO0FBQ0gsTUFBTSxXQUFXLGFBQWE7SUFDNUIsaUNBQWlDO0lBQ2pDLFNBQVMsRUFBRSxTQUFTLENBQUM7SUFDckIseURBQXlEO0lBQ3pELFVBQVUsRUFBRSxTQUFTLENBQUM7Q0FDdkI7QUFFRDs7Ozs7R0FLRztBQUNILE1BQU0sV0FBVyxXQUFXO0lBQzFCLHdEQUF3RDtJQUN4RCxhQUFhLEVBQUUsU0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UksQ0FBQztBQUV6Qzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBcUJHO0FBQ0gsd0JBQWdCLFdBQVcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEtBQUssR0FBRSxNQUFnQyxHQUFHLE1BQU0sQ0FPekYifQ==
|
package/dest/crypto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AA8DA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,CAAC,EAAE,MAAM,CAAC;IACV,uCAAuC;IACvC,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,yDAAyD;IACzD,UAAU,EAAE,SAAS,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,aAAa,EAAE,SAAS,CAAC;IACzB,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,CAa9D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQtF;AAED;;;;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