@solana/keys
Advanced tools
Comparing version 2.0.0-experimental.982fafd to 2.0.0-experimental.9b5eac4
@@ -1,4 +0,5 @@ | ||
import bs58 from 'bs58'; | ||
import { base58, string } from '@metaplex-foundation/umi-serializers'; | ||
// src/base58.ts | ||
// ../build-scripts/env-shim.ts | ||
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")(); | ||
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) { | ||
@@ -13,3 +14,3 @@ try { | ||
} | ||
const bytes = bs58.decode(putativeBase58EncodedAddress); | ||
const bytes = base58.serialize(putativeBase58EncodedAddress); | ||
const numBytes = bytes.byteLength; | ||
@@ -25,5 +26,97 @@ if (numBytes !== 32) { | ||
} | ||
function getBase58EncodedAddressCodec(config) { | ||
return string({ | ||
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""), | ||
encoding: base58, | ||
size: 32 | ||
}); | ||
} | ||
function getBase58EncodedAddressComparator() { | ||
return new Intl.Collator("en", { | ||
caseFirst: "lower", | ||
ignorePunctuation: false, | ||
localeMatcher: "best fit", | ||
numeric: false, | ||
sensitivity: "variant", | ||
usage: "sort" | ||
}).compare; | ||
} | ||
export { assertIsBase58EncodedAddress }; | ||
// src/guard.ts | ||
function assertIsSecureContext() { | ||
if (!globalThis.isSecureContext) { | ||
throw new Error( | ||
"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts" | ||
); | ||
} | ||
} | ||
var cachedEd25519Decision; | ||
async function isEd25519CurveSupported(subtle) { | ||
if (cachedEd25519Decision === void 0) { | ||
cachedEd25519Decision = new Promise((resolve) => { | ||
subtle.generateKey( | ||
"Ed25519", | ||
/* extractable */ | ||
false, | ||
["sign", "verify"] | ||
).catch(() => { | ||
resolve(cachedEd25519Decision = false); | ||
}).then(() => { | ||
resolve(cachedEd25519Decision = true); | ||
}); | ||
}); | ||
} | ||
if (typeof cachedEd25519Decision === "boolean") { | ||
return cachedEd25519Decision; | ||
} else { | ||
return await cachedEd25519Decision; | ||
} | ||
} | ||
async function assertKeyGenerationIsAvailable() { | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") { | ||
throw new Error("No key generation implementation could be found"); | ||
} | ||
if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) { | ||
throw new Error( | ||
"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20" | ||
); | ||
} | ||
} | ||
async function assertKeyExporterIsAvailable() { | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") { | ||
throw new Error("No key export implementation could be found"); | ||
} | ||
} | ||
// src/key-pair.ts | ||
async function generateKeyPair() { | ||
await assertKeyGenerationIsAvailable(); | ||
const keyPair = await crypto.subtle.generateKey( | ||
/* algorithm */ | ||
"Ed25519", | ||
// Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20 | ||
/* extractable */ | ||
false, | ||
// Prevents the bytes of the private key from being visible to JS. | ||
/* allowed uses */ | ||
["sign", "verify"] | ||
); | ||
return keyPair; | ||
} | ||
// src/pubkey.ts | ||
async function getBase58EncodedAddressFromPublicKey(publicKey) { | ||
await assertKeyExporterIsAvailable(); | ||
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") { | ||
throw new Error("The `CryptoKey` must be an `Ed25519` public key"); | ||
} | ||
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey); | ||
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes)); | ||
return base58EncodedAddress; | ||
} | ||
export { assertIsBase58EncodedAddress, generateKeyPair, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getBase58EncodedAddressFromPublicKey }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
@@ -5,184 +5,267 @@ 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; | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs | ||
var mergeBytes = (bytesArr) => { | ||
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0); | ||
const result = new Uint8Array(totalLength); | ||
let offset = 0; | ||
bytesArr.forEach((arr) => { | ||
result.set(arr, offset); | ||
offset += arr.length; | ||
}); | ||
return result; | ||
}; | ||
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 }); | ||
} | ||
return to; | ||
var padBytes = (bytes, length) => { | ||
if (bytes.length >= length) | ||
return bytes; | ||
const paddedBytes = new Uint8Array(length).fill(0); | ||
paddedBytes.set(bytes); | ||
return paddedBytes; | ||
}; | ||
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 | ||
)); | ||
var fixBytes = (bytes, length) => padBytes(bytes.slice(0, length), length); | ||
// ../build-scripts/env-shim.ts | ||
var init_env_shim = __esm({ | ||
"../build-scripts/env-shim.ts"() { | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs | ||
var DeserializingEmptyBufferError = class extends Error { | ||
constructor(serializer) { | ||
super(`Serializer [${serializer}] cannot deserialize empty buffers.`); | ||
__publicField(this, "name", "DeserializingEmptyBufferError"); | ||
} | ||
}); | ||
}; | ||
var NotEnoughBytesError = class extends Error { | ||
constructor(serializer, expected, actual) { | ||
super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`); | ||
__publicField(this, "name", "NotEnoughBytesError"); | ||
} | ||
}; | ||
// ../../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-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs | ||
function fixSerializer(serializer, fixedBytes, description) { | ||
return { | ||
description: description ?? `fixed(${fixedBytes}, ${serializer.description})`, | ||
fixedSize: fixedBytes, | ||
maxSize: fixedBytes, | ||
serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes), | ||
deserialize: (buffer, offset = 0) => { | ||
buffer = buffer.slice(offset, offset + fixedBytes); | ||
if (buffer.length < fixedBytes) { | ||
throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length); | ||
} | ||
var BASE_MAP = new Uint8Array(256); | ||
for (var j = 0; j < BASE_MAP.length; j++) { | ||
BASE_MAP[j] = 255; | ||
if (serializer.fixedSize !== null) { | ||
buffer = fixBytes(buffer, serializer.fixedSize); | ||
} | ||
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 [value] = serializer.deserialize(buffer, 0); | ||
return [value, offset + fixedBytes]; | ||
} | ||
}; | ||
} | ||
// ../../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; | ||
} | ||
}; | ||
// ../../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 = 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; | ||
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; | ||
} | ||
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; | ||
const tailBytes = []; | ||
while (base10Number > 0n) { | ||
tailBytes.unshift(Number(base10Number % 256n)); | ||
base10Number /= 256n; | ||
} | ||
function decode(string) { | ||
var buffer = decodeUnsafe(string); | ||
if (buffer) { | ||
return buffer; | ||
} | ||
throw new Error("Non-base" + BASE + " character"); | ||
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; | ||
} | ||
return { | ||
encode, | ||
decodeUnsafe, | ||
decode | ||
}; | ||
return [leadingZeroes + tailChars.join(""), buffer.length]; | ||
} | ||
module.exports = base; | ||
}; | ||
}; | ||
// ../../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"); | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs | ||
var removeNullCharacters = (value) => ( | ||
// eslint-disable-next-line no-control-regex | ||
value.replace(/\u0000/g, "") | ||
); | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs | ||
var utf8 = { | ||
description: "utf8", | ||
fixedSize: null, | ||
maxSize: null, | ||
serialize(value) { | ||
return new TextEncoder().encode(value); | ||
}, | ||
deserialize(buffer, offset = 0) { | ||
const value = new TextDecoder().decode(buffer.slice(offset)); | ||
return [removeNullCharacters(value), buffer.length]; | ||
} | ||
}); | ||
}; | ||
// ../../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-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs | ||
var Endian; | ||
(function(Endian2) { | ||
Endian2["Little"] = "le"; | ||
Endian2["Big"] = "be"; | ||
})(Endian || (Endian = {})); | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs | ||
var NumberOutOfRangeError = class extends RangeError { | ||
constructor(serializer, min, max, actual) { | ||
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`); | ||
__publicField(this, "name", "NumberOutOfRangeError"); | ||
} | ||
}; | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs | ||
function numberFactory(input) { | ||
let littleEndian; | ||
let defaultDescription = input.name; | ||
if (input.size > 1) { | ||
littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little; | ||
defaultDescription += littleEndian ? "(le)" : "(be)"; | ||
} | ||
return { | ||
description: input.options.description ?? defaultDescription, | ||
fixedSize: input.size, | ||
maxSize: input.size, | ||
serialize(value) { | ||
if (input.range) { | ||
assertRange(input.name, input.range[0], input.range[1], value); | ||
} | ||
const buffer = new ArrayBuffer(input.size); | ||
input.set(new DataView(buffer), value, littleEndian); | ||
return new Uint8Array(buffer); | ||
}, | ||
deserialize(bytes, offset = 0) { | ||
const slice = bytes.slice(offset, offset + input.size); | ||
assertEnoughBytes("i8", slice, input.size); | ||
const view = toDataView(slice); | ||
return [input.get(view, littleEndian), offset + input.size]; | ||
} | ||
}; | ||
} | ||
var toArrayBuffer = (array) => array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset); | ||
var toDataView = (array) => new DataView(toArrayBuffer(array)); | ||
var assertRange = (serializer, min, max, value) => { | ||
if (value < min || value > max) { | ||
throw new NumberOutOfRangeError(serializer, min, max, value); | ||
} | ||
}; | ||
var assertEnoughBytes = (serializer, bytes, expected) => { | ||
if (bytes.length === 0) { | ||
throw new DeserializingEmptyBufferError(serializer); | ||
} | ||
if (bytes.length < expected) { | ||
throw new NotEnoughBytesError(serializer, expected, bytes.length); | ||
} | ||
}; | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs | ||
var u32 = (options = {}) => numberFactory({ | ||
name: "u32", | ||
size: 4, | ||
range: [0, Number("0xffffffff")], | ||
set: (view, value, le) => view.setUint32(0, Number(value), le), | ||
get: (view, le) => view.getUint32(0, le), | ||
options | ||
}); | ||
// src/index.ts | ||
init_env_shim(); | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs | ||
function getSizeDescription(size) { | ||
return typeof size === "object" ? size.description : `${size}`; | ||
} | ||
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs | ||
function string(options = {}) { | ||
const size = options.size ?? u32(); | ||
const encoding = options.encoding ?? utf8; | ||
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`; | ||
if (size === "variable") { | ||
return { | ||
...encoding, | ||
description | ||
}; | ||
} | ||
if (typeof size === "number") { | ||
return fixSerializer(encoding, size, description); | ||
} | ||
return { | ||
description, | ||
fixedSize: null, | ||
maxSize: null, | ||
serialize: (value) => { | ||
const contentBytes = encoding.serialize(value); | ||
const lengthBytes = size.serialize(contentBytes.length); | ||
return mergeBytes([lengthBytes, contentBytes]); | ||
}, | ||
deserialize: (buffer, offset = 0) => { | ||
if (buffer.slice(offset).length === 0) { | ||
throw new DeserializingEmptyBufferError("string"); | ||
} | ||
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset); | ||
const length = Number(lengthBigInt); | ||
offset = lengthOffset; | ||
const contentBuffer = buffer.slice(offset, offset + length); | ||
if (contentBuffer.length < length) { | ||
throw new NotEnoughBytesError("string", length, contentBuffer.length); | ||
} | ||
const [value, contentOffset] = encoding.deserialize(contentBuffer); | ||
offset += contentOffset; | ||
return [value, offset]; | ||
} | ||
}; | ||
} | ||
// src/base58.ts | ||
init_env_shim(); | ||
var import_bs58 = __toESM(require_bs58(), 1); | ||
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) { | ||
@@ -197,3 +280,3 @@ try { | ||
} | ||
const bytes = import_bs58.default.decode(putativeBase58EncodedAddress); | ||
const bytes = base58.serialize(putativeBase58EncodedAddress); | ||
const numBytes = bytes.byteLength; | ||
@@ -209,4 +292,100 @@ if (numBytes !== 32) { | ||
} | ||
function getBase58EncodedAddressCodec(config) { | ||
return string({ | ||
description: config?.description ?? ("A 32-byte account address" ), | ||
encoding: base58, | ||
size: 32 | ||
}); | ||
} | ||
function getBase58EncodedAddressComparator() { | ||
return new Intl.Collator("en", { | ||
caseFirst: "lower", | ||
ignorePunctuation: false, | ||
localeMatcher: "best fit", | ||
numeric: false, | ||
sensitivity: "variant", | ||
usage: "sort" | ||
}).compare; | ||
} | ||
// src/guard.ts | ||
function assertIsSecureContext() { | ||
if (!globalThis.isSecureContext) { | ||
throw new Error( | ||
"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts" | ||
); | ||
} | ||
} | ||
var cachedEd25519Decision; | ||
async function isEd25519CurveSupported(subtle) { | ||
if (cachedEd25519Decision === void 0) { | ||
cachedEd25519Decision = new Promise((resolve) => { | ||
subtle.generateKey( | ||
"Ed25519", | ||
/* extractable */ | ||
false, | ||
["sign", "verify"] | ||
).catch(() => { | ||
resolve(cachedEd25519Decision = false); | ||
}).then(() => { | ||
resolve(cachedEd25519Decision = true); | ||
}); | ||
}); | ||
} | ||
if (typeof cachedEd25519Decision === "boolean") { | ||
return cachedEd25519Decision; | ||
} else { | ||
return await cachedEd25519Decision; | ||
} | ||
} | ||
async function assertKeyGenerationIsAvailable() { | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") { | ||
throw new Error("No key generation implementation could be found"); | ||
} | ||
if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) { | ||
throw new Error( | ||
"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20" | ||
); | ||
} | ||
} | ||
async function assertKeyExporterIsAvailable() { | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") { | ||
throw new Error("No key export implementation could be found"); | ||
} | ||
} | ||
// src/key-pair.ts | ||
async function generateKeyPair() { | ||
await assertKeyGenerationIsAvailable(); | ||
const keyPair = await crypto.subtle.generateKey( | ||
/* algorithm */ | ||
"Ed25519", | ||
// Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20 | ||
/* extractable */ | ||
false, | ||
// Prevents the bytes of the private key from being visible to JS. | ||
/* allowed uses */ | ||
["sign", "verify"] | ||
); | ||
return keyPair; | ||
} | ||
// src/pubkey.ts | ||
async function getBase58EncodedAddressFromPublicKey(publicKey) { | ||
await assertKeyExporterIsAvailable(); | ||
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") { | ||
throw new Error("The `CryptoKey` must be an `Ed25519` public key"); | ||
} | ||
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey); | ||
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes)); | ||
return base58EncodedAddress; | ||
} | ||
exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress; | ||
exports.generateKeyPair = generateKeyPair; | ||
exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec; | ||
exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator; | ||
exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey; | ||
@@ -213,0 +392,0 @@ return exports; |
@@ -1,4 +0,5 @@ | ||
import bs58 from 'bs58'; | ||
import { base58, string } from '@metaplex-foundation/umi-serializers'; | ||
// src/base58.ts | ||
// ../build-scripts/env-shim.ts | ||
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")(); | ||
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) { | ||
@@ -13,3 +14,3 @@ try { | ||
} | ||
const bytes = bs58.decode(putativeBase58EncodedAddress); | ||
const bytes = base58.serialize(putativeBase58EncodedAddress); | ||
const numBytes = bytes.byteLength; | ||
@@ -25,5 +26,86 @@ if (numBytes !== 32) { | ||
} | ||
function getBase58EncodedAddressCodec(config) { | ||
return string({ | ||
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""), | ||
encoding: base58, | ||
size: 32 | ||
}); | ||
} | ||
function getBase58EncodedAddressComparator() { | ||
return new Intl.Collator("en", { | ||
caseFirst: "lower", | ||
ignorePunctuation: false, | ||
localeMatcher: "best fit", | ||
numeric: false, | ||
sensitivity: "variant", | ||
usage: "sort" | ||
}).compare; | ||
} | ||
var cachedEd25519Decision; | ||
async function isEd25519CurveSupported(subtle) { | ||
if (cachedEd25519Decision === void 0) { | ||
cachedEd25519Decision = new Promise((resolve) => { | ||
subtle.generateKey( | ||
"Ed25519", | ||
/* extractable */ | ||
false, | ||
["sign", "verify"] | ||
).catch(() => { | ||
resolve(cachedEd25519Decision = false); | ||
}).then(() => { | ||
resolve(cachedEd25519Decision = true); | ||
}); | ||
}); | ||
} | ||
if (typeof cachedEd25519Decision === "boolean") { | ||
return cachedEd25519Decision; | ||
} else { | ||
return await cachedEd25519Decision; | ||
} | ||
} | ||
async function assertKeyGenerationIsAvailable() { | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") { | ||
throw new Error("No key generation implementation could be found"); | ||
} | ||
if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) { | ||
throw new Error( | ||
"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20" | ||
); | ||
} | ||
} | ||
async function assertKeyExporterIsAvailable() { | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") { | ||
throw new Error("No key export implementation could be found"); | ||
} | ||
} | ||
export { assertIsBase58EncodedAddress }; | ||
// src/key-pair.ts | ||
async function generateKeyPair() { | ||
await assertKeyGenerationIsAvailable(); | ||
const keyPair = await crypto.subtle.generateKey( | ||
/* algorithm */ | ||
"Ed25519", | ||
// Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20 | ||
/* extractable */ | ||
false, | ||
// Prevents the bytes of the private key from being visible to JS. | ||
/* allowed uses */ | ||
["sign", "verify"] | ||
); | ||
return keyPair; | ||
} | ||
// src/pubkey.ts | ||
async function getBase58EncodedAddressFromPublicKey(publicKey) { | ||
await assertKeyExporterIsAvailable(); | ||
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") { | ||
throw new Error("The `CryptoKey` must be an `Ed25519` public key"); | ||
} | ||
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey); | ||
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes)); | ||
return base58EncodedAddress; | ||
} | ||
export { assertIsBase58EncodedAddress, generateKeyPair, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getBase58EncodedAddressFromPublicKey }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -1,4 +0,5 @@ | ||
import bs58 from 'bs58'; | ||
import { base58, string } from '@metaplex-foundation/umi-serializers'; | ||
// src/base58.ts | ||
// ../build-scripts/env-shim.ts | ||
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")(); | ||
function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) { | ||
@@ -13,3 +14,3 @@ try { | ||
} | ||
const bytes = bs58.decode(putativeBase58EncodedAddress); | ||
const bytes = base58.serialize(putativeBase58EncodedAddress); | ||
const numBytes = bytes.byteLength; | ||
@@ -25,5 +26,86 @@ if (numBytes !== 32) { | ||
} | ||
function getBase58EncodedAddressCodec(config) { | ||
return string({ | ||
description: config?.description ?? (__DEV__ ? "A 32-byte account address" : ""), | ||
encoding: base58, | ||
size: 32 | ||
}); | ||
} | ||
function getBase58EncodedAddressComparator() { | ||
return new Intl.Collator("en", { | ||
caseFirst: "lower", | ||
ignorePunctuation: false, | ||
localeMatcher: "best fit", | ||
numeric: false, | ||
sensitivity: "variant", | ||
usage: "sort" | ||
}).compare; | ||
} | ||
var cachedEd25519Decision; | ||
async function isEd25519CurveSupported(subtle) { | ||
if (cachedEd25519Decision === void 0) { | ||
cachedEd25519Decision = new Promise((resolve) => { | ||
subtle.generateKey( | ||
"Ed25519", | ||
/* extractable */ | ||
false, | ||
["sign", "verify"] | ||
).catch(() => { | ||
resolve(cachedEd25519Decision = false); | ||
}).then(() => { | ||
resolve(cachedEd25519Decision = true); | ||
}); | ||
}); | ||
} | ||
if (typeof cachedEd25519Decision === "boolean") { | ||
return cachedEd25519Decision; | ||
} else { | ||
return await cachedEd25519Decision; | ||
} | ||
} | ||
async function assertKeyGenerationIsAvailable() { | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") { | ||
throw new Error("No key generation implementation could be found"); | ||
} | ||
if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) { | ||
throw new Error( | ||
"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20" | ||
); | ||
} | ||
} | ||
async function assertKeyExporterIsAvailable() { | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") { | ||
throw new Error("No key export implementation could be found"); | ||
} | ||
} | ||
export { assertIsBase58EncodedAddress }; | ||
// src/key-pair.ts | ||
async function generateKeyPair() { | ||
await assertKeyGenerationIsAvailable(); | ||
const keyPair = await crypto.subtle.generateKey( | ||
/* algorithm */ | ||
"Ed25519", | ||
// Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20 | ||
/* extractable */ | ||
false, | ||
// Prevents the bytes of the private key from being visible to JS. | ||
/* allowed uses */ | ||
["sign", "verify"] | ||
); | ||
return keyPair; | ||
} | ||
// src/pubkey.ts | ||
async function getBase58EncodedAddressFromPublicKey(publicKey) { | ||
await assertKeyExporterIsAvailable(); | ||
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") { | ||
throw new Error("The `CryptoKey` must be an `Ed25519` public key"); | ||
} | ||
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey); | ||
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes)); | ||
return base58EncodedAddress; | ||
} | ||
export { assertIsBase58EncodedAddress, generateKeyPair, getBase58EncodedAddressCodec, getBase58EncodedAddressComparator, getBase58EncodedAddressFromPublicKey }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
@@ -5,8 +5,16 @@ this.globalThis = this.globalThis || {}; | ||
var V=Object.create;var m=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var $=(e,r)=>()=>(e&&(r=e(e=0)),r);var z=(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 v of F(r))!B.call(e,v)&&v!==n&&m(e,v,{get:()=>r[v],enumerable:!(p=q(r,v))||p.enumerable});return e};var G=(e,r,n)=>(n=e!=null?V(T(e)):{},k(r||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e));var l=$(()=>{});var u=z((X,_)=>{l();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 v=e.charAt(p),c=v.charCodeAt(0);if(r[c]!==255)throw new TypeError(v+" is ambiguous");r[c]=p;}var b=e.length,U=e.charAt(0),D=Math.log(b)/Math.log(256),O=Math.log(256)/Math.log(b);function R(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,f=t.length;i!==f&&t[i]===0;)i++,a++;for(var s=(f-i)*O+1>>>0,o=new Uint8Array(s);i!==f;){for(var d=t[i],g=0,h=s-1;(d!==0||g<y)&&h!==-1;h--,g++)d+=256*o[h]>>>0,o[h]=d%b>>>0,d=d/b>>>0;if(d!==0)throw new Error("Non-zero carry");y=g,i++;}for(var w=s-y;w!==s&&o[w]===0;)w++;for(var A=U.repeat(a);w<s;++w)A+=e.charAt(o[w]);return A}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 f=(t.length-a)*D+1>>>0,s=new Uint8Array(f);t[a];){var o=r[t.charCodeAt(a)];if(o===255)return;for(var d=0,g=f-1;(o!==0||d<i)&&g!==-1;g--,d++)o+=b*s[g]>>>0,s[g]=o%256>>>0,o=o/256>>>0;if(o!==0)throw new Error("Non-zero carry");i=d,a++;}for(var h=f-i;h!==f&&s[h]===0;)h++;for(var w=new Uint8Array(y+(f-h)),A=y;h!==f;)w[A++]=s[h++];return w}function S(t){var a=x(t);if(a)return a;throw new Error("Non-base"+b+" character")}return {encode:R,decodeUnsafe:x,decode:S}}_.exports=I;});var N=z((Z,M)=>{l();var J=u(),K="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";M.exports=J(K);});l();l();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 U=Object.defineProperty;var k=(e,r,t)=>r in e?U(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var u=(e,r,t)=>(k(e,typeof r!="symbol"?r+"":r,t),t);var w=e=>{let r=e.reduce((n,i)=>n+i.length,0),t=new Uint8Array(r),o=0;return e.forEach(n=>{t.set(n,o),o+=n.length;}),t},I=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},y=(e,r)=>I(e.slice(0,r),r);var g=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);u(this,"name","DeserializingEmptyBufferError");}},f=class extends Error{constructor(t,o,n){super(`Serializer [${t}] expected ${o} bytes, got ${n}.`);u(this,"name","NotEnoughBytesError");}};function S(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:o=>y(e.serialize(o),r),deserialize:(o,n=0)=>{if(o=o.slice(n,n+r),o.length<r)throw new f("fixSerializer",r,o.length);e.fixedSize!==null&&(o=y(o,e.fixedSize));let[i]=e.deserialize(o,0);return [i,n+r]}}}var h=class extends Error{constructor(t,o,n){let i=`Expected a string of base ${o}, got [${t}].`;super(i);u(this,"name","InvalidBaseStringError");this.cause=n;}};var C=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(o){if(!o.match(new RegExp(`^[${e}]*$`)))throw new h(o,r);if(o==="")return new Uint8Array;let n=[...o],i=n.findIndex(d=>d!==e[0]);i=i===-1?n.length:i;let a=Array(i).fill(0);if(i===n.length)return Uint8Array.from(a);let m=n.slice(i),l=0n,c=1n;for(let d=m.length-1;d>=0;d-=1)l+=c*BigInt(e.indexOf(m[d])),c*=t;let p=[];for(;l>0n;)p.unshift(Number(l%256n)),l/=256n;return Uint8Array.from(a.concat(p))},deserialize(o,n=0){if(o.length===0)return ["",0];let i=o.slice(n),a=i.findIndex(p=>p!==0);a=a===-1?i.length:a;let m=e[0].repeat(a);if(a===i.length)return [m,o.length];let l=i.slice(a).reduce((p,d)=>p*256n+BigInt(d),0n),c=[];for(;l>0n;)c.unshift(e[Number(l%t)]),l/=t;return [m+c.join(""),o.length]}}};var E=C("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var N=e=>e.replace(/\u0000/g,"");var A={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let t=new TextDecoder().decode(e.slice(r));return [N(t),e.length]}};var b;(function(e){e.Little="le",e.Big="be";})(b||(b={}));var z=class extends RangeError{constructor(t,o,n,i){super(`Serializer [${t}] expected number to be between ${o} and ${n}, got ${i}.`);u(this,"name","NumberOutOfRangeError");}};function $(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===b.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(o){e.range&&L(e.name,e.range[0],e.range[1],o);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),o,r),new Uint8Array(n)},deserialize(o,n=0){let i=o.slice(n,n+e.size);V("i8",i,e.size);let a=R(i);return [e.get(a,r),n+e.size]}}}var O=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),R=e=>new DataView(O(e)),L=(e,r,t,o)=>{if(o<r||o>t)throw new z(e,r,t,o)},V=(e,r,t)=>{if(r.length===0)throw new g(e);if(r.length<t)throw new f(e,t,r.length)};var B=(e={})=>$({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,o)=>r.setUint32(0,Number(t),o),get:(r,t)=>r.getUint32(0,t),options:e});function D(e){return typeof e=="object"?e.description:`${e}`}function v(e={}){let r=e.size??B(),t=e.encoding??A,o=e.description??`string(${t.description}; ${D(r)})`;return r==="variable"?{...t,description:o}:typeof r=="number"?S(t,r,o):{description:o,fixedSize:null,maxSize:null,serialize:n=>{let i=t.serialize(n),a=r.serialize(i.length);return w([a,i])},deserialize:(n,i=0)=>{if(n.slice(i).length===0)throw new g("string");let[a,m]=r.deserialize(n,i),l=Number(a);i=m;let c=n.slice(i,i+l);if(c.length<l)throw new f("string",l,c.length);let[p,d]=t.deserialize(c);return i+=d,[p,i]}}}function tr(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=E.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 T(e){return v({description:e?.description??"",encoding:E,size:32})}function or(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function K(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}var x;async function F(e){return x===void 0&&(x=new Promise(r=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{r(x=!1);}).then(()=>{r(x=!0);});})),typeof x=="boolean"?x:await x}async function _(){if(K(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!="function")throw new Error("No key generation implementation could be found");if(!await F(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs. | ||
exports.assertIsBase58EncodedAddress = L; | ||
Install and import \`@solana/webcrypto-ed25519-polyfill\` before generating keys in environments that do not support Ed25519. | ||
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function P(){if(K(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function cr(){return await _(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function gr(e){if(await P(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let r=await crypto.subtle.exportKey("raw",e),[t]=T().deserialize(new Uint8Array(r));return t} | ||
exports.assertIsBase58EncodedAddress = tr; | ||
exports.generateKeyPair = cr; | ||
exports.getBase58EncodedAddressCodec = T; | ||
exports.getBase58EncodedAddressComparator = or; | ||
exports.getBase58EncodedAddressFromPublicKey = gr; | ||
return exports; | ||
})({}); |
@@ -1,5 +0,10 @@ | ||
export type Base58EncodedAddress = string & { | ||
import { Serializer } from '@metaplex-foundation/umi-serializers'; | ||
export type Base58EncodedAddress<TAddress extends string = string> = TAddress & { | ||
readonly __base58EncodedAddress: unique symbol; | ||
}; | ||
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress; | ||
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>; | ||
export declare function getBase58EncodedAddressCodec(config?: Readonly<{ | ||
description: string; | ||
}>): Serializer<Base58EncodedAddress>; | ||
export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number; | ||
//# sourceMappingURL=base58.d.ts.map |
export * from './base58'; | ||
export * from './key-pair'; | ||
export * from './pubkey'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@solana/keys", | ||
"version": "2.0.0-experimental.982fafd", | ||
"version": "2.0.0-experimental.9b5eac4", | ||
"description": "Helpers for generating and transforming key material", | ||
@@ -48,23 +48,29 @@ "exports": { | ||
], | ||
"engine": { | ||
"node": ">=17.4" | ||
}, | ||
"dependencies": { | ||
"@metaplex-foundation/umi-serializers": "^0.8.2" | ||
}, | ||
"devDependencies": { | ||
"@solana/eslint-config-solana": "^1.0.0", | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/core": "^1.3.18", | ||
"@swc/jest": "^0.2.23", | ||
"@types/jest": "^29.5.0", | ||
"@typescript-eslint/eslint-plugin": "^5.57.1", | ||
"@typescript-eslint/parser": "^5.57.1", | ||
"@swc/jest": "^0.2.26", | ||
"@types/jest": "^29.5.2", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"agadoo": "^3.0.0", | ||
"eslint": "^8.37.0", | ||
"eslint-plugin-jest": "^27.1.5", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-jest": "^27.2.3", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"jest": "^29.5.0", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"jest-runner-eslint": "^2.0.0", | ||
"jest": "^29.6.1", | ||
"jest-environment-jsdom": "^29.6.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.1.6", | ||
"version-from-git": "^1.1.1", | ||
@@ -83,5 +89,2 @@ "build-scripts": "0.0.0", | ||
}, | ||
"dependencies": { | ||
"bs58": "^5.0.0" | ||
}, | ||
"scripts": { | ||
@@ -88,0 +91,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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
136647
22
1089
0
73
1
+ Added@metaplex-foundation/umi-options@0.8.9(transitive)
+ Added@metaplex-foundation/umi-public-keys@0.8.9(transitive)
+ Added@metaplex-foundation/umi-serializers@0.8.9(transitive)
+ Added@metaplex-foundation/umi-serializers-core@0.8.9(transitive)
+ Added@metaplex-foundation/umi-serializers-encodings@0.8.9(transitive)
+ Added@metaplex-foundation/umi-serializers-numbers@0.8.9(transitive)
- Removedbs58@^5.0.0
- Removedbase-x@4.0.0(transitive)
- Removedbs58@5.0.0(transitive)