jose 6.2.1 → 6.2.3
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.
|
@@ -134,7 +134,11 @@ export async function flattenedDecrypt(jwe, key, options) {
|
|
|
134
134
|
(!Number.isSafeInteger(maxDecompressedLength) || maxDecompressedLength < 1)) {
|
|
135
135
|
throw new TypeError('maxDecompressedLength must be 0, a positive safe integer, or Infinity');
|
|
136
136
|
}
|
|
137
|
-
result.plaintext = await decompress(plaintext, maxDecompressedLength)
|
|
137
|
+
result.plaintext = await decompress(plaintext, maxDecompressedLength).catch((cause) => {
|
|
138
|
+
if (cause instanceof JWEInvalid)
|
|
139
|
+
throw cause;
|
|
140
|
+
throw new JWEInvalid('Failed to decompress plaintext', { cause });
|
|
141
|
+
});
|
|
138
142
|
}
|
|
139
143
|
if (jwe.protected !== undefined) {
|
|
140
144
|
result.protectedHeader = parsedProt;
|
|
@@ -133,7 +133,9 @@ export class FlattenedEncrypt {
|
|
|
133
133
|
}
|
|
134
134
|
let plaintext = this.#plaintext;
|
|
135
135
|
if (joseHeader.zip === 'DEF') {
|
|
136
|
-
plaintext = await compress(plaintext)
|
|
136
|
+
plaintext = await compress(plaintext).catch((cause) => {
|
|
137
|
+
throw new JWEInvalid('Failed to compress plaintext', { cause });
|
|
138
|
+
});
|
|
137
139
|
}
|
|
138
140
|
const { ciphertext, tag, iv } = await encrypt(enc, plaintext, cek, this.#iv, additionalData);
|
|
139
141
|
const jwe = {
|
|
@@ -9,7 +9,7 @@ function isCloudflareWorkers() {
|
|
|
9
9
|
let USER_AGENT;
|
|
10
10
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
11
11
|
const NAME = 'jose';
|
|
12
|
-
const VERSION = 'v6.2.
|
|
12
|
+
const VERSION = 'v6.2.3';
|
|
13
13
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
14
14
|
}
|
|
15
15
|
export const customFetch = Symbol();
|
|
@@ -9,8 +9,8 @@ export async function compress(input) {
|
|
|
9
9
|
supported('CompressionStream');
|
|
10
10
|
const cs = new CompressionStream('deflate-raw');
|
|
11
11
|
const writer = cs.writable.getWriter();
|
|
12
|
-
writer.write(input);
|
|
13
|
-
writer.close();
|
|
12
|
+
writer.write(input).catch(() => { });
|
|
13
|
+
writer.close().catch(() => { });
|
|
14
14
|
const chunks = [];
|
|
15
15
|
const reader = cs.readable.getReader();
|
|
16
16
|
for (;;) {
|
|
@@ -25,8 +25,8 @@ export async function decompress(input, maxLength) {
|
|
|
25
25
|
supported('DecompressionStream');
|
|
26
26
|
const ds = new DecompressionStream('deflate-raw');
|
|
27
27
|
const writer = ds.writable.getWriter();
|
|
28
|
-
writer.write(input);
|
|
29
|
-
writer.close();
|
|
28
|
+
writer.write(input).catch(() => { });
|
|
29
|
+
writer.close().catch(() => { });
|
|
30
30
|
const chunks = [];
|
|
31
31
|
let length = 0;
|
|
32
32
|
const reader = ds.readable.getReader();
|
|
@@ -17,6 +17,9 @@ async function deriveKey(p2s, alg, p2c, key) {
|
|
|
17
17
|
if (!(p2s instanceof Uint8Array) || p2s.length < 8) {
|
|
18
18
|
throw new JWEInvalid('PBES2 Salt Input must be 8 or more octets');
|
|
19
19
|
}
|
|
20
|
+
if (!Number.isSafeInteger(p2c) || Math.sign(p2c) !== 1) {
|
|
21
|
+
throw new JWEInvalid('PBES2 Count Input must be a positive integer');
|
|
22
|
+
}
|
|
20
23
|
const salt = concatSalt(alg, p2s);
|
|
21
24
|
const keylen = parseInt(alg.slice(13, 16), 10);
|
|
22
25
|
const subtleAlg = {
|