1 | import { hexToU8a, isHex } from '@polkadot/util';
|
2 | import { base64Decode } from '../base64/index.js';
|
3 | import { jsonDecryptData } from './decryptData.js';
|
4 | export 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 | }
|