jose 5.10.0 → 6.0.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 (291) hide show
  1. package/README.md +15 -15
  2. package/dist/types/index.d.ts +48 -48
  3. package/dist/types/jwe/compact/decrypt.d.ts +4 -4
  4. package/dist/types/jwe/compact/encrypt.d.ts +4 -4
  5. package/dist/types/jwe/flattened/decrypt.d.ts +4 -4
  6. package/dist/types/jwe/flattened/encrypt.d.ts +6 -6
  7. package/dist/types/jwe/general/decrypt.d.ts +4 -4
  8. package/dist/types/jwe/general/encrypt.d.ts +7 -7
  9. package/dist/types/jwk/embedded.d.ts +2 -2
  10. package/dist/types/jwk/thumbprint.d.ts +5 -5
  11. package/dist/types/jwks/local.d.ts +2 -2
  12. package/dist/types/jwks/remote.d.ts +104 -25
  13. package/dist/types/jws/compact/sign.d.ts +4 -4
  14. package/dist/types/jws/compact/verify.d.ts +4 -4
  15. package/dist/types/jws/flattened/sign.d.ts +4 -4
  16. package/dist/types/jws/flattened/verify.d.ts +4 -4
  17. package/dist/types/jws/general/sign.d.ts +6 -6
  18. package/dist/types/jws/general/verify.d.ts +4 -4
  19. package/dist/types/jwt/decrypt.d.ts +5 -5
  20. package/dist/types/jwt/encrypt.d.ts +5 -5
  21. package/dist/types/jwt/produce.d.ts +3 -3
  22. package/dist/types/jwt/sign.d.ts +4 -4
  23. package/dist/types/jwt/unsecured.d.ts +6 -6
  24. package/dist/types/jwt/verify.d.ts +5 -5
  25. package/dist/types/key/export.d.ts +10 -12
  26. package/dist/types/key/generate_key_pair.d.ts +10 -11
  27. package/dist/types/key/generate_secret.d.ts +6 -9
  28. package/dist/types/key/import.d.ts +20 -27
  29. package/dist/types/types.d.ts +27 -29
  30. package/dist/types/util/decode_jwt.d.ts +2 -2
  31. package/dist/types/util/decode_protected_header.d.ts +2 -2
  32. package/dist/types/util/errors.d.ts +6 -6
  33. package/dist/{browser → webapi}/index.js +2 -2
  34. package/dist/{node/esm → webapi}/jwe/flattened/decrypt.js +8 -4
  35. package/dist/{node/esm → webapi}/jwe/flattened/encrypt.js +7 -3
  36. package/dist/{node/esm → webapi}/jwe/general/encrypt.js +8 -3
  37. package/dist/{node/esm → webapi}/jwk/thumbprint.js +18 -8
  38. package/dist/{node/esm → webapi}/jwks/local.js +1 -6
  39. package/dist/{node/esm → webapi}/jwks/remote.js +34 -6
  40. package/dist/{node/esm → webapi}/jws/flattened/sign.js +7 -5
  41. package/dist/{browser → webapi}/jws/flattened/verify.js +8 -14
  42. package/dist/{browser → webapi}/jwt/unsecured.js +1 -1
  43. package/dist/{node/esm → webapi}/key/export.js +2 -3
  44. package/dist/{browser/runtime/generate.js → webapi/key/generate_key_pair.js} +4 -57
  45. package/dist/webapi/key/generate_secret.js +40 -0
  46. package/dist/{browser → webapi}/key/import.js +8 -6
  47. package/dist/{node/esm → webapi}/lib/aesgcmkw.js +3 -3
  48. package/dist/{browser/runtime → webapi/lib}/aeskw.js +9 -16
  49. package/dist/{browser/runtime → webapi/lib}/asn1.js +24 -20
  50. package/dist/{browser/runtime → webapi/lib}/base64url.js +17 -9
  51. package/dist/{browser → webapi}/lib/buffer_utils.js +4 -19
  52. package/dist/{browser → webapi}/lib/cek.js +1 -2
  53. package/dist/{browser/runtime → webapi/lib}/check_cek_length.js +1 -2
  54. package/dist/{browser → webapi}/lib/check_iv_length.js +1 -2
  55. package/dist/webapi/lib/check_key_type.js +126 -0
  56. package/dist/{node/esm → webapi}/lib/crypto_key.js +9 -26
  57. package/dist/{browser/runtime → webapi/lib}/decrypt.js +26 -10
  58. package/dist/{node/esm → webapi}/lib/decrypt_key_management.js +22 -24
  59. package/dist/{browser/runtime → webapi/lib}/digest.js +1 -3
  60. package/dist/webapi/lib/ecdhes.js +46 -0
  61. package/dist/{browser/runtime → webapi/lib}/encrypt.js +8 -10
  62. package/dist/{node/esm → webapi}/lib/encrypt_key_management.js +26 -23
  63. package/dist/webapi/lib/get_sign_verify_key.js +12 -0
  64. package/dist/{node/esm → webapi}/lib/is_disjoint.js +1 -2
  65. package/dist/{browser → webapi}/lib/is_jwk.js +1 -1
  66. package/dist/webapi/lib/is_key_like.js +14 -0
  67. package/dist/{browser → webapi}/lib/is_object.js +2 -2
  68. package/dist/{node/esm → webapi}/lib/iv.js +1 -2
  69. package/dist/{browser/runtime → webapi/lib}/jwk_to_key.js +3 -13
  70. package/dist/webapi/lib/key_to_jwk.js +27 -0
  71. package/dist/webapi/lib/normalize_key.js +164 -0
  72. package/dist/webapi/lib/pbes2kw.js +37 -0
  73. package/dist/webapi/lib/rsaes.js +24 -0
  74. package/dist/{browser/runtime → webapi/lib}/sign.js +1 -3
  75. package/dist/{browser/runtime → webapi/lib}/subtle_dsa.js +4 -5
  76. package/dist/{browser → webapi}/lib/validate_algorithms.js +1 -2
  77. package/dist/{node/esm → webapi}/lib/validate_crit.js +3 -4
  78. package/dist/{browser/runtime → webapi/lib}/verify.js +1 -3
  79. package/dist/{node/esm → webapi}/util/base64url.js +1 -1
  80. package/package.json +36 -219
  81. package/dist/browser/jwe/compact/encrypt.js +0 -26
  82. package/dist/browser/jwe/flattened/decrypt.js +0 -161
  83. package/dist/browser/jwe/flattened/encrypt.js +0 -153
  84. package/dist/browser/jwe/general/encrypt.js +0 -174
  85. package/dist/browser/jwk/thumbprint.js +0 -53
  86. package/dist/browser/jwks/local.js +0 -124
  87. package/dist/browser/jwks/remote.js +0 -139
  88. package/dist/browser/jws/compact/sign.js +0 -17
  89. package/dist/browser/jws/flattened/sign.js +0 -81
  90. package/dist/browser/jws/general/sign.js +0 -67
  91. package/dist/browser/jwt/encrypt.js +0 -68
  92. package/dist/browser/jwt/produce.js +0 -75
  93. package/dist/browser/jwt/sign.js +0 -20
  94. package/dist/browser/key/export.js +0 -12
  95. package/dist/browser/key/generate_key_pair.js +0 -4
  96. package/dist/browser/key/generate_secret.js +0 -4
  97. package/dist/browser/lib/aesgcmkw.js +0 -16
  98. package/dist/browser/lib/check_key_type.js +0 -77
  99. package/dist/browser/lib/check_p2s.js +0 -6
  100. package/dist/browser/lib/crypto_key.js +0 -157
  101. package/dist/browser/lib/decrypt_key_management.js +0 -129
  102. package/dist/browser/lib/encrypt_key_management.js +0 -89
  103. package/dist/browser/lib/format_pem.js +0 -4
  104. package/dist/browser/lib/is_disjoint.js +0 -22
  105. package/dist/browser/lib/iv.js +0 -20
  106. package/dist/browser/lib/validate_crit.js +0 -34
  107. package/dist/browser/package.json +0 -1
  108. package/dist/browser/runtime/bogus.js +0 -6
  109. package/dist/browser/runtime/ecdhes.js +0 -47
  110. package/dist/browser/runtime/fetch_jwks.js +0 -34
  111. package/dist/browser/runtime/get_sign_verify_key.js +0 -24
  112. package/dist/browser/runtime/is_key_like.js +0 -8
  113. package/dist/browser/runtime/key_to_jwk.js +0 -21
  114. package/dist/browser/runtime/normalize_key.js +0 -68
  115. package/dist/browser/runtime/pbes2kw.js +0 -51
  116. package/dist/browser/runtime/random.js +0 -2
  117. package/dist/browser/runtime/rsaes.js +0 -37
  118. package/dist/browser/runtime/runtime.js +0 -1
  119. package/dist/browser/runtime/subtle_rsaes.js +0 -12
  120. package/dist/browser/runtime/timing_safe_equal.js +0 -19
  121. package/dist/browser/runtime/webcrypto.js +0 -2
  122. package/dist/browser/util/base64url.js +0 -3
  123. package/dist/browser/util/errors.js +0 -114
  124. package/dist/browser/util/runtime.js +0 -2
  125. package/dist/node/cjs/index.js +0 -69
  126. package/dist/node/cjs/jwe/compact/decrypt.js +0 -30
  127. package/dist/node/cjs/jwe/compact/encrypt.js +0 -31
  128. package/dist/node/cjs/jwe/flattened/decrypt.js +0 -164
  129. package/dist/node/cjs/jwe/flattened/encrypt.js +0 -165
  130. package/dist/node/cjs/jwe/general/decrypt.js +0 -34
  131. package/dist/node/cjs/jwe/general/encrypt.js +0 -186
  132. package/dist/node/cjs/jwk/embedded.js +0 -20
  133. package/dist/node/cjs/jwk/thumbprint.js +0 -57
  134. package/dist/node/cjs/jwks/local.js +0 -128
  135. package/dist/node/cjs/jwks/remote.js +0 -152
  136. package/dist/node/cjs/jws/compact/sign.js +0 -22
  137. package/dist/node/cjs/jws/compact/verify.js +0 -24
  138. package/dist/node/cjs/jws/flattened/sign.js +0 -88
  139. package/dist/node/cjs/jws/flattened/verify.js +0 -125
  140. package/dist/node/cjs/jws/general/sign.js +0 -77
  141. package/dist/node/cjs/jws/general/verify.js +0 -27
  142. package/dist/node/cjs/jwt/decrypt.js +0 -26
  143. package/dist/node/cjs/jwt/encrypt.js +0 -79
  144. package/dist/node/cjs/jwt/produce.js +0 -80
  145. package/dist/node/cjs/jwt/sign.js +0 -25
  146. package/dist/node/cjs/jwt/unsecured.js +0 -36
  147. package/dist/node/cjs/jwt/verify.js +0 -18
  148. package/dist/node/cjs/key/export.js +0 -17
  149. package/dist/node/cjs/key/generate_key_pair.js +0 -7
  150. package/dist/node/cjs/key/generate_secret.js +0 -7
  151. package/dist/node/cjs/key/import.js +0 -51
  152. package/dist/node/cjs/lib/aesgcmkw.js +0 -20
  153. package/dist/node/cjs/lib/buffer_utils.js +0 -60
  154. package/dist/node/cjs/lib/cek.js +0 -23
  155. package/dist/node/cjs/lib/check_iv_length.js +0 -10
  156. package/dist/node/cjs/lib/check_key_type.js +0 -80
  157. package/dist/node/cjs/lib/check_p2s.js +0 -9
  158. package/dist/node/cjs/lib/crypto_key.js +0 -161
  159. package/dist/node/cjs/lib/decrypt_key_management.js +0 -131
  160. package/dist/node/cjs/lib/encrypt_key_management.js +0 -91
  161. package/dist/node/cjs/lib/epoch.js +0 -3
  162. package/dist/node/cjs/lib/invalid_key_input.js +0 -34
  163. package/dist/node/cjs/lib/is_disjoint.js +0 -24
  164. package/dist/node/cjs/lib/is_jwk.js +0 -19
  165. package/dist/node/cjs/lib/is_object.js +0 -19
  166. package/dist/node/cjs/lib/iv.js +0 -23
  167. package/dist/node/cjs/lib/jwt_claims_set.js +0 -106
  168. package/dist/node/cjs/lib/private_symbols.js +0 -4
  169. package/dist/node/cjs/lib/secs.js +0 -57
  170. package/dist/node/cjs/lib/validate_algorithms.js +0 -13
  171. package/dist/node/cjs/lib/validate_crit.js +0 -36
  172. package/dist/node/cjs/runtime/aeskw.js +0 -55
  173. package/dist/node/cjs/runtime/asn1.js +0 -54
  174. package/dist/node/cjs/runtime/base64url.js +0 -20
  175. package/dist/node/cjs/runtime/cbc_tag.js +0 -11
  176. package/dist/node/cjs/runtime/check_cek_length.js +0 -37
  177. package/dist/node/cjs/runtime/check_key_length.js +0 -18
  178. package/dist/node/cjs/runtime/ciphers.js +0 -8
  179. package/dist/node/cjs/runtime/decrypt.js +0 -103
  180. package/dist/node/cjs/runtime/digest.js +0 -5
  181. package/dist/node/cjs/runtime/dsa_digest.js +0 -26
  182. package/dist/node/cjs/runtime/ecdhes.js +0 -70
  183. package/dist/node/cjs/runtime/encrypt.js +0 -80
  184. package/dist/node/cjs/runtime/fetch_jwks.js +0 -45
  185. package/dist/node/cjs/runtime/generate.js +0 -103
  186. package/dist/node/cjs/runtime/get_named_curve.js +0 -61
  187. package/dist/node/cjs/runtime/get_sign_verify_key.js +0 -31
  188. package/dist/node/cjs/runtime/hmac_digest.js +0 -16
  189. package/dist/node/cjs/runtime/is_key_like.js +0 -11
  190. package/dist/node/cjs/runtime/is_key_object.js +0 -4
  191. package/dist/node/cjs/runtime/jwk_to_key.js +0 -10
  192. package/dist/node/cjs/runtime/key_to_jwk.js +0 -36
  193. package/dist/node/cjs/runtime/node_key.js +0 -111
  194. package/dist/node/cjs/runtime/normalize_key.js +0 -3
  195. package/dist/node/cjs/runtime/pbes2kw.js +0 -48
  196. package/dist/node/cjs/runtime/random.js +0 -5
  197. package/dist/node/cjs/runtime/rsaes.js +0 -71
  198. package/dist/node/cjs/runtime/runtime.js +0 -3
  199. package/dist/node/cjs/runtime/sign.js +0 -19
  200. package/dist/node/cjs/runtime/timing_safe_equal.js +0 -5
  201. package/dist/node/cjs/runtime/verify.js +0 -31
  202. package/dist/node/cjs/runtime/webcrypto.js +0 -9
  203. package/dist/node/cjs/util/base64url.js +0 -6
  204. package/dist/node/cjs/util/decode_jwt.js +0 -35
  205. package/dist/node/cjs/util/decode_protected_header.js +0 -37
  206. package/dist/node/cjs/util/errors.js +0 -117
  207. package/dist/node/cjs/util/runtime.js +0 -4
  208. package/dist/node/esm/index.js +0 -30
  209. package/dist/node/esm/jwe/compact/decrypt.js +0 -27
  210. package/dist/node/esm/jwe/general/decrypt.js +0 -31
  211. package/dist/node/esm/jwk/embedded.js +0 -17
  212. package/dist/node/esm/jws/compact/verify.js +0 -21
  213. package/dist/node/esm/jws/flattened/verify.js +0 -122
  214. package/dist/node/esm/jws/general/verify.js +0 -24
  215. package/dist/node/esm/jwt/decrypt.js +0 -23
  216. package/dist/node/esm/jwt/unsecured.js +0 -32
  217. package/dist/node/esm/jwt/verify.js +0 -15
  218. package/dist/node/esm/key/generate_key_pair.js +0 -4
  219. package/dist/node/esm/key/generate_secret.js +0 -4
  220. package/dist/node/esm/key/import.js +0 -45
  221. package/dist/node/esm/lib/buffer_utils.js +0 -51
  222. package/dist/node/esm/lib/cek.js +0 -20
  223. package/dist/node/esm/lib/check_iv_length.js +0 -8
  224. package/dist/node/esm/lib/check_key_type.js +0 -77
  225. package/dist/node/esm/lib/check_p2s.js +0 -6
  226. package/dist/node/esm/lib/epoch.js +0 -1
  227. package/dist/node/esm/lib/invalid_key_input.js +0 -31
  228. package/dist/node/esm/lib/is_jwk.js +0 -13
  229. package/dist/node/esm/lib/is_object.js +0 -16
  230. package/dist/node/esm/lib/jwt_claims_set.js +0 -104
  231. package/dist/node/esm/lib/private_symbols.js +0 -1
  232. package/dist/node/esm/lib/secs.js +0 -55
  233. package/dist/node/esm/lib/validate_algorithms.js +0 -11
  234. package/dist/node/esm/package.json +0 -1
  235. package/dist/node/esm/runtime/aeskw.js +0 -50
  236. package/dist/node/esm/runtime/asn1.js +0 -46
  237. package/dist/node/esm/runtime/base64url.js +0 -14
  238. package/dist/node/esm/runtime/cbc_tag.js +0 -8
  239. package/dist/node/esm/runtime/check_cek_length.js +0 -35
  240. package/dist/node/esm/runtime/check_key_length.js +0 -16
  241. package/dist/node/esm/runtime/ciphers.js +0 -6
  242. package/dist/node/esm/runtime/decrypt.js +0 -101
  243. package/dist/node/esm/runtime/digest.js +0 -3
  244. package/dist/node/esm/runtime/dsa_digest.js +0 -23
  245. package/dist/node/esm/runtime/ecdhes.js +0 -64
  246. package/dist/node/esm/runtime/encrypt.js +0 -78
  247. package/dist/node/esm/runtime/fetch_jwks.js +0 -43
  248. package/dist/node/esm/runtime/generate.js +0 -99
  249. package/dist/node/esm/runtime/get_named_curve.js +0 -58
  250. package/dist/node/esm/runtime/get_sign_verify_key.js +0 -28
  251. package/dist/node/esm/runtime/hmac_digest.js +0 -13
  252. package/dist/node/esm/runtime/is_key_like.js +0 -8
  253. package/dist/node/esm/runtime/is_key_object.js +0 -2
  254. package/dist/node/esm/runtime/jwk_to_key.js +0 -8
  255. package/dist/node/esm/runtime/key_to_jwk.js +0 -34
  256. package/dist/node/esm/runtime/node_key.js +0 -108
  257. package/dist/node/esm/runtime/normalize_key.js +0 -1
  258. package/dist/node/esm/runtime/pbes2kw.js +0 -43
  259. package/dist/node/esm/runtime/random.js +0 -1
  260. package/dist/node/esm/runtime/rsaes.js +0 -66
  261. package/dist/node/esm/runtime/runtime.js +0 -1
  262. package/dist/node/esm/runtime/sign.js +0 -17
  263. package/dist/node/esm/runtime/timing_safe_equal.js +0 -3
  264. package/dist/node/esm/runtime/verify.js +0 -29
  265. package/dist/node/esm/runtime/webcrypto.js +0 -5
  266. package/dist/node/esm/util/decode_jwt.js +0 -32
  267. package/dist/node/esm/util/decode_protected_header.js +0 -34
  268. package/dist/node/esm/util/runtime.js +0 -2
  269. package/dist/types/util/runtime.d.ts +0 -3
  270. /package/dist/{browser → webapi}/jwe/compact/decrypt.js +0 -0
  271. /package/dist/{node/esm → webapi}/jwe/compact/encrypt.js +0 -0
  272. /package/dist/{browser → webapi}/jwe/general/decrypt.js +0 -0
  273. /package/dist/{browser → webapi}/jwk/embedded.js +0 -0
  274. /package/dist/{node/esm → webapi}/jws/compact/sign.js +0 -0
  275. /package/dist/{browser → webapi}/jws/compact/verify.js +0 -0
  276. /package/dist/{node/esm → webapi}/jws/general/sign.js +0 -0
  277. /package/dist/{browser → webapi}/jws/general/verify.js +0 -0
  278. /package/dist/{browser → webapi}/jwt/decrypt.js +0 -0
  279. /package/dist/{node/esm → webapi}/jwt/encrypt.js +0 -0
  280. /package/dist/{node/esm → webapi}/jwt/produce.js +0 -0
  281. /package/dist/{node/esm → webapi}/jwt/sign.js +0 -0
  282. /package/dist/{browser → webapi}/jwt/verify.js +0 -0
  283. /package/dist/{browser/runtime → webapi/lib}/check_key_length.js +0 -0
  284. /package/dist/{browser → webapi}/lib/epoch.js +0 -0
  285. /package/dist/{browser → webapi}/lib/invalid_key_input.js +0 -0
  286. /package/dist/{browser → webapi}/lib/jwt_claims_set.js +0 -0
  287. /package/dist/{browser → webapi}/lib/private_symbols.js +0 -0
  288. /package/dist/{browser → webapi}/lib/secs.js +0 -0
  289. /package/dist/{browser → webapi}/util/decode_jwt.js +0 -0
  290. /package/dist/{browser → webapi}/util/decode_protected_header.js +0 -0
  291. /package/dist/{node/esm → webapi}/util/errors.js +0 -0
@@ -1,11 +1,11 @@
1
- import type { JWK, CompactVerifyResult, FlattenedJWSInput, GenericGetKeyFunction, CompactJWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
1
+ import type * as types from '../../types.d.ts';
2
2
  /**
3
3
  * Interface for Compact JWS Verification dynamic key resolution. No token components have been
4
4
  * verified at the time of this function call.
5
5
  *
6
6
  * @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
7
7
  */
8
- export interface CompactVerifyGetKey extends GenericGetKeyFunction<CompactJWSHeaderParameters, FlattenedJWSInput, KeyLike | JWK | Uint8Array> {
8
+ export interface CompactVerifyGetKey extends types.GenericGetKeyFunction<types.CompactJWSHeaderParameters, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
9
9
  }
10
10
  /**
11
11
  * Verifies the signature and format of and afterwards decodes the Compact JWS.
@@ -18,11 +18,11 @@ export interface CompactVerifyGetKey extends GenericGetKeyFunction<CompactJWSHea
18
18
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
19
19
  * @param options JWS Verify options.
20
20
  */
21
- export declare function compactVerify(jws: string | Uint8Array, key: KeyLike | Uint8Array | JWK, options?: VerifyOptions): Promise<CompactVerifyResult>;
21
+ export declare function compactVerify(jws: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.CompactVerifyResult>;
22
22
  /**
23
23
  * @param jws Compact JWS.
24
24
  * @param getKey Function resolving a key to verify the JWS with. See
25
25
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
26
26
  * @param options JWS Verify options.
27
27
  */
28
- export declare function compactVerify<KeyLikeType extends KeyLike = KeyLike>(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey<KeyLikeType>>;
28
+ export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: types.VerifyOptions): Promise<types.CompactVerifyResult & types.ResolvedKey>;
@@ -1,4 +1,4 @@
1
- import type { JWK, KeyLike, FlattenedJWS, JWSHeaderParameters, SignOptions } from '../../types';
1
+ import type * as types from '../../types.d.ts';
2
2
  /**
3
3
  * The FlattenedSign class is used to build and sign Flattened JWS objects.
4
4
  *
@@ -17,13 +17,13 @@ export declare class FlattenedSign {
17
17
  *
18
18
  * @param protectedHeader JWS Protected Header.
19
19
  */
20
- setProtectedHeader(protectedHeader: JWSHeaderParameters): this;
20
+ setProtectedHeader(protectedHeader: types.JWSHeaderParameters): this;
21
21
  /**
22
22
  * Sets the JWS Unprotected Header on the FlattenedSign object.
23
23
  *
24
24
  * @param unprotectedHeader JWS Unprotected Header.
25
25
  */
26
- setUnprotectedHeader(unprotectedHeader: JWSHeaderParameters): this;
26
+ setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): this;
27
27
  /**
28
28
  * Signs and resolves the value of the Flattened JWS object.
29
29
  *
@@ -31,5 +31,5 @@ export declare class FlattenedSign {
31
31
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
32
32
  * @param options JWS Sign options.
33
33
  */
34
- sign(key: KeyLike | Uint8Array | JWK, options?: SignOptions): Promise<FlattenedJWS>;
34
+ sign(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Promise<types.FlattenedJWS>;
35
35
  }
@@ -1,11 +1,11 @@
1
- import type { JWK, FlattenedVerifyResult, KeyLike, FlattenedJWSInput, JWSHeaderParameters, VerifyOptions, GenericGetKeyFunction, ResolvedKey } from '../../types';
1
+ import type * as types from '../../types.d.ts';
2
2
  /**
3
3
  * Interface for Flattened JWS Verification dynamic key resolution. No token components have been
4
4
  * verified at the time of this function call.
5
5
  *
6
6
  * @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
7
7
  */
8
- export interface FlattenedVerifyGetKey extends GenericGetKeyFunction<JWSHeaderParameters | undefined, FlattenedJWSInput, KeyLike | JWK | Uint8Array> {
8
+ export interface FlattenedVerifyGetKey extends types.GenericGetKeyFunction<types.JWSHeaderParameters | undefined, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
9
9
  }
10
10
  /**
11
11
  * Verifies the signature and format of and afterwards decodes the Flattened JWS.
@@ -18,11 +18,11 @@ export interface FlattenedVerifyGetKey extends GenericGetKeyFunction<JWSHeaderPa
18
18
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
19
19
  * @param options JWS Verify options.
20
20
  */
21
- export declare function flattenedVerify(jws: FlattenedJWSInput, key: KeyLike | Uint8Array | JWK, options?: VerifyOptions): Promise<FlattenedVerifyResult>;
21
+ export declare function flattenedVerify(jws: types.FlattenedJWSInput, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult>;
22
22
  /**
23
23
  * @param jws Flattened JWS.
24
24
  * @param getKey Function resolving a key to verify the JWS with. See
25
25
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
26
26
  * @param options JWS Verify options.
27
27
  */
28
- export declare function flattenedVerify<KeyLikeType extends KeyLike = KeyLike>(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey<KeyLikeType>>;
28
+ export declare function flattenedVerify(jws: types.FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult & types.ResolvedKey>;
@@ -1,21 +1,21 @@
1
- import type { JWK, KeyLike, GeneralJWS, JWSHeaderParameters, SignOptions } from '../../types';
1
+ import type * as types from '../../types.d.ts';
2
2
  export interface Signature {
3
3
  /**
4
4
  * Sets the JWS Protected Header on the Signature object.
5
5
  *
6
6
  * @param protectedHeader JWS Protected Header.
7
7
  */
8
- setProtectedHeader(protectedHeader: JWSHeaderParameters): Signature;
8
+ setProtectedHeader(protectedHeader: types.JWSHeaderParameters): Signature;
9
9
  /**
10
10
  * Sets the JWS Unprotected Header on the Signature object.
11
11
  *
12
12
  * @param unprotectedHeader JWS Unprotected Header.
13
13
  */
14
- setUnprotectedHeader(unprotectedHeader: JWSHeaderParameters): Signature;
14
+ setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): Signature;
15
15
  /** A shorthand for calling addSignature() on the enclosing GeneralSign instance */
16
16
  addSignature(...args: Parameters<GeneralSign['addSignature']>): Signature;
17
17
  /** A shorthand for calling encrypt() on the enclosing GeneralSign instance */
18
- sign(...args: Parameters<GeneralSign['sign']>): Promise<GeneralJWS>;
18
+ sign(...args: Parameters<GeneralSign['sign']>): Promise<types.GeneralJWS>;
19
19
  /** Returns the enclosing GeneralSign */
20
20
  done(): GeneralSign;
21
21
  }
@@ -38,7 +38,7 @@ export declare class GeneralSign {
38
38
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
39
39
  * @param options JWS Sign options.
40
40
  */
41
- addSignature(key: KeyLike | Uint8Array | JWK, options?: SignOptions): Signature;
41
+ addSignature(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Signature;
42
42
  /** Signs and resolves the value of the General JWS object. */
43
- sign(): Promise<GeneralJWS>;
43
+ sign(): Promise<types.GeneralJWS>;
44
44
  }
@@ -1,11 +1,11 @@
1
- import type { JWK, GeneralJWSInput, GeneralVerifyResult, FlattenedJWSInput, GenericGetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
1
+ import type * as types from '../../types.d.ts';
2
2
  /**
3
3
  * Interface for General JWS Verification dynamic key resolution. No token components have been
4
4
  * verified at the time of this function call.
5
5
  *
6
6
  * @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
7
7
  */
8
- export interface GeneralVerifyGetKey extends GenericGetKeyFunction<JWSHeaderParameters, FlattenedJWSInput, KeyLike | JWK | Uint8Array> {
8
+ export interface GeneralVerifyGetKey extends types.GenericGetKeyFunction<types.JWSHeaderParameters, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
9
9
  }
10
10
  /**
11
11
  * Verifies the signature and format of and afterwards decodes the General JWS.
@@ -18,11 +18,11 @@ export interface GeneralVerifyGetKey extends GenericGetKeyFunction<JWSHeaderPara
18
18
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
19
19
  * @param options JWS Verify options.
20
20
  */
21
- export declare function generalVerify(jws: GeneralJWSInput, key: KeyLike | Uint8Array | JWK, options?: VerifyOptions): Promise<GeneralVerifyResult>;
21
+ export declare function generalVerify(jws: types.GeneralJWSInput, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.GeneralVerifyResult>;
22
22
  /**
23
23
  * @param jws General JWS.
24
24
  * @param getKey Function resolving a key to verify the JWS with. See
25
25
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
26
26
  * @param options JWS Verify options.
27
27
  */
28
- export declare function generalVerify<KeyLikeType extends KeyLike = KeyLike>(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey<KeyLikeType>>;
28
+ export declare function generalVerify(jws: types.GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: types.VerifyOptions): Promise<types.GeneralVerifyResult & types.ResolvedKey>;
@@ -1,12 +1,12 @@
1
- import type { JWTPayload, KeyLike, DecryptOptions, JWTClaimVerificationOptions, GetKeyFunction, CompactJWEHeaderParameters, FlattenedJWE, JWTDecryptResult, ResolvedKey } from '../types';
1
+ import type * as types from '../types.d.ts';
2
2
  /** Combination of JWE Decryption options and JWT Claims Set verification options. */
3
- export interface JWTDecryptOptions extends DecryptOptions, JWTClaimVerificationOptions {
3
+ export interface JWTDecryptOptions extends types.DecryptOptions, types.JWTClaimVerificationOptions {
4
4
  }
5
5
  /**
6
6
  * Interface for JWT Decryption dynamic key resolution. No token components have been verified at
7
7
  * the time of this function call.
8
8
  */
9
- export interface JWTDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParameters, FlattenedJWE> {
9
+ export interface JWTDecryptGetKey extends types.GetKeyFunction<types.CompactJWEHeaderParameters, types.FlattenedJWE> {
10
10
  }
11
11
  /**
12
12
  * Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, validates the JWT
@@ -20,11 +20,11 @@ export interface JWTDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParamet
20
20
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
21
21
  * @param options JWT Decryption and JWT Claims Set validation options.
22
22
  */
23
- export declare function jwtDecrypt<PayloadType = JWTPayload>(jwt: string | Uint8Array, key: KeyLike | Uint8Array, options?: JWTDecryptOptions): Promise<JWTDecryptResult<PayloadType>>;
23
+ export declare function jwtDecrypt<PayloadType = types.JWTPayload>(jwt: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: JWTDecryptOptions): Promise<types.JWTDecryptResult<PayloadType>>;
24
24
  /**
25
25
  * @param jwt JSON Web Token value (encoded as JWE).
26
26
  * @param getKey Function resolving Private Key or Secret to decrypt and verify the JWT with. See
27
27
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
28
28
  * @param options JWT Decryption and JWT Claims Set validation options.
29
29
  */
30
- export declare function jwtDecrypt<PayloadType = JWTPayload, KeyLikeType extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult<PayloadType> & ResolvedKey<KeyLikeType>>;
30
+ export declare function jwtDecrypt<PayloadType = types.JWTPayload>(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<types.JWTDecryptResult<PayloadType> & types.ResolvedKey>;
@@ -1,5 +1,5 @@
1
- import type { EncryptOptions, CompactJWEHeaderParameters, JWEKeyManagementHeaderParameters, KeyLike } from '../types';
2
- import { ProduceJWT } from './produce';
1
+ import type * as types from '../types.d.ts';
2
+ import { ProduceJWT } from './produce.js';
3
3
  /**
4
4
  * The EncryptJWT class is used to build and encrypt Compact JWE formatted JSON Web Tokens.
5
5
  *
@@ -21,7 +21,7 @@ export declare class EncryptJWT extends ProduceJWT {
21
21
  * @param protectedHeader JWE Protected Header. Must contain an "alg" (JWE Algorithm) and "enc"
22
22
  * (JWE Encryption Algorithm) properties.
23
23
  */
24
- setProtectedHeader(protectedHeader: CompactJWEHeaderParameters): this;
24
+ setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
25
25
  /**
26
26
  * Sets the JWE Key Management parameters to be used when encrypting. Use of this is method is
27
27
  * really only needed for ECDH based algorithms when utilizing the Agreement PartyUInfo or
@@ -30,7 +30,7 @@ export declare class EncryptJWT extends ProduceJWT {
30
30
  *
31
31
  * @param parameters JWE Key Management parameters.
32
32
  */
33
- setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters): this;
33
+ setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): this;
34
34
  /**
35
35
  * Sets a content encryption key to use, by default a random suitable one is generated for the JWE
36
36
  * enc" (Encryption Algorithm) Header Parameter.
@@ -76,5 +76,5 @@ export declare class EncryptJWT extends ProduceJWT {
76
76
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
77
77
  * @param options JWE Encryption options.
78
78
  */
79
- encrypt(key: KeyLike | Uint8Array, options?: EncryptOptions): Promise<string>;
79
+ encrypt(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.EncryptOptions): Promise<string>;
80
80
  }
@@ -1,9 +1,9 @@
1
- import type { JWTPayload } from '../types';
1
+ import type * as types from '../types.d.ts';
2
2
  /** Generic class for JWT producing. */
3
3
  export declare class ProduceJWT {
4
- protected _payload: JWTPayload;
4
+ protected _payload: types.JWTPayload;
5
5
  /** @param payload The JWT Claims Set object. Defaults to an empty object. */
6
- constructor(payload?: JWTPayload);
6
+ constructor(payload?: types.JWTPayload);
7
7
  /**
8
8
  * Set the "iss" (Issuer) Claim.
9
9
  *
@@ -1,5 +1,5 @@
1
- import type { JWK, JWTHeaderParameters, KeyLike, SignOptions } from '../types';
2
- import { ProduceJWT } from './produce';
1
+ import type * as types from '../types.d.ts';
2
+ import { ProduceJWT } from './produce.js';
3
3
  /**
4
4
  * The SignJWT class is used to build and sign Compact JWS formatted JSON Web Tokens.
5
5
  *
@@ -14,7 +14,7 @@ export declare class SignJWT extends ProduceJWT {
14
14
  *
15
15
  * @param protectedHeader JWS Protected Header. Must contain an "alg" (JWS Algorithm) property.
16
16
  */
17
- setProtectedHeader(protectedHeader: JWTHeaderParameters): this;
17
+ setProtectedHeader(protectedHeader: types.JWTHeaderParameters): this;
18
18
  /**
19
19
  * Signs and returns the JWT.
20
20
  *
@@ -22,5 +22,5 @@ export declare class SignJWT extends ProduceJWT {
22
22
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
23
23
  * @param options JWT Sign options.
24
24
  */
25
- sign(key: KeyLike | Uint8Array | JWK, options?: SignOptions): Promise<string>;
25
+ sign(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Promise<string>;
26
26
  }
@@ -1,8 +1,8 @@
1
- import type { JWSHeaderParameters, JWTClaimVerificationOptions, JWTPayload } from '../types';
2
- import { ProduceJWT } from './produce';
3
- export interface UnsecuredResult<PayloadType = JWTPayload> {
4
- payload: PayloadType & JWTPayload;
5
- header: JWSHeaderParameters;
1
+ import type * as types from '../types.d.ts';
2
+ import { ProduceJWT } from './produce.js';
3
+ export interface UnsecuredResult<PayloadType = types.JWTPayload> {
4
+ payload: PayloadType & types.JWTPayload;
5
+ header: types.JWSHeaderParameters;
6
6
  }
7
7
  /**
8
8
  * The UnsecuredJWT class is a utility for dealing with `{ "alg": "none" }` Unsecured JWTs.
@@ -20,5 +20,5 @@ export declare class UnsecuredJWT extends ProduceJWT {
20
20
  * @param jwt Unsecured JWT to decode the payload of.
21
21
  * @param options JWT Claims Set validation options.
22
22
  */
23
- static decode<PayloadType = JWTPayload>(jwt: string, options?: JWTClaimVerificationOptions): UnsecuredResult<PayloadType>;
23
+ static decode<PayloadType = types.JWTPayload>(jwt: string, options?: types.JWTClaimVerificationOptions): UnsecuredResult<PayloadType>;
24
24
  }
@@ -1,6 +1,6 @@
1
- import type { JWK, JWTPayload, KeyLike, VerifyOptions, JWTClaimVerificationOptions, JWTHeaderParameters, GenericGetKeyFunction, FlattenedJWSInput, JWTVerifyResult, ResolvedKey } from '../types';
1
+ import type * as types from '../types.d.ts';
2
2
  /** Combination of JWS Verification options and JWT Claims Set verification options. */
3
- export interface JWTVerifyOptions extends VerifyOptions, JWTClaimVerificationOptions {
3
+ export interface JWTVerifyOptions extends types.VerifyOptions, types.JWTClaimVerificationOptions {
4
4
  }
5
5
  /**
6
6
  * Interface for JWT Verification dynamic key resolution. No token components have been verified at
@@ -8,7 +8,7 @@ export interface JWTVerifyOptions extends VerifyOptions, JWTClaimVerificationOpt
8
8
  *
9
9
  * @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
10
10
  */
11
- export interface JWTVerifyGetKey extends GenericGetKeyFunction<JWTHeaderParameters, FlattenedJWSInput, KeyLike | JWK | Uint8Array> {
11
+ export interface JWTVerifyGetKey extends types.GenericGetKeyFunction<types.JWTHeaderParameters, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
12
12
  }
13
13
  /**
14
14
  * Verifies the JWT format (to be a JWS Compact format), verifies the JWS signature, validates the
@@ -22,11 +22,11 @@ export interface JWTVerifyGetKey extends GenericGetKeyFunction<JWTHeaderParamete
22
22
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
23
23
  * @param options JWT Decryption and JWT Claims Set validation options.
24
24
  */
25
- export declare function jwtVerify<PayloadType = JWTPayload>(jwt: string | Uint8Array, key: KeyLike | Uint8Array | JWK, options?: JWTVerifyOptions): Promise<JWTVerifyResult<PayloadType>>;
25
+ export declare function jwtVerify<PayloadType = types.JWTPayload>(jwt: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: JWTVerifyOptions): Promise<types.JWTVerifyResult<PayloadType>>;
26
26
  /**
27
27
  * @param jwt JSON Web Token value (encoded as JWS).
28
28
  * @param getKey Function resolving a key to verify the JWT with. See
29
29
  * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
30
30
  * @param options JWT Decryption and JWT Claims Set validation options.
31
31
  */
32
- export declare function jwtVerify<PayloadType = JWTPayload, KeyLikeType extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<JWTVerifyResult<PayloadType> & ResolvedKey<KeyLikeType>>;
32
+ export declare function jwtVerify<PayloadType = types.JWTPayload>(jwt: string | Uint8Array, getKey: JWTVerifyGetKey, options?: JWTVerifyOptions): Promise<types.JWTVerifyResult<PayloadType> & types.ResolvedKey>;
@@ -1,30 +1,28 @@
1
- import type { JWK, KeyLike } from '../types';
1
+ import type * as types from '../types.d.ts';
2
2
  /**
3
- * Exports a runtime-specific public key representation ({@link !KeyObject} or {@link !CryptoKey}) to
4
- * a PEM-encoded SPKI string format.
3
+ * Exports a public {@link !CryptoKey} or {@link !KeyObject} to a PEM-encoded SPKI string format.
5
4
  *
6
5
  * This function is exported (as a named export) from the main `'jose'` module entry point as well
7
6
  * as from its subpath export `'jose/key/export'`.
8
7
  *
9
- * @param key Key representation to transform to a PEM-encoded SPKI string format.
8
+ * @param key Key to export to a PEM-encoded SPKI string format.
10
9
  */
11
- export declare function exportSPKI(key: KeyLike): Promise<string>;
10
+ export declare function exportSPKI(key: types.CryptoKey | types.KeyObject): Promise<string>;
12
11
  /**
13
- * Exports a runtime-specific private key representation ({@link !KeyObject} or {@link !CryptoKey}) to
14
- * a PEM-encoded PKCS8 string format.
12
+ * Exports a private {@link !CryptoKey} or {@link !KeyObject} to a PEM-encoded PKCS8 string format.
15
13
  *
16
14
  * This function is exported (as a named export) from the main `'jose'` module entry point as well
17
15
  * as from its subpath export `'jose/key/export'`.
18
16
  *
19
- * @param key Key representation to transform to a PEM-encoded PKCS8 string format.
17
+ * @param key Key to export to a PEM-encoded PKCS8 string format.
20
18
  */
21
- export declare function exportPKCS8(key: KeyLike): Promise<string>;
19
+ export declare function exportPKCS8(key: types.CryptoKey | types.KeyObject): Promise<string>;
22
20
  /**
23
- * Exports a runtime-specific key representation (KeyLike) to a JWK.
21
+ * Exports a {@link !CryptoKey}, {@link !KeyObject}, or {@link !Uint8Array} to a JWK.
24
22
  *
25
23
  * This function is exported (as a named export) from the main `'jose'` module entry point as well
26
24
  * as from its subpath export `'jose/key/export'`.
27
25
  *
28
- * @param key Key representation to export as JWK.
26
+ * @param key Key to export as JWK.
29
27
  */
30
- export declare function exportJWK(key: KeyLike | Uint8Array): Promise<JWK>;
28
+ export declare function exportJWK(key: types.CryptoKey | types.KeyObject | Uint8Array): Promise<types.JWK>;
@@ -1,9 +1,9 @@
1
- import type { KeyLike } from '../types';
2
- export interface GenerateKeyPairResult<KeyLikeType extends KeyLike = KeyLike> {
1
+ import type * as types from '../types.d.ts';
2
+ export interface GenerateKeyPairResult {
3
3
  /** The generated Private Key. */
4
- privateKey: KeyLikeType;
4
+ privateKey: types.CryptoKey;
5
5
  /** Public Key corresponding to the generated Private Key. */
6
- publicKey: KeyLikeType;
6
+ publicKey: types.CryptoKey;
7
7
  }
8
8
  export interface GenerateKeyPairOptions {
9
9
  /**
@@ -17,8 +17,7 @@ export interface GenerateKeyPairOptions {
17
17
  */
18
18
  modulusLength?: number;
19
19
  /**
20
- * (Only effective in Web Crypto API runtimes) The value to use as
21
- * {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false.
20
+ * The value to use as {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false.
22
21
  *
23
22
  */
24
23
  extractable?: boolean;
@@ -27,14 +26,14 @@ export interface GenerateKeyPairOptions {
27
26
  * Generates a private and a public key for a given JWA algorithm identifier. This can only generate
28
27
  * asymmetric key pairs. For symmetric secrets use the `generateSecret` function.
29
28
  *
30
- * Note: Under Web Crypto API runtime the `privateKey` is generated with `extractable` set to
31
- * `false` by default. See {@link GenerateKeyPairOptions.extractable} to generate an extractable
32
- * `privateKey`.
29
+ * Note: The `privateKey` is generated with `extractable` set to `false` by default. See
30
+ * {@link GenerateKeyPairOptions.extractable} to generate an extractable `privateKey`.
33
31
  *
34
32
  * This function is exported (as a named export) from the main `'jose'` module entry point as well
35
33
  * as from its subpath export `'jose/generate/keypair'`.
36
34
  *
37
- * @param alg JWA Algorithm Identifier to be used with the generated key pair.
35
+ * @param alg JWA Algorithm Identifier to be used with the generated key pair. See
36
+ * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
38
37
  * @param options Additional options passed down to the key pair generation.
39
38
  */
40
- export declare function generateKeyPair<KeyLikeType extends KeyLike = KeyLike>(alg: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult<KeyLikeType>>;
39
+ export declare function generateKeyPair(alg: string, options?: GenerateKeyPairOptions): Promise<GenerateKeyPairResult>;
@@ -1,21 +1,18 @@
1
- import type { KeyLike } from '../types';
1
+ import type * as types from '../types.d.ts';
2
2
  export interface GenerateSecretOptions {
3
- /**
4
- * (Only effective in Web Crypto API runtimes) The value to use as
5
- * {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false.
6
- */
3
+ /** The value to use as {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false. */
7
4
  extractable?: boolean;
8
5
  }
9
6
  /**
10
7
  * Generates a symmetric secret key for a given JWA algorithm identifier.
11
8
  *
12
- * Note: Under Web Crypto API runtime the secret key is generated with `extractable` set to `false`
13
- * by default.
9
+ * Note: The secret key is generated with `extractable` set to `false` by default.
14
10
  *
15
11
  * This function is exported (as a named export) from the main `'jose'` module entry point as well
16
12
  * as from its subpath export `'jose/generate/secret'`.
17
13
  *
18
- * @param alg JWA Algorithm Identifier to be used with the generated secret.
14
+ * @param alg JWA Algorithm Identifier to be used with the generated secret. See
15
+ * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
19
16
  * @param options Additional options passed down to the secret generation.
20
17
  */
21
- export declare function generateSecret<KeyLikeType extends KeyLike = KeyLike>(alg: string, options?: GenerateSecretOptions): Promise<KeyLikeType | Uint8Array>;
18
+ export declare function generateSecret(alg: string, options?: GenerateSecretOptions): Promise<types.CryptoKey | Uint8Array>;
@@ -1,14 +1,13 @@
1
- import type { JWK, KeyLike } from '../types';
2
- export interface PEMImportOptions {
1
+ import type * as types from '../types.d.ts';
2
+ export interface KeyImportOptions {
3
3
  /**
4
- * (Only effective in Web Crypto API runtimes) The value to use as {@link !SubtleCrypto.importKey}
5
- * `extractable` argument. Default is false.
4
+ * The value to use as {@link !SubtleCrypto.importKey} `extractable` argument. Default is false for
5
+ * private and secret keys, true otherwise.
6
6
  */
7
7
  extractable?: boolean;
8
8
  }
9
9
  /**
10
- * Imports a PEM-encoded SPKI string as a runtime-specific public key representation
11
- * ({@link !KeyObject} or {@link !CryptoKey}).
10
+ * Imports a PEM-encoded SPKI string as a {@link !CryptoKey}.
12
11
  *
13
12
  * Note: The OID id-RSASSA-PSS (1.2.840.113549.1.1.10) is not supported in
14
13
  * {@link https://w3c.github.io/webcrypto/ Web Cryptography API}, use the OID rsaEncryption
@@ -18,14 +17,12 @@ export interface PEMImportOptions {
18
17
  * as from its subpath export `'jose/key/import'`.
19
18
  *
20
19
  * @param spki PEM-encoded SPKI string
21
- * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
22
- * with the imported key, its presence is only enforced in Web Crypto API runtimes. See
20
+ * @param alg JSON Web Algorithm identifier to be used with the imported key. See
23
21
  * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
24
22
  */
25
- export declare function importSPKI<KeyLikeType extends KeyLike = KeyLike>(spki: string, alg: string, options?: PEMImportOptions): Promise<KeyLikeType>;
23
+ export declare function importSPKI(spki: string, alg: string, options?: KeyImportOptions): Promise<types.CryptoKey>;
26
24
  /**
27
- * Imports the SPKI from an X.509 string certificate as a runtime-specific public key representation
28
- * ({@link !KeyObject} or {@link !CryptoKey}).
25
+ * Imports the SPKI from an X.509 string certificate as a {@link !CryptoKey}.
29
26
  *
30
27
  * Note: The OID id-RSASSA-PSS (1.2.840.113549.1.1.10) is not supported in
31
28
  * {@link https://w3c.github.io/webcrypto/ Web Cryptography API}, use the OID rsaEncryption
@@ -35,14 +32,12 @@ export declare function importSPKI<KeyLikeType extends KeyLike = KeyLike>(spki:
35
32
  * as from its subpath export `'jose/key/import'`.
36
33
  *
37
34
  * @param x509 X.509 certificate string
38
- * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
39
- * with the imported key, its presence is only enforced in Web Crypto API runtimes. See
35
+ * @param alg JSON Web Algorithm identifier to be used with the imported key. See
40
36
  * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
41
37
  */
42
- export declare function importX509<KeyLikeType extends KeyLike = KeyLike>(x509: string, alg: string, options?: PEMImportOptions): Promise<KeyLikeType>;
38
+ export declare function importX509(x509: string, alg: string, options?: KeyImportOptions): Promise<types.CryptoKey>;
43
39
  /**
44
- * Imports a PEM-encoded PKCS#8 string as a runtime-specific private key representation
45
- * ({@link !KeyObject} or {@link !CryptoKey}).
40
+ * Imports a PEM-encoded PKCS#8 string as a {@link !CryptoKey}.
46
41
  *
47
42
  * Note: The OID id-RSASSA-PSS (1.2.840.113549.1.1.10) is not supported in
48
43
  * {@link https://w3c.github.io/webcrypto/ Web Cryptography API}, use the OID rsaEncryption
@@ -52,25 +47,23 @@ export declare function importX509<KeyLikeType extends KeyLike = KeyLike>(x509:
52
47
  * as from its subpath export `'jose/key/import'`.
53
48
  *
54
49
  * @param pkcs8 PEM-encoded PKCS#8 string
55
- * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
56
- * with the imported key, its presence is only enforced in Web Crypto API runtimes. See
50
+ * @param alg JSON Web Algorithm identifier to be used with the imported key. See
57
51
  * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
58
52
  */
59
- export declare function importPKCS8<KeyLikeType extends KeyLike = KeyLike>(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<KeyLikeType>;
53
+ export declare function importPKCS8(pkcs8: string, alg: string, options?: KeyImportOptions): Promise<types.CryptoKey>;
60
54
  /**
61
- * Imports a JWK to a runtime-specific key representation (KeyLike). Either the JWK "alg"
62
- * (Algorithm) Parameter, or the optional "alg" argument, must be present.
55
+ * Imports a JWK to a {@link !CryptoKey}. Either the JWK "alg" (Algorithm) Parameter, or the optional
56
+ * "alg" argument, must be present.
63
57
  *
64
- * Note: When the runtime is using {@link https://w3c.github.io/webcrypto/ Web Cryptography API} the
65
- * jwk parameters "use", "key_ops", and "ext" are also used in the resulting {@link !CryptoKey}.
58
+ * Note: The JSON Web Key parameters "use", "key_ops", and "ext" are also used in the
59
+ * {@link !CryptoKey} import process.
66
60
  *
67
61
  * This function is exported (as a named export) from the main `'jose'` module entry point as well
68
62
  * as from its subpath export `'jose/key/import'`.
69
63
  *
70
64
  * @param jwk JSON Web Key.
71
- * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
72
- * with the imported key. Default is the "alg" property on the JWK, its presence is only enforced
73
- * in Web Crypto API runtimes. See
65
+ * @param alg JSON Web Algorithm identifier to be used with the imported key. Default is the "alg"
66
+ * property on the JWK. See
74
67
  * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
75
68
  */
76
- export declare function importJWK<KeyLikeType extends KeyLike = KeyLike>(jwk: JWK, alg?: string): Promise<KeyLikeType | Uint8Array>;
69
+ export declare function importJWK(jwk: types.JWK, alg?: string, options?: KeyImportOptions): Promise<types.CryptoKey | Uint8Array>;
@@ -1,27 +1,3 @@
1
- /**
2
- * KeyLike are runtime-specific classes representing asymmetric keys or symmetric secrets. These are
3
- * instances of {@link !CryptoKey} and additionally {@link !KeyObject} in Node.js runtime.
4
- * {@link !Uint8Array} instances are also accepted as symmetric secret representation only.
5
- *
6
- * {@link key/import Key Import Functions} can be used to import PEM, or JWK formatted asymmetric
7
- * keys and certificates to these runtime-specific representations.
8
- *
9
- * In Node.js the {@link !Buffer} class is a subclass of {@link !Uint8Array} and so {@link !Buffer} can
10
- * be provided for symmetric secrets as well.
11
- *
12
- * {@link !KeyObject} is a representation of a key/secret available in the Node.js runtime. In
13
- * addition to the {@link key/import Key Import Functions} you may use the runtime APIs
14
- * {@link !createPublicKey}, {@link !createPrivateKey}, and {@link !createSecretKey} to obtain a
15
- * {@link !KeyObject} from your existing key material.
16
- *
17
- * {@link !CryptoKey} is a representation of a key/secret available in the Browser and
18
- * Web-interoperable runtimes. In addition to the {@link key/import Key Import Functions} you may use
19
- * the {@link !SubtleCrypto.importKey} API to obtain a {@link !CryptoKey} from your existing key
20
- * material.
21
- *
22
- */
23
- export type KeyLike = { type: string }
24
-
25
1
  /** Generic JSON Web Key Parameters. */
26
2
  export interface JWKParameters {
27
3
  /** JWK "kty" (Key Type) Parameter */
@@ -184,7 +160,11 @@ export interface GenericGetKeyFunction<IProtectedHeader, IToken, ReturnKeyTypes>
184
160
  * @param IToken Type definition of the consumed JWE or JWS token.
185
161
  */
186
162
  export interface GetKeyFunction<IProtectedHeader, IToken>
187
- extends GenericGetKeyFunction<IProtectedHeader, IToken, KeyLike | Uint8Array> {}
163
+ extends GenericGetKeyFunction<
164
+ IProtectedHeader,
165
+ IToken,
166
+ CryptoKey | KeyObject | JWK | Uint8Array
167
+ > {}
188
168
 
189
169
  /**
190
170
  * Flattened JWS definition for verify function inputs, allows payload as {@link !Uint8Array} for
@@ -324,7 +304,7 @@ export interface JWEKeyManagementHeaderParameters {
324
304
  * @deprecated You should not use this parameter. It is only really intended for test and vector
325
305
  * validation purposes.
326
306
  */
327
- epk?: KeyLike
307
+ epk?: CryptoKey | KeyObject
328
308
  }
329
309
 
330
310
  /** Flattened JWE definition. */
@@ -667,9 +647,9 @@ export interface JWTDecryptResult<PayloadType = JWTPayload> {
667
647
  protectedHeader: CompactJWEHeaderParameters
668
648
  }
669
649
 
670
- export interface ResolvedKey<KeyLikeType extends KeyLike = KeyLike> {
650
+ export interface ResolvedKey {
671
651
  /** Key resolved from the key resolver function. */
672
- key: KeyLikeType | Uint8Array
652
+ key: CryptoKey | Uint8Array
673
653
  }
674
654
 
675
655
  /** Recognized Compact JWS Header Parameters, any other Header Members may also be present. */
@@ -693,4 +673,22 @@ export interface JSONWebKeySet {
693
673
  keys: JWK[]
694
674
  }
695
675
 
696
- export type CryptoRuntime = 'WebCryptoAPI' | 'node:crypto'
676
+ /**
677
+ * {@link !KeyObject} is a representation of a key/secret available in the Node.js runtime. You may
678
+ * use the Node.js runtime APIs {@link !createPublicKey}, {@link !createPrivateKey}, and
679
+ * {@link !createSecretKey} to obtain a {@link !KeyObject} from your existing key material.
680
+ */
681
+ export interface KeyObject {
682
+ type: string
683
+ }
684
+
685
+ /**
686
+ * {@link !CryptoKey} is a representation of a key/secret available in all supported runtimes. In
687
+ * addition to the {@link key/import Key Import Functions} you may use the
688
+ * {@link !SubtleCrypto.importKey} API to obtain a {@link !CryptoKey} from your existing key
689
+ * material.
690
+ */
691
+ export type CryptoKey = Extract<
692
+ Awaited<ReturnType<typeof crypto.subtle.generateKey>>,
693
+ { type: string }
694
+ >
@@ -1,4 +1,4 @@
1
- import type { JWTPayload } from '../types';
1
+ import type * as types from '../types.d.ts';
2
2
  /**
3
3
  * Decodes a signed JSON Web Token payload. This does not validate the JWT Claims Set types or
4
4
  * values. This does not validate the JWS Signature. For a proper Signed JWT Claims Set validation
@@ -10,4 +10,4 @@ import type { JWTPayload } from '../types';
10
10
  *
11
11
  * @param jwt JWT token in compact JWS serialization.
12
12
  */
13
- export declare function decodeJwt<PayloadType = JWTPayload>(jwt: string): PayloadType & JWTPayload;
13
+ export declare function decodeJwt<PayloadType = types.JWTPayload>(jwt: string): PayloadType & types.JWTPayload;
@@ -1,5 +1,5 @@
1
- import type { JWSHeaderParameters, JWEHeaderParameters } from '../types';
2
- export type ProtectedHeaderParameters = JWSHeaderParameters & JWEHeaderParameters;
1
+ import type * as types from '../types.d.ts';
2
+ export type ProtectedHeaderParameters = types.JWSHeaderParameters & types.JWEHeaderParameters;
3
3
  /**
4
4
  * Decodes the Protected Header of a JWE/JWS/JWT token utilizing any JOSE serialization.
5
5
  *