@metamask-previews/eth-snap-keyring 22.3.0-e51c895 → 22.4.0-5951828
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/CHANGELOG.md +21 -1
- package/dist/SnapKeyring.cjs +31 -16
- package/dist/SnapKeyring.cjs.map +1 -1
- package/dist/SnapKeyring.d.cts +1 -1
- package/dist/SnapKeyring.d.cts.map +1 -1
- package/dist/SnapKeyring.d.mts +1 -1
- package/dist/SnapKeyring.d.mts.map +1 -1
- package/dist/SnapKeyring.mjs +31 -16
- package/dist/SnapKeyring.mjs.map +1 -1
- package/dist/SnapKeyringV1.cjs +16 -2
- package/dist/SnapKeyringV1.cjs.map +1 -1
- package/dist/SnapKeyringV1.d.cts +21 -2
- package/dist/SnapKeyringV1.d.cts.map +1 -1
- package/dist/SnapKeyringV1.d.mts +21 -2
- package/dist/SnapKeyringV1.d.mts.map +1 -1
- package/dist/SnapKeyringV1.mjs +16 -2
- package/dist/SnapKeyringV1.mjs.map +1 -1
- package/dist/events.cjs +4 -5
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +4 -4
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +4 -4
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +1 -2
- package/dist/events.mjs.map +1 -1
- package/dist/v2/SnapKeyring.cjs +202 -58
- package/dist/v2/SnapKeyring.cjs.map +1 -1
- package/dist/v2/SnapKeyring.d.cts +67 -24
- package/dist/v2/SnapKeyring.d.cts.map +1 -1
- package/dist/v2/SnapKeyring.d.mts +67 -24
- package/dist/v2/SnapKeyring.d.mts.map +1 -1
- package/dist/v2/SnapKeyring.mjs +202 -58
- package/dist/v2/SnapKeyring.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
2
2
|
import type { CreateAccountOptions, Keyring, KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
3
3
|
import type { AccountId } from "@metamask/keyring-utils";
|
|
4
|
+
import type { SnapId } from "@metamask/snaps-sdk";
|
|
4
5
|
import type { Infer } from "@metamask/superstruct";
|
|
5
6
|
import type { Json } from "@metamask/utils";
|
|
7
|
+
import type { SnapKeyringMessenger } from "../SnapKeyringMessenger.cjs";
|
|
6
8
|
import { SnapKeyringV1 } from "../SnapKeyringV1.cjs";
|
|
7
|
-
import type { SnapKeyringV1Callbacks
|
|
9
|
+
import type { SnapKeyringV1Callbacks } from "../SnapKeyringV1.cjs";
|
|
10
|
+
/**
|
|
11
|
+
* Default, empty capabilities used until the snap manifest is read on
|
|
12
|
+
* `deserialize`. Typed (no cast) so that adding a new required
|
|
13
|
+
* `KeyringCapabilities` field surfaces here as a compile error.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EMPTY_CAPABILITIES: KeyringCapabilities;
|
|
8
16
|
/**
|
|
9
17
|
* Superstruct schema for {@link SnapKeyringState}.
|
|
10
18
|
*
|
|
@@ -46,7 +54,10 @@ export declare const SnapKeyringStateStruct: import("@metamask/superstruct").Str
|
|
|
46
54
|
type: "private-key";
|
|
47
55
|
} | {
|
|
48
56
|
type: "custom";
|
|
49
|
-
};
|
|
57
|
+
}; /**
|
|
58
|
+
* V1 instance, present only when the snap does not declare v2 capabilities.
|
|
59
|
+
* Created on `deserialize()` after reading the snap manifest.
|
|
60
|
+
*/
|
|
50
61
|
exportable?: boolean;
|
|
51
62
|
};
|
|
52
63
|
methods: string[];
|
|
@@ -86,7 +97,10 @@ export declare const SnapKeyringStateStruct: import("@metamask/superstruct").Str
|
|
|
86
97
|
type: "private-key";
|
|
87
98
|
} | {
|
|
88
99
|
type: "custom";
|
|
89
|
-
};
|
|
100
|
+
}; /**
|
|
101
|
+
* V1 instance, present only when the snap does not declare v2 capabilities.
|
|
102
|
+
* Created on `deserialize()` after reading the snap manifest.
|
|
103
|
+
*/
|
|
90
104
|
exportable?: boolean;
|
|
91
105
|
};
|
|
92
106
|
methods: string[];
|
|
@@ -118,8 +132,10 @@ export type SnapKeyringCallbacks = SnapKeyringV1Callbacks & {
|
|
|
118
132
|
*/
|
|
119
133
|
withLock?: <Result>(callback: () => Promise<Result>) => Promise<Result>;
|
|
120
134
|
};
|
|
121
|
-
type SnapKeyringOptions =
|
|
135
|
+
type SnapKeyringOptions = {
|
|
136
|
+
messenger: SnapKeyringMessenger;
|
|
122
137
|
callbacks: SnapKeyringCallbacks;
|
|
138
|
+
isAnyAccountTypeAllowed?: boolean;
|
|
123
139
|
};
|
|
124
140
|
/**
|
|
125
141
|
* Checks if a given keyring is a Snap keyring (v2).
|
|
@@ -129,17 +145,15 @@ type SnapKeyringOptions = Omit<SnapKeyringV1Options, 'callbacks'> & {
|
|
|
129
145
|
*/
|
|
130
146
|
export declare function isSnapKeyring(keyring: Keyring): keyring is SnapKeyring;
|
|
131
147
|
/**
|
|
132
|
-
* Per-snap keyring
|
|
148
|
+
* Per-snap keyring that implements `Keyring` (v2).
|
|
133
149
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* The `KeyringAccountRegistry`, snap client, and messenger are all inherited
|
|
140
|
-
* from `SnapKeyringV1` so there is no duplicated state.
|
|
150
|
+
* Owns the account registry and messenger. For v1 snaps (those that do not
|
|
151
|
+
* declare `endowment:keyring` capabilities in their manifest), a
|
|
152
|
+
* {@link SnapKeyringV1} instance is created on `deserialize` and held under
|
|
153
|
+
* {@link SnapKeyring.v1}. V2 snaps have `v1 === undefined` and communicate
|
|
154
|
+
* directly through the v2 client without the `{ pending, result }` envelope.
|
|
141
155
|
*/
|
|
142
|
-
export declare class SnapKeyring
|
|
156
|
+
export declare class SnapKeyring implements Keyring {
|
|
143
157
|
#private;
|
|
144
158
|
readonly type: "snap";
|
|
145
159
|
static readonly type: "snap";
|
|
@@ -148,12 +162,38 @@ export declare class SnapKeyring extends SnapKeyringV1 implements Keyring {
|
|
|
148
162
|
* by the parent when snap metadata becomes available.
|
|
149
163
|
*/
|
|
150
164
|
capabilities: KeyringCapabilities;
|
|
151
|
-
constructor(
|
|
165
|
+
constructor({ messenger, callbacks, isAnyAccountTypeAllowed, }: SnapKeyringOptions);
|
|
166
|
+
/**
|
|
167
|
+
* Gets the v1 instance for this snap, or `undefined` if the snap is v2-only.
|
|
168
|
+
*
|
|
169
|
+
* @returns The v1 instance, or `undefined` if the snap is v2-only.
|
|
170
|
+
*
|
|
171
|
+
* Use this to make v1 calls explicit:
|
|
172
|
+
* ```ts
|
|
173
|
+
* keyring.v1?.signTransaction(account, tx);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
get v1(): SnapKeyringV1 | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* The snap ID this instance is scoped to.
|
|
179
|
+
*
|
|
180
|
+
* @returns The snap ID.
|
|
181
|
+
* @throws If the keyring has not been initialized yet.
|
|
182
|
+
*/
|
|
183
|
+
get snapId(): SnapId;
|
|
184
|
+
/**
|
|
185
|
+
* Bind this keyring to a snap ID and initialize the v2 client.
|
|
186
|
+
*
|
|
187
|
+
* Idempotent for the same `snapId`; throws if called again with a different
|
|
188
|
+
* one to prevent accidentally swapping a keyring's identity.
|
|
189
|
+
*
|
|
190
|
+
* @param snapId - The snap ID to bind to.
|
|
191
|
+
*/
|
|
192
|
+
protected bindSnapId(snapId: SnapId): void;
|
|
152
193
|
/**
|
|
153
|
-
* Destroy this keyring.
|
|
194
|
+
* Destroy this keyring, rejecting any pending v1 requests.
|
|
154
195
|
*
|
|
155
|
-
*
|
|
156
|
-
* requests inherited from the v1 flow.
|
|
196
|
+
* @returns A promise that resolves when the keyring is destroyed.
|
|
157
197
|
*/
|
|
158
198
|
destroy(): Promise<void>;
|
|
159
199
|
/**
|
|
@@ -197,12 +237,13 @@ export declare class SnapKeyring extends SnapKeyringV1 implements Keyring {
|
|
|
197
237
|
/**
|
|
198
238
|
* Submits a request to the keyring.
|
|
199
239
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
240
|
+
* For v1 snaps (those without declared capabilities), delegates to the v1
|
|
241
|
+
* event-driven flow that handles the `{ pending, result }` envelope.
|
|
242
|
+
* For v2 snaps, calls the snap directly via the v2 client which returns
|
|
243
|
+
* `Json` with no envelope.
|
|
203
244
|
*
|
|
204
245
|
* @param request - The keyring request to submit.
|
|
205
|
-
* @param request.id - The request ID
|
|
246
|
+
* @param request.id - The request ID.
|
|
206
247
|
* @param request.origin - The sender origin.
|
|
207
248
|
* @param request.scope - The CAIP-2 chain ID.
|
|
208
249
|
* @param request.account - The account ID.
|
|
@@ -287,9 +328,11 @@ export declare class SnapKeyring extends SnapKeyringV1 implements Keyring {
|
|
|
287
328
|
/**
|
|
288
329
|
* Restore this keyring from a serialized state.
|
|
289
330
|
*
|
|
290
|
-
* Validates the payload (accepting both v1 and v2
|
|
291
|
-
* v1 accounts to v2, then replaces the registry.
|
|
292
|
-
*
|
|
331
|
+
* Validates the payload (accepting both v1 and v2 account shapes), migrates
|
|
332
|
+
* any v1 accounts to v2, then replaces the registry. Also determines whether
|
|
333
|
+
* the snap is v1 or v2 by reading its manifest capabilities: if no
|
|
334
|
+
* capabilities are declared, a {@link SnapKeyringV1} instance is created and
|
|
335
|
+
* held under {@link SnapKeyring.v1}.
|
|
293
336
|
*
|
|
294
337
|
* @param state - The state to deserialize.
|
|
295
338
|
* @returns A promise that resolves when deserialization is complete.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnapKeyring.d.cts","sourceRoot":"","sources":["../../src/v2/SnapKeyring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D,OAAO,KAAK,EACV,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACpB,iCAAiC;
|
|
1
|
+
{"version":3,"file":"SnapKeyring.d.cts","sourceRoot":"","sources":["../../src/v2/SnapKeyring.ts"],"names":[],"mappings":"AAAA,OAAO,KA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IAQzC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO;IASrC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO;IAIlC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS;IAIxD;;;;;;;;OAQG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAc5D;;;;;;;;OAQG;IACH,QAAQ,IAAI,cAAc,EAAE;IAI5B;;;;;;;;OAQG;IACG,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAY5C;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CA0G9C"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
2
2
|
import type { CreateAccountOptions, Keyring, KeyringCapabilities } from "@metamask/keyring-api/v2";
|
|
3
3
|
import type { AccountId } from "@metamask/keyring-utils";
|
|
4
|
+
import type { SnapId } from "@metamask/snaps-sdk";
|
|
4
5
|
import type { Infer } from "@metamask/superstruct";
|
|
5
6
|
import type { Json } from "@metamask/utils";
|
|
7
|
+
import type { SnapKeyringMessenger } from "../SnapKeyringMessenger.mjs";
|
|
6
8
|
import { SnapKeyringV1 } from "../SnapKeyringV1.mjs";
|
|
7
|
-
import type { SnapKeyringV1Callbacks
|
|
9
|
+
import type { SnapKeyringV1Callbacks } from "../SnapKeyringV1.mjs";
|
|
10
|
+
/**
|
|
11
|
+
* Default, empty capabilities used until the snap manifest is read on
|
|
12
|
+
* `deserialize`. Typed (no cast) so that adding a new required
|
|
13
|
+
* `KeyringCapabilities` field surfaces here as a compile error.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EMPTY_CAPABILITIES: KeyringCapabilities;
|
|
8
16
|
/**
|
|
9
17
|
* Superstruct schema for {@link SnapKeyringState}.
|
|
10
18
|
*
|
|
@@ -46,7 +54,10 @@ export declare const SnapKeyringStateStruct: import("@metamask/superstruct").Str
|
|
|
46
54
|
type: "private-key";
|
|
47
55
|
} | {
|
|
48
56
|
type: "custom";
|
|
49
|
-
};
|
|
57
|
+
}; /**
|
|
58
|
+
* V1 instance, present only when the snap does not declare v2 capabilities.
|
|
59
|
+
* Created on `deserialize()` after reading the snap manifest.
|
|
60
|
+
*/
|
|
50
61
|
exportable?: boolean;
|
|
51
62
|
};
|
|
52
63
|
methods: string[];
|
|
@@ -86,7 +97,10 @@ export declare const SnapKeyringStateStruct: import("@metamask/superstruct").Str
|
|
|
86
97
|
type: "private-key";
|
|
87
98
|
} | {
|
|
88
99
|
type: "custom";
|
|
89
|
-
};
|
|
100
|
+
}; /**
|
|
101
|
+
* V1 instance, present only when the snap does not declare v2 capabilities.
|
|
102
|
+
* Created on `deserialize()` after reading the snap manifest.
|
|
103
|
+
*/
|
|
90
104
|
exportable?: boolean;
|
|
91
105
|
};
|
|
92
106
|
methods: string[];
|
|
@@ -118,8 +132,10 @@ export type SnapKeyringCallbacks = SnapKeyringV1Callbacks & {
|
|
|
118
132
|
*/
|
|
119
133
|
withLock?: <Result>(callback: () => Promise<Result>) => Promise<Result>;
|
|
120
134
|
};
|
|
121
|
-
type SnapKeyringOptions =
|
|
135
|
+
type SnapKeyringOptions = {
|
|
136
|
+
messenger: SnapKeyringMessenger;
|
|
122
137
|
callbacks: SnapKeyringCallbacks;
|
|
138
|
+
isAnyAccountTypeAllowed?: boolean;
|
|
123
139
|
};
|
|
124
140
|
/**
|
|
125
141
|
* Checks if a given keyring is a Snap keyring (v2).
|
|
@@ -129,17 +145,15 @@ type SnapKeyringOptions = Omit<SnapKeyringV1Options, 'callbacks'> & {
|
|
|
129
145
|
*/
|
|
130
146
|
export declare function isSnapKeyring(keyring: Keyring): keyring is SnapKeyring;
|
|
131
147
|
/**
|
|
132
|
-
* Per-snap keyring
|
|
148
|
+
* Per-snap keyring that implements `Keyring` (v2).
|
|
133
149
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* The `KeyringAccountRegistry`, snap client, and messenger are all inherited
|
|
140
|
-
* from `SnapKeyringV1` so there is no duplicated state.
|
|
150
|
+
* Owns the account registry and messenger. For v1 snaps (those that do not
|
|
151
|
+
* declare `endowment:keyring` capabilities in their manifest), a
|
|
152
|
+
* {@link SnapKeyringV1} instance is created on `deserialize` and held under
|
|
153
|
+
* {@link SnapKeyring.v1}. V2 snaps have `v1 === undefined` and communicate
|
|
154
|
+
* directly through the v2 client without the `{ pending, result }` envelope.
|
|
141
155
|
*/
|
|
142
|
-
export declare class SnapKeyring
|
|
156
|
+
export declare class SnapKeyring implements Keyring {
|
|
143
157
|
#private;
|
|
144
158
|
readonly type: "snap";
|
|
145
159
|
static readonly type: "snap";
|
|
@@ -148,12 +162,38 @@ export declare class SnapKeyring extends SnapKeyringV1 implements Keyring {
|
|
|
148
162
|
* by the parent when snap metadata becomes available.
|
|
149
163
|
*/
|
|
150
164
|
capabilities: KeyringCapabilities;
|
|
151
|
-
constructor(
|
|
165
|
+
constructor({ messenger, callbacks, isAnyAccountTypeAllowed, }: SnapKeyringOptions);
|
|
166
|
+
/**
|
|
167
|
+
* Gets the v1 instance for this snap, or `undefined` if the snap is v2-only.
|
|
168
|
+
*
|
|
169
|
+
* @returns The v1 instance, or `undefined` if the snap is v2-only.
|
|
170
|
+
*
|
|
171
|
+
* Use this to make v1 calls explicit:
|
|
172
|
+
* ```ts
|
|
173
|
+
* keyring.v1?.signTransaction(account, tx);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
get v1(): SnapKeyringV1 | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* The snap ID this instance is scoped to.
|
|
179
|
+
*
|
|
180
|
+
* @returns The snap ID.
|
|
181
|
+
* @throws If the keyring has not been initialized yet.
|
|
182
|
+
*/
|
|
183
|
+
get snapId(): SnapId;
|
|
184
|
+
/**
|
|
185
|
+
* Bind this keyring to a snap ID and initialize the v2 client.
|
|
186
|
+
*
|
|
187
|
+
* Idempotent for the same `snapId`; throws if called again with a different
|
|
188
|
+
* one to prevent accidentally swapping a keyring's identity.
|
|
189
|
+
*
|
|
190
|
+
* @param snapId - The snap ID to bind to.
|
|
191
|
+
*/
|
|
192
|
+
protected bindSnapId(snapId: SnapId): void;
|
|
152
193
|
/**
|
|
153
|
-
* Destroy this keyring.
|
|
194
|
+
* Destroy this keyring, rejecting any pending v1 requests.
|
|
154
195
|
*
|
|
155
|
-
*
|
|
156
|
-
* requests inherited from the v1 flow.
|
|
196
|
+
* @returns A promise that resolves when the keyring is destroyed.
|
|
157
197
|
*/
|
|
158
198
|
destroy(): Promise<void>;
|
|
159
199
|
/**
|
|
@@ -197,12 +237,13 @@ export declare class SnapKeyring extends SnapKeyringV1 implements Keyring {
|
|
|
197
237
|
/**
|
|
198
238
|
* Submits a request to the keyring.
|
|
199
239
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
240
|
+
* For v1 snaps (those without declared capabilities), delegates to the v1
|
|
241
|
+
* event-driven flow that handles the `{ pending, result }` envelope.
|
|
242
|
+
* For v2 snaps, calls the snap directly via the v2 client which returns
|
|
243
|
+
* `Json` with no envelope.
|
|
203
244
|
*
|
|
204
245
|
* @param request - The keyring request to submit.
|
|
205
|
-
* @param request.id - The request ID
|
|
246
|
+
* @param request.id - The request ID.
|
|
206
247
|
* @param request.origin - The sender origin.
|
|
207
248
|
* @param request.scope - The CAIP-2 chain ID.
|
|
208
249
|
* @param request.account - The account ID.
|
|
@@ -287,9 +328,11 @@ export declare class SnapKeyring extends SnapKeyringV1 implements Keyring {
|
|
|
287
328
|
/**
|
|
288
329
|
* Restore this keyring from a serialized state.
|
|
289
330
|
*
|
|
290
|
-
* Validates the payload (accepting both v1 and v2
|
|
291
|
-
* v1 accounts to v2, then replaces the registry.
|
|
292
|
-
*
|
|
331
|
+
* Validates the payload (accepting both v1 and v2 account shapes), migrates
|
|
332
|
+
* any v1 accounts to v2, then replaces the registry. Also determines whether
|
|
333
|
+
* the snap is v1 or v2 by reading its manifest capabilities: if no
|
|
334
|
+
* capabilities are declared, a {@link SnapKeyringV1} instance is created and
|
|
335
|
+
* held under {@link SnapKeyring.v1}.
|
|
293
336
|
*
|
|
294
337
|
* @param state - The state to deserialize.
|
|
295
338
|
* @returns A promise that resolves when deserialization is complete.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnapKeyring.d.mts","sourceRoot":"","sources":["../../src/v2/SnapKeyring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D,OAAO,KAAK,EACV,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACpB,iCAAiC;
|
|
1
|
+
{"version":3,"file":"SnapKeyring.d.mts","sourceRoot":"","sources":["../../src/v2/SnapKeyring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAE5D,OAAO,KAAK,EACV,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACpB,iCAAiC;AAIlC,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAEnD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAU5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,oCAAgC;AACpE,OAAO,EAAE,aAAa,EAAE,6BAAyB;AACjD,OAAO,KAAK,EAAiB,sBAAsB,EAAE,6BAAyB;AAG9E;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,mBAE/B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0FjC;;;eAGG;;;;;;;;;;;;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