@hazem3500/palette 0.9.113 → 0.9.115

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/setup.js CHANGED
@@ -1 +1 @@
1
- import{a as n,d as o}from"./chunk-CF4GJN3B.js";import"./chunk-KLPQTFVH.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-DU7H4TEX.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};
1
+ import{a as n,d as o}from"./chunk-PI5FFV5P.js";import"./chunk-KLPQTFVH.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-DU7H4TEX.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};
@@ -0,0 +1 @@
1
+ var e="palette-shell",t="palette:shell";function a(t,a){let o=new URL(t,location.href);return o.searchParams.delete("komo-shell"),a?o.searchParams.set(e,a):o.searchParams.delete(e),o.href}function o(e,o=""){try{sessionStorage.removeItem(t),sessionStorage.removeItem("komo:shell"),o&&sessionStorage.setItem("palette:shell-off",o)}catch{}location.replace(a(e,""))}function l(e,o,l,r){try{let n=sessionStorage.getItem("palette:shell-off");if(n)return r(n);if(o&&!confirm(`Reload in Frame?\n\nUnsaved app changes${l?" and unposted Design changes":""} will be lost.`))return r("Reload cancelled.");let s=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join("");sessionStorage.setItem(t,JSON.stringify({v:1,project:e,nonce:s,origin:location.origin})),location.replace(a(location.href,s))}catch{return r("Storage blocked.")}setTimeout(r,3e3,"Reload cancelled.")}function r(e,t){try{let o=e.location.href,l=a(o,t);o.startsWith(location.origin)&&l!==location.href&&history.replaceState(history.state,"",l)}catch{}}export{l as enterShell,o as leaveShellPage,a as shellUrl,r as syncShell};
@@ -4,9 +4,9 @@ export declare function shellUrl(href: string, nonce: string): string;
4
4
  export declare function leaveShellPage(href: string, reason?: string): void;
5
5
  /**
6
6
  * Reloads this page as the shell. `ask` confirms first; `fallback` runs when the
7
- * reviewer keeps two copies, storage is blocked, or the page didn't unload (the
7
+ * reviewer cancels, storage is blocked, or the page didn't unload (the
8
8
  * app's own unsaved-changes guard can keep it).
9
9
  */
10
- export declare function enterShell(project: string, ask: boolean, edited: boolean, fallback: () => void): void;
10
+ export declare function enterShell(project: string, ask: boolean, edited: boolean, fallback: (reason: string) => void): void;
11
11
  /** The shell's URL follows the frame's route, so reloading or sharing it keeps the page. */
12
12
  export declare function syncShell(view: Window | null | undefined, nonce: string): void;
@@ -4,7 +4,7 @@ export declare const SHELL_PARAM = "palette-shell";
4
4
  export declare const LEGACY_SHELL_PARAM = "komo-shell";
5
5
  /** sessionStorage: the shell Palette started in this tab, `{ v, project, nonce, origin }`. */
6
6
  export declare const SHELL_KEY = "palette:shell";
7
- /** sessionStorage: why the last shell ended early. This tab then keeps two copies, without reloading. */
7
+ /** sessionStorage: why the last shell ended early. This tab stays on the normal page until an explicit retry. */
8
8
  export declare const SHELL_OFF_KEY = "palette:shell-off";
9
9
  /** The page's shell nonce, when Palette started a shell for `project` in this tab; else "". */
10
10
  export declare function shellNonce(project: string): string;
package/dist/types.d.ts CHANGED
@@ -275,6 +275,7 @@ export interface CommentsOptions {
275
275
  * Single-copy simulated viewport (with mode "iframe"): turning it on reloads this page as a
276
276
  * shell for Palette, so the app runs once, in the frame. Requires the app's entry
277
277
  * to skip mounting when `isShell(project)` from `@hazem3500/palette/shell` is true.
278
+ * Cancellation or failure keeps the normal page; a second app is never loaded as fallback.
278
279
  */
279
280
  shell?: boolean;
280
281
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazem3500/palette",
3
- "version": "0.9.113",
3
+ "version": "0.9.115",
4
4
  "description": "Point, area, and threaded comments for website branches.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/server/index.ts CHANGED
@@ -1073,7 +1073,7 @@ async function route(
1073
1073
  tokens: await listTokens(env, user.id),
1074
1074
  projects: await accountProjects(env, user.id),
1075
1075
  scopes: PAT_SCOPES,
1076
- ...(auth.proxy ? { policy: { explicitProjects: true, maxLifetimeDays: 365 } } : {}),
1076
+ ...(auth.proxy ? { policy: { explicitProjects: !auth.proxyTokenAllProjects, maxLifetimeDays: 365, noExpiry: auth.proxyTokenNoExpiry } } : {}),
1077
1077
  });
1078
1078
  if (url.pathname === "/account/tokens" && request.method === "POST") {
1079
1079
  await limit(env, `pat:create:${user.id}`, 10, 3600);
@@ -28,6 +28,8 @@ export type AuthOptions = {
28
28
  requireSessionForReads: boolean;
29
29
  allowGuests: boolean;
30
30
  proxyAccessTokens: boolean;
31
+ proxyTokenAllProjects: boolean;
32
+ proxyTokenNoExpiry: boolean;
31
33
  /** Session lifetime cap in milliseconds; undefined keeps the default. */
32
34
  sessionMaxAge?: number;
33
35
  };
@@ -91,12 +93,14 @@ function resolve(env: OptionEnv): AuthOptions {
91
93
  if (days !== undefined && !(/^\d{1,5}$/.test(days) && +days >= 1 && +days <= 36500))
92
94
  throw new ConfigError("PALETTE_SESSION_MAX_AGE_DAYS must be a whole number of days from 1 to 36500.");
93
95
 
94
- // Parse both flags even when a proxy overrides them, so typos still fail.
96
+ // Parse flags even when a proxy overrides them, so typos still fail.
95
97
  const requireSessionForReads = flag(env, "PALETTE_REQUIRE_SESSION_FOR_READS", false);
96
98
  const allowGuests = flag(env, "PALETTE_ALLOW_GUESTS", true);
97
99
  return {
98
100
  proxy,
99
101
  proxyAccessTokens: flag(env, "PALETTE_PROXY_ACCESS_TOKENS", false),
102
+ proxyTokenAllProjects: flag(env, "PALETTE_PROXY_TOKEN_ALL_PROJECTS", false),
103
+ proxyTokenNoExpiry: flag(env, "PALETTE_PROXY_TOKEN_NO_EXPIRY", false),
100
104
  signInPrefix,
101
105
  requireSessionForReads: !!proxy || requireSessionForReads,
102
106
  allowGuests: !proxy && allowGuests,
@@ -20,8 +20,10 @@ export interface ServerEnv {
20
20
  PALETTE_PAUSED?: string;
21
21
  /** Trusted identity proxy that signs reviewers in, e.g. "gcp-iap". Off unless set. */
22
22
  PALETTE_PROXY_AUTH?: string;
23
- /** Explicitly allow bounded, project-scoped access tokens behind a proxy. */
23
+ /** Explicitly allow access tokens behind a proxy, bounded and project-scoped by default. */
24
24
  PALETTE_PROXY_ACCESS_TOKENS?: string;
25
+ PALETTE_PROXY_TOKEN_ALL_PROJECTS?: string;
26
+ PALETTE_PROXY_TOKEN_NO_EXPIRY?: string;
25
27
  /** The audience the proxy signs its assertions for. */
26
28
  PALETTE_PROXY_AUDIENCE?: string;
27
29
  /** Older name: setting it alone turns on "gcp-iap" with this audience. */
@@ -57,6 +59,8 @@ export interface ServerEnv {
57
59
  KOMO_PROXY_AUTH?: string;
58
60
  /** @deprecated Read when PALETTE_PROXY_ACCESS_TOKENS is unset. */
59
61
  KOMO_PROXY_ACCESS_TOKENS?: string;
62
+ KOMO_PROXY_TOKEN_ALL_PROJECTS?: string;
63
+ KOMO_PROXY_TOKEN_NO_EXPIRY?: string;
60
64
  /** @deprecated Read when PALETTE_PROXY_AUDIENCE is unset. */
61
65
  KOMO_PROXY_AUDIENCE?: string;
62
66
  /** @deprecated Read when PALETTE_IAP_AUDIENCE is unset. */