@coinbase/cdp-core 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/dist/esm/index.js +17 -15
- package/dist/esm/index10.js +20 -14
- package/dist/esm/index100.js +6 -9
- package/dist/esm/index101.js +11 -13
- package/dist/esm/index102.js +11 -8
- package/dist/esm/index103.js +7 -14
- package/dist/esm/index104.js +16 -80
- package/dist/esm/index105.js +72 -70
- package/dist/esm/index106.js +81 -0
- package/dist/esm/index11.js +13 -117
- package/dist/esm/index12.js +116 -11
- package/dist/esm/index13.js +14 -22
- package/dist/esm/index14.js +42 -20
- package/dist/esm/index15.js +20 -172
- package/dist/esm/index16.js +170 -24
- package/dist/esm/index17.js +22 -156
- package/dist/esm/index18.js +157 -45
- package/dist/esm/index19.js +44 -149
- package/dist/esm/index2.js +10 -10
- package/dist/esm/index20.js +247 -53
- package/dist/esm/index21.js +56 -41
- package/dist/esm/index22.js +40 -16
- package/dist/esm/index23.js +16 -4
- package/dist/esm/index24.js +5 -5
- package/dist/esm/index25.js +5 -9
- package/dist/esm/index26.js +8 -17
- package/dist/esm/index27.js +16 -44
- package/dist/esm/index28.js +45 -13
- package/dist/esm/index29.js +13 -55
- package/dist/esm/index3.js +66 -60
- package/dist/esm/index30.js +55 -6
- package/dist/esm/index31.js +6 -21
- package/dist/esm/index32.js +21 -11
- package/dist/esm/index33.js +11 -3
- package/dist/esm/index34.js +3 -3
- package/dist/esm/index35.js +3 -34
- package/dist/esm/index36.js +32 -10
- package/dist/esm/index37.js +12 -4
- package/dist/esm/index38.js +4 -28
- package/dist/esm/index39.js +28 -6
- package/dist/esm/index4.js +48 -35
- package/dist/esm/index40.js +6 -24
- package/dist/esm/index41.js +24 -16
- package/dist/esm/index42.js +16 -54
- package/dist/esm/index43.js +53 -22
- package/dist/esm/index44.js +23 -11
- package/dist/esm/index45.js +10 -26
- package/dist/esm/index46.js +26 -41
- package/dist/esm/index47.js +41 -54
- package/dist/esm/index48.js +54 -126
- package/dist/esm/index49.js +126 -11
- package/dist/esm/index5.js +1 -1
- package/dist/esm/index50.js +9 -101
- package/dist/esm/index51.js +104 -6
- package/dist/esm/index52.js +7 -3
- package/dist/esm/index53.js +3 -15
- package/dist/esm/index54.js +14 -42
- package/dist/esm/index55.js +38 -74
- package/dist/esm/index56.js +79 -2
- package/dist/esm/index57.js +2 -2
- package/dist/esm/index58.js +2 -13
- package/dist/esm/index59.js +8 -33
- package/dist/esm/index6.js +13 -183
- package/dist/esm/index60.js +36 -5
- package/dist/esm/index61.js +5 -33
- package/dist/esm/index62.js +34 -8
- package/dist/esm/index63.js +8 -10
- package/dist/esm/index64.js +10 -11
- package/dist/esm/index65.js +11 -13
- package/dist/esm/index66.js +13 -18
- package/dist/esm/index67.js +18 -5
- package/dist/esm/index68.js +6 -5
- package/dist/esm/index69.js +5 -11
- package/dist/esm/index7.js +192 -15
- package/dist/esm/index70.js +10 -16
- package/dist/esm/index71.js +15 -21
- package/dist/esm/index72.js +21 -49
- package/dist/esm/index73.js +51 -2
- package/dist/esm/index74.js +1 -1
- package/dist/esm/index75.js +2 -20
- package/dist/esm/index76.js +20 -80
- package/dist/esm/index77.js +79 -103
- package/dist/esm/index78.js +101 -30
- package/dist/esm/index79.js +32 -6
- package/dist/esm/index8.js +14 -15
- package/dist/esm/index80.js +6 -78
- package/dist/esm/index81.js +79 -10
- package/dist/esm/index82.js +10 -55
- package/dist/esm/index83.js +54 -10
- package/dist/esm/index84.js +11 -2
- package/dist/esm/index85.js +2 -45
- package/dist/esm/index86.js +44 -13
- package/dist/esm/index87.js +14 -5
- package/dist/esm/index88.js +5 -13
- package/dist/esm/index89.js +12 -35
- package/dist/esm/index9.js +15 -20
- package/dist/esm/index90.js +35 -41
- package/dist/esm/index91.js +40 -19
- package/dist/esm/index92.js +21 -10
- package/dist/esm/index93.js +9 -19
- package/dist/esm/index94.js +15 -89
- package/dist/esm/index95.js +92 -19
- package/dist/esm/index96.js +18 -115
- package/dist/esm/index97.js +118 -18
- package/dist/esm/index98.js +18 -28
- package/dist/esm/index99.js +26 -6
- package/dist/types/index.d.ts +36 -1
- package/package.json +2 -2
package/dist/esm/index7.js
CHANGED
|
@@ -1,17 +1,194 @@
|
|
|
1
|
-
import "@coinbase/cdp-api-client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { logOutEndUser as h, refreshAccessToken as l, registerTemporaryWalletSecret as c } from "@coinbase/cdp-api-client";
|
|
2
|
+
import { SignJWT as o } from "./index22.js";
|
|
3
|
+
import "viem";
|
|
4
|
+
import { toAuthState as u } from "./index8.js";
|
|
5
|
+
import { createKeyPair as S } from "./index23.js";
|
|
6
|
+
import { generateRandomId as i } from "./index24.js";
|
|
7
|
+
import { hash as w } from "./index25.js";
|
|
8
|
+
import { sortKeys as f } from "./index14.js";
|
|
9
|
+
const n = 60 * 1e3;
|
|
10
|
+
class C {
|
|
11
|
+
projectId;
|
|
12
|
+
authState = null;
|
|
13
|
+
walletSecret = null;
|
|
14
|
+
authStateChangeCallbacks = [];
|
|
15
|
+
initPromise = null;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the token manager.
|
|
18
|
+
*
|
|
19
|
+
* @param projectId - The project ID.
|
|
20
|
+
*/
|
|
21
|
+
constructor(t) {
|
|
22
|
+
this.projectId = t, this.initPromise = this._doInitialize();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the current user, or null if there is no user signed in.
|
|
26
|
+
*
|
|
27
|
+
* @returns The current user.
|
|
28
|
+
*/
|
|
29
|
+
async getUser() {
|
|
30
|
+
return this.authState?.user ?? null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns whether the user is signed in - i.e., whether there is an unexpired
|
|
34
|
+
* access token and user.
|
|
35
|
+
*
|
|
36
|
+
* @returns True if the user is signed in, false otherwise.
|
|
37
|
+
*/
|
|
38
|
+
async isSignedIn() {
|
|
39
|
+
return this.authState ? Promise.resolve(this.authState.expiresAt > Date.now()) : Promise.resolve(!1);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Signs out the user, clearing all authentication state.
|
|
43
|
+
*/
|
|
44
|
+
async signOut() {
|
|
45
|
+
try {
|
|
46
|
+
await h(this.projectId);
|
|
47
|
+
} catch {
|
|
48
|
+
} finally {
|
|
49
|
+
await this.clearAuthState();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Adds a callback to be called when the auth state changes.
|
|
54
|
+
*
|
|
55
|
+
* @param callback - The function to call when the auth state changes.
|
|
56
|
+
*/
|
|
57
|
+
addAuthStateChangeCallback(t) {
|
|
58
|
+
this.authStateChangeCallbacks.push(t), t(this.authState?.user ?? null);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the access token, refreshing it if it is expired. Returns null if the user is not
|
|
62
|
+
* signed in.
|
|
63
|
+
*
|
|
64
|
+
* @returns The access token.
|
|
65
|
+
*/
|
|
66
|
+
async getToken() {
|
|
67
|
+
return this.shouldRefreshToken() && await this.refreshAccessToken(), this.authState?.accessToken ?? null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets the currently registered wallet secret ID. Rejects if the user is not signed in.
|
|
71
|
+
*
|
|
72
|
+
* @returns The wallet secret ID.
|
|
73
|
+
*/
|
|
74
|
+
async getWalletSecretId() {
|
|
75
|
+
if (!await this.isSignedIn())
|
|
76
|
+
throw new Error("Cannot get wallet secret ID if the user is not signed in");
|
|
77
|
+
return this.shouldRefreshWalletSecret() && await this.refreshWalletSecret(), this.walletSecret.walletSecretId;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the X-Wallet-Auth header. Rejects if the user is not signed in.
|
|
81
|
+
*
|
|
82
|
+
* @param options - The options for the request.
|
|
83
|
+
* @param options.requestMethod - The HTTP method of the request.
|
|
84
|
+
* @param options.requestHost - The host of the request.
|
|
85
|
+
* @param options.requestPath - The path of the request.
|
|
86
|
+
* @param options.requestData - The data of the request.
|
|
87
|
+
* @returns The X-Wallet-Auth header.
|
|
88
|
+
*/
|
|
89
|
+
async getXWalletAuth(t) {
|
|
90
|
+
if (!await this.isSignedIn())
|
|
91
|
+
throw new Error("Cannot get X-Wallet-Auth header if the user is not signed in");
|
|
92
|
+
this.shouldRefreshWalletSecret() && await this.refreshWalletSecret();
|
|
93
|
+
const e = `${t.requestMethod} ${t.requestHost}${t.requestPath}`, a = Math.floor(Date.now() / 1e3), r = {
|
|
94
|
+
uris: [e]
|
|
95
|
+
};
|
|
96
|
+
if (t.requestData && Object.keys(t.requestData).length > 0) {
|
|
97
|
+
const s = f(t.requestData);
|
|
98
|
+
r.reqHash = await w(new TextEncoder().encode(JSON.stringify(s)));
|
|
99
|
+
}
|
|
100
|
+
return await new o(r).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuedAt(a).setNotBefore(a).setJti(await i()).sign(this.walletSecret.keyPair.privateKey);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Sets the authentication state.
|
|
104
|
+
*
|
|
105
|
+
* @param authState - The authentication state.
|
|
106
|
+
*/
|
|
107
|
+
async setAuthState(t) {
|
|
108
|
+
this.authState = t, this.authStateChangeCallbacks.forEach((e) => e(this.authState?.user ?? null));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Clears the authentication state.
|
|
112
|
+
*/
|
|
113
|
+
async clearAuthState() {
|
|
114
|
+
this.authState = null, this.walletSecret = null, this.authStateChangeCallbacks.forEach((t) => t(null));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Ensures the AuthManager is initialized before proceeding.
|
|
118
|
+
* If initialization is already in progress, waits for it to complete.
|
|
119
|
+
*/
|
|
120
|
+
async ensureInitialized() {
|
|
121
|
+
if (this.initPromise) {
|
|
122
|
+
await this.initPromise;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
throw new Error("AuthManager not initialized");
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Internal async initialization logic.
|
|
129
|
+
*/
|
|
130
|
+
async _doInitialize() {
|
|
131
|
+
try {
|
|
132
|
+
await this.refreshAccessToken();
|
|
133
|
+
} catch (t) {
|
|
134
|
+
console.warn("Failed to refresh access token during initialization:", t);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Returns whether the token should be refreshed.
|
|
139
|
+
*
|
|
140
|
+
* @returns True if the token should be refreshed, false otherwise.
|
|
141
|
+
*/
|
|
142
|
+
shouldRefreshToken() {
|
|
143
|
+
return !(this.authState && this.authState.expiresAt > Date.now() + n);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Refreshes the access token and transitions the auth state accordingly.
|
|
147
|
+
* If a refresh is already in progress, it will wait for that refresh to complete.
|
|
148
|
+
*
|
|
149
|
+
* @returns The new access token.
|
|
150
|
+
*/
|
|
151
|
+
async refreshAccessToken() {
|
|
152
|
+
try {
|
|
153
|
+
const t = await l(this.projectId, {
|
|
154
|
+
grantType: "refresh_token"
|
|
155
|
+
}), e = u(
|
|
156
|
+
t.accessToken,
|
|
157
|
+
t.validUntil,
|
|
158
|
+
t.endUser
|
|
159
|
+
);
|
|
160
|
+
await this.setAuthState(e);
|
|
161
|
+
} catch {
|
|
162
|
+
await this.signOut();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns whether the wallet secret should be refreshed.
|
|
167
|
+
*
|
|
168
|
+
* @returns True if the wallet secret should be refreshed, false otherwise.
|
|
169
|
+
*/
|
|
170
|
+
shouldRefreshWalletSecret() {
|
|
171
|
+
return !(this.walletSecret && this.walletSecret.expiresAt > Date.now() + n);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Refreshes the wallet secret. Assumes the user is signed in.
|
|
175
|
+
*
|
|
176
|
+
* @returns The wallet secret.
|
|
177
|
+
*/
|
|
178
|
+
async refreshWalletSecret() {
|
|
179
|
+
const t = this.walletSecret?.walletSecretId ?? await i(), e = this.walletSecret?.keyPair ?? await S(), a = this.authState.expiresAt, r = new Date(a).toISOString();
|
|
180
|
+
this.walletSecret = { walletSecretId: t, keyPair: e, expiresAt: a };
|
|
181
|
+
try {
|
|
182
|
+
await c(this.projectId, this.authState.user.userId, {
|
|
183
|
+
walletSecretId: t,
|
|
184
|
+
publicKey: e.publicKeyBase64,
|
|
185
|
+
validUntil: r
|
|
186
|
+
});
|
|
187
|
+
} catch (s) {
|
|
188
|
+
throw this.walletSecret = null, s;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
15
192
|
export {
|
|
16
|
-
|
|
193
|
+
C as AuthManager
|
|
17
194
|
};
|
package/dist/esm/index70.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
}
|
|
1
|
+
function a(r, n) {
|
|
2
|
+
let t = r.toString();
|
|
3
|
+
const i = t.startsWith("-");
|
|
4
|
+
i && (t = t.slice(1)), t = t.padStart(n, "0");
|
|
5
|
+
let [l, e] = [
|
|
6
|
+
t.slice(0, t.length - n),
|
|
7
|
+
t.slice(t.length - n)
|
|
8
|
+
];
|
|
9
|
+
return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
|
|
16
10
|
}
|
|
17
11
|
export {
|
|
18
|
-
|
|
12
|
+
a as formatUnits
|
|
19
13
|
};
|
package/dist/esm/index71.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
constructor(
|
|
5
|
-
|
|
1
|
+
import { FlattenedSign as n } from "./index83.js";
|
|
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}`;
|
|
6
15
|
}
|
|
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
16
|
}
|
|
20
17
|
export {
|
|
21
|
-
|
|
22
|
-
E as JOSENotSupported,
|
|
23
|
-
o as JWSInvalid,
|
|
24
|
-
r as JWTInvalid
|
|
18
|
+
o as CompactSign
|
|
25
19
|
};
|
package/dist/esm/index72.js
CHANGED
|
@@ -1,53 +1,25 @@
|
|
|
1
|
-
|
|
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);
|
|
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);
|
|
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);
|
|
49
6
|
}
|
|
50
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
|
+
}
|
|
51
20
|
export {
|
|
52
|
-
|
|
21
|
+
c as JOSEError,
|
|
22
|
+
E as JOSENotSupported,
|
|
23
|
+
o as JWSInvalid,
|
|
24
|
+
r as JWTInvalid
|
|
53
25
|
};
|
package/dist/esm/index73.js
CHANGED
|
@@ -1,4 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
import { encoder as n } from "./index84.js";
|
|
2
|
+
import e from "./index85.js";
|
|
3
|
+
import i from "./index86.js";
|
|
4
|
+
import o from "./index87.js";
|
|
5
|
+
function s(r, t) {
|
|
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);
|
|
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);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
2
51
|
export {
|
|
3
|
-
|
|
52
|
+
d as JWTClaimsBuilder
|
|
4
53
|
};
|
package/dist/esm/index74.js
CHANGED
package/dist/esm/index75.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
const o =
|
|
2
|
-
function s(t, r = !1) {
|
|
3
|
-
return r ? { h: Number(t & o), l: Number(t >> i & o) } : { h: Number(t >> i & o) | 0, l: Number(t & o) | 0 };
|
|
4
|
-
}
|
|
5
|
-
function h(t, r = !1) {
|
|
6
|
-
const n = t.length;
|
|
7
|
-
let l = new Uint32Array(n), c = new Uint32Array(n);
|
|
8
|
-
for (let e = 0; e < n; e++) {
|
|
9
|
-
const { h: u, l: f } = s(t[e], r);
|
|
10
|
-
[l[e], c[e]] = [u, f];
|
|
11
|
-
}
|
|
12
|
-
return [l, c];
|
|
13
|
-
}
|
|
14
|
-
const m = (t, r, n) => t << n | r >>> 32 - n, A = (t, r, n) => r << n | t >>> 32 - n, B = (t, r, n) => r << n - 32 | t >>> 64 - n, a = (t, r, n) => t << n - 32 | r >>> 64 - n;
|
|
1
|
+
const o = "2.33.0";
|
|
15
2
|
export {
|
|
16
|
-
|
|
17
|
-
B as rotlBH,
|
|
18
|
-
a as rotlBL,
|
|
19
|
-
m as rotlSH,
|
|
20
|
-
A as rotlSL,
|
|
21
|
-
h as split
|
|
3
|
+
o as version
|
|
22
4
|
};
|
package/dist/esm/index76.js
CHANGED
|
@@ -1,82 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
return
|
|
4
|
-
}
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function h(e, t = !0) {
|
|
16
|
-
if (e.destroyed)
|
|
17
|
-
throw new Error("Hash instance has been destroyed");
|
|
18
|
-
if (t && e.finished)
|
|
19
|
-
throw new Error("Hash#digest() has already been called");
|
|
20
|
-
}
|
|
21
|
-
function l(e, t) {
|
|
22
|
-
r(e);
|
|
23
|
-
const n = t.outputLen;
|
|
24
|
-
if (e.length < n)
|
|
25
|
-
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
26
|
-
}
|
|
27
|
-
function a(e) {
|
|
28
|
-
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
29
|
-
}
|
|
30
|
-
function g(...e) {
|
|
31
|
-
for (let t = 0; t < e.length; t++)
|
|
32
|
-
e[t].fill(0);
|
|
33
|
-
}
|
|
34
|
-
function p(e) {
|
|
35
|
-
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
36
|
-
}
|
|
37
|
-
function b(e, t) {
|
|
38
|
-
return e << 32 - t | e >>> t;
|
|
39
|
-
}
|
|
40
|
-
const i = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
41
|
-
function u(e) {
|
|
42
|
-
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
43
|
-
}
|
|
44
|
-
function c(e) {
|
|
45
|
-
for (let t = 0; t < e.length; t++)
|
|
46
|
-
e[t] = u(e[t]);
|
|
47
|
-
return e;
|
|
48
|
-
}
|
|
49
|
-
const x = i ? (e) => e : c;
|
|
50
|
-
function s(e) {
|
|
51
|
-
if (typeof e != "string")
|
|
52
|
-
throw new Error("string expected");
|
|
53
|
-
return new Uint8Array(new TextEncoder().encode(e));
|
|
54
|
-
}
|
|
55
|
-
function y(e) {
|
|
56
|
-
return typeof e == "string" && (e = s(e)), r(e), e;
|
|
57
|
-
}
|
|
58
|
-
class d {
|
|
59
|
-
}
|
|
60
|
-
function E(e) {
|
|
61
|
-
const t = (f) => e().update(y(f)).digest(), n = e();
|
|
62
|
-
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
63
|
-
}
|
|
1
|
+
const o = /* @__PURE__ */ BigInt(4294967295), i = /* @__PURE__ */ BigInt(32);
|
|
2
|
+
function s(t, r = !1) {
|
|
3
|
+
return r ? { h: Number(t & o), l: Number(t >> i & o) } : { h: Number(t >> i & o) | 0, l: Number(t & o) | 0 };
|
|
4
|
+
}
|
|
5
|
+
function h(t, r = !1) {
|
|
6
|
+
const n = t.length;
|
|
7
|
+
let l = new Uint32Array(n), c = new Uint32Array(n);
|
|
8
|
+
for (let e = 0; e < n; e++) {
|
|
9
|
+
const { h: u, l: f } = s(t[e], r);
|
|
10
|
+
[l[e], c[e]] = [u, f];
|
|
11
|
+
}
|
|
12
|
+
return [l, c];
|
|
13
|
+
}
|
|
14
|
+
const m = (t, r, n) => t << n | r >>> 32 - n, A = (t, r, n) => r << n | t >>> 32 - n, B = (t, r, n) => r << n - 32 | t >>> 64 - n, a = (t, r, n) => t << n - 32 | r >>> 64 - n;
|
|
64
15
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
c as byteSwap32,
|
|
72
|
-
g as clean,
|
|
73
|
-
E as createHasher,
|
|
74
|
-
p as createView,
|
|
75
|
-
o as isBytes,
|
|
76
|
-
i as isLE,
|
|
77
|
-
b as rotr,
|
|
78
|
-
x as swap32IfBE,
|
|
79
|
-
y as toBytes,
|
|
80
|
-
a as u32,
|
|
81
|
-
s as utf8ToBytes
|
|
16
|
+
s as fromBig,
|
|
17
|
+
B as rotlBH,
|
|
18
|
+
a as rotlBL,
|
|
19
|
+
m as rotlSH,
|
|
20
|
+
A as rotlSL,
|
|
21
|
+
h as split
|
|
82
22
|
};
|