@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
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decoder } from '../lib/buffer_utils.js';
|
|
3
|
-
import { isObject } from '../lib/type_checks.js';
|
|
1
|
+
import { parseJoseHeader } from '../lib/helpers.js';
|
|
4
2
|
export function decodeProtectedHeader(token) {
|
|
5
3
|
let protectedB64u;
|
|
6
4
|
if (typeof token === 'string') {
|
|
@@ -18,17 +16,9 @@ export function decodeProtectedHeader(token) {
|
|
|
18
16
|
throw new TypeError('Token does not contain a Protected Header');
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
const result = JSON.parse(decoder.decode(b64u(protectedB64u)));
|
|
26
|
-
if (!isObject(result)) {
|
|
27
|
-
throw new Error();
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
throw new TypeError('Invalid Token or Protected Header formatting');
|
|
19
|
+
const invalid = 'Invalid Token or Protected Header formatting';
|
|
20
|
+
if (typeof protectedB64u !== 'string' || !protectedB64u) {
|
|
21
|
+
throw new TypeError(invalid);
|
|
33
22
|
}
|
|
23
|
+
return parseJoseHeader(protectedB64u, TypeError, invalid);
|
|
34
24
|
}
|
|
@@ -76,7 +76,7 @@ export class JWKSNoMatchingKey extends JOSEError {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
export class JWKSMultipleMatchingKeys extends JOSEError {
|
|
79
|
-
[Symbol.asyncIterator];
|
|
79
|
+
[Symbol.asyncIterator] = async function* () { };
|
|
80
80
|
static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
|
81
81
|
code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
|
82
82
|
constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jose",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.5",
|
|
4
4
|
"description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"akp",
|
|
@@ -193,8 +193,6 @@
|
|
|
193
193
|
"!dist/**/*.bundle.js",
|
|
194
194
|
"!dist/**/*.umd.js",
|
|
195
195
|
"!dist/**/*.min.js",
|
|
196
|
-
"!dist/types/
|
|
197
|
-
"!dist/types/lib/*",
|
|
198
|
-
"!dist/deno/**/*"
|
|
196
|
+
"!dist/types/lib/**"
|
|
199
197
|
]
|
|
200
198
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "6.73.
|
|
3
|
+
"version": "6.73.28",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@opentelemetry/api": "1.9.0",
|
|
28
28
|
"@opentelemetry/api-logs": "0.220.0",
|
|
29
29
|
"@swc/core": "1.10.18",
|
|
30
|
-
"@zuplo/core": "6.73.
|
|
30
|
+
"@zuplo/core": "6.73.28",
|
|
31
31
|
"@zuplo/editor": "1.0.29844086763",
|
|
32
|
-
"@zuplo/openapi-tools": "6.73.
|
|
33
|
-
"@zuplo/runtime": "6.73.
|
|
32
|
+
"@zuplo/openapi-tools": "6.73.28",
|
|
33
|
+
"@zuplo/runtime": "6.73.28",
|
|
34
34
|
"chalk": "5.4.1",
|
|
35
35
|
"chokidar": "3.5.3",
|
|
36
36
|
"cookie": "1.0.2",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"workerd": "1.20241230.0",
|
|
62
62
|
"yargs": "17.7.2",
|
|
63
63
|
"zod": "3.25.76",
|
|
64
|
-
"@zuplo/graphql": "6.73.
|
|
65
|
-
"@zuplo/otel": "6.73.
|
|
64
|
+
"@zuplo/graphql": "6.73.28",
|
|
65
|
+
"@zuplo/otel": "6.73.28"
|
|
66
66
|
},
|
|
67
67
|
"bundleDependencies": [
|
|
68
68
|
"@inquirer/prompts",
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/aesgcmkw.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { encrypt, decrypt } from './content_encryption.js';
|
|
2
|
-
import { encode as b64u } from '../util/base64url.js';
|
|
3
|
-
export async function wrap(alg, key, cek, iv) {
|
|
4
|
-
const jweAlgorithm = alg.slice(0, 7);
|
|
5
|
-
const wrapped = await encrypt(jweAlgorithm, cek, key, iv, new Uint8Array());
|
|
6
|
-
return {
|
|
7
|
-
encryptedKey: wrapped.ciphertext,
|
|
8
|
-
iv: b64u(wrapped.iv),
|
|
9
|
-
tag: b64u(wrapped.tag),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export async function unwrap(alg, key, encryptedKey, iv, tag) {
|
|
13
|
-
const jweAlgorithm = alg.slice(0, 7);
|
|
14
|
-
return decrypt(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array());
|
|
15
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { checkEncCryptoKey } from './crypto_key.js';
|
|
2
|
-
function checkKeySize(key, alg) {
|
|
3
|
-
if (key.algorithm.length !== parseInt(alg.slice(1, 4), 10)) {
|
|
4
|
-
throw new TypeError(`Invalid key size for alg: ${alg}`);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
function getCryptoKey(key, alg, usage) {
|
|
8
|
-
if (key instanceof Uint8Array) {
|
|
9
|
-
return crypto.subtle.importKey('raw', key, 'AES-KW', true, [usage]);
|
|
10
|
-
}
|
|
11
|
-
checkEncCryptoKey(key, alg, usage);
|
|
12
|
-
return key;
|
|
13
|
-
}
|
|
14
|
-
export async function wrap(alg, key, cek) {
|
|
15
|
-
const cryptoKey = await getCryptoKey(key, alg, 'wrapKey');
|
|
16
|
-
checkKeySize(cryptoKey, alg);
|
|
17
|
-
const cryptoKeyCek = await crypto.subtle.importKey('raw', cek, { hash: 'SHA-256', name: 'HMAC' }, true, ['sign']);
|
|
18
|
-
return new Uint8Array(await crypto.subtle.wrapKey('raw', cryptoKeyCek, cryptoKey, 'AES-KW'));
|
|
19
|
-
}
|
|
20
|
-
export async function unwrap(alg, key, encryptedKey) {
|
|
21
|
-
const cryptoKey = await getCryptoKey(key, alg, 'unwrapKey');
|
|
22
|
-
checkKeySize(cryptoKey, alg);
|
|
23
|
-
const cryptoKeyCek = await crypto.subtle.unwrapKey('raw', encryptedKey, cryptoKey, 'AES-KW', { hash: 'SHA-256', name: 'HMAC' }, true, ['sign']);
|
|
24
|
-
return new Uint8Array(await crypto.subtle.exportKey('raw', cryptoKeyCek));
|
|
25
|
-
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/check_key_type.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { withAlg as invalidKeyInput } from './invalid_key_input.js';
|
|
2
|
-
import { isKeyLike } from './is_key_like.js';
|
|
3
|
-
import * as jwk from './type_checks.js';
|
|
4
|
-
const tag = (key) => key?.[Symbol.toStringTag];
|
|
5
|
-
const jwkMatchesOp = (alg, key, usage) => {
|
|
6
|
-
if (key.use !== undefined) {
|
|
7
|
-
let expected;
|
|
8
|
-
switch (usage) {
|
|
9
|
-
case 'sign':
|
|
10
|
-
case 'verify':
|
|
11
|
-
expected = 'sig';
|
|
12
|
-
break;
|
|
13
|
-
case 'encrypt':
|
|
14
|
-
case 'decrypt':
|
|
15
|
-
expected = 'enc';
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
if (key.use !== expected) {
|
|
19
|
-
throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (key.alg !== undefined && key.alg !== alg) {
|
|
23
|
-
throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
24
|
-
}
|
|
25
|
-
if (Array.isArray(key.key_ops)) {
|
|
26
|
-
let expectedKeyOp;
|
|
27
|
-
switch (true) {
|
|
28
|
-
case usage === 'sign' || usage === 'verify':
|
|
29
|
-
case alg === 'dir':
|
|
30
|
-
case alg.includes('CBC-HS'):
|
|
31
|
-
expectedKeyOp = usage;
|
|
32
|
-
break;
|
|
33
|
-
case alg.startsWith('PBES2'):
|
|
34
|
-
expectedKeyOp = 'deriveBits';
|
|
35
|
-
break;
|
|
36
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
|
|
37
|
-
if (!alg.includes('GCM') && alg.endsWith('KW')) {
|
|
38
|
-
expectedKeyOp = usage === 'encrypt' ? 'wrapKey' : 'unwrapKey';
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
expectedKeyOp = usage;
|
|
42
|
-
}
|
|
43
|
-
break;
|
|
44
|
-
case usage === 'encrypt' && alg.startsWith('RSA'):
|
|
45
|
-
expectedKeyOp = 'wrapKey';
|
|
46
|
-
break;
|
|
47
|
-
case usage === 'decrypt':
|
|
48
|
-
expectedKeyOp = alg.startsWith('RSA') ? 'unwrapKey' : 'deriveBits';
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
|
|
52
|
-
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
};
|
|
57
|
-
const symmetricTypeCheck = (alg, key, usage) => {
|
|
58
|
-
if (key instanceof Uint8Array)
|
|
59
|
-
return;
|
|
60
|
-
if (jwk.isJWK(key)) {
|
|
61
|
-
if (jwk.isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
62
|
-
return;
|
|
63
|
-
throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
|
|
64
|
-
}
|
|
65
|
-
if (!isKeyLike(key)) {
|
|
66
|
-
throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key', 'Uint8Array'));
|
|
67
|
-
}
|
|
68
|
-
if (key.type !== 'secret') {
|
|
69
|
-
throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const asymmetricTypeCheck = (alg, key, usage) => {
|
|
73
|
-
if (jwk.isJWK(key)) {
|
|
74
|
-
switch (usage) {
|
|
75
|
-
case 'decrypt':
|
|
76
|
-
case 'sign':
|
|
77
|
-
if (jwk.isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
78
|
-
return;
|
|
79
|
-
throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
|
|
80
|
-
case 'encrypt':
|
|
81
|
-
case 'verify':
|
|
82
|
-
if (jwk.isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
83
|
-
return;
|
|
84
|
-
throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (!isKeyLike(key)) {
|
|
88
|
-
throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));
|
|
89
|
-
}
|
|
90
|
-
if (key.type === 'secret') {
|
|
91
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
92
|
-
}
|
|
93
|
-
if (key.type === 'public') {
|
|
94
|
-
switch (usage) {
|
|
95
|
-
case 'sign':
|
|
96
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
97
|
-
case 'decrypt':
|
|
98
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (key.type === 'private') {
|
|
102
|
-
switch (usage) {
|
|
103
|
-
case 'verify':
|
|
104
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
105
|
-
case 'encrypt':
|
|
106
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
export function checkKeyType(alg, key, usage) {
|
|
111
|
-
switch (alg.substring(0, 2)) {
|
|
112
|
-
case 'A1':
|
|
113
|
-
case 'A2':
|
|
114
|
-
case 'di':
|
|
115
|
-
case 'HS':
|
|
116
|
-
case 'PB':
|
|
117
|
-
symmetricTypeCheck(alg, key, usage);
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
asymmetricTypeCheck(alg, key, usage);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { encode, concat, uint32be } from './buffer_utils.js';
|
|
2
|
-
import { checkEncCryptoKey } from './crypto_key.js';
|
|
3
|
-
import { digest } from './helpers.js';
|
|
4
|
-
function lengthAndInput(input) {
|
|
5
|
-
return concat(uint32be(input.length), input);
|
|
6
|
-
}
|
|
7
|
-
async function concatKdf(Z, L, OtherInfo) {
|
|
8
|
-
const dkLen = L >> 3;
|
|
9
|
-
const hashLen = 32;
|
|
10
|
-
const reps = Math.ceil(dkLen / hashLen);
|
|
11
|
-
const dk = new Uint8Array(reps * hashLen);
|
|
12
|
-
for (let i = 1; i <= reps; i++) {
|
|
13
|
-
const hashInput = new Uint8Array(4 + Z.length + OtherInfo.length);
|
|
14
|
-
hashInput.set(uint32be(i), 0);
|
|
15
|
-
hashInput.set(Z, 4);
|
|
16
|
-
hashInput.set(OtherInfo, 4 + Z.length);
|
|
17
|
-
const hashResult = await digest('sha256', hashInput);
|
|
18
|
-
dk.set(hashResult, (i - 1) * hashLen);
|
|
19
|
-
}
|
|
20
|
-
return dk.slice(0, dkLen);
|
|
21
|
-
}
|
|
22
|
-
export async function deriveKey(publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(), apv = new Uint8Array()) {
|
|
23
|
-
checkEncCryptoKey(publicKey, 'ECDH');
|
|
24
|
-
checkEncCryptoKey(privateKey, 'ECDH', 'deriveBits');
|
|
25
|
-
const algorithmID = lengthAndInput(encode(algorithm));
|
|
26
|
-
const partyUInfo = lengthAndInput(apu);
|
|
27
|
-
const partyVInfo = lengthAndInput(apv);
|
|
28
|
-
const suppPubInfo = uint32be(keyLength);
|
|
29
|
-
const suppPrivInfo = new Uint8Array();
|
|
30
|
-
const otherInfo = concat(algorithmID, partyUInfo, partyVInfo, suppPubInfo, suppPrivInfo);
|
|
31
|
-
const Z = new Uint8Array(await crypto.subtle.deriveBits({
|
|
32
|
-
name: publicKey.algorithm.name,
|
|
33
|
-
public: publicKey,
|
|
34
|
-
}, privateKey, getEcdhBitLength(publicKey)));
|
|
35
|
-
return concatKdf(Z, keyLength, otherInfo);
|
|
36
|
-
}
|
|
37
|
-
function getEcdhBitLength(publicKey) {
|
|
38
|
-
if (publicKey.algorithm.name === 'X25519') {
|
|
39
|
-
return 256;
|
|
40
|
-
}
|
|
41
|
-
return (Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3);
|
|
42
|
-
}
|
|
43
|
-
export function allowed(key) {
|
|
44
|
-
switch (key.algorithm.namedCurve) {
|
|
45
|
-
case 'P-256':
|
|
46
|
-
case 'P-384':
|
|
47
|
-
case 'P-521':
|
|
48
|
-
return true;
|
|
49
|
-
default:
|
|
50
|
-
return key.algorithm.name === 'X25519';
|
|
51
|
-
}
|
|
52
|
-
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_to_jwk.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { invalidKeyInput } from './invalid_key_input.js';
|
|
2
|
-
import { encode as b64u } from '../util/base64url.js';
|
|
3
|
-
import { isCryptoKey, isKeyObject } from './is_key_like.js';
|
|
4
|
-
function omitUndefinedProperties(jwk) {
|
|
5
|
-
return Object.fromEntries(Object.entries(jwk).filter(([, value]) => value !== undefined));
|
|
6
|
-
}
|
|
7
|
-
export async function keyToJWK(key) {
|
|
8
|
-
if (isKeyObject(key)) {
|
|
9
|
-
if (key.type === 'secret') {
|
|
10
|
-
key = key.export();
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return key.export({ format: 'jwk' });
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (key instanceof Uint8Array) {
|
|
17
|
-
return {
|
|
18
|
-
kty: 'oct',
|
|
19
|
-
k: b64u(key),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if (!isCryptoKey(key)) {
|
|
23
|
-
throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'Uint8Array'));
|
|
24
|
-
}
|
|
25
|
-
if (!key.extractable) {
|
|
26
|
-
throw new TypeError('non-extractable CryptoKey cannot be exported as a JWK');
|
|
27
|
-
}
|
|
28
|
-
const { ext, key_ops, alg, use, ...jwk } = omitUndefinedProperties(await crypto.subtle.exportKey('jwk', key));
|
|
29
|
-
if (jwk.kty === 'AKP') {
|
|
30
|
-
;
|
|
31
|
-
jwk.alg = alg;
|
|
32
|
-
}
|
|
33
|
-
return jwk;
|
|
34
|
-
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/normalize_key.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { isJWK } from './type_checks.js';
|
|
2
|
-
import { decode } from '../util/base64url.js';
|
|
3
|
-
import { jwkToKey } from './jwk_to_key.js';
|
|
4
|
-
import { isCryptoKey, isKeyObject } from './is_key_like.js';
|
|
5
|
-
const unusableForAlg = 'given KeyObject instance cannot be used for this algorithm';
|
|
6
|
-
let cache;
|
|
7
|
-
const handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
8
|
-
cache ||= new WeakMap();
|
|
9
|
-
let cached = cache.get(key);
|
|
10
|
-
if (cached?.[alg]) {
|
|
11
|
-
return cached[alg];
|
|
12
|
-
}
|
|
13
|
-
const cryptoKey = await jwkToKey({ ...jwk, alg });
|
|
14
|
-
if (freeze)
|
|
15
|
-
Object.freeze(key);
|
|
16
|
-
if (!cached) {
|
|
17
|
-
cache.set(key, { [alg]: cryptoKey });
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
cached[alg] = cryptoKey;
|
|
21
|
-
}
|
|
22
|
-
return cryptoKey;
|
|
23
|
-
};
|
|
24
|
-
const handleKeyObject = (keyObject, alg) => {
|
|
25
|
-
cache ||= new WeakMap();
|
|
26
|
-
let cached = cache.get(keyObject);
|
|
27
|
-
if (cached?.[alg]) {
|
|
28
|
-
return cached[alg];
|
|
29
|
-
}
|
|
30
|
-
const isPublic = keyObject.type === 'public';
|
|
31
|
-
const extractable = isPublic ? true : false;
|
|
32
|
-
let cryptoKey;
|
|
33
|
-
if (keyObject.asymmetricKeyType === 'x25519') {
|
|
34
|
-
switch (alg) {
|
|
35
|
-
case 'ECDH-ES':
|
|
36
|
-
case 'ECDH-ES+A128KW':
|
|
37
|
-
case 'ECDH-ES+A192KW':
|
|
38
|
-
case 'ECDH-ES+A256KW':
|
|
39
|
-
break;
|
|
40
|
-
default:
|
|
41
|
-
throw new TypeError(unusableForAlg);
|
|
42
|
-
}
|
|
43
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ['deriveBits']);
|
|
44
|
-
}
|
|
45
|
-
if (keyObject.asymmetricKeyType === 'ed25519') {
|
|
46
|
-
if (alg !== 'EdDSA' && alg !== 'Ed25519') {
|
|
47
|
-
throw new TypeError(unusableForAlg);
|
|
48
|
-
}
|
|
49
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
50
|
-
isPublic ? 'verify' : 'sign',
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
switch (keyObject.asymmetricKeyType) {
|
|
54
|
-
case 'ml-dsa-44':
|
|
55
|
-
case 'ml-dsa-65':
|
|
56
|
-
case 'ml-dsa-87': {
|
|
57
|
-
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
58
|
-
throw new TypeError(unusableForAlg);
|
|
59
|
-
}
|
|
60
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
61
|
-
isPublic ? 'verify' : 'sign',
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (keyObject.asymmetricKeyType === 'rsa') {
|
|
66
|
-
let hash;
|
|
67
|
-
switch (alg) {
|
|
68
|
-
case 'RSA-OAEP':
|
|
69
|
-
hash = 'SHA-1';
|
|
70
|
-
break;
|
|
71
|
-
case 'RS256':
|
|
72
|
-
case 'PS256':
|
|
73
|
-
case 'RSA-OAEP-256':
|
|
74
|
-
hash = 'SHA-256';
|
|
75
|
-
break;
|
|
76
|
-
case 'RS384':
|
|
77
|
-
case 'PS384':
|
|
78
|
-
case 'RSA-OAEP-384':
|
|
79
|
-
hash = 'SHA-384';
|
|
80
|
-
break;
|
|
81
|
-
case 'RS512':
|
|
82
|
-
case 'PS512':
|
|
83
|
-
case 'RSA-OAEP-512':
|
|
84
|
-
hash = 'SHA-512';
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
throw new TypeError(unusableForAlg);
|
|
88
|
-
}
|
|
89
|
-
if (alg.startsWith('RSA-OAEP')) {
|
|
90
|
-
return keyObject.toCryptoKey({
|
|
91
|
-
name: 'RSA-OAEP',
|
|
92
|
-
hash,
|
|
93
|
-
}, extractable, isPublic ? ['encrypt'] : ['decrypt']);
|
|
94
|
-
}
|
|
95
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
96
|
-
name: alg.startsWith('PS') ? 'RSA-PSS' : 'RSASSA-PKCS1-v1_5',
|
|
97
|
-
hash,
|
|
98
|
-
}, extractable, [isPublic ? 'verify' : 'sign']);
|
|
99
|
-
}
|
|
100
|
-
if (keyObject.asymmetricKeyType === 'ec') {
|
|
101
|
-
const nist = new Map([
|
|
102
|
-
['prime256v1', 'P-256'],
|
|
103
|
-
['secp384r1', 'P-384'],
|
|
104
|
-
['secp521r1', 'P-521'],
|
|
105
|
-
]);
|
|
106
|
-
const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
107
|
-
if (!namedCurve) {
|
|
108
|
-
throw new TypeError(unusableForAlg);
|
|
109
|
-
}
|
|
110
|
-
const expectedCurve = { ES256: 'P-256', ES384: 'P-384', ES512: 'P-521' };
|
|
111
|
-
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
|
|
112
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
113
|
-
name: 'ECDSA',
|
|
114
|
-
namedCurve,
|
|
115
|
-
}, extractable, [isPublic ? 'verify' : 'sign']);
|
|
116
|
-
}
|
|
117
|
-
if (alg.startsWith('ECDH-ES')) {
|
|
118
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
119
|
-
name: 'ECDH',
|
|
120
|
-
namedCurve,
|
|
121
|
-
}, extractable, isPublic ? [] : ['deriveBits']);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (!cryptoKey) {
|
|
125
|
-
throw new TypeError(unusableForAlg);
|
|
126
|
-
}
|
|
127
|
-
if (!cached) {
|
|
128
|
-
cache.set(keyObject, { [alg]: cryptoKey });
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
cached[alg] = cryptoKey;
|
|
132
|
-
}
|
|
133
|
-
return cryptoKey;
|
|
134
|
-
};
|
|
135
|
-
export async function normalizeKey(key, alg) {
|
|
136
|
-
if (key instanceof Uint8Array) {
|
|
137
|
-
return key;
|
|
138
|
-
}
|
|
139
|
-
if (isCryptoKey(key)) {
|
|
140
|
-
return key;
|
|
141
|
-
}
|
|
142
|
-
if (isKeyObject(key)) {
|
|
143
|
-
if (key.type === 'secret') {
|
|
144
|
-
return key.export();
|
|
145
|
-
}
|
|
146
|
-
if ('toCryptoKey' in key && typeof key.toCryptoKey === 'function') {
|
|
147
|
-
try {
|
|
148
|
-
return handleKeyObject(key, alg);
|
|
149
|
-
}
|
|
150
|
-
catch (err) {
|
|
151
|
-
if (err instanceof TypeError) {
|
|
152
|
-
throw err;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
let jwk = key.export({ format: 'jwk' });
|
|
157
|
-
return handleJWK(key, jwk, alg);
|
|
158
|
-
}
|
|
159
|
-
if (isJWK(key)) {
|
|
160
|
-
if (key.k) {
|
|
161
|
-
return decode(key.k);
|
|
162
|
-
}
|
|
163
|
-
return handleJWK(key, key, alg, true);
|
|
164
|
-
}
|
|
165
|
-
throw new Error('unreachable');
|
|
166
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { encode as b64u } from '../util/base64url.js';
|
|
2
|
-
import * as aeskw from './aeskw.js';
|
|
3
|
-
import { checkEncCryptoKey } from './crypto_key.js';
|
|
4
|
-
import { concat, encode } from './buffer_utils.js';
|
|
5
|
-
import { JWEInvalid } from '../util/errors.js';
|
|
6
|
-
function getCryptoKey(key, alg) {
|
|
7
|
-
if (key instanceof Uint8Array) {
|
|
8
|
-
return crypto.subtle.importKey('raw', key, 'PBKDF2', false, [
|
|
9
|
-
'deriveBits',
|
|
10
|
-
]);
|
|
11
|
-
}
|
|
12
|
-
checkEncCryptoKey(key, alg, 'deriveBits');
|
|
13
|
-
return key;
|
|
14
|
-
}
|
|
15
|
-
const concatSalt = (alg, p2sInput) => concat(encode(alg), Uint8Array.of(0x00), p2sInput);
|
|
16
|
-
async function deriveKey(p2s, alg, p2c, key) {
|
|
17
|
-
if (!(p2s instanceof Uint8Array) || p2s.length < 8) {
|
|
18
|
-
throw new JWEInvalid('PBES2 Salt Input must be 8 or more octets');
|
|
19
|
-
}
|
|
20
|
-
if (!Number.isSafeInteger(p2c) || Math.sign(p2c) !== 1) {
|
|
21
|
-
throw new JWEInvalid('PBES2 Count Input must be a positive integer');
|
|
22
|
-
}
|
|
23
|
-
const salt = concatSalt(alg, p2s);
|
|
24
|
-
const keylen = parseInt(alg.slice(13, 16), 10);
|
|
25
|
-
const subtleAlg = {
|
|
26
|
-
hash: `SHA-${alg.slice(8, 11)}`,
|
|
27
|
-
iterations: p2c,
|
|
28
|
-
name: 'PBKDF2',
|
|
29
|
-
salt,
|
|
30
|
-
};
|
|
31
|
-
const cryptoKey = await getCryptoKey(key, alg);
|
|
32
|
-
return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey, keylen));
|
|
33
|
-
}
|
|
34
|
-
export async function wrap(alg, key, cek, p2c = 2048, p2s = crypto.getRandomValues(new Uint8Array(16))) {
|
|
35
|
-
const derived = await deriveKey(p2s, alg, p2c, key);
|
|
36
|
-
const encryptedKey = await aeskw.wrap(alg.slice(-6), derived, cek);
|
|
37
|
-
return { encryptedKey, p2c, p2s: b64u(p2s) };
|
|
38
|
-
}
|
|
39
|
-
export async function unwrap(alg, key, encryptedKey, p2c, p2s) {
|
|
40
|
-
const derived = await deriveKey(p2s, alg, p2c, key);
|
|
41
|
-
return aeskw.unwrap(alg.slice(-6), derived, encryptedKey);
|
|
42
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { checkEncCryptoKey } from './crypto_key.js';
|
|
2
|
-
import { checkKeyLength } from './signing.js';
|
|
3
|
-
import { JOSENotSupported } from '../util/errors.js';
|
|
4
|
-
const subtleAlgorithm = (alg) => {
|
|
5
|
-
switch (alg) {
|
|
6
|
-
case 'RSA-OAEP':
|
|
7
|
-
case 'RSA-OAEP-256':
|
|
8
|
-
case 'RSA-OAEP-384':
|
|
9
|
-
case 'RSA-OAEP-512':
|
|
10
|
-
return 'RSA-OAEP';
|
|
11
|
-
default:
|
|
12
|
-
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
export async function encrypt(alg, key, cek) {
|
|
16
|
-
checkEncCryptoKey(key, alg, 'encrypt');
|
|
17
|
-
checkKeyLength(alg, key);
|
|
18
|
-
return new Uint8Array(await crypto.subtle.encrypt(subtleAlgorithm(alg), key, cek));
|
|
19
|
-
}
|
|
20
|
-
export async function decrypt(alg, key, encryptedKey) {
|
|
21
|
-
checkEncCryptoKey(key, alg, 'decrypt');
|
|
22
|
-
checkKeyLength(alg, key);
|
|
23
|
-
return new Uint8Array(await crypto.subtle.decrypt(subtleAlgorithm(alg), key, encryptedKey));
|
|
24
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function validateAlgorithms(option, algorithms) {
|
|
2
|
-
if (algorithms !== undefined &&
|
|
3
|
-
(!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {
|
|
4
|
-
throw new TypeError(`"${option}" option must be an array of strings`);
|
|
5
|
-
}
|
|
6
|
-
if (!algorithms) {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
return new Set(algorithms);
|
|
10
|
-
}
|