Socket
Socket
Sign inDemoInstall

@scure/base

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scure/base - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

lib/esm/index.d.ts

24

index.ts

@@ -154,3 +154,3 @@ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */

*/
function convertRadix(data: number[], from: number, to: number) {
function convertRadix(data: number[], from: number, to: number): number[] {
// base 1 is impossible

@@ -480,6 +480,22 @@ if (from < 2) throw new Error(`convertRadix: wrong from=${from}, base cannot be less than 2`);

export interface Bech32 {
encode<Prefix extends string>(
prefix: Prefix,
words: number[] | Uint8Array,
limit: number | false
): `${Lowercase<Prefix>}1${string}`;
decode<Prefix extends string>(
str: `${Prefix}1${string}`,
limit?: number | false
): Bech32Decoded<Prefix>;
decodeToBytes(str: string): Bech32DecodedWithArray;
decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>;
fromWords(to: number[]): Uint8Array;
fromWordsUnsafe(to: number[]): void | Uint8Array;
toWords(from: Uint8Array): number[];
}
/**
* @__NO_SIDE_EFFECTS__
*/
function genBech32(encoding: 'bech32' | 'bech32m') {
function genBech32(encoding: 'bech32' | 'bech32m'): Bech32 {
const ENCODING_CONST = encoding === 'bech32' ? 1 : 0x2bc830a3;

@@ -545,4 +561,4 @@ const _words = radix2(5);

export const bech32 = /* @__PURE__ */ genBech32('bech32');
export const bech32m = /* @__PURE__ */ genBech32('bech32m');
export const bech32: Bech32 = /* @__PURE__ */ genBech32('bech32');
export const bech32m: Bech32 = /* @__PURE__ */ genBech32('bech32m');

@@ -549,0 +565,0 @@ declare const TextEncoder: any;

35

lib/index.d.ts

@@ -102,26 +102,13 @@ /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */

}
export declare const bech32: {
encode: <Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit?: number | false) => `${Lowercase<Prefix>}1${string}`;
decode: {
<Prefix_1 extends string>(str: `${Prefix_1}1${string}`, limit?: number | false): Bech32Decoded<Prefix_1>;
(str: string, limit?: number | false): Bech32Decoded;
};
decodeToBytes: (str: string) => Bech32DecodedWithArray;
decodeUnsafe: (str: string, limit?: number | false | undefined) => void | Bech32Decoded<string>;
fromWords: (to: number[]) => Uint8Array;
fromWordsUnsafe: (to: number[]) => void | Uint8Array;
toWords: (from: Uint8Array) => number[];
};
export declare const bech32m: {
encode: <Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit?: number | false) => `${Lowercase<Prefix>}1${string}`;
decode: {
<Prefix_1 extends string>(str: `${Prefix_1}1${string}`, limit?: number | false): Bech32Decoded<Prefix_1>;
(str: string, limit?: number | false): Bech32Decoded;
};
decodeToBytes: (str: string) => Bech32DecodedWithArray;
decodeUnsafe: (str: string, limit?: number | false | undefined) => void | Bech32Decoded<string>;
fromWords: (to: number[]) => Uint8Array;
fromWordsUnsafe: (to: number[]) => void | Uint8Array;
toWords: (from: Uint8Array) => number[];
};
export interface Bech32 {
encode<Prefix extends string>(prefix: Prefix, words: number[] | Uint8Array, limit: number | false): `${Lowercase<Prefix>}1${string}`;
decode<Prefix extends string>(str: `${Prefix}1${string}`, limit?: number | false): Bech32Decoded<Prefix>;
decodeToBytes(str: string): Bech32DecodedWithArray;
decodeUnsafe(str: string, limit?: number | false): void | Bech32Decoded<string>;
fromWords(to: number[]): Uint8Array;
fromWordsUnsafe(to: number[]): void | Uint8Array;
toWords(from: Uint8Array): number[];
}
export declare const bech32: Bech32;
export declare const bech32m: Bech32;
export declare const utf8: BytesCoder;

@@ -128,0 +115,0 @@ export declare const hex: BytesCoder;

"use strict";
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(exports, "__esModule", { value: true });
exports.bytes = exports.stringToBytes = exports.str = exports.bytesToString = exports.hex = exports.utf8 = exports.bech32m = exports.bech32 = exports.base58check = exports.createBase58check = exports.base58xmr = exports.base58xrp = exports.base58flickr = exports.base58 = exports.base64urlnopad = exports.base64url = exports.base64nopad = exports.base64 = exports.base32crockford = exports.base32hexnopad = exports.base32hex = exports.base32nopad = exports.base32 = exports.base16 = exports.utils = exports.assertNumber = void 0;
exports.bytes = exports.stringToBytes = exports.str = exports.bytesToString = exports.hex = exports.utf8 = exports.bech32m = exports.bech32 = exports.base58check = exports.createBase58check = exports.base58xmr = exports.base58xrp = exports.base58flickr = exports.base58 = exports.base64urlnopad = exports.base64url = exports.base64nopad = exports.base64 = exports.base32crockford = exports.base32hexnopad = exports.base32hex = exports.base32nopad = exports.base32 = exports.base16 = exports.utils = void 0;
exports.assertNumber = assertNumber;
// Utilities

@@ -13,3 +14,2 @@ /**

}
exports.assertNumber = assertNumber;
function isBytes(a) {

@@ -16,0 +16,0 @@ return (a instanceof Uint8Array ||

{
"name": "@scure/base",
"version": "1.1.7",
"version": "1.1.8",
"description": "Secure, audited & 0-dep implementation of base64, bech32, base58, base32 & base16",

@@ -8,7 +8,9 @@ "files": [

"lib/index.js.map",
"lib/index.d.ts",
"lib/index.d.ts.map",
"lib/esm/index.js",
"lib/esm/index.js.map",
"lib/esm/index.d.ts",
"lib/esm/index.d.ts.map",
"lib/esm/package.json",
"lib/index.d.ts",
"lib/index.d.ts.map",
"index.ts"

@@ -21,5 +23,4 @@ ],

".": {
"types": "./lib/index.d.ts",
"import": "./lib/esm/index.js",
"default": "./lib/index.js"
"require": "./lib/index.js"
}

@@ -44,6 +45,6 @@ },

"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"@paulmillr/jsbt": "0.2.1",
"micro-should": "0.4.0",
"prettier": "3.1.1",
"typescript": "5.3.2"
"prettier": "3.3.2",
"typescript": "5.5.2"
},

@@ -50,0 +51,0 @@ "keywords": [

@@ -6,3 +6,3 @@ # scure-base

- 🔒 [Audited](#security) by an independent security firm
- 🔻 Tree-shaking-friendly: use only what's necessary, other code won't be included
- 🔻 Tree-shakeable: unused code is excluded from your builds
- 📦 ESM and common.js

@@ -35,4 +35,6 @@ - ✍️ Written in [functional style](#design-rationale), easily composable

> npm install @scure/base
> `npm install @scure/base`
> `deno add @scure/base`
We support all major platforms and runtimes. The library is hybrid ESM / Common.js package.

@@ -95,3 +97,3 @@

// NOTE: words in bitcoin addresses contain version as first element,
// with actual witnes program words in rest
// with actual witness program words in rest
// BIP-141: The value of the first push is called the "version byte".

@@ -137,3 +139,3 @@ // The following byte vector pushed is called the "witness program".

But instead of creating two big functions for each specific case,
we create them from tiny composamble building blocks:
we create them from tiny composable building blocks:

@@ -158,3 +160,3 @@ ```

if (!Array.isArray(wordlist) || wordlist.length !== 2 ** 11 || typeof wordlist[0] !== 'string') {
throw new Error('Worlist: expected array of 2048 strings');
throw new Error('Wordlist: expected array of 2048 strings');
}

@@ -161,0 +163,0 @@ return mbc.chain(mbu.checksum(1, checksum), mbu.radix2(11, true), mbu.alphabet(wordlist));

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