modality-ai 0.8.2 → 0.8.3
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/index.js
CHANGED
|
@@ -130128,6 +130128,11 @@ var SERVER_IDENTITY_WHITELIST = {
|
|
|
130128
130128
|
client_uri: "https://claude.ai"
|
|
130129
130129
|
}
|
|
130130
130130
|
};
|
|
130131
|
+
var OAUTH_ERROR_CODES = {
|
|
130132
|
+
ALREADY_COMPLETED: "already_completed",
|
|
130133
|
+
STATE_MISMATCH: "state_mismatch",
|
|
130134
|
+
NO_CODE: "no_code"
|
|
130135
|
+
};
|
|
130131
130136
|
|
|
130132
130137
|
class CLIBrowserOAuthProvider {
|
|
130133
130138
|
_clientName;
|
|
@@ -130183,11 +130188,14 @@ class CLIBrowserOAuthProvider {
|
|
|
130183
130188
|
});
|
|
130184
130189
|
this._port = this._server.port ?? 9876;
|
|
130185
130190
|
}
|
|
130186
|
-
|
|
130187
|
-
|
|
130188
|
-
|
|
130189
|
-
|
|
130190
|
-
|
|
130191
|
+
this._invalidateStaleCache(options.clientId);
|
|
130192
|
+
}
|
|
130193
|
+
_invalidateStaleCache(clientId) {
|
|
130194
|
+
if (!this._clientInfo || clientId)
|
|
130195
|
+
return;
|
|
130196
|
+
const uris = this._clientInfo.redirect_uris ?? [];
|
|
130197
|
+
if (!uris.includes(this.redirectUrl)) {
|
|
130198
|
+
this._clientInfo = undefined;
|
|
130191
130199
|
}
|
|
130192
130200
|
}
|
|
130193
130201
|
get redirectUrl() {
|
|
@@ -130232,7 +130240,7 @@ class CLIBrowserOAuthProvider {
|
|
|
130232
130240
|
throw new Error("No PKCE code verifier saved");
|
|
130233
130241
|
return this._codeVerifier;
|
|
130234
130242
|
}
|
|
130235
|
-
addClientAuthentication = (_headers, params) => {
|
|
130243
|
+
addClientAuthentication = (_headers, params, _url3, _metadata) => {
|
|
130236
130244
|
const info3 = this._clientInfo;
|
|
130237
130245
|
if (!info3)
|
|
130238
130246
|
return;
|
|
@@ -130308,7 +130316,9 @@ class CLIBrowserOAuthProvider {
|
|
|
130308
130316
|
state.tokens = this._tokens;
|
|
130309
130317
|
try {
|
|
130310
130318
|
writeFileSync(this._cachePath, JSON.stringify(state, null, 2));
|
|
130311
|
-
} catch {
|
|
130319
|
+
} catch (err) {
|
|
130320
|
+
console.error(`[OAuth] Failed to persist cache to ${this._cachePath}:`, err);
|
|
130321
|
+
}
|
|
130312
130322
|
}
|
|
130313
130323
|
_handleCallback(req) {
|
|
130314
130324
|
const url5 = new URL(req.url);
|
|
@@ -130316,13 +130326,13 @@ class CLIBrowserOAuthProvider {
|
|
|
130316
130326
|
return new Response("Not found", { status: 404 });
|
|
130317
130327
|
}
|
|
130318
130328
|
if (this._codeSettled) {
|
|
130319
|
-
return errorPage(
|
|
130329
|
+
return errorPage(OAUTH_ERROR_CODES.ALREADY_COMPLETED, "Authorization code was already received.");
|
|
130320
130330
|
}
|
|
130321
130331
|
const returnedState = url5.searchParams.get("state");
|
|
130322
130332
|
if (returnedState !== null && returnedState !== this._state) {
|
|
130323
130333
|
this._codeSettled = true;
|
|
130324
130334
|
this._rejectCode?.(new Error("OAuth state mismatch"));
|
|
130325
|
-
return errorPage(
|
|
130335
|
+
return errorPage(OAUTH_ERROR_CODES.STATE_MISMATCH, "State parameter did not match.");
|
|
130326
130336
|
}
|
|
130327
130337
|
const error54 = url5.searchParams.get("error");
|
|
130328
130338
|
if (error54) {
|
|
@@ -130335,7 +130345,7 @@ class CLIBrowserOAuthProvider {
|
|
|
130335
130345
|
if (!code) {
|
|
130336
130346
|
this._codeSettled = true;
|
|
130337
130347
|
this._rejectCode?.(new Error("OAuth callback missing authorization code"));
|
|
130338
|
-
return errorPage(
|
|
130348
|
+
return errorPage(OAUTH_ERROR_CODES.NO_CODE, "No authorization code received.");
|
|
130339
130349
|
}
|
|
130340
130350
|
this._codeSettled = true;
|
|
130341
130351
|
this._resolveCode?.(code);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -46,6 +46,15 @@ interface CLIBrowserOAuthProviderOptions {
|
|
|
46
46
|
*/
|
|
47
47
|
serverUrl?: string | null;
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Per-server OAuth client identity override.
|
|
51
|
+
* Some MCP servers whitelist specific client_name values during dynamic
|
|
52
|
+
* registration — use this map to supply the expected identity automatically.
|
|
53
|
+
*/
|
|
54
|
+
interface ServerClientIdentity {
|
|
55
|
+
client_name: string;
|
|
56
|
+
client_uri: string;
|
|
57
|
+
}
|
|
49
58
|
/**
|
|
50
59
|
* OAuthClientProvider for CLI tools.
|
|
51
60
|
*
|
|
@@ -93,6 +102,12 @@ export declare class CLIBrowserOAuthProvider implements OAuthClientProvider {
|
|
|
93
102
|
private _tokens?;
|
|
94
103
|
private _discoveryState?;
|
|
95
104
|
constructor(options?: CLIBrowserOAuthProviderOptions);
|
|
105
|
+
/**
|
|
106
|
+
* Clear cached clientInfo when its redirect_uris don't match the current redirectUrl.
|
|
107
|
+
* This handles the case where the user switches --callback-port or the cache is stale.
|
|
108
|
+
* Skip invalidation when clientId is explicitly provided (no redirect_uris expected).
|
|
109
|
+
*/
|
|
110
|
+
private _invalidateStaleCache;
|
|
96
111
|
get redirectUrl(): string;
|
|
97
112
|
get clientMetadata(): OAuthClientMetadata;
|
|
98
113
|
clientInformation(): OAuthClientInformationMixed | undefined;
|
|
@@ -149,6 +164,16 @@ export declare class CLIBrowserOAuthProvider implements OAuthClientProvider {
|
|
|
149
164
|
private _persistCache;
|
|
150
165
|
private _handleCallback;
|
|
151
166
|
}
|
|
167
|
+
/** Escape HTML special characters to prevent XSS from attacker-controlled strings. */
|
|
168
|
+
export declare function escapeHtml(s: string): string;
|
|
169
|
+
/** Short stable hash of a string — used to derive a cache file name from a URL. */
|
|
170
|
+
export declare function urlStorageKey(url: string): string;
|
|
171
|
+
/**
|
|
172
|
+
* Returns a whitelisted client identity for the given server URL, or null
|
|
173
|
+
* if none matches. Matching is hostname-suffix based: a key "figma.com"
|
|
174
|
+
* matches "mcp.figma.com", "api.figma.com", etc.
|
|
175
|
+
*/
|
|
176
|
+
export declare function resolveServerIdentity(serverUrl: string): ServerClientIdentity | null;
|
|
152
177
|
/** Options for {@link createHostedOAuth}. */
|
|
153
178
|
export interface HostedOAuthOptions {
|
|
154
179
|
/**
|
package/package.json
CHANGED