nervur 0.21.4 → 0.22.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/README.md +215 -158
- package/dist/browser.js +4 -3
- package/dist/cli.js +16 -0
- package/dist/{being → core/being}/being.js +10 -0
- package/dist/{being → core/being}/faculty.js +5 -2
- package/dist/{being → core/being}/index.d.ts +1 -1
- package/dist/{being → core/being}/index.js +1 -1
- package/dist/{being → core/being}/kind.d.ts +2 -0
- package/dist/{being → core/being}/kind.js +6 -0
- package/dist/{being → core/being}/types.js +1 -1
- package/dist/{browser → core/browser}/index.d.ts +6 -5
- package/dist/{browser → core/browser}/index.js +10 -10
- package/dist/{browser → core/browser}/worker.d.ts +2 -3
- package/dist/{browser → core/browser}/worker.js +8 -11
- package/dist/{cli → core/cli}/command.d.ts +4 -4
- package/dist/{cli → core/cli}/command.js +116 -66
- package/dist/{cli → core/cli}/edge.js +4 -2
- package/dist/core/cli/harbor.d.ts +25 -0
- package/dist/{cli → core/cli}/harbor.js +45 -33
- package/dist/{contract → core/contract}/index.d.ts +6 -5
- package/dist/{contract → core/contract}/index.js +8 -9
- package/dist/core/contract/link.d.ts +4 -0
- package/dist/core/contract/link.js +45 -0
- package/dist/{crypto → core/crypto}/ed25519.js +22 -14
- package/dist/core/crypto/subtle.d.ts +3 -0
- package/dist/core/crypto/subtle.js +11 -0
- package/dist/core/crypto/x25519.js +24 -0
- package/dist/core/edge/index.d.ts +164 -0
- package/dist/core/edge/index.js +739 -0
- package/dist/core/edge/kit.d.ts +2 -0
- package/dist/core/edge/kit.js +2 -0
- package/dist/core/git/http.d.ts +6 -0
- package/dist/core/git/http.js +102 -0
- package/dist/core/git/index.d.ts +5 -0
- package/dist/core/git/index.js +10 -0
- package/dist/core/git/object.d.ts +40 -0
- package/dist/core/git/object.js +103 -0
- package/dist/core/git/pack.d.ts +9 -0
- package/dist/core/git/pack.js +171 -0
- package/dist/core/git/store.d.ts +23 -0
- package/dist/core/git/store.js +120 -0
- package/dist/core/git/zlib.d.ts +6 -0
- package/dist/core/git/zlib.js +210 -0
- package/dist/core/harbor/carrying.d.ts +51 -0
- package/dist/core/harbor/carrying.js +69 -0
- package/dist/core/harbor/catalogue.d.ts +33 -0
- package/dist/core/harbor/catalogue.js +365 -0
- package/dist/core/harbor/dna.d.ts +13 -0
- package/dist/core/harbor/dna.js +120 -0
- package/dist/{harbor → core/harbor}/dock.d.ts +22 -13
- package/dist/core/harbor/dock.js +381 -0
- package/dist/core/harbor/harbor.d.ts +16 -0
- package/dist/core/harbor/harbor.js +438 -0
- package/dist/core/harbor/index.d.ts +11 -0
- package/dist/{harbor → core/harbor}/index.js +5 -5
- package/dist/core/harbor/memory.d.ts +10 -0
- package/dist/core/harbor/memory.js +25 -0
- package/dist/{harbor → core/harbor}/package.d.ts +0 -1
- package/dist/{harbor → core/harbor}/package.js +9 -9
- package/dist/core/harbor/probe.d.ts +22 -0
- package/dist/core/harbor/probe.js +15 -0
- package/dist/core/harbor/registry.d.ts +15 -0
- package/dist/{harbor → core/harbor}/registry.js +26 -10
- package/dist/core/harbor/root-line.d.ts +7 -0
- package/dist/core/harbor/root-line.js +9 -0
- package/dist/{harbor → core/harbor}/terrain.d.ts +9 -6
- package/dist/{harbor → core/harbor}/terrain.js +5 -4
- package/dist/core/http/index.d.ts +2 -0
- package/dist/{http → core/http}/index.js +3 -5
- package/dist/{line → core/line}/answer.d.ts +2 -2
- package/dist/{line → core/line}/frame.d.ts +0 -5
- package/dist/{line → core/line}/frame.js +0 -4
- package/dist/core/line/ground.js +7 -0
- package/dist/core/line/index.d.ts +4 -0
- package/dist/core/line/index.js +8 -0
- package/dist/core/line/web.d.ts +12 -0
- package/dist/{line → core/line}/web.js +13 -77
- package/dist/{node → core/node}/index.d.ts +2 -15
- package/dist/core/node/index.js +124 -0
- package/dist/{pointer → core/pointer}/bodies.d.ts +7 -5
- package/dist/core/pointer/bodies.js +118 -0
- package/dist/core/pointer/index.d.ts +2 -0
- package/dist/{pointer → core/pointer}/index.js +1 -1
- package/dist/{pointer → core/pointer}/world.d.ts +13 -9
- package/dist/{pointer → core/pointer}/world.js +31 -16
- package/dist/{proof → core/proof}/contracts.d.ts +6 -2
- package/dist/{proof → core/proof}/contracts.js +11 -10
- package/dist/core/proof/index.d.ts +3 -0
- package/dist/{proof → core/proof}/index.js +2 -2
- package/dist/core/proof/law.d.ts +25 -0
- package/dist/core/proof/law.js +715 -0
- package/dist/{tcp → core/tcp}/index.d.ts +7 -4
- package/dist/{tcp → core/tcp}/index.js +11 -62
- package/dist/{ward/ward.d.ts → core/ward/house.d.ts} +24 -10
- package/dist/core/ward/house.js +473 -0
- package/dist/core/ward/index.d.ts +5 -0
- package/dist/core/ward/index.js +7 -0
- package/dist/{ward → core/ward}/partition.d.ts +1 -0
- package/dist/{ward → core/ward}/stance.d.ts +2 -2
- package/dist/{ward → core/ward}/stance.js +5 -2
- package/dist/{ward/ward-being.d.ts → core/ward/ward.d.ts} +14 -6
- package/dist/core/ward/ward.js +140 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +19 -0
- package/dist/defaults/dock/index.d.ts +4 -0
- package/dist/defaults/dock/index.js +11 -0
- package/dist/defaults/index.d.ts +5 -0
- package/dist/defaults/index.js +10 -0
- package/dist/defaults/memory/index.d.ts +12 -0
- package/dist/defaults/memory/index.js +39 -0
- package/dist/defaults/tcp/index.d.ts +16 -0
- package/dist/defaults/tcp/index.js +82 -0
- package/dist/defaults/ward/index.d.ts +4 -0
- package/dist/defaults/ward/index.js +11 -0
- package/dist/defaults/web/index.d.ts +15 -0
- package/dist/defaults/web/index.js +90 -0
- package/dist/edge.js +4 -3
- package/dist/index.d.ts +1 -8
- package/dist/index.js +13 -18
- package/dist/kit.d.ts +4 -0
- package/dist/kit.js +12 -0
- package/dist/node.js +4 -3
- package/package.json +23 -18
- package/src/browser.ts +4 -3
- package/src/cli.ts +15 -0
- package/src/{being → core/being}/being.ts +4 -0
- package/src/{being → core/being}/faculty.ts +5 -2
- package/src/{being → core/being}/index.ts +1 -1
- package/src/{being → core/being}/kind.ts +7 -0
- package/src/{being → core/being}/types.ts +1 -1
- package/src/{browser → core/browser}/index.ts +16 -13
- package/src/{browser → core/browser}/worker.ts +11 -14
- package/src/{cli → core/cli}/command.ts +113 -66
- package/src/{cli → core/cli}/edge.ts +4 -2
- package/src/{cli → core/cli}/harbor.ts +48 -31
- package/src/{contract → core/contract}/index.ts +14 -14
- package/src/core/contract/link.ts +58 -0
- package/src/{crypto → core/crypto}/ed25519.ts +22 -14
- package/src/core/crypto/subtle.ts +13 -0
- package/src/core/crypto/x25519.ts +23 -0
- package/src/core/edge/index.ts +865 -0
- package/src/core/git/http.ts +103 -0
- package/src/core/git/index.ts +10 -0
- package/src/core/git/object.ts +116 -0
- package/src/core/git/pack.ts +147 -0
- package/src/core/git/store.ts +122 -0
- package/src/core/git/zlib.ts +197 -0
- package/src/core/harbor/carrying.ts +124 -0
- package/src/core/harbor/catalogue.ts +386 -0
- package/src/core/harbor/dna.ts +116 -0
- package/src/core/harbor/dock.ts +420 -0
- package/src/core/harbor/harbor.ts +433 -0
- package/src/core/harbor/index.ts +14 -0
- package/src/core/harbor/memory.ts +31 -0
- package/src/{harbor → core/harbor}/package.ts +15 -15
- package/src/core/harbor/probe.ts +39 -0
- package/src/{harbor → core/harbor}/registry.ts +28 -11
- package/src/core/harbor/root-line.ts +19 -0
- package/src/{harbor → core/harbor}/terrain.ts +14 -7
- package/src/{http → core/http}/index.ts +5 -8
- package/src/{line → core/line}/answer.ts +3 -2
- package/src/{line → core/line}/frame.ts +0 -5
- package/src/core/line/ground.ts +18 -0
- package/src/core/line/index.ts +8 -0
- package/src/{line → core/line}/web.ts +1 -105
- package/src/core/node/index.ts +139 -0
- package/src/core/pointer/bodies.ts +122 -0
- package/src/core/pointer/index.ts +4 -0
- package/src/{pointer → core/pointer}/world.ts +45 -21
- package/src/{proof → core/proof}/contracts.ts +18 -13
- package/src/{proof → core/proof}/index.ts +3 -3
- package/src/core/proof/law.ts +742 -0
- package/src/{stand → core/stand}/stand.ts +2 -2
- package/src/{tcp → core/tcp}/index.ts +17 -74
- package/src/core/ward/house.ts +524 -0
- package/src/core/ward/index.ts +7 -0
- package/src/{ward → core/ward}/partition.ts +5 -1
- package/src/{ward → core/ward}/stance.ts +5 -2
- package/src/core/ward/ward.ts +166 -0
- package/src/core.ts +55 -0
- package/src/defaults/dock/index.ts +12 -0
- package/src/defaults/index.ts +10 -0
- package/src/defaults/memory/index.ts +50 -0
- package/src/defaults/tcp/index.ts +89 -0
- package/src/defaults/ward/index.ts +12 -0
- package/src/defaults/web/index.ts +97 -0
- package/src/edge.ts +4 -3
- package/src/index.ts +13 -50
- package/src/kit.ts +15 -0
- package/src/node.ts +4 -3
- package/dist/cli/harbor.d.ts +0 -16
- package/dist/cli/main.js +0 -14
- package/dist/crypto/subtle.d.ts +0 -10
- package/dist/crypto/subtle.js +0 -29
- package/dist/crypto/x25519.js +0 -21
- package/dist/edge/index.d.ts +0 -81
- package/dist/edge/index.js +0 -400
- package/dist/harbor/carrying.d.ts +0 -17
- package/dist/harbor/carrying.js +0 -38
- package/dist/harbor/catalogue.d.ts +0 -28
- package/dist/harbor/catalogue.js +0 -109
- package/dist/harbor/dock.js +0 -236
- package/dist/harbor/harbor.d.ts +0 -45
- package/dist/harbor/harbor.js +0 -347
- package/dist/harbor/index.d.ts +0 -11
- package/dist/harbor/probe.d.ts +0 -18
- package/dist/harbor/probe.js +0 -15
- package/dist/harbor/registry.d.ts +0 -10
- package/dist/harbor/relay.d.ts +0 -15
- package/dist/harbor/relay.js +0 -406
- package/dist/harbor/root-line.d.ts +0 -9
- package/dist/harbor/root-line.js +0 -38
- package/dist/harbor/store.d.ts +0 -13
- package/dist/harbor/store.js +0 -53
- package/dist/http/index.d.ts +0 -4
- package/dist/line/ground.js +0 -9
- package/dist/line/index.d.ts +0 -5
- package/dist/line/index.js +0 -9
- package/dist/line/push.d.ts +0 -7
- package/dist/line/push.js +0 -92
- package/dist/line/web.d.ts +0 -30
- package/dist/node/index.js +0 -236
- package/dist/pointer/bodies.js +0 -80
- package/dist/pointer/index.d.ts +0 -2
- package/dist/proof/index.d.ts +0 -3
- package/dist/proof/law.d.ts +0 -90
- package/dist/proof/law.js +0 -591
- package/dist/tcp/frame.d.ts +0 -25
- package/dist/tcp/frame.js +0 -64
- package/dist/ward/index.d.ts +0 -6
- package/dist/ward/index.js +0 -8
- package/dist/ward/pilot.d.ts +0 -8
- package/dist/ward/pilot.js +0 -50
- package/dist/ward/ward-being.js +0 -82
- package/dist/ward/ward.js +0 -290
- package/src/cli/main.ts +0 -13
- package/src/crypto/subtle.ts +0 -33
- package/src/crypto/x25519.ts +0 -21
- package/src/edge/index.ts +0 -490
- package/src/harbor/carrying.ts +0 -56
- package/src/harbor/catalogue.ts +0 -134
- package/src/harbor/dock.ts +0 -265
- package/src/harbor/harbor.ts +0 -381
- package/src/harbor/index.ts +0 -14
- package/src/harbor/probe.ts +0 -34
- package/src/harbor/relay.ts +0 -418
- package/src/harbor/root-line.ts +0 -39
- package/src/harbor/store.ts +0 -69
- package/src/line/ground.ts +0 -19
- package/src/line/index.ts +0 -9
- package/src/line/push.ts +0 -112
- package/src/node/index.ts +0 -241
- package/src/pointer/bodies.ts +0 -82
- package/src/pointer/index.ts +0 -4
- package/src/proof/law.ts +0 -591
- package/src/ward/index.ts +0 -8
- package/src/ward/pilot.ts +0 -50
- package/src/ward/ward-being.ts +0 -103
- package/src/ward/ward.ts +0 -328
- /package/dist/{cli/main.d.ts → cli.d.ts} +0 -0
- /package/dist/{being → core/being}/being.d.ts +0 -0
- /package/dist/{being → core/being}/digest.d.ts +0 -0
- /package/dist/{being → core/being}/digest.js +0 -0
- /package/dist/{being → core/being}/faculty.d.ts +0 -0
- /package/dist/{being → core/being}/types.d.ts +0 -0
- /package/dist/{being → core/being}/words.d.ts +0 -0
- /package/dist/{being → core/being}/words.js +0 -0
- /package/dist/{cli → core/cli}/edge.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/aes.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/aes.js +0 -0
- /package/dist/{crypto → core/crypto}/bytes.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/bytes.js +0 -0
- /package/dist/{crypto → core/crypto}/ed25519.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/hash.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/hash.js +0 -0
- /package/dist/{crypto → core/crypto}/index.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/index.js +0 -0
- /package/dist/{crypto → core/crypto}/json.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/json.js +0 -0
- /package/dist/{crypto → core/crypto}/mlkem.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/mlkem.js +0 -0
- /package/dist/{crypto → core/crypto}/x25519.d.ts +0 -0
- /package/dist/{folder → core/folder}/index.d.ts +0 -0
- /package/dist/{folder → core/folder}/index.js +0 -0
- /package/dist/{http → core/http}/websocket.d.ts +0 -0
- /package/dist/{http → core/http}/websocket.js +0 -0
- /package/dist/{line → core/line}/answer.js +0 -0
- /package/dist/{line → core/line}/ground.d.ts +0 -0
- /package/dist/{proof → core/proof}/expect.d.ts +0 -0
- /package/dist/{proof → core/proof}/expect.js +0 -0
- /package/dist/{quo → core/quo}/address.d.ts +0 -0
- /package/dist/{quo → core/quo}/address.js +0 -0
- /package/dist/{quo → core/quo}/door.d.ts +0 -0
- /package/dist/{quo → core/quo}/door.js +0 -0
- /package/dist/{quo → core/quo}/index.d.ts +0 -0
- /package/dist/{quo → core/quo}/index.js +0 -0
- /package/dist/{quo → core/quo}/invitation.d.ts +0 -0
- /package/dist/{quo → core/quo}/invitation.js +0 -0
- /package/dist/{quo → core/quo}/keys.d.ts +0 -0
- /package/dist/{quo → core/quo}/keys.js +0 -0
- /package/dist/{quo → core/quo}/payload.d.ts +0 -0
- /package/dist/{quo → core/quo}/payload.js +0 -0
- /package/dist/{quo → core/quo}/relations.d.ts +0 -0
- /package/dist/{quo → core/quo}/relations.js +0 -0
- /package/dist/{quo → core/quo}/reply.d.ts +0 -0
- /package/dist/{quo → core/quo}/reply.js +0 -0
- /package/dist/{quo → core/quo}/seal.d.ts +0 -0
- /package/dist/{quo → core/quo}/seal.js +0 -0
- /package/dist/{quo → core/quo}/standing.d.ts +0 -0
- /package/dist/{quo → core/quo}/standing.js +0 -0
- /package/dist/{ward → core/ward}/allowance.d.ts +0 -0
- /package/dist/{ward → core/ward}/allowance.js +0 -0
- /package/dist/{ward → core/ward}/cells.d.ts +0 -0
- /package/dist/{ward → core/ward}/cells.js +0 -0
- /package/dist/{ward → core/ward}/partition.js +0 -0
- /package/src/{being → core/being}/digest.ts +0 -0
- /package/src/{being → core/being}/words.ts +0 -0
- /package/src/{crypto → core/crypto}/aes.ts +0 -0
- /package/src/{crypto → core/crypto}/bytes.ts +0 -0
- /package/src/{crypto → core/crypto}/hash.ts +0 -0
- /package/src/{crypto → core/crypto}/index.ts +0 -0
- /package/src/{crypto → core/crypto}/json.ts +0 -0
- /package/src/{crypto → core/crypto}/mlkem.ts +0 -0
- /package/src/{folder → core/folder}/index.ts +0 -0
- /package/src/{http → core/http}/websocket.ts +0 -0
- /package/src/{proof → core/proof}/expect.ts +0 -0
- /package/src/{quo → core/quo}/address.ts +0 -0
- /package/src/{quo → core/quo}/door.ts +0 -0
- /package/src/{quo → core/quo}/index.ts +0 -0
- /package/src/{quo → core/quo}/invitation.ts +0 -0
- /package/src/{quo → core/quo}/keys.ts +0 -0
- /package/src/{quo → core/quo}/payload.ts +0 -0
- /package/src/{quo → core/quo}/relations.ts +0 -0
- /package/src/{quo → core/quo}/reply.ts +0 -0
- /package/src/{quo → core/quo}/seal.ts +0 -0
- /package/src/{quo → core/quo}/standing.ts +0 -0
- /package/src/{stand → core/stand}/main.ts +0 -0
- /package/src/{ward → core/ward}/allowance.ts +0 -0
- /package/src/{ward → core/ward}/cells.ts +0 -0
package/dist/line/web.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type Dialed, type Ground, type GroundFaculty } from '../harbor/index.ts';
|
|
2
|
-
export declare const MIN_POST = 65;
|
|
3
|
-
export declare const MAX_POST: number;
|
|
4
|
-
export declare class WebDialer {
|
|
5
|
-
#private;
|
|
6
|
-
dial(at: string, pk: string, bytes: Uint8Array): Promise<Dialed>;
|
|
7
|
-
close(): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export type WebListen = {
|
|
10
|
-
host: string;
|
|
11
|
-
port: number;
|
|
12
|
-
path: string;
|
|
13
|
-
origins: string[];
|
|
14
|
-
};
|
|
15
|
-
export interface WebListener {
|
|
16
|
-
readonly at: string[];
|
|
17
|
-
readonly port: number;
|
|
18
|
-
close(): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export type WebServe = (ground: Ground, listen: WebListen) => Promise<WebListener>;
|
|
21
|
-
export declare const WEB = "org.nervur.web";
|
|
22
|
-
export declare const WEB_OPENING: {
|
|
23
|
-
readonly key: 'web';
|
|
24
|
-
readonly kind: "org.nervur.web";
|
|
25
|
-
};
|
|
26
|
-
export declare const webFaculty: (serve?: WebServe) => GroundFaculty;
|
|
27
|
-
export declare const readPost: (body: Uint8Array) => {
|
|
28
|
-
pk: string;
|
|
29
|
-
box: Uint8Array;
|
|
30
|
-
} | null;
|
package/dist/node/index.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
// `nervur/node`: the Node ground. A harbor keeps its seed and sealed
|
|
11
|
-
// memory in a folder, finds its code among the modules it is handed and
|
|
12
|
-
// then in files, speaks TCP from genesis and the web and Web Push where
|
|
13
|
-
// the root opens them, and serves the root line on a local socket, so the
|
|
14
|
-
// `nervur` command reaches it while it stands.
|
|
15
|
-
//
|
|
16
|
-
// <dir>/seed the harbor's seed
|
|
17
|
-
// <dir>/<place>/ its sealed memory
|
|
18
|
-
// <dir>/root.sock the root line while the harbor is served, open to
|
|
19
|
-
// this user alone, or in the temporary folder for a
|
|
20
|
-
// folder too deep for a socket path
|
|
21
|
-
//
|
|
22
|
-
// One run holds a folder: a terrain refuses a folder another run serves.
|
|
23
|
-
import { createHash } from 'node:crypto';
|
|
24
|
-
import { chmod, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
25
|
-
import { createRequire } from 'node:module';
|
|
26
|
-
import { connect, createServer } from 'node:net';
|
|
27
|
-
import { homedir, tmpdir } from 'node:os';
|
|
28
|
-
import { dirname, join, resolve } from 'node:path';
|
|
29
|
-
import { pathToFileURL } from 'node:url';
|
|
30
|
-
import { Loader } from '../contract/index.js';
|
|
31
|
-
import { FolderCustody, FolderMemory } from '../folder/index.js';
|
|
32
|
-
import { rootLine } from '../harbor/index.js';
|
|
33
|
-
import { webGround } from '../http/index.js';
|
|
34
|
-
import { webPush } from '../line/index.js';
|
|
35
|
-
import { CryptoEntropy, HeldLoader, PointerTerrain } from '../pointer/index.js';
|
|
36
|
-
import { TCP_OPENING, tcpFaculty } from '../tcp/index.js';
|
|
37
|
-
export const NODE = 'node';
|
|
38
|
-
// Where a harbor of this user lives unless named: $NERVUR_DIR, then
|
|
39
|
-
// ~/.nervur.
|
|
40
|
-
export const harborDir = (env = process.env) => env.NERVUR_DIR ?? join(homedir(), '.nervur');
|
|
41
|
-
// A socket path has a hundred bytes or so on every system, so a folder too
|
|
42
|
-
// deep for one puts its socket in this user's temporary folder, under a
|
|
43
|
-
// name drawn from the folder's own path.
|
|
44
|
-
const SOCKET_PATH = 100;
|
|
45
|
-
export const socketOf = (dir) => {
|
|
46
|
-
const beside = join(resolve(dir), 'root.sock');
|
|
47
|
-
if (Buffer.byteLength(beside) <= SOCKET_PATH)
|
|
48
|
-
return beside;
|
|
49
|
-
return join(tmpdir(), `nervur-${createHash('sha256').update(resolve(dir)).digest('hex').slice(0, 32)}.sock`);
|
|
50
|
-
};
|
|
51
|
-
// A specifier that names a file rather than a package.
|
|
52
|
-
export const isFile = (from) => /^(\.{1,2}[\\/]|[\\/]|[A-Za-z]:[\\/])/.test(from) || /\.(m?[jt]s|c[jt]s)$/.test(from);
|
|
53
|
-
// Code from a file or an installed package: a module that exports
|
|
54
|
-
// `module`, `version` and `classes`, found again by where it was found, a
|
|
55
|
-
// file by its absolute path and a package by its name, resolved from each
|
|
56
|
-
// folder of `bases` in order. What is not there, or exports no module, is
|
|
57
|
-
// none. Code that is there and does not import throws Node's reason, so
|
|
58
|
-
// whoever added it learns why; an ES module read as CommonJS says which
|
|
59
|
-
// field its package.json lacks.
|
|
60
|
-
export class ImportLoader extends Loader {
|
|
61
|
-
#bases;
|
|
62
|
-
constructor(bases = [process.cwd()]) {
|
|
63
|
-
super();
|
|
64
|
-
this.#bases = bases;
|
|
65
|
-
}
|
|
66
|
-
async load(from) {
|
|
67
|
-
const found = isFile(from) ? resolve(from) : this.#package(from);
|
|
68
|
-
if (found === null)
|
|
69
|
-
return null;
|
|
70
|
-
let exported;
|
|
71
|
-
try {
|
|
72
|
-
exported = (await import(__rewriteRelativeImportExtension(pathToFileURL(found).href)));
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
const said = e.message;
|
|
76
|
-
// The name itself is nowhere, as against code there that needs
|
|
77
|
-
// something that is not.
|
|
78
|
-
if (e.code === 'ERR_MODULE_NOT_FOUND' && said.includes(`'${found}'`))
|
|
79
|
-
return null;
|
|
80
|
-
const commonjs = e instanceof SyntaxError && /\b(export|import)\b/.test(said);
|
|
81
|
-
throw new Error(`${found} did not load: ${said}${commonjs ? '; it is an ES module read as CommonJS, so set "type": "module" in its package.json' : ''}`, { cause: e });
|
|
82
|
-
}
|
|
83
|
-
const { module, version, classes } = exported;
|
|
84
|
-
if (typeof module !== 'string' || typeof version !== 'string' || !Array.isArray(classes))
|
|
85
|
-
return null;
|
|
86
|
-
return { module, version, classes, from: isFile(from) ? found : from };
|
|
87
|
-
}
|
|
88
|
-
#package(name) {
|
|
89
|
-
for (const base of this.#bases) {
|
|
90
|
-
try {
|
|
91
|
-
return createRequire(join(resolve(base), 'noop.js')).resolve(name);
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
// Not installed from here; the next base may hold it.
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// A module by its id, the name it declares, so the catalogue's cells name
|
|
101
|
-
// code the same way on every ground. `add` may name a module by its id, a
|
|
102
|
-
// file, or an installed package, and the ground works out which. The
|
|
103
|
-
// modules a harbor is handed are found by their id first. Where else an id
|
|
104
|
-
// is found, a file's path or a package's name, is this ground's own
|
|
105
|
-
// knowledge, kept beside the harbor in `<dir>/modules.json` and never in
|
|
106
|
-
// the sealed package, since another ground finds the same id in its own
|
|
107
|
-
// bundle. Packages resolve from where the command runs, then from the
|
|
108
|
-
// harbor's folder.
|
|
109
|
-
export class NodeLoader extends ImportLoader {
|
|
110
|
-
#held;
|
|
111
|
-
#map;
|
|
112
|
-
constructor(modules = [], dir) {
|
|
113
|
-
super(dir === undefined ? [process.cwd()] : [process.cwd(), dir]);
|
|
114
|
-
this.#held = new HeldLoader(modules);
|
|
115
|
-
this.#map = dir === undefined ? undefined : join(dir, MODULES);
|
|
116
|
-
}
|
|
117
|
-
async load(from) {
|
|
118
|
-
const held = await this.#held.load(from);
|
|
119
|
-
if (held)
|
|
120
|
-
return held;
|
|
121
|
-
const known = await this.#known();
|
|
122
|
-
const where = known[from];
|
|
123
|
-
if (where !== undefined) {
|
|
124
|
-
const loaded = await super.load(where);
|
|
125
|
-
return loaded?.module === from ? { ...loaded, from } : null;
|
|
126
|
-
}
|
|
127
|
-
const loaded = await super.load(from);
|
|
128
|
-
if (!loaded)
|
|
129
|
-
return null;
|
|
130
|
-
if (this.#map && known[loaded.module] !== loaded.from)
|
|
131
|
-
await this.#keep({ ...known, [loaded.module]: loaded.from });
|
|
132
|
-
return { ...loaded, from: loaded.module };
|
|
133
|
-
}
|
|
134
|
-
async #known() {
|
|
135
|
-
if (!this.#map)
|
|
136
|
-
return {};
|
|
137
|
-
try {
|
|
138
|
-
return JSON.parse(await readFile(this.#map, 'utf8'));
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
return {};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async #keep(files) {
|
|
145
|
-
await mkdir(dirname(this.#map), { recursive: true, mode: 0o700 });
|
|
146
|
-
await writeFile(`${this.#map}.new`, `${JSON.stringify(files, null, 2)}\n`, { mode: 0o600 });
|
|
147
|
-
await rename(`${this.#map}.new`, this.#map);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// Where a Node harbor's module ids find their files.
|
|
151
|
-
export const MODULES = 'modules.json';
|
|
152
|
-
// One root request over a served harbor's socket, or undefined where none
|
|
153
|
-
// is served.
|
|
154
|
-
export const askServed = (dir, request) => new Promise((done, fail) => {
|
|
155
|
-
const socket = connect(socketOf(dir));
|
|
156
|
-
let text = '';
|
|
157
|
-
socket.once('connect', () => socket.write(`${JSON.stringify(request)}\n`));
|
|
158
|
-
socket.on('data', (chunk) => {
|
|
159
|
-
text += chunk.toString('utf8');
|
|
160
|
-
const end = text.indexOf('\n');
|
|
161
|
-
if (end < 0)
|
|
162
|
-
return;
|
|
163
|
-
socket.end();
|
|
164
|
-
done(JSON.parse(text.slice(0, end)));
|
|
165
|
-
});
|
|
166
|
-
socket.once('error', (e) => (e.code === 'ENOENT' || e.code === 'ECONNREFUSED' ? done(undefined) : fail(e)));
|
|
167
|
-
});
|
|
168
|
-
export class NodeTerrain extends PointerTerrain {
|
|
169
|
-
dir;
|
|
170
|
-
serves;
|
|
171
|
-
#server;
|
|
172
|
-
constructor(parts) {
|
|
173
|
-
const entropy = new CryptoEntropy();
|
|
174
|
-
super({
|
|
175
|
-
entropy,
|
|
176
|
-
loader: new NodeLoader(parts.modules, parts.dir),
|
|
177
|
-
custody: new FolderCustody(parts.dir, entropy),
|
|
178
|
-
memory: new FolderMemory(parts.dir),
|
|
179
|
-
faculties: [tcpFaculty, webGround, webPush],
|
|
180
|
-
opens: [TCP_OPENING],
|
|
181
|
-
wakes: parts.wakes ?? true,
|
|
182
|
-
});
|
|
183
|
-
this.dir = parts.dir;
|
|
184
|
-
this.serves = parts.serves ?? true;
|
|
185
|
-
}
|
|
186
|
-
async claim() {
|
|
187
|
-
if ((await askServed(this.dir, {})) !== undefined)
|
|
188
|
-
throw new Error(`a harbor is already served from ${this.dir}`);
|
|
189
|
-
}
|
|
190
|
-
// The root line on the socket. A socket file nobody answers on is a
|
|
191
|
-
// stale one, and is replaced.
|
|
192
|
-
async stand(harbor) {
|
|
193
|
-
if (!this.serves)
|
|
194
|
-
return;
|
|
195
|
-
const root = socketOf(this.dir);
|
|
196
|
-
await rm(root, { force: true });
|
|
197
|
-
const server = createServer((socket) => {
|
|
198
|
-
let text = '';
|
|
199
|
-
socket.on('data', (chunk) => {
|
|
200
|
-
text += chunk.toString('utf8');
|
|
201
|
-
for (let end = text.indexOf('\n'); end >= 0; end = text.indexOf('\n')) {
|
|
202
|
-
const line = text.slice(0, end);
|
|
203
|
-
text = text.slice(end + 1);
|
|
204
|
-
let value;
|
|
205
|
-
try {
|
|
206
|
-
value = JSON.parse(line);
|
|
207
|
-
}
|
|
208
|
-
catch {
|
|
209
|
-
value = undefined;
|
|
210
|
-
}
|
|
211
|
-
void rootLine(harbor, value)
|
|
212
|
-
.catch(() => ({ error: 'the harbor threw' }))
|
|
213
|
-
.then((answer) => socket.write(`${JSON.stringify(answer)}\n`));
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
socket.on('error', () => socket.destroy());
|
|
217
|
-
});
|
|
218
|
-
await new Promise((done) => server.listen(root, done));
|
|
219
|
-
await chmod(root, 0o600);
|
|
220
|
-
this.#server = server;
|
|
221
|
-
}
|
|
222
|
-
async release() {
|
|
223
|
-
const server = this.#server;
|
|
224
|
-
if (!server)
|
|
225
|
-
return;
|
|
226
|
-
this.#server = undefined;
|
|
227
|
-
await new Promise((done) => server.close(done));
|
|
228
|
-
await rm(socketOf(this.dir), { force: true });
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
// Node, and the engines that answer as Node does.
|
|
232
|
-
export const nodeGround = {
|
|
233
|
-
name: NODE,
|
|
234
|
-
fits: () => typeof process !== 'undefined' && typeof process.versions?.node === 'string',
|
|
235
|
-
terrain: ({ modules, where }) => new NodeTerrain({ dir: where ?? harborDir(), ...(modules ? { modules } : {}) }),
|
|
236
|
-
};
|
package/dist/pointer/bodies.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// The pointer terrain's bodies: each contract fulfilled in one process,
|
|
3
|
-
// with nothing beyond JavaScript.
|
|
4
|
-
import { Clock, Custody, Entropy, Loader, Memory } from '../contract/index.js';
|
|
5
|
-
export class CryptoEntropy extends Entropy {
|
|
6
|
-
draw(length) {
|
|
7
|
-
return globalThis.crypto.getRandomValues(new Uint8Array(length));
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export class SystemClock extends Clock {
|
|
11
|
-
now() {
|
|
12
|
-
return Date.now();
|
|
13
|
-
}
|
|
14
|
-
wait(ms) {
|
|
15
|
-
let timer;
|
|
16
|
-
const done = new Promise((resolve) => (timer = setTimeout(resolve, ms)));
|
|
17
|
-
return { done, cancel: () => clearTimeout(timer) };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// The harbor's seed, drawn once and held by this object.
|
|
21
|
-
export class HeldCustody extends Custody {
|
|
22
|
-
#seed;
|
|
23
|
-
constructor(entropy) {
|
|
24
|
-
super();
|
|
25
|
-
this.#seed = entropy.draw(32);
|
|
26
|
-
}
|
|
27
|
-
seed() {
|
|
28
|
-
return Promise.resolve(this.#seed.slice());
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Modules handed to this object, found by the name each declares: the
|
|
32
|
-
// bundle a ground with no disk to load from carries, an edge's or a
|
|
33
|
-
// browser's. A path, a package or any other name is no module of it.
|
|
34
|
-
export class HeldLoader extends Loader {
|
|
35
|
-
#modules = new Map();
|
|
36
|
-
constructor(modules = []) {
|
|
37
|
-
super();
|
|
38
|
-
for (const m of modules)
|
|
39
|
-
this.#modules.set(m.module, m);
|
|
40
|
-
}
|
|
41
|
-
load(from) {
|
|
42
|
-
const m = this.#modules.get(from);
|
|
43
|
-
return Promise.resolve(m ? { module: m.module, version: m.version, classes: m.classes, from } : null);
|
|
44
|
-
}
|
|
45
|
-
missing(from) {
|
|
46
|
-
const carried = [...this.#modules.keys()];
|
|
47
|
-
return `${from} is no module this bundle carries${carried.length === 0 ? ', and it carries none' : `: it carries ${carried.join(', ')}`}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Entries that live as long as this object, copied in and out, which is
|
|
51
|
-
// what a restart in one process finds.
|
|
52
|
-
export class VolatileMemory extends Memory {
|
|
53
|
-
#places = new Map();
|
|
54
|
-
read(place) {
|
|
55
|
-
const entries = this.#places.get(place) ?? new Map();
|
|
56
|
-
return Promise.resolve(new Map([...entries].map(([name, bytes]) => [name, bytes.slice()])));
|
|
57
|
-
}
|
|
58
|
-
// One object holds it, so a keep is whole by the run of one turn.
|
|
59
|
-
write(place, entries) {
|
|
60
|
-
let kept = this.#places.get(place);
|
|
61
|
-
if (!kept)
|
|
62
|
-
this.#places.set(place, (kept = new Map()));
|
|
63
|
-
for (const [name, bytes] of entries) {
|
|
64
|
-
if (bytes === null)
|
|
65
|
-
kept.delete(name);
|
|
66
|
-
else
|
|
67
|
-
kept.set(name, bytes.slice());
|
|
68
|
-
}
|
|
69
|
-
if (kept.size === 0)
|
|
70
|
-
this.#places.delete(place);
|
|
71
|
-
return Promise.resolve();
|
|
72
|
-
}
|
|
73
|
-
places() {
|
|
74
|
-
return Promise.resolve([...this.#places.keys()]);
|
|
75
|
-
}
|
|
76
|
-
forget(place) {
|
|
77
|
-
this.#places.delete(place);
|
|
78
|
-
return Promise.resolve();
|
|
79
|
-
}
|
|
80
|
-
}
|
package/dist/pointer/index.d.ts
DELETED
package/dist/proof/index.d.ts
DELETED
package/dist/proof/law.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Being, Faculty, type Asker, type JsonObject } from '../being/index.ts';
|
|
2
|
-
import { Memory, type Custody, type Module } from '../contract/index.ts';
|
|
3
|
-
import { Store, type Harbor } from '../harbor/index.ts';
|
|
4
|
-
import { World } from '../pointer/index.ts';
|
|
5
|
-
import type { Expect } from './expect.ts';
|
|
6
|
-
export type Bodies = {
|
|
7
|
-
custody: Custody;
|
|
8
|
-
memory: Memory;
|
|
9
|
-
};
|
|
10
|
-
export type Terrain = {
|
|
11
|
-
name: string;
|
|
12
|
-
make(): Bodies;
|
|
13
|
-
again(bodies: Bodies): Bodies;
|
|
14
|
-
};
|
|
15
|
-
declare abstract class Echoes extends Faculty {
|
|
16
|
-
static kind: string;
|
|
17
|
-
}
|
|
18
|
-
declare class Echo extends Echoes {
|
|
19
|
-
static kind: string;
|
|
20
|
-
static asks: {
|
|
21
|
-
echo: {};
|
|
22
|
-
};
|
|
23
|
-
echo(args: JsonObject, asker: Asker): JsonObject;
|
|
24
|
-
}
|
|
25
|
-
declare class Shop extends Being {
|
|
26
|
-
static kind: string;
|
|
27
|
-
static cells: {
|
|
28
|
-
sold: string[];
|
|
29
|
-
};
|
|
30
|
-
static asks: {
|
|
31
|
-
buy: {};
|
|
32
|
-
};
|
|
33
|
-
buy(args: JsonObject, asker: Asker): JsonObject;
|
|
34
|
-
}
|
|
35
|
-
declare class Customer extends Being {
|
|
36
|
-
static kind: string;
|
|
37
|
-
static asks: {
|
|
38
|
-
join: {};
|
|
39
|
-
buy: {};
|
|
40
|
-
echo: {};
|
|
41
|
-
spoil: {};
|
|
42
|
-
};
|
|
43
|
-
spoil(): JsonObject;
|
|
44
|
-
join(args: JsonObject): Promise<JsonObject>;
|
|
45
|
-
buy(args: JsonObject): Promise<JsonObject>;
|
|
46
|
-
echo(args: JsonObject): Promise<JsonObject>;
|
|
47
|
-
}
|
|
48
|
-
declare class Profile extends Being {
|
|
49
|
-
static kind: string;
|
|
50
|
-
static cells: {
|
|
51
|
-
name: string;
|
|
52
|
-
age: number;
|
|
53
|
-
};
|
|
54
|
-
static asks: {
|
|
55
|
-
set: {};
|
|
56
|
-
get: {};
|
|
57
|
-
};
|
|
58
|
-
set(args: JsonObject): JsonObject;
|
|
59
|
-
get(): JsonObject;
|
|
60
|
-
}
|
|
61
|
-
declare class Shelf extends Store {
|
|
62
|
-
#private;
|
|
63
|
-
static kind: string;
|
|
64
|
-
static shelf(key: string): Watched;
|
|
65
|
-
static reset(): void;
|
|
66
|
-
read(place: string): Promise<Map<string, Uint8Array>>;
|
|
67
|
-
write(place: string, entries: ReadonlyMap<string, Uint8Array | null>): Promise<void>;
|
|
68
|
-
places(): Promise<string[]>;
|
|
69
|
-
forget(place: string): Promise<void>;
|
|
70
|
-
}
|
|
71
|
-
export declare const classes: (typeof Echo | typeof Shop | typeof Customer | typeof Profile | typeof Shelf)[];
|
|
72
|
-
export declare const law: Module;
|
|
73
|
-
export declare const standOne: (world: World, name: string, parts?: Partial<Bodies>) => Promise<Harbor>;
|
|
74
|
-
declare class Watched extends Memory {
|
|
75
|
-
readonly inner: Memory;
|
|
76
|
-
readonly seen: {
|
|
77
|
-
place: string;
|
|
78
|
-
name: string;
|
|
79
|
-
bytes: Uint8Array | null;
|
|
80
|
-
}[];
|
|
81
|
-
refuse: (place: string) => boolean;
|
|
82
|
-
constructor(inner: Memory);
|
|
83
|
-
read(place: string): Promise<Map<string, Uint8Array>>;
|
|
84
|
-
write(place: string, entries: ReadonlyMap<string, Uint8Array | null>): Promise<void>;
|
|
85
|
-
places(): Promise<string[]>;
|
|
86
|
-
forget(place: string): Promise<void>;
|
|
87
|
-
}
|
|
88
|
-
export declare const lawScenes: (t: Terrain, expect: Expect) => [string, () => Promise<void>][];
|
|
89
|
-
export declare const keeperScenes: (t: Terrain, expect: Expect) => [string, () => Promise<void>][];
|
|
90
|
-
export {};
|