@dcasegr/skein 0.0.0-stage → 0.1.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/README.md +522 -2
- package/bin/skein-host.js +22 -0
- package/bin/skein.js +8 -0
- package/dist/client/admin-cli.d.ts +10 -0
- package/dist/client/admin-cli.js +370 -0
- package/dist/client/admin.d.ts +139 -0
- package/dist/client/admin.js +256 -0
- package/dist/client/bundle.d.ts +9 -0
- package/dist/client/bundle.js +34 -0
- package/dist/client/cli.d.ts +44 -0
- package/dist/client/cli.js +306 -0
- package/dist/client/client.d.ts +161 -0
- package/dist/client/client.js +237 -0
- package/dist/client/config.d.ts +18 -0
- package/dist/client/config.js +31 -0
- package/dist/client/conversation.d.ts +62 -0
- package/dist/client/conversation.js +113 -0
- package/dist/client/raw.d.ts +94 -0
- package/dist/client/raw.js +154 -0
- package/dist/client/target.d.ts +34 -0
- package/dist/client/target.js +158 -0
- package/dist/dev/cli.d.ts +8 -0
- package/dist/dev/cli.js +248 -0
- package/dist/dev/scan.d.ts +15 -0
- package/dist/dev/scan.js +173 -0
- package/dist/envelope-cbor.d.ts +110 -0
- package/dist/envelope-cbor.js +160 -0
- package/dist/envelope.d.ts +38 -0
- package/dist/envelope.js +101 -0
- package/dist/host/arc.d.ts +131 -0
- package/dist/host/arc.js +425 -0
- package/dist/host/billing.d.ts +102 -0
- package/dist/host/billing.js +167 -0
- package/dist/host/boot.d.ts +246 -0
- package/dist/host/boot.js +643 -0
- package/dist/host/cli.d.ts +57 -0
- package/dist/host/cli.js +1253 -0
- package/dist/host/clock.d.ts +3 -0
- package/dist/host/clock.js +8 -0
- package/dist/host/control.d.ts +45 -0
- package/dist/host/control.js +170 -0
- package/dist/host/cron.d.ts +99 -0
- package/dist/host/cron.js +196 -0
- package/dist/host/deliver.d.ts +53 -0
- package/dist/host/deliver.js +251 -0
- package/dist/host/deploy.d.ts +29 -0
- package/dist/host/deploy.js +55 -0
- package/dist/host/door-answer.d.ts +24 -0
- package/dist/host/door-answer.js +21 -0
- package/dist/host/events.d.ts +89 -0
- package/dist/host/events.js +222 -0
- package/dist/host/fake-arcade.d.ts +40 -0
- package/dist/host/fake-arcade.js +149 -0
- package/dist/host/fake-discovery.d.ts +4 -0
- package/dist/host/fake-discovery.js +58 -0
- package/dist/host/feeds.d.ts +127 -0
- package/dist/host/feeds.js +422 -0
- package/dist/host/frontdoor.d.ts +92 -0
- package/dist/host/frontdoor.js +172 -0
- package/dist/host/genesis.d.ts +259 -0
- package/dist/host/genesis.js +353 -0
- package/dist/host/handles.d.ts +40 -0
- package/dist/host/handles.js +88 -0
- package/dist/host/hostenv.d.ts +30 -0
- package/dist/host/hostenv.js +83 -0
- package/dist/host/image-chain.d.ts +127 -0
- package/dist/host/image-chain.js +440 -0
- package/dist/host/install.d.ts +22 -0
- package/dist/host/install.js +139 -0
- package/dist/host/instances.d.ts +227 -0
- package/dist/host/instances.js +430 -0
- package/dist/host/kernel.d.ts +246 -0
- package/dist/host/kernel.js +603 -0
- package/dist/host/liveness.d.ts +65 -0
- package/dist/host/liveness.js +155 -0
- package/dist/host/manifest.d.ts +160 -0
- package/dist/host/manifest.js +597 -0
- package/dist/host/p2p.d.ts +337 -0
- package/dist/host/p2p.js +1002 -0
- package/dist/host/packet.d.ts +121 -0
- package/dist/host/packet.js +562 -0
- package/dist/host/plan.d.ts +154 -0
- package/dist/host/plan.js +418 -0
- package/dist/host/providers.d.ts +238 -0
- package/dist/host/providers.js +565 -0
- package/dist/host/roster.d.ts +72 -0
- package/dist/host/roster.js +172 -0
- package/dist/host/router.d.ts +773 -0
- package/dist/host/router.js +2389 -0
- package/dist/host/signer.d.ts +49 -0
- package/dist/host/signer.js +167 -0
- package/dist/host/store-sqlite.d.ts +39 -0
- package/dist/host/store-sqlite.js +170 -0
- package/dist/host/stores.d.ts +43 -0
- package/dist/host/stores.js +342 -0
- package/dist/host/sync.d.ts +121 -0
- package/dist/host/sync.js +467 -0
- package/dist/host/testbeef.d.ts +21 -0
- package/dist/host/testbeef.js +37 -0
- package/dist/host/testhost.d.ts +149 -0
- package/dist/host/testhost.js +211 -0
- package/dist/host/vcdiff.d.ts +9 -0
- package/dist/host/vcdiff.js +210 -0
- package/dist/host/wasm-kernel.d.ts +87 -0
- package/dist/host/wasm-kernel.js +296 -0
- package/dist/host/wasm-worker.d.ts +1 -0
- package/dist/host/wasm-worker.js +186 -0
- package/dist/peers/cron.d.ts +33 -0
- package/dist/peers/cron.js +75 -0
- package/dist/peers/infer-main.d.ts +2 -0
- package/dist/peers/infer-main.js +74 -0
- package/dist/peers/infer.d.ts +163 -0
- package/dist/peers/infer.js +367 -0
- package/dist/runtime/beef.d.ts +28 -0
- package/dist/runtime/beef.js +107 -0
- package/dist/runtime/bitcoin.d.ts +36 -0
- package/dist/runtime/bitcoin.js +141 -0
- package/dist/runtime/cid.d.ts +14 -0
- package/dist/runtime/cid.js +51 -0
- package/dist/runtime/dispatch.d.ts +92 -0
- package/dist/runtime/dispatch.js +142 -0
- package/dist/runtime/envelope.d.ts +60 -0
- package/dist/runtime/envelope.js +101 -0
- package/dist/runtime/heads.d.ts +25 -0
- package/dist/runtime/heads.js +37 -0
- package/dist/runtime/identity.d.ts +28 -0
- package/dist/runtime/identity.js +67 -0
- package/dist/runtime/index-store.d.ts +152 -0
- package/dist/runtime/index-store.js +715 -0
- package/dist/runtime/log.d.ts +62 -0
- package/dist/runtime/log.js +104 -0
- package/dist/runtime/programs.d.ts +30 -0
- package/dist/runtime/programs.js +61 -0
- package/dist/runtime/records.d.ts +135 -0
- package/dist/runtime/records.js +149 -0
- package/dist/runtime/sqlite.d.ts +33 -0
- package/dist/runtime/sqlite.js +604 -0
- package/dist/runtime/store.d.ts +141 -0
- package/dist/runtime/store.js +24 -0
- package/dist/runtime/syscalls.d.ts +9 -0
- package/dist/runtime/syscalls.js +41 -0
- package/dist/runtime/tree.d.ts +60 -0
- package/dist/runtime/tree.js +196 -0
- package/dist/runtime/types.d.ts +100 -0
- package/dist/runtime/types.js +7 -0
- package/dist/testapps.d.ts +101 -0
- package/dist/testapps.js +275 -0
- package/dist/testkit.d.ts +25 -0
- package/dist/testkit.js +48 -0
- package/dist/wallet.d.ts +35 -0
- package/dist/wallet.js +87 -0
- package/images/README.md +68 -0
- package/images/default/README.md +38 -0
- package/images/default/bin/frontdoor.cid +1 -0
- package/images/default/bin/frontdoor.json +5 -0
- package/images/default/bin/messagebox.cid +1 -0
- package/images/default/bin/messagebox.json +8 -0
- package/images/default/bin/wallet.cid +1 -0
- package/images/default/bin/wallet.json +14 -0
- package/images/default/etc/config.json +1 -0
- package/images/default/etc/dispatch.json +82 -0
- package/images/host/etc/apps.json +8 -0
- package/kernel-zig/README.md +1247 -0
- package/kernel-zig/web/client.js +65 -0
- package/kernel-zig/web/kernel.d.ts +59 -0
- package/kernel-zig/web/kernel.js +329 -0
- package/kernel-zig/web/store.js +67 -0
- package/kernel-zig/web/worker.js +79 -0
- package/kernel-zig/zig-out/web/skein-kernel.wasm +0 -0
- package/package.json +77 -4
- package/wasm/README.md +35 -0
- package/wasm/frontdoor.wasm +0 -0
- package/wasm/messagebox.wasm +0 -0
- package/wasm/resolve.wasm +0 -0
- package/wasm/wallet.wasm +0 -0
- package/wasm/wire-probe.wasm +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Named heads (docs/VM.md, "Heads"): a chain per name, origin
|
|
2
|
+
//
|
|
3
|
+
// { kind: "head", name }
|
|
4
|
+
//
|
|
5
|
+
// and one update per move, { tree, owner, thread, input, at } (the store adds
|
|
6
|
+
// origin, prev, seq). The origin is the name's record, so a head is found by
|
|
7
|
+
// encoding it; a name never moved has no chain. Only the kernel writes heads
|
|
8
|
+
// (kernel-zig/src/heads.zig advanceHead): a program's step says so (the
|
|
9
|
+
// `advance` import) and that step ends without error, or a kernel operation
|
|
10
|
+
// does; the update names the thread and the log entry, so replay writes the
|
|
11
|
+
// same chain. This side reads them. `main` is the tree `chat` and `run` start
|
|
12
|
+
// from when they name none.
|
|
13
|
+
import { encode } from "./cid.js";
|
|
14
|
+
import { NotFound } from "./store.js";
|
|
15
|
+
export const MAIN = "main";
|
|
16
|
+
export const isHeadName = (x) => typeof x === "string" && x !== "" && !/[\s\0]/.test(x);
|
|
17
|
+
/** The head's chain origin: the same CID in every store. */
|
|
18
|
+
export function headOrigin(name) {
|
|
19
|
+
if (!isHeadName(name))
|
|
20
|
+
throw new TypeError(`head: bad name ${JSON.stringify(name)}`);
|
|
21
|
+
return encode({ kind: "head", name }).cid;
|
|
22
|
+
}
|
|
23
|
+
/** The tree a head names now, or undefined if it has never moved. */
|
|
24
|
+
export async function headTree(store, name) {
|
|
25
|
+
const origin = headOrigin(name);
|
|
26
|
+
let tip;
|
|
27
|
+
try {
|
|
28
|
+
tip = await store.chains.tip(origin);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
if (e instanceof NotFound)
|
|
32
|
+
return undefined;
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
return tip.equals(origin) ? undefined : treeOf(store, tip);
|
|
36
|
+
}
|
|
37
|
+
const treeOf = async (store, update) => (await store.get(update)).tree;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PublicKey, type WalletInterface, type WalletProtocol } from "@bsv/sdk";
|
|
2
|
+
export type { WalletInterface };
|
|
3
|
+
/** Every skein key is derived under this protocol, keyID = the service/actor name. */
|
|
4
|
+
export declare const PROTOCOL: WalletProtocol;
|
|
5
|
+
/** The part of BRC-100 skein's identities use. Any WalletInterface is one. */
|
|
6
|
+
export type KeyWallet = Pick<WalletInterface, "getPublicKey" | "createSignature">;
|
|
7
|
+
/** The public key (compressed hex) a wallet derives for `name`. */
|
|
8
|
+
export declare function identityOf(wallet: KeyWallet, name: string): Promise<string>;
|
|
9
|
+
/** The wallet's identity key: the instance's root. Nothing is signed with it directly (see Signer). */
|
|
10
|
+
export declare function rootIdentity(wallet: KeyWallet): Promise<string>;
|
|
11
|
+
export interface Signer {
|
|
12
|
+
/** DER ECDSA (secp256k1, low-S) over sha256(bytes), by the key behind `identity`. */
|
|
13
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
14
|
+
identity: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function signerFor(wallet: KeyWallet, name: string): Promise<Signer>;
|
|
17
|
+
/**
|
|
18
|
+
* The public key a wallet signs with for (protocol, keyID, counterparty
|
|
19
|
+
* "anyone") under `identityKey` (BRC-42/43). Anyone can compute it: the
|
|
20
|
+
* counterparty "anyone" is the private key 1, so the shared secret is the
|
|
21
|
+
* identity key itself. This is how skein verifies log entries and
|
|
22
|
+
* envelopes without a wallet.
|
|
23
|
+
*/
|
|
24
|
+
export declare function anyoneKey(identityKey: string, protocol: WalletProtocol, keyID: string): PublicKey;
|
|
25
|
+
/** Verify a DER signature over sha256(data) by the "anyone" key of (identityKey, protocol, keyID). */
|
|
26
|
+
export declare function verifyAnyone(identityKey: string, protocol: WalletProtocol, keyID: string, data: Uint8Array, der: Uint8Array): boolean;
|
|
27
|
+
/** Sign sha256(data) with the wallet's "anyone" key for (protocol, keyID): what verifyAnyone checks. */
|
|
28
|
+
export declare function signAnyone(wallet: KeyWallet, protocol: WalletProtocol, keyID: string, data: Uint8Array): Promise<Uint8Array>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Identities under a wallet, seen only as `KeyWallet` (BRC-100's
|
|
2
|
+
// getPublicKey + createSignature); how it is connected (a remote wallet-api
|
|
3
|
+
// over HTTP, an in-process wallet) is src/wallet.ts.
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { PrivateKey, PublicKey, Signature } from "@bsv/sdk";
|
|
6
|
+
/** Every skein key is derived under this protocol, keyID = the service/actor name. */
|
|
7
|
+
export const PROTOCOL = [1, "skein"];
|
|
8
|
+
// Keyed by wallet object: identities are a pure function of (root key, name),
|
|
9
|
+
// and a round trip per lookup would dominate signing over a remote wallet.
|
|
10
|
+
const identities = new WeakMap();
|
|
11
|
+
/** The public key (compressed hex) a wallet derives for `name`. */
|
|
12
|
+
export function identityOf(wallet, name) {
|
|
13
|
+
let byName = identities.get(wallet);
|
|
14
|
+
if (!byName)
|
|
15
|
+
identities.set(wallet, (byName = new Map()));
|
|
16
|
+
let p = byName.get(name);
|
|
17
|
+
if (!p) {
|
|
18
|
+
p = wallet.getPublicKey({ protocolID: PROTOCOL, keyID: name, counterparty: "self" }).then((r) => r.publicKey);
|
|
19
|
+
p.catch(() => byName.delete(name)); // don't memoise a failure (wallet locked, permission not yet granted); the caller awaiting `p` gets the error itself
|
|
20
|
+
byName.set(name, p);
|
|
21
|
+
}
|
|
22
|
+
return p;
|
|
23
|
+
}
|
|
24
|
+
/** The wallet's identity key: the instance's root. Nothing is signed with it directly (see Signer). */
|
|
25
|
+
export async function rootIdentity(wallet) {
|
|
26
|
+
return (await wallet.getPublicKey({ identityKey: true })).publicKey;
|
|
27
|
+
}
|
|
28
|
+
export async function signerFor(wallet, name) {
|
|
29
|
+
const identity = await identityOf(wallet, name);
|
|
30
|
+
return {
|
|
31
|
+
identity,
|
|
32
|
+
async sign(bytes) {
|
|
33
|
+
// Send the digest, not the data: a remote wallet needn't see the record.
|
|
34
|
+
const hash = [...createHash("sha256").update(bytes).digest()];
|
|
35
|
+
const { signature } = await wallet.createSignature({ protocolID: PROTOCOL, keyID: name, counterparty: "self", hashToDirectlySign: hash });
|
|
36
|
+
return Uint8Array.from(signature);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------- "anyone" signatures
|
|
41
|
+
/**
|
|
42
|
+
* The public key a wallet signs with for (protocol, keyID, counterparty
|
|
43
|
+
* "anyone") under `identityKey` (BRC-42/43). Anyone can compute it: the
|
|
44
|
+
* counterparty "anyone" is the private key 1, so the shared secret is the
|
|
45
|
+
* identity key itself. This is how skein verifies log entries and
|
|
46
|
+
* envelopes without a wallet.
|
|
47
|
+
*/
|
|
48
|
+
export function anyoneKey(identityKey, protocol, keyID) {
|
|
49
|
+
const invoice = `${protocol[0]}-${protocol[1].toLowerCase().trim()}-${keyID}`;
|
|
50
|
+
return PublicKey.fromString(identityKey).deriveChild(new PrivateKey(1), invoice);
|
|
51
|
+
}
|
|
52
|
+
/** Verify a DER signature over sha256(data) by the "anyone" key of (identityKey, protocol, keyID). */
|
|
53
|
+
export function verifyAnyone(identityKey, protocol, keyID, data, der) {
|
|
54
|
+
try {
|
|
55
|
+
// PublicKey.verify hashes with sha256 itself.
|
|
56
|
+
return anyoneKey(identityKey, protocol, keyID).verify([...data], Signature.fromDER([...der]));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Sign sha256(data) with the wallet's "anyone" key for (protocol, keyID): what verifyAnyone checks. */
|
|
63
|
+
export async function signAnyone(wallet, protocol, keyID, data) {
|
|
64
|
+
const hash = [...createHash("sha256").update(data).digest()];
|
|
65
|
+
const { signature } = await wallet.createSignature({ protocolID: protocol, keyID, counterparty: "anyone", hashToDirectlySign: hash });
|
|
66
|
+
return Uint8Array.from(signature);
|
|
67
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2
|
+
import { CID } from "./cid.ts";
|
|
3
|
+
import { type SqliteStore } from "./sqlite.ts";
|
|
4
|
+
import { type Store } from "./store.ts";
|
|
5
|
+
import type { Ref } from "./types.ts";
|
|
6
|
+
export declare const MAPS: readonly ["log", "unique", "chains", "updates", "threads", "resting", "sleepers", "awaits", "edges", "heads"];
|
|
7
|
+
export type MapName = typeof MAPS[number];
|
|
8
|
+
export declare const STATE_KIND = "skein-state";
|
|
9
|
+
/**
|
|
10
|
+
* A record as the TypeScript readers (the explorer, skein-dev, skein-host)
|
|
11
|
+
* show it. Format 2 (issue #33, kernel-zig/src/log.zig) keeps identity keys,
|
|
12
|
+
* hashes and signatures as byte strings and a genesis's `names` as a list;
|
|
13
|
+
* here they read back as the hex (and the `{key: name}` map) the display code
|
|
14
|
+
* knows, and a §7.3 envelope's `content` as base64. Display only: the
|
|
15
|
+
* record's CID is its stored bytes'.
|
|
16
|
+
*/
|
|
17
|
+
export declare function display(v: unknown): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* The Zig kernel's bitcoin codecs decoded the IPLD way (#42, bitcoin.ts,
|
|
20
|
+
* kernel-zig/src/bitcoin.zig): a header (bitcoin-block) links the previous
|
|
21
|
+
* header and its merkle root; a 64-byte bitcoin-tx is a merkle node linking
|
|
22
|
+
* its two children (nodes, or at the bottom transactions); a transaction's
|
|
23
|
+
* inputs link what they spend. The tree and the ancestry are sparse, so a
|
|
24
|
+
* link's target may not be held. The fields are the decoded node's.
|
|
25
|
+
*/
|
|
26
|
+
export { BITCOIN_BLOCK, BITCOIN_TX, DBL_SHA2_256 } from "./bitcoin.ts";
|
|
27
|
+
export declare function bitcoinView(cid: CID, bytes: Uint8Array): {
|
|
28
|
+
codec: string;
|
|
29
|
+
fields: Array<[string, string | CID]>;
|
|
30
|
+
} | undefined;
|
|
31
|
+
export declare function be64(n: number | bigint): Uint8Array;
|
|
32
|
+
export declare function readBe64(b: Uint8Array, at?: number): number;
|
|
33
|
+
export declare function strKey(s: string): Uint8Array;
|
|
34
|
+
declare function readStrKey(b: Uint8Array): {
|
|
35
|
+
s: string;
|
|
36
|
+
used: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function cat(...parts: Uint8Array[]): Uint8Array;
|
|
39
|
+
export declare function compare(a: Uint8Array, b: Uint8Array): number;
|
|
40
|
+
/** The length of the binary CID at the front of `b` (binary CIDs are prefix-free). */
|
|
41
|
+
declare function cidLen(b: Uint8Array): number;
|
|
42
|
+
/** A key's level: sha2-256(key)'s leading zero 5-bit groups. */
|
|
43
|
+
export declare function level(key: Uint8Array): number;
|
|
44
|
+
type Entry = [Uint8Array, unknown, CID | null];
|
|
45
|
+
type Node = [CID | null, Entry[]];
|
|
46
|
+
/** Read the trees through `get` (a block's bytes by CID). */
|
|
47
|
+
export declare class Trees {
|
|
48
|
+
private cache;
|
|
49
|
+
private readonly get;
|
|
50
|
+
constructor(get: (cid: CID) => Uint8Array | undefined);
|
|
51
|
+
node(cid: CID): Node;
|
|
52
|
+
lookup(root: CID | null, key: Uint8Array): unknown;
|
|
53
|
+
/** Entries with lo <= key < hi, in key order. */
|
|
54
|
+
range(root: CID | null, lo?: Uint8Array, hi?: Uint8Array): Generator<[Uint8Array, unknown]>;
|
|
55
|
+
prefixed(root: CID | null, p: Uint8Array): Generator<[Uint8Array<ArrayBufferLike>, unknown], any, any>;
|
|
56
|
+
}
|
|
57
|
+
/** The canonical tree of these pairs: its root, and its nodes (to store). */
|
|
58
|
+
export declare function buildTree(pairs: Array<[Uint8Array, unknown]>): {
|
|
59
|
+
root: CID | null;
|
|
60
|
+
blocks: Array<{
|
|
61
|
+
cid: CID;
|
|
62
|
+
bytes: Uint8Array;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
export interface State {
|
|
66
|
+
cid: CID;
|
|
67
|
+
log: CID | null;
|
|
68
|
+
cursor: number;
|
|
69
|
+
roots: Record<MapName, CID | null>;
|
|
70
|
+
}
|
|
71
|
+
export declare function readState(get: (cid: CID) => Uint8Array | undefined, cid: CID): State;
|
|
72
|
+
/** Every map's pairs for a store's chains and log, as index.zig derives them. */
|
|
73
|
+
export declare function derive(store: Store): Promise<{
|
|
74
|
+
pairs: Record<MapName, Array<[Uint8Array, unknown]>>;
|
|
75
|
+
log: CID | null;
|
|
76
|
+
cursor: number;
|
|
77
|
+
}>;
|
|
78
|
+
/** Does this SQLite file carry the state pointer (the format of #30)? */
|
|
79
|
+
export declare function hasStatePointer(path: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* A store file, whichever format it is in: the new format (#30) through the
|
|
82
|
+
* index, read only (blocks may be added unless `readOnly`); any other
|
|
83
|
+
* through sqlite.ts. (An LMDB set, `lmdb:<env dir>#<set>`: src/host/stores.ts.)
|
|
84
|
+
*/
|
|
85
|
+
export declare function openStoreFile(path: string, o?: {
|
|
86
|
+
readOnly?: boolean;
|
|
87
|
+
}): SqliteStore;
|
|
88
|
+
/** A store over the kernel's index (#30): its state record, and every head's name and root (the state's `heads` map). */
|
|
89
|
+
export type IndexStore = SqliteStore & {
|
|
90
|
+
state(): State;
|
|
91
|
+
heads(): Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
root: CID;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
export declare function indexStore(db: DatabaseSync, o?: {
|
|
97
|
+
readOnly?: boolean;
|
|
98
|
+
}): IndexStore;
|
|
99
|
+
/**
|
|
100
|
+
* What the index reader needs of a backend (as index.zig's `Backend`): blocks by binary CID, the
|
|
101
|
+
* state pointer (read on every call: a reader beside a live kernel follows it), a put if writable.
|
|
102
|
+
*/
|
|
103
|
+
export interface Blocks {
|
|
104
|
+
get(cid: Uint8Array): Uint8Array | undefined;
|
|
105
|
+
has(cid: Uint8Array): boolean;
|
|
106
|
+
put?(cid: Uint8Array, bytes: Uint8Array): void;
|
|
107
|
+
pointer(): Uint8Array | undefined;
|
|
108
|
+
close(): void;
|
|
109
|
+
}
|
|
110
|
+
export declare function indexStoreOver(src: Blocks): IndexStore;
|
|
111
|
+
/** host.db's `store` column for a set of the host's LMDB environment: `lmdb:<env dir>` (the set: the row's handle). */
|
|
112
|
+
export declare const LMDB = "lmdb:";
|
|
113
|
+
/** The chain's member set (#133): readable by every set (kernel-zig/src/lmdb_store.zig CHAIN_SET). */
|
|
114
|
+
export declare const CHAIN_SET = "host/chain";
|
|
115
|
+
/** Whether host.db's `store` column names a set of an LMDB environment. */
|
|
116
|
+
export declare function isLmdb(store: string): boolean;
|
|
117
|
+
/** host.db's `store` column for a set of the one-process kernel's RocksDB database (#158): `rocksdb:<db dir>` (the set: the row's handle). */
|
|
118
|
+
export declare const ROCKSDB = "rocksdb:";
|
|
119
|
+
/** Whether host.db's `store` column names a set of a RocksDB database (#158). */
|
|
120
|
+
export declare function isRocks(store: string): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* host.db's `store` column for a set of the host's one SQLite database (the settled split,
|
|
123
|
+
* 2026-10-31: the host loads the wasm kernel and keeps the storage, src/host/store-sqlite.ts):
|
|
124
|
+
* `sqlite:<db path>` (the set: the row's handle).
|
|
125
|
+
*/
|
|
126
|
+
export declare const SQLITE = "sqlite:";
|
|
127
|
+
/** Whether host.db's `store` column names a set of the host's SQLite database. */
|
|
128
|
+
export declare function isSqliteSet(store: string): boolean;
|
|
129
|
+
/** Whether a store is a set of a host's shared store (LMDB #96, RocksDB #158, SQLite 2026-10-31), not a file of its own. */
|
|
130
|
+
export declare function isSet(store: string): boolean;
|
|
131
|
+
/** A row's store as the kernel's tools and `openStoreFile` name it: its path, `lmdb:<env dir>#<handle>`, `rocksdb:<db dir>#<handle>` or `sqlite:<db path>#<handle>`. */
|
|
132
|
+
export declare function storeSpec(row: {
|
|
133
|
+
store: string;
|
|
134
|
+
handle: string;
|
|
135
|
+
}): string;
|
|
136
|
+
/** `rocksdb:<db dir>#<set>` → its parts (kernel-zig/src/any_store.zig parseRocksSpec); undefined for anything else. */
|
|
137
|
+
export declare function parseRocksSpec(spec: string): {
|
|
138
|
+
dir: string;
|
|
139
|
+
set: string;
|
|
140
|
+
} | undefined;
|
|
141
|
+
/** `sqlite:<db path>#<set>` → its parts; undefined for anything else. */
|
|
142
|
+
export declare function parseSqliteSpec(spec: string): {
|
|
143
|
+
db: string;
|
|
144
|
+
set: string;
|
|
145
|
+
} | undefined;
|
|
146
|
+
/** `lmdb:<env dir>#<set>` → its parts (kernel-zig/src/any_store.zig parseSpec); undefined for a path. */
|
|
147
|
+
export declare function parseLmdbSpec(spec: string): {
|
|
148
|
+
dir: string;
|
|
149
|
+
set: string;
|
|
150
|
+
} | undefined;
|
|
151
|
+
export { readStrKey, cidLen };
|
|
152
|
+
export type { Ref };
|