@raybase/create 0.3.14 → 0.3.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raybase/create",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "Scaffold secure internal apps powered by Raybase.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -284,8 +284,10 @@ its own. Do not build an app-side sign-up gate instead; this is the gate.
284
284
  ## Sign-In Rate Limits
285
285
 
286
286
  Raybase limits, per address and per client (`cf-connecting-ip`), asking for
287
- sign-in email (codes, magic links, password-reset links, verification links)
288
- and wrong sign-in codes. The counters are rows in the app's Durable Object
287
+ sign-in email (codes, magic links, password-reset links, verification links),
288
+ wrong sign-in codes, and wrong passwords (at `/api/auth/sign-in/email` and
289
+ Raybase's own password sign-ins, such as `/api/auth/login`, counted
290
+ together). The counters are rows in the app's Durable Object
289
291
  (`_auth_rate_limits`, keys HMAC'd under the auth secret), so every isolate
290
292
  shares them; Better Auth's own in-memory limiter stands aside on those paths.
291
293
 
@@ -293,11 +295,12 @@ shares them; Better Auth's own in-memory limiter stands aside on those paths.
293
295
  |---|---|---|
294
296
  | `emails` | 3 per 10 minutes | 20 per hour |
295
297
  | `wrongCodes` | 10 per hour | 20 per hour |
298
+ | `wrongPasswords` | 10 per hour | 20 per hour |
296
299
 
297
300
  A limited request gets `429`, `Retry-After`, and
298
301
  `{ error, message, code: "rate_limited", retryAfter }`, the same for every
299
- address whether or not it has an account or is listed. A code that signs in is
300
- not counted. Better Auth's `allowedAttempts` (three tries per code) still ends
302
+ address whether or not it has an account or is listed. A code or password that
303
+ signs in is not counted. Better Auth's `allowedAttempts` (three tries per code) still ends
301
304
  each code. Change numbers with `appConfig.auth.rateLimits` (for example
302
305
  `{ emails: { perClient: { max: 50, windowSeconds: 3600 } } }`); every limit
303
306
  stays on. Locally the limits hold too: `GET /api/auth/raybase/sign-in-limits`
@@ -96,6 +96,28 @@ For user-scoped values:
96
96
  const density = await ctx.settings.getForUser(ctx.user.id, "inboxDensity");
97
97
  ```
98
98
 
99
+ ### A person's own preferences
100
+
101
+ A user-scoped setting declared `permissions: { write: "self" }` is the
102
+ signed-in person's to set for themselves; no other setting is:
103
+
104
+ ```ts
105
+ upkeepEmails: setting.boolean({ scope: "user", default: true, label: "Emails about my apps", permissions: { write: "self" } })
106
+ ```
107
+
108
+ - `GET /api/account/settings` lists the person's own values of those settings.
109
+ - `PATCH /api/account/settings/:key` with `{ "value": ... }` sets one, validated
110
+ as an admin write is; `DELETE /api/account/settings/:key` returns it to the
111
+ default. Both are audited with `by: "self"`.
112
+ - Any other key answers 404. `permissions.roles` narrows who may set it;
113
+ `"self"` on an app- or organization-scoped setting is refused at definition.
114
+ - `ctx.settings.get(key)` in that person's requests reads what they set.
115
+
116
+ For a kind of notification a person may switch off, the app's own action can
117
+ call `setNotificationSubscription(ctx.control, { organizationId: ctx.organizationId, userId: ctx.user.id, kind, enabled: false })`:
118
+ `notifications.send` skips them for that `kind` on every channel and reports
119
+ `reason: "unsubscribed"` in `skipped`.
120
+
99
121
  Prefer reading settings at request/action execution time. Do not bake setting
100
122
  values into module scope constants.
101
123
  Module-scope reads freeze an admin override until the worker reloads and can
@@ -1,7 +1,7 @@
1
1
  // Raybase runs in the same worker as the React Router app: workers/app.ts
2
2
  // routes Raybase's own paths here (the admin panel, its API, sign-in, setup
3
3
  // and invite pages, MCP) and everything else to React Router.
4
- import { createRaybaseApp, isRaybaseAdminPanelRequestDisabled } from "@raybase/core/worker";
4
+ import { createRaybaseApp, isRaybaseAdminPanelRequestDisabled, raybaseRequestPath } from "@raybase/core/worker";
5
5
  import type { RaybaseEnv } from "@raybase/core/worker";
6
6
  import { docsModule } from "@raybase/docs";
7
7
  import { appMigrations } from "./db/migrations.gen";
@@ -34,9 +34,10 @@ export class RaybaseAIChatAgentObject extends raybase.RaybaseAIChatAgentObject {
34
34
  const raybasePathPrefixes = ["/admin", "/api", "/login", "/signup", "/setup", "/invite", "/forgot-password", "/reset-password", "/verify-email", "/mcp", "/.well-known"];
35
35
 
36
36
  export function isRaybaseRequest(url: URL): boolean {
37
- return raybasePathPrefixes.some(
38
- (prefix) => url.pathname === prefix || url.pathname.startsWith(`${prefix}/`)
39
- );
37
+ // The path as Raybase's router reads it, percent-encodings decoded, so an
38
+ // encoded "/%61pi/..." reaches Raybase (which refuses it) and not the app.
39
+ const path = raybaseRequestPath(url);
40
+ return raybasePathPrefixes.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
40
41
  }
41
42
 
42
43
  export function isDisabledRaybaseAdminRequest(request: Request): boolean {