@metamask/profile-sync-controller 28.3.0 → 30.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/LICENSE +1 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.cjs +236 -75
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +22 -3
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +22 -3
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +231 -70
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/index.cjs +3 -3
- package/dist/controllers/authentication/index.cjs.map +1 -1
- package/dist/controllers/authentication/index.d.cts.map +1 -1
- package/dist/controllers/authentication/index.d.mts.map +1 -1
- package/dist/controllers/authentication/index.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/index.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/index.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/index.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/index.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.cjs +26 -15
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +11 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +11 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.mjs +13 -3
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/index.cjs.map +1 -1
- package/dist/controllers/index.d.cts.map +1 -1
- package/dist/controllers/index.d.mts.map +1 -1
- package/dist/controllers/index.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +35 -36
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +2 -3
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +2 -3
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +22 -23
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +23 -23
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +9 -9
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.cjs +2 -2
- package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/index.cjs +3 -3
- package/dist/controllers/user-storage/index.cjs.map +1 -1
- package/dist/controllers/user-storage/index.d.cts.map +1 -1
- package/dist/controllers/user-storage/index.d.mts.map +1 -1
- package/dist/controllers/user-storage/index.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/index.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/index.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.cjs +15 -15
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.cjs +3 -3
- package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -1
- package/dist/controllers/user-storage/types.cjs.map +1 -1
- package/dist/controllers/user-storage/types.d.cts.map +1 -1
- package/dist/controllers/user-storage/types.d.mts.map +1 -1
- package/dist/controllers/user-storage/types.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +11 -11
- 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 +40 -26
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +12 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +12 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +20 -6
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +85 -39
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +19 -2
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +19 -2
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +46 -2
- 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 +36 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +36 -0
- 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-jwt-bearer/utils/identifier.cjs +2 -2
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +25 -21
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +2 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +2 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs +4 -0
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/constants.cjs +1 -0
- package/dist/sdk/constants.cjs.map +1 -1
- package/dist/sdk/constants.d.cts +1 -0
- package/dist/sdk/constants.d.cts.map +1 -1
- package/dist/sdk/constants.d.mts +1 -0
- package/dist/sdk/constants.d.mts.map +1 -1
- package/dist/sdk/constants.mjs +1 -0
- package/dist/sdk/constants.mjs.map +1 -1
- package/dist/sdk/errors.cjs +17 -4
- package/dist/sdk/errors.cjs.map +1 -1
- package/dist/sdk/errors.d.cts +9 -0
- package/dist/sdk/errors.d.cts.map +1 -1
- package/dist/sdk/errors.d.mts +9 -0
- package/dist/sdk/errors.d.mts.map +1 -1
- package/dist/sdk/errors.mjs +12 -0
- package/dist/sdk/errors.mjs.map +1 -1
- package/dist/sdk/index.cjs.map +1 -1
- package/dist/sdk/index.d.cts.map +1 -1
- package/dist/sdk/index.d.mts.map +1 -1
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/sdk/mocks/auth.cjs +24 -13
- package/dist/sdk/mocks/auth.cjs.map +1 -1
- package/dist/sdk/mocks/auth.d.cts +11 -0
- package/dist/sdk/mocks/auth.d.cts.map +1 -1
- package/dist/sdk/mocks/auth.d.mts +11 -0
- package/dist/sdk/mocks/auth.d.mts.map +1 -1
- package/dist/sdk/mocks/auth.mjs +12 -1
- package/dist/sdk/mocks/auth.mjs.map +1 -1
- package/dist/sdk/mocks/userstorage.cjs +8 -8
- package/dist/sdk/mocks/userstorage.cjs.map +1 -1
- package/dist/sdk/mocks/userstorage.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +32 -32
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +1 -1
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/validate-login-response.cjs.map +1 -1
- package/dist/sdk/utils/validate-login-response.d.cts.map +1 -1
- package/dist/sdk/utils/validate-login-response.d.mts.map +1 -1
- package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
- package/dist/shared/encryption/cache.cjs +6 -6
- package/dist/shared/encryption/cache.cjs.map +1 -1
- package/dist/shared/encryption/cache.mjs.map +1 -1
- package/dist/shared/encryption/encryption.cjs +26 -26
- package/dist/shared/encryption/encryption.cjs.map +1 -1
- package/dist/shared/encryption/encryption.d.cts.map +1 -1
- package/dist/shared/encryption/encryption.d.mts.map +1 -1
- package/dist/shared/encryption/encryption.mjs.map +1 -1
- package/dist/shared/encryption/index.cjs +3 -3
- package/dist/shared/encryption/index.cjs.map +1 -1
- package/dist/shared/encryption/index.d.cts.map +1 -1
- package/dist/shared/encryption/index.d.mts.map +1 -1
- package/dist/shared/encryption/index.mjs.map +1 -1
- package/dist/shared/storage-schema.cjs +2 -2
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/dist/shared/types/services.cjs.map +1 -1
- package/dist/shared/types/services.d.cts.map +1 -1
- package/dist/shared/types/services.d.mts.map +1 -1
- package/dist/shared/types/services.mjs.map +1 -1
- package/dist/shared/utils/entropy-source.cjs +37 -0
- package/dist/shared/utils/entropy-source.cjs.map +1 -0
- package/dist/shared/utils/entropy-source.d.cts +22 -0
- package/dist/shared/utils/entropy-source.d.cts.map +1 -0
- package/dist/shared/utils/entropy-source.d.mts +22 -0
- package/dist/shared/utils/entropy-source.d.mts.map +1 -0
- package/dist/shared/utils/entropy-source.mjs +32 -0
- package/dist/shared/utils/entropy-source.mjs.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
- package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.cts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.mjs +45 -0
- package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
- package/dist/shared/utils/message-signing.cjs +147 -0
- package/dist/shared/utils/message-signing.cjs.map +1 -0
- package/dist/shared/utils/message-signing.d.cts +73 -0
- package/dist/shared/utils/message-signing.d.cts.map +1 -0
- package/dist/shared/utils/message-signing.d.mts +73 -0
- package/dist/shared/utils/message-signing.d.mts.map +1 -0
- package/dist/shared/utils/message-signing.mjs +140 -0
- package/dist/shared/utils/message-signing.mjs.map +1 -0
- package/package.json +17 -14
- package/dist/controllers/authentication/auth-snap-requests.cjs +0 -60
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.d.cts +0 -27
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.d.mts +0 -27
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.mjs +0 -54
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +0 -1
|
@@ -9,14 +9,17 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_auth, _AuthenticationController_config, _AuthenticationController_isUnlocked,
|
|
12
|
+
var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_auth, _AuthenticationController_config, _AuthenticationController_isUnlocked, _AuthenticationController_profilePairingRequestEpoch, _AuthenticationController_keyringController, _AuthenticationController_getLoginResponseFromState, _AuthenticationController_setLoginResponseToState, _AuthenticationController_assertIsUnlocked, _AuthenticationController_getHdKeyringEntropySourceIds, _AuthenticationController_getPrimaryEntropySourceId, _AuthenticationController_getLoginTag, _AuthenticationController_getLoginIdentifierType, _AuthenticationController_resolveSocialIdentifierType, _AuthenticationController_identifierTypeFromSeedlessState, _AuthenticationController_trySocialPairing, _AuthenticationController_clearNeedsSocialPairing, _AuthenticationController_tryClearNeedsProfilePairing, _AuthenticationController_doPair, _AuthenticationController_pairSrpProfiles, _AuthenticationController_propagateCanonical, _AuthenticationController_getCanonicalProfileId, _AuthenticationController_invalidateSrpSession, _AuthenticationController_getHdKeyringSeed, _AuthenticationController_getPublicKey, _AuthenticationController__signMessageCache, _AuthenticationController_scopedCacheKey, _AuthenticationController_signMessage;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
|
-
import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth } from "../../sdk/index.mjs";
|
|
15
|
-
import {
|
|
14
|
+
import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth, PairConflictError } from "../../sdk/index.mjs";
|
|
15
|
+
import { getHdKeyringEntropySourceIds, getPrimaryHdKeyringEntropySourceId } from "../../shared/utils/entropy-source.mjs";
|
|
16
|
+
import { getHdKeyringSeed } from "../../shared/utils/hd-keyring-seed.mjs";
|
|
17
|
+
import { getMessageSigningPublicKey, signMessageWithMessageSigningKey } from "../../shared/utils/message-signing.mjs";
|
|
16
18
|
const controllerName = 'AuthenticationController';
|
|
17
19
|
export const defaultState = {
|
|
18
20
|
isSignedIn: false,
|
|
19
21
|
needsProfilePairing: true,
|
|
22
|
+
needsSocialPairing: true,
|
|
20
23
|
};
|
|
21
24
|
const metadata = {
|
|
22
25
|
isSignedIn: {
|
|
@@ -31,6 +34,12 @@ const metadata = {
|
|
|
31
34
|
includeInDebugSnapshot: true,
|
|
32
35
|
usedInUi: true,
|
|
33
36
|
},
|
|
37
|
+
needsSocialPairing: {
|
|
38
|
+
includeInStateLogs: true,
|
|
39
|
+
persist: true,
|
|
40
|
+
includeInDebugSnapshot: true,
|
|
41
|
+
usedInUi: true,
|
|
42
|
+
},
|
|
34
43
|
srpSessionData: {
|
|
35
44
|
// Remove access token from state logs
|
|
36
45
|
includeInStateLogs: (srpSessionData) => {
|
|
@@ -84,9 +93,9 @@ export class AuthenticationController extends BaseController {
|
|
|
84
93
|
_AuthenticationController_auth.set(this, void 0);
|
|
85
94
|
_AuthenticationController_config.set(this, {
|
|
86
95
|
env: Env.PRD,
|
|
96
|
+
isSocialPairingEnabled: () => false,
|
|
87
97
|
});
|
|
88
98
|
_AuthenticationController_isUnlocked.set(this, false);
|
|
89
|
-
_AuthenticationController_cachedPrimaryEntropySourceId.set(this, void 0);
|
|
90
99
|
// Bumped by `requestProfilePairing`. `performSignIn` snapshots this
|
|
91
100
|
// before its first await; if it changes mid-flight we must NOT clear
|
|
92
101
|
// `needsProfilePairing` (the rearm signal wins).
|
|
@@ -103,13 +112,14 @@ export class AuthenticationController extends BaseController {
|
|
|
103
112
|
});
|
|
104
113
|
},
|
|
105
114
|
});
|
|
106
|
-
|
|
115
|
+
_AuthenticationController__signMessageCache.set(this, {});
|
|
107
116
|
if (!metametrics) {
|
|
108
117
|
throw new Error('`metametrics` field is required');
|
|
109
118
|
}
|
|
110
119
|
__classPrivateFieldSet(this, _AuthenticationController_config, {
|
|
111
120
|
...__classPrivateFieldGet(this, _AuthenticationController_config, "f"),
|
|
112
121
|
...config,
|
|
122
|
+
isSocialPairingEnabled: config?.isSocialPairingEnabled ?? __classPrivateFieldGet(this, _AuthenticationController_config, "f").isSocialPairingEnabled,
|
|
113
123
|
}, "f");
|
|
114
124
|
__classPrivateFieldSet(this, _AuthenticationController_metametrics, metametrics, "f");
|
|
115
125
|
__classPrivateFieldSet(this, _AuthenticationController_auth, new JwtBearerAuth({
|
|
@@ -122,9 +132,11 @@ export class AuthenticationController extends BaseController {
|
|
|
122
132
|
setLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_setLoginResponseToState).bind(this),
|
|
123
133
|
},
|
|
124
134
|
signing: {
|
|
125
|
-
getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m",
|
|
126
|
-
signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m",
|
|
135
|
+
getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPublicKey).bind(this),
|
|
136
|
+
signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_signMessage).bind(this),
|
|
127
137
|
},
|
|
138
|
+
getLoginTag: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginTag).bind(this),
|
|
139
|
+
getLoginIdentifierType: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginIdentifierType).bind(this),
|
|
128
140
|
metametrics: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f"),
|
|
129
141
|
}), "f");
|
|
130
142
|
__classPrivateFieldGet(this, _AuthenticationController_keyringController, "f").setupLockedStateSubscriptions();
|
|
@@ -133,15 +145,15 @@ export class AuthenticationController extends BaseController {
|
|
|
133
145
|
async performSignIn() {
|
|
134
146
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'performSignIn');
|
|
135
147
|
const epochAtStart = __classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f");
|
|
136
|
-
const
|
|
148
|
+
const entropySourceIds = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringEntropySourceIds).call(this);
|
|
137
149
|
const accessTokens = [];
|
|
138
150
|
// We iterate sequentially in order to be sure that the first entry
|
|
139
151
|
// is the primary SRP LoginResponse.
|
|
140
|
-
for (const
|
|
152
|
+
for (const entropySourceId of entropySourceIds) {
|
|
141
153
|
const accessToken = await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(entropySourceId);
|
|
142
154
|
accessTokens.push(accessToken);
|
|
143
155
|
}
|
|
144
|
-
if (
|
|
156
|
+
if (entropySourceIds.length < 2) {
|
|
145
157
|
// Single-SRP wallet: nothing to pair.
|
|
146
158
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_tryClearNeedsProfilePairing).call(this, epochAtStart);
|
|
147
159
|
}
|
|
@@ -154,6 +166,12 @@ export class AuthenticationController extends BaseController {
|
|
|
154
166
|
// noop
|
|
155
167
|
}
|
|
156
168
|
}
|
|
169
|
+
try {
|
|
170
|
+
await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_trySocialPairing).call(this, accessTokens[0]);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// noop
|
|
174
|
+
}
|
|
157
175
|
return accessTokens;
|
|
158
176
|
}
|
|
159
177
|
/**
|
|
@@ -170,7 +188,6 @@ export class AuthenticationController extends BaseController {
|
|
|
170
188
|
}
|
|
171
189
|
}
|
|
172
190
|
performSignOut() {
|
|
173
|
-
__classPrivateFieldSet(this, _AuthenticationController_cachedPrimaryEntropySourceId, undefined, "f");
|
|
174
191
|
this.update((state) => {
|
|
175
192
|
state.isSignedIn = false;
|
|
176
193
|
state.srpSessionData = undefined;
|
|
@@ -189,7 +206,7 @@ export class AuthenticationController extends BaseController {
|
|
|
189
206
|
*/
|
|
190
207
|
async getBearerToken(entropySourceId) {
|
|
191
208
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getBearerToken');
|
|
192
|
-
const resolvedId = entropySourceId ??
|
|
209
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
193
210
|
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(resolvedId);
|
|
194
211
|
}
|
|
195
212
|
/**
|
|
@@ -207,7 +224,7 @@ export class AuthenticationController extends BaseController {
|
|
|
207
224
|
*/
|
|
208
225
|
async getSessionProfile(entropySourceId) {
|
|
209
226
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getSessionProfile');
|
|
210
|
-
const resolvedId = entropySourceId ??
|
|
227
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
211
228
|
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfile(resolvedId);
|
|
212
229
|
}
|
|
213
230
|
/**
|
|
@@ -228,10 +245,10 @@ export class AuthenticationController extends BaseController {
|
|
|
228
245
|
*/
|
|
229
246
|
async refreshCanonicalProfileId() {
|
|
230
247
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'refreshCanonicalProfileId');
|
|
231
|
-
const primaryEntropySourceId =
|
|
248
|
+
const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
232
249
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_invalidateSrpSession).call(this, primaryEntropySourceId);
|
|
233
250
|
await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(primaryEntropySourceId);
|
|
234
|
-
const canonical =
|
|
251
|
+
const canonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
|
|
235
252
|
if (!canonical) {
|
|
236
253
|
throw new Error('refreshCanonicalProfileId - Unable to resolve canonical profile ID');
|
|
237
254
|
}
|
|
@@ -240,7 +257,7 @@ export class AuthenticationController extends BaseController {
|
|
|
240
257
|
}
|
|
241
258
|
async getUserProfileLineage(entropySourceId) {
|
|
242
259
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getUserProfileLineage');
|
|
243
|
-
const resolvedId = entropySourceId ??
|
|
260
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
244
261
|
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfileLineage(resolvedId);
|
|
245
262
|
}
|
|
246
263
|
/**
|
|
@@ -256,21 +273,21 @@ export class AuthenticationController extends BaseController {
|
|
|
256
273
|
*/
|
|
257
274
|
async getCustomerServiceToken(entropySourceId) {
|
|
258
275
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getCustomerServiceToken');
|
|
259
|
-
const resolvedId = entropySourceId ??
|
|
276
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
260
277
|
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getCustomerServiceToken(resolvedId);
|
|
261
278
|
}
|
|
262
279
|
isSignedIn() {
|
|
263
280
|
return this.state.isSignedIn;
|
|
264
281
|
}
|
|
265
282
|
}
|
|
266
|
-
_AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_auth = new WeakMap(), _AuthenticationController_config = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(),
|
|
267
|
-
const resolvedId = entropySourceId ??
|
|
283
|
+
_AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_auth = new WeakMap(), _AuthenticationController_config = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(), _AuthenticationController_profilePairingRequestEpoch = new WeakMap(), _AuthenticationController_keyringController = new WeakMap(), _AuthenticationController__signMessageCache = new WeakMap(), _AuthenticationController_instances = new WeakSet(), _AuthenticationController_getLoginResponseFromState = async function _AuthenticationController_getLoginResponseFromState(entropySourceId) {
|
|
284
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
268
285
|
if (!this.state.srpSessionData?.[resolvedId]) {
|
|
269
286
|
return null;
|
|
270
287
|
}
|
|
271
288
|
return this.state.srpSessionData[resolvedId];
|
|
272
289
|
}, _AuthenticationController_setLoginResponseToState = async function _AuthenticationController_setLoginResponseToState(loginResponse, entropySourceId) {
|
|
273
|
-
const resolvedId = entropySourceId ??
|
|
290
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
274
291
|
const metaMetricsId = await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId();
|
|
275
292
|
this.update((state) => {
|
|
276
293
|
state.isSignedIn = true;
|
|
@@ -289,20 +306,168 @@ _AuthenticationController_metametrics = new WeakMap(), _AuthenticationController
|
|
|
289
306
|
if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
|
|
290
307
|
throw new Error(`${methodName} - unable to proceed, wallet is locked`);
|
|
291
308
|
}
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
|
|
309
|
+
}, _AuthenticationController_getHdKeyringEntropySourceIds = function _AuthenticationController_getHdKeyringEntropySourceIds() {
|
|
310
|
+
const { keyrings } = this.messenger.call('KeyringController:getState');
|
|
311
|
+
return getHdKeyringEntropySourceIds(keyrings);
|
|
312
|
+
}, _AuthenticationController_getPrimaryEntropySourceId = function _AuthenticationController_getPrimaryEntropySourceId() {
|
|
313
|
+
const { keyrings } = this.messenger.call('KeyringController:getState');
|
|
314
|
+
return getPrimaryHdKeyringEntropySourceId(keyrings);
|
|
315
|
+
}, _AuthenticationController_getLoginTag =
|
|
316
|
+
/**
|
|
317
|
+
* Resolves the SRP login tag for `raw_message`.
|
|
318
|
+
*
|
|
319
|
+
* - `primary` for the first HD entropy source
|
|
320
|
+
* - `secondary` for any other entropy source
|
|
321
|
+
*
|
|
322
|
+
* @param entropySourceId - Entropy source for this login attempt.
|
|
323
|
+
* @returns The login tag to append to the signed message.
|
|
324
|
+
*/
|
|
325
|
+
async function _AuthenticationController_getLoginTag(entropySourceId) {
|
|
326
|
+
const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
327
|
+
const resolvedId = entropySourceId ?? primaryEntropySourceId;
|
|
328
|
+
return resolvedId === primaryEntropySourceId ? 'primary' : 'secondary';
|
|
329
|
+
}, _AuthenticationController_getLoginIdentifierType =
|
|
330
|
+
/**
|
|
331
|
+
* Resolves metametrics `identifier_type` for `/srp/login`
|
|
332
|
+
* (`SRP` | `GOOGLE` | `APPLE` | `TELEGRAM`).
|
|
333
|
+
*
|
|
334
|
+
* This is the auth method for the entropy source, independent of
|
|
335
|
+
* {@link SrpLoginTag} (`primary` / `secondary`).
|
|
336
|
+
*
|
|
337
|
+
* SeedlessOnboarding currently exposes a single vault-level
|
|
338
|
+
* `authConnection`, which always backs the primary entropy source. Non-
|
|
339
|
+
* primary sources therefore return `SRP`. If social identities become
|
|
340
|
+
* per-entropy later, resolve from that metadata instead of assuming
|
|
341
|
+
* primary === social.
|
|
342
|
+
*
|
|
343
|
+
* Soft-fails to `SRP` when SeedlessOnboarding is not registered.
|
|
344
|
+
*
|
|
345
|
+
* @param entropySourceId - Entropy source for this login attempt.
|
|
346
|
+
* @returns The login identifier type.
|
|
347
|
+
*/
|
|
348
|
+
async function _AuthenticationController_getLoginIdentifierType(entropySourceId) {
|
|
349
|
+
const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
350
|
+
const resolvedId = entropySourceId ?? primaryEntropySourceId;
|
|
351
|
+
// Social vault authConnection is only associated with the primary source.
|
|
352
|
+
if (resolvedId !== primaryEntropySourceId) {
|
|
353
|
+
return 'SRP';
|
|
354
|
+
}
|
|
355
|
+
return __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_resolveSocialIdentifierType).call(this);
|
|
356
|
+
}, _AuthenticationController_resolveSocialIdentifierType = function _AuthenticationController_resolveSocialIdentifierType() {
|
|
357
|
+
try {
|
|
358
|
+
return __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_identifierTypeFromSeedlessState).call(this, this.messenger.call('SeedlessOnboardingController:getState'));
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return 'SRP';
|
|
362
|
+
}
|
|
363
|
+
}, _AuthenticationController_identifierTypeFromSeedlessState = function _AuthenticationController_identifierTypeFromSeedlessState(state) {
|
|
364
|
+
if (state.vault === null || state.vault === undefined) {
|
|
365
|
+
return 'SRP';
|
|
366
|
+
}
|
|
367
|
+
// Match provider strings from SeedlessOnboarding state rather than
|
|
368
|
+
// importing AuthConnection — a value import would load that package
|
|
369
|
+
// (and its heavy deps) whenever this controller is imported.
|
|
370
|
+
switch (state.authConnection) {
|
|
371
|
+
case 'google':
|
|
372
|
+
return 'GOOGLE';
|
|
373
|
+
case 'apple':
|
|
374
|
+
return 'APPLE';
|
|
375
|
+
case 'telegram':
|
|
376
|
+
return 'TELEGRAM';
|
|
377
|
+
default:
|
|
378
|
+
return 'SRP';
|
|
379
|
+
}
|
|
380
|
+
}, _AuthenticationController_trySocialPairing =
|
|
381
|
+
/**
|
|
382
|
+
* Attaches a Google/Apple/Telegram social identifier to the primary SRP
|
|
383
|
+
* profile via `POST /api/v2/profile/pair/identifier`.
|
|
384
|
+
*
|
|
385
|
+
* Runs only when `isSocialPairingEnabled()` is true and
|
|
386
|
+
* `needsSocialPairing` is not `false` (`undefined` is treated as true).
|
|
387
|
+
* No social provider (`authConnection` unset) → clear the flag (nothing
|
|
388
|
+
* to pair). Social provider set but vault missing → skip (onboarding
|
|
389
|
+
* still in flight). Google without email → skip (API requires it).
|
|
390
|
+
* Telegram never sends `email` (the field holds a display name, not an
|
|
391
|
+
* address). Missing social JWT → skip. 409 Conflict → clear the flag
|
|
392
|
+
* (identifier already owned; retry is pointless). Other errors
|
|
393
|
+
* propagate so the caller can swallow them and leave the flag set for
|
|
394
|
+
* retry.
|
|
395
|
+
*
|
|
396
|
+
* @param primaryAccessToken - Primary SRP OIDC access token used as the
|
|
397
|
+
* Bearer credential. The profile associated with this JWT becomes the
|
|
398
|
+
* canonical owner of the social identifier.
|
|
399
|
+
*/
|
|
400
|
+
async function _AuthenticationController_trySocialPairing(primaryAccessToken) {
|
|
401
|
+
if (!__classPrivateFieldGet(this, _AuthenticationController_config, "f").isSocialPairingEnabled() ||
|
|
402
|
+
this.state.needsSocialPairing === false ||
|
|
403
|
+
!primaryAccessToken) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
let seedlessState;
|
|
407
|
+
try {
|
|
408
|
+
seedlessState = this.messenger.call('SeedlessOnboardingController:getState');
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
// Controller missing or getState failed — retry next performSignIn.
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
// `SRP` here does not describe the vault: it is the mapping's "no social
|
|
415
|
+
// identity" result, returned when there is no seedless vault or the
|
|
416
|
+
// provider is unrecognised. In both cases there is nothing to pair.
|
|
417
|
+
const identifierType = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_identifierTypeFromSeedlessState).call(this, seedlessState);
|
|
418
|
+
if (identifierType === 'SRP') {
|
|
419
|
+
const { vault, authConnection } = seedlessState;
|
|
420
|
+
// Vault not written yet but a social provider is already known —
|
|
421
|
+
// onboarding is still in flight. Do not clear; retry next sign-in.
|
|
422
|
+
if ((vault === null || vault === undefined) && Boolean(authConnection)) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
// Email policy follows the API contract: GOOGLE requires `email` (400
|
|
429
|
+
// without it), APPLE accepts it optionally, TELEGRAM must not send it
|
|
430
|
+
// (clients store a display name in `socialLoginEmail` for Telegram).
|
|
431
|
+
// Clients request the `email` scope for Google, so a missing value is a
|
|
432
|
+
// defensive case rather than an expected one; returning here leaves
|
|
433
|
+
// `needsSocialPairing` set so the next sign-in retries instead of
|
|
434
|
+
// sending a request that would fail.
|
|
435
|
+
const { socialLoginEmail } = seedlessState;
|
|
436
|
+
let email;
|
|
437
|
+
if (identifierType === 'GOOGLE') {
|
|
438
|
+
if (!socialLoginEmail) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
email = socialLoginEmail;
|
|
442
|
+
}
|
|
443
|
+
else if (identifierType === 'APPLE') {
|
|
444
|
+
email = socialLoginEmail;
|
|
445
|
+
}
|
|
446
|
+
const socialJwt = await this.messenger.call('SeedlessOnboardingController:getAccessToken');
|
|
447
|
+
if (socialJwt === undefined || socialJwt === '') {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").pairSocialIdentifier({
|
|
452
|
+
identifierType,
|
|
453
|
+
socialJwt,
|
|
454
|
+
...(email ? { email } : {}),
|
|
455
|
+
}, primaryAccessToken);
|
|
456
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
|
|
295
457
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
458
|
+
catch (error) {
|
|
459
|
+
if (error instanceof PairConflictError) {
|
|
460
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
throw error;
|
|
299
464
|
}
|
|
300
|
-
|
|
301
|
-
if (
|
|
302
|
-
|
|
465
|
+
}, _AuthenticationController_clearNeedsSocialPairing = function _AuthenticationController_clearNeedsSocialPairing() {
|
|
466
|
+
if (this.state.needsSocialPairing !== false) {
|
|
467
|
+
this.update((state) => {
|
|
468
|
+
state.needsSocialPairing = false;
|
|
469
|
+
});
|
|
303
470
|
}
|
|
304
|
-
__classPrivateFieldSet(this, _AuthenticationController_cachedPrimaryEntropySourceId, primaryId, "f");
|
|
305
|
-
return __classPrivateFieldGet(this, _AuthenticationController_cachedPrimaryEntropySourceId, "f");
|
|
306
471
|
}, _AuthenticationController_tryClearNeedsProfilePairing = function _AuthenticationController_tryClearNeedsProfilePairing(epochAtStart) {
|
|
307
472
|
if (__classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f") !== epochAtStart) {
|
|
308
473
|
return;
|
|
@@ -325,9 +490,9 @@ _AuthenticationController_metametrics = new WeakMap(), _AuthenticationController
|
|
|
325
490
|
* pair API call was in-flight.
|
|
326
491
|
*/
|
|
327
492
|
async function _AuthenticationController_doPair(accessTokens, epochAtStart) {
|
|
328
|
-
const previousCanonical =
|
|
493
|
+
const previousCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
|
|
329
494
|
const profileAliases = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_pairSrpProfiles).call(this, accessTokens);
|
|
330
|
-
const newCanonical =
|
|
495
|
+
const newCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
|
|
331
496
|
// If somehow we cannot compute the new canonical profile ID after pairing,
|
|
332
497
|
// we just return now and do not update the `needsProfilePairing` flag.
|
|
333
498
|
if (!newCanonical) {
|
|
@@ -363,18 +528,8 @@ async function _AuthenticationController_doPair(accessTokens, epochAtStart) {
|
|
|
363
528
|
}
|
|
364
529
|
}
|
|
365
530
|
});
|
|
366
|
-
}, _AuthenticationController_getCanonicalProfileId =
|
|
367
|
-
|
|
368
|
-
* Returns the canonical profile id from the primary SRP's cached session.
|
|
369
|
-
* Returns `null` when no session exists yet for the primary SRP.
|
|
370
|
-
*
|
|
371
|
-
* Always reads from the primary SRP because the canonical is shared across
|
|
372
|
-
* all paired SRPs after `#propagateCanonical`.
|
|
373
|
-
*
|
|
374
|
-
* @returns The canonical profile id, or `null` if unavailable.
|
|
375
|
-
*/
|
|
376
|
-
async function _AuthenticationController_getCanonicalProfileId() {
|
|
377
|
-
const primaryEntropySourceId = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
531
|
+
}, _AuthenticationController_getCanonicalProfileId = function _AuthenticationController_getCanonicalProfileId() {
|
|
532
|
+
const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
378
533
|
return (this.state.srpSessionData?.[primaryEntropySourceId]?.profile
|
|
379
534
|
?.canonicalProfileId ?? null);
|
|
380
535
|
}, _AuthenticationController_invalidateSrpSession = function _AuthenticationController_invalidateSrpSession(entropySourceId) {
|
|
@@ -387,45 +542,51 @@ async function _AuthenticationController_getCanonicalProfileId() {
|
|
|
387
542
|
entry.profile.canonicalProfileId = '';
|
|
388
543
|
}
|
|
389
544
|
});
|
|
390
|
-
},
|
|
545
|
+
}, _AuthenticationController_getHdKeyringSeed =
|
|
391
546
|
/**
|
|
392
|
-
*
|
|
547
|
+
* Reads the BIP-39 seed for an HD entropy source from KeyringController.
|
|
393
548
|
*
|
|
394
|
-
* @param entropySourceId -
|
|
395
|
-
*
|
|
396
|
-
* @returns The
|
|
549
|
+
* @param entropySourceId - Entropy source ID. Defaults to the primary HD
|
|
550
|
+
* keyring.
|
|
551
|
+
* @returns The HD keyring seed.
|
|
397
552
|
*/
|
|
398
|
-
async function
|
|
399
|
-
__classPrivateFieldGet(this, _AuthenticationController_instances, "m",
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}, _AuthenticationController_snapGetAllPublicKeys =
|
|
553
|
+
async function _AuthenticationController_getHdKeyringSeed(entropySourceId) {
|
|
554
|
+
const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
|
|
555
|
+
return getHdKeyringSeed(this.messenger, resolvedId);
|
|
556
|
+
}, _AuthenticationController_getPublicKey =
|
|
403
557
|
/**
|
|
404
|
-
* Returns
|
|
558
|
+
* Returns the message-signing public key via native SIP-6 derivation
|
|
559
|
+
* (same key as `@metamask/message-signing-snap` with empty salt).
|
|
405
560
|
*
|
|
406
|
-
* @
|
|
561
|
+
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
562
|
+
* when multiple sources are available (Multi-SRP).
|
|
563
|
+
* @returns The public key hex.
|
|
407
564
|
*/
|
|
408
|
-
async function
|
|
409
|
-
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#
|
|
410
|
-
const
|
|
411
|
-
return
|
|
412
|
-
},
|
|
565
|
+
async function _AuthenticationController_getPublicKey(entropySourceId) {
|
|
566
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#getPublicKey');
|
|
567
|
+
const seed = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringSeed).call(this, entropySourceId);
|
|
568
|
+
return getMessageSigningPublicKey(seed);
|
|
569
|
+
}, _AuthenticationController_scopedCacheKey = function _AuthenticationController_scopedCacheKey(message, entropySourceId) {
|
|
570
|
+
return `${entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this)}:${message}`;
|
|
571
|
+
}, _AuthenticationController_signMessage =
|
|
413
572
|
/**
|
|
414
|
-
* Signs a
|
|
573
|
+
* Signs a `metamask:…` message with the native SIP-6 message-signing key.
|
|
415
574
|
*
|
|
416
575
|
* @param message - A specific tagged message to sign.
|
|
417
576
|
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
418
577
|
* when multiple sources are available (Multi-SRP).
|
|
419
|
-
* @returns
|
|
578
|
+
* @returns Compact secp256k1 signature hex.
|
|
420
579
|
*/
|
|
421
|
-
async function
|
|
580
|
+
async function _AuthenticationController_signMessage(message, entropySourceId) {
|
|
422
581
|
assertMessageStartsWithMetamask(message);
|
|
423
|
-
|
|
424
|
-
|
|
582
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#signMessage');
|
|
583
|
+
const cacheKey = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_scopedCacheKey).call(this, message, entropySourceId);
|
|
584
|
+
if (__classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey]) {
|
|
585
|
+
return __classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey];
|
|
425
586
|
}
|
|
426
|
-
__classPrivateFieldGet(this, _AuthenticationController_instances, "m",
|
|
427
|
-
const result =
|
|
428
|
-
__classPrivateFieldGet(this,
|
|
587
|
+
const seed = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringSeed).call(this, entropySourceId);
|
|
588
|
+
const result = await signMessageWithMessageSigningKey(message, seed);
|
|
589
|
+
__classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey] = result;
|
|
429
590
|
return result;
|
|
430
591
|
};
|
|
431
592
|
//# sourceMappingURL=AuthenticationController.mjs.map
|