nervur 0.19.2 → 0.20.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 (205) hide show
  1. package/README.md +66 -101
  2. package/dist/being/being.d.ts +7 -15
  3. package/dist/being/being.js +16 -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 +9 -0
  7. package/dist/being/faculty.js +68 -0
  8. package/dist/being/index.d.ts +4 -5
  9. package/dist/being/index.js +5 -5
  10. package/dist/being/types.d.ts +35 -62
  11. package/dist/being/types.js +3 -57
  12. package/dist/being/words.d.ts +13 -0
  13. package/dist/being/words.js +14 -0
  14. package/dist/contract/index.d.ts +26 -0
  15. package/dist/contract/index.js +19 -0
  16. package/dist/crypto/aes.d.ts +3 -0
  17. package/dist/crypto/aes.js +24 -0
  18. package/dist/crypto/bytes.d.ts +6 -0
  19. package/dist/crypto/bytes.js +33 -0
  20. package/dist/crypto/ed25519.d.ts +3 -0
  21. package/dist/crypto/ed25519.js +85 -0
  22. package/dist/crypto/hash.d.ts +2 -0
  23. package/dist/crypto/hash.js +11 -0
  24. package/dist/crypto/index.d.ts +7 -0
  25. package/dist/crypto/index.js +10 -0
  26. package/dist/crypto/json.d.ts +8 -0
  27. package/dist/crypto/json.js +250 -0
  28. package/dist/crypto/mlkem.d.ts +12 -0
  29. package/dist/crypto/mlkem.js +36 -0
  30. package/dist/crypto/subtle.d.ts +10 -0
  31. package/dist/crypto/subtle.js +29 -0
  32. package/dist/crypto/x25519.d.ts +2 -0
  33. package/dist/crypto/x25519.js +21 -0
  34. package/dist/folder/index.d.ts +13 -0
  35. package/dist/folder/index.js +125 -0
  36. package/dist/harbor/dock.d.ts +19 -0
  37. package/dist/harbor/dock.js +92 -0
  38. package/dist/harbor/harbor.d.ts +22 -0
  39. package/dist/harbor/harbor.js +84 -0
  40. package/dist/harbor/index.d.ts +4 -10
  41. package/dist/harbor/index.js +5 -18
  42. package/dist/harbor/registry.d.ts +7 -0
  43. package/dist/harbor/registry.js +13 -0
  44. package/dist/harbor/terrain.d.ts +8 -0
  45. package/dist/harbor/terrain.js +2 -0
  46. package/dist/index.d.ts +7 -0
  47. package/dist/index.js +14 -0
  48. package/dist/pointer/bodies.d.ts +20 -0
  49. package/dist/pointer/bodies.js +45 -0
  50. package/dist/pointer/index.d.ts +2 -0
  51. package/dist/pointer/index.js +4 -0
  52. package/dist/pointer/world.d.ts +34 -0
  53. package/dist/pointer/world.js +76 -0
  54. package/dist/quo/door.d.ts +34 -0
  55. package/dist/quo/door.js +172 -0
  56. package/dist/quo/index.d.ts +8 -0
  57. package/dist/quo/index.js +11 -0
  58. package/dist/quo/invitation.d.ts +7 -0
  59. package/dist/quo/invitation.js +15 -0
  60. package/dist/quo/keys.d.ts +40 -0
  61. package/dist/quo/keys.js +79 -0
  62. package/dist/quo/payload.d.ts +15 -0
  63. package/dist/quo/payload.js +55 -0
  64. package/dist/quo/relations.d.ts +40 -0
  65. package/dist/quo/relations.js +33 -0
  66. package/dist/quo/reply.d.ts +13 -0
  67. package/dist/quo/reply.js +35 -0
  68. package/dist/quo/seal.d.ts +42 -0
  69. package/dist/quo/seal.js +78 -0
  70. package/dist/quo/standing.d.ts +39 -0
  71. package/dist/quo/standing.js +90 -0
  72. package/dist/ward/allowance.d.ts +13 -9
  73. package/dist/ward/allowance.js +28 -67
  74. package/dist/ward/cells.d.ts +6 -6
  75. package/dist/ward/cells.js +67 -179
  76. package/dist/ward/index.d.ts +5 -10
  77. package/dist/ward/index.js +6 -13
  78. package/dist/ward/partition.d.ts +44 -60
  79. package/dist/ward/partition.js +56 -285
  80. package/dist/ward/stance.d.ts +29 -20
  81. package/dist/ward/stance.js +173 -406
  82. package/dist/ward/ward-being.d.ts +33 -0
  83. package/dist/ward/ward-being.js +76 -0
  84. package/dist/ward/ward.d.ts +43 -11
  85. package/dist/ward/ward.js +215 -363
  86. package/package.json +19 -33
  87. package/src/being/being.ts +31 -78
  88. package/src/being/digest.ts +7 -35
  89. package/src/being/faculty.ts +66 -0
  90. package/src/being/index.ts +5 -6
  91. package/src/being/types.ts +47 -145
  92. package/src/being/words.ts +31 -0
  93. package/src/contract/index.ts +44 -0
  94. package/src/crypto/aes.ts +26 -0
  95. package/src/crypto/bytes.ts +37 -0
  96. package/src/crypto/ed25519.ts +84 -0
  97. package/src/crypto/hash.ts +14 -0
  98. package/src/crypto/index.ts +10 -0
  99. package/src/crypto/json.ts +241 -0
  100. package/src/crypto/mlkem.ts +38 -0
  101. package/src/crypto/subtle.ts +33 -0
  102. package/src/crypto/x25519.ts +21 -0
  103. package/src/folder/index.ts +134 -0
  104. package/src/harbor/dock.ts +101 -0
  105. package/src/harbor/harbor.ts +105 -0
  106. package/src/harbor/index.ts +5 -19
  107. package/src/harbor/registry.ts +20 -0
  108. package/src/harbor/terrain.ts +13 -0
  109. package/src/index.ts +20 -0
  110. package/src/pointer/bodies.ts +47 -0
  111. package/src/pointer/index.ts +4 -0
  112. package/src/pointer/world.ts +91 -0
  113. package/src/quo/door.ts +178 -0
  114. package/src/quo/index.ts +11 -0
  115. package/src/quo/invitation.ts +15 -0
  116. package/src/quo/keys.ts +91 -0
  117. package/src/quo/payload.ts +61 -0
  118. package/src/quo/relations.ts +62 -0
  119. package/src/quo/reply.ts +38 -0
  120. package/src/quo/seal.ts +101 -0
  121. package/src/quo/standing.ts +111 -0
  122. package/src/stand/main.ts +19 -0
  123. package/src/stand/stand.ts +178 -0
  124. package/src/ward/allowance.ts +37 -75
  125. package/src/ward/cells.ts +63 -176
  126. package/src/ward/index.ts +6 -17
  127. package/src/ward/partition.ts +86 -326
  128. package/src/ward/stance.ts +185 -420
  129. package/src/ward/ward-being.ts +97 -0
  130. package/src/ward/ward.ts +229 -363
  131. package/dist/being/lent.d.ts +0 -32
  132. package/dist/being/lent.js +0 -72
  133. package/dist/being/silence.d.ts +0 -12
  134. package/dist/being/silence.js +0 -41
  135. package/dist/conformance/assert.d.ts +0 -11
  136. package/dist/conformance/assert.js +0 -106
  137. package/dist/conformance/beings.d.ts +0 -199
  138. package/dist/conformance/beings.js +0 -188
  139. package/dist/conformance/estate.d.ts +0 -5
  140. package/dist/conformance/estate.js +0 -388
  141. package/dist/conformance/index.d.ts +0 -80
  142. package/dist/conformance/index.js +0 -819
  143. package/dist/conformance/reach.d.ts +0 -10
  144. package/dist/conformance/reach.js +0 -72
  145. package/dist/conformance/store.d.ts +0 -5
  146. package/dist/conformance/store.js +0 -113
  147. package/dist/harbor/box.d.ts +0 -121
  148. package/dist/harbor/box.js +0 -121
  149. package/dist/harbor/core.d.ts +0 -55
  150. package/dist/harbor/core.js +0 -662
  151. package/dist/harbor/dial.d.ts +0 -9
  152. package/dist/harbor/dial.js +0 -81
  153. package/dist/harbor/memory.d.ts +0 -29
  154. package/dist/harbor/memory.js +0 -104
  155. package/dist/harbor/reach.d.ts +0 -36
  156. package/dist/harbor/reach.js +0 -199
  157. package/dist/harbor/store.d.ts +0 -35
  158. package/dist/harbor/store.js +0 -62
  159. package/dist/vector/cases.d.ts +0 -42
  160. package/dist/vector/cases.js +0 -223
  161. package/dist/vector/index.d.ts +0 -6
  162. package/dist/vector/index.js +0 -8
  163. package/dist/vector/stand.d.ts +0 -9
  164. package/dist/vector/stand.js +0 -77
  165. package/dist/vector/world.d.ts +0 -144
  166. package/dist/vector/world.js +0 -209
  167. package/dist/ward/arithmetic.d.ts +0 -31
  168. package/dist/ward/arithmetic.js +0 -249
  169. package/dist/ward/door.d.ts +0 -18
  170. package/dist/ward/door.js +0 -186
  171. package/dist/ward/ground.d.ts +0 -29
  172. package/dist/ward/ground.js +0 -56
  173. package/dist/ward/heirs.d.ts +0 -13
  174. package/dist/ward/heirs.js +0 -117
  175. package/dist/ward/json.d.ts +0 -2
  176. package/dist/ward/json.js +0 -163
  177. package/dist/ward/owner.d.ts +0 -13
  178. package/dist/ward/owner.js +0 -220
  179. package/dist/ward/seal.d.ts +0 -52
  180. package/dist/ward/seal.js +0 -150
  181. package/src/being/lent.ts +0 -72
  182. package/src/being/silence.ts +0 -46
  183. package/src/conformance/assert.ts +0 -100
  184. package/src/conformance/beings.ts +0 -188
  185. package/src/conformance/estate.ts +0 -412
  186. package/src/conformance/index.ts +0 -965
  187. package/src/conformance/reach.ts +0 -83
  188. package/src/conformance/store.ts +0 -125
  189. package/src/harbor/box.ts +0 -131
  190. package/src/harbor/core.ts +0 -699
  191. package/src/harbor/dial.ts +0 -112
  192. package/src/harbor/memory.ts +0 -123
  193. package/src/harbor/reach.ts +0 -221
  194. package/src/harbor/store.ts +0 -91
  195. package/src/vector/cases.ts +0 -257
  196. package/src/vector/index.ts +0 -11
  197. package/src/vector/stand.ts +0 -76
  198. package/src/vector/world.ts +0 -232
  199. package/src/ward/arithmetic.ts +0 -251
  200. package/src/ward/door.ts +0 -186
  201. package/src/ward/ground.ts +0 -142
  202. package/src/ward/heirs.ts +0 -116
  203. package/src/ward/json.ts +0 -144
  204. package/src/ward/owner.ts +0 -214
  205. package/src/ward/seal.ts +0 -178
@@ -0,0 +1,76 @@
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, 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
+ const text = (v) => typeof v === 'string';
14
+ const object = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
15
+ export class WardBeing extends Being {
16
+ static asks = {
17
+ boot: ownerAsk('a new being of this ward', { required: ['key', 'class'] }),
18
+ unboot: ownerAsk('a being out, with every relation she holds', { required: ['being'] }),
19
+ public: ownerAsk('the being a stranger reaches, or none', { required: ['key'] }),
20
+ invite: ownerAsk('an invitation on a being of this ward', { required: ['being', 'id'] }),
21
+ ask: ownerAsk('a being of this ward, asked as the owner; with no being, the public being asked as nobody'),
22
+ own: rootAsk('an invitation for an owner of this ward, under an id', { required: ['id'] }),
23
+ disown: rootAsk('an owner no more', { required: ['id'] }),
24
+ };
25
+ steward;
26
+ constructor(stance) {
27
+ super(stance);
28
+ this.steward = stance.steward;
29
+ }
30
+ describe(asker) {
31
+ const { asks } = super.describe(asker);
32
+ return { asks, notes: pilots(asker, this.notes(asker)) ? { pk: this.steward.pk(), beings: this.steward.beings() } : {} };
33
+ }
34
+ async own(args) {
35
+ if (!text(args.id))
36
+ return { error: 'id is text' };
37
+ return (await this.stance.occupants.invite(args.id, { owner: true })) ?? { error: 'id taken' };
38
+ }
39
+ disown(args) {
40
+ if (!text(args.id) || this.stance.occupants.notes(args.id)?.owner !== true)
41
+ return { error: 'no such owner' };
42
+ this.stance.occupants.remove(args.id);
43
+ return { disowned: args.id };
44
+ }
45
+ async boot(args) {
46
+ if (!text(args.key) || !text(args.class))
47
+ return { error: 'key and class are text' };
48
+ const out = await this.steward.boot(args.key, args.class);
49
+ return out === 'booted' ? { booted: args.key } : { error: out };
50
+ }
51
+ unboot(args) {
52
+ return text(args.being) && this.steward.unboot(args.being) ? { unbooted: args.being } : { error: 'no such being' };
53
+ }
54
+ public(args) {
55
+ if (args.key !== null && !text(args.key))
56
+ return { error: 'key is text or null' };
57
+ return this.steward.publish(args.key) ? { public: args.key } : { error: 'no such being' };
58
+ }
59
+ async invite(args) {
60
+ if (!text(args.being) || !text(args.id) || (args.notes !== undefined && !object(args.notes)))
61
+ return { error: 'being and id are text, notes an object' };
62
+ const invitation = await this.steward.invite(args.being, args.id, args.notes ?? {});
63
+ return invitation ?? { error: 'not invited' };
64
+ }
65
+ async ask(args) {
66
+ if ((args.being !== undefined && !text(args.being)) || (args.method !== undefined && !text(args.method)) || (args.args !== undefined && !object(args.args))) {
67
+ return { error: 'being and method are text, args an object' };
68
+ }
69
+ const out = await this.steward.ask(args.being ?? null, args.method, args.args ?? {});
70
+ if (isSilence(out))
71
+ return { error: 'silence' };
72
+ if (isWord(out))
73
+ return { error: told(out) };
74
+ return { answer: out };
75
+ }
76
+ }
@@ -1,12 +1,44 @@
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 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(name: 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
+ root(method?: string, args?: JsonObject): Promise<Answer>;
37
+ get zero(): boolean;
38
+ answer(heir: string | null, p: Payload): Promise<Choice>;
39
+ send(pk: string, bytes: Uint8Array): Promise<Uint8Array | null>;
40
+ offer(contract: string): Promise<Invitation | null>;
41
+ retract(contract: string, heir: string): Promise<void>;
42
+ live(key: string, row: BeingRow): boolean;
43
+ boot(maker: string, className: string, key: string, id?: string): Promise<string | null>;
44
+ }