@softr/sdk 0.0.22-alpha.2 → 0.0.22

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.
@@ -3,11 +3,7 @@ import { makeSessionClearingCookies, makeSessionTokenCookie, sessionTokenCookieN
3
3
  //#region src/preview-identity/preview-identity.ts
4
4
  const PREVIEW_REDEMPTION_PATH = "/__preview/identity";
5
5
  const PREVIEW_SIGNED_IN_PATH = "/__preview/signed-in";
6
- /**
7
- * Signs the preview in as one of the app's own users by spending the one-time grant studio-api put
8
- * in this URL. No cookie of its own is forwarded: the grant is the only credential, and studio-api
9
- * authorized the builder before it issued one.
10
- */
6
+ /** The grant in the URL is the only credential: studio-api authorized the builder before issuing it. */
11
7
  const redeemGrant = async (req, res) => {
12
8
  res.setHeader("Cache-Control", "no-store");
13
9
  res.setHeader("Referrer-Policy", "no-referrer");
@@ -34,14 +30,7 @@ const redeemGrant = async (req, res) => {
34
30
  res.setHeader("Set-Cookie", session.anonymous ? makeSessionClearingCookies(secure) : makeSessionTokenCookie(session.jwt, secure));
35
31
  res.end();
36
32
  };
37
- /**
38
- * Whether the preview currently holds a session, and nothing else.
39
- *
40
- * Presence only, never decoded: whether anyone is signed in is all Studio's picker needs, and
41
- * decoding would put an app user's identity on a route the studio bundle can read. Asked under the
42
- * one name this scheme's app would read, so a cookie the app ignores reads as signed out here too
43
- * rather than as a session it cannot see.
44
- */
33
+ /** Presence only, never decoded: decoding would put an app user's identity on a route Studio reads. */
45
34
  const reportSignedIn = (req, res) => {
46
35
  res.setHeader("Cache-Control", "no-store");
47
36
  if (req.method !== "GET") {
@@ -89,13 +78,7 @@ async function redeemPreviewGrant(req, grant) {
89
78
  };
90
79
  }
91
80
  const STAGING_HOST_PATTERN = /(?:^|\.)staging(\d+)\.softr\.io$/;
92
- /**
93
- * The studio-api base URL of the environment this dev server runs in, read off the request's host.
94
- *
95
- * The host is the only per-environment signal the app has: it is served at
96
- * `<slug>-app.vibe-coding-preview.staging12.softr.io`, and staging 12's API is
97
- * `studio-api-staging12.softr.io`. Every other host gives `null` — localhost included.
98
- */
81
+ /** The host is the only per-environment signal the app has. Anything but a staging one gives null. */
99
82
  function studioApiUrlFor(req) {
100
83
  const forwarded = req.headers["x-forwarded-host"];
101
84
  const name = ((Array.isArray(forwarded) ? forwarded[0] : forwarded) ?? req.headers.host ?? "").split(",")[0].trim().split(":")[0];
@@ -111,12 +94,9 @@ function hasSessionCookie(header, name) {
111
94
  });
112
95
  }
113
96
  /**
114
- * Whether this request is https, by the same rule the session code reads the cookie back with.
115
- *
116
- * h3's `getRequestProtocol` compares `x-forwarded-proto` for exact equality, so it reads anything
117
- * else — `https, http` from a two-hop chain, or `HTTPS` — as not-https. Being more generous here
118
- * than it is writes `__Host-session_token` where the app then looks up `session_token`, and the
119
- * visitor is silently anonymous with no error on either side.
97
+ * Exactly as strict as h3's `getRequestProtocol`, which reads the cookie back. Being more generous
98
+ * writes `__Host-session_token` where the app looks up `session_token`, and the visitor is silently
99
+ * anonymous with no error on either side.
120
100
  */
121
101
  function requestIsHttps(req) {
122
102
  const forwarded = req.headers["x-forwarded-proto"];
package/dist/vite.js CHANGED
@@ -38,15 +38,10 @@ function softr() {
38
38
  ];
39
39
  }
40
40
  /**
41
- * The routes that sign the preview in as one of the app's own users, and report whether it is.
41
+ * Signing the preview in writes the cookie this app's own session code reads back, so it lives here
42
+ * rather than in the edit engine — one implementation of the format, no version to keep in step.
42
43
  *
43
- * They live in this package, not in the edit engine, because signing the preview in means writing
44
- * the very cookie this app's own session code reads back — one implementation of the cookie format,
45
- * with no version to keep in step across a package seam.
46
- *
47
- * `SOFTR_APPLICATION_ID` is the gate: the pod sets it, and it is what binds a redemption to the
48
- * application the grant was issued for. An app running on a developer's machine has none, and
49
- * serves neither route.
44
+ * `SOFTR_APPLICATION_ID` gates it: the pod sets it, a developer's machine has none.
50
45
  */
51
46
  async function previewIdentity() {
52
47
  if (!process.env.SOFTR_APPLICATION_ID) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "0.0.22-alpha.2",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: core
12
12
  library: softr-sdk
13
- library_version: 0.0.22-alpha.2
13
+ library_version: 0.0.22
14
14
  ---
15
15
 
16
16
  # Softr SDK core
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.22-alpha.2
13
+ library_version: 0.0.22
14
14
  ---
15
15
 
16
16
  This skill builds on softr-sdk. Read it first for the entrypoints and the client/server boundary.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.22-alpha.2
13
+ library_version: 0.0.22
14
14
  ---
15
15
 
16
16
  This skill builds on softr-sdk. Read it first for the entrypoints and the wiring that puts a visitor on route context.
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 0.0.22-alpha.2
11
+ library_version: 0.0.22
12
12
  ---
13
13
 
14
14
  This skill builds on softr-sdk. Read it first for the entrypoints and the client/server boundary.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.22-alpha.2
13
+ library_version: 0.0.22
14
14
  ---
15
15
 
16
16
  This skill builds on softr-sdk. Read it first for the entrypoints and the client/server boundary.
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 0.0.22-alpha.2
15
+ library_version: 0.0.22
16
16
  ---
17
17
 
18
18
  This skill builds on softr-sdk. Read it first for the entrypoints and the wiring that puts a visitor on route context.