@suveren/gateway 0.4.0 → 0.5.0
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.
- package/bin/suveren-gateway.js +59 -0
- package/content/integrations/calendar.json +116 -22
- package/content/integrations/gmail.json +3 -0
- package/dist/control-plane/index.mjs +67 -7
- package/dist/mcp-server/http.mjs +98 -17
- package/dist/ui/assets/index-DedRWpBs.js +105 -0
- package/dist/ui/index.html +1 -1
- package/lib/autostart-templates.d.mts +37 -0
- package/lib/autostart-templates.mjs +208 -0
- package/node_modules/jose/README.md +13 -13
- package/node_modules/jose/dist/types/index.d.ts +6 -5
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +7 -19
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +7 -19
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +18 -13
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +20 -21
- package/node_modules/jose/dist/types/jwk/embedded.d.ts +8 -12
- package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -15
- package/node_modules/jose/dist/types/jwks/local.d.ts +12 -21
- package/node_modules/jose/dist/types/jwks/remote.d.ts +34 -165
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +16 -17
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +18 -15
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +10 -34
- package/node_modules/jose/dist/types/jwt/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +4 -13
- package/node_modules/jose/dist/types/jwt/verify.d.ts +14 -13
- package/node_modules/jose/dist/types/key/export.d.ts +0 -14
- package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +7 -14
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +16 -14
- package/node_modules/jose/dist/types/key/import.d.ts +18 -28
- package/node_modules/jose/dist/types/types.d.ts +242 -223
- package/node_modules/jose/dist/types/util/base64url.d.ts +11 -4
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -9
- package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -8
- package/node_modules/jose/dist/types/util/errors.d.ts +128 -121
- package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +3 -21
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +5 -153
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +16 -111
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +15 -3
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +33 -48
- package/node_modules/jose/dist/webapi/jwk/embedded.js +5 -3
- package/node_modules/jose/dist/webapi/jwks/local.js +27 -47
- package/node_modules/jose/dist/webapi/jwks/remote.js +3 -3
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +5 -2
- package/node_modules/jose/dist/webapi/jws/compact/verify.js +3 -15
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +7 -57
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +3 -89
- package/node_modules/jose/dist/webapi/jws/general/sign.js +18 -5
- package/node_modules/jose/dist/webapi/jws/general/verify.js +21 -3
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +4 -4
- package/node_modules/jose/dist/webapi/jwt/sign.js +2 -3
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +4 -3
- package/node_modules/jose/dist/webapi/jwt/verify.js +5 -5
- package/node_modules/jose/dist/webapi/key/export.js +34 -1
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +32 -82
- package/node_modules/jose/dist/webapi/key/import.js +8 -8
- package/node_modules/jose/dist/webapi/lib/asn1.js +29 -65
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +1 -0
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +20 -77
- package/node_modules/jose/dist/webapi/lib/crypto_key.js +13 -127
- package/node_modules/jose/dist/webapi/lib/helpers.js +23 -0
- package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +143 -0
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +181 -0
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +109 -0
- package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +11 -96
- package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +74 -0
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +68 -0
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +108 -0
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +9 -8
- package/node_modules/jose/dist/webapi/lib/key.js +170 -0
- package/node_modules/jose/dist/webapi/lib/key_algorithm.js +16 -0
- package/node_modules/jose/dist/webapi/lib/key_descriptor.js +7 -0
- package/node_modules/jose/dist/webapi/lib/key_management.js +186 -29
- package/node_modules/jose/dist/webapi/lib/{validate_crit.js → options.js} +18 -0
- package/node_modules/jose/dist/webapi/lib/signing.js +20 -52
- package/node_modules/jose/dist/webapi/util/base64url.js +11 -3
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +2 -2
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -15
- package/node_modules/jose/dist/webapi/util/errors.js +1 -1
- package/node_modules/jose/package.json +2 -4
- package/package.json +2 -1
- package/profiles/email/0.4.profile.json +2 -1
- package/dist/ui/assets/index-BDQY7Z3H.js +0 -105
- package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -15
- package/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
- package/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
- package/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
- package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -34
- package/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -166
- package/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -42
- package/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
- package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encrypting JSON Web Encryption (JWE) in General JSON Serialization
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../../types.d.ts';
|
|
7
2
|
/** Used to build General JWE object's individual recipients. */
|
|
8
3
|
export interface Recipient {
|
|
@@ -13,28 +8,32 @@ export interface Recipient {
|
|
|
13
8
|
*/
|
|
14
9
|
setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
|
|
15
10
|
/**
|
|
16
|
-
* Sets the JWE Key Management parameters to be used when encrypting.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* PartyUInfo) or "apv" (Agreement PartyVInfo) parameters.
|
|
11
|
+
* Sets the JWE Key Management parameters to be used when encrypting. For ECDH based algorithms,
|
|
12
|
+
* use this method to set the "apu" (Agreement PartyUInfo) or "apv" (Agreement PartyVInfo)
|
|
13
|
+
* parameters.
|
|
20
14
|
*
|
|
21
15
|
* @param parameters JWE Key Management parameters.
|
|
22
16
|
*/
|
|
23
17
|
setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): Recipient;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A shorthand for calling {@link GeneralEncrypt.addRecipient addRecipient()} on the enclosing
|
|
20
|
+
* {@link GeneralEncrypt} instance.
|
|
21
|
+
*
|
|
22
|
+
* @param key Public Key or Secret to encrypt the Content Encryption Key for the recipient with.
|
|
23
|
+
* See {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
24
|
+
* @param options JWE Encryption options.
|
|
25
|
+
*/
|
|
26
|
+
addRecipient(key: types.KeyInput, options?: types.CritOption): Recipient;
|
|
27
|
+
/**
|
|
28
|
+
* A shorthand for calling {@link GeneralEncrypt.encrypt encrypt()} on the enclosing
|
|
29
|
+
* {@link GeneralEncrypt} instance. Takes no arguments — each recipient's key is supplied to
|
|
30
|
+
* {@link addRecipient}.
|
|
31
|
+
*/
|
|
32
|
+
encrypt(): Promise<types.GeneralJWE>;
|
|
28
33
|
/** Returns the enclosing {@link GeneralEncrypt} instance */
|
|
29
34
|
done(): GeneralEncrypt;
|
|
30
35
|
}
|
|
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
|
-
*/
|
|
36
|
+
/** The GeneralEncrypt class is used to build and encrypt General JWE objects. */
|
|
38
37
|
export declare class GeneralEncrypt {
|
|
39
38
|
#private;
|
|
40
39
|
/**
|
|
@@ -50,7 +49,7 @@ export declare class GeneralEncrypt {
|
|
|
50
49
|
* See {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
51
50
|
* @param options JWE Encryption options.
|
|
52
51
|
*/
|
|
53
|
-
addRecipient(key: types.
|
|
52
|
+
addRecipient(key: types.KeyInput, options?: types.CritOption): Recipient;
|
|
54
53
|
/**
|
|
55
54
|
* Sets the JWE Protected Header on the GeneralEncrypt object.
|
|
56
55
|
*
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verification using a JWK Embedded in a JWS Header
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../types.d.ts';
|
|
7
2
|
/**
|
|
8
|
-
* EmbeddedJWK is an implementation of a GetKeyFunction intended to be
|
|
9
|
-
* operations whenever you need to opt-in to verify signatures with a
|
|
10
|
-
* token's "jwk" (JSON Web Key) Header Parameter. It is recommended to
|
|
11
|
-
* function's `algorithms` option to define accepted JWS "alg"
|
|
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'`.
|
|
3
|
+
* EmbeddedJWK is an implementation of a {@link types.GetKeyFunction GetKeyFunction} intended to be
|
|
4
|
+
* used with the JWS/JWT verify operations whenever you need to opt-in to verify signatures with a
|
|
5
|
+
* public key embedded in the token's "jwk" (JSON Web Key) Header Parameter. It is recommended to
|
|
6
|
+
* combine this with the verify function's `algorithms` option to define accepted JWS "alg"
|
|
7
|
+
* (Algorithm) Header Parameter values.
|
|
15
8
|
*
|
|
9
|
+
* @param protectedHeader JWS Protected Header.
|
|
10
|
+
* @param token The consumed JWS token.
|
|
11
|
+
* @returns The public key from the JWS "jwk" (JSON Web Key) Header Parameter.
|
|
16
12
|
*/
|
|
17
13
|
export declare function EmbeddedJWK(protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
|
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON Web Key Thumbprint and JSON Web Key Thumbprint URI
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../types.d.ts';
|
|
7
2
|
/**
|
|
8
3
|
* Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint
|
|
9
4
|
*
|
|
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
5
|
* @param key Key to calculate the thumbprint for.
|
|
14
6
|
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
15
7
|
* "sha256".
|
|
16
|
-
*
|
|
17
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc7638 RFC7638}
|
|
18
8
|
*/
|
|
19
9
|
export declare function calculateJwkThumbprint(key: types.JWK | types.CryptoKey | types.KeyObject, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
20
10
|
/**
|
|
21
11
|
* Calculates a JSON Web Key (JWK) Thumbprint URI
|
|
22
12
|
*
|
|
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
13
|
* @param key Key to calculate the thumbprint for.
|
|
27
14
|
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
28
15
|
* "sha256".
|
|
29
|
-
*
|
|
30
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc9278 RFC9278}
|
|
31
16
|
*/
|
|
32
17
|
export declare function calculateJwkThumbprintUri(key: types.CryptoKey | types.KeyObject | types.JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verification using a JSON Web Key Set (JWKS) available locally
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../types.d.ts';
|
|
2
|
+
/** The key resolution function returned by {@link createLocalJWKSet}. */
|
|
3
|
+
export interface LocalJWKSet {
|
|
4
|
+
(protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
|
|
5
|
+
/** Returns a structured clone of the JSON Web Key Set this resolver was created with. */
|
|
6
|
+
jwks: () => types.JSONWebKeySet;
|
|
7
|
+
}
|
|
7
8
|
/**
|
|
8
9
|
* 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
|
+
* or otherwise available, JSON Web Key Set. Selection respects the header's "alg" (Algorithm) and
|
|
11
|
+
* "kid" (Key ID) as well as the JWK's "use" (Public Key Use) and "key_ops" (Key Operations).
|
|
12
|
+
* Exactly one key must match; if multiple keys match, the thrown `JWKSMultipleMatchingKeys` can be
|
|
13
|
+
* iterated.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
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
|
|
15
|
+
* > Note: The function's purpose is to resolve public keys used for verifying signatures and will not work
|
|
22
16
|
* > for public encryption keys.
|
|
23
17
|
*
|
|
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
18
|
* @param jwks JSON Web Key Set formatted object.
|
|
28
19
|
*/
|
|
29
|
-
export declare function createLocalJWKSet(jwks: types.JSONWebKeySet):
|
|
20
|
+
export declare function createLocalJWKSet(jwks: types.JSONWebKeySet): LocalJWKSet;
|
|
@@ -1,101 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verification using a JSON Web Key Set (JWKS) available on an HTTP(S) URL
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../types.d.ts';
|
|
7
2
|
/**
|
|
8
3
|
* When passed to {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} this allows the resolver
|
|
9
4
|
* to make use of advanced fetch configurations, HTTP Proxies, retry on network errors, etc.
|
|
10
5
|
*
|
|
11
|
-
* >
|
|
12
|
-
* > Known caveat: Expect Type-related issues when passing the inputs through to fetch-like modules,
|
|
6
|
+
* > Note: Known caveat: Expect Type-related issues when passing the inputs through to fetch-like modules,
|
|
13
7
|
* > 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/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/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/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
8
|
*/
|
|
100
9
|
export declare const customFetch: unique symbol;
|
|
101
10
|
/** See {@link customFetch}. */
|
|
@@ -113,55 +22,14 @@ options: {
|
|
|
113
22
|
signal: AbortSignal;
|
|
114
23
|
}) => Promise<Response>;
|
|
115
24
|
/**
|
|
116
|
-
* >
|
|
117
|
-
* > This option has security implications that must be understood, assessed for applicability, and
|
|
25
|
+
* > Warning: This option has security implications that must be understood, assessed for applicability, and
|
|
118
26
|
* > accepted before use. It is critical that the JSON Web Key Set cache only be writable by your own
|
|
119
27
|
* > code.
|
|
120
28
|
*
|
|
121
29
|
* This option is intended for cloud computing runtimes that cannot keep an in memory cache between
|
|
122
|
-
* their code's invocations.
|
|
123
|
-
*
|
|
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
|
-
* ```
|
|
30
|
+
* their code's invocations. The supplied writable object seeds the resolver's cache and is updated
|
|
31
|
+
* with `jwks` and `uat` after a successful fetch; persist it whenever `uat` changes. Using this in
|
|
32
|
+
* runtimes that can keep an in-memory cache between requests is not desirable.
|
|
165
33
|
*/
|
|
166
34
|
export declare const jwksCache: unique symbol;
|
|
167
35
|
/** Options for the remote JSON Web Key Set. */
|
|
@@ -197,41 +65,42 @@ export interface ExportedJWKSCache {
|
|
|
197
65
|
}
|
|
198
66
|
/** See {@link jwksCache}. */
|
|
199
67
|
export type JWKSCacheInput = ExportedJWKSCache | Record<string, never>;
|
|
68
|
+
/** The key resolution function returned by {@link createRemoteJWKSet}. */
|
|
69
|
+
export interface RemoteJWKSet {
|
|
70
|
+
(protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
|
|
71
|
+
/** Whether the cooldown window following the last successful fetch is still in effect. */
|
|
72
|
+
readonly coolingDown: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the currently cached JSON Web Key Set is within its
|
|
75
|
+
* {@link RemoteJWKSetOptions.cacheMaxAge}.
|
|
76
|
+
*/
|
|
77
|
+
readonly fresh: boolean;
|
|
78
|
+
/** Whether a JSON Web Key Set fetch is currently in flight. */
|
|
79
|
+
readonly reloading: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Triggers a JSON Web Key Set fetch, bypassing
|
|
82
|
+
* {@link RemoteJWKSetOptions.cooldownDuration the cooldown}.
|
|
83
|
+
*/
|
|
84
|
+
reload: () => Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* The currently cached JSON Web Key Set, or `undefined` when none has been fetched or seeded via
|
|
87
|
+
* {@link jwksCache} yet.
|
|
88
|
+
*/
|
|
89
|
+
jwks: () => types.JSONWebKeySet | undefined;
|
|
90
|
+
}
|
|
200
91
|
/**
|
|
201
92
|
* Returns a function that resolves a JWS JOSE Header to a public key object downloaded from a
|
|
202
93
|
* remote endpoint returning a JSON Web Key Set, that is, for example, an OAuth 2.0 or OIDC
|
|
203
94
|
* 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
|
-
*
|
|
207
|
-
*
|
|
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).
|
|
95
|
+
* frequently as the `cooldownDuration` option allows to prevent abuse. Selection respects the
|
|
96
|
+
* header's "alg" (Algorithm) and "kid" (Key ID) as well as the JWK's "use" (Public Key Use) and
|
|
97
|
+
* "key_ops" (Key Operations). Exactly one key must match; if multiple keys match, the thrown
|
|
98
|
+
* `JWKSMultipleMatchingKeys` can be iterated.
|
|
210
99
|
*
|
|
211
|
-
*
|
|
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
|
|
100
|
+
* > Note: The function's purpose is to resolve public keys used for verifying signatures and will not work
|
|
217
101
|
* > for public encryption keys.
|
|
218
102
|
*
|
|
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
103
|
* @param url URL to fetch the JSON Web Key Set from.
|
|
223
104
|
* @param options Options for the remote JSON Web Key Set.
|
|
224
105
|
*/
|
|
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
|
-
};
|
|
106
|
+
export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): RemoteJWKSet;
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signing JSON Web Signature (JWS) in Compact Serialization
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
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
|
-
*/
|
|
2
|
+
/** The CompactSign class is used to build and sign Compact JWS strings. */
|
|
14
3
|
export declare class CompactSign {
|
|
15
4
|
#private;
|
|
16
5
|
/**
|
|
@@ -32,5 +21,5 @@ export declare class CompactSign {
|
|
|
32
21
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
33
22
|
* @param options JWS Sign options.
|
|
34
23
|
*/
|
|
35
|
-
sign(key: types.
|
|
24
|
+
sign(key: types.KeyInput, options?: types.SignOptions): Promise<string>;
|
|
36
25
|
}
|
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifying JSON Web Signature (JWS) in Compact Serialization
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../../types.d.ts';
|
|
7
2
|
/**
|
|
8
3
|
* Interface for Compact JWS Verification dynamic key resolution. No token components have been
|
|
9
4
|
* 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
5
|
*/
|
|
13
|
-
export interface CompactVerifyGetKey extends types.
|
|
6
|
+
export interface CompactVerifyGetKey<KeyType extends types.CryptoKey | Uint8Array = types.CryptoKey | Uint8Array> extends types.GetKeyFunction<types.CompactJWSHeaderParameters, types.FlattenedJWSInput, KeyType | types.KeyObject | types.JWK> {
|
|
14
7
|
}
|
|
15
8
|
/**
|
|
16
9
|
* Verifies the signature and format of and afterwards decodes the Compact JWS.
|
|
17
10
|
*
|
|
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
11
|
* @param jws Compact JWS.
|
|
22
12
|
* @param key Key to verify the JWS with. See
|
|
23
13
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
24
14
|
* @param options JWS Verify options.
|
|
25
15
|
*/
|
|
26
|
-
export declare function compactVerify(jws: string | Uint8Array, key: types.
|
|
16
|
+
export declare function compactVerify(jws: string | Uint8Array, key: types.KeyInput, options?: types.VerifyOptions): Promise<types.CompactVerifyResult>;
|
|
27
17
|
/**
|
|
18
|
+
* Verifies the signature and format of and afterwards decodes the Compact JWS, resolving the key
|
|
19
|
+
* dynamically. The result additionally carries the {@link types.ResolvedKey.key resolved key}.
|
|
20
|
+
*
|
|
28
21
|
* @param jws Compact JWS.
|
|
29
22
|
* @param getKey Function resolving a key to verify the JWS with. See
|
|
30
23
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
31
24
|
* @param options JWS Verify options.
|
|
32
25
|
*/
|
|
33
|
-
export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey
|
|
26
|
+
export declare function compactVerify<KeyType extends types.CryptoKey | Uint8Array = types.CryptoKey | Uint8Array>(jws: string | Uint8Array, getKey: CompactVerifyGetKey<KeyType>, options?: types.VerifyOptions): Promise<types.CompactVerifyResult & types.ResolvedKey<KeyType>>;
|
|
27
|
+
/**
|
|
28
|
+
* Accepts either form of the `key` argument. Use this overload when forwarding a value that may be
|
|
29
|
+
* either a key or a key resolution function; `key` is present on the result only when a resolution
|
|
30
|
+
* function was used.
|
|
31
|
+
*
|
|
32
|
+
* @param jws Compact JWS.
|
|
33
|
+
* @param key Key, or function resolving a key, to verify the JWS with. See
|
|
34
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
35
|
+
* @param options JWS Verify options.
|
|
36
|
+
*/
|
|
37
|
+
export declare function compactVerify(jws: string | Uint8Array, key: types.KeyInput | CompactVerifyGetKey, options?: types.VerifyOptions): Promise<types.CompactVerifyResult & Partial<types.ResolvedKey>>;
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signing JSON Web Signature (JWS) in Flattened JSON Serialization
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
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
|
-
*/
|
|
2
|
+
/** The FlattenedSign class is used to build and sign Flattened JWS objects. */
|
|
14
3
|
export declare class FlattenedSign {
|
|
15
4
|
#private;
|
|
16
5
|
/**
|
|
@@ -38,5 +27,5 @@ export declare class FlattenedSign {
|
|
|
38
27
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
39
28
|
* @param options JWS Sign options.
|
|
40
29
|
*/
|
|
41
|
-
sign(key: types.
|
|
30
|
+
sign(key: types.KeyInput, options?: types.SignOptions): Promise<types.FlattenedJWS>;
|
|
42
31
|
}
|
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifying JSON Web Signature (JWS) in Flattened JSON Serialization
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../../types.d.ts';
|
|
7
2
|
/**
|
|
8
3
|
* Interface for Flattened JWS Verification dynamic key resolution. No token components have been
|
|
9
4
|
* 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
5
|
*/
|
|
13
|
-
export interface FlattenedVerifyGetKey extends types.
|
|
6
|
+
export interface FlattenedVerifyGetKey<KeyType extends types.CryptoKey | Uint8Array = types.CryptoKey | Uint8Array> extends types.GetKeyFunction<types.JWSHeaderParameters, types.FlattenedJWSInput, KeyType | types.KeyObject | types.JWK> {
|
|
14
7
|
}
|
|
15
8
|
/**
|
|
16
9
|
* Verifies the signature and format of and afterwards decodes the Flattened JWS.
|
|
17
10
|
*
|
|
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
11
|
* @param jws Flattened JWS.
|
|
22
12
|
* @param key Key to verify the JWS with. See
|
|
23
13
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
24
14
|
* @param options JWS Verify options.
|
|
25
15
|
*/
|
|
26
|
-
export declare function flattenedVerify(jws: types.FlattenedJWSInput, key: types.
|
|
16
|
+
export declare function flattenedVerify(jws: types.FlattenedJWSInput, key: types.KeyInput, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult>;
|
|
27
17
|
/**
|
|
18
|
+
* Verifies the signature and format of and afterwards decodes the Flattened JWS, resolving the key
|
|
19
|
+
* dynamically. The result additionally carries the {@link types.ResolvedKey.key resolved key}.
|
|
20
|
+
*
|
|
28
21
|
* @param jws Flattened JWS.
|
|
29
22
|
* @param getKey Function resolving a key to verify the JWS with. See
|
|
30
23
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
31
24
|
* @param options JWS Verify options.
|
|
32
25
|
*/
|
|
33
|
-
export declare function flattenedVerify(jws: types.FlattenedJWSInput, getKey: FlattenedVerifyGetKey
|
|
26
|
+
export declare function flattenedVerify<KeyType extends types.CryptoKey | Uint8Array = types.CryptoKey | Uint8Array>(jws: types.FlattenedJWSInput, getKey: FlattenedVerifyGetKey<KeyType>, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult & types.ResolvedKey<KeyType>>;
|
|
27
|
+
/**
|
|
28
|
+
* Accepts either form of the `key` argument. Use this overload when forwarding a value that may be
|
|
29
|
+
* either a key or a key resolution function; `key` is present on the result only when a resolution
|
|
30
|
+
* function was used.
|
|
31
|
+
*
|
|
32
|
+
* @param jws Flattened JWS.
|
|
33
|
+
* @param key Key, or function resolving a key, to verify the JWS with. See
|
|
34
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
35
|
+
* @param options JWS Verify options.
|
|
36
|
+
*/
|
|
37
|
+
export declare function flattenedVerify(jws: types.FlattenedJWSInput, key: types.KeyInput | FlattenedVerifyGetKey, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult & Partial<types.ResolvedKey>>;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signing JSON Web Signature (JWS) in General JSON Serialization
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import type * as types from '../../types.d.ts';
|
|
7
2
|
/** Used to build General JWS object's individual signatures. */
|
|
8
3
|
export interface Signature {
|
|
@@ -18,20 +13,24 @@ export interface Signature {
|
|
|
18
13
|
* @param unprotectedHeader JWS Unprotected Header.
|
|
19
14
|
*/
|
|
20
15
|
setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): Signature;
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
/**
|
|
17
|
+
* A shorthand for calling {@link GeneralSign.addSignature addSignature()} on the enclosing
|
|
18
|
+
* {@link GeneralSign} instance.
|
|
19
|
+
*
|
|
20
|
+
* @param key Private Key or Secret to sign the individual JWS signature with. See
|
|
21
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
22
|
+
* @param options JWS Sign options.
|
|
23
|
+
*/
|
|
24
|
+
addSignature(key: types.KeyInput, options?: types.SignOptions): Signature;
|
|
25
|
+
/**
|
|
26
|
+
* A shorthand for calling {@link GeneralSign.sign sign()} on the enclosing {@link GeneralSign}
|
|
27
|
+
* instance. Takes no arguments — each signature's key is supplied to {@link addSignature}.
|
|
28
|
+
*/
|
|
29
|
+
sign(): Promise<types.GeneralJWS>;
|
|
25
30
|
/** Returns the enclosing {@link GeneralSign} instance */
|
|
26
31
|
done(): GeneralSign;
|
|
27
32
|
}
|
|
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
|
-
*/
|
|
33
|
+
/** The GeneralSign class is used to build and sign General JWS objects. */
|
|
35
34
|
export declare class GeneralSign {
|
|
36
35
|
#private;
|
|
37
36
|
/**
|
|
@@ -47,7 +46,7 @@ export declare class GeneralSign {
|
|
|
47
46
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
48
47
|
* @param options JWS Sign options.
|
|
49
48
|
*/
|
|
50
|
-
addSignature(key: types.
|
|
49
|
+
addSignature(key: types.KeyInput, options?: types.SignOptions): Signature;
|
|
51
50
|
/** Signs and resolves the value of the General JWS object. */
|
|
52
51
|
sign(): Promise<types.GeneralJWS>;
|
|
53
52
|
}
|