@hazem3500/palette 0.9.126 → 0.9.128
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/NODE.md +4 -2
- package/dist/chunk-5WDIM47T.js +1 -0
- package/dist/index.js +1 -1
- package/dist/node.mjs +21 -7
- package/dist/react.js +1 -1
- package/dist/server.js +21 -7
- package/dist/setup.js +1 -1
- package/package.json +1 -1
- package/server/index.ts +31 -6
- package/server/setup-client.txt +59 -59
- package/dist/chunk-TVBEFG2A.js +0 -1
package/dist/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n,d as o}from"./chunk-
|
|
1
|
+
import{a as n,d as o}from"./chunk-5WDIM47T.js";import"./chunk-KLPQTFVH.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-HHUTDVTM.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-J47R52WX.js";import"./chunk-VX6XCU4E.js";import"./chunk-4HBBEVFK.js";function r(r){return(t={})=>o(n({...r,...t}))}var t=r;export{t as defineKomo,r as definePalette};
|
package/package.json
CHANGED
package/server/index.ts
CHANGED
|
@@ -611,7 +611,8 @@ async function finishSignIn(
|
|
|
611
611
|
saved: SignInState,
|
|
612
612
|
user: Identity,
|
|
613
613
|
provider: "github" | "google",
|
|
614
|
-
via: SessionVia = provider
|
|
614
|
+
via: SessionVia = provider,
|
|
615
|
+
frame = false
|
|
615
616
|
) {
|
|
616
617
|
const setupCode =
|
|
617
618
|
env.PALETTE_HOSTED === "true" &&
|
|
@@ -624,6 +625,7 @@ async function finishSignIn(
|
|
|
624
625
|
403,
|
|
625
626
|
"Use Google to set up inline feedback."
|
|
626
627
|
);
|
|
628
|
+
check(!setupCode || !frame, 400, "Set up inline feedback in a popup.");
|
|
627
629
|
const created = setupCode
|
|
628
630
|
? await completeSetup(
|
|
629
631
|
env,
|
|
@@ -648,20 +650,31 @@ async function finishSignIn(
|
|
|
648
650
|
token: accessToken,
|
|
649
651
|
user,
|
|
650
652
|
},
|
|
651
|
-
saved.origin
|
|
653
|
+
saved.origin,
|
|
654
|
+
frame
|
|
652
655
|
);
|
|
653
656
|
}
|
|
654
657
|
// The popup posts the session back to the site that opened it, then closes.
|
|
655
|
-
|
|
658
|
+
// A silent sign-in loads the page in a hidden frame instead: only the site
|
|
659
|
+
// that started the sign-in may embed it, and only that site receives the
|
|
660
|
+
// session, the same site a popup would post it to.
|
|
661
|
+
function signedInPage(
|
|
662
|
+
message: Record<string, unknown>,
|
|
663
|
+
origin: string,
|
|
664
|
+
frame = false
|
|
665
|
+
) {
|
|
656
666
|
const nonce = crypto.randomUUID();
|
|
657
667
|
const body = JSON.stringify(message).replace(/</g, "\\u003c");
|
|
658
668
|
const target = JSON.stringify(origin).replace(/</g, "\\u003c");
|
|
669
|
+
const post = frame
|
|
670
|
+
? `if(window.parent!==window)window.parent.postMessage(${body},${target});`
|
|
671
|
+
: `if(window.opener){window.opener.postMessage(${body},${target});window.close();}`;
|
|
659
672
|
return new Response(
|
|
660
|
-
`<!doctype html><meta charset="utf-8"><title>Signed in</title><p>You’re signed in. You can close this window and return to your comments.</p><script nonce="${nonce}"
|
|
673
|
+
`<!doctype html><meta charset="utf-8"><title>Signed in</title><p>You’re signed in. You can close this window and return to your comments.</p><script nonce="${nonce}">${post}</script>`,
|
|
661
674
|
{
|
|
662
675
|
headers: {
|
|
663
676
|
"Content-Type": "text/html; charset=utf-8",
|
|
664
|
-
"Content-Security-Policy": `default-src 'none'; script-src 'nonce-${nonce}'; frame-ancestors 'none'`,
|
|
677
|
+
"Content-Security-Policy": `default-src 'none'; script-src 'nonce-${nonce}'; frame-ancestors ${frame && exactOrigin(origin) ? origin : "'none'"}`,
|
|
665
678
|
"Cache-Control": "no-store",
|
|
666
679
|
"Set-Cookie":
|
|
667
680
|
"__Host-comments-oauth=; HttpOnly; Secure; SameSite=Lax; Path=/; Max-Age=0",
|
|
@@ -669,6 +682,14 @@ function signedInPage(message: Record<string, unknown>, origin: string) {
|
|
|
669
682
|
}
|
|
670
683
|
);
|
|
671
684
|
}
|
|
685
|
+
// An origin is safe to place in a CSP source list only in its serialized form.
|
|
686
|
+
function exactOrigin(value: string) {
|
|
687
|
+
try {
|
|
688
|
+
return new URL(value).origin === value;
|
|
689
|
+
} catch {
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
672
693
|
// Records the account a sign-in proxy vouched for as a verified reviewer.
|
|
673
694
|
async function proxyUser(env: Env, signedIn: ProxyIdentity) {
|
|
674
695
|
await env.DB.prepare(
|
|
@@ -706,7 +727,8 @@ async function proxySignIn(
|
|
|
706
727
|
saved,
|
|
707
728
|
await proxyUser(env, signedIn),
|
|
708
729
|
proxy.signIn,
|
|
709
|
-
"proxy"
|
|
730
|
+
"proxy",
|
|
731
|
+
url.searchParams.get("frame") === "1"
|
|
710
732
|
);
|
|
711
733
|
}
|
|
712
734
|
// For agents and CLIs: a caller the proxy authenticated exchanges that
|
|
@@ -1168,6 +1190,9 @@ async function route(
|
|
|
1168
1190
|
private: await privateAccess(env, project),
|
|
1169
1191
|
guestResolve: config.allowGuestResolve !== false,
|
|
1170
1192
|
tokens: !auth.proxy || auth.proxyAccessTokens,
|
|
1193
|
+
// Behind a sign-in proxy the browser may already be signed in, so the
|
|
1194
|
+
// client can try a sign-in in a hidden frame before showing the button.
|
|
1195
|
+
silentSignIn: !!auth.proxy,
|
|
1171
1196
|
// Element snapshots are opt-in on the client; guests need project consent.
|
|
1172
1197
|
// Clients may send `share` on new threads and edit `/me/settings`.
|
|
1173
1198
|
share: true,
|