@coinbase/cdp-core 0.0.21 → 0.0.22
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/dist/esm/index103.js +1 -1
- package/dist/esm/index17.js +158 -39
- package/dist/esm/index18.js +47 -16
- package/dist/esm/index19.js +152 -4
- package/dist/esm/index20.js +56 -5
- package/dist/esm/index21.js +39 -158
- package/dist/esm/index22.js +16 -47
- package/dist/esm/index23.js +4 -152
- package/dist/esm/index24.js +5 -56
- package/dist/esm/index3.js +4 -4
- package/dist/esm/index6.js +4 -4
- package/dist/esm/index70.js +1 -1
- package/dist/esm/index72.js +4 -4
- package/dist/esm/index77.js +1 -1
- package/dist/esm/index80.js +74 -50
- package/dist/esm/index81.js +10 -11
- package/dist/esm/index82.js +55 -2
- package/dist/esm/index83.js +11 -45
- package/dist/esm/index84.js +2 -14
- package/dist/esm/index85.js +44 -9
- package/dist/esm/index86.js +13 -78
- package/dist/esm/index88.js +12 -20
- package/dist/esm/index89.js +35 -9
- package/dist/esm/index90.js +41 -19
- package/dist/esm/index91.js +20 -93
- package/dist/esm/index92.js +9 -20
- package/dist/esm/index93.js +16 -114
- package/dist/esm/index94.js +92 -11
- package/dist/esm/index95.js +20 -35
- package/dist/esm/index96.js +117 -41
- package/package.json +2 -2
package/dist/esm/index22.js
CHANGED
|
@@ -1,50 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @param listener - The function to remove from the event listeners.
|
|
17
|
-
*/
|
|
18
|
-
removeListener(e, s) {
|
|
19
|
-
if (!this.events[e])
|
|
20
|
-
return;
|
|
21
|
-
const t = this.events[e].indexOf(s);
|
|
22
|
-
t > -1 && this.events[e].splice(t, 1);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Emit an event.
|
|
26
|
-
*
|
|
27
|
-
* @param event - The name of the event to emit.
|
|
28
|
-
* @param args - The arguments to pass to the event listeners.
|
|
29
|
-
*/
|
|
30
|
-
emit(e, ...s) {
|
|
31
|
-
this.events[e] && this.events[e].forEach((t) => {
|
|
32
|
-
try {
|
|
33
|
-
t(...s);
|
|
34
|
-
} catch (i) {
|
|
35
|
-
console.error(`Error in event listener for ${e}:`, i);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Remove all listeners for an event.
|
|
41
|
-
*
|
|
42
|
-
* @param event - The name of the event to remove all listeners from. If not provided, removes all listeners for all events.
|
|
43
|
-
*/
|
|
44
|
-
removeAllListeners(e) {
|
|
45
|
-
e ? delete this.events[e] : this.events = {};
|
|
46
|
-
}
|
|
1
|
+
async function n() {
|
|
2
|
+
const e = await window.crypto.subtle.generateKey(
|
|
3
|
+
{
|
|
4
|
+
name: "ECDSA",
|
|
5
|
+
namedCurve: "P-256"
|
|
6
|
+
// secp256r1
|
|
7
|
+
},
|
|
8
|
+
!1,
|
|
9
|
+
// Do not allow key export.
|
|
10
|
+
["sign", "verify"]
|
|
11
|
+
// Key usages
|
|
12
|
+
), r = await window.crypto.subtle.exportKey("spki", e.publicKey), t = new Uint8Array(r), a = btoa(
|
|
13
|
+
Array.from(t).map((i) => String.fromCharCode(i)).join("")
|
|
14
|
+
);
|
|
15
|
+
return { privateKey: e.privateKey, publicKeyBase64: a };
|
|
47
16
|
}
|
|
48
17
|
export {
|
|
49
|
-
n as
|
|
18
|
+
n as createKeyPair
|
|
50
19
|
};
|
package/dist/esm/index23.js
CHANGED
|
@@ -1,155 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "@coinbase/cdp-api-client";
|
|
5
|
-
import "./index3.js";
|
|
6
|
-
import { validateUserOwnsAddress as m, EIP1193ProviderError as l, STANDARD_ERROR_CODES as s, RPCRequestError as o, validateUserHasEvmAccount as x, validateUserConnected as C } from "./index4.js";
|
|
7
|
-
import "zustand";
|
|
8
|
-
import { isChainIdSupportedForCDPSends as D, chainIdToNameMapping as b } from "./index13.js";
|
|
9
|
-
function g(e) {
|
|
10
|
-
return {
|
|
11
|
-
to: e.to,
|
|
12
|
-
data: e.data,
|
|
13
|
-
value: e.value ? BigInt(e.value) : void 0,
|
|
14
|
-
nonce: e.nonce ? Number(e.nonce) : void 0,
|
|
15
|
-
gas: e.gas ? BigInt(e.gas) : void 0,
|
|
16
|
-
maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
|
|
17
|
-
maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
|
|
18
|
-
type: "eip1559"
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
async function M() {
|
|
22
|
-
return (await f())?.evmAccounts || [];
|
|
23
|
-
}
|
|
24
|
-
async function _(e, n) {
|
|
25
|
-
const a = await C();
|
|
26
|
-
return e.emit("connect", {
|
|
27
|
-
chainId: y.fromNumber(n.getState().chainId)
|
|
28
|
-
}), a.evmAccounts || [];
|
|
29
|
-
}
|
|
30
|
-
async function k(e) {
|
|
31
|
-
const [n, a] = e;
|
|
32
|
-
await m(a);
|
|
33
|
-
const t = Buffer.from(n.slice(2), "hex").toString();
|
|
34
|
-
try {
|
|
35
|
-
return (await A({
|
|
36
|
-
evmAccount: a,
|
|
37
|
-
message: t
|
|
38
|
-
})).signature;
|
|
39
|
-
} catch (c) {
|
|
40
|
-
throw new l(
|
|
41
|
-
s.provider.userRejectedRequest,
|
|
42
|
-
c instanceof Error ? c.message : "Signing failed"
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async function z(e) {
|
|
47
|
-
const [n, a] = e;
|
|
48
|
-
await m(n);
|
|
49
|
-
try {
|
|
50
|
-
return (await E({
|
|
51
|
-
evmAccount: n,
|
|
52
|
-
typedData: JSON.parse(a)
|
|
53
|
-
})).signature;
|
|
54
|
-
} catch (t) {
|
|
55
|
-
throw new l(
|
|
56
|
-
s.provider.userRejectedRequest,
|
|
57
|
-
t instanceof Error ? t.message : "Signing failed"
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function J(e, n, a) {
|
|
62
|
-
const [t] = e;
|
|
63
|
-
if (!t || typeof t != "object")
|
|
64
|
-
throw new o(
|
|
65
|
-
s.rpc.invalidParams,
|
|
66
|
-
"Transaction parameter must be an object"
|
|
67
|
-
);
|
|
68
|
-
if (!t.to)
|
|
69
|
-
throw new o(
|
|
70
|
-
s.rpc.invalidParams,
|
|
71
|
-
"Transaction must include 'to' field"
|
|
72
|
-
);
|
|
73
|
-
const d = (await x()).evmAccounts?.[0], u = n.getState(), i = t.chainId ? Number(t.chainId) : u.chainId;
|
|
74
|
-
if (!d)
|
|
75
|
-
throw new o(
|
|
76
|
-
s.rpc.invalidParams,
|
|
77
|
-
"User does not have an EVM account"
|
|
78
|
-
);
|
|
79
|
-
if (D(i))
|
|
80
|
-
try {
|
|
81
|
-
return (await R({
|
|
82
|
-
evmAccount: d,
|
|
83
|
-
transaction: { ...g(t), chainId: i },
|
|
84
|
-
network: b[i]
|
|
85
|
-
})).transactionHash;
|
|
86
|
-
} catch (r) {
|
|
87
|
-
throw console.log("Transaction failed", r), new o(
|
|
88
|
-
s.rpc.transactionRejected,
|
|
89
|
-
r instanceof Error ? r.message : "Transaction failed"
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
else
|
|
93
|
-
try {
|
|
94
|
-
const r = I({
|
|
95
|
-
// Safe as we check before calling this handler that chainId is configured
|
|
96
|
-
chain: u.chains.find((h) => h.id === i),
|
|
97
|
-
transport: a[i],
|
|
98
|
-
account: d
|
|
99
|
-
}), p = u.chains.find((h) => h.id === i), w = await r.prepareTransactionRequest({
|
|
100
|
-
...g(t),
|
|
101
|
-
chain: p
|
|
102
|
-
}), v = await T({
|
|
103
|
-
evmAccount: d,
|
|
104
|
-
transaction: {
|
|
105
|
-
...w,
|
|
106
|
-
type: "eip1559"
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return await r.sendRawTransaction({
|
|
110
|
-
serializedTransaction: v.signedTransaction
|
|
111
|
-
});
|
|
112
|
-
} catch (r) {
|
|
113
|
-
throw new o(
|
|
114
|
-
s.rpc.transactionRejected,
|
|
115
|
-
r instanceof Error ? r.message : "Transaction failed"
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async function V(e) {
|
|
120
|
-
const [n, a] = e;
|
|
121
|
-
await m(a);
|
|
122
|
-
try {
|
|
123
|
-
return (await S({
|
|
124
|
-
evmAccount: a,
|
|
125
|
-
hash: n
|
|
126
|
-
})).signature;
|
|
127
|
-
} catch (t) {
|
|
128
|
-
throw new l(
|
|
129
|
-
s.provider.userRejectedRequest,
|
|
130
|
-
t instanceof Error ? t.message : "Signing failed"
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async function W(e) {
|
|
135
|
-
return `0x${e.getState().chainId.toString(16)}`;
|
|
136
|
-
}
|
|
137
|
-
async function $() {
|
|
138
|
-
await f() && await P();
|
|
139
|
-
}
|
|
140
|
-
function K(e, n) {
|
|
141
|
-
const a = Number.parseInt(e[0].chainId, 16);
|
|
142
|
-
n.getState().setChainId(a);
|
|
1
|
+
async function t() {
|
|
2
|
+
const r = new Uint8Array(16);
|
|
3
|
+
return window.crypto.getRandomValues(r), Array.from(r, (n) => n.toString(16).padStart(2, "0")).join("");
|
|
143
4
|
}
|
|
144
5
|
export {
|
|
145
|
-
|
|
146
|
-
W as handleChainId,
|
|
147
|
-
$ as handleDisconnect,
|
|
148
|
-
V as handleEthSign,
|
|
149
|
-
k as handlePersonalSign,
|
|
150
|
-
_ as handleRequestAccounts,
|
|
151
|
-
J as handleSendTransaction,
|
|
152
|
-
z as handleSignTypedData,
|
|
153
|
-
K as handleSwitchEthereumChain,
|
|
154
|
-
g as shimProviderTxRequest
|
|
6
|
+
t as generateRandomId
|
|
155
7
|
};
|
package/dist/esm/index24.js
CHANGED
|
@@ -1,58 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id: 84532,
|
|
6
|
-
network: "base-sepolia",
|
|
7
|
-
name: "Base Sepolia",
|
|
8
|
-
nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
|
|
9
|
-
rpcUrls: {
|
|
10
|
-
default: {
|
|
11
|
-
http: ["https://sepolia.base.org"]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
blockExplorers: {
|
|
15
|
-
default: {
|
|
16
|
-
name: "Basescan",
|
|
17
|
-
url: "https://sepolia.basescan.org",
|
|
18
|
-
apiUrl: "https://api-sepolia.basescan.org/api"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
contracts: {
|
|
22
|
-
...a.contracts,
|
|
23
|
-
disputeGameFactory: {
|
|
24
|
-
[e]: {
|
|
25
|
-
address: "0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
l2OutputOracle: {
|
|
29
|
-
[e]: {
|
|
30
|
-
address: "0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
portal: {
|
|
34
|
-
[e]: {
|
|
35
|
-
address: "0x49f53e41452c74589e85ca1677426ba426459e85",
|
|
36
|
-
blockCreated: 4446677
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
l1StandardBridge: {
|
|
40
|
-
[e]: {
|
|
41
|
-
address: "0xfd0Bf71F60660E2f608ed56e1659C450eB113120",
|
|
42
|
-
blockCreated: 4446677
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
multicall3: {
|
|
46
|
-
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
47
|
-
blockCreated: 1059647
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
testnet: !0,
|
|
51
|
-
sourceId: e
|
|
52
|
-
});
|
|
53
|
-
({
|
|
54
|
-
...r
|
|
55
|
-
});
|
|
1
|
+
const h = async (t) => {
|
|
2
|
+
const a = await window.crypto.subtle.digest("SHA-256", t), r = new Uint8Array(a);
|
|
3
|
+
return Array.from(r).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
4
|
+
};
|
|
56
5
|
export {
|
|
57
|
-
|
|
6
|
+
h as hash
|
|
58
7
|
};
|
package/dist/esm/index3.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Provider as h } from "ox";
|
|
2
2
|
import { http as p } from "viem";
|
|
3
3
|
import { create as l } from "zustand";
|
|
4
|
-
import { subscribeWithSelector as f, persist as g } from "./
|
|
4
|
+
import { subscribeWithSelector as f, persist as g } from "./index17.js";
|
|
5
5
|
import { validateRequest as w, EIP1193ProviderError as I, STANDARD_ERROR_CODES as S } from "./index4.js";
|
|
6
|
-
import { EventEmitter as b } from "./
|
|
6
|
+
import { EventEmitter as b } from "./index18.js";
|
|
7
7
|
import "@coinbase/cdp-api-client";
|
|
8
|
-
import { handleChainId as A, handleSignTypedData as C, handleEthSign as _, handleSwitchEthereumChain as v, handleDisconnect as D, handleSendTransaction as E, handlePersonalSign as P, handleRequestAccounts as R, handleAccounts as y } from "./
|
|
8
|
+
import { handleChainId as A, handleSignTypedData as C, handleEthSign as _, handleSwitchEthereumChain as v, handleDisconnect as D, handleSendTransaction as E, handlePersonalSign as P, handleRequestAccounts as R, handleAccounts as y } from "./index19.js";
|
|
9
9
|
import { onAuthStateChange as T } from "./index2.js";
|
|
10
|
-
import { baseSepolia as d } from "./
|
|
10
|
+
import { baseSepolia as d } from "./index20.js";
|
|
11
11
|
function q(r, e, a) {
|
|
12
12
|
e.subscribe(
|
|
13
13
|
(t) => t.chainId,
|
package/dist/esm/index6.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { logOutEndUser as h, refreshAccessToken as l, registerTemporaryWalletSecret as c } from "@coinbase/cdp-api-client";
|
|
2
|
-
import { SignJWT as o } from "./
|
|
2
|
+
import { SignJWT as o } from "./index21.js";
|
|
3
3
|
import "viem";
|
|
4
4
|
import { toAuthState as u } from "./index7.js";
|
|
5
|
-
import { createKeyPair as S } from "./
|
|
6
|
-
import { generateRandomId as i } from "./
|
|
7
|
-
import { hash as w } from "./
|
|
5
|
+
import { createKeyPair as S } from "./index22.js";
|
|
6
|
+
import { generateRandomId as i } from "./index23.js";
|
|
7
|
+
import { hash as w } from "./index24.js";
|
|
8
8
|
import { sortKeys as f } from "./index13.js";
|
|
9
9
|
const n = 60 * 1e3;
|
|
10
10
|
class C {
|
package/dist/esm/index70.js
CHANGED
package/dist/esm/index72.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { encoder as n } from "./
|
|
2
|
-
import e from "./
|
|
3
|
-
import i from "./
|
|
4
|
-
import o from "./
|
|
1
|
+
import { encoder as n } from "./index83.js";
|
|
2
|
+
import e from "./index84.js";
|
|
3
|
+
import i from "./index85.js";
|
|
4
|
+
import o from "./index86.js";
|
|
5
5
|
function s(r, t) {
|
|
6
6
|
if (!Number.isFinite(t))
|
|
7
7
|
throw new TypeError(`Invalid ${r} input`);
|
package/dist/esm/index77.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./
|
|
1
|
+
import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index80.js";
|
|
2
2
|
import { createHasher as u, clean as C, rotr as i } from "./index76.js";
|
|
3
3
|
const B = /* @__PURE__ */ Uint32Array.from([
|
|
4
4
|
1116352408,
|
package/dist/esm/index80.js
CHANGED
|
@@ -1,57 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this
|
|
1
|
+
import { Hash as g, createView as l, aexists as b, toBytes as a, abytes as d, aoutput as x, clean as w } from "./index76.js";
|
|
2
|
+
function y(o, t, s, n) {
|
|
3
|
+
if (typeof o.setBigUint64 == "function")
|
|
4
|
+
return o.setBigUint64(t, s, n);
|
|
5
|
+
const i = BigInt(32), h = BigInt(4294967295), e = Number(s >> i & h), r = Number(s & h), c = n ? 4 : 0, u = n ? 0 : 4;
|
|
6
|
+
o.setUint32(t + c, e, n), o.setUint32(t + u, r, n);
|
|
7
|
+
}
|
|
8
|
+
function U(o, t, s) {
|
|
9
|
+
return o & t ^ ~o & s;
|
|
10
|
+
}
|
|
11
|
+
function _(o, t, s) {
|
|
12
|
+
return o & t ^ o & s ^ t & s;
|
|
13
|
+
}
|
|
14
|
+
class m extends g {
|
|
15
|
+
constructor(t, s, n, i) {
|
|
16
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = l(this.buffer);
|
|
17
|
+
}
|
|
18
|
+
update(t) {
|
|
19
|
+
b(this), t = a(t), d(t);
|
|
20
|
+
const { view: s, buffer: n, blockLen: i } = this, h = t.length;
|
|
21
|
+
for (let e = 0; e < h; ) {
|
|
22
|
+
const r = Math.min(i - this.pos, h - e);
|
|
23
|
+
if (r === i) {
|
|
24
|
+
const c = l(t);
|
|
25
|
+
for (; i <= h - e; e += i)
|
|
26
|
+
this.process(c, e);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
n.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === i && (this.process(s, 0), this.pos = 0);
|
|
30
|
+
}
|
|
31
|
+
return this.length += t.length, this.roundClean(), this;
|
|
32
|
+
}
|
|
33
|
+
digestInto(t) {
|
|
34
|
+
b(this), x(t, this), this.finished = !0;
|
|
35
|
+
const { buffer: s, view: n, blockLen: i, isLE: h } = this;
|
|
36
|
+
let { pos: e } = this;
|
|
37
|
+
s[e++] = 128, w(this.buffer.subarray(e)), this.padOffset > i - e && (this.process(n, 0), e = 0);
|
|
38
|
+
for (let f = e; f < i; f++)
|
|
39
|
+
s[f] = 0;
|
|
40
|
+
y(n, i - 8, BigInt(this.length * 8), h), this.process(n, 0);
|
|
41
|
+
const r = l(t), c = this.outputLen;
|
|
42
|
+
if (c % 4)
|
|
43
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
44
|
+
const u = c / 4, p = this.get();
|
|
45
|
+
if (u > p.length)
|
|
46
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
47
|
+
for (let f = 0; f < u; f++)
|
|
48
|
+
r.setUint32(4 * f, p[f], h);
|
|
17
49
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
50
|
+
digest() {
|
|
51
|
+
const { buffer: t, outputLen: s } = this;
|
|
52
|
+
this.digestInto(t);
|
|
53
|
+
const n = t.slice(0, s);
|
|
54
|
+
return this.destroy(), n;
|
|
22
55
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
56
|
+
_cloneInto(t) {
|
|
57
|
+
t || (t = new this.constructor()), t.set(...this.get());
|
|
58
|
+
const { blockLen: s, buffer: n, length: i, finished: h, destroyed: e, pos: r } = this;
|
|
59
|
+
return t.destroyed = e, t.finished = h, t.length = i, t.pos = r, i % s && t.buffer.set(n), t;
|
|
27
60
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new r("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
31
|
-
if (!b(this.#e, this.#t))
|
|
32
|
-
throw new r("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
33
|
-
const c = {
|
|
34
|
-
...this.#e,
|
|
35
|
-
...this.#t
|
|
36
|
-
}, p = H(r, /* @__PURE__ */ new Map([["b64", !0]]), l?.crit, this.#e, c);
|
|
37
|
-
let o = !0;
|
|
38
|
-
if (p.has("b64") && (o = this.#e.b64, typeof o != "boolean"))
|
|
39
|
-
throw new r('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
40
|
-
const { alg: t } = c;
|
|
41
|
-
if (typeof t != "string" || !t)
|
|
42
|
-
throw new r('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
43
|
-
g(t, e, "sign");
|
|
44
|
-
let i = this.#r;
|
|
45
|
-
o && (i = s.encode(d(i)));
|
|
46
|
-
let n;
|
|
47
|
-
this.#e ? n = s.encode(d(JSON.stringify(this.#e))) : n = s.encode("");
|
|
48
|
-
const f = u(n, s.encode("."), i), m = await P(e, t), w = await y(t, m, f), a = {
|
|
49
|
-
signature: d(w),
|
|
50
|
-
payload: ""
|
|
51
|
-
};
|
|
52
|
-
return o && (a.payload = h.decode(i)), this.#t && (a.header = this.#t), this.#e && (a.protected = h.decode(n)), a;
|
|
61
|
+
clone() {
|
|
62
|
+
return this._cloneInto();
|
|
53
63
|
}
|
|
54
64
|
}
|
|
65
|
+
const B = /* @__PURE__ */ Uint32Array.from([
|
|
66
|
+
1779033703,
|
|
67
|
+
3144134277,
|
|
68
|
+
1013904242,
|
|
69
|
+
2773480762,
|
|
70
|
+
1359893119,
|
|
71
|
+
2600822924,
|
|
72
|
+
528734635,
|
|
73
|
+
1541459225
|
|
74
|
+
]);
|
|
55
75
|
export {
|
|
56
|
-
|
|
76
|
+
U as Chi,
|
|
77
|
+
m as HashMD,
|
|
78
|
+
_ as Maj,
|
|
79
|
+
B as SHA256_IV,
|
|
80
|
+
y as setBigUint64
|
|
57
81
|
};
|
package/dist/esm/index81.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { contracts as o } from "./index88.js";
|
|
2
|
+
import { formatters as r } from "./index89.js";
|
|
3
|
+
import { serializers as t } from "./index90.js";
|
|
4
|
+
const e = {
|
|
5
|
+
blockTime: 2e3,
|
|
6
|
+
contracts: o,
|
|
7
|
+
formatters: r,
|
|
8
|
+
serializers: t
|
|
9
|
+
};
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
-
s as decoder,
|
|
12
|
-
d as encoder
|
|
11
|
+
e as chainConfig
|
|
13
12
|
};
|
package/dist/esm/index82.js
CHANGED
|
@@ -1,4 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import { encode as d } from "./index91.js";
|
|
2
|
+
import y from "./index92.js";
|
|
3
|
+
import b from "./index93.js";
|
|
4
|
+
import { JWSInvalid as r } from "./index71.js";
|
|
5
|
+
import { encoder as s, concat as u, decoder as h } from "./index83.js";
|
|
6
|
+
import g from "./index94.js";
|
|
7
|
+
import H from "./index95.js";
|
|
8
|
+
import P from "./index96.js";
|
|
9
|
+
class x {
|
|
10
|
+
#r;
|
|
11
|
+
#e;
|
|
12
|
+
#t;
|
|
13
|
+
constructor(e) {
|
|
14
|
+
if (!(e instanceof Uint8Array))
|
|
15
|
+
throw new TypeError("payload must be an instance of Uint8Array");
|
|
16
|
+
this.#r = e;
|
|
17
|
+
}
|
|
18
|
+
setProtectedHeader(e) {
|
|
19
|
+
if (this.#e)
|
|
20
|
+
throw new TypeError("setProtectedHeader can only be called once");
|
|
21
|
+
return this.#e = e, this;
|
|
22
|
+
}
|
|
23
|
+
setUnprotectedHeader(e) {
|
|
24
|
+
if (this.#t)
|
|
25
|
+
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
26
|
+
return this.#t = e, this;
|
|
27
|
+
}
|
|
28
|
+
async sign(e, l) {
|
|
29
|
+
if (!this.#e && !this.#t)
|
|
30
|
+
throw new r("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
31
|
+
if (!b(this.#e, this.#t))
|
|
32
|
+
throw new r("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
33
|
+
const c = {
|
|
34
|
+
...this.#e,
|
|
35
|
+
...this.#t
|
|
36
|
+
}, p = H(r, /* @__PURE__ */ new Map([["b64", !0]]), l?.crit, this.#e, c);
|
|
37
|
+
let o = !0;
|
|
38
|
+
if (p.has("b64") && (o = this.#e.b64, typeof o != "boolean"))
|
|
39
|
+
throw new r('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
40
|
+
const { alg: t } = c;
|
|
41
|
+
if (typeof t != "string" || !t)
|
|
42
|
+
throw new r('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
43
|
+
g(t, e, "sign");
|
|
44
|
+
let i = this.#r;
|
|
45
|
+
o && (i = s.encode(d(i)));
|
|
46
|
+
let n;
|
|
47
|
+
this.#e ? n = s.encode(d(JSON.stringify(this.#e))) : n = s.encode("");
|
|
48
|
+
const f = u(n, s.encode("."), i), m = await P(e, t), w = await y(t, m, f), a = {
|
|
49
|
+
signature: d(w),
|
|
50
|
+
payload: ""
|
|
51
|
+
};
|
|
52
|
+
return o && (a.payload = h.decode(i)), this.#t && (a.header = this.#t), this.#e && (a.protected = h.decode(n)), a;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
2
55
|
export {
|
|
3
|
-
|
|
56
|
+
x as FlattenedSign
|
|
4
57
|
};
|
package/dist/esm/index83.js
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
case "secs":
|
|
10
|
-
case "second":
|
|
11
|
-
case "seconds":
|
|
12
|
-
case "s":
|
|
13
|
-
e = Math.round(a);
|
|
14
|
-
break;
|
|
15
|
-
case "minute":
|
|
16
|
-
case "minutes":
|
|
17
|
-
case "min":
|
|
18
|
-
case "mins":
|
|
19
|
-
case "m":
|
|
20
|
-
e = Math.round(a * 60);
|
|
21
|
-
break;
|
|
22
|
-
case "hour":
|
|
23
|
-
case "hours":
|
|
24
|
-
case "hr":
|
|
25
|
-
case "hrs":
|
|
26
|
-
case "h":
|
|
27
|
-
e = Math.round(a * 3600);
|
|
28
|
-
break;
|
|
29
|
-
case "day":
|
|
30
|
-
case "days":
|
|
31
|
-
case "d":
|
|
32
|
-
e = Math.round(a * 86400);
|
|
33
|
-
break;
|
|
34
|
-
case "week":
|
|
35
|
-
case "weeks":
|
|
36
|
-
case "w":
|
|
37
|
-
e = Math.round(a * 604800);
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
e = Math.round(a * 31557600);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
return s[1] === "-" || s[4] === "ago" ? -e : e;
|
|
44
|
-
};
|
|
1
|
+
const d = new TextEncoder(), s = new TextDecoder();
|
|
2
|
+
function f(...n) {
|
|
3
|
+
const c = n.reduce((e, { length: r }) => e + r, 0), t = new Uint8Array(c);
|
|
4
|
+
let o = 0;
|
|
5
|
+
for (const e of n)
|
|
6
|
+
t.set(e, o), o += e.length;
|
|
7
|
+
return t;
|
|
8
|
+
}
|
|
45
9
|
export {
|
|
46
|
-
|
|
10
|
+
f as concat,
|
|
11
|
+
s as decoder,
|
|
12
|
+
d as encoder
|
|
47
13
|
};
|
package/dist/esm/index84.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return typeof t == "object" && t !== null;
|
|
3
|
-
}
|
|
4
|
-
const r = (t) => {
|
|
5
|
-
if (!o(t) || Object.prototype.toString.call(t) !== "[object Object]")
|
|
6
|
-
return !1;
|
|
7
|
-
if (Object.getPrototypeOf(t) === null)
|
|
8
|
-
return !0;
|
|
9
|
-
let e = t;
|
|
10
|
-
for (; Object.getPrototypeOf(e) !== null; )
|
|
11
|
-
e = Object.getPrototypeOf(e);
|
|
12
|
-
return Object.getPrototypeOf(t) === e;
|
|
13
|
-
};
|
|
1
|
+
const o = (e) => Math.floor(e.getTime() / 1e3);
|
|
14
2
|
export {
|
|
15
|
-
|
|
3
|
+
o as default
|
|
16
4
|
};
|