@coinbase/cdp-core 0.0.18 → 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 +3 -3
- package/dist/esm/index2.js +138 -124
- package/dist/esm/index24.js +1 -1
- package/dist/esm/index47.js +1 -1
- package/dist/esm/index48.js +1 -1
- 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/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 -9
- 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/dist/esm/index98.js +1 -1
- package/dist/types/index.d.ts +26 -0
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { exportEvmAccount as n,
|
|
2
|
-
import { APIError as
|
|
1
|
+
import { exportEvmAccount as n, getAccessToken as m, getCurrentUser as s, initialize as E, isSignedIn as a, onAuthStateChange as p, sendEvmTransaction as c, signEvmHash as g, signEvmMessage as d, signEvmTransaction as v, signEvmTypedData as T, signInWithEmail as A, signInWithSms as f, signOut as S, verifyEmailOTP as h, verifySmsOTP as u } from "./index2.js";
|
|
2
|
+
import { APIError as y, ErrorType as P, HttpErrorType as l, SendEvmTransactionWithEndUserAccountBodyNetwork as D } from "@coinbase/cdp-api-client";
|
|
3
3
|
import "viem";
|
|
4
|
-
import { createCDPEmbeddedWallet as
|
|
5
|
-
import { EIP1193ProviderError as
|
|
4
|
+
import { createCDPEmbeddedWallet as O } from "./index3.js";
|
|
5
|
+
import { EIP1193ProviderError as R, STANDARD_ERROR_CODES as W } from "./index4.js";
|
|
6
6
|
import "ox";
|
|
7
7
|
import "zustand";
|
|
8
|
-
import { toViemAccount as
|
|
8
|
+
import { toViemAccount as H } from "./index5.js";
|
|
9
9
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
y as APIError,
|
|
11
|
+
R as EIP1193ProviderError,
|
|
12
|
+
P as ErrorType,
|
|
13
13
|
l as HttpErrorType,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
W as STANDARD_ERROR_CODES,
|
|
15
|
+
D as SendEvmTransactionWithEndUserAccountBodyNetwork,
|
|
16
|
+
O as createCDPEmbeddedWallet,
|
|
17
17
|
n as exportEvmAccount,
|
|
18
|
-
m as
|
|
18
|
+
m as getAccessToken,
|
|
19
|
+
s as getCurrentUser,
|
|
19
20
|
E as initialize,
|
|
20
21
|
a as isSignedIn,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
p as onAuthStateChange,
|
|
23
|
+
c as sendEvmTransaction,
|
|
24
|
+
g as signEvmHash,
|
|
24
25
|
d as signEvmMessage,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
v as signEvmTransaction,
|
|
27
|
+
T as signEvmTypedData,
|
|
28
|
+
A as signInWithEmail,
|
|
29
|
+
f as signInWithSms,
|
|
30
|
+
S as signOut,
|
|
31
|
+
H as toViemAccount,
|
|
32
|
+
h as verifyEmailOTP,
|
|
33
|
+
u as verifySmsOTP
|
|
31
34
|
};
|
package/dist/esm/index103.js
CHANGED
package/dist/esm/index104.js
CHANGED
package/dist/esm/index17.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CompactSign as i } from "./
|
|
2
|
-
import { JWTInvalid as r } from "./
|
|
3
|
-
import { JWTClaimsBuilder as n } from "./
|
|
1
|
+
import { CompactSign as i } from "./index72.js";
|
|
2
|
+
import { JWTInvalid as r } from "./index73.js";
|
|
3
|
+
import { JWTClaimsBuilder as n } from "./index74.js";
|
|
4
4
|
class d {
|
|
5
5
|
#s;
|
|
6
6
|
#t;
|
package/dist/esm/index2.js
CHANGED
|
@@ -1,176 +1,190 @@
|
|
|
1
|
-
import { configureCdpApiClient as
|
|
2
|
-
import { AuthManager as
|
|
3
|
-
import { toAuthState as
|
|
4
|
-
import { withAuth as
|
|
5
|
-
import { createExportKeyPair as
|
|
6
|
-
import { decryptWithPrivateKey as
|
|
7
|
-
import { MockAuthManager as
|
|
8
|
-
import { mockUser as
|
|
9
|
-
import { isChainSupportedForCDPSends as
|
|
10
|
-
import { getConfig as
|
|
1
|
+
import { configureCdpApiClient as I, setAuthManager as l, initiateAuthentication as v, createEndUserEvmAccount as A, verifyEmailAuthentication as E, verifySmsAuthentication as k, signEvmHashWithEndUserAccount as S, signEvmTransactionWithEndUserAccount as M, sendEvmTransactionWithEndUserAccount as T, signEvmMessageWithEndUserAccount as U, signEvmTypedDataWithEndUserAccount as C, exportEndUserEvmAccount as j } from "@coinbase/cdp-api-client";
|
|
2
|
+
import { AuthManager as P } from "./index6.js";
|
|
3
|
+
import { toAuthState as d } from "./index7.js";
|
|
4
|
+
import { withAuth as o } from "./index8.js";
|
|
5
|
+
import { createExportKeyPair as x } from "./index9.js";
|
|
6
|
+
import { decryptWithPrivateKey as b } from "./index10.js";
|
|
7
|
+
import { MockAuthManager as K } from "./index11.js";
|
|
8
|
+
import { mockUser as g } from "./index12.js";
|
|
9
|
+
import { isChainSupportedForCDPSends as W } from "./index13.js";
|
|
10
|
+
import { getConfig as n, setCoreAuthManager as m, getCoreAuthManager as s, setConfig as D } from "./index14.js";
|
|
11
11
|
import "viem";
|
|
12
|
-
import { serializeTransaction as
|
|
13
|
-
const
|
|
12
|
+
import { serializeTransaction as p } from "./index15.js";
|
|
13
|
+
const Q = async (e) => {
|
|
14
14
|
if (!e.projectId)
|
|
15
15
|
throw new Error("Project ID is required");
|
|
16
|
-
let
|
|
16
|
+
let r;
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
r = n().projectId !== e.projectId;
|
|
19
19
|
} catch {
|
|
20
|
-
|
|
20
|
+
r = !0;
|
|
21
21
|
}
|
|
22
|
-
if (
|
|
23
|
-
|
|
22
|
+
if (D(e), n().useMock) {
|
|
23
|
+
m(new K(n().projectId));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
debugging:
|
|
28
|
-
basePath:
|
|
29
|
-
}),
|
|
30
|
-
const t = new
|
|
31
|
-
|
|
26
|
+
if (I({
|
|
27
|
+
debugging: n().debugging,
|
|
28
|
+
basePath: n().basePath
|
|
29
|
+
}), r) {
|
|
30
|
+
const t = new P(n().projectId);
|
|
31
|
+
m(t), l(t);
|
|
32
32
|
}
|
|
33
|
-
await
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (r().useMock)
|
|
52
|
-
return await n().setAuthState({
|
|
53
|
-
accessToken: "mock-access-token",
|
|
54
|
-
expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
|
|
55
|
-
user: d
|
|
56
|
-
}), {
|
|
57
|
-
message: "Mock email OTP verified",
|
|
58
|
-
user: d,
|
|
59
|
-
isNewUser: !1
|
|
60
|
-
};
|
|
61
|
-
if (await n().isSignedIn())
|
|
62
|
-
throw new Error("User is already authenticated. Please sign out first.");
|
|
63
|
-
const t = await f(r().projectId, {
|
|
64
|
-
flowId: e.flowId,
|
|
65
|
-
otp: e.otp
|
|
66
|
-
});
|
|
67
|
-
let a = u(t.accessToken, t.validUntil, t.endUser);
|
|
68
|
-
if (await n().setAuthState(a), !a.user.evmAccounts || a.user.evmAccounts.length === 0)
|
|
69
|
-
try {
|
|
70
|
-
const o = await n().getWalletSecretId(), p = await I(r().projectId, a.user.userId, {
|
|
71
|
-
walletSecretId: o
|
|
72
|
-
});
|
|
73
|
-
a = u(t.accessToken, t.validUntil, p), await n().setAuthState(a);
|
|
74
|
-
} catch (o) {
|
|
75
|
-
throw new Error(`Failed to create EVM account: ${o}`);
|
|
76
|
-
}
|
|
77
|
-
const c = await n().getUser();
|
|
78
|
-
return {
|
|
79
|
-
message: t.message,
|
|
80
|
-
user: c,
|
|
81
|
-
isNewUser: t.isNewEndUser
|
|
82
|
-
};
|
|
83
|
-
}, J = async () => n().getUser(), L = async () => n().isSignedIn(), Q = async () => {
|
|
84
|
-
if (r().useMock) {
|
|
85
|
-
await n().signOut();
|
|
33
|
+
await s().ensureInitialized();
|
|
34
|
+
}, R = async (e) => h({
|
|
35
|
+
email: e.email,
|
|
36
|
+
type: "email"
|
|
37
|
+
}), X = async (e) => h({
|
|
38
|
+
phoneNumber: e.phoneNumber,
|
|
39
|
+
type: "sms"
|
|
40
|
+
}), Y = async (e) => w(
|
|
41
|
+
e,
|
|
42
|
+
"Mock email OTP verified",
|
|
43
|
+
(r, t) => E(r, t)
|
|
44
|
+
), Z = async (e) => w(
|
|
45
|
+
e,
|
|
46
|
+
"Mock SMS OTP verified",
|
|
47
|
+
(r, t) => k(r, t)
|
|
48
|
+
), _ = async () => s().getUser(), ee = async () => s().isSignedIn(), te = async () => {
|
|
49
|
+
if (n().useMock) {
|
|
50
|
+
await s().signOut();
|
|
86
51
|
return;
|
|
87
52
|
}
|
|
88
|
-
if (!await
|
|
53
|
+
if (!await s().isSignedIn())
|
|
89
54
|
throw new Error("User not signed in");
|
|
90
|
-
await
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
signature: (await
|
|
55
|
+
await s().signOut();
|
|
56
|
+
}, ne = async () => s().getToken(), re = (e) => {
|
|
57
|
+
s().addAuthStateChangeCallback(e);
|
|
58
|
+
}, se = async (e) => n().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => ({
|
|
59
|
+
signature: (await S(n().projectId, r.userId, {
|
|
95
60
|
hash: e.hash,
|
|
96
61
|
address: e.evmAccount,
|
|
97
62
|
walletSecretId: t
|
|
98
63
|
})).signature
|
|
99
|
-
})),
|
|
100
|
-
const
|
|
64
|
+
})), ae = async (e) => n().useMock ? { signedTransaction: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => {
|
|
65
|
+
const i = p(e.transaction);
|
|
101
66
|
return {
|
|
102
|
-
signedTransaction: (await
|
|
103
|
-
|
|
104
|
-
|
|
67
|
+
signedTransaction: (await M(
|
|
68
|
+
n().projectId,
|
|
69
|
+
r.userId,
|
|
105
70
|
{
|
|
106
|
-
transaction:
|
|
71
|
+
transaction: i,
|
|
107
72
|
address: e.evmAccount,
|
|
108
73
|
walletSecretId: t
|
|
109
74
|
}
|
|
110
75
|
)).signedTransaction
|
|
111
76
|
};
|
|
112
|
-
}),
|
|
113
|
-
if (!
|
|
77
|
+
}), ie = async (e) => {
|
|
78
|
+
if (!W(e.network))
|
|
114
79
|
throw new Error(`Chain ${e.network} is not supported by the CDP Apis`);
|
|
115
|
-
if (
|
|
80
|
+
if (n().useMock)
|
|
116
81
|
return { transactionHash: "0x0" };
|
|
117
|
-
const
|
|
118
|
-
return
|
|
119
|
-
transactionHash: (await
|
|
120
|
-
|
|
82
|
+
const r = p(e.transaction);
|
|
83
|
+
return o(e, s(), async ({ user: t, walletSecretId: i }) => ({
|
|
84
|
+
transactionHash: (await T(
|
|
85
|
+
n().projectId,
|
|
121
86
|
t.userId,
|
|
122
87
|
{
|
|
123
|
-
transaction:
|
|
88
|
+
transaction: r,
|
|
124
89
|
address: e.evmAccount,
|
|
125
|
-
walletSecretId:
|
|
90
|
+
walletSecretId: i,
|
|
126
91
|
network: e.network
|
|
127
92
|
}
|
|
128
93
|
)).transactionHash
|
|
129
94
|
}));
|
|
130
|
-
},
|
|
131
|
-
signature: (await
|
|
95
|
+
}, ce = async (e) => n().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => ({
|
|
96
|
+
signature: (await U(n().projectId, r.userId, {
|
|
132
97
|
message: e.message,
|
|
133
98
|
address: e.evmAccount,
|
|
134
99
|
walletSecretId: t
|
|
135
100
|
})).signature
|
|
136
|
-
})),
|
|
137
|
-
signature: (await
|
|
101
|
+
})), oe = async (e) => n().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => ({
|
|
102
|
+
signature: (await C(n().projectId, r.userId, {
|
|
138
103
|
typedData: e.typedData,
|
|
139
104
|
address: e.evmAccount,
|
|
140
105
|
walletSecretId: t
|
|
141
106
|
})).signature
|
|
142
|
-
})),
|
|
143
|
-
if (
|
|
107
|
+
})), ue = async (e) => {
|
|
108
|
+
if (n().useMock)
|
|
144
109
|
return {
|
|
145
110
|
privateKey: "mock-private-key"
|
|
146
111
|
};
|
|
147
|
-
const
|
|
148
|
-
return
|
|
149
|
-
const
|
|
112
|
+
const r = await x();
|
|
113
|
+
return o(e, s(), async ({ user: t, walletSecretId: i }) => {
|
|
114
|
+
const a = await j(n().projectId, t.userId, {
|
|
150
115
|
address: e.evmAccount,
|
|
151
|
-
walletSecretId:
|
|
152
|
-
exportEncryptionKey:
|
|
116
|
+
walletSecretId: i,
|
|
117
|
+
exportEncryptionKey: r.publicKeyBase64
|
|
153
118
|
});
|
|
154
119
|
return {
|
|
155
|
-
privateKey: await
|
|
156
|
-
|
|
157
|
-
|
|
120
|
+
privateKey: await b(
|
|
121
|
+
r.privateKey,
|
|
122
|
+
a.encryptedPrivateKey
|
|
158
123
|
)
|
|
159
124
|
};
|
|
160
125
|
});
|
|
126
|
+
}, h = async (e) => {
|
|
127
|
+
if (n().useMock)
|
|
128
|
+
return {
|
|
129
|
+
message: "Mock sign in initiated",
|
|
130
|
+
flowId: "mock-flow-id"
|
|
131
|
+
};
|
|
132
|
+
if (await s().isSignedIn())
|
|
133
|
+
throw new Error("User is already authenticated. Please sign out first.");
|
|
134
|
+
const t = await v(n().projectId, e);
|
|
135
|
+
return {
|
|
136
|
+
flowId: t.flowId,
|
|
137
|
+
message: t.message
|
|
138
|
+
};
|
|
139
|
+
}, w = async (e, r, t) => {
|
|
140
|
+
if (n().useMock)
|
|
141
|
+
return await s().setAuthState({
|
|
142
|
+
accessToken: "mock-access-token",
|
|
143
|
+
expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
|
|
144
|
+
user: g
|
|
145
|
+
}), {
|
|
146
|
+
message: r,
|
|
147
|
+
user: g,
|
|
148
|
+
isNewUser: !1
|
|
149
|
+
};
|
|
150
|
+
if (await s().isSignedIn())
|
|
151
|
+
throw new Error("User is already authenticated. Please sign out first.");
|
|
152
|
+
const a = await t(n().projectId, {
|
|
153
|
+
flowId: e.flowId,
|
|
154
|
+
otp: e.otp
|
|
155
|
+
});
|
|
156
|
+
let c = d(a.accessToken, a.validUntil, a.endUser);
|
|
157
|
+
if (await s().setAuthState(c), !c.user.evmAccounts || c.user.evmAccounts.length === 0)
|
|
158
|
+
try {
|
|
159
|
+
const u = await s().getWalletSecretId(), f = await A(n().projectId, c.user.userId, {
|
|
160
|
+
walletSecretId: u
|
|
161
|
+
});
|
|
162
|
+
c = d(a.accessToken, a.validUntil, f), await s().setAuthState(c);
|
|
163
|
+
} catch (u) {
|
|
164
|
+
throw new Error(`Failed to create EVM account: ${u}`);
|
|
165
|
+
}
|
|
166
|
+
const y = await s().getUser();
|
|
167
|
+
return {
|
|
168
|
+
message: a.message,
|
|
169
|
+
user: y,
|
|
170
|
+
isNewUser: a.isNewEndUser
|
|
171
|
+
};
|
|
161
172
|
};
|
|
162
173
|
export {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
ue as exportEvmAccount,
|
|
175
|
+
ne as getAccessToken,
|
|
176
|
+
_ as getCurrentUser,
|
|
177
|
+
Q as initialize,
|
|
178
|
+
ee as isSignedIn,
|
|
179
|
+
re as onAuthStateChange,
|
|
180
|
+
ie as sendEvmTransaction,
|
|
181
|
+
se as signEvmHash,
|
|
182
|
+
ce as signEvmMessage,
|
|
183
|
+
ae as signEvmTransaction,
|
|
184
|
+
oe as signEvmTypedData,
|
|
185
|
+
R as signInWithEmail,
|
|
186
|
+
X as signInWithSms,
|
|
187
|
+
te as signOut,
|
|
188
|
+
Y as verifyEmailOTP,
|
|
189
|
+
Z as verifySmsOTP
|
|
176
190
|
};
|
package/dist/esm/index24.js
CHANGED
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/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
|
};
|