@helium/crypto-react-native
Advanced tools
Comparing version 4.11.1 to 4.12.0
@@ -9,3 +9,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -12,0 +16,0 @@ if (k2 === undefined) k2 = k; |
/// <reference types="node" /> | ||
import Address, { KeyTypes, NetTypes } from '@helium/address'; | ||
import Mnemonic from './Mnemonic'; | ||
declare type KeyType = KeyTypes.KeyType; | ||
declare type NetType = NetTypes.NetType; | ||
type KeyType = KeyTypes.KeyType; | ||
type NetType = NetTypes.NetType; | ||
interface SodiumKeyPair { | ||
@@ -7,0 +7,0 @@ keyType?: KeyType; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
/// <reference types="node" /> | ||
export declare type MnemonicLength = 12 | 24; | ||
export type MnemonicLength = 12 | 24; | ||
export default class Mnemonic { | ||
@@ -4,0 +4,0 @@ words: Array<string>; |
@@ -17,3 +17,3 @@ "use strict"; | ||
const entropyBytes = (16 / 12) * length; | ||
const entropy = await utils_1.randomBytes(entropyBytes); | ||
const entropy = await (0, utils_1.randomBytes)(entropyBytes); | ||
return Mnemonic.fromEntropy(entropy); | ||
@@ -29,7 +29,7 @@ } | ||
} | ||
const entropyBits = utils_1.bytesToBinary([].slice.call(entropy)); | ||
const checksumBits = utils_1.deriveChecksumBits(entropy); | ||
const entropyBits = (0, utils_1.bytesToBinary)([].slice.call(entropy)); | ||
const checksumBits = (0, utils_1.deriveChecksumBits)(entropy); | ||
const bits = entropyBits + checksumBits; | ||
const chunks = bits.match(/(.{1,11})/g) || []; | ||
const words = chunks.map((binary) => english_json_1.default[utils_1.binaryToByte(binary)]); | ||
const words = chunks.map((binary) => english_json_1.default[(0, utils_1.binaryToByte)(binary)]); | ||
return new Mnemonic(words); | ||
@@ -42,3 +42,3 @@ } | ||
const index = english_json_1.default.indexOf(word); | ||
return utils_1.lpad(index.toString(2), '0', 11); | ||
return (0, utils_1.lpad)(index.toString(2), '0', 11); | ||
}) | ||
@@ -59,3 +59,3 @@ .join(''); | ||
const entropy = Buffer.from(entropyBytes); | ||
const newChecksum = utils_1.deriveChecksumBits(entropy); | ||
const newChecksum = (0, utils_1.deriveChecksumBits)(entropy); | ||
if (checksumBits !== '0000' && newChecksum !== checksumBits) | ||
@@ -62,0 +62,0 @@ throw new Error('invalid checksum'); |
@@ -24,3 +24,3 @@ "use strict"; | ||
const bytesToBinary = (bytes) => bytes | ||
.map((x) => exports.lpad(x.toString(2), '0', 8)) | ||
.map((x) => (0, exports.lpad)(x.toString(2), '0', 8)) | ||
.join(''); | ||
@@ -34,3 +34,3 @@ exports.bytesToBinary = bytesToBinary; | ||
const hash = js_sha256_1.sha256.digest(entropyBuffer); | ||
return exports.bytesToBinary(Array.from(hash)).slice(0, CS); | ||
return (0, exports.bytesToBinary)(Array.from(hash)).slice(0, CS); | ||
}; | ||
@@ -37,0 +37,0 @@ exports.deriveChecksumBits = deriveChecksumBits; |
{ | ||
"name": "@helium/crypto-react-native", | ||
"version": "4.11.1", | ||
"version": "4.12.0", | ||
"description": "Cryptography utilities including mnemonics, keypairs and base58-check encoding for React Native", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@helium/address": "^4.11.1", | ||
"@helium/address": "^4.12.0", | ||
"js-sha256": "^0.9.0", | ||
@@ -36,3 +36,3 @@ "react-native-sodium": "^0.4.0", | ||
}, | ||
"gitHead": "f9abfceadb3e2b4574cf159c9af454a0aefe75cd" | ||
"gitHead": "77bcfdd97c8ffbb314e1965ac6eb96d00275db05" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
60354
2312
0
Updated@helium/address@^4.12.0