@metamask-previews/profile-sync-controller 8.1.1-preview-4b0cb25d → 8.1.1-preview-e951f896
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 +0 -1
- package/dist/controllers/authentication/AuthenticationController.cjs +55 -86
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +11 -23
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +11 -23
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +55 -86
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.cjs +10 -23
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +42 -10
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +42 -10
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.mjs +9 -22
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +71 -127
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +5 -4
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +5 -4
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +71 -127
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +1 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
- 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.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +1 -0
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.cjs +3 -3
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.mjs +3 -3
- package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +14 -14
- package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +3 -3
- package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +14 -14
- package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.cjs +27 -23
- package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.cts +16 -7
- package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.d.mts +16 -7
- package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/services.mjs +27 -23
- package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +13 -5
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +13 -5
- package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -1
- package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -1
- package/dist/controllers/user-storage/types.cjs +3 -0
- package/dist/controllers/user-storage/types.cjs.map +1 -0
- package/dist/controllers/user-storage/types.d.cts +23 -0
- package/dist/controllers/user-storage/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/types.d.mts +23 -0
- package/dist/controllers/user-storage/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/types.mjs +2 -0
- package/dist/controllers/user-storage/types.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +7 -8
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +2 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +2 -0
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +8 -9
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +10 -2
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +3 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +3 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +10 -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.mjs.map +1 -1
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +1 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +1 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/mocks/auth.cjs +44 -0
- package/dist/sdk/mocks/auth.cjs.map +1 -0
- package/dist/sdk/mocks/auth.d.cts +39 -0
- package/dist/sdk/mocks/auth.d.cts.map +1 -0
- package/dist/sdk/mocks/auth.d.mts +39 -0
- package/dist/sdk/mocks/auth.d.mts.map +1 -0
- package/dist/sdk/mocks/auth.mjs +41 -0
- package/dist/sdk/mocks/auth.mjs.map +1 -0
- package/dist/sdk/mocks/userstorage.cjs +43 -0
- package/dist/sdk/mocks/userstorage.cjs.map +1 -0
- package/dist/sdk/mocks/userstorage.d.cts +10 -0
- package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
- package/dist/sdk/mocks/userstorage.d.mts +10 -0
- package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
- package/dist/sdk/mocks/userstorage.mjs +15 -0
- package/dist/sdk/mocks/userstorage.mjs.map +1 -0
- package/dist/sdk/user-storage.cjs +34 -39
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +11 -6
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +11 -6
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +34 -39
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +12 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +6 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +6 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +10 -0
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/shared/types/services.cjs +3 -0
- package/dist/shared/types/services.cjs.map +1 -0
- package/dist/shared/types/services.d.cts +10 -0
- package/dist/shared/types/services.d.cts.map +1 -0
- package/dist/shared/types/services.d.mts +10 -0
- package/dist/shared/types/services.d.mts.map +1 -0
- package/dist/shared/types/services.mjs +2 -0
- package/dist/shared/types/services.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/controllers/authentication/services.cjs +0 -132
- package/dist/controllers/authentication/services.cjs.map +0 -1
- package/dist/controllers/authentication/services.d.cts +0 -72
- package/dist/controllers/authentication/services.d.cts.map +0 -1
- package/dist/controllers/authentication/services.d.mts +0 -72
- package/dist/controllers/authentication/services.d.mts.map +0 -1
- package/dist/controllers/authentication/services.mjs +0 -129
- package/dist/controllers/authentication/services.mjs.map +0 -1
- package/dist/controllers/user-storage/services.cjs +0 -306
- package/dist/controllers/user-storage/services.cjs.map +0 -1
- package/dist/controllers/user-storage/services.d.cts +0 -85
- package/dist/controllers/user-storage/services.d.cts.map +0 -1
- package/dist/controllers/user-storage/services.d.mts +0 -85
- package/dist/controllers/user-storage/services.d.mts.map +0 -1
- package/dist/controllers/user-storage/services.mjs +0 -276
- package/dist/controllers/user-storage/services.mjs.map +0 -1
|
@@ -9,11 +9,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_isUnlocked, _AuthenticationController_keyringController, _AuthenticationController_registerMessageHandlers,
|
|
12
|
+
var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_auth, _AuthenticationController_isUnlocked, _AuthenticationController_keyringController, _AuthenticationController_registerMessageHandlers, _AuthenticationController_getLoginResponseFromState, _AuthenticationController_setLoginResponseToState, _AuthenticationController_assertIsUnlocked, _AuthenticationController__snapPublicKeyCache, _AuthenticationController_snapGetPublicKey, _AuthenticationController__snapSignMessageCache, _AuthenticationController_snapSignMessage;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
14
|
import { createSnapPublicKeyRequest, createSnapSignMessageRequest } from "./auth-snap-requests.mjs";
|
|
15
|
-
import {
|
|
16
|
-
const THIRTY_MIN_MS = 1000 * 60 * 30;
|
|
15
|
+
import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth } from "../../sdk/index.mjs";
|
|
17
16
|
const controllerName = 'AuthenticationController';
|
|
18
17
|
export const defaultState = {
|
|
19
18
|
isSignedIn: false,
|
|
@@ -42,6 +41,7 @@ class AuthenticationController extends BaseController {
|
|
|
42
41
|
});
|
|
43
42
|
_AuthenticationController_instances.add(this);
|
|
44
43
|
_AuthenticationController_metametrics.set(this, void 0);
|
|
44
|
+
_AuthenticationController_auth.set(this, void 0);
|
|
45
45
|
_AuthenticationController_isUnlocked.set(this, false);
|
|
46
46
|
_AuthenticationController_keyringController.set(this, {
|
|
47
47
|
setupLockedStateSubscriptions: () => {
|
|
@@ -61,114 +61,86 @@ class AuthenticationController extends BaseController {
|
|
|
61
61
|
throw new Error('`metametrics` field is required');
|
|
62
62
|
}
|
|
63
63
|
__classPrivateFieldSet(this, _AuthenticationController_metametrics, metametrics, "f");
|
|
64
|
+
__classPrivateFieldSet(this, _AuthenticationController_auth, new JwtBearerAuth({
|
|
65
|
+
env: Env.PRD,
|
|
66
|
+
platform: metametrics.agent,
|
|
67
|
+
type: AuthType.SRP,
|
|
68
|
+
}, {
|
|
69
|
+
storage: {
|
|
70
|
+
getLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginResponseFromState).bind(this),
|
|
71
|
+
setLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_setLoginResponseToState).bind(this),
|
|
72
|
+
},
|
|
73
|
+
signing: {
|
|
74
|
+
getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapGetPublicKey).bind(this),
|
|
75
|
+
signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapSignMessage).bind(this),
|
|
76
|
+
},
|
|
77
|
+
metametrics: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f"),
|
|
78
|
+
}), "f");
|
|
64
79
|
__classPrivateFieldGet(this, _AuthenticationController_keyringController, "f").setupLockedStateSubscriptions();
|
|
65
80
|
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_registerMessageHandlers).call(this);
|
|
66
81
|
}
|
|
67
82
|
async performSignIn() {
|
|
68
|
-
|
|
69
|
-
return
|
|
83
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'performSignIn');
|
|
84
|
+
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken();
|
|
70
85
|
}
|
|
71
86
|
performSignOut() {
|
|
87
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'performSignOut');
|
|
72
88
|
this.update((state) => {
|
|
73
89
|
state.isSignedIn = false;
|
|
74
90
|
state.sessionData = undefined;
|
|
75
91
|
});
|
|
76
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Will return a bearer token.
|
|
95
|
+
* Logs a user in if a user is not logged in.
|
|
96
|
+
*
|
|
97
|
+
* @returns profile for the session.
|
|
98
|
+
*/
|
|
77
99
|
async getBearerToken() {
|
|
78
|
-
__classPrivateFieldGet(this, _AuthenticationController_instances, "m",
|
|
79
|
-
|
|
80
|
-
return this.state.sessionData.accessToken;
|
|
81
|
-
}
|
|
82
|
-
const { accessToken } = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_performAuthenticationFlow).call(this);
|
|
83
|
-
return accessToken;
|
|
100
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getBearerToken');
|
|
101
|
+
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken();
|
|
84
102
|
}
|
|
85
103
|
/**
|
|
86
104
|
* Will return a session profile.
|
|
87
|
-
*
|
|
105
|
+
* Logs a user in if a user is not logged in.
|
|
88
106
|
*
|
|
89
107
|
* @returns profile for the session.
|
|
90
108
|
*/
|
|
91
109
|
async getSessionProfile() {
|
|
92
|
-
__classPrivateFieldGet(this, _AuthenticationController_instances, "m",
|
|
93
|
-
|
|
94
|
-
return this.state.sessionData.profile;
|
|
95
|
-
}
|
|
96
|
-
const { profile } = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_performAuthenticationFlow).call(this);
|
|
97
|
-
return profile;
|
|
110
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getSessionProfile');
|
|
111
|
+
return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfile();
|
|
98
112
|
}
|
|
99
113
|
isSignedIn() {
|
|
114
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'isSignedIn');
|
|
100
115
|
return this.state.isSignedIn;
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
|
-
_AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(), _AuthenticationController_keyringController = new WeakMap(), _AuthenticationController__snapPublicKeyCache = new WeakMap(), _AuthenticationController__snapSignMessageCache = new WeakMap(), _AuthenticationController_instances = new WeakSet(), _AuthenticationController_registerMessageHandlers = function _AuthenticationController_registerMessageHandlers() {
|
|
118
|
+
_AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_auth = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(), _AuthenticationController_keyringController = new WeakMap(), _AuthenticationController__snapPublicKeyCache = new WeakMap(), _AuthenticationController__snapSignMessageCache = new WeakMap(), _AuthenticationController_instances = new WeakSet(), _AuthenticationController_registerMessageHandlers = function _AuthenticationController_registerMessageHandlers() {
|
|
104
119
|
this.messagingSystem.registerActionHandler('AuthenticationController:getBearerToken', this.getBearerToken.bind(this));
|
|
105
120
|
this.messagingSystem.registerActionHandler('AuthenticationController:getSessionProfile', this.getSessionProfile.bind(this));
|
|
106
121
|
this.messagingSystem.registerActionHandler('AuthenticationController:isSignedIn', this.isSignedIn.bind(this));
|
|
107
122
|
this.messagingSystem.registerActionHandler('AuthenticationController:performSignIn', this.performSignIn.bind(this));
|
|
108
123
|
this.messagingSystem.registerActionHandler('AuthenticationController:performSignOut', this.performSignOut.bind(this));
|
|
109
|
-
},
|
|
110
|
-
if (!this.state.
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}, _AuthenticationController_performAuthenticationFlow = async function _AuthenticationController_performAuthenticationFlow() {
|
|
114
|
-
try {
|
|
115
|
-
// 1. Nonce
|
|
116
|
-
const publicKey = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapGetPublicKey).call(this);
|
|
117
|
-
const nonce = await getNonce(publicKey);
|
|
118
|
-
if (!nonce) {
|
|
119
|
-
throw new Error(`Unable to get nonce`);
|
|
120
|
-
}
|
|
121
|
-
// 2. Login
|
|
122
|
-
const rawMessage = createLoginRawMessage(nonce, publicKey);
|
|
123
|
-
const signature = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapSignMessage).call(this, rawMessage);
|
|
124
|
-
const loginResponse = await login(rawMessage, signature, {
|
|
125
|
-
metametricsId: await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId(),
|
|
126
|
-
agent: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").agent,
|
|
127
|
-
});
|
|
128
|
-
if (!loginResponse?.token) {
|
|
129
|
-
throw new Error(`Unable to login`);
|
|
130
|
-
}
|
|
131
|
-
const profile = {
|
|
132
|
-
identifierId: loginResponse.profile.identifier_id,
|
|
133
|
-
profileId: loginResponse.profile.profile_id,
|
|
134
|
-
};
|
|
135
|
-
// 3. Trade for Access Token
|
|
136
|
-
const accessToken = await getAccessToken(loginResponse.token, __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").agent);
|
|
137
|
-
if (!accessToken) {
|
|
138
|
-
throw new Error(`Unable to get Access Token`);
|
|
139
|
-
}
|
|
140
|
-
// Update Internal State
|
|
141
|
-
this.update((state) => {
|
|
142
|
-
state.isSignedIn = true;
|
|
143
|
-
const expiresIn = new Date();
|
|
144
|
-
expiresIn.setTime(expiresIn.getTime() + THIRTY_MIN_MS);
|
|
145
|
-
state.sessionData = {
|
|
146
|
-
profile,
|
|
147
|
-
accessToken,
|
|
148
|
-
expiresIn: expiresIn.toString(),
|
|
149
|
-
};
|
|
150
|
-
});
|
|
151
|
-
return {
|
|
152
|
-
profile,
|
|
153
|
-
accessToken,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
catch (e) {
|
|
157
|
-
console.error('Failed to authenticate', e);
|
|
158
|
-
const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
|
|
159
|
-
throw new Error(`${controllerName}: Failed to authenticate - ${errorMessage}`);
|
|
160
|
-
}
|
|
161
|
-
}, _AuthenticationController_hasValidSession = function _AuthenticationController_hasValidSession(sessionData) {
|
|
162
|
-
if (!sessionData) {
|
|
163
|
-
return false;
|
|
124
|
+
}, _AuthenticationController_getLoginResponseFromState = async function _AuthenticationController_getLoginResponseFromState() {
|
|
125
|
+
if (!this.state.sessionData) {
|
|
126
|
+
return null;
|
|
164
127
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
128
|
+
return {
|
|
129
|
+
...this.state.sessionData,
|
|
130
|
+
profile: {
|
|
131
|
+
...this.state.sessionData.profile,
|
|
132
|
+
metaMetricsId: await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId(),
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}, _AuthenticationController_setLoginResponseToState = async function _AuthenticationController_setLoginResponseToState(loginResponse) {
|
|
136
|
+
this.update((state) => {
|
|
137
|
+
state.isSignedIn = true;
|
|
138
|
+
state.sessionData = loginResponse;
|
|
139
|
+
});
|
|
140
|
+
}, _AuthenticationController_assertIsUnlocked = function _AuthenticationController_assertIsUnlocked(methodName) {
|
|
141
|
+
if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
|
|
142
|
+
throw new Error(`${methodName} - unable to proceed, wallet is locked`);
|
|
168
143
|
}
|
|
169
|
-
const currentDate = new Date();
|
|
170
|
-
const diffMs = Math.abs(currentDate.getTime() - prevDate);
|
|
171
|
-
return THIRTY_MIN_MS > diffMs;
|
|
172
144
|
}, _AuthenticationController_snapGetPublicKey =
|
|
173
145
|
/**
|
|
174
146
|
* Returns the auth snap public key.
|
|
@@ -179,9 +151,7 @@ async function _AuthenticationController_snapGetPublicKey() {
|
|
|
179
151
|
if (__classPrivateFieldGet(this, _AuthenticationController__snapPublicKeyCache, "f")) {
|
|
180
152
|
return __classPrivateFieldGet(this, _AuthenticationController__snapPublicKeyCache, "f");
|
|
181
153
|
}
|
|
182
|
-
|
|
183
|
-
throw new Error('#snapGetPublicKey - unable to call snap, wallet is locked');
|
|
184
|
-
}
|
|
154
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#snapGetPublicKey');
|
|
185
155
|
const result = (await this.messagingSystem.call('SnapController:handleRequest', createSnapPublicKeyRequest()));
|
|
186
156
|
__classPrivateFieldSet(this, _AuthenticationController__snapPublicKeyCache, result, "f");
|
|
187
157
|
return result;
|
|
@@ -193,12 +163,11 @@ async function _AuthenticationController_snapGetPublicKey() {
|
|
|
193
163
|
* @returns A Signature created by the snap.
|
|
194
164
|
*/
|
|
195
165
|
async function _AuthenticationController_snapSignMessage(message) {
|
|
166
|
+
assertMessageStartsWithMetamask(message);
|
|
196
167
|
if (__classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message]) {
|
|
197
168
|
return __classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message];
|
|
198
169
|
}
|
|
199
|
-
|
|
200
|
-
throw new Error('#snapSignMessage - unable to call snap, wallet is locked');
|
|
201
|
-
}
|
|
170
|
+
__classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#snapSignMessage');
|
|
202
171
|
const result = (await this.messagingSystem.call('SnapController:handleRequest', createSnapSignMessageRequest(message)));
|
|
203
172
|
__classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message] = result;
|
|
204
173
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticationController.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAQ3D,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC7B,iCAA6B;AAC9B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,KAAK,EACN,uBAAmB;AAEpB,MAAM,aAAa,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAErC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AA8BlD,MAAM,CAAC,MAAM,YAAY,GAAkC;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CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAC7C,8BAA8B,EAC9B,4BAA4B,CAAC,OAAO,CAAC,CACtC,CAAW,CAAC;IAEb,uBAAA,IAAI,uDAAuB,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IAE9C,OAAO,MAAM,CAAC;AAChB,CAAC;eAnRkB,wBAAwB","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport {\n createSnapPublicKeyRequest,\n createSnapSignMessageRequest,\n} from './auth-snap-requests';\nimport {\n createLoginRawMessage,\n getAccessToken,\n getNonce,\n login,\n} from './services';\n\nconst THIRTY_MIN_MS = 1000 * 60 * 30;\n\nconst controllerName = 'AuthenticationController';\n\n// State\ntype SessionProfile = {\n identifierId: string;\n profileId: string;\n};\n\ntype SessionData = {\n /** profile - anonymous profile data for the given logged in user */\n profile: SessionProfile;\n /** accessToken - used to make requests authorized endpoints */\n accessToken: string;\n /** expiresIn - string date to determine if new access token is required */\n expiresIn: string;\n};\n\ntype MetaMetricsAuth = {\n getMetaMetricsId: () => string | Promise<string>;\n agent: 'extension' | 'mobile';\n};\n\nexport type AuthenticationControllerState = {\n /**\n * Global isSignedIn state.\n * Can be used to determine if \"Profile Syncing\" is enabled.\n */\n isSignedIn: boolean;\n sessionData?: SessionData;\n};\nexport const defaultState: AuthenticationControllerState = {\n isSignedIn: false,\n};\nconst metadata: StateMetadata<AuthenticationControllerState> = {\n isSignedIn: {\n persist: true,\n anonymous: true,\n },\n sessionData: {\n persist: true,\n anonymous: false,\n },\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof AuthenticationController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: AuthenticationController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performSignIn'\n | 'performSignOut'\n | 'getBearerToken'\n | 'getSessionProfile'\n | 'isSignedIn'\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | AuthenticationControllerGetStateAction;\nexport type AuthenticationControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AuthenticationControllerState\n>;\nexport type AuthenticationControllerPerformSignIn = ActionsObj['performSignIn'];\nexport type AuthenticationControllerPerformSignOut =\n ActionsObj['performSignOut'];\nexport type AuthenticationControllerGetBearerToken =\n ActionsObj['getBearerToken'];\nexport type AuthenticationControllerGetSessionProfile =\n ActionsObj['getSessionProfile'];\nexport type AuthenticationControllerIsSignedIn = ActionsObj['isSignedIn'];\n\nexport type AuthenticationControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n AuthenticationControllerState\n >;\n\nexport type Events = AuthenticationControllerStateChangeEvent;\n\n// Allowed Actions\nexport type AllowedActions =\n | HandleSnapRequest\n | KeyringControllerGetStateAction;\n\nexport type AllowedEvents =\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent;\n\n// Messenger\nexport type AuthenticationControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Controller that enables authentication for restricted endpoints.\n * Used for Global Profile Syncing and Notifications\n */\nexport default class AuthenticationController extends BaseController<\n typeof controllerName,\n AuthenticationControllerState,\n AuthenticationControllerMessenger\n> {\n readonly #metametrics: MetaMetricsAuth;\n\n #isUnlocked = false;\n\n readonly #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n constructor({\n messenger,\n state,\n metametrics,\n }: {\n messenger: AuthenticationControllerMessenger;\n state?: AuthenticationControllerState;\n /**\n * Not using the Messaging System as we\n * do not want to tie this strictly to extension\n */\n metametrics: MetaMetricsAuth;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n if (!metametrics) {\n throw new Error('`metametrics` field is required');\n }\n\n this.#metametrics = metametrics;\n\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getBearerToken',\n this.getBearerToken.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getSessionProfile',\n this.getSessionProfile.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:isSignedIn',\n this.isSignedIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignIn',\n this.performSignIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignOut',\n this.performSignOut.bind(this),\n );\n }\n\n public async performSignIn(): Promise<string> {\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n public performSignOut(): void {\n this.update((state) => {\n state.isSignedIn = false;\n state.sessionData = undefined;\n });\n }\n\n public async getBearerToken(): Promise<string> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.accessToken;\n }\n\n const { accessToken } = await this.#performAuthenticationFlow();\n return accessToken;\n }\n\n /**\n * Will return a session profile.\n * Throws if a user is not logged in.\n *\n * @returns profile for the session.\n */\n public async getSessionProfile(): Promise<SessionProfile> {\n this.#assertLoggedIn();\n\n if (this.#hasValidSession(this.state.sessionData)) {\n return this.state.sessionData.profile;\n }\n\n const { profile } = await this.#performAuthenticationFlow();\n return profile;\n }\n\n public isSignedIn(): boolean {\n return this.state.isSignedIn;\n }\n\n #assertLoggedIn(): void {\n if (!this.state.isSignedIn) {\n throw new Error(\n `${controllerName}: Unable to call method, user is not authenticated`,\n );\n }\n }\n\n async #performAuthenticationFlow(): Promise<{\n profile: SessionProfile;\n accessToken: string;\n }> {\n try {\n // 1. Nonce\n const publicKey = await this.#snapGetPublicKey();\n const nonce = await getNonce(publicKey);\n if (!nonce) {\n throw new Error(`Unable to get nonce`);\n }\n\n // 2. Login\n const rawMessage = createLoginRawMessage(nonce, publicKey);\n const signature = await this.#snapSignMessage(rawMessage);\n const loginResponse = await login(rawMessage, signature, {\n metametricsId: await this.#metametrics.getMetaMetricsId(),\n agent: this.#metametrics.agent,\n });\n if (!loginResponse?.token) {\n throw new Error(`Unable to login`);\n }\n\n const profile: SessionProfile = {\n identifierId: loginResponse.profile.identifier_id,\n profileId: loginResponse.profile.profile_id,\n };\n\n // 3. Trade for Access Token\n const accessToken = await getAccessToken(\n loginResponse.token,\n this.#metametrics.agent,\n );\n if (!accessToken) {\n throw new Error(`Unable to get Access Token`);\n }\n\n // Update Internal State\n this.update((state) => {\n state.isSignedIn = true;\n const expiresIn = new Date();\n expiresIn.setTime(expiresIn.getTime() + THIRTY_MIN_MS);\n state.sessionData = {\n profile,\n accessToken,\n expiresIn: expiresIn.toString(),\n };\n });\n\n return {\n profile,\n accessToken,\n };\n } catch (e) {\n console.error('Failed to authenticate', e);\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new Error(\n `${controllerName}: Failed to authenticate - ${errorMessage}`,\n );\n }\n }\n\n #hasValidSession(\n sessionData: SessionData | undefined,\n ): sessionData is SessionData {\n if (!sessionData) {\n return false;\n }\n\n const prevDate = Date.parse(sessionData.expiresIn);\n if (isNaN(prevDate)) {\n return false;\n }\n\n const currentDate = new Date();\n const diffMs = Math.abs(currentDate.getTime() - prevDate);\n\n return THIRTY_MIN_MS > diffMs;\n }\n\n #_snapPublicKeyCache: string | undefined;\n\n /**\n * Returns the auth snap public key.\n *\n * @returns The snap public key.\n */\n async #snapGetPublicKey(): Promise<string> {\n if (this.#_snapPublicKeyCache) {\n return this.#_snapPublicKeyCache;\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapGetPublicKey - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapPublicKeyRequest(),\n )) as string;\n\n this.#_snapPublicKeyCache = result;\n\n return result;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapSignMessage - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AuthenticationController.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAQ3D,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC7B,iCAA6B;AAE9B,OAAO,EACL,+BAA+B,EAC/B,QAAQ,EACR,GAAG,EACH,aAAa,EACd,4BAAkB;AAGnB,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAOlD,MAAM,CAAC,MAAM,YAAY,GAAkC;IACzD,UAAU,EAAE,KAAK;CAClB,CAAC;AACF,MAAM,QAAQ,GAAiD;IAC7D,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,WAAW,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n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport {\n createSnapPublicKeyRequest,\n createSnapSignMessageRequest,\n} from './auth-snap-requests';\nimport type { LoginResponse, SRPInterface, UserProfile } from '../../sdk';\nimport {\n assertMessageStartsWithMetamask,\n AuthType,\n Env,\n JwtBearerAuth,\n} from '../../sdk';\nimport type { MetaMetricsAuth } from '../../shared/types/services';\n\nconst controllerName = 'AuthenticationController';\n\n// State\nexport type AuthenticationControllerState = {\n isSignedIn: boolean;\n sessionData?: LoginResponse;\n};\nexport const defaultState: AuthenticationControllerState = {\n isSignedIn: false,\n};\nconst metadata: StateMetadata<AuthenticationControllerState> = {\n isSignedIn: {\n persist: true,\n anonymous: true,\n },\n sessionData: {\n persist: true,\n anonymous: false,\n },\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof AuthenticationController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: AuthenticationController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performSignIn'\n | 'performSignOut'\n | 'getBearerToken'\n | 'getSessionProfile'\n | 'isSignedIn'\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | AuthenticationControllerGetStateAction;\nexport type AuthenticationControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AuthenticationControllerState\n>;\nexport type AuthenticationControllerPerformSignIn = ActionsObj['performSignIn'];\nexport type AuthenticationControllerPerformSignOut =\n ActionsObj['performSignOut'];\nexport type AuthenticationControllerGetBearerToken =\n ActionsObj['getBearerToken'];\nexport type AuthenticationControllerGetSessionProfile =\n ActionsObj['getSessionProfile'];\nexport type AuthenticationControllerIsSignedIn = ActionsObj['isSignedIn'];\n\nexport type AuthenticationControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n AuthenticationControllerState\n >;\n\nexport type Events = AuthenticationControllerStateChangeEvent;\n\n// Allowed Actions\nexport type AllowedActions =\n | HandleSnapRequest\n | KeyringControllerGetStateAction;\n\nexport type AllowedEvents =\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent;\n\n// Messenger\nexport type AuthenticationControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * Controller that enables authentication for restricted endpoints.\n * Used for Global Profile Syncing and Notifications\n */\nexport default class AuthenticationController extends BaseController<\n typeof controllerName,\n AuthenticationControllerState,\n AuthenticationControllerMessenger\n> {\n readonly #metametrics: MetaMetricsAuth;\n\n readonly #auth: SRPInterface;\n\n #isUnlocked = false;\n\n readonly #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n constructor({\n messenger,\n state,\n metametrics,\n }: {\n messenger: AuthenticationControllerMessenger;\n state?: AuthenticationControllerState;\n /**\n * Not using the Messaging System as we\n * do not want to tie this strictly to extension\n */\n metametrics: MetaMetricsAuth;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n if (!metametrics) {\n throw new Error('`metametrics` field is required');\n }\n\n this.#metametrics = metametrics;\n\n this.#auth = new JwtBearerAuth(\n {\n env: Env.PRD,\n platform: metametrics.agent,\n type: AuthType.SRP,\n },\n {\n storage: {\n getLoginResponse: this.#getLoginResponseFromState.bind(this),\n setLoginResponse: this.#setLoginResponseToState.bind(this),\n },\n signing: {\n getIdentifier: this.#snapGetPublicKey.bind(this),\n signMessage: this.#snapSignMessage.bind(this),\n },\n metametrics: this.#metametrics,\n },\n );\n\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getBearerToken',\n this.getBearerToken.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:getSessionProfile',\n this.getSessionProfile.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:isSignedIn',\n this.isSignedIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignIn',\n this.performSignIn.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'AuthenticationController:performSignOut',\n this.performSignOut.bind(this),\n );\n }\n\n async #getLoginResponseFromState(): Promise<LoginResponse | null> {\n if (!this.state.sessionData) {\n return null;\n }\n\n return {\n ...this.state.sessionData,\n profile: {\n ...this.state.sessionData.profile,\n metaMetricsId: await this.#metametrics.getMetaMetricsId(),\n },\n };\n }\n\n async #setLoginResponseToState(loginResponse: LoginResponse) {\n this.update((state) => {\n state.isSignedIn = true;\n state.sessionData = loginResponse;\n });\n }\n\n #assertIsUnlocked(methodName: string): void {\n if (!this.#isUnlocked) {\n throw new Error(`${methodName} - unable to proceed, wallet is locked`);\n }\n }\n\n public async performSignIn(): Promise<string> {\n this.#assertIsUnlocked('performSignIn');\n return await this.#auth.getAccessToken();\n }\n\n public performSignOut(): void {\n this.#assertIsUnlocked('performSignOut');\n this.update((state) => {\n state.isSignedIn = false;\n state.sessionData = undefined;\n });\n }\n\n /**\n * Will return a bearer token.\n * Logs a user in if a user is not logged in.\n *\n * @returns profile for the session.\n */\n\n public async getBearerToken(): Promise<string> {\n this.#assertIsUnlocked('getBearerToken');\n return await this.#auth.getAccessToken();\n }\n\n /**\n * Will return a session profile.\n * Logs a user in if a user is not logged in.\n *\n * @returns profile for the session.\n */\n public async getSessionProfile(): Promise<UserProfile> {\n this.#assertIsUnlocked('getSessionProfile');\n return await this.#auth.getUserProfile();\n }\n\n public isSignedIn(): boolean {\n this.#assertIsUnlocked('isSignedIn');\n return this.state.isSignedIn;\n }\n\n #_snapPublicKeyCache: string | undefined;\n\n /**\n * Returns the auth snap public key.\n *\n * @returns The snap public key.\n */\n async #snapGetPublicKey(): Promise<string> {\n if (this.#_snapPublicKeyCache) {\n return this.#_snapPublicKeyCache;\n }\n\n this.#assertIsUnlocked('#snapGetPublicKey');\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapPublicKeyRequest(),\n )) as string;\n\n this.#_snapPublicKeyCache = result;\n\n return result;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: string): Promise<string> {\n assertMessageStartsWithMetamask(message);\n\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n this.#assertIsUnlocked('#snapSignMessage');\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n}\n"]}
|
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMockAuthAccessTokenResponse = exports.MOCK_OATH_TOKEN_RESPONSE = exports.
|
|
4
|
-
const
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
};
|
|
3
|
+
exports.getMockAuthAccessTokenResponse = exports.MOCK_OATH_TOKEN_RESPONSE = exports.getMockAuthLoginResponse = exports.MOCK_LOGIN_RESPONSE = exports.getMockAuthNonceResponse = exports.MOCK_JWT = exports.MOCK_NONCE = exports.MOCK_NONCE_RESPONSE = void 0;
|
|
4
|
+
const auth_1 = require("../../../sdk/mocks/auth.cjs");
|
|
5
|
+
exports.MOCK_NONCE_RESPONSE = auth_1.MOCK_NONCE_RESPONSE;
|
|
6
|
+
exports.MOCK_NONCE = exports.MOCK_NONCE_RESPONSE.nonce;
|
|
7
|
+
exports.MOCK_JWT = auth_1.MOCK_JWT;
|
|
9
8
|
const getMockAuthNonceResponse = () => {
|
|
10
9
|
return {
|
|
11
|
-
url:
|
|
10
|
+
url: auth_1.MOCK_NONCE_URL,
|
|
12
11
|
requestMethod: 'GET',
|
|
13
12
|
response: exports.MOCK_NONCE_RESPONSE,
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
15
|
exports.getMockAuthNonceResponse = getMockAuthNonceResponse;
|
|
17
|
-
exports.
|
|
18
|
-
exports.MOCK_LOGIN_RESPONSE = {
|
|
19
|
-
token: exports.MOCK_JWT,
|
|
20
|
-
expires_in: new Date().toString(),
|
|
21
|
-
profile: {
|
|
22
|
-
identifier_id: 'MOCK_IDENTIFIER',
|
|
23
|
-
profile_id: 'MOCK_PROFILE_ID',
|
|
24
|
-
},
|
|
25
|
-
};
|
|
16
|
+
exports.MOCK_LOGIN_RESPONSE = auth_1.MOCK_SRP_LOGIN_RESPONSE;
|
|
26
17
|
const getMockAuthLoginResponse = () => {
|
|
27
18
|
return {
|
|
28
|
-
url:
|
|
19
|
+
url: auth_1.MOCK_SRP_LOGIN_URL,
|
|
29
20
|
requestMethod: 'POST',
|
|
30
21
|
response: exports.MOCK_LOGIN_RESPONSE,
|
|
31
22
|
};
|
|
32
23
|
};
|
|
33
24
|
exports.getMockAuthLoginResponse = getMockAuthLoginResponse;
|
|
34
|
-
exports.
|
|
35
|
-
exports.MOCK_OATH_TOKEN_RESPONSE = {
|
|
36
|
-
access_token: exports.MOCK_ACCESS_TOKEN,
|
|
37
|
-
expires_in: new Date().getTime(),
|
|
38
|
-
};
|
|
25
|
+
exports.MOCK_OATH_TOKEN_RESPONSE = auth_1.MOCK_OIDC_TOKEN_RESPONSE;
|
|
39
26
|
const getMockAuthAccessTokenResponse = () => {
|
|
40
27
|
return {
|
|
41
|
-
url:
|
|
28
|
+
url: auth_1.MOCK_OIDC_TOKEN_URL,
|
|
42
29
|
requestMethod: 'POST',
|
|
43
30
|
response: exports.MOCK_OATH_TOKEN_RESPONSE,
|
|
44
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":";;;
|
|
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;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC;AAEW,QAAA,mBAAmB,GAAG,8BAA2B,CAAC;AAExD,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,yBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,2BAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC;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,gCAAwB;KACZ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,8BAA8B,kCAMzC","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: MOCK_NONCE_RESPONSE,\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 response: MOCK_LOGIN_RESPONSE,\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: MOCK_OATH_TOKEN_RESPONSE,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -1,23 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const MOCK_NONCE_RESPONSE: {
|
|
2
|
+
nonce: string;
|
|
3
|
+
identifier: string;
|
|
4
|
+
expires_in: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const MOCK_NONCE: string;
|
|
7
|
+
export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ";
|
|
4
8
|
export declare const getMockAuthNonceResponse: () => {
|
|
5
9
|
url: string;
|
|
6
10
|
requestMethod: "GET";
|
|
7
|
-
response:
|
|
11
|
+
response: {
|
|
12
|
+
nonce: string;
|
|
13
|
+
identifier: string;
|
|
14
|
+
expires_in: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const MOCK_LOGIN_RESPONSE: {
|
|
18
|
+
token: string;
|
|
19
|
+
expires_in: number;
|
|
20
|
+
profile: {
|
|
21
|
+
profile_id: string;
|
|
22
|
+
metametrics_id: string;
|
|
23
|
+
identifier_id: string;
|
|
24
|
+
identifier_type: string;
|
|
25
|
+
encrypted_storage_key: string;
|
|
26
|
+
};
|
|
8
27
|
};
|
|
9
|
-
export declare const MOCK_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
|
|
10
|
-
export declare const MOCK_LOGIN_RESPONSE: LoginResponse;
|
|
11
28
|
export declare const getMockAuthLoginResponse: () => {
|
|
12
29
|
url: string;
|
|
13
30
|
requestMethod: "POST";
|
|
14
|
-
response:
|
|
31
|
+
response: {
|
|
32
|
+
token: string;
|
|
33
|
+
expires_in: number;
|
|
34
|
+
profile: {
|
|
35
|
+
profile_id: string;
|
|
36
|
+
metametrics_id: string;
|
|
37
|
+
identifier_id: string;
|
|
38
|
+
identifier_type: string;
|
|
39
|
+
encrypted_storage_key: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const MOCK_OATH_TOKEN_RESPONSE: {
|
|
44
|
+
access_token: string;
|
|
45
|
+
expires_in: number;
|
|
15
46
|
};
|
|
16
|
-
export declare const MOCK_ACCESS_TOKEN = "MOCK_ACCESS_TOKEN-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
|
|
17
|
-
export declare const MOCK_OATH_TOKEN_RESPONSE: OAuthTokenResponse;
|
|
18
47
|
export declare const getMockAuthAccessTokenResponse: () => {
|
|
19
48
|
url: string;
|
|
20
49
|
requestMethod: "POST";
|
|
21
|
-
response:
|
|
50
|
+
response: {
|
|
51
|
+
access_token: string;
|
|
52
|
+
expires_in: number;
|
|
53
|
+
};
|
|
22
54
|
};
|
|
23
55
|
//# sourceMappingURL=mockResponses.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"
|
|
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;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;;;;;CAM1C,CAAC"}
|
|
@@ -1,23 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const MOCK_NONCE_RESPONSE: {
|
|
2
|
+
nonce: string;
|
|
3
|
+
identifier: string;
|
|
4
|
+
expires_in: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const MOCK_NONCE: string;
|
|
7
|
+
export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ";
|
|
4
8
|
export declare const getMockAuthNonceResponse: () => {
|
|
5
9
|
url: string;
|
|
6
10
|
requestMethod: "GET";
|
|
7
|
-
response:
|
|
11
|
+
response: {
|
|
12
|
+
nonce: string;
|
|
13
|
+
identifier: string;
|
|
14
|
+
expires_in: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const MOCK_LOGIN_RESPONSE: {
|
|
18
|
+
token: string;
|
|
19
|
+
expires_in: number;
|
|
20
|
+
profile: {
|
|
21
|
+
profile_id: string;
|
|
22
|
+
metametrics_id: string;
|
|
23
|
+
identifier_id: string;
|
|
24
|
+
identifier_type: string;
|
|
25
|
+
encrypted_storage_key: string;
|
|
26
|
+
};
|
|
8
27
|
};
|
|
9
|
-
export declare const MOCK_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
|
|
10
|
-
export declare const MOCK_LOGIN_RESPONSE: LoginResponse;
|
|
11
28
|
export declare const getMockAuthLoginResponse: () => {
|
|
12
29
|
url: string;
|
|
13
30
|
requestMethod: "POST";
|
|
14
|
-
response:
|
|
31
|
+
response: {
|
|
32
|
+
token: string;
|
|
33
|
+
expires_in: number;
|
|
34
|
+
profile: {
|
|
35
|
+
profile_id: string;
|
|
36
|
+
metametrics_id: string;
|
|
37
|
+
identifier_id: string;
|
|
38
|
+
identifier_type: string;
|
|
39
|
+
encrypted_storage_key: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const MOCK_OATH_TOKEN_RESPONSE: {
|
|
44
|
+
access_token: string;
|
|
45
|
+
expires_in: number;
|
|
15
46
|
};
|
|
16
|
-
export declare const MOCK_ACCESS_TOKEN = "MOCK_ACCESS_TOKEN-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
|
|
17
|
-
export declare const MOCK_OATH_TOKEN_RESPONSE: OAuthTokenResponse;
|
|
18
47
|
export declare const getMockAuthAccessTokenResponse: () => {
|
|
19
48
|
url: string;
|
|
20
49
|
requestMethod: "POST";
|
|
21
|
-
response:
|
|
50
|
+
response: {
|
|
51
|
+
access_token: string;
|
|
52
|
+
expires_in: number;
|
|
53
|
+
};
|
|
22
54
|
};
|
|
23
55
|
//# sourceMappingURL=mockResponses.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"
|
|
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;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;;;;;CAM1C,CAAC"}
|
|
@@ -1,39 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import { MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE, MOCK_JWT as SDK_MOCK_JWT, MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE, MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE, MOCK_NONCE_URL, MOCK_SRP_LOGIN_URL, MOCK_OIDC_TOKEN_URL } from "../../../sdk/mocks/auth.mjs";
|
|
2
|
+
export const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;
|
|
3
|
+
export const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;
|
|
4
|
+
export const MOCK_JWT = SDK_MOCK_JWT;
|
|
6
5
|
export const getMockAuthNonceResponse = () => {
|
|
7
6
|
return {
|
|
8
|
-
url:
|
|
7
|
+
url: MOCK_NONCE_URL,
|
|
9
8
|
requestMethod: 'GET',
|
|
10
9
|
response: MOCK_NONCE_RESPONSE,
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
export const
|
|
14
|
-
export const MOCK_LOGIN_RESPONSE = {
|
|
15
|
-
token: MOCK_JWT,
|
|
16
|
-
expires_in: new Date().toString(),
|
|
17
|
-
profile: {
|
|
18
|
-
identifier_id: 'MOCK_IDENTIFIER',
|
|
19
|
-
profile_id: 'MOCK_PROFILE_ID',
|
|
20
|
-
},
|
|
21
|
-
};
|
|
12
|
+
export const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;
|
|
22
13
|
export const getMockAuthLoginResponse = () => {
|
|
23
14
|
return {
|
|
24
|
-
url:
|
|
15
|
+
url: MOCK_SRP_LOGIN_URL,
|
|
25
16
|
requestMethod: 'POST',
|
|
26
17
|
response: MOCK_LOGIN_RESPONSE,
|
|
27
18
|
};
|
|
28
19
|
};
|
|
29
|
-
export const
|
|
30
|
-
export const MOCK_OATH_TOKEN_RESPONSE = {
|
|
31
|
-
access_token: MOCK_ACCESS_TOKEN,
|
|
32
|
-
expires_in: new Date().getTime(),
|
|
33
|
-
};
|
|
20
|
+
export const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;
|
|
34
21
|
export const getMockAuthAccessTokenResponse = () => {
|
|
35
22
|
return {
|
|
36
|
-
url:
|
|
23
|
+
url: MOCK_OIDC_TOKEN_URL,
|
|
37
24
|
requestMethod: 'POST',
|
|
38
25
|
response: MOCK_OATH_TOKEN_RESPONSE,
|
|
39
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"
|
|
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;KACP,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,QAAQ,EAAE,mBAAmB;KACP,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,wBAAwB;KACZ,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: MOCK_NONCE_RESPONSE,\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 response: MOCK_LOGIN_RESPONSE,\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: MOCK_OATH_TOKEN_RESPONSE,\n } satisfies MockResponse;\n};\n"]}
|