modality-ai 0.8.0 → 0.8.1
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 +13 -2
- package/dist/types/mcp-oauth-provider.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129483,6 +129483,7 @@ class CLIBrowserOAuthProvider {
|
|
|
129483
129483
|
_resolveCode;
|
|
129484
129484
|
_rejectCode;
|
|
129485
129485
|
_pendingCode;
|
|
129486
|
+
_codeSettled = false;
|
|
129486
129487
|
_codeVerifier;
|
|
129487
129488
|
_clientInfo;
|
|
129488
129489
|
_tokens;
|
|
@@ -129609,7 +129610,7 @@ class CLIBrowserOAuthProvider {
|
|
|
129609
129610
|
return this._pendingCode;
|
|
129610
129611
|
}
|
|
129611
129612
|
get oauthState() {
|
|
129612
|
-
return this.
|
|
129613
|
+
return this.state();
|
|
129613
129614
|
}
|
|
129614
129615
|
get callbackPath() {
|
|
129615
129616
|
return this._callbackPath;
|
|
@@ -129654,22 +129655,29 @@ class CLIBrowserOAuthProvider {
|
|
|
129654
129655
|
if (url5.pathname !== this._callbackPath) {
|
|
129655
129656
|
return new Response("Not found", { status: 404 });
|
|
129656
129657
|
}
|
|
129658
|
+
if (this._codeSettled) {
|
|
129659
|
+
return errorPage("already_completed", "Authorization code was already received.");
|
|
129660
|
+
}
|
|
129657
129661
|
const returnedState = url5.searchParams.get("state");
|
|
129658
129662
|
if (returnedState !== null && returnedState !== this._state) {
|
|
129663
|
+
this._codeSettled = true;
|
|
129659
129664
|
this._rejectCode?.(new Error("OAuth state mismatch"));
|
|
129660
129665
|
return errorPage("state_mismatch", "State parameter did not match.");
|
|
129661
129666
|
}
|
|
129662
129667
|
const error54 = url5.searchParams.get("error");
|
|
129663
129668
|
if (error54) {
|
|
129664
129669
|
const description = url5.searchParams.get("error_description") ?? "";
|
|
129670
|
+
this._codeSettled = true;
|
|
129665
129671
|
this._rejectCode?.(new Error(`OAuth error: ${error54} — ${description}`));
|
|
129666
129672
|
return errorPage(error54, description);
|
|
129667
129673
|
}
|
|
129668
129674
|
const code = url5.searchParams.get("code");
|
|
129669
129675
|
if (!code) {
|
|
129676
|
+
this._codeSettled = true;
|
|
129670
129677
|
this._rejectCode?.(new Error("OAuth callback missing authorization code"));
|
|
129671
129678
|
return errorPage("no_code", "No authorization code received.");
|
|
129672
129679
|
}
|
|
129680
|
+
this._codeSettled = true;
|
|
129673
129681
|
this._resolveCode?.(code);
|
|
129674
129682
|
return successPage();
|
|
129675
129683
|
}
|
|
@@ -129716,6 +129724,9 @@ function successPage() {
|
|
|
129716
129724
|
</html>`;
|
|
129717
129725
|
return new Response(body, { status: 200, headers: { "Content-Type": "text/html" } });
|
|
129718
129726
|
}
|
|
129727
|
+
function escapeHtml2(s) {
|
|
129728
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
129729
|
+
}
|
|
129719
129730
|
function errorPage(error54, description) {
|
|
129720
129731
|
const body = `<!DOCTYPE html>
|
|
129721
129732
|
<html lang="en">
|
|
@@ -129753,7 +129764,7 @@ function errorPage(error54, description) {
|
|
|
129753
129764
|
<div class="card">
|
|
129754
129765
|
<span class="icon">❌</span>
|
|
129755
129766
|
<h1>Authentication failed</h1>
|
|
129756
|
-
<p><code>${error54}</code>${description ? `: ${description}` : ""}</p>
|
|
129767
|
+
<p><code>${escapeHtml2(error54)}</code>${description ? `: ${escapeHtml2(description)}` : ""}</p>
|
|
129757
129768
|
</div>
|
|
129758
129769
|
</body>
|
|
129759
129770
|
</html>`;
|
package/package.json
CHANGED