toolcraft 0.0.119 → 0.0.121

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 (153) hide show
  1. package/composition.json +17 -2
  2. package/dist/composition.json +17 -2
  3. package/dist/http.compile-check.d.ts +1 -0
  4. package/dist/http.compile-check.js +31 -0
  5. package/dist/http.d.ts +19 -0
  6. package/dist/http.js +62 -0
  7. package/dist/mcp.js +26 -11
  8. package/node_modules/jose/LICENSE.md +21 -0
  9. package/node_modules/jose/README.md +153 -0
  10. package/node_modules/jose/dist/types/index.d.ts +55 -0
  11. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
  12. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
  13. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
  14. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
  15. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +38 -0
  16. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
  17. package/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
  18. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
  19. package/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
  20. package/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
  21. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
  22. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
  23. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
  24. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
  25. package/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
  26. package/node_modules/jose/dist/types/jws/general/verify.d.ts +41 -0
  27. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
  28. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
  29. package/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
  30. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
  31. package/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
  32. package/node_modules/jose/dist/types/key/export.d.ts +33 -0
  33. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
  34. package/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
  35. package/node_modules/jose/dist/types/key/import.d.ts +83 -0
  36. package/node_modules/jose/dist/types/types.d.ts +852 -0
  37. package/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
  38. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
  39. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
  40. package/node_modules/jose/dist/types/util/errors.d.ts +213 -0
  41. package/node_modules/jose/dist/webapi/index.js +32 -0
  42. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
  43. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
  44. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +159 -0
  45. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +167 -0
  46. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
  47. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +182 -0
  48. package/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
  49. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
  50. package/node_modules/jose/dist/webapi/jwks/local.js +119 -0
  51. package/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
  52. package/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
  53. package/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
  54. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +89 -0
  55. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +110 -0
  56. package/node_modules/jose/dist/webapi/jws/general/sign.js +70 -0
  57. package/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
  58. package/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
  59. package/node_modules/jose/dist/webapi/jwt/encrypt.js +101 -0
  60. package/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
  61. package/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
  62. package/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
  63. package/node_modules/jose/dist/webapi/key/export.js +11 -0
  64. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
  65. package/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
  66. package/node_modules/jose/dist/webapi/key/import.js +57 -0
  67. package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +15 -0
  68. package/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
  69. package/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
  70. package/node_modules/jose/dist/webapi/lib/base64.js +22 -0
  71. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
  72. package/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
  73. package/node_modules/jose/dist/webapi/lib/content_encryption.js +217 -0
  74. package/node_modules/jose/dist/webapi/lib/crypto_key.js +136 -0
  75. package/node_modules/jose/dist/webapi/lib/deflate.js +44 -0
  76. package/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
  77. package/node_modules/jose/dist/webapi/lib/helpers.js +19 -0
  78. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
  79. package/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
  80. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +107 -0
  81. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
  82. package/node_modules/jose/dist/webapi/lib/key_management.js +186 -0
  83. package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
  84. package/node_modules/jose/dist/webapi/lib/normalize_key.js +166 -0
  85. package/node_modules/jose/dist/webapi/lib/pbes2kw.js +42 -0
  86. package/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
  87. package/node_modules/jose/dist/webapi/lib/signing.js +68 -0
  88. package/node_modules/jose/dist/webapi/lib/type_checks.js +40 -0
  89. package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
  90. package/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
  91. package/node_modules/jose/dist/webapi/util/base64url.js +30 -0
  92. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
  93. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
  94. package/node_modules/jose/dist/webapi/util/errors.js +99 -0
  95. package/node_modules/jose/package.json +200 -0
  96. package/node_modules/tiny-http-mcp-server/LICENSE +21 -0
  97. package/node_modules/tiny-http-mcp-server/README.md +778 -0
  98. package/node_modules/tiny-http-mcp-server/dist/auth.d.ts +69 -0
  99. package/node_modules/tiny-http-mcp-server/dist/auth.js +261 -0
  100. package/node_modules/tiny-http-mcp-server/dist/cli.d.ts +20 -0
  101. package/node_modules/tiny-http-mcp-server/dist/cli.js +465 -0
  102. package/node_modules/tiny-http-mcp-server/dist/composition.json +30 -0
  103. package/node_modules/tiny-http-mcp-server/dist/express-middleware.d.ts +18 -0
  104. package/node_modules/tiny-http-mcp-server/dist/express-middleware.js +90 -0
  105. package/node_modules/tiny-http-mcp-server/dist/http-server.d.ts +49 -0
  106. package/node_modules/tiny-http-mcp-server/dist/http-server.js +264 -0
  107. package/node_modules/tiny-http-mcp-server/dist/http-transport.d.ts +164 -0
  108. package/node_modules/tiny-http-mcp-server/dist/http-transport.js +897 -0
  109. package/node_modules/tiny-http-mcp-server/dist/index.d.ts +13 -0
  110. package/node_modules/tiny-http-mcp-server/dist/index.js +6 -0
  111. package/node_modules/tiny-http-mcp-server/dist/load-oauth-verifier.d.ts +6 -0
  112. package/node_modules/tiny-http-mcp-server/dist/load-oauth-verifier.js +43 -0
  113. package/node_modules/tiny-http-mcp-server/dist/parse-body.d.ts +22 -0
  114. package/node_modules/tiny-http-mcp-server/dist/parse-body.js +150 -0
  115. package/node_modules/tiny-http-mcp-server/dist/server.d.ts +9 -0
  116. package/node_modules/tiny-http-mcp-server/dist/server.js +4 -0
  117. package/node_modules/tiny-http-mcp-server/dist/session.d.ts +18 -0
  118. package/node_modules/tiny-http-mcp-server/dist/session.js +37 -0
  119. package/node_modules/tiny-http-mcp-server/dist/sse.d.ts +11 -0
  120. package/node_modules/tiny-http-mcp-server/dist/sse.js +22 -0
  121. package/node_modules/tiny-http-mcp-server/dist/test-support.d.ts +10 -0
  122. package/node_modules/tiny-http-mcp-server/dist/test-support.js +398 -0
  123. package/node_modules/tiny-http-mcp-server/dist/testing.d.ts +59 -0
  124. package/node_modules/tiny-http-mcp-server/dist/testing.js +191 -0
  125. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/LICENSE +21 -0
  126. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +70 -0
  127. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +14 -0
  128. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +169 -0
  129. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.d.ts +8 -0
  130. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.js +47 -0
  131. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.d.ts +3 -0
  132. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +627 -0
  133. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +20 -0
  134. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/loopback-authorization.js +207 -0
  135. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.d.ts +2 -0
  136. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +7 -0
  137. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.d.ts +40 -0
  138. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.js +164 -0
  139. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/types.d.ts +113 -0
  140. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/types.js +1 -0
  141. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +10 -0
  142. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +7 -0
  143. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/resource-indicator.d.ts +1 -0
  144. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/resource-indicator.js +11 -0
  145. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/server/jwks-token-verifier.d.ts +32 -0
  146. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +388 -0
  147. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/types.compile-check.d.ts +1 -0
  148. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/types.compile-check.js +22 -0
  149. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/package.json +28 -0
  150. package/node_modules/tiny-http-mcp-server/package.json +59 -0
  151. package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
  152. package/node_modules/toolcraft-schema/package.json +1 -1
  153. package/package.json +11 -4
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Decrypting JSON Web Encryption (JWE) in Flattened JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * Interface for Flattened JWE Decryption dynamic key resolution. No token components have been
9
+ * verified at the time of this function call.
10
+ */
11
+ export interface FlattenedDecryptGetKey extends types.GetKeyFunction<types.JWEHeaderParameters | undefined, types.FlattenedJWE> {
12
+ }
13
+ /**
14
+ * Decrypts a Flattened JWE.
15
+ *
16
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
17
+ * as from its subpath export `'jose/jwe/flattened/decrypt'`.
18
+ *
19
+ * @param jwe Flattened JWE.
20
+ * @param key Private Key or Secret to decrypt the JWE with. See
21
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
22
+ * @param options JWE Decryption options.
23
+ */
24
+ export declare function flattenedDecrypt(jwe: types.FlattenedJWE, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.DecryptOptions): Promise<types.FlattenedDecryptResult>;
25
+ /**
26
+ * @param jwe Flattened JWE.
27
+ * @param getKey Function resolving Private Key or Secret to decrypt the JWE with. See
28
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
29
+ * @param options JWE Decryption options.
30
+ */
31
+ export declare function flattenedDecrypt(jwe: types.FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: types.DecryptOptions): Promise<types.FlattenedDecryptResult & types.ResolvedKey>;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Encrypting JSON Web Encryption (JWE) in Flattened JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * The FlattenedEncrypt class is used to build and encrypt Flattened JWE objects.
9
+ *
10
+ * This class is exported (as a named export) from the main `'jose'` module entry point as well as
11
+ * from its subpath export `'jose/jwe/flattened/encrypt'`.
12
+ *
13
+ */
14
+ export declare class FlattenedEncrypt {
15
+ #private;
16
+ /**
17
+ * {@link FlattenedEncrypt} constructor
18
+ *
19
+ * @param plaintext Binary representation of the plaintext to encrypt.
20
+ */
21
+ constructor(plaintext: Uint8Array);
22
+ /**
23
+ * Sets the JWE Key Management parameters to be used when encrypting.
24
+ *
25
+ * (ECDH-ES) Use of this method is needed for ECDH based algorithms to set the "apu" (Agreement
26
+ * PartyUInfo) or "apv" (Agreement PartyVInfo) parameters.
27
+ *
28
+ * @param parameters JWE Key Management parameters.
29
+ */
30
+ setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): this;
31
+ /**
32
+ * Sets the JWE Protected Header on the FlattenedEncrypt object.
33
+ *
34
+ * @param protectedHeader JWE Protected Header.
35
+ */
36
+ setProtectedHeader(protectedHeader: types.JWEHeaderParameters): this;
37
+ /**
38
+ * Sets the JWE Shared Unprotected Header on the FlattenedEncrypt object.
39
+ *
40
+ * @param sharedUnprotectedHeader JWE Shared Unprotected Header.
41
+ */
42
+ setSharedUnprotectedHeader(sharedUnprotectedHeader: types.JWEHeaderParameters): this;
43
+ /**
44
+ * Sets the JWE Per-Recipient Unprotected Header on the FlattenedEncrypt object.
45
+ *
46
+ * @param unprotectedHeader JWE Per-Recipient Unprotected Header.
47
+ */
48
+ setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): this;
49
+ /**
50
+ * Sets the Additional Authenticated Data on the FlattenedEncrypt object.
51
+ *
52
+ * @param aad Additional Authenticated Data.
53
+ */
54
+ setAdditionalAuthenticatedData(aad: Uint8Array): this;
55
+ /**
56
+ * Sets a content encryption key to use, by default a random suitable one is generated for the JWE
57
+ * enc" (Encryption Algorithm) Header Parameter.
58
+ *
59
+ * @deprecated You should not use this method. It is only really intended for test and vector
60
+ * validation purposes.
61
+ *
62
+ * @param cek JWE Content Encryption Key.
63
+ */
64
+ setContentEncryptionKey(cek: Uint8Array): this;
65
+ /**
66
+ * Sets the JWE Initialization Vector to use for content encryption, by default a random suitable
67
+ * one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
68
+ *
69
+ * @deprecated You should not use this method. It is only really intended for test and vector
70
+ * validation purposes.
71
+ *
72
+ * @param iv JWE Initialization Vector.
73
+ */
74
+ setInitializationVector(iv: Uint8Array): this;
75
+ /**
76
+ * Encrypts and resolves the value of the Flattened JWE object.
77
+ *
78
+ * @param key Public Key or Secret to encrypt the JWE with. See
79
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
80
+ * @param options JWE Encryption options.
81
+ */
82
+ encrypt(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.EncryptOptions): Promise<types.FlattenedJWE>;
83
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Decrypting JSON Web Encryption (JWE) in General JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * Interface for General JWE Decryption dynamic key resolution. No token components have been
9
+ * verified at the time of this function call.
10
+ */
11
+ export interface GeneralDecryptGetKey extends types.GetKeyFunction<types.JWEHeaderParameters, types.FlattenedJWE> {
12
+ }
13
+ /**
14
+ * Decrypts a General JWE.
15
+ *
16
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
17
+ * as from its subpath export `'jose/jwe/general/decrypt'`.
18
+ *
19
+ * > [!NOTE]\
20
+ * > The function iterates over the `recipients` array in the General JWE and returns the decryption
21
+ * > result of the first recipient entry that can be successfully decrypted. The result only contains
22
+ * > the plaintext and headers of that successfully decrypted recipient entry. Other recipient entries
23
+ * > in the General JWE are not validated, and their headers are not included in the returned result.
24
+ * > Recipients of a General JWE should only rely on the returned (decrypted) data.
25
+ *
26
+ * @param jwe General JWE.
27
+ * @param key Private Key or Secret to decrypt the JWE with. See
28
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
29
+ * @param options JWE Decryption options.
30
+ */
31
+ export declare function generalDecrypt(jwe: types.GeneralJWE, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.DecryptOptions): Promise<types.GeneralDecryptResult>;
32
+ /**
33
+ * @param jwe General JWE.
34
+ * @param getKey Function resolving Private Key or Secret to decrypt the JWE with. See
35
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
36
+ * @param options JWE Decryption options.
37
+ */
38
+ export declare function generalDecrypt(jwe: types.GeneralJWE, getKey: GeneralDecryptGetKey, options?: types.DecryptOptions): Promise<types.GeneralDecryptResult & types.ResolvedKey>;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Encrypting JSON Web Encryption (JWE) in General JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /** Used to build General JWE object's individual recipients. */
8
+ export interface Recipient {
9
+ /**
10
+ * Sets the JWE Per-Recipient Unprotected Header on the Recipient object.
11
+ *
12
+ * @param unprotectedHeader JWE Per-Recipient Unprotected Header.
13
+ */
14
+ setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
15
+ /**
16
+ * Sets the JWE Key Management parameters to be used when encrypting.
17
+ *
18
+ * (ECDH-ES) Use of this method is needed for ECDH based algorithms to set the "apu" (Agreement
19
+ * PartyUInfo) or "apv" (Agreement PartyVInfo) parameters.
20
+ *
21
+ * @param parameters JWE Key Management parameters.
22
+ */
23
+ setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): Recipient;
24
+ /** A shorthand for calling addRecipient() on the enclosing {@link GeneralEncrypt} instance */
25
+ addRecipient(...args: Parameters<GeneralEncrypt['addRecipient']>): Recipient;
26
+ /** A shorthand for calling encrypt() on the enclosing {@link GeneralEncrypt} instance */
27
+ encrypt(...args: Parameters<GeneralEncrypt['encrypt']>): Promise<types.GeneralJWE>;
28
+ /** Returns the enclosing {@link GeneralEncrypt} instance */
29
+ done(): GeneralEncrypt;
30
+ }
31
+ /**
32
+ * The GeneralEncrypt class is used to build and encrypt General JWE objects.
33
+ *
34
+ * This class is exported (as a named export) from the main `'jose'` module entry point as well as
35
+ * from its subpath export `'jose/jwe/general/encrypt'`.
36
+ *
37
+ */
38
+ export declare class GeneralEncrypt {
39
+ #private;
40
+ /**
41
+ * {@link GeneralEncrypt} constructor
42
+ *
43
+ * @param plaintext Binary representation of the plaintext to encrypt.
44
+ */
45
+ constructor(plaintext: Uint8Array);
46
+ /**
47
+ * Adds an additional recipient for the General JWE object.
48
+ *
49
+ * @param key Public Key or Secret to encrypt the Content Encryption Key for the recipient with.
50
+ * See {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
51
+ * @param options JWE Encryption options.
52
+ */
53
+ addRecipient(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.CritOption): Recipient;
54
+ /**
55
+ * Sets the JWE Protected Header on the GeneralEncrypt object.
56
+ *
57
+ * @param protectedHeader JWE Protected Header object.
58
+ */
59
+ setProtectedHeader(protectedHeader: types.JWEHeaderParameters): this;
60
+ /**
61
+ * Sets the JWE Shared Unprotected Header on the GeneralEncrypt object.
62
+ *
63
+ * @param sharedUnprotectedHeader JWE Shared Unprotected Header object.
64
+ */
65
+ setSharedUnprotectedHeader(sharedUnprotectedHeader: types.JWEHeaderParameters): this;
66
+ /**
67
+ * Sets the Additional Authenticated Data on the GeneralEncrypt object.
68
+ *
69
+ * @param aad Additional Authenticated Data.
70
+ */
71
+ setAdditionalAuthenticatedData(aad: Uint8Array): this;
72
+ /** Encrypts and resolves the value of the General JWE object. */
73
+ encrypt(): Promise<types.GeneralJWE>;
74
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Verification using a JWK Embedded in a JWS Header
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../types.d.ts';
7
+ /**
8
+ * EmbeddedJWK is an implementation of a GetKeyFunction intended to be used with the JWS/JWT verify
9
+ * operations whenever you need to opt-in to verify signatures with a public key embedded in the
10
+ * token's "jwk" (JSON Web Key) Header Parameter. It is recommended to combine this with the verify
11
+ * function's `algorithms` option to define accepted JWS "alg" (Algorithm) Header Parameter values.
12
+ *
13
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
14
+ * as from its subpath export `'jose/jwk/embedded'`.
15
+ *
16
+ */
17
+ export declare function EmbeddedJWK(protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * JSON Web Key Thumbprint and JSON Web Key Thumbprint URI
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../types.d.ts';
7
+ /**
8
+ * Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint
9
+ *
10
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
11
+ * as from its subpath export `'jose/jwk/thumbprint'`.
12
+ *
13
+ * @param key Key to calculate the thumbprint for.
14
+ * @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
15
+ * "sha256".
16
+ *
17
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7638 RFC7638}
18
+ */
19
+ export declare function calculateJwkThumbprint(key: types.JWK | types.CryptoKey | types.KeyObject, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
20
+ /**
21
+ * Calculates a JSON Web Key (JWK) Thumbprint URI
22
+ *
23
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
24
+ * as from its subpath export `'jose/jwk/thumbprint'`.
25
+ *
26
+ * @param key Key to calculate the thumbprint for.
27
+ * @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
28
+ * "sha256".
29
+ *
30
+ * @see {@link https://www.rfc-editor.org/rfc/rfc9278 RFC9278}
31
+ */
32
+ export declare function calculateJwkThumbprintUri(key: types.CryptoKey | types.KeyObject | types.JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Verification using a JSON Web Key Set (JWKS) available locally
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../types.d.ts';
7
+ /**
8
+ * Returns a function that resolves a JWS JOSE Header to a public key object from a locally stored,
9
+ * or otherwise available, JSON Web Key Set.
10
+ *
11
+ * It uses the "alg" (JWS Algorithm) Header Parameter to determine the right JWK "kty" (Key Type),
12
+ * then proceeds to match the JWK "kid" (Key ID) with one found in the JWS Header Parameters (if
13
+ * there is one) while also respecting the JWK "use" (Public Key Use) and JWK "key_ops" (Key
14
+ * Operations) Parameters (if they are present on the JWK).
15
+ *
16
+ * Only a single public key must match the selection process. As shown in the example below when
17
+ * multiple keys get matched it is possible to opt-in to iterate over the matched keys and attempt
18
+ * verification in an iterative manner.
19
+ *
20
+ * > [!NOTE]\
21
+ * > The function's purpose is to resolve public keys used for verifying signatures and will not work
22
+ * > for public encryption keys.
23
+ *
24
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
25
+ * as from its subpath export `'jose/jwks/local'`.
26
+ *
27
+ * @param jwks JSON Web Key Set formatted object.
28
+ */
29
+ export declare function createLocalJWKSet(jwks: types.JSONWebKeySet): (protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput) => Promise<types.CryptoKey>;
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Verification using a JSON Web Key Set (JWKS) available on an HTTP(S) URL
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../types.d.ts';
7
+ /**
8
+ * When passed to {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} this allows the resolver
9
+ * to make use of advanced fetch configurations, HTTP Proxies, retry on network errors, etc.
10
+ *
11
+ * > [!NOTE]\
12
+ * > Known caveat: Expect Type-related issues when passing the inputs through to fetch-like modules,
13
+ * > they hardly ever get their typings inline with actual fetch, you should `@ts-expect-error` them.
14
+ *
15
+ * import ky from 'ky'
16
+ *
17
+ * let logRequest!: (request: Request) => void
18
+ * let logResponse!: (request: Request, response: Response) => void
19
+ * let logRetry!: (request: Request, error: Error, retryCount: number) => void
20
+ *
21
+ * const JWKS = jose.createRemoteJWKSet(url, {
22
+ * [jose.customFetch]: (...args) =>
23
+ * ky(args[0], {
24
+ * ...args[1],
25
+ * hooks: {
26
+ * beforeRequest: [
27
+ * (request) => {
28
+ * logRequest(request)
29
+ * },
30
+ * ],
31
+ * beforeRetry: [
32
+ * ({ request, error, retryCount }) => {
33
+ * logRetry(request, error, retryCount)
34
+ * },
35
+ * ],
36
+ * afterResponse: [
37
+ * (request, _, response) => {
38
+ * logResponse(request, response)
39
+ * },
40
+ * ],
41
+ * },
42
+ * }),
43
+ * })
44
+ * ```
45
+ *
46
+ * import * as undici from 'undici'
47
+ *
48
+ * // see https://undici.nodejs.org/#/docs/api/EnvHttpProxyAgent
49
+ * let envHttpProxyAgent = new undici.EnvHttpProxyAgent()
50
+ *
51
+ * // @ts-ignore
52
+ * const JWKS = jose.createRemoteJWKSet(url, {
53
+ * [jose.customFetch]: (...args) => {
54
+ * // @ts-ignore
55
+ * return undici.fetch(args[0], { ...args[1], dispatcher: envHttpProxyAgent }) // prettier-ignore
56
+ * },
57
+ * })
58
+ * ```
59
+ *
60
+ * import * as undici from 'undici'
61
+ *
62
+ * // see https://undici.nodejs.org/#/docs/api/RetryAgent
63
+ * let retryAgent = new undici.RetryAgent(new undici.Agent(), {
64
+ * statusCodes: [],
65
+ * errorCodes: [
66
+ * 'ECONNRESET',
67
+ * 'ECONNREFUSED',
68
+ * 'ENOTFOUND',
69
+ * 'ENETDOWN',
70
+ * 'ENETUNREACH',
71
+ * 'EHOSTDOWN',
72
+ * 'UND_ERR_SOCKET',
73
+ * ],
74
+ * })
75
+ *
76
+ * // @ts-ignore
77
+ * const JWKS = jose.createRemoteJWKSet(url, {
78
+ * [jose.customFetch]: (...args) => {
79
+ * // @ts-ignore
80
+ * return undici.fetch(args[0], { ...args[1], dispatcher: retryAgent }) // prettier-ignore
81
+ * },
82
+ * })
83
+ * ```
84
+ *
85
+ * import * as undici from 'undici'
86
+ *
87
+ * // see https://undici.nodejs.org/#/docs/api/MockAgent
88
+ * let mockAgent = new undici.MockAgent()
89
+ * mockAgent.disableNetConnect()
90
+ *
91
+ * // @ts-ignore
92
+ * const JWKS = jose.createRemoteJWKSet(url, {
93
+ * [jose.customFetch]: (...args) => {
94
+ * // @ts-ignore
95
+ * return undici.fetch(args[0], { ...args[1], dispatcher: mockAgent }) // prettier-ignore
96
+ * },
97
+ * })
98
+ * ```
99
+ */
100
+ export declare const customFetch: unique symbol;
101
+ /** See {@link customFetch}. */
102
+ export type FetchImplementation = (
103
+ /** URL the request is being made sent to {@link !fetch} as the `resource` argument */
104
+ url: string,
105
+ /** Options otherwise sent to {@link !fetch} as the `options` argument */
106
+ options: {
107
+ /** HTTP Headers */
108
+ headers: Headers;
109
+ /** The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods request method} */
110
+ method: 'GET';
111
+ /** See {@link !Request.redirect} */
112
+ redirect: 'manual';
113
+ signal: AbortSignal;
114
+ }) => Promise<Response>;
115
+ /**
116
+ * > [!WARNING]\
117
+ * > This option has security implications that must be understood, assessed for applicability, and
118
+ * > accepted before use. It is critical that the JSON Web Key Set cache only be writable by your own
119
+ * > code.
120
+ *
121
+ * This option is intended for cloud computing runtimes that cannot keep an in memory cache between
122
+ * their code's invocations. Use in runtimes where an in memory cache between requests is available
123
+ * is not desirable.
124
+ *
125
+ * When passed to {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} this allows the passed in
126
+ * object to:
127
+ *
128
+ * - Serve as an initial value for the JSON Web Key Set that the module would otherwise need to
129
+ * trigger an HTTP request for
130
+ * - Have the JSON Web Key Set the function optionally ended up triggering an HTTP request for
131
+ * assigned to it as properties
132
+ *
133
+ * The intended use pattern is:
134
+ *
135
+ * - Before verifying with {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} you pull the
136
+ * previously cached object from a low-latency key-value store offered by the cloud computing
137
+ * runtime it is executed on;
138
+ * - Default to an empty object `{}` instead when there's no previously cached value;
139
+ * - Pass it in as {@link RemoteJWKSetOptions[jwksCache]};
140
+ * - Afterwards, update the key-value storage if the {@link ExportedJWKSCache.uat `uat`} property of
141
+ * the object has changed.
142
+ *
143
+ * // Prerequisites
144
+ * let url!: URL
145
+ * let jwt!: string
146
+ * let getPreviouslyCachedJWKS!: () => Promise<jose.ExportedJWKSCache>
147
+ * let storeNewJWKScache!: (cache: jose.ExportedJWKSCache) => Promise<void>
148
+ *
149
+ * // Load JSON Web Key Set cache
150
+ * const jwksCache: jose.JWKSCacheInput = (await getPreviouslyCachedJWKS()) || {}
151
+ * const { uat } = jwksCache
152
+ *
153
+ * const JWKS = jose.createRemoteJWKSet(url, {
154
+ * [jose.jwksCache]: jwksCache,
155
+ * })
156
+ *
157
+ * // Use JSON Web Key Set cache
158
+ * await jose.jwtVerify(jwt, JWKS)
159
+ *
160
+ * if (uat !== jwksCache.uat) {
161
+ * // Update JSON Web Key Set cache
162
+ * await storeNewJWKScache(jwksCache)
163
+ * }
164
+ * ```
165
+ */
166
+ export declare const jwksCache: unique symbol;
167
+ /** Options for the remote JSON Web Key Set. */
168
+ export interface RemoteJWKSetOptions {
169
+ /**
170
+ * Timeout (in milliseconds) for the HTTP request. When reached the request will be aborted and
171
+ * the verification will fail. Default is 5000 (5 seconds).
172
+ */
173
+ timeoutDuration?: number;
174
+ /**
175
+ * Duration (in milliseconds) for which no more HTTP requests will be triggered after a previous
176
+ * successful fetch. Default is 30000 (30 seconds).
177
+ */
178
+ cooldownDuration?: number;
179
+ /**
180
+ * Maximum time (in milliseconds) between successful HTTP requests. Default is 600000 (10
181
+ * minutes).
182
+ */
183
+ cacheMaxAge?: number | typeof Infinity;
184
+ /** Headers to be sent with the HTTP request. */
185
+ headers?: Record<string, string>;
186
+ /** See {@link jwksCache}. */
187
+ [jwksCache]?: JWKSCacheInput;
188
+ /** See {@link customFetch}. */
189
+ [customFetch]?: FetchImplementation;
190
+ }
191
+ /** See {@link jwksCache}. */
192
+ export interface ExportedJWKSCache {
193
+ /** Current cached JSON Web Key Set */
194
+ jwks: types.JSONWebKeySet;
195
+ /** Last updated at timestamp (seconds since epoch) */
196
+ uat: number;
197
+ }
198
+ /** See {@link jwksCache}. */
199
+ export type JWKSCacheInput = ExportedJWKSCache | Record<string, never>;
200
+ /**
201
+ * Returns a function that resolves a JWS JOSE Header to a public key object downloaded from a
202
+ * remote endpoint returning a JSON Web Key Set, that is, for example, an OAuth 2.0 or OIDC
203
+ * jwks_uri. The JSON Web Key Set is fetched when no key matches the selection process but only as
204
+ * frequently as the `cooldownDuration` option allows to prevent abuse.
205
+ *
206
+ * It uses the "alg" (JWS Algorithm) Header Parameter to determine the right JWK "kty" (Key Type),
207
+ * then proceeds to match the JWK "kid" (Key ID) with one found in the JWS Header Parameters (if
208
+ * there is one) while also respecting the JWK "use" (Public Key Use) and JWK "key_ops" (Key
209
+ * Operations) Parameters (if they are present on the JWK).
210
+ *
211
+ * Only a single public key must match the selection process. As shown in the example below when
212
+ * multiple keys get matched it is possible to opt-in to iterate over the matched keys and attempt
213
+ * verification in an iterative manner.
214
+ *
215
+ * > [!NOTE]\
216
+ * > The function's purpose is to resolve public keys used for verifying signatures and will not work
217
+ * > for public encryption keys.
218
+ *
219
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
220
+ * as from its subpath export `'jose/jwks/remote'`.
221
+ *
222
+ * @param url URL to fetch the JSON Web Key Set from.
223
+ * @param options Options for the remote JSON Web Key Set.
224
+ */
225
+ export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): {
226
+ (protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
227
+ /** @ignore */
228
+ coolingDown: boolean;
229
+ /** @ignore */
230
+ fresh: boolean;
231
+ /** @ignore */
232
+ reloading: boolean;
233
+ /** @ignore */
234
+ reload: () => Promise<void>;
235
+ /** @ignore */
236
+ jwks: () => types.JSONWebKeySet | undefined;
237
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Signing JSON Web Signature (JWS) in Compact Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * The CompactSign class is used to build and sign Compact JWS strings.
9
+ *
10
+ * This class is exported (as a named export) from the main `'jose'` module entry point as well as
11
+ * from its subpath export `'jose/jws/compact/sign'`.
12
+ *
13
+ */
14
+ export declare class CompactSign {
15
+ #private;
16
+ /**
17
+ * {@link CompactSign} constructor
18
+ *
19
+ * @param payload Binary representation of the payload to sign.
20
+ */
21
+ constructor(payload: Uint8Array);
22
+ /**
23
+ * Sets the JWS Protected Header on the CompactSign object.
24
+ *
25
+ * @param protectedHeader JWS Protected Header.
26
+ */
27
+ setProtectedHeader(protectedHeader: types.CompactJWSHeaderParameters): this;
28
+ /**
29
+ * Signs and resolves the value of the Compact JWS string.
30
+ *
31
+ * @param key Private Key or Secret to sign the JWS with. See
32
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
33
+ * @param options JWS Sign options.
34
+ */
35
+ sign(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Promise<string>;
36
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Verifying JSON Web Signature (JWS) in Compact Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * Interface for Compact JWS Verification dynamic key resolution. No token components have been
9
+ * verified at the time of this function call.
10
+ *
11
+ * @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
12
+ */
13
+ export interface CompactVerifyGetKey extends types.GenericGetKeyFunction<types.CompactJWSHeaderParameters, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
14
+ }
15
+ /**
16
+ * Verifies the signature and format of and afterwards decodes the Compact JWS.
17
+ *
18
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
19
+ * as from its subpath export `'jose/jws/compact/verify'`.
20
+ *
21
+ * @param jws Compact JWS.
22
+ * @param key Key to verify the JWS with. See
23
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
24
+ * @param options JWS Verify options.
25
+ */
26
+ export declare function compactVerify(jws: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.CompactVerifyResult>;
27
+ /**
28
+ * @param jws Compact JWS.
29
+ * @param getKey Function resolving a key to verify the JWS with. See
30
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
31
+ * @param options JWS Verify options.
32
+ */
33
+ export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: types.VerifyOptions): Promise<types.CompactVerifyResult & types.ResolvedKey>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Signing JSON Web Signature (JWS) in Flattened JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * The FlattenedSign class is used to build and sign Flattened JWS objects.
9
+ *
10
+ * This class is exported (as a named export) from the main `'jose'` module entry point as well as
11
+ * from its subpath export `'jose/jws/flattened/sign'`.
12
+ *
13
+ */
14
+ export declare class FlattenedSign {
15
+ #private;
16
+ /**
17
+ * {@link FlattenedSign} constructor
18
+ *
19
+ * @param payload Binary representation of the payload to sign.
20
+ */
21
+ constructor(payload: Uint8Array);
22
+ /**
23
+ * Sets the JWS Protected Header on the FlattenedSign object.
24
+ *
25
+ * @param protectedHeader JWS Protected Header.
26
+ */
27
+ setProtectedHeader(protectedHeader: types.JWSHeaderParameters): this;
28
+ /**
29
+ * Sets the JWS Unprotected Header on the FlattenedSign object.
30
+ *
31
+ * @param unprotectedHeader JWS Unprotected Header.
32
+ */
33
+ setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): this;
34
+ /**
35
+ * Signs and resolves the value of the Flattened JWS object.
36
+ *
37
+ * @param key Private Key or Secret to sign the JWS with. See
38
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
39
+ * @param options JWS Sign options.
40
+ */
41
+ sign(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Promise<types.FlattenedJWS>;
42
+ }