@metamask-previews/seedless-onboarding-controller 9.0.0-preview-93f8bb3d0 → 9.0.0-preview-ea4ea0a

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 (52) hide show
  1. package/CHANGELOG.md +0 -18
  2. package/dist/SecretMetadata.cjs +82 -100
  3. package/dist/SecretMetadata.cjs.map +1 -1
  4. package/dist/SecretMetadata.d.cts +43 -65
  5. package/dist/SecretMetadata.d.cts.map +1 -1
  6. package/dist/SecretMetadata.d.mts +43 -65
  7. package/dist/SecretMetadata.d.mts.map +1 -1
  8. package/dist/SecretMetadata.mjs +83 -101
  9. package/dist/SecretMetadata.mjs.map +1 -1
  10. package/dist/SeedlessOnboardingController-method-action-types.cjs.map +1 -1
  11. package/dist/SeedlessOnboardingController-method-action-types.d.cts +4 -4
  12. package/dist/SeedlessOnboardingController-method-action-types.d.mts +4 -4
  13. package/dist/SeedlessOnboardingController-method-action-types.mjs.map +1 -1
  14. package/dist/SeedlessOnboardingController.cjs +24 -179
  15. package/dist/SeedlessOnboardingController.cjs.map +1 -1
  16. package/dist/SeedlessOnboardingController.d.cts +7 -30
  17. package/dist/SeedlessOnboardingController.d.cts.map +1 -1
  18. package/dist/SeedlessOnboardingController.d.mts +7 -30
  19. package/dist/SeedlessOnboardingController.d.mts.map +1 -1
  20. package/dist/SeedlessOnboardingController.mjs +26 -181
  21. package/dist/SeedlessOnboardingController.mjs.map +1 -1
  22. package/dist/constants.cjs +5 -6
  23. package/dist/constants.cjs.map +1 -1
  24. package/dist/constants.d.cts +3 -4
  25. package/dist/constants.d.cts.map +1 -1
  26. package/dist/constants.d.mts +3 -4
  27. package/dist/constants.d.mts.map +1 -1
  28. package/dist/constants.mjs +4 -5
  29. package/dist/constants.mjs.map +1 -1
  30. package/dist/index.cjs +1 -4
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +1 -2
  33. package/dist/index.d.cts.map +1 -1
  34. package/dist/index.d.mts +1 -2
  35. package/dist/index.d.mts.map +1 -1
  36. package/dist/index.mjs +1 -2
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/types.cjs.map +1 -1
  39. package/dist/types.d.cts +18 -6
  40. package/dist/types.d.cts.map +1 -1
  41. package/dist/types.d.mts +18 -6
  42. package/dist/types.d.mts.map +1 -1
  43. package/dist/types.mjs.map +1 -1
  44. package/dist/utils.cjs +1 -69
  45. package/dist/utils.cjs.map +1 -1
  46. package/dist/utils.d.cts +0 -38
  47. package/dist/utils.d.cts.map +1 -1
  48. package/dist/utils.d.mts +0 -38
  49. package/dist/utils.d.mts.map +1 -1
  50. package/dist/utils.mjs +0 -65
  51. package/dist/utils.mjs.map +1 -1
  52. package/package.json +2 -2
@@ -1,11 +1,10 @@
1
- import type { SecretDataItemOutput } from "@metamask/toprf-secure-backup";
2
- import { EncAccountDataType } from "@metamask/toprf-secure-backup";
3
- import { SecretType } from "./constants.mjs";
4
- import type { SecretDataType } from "./types.mjs";
1
+ import { SecretType, SecretMetadataVersion } from "./constants.mjs";
2
+ import type { SecretDataType, SecretMetadataOptions } from "./types.mjs";
5
3
  type ISecretMetadata<DataType extends SecretDataType = Uint8Array> = {
6
4
  data: DataType;
7
5
  timestamp: number;
8
6
  type: SecretType;
7
+ version: SecretMetadataVersion;
9
8
  toBytes: () => Uint8Array;
10
9
  };
11
10
  /**
@@ -26,32 +25,33 @@ type SecretMetadataJson<DataType extends SecretDataType> = Omit<ISecretMetadata<
26
25
  * const secretMetadata = new SecretMetadata(secret);
27
26
  * ```
28
27
  */
29
- /**
30
- * Options for SecretMetadata constructor.
31
- *
32
- * New clients: provide V2 fields (`dataType`, `createdAt`, etc).
33
- * Reading V1 data: `timestamp` and `type` come from encrypted JSON.
34
- */
35
- type SecretMetadataOptions = {
36
- timestamp?: number;
37
- type?: SecretType;
38
- itemId?: string;
39
- dataType?: EncAccountDataType;
40
- createdAt?: string;
41
- /**
42
- * The storage-level version from the SDK ('v1' or 'v2').
43
- * - 'v1': Legacy items created before dataType was introduced
44
- * - 'v2': Items with dataType set (either new or migrated)
45
- */
46
- storageVersion?: SecretDataItemOutput['version'];
47
- };
48
28
  export declare class SecretMetadata<DataType extends SecretDataType = Uint8Array> implements ISecretMetadata<DataType> {
49
29
  #private;
50
30
  /**
51
- * @param data - The secret data.
52
- * @param options - Optional metadata. New clients should provide `dataType`.
31
+ * Create a new SecretMetadata instance.
32
+ *
33
+ * @param data - The secret to add metadata to.
34
+ * @param options - The options for the secret metadata.
35
+ * @param options.timestamp - The timestamp when the secret was created.
36
+ * @param options.type - The type of the secret.
37
+ */
38
+ constructor(data: DataType, options?: Partial<SecretMetadataOptions>);
39
+ /**
40
+ * Create an Array of SecretMetadata instances from an array of secrets.
41
+ *
42
+ * To respect the order of the secrets, we add the index to the timestamp
43
+ * so that the first secret backup will have the oldest timestamp
44
+ * and the last secret backup will have the newest timestamp.
45
+ *
46
+ * @param batchData - The data to add metadata to.
47
+ * @param batchData.value - The SeedPhrase/PrivateKey to add metadata to.
48
+ * @param batchData.options - The options for the seed phrase metadata.
49
+ * @returns The SecretMetadata instances.
53
50
  */
54
- constructor(data: DataType, options?: SecretMetadataOptions);
51
+ static fromBatch<DataType extends SecretDataType = Uint8Array>(batchData: {
52
+ value: DataType;
53
+ options?: Partial<SecretMetadataOptions>;
54
+ }[]): SecretMetadata<DataType>[];
55
55
  /**
56
56
  * Assert that the provided value is a valid seed phrase metadata.
57
57
  *
@@ -60,57 +60,35 @@ export declare class SecretMetadata<DataType extends SecretDataType = Uint8Array
60
60
  */
61
61
  static assertIsValidSecretMetadataJson<DataType extends SecretDataType = Uint8Array>(value: unknown): asserts value is SecretMetadataJson<DataType>;
62
62
  /**
63
- * Parse and create the SecretMetadata instance from the raw metadata bytes.
63
+ * Parse the SecretMetadata from the metadata store and return the array of SecretMetadata instances.
64
64
  *
65
- * @param rawMetadata - The raw metadata.
66
- * @param storageMetadata - Storage-level metadata from the metadata store.
67
- * @returns The parsed secret metadata.
68
- */
69
- static fromRawMetadata<DataType extends SecretDataType>(rawMetadata: Uint8Array, storageMetadata: Omit<SecretMetadataOptions, 'timestamp' | 'type'>): SecretMetadata<DataType>;
70
- /**
71
- * Compare two SecretMetadata instances by timestamp.
65
+ * This method also sorts the secrets by timestamp in ascending order, i.e. the oldest secret will be the first element in the array.
72
66
  *
73
- * @param a - The first SecretMetadata instance.
74
- * @param b - The second SecretMetadata instance.
75
- * @param order - The sort order. Default is 'asc'.
76
- * @returns A negative number if a < b, positive if a > b, zero if equal.
67
+ * @param secretMetadataArr - The array of SecretMetadata from the metadata store.
68
+ * @param filterType - The type of the secret to filter.
69
+ * @returns The array of SecretMetadata instances.
77
70
  */
78
- static compareByTimestamp<DataType extends SecretDataType = SecretDataType>(a: SecretMetadata<DataType>, b: SecretMetadata<DataType>, order?: 'asc' | 'desc'): number;
71
+ static parseSecretsFromMetadataStore<DataType extends SecretDataType = Uint8Array>(secretMetadataArr: Uint8Array[], filterType?: SecretType): SecretMetadata<DataType>[];
79
72
  /**
80
- * Compare two SecretMetadata instances for ordering.
81
- *
82
- * Ordering priority:
83
- * 1. PrimarySrp always comes first (regardless of order direction)
84
- * 2. Server-side createdAt (TIMEUUID) if both have it
85
- * 3. Legacy items (null createdAt) are considered older
86
- * 4. Fall back to client-side timestamp
73
+ * Parse and create the SecretMetadata instance from the raw metadata bytes.
87
74
  *
88
- * @param a - The first SecretMetadata instance.
89
- * @param b - The second SecretMetadata instance.
90
- * @param order - The sort order. Default is 'asc'.
91
- * @returns A negative number if a < b, positive if a > b, zero if equal.
75
+ * @param rawMetadata - The raw metadata.
76
+ * @returns The parsed secret metadata.
92
77
  */
93
- static compare<DataType extends SecretDataType = SecretDataType>(a: SecretMetadata<DataType>, b: SecretMetadata<DataType>, order?: 'asc' | 'desc'): number;
78
+ static fromRawMetadata<DataType extends SecretDataType>(rawMetadata: Uint8Array): SecretMetadata<DataType>;
94
79
  /**
95
- * Check if a SecretMetadata instance matches the given type.
80
+ * Sort the seed phrases by timestamp.
81
+ *
82
+ * @param data - The secret metadata array to sort.
83
+ * @param order - The order to sort the seed phrases. Default is `desc`.
96
84
  *
97
- * @param secret - The SecretMetadata instance to check.
98
- * @param type - The type to match against.
99
- * @returns True if the secret matches the type.
85
+ * @returns The sorted secret metadata array.
100
86
  */
101
- static matchesType<DataType extends SecretDataType = SecretDataType>(secret: SecretMetadata<DataType>, type: SecretType): boolean;
87
+ static sort<DataType extends SecretDataType = Uint8Array>(data: SecretMetadata<DataType>[], order?: 'asc' | 'desc'): SecretMetadata<DataType>[];
102
88
  get data(): DataType;
103
89
  get timestamp(): number;
104
90
  get type(): SecretType;
105
- get itemId(): string | undefined;
106
- get dataType(): EncAccountDataType | undefined;
107
- get createdAt(): string | undefined;
108
- /**
109
- * The storage-level version from the SDK ('v1' or 'v2').
110
- *
111
- * @returns The storage-level version.
112
- */
113
- get storageVersion(): SecretDataItemOutput['version'] | undefined;
91
+ get version(): SecretMetadataVersion;
114
92
  /**
115
93
  * Serialize the secret metadata and convert it to a Uint8Array.
116
94
  *
@@ -1 +1 @@
1
- {"version":3,"file":"SecretMetadata.d.mts","sourceRoot":"","sources":["../src/SecretMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,sCAAsC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,sCAAsC;AAQnE,OAAO,EAEL,UAAU,EACX,wBAAoB;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAgB;AAG9C,KAAK,eAAe,CAAC,QAAQ,SAAS,cAAc,GAAG,UAAU,IAAI;IACnE,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,UAAU,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,KAAK,kBAAkB,CAAC,QAAQ,SAAS,cAAc,IAAI,IAAI,CAC7D,eAAe,CAAC,QAAQ,CAAC,EACzB,MAAM,GA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AI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,OAAO,IAAI,qBAAqB,CAEnC;IAED;;;;OAIG;IACH,OAAO,IAAI,UAAU;CAmBtB"}
@@ -9,38 +9,63 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _SecretMetadata_data, _SecretMetadata_timestamp, _SecretMetadata_type, _SecretMetadata_itemId, _SecretMetadata_dataType, _SecretMetadata_createdAt, _SecretMetadata_storageVersion;
13
- import { EncAccountDataType } from "@metamask/toprf-secure-backup";
12
+ var _SecretMetadata_data, _SecretMetadata_timestamp, _SecretMetadata_type, _SecretMetadata_version;
14
13
  import { base64ToBytes, bytesToBase64, stringToBytes, bytesToString } from "@metamask/utils";
15
- import { SeedlessOnboardingControllerErrorMessage, SecretType } from "./constants.mjs";
16
- import { compareTimeuuid, getSecretTypeFromDataType } from "./utils.mjs";
14
+ import { SeedlessOnboardingControllerErrorMessage, SecretType, SecretMetadataVersion } from "./constants.mjs";
15
+ /**
16
+ * SecretMetadata is a class that adds metadata to the secret.
17
+ *
18
+ * It contains the secret and the timestamp when it was created.
19
+ * It is used to store the secret in the metadata store.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const secretMetadata = new SecretMetadata(secret);
24
+ * ```
25
+ */
17
26
  export class SecretMetadata {
18
27
  /**
19
- * @param data - The secret data.
20
- * @param options - Optional metadata. New clients should provide `dataType`.
28
+ * Create a new SecretMetadata instance.
29
+ *
30
+ * @param data - The secret to add metadata to.
31
+ * @param options - The options for the secret metadata.
32
+ * @param options.timestamp - The timestamp when the secret was created.
33
+ * @param options.type - The type of the secret.
21
34
  */
22
35
  constructor(data, options) {
23
36
  _SecretMetadata_data.set(this, void 0);
24
37
  _SecretMetadata_timestamp.set(this, void 0);
25
38
  _SecretMetadata_type.set(this, void 0);
26
- // Storage-level metadata (not encrypted)
27
- _SecretMetadata_itemId.set(this, void 0);
28
- _SecretMetadata_dataType.set(this, void 0);
29
- _SecretMetadata_createdAt.set(this, void 0);
30
- _SecretMetadata_storageVersion.set(this, void 0);
39
+ _SecretMetadata_version.set(this, void 0);
31
40
  __classPrivateFieldSet(this, _SecretMetadata_data, data, "f");
32
41
  __classPrivateFieldSet(this, _SecretMetadata_timestamp, options?.timestamp ?? Date.now(), "f");
33
- __classPrivateFieldSet(this, _SecretMetadata_itemId, options?.itemId, "f");
34
- __classPrivateFieldSet(this, _SecretMetadata_dataType, options?.dataType, "f");
35
- __classPrivateFieldSet(this, _SecretMetadata_createdAt, options?.createdAt, "f");
36
- __classPrivateFieldSet(this, _SecretMetadata_storageVersion, options?.storageVersion, "f");
37
- // Derive type from dataType (new clients), or use provided type (V1 compat)
38
- if (options?.dataType === undefined || options?.dataType === null) {
39
- __classPrivateFieldSet(this, _SecretMetadata_type, options?.type ?? SecretType.Mnemonic, "f");
40
- }
41
- else {
42
- __classPrivateFieldSet(this, _SecretMetadata_type, getSecretTypeFromDataType(options.dataType), "f");
43
- }
42
+ __classPrivateFieldSet(this, _SecretMetadata_type, options?.type ?? SecretType.Mnemonic, "f");
43
+ __classPrivateFieldSet(this, _SecretMetadata_version, options?.version ?? SecretMetadataVersion.V1, "f");
44
+ }
45
+ /**
46
+ * Create an Array of SecretMetadata instances from an array of secrets.
47
+ *
48
+ * To respect the order of the secrets, we add the index to the timestamp
49
+ * so that the first secret backup will have the oldest timestamp
50
+ * and the last secret backup will have the newest timestamp.
51
+ *
52
+ * @param batchData - The data to add metadata to.
53
+ * @param batchData.value - The SeedPhrase/PrivateKey to add metadata to.
54
+ * @param batchData.options - The options for the seed phrase metadata.
55
+ * @returns The SecretMetadata instances.
56
+ */
57
+ static fromBatch(batchData) {
58
+ const timestamp = Date.now();
59
+ return batchData.map((data, index) => {
60
+ // To respect the order of the seed phrases, we add the index to the timestamp
61
+ // so that the first seed phrase backup will have the oldest timestamp
62
+ // and the last seed phrase backup will have the newest timestamp
63
+ const backupCreatedAt = data.options?.timestamp ?? timestamp + index * 5;
64
+ return new SecretMetadata(data.value, {
65
+ timestamp: backupCreatedAt,
66
+ type: data.options?.type,
67
+ });
68
+ });
44
69
  }
45
70
  /**
46
71
  * Assert that the provided value is a valid seed phrase metadata.
@@ -58,18 +83,36 @@ export class SecretMetadata {
58
83
  throw new Error(SeedlessOnboardingControllerErrorMessage.InvalidSecretMetadata);
59
84
  }
60
85
  }
86
+ /**
87
+ * Parse the SecretMetadata from the metadata store and return the array of SecretMetadata instances.
88
+ *
89
+ * This method also sorts the secrets by timestamp in ascending order, i.e. the oldest secret will be the first element in the array.
90
+ *
91
+ * @param secretMetadataArr - The array of SecretMetadata from the metadata store.
92
+ * @param filterType - The type of the secret to filter.
93
+ * @returns The array of SecretMetadata instances.
94
+ */
95
+ static parseSecretsFromMetadataStore(secretMetadataArr, filterType) {
96
+ const parsedSecertMetadata = secretMetadataArr.map((metadata) => SecretMetadata.fromRawMetadata(metadata));
97
+ const secrets = SecretMetadata.sort(parsedSecertMetadata);
98
+ if (filterType) {
99
+ return secrets.filter((secret) => secret.type === filterType);
100
+ }
101
+ return secrets;
102
+ }
61
103
  /**
62
104
  * Parse and create the SecretMetadata instance from the raw metadata bytes.
63
105
  *
64
106
  * @param rawMetadata - The raw metadata.
65
- * @param storageMetadata - Storage-level metadata from the metadata store.
66
107
  * @returns The parsed secret metadata.
67
108
  */
68
- static fromRawMetadata(rawMetadata, storageMetadata) {
109
+ static fromRawMetadata(rawMetadata) {
69
110
  const serializedMetadata = bytesToString(rawMetadata);
70
111
  const parsedMetadata = JSON.parse(serializedMetadata);
71
112
  SecretMetadata.assertIsValidSecretMetadataJson(parsedMetadata);
113
+ // if the type is not provided, we default to Mnemonic for the backwards compatibility
72
114
  const type = parsedMetadata.type ?? SecretType.Mnemonic;
115
+ const version = parsedMetadata.version ?? SecretMetadataVersion.V1;
73
116
  let data;
74
117
  try {
75
118
  data = base64ToBytes(parsedMetadata.data);
@@ -80,72 +123,24 @@ export class SecretMetadata {
80
123
  return new SecretMetadata(data, {
81
124
  timestamp: parsedMetadata.timestamp,
82
125
  type,
83
- ...storageMetadata,
126
+ version,
84
127
  });
85
128
  }
86
129
  /**
87
- * Compare two SecretMetadata instances by timestamp.
88
- *
89
- * @param a - The first SecretMetadata instance.
90
- * @param b - The second SecretMetadata instance.
91
- * @param order - The sort order. Default is 'asc'.
92
- * @returns A negative number if a < b, positive if a > b, zero if equal.
93
- */
94
- static compareByTimestamp(a, b, order = 'asc') {
95
- return order === 'asc'
96
- ? a.timestamp - b.timestamp
97
- : b.timestamp - a.timestamp;
98
- }
99
- /**
100
- * Compare two SecretMetadata instances for ordering.
101
- *
102
- * Ordering priority:
103
- * 1. PrimarySrp always comes first (regardless of order direction)
104
- * 2. Server-side createdAt (TIMEUUID) if both have it
105
- * 3. Legacy items (null createdAt) are considered older
106
- * 4. Fall back to client-side timestamp
130
+ * Sort the seed phrases by timestamp.
107
131
  *
108
- * @param a - The first SecretMetadata instance.
109
- * @param b - The second SecretMetadata instance.
110
- * @param order - The sort order. Default is 'asc'.
111
- * @returns A negative number if a < b, positive if a > b, zero if equal.
112
- */
113
- static compare(a, b, order = 'asc') {
114
- // PrimarySrp always comes first (regardless of order direction)
115
- const aIsPrimary = a.dataType === EncAccountDataType.PrimarySrp;
116
- const bIsPrimary = b.dataType === EncAccountDataType.PrimarySrp;
117
- if (aIsPrimary && bIsPrimary) {
118
- return 0; // Both PrimarySrp: treat as equal (handles data corruption gracefully)
119
- }
120
- if (aIsPrimary) {
121
- return -1;
122
- }
123
- if (bIsPrimary) {
124
- return 1;
125
- }
126
- // Use server-side createdAt if available (TIMEUUID requires timestamp extraction)
127
- if (a.createdAt && b.createdAt) {
128
- return compareTimeuuid(a.createdAt, b.createdAt, order);
129
- }
130
- // Handle mixed createdAt: legacy items (null) are older
131
- if (!a.createdAt && b.createdAt) {
132
- return order === 'asc' ? -1 : 1; // a (legacy/older) comes before b in asc
133
- }
134
- if (a.createdAt && !b.createdAt) {
135
- return order === 'asc' ? 1 : -1; // b (legacy/older) comes before a in asc
136
- }
137
- // Both null: fall back to client-side timestamp
138
- return SecretMetadata.compareByTimestamp(a, b, order);
139
- }
140
- /**
141
- * Check if a SecretMetadata instance matches the given type.
132
+ * @param data - The secret metadata array to sort.
133
+ * @param order - The order to sort the seed phrases. Default is `desc`.
142
134
  *
143
- * @param secret - The SecretMetadata instance to check.
144
- * @param type - The type to match against.
145
- * @returns True if the secret matches the type.
135
+ * @returns The sorted secret metadata array.
146
136
  */
147
- static matchesType(secret, type) {
148
- return secret.type === type;
137
+ static sort(data, order = 'asc') {
138
+ return data.sort((a, b) => {
139
+ if (order === 'asc') {
140
+ return a.timestamp - b.timestamp;
141
+ }
142
+ return b.timestamp - a.timestamp;
143
+ });
149
144
  }
150
145
  get data() {
151
146
  return __classPrivateFieldGet(this, _SecretMetadata_data, "f");
@@ -156,22 +151,8 @@ export class SecretMetadata {
156
151
  get type() {
157
152
  return __classPrivateFieldGet(this, _SecretMetadata_type, "f");
158
153
  }
159
- get itemId() {
160
- return __classPrivateFieldGet(this, _SecretMetadata_itemId, "f");
161
- }
162
- get dataType() {
163
- return __classPrivateFieldGet(this, _SecretMetadata_dataType, "f");
164
- }
165
- get createdAt() {
166
- return __classPrivateFieldGet(this, _SecretMetadata_createdAt, "f");
167
- }
168
- /**
169
- * The storage-level version from the SDK ('v1' or 'v2').
170
- *
171
- * @returns The storage-level version.
172
- */
173
- get storageVersion() {
174
- return __classPrivateFieldGet(this, _SecretMetadata_storageVersion, "f");
154
+ get version() {
155
+ return __classPrivateFieldGet(this, _SecretMetadata_version, "f");
175
156
  }
176
157
  /**
177
158
  * Serialize the secret metadata and convert it to a Uint8Array.
@@ -190,10 +171,11 @@ export class SecretMetadata {
190
171
  data: _data,
191
172
  timestamp: __classPrivateFieldGet(this, _SecretMetadata_timestamp, "f"),
192
173
  type: __classPrivateFieldGet(this, _SecretMetadata_type, "f"),
174
+ version: __classPrivateFieldGet(this, _SecretMetadata_version, "f"),
193
175
  });
194
176
  // convert the serialized metadata to bytes(Uint8Array)
195
177
  return stringToBytes(serializedMetadata);
196
178
  }
197
179
  }
198
- _SecretMetadata_data = new WeakMap(), _SecretMetadata_timestamp = new WeakMap(), _SecretMetadata_type = new WeakMap(), _SecretMetadata_itemId = new WeakMap(), _SecretMetadata_dataType = new WeakMap(), _SecretMetadata_createdAt = new WeakMap(), _SecretMetadata_storageVersion = new WeakMap();
180
+ _SecretMetadata_data = new WeakMap(), _SecretMetadata_timestamp = new WeakMap(), _SecretMetadata_type = new WeakMap(), _SecretMetadata_version = new WeakMap();
199
181
  //# sourceMappingURL=SecretMetadata.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecretMetadata.mjs","sourceRoot":"","sources":["../src/SecretMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,sCAAsC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACd,wBAAwB;AAEzB,OAAO,EACL,wCAAwC,EACxC,UAAU,EACX,wBAAoB;AAErB,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,oBAAgB;AAuDrE,MAAM,OAAO,cAAc;IAkBzB;;;OAGG;IACH,YAAY,IAAc,EAAE,OAA+B;QAnBlD,uCAAgB;QAEhB,4CAAmB;QAEnB,uCAAkB;QAE3B,yCAAyC;QAChC,yCAAiB;QAEjB,2CAA+B;QAE/B,4CAAoB;QAEpB,iDAAkD;QAOzD,uBAAA,IAAI,wBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,6BAAc,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,MAAA,CAAC;QACnD,uBAAA,IAAI,0BAAW,OAAO,EAAE,MAAM,MAAA,CAA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iD;YACjD,oCAAoC;YACpC,KAAK,GAAG,aAAa,CAAC,uBAAA,IAAI,4BAAM,CAAC,CAAC;QACpC,CAAC;QAED,0CAA0C;QAC1C,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC;YACxC,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,uBAAA,IAAI,iCAAW;YAC1B,IAAI,EAAE,uBAAA,IAAI,4BAAM;SACjB,CAAC,CAAC;QAEH,uDAAuD;QACvD,OAAO,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import type { SecretDataItemOutput } from '@metamask/toprf-secure-backup';\nimport { EncAccountDataType } from '@metamask/toprf-secure-backup';\nimport {\n base64ToBytes,\n bytesToBase64,\n stringToBytes,\n bytesToString,\n} from '@metamask/utils';\n\nimport {\n SeedlessOnboardingControllerErrorMessage,\n SecretType,\n} from './constants';\nimport type { SecretDataType } from './types';\nimport { compareTimeuuid, getSecretTypeFromDataType } from './utils';\n\ntype ISecretMetadata<DataType extends SecretDataType = Uint8Array> = {\n data: DataType;\n timestamp: number;\n type: SecretType;\n toBytes: () => Uint8Array;\n};\n\n/**\n * SecretMetadata type without the data and toBytes methods\n * in which the data is base64 encoded for more compacted metadata\n */\ntype SecretMetadataJson<DataType extends SecretDataType> = Omit<\n ISecretMetadata<DataType>,\n 'data' | 'toBytes'\n> & {\n data: string; // base64 encoded string\n};\n\n/**\n * SecretMetadata is a class that adds metadata to the secret.\n *\n * It contains the secret and the timestamp when it was created.\n * It is used to store the secret in the metadata store.\n *\n * @example\n * ```ts\n * const secretMetadata = new SecretMetadata(secret);\n * ```\n */\n\n/**\n * Options for SecretMetadata constructor.\n *\n * New clients: provide V2 fields (`dataType`, `createdAt`, etc).\n * Reading V1 data: `timestamp` and `type` come from encrypted JSON.\n */\ntype SecretMetadataOptions = {\n // V1 fields (from encrypted JSON payload, for backward compat)\n timestamp?: number;\n type?: SecretType;\n\n // Storage-level metadata from the metadata store (not encrypted).\n itemId?: string;\n dataType?: EncAccountDataType;\n createdAt?: string;\n /**\n * The storage-level version from the SDK ('v1' or 'v2').\n * - 'v1': Legacy items created before dataType was introduced\n * - 'v2': Items with dataType set (either new or migrated)\n */\n storageVersion?: SecretDataItemOutput['version'];\n};\n\nexport class SecretMetadata<DataType extends SecretDataType = Uint8Array>\n implements ISecretMetadata<DataType>\n{\n readonly #data: DataType;\n\n readonly #timestamp: number;\n\n readonly #type: SecretType;\n\n // Storage-level metadata (not encrypted)\n readonly #itemId?: string;\n\n readonly #dataType?: EncAccountDataType;\n\n readonly #createdAt?: string;\n\n readonly #storageVersion?: SecretDataItemOutput['version'];\n\n /**\n * @param data - The secret data.\n * @param options - Optional metadata. New clients should provide `dataType`.\n */\n constructor(data: DataType, options?: SecretMetadataOptions) {\n this.#data = data;\n this.#timestamp = options?.timestamp ?? Date.now();\n this.#itemId = options?.itemId;\n this.#dataType = options?.dataType;\n this.#createdAt = options?.createdAt;\n this.#storageVersion = options?.storageVersion;\n\n // Derive type from dataType (new clients), or use provided type (V1 compat)\n if (options?.dataType === undefined || options?.dataType === null) {\n this.#type = options?.type ?? SecretType.Mnemonic;\n } else {\n this.#type = getSecretTypeFromDataType(options.dataType);\n }\n }\n\n /**\n * Assert that the provided value is a valid seed phrase metadata.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid seed phrase metadata.\n */\n static assertIsValidSecretMetadataJson<\n DataType extends SecretDataType = Uint8Array,\n >(value: unknown): asserts value is SecretMetadataJson<DataType> {\n if (\n typeof value !== 'object' ||\n !value ||\n !('data' in value) ||\n typeof value.data !== 'string' ||\n !('timestamp' in value) ||\n typeof value.timestamp !== 'number'\n ) {\n throw new Error(\n SeedlessOnboardingControllerErrorMessage.InvalidSecretMetadata,\n );\n }\n }\n\n /**\n * Parse and create the SecretMetadata instance from the raw metadata bytes.\n *\n * @param rawMetadata - The raw metadata.\n * @param storageMetadata - Storage-level metadata from the metadata store.\n * @returns The parsed secret metadata.\n */\n static fromRawMetadata<DataType extends SecretDataType>(\n rawMetadata: Uint8Array,\n storageMetadata: Omit<SecretMetadataOptions, 'timestamp' | 'type'>,\n ): SecretMetadata<DataType> {\n const serializedMetadata = bytesToString(rawMetadata);\n const parsedMetadata = JSON.parse(serializedMetadata);\n\n SecretMetadata.assertIsValidSecretMetadataJson<DataType>(parsedMetadata);\n\n const type = parsedMetadata.type ?? SecretType.Mnemonic;\n\n let data: DataType;\n try {\n data = base64ToBytes(parsedMetadata.data) as DataType;\n } catch {\n data = parsedMetadata.data as DataType;\n }\n\n return new SecretMetadata<DataType>(data, {\n timestamp: parsedMetadata.timestamp,\n type,\n ...storageMetadata,\n });\n }\n\n /**\n * Compare two SecretMetadata instances by timestamp.\n *\n * @param a - The first SecretMetadata instance.\n * @param b - The second SecretMetadata instance.\n * @param order - The sort order. Default is 'asc'.\n * @returns A negative number if a < b, positive if a > b, zero if equal.\n */\n static compareByTimestamp<DataType extends SecretDataType = SecretDataType>(\n a: SecretMetadata<DataType>,\n b: SecretMetadata<DataType>,\n order: 'asc' | 'desc' = 'asc',\n ): number {\n return order === 'asc'\n ? a.timestamp - b.timestamp\n : b.timestamp - a.timestamp;\n }\n\n /**\n * Compare two SecretMetadata instances for ordering.\n *\n * Ordering priority:\n * 1. PrimarySrp always comes first (regardless of order direction)\n * 2. Server-side createdAt (TIMEUUID) if both have it\n * 3. Legacy items (null createdAt) are considered older\n * 4. Fall back to client-side timestamp\n *\n * @param a - The first SecretMetadata instance.\n * @param b - The second SecretMetadata instance.\n * @param order - The sort order. Default is 'asc'.\n * @returns A negative number if a < b, positive if a > b, zero if equal.\n */\n static compare<DataType extends SecretDataType = SecretDataType>(\n a: SecretMetadata<DataType>,\n b: SecretMetadata<DataType>,\n order: 'asc' | 'desc' = 'asc',\n ): number {\n // PrimarySrp always comes first (regardless of order direction)\n const aIsPrimary = a.dataType === EncAccountDataType.PrimarySrp;\n const bIsPrimary = b.dataType === EncAccountDataType.PrimarySrp;\n if (aIsPrimary && bIsPrimary) {\n return 0; // Both PrimarySrp: treat as equal (handles data corruption gracefully)\n }\n if (aIsPrimary) {\n return -1;\n }\n if (bIsPrimary) {\n return 1;\n }\n // Use server-side createdAt if available (TIMEUUID requires timestamp extraction)\n if (a.createdAt && b.createdAt) {\n return compareTimeuuid(a.createdAt, b.createdAt, order);\n }\n // Handle mixed createdAt: legacy items (null) are older\n if (!a.createdAt && b.createdAt) {\n return order === 'asc' ? -1 : 1; // a (legacy/older) comes before b in asc\n }\n if (a.createdAt && !b.createdAt) {\n return order === 'asc' ? 1 : -1; // b (legacy/older) comes before a in asc\n }\n // Both null: fall back to client-side timestamp\n return SecretMetadata.compareByTimestamp(a, b, order);\n }\n\n /**\n * Check if a SecretMetadata instance matches the given type.\n *\n * @param secret - The SecretMetadata instance to check.\n * @param type - The type to match against.\n * @returns True if the secret matches the type.\n */\n static matchesType<DataType extends SecretDataType = SecretDataType>(\n secret: SecretMetadata<DataType>,\n type: SecretType,\n ): boolean {\n return secret.type === type;\n }\n\n get data(): DataType {\n return this.#data;\n }\n\n get timestamp(): number {\n return this.#timestamp;\n }\n\n get type(): SecretType {\n return this.#type;\n }\n\n get itemId(): string | undefined {\n return this.#itemId;\n }\n\n get dataType(): EncAccountDataType | undefined {\n return this.#dataType;\n }\n\n get createdAt(): string | undefined {\n return this.#createdAt;\n }\n\n /**\n * The storage-level version from the SDK ('v1' or 'v2').\n *\n * @returns The storage-level version.\n */\n get storageVersion(): SecretDataItemOutput['version'] | undefined {\n return this.#storageVersion;\n }\n\n /**\n * Serialize the secret metadata and convert it to a Uint8Array.\n *\n * @returns The serialized SecretMetadata value in bytes.\n */\n toBytes(): Uint8Array {\n let _data: unknown = this.#data;\n if (this.#data instanceof Uint8Array) {\n // encode the raw secret to base64 encoded string\n // to create more compacted metadata\n _data = bytesToBase64(this.#data);\n }\n\n // serialize the metadata to a JSON string\n const serializedMetadata = JSON.stringify({\n data: _data,\n timestamp: this.#timestamp,\n type: this.#type,\n });\n\n // convert the serialized metadata to bytes(Uint8Array)\n return stringToBytes(serializedMetadata);\n }\n}\n"]}
1
+ {"version":3,"file":"SecretMetadata.mjs","sourceRoot":"","sources":["../src/SecretMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACd,wBAAwB;AAEzB,OAAO,EACL,wCAAwC,EACxC,UAAU,EACV,qBAAqB,EACtB,wBAAoB;AAsBrB;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAWzB;;;;;;;OAOG;IACH,YAAY,IAAc,EAAE,OAAwC;QAhB3D,uCAAgB;QAEhB,4CAAmB;QAEnB,uCAAkB;QAElB,0CAAgC;QAWvC,uBAAA,IAAI,wBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,6BAAc,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,MAAA,CAAC;QACnD,uBAAA,IAAI,wBAAS,OAAO,EAAE,IAAI,IAAI,UAAU,CAAC,QAAQ,MAAA,CAAC;QAClD,uBAAA,IAAI,2BAAY,OAAO,EAAE,OAAO,IAAI,qBAAqB,CAAC,EAAE,MAAA,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,SAAS,CACd,SAGG;QAEH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACnC,8EAA8E;YAC9E,sEAAsE;YACtE,iEAAiE;YACjE,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,IAAI,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;YACzE,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE;gBACpC,SAAS,EAAE,eAAe;gBAC1B,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI;aACzB,CAAC,CAAC;QACL,CAAC,CA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,IAAI,CAAC,SAAS,CAAC;YACxC,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,uBAAA,IAAI,iCAAW;YAC1B,IAAI,EAAE,uBAAA,IAAI,4BAAM;YAChB,OAAO,EAAE,uBAAA,IAAI,+BAAS;SACvB,CAAC,CAAC;QAEH,uDAAuD;QACvD,OAAO,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import {\n base64ToBytes,\n bytesToBase64,\n stringToBytes,\n bytesToString,\n} from '@metamask/utils';\n\nimport {\n SeedlessOnboardingControllerErrorMessage,\n SecretType,\n SecretMetadataVersion,\n} from './constants';\nimport type { SecretDataType, SecretMetadataOptions } from './types';\n\ntype ISecretMetadata<DataType extends SecretDataType = Uint8Array> = {\n data: DataType;\n timestamp: number;\n type: SecretType;\n version: SecretMetadataVersion;\n toBytes: () => Uint8Array;\n};\n\n/**\n * SecretMetadata type without the data and toBytes methods\n * in which the data is base64 encoded for more compacted metadata\n */\ntype SecretMetadataJson<DataType extends SecretDataType> = Omit<\n ISecretMetadata<DataType>,\n 'data' | 'toBytes'\n> & {\n data: string; // base64 encoded string\n};\n\n/**\n * SecretMetadata is a class that adds metadata to the secret.\n *\n * It contains the secret and the timestamp when it was created.\n * It is used to store the secret in the metadata store.\n *\n * @example\n * ```ts\n * const secretMetadata = new SecretMetadata(secret);\n * ```\n */\nexport class SecretMetadata<DataType extends SecretDataType = Uint8Array>\n implements ISecretMetadata<DataType>\n{\n readonly #data: DataType;\n\n readonly #timestamp: number;\n\n readonly #type: SecretType;\n\n readonly #version: SecretMetadataVersion;\n\n /**\n * Create a new SecretMetadata instance.\n *\n * @param data - The secret to add metadata to.\n * @param options - The options for the secret metadata.\n * @param options.timestamp - The timestamp when the secret was created.\n * @param options.type - The type of the secret.\n */\n constructor(data: DataType, options?: Partial<SecretMetadataOptions>) {\n this.#data = data;\n this.#timestamp = options?.timestamp ?? Date.now();\n this.#type = options?.type ?? SecretType.Mnemonic;\n this.#version = options?.version ?? SecretMetadataVersion.V1;\n }\n\n /**\n * Create an Array of SecretMetadata instances from an array of secrets.\n *\n * To respect the order of the secrets, we add the index to the timestamp\n * so that the first secret backup will have the oldest timestamp\n * and the last secret backup will have the newest timestamp.\n *\n * @param batchData - The data to add metadata to.\n * @param batchData.value - The SeedPhrase/PrivateKey to add metadata to.\n * @param batchData.options - The options for the seed phrase metadata.\n * @returns The SecretMetadata instances.\n */\n static fromBatch<DataType extends SecretDataType = Uint8Array>(\n batchData: {\n value: DataType;\n options?: Partial<SecretMetadataOptions>;\n }[],\n ): SecretMetadata<DataType>[] {\n const timestamp = Date.now();\n return batchData.map((data, index) => {\n // To respect the order of the seed phrases, we add the index to the timestamp\n // so that the first seed phrase backup will have the oldest timestamp\n // and the last seed phrase backup will have the newest timestamp\n const backupCreatedAt = data.options?.timestamp ?? timestamp + index * 5;\n return new SecretMetadata(data.value, {\n timestamp: backupCreatedAt,\n type: data.options?.type,\n });\n });\n }\n\n /**\n * Assert that the provided value is a valid seed phrase metadata.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid seed phrase metadata.\n */\n static assertIsValidSecretMetadataJson<\n DataType extends SecretDataType = Uint8Array,\n >(value: unknown): asserts value is SecretMetadataJson<DataType> {\n if (\n typeof value !== 'object' ||\n !value ||\n !('data' in value) ||\n typeof value.data !== 'string' ||\n !('timestamp' in value) ||\n typeof value.timestamp !== 'number'\n ) {\n throw new Error(\n SeedlessOnboardingControllerErrorMessage.InvalidSecretMetadata,\n );\n }\n }\n\n /**\n * Parse the SecretMetadata from the metadata store and return the array of SecretMetadata instances.\n *\n * This method also sorts the secrets by timestamp in ascending order, i.e. the oldest secret will be the first element in the array.\n *\n * @param secretMetadataArr - The array of SecretMetadata from the metadata store.\n * @param filterType - The type of the secret to filter.\n * @returns The array of SecretMetadata instances.\n */\n static parseSecretsFromMetadataStore<\n DataType extends SecretDataType = Uint8Array,\n >(\n secretMetadataArr: Uint8Array[],\n filterType?: SecretType,\n ): SecretMetadata<DataType>[] {\n const parsedSecertMetadata = secretMetadataArr.map((metadata) =>\n SecretMetadata.fromRawMetadata<DataType>(metadata),\n );\n\n const secrets = SecretMetadata.sort(parsedSecertMetadata);\n\n if (filterType) {\n return secrets.filter((secret) => secret.type === filterType);\n }\n\n return secrets;\n }\n\n /**\n * Parse and create the SecretMetadata instance from the raw metadata bytes.\n *\n * @param rawMetadata - The raw metadata.\n * @returns The parsed secret metadata.\n */\n static fromRawMetadata<DataType extends SecretDataType>(\n rawMetadata: Uint8Array,\n ): SecretMetadata<DataType> {\n const serializedMetadata = bytesToString(rawMetadata);\n const parsedMetadata = JSON.parse(serializedMetadata);\n\n SecretMetadata.assertIsValidSecretMetadataJson<DataType>(parsedMetadata);\n\n // if the type is not provided, we default to Mnemonic for the backwards compatibility\n const type = parsedMetadata.type ?? SecretType.Mnemonic;\n const version = parsedMetadata.version ?? SecretMetadataVersion.V1;\n\n let data: DataType;\n try {\n data = base64ToBytes(parsedMetadata.data) as DataType;\n } catch {\n data = parsedMetadata.data as DataType;\n }\n\n return new SecretMetadata<DataType>(data, {\n timestamp: parsedMetadata.timestamp,\n type,\n version,\n });\n }\n\n /**\n * Sort the seed phrases by timestamp.\n *\n * @param data - The secret metadata array to sort.\n * @param order - The order to sort the seed phrases. Default is `desc`.\n *\n * @returns The sorted secret metadata array.\n */\n static sort<DataType extends SecretDataType = Uint8Array>(\n data: SecretMetadata<DataType>[],\n order: 'asc' | 'desc' = 'asc',\n ): SecretMetadata<DataType>[] {\n return data.sort((a, b) => {\n if (order === 'asc') {\n return a.timestamp - b.timestamp;\n }\n return b.timestamp - a.timestamp;\n });\n }\n\n get data(): DataType {\n return this.#data;\n }\n\n get timestamp(): number {\n return this.#timestamp;\n }\n\n get type(): SecretType {\n return this.#type;\n }\n\n get version(): SecretMetadataVersion {\n return this.#version;\n }\n\n /**\n * Serialize the secret metadata and convert it to a Uint8Array.\n *\n * @returns The serialized SecretMetadata value in bytes.\n */\n toBytes(): Uint8Array {\n let _data: unknown = this.#data;\n if (this.#data instanceof Uint8Array) {\n // encode the raw secret to base64 encoded string\n // to create more compacted metadata\n _data = bytesToBase64(this.#data);\n }\n\n // serialize the metadata to a JSON string\n const serializedMetadata = JSON.stringify({\n data: _data,\n timestamp: this.#timestamp,\n type: this.#type,\n version: this.#version,\n });\n\n // convert the serialized metadata to bytes(Uint8Array)\n return stringToBytes(serializedMetadata);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SeedlessOnboardingController-method-action-types.cjs","sourceRoot":"","sources":["../src/SeedlessOnboardingController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { SeedlessOnboardingController } from './SeedlessOnboardingController';\n\nexport type SeedlessOnboardingControllerFetchMetadataAccessCredsAction = {\n type: `SeedlessOnboardingController:fetchMetadataAccessCreds`;\n handler: SeedlessOnboardingController['fetchMetadataAccessCreds'];\n};\n\n/**\n * Gets the node details for the TOPRF operations.\n * This function can be called to get the node endpoints, indexes and pubkeys and cache them locally.\n */\nexport type SeedlessOnboardingControllerPreloadToprfNodeDetailsAction = {\n type: `SeedlessOnboardingController:preloadToprfNodeDetails`;\n handler: SeedlessOnboardingController['preloadToprfNodeDetails'];\n};\n\n/**\n * Authenticate OAuth user using the seedless onboarding flow\n * and determine if the user is already registered or not.\n *\n * @param params - The parameters for authenticate OAuth user.\n * @param params.idTokens - The ID token(s) issued by OAuth verification service. Currently this array only contains a single idToken which is verified by all the nodes, in future we are considering to issue a unique idToken for each node.\n * @param params.authConnection - The social login provider.\n * @param params.authConnectionId - OAuth authConnectionId from dashboard\n * @param params.userId - user email or id from Social login\n * @param params.groupedAuthConnectionId - Optional grouped authConnectionId to be used for the authenticate request.\n * @param params.socialLoginEmail - The user email from Social login.\n * @param params.refreshToken - Refresh token issued during OAuth login. Written to state when provided.\n * @param params.revokeToken - revoke token for revoking refresh token and get new refresh token and new revoke token.\n * @param params.accessToken - Access token for pairing with profile sync auth service and to access other services.\n * @param params.metadataAccessToken - Metadata access token for accessing the metadata service before the vault is created or unlocked.\n * @param params.skipLock - Optional flag to skip acquiring the controller lock. (to prevent deadlock in case the caller already acquired the lock)\n * @returns A promise that resolves to the authentication result.\n */\nexport type SeedlessOnboardingControllerAuthenticateAction = {\n type: `SeedlessOnboardingController:authenticate`;\n handler: SeedlessOnboardingController['authenticate'];\n};\n\n/**\n * Create a new TOPRF encryption key using given password and backups the provided seed phrase.\n *\n * @param password - The password used to create new wallet and seedphrase\n * @param seedPhrase - The initial seed phrase (Mnemonic) created together with the wallet.\n * @param keyringId - The keyring id of the backup seed phrase\n * @returns A promise that resolves to the encrypted seed phrase and the encryption key.\n */\nexport type SeedlessOnboardingControllerCreateToprfKeyAndBackupSeedPhraseAction =\n {\n type: `SeedlessOnboardingController:createToprfKeyAndBackupSeedPhrase`;\n handler: SeedlessOnboardingController['createToprfKeyAndBackupSeedPhrase'];\n };\n\n/**\n * Encrypt and add a new secret data to the metadata store.\n *\n * @param data - The data to add.\n * @param dataType - The data type classification for the secret data.\n * @param options - Optional options object, which includes optional data to be added to the metadata store.\n * @param options.keyringId - The keyring id of the backup keyring (SRP).\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerAddNewSecretDataAction = {\n type: `SeedlessOnboardingController:addNewSecretData`;\n handler: SeedlessOnboardingController['addNewSecretData'];\n};\n\n/**\n * Fetches all secret data items from the metadata store.\n *\n * Decrypts the secret data and returns the decrypted secret data using the recovered encryption key from the password.\n *\n * @param password - The optional password used to create new wallet. If not provided, `cached Encryption Key` will be used.\n * @returns A promise that resolves to the secret metadata items.\n */\nexport type SeedlessOnboardingControllerFetchAllSecretDataAction = {\n type: `SeedlessOnboardingController:fetchAllSecretData`;\n handler: SeedlessOnboardingController['fetchAllSecretData'];\n};\n\n/**\n * Update the password of the seedless onboarding flow.\n *\n * Changing password will also update the encryption key, metadata store and the vault with new encrypted values.\n *\n * @param newPassword - The new password to update.\n * @param oldPassword - The old password to verify.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerChangePasswordAction = {\n type: `SeedlessOnboardingController:changePassword`;\n handler: SeedlessOnboardingController['changePassword'];\n};\n\n/**\n * Update the backup metadata state for the given secret data.\n *\n * @param secretData - The data to backup, can be a single backup or array of backups.\n * @param secretData.keyringId - The keyring id associated with the backup secret data.\n * @param secretData.data - The secret data to update the backup metadata state.\n */\nexport type SeedlessOnboardingControllerUpdateBackupMetadataStateAction = {\n type: `SeedlessOnboardingController:updateBackupMetadataState`;\n handler: SeedlessOnboardingController['updateBackupMetadataState'];\n};\n\n/**\n * Verify the password validity by decrypting the vault.\n *\n * @param password - The password to verify.\n * @param options - Optional options object.\n * @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)\n * @returns A promise that resolves to the success of the operation.\n * @throws {Error} If the password is invalid or the vault is not initialized.\n */\nexport type SeedlessOnboardingControllerVerifyVaultPasswordAction = {\n type: `SeedlessOnboardingController:verifyVaultPassword`;\n handler: SeedlessOnboardingController['verifyVaultPassword'];\n};\n\n/**\n * Get backup state of the given secret data, from the controller state.\n *\n * If the given secret data is not backed up and not found in the state, it will return `undefined`.\n *\n * @param data - The data to get the backup state of.\n * @param type - The type of the secret data.\n * @returns The backup state of the given secret data.\n */\nexport type SeedlessOnboardingControllerGetSecretDataBackupStateAction = {\n type: `SeedlessOnboardingController:getSecretDataBackupState`;\n handler: SeedlessOnboardingController['getSecretDataBackupState'];\n};\n\n/**\n * Submit the password to the controller, verify the password validity and unlock the controller.\n *\n * This method will be used especially when user unlock the wallet.\n * The provided password will be verified against the encrypted vault, encryption key will be derived and saved in the controller state.\n *\n * This operation is useful when user performs some actions that requires the user password/encryption key. e.g. add new srp backup\n *\n * @param password - The password to submit.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSubmitPasswordAction = {\n type: `SeedlessOnboardingController:submitPassword`;\n handler: SeedlessOnboardingController['submitPassword'];\n};\n\n/**\n * Set the controller to locked state, and deallocate the secrets (vault encryption key and salt).\n *\n * When the controller is locked, the user will not be able to perform any operations on the controller/vault.\n *\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSetLockedAction = {\n type: `SeedlessOnboardingController:setLocked`;\n handler: SeedlessOnboardingController['setLocked'];\n};\n\n/**\n * Sync the latest global password to the controller.\n * reset vault with latest globalPassword,\n * persist the latest global password authPubKey\n *\n * @param params - The parameters for syncing the latest global password.\n * @param params.globalPassword - The latest global password.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSyncLatestGlobalPasswordAction = {\n type: `SeedlessOnboardingController:syncLatestGlobalPassword`;\n handler: SeedlessOnboardingController['syncLatestGlobalPassword'];\n};\n\n/**\n * @description Unlock the controller with the latest global password.\n *\n * @param params - The parameters for unlocking the controller.\n * @param params.maxKeyChainLength - The maximum chain length of the pwd encryption keys.\n * @param params.globalPassword - The latest global password.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSubmitGlobalPasswordAction = {\n type: `SeedlessOnboardingController:submitGlobalPassword`;\n handler: SeedlessOnboardingController['submitGlobalPassword'];\n};\n\n/**\n * @description Check if the current password is outdated compare to the global password.\n *\n * @param options - Optional options object.\n * @param options.globalAuthPubKey - The global auth public key to compare with the current auth public key.\n * If not provided, the global auth public key will be fetched from the backend.\n * @param options.skipCache - If true, bypass the cache and force a fresh check.\n * @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)\n * @returns A promise that resolves to true if the password is outdated, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckIsPasswordOutdatedAction = {\n type: `SeedlessOnboardingController:checkIsPasswordOutdated`;\n handler: SeedlessOnboardingController['checkIsPasswordOutdated'];\n};\n\n/**\n * Check if the user is authenticated with the seedless onboarding flow by checking the token values in the state.\n *\n * This method will check the `accessToken` and `revokeToken` in the state, besides the social login authentication details.\n * If both are present, the user is authenticated.\n * If either is missing, the user is not authenticated.\n *\n * This method is useful when we want to check if the state has valid authenticated user details to perform vault creations.\n *\n * @returns True if the user is authenticated, false otherwise.\n */\nexport type SeedlessOnboardingControllerGetIsUserAuthenticatedAction = {\n type: `SeedlessOnboardingController:getIsUserAuthenticated`;\n handler: SeedlessOnboardingController['getIsUserAuthenticated'];\n};\n\n/**\n * Clears the current state of the SeedlessOnboardingController.\n */\nexport type SeedlessOnboardingControllerClearStateAction = {\n type: `SeedlessOnboardingController:clearState`;\n handler: SeedlessOnboardingController['clearState'];\n};\n\n/**\n * Store the keyring encryption key in state, encrypted under the current\n * encryption key.\n *\n * @param keyringEncryptionKey - The keyring encryption key.\n */\nexport type SeedlessOnboardingControllerStoreKeyringEncryptionKeyAction = {\n type: `SeedlessOnboardingController:storeKeyringEncryptionKey`;\n handler: SeedlessOnboardingController['storeKeyringEncryptionKey'];\n};\n\n/**\n * Load the keyring encryption key from state, decrypted under the current\n * encryption key.\n *\n * @returns The keyring encryption key.\n */\nexport type SeedlessOnboardingControllerLoadKeyringEncryptionKeyAction = {\n type: `SeedlessOnboardingController:loadKeyringEncryptionKey`;\n handler: SeedlessOnboardingController['loadKeyringEncryptionKey'];\n};\n\n/**\n * Refresh expired nodeAuthTokens, accessToken, and metadataAccessToken using\n * the stored refresh token.\n *\n * Concurrent callers share a single in-flight HTTP request — if a refresh is\n * already in-progress the returned promise resolves when that request settles\n * rather than firing a duplicate request with the same token.\n *\n * @returns A promise that resolves when the tokens have been refreshed.\n */\nexport type SeedlessOnboardingControllerRefreshAuthTokensAction = {\n type: `SeedlessOnboardingController:refreshAuthTokens`;\n handler: SeedlessOnboardingController['refreshAuthTokens'];\n};\n\n/**\n * Rotate the refresh token — fetch a new refresh/revoke token pair from the\n * auth service and persist the new revoke token in the vault.\n *\n * This method should be called after a successful JWT refresh.\n *\n * @returns A Promise that resolves to void.\n */\nexport type SeedlessOnboardingControllerRotateRefreshTokenAction = {\n type: `SeedlessOnboardingController:rotateRefreshToken`;\n handler: SeedlessOnboardingController['rotateRefreshToken'];\n};\n\n/**\n * Revoke all pending refresh tokens.\n *\n * This method is to be called after user is authenticated.\n *\n * @returns A Promise that resolves to void.\n */\nexport type SeedlessOnboardingControllerRevokePendingRefreshTokensAction = {\n type: `SeedlessOnboardingController:revokePendingRefreshTokens`;\n handler: SeedlessOnboardingController['revokePendingRefreshTokens'];\n};\n\n/**\n * Get the access token from the state.\n *\n * If the tokens are expired, the method will refresh them and return the new access token.\n *\n * @returns The access token.\n */\nexport type SeedlessOnboardingControllerGetAccessTokenAction = {\n type: `SeedlessOnboardingController:getAccessToken`;\n handler: SeedlessOnboardingController['getAccessToken'];\n};\n\n/**\n * Check if the current node auth token is expired.\n *\n * @returns True if the current node auth token is expired, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckNodeAuthTokenExpiredAction = {\n type: `SeedlessOnboardingController:checkNodeAuthTokenExpired`;\n handler: SeedlessOnboardingController['checkNodeAuthTokenExpired'];\n};\n\n/**\n * Check if the current metadata access token should be refreshed.\n * Returns true when the token is expired or when less than 10% of its\n * lifetime remains (proactive refresh).\n *\n * @returns True if the metadata access token should be refreshed, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckMetadataAccessTokenExpiredAction =\n {\n type: `SeedlessOnboardingController:checkMetadataAccessTokenExpired`;\n handler: SeedlessOnboardingController['checkMetadataAccessTokenExpired'];\n };\n\n/**\n * Check if the current access token should be refreshed.\n * Returns true when the token is expired or when less than 10% of its\n * lifetime remains (proactive refresh).\n * When the vault is locked, the access token is not accessible, so we return false.\n *\n * @returns True if the access token should be refreshed, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckAccessTokenExpiredAction = {\n type: `SeedlessOnboardingController:checkAccessTokenExpired`;\n handler: SeedlessOnboardingController['checkAccessTokenExpired'];\n};\n\n/**\n * Union of all SeedlessOnboardingController action types.\n */\nexport type SeedlessOnboardingControllerMethodActions =\n | SeedlessOnboardingControllerFetchMetadataAccessCredsAction\n | SeedlessOnboardingControllerPreloadToprfNodeDetailsAction\n | SeedlessOnboardingControllerAuthenticateAction\n | SeedlessOnboardingControllerCreateToprfKeyAndBackupSeedPhraseAction\n | SeedlessOnboardingControllerAddNewSecretDataAction\n | SeedlessOnboardingControllerFetchAllSecretDataAction\n | SeedlessOnboardingControllerChangePasswordAction\n | SeedlessOnboardingControllerUpdateBackupMetadataStateAction\n | SeedlessOnboardingControllerVerifyVaultPasswordAction\n | SeedlessOnboardingControllerGetSecretDataBackupStateAction\n | SeedlessOnboardingControllerSubmitPasswordAction\n | SeedlessOnboardingControllerSetLockedAction\n | SeedlessOnboardingControllerSyncLatestGlobalPasswordAction\n | SeedlessOnboardingControllerSubmitGlobalPasswordAction\n | SeedlessOnboardingControllerCheckIsPasswordOutdatedAction\n | SeedlessOnboardingControllerGetIsUserAuthenticatedAction\n | SeedlessOnboardingControllerClearStateAction\n | SeedlessOnboardingControllerStoreKeyringEncryptionKeyAction\n | SeedlessOnboardingControllerLoadKeyringEncryptionKeyAction\n | SeedlessOnboardingControllerRefreshAuthTokensAction\n | SeedlessOnboardingControllerRotateRefreshTokenAction\n | SeedlessOnboardingControllerRevokePendingRefreshTokensAction\n | SeedlessOnboardingControllerGetAccessTokenAction\n | SeedlessOnboardingControllerCheckNodeAuthTokenExpiredAction\n | SeedlessOnboardingControllerCheckMetadataAccessTokenExpiredAction\n | SeedlessOnboardingControllerCheckAccessTokenExpiredAction;\n"]}
1
+ {"version":3,"file":"SeedlessOnboardingController-method-action-types.cjs","sourceRoot":"","sources":["../src/SeedlessOnboardingController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { SeedlessOnboardingController } from './SeedlessOnboardingController';\n\nexport type SeedlessOnboardingControllerFetchMetadataAccessCredsAction = {\n type: `SeedlessOnboardingController:fetchMetadataAccessCreds`;\n handler: SeedlessOnboardingController['fetchMetadataAccessCreds'];\n};\n\n/**\n * Gets the node details for the TOPRF operations.\n * This function can be called to get the node endpoints, indexes and pubkeys and cache them locally.\n */\nexport type SeedlessOnboardingControllerPreloadToprfNodeDetailsAction = {\n type: `SeedlessOnboardingController:preloadToprfNodeDetails`;\n handler: SeedlessOnboardingController['preloadToprfNodeDetails'];\n};\n\n/**\n * Authenticate OAuth user using the seedless onboarding flow\n * and determine if the user is already registered or not.\n *\n * @param params - The parameters for authenticate OAuth user.\n * @param params.idTokens - The ID token(s) issued by OAuth verification service. Currently this array only contains a single idToken which is verified by all the nodes, in future we are considering to issue a unique idToken for each node.\n * @param params.authConnection - The social login provider.\n * @param params.authConnectionId - OAuth authConnectionId from dashboard\n * @param params.userId - user email or id from Social login\n * @param params.groupedAuthConnectionId - Optional grouped authConnectionId to be used for the authenticate request.\n * @param params.socialLoginEmail - The user email from Social login.\n * @param params.refreshToken - Refresh token issued during OAuth login. Written to state when provided.\n * @param params.revokeToken - revoke token for revoking refresh token and get new refresh token and new revoke token.\n * @param params.accessToken - Access token for pairing with profile sync auth service and to access other services.\n * @param params.metadataAccessToken - Metadata access token for accessing the metadata service before the vault is created or unlocked.\n * @param params.skipLock - Optional flag to skip acquiring the controller lock. (to prevent deadlock in case the caller already acquired the lock)\n * @returns A promise that resolves to the authentication result.\n */\nexport type SeedlessOnboardingControllerAuthenticateAction = {\n type: `SeedlessOnboardingController:authenticate`;\n handler: SeedlessOnboardingController['authenticate'];\n};\n\n/**\n * Create a new TOPRF encryption key using given password and backups the provided seed phrase.\n *\n * @param password - The password used to create new wallet and seedphrase\n * @param seedPhrase - The initial seed phrase (Mnemonic) created together with the wallet.\n * @param keyringId - The keyring id of the backup seed phrase\n * @returns A promise that resolves to the encrypted seed phrase and the encryption key.\n */\nexport type SeedlessOnboardingControllerCreateToprfKeyAndBackupSeedPhraseAction =\n {\n type: `SeedlessOnboardingController:createToprfKeyAndBackupSeedPhrase`;\n handler: SeedlessOnboardingController['createToprfKeyAndBackupSeedPhrase'];\n };\n\n/**\n * encrypt and add a new secret data to the metadata store.\n *\n * @param data - The data to add.\n * @param type - The type of the secret data.\n * @param options - Optional options object, which includes optional data to be added to the metadata store.\n * @param options.keyringId - The keyring id of the backup keyring (SRP).\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerAddNewSecretDataAction = {\n type: `SeedlessOnboardingController:addNewSecretData`;\n handler: SeedlessOnboardingController['addNewSecretData'];\n};\n\n/**\n * Fetches all encrypted secret data and metadata for user's account from the metadata store.\n *\n * Decrypts the secret data and returns the decrypted secret data using the recovered encryption key from the password.\n *\n * @param password - The optional password used to create new wallet. If not provided, `cached Encryption Key` will be used.\n * @returns A promise that resolves to the secret data.\n */\nexport type SeedlessOnboardingControllerFetchAllSecretDataAction = {\n type: `SeedlessOnboardingController:fetchAllSecretData`;\n handler: SeedlessOnboardingController['fetchAllSecretData'];\n};\n\n/**\n * Update the password of the seedless onboarding flow.\n *\n * Changing password will also update the encryption key, metadata store and the vault with new encrypted values.\n *\n * @param newPassword - The new password to update.\n * @param oldPassword - The old password to verify.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerChangePasswordAction = {\n type: `SeedlessOnboardingController:changePassword`;\n handler: SeedlessOnboardingController['changePassword'];\n};\n\n/**\n * Update the backup metadata state for the given secret data.\n *\n * @param secretData - The data to backup, can be a single backup or array of backups.\n * @param secretData.keyringId - The keyring id associated with the backup secret data.\n * @param secretData.data - The secret data to update the backup metadata state.\n */\nexport type SeedlessOnboardingControllerUpdateBackupMetadataStateAction = {\n type: `SeedlessOnboardingController:updateBackupMetadataState`;\n handler: SeedlessOnboardingController['updateBackupMetadataState'];\n};\n\n/**\n * Verify the password validity by decrypting the vault.\n *\n * @param password - The password to verify.\n * @param options - Optional options object.\n * @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)\n * @returns A promise that resolves to the success of the operation.\n * @throws {Error} If the password is invalid or the vault is not initialized.\n */\nexport type SeedlessOnboardingControllerVerifyVaultPasswordAction = {\n type: `SeedlessOnboardingController:verifyVaultPassword`;\n handler: SeedlessOnboardingController['verifyVaultPassword'];\n};\n\n/**\n * Get backup state of the given secret data, from the controller state.\n *\n * If the given secret data is not backed up and not found in the state, it will return `undefined`.\n *\n * @param data - The data to get the backup state of.\n * @param type - The type of the secret data.\n * @returns The backup state of the given secret data.\n */\nexport type SeedlessOnboardingControllerGetSecretDataBackupStateAction = {\n type: `SeedlessOnboardingController:getSecretDataBackupState`;\n handler: SeedlessOnboardingController['getSecretDataBackupState'];\n};\n\n/**\n * Submit the password to the controller, verify the password validity and unlock the controller.\n *\n * This method will be used especially when user unlock the wallet.\n * The provided password will be verified against the encrypted vault, encryption key will be derived and saved in the controller state.\n *\n * This operation is useful when user performs some actions that requires the user password/encryption key. e.g. add new srp backup\n *\n * @param password - The password to submit.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSubmitPasswordAction = {\n type: `SeedlessOnboardingController:submitPassword`;\n handler: SeedlessOnboardingController['submitPassword'];\n};\n\n/**\n * Set the controller to locked state, and deallocate the secrets (vault encryption key and salt).\n *\n * When the controller is locked, the user will not be able to perform any operations on the controller/vault.\n *\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSetLockedAction = {\n type: `SeedlessOnboardingController:setLocked`;\n handler: SeedlessOnboardingController['setLocked'];\n};\n\n/**\n * Sync the latest global password to the controller.\n * reset vault with latest globalPassword,\n * persist the latest global password authPubKey\n *\n * @param params - The parameters for syncing the latest global password.\n * @param params.globalPassword - The latest global password.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSyncLatestGlobalPasswordAction = {\n type: `SeedlessOnboardingController:syncLatestGlobalPassword`;\n handler: SeedlessOnboardingController['syncLatestGlobalPassword'];\n};\n\n/**\n * @description Unlock the controller with the latest global password.\n *\n * @param params - The parameters for unlocking the controller.\n * @param params.maxKeyChainLength - The maximum chain length of the pwd encryption keys.\n * @param params.globalPassword - The latest global password.\n * @returns A promise that resolves to the success of the operation.\n */\nexport type SeedlessOnboardingControllerSubmitGlobalPasswordAction = {\n type: `SeedlessOnboardingController:submitGlobalPassword`;\n handler: SeedlessOnboardingController['submitGlobalPassword'];\n};\n\n/**\n * @description Check if the current password is outdated compare to the global password.\n *\n * @param options - Optional options object.\n * @param options.globalAuthPubKey - The global auth public key to compare with the current auth public key.\n * If not provided, the global auth public key will be fetched from the backend.\n * @param options.skipCache - If true, bypass the cache and force a fresh check.\n * @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)\n * @returns A promise that resolves to true if the password is outdated, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckIsPasswordOutdatedAction = {\n type: `SeedlessOnboardingController:checkIsPasswordOutdated`;\n handler: SeedlessOnboardingController['checkIsPasswordOutdated'];\n};\n\n/**\n * Check if the user is authenticated with the seedless onboarding flow by checking the token values in the state.\n *\n * This method will check the `accessToken` and `revokeToken` in the state, besides the social login authentication details.\n * If both are present, the user is authenticated.\n * If either is missing, the user is not authenticated.\n *\n * This method is useful when we want to check if the state has valid authenticated user details to perform vault creations.\n *\n * @returns True if the user is authenticated, false otherwise.\n */\nexport type SeedlessOnboardingControllerGetIsUserAuthenticatedAction = {\n type: `SeedlessOnboardingController:getIsUserAuthenticated`;\n handler: SeedlessOnboardingController['getIsUserAuthenticated'];\n};\n\n/**\n * Clears the current state of the SeedlessOnboardingController.\n */\nexport type SeedlessOnboardingControllerClearStateAction = {\n type: `SeedlessOnboardingController:clearState`;\n handler: SeedlessOnboardingController['clearState'];\n};\n\n/**\n * Store the keyring encryption key in state, encrypted under the current\n * encryption key.\n *\n * @param keyringEncryptionKey - The keyring encryption key.\n */\nexport type SeedlessOnboardingControllerStoreKeyringEncryptionKeyAction = {\n type: `SeedlessOnboardingController:storeKeyringEncryptionKey`;\n handler: SeedlessOnboardingController['storeKeyringEncryptionKey'];\n};\n\n/**\n * Load the keyring encryption key from state, decrypted under the current\n * encryption key.\n *\n * @returns The keyring encryption key.\n */\nexport type SeedlessOnboardingControllerLoadKeyringEncryptionKeyAction = {\n type: `SeedlessOnboardingController:loadKeyringEncryptionKey`;\n handler: SeedlessOnboardingController['loadKeyringEncryptionKey'];\n};\n\n/**\n * Refresh expired nodeAuthTokens, accessToken, and metadataAccessToken using\n * the stored refresh token.\n *\n * Concurrent callers share a single in-flight HTTP request — if a refresh is\n * already in-progress the returned promise resolves when that request settles\n * rather than firing a duplicate request with the same token.\n *\n * @returns A promise that resolves when the tokens have been refreshed.\n */\nexport type SeedlessOnboardingControllerRefreshAuthTokensAction = {\n type: `SeedlessOnboardingController:refreshAuthTokens`;\n handler: SeedlessOnboardingController['refreshAuthTokens'];\n};\n\n/**\n * Rotate the refresh token — fetch a new refresh/revoke token pair from the\n * auth service and persist the new revoke token in the vault.\n *\n * This method should be called after a successful JWT refresh.\n *\n * @returns A Promise that resolves to void.\n */\nexport type SeedlessOnboardingControllerRotateRefreshTokenAction = {\n type: `SeedlessOnboardingController:rotateRefreshToken`;\n handler: SeedlessOnboardingController['rotateRefreshToken'];\n};\n\n/**\n * Revoke all pending refresh tokens.\n *\n * This method is to be called after user is authenticated.\n *\n * @returns A Promise that resolves to void.\n */\nexport type SeedlessOnboardingControllerRevokePendingRefreshTokensAction = {\n type: `SeedlessOnboardingController:revokePendingRefreshTokens`;\n handler: SeedlessOnboardingController['revokePendingRefreshTokens'];\n};\n\n/**\n * Get the access token from the state.\n *\n * If the tokens are expired, the method will refresh them and return the new access token.\n *\n * @returns The access token.\n */\nexport type SeedlessOnboardingControllerGetAccessTokenAction = {\n type: `SeedlessOnboardingController:getAccessToken`;\n handler: SeedlessOnboardingController['getAccessToken'];\n};\n\n/**\n * Check if the current node auth token is expired.\n *\n * @returns True if the current node auth token is expired, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckNodeAuthTokenExpiredAction = {\n type: `SeedlessOnboardingController:checkNodeAuthTokenExpired`;\n handler: SeedlessOnboardingController['checkNodeAuthTokenExpired'];\n};\n\n/**\n * Check if the current metadata access token should be refreshed.\n * Returns true when the token is expired or when less than 10% of its\n * lifetime remains (proactive refresh).\n *\n * @returns True if the metadata access token should be refreshed, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckMetadataAccessTokenExpiredAction =\n {\n type: `SeedlessOnboardingController:checkMetadataAccessTokenExpired`;\n handler: SeedlessOnboardingController['checkMetadataAccessTokenExpired'];\n };\n\n/**\n * Check if the current access token should be refreshed.\n * Returns true when the token is expired or when less than 10% of its\n * lifetime remains (proactive refresh).\n * When the vault is locked, the access token is not accessible, so we return false.\n *\n * @returns True if the access token should be refreshed, false otherwise.\n */\nexport type SeedlessOnboardingControllerCheckAccessTokenExpiredAction = {\n type: `SeedlessOnboardingController:checkAccessTokenExpired`;\n handler: SeedlessOnboardingController['checkAccessTokenExpired'];\n};\n\n/**\n * Union of all SeedlessOnboardingController action types.\n */\nexport type SeedlessOnboardingControllerMethodActions =\n | SeedlessOnboardingControllerFetchMetadataAccessCredsAction\n | SeedlessOnboardingControllerPreloadToprfNodeDetailsAction\n | SeedlessOnboardingControllerAuthenticateAction\n | SeedlessOnboardingControllerCreateToprfKeyAndBackupSeedPhraseAction\n | SeedlessOnboardingControllerAddNewSecretDataAction\n | SeedlessOnboardingControllerFetchAllSecretDataAction\n | SeedlessOnboardingControllerChangePasswordAction\n | SeedlessOnboardingControllerUpdateBackupMetadataStateAction\n | SeedlessOnboardingControllerVerifyVaultPasswordAction\n | SeedlessOnboardingControllerGetSecretDataBackupStateAction\n | SeedlessOnboardingControllerSubmitPasswordAction\n | SeedlessOnboardingControllerSetLockedAction\n | SeedlessOnboardingControllerSyncLatestGlobalPasswordAction\n | SeedlessOnboardingControllerSubmitGlobalPasswordAction\n | SeedlessOnboardingControllerCheckIsPasswordOutdatedAction\n | SeedlessOnboardingControllerGetIsUserAuthenticatedAction\n | SeedlessOnboardingControllerClearStateAction\n | SeedlessOnboardingControllerStoreKeyringEncryptionKeyAction\n | SeedlessOnboardingControllerLoadKeyringEncryptionKeyAction\n | SeedlessOnboardingControllerRefreshAuthTokensAction\n | SeedlessOnboardingControllerRotateRefreshTokenAction\n | SeedlessOnboardingControllerRevokePendingRefreshTokensAction\n | SeedlessOnboardingControllerGetAccessTokenAction\n | SeedlessOnboardingControllerCheckNodeAuthTokenExpiredAction\n | SeedlessOnboardingControllerCheckMetadataAccessTokenExpiredAction\n | SeedlessOnboardingControllerCheckAccessTokenExpiredAction;\n"]}
@@ -50,10 +50,10 @@ export type SeedlessOnboardingControllerCreateToprfKeyAndBackupSeedPhraseAction
50
50
  handler: SeedlessOnboardingController['createToprfKeyAndBackupSeedPhrase'];
51
51
  };
52
52
  /**
53
- * Encrypt and add a new secret data to the metadata store.
53
+ * encrypt and add a new secret data to the metadata store.
54
54
  *
55
55
  * @param data - The data to add.
56
- * @param dataType - The data type classification for the secret data.
56
+ * @param type - The type of the secret data.
57
57
  * @param options - Optional options object, which includes optional data to be added to the metadata store.
58
58
  * @param options.keyringId - The keyring id of the backup keyring (SRP).
59
59
  * @returns A promise that resolves to the success of the operation.
@@ -63,12 +63,12 @@ export type SeedlessOnboardingControllerAddNewSecretDataAction = {
63
63
  handler: SeedlessOnboardingController['addNewSecretData'];
64
64
  };
65
65
  /**
66
- * Fetches all secret data items from the metadata store.
66
+ * Fetches all encrypted secret data and metadata for user's account from the metadata store.
67
67
  *
68
68
  * Decrypts the secret data and returns the decrypted secret data using the recovered encryption key from the password.
69
69
  *
70
70
  * @param password - The optional password used to create new wallet. If not provided, `cached Encryption Key` will be used.
71
- * @returns A promise that resolves to the secret metadata items.
71
+ * @returns A promise that resolves to the secret data.
72
72
  */
73
73
  export type SeedlessOnboardingControllerFetchAllSecretDataAction = {
74
74
  type: `SeedlessOnboardingController:fetchAllSecretData`;
@@ -50,10 +50,10 @@ export type SeedlessOnboardingControllerCreateToprfKeyAndBackupSeedPhraseAction
50
50
  handler: SeedlessOnboardingController['createToprfKeyAndBackupSeedPhrase'];
51
51
  };
52
52
  /**
53
- * Encrypt and add a new secret data to the metadata store.
53
+ * encrypt and add a new secret data to the metadata store.
54
54
  *
55
55
  * @param data - The data to add.
56
- * @param dataType - The data type classification for the secret data.
56
+ * @param type - The type of the secret data.
57
57
  * @param options - Optional options object, which includes optional data to be added to the metadata store.
58
58
  * @param options.keyringId - The keyring id of the backup keyring (SRP).
59
59
  * @returns A promise that resolves to the success of the operation.
@@ -63,12 +63,12 @@ export type SeedlessOnboardingControllerAddNewSecretDataAction = {
63
63
  handler: SeedlessOnboardingController['addNewSecretData'];
64
64
  };
65
65
  /**
66
- * Fetches all secret data items from the metadata store.
66
+ * Fetches all encrypted secret data and metadata for user's account from the metadata store.
67
67
  *
68
68
  * Decrypts the secret data and returns the decrypted secret data using the recovered encryption key from the password.
69
69
  *
70
70
  * @param password - The optional password used to create new wallet. If not provided, `cached Encryption Key` will be used.
71
- * @returns A promise that resolves to the secret metadata items.
71
+ * @returns A promise that resolves to the secret data.
72
72
  */
73
73
  export type SeedlessOnboardingControllerFetchAllSecretDataAction = {
74
74
  type: `SeedlessOnboardingController:fetchAllSecretData`;