@lightdash-tools/mcp 0.24.0 → 0.25.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/README.md +2 -2
- package/dist/auth/oauth-broker/as-metadata.d.ts +1 -0
- package/dist/auth/oauth-broker/as-metadata.js +5 -1
- package/dist/auth/oauth-broker/client-crypto.d.ts +12 -0
- package/dist/auth/oauth-broker/client-crypto.js +80 -0
- package/dist/auth/oauth-broker/client-directory.d.ts +39 -0
- package/dist/auth/oauth-broker/client-directory.js +104 -0
- package/dist/auth/oauth-broker/client-directory.test.d.ts +1 -0
- package/dist/auth/oauth-broker/client-directory.test.js +134 -0
- package/dist/auth/oauth-broker/lightdash-token.d.ts +8 -0
- package/dist/auth/oauth-broker/lightdash-token.js +72 -8
- package/dist/auth/oauth-broker/mcp-access-token.d.ts +3 -0
- package/dist/auth/oauth-broker/mcp-access-token.js +9 -1
- package/dist/auth/oauth-broker/pending-store.d.ts +16 -4
- package/dist/auth/oauth-broker/pending-store.js +40 -18
- package/dist/auth/oauth-broker/refresh-crypto.d.ts +19 -0
- package/dist/auth/oauth-broker/refresh-crypto.js +70 -0
- package/dist/auth/oauth-broker/refresh-crypto.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-crypto.test.js +40 -0
- package/dist/auth/oauth-broker/refresh-flow.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-flow.test.js +350 -0
- package/dist/auth/oauth-broker/refresh-grant.d.ts +46 -0
- package/dist/auth/oauth-broker/refresh-grant.js +288 -0
- package/dist/auth/oauth-broker/refresh-store.conformance.test.d.ts +1 -0
- package/dist/auth/oauth-broker/refresh-store.conformance.test.js +254 -0
- package/dist/auth/oauth-broker/refresh-store.d.ts +61 -0
- package/dist/auth/oauth-broker/refresh-store.js +124 -0
- package/dist/auth/oauth-broker/routes.d.ts +6 -4
- package/dist/auth/oauth-broker/routes.js +114 -51
- package/dist/auth/oauth-broker/routes.test.js +48 -0
- package/dist/auth/oauth-broker/stores/client-kv.d.ts +46 -0
- package/dist/auth/oauth-broker/stores/client-kv.js +182 -0
- package/dist/auth/oauth-broker/stores/firestore.d.ts +29 -0
- package/dist/auth/oauth-broker/stores/firestore.js +201 -0
- package/dist/auth/oauth-broker/stores/open-client-directory.d.ts +4 -0
- package/dist/auth/oauth-broker/stores/open-client-directory.js +30 -0
- package/dist/auth/oauth-broker/stores/open-refresh-store.d.ts +4 -0
- package/dist/auth/oauth-broker/stores/open-refresh-store.js +24 -0
- package/dist/auth/oauth-broker/stores/postgres.d.ts +13 -0
- package/dist/auth/oauth-broker/stores/postgres.js +193 -0
- package/dist/auth/oauth-broker/stores/redis.d.ts +25 -0
- package/dist/auth/oauth-broker/stores/redis.js +337 -0
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
- package/dist/config/env.d.ts +13 -0
- package/dist/config/env.js +14 -1
- package/dist/config/load-mcp-config.d.ts +20 -0
- package/dist/config/load-mcp-config.js +53 -1
- package/dist/config/load-mcp-config.test.js +53 -0
- package/dist/config/oauth-store-key.d.ts +2 -0
- package/dist/config/oauth-store-key.js +17 -0
- package/dist/policy/content-developer.d.ts +4 -1
- package/dist/policy/content-developer.js +7 -3
- package/dist/policy/preview-ledger.d.ts +11 -1
- package/dist/policy/preview-ledger.js +29 -3
- package/dist/policy/rename-rejected.d.ts +9 -0
- package/dist/policy/rename-rejected.js +15 -0
- package/dist/profiles/content-developer/v1/index.js +6 -0
- package/dist/profiles/content-developer/v1/prompt-specs.d.ts +1 -1
- package/dist/profiles/content-developer/v1/resources/playbooks/core.md +15 -0
- package/dist/profiles/content-developer/v1/resources/playbooks/recovery/preview-stale.md +1 -0
- package/dist/profiles/content-reader/v1/prompt-specs.d.ts +1 -1
- package/dist/server/capabilities.d.ts +1 -1
- package/dist/stdio.process.test.js +3 -1
- package/dist/tools/project/content.js +8 -1
- package/dist/tools/project/developer-content.js +1 -1
- package/dist/tools/project/developer-helpers.d.ts +1 -0
- package/dist/tools/project/developer-helpers.test.js +1 -0
- package/dist/tools/project/developer-rename.d.ts +13 -0
- package/dist/tools/project/developer-rename.js +319 -0
- package/dist/tools/project/developer-rename.test.d.ts +5 -0
- package/dist/tools/project/developer-rename.test.js +296 -0
- package/dist/tools/project/reader-content.js +10 -3
- package/dist/tools/project/rename-instruction.d.ts +58 -0
- package/dist/tools/project/rename-instruction.js +104 -0
- package/dist/tools/query/reader-tool-helpers.d.ts +1 -1
- package/dist/tools/query/reader-tool-helpers.js +4 -0
- package/dist/tools/registry.d.ts +1 -1
- package/dist/transports/streamable-http.js +33 -7
- package/package.json +13 -9
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* OAuth broker pending / codes / DCR clients (ADR-0007 / ADR-0019).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Pending authorizations and authorization codes stay process-local.
|
|
6
|
+
* Client registrations are write-through to `ClientDirectory` when the OAuth store is on.
|
|
7
|
+
* Multi-instance authorization-code exchange still needs sticky `/oauth/*` or a single replica.
|
|
7
8
|
* Issued MCP access tokens are self-contained and do not depend on this store after exchange.
|
|
8
9
|
*/
|
|
9
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
11
|
exports.InMemoryOAuthBrokerStore = exports.DEFAULT_MAX_CLIENTS = exports.DEFAULT_MAX_CODES = exports.DEFAULT_MAX_PENDING = exports.DEFAULT_CLIENT_TTL_MS = exports.DEFAULT_CODE_TTL_MS = exports.DEFAULT_PENDING_TTL_MS = void 0;
|
|
11
12
|
const node_crypto_1 = require("node:crypto");
|
|
13
|
+
const client_directory_js_1 = require("./client-directory.js");
|
|
12
14
|
/** Pending authorize→callback state TTL. */
|
|
13
15
|
exports.DEFAULT_PENDING_TTL_MS = 10 * 60 * 1000;
|
|
14
16
|
/** Issued broker authorization code TTL (RFC 6749 recommends ≤10m; keep short). */
|
|
15
17
|
exports.DEFAULT_CODE_TTL_MS = 60 * 1000;
|
|
16
|
-
/** Registered DCR clients TTL
|
|
17
|
-
exports.DEFAULT_CLIENT_TTL_MS =
|
|
18
|
+
/** Registered DCR clients TTL. Matches the durable directory so a restart cannot revive a dropped client. */
|
|
19
|
+
exports.DEFAULT_CLIENT_TTL_MS = client_directory_js_1.CLIENT_DIRECTORY_TTL_MS;
|
|
18
20
|
exports.DEFAULT_MAX_PENDING = 10000;
|
|
19
21
|
exports.DEFAULT_MAX_CODES = 10000;
|
|
20
22
|
exports.DEFAULT_MAX_CLIENTS = 10000;
|
|
@@ -31,6 +33,7 @@ class InMemoryOAuthBrokerStore {
|
|
|
31
33
|
this.maxPending = (_d = options.maxPending) !== null && _d !== void 0 ? _d : exports.DEFAULT_MAX_PENDING;
|
|
32
34
|
this.maxCodes = (_e = options.maxCodes) !== null && _e !== void 0 ? _e : exports.DEFAULT_MAX_CODES;
|
|
33
35
|
this.maxClients = (_f = options.maxClients) !== null && _f !== void 0 ? _f : exports.DEFAULT_MAX_CLIENTS;
|
|
36
|
+
this.clientDirectory = options.clientDirectory;
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
39
|
* Registers a public MCP client with exact redirect URIs, or returns undefined
|
|
@@ -47,11 +50,40 @@ class InMemoryOAuthBrokerStore {
|
|
|
47
50
|
createdAt: Date.now(),
|
|
48
51
|
};
|
|
49
52
|
this.clients.set(client.clientId, client);
|
|
53
|
+
if (this.clientDirectory) {
|
|
54
|
+
try {
|
|
55
|
+
await this.clientDirectory.put({
|
|
56
|
+
clientId: client.clientId,
|
|
57
|
+
redirectUris: [...client.redirectUris],
|
|
58
|
+
createdAt: client.createdAt,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.clients.delete(client.clientId);
|
|
63
|
+
const name = error instanceof Error ? error.name : 'Error';
|
|
64
|
+
console.error(`OAuth client directory write failed (${name})`);
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
50
68
|
return client;
|
|
51
69
|
}
|
|
52
70
|
async getClient(clientId) {
|
|
53
71
|
this.cleanup();
|
|
54
|
-
|
|
72
|
+
const cached = this.clients.get(clientId);
|
|
73
|
+
if (cached || !this.clientDirectory)
|
|
74
|
+
return cached;
|
|
75
|
+
const stored = await this.clientDirectory.get(clientId);
|
|
76
|
+
if (!stored)
|
|
77
|
+
return undefined;
|
|
78
|
+
const client = {
|
|
79
|
+
clientId,
|
|
80
|
+
redirectUris: new Set(stored.redirectUris),
|
|
81
|
+
createdAt: stored.createdAt,
|
|
82
|
+
};
|
|
83
|
+
if (this.clients.size < this.maxClients) {
|
|
84
|
+
this.clients.set(clientId, client);
|
|
85
|
+
}
|
|
86
|
+
return client;
|
|
55
87
|
}
|
|
56
88
|
/** True when clientId is registered and redirectUri is an exact registered URI. */
|
|
57
89
|
async isRedirectAllowedForClient(clientId, redirectUri) {
|
|
@@ -85,19 +117,9 @@ class InMemoryOAuthBrokerStore {
|
|
|
85
117
|
if (this.codes.size >= this.maxCodes) {
|
|
86
118
|
return undefined;
|
|
87
119
|
}
|
|
88
|
-
const issued = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
redirectUri: pending.redirectUri,
|
|
92
|
-
codeChallenge: pending.codeChallenge,
|
|
93
|
-
codeChallengeMethod: pending.codeChallengeMethod,
|
|
94
|
-
accessToken: tokens.accessToken,
|
|
95
|
-
expiresIn: tokens.expiresIn,
|
|
96
|
-
tokenType: (_a = tokens.tokenType) !== null && _a !== void 0 ? _a : 'Bearer',
|
|
97
|
-
resource: pending.resource,
|
|
98
|
-
scope: pending.scope,
|
|
99
|
-
createdAt: Date.now(),
|
|
100
|
-
};
|
|
120
|
+
const issued = Object.assign(Object.assign({ code: (0, node_crypto_1.randomBytes)(32).toString('base64url'), clientId: pending.clientId, redirectUri: pending.redirectUri, codeChallenge: pending.codeChallenge, codeChallengeMethod: pending.codeChallengeMethod, accessToken: tokens.accessToken, expiresIn: tokens.expiresIn, tokenType: (_a = tokens.tokenType) !== null && _a !== void 0 ? _a : 'Bearer' }, (tokens.lightdashRefreshToken
|
|
121
|
+
? { lightdashRefreshToken: tokens.lightdashRefreshToken }
|
|
122
|
+
: {})), { resource: pending.resource, scope: pending.scope, createdAt: Date.now() });
|
|
101
123
|
this.codes.set(issued.code, issued);
|
|
102
124
|
return issued;
|
|
103
125
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class RefreshCryptoError extends Error {
|
|
2
|
+
readonly cause?: unknown;
|
|
3
|
+
constructor(message: string, options?: {
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
/** Row fields bound into the AES-GCM tag so a ciphertext cannot be moved to another row. */
|
|
8
|
+
export interface RefreshCipherContext {
|
|
9
|
+
handleDigest: string;
|
|
10
|
+
familyId: string;
|
|
11
|
+
clientId: string;
|
|
12
|
+
resource: string;
|
|
13
|
+
scope?: string;
|
|
14
|
+
firstIssuedAtMs: number;
|
|
15
|
+
}
|
|
16
|
+
/** Encrypts one upstream refresh token. Output is `iv.ciphertext.tag`, base64url. */
|
|
17
|
+
export declare function encryptRefreshToken(key: Buffer, refreshToken: string, context: RefreshCipherContext): string;
|
|
18
|
+
/** Decrypts a value produced by `encryptRefreshToken`. Throws on tampering or a wrong key. */
|
|
19
|
+
export declare function decryptRefreshToken(key: Buffer, payload: string, context: RefreshCipherContext): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RefreshCryptoError = void 0;
|
|
4
|
+
exports.encryptRefreshToken = encryptRefreshToken;
|
|
5
|
+
exports.decryptRefreshToken = decryptRefreshToken;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
class RefreshCryptoError extends Error {
|
|
8
|
+
constructor(message, options) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'RefreshCryptoError';
|
|
11
|
+
this.cause = options === null || options === void 0 ? void 0 : options.cause;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.RefreshCryptoError = RefreshCryptoError;
|
|
15
|
+
const INVALID_PAYLOAD = 'Invalid encrypted refresh token';
|
|
16
|
+
const AAD_PREFIX = 'lightdash-tools:oauth-refresh-token:v1';
|
|
17
|
+
const IV_BYTES = 12;
|
|
18
|
+
const AUTH_TAG_BYTES = 16;
|
|
19
|
+
const KEY_BYTES = 32;
|
|
20
|
+
/** Encrypts one upstream refresh token. Output is `iv.ciphertext.tag`, base64url. */
|
|
21
|
+
function encryptRefreshToken(key, refreshToken, context) {
|
|
22
|
+
assertKey(key);
|
|
23
|
+
const iv = (0, node_crypto_1.randomBytes)(IV_BYTES);
|
|
24
|
+
const cipher = (0, node_crypto_1.createCipheriv)('aes-256-gcm', key, iv);
|
|
25
|
+
cipher.setAAD(additionalData(context));
|
|
26
|
+
const ciphertext = Buffer.concat([cipher.update(refreshToken, 'utf8'), cipher.final()]);
|
|
27
|
+
const tag = cipher.getAuthTag();
|
|
28
|
+
return [iv, ciphertext, tag].map((part) => part.toString('base64url')).join('.');
|
|
29
|
+
}
|
|
30
|
+
/** Decrypts a value produced by `encryptRefreshToken`. Throws on tampering or a wrong key. */
|
|
31
|
+
function decryptRefreshToken(key, payload, context) {
|
|
32
|
+
assertKey(key);
|
|
33
|
+
const parts = payload.split('.');
|
|
34
|
+
if (parts.length !== 3) {
|
|
35
|
+
throw new RefreshCryptoError(INVALID_PAYLOAD);
|
|
36
|
+
}
|
|
37
|
+
const iv = Buffer.from(parts[0], 'base64url');
|
|
38
|
+
const ciphertext = Buffer.from(parts[1], 'base64url');
|
|
39
|
+
const tag = Buffer.from(parts[2], 'base64url');
|
|
40
|
+
if (iv.length !== IV_BYTES || tag.length !== AUTH_TAG_BYTES || ciphertext.length === 0) {
|
|
41
|
+
throw new RefreshCryptoError(INVALID_PAYLOAD);
|
|
42
|
+
}
|
|
43
|
+
const decipher = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', key, iv);
|
|
44
|
+
decipher.setAAD(additionalData(context));
|
|
45
|
+
decipher.setAuthTag(tag);
|
|
46
|
+
try {
|
|
47
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString('utf8');
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new RefreshCryptoError(INVALID_PAYLOAD, { cause: error });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function additionalData(context) {
|
|
54
|
+
var _a;
|
|
55
|
+
const fields = [
|
|
56
|
+
AAD_PREFIX,
|
|
57
|
+
context.handleDigest,
|
|
58
|
+
context.familyId,
|
|
59
|
+
context.clientId,
|
|
60
|
+
context.resource,
|
|
61
|
+
(_a = context.scope) !== null && _a !== void 0 ? _a : '',
|
|
62
|
+
String(context.firstIssuedAtMs),
|
|
63
|
+
];
|
|
64
|
+
return Buffer.from(fields.map((field) => `${Buffer.byteLength(field, 'utf8')}:${field}`).join('\0'), 'utf8');
|
|
65
|
+
}
|
|
66
|
+
function assertKey(key) {
|
|
67
|
+
if (key.length !== KEY_BYTES) {
|
|
68
|
+
throw new RefreshCryptoError('OAuth store key must be 32 bytes');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const oauth_store_key_js_1 = require("../../config/oauth-store-key.js");
|
|
5
|
+
const refresh_crypto_js_1 = require("./refresh-crypto.js");
|
|
6
|
+
const key = Buffer.alloc(32, 7);
|
|
7
|
+
const context = {
|
|
8
|
+
handleDigest: 'digest-a',
|
|
9
|
+
familyId: 'family-a',
|
|
10
|
+
clientId: 'client-a',
|
|
11
|
+
resource: 'https://mcp.example.com/semantic-layer/v1/mcp',
|
|
12
|
+
scope: 'mcp:read',
|
|
13
|
+
firstIssuedAtMs: 1700000000000,
|
|
14
|
+
};
|
|
15
|
+
(0, vitest_1.describe)('refresh token encryption', () => {
|
|
16
|
+
(0, vitest_1.it)('round-trips a refresh token', () => {
|
|
17
|
+
const encrypted = (0, refresh_crypto_js_1.encryptRefreshToken)(key, 'ld-refresh', context);
|
|
18
|
+
(0, vitest_1.expect)(encrypted).not.toContain('ld-refresh');
|
|
19
|
+
(0, vitest_1.expect)((0, refresh_crypto_js_1.decryptRefreshToken)(key, encrypted, context)).toBe('ld-refresh');
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.it)('rejects a ciphertext whose session start was changed', () => {
|
|
22
|
+
const encrypted = (0, refresh_crypto_js_1.encryptRefreshToken)(key, 'ld-refresh', context);
|
|
23
|
+
(0, vitest_1.expect)(() => (0, refresh_crypto_js_1.decryptRefreshToken)(key, encrypted, Object.assign(Object.assign({}, context), { firstIssuedAtMs: context.firstIssuedAtMs + 60000 }))).toThrow();
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.it)('rejects a ciphertext moved to another handle', () => {
|
|
26
|
+
const encrypted = (0, refresh_crypto_js_1.encryptRefreshToken)(key, 'ld-refresh', context);
|
|
27
|
+
(0, vitest_1.expect)(() => (0, refresh_crypto_js_1.decryptRefreshToken)(key, encrypted, Object.assign(Object.assign({}, context), { handleDigest: 'digest-b' }))).toThrow();
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)('rejects a ciphertext encrypted with a different key', () => {
|
|
30
|
+
const encrypted = (0, refresh_crypto_js_1.encryptRefreshToken)(key, 'ld-refresh', context);
|
|
31
|
+
(0, vitest_1.expect)(() => (0, refresh_crypto_js_1.decryptRefreshToken)(Buffer.alloc(32, 8), encrypted, context)).toThrow();
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.it)('accepts standard and url-safe base64 keys of 32 bytes', () => {
|
|
34
|
+
(0, vitest_1.expect)((0, oauth_store_key_js_1.decodeStoreKey)(key.toString('base64')).equals(key)).toBe(true);
|
|
35
|
+
(0, vitest_1.expect)((0, oauth_store_key_js_1.decodeStoreKey)(key.toString('base64url')).equals(key)).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
(0, vitest_1.it)('rejects a key that is not 32 bytes', () => {
|
|
38
|
+
(0, vitest_1.expect)(() => (0, oauth_store_key_js_1.decodeStoreKey)(Buffer.alloc(16, 1).toString('base64'))).toThrow(/32 bytes/);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_crypto_1 = require("node:crypto");
|
|
4
|
+
const node_events_1 = require("node:events");
|
|
5
|
+
const client_1 = require("@lightdash-tools/client");
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
const test_mcp_http_config_js_1 = require("../../config/test-mcp-http-config.js");
|
|
8
|
+
const mcp_access_token_js_1 = require("./mcp-access-token.js");
|
|
9
|
+
const refresh_crypto_js_1 = require("./refresh-crypto.js");
|
|
10
|
+
const refresh_grant_js_1 = require("./refresh-grant.js");
|
|
11
|
+
const refresh_store_js_1 = require("./refresh-store.js");
|
|
12
|
+
const routes_js_1 = require("./routes.js");
|
|
13
|
+
const RESOURCE = 'https://mcp.example.com/semantic-layer/v1/mcp';
|
|
14
|
+
function requireDigest(token) {
|
|
15
|
+
const digest = (0, refresh_grant_js_1.digestOfRefreshToken)(token);
|
|
16
|
+
if (!digest)
|
|
17
|
+
throw new Error('malformed refresh token');
|
|
18
|
+
return digest;
|
|
19
|
+
}
|
|
20
|
+
const STORE_KEY = Buffer.alloc(32, 5).toString('base64');
|
|
21
|
+
function refreshConfig(maxSessionSeconds = 86400) {
|
|
22
|
+
return {
|
|
23
|
+
kind: 'postgres',
|
|
24
|
+
key: new client_1.SecretString(STORE_KEY),
|
|
25
|
+
maxSessionSeconds,
|
|
26
|
+
postgresUrl: new client_1.SecretString('postgres://refresh-flow.invalid/oauth'),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function config() {
|
|
30
|
+
return (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
|
|
31
|
+
oauthClientId: 'ld-client',
|
|
32
|
+
oauthClientSecret: new client_1.SecretString('ld-secret'),
|
|
33
|
+
oauthRefresh: refreshConfig(),
|
|
34
|
+
requiredScopes: [],
|
|
35
|
+
scopesSupported: [],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function mockRes() {
|
|
39
|
+
const state = {
|
|
40
|
+
statusCode: 0,
|
|
41
|
+
body: undefined,
|
|
42
|
+
headers: {},
|
|
43
|
+
};
|
|
44
|
+
const res = {
|
|
45
|
+
get statusCode() {
|
|
46
|
+
return state.statusCode;
|
|
47
|
+
},
|
|
48
|
+
get body() {
|
|
49
|
+
return state.body;
|
|
50
|
+
},
|
|
51
|
+
get headers() {
|
|
52
|
+
return state.headers;
|
|
53
|
+
},
|
|
54
|
+
writeHead(code, headers) {
|
|
55
|
+
state.statusCode = code;
|
|
56
|
+
state.headers = Object.assign(Object.assign({}, state.headers), headers);
|
|
57
|
+
return res;
|
|
58
|
+
},
|
|
59
|
+
end(chunk) {
|
|
60
|
+
if (chunk !== undefined) {
|
|
61
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
62
|
+
state.body = JSON.parse(text);
|
|
63
|
+
}
|
|
64
|
+
return res;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return res;
|
|
68
|
+
}
|
|
69
|
+
function mockReq(method, url, body) {
|
|
70
|
+
const req = new node_events_1.EventEmitter();
|
|
71
|
+
req.method = method;
|
|
72
|
+
req.url = url;
|
|
73
|
+
req.headers = Object.assign({ host: 'mcp.example.com' }, (body !== undefined ? { 'content-type': 'application/x-www-form-urlencoded' } : {}));
|
|
74
|
+
queueMicrotask(() => {
|
|
75
|
+
if (body !== undefined)
|
|
76
|
+
req.emit('data', Buffer.from(body, 'utf8'));
|
|
77
|
+
req.emit('end');
|
|
78
|
+
});
|
|
79
|
+
return req;
|
|
80
|
+
}
|
|
81
|
+
async function issueBrokerTokens(upstream) {
|
|
82
|
+
const httpConfig = config();
|
|
83
|
+
const store = new refresh_store_js_1.InMemoryRefreshStore();
|
|
84
|
+
const broker = (0, routes_js_1.createOAuthBroker)(httpConfig, undefined, store);
|
|
85
|
+
const redirectUri = 'http://127.0.0.1:8787/callback';
|
|
86
|
+
const verifier = 'test-verifier-value-1234567890';
|
|
87
|
+
const challenge = (0, node_crypto_1.createHash)('sha256').update(verifier).digest('base64url');
|
|
88
|
+
const registerRes = mockRes();
|
|
89
|
+
await broker.handle(mockReq('POST', '/oauth/register', `redirect_uris=${encodeURIComponent(redirectUri)}`), registerRes, '/oauth/register');
|
|
90
|
+
const clientId = registerRes.body.client_id;
|
|
91
|
+
const authorizeRes = mockRes();
|
|
92
|
+
await broker.handle(mockReq('GET', `/oauth/authorize?response_type=code&client_id=${encodeURIComponent(clientId)}` +
|
|
93
|
+
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
94
|
+
`&code_challenge=${encodeURIComponent(challenge)}&code_challenge_method=S256` +
|
|
95
|
+
`&resource=${encodeURIComponent(RESOURCE)}`), authorizeRes, '/oauth/authorize');
|
|
96
|
+
const brokerState = new URL(String(authorizeRes.headers.Location)).searchParams.get('state');
|
|
97
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn().mockResolvedValue({
|
|
98
|
+
ok: true,
|
|
99
|
+
json: async () => ({
|
|
100
|
+
access_token: upstream.access,
|
|
101
|
+
refresh_token: upstream.refresh,
|
|
102
|
+
expires_in: 3600,
|
|
103
|
+
token_type: 'Bearer',
|
|
104
|
+
}),
|
|
105
|
+
}));
|
|
106
|
+
const callbackRes = mockRes();
|
|
107
|
+
await broker.handle(mockReq('GET', `/oauth/callback?code=upstream-code&state=${encodeURIComponent(brokerState)}`), callbackRes, '/oauth/callback');
|
|
108
|
+
const code = new URL(String(callbackRes.headers.Location)).searchParams.get('code');
|
|
109
|
+
const tokenRes = mockRes();
|
|
110
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
111
|
+
grant_type: 'authorization_code',
|
|
112
|
+
code: code,
|
|
113
|
+
redirect_uri: redirectUri,
|
|
114
|
+
client_id: clientId,
|
|
115
|
+
code_verifier: verifier,
|
|
116
|
+
resource: RESOURCE,
|
|
117
|
+
}).toString()), tokenRes, '/oauth/token');
|
|
118
|
+
(0, vitest_1.expect)(tokenRes.statusCode).toBe(200);
|
|
119
|
+
const body = tokenRes.body;
|
|
120
|
+
return {
|
|
121
|
+
config: httpConfig,
|
|
122
|
+
store,
|
|
123
|
+
accessToken: body.access_token,
|
|
124
|
+
refreshToken: body.refresh_token,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
(0, vitest_1.describe)('oauth refresh flow', () => {
|
|
128
|
+
(0, vitest_1.afterEach)(() => {
|
|
129
|
+
vitest_1.vi.restoreAllMocks();
|
|
130
|
+
vitest_1.vi.unstubAllGlobals();
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.it)('issues an MCP refresh handle and rotates it without exposing the Lightdash refresh token', async () => {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
135
|
+
(0, vitest_1.expect)(issued.accessToken).toMatch(/^ldmcp1\./);
|
|
136
|
+
(0, vitest_1.expect)(issued.refreshToken).toMatch(/^ldmcpr1\./);
|
|
137
|
+
(0, vitest_1.expect)(issued.refreshToken).not.toContain('ld-refresh-1');
|
|
138
|
+
(0, vitest_1.expect)((0, mcp_access_token_js_1.verifyMcpAccessToken)(issued.config, issued.accessToken, RESOURCE)).toMatchObject({
|
|
139
|
+
lightdashAccessToken: 'ld-access',
|
|
140
|
+
});
|
|
141
|
+
const fetchMock = vitest_1.vi.mocked(fetch);
|
|
142
|
+
fetchMock.mockResolvedValue({
|
|
143
|
+
ok: true,
|
|
144
|
+
json: async () => ({
|
|
145
|
+
access_token: 'ld-access-2',
|
|
146
|
+
refresh_token: 'ld-refresh-2',
|
|
147
|
+
expires_in: 1800,
|
|
148
|
+
token_type: 'Bearer',
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
const broker = (0, routes_js_1.createOAuthBroker)(issued.config, undefined, issued.store);
|
|
152
|
+
const refreshRes = mockRes();
|
|
153
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
154
|
+
grant_type: 'refresh_token',
|
|
155
|
+
refresh_token: issued.refreshToken,
|
|
156
|
+
resource: RESOURCE,
|
|
157
|
+
}).toString()), refreshRes, '/oauth/token');
|
|
158
|
+
(0, vitest_1.expect)(refreshRes.statusCode).toBe(200);
|
|
159
|
+
(0, vitest_1.expect)(refreshRes.headers['Cache-Control']).toBe('no-store');
|
|
160
|
+
(0, vitest_1.expect)(refreshRes.headers.Pragma).toBe('no-cache');
|
|
161
|
+
const rotated = refreshRes.body;
|
|
162
|
+
(0, vitest_1.expect)(rotated.refresh_token).toMatch(/^ldmcpr1\./);
|
|
163
|
+
(0, vitest_1.expect)(rotated.refresh_token).not.toBe(issued.refreshToken);
|
|
164
|
+
(0, vitest_1.expect)(JSON.stringify(rotated)).not.toContain('ld-refresh');
|
|
165
|
+
(0, vitest_1.expect)((0, mcp_access_token_js_1.verifyMcpAccessToken)(issued.config, rotated.access_token, RESOURCE)).toMatchObject({
|
|
166
|
+
lightdashAccessToken: 'ld-access-2',
|
|
167
|
+
});
|
|
168
|
+
const sent = (_b = (_a = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.body;
|
|
169
|
+
(0, vitest_1.expect)(String(sent)).toContain('grant_type=refresh_token');
|
|
170
|
+
(0, vitest_1.expect)(String(sent)).toContain('refresh_token=ld-refresh-1');
|
|
171
|
+
const replay = mockRes();
|
|
172
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
173
|
+
grant_type: 'refresh_token',
|
|
174
|
+
refresh_token: issued.refreshToken,
|
|
175
|
+
resource: RESOURCE,
|
|
176
|
+
}).toString()), replay, '/oauth/token');
|
|
177
|
+
(0, vitest_1.expect)(replay.statusCode).toBe(400);
|
|
178
|
+
(0, vitest_1.expect)(replay.body.error).toBe('invalid_grant');
|
|
179
|
+
const afterReuse = mockRes();
|
|
180
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
181
|
+
grant_type: 'refresh_token',
|
|
182
|
+
refresh_token: rotated.refresh_token,
|
|
183
|
+
resource: RESOURCE,
|
|
184
|
+
}).toString()), afterReuse, '/oauth/token');
|
|
185
|
+
(0, vitest_1.expect)(afterReuse.statusCode).toBe(400);
|
|
186
|
+
});
|
|
187
|
+
(0, vitest_1.it)('keeps the handle when Lightdash is unavailable and rejects it after the session cap', async () => {
|
|
188
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
189
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn().mockResolvedValue({
|
|
190
|
+
ok: false,
|
|
191
|
+
status: 503,
|
|
192
|
+
text: async () => 'unavailable',
|
|
193
|
+
}));
|
|
194
|
+
const broker = (0, routes_js_1.createOAuthBroker)(issued.config, undefined, issued.store);
|
|
195
|
+
const unavailable = mockRes();
|
|
196
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
197
|
+
grant_type: 'refresh_token',
|
|
198
|
+
refresh_token: issued.refreshToken,
|
|
199
|
+
resource: RESOURCE,
|
|
200
|
+
}).toString()), unavailable, '/oauth/token');
|
|
201
|
+
(0, vitest_1.expect)(unavailable.statusCode).toBe(503);
|
|
202
|
+
const digest = requireDigest(issued.refreshToken);
|
|
203
|
+
const stored = await issued.store.consume(digest);
|
|
204
|
+
(0, vitest_1.expect)(stored.status).toBe('ok');
|
|
205
|
+
if (stored.status !== 'ok')
|
|
206
|
+
return;
|
|
207
|
+
await issued.store.release(digest);
|
|
208
|
+
const expired = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
209
|
+
config: Object.assign(Object.assign({}, issued.config), { oauthRefresh: refreshConfig(60) }),
|
|
210
|
+
refreshStore: issued.store,
|
|
211
|
+
refreshToken: issued.refreshToken,
|
|
212
|
+
resource: RESOURCE,
|
|
213
|
+
nowMs: stored.record.firstIssuedAtMs + 61000,
|
|
214
|
+
});
|
|
215
|
+
(0, vitest_1.expect)(expired.status).toBe(400);
|
|
216
|
+
(0, vitest_1.expect)(expired.body.error).toBe('invalid_grant');
|
|
217
|
+
(0, vitest_1.expect)(expired.body.error_description).toBe('Session expired. Log in again.');
|
|
218
|
+
});
|
|
219
|
+
(0, vitest_1.it)('drops the consumed handle when the broker token cannot be minted', async () => {
|
|
220
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
221
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn().mockResolvedValue({
|
|
222
|
+
ok: true,
|
|
223
|
+
json: async () => ({
|
|
224
|
+
access_token: 'ld-access-2',
|
|
225
|
+
refresh_token: 'ld-refresh-2',
|
|
226
|
+
expires_in: 0,
|
|
227
|
+
token_type: 'Bearer',
|
|
228
|
+
}),
|
|
229
|
+
}));
|
|
230
|
+
const first = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
231
|
+
config: issued.config,
|
|
232
|
+
refreshStore: issued.store,
|
|
233
|
+
refreshToken: issued.refreshToken,
|
|
234
|
+
resource: RESOURCE,
|
|
235
|
+
});
|
|
236
|
+
(0, vitest_1.expect)(first.status).toBe(400);
|
|
237
|
+
const retry = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
238
|
+
config: issued.config,
|
|
239
|
+
refreshStore: issued.store,
|
|
240
|
+
refreshToken: issued.refreshToken,
|
|
241
|
+
resource: RESOURCE,
|
|
242
|
+
});
|
|
243
|
+
(0, vitest_1.expect)(retry.status).toBe(400);
|
|
244
|
+
(0, vitest_1.expect)(retry.body.error_description).toBe('Invalid or expired refresh token');
|
|
245
|
+
});
|
|
246
|
+
(0, vitest_1.it)('releases the handle on client_id or resource mismatch and accepts omitted resource', async () => {
|
|
247
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
248
|
+
const broker = (0, routes_js_1.createOAuthBroker)(issued.config, undefined, issued.store);
|
|
249
|
+
const badClient = mockRes();
|
|
250
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
251
|
+
grant_type: 'refresh_token',
|
|
252
|
+
refresh_token: issued.refreshToken,
|
|
253
|
+
client_id: 'other-client',
|
|
254
|
+
resource: RESOURCE,
|
|
255
|
+
}).toString()), badClient, '/oauth/token');
|
|
256
|
+
(0, vitest_1.expect)(badClient.statusCode).toBe(400);
|
|
257
|
+
(0, vitest_1.expect)(badClient.body.error_description).toBe('client_id mismatch');
|
|
258
|
+
const badResource = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
259
|
+
config: issued.config,
|
|
260
|
+
refreshStore: issued.store,
|
|
261
|
+
refreshToken: issued.refreshToken,
|
|
262
|
+
resource: 'https://mcp.example.com/content-reader/v1/mcp',
|
|
263
|
+
});
|
|
264
|
+
(0, vitest_1.expect)(badResource.status).toBe(400);
|
|
265
|
+
(0, vitest_1.expect)(badResource.body.error_description).toBe('resource mismatch');
|
|
266
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn().mockResolvedValue({
|
|
267
|
+
ok: true,
|
|
268
|
+
json: async () => ({
|
|
269
|
+
access_token: 'ld-access-2',
|
|
270
|
+
refresh_token: 'ld-refresh-2',
|
|
271
|
+
expires_in: 1800,
|
|
272
|
+
token_type: 'Bearer',
|
|
273
|
+
}),
|
|
274
|
+
}));
|
|
275
|
+
const okOmittedResource = mockRes();
|
|
276
|
+
await broker.handle(mockReq('POST', '/oauth/token', new URLSearchParams({
|
|
277
|
+
grant_type: 'refresh_token',
|
|
278
|
+
refresh_token: issued.refreshToken,
|
|
279
|
+
}).toString()), okOmittedResource, '/oauth/token');
|
|
280
|
+
(0, vitest_1.expect)(okOmittedResource.statusCode).toBe(200);
|
|
281
|
+
(0, vitest_1.expect)(okOmittedResource.headers['Cache-Control']).toBe('no-store');
|
|
282
|
+
});
|
|
283
|
+
(0, vitest_1.it)('drops the handle when upstream does not return a rotated refresh token', async () => {
|
|
284
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
285
|
+
vitest_1.vi.stubGlobal('fetch', vitest_1.vi.fn().mockResolvedValue({
|
|
286
|
+
ok: true,
|
|
287
|
+
json: async () => ({
|
|
288
|
+
access_token: 'ld-access-2',
|
|
289
|
+
expires_in: 1800,
|
|
290
|
+
token_type: 'Bearer',
|
|
291
|
+
}),
|
|
292
|
+
}));
|
|
293
|
+
const failed = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
294
|
+
config: issued.config,
|
|
295
|
+
refreshStore: issued.store,
|
|
296
|
+
refreshToken: issued.refreshToken,
|
|
297
|
+
resource: RESOURCE,
|
|
298
|
+
});
|
|
299
|
+
(0, vitest_1.expect)(failed.status).toBe(400);
|
|
300
|
+
(0, vitest_1.expect)(failed.body.error_description).toBe('Upstream refresh did not rotate the refresh token');
|
|
301
|
+
});
|
|
302
|
+
(0, vitest_1.it)('does not revoke another family when a store row is forged', async () => {
|
|
303
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
304
|
+
const attackerHandle = 'attacker-chosen-handle';
|
|
305
|
+
const victimDigest = requireDigest(issued.refreshToken);
|
|
306
|
+
const attackerDigest = requireDigest(`ldmcpr1.${attackerHandle}`);
|
|
307
|
+
const victim = await issued.store.consume(victimDigest);
|
|
308
|
+
(0, vitest_1.expect)(victim.status).toBe('ok');
|
|
309
|
+
if (victim.status !== 'ok')
|
|
310
|
+
return;
|
|
311
|
+
await issued.store.release(victimDigest);
|
|
312
|
+
await issued.store.put(attackerDigest, Object.assign(Object.assign({}, victim.record), { encryptedRefreshToken: 'not-a-ciphertext' }));
|
|
313
|
+
const forged = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
314
|
+
config: issued.config,
|
|
315
|
+
refreshStore: issued.store,
|
|
316
|
+
refreshToken: `ldmcpr1.${attackerHandle}`,
|
|
317
|
+
resource: RESOURCE,
|
|
318
|
+
});
|
|
319
|
+
(0, vitest_1.expect)(forged.status).toBe(400);
|
|
320
|
+
(0, vitest_1.expect)(forged.body.error).toBe('invalid_grant');
|
|
321
|
+
const stillThere = await issued.store.consume(victimDigest);
|
|
322
|
+
(0, vitest_1.expect)(stillThere.status).toBe('ok');
|
|
323
|
+
});
|
|
324
|
+
(0, vitest_1.it)('rejects a store row whose session start was extended', async () => {
|
|
325
|
+
const issued = await issueBrokerTokens({ access: 'ld-access', refresh: 'ld-refresh-1' });
|
|
326
|
+
const digest = requireDigest(issued.refreshToken);
|
|
327
|
+
const stored = await issued.store.consume(digest);
|
|
328
|
+
(0, vitest_1.expect)(stored.status).toBe('ok');
|
|
329
|
+
if (stored.status !== 'ok')
|
|
330
|
+
return;
|
|
331
|
+
const extendedAt = stored.record.firstIssuedAtMs + 86400000;
|
|
332
|
+
await issued.store.put(digest, Object.assign(Object.assign({}, stored.record), { firstIssuedAtMs: extendedAt, encryptedRefreshToken: (0, refresh_crypto_js_1.encryptRefreshToken)(Buffer.from(STORE_KEY, 'base64'), 'ld-refresh-1', {
|
|
333
|
+
handleDigest: digest,
|
|
334
|
+
familyId: stored.record.familyId,
|
|
335
|
+
clientId: stored.record.clientId,
|
|
336
|
+
resource: stored.record.resource,
|
|
337
|
+
scope: stored.record.scope,
|
|
338
|
+
firstIssuedAtMs: stored.record.firstIssuedAtMs,
|
|
339
|
+
}) }));
|
|
340
|
+
const extended = await (0, refresh_grant_js_1.handleRefreshTokenGrant)({
|
|
341
|
+
config: issued.config,
|
|
342
|
+
refreshStore: issued.store,
|
|
343
|
+
refreshToken: issued.refreshToken,
|
|
344
|
+
resource: RESOURCE,
|
|
345
|
+
nowMs: extendedAt + 1000,
|
|
346
|
+
});
|
|
347
|
+
(0, vitest_1.expect)(extended.status).toBe(400);
|
|
348
|
+
(0, vitest_1.expect)(extended.body.error_description).toBe('Invalid refresh token');
|
|
349
|
+
});
|
|
350
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { McpHttpConfig, OAuthRefreshPolicy } from '../../config/load-mcp-config.js';
|
|
2
|
+
import type { IssuedAuthorizationCode } from './pending-store.js';
|
|
3
|
+
import type { RefreshStore } from './refresh-store.js';
|
|
4
|
+
export interface TokenErrorResult {
|
|
5
|
+
status: number;
|
|
6
|
+
body: {
|
|
7
|
+
error: string;
|
|
8
|
+
error_description: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface TokenEndpointResult {
|
|
12
|
+
status: number;
|
|
13
|
+
body: Record<string, number | string | undefined>;
|
|
14
|
+
}
|
|
15
|
+
type AttachRefreshResult = {
|
|
16
|
+
ok: false;
|
|
17
|
+
} | {
|
|
18
|
+
ok: true;
|
|
19
|
+
refreshToken?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Returns the store key for an `ldmcpr1` token, or undefined when the token is malformed. */
|
|
22
|
+
export declare function digestOfRefreshToken(token: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Stores the upstream refresh token from a code exchange and returns the MCP handle.
|
|
25
|
+
* `ok: false` means the store was unavailable and the authorization code should be restored.
|
|
26
|
+
*/
|
|
27
|
+
export declare function attachRefreshToken(input: {
|
|
28
|
+
config: McpHttpConfig;
|
|
29
|
+
refreshStore: RefreshStore;
|
|
30
|
+
issued: IssuedAuthorizationCode;
|
|
31
|
+
nowMs: number;
|
|
32
|
+
}): Promise<AttachRefreshResult>;
|
|
33
|
+
export declare function handleRefreshTokenGrant(input: {
|
|
34
|
+
config: McpHttpConfig;
|
|
35
|
+
refreshStore: RefreshStore;
|
|
36
|
+
refreshToken: string;
|
|
37
|
+
resource?: string;
|
|
38
|
+
clientId?: string;
|
|
39
|
+
isResourceAllowed?: (resource: string) => boolean;
|
|
40
|
+
nowMs?: number;
|
|
41
|
+
}): Promise<TokenEndpointResult>;
|
|
42
|
+
export declare function cappedExpiryMs(nowMs: number, firstIssuedAtMs: number, refresh: OAuthRefreshPolicy, upstreamExpiresIn: number | undefined): number;
|
|
43
|
+
export declare function invalidGrant(description: string): TokenErrorResult;
|
|
44
|
+
export declare function unavailable(description: string): TokenErrorResult;
|
|
45
|
+
export declare function unsupportedGrantType(refreshEnabled?: boolean): TokenErrorResult;
|
|
46
|
+
export {};
|