@solana/keys 2.0.0-experimental.eefafdf → 2.0.0-experimental.f07dced
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 +51 -1
- package/dist/index.browser.cjs +114 -7
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +110 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +355 -162
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +97 -4
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +101 -7
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +97 -4
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +12 -3
- package/dist/types/base58.d.ts +4 -0
- package/dist/types/guard.d.ts +5 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/key-pair.d.ts +2 -0
- package/dist/types/pubkey.d.ts +3 -0
- package/dist/types/signatures.d.ts +6 -0
- package/package.json +16 -13
|
@@ -2,10 +2,19 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var O=Object.
|
|
5
|
+
var O=Object.defineProperty;var R=(e,r,t)=>r in e?O(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var m=(e,r,t)=>(R(e,typeof r!="symbol"?r+"":r,t),t);var S=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},x=(e,r)=>I(e.slice(0,r),r);var g=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);m(this,"name","DeserializingEmptyBufferError");}},p=class extends Error{constructor(t,o,n){super(`Serializer [${t}] expected ${o} bytes, got ${n}.`);m(this,"name","NotEnoughBytesError");}};function A(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:o=>x(e.serialize(o),r),deserialize:(o,n=0)=>{if(o=o.slice(n,n+r),o.length<r)throw new p("fixSerializer",r,o.length);e.fixedSize!==null&&(o=x(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);m(this,"name","InvalidBaseStringError");this.cause=n;}};var N=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 u=n.slice(i),l=0n,c=1n;for(let d=u.length-1;d>=0;d-=1)l+=c*BigInt(e.indexOf(u[d])),c*=t;let f=[];for(;l>0n;)f.unshift(Number(l%256n)),l/=256n;return Uint8Array.from(a.concat(f))},deserialize(o,n=0){if(o.length===0)return ["",0];let i=o.slice(n),a=i.findIndex(f=>f!==0);a=a===-1?i.length:a;let u=e[0].repeat(a);if(a===i.length)return [u,o.length];let l=i.slice(a).reduce((f,d)=>f*256n+BigInt(d),0n),c=[];for(;l>0n;)c.unshift(e[Number(l%t)]),l/=t;return [u+c.join(""),o.length]}}};var E=N("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var $=e=>e.replace(/\u0000/g,"");var B={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 [$(t),e.length]}};var b;(function(e){e.Little="le",e.Big="be";})(b||(b={}));var w=class extends RangeError{constructor(t,o,n,i){super(`Serializer [${t}] expected number to be between ${o} and ${n}, got ${i}.`);m(this,"name","NumberOutOfRangeError");}};function U(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&&F(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);j("i8",i,e.size);let a=V(i);return [e.get(a,r),n+e.size]}}}var L=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),V=e=>new DataView(L(e)),F=(e,r,t,o)=>{if(o<r||o>t)throw new w(e,r,t,o)},j=(e,r,t)=>{if(r.length===0)throw new g(e);if(r.length<t)throw new p(e,t,r.length)};var v=(e={})=>U({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 C(e={}){let r=e.size??v(),t=e.encoding??B,o=e.description??`string(${t.description}; ${D(r)})`;return r==="variable"?{...t,description:o}:typeof r=="number"?A(t,r,o):{description:o,fixedSize:null,maxSize:null,serialize:n=>{let i=t.serialize(n),a=r.serialize(i.length);return S([a,i])},deserialize:(n,i=0)=>{if(n.slice(i).length===0)throw new g("string");let[a,u]=r.deserialize(n,i),l=Number(a);i=u;let c=n.slice(i,i+l);if(c.length<l)throw new p("string",l,c.length);let[f,d]=t.deserialize(c);return i+=d,[f,i]}}}function nr(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 K(e){return C({description:e?.description??"",encoding:E,size:32})}function ir(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}function z(){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 y;async function X(e){return y===void 0&&(y=new Promise(r=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{r(y=!1);}).then(()=>{r(y=!0);});})),typeof y=="boolean"?y:await y}async function _(){if(z(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!="function")throw new Error("No key generation implementation could be found");if(!await X(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Install and import \`@solana/webcrypto-ed25519-polyfill\` before generating keys in environments that do not support Ed25519.
|
|
8
|
+
|
|
9
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function P(){if(z(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function T(){if(z(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}async function k(){if(z(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new Error("No signature verification implementation could be found")}async function pr(){return await _(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function xr(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]=K().deserialize(new Uint8Array(r));return t}async function wr(e,r){await T();let t=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(t)}async function zr(e,r,t){return await k(),await crypto.subtle.verify("Ed25519",e,r,t)}
|
|
10
|
+
|
|
11
|
+
exports.assertIsBase58EncodedAddress = nr;
|
|
12
|
+
exports.generateKeyPair = pr;
|
|
13
|
+
exports.getBase58EncodedAddressCodec = K;
|
|
14
|
+
exports.getBase58EncodedAddressComparator = ir;
|
|
15
|
+
exports.getBase58EncodedAddressFromPublicKey = xr;
|
|
16
|
+
exports.signBytes = wr;
|
|
17
|
+
exports.verifySignature = zr;
|
|
9
18
|
|
|
10
19
|
return exports;
|
|
11
20
|
|
package/dist/types/base58.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { Serializer } from '@metaplex-foundation/umi-serializers';
|
|
1
2
|
export type Base58EncodedAddress<TAddress extends string = string> = TAddress & {
|
|
2
3
|
readonly __base58EncodedAddress: unique symbol;
|
|
3
4
|
};
|
|
4
5
|
export declare function assertIsBase58EncodedAddress(putativeBase58EncodedAddress: string): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress>;
|
|
6
|
+
export declare function getBase58EncodedAddressCodec(config?: Readonly<{
|
|
7
|
+
description: string;
|
|
8
|
+
}>): Serializer<Base58EncodedAddress>;
|
|
5
9
|
export declare function getBase58EncodedAddressComparator(): (x: string, y: string) => number;
|
|
6
10
|
//# sourceMappingURL=base58.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function assertKeyGenerationIsAvailable(): Promise<void>;
|
|
2
|
+
export declare function assertKeyExporterIsAvailable(): Promise<void>;
|
|
3
|
+
export declare function assertSigningCapabilityIsAvailable(): Promise<void>;
|
|
4
|
+
export declare function assertVerificationCapabilityIsAvailable(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=guard.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type Ed25519Signature = Uint8Array & {
|
|
2
|
+
readonly __ed25519Signature: unique symbol;
|
|
3
|
+
};
|
|
4
|
+
export declare function signBytes(key: CryptoKey, data: Uint8Array): Promise<Ed25519Signature>;
|
|
5
|
+
export declare function verifySignature(key: CryptoKey, signature: Ed25519Signature, data: Uint8Array): Promise<boolean>;
|
|
6
|
+
//# sourceMappingURL=signatures.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/keys",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.f07dced",
|
|
4
4
|
"description": "Helpers for generating and transforming key material",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -45,27 +45,33 @@
|
|
|
45
45
|
"supports bigint and not dead",
|
|
46
46
|
"maintained node versions"
|
|
47
47
|
],
|
|
48
|
+
"engine": {
|
|
49
|
+
"node": ">=17.4"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@metaplex-foundation/umi-serializers": "^0.8.5"
|
|
53
|
+
},
|
|
48
54
|
"devDependencies": {
|
|
49
|
-
"@solana/eslint-config-solana": "^1.0.
|
|
55
|
+
"@solana/eslint-config-solana": "^1.0.2",
|
|
50
56
|
"@swc/core": "^1.3.18",
|
|
51
57
|
"@swc/jest": "^0.2.26",
|
|
52
|
-
"@types/jest": "^29.5.
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
54
|
-
"@typescript-eslint/parser": "^
|
|
58
|
+
"@types/jest": "^29.5.2",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
55
61
|
"agadoo": "^3.0.0",
|
|
56
|
-
"eslint": "^8.
|
|
57
|
-
"eslint-plugin-jest": "^27.
|
|
62
|
+
"eslint": "^8.45.0",
|
|
63
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
58
64
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
59
65
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
60
|
-
"jest": "^29.
|
|
61
|
-
"jest-environment-jsdom": "^29.
|
|
66
|
+
"jest": "^29.6.1",
|
|
67
|
+
"jest-environment-jsdom": "^29.6.0",
|
|
62
68
|
"jest-runner-eslint": "^2.1.0",
|
|
63
69
|
"jest-runner-prettier": "^1.0.0",
|
|
64
70
|
"postcss": "^8.4.12",
|
|
65
71
|
"prettier": "^2.8.8",
|
|
66
72
|
"ts-node": "^10.9.1",
|
|
67
73
|
"tsup": "6.7.0",
|
|
68
|
-
"typescript": "^5.
|
|
74
|
+
"typescript": "^5.1.6",
|
|
69
75
|
"version-from-git": "^1.1.1",
|
|
70
76
|
"build-scripts": "0.0.0",
|
|
71
77
|
"test-config": "0.0.0",
|
|
@@ -79,9 +85,6 @@
|
|
|
79
85
|
}
|
|
80
86
|
]
|
|
81
87
|
},
|
|
82
|
-
"dependencies": {
|
|
83
|
-
"bs58": "^5.0.0"
|
|
84
|
-
},
|
|
85
88
|
"scripts": {
|
|
86
89
|
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
|
|
87
90
|
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|