@urun-sh/next 0.2.36 → 0.2.38

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.d.cts CHANGED
@@ -55,9 +55,13 @@ declare function resolveCredential(env?: Record<string, string | undefined>): Pr
55
55
  * SECURITY MODEL of the per-request body: the browser may only NARROW the
56
56
  * scope your options configured — request a SUBSET of a configured function /
57
57
  * origin allowlist, LOWER the expiry, and maxSessionS folds by MIN. It can
58
- * never widen anything, and it can never choose its own `subject` (identity
59
- * is server-derived via `options.subject`, defaulting to a random subject per
60
- * token so distinct end-users never share a session).
58
+ * never widen anything, and it can never choose its own `subject`. Identity
59
+ * is server-derived: `options.subject` when configured, otherwise the ONE
60
+ * fixed {@link DEFAULT_ONRAMP_SUBJECT} the dev/single-identity setup, where
61
+ * every tab and browser is the SAME user sharing ONE session. Real multi-user
62
+ * identity comes from your own auth provider: derive per-user subjects in
63
+ * `options.subject` from your auth session, or set up your own JWTs via the
64
+ * org trusted-JWKS path and skip the onramp mint entirely.
61
65
  *
62
66
  * SECURITY MODEL of the route itself: `options.authorize` is required and
63
67
  * must return true before the route mints a token.
@@ -65,6 +69,21 @@ declare function resolveCredential(env?: Record<string, string | undefined>): Pr
65
69
 
66
70
  /** The standard env secret the route reads the org API key from. */
67
71
  declare const URUN_API_KEY_ENV = "URUN_API_KEY";
72
+ /**
73
+ * The subject every token carries when `options.subject` is absent (or
74
+ * returns undefined): ONE fixed, deterministic identity — never random.
75
+ * Owner ruling 2026-07-17: "not per browser SINGLE SUBJECT, full stop. this
76
+ * is a dev setup. user wants > 1 user? setup the proper auth provider with
77
+ * your own jwts and trust them."
78
+ *
79
+ * The platform enforces one session per user per app function keyed on the
80
+ * token subject; a random per-token subject made two dials from the SAME
81
+ * browser look like different users, so the reconnect invariant could never
82
+ * fire. With this constant, every tab/browser hitting the onramp route is the
83
+ * SAME user: a dev app has ONE session and every dial reconnects to it.
84
+ * Tokens are org-scoped, so the literal constant never collides across orgs.
85
+ */
86
+ declare const DEFAULT_ONRAMP_SUBJECT = "onramp";
68
87
  /**
69
88
  * Canonical env var names carrying a frontend's session-plane config — the
70
89
  * values `urun deploy` writes into `frontend/.env.local` and `urun dev`
@@ -116,9 +135,14 @@ interface UrunTokenRouteOptions extends Omit<CreateClientTokenOptions, 'fetch' |
116
135
  authorize: (request: Request | UrunTokenPagesRequest) => boolean | Promise<boolean>;
117
136
  /**
118
137
  * Derive a STABLE per-end-user subject from the request (e.g. your auth
119
- * session). A stable subject coalesces one user's tabs into one session;
120
- * omitted, every token gets a random subject (users never share sessions).
121
- * The browser body can never set this.
138
+ * session). A stable subject coalesces one user's tabs into one session.
139
+ * Omitted (or returning undefined), the route sends the ONE fixed
140
+ * {@link DEFAULT_ONRAMP_SUBJECT}: the dev/single-identity setup every
141
+ * tab and browser is the SAME user, sharing ONE session. Real multi-user
142
+ * identity comes from your own auth provider: derive per-user subjects
143
+ * here from your auth session, or set up your own JWTs via the org
144
+ * trusted-JWKS path and skip the onramp mint entirely. The browser body
145
+ * can never set this.
122
146
  */
123
147
  subject?: (request: Request) => string | undefined | Promise<string | undefined>;
124
148
  /** Fetch override (tests / custom agents). */
@@ -200,4 +224,4 @@ declare function createTokenRoute(options?: CreateTokenRouteOptions): (request:
200
224
  */
201
225
  declare function urunTokenPagesHandler(options: UrunTokenRouteOptions): (req: UrunTokenPagesRequest, res: UrunTokenPagesResponse) => Promise<void>;
202
226
 
203
- export { type CreateTokenRouteOptions, type CreateTokenRouteResponseBody, MissingCredentialError, URUN_API_KEY_ENV, URUN_API_URL_ENV, URUN_APP_ENV, URUN_FUNCTION_ENV, URUN_GATEWAY_URL_ENV, type UrunSessionConfig, type UrunTokenPagesRequest, type UrunTokenPagesResponse, type UrunTokenResponseBody, type UrunTokenRouteOptions, createTokenRoute, resolveCredential, urunSessionConfig, urunTokenPagesHandler, urunTokenRoute };
227
+ export { type CreateTokenRouteOptions, type CreateTokenRouteResponseBody, DEFAULT_ONRAMP_SUBJECT, MissingCredentialError, URUN_API_KEY_ENV, URUN_API_URL_ENV, URUN_APP_ENV, URUN_FUNCTION_ENV, URUN_GATEWAY_URL_ENV, type UrunSessionConfig, type UrunTokenPagesRequest, type UrunTokenPagesResponse, type UrunTokenResponseBody, type UrunTokenRouteOptions, createTokenRoute, resolveCredential, urunSessionConfig, urunTokenPagesHandler, urunTokenRoute };
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ declare function resolveCredential(env?: Record<string, string | undefined>): Pr
15
15
 
16
16
  declare const URUN_API_KEY_ENV = "URUN_API_KEY";
17
17
 
18
+ declare const DEFAULT_ONRAMP_SUBJECT = "onramp";
19
+
18
20
  declare const URUN_GATEWAY_URL_ENV = "URUN_GATEWAY_URL";
19
21
 
20
22
  declare const URUN_API_URL_ENV = "URUN_API_URL";
@@ -73,4 +75,4 @@ declare function createTokenRoute(options?: CreateTokenRouteOptions): (request:
73
75
 
74
76
  declare function urunTokenPagesHandler(options: UrunTokenRouteOptions): (req: UrunTokenPagesRequest, res: UrunTokenPagesResponse) => Promise<void>;
75
77
 
76
- export { type CreateTokenRouteOptions, type CreateTokenRouteResponseBody, MissingCredentialError, URUN_API_KEY_ENV, URUN_API_URL_ENV, URUN_APP_ENV, URUN_FUNCTION_ENV, URUN_GATEWAY_URL_ENV, type UrunSessionConfig, type UrunTokenPagesRequest, type UrunTokenPagesResponse, type UrunTokenResponseBody, type UrunTokenRouteOptions, createTokenRoute, resolveCredential, urunSessionConfig, urunTokenPagesHandler, urunTokenRoute };
78
+ export { type CreateTokenRouteOptions, type CreateTokenRouteResponseBody, DEFAULT_ONRAMP_SUBJECT, MissingCredentialError, URUN_API_KEY_ENV, URUN_API_URL_ENV, URUN_APP_ENV, URUN_FUNCTION_ENV, URUN_GATEWAY_URL_ENV, type UrunSessionConfig, type UrunTokenPagesRequest, type UrunTokenPagesResponse, type UrunTokenResponseBody, type UrunTokenRouteOptions, createTokenRoute, resolveCredential, urunSessionConfig, urunTokenPagesHandler, urunTokenRoute };