@solana/keys 2.0.0-experimental.021b83f → 2.0.0-experimental.02a66ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ [![npm][npm-image]][npm-url]
2
+ [![npm-downloads][npm-downloads-image]][npm-url]
3
+ [![semantic-release][semantic-release-image]][semantic-release-url]
4
+ <br />
5
+ [![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
6
+
7
+ [code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
8
+ [code-style-prettier-url]: https://github.com/prettier/prettier
9
+ [npm-downloads-image]: https://img.shields.io/npm/dm/@solana/keys/experimental.svg?style=flat
10
+ [npm-image]: https://img.shields.io/npm/v/@solana/keys/experimental.svg?style=flat
11
+ [npm-url]: https://www.npmjs.com/package/@solana/keys/v/experimental
12
+ [semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
13
+ [semantic-release-url]: https://github.com/semantic-release/semantic-release
14
+
15
+ # @solana/keys
16
+
17
+ This package contains utilities for validating, generating, and manipulating addresses and key material. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
18
+
19
+ ## Types
20
+
21
+ ### `Base58EncodedAddress`
22
+
23
+ This type represents a string that validates as a Solana address or public key. Functions that require well-formed addresses should specify their inputs in terms of this type.
24
+
25
+ Whenever you need to validate an arbitrary string as a base58-encoded address, use the `assertIsBase58EncodedAddress()` function in this package.
26
+
27
+ ## Functions
28
+
29
+ ### `assertIsBase58EncodedAddress()`
30
+
31
+ Client applications primarily deal with addresses and public keys in the form of base58-encoded strings. Addresses and public keys returned from the RPC API conform to the type `Base58EncodedAddress`. You can use a value of that type wherever a base58-encoded address or key is expected.
32
+
33
+ From time to time you might acquire a string, that you expect to validate as an address, from an untrusted network API or user input. To assert that such an arbitrary string is a base58-encoded address, use the `assertIsBase58EncodedAddress` function.
34
+
35
+ ```ts
36
+ import { assertIsBase58EncodedAddress } from '@solana/web3.js`;
37
+
38
+ // Imagine a function that fetches an account's balance when a user submits a form.
39
+ function handleSubmit() {
40
+ // We know only that what the user typed conforms to the `string` type.
41
+ const address: string = accountAddressInput.value;
42
+ try {
43
+ // If this type assertion function doesn't throw, then
44
+ // Typescript will upcast `address` to `Base58EncodedAddress`.
45
+ assertIsBase58EncodedAddress(address);
46
+ // At this point, `address` is a `Base58EncodedAddress` that can be used with the RPC.
47
+ const balanceInLamports = await rpc.getBalance(address).send();
48
+ } catch (e) {
49
+ // `address` turned out not to be a base58-encoded address
50
+ }
51
+ }
52
+ ```
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var bs58 = require('bs58');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var bs58__default = /*#__PURE__*/_interopDefault(bs58);
3
+ var umiSerializersEncodings = require('@metaplex-foundation/umi-serializers-encodings');
8
4
 
9
5
  // src/base58.ts
10
6
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
@@ -16,7 +12,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
16
12
  ) {
17
13
  throw new Error("Expected input string to decode to a byte array of length 32.");
18
14
  }
19
- const bytes = bs58__default.default.decode(putativeBase58EncodedAddress);
15
+ const bytes = umiSerializersEncodings.base58.serialize(putativeBase58EncodedAddress);
20
16
  const numBytes = bytes.byteLength;
21
17
  if (numBytes !== 32) {
22
18
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -27,7 +23,18 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
27
23
  });
28
24
  }
29
25
  }
26
+ function getBase58EncodedAddressComparator() {
27
+ return new Intl.Collator("en", {
28
+ caseFirst: "lower",
29
+ ignorePunctuation: false,
30
+ localeMatcher: "best fit",
31
+ numeric: false,
32
+ sensitivity: "variant",
33
+ usage: "sort"
34
+ }).compare;
35
+ }
30
36
 
31
37
  exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
38
+ exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
32
39
  //# sourceMappingURL=out.js.map
33
40
  //# sourceMappingURL=index.browser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU;AAIV,SAAS,6BACZ,8BAC4D;AAC5D,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,KAAK,OAAO,4BAA4B;AACtD,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ","sourcesContent":["import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = bs58.decode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import bs58 from 'bs58';
1
+ import { base58 } from '@metaplex-foundation/umi-serializers-encodings';
2
2
 
3
3
  // src/base58.ts
4
4
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
@@ -10,7 +10,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
10
10
  ) {
11
11
  throw new Error("Expected input string to decode to a byte array of length 32.");
12
12
  }
13
- const bytes = bs58.decode(putativeBase58EncodedAddress);
13
+ const bytes = base58.serialize(putativeBase58EncodedAddress);
14
14
  const numBytes = bytes.byteLength;
15
15
  if (numBytes !== 32) {
16
16
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -21,7 +21,17 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
21
21
  });
22
22
  }
23
23
  }
24
+ function getBase58EncodedAddressComparator() {
25
+ return new Intl.Collator("en", {
26
+ caseFirst: "lower",
27
+ ignorePunctuation: false,
28
+ localeMatcher: "best fit",
29
+ numeric: false,
30
+ sensitivity: "variant",
31
+ usage: "sort"
32
+ }).compare;
33
+ }
24
34
 
25
- export { assertIsBase58EncodedAddress };
35
+ export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
26
36
  //# sourceMappingURL=out.js.map
27
37
  //# sourceMappingURL=index.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU;AAIV,SAAS,6BACZ,8BAC4D;AAC5D,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,KAAK,OAAO,4BAA4B;AACtD,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ","sourcesContent":["import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = bs58.decode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
@@ -2,188 +2,81 @@ this.globalThis = this.globalThis || {};
2
2
  this.globalThis.solanaWeb3 = (function (exports) {
3
3
  'use strict';
4
4
 
5
- var __create = Object.create;
6
5
  var __defProp = Object.defineProperty;
7
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
- var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __esm = (fn, res) => function __init() {
12
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __publicField = (obj, key, value) => {
8
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ return value;
13
10
  };
14
- var __commonJS = (cb, mod) => function __require() {
15
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
- // If the importer is in node compatibility mode or this is not an ESM
27
- // file that has been converted to a CommonJS file using a Babel-
28
- // compatible transform (i.e. "__esModule" has not been set), then set
29
- // "default" to the CommonJS "module.exports" for node compatibility.
30
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
- mod
32
- ));
33
11
 
34
- // ../build-scripts/env-shim.ts
35
- var init_env_shim = __esm({
36
- "../build-scripts/env-shim.ts"() {
12
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
13
+ var InvalidBaseStringError = class extends Error {
14
+ constructor(value, base, cause) {
15
+ const message = `Expected a string of base ${base}, got [${value}].`;
16
+ super(message);
17
+ __publicField(this, "name", "InvalidBaseStringError");
18
+ this.cause = cause;
37
19
  }
38
- });
20
+ };
39
21
 
40
- // ../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js
41
- var require_src = __commonJS({
42
- "../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js"(exports, module) {
43
- init_env_shim();
44
- function base(ALPHABET) {
45
- if (ALPHABET.length >= 255) {
46
- throw new TypeError("Alphabet too long");
47
- }
48
- var BASE_MAP = new Uint8Array(256);
49
- for (var j = 0; j < BASE_MAP.length; j++) {
50
- BASE_MAP[j] = 255;
51
- }
52
- for (var i = 0; i < ALPHABET.length; i++) {
53
- var x = ALPHABET.charAt(i);
54
- var xc = x.charCodeAt(0);
55
- if (BASE_MAP[xc] !== 255) {
56
- throw new TypeError(x + " is ambiguous");
57
- }
58
- BASE_MAP[xc] = i;
22
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
23
+ var baseX = (alphabet) => {
24
+ const base = alphabet.length;
25
+ const baseBigInt = BigInt(base);
26
+ return {
27
+ description: `base${base}`,
28
+ fixedSize: null,
29
+ maxSize: null,
30
+ serialize(value) {
31
+ if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
32
+ throw new InvalidBaseStringError(value, base);
59
33
  }
60
- var BASE = ALPHABET.length;
61
- var LEADER = ALPHABET.charAt(0);
62
- var FACTOR = Math.log(BASE) / Math.log(256);
63
- var iFACTOR = Math.log(256) / Math.log(BASE);
64
- function encode(source) {
65
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
66
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
67
- } else if (Array.isArray(source)) {
68
- source = Uint8Array.from(source);
69
- }
70
- if (!(source instanceof Uint8Array)) {
71
- throw new TypeError("Expected Uint8Array");
72
- }
73
- if (source.length === 0) {
74
- return "";
75
- }
76
- var zeroes = 0;
77
- var length = 0;
78
- var pbegin = 0;
79
- var pend = source.length;
80
- while (pbegin !== pend && source[pbegin] === 0) {
81
- pbegin++;
82
- zeroes++;
83
- }
84
- var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
85
- var b58 = new Uint8Array(size);
86
- while (pbegin !== pend) {
87
- var carry = source[pbegin];
88
- var i2 = 0;
89
- for (var it1 = size - 1; (carry !== 0 || i2 < length) && it1 !== -1; it1--, i2++) {
90
- carry += 256 * b58[it1] >>> 0;
91
- b58[it1] = carry % BASE >>> 0;
92
- carry = carry / BASE >>> 0;
93
- }
94
- if (carry !== 0) {
95
- throw new Error("Non-zero carry");
96
- }
97
- length = i2;
98
- pbegin++;
99
- }
100
- var it2 = size - length;
101
- while (it2 !== size && b58[it2] === 0) {
102
- it2++;
103
- }
104
- var str = LEADER.repeat(zeroes);
105
- for (; it2 < size; ++it2) {
106
- str += ALPHABET.charAt(b58[it2]);
107
- }
108
- return str;
34
+ if (value === "")
35
+ return new Uint8Array();
36
+ const chars = [...value];
37
+ let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
38
+ trailIndex = trailIndex === -1 ? chars.length : trailIndex;
39
+ const leadingZeroes = Array(trailIndex).fill(0);
40
+ if (trailIndex === chars.length)
41
+ return Uint8Array.from(leadingZeroes);
42
+ const tailChars = chars.slice(trailIndex);
43
+ let base10Number = 0n;
44
+ let baseXPower = 1n;
45
+ for (let i = tailChars.length - 1; i >= 0; i -= 1) {
46
+ base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
47
+ baseXPower *= baseBigInt;
109
48
  }
110
- function decodeUnsafe(source) {
111
- if (typeof source !== "string") {
112
- throw new TypeError("Expected String");
113
- }
114
- if (source.length === 0) {
115
- return new Uint8Array();
116
- }
117
- var psz = 0;
118
- var zeroes = 0;
119
- var length = 0;
120
- while (source[psz] === LEADER) {
121
- zeroes++;
122
- psz++;
123
- }
124
- var size = (source.length - psz) * FACTOR + 1 >>> 0;
125
- var b256 = new Uint8Array(size);
126
- while (source[psz]) {
127
- var carry = BASE_MAP[source.charCodeAt(psz)];
128
- if (carry === 255) {
129
- return;
130
- }
131
- var i2 = 0;
132
- for (var it3 = size - 1; (carry !== 0 || i2 < length) && it3 !== -1; it3--, i2++) {
133
- carry += BASE * b256[it3] >>> 0;
134
- b256[it3] = carry % 256 >>> 0;
135
- carry = carry / 256 >>> 0;
136
- }
137
- if (carry !== 0) {
138
- throw new Error("Non-zero carry");
139
- }
140
- length = i2;
141
- psz++;
142
- }
143
- var it4 = size - length;
144
- while (it4 !== size && b256[it4] === 0) {
145
- it4++;
146
- }
147
- var vch = new Uint8Array(zeroes + (size - it4));
148
- var j2 = zeroes;
149
- while (it4 !== size) {
150
- vch[j2++] = b256[it4++];
151
- }
152
- return vch;
49
+ const tailBytes = [];
50
+ while (base10Number > 0n) {
51
+ tailBytes.unshift(Number(base10Number % 256n));
52
+ base10Number /= 256n;
153
53
  }
154
- function decode(string) {
155
- var buffer = decodeUnsafe(string);
156
- if (buffer) {
157
- return buffer;
158
- }
159
- throw new Error("Non-base" + BASE + " character");
54
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
55
+ },
56
+ deserialize(buffer, offset = 0) {
57
+ if (buffer.length === 0)
58
+ return ["", 0];
59
+ const bytes = buffer.slice(offset);
60
+ let trailIndex = bytes.findIndex((n) => n !== 0);
61
+ trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
62
+ const leadingZeroes = alphabet[0].repeat(trailIndex);
63
+ if (trailIndex === bytes.length)
64
+ return [leadingZeroes, buffer.length];
65
+ let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
66
+ const tailChars = [];
67
+ while (base10Number > 0n) {
68
+ tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
69
+ base10Number /= baseBigInt;
160
70
  }
161
- return {
162
- encode,
163
- decodeUnsafe,
164
- decode
165
- };
71
+ return [leadingZeroes + tailChars.join(""), buffer.length];
166
72
  }
167
- module.exports = base;
168
- }
169
- });
170
-
171
- // ../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js
172
- var require_bs58 = __commonJS({
173
- "../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js"(exports, module) {
174
- init_env_shim();
175
- var basex = require_src();
176
- var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
177
- module.exports = basex(ALPHABET);
178
- }
179
- });
73
+ };
74
+ };
180
75
 
181
- // src/index.ts
182
- init_env_shim();
76
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
77
+ var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
183
78
 
184
79
  // src/base58.ts
185
- init_env_shim();
186
- var import_bs58 = __toESM(require_bs58(), 1);
187
80
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
188
81
  try {
189
82
  if (
@@ -193,7 +86,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
193
86
  ) {
194
87
  throw new Error("Expected input string to decode to a byte array of length 32.");
195
88
  }
196
- const bytes = import_bs58.default.decode(putativeBase58EncodedAddress);
89
+ const bytes = base58.serialize(putativeBase58EncodedAddress);
197
90
  const numBytes = bytes.byteLength;
198
91
  if (numBytes !== 32) {
199
92
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -204,8 +97,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
204
97
  });
205
98
  }
206
99
  }
100
+ function getBase58EncodedAddressComparator() {
101
+ return new Intl.Collator("en", {
102
+ caseFirst: "lower",
103
+ ignorePunctuation: false,
104
+ localeMatcher: "best fit",
105
+ numeric: false,
106
+ sensitivity: "variant",
107
+ usage: "sort"
108
+ }).compare;
109
+ }
207
110
 
208
111
  exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
112
+ exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
209
113
 
210
114
  return exports;
211
115
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../build-scripts/env-shim.ts","../../../node_modules/.pnpm/base-x@4.0.0/node_modules/base-x/src/index.js","../../../node_modules/.pnpm/bs58@5.0.0/node_modules/bs58/index.js","../src/index.ts","../src/base58.ts"],"names":["i","j","bs58"],"mappings":"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","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","'use strict'\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n var BASE_MAP = new Uint8Array(256)\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i)\n var xc = x.charCodeAt(0)\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i\n }\n var BASE = ALPHABET.length\n var LEADER = ALPHABET.charAt(0)\n var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up\n function encode (source) {\n if (source instanceof Uint8Array) {\n } else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength)\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source)\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n var zeroes = 0\n var length = 0\n var pbegin = 0\n var pend = source.length\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++\n zeroes++\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0\n var b58 = new Uint8Array(size)\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin]\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0\n b58[it1] = (carry % BASE) >>> 0\n carry = (carry / BASE) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n pbegin++\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length\n while (it2 !== size && b58[it2] === 0) {\n it2++\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes)\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n var psz = 0\n // Skip and count leading '1's.\n var zeroes = 0\n var length = 0\n while (source[psz] === LEADER) {\n zeroes++\n psz++\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size)\n // Process the characters.\n while (source[psz]) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)]\n // Invalid character\n if (carry === 255) { return }\n var i = 0\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0\n b256[it3] = (carry % 256) >>> 0\n carry = (carry / 256) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n psz++\n }\n // Skip leading zeroes in b256.\n var it4 = size - length\n while (it4 !== size && b256[it4] === 0) {\n it4++\n }\n var vch = new Uint8Array(zeroes + (size - it4))\n var j = zeroes\n while (it4 !== size) {\n vch[j++] = b256[it4++]\n }\n return vch\n }\n function decode (string) {\n var buffer = decodeUnsafe(string)\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n }\n}\nmodule.exports = base\n","const basex = require('base-x')\nconst ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n\nmodule.exports = basex(ALPHABET)\n","export * from './base58';\n","import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = bs58.decode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/errors.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/baseX.ts","../../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/src/base58.ts","../src/base58.ts"],"names":["InvalidBaseStringError","Error","constructor","value","base","cause","message","name","baseX","alphabet","length","baseBigInt","BigInt","description","fixedSize","maxSize","serialize","match","RegExp","Uint8Array","chars","trailIndex","findIndex","c","leadingZeroes","Array","fill","from","tailChars","slice","base10Number","baseXPower","i","indexOf","tailBytes","unshift","Number","concat","deserialize","buffer","offset","bytes","n","repeat","reduce","sum","byte","join","base58"],"mappings":"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","sourcesContent":["/** @category Errors */\nexport class InvalidBaseStringError extends Error {\n readonly name: string = 'InvalidBaseStringError';\n\n readonly cause?: Error;\n\n constructor(value: string, base: number, cause?: Error) {\n const message = `Expected a string of base ${base}, got [${value}].`;\n super(message);\n this.cause = cause;\n }\n}\n","import type { Serializer } from '@metaplex-foundation/umi-serializers-core';\nimport { InvalidBaseStringError } from './errors';\n\n/**\n * A string serializer that uses a custom alphabet.\n * This can be used to create serializers for base58, base64, etc.\n * @category Serializers\n */\nexport const baseX = (alphabet: string): Serializer<string> => {\n const base = alphabet.length;\n const baseBigInt = BigInt(base);\n return {\n description: `base${base}`,\n fixedSize: null,\n maxSize: null,\n serialize(value: string): Uint8Array {\n // Check if the value is valid.\n if (!value.match(new RegExp(`^[${alphabet}]*$`))) {\n throw new InvalidBaseStringError(value, base);\n }\n if (value === '') return new Uint8Array();\n\n // Handle leading zeroes.\n const chars = [...value];\n let trailIndex = chars.findIndex((c) => c !== alphabet[0]);\n trailIndex = trailIndex === -1 ? chars.length : trailIndex;\n const leadingZeroes = Array(trailIndex).fill(0);\n if (trailIndex === chars.length) return Uint8Array.from(leadingZeroes);\n\n // From baseX to base10.\n const tailChars = chars.slice(trailIndex);\n let base10Number = 0n;\n let baseXPower = 1n;\n for (let i = tailChars.length - 1; i >= 0; i -= 1) {\n base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));\n baseXPower *= baseBigInt;\n }\n\n // From base10 to bytes.\n const tailBytes = [];\n while (base10Number > 0n) {\n tailBytes.unshift(Number(base10Number % 256n));\n base10Number /= 256n;\n }\n return Uint8Array.from(leadingZeroes.concat(tailBytes));\n },\n deserialize(buffer, offset = 0): [string, number] {\n if (buffer.length === 0) return ['', 0];\n\n // Handle leading zeroes.\n const bytes = buffer.slice(offset);\n let trailIndex = bytes.findIndex((n) => n !== 0);\n trailIndex = trailIndex === -1 ? bytes.length : trailIndex;\n const leadingZeroes = alphabet[0].repeat(trailIndex);\n if (trailIndex === bytes.length) return [leadingZeroes, buffer.length];\n\n // From bytes to base10.\n let base10Number = bytes\n .slice(trailIndex)\n .reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);\n\n // From base10 to baseX.\n const tailChars = [];\n while (base10Number > 0n) {\n tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);\n base10Number /= baseBigInt;\n }\n\n return [leadingZeroes + tailChars.join(''), buffer.length];\n },\n };\n};\n","import type { Serializer } from '@metaplex-foundation/umi-serializers-core';\nimport { baseX } from './baseX';\n\n/**\n * A string serializer that uses base58 encoding.\n * @category Serializers\n */\nexport const base58: Serializer<string> = baseX(\n '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n);\n","import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import bs58 from 'bs58';
1
+ import { base58 } from '@metaplex-foundation/umi-serializers-encodings';
2
2
 
3
3
  // src/base58.ts
4
4
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
@@ -10,7 +10,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
10
10
  ) {
11
11
  throw new Error("Expected input string to decode to a byte array of length 32.");
12
12
  }
13
- const bytes = bs58.decode(putativeBase58EncodedAddress);
13
+ const bytes = base58.serialize(putativeBase58EncodedAddress);
14
14
  const numBytes = bytes.byteLength;
15
15
  if (numBytes !== 32) {
16
16
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -21,7 +21,17 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
21
21
  });
22
22
  }
23
23
  }
24
+ function getBase58EncodedAddressComparator() {
25
+ return new Intl.Collator("en", {
26
+ caseFirst: "lower",
27
+ ignorePunctuation: false,
28
+ localeMatcher: "best fit",
29
+ numeric: false,
30
+ sensitivity: "variant",
31
+ usage: "sort"
32
+ }).compare;
33
+ }
24
34
 
25
- export { assertIsBase58EncodedAddress };
35
+ export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
26
36
  //# sourceMappingURL=out.js.map
27
37
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU;AAIV,SAAS,6BACZ,8BAC4D;AAC5D,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,KAAK,OAAO,4BAA4B;AACtD,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ","sourcesContent":["import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = bs58.decode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var bs58 = require('bs58');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var bs58__default = /*#__PURE__*/_interopDefault(bs58);
3
+ var umiSerializersEncodings = require('@metaplex-foundation/umi-serializers-encodings');
8
4
 
9
5
  // src/base58.ts
10
6
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
@@ -16,7 +12,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
16
12
  ) {
17
13
  throw new Error("Expected input string to decode to a byte array of length 32.");
18
14
  }
19
- const bytes = bs58__default.default.decode(putativeBase58EncodedAddress);
15
+ const bytes = umiSerializersEncodings.base58.serialize(putativeBase58EncodedAddress);
20
16
  const numBytes = bytes.byteLength;
21
17
  if (numBytes !== 32) {
22
18
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -27,7 +23,18 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
27
23
  });
28
24
  }
29
25
  }
26
+ function getBase58EncodedAddressComparator() {
27
+ return new Intl.Collator("en", {
28
+ caseFirst: "lower",
29
+ ignorePunctuation: false,
30
+ localeMatcher: "best fit",
31
+ numeric: false,
32
+ sensitivity: "variant",
33
+ usage: "sort"
34
+ }).compare;
35
+ }
30
36
 
31
37
  exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
38
+ exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
32
39
  //# sourceMappingURL=out.js.map
33
40
  //# sourceMappingURL=index.node.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU;AAIV,SAAS,6BACZ,8BAC4D;AAC5D,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,KAAK,OAAO,4BAA4B;AACtD,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ","sourcesContent":["import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = bs58.decode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import bs58 from 'bs58';
1
+ import { base58 } from '@metaplex-foundation/umi-serializers-encodings';
2
2
 
3
3
  // src/base58.ts
4
4
  function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
@@ -10,7 +10,7 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
10
10
  ) {
11
11
  throw new Error("Expected input string to decode to a byte array of length 32.");
12
12
  }
13
- const bytes = bs58.decode(putativeBase58EncodedAddress);
13
+ const bytes = base58.serialize(putativeBase58EncodedAddress);
14
14
  const numBytes = bytes.byteLength;
15
15
  if (numBytes !== 32) {
16
16
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -21,7 +21,17 @@ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
21
21
  });
22
22
  }
23
23
  }
24
+ function getBase58EncodedAddressComparator() {
25
+ return new Intl.Collator("en", {
26
+ caseFirst: "lower",
27
+ ignorePunctuation: false,
28
+ localeMatcher: "best fit",
29
+ numeric: false,
30
+ sensitivity: "variant",
31
+ usage: "sort"
32
+ }).compare;
33
+ }
24
34
 
25
- export { assertIsBase58EncodedAddress };
35
+ export { assertIsBase58EncodedAddress, getBase58EncodedAddressComparator };
26
36
  //# sourceMappingURL=out.js.map
27
37
  //# sourceMappingURL=index.node.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU;AAIV,SAAS,6BACZ,8BAC4D;AAC5D,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,KAAK,OAAO,4BAA4B;AACtD,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ","sourcesContent":["import bs58 from 'bs58';\n\nexport type Base58EncodedAddress = string & { readonly __base58EncodedAddress: unique symbol };\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = bs58.decode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/base58.ts"],"names":[],"mappings":";AAAA,SAAS,cAAc;AAMhB,SAAS,6BACZ,8BACiG;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,6BAA6B,SAAS;AAAA,MAEtC,6BAA6B,SAAS;AAAA,MACxC;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAM,QAAQ,OAAO,UAAU,4BAA4B;AAC3D,UAAM,WAAW,MAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,UAAU;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAP;AACE,UAAM,IAAI,MAAM,KAAK,mEAAmE;AAAA,MACpF,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,oCAAsE;AAClF,SAAO,IAAI,KAAK,SAAS,MAAM;AAAA,IAC3B,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,SAAS;AAAA,IACT,aAAa;AAAA,IACb,OAAO;AAAA,EACX,CAAC,EAAE;AACP","sourcesContent":["import { base58 } from '@metaplex-foundation/umi-serializers-encodings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __base58EncodedAddress: unique symbol;\n};\n\nexport function assertIsBase58EncodedAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function getBase58EncodedAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n"]}
@@ -2,9 +2,10 @@ this.globalThis = this.globalThis || {};
2
2
  this.globalThis.solanaWeb3 = (function (exports) {
3
3
  'use strict';
4
4
 
5
- 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})}}
5
+ 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}
6
6
 
7
- exports.assertIsBase58EncodedAddress = L;
7
+ exports.assertIsBase58EncodedAddress = D;
8
+ exports.getBase58EncodedAddressComparator = P;
8
9
 
9
10
  return exports;
10
11
 
@@ -1,5 +1,6 @@
1
- export type Base58EncodedAddress = string & {
1
+ export type Base58EncodedAddress<TAddress extends string = string> = TAddress & {
2
2
  readonly __base58EncodedAddress: unique symbol;
3
3
  };
4
- export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress;
4
+ export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
5
+ export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number;
5
6
  //# sourceMappingURL=base58.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,sBAAsB,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAE/F,wBAAgB,4BAA4B,CACxC,4BAA4B,EAAE,MAAM,GACrC,OAAO,CAAC,4BAA4B,IAAI,oBAAoB,CAsB9D"}
1
+ {"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,GAAG;IAC5E,QAAQ,CAAC,sBAAsB,EAAE,OAAO,MAAM,CAAC;CAClD,CAAC;AAEF,wBAAgB,4BAA4B,CACxC,4BAA4B,EAAE,MAAM,GACrC,OAAO,CAAC,4BAA4B,IAAI,oBAAoB,CAAC,OAAO,4BAA4B,CAAC,CAsBnG;AAED,wBAAgB,iCAAiC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CASpF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/keys",
3
- "version": "2.0.0-experimental.021b83f",
3
+ "version": "2.0.0-experimental.02a66ef",
4
4
  "description": "Helpers for generating and transforming key material",
5
5
  "exports": {
6
6
  "browser": {
@@ -45,11 +45,14 @@
45
45
  "supports bigint and not dead",
46
46
  "maintained node versions"
47
47
  ],
48
+ "dependencies": {
49
+ "@metaplex-foundation/umi-serializers-encodings": "^0.8.2"
50
+ },
48
51
  "devDependencies": {
49
- "@solana/eslint-config-solana": "^1.0.0",
52
+ "@solana/eslint-config-solana": "^1.0.1",
50
53
  "@swc/core": "^1.3.18",
51
- "@swc/jest": "^0.2.23",
52
- "@types/jest": "^29.5.0",
54
+ "@swc/jest": "^0.2.26",
55
+ "@types/jest": "^29.5.1",
53
56
  "@typescript-eslint/eslint-plugin": "^5.57.1",
54
57
  "@typescript-eslint/parser": "^5.57.1",
55
58
  "agadoo": "^3.0.0",
@@ -59,14 +62,13 @@
59
62
  "eslint-plugin-sort-keys-fix": "^1.1.2",
60
63
  "jest": "^29.5.0",
61
64
  "jest-environment-jsdom": "^29.5.0",
62
- "jest-runner-eslint": "^2.0.0",
65
+ "jest-runner-eslint": "^2.1.0",
63
66
  "jest-runner-prettier": "^1.0.0",
64
67
  "postcss": "^8.4.12",
65
- "prettier": "^2.7.1",
68
+ "prettier": "^2.8.8",
66
69
  "ts-node": "^10.9.1",
67
70
  "tsup": "6.7.0",
68
- "turbo": "^1.6.3",
69
- "typescript": "^5.0.3",
71
+ "typescript": "^5.0.4",
70
72
  "version-from-git": "^1.1.1",
71
73
  "build-scripts": "0.0.0",
72
74
  "test-config": "0.0.0",
@@ -80,9 +82,6 @@
80
82
  }
81
83
  ]
82
84
  },
83
- "dependencies": {
84
- "bs58": "^5.0.0"
85
- },
86
85
  "scripts": {
87
86
  "compile:js": "tsup --config build-scripts/tsup.config.library.ts",
88
87
  "compile:typedefs": "tsc -p ./tsconfig.declarations.json",