nervur 0.23.0 → 0.24.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.
Files changed (157) hide show
  1. package/CONTRIBUTING.md +13 -0
  2. package/LICENSE +55 -202
  3. package/NOTICE +3 -8
  4. package/README.md +14 -156
  5. package/RELEASING.md +15 -0
  6. package/SECURITY.md +9 -0
  7. package/bin/nervur.js +6 -0
  8. package/package.json +26 -81
  9. package/AUTHORING.md +0 -935
  10. package/COMMAND.md +0 -179
  11. package/FACES.md +0 -280
  12. package/FACULTIES.md +0 -578
  13. package/GROUNDS.md +0 -315
  14. package/KIT-SPEC.md +0 -304
  15. package/WORLD.md +0 -195
  16. package/dist/app/app-ground.d.ts +0 -18
  17. package/dist/app/app-ground.js +0 -23
  18. package/dist/app/index.d.ts +0 -2
  19. package/dist/app/index.js +0 -5
  20. package/dist/app/native.d.ts +0 -11
  21. package/dist/app/native.js +0 -13
  22. package/dist/being/being.d.ts +0 -306
  23. package/dist/being/being.js +0 -20
  24. package/dist/being/covers.d.ts +0 -9
  25. package/dist/being/covers.js +0 -21
  26. package/dist/being/index.d.ts +0 -4
  27. package/dist/being/index.js +0 -6
  28. package/dist/being/need.d.ts +0 -49
  29. package/dist/being/need.js +0 -33
  30. package/dist/being/schema.d.ts +0 -100
  31. package/dist/being/schema.js +0 -132
  32. package/dist/being/table.d.ts +0 -48
  33. package/dist/being/table.js +0 -344
  34. package/dist/bench/bench-ground.d.ts +0 -73
  35. package/dist/bench/bench-ground.js +0 -153
  36. package/dist/bench/bench.d.ts +0 -101
  37. package/dist/bench/bench.js +0 -368
  38. package/dist/bench/fake-clock.d.ts +0 -17
  39. package/dist/bench/fake-clock.js +0 -34
  40. package/dist/bench/fake-memory.d.ts +0 -16
  41. package/dist/bench/fake-memory.js +0 -46
  42. package/dist/bench/fake-network.d.ts +0 -66
  43. package/dist/bench/fake-network.js +0 -222
  44. package/dist/bench/fake-unlock.d.ts +0 -6
  45. package/dist/bench/fake-unlock.js +0 -10
  46. package/dist/bench/index.d.ts +0 -3
  47. package/dist/bench/index.js +0 -5
  48. package/dist/bench/seeded.d.ts +0 -11
  49. package/dist/bench/seeded.js +0 -37
  50. package/dist/bench/settle.d.ts +0 -2
  51. package/dist/bench/settle.js +0 -49
  52. package/dist/bench/stewards.d.ts +0 -169
  53. package/dist/bench/stewards.js +0 -128
  54. package/dist/bodies/class-list.d.ts +0 -14
  55. package/dist/bodies/class-list.js +0 -33
  56. package/dist/bodies/joined-carry.d.ts +0 -29
  57. package/dist/bodies/joined-carry.js +0 -48
  58. package/dist/bodies/kept.d.ts +0 -44
  59. package/dist/bodies/kept.js +0 -91
  60. package/dist/bodies/noble-crypto.d.ts +0 -22
  61. package/dist/bodies/noble-crypto.js +0 -88
  62. package/dist/bodies/seed-keys.d.ts +0 -10
  63. package/dist/bodies/seed-keys.js +0 -42
  64. package/dist/bodies/strict-tools.d.ts +0 -10
  65. package/dist/bodies/strict-tools.js +0 -306
  66. package/dist/bodies/vouch.d.ts +0 -20
  67. package/dist/bodies/vouch.js +0 -71
  68. package/dist/bodies/web-carry.d.ts +0 -72
  69. package/dist/bodies/web-carry.js +0 -245
  70. package/dist/bodies/web-clock.d.ts +0 -12
  71. package/dist/bodies/web-clock.js +0 -33
  72. package/dist/browser/browser-ground.d.ts +0 -76
  73. package/dist/browser/browser-ground.js +0 -294
  74. package/dist/browser/index.d.ts +0 -4
  75. package/dist/browser/index.js +0 -7
  76. package/dist/browser/indexeddb-memory.d.ts +0 -17
  77. package/dist/browser/indexeddb-memory.js +0 -97
  78. package/dist/browser/locked-unlock.d.ts +0 -24
  79. package/dist/browser/locked-unlock.js +0 -85
  80. package/dist/browser/origin-classes.d.ts +0 -7
  81. package/dist/browser/origin-classes.js +0 -31
  82. package/dist/edge/durable-clock.d.ts +0 -19
  83. package/dist/edge/durable-clock.js +0 -61
  84. package/dist/edge/durable-memory.d.ts +0 -5
  85. package/dist/edge/durable-memory.js +0 -11
  86. package/dist/edge/durable.d.ts +0 -18
  87. package/dist/edge/durable.js +0 -24
  88. package/dist/edge/edge-ground.d.ts +0 -49
  89. package/dist/edge/edge-ground.js +0 -223
  90. package/dist/edge/index.d.ts +0 -7
  91. package/dist/edge/index.js +0 -9
  92. package/dist/edge/native-crypto.d.ts +0 -8
  93. package/dist/edge/native-crypto.js +0 -102
  94. package/dist/edge/secret-unlock.d.ts +0 -7
  95. package/dist/edge/secret-unlock.js +0 -13
  96. package/dist/edge/socket-carry.d.ts +0 -39
  97. package/dist/edge/socket-carry.js +0 -111
  98. package/dist/foundation.d.ts +0 -162
  99. package/dist/foundation.js +0 -4
  100. package/dist/ground/dock.d.ts +0 -1460
  101. package/dist/ground/dock.js +0 -1159
  102. package/dist/ground/ground.d.ts +0 -239
  103. package/dist/ground/ground.js +0 -787
  104. package/dist/ground/views.d.ts +0 -76
  105. package/dist/ground/views.js +0 -208
  106. package/dist/house/crossing.d.ts +0 -50
  107. package/dist/house/crossing.js +0 -153
  108. package/dist/house/house.d.ts +0 -88
  109. package/dist/house/house.js +0 -2069
  110. package/dist/house/rows-shape.d.ts +0 -110
  111. package/dist/house/rows-shape.js +0 -12
  112. package/dist/house/rows.d.ts +0 -27
  113. package/dist/house/rows.js +0 -185
  114. package/dist/index.d.ts +0 -33
  115. package/dist/index.js +0 -29
  116. package/dist/node/bridge.d.ts +0 -20
  117. package/dist/node/bridge.js +0 -284
  118. package/dist/node/cli.d.ts +0 -2
  119. package/dist/node/cli.js +0 -225
  120. package/dist/node/file-memory.d.ts +0 -13
  121. package/dist/node/file-memory.js +0 -86
  122. package/dist/node/folder-classes.d.ts +0 -5
  123. package/dist/node/folder-classes.js +0 -40
  124. package/dist/node/gone.d.ts +0 -2
  125. package/dist/node/gone.js +0 -7
  126. package/dist/node/hand.d.ts +0 -39
  127. package/dist/node/hand.js +0 -107
  128. package/dist/node/http.d.ts +0 -11
  129. package/dist/node/http.js +0 -90
  130. package/dist/node/index.d.ts +0 -11
  131. package/dist/node/index.js +0 -13
  132. package/dist/node/ledger-memory.d.ts +0 -17
  133. package/dist/node/ledger-memory.js +0 -152
  134. package/dist/node/lock.d.ts +0 -10
  135. package/dist/node/lock.js +0 -78
  136. package/dist/node/node-ground.d.ts +0 -26
  137. package/dist/node/node-ground.js +0 -228
  138. package/dist/node/notify.d.ts +0 -1
  139. package/dist/node/notify.js +0 -18
  140. package/dist/node/shell.d.ts +0 -11
  141. package/dist/node/shell.js +0 -35
  142. package/dist/node/sync-folder.d.ts +0 -6
  143. package/dist/node/sync-folder.js +0 -18
  144. package/dist/node/tcp-carry.d.ts +0 -42
  145. package/dist/node/tcp-carry.js +0 -193
  146. package/dist/node/unlock.d.ts +0 -17
  147. package/dist/node/unlock.js +0 -86
  148. package/dist/node/websocket.d.ts +0 -12
  149. package/dist/node/websocket.js +0 -134
  150. package/dist/quo/frame.d.ts +0 -33
  151. package/dist/quo/frame.js +0 -92
  152. package/dist/quo/index.d.ts +0 -1
  153. package/dist/quo/index.js +0 -5
  154. package/dist/quo/room.d.ts +0 -154
  155. package/dist/quo/room.js +0 -362
  156. package/dist/serve/index.d.ts +0 -45
  157. package/dist/serve/index.js +0 -71
@@ -1,12 +0,0 @@
1
- import type { Socket } from 'node:net';
2
- import type { Held, HeldSocket } from '../bodies/web-carry.ts';
3
- /** The `Sec-WebSocket-Accept` for a client's key. */
4
- export declare const acceptOf: (key: string) => string;
5
- /**
6
- * A socket past its handshake, held as frames. Every `ping` milliseconds it
7
- * pings, so a router between keeps the line, and a line silent across two
8
- * pings is closed, so its dialer dials again rather than wait on the dead.
9
- */
10
- export declare const hold: (socket: Socket, open: (held: HeldSocket) => Held, longest: number, { ping }?: {
11
- ping?: number;
12
- }) => void;
@@ -1,134 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // The server's side of a WebSocket, as RFC 6455 writes it: the handshake's
3
- // answer, and messages framed on the socket. A client masks every frame;
4
- // the server masks none. A message past `longest` closes the connection.
5
- import { createHash } from 'node:crypto';
6
- const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
7
- const TEXT = 1;
8
- const BINARY = 2;
9
- const CLOSE = 8;
10
- const PING = 9;
11
- const PONG = 10;
12
- /** The `Sec-WebSocket-Accept` for a client's key. */
13
- export const acceptOf = (key) => createHash('sha1').update(`${key}${GUID}`).digest('base64');
14
- const header = (opcode, length) => {
15
- if (length < 126)
16
- return Buffer.from([0x80 | opcode, length]);
17
- if (length < 65_536) {
18
- const out = Buffer.alloc(4);
19
- out[0] = 0x80 | opcode;
20
- out[1] = 126;
21
- out.writeUInt16BE(length, 2);
22
- return out;
23
- }
24
- const out = Buffer.alloc(10);
25
- out[0] = 0x80 | opcode;
26
- out[1] = 127;
27
- out.writeBigUInt64BE(BigInt(length), 2);
28
- return out;
29
- };
30
- /**
31
- * A socket past its handshake, held as frames. Every `ping` milliseconds it
32
- * pings, so a router between keeps the line, and a line silent across two
33
- * pings is closed, so its dialer dials again rather than wait on the dead.
34
- */
35
- export const hold = (socket, open, longest, { ping = 25_000 } = {}) => {
36
- let closed = false;
37
- let quiet = 0;
38
- const write = (opcode, payload) => {
39
- if (closed)
40
- return;
41
- socket.write(Buffer.concat([header(opcode, payload.length), payload]));
42
- };
43
- const beat = setInterval(() => {
44
- if (++quiet > 2)
45
- return end();
46
- write(PING, new Uint8Array());
47
- }, ping);
48
- beat.unref();
49
- const end = () => {
50
- clearInterval(beat);
51
- if (closed)
52
- return;
53
- write(CLOSE, new Uint8Array());
54
- closed = true;
55
- socket.end();
56
- };
57
- const held = open({ send: (data) => write(BINARY, data), close: end });
58
- let buffered = Buffer.alloc(0);
59
- let parts = [];
60
- let partsKind = 0;
61
- let partsLength = 0;
62
- socket.on('data', (chunk) => {
63
- // Anything heard, a pong among it, says the line stands.
64
- quiet = 0;
65
- buffered = Buffer.concat([buffered, chunk]);
66
- while (buffered.length >= 2) {
67
- const fin = (buffered[0] & 0x80) !== 0;
68
- const opcode = buffered[0] & 0x0f;
69
- const masked = (buffered[1] & 0x80) !== 0;
70
- let length = buffered[1] & 0x7f;
71
- let at = 2;
72
- if (length === 126) {
73
- if (buffered.length < 4)
74
- return;
75
- length = buffered.readUInt16BE(2);
76
- at = 4;
77
- }
78
- else if (length === 127) {
79
- if (buffered.length < 10)
80
- return;
81
- const long = buffered.readBigUInt64BE(2);
82
- if (long > BigInt(longest))
83
- return end();
84
- length = Number(long);
85
- at = 10;
86
- }
87
- // Every frame from a client is masked, and a message past the longest is none of ours.
88
- if (!masked || length > longest)
89
- return end();
90
- if (buffered.length < at + 4 + length)
91
- return;
92
- const mask = buffered.subarray(at, at + 4);
93
- const payload = Buffer.from(buffered.subarray(at + 4, at + 4 + length));
94
- for (let index = 0; index < payload.length; index++)
95
- payload[index] ^= mask[index % 4];
96
- buffered = buffered.subarray(at + 4 + length);
97
- if (opcode === CLOSE)
98
- return end();
99
- if (opcode === PING) {
100
- write(PONG, payload);
101
- continue;
102
- }
103
- if (opcode === PONG)
104
- continue;
105
- if (opcode !== 0) {
106
- partsKind = opcode;
107
- parts = [];
108
- partsLength = 0;
109
- }
110
- parts.push(payload);
111
- partsLength += payload.length;
112
- if (partsLength > longest)
113
- return end();
114
- if (!fin)
115
- continue;
116
- const message = Buffer.concat(parts);
117
- parts = [];
118
- partsLength = 0;
119
- // An always-on ground holds no wake, so what a message asks is answered in its own time.
120
- if (partsKind === TEXT)
121
- void held.message(message.toString('utf8'));
122
- else if (partsKind === BINARY)
123
- void held.message(new Uint8Array(message));
124
- else
125
- return end();
126
- }
127
- });
128
- socket.on('close', () => {
129
- clearInterval(beat);
130
- closed = true;
131
- held.close();
132
- });
133
- socket.on('error', () => socket.destroy());
134
- };
@@ -1,33 +0,0 @@
1
- export declare const ASK = 0;
2
- export declare const REPLY = 1;
3
- export declare const NOTHING = 2;
4
- /** The longest frame body. */
5
- export declare const LARGEST = 1048645;
6
- /** A ward pk, in bytes. */
7
- export declare const PK = 64;
8
- export interface Frame {
9
- readonly kind: number;
10
- readonly id: number;
11
- readonly rest: Uint8Array;
12
- }
13
- /** A frame's body. */
14
- export declare const body: (kind: number, id: number, rest: Uint8Array) => Uint8Array<ArrayBuffer>;
15
- /** A frame read from its body, or `null` where the body is no frame and its connection closes. */
16
- export declare const read: (bytes: Uint8Array) => Frame | null;
17
- /** A frame as a stream carries it: its body's length in four bytes, then the body. */
18
- export declare const framed: (kind: number, id: number, rest: Uint8Array) => Uint8Array<ArrayBuffer>;
19
- /** Frames read off a stream, as its chunks arrive. */
20
- export declare class Frames {
21
- #private;
22
- /** Each whole frame in order; `false` where the stream sent something that is no frame, and closes. */
23
- take(chunk: Uint8Array, each: (frame: Frame) => void): boolean;
24
- }
25
- /** A `tcp://host:port` address read, or `null` where it is none of the TCP carrier's. */
26
- export declare const parseAddress: (address: string) => {
27
- host: string;
28
- port: number;
29
- } | null;
30
- /** Whether an IP address is loopback, private, shared, link-local or unspecified. */
31
- export declare const privateAddress: (ip: string) => boolean;
32
- /** Whether a host, as a URL writes it, is one a carry dials only where its ground allows. */
33
- export declare const privateHost: (host: string) => boolean;
package/dist/quo/frame.js DELETED
@@ -1,92 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // A frame's body, as quo/CARRIER-TCP.md writes it: kind, id and rest. Over
3
- // TCP a length goes in front; on a held line the message is the body.
4
- // And which hosts a carry refuses to dial unless its ground allows it.
5
- export const ASK = 0;
6
- export const REPLY = 1;
7
- export const NOTHING = 2;
8
- /** The longest frame body. */
9
- export const LARGEST = 1_048_645;
10
- /** A ward pk, in bytes. */
11
- export const PK = 64;
12
- /** A frame's body. */
13
- export const body = (kind, id, rest) => {
14
- const out = new Uint8Array(5 + rest.length);
15
- out[0] = kind;
16
- new DataView(out.buffer).setUint32(1, id >>> 0);
17
- out.set(rest, 5);
18
- return out;
19
- };
20
- /** A frame read from its body, or `null` where the body is no frame and its connection closes. */
21
- export const read = (bytes) => {
22
- if (bytes.length < 5 || bytes.length > LARGEST)
23
- return null;
24
- const kind = bytes[0];
25
- const rest = bytes.slice(5);
26
- if (kind > NOTHING || (kind === ASK && rest.length < PK) || (kind === NOTHING && rest.length > 0))
27
- return null;
28
- return { kind, id: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(1), rest };
29
- };
30
- /** A frame as a stream carries it: its body's length in four bytes, then the body. */
31
- export const framed = (kind, id, rest) => {
32
- const inner = body(kind, id, rest);
33
- const out = new Uint8Array(4 + inner.length);
34
- new DataView(out.buffer).setUint32(0, inner.length);
35
- out.set(inner, 4);
36
- return out;
37
- };
38
- /** Frames read off a stream, as its chunks arrive. */
39
- export class Frames {
40
- #held = new Uint8Array(0);
41
- /** Each whole frame in order; `false` where the stream sent something that is no frame, and closes. */
42
- take(chunk, each) {
43
- const joined = new Uint8Array(this.#held.length + chunk.length);
44
- joined.set(this.#held);
45
- joined.set(chunk, this.#held.length);
46
- let at = 0;
47
- while (joined.length - at >= 4) {
48
- const length = new DataView(joined.buffer, at, 4).getUint32(0);
49
- if (length < 5 || length > LARGEST)
50
- return false;
51
- if (joined.length - at < 4 + length)
52
- break;
53
- const frame = read(joined.subarray(at + 4, at + 4 + length));
54
- if (frame === null)
55
- return false;
56
- at += 4 + length;
57
- each(frame);
58
- }
59
- this.#held = joined.slice(at);
60
- return true;
61
- }
62
- }
63
- /** A `tcp://host:port` address read, or `null` where it is none of the TCP carrier's. */
64
- export const parseAddress = (address) => {
65
- const found = /^tcp:\/\/(\[[0-9a-fA-F:.]+\]|[^/?#@:[\]]+):([0-9]{1,5})$/i.exec(address);
66
- if (found === null)
67
- return null;
68
- const port = Number(found[2]);
69
- if (port < 1 || port > 65_535)
70
- return null;
71
- const host = found[1].startsWith('[') ? found[1].slice(1, -1) : found[1];
72
- return { host, port };
73
- };
74
- const IPV4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
75
- /** Whether an IP address is loopback, private, shared, link-local or unspecified. */
76
- export const privateAddress = (ip) => {
77
- const four = IPV4.exec(ip);
78
- if (four !== null) {
79
- const [a, b] = [Number(four[1]), Number(four[2])];
80
- return a === 0 || a === 10 || a === 127 || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 100 && b >= 64 && b <= 127);
81
- }
82
- const lower = ip.toLowerCase();
83
- if (lower.startsWith('::ffff:'))
84
- return privateAddress(lower.slice(7));
85
- return lower === '::' || lower === '::1' || /^f[cd]/.test(lower) || /^fe[89ab]/.test(lower);
86
- };
87
- /** Whether a host, as a URL writes it, is one a carry dials only where its ground allows. */
88
- export const privateHost = (host) => {
89
- const bare = host.startsWith('[') ? host.slice(1, -1) : host;
90
- const lower = bare.toLowerCase();
91
- return lower === 'localhost' || lower.endsWith('.localhost') || privateAddress(lower);
92
- };
@@ -1 +0,0 @@
1
- export { Room, type Admitted, type Choice, type Occupant, type Standing } from './room.ts';
package/dist/quo/index.js DELETED
@@ -1,5 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // The room's one index: the ward's code, reached by the house through here
3
- // alone. The framing the carriers share stands beside it, and is no part
4
- // of the room.
5
- export { Room } from './room.js';
@@ -1,154 +0,0 @@
1
- import type { Crypto, Keys, Tools } from '../foundation.ts';
2
- /** The invitation of the spec, read. */
3
- export interface Invitation {
4
- readonly ward: string;
5
- readonly heir: string;
6
- readonly secret: string;
7
- readonly lock: string;
8
- readonly at?: readonly string[];
9
- }
10
- /** The door's end of a relation, by its heir. */
11
- export interface Occupant {
12
- readonly heir: string;
13
- /** A door has made a choice on it. */
14
- readonly spent: boolean;
15
- /** The door stopped holding it while it was spent, and keeps its keys. */
16
- readonly removed: boolean;
17
- readonly held: string | null;
18
- readonly vouched: string | null;
19
- readonly open: string | null;
20
- readonly offered: string | null;
21
- /** The highest number honoured; the door honours none below it. */
22
- readonly highest: number;
23
- }
24
- /** The standing's end of a relation. */
25
- export interface Standing {
26
- readonly invitation: Invitation;
27
- /** The secret it signs with. */
28
- readonly key: string;
29
- /** The edge key it sends under; `null` before its knock. */
30
- readonly edge: string | null;
31
- /** Its knock, kept to send again until the door is known to have bound it. */
32
- readonly knock: string | null;
33
- readonly bound: boolean;
34
- /** Whether its knock may have reached the door. Until it may have, the knock alone is sent again. */
35
- readonly heard: boolean;
36
- /** Whether the last box it sealed was its knock again. */
37
- readonly knockedLast: boolean;
38
- readonly sent: number;
39
- readonly moved: number;
40
- }
41
- /** One ask in flight, kept by its sender until its reply is read. */
42
- export interface Pending {
43
- readonly seq: number;
44
- readonly lid: string;
45
- readonly announced: string | null;
46
- readonly under: string;
47
- readonly knock: boolean;
48
- }
49
- /** What a standing read. */
50
- export type Read = {
51
- readonly object: unknown;
52
- readonly text: string;
53
- readonly seen: string | null;
54
- readonly at?: readonly string[];
55
- } | {
56
- readonly silence: true;
57
- } | {
58
- readonly quo: 'removed' | 'unannounced' | 'repeated';
59
- } | {
60
- readonly nothing: true;
61
- };
62
- /** What the door chooses. `object` is JSON text, written into the reply as it stands, and `at` where the ward is reached now. */
63
- export type Choice = {
64
- readonly object: string;
65
- readonly seen: string | null;
66
- readonly at?: readonly string[];
67
- } | {
68
- readonly silence: true;
69
- };
70
- /** An ask the door admitted, waiting for its choice. */
71
- export interface Admitted {
72
- readonly refused: false;
73
- /** `null` for the zero head. */
74
- readonly heir: string | null;
75
- readonly by: string;
76
- readonly seq: number;
77
- readonly method: string | undefined;
78
- /** The text of `args` as it arrived, `{}` where absent. */
79
- readonly args: string;
80
- /** Two keys of one name somewhere inside `args`. */
81
- readonly strange: boolean;
82
- /** The call id beside the method, a field Quo gives no meaning. */
83
- readonly call: string | undefined;
84
- /** The milliseconds its chain still has, a field Quo gives no meaning. */
85
- readonly within: number | undefined;
86
- /** The digest of the answer a watch holds, a field Quo gives no meaning. */
87
- readonly after: string | undefined;
88
- /** The ask's signature as hex, which names a box on the zero head. */
89
- readonly signature: string;
90
- /** The reply to the choice, and the occupant moved; `null` on the zero head. */
91
- choose(choice: Choice): Promise<{
92
- readonly reply: Uint8Array;
93
- readonly occupant: Occupant | null;
94
- }>;
95
- }
96
- /** A refusal: the reply, and nothing moves. `why` is the case, for the kit's own eyes. */
97
- export interface Refusal {
98
- readonly refused: true;
99
- readonly reply: Uint8Array;
100
- readonly why: number;
101
- }
102
- export type Arrival = Admitted | Refusal;
103
- /** How the door finds an occupant, and whether anything answers the zero head. */
104
- export interface Lookup {
105
- occupant(heir: string): Promise<Occupant | undefined> | Occupant | undefined;
106
- readonly zero: boolean;
107
- }
108
- export declare class Room {
109
- #private;
110
- constructor(keys: Keys, crypto: Crypto, tools: Tools);
111
- /** The ward's name: its signing pk, then its padlock, as 128 hex. */
112
- ward(): Promise<string>;
113
- /** A new heir: the invitation to give away, and the occupant to keep. */
114
- invite(at?: readonly string[]): Promise<{
115
- invitation: Invitation;
116
- occupant: Occupant;
117
- }>;
118
- /** The occupant after the door stops holding it: gone while fresh, its keys kept while spent. */
119
- release(occupant: Occupant): Occupant | null;
120
- /** A value read as an invitation, or `null` where it is none. */
121
- invitation(value: unknown): Promise<Invitation | null>;
122
- /** A standing on an invitation, before its knock. */
123
- standing(invitation: Invitation): Standing;
124
- /** A box at the door: refused with its reply, or admitted and waiting for a choice. */
125
- arrive(box: Uint8Array, lookup: Lookup): Promise<Arrival>;
126
- /** The next box on a relation: its knock, its knock again, or an ask. */
127
- seal(standing: Standing, ask: {
128
- method?: string;
129
- args?: string;
130
- call?: string;
131
- within?: number;
132
- after?: string;
133
- }): Promise<{
134
- box: Uint8Array;
135
- pending: Pending;
136
- standing: Standing;
137
- }>;
138
- /** A reply read, and the standing moved where an object came back above every ask it moved on. */
139
- /** `heard` says whether a box that brought nothing may have reached the door; a reply was heard. */
140
- read(given: Standing, pending: Pending, reply: Uint8Array | null, heard?: boolean): Promise<{
141
- read: Read;
142
- standing: Standing;
143
- }>;
144
- /** An ask on the zero head of a ward, signed by `secret`, which the door keeps nothing of. */
145
- stranger(ward: string, secret: string, ask: {
146
- method?: string;
147
- args?: string;
148
- }): Promise<{
149
- box: Uint8Array;
150
- lid: string;
151
- }>;
152
- /** A stranger's reply read. */
153
- strangerRead(ward: string, lid: string, reply: Uint8Array | null): Promise<Read>;
154
- }