@metamask-previews/account-tree-controller 7.6.1-preview-58a4a8b71 → 7.6.1-preview-4c8a5dfcb
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 +1 -5
- package/dist/AccountTreeController-method-action-types.cjs.map +1 -1
- package/dist/AccountTreeController-method-action-types.d.cts +1 -34
- package/dist/AccountTreeController-method-action-types.d.cts.map +1 -1
- package/dist/AccountTreeController-method-action-types.d.mts +1 -34
- package/dist/AccountTreeController-method-action-types.d.mts.map +1 -1
- package/dist/AccountTreeController-method-action-types.mjs.map +1 -1
- package/dist/AccountTreeController.cjs +0 -42
- package/dist/AccountTreeController.cjs.map +1 -1
- package/dist/AccountTreeController.d.cts +0 -29
- package/dist/AccountTreeController.d.cts.map +1 -1
- package/dist/AccountTreeController.d.mts +0 -29
- package/dist/AccountTreeController.d.mts.map +1 -1
- package/dist/AccountTreeController.mjs +0 -42
- package/dist/AccountTreeController.mjs.map +1 -1
- package/dist/index.cjs +1 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +3 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -3
- package/dist/state/export.cjs +0 -210
- package/dist/state/export.cjs.map +0 -1
- package/dist/state/export.d.cts +0 -40
- package/dist/state/export.d.cts.map +0 -1
- package/dist/state/export.d.mts +0 -40
- package/dist/state/export.d.mts.map +0 -1
- package/dist/state/export.mjs +0 -204
- package/dist/state/export.mjs.map +0 -1
- package/dist/state/id-map.cjs +0 -59
- package/dist/state/id-map.cjs.map +0 -1
- package/dist/state/id-map.d.cts +0 -41
- package/dist/state/id-map.d.cts.map +0 -1
- package/dist/state/id-map.d.mts +0 -41
- package/dist/state/id-map.d.mts.map +0 -1
- package/dist/state/id-map.mjs +0 -55
- package/dist/state/id-map.mjs.map +0 -1
- package/dist/state/import.cjs +0 -233
- package/dist/state/import.cjs.map +0 -1
- package/dist/state/import.d.cts +0 -29
- package/dist/state/import.d.cts.map +0 -1
- package/dist/state/import.d.mts +0 -29
- package/dist/state/import.d.mts.map +0 -1
- package/dist/state/import.mjs +0 -229
- package/dist/state/import.mjs.map +0 -1
- package/dist/state/payload.cjs +0 -159
- package/dist/state/payload.cjs.map +0 -1
- package/dist/state/payload.d.cts +0 -287
- package/dist/state/payload.d.cts.map +0 -1
- package/dist/state/payload.d.mts +0 -287
- package/dist/state/payload.d.mts.map +0 -1
- package/dist/state/payload.mjs +0 -152
- package/dist/state/payload.mjs.map +0 -1
- package/dist/state/snapshot.cjs +0 -203
- package/dist/state/snapshot.cjs.map +0 -1
- package/dist/state/snapshot.d.cts +0 -111
- package/dist/state/snapshot.d.cts.map +0 -1
- package/dist/state/snapshot.d.mts +0 -111
- package/dist/state/snapshot.d.mts.map +0 -1
- package/dist/state/snapshot.mjs +0 -199
- package/dist/state/snapshot.mjs.map +0 -1
package/dist/state/payload.cjs
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrate = exports.ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION = exports.migrations = exports.assertValidAccountTreePayload = exports.AccountTreePayloadStruct = exports.toWalletPayloadId = exports.parsePayloadGroupId = void 0;
|
|
4
|
-
const keyring_sdk_1 = require("@metamask/keyring-sdk");
|
|
5
|
-
const superstruct_1 = require("@metamask/superstruct");
|
|
6
|
-
const PAYLOAD_GROUP_ID_REGEX = /^(?<walletId>wallet:[^/]+)\/(?<subId>.+)$/u;
|
|
7
|
-
/**
|
|
8
|
-
* Parses a payload group ID into its wallet ID and group sub-ID components.
|
|
9
|
-
*
|
|
10
|
-
* @param groupId - The payload group ID to parse.
|
|
11
|
-
* @returns The parsed wallet ID and group sub-ID.
|
|
12
|
-
* @throws If the group ID format is invalid.
|
|
13
|
-
*/
|
|
14
|
-
function parsePayloadGroupId(groupId) {
|
|
15
|
-
const match = PAYLOAD_GROUP_ID_REGEX.exec(groupId);
|
|
16
|
-
if (!match?.groups) {
|
|
17
|
-
throw new Error(`Invalid payload group ID: "${groupId}"`);
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
walletId: match.groups.walletId,
|
|
21
|
-
subId: match.groups.subId,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.parsePayloadGroupId = parsePayloadGroupId;
|
|
25
|
-
/**
|
|
26
|
-
* Constructs an {@link AccountWalletPayloadId} from an entropy source ID.
|
|
27
|
-
*
|
|
28
|
-
* @param entropySourceId - Stable entropy source ID returned by `HdKeyring.toEntropySourceId()`.
|
|
29
|
-
* @returns The portable wallet payload ID.
|
|
30
|
-
*/
|
|
31
|
-
function toWalletPayloadId(entropySourceId) {
|
|
32
|
-
return `wallet:${entropySourceId}`;
|
|
33
|
-
}
|
|
34
|
-
exports.toWalletPayloadId = toWalletPayloadId;
|
|
35
|
-
const AccountWalletPayloadIdStruct = (0, superstruct_1.define)('AccountWalletPayloadId', (value) => typeof value === 'string' && value.startsWith('wallet:')
|
|
36
|
-
? true
|
|
37
|
-
: 'Expected a wallet payload ID starting with "wallet:"');
|
|
38
|
-
const AccountGroupPayloadIdStruct = (0, superstruct_1.define)('AccountGroupPayloadId', (value) => typeof value === 'string' && PAYLOAD_GROUP_ID_REGEX.test(value)
|
|
39
|
-
? true
|
|
40
|
-
: 'Expected a group payload ID in the form "wallet:<id>/<subId>"');
|
|
41
|
-
const AccountWalletPayloadMetadataStruct = (0, superstruct_1.object)({
|
|
42
|
-
name: (0, superstruct_1.string)(),
|
|
43
|
-
});
|
|
44
|
-
const AccountWalletGroupPayloadMetadataStruct = (0, superstruct_1.object)({
|
|
45
|
-
name: (0, superstruct_1.string)(),
|
|
46
|
-
pinned: (0, superstruct_1.boolean)(),
|
|
47
|
-
hidden: (0, superstruct_1.boolean)(),
|
|
48
|
-
});
|
|
49
|
-
const AccountWalletPrivateKeyValueStruct = (0, superstruct_1.object)({
|
|
50
|
-
privateKey: (0, superstruct_1.sensitive)((0, superstruct_1.string)()),
|
|
51
|
-
encoding: (0, superstruct_1.enums)(['hexadecimal', 'base58', 'base32']),
|
|
52
|
-
type: (0, superstruct_1.exactOptional)((0, superstruct_1.string)()),
|
|
53
|
-
});
|
|
54
|
-
const AccountWalletMnemonicGroupEntryStruct = (0, superstruct_1.object)({
|
|
55
|
-
id: AccountGroupPayloadIdStruct,
|
|
56
|
-
groupIndex: (0, superstruct_1.integer)(),
|
|
57
|
-
metadata: AccountWalletGroupPayloadMetadataStruct,
|
|
58
|
-
});
|
|
59
|
-
const AccountWalletPrivateKeyGroupEntryStruct = (0, superstruct_1.object)({
|
|
60
|
-
id: AccountGroupPayloadIdStruct,
|
|
61
|
-
value: (0, superstruct_1.exactOptional)(AccountWalletPrivateKeyValueStruct),
|
|
62
|
-
metadata: AccountWalletGroupPayloadMetadataStruct,
|
|
63
|
-
});
|
|
64
|
-
const AccountWalletMnemonicPayloadStruct = (0, superstruct_1.object)({
|
|
65
|
-
id: AccountWalletPayloadIdStruct,
|
|
66
|
-
type: (0, superstruct_1.literal)('mnemonic'),
|
|
67
|
-
value: (0, superstruct_1.exactOptional)((0, superstruct_1.sensitive)((0, superstruct_1.string)())),
|
|
68
|
-
metadata: AccountWalletPayloadMetadataStruct,
|
|
69
|
-
groups: (0, superstruct_1.array)(AccountWalletMnemonicGroupEntryStruct),
|
|
70
|
-
});
|
|
71
|
-
const AccountWalletPrivateKeyPayloadStruct = (0, superstruct_1.object)({
|
|
72
|
-
id: AccountWalletPayloadIdStruct,
|
|
73
|
-
type: (0, superstruct_1.literal)('private-key'),
|
|
74
|
-
metadata: AccountWalletPayloadMetadataStruct,
|
|
75
|
-
groups: (0, superstruct_1.array)(AccountWalletPrivateKeyGroupEntryStruct),
|
|
76
|
-
});
|
|
77
|
-
const AccountTreeWalletEntryStruct = (0, superstruct_1.union)([
|
|
78
|
-
AccountWalletMnemonicPayloadStruct,
|
|
79
|
-
AccountWalletPrivateKeyPayloadStruct,
|
|
80
|
-
]);
|
|
81
|
-
/**
|
|
82
|
-
* Superstruct schema for an {@link AccountTreePayload} (inner data, without version envelope).
|
|
83
|
-
*
|
|
84
|
-
* Validates v1 wallet entries (`'mnemonic'` and `'private-key'` only) and
|
|
85
|
-
* rejects unsupported wallet types. Secret fields (`value`, `privateKey`) use
|
|
86
|
-
* the Superstruct `sensitive()` wrapper so validation failures redact secrets
|
|
87
|
-
* from error output.
|
|
88
|
-
*/
|
|
89
|
-
exports.AccountTreePayloadStruct = (0, superstruct_1.object)({
|
|
90
|
-
wallets: (0, superstruct_1.array)(AccountTreeWalletEntryStruct),
|
|
91
|
-
});
|
|
92
|
-
/**
|
|
93
|
-
* Formats Superstruct validation failures into a single error message string.
|
|
94
|
-
*
|
|
95
|
-
* @param error - The StructError thrown during payload validation.
|
|
96
|
-
* @returns A comma-separated list of `[path] message` entries.
|
|
97
|
-
*/
|
|
98
|
-
const formatValidationErrorMessages = (error) => error
|
|
99
|
-
.failures()
|
|
100
|
-
.map(({ path, message }) => `[${path.join('.')}] ${message}`)
|
|
101
|
-
.join(', ');
|
|
102
|
-
/**
|
|
103
|
-
* Asserts that `value` conforms to the v1 {@link AccountTreePayload} schema.
|
|
104
|
-
*
|
|
105
|
-
* Prefer {@link AccountTreeSnapshot.deserialize} at transport boundaries so
|
|
106
|
-
* validation stays paired with snapshot construction. Use this helper when you
|
|
107
|
-
* already hold a parsed object and need to assert its shape before further
|
|
108
|
-
* processing.
|
|
109
|
-
*
|
|
110
|
-
* @param value - Value to validate.
|
|
111
|
-
* @throws If `value` is not a valid v1 payload, including unsupported wallet types.
|
|
112
|
-
*/
|
|
113
|
-
function assertValidAccountTreePayload(value) {
|
|
114
|
-
try {
|
|
115
|
-
(0, superstruct_1.assert)(value, exports.AccountTreePayloadStruct);
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
if (error instanceof superstruct_1.StructError) {
|
|
119
|
-
throw new Error(`Invalid AccountTreePayload: ${formatValidationErrorMessages(error)}`);
|
|
120
|
-
}
|
|
121
|
-
/* istanbul ignore next */
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.assertValidAccountTreePayload = assertValidAccountTreePayload;
|
|
126
|
-
/**
|
|
127
|
-
* Migration chain for {@link AccountTreePayload}.
|
|
128
|
-
*
|
|
129
|
-
* Each `.add()` call appends a step; `migrations.version` equals the number of
|
|
130
|
-
* steps and serves as the canonical current version written by
|
|
131
|
-
* {@link AccountTreeSnapshot.serialize}.
|
|
132
|
-
*
|
|
133
|
-
* **v1** — validates and returns the v1 payload structure `{ wallets: [...] }`.
|
|
134
|
-
*/
|
|
135
|
-
exports.migrations = (0, keyring_sdk_1.createMigrations)().add({
|
|
136
|
-
migrate(data) {
|
|
137
|
-
assertValidAccountTreePayload(data);
|
|
138
|
-
return data;
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
/** Current version of the {@link AccountTreePayload} format, derived from the migration chain. */
|
|
142
|
-
exports.ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION = exports.migrations.version;
|
|
143
|
-
/**
|
|
144
|
-
* Validates a raw value as an `AccountTreePayload` and runs any necessary version migrations.
|
|
145
|
-
*
|
|
146
|
-
* This is the low-level entry point used by {@link AccountTreeSnapshot.deserialize}.
|
|
147
|
-
* Callers receiving untrusted wire data should prefer `deserialize`, which returns
|
|
148
|
-
* an immutable {@link AccountTreeSnapshot} ready for filtering and import.
|
|
149
|
-
*
|
|
150
|
-
* @param raw - Unknown value to validate.
|
|
151
|
-
* @returns A fully migrated `AccountTreePayload`.
|
|
152
|
-
* @throws If `raw` is not a valid payload, its version is unsupported, or any wallet type is unrecognized.
|
|
153
|
-
*/
|
|
154
|
-
async function migrate(raw) {
|
|
155
|
-
const { data } = await exports.migrations.apply(raw);
|
|
156
|
-
return data;
|
|
157
|
-
}
|
|
158
|
-
exports.migrate = migrate;
|
|
159
|
-
//# sourceMappingURL=payload.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payload.cjs","sourceRoot":"","sources":["../../src/state/payload.ts"],"names":[],"mappings":";;;AAEA,uDAAyD;AACzD,uDAc+B;AAoB/B,MAAM,sBAAsB,GAAG,4CAA4C,CAAC;AAE5E;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,OAA8B;IAE9B,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,QAAkC;QACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK;KAC1B,CAAC;AACJ,CAAC;AAXD,kDAWC;AAkHD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,eAAuB;IAEvB,OAAO,UAAU,eAAe,EAAE,CAAC;AACrC,CAAC;AAJD,8CAIC;AAQD,MAAM,4BAA4B,GAAG,IAAA,oBAAM,EACzC,wBAAwB,EACxB,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC;IACtD,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,sDAAsD,CAC7D,CAAC;AAEF,MAAM,2BAA2B,GAAG,IAAA,oBAAM,EACxC,uBAAuB,EACvB,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ,IAAI,sBAA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AG,CAAC;IACrB,OAAO,CAAC,IAAU;QAChB,6BAA6B,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC;AAEL,kGAAkG;AACrF,QAAA,oCAAoC,GAAG,kBAAU,CAAC,OAAO,CAAC;AAEvE;;;;;;;;;;GAUG;AACI,KAAK,UAAU,OAAO,CAAC,GAAY;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,kBAAU,CAAC,KAAK,CAAC,GAAW,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC;AACd,CAAC;AAHD,0BAGC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\nimport type { MigrationChain } from '@metamask/keyring-sdk';\nimport { createMigrations } from '@metamask/keyring-sdk';\nimport {\n assert,\n array,\n boolean,\n define,\n enums,\n integer,\n literal,\n object,\n exactOptional,\n sensitive,\n string,\n StructError,\n union,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\n\n/** Stable cross-device wallet identifier. Format: `wallet:<entropySourceId>`. */\nexport type AccountWalletPayloadId = `wallet:${string}`;\n\n/** Stable cross-device group identifier. Format: `wallet:<entropySourceId>/<groupSubId>`. */\nexport type AccountGroupPayloadId = `wallet:${string}/${string}`;\n\n/**\n * Parsed representation of an {@link AccountGroupPayloadId}.\n */\nexport type ParsedPayloadGroupId = {\n /** The wallet portion of the group ID. */\n walletId: AccountWalletPayloadId;\n /** The group-specific sub-ID (e.g. group index for mnemonic wallets, address for private-key wallets). */\n subId: string;\n};\n\nconst PAYLOAD_GROUP_ID_REGEX = /^(?<walletId>wallet:[^/]+)\\/(?<subId>.+)$/u;\n\n/**\n * Parses a payload group ID into its wallet ID and group sub-ID components.\n *\n * @param groupId - The payload group ID to parse.\n * @returns The parsed wallet ID and group sub-ID.\n * @throws If the group ID format is invalid.\n */\nexport function parsePayloadGroupId(\n groupId: AccountGroupPayloadId,\n): ParsedPayloadGroupId {\n const match = PAYLOAD_GROUP_ID_REGEX.exec(groupId);\n if (!match?.groups) {\n throw new Error(`Invalid payload group ID: \"${groupId}\"`);\n }\n return {\n walletId: match.groups.walletId as AccountWalletPayloadId,\n subId: match.groups.subId,\n };\n}\n\n/** Wallet-level metadata carried in every payload wallet entry. */\nexport type AccountWalletPayloadMetadata = { name: string };\n\n/** Group-level metadata carried in every payload group entry. */\nexport type AccountWalletGroupPayloadMetadata = {\n name: string;\n pinned: boolean;\n hidden: boolean;\n};\n\n/** A single group entry inside an {@link AccountWalletMnemonicPayload}. */\nexport type AccountWalletMnemonicGroupEntry = {\n /** Stable group payload ID. Format: `<walletPayloadId>/<groupIndex>`. */\n id: AccountGroupPayloadId;\n /** BIP-44 account index this group was derived at. */\n groupIndex: number;\n metadata: AccountWalletGroupPayloadMetadata;\n};\n\n/** A single group entry inside an {@link AccountWalletPrivateKeyPayload}. */\nexport type AccountWalletPrivateKeyGroupEntry = {\n /** Stable group payload ID. Format: `wallet:private-key/<address>`. */\n id: AccountGroupPayloadId;\n /**\n * Private key material. Shape matches `ExportedAccount` from `@metamask/keyring-api/v2`\n * so the importer knows how to decode the key without additional out-of-band information.\n * Absent in metadata-only exports.\n */\n value?: {\n privateKey: string;\n encoding: 'hexadecimal' | 'base58' | 'base32';\n /**\n * Account type from `KeyringAccountType` (e.g. `'eip155:eoa'`, `'bip122:p2wpkh'`).\n * Absent for EVM accounts -- import via `SimpleKeyring`.\n * Present for non-EVM accounts -- routing to the BIP-44 Snap handling this type is not yet implemented.\n */\n type?: KeyringAccount['type'];\n };\n metadata: AccountWalletGroupPayloadMetadata;\n};\n\n/** Payload entry for an HD (entropy) wallet and its derived account groups. */\nexport type AccountWalletMnemonicPayload = {\n id: AccountWalletPayloadId;\n type: 'mnemonic';\n /** BIP-39 mnemonic phrase. Absent in metadata-only exports. */\n value?: string;\n metadata: AccountWalletPayloadMetadata;\n groups: AccountWalletMnemonicGroupEntry[];\n};\n\n/**\n * Payload entry for all imported private-key accounts.\n *\n * All local simple-keyring wallets are merged into this single entry;\n * each account is represented as a separate group entry keyed by address.\n */\nexport type AccountWalletPrivateKeyPayload = {\n id: AccountWalletPayloadId;\n type: 'private-key';\n metadata: AccountWalletPayloadMetadata;\n groups: AccountWalletPrivateKeyGroupEntry[];\n};\n\n/** Union of all wallet entry types that can appear in an {@link AccountTreePayload}. */\nexport type AccountTreeWalletEntry =\n | AccountWalletMnemonicPayload\n | AccountWalletPrivateKeyPayload;\n\n/** Portable snapshot of the full account tree state (inner data, without version envelope). */\nexport type AccountTreePayload = {\n wallets: AccountTreeWalletEntry[];\n};\n\n/**\n * Recursively readonly view of `T` used by snapshot filtering predicate types.\n *\n * @typeParam T - The mutable source type to expose as deeply read-only.\n */\nexport type DeepReadonly<T> = T extends readonly (infer Item)[]\n ? readonly DeepReadonly<Item>[]\n : T extends object\n ? { readonly [Key in keyof T]: DeepReadonly<T[Key]> }\n : T;\n\n/**\n * Deeply read-only wallet view passed to {@link AccountTreeSnapshot.filterWallets}\n * and {@link AccountTreeSnapshot.filterAllGroups} predicates.\n *\n * Entries are deep-cloned and deep-frozen when a snapshot is constructed, so\n * callers cannot mutate wallet IDs, types, secrets, metadata, or groups.\n */\nexport type AccountTreeSnapshotWallet = DeepReadonly<\n AccountWalletMnemonicPayload | AccountWalletPrivateKeyPayload\n>;\n\n/**\n * Deeply read-only group view passed to {@link AccountTreeSnapshot.filterGroups}\n * and {@link AccountTreeSnapshot.filterAllGroups} predicates.\n *\n * Entries are deep-cloned and deep-frozen when a snapshot is constructed, so\n * callers cannot mutate group IDs, secrets, metadata, or parent wallet references.\n */\nexport type AccountTreeSnapshotGroup = DeepReadonly<\n AccountWalletMnemonicGroupEntry | AccountWalletPrivateKeyGroupEntry\n>;\n\n/**\n * @deprecated Use {@link AccountTreeSnapshotWallet} instead.\n */\nexport type AccountTreeSnapshotEntry = AccountTreeSnapshotWallet;\n\n/**\n * Constructs an {@link AccountWalletPayloadId} from an entropy source ID.\n *\n * @param entropySourceId - Stable entropy source ID returned by `HdKeyring.toEntropySourceId()`.\n * @returns The portable wallet payload ID.\n */\nexport function toWalletPayloadId(\n entropySourceId: string,\n): AccountWalletPayloadId {\n return `wallet:${entropySourceId}`;\n}\n\n/** Options accepted by {@link AccountTreeController.exportState}. */\nexport type ExportStateOptions = {\n /** When `true`, secrets (mnemonic / private keys) are included. Requires the vault to be unlocked. */\n includeSecrets?: boolean;\n};\n\nconst AccountWalletPayloadIdStruct = define<AccountWalletPayloadId>(\n 'AccountWalletPayloadId',\n (value) =>\n typeof value === 'string' && value.startsWith('wallet:')\n ? true\n : 'Expected a wallet payload ID starting with \"wallet:\"',\n);\n\nconst AccountGroupPayloadIdStruct = define<AccountGroupPayloadId>(\n 'AccountGroupPayloadId',\n (value) =>\n typeof value === 'string' && PAYLOAD_GROUP_ID_REGEX.test(value)\n ? true\n : 'Expected a group payload ID in the form \"wallet:<id>/<subId>\"',\n);\n\nconst AccountWalletPayloadMetadataStruct = object({\n name: string(),\n});\n\nconst AccountWalletGroupPayloadMetadataStruct = object({\n name: string(),\n pinned: boolean(),\n hidden: boolean(),\n});\n\nconst AccountWalletPrivateKeyValueStruct = object({\n privateKey: sensitive(string()),\n encoding: enums(['hexadecimal', 'base58', 'base32']),\n type: exactOptional(string()),\n});\n\nconst AccountWalletMnemonicGroupEntryStruct = object({\n id: AccountGroupPayloadIdStruct,\n groupIndex: integer(),\n metadata: AccountWalletGroupPayloadMetadataStruct,\n});\n\nconst AccountWalletPrivateKeyGroupEntryStruct = object({\n id: AccountGroupPayloadIdStruct,\n value: exactOptional(AccountWalletPrivateKeyValueStruct),\n metadata: AccountWalletGroupPayloadMetadataStruct,\n});\n\nconst AccountWalletMnemonicPayloadStruct = object({\n id: AccountWalletPayloadIdStruct,\n type: literal('mnemonic'),\n value: exactOptional(sensitive(string())),\n metadata: AccountWalletPayloadMetadataStruct,\n groups: array(AccountWalletMnemonicGroupEntryStruct),\n});\n\nconst AccountWalletPrivateKeyPayloadStruct = object({\n id: AccountWalletPayloadIdStruct,\n type: literal('private-key'),\n metadata: AccountWalletPayloadMetadataStruct,\n groups: array(AccountWalletPrivateKeyGroupEntryStruct),\n});\n\nconst AccountTreeWalletEntryStruct = union([\n AccountWalletMnemonicPayloadStruct,\n AccountWalletPrivateKeyPayloadStruct,\n]);\n\n/**\n * Superstruct schema for an {@link AccountTreePayload} (inner data, without version envelope).\n *\n * Validates v1 wallet entries (`'mnemonic'` and `'private-key'` only) and\n * rejects unsupported wallet types. Secret fields (`value`, `privateKey`) use\n * the Superstruct `sensitive()` wrapper so validation failures redact secrets\n * from error output.\n */\nexport const AccountTreePayloadStruct = object({\n wallets: array(AccountTreeWalletEntryStruct),\n});\n\n/** Inferred TypeScript type for a value matching {@link AccountTreePayloadStruct}. */\nexport type AccountTreePayloadStructType = Infer<\n typeof AccountTreePayloadStruct\n>;\n\n/**\n * Formats Superstruct validation failures into a single error message string.\n *\n * @param error - The StructError thrown during payload validation.\n * @returns A comma-separated list of `[path] message` entries.\n */\nconst formatValidationErrorMessages = (error: StructError): string =>\n error\n .failures()\n .map(({ path, message }) => `[${path.join('.')}] ${message}`)\n .join(', ');\n\n/**\n * Asserts that `value` conforms to the v1 {@link AccountTreePayload} schema.\n *\n * Prefer {@link AccountTreeSnapshot.deserialize} at transport boundaries so\n * validation stays paired with snapshot construction. Use this helper when you\n * already hold a parsed object and need to assert its shape before further\n * processing.\n *\n * @param value - Value to validate.\n * @throws If `value` is not a valid v1 payload, including unsupported wallet types.\n */\nexport function assertValidAccountTreePayload(\n value: unknown,\n): asserts value is AccountTreePayload {\n try {\n assert(value, AccountTreePayloadStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Invalid AccountTreePayload: ${formatValidationErrorMessages(error)}`,\n );\n }\n /* istanbul ignore next */\n throw error;\n }\n}\n\n/**\n * Migration chain for {@link AccountTreePayload}.\n *\n * Each `.add()` call appends a step; `migrations.version` equals the number of\n * steps and serves as the canonical current version written by\n * {@link AccountTreeSnapshot.serialize}.\n *\n * **v1** — validates and returns the v1 payload structure `{ wallets: [...] }`.\n */\nexport const migrations: MigrationChain<AccountTreePayload> =\n createMigrations().add({\n migrate(data: Json): AccountTreePayload {\n assertValidAccountTreePayload(data);\n return data;\n },\n });\n\n/** Current version of the {@link AccountTreePayload} format, derived from the migration chain. */\nexport const ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION = migrations.version;\n\n/**\n * Validates a raw value as an `AccountTreePayload` and runs any necessary version migrations.\n *\n * This is the low-level entry point used by {@link AccountTreeSnapshot.deserialize}.\n * Callers receiving untrusted wire data should prefer `deserialize`, which returns\n * an immutable {@link AccountTreeSnapshot} ready for filtering and import.\n *\n * @param raw - Unknown value to validate.\n * @returns A fully migrated `AccountTreePayload`.\n * @throws If `raw` is not a valid payload, its version is unsupported, or any wallet type is unrecognized.\n */\nexport async function migrate(raw: unknown): Promise<AccountTreePayload> {\n const { data } = await migrations.apply(raw as Json);\n return data;\n}\n"]}
|
package/dist/state/payload.d.cts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
2
|
-
import type { MigrationChain } from "@metamask/keyring-sdk";
|
|
3
|
-
import type { Infer } from "@metamask/superstruct";
|
|
4
|
-
/** Stable cross-device wallet identifier. Format: `wallet:<entropySourceId>`. */
|
|
5
|
-
export type AccountWalletPayloadId = `wallet:${string}`;
|
|
6
|
-
/** Stable cross-device group identifier. Format: `wallet:<entropySourceId>/<groupSubId>`. */
|
|
7
|
-
export type AccountGroupPayloadId = `wallet:${string}/${string}`;
|
|
8
|
-
/**
|
|
9
|
-
* Parsed representation of an {@link AccountGroupPayloadId}.
|
|
10
|
-
*/
|
|
11
|
-
export type ParsedPayloadGroupId = {
|
|
12
|
-
/** The wallet portion of the group ID. */
|
|
13
|
-
walletId: AccountWalletPayloadId;
|
|
14
|
-
/** The group-specific sub-ID (e.g. group index for mnemonic wallets, address for private-key wallets). */
|
|
15
|
-
subId: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Parses a payload group ID into its wallet ID and group sub-ID components.
|
|
19
|
-
*
|
|
20
|
-
* @param groupId - The payload group ID to parse.
|
|
21
|
-
* @returns The parsed wallet ID and group sub-ID.
|
|
22
|
-
* @throws If the group ID format is invalid.
|
|
23
|
-
*/
|
|
24
|
-
export declare function parsePayloadGroupId(groupId: AccountGroupPayloadId): ParsedPayloadGroupId;
|
|
25
|
-
/** Wallet-level metadata carried in every payload wallet entry. */
|
|
26
|
-
export type AccountWalletPayloadMetadata = {
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
/** Group-level metadata carried in every payload group entry. */
|
|
30
|
-
export type AccountWalletGroupPayloadMetadata = {
|
|
31
|
-
name: string;
|
|
32
|
-
pinned: boolean;
|
|
33
|
-
hidden: boolean;
|
|
34
|
-
};
|
|
35
|
-
/** A single group entry inside an {@link AccountWalletMnemonicPayload}. */
|
|
36
|
-
export type AccountWalletMnemonicGroupEntry = {
|
|
37
|
-
/** Stable group payload ID. Format: `<walletPayloadId>/<groupIndex>`. */
|
|
38
|
-
id: AccountGroupPayloadId;
|
|
39
|
-
/** BIP-44 account index this group was derived at. */
|
|
40
|
-
groupIndex: number;
|
|
41
|
-
metadata: AccountWalletGroupPayloadMetadata;
|
|
42
|
-
};
|
|
43
|
-
/** A single group entry inside an {@link AccountWalletPrivateKeyPayload}. */
|
|
44
|
-
export type AccountWalletPrivateKeyGroupEntry = {
|
|
45
|
-
/** Stable group payload ID. Format: `wallet:private-key/<address>`. */
|
|
46
|
-
id: AccountGroupPayloadId;
|
|
47
|
-
/**
|
|
48
|
-
* Private key material. Shape matches `ExportedAccount` from `@metamask/keyring-api/v2`
|
|
49
|
-
* so the importer knows how to decode the key without additional out-of-band information.
|
|
50
|
-
* Absent in metadata-only exports.
|
|
51
|
-
*/
|
|
52
|
-
value?: {
|
|
53
|
-
privateKey: string;
|
|
54
|
-
encoding: 'hexadecimal' | 'base58' | 'base32';
|
|
55
|
-
/**
|
|
56
|
-
* Account type from `KeyringAccountType` (e.g. `'eip155:eoa'`, `'bip122:p2wpkh'`).
|
|
57
|
-
* Absent for EVM accounts -- import via `SimpleKeyring`.
|
|
58
|
-
* Present for non-EVM accounts -- routing to the BIP-44 Snap handling this type is not yet implemented.
|
|
59
|
-
*/
|
|
60
|
-
type?: KeyringAccount['type'];
|
|
61
|
-
};
|
|
62
|
-
metadata: AccountWalletGroupPayloadMetadata;
|
|
63
|
-
};
|
|
64
|
-
/** Payload entry for an HD (entropy) wallet and its derived account groups. */
|
|
65
|
-
export type AccountWalletMnemonicPayload = {
|
|
66
|
-
id: AccountWalletPayloadId;
|
|
67
|
-
type: 'mnemonic';
|
|
68
|
-
/** BIP-39 mnemonic phrase. Absent in metadata-only exports. */
|
|
69
|
-
value?: string;
|
|
70
|
-
metadata: AccountWalletPayloadMetadata;
|
|
71
|
-
groups: AccountWalletMnemonicGroupEntry[];
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Payload entry for all imported private-key accounts.
|
|
75
|
-
*
|
|
76
|
-
* All local simple-keyring wallets are merged into this single entry;
|
|
77
|
-
* each account is represented as a separate group entry keyed by address.
|
|
78
|
-
*/
|
|
79
|
-
export type AccountWalletPrivateKeyPayload = {
|
|
80
|
-
id: AccountWalletPayloadId;
|
|
81
|
-
type: 'private-key';
|
|
82
|
-
metadata: AccountWalletPayloadMetadata;
|
|
83
|
-
groups: AccountWalletPrivateKeyGroupEntry[];
|
|
84
|
-
};
|
|
85
|
-
/** Union of all wallet entry types that can appear in an {@link AccountTreePayload}. */
|
|
86
|
-
export type AccountTreeWalletEntry = AccountWalletMnemonicPayload | AccountWalletPrivateKeyPayload;
|
|
87
|
-
/** Portable snapshot of the full account tree state (inner data, without version envelope). */
|
|
88
|
-
export type AccountTreePayload = {
|
|
89
|
-
wallets: AccountTreeWalletEntry[];
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Recursively readonly view of `T` used by snapshot filtering predicate types.
|
|
93
|
-
*
|
|
94
|
-
* @typeParam T - The mutable source type to expose as deeply read-only.
|
|
95
|
-
*/
|
|
96
|
-
export type DeepReadonly<T> = T extends readonly (infer Item)[] ? readonly DeepReadonly<Item>[] : T extends object ? {
|
|
97
|
-
readonly [Key in keyof T]: DeepReadonly<T[Key]>;
|
|
98
|
-
} : T;
|
|
99
|
-
/**
|
|
100
|
-
* Deeply read-only wallet view passed to {@link AccountTreeSnapshot.filterWallets}
|
|
101
|
-
* and {@link AccountTreeSnapshot.filterAllGroups} predicates.
|
|
102
|
-
*
|
|
103
|
-
* Entries are deep-cloned and deep-frozen when a snapshot is constructed, so
|
|
104
|
-
* callers cannot mutate wallet IDs, types, secrets, metadata, or groups.
|
|
105
|
-
*/
|
|
106
|
-
export type AccountTreeSnapshotWallet = DeepReadonly<AccountWalletMnemonicPayload | AccountWalletPrivateKeyPayload>;
|
|
107
|
-
/**
|
|
108
|
-
* Deeply read-only group view passed to {@link AccountTreeSnapshot.filterGroups}
|
|
109
|
-
* and {@link AccountTreeSnapshot.filterAllGroups} predicates.
|
|
110
|
-
*
|
|
111
|
-
* Entries are deep-cloned and deep-frozen when a snapshot is constructed, so
|
|
112
|
-
* callers cannot mutate group IDs, secrets, metadata, or parent wallet references.
|
|
113
|
-
*/
|
|
114
|
-
export type AccountTreeSnapshotGroup = DeepReadonly<AccountWalletMnemonicGroupEntry | AccountWalletPrivateKeyGroupEntry>;
|
|
115
|
-
/**
|
|
116
|
-
* @deprecated Use {@link AccountTreeSnapshotWallet} instead.
|
|
117
|
-
*/
|
|
118
|
-
export type AccountTreeSnapshotEntry = AccountTreeSnapshotWallet;
|
|
119
|
-
/**
|
|
120
|
-
* Constructs an {@link AccountWalletPayloadId} from an entropy source ID.
|
|
121
|
-
*
|
|
122
|
-
* @param entropySourceId - Stable entropy source ID returned by `HdKeyring.toEntropySourceId()`.
|
|
123
|
-
* @returns The portable wallet payload ID.
|
|
124
|
-
*/
|
|
125
|
-
export declare function toWalletPayloadId(entropySourceId: string): AccountWalletPayloadId;
|
|
126
|
-
/** Options accepted by {@link AccountTreeController.exportState}. */
|
|
127
|
-
export type ExportStateOptions = {
|
|
128
|
-
/** When `true`, secrets (mnemonic / private keys) are included. Requires the vault to be unlocked. */
|
|
129
|
-
includeSecrets?: boolean;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Superstruct schema for an {@link AccountTreePayload} (inner data, without version envelope).
|
|
133
|
-
*
|
|
134
|
-
* Validates v1 wallet entries (`'mnemonic'` and `'private-key'` only) and
|
|
135
|
-
* rejects unsupported wallet types. Secret fields (`value`, `privateKey`) use
|
|
136
|
-
* the Superstruct `sensitive()` wrapper so validation failures redact secrets
|
|
137
|
-
* from error output.
|
|
138
|
-
*/
|
|
139
|
-
export declare const AccountTreePayloadStruct: import("@metamask/superstruct").Struct<{
|
|
140
|
-
wallets: ({
|
|
141
|
-
id: `wallet:${string}`;
|
|
142
|
-
type: "mnemonic";
|
|
143
|
-
metadata: {
|
|
144
|
-
name: string;
|
|
145
|
-
};
|
|
146
|
-
groups: {
|
|
147
|
-
id: `wallet:${string}/${string}`;
|
|
148
|
-
metadata: {
|
|
149
|
-
name: string;
|
|
150
|
-
pinned: boolean;
|
|
151
|
-
hidden: boolean;
|
|
152
|
-
};
|
|
153
|
-
groupIndex: number;
|
|
154
|
-
}[];
|
|
155
|
-
value?: string | undefined;
|
|
156
|
-
} | {
|
|
157
|
-
id: `wallet:${string}`;
|
|
158
|
-
type: "private-key";
|
|
159
|
-
metadata: {
|
|
160
|
-
name: string;
|
|
161
|
-
};
|
|
162
|
-
groups: {
|
|
163
|
-
id: `wallet:${string}/${string}`;
|
|
164
|
-
metadata: {
|
|
165
|
-
name: string;
|
|
166
|
-
pinned: boolean;
|
|
167
|
-
hidden: boolean;
|
|
168
|
-
};
|
|
169
|
-
value?: {
|
|
170
|
-
privateKey: string;
|
|
171
|
-
encoding: "hexadecimal" | "base58" | "base32";
|
|
172
|
-
type?: string | undefined;
|
|
173
|
-
} | undefined;
|
|
174
|
-
}[];
|
|
175
|
-
})[];
|
|
176
|
-
}, {
|
|
177
|
-
wallets: import("@metamask/superstruct").Struct<({
|
|
178
|
-
id: `wallet:${string}`;
|
|
179
|
-
type: "mnemonic";
|
|
180
|
-
metadata: {
|
|
181
|
-
name: string;
|
|
182
|
-
};
|
|
183
|
-
groups: {
|
|
184
|
-
id: `wallet:${string}/${string}`;
|
|
185
|
-
metadata: {
|
|
186
|
-
name: string;
|
|
187
|
-
pinned: boolean;
|
|
188
|
-
hidden: boolean;
|
|
189
|
-
};
|
|
190
|
-
groupIndex: number;
|
|
191
|
-
}[];
|
|
192
|
-
value?: string | undefined;
|
|
193
|
-
} | {
|
|
194
|
-
id: `wallet:${string}`;
|
|
195
|
-
type: "private-key";
|
|
196
|
-
metadata: {
|
|
197
|
-
name: string;
|
|
198
|
-
};
|
|
199
|
-
groups: {
|
|
200
|
-
id: `wallet:${string}/${string}`;
|
|
201
|
-
metadata: {
|
|
202
|
-
name: string;
|
|
203
|
-
pinned: boolean;
|
|
204
|
-
hidden: boolean;
|
|
205
|
-
};
|
|
206
|
-
value?: {
|
|
207
|
-
privateKey: string;
|
|
208
|
-
encoding: "hexadecimal" | "base58" | "base32";
|
|
209
|
-
type?: string | undefined;
|
|
210
|
-
} | undefined;
|
|
211
|
-
}[];
|
|
212
|
-
})[], import("@metamask/superstruct").Struct<{
|
|
213
|
-
id: `wallet:${string}`;
|
|
214
|
-
type: "mnemonic";
|
|
215
|
-
metadata: {
|
|
216
|
-
name: string;
|
|
217
|
-
};
|
|
218
|
-
groups: {
|
|
219
|
-
id: `wallet:${string}/${string}`;
|
|
220
|
-
metadata: {
|
|
221
|
-
name: string;
|
|
222
|
-
pinned: boolean;
|
|
223
|
-
hidden: boolean;
|
|
224
|
-
};
|
|
225
|
-
groupIndex: number;
|
|
226
|
-
}[];
|
|
227
|
-
value?: string | undefined;
|
|
228
|
-
} | {
|
|
229
|
-
id: `wallet:${string}`;
|
|
230
|
-
type: "private-key";
|
|
231
|
-
metadata: {
|
|
232
|
-
name: string;
|
|
233
|
-
};
|
|
234
|
-
groups: {
|
|
235
|
-
id: `wallet:${string}/${string}`;
|
|
236
|
-
metadata: {
|
|
237
|
-
name: string;
|
|
238
|
-
pinned: boolean;
|
|
239
|
-
hidden: boolean;
|
|
240
|
-
};
|
|
241
|
-
value?: {
|
|
242
|
-
privateKey: string;
|
|
243
|
-
encoding: "hexadecimal" | "base58" | "base32";
|
|
244
|
-
type?: string | undefined;
|
|
245
|
-
} | undefined;
|
|
246
|
-
}[];
|
|
247
|
-
}, null>>;
|
|
248
|
-
}>;
|
|
249
|
-
/** Inferred TypeScript type for a value matching {@link AccountTreePayloadStruct}. */
|
|
250
|
-
export type AccountTreePayloadStructType = Infer<typeof AccountTreePayloadStruct>;
|
|
251
|
-
/**
|
|
252
|
-
* Asserts that `value` conforms to the v1 {@link AccountTreePayload} schema.
|
|
253
|
-
*
|
|
254
|
-
* Prefer {@link AccountTreeSnapshot.deserialize} at transport boundaries so
|
|
255
|
-
* validation stays paired with snapshot construction. Use this helper when you
|
|
256
|
-
* already hold a parsed object and need to assert its shape before further
|
|
257
|
-
* processing.
|
|
258
|
-
*
|
|
259
|
-
* @param value - Value to validate.
|
|
260
|
-
* @throws If `value` is not a valid v1 payload, including unsupported wallet types.
|
|
261
|
-
*/
|
|
262
|
-
export declare function assertValidAccountTreePayload(value: unknown): asserts value is AccountTreePayload;
|
|
263
|
-
/**
|
|
264
|
-
* Migration chain for {@link AccountTreePayload}.
|
|
265
|
-
*
|
|
266
|
-
* Each `.add()` call appends a step; `migrations.version` equals the number of
|
|
267
|
-
* steps and serves as the canonical current version written by
|
|
268
|
-
* {@link AccountTreeSnapshot.serialize}.
|
|
269
|
-
*
|
|
270
|
-
* **v1** — validates and returns the v1 payload structure `{ wallets: [...] }`.
|
|
271
|
-
*/
|
|
272
|
-
export declare const migrations: MigrationChain<AccountTreePayload>;
|
|
273
|
-
/** Current version of the {@link AccountTreePayload} format, derived from the migration chain. */
|
|
274
|
-
export declare const ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION: number;
|
|
275
|
-
/**
|
|
276
|
-
* Validates a raw value as an `AccountTreePayload` and runs any necessary version migrations.
|
|
277
|
-
*
|
|
278
|
-
* This is the low-level entry point used by {@link AccountTreeSnapshot.deserialize}.
|
|
279
|
-
* Callers receiving untrusted wire data should prefer `deserialize`, which returns
|
|
280
|
-
* an immutable {@link AccountTreeSnapshot} ready for filtering and import.
|
|
281
|
-
*
|
|
282
|
-
* @param raw - Unknown value to validate.
|
|
283
|
-
* @returns A fully migrated `AccountTreePayload`.
|
|
284
|
-
* @throws If `raw` is not a valid payload, its version is unsupported, or any wallet type is unrecognized.
|
|
285
|
-
*/
|
|
286
|
-
export declare function migrate(raw: unknown): Promise<AccountTreePayload>;
|
|
287
|
-
//# sourceMappingURL=payload.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.cts","sourceRoot":"","sources":["../../src/state/payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAiB5D,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD,iFAAiF;AACjF,MAAM,MAAM,sBAAsB,GAAG,UAAU,MAAM,EAAE,CAAC;AAExD,6FAA6F;AAC7F,MAAM,MAAM,qBAAqB,GAAG,UAAU,MAAM,IAAI,MAAM,EAAE,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,0CAA0C;IAC1C,QAAQ,EAAE,sBAAsB,CAAC;IACjC,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAIF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,qBAAqB,GAC7B,oBAAoB,CAStB;AAED,mEAAmE;AACnE,MAAM,MAA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