@keycardai/mcp 0.4.0 → 0.6.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/LICENSE +5 -17
- package/README.md +4 -0
- package/dist/cjs/server/auth/credentials.d.ts +6 -43
- package/dist/cjs/server/auth/credentials.d.ts.map +1 -1
- package/dist/cjs/server/auth/credentials.js +6 -184
- package/dist/cjs/server/auth/credentials.js.map +1 -1
- package/dist/cjs/server/auth/errors.d.ts +1 -7
- package/dist/cjs/server/auth/errors.d.ts.map +1 -1
- package/dist/cjs/server/auth/errors.js +2 -14
- package/dist/cjs/server/auth/errors.js.map +1 -1
- package/dist/cjs/server/auth/middleware/bearerAuth.js +1 -1
- package/dist/cjs/server/auth/middleware/bearerAuth.js.map +1 -1
- package/dist/cjs/server/auth/privateKey.d.ts +2 -46
- package/dist/cjs/server/auth/privateKey.d.ts.map +1 -1
- package/dist/cjs/server/auth/privateKey.js +3 -231
- package/dist/cjs/server/auth/privateKey.js.map +1 -1
- package/dist/cjs/server/auth/provider.d.ts +3 -29
- package/dist/cjs/server/auth/provider.d.ts.map +1 -1
- package/dist/cjs/server/auth/provider.js +12 -87
- package/dist/cjs/server/auth/provider.js.map +1 -1
- package/dist/cjs/server/auth/router.d.ts +1 -0
- package/dist/cjs/server/auth/router.d.ts.map +1 -1
- package/dist/cjs/server/auth/router.js +3 -0
- package/dist/cjs/server/auth/router.js.map +1 -1
- package/dist/esm/server/auth/credentials.d.ts +6 -43
- package/dist/esm/server/auth/credentials.d.ts.map +1 -1
- package/dist/esm/server/auth/credentials.js +3 -148
- package/dist/esm/server/auth/credentials.js.map +1 -1
- package/dist/esm/server/auth/errors.d.ts +1 -7
- package/dist/esm/server/auth/errors.d.ts.map +1 -1
- package/dist/esm/server/auth/errors.js +1 -13
- package/dist/esm/server/auth/errors.js.map +1 -1
- package/dist/esm/server/auth/middleware/bearerAuth.js +1 -1
- package/dist/esm/server/auth/middleware/bearerAuth.js.map +1 -1
- package/dist/esm/server/auth/privateKey.d.ts +2 -46
- package/dist/esm/server/auth/privateKey.d.ts.map +1 -1
- package/dist/esm/server/auth/privateKey.js +1 -196
- package/dist/esm/server/auth/privateKey.js.map +1 -1
- package/dist/esm/server/auth/provider.d.ts +3 -29
- package/dist/esm/server/auth/provider.d.ts.map +1 -1
- package/dist/esm/server/auth/provider.js +10 -85
- package/dist/esm/server/auth/provider.js.map +1 -1
- package/dist/esm/server/auth/router.d.ts +1 -0
- package/dist/esm/server/auth/router.d.ts.map +1 -1
- package/dist/esm/server/auth/router.js +1 -0
- package/dist/esm/server/auth/router.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,235 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
36
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
37
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
38
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
39
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
40
|
-
};
|
|
41
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
42
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
43
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
44
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
45
|
-
};
|
|
46
|
-
var _FilePrivateKeyStorage_instances, _FilePrivateKeyStorage_storageDir, _FilePrivateKeyStorage_keyPath, _FilePrivateKeyStorage_metadataPath, _PrivateKeyManager_instances, _PrivateKeyManager_storage, _PrivateKeyManager_keyId, _PrivateKeyManager_audienceConfig, _PrivateKeyManager_privateKeyPem, _PrivateKeyManager_publicKeyJwk, _PrivateKeyManager_generateAndStoreKeyPair, _PemPrivateKeyring_pem, _PemPrivateKeyring_kid, _PemPrivateKeyring_issuer;
|
|
47
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
3
|
exports.PrivateKeyManager = exports.FilePrivateKeyStorage = void 0;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const signer_1 = require("@keycardai/oauth/jwt/signer");
|
|
53
|
-
// =============================================================================
|
|
54
|
-
// File-Based Storage
|
|
55
|
-
// =============================================================================
|
|
56
|
-
class FilePrivateKeyStorage {
|
|
57
|
-
constructor(storageDir) {
|
|
58
|
-
_FilePrivateKeyStorage_instances.add(this);
|
|
59
|
-
_FilePrivateKeyStorage_storageDir.set(this, void 0);
|
|
60
|
-
__classPrivateFieldSet(this, _FilePrivateKeyStorage_storageDir, storageDir, "f");
|
|
61
|
-
}
|
|
62
|
-
async exists(keyId) {
|
|
63
|
-
try {
|
|
64
|
-
await fs.access(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_keyPath).call(this, keyId));
|
|
65
|
-
await fs.access(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_metadataPath).call(this, keyId));
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async storeKeyPair(keyId, privateKeyPem, publicKeyJwk) {
|
|
73
|
-
await fs.mkdir(__classPrivateFieldGet(this, _FilePrivateKeyStorage_storageDir, "f"), { recursive: true });
|
|
74
|
-
const metadata = {
|
|
75
|
-
key_id: keyId,
|
|
76
|
-
public_key_jwk: publicKeyJwk,
|
|
77
|
-
created_at: Date.now() / 1000,
|
|
78
|
-
algorithm: "RS256",
|
|
79
|
-
};
|
|
80
|
-
await fs.writeFile(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_keyPath).call(this, keyId), privateKeyPem, { encoding: "utf-8", mode: 0o600 });
|
|
81
|
-
await fs.writeFile(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_metadataPath).call(this, keyId), JSON.stringify(metadata, null, 2), { encoding: "utf-8", mode: 0o644 });
|
|
82
|
-
}
|
|
83
|
-
async loadKeyPair(keyId) {
|
|
84
|
-
const [privateKeyPem, metadataRaw] = await Promise.all([
|
|
85
|
-
fs.readFile(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_keyPath).call(this, keyId), "utf-8"),
|
|
86
|
-
fs.readFile(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_metadataPath).call(this, keyId), "utf-8"),
|
|
87
|
-
]);
|
|
88
|
-
const metadata = JSON.parse(metadataRaw);
|
|
89
|
-
return { privateKeyPem, publicKeyJwk: metadata.public_key_jwk };
|
|
90
|
-
}
|
|
91
|
-
async deleteKeyPair(keyId) {
|
|
92
|
-
let deleted = false;
|
|
93
|
-
try {
|
|
94
|
-
await fs.unlink(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_keyPath).call(this, keyId));
|
|
95
|
-
deleted = true;
|
|
96
|
-
}
|
|
97
|
-
catch { /* ignore */ }
|
|
98
|
-
try {
|
|
99
|
-
await fs.unlink(__classPrivateFieldGet(this, _FilePrivateKeyStorage_instances, "m", _FilePrivateKeyStorage_metadataPath).call(this, keyId));
|
|
100
|
-
deleted = true;
|
|
101
|
-
}
|
|
102
|
-
catch { /* ignore */ }
|
|
103
|
-
return deleted;
|
|
104
|
-
}
|
|
105
|
-
async listKeyIds() {
|
|
106
|
-
try {
|
|
107
|
-
const files = await fs.readdir(__classPrivateFieldGet(this, _FilePrivateKeyStorage_storageDir, "f"));
|
|
108
|
-
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
|
109
|
-
const keyIds = [];
|
|
110
|
-
for (const file of jsonFiles) {
|
|
111
|
-
const keyId = file.replace(/\.json$/, "");
|
|
112
|
-
if (await this.exists(keyId)) {
|
|
113
|
-
keyIds.push(keyId);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return keyIds.sort();
|
|
117
|
-
}
|
|
118
|
-
catch {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.FilePrivateKeyStorage = FilePrivateKeyStorage;
|
|
124
|
-
_FilePrivateKeyStorage_storageDir = new WeakMap(), _FilePrivateKeyStorage_instances = new WeakSet(), _FilePrivateKeyStorage_keyPath = function _FilePrivateKeyStorage_keyPath(keyId) {
|
|
125
|
-
return path.join(__classPrivateFieldGet(this, _FilePrivateKeyStorage_storageDir, "f"), `${keyId}.pem`);
|
|
126
|
-
}, _FilePrivateKeyStorage_metadataPath = function _FilePrivateKeyStorage_metadataPath(keyId) {
|
|
127
|
-
return path.join(__classPrivateFieldGet(this, _FilePrivateKeyStorage_storageDir, "f"), `${keyId}.json`);
|
|
128
|
-
};
|
|
129
|
-
// =============================================================================
|
|
130
|
-
// Private Key Manager
|
|
131
|
-
// =============================================================================
|
|
132
|
-
class PrivateKeyManager {
|
|
133
|
-
constructor(options) {
|
|
134
|
-
_PrivateKeyManager_instances.add(this);
|
|
135
|
-
_PrivateKeyManager_storage.set(this, void 0);
|
|
136
|
-
_PrivateKeyManager_keyId.set(this, void 0);
|
|
137
|
-
_PrivateKeyManager_audienceConfig.set(this, void 0);
|
|
138
|
-
_PrivateKeyManager_privateKeyPem.set(this, void 0);
|
|
139
|
-
_PrivateKeyManager_publicKeyJwk.set(this, void 0);
|
|
140
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_storage, options.storage, "f");
|
|
141
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_keyId, options.keyId ?? crypto.randomUUID(), "f");
|
|
142
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_audienceConfig, options.audienceConfig, "f");
|
|
143
|
-
}
|
|
144
|
-
async bootstrapIdentity() {
|
|
145
|
-
if (await __classPrivateFieldGet(this, _PrivateKeyManager_storage, "f").exists(__classPrivateFieldGet(this, _PrivateKeyManager_keyId, "f"))) {
|
|
146
|
-
const { privateKeyPem, publicKeyJwk } = await __classPrivateFieldGet(this, _PrivateKeyManager_storage, "f").loadKeyPair(__classPrivateFieldGet(this, _PrivateKeyManager_keyId, "f"));
|
|
147
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_privateKeyPem, privateKeyPem, "f");
|
|
148
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_publicKeyJwk, publicKeyJwk, "f");
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
await __classPrivateFieldGet(this, _PrivateKeyManager_instances, "m", _PrivateKeyManager_generateAndStoreKeyPair).call(this);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
async createClientAssertion(issuer, audience, expirySeconds = 300) {
|
|
155
|
-
if (!__classPrivateFieldGet(this, _PrivateKeyManager_privateKeyPem, "f") || !__classPrivateFieldGet(this, _PrivateKeyManager_publicKeyJwk, "f")) {
|
|
156
|
-
throw new Error("Identity not bootstrapped. Call bootstrapIdentity() first.");
|
|
157
|
-
}
|
|
158
|
-
const keyring = new PemPrivateKeyring(__classPrivateFieldGet(this, _PrivateKeyManager_privateKeyPem, "f"), __classPrivateFieldGet(this, _PrivateKeyManager_keyId, "f"), issuer);
|
|
159
|
-
const signer = new signer_1.JWTSigner(keyring);
|
|
160
|
-
const now = Math.floor(Date.now() / 1000);
|
|
161
|
-
return signer.sign({
|
|
162
|
-
iss: issuer,
|
|
163
|
-
sub: issuer,
|
|
164
|
-
aud: audience,
|
|
165
|
-
jti: crypto.randomUUID(),
|
|
166
|
-
iat: now,
|
|
167
|
-
exp: now + expirySeconds,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
getPublicJwks() {
|
|
171
|
-
if (!__classPrivateFieldGet(this, _PrivateKeyManager_publicKeyJwk, "f")) {
|
|
172
|
-
throw new Error("Identity not bootstrapped. Call bootstrapIdentity() first.");
|
|
173
|
-
}
|
|
174
|
-
return { keys: [__classPrivateFieldGet(this, _PrivateKeyManager_publicKeyJwk, "f")] };
|
|
175
|
-
}
|
|
176
|
-
getClientId() {
|
|
177
|
-
return __classPrivateFieldGet(this, _PrivateKeyManager_keyId, "f");
|
|
178
|
-
}
|
|
179
|
-
getClientJwksUrl(resourceServerUrl) {
|
|
180
|
-
const url = new URL(resourceServerUrl);
|
|
181
|
-
return `${url.protocol}//${url.host}/.well-known/jwks.json`;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
exports.PrivateKeyManager = PrivateKeyManager;
|
|
185
|
-
_PrivateKeyManager_storage = new WeakMap(), _PrivateKeyManager_keyId = new WeakMap(), _PrivateKeyManager_audienceConfig = new WeakMap(), _PrivateKeyManager_privateKeyPem = new WeakMap(), _PrivateKeyManager_publicKeyJwk = new WeakMap(), _PrivateKeyManager_instances = new WeakSet(), _PrivateKeyManager_generateAndStoreKeyPair = async function _PrivateKeyManager_generateAndStoreKeyPair() {
|
|
186
|
-
const keyPair = crypto.generateKeyPairSync("rsa", {
|
|
187
|
-
modulusLength: 2048,
|
|
188
|
-
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
189
|
-
privateKeyEncoding: { type: "pkcs8", format: "pem" },
|
|
190
|
-
});
|
|
191
|
-
const privateKeyPem = String(keyPair.privateKey);
|
|
192
|
-
const publicKeyPem = String(keyPair.publicKey);
|
|
193
|
-
// Convert public key PEM to JWK format
|
|
194
|
-
const publicKeyObj = crypto.createPublicKey(publicKeyPem);
|
|
195
|
-
const jwk = publicKeyObj.export({ format: "jwk" });
|
|
196
|
-
const publicKeyJwk = {
|
|
197
|
-
kty: jwk.kty,
|
|
198
|
-
n: jwk.n,
|
|
199
|
-
e: jwk.e,
|
|
200
|
-
kid: __classPrivateFieldGet(this, _PrivateKeyManager_keyId, "f"),
|
|
201
|
-
alg: "RS256",
|
|
202
|
-
use: "sig",
|
|
203
|
-
};
|
|
204
|
-
await __classPrivateFieldGet(this, _PrivateKeyManager_storage, "f").storeKeyPair(__classPrivateFieldGet(this, _PrivateKeyManager_keyId, "f"), privateKeyPem, publicKeyJwk);
|
|
205
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_privateKeyPem, privateKeyPem, "f");
|
|
206
|
-
__classPrivateFieldSet(this, _PrivateKeyManager_publicKeyJwk, publicKeyJwk, "f");
|
|
207
|
-
};
|
|
208
|
-
// =============================================================================
|
|
209
|
-
// PEM-based PrivateKeyring adapter (implements PrivateKeyring from @keycardai/oauth)
|
|
210
|
-
// =============================================================================
|
|
211
|
-
class PemPrivateKeyring {
|
|
212
|
-
constructor(pem, kid, issuer) {
|
|
213
|
-
_PemPrivateKeyring_pem.set(this, void 0);
|
|
214
|
-
_PemPrivateKeyring_kid.set(this, void 0);
|
|
215
|
-
_PemPrivateKeyring_issuer.set(this, void 0);
|
|
216
|
-
__classPrivateFieldSet(this, _PemPrivateKeyring_pem, pem, "f");
|
|
217
|
-
__classPrivateFieldSet(this, _PemPrivateKeyring_kid, kid, "f");
|
|
218
|
-
__classPrivateFieldSet(this, _PemPrivateKeyring_issuer, issuer, "f");
|
|
219
|
-
}
|
|
220
|
-
async key(_usage) {
|
|
221
|
-
// Import PEM private key as CryptoKey
|
|
222
|
-
const keyObj = crypto.createPrivateKey(__classPrivateFieldGet(this, _PemPrivateKeyring_pem, "f"));
|
|
223
|
-
const jwk = keyObj.export({ format: "jwk" });
|
|
224
|
-
const cryptoKey = await crypto.subtle.importKey("jwk", jwk, { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } }, false, ["sign"]);
|
|
225
|
-
return {
|
|
226
|
-
// node:crypto.webcrypto.CryptoKey and global CryptoKey are identical at runtime
|
|
227
|
-
// but TypeScript treats them as separate declarations
|
|
228
|
-
key: cryptoKey,
|
|
229
|
-
kid: __classPrivateFieldGet(this, _PemPrivateKeyring_kid, "f"),
|
|
230
|
-
issuer: __classPrivateFieldGet(this, _PemPrivateKeyring_issuer, "f"),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
_PemPrivateKeyring_pem = new WeakMap(), _PemPrivateKeyring_kid = new WeakMap(), _PemPrivateKeyring_issuer = new WeakMap();
|
|
4
|
+
var server_1 = require("@keycardai/oauth/server");
|
|
5
|
+
Object.defineProperty(exports, "FilePrivateKeyStorage", { enumerable: true, get: function () { return server_1.FilePrivateKeyStorage; } });
|
|
6
|
+
Object.defineProperty(exports, "PrivateKeyManager", { enumerable: true, get: function () { return server_1.PrivateKeyManager; } });
|
|
235
7
|
//# sourceMappingURL=privateKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privateKey.js","sourceRoot":"","sources":["../../../../src/server/auth/privateKey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"privateKey.js","sourceRoot":"","sources":["../../../../src/server/auth/privateKey.ts"],"names":[],"mappings":";;;AAAA,kDAGiC;AAF/B,+GAAA,qBAAqB,OAAA;AACrB,2GAAA,iBAAiB,OAAA"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import type { Request, RequestHandler } from "express";
|
|
2
2
|
import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
|
|
3
|
-
import type { TokenResponse } from "@keycardai/oauth/tokenExchange";
|
|
4
3
|
import type { ApplicationCredential } from "./credentials.js";
|
|
4
|
+
import { AccessContext } from "@keycardai/oauth/server/accessContext";
|
|
5
5
|
export type { TokenResponse } from "@keycardai/oauth/tokenExchange";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
code?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
rawError?: string;
|
|
11
|
-
};
|
|
12
|
-
export type AccessContextStatus = "success" | "partial_error" | "error";
|
|
6
|
+
export { AccessContext } from "@keycardai/oauth/server/accessContext";
|
|
7
|
+
export type { ErrorDetail, AccessContextStatus } from "@keycardai/oauth/server/accessContext";
|
|
13
8
|
export interface AuthProviderOptions {
|
|
14
9
|
zoneUrl?: string;
|
|
15
10
|
zoneId?: string;
|
|
@@ -20,27 +15,6 @@ export interface DelegatedRequest extends Request {
|
|
|
20
15
|
auth: AuthInfo;
|
|
21
16
|
accessContext: AccessContext;
|
|
22
17
|
}
|
|
23
|
-
export declare class AccessContext {
|
|
24
|
-
#private;
|
|
25
|
-
constructor(accessTokens?: Record<string, TokenResponse>);
|
|
26
|
-
setToken(resource: string, token: TokenResponse): void;
|
|
27
|
-
setBulkTokens(tokens: Record<string, TokenResponse>): void;
|
|
28
|
-
setResourceError(resource: string, error: ErrorDetail): void;
|
|
29
|
-
setError(error: ErrorDetail): void;
|
|
30
|
-
access(resource: string): TokenResponse;
|
|
31
|
-
hasError(): boolean;
|
|
32
|
-
hasResourceError(resource: string): boolean;
|
|
33
|
-
hasErrors(): boolean;
|
|
34
|
-
getError(): ErrorDetail | null;
|
|
35
|
-
getResourceErrors(resource: string): ErrorDetail | null;
|
|
36
|
-
getErrors(): {
|
|
37
|
-
resources: Record<string, ErrorDetail>;
|
|
38
|
-
error: ErrorDetail | null;
|
|
39
|
-
};
|
|
40
|
-
getStatus(): AccessContextStatus;
|
|
41
|
-
getSuccessfulResources(): string[];
|
|
42
|
-
getFailedResources(): string[];
|
|
43
|
-
}
|
|
44
18
|
export declare class AuthProvider {
|
|
45
19
|
#private;
|
|
46
20
|
constructor(options: AuthProviderOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/server/auth/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/server/auth/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAK/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAOtE,YAAY,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE9F,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAiB,SAAQ,OAAO;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;CAC9B;AAMD,qBAAa,YAAY;;gBAMX,OAAO,EAAE,mBAAmB;IAWxC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,cAAc;IAoB7C,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;CA8EjG"}
|
|
@@ -1,99 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
2
7
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
8
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
9
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
12
|
};
|
|
8
|
-
var
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _AccessContext_accessTokens, _AccessContext_resourceErrors, _AccessContext_error, _AuthProvider_instances, _AuthProvider_zoneUrl, _AuthProvider_applicationCredential, _AuthProvider_client, _AuthProvider_clientPromise, _AuthProvider_getOrCreateClient, _AuthProvider_buildZoneUrl;
|
|
13
|
+
var _AuthProvider_instances, _AuthProvider_zoneUrl, _AuthProvider_applicationCredential, _AuthProvider_client, _AuthProvider_clientPromise, _AuthProvider_getOrCreateClient, _AuthProvider_buildZoneUrl;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AuthProvider = exports.AccessContext = void 0;
|
|
16
16
|
const tokenExchange_1 = require("@keycardai/oauth/tokenExchange");
|
|
17
17
|
const errors_1 = require("@keycardai/oauth/errors");
|
|
18
18
|
const errors_js_1 = require("./errors.js");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class AccessContext {
|
|
23
|
-
constructor(accessTokens) {
|
|
24
|
-
_AccessContext_accessTokens.set(this, void 0);
|
|
25
|
-
_AccessContext_resourceErrors.set(this, void 0);
|
|
26
|
-
_AccessContext_error.set(this, void 0);
|
|
27
|
-
__classPrivateFieldSet(this, _AccessContext_accessTokens, new Map(accessTokens ? Object.entries(accessTokens) : []), "f");
|
|
28
|
-
__classPrivateFieldSet(this, _AccessContext_resourceErrors, new Map(), "f");
|
|
29
|
-
__classPrivateFieldSet(this, _AccessContext_error, null, "f");
|
|
30
|
-
}
|
|
31
|
-
setToken(resource, token) {
|
|
32
|
-
__classPrivateFieldGet(this, _AccessContext_accessTokens, "f").set(resource, token);
|
|
33
|
-
__classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").delete(resource);
|
|
34
|
-
}
|
|
35
|
-
setBulkTokens(tokens) {
|
|
36
|
-
for (const [resource, token] of Object.entries(tokens)) {
|
|
37
|
-
__classPrivateFieldGet(this, _AccessContext_accessTokens, "f").set(resource, token);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
setResourceError(resource, error) {
|
|
41
|
-
__classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").set(resource, error);
|
|
42
|
-
__classPrivateFieldGet(this, _AccessContext_accessTokens, "f").delete(resource);
|
|
43
|
-
}
|
|
44
|
-
setError(error) {
|
|
45
|
-
__classPrivateFieldSet(this, _AccessContext_error, error, "f");
|
|
46
|
-
}
|
|
47
|
-
access(resource) {
|
|
48
|
-
if (__classPrivateFieldGet(this, _AccessContext_error, "f")) {
|
|
49
|
-
throw new errors_js_1.ResourceAccessError();
|
|
50
|
-
}
|
|
51
|
-
if (__classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").has(resource)) {
|
|
52
|
-
throw new errors_js_1.ResourceAccessError();
|
|
53
|
-
}
|
|
54
|
-
const token = __classPrivateFieldGet(this, _AccessContext_accessTokens, "f").get(resource);
|
|
55
|
-
if (!token) {
|
|
56
|
-
throw new errors_js_1.ResourceAccessError();
|
|
57
|
-
}
|
|
58
|
-
return token;
|
|
59
|
-
}
|
|
60
|
-
hasError() {
|
|
61
|
-
return __classPrivateFieldGet(this, _AccessContext_error, "f") !== null;
|
|
62
|
-
}
|
|
63
|
-
hasResourceError(resource) {
|
|
64
|
-
return __classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").has(resource);
|
|
65
|
-
}
|
|
66
|
-
hasErrors() {
|
|
67
|
-
return this.hasError() || __classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").size > 0;
|
|
68
|
-
}
|
|
69
|
-
getError() {
|
|
70
|
-
return __classPrivateFieldGet(this, _AccessContext_error, "f");
|
|
71
|
-
}
|
|
72
|
-
getResourceErrors(resource) {
|
|
73
|
-
return __classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").get(resource) ?? null;
|
|
74
|
-
}
|
|
75
|
-
getErrors() {
|
|
76
|
-
return {
|
|
77
|
-
resources: Object.fromEntries(__classPrivateFieldGet(this, _AccessContext_resourceErrors, "f")),
|
|
78
|
-
error: __classPrivateFieldGet(this, _AccessContext_error, "f"),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
getStatus() {
|
|
82
|
-
if (__classPrivateFieldGet(this, _AccessContext_error, "f"))
|
|
83
|
-
return "error";
|
|
84
|
-
if (__classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").size > 0)
|
|
85
|
-
return "partial_error";
|
|
86
|
-
return "success";
|
|
87
|
-
}
|
|
88
|
-
getSuccessfulResources() {
|
|
89
|
-
return Array.from(__classPrivateFieldGet(this, _AccessContext_accessTokens, "f").keys());
|
|
90
|
-
}
|
|
91
|
-
getFailedResources() {
|
|
92
|
-
return Array.from(__classPrivateFieldGet(this, _AccessContext_resourceErrors, "f").keys());
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.AccessContext = AccessContext;
|
|
96
|
-
_AccessContext_accessTokens = new WeakMap(), _AccessContext_resourceErrors = new WeakMap(), _AccessContext_error = new WeakMap();
|
|
19
|
+
const accessContext_1 = require("@keycardai/oauth/server/accessContext");
|
|
20
|
+
var accessContext_2 = require("@keycardai/oauth/server/accessContext");
|
|
21
|
+
Object.defineProperty(exports, "AccessContext", { enumerable: true, get: function () { return accessContext_2.AccessContext; } });
|
|
97
22
|
// =============================================================================
|
|
98
23
|
// AuthProvider
|
|
99
24
|
// =============================================================================
|
|
@@ -116,7 +41,7 @@ class AuthProvider {
|
|
|
116
41
|
const authReq = req;
|
|
117
42
|
const subjectToken = authReq.auth?.token;
|
|
118
43
|
if (!subjectToken) {
|
|
119
|
-
const accessCtx = new AccessContext();
|
|
44
|
+
const accessCtx = new accessContext_1.AccessContext();
|
|
120
45
|
accessCtx.setError({
|
|
121
46
|
message: "No authentication token available. Ensure requireBearerAuth() middleware runs before grant().",
|
|
122
47
|
});
|
|
@@ -129,7 +54,7 @@ class AuthProvider {
|
|
|
129
54
|
};
|
|
130
55
|
}
|
|
131
56
|
async exchangeTokens(subjectToken, resources) {
|
|
132
|
-
const accessCtx = new AccessContext();
|
|
57
|
+
const accessCtx = new accessContext_1.AccessContext();
|
|
133
58
|
const resourceList = Array.isArray(resources) ? resources : [resources];
|
|
134
59
|
let client;
|
|
135
60
|
try {
|
|
@@ -147,7 +72,7 @@ class AuthProvider {
|
|
|
147
72
|
try {
|
|
148
73
|
let request;
|
|
149
74
|
if (__classPrivateFieldGet(this, _AuthProvider_applicationCredential, "f")) {
|
|
150
|
-
const tokenEndpoint =
|
|
75
|
+
const tokenEndpoint = await client.getTokenEndpoint();
|
|
151
76
|
request = await __classPrivateFieldGet(this, _AuthProvider_applicationCredential, "f").prepareTokenExchangeRequest(subjectToken, resource, { tokenEndpoint });
|
|
152
77
|
}
|
|
153
78
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../src/server/auth/provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,kEAAqE;AAErE,oDAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../src/server/auth/provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,kEAAqE;AAErE,oDAAqD;AACrD,2CAA6D;AAE7D,yEAAsE;AAQtE,uEAAsE;AAA7D,8GAAA,aAAa,OAAA;AAetB,gFAAgF;AACh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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../src/server/auth/router.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../src/server/auth/router.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,uBAAuB,CAAC,EAAE,GAAG,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAmB1F;AAED,wBAAgB,oCAAoC,CAAC,WAAW,EAAE,GAAG,GAAG,MAAM,CAS7E"}
|
|
@@ -3,10 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.keycardMetadataRouter = void 0;
|
|
6
7
|
exports.mcpAuthMetadataRouter = mcpAuthMetadataRouter;
|
|
7
8
|
exports.getOAuthProtectedResourceMetadataUrl = getOAuthProtectedResourceMetadataUrl;
|
|
8
9
|
const express_1 = __importDefault(require("express"));
|
|
9
10
|
const metadata_js_1 = require("./handlers/metadata.js");
|
|
11
|
+
var express_2 = require("@keycardai/express");
|
|
12
|
+
Object.defineProperty(exports, "keycardMetadataRouter", { enumerable: true, get: function () { return express_2.keycardMetadataRouter; } });
|
|
10
13
|
function mcpAuthMetadataRouter(options) {
|
|
11
14
|
const router = express_1.default.Router();
|
|
12
15
|
const protectedResourceMetadata = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../src/server/auth/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../src/server/auth/router.ts"],"names":[],"mappings":";;;;;;AAaA,sDAmBC;AAED,oFASC;AA3CD,sDAA8B;AAE9B,wDAA8G;AAC9G,8CAA2D;AAAlD,gHAAA,qBAAqB,OAAA;AAU9B,SAAgB,qBAAqB,CAAC,OAAoC;IACxE,MAAM,MAAM,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,yBAAyB,GAA2C;QACxE,qBAAqB,EAAE;YACrB,OAAO,CAAC,aAAa,CAAC,MAAM;SAC7B;QAED,gBAAgB,EAAE,OAAO,CAAC,eAAe;QACzC,aAAa,EAAE,OAAO,CAAC,YAAY;QACnC,sBAAsB,EAAE,OAAO,CAAC,uBAAuB,EAAE,IAAI;KAC9D,CAAC;IAEF,MAAM,CAAC,GAAG,CAAC,uCAAuC,EAAE,IAAA,8CAAgC,EAAC,yBAAyB,CAAC,CAAC,CAAC;IAEjH,8CAA8C;IAC9C,MAAM,CAAC,GAAG,CAAC,yCAAyC,EAAE,IAAA,gDAAkC,EAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAExH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,oCAAoC,CAAC,WAAgB;IACnE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IAC1C,IAAI,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC;IACjC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACnB,IAAI,GAAG,EAAE,CAAC;IACX,CAAC;IAEA,YAAY,CAAC,QAAQ,GAAG,wCAAwC,IAAI,EAAE,CAAA;IACtE,OAAO,YAAY,CAAC,QAAQ,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import type { TokenExchangeRequest } from "@keycardai/oauth/tokenExchange";
|
|
2
|
-
import type { ApplicationCredential } from "@keycardai/oauth/credentials";
|
|
3
|
-
import type { PrivateKeyStorage } from "./privateKey.js";
|
|
4
1
|
export type { ApplicationCredential } from "@keycardai/oauth/credentials";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
prepareTokenExchangeRequest(subjectToken: string, resource: string): Promise<TokenExchangeRequest>;
|
|
13
|
-
}
|
|
14
|
-
export interface WebIdentityOptions {
|
|
15
|
-
serverName?: string;
|
|
16
|
-
storage?: PrivateKeyStorage;
|
|
17
|
-
storageDir?: string;
|
|
18
|
-
keyId?: string;
|
|
19
|
-
audienceConfig?: string | Record<string, string>;
|
|
20
|
-
}
|
|
21
|
-
export declare class WebIdentity implements ApplicationCredential {
|
|
22
|
-
#private;
|
|
23
|
-
constructor(options?: WebIdentityOptions);
|
|
24
|
-
bootstrap(): Promise<void>;
|
|
25
|
-
getAuth(): null;
|
|
26
|
-
prepareTokenExchangeRequest(subjectToken: string, resource: string, options?: {
|
|
27
|
-
tokenEndpoint?: string;
|
|
28
|
-
authInfo?: Record<string, string>;
|
|
29
|
-
}): Promise<TokenExchangeRequest>;
|
|
30
|
-
getPublicJwks(): {
|
|
31
|
-
keys: Record<string, unknown>[];
|
|
32
|
-
};
|
|
33
|
-
getClientJwksUrl(resourceServerUrl: string): string;
|
|
34
|
-
}
|
|
35
|
-
export interface EKSWorkloadIdentityOptions {
|
|
36
|
-
tokenFilePath?: string;
|
|
37
|
-
envVarName?: string;
|
|
38
|
-
}
|
|
39
|
-
export declare class EKSWorkloadIdentity implements ApplicationCredential {
|
|
40
|
-
#private;
|
|
41
|
-
constructor(options?: EKSWorkloadIdentityOptions);
|
|
42
|
-
getAuth(): null;
|
|
43
|
-
prepareTokenExchangeRequest(subjectToken: string, resource: string): Promise<TokenExchangeRequest>;
|
|
44
|
-
}
|
|
2
|
+
export { ClientSecret } from "@keycardai/oauth/server/clientSecret";
|
|
3
|
+
export type { ClientSecretCredentials } from "@keycardai/oauth/server/clientSecret";
|
|
4
|
+
export { WebIdentity } from "@keycardai/oauth/server";
|
|
5
|
+
export type { WebIdentityOptions } from "@keycardai/oauth/server";
|
|
6
|
+
export { EKSWorkloadIdentity } from "@keycardai/oauth/server";
|
|
7
|
+
export type { EKSWorkloadIdentityOptions } from "@keycardai/oauth/server";
|
|
45
8
|
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/server/auth/credentials.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/server/auth/credentials.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC"}
|