@metamask-previews/seedless-onboarding-controller 3.0.0-preview-3f792d6 → 3.0.0-preview-6a91767a
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 +87 -53
- 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 +89 -55
- package/dist/SeedlessOnboardingController.mjs.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +1 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +1 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -0
- 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 +8 -9
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +8 -9
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs +1 -66
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -30
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +1 -30
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +1 -62
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken,
|
|
13
|
+
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken, _SeedlessOnboardingController_isUnlocked, _SeedlessOnboardingController_passwordOutdatedCacheTTL, _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_serializeKeyData, _SeedlessOnboardingController_parseVaultData, _SeedlessOnboardingController_assertIsUnlocked, _SeedlessOnboardingController_assertIsAuthenticatedUser, _SeedlessOnboardingController_assertIsSRPBackedUpUser, _SeedlessOnboardingController_assertPasswordInSync, _SeedlessOnboardingController_resetPasswordOutdatedCache, _SeedlessOnboardingController_isTokenExpiredError, _SeedlessOnboardingController_isMaxKeyChainLengthError, _SeedlessOnboardingController_executeWithTokenRefresh;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SeedlessOnboardingController = exports.getInitialSeedlessOnboardingControllerStateWithDefaults = void 0;
|
|
16
16
|
const auth_network_utils_1 = require("@metamask/auth-network-utils");
|
|
@@ -167,16 +167,16 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
167
167
|
_SeedlessOnboardingController_vaultOperationMutex.set(this, new async_mutex_1.Mutex());
|
|
168
168
|
_SeedlessOnboardingController_refreshJWTToken.set(this, void 0);
|
|
169
169
|
_SeedlessOnboardingController_revokeRefreshToken.set(this, void 0);
|
|
170
|
-
/**
|
|
171
|
-
* The TTL of the password outdated cache in milliseconds.
|
|
172
|
-
*/
|
|
173
|
-
_SeedlessOnboardingController_passwordOutdatedCacheTTL.set(this, void 0);
|
|
174
170
|
/**
|
|
175
171
|
* Controller lock state.
|
|
176
172
|
*
|
|
177
173
|
* The controller lock is synchronized with the keyring lock.
|
|
178
174
|
*/
|
|
179
175
|
_SeedlessOnboardingController_isUnlocked.set(this, false);
|
|
176
|
+
/**
|
|
177
|
+
* The TTL of the password outdated cache in milliseconds.
|
|
178
|
+
*/
|
|
179
|
+
_SeedlessOnboardingController_passwordOutdatedCacheTTL.set(this, void 0);
|
|
180
180
|
(0, assertions_1.assertIsPasswordOutdatedCacheValid)(passwordOutdatedCacheTTL);
|
|
181
181
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_passwordOutdatedCacheTTL, passwordOutdatedCacheTTL, "f");
|
|
182
182
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_vaultEncryptor, encryptor, "f");
|
|
@@ -506,7 +506,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
506
506
|
*/
|
|
507
507
|
async submitPassword(password) {
|
|
508
508
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
509
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this,
|
|
509
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, password);
|
|
510
510
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
511
511
|
});
|
|
512
512
|
}
|
|
@@ -700,10 +700,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
700
700
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
701
701
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
702
702
|
const { vaultEncryptionKey } = this.state;
|
|
703
|
-
const { toprfEncryptionKey: rawToprfEncryptionKey, toprfPwEncryptionKey: rawToprfPwEncryptionKey, toprfAuthKeyPair: rawToprfAuthKeyPair, revokeToken, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this,
|
|
704
|
-
password,
|
|
705
|
-
encryptionKey: vaultEncryptionKey,
|
|
706
|
-
});
|
|
703
|
+
const { toprfEncryptionKey: rawToprfEncryptionKey, toprfPwEncryptionKey: rawToprfPwEncryptionKey, toprfAuthKeyPair: rawToprfAuthKeyPair, revokeToken, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, password, vaultEncryptionKey);
|
|
707
704
|
if (!revokeToken) {
|
|
708
705
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.InvalidRevokeToken);
|
|
709
706
|
}
|
|
@@ -781,7 +778,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
781
778
|
}
|
|
782
779
|
}
|
|
783
780
|
exports.SeedlessOnboardingController = SeedlessOnboardingController;
|
|
784
|
-
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(),
|
|
781
|
+
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(), _SeedlessOnboardingController_isUnlocked = new WeakMap(), _SeedlessOnboardingController_passwordOutdatedCacheTTL = new WeakMap(), _SeedlessOnboardingController_instances = new WeakSet(), _SeedlessOnboardingController_submitGlobalPassword =
|
|
785
782
|
/**
|
|
786
783
|
* @description Submit the global password to the controller, verify the
|
|
787
784
|
* password validity and unlock the controller.
|
|
@@ -807,9 +804,7 @@ async function _SeedlessOnboardingController_submitGlobalPassword({ targetAuthPu
|
|
|
807
804
|
const { pwEncKey } = res;
|
|
808
805
|
const vaultKey = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_loadSeedlessEncryptionKey).call(this, pwEncKey);
|
|
809
806
|
// Unlock the controller
|
|
810
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this,
|
|
811
|
-
encryptionKey: vaultKey,
|
|
812
|
-
});
|
|
807
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, undefined, vaultKey);
|
|
813
808
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
814
809
|
}
|
|
815
810
|
catch (error) {
|
|
@@ -841,10 +836,8 @@ async function _SeedlessOnboardingController_getAccessToken(password) {
|
|
|
841
836
|
if (!vault) {
|
|
842
837
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.InvalidAccessToken);
|
|
843
838
|
}
|
|
844
|
-
const {
|
|
845
|
-
|
|
846
|
-
});
|
|
847
|
-
return vaultData.accessToken;
|
|
839
|
+
const { parsedVaultData } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_decryptAndParseVaultData).call(this, password);
|
|
840
|
+
return parsedVaultData.accessToken;
|
|
848
841
|
}, _SeedlessOnboardingController_setUnlocked = function _SeedlessOnboardingController_setUnlocked() {
|
|
849
842
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_isUnlocked, true, "f");
|
|
850
843
|
}, _SeedlessOnboardingController_persistOprfKey =
|
|
@@ -1009,7 +1002,7 @@ async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword,
|
|
|
1009
1002
|
toprfEncryptionKey: encKey,
|
|
1010
1003
|
toprfPwEncryptionKey: pwEncKey,
|
|
1011
1004
|
toprfAuthKeyPair: authKeyPair,
|
|
1012
|
-
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this,
|
|
1005
|
+
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, oldPassword));
|
|
1013
1006
|
}
|
|
1014
1007
|
const result = await this.toprfClient.changeEncKey({
|
|
1015
1008
|
nodeAuthTokens: this.state.nodeAuthTokens,
|
|
@@ -1078,9 +1071,8 @@ async function _SeedlessOnboardingController_encryptAndStoreSecretData(params) {
|
|
|
1078
1071
|
* Unlocks the encrypted vault using the provided password and returns the decrypted vault data.
|
|
1079
1072
|
* This method ensures thread-safety by using a mutex lock when accessing the vault.
|
|
1080
1073
|
*
|
|
1081
|
-
* @param
|
|
1082
|
-
* @param
|
|
1083
|
-
* @param params.encryptionKey - The optional encryption key to unlock the vault.
|
|
1074
|
+
* @param password - The optional password to unlock the vault.
|
|
1075
|
+
* @param encryptionKey - The optional encryption key to unlock the vault.
|
|
1084
1076
|
* @returns A promise that resolves to an object containing:
|
|
1085
1077
|
* - toprfEncryptionKey: The decrypted TOPRF encryption key
|
|
1086
1078
|
* - toprfAuthKeyPair: The decrypted TOPRF authentication key pair
|
|
@@ -1092,38 +1084,54 @@ async function _SeedlessOnboardingController_encryptAndStoreSecretData(params) {
|
|
|
1092
1084
|
* - The password is incorrect (from encryptor.decrypt)
|
|
1093
1085
|
* - The decrypted vault data is malformed
|
|
1094
1086
|
*/
|
|
1095
|
-
async function _SeedlessOnboardingController_unlockVaultAndGetVaultData(
|
|
1087
|
+
async function _SeedlessOnboardingController_unlockVaultAndGetVaultData(password, encryptionKey) {
|
|
1096
1088
|
return __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withVaultLock).call(this, async () => {
|
|
1097
|
-
const {
|
|
1089
|
+
const { parsedVaultData, vaultEncryptionKey, vaultEncryptionSalt } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_decryptAndParseVaultData).call(this, password, encryptionKey);
|
|
1090
|
+
const { toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair, revokeToken, accessToken, } = parsedVaultData;
|
|
1098
1091
|
this.update((state) => {
|
|
1099
1092
|
state.vaultEncryptionKey = vaultEncryptionKey;
|
|
1100
1093
|
state.vaultEncryptionSalt = vaultEncryptionSalt;
|
|
1101
|
-
state.revokeToken =
|
|
1102
|
-
state.accessToken =
|
|
1094
|
+
state.revokeToken = revokeToken;
|
|
1095
|
+
state.accessToken = accessToken;
|
|
1103
1096
|
});
|
|
1104
|
-
return
|
|
1097
|
+
return {
|
|
1098
|
+
toprfEncryptionKey,
|
|
1099
|
+
toprfPwEncryptionKey,
|
|
1100
|
+
toprfAuthKeyPair,
|
|
1101
|
+
revokeToken,
|
|
1102
|
+
accessToken,
|
|
1103
|
+
};
|
|
1105
1104
|
});
|
|
1106
1105
|
}, _SeedlessOnboardingController_decryptAndParseVaultData =
|
|
1107
1106
|
/**
|
|
1108
1107
|
* Decrypts the vault data and parses it into a usable format.
|
|
1109
1108
|
*
|
|
1110
|
-
* @param
|
|
1111
|
-
* @param
|
|
1112
|
-
* @param params.encryptionKey - The optional encryption key to decrypt the vault.
|
|
1109
|
+
* @param password - The optional password to decrypt the vault.
|
|
1110
|
+
* @param encryptionKey - The optional encryption key to decrypt the vault.
|
|
1113
1111
|
* @returns A promise that resolves to an object containing:
|
|
1114
1112
|
*/
|
|
1115
|
-
async function _SeedlessOnboardingController_decryptAndParseVaultData(
|
|
1113
|
+
async function _SeedlessOnboardingController_decryptAndParseVaultData(password, encryptionKey) {
|
|
1116
1114
|
let { vaultEncryptionKey, vaultEncryptionSalt } = this.state;
|
|
1117
1115
|
const { vault: encryptedVault } = this.state;
|
|
1118
1116
|
if (!encryptedVault) {
|
|
1119
1117
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.VaultError);
|
|
1120
1118
|
}
|
|
1121
|
-
if (
|
|
1122
|
-
vaultEncryptionKey =
|
|
1119
|
+
if (encryptionKey) {
|
|
1120
|
+
vaultEncryptionKey = encryptionKey;
|
|
1123
1121
|
}
|
|
1124
1122
|
let decryptedVaultData;
|
|
1125
|
-
|
|
1126
|
-
|
|
1123
|
+
if (password) {
|
|
1124
|
+
assertIsValidPassword(password);
|
|
1125
|
+
// Note that vault decryption using the password is a very costly operation as it involves deriving the encryption key
|
|
1126
|
+
// from the password using an intentionally slow key derivation function.
|
|
1127
|
+
// We should make sure that we only call it very intentionally.
|
|
1128
|
+
const result = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").decryptWithDetail(password, encryptedVault);
|
|
1129
|
+
decryptedVaultData = result.vault;
|
|
1130
|
+
vaultEncryptionKey = result.exportedKeyString;
|
|
1131
|
+
vaultEncryptionSalt = result.salt;
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
assertIsVaultEncryptionKeyDefined(vaultEncryptionKey);
|
|
1127
1135
|
const parsedEncryptedVault = JSON.parse(encryptedVault);
|
|
1128
1136
|
if (vaultEncryptionSalt &&
|
|
1129
1137
|
vaultEncryptionSalt !== parsedEncryptedVault.salt) {
|
|
@@ -1132,20 +1140,9 @@ async function _SeedlessOnboardingController_decryptAndParseVaultData(params) {
|
|
|
1132
1140
|
const key = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").importKey(vaultEncryptionKey);
|
|
1133
1141
|
decryptedVaultData = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").decryptWithKey(key, parsedEncryptedVault);
|
|
1134
1142
|
}
|
|
1135
|
-
|
|
1136
|
-
// if the encryption key is not available, we will use the password to decrypt the vault
|
|
1137
|
-
assertIsValidPassword(params?.password);
|
|
1138
|
-
// Note that vault decryption using the password is a very costly operation as it involves deriving the encryption key
|
|
1139
|
-
// from the password using an intentionally slow key derivation function.
|
|
1140
|
-
// We should make sure that we only call it very intentionally.
|
|
1141
|
-
const result = await __classPrivateFieldGet(this, _SeedlessOnboardingController_vaultEncryptor, "f").decryptWithDetail(params.password, encryptedVault);
|
|
1142
|
-
decryptedVaultData = result.vault;
|
|
1143
|
-
vaultEncryptionKey = result.exportedKeyString;
|
|
1144
|
-
vaultEncryptionSalt = result.salt;
|
|
1145
|
-
}
|
|
1146
|
-
const vaultData = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_parseVaultData).call(this, decryptedVaultData);
|
|
1143
|
+
const parsedVaultData = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_parseVaultData).call(this, decryptedVaultData);
|
|
1147
1144
|
return {
|
|
1148
|
-
|
|
1145
|
+
parsedVaultData,
|
|
1149
1146
|
vaultEncryptionKey,
|
|
1150
1147
|
vaultEncryptionSalt,
|
|
1151
1148
|
};
|
|
@@ -1221,10 +1218,11 @@ async function _SeedlessOnboardingController_createNewVaultWithAuthData({ passwo
|
|
|
1221
1218
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
1222
1219
|
const { revokeToken } = this.state;
|
|
1223
1220
|
const accessToken = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_getAccessToken).call(this, password);
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1226
|
-
toprfEncryptionKey
|
|
1227
|
-
toprfPwEncryptionKey
|
|
1221
|
+
const { toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair } = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_serializeKeyData).call(this, rawToprfEncryptionKey, rawToprfPwEncryptionKey, rawToprfAuthKeyPair);
|
|
1222
|
+
const serializedVaultData = JSON.stringify({
|
|
1223
|
+
toprfEncryptionKey,
|
|
1224
|
+
toprfPwEncryptionKey,
|
|
1225
|
+
toprfAuthKeyPair,
|
|
1228
1226
|
revokeToken,
|
|
1229
1227
|
accessToken,
|
|
1230
1228
|
});
|
|
@@ -1294,6 +1292,18 @@ async function _SeedlessOnboardingController_withControllerLock(callback) {
|
|
|
1294
1292
|
*/
|
|
1295
1293
|
async function _SeedlessOnboardingController_withVaultLock(callback) {
|
|
1296
1294
|
return await withLock(__classPrivateFieldGet(this, _SeedlessOnboardingController_vaultOperationMutex, "f"), callback);
|
|
1295
|
+
}, _SeedlessOnboardingController_serializeKeyData = function _SeedlessOnboardingController_serializeKeyData(encKey, pwEncKey, authKeyPair) {
|
|
1296
|
+
const b64EncodedEncKey = (0, utils_1.bytesToBase64)(encKey);
|
|
1297
|
+
const b64EncodedPwEncKey = (0, utils_1.bytesToBase64)(pwEncKey);
|
|
1298
|
+
const b64EncodedAuthKeyPair = JSON.stringify({
|
|
1299
|
+
sk: (0, utils_1.bigIntToHex)(authKeyPair.sk),
|
|
1300
|
+
pk: (0, utils_1.bytesToBase64)(authKeyPair.pk),
|
|
1301
|
+
});
|
|
1302
|
+
return {
|
|
1303
|
+
toprfEncryptionKey: b64EncodedEncKey,
|
|
1304
|
+
toprfPwEncryptionKey: b64EncodedPwEncKey,
|
|
1305
|
+
toprfAuthKeyPair: b64EncodedAuthKeyPair,
|
|
1306
|
+
};
|
|
1297
1307
|
}, _SeedlessOnboardingController_parseVaultData = function _SeedlessOnboardingController_parseVaultData(data) {
|
|
1298
1308
|
if (typeof data !== 'string') {
|
|
1299
1309
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.InvalidVaultData);
|
|
@@ -1306,7 +1316,20 @@ async function _SeedlessOnboardingController_withVaultLock(callback) {
|
|
|
1306
1316
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.InvalidVaultData);
|
|
1307
1317
|
}
|
|
1308
1318
|
(0, assertions_1.assertIsValidVaultData)(parsedVaultData);
|
|
1309
|
-
|
|
1319
|
+
const rawToprfEncryptionKey = (0, utils_1.base64ToBytes)(parsedVaultData.toprfEncryptionKey);
|
|
1320
|
+
const rawToprfPwEncryptionKey = (0, utils_1.base64ToBytes)(parsedVaultData.toprfPwEncryptionKey);
|
|
1321
|
+
const parsedToprfAuthKeyPair = JSON.parse(parsedVaultData.toprfAuthKeyPair);
|
|
1322
|
+
const rawToprfAuthKeyPair = {
|
|
1323
|
+
sk: BigInt(parsedToprfAuthKeyPair.sk),
|
|
1324
|
+
pk: (0, utils_1.base64ToBytes)(parsedToprfAuthKeyPair.pk),
|
|
1325
|
+
};
|
|
1326
|
+
return {
|
|
1327
|
+
toprfEncryptionKey: rawToprfEncryptionKey,
|
|
1328
|
+
toprfPwEncryptionKey: rawToprfPwEncryptionKey,
|
|
1329
|
+
toprfAuthKeyPair: rawToprfAuthKeyPair,
|
|
1330
|
+
revokeToken: parsedVaultData.revokeToken,
|
|
1331
|
+
accessToken: parsedVaultData.accessToken,
|
|
1332
|
+
};
|
|
1310
1333
|
}, _SeedlessOnboardingController_assertIsUnlocked = function _SeedlessOnboardingController_assertIsUnlocked() {
|
|
1311
1334
|
if (!__classPrivateFieldGet(this, _SeedlessOnboardingController_isUnlocked, "f")) {
|
|
1312
1335
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.ControllerLocked);
|
|
@@ -1482,4 +1505,15 @@ function assertIsEncryptedSeedlessEncryptionKeySet(encryptedSeedlessEncryptionKe
|
|
|
1482
1505
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.EncryptedSeedlessEncryptionKeyNotSet);
|
|
1483
1506
|
}
|
|
1484
1507
|
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Assert that the provided vault encryption key is a valid non-empty string.
|
|
1510
|
+
*
|
|
1511
|
+
* @param vaultEncryptionKey - The vault encryption key to check.
|
|
1512
|
+
* @throws If the vault encryption key is not a valid string.
|
|
1513
|
+
*/
|
|
1514
|
+
function assertIsVaultEncryptionKeyDefined(vaultEncryptionKey) {
|
|
1515
|
+
if (!vaultEncryptionKey) {
|
|
1516
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.VaultEncryptionKeyUndefined);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1485
1519
|
//# sourceMappingURL=SeedlessOnboardingController.cjs.map
|