@nervur-org/dock 0.5.0 → 0.6.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 (216) hide show
  1. package/README.md +7 -4
  2. package/api/route.ts +4 -72
  3. package/beings/avatar.ts +11 -7
  4. package/beings/carry.ts +129 -116
  5. package/beings/clock.ts +11 -7
  6. package/beings/desk.ts +7 -6
  7. package/beings/doorbell.ts +36 -7
  8. package/beings/index.ts +17 -4
  9. package/beings/join.ts +7 -4
  10. package/beings/link.ts +1 -1
  11. package/beings/porter.ts +5 -1
  12. package/beings/presence.ts +15 -5
  13. package/beings/setup.ts +27 -21
  14. package/beings/user.ts +26 -17
  15. package/beings/way.ts +1 -1
  16. package/{dock → box}/agents.ts +37 -44
  17. package/{dock → box}/apns.ts +4 -4
  18. package/box/box.ts +31 -0
  19. package/box/contract.ts +41 -0
  20. package/box/dialers.ts +88 -0
  21. package/box/dock.ts +148 -0
  22. package/box/envoy.ts +96 -0
  23. package/box/faculty.ts +111 -0
  24. package/{dock → box}/fcm.ts +1 -1
  25. package/box/grants.ts +90 -0
  26. package/box/http.ts +93 -0
  27. package/{dock → box}/http2.ts +7 -7
  28. package/box/index.ts +201 -0
  29. package/box/join.ts +78 -0
  30. package/box/local.ts +37 -0
  31. package/{dock → box}/location.ts +15 -3
  32. package/{dock → box}/notifications.ts +17 -5
  33. package/box/push.ts +85 -0
  34. package/box/ring.ts +85 -0
  35. package/{dock → box}/service.ts +2 -2
  36. package/box/timer.ts +150 -0
  37. package/box/tree.ts +22 -0
  38. package/{dock → box}/webpush.ts +2 -2
  39. package/cli/client.ts +1 -1
  40. package/cli/daemon.ts +101 -103
  41. package/cli/estate.ts +2 -3
  42. package/cli/nervur.ts +44 -25
  43. package/cli/stand.ts +1 -1
  44. package/dist/api/route.d.ts +1 -2
  45. package/dist/api/route.js +4 -76
  46. package/dist/beings/avatar.d.ts +4 -3
  47. package/dist/beings/avatar.js +9 -6
  48. package/dist/beings/carry.d.ts +10 -12
  49. package/dist/beings/carry.js +119 -127
  50. package/dist/beings/clock.js +10 -7
  51. package/dist/beings/desk.js +8 -7
  52. package/dist/beings/doorbell.d.ts +3 -1
  53. package/dist/beings/doorbell.js +37 -4
  54. package/dist/beings/index.d.ts +24 -4
  55. package/dist/beings/index.js +15 -4
  56. package/dist/beings/join.d.ts +1 -0
  57. package/dist/beings/join.js +6 -4
  58. package/dist/beings/link.d.ts +0 -1
  59. package/dist/beings/link.js +1 -1
  60. package/dist/beings/porter.js +5 -1
  61. package/dist/beings/presence.d.ts +1 -0
  62. package/dist/beings/presence.js +12 -3
  63. package/dist/beings/setup.d.ts +5 -2
  64. package/dist/beings/setup.js +16 -15
  65. package/dist/beings/user.d.ts +4 -3
  66. package/dist/beings/user.js +18 -11
  67. package/dist/{dock → box}/agents.d.ts +7 -4
  68. package/dist/{dock → box}/agents.js +30 -37
  69. package/dist/{dock → box}/apns.d.ts +1 -1
  70. package/dist/{dock → box}/apns.js +3 -3
  71. package/dist/box/box.d.ts +9 -0
  72. package/dist/box/box.js +18 -0
  73. package/dist/box/contract.d.ts +6 -0
  74. package/dist/box/contract.js +35 -0
  75. package/dist/{dock → box}/dialers.d.ts +7 -4
  76. package/dist/box/dialers.js +76 -0
  77. package/dist/box/dock.d.ts +182 -0
  78. package/dist/box/dock.js +128 -0
  79. package/dist/box/envoy.d.ts +44 -0
  80. package/dist/box/envoy.js +75 -0
  81. package/dist/box/faculty.d.ts +68 -0
  82. package/dist/box/faculty.js +97 -0
  83. package/dist/{dock → box}/fcm.d.ts +1 -1
  84. package/dist/{dock → box}/grants.d.ts +4 -3
  85. package/dist/box/grants.js +78 -0
  86. package/dist/box/http.d.ts +26 -0
  87. package/dist/box/http.js +89 -0
  88. package/dist/{dock → box}/http2.d.ts +1 -1
  89. package/dist/{dock → box}/http2.js +6 -6
  90. package/dist/box/index.d.ts +46 -0
  91. package/dist/box/index.js +179 -0
  92. package/dist/box/join.d.ts +19 -0
  93. package/dist/box/join.js +67 -0
  94. package/dist/{dock → box}/local.d.ts +3 -2
  95. package/dist/box/local.js +27 -0
  96. package/dist/{dock → box}/location.d.ts +3 -0
  97. package/dist/box/location.js +21 -0
  98. package/dist/{dock → box}/notifications.d.ts +3 -0
  99. package/dist/{dock → box}/notifications.js +14 -4
  100. package/dist/{dock → box}/push.d.ts +12 -18
  101. package/dist/box/push.js +83 -0
  102. package/dist/box/ring.d.ts +18 -0
  103. package/dist/box/ring.js +55 -0
  104. package/dist/{dock → box}/service.d.ts +1 -1
  105. package/dist/{dock → box}/service.js +1 -1
  106. package/dist/{dock → box}/timer.d.ts +2 -0
  107. package/dist/box/timer.js +127 -0
  108. package/dist/box/tree.d.ts +5 -0
  109. package/dist/box/tree.js +14 -0
  110. package/dist/{dock → box}/webpush.d.ts +1 -1
  111. package/dist/cli/client.d.ts +1 -0
  112. package/dist/cli/daemon.d.ts +2 -8
  113. package/dist/cli/daemon.js +102 -107
  114. package/dist/cli/estate.js +2 -3
  115. package/dist/cli/nervur.js +44 -24
  116. package/dist/cli/stand.d.ts +0 -14
  117. package/dist/cli/stand.js +1 -1
  118. package/dist/harbor/browser.d.ts +8 -5
  119. package/dist/harbor/browser.js +20 -21
  120. package/dist/harbor/capacitor.d.ts +3 -3
  121. package/dist/harbor/capacitor.js +9 -8
  122. package/dist/harbor/disk.d.ts +9 -9
  123. package/dist/harbor/disk.js +56 -51
  124. package/dist/harbor/edge/alarm.d.ts +4 -2
  125. package/dist/harbor/edge/alarm.js +9 -19
  126. package/dist/harbor/edge/edge.d.ts +7 -6
  127. package/dist/harbor/edge/edge.js +58 -53
  128. package/dist/harbor/edge/exercise.js +4 -4
  129. package/dist/harbor/edge/given.d.ts +0 -1
  130. package/dist/harbor/edge/given.js +0 -29
  131. package/dist/harbor/edge/storage.d.ts +0 -2
  132. package/dist/harbor/edge/storage.js +2 -2
  133. package/dist/harbor/http.js +4 -2
  134. package/dist/harbor/sealed.d.ts +0 -5
  135. package/dist/harbor/sealed.js +0 -39
  136. package/dist/harbor/tauri.d.ts +2 -2
  137. package/dist/harbor/tauri.js +13 -10
  138. package/dist/human/app.d.ts +1 -1
  139. package/dist/human/app.js +10 -12
  140. package/dist/human/door.d.ts +0 -1
  141. package/dist/human/door.js +1 -1
  142. package/dist/human/html.js +1 -1
  143. package/dist/human/move.js +1 -1
  144. package/dist/human/tab.bundle.txt +3629 -2824
  145. package/dist/human/wake.d.ts +5 -2
  146. package/dist/human/wake.js +23 -14
  147. package/dist/human/web.d.ts +0 -1
  148. package/dist/human/web.js +3 -3
  149. package/dist/human/worker.bundle.txt +2945 -2118
  150. package/dist/human/worlds.js +3 -3
  151. package/dist/mcp/agent.d.ts +0 -1
  152. package/dist/mcp/agent.js +1 -1
  153. package/dist/mcp/allow.js +3 -2
  154. package/dist/mcp/http.d.ts +0 -1
  155. package/dist/mcp/http.js +1 -1
  156. package/dist/mcp/oauth.d.ts +3 -4
  157. package/dist/mcp/oauth.js +4 -4
  158. package/dist/mcp/route.d.ts +1 -1
  159. package/dist/mcp/runner.d.ts +0 -1
  160. package/dist/mcp/runner.js +1 -1
  161. package/dist/mcp/server.d.ts +0 -1
  162. package/dist/mcp/server.js +1 -1
  163. package/harbor/browser.ts +22 -24
  164. package/harbor/capacitor.ts +9 -8
  165. package/harbor/disk.ts +53 -48
  166. package/harbor/edge/alarm.ts +15 -12
  167. package/harbor/edge/edge.ts +61 -55
  168. package/harbor/edge/exercise.ts +4 -4
  169. package/harbor/edge/given.ts +3 -33
  170. package/harbor/edge/storage.ts +2 -2
  171. package/harbor/http.ts +5 -3
  172. package/harbor/sealed.ts +0 -35
  173. package/harbor/tauri.ts +13 -10
  174. package/human/app.ts +12 -13
  175. package/human/door.ts +1 -1
  176. package/human/html.ts +1 -1
  177. package/human/local.ts +1 -1
  178. package/human/move.ts +1 -1
  179. package/human/tab.bundle.txt +3629 -2824
  180. package/human/wake.ts +36 -16
  181. package/human/web.ts +4 -4
  182. package/human/worker.bundle.txt +2945 -2118
  183. package/human/worlds.ts +3 -3
  184. package/mcp/agent.ts +1 -1
  185. package/mcp/allow.ts +2 -1
  186. package/mcp/http.ts +1 -1
  187. package/mcp/oauth.ts +4 -4
  188. package/mcp/route.ts +1 -1
  189. package/mcp/runner.ts +1 -1
  190. package/mcp/server.ts +1 -1
  191. package/package.json +9 -8
  192. package/beings/envoy.ts +0 -218
  193. package/dist/beings/envoy.d.ts +0 -54
  194. package/dist/beings/envoy.js +0 -211
  195. package/dist/dock/console.d.ts +0 -6
  196. package/dist/dock/console.js +0 -20
  197. package/dist/dock/dialers.js +0 -75
  198. package/dist/dock/faculty.d.ts +0 -24
  199. package/dist/dock/faculty.js +0 -142
  200. package/dist/dock/grants.js +0 -99
  201. package/dist/dock/index.d.ts +0 -41
  202. package/dist/dock/index.js +0 -113
  203. package/dist/dock/local.js +0 -44
  204. package/dist/dock/location.js +0 -11
  205. package/dist/dock/push.js +0 -132
  206. package/dist/dock/timer.js +0 -149
  207. package/dock/console.ts +0 -23
  208. package/dock/dialers.ts +0 -85
  209. package/dock/faculty.ts +0 -148
  210. package/dock/grants.ts +0 -111
  211. package/dock/index.ts +0 -133
  212. package/dock/local.ts +0 -48
  213. package/dock/push.ts +0 -161
  214. package/dock/timer.ts +0 -174
  215. /package/dist/{dock → box}/fcm.js +0 -0
  216. /package/dist/{dock → box}/webpush.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { Invitation, JsonObject } from 'nervur';
2
2
  import type { Harbor } from 'nervur/harbor';
3
- import { type Token } from '../dock/index.ts';
3
+ import { type Token } from '../box/index.ts';
4
4
  export declare const webToken: (endpoint: string, p256dh?: string, auth?: string) => {
5
5
  kind: string;
6
6
  endpoint: string;
@@ -19,7 +19,10 @@ export type Held = {
19
19
  banner: string;
20
20
  } | null>;
21
21
  };
22
- export declare function doorbell(harbor: Harbor, bell?: Bell): Promise<Held | null>;
22
+ export type Why = 'unbuilt' | 'unhoused' | 'unanswered' | 'unmade' | 'untaken';
23
+ export declare function doorbell(harbor: Harbor, bell?: Bell, note?: {
24
+ why?: Why;
25
+ }): Promise<Held | null>;
23
26
  export declare function told(rel: {
24
27
  call(name: string, args?: JsonObject): Promise<unknown>;
25
28
  }, at: Held | null, token?: Token | null): Promise<string | null>;
@@ -18,8 +18,8 @@
18
18
  // browser endpoint is rung only by whoever holds the VAPID secret the
19
19
  // subscription was made under, and that secret is the world's own.
20
20
  import { isInvitation, isSilence, isWord } from 'nervur';
21
- import { DOCK, CONSOLE, NOTIFICATIONS, facultyOf } from '../dock/index.js';
22
- import { banner } from '../dock/push.js';
21
+ import { BOX, BOX_SEED, NOTIFICATIONS, Notifications, lent } from '../box/index.js';
22
+ import { banner } from '../box/ring.js';
23
23
  import { localName, relations } from './worlds.js';
24
24
  // The token a browser's push service hands a page: the endpoint, and the
25
25
  // two keys of the subscription made at it. RFC 8291 encrypts a body to
@@ -31,7 +31,7 @@ export const DOORBELL = 'doorbell';
31
31
  const said = (out) => (out === undefined || isSilence(out) || isWord(out) || out === null || typeof out !== 'object' || Array.isArray(out) ? null : out);
32
32
  // The box's own being, as the device's own code reaches its own object in
33
33
  // its own process. Nothing of this crosses an edge.
34
- const box = (harbor) => harbor.wards.get(DOCK)?.being(CONSOLE);
34
+ const box = (harbor) => harbor.wards.get(BOX_SEED)?.being(BOX);
35
35
  // The doorbell this device holds, taken the first time and kept after that.
36
36
  // A stranger phone knocks the bell's public being, is booted a doorbell of
37
37
  // its own and comes away with the one way in; the standing lives on the
@@ -39,30 +39,39 @@ const box = (harbor) => harbor.wards.get(DOCK)?.being(CONSOLE);
39
39
  //
40
40
  // Null is a device with no bell behind it, which is what a build that names
41
41
  // none looks like and what a bell that will not answer looks like. Each of
42
- // them works in every other way.
43
- export async function doorbell(harbor, bell) {
44
- if (!bell)
42
+ // them works in every other way. The reason comes back beside the null, in
43
+ // `note`, so a caller that wants to know which of them it is can ask and one
44
+ // that does not passes nothing.
45
+ export async function doorbell(harbor, bell, note) {
46
+ const no = (why) => {
47
+ if (note)
48
+ note.why = why;
45
49
  return null;
46
- const ward = harbor.wards.get(DOCK);
50
+ };
51
+ if (!bell)
52
+ return no('unbuilt');
53
+ const ward = harbor.wards.get(BOX_SEED);
47
54
  const me = box(harbor);
48
55
  if (!ward || !me)
49
- return null;
56
+ return no('unhoused');
50
57
  if (!me.standings[DOORBELL]) {
51
58
  const hello = said(await me.standings.knock({ ward: bell.pk }, 'hello', {}));
52
- const inv = hello?.invitation;
59
+ if (!hello)
60
+ return no('unanswered');
61
+ const inv = hello.invitation;
53
62
  if (!isInvitation(inv))
54
- return null;
63
+ return no('unmade');
55
64
  // The ward's own knock, which knocks and takes in one act: an
56
65
  // invitation is taken only where it was answered, so the two halves are
57
66
  // never split.
58
- const took = said(await ward.ask('knock', { being: CONSOLE, id: DOORBELL, invitation: inv }));
67
+ const took = said(await ward.ask('knock', { being: BOX, id: DOORBELL, invitation: inv }));
59
68
  await ward.save();
60
69
  if (took?.taken !== DOORBELL)
61
- return null;
70
+ return no('untaken');
62
71
  }
63
72
  const mine = me.standings[DOORBELL];
64
73
  if (!mine)
65
- return null;
74
+ return no('untaken');
66
75
  return {
67
76
  keep: async (token) => {
68
77
  const out = said(await mine.ask('keep', { token }));
@@ -73,7 +82,7 @@ export async function doorbell(harbor, bell) {
73
82
  // The banner key is minted on the first ask and kept, and a terrain
74
83
  // whose banners are drawn by a second process plants the secret half
75
84
  // where that process reads it while this is happening.
76
- const keys = facultyOf(harbor, NOTIFICATIONS);
85
+ const keys = await lent(harbor, NOTIFICATIONS);
77
86
  const key = keys ? said(await keys.banner({}))?.banner : undefined;
78
87
  if (typeof key !== 'string')
79
88
  return null;
@@ -11,7 +11,6 @@ export type Folder = {
11
11
  serving(): Promise<boolean>;
12
12
  beings(): Promise<string | null>;
13
13
  };
14
- export declare const BARE_FOLDER: Folder;
15
14
  export type WebOptions = {
16
15
  at: {
17
16
  quo: string;
package/dist/human/web.js CHANGED
@@ -1,11 +1,11 @@
1
- import { DOCK } from '../dock/index.js';
1
+ import { BOX_SEED } from '../box/index.js';
2
2
  import { publicKey } from '../harbor/ward.js';
3
3
  import { ANDROID, APPLE, association } from './apps.js';
4
4
  import { door } from './door.js';
5
5
  import { BARE, CSS } from './style.js';
6
6
  // A world with nothing beside its wards: no design, no code of its own. It
7
7
  // is what a terrain hands the route when it holds no folder at all.
8
- export const BARE_FOLDER = {
8
+ const BARE_FOLDER = {
9
9
  wearing: () => Promise.resolve({ tokens: false, fonts: false }),
10
10
  design: () => Promise.resolve(null),
11
11
  serving: () => Promise.resolve(false),
@@ -88,7 +88,7 @@ ${await design()}
88
88
  // public being still answers a proof and a link still knocks, but a hidden
89
89
  // ward's page is the plain door page and its root line is not written.
90
90
  const shown = o.shown ?? (() => true);
91
- const wards = async () => Object.fromEntries(await Promise.all([...harbor.wards].filter(([n]) => n !== DOCK).map(async ([n, h]) => [n, { pk: h.pk, public: shown(n) && (await publicKey(h)) !== null }])));
91
+ const wards = async () => Object.fromEntries(await Promise.all([...harbor.wards].filter(([n]) => n !== BOX_SEED).map(async ([n, h]) => [n, { pk: h.pk, public: shown(n) && (await publicKey(h)) !== null }])));
92
92
  const config = async (ward, being) => ({ quo: o.at.quo, web: o.at.web, wards: await wards(), beings: await folder.serving(), ...(o.bell ? { bell: o.bell } : {}), ...(ward ? { ward } : {}), ...(being ? { being } : {}) });
93
93
  const tab = async (ward, being) => {
94
94
  return `<script id="nervur" type="application/json">${JSON.stringify(await config(ward, being)).replace(/</g, '\\u003c')}</script><script type="module" src="${o.at.web}/tab.js"></script>`;