nervur 0.19.2 → 0.20.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.
Files changed (235) hide show
  1. package/README.md +156 -104
  2. package/dist/being/being.d.ts +8 -15
  3. package/dist/being/being.js +20 -67
  4. package/dist/being/digest.d.ts +1 -1
  5. package/dist/being/digest.js +7 -27
  6. package/dist/being/faculty.d.ts +10 -0
  7. package/dist/being/faculty.js +74 -0
  8. package/dist/being/index.d.ts +5 -5
  9. package/dist/being/index.js +6 -5
  10. package/dist/being/kind.d.ts +4 -0
  11. package/dist/being/kind.js +28 -0
  12. package/dist/being/types.d.ts +35 -63
  13. package/dist/being/types.js +3 -57
  14. package/dist/being/words.d.ts +13 -0
  15. package/dist/being/words.js +14 -0
  16. package/dist/cli/command.d.ts +13 -0
  17. package/dist/cli/command.js +194 -0
  18. package/dist/cli/harbor.d.ts +21 -0
  19. package/dist/cli/harbor.js +141 -0
  20. package/dist/cli/main.d.ts +2 -0
  21. package/dist/cli/main.js +14 -0
  22. package/dist/contract/index.d.ts +39 -0
  23. package/dist/contract/index.js +33 -0
  24. package/dist/crypto/aes.d.ts +3 -0
  25. package/dist/crypto/aes.js +24 -0
  26. package/dist/crypto/bytes.d.ts +6 -0
  27. package/dist/crypto/bytes.js +33 -0
  28. package/dist/crypto/ed25519.d.ts +3 -0
  29. package/dist/crypto/ed25519.js +85 -0
  30. package/dist/crypto/hash.d.ts +2 -0
  31. package/dist/crypto/hash.js +11 -0
  32. package/dist/crypto/index.d.ts +7 -0
  33. package/dist/crypto/index.js +10 -0
  34. package/dist/crypto/json.d.ts +8 -0
  35. package/dist/crypto/json.js +250 -0
  36. package/dist/crypto/mlkem.d.ts +12 -0
  37. package/dist/crypto/mlkem.js +36 -0
  38. package/dist/crypto/subtle.d.ts +10 -0
  39. package/dist/crypto/subtle.js +29 -0
  40. package/dist/crypto/x25519.d.ts +2 -0
  41. package/dist/crypto/x25519.js +21 -0
  42. package/dist/folder/index.d.ts +14 -0
  43. package/dist/folder/index.js +87 -0
  44. package/dist/harbor/catalogue.d.ts +25 -0
  45. package/dist/harbor/catalogue.js +93 -0
  46. package/dist/harbor/dock.d.ts +29 -0
  47. package/dist/harbor/dock.js +122 -0
  48. package/dist/harbor/harbor.d.ts +31 -0
  49. package/dist/harbor/harbor.js +146 -0
  50. package/dist/harbor/index.d.ts +7 -10
  51. package/dist/harbor/index.js +9 -18
  52. package/dist/harbor/package.d.ts +10 -0
  53. package/dist/harbor/package.js +115 -0
  54. package/dist/harbor/registry.d.ts +9 -0
  55. package/dist/harbor/registry.js +78 -0
  56. package/dist/harbor/root-line.d.ts +9 -0
  57. package/dist/harbor/root-line.js +36 -0
  58. package/dist/harbor/terrain.d.ts +9 -0
  59. package/dist/harbor/terrain.js +2 -0
  60. package/dist/index.d.ts +7 -0
  61. package/dist/index.js +14 -0
  62. package/dist/pointer/bodies.d.ts +26 -0
  63. package/dist/pointer/bodies.js +64 -0
  64. package/dist/pointer/index.d.ts +2 -0
  65. package/dist/pointer/index.js +4 -0
  66. package/dist/pointer/world.d.ts +35 -0
  67. package/dist/pointer/world.js +85 -0
  68. package/dist/quo/door.d.ts +34 -0
  69. package/dist/quo/door.js +172 -0
  70. package/dist/quo/index.d.ts +8 -0
  71. package/dist/quo/index.js +11 -0
  72. package/dist/quo/invitation.d.ts +7 -0
  73. package/dist/quo/invitation.js +15 -0
  74. package/dist/quo/keys.d.ts +40 -0
  75. package/dist/quo/keys.js +79 -0
  76. package/dist/quo/payload.d.ts +15 -0
  77. package/dist/quo/payload.js +55 -0
  78. package/dist/quo/relations.d.ts +40 -0
  79. package/dist/quo/relations.js +33 -0
  80. package/dist/quo/reply.d.ts +13 -0
  81. package/dist/quo/reply.js +35 -0
  82. package/dist/quo/seal.d.ts +42 -0
  83. package/dist/quo/seal.js +78 -0
  84. package/dist/quo/standing.d.ts +39 -0
  85. package/dist/quo/standing.js +90 -0
  86. package/dist/tcp/frame.d.ts +29 -0
  87. package/dist/tcp/frame.js +74 -0
  88. package/dist/tcp/index.d.ts +18 -0
  89. package/dist/tcp/index.js +164 -0
  90. package/dist/ward/allowance.d.ts +13 -9
  91. package/dist/ward/allowance.js +28 -67
  92. package/dist/ward/cells.d.ts +6 -6
  93. package/dist/ward/cells.js +67 -179
  94. package/dist/ward/index.d.ts +6 -10
  95. package/dist/ward/index.js +7 -13
  96. package/dist/ward/partition.d.ts +44 -60
  97. package/dist/ward/partition.js +56 -285
  98. package/dist/ward/pilot.d.ts +8 -0
  99. package/dist/ward/pilot.js +50 -0
  100. package/dist/ward/stance.d.ts +27 -20
  101. package/dist/ward/stance.js +174 -406
  102. package/dist/ward/ward-being.d.ts +35 -0
  103. package/dist/ward/ward-being.js +82 -0
  104. package/dist/ward/ward.d.ts +45 -11
  105. package/dist/ward/ward.js +239 -357
  106. package/package.json +24 -31
  107. package/src/being/being.ts +35 -78
  108. package/src/being/digest.ts +7 -35
  109. package/src/being/faculty.ts +73 -0
  110. package/src/being/index.ts +6 -6
  111. package/src/being/kind.ts +30 -0
  112. package/src/being/types.ts +50 -146
  113. package/src/being/words.ts +31 -0
  114. package/src/cli/command.ts +188 -0
  115. package/src/cli/harbor.ts +137 -0
  116. package/src/cli/main.ts +13 -0
  117. package/src/contract/index.ts +73 -0
  118. package/src/crypto/aes.ts +26 -0
  119. package/src/crypto/bytes.ts +37 -0
  120. package/src/crypto/ed25519.ts +84 -0
  121. package/src/crypto/hash.ts +14 -0
  122. package/src/crypto/index.ts +10 -0
  123. package/src/crypto/json.ts +241 -0
  124. package/src/crypto/mlkem.ts +38 -0
  125. package/src/crypto/subtle.ts +33 -0
  126. package/src/crypto/x25519.ts +21 -0
  127. package/src/folder/index.ts +92 -0
  128. package/src/harbor/catalogue.ts +110 -0
  129. package/src/harbor/dock.ts +137 -0
  130. package/src/harbor/harbor.ts +180 -0
  131. package/src/harbor/index.ts +9 -19
  132. package/src/harbor/package.ts +131 -0
  133. package/src/harbor/registry.ts +73 -0
  134. package/src/harbor/root-line.ts +36 -0
  135. package/src/harbor/terrain.ts +15 -0
  136. package/src/index.ts +20 -0
  137. package/src/pointer/bodies.ts +65 -0
  138. package/src/pointer/index.ts +4 -0
  139. package/src/pointer/world.ts +94 -0
  140. package/src/quo/door.ts +178 -0
  141. package/src/quo/index.ts +11 -0
  142. package/src/quo/invitation.ts +15 -0
  143. package/src/quo/keys.ts +91 -0
  144. package/src/quo/payload.ts +61 -0
  145. package/src/quo/relations.ts +62 -0
  146. package/src/quo/reply.ts +38 -0
  147. package/src/quo/seal.ts +101 -0
  148. package/src/quo/standing.ts +111 -0
  149. package/src/stand/main.ts +20 -0
  150. package/src/stand/stand.ts +220 -0
  151. package/src/tcp/frame.ts +78 -0
  152. package/src/tcp/index.ts +173 -0
  153. package/src/ward/allowance.ts +37 -75
  154. package/src/ward/cells.ts +63 -176
  155. package/src/ward/index.ts +7 -17
  156. package/src/ward/partition.ts +86 -326
  157. package/src/ward/pilot.ts +50 -0
  158. package/src/ward/stance.ts +186 -420
  159. package/src/ward/ward-being.ts +103 -0
  160. package/src/ward/ward.ts +256 -359
  161. package/dist/being/lent.d.ts +0 -32
  162. package/dist/being/lent.js +0 -72
  163. package/dist/being/silence.d.ts +0 -12
  164. package/dist/being/silence.js +0 -41
  165. package/dist/conformance/assert.d.ts +0 -11
  166. package/dist/conformance/assert.js +0 -106
  167. package/dist/conformance/beings.d.ts +0 -199
  168. package/dist/conformance/beings.js +0 -188
  169. package/dist/conformance/estate.d.ts +0 -5
  170. package/dist/conformance/estate.js +0 -388
  171. package/dist/conformance/index.d.ts +0 -80
  172. package/dist/conformance/index.js +0 -819
  173. package/dist/conformance/reach.d.ts +0 -10
  174. package/dist/conformance/reach.js +0 -72
  175. package/dist/conformance/store.d.ts +0 -5
  176. package/dist/conformance/store.js +0 -113
  177. package/dist/harbor/box.d.ts +0 -121
  178. package/dist/harbor/box.js +0 -121
  179. package/dist/harbor/core.d.ts +0 -55
  180. package/dist/harbor/core.js +0 -662
  181. package/dist/harbor/dial.d.ts +0 -9
  182. package/dist/harbor/dial.js +0 -81
  183. package/dist/harbor/memory.d.ts +0 -29
  184. package/dist/harbor/memory.js +0 -104
  185. package/dist/harbor/reach.d.ts +0 -36
  186. package/dist/harbor/reach.js +0 -199
  187. package/dist/harbor/store.d.ts +0 -35
  188. package/dist/harbor/store.js +0 -62
  189. package/dist/vector/cases.d.ts +0 -42
  190. package/dist/vector/cases.js +0 -223
  191. package/dist/vector/index.d.ts +0 -6
  192. package/dist/vector/index.js +0 -8
  193. package/dist/vector/stand.d.ts +0 -9
  194. package/dist/vector/stand.js +0 -77
  195. package/dist/vector/world.d.ts +0 -144
  196. package/dist/vector/world.js +0 -209
  197. package/dist/ward/arithmetic.d.ts +0 -31
  198. package/dist/ward/arithmetic.js +0 -249
  199. package/dist/ward/door.d.ts +0 -18
  200. package/dist/ward/door.js +0 -186
  201. package/dist/ward/ground.d.ts +0 -29
  202. package/dist/ward/ground.js +0 -56
  203. package/dist/ward/heirs.d.ts +0 -13
  204. package/dist/ward/heirs.js +0 -117
  205. package/dist/ward/json.d.ts +0 -2
  206. package/dist/ward/json.js +0 -163
  207. package/dist/ward/owner.d.ts +0 -13
  208. package/dist/ward/owner.js +0 -220
  209. package/dist/ward/seal.d.ts +0 -52
  210. package/dist/ward/seal.js +0 -150
  211. package/src/being/lent.ts +0 -72
  212. package/src/being/silence.ts +0 -46
  213. package/src/conformance/assert.ts +0 -100
  214. package/src/conformance/beings.ts +0 -188
  215. package/src/conformance/estate.ts +0 -412
  216. package/src/conformance/index.ts +0 -965
  217. package/src/conformance/reach.ts +0 -83
  218. package/src/conformance/store.ts +0 -125
  219. package/src/harbor/box.ts +0 -131
  220. package/src/harbor/core.ts +0 -699
  221. package/src/harbor/dial.ts +0 -112
  222. package/src/harbor/memory.ts +0 -123
  223. package/src/harbor/reach.ts +0 -221
  224. package/src/harbor/store.ts +0 -91
  225. package/src/vector/cases.ts +0 -257
  226. package/src/vector/index.ts +0 -11
  227. package/src/vector/stand.ts +0 -76
  228. package/src/vector/world.ts +0 -232
  229. package/src/ward/arithmetic.ts +0 -251
  230. package/src/ward/door.ts +0 -186
  231. package/src/ward/ground.ts +0 -142
  232. package/src/ward/heirs.ts +0 -116
  233. package/src/ward/json.ts +0 -144
  234. package/src/ward/owner.ts +0 -214
  235. package/src/ward/seal.ts +0 -178
@@ -0,0 +1,82 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // The ward-being: the first being of every ward, the ward itself. Her asks
3
+ // are the root's, shown and answered to `OWNER` alone.
4
+ import { Being, isSilence, isWord, KIT, OWNER, told } from '../being/index.js';
5
+ // Whoever pilots a ward: the root, holding its unsealed ask, or an owner,
6
+ // an occupant of the ward-being the root invited as one.
7
+ export const pilots = (asker, notes) => asker.id === OWNER || notes?.owner === true;
8
+ // An ask whoever pilots the ward may make.
9
+ export const ownerAsk = (description, input = {}) => ({ description, input: { type: 'object', ...input }, for: pilots });
10
+ // An ask the root alone may make, so a carried key pilots but never hands
11
+ // piloting on.
12
+ const rootAsk = (description, input = {}) => ({ description, input: { type: 'object', ...input }, for: (asker) => asker.id === OWNER });
13
+ // The one kit kind the root boots: every other kit class stands where the
14
+ // kit puts it.
15
+ export const PILOT = 'org.nervur.pilot';
16
+ const text = (v) => typeof v === 'string';
17
+ const object = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
18
+ export class WardBeing extends Being {
19
+ static kind = 'org.nervur.ward-being';
20
+ static asks = {
21
+ boot: ownerAsk('a new being of this ward', { required: ['key', 'class'] }),
22
+ unboot: ownerAsk('a being out, with every relation she holds', { required: ['being'] }),
23
+ public: ownerAsk('the being a stranger reaches, or none', { required: ['key'] }),
24
+ invite: ownerAsk('an invitation on a being of this ward', { required: ['being', 'id'] }),
25
+ ask: ownerAsk('a being of this ward, asked as the owner; with no being, the public being asked as nobody'),
26
+ own: rootAsk('an invitation for an owner of this ward, under an id', { required: ['id'] }),
27
+ disown: rootAsk('an owner no more', { required: ['id'] }),
28
+ };
29
+ steward;
30
+ constructor(stance) {
31
+ super(stance);
32
+ this.steward = stance.steward;
33
+ }
34
+ describe(asker) {
35
+ const { asks } = super.describe(asker);
36
+ return { asks, notes: pilots(asker, this.notes(asker)) ? { pk: this.steward.pk(), beings: this.steward.beings() } : {} };
37
+ }
38
+ async own(args) {
39
+ if (!text(args.id))
40
+ return { error: 'id is text' };
41
+ return (await this.stance.occupants.invite(args.id, { owner: true })) ?? { error: 'id taken' };
42
+ }
43
+ disown(args) {
44
+ if (!text(args.id) || this.stance.occupants.notes(args.id)?.owner !== true)
45
+ return { error: 'no such owner' };
46
+ this.stance.occupants.remove(args.id);
47
+ return { disowned: args.id };
48
+ }
49
+ async boot(args) {
50
+ if (!text(args.key) || !text(args.class))
51
+ return { error: 'key and class are text' };
52
+ if (args.class.startsWith(KIT) && args.class !== PILOT)
53
+ return { error: 'no such class' };
54
+ const out = await this.steward.boot(args.key, args.class);
55
+ return out === 'booted' ? { booted: args.key } : { error: out };
56
+ }
57
+ unboot(args) {
58
+ return text(args.being) && this.steward.unboot(args.being) ? { unbooted: args.being } : { error: 'no such being' };
59
+ }
60
+ public(args) {
61
+ if (args.key !== null && !text(args.key))
62
+ return { error: 'key is text or null' };
63
+ return this.steward.publish(args.key) ? { public: args.key } : { error: 'no such being' };
64
+ }
65
+ async invite(args) {
66
+ if (!text(args.being) || !text(args.id) || (args.notes !== undefined && !object(args.notes)))
67
+ return { error: 'being and id are text, notes an object' };
68
+ const invitation = await this.steward.invite(args.being, args.id, args.notes ?? {});
69
+ return invitation ?? { error: 'not invited' };
70
+ }
71
+ async ask(args) {
72
+ if ((args.being !== undefined && !text(args.being)) || (args.method !== undefined && !text(args.method)) || (args.args !== undefined && !object(args.args))) {
73
+ return { error: 'being and method are text, args an object' };
74
+ }
75
+ const out = await this.steward.ask(args.being ?? null, args.method, args.args ?? {});
76
+ if (isSilence(out))
77
+ return { error: 'silence' };
78
+ if (isWord(out))
79
+ return { error: told(out) };
80
+ return { answer: out };
81
+ }
82
+ }
@@ -1,12 +1,46 @@
1
- import type { Cells, Stance } from '../being/types.ts';
2
- import { type Ground, type WardPointers } from './ground.ts';
3
- import { type Bind } from './partition.ts';
4
- import { type Door } from './door.ts';
5
- export type Resident = Door & {
6
- bind: Bind;
7
- stance: Stance;
8
- cells: Cells & {
9
- class?: string;
10
- };
1
+ import { Door, WardKey, type Behind, type Choice, type Invitation, type Payload } from '../quo/index.ts';
2
+ import type { Carrier, Clock, Entropy, Rows } from '../contract/index.ts';
3
+ import { type Answer, type BeingClass, type BeingLike, type JsonObject } from '../being/index.ts';
4
+ import { Partition, type BeingRow } from './partition.ts';
5
+ import { type Inside } from './stance.ts';
6
+ import { WardBeing, type WardBeingStance } from './ward-being.ts';
7
+ export interface Catalogue {
8
+ classOf(kind: string): BeingClass | undefined;
9
+ }
10
+ export type WardParts = {
11
+ readonly seed: Uint8Array | string;
12
+ readonly memory: Rows;
13
+ readonly catalogue: Catalogue;
14
+ readonly entropy: Entropy;
15
+ readonly clock: Clock;
16
+ readonly carrier: Carrier;
17
+ readonly root?: (stance: WardBeingStance) => WardBeing;
18
+ readonly dock?: Invitation;
11
19
  };
12
- export declare function Ward(ground: Ground): Promise<WardPointers>;
20
+ export declare const DOCK = "dock";
21
+ export interface Lender {
22
+ offer(contract: string): Promise<Invitation | null>;
23
+ withdraw(contract: string, heir: string): Promise<void>;
24
+ }
25
+ export declare class Ward implements Behind, Inside {
26
+ #private;
27
+ readonly key: WardKey;
28
+ readonly partition: Partition;
29
+ readonly door: Door;
30
+ readonly clock: Clock;
31
+ private constructor();
32
+ static unpack(parts: WardParts): Promise<Ward>;
33
+ get pk(): string;
34
+ get draw(): import("../quo/keys.ts").Draw;
35
+ get wardBeing(): WardBeing;
36
+ being(key: string): BeingLike | undefined;
37
+ bearAnew(): void;
38
+ root(method?: string, args?: JsonObject): Promise<Answer>;
39
+ get zero(): boolean;
40
+ answer(heir: string | null, p: Payload): Promise<Choice>;
41
+ send(pk: string, bytes: Uint8Array): Promise<Uint8Array | null>;
42
+ offer(contract: string): Promise<Invitation | null>;
43
+ retract(contract: string, heir: string): Promise<void>;
44
+ live(key: string, row: BeingRow): boolean;
45
+ boot(maker: string, className: string, key: string, id?: string): Promise<string | null>;
46
+ }