UNPKG

508 BJavaScriptView Raw
1import { hexToU8a, isHex } from '@polkadot/util';
2import { base64Decode } from '../base64/index.js';
3import { jsonDecryptData } from './decryptData.js';
4export function jsonDecrypt({ encoded, encoding }, passphrase) {
5 if (!encoded) {
6 throw new Error('No encrypted data available to decode');
7 }
8 return jsonDecryptData(isHex(encoded)
9 ? hexToU8a(encoded)
10 : base64Decode(encoded), passphrase, Array.isArray(encoding.type)
11 ? encoding.type
12 : [encoding.type]);
13}