unjwt 0.8.5 → 0.9.1
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 +34 -21
- package/dist/_chunks/algorithms.mjs +44 -20
- package/dist/_chunks/digest.d.mts +4 -4
- package/dist/_chunks/digest.mjs +23 -15
- package/dist/_chunks/error.d.mts +29 -42
- package/dist/_chunks/export.mjs +1 -4
- package/dist/_chunks/index.d.mts +270 -234
- package/dist/_chunks/index2.d.mts +82 -189
- package/dist/_chunks/index4.d.mts +223 -60
- package/dist/_chunks/index5.d.mts +68 -31
- package/dist/_chunks/index6.d.mts +45 -64
- package/dist/_chunks/jwe.mjs +53 -48
- package/dist/_chunks/jwk.mjs +9 -3
- package/dist/_chunks/jws.mjs +55 -50
- package/dist/_chunks/jwt.d.mts +13 -49
- package/dist/_chunks/jwt.mjs +4 -158
- package/dist/_chunks/jwt2.mjs +162 -0
- package/dist/_chunks/libs/unsecure.d.mts +0 -6
- package/dist/_chunks/limits.d.mts +3 -2
- package/dist/_chunks/payload.mjs +13 -7
- package/dist/_chunks/wrap.mjs +3 -1
- package/dist/core/internal.d.mts +50 -2
- package/dist/core/internal.mjs +3 -1
- package/dist/core/jwe/index.d.mts +1 -1
- package/dist/core/jwk/index.d.mts +2 -2
- package/dist/core/jwk/index.mjs +2 -2
- package/dist/dpop/index.d.mts +77 -18
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/session/index.d.mts +568 -22
- package/dist/session/index.mjs +1386 -34
- package/dist/utils/index.d.mts +4 -4
- package/dist/utils/index.mjs +2 -10
- package/package.json +4 -32
- package/dist/_chunks/codec-jwe.d.mts +0 -280
- package/dist/_chunks/codec-jws.mjs +0 -1005
- package/dist/_chunks/cookie-attributes.d.mts +0 -12
- package/dist/_chunks/cookie.mjs +0 -50
- package/dist/adapters/elysia/index.d.mts +0 -123
- package/dist/adapters/elysia/index.mjs +0 -120
- package/dist/adapters/h3/index.d.mts +0 -135
- package/dist/adapters/h3/index.mjs +0 -117
- package/dist/adapters/h3v1/index.d.mts +0 -148
- package/dist/adapters/h3v1/index.mjs +0 -128
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { safeJsonParse, textEncoder } from "./libs/unsecure.mjs";
|
|
2
|
+
import { JWTError } from "../error.mjs";
|
|
3
|
+
import { base64UrlParse, computeDurationInSeconds, isPlainObject, parseDurationSeconds } from "./jwt.mjs";
|
|
4
|
+
const MAX_QUOTED_VALUE = 64;
|
|
5
|
+
function quoteTokenValue(value) {
|
|
6
|
+
const text = String(value);
|
|
7
|
+
return JSON.stringify(text.length > MAX_QUOTED_VALUE ? `${text.slice(0, MAX_QUOTED_VALUE)}…` : text);
|
|
8
|
+
}
|
|
9
|
+
function applyTypDefault(header, payload) {
|
|
10
|
+
const declared = header.typ;
|
|
11
|
+
if (declared !== void 0 && typeof declared !== "string") throw new JWTError("\"typ\" must be a string.", "ERR_INVALID_OPTION");
|
|
12
|
+
if (declared === void 0 && typeof payload === "object" && payload !== null && !(payload instanceof Uint8Array)) header.typ = "JWT";
|
|
13
|
+
return header;
|
|
14
|
+
}
|
|
15
|
+
function parsePayloadBytes(bytes, options) {
|
|
16
|
+
const mode = options?.payload ?? "json";
|
|
17
|
+
if (mode === "bytes") return bytes;
|
|
18
|
+
const family = options?.family ?? "JWS";
|
|
19
|
+
const text = parsePayloadText(bytes, { family });
|
|
20
|
+
if (mode === "string") return text;
|
|
21
|
+
return _parsePayloadObject(text, family);
|
|
22
|
+
}
|
|
23
|
+
function parsePayloadText(bytes, options) {
|
|
24
|
+
const family = options?.family ?? "JWS";
|
|
25
|
+
try {
|
|
26
|
+
return _utf8Decoder.decode(bytes);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new JWTError(`Invalid ${family}: Payload is not valid UTF-8.`, `ERR_${family}_INVALID`, error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function parsePayloadSegment(payloadEncoded, options) {
|
|
32
|
+
return parsePayloadBytes(base64UrlParse(payloadEncoded, { returnAs: "uint8array" }), options);
|
|
33
|
+
}
|
|
34
|
+
function getPlaintextBytes(payload) {
|
|
35
|
+
if (payload instanceof Uint8Array) return payload;
|
|
36
|
+
if (typeof payload === "string") return textEncoder.encode(payload);
|
|
37
|
+
if (typeof payload === "object" && payload !== null) {
|
|
38
|
+
let json;
|
|
39
|
+
try {
|
|
40
|
+
json = JSON.stringify(payload);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new JWTError("Payload is not JSON-serializable.", "ERR_INVALID_OPTION", error);
|
|
43
|
+
}
|
|
44
|
+
return textEncoder.encode(json);
|
|
45
|
+
}
|
|
46
|
+
throw new JWTError("Plaintext must be a string, Uint8Array, or a JSON-serializable object.", "ERR_INVALID_OPTION");
|
|
47
|
+
}
|
|
48
|
+
function computeJwtTimeClaims(payload, options) {
|
|
49
|
+
const { currentDate, issuedAt, expiresIn, expiresAt, notBeforeIn, notBeforeAt } = options ?? {};
|
|
50
|
+
if (issuedAt !== void 0 && typeof issuedAt !== "boolean" && !(issuedAt instanceof Date)) throw new JWTError("\"issuedAt\" must be a boolean or a Date.", "ERR_INVALID_OPTION");
|
|
51
|
+
if (expiresIn !== void 0 && expiresAt !== void 0) throw new JWTError("\"expiresIn\" and \"expiresAt\" are mutually exclusive.", "ERR_JWT_CLAIM_INVALID");
|
|
52
|
+
if (notBeforeIn !== void 0 && notBeforeAt !== void 0) throw new JWTError("\"notBeforeIn\" and \"notBeforeAt\" are mutually exclusive.", "ERR_JWT_CLAIM_INVALID");
|
|
53
|
+
const hasExpHint = expiresIn !== void 0 || expiresAt !== void 0;
|
|
54
|
+
const hasNbfHint = notBeforeIn !== void 0 || notBeforeAt !== void 0;
|
|
55
|
+
const hasIatHint = issuedAt === true || issuedAt instanceof Date;
|
|
56
|
+
if (!hasExpHint && !hasNbfHint && !hasIatHint) return void 0;
|
|
57
|
+
if (!payload || typeof payload !== "object" || payload instanceof Uint8Array) {
|
|
58
|
+
const option = Object.entries({
|
|
59
|
+
expiresIn,
|
|
60
|
+
expiresAt,
|
|
61
|
+
notBeforeIn,
|
|
62
|
+
notBeforeAt
|
|
63
|
+
}).find(([, value]) => value !== void 0)?.[0] ?? "issuedAt";
|
|
64
|
+
throw new JWTError(`"${option}" needs a JSON payload: pass an object payload or drop the option.`, "ERR_INVALID_OPTION");
|
|
65
|
+
}
|
|
66
|
+
const wantsExp = hasExpHint && (!("exp" in payload) || payload.exp === void 0);
|
|
67
|
+
const wantsNbf = hasNbfHint && (!("nbf" in payload) || payload.nbf === void 0);
|
|
68
|
+
const wantsIat = hasIatHint && (!("iat" in payload) || payload.iat === void 0);
|
|
69
|
+
if (!wantsExp && !wantsNbf && !wantsIat) return void 0;
|
|
70
|
+
const now = Math.floor((currentDate ?? /* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
71
|
+
const claims = { ...payload };
|
|
72
|
+
claims.iat ??= issuedAt instanceof Date ? Math.floor(_instantOf(issuedAt, "issuedAt") / 1e3) : now;
|
|
73
|
+
if (wantsExp) {
|
|
74
|
+
if (expiresAt !== void 0) claims.exp = Math.floor(_instantOf(expiresAt, "expiresAt") / 1e3);
|
|
75
|
+
else if (expiresIn !== void 0) claims.exp = now + computeDurationInSeconds(expiresIn);
|
|
76
|
+
}
|
|
77
|
+
if (wantsNbf) {
|
|
78
|
+
if (notBeforeAt !== void 0) claims.nbf = Math.floor(_instantOf(notBeforeAt, "notBeforeAt") / 1e3);
|
|
79
|
+
else if (notBeforeIn !== void 0) {
|
|
80
|
+
const offset = parseDurationSeconds(notBeforeIn);
|
|
81
|
+
if (offset < 0) throw new JWTError("\"notBeforeIn\" must be zero or a positive duration.", "ERR_JWT_CLAIM_INVALID");
|
|
82
|
+
claims.nbf = now + offset;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return claims;
|
|
86
|
+
}
|
|
87
|
+
const BASE_PROCESSED = /* @__PURE__ */ Object.freeze({
|
|
88
|
+
JWS: ["b64"],
|
|
89
|
+
JWE: []
|
|
90
|
+
});
|
|
91
|
+
function validateCriticalHeadersJWS(protectedHeader, recognizedHeaders) {
|
|
92
|
+
validateCriticalHeaders(protectedHeader, {
|
|
93
|
+
family: "JWS",
|
|
94
|
+
recognizedHeaders
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function validateCriticalHeadersJWE(protectedHeader, recognizedHeaders) {
|
|
98
|
+
validateCriticalHeaders(protectedHeader, {
|
|
99
|
+
family: "JWE",
|
|
100
|
+
recognizedHeaders
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const REGISTERED_HEADER_PARAMS = /* @__PURE__ */ new Set([
|
|
104
|
+
"alg",
|
|
105
|
+
"enc",
|
|
106
|
+
"zip",
|
|
107
|
+
"jku",
|
|
108
|
+
"jwk",
|
|
109
|
+
"kid",
|
|
110
|
+
"x5u",
|
|
111
|
+
"x5c",
|
|
112
|
+
"x5t",
|
|
113
|
+
"x5t#S256",
|
|
114
|
+
"typ",
|
|
115
|
+
"cty",
|
|
116
|
+
"crit",
|
|
117
|
+
"epk",
|
|
118
|
+
"apu",
|
|
119
|
+
"apv",
|
|
120
|
+
"iv",
|
|
121
|
+
"tag",
|
|
122
|
+
"p2s",
|
|
123
|
+
"p2c"
|
|
124
|
+
]);
|
|
125
|
+
function assertCritShape(crit, options) {
|
|
126
|
+
const { family } = options;
|
|
127
|
+
const code = options.code ?? `ERR_${family}_INVALID`;
|
|
128
|
+
if (!Array.isArray(crit) || crit.length === 0 || crit.some((param) => typeof param !== "string")) throw new JWTError(`Invalid ${family}: "crit" must be a non-empty array of strings.`, code);
|
|
129
|
+
for (const param of crit) if (REGISTERED_HEADER_PARAMS.has(param)) throw new JWTError(`Invalid ${family}: "crit" must not list registered header parameters.`, code);
|
|
130
|
+
}
|
|
131
|
+
function _instantOf(value, name) {
|
|
132
|
+
const ms = value instanceof Date ? value.getTime() : NaN;
|
|
133
|
+
if (!Number.isFinite(ms)) throw new JWTError(`"${name}" must be a valid Date.`, "ERR_INVALID_OPTION");
|
|
134
|
+
return ms;
|
|
135
|
+
}
|
|
136
|
+
const _utf8Decoder = /* @__PURE__ */ new TextDecoder("utf-8", {
|
|
137
|
+
fatal: true,
|
|
138
|
+
ignoreBOM: true
|
|
139
|
+
});
|
|
140
|
+
function _parsePayloadObject(text, family) {
|
|
141
|
+
const code = `ERR_${family}_INVALID`;
|
|
142
|
+
const message = `Invalid ${family}: Payload is not a JSON object.`;
|
|
143
|
+
let parsed;
|
|
144
|
+
try {
|
|
145
|
+
parsed = safeJsonParse(text);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
throw new JWTError(message, code, error);
|
|
148
|
+
}
|
|
149
|
+
if (!isPlainObject(parsed)) throw new JWTError(message, code);
|
|
150
|
+
return parsed;
|
|
151
|
+
}
|
|
152
|
+
function validateCriticalHeaders(protectedHeader, options) {
|
|
153
|
+
const { crit } = protectedHeader;
|
|
154
|
+
if (crit === void 0) return;
|
|
155
|
+
const { family, recognizedHeaders = [] } = options;
|
|
156
|
+
assertCritShape(crit, { family });
|
|
157
|
+
for (const param of crit) {
|
|
158
|
+
if (!Object.hasOwn(protectedHeader, param)) throw new JWTError(`Critical header parameter ${quoteTokenValue(param)} is missing from the protected header.`, `ERR_${family}_INVALID`);
|
|
159
|
+
if (!recognizedHeaders.includes(param) && !BASE_PROCESSED[family].includes(param)) throw new JWTError(`Unprocessed critical header parameters: ${quoteTokenValue(param)}`, `ERR_${family}_INVALID`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export { applyTypDefault, assertCritShape, computeJwtTimeClaims, getPlaintextBytes, parsePayloadBytes, parsePayloadSegment, parsePayloadText, quoteTokenValue, validateCriticalHeadersJWE, validateCriticalHeadersJWS };
|
|
@@ -168,12 +168,6 @@ export declare function sanitizeObjectCopy<T>(obj: T, options?: SanitizeCopyOpti
|
|
|
168
168
|
* single instance serves every caller.
|
|
169
169
|
*/
|
|
170
170
|
export declare const textEncoder: TextEncoder;
|
|
171
|
-
/**
|
|
172
|
-
* Any byte container the library accepts: an `ArrayBuffer` — shared or not —
|
|
173
|
-
* or a view over one. Wider than the DOM `BufferSource`, which excludes
|
|
174
|
-
* `SharedArrayBuffer`-backed views.
|
|
175
|
-
*/
|
|
176
|
-
export type BytesSource = ArrayBufferLike | ArrayBufferView<ArrayBufferLike>;
|
|
177
171
|
/**
|
|
178
172
|
* Shared UTF-8 `TextDecoder` instance. `ignoreBOM` keeps a leading U+FEFF in
|
|
179
173
|
* the output: what the codecs decode is a byte string, and a BOM inside it is
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import "./error.mjs";
|
|
1
2
|
import { JOSELimits } from "./index.mjs";
|
|
2
3
|
import "./index3.mjs";
|
|
3
4
|
/**
|
|
4
|
-
* Default per-call work limits: 16 signatures, 16 recipients, 8 JWK Set candidates
|
|
5
|
-
*
|
|
5
|
+
* Default per-call work limits: 16 signatures, 16 recipients, 8 JWK Set candidates and
|
|
6
|
+
* 16 key attempts per multi call. The PBKDF2 iteration budget equals four default-cost PBES2 attempts.
|
|
6
7
|
*/
|
|
7
8
|
export declare const DEFAULT_JOSE_LIMITS: Readonly<Required<JOSELimits>>;
|
package/dist/_chunks/payload.mjs
CHANGED
|
@@ -9,15 +9,21 @@ const PAYLOAD_MODES = /* @__PURE__ */ new Set([
|
|
|
9
9
|
"string",
|
|
10
10
|
"bytes"
|
|
11
11
|
]);
|
|
12
|
+
const CLAIM_OPTIONS = [
|
|
13
|
+
"audience",
|
|
14
|
+
"issuer",
|
|
15
|
+
"subject",
|
|
16
|
+
"maxTokenAge",
|
|
17
|
+
"requiredClaims"
|
|
18
|
+
];
|
|
12
19
|
function resolvePayloadMode(options) {
|
|
13
|
-
const { payload,
|
|
20
|
+
const { payload, validateClaims } = options;
|
|
14
21
|
if (payload !== void 0 && !PAYLOAD_MODES.has(payload)) throw new JWTError("\"payload\" must be \"json\", \"string\" or \"bytes\".", "ERR_INVALID_OPTION");
|
|
15
|
-
|
|
16
|
-
if (forceUint8Array !== void 0) {
|
|
17
|
-
if (payload === void 0) mode = forceUint8Array ? "bytes" : "json";
|
|
18
|
-
else if (forceUint8Array !== (payload === "bytes")) throw new JWTError("\"forceUint8Array\" contradicts \"payload\", pass \"payload\" alone.", "ERR_INVALID_OPTION");
|
|
19
|
-
}
|
|
22
|
+
const mode = payload ?? "json";
|
|
20
23
|
if (validateClaims === true && mode !== "json") throw new JWTError("\"validateClaims\" requires payload: \"json\".", "ERR_INVALID_OPTION");
|
|
21
|
-
return mode;
|
|
24
|
+
if (mode === "json" && validateClaims !== false) return mode;
|
|
25
|
+
const option = CLAIM_OPTIONS.find((name) => options[name] !== void 0);
|
|
26
|
+
if (option === void 0) return mode;
|
|
27
|
+
throw new JWTError(mode === "json" ? `"${option}" needs claim validation: drop validateClaims: false or the option.` : `"${option}" needs a JSON payload: pass payload: "json" or drop the option.`, "ERR_INVALID_OPTION");
|
|
22
28
|
}
|
|
23
29
|
export { resolvePayloadMode, validateClaimsIfJson };
|
package/dist/_chunks/wrap.mjs
CHANGED
|
@@ -204,6 +204,8 @@ async function unwrapKey(wrappedKey, unwrappingKey, options) {
|
|
|
204
204
|
default: throw new JWTError(`Unsupported key unwrapping algorithm: ${alg}`, "ERR_JWK_UNSUPPORTED");
|
|
205
205
|
}
|
|
206
206
|
if (returnRaw) return unwrappedCekBytes;
|
|
207
|
-
|
|
207
|
+
const importAlgorithm = options.unwrappedKeyAlgorithm || inferAesImportAlgorithm(options.enc, unwrappedCekBytes.length);
|
|
208
|
+
if (!importAlgorithm) throw new JWTError("Cannot infer the unwrapped key algorithm, pass \"unwrappedKeyAlgorithm\" or unwrap to raw bytes.", "ERR_JWE_INVALID");
|
|
209
|
+
return crypto.subtle.importKey("raw", unwrappedCekBytes, importAlgorithm, defaultExtractable, options.keyUsage || ["encrypt", "decrypt"]);
|
|
208
210
|
}
|
|
209
211
|
export { unwrapKey, wrapKey };
|
package/dist/core/internal.d.mts
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { JWTErrorCode } from "../_chunks/error.mjs";
|
|
2
|
+
import { JOSEPayload, JOSEPayloadMode, JWTClaims, JWTTimeClaimOptions, PayloadOf } from "../_chunks/index.mjs";
|
|
3
|
+
import { expiredClaimMessage } from "../_chunks/jwt.mjs";
|
|
4
|
+
/** Sets `typ: "JWT"` on a header without `typ` when the payload is an object other than a `Uint8Array`. @throws `ERR_INVALID_OPTION` if `header.typ` is set and is not a string. */
|
|
5
|
+
export declare function applyTypDefault<T extends {
|
|
6
|
+
typ?: string;
|
|
7
|
+
}>(header: T, payload: unknown): T;
|
|
8
|
+
/** Options for {@link parsePayloadBytes} and {@link parsePayloadSegment}. */
|
|
9
|
+
interface ParsePayloadOptions<Mode extends JOSEPayloadMode = JOSEPayloadMode> {
|
|
10
|
+
/** How the payload bytes are read. The return type follows it. @default "json" */
|
|
11
|
+
payload?: Mode;
|
|
12
|
+
/** The family a failure is reported under: `ERR_JWS_INVALID` or `ERR_JWE_INVALID`. @default "JWS" */
|
|
13
|
+
family?: "JWS" | "JWE";
|
|
14
|
+
}
|
|
15
|
+
/** Reads payload bytes as a UTF-8 JSON object (`"json"`), UTF-8 text (`"string"`) or as is (`"bytes"`). @throws `ERR_JWS_INVALID` if the bytes do not fit the mode (`ERR_JWE_INVALID` under `family: "JWE"`). */
|
|
16
|
+
export declare function parsePayloadBytes<T = JWTClaims>(bytes: Uint8Array<ArrayBuffer>, options?: ParsePayloadOptions<"json">): T;
|
|
17
|
+
export declare function parsePayloadBytes<Mode extends JOSEPayloadMode = JOSEPayloadMode>(bytes: Uint8Array<ArrayBuffer>, options?: ParsePayloadOptions<Mode>): PayloadOf<Mode>;
|
|
18
|
+
/** Decodes payload bytes as strict UTF-8. @throws `ERR_JWS_INVALID` if they are not (`ERR_JWE_INVALID` under `family: "JWE"`). */
|
|
19
|
+
export declare function parsePayloadText(bytes: Uint8Array<ArrayBuffer>, options?: Pick<ParsePayloadOptions, "family">): string;
|
|
20
|
+
/** {@link parsePayloadBytes} over a base64url payload segment. @throws `UnsecureError` if the segment is not base64url. */
|
|
21
|
+
export declare function parsePayloadSegment<T = JWTClaims>(payloadEncoded: string, options?: ParsePayloadOptions<"json">): T;
|
|
22
|
+
export declare function parsePayloadSegment<Mode extends JOSEPayloadMode = JOSEPayloadMode>(payloadEncoded: string, options?: ParsePayloadOptions<Mode>): PayloadOf<Mode>;
|
|
23
|
+
/** Encodes a payload as bytes: a `Uint8Array` as is, a string as UTF-8, an object as UTF-8 JSON. @throws `ERR_INVALID_OPTION` if the payload is none of these or `JSON.stringify` rejects it. */
|
|
24
|
+
export declare function getPlaintextBytes(payload: JOSEPayload): Uint8Array<ArrayBuffer>;
|
|
25
|
+
/** Options for {@link computeJwtTimeClaims}. */
|
|
26
|
+
type ComputeJwtTimeClaimsOptions = JWTTimeClaimOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a copy of an object payload with the requested `exp` and `nbf`, plus `iat`.
|
|
29
|
+
* Claims the payload already holds are kept, `iat: 0` included.
|
|
30
|
+
* Returns `undefined` when no option applies or every requested claim is present.
|
|
31
|
+
* `currentDate` is the default `iat` and the base of `expiresIn` and `notBeforeIn`.
|
|
32
|
+
* `issuedAt: true` requests `iat` with no other claim. A `Date` sets `iat` to that instant.
|
|
33
|
+
* @throws `ERR_JWT_CLAIM_INVALID` if both `expiresIn` and `expiresAt`, or both `notBeforeIn` and `notBeforeAt`, are set, or `notBeforeIn` is negative.
|
|
34
|
+
* @throws `ERR_INVALID_OPTION` if a time option is set for a non-object payload, or an option value is malformed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function computeJwtTimeClaims(payload: unknown, options?: ComputeJwtTimeClaimsOptions): JWTClaims | undefined;
|
|
37
|
+
/** Checks a JWS `crit` (RFC 7515 §4.1.11): each entry is in the header and is `b64` or in `recognizedHeaders`. @throws `ERR_JWS_INVALID` if `crit` is malformed or an entry is absent or not understood. */
|
|
38
|
+
export declare function validateCriticalHeadersJWS(protectedHeader: {
|
|
39
|
+
crit?: string[];
|
|
40
|
+
} & Record<string, unknown>, recognizedHeaders?: string[]): void;
|
|
41
|
+
/** Checks a JWE `crit` (RFC 7516 §4.1.13): each entry is in the header and in `recognizedHeaders`. @throws `ERR_JWE_INVALID` if `crit` is malformed or an entry is absent or not understood. */
|
|
42
|
+
export declare function validateCriticalHeadersJWE(protectedHeader: {
|
|
43
|
+
crit?: string[];
|
|
44
|
+
} & Record<string, unknown>, recognizedHeaders?: string[]): void;
|
|
45
|
+
/** Asserts `crit` is a non-empty string array with no registered header name (RFC 7515 §4.1.11, RFC 7516 §4.1.13). @throws `ERR_JWS_INVALID` or `ERR_JWE_INVALID` by `family`, or `code` when given. */
|
|
46
|
+
export declare function assertCritShape(crit: unknown, options: {
|
|
47
|
+
family: "JWS" | "JWE";
|
|
48
|
+
code?: JWTErrorCode;
|
|
49
|
+
}): asserts crit is string[];
|
|
50
|
+
export { type ComputeJwtTimeClaimsOptions, type ParsePayloadOptions, expiredClaimMessage };
|
package/dist/core/internal.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { expiredClaimMessage } from "../_chunks/jwt.mjs";
|
|
2
|
+
import { applyTypDefault, assertCritShape, computeJwtTimeClaims, getPlaintextBytes, parsePayloadBytes, parsePayloadSegment, parsePayloadText, validateCriticalHeadersJWE, validateCriticalHeadersJWS } from "../_chunks/jwt2.mjs";
|
|
3
|
+
export { applyTypDefault, assertCritShape, computeJwtTimeClaims, expiredClaimMessage, getPlaintextBytes, parsePayloadBytes, parsePayloadSegment, parsePayloadText, validateCriticalHeadersJWE, validateCriticalHeadersJWS };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnsecureError, UnsecureErrorCode } from "../../_chunks/libs/unsecure.mjs";
|
|
2
2
|
import { JWTError, JWTErrorCauseMap, JWTErrorCode, KnownJWTErrorCode, isJWTError, isUnsecureError } from "../../_chunks/error.mjs";
|
|
3
3
|
import { JOSEPayloadMode, JOSEPayloadTypeMap, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyLookup, JWEKeyManagementHeaderParameters, JWELibraryHeaderName, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, PayloadOf } from "../../_chunks/index.mjs";
|
|
4
|
-
import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "../../_chunks/
|
|
4
|
+
import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "../../_chunks/index2.mjs";
|
|
5
5
|
import { DEFAULT_JOSE_LIMITS } from "../../_chunks/limits.mjs";
|
|
6
6
|
export { DEFAULT_JOSE_LIMITS, type JOSEPayloadMode, type JOSEPayloadTypeMap, type JWEAsymmetricPrivateJWK, type JWEAsymmetricPublicJWK, type JWEDecryptJWK, type JWEDecryptOptions, type JWEDecryptResult, type JWEEncryptJWK, type JWEEncryptOptions, type JWEFlattenedSerialization, type JWEGeneralRecipient, type JWEGeneralSerialization, type JWEHeaderParameters, type JWEKeyLookup, type JWEKeyManagementHeaderParameters, type JWELibraryHeaderName, type JWEMultiDecryptKey, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type KnownJWTErrorCode, type PayloadOf, UnsecureError, type UnsecureErrorCode, decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened, isJWTError, isUnsecureError };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnsecureError, UnsecureErrorCode } from "../../_chunks/libs/unsecure.mjs";
|
|
2
2
|
import { JWTError, JWTErrorCauseMap, JWTErrorCode, KnownJWTErrorCode, isJWTError, isUnsecureError } from "../../_chunks/error.mjs";
|
|
3
3
|
import { CompositeKey, ContentEncryptionAlgorithm, DeriveJWKOptions, DeriveJWKReturn, DeriveKeyOptions, DeriveKeyReturn, ECDHEphemeralKeyInput, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, ImportedPEMJWK, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_Algorithm, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, KeyManagementAlgorithm, KeyWrapAlgorithmOf, KeyWrappingAlgorithm, PEMType, ToPublicJWKReturn, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor } from "../../_chunks/index.mjs";
|
|
4
|
-
import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportJWK, exportKey, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, toPublicJWK, unwrapKey, wrapKey } from "../../_chunks/index2.mjs";
|
|
5
4
|
import { ThumbprintHash, thumbprint } from "../../_chunks/index3.mjs";
|
|
6
|
-
|
|
5
|
+
import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportJWK, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, toPublicJWK, unwrapKey, wrapKey } from "../../_chunks/index4.mjs";
|
|
6
|
+
export { type CompositeKey, type ContentEncryptionAlgorithm, type DeriveJWKOptions, type DeriveJWKReturn, type DeriveKeyOptions, type DeriveKeyReturn, type ECDHEphemeralKeyInput, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type ImportedPEMJWK, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_Algorithm, type JWK_AES_CBC_HMAC, type JWK_AES_GCM, type JWK_AES_GCM_KW, type JWK_AES_KW, type JWK_Asymmetric, type JWK_Asymmetric_Algorithm, type JWK_EC, type JWK_ECDH_ES, type JWK_ECDSA, type JWK_EC_Private, type JWK_EC_Public, type JWK_HMAC, type JWK_OKP, type JWK_OKP_Private, type JWK_OKP_Public, type JWK_OKP_SIGN, type JWK_PBES2, type JWK_Pair, type JWK_Private, type JWK_Public, type JWK_RSA, type JWK_RSA_ENC, type JWK_RSA_PSS, type JWK_RSA_Private, type JWK_RSA_Public, type JWK_RSA_SIGN, type JWK_Symmetric, type JWK_Symmetric_Algorithm, type JWK_oct, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type KeyManagementAlgorithm, type KeyWrapAlgorithmOf, type KeyWrappingAlgorithm, type KnownJWTErrorCode, type PEMType, type ThumbprintHash, type ToPublicJWKReturn, UnsecureError, type UnsecureErrorCode, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, WeakMapJWKCache, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportJWK, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, isJWTError, isUnsecureError, thumbprint, toPublicJWK, unwrapKey, wrapKey };
|
package/dist/core/jwk/index.mjs
CHANGED
|
@@ -2,6 +2,6 @@ import { UnsecureError } from "../../_chunks/libs/unsecure.mjs";
|
|
|
2
2
|
import { JWTError, isJWTError, isUnsecureError } from "../../error.mjs";
|
|
3
3
|
import { WeakMapJWKCache, clearJWKCache, configureJWKCache, getJWKsFromSet, importKey, thumbprint } from "../../_chunks/algorithms.mjs";
|
|
4
4
|
import { unwrapKey, wrapKey } from "../../_chunks/wrap.mjs";
|
|
5
|
-
import { exportJWK,
|
|
5
|
+
import { exportJWK, toPublicJWK } from "../../_chunks/export.mjs";
|
|
6
6
|
import { deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportPEM, generateJWK, generateKey, importPEM } from "../../_chunks/jwk.mjs";
|
|
7
|
-
export { JWTError, UnsecureError, WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportJWK,
|
|
7
|
+
export { JWTError, UnsecureError, WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportJWK, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, isJWTError, isUnsecureError, thumbprint, toPublicJWK, unwrapKey, wrapKey };
|
package/dist/dpop/index.d.mts
CHANGED
|
@@ -1,73 +1,132 @@
|
|
|
1
1
|
import { JWTError, JWTErrorCode, KnownJWTErrorCode, isJWTError } from "../_chunks/error.mjs";
|
|
2
2
|
import { JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK } from "../_chunks/index.mjs";
|
|
3
|
-
/**
|
|
3
|
+
/** The JWS algorithms a DPoP proof can use: every supported `alg` except `HS*`. */
|
|
4
4
|
type DPoPAlgorithm = Exclude<JWSAlgorithm, `HS${string}`>;
|
|
5
|
-
/** The request
|
|
5
|
+
/** The request a proof is bound to. A Web `Request` matches this shape. */
|
|
6
6
|
interface DPoPTarget {
|
|
7
|
+
/** HTTP method, compared case-sensitively with the proof's `htm`. */
|
|
7
8
|
method: string;
|
|
9
|
+
/** Absolute `http:` or `https:` URL without credentials. Its query and fragment are ignored. */
|
|
8
10
|
url: string;
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The signing key pair: two `CryptoKey`s or two asymmetric JWKs.
|
|
14
|
+
* The private `CryptoKey` can be non-extractable. The public `CryptoKey` must be extractable.
|
|
15
|
+
*/
|
|
11
16
|
type DPoPKeyPair = CryptoKeyPair | {
|
|
12
17
|
privateKey: JWSAsymmetricPrivateJWK;
|
|
13
18
|
publicKey: JWSAsymmetricPublicJWK;
|
|
14
19
|
};
|
|
20
|
+
/** The claims of a DPoP proof (RFC 9449 §4.2). */
|
|
15
21
|
interface DPoPPayload {
|
|
22
|
+
/** Unique proof identifier. */
|
|
16
23
|
jti: string;
|
|
24
|
+
/** Creation time in NumericDate seconds. */
|
|
17
25
|
iat: number;
|
|
26
|
+
/** Expiration time in NumericDate seconds. */
|
|
18
27
|
exp?: number;
|
|
28
|
+
/** Earliest acceptance time in NumericDate seconds. */
|
|
19
29
|
nbf?: number;
|
|
30
|
+
/** HTTP method of the request. */
|
|
20
31
|
htm: string;
|
|
32
|
+
/** Target URI of the request, without query and fragment. */
|
|
21
33
|
htu: string;
|
|
34
|
+
/** Nonce the server supplied. */
|
|
22
35
|
nonce?: string;
|
|
36
|
+
/** Base64url SHA-256 hash of the access token. */
|
|
23
37
|
ath?: string;
|
|
24
38
|
[claim: string]: unknown;
|
|
25
39
|
}
|
|
26
40
|
interface DPoPCreateOptions {
|
|
41
|
+
/** The key pair that signs the proof. Its public key is written to the `jwk` header. */
|
|
27
42
|
keyPair: DPoPKeyPair;
|
|
28
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Signing algorithm. Inferred from the JWK pair's `alg`, or from a key that serves one algorithm.
|
|
45
|
+
* Required for a `CryptoKey` pair.
|
|
46
|
+
*/
|
|
29
47
|
algorithm?: DPoPAlgorithm;
|
|
30
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Unique proof identifier. Must be a non-empty string.
|
|
50
|
+
* @default crypto.randomUUID()
|
|
51
|
+
*/
|
|
31
52
|
jti?: string;
|
|
32
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Creation time in NumericDate seconds.
|
|
55
|
+
* @default the current Unix second
|
|
56
|
+
*/
|
|
33
57
|
iat?: number;
|
|
34
|
-
/** Expiration time in NumericDate seconds.
|
|
58
|
+
/** Expiration time in NumericDate seconds. The proof has no `exp` when omitted. */
|
|
35
59
|
exp?: number;
|
|
36
|
-
/** Earliest acceptance time in NumericDate seconds.
|
|
60
|
+
/** Earliest acceptance time in NumericDate seconds. The proof has no `nbf` when omitted. */
|
|
37
61
|
nbf?: number;
|
|
62
|
+
/** Nonce the server supplied: printable ASCII without space, `"` or `\`. */
|
|
38
63
|
nonce?: string;
|
|
39
|
-
/**
|
|
64
|
+
/** The non-empty ASCII access token the proof is bound to. Its SHA-256 hash is written to `ath`. */
|
|
40
65
|
accessToken?: {
|
|
41
66
|
token: string;
|
|
42
67
|
};
|
|
43
68
|
}
|
|
44
69
|
interface DPoPVerifyResult {
|
|
70
|
+
/** The verified proof claims. */
|
|
45
71
|
payload: DPoPPayload;
|
|
46
|
-
/** SHA-256
|
|
72
|
+
/** RFC 7638 SHA-256 thumbprint of the proof's public key, the value a `cnf.jkt` binds. */
|
|
47
73
|
thumbprint: string;
|
|
48
74
|
}
|
|
49
75
|
interface DPoPVerifyOptions {
|
|
76
|
+
/** Accepted signing algorithms. Must be non-empty. */
|
|
50
77
|
algorithms: DPoPAlgorithm[];
|
|
51
|
-
/**
|
|
78
|
+
/** Maximum proof age in seconds, measured from `iat`. Must be positive and finite. */
|
|
52
79
|
maxTokenAge: number;
|
|
80
|
+
/**
|
|
81
|
+
* Time the proof is verified against.
|
|
82
|
+
* @default new Date()
|
|
83
|
+
*/
|
|
53
84
|
currentDate?: Date;
|
|
54
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Clock skew in seconds accepted on `iat`, `exp` and `nbf`. Must be finite and non-negative.
|
|
87
|
+
* @default 0
|
|
88
|
+
*/
|
|
55
89
|
clockTolerance?: number;
|
|
90
|
+
/** Expected nonce. A proof without it, or with another one, fails with `ERR_DPOP_NONCE_INVALID`. */
|
|
56
91
|
nonce?: string;
|
|
57
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* The access token and the `cnf.jkt` thumbprint it is bound to. The proof's `ath` must match
|
|
94
|
+
* `token` and its key must match `thumbprint`.
|
|
95
|
+
*/
|
|
58
96
|
accessToken?: {
|
|
59
97
|
token: string;
|
|
60
98
|
thumbprint: string;
|
|
61
99
|
};
|
|
62
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Replay check, called with a copy of the result once every other check passes.
|
|
102
|
+
* Return `true` to accept the proof. Any other value, or a throw, fails with `ERR_DPOP_REPLAY`.
|
|
103
|
+
* No replay storage is included: record the `jti` atomically.
|
|
104
|
+
*/
|
|
63
105
|
consumeProof?: (result: DPoPVerifyResult) => boolean | Promise<boolean>;
|
|
64
106
|
}
|
|
65
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Creates a DPoP proof (RFC 9449 §4.2) for `target`, signed with `options.keyPair`.
|
|
109
|
+
* The proof has `typ: "dpop+jwt"` and the public key in its `jwk` header.
|
|
110
|
+
* `htu` is `target.url` without query and fragment.
|
|
111
|
+
*
|
|
112
|
+
* @returns The proof as a compact JWS.
|
|
113
|
+
* @throws `ERR_INVALID_OPTION` if the target, the key pair or another option is invalid.
|
|
114
|
+
* @throws `ERR_DPOP_INVALID` if signing fails with an error that is not a `JWTError`.
|
|
115
|
+
*/
|
|
66
116
|
export declare function createDPoPProof(target: DPoPTarget, options: DPoPCreateOptions): Promise<string>;
|
|
67
117
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
118
|
+
* Verifies a DPoP proof against `target` and `options`.
|
|
119
|
+
* Returns its claims and the thumbprint of its key.
|
|
120
|
+
* Validate the access token yourself. Pass `consumeProof` to reject a replayed proof.
|
|
121
|
+
* A core error behind a proof failure is kept as `cause`.
|
|
122
|
+
*
|
|
123
|
+
* @throws `ERR_INVALID_OPTION` if the target or an option is invalid.
|
|
124
|
+
* @throws `ERR_DPOP_INVALID` if the proof's structure, header, key, algorithm or signature is invalid.
|
|
125
|
+
* @throws `ERR_DPOP_CLAIM_INVALID` if a claim is invalid, `iat` is outside the age window,
|
|
126
|
+
* or the proof does not match the request or the access token.
|
|
127
|
+
* @throws `ERR_DPOP_NONCE_INVALID` if the proof's `nonce` differs from `options.nonce`.
|
|
128
|
+
* This check runs after every other proof check.
|
|
129
|
+
* @throws `ERR_DPOP_REPLAY` if `consumeProof` does not return `true` or throws.
|
|
71
130
|
*/
|
|
72
131
|
export declare function verifyDPoPProof(proof: string, target: DPoPTarget, options: DPoPVerifyOptions): Promise<DPoPVerifyResult>;
|
|
73
132
|
export { type DPoPAlgorithm, type DPoPCreateOptions, type DPoPKeyPair, type DPoPPayload, type DPoPTarget, type DPoPVerifyOptions, type DPoPVerifyResult, JWTError, type JWTErrorCode, type KnownJWTErrorCode, isJWTError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnsecureError, UnsecureErrorCode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "./_chunks/libs/unsecure.mjs";
|
|
2
2
|
import { JWTError, JWTErrorCauseMap, JWTErrorCode, KnownJWTErrorCode, isJWTError, isUnsecureError } from "./_chunks/error.mjs";
|
|
3
3
|
import { CompositeKey, ContentEncryptionAlgorithm, DeriveJWKOptions, DeriveJWKReturn, DeriveKeyOptions, DeriveKeyReturn, Duration, ECDHEphemeralKeyInput, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, ImportedPEMJWK, JOSEConsumerOptions, JOSELimits, JOSEPayload, JOSEPayloadMode, JOSEPayloadTypeMap, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyLookup, JWEKeyManagementHeaderParameters, JWELibraryHeaderName, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_Algorithm, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHashedAlgorithm, JWSHeaderParameters, JWSKeyLookup, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JWTConfirmation, JWTTimeClaimOptions, JoseHeaderParameters, KeyManagementAlgorithm, KeyWrapAlgorithmOf, KeyWrappingAlgorithm, MaxTokenAge, NotBeforeIn, PEMType, PayloadOf, StrictOmit, ToPublicJWKReturn, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor } from "./_chunks/index.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { computeDurationInSeconds, isJWTContent, validateJwtClaims } from "./_chunks/jwt.mjs";
|
|
5
|
+
import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/index2.mjs";
|
|
5
6
|
import { thumbprint } from "./_chunks/index3.mjs";
|
|
6
7
|
import { DigestHash, digestUrl } from "./_chunks/digest.mjs";
|
|
7
|
-
import { computeDurationInSeconds, isJWTContent, validateJwtClaims } from "./_chunks/jwt.mjs";
|
|
8
|
-
import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/index4.mjs";
|
|
9
8
|
import { DEFAULT_JOSE_LIMITS } from "./_chunks/limits.mjs";
|
|
9
|
+
import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportJWK, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, toPublicJWK, unwrapKey, wrapKey } from "./_chunks/index4.mjs";
|
|
10
10
|
import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "./_chunks/index5.mjs";
|
|
11
|
-
import { Base64ParseOptions,
|
|
12
|
-
export { type Base64ParseOptions, type
|
|
11
|
+
import { Base64ParseOptions, DecodeReturnAs, assertCryptoKey, base64Parse, base64Stringify, base64UrlParse, base64UrlStringify, concatUint8Arrays, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray } from "./_chunks/index6.mjs";
|
|
12
|
+
export { type Base64ParseOptions, type CompositeKey, type ContentEncryptionAlgorithm, DEFAULT_JOSE_LIMITS, type DecodeReturnAs, type DeriveJWKOptions, type DeriveJWKReturn, type DeriveKeyOptions, type DeriveKeyReturn, type DigestHash, type Duration, type ECDHEphemeralKeyInput, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type ImportedPEMJWK, type JOSEConsumerOptions, type JOSELimits, type JOSEPayload, type JOSEPayloadMode, type JOSEPayloadTypeMap, type JWEAsymmetricPrivateJWK, type JWEAsymmetricPublicJWK, type JWEDecryptJWK, type JWEDecryptOptions, type JWEDecryptResult, type JWEEncryptJWK, type JWEEncryptOptions, type JWEFlattenedSerialization, type JWEGeneralRecipient, type JWEGeneralSerialization, type JWEHeaderParameters, type JWEKeyLookup, type JWEKeyManagementHeaderParameters, type JWELibraryHeaderName, type JWEMultiDecryptKey, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_Algorithm, type JWK_AES_CBC_HMAC, type JWK_AES_GCM, type JWK_AES_GCM_KW, type JWK_AES_KW, type JWK_Asymmetric, type JWK_Asymmetric_Algorithm, type JWK_EC, type JWK_ECDH_ES, type JWK_ECDSA, type JWK_EC_Private, type JWK_EC_Public, type JWK_HMAC, type JWK_OKP, type JWK_OKP_Private, type JWK_OKP_Public, type JWK_OKP_SIGN, type JWK_PBES2, type JWK_Pair, type JWK_Private, type JWK_Public, type JWK_RSA, type JWK_RSA_ENC, type JWK_RSA_PSS, type JWK_RSA_Private, type JWK_RSA_Public, type JWK_RSA_SIGN, type JWK_Symmetric, type JWK_Symmetric_Algorithm, type JWK_oct, type JWSAlgorithm, type JWSAsymmetricPrivateJWK, type JWSAsymmetricPublicJWK, type JWSFlattenedSerialization, type JWSGeneralSerialization, type JWSGeneralSignature, type JWSHashedAlgorithm, type JWSHeaderParameters, type JWSKeyLookup, type JWSMultiSignOptions, type JWSMultiSigner, type JWSMultiVerifyAllOptions, type JWSMultiVerifyOptions, type JWSMultiVerifyOutcome, type JWSMultiVerifyResult, type JWSProtectedHeader, type JWSSignJWK, type JWSSignOptions, type JWSVerifyJWK, type JWSVerifyOptions, type JWSVerifyResult, type JWT, type JWTClaimValidationOptions, type JWTClaims, type JWTConfirmation, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type JWTTimeClaimOptions, type JoseHeaderParameters, type KeyManagementAlgorithm, type KeyWrapAlgorithmOf, type KeyWrappingAlgorithm, type KnownJWTErrorCode, type MaxTokenAge, type NotBeforeIn, type PEMType, type PayloadOf, type StrictOmit, type ToPublicJWKReturn, UnsecureError, type UnsecureErrorCode, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, WeakMapJWKCache, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, assertCryptoKey, base64Parse, base64Stringify, base64UrlParse, base64UrlStringify, clearJWKCache, computeDurationInSeconds, concatUint8Arrays, configureJWKCache, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, digestUrl, encrypt, encryptMulti, exportJWK, exportPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, sign, signMulti, textDecoder, textEncoder, thumbprint, toPublicJWK, unwrapKey, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { UnsecureError, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "./_chunks/libs/unsecure.mjs";
|
|
2
2
|
import { JWTError, isJWTError, isUnsecureError } from "./error.mjs";
|
|
3
|
-
import { assertCryptoKey,
|
|
3
|
+
import { assertCryptoKey, base64Parse, base64Stringify, base64UrlParse, base64UrlStringify, computeDurationInSeconds, concatUint8Arrays, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, validateJwtClaims } from "./_chunks/jwt.mjs";
|
|
4
4
|
import { DEFAULT_JOSE_LIMITS, WeakMapJWKCache, clearJWKCache, configureJWKCache, getJWKsFromSet, importKey, thumbprint } from "./_chunks/algorithms.mjs";
|
|
5
5
|
import { digestUrl, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms } from "./_chunks/digest.mjs";
|
|
6
6
|
import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "./_chunks/jws.mjs";
|
|
7
7
|
import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/jwe.mjs";
|
|
8
8
|
import { unwrapKey, wrapKey } from "./_chunks/wrap.mjs";
|
|
9
|
-
import { exportJWK,
|
|
9
|
+
import { exportJWK, toPublicJWK } from "./_chunks/export.mjs";
|
|
10
10
|
import { deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportPEM, generateJWK, generateKey, importPEM } from "./_chunks/jwk.mjs";
|
|
11
|
-
import
|
|
12
|
-
export { DEFAULT_JOSE_LIMITS, JWTError, UnsecureError, WeakMapJWKCache,
|
|
11
|
+
import "./utils/index.mjs";
|
|
12
|
+
export { DEFAULT_JOSE_LIMITS, JWTError, UnsecureError, WeakMapJWKCache, assertCryptoKey, base64Parse, base64Stringify, base64UrlParse, base64UrlStringify, clearJWKCache, computeDurationInSeconds, concatUint8Arrays, configureJWKCache, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, digestUrl, encrypt, encryptMulti, exportJWK, exportPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, sign, signMulti, textDecoder, textEncoder, thumbprint, toPublicJWK, unwrapKey, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
|