@mcp-z/client 1.0.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/AGENTS.md +159 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/auth/capability-discovery.d.cts +25 -0
- package/dist/cjs/auth/capability-discovery.d.ts +25 -0
- package/dist/cjs/auth/capability-discovery.js +280 -0
- package/dist/cjs/auth/capability-discovery.js.map +1 -0
- package/dist/cjs/auth/index.d.cts +9 -0
- package/dist/cjs/auth/index.d.ts +9 -0
- package/dist/cjs/auth/index.js +28 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.cts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.js +537 -0
- package/dist/cjs/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/cjs/auth/oauth-callback-listener.d.cts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.js +333 -0
- package/dist/cjs/auth/oauth-callback-listener.js.map +1 -0
- package/dist/cjs/auth/pkce.d.cts +17 -0
- package/dist/cjs/auth/pkce.d.ts +17 -0
- package/dist/cjs/auth/pkce.js +192 -0
- package/dist/cjs/auth/pkce.js.map +1 -0
- package/dist/cjs/auth/rfc9728-discovery.d.cts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.js +436 -0
- package/dist/cjs/auth/rfc9728-discovery.js.map +1 -0
- package/dist/cjs/auth/types.d.cts +137 -0
- package/dist/cjs/auth/types.d.ts +137 -0
- package/dist/cjs/auth/types.js +9 -0
- package/dist/cjs/auth/types.js.map +1 -0
- package/dist/cjs/client-helpers.d.cts +55 -0
- package/dist/cjs/client-helpers.d.ts +55 -0
- package/dist/cjs/client-helpers.js +128 -0
- package/dist/cjs/client-helpers.js.map +1 -0
- package/dist/cjs/config/server-loader.d.cts +27 -0
- package/dist/cjs/config/server-loader.d.ts +27 -0
- package/dist/cjs/config/server-loader.js +111 -0
- package/dist/cjs/config/server-loader.js.map +1 -0
- package/dist/cjs/config/validate-config.d.cts +15 -0
- package/dist/cjs/config/validate-config.d.ts +15 -0
- package/dist/cjs/config/validate-config.js +128 -0
- package/dist/cjs/config/validate-config.js.map +1 -0
- package/dist/cjs/connection/connect-client.d.cts +59 -0
- package/dist/cjs/connection/connect-client.d.ts +59 -0
- package/dist/cjs/connection/connect-client.js +536 -0
- package/dist/cjs/connection/connect-client.js.map +1 -0
- package/dist/cjs/connection/existing-process-transport.d.cts +40 -0
- package/dist/cjs/connection/existing-process-transport.d.ts +40 -0
- package/dist/cjs/connection/existing-process-transport.js +274 -0
- package/dist/cjs/connection/existing-process-transport.js.map +1 -0
- package/dist/cjs/connection/types.d.cts +61 -0
- package/dist/cjs/connection/types.d.ts +61 -0
- package/dist/cjs/connection/types.js +53 -0
- package/dist/cjs/connection/types.js.map +1 -0
- package/dist/cjs/connection/wait-for-http-ready.d.cts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.js +232 -0
- package/dist/cjs/connection/wait-for-http-ready.js.map +1 -0
- package/dist/cjs/dcr/dcr-authenticator.d.cts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.js +655 -0
- package/dist/cjs/dcr/dcr-authenticator.js.map +1 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.cts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js +245 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/cjs/dcr/index.d.cts +8 -0
- package/dist/cjs/dcr/index.d.ts +8 -0
- package/dist/cjs/dcr/index.js +24 -0
- package/dist/cjs/dcr/index.js.map +1 -0
- package/dist/cjs/index.d.cts +21 -0
- package/dist/cjs/index.d.ts +21 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/monkey-patches.d.cts +6 -0
- package/dist/cjs/monkey-patches.d.ts +6 -0
- package/dist/cjs/monkey-patches.js +236 -0
- package/dist/cjs/monkey-patches.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/response-wrappers.d.cts +41 -0
- package/dist/cjs/response-wrappers.d.ts +41 -0
- package/dist/cjs/response-wrappers.js +443 -0
- package/dist/cjs/response-wrappers.js.map +1 -0
- package/dist/cjs/search/index.d.cts +6 -0
- package/dist/cjs/search/index.d.ts +6 -0
- package/dist/cjs/search/index.js +25 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/search/search.d.cts +22 -0
- package/dist/cjs/search/search.d.ts +22 -0
- package/dist/cjs/search/search.js +630 -0
- package/dist/cjs/search/search.js.map +1 -0
- package/dist/cjs/search/types.d.cts +122 -0
- package/dist/cjs/search/types.d.ts +122 -0
- package/dist/cjs/search/types.js +10 -0
- package/dist/cjs/search/types.js.map +1 -0
- package/dist/cjs/spawn/spawn-server.d.cts +83 -0
- package/dist/cjs/spawn/spawn-server.d.ts +83 -0
- package/dist/cjs/spawn/spawn-server.js +410 -0
- package/dist/cjs/spawn/spawn-server.js.map +1 -0
- package/dist/cjs/spawn/spawn-servers.d.cts +151 -0
- package/dist/cjs/spawn/spawn-servers.d.ts +151 -0
- package/dist/cjs/spawn/spawn-servers.js +911 -0
- package/dist/cjs/spawn/spawn-servers.js.map +1 -0
- package/dist/cjs/types.d.cts +11 -0
- package/dist/cjs/types.d.ts +11 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/logger.d.cts +24 -0
- package/dist/cjs/utils/logger.d.ts +24 -0
- package/dist/cjs/utils/logger.js +80 -0
- package/dist/cjs/utils/logger.js.map +1 -0
- package/dist/cjs/utils/path-utils.d.cts +45 -0
- package/dist/cjs/utils/path-utils.d.ts +45 -0
- package/dist/cjs/utils/path-utils.js +158 -0
- package/dist/cjs/utils/path-utils.js.map +1 -0
- package/dist/cjs/utils/sanitizer.d.cts +30 -0
- package/dist/cjs/utils/sanitizer.d.ts +30 -0
- package/dist/cjs/utils/sanitizer.js +124 -0
- package/dist/cjs/utils/sanitizer.js.map +1 -0
- package/dist/esm/auth/capability-discovery.d.ts +25 -0
- package/dist/esm/auth/capability-discovery.js +110 -0
- package/dist/esm/auth/capability-discovery.js.map +1 -0
- package/dist/esm/auth/index.d.ts +9 -0
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/esm/auth/interactive-oauth-flow.js +217 -0
- package/dist/esm/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/esm/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/esm/auth/oauth-callback-listener.js +166 -0
- package/dist/esm/auth/oauth-callback-listener.js.map +1 -0
- package/dist/esm/auth/pkce.d.ts +17 -0
- package/dist/esm/auth/pkce.js +41 -0
- package/dist/esm/auth/pkce.js.map +1 -0
- package/dist/esm/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/esm/auth/rfc9728-discovery.js +157 -0
- package/dist/esm/auth/rfc9728-discovery.js.map +1 -0
- package/dist/esm/auth/types.d.ts +137 -0
- package/dist/esm/auth/types.js +7 -0
- package/dist/esm/auth/types.js.map +1 -0
- package/dist/esm/client-helpers.d.ts +55 -0
- package/dist/esm/client-helpers.js +81 -0
- package/dist/esm/client-helpers.js.map +1 -0
- package/dist/esm/config/server-loader.d.ts +27 -0
- package/dist/esm/config/server-loader.js +49 -0
- package/dist/esm/config/server-loader.js.map +1 -0
- package/dist/esm/config/validate-config.d.ts +15 -0
- package/dist/esm/config/validate-config.js +76 -0
- package/dist/esm/config/validate-config.js.map +1 -0
- package/dist/esm/connection/connect-client.d.ts +59 -0
- package/dist/esm/connection/connect-client.js +272 -0
- package/dist/esm/connection/connect-client.js.map +1 -0
- package/dist/esm/connection/existing-process-transport.d.ts +40 -0
- package/dist/esm/connection/existing-process-transport.js +103 -0
- package/dist/esm/connection/existing-process-transport.js.map +1 -0
- package/dist/esm/connection/types.d.ts +61 -0
- package/dist/esm/connection/types.js +34 -0
- package/dist/esm/connection/types.js.map +1 -0
- package/dist/esm/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/esm/connection/wait-for-http-ready.js +43 -0
- package/dist/esm/connection/wait-for-http-ready.js.map +1 -0
- package/dist/esm/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/esm/dcr/dcr-authenticator.js +235 -0
- package/dist/esm/dcr/dcr-authenticator.js.map +1 -0
- package/dist/esm/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/esm/dcr/dynamic-client-registrar.js +66 -0
- package/dist/esm/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/esm/dcr/index.d.ts +8 -0
- package/dist/esm/dcr/index.js +5 -0
- package/dist/esm/dcr/index.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/monkey-patches.d.ts +6 -0
- package/dist/esm/monkey-patches.js +32 -0
- package/dist/esm/monkey-patches.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/response-wrappers.d.ts +41 -0
- package/dist/esm/response-wrappers.js +201 -0
- package/dist/esm/response-wrappers.js.map +1 -0
- package/dist/esm/search/index.d.ts +6 -0
- package/dist/esm/search/index.js +3 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/search/search.d.ts +22 -0
- package/dist/esm/search/search.js +236 -0
- package/dist/esm/search/search.js.map +1 -0
- package/dist/esm/search/types.d.ts +122 -0
- package/dist/esm/search/types.js +8 -0
- package/dist/esm/search/types.js.map +1 -0
- package/dist/esm/spawn/spawn-server.d.ts +83 -0
- package/dist/esm/spawn/spawn-server.js +145 -0
- package/dist/esm/spawn/spawn-server.js.map +1 -0
- package/dist/esm/spawn/spawn-servers.d.ts +151 -0
- package/dist/esm/spawn/spawn-servers.js +406 -0
- package/dist/esm/spawn/spawn-servers.js.map +1 -0
- package/dist/esm/types.d.ts +11 -0
- package/dist/esm/types.js +9 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/logger.d.ts +24 -0
- package/dist/esm/utils/logger.js +59 -0
- package/dist/esm/utils/logger.js.map +1 -0
- package/dist/esm/utils/path-utils.d.ts +45 -0
- package/dist/esm/utils/path-utils.js +89 -0
- package/dist/esm/utils/path-utils.js.map +1 -0
- package/dist/esm/utils/sanitizer.d.ts +30 -0
- package/dist/esm/utils/sanitizer.js +43 -0
- package/dist/esm/utils/sanitizer.js.map +1 -0
- package/package.json +92 -0
- package/schemas/servers.d.ts +90 -0
- package/schemas/servers.schema.json +104 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Callback Server for CLI Authentication
|
|
3
|
+
* Listens for OAuth authorization callbacks and captures authorization code
|
|
4
|
+
*/
|
|
5
|
+
import { type Logger } from '../utils/logger.js';
|
|
6
|
+
import type { CallbackResult } from './types.js';
|
|
7
|
+
export interface OAuthCallbackListenerOptions {
|
|
8
|
+
/** Port to listen on (required - use get-port package to find available port) */
|
|
9
|
+
port: number;
|
|
10
|
+
/** Optional logger for debug output (defaults to singleton logger) */
|
|
11
|
+
logger?: Logger;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* OAuthCallbackListener handles OAuth redirect callbacks
|
|
15
|
+
* Starts a temporary HTTP server to receive authorization code
|
|
16
|
+
*
|
|
17
|
+
* Note: Caller is responsible for finding an available port using get-port package
|
|
18
|
+
*/
|
|
19
|
+
export declare class OAuthCallbackListener {
|
|
20
|
+
private server;
|
|
21
|
+
private resolveCallback?;
|
|
22
|
+
private rejectCallback?;
|
|
23
|
+
private timeout;
|
|
24
|
+
private port;
|
|
25
|
+
private logger;
|
|
26
|
+
constructor(options: OAuthCallbackListenerOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Start the callback server
|
|
29
|
+
* Fails fast if port is already in use - caller should use get-port to find available port
|
|
30
|
+
*/
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Listen on a specific port
|
|
34
|
+
*/
|
|
35
|
+
private listen;
|
|
36
|
+
/**
|
|
37
|
+
* Handle incoming HTTP requests
|
|
38
|
+
*/
|
|
39
|
+
private handleRequest;
|
|
40
|
+
/**
|
|
41
|
+
* Handle OAuth callback
|
|
42
|
+
*/
|
|
43
|
+
private handleCallback;
|
|
44
|
+
/**
|
|
45
|
+
* Wait for OAuth callback with timeout
|
|
46
|
+
*/
|
|
47
|
+
waitForCallback(timeoutMs?: number): Promise<CallbackResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Stop the callback server and close
|
|
50
|
+
*/
|
|
51
|
+
stop(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the callback URL for this server
|
|
54
|
+
*/
|
|
55
|
+
getCallbackUrl(): string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Callback Server for CLI Authentication
|
|
3
|
+
* Listens for OAuth authorization callbacks and captures authorization code
|
|
4
|
+
*/
|
|
5
|
+
import { type Logger } from '../utils/logger.js';
|
|
6
|
+
import type { CallbackResult } from './types.js';
|
|
7
|
+
export interface OAuthCallbackListenerOptions {
|
|
8
|
+
/** Port to listen on (required - use get-port package to find available port) */
|
|
9
|
+
port: number;
|
|
10
|
+
/** Optional logger for debug output (defaults to singleton logger) */
|
|
11
|
+
logger?: Logger;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* OAuthCallbackListener handles OAuth redirect callbacks
|
|
15
|
+
* Starts a temporary HTTP server to receive authorization code
|
|
16
|
+
*
|
|
17
|
+
* Note: Caller is responsible for finding an available port using get-port package
|
|
18
|
+
*/
|
|
19
|
+
export declare class OAuthCallbackListener {
|
|
20
|
+
private server;
|
|
21
|
+
private resolveCallback?;
|
|
22
|
+
private rejectCallback?;
|
|
23
|
+
private timeout;
|
|
24
|
+
private port;
|
|
25
|
+
private logger;
|
|
26
|
+
constructor(options: OAuthCallbackListenerOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Start the callback server
|
|
29
|
+
* Fails fast if port is already in use - caller should use get-port to find available port
|
|
30
|
+
*/
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Listen on a specific port
|
|
34
|
+
*/
|
|
35
|
+
private listen;
|
|
36
|
+
/**
|
|
37
|
+
* Handle incoming HTTP requests
|
|
38
|
+
*/
|
|
39
|
+
private handleRequest;
|
|
40
|
+
/**
|
|
41
|
+
* Handle OAuth callback
|
|
42
|
+
*/
|
|
43
|
+
private handleCallback;
|
|
44
|
+
/**
|
|
45
|
+
* Wait for OAuth callback with timeout
|
|
46
|
+
*/
|
|
47
|
+
waitForCallback(timeoutMs?: number): Promise<CallbackResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Stop the callback server and close
|
|
50
|
+
*/
|
|
51
|
+
stop(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the callback URL for this server
|
|
54
|
+
*/
|
|
55
|
+
getCallbackUrl(): string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Callback Server for CLI Authentication
|
|
3
|
+
* Listens for OAuth authorization callbacks and captures authorization code
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "OAuthCallbackListener", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return OAuthCallbackListener;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _nodehttp = /*#__PURE__*/ _interop_require_default(require("node:http"));
|
|
15
|
+
var _loggerts = require("../utils/logger.js");
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(undefined);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function _class_call_check(instance, Constructor) {
|
|
46
|
+
if (!(instance instanceof Constructor)) {
|
|
47
|
+
throw new TypeError("Cannot call a class as a function");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function _interop_require_default(obj) {
|
|
51
|
+
return obj && obj.__esModule ? obj : {
|
|
52
|
+
default: obj
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function _ts_generator(thisArg, body) {
|
|
56
|
+
var f, y, t, _ = {
|
|
57
|
+
label: 0,
|
|
58
|
+
sent: function() {
|
|
59
|
+
if (t[0] & 1) throw t[1];
|
|
60
|
+
return t[1];
|
|
61
|
+
},
|
|
62
|
+
trys: [],
|
|
63
|
+
ops: []
|
|
64
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
65
|
+
return d(g, "next", {
|
|
66
|
+
value: verb(0)
|
|
67
|
+
}), d(g, "throw", {
|
|
68
|
+
value: verb(1)
|
|
69
|
+
}), d(g, "return", {
|
|
70
|
+
value: verb(2)
|
|
71
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
72
|
+
value: function() {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
}), g;
|
|
76
|
+
function verb(n) {
|
|
77
|
+
return function(v) {
|
|
78
|
+
return step([
|
|
79
|
+
n,
|
|
80
|
+
v
|
|
81
|
+
]);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function step(op) {
|
|
85
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
86
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
87
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
88
|
+
if (y = 0, t) op = [
|
|
89
|
+
op[0] & 2,
|
|
90
|
+
t.value
|
|
91
|
+
];
|
|
92
|
+
switch(op[0]){
|
|
93
|
+
case 0:
|
|
94
|
+
case 1:
|
|
95
|
+
t = op;
|
|
96
|
+
break;
|
|
97
|
+
case 4:
|
|
98
|
+
_.label++;
|
|
99
|
+
return {
|
|
100
|
+
value: op[1],
|
|
101
|
+
done: false
|
|
102
|
+
};
|
|
103
|
+
case 5:
|
|
104
|
+
_.label++;
|
|
105
|
+
y = op[1];
|
|
106
|
+
op = [
|
|
107
|
+
0
|
|
108
|
+
];
|
|
109
|
+
continue;
|
|
110
|
+
case 7:
|
|
111
|
+
op = _.ops.pop();
|
|
112
|
+
_.trys.pop();
|
|
113
|
+
continue;
|
|
114
|
+
default:
|
|
115
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
116
|
+
_ = 0;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
120
|
+
_.label = op[1];
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
124
|
+
_.label = t[1];
|
|
125
|
+
t = op;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (t && _.label < t[2]) {
|
|
129
|
+
_.label = t[2];
|
|
130
|
+
_.ops.push(op);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
if (t[2]) _.ops.pop();
|
|
134
|
+
_.trys.pop();
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
op = body.call(thisArg, _);
|
|
138
|
+
} catch (e) {
|
|
139
|
+
op = [
|
|
140
|
+
6,
|
|
141
|
+
e
|
|
142
|
+
];
|
|
143
|
+
y = 0;
|
|
144
|
+
} finally{
|
|
145
|
+
f = t = 0;
|
|
146
|
+
}
|
|
147
|
+
if (op[0] & 5) throw op[1];
|
|
148
|
+
return {
|
|
149
|
+
value: op[0] ? op[1] : void 0,
|
|
150
|
+
done: true
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
var OAuthCallbackListener = /*#__PURE__*/ function() {
|
|
155
|
+
"use strict";
|
|
156
|
+
function OAuthCallbackListener(options) {
|
|
157
|
+
_class_call_check(this, OAuthCallbackListener);
|
|
158
|
+
var _options_logger;
|
|
159
|
+
this.port = options.port;
|
|
160
|
+
this.logger = (_options_logger = options.logger) !== null && _options_logger !== void 0 ? _options_logger : _loggerts.logger;
|
|
161
|
+
}
|
|
162
|
+
var _proto = OAuthCallbackListener.prototype;
|
|
163
|
+
/**
|
|
164
|
+
* Start the callback server
|
|
165
|
+
* Fails fast if port is already in use - caller should use get-port to find available port
|
|
166
|
+
*/ _proto.start = function start() {
|
|
167
|
+
return _async_to_generator(function() {
|
|
168
|
+
return _ts_generator(this, function(_state) {
|
|
169
|
+
switch(_state.label){
|
|
170
|
+
case 0:
|
|
171
|
+
return [
|
|
172
|
+
4,
|
|
173
|
+
this.listen(this.port)
|
|
174
|
+
];
|
|
175
|
+
case 1:
|
|
176
|
+
_state.sent();
|
|
177
|
+
this.logger.debug("✅ Callback server listening on http://localhost:".concat(this.port, "/callback"));
|
|
178
|
+
return [
|
|
179
|
+
2
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}).call(this);
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Listen on a specific port
|
|
187
|
+
*/ _proto.listen = function listen(port) {
|
|
188
|
+
var _this = this;
|
|
189
|
+
return new Promise(function(resolve, reject) {
|
|
190
|
+
_this.server = _nodehttp.default.createServer(function(req, res) {
|
|
191
|
+
_this.handleRequest(req, res);
|
|
192
|
+
});
|
|
193
|
+
_this.server.on('error', function(error) {
|
|
194
|
+
reject(error);
|
|
195
|
+
});
|
|
196
|
+
_this.server.listen(port, function() {
|
|
197
|
+
resolve();
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Handle incoming HTTP requests
|
|
203
|
+
*/ _proto.handleRequest = function handleRequest(req, res) {
|
|
204
|
+
var url = new URL(req.url || '', "http://localhost:".concat(this.port));
|
|
205
|
+
if (url.pathname === '/callback') {
|
|
206
|
+
this.handleCallback(url, res);
|
|
207
|
+
} else {
|
|
208
|
+
res.writeHead(404, {
|
|
209
|
+
'Content-Type': 'text/plain'
|
|
210
|
+
});
|
|
211
|
+
res.end('Not Found');
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Handle OAuth callback
|
|
216
|
+
*/ _proto.handleCallback = function handleCallback(url, res) {
|
|
217
|
+
var code = url.searchParams.get('code');
|
|
218
|
+
var state = url.searchParams.get('state');
|
|
219
|
+
var error = url.searchParams.get('error');
|
|
220
|
+
var errorDescription = url.searchParams.get('error_description');
|
|
221
|
+
// Handle OAuth errors
|
|
222
|
+
if (error) {
|
|
223
|
+
var errorMessage = errorDescription ? "".concat(error, ": ").concat(errorDescription) : error;
|
|
224
|
+
res.writeHead(400, {
|
|
225
|
+
'Content-Type': 'text/html'
|
|
226
|
+
});
|
|
227
|
+
res.end("\n <html>\n <body>\n <h1>Authorization Failed</h1>\n <p>".concat(errorMessage, "</p>\n <script>setTimeout(() => window.close(), 3000);</script>\n </body>\n </html>\n "));
|
|
228
|
+
if (this.rejectCallback) {
|
|
229
|
+
this.rejectCallback(new Error(errorMessage));
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// Validate code parameter
|
|
234
|
+
if (!code) {
|
|
235
|
+
res.writeHead(400, {
|
|
236
|
+
'Content-Type': 'text/html'
|
|
237
|
+
});
|
|
238
|
+
res.end("\n <html>\n <body>\n <h1>Invalid Callback</h1>\n <p>Missing authorization code</p>\n <script>setTimeout(() => window.close(), 3000);</script>\n </body>\n </html>\n ");
|
|
239
|
+
if (this.rejectCallback) {
|
|
240
|
+
this.rejectCallback(new Error('Missing authorization code'));
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
// Success - send confirmation page
|
|
245
|
+
res.writeHead(200, {
|
|
246
|
+
'Content-Type': 'text/html; charset=utf-8'
|
|
247
|
+
});
|
|
248
|
+
res.end('\n <html>\n <head>\n <meta charset="UTF-8">\n </head>\n <body>\n <h1>Authorization Successful</h1>\n <p>You can close this window and return to the terminal.</p>\n <script>setTimeout(() => window.close(), 2000);</script>\n </body>\n </html>\n ');
|
|
249
|
+
// Resolve the promise with authorization code
|
|
250
|
+
if (this.resolveCallback) {
|
|
251
|
+
var result = {
|
|
252
|
+
code: code
|
|
253
|
+
};
|
|
254
|
+
if (state) {
|
|
255
|
+
result.state = state;
|
|
256
|
+
}
|
|
257
|
+
this.resolveCallback(result);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Wait for OAuth callback with timeout
|
|
262
|
+
*/ _proto.waitForCallback = function waitForCallback() {
|
|
263
|
+
var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 300000;
|
|
264
|
+
return _async_to_generator(function() {
|
|
265
|
+
var _this;
|
|
266
|
+
return _ts_generator(this, function(_state) {
|
|
267
|
+
_this = this;
|
|
268
|
+
return [
|
|
269
|
+
2,
|
|
270
|
+
new Promise(function(resolve, reject) {
|
|
271
|
+
_this.resolveCallback = resolve;
|
|
272
|
+
_this.rejectCallback = reject;
|
|
273
|
+
// Set timeout to prevent hanging forever
|
|
274
|
+
_this.timeout = setTimeout(function() {
|
|
275
|
+
reject(new Error("Authorization timeout - no callback received within ".concat(timeoutMs / 1000, " seconds")));
|
|
276
|
+
_this.stop();
|
|
277
|
+
}, timeoutMs);
|
|
278
|
+
})
|
|
279
|
+
];
|
|
280
|
+
});
|
|
281
|
+
}).call(this);
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Stop the callback server and close
|
|
285
|
+
*/ _proto.stop = function stop() {
|
|
286
|
+
return _async_to_generator(function() {
|
|
287
|
+
var _this;
|
|
288
|
+
return _ts_generator(this, function(_state) {
|
|
289
|
+
switch(_state.label){
|
|
290
|
+
case 0:
|
|
291
|
+
_this = this;
|
|
292
|
+
// Clear the timeout
|
|
293
|
+
if (this.timeout) {
|
|
294
|
+
clearTimeout(this.timeout);
|
|
295
|
+
this.timeout = undefined;
|
|
296
|
+
}
|
|
297
|
+
if (!this.server) return [
|
|
298
|
+
3,
|
|
299
|
+
2
|
|
300
|
+
];
|
|
301
|
+
return [
|
|
302
|
+
4,
|
|
303
|
+
new Promise(function(resolve) {
|
|
304
|
+
var _this_server;
|
|
305
|
+
(_this_server = _this.server) === null || _this_server === void 0 ? void 0 : _this_server.close(function() {
|
|
306
|
+
_this.logger.debug('🔒 Callback server closed');
|
|
307
|
+
resolve();
|
|
308
|
+
});
|
|
309
|
+
})
|
|
310
|
+
];
|
|
311
|
+
case 1:
|
|
312
|
+
_state.sent();
|
|
313
|
+
this.server = undefined;
|
|
314
|
+
_state.label = 2;
|
|
315
|
+
case 2:
|
|
316
|
+
return [
|
|
317
|
+
2
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}).call(this);
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Get the callback URL for this server
|
|
325
|
+
*/ _proto.getCallbackUrl = function getCallbackUrl() {
|
|
326
|
+
if (!this.port) {
|
|
327
|
+
throw new Error('Server not started - call start() first');
|
|
328
|
+
}
|
|
329
|
+
return "http://localhost:".concat(this.port, "/callback");
|
|
330
|
+
};
|
|
331
|
+
return OAuthCallbackListener;
|
|
332
|
+
}();
|
|
333
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/libs/client/src/auth/oauth-callback-listener.ts"],"sourcesContent":["/**\n * OAuth Callback Server for CLI Authentication\n * Listens for OAuth authorization callbacks and captures authorization code\n */\n\nimport http from 'node:http';\nimport { logger as defaultLogger, type Logger } from '../utils/logger.ts';\nimport type { CallbackResult } from './types.ts';\n\nexport interface OAuthCallbackListenerOptions {\n /** Port to listen on (required - use get-port package to find available port) */\n port: number;\n /** Optional logger for debug output (defaults to singleton logger) */\n logger?: Logger;\n}\n\n/**\n * OAuthCallbackListener handles OAuth redirect callbacks\n * Starts a temporary HTTP server to receive authorization code\n *\n * Note: Caller is responsible for finding an available port using get-port package\n */\nexport class OAuthCallbackListener {\n private server: http.Server | undefined;\n private resolveCallback?: (result: CallbackResult) => void;\n private rejectCallback?: (error: Error) => void;\n private timeout: NodeJS.Timeout | undefined;\n private port: number;\n private logger: Logger;\n\n constructor(options: OAuthCallbackListenerOptions) {\n this.port = options.port;\n this.logger = options.logger ?? defaultLogger;\n }\n\n /**\n * Start the callback server\n * Fails fast if port is already in use - caller should use get-port to find available port\n */\n async start(): Promise<void> {\n await this.listen(this.port);\n this.logger.debug(`✅ Callback server listening on http://localhost:${this.port}/callback`);\n }\n\n /**\n * Listen on a specific port\n */\n private listen(port: number): Promise<void> {\n return new Promise((resolve, reject) => {\n this.server = http.createServer((req, res) => {\n this.handleRequest(req, res);\n });\n\n this.server.on('error', (error) => {\n reject(error);\n });\n\n this.server.listen(port, () => {\n resolve();\n });\n });\n }\n\n /**\n * Handle incoming HTTP requests\n */\n private handleRequest(req: http.IncomingMessage, res: http.ServerResponse): void {\n const url = new URL(req.url || '', `http://localhost:${this.port}`);\n\n if (url.pathname === '/callback') {\n this.handleCallback(url, res);\n } else {\n res.writeHead(404, { 'Content-Type': 'text/plain' });\n res.end('Not Found');\n }\n }\n\n /**\n * Handle OAuth callback\n */\n private handleCallback(url: URL, res: http.ServerResponse): void {\n const code = url.searchParams.get('code');\n const state = url.searchParams.get('state');\n const error = url.searchParams.get('error');\n const errorDescription = url.searchParams.get('error_description');\n\n // Handle OAuth errors\n if (error) {\n const errorMessage = errorDescription ? `${error}: ${errorDescription}` : error;\n\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(`\n <html>\n <body>\n <h1>Authorization Failed</h1>\n <p>${errorMessage}</p>\n <script>setTimeout(() => window.close(), 3000);</script>\n </body>\n </html>\n `);\n\n if (this.rejectCallback) {\n this.rejectCallback(new Error(errorMessage));\n }\n return;\n }\n\n // Validate code parameter\n if (!code) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(`\n <html>\n <body>\n <h1>Invalid Callback</h1>\n <p>Missing authorization code</p>\n <script>setTimeout(() => window.close(), 3000);</script>\n </body>\n </html>\n `);\n\n if (this.rejectCallback) {\n this.rejectCallback(new Error('Missing authorization code'));\n }\n return;\n }\n\n // Success - send confirmation page\n res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });\n res.end(`\n <html>\n <head>\n <meta charset=\"UTF-8\">\n </head>\n <body>\n <h1>Authorization Successful</h1>\n <p>You can close this window and return to the terminal.</p>\n <script>setTimeout(() => window.close(), 2000);</script>\n </body>\n </html>\n `);\n\n // Resolve the promise with authorization code\n if (this.resolveCallback) {\n const result: CallbackResult = { code };\n if (state) {\n result.state = state;\n }\n this.resolveCallback(result);\n }\n }\n\n /**\n * Wait for OAuth callback with timeout\n */\n async waitForCallback(timeoutMs = 300000): Promise<CallbackResult> {\n return new Promise((resolve, reject) => {\n this.resolveCallback = resolve;\n this.rejectCallback = reject;\n\n // Set timeout to prevent hanging forever\n this.timeout = setTimeout(() => {\n reject(new Error(`Authorization timeout - no callback received within ${timeoutMs / 1000} seconds`));\n this.stop();\n }, timeoutMs);\n });\n }\n\n /**\n * Stop the callback server and close\n */\n async stop(): Promise<void> {\n // Clear the timeout\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n\n // Close the server\n if (this.server) {\n await new Promise<void>((resolve) => {\n this.server?.close(() => {\n this.logger.debug('🔒 Callback server closed');\n resolve();\n });\n });\n this.server = undefined;\n }\n }\n\n /**\n * Get the callback URL for this server\n */\n getCallbackUrl(): string {\n if (!this.port) {\n throw new Error('Server not started - call start() first');\n }\n return `http://localhost:${this.port}/callback`;\n }\n}\n"],"names":["OAuthCallbackListener","options","port","logger","defaultLogger","start","listen","debug","Promise","resolve","reject","server","http","createServer","req","res","handleRequest","on","error","url","URL","pathname","handleCallback","writeHead","end","code","searchParams","get","state","errorDescription","errorMessage","rejectCallback","Error","resolveCallback","result","waitForCallback","timeoutMs","timeout","setTimeout","stop","clearTimeout","undefined","close","getCallbackUrl"],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PKCE (Proof Key for Code Exchange) utilities
|
|
3
|
+
* Implements RFC 7636 for OAuth 2.0 public client security
|
|
4
|
+
*/
|
|
5
|
+
import type { PkceParams } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate PKCE parameters for OAuth 2.0 authorization code flow
|
|
8
|
+
* Uses S256 method (SHA-256 hash) as recommended by RFC 7636
|
|
9
|
+
*
|
|
10
|
+
* @returns PkceParams with code verifier, challenge, and method
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const pkce = await generatePkce();
|
|
14
|
+
* // Use pkce.codeChallenge and pkce.codeChallengeMethod in authorization URL
|
|
15
|
+
* // Store pkce.codeVerifier for token exchange
|
|
16
|
+
*/
|
|
17
|
+
export declare function generatePkce(): Promise<PkceParams>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PKCE (Proof Key for Code Exchange) utilities
|
|
3
|
+
* Implements RFC 7636 for OAuth 2.0 public client security
|
|
4
|
+
*/
|
|
5
|
+
import type { PkceParams } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate PKCE parameters for OAuth 2.0 authorization code flow
|
|
8
|
+
* Uses S256 method (SHA-256 hash) as recommended by RFC 7636
|
|
9
|
+
*
|
|
10
|
+
* @returns PkceParams with code verifier, challenge, and method
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const pkce = await generatePkce();
|
|
14
|
+
* // Use pkce.codeChallenge and pkce.codeChallengeMethod in authorization URL
|
|
15
|
+
* // Store pkce.codeVerifier for token exchange
|
|
16
|
+
*/
|
|
17
|
+
export declare function generatePkce(): Promise<PkceParams>;
|