@supacloud/lite 0.29.5 → 0.31.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.
- package/CHANGELOG.md +101 -0
- package/dist/cli.js +177 -50
- package/dist/index.js +177 -50
- package/dist/project-runtime.d.ts.map +1 -1
- package/dist/runtime/auth/handler.d.ts +1 -0
- package/dist/runtime/auth/handler.d.ts.map +1 -1
- package/dist/runtime/auth/oauth.d.ts +6 -0
- package/dist/runtime/auth/oauth.d.ts.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/node/load-config.d.ts +3 -0
- package/dist/runtime/node/load-config.d.ts.map +1 -1
- package/dist/runtime/storage/handler.d.ts +3 -0
- package/dist/runtime/storage/handler.d.ts.map +1 -1
- package/dist/runtime/storage/image-transform.d.ts +7 -1
- package/dist/runtime/storage/image-transform.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.31.0](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.30.0...supacloud-lite-v0.31.0) (2026-10-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* @supacloud/app no longer publishes dist/index.cjs or a separate synchronous CommonJS entrypoint. CommonJS consumers should use dynamic import() or migrate to ESM. Release-please should handle the corresponding breaking version change.
|
|
9
|
+
* @supacloud/app no longer publishes dist/index.cjs or a separate synchronous CommonJS entrypoint. CommonJS consumers should use dynamic import() or migrate to ESM. Release-please should handle the corresponding breaking version change.
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add agent backend authoring, runtime and observability workflows ([#1648](https://github.com/vibeunion/supacloud/issues/1648)) ([59a66d1](https://github.com/vibeunion/supacloud/commit/59a66d184a47d19c7f8895f24a6ba2c7e74e93d0))
|
|
14
|
+
* **app:** add governed reactive event streams and lifecycle signals ([38a26e2](https://github.com/vibeunion/supacloud/commit/38a26e2d3b83226a7488df2ef4f1f5714573aeb2))
|
|
15
|
+
* **compiler:** enforce vibecoding defaults ([886c82f](https://github.com/vibeunion/supacloud/commit/886c82f1462261e10c490586cc9446cb447a21ae))
|
|
16
|
+
* converge SDK-aware vibecoding defaults and local development ([#1607](https://github.com/vibeunion/supacloud/issues/1607)) ([cd66672](https://github.com/vibeunion/supacloud/commit/cd6667252a6a8fe0cc0539bc8610ebb8a818af51))
|
|
17
|
+
* default RxJS support with compatible SupaCloud JS calls ([#1556](https://github.com/vibeunion/supacloud/issues/1556)) ([b3015cb](https://github.com/vibeunion/supacloud/commit/b3015cb161c0d87e6611f6c4fc60c120a8c9fffe))
|
|
18
|
+
* **effect:** upgrade runtime governance to Effect 4 ([#1748](https://github.com/vibeunion/supacloud/issues/1748)) ([2b48efc](https://github.com/vibeunion/supacloud/commit/2b48efcbe78db2a61c0c086f3350eaa87c697e90))
|
|
19
|
+
* **elysia:** Elysia 2 AOT evaluation and end-to-end typing architecture ([#1654](https://github.com/vibeunion/supacloud/issues/1654)) ([39ee49f](https://github.com/vibeunion/supacloud/commit/39ee49f760e85e789c43c1d18cf5729db592f6bc))
|
|
20
|
+
* enable strict Effect route governance by default ([#1742](https://github.com/vibeunion/supacloud/issues/1742)) ([4e18c90](https://github.com/vibeunion/supacloud/commit/4e18c908b9c08a8895be016b4e00a0158bf539c6))
|
|
21
|
+
* **governance:** enforce strict user and platform type contracts ([#1754](https://github.com/vibeunion/supacloud/issues/1754)) ([b22f889](https://github.com/vibeunion/supacloud/commit/b22f88919c349f088848028f13b15e44994e0d9c))
|
|
22
|
+
* **lite:** add offline auth user provisioning ([#1911](https://github.com/vibeunion/supacloud/issues/1911)) ([e9c8931](https://github.com/vibeunion/supacloud/commit/e9c89319cf39d9fe2d71ceac9ab76e6856bb5d84))
|
|
23
|
+
* **lite:** bundle PostgreSQL extension parity set ([#1849](https://github.com/vibeunion/supacloud/issues/1849)) ([233fb1b](https://github.com/vibeunion/supacloud/commit/233fb1bb9d52673a7f38d77d47e8c1e6c0b7c5e4))
|
|
24
|
+
* **platform:** close application platform P0/P1 capabilities ([dbaf3a6](https://github.com/vibeunion/supacloud/commit/dbaf3a6d01daa71455a8cde96e9e233743bfdfca))
|
|
25
|
+
* reduce approval infrastructure wiring and reuse business contracts ([#1948](https://github.com/vibeunion/supacloud/issues/1948)) ([7c68543](https://github.com/vibeunion/supacloud/commit/7c6854338968209c2bbd658782224db238650aeb))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **deps,perf:** replace Bun native APIs and resolve audit vulnerabilities ([#1667](https://github.com/vibeunion/supacloud/issues/1667)) ([06a9199](https://github.com/vibeunion/supacloud/commit/06a91990c754ce586f2a2353f253dc50f4fa0f98))
|
|
31
|
+
* integrate reviewed customer, auth and release repairs ([#2027](https://github.com/vibeunion/supacloud/issues/2027)) ([5c07903](https://github.com/vibeunion/supacloud/commit/5c07903f20bfb069229cf3a829886fe96c78c288))
|
|
32
|
+
* **lite:** classify PL/pgSQL failures as server errors ([#1986](https://github.com/vibeunion/supacloud/issues/1986)) ([27c5e29](https://github.com/vibeunion/supacloud/commit/27c5e29b351e2b6bc0d3da55a1ccb6607e4e06a5))
|
|
33
|
+
* **lite:** close backend after startup failure ([#1903](https://github.com/vibeunion/supacloud/issues/1903)) ([3de47be](https://github.com/vibeunion/supacloud/commit/3de47be7821072b88563d51ee388bf76062040f4))
|
|
34
|
+
* **lite:** enforce read-only table and view requests ([#1941](https://github.com/vibeunion/supacloud/issues/1941)) ([d726716](https://github.com/vibeunion/supacloud/commit/d726716a1492a5a581f99a1aa40f15a1125a23aa))
|
|
35
|
+
* **lite:** enforce RPC transaction access modes ([#1936](https://github.com/vibeunion/supacloud/issues/1936)) ([fb90dcc](https://github.com/vibeunion/supacloud/commit/fb90dcc43ed49a45656e1877493eaa641ef494da))
|
|
36
|
+
* **lite:** normalize filesystem storage roots ([#1902](https://github.com/vibeunion/supacloud/issues/1902)) ([f1b5141](https://github.com/vibeunion/supacloud/commit/f1b5141c1e831e68aaf94b505909c9e4942a42df))
|
|
37
|
+
* **lite:** preserve single-column table RPC responses ([#1971](https://github.com/vibeunion/supacloud/issues/1971)) ([63edb93](https://github.com/vibeunion/supacloud/commit/63edb937322130796260a1284c09cc895735214e))
|
|
38
|
+
* **lite:** reject ineligible password logins ([#1998](https://github.com/vibeunion/supacloud/issues/1998)) ([479e967](https://github.com/vibeunion/supacloud/commit/479e96719209f7aed26c44663d78e1442a7097f0))
|
|
39
|
+
* **lite:** report effective local auth configuration in doctor ([#1907](https://github.com/vibeunion/supacloud/issues/1907)) ([c167617](https://github.com/vibeunion/supacloud/commit/c1676176bdd5a2c057114474186570b7e6d5d0dd))
|
|
40
|
+
* **lite:** resolve RPC overloads using required arguments ([#1967](https://github.com/vibeunion/supacloud/issues/1967)) ([e00ffaf](https://github.com/vibeunion/supacloud/commit/e00ffafd41aa52c8f14c2e81f3bb8a8914b336c8))
|
|
41
|
+
* **lite:** roll back rejected singular REST writes ([#1925](https://github.com/vibeunion/supacloud/issues/1925)) ([0af235d](https://github.com/vibeunion/supacloud/commit/0af235d55a3619ffd150e4b16751a27a32d1f2e0))
|
|
42
|
+
* pin Elysia 2 beta compatibility boundary ([#1467](https://github.com/vibeunion/supacloud/issues/1467)) ([bdb2a2e](https://github.com/vibeunion/supacloud/commit/bdb2a2e658cae4160f2a774b5c459d1a2d8fb601))
|
|
43
|
+
* **worker:** ship reviewed PGMQ job controls and concurrency repairs ([#1689](https://github.com/vibeunion/supacloud/issues/1689)) ([e283915](https://github.com/vibeunion/supacloud/commit/e283915e66e119b75ad1b909e18816270b5d01e3))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Elegance & Refactoring
|
|
47
|
+
|
|
48
|
+
* use ESM-only owned packages and Lite launcher ([#1582](https://github.com/vibeunion/supacloud/issues/1582)) ([ed5ac78](https://github.com/vibeunion/supacloud/commit/ed5ac78ee3ab22567268fa276e5b016ad1e8b575))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Miscellaneous Chores
|
|
52
|
+
|
|
53
|
+
* adopt AGPL-3.0-only licensing ([#1481](https://github.com/vibeunion/supacloud/issues/1481)) ([8787ad9](https://github.com/vibeunion/supacloud/commit/8787ad9466ebba8f487d28bf62d5f79a220b0ab8))
|
|
54
|
+
* adopt current Supabase SDK baseline ([#1698](https://github.com/vibeunion/supacloud/issues/1698)) ([4e6613a](https://github.com/vibeunion/supacloud/commit/4e6613aeda3c5958e44cbe9604e30cce0622a66f))
|
|
55
|
+
* release main ([#1474](https://github.com/vibeunion/supacloud/issues/1474)) ([6255eb7](https://github.com/vibeunion/supacloud/commit/6255eb7e7eefc4ee5cd06bef05d4c81a29be706a))
|
|
56
|
+
* release main ([#1484](https://github.com/vibeunion/supacloud/issues/1484)) ([41b3e72](https://github.com/vibeunion/supacloud/commit/41b3e72d25dd8b1ea1d3dea5b75c90bdea9be797))
|
|
57
|
+
* release main ([#1561](https://github.com/vibeunion/supacloud/issues/1561)) ([3ee71e3](https://github.com/vibeunion/supacloud/commit/3ee71e301e7a5499780b45ec6c64e53698000029))
|
|
58
|
+
* release main ([#1609](https://github.com/vibeunion/supacloud/issues/1609)) ([b52c79c](https://github.com/vibeunion/supacloud/commit/b52c79ceda912786f1299ae2d618172f9252607a))
|
|
59
|
+
* release main ([#1647](https://github.com/vibeunion/supacloud/issues/1647)) ([9afdb5c](https://github.com/vibeunion/supacloud/commit/9afdb5c348a2e87169e8898b3842091bb8f1ddea))
|
|
60
|
+
* release main ([#1657](https://github.com/vibeunion/supacloud/issues/1657)) ([1a3f7ff](https://github.com/vibeunion/supacloud/commit/1a3f7ff901f05dda38ed4827d70a91a4acccd8b3))
|
|
61
|
+
* release main ([#1668](https://github.com/vibeunion/supacloud/issues/1668)) ([a7ce18b](https://github.com/vibeunion/supacloud/commit/a7ce18b73e0a2e93df664fb8da08cd40f3bdae82))
|
|
62
|
+
* release main ([#1691](https://github.com/vibeunion/supacloud/issues/1691)) ([2d47123](https://github.com/vibeunion/supacloud/commit/2d47123013522350129d49480ce6d132595976db))
|
|
63
|
+
* release main ([#1695](https://github.com/vibeunion/supacloud/issues/1695)) ([2b9da10](https://github.com/vibeunion/supacloud/commit/2b9da1004b8cc1fd78cfcad79110d5c5eba5349d))
|
|
64
|
+
* release main ([#1743](https://github.com/vibeunion/supacloud/issues/1743)) ([dcbf82c](https://github.com/vibeunion/supacloud/commit/dcbf82c29fb6de94bd6be0c37df20662a6861b2e))
|
|
65
|
+
* release main ([#1747](https://github.com/vibeunion/supacloud/issues/1747)) ([cbdf2a4](https://github.com/vibeunion/supacloud/commit/cbdf2a426aeb5a405a4d27820fdfb51dd489b93a))
|
|
66
|
+
* release main ([#1767](https://github.com/vibeunion/supacloud/issues/1767)) ([d31bf06](https://github.com/vibeunion/supacloud/commit/d31bf06a2bfbdb353554a44576d0c54685f46193))
|
|
67
|
+
* release main ([#1825](https://github.com/vibeunion/supacloud/issues/1825)) ([4819f95](https://github.com/vibeunion/supacloud/commit/4819f95ae7ce722b58f4858261c100c448c9975e))
|
|
68
|
+
* release main ([#1857](https://github.com/vibeunion/supacloud/issues/1857)) ([6b98454](https://github.com/vibeunion/supacloud/commit/6b9845403733f7ffac7711587982979d928702b2))
|
|
69
|
+
* release main ([#1890](https://github.com/vibeunion/supacloud/issues/1890)) ([8b88c00](https://github.com/vibeunion/supacloud/commit/8b88c00e4eb523203520757219be1bc42e45e44d))
|
|
70
|
+
* release main ([#1904](https://github.com/vibeunion/supacloud/issues/1904)) ([c9dc22b](https://github.com/vibeunion/supacloud/commit/c9dc22b89383eefffe11ae4cfa6df57114165a78))
|
|
71
|
+
* release main ([#1909](https://github.com/vibeunion/supacloud/issues/1909)) ([e6590d5](https://github.com/vibeunion/supacloud/commit/e6590d539d92bd99a31e91f9a48f98d0d5a177a5))
|
|
72
|
+
* release main ([#1930](https://github.com/vibeunion/supacloud/issues/1930)) ([2a0a7fa](https://github.com/vibeunion/supacloud/commit/2a0a7fa8ad5c2d88bd8b9ce76b9a6a1744428eb4))
|
|
73
|
+
* release main ([#1937](https://github.com/vibeunion/supacloud/issues/1937)) ([c63b5dd](https://github.com/vibeunion/supacloud/commit/c63b5dd722571e884dbbca379781ecf44542d643))
|
|
74
|
+
* release main ([#1944](https://github.com/vibeunion/supacloud/issues/1944)) ([206d711](https://github.com/vibeunion/supacloud/commit/206d711a0012bad9465283f2f2bfc5f4eb80d269))
|
|
75
|
+
* release main ([#1952](https://github.com/vibeunion/supacloud/issues/1952)) ([1693369](https://github.com/vibeunion/supacloud/commit/1693369010c63e77de8012d0a8acd7b116def94c))
|
|
76
|
+
* release main ([#1955](https://github.com/vibeunion/supacloud/issues/1955)) ([1d93a49](https://github.com/vibeunion/supacloud/commit/1d93a491a8ee2b514e18b802db71233c4535bc23))
|
|
77
|
+
* release main ([#1969](https://github.com/vibeunion/supacloud/issues/1969)) ([89ba2f7](https://github.com/vibeunion/supacloud/commit/89ba2f77a0f8831cd4be3aa9ccca81886ec3bfb0))
|
|
78
|
+
* release main ([#1982](https://github.com/vibeunion/supacloud/issues/1982)) ([02cb9a7](https://github.com/vibeunion/supacloud/commit/02cb9a7011588e7d02e22a84f972c324e4983de4))
|
|
79
|
+
* release main ([#1988](https://github.com/vibeunion/supacloud/issues/1988)) ([e1b912d](https://github.com/vibeunion/supacloud/commit/e1b912df24c27cf822d1f82df6561248783abbb5))
|
|
80
|
+
* release main ([#1999](https://github.com/vibeunion/supacloud/issues/1999)) ([af2a885](https://github.com/vibeunion/supacloud/commit/af2a885e70d8baf3bad4cc3c8264efe62b87d8e9))
|
|
81
|
+
* release main ([#2030](https://github.com/vibeunion/supacloud/issues/2030)) ([2f7cf91](https://github.com/vibeunion/supacloud/commit/2f7cf91d941ab583ebe21d901069a16e55efc48a))
|
|
82
|
+
* unify project licensing under Apache-2.0 ([#1566](https://github.com/vibeunion/supacloud/issues/1566)) ([36dd377](https://github.com/vibeunion/supacloud/commit/36dd37796147a5e7051534d6d9535f13ad881a93))
|
|
83
|
+
* upgrade dependencies and caddy ([#1821](https://github.com/vibeunion/supacloud/issues/1821)) ([91c9a4b](https://github.com/vibeunion/supacloud/commit/91c9a4bd0a14f757670822a1aa953643a00a83c9))
|
|
84
|
+
* upgrade workspace dependencies ([#1940](https://github.com/vibeunion/supacloud/issues/1940)) ([77ad418](https://github.com/vibeunion/supacloud/commit/77ad418e0568ceeeea0b59a10a3bbc451a68a95f))
|
|
85
|
+
|
|
86
|
+
## [0.30.0](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.29.5...supacloud-lite-v0.30.0) (2026-10-17)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### Features
|
|
90
|
+
|
|
91
|
+
* add configurable image-transformation input and output limits with a 500 MiB default and maximum ([#2027](https://github.com/vibeunion/supacloud/issues/2027)) ([5c07903](https://github.com/vibeunion/supacloud/commit/5c07903f20bfb069229cf3a829886fe96c78c288))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### Bug Fixes
|
|
95
|
+
|
|
96
|
+
* enforce account eligibility consistently for bearer, email, OAuth and refresh authentication ([#2027](https://github.com/vibeunion/supacloud/issues/2027)) ([5c07903](https://github.com/vibeunion/supacloud/commit/5c07903f20bfb069229cf3a829886fe96c78c288))
|
|
97
|
+
* prepare isolated package artifacts against the current database dependency ([#2027](https://github.com/vibeunion/supacloud/issues/2027)) ([5c07903](https://github.com/vibeunion/supacloud/commit/5c07903f20bfb069229cf3a829886fe96c78c288))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### Dependencies
|
|
101
|
+
|
|
102
|
+
* align the published @supacloud/db dependency to 0.18.1.
|
|
103
|
+
|
|
3
104
|
## [0.29.5](https://github.com/vibeunion/supacloud/compare/supacloud-lite-v0.29.4...supacloud-lite-v0.29.5) (2026-10-16)
|
|
4
105
|
|
|
5
106
|
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { dirname as dirname8, join as join10, resolve as resolve6 } from "path";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@supacloud/lite",
|
|
11
|
-
version: "0.
|
|
11
|
+
version: "0.31.0",
|
|
12
12
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite or native PostgreSQL",
|
|
13
13
|
type: "module",
|
|
14
14
|
license: "Apache-2.0",
|
|
@@ -67,16 +67,16 @@ var package_default = {
|
|
|
67
67
|
"@electric-sql/pglite-pgmq": "0.0.8",
|
|
68
68
|
"@electric-sql/pglite-pgvector": "0.0.11",
|
|
69
69
|
"@electric-sql/pglite-postgis": "0.2.10",
|
|
70
|
-
"@supacloud/db": "
|
|
70
|
+
"@supacloud/db": "0.18.1",
|
|
71
71
|
"exact-mirror": "1.2.6",
|
|
72
72
|
tar: "^7.5.22",
|
|
73
73
|
typebox: "1.3.37"
|
|
74
74
|
},
|
|
75
75
|
devDependencies: {
|
|
76
|
-
"@supacloud/app": "
|
|
77
|
-
"@supacloud/contracts": "
|
|
78
|
-
"@supacloud/compiler": "
|
|
79
|
-
"@supacloud/elysia": "
|
|
76
|
+
"@supacloud/app": "0.28.0",
|
|
77
|
+
"@supacloud/contracts": "0.11.2",
|
|
78
|
+
"@supacloud/compiler": "0.47.0",
|
|
79
|
+
"@supacloud/elysia": "0.33.2",
|
|
80
80
|
"@supabase/supabase-js": "^2.117.3",
|
|
81
81
|
"@types/bun": "^1.4.3",
|
|
82
82
|
effect: "4.0.5",
|
|
@@ -85,13 +85,13 @@ var package_default = {
|
|
|
85
85
|
typescript: "^7.0.2"
|
|
86
86
|
},
|
|
87
87
|
overrides: {
|
|
88
|
-
"@supacloud/db": "
|
|
89
|
-
"@supacloud/app": "
|
|
90
|
-
"@supacloud/compiler": "
|
|
91
|
-
"@supacloud/elysia": "
|
|
92
|
-
"@supacloud/contracts": "
|
|
93
|
-
"@supacloud/commands": "
|
|
94
|
-
"@supacloud/delivery": "
|
|
88
|
+
"@supacloud/db": "0.18.1",
|
|
89
|
+
"@supacloud/app": "0.28.0",
|
|
90
|
+
"@supacloud/compiler": "0.47.0",
|
|
91
|
+
"@supacloud/elysia": "0.33.2",
|
|
92
|
+
"@supacloud/contracts": "0.11.2",
|
|
93
|
+
"@supacloud/commands": "0.9.4",
|
|
94
|
+
"@supacloud/delivery": "0.19.1",
|
|
95
95
|
"@graphql-tools/utils": "^12.0.4"
|
|
96
96
|
},
|
|
97
97
|
engines: {
|
|
@@ -242,6 +242,13 @@ function isAllowedRedirect(requested, siteUrl, allowList = []) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
// src/runtime/auth/oauth.ts
|
|
245
|
+
class OAuthAccountIneligibleError extends Error {
|
|
246
|
+
code;
|
|
247
|
+
constructor(code) {
|
|
248
|
+
super(code);
|
|
249
|
+
this.code = code;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
245
252
|
var PRESETS = {
|
|
246
253
|
google: {
|
|
247
254
|
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
@@ -364,14 +371,30 @@ class OAuthService {
|
|
|
364
371
|
const msg = encodeURIComponent(e instanceof Error ? e.message : "oauth_error");
|
|
365
372
|
return redirect(`${flow.redirect_to}#error=server_error&error_description=${msg}`);
|
|
366
373
|
}
|
|
367
|
-
|
|
374
|
+
let userId;
|
|
375
|
+
try {
|
|
376
|
+
userId = await this.upsertUser(provider.name, profile);
|
|
377
|
+
} catch (e) {
|
|
378
|
+
if (e instanceof OAuthAccountIneligibleError) {
|
|
379
|
+
return redirect(`${flow.redirect_to}#error=access_denied&error_code=${e.code}`);
|
|
380
|
+
}
|
|
381
|
+
throw e;
|
|
382
|
+
}
|
|
368
383
|
if (flow.code_challenge) {
|
|
369
384
|
const authCode = randomToken(24);
|
|
370
385
|
await this.db.query(`insert into auth.flow_state (provider, provider_state, redirect_to, code_challenge, code_challenge_method, auth_code, user_id, expires_at)
|
|
371
386
|
values ($1, $2, $3, $4, $5, $6, $7, now() + interval '5 minutes')`, [flow.provider, randomToken(16), flow.redirect_to, flow.code_challenge, flow.code_challenge_method, authCode, userId]);
|
|
372
387
|
return redirect(`${flow.redirect_to}?code=${authCode}`);
|
|
373
388
|
}
|
|
374
|
-
|
|
389
|
+
let session;
|
|
390
|
+
try {
|
|
391
|
+
session = await createSession(userId);
|
|
392
|
+
} catch (e) {
|
|
393
|
+
if (e instanceof OAuthAccountIneligibleError) {
|
|
394
|
+
return redirect(`${flow.redirect_to}#error=access_denied&error_code=${e.code}`);
|
|
395
|
+
}
|
|
396
|
+
throw e;
|
|
397
|
+
}
|
|
375
398
|
const hash = `#access_token=${session.access_token}&refresh_token=${session.refresh_token}&expires_in=${session.expires_in}&token_type=bearer&provider_token=`;
|
|
376
399
|
return redirect(`${flow.redirect_to}${hash}`);
|
|
377
400
|
}
|
|
@@ -422,31 +445,37 @@ class OAuthService {
|
|
|
422
445
|
return profile;
|
|
423
446
|
}
|
|
424
447
|
async upsertUser(provider, profile) {
|
|
425
|
-
|
|
448
|
+
return this.db.transaction((query) => this.upsertUserInTransaction(query, provider, profile));
|
|
449
|
+
}
|
|
450
|
+
async upsertUserInTransaction(query, provider, profile) {
|
|
451
|
+
const existing = await query(`select user_id from auth.identities where provider = $1 and provider_id = $2`, [provider, profile.id]);
|
|
426
452
|
if (existing.rows[0]) {
|
|
427
|
-
await this.
|
|
453
|
+
await this.assertUserEligible(query, existing.rows[0].user_id);
|
|
454
|
+
await query(`update auth.identities set last_sign_in_at = now(), identity_data = $3 where provider = $1 and provider_id = $2`, [
|
|
428
455
|
provider,
|
|
429
456
|
profile.id,
|
|
430
457
|
JSON.stringify({ sub: profile.id, email: profile.email, ...profile.metadata })
|
|
431
458
|
]);
|
|
432
|
-
await
|
|
459
|
+
await query(`update auth.users set last_sign_in_at = now() where id = $1`, [existing.rows[0].user_id]);
|
|
433
460
|
return existing.rows[0].user_id;
|
|
434
461
|
}
|
|
435
462
|
let userId;
|
|
436
463
|
const email = profile.email?.toLowerCase() ?? null;
|
|
437
464
|
const verified = !!profile.email && profile.emailVerified === true;
|
|
438
465
|
if (email && verified) {
|
|
439
|
-
const byEmail = await
|
|
466
|
+
const byEmail = await query(`select id from auth.users where email = $1`, [email]);
|
|
440
467
|
userId = byEmail.rows[0]?.id;
|
|
468
|
+
if (userId)
|
|
469
|
+
await this.assertUserEligible(query, userId);
|
|
441
470
|
}
|
|
442
471
|
if (!userId) {
|
|
443
472
|
let userEmail = verified ? email : null;
|
|
444
473
|
if (userEmail) {
|
|
445
|
-
const taken = await
|
|
474
|
+
const taken = await query(`select 1 from auth.users where email = $1`, [userEmail]);
|
|
446
475
|
if (taken.rows.length > 0)
|
|
447
476
|
userEmail = null;
|
|
448
477
|
}
|
|
449
|
-
const created = await
|
|
478
|
+
const created = await query(`insert into auth.users (aud, role, email, email_confirmed_at, last_sign_in_at, raw_app_meta_data, raw_user_meta_data)
|
|
450
479
|
values ('authenticated','authenticated',$1, $2, now(),
|
|
451
480
|
$3::jsonb, $4::jsonb) returning id`, [
|
|
452
481
|
userEmail,
|
|
@@ -459,12 +488,22 @@ class OAuthService {
|
|
|
459
488
|
throw new Error("OAuth user creation returned no row");
|
|
460
489
|
userId = user.id;
|
|
461
490
|
}
|
|
462
|
-
await
|
|
491
|
+
await query(`insert into auth.identities (user_id, provider, provider_id, identity_data)
|
|
463
492
|
values ($1, $2, $3, $4::jsonb)`, [userId, provider, profile.id, JSON.stringify({ sub: profile.id, email: profile.email, ...profile.metadata })]);
|
|
464
493
|
if (!userId)
|
|
465
494
|
throw new Error("OAuth identity has no user ID");
|
|
466
495
|
return userId;
|
|
467
496
|
}
|
|
497
|
+
async assertUserEligible(query, userId) {
|
|
498
|
+
const users = await query(`select deleted_at is not null as is_deleted,
|
|
499
|
+
coalesce(banned_until > now(), false) as is_banned
|
|
500
|
+
from auth.users where id = $1 for update`, [userId]);
|
|
501
|
+
const user = users.rows[0];
|
|
502
|
+
if (!user || user.is_deleted)
|
|
503
|
+
throw new OAuthAccountIneligibleError("user_not_found");
|
|
504
|
+
if (user.is_banned)
|
|
505
|
+
throw new OAuthAccountIneligibleError("user_banned");
|
|
506
|
+
}
|
|
468
507
|
}
|
|
469
508
|
function redirect(location) {
|
|
470
509
|
return new Response(null, { status: 303, headers: { location } });
|
|
@@ -1350,6 +1389,8 @@ class AuthHandler {
|
|
|
1350
1389
|
return await this.admin(req, ctx, path, method);
|
|
1351
1390
|
return authError(404, "not_found", `unknown auth endpoint: ${path}`);
|
|
1352
1391
|
} catch (e) {
|
|
1392
|
+
if (e instanceof OAuthAccountIneligibleError)
|
|
1393
|
+
return authError(400, e.code, e.message);
|
|
1353
1394
|
const msg = e instanceof Error ? e.message : String(e);
|
|
1354
1395
|
return authError(500, "unexpected_failure", msg);
|
|
1355
1396
|
}
|
|
@@ -1444,8 +1485,7 @@ class AuthHandler {
|
|
|
1444
1485
|
const userId = await this.oauth.exchangePkce(authCode, verifier);
|
|
1445
1486
|
if (!userId)
|
|
1446
1487
|
return authError(403, "flow_state_not_found", "invalid or expired auth code");
|
|
1447
|
-
|
|
1448
|
-
return json(200, await this.sessionForOAuth(ures.rows[0]));
|
|
1488
|
+
return json(200, await this.sessionForOAuth(userId));
|
|
1449
1489
|
}
|
|
1450
1490
|
return authError(400, "invalid_grant", `unsupported grant_type: ${grantType}`);
|
|
1451
1491
|
}
|
|
@@ -1740,7 +1780,10 @@ Or sign in with this link: ${link}`
|
|
|
1740
1780
|
tokenTypes: `{${types.join(",")}}`,
|
|
1741
1781
|
email: email?.toLowerCase().trim() ?? null
|
|
1742
1782
|
};
|
|
1743
|
-
return this.db.transaction((query) =>
|
|
1783
|
+
return this.db.transaction(async (query) => {
|
|
1784
|
+
const user = await this.claimEmailToken(query, redemption);
|
|
1785
|
+
return user ? this.sessionFor(user, undefined, undefined, query) : null;
|
|
1786
|
+
});
|
|
1744
1787
|
}
|
|
1745
1788
|
async claimEmailToken(query, redemption) {
|
|
1746
1789
|
const candidate = await this.findEmailTokenCandidate(query, redemption);
|
|
@@ -1752,7 +1795,10 @@ Or sign in with this link: ${link}`
|
|
|
1752
1795
|
return claimedToken ? this.confirmEmailTokenUser(query, claimedToken) : null;
|
|
1753
1796
|
}
|
|
1754
1797
|
async lockAndDeleteEmailToken(query, candidate, redemption) {
|
|
1755
|
-
await query(`select id from auth.users where id = $1
|
|
1798
|
+
const eligible = await query(`select id from auth.users where id = $1 and deleted_at is null
|
|
1799
|
+
and (banned_until is null or banned_until <= now()) for update`, [candidate.user_id]);
|
|
1800
|
+
if (eligible.rows.length === 0)
|
|
1801
|
+
return null;
|
|
1756
1802
|
const claimedTokens = await query(`delete from auth.one_time_tokens
|
|
1757
1803
|
where id = $1 and token = $2 and token_type = any($3::text[])
|
|
1758
1804
|
and expires_at > now() and attempts < $4
|
|
@@ -1805,10 +1851,10 @@ Or sign in with this link: ${link}`
|
|
|
1805
1851
|
return json(200, session);
|
|
1806
1852
|
}
|
|
1807
1853
|
const types = body.type === "recovery" ? ["recovery"] : body.type === "magiclink" ? ["magiclink"] : ["otp", "magiclink"];
|
|
1808
|
-
const
|
|
1809
|
-
if (!
|
|
1854
|
+
const session = await this.redeem(token, types, body.email);
|
|
1855
|
+
if (!session)
|
|
1810
1856
|
return authError(403, "otp_expired", "Token has expired or is invalid");
|
|
1811
|
-
return json(200,
|
|
1857
|
+
return json(200, session);
|
|
1812
1858
|
}
|
|
1813
1859
|
async redeemPhoneOtp(phone, code) {
|
|
1814
1860
|
const tokenDigest = `hmac-sha256:v1:${await keyedDigest(this.config.jwtSecret, "supacloud-lite:phone-otp:v1", `${phone}\x00${code}`)}`;
|
|
@@ -1849,11 +1895,10 @@ Or sign in with this link: ${link}`
|
|
|
1849
1895
|
const token = url.searchParams.get("token") ?? "";
|
|
1850
1896
|
const type = url.searchParams.get("type") ?? "magiclink";
|
|
1851
1897
|
const redirectTo = resolveRedirect(url.searchParams.get("redirect_to"), this.config.siteUrl, this.config.uriAllowList, this.config.enforceRedirectAllowList);
|
|
1852
|
-
const
|
|
1853
|
-
if (!
|
|
1898
|
+
const session = await this.redeem(token, [type]);
|
|
1899
|
+
if (!session) {
|
|
1854
1900
|
return new Response(null, { status: 303, headers: { location: `${redirectTo}#error=access_denied&error_code=otp_expired` } });
|
|
1855
1901
|
}
|
|
1856
|
-
const session = await this.sessionFor(user);
|
|
1857
1902
|
const hash = `#access_token=${session.access_token}&refresh_token=${session.refresh_token}&expires_in=${session.expires_in}&token_type=bearer&type=${type}`;
|
|
1858
1903
|
return new Response(null, { status: 303, headers: { location: `${redirectTo}${hash}` } });
|
|
1859
1904
|
}
|
|
@@ -2154,6 +2199,11 @@ Or sign in with this link: ${link}`
|
|
|
2154
2199
|
return authError(422, "mfa_verification_failed", "Invalid TOTP code entered");
|
|
2155
2200
|
}
|
|
2156
2201
|
const session = await this.db.transaction(async (query) => {
|
|
2202
|
+
const currentUsers = await query(`select * from auth.users where id = $1 and deleted_at is null
|
|
2203
|
+
and (banned_until is null or banned_until <= now()) for update`, [user.id]);
|
|
2204
|
+
const currentUser = currentUsers.rows[0];
|
|
2205
|
+
if (!currentUser)
|
|
2206
|
+
return null;
|
|
2157
2207
|
const claimed = await query(`update auth.mfa_challenges set verified_at = now()
|
|
2158
2208
|
where id = $1 and factor_id = $2 and verified_at is null and expires_at >= now()
|
|
2159
2209
|
returning id`, [challenge.id, factorId]);
|
|
@@ -2162,7 +2212,7 @@ Or sign in with this link: ${link}`
|
|
|
2162
2212
|
if (factor.status !== "verified") {
|
|
2163
2213
|
await query(`update auth.mfa_factors set status = 'verified', updated_at = now() where id = $1`, [factorId]);
|
|
2164
2214
|
}
|
|
2165
|
-
return this.sessionFor(
|
|
2215
|
+
return this.sessionFor(currentUser, undefined, {
|
|
2166
2216
|
aal: "aal2",
|
|
2167
2217
|
amr: [
|
|
2168
2218
|
{ method: "password", timestamp: Math.floor(Date.now() / 1000) },
|
|
@@ -2223,6 +2273,18 @@ Or sign in with this link: ${link}`
|
|
|
2223
2273
|
}
|
|
2224
2274
|
async rotateRefreshToken(token) {
|
|
2225
2275
|
return this.db.transaction(async (query) => {
|
|
2276
|
+
const availableToken = await this.findAvailableRefreshToken(query, token);
|
|
2277
|
+
if (!availableToken)
|
|
2278
|
+
return authError(400, "refresh_token_not_found", "Invalid Refresh Token: Refresh Token Not Found");
|
|
2279
|
+
const userResult = await query(`select *, coalesce(banned_until > now(), false) as is_banned
|
|
2280
|
+
from auth.users where id = $1 for update`, [availableToken.user_id]);
|
|
2281
|
+
const user = userResult.rows[0];
|
|
2282
|
+
if (!user || user.deleted_at !== null) {
|
|
2283
|
+
return authError(400, "refresh_token_not_found", "Invalid Refresh Token: Refresh Token Not Found");
|
|
2284
|
+
}
|
|
2285
|
+
if (user.is_banned) {
|
|
2286
|
+
return authError(400, "user_banned", "Invalid Refresh Token: User Banned");
|
|
2287
|
+
}
|
|
2226
2288
|
const claimedToken = await this.claimRefreshToken(query, token);
|
|
2227
2289
|
if (!claimedToken)
|
|
2228
2290
|
return authError(400, "refresh_token_not_found", "Invalid Refresh Token: Refresh Token Not Found");
|
|
@@ -2230,14 +2292,19 @@ Or sign in with this link: ${link}`
|
|
|
2230
2292
|
const expiryError = this.refreshExpiryError(claimedToken, sessionStartedAt);
|
|
2231
2293
|
if (expiryError)
|
|
2232
2294
|
return expiryError;
|
|
2233
|
-
const
|
|
2234
|
-
const session = await this.sessionFor(userResult.rows[0], token, {
|
|
2295
|
+
const session = await this.sessionFor(user, token, {
|
|
2235
2296
|
sessionId: claimedToken.session_id ?? undefined,
|
|
2236
2297
|
sessionStartedAt: sessionStartedAt === null ? undefined : Math.floor(sessionStartedAt / 1000)
|
|
2237
2298
|
}, query);
|
|
2238
2299
|
return json(200, session);
|
|
2239
2300
|
});
|
|
2240
2301
|
}
|
|
2302
|
+
async findAvailableRefreshToken(query, token) {
|
|
2303
|
+
const available = await query(`select user_id, session_id, created_at
|
|
2304
|
+
from auth.refresh_tokens
|
|
2305
|
+
where token = $1 and revoked is not true`, [token]);
|
|
2306
|
+
return available.rows[0];
|
|
2307
|
+
}
|
|
2241
2308
|
async claimRefreshToken(query, token) {
|
|
2242
2309
|
const claimed = await query(`update auth.refresh_tokens set revoked = true, updated_at = now()
|
|
2243
2310
|
where token = $1 and revoked is not true
|
|
@@ -2265,7 +2332,8 @@ Or sign in with this link: ${link}`
|
|
|
2265
2332
|
const claims = await this.claimsFromBearer(req);
|
|
2266
2333
|
if (!claims?.sub)
|
|
2267
2334
|
return null;
|
|
2268
|
-
const res = await this.db.query(`select * from auth.users where id = $1
|
|
2335
|
+
const res = await this.db.query(`select * from auth.users where id = $1 and deleted_at is null
|
|
2336
|
+
and (banned_until is null or banned_until <= now())`, [claims.sub]);
|
|
2269
2337
|
return res.rows[0] ?? null;
|
|
2270
2338
|
}
|
|
2271
2339
|
async claimsFromBearer(req) {
|
|
@@ -2294,14 +2362,22 @@ Or sign in with this link: ${link}`
|
|
|
2294
2362
|
is_anonymous: u.is_anonymous ?? false
|
|
2295
2363
|
};
|
|
2296
2364
|
}
|
|
2297
|
-
sessionForOAuth(
|
|
2298
|
-
return this.
|
|
2299
|
-
|
|
2365
|
+
sessionForOAuth(userId) {
|
|
2366
|
+
return this.db.transaction(async (query) => {
|
|
2367
|
+
const res = await query(`select *, coalesce(banned_until > now(), false) as is_banned
|
|
2368
|
+
from auth.users where id = $1 for update`, [userId]);
|
|
2369
|
+
const user = res.rows[0];
|
|
2370
|
+
if (!user || user.deleted_at !== null)
|
|
2371
|
+
throw new OAuthAccountIneligibleError("user_not_found");
|
|
2372
|
+
if (user.is_banned)
|
|
2373
|
+
throw new OAuthAccountIneligibleError("user_banned");
|
|
2374
|
+
return this.sessionFor(user, undefined, {
|
|
2375
|
+
amr: [{ method: "oauth", timestamp: Math.floor(Date.now() / 1000) }]
|
|
2376
|
+
}, query);
|
|
2300
2377
|
});
|
|
2301
2378
|
}
|
|
2302
2379
|
async oauthSessionTokensFor(userId) {
|
|
2303
|
-
const
|
|
2304
|
-
const session = await this.sessionForOAuth(res.rows[0]);
|
|
2380
|
+
const session = await this.sessionForOAuth(userId);
|
|
2305
2381
|
return { access_token: session.access_token, refresh_token: session.refresh_token, expires_in: session.expires_in };
|
|
2306
2382
|
}
|
|
2307
2383
|
async sessionFor(user, parentToken, opts, query = (sql, params) => this.db.query(sql, params)) {
|
|
@@ -8978,8 +9054,18 @@ var IMAGE_FORMAT_CONTENT_TYPES = {
|
|
|
8978
9054
|
gif: "image/gif"
|
|
8979
9055
|
};
|
|
8980
9056
|
var MAX_TRANSFORM_DIMENSION = 2500;
|
|
8981
|
-
var MAX_TRANSFORM_BYTES =
|
|
9057
|
+
var MAX_TRANSFORM_BYTES = 500 * 1024 * 1024;
|
|
8982
9058
|
var MAX_TRANSFORM_PIXELS = 50000000;
|
|
9059
|
+
function resolveImageTransformLimits(options = {}) {
|
|
9060
|
+
const maxInputBytes = options.maxInputBytes === undefined ? MAX_TRANSFORM_BYTES : options.maxInputBytes;
|
|
9061
|
+
const maxOutputBytes = options.maxOutputBytes === undefined ? MAX_TRANSFORM_BYTES : options.maxOutputBytes;
|
|
9062
|
+
for (const [name, value] of Object.entries({ maxInputBytes, maxOutputBytes })) {
|
|
9063
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > MAX_TRANSFORM_BYTES) {
|
|
9064
|
+
throw new Error(`Invalid image transformation ${name}: expected 1..${MAX_TRANSFORM_BYTES} bytes`);
|
|
9065
|
+
}
|
|
9066
|
+
}
|
|
9067
|
+
return { maxInputBytes, maxOutputBytes };
|
|
9068
|
+
}
|
|
8983
9069
|
function invalid(message) {
|
|
8984
9070
|
return { ok: false, status: 400, error: "InvalidTransformation", message };
|
|
8985
9071
|
}
|
|
@@ -9037,7 +9123,16 @@ function parseImageTransform(query) {
|
|
|
9037
9123
|
if (quality !== undefined && format === "png") {
|
|
9038
9124
|
return invalid("quality is supported only for jpeg and webp output");
|
|
9039
9125
|
}
|
|
9040
|
-
return {
|
|
9126
|
+
return {
|
|
9127
|
+
ok: true,
|
|
9128
|
+
value: {
|
|
9129
|
+
resize,
|
|
9130
|
+
format,
|
|
9131
|
+
...width === undefined ? {} : { width },
|
|
9132
|
+
...height === undefined ? {} : { height },
|
|
9133
|
+
...quality === undefined ? {} : { quality }
|
|
9134
|
+
}
|
|
9135
|
+
};
|
|
9041
9136
|
}
|
|
9042
9137
|
function imageTransformToSearchParams(options) {
|
|
9043
9138
|
const query = new URLSearchParams;
|
|
@@ -9111,15 +9206,16 @@ function applyResize(image, metadata, options) {
|
|
|
9111
9206
|
const proportionalWidth = Math.max(1, Math.round(metadata.width * height / metadata.height));
|
|
9112
9207
|
image.resize(proportionalWidth);
|
|
9113
9208
|
}
|
|
9114
|
-
async function transformImage(source, options, knownSourceSize) {
|
|
9209
|
+
async function transformImage(source, options, knownSourceSize, configuredLimits = {}) {
|
|
9210
|
+
const limits = resolveImageTransformLimits(configuredLimits);
|
|
9115
9211
|
const actualSourceSize = source instanceof Uint8Array ? source.byteLength : await Promise.resolve(source.size);
|
|
9116
9212
|
const sourceSize = Math.max(knownSourceSize ?? 0, actualSourceSize);
|
|
9117
|
-
if (sourceSize >
|
|
9213
|
+
if (sourceSize > limits.maxInputBytes) {
|
|
9118
9214
|
return {
|
|
9119
9215
|
ok: false,
|
|
9120
9216
|
status: 413,
|
|
9121
9217
|
error: "ImageTooLarge",
|
|
9122
|
-
message:
|
|
9218
|
+
message: `The source image exceeds the transformation limit (${limits.maxInputBytes} bytes)`
|
|
9123
9219
|
};
|
|
9124
9220
|
}
|
|
9125
9221
|
const image = new Bun.Image(source, { maxPixels: MAX_TRANSFORM_PIXELS });
|
|
@@ -9152,12 +9248,12 @@ async function transformImage(source, options, knownSourceSize) {
|
|
|
9152
9248
|
}
|
|
9153
9249
|
try {
|
|
9154
9250
|
const bytes = await image.bytes();
|
|
9155
|
-
if (bytes.byteLength >
|
|
9251
|
+
if (bytes.byteLength > limits.maxOutputBytes) {
|
|
9156
9252
|
return {
|
|
9157
9253
|
ok: false,
|
|
9158
9254
|
status: 413,
|
|
9159
9255
|
error: "ImageTooLarge",
|
|
9160
|
-
message:
|
|
9256
|
+
message: `The transformed image exceeds the transformation limit (${limits.maxOutputBytes} bytes)`
|
|
9161
9257
|
};
|
|
9162
9258
|
}
|
|
9163
9259
|
return { ok: true, bytes, contentType };
|
|
@@ -9360,10 +9456,12 @@ class StorageHandler {
|
|
|
9360
9456
|
tusUploads = new Map;
|
|
9361
9457
|
mutationTail = Promise.resolve();
|
|
9362
9458
|
imageTransforms = new ImageTransformCache;
|
|
9459
|
+
transformLimits;
|
|
9363
9460
|
constructor(db, driver, config) {
|
|
9364
9461
|
this.db = db;
|
|
9365
9462
|
this.driver = driver;
|
|
9366
9463
|
this.config = config;
|
|
9464
|
+
this.transformLimits = resolveImageTransformLimits(config.imageTransformLimits);
|
|
9367
9465
|
}
|
|
9368
9466
|
async ensureBuckets(buckets) {
|
|
9369
9467
|
for (const b of buckets) {
|
|
@@ -9639,7 +9737,7 @@ class StorageHandler {
|
|
|
9639
9737
|
const source = await this.readObjectSource(row);
|
|
9640
9738
|
if (source === null)
|
|
9641
9739
|
throw new StorageObjectMissingError;
|
|
9642
|
-
return transformImage(source, parsed.value, objectSize(row));
|
|
9740
|
+
return transformImage(source, parsed.value, objectSize(row), this.transformLimits);
|
|
9643
9741
|
});
|
|
9644
9742
|
} catch (error) {
|
|
9645
9743
|
if (error instanceof StorageObjectMissingError) {
|
|
@@ -11735,6 +11833,7 @@ ${msg.text}` : `[mail] to=${msg.to} subject="${msg.subject}"`));
|
|
|
11735
11833
|
const storage = new StorageHandler(db, config.storageDriver ?? new MemoryStorageDriver, {
|
|
11736
11834
|
jwtSecret,
|
|
11737
11835
|
defaultFileSizeLimit: config.storageFileSizeLimit,
|
|
11836
|
+
imageTransformLimits: config.storageImageTransformLimits,
|
|
11738
11837
|
log
|
|
11739
11838
|
});
|
|
11740
11839
|
if (config.buckets?.length) {
|
|
@@ -13274,8 +13373,22 @@ import { readFile as readFile2, stat } from "fs/promises";
|
|
|
13274
13373
|
import { dirname as dirname3, resolve as resolve3 } from "path";
|
|
13275
13374
|
import { pathToFileURL } from "url";
|
|
13276
13375
|
|
|
13277
|
-
//
|
|
13376
|
+
// ../db/dist/index.js
|
|
13278
13377
|
import { createHash as createHash3 } from "crypto";
|
|
13378
|
+
|
|
13379
|
+
// ../contracts/dist/index.mjs
|
|
13380
|
+
var commandErrorBrand = Symbol.for("@supacloud/contracts/CommandError/v1");
|
|
13381
|
+
var commandErrorCodes = new Set([
|
|
13382
|
+
"COMMAND_INPUT_INVALID",
|
|
13383
|
+
"COMMAND_REJECTED",
|
|
13384
|
+
"COMMAND_UNAVAILABLE",
|
|
13385
|
+
"COMMAND_IDEMPOTENCY_CONFLICT",
|
|
13386
|
+
"COMMAND_RECEIPT_INVALID",
|
|
13387
|
+
"COMMAND_OUTCOME_UNKNOWN",
|
|
13388
|
+
"COMMAND_INPUT_EXPIRED"
|
|
13389
|
+
]);
|
|
13390
|
+
|
|
13391
|
+
// ../db/dist/index.js
|
|
13279
13392
|
var TABLES_SQL = `
|
|
13280
13393
|
SELECT n.nspname AS schema,
|
|
13281
13394
|
c.relname AS name,
|
|
@@ -14684,6 +14797,19 @@ function readStorage(root) {
|
|
|
14684
14797
|
const limit = getByteSize(storage, "file_size_limit");
|
|
14685
14798
|
if (limit !== undefined)
|
|
14686
14799
|
out.fileSizeLimit = limit;
|
|
14800
|
+
const image = tableAt(root, "storage.image_transformation");
|
|
14801
|
+
if (image) {
|
|
14802
|
+
const limits = {};
|
|
14803
|
+
for (const [key, field] of [["max_input_bytes", "maxInputBytes"], ["max_output_bytes", "maxOutputBytes"]]) {
|
|
14804
|
+
if (!image.values.has(key))
|
|
14805
|
+
continue;
|
|
14806
|
+
const value = getByteSize(image, key);
|
|
14807
|
+
if (value === undefined)
|
|
14808
|
+
throw new Error(`Invalid image transformation ${key}`);
|
|
14809
|
+
limits[field] = value;
|
|
14810
|
+
}
|
|
14811
|
+
out.imageTransformLimits = resolveImageTransformLimits(limits);
|
|
14812
|
+
}
|
|
14687
14813
|
const buckets = tableAt(root, "storage.buckets");
|
|
14688
14814
|
if (buckets && buckets.children.size > 0) {
|
|
14689
14815
|
out.buckets = [...buckets.children].map(([id, t]) => ({
|
|
@@ -15521,6 +15647,7 @@ async function createProjectBackend(options = {}) {
|
|
|
15521
15647
|
dbSchemas: config.api.schemas,
|
|
15522
15648
|
maxRows: config.api.maxRows,
|
|
15523
15649
|
storageFileSizeLimit: config.storage.fileSizeLimit,
|
|
15650
|
+
storageImageTransformLimits: config.storage.imageTransformLimits,
|
|
15524
15651
|
buckets: config.storage.buckets,
|
|
15525
15652
|
migrations: options.applyMigrations === false ? [] : project.migrations,
|
|
15526
15653
|
seedSql: options.applyMigrations === false || options.includeSeed === false ? undefined : project.seedSql,
|