@coinbase/cdp-core 0.0.17 → 0.0.19
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/index.js +24 -21
- package/dist/esm/index103.js +1 -1
- package/dist/esm/index104.js +1 -1
- package/dist/esm/index17.js +39 -158
- package/dist/esm/index18.js +16 -47
- package/dist/esm/index19.js +4 -152
- package/dist/esm/index2.js +138 -124
- package/dist/esm/index20.js +5 -56
- package/dist/esm/index21.js +158 -39
- package/dist/esm/index22.js +47 -16
- package/dist/esm/index23.js +152 -4
- package/dist/esm/index24.js +56 -5
- package/dist/esm/index3.js +4 -4
- package/dist/esm/index47.js +1 -1
- package/dist/esm/index48.js +1 -1
- package/dist/esm/index6.js +4 -4
- package/dist/esm/index70.js +2 -17
- package/dist/esm/index71.js +17 -19
- package/dist/esm/index72.js +13 -47
- package/dist/esm/index73.js +23 -2
- package/dist/esm/index74.js +47 -17
- package/dist/esm/index77.js +1 -1
- package/dist/esm/index80.js +79 -10
- package/dist/esm/index81.js +10 -55
- package/dist/esm/index82.js +54 -10
- package/dist/esm/index83.js +11 -2
- package/dist/esm/index84.js +2 -45
- package/dist/esm/index85.js +44 -13
- package/dist/esm/index86.js +13 -78
- package/dist/esm/index91.js +1 -1
- package/dist/esm/index95.js +1 -1
- package/dist/esm/index98.js +1 -1
- package/dist/types/index.d.ts +26 -0
- package/package.json +2 -2
package/dist/esm/index23.js
CHANGED
|
@@ -1,7 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Hex as y } from "ox";
|
|
2
|
+
import { createWalletClient as I } from "viem";
|
|
3
|
+
import { signEvmTypedData as E, signEvmHash as S, getCurrentUser as f, signOut as P, sendEvmTransaction as R, signEvmTransaction as T, signEvmMessage as A } from "./index2.js";
|
|
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);
|
|
4
143
|
}
|
|
5
144
|
export {
|
|
6
|
-
|
|
145
|
+
M as handleAccounts,
|
|
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
|
|
7
155
|
};
|
package/dist/esm/index24.js
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { chainConfig as a } from "./index81.js";
|
|
2
|
+
import { defineChain as t } from "./index25.js";
|
|
3
|
+
const e = 11155111, r = /* @__PURE__ */ t({
|
|
4
|
+
...a,
|
|
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
|
+
});
|
|
5
56
|
export {
|
|
6
|
-
|
|
57
|
+
r as baseSepolia
|
|
7
58
|
};
|
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 "./index21.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 "./index22.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 "./index23.js";
|
|
9
9
|
import { onAuthStateChange as T } from "./index2.js";
|
|
10
|
-
import { baseSepolia as d } from "./
|
|
10
|
+
import { baseSepolia as d } from "./index24.js";
|
|
11
11
|
function q(r, e, a) {
|
|
12
12
|
e.subscribe(
|
|
13
13
|
(t) => t.chainId,
|
package/dist/esm/index47.js
CHANGED
package/dist/esm/index48.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./
|
|
1
|
+
import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./index71.js";
|
|
2
2
|
const h = {
|
|
3
3
|
bytes: new Uint8Array(),
|
|
4
4
|
dataView: new DataView(new ArrayBuffer(0)),
|
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 "./index17.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 "./index18.js";
|
|
6
|
+
import { generateRandomId as i } from "./index19.js";
|
|
7
|
+
import { hash as w } from "./index20.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
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
class o {
|
|
3
|
-
#e;
|
|
4
|
-
constructor(e) {
|
|
5
|
-
this.#e = new n(e);
|
|
6
|
-
}
|
|
7
|
-
setProtectedHeader(e) {
|
|
8
|
-
return this.#e.setProtectedHeader(e), this;
|
|
9
|
-
}
|
|
10
|
-
async sign(e, r) {
|
|
11
|
-
const t = await this.#e.sign(e, r);
|
|
12
|
-
if (t.payload === void 0)
|
|
13
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
14
|
-
return `${t.protected}.${t.payload}.${t.signature}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
const o = "2.33.0";
|
|
17
2
|
export {
|
|
18
|
-
o as
|
|
3
|
+
o as version
|
|
19
4
|
};
|
package/dist/esm/index71.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { BaseError as o } from "./index47.js";
|
|
2
|
+
class i extends o {
|
|
3
|
+
constructor({ offset: e }) {
|
|
4
|
+
super(`Offset \`${e}\` cannot be negative.`, {
|
|
5
|
+
name: "NegativeOffsetError"
|
|
6
|
+
});
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
|
-
class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
class o extends c {
|
|
13
|
-
static code = "ERR_JWS_INVALID";
|
|
14
|
-
code = "ERR_JWS_INVALID";
|
|
9
|
+
class n extends o {
|
|
10
|
+
constructor({ length: e, position: r }) {
|
|
11
|
+
super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" });
|
|
12
|
+
}
|
|
15
13
|
}
|
|
16
|
-
class
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
class c extends o {
|
|
15
|
+
constructor({ count: e, limit: r }) {
|
|
16
|
+
super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`, { name: "RecursiveReadLimitExceededError" });
|
|
17
|
+
}
|
|
19
18
|
}
|
|
20
19
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
r as JWTInvalid
|
|
20
|
+
i as NegativeOffsetError,
|
|
21
|
+
n as PositionOutOfBoundsError,
|
|
22
|
+
c as RecursiveReadLimitExceededError
|
|
25
23
|
};
|
package/dist/esm/index72.js
CHANGED
|
@@ -1,53 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!Number.isFinite(t))
|
|
7
|
-
throw new TypeError(`Invalid ${r} input`);
|
|
8
|
-
return t;
|
|
9
|
-
}
|
|
10
|
-
class d {
|
|
11
|
-
#t;
|
|
12
|
-
constructor(t) {
|
|
13
|
-
if (!o(t))
|
|
14
|
-
throw new TypeError("JWT Claims Set MUST be an object");
|
|
15
|
-
this.#t = structuredClone(t);
|
|
16
|
-
}
|
|
17
|
-
data() {
|
|
18
|
-
return n.encode(JSON.stringify(this.#t));
|
|
19
|
-
}
|
|
20
|
-
get iss() {
|
|
21
|
-
return this.#t.iss;
|
|
22
|
-
}
|
|
23
|
-
set iss(t) {
|
|
24
|
-
this.#t.iss = t;
|
|
25
|
-
}
|
|
26
|
-
get sub() {
|
|
27
|
-
return this.#t.sub;
|
|
28
|
-
}
|
|
29
|
-
set sub(t) {
|
|
30
|
-
this.#t.sub = t;
|
|
31
|
-
}
|
|
32
|
-
get aud() {
|
|
33
|
-
return this.#t.aud;
|
|
34
|
-
}
|
|
35
|
-
set aud(t) {
|
|
36
|
-
this.#t.aud = t;
|
|
37
|
-
}
|
|
38
|
-
set jti(t) {
|
|
39
|
-
this.#t.jti = t;
|
|
40
|
-
}
|
|
41
|
-
set nbf(t) {
|
|
42
|
-
typeof t == "number" ? this.#t.nbf = s("setNotBefore", t) : t instanceof Date ? this.#t.nbf = s("setNotBefore", e(t)) : this.#t.nbf = e(/* @__PURE__ */ new Date()) + i(t);
|
|
1
|
+
import { FlattenedSign as n } from "./index82.js";
|
|
2
|
+
class o {
|
|
3
|
+
#e;
|
|
4
|
+
constructor(e) {
|
|
5
|
+
this.#e = new n(e);
|
|
43
6
|
}
|
|
44
|
-
|
|
45
|
-
|
|
7
|
+
setProtectedHeader(e) {
|
|
8
|
+
return this.#e.setProtectedHeader(e), this;
|
|
46
9
|
}
|
|
47
|
-
|
|
48
|
-
|
|
10
|
+
async sign(e, r) {
|
|
11
|
+
const t = await this.#e.sign(e, r);
|
|
12
|
+
if (t.payload === void 0)
|
|
13
|
+
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
14
|
+
return `${t.protected}.${t.payload}.${t.signature}`;
|
|
49
15
|
}
|
|
50
16
|
}
|
|
51
17
|
export {
|
|
52
|
-
|
|
18
|
+
o as CompactSign
|
|
53
19
|
};
|
package/dist/esm/index73.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
class c extends Error {
|
|
2
|
+
static code = "ERR_JOSE_GENERIC";
|
|
3
|
+
code = "ERR_JOSE_GENERIC";
|
|
4
|
+
constructor(s, e) {
|
|
5
|
+
super(s, e), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
class E extends c {
|
|
9
|
+
static code = "ERR_JOSE_NOT_SUPPORTED";
|
|
10
|
+
code = "ERR_JOSE_NOT_SUPPORTED";
|
|
11
|
+
}
|
|
12
|
+
class o extends c {
|
|
13
|
+
static code = "ERR_JWS_INVALID";
|
|
14
|
+
code = "ERR_JWS_INVALID";
|
|
15
|
+
}
|
|
16
|
+
class r extends c {
|
|
17
|
+
static code = "ERR_JWT_INVALID";
|
|
18
|
+
code = "ERR_JWT_INVALID";
|
|
19
|
+
}
|
|
2
20
|
export {
|
|
3
|
-
|
|
21
|
+
c as JOSEError,
|
|
22
|
+
E as JOSENotSupported,
|
|
23
|
+
o as JWSInvalid,
|
|
24
|
+
r as JWTInvalid
|
|
4
25
|
};
|
package/dist/esm/index74.js
CHANGED
|
@@ -1,23 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
function s(r, t) {
|
|
6
|
+
if (!Number.isFinite(t))
|
|
7
|
+
throw new TypeError(`Invalid ${r} input`);
|
|
8
|
+
return t;
|
|
8
9
|
}
|
|
9
|
-
class
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
class d {
|
|
11
|
+
#t;
|
|
12
|
+
constructor(t) {
|
|
13
|
+
if (!o(t))
|
|
14
|
+
throw new TypeError("JWT Claims Set MUST be an object");
|
|
15
|
+
this.#t = structuredClone(t);
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
data() {
|
|
18
|
+
return n.encode(JSON.stringify(this.#t));
|
|
19
|
+
}
|
|
20
|
+
get iss() {
|
|
21
|
+
return this.#t.iss;
|
|
22
|
+
}
|
|
23
|
+
set iss(t) {
|
|
24
|
+
this.#t.iss = t;
|
|
25
|
+
}
|
|
26
|
+
get sub() {
|
|
27
|
+
return this.#t.sub;
|
|
28
|
+
}
|
|
29
|
+
set sub(t) {
|
|
30
|
+
this.#t.sub = t;
|
|
31
|
+
}
|
|
32
|
+
get aud() {
|
|
33
|
+
return this.#t.aud;
|
|
34
|
+
}
|
|
35
|
+
set aud(t) {
|
|
36
|
+
this.#t.aud = t;
|
|
37
|
+
}
|
|
38
|
+
set jti(t) {
|
|
39
|
+
this.#t.jti = t;
|
|
40
|
+
}
|
|
41
|
+
set nbf(t) {
|
|
42
|
+
typeof t == "number" ? this.#t.nbf = s("setNotBefore", t) : t instanceof Date ? this.#t.nbf = s("setNotBefore", e(t)) : this.#t.nbf = e(/* @__PURE__ */ new Date()) + i(t);
|
|
43
|
+
}
|
|
44
|
+
set exp(t) {
|
|
45
|
+
typeof t == "number" ? this.#t.exp = s("setExpirationTime", t) : t instanceof Date ? this.#t.exp = s("setExpirationTime", e(t)) : this.#t.exp = e(/* @__PURE__ */ new Date()) + i(t);
|
|
46
|
+
}
|
|
47
|
+
set iat(t) {
|
|
48
|
+
typeof t > "u" ? this.#t.iat = e(/* @__PURE__ */ new Date()) : t instanceof Date ? this.#t.iat = s("setIssuedAt", e(t)) : typeof t == "string" ? this.#t.iat = s("setIssuedAt", e(/* @__PURE__ */ new Date()) + i(t)) : this.#t.iat = s("setIssuedAt", t);
|
|
17
49
|
}
|
|
18
50
|
}
|
|
19
51
|
export {
|
|
20
|
-
|
|
21
|
-
n as PositionOutOfBoundsError,
|
|
22
|
-
c as RecursiveReadLimitExceededError
|
|
52
|
+
d as JWTClaimsBuilder
|
|
23
53
|
};
|
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,12 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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);
|
|
49
|
+
}
|
|
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;
|
|
55
|
+
}
|
|
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;
|
|
60
|
+
}
|
|
61
|
+
clone() {
|
|
62
|
+
return this._cloneInto();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const B = /* @__PURE__ */ Uint32Array.from([
|
|
66
|
+
1779033703,
|
|
67
|
+
3144134277,
|
|
68
|
+
1013904242,
|
|
69
|
+
2773480762,
|
|
70
|
+
1359893119,
|
|
71
|
+
2600822924,
|
|
72
|
+
528734635,
|
|
73
|
+
1541459225
|
|
74
|
+
]);
|
|
10
75
|
export {
|
|
11
|
-
|
|
76
|
+
U as Chi,
|
|
77
|
+
m as HashMD,
|
|
78
|
+
_ as Maj,
|
|
79
|
+
B as SHA256_IV,
|
|
80
|
+
y as setBigUint64
|
|
12
81
|
};
|
package/dist/esm/index81.js
CHANGED
|
@@ -1,57 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
}
|
|
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
|
+
};
|
|
55
10
|
export {
|
|
56
|
-
|
|
11
|
+
e as chainConfig
|
|
57
12
|
};
|