jose 6.1.3 → 6.2.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.
Files changed (52) hide show
  1. package/dist/types/jwe/general/decrypt.d.ts +7 -0
  2. package/dist/types/jws/general/verify.d.ts +8 -0
  3. package/dist/types/types.d.ts +15 -4
  4. package/dist/webapi/jwe/flattened/decrypt.js +28 -38
  5. package/dist/webapi/jwe/flattened/encrypt.js +21 -25
  6. package/dist/webapi/jwe/general/decrypt.js +1 -1
  7. package/dist/webapi/jwe/general/encrypt.js +13 -18
  8. package/dist/webapi/jwk/embedded.js +1 -1
  9. package/dist/webapi/jwk/thumbprint.js +2 -2
  10. package/dist/webapi/jwks/local.js +1 -1
  11. package/dist/webapi/jwks/remote.js +2 -2
  12. package/dist/webapi/jws/flattened/sign.js +5 -8
  13. package/dist/webapi/jws/flattened/verify.js +6 -16
  14. package/dist/webapi/jws/general/sign.js +3 -6
  15. package/dist/webapi/jws/general/verify.js +1 -1
  16. package/dist/webapi/jwt/encrypt.js +5 -12
  17. package/dist/webapi/key/import.js +1 -1
  18. package/dist/webapi/lib/aesgcmkw.js +1 -2
  19. package/dist/webapi/lib/check_key_type.js +1 -1
  20. package/dist/webapi/lib/content_encryption.js +217 -0
  21. package/dist/webapi/lib/crypto_key.js +9 -16
  22. package/dist/webapi/lib/deflate.js +44 -0
  23. package/dist/webapi/lib/ecdhes.js +1 -1
  24. package/dist/webapi/lib/helpers.js +19 -0
  25. package/dist/webapi/lib/jwk_to_key.js +9 -11
  26. package/dist/webapi/lib/jwt_claims_set.js +1 -1
  27. package/dist/webapi/lib/key_management.js +186 -0
  28. package/dist/webapi/lib/normalize_key.js +10 -20
  29. package/dist/webapi/lib/rsaes.js +1 -1
  30. package/dist/webapi/lib/signing.js +68 -0
  31. package/dist/webapi/lib/type_checks.js +40 -0
  32. package/dist/webapi/util/decode_jwt.js +1 -1
  33. package/dist/webapi/util/decode_protected_header.js +1 -1
  34. package/package.json +1 -1
  35. package/dist/webapi/lib/cek.js +0 -19
  36. package/dist/webapi/lib/check_cek_length.js +0 -7
  37. package/dist/webapi/lib/check_iv_length.js +0 -7
  38. package/dist/webapi/lib/check_key_length.js +0 -8
  39. package/dist/webapi/lib/decrypt.js +0 -106
  40. package/dist/webapi/lib/decrypt_key_management.js +0 -127
  41. package/dist/webapi/lib/digest.js +0 -4
  42. package/dist/webapi/lib/encrypt.js +0 -74
  43. package/dist/webapi/lib/encrypt_key_management.js +0 -92
  44. package/dist/webapi/lib/get_sign_verify_key.js +0 -12
  45. package/dist/webapi/lib/is_disjoint.js +0 -21
  46. package/dist/webapi/lib/is_jwk.js +0 -6
  47. package/dist/webapi/lib/is_object.js +0 -14
  48. package/dist/webapi/lib/iv.js +0 -19
  49. package/dist/webapi/lib/private_symbols.js +0 -1
  50. package/dist/webapi/lib/sign.js +0 -9
  51. package/dist/webapi/lib/subtle_dsa.js +0 -31
  52. package/dist/webapi/lib/verify.js +0 -14
@@ -1,19 +0,0 @@
1
- import { JOSENotSupported } from '../util/errors.js';
2
- export function bitLength(alg) {
3
- switch (alg) {
4
- case 'A128GCM':
5
- case 'A128GCMKW':
6
- case 'A192GCM':
7
- case 'A192GCMKW':
8
- case 'A256GCM':
9
- case 'A256GCMKW':
10
- return 96;
11
- case 'A128CBC-HS256':
12
- case 'A192CBC-HS384':
13
- case 'A256CBC-HS512':
14
- return 128;
15
- default:
16
- throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);
17
- }
18
- }
19
- export const generateIv = (alg) => crypto.getRandomValues(new Uint8Array(bitLength(alg) >> 3));
@@ -1 +0,0 @@
1
- export const unprotected = Symbol();
@@ -1,9 +0,0 @@
1
- import { subtleAlgorithm } from './subtle_dsa.js';
2
- import { checkKeyLength } from './check_key_length.js';
3
- import { getSigKey } from './get_sign_verify_key.js';
4
- export async function sign(alg, key, data) {
5
- const cryptoKey = await getSigKey(alg, key, 'sign');
6
- checkKeyLength(alg, cryptoKey);
7
- const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);
8
- return new Uint8Array(signature);
9
- }
@@ -1,31 +0,0 @@
1
- import { JOSENotSupported } from '../util/errors.js';
2
- export function subtleAlgorithm(alg, algorithm) {
3
- const hash = `SHA-${alg.slice(-3)}`;
4
- switch (alg) {
5
- case 'HS256':
6
- case 'HS384':
7
- case 'HS512':
8
- return { hash, name: 'HMAC' };
9
- case 'PS256':
10
- case 'PS384':
11
- case 'PS512':
12
- return { hash, name: 'RSA-PSS', saltLength: parseInt(alg.slice(-3), 10) >> 3 };
13
- case 'RS256':
14
- case 'RS384':
15
- case 'RS512':
16
- return { hash, name: 'RSASSA-PKCS1-v1_5' };
17
- case 'ES256':
18
- case 'ES384':
19
- case 'ES512':
20
- return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };
21
- case 'Ed25519':
22
- case 'EdDSA':
23
- return { name: 'Ed25519' };
24
- case 'ML-DSA-44':
25
- case 'ML-DSA-65':
26
- case 'ML-DSA-87':
27
- return { name: alg };
28
- default:
29
- throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
30
- }
31
- }
@@ -1,14 +0,0 @@
1
- import { subtleAlgorithm } from './subtle_dsa.js';
2
- import { checkKeyLength } from './check_key_length.js';
3
- import { getSigKey } from './get_sign_verify_key.js';
4
- export async function verify(alg, key, signature, data) {
5
- const cryptoKey = await getSigKey(alg, key, 'verify');
6
- checkKeyLength(alg, cryptoKey);
7
- const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
8
- try {
9
- return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
10
- }
11
- catch {
12
- return false;
13
- }
14
- }