@zuplo/cli 6.73.27 → 6.73.28
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/node_modules/@modelcontextprotocol/sdk/node_modules/jose/README.md +13 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/index.d.ts +6 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +17 -11
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +7 -19
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +17 -11
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +7 -19
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +18 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +20 -21
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwk/embedded.d.ts +8 -12
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwks/local.d.ts +12 -21
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwks/remote.d.ts +34 -165
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/compact/sign.d.ts +2 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/compact/verify.d.ts +17 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/flattened/sign.d.ts +2 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/flattened/verify.d.ts +17 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/general/sign.d.ts +16 -17
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/general/verify.d.ts +18 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/decrypt.d.ts +17 -11
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/encrypt.d.ts +10 -34
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/sign.d.ts +2 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/unsecured.d.ts +4 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/verify.d.ts +14 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/export.d.ts +0 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/generate_key_pair.d.ts +7 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/generate_secret.d.ts +16 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/import.d.ts +18 -28
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/types.d.ts +242 -223
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/base64url.d.ts +11 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -9
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/errors.d.ts +128 -121
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +3 -21
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +5 -153
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +16 -111
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/decrypt.js +15 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/encrypt.js +33 -48
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/embedded.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/local.js +27 -47
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/compact/sign.js +5 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/compact/verify.js +3 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/flattened/sign.js +7 -57
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/flattened/verify.js +3 -89
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/sign.js +18 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js +21 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/decrypt.js +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/sign.js +2 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/unsecured.js +4 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/verify.js +5 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/export.js +34 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/generate_key_pair.js +32 -82
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/import.js +8 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/asn1.js +29 -65
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/buffer_utils.js +1 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/content_encryption.js +20 -77
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/crypto_key.js +13 -127
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/helpers.js +23 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +143 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +181 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +109 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwk_to_key.js +11 -96
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_algorithms.js +74 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_sign.js +68 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_verify.js +108 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +9 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key.js +170 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_algorithm.js +16 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_descriptor.js +7 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js +186 -29
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/{validate_crit.js → options.js} +18 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/signing.js +20 -52
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/base64url.js +11 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/decode_jwt.js +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/errors.js +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +2 -4
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -34
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -166
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -42
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { encode as b64u } from '../util/base64url.js';
|
|
2
|
+
import { encrypt } from './content_encryption.js';
|
|
3
|
+
import { encryptKeyManagement } from './key_management.js';
|
|
4
|
+
import { JOSENotSupported, JWEInvalid } from '../util/errors.js';
|
|
5
|
+
import { isDisjoint } from './type_checks.js';
|
|
6
|
+
import { concat, encode } from './buffer_utils.js';
|
|
7
|
+
import { validateCrit, JWE_RECOGNIZED } from './options.js';
|
|
8
|
+
import { prepareKey } from './key.js';
|
|
9
|
+
import { jweAlgorithm, jweEncryption } from './jwe_algorithms.js';
|
|
10
|
+
import { compress } from './deflate.js';
|
|
11
|
+
export function checkEncryptHeaders(input) {
|
|
12
|
+
const { protectedHeader, unprotectedHeader, sharedUnprotectedHeader } = input;
|
|
13
|
+
if (!isDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader)) {
|
|
14
|
+
throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
|
|
15
|
+
}
|
|
16
|
+
const joseHeader = {
|
|
17
|
+
...protectedHeader,
|
|
18
|
+
...unprotectedHeader,
|
|
19
|
+
...sharedUnprotectedHeader,
|
|
20
|
+
};
|
|
21
|
+
validateCrit(JWEInvalid, JWE_RECOGNIZED, input.crit, protectedHeader, joseHeader);
|
|
22
|
+
if (joseHeader.zip !== undefined && joseHeader.zip !== 'DEF') {
|
|
23
|
+
throw new JOSENotSupported('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');
|
|
24
|
+
}
|
|
25
|
+
if (joseHeader.zip !== undefined && !protectedHeader?.zip) {
|
|
26
|
+
throw new JWEInvalid('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');
|
|
27
|
+
}
|
|
28
|
+
const { alg, enc } = joseHeader;
|
|
29
|
+
if (typeof alg !== 'string' || !alg) {
|
|
30
|
+
throw new JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');
|
|
31
|
+
}
|
|
32
|
+
if (typeof enc !== 'string' || !enc) {
|
|
33
|
+
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
|
|
34
|
+
}
|
|
35
|
+
return { joseHeader, alg, enc, encEntry: jweEncryption(enc) };
|
|
36
|
+
}
|
|
37
|
+
export async function encryptJWE(input, checked, key) {
|
|
38
|
+
const { joseHeader, alg, encEntry } = checked;
|
|
39
|
+
let { protectedHeader, unprotectedHeader } = input;
|
|
40
|
+
const { sharedUnprotectedHeader } = input;
|
|
41
|
+
if (input.cek && (alg === 'dir' || alg === 'ECDH-ES')) {
|
|
42
|
+
throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${alg}`);
|
|
43
|
+
}
|
|
44
|
+
const algEntry = jweAlgorithm(alg);
|
|
45
|
+
const k = await prepareKey(alg === 'dir' ? encEntry : algEntry, key, 'encrypt');
|
|
46
|
+
const { cek, encryptedKey, parameters } = await encryptKeyManagement(alg, encEntry, k, input.cek, input.keyManagementParameters);
|
|
47
|
+
if (parameters) {
|
|
48
|
+
if (input.unprotectedParameters) {
|
|
49
|
+
unprotectedHeader = unprotectedHeader ? { ...unprotectedHeader, ...parameters } : parameters;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
protectedHeader = protectedHeader ? { ...protectedHeader, ...parameters } : parameters;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
let protectedHeaderS;
|
|
56
|
+
let protectedHeaderB;
|
|
57
|
+
if (protectedHeader) {
|
|
58
|
+
protectedHeaderS = b64u(JSON.stringify(protectedHeader));
|
|
59
|
+
protectedHeaderB = encode(protectedHeaderS);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
protectedHeaderS = '';
|
|
63
|
+
protectedHeaderB = new Uint8Array();
|
|
64
|
+
}
|
|
65
|
+
let additionalData;
|
|
66
|
+
let aadMember;
|
|
67
|
+
if (input.aad?.byteLength) {
|
|
68
|
+
aadMember = b64u(input.aad);
|
|
69
|
+
additionalData = concat(protectedHeaderB, encode('.'), encode(aadMember));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
additionalData = protectedHeaderB;
|
|
73
|
+
}
|
|
74
|
+
let plaintext = input.plaintext;
|
|
75
|
+
if (joseHeader.zip === 'DEF') {
|
|
76
|
+
plaintext = await compress(plaintext).catch((cause) => {
|
|
77
|
+
throw new JWEInvalid('Failed to compress plaintext', { cause });
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const { ciphertext, tag, iv } = await encrypt(encEntry, plaintext, cek, input.iv, additionalData);
|
|
81
|
+
const jwe = {
|
|
82
|
+
ciphertext: b64u(ciphertext),
|
|
83
|
+
};
|
|
84
|
+
if (iv) {
|
|
85
|
+
jwe.iv = b64u(iv);
|
|
86
|
+
}
|
|
87
|
+
if (tag) {
|
|
88
|
+
jwe.tag = b64u(tag);
|
|
89
|
+
}
|
|
90
|
+
if (encryptedKey) {
|
|
91
|
+
jwe.encrypted_key = b64u(encryptedKey);
|
|
92
|
+
}
|
|
93
|
+
if (aadMember) {
|
|
94
|
+
jwe.aad = aadMember;
|
|
95
|
+
}
|
|
96
|
+
if (protectedHeader) {
|
|
97
|
+
jwe.protected = protectedHeaderS;
|
|
98
|
+
}
|
|
99
|
+
if (sharedUnprotectedHeader) {
|
|
100
|
+
jwe.unprotected = sharedUnprotectedHeader;
|
|
101
|
+
}
|
|
102
|
+
if (unprotectedHeader) {
|
|
103
|
+
jwe.header = unprotectedHeader;
|
|
104
|
+
}
|
|
105
|
+
return jwe;
|
|
106
|
+
}
|
|
107
|
+
export async function createJWE(input, key) {
|
|
108
|
+
return encryptJWE(input, checkEncryptHeaders(input), key);
|
|
109
|
+
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwk_to_key.js
CHANGED
|
@@ -1,107 +1,22 @@
|
|
|
1
1
|
import { JOSENotSupported } from '../util/errors.js';
|
|
2
2
|
const unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
switch (jwk.kty) {
|
|
7
|
-
case 'AKP': {
|
|
8
|
-
switch (jwk.alg) {
|
|
9
|
-
case 'ML-DSA-44':
|
|
10
|
-
case 'ML-DSA-65':
|
|
11
|
-
case 'ML-DSA-87':
|
|
12
|
-
algorithm = { name: jwk.alg };
|
|
13
|
-
keyUsages = jwk.priv ? ['sign'] : ['verify'];
|
|
14
|
-
break;
|
|
15
|
-
default:
|
|
16
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
case 'RSA': {
|
|
21
|
-
switch (jwk.alg) {
|
|
22
|
-
case 'PS256':
|
|
23
|
-
case 'PS384':
|
|
24
|
-
case 'PS512':
|
|
25
|
-
algorithm = { name: 'RSA-PSS', hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
26
|
-
keyUsages = jwk.d ? ['sign'] : ['verify'];
|
|
27
|
-
break;
|
|
28
|
-
case 'RS256':
|
|
29
|
-
case 'RS384':
|
|
30
|
-
case 'RS512':
|
|
31
|
-
algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
32
|
-
keyUsages = jwk.d ? ['sign'] : ['verify'];
|
|
33
|
-
break;
|
|
34
|
-
case 'RSA-OAEP':
|
|
35
|
-
case 'RSA-OAEP-256':
|
|
36
|
-
case 'RSA-OAEP-384':
|
|
37
|
-
case 'RSA-OAEP-512':
|
|
38
|
-
algorithm = {
|
|
39
|
-
name: 'RSA-OAEP',
|
|
40
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`,
|
|
41
|
-
};
|
|
42
|
-
keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];
|
|
43
|
-
break;
|
|
44
|
-
default:
|
|
45
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case 'EC': {
|
|
50
|
-
switch (jwk.alg) {
|
|
51
|
-
case 'ES256':
|
|
52
|
-
case 'ES384':
|
|
53
|
-
case 'ES512':
|
|
54
|
-
algorithm = {
|
|
55
|
-
name: 'ECDSA',
|
|
56
|
-
namedCurve: { ES256: 'P-256', ES384: 'P-384', ES512: 'P-521' }[jwk.alg],
|
|
57
|
-
};
|
|
58
|
-
keyUsages = jwk.d ? ['sign'] : ['verify'];
|
|
59
|
-
break;
|
|
60
|
-
case 'ECDH-ES':
|
|
61
|
-
case 'ECDH-ES+A128KW':
|
|
62
|
-
case 'ECDH-ES+A192KW':
|
|
63
|
-
case 'ECDH-ES+A256KW':
|
|
64
|
-
algorithm = { name: 'ECDH', namedCurve: jwk.crv };
|
|
65
|
-
keyUsages = jwk.d ? ['deriveBits'] : [];
|
|
66
|
-
break;
|
|
67
|
-
default:
|
|
68
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case 'OKP': {
|
|
73
|
-
switch (jwk.alg) {
|
|
74
|
-
case 'Ed25519':
|
|
75
|
-
case 'EdDSA':
|
|
76
|
-
algorithm = { name: 'Ed25519' };
|
|
77
|
-
keyUsages = jwk.d ? ['sign'] : ['verify'];
|
|
78
|
-
break;
|
|
79
|
-
case 'ECDH-ES':
|
|
80
|
-
case 'ECDH-ES+A128KW':
|
|
81
|
-
case 'ECDH-ES+A192KW':
|
|
82
|
-
case 'ECDH-ES+A256KW':
|
|
83
|
-
algorithm = { name: jwk.crv };
|
|
84
|
-
keyUsages = jwk.d ? ['deriveBits'] : [];
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
throw new JOSENotSupported(unsupportedAlg);
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
default:
|
|
92
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
3
|
+
function subtleParams(entry, jwk) {
|
|
4
|
+
if (!entry.kty.includes(jwk.kty)) {
|
|
5
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
93
6
|
}
|
|
94
|
-
return {
|
|
7
|
+
return entry.subtleFor?.({ kty: jwk.kty, crv: jwk.crv }) ?? entry.subtle;
|
|
95
8
|
}
|
|
96
|
-
export async function jwkToKey(jwk) {
|
|
97
|
-
if (
|
|
98
|
-
throw new
|
|
9
|
+
export async function jwkToKey(entry, jwk) {
|
|
10
|
+
if (jwk.kty === 'RSA' && 'oth' in jwk && jwk.oth !== undefined) {
|
|
11
|
+
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
99
12
|
}
|
|
100
|
-
const
|
|
13
|
+
const algorithm = subtleParams(entry, jwk);
|
|
14
|
+
const isPrivate = !!(jwk.d || jwk.priv);
|
|
15
|
+
const keyUsages = isPrivate ? entry.usages.private : entry.usages.public;
|
|
101
16
|
const keyData = { ...jwk };
|
|
102
17
|
if (keyData.kty !== 'AKP') {
|
|
103
18
|
delete keyData.alg;
|
|
104
19
|
}
|
|
105
20
|
delete keyData.use;
|
|
106
|
-
return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (
|
|
21
|
+
return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (isPrivate ? false : true), jwk.key_ops ?? keyUsages);
|
|
107
22
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_algorithms.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { JOSENotSupported } from '../util/errors.js';
|
|
2
|
+
import { table } from './key_descriptor.js';
|
|
3
|
+
const sig = { public: ['verify'], private: ['sign'] };
|
|
4
|
+
function hmac(bits) {
|
|
5
|
+
const subtle = { name: 'HMAC', hash: `SHA-${bits}` };
|
|
6
|
+
return { kty: ['oct'], symmetric: true, subtle, operation: subtle, usages: sig };
|
|
7
|
+
}
|
|
8
|
+
function rsa(name, bits, saltLength) {
|
|
9
|
+
const subtle = { name, hash: `SHA-${bits}` };
|
|
10
|
+
return {
|
|
11
|
+
kty: ['RSA'],
|
|
12
|
+
subtle,
|
|
13
|
+
operation: saltLength ? { ...subtle, saltLength } : subtle,
|
|
14
|
+
usages: sig,
|
|
15
|
+
minModulusLength: 2048,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function ecdsa(crv, bits) {
|
|
19
|
+
return {
|
|
20
|
+
kty: ['EC'],
|
|
21
|
+
crv,
|
|
22
|
+
subtle: { name: 'ECDSA', namedCurve: crv },
|
|
23
|
+
operation: { name: 'ECDSA', hash: `SHA-${bits}` },
|
|
24
|
+
usages: sig,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function eddsa() {
|
|
28
|
+
const subtle = { name: 'Ed25519' };
|
|
29
|
+
return {
|
|
30
|
+
kty: ['OKP'],
|
|
31
|
+
crv: 'Ed25519',
|
|
32
|
+
subtle,
|
|
33
|
+
operation: subtle,
|
|
34
|
+
usages: sig,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function mldsa(name) {
|
|
38
|
+
const subtle = { name };
|
|
39
|
+
return {
|
|
40
|
+
kty: ['AKP'],
|
|
41
|
+
subtle,
|
|
42
|
+
operation: subtle,
|
|
43
|
+
usages: sig,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const JWS = table({
|
|
47
|
+
HS256: hmac(256),
|
|
48
|
+
HS384: hmac(384),
|
|
49
|
+
HS512: hmac(512),
|
|
50
|
+
RS256: rsa('RSASSA-PKCS1-v1_5', 256),
|
|
51
|
+
RS384: rsa('RSASSA-PKCS1-v1_5', 384),
|
|
52
|
+
RS512: rsa('RSASSA-PKCS1-v1_5', 512),
|
|
53
|
+
PS256: rsa('RSA-PSS', 256, 32),
|
|
54
|
+
PS384: rsa('RSA-PSS', 384, 48),
|
|
55
|
+
PS512: rsa('RSA-PSS', 512, 64),
|
|
56
|
+
ES256: ecdsa('P-256', 256),
|
|
57
|
+
ES384: ecdsa('P-384', 384),
|
|
58
|
+
ES512: ecdsa('P-521', 512),
|
|
59
|
+
EdDSA: eddsa(),
|
|
60
|
+
Ed25519: eddsa(),
|
|
61
|
+
'ML-DSA-44': mldsa('ML-DSA-44'),
|
|
62
|
+
'ML-DSA-65': mldsa('ML-DSA-65'),
|
|
63
|
+
'ML-DSA-87': mldsa('ML-DSA-87'),
|
|
64
|
+
});
|
|
65
|
+
export function jwsAlgorithm(alg) {
|
|
66
|
+
const entry = JWS[alg];
|
|
67
|
+
if (!entry) {
|
|
68
|
+
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
69
|
+
}
|
|
70
|
+
return entry;
|
|
71
|
+
}
|
|
72
|
+
export function maybeJWSAlgorithm(alg) {
|
|
73
|
+
return JWS[alg];
|
|
74
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { encode as b64u } from '../util/base64url.js';
|
|
2
|
+
import { sign } from './signing.js';
|
|
3
|
+
import { jwsAlgorithm } from './jws_algorithms.js';
|
|
4
|
+
import { isDisjoint } from './type_checks.js';
|
|
5
|
+
import { JWSInvalid } from '../util/errors.js';
|
|
6
|
+
import { concat, encode } from './buffer_utils.js';
|
|
7
|
+
import { validateCrit, validateCritDuplicates, JWS_RECOGNIZED } from './options.js';
|
|
8
|
+
import { prepareKey } from './key.js';
|
|
9
|
+
export function unencodedPayload(protectedHeader) {
|
|
10
|
+
return (protectedHeader?.b64 === false &&
|
|
11
|
+
Array.isArray(protectedHeader.crit) &&
|
|
12
|
+
protectedHeader.crit.includes('b64'));
|
|
13
|
+
}
|
|
14
|
+
export async function createSignature(input, key) {
|
|
15
|
+
const { protectedHeader, unprotectedHeader } = input;
|
|
16
|
+
if (!isDisjoint(protectedHeader, unprotectedHeader)) {
|
|
17
|
+
throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');
|
|
18
|
+
}
|
|
19
|
+
const joseHeader = { ...protectedHeader, ...unprotectedHeader };
|
|
20
|
+
validateCritDuplicates(JWSInvalid, protectedHeader);
|
|
21
|
+
const extensions = validateCrit(JWSInvalid, JWS_RECOGNIZED, input.crit, protectedHeader, joseHeader);
|
|
22
|
+
let b64 = true;
|
|
23
|
+
if (extensions.has('b64')) {
|
|
24
|
+
b64 = protectedHeader.b64;
|
|
25
|
+
if (typeof b64 !== 'boolean') {
|
|
26
|
+
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const { alg } = joseHeader;
|
|
30
|
+
if (typeof alg !== 'string' || !alg) {
|
|
31
|
+
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
32
|
+
}
|
|
33
|
+
const entry = jwsAlgorithm(alg);
|
|
34
|
+
let payloadS;
|
|
35
|
+
let payloadB;
|
|
36
|
+
if (b64) {
|
|
37
|
+
const encoded = (input.encoded ??= {});
|
|
38
|
+
encoded.b64 ??= b64u(input.payload);
|
|
39
|
+
encoded.raw ??= encode(encoded.b64);
|
|
40
|
+
payloadS = encoded.b64;
|
|
41
|
+
payloadB = encoded.raw;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
payloadB = input.payload;
|
|
45
|
+
payloadS = '';
|
|
46
|
+
}
|
|
47
|
+
let protectedHeaderString;
|
|
48
|
+
let protectedHeaderBytes;
|
|
49
|
+
if (protectedHeader) {
|
|
50
|
+
protectedHeaderString = b64u(JSON.stringify(protectedHeader));
|
|
51
|
+
protectedHeaderBytes = encode(protectedHeaderString);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
protectedHeaderString = '';
|
|
55
|
+
protectedHeaderBytes = new Uint8Array();
|
|
56
|
+
}
|
|
57
|
+
const data = concat(protectedHeaderBytes, encode('.'), payloadB);
|
|
58
|
+
const k = await prepareKey(entry, key, 'sign');
|
|
59
|
+
const signature = await sign(entry, k, data);
|
|
60
|
+
const jws = {
|
|
61
|
+
signature: b64u(signature),
|
|
62
|
+
payload: payloadS,
|
|
63
|
+
};
|
|
64
|
+
if (protectedHeader) {
|
|
65
|
+
jws.protected = protectedHeaderString;
|
|
66
|
+
}
|
|
67
|
+
return jws;
|
|
68
|
+
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_verify.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { verify } from './signing.js';
|
|
2
|
+
import { jwsAlgorithm } from './jws_algorithms.js';
|
|
3
|
+
import { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../util/errors.js';
|
|
4
|
+
import { concat, decoder, encoder, encode } from './buffer_utils.js';
|
|
5
|
+
import { decodeBase64url, encodeBase64url, parseJoseHeader } from './helpers.js';
|
|
6
|
+
import { isDisjoint } from './type_checks.js';
|
|
7
|
+
import { validateCrit, validateAlgorithms, JWS_RECOGNIZED } from './options.js';
|
|
8
|
+
import { prepareKey } from './key.js';
|
|
9
|
+
export function verifyResult(jws, verified) {
|
|
10
|
+
const result = { payload: verified.payload };
|
|
11
|
+
if (jws.protected !== undefined) {
|
|
12
|
+
result.protectedHeader = verified.parsedProt;
|
|
13
|
+
}
|
|
14
|
+
if (jws.header !== undefined) {
|
|
15
|
+
result.unprotectedHeader = jws.header;
|
|
16
|
+
}
|
|
17
|
+
if (verified.resolvedKey) {
|
|
18
|
+
return { ...result, key: verified.key };
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
export function prepareVerify(options) {
|
|
23
|
+
return {
|
|
24
|
+
algorithms: options && validateAlgorithms('algorithms', options.algorithms),
|
|
25
|
+
crit: options?.crit,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export async function verifySignature(jws, shared, key) {
|
|
29
|
+
let parsedProt = {};
|
|
30
|
+
if (jws.protected) {
|
|
31
|
+
parsedProt = parseJoseHeader(jws.protected, JWSInvalid, 'JWS Protected Header is invalid');
|
|
32
|
+
}
|
|
33
|
+
let joseHeader;
|
|
34
|
+
if (jws.header !== undefined) {
|
|
35
|
+
if (!isDisjoint(parsedProt, jws.header)) {
|
|
36
|
+
throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');
|
|
37
|
+
}
|
|
38
|
+
joseHeader = { ...parsedProt, ...jws.header };
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
joseHeader = parsedProt;
|
|
42
|
+
}
|
|
43
|
+
const extensions = validateCrit(JWSInvalid, JWS_RECOGNIZED, shared.crit, parsedProt, joseHeader);
|
|
44
|
+
let b64 = true;
|
|
45
|
+
if (extensions.has('b64')) {
|
|
46
|
+
b64 = parsedProt.b64;
|
|
47
|
+
if (typeof b64 !== 'boolean') {
|
|
48
|
+
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const { alg } = joseHeader;
|
|
52
|
+
if (typeof alg !== 'string' || !alg) {
|
|
53
|
+
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
54
|
+
}
|
|
55
|
+
if (shared.algorithms && !shared.algorithms.has(alg)) {
|
|
56
|
+
throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
|
|
57
|
+
}
|
|
58
|
+
if (b64) {
|
|
59
|
+
if (typeof jws.payload !== 'string') {
|
|
60
|
+
throw new JWSInvalid('JWS Payload must be a string');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if (typeof jws.payload !== 'string' && !(jws.payload instanceof Uint8Array)) {
|
|
64
|
+
throw new JWSInvalid('JWS Payload must be a string or an Uint8Array instance');
|
|
65
|
+
}
|
|
66
|
+
let resolvedKey = false;
|
|
67
|
+
if (typeof key === 'function') {
|
|
68
|
+
key = await key(parsedProt, jws);
|
|
69
|
+
resolvedKey = true;
|
|
70
|
+
}
|
|
71
|
+
const entry = jwsAlgorithm(alg);
|
|
72
|
+
const data = concat(jws.protected !== undefined ? encode(jws.protected) : new Uint8Array(), encode('.'), typeof jws.payload === 'string'
|
|
73
|
+
? b64
|
|
74
|
+
?
|
|
75
|
+
(shared.b64p ??= encodeBase64url(jws.payload, 'payload', JWSInvalid))
|
|
76
|
+
: encoder.encode(jws.payload)
|
|
77
|
+
: jws.payload);
|
|
78
|
+
const signature = decodeBase64url(jws.signature, 'signature', JWSInvalid);
|
|
79
|
+
const k = await prepareKey(entry, key, 'verify');
|
|
80
|
+
const verified = await verify(entry, k, signature, data);
|
|
81
|
+
if (!verified) {
|
|
82
|
+
throw new JWSSignatureVerificationFailed();
|
|
83
|
+
}
|
|
84
|
+
let payload;
|
|
85
|
+
if (b64) {
|
|
86
|
+
payload = decodeBase64url(jws.payload, 'payload', JWSInvalid);
|
|
87
|
+
}
|
|
88
|
+
else if (typeof jws.payload === 'string') {
|
|
89
|
+
payload = encoder.encode(jws.payload);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
payload = jws.payload;
|
|
93
|
+
}
|
|
94
|
+
return { payload, parsedProt, b64, key: k, resolvedKey };
|
|
95
|
+
}
|
|
96
|
+
export async function verifyCompact(jws, shared, key) {
|
|
97
|
+
if (jws instanceof Uint8Array) {
|
|
98
|
+
jws = decoder.decode(jws);
|
|
99
|
+
}
|
|
100
|
+
if (typeof jws !== 'string') {
|
|
101
|
+
throw new JWSInvalid('Compact JWS must be a string or Uint8Array');
|
|
102
|
+
}
|
|
103
|
+
const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split('.');
|
|
104
|
+
if (length !== 3) {
|
|
105
|
+
throw new JWSInvalid('Invalid Compact JWS');
|
|
106
|
+
}
|
|
107
|
+
return verifySignature({ payload, protected: protectedHeader, signature }, shared, key);
|
|
108
|
+
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JWTClaimValidationFailed, JWTExpired, JWTInvalid } from '../util/errors.js';
|
|
2
|
-
import { encoder,
|
|
2
|
+
import { encoder, strictDecoder } from './buffer_utils.js';
|
|
3
3
|
import { isObject } from './type_checks.js';
|
|
4
4
|
const epoch = (date) => Math.floor(date.getTime() / 1000);
|
|
5
5
|
const minute = 60;
|
|
@@ -81,7 +81,7 @@ const checkAudiencePresence = (audPayload, audOption) => {
|
|
|
81
81
|
export function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
82
82
|
let payload;
|
|
83
83
|
try {
|
|
84
|
-
payload = JSON.parse(
|
|
84
|
+
payload = JSON.parse(strictDecoder.decode(encodedPayload));
|
|
85
85
|
}
|
|
86
86
|
catch {
|
|
87
87
|
}
|
|
@@ -109,14 +109,14 @@ export function validateClaimsSet(protectedHeader, encodedPayload, options = {})
|
|
|
109
109
|
throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, 'missing');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
if (issuer &&
|
|
112
|
+
if (issuer !== undefined &&
|
|
113
113
|
!(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {
|
|
114
114
|
throw new JWTClaimValidationFailed('unexpected "iss" claim value', payload, 'iss', 'check_failed');
|
|
115
115
|
}
|
|
116
|
-
if (subject && payload.sub !== subject) {
|
|
116
|
+
if (subject !== undefined && payload.sub !== subject) {
|
|
117
117
|
throw new JWTClaimValidationFailed('unexpected "sub" claim value', payload, 'sub', 'check_failed');
|
|
118
118
|
}
|
|
119
|
-
if (audience &&
|
|
119
|
+
if (audience !== undefined &&
|
|
120
120
|
!checkAudiencePresence(payload.aud, typeof audience === 'string' ? [audience] : audience)) {
|
|
121
121
|
throw new JWTClaimValidationFailed('unexpected "aud" claim value', payload, 'aud', 'check_failed');
|
|
122
122
|
}
|
|
@@ -134,9 +134,10 @@ export function validateClaimsSet(protectedHeader, encodedPayload, options = {})
|
|
|
134
134
|
default:
|
|
135
135
|
throw new TypeError('Invalid clockTolerance option type');
|
|
136
136
|
}
|
|
137
|
+
validateInput('clockTolerance option', tolerance);
|
|
137
138
|
const { currentDate } = options;
|
|
138
|
-
const now = epoch(currentDate || new Date());
|
|
139
|
-
if ((payload.iat !== undefined || maxTokenAge) && typeof payload.iat !== 'number') {
|
|
139
|
+
const now = validateInput('currentDate option', epoch(currentDate || new Date()));
|
|
140
|
+
if ((payload.iat !== undefined || maxTokenAge !== undefined) && typeof payload.iat !== 'number') {
|
|
140
141
|
throw new JWTClaimValidationFailed('"iat" claim must be a number', payload, 'iat', 'invalid');
|
|
141
142
|
}
|
|
142
143
|
if (payload.nbf !== undefined) {
|
|
@@ -155,7 +156,7 @@ export function validateClaimsSet(protectedHeader, encodedPayload, options = {})
|
|
|
155
156
|
throw new JWTExpired('"exp" claim timestamp check failed', payload, 'exp', 'check_failed');
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
|
-
if (maxTokenAge) {
|
|
159
|
+
if (maxTokenAge !== undefined) {
|
|
159
160
|
const age = now - payload.iat;
|
|
160
161
|
const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs(maxTokenAge);
|
|
161
162
|
if (age - tolerance > max) {
|