chatbot-nc 2.2.32 → 2.2.33
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/dist/cjs/type/index.d.ts +86 -2
- package/dist/cjs/utils/index.d.ts +7 -4
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/mcp-oauth.d.ts +5 -5
- package/dist/cjs/utils/mcp-oauth.js.map +1 -1
- package/dist/cjs/utils/oauth.d.ts +4 -0
- package/dist/cjs/utils/oauth.js +91 -0
- package/dist/cjs/utils/oauth.js.map +1 -0
- package/dist/esm/type/index.d.ts +86 -2
- package/dist/esm/utils/index.d.ts +7 -4
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/mcp-oauth.d.ts +5 -5
- package/dist/esm/utils/mcp-oauth.js.map +1 -1
- package/dist/esm/utils/oauth.d.ts +4 -0
- package/dist/esm/utils/oauth.js +97 -0
- package/dist/esm/utils/oauth.js.map +1 -0
- package/package.json +1 -1
package/dist/cjs/type/index.d.ts
CHANGED
|
@@ -2,7 +2,91 @@ export type OAuthKeys = 'AuthURL' | 'AccessTokenURL' | 'CallBackURL' | 'CodeChal
|
|
|
2
2
|
export type ApiKeys = 'AuthApiHeader' | 'AuthApiValue';
|
|
3
3
|
export type BasicAuthKeys = 'AuthBasicUsername' | 'AuthBasicPassword';
|
|
4
4
|
export type BearerAuthKeys = 'AuthBearerUsername' | 'AuthBearerPassword' | 'AuthBearerURL' | 'AuthBearerToken';
|
|
5
|
-
export type
|
|
5
|
+
export type OAuthMetadata = {
|
|
6
|
+
/**
|
|
7
|
+
* OpenID Provider Issuer URL
|
|
8
|
+
*/
|
|
9
|
+
issuer: string;
|
|
10
|
+
/**
|
|
11
|
+
* OAuth/OpenID endpoints
|
|
12
|
+
*/
|
|
13
|
+
authorization_endpoint: string;
|
|
14
|
+
token_endpoint: string;
|
|
15
|
+
revocation_endpoint?: string;
|
|
16
|
+
userinfo_endpoint?: string;
|
|
17
|
+
registration_endpoint?: string;
|
|
18
|
+
introspection_endpoint?: string;
|
|
19
|
+
end_session_endpoint?: string;
|
|
20
|
+
jwks_uri?: string;
|
|
21
|
+
device_authorization_endpoint?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Supported OAuth response types
|
|
24
|
+
* Example: ["code"]
|
|
25
|
+
*/
|
|
26
|
+
response_types_supported?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Supported response modes
|
|
29
|
+
* Example: ["query", "fragment", "form_post"]
|
|
30
|
+
*/
|
|
31
|
+
response_modes_supported?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Supported grant types
|
|
34
|
+
*/
|
|
35
|
+
grant_types_supported?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* PKCE methods
|
|
38
|
+
* Example: ["S256", "plain"]
|
|
39
|
+
*/
|
|
40
|
+
code_challenge_methods_supported?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Supported scopes
|
|
43
|
+
* Example: ["openid", "email", "profile"]
|
|
44
|
+
*/
|
|
45
|
+
scopes_supported?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Supported subject types
|
|
48
|
+
* Example: ["public", "pairwise"]
|
|
49
|
+
*/
|
|
50
|
+
subject_types_supported?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* ID Token signing algorithms
|
|
53
|
+
* Example: ["RS256"]
|
|
54
|
+
*/
|
|
55
|
+
id_token_signing_alg_values_supported?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* Token endpoint auth methods
|
|
58
|
+
* Example:
|
|
59
|
+
* ["client_secret_basic", "client_secret_post"]
|
|
60
|
+
*/
|
|
61
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Token endpoint signing algorithms
|
|
64
|
+
*/
|
|
65
|
+
token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Claims supported in ID token / userinfo
|
|
68
|
+
*/
|
|
69
|
+
claims_supported?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Whether issuer parameter supported
|
|
72
|
+
*/
|
|
73
|
+
authorization_response_iss_parameter_supported?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Dynamic client registration support
|
|
76
|
+
*/
|
|
77
|
+
client_id_metadata_supported?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Documentation links
|
|
80
|
+
*/
|
|
81
|
+
service_documentation?: string;
|
|
82
|
+
op_policy_uri?: string;
|
|
83
|
+
op_tos_uri?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Allow provider-specific custom fields
|
|
86
|
+
*/
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
export type OAuthMCPProtectedResourceMetadata = {
|
|
6
90
|
/**
|
|
7
91
|
* Protected resource identifier
|
|
8
92
|
* Example:
|
|
@@ -36,7 +120,7 @@ export type OAuthProtectedResourceMetadata = {
|
|
|
36
120
|
*/
|
|
37
121
|
[key: string]: unknown;
|
|
38
122
|
};
|
|
39
|
-
export type
|
|
123
|
+
export type OAuthMCPMetadata = {
|
|
40
124
|
issuer: string;
|
|
41
125
|
authorization_endpoint: string;
|
|
42
126
|
token_endpoint: string;
|
|
@@ -51,11 +51,14 @@ export declare const Utils: {
|
|
|
51
51
|
AttachClientHeaders: (clientHeaders?: string, contentType?: string, sessionAttributes?: Record<string, string>) => Promise<Record<string, string>>;
|
|
52
52
|
};
|
|
53
53
|
jwt: typeof jwt;
|
|
54
|
+
OAuth: {
|
|
55
|
+
discoverOAuthOpenIdMetadata: (providerUrl: string) => Promise<import("../type").OAuthMetadata>;
|
|
56
|
+
};
|
|
54
57
|
MCPOAuth: {
|
|
55
|
-
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<import("../type").
|
|
56
|
-
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<import("../type").
|
|
57
|
-
registerClient: (metadata: import("../type").
|
|
58
|
-
buildAuthorizationUrl: (metadata: import("../type").
|
|
58
|
+
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<import("../type").OAuthMCPProtectedResourceMetadata>;
|
|
59
|
+
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<import("../type").OAuthMCPMetadata>;
|
|
60
|
+
registerClient: (metadata: import("../type").OAuthMCPMetadata, redirectUris: string[], client_Name?: string) => Promise<import("../type").ClientCredentials>;
|
|
61
|
+
buildAuthorizationUrl: (metadata: import("../type").OAuthMCPMetadata, clientId: string, redirectUri: string, state: string, codeChallenge?: string, codeChallengeMethod?: string, resource?: string) => Promise<string>;
|
|
59
62
|
handleCallBack: (callbackUrl: string, storedState: string, codeVerifier: string) => Promise<string>;
|
|
60
63
|
};
|
|
61
64
|
};
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -29,6 +29,7 @@ const intent_1 = require("./intent");
|
|
|
29
29
|
const date_format_1 = require("./date-format");
|
|
30
30
|
const jwt = __importStar(require("jsonwebtoken"));
|
|
31
31
|
const auth_1 = require("./auth");
|
|
32
|
+
const oauth_1 = require("./oauth");
|
|
32
33
|
const mcp_oauth_1 = require("./mcp-oauth");
|
|
33
34
|
exports.Utils = {
|
|
34
35
|
Intents: intent_1.Intents,
|
|
@@ -36,6 +37,7 @@ exports.Utils = {
|
|
|
36
37
|
DateFormat: date_format_1.DateFormat,
|
|
37
38
|
Auth: auth_1.Auth,
|
|
38
39
|
jwt,
|
|
40
|
+
OAuth: oauth_1.OAuth,
|
|
39
41
|
MCPOAuth: mcp_oauth_1.MCPOAuth
|
|
40
42
|
};
|
|
41
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAkC;AAClC,qCAAmC;AACnC,+CAA2C;AAC3C,kDAAoC;AACpC,iCAA8B;AAC9B,2CAAuC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAkC;AAClC,qCAAmC;AACnC,+CAA2C;AAC3C,kDAAoC;AACpC,iCAA8B;AAC9B,mCAAgC;AAChC,2CAAuC;AAE1B,QAAA,KAAK,GAAG;IACjB,OAAO,EAAP,gBAAO;IACP,MAAM,EAAN,eAAM;IACN,UAAU,EAAV,wBAAU;IACV,IAAI,EAAJ,WAAI;IACJ,GAAG;IACH,KAAK,EAAL,aAAK;IACL,QAAQ,EAAR,oBAAQ;CACX,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClientCredentials,
|
|
1
|
+
import { ClientCredentials, OAuthMCPMetadata, OAuthMCPProtectedResourceMetadata } from "../type";
|
|
2
2
|
export declare const MCPOAuth: {
|
|
3
|
-
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<
|
|
4
|
-
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<
|
|
5
|
-
registerClient: (metadata:
|
|
6
|
-
buildAuthorizationUrl: (metadata:
|
|
3
|
+
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<OAuthMCPProtectedResourceMetadata>;
|
|
4
|
+
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<OAuthMCPMetadata>;
|
|
5
|
+
registerClient: (metadata: OAuthMCPMetadata, redirectUris: string[], client_Name?: string) => Promise<ClientCredentials>;
|
|
6
|
+
buildAuthorizationUrl: (metadata: OAuthMCPMetadata, clientId: string, redirectUri: string, state: string, codeChallenge?: string, codeChallengeMethod?: string, resource?: string) => Promise<string>;
|
|
7
7
|
handleCallBack: (callbackUrl: string, storedState: string, codeVerifier: string) => Promise<string>;
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-oauth.js","sourceRoot":"","sources":["../../../utils/mcp-oauth.ts"],"names":[],"mappings":";;;
|
|
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AkB,EAAE;IACrD,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;IAC1D,OAAO;QACN,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS;QACxC,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS;QAC1C,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS;QAC1C,iBAAiB,EAAE,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,SAAS;KAClE,CAAA;AACF,CAAC,CAAA;AAEY,QAAA,QAAQ,GAAG,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuth = void 0;
|
|
4
|
+
const OPENID_CONFIGURATION_URLS = {
|
|
5
|
+
// Google
|
|
6
|
+
google: "https://accounts.google.com",
|
|
7
|
+
// Microsoft
|
|
8
|
+
microsoft: "https://login.microsoftonline.com/common/v2.0",
|
|
9
|
+
azure: "https://login.microsoftonline.com/common/v2.0",
|
|
10
|
+
// Atlassian
|
|
11
|
+
atlassian: "https://auth.atlassian.com",
|
|
12
|
+
jira: "https://auth.atlassian.com",
|
|
13
|
+
confluence: "https://auth.atlassian.com",
|
|
14
|
+
// Salesforce
|
|
15
|
+
salesforce: "https://login.salesforce.com",
|
|
16
|
+
salesforce_sandbox: "https://test.salesforce.com",
|
|
17
|
+
// Slack
|
|
18
|
+
slack: "https://slack.com",
|
|
19
|
+
// GitHub
|
|
20
|
+
github: "https://github.com",
|
|
21
|
+
// GitLab
|
|
22
|
+
gitlab: "https://gitlab.com",
|
|
23
|
+
// Apple
|
|
24
|
+
apple: "https://appleid.apple.com",
|
|
25
|
+
// Okta (tenant specific)
|
|
26
|
+
okta: "https://YOUR_DOMAIN.okta.com",
|
|
27
|
+
// Auth0 (tenant specific)
|
|
28
|
+
auth0: "https://YOUR_DOMAIN.auth0.com",
|
|
29
|
+
// Keycloak (realm specific)
|
|
30
|
+
keycloak: "https://YOUR_DOMAIN/realms/YOUR_REALM",
|
|
31
|
+
// Twitch
|
|
32
|
+
twitch: "https://id.twitch.tv",
|
|
33
|
+
// Spotify
|
|
34
|
+
spotify: "https://accounts.spotify.com",
|
|
35
|
+
// Yahoo
|
|
36
|
+
yahoo: "https://api.login.yahoo.com",
|
|
37
|
+
// PayPal
|
|
38
|
+
paypal: "https://www.paypal.com",
|
|
39
|
+
// Coinbase
|
|
40
|
+
coinbase: "https://www.coinbase.com",
|
|
41
|
+
// Reddit
|
|
42
|
+
reddit: "https://www.reddit.com",
|
|
43
|
+
// Dropbox
|
|
44
|
+
dropbox: "https://www.dropbox.com",
|
|
45
|
+
// Box
|
|
46
|
+
box: "https://account.box.com",
|
|
47
|
+
// Linear
|
|
48
|
+
linear: "https://linear.app",
|
|
49
|
+
// Discord
|
|
50
|
+
discord: "https://discord.com",
|
|
51
|
+
// Zoom
|
|
52
|
+
zoom: "https://zoom.us",
|
|
53
|
+
// Hugging Face
|
|
54
|
+
huggingface: "https://huggingface.co",
|
|
55
|
+
};
|
|
56
|
+
const resolveProviderUrl = (provider) => {
|
|
57
|
+
try {
|
|
58
|
+
// already full URL
|
|
59
|
+
new URL(provider);
|
|
60
|
+
return provider;
|
|
61
|
+
}
|
|
62
|
+
catch (_a) {
|
|
63
|
+
// lookup provider name
|
|
64
|
+
const url = OPENID_CONFIGURATION_URLS[provider.toLowerCase()];
|
|
65
|
+
if (!url) {
|
|
66
|
+
throw new Error(`Unsupported OAuth provider: ${provider}`);
|
|
67
|
+
}
|
|
68
|
+
return url;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param providerUrl Either provide Url or Name of provider in small case
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
const discoverOAuthOpenIdMetadata = async (providerUrl) => {
|
|
77
|
+
providerUrl = resolveProviderUrl(providerUrl);
|
|
78
|
+
const url = new URL(providerUrl);
|
|
79
|
+
// Build discovery URL
|
|
80
|
+
const discoveryUrl = new URL("/.well-known/openid-configuration", url);
|
|
81
|
+
// Step 1: RFC 9470 - Get OpenId Configuration
|
|
82
|
+
const openIdResponse = await fetch(discoveryUrl.toString());
|
|
83
|
+
if (!openIdResponse.ok) {
|
|
84
|
+
throw new Error(`Failed to fetch OpenID configuration: ` +
|
|
85
|
+
`${openIdResponse.status}`);
|
|
86
|
+
}
|
|
87
|
+
const metadata = (await openIdResponse.json());
|
|
88
|
+
return metadata;
|
|
89
|
+
};
|
|
90
|
+
exports.OAuth = { discoverOAuthOpenIdMetadata };
|
|
91
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../utils/oauth.ts"],"names":[],"mappings":";;;AAEA,MAAM,yBAAyB,GAA2B;IACxD,SAAS;IACT,MAAM,EAAE,6BAA6B;IAErC,YAAY;IACZ,SAAS,EAAE,+CAA+C;IAC1D,KAAK,EAAE,+CAA+C;IAEtD,YAAY;IACZ,SAAS,EAAE,4BAA4B;IACvC,IAAI,EAAE,4BAA4B;IAClC,UAAU,EAAE,4BAA4B;IAExC,aAAa;IACb,UAAU,EAAE,8BAA8B;IAC1C,kBAAkB,EAAE,6BAA6B;IAEjD,QAAQ;IACR,KAAK,EAAE,mBAAmB;IAE1B,SAAS;IACT,MAAM,EAAE,oBAAoB;IAE5B,SAAS;IACT,MAAM,EAAE,oBAAoB;IAE5B,QAAQ;IACR,KAAK,EAAE,2BAA2B;IAElC,yBAAyB;IACzB,IAAI,EAAE,8BAA8B;IAEpC,0BAA0B;IAC1B,KAAK,EAAE,+BAA+B;IAEtC,4B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;IAC9C,MAAM,cAAc,GAAG,MAAM,KAAK,CACjC,YAAY,CAAC,QAAQ,EAAE,CACvB,CAAA;IACD,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACd,wCAAwC;YACxC,GAAG,cAAc,CAAC,MAAM,EAAE,CAC1B,CAAA;IACF,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,MAAM,cAAc,CAAC,IAAI,EAAE,CAAkB,CAAA;IAC/D,OAAO,QAAQ,CAAA;AAChB,CAAC,CAAA;AAEY,QAAA,KAAK,GAAG,EAAE,2BAA2B,EAAE,CAAC"}
|
package/dist/esm/type/index.d.ts
CHANGED
|
@@ -2,7 +2,91 @@ export type OAuthKeys = 'AuthURL' | 'AccessTokenURL' | 'CallBackURL' | 'CodeChal
|
|
|
2
2
|
export type ApiKeys = 'AuthApiHeader' | 'AuthApiValue';
|
|
3
3
|
export type BasicAuthKeys = 'AuthBasicUsername' | 'AuthBasicPassword';
|
|
4
4
|
export type BearerAuthKeys = 'AuthBearerUsername' | 'AuthBearerPassword' | 'AuthBearerURL' | 'AuthBearerToken';
|
|
5
|
-
export type
|
|
5
|
+
export type OAuthMetadata = {
|
|
6
|
+
/**
|
|
7
|
+
* OpenID Provider Issuer URL
|
|
8
|
+
*/
|
|
9
|
+
issuer: string;
|
|
10
|
+
/**
|
|
11
|
+
* OAuth/OpenID endpoints
|
|
12
|
+
*/
|
|
13
|
+
authorization_endpoint: string;
|
|
14
|
+
token_endpoint: string;
|
|
15
|
+
revocation_endpoint?: string;
|
|
16
|
+
userinfo_endpoint?: string;
|
|
17
|
+
registration_endpoint?: string;
|
|
18
|
+
introspection_endpoint?: string;
|
|
19
|
+
end_session_endpoint?: string;
|
|
20
|
+
jwks_uri?: string;
|
|
21
|
+
device_authorization_endpoint?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Supported OAuth response types
|
|
24
|
+
* Example: ["code"]
|
|
25
|
+
*/
|
|
26
|
+
response_types_supported?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Supported response modes
|
|
29
|
+
* Example: ["query", "fragment", "form_post"]
|
|
30
|
+
*/
|
|
31
|
+
response_modes_supported?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Supported grant types
|
|
34
|
+
*/
|
|
35
|
+
grant_types_supported?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* PKCE methods
|
|
38
|
+
* Example: ["S256", "plain"]
|
|
39
|
+
*/
|
|
40
|
+
code_challenge_methods_supported?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Supported scopes
|
|
43
|
+
* Example: ["openid", "email", "profile"]
|
|
44
|
+
*/
|
|
45
|
+
scopes_supported?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Supported subject types
|
|
48
|
+
* Example: ["public", "pairwise"]
|
|
49
|
+
*/
|
|
50
|
+
subject_types_supported?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* ID Token signing algorithms
|
|
53
|
+
* Example: ["RS256"]
|
|
54
|
+
*/
|
|
55
|
+
id_token_signing_alg_values_supported?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* Token endpoint auth methods
|
|
58
|
+
* Example:
|
|
59
|
+
* ["client_secret_basic", "client_secret_post"]
|
|
60
|
+
*/
|
|
61
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Token endpoint signing algorithms
|
|
64
|
+
*/
|
|
65
|
+
token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Claims supported in ID token / userinfo
|
|
68
|
+
*/
|
|
69
|
+
claims_supported?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Whether issuer parameter supported
|
|
72
|
+
*/
|
|
73
|
+
authorization_response_iss_parameter_supported?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Dynamic client registration support
|
|
76
|
+
*/
|
|
77
|
+
client_id_metadata_supported?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Documentation links
|
|
80
|
+
*/
|
|
81
|
+
service_documentation?: string;
|
|
82
|
+
op_policy_uri?: string;
|
|
83
|
+
op_tos_uri?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Allow provider-specific custom fields
|
|
86
|
+
*/
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
export type OAuthMCPProtectedResourceMetadata = {
|
|
6
90
|
/**
|
|
7
91
|
* Protected resource identifier
|
|
8
92
|
* Example:
|
|
@@ -36,7 +120,7 @@ export type OAuthProtectedResourceMetadata = {
|
|
|
36
120
|
*/
|
|
37
121
|
[key: string]: unknown;
|
|
38
122
|
};
|
|
39
|
-
export type
|
|
123
|
+
export type OAuthMCPMetadata = {
|
|
40
124
|
issuer: string;
|
|
41
125
|
authorization_endpoint: string;
|
|
42
126
|
token_endpoint: string;
|
|
@@ -51,11 +51,14 @@ export declare const Utils: {
|
|
|
51
51
|
AttachClientHeaders: (clientHeaders?: string, contentType?: string, sessionAttributes?: Record<string, string>) => Promise<Record<string, string>>;
|
|
52
52
|
};
|
|
53
53
|
jwt: typeof jwt;
|
|
54
|
+
OAuth: {
|
|
55
|
+
discoverOAuthOpenIdMetadata: (providerUrl: string) => Promise<import("../type").OAuthMetadata>;
|
|
56
|
+
};
|
|
54
57
|
MCPOAuth: {
|
|
55
|
-
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<import("../type").
|
|
56
|
-
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<import("../type").
|
|
57
|
-
registerClient: (metadata: import("../type").
|
|
58
|
-
buildAuthorizationUrl: (metadata: import("../type").
|
|
58
|
+
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<import("../type").OAuthMCPProtectedResourceMetadata>;
|
|
59
|
+
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<import("../type").OAuthMCPMetadata>;
|
|
60
|
+
registerClient: (metadata: import("../type").OAuthMCPMetadata, redirectUris: string[], client_Name?: string) => Promise<import("../type").ClientCredentials>;
|
|
61
|
+
buildAuthorizationUrl: (metadata: import("../type").OAuthMCPMetadata, clientId: string, redirectUri: string, state: string, codeChallenge?: string, codeChallengeMethod?: string, resource?: string) => Promise<string>;
|
|
59
62
|
handleCallBack: (callbackUrl: string, storedState: string, codeVerifier: string) => Promise<string>;
|
|
60
63
|
};
|
|
61
64
|
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Intents } from "./intent";
|
|
|
3
3
|
import { DateFormat } from "./date-format";
|
|
4
4
|
import * as jwt from 'jsonwebtoken';
|
|
5
5
|
import { Auth } from "./auth";
|
|
6
|
+
import { OAuth } from "./oauth";
|
|
6
7
|
import { MCPOAuth } from "./mcp-oauth";
|
|
7
8
|
export const Utils = {
|
|
8
9
|
Intents,
|
|
@@ -10,6 +11,7 @@ export const Utils = {
|
|
|
10
11
|
DateFormat,
|
|
11
12
|
Auth,
|
|
12
13
|
jwt,
|
|
14
|
+
OAuth,
|
|
13
15
|
MCPOAuth
|
|
14
16
|
};
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,OAAO;IACP,MAAM;IACN,UAAU;IACV,IAAI;IACJ,GAAG;IACH,KAAK;IACL,QAAQ;CACX,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClientCredentials,
|
|
1
|
+
import { ClientCredentials, OAuthMCPMetadata, OAuthMCPProtectedResourceMetadata } from "../type";
|
|
2
2
|
export declare const MCPOAuth: {
|
|
3
|
-
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<
|
|
4
|
-
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<
|
|
5
|
-
registerClient: (metadata:
|
|
6
|
-
buildAuthorizationUrl: (metadata:
|
|
3
|
+
discoverOAuthResourceMetadata: (mcpServerUrl: string) => Promise<OAuthMCPProtectedResourceMetadata>;
|
|
4
|
+
discoverOAuthMetadata: (mcpServerUrl: string) => Promise<OAuthMCPMetadata>;
|
|
5
|
+
registerClient: (metadata: OAuthMCPMetadata, redirectUris: string[], client_Name?: string) => Promise<ClientCredentials>;
|
|
6
|
+
buildAuthorizationUrl: (metadata: OAuthMCPMetadata, clientId: string, redirectUri: string, state: string, codeChallenge?: string, codeChallengeMethod?: string, resource?: string) => Promise<string>;
|
|
7
7
|
handleCallBack: (callbackUrl: string, storedState: string, codeVerifier: string) => Promise<string>;
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-oauth.js","sourceRoot":"","sources":["../../../utils/mcp-oauth.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mcp-oauth.js","sourceRoot":"","sources":["../../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AI,eAAe,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;IAC1D,OAAO;QACN,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS;QACxC,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS;QAC1C,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS;QAC1C,iBAAiB,EAAE,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,SAAS;KAClE,CAAA;AACF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const OPENID_CONFIGURATION_URLS = {
|
|
11
|
+
// Google
|
|
12
|
+
google: "https://accounts.google.com",
|
|
13
|
+
// Microsoft
|
|
14
|
+
microsoft: "https://login.microsoftonline.com/common/v2.0",
|
|
15
|
+
azure: "https://login.microsoftonline.com/common/v2.0",
|
|
16
|
+
// Atlassian
|
|
17
|
+
atlassian: "https://auth.atlassian.com",
|
|
18
|
+
jira: "https://auth.atlassian.com",
|
|
19
|
+
confluence: "https://auth.atlassian.com",
|
|
20
|
+
// Salesforce
|
|
21
|
+
salesforce: "https://login.salesforce.com",
|
|
22
|
+
salesforce_sandbox: "https://test.salesforce.com",
|
|
23
|
+
// Slack
|
|
24
|
+
slack: "https://slack.com",
|
|
25
|
+
// GitHub
|
|
26
|
+
github: "https://github.com",
|
|
27
|
+
// GitLab
|
|
28
|
+
gitlab: "https://gitlab.com",
|
|
29
|
+
// Apple
|
|
30
|
+
apple: "https://appleid.apple.com",
|
|
31
|
+
// Okta (tenant specific)
|
|
32
|
+
okta: "https://YOUR_DOMAIN.okta.com",
|
|
33
|
+
// Auth0 (tenant specific)
|
|
34
|
+
auth0: "https://YOUR_DOMAIN.auth0.com",
|
|
35
|
+
// Keycloak (realm specific)
|
|
36
|
+
keycloak: "https://YOUR_DOMAIN/realms/YOUR_REALM",
|
|
37
|
+
// Twitch
|
|
38
|
+
twitch: "https://id.twitch.tv",
|
|
39
|
+
// Spotify
|
|
40
|
+
spotify: "https://accounts.spotify.com",
|
|
41
|
+
// Yahoo
|
|
42
|
+
yahoo: "https://api.login.yahoo.com",
|
|
43
|
+
// PayPal
|
|
44
|
+
paypal: "https://www.paypal.com",
|
|
45
|
+
// Coinbase
|
|
46
|
+
coinbase: "https://www.coinbase.com",
|
|
47
|
+
// Reddit
|
|
48
|
+
reddit: "https://www.reddit.com",
|
|
49
|
+
// Dropbox
|
|
50
|
+
dropbox: "https://www.dropbox.com",
|
|
51
|
+
// Box
|
|
52
|
+
box: "https://account.box.com",
|
|
53
|
+
// Linear
|
|
54
|
+
linear: "https://linear.app",
|
|
55
|
+
// Discord
|
|
56
|
+
discord: "https://discord.com",
|
|
57
|
+
// Zoom
|
|
58
|
+
zoom: "https://zoom.us",
|
|
59
|
+
// Hugging Face
|
|
60
|
+
huggingface: "https://huggingface.co",
|
|
61
|
+
};
|
|
62
|
+
const resolveProviderUrl = (provider) => {
|
|
63
|
+
try {
|
|
64
|
+
// already full URL
|
|
65
|
+
new URL(provider);
|
|
66
|
+
return provider;
|
|
67
|
+
}
|
|
68
|
+
catch (_a) {
|
|
69
|
+
// lookup provider name
|
|
70
|
+
const url = OPENID_CONFIGURATION_URLS[provider.toLowerCase()];
|
|
71
|
+
if (!url) {
|
|
72
|
+
throw new Error(`Unsupported OAuth provider: ${provider}`);
|
|
73
|
+
}
|
|
74
|
+
return url;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param providerUrl Either provide Url or Name of provider in small case
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
const discoverOAuthOpenIdMetadata = (providerUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
providerUrl = resolveProviderUrl(providerUrl);
|
|
84
|
+
const url = new URL(providerUrl);
|
|
85
|
+
// Build discovery URL
|
|
86
|
+
const discoveryUrl = new URL("/.well-known/openid-configuration", url);
|
|
87
|
+
// Step 1: RFC 9470 - Get OpenId Configuration
|
|
88
|
+
const openIdResponse = yield fetch(discoveryUrl.toString());
|
|
89
|
+
if (!openIdResponse.ok) {
|
|
90
|
+
throw new Error(`Failed to fetch OpenID configuration: ` +
|
|
91
|
+
`${openIdResponse.status}`);
|
|
92
|
+
}
|
|
93
|
+
const metadata = (yield openIdResponse.json());
|
|
94
|
+
return metadata;
|
|
95
|
+
});
|
|
96
|
+
export const OAuth = { discoverOAuthOpenIdMetadata };
|
|
97
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../utils/oauth.ts"],"names":[],"mappings":";;;;;;;;;AAEA,MAAM,yBAAyB,GAA2B;IACxD,SAAS;IACT,MAAM,EAAE,6BAA6B;IAErC,YAAY;IACZ,SAAS,EAAE,+CAA+C;IAC1D,KAAK,EAAE,+CAA+C;IAEtD,YAAY;IACZ,SAAS,EAAE,4BAA4B;IACvC,IAAI,EAAE,4BAA4B;IAClC,UAAU,EAAE,4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