@metamask-previews/seedless-onboarding-controller 3.0.0-preview-e53ed971 → 3.0.0-preview-3f792d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SeedlessOnboardingController.cjs +53 -87
- package/dist/SeedlessOnboardingController.cjs.map +1 -1
- package/dist/SeedlessOnboardingController.d.cts.map +1 -1
- package/dist/SeedlessOnboardingController.d.mts.map +1 -1
- package/dist/SeedlessOnboardingController.mjs +55 -89
- package/dist/SeedlessOnboardingController.mjs.map +1 -1
- package/dist/constants.cjs +0 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +0 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +0 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +0 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +9 -8
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +9 -8
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs +66 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +30 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +30 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +62 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -9,11 +9,11 @@ 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 _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken,
|
|
12
|
+
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken, _SeedlessOnboardingController_passwordOutdatedCacheTTL, _SeedlessOnboardingController_isUnlocked, _SeedlessOnboardingController_submitGlobalPassword, _SeedlessOnboardingController_getAccessToken, _SeedlessOnboardingController_setUnlocked, _SeedlessOnboardingController_persistOprfKey, _SeedlessOnboardingController_persistAuthPubKey, _SeedlessOnboardingController_storeKeyringEncryptionKey, _SeedlessOnboardingController_loadKeyringEncryptionKey, _SeedlessOnboardingController_loadSeedlessEncryptionKey, _SeedlessOnboardingController_recoverAuthPubKey, _SeedlessOnboardingController_recoverEncKey, _SeedlessOnboardingController_fetchAllSecretDataFromMetadataStore, _SeedlessOnboardingController_changeEncryptionKey, _SeedlessOnboardingController_encryptAndStoreSecretData, _SeedlessOnboardingController_unlockVaultAndGetVaultData, _SeedlessOnboardingController_decryptAndParseVaultData, _SeedlessOnboardingController_withPersistedSecretMetadataBackupsState, _SeedlessOnboardingController_filterDupesAndUpdateSocialBackupsMetadata, _SeedlessOnboardingController_createNewVaultWithAuthData, _SeedlessOnboardingController_updateVault, _SeedlessOnboardingController_withControllerLock, _SeedlessOnboardingController_withVaultLock, _SeedlessOnboardingController_parseVaultData, _SeedlessOnboardingController_assertIsUnlocked, _SeedlessOnboardingController_assertIsAuthenticatedUser, _SeedlessOnboardingController_assertIsSRPBackedUpUser, _SeedlessOnboardingController_assertPasswordInSync, _SeedlessOnboardingController_resetPasswordOutdatedCache, _SeedlessOnboardingController_isTokenExpiredError, _SeedlessOnboardingController_isMaxKeyChainLengthError, _SeedlessOnboardingController_executeWithTokenRefresh;
|
|
13
13
|
import { keccak256AndHexify } from "@metamask/auth-network-utils";
|
|
14
14
|
import { BaseController } from "@metamask/base-controller";
|
|
15
15
|
import { ToprfSecureBackup, TOPRFErrorCode, TOPRFError } from "@metamask/toprf-secure-backup";
|
|
16
|
-
import { base64ToBytes, bytesToBase64
|
|
16
|
+
import { base64ToBytes, bytesToBase64 } from "@metamask/utils";
|
|
17
17
|
import { gcm } from "@noble/ciphers/aes";
|
|
18
18
|
import { bytesToUtf8, utf8ToBytes } from "@noble/ciphers/utils";
|
|
19
19
|
import { managedNonce } from "@noble/ciphers/webcrypto";
|
|
@@ -24,7 +24,7 @@ import { controllerName, PASSWORD_OUTDATED_CACHE_TTL_MS, SecretType, SeedlessOnb
|
|
|
24
24
|
import { PasswordSyncError, RecoveryError } from "./errors.mjs";
|
|
25
25
|
import { projectLogger, createModuleLogger } from "./logger.mjs";
|
|
26
26
|
import { SecretMetadata } from "./SecretMetadata.mjs";
|
|
27
|
-
import { decodeJWTToken, decodeNodeAuthToken } from "./utils.mjs";
|
|
27
|
+
import { decodeJWTToken, decodeNodeAuthToken, deserializeVaultData, serializeVaultData } from "./utils.mjs";
|
|
28
28
|
const log = createModuleLogger(projectLogger, controllerName);
|
|
29
29
|
/**
|
|
30
30
|
* Get the initial state for the Seedless Onboarding Controller with defaults.
|
|
@@ -163,16 +163,16 @@ export class SeedlessOnboardingController extends BaseController {
|
|
|
163
163
|
_SeedlessOnboardingController_vaultOperationMutex.set(this, new Mutex());
|
|
164
164
|
_SeedlessOnboardingController_refreshJWTToken.set(this, void 0);
|
|
165
165
|
_SeedlessOnboardingController_revokeRefreshToken.set(this, void 0);
|
|
166
|
+
/**
|
|
167
|
+
* The TTL of the password outdated cache in milliseconds.
|
|
168
|
+
*/
|
|
169
|
+
_SeedlessOnboardingController_passwordOutdatedCacheTTL.set(this, void 0);
|
|
166
170
|
/**
|
|
167
171
|
* Controller lock state.
|
|
168
172
|
*
|
|
169
173
|
* The controller lock is synchronized with the keyring lock.
|
|
170
174
|
*/
|
|
171
175
|
_SeedlessOnboardingController_isUnlocked.set(this, false);
|
|
172
|
-
/**
|
|
173
|
-
* The TTL of the password outdated cache in milliseconds.
|
|
174
|
-
*/
|
|
175
|
-
_SeedlessOnboardingController_passwordOutdatedCacheTTL.set(this, void 0);
|
|
176
176
|
assertIsPasswordOutdatedCacheValid(passwordOutdatedCacheTTL);
|
|
177
177
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_passwordOutdatedCacheTTL, passwordOutdatedCacheTTL, "f");
|
|
178
178
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_vaultEncryptor, encryptor, "f");
|
|
@@ -502,7 +502,7 @@ export class SeedlessOnboardingController extends BaseController {
|
|
|
502
502
|
*/
|
|
503
503
|
async submitPassword(password) {
|
|
504
504
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
505
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, password);
|
|
505
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, { password });
|
|
506
506
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
507
507
|
});
|
|
508
508
|
}
|
|
@@ -696,7 +696,10 @@ export class SeedlessOnboardingController extends BaseController {
|
|
|
696
696
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
697
697
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
698
698
|
const { vaultEncryptionKey } = this.state;
|
|
699
|
-
const { toprfEncryptionKey: rawToprfEncryptionKey, toprfPwEncryptionKey: rawToprfPwEncryptionKey, toprfAuthKeyPair: rawToprfAuthKeyPair, revokeToken, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this,
|
|
699
|
+
const { toprfEncryptionKey: rawToprfEncryptionKey, toprfPwEncryptionKey: rawToprfPwEncryptionKey, toprfAuthKeyPair: rawToprfAuthKeyPair, revokeToken, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, {
|
|
700
|
+
password,
|
|
701
|
+
encryptionKey: vaultEncryptionKey,
|
|
702
|
+
});
|
|
700
703
|
if (!revokeToken) {
|
|
701
704
|
throw new Error(SeedlessOnboardingControllerErrorMessage.InvalidRevokeToken);
|
|
702
705
|
}
|
|
@@ -773,7 +776,7 @@ export class SeedlessOnboardingController extends BaseController {
|
|
|
773
776
|
}
|
|
774
777
|
}
|
|
775
778
|
}
|
|
776
|
-
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(),
|
|
779
|
+
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(), _SeedlessOnboardingController_passwordOutdatedCacheTTL = new WeakMap(), _SeedlessOnboardingController_isUnlocked = new WeakMap(), _SeedlessOnboardingController_instances = new WeakSet(), _SeedlessOnboardingController_submitGlobalPassword =
|
|
777
780
|
/**
|
|
778
781
|
* @description Submit the global password to the controller, verify the
|
|
779
782
|
* password validity and unlock the controller.
|
|
@@ -799,7 +802,9 @@ async function _SeedlessOnboardingController_submitGlobalPassword({ targetAuthPu
|
|
|
799
802
|
const { pwEncKey } = res;
|
|
800
803
|
const vaultKey = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_loadSeedlessEncryptionKey).call(this, pwEncKey);
|
|
801
804
|
// Unlock the controller
|
|
802
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this,
|
|
805
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, {
|
|
806
|
+
encryptionKey: vaultKey,
|
|
807
|
+
});
|
|
803
808
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
804
809
|
}
|
|
805
810
|
catch (error) {
|
|
@@ -831,8 +836,10 @@ async function _SeedlessOnboardingController_getAccessToken(password) {
|
|
|
831
836
|
if (!vault) {
|
|
832
837
|
throw new Error(SeedlessOnboardingControllerErrorMessage.InvalidAccessToken);
|
|
833
838
|
}
|
|
834
|
-
const {
|
|
835
|
-
|
|
839
|
+
const { vaultData } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_decryptAndParseVaultData).call(this, {
|
|
840
|
+
password,
|
|
841
|
+
});
|
|
842
|
+
return vaultData.accessToken;
|
|
836
843
|
}, _SeedlessOnboardingController_setUnlocked = function _SeedlessOnboardingController_setUnlocked() {
|
|
837
844
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_isUnlocked, true, "f");
|
|
838
845
|
}, _SeedlessOnboardingController_persistOprfKey =
|
|
@@ -997,7 +1004,7 @@ async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword,
|
|
|
997
1004
|
toprfEncryptionKey: encKey,
|
|
998
1005
|
toprfPwEncryptionKey: pwEncKey,
|
|
999
1006
|
toprfAuthKeyPair: authKeyPair,
|
|
1000
|
-
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, oldPassword));
|
|
1007
|
+
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, { password: oldPassword }));
|
|
1001
1008
|
}
|
|
1002
1009
|
const result = await this.toprfClient.changeEncKey({
|
|
1003
1010
|
nodeAuthTokens: this.state.nodeAuthTokens,
|
|
@@ -1066,8 +1073,9 @@ async function _SeedlessOnboardingController_encryptAndStoreSecretData(params) {
|
|
|
1066
1073
|
* Unlocks the encrypted vault using the provided password and returns the decrypted vault data.
|
|
1067
1074
|
* This method ensures thread-safety by using a mutex lock when accessing the vault.
|
|
1068
1075
|
*
|
|
1069
|
-
* @param
|
|
1070
|
-
* @param
|
|
1076
|
+
* @param params - The parameters for unlocking the vault.
|
|
1077
|
+
* @param params.password - The optional password to unlock the vault.
|
|
1078
|
+
* @param params.encryptionKey - The optional encryption key to unlock the vault.
|
|
1071
1079
|
* @returns A promise that resolves to an object containing:
|
|
1072
1080
|
* - toprfEncryptionKey: The decrypted TOPRF encryption key
|
|
1073
1081
|
* - toprfAuthKeyPair: The decrypted TOPRF authentication key pair
|
|
@@ -1079,54 +1087,38 @@ async function _SeedlessOnboardingController_encryptAndStoreSecretData(params) {
|
|
|
1079
1087
|
* - The password is incorrect (from encryptor.decrypt)
|
|
1080
1088
|
* - The decrypted vault data is malformed
|
|
1081
1089
|
*/
|
|
1082
|
-
async function _SeedlessOnboardingController_unlockVaultAndGetVaultData(
|
|
1090
|
+
async function _SeedlessOnboardingController_unlockVaultAndGetVaultData(params) {
|
|
1083
1091
|
return __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withVaultLock).call(this, async () => {
|
|
1084
|
-
const {
|
|
1085
|
-
const { toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair, revokeToken, accessToken, } = parsedVaultData;
|
|
1092
|
+
const { vaultData, vaultEncryptionKey, vaultEncryptionSalt } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_decryptAndParseVaultData).call(this, params);
|
|
1086
1093
|
this.update((state) => {
|
|
1087
1094
|
state.vaultEncryptionKey = vaultEncryptionKey;
|
|
1088
1095
|
state.vaultEncryptionSalt = vaultEncryptionSalt;
|
|
1089
|
-
state.revokeToken = revokeToken;
|
|
1090
|
-
state.accessToken = accessToken;
|
|
1096
|
+
state.revokeToken = vaultData.revokeToken;
|
|
1097
|
+
state.accessToken = vaultData.accessToken;
|
|
1091
1098
|
});
|
|
1092
|
-
return
|
|
1093
|
-
toprfEncryptionKey,
|
|
1094
|
-
toprfPwEncryptionKey,
|
|
1095
|
-
toprfAuthKeyPair,
|
|
1096
|
-
revokeToken,
|
|
1097
|
-
accessToken,
|
|
1098
|
-
};
|
|
1099
|
+
return deserializeVaultData(vaultData);
|
|
1099
1100
|
});
|
|
1100
1101
|
}, _SeedlessOnboardingController_decryptAndParseVaultData =
|
|
1101
1102
|
/**
|
|
1102
1103
|
* Decrypts the vault data and parses it into a usable format.
|
|
1103
1104
|
*
|
|
1104
|
-
* @param
|
|
1105
|
-
* @param
|
|
1105
|
+
* @param params - The parameters for decrypting the vault.
|
|
1106
|
+
* @param params.password - The optional password to decrypt the vault.
|
|
1107
|
+
* @param params.encryptionKey - The optional encryption key to decrypt the vault.
|
|
1106
1108
|
* @returns A promise that resolves to an object containing:
|
|
1107
1109
|
*/
|
|
1108
|
-
async function _SeedlessOnboardingController_decryptAndParseVaultData(
|
|
1110
|
+
async function _SeedlessOnboardingController_decryptAndParseVaultData(params) {
|
|
1109
1111
|
let { vaultEncryptionKey, vaultEncryptionSalt } = this.state;
|
|
1110
1112
|
const { vault: encryptedVault } = this.state;
|
|
1111
1113
|
if (!encryptedVault) {
|
|
1112
1114
|
throw new Error(SeedlessOnboardingControllerErrorMessage.VaultError);
|
|
1113
1115
|
}
|
|
1114
|
-
if (encryptionKey) {
|
|
1115
|
-
vaultEncryptionKey = encryptionKey;
|
|
1116
|
+
if (params?.encryptionKey) {
|
|
1117
|
+
vaultEncryptionKey = params.encryptionKey;
|
|
1116
1118
|
}
|
|
1117
1119
|
let decryptedVaultData;
|
|
1118
|
-
if
|
|
1119
|
-
|
|
1120
|
-
// Note that vault decryption using the password is a very costly operation as it involves deriving the encryption key
|
|
1121
|
-
// from the password using an intentionally slow key derivation function.
|
|
1122
|
-
// We should make sure that we only call it very intentionally.
|
|
1123
|
-
const result = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").decryptWithDetail(password, encryptedVault);
|
|
1124
|
-
decryptedVaultData = result.vault;
|
|
1125
|
-
vaultEncryptionKey = result.exportedKeyString;
|
|
1126
|
-
vaultEncryptionSalt = result.salt;
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
-
assertIsVaultEncryptionKeyDefined(vaultEncryptionKey);
|
|
1120
|
+
// if the encryption key is available, we will use it to decrypt the vault
|
|
1121
|
+
if (vaultEncryptionKey) {
|
|
1130
1122
|
const parsedEncryptedVault = JSON.parse(encryptedVault);
|
|
1131
1123
|
if (vaultEncryptionSalt &&
|
|
1132
1124
|
vaultEncryptionSalt !== parsedEncryptedVault.salt) {
|
|
@@ -1135,9 +1127,20 @@ async function _SeedlessOnboardingController_decryptAndParseVaultData(password,
|
|
|
1135
1127
|
const key = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").importKey(vaultEncryptionKey);
|
|
1136
1128
|
decryptedVaultData = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").decryptWithKey(key, parsedEncryptedVault);
|
|
1137
1129
|
}
|
|
1138
|
-
|
|
1130
|
+
else {
|
|
1131
|
+
// if the encryption key is not available, we will use the password to decrypt the vault
|
|
1132
|
+
assertIsValidPassword(params?.password);
|
|
1133
|
+
// Note that vault decryption using the password is a very costly operation as it involves deriving the encryption key
|
|
1134
|
+
// from the password using an intentionally slow key derivation function.
|
|
1135
|
+
// We should make sure that we only call it very intentionally.
|
|
1136
|
+
const result = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").decryptWithDetail(params.password, encryptedVault);
|
|
1137
|
+
decryptedVaultData = result.vault;
|
|
1138
|
+
vaultEncryptionKey = result.exportedKeyString;
|
|
1139
|
+
vaultEncryptionSalt = result.salt;
|
|
1140
|
+
}
|
|
1141
|
+
const vaultData = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_parseVaultData).call(this, decryptedVaultData);
|
|
1139
1142
|
return {
|
|
1140
|
-
|
|
1143
|
+
vaultData,
|
|
1141
1144
|
vaultEncryptionKey,
|
|
1142
1145
|
vaultEncryptionSalt,
|
|
1143
1146
|
};
|
|
@@ -1213,11 +1216,10 @@ async function _SeedlessOnboardingController_createNewVaultWithAuthData({ passwo
|
|
|
1213
1216
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
1214
1217
|
const { revokeToken } = this.state;
|
|
1215
1218
|
const accessToken = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_getAccessToken).call(this, password);
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
toprfEncryptionKey,
|
|
1219
|
-
toprfPwEncryptionKey,
|
|
1220
|
-
toprfAuthKeyPair,
|
|
1219
|
+
const serializedVaultData = serializeVaultData({
|
|
1220
|
+
toprfAuthKeyPair: rawToprfAuthKeyPair,
|
|
1221
|
+
toprfEncryptionKey: rawToprfEncryptionKey,
|
|
1222
|
+
toprfPwEncryptionKey: rawToprfPwEncryptionKey,
|
|
1221
1223
|
revokeToken,
|
|
1222
1224
|
accessToken,
|
|
1223
1225
|
});
|
|
@@ -1287,18 +1289,6 @@ async function _SeedlessOnboardingController_withControllerLock(callback) {
|
|
|
1287
1289
|
*/
|
|
1288
1290
|
async function _SeedlessOnboardingController_withVaultLock(callback) {
|
|
1289
1291
|
return await withLock(__classPrivateFieldGet(this, _SeedlessOnboardingController_vaultOperationMutex, "f"), callback);
|
|
1290
|
-
}, _SeedlessOnboardingController_serializeKeyData = function _SeedlessOnboardingController_serializeKeyData(encKey, pwEncKey, authKeyPair) {
|
|
1291
|
-
const b64EncodedEncKey = bytesToBase64(encKey);
|
|
1292
|
-
const b64EncodedPwEncKey = bytesToBase64(pwEncKey);
|
|
1293
|
-
const b64EncodedAuthKeyPair = JSON.stringify({
|
|
1294
|
-
sk: bigIntToHex(authKeyPair.sk),
|
|
1295
|
-
pk: bytesToBase64(authKeyPair.pk),
|
|
1296
|
-
});
|
|
1297
|
-
return {
|
|
1298
|
-
toprfEncryptionKey: b64EncodedEncKey,
|
|
1299
|
-
toprfPwEncryptionKey: b64EncodedPwEncKey,
|
|
1300
|
-
toprfAuthKeyPair: b64EncodedAuthKeyPair,
|
|
1301
|
-
};
|
|
1302
1292
|
}, _SeedlessOnboardingController_parseVaultData = function _SeedlessOnboardingController_parseVaultData(data) {
|
|
1303
1293
|
if (typeof data !== 'string') {
|
|
1304
1294
|
throw new Error(SeedlessOnboardingControllerErrorMessage.InvalidVaultData);
|
|
@@ -1311,20 +1301,7 @@ async function _SeedlessOnboardingController_withVaultLock(callback) {
|
|
|
1311
1301
|
throw new Error(SeedlessOnboardingControllerErrorMessage.InvalidVaultData);
|
|
1312
1302
|
}
|
|
1313
1303
|
assertIsValidVaultData(parsedVaultData);
|
|
1314
|
-
|
|
1315
|
-
const rawToprfPwEncryptionKey = base64ToBytes(parsedVaultData.toprfPwEncryptionKey);
|
|
1316
|
-
const parsedToprfAuthKeyPair = JSON.parse(parsedVaultData.toprfAuthKeyPair);
|
|
1317
|
-
const rawToprfAuthKeyPair = {
|
|
1318
|
-
sk: BigInt(parsedToprfAuthKeyPair.sk),
|
|
1319
|
-
pk: base64ToBytes(parsedToprfAuthKeyPair.pk),
|
|
1320
|
-
};
|
|
1321
|
-
return {
|
|
1322
|
-
toprfEncryptionKey: rawToprfEncryptionKey,
|
|
1323
|
-
toprfPwEncryptionKey: rawToprfPwEncryptionKey,
|
|
1324
|
-
toprfAuthKeyPair: rawToprfAuthKeyPair,
|
|
1325
|
-
revokeToken: parsedVaultData.revokeToken,
|
|
1326
|
-
accessToken: parsedVaultData.accessToken,
|
|
1327
|
-
};
|
|
1304
|
+
return parsedVaultData;
|
|
1328
1305
|
}, _SeedlessOnboardingController_assertIsUnlocked = function _SeedlessOnboardingController_assertIsUnlocked() {
|
|
1329
1306
|
if (!__classPrivateFieldGet(this, _SeedlessOnboardingController_isUnlocked, "f")) {
|
|
1330
1307
|
throw new Error(SeedlessOnboardingControllerErrorMessage.ControllerLocked);
|
|
@@ -1500,15 +1477,4 @@ function assertIsEncryptedSeedlessEncryptionKeySet(encryptedSeedlessEncryptionKe
|
|
|
1500
1477
|
throw new Error(SeedlessOnboardingControllerErrorMessage.EncryptedSeedlessEncryptionKeyNotSet);
|
|
1501
1478
|
}
|
|
1502
1479
|
}
|
|
1503
|
-
/**
|
|
1504
|
-
* Assert that the provided vault encryption key is a valid non-empty string.
|
|
1505
|
-
*
|
|
1506
|
-
* @param vaultEncryptionKey - The vault encryption key to check.
|
|
1507
|
-
* @throws If the vault encryption key is not a valid string.
|
|
1508
|
-
*/
|
|
1509
|
-
function assertIsVaultEncryptionKeyDefined(vaultEncryptionKey) {
|
|
1510
|
-
if (!vaultEncryptionKey) {
|
|
1511
|
-
throw new Error(SeedlessOnboardingControllerErrorMessage.VaultEncryptionKeyUndefined);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
1480
|
//# sourceMappingURL=SeedlessOnboardingController.mjs.map
|