@tensorix/metahub 0.1.2
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/README.md +162 -0
- package/dist/cli.js +20961 -0
- package/dist/cli.js.map +143 -0
- package/dist/core/blocks.d.ts +22 -0
- package/dist/core/blocks.d.ts.map +1 -0
- package/dist/core/cache.d.ts +10 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/context.d.ts +11 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/crdt.d.ts +35 -0
- package/dist/core/crdt.d.ts.map +1 -0
- package/dist/core/csv.d.ts +14 -0
- package/dist/core/csv.d.ts.map +1 -0
- package/dist/core/databases.d.ts +19 -0
- package/dist/core/databases.d.ts.map +1 -0
- package/dist/core/db.d.ts +13 -0
- package/dist/core/db.d.ts.map +1 -0
- package/dist/core/documents.d.ts +50 -0
- package/dist/core/documents.d.ts.map +1 -0
- package/dist/core/fracdex.d.ts +5 -0
- package/dist/core/fracdex.d.ts.map +1 -0
- package/dist/core/hlc.d.ts +13 -0
- package/dist/core/hlc.d.ts.map +1 -0
- package/dist/core/ids.d.ts +17 -0
- package/dist/core/ids.d.ts.map +1 -0
- package/dist/core/index.d.ts +22 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/indexing.d.ts +16 -0
- package/dist/core/indexing.d.ts.map +1 -0
- package/dist/core/node.d.ts +4 -0
- package/dist/core/node.d.ts.map +1 -0
- package/dist/core/paths.d.ts +4 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/properties.d.ts +35 -0
- package/dist/core/properties.d.ts.map +1 -0
- package/dist/core/records.d.ts +18 -0
- package/dist/core/records.d.ts.map +1 -0
- package/dist/core/resolve.d.ts +33 -0
- package/dist/core/resolve.d.ts.map +1 -0
- package/dist/core/schema.d.ts +3 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/search.d.ts +12 -0
- package/dist/core/search.d.ts.map +1 -0
- package/dist/core/sites.d.ts +45 -0
- package/dist/core/sites.d.ts.map +1 -0
- package/dist/core/snapshot.d.ts +58 -0
- package/dist/core/snapshot.d.ts.map +1 -0
- package/dist/core/sync/auth.d.ts +39 -0
- package/dist/core/sync/auth.d.ts.map +1 -0
- package/dist/core/sync/client.d.ts +8 -0
- package/dist/core/sync/client.d.ts.map +1 -0
- package/dist/core/sync/files.d.ts +17 -0
- package/dist/core/sync/files.d.ts.map +1 -0
- package/dist/core/sync/openapi.d.ts +14 -0
- package/dist/core/sync/openapi.d.ts.map +1 -0
- package/dist/core/sync/protocol.d.ts +49 -0
- package/dist/core/sync/protocol.d.ts.map +1 -0
- package/dist/core/sync/routes.d.ts +22 -0
- package/dist/core/sync/routes.d.ts.map +1 -0
- package/dist/core/sync/server.d.ts +21 -0
- package/dist/core/sync/server.d.ts.map +1 -0
- package/dist/core/sync/sites-routes.d.ts +3 -0
- package/dist/core/sync/sites-routes.d.ts.map +1 -0
- package/dist/core/sync/sites-serve.d.ts +3 -0
- package/dist/core/sync/sites-serve.d.ts.map +1 -0
- package/dist/core/sync/token.d.ts +23 -0
- package/dist/core/sync/token.d.ts.map +1 -0
- package/dist/core/sync/webui-routes.d.ts +3 -0
- package/dist/core/sync/webui-routes.d.ts.map +1 -0
- package/dist/core/sync/webui.d.ts +4 -0
- package/dist/core/sync/webui.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17389 -0
- package/dist/index.js.map +114 -0
- package/dist/webui.js +34 -0
- package/package.json +41 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export interface AuthConfig {
|
|
3
|
+
debug: boolean;
|
|
4
|
+
staticToken: string | null;
|
|
5
|
+
db: Database | null;
|
|
6
|
+
ttlMs: number;
|
|
7
|
+
graceMs: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function extractToken(req: Request, url: URL): string | null;
|
|
10
|
+
/** Whether auth is on at all (so the gate runs and the fetch shim is injected). */
|
|
11
|
+
export declare function authActive(cfg: AuthConfig): boolean;
|
|
12
|
+
/** The currently-valid token and its expiry, or null when auth is off. */
|
|
13
|
+
export declare function activeToken(cfg: AuthConfig): {
|
|
14
|
+
token: string;
|
|
15
|
+
exp: number;
|
|
16
|
+
} | null;
|
|
17
|
+
export declare function hasValidToken(req: Request, url: URL, cfg: AuthConfig): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Token exchange: a holder of the current token (or the in-grace previous token)
|
|
20
|
+
* gets the current token back. Managed mode only — returns null otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renewToken(req: Request, url: URL, cfg: AuthConfig): {
|
|
23
|
+
token: string;
|
|
24
|
+
exp: number;
|
|
25
|
+
} | null;
|
|
26
|
+
/** A browser navigation (so we can answer with an unlock page instead of a 401). */
|
|
27
|
+
export declare function wantsHtml(req: Request): boolean;
|
|
28
|
+
declare const HTML_HEADERS: {
|
|
29
|
+
"content-type": string;
|
|
30
|
+
};
|
|
31
|
+
/** Self-contained password prompt: stores token to localStorage + cookie, reloads. */
|
|
32
|
+
export declare function unlockPage(): string;
|
|
33
|
+
/** Insert the fetch shim into an HTML document (right after <head>, else prepend). */
|
|
34
|
+
export declare function injectShim(html: string): string;
|
|
35
|
+
/** For HTML responses when auth is active, inject the shim; otherwise pass through. */
|
|
36
|
+
export declare function withShim(res: Response, cfg: AuthConfig): Promise<Response>;
|
|
37
|
+
export declare function unauthorized(): Response;
|
|
38
|
+
export { HTML_HEADERS };
|
|
39
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/sync/auth.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQ3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,EAAE,EAAE,QAAQ,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAcD,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAIlE;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAEnD;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQlF;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAI9E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,UAAU,GACd;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUvC;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED,QAAA,MAAM,YAAY;;CAAiD,CAAC;AAEpE,sFAAsF;AACtF,wBAAgB,UAAU,IAAI,MAAM,CAoDnC;AA2CD,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED,uFAAuF;AACvF,wBAAsB,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAOhF;AAED,wBAAgB,YAAY,IAAI,QAAQ,CAEvC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export interface SyncResult {
|
|
3
|
+
pushed: number;
|
|
4
|
+
pulled: number;
|
|
5
|
+
}
|
|
6
|
+
/** Run one push/pull round against a peer server. */
|
|
7
|
+
export declare function syncWithPeer(db: Database, url: string): Promise<SyncResult>;
|
|
8
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/core/sync/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAuB3C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qDAAqD;AACrD,wBAAsB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAkBjF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export interface FileSyncResult {
|
|
3
|
+
direction: "export" | "import";
|
|
4
|
+
kind: "doc" | "db";
|
|
5
|
+
id: string;
|
|
6
|
+
path: string;
|
|
7
|
+
bytes?: number;
|
|
8
|
+
rows?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Move one document or data table between metahub and a file. Direction is
|
|
12
|
+
* inferred: whichever of `src`/`dst` resolves to an entity is the entity, the
|
|
13
|
+
* other is the file path. Entity on the left ⇒ export; on the right ⇒ import.
|
|
14
|
+
* Documents map to markdown (the doc body), data tables to CSV.
|
|
15
|
+
*/
|
|
16
|
+
export declare function syncFiles(db: Database, src: string, dst: string): Promise<FileSyncResult>;
|
|
17
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/core/sync/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAO3C,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAoFD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAkB/F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build an OpenAPI 3.1 document by walking the route registry. Each route's
|
|
3
|
+
* Zod schemas are converted to JSON Schema (draft 2020-12, which 3.1 accepts).
|
|
4
|
+
* Adding a route to ./routes.ts is enough — this picks it up with no codegen.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildOpenApi(version: string): {
|
|
7
|
+
openapi: string;
|
|
8
|
+
info: {
|
|
9
|
+
title: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
paths: Record<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/core/sync/openapi.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM;;;;;;;EA2B3C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Change as CrdtChange } from "../crdt.ts";
|
|
3
|
+
export declare const ChangeSchema: z.ZodObject<{
|
|
4
|
+
hlc: z.ZodString;
|
|
5
|
+
node_id: z.ZodString;
|
|
6
|
+
dataset: z.ZodString;
|
|
7
|
+
row_id: z.ZodString;
|
|
8
|
+
col: z.ZodString;
|
|
9
|
+
value: z.ZodNullable<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const SyncRequestSchema: z.ZodObject<{
|
|
12
|
+
node_id: z.ZodString;
|
|
13
|
+
since: z.ZodNumber;
|
|
14
|
+
changes: z.ZodArray<z.ZodObject<{
|
|
15
|
+
hlc: z.ZodString;
|
|
16
|
+
node_id: z.ZodString;
|
|
17
|
+
dataset: z.ZodString;
|
|
18
|
+
row_id: z.ZodString;
|
|
19
|
+
col: z.ZodString;
|
|
20
|
+
value: z.ZodNullable<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const SyncResponseSchema: z.ZodObject<{
|
|
24
|
+
node_id: z.ZodString;
|
|
25
|
+
changes: z.ZodArray<z.ZodObject<{
|
|
26
|
+
hlc: z.ZodString;
|
|
27
|
+
node_id: z.ZodString;
|
|
28
|
+
dataset: z.ZodString;
|
|
29
|
+
row_id: z.ZodString;
|
|
30
|
+
col: z.ZodString;
|
|
31
|
+
value: z.ZodNullable<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
cursor: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const HealthResponseSchema: z.ZodObject<{
|
|
36
|
+
ok: z.ZodBoolean;
|
|
37
|
+
node: z.ZodString;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type SyncRequest = z.infer<typeof SyncRequestSchema> & {
|
|
40
|
+
changes: CrdtChange[];
|
|
41
|
+
};
|
|
42
|
+
export type SyncResponse = z.infer<typeof SyncResponseSchema> & {
|
|
43
|
+
changes: CrdtChange[];
|
|
44
|
+
};
|
|
45
|
+
export type HealthResponse = z.infer<typeof HealthResponseSchema>;
|
|
46
|
+
export declare const SYNC_PATH = "/sync";
|
|
47
|
+
export declare const HEALTH_PATH = "/health";
|
|
48
|
+
export declare const RENEW_PATH = "/auth/token";
|
|
49
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/core/sync/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AAMvD,eAAO,MAAM,YAAY;;;;;;;iBAOvB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC;AAIH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,GAAG;IAAE,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AACxF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAAE,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AAC1F,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,WAAW,YAAY,CAAC;AAGrC,eAAO,MAAM,UAAU,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
|
+
import type { Database } from "bun:sqlite";
|
|
3
|
+
/** Injected at server startup; handlers reuse the open DB connection. */
|
|
4
|
+
export interface RouteCtx {
|
|
5
|
+
db: Database;
|
|
6
|
+
node: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One entry per endpoint. `request`/`response` are Zod schemas that double as
|
|
10
|
+
* the OpenAPI source (see ./openapi.ts). Add an endpoint here and it shows up
|
|
11
|
+
* in /docs automatically — no generate step, no separate spec file.
|
|
12
|
+
*/
|
|
13
|
+
export interface Route {
|
|
14
|
+
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
15
|
+
path: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
request?: ZodType;
|
|
18
|
+
response: ZodType;
|
|
19
|
+
handler: (req: Request, ctx: RouteCtx) => Promise<Response> | Response;
|
|
20
|
+
}
|
|
21
|
+
export declare const routes: Route[];
|
|
22
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/core/sync/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa3C,yEAAyE;AACzE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;CACxE;AA6BD,eAAO,MAAM,MAAM,EAAE,KAAK,EAAoD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RunningServer {
|
|
2
|
+
server: ReturnType<typeof Bun.serve>;
|
|
3
|
+
node: string;
|
|
4
|
+
port: number;
|
|
5
|
+
/** The active token, or null in --debug mode (auth disabled). */
|
|
6
|
+
token: string | null;
|
|
7
|
+
/** Token expiry (epoch ms); Infinity for a static --token, null when auth is off. */
|
|
8
|
+
exp: number | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ServerOptions {
|
|
11
|
+
port?: number;
|
|
12
|
+
/** Bind address. Defaults to 127.0.0.1; pass "0.0.0.0" to expose. */
|
|
13
|
+
host?: string;
|
|
14
|
+
/** Disable auth entirely. */
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
/** Custom token. If omitted in non-debug mode, one is generated. */
|
|
17
|
+
token?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Start the CRDT sync server. It is just another node backed by ~/.metahub. */
|
|
20
|
+
export declare function startServer(opts?: ServerOptions): RunningServer;
|
|
21
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/core/sync/server.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,qFAAqF;IACrF,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAYD,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,IAAI,GAAE,aAAkB,GAAG,aAAa,CA0FnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-routes.d.ts","sourceRoot":"","sources":["../../../src/core/sync/sites-routes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAY,MAAM,aAAa,CAAC;AAqCnD,eAAO,MAAM,WAAW,EAAE,KAAK,EAe9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-serve.d.ts","sourceRoot":"","sources":["../../../src/core/sync/sites-serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ5C,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAuBrF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
export interface TokenState {
|
|
3
|
+
token: string;
|
|
4
|
+
/** Epoch ms; once `now > exp`, the next request rotates. */
|
|
5
|
+
exp: number;
|
|
6
|
+
/** The immediately-previous token, exchangeable until `prevExp`. */
|
|
7
|
+
prev: string | null;
|
|
8
|
+
/** Epoch ms; how long `prev` stays exchangeable. */
|
|
9
|
+
prevExp: number;
|
|
10
|
+
}
|
|
11
|
+
/** Parse a duration like "30d" / "24h" / "90m" / "3600" (bare number = seconds). */
|
|
12
|
+
export declare function parseDuration(s: string | undefined, fallbackMs: number): number;
|
|
13
|
+
/** Default token lifetime (override with METAHUB_TOKEN_TTL). */
|
|
14
|
+
export declare const DEFAULT_TTL_MS: number;
|
|
15
|
+
/** Default grace window an old token stays swappable (override with METAHUB_TOKEN_GRACE). */
|
|
16
|
+
export declare const DEFAULT_GRACE_MS: number;
|
|
17
|
+
/** Current persisted state, or null if no token has been minted yet. */
|
|
18
|
+
export declare function readState(db: Database): TokenState | null;
|
|
19
|
+
/** Rotate: current → prev (swappable for `graceMs`), mint a fresh current. */
|
|
20
|
+
export declare function rotate(db: Database, ttlMs: number, graceMs: number): TokenState;
|
|
21
|
+
/** Persisted state, minting or rotating when missing/expired. */
|
|
22
|
+
export declare function loadOrRotate(db: Database, ttlMs: number, graceMs: number): TokenState;
|
|
23
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/core/sync/token.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQ3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiB/E;AAGD,gEAAgE;AAChE,eAAO,MAAM,cAAc,QAAyD,CAAC;AACrF,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,QAA0D,CAAC;AAexF,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI,CAUzD;AAED,8EAA8E;AAC9E,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAc/E;AAED,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAIrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webui-routes.d.ts","sourceRoot":"","sources":["../../../src/core/sync/webui-routes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAY,MAAM,aAAa,CAAC;AAsInD,eAAO,MAAM,WAAW,EAAE,KAAK,EAyN9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webui.d.ts","sourceRoot":"","sources":["../../../src/core/sync/webui.ts"],"names":[],"mappings":"AAkmBA;0CAC0C;AAC1C,wBAAsB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAiBvE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|