SHA256
Миграция PDA на client.key
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { loadEncryptedUserSecrets, updateEncryptedUserSecrets } from './key-vault.js';
|
||||
import { extractDeviceKey32FromStoredValue } from './device-key-utils.js';
|
||||
import { deriveArweaveWalletFromDeviceKey32 } from './sawd-v1.js';
|
||||
import { extractClientKey32FromStoredValue } from './client-key-utils.js';
|
||||
import { deriveArweaveWalletFromClientKey32 } from './sawd-v1.js';
|
||||
|
||||
const DEFAULT_ARWEAVE_GATEWAY = 'https://arweave.net';
|
||||
const AR_TOPUP_URL = 'https://changenow.io/exchange?from=usd&to=ar&amount=10&fiatMode=true';
|
||||
@@ -102,11 +102,11 @@ function safeStatus(onStatus, text) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getArweaveWalletFromStoredDeviceKey({ login, storagePwd, onStatus } = {}) {
|
||||
export async function getArweaveWalletFromStoredClientKey({ login, storagePwd, onStatus } = {}) {
|
||||
const cleanLogin = String(login || '').trim();
|
||||
const cleanPwd = String(storagePwd || '').trim();
|
||||
if (!cleanLogin || !cleanPwd) {
|
||||
throw new Error('Нет активной сессии для доступа к wallet.key');
|
||||
throw new Error('Нет активной сессии для доступа к client.key');
|
||||
}
|
||||
|
||||
const secrets = await loadEncryptedUserSecrets(cleanLogin, cleanPwd);
|
||||
@@ -116,19 +116,19 @@ export async function getArweaveWalletFromStoredDeviceKey({ login, storagePwd, o
|
||||
return cached;
|
||||
}
|
||||
|
||||
safeStatus(onStatus, 'Сейчас мы впервые получаем Arweave-кошелёк из вашего device key. Это может занять немного времени.');
|
||||
safeStatus(onStatus, 'Сейчас мы впервые получаем Arweave-кошелёк из вашего client key. Это может занять немного времени.');
|
||||
|
||||
const storedDeviceKey = String(secrets?.deviceKey || '').trim();
|
||||
if (!storedDeviceKey) {
|
||||
throw new Error('На устройстве не найден device.key (wallet.key)');
|
||||
const storedClientKey = String(secrets?.clientKey || '').trim();
|
||||
if (!storedClientKey) {
|
||||
throw new Error('На устройстве не найден client.key');
|
||||
}
|
||||
|
||||
const deviceKey32 = extractDeviceKey32FromStoredValue(storedDeviceKey);
|
||||
const clientKey32 = extractClientKey32FromStoredValue(storedClientKey);
|
||||
let wallet;
|
||||
try {
|
||||
wallet = await deriveArweaveWalletFromDeviceKey32(deviceKey32);
|
||||
wallet = await deriveArweaveWalletFromClientKey32(clientKey32);
|
||||
} finally {
|
||||
deviceKey32.fill(0);
|
||||
clientKey32.fill(0);
|
||||
}
|
||||
|
||||
const cachedWallet = {
|
||||
|
||||
Reference in New Issue
Block a user