@coinbase/cdp-core 0.0.23 → 0.0.24
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/index13.js +29 -9
- package/dist/esm/index17.js +39 -158
- package/dist/esm/index18.js +16 -47
- package/dist/esm/index19.js +4 -152
- 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 +249 -4
- package/dist/esm/index24.js +56 -5
- package/dist/esm/index3.js +66 -60
- package/dist/esm/index4.js +48 -35
- 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 +50 -74
- package/dist/esm/index81.js +11 -10
- package/dist/esm/index82.js +2 -55
- package/dist/esm/index83.js +45 -11
- package/dist/esm/index84.js +14 -2
- package/dist/esm/index85.js +9 -44
- package/dist/esm/index86.js +78 -13
- package/dist/esm/index88.js +20 -12
- package/dist/esm/index89.js +9 -35
- package/dist/esm/index90.js +19 -41
- package/dist/esm/index91.js +93 -20
- package/dist/esm/index92.js +20 -9
- package/dist/esm/index93.js +114 -16
- package/dist/esm/index94.js +11 -92
- package/dist/esm/index95.js +35 -20
- package/dist/esm/index96.js +41 -117
- package/dist/types/index.d.ts +30 -1
- package/package.json +2 -2
package/dist/esm/index3.js
CHANGED
|
@@ -1,93 +1,99 @@
|
|
|
1
|
-
import { Provider as
|
|
1
|
+
import { Provider as d } from "ox";
|
|
2
2
|
import { http as p } from "viem";
|
|
3
|
-
import { create as
|
|
4
|
-
import { subscribeWithSelector as f, persist as g } from "./
|
|
5
|
-
import { validateRequest as w, EIP1193ProviderError as
|
|
6
|
-
import { EventEmitter as b } from "./
|
|
3
|
+
import { create as m } from "zustand";
|
|
4
|
+
import { subscribeWithSelector as f, persist as g } from "./index21.js";
|
|
5
|
+
import { validateRequest as w, EIP1193ProviderError as C, STANDARD_ERROR_CODES as S } from "./index4.js";
|
|
6
|
+
import { EventEmitter as b } from "./index22.js";
|
|
7
7
|
import "@coinbase/cdp-api-client";
|
|
8
|
-
import {
|
|
9
|
-
import { onAuthStateChange as
|
|
10
|
-
import { baseSepolia as
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
(
|
|
14
|
-
(
|
|
15
|
-
|
|
8
|
+
import { handleGetCapabilities as I, handleGetCallsStatus as _, handleSendCalls as A, handleChainId as v, handleSignTypedData as D, handleEthSign as E, handleSwitchEthereumChain as P, handleDisconnect as R, handleSendTransaction as y, handlePersonalSign as T, handleRequestAccounts as q, handleAccounts as G } from "./index23.js";
|
|
9
|
+
import { onAuthStateChange as L } from "./index2.js";
|
|
10
|
+
import { baseSepolia as h } from "./index24.js";
|
|
11
|
+
function M(a, n, r) {
|
|
12
|
+
n.subscribe(
|
|
13
|
+
(e) => e.chainId,
|
|
14
|
+
(e, t) => {
|
|
15
|
+
e !== t && a.emit("chainChanged", e);
|
|
16
16
|
}
|
|
17
|
-
),
|
|
18
|
-
(
|
|
19
|
-
(
|
|
20
|
-
if (!(
|
|
21
|
-
if (!
|
|
22
|
-
|
|
17
|
+
), n.subscribe(
|
|
18
|
+
(e) => e.user,
|
|
19
|
+
(e, t) => {
|
|
20
|
+
if (!(e?.userId === t?.userId && e?.evmAccounts?.length === t?.evmAccounts?.length)) {
|
|
21
|
+
if (!e && t) {
|
|
22
|
+
a.emit("disconnect", new d.DisconnectedError());
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
|
|
25
|
+
if (e && e.evmAccounts?.length && (!t || t.evmAccounts?.length === 0)) {
|
|
26
|
+
const u = n.getState().chainId;
|
|
27
|
+
a.emit("connect", { chainId: u });
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
);
|
|
33
|
-
const { chainId:
|
|
34
|
-
return
|
|
35
|
-
request: async (
|
|
36
|
-
w(
|
|
37
|
-
const
|
|
38
|
-
switch (
|
|
33
|
+
const { chainId: o, setChainId: s } = n.getState(), c = o || r.chains[0].id;
|
|
34
|
+
return o || s(c), d.from({
|
|
35
|
+
request: async (e) => {
|
|
36
|
+
w(e, r);
|
|
37
|
+
const t = e;
|
|
38
|
+
switch (t.method) {
|
|
39
39
|
case "eth_accounts":
|
|
40
|
-
return
|
|
40
|
+
return G();
|
|
41
41
|
case "eth_requestAccounts":
|
|
42
|
-
return
|
|
42
|
+
return q(a, n);
|
|
43
43
|
case "personal_sign":
|
|
44
|
-
return
|
|
44
|
+
return T(t.params);
|
|
45
45
|
case "eth_sendTransaction":
|
|
46
|
-
return
|
|
46
|
+
return y(t.params, n, r.transports);
|
|
47
47
|
case "wallet_disconnect":
|
|
48
|
-
return
|
|
48
|
+
return R();
|
|
49
49
|
case "wallet_switchEthereumChain":
|
|
50
|
-
return
|
|
50
|
+
return P(t.params, n);
|
|
51
51
|
case "eth_sign":
|
|
52
|
-
return
|
|
52
|
+
return E(t.params);
|
|
53
53
|
case "eth_signTypedData_v4":
|
|
54
|
-
return
|
|
54
|
+
return D(t.params);
|
|
55
55
|
case "eth_chainId":
|
|
56
|
-
return
|
|
56
|
+
return v(n);
|
|
57
|
+
case "wallet_sendCalls":
|
|
58
|
+
return A(t.params, n);
|
|
59
|
+
case "wallet_getCallsStatus":
|
|
60
|
+
return _(t.params, n);
|
|
61
|
+
case "wallet_getCapabilities":
|
|
62
|
+
return I();
|
|
57
63
|
// Catch-all for any unknown method
|
|
58
64
|
default:
|
|
59
|
-
throw new
|
|
65
|
+
throw new C(
|
|
60
66
|
S.provider.unsupportedMethod,
|
|
61
|
-
`Method ${
|
|
67
|
+
`Method ${t.method} not supported`
|
|
62
68
|
);
|
|
63
69
|
}
|
|
64
70
|
},
|
|
65
71
|
// Event emitter methods - only the ones required by the interface
|
|
66
|
-
on:
|
|
67
|
-
removeListener:
|
|
72
|
+
on: a.on.bind(a),
|
|
73
|
+
removeListener: a.removeListener.bind(a)
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
|
-
const
|
|
71
|
-
chains: [
|
|
76
|
+
const l = {
|
|
77
|
+
chains: [h],
|
|
72
78
|
transports: {
|
|
73
|
-
[
|
|
79
|
+
[h.id]: p()
|
|
74
80
|
}
|
|
75
81
|
};
|
|
76
|
-
function
|
|
77
|
-
if (
|
|
82
|
+
function H(a) {
|
|
83
|
+
if (a?.chains.length === 0)
|
|
78
84
|
throw new Error("At least one chain must be configured");
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
85
|
+
const n = a?.chains ?? l.chains, r = a?.transports ?? l.transports;
|
|
86
|
+
if (n.length === 0)
|
|
81
87
|
throw new Error("No chains found in configuration");
|
|
82
|
-
const
|
|
88
|
+
const o = new b(), s = m()(
|
|
83
89
|
f(
|
|
84
90
|
g(
|
|
85
|
-
(
|
|
86
|
-
chainId:
|
|
87
|
-
setChainId: (
|
|
88
|
-
chains:
|
|
91
|
+
(i) => ({
|
|
92
|
+
chainId: n[0].id,
|
|
93
|
+
setChainId: (e) => i({ chainId: e }),
|
|
94
|
+
chains: n,
|
|
89
95
|
user: null,
|
|
90
|
-
setUser: (
|
|
96
|
+
setUser: (e) => i({ user: e })
|
|
91
97
|
}),
|
|
92
98
|
{
|
|
93
99
|
name: "cdp-provider-store"
|
|
@@ -96,15 +102,15 @@ function B(r) {
|
|
|
96
102
|
)
|
|
97
103
|
)
|
|
98
104
|
);
|
|
99
|
-
return
|
|
100
|
-
|
|
105
|
+
return s.persist.rehydrate(), L((i) => {
|
|
106
|
+
s.getState().setUser(i);
|
|
101
107
|
}), {
|
|
102
|
-
provider:
|
|
103
|
-
chains:
|
|
104
|
-
transports:
|
|
108
|
+
provider: M(o, s, {
|
|
109
|
+
chains: n,
|
|
110
|
+
transports: r
|
|
105
111
|
})
|
|
106
112
|
};
|
|
107
113
|
}
|
|
108
114
|
export {
|
|
109
|
-
|
|
115
|
+
H as createCDPEmbeddedWallet
|
|
110
116
|
};
|
package/dist/esm/index4.js
CHANGED
|
@@ -4,7 +4,7 @@ import "zustand";
|
|
|
4
4
|
import "@coinbase/cdp-api-client";
|
|
5
5
|
import { getCurrentUser as u } from "./index2.js";
|
|
6
6
|
import "./index3.js";
|
|
7
|
-
const
|
|
7
|
+
const r = {
|
|
8
8
|
rpc: {
|
|
9
9
|
invalidInput: -32e3,
|
|
10
10
|
resourceNotFound: -32001,
|
|
@@ -38,11 +38,11 @@ class o extends Error {
|
|
|
38
38
|
* @param code - The error code from EIP1193ErrorCode enum.
|
|
39
39
|
* @param message - The error message.
|
|
40
40
|
*/
|
|
41
|
-
constructor(t,
|
|
42
|
-
super(
|
|
41
|
+
constructor(t, n) {
|
|
42
|
+
super(n), this.code = t;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class c extends Error {
|
|
46
46
|
/**
|
|
47
47
|
* The error code from RPCErrorCode type.
|
|
48
48
|
*/
|
|
@@ -53,8 +53,8 @@ class a extends Error {
|
|
|
53
53
|
* @param code - The error code from RPCErrorCode type.
|
|
54
54
|
* @param message - The error message.
|
|
55
55
|
*/
|
|
56
|
-
constructor(t,
|
|
57
|
-
super(
|
|
56
|
+
constructor(t, n) {
|
|
57
|
+
super(n), this.code = t;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
const p = /* @__PURE__ */ new Set([
|
|
@@ -66,65 +66,78 @@ const p = /* @__PURE__ */ new Set([
|
|
|
66
66
|
"eth_chainId",
|
|
67
67
|
"eth_sign",
|
|
68
68
|
"wallet_disconnect",
|
|
69
|
-
"wallet_switchEthereumChain"
|
|
69
|
+
"wallet_switchEthereumChain",
|
|
70
|
+
"wallet_sendCalls",
|
|
71
|
+
"wallet_getCallsStatus",
|
|
72
|
+
"wallet_getCapabilities"
|
|
70
73
|
]);
|
|
71
|
-
function
|
|
72
|
-
const { method:
|
|
73
|
-
if (typeof
|
|
74
|
-
throw new
|
|
75
|
-
|
|
74
|
+
function _(e, { chains: t }) {
|
|
75
|
+
const { method: n, params: a } = e;
|
|
76
|
+
if (typeof n != "string" || n.length === 0)
|
|
77
|
+
throw new c(
|
|
78
|
+
r.rpc.invalidParams,
|
|
76
79
|
"'method' must be a non-empty string."
|
|
77
80
|
);
|
|
78
|
-
const
|
|
79
|
-
if (typeof
|
|
81
|
+
const s = (a ?? [])[0]?.chainId;
|
|
82
|
+
if (typeof s == "string" && !t.some((d) => d.id === Number.parseInt(s, 16)))
|
|
80
83
|
throw new o(
|
|
81
|
-
|
|
82
|
-
`Chain ${
|
|
84
|
+
r.provider.unsupportedChain,
|
|
85
|
+
`Chain ${s} not supported - make sure the provider is configured with the correct chains.`
|
|
83
86
|
);
|
|
84
|
-
if (
|
|
85
|
-
throw new
|
|
86
|
-
|
|
87
|
+
if (a !== void 0 && !Array.isArray(a))
|
|
88
|
+
throw new c(
|
|
89
|
+
r.rpc.invalidParams,
|
|
87
90
|
"'params' must be an array if provided."
|
|
88
91
|
);
|
|
89
|
-
if (!p.has(
|
|
92
|
+
if (!p.has(n))
|
|
90
93
|
throw new o(
|
|
91
|
-
|
|
94
|
+
r.provider.unsupportedMethod,
|
|
92
95
|
`Method ${e.method} not supported`
|
|
93
96
|
);
|
|
94
97
|
}
|
|
95
|
-
async function
|
|
98
|
+
async function i() {
|
|
96
99
|
const e = await u();
|
|
97
100
|
if (!e)
|
|
98
101
|
throw new o(
|
|
99
|
-
|
|
102
|
+
r.provider.unauthorized,
|
|
100
103
|
"User not connected"
|
|
101
104
|
);
|
|
102
105
|
return e;
|
|
103
106
|
}
|
|
104
|
-
async function
|
|
105
|
-
const t = await
|
|
107
|
+
async function E(e) {
|
|
108
|
+
const t = await i();
|
|
106
109
|
if (!t.evmAccounts?.includes(e))
|
|
107
110
|
throw new o(
|
|
108
|
-
|
|
111
|
+
r.provider.unauthorized,
|
|
109
112
|
"Address not owned by user"
|
|
110
113
|
);
|
|
111
114
|
return t;
|
|
112
115
|
}
|
|
113
|
-
async function
|
|
114
|
-
const e = await
|
|
116
|
+
async function y() {
|
|
117
|
+
const e = await i();
|
|
115
118
|
if (!e.evmAccounts?.[0])
|
|
116
119
|
throw new o(
|
|
117
|
-
|
|
120
|
+
r.provider.unauthorized,
|
|
118
121
|
"No EVM accounts available"
|
|
119
122
|
);
|
|
120
123
|
return e;
|
|
121
124
|
}
|
|
125
|
+
async function A() {
|
|
126
|
+
const e = await i();
|
|
127
|
+
if (!e.evmSmartAccounts?.[0])
|
|
128
|
+
throw new o(
|
|
129
|
+
r.provider.unauthorized,
|
|
130
|
+
"No EVM smart accounts available"
|
|
131
|
+
);
|
|
132
|
+
return e;
|
|
133
|
+
}
|
|
122
134
|
export {
|
|
123
135
|
o as EIP1193ProviderError,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
c as RPCRequestError,
|
|
137
|
+
r as STANDARD_ERROR_CODES,
|
|
138
|
+
_ as validateRequest,
|
|
139
|
+
i as validateUserConnected,
|
|
140
|
+
y as validateUserHasEvmAccount,
|
|
141
|
+
A as validateUserHasEvmSmartAccount,
|
|
142
|
+
E as validateUserOwnsAddress
|
|
130
143
|
};
|
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
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 "./index81.js";
|
|
2
|
+
import e from "./index82.js";
|
|
3
|
+
import i from "./index83.js";
|
|
4
|
+
import o from "./index84.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 "./index86.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,81 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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);
|
|
1
|
+
import { encode as d } from "./index88.js";
|
|
2
|
+
import y from "./index89.js";
|
|
3
|
+
import b from "./index90.js";
|
|
4
|
+
import { JWSInvalid as r } from "./index71.js";
|
|
5
|
+
import { encoder as s, concat as u, decoder as h } from "./index81.js";
|
|
6
|
+
import g from "./index91.js";
|
|
7
|
+
import H from "./index92.js";
|
|
8
|
+
import P from "./index93.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;
|
|
49
17
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return this.destroy(), n;
|
|
18
|
+
setProtectedHeader(e) {
|
|
19
|
+
if (this.#e)
|
|
20
|
+
throw new TypeError("setProtectedHeader can only be called once");
|
|
21
|
+
return this.#e = e, this;
|
|
55
22
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return t
|
|
23
|
+
setUnprotectedHeader(e) {
|
|
24
|
+
if (this.#t)
|
|
25
|
+
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
26
|
+
return this.#t = e, this;
|
|
60
27
|
}
|
|
61
|
-
|
|
62
|
-
|
|
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;
|
|
63
53
|
}
|
|
64
54
|
}
|
|
65
|
-
const B = /* @__PURE__ */ Uint32Array.from([
|
|
66
|
-
1779033703,
|
|
67
|
-
3144134277,
|
|
68
|
-
1013904242,
|
|
69
|
-
2773480762,
|
|
70
|
-
1359893119,
|
|
71
|
-
2600822924,
|
|
72
|
-
528734635,
|
|
73
|
-
1541459225
|
|
74
|
-
]);
|
|
75
55
|
export {
|
|
76
|
-
|
|
77
|
-
m as HashMD,
|
|
78
|
-
_ as Maj,
|
|
79
|
-
B as SHA256_IV,
|
|
80
|
-
y as setBigUint64
|
|
56
|
+
x as FlattenedSign
|
|
81
57
|
};
|
package/dist/esm/index81.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
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
|
+
}
|
|
10
9
|
export {
|
|
11
|
-
|
|
10
|
+
f as concat,
|
|
11
|
+
s as decoder,
|
|
12
|
+
d as encoder
|
|
12
13
|
};
|
package/dist/esm/index82.js
CHANGED
|
@@ -1,57 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
const o = (e) => Math.floor(e.getTime() / 1e3);
|
|
55
2
|
export {
|
|
56
|
-
|
|
3
|
+
o as default
|
|
57
4
|
};
|
package/dist/esm/index83.js
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const o = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, t = (c) => {
|
|
2
|
+
const s = o.exec(c);
|
|
3
|
+
if (!s || s[4] && s[1])
|
|
4
|
+
throw new TypeError("Invalid time period format");
|
|
5
|
+
const a = parseFloat(s[2]), r = s[3].toLowerCase();
|
|
6
|
+
let e;
|
|
7
|
+
switch (r) {
|
|
8
|
+
case "sec":
|
|
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
|
+
};
|
|
9
45
|
export {
|
|
10
|
-
|
|
11
|
-
s as decoder,
|
|
12
|
-
d as encoder
|
|
46
|
+
t as default
|
|
13
47
|
};
|
package/dist/esm/index84.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
function o(t) {
|
|
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
|
+
};
|
|
2
14
|
export {
|
|
3
|
-
|
|
15
|
+
r as default
|
|
4
16
|
};
|