tiny-http-mcp-server 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/composition.json +6 -1
  2. package/dist/express-middleware.d.ts +1 -1
  3. package/dist/express-middleware.js +9 -10
  4. package/dist/http-server.d.ts +1 -0
  5. package/dist/http-server.js +1 -0
  6. package/dist/server.d.ts +9 -0
  7. package/dist/server.js +4 -0
  8. package/node_modules/auth-store/package.json +0 -2
  9. package/node_modules/jose/LICENSE.md +21 -0
  10. package/node_modules/jose/README.md +153 -0
  11. package/node_modules/jose/dist/types/index.d.ts +55 -0
  12. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
  13. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
  14. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
  15. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
  16. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +38 -0
  17. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
  18. package/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
  19. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
  20. package/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
  21. package/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
  22. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
  23. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
  24. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
  25. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
  26. package/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
  27. package/node_modules/jose/dist/types/jws/general/verify.d.ts +41 -0
  28. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
  29. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
  30. package/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
  31. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
  32. package/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
  33. package/node_modules/jose/dist/types/key/export.d.ts +33 -0
  34. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
  35. package/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
  36. package/node_modules/jose/dist/types/key/import.d.ts +83 -0
  37. package/node_modules/jose/dist/types/types.d.ts +852 -0
  38. package/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
  39. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
  40. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
  41. package/node_modules/jose/dist/types/util/errors.d.ts +213 -0
  42. package/node_modules/jose/dist/webapi/index.js +32 -0
  43. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
  44. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
  45. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +159 -0
  46. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +167 -0
  47. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
  48. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +182 -0
  49. package/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
  50. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
  51. package/node_modules/jose/dist/webapi/jwks/local.js +119 -0
  52. package/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
  53. package/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
  54. package/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
  55. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +89 -0
  56. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +110 -0
  57. package/node_modules/jose/dist/webapi/jws/general/sign.js +70 -0
  58. package/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
  59. package/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
  60. package/node_modules/jose/dist/webapi/jwt/encrypt.js +101 -0
  61. package/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
  62. package/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
  63. package/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
  64. package/node_modules/jose/dist/webapi/key/export.js +11 -0
  65. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
  66. package/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
  67. package/node_modules/jose/dist/webapi/key/import.js +57 -0
  68. package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +15 -0
  69. package/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
  70. package/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
  71. package/node_modules/jose/dist/webapi/lib/base64.js +22 -0
  72. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
  73. package/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
  74. package/node_modules/jose/dist/webapi/lib/content_encryption.js +217 -0
  75. package/node_modules/jose/dist/webapi/lib/crypto_key.js +136 -0
  76. package/node_modules/jose/dist/webapi/lib/deflate.js +44 -0
  77. package/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
  78. package/node_modules/jose/dist/webapi/lib/helpers.js +19 -0
  79. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
  80. package/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
  81. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +107 -0
  82. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
  83. package/node_modules/jose/dist/webapi/lib/key_management.js +186 -0
  84. package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
  85. package/node_modules/jose/dist/webapi/lib/normalize_key.js +166 -0
  86. package/node_modules/jose/dist/webapi/lib/pbes2kw.js +42 -0
  87. package/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
  88. package/node_modules/jose/dist/webapi/lib/signing.js +68 -0
  89. package/node_modules/jose/dist/webapi/lib/type_checks.js +40 -0
  90. package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
  91. package/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
  92. package/node_modules/jose/dist/webapi/util/base64url.js +30 -0
  93. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
  94. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
  95. package/node_modules/jose/dist/webapi/util/errors.js +99 -0
  96. package/node_modules/jose/package.json +200 -0
  97. package/node_modules/mcp-oauth/package.json +0 -5
  98. package/node_modules/tiny-mcp-client/package.json +0 -2
  99. package/package.json +11 -6
@@ -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
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Verifying JSON Web Signature (JWS) in Flattened JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * Interface for Flattened 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 FlattenedVerifyGetKey extends types.GenericGetKeyFunction<types.JWSHeaderParameters | undefined, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
14
+ }
15
+ /**
16
+ * Verifies the signature and format of and afterwards decodes the Flattened 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/flattened/verify'`.
20
+ *
21
+ * @param jws Flattened 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 flattenedVerify(jws: types.FlattenedJWSInput, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult>;
27
+ /**
28
+ * @param jws Flattened 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 flattenedVerify(jws: types.FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult & types.ResolvedKey>;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Signing JSON Web Signature (JWS) in General JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /** Used to build General JWS object's individual signatures. */
8
+ export interface Signature {
9
+ /**
10
+ * Sets the JWS Protected Header on the Signature object.
11
+ *
12
+ * @param protectedHeader JWS Protected Header.
13
+ */
14
+ setProtectedHeader(protectedHeader: types.JWSHeaderParameters): Signature;
15
+ /**
16
+ * Sets the JWS Unprotected Header on the Signature object.
17
+ *
18
+ * @param unprotectedHeader JWS Unprotected Header.
19
+ */
20
+ setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): Signature;
21
+ /** A shorthand for calling addSignature() on the enclosing {@link GeneralSign} instance */
22
+ addSignature(...args: Parameters<GeneralSign['addSignature']>): Signature;
23
+ /** A shorthand for calling encrypt() on the enclosing {@link GeneralSign} instance */
24
+ sign(...args: Parameters<GeneralSign['sign']>): Promise<types.GeneralJWS>;
25
+ /** Returns the enclosing {@link GeneralSign} instance */
26
+ done(): GeneralSign;
27
+ }
28
+ /**
29
+ * The GeneralSign class is used to build and sign General JWS objects.
30
+ *
31
+ * This class is exported (as a named export) from the main `'jose'` module entry point as well as
32
+ * from its subpath export `'jose/jws/general/sign'`.
33
+ *
34
+ */
35
+ export declare class GeneralSign {
36
+ #private;
37
+ /**
38
+ * {@link GeneralSign} constructor
39
+ *
40
+ * @param payload Binary representation of the payload to sign.
41
+ */
42
+ constructor(payload: Uint8Array);
43
+ /**
44
+ * Adds an additional signature for the General JWS object.
45
+ *
46
+ * @param key Private Key or Secret to sign the individual JWS signature with. See
47
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
48
+ * @param options JWS Sign options.
49
+ */
50
+ addSignature(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Signature;
51
+ /** Signs and resolves the value of the General JWS object. */
52
+ sign(): Promise<types.GeneralJWS>;
53
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Verifying JSON Web Signature (JWS) in General JSON Serialization
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../../types.d.ts';
7
+ /**
8
+ * Interface for General 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 GeneralVerifyGetKey extends types.GenericGetKeyFunction<types.JWSHeaderParameters, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
14
+ }
15
+ /**
16
+ * Verifies the signature and format of and afterwards decodes the General 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/general/verify'`.
20
+ *
21
+ * > [!NOTE]\
22
+ * > The function iterates over the `signatures` array in the General JWS and returns the verification
23
+ * > result of the first signature entry that can be successfully verified. The result only contains
24
+ * > the payload, protected header, and unprotected header of that successfully verified signature
25
+ * > entry. Other signature entries in the General JWS are not validated, and their headers are not
26
+ * > included in the returned result. Recipients of a General JWS should only rely on the returned
27
+ * > (verified) data.
28
+ *
29
+ * @param jws General JWS.
30
+ * @param key Key to verify the JWS with. See
31
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
32
+ * @param options JWS Verify options.
33
+ */
34
+ export declare function generalVerify(jws: types.GeneralJWSInput, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.GeneralVerifyResult>;
35
+ /**
36
+ * @param jws General JWS.
37
+ * @param getKey Function resolving a key to verify the JWS with. See
38
+ * {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
39
+ * @param options JWS Verify options.
40
+ */
41
+ export declare function generalVerify(jws: types.GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: types.VerifyOptions): Promise<types.GeneralVerifyResult & types.ResolvedKey>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * JSON Web Token (JWT) Decryption (JWT is in JWE format)
3
+ *
4
+ * @module
5
+ */
6
+ import type * as types from '../types.d.ts';
7
+ /** Combination of JWE Decryption options and JWT Claims Set verification options. */
8
+ export interface JWTDecryptOptions extends types.DecryptOptions, types.JWTClaimVerificationOptions {
9
+ }
10
+ /**
11
+ * Interface for JWT Decryption dynamic key resolution. No token components have been verified at
12
+ * the time of this function call.
13
+ */
14
+ export interface JWTDecryptGetKey extends types.GetKeyFunction<types.CompactJWEHeaderParameters, types.FlattenedJWE> {
15
+ }
16
+ /**
17
+ * Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, validates the JWT
18
+ * Claims Set.
19
+ *
20
+ * This function is exported (as a named export) from the main `'jose'` module entry point as well
21
+ * as from its subpath export `'jose/jwt/decrypt'`.
22
+ *
23
+ * @param jwt JSON Web Token value (encoded as JWE).
24
+ * @param key Private Key or Secret to decrypt and verify the JWT with. See
25
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
26
+ * @param options JWT Decryption and JWT Claims Set validation options.
27
+ */
28
+ export declare function jwtDecrypt<PayloadType = types.JWTPayload>(jwt: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: JWTDecryptOptions): Promise<types.JWTDecryptResult<PayloadType>>;
29
+ /**
30
+ * @param jwt JSON Web Token value (encoded as JWE).
31
+ * @param getKey Function resolving Private Key or Secret to decrypt and verify the JWT with. See
32
+ * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
33
+ * @param options JWT Decryption and JWT Claims Set validation options.
34
+ */
35
+ export declare function jwtDecrypt<PayloadType = types.JWTPayload>(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<types.JWTDecryptResult<PayloadType> & types.ResolvedKey>;