SHA256
Обновление архитектуры ключей и кошельков
This commit is contained in:
@@ -73,15 +73,15 @@ function normalizeKeys(keys = {}) {
|
||||
return {
|
||||
clientKey: String(keys?.clientKey || '').trim(),
|
||||
blockchainKey: String(keys?.blockchainKey || '').trim(),
|
||||
rootKey: String(keys?.rootKey || '').trim(),
|
||||
};
|
||||
}
|
||||
|
||||
export function detectPairingPayloadType(keys = {}) {
|
||||
const normalized = normalizeKeys(keys);
|
||||
if (normalized.rootKey) return 3;
|
||||
if (normalized.blockchainKey) return 2;
|
||||
return 1;
|
||||
if (!normalized.clientKey || !normalized.blockchainKey) {
|
||||
throw new Error('Для подключения устройства нужны ключ доступа и ключ блокчейна');
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
export async function deriveEspPairingPasswordHash(login, password) {
|
||||
@@ -159,13 +159,14 @@ export async function decryptPairingPayloadFromEnvelope(encryptedPayload, reques
|
||||
}
|
||||
|
||||
export function buildSecretsPayload({ login, keys, mode }) {
|
||||
const normalizedKeys = normalizeKeys(keys);
|
||||
return {
|
||||
v: 1,
|
||||
type: 'shine-esp-pairing-transfer',
|
||||
login: String(login || '').trim(),
|
||||
mode: String(mode || 'device-only').trim() || 'device-only',
|
||||
keys: normalizeKeys(keys),
|
||||
payloadType: detectPairingPayloadType(keys),
|
||||
mode: String(mode || 'full-device').trim() || 'full-device',
|
||||
keys: normalizedKeys,
|
||||
payloadType: detectPairingPayloadType(normalizedKeys),
|
||||
createdAtMs: Date.now(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user