@supacloud/lite 0.7.0 → 0.7.1
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 +9 -0
- package/README.md +6 -2
- package/dist/cli.js +52 -25
- package/dist/index.js +19 -21
- package/dist/project-runtime.d.ts.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/jwt.d.ts +6 -0
- package/dist/runtime/jwt.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.1](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.7.0...supacloud-lite-v0.7.1) (2026-08-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **lite:** bound standalone subprocess collection ([#827](https://github.com/zuohuadong/supacloud/issues/827)) ([4c37c33](https://github.com/zuohuadong/supacloud/commit/4c37c3325391de11ff6224b0297eb211a3627f5a))
|
|
9
|
+
* **lite:** guard db reset on uninitialized state ([#826](https://github.com/zuohuadong/supacloud/issues/826)) ([1e45f5f](https://github.com/zuohuadong/supacloud/commit/1e45f5fdd0cda0dbe238043526eb8d5ab8ebf1e1))
|
|
10
|
+
* **lite:** keep project API keys stable ([#817](https://github.com/zuohuadong/supacloud/issues/817)) ([80c5818](https://github.com/zuohuadong/supacloud/commit/80c581846a91654268af2b745f9a7d3d01ab8d5e))
|
|
11
|
+
|
|
3
12
|
## [0.7.0](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.6.0...supacloud-lite-v0.7.0) (2026-08-11)
|
|
4
13
|
|
|
5
14
|
|
package/README.md
CHANGED
|
@@ -109,6 +109,8 @@ supacloud-lite inspect
|
|
|
109
109
|
supacloud-lite version
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
首次初始化或 state 目录不存在/为空时,先运行 `supacloud-lite migrate`。`db reset` 只接受已经初始化且保留有效 `secrets.json` 标记的 state;它不会为 reset 创建或覆盖项目 secrets。
|
|
113
|
+
|
|
112
114
|
通用参数:
|
|
113
115
|
|
|
114
116
|
- `--project-dir`:包含 `supabase/` 的项目目录
|
|
@@ -257,7 +259,7 @@ RLS 表的 Realtime DELETE 无法在行删除后安全重放 SELECT policy,因
|
|
|
257
259
|
应用代码、SQL migrations、RLS policy、Storage 调用和 Realtime 订阅可以保持原来的 Supabase 形状。迁移时仍需验证以下边界:
|
|
258
260
|
|
|
259
261
|
1. 把现有 `supabase/migrations`、`config.toml`、Functions 和 seed 文件带到 Lite 项目。
|
|
260
|
-
2.
|
|
262
|
+
2. 先用 `supacloud-lite migrate` 初始化空 state 并重放 schema;只有在已初始化的可丢弃 state 上需要再次重放时才使用 `supacloud-lite db reset`,然后导入业务数据。
|
|
261
263
|
3. 对使用 PGlite 未提供扩展或 PostgREST 高级语法的 SQL/API 做替代处理。
|
|
262
264
|
4. 通过真实 `@supabase/supabase-js` 集成测试验证关键查询、RLS、Storage 和 Realtime。
|
|
263
265
|
|
|
@@ -441,6 +443,8 @@ supacloud-lite inspect
|
|
|
441
443
|
supacloud-lite version
|
|
442
444
|
```
|
|
443
445
|
|
|
446
|
+
Run `supacloud-lite migrate` first when initializing a project or when the state directory is missing or empty. `db reset` only accepts initialized state with a valid `secrets.json` marker; it never creates or replaces project secrets for a reset.
|
|
447
|
+
|
|
444
448
|
Common flags:
|
|
445
449
|
|
|
446
450
|
- `--project-dir`: the project directory containing `supabase/`
|
|
@@ -589,7 +593,7 @@ Realtime DELETE on RLS tables cannot safely replay SELECT policies after a row i
|
|
|
589
593
|
Application code, SQL migrations, RLS policies, Storage calls, and Realtime subscriptions can keep their original Supabase shape. When migrating, you still need to validate the following boundaries:
|
|
590
594
|
|
|
591
595
|
1. Bring the existing `supabase/migrations`, `config.toml`, Functions, and seed files into the Lite project.
|
|
592
|
-
2. Use `supacloud-lite
|
|
596
|
+
2. Use `supacloud-lite migrate` to initialize empty state and replay the schema. Use `supacloud-lite db reset` only when replaying an already initialized disposable state, then import business data.
|
|
593
597
|
3. Provide alternatives for SQL/API that use extensions not offered by PGlite or advanced PostgREST syntax.
|
|
594
598
|
4. Verify key queries, RLS, Storage, and Realtime through real `@supabase/supabase-js` integration tests.
|
|
595
599
|
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@supacloud/lite",
|
|
11
|
-
version: "0.7.
|
|
11
|
+
version: "0.7.1",
|
|
12
12
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite",
|
|
13
13
|
type: "module",
|
|
14
14
|
license: "Apache-2.0",
|
|
@@ -83,6 +83,8 @@ var package_default = {
|
|
|
83
83
|
// src/runtime/jwt.ts
|
|
84
84
|
var encoder = new TextEncoder;
|
|
85
85
|
var decoder = new TextDecoder;
|
|
86
|
+
var PROJECT_API_KEY_ISSUED_AT = 1641769200;
|
|
87
|
+
var PROJECT_API_KEY_EXPIRES_AT = 4102444800;
|
|
86
88
|
function bytesToBase64Url(bytes) {
|
|
87
89
|
let binary = "";
|
|
88
90
|
const chunk = 32768;
|
|
@@ -111,6 +113,18 @@ async function signJwt(claims, secret) {
|
|
|
111
113
|
const sig = await crypto.subtle.sign("HMAC", key, encoder.encode(data));
|
|
112
114
|
return `${data}.${bytesToBase64Url(new Uint8Array(sig))}`;
|
|
113
115
|
}
|
|
116
|
+
async function mintProjectApiKeys(jwtSecret) {
|
|
117
|
+
const commonClaims = {
|
|
118
|
+
iss: "supabase",
|
|
119
|
+
ref: "local",
|
|
120
|
+
iat: PROJECT_API_KEY_ISSUED_AT,
|
|
121
|
+
exp: PROJECT_API_KEY_EXPIRES_AT
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
anonKey: await signJwt({ ...commonClaims, role: "anon" }, jwtSecret),
|
|
125
|
+
serviceRoleKey: await signJwt({ ...commonClaims, role: "service_role" }, jwtSecret)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
114
128
|
async function verifyJwt(token, secret) {
|
|
115
129
|
const parts = token.split(".");
|
|
116
130
|
if (parts.length !== 3)
|
|
@@ -8590,10 +8604,7 @@ async function createBackend(config = {}) {
|
|
|
8590
8604
|
await failStartup(e);
|
|
8591
8605
|
}
|
|
8592
8606
|
const pgredis = await PgredisCache.create(db).catch(failStartup);
|
|
8593
|
-
const
|
|
8594
|
-
const tenYears = 10 * 365 * 24 * 3600;
|
|
8595
|
-
const anonKey = await signJwt({ iss: "supabase", ref: "local", role: "anon", iat: now, exp: now + tenYears }, jwtSecret);
|
|
8596
|
-
const serviceRoleKey = await signJwt({ iss: "supabase", ref: "local", role: "service_role", iat: now, exp: now + tenYears }, jwtSecret);
|
|
8607
|
+
const { anonKey, serviceRoleKey } = await mintProjectApiKeys(jwtSecret);
|
|
8597
8608
|
const exposedSchemas = [...new Set(config.dbSchemas ?? ["public", "pgmq_public"])];
|
|
8598
8609
|
const rest = new RestHandler(db, { exposedSchemas, maxRows: config.maxRows });
|
|
8599
8610
|
const exposed = isNetworkExposed(config.host);
|
|
@@ -9701,6 +9712,8 @@ class S3StorageDriver {
|
|
|
9701
9712
|
}
|
|
9702
9713
|
|
|
9703
9714
|
// src/project-runtime.ts
|
|
9715
|
+
var RESET_INITIALIZATION_ERROR = 'db reset requires initialized state; run "supacloud-lite migrate" first';
|
|
9716
|
+
var RESET_INVALID_SECRETS_ERROR = "db reset requires a valid project secrets marker; restore the state before retrying";
|
|
9704
9717
|
function resolveProjectPaths(options = {}) {
|
|
9705
9718
|
const projectDir = resolve2(options.projectDir ?? process.cwd());
|
|
9706
9719
|
const stateDir = resolvePath(projectDir, options.stateDir ?? process.env.SUPACLOUD_LITE_STATE_DIR ?? ".supacloud-lite");
|
|
@@ -9718,7 +9731,7 @@ async function assertResetPathsSafe(paths) {
|
|
|
9718
9731
|
const stateDir = resolve2(paths.stateDir);
|
|
9719
9732
|
if (stateDir === parse(stateDir).root)
|
|
9720
9733
|
throw new Error("refusing to use the filesystem root as the state directory");
|
|
9721
|
-
const stateInfo = await
|
|
9734
|
+
const stateInfo = await requiredResetEntry(stateDir);
|
|
9722
9735
|
if (!stateInfo.isDirectory() || stateInfo.isSymbolicLink()) {
|
|
9723
9736
|
throw new Error(`refusing to reset through an invalid state directory: ${stateDir}`);
|
|
9724
9737
|
}
|
|
@@ -9727,10 +9740,11 @@ async function assertResetPathsSafe(paths) {
|
|
|
9727
9740
|
if (secretsFile !== join7(stateDir, "secrets.json")) {
|
|
9728
9741
|
throw new Error(`refusing to reset a state directory with an invalid secrets marker path: ${secretsFile}`);
|
|
9729
9742
|
}
|
|
9730
|
-
const markerInfo = await
|
|
9743
|
+
const markerInfo = await requiredResetEntry(secretsFile);
|
|
9731
9744
|
if (!markerInfo.isFile() || markerInfo.isSymbolicLink()) {
|
|
9732
|
-
throw new Error(
|
|
9745
|
+
throw new Error(RESET_INVALID_SECRETS_ERROR);
|
|
9733
9746
|
}
|
|
9747
|
+
await assertResetSecretsValid(secretsFile);
|
|
9734
9748
|
const targets = [
|
|
9735
9749
|
...paths.dataDir ? [["database", paths.dataDir]] : [],
|
|
9736
9750
|
["storage", paths.storageDir]
|
|
@@ -9744,6 +9758,30 @@ async function assertResetPathsSafe(paths) {
|
|
|
9744
9758
|
await assertResetTargetCanonical(stateDir, canonicalStateDir, target, label);
|
|
9745
9759
|
}
|
|
9746
9760
|
}
|
|
9761
|
+
async function requiredResetEntry(path) {
|
|
9762
|
+
try {
|
|
9763
|
+
return await lstat(path);
|
|
9764
|
+
} catch (error) {
|
|
9765
|
+
if (error.code === "ENOENT")
|
|
9766
|
+
throw new Error(RESET_INITIALIZATION_ERROR);
|
|
9767
|
+
throw error;
|
|
9768
|
+
}
|
|
9769
|
+
}
|
|
9770
|
+
async function assertResetSecretsValid(path) {
|
|
9771
|
+
let serializedSecrets;
|
|
9772
|
+
try {
|
|
9773
|
+
serializedSecrets = await readFile6(path, "utf8");
|
|
9774
|
+
} catch (error) {
|
|
9775
|
+
if (error.code === "ENOENT")
|
|
9776
|
+
throw new Error(RESET_INITIALIZATION_ERROR);
|
|
9777
|
+
throw error;
|
|
9778
|
+
}
|
|
9779
|
+
try {
|
|
9780
|
+
validateSecrets(JSON.parse(serializedSecrets));
|
|
9781
|
+
} catch {
|
|
9782
|
+
throw new Error(RESET_INVALID_SECRETS_ERROR);
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
9747
9785
|
async function assertResetTargetCanonical(stateDir, canonicalStateDir, target, label) {
|
|
9748
9786
|
let current = target;
|
|
9749
9787
|
while (current !== stateDir) {
|
|
@@ -9826,13 +9864,7 @@ async function ensureProjectSecrets(paths) {
|
|
|
9826
9864
|
});
|
|
9827
9865
|
}
|
|
9828
9866
|
async function mintProjectKeys(jwtSecret) {
|
|
9829
|
-
|
|
9830
|
-
const exp = now + 10 * 365 * 24 * 3600;
|
|
9831
|
-
const common = { iss: "supabase", ref: "local", iat: now, exp };
|
|
9832
|
-
return {
|
|
9833
|
-
anonKey: await signJwt({ ...common, role: "anon" }, jwtSecret),
|
|
9834
|
-
serviceRoleKey: await signJwt({ ...common, role: "service_role" }, jwtSecret)
|
|
9835
|
-
};
|
|
9867
|
+
return await mintProjectApiKeys(jwtSecret);
|
|
9836
9868
|
}
|
|
9837
9869
|
async function createProjectBackend(options = {}) {
|
|
9838
9870
|
const paths = resolveProjectPaths(options);
|
|
@@ -10004,7 +10036,7 @@ async function findEphemeralPort(host = "127.0.0.1") {
|
|
|
10004
10036
|
}
|
|
10005
10037
|
|
|
10006
10038
|
// src/snapshot.ts
|
|
10007
|
-
import { chmod as chmod2, copyFile,
|
|
10039
|
+
import { chmod as chmod2, copyFile, lstat as lstat2, mkdir as mkdir6, mkdtemp, readdir as readdir3, readFile as readFile7, rename as rename2, rm as rm3, writeFile as writeFile5 } from "fs/promises";
|
|
10008
10040
|
import { dirname as dirname4, join as join8, parse as parse2, relative as relative2, resolve as resolve3, sep as sep2 } from "path";
|
|
10009
10041
|
import { create as createTar, extract as extractTar } from "tar";
|
|
10010
10042
|
var SNAPSHOT_FORMAT = "supacloud-lite-snapshot";
|
|
@@ -10229,14 +10261,7 @@ async function stageDirectory(root, destination) {
|
|
|
10229
10261
|
}
|
|
10230
10262
|
async function stageFile(source, target) {
|
|
10231
10263
|
await mkdir6(dirname4(target), { recursive: true });
|
|
10232
|
-
|
|
10233
|
-
await link2(source, target);
|
|
10234
|
-
} catch (error) {
|
|
10235
|
-
const code = error.code;
|
|
10236
|
-
if (code !== "EXDEV" && code !== "EPERM" && code !== "EACCES")
|
|
10237
|
-
throw error;
|
|
10238
|
-
await copyFile(source, target);
|
|
10239
|
-
}
|
|
10264
|
+
await copyFile(source, target);
|
|
10240
10265
|
}
|
|
10241
10266
|
async function readManifest(payloadRoot) {
|
|
10242
10267
|
let parsed;
|
|
@@ -10753,7 +10778,7 @@ Commands:
|
|
|
10753
10778
|
keys print the anon key
|
|
10754
10779
|
keys --service-role also print the privileged service_role key
|
|
10755
10780
|
gen types emit Supabase-shaped TypeScript database types
|
|
10756
|
-
db reset
|
|
10781
|
+
db reset reset initialized database/storage and re-run migrations
|
|
10757
10782
|
db diff print schema changes outside migrations
|
|
10758
10783
|
db pull [name] write live schema changes as an applied migration
|
|
10759
10784
|
snapshot create create a compressed database/storage/secrets snapshot
|
|
@@ -10762,6 +10787,8 @@ Commands:
|
|
|
10762
10787
|
inspect show table rows and sizes
|
|
10763
10788
|
version print the package version
|
|
10764
10789
|
|
|
10790
|
+
Fresh projects must run "supacloud-lite migrate" before "db reset".
|
|
10791
|
+
|
|
10765
10792
|
Options:
|
|
10766
10793
|
-p, --port <n> port (default 54321)
|
|
10767
10794
|
--host <host> bind host (default 127.0.0.1)
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ var __require = import.meta.require;
|
|
|
4
4
|
// src/runtime/jwt.ts
|
|
5
5
|
var encoder = new TextEncoder;
|
|
6
6
|
var decoder = new TextDecoder;
|
|
7
|
+
var PROJECT_API_KEY_ISSUED_AT = 1641769200;
|
|
8
|
+
var PROJECT_API_KEY_EXPIRES_AT = 4102444800;
|
|
7
9
|
function bytesToBase64Url(bytes) {
|
|
8
10
|
let binary = "";
|
|
9
11
|
const chunk = 32768;
|
|
@@ -32,6 +34,18 @@ async function signJwt(claims, secret) {
|
|
|
32
34
|
const sig = await crypto.subtle.sign("HMAC", key, encoder.encode(data));
|
|
33
35
|
return `${data}.${bytesToBase64Url(new Uint8Array(sig))}`;
|
|
34
36
|
}
|
|
37
|
+
async function mintProjectApiKeys(jwtSecret) {
|
|
38
|
+
const commonClaims = {
|
|
39
|
+
iss: "supabase",
|
|
40
|
+
ref: "local",
|
|
41
|
+
iat: PROJECT_API_KEY_ISSUED_AT,
|
|
42
|
+
exp: PROJECT_API_KEY_EXPIRES_AT
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
anonKey: await signJwt({ ...commonClaims, role: "anon" }, jwtSecret),
|
|
46
|
+
serviceRoleKey: await signJwt({ ...commonClaims, role: "service_role" }, jwtSecret)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
35
49
|
async function verifyJwt(token, secret) {
|
|
36
50
|
const parts = token.split(".");
|
|
37
51
|
if (parts.length !== 3)
|
|
@@ -71,7 +85,7 @@ function randomToken(bytes = 32) {
|
|
|
71
85
|
// package.json
|
|
72
86
|
var package_default = {
|
|
73
87
|
name: "@supacloud/lite",
|
|
74
|
-
version: "0.7.
|
|
88
|
+
version: "0.7.1",
|
|
75
89
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite",
|
|
76
90
|
type: "module",
|
|
77
91
|
license: "Apache-2.0",
|
|
@@ -8434,10 +8448,7 @@ async function createBackend(config = {}) {
|
|
|
8434
8448
|
await failStartup(e);
|
|
8435
8449
|
}
|
|
8436
8450
|
const pgredis = await PgredisCache.create(db).catch(failStartup);
|
|
8437
|
-
const
|
|
8438
|
-
const tenYears = 10 * 365 * 24 * 3600;
|
|
8439
|
-
const anonKey = await signJwt({ iss: "supabase", ref: "local", role: "anon", iat: now, exp: now + tenYears }, jwtSecret);
|
|
8440
|
-
const serviceRoleKey = await signJwt({ iss: "supabase", ref: "local", role: "service_role", iat: now, exp: now + tenYears }, jwtSecret);
|
|
8451
|
+
const { anonKey, serviceRoleKey } = await mintProjectApiKeys(jwtSecret);
|
|
8441
8452
|
const exposedSchemas = [...new Set(config.dbSchemas ?? ["public", "pgmq_public"])];
|
|
8442
8453
|
const rest = new RestHandler(db, { exposedSchemas, maxRows: config.maxRows });
|
|
8443
8454
|
const exposed = isNetworkExposed(config.host);
|
|
@@ -9510,13 +9521,7 @@ async function ensureProjectSecrets(paths) {
|
|
|
9510
9521
|
});
|
|
9511
9522
|
}
|
|
9512
9523
|
async function mintProjectKeys(jwtSecret) {
|
|
9513
|
-
|
|
9514
|
-
const exp = now + 10 * 365 * 24 * 3600;
|
|
9515
|
-
const common = { iss: "supabase", ref: "local", iat: now, exp };
|
|
9516
|
-
return {
|
|
9517
|
-
anonKey: await signJwt({ ...common, role: "anon" }, jwtSecret),
|
|
9518
|
-
serviceRoleKey: await signJwt({ ...common, role: "service_role" }, jwtSecret)
|
|
9519
|
-
};
|
|
9524
|
+
return await mintProjectApiKeys(jwtSecret);
|
|
9520
9525
|
}
|
|
9521
9526
|
async function createProjectBackend(options = {}) {
|
|
9522
9527
|
const paths = resolveProjectPaths(options);
|
|
@@ -9687,7 +9692,7 @@ async function findEphemeralPort(host = "127.0.0.1") {
|
|
|
9687
9692
|
return port;
|
|
9688
9693
|
}
|
|
9689
9694
|
// src/snapshot.ts
|
|
9690
|
-
import { chmod as chmod2, copyFile,
|
|
9695
|
+
import { chmod as chmod2, copyFile, lstat as lstat2, mkdir as mkdir5, mkdtemp, readdir as readdir3, readFile as readFile7, rename as rename2, rm as rm3, writeFile as writeFile4 } from "fs/promises";
|
|
9691
9696
|
import { dirname as dirname4, join as join7, parse as parse2, relative as relative2, resolve as resolve3, sep as sep2 } from "path";
|
|
9692
9697
|
import { create as createTar, extract as extractTar } from "tar";
|
|
9693
9698
|
var SNAPSHOT_FORMAT = "supacloud-lite-snapshot";
|
|
@@ -9912,14 +9917,7 @@ async function stageDirectory(root, destination) {
|
|
|
9912
9917
|
}
|
|
9913
9918
|
async function stageFile(source, target) {
|
|
9914
9919
|
await mkdir5(dirname4(target), { recursive: true });
|
|
9915
|
-
|
|
9916
|
-
await link2(source, target);
|
|
9917
|
-
} catch (error) {
|
|
9918
|
-
const code = error.code;
|
|
9919
|
-
if (code !== "EXDEV" && code !== "EPERM" && code !== "EACCES")
|
|
9920
|
-
throw error;
|
|
9921
|
-
await copyFile(source, target);
|
|
9922
|
-
}
|
|
9920
|
+
await copyFile(source, target);
|
|
9923
9921
|
}
|
|
9924
9922
|
async function readManifest(payloadRoot) {
|
|
9925
9923
|
let parsed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-runtime.d.ts","sourceRoot":"","sources":["../src/project-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"project-runtime.d.ts","sourceRoot":"","sources":["../src/project-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAG7E,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE3E,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAIrF,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKlE,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE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,CAAA;IACjB,wDAAwD;IACxD,GAAG,EAAE,UAAU,CAAA;IACf,6EAA6E;IAC7E,SAAS,EAAE,gBAAgB,CAAA;IAC3B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAA;IACtB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAA;IACjB,kEAAkE;IAClE,IAAI,EAAE,SAAS,CAAA;IACf,4FAA4F;IAC5F,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACzB,gHAAgH;IAChH,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAA;IACzB,8CAA8C;IAC9C,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC7E,gGAAgG;IAChG,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA8W7F"}
|
package/dist/runtime/jwt.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Minimal HS256 JWT implementation on WebCrypto.
|
|
3
3
|
* Works in Node (>=18) and browsers - no dependencies.
|
|
4
4
|
*/
|
|
5
|
+
export interface ProjectApiKeys {
|
|
6
|
+
anonKey: string;
|
|
7
|
+
serviceRoleKey: string;
|
|
8
|
+
}
|
|
5
9
|
/** Standard + Supabase/GoTrue claims carried in an access token. Open-ended: any extra claims are preserved. */
|
|
6
10
|
export interface JwtClaims {
|
|
7
11
|
[key: string]: unknown;
|
|
@@ -22,6 +26,8 @@ export interface JwtClaims {
|
|
|
22
26
|
}
|
|
23
27
|
/** Sign claims as an HS256 JWT. */
|
|
24
28
|
export declare function signJwt(claims: JwtClaims, secret: string): Promise<string>;
|
|
29
|
+
/** Keep project API keys canonical so CLI output and restarted runtimes remain byte-identical. */
|
|
30
|
+
export declare function mintProjectApiKeys(jwtSecret: string): Promise<ProjectApiKeys>;
|
|
25
31
|
/** Verifies signature and expiry. Returns claims, or null when invalid. */
|
|
26
32
|
export declare function verifyJwt(token: string, secret: string): Promise<JwtClaims | null>;
|
|
27
33
|
/** Decode without verification (for introspection/debugging only). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/runtime/jwt.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/runtime/jwt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;CACvB;AA8BD,gHAAgH;AAChH,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qFAAqF;IACrF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,2FAA2F;IAC3F,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC9C;AAED,mCAAmC;AACnC,wBAAsB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOhF;AAED,kGAAkG;AAClG,wBAAsB,kBAAkB,CAAC,SAAS,EAAE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