Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/keys

Package Overview
Dependencies
Maintainers
13
Versions
1514
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/keys - npm Package Compare versions

Comparing version 2.0.0-experimental.88723ed to 2.0.0-experimental.8d5318e

dist/types/base58.d.ts.map

16

dist/index.browser.js

@@ -1,2 +0,2 @@

import bs58 from 'bs58';
import { base58 } from '@metaplex-foundation/umi-serializers-encodings';

@@ -13,3 +13,3 @@ // src/base58.ts

}
const bytes = bs58.decode(putativeBase58EncodedAddress);
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;

@@ -25,5 +25,15 @@ if (numBytes !== 32) {

}
function getBase58EncodedAddressComparator() {
return new Intl.Collator("en", {
caseFirst: "lower",
ignorePunctuation: false,
localeMatcher: "best fit",
numeric: false,
sensitivity: "variant",
usage: "sort"
}).compare;
}
export { assertIsBase58EncodedAddress };
export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

244

dist/index.development.js

@@ -5,184 +5,77 @@ this.globalThis = this.globalThis || {};

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
var InvalidBaseStringError = class extends Error {
constructor(value, base, cause) {
const message = `Expected a string of base ${base}, got [${value}].`;
super(message);
__publicField(this, "name", "InvalidBaseStringError");
this.cause = cause;
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// ../build-scripts/env-shim.ts
var init_env_shim = __esm({
"../build-scripts/env-shim.ts"() {
}
});
// ../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js
var require_src = __commonJS({
"../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js"(exports, module) {
init_env_shim();
function base(ALPHABET) {
if (ALPHABET.length >= 255) {
throw new TypeError("Alphabet too long");
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
var baseX = (alphabet) => {
const base = alphabet.length;
const baseBigInt = BigInt(base);
return {
description: `base${base}`,
fixedSize: null,
maxSize: null,
serialize(value) {
if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
throw new InvalidBaseStringError(value, base);
}
var BASE_MAP = new Uint8Array(256);
for (var j = 0; j < BASE_MAP.length; j++) {
BASE_MAP[j] = 255;
if (value === "")
return new Uint8Array();
const chars = [...value];
let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
const leadingZeroes = Array(trailIndex).fill(0);
if (trailIndex === chars.length)
return Uint8Array.from(leadingZeroes);
const tailChars = chars.slice(trailIndex);
let base10Number = 0n;
let baseXPower = 1n;
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
baseXPower *= baseBigInt;
}
for (var i = 0; i < ALPHABET.length; i++) {
var x = ALPHABET.charAt(i);
var xc = x.charCodeAt(0);
if (BASE_MAP[xc] !== 255) {
throw new TypeError(x + " is ambiguous");
}
BASE_MAP[xc] = i;
const tailBytes = [];
while (base10Number > 0n) {
tailBytes.unshift(Number(base10Number % 256n));
base10Number /= 256n;
}
var BASE = ALPHABET.length;
var LEADER = ALPHABET.charAt(0);
var FACTOR = Math.log(BASE) / Math.log(256);
var iFACTOR = Math.log(256) / Math.log(BASE);
function encode(source) {
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
} else if (Array.isArray(source)) {
source = Uint8Array.from(source);
}
if (!(source instanceof Uint8Array)) {
throw new TypeError("Expected Uint8Array");
}
if (source.length === 0) {
return "";
}
var zeroes = 0;
var length = 0;
var pbegin = 0;
var pend = source.length;
while (pbegin !== pend && source[pbegin] === 0) {
pbegin++;
zeroes++;
}
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
var b58 = new Uint8Array(size);
while (pbegin !== pend) {
var carry = source[pbegin];
var i2 = 0;
for (var it1 = size - 1; (carry !== 0 || i2 < length) && it1 !== -1; it1--, i2++) {
carry += 256 * b58[it1] >>> 0;
b58[it1] = carry % BASE >>> 0;
carry = carry / BASE >>> 0;
}
if (carry !== 0) {
throw new Error("Non-zero carry");
}
length = i2;
pbegin++;
}
var it2 = size - length;
while (it2 !== size && b58[it2] === 0) {
it2++;
}
var str = LEADER.repeat(zeroes);
for (; it2 < size; ++it2) {
str += ALPHABET.charAt(b58[it2]);
}
return str;
return Uint8Array.from(leadingZeroes.concat(tailBytes));
},
deserialize(buffer, offset = 0) {
if (buffer.length === 0)
return ["", 0];
const bytes = buffer.slice(offset);
let trailIndex = bytes.findIndex((n) => n !== 0);
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
const leadingZeroes = alphabet[0].repeat(trailIndex);
if (trailIndex === bytes.length)
return [leadingZeroes, buffer.length];
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
const tailChars = [];
while (base10Number > 0n) {
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
base10Number /= baseBigInt;
}
function decodeUnsafe(source) {
if (typeof source !== "string") {
throw new TypeError("Expected String");
}
if (source.length === 0) {
return new Uint8Array();
}
var psz = 0;
var zeroes = 0;
var length = 0;
while (source[psz] === LEADER) {
zeroes++;
psz++;
}
var size = (source.length - psz) * FACTOR + 1 >>> 0;
var b256 = new Uint8Array(size);
while (source[psz]) {
var carry = BASE_MAP[source.charCodeAt(psz)];
if (carry === 255) {
return;
}
var i2 = 0;
for (var it3 = size - 1; (carry !== 0 || i2 < length) && it3 !== -1; it3--, i2++) {
carry += BASE * b256[it3] >>> 0;
b256[it3] = carry % 256 >>> 0;
carry = carry / 256 >>> 0;
}
if (carry !== 0) {
throw new Error("Non-zero carry");
}
length = i2;
psz++;
}
var it4 = size - length;
while (it4 !== size && b256[it4] === 0) {
it4++;
}
var vch = new Uint8Array(zeroes + (size - it4));
var j2 = zeroes;
while (it4 !== size) {
vch[j2++] = b256[it4++];
}
return vch;
}
function decode(string) {
var buffer = decodeUnsafe(string);
if (buffer) {
return buffer;
}
throw new Error("Non-base" + BASE + " character");
}
return {
encode,
decodeUnsafe,
decode
};
return [leadingZeroes + tailChars.join(""), buffer.length];
}
module.exports = base;
}
});
};
};
// ../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js
var require_bs58 = __commonJS({
"../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js"(exports, module) {
init_env_shim();
var basex = require_src();
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
module.exports = basex(ALPHABET);
}
});
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
// src/index.ts
init_env_shim();
// src/base58.ts
init_env_shim();
var import_bs58 = __toESM(require_bs58(), 1);
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {

@@ -197,3 +90,3 @@ try {

}
const bytes = import_bs58.default.decode(putativeBase58EncodedAddress);
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;

@@ -209,4 +102,15 @@ if (numBytes !== 32) {

}
function getBase58EncodedAddressComparator() {
return new Intl.Collator("en", {
caseFirst: "lower",
ignorePunctuation: false,
localeMatcher: "best fit",
numeric: false,
sensitivity: "variant",
usage: "sort"
}).compare;
}
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;

@@ -213,0 +117,0 @@ return exports;

@@ -1,2 +0,2 @@

import bs58 from 'bs58';
import { base58 } from '@metaplex-foundation/umi-serializers-encodings';

@@ -13,3 +13,3 @@ // src/base58.ts

}
const bytes = bs58.decode(putativeBase58EncodedAddress);
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;

@@ -25,5 +25,15 @@ if (numBytes !== 32) {

}
function getBase58EncodedAddressComparator() {
return new Intl.Collator("en", {
caseFirst: "lower",
ignorePunctuation: false,
localeMatcher: "best fit",
numeric: false,
sensitivity: "variant",
usage: "sort"
}).compare;
}
export { assertIsBase58EncodedAddress };
export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -1,2 +0,2 @@

import bs58 from 'bs58';
import { base58 } from '@metaplex-foundation/umi-serializers-encodings';

@@ -13,3 +13,3 @@ // src/base58.ts

}
const bytes = bs58.decode(putativeBase58EncodedAddress);
const bytes = base58.serialize(putativeBase58EncodedAddress);
const numBytes = bytes.byteLength;

@@ -25,5 +25,15 @@ if (numBytes !== 32) {

}
function getBase58EncodedAddressComparator() {
return new Intl.Collator("en", {
caseFirst: "lower",
ignorePunctuation: false,
localeMatcher: "best fit",
numeric: false,
sensitivity: "variant",
usage: "sort"
}).compare;
}
export { assertIsBase58EncodedAddress };
export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

@@ -5,5 +5,6 @@ this.globalThis = this.globalThis || {};

var S=Object.create;var m=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var $=(e,r)=>()=>(e&&(r=e(e=0)),r);var u=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var k=(e,r,n,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of q(r))!F.call(e,l)&&l!==n&&m(e,l,{get:()=>r[l],enumerable:!(p=V(r,l))||p.enumerable});return e};var G=(e,r,n)=>(n=e!=null?S(B(e)):{},k(r||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e));var w=$(()=>{});var _=u((X,z)=>{w();function I(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var p=0;p<e.length;p++){var l=e.charAt(p),c=l.charCodeAt(0);if(r[c]!==255)throw new TypeError(l+" is ambiguous");r[c]=p;}var A=e.length,U=e.charAt(0),T=Math.log(A)/Math.log(256),D=Math.log(256)/Math.log(A);function O(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length===0)return "";for(var a=0,y=0,i=0,h=t.length;i!==h&&t[i]===0;)i++,a++;for(var d=(h-i)*D+1>>>0,o=new Uint8Array(d);i!==h;){for(var f=t[i],g=0,s=d-1;(f!==0||g<y)&&s!==-1;s--,g++)f+=256*o[s]>>>0,o[s]=f%A>>>0,f=f/A>>>0;if(f!==0)throw new Error("Non-zero carry");y=g,i++;}for(var v=d-y;v!==d&&o[v]===0;)v++;for(var b=U.repeat(a);v<d;++v)b+=e.charAt(o[v]);return b}function x(t){if(typeof t!="string")throw new TypeError("Expected String");if(t.length===0)return new Uint8Array;for(var a=0,y=0,i=0;t[a]===U;)y++,a++;for(var h=(t.length-a)*T+1>>>0,d=new Uint8Array(h);t[a];){var o=r[t.charCodeAt(a)];if(o===255)return;for(var f=0,g=h-1;(o!==0||f<i)&&g!==-1;g--,f++)o+=A*d[g]>>>0,d[g]=o%256>>>0,o=o/256>>>0;if(o!==0)throw new Error("Non-zero carry");i=f,a++;}for(var s=h-i;s!==h&&d[s]===0;)s++;for(var v=new Uint8Array(y+(h-s)),b=y;s!==h;)v[b++]=d[s++];return v}function R(t){var a=x(t);if(a)return a;throw new Error("Non-base"+A+" character")}return {encode:O,decodeUnsafe:x,decode:R}}z.exports=I;});var N=u((Z,M)=>{w();var J=_(),K="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";M.exports=J(K);});w();w();var C=G(N(),1);function L(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let n=C.default.decode(e).byteLength;if(n!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}
var h=Object.defineProperty;var b=(e,r,t)=>r in e?h(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var x=(e,r,t)=>(b(e,typeof r!="symbol"?r+"":r,t),t);var m=class extends Error{constructor(t,s,i){let n=`Expected a string of base ${s}, got [${t}].`;super(n);x(this,"name","InvalidBaseStringError");this.cause=i;}};var p=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(s){if(!s.match(new RegExp(`^[${e}]*$`)))throw new m(s,r);if(s==="")return new Uint8Array;let i=[...s],n=i.findIndex(c=>c!==e[0]);n=n===-1?i.length:n;let o=Array(n).fill(0);if(n===i.length)return Uint8Array.from(o);let l=i.slice(n),a=0n,g=1n;for(let c=l.length-1;c>=0;c-=1)a+=g*BigInt(e.indexOf(l[c])),g*=t;let d=[];for(;a>0n;)d.unshift(Number(a%256n)),a/=256n;return Uint8Array.from(o.concat(d))},deserialize(s,i=0){if(s.length===0)return ["",0];let n=s.slice(i),o=n.findIndex(d=>d!==0);o=o===-1?n.length:o;let l=e[0].repeat(o);if(o===n.length)return [l,s.length];let a=n.slice(o).reduce((d,c)=>d*256n+BigInt(c),0n),g=[];for(;a>0n;)g.unshift(e[Number(a%t)]),a/=t;return [l+g.join(""),s.length]}}};var u=p("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function D(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=u.serialize(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function P(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}
exports.assertIsBase58EncodedAddress = L;
exports.assertIsBase58EncodedAddress = D;
exports.getBase58EncodedAddressComparator = P;

@@ -10,0 +11,0 @@ return exports;

@@ -5,2 +5,3 @@ export type Base58EncodedAddress<TAddress extends string = string> = TAddress & {

export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number;
//# sourceMappingURL=base58.d.ts.map
{
"name": "@solana/keys",
"version": "2.0.0-experimental.88723ed",
"version": "2.0.0-experimental.8d5318e",
"description": "Helpers for generating and transforming key material",

@@ -48,7 +48,10 @@ "exports": {

],
"dependencies": {
"@metaplex-foundation/umi-serializers-encodings": "^0.8.2"
},
"devDependencies": {
"@solana/eslint-config-solana": "^1.0.0",
"@solana/eslint-config-solana": "^1.0.1",
"@swc/core": "^1.3.18",
"@swc/jest": "^0.2.23",
"@types/jest": "^29.5.0",
"@swc/jest": "^0.2.26",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^5.57.1",

@@ -63,9 +66,9 @@ "@typescript-eslint/parser": "^5.57.1",

"jest-environment-jsdom": "^29.5.0",
"jest-runner-eslint": "^2.0.0",
"jest-runner-eslint": "^2.1.0",
"jest-runner-prettier": "^1.0.0",
"postcss": "^8.4.12",
"prettier": "^2.7.1",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"tsup": "6.7.0",
"typescript": "^5.0.3",
"typescript": "^5.0.4",
"version-from-git": "^1.1.1",

@@ -84,5 +87,2 @@ "build-scripts": "0.0.0",

},
"dependencies": {
"bs58": "^5.0.0"
},
"scripts": {

@@ -89,0 +89,0 @@ "compile:js": "tsup --config build-scripts/tsup.config.library.ts",

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

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