Commit 013fcf74 authored by Moul's avatar Moul

[fix] Correct deprecations warnings raised into Nodejs v10

https://stackoverflow.com/questions/52165333/deprecationwarning-buffer-is-deprecated-due-to-security-and-usability-issues
- Consider Uint8Array as a string type
parent 68d9af9c
Pipeline #6183 waiting for manual action with stages
in 37 minutes and 34 seconds
......@@ -72,8 +72,8 @@ export function randomKey() {
}
const keypair = nacl.sign.keyPair.fromSeed(byteseed)
return new Key(
Base58encode(new Buffer(keypair.publicKey)),
Base58encode(new Buffer(keypair.secretKey))
Base58encode(Buffer.from(keypair.publicKey)),
Base58encode(Buffer.from(keypair.secretKey))
)
}
......
......@@ -28,7 +28,7 @@ export const encodeUTF8 = function(arr:any[]) {
export const encodeBase64 = function(arr:Uint8Array) {
if (typeof btoa === 'undefined' || !window) {
return (new Buffer(arr)).toString('base64');
return (Buffer.from(arr)).toString('base64');
} else {
let i, s = [], len = arr.length;
for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
......@@ -38,10 +38,10 @@ export const encodeBase64 = function(arr:Uint8Array) {
export const decodeBase64 = function(s:string) {
if (typeof atob === 'undefined' || !window) {
return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
} else {
let i, d = atob(s), b = new Uint8Array(d.length);
for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
return b;
}
}
\ No newline at end of file
}
......@@ -32,8 +32,8 @@ export const Scrypt = async (salt:string, key:string, N = 4096, r = 16, p = 1) =
const keyBytes = await getScryptKey(key, salt, N, r, p)
const pair = nacl.sign.keyPair.fromSeed(keyBytes);
return {
pub: Base58encode(new Buffer(pair.publicKey, 'hex')),
sec: Base58encode(new Buffer(pair.secretKey, 'hex'))
pub: Base58encode(Buffer.from(pair.publicKey, 'hex')),
sec: Base58encode(Buffer.from(pair.secretKey, 'hex'))
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment