@atxp/client 0.2.21 → 0.3.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/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/ajv.js +8 -0
- package/dist/_virtual/ajv.js.map +1 -0
- package/dist/_virtual/cache.js +4 -0
- package/dist/_virtual/cache.js.map +1 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/uri.all.js +4 -0
- package/dist/_virtual/uri.all.js.map +1 -0
- package/dist/atxpAccount.js +4 -2
- package/dist/atxpAccount.js.map +1 -1
- package/dist/atxpClient.js +12 -10
- package/dist/atxpClient.js.map +1 -1
- package/dist/atxpFetcher.js +10 -8
- package/dist/atxpFetcher.js.map +1 -1
- package/dist/baseAccount.js +5 -3
- package/dist/baseAccount.js.map +1 -1
- package/dist/baseConstants.js +4 -0
- package/dist/baseConstants.js.map +1 -0
- package/dist/basePaymentMaker.js +15 -12
- package/dist/basePaymentMaker.js.map +1 -1
- package/dist/index.cjs +15595 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +250 -10
- package/dist/index.js +15558 -10
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js +398 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +273 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +378 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js +46 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js +120 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +380 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js.map +1 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +1254 -0
- package/dist/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js.map +1 -0
- package/dist/node_modules/ajv/lib/ajv.js +531 -0
- package/dist/node_modules/ajv/lib/ajv.js.map +1 -0
- package/dist/node_modules/ajv/lib/cache.js +37 -0
- package/dist/node_modules/ajv/lib/cache.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/async.js +102 -0
- package/dist/node_modules/ajv/lib/compile/async.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/error_classes.js +46 -0
- package/dist/node_modules/ajv/lib/compile/error_classes.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/formats.js +154 -0
- package/dist/node_modules/ajv/lib/compile/formats.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/index.js +404 -0
- package/dist/node_modules/ajv/lib/compile/index.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/resolve.js +286 -0
- package/dist/node_modules/ajv/lib/compile/resolve.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/rules.js +79 -0
- package/dist/node_modules/ajv/lib/compile/rules.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/schema_obj.js +21 -0
- package/dist/node_modules/ajv/lib/compile/schema_obj.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/ucs2length.js +30 -0
- package/dist/node_modules/ajv/lib/compile/ucs2length.js.map +1 -0
- package/dist/node_modules/ajv/lib/compile/util.js +252 -0
- package/dist/node_modules/ajv/lib/compile/util.js.map +1 -0
- package/dist/node_modules/ajv/lib/data.js +59 -0
- package/dist/node_modules/ajv/lib/data.js.map +1 -0
- package/dist/node_modules/ajv/lib/definition_schema.js +49 -0
- package/dist/node_modules/ajv/lib/definition_schema.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/_limit.js +173 -0
- package/dist/node_modules/ajv/lib/dotjs/_limit.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitItems.js +90 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitItems.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitLength.js +95 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitLength.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js +90 -0
- package/dist/node_modules/ajv/lib/dotjs/_limitProperties.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/allOf.js +52 -0
- package/dist/node_modules/ajv/lib/dotjs/allOf.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/anyOf.js +83 -0
- package/dist/node_modules/ajv/lib/dotjs/anyOf.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/comment.js +24 -0
- package/dist/node_modules/ajv/lib/dotjs/comment.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/const.js +62 -0
- package/dist/node_modules/ajv/lib/dotjs/const.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/contains.js +91 -0
- package/dist/node_modules/ajv/lib/dotjs/contains.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/custom.js +238 -0
- package/dist/node_modules/ajv/lib/dotjs/custom.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/dependencies.js +178 -0
- package/dist/node_modules/ajv/lib/dotjs/dependencies.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/enum.js +72 -0
- package/dist/node_modules/ajv/lib/dotjs/enum.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/format.js +160 -0
- package/dist/node_modules/ajv/lib/dotjs/format.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/if.js +113 -0
- package/dist/node_modules/ajv/lib/dotjs/if.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/index.js +68 -0
- package/dist/node_modules/ajv/lib/dotjs/index.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/items.js +150 -0
- package/dist/node_modules/ajv/lib/dotjs/items.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/multipleOf.js +90 -0
- package/dist/node_modules/ajv/lib/dotjs/multipleOf.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/not.js +94 -0
- package/dist/node_modules/ajv/lib/dotjs/not.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/oneOf.js +83 -0
- package/dist/node_modules/ajv/lib/dotjs/oneOf.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/pattern.js +85 -0
- package/dist/node_modules/ajv/lib/dotjs/pattern.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/properties.js +345 -0
- package/dist/node_modules/ajv/lib/dotjs/properties.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/propertyNames.js +91 -0
- package/dist/node_modules/ajv/lib/dotjs/propertyNames.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/ref.js +134 -0
- package/dist/node_modules/ajv/lib/dotjs/ref.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/required.js +276 -0
- package/dist/node_modules/ajv/lib/dotjs/required.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js +96 -0
- package/dist/node_modules/ajv/lib/dotjs/uniqueItems.js.map +1 -0
- package/dist/node_modules/ajv/lib/dotjs/validate.js +492 -0
- package/dist/node_modules/ajv/lib/dotjs/validate.js.map +1 -0
- package/dist/node_modules/ajv/lib/keyword.js +159 -0
- package/dist/node_modules/ajv/lib/keyword.js.map +1 -0
- package/dist/node_modules/ajv/lib/refs/data.json.js +33 -0
- package/dist/node_modules/ajv/lib/refs/data.json.js.map +1 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json.js +254 -0
- package/dist/node_modules/ajv/lib/refs/json-schema-draft-07.json.js.map +1 -0
- package/dist/node_modules/eventsource-parser/dist/index.js +104 -0
- package/dist/node_modules/eventsource-parser/dist/index.js.map +1 -0
- package/dist/node_modules/eventsource-parser/dist/stream.js +28 -0
- package/dist/node_modules/eventsource-parser/dist/stream.js.map +1 -0
- package/dist/node_modules/fast-deep-equal/index.js +56 -0
- package/dist/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/node_modules/fast-json-stable-stringify/index.js +69 -0
- package/dist/node_modules/fast-json-stable-stringify/index.js.map +1 -0
- package/dist/node_modules/json-schema-traverse/index.js +100 -0
- package/dist/node_modules/json-schema-traverse/index.js.map +1 -0
- package/dist/node_modules/pkce-challenge/dist/index.browser.js +66 -0
- package/dist/node_modules/pkce-challenge/dist/index.browser.js.map +1 -0
- package/dist/node_modules/uri-js/dist/es5/uri.all.js +1418 -0
- package/dist/node_modules/uri-js/dist/es5/uri.all.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/ZodError.js +132 -0
- package/dist/node_modules/zod/dist/esm/v3/ZodError.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/errors.js +9 -0
- package/dist/node_modules/zod/dist/esm/v3/errors.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/helpers/errorUtil.js +9 -0
- package/dist/node_modules/zod/dist/esm/v3/helpers/errorUtil.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/helpers/parseUtil.js +112 -0
- package/dist/node_modules/zod/dist/esm/v3/helpers/parseUtil.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/helpers/util.js +136 -0
- package/dist/node_modules/zod/dist/esm/v3/helpers/util.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/locales/en.js +110 -0
- package/dist/node_modules/zod/dist/esm/v3/locales/en.js.map +1 -0
- package/dist/node_modules/zod/dist/esm/v3/types.js +3488 -0
- package/dist/node_modules/zod/dist/esm/v3/types.js.map +1 -0
- package/dist/oAuth.js +7 -6
- package/dist/oAuth.js.map +1 -1
- package/dist/solanaAccount.js +7 -4
- package/dist/solanaAccount.js.map +1 -1
- package/dist/solanaPaymentMaker.js +15 -12
- package/dist/solanaPaymentMaker.js.map +1 -1
- package/dist/types.js +5 -3
- package/dist/types.js.map +1 -1
- package/package.json +26 -10
- package/dist/atxpAccount.d.ts +0 -13
- package/dist/atxpAccount.d.ts.map +0 -1
- package/dist/atxpClient.d.ts +0 -14
- package/dist/atxpClient.d.ts.map +0 -1
- package/dist/atxpFetcher.d.ts +0 -72
- package/dist/atxpFetcher.d.ts.map +0 -1
- package/dist/baseAccount.d.ts +0 -10
- package/dist/baseAccount.d.ts.map +0 -1
- package/dist/basePaymentMaker.d.ts +0 -16
- package/dist/basePaymentMaker.d.ts.map +0 -1
- package/dist/clientTestHelpers.d.ts +0 -6
- package/dist/clientTestHelpers.d.ts.map +0 -1
- package/dist/clientTestHelpers.js +0 -94
- package/dist/clientTestHelpers.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/oAuth.d.ts +0 -44
- package/dist/oAuth.d.ts.map +0 -1
- package/dist/setup.expo.d.ts +0 -2
- package/dist/setup.expo.d.ts.map +0 -1
- package/dist/setup.expo.js +0 -30
- package/dist/setup.expo.js.map +0 -1
- package/dist/solanaAccount.d.ts +0 -9
- package/dist/solanaAccount.d.ts.map +0 -1
- package/dist/solanaPaymentMaker.d.ts +0 -18
- package/dist/solanaPaymentMaker.d.ts.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.d.ts.map +0 -1
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import pkceChallenge from '../../../../../pkce-challenge/dist/index.browser.js';
|
|
2
|
+
import { LATEST_PROTOCOL_VERSION } from '../types.js';
|
|
3
|
+
import { OAuthProtectedResourceMetadataSchema, OAuthMetadataSchema, OAuthClientInformationFullSchema, OAuthTokensSchema } from '../shared/auth.js';
|
|
4
|
+
import { resourceUrlFromServerUrl, checkResourceAllowed } from '../shared/auth-utils.js';
|
|
5
|
+
|
|
6
|
+
class UnauthorizedError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message !== null && message !== void 0 ? message : "Unauthorized");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Orchestrates the full auth flow with a server.
|
|
13
|
+
*
|
|
14
|
+
* This can be used as a single entry point for all authorization functionality,
|
|
15
|
+
* instead of linking together the other lower-level functions in this module.
|
|
16
|
+
*/
|
|
17
|
+
async function auth(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl }) {
|
|
18
|
+
let resourceMetadata;
|
|
19
|
+
let authorizationServerUrl = serverUrl;
|
|
20
|
+
try {
|
|
21
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl });
|
|
22
|
+
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
23
|
+
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
// Ignore errors and fall back to /.well-known/oauth-authorization-server
|
|
28
|
+
}
|
|
29
|
+
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
30
|
+
const metadata = await discoverOAuthMetadata(authorizationServerUrl);
|
|
31
|
+
// Handle client registration if needed
|
|
32
|
+
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
33
|
+
if (!clientInformation) {
|
|
34
|
+
if (authorizationCode !== undefined) {
|
|
35
|
+
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
36
|
+
}
|
|
37
|
+
if (!provider.saveClientInformation) {
|
|
38
|
+
throw new Error("OAuth client information must be saveable for dynamic registration");
|
|
39
|
+
}
|
|
40
|
+
const fullInformation = await registerClient(authorizationServerUrl, {
|
|
41
|
+
metadata,
|
|
42
|
+
clientMetadata: provider.clientMetadata,
|
|
43
|
+
});
|
|
44
|
+
await provider.saveClientInformation(fullInformation);
|
|
45
|
+
clientInformation = fullInformation;
|
|
46
|
+
}
|
|
47
|
+
// Exchange authorization code for tokens
|
|
48
|
+
if (authorizationCode !== undefined) {
|
|
49
|
+
const codeVerifier = await provider.codeVerifier();
|
|
50
|
+
const tokens = await exchangeAuthorization(authorizationServerUrl, {
|
|
51
|
+
metadata,
|
|
52
|
+
clientInformation,
|
|
53
|
+
authorizationCode,
|
|
54
|
+
codeVerifier,
|
|
55
|
+
redirectUri: provider.redirectUrl,
|
|
56
|
+
resource,
|
|
57
|
+
});
|
|
58
|
+
await provider.saveTokens(tokens);
|
|
59
|
+
return "AUTHORIZED";
|
|
60
|
+
}
|
|
61
|
+
const tokens = await provider.tokens();
|
|
62
|
+
// Handle token refresh or new authorization
|
|
63
|
+
if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {
|
|
64
|
+
try {
|
|
65
|
+
// Attempt to refresh the token
|
|
66
|
+
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
67
|
+
metadata,
|
|
68
|
+
clientInformation,
|
|
69
|
+
refreshToken: tokens.refresh_token,
|
|
70
|
+
resource,
|
|
71
|
+
});
|
|
72
|
+
await provider.saveTokens(newTokens);
|
|
73
|
+
return "AUTHORIZED";
|
|
74
|
+
}
|
|
75
|
+
catch (_b) {
|
|
76
|
+
// Could not refresh OAuth tokens
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const state = provider.state ? await provider.state() : undefined;
|
|
80
|
+
// Start new authorization flow
|
|
81
|
+
const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
|
|
82
|
+
metadata,
|
|
83
|
+
clientInformation,
|
|
84
|
+
state,
|
|
85
|
+
redirectUrl: provider.redirectUrl,
|
|
86
|
+
scope: scope || provider.clientMetadata.scope,
|
|
87
|
+
resource,
|
|
88
|
+
});
|
|
89
|
+
await provider.saveCodeVerifier(codeVerifier);
|
|
90
|
+
await provider.redirectToAuthorization(authorizationUrl);
|
|
91
|
+
return "REDIRECT";
|
|
92
|
+
}
|
|
93
|
+
async function selectResourceURL(serverUrl, provider, resourceMetadata) {
|
|
94
|
+
const defaultResource = resourceUrlFromServerUrl(serverUrl);
|
|
95
|
+
// If provider has custom validation, delegate to it
|
|
96
|
+
if (provider.validateResourceURL) {
|
|
97
|
+
return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);
|
|
98
|
+
}
|
|
99
|
+
// Only include resource parameter when Protected Resource Metadata is present
|
|
100
|
+
if (!resourceMetadata) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
// Validate that the metadata's resource is compatible with our request
|
|
104
|
+
if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {
|
|
105
|
+
throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);
|
|
106
|
+
}
|
|
107
|
+
// Prefer the resource from metadata since it's what the server is telling us to request
|
|
108
|
+
return new URL(resourceMetadata.resource);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Extract resource_metadata from response header.
|
|
112
|
+
*/
|
|
113
|
+
function extractResourceMetadataUrl(res) {
|
|
114
|
+
const authenticateHeader = res.headers.get("WWW-Authenticate");
|
|
115
|
+
if (!authenticateHeader) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
const [type, scheme] = authenticateHeader.split(' ');
|
|
119
|
+
if (type.toLowerCase() !== 'bearer' || !scheme) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
const regex = /resource_metadata="([^"]*)"/;
|
|
123
|
+
const match = regex.exec(authenticateHeader);
|
|
124
|
+
if (!match) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
return new URL(match[1]);
|
|
129
|
+
}
|
|
130
|
+
catch (_a) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.
|
|
136
|
+
*
|
|
137
|
+
* If the server returns a 404 for the well-known endpoint, this function will
|
|
138
|
+
* return `undefined`. Any other errors will be thrown as exceptions.
|
|
139
|
+
*/
|
|
140
|
+
async function discoverOAuthProtectedResourceMetadata(serverUrl, opts) {
|
|
141
|
+
var _a;
|
|
142
|
+
let url;
|
|
143
|
+
if (opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl) {
|
|
144
|
+
url = new URL(opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
url = new URL("/.well-known/oauth-protected-resource", serverUrl);
|
|
148
|
+
}
|
|
149
|
+
let response;
|
|
150
|
+
try {
|
|
151
|
+
response = await fetch(url, {
|
|
152
|
+
headers: {
|
|
153
|
+
"MCP-Protocol-Version": (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
// CORS errors come back as TypeError
|
|
159
|
+
if (error instanceof TypeError) {
|
|
160
|
+
response = await fetch(url);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (response.status === 404) {
|
|
167
|
+
throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
|
|
168
|
+
}
|
|
169
|
+
if (!response.ok) {
|
|
170
|
+
throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
|
|
171
|
+
}
|
|
172
|
+
return OAuthProtectedResourceMetadataSchema.parse(await response.json());
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Helper function to handle fetch with CORS retry logic
|
|
176
|
+
*/
|
|
177
|
+
async function fetchWithCorsRetry(url, headers) {
|
|
178
|
+
try {
|
|
179
|
+
return await fetch(url, { headers });
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error instanceof TypeError) {
|
|
183
|
+
if (headers) {
|
|
184
|
+
// CORS errors come back as TypeError, retry without headers
|
|
185
|
+
return fetchWithCorsRetry(url);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
// We're getting CORS errors on retry too, return undefined
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Constructs the well-known path for OAuth metadata discovery
|
|
197
|
+
*/
|
|
198
|
+
function buildWellKnownPath(pathname) {
|
|
199
|
+
let wellKnownPath = `/.well-known/oauth-authorization-server${pathname}`;
|
|
200
|
+
if (pathname.endsWith('/')) {
|
|
201
|
+
// Strip trailing slash from pathname to avoid double slashes
|
|
202
|
+
wellKnownPath = wellKnownPath.slice(0, -1);
|
|
203
|
+
}
|
|
204
|
+
return wellKnownPath;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Tries to discover OAuth metadata at a specific URL
|
|
208
|
+
*/
|
|
209
|
+
async function tryMetadataDiscovery(url, protocolVersion) {
|
|
210
|
+
const headers = {
|
|
211
|
+
"MCP-Protocol-Version": protocolVersion
|
|
212
|
+
};
|
|
213
|
+
return await fetchWithCorsRetry(url, headers);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Determines if fallback to root discovery should be attempted
|
|
217
|
+
*/
|
|
218
|
+
function shouldAttemptFallback(response, pathname) {
|
|
219
|
+
return !response || response.status === 404 && pathname !== '/';
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.
|
|
223
|
+
*
|
|
224
|
+
* If the server returns a 404 for the well-known endpoint, this function will
|
|
225
|
+
* return `undefined`. Any other errors will be thrown as exceptions.
|
|
226
|
+
*/
|
|
227
|
+
async function discoverOAuthMetadata(authorizationServerUrl, opts) {
|
|
228
|
+
var _a;
|
|
229
|
+
const issuer = new URL(authorizationServerUrl);
|
|
230
|
+
const protocolVersion = (_a = void 0 ) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;
|
|
231
|
+
// Try path-aware discovery first (RFC 8414 compliant)
|
|
232
|
+
const wellKnownPath = buildWellKnownPath(issuer.pathname);
|
|
233
|
+
const pathAwareUrl = new URL(wellKnownPath, issuer);
|
|
234
|
+
let response = await tryMetadataDiscovery(pathAwareUrl, protocolVersion);
|
|
235
|
+
// If path-aware discovery fails with 404, try fallback to root discovery
|
|
236
|
+
if (shouldAttemptFallback(response, issuer.pathname)) {
|
|
237
|
+
const rootUrl = new URL("/.well-known/oauth-authorization-server", issuer);
|
|
238
|
+
response = await tryMetadataDiscovery(rootUrl, protocolVersion);
|
|
239
|
+
}
|
|
240
|
+
if (!response || response.status === 404) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
if (!response.ok) {
|
|
244
|
+
throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);
|
|
245
|
+
}
|
|
246
|
+
return OAuthMetadataSchema.parse(await response.json());
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.
|
|
250
|
+
*/
|
|
251
|
+
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource, }) {
|
|
252
|
+
const responseType = "code";
|
|
253
|
+
const codeChallengeMethod = "S256";
|
|
254
|
+
let authorizationUrl;
|
|
255
|
+
if (metadata) {
|
|
256
|
+
authorizationUrl = new URL(metadata.authorization_endpoint);
|
|
257
|
+
if (!metadata.response_types_supported.includes(responseType)) {
|
|
258
|
+
throw new Error(`Incompatible auth server: does not support response type ${responseType}`);
|
|
259
|
+
}
|
|
260
|
+
if (!metadata.code_challenge_methods_supported ||
|
|
261
|
+
!metadata.code_challenge_methods_supported.includes(codeChallengeMethod)) {
|
|
262
|
+
throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
authorizationUrl = new URL("/authorize", authorizationServerUrl);
|
|
267
|
+
}
|
|
268
|
+
// Generate PKCE challenge
|
|
269
|
+
const challenge = await pkceChallenge();
|
|
270
|
+
const codeVerifier = challenge.code_verifier;
|
|
271
|
+
const codeChallenge = challenge.code_challenge;
|
|
272
|
+
authorizationUrl.searchParams.set("response_type", responseType);
|
|
273
|
+
authorizationUrl.searchParams.set("client_id", clientInformation.client_id);
|
|
274
|
+
authorizationUrl.searchParams.set("code_challenge", codeChallenge);
|
|
275
|
+
authorizationUrl.searchParams.set("code_challenge_method", codeChallengeMethod);
|
|
276
|
+
authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
|
|
277
|
+
if (state) {
|
|
278
|
+
authorizationUrl.searchParams.set("state", state);
|
|
279
|
+
}
|
|
280
|
+
if (scope) {
|
|
281
|
+
authorizationUrl.searchParams.set("scope", scope);
|
|
282
|
+
}
|
|
283
|
+
if (resource) {
|
|
284
|
+
authorizationUrl.searchParams.set("resource", resource.href);
|
|
285
|
+
}
|
|
286
|
+
return { authorizationUrl, codeVerifier };
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Exchanges an authorization code for an access token with the given server.
|
|
290
|
+
*/
|
|
291
|
+
async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, }) {
|
|
292
|
+
const grantType = "authorization_code";
|
|
293
|
+
let tokenUrl;
|
|
294
|
+
if (metadata) {
|
|
295
|
+
tokenUrl = new URL(metadata.token_endpoint);
|
|
296
|
+
if (metadata.grant_types_supported &&
|
|
297
|
+
!metadata.grant_types_supported.includes(grantType)) {
|
|
298
|
+
throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
tokenUrl = new URL("/token", authorizationServerUrl);
|
|
303
|
+
}
|
|
304
|
+
// Exchange code for tokens
|
|
305
|
+
const params = new URLSearchParams({
|
|
306
|
+
grant_type: grantType,
|
|
307
|
+
client_id: clientInformation.client_id,
|
|
308
|
+
code: authorizationCode,
|
|
309
|
+
code_verifier: codeVerifier,
|
|
310
|
+
redirect_uri: String(redirectUri),
|
|
311
|
+
});
|
|
312
|
+
if (clientInformation.client_secret) {
|
|
313
|
+
params.set("client_secret", clientInformation.client_secret);
|
|
314
|
+
}
|
|
315
|
+
if (resource) {
|
|
316
|
+
params.set("resource", resource.href);
|
|
317
|
+
}
|
|
318
|
+
const response = await fetch(tokenUrl, {
|
|
319
|
+
method: "POST",
|
|
320
|
+
headers: {
|
|
321
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
322
|
+
},
|
|
323
|
+
body: params,
|
|
324
|
+
});
|
|
325
|
+
if (!response.ok) {
|
|
326
|
+
throw new Error(`Token exchange failed: HTTP ${response.status}`);
|
|
327
|
+
}
|
|
328
|
+
return OAuthTokensSchema.parse(await response.json());
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Exchange a refresh token for an updated access token.
|
|
332
|
+
*/
|
|
333
|
+
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, }) {
|
|
334
|
+
const grantType = "refresh_token";
|
|
335
|
+
let tokenUrl;
|
|
336
|
+
if (metadata) {
|
|
337
|
+
tokenUrl = new URL(metadata.token_endpoint);
|
|
338
|
+
if (metadata.grant_types_supported &&
|
|
339
|
+
!metadata.grant_types_supported.includes(grantType)) {
|
|
340
|
+
throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
tokenUrl = new URL("/token", authorizationServerUrl);
|
|
345
|
+
}
|
|
346
|
+
// Exchange refresh token
|
|
347
|
+
const params = new URLSearchParams({
|
|
348
|
+
grant_type: grantType,
|
|
349
|
+
client_id: clientInformation.client_id,
|
|
350
|
+
refresh_token: refreshToken,
|
|
351
|
+
});
|
|
352
|
+
if (clientInformation.client_secret) {
|
|
353
|
+
params.set("client_secret", clientInformation.client_secret);
|
|
354
|
+
}
|
|
355
|
+
if (resource) {
|
|
356
|
+
params.set("resource", resource.href);
|
|
357
|
+
}
|
|
358
|
+
const response = await fetch(tokenUrl, {
|
|
359
|
+
method: "POST",
|
|
360
|
+
headers: {
|
|
361
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
362
|
+
},
|
|
363
|
+
body: params,
|
|
364
|
+
});
|
|
365
|
+
if (!response.ok) {
|
|
366
|
+
throw new Error(`Token refresh failed: HTTP ${response.status}`);
|
|
367
|
+
}
|
|
368
|
+
return OAuthTokensSchema.parse({ refresh_token: refreshToken, ...(await response.json()) });
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.
|
|
372
|
+
*/
|
|
373
|
+
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, }) {
|
|
374
|
+
let registrationUrl;
|
|
375
|
+
if (metadata) {
|
|
376
|
+
if (!metadata.registration_endpoint) {
|
|
377
|
+
throw new Error("Incompatible auth server: does not support dynamic client registration");
|
|
378
|
+
}
|
|
379
|
+
registrationUrl = new URL(metadata.registration_endpoint);
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
registrationUrl = new URL("/register", authorizationServerUrl);
|
|
383
|
+
}
|
|
384
|
+
const response = await fetch(registrationUrl, {
|
|
385
|
+
method: "POST",
|
|
386
|
+
headers: {
|
|
387
|
+
"Content-Type": "application/json",
|
|
388
|
+
},
|
|
389
|
+
body: JSON.stringify(clientMetadata),
|
|
390
|
+
});
|
|
391
|
+
if (!response.ok) {
|
|
392
|
+
throw new Error(`Dynamic client registration failed: HTTP ${response.status}`);
|
|
393
|
+
}
|
|
394
|
+
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export { UnauthorizedError, auth, discoverOAuthMetadata, discoverOAuthProtectedResourceMetadata, exchangeAuthorization, extractResourceMetadataUrl, refreshAuthorization, registerClient, selectResourceURL, startAuthorization };
|
|
398
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sources":["../../../../../../../../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js"],"sourcesContent":["import pkceChallenge from \"pkce-challenge\";\nimport { LATEST_PROTOCOL_VERSION } from \"../types.js\";\nimport { OAuthClientInformationFullSchema, OAuthMetadataSchema, OAuthProtectedResourceMetadataSchema, OAuthTokensSchema } from \"../shared/auth.js\";\nimport { checkResourceAllowed, resourceUrlFromServerUrl } from \"../shared/auth-utils.js\";\nexport class UnauthorizedError extends Error {\n constructor(message) {\n super(message !== null && message !== void 0 ? message : \"Unauthorized\");\n }\n}\n/**\n * Orchestrates the full auth flow with a server.\n *\n * This can be used as a single entry point for all authorization functionality,\n * instead of linking together the other lower-level functions in this module.\n */\nexport async function auth(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl }) {\n let resourceMetadata;\n let authorizationServerUrl = serverUrl;\n try {\n resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl });\n if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {\n authorizationServerUrl = resourceMetadata.authorization_servers[0];\n }\n }\n catch (_a) {\n // Ignore errors and fall back to /.well-known/oauth-authorization-server\n }\n const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);\n const metadata = await discoverOAuthMetadata(authorizationServerUrl);\n // Handle client registration if needed\n let clientInformation = await Promise.resolve(provider.clientInformation());\n if (!clientInformation) {\n if (authorizationCode !== undefined) {\n throw new Error(\"Existing OAuth client information is required when exchanging an authorization code\");\n }\n if (!provider.saveClientInformation) {\n throw new Error(\"OAuth client information must be saveable for dynamic registration\");\n }\n const fullInformation = await registerClient(authorizationServerUrl, {\n metadata,\n clientMetadata: provider.clientMetadata,\n });\n await provider.saveClientInformation(fullInformation);\n clientInformation = fullInformation;\n }\n // Exchange authorization code for tokens\n if (authorizationCode !== undefined) {\n const codeVerifier = await provider.codeVerifier();\n const tokens = await exchangeAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n authorizationCode,\n codeVerifier,\n redirectUri: provider.redirectUrl,\n resource,\n });\n await provider.saveTokens(tokens);\n return \"AUTHORIZED\";\n }\n const tokens = await provider.tokens();\n // Handle token refresh or new authorization\n if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {\n try {\n // Attempt to refresh the token\n const newTokens = await refreshAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n refreshToken: tokens.refresh_token,\n resource,\n });\n await provider.saveTokens(newTokens);\n return \"AUTHORIZED\";\n }\n catch (_b) {\n // Could not refresh OAuth tokens\n }\n }\n const state = provider.state ? await provider.state() : undefined;\n // Start new authorization flow\n const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {\n metadata,\n clientInformation,\n state,\n redirectUrl: provider.redirectUrl,\n scope: scope || provider.clientMetadata.scope,\n resource,\n });\n await provider.saveCodeVerifier(codeVerifier);\n await provider.redirectToAuthorization(authorizationUrl);\n return \"REDIRECT\";\n}\nexport async function selectResourceURL(serverUrl, provider, resourceMetadata) {\n const defaultResource = resourceUrlFromServerUrl(serverUrl);\n // If provider has custom validation, delegate to it\n if (provider.validateResourceURL) {\n return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);\n }\n // Only include resource parameter when Protected Resource Metadata is present\n if (!resourceMetadata) {\n return undefined;\n }\n // Validate that the metadata's resource is compatible with our request\n if (!checkResourceAllowed({ requestedResource: defaultResource, configuredResource: resourceMetadata.resource })) {\n throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);\n }\n // Prefer the resource from metadata since it's what the server is telling us to request\n return new URL(resourceMetadata.resource);\n}\n/**\n * Extract resource_metadata from response header.\n */\nexport function extractResourceMetadataUrl(res) {\n const authenticateHeader = res.headers.get(\"WWW-Authenticate\");\n if (!authenticateHeader) {\n return undefined;\n }\n const [type, scheme] = authenticateHeader.split(' ');\n if (type.toLowerCase() !== 'bearer' || !scheme) {\n return undefined;\n }\n const regex = /resource_metadata=\"([^\"]*)\"/;\n const match = regex.exec(authenticateHeader);\n if (!match) {\n return undefined;\n }\n try {\n return new URL(match[1]);\n }\n catch (_a) {\n return undefined;\n }\n}\n/**\n * Looks up RFC 9728 OAuth 2.0 Protected Resource Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n */\nexport async function discoverOAuthProtectedResourceMetadata(serverUrl, opts) {\n var _a;\n let url;\n if (opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl) {\n url = new URL(opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl);\n }\n else {\n url = new URL(\"/.well-known/oauth-protected-resource\", serverUrl);\n }\n let response;\n try {\n response = await fetch(url, {\n headers: {\n \"MCP-Protocol-Version\": (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION\n }\n });\n }\n catch (error) {\n // CORS errors come back as TypeError\n if (error instanceof TypeError) {\n response = await fetch(url);\n }\n else {\n throw error;\n }\n }\n if (response.status === 404) {\n throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);\n }\n return OAuthProtectedResourceMetadataSchema.parse(await response.json());\n}\n/**\n * Helper function to handle fetch with CORS retry logic\n */\nasync function fetchWithCorsRetry(url, headers) {\n try {\n return await fetch(url, { headers });\n }\n catch (error) {\n if (error instanceof TypeError) {\n if (headers) {\n // CORS errors come back as TypeError, retry without headers\n return fetchWithCorsRetry(url);\n }\n else {\n // We're getting CORS errors on retry too, return undefined\n return undefined;\n }\n }\n throw error;\n }\n}\n/**\n * Constructs the well-known path for OAuth metadata discovery\n */\nfunction buildWellKnownPath(pathname) {\n let wellKnownPath = `/.well-known/oauth-authorization-server${pathname}`;\n if (pathname.endsWith('/')) {\n // Strip trailing slash from pathname to avoid double slashes\n wellKnownPath = wellKnownPath.slice(0, -1);\n }\n return wellKnownPath;\n}\n/**\n * Tries to discover OAuth metadata at a specific URL\n */\nasync function tryMetadataDiscovery(url, protocolVersion) {\n const headers = {\n \"MCP-Protocol-Version\": protocolVersion\n };\n return await fetchWithCorsRetry(url, headers);\n}\n/**\n * Determines if fallback to root discovery should be attempted\n */\nfunction shouldAttemptFallback(response, pathname) {\n return !response || response.status === 404 && pathname !== '/';\n}\n/**\n * Looks up RFC 8414 OAuth 2.0 Authorization Server Metadata.\n *\n * If the server returns a 404 for the well-known endpoint, this function will\n * return `undefined`. Any other errors will be thrown as exceptions.\n */\nexport async function discoverOAuthMetadata(authorizationServerUrl, opts) {\n var _a;\n const issuer = new URL(authorizationServerUrl);\n const protocolVersion = (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;\n // Try path-aware discovery first (RFC 8414 compliant)\n const wellKnownPath = buildWellKnownPath(issuer.pathname);\n const pathAwareUrl = new URL(wellKnownPath, issuer);\n let response = await tryMetadataDiscovery(pathAwareUrl, protocolVersion);\n // If path-aware discovery fails with 404, try fallback to root discovery\n if (shouldAttemptFallback(response, issuer.pathname)) {\n const rootUrl = new URL(\"/.well-known/oauth-authorization-server\", issuer);\n response = await tryMetadataDiscovery(rootUrl, protocolVersion);\n }\n if (!response || response.status === 404) {\n return undefined;\n }\n if (!response.ok) {\n throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);\n }\n return OAuthMetadataSchema.parse(await response.json());\n}\n/**\n * Begins the authorization flow with the given server, by generating a PKCE challenge and constructing the authorization URL.\n */\nexport async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource, }) {\n const responseType = \"code\";\n const codeChallengeMethod = \"S256\";\n let authorizationUrl;\n if (metadata) {\n authorizationUrl = new URL(metadata.authorization_endpoint);\n if (!metadata.response_types_supported.includes(responseType)) {\n throw new Error(`Incompatible auth server: does not support response type ${responseType}`);\n }\n if (!metadata.code_challenge_methods_supported ||\n !metadata.code_challenge_methods_supported.includes(codeChallengeMethod)) {\n throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);\n }\n }\n else {\n authorizationUrl = new URL(\"/authorize\", authorizationServerUrl);\n }\n // Generate PKCE challenge\n const challenge = await pkceChallenge();\n const codeVerifier = challenge.code_verifier;\n const codeChallenge = challenge.code_challenge;\n authorizationUrl.searchParams.set(\"response_type\", responseType);\n authorizationUrl.searchParams.set(\"client_id\", clientInformation.client_id);\n authorizationUrl.searchParams.set(\"code_challenge\", codeChallenge);\n authorizationUrl.searchParams.set(\"code_challenge_method\", codeChallengeMethod);\n authorizationUrl.searchParams.set(\"redirect_uri\", String(redirectUrl));\n if (state) {\n authorizationUrl.searchParams.set(\"state\", state);\n }\n if (scope) {\n authorizationUrl.searchParams.set(\"scope\", scope);\n }\n if (resource) {\n authorizationUrl.searchParams.set(\"resource\", resource.href);\n }\n return { authorizationUrl, codeVerifier };\n}\n/**\n * Exchanges an authorization code for an access token with the given server.\n */\nexport async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, }) {\n const grantType = \"authorization_code\";\n let tokenUrl;\n if (metadata) {\n tokenUrl = new URL(metadata.token_endpoint);\n if (metadata.grant_types_supported &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n }\n else {\n tokenUrl = new URL(\"/token\", authorizationServerUrl);\n }\n // Exchange code for tokens\n const params = new URLSearchParams({\n grant_type: grantType,\n client_id: clientInformation.client_id,\n code: authorizationCode,\n code_verifier: codeVerifier,\n redirect_uri: String(redirectUri),\n });\n if (clientInformation.client_secret) {\n params.set(\"client_secret\", clientInformation.client_secret);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n body: params,\n });\n if (!response.ok) {\n throw new Error(`Token exchange failed: HTTP ${response.status}`);\n }\n return OAuthTokensSchema.parse(await response.json());\n}\n/**\n * Exchange a refresh token for an updated access token.\n */\nexport async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, }) {\n const grantType = \"refresh_token\";\n let tokenUrl;\n if (metadata) {\n tokenUrl = new URL(metadata.token_endpoint);\n if (metadata.grant_types_supported &&\n !metadata.grant_types_supported.includes(grantType)) {\n throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);\n }\n }\n else {\n tokenUrl = new URL(\"/token\", authorizationServerUrl);\n }\n // Exchange refresh token\n const params = new URLSearchParams({\n grant_type: grantType,\n client_id: clientInformation.client_id,\n refresh_token: refreshToken,\n });\n if (clientInformation.client_secret) {\n params.set(\"client_secret\", clientInformation.client_secret);\n }\n if (resource) {\n params.set(\"resource\", resource.href);\n }\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n body: params,\n });\n if (!response.ok) {\n throw new Error(`Token refresh failed: HTTP ${response.status}`);\n }\n return OAuthTokensSchema.parse({ refresh_token: refreshToken, ...(await response.json()) });\n}\n/**\n * Performs OAuth 2.0 Dynamic Client Registration according to RFC 7591.\n */\nexport async function registerClient(authorizationServerUrl, { metadata, clientMetadata, }) {\n let registrationUrl;\n if (metadata) {\n if (!metadata.registration_endpoint) {\n throw new Error(\"Incompatible auth server: does not support dynamic client registration\");\n }\n registrationUrl = new URL(metadata.registration_endpoint);\n }\n else {\n registrationUrl = new URL(\"/register\", authorizationServerUrl);\n }\n const response = await fetch(registrationUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(clientMetadata),\n });\n if (!response.ok) {\n throw new Error(`Dynamic client registration failed: HTTP ${response.status}`);\n }\n return OAuthClientInformationFullSchema.parse(await response.json());\n}\n//# sourceMappingURL=auth.js.map"],"names":[],"mappings":";;;;;AAIO,MAAM,iBAAiB,SAAS,KAAK,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAChF,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAAE;AACnG,IAAI,IAAI,gBAAgB;AACxB,IAAI,IAAI,sBAAsB,GAAG,SAAS;AAC1C,IAAI,IAAI;AACR,QAAQ,gBAAgB,GAAG,MAAM,sCAAsC,CAAC,SAAS,EAAE,EAAE,mBAAmB,EAAE,CAAC;AAC3G,QAAQ,IAAI,gBAAgB,CAAC,qBAAqB,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE;AACzG,YAAY,sBAAsB,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC9E,QAAQ;AACR,IAAI;AACJ,IAAI,OAAO,EAAE,EAAE;AACf;AACA,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,CAAC;AACnF,IAAI,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,sBAAsB,CAAC;AACxE;AACA,IAAI,IAAI,iBAAiB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CA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