@metamask-previews/profile-sync-controller 15.0.0-preview-eb5ae1b → 15.0.0-preview-0c874fe4
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/dist/controllers/authentication/AuthenticationController.cjs +58 -24
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +6 -4
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +6 -4
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +59 -25
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.cjs +25 -4
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.d.cts +12 -2
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.d.mts +12 -2
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.mjs +23 -3
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.cjs +36 -3
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +7 -5
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +7 -5
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.mjs +36 -3
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +76 -27
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +23 -9
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +23 -9
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +77 -28
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +33 -28
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +5 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +5 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +34 -29
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +12 -7
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +6 -2
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +6 -2
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +12 -7
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.cjs +1 -42
- package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.cts +1 -18
- package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.mts +1 -18
- package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.mjs +0 -39
- package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +22 -22
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +4 -4
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +4 -4
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +22 -22
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.cts +8 -8
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +8 -8
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +8 -11
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +4 -4
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +4 -4
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs +8 -11
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +38 -32
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +4 -3
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +4 -3
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +38 -32
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +16 -4
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +2 -2
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +2 -2
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +16 -4
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/shared/storage-schema.cjs +1 -6
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.d.cts +0 -1
- package/dist/shared/storage-schema.d.cts.map +1 -1
- package/dist/shared/storage-schema.d.mts +0 -1
- package/dist/shared/storage-schema.d.mts.map +1 -1
- package/dist/shared/storage-schema.mjs +0 -4
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":";;;AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"auth-snap-requests.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":";;;AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;YACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC;AAZD,gEAYC;AAED;;;;GAIG;AACH,SAAgB,8BAA8B;IAC5C,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;KACF,CAAC;AACJ,CAAC;AATD,wEASC;AAED;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,OAA6B,EAC7B,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SACrE;KACF,CAAC;AACJ,CAAC;AAbD,oEAaC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n };\n}\n\n/**\n * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]\n *\n * @returns Snap getAllPublicKeys Request\n */\nexport function createSnapAllPublicKeysRequest(): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getAllPublicKeys',\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message, ...(entropySourceId ? { entropySourceId } : {}) },\n },\n };\n}\n"]}
|
|
@@ -3,15 +3,25 @@ type SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];
|
|
|
3
3
|
/**
|
|
4
4
|
* Constructs Request to Message Signing Snap to get Public Key
|
|
5
5
|
*
|
|
6
|
+
* @param entropySourceId - The source of entropy to use for key generation,
|
|
7
|
+
* when multiple sources are available (Multi-SRP).
|
|
6
8
|
* @returns Snap Public Key Request
|
|
7
9
|
*/
|
|
8
|
-
export declare function createSnapPublicKeyRequest(): SnapRPCRequest;
|
|
10
|
+
export declare function createSnapPublicKeyRequest(entropySourceId?: string): SnapRPCRequest;
|
|
11
|
+
/**
|
|
12
|
+
* Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
|
|
13
|
+
*
|
|
14
|
+
* @returns Snap getAllPublicKeys Request
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSnapAllPublicKeysRequest(): SnapRPCRequest;
|
|
9
17
|
/**
|
|
10
18
|
* Constructs Request to get Message Signing Snap to sign a message.
|
|
11
19
|
*
|
|
12
20
|
* @param message - message to sign
|
|
21
|
+
* @param entropySourceId - The source of entropy to use for key generation,
|
|
22
|
+
* when multiple sources are available (Multi-SRP).
|
|
13
23
|
* @returns Snap Sign Message Request
|
|
14
24
|
*/
|
|
15
|
-
export declare function createSnapSignMessageRequest(message: `metamask:${string}
|
|
25
|
+
export declare function createSnapSignMessageRequest(message: `metamask:${string}`, entropySourceId?: string): SnapRPCRequest;
|
|
16
26
|
export {};
|
|
17
27
|
//# sourceMappingURL=auth-snap-requests.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.d.cts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;GAIG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"auth-snap-requests.d.cts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,cAAc,CAS/D;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB"}
|
|
@@ -3,15 +3,25 @@ type SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];
|
|
|
3
3
|
/**
|
|
4
4
|
* Constructs Request to Message Signing Snap to get Public Key
|
|
5
5
|
*
|
|
6
|
+
* @param entropySourceId - The source of entropy to use for key generation,
|
|
7
|
+
* when multiple sources are available (Multi-SRP).
|
|
6
8
|
* @returns Snap Public Key Request
|
|
7
9
|
*/
|
|
8
|
-
export declare function createSnapPublicKeyRequest(): SnapRPCRequest;
|
|
10
|
+
export declare function createSnapPublicKeyRequest(entropySourceId?: string): SnapRPCRequest;
|
|
11
|
+
/**
|
|
12
|
+
* Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
|
|
13
|
+
*
|
|
14
|
+
* @returns Snap getAllPublicKeys Request
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSnapAllPublicKeysRequest(): SnapRPCRequest;
|
|
9
17
|
/**
|
|
10
18
|
* Constructs Request to get Message Signing Snap to sign a message.
|
|
11
19
|
*
|
|
12
20
|
* @param message - message to sign
|
|
21
|
+
* @param entropySourceId - The source of entropy to use for key generation,
|
|
22
|
+
* when multiple sources are available (Multi-SRP).
|
|
13
23
|
* @returns Snap Sign Message Request
|
|
14
24
|
*/
|
|
15
|
-
export declare function createSnapSignMessageRequest(message: `metamask:${string}
|
|
25
|
+
export declare function createSnapSignMessageRequest(message: `metamask:${string}`, entropySourceId?: string): SnapRPCRequest;
|
|
16
26
|
export {};
|
|
17
27
|
//# sourceMappingURL=auth-snap-requests.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;GAIG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"auth-snap-requests.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,cAAc,CAS/D;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB"}
|
|
@@ -2,15 +2,33 @@ const snapId = 'npm:@metamask/message-signing-snap';
|
|
|
2
2
|
/**
|
|
3
3
|
* Constructs Request to Message Signing Snap to get Public Key
|
|
4
4
|
*
|
|
5
|
+
* @param entropySourceId - The source of entropy to use for key generation,
|
|
6
|
+
* when multiple sources are available (Multi-SRP).
|
|
5
7
|
* @returns Snap Public Key Request
|
|
6
8
|
*/
|
|
7
|
-
export function createSnapPublicKeyRequest() {
|
|
9
|
+
export function createSnapPublicKeyRequest(entropySourceId) {
|
|
8
10
|
return {
|
|
9
11
|
snapId,
|
|
10
12
|
origin: 'metamask',
|
|
11
13
|
handler: 'onRpcRequest',
|
|
12
14
|
request: {
|
|
13
15
|
method: 'getPublicKey',
|
|
16
|
+
...(entropySourceId ? { params: { entropySourceId } } : {}),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
|
|
22
|
+
*
|
|
23
|
+
* @returns Snap getAllPublicKeys Request
|
|
24
|
+
*/
|
|
25
|
+
export function createSnapAllPublicKeysRequest() {
|
|
26
|
+
return {
|
|
27
|
+
snapId,
|
|
28
|
+
origin: 'metamask',
|
|
29
|
+
handler: 'onRpcRequest',
|
|
30
|
+
request: {
|
|
31
|
+
method: 'getAllPublicKeys',
|
|
14
32
|
},
|
|
15
33
|
};
|
|
16
34
|
}
|
|
@@ -18,16 +36,18 @@ export function createSnapPublicKeyRequest() {
|
|
|
18
36
|
* Constructs Request to get Message Signing Snap to sign a message.
|
|
19
37
|
*
|
|
20
38
|
* @param message - message to sign
|
|
39
|
+
* @param entropySourceId - The source of entropy to use for key generation,
|
|
40
|
+
* when multiple sources are available (Multi-SRP).
|
|
21
41
|
* @returns Snap Sign Message Request
|
|
22
42
|
*/
|
|
23
|
-
export function createSnapSignMessageRequest(message) {
|
|
43
|
+
export function createSnapSignMessageRequest(message, entropySourceId) {
|
|
24
44
|
return {
|
|
25
45
|
snapId,
|
|
26
46
|
origin: 'metamask',
|
|
27
47
|
handler: 'onRpcRequest',
|
|
28
48
|
request: {
|
|
29
49
|
method: 'signMessage',
|
|
30
|
-
params: { message },
|
|
50
|
+
params: { message, ...(entropySourceId ? { entropySourceId } : {}) },
|
|
31
51
|
},
|
|
32
52
|
};
|
|
33
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-snap-requests.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"auth-snap-requests.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;YACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA6B,EAC7B,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SACrE;KACF,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n };\n}\n\n/**\n * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]\n *\n * @returns Snap getAllPublicKeys Request\n */\nexport function createSnapAllPublicKeysRequest(): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getAllPublicKeys',\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message, ...(entropySourceId ? { entropySourceId } : {}) },\n },\n };\n}\n"]}
|
|
@@ -9,7 +9,17 @@ const getMockAuthNonceResponse = () => {
|
|
|
9
9
|
return {
|
|
10
10
|
url: auth_1.MOCK_NONCE_URL,
|
|
11
11
|
requestMethod: 'GET',
|
|
12
|
-
response:
|
|
12
|
+
response: (_, path, getE2ESrpIdentifierForPublicKey) => {
|
|
13
|
+
// The goal here is to have this identifier bubble all the way up to being the access token
|
|
14
|
+
// That way, we can use it to segregate data in the test environment
|
|
15
|
+
const identifier = path?.split('?identifier=')[1];
|
|
16
|
+
const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');
|
|
17
|
+
return {
|
|
18
|
+
...exports.MOCK_NONCE_RESPONSE,
|
|
19
|
+
nonce: e2eIdentifier ?? exports.MOCK_NONCE_RESPONSE.nonce,
|
|
20
|
+
identifier: exports.MOCK_NONCE_RESPONSE.identifier,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
13
23
|
};
|
|
14
24
|
};
|
|
15
25
|
exports.getMockAuthNonceResponse = getMockAuthNonceResponse;
|
|
@@ -18,7 +28,21 @@ const getMockAuthLoginResponse = () => {
|
|
|
18
28
|
return {
|
|
19
29
|
url: auth_1.MOCK_SRP_LOGIN_URL,
|
|
20
30
|
requestMethod: 'POST',
|
|
21
|
-
|
|
31
|
+
// In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier
|
|
32
|
+
// to make it easier to segregate data in the test environment.
|
|
33
|
+
response: (requestJsonBody) => {
|
|
34
|
+
const splittedRawMessage = requestJsonBody?.raw_message.split(':');
|
|
35
|
+
const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];
|
|
36
|
+
return {
|
|
37
|
+
...exports.MOCK_LOGIN_RESPONSE,
|
|
38
|
+
token: e2eIdentifier ?? exports.MOCK_LOGIN_RESPONSE.token,
|
|
39
|
+
profile: {
|
|
40
|
+
...exports.MOCK_LOGIN_RESPONSE.profile,
|
|
41
|
+
profile_id: e2eIdentifier ?? exports.MOCK_LOGIN_RESPONSE.profile.profile_id,
|
|
42
|
+
identifier_id: e2eIdentifier ?? exports.MOCK_LOGIN_RESPONSE.profile.identifier_id,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
22
46
|
};
|
|
23
47
|
};
|
|
24
48
|
exports.getMockAuthLoginResponse = getMockAuthLoginResponse;
|
|
@@ -27,7 +51,16 @@ const getMockAuthAccessTokenResponse = () => {
|
|
|
27
51
|
return {
|
|
28
52
|
url: auth_1.MOCK_OIDC_TOKEN_URL,
|
|
29
53
|
requestMethod: 'POST',
|
|
30
|
-
response:
|
|
54
|
+
response: (requestJsonBody) => {
|
|
55
|
+
// We end up setting the access token to the e2eIdentifier in the test environment
|
|
56
|
+
// This is then attached to every request's Authorization header
|
|
57
|
+
// and used to segregate data in the test environment
|
|
58
|
+
const e2eIdentifier = new URLSearchParams(requestJsonBody).get('assertion');
|
|
59
|
+
return {
|
|
60
|
+
...exports.MOCK_OATH_TOKEN_RESPONSE,
|
|
61
|
+
access_token: e2eIdentifier ?? exports.MOCK_OATH_TOKEN_RESPONSE.access_token,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
31
64
|
};
|
|
32
65
|
};
|
|
33
66
|
exports.getMockAuthAccessTokenResponse = getMockAuthAccessTokenResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,sDAQiC;AAQpB,QAAA,mBAAmB,GAAG,0BAAuB,CAAC;AAC9C,QAAA,UAAU,GAAG,2BAAmB,CAAC,KAAK,CAAC;AACvC,QAAA,QAAQ,GAAG,eAAY,CAAC;AAE9B,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,qBAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,2BAAmB;
|
|
1
|
+
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,sDAQiC;AAQpB,QAAA,mBAAmB,GAAG,0BAAuB,CAAC;AAC9C,QAAA,UAAU,GAAG,2BAAmB,CAAC,KAAK,CAAC;AACvC,QAAA,QAAQ,GAAG,eAAY,CAAC;AAE9B,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,qBAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,CACR,CAAW,EACX,IAAa,EACb,+BAA+D,EAC/D,EAAE;YACF,2FAA2F;YAC3F,oEAAoE;YACpE,MAAM,UAAU,GAAG,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,+BAA+B,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,2BAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,2BAAmB,CAAC,KAAK;gBACjD,UAAU,EAAE,2BAAmB,CAAC,UAAU;aAC3C,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AArBW,QAAA,wBAAwB,4BAqBnC;AAEW,QAAA,mBAAmB,GAAG,8BAA2B,CAAC;AAExD,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,yBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,mHAAmH;QACnH,+DAA+D;QAC/D,QAAQ,EAAE,CAAC,eAAyC,EAAE,EAAE;YACtD,MAAM,kBAAkB,GAAG,eAAe,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnE,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,2BAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,2BAAmB,CAAC,KAAK;gBACjD,OAAO,EAAE;oBACP,GAAG,2BAAmB,CAAC,OAAO;oBAC9B,UAAU,EAAE,aAAa,IAAI,2BAAmB,CAAC,OAAO,CAAC,UAAU;oBACnE,aAAa,EACX,aAAa,IAAI,2BAAmB,CAAC,OAAO,CAAC,aAAa;iBAC7D;aACF,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAtBW,QAAA,wBAAwB,4BAsBnC;AAEW,QAAA,wBAAwB,GAAG,+BAA4B,CAAC;AAE9D,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,0BAAmB;QACxB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,eAAwB,EAAE,EAAE;YACrC,kFAAkF;YAClF,gEAAgE;YAChE,qDAAqD;YACrD,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,CAC5D,WAAW,CACZ,CAAC;YAEF,OAAO;gBACL,GAAG,gCAAwB;gBAC3B,YAAY,EAAE,aAAa,IAAI,gCAAwB,CAAC,YAAY;aACrE,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","sourcesContent":["import {\n MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE,\n MOCK_JWT as SDK_MOCK_JWT,\n MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE,\n MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE,\n MOCK_NONCE_URL,\n MOCK_SRP_LOGIN_URL,\n MOCK_OIDC_TOKEN_URL,\n} from '../../../sdk/mocks/auth';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;\nexport const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;\nexport const MOCK_JWT = SDK_MOCK_JWT;\n\nexport const getMockAuthNonceResponse = () => {\n return {\n url: MOCK_NONCE_URL,\n requestMethod: 'GET',\n response: (\n _?: unknown,\n path?: string,\n getE2ESrpIdentifierForPublicKey?: (publicKey: string) => string,\n ) => {\n // The goal here is to have this identifier bubble all the way up to being the access token\n // That way, we can use it to segregate data in the test environment\n const identifier = path?.split('?identifier=')[1];\n const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');\n\n return {\n ...MOCK_NONCE_RESPONSE,\n nonce: e2eIdentifier ?? MOCK_NONCE_RESPONSE.nonce,\n identifier: MOCK_NONCE_RESPONSE.identifier,\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;\n\nexport const getMockAuthLoginResponse = () => {\n return {\n url: MOCK_SRP_LOGIN_URL,\n requestMethod: 'POST',\n // In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier\n // to make it easier to segregate data in the test environment.\n response: (requestJsonBody?: { raw_message: string }) => {\n const splittedRawMessage = requestJsonBody?.raw_message.split(':');\n const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];\n\n return {\n ...MOCK_LOGIN_RESPONSE,\n token: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.token,\n profile: {\n ...MOCK_LOGIN_RESPONSE.profile,\n profile_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.profile_id,\n identifier_id:\n e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.identifier_id,\n },\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;\n\nexport const getMockAuthAccessTokenResponse = () => {\n return {\n url: MOCK_OIDC_TOKEN_URL,\n requestMethod: 'POST',\n response: (requestJsonBody?: string) => {\n // We end up setting the access token to the e2eIdentifier in the test environment\n // This is then attached to every request's Authorization header\n // and used to segregate data in the test environment\n const e2eIdentifier = new URLSearchParams(requestJsonBody).get(\n 'assertion',\n );\n\n return {\n ...MOCK_OATH_TOKEN_RESPONSE,\n access_token: e2eIdentifier ?? MOCK_OATH_TOKEN_RESPONSE.access_token,\n };\n },\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -8,7 +8,7 @@ export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImI
|
|
|
8
8
|
export declare const getMockAuthNonceResponse: () => {
|
|
9
9
|
url: string;
|
|
10
10
|
requestMethod: "GET";
|
|
11
|
-
response: {
|
|
11
|
+
response: (_?: unknown, path?: string, getE2ESrpIdentifierForPublicKey?: ((publicKey: string) => string) | undefined) => {
|
|
12
12
|
nonce: string;
|
|
13
13
|
identifier: string;
|
|
14
14
|
expires_in: number;
|
|
@@ -28,16 +28,18 @@ export declare const MOCK_LOGIN_RESPONSE: {
|
|
|
28
28
|
export declare const getMockAuthLoginResponse: () => {
|
|
29
29
|
url: string;
|
|
30
30
|
requestMethod: "POST";
|
|
31
|
-
response: {
|
|
31
|
+
response: (requestJsonBody?: {
|
|
32
|
+
raw_message: string;
|
|
33
|
+
}) => {
|
|
32
34
|
token: string;
|
|
33
|
-
expires_in: number;
|
|
34
35
|
profile: {
|
|
35
36
|
profile_id: string;
|
|
36
|
-
metametrics_id: string;
|
|
37
37
|
identifier_id: string;
|
|
38
|
+
metametrics_id: string;
|
|
38
39
|
identifier_type: string;
|
|
39
40
|
encrypted_storage_key: string;
|
|
40
41
|
};
|
|
42
|
+
expires_in: number;
|
|
41
43
|
};
|
|
42
44
|
};
|
|
43
45
|
export declare const MOCK_OATH_TOKEN_RESPONSE: {
|
|
@@ -47,7 +49,7 @@ export declare const MOCK_OATH_TOKEN_RESPONSE: {
|
|
|
47
49
|
export declare const getMockAuthAccessTokenResponse: () => {
|
|
48
50
|
url: string;
|
|
49
51
|
requestMethod: "POST";
|
|
50
|
-
response: {
|
|
52
|
+
response: (requestJsonBody?: string) => {
|
|
51
53
|
access_token: string;
|
|
52
54
|
expires_in: number;
|
|
53
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;mBAK3B,OAAO,SACJ,MAAM,iDACiC,MAAM,KAAK,MAAM;;;;;CAcpE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;iCAMJ;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;CAgBvD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;iCAIV,MAAM;;;;CActC,CAAC"}
|
|
@@ -8,7 +8,7 @@ export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImI
|
|
|
8
8
|
export declare const getMockAuthNonceResponse: () => {
|
|
9
9
|
url: string;
|
|
10
10
|
requestMethod: "GET";
|
|
11
|
-
response: {
|
|
11
|
+
response: (_?: unknown, path?: string, getE2ESrpIdentifierForPublicKey?: ((publicKey: string) => string) | undefined) => {
|
|
12
12
|
nonce: string;
|
|
13
13
|
identifier: string;
|
|
14
14
|
expires_in: number;
|
|
@@ -28,16 +28,18 @@ export declare const MOCK_LOGIN_RESPONSE: {
|
|
|
28
28
|
export declare const getMockAuthLoginResponse: () => {
|
|
29
29
|
url: string;
|
|
30
30
|
requestMethod: "POST";
|
|
31
|
-
response: {
|
|
31
|
+
response: (requestJsonBody?: {
|
|
32
|
+
raw_message: string;
|
|
33
|
+
}) => {
|
|
32
34
|
token: string;
|
|
33
|
-
expires_in: number;
|
|
34
35
|
profile: {
|
|
35
36
|
profile_id: string;
|
|
36
|
-
metametrics_id: string;
|
|
37
37
|
identifier_id: string;
|
|
38
|
+
metametrics_id: string;
|
|
38
39
|
identifier_type: string;
|
|
39
40
|
encrypted_storage_key: string;
|
|
40
41
|
};
|
|
42
|
+
expires_in: number;
|
|
41
43
|
};
|
|
42
44
|
};
|
|
43
45
|
export declare const MOCK_OATH_TOKEN_RESPONSE: {
|
|
@@ -47,7 +49,7 @@ export declare const MOCK_OATH_TOKEN_RESPONSE: {
|
|
|
47
49
|
export declare const getMockAuthAccessTokenResponse: () => {
|
|
48
50
|
url: string;
|
|
49
51
|
requestMethod: "POST";
|
|
50
|
-
response: {
|
|
52
|
+
response: (requestJsonBody?: string) => {
|
|
51
53
|
access_token: string;
|
|
52
54
|
expires_in: number;
|
|
53
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;mBAK3B,OAAO,SACJ,MAAM,iDACiC,MAAM,KAAK,MAAM;;;;;CAcpE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;iCAMJ;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;CAgBvD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;iCAIV,MAAM;;;;CActC,CAAC"}
|
|
@@ -6,7 +6,17 @@ export const getMockAuthNonceResponse = () => {
|
|
|
6
6
|
return {
|
|
7
7
|
url: MOCK_NONCE_URL,
|
|
8
8
|
requestMethod: 'GET',
|
|
9
|
-
response:
|
|
9
|
+
response: (_, path, getE2ESrpIdentifierForPublicKey) => {
|
|
10
|
+
// The goal here is to have this identifier bubble all the way up to being the access token
|
|
11
|
+
// That way, we can use it to segregate data in the test environment
|
|
12
|
+
const identifier = path?.split('?identifier=')[1];
|
|
13
|
+
const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');
|
|
14
|
+
return {
|
|
15
|
+
...MOCK_NONCE_RESPONSE,
|
|
16
|
+
nonce: e2eIdentifier ?? MOCK_NONCE_RESPONSE.nonce,
|
|
17
|
+
identifier: MOCK_NONCE_RESPONSE.identifier,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
10
20
|
};
|
|
11
21
|
};
|
|
12
22
|
export const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;
|
|
@@ -14,7 +24,21 @@ export const getMockAuthLoginResponse = () => {
|
|
|
14
24
|
return {
|
|
15
25
|
url: MOCK_SRP_LOGIN_URL,
|
|
16
26
|
requestMethod: 'POST',
|
|
17
|
-
|
|
27
|
+
// In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier
|
|
28
|
+
// to make it easier to segregate data in the test environment.
|
|
29
|
+
response: (requestJsonBody) => {
|
|
30
|
+
const splittedRawMessage = requestJsonBody?.raw_message.split(':');
|
|
31
|
+
const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];
|
|
32
|
+
return {
|
|
33
|
+
...MOCK_LOGIN_RESPONSE,
|
|
34
|
+
token: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.token,
|
|
35
|
+
profile: {
|
|
36
|
+
...MOCK_LOGIN_RESPONSE.profile,
|
|
37
|
+
profile_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.profile_id,
|
|
38
|
+
identifier_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.identifier_id,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
18
42
|
};
|
|
19
43
|
};
|
|
20
44
|
export const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;
|
|
@@ -22,7 +46,16 @@ export const getMockAuthAccessTokenResponse = () => {
|
|
|
22
46
|
return {
|
|
23
47
|
url: MOCK_OIDC_TOKEN_URL,
|
|
24
48
|
requestMethod: 'POST',
|
|
25
|
-
response:
|
|
49
|
+
response: (requestJsonBody) => {
|
|
50
|
+
// We end up setting the access token to the e2eIdentifier in the test environment
|
|
51
|
+
// This is then attached to every request's Authorization header
|
|
52
|
+
// and used to segregate data in the test environment
|
|
53
|
+
const e2eIdentifier = new URLSearchParams(requestJsonBody).get('assertion');
|
|
54
|
+
return {
|
|
55
|
+
...MOCK_OATH_TOKEN_RESPONSE,
|
|
56
|
+
access_token: e2eIdentifier ?? MOCK_OATH_TOKEN_RESPONSE.access_token,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
26
59
|
};
|
|
27
60
|
};
|
|
28
61
|
//# sourceMappingURL=mockResponses.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,QAAQ,IAAI,YAAY,EACxB,uBAAuB,IAAI,2BAA2B,EACtD,wBAAwB,IAAI,4BAA4B,EACxD,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,oCAAgC;AAQjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,cAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,QAAQ,IAAI,YAAY,EACxB,uBAAuB,IAAI,2BAA2B,EACtD,wBAAwB,IAAI,4BAA4B,EACxD,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,oCAAgC;AAQjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,cAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,CACR,CAAW,EACX,IAAa,EACb,+BAA+D,EAC/D,EAAE;YACF,2FAA2F;YAC3F,oEAAoE;YACpE,MAAM,UAAU,GAAG,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,+BAA+B,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,mBAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,mBAAmB,CAAC,KAAK;gBACjD,UAAU,EAAE,mBAAmB,CAAC,UAAU;aAC3C,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,kBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,mHAAmH;QACnH,+DAA+D;QAC/D,QAAQ,EAAE,CAAC,eAAyC,EAAE,EAAE;YACtD,MAAM,kBAAkB,GAAG,eAAe,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnE,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,mBAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,mBAAmB,CAAC,KAAK;gBACjD,OAAO,EAAE;oBACP,GAAG,mBAAmB,CAAC,OAAO;oBAC9B,UAAU,EAAE,aAAa,IAAI,mBAAmB,CAAC,OAAO,CAAC,UAAU;oBACnE,aAAa,EACX,aAAa,IAAI,mBAAmB,CAAC,OAAO,CAAC,aAAa;iBAC7D;aACF,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAErE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,eAAwB,EAAE,EAAE;YACrC,kFAAkF;YAClF,gEAAgE;YAChE,qDAAqD;YACrD,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,CAC5D,WAAW,CACZ,CAAC;YAEF,OAAO;gBACL,GAAG,wBAAwB;gBAC3B,YAAY,EAAE,aAAa,IAAI,wBAAwB,CAAC,YAAY;aACrE,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import {\n MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE,\n MOCK_JWT as SDK_MOCK_JWT,\n MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE,\n MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE,\n MOCK_NONCE_URL,\n MOCK_SRP_LOGIN_URL,\n MOCK_OIDC_TOKEN_URL,\n} from '../../../sdk/mocks/auth';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;\nexport const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;\nexport const MOCK_JWT = SDK_MOCK_JWT;\n\nexport const getMockAuthNonceResponse = () => {\n return {\n url: MOCK_NONCE_URL,\n requestMethod: 'GET',\n response: (\n _?: unknown,\n path?: string,\n getE2ESrpIdentifierForPublicKey?: (publicKey: string) => string,\n ) => {\n // The goal here is to have this identifier bubble all the way up to being the access token\n // That way, we can use it to segregate data in the test environment\n const identifier = path?.split('?identifier=')[1];\n const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');\n\n return {\n ...MOCK_NONCE_RESPONSE,\n nonce: e2eIdentifier ?? MOCK_NONCE_RESPONSE.nonce,\n identifier: MOCK_NONCE_RESPONSE.identifier,\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;\n\nexport const getMockAuthLoginResponse = () => {\n return {\n url: MOCK_SRP_LOGIN_URL,\n requestMethod: 'POST',\n // In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier\n // to make it easier to segregate data in the test environment.\n response: (requestJsonBody?: { raw_message: string }) => {\n const splittedRawMessage = requestJsonBody?.raw_message.split(':');\n const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];\n\n return {\n ...MOCK_LOGIN_RESPONSE,\n token: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.token,\n profile: {\n ...MOCK_LOGIN_RESPONSE.profile,\n profile_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.profile_id,\n identifier_id:\n e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.identifier_id,\n },\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;\n\nexport const getMockAuthAccessTokenResponse = () => {\n return {\n url: MOCK_OIDC_TOKEN_URL,\n requestMethod: 'POST',\n response: (requestJsonBody?: string) => {\n // We end up setting the access token to the e2eIdentifier in the test environment\n // This is then attached to every request's Authorization header\n // and used to segregate data in the test environment\n const e2eIdentifier = new URLSearchParams(requestJsonBody).get(\n 'assertion',\n );\n\n return {\n ...MOCK_OATH_TOKEN_RESPONSE,\n access_token: e2eIdentifier ?? MOCK_OATH_TOKEN_RESPONSE.access_token,\n };\n },\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -83,8 +83,8 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
83
83
|
});
|
|
84
84
|
_UserStorageController_userStorage.set(this, void 0);
|
|
85
85
|
_UserStorageController_auth.set(this, {
|
|
86
|
-
getProfileId: async () => {
|
|
87
|
-
const sessionProfile = await this.messagingSystem.call('AuthenticationController:getSessionProfile');
|
|
86
|
+
getProfileId: async (entropySourceId) => {
|
|
87
|
+
const sessionProfile = await this.messagingSystem.call('AuthenticationController:getSessionProfile', entropySourceId);
|
|
88
88
|
return sessionProfile?.profileId;
|
|
89
89
|
},
|
|
90
90
|
isSignedIn: () => {
|
|
@@ -116,11 +116,11 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
116
116
|
__classPrivateFieldSet(this, _UserStorageController_userStorage, new sdk_1.UserStorage({
|
|
117
117
|
env: sdk_1.Env.PRD,
|
|
118
118
|
auth: {
|
|
119
|
-
getAccessToken: () => this.messagingSystem.call('AuthenticationController:getBearerToken'),
|
|
120
|
-
getUserProfile: async () => {
|
|
121
|
-
return await this.messagingSystem.call('AuthenticationController:getSessionProfile');
|
|
119
|
+
getAccessToken: (entropySourceId) => this.messagingSystem.call('AuthenticationController:getBearerToken', entropySourceId),
|
|
120
|
+
getUserProfile: async (entropySourceId) => {
|
|
121
|
+
return await this.messagingSystem.call('AuthenticationController:getSessionProfile', entropySourceId);
|
|
122
122
|
},
|
|
123
|
-
signMessage: (message) => __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_snapSignMessage).call(this, message),
|
|
123
|
+
signMessage: (message, entropySourceId) => __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_snapSignMessage).call(this, message, entropySourceId),
|
|
124
124
|
},
|
|
125
125
|
}, {
|
|
126
126
|
storage: {
|
|
@@ -152,12 +152,14 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
152
152
|
* Developers can extend the entry path and entry name through the `schema.ts` file.
|
|
153
153
|
*
|
|
154
154
|
* @param path - string in the form of `${feature}.${key}` that matches schema
|
|
155
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
155
156
|
* @returns the decrypted string contents found from user storage (or null if not found)
|
|
156
157
|
*/
|
|
157
|
-
async performGetStorage(path) {
|
|
158
|
+
async performGetStorage(path, entropySourceId) {
|
|
158
159
|
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getItem(path, {
|
|
159
160
|
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
160
161
|
validateAgainstSchema: true,
|
|
162
|
+
entropySourceId,
|
|
161
163
|
});
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
@@ -165,12 +167,14 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
165
167
|
* Developers can extend the entry path through the `schema.ts` file.
|
|
166
168
|
*
|
|
167
169
|
* @param path - string in the form of `${feature}` that matches schema
|
|
170
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
168
171
|
* @returns the array of decrypted string contents found from user storage (or null if not found)
|
|
169
172
|
*/
|
|
170
|
-
async performGetStorageAllFeatureEntries(path) {
|
|
173
|
+
async performGetStorageAllFeatureEntries(path, entropySourceId) {
|
|
171
174
|
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getAllFeatureItems(path, {
|
|
172
175
|
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
173
176
|
validateAgainstSchema: true,
|
|
177
|
+
entropySourceId,
|
|
174
178
|
});
|
|
175
179
|
}
|
|
176
180
|
/**
|
|
@@ -179,12 +183,14 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
179
183
|
*
|
|
180
184
|
* @param path - string in the form of `${feature}.${key}` that matches schema
|
|
181
185
|
* @param value - The string data you want to store.
|
|
186
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
182
187
|
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
183
188
|
*/
|
|
184
|
-
async performSetStorage(path, value) {
|
|
189
|
+
async performSetStorage(path, value, entropySourceId) {
|
|
185
190
|
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").setItem(path, value, {
|
|
186
191
|
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
187
192
|
validateAgainstSchema: true,
|
|
193
|
+
entropySourceId,
|
|
188
194
|
});
|
|
189
195
|
}
|
|
190
196
|
/**
|
|
@@ -193,24 +199,28 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
193
199
|
*
|
|
194
200
|
* @param path - string in the form of `${feature}` that matches schema
|
|
195
201
|
* @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs
|
|
202
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
196
203
|
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
197
204
|
*/
|
|
198
|
-
async performBatchSetStorage(path, values) {
|
|
205
|
+
async performBatchSetStorage(path, values, entropySourceId) {
|
|
199
206
|
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchSetItems(path, values, {
|
|
200
207
|
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
201
208
|
validateAgainstSchema: true,
|
|
209
|
+
entropySourceId,
|
|
202
210
|
});
|
|
203
211
|
}
|
|
204
212
|
/**
|
|
205
213
|
* Allows deletion of user data. Developers can extend the entry path and entry name through the `schema.ts` file.
|
|
206
214
|
*
|
|
207
215
|
* @param path - string in the form of `${feature}.${key}` that matches schema
|
|
216
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
208
217
|
* @returns nothing. NOTE that an error is thrown if fails to delete data.
|
|
209
218
|
*/
|
|
210
|
-
async performDeleteStorage(path) {
|
|
219
|
+
async performDeleteStorage(path, entropySourceId) {
|
|
211
220
|
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteItem(path, {
|
|
212
221
|
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
213
222
|
validateAgainstSchema: true,
|
|
223
|
+
entropySourceId,
|
|
214
224
|
});
|
|
215
225
|
}
|
|
216
226
|
/**
|
|
@@ -218,10 +228,15 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
218
228
|
* Developers can extend the entry path through the `schema.ts` file.
|
|
219
229
|
*
|
|
220
230
|
* @param path - string in the form of `${feature}` that matches schema
|
|
231
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
221
232
|
* @returns nothing. NOTE that an error is thrown if fails to delete data.
|
|
222
233
|
*/
|
|
223
|
-
async performDeleteStorageAllFeatureEntries(path) {
|
|
224
|
-
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteAllFeatureItems(path
|
|
234
|
+
async performDeleteStorageAllFeatureEntries(path, entropySourceId) {
|
|
235
|
+
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteAllFeatureItems(path, {
|
|
236
|
+
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
237
|
+
validateAgainstSchema: true,
|
|
238
|
+
entropySourceId,
|
|
239
|
+
});
|
|
225
240
|
}
|
|
226
241
|
/**
|
|
227
242
|
* Allows delete of multiple user data entries for one specific feature. Data deleted must be string formatted.
|
|
@@ -229,10 +244,15 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
229
244
|
*
|
|
230
245
|
* @param path - string in the form of `${feature}` that matches schema
|
|
231
246
|
* @param values - data to store, in the form of an array of entryKey[]
|
|
247
|
+
* @param entropySourceId - The entropy source ID used to generate the encryption key.
|
|
232
248
|
* @returns nothing. NOTE that an error is thrown if fails to store data.
|
|
233
249
|
*/
|
|
234
|
-
async performBatchDeleteStorage(path, values) {
|
|
235
|
-
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchDeleteItems(path, values
|
|
250
|
+
async performBatchDeleteStorage(path, values, entropySourceId) {
|
|
251
|
+
return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchDeleteItems(path, values, {
|
|
252
|
+
nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
|
|
253
|
+
validateAgainstSchema: true,
|
|
254
|
+
entropySourceId,
|
|
255
|
+
});
|
|
236
256
|
}
|
|
237
257
|
/**
|
|
238
258
|
* Retrieves the storage key, for internal use only!
|
|
@@ -250,6 +270,19 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
250
270
|
flushStorageKeyCache() {
|
|
251
271
|
__classPrivateFieldSet(this, _UserStorageController_storageKeyCache, {}, "f");
|
|
252
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Lists all the available HD keyring metadata IDs.
|
|
275
|
+
* These IDs can be used in a multi-SRP context to segregate data specific to different SRPs.
|
|
276
|
+
*
|
|
277
|
+
* @returns A promise that resolves to an array of HD keyring metadata IDs.
|
|
278
|
+
*/
|
|
279
|
+
async listEntropySources() {
|
|
280
|
+
if (!__classPrivateFieldGet(this, _UserStorageController_isUnlocked, "f")) {
|
|
281
|
+
throw new Error('listEntropySources - unable to call snap, wallet is locked');
|
|
282
|
+
}
|
|
283
|
+
const result = (await this.messagingSystem.call('SnapController:handleRequest', (0, auth_snap_requests_1.createSnapAllPublicKeysRequest)()));
|
|
284
|
+
return result.map(([id]) => id);
|
|
285
|
+
}
|
|
253
286
|
async setIsBackupAndSyncFeatureEnabled(feature, enabled) {
|
|
254
287
|
try {
|
|
255
288
|
__classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsBackupAndSyncUpdateLoading).call(this, true);
|
|
@@ -302,16 +335,29 @@ class UserStorageController extends base_controller_1.BaseController {
|
|
|
302
335
|
* It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.
|
|
303
336
|
*/
|
|
304
337
|
async syncInternalAccountsWithUserStorage() {
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
338
|
+
const entropySourceIds = await this.listEntropySources();
|
|
339
|
+
try {
|
|
340
|
+
for (const entropySourceId of entropySourceIds) {
|
|
341
|
+
const profileId = await __classPrivateFieldGet(this, _UserStorageController_auth, "f").getProfileId(entropySourceId);
|
|
342
|
+
await (0, controller_integration_1.syncInternalAccountsWithUserStorage)({
|
|
343
|
+
maxNumberOfAccountsToAdd: __classPrivateFieldGet(this, _UserStorageController_config, "f")?.accountSyncing?.maxNumberOfAccountsToAdd,
|
|
344
|
+
onAccountAdded: () => __classPrivateFieldGet(this, _UserStorageController_config, "f")?.accountSyncing?.onAccountAdded?.(profileId),
|
|
345
|
+
onAccountNameUpdated: () => __classPrivateFieldGet(this, _UserStorageController_config, "f")?.accountSyncing?.onAccountNameUpdated?.(profileId),
|
|
346
|
+
onAccountSyncErroneousSituation: (situationMessage, sentryContext) => __classPrivateFieldGet(this, _UserStorageController_config, "f")?.accountSyncing?.onAccountSyncErroneousSituation?.(profileId, situationMessage, sentryContext),
|
|
347
|
+
}, {
|
|
348
|
+
getMessenger: () => this.messagingSystem,
|
|
349
|
+
getUserStorageControllerInstance: () => this,
|
|
350
|
+
}, entropySourceId);
|
|
351
|
+
}
|
|
352
|
+
// We do this here and not in the finally statement because we want to make sure that
|
|
353
|
+
// the accounts are saved / updated / deleted at least once before we set this flag
|
|
354
|
+
await this.setHasAccountSyncingSyncedAtLeastOnce(true);
|
|
355
|
+
}
|
|
356
|
+
catch (e) {
|
|
357
|
+
// Silently fail for now
|
|
358
|
+
// istanbul ignore next
|
|
359
|
+
console.error(e);
|
|
360
|
+
}
|
|
315
361
|
}
|
|
316
362
|
/**
|
|
317
363
|
* Saves an individual internal account to the user storage.
|
|
@@ -355,16 +401,19 @@ _UserStorageController_env = new WeakMap(), _UserStorageController_userStorage =
|
|
|
355
401
|
* Signs a specific message using an underlying auth snap.
|
|
356
402
|
*
|
|
357
403
|
* @param message - A specific tagged message to sign.
|
|
404
|
+
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
405
|
+
* when multiple sources are available (Multi-SRP).
|
|
358
406
|
* @returns A Signature created by the snap.
|
|
359
407
|
*/
|
|
360
|
-
async function _UserStorageController_snapSignMessage(message) {
|
|
408
|
+
async function _UserStorageController_snapSignMessage(message, entropySourceId) {
|
|
409
|
+
// the message is SRP specific already, so there's no need to use the entropySourceId in the cache
|
|
361
410
|
if (__classPrivateFieldGet(this, _UserStorageController__snapSignMessageCache, "f")[message]) {
|
|
362
411
|
return __classPrivateFieldGet(this, _UserStorageController__snapSignMessageCache, "f")[message];
|
|
363
412
|
}
|
|
364
413
|
if (!__classPrivateFieldGet(this, _UserStorageController_isUnlocked, "f")) {
|
|
365
414
|
throw new Error('#snapSignMessage - unable to call snap, wallet is locked');
|
|
366
415
|
}
|
|
367
|
-
const result = (await this.messagingSystem.call('SnapController:handleRequest', (0, auth_snap_requests_1.createSnapSignMessageRequest)(message)));
|
|
416
|
+
const result = (await this.messagingSystem.call('SnapController:handleRequest', (0, auth_snap_requests_1.createSnapSignMessageRequest)(message, entropySourceId)));
|
|
368
417
|
__classPrivateFieldGet(this, _UserStorageController__snapSignMessageCache, "f")[message] = result;
|
|
369
418
|
return result;
|
|
370
419
|
}, _UserStorageController_setIsBackupAndSyncUpdateLoading = function _UserStorageController_setIsBackupAndSyncUpdateLoading(isBackupAndSyncUpdateLoading) {
|