@rebasepro/server 0.9.1-canary.fd3754b → 0.10.0

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.
Files changed (50) hide show
  1. package/dist/api/errors.d.ts +16 -1
  2. package/dist/api/rest/api-generator.d.ts +13 -1
  3. package/dist/api/rest/write-validation.d.ts +22 -0
  4. package/dist/api/types.d.ts +2 -2
  5. package/dist/auth/admin-users-route.d.ts +3 -3
  6. package/dist/auth/api-keys/api-key-middleware.d.ts +60 -1
  7. package/dist/auth/api-keys/api-key-permission-guard.d.ts +33 -0
  8. package/dist/auth/api-keys/api-key-types.d.ts +21 -8
  9. package/dist/auth/api-keys/index.d.ts +2 -2
  10. package/dist/auth/auth-hooks.d.ts +7 -7
  11. package/dist/auth/collection-callback-warning.d.ts +21 -0
  12. package/dist/auth/index.d.ts +4 -1
  13. package/dist/auth/interfaces.d.ts +28 -28
  14. package/dist/auth/jwt.d.ts +20 -4
  15. package/dist/auth/magic-link-routes.d.ts +2 -2
  16. package/dist/auth/mfa-routes.d.ts +1 -1
  17. package/dist/auth/middleware.d.ts +24 -3
  18. package/dist/auth/rate-limit-store.d.ts +49 -0
  19. package/dist/auth/rate-limiter.d.ts +68 -6
  20. package/dist/auth/reset-password-admin.d.ts +1 -1
  21. package/dist/auth/session-routes.d.ts +2 -2
  22. package/dist/cron/cron-store.d.ts +18 -0
  23. package/dist/env.d.ts +4 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.es.js +2124 -505
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/init/middlewares.d.ts +1 -0
  28. package/dist/init.d.ts +62 -0
  29. package/dist/{jwt-BwIn8xmk.js → jwt-B3zjddCa.js} +177 -9
  30. package/dist/jwt-B3zjddCa.js.map +1 -0
  31. package/dist/{openapi-generator-Z9oYWLf_.js → openapi-generator-DqSIwNLV.js} +8 -2
  32. package/dist/openapi-generator-DqSIwNLV.js.map +1 -0
  33. package/dist/{src-B4OLmNVa.js → src-CsHhSKbi.js} +60 -2
  34. package/dist/src-CsHhSKbi.js.map +1 -0
  35. package/dist/storage/LocalStorageController.d.ts +19 -2
  36. package/dist/storage/routes.d.ts +8 -1
  37. package/dist/storage/tus-handler.d.ts +21 -1
  38. package/dist/storage/types.d.ts +33 -0
  39. package/dist/utils/compression.d.ts +16 -0
  40. package/dist/utils/sql.d.ts +2 -2
  41. package/package.json +12 -11
  42. package/dist/index.umd.js +0 -48745
  43. package/dist/index.umd.js.map +0 -1
  44. package/dist/jwt-BwIn8xmk.js.map +0 -1
  45. package/dist/ms-DnYXB-Wd.js +0 -162
  46. package/dist/ms-DnYXB-Wd.js.map +0 -1
  47. package/dist/openapi-generator-Z9oYWLf_.js.map +0 -1
  48. package/dist/src-B4OLmNVa.js.map +0 -1
  49. package/dist/src-B9tjYmqP.js +0 -24598
  50. package/dist/src-B9tjYmqP.js.map +0 -1
@@ -78,6 +78,39 @@ export interface GCSStorageConfig {
78
78
  * interface and pass the instance directly to the `storage` config.
79
79
  */
80
80
  export type BackendStorageConfig = LocalStorageConfig | S3StorageConfig | GCSStorageConfig;
81
+ /** What a storage request is trying to do to an object. */
82
+ export type StorageOperation = "read" | "write" | "delete" | "list";
83
+ /** The caller, as resolved by whichever auth middleware ran. */
84
+ export interface StorageAuthorizeUser {
85
+ uid: string;
86
+ email?: string;
87
+ roles?: string[];
88
+ }
89
+ export interface StorageAuthorizeContext {
90
+ /** Object key, bucket prefix stripped and traversal already sanitized. */
91
+ key: string;
92
+ bucket: string;
93
+ operation: StorageOperation;
94
+ /** Null when the route allows unauthenticated access. */
95
+ user: StorageAuthorizeUser | null;
96
+ /** Named backend the request targeted, when one was given. */
97
+ storageId?: string;
98
+ }
99
+ /**
100
+ * Per-object access control for storage, the analogue of an RLS policy on a
101
+ * collection.
102
+ *
103
+ * Without it, storage routes authenticate but do not authorize: `requireAuth`
104
+ * and `publicRead` are global switches, so any signed-in user could read any
105
+ * key they could name. That is fine for a single-tenant app and useless for a
106
+ * multi-tenant one, where the only thing separating two tenants' files would be
107
+ * key unguessability — not an access-control model. Multi-tenant apps were
108
+ * left to route every byte through a custom function to get an ownership check
109
+ * in, and each of them had to invent it.
110
+ *
111
+ * Return false (or throw) to deny. Denials surface as 403.
112
+ */
113
+ export type StorageAuthorize = (ctx: StorageAuthorizeContext) => boolean | Promise<boolean>;
81
114
  /**
82
115
  * Storage controller interface for backend implementations
83
116
  */
@@ -0,0 +1,16 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ /**
3
+ * Response compression (gzip/deflate), negotiated from `Accept-Encoding`.
4
+ *
5
+ * Wraps Hono's `compress` with two corrections it does not make itself:
6
+ *
7
+ * - **`Vary: Accept-Encoding`** on every response it guards. Without it a shared
8
+ * cache may hand a gzipped body to a client that asked for identity.
9
+ * - **Range responses are left alone.** `Content-Range` describes offsets into
10
+ * the identity body, so compressing a 206 desyncs the framing from the bytes
11
+ * actually sent.
12
+ *
13
+ * No brotli: `CompressionStream` has no "br", so a br-only client would fall
14
+ * back to identity — every real client sends gzip too.
15
+ */
16
+ export declare function responseCompression(): MiddlewareHandler;
@@ -2,10 +2,10 @@ import { SQL } from "drizzle-orm";
2
2
  /**
3
3
  * Returns a SQL chunk calling `auth.uid()` — the current user's ID.
4
4
  * This is a PostgreSQL RLS helper function created in the `auth` schema
5
- * that reads `app.user_id` set per-transaction by `withAuth()`.
5
+ * that reads `app.uid` set per-transaction by `withAuth()`.
6
6
  *
7
7
  * @example
8
- * sql`${table.user_id} = ${authUid()}`
8
+ * sql`${table.uid} = ${authUid()}`
9
9
  */
10
10
  export declare const authUid: () => SQL;
11
11
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/server",
3
3
  "type": "module",
4
- "version": "0.9.1-canary.fd3754b",
4
+ "version": "0.10.0",
5
5
  "description": "Database-Agnostic Backend Core for Rebase",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -13,12 +13,12 @@
13
13
  "url": "https://github.com/rebasepro/rebase.git",
14
14
  "directory": "packages/server"
15
15
  },
16
- "main": "./dist/index.umd.js",
16
+ "main": "./dist/index.es.js",
17
17
  "module": "./dist/index.es.js",
18
18
  "types": "./dist/index.d.ts",
19
19
  "source": "src/index.ts",
20
20
  "engines": {
21
- "node": ">=14"
21
+ "node": ">=20"
22
22
  },
23
23
  "keywords": [
24
24
  "rebase",
@@ -34,24 +34,23 @@
34
34
  ".": {
35
35
  "types": "./dist/index.d.ts",
36
36
  "development": "./dist/index.es.js",
37
- "import": "./dist/index.es.js",
38
- "require": "./dist/index.umd.js"
37
+ "import": "./dist/index.es.js"
39
38
  },
40
39
  "./package.json": "./package.json"
41
40
  },
42
41
  "dependencies": {
43
42
  "@hono/node-server": "2.0.4",
44
43
  "drizzle-orm": "^0.45.2",
45
- "hono": "^4.12.25",
46
44
  "jsonwebtoken": "^9.0.3",
47
45
  "ws": "^8.21.0",
48
46
  "zod": "^4.4.3",
49
- "@rebasepro/client": "0.9.1-canary.fd3754b",
50
- "@rebasepro/common": "0.9.1-canary.fd3754b",
51
- "@rebasepro/utils": "0.9.1-canary.fd3754b",
52
- "@rebasepro/types": "0.9.1-canary.fd3754b"
47
+ "@rebasepro/types": "0.10.0",
48
+ "@rebasepro/common": "0.10.0",
49
+ "@rebasepro/client": "0.10.0",
50
+ "@rebasepro/utils": "0.10.0"
53
51
  },
54
52
  "devDependencies": {
53
+ "@jest/globals": "^30.4.1",
55
54
  "@types/jest": "^30.0.0",
56
55
  "@types/jsonwebtoken": "^9.0.10",
57
56
  "@types/node": "^25.9.3",
@@ -61,6 +60,7 @@
61
60
  "@types/ws": "^8.18.1",
62
61
  "@vitejs/plugin-react": "^6.0.2",
63
62
  "cross-env": "^10.1.0",
63
+ "hono": "^4.12.25",
64
64
  "jest": "^30.4.2",
65
65
  "ts-jest": "29.4.11",
66
66
  "typescript": "^6.0.3",
@@ -71,6 +71,7 @@
71
71
  "@aws-sdk/s3-request-presigner": "^3.1068.0",
72
72
  "@google-cloud/storage": "^7.0.0",
73
73
  "google-auth-library": "^10.7.0",
74
+ "hono": "^4.12.25",
74
75
  "nodemailer": "^9.0.0",
75
76
  "sharp": "^0.35.1",
76
77
  "ts-morph": "28.0.0"
@@ -107,7 +108,7 @@
107
108
  ],
108
109
  "scripts": {
109
110
  "watch": "vite build --watch",
110
- "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
111
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json && node ../../scripts/assert-build-output.mjs",
111
112
  "test:lint": "eslint \"src/**\" --quiet",
112
113
  "test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --passWithNoTests --forceExit",
113
114
  "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"