@coinbase/cdp-core 0.0.13 → 0.0.15
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 +4 -0
- package/dist/esm/index103.js +1 -1
- package/dist/esm/index104.js +1 -1
- package/dist/esm/index12.js +10 -4
- package/dist/esm/index17.js +158 -39
- package/dist/esm/index18.js +47 -16
- package/dist/esm/index19.js +150 -4
- package/dist/esm/index2.js +5 -5
- package/dist/esm/index20.js +56 -5
- package/dist/esm/index21.js +39 -158
- package/dist/esm/index22.js +16 -47
- package/dist/esm/index23.js +4 -145
- package/dist/esm/index24.js +5 -56
- package/dist/esm/index3.js +47 -47
- package/dist/esm/index4.js +2 -2
- package/dist/esm/index47.js +1 -1
- package/dist/esm/index48.js +1 -1
- package/dist/esm/index6.js +4 -4
- package/dist/esm/index7.js +9 -8
- package/dist/esm/index70.js +17 -2
- package/dist/esm/index71.js +19 -17
- package/dist/esm/index72.js +47 -13
- package/dist/esm/index73.js +2 -23
- package/dist/esm/index74.js +17 -47
- package/dist/esm/index77.js +1 -1
- package/dist/esm/index8.js +1 -1
- package/dist/esm/index80.js +10 -79
- package/dist/esm/index81.js +55 -10
- package/dist/esm/index82.js +10 -54
- package/dist/esm/index83.js +2 -11
- package/dist/esm/index84.js +45 -2
- package/dist/esm/index85.js +13 -44
- package/dist/esm/index86.js +78 -13
- 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 +13 -1
- package/package.json +2 -2
package/dist/esm/index7.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
userId:
|
|
4
|
-
evmAccounts:
|
|
1
|
+
const c = (u, n, e) => {
|
|
2
|
+
const o = new Date(n).getTime(), r = {
|
|
3
|
+
userId: e.userId,
|
|
4
|
+
evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
|
|
5
|
+
authenticationMethods: e.authenticationMethods.reduce((t, s) => (t[s.type] = s, t), {})
|
|
5
6
|
};
|
|
6
7
|
return {
|
|
7
|
-
accessToken:
|
|
8
|
-
expiresAt:
|
|
9
|
-
user:
|
|
8
|
+
accessToken: u,
|
|
9
|
+
expiresAt: o,
|
|
10
|
+
user: r
|
|
10
11
|
};
|
|
11
12
|
};
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
+
c as toAuthState
|
|
14
15
|
};
|
package/dist/esm/index70.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { FlattenedSign as n } from "./index81.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}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
2
17
|
export {
|
|
3
|
-
o as
|
|
18
|
+
o as CompactSign
|
|
4
19
|
};
|
package/dist/esm/index71.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
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);
|
|
7
6
|
}
|
|
8
7
|
}
|
|
9
|
-
class
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
8
|
+
class E extends c {
|
|
9
|
+
static code = "ERR_JOSE_NOT_SUPPORTED";
|
|
10
|
+
code = "ERR_JOSE_NOT_SUPPORTED";
|
|
13
11
|
}
|
|
14
|
-
class
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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";
|
|
18
19
|
}
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
c as JOSEError,
|
|
22
|
+
E as JOSENotSupported,
|
|
23
|
+
o as JWSInvalid,
|
|
24
|
+
r as JWTInvalid
|
|
23
25
|
};
|
package/dist/esm/index72.js
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { encoder as n } from "./index82.js";
|
|
2
|
+
import e from "./index83.js";
|
|
3
|
+
import i from "./index84.js";
|
|
4
|
+
import o from "./index85.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);
|
|
6
43
|
}
|
|
7
|
-
|
|
8
|
-
|
|
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);
|
|
9
46
|
}
|
|
10
|
-
|
|
11
|
-
|
|
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}`;
|
|
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);
|
|
15
49
|
}
|
|
16
50
|
}
|
|
17
51
|
export {
|
|
18
|
-
|
|
52
|
+
d as JWTClaimsBuilder
|
|
19
53
|
};
|
package/dist/esm/index73.js
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
const o = "2.33.0";
|
|
20
2
|
export {
|
|
21
|
-
|
|
22
|
-
E as JOSENotSupported,
|
|
23
|
-
o as JWSInvalid,
|
|
24
|
-
r as JWTInvalid
|
|
3
|
+
o as version
|
|
25
4
|
};
|
package/dist/esm/index74.js
CHANGED
|
@@ -1,53 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
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
|
+
});
|
|
31
7
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
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);
|
|
8
|
+
}
|
|
9
|
+
class n extends o {
|
|
10
|
+
constructor({ length: e, position: r }) {
|
|
11
|
+
super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" });
|
|
46
12
|
}
|
|
47
|
-
|
|
48
|
-
|
|
13
|
+
}
|
|
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" });
|
|
49
17
|
}
|
|
50
18
|
}
|
|
51
19
|
export {
|
|
52
|
-
|
|
20
|
+
i as NegativeOffsetError,
|
|
21
|
+
n as PositionOutOfBoundsError,
|
|
22
|
+
c as RecursiveReadLimitExceededError
|
|
53
23
|
};
|
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/index8.js
CHANGED
|
@@ -3,7 +3,7 @@ async function s(t, n, r) {
|
|
|
3
3
|
if (!await o(n))
|
|
4
4
|
throw new Error("User not signed in");
|
|
5
5
|
const e = await n.getUser();
|
|
6
|
-
if (!e.evmAccounts
|
|
6
|
+
if (!e.evmAccounts?.find((i) => i === t.evmAccount))
|
|
7
7
|
throw new Error("EVM account not found");
|
|
8
8
|
const c = await n.getWalletSecretId();
|
|
9
9
|
return r({ ...t, user: e, walletSecretId: c });
|
package/dist/esm/index80.js
CHANGED
|
@@ -1,81 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
]);
|
|
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
|
+
};
|
|
75
10
|
export {
|
|
76
|
-
|
|
77
|
-
m as HashMD,
|
|
78
|
-
_ as Maj,
|
|
79
|
-
B as SHA256_IV,
|
|
80
|
-
y as setBigUint64
|
|
11
|
+
e as chainConfig
|
|
81
12
|
};
|
package/dist/esm/index81.js
CHANGED
|
@@ -1,12 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { encode as d } from "./index91.js";
|
|
2
|
+
import y from "./index92.js";
|
|
3
|
+
import b from "./index93.js";
|
|
4
|
+
import { JWSInvalid as r } from "./index71.js";
|
|
5
|
+
import { encoder as s, concat as u, decoder as h } from "./index82.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
|
+
}
|
|
10
55
|
export {
|
|
11
|
-
|
|
56
|
+
x as FlattenedSign
|
|
12
57
|
};
|
package/dist/esm/index82.js
CHANGED
|
@@ -1,57 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
}
|
|
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;
|
|
54
8
|
}
|
|
55
9
|
export {
|
|
56
|
-
|
|
10
|
+
f as concat,
|
|
11
|
+
s as decoder,
|
|
12
|
+
d as encoder
|
|
57
13
|
};
|
package/dist/esm/index83.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
const
|
|
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
|
-
}
|
|
1
|
+
const o = (e) => Math.floor(e.getTime() / 1e3);
|
|
9
2
|
export {
|
|
10
|
-
|
|
11
|
-
s as decoder,
|
|
12
|
-
d as encoder
|
|
3
|
+
o as default
|
|
13
4
|
};
|
package/dist/esm/index84.js
CHANGED
|
@@ -1,4 +1,47 @@
|
|
|
1
|
-
const o = (
|
|
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
|
+
};
|
|
2
45
|
export {
|
|
3
|
-
|
|
46
|
+
t as default
|
|
4
47
|
};
|
package/dist/esm/index85.js
CHANGED
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
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;
|
|
44
13
|
};
|
|
45
14
|
export {
|
|
46
|
-
|
|
15
|
+
r as default
|
|
47
16
|
};
|