@iov/crypto
Advanced tools
Comparing version 0.14.4 to 0.14.5
@@ -32,3 +32,3 @@ "use strict"; | ||
static decode(mnemonic) { | ||
return encoding_1.Encoding.fromHex(bip39.mnemonicToEntropy(mnemonic.asString())); | ||
return encoding_1.Encoding.fromHex(bip39.mnemonicToEntropy(mnemonic.toString())); | ||
} | ||
@@ -39,3 +39,3 @@ static mnemonicToSeed(mnemonic, password) { | ||
// interface of https://www.npmjs.com/package/pbkdf2 | ||
const mnemonicBytes = Buffer.from(unorm.nfkd(mnemonic.asString()), "utf8"); | ||
const mnemonicBytes = Buffer.from(unorm.nfkd(mnemonic.toString()), "utf8"); | ||
const salt = "mnemonic" + (password ? unorm.nfkd(password) : ""); | ||
@@ -42,0 +42,0 @@ const saltBytes = Buffer.from(salt, "utf8"); |
@@ -27,3 +27,3 @@ "use strict"; | ||
for (const { entropy, mnemonic } of vectors) { | ||
expect(bip39_1.Bip39.encode(fromHex(entropy)).asString()).toEqual(mnemonic); | ||
expect(bip39_1.Bip39.encode(fromHex(entropy)).toString()).toEqual(mnemonic); | ||
} | ||
@@ -30,0 +30,0 @@ } |
@@ -36,5 +36,9 @@ "use strict"; | ||
} | ||
asString() { | ||
toString() { | ||
return this.data; | ||
} | ||
/** @deprecated use toString */ | ||
asString() { | ||
return this.toString(); | ||
} | ||
} | ||
@@ -41,0 +45,0 @@ // list of space separated lower case words (1 or more) |
@@ -60,3 +60,10 @@ "use strict"; | ||
// tslint:enable:no-unused-expression | ||
describe("toString", () => { | ||
it("works", () => { | ||
const original = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; | ||
const mnemonic = new englishmnemonic_1.EnglishMnemonic(original); | ||
expect(mnemonic.toString()).toEqual(original); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=englishmnemonic.spec.js.map |
{ | ||
"name": "@iov/crypto", | ||
"version": "0.14.4", | ||
"version": "0.14.5", | ||
"description": "Cryptography resources for IOV projects", | ||
@@ -33,3 +33,3 @@ "author": "IOV SAS <admin@iov.one>", | ||
"dependencies": { | ||
"@iov/encoding": "^0.14.4", | ||
"@iov/encoding": "^0.14.5", | ||
"bip39": "^2.5.0", | ||
@@ -48,3 +48,3 @@ "bn.js": "^4.11.8", | ||
}, | ||
"gitHead": "15f31720ee4eedf9dcb7608134acff3f1facc23b" | ||
"gitHead": "1f4d0497bfd5b28fbe9684921529ddbb8b943746" | ||
} |
@@ -18,3 +18,3 @@ import { Encoding } from "@iov/encoding"; | ||
for (const { entropy, mnemonic } of vectors) { | ||
expect(Bip39.encode(fromHex(entropy)).asString()).toEqual(mnemonic); | ||
expect(Bip39.encode(fromHex(entropy)).toString()).toEqual(mnemonic); | ||
} | ||
@@ -21,0 +21,0 @@ } |
@@ -21,3 +21,3 @@ import * as bip39 from "bip39"; | ||
public static decode(mnemonic: EnglishMnemonic): Uint8Array { | ||
return Encoding.fromHex(bip39.mnemonicToEntropy(mnemonic.asString())); | ||
return Encoding.fromHex(bip39.mnemonicToEntropy(mnemonic.toString())); | ||
} | ||
@@ -28,3 +28,3 @@ | ||
// interface of https://www.npmjs.com/package/pbkdf2 | ||
const mnemonicBytes = Buffer.from(unorm.nfkd(mnemonic.asString()), "utf8"); | ||
const mnemonicBytes = Buffer.from(unorm.nfkd(mnemonic.toString()), "utf8"); | ||
const salt = "mnemonic" + (password ? unorm.nfkd(password) : ""); | ||
@@ -31,0 +31,0 @@ const saltBytes = Buffer.from(salt, "utf8"); |
@@ -208,2 +208,11 @@ import { EnglishMnemonic } from "./englishmnemonic"; | ||
// tslint:enable:no-unused-expression | ||
describe("toString", () => { | ||
it("works", () => { | ||
const original = | ||
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; | ||
const mnemonic = new EnglishMnemonic(original); | ||
expect(mnemonic.toString()).toEqual(original); | ||
}); | ||
}); | ||
}); |
@@ -37,5 +37,10 @@ import * as bip39 from "bip39"; | ||
public asString(): string { | ||
public toString(): string { | ||
return this.data; | ||
} | ||
/** @deprecated use toString */ | ||
public asString(): string { | ||
return this.toString(); | ||
} | ||
} |
@@ -5,3 +5,5 @@ export declare class EnglishMnemonic { | ||
constructor(mnemonic: string); | ||
toString(): string; | ||
/** @deprecated use toString */ | ||
asString(): string; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
980082
12707
Updated@iov/encoding@^0.14.5