Base64 without Buffer (#891)
This commit is contained in:
@@ -21,13 +21,13 @@
|
||||
"@polkadot/wasm-crypto": "^3.2.4",
|
||||
"@polkadot/x-randomvalues": "5.7.2-5",
|
||||
"base-x": "^3.0.8",
|
||||
"base64-js": "^1.5.1",
|
||||
"blakejs": "^1.1.0",
|
||||
"bn.js": "^4.11.9",
|
||||
"create-hash": "^1.2.0",
|
||||
"elliptic": "^6.5.4",
|
||||
"hash.js": "^1.1.7",
|
||||
"js-sha3": "^0.8.0",
|
||||
"safe-buffer": "^5.2.1",
|
||||
"scryptsy": "^2.1.0",
|
||||
"tweetnacl": "^1.0.3",
|
||||
"xxhashjs": "^0.2.2"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { bufferToU8a } from '@polkadot/util';
|
||||
import base64 from 'base64-js';
|
||||
|
||||
import { base64Validate } from './validate';
|
||||
|
||||
@@ -14,5 +14,5 @@ import { base64Validate } from './validate';
|
||||
export function base64Decode (value: string): Uint8Array {
|
||||
base64Validate(value);
|
||||
|
||||
return bufferToU8a(Buffer.from(value, 'base64'));
|
||||
return base64.toByteArray(value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { u8aToBuffer, u8aToU8a } from '@polkadot/util';
|
||||
import base64 from 'base64-js';
|
||||
|
||||
import { u8aToU8a } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* @name base64Encode
|
||||
@@ -10,5 +12,5 @@ import { u8aToBuffer, u8aToU8a } from '@polkadot/util';
|
||||
* From the provided input, create the base64 and return the result as a string.
|
||||
*/
|
||||
export function base64Encode (value: Uint8Array | string | Buffer | number[]): string {
|
||||
return u8aToBuffer(u8aToU8a(value)).toString('base64');
|
||||
return base64.fromByteArray(u8aToU8a(value));
|
||||
}
|
||||
|
||||
@@ -2013,13 +2013,13 @@ __metadata:
|
||||
"@types/scryptsy": ^2.0.0
|
||||
"@types/xxhashjs": ^0.2.2
|
||||
base-x: ^3.0.8
|
||||
base64-js: ^1.5.1
|
||||
blakejs: ^1.1.0
|
||||
bn.js: ^4.11.9
|
||||
create-hash: ^1.2.0
|
||||
elliptic: ^6.5.4
|
||||
hash.js: ^1.1.7
|
||||
js-sha3: ^0.8.0
|
||||
safe-buffer: ^5.2.1
|
||||
scryptsy: ^2.1.0
|
||||
tweetnacl: ^1.0.3
|
||||
xxhashjs: ^0.2.2
|
||||
@@ -3215,7 +3215,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"base64-js@npm:^1.3.1":
|
||||
"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1":
|
||||
version: 1.5.1
|
||||
resolution: "base64-js@npm:1.5.1"
|
||||
checksum: c1b41a26ddc6620eb7f1ee6c29c812f5942a4e328e74263f995872cfb8ca3aee08542beb25cd10fd7ef16e4f16603e25c35a26e776c01fd55277e5035e829e0e
|
||||
@@ -9589,7 +9589,7 @@ fsevents@~2.1.2:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.2, safe-buffer@npm:^5.2.0, safe-buffer@npm:^5.2.1, safe-buffer@npm:~5.2.0":
|
||||
"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.2, safe-buffer@npm:^5.2.0, safe-buffer@npm:~5.2.0":
|
||||
version: 5.2.1
|
||||
resolution: "safe-buffer@npm:5.2.1"
|
||||
checksum: 0bb57f0d8f9d1fa4fe35ad8a2db1f83a027d48f2822d59ede88fd5cd4ddad83c0b497213feb7a70fbf90597a70c5217f735b0eb1850df40ce9b4ae81dd22b3f9
|
||||
|
||||
Reference in New Issue
Block a user