New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@helium/crypto-react-native

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helium/crypto-react-native - npm Package Compare versions

Comparing version 3.60.0 to 4.0.0

3

build/index.d.ts

@@ -8,6 +8,3 @@ /**

export { default as Keypair } from './Keypair';
export { default as Address } from './Address';
export * as NetType from './NetType';
export * as KeyType from './KeyType';
export * as utils from './utils';
//# sourceMappingURL=index.d.ts.map

@@ -30,3 +30,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.utils = exports.KeyType = exports.NetType = exports.Address = exports.Keypair = exports.Mnemonic = void 0;
exports.utils = exports.Keypair = exports.Mnemonic = void 0;
var Mnemonic_1 = require("./Mnemonic");

@@ -36,8 +36,4 @@ Object.defineProperty(exports, "Mnemonic", { enumerable: true, get: function () { return __importDefault(Mnemonic_1).default; } });

Object.defineProperty(exports, "Keypair", { enumerable: true, get: function () { return __importDefault(Keypair_1).default; } });
var Address_1 = require("./Address");
Object.defineProperty(exports, "Address", { enumerable: true, get: function () { return __importDefault(Address_1).default; } });
exports.NetType = __importStar(require("./NetType"));
exports.KeyType = __importStar(require("./KeyType"));
exports.utils = __importStar(require("./utils"));
global.Buffer = require('safe-buffer').Buffer;
//# sourceMappingURL=index.js.map

6

build/Keypair.d.ts
/// <reference types="node" />
import Address, { KeyTypes, NetTypes } from '@helium/address';
import Mnemonic from './Mnemonic';
import Address from './Address';
import { KeyType } from './KeyType';
import { NetType } from './NetType';
declare type KeyType = KeyTypes.KeyType;
declare 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]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,6 +26,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const react_native_sodium_1 = __importDefault(require("react-native-sodium"));
const address_1 = __importStar(require("@helium/address"));
const Mnemonic_1 = __importDefault(require("./Mnemonic"));
const Address_1 = __importDefault(require("./Address"));
const KeyType_1 = require("./KeyType");
const NetType_1 = require("./NetType");
// extend SodiumKeyPair?

@@ -18,7 +35,7 @@ class Keypair {

this.privateKey = Buffer.from(keypair.sk, 'base64');
this.keyType = keypair.keyType || KeyType_1.ED25519_KEY_TYPE;
this.netType = netType || NetType_1.MAINNET;
this.keyType = keypair.keyType || address_1.KeyTypes.ED25519_KEY_TYPE;
this.netType = netType || address_1.NetTypes.MAINNET;
}
get address() {
return new Address_1.default(0, this.netType, KeyType_1.ED25519_KEY_TYPE, this.publicKey);
return new address_1.default(0, this.netType, address_1.KeyTypes.ED25519_KEY_TYPE, this.publicKey);
}

@@ -25,0 +42,0 @@ static async makeRandom(netType) {

/// <reference types="node" />
import { NetType } from './NetType';
import { KeyType } from './KeyType';
export declare const randomBytes: (n: number) => Promise<Buffer>;

@@ -9,10 +7,2 @@ export declare const lpad: (str: string | any[], padString: string, length: number) => string | any[];

export declare const deriveChecksumBits: (entropyBuffer: Buffer | string) => string;
export declare const bs58CheckEncode: (version: number, binary: Buffer | Uint8Array) => string;
export declare const bs58ToBin: (bs58Address: string) => Buffer;
export declare const byteToNetType: (byte: number) => NetType;
export declare const byteToKeyType: (byte: number) => KeyType;
export declare const bs58NetType: (bs58Address: string) => NetType;
export declare const bs58KeyType: (bs58Address: string) => KeyType;
export declare const bs58Version: (bs58Address: string) => number;
export declare const bs58PublicKey: (bs58Address: string) => Buffer;
//# sourceMappingURL=utils.d.ts.map

@@ -6,7 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.bs58PublicKey = exports.bs58Version = exports.bs58KeyType = exports.bs58NetType = exports.byteToKeyType = exports.byteToNetType = exports.bs58ToBin = exports.bs58CheckEncode = exports.deriveChecksumBits = exports.binaryToByte = exports.bytesToBinary = exports.lpad = exports.randomBytes = void 0;
exports.deriveChecksumBits = exports.binaryToByte = exports.bytesToBinary = exports.lpad = exports.randomBytes = void 0;
/* eslint-disable no-bitwise */
const react_native_sodium_1 = __importDefault(require("react-native-sodium"));
const js_sha256_1 = require("js-sha256");
const bs58_1 = __importDefault(require("bs58"));
const randomBytes = async (n) => {

@@ -37,61 +36,2 @@ const bytes = await react_native_sodium_1.default.randombytes_buf(n);

exports.deriveChecksumBits = deriveChecksumBits;
const bs58CheckEncode = (version, binary) => {
// VPayload = <<Version:8/unsigned-integer, Payload/binary>>,
const vPayload = Buffer.concat([
Buffer.from([version]),
binary,
]);
// <<Checksum:4/binary, _/binary>> = crypto:hash(sha256, crypto:hash(sha256, VPayload)),
const checksum = js_sha256_1.sha256(Buffer.from(js_sha256_1.sha256(vPayload), 'hex'));
const checksumBytes = Buffer.alloc(4, checksum, 'hex');
// Result = <<VPayload/binary, Checksum/binary>>,
const result = Buffer.concat([
vPayload,
checksumBytes,
]);
// base58:binary_to_base58(Result).
return bs58_1.default.encode(result);
};
exports.bs58CheckEncode = bs58CheckEncode;
const bs58ToBin = (bs58Address) => {
const bin = bs58_1.default.decode(bs58Address);
const vPayload = bin.slice(0, -4);
const payload = bin.slice(1, -4);
const checksum = bin.slice(-4);
const checksumVerify = js_sha256_1.sha256(Buffer.from(js_sha256_1.sha256(vPayload), 'hex'));
const checksumVerifyBytes = Buffer.alloc(4, checksumVerify, 'hex');
if (!checksumVerifyBytes.equals(checksum)) {
throw new Error('invalid checksum');
}
return payload;
};
exports.bs58ToBin = bs58ToBin;
const byteToNetType = (byte) => byte & 0xf0;
exports.byteToNetType = byteToNetType;
const byteToKeyType = (byte) => byte & 0x0f;
exports.byteToKeyType = byteToKeyType;
const bs58NetType = (bs58Address) => {
const bin = exports.bs58ToBin(bs58Address);
const byte = Buffer.from(bin).slice(0, 1)[0];
return exports.byteToNetType(byte);
};
exports.bs58NetType = bs58NetType;
const bs58KeyType = (bs58Address) => {
const bin = exports.bs58ToBin(bs58Address);
const byte = Buffer.from(bin).slice(0, 1)[0];
return exports.byteToKeyType(byte);
};
exports.bs58KeyType = bs58KeyType;
const bs58Version = (bs58Address) => {
const bin = bs58_1.default.decode(bs58Address);
const version = bin.slice(0, 1)[0];
return version;
};
exports.bs58Version = bs58Version;
const bs58PublicKey = (bs58Address) => {
const bin = exports.bs58ToBin(bs58Address);
const publicKey = Buffer.from(bin).slice(1);
return publicKey;
};
exports.bs58PublicKey = bs58PublicKey;
//# sourceMappingURL=utils.js.map
{
"name": "@helium/crypto-react-native",
"version": "3.60.0",
"version": "4.0.0",
"description": "Cryptography utilities including mnemonics, keypairs and base58-check encoding for React Native",

@@ -30,4 +30,3 @@ "keywords": [

"dependencies": {
"bs58": "^4.0.1",
"buffer": "^6.0.1",
"@helium/address": "^4.0.0",
"js-sha256": "^0.9.0",

@@ -37,6 +36,3 @@ "react-native-sodium": "^0.3.8",

},
"devDependencies": {
"@types/bs58": "4.0.1"
},
"gitHead": "4b9b123f61969cc357d1bc44b1e7f88bd974d7aa"
"gitHead": "048f2becc33ce3e2313da4b4f2c6d18d0462a998"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc