@@ -2299,92 +2299,6 @@ export class KeyringController extends BaseController<
22992299 return { keyrings, newMetadata } ;
23002300 }
23012301
2302- // async #unlockKeyrings(
2303- // password: string | undefined,
2304- // encryptionKey?: string,
2305- // encryptionSalt?: string,
2306- // ): Promise<{
2307- // keyrings: { keyring: EthKeyring; metadata: KeyringMetadata }[];
2308- // newMetadata: boolean;
2309- // }> {
2310- // return this.#withVaultLock(async () => {
2311- // const encryptedVault = this.state.vault;
2312- // if (!encryptedVault) {
2313- // throw new Error(KeyringControllerError.VaultError);
2314- // }
2315- //
2316- // let vault;
2317- // const updatedState: Partial<KeyringControllerState> = {};
2318- //
2319- // if (this.#cacheEncryptionKey) {
2320- // assertIsExportableKeyEncryptor(this.#encryptor);
2321- //
2322- // if (password) {
2323- // const result = await this.#encryptor.decryptWithDetail(
2324- // password,
2325- // encryptedVault,
2326- // );
2327- // vault = result.vault;
2328- // this.#password = password;
2329- //
2330- // updatedState.encryptionKey = result.exportedKeyString;
2331- // updatedState.encryptionSalt = result.salt;
2332- // } else {
2333- // const parsedEncryptedVault = JSON.parse(encryptedVault);
2334- //
2335- // if (encryptionSalt !== parsedEncryptedVault.salt) {
2336- // throw new Error(KeyringControllerError.ExpiredCredentials);
2337- // }
2338- //
2339- // if (typeof encryptionKey !== 'string') {
2340- // throw new TypeError(KeyringControllerError.WrongPasswordType);
2341- // }
2342- //
2343- // const key = await this.#encryptor.importKey(encryptionKey);
2344- // vault = await this.#encryptor.decryptWithKey(
2345- // key,
2346- // parsedEncryptedVault,
2347- // );
2348- //
2349- // // This call is required on the first call because encryptionKey
2350- // // is not yet inside the memStore
2351- // updatedState.encryptionKey = encryptionKey;
2352- // // we can safely assume that encryptionSalt is defined here
2353- // // because we compare it with the salt from the vault
2354- // // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2355- // updatedState.encryptionSalt = encryptionSalt!;
2356- // }
2357- // } else {
2358- // if (typeof password !== 'string') {
2359- // throw new TypeError(KeyringControllerError.WrongPasswordType);
2360- // }
2361- //
2362- // vault = await this.#encryptor.decrypt(password, encryptedVault);
2363- // this.#password = password;
2364- // }
2365- //
2366- // if (!isSerializedKeyringsArray(vault)) {
2367- // throw new Error(KeyringControllerError.VaultDataError);
2368- // }
2369- //
2370- // const { keyrings, newMetadata } =
2371- // await this.#restoreSerializedKeyrings(vault);
2372- //
2373- // const updatedKeyrings = await this.#getUpdatedKeyrings();
2374- //
2375- // this.update((state) => {
2376- // state.keyrings = updatedKeyrings;
2377- // if (updatedState.encryptionKey || updatedState.encryptionSalt) {
2378- // state.encryptionKey = updatedState.encryptionKey;
2379- // state.encryptionSalt = updatedState.encryptionSalt;
2380- // }
2381- // });
2382- //
2383- // return { keyrings, newMetadata };
2384- // });
2385- // }
2386- //
2387-
23882302 /**
23892303 * Unlock Keyrings, decrypting the vault and deserializing all
23902304 * keyrings contained in it, using a password or an encryption key with salt.
0 commit comments