@artblocks/abx-token-api 0.1.0-alpha.4 → 0.1.0-alpha.6
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/dist/control-plane.d.ts +78 -0
- package/dist/control-plane.d.ts.map +1 -0
- package/dist/control-plane.js +652 -0
- package/dist/control-plane.js.map +1 -0
- package/dist/dashboard.js +5 -3
- package/dist/dashboard.js.map +1 -1
- package/dist/server.d.ts +0 -26
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +59 -357
- package/dist/server.js.map +1 -1
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js +125 -2
- package/dist/watcher.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The /v1 control plane + the service descriptor — the resolver's ONE write surface, speaking the
|
|
3
|
+
* provider-neutral interface pinned by specs/self-host-toolkit/remote-services.md. Everything here
|
|
4
|
+
* is index/metadata control (register, list, deregister, reindex, status, effect publishes): the
|
|
5
|
+
* bearer token never signs anything on-chain, so the "no signing key on the host" rule is intact.
|
|
6
|
+
*
|
|
7
|
+
* This module never imports server.ts (one-way dependency), which is why the shared HTTP helpers
|
|
8
|
+
* (sendJson, the bearer guard) live here and the read plane imports them.
|
|
9
|
+
*/
|
|
10
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
11
|
+
import { type ProjectState, type ServiceDescriptor } from '@artblocks/abx-sdk';
|
|
12
|
+
import type { SelfHostIndexer } from '@artblocks/abx-indexer';
|
|
13
|
+
import type { StorageBackend } from '@artblocks/abx-storage';
|
|
14
|
+
export interface ControlPlaneContext {
|
|
15
|
+
indexer: SelfHostIndexer;
|
|
16
|
+
storage: StorageBackend;
|
|
17
|
+
/** The chain this node serves — every control-plane call names a chainId and is checked against it. */
|
|
18
|
+
chainId: number;
|
|
19
|
+
/** The chain KEY ('sepolia', …) the indexer registers projects under — the string form of chainId. */
|
|
20
|
+
chainKey: string;
|
|
21
|
+
/** The public base this node believes it serves — echoed in the descriptor. */
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function sendJson(res: ServerResponse, status: number, body: unknown): void;
|
|
25
|
+
/**
|
|
26
|
+
* The ONE bearer guard for every gated route: 404 code `disabled` when no token is configured on
|
|
27
|
+
* the host (the write surface honestly doesn't exist — the descriptor omits the control-plane
|
|
28
|
+
* interface too), 401 code `unauthorized` on a missing/bad bearer. Returns false if it handled
|
|
29
|
+
* the response (caller must stop), true when the request may proceed. 403 (`forbidden`) is
|
|
30
|
+
* spec-defined for multi-tenant providers; this single-token reference never emits it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function requireBearer(req: IncomingMessage, res: ServerResponse): boolean;
|
|
33
|
+
/** The one-line project summary shared by `GET /api/projects` and the register/reindex responses. */
|
|
34
|
+
export declare function summarize(s: ProjectState): {
|
|
35
|
+
address: `0x${string}`;
|
|
36
|
+
name: string | null;
|
|
37
|
+
symbol: string | null;
|
|
38
|
+
owner: `0x${string}` | null;
|
|
39
|
+
abxVersion: number | null;
|
|
40
|
+
isCanonical: boolean | null;
|
|
41
|
+
extensions: string[];
|
|
42
|
+
eventCount: number;
|
|
43
|
+
tokenCount: number;
|
|
44
|
+
mintedCount: number;
|
|
45
|
+
reconstructedAt: string;
|
|
46
|
+
};
|
|
47
|
+
/** Parse a stored content-locators JSON column → `{hash: locator}` (lowercased keys, never throws). */
|
|
48
|
+
export declare function safeLocators(json: string): Record<string, string> | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Decide the scan floor + whether a full replay is needed when registering a project via the
|
|
51
|
+
* control plane. Pure (the discovery/refusal fallback for the null case is the caller's):
|
|
52
|
+
* - explicit `bodyFromBlock` wins; else the `existingFromBlock` already stored.
|
|
53
|
+
* - `null` ⇒ NEITHER supplied nor stored — the caller must derive the deploy block or refuse
|
|
54
|
+
* (never default to genesis: a range-capped RPC would sweep millions of blocks).
|
|
55
|
+
* - `full` is true only when forced, on a first registration (no existing floor), or when the
|
|
56
|
+
* floor actually CHANGED — so re-sending the SAME floor (the CLI now always forwards the deploy
|
|
57
|
+
* block, even on a nudge) stays incremental: registering twice ≠ two full scans.
|
|
58
|
+
*/
|
|
59
|
+
export declare function planRegistrationFloor(bodyFromBlock: string | undefined, existingFromBlock: string | undefined, forceFull?: boolean): {
|
|
60
|
+
fromBlock: string;
|
|
61
|
+
full: boolean;
|
|
62
|
+
} | null;
|
|
63
|
+
/**
|
|
64
|
+
* `GET /.well-known/abx-service` — what this node supports, agent-readably (public, no auth).
|
|
65
|
+
* The control-plane + effects-publish interfaces (and `auth`) appear iff the bearer token is
|
|
66
|
+
* configured: a token-less self-host node honestly advertises no remote control surface — which
|
|
67
|
+
* is how a client tells "disabled" from "wrong URL". `render` appears when a runner rides behind
|
|
68
|
+
* this resolver (ABX_EFFECTS_URL); its declared effects come from a best-effort `/health` probe.
|
|
69
|
+
* Provider identity (name, signup/docs URLs) is deployment env — no provider ships in this code.
|
|
70
|
+
*/
|
|
71
|
+
export declare function serviceDescriptor(ctx: ControlPlaneContext): Promise<ServiceDescriptor>;
|
|
72
|
+
/**
|
|
73
|
+
* Dispatch a `/v1/*` request (`parts` excludes the leading `v1`). Every route is bearer-gated;
|
|
74
|
+
* `chainId` is explicit everywhere (body on collection POSTs, path elsewhere) and validated, so a
|
|
75
|
+
* project can never silently register against the wrong chain. Wrong method on a known path ⇒ 405.
|
|
76
|
+
*/
|
|
77
|
+
export declare function routeControlPlane(req: IncomingMessage, res: ServerResponse, ctx: ControlPlaneContext, parts: string[]): Promise<void>;
|
|
78
|
+
//# sourceMappingURL=control-plane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../src/control-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,WAAW,CAAC;AAC/D,OAAO,EAaL,K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