smoodly 0.0.40 → 0.0.42

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.
@@ -28,6 +28,9 @@ export function createSmoodlyAdmin(input) {
28
28
  // Presence is the one thing that needs it: a failed lookup (an unmigrated project, an
29
29
  // unreachable database) is logged and turns presence off, so the shell still reaches
30
30
  // sign-in, the schema notice or the admin-path ErrorPane.
31
+ // Auth first: an admin that cannot start (a missing publishable key) fails on its own
32
+ // error, not after a presence line that suggests it runs without presence.
33
+ const auth = input.auth();
31
34
  let presenceConfig;
32
35
  try {
33
36
  presenceConfig = await input.presence?.();
@@ -35,7 +38,7 @@ export function createSmoodlyAdmin(input) {
35
38
  catch (e) {
36
39
  console.error("smoodly: editing presence is off —", e instanceof Error ? e.message : e);
37
40
  }
38
- return (_jsxs("div", { className: "sm-admin", suppressHydrationWarning: true, children: [_jsx(AdminStyles, {}), _jsx(AdminApp, { registry: registry, op: input.op, auth: input.auth(), presenceConfig: presenceConfig }), children] }));
41
+ return (_jsxs("div", { className: "sm-admin", suppressHydrationWarning: true, children: [_jsx(AdminStyles, {}), _jsx(AdminApp, { registry: registry, op: input.op, auth: auth, presenceConfig: presenceConfig }), children] }));
39
42
  }
40
43
  return { AdminPage, AdminLayout };
41
44
  }
@@ -11,7 +11,7 @@ export function supabaseAdminAuth(input) {
11
11
  let client = null;
12
12
  const auth = () => {
13
13
  if (!input.authKey) {
14
- throw new Error("smoodly: set SMOODLY_PUBLISHABLE_KEY in .env.local — the admin signs in with it (Deploying: https://smoodly.io/docs/getting-started/deploying).");
14
+ throw new Error("smoodly: set SMOODLY_PUBLISHABLE_KEY in .env.local, or in your host's environment variables — the admin signs in with it (Deploying: https://smoodly.io/docs/getting-started/deploying).");
15
15
  }
16
16
  return (client ?? (client = createClient(input.authUrl, input.authKey, { auth: { persistSession: false, autoRefreshToken: false } })));
17
17
  };
package/dist/cli/main.js CHANGED
@@ -35,7 +35,7 @@ export const USAGE = `usage: smoodly <command>
35
35
  whose link lands on --admin-url (default: SITE_URL + /admin).`;
36
36
  export function parseArgs(argv) {
37
37
  const [command, ...rest] = argv;
38
- if (!command || command === "--help" || command === "-h" || command === "help")
38
+ if (!command || command === "help" || argv.some((a) => a === "--help" || a === "-h"))
39
39
  return { command: "help" };
40
40
  if (command === "export") {
41
41
  const args = { out: null };
package/dist/client.js CHANGED
@@ -11,18 +11,32 @@ export function clientOptions(env) {
11
11
  // without one (spec 2026-09-30 tester findings §4): a self-host service role is a valid apikey.
12
12
  return { url: env.url, key: env.publishableKey || env.secretKey, headers: { Authorization: `Bearer ${env.secretKey}` } };
13
13
  }
14
- /** fetch that names the address when the network fails: supabase-js reports only
15
- * "TypeError: fetch failed", which names neither the variable nor the URL. */
14
+ /** fetch that names the variable behind two failures supabase-js reports bare: the network
15
+ * ("TypeError: fetch failed") and PostgREST refusing the key. */
16
16
  function namedFetch(url) {
17
17
  return async (input, init) => {
18
+ let res;
18
19
  try {
19
- return await fetch(input, init);
20
+ res = await fetch(input, init);
20
21
  }
21
22
  catch (e) {
22
23
  if (e instanceof Error && e.name === "AbortError")
23
24
  throw e;
24
25
  throw new TypeError(`can't reach SMOODLY_URL (${url}): ${e instanceof Error ? e.message : String(e)}`);
25
26
  }
27
+ if (res.status !== 401)
28
+ return res;
29
+ // PostgREST's key errors are PGRST300–303; their message varies by version ("JWT cryptographic
30
+ // operation failed", "No suitable key or wrong key type").
31
+ const body = (await res.clone().json().catch(() => null));
32
+ if (typeof body?.message !== "string")
33
+ return res;
34
+ if (!(typeof body.code === "string" && /^PGRST30\d$/.test(body.code)) && !/JWT/i.test(body.message))
35
+ return res;
36
+ const headers = new Headers(res.headers);
37
+ headers.delete("content-length");
38
+ const message = `SMOODLY_SECRET_KEY is not a valid key for SMOODLY_URL (${url}): ${body.message}`;
39
+ return new Response(JSON.stringify({ ...body, message }), { status: 401, statusText: res.statusText, headers });
26
40
  };
27
41
  }
28
42
  /** The server-side client the stores are built on. */
package/dist/env.js CHANGED
@@ -25,7 +25,7 @@ function jwtRole(v) {
25
25
  export function resolveSmoodlyEnv(env, need = "site") {
26
26
  const missing = (need === "admin" ? ADMIN_NEEDS : SITE_NEEDS).filter((name) => !env[name]);
27
27
  if (missing.length > 0)
28
- throw new Error(`smoodly: set ${missing.join(", ")} in .env.local (Deploying: ${DEPLOYING}).`);
28
+ throw new Error(`smoodly: set ${missing.join(", ")} in .env.local, or in your host's environment variables (Deploying: ${DEPLOYING}).`);
29
29
  const secretKey = env.SMOODLY_SECRET_KEY;
30
30
  const publishableKey = env.SMOODLY_PUBLISHABLE_KEY ?? "";
31
31
  if (secretKey.startsWith("sb_publishable_") || jwtRole(secretKey) === "anon") {
@@ -13,7 +13,9 @@ export async function previewRoute(request) {
13
13
  }
14
14
  else {
15
15
  const secret = process.env.SMOODLY_PREVIEW_SECRET;
16
- if (!secret || url.searchParams.get("secret") !== secret)
16
+ if (!secret)
17
+ return new Response("Draft links are off: SMOODLY_PREVIEW_SECRET is not set.", { status: 401 });
18
+ if (url.searchParams.get("secret") !== secret)
17
19
  return new Response("Invalid secret", { status: 401 });
18
20
  draft.enable();
19
21
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SMOODLY_VERSION = "0.0.40";
1
+ export declare const SMOODLY_VERSION = "0.0.42";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/write-version.mjs from package.json — do not edit.
2
- export const SMOODLY_VERSION = "0.0.40";
2
+ export const SMOODLY_VERSION = "0.0.42";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoodly",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "description": "Open-source, code-first CMS for Next.js on Supabase: define a component once, it becomes a typed, editable building block.",
5
5
  "license": "MIT",
6
6
  "repository": {