@minca/core 0.3.1 → 0.4.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 (212) hide show
  1. package/README.md +2 -2
  2. package/dist/{session → hosting}/hosting.d.ts +1 -1
  3. package/dist/{session → hosting}/hosting.d.ts.map +1 -1
  4. package/dist/{session → hosting}/hosting.js.map +1 -1
  5. package/dist/index.d.ts +20 -28
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +16 -19
  8. package/dist/index.js.map +1 -1
  9. package/dist/network/mesh.d.ts.map +1 -1
  10. package/dist/network/mesh.js +13 -3
  11. package/dist/network/mesh.js.map +1 -1
  12. package/dist/network/network-manager.d.ts +5 -0
  13. package/dist/network/network-manager.d.ts.map +1 -1
  14. package/dist/network/network-manager.js +3 -0
  15. package/dist/network/network-manager.js.map +1 -1
  16. package/dist/network/peer-auth.d.ts +17 -5
  17. package/dist/network/peer-auth.d.ts.map +1 -1
  18. package/dist/network/peer-auth.js +19 -9
  19. package/dist/network/peer-auth.js.map +1 -1
  20. package/dist/network/rtc-transport.d.ts.map +1 -1
  21. package/dist/network/rtc-transport.js +1 -0
  22. package/dist/network/rtc-transport.js.map +1 -1
  23. package/dist/network/transport.d.ts +12 -0
  24. package/dist/network/transport.d.ts.map +1 -1
  25. package/dist/network/ws-transport.d.ts +1 -1
  26. package/dist/network/ws-transport.d.ts.map +1 -1
  27. package/dist/network/ws-transport.js +14 -4
  28. package/dist/network/ws-transport.js.map +1 -1
  29. package/dist/node/index.d.ts +1 -5
  30. package/dist/node/index.d.ts.map +1 -1
  31. package/dist/node/index.js +0 -3
  32. package/dist/node/index.js.map +1 -1
  33. package/dist/node/node-hosting.js +1 -1
  34. package/dist/node/node-records.js +1 -1
  35. package/dist/node/node-records.js.map +1 -1
  36. package/dist/node/node.d.ts.map +1 -1
  37. package/dist/node/node.js +18 -0
  38. package/dist/node/node.js.map +1 -1
  39. package/dist/node/space-mirrors.d.ts +1 -1
  40. package/dist/node/space-mirrors.d.ts.map +1 -1
  41. package/dist/node/space-mirrors.js +17 -5
  42. package/dist/node/space-mirrors.js.map +1 -1
  43. package/dist/node/space-peers.d.ts +2 -0
  44. package/dist/node/space-peers.d.ts.map +1 -1
  45. package/dist/node/space-peers.js +41 -8
  46. package/dist/node/space-peers.js.map +1 -1
  47. package/dist/node/space-runtime.d.ts +4 -2
  48. package/dist/node/space-runtime.d.ts.map +1 -1
  49. package/dist/node/space-runtime.js +3 -2
  50. package/dist/node/space-runtime.js.map +1 -1
  51. package/dist/node/space-standing.d.ts.map +1 -1
  52. package/dist/node/space-standing.js +12 -38
  53. package/dist/node/space-standing.js.map +1 -1
  54. package/dist/node/space-warrants.js +1 -1
  55. package/dist/node/space-warrants.js.map +1 -1
  56. package/dist/node/space-writing.d.ts.map +1 -1
  57. package/dist/node/space-writing.js +12 -32
  58. package/dist/node/space-writing.js.map +1 -1
  59. package/dist/node/stores.d.ts +2 -58
  60. package/dist/node/stores.d.ts.map +1 -1
  61. package/dist/node/stores.js +1 -74
  62. package/dist/node/stores.js.map +1 -1
  63. package/dist/node/types.d.ts +3 -3
  64. package/dist/node/types.d.ts.map +1 -1
  65. package/dist/node/writer-keys.d.ts +15 -14
  66. package/dist/node/writer-keys.d.ts.map +1 -1
  67. package/dist/node/writer-keys.js +3 -113
  68. package/dist/node/writer-keys.js.map +1 -1
  69. package/dist/records/key.d.ts +16 -19
  70. package/dist/records/key.d.ts.map +1 -1
  71. package/dist/records/key.js +53 -45
  72. package/dist/records/key.js.map +1 -1
  73. package/dist/records/rules.d.ts +1 -1
  74. package/dist/records/rules.d.ts.map +1 -1
  75. package/dist/records/rules.js +6 -4
  76. package/dist/records/rules.js.map +1 -1
  77. package/dist/storage/body-cache.d.ts +6 -3
  78. package/dist/storage/body-cache.d.ts.map +1 -1
  79. package/dist/storage/body-cache.js +37 -14
  80. package/dist/storage/body-cache.js.map +1 -1
  81. package/dist/storage/mirror.d.ts.map +1 -1
  82. package/dist/storage/mirror.js +35 -16
  83. package/dist/storage/mirror.js.map +1 -1
  84. package/dist/storage/segment.d.ts +6 -2
  85. package/dist/storage/segment.d.ts.map +1 -1
  86. package/dist/storage/segment.js +8 -4
  87. package/dist/storage/segment.js.map +1 -1
  88. package/dist/storage/shared-store.d.ts +32 -0
  89. package/dist/storage/shared-store.d.ts.map +1 -0
  90. package/dist/storage/{folder-reconcile.js → shared-store.js} +15 -15
  91. package/dist/storage/shared-store.js.map +1 -0
  92. package/dist/storage/storage-provider.d.ts +0 -9
  93. package/dist/storage/storage-provider.d.ts.map +1 -1
  94. package/dist/storage/storage-provider.js +8 -8
  95. package/dist/storage/storage-provider.js.map +1 -1
  96. package/dist/sync/sync-engine.d.ts +7 -0
  97. package/dist/sync/sync-engine.d.ts.map +1 -1
  98. package/dist/sync/sync-engine.js +179 -47
  99. package/dist/sync/sync-engine.js.map +1 -1
  100. package/dist/sync/sync-messages.d.ts +1 -1
  101. package/dist/sync/sync-messages.js +1 -1
  102. package/dist/types.d.ts +19 -0
  103. package/dist/types.d.ts.map +1 -1
  104. package/dist/types.js +4 -0
  105. package/dist/types.js.map +1 -1
  106. package/dist/utils/index.d.ts +5 -5
  107. package/dist/utils/index.d.ts.map +1 -1
  108. package/dist/utils/index.js +5 -5
  109. package/dist/utils/index.js.map +1 -1
  110. package/docs/README.md +3 -2
  111. package/docs/building-an-app.md +2 -2
  112. package/docs/node.md +24 -20
  113. package/docs/query-format.md +6 -5
  114. package/docs/records-and-queries.md +12 -13
  115. package/docs/storage.md +41 -15
  116. package/package.json +10 -19
  117. package/dist/identity/account-store.d.ts +0 -83
  118. package/dist/identity/account-store.d.ts.map +0 -1
  119. package/dist/identity/account-store.js +0 -234
  120. package/dist/identity/account-store.js.map +0 -1
  121. package/dist/identity/device-key.d.ts +0 -26
  122. package/dist/identity/device-key.d.ts.map +0 -1
  123. package/dist/identity/device-key.js +0 -48
  124. package/dist/identity/device-key.js.map +0 -1
  125. package/dist/identity/idb.d.ts +0 -19
  126. package/dist/identity/idb.d.ts.map +0 -1
  127. package/dist/identity/idb.js +0 -56
  128. package/dist/identity/idb.js.map +0 -1
  129. package/dist/node/worker.d.ts +0 -91
  130. package/dist/node/worker.d.ts.map +0 -1
  131. package/dist/node/worker.js +0 -344
  132. package/dist/node/worker.js.map +0 -1
  133. package/dist/node-worker.d.ts +0 -2
  134. package/dist/node-worker.d.ts.map +0 -1
  135. package/dist/node-worker.js +0 -16
  136. package/dist/node-worker.js.map +0 -1
  137. package/dist/session/account-hint.d.ts +0 -13
  138. package/dist/session/account-hint.d.ts.map +0 -1
  139. package/dist/session/account-hint.js +0 -54
  140. package/dist/session/account-hint.js.map +0 -1
  141. package/dist/session/channel-room.d.ts +0 -26
  142. package/dist/session/channel-room.d.ts.map +0 -1
  143. package/dist/session/channel-room.js +0 -56
  144. package/dist/session/channel-room.js.map +0 -1
  145. package/dist/session/connect-code.d.ts +0 -127
  146. package/dist/session/connect-code.d.ts.map +0 -1
  147. package/dist/session/connect-code.js +0 -408
  148. package/dist/session/connect-code.js.map +0 -1
  149. package/dist/session/connect.d.ts +0 -393
  150. package/dist/session/connect.d.ts.map +0 -1
  151. package/dist/session/connect.js +0 -587
  152. package/dist/session/connect.js.map +0 -1
  153. package/dist/session/connection.d.ts +0 -141
  154. package/dist/session/connection.d.ts.map +0 -1
  155. package/dist/session/connection.js +0 -344
  156. package/dist/session/connection.js.map +0 -1
  157. package/dist/session/index.d.ts +0 -24
  158. package/dist/session/index.d.ts.map +0 -1
  159. package/dist/session/index.js +0 -18
  160. package/dist/session/index.js.map +0 -1
  161. package/dist/session/pairing.d.ts +0 -97
  162. package/dist/session/pairing.d.ts.map +0 -1
  163. package/dist/session/pairing.js +0 -251
  164. package/dist/session/pairing.js.map +0 -1
  165. package/dist/session/places.d.ts +0 -71
  166. package/dist/session/places.d.ts.map +0 -1
  167. package/dist/session/places.js +0 -130
  168. package/dist/session/places.js.map +0 -1
  169. package/dist/session/popup.d.ts +0 -13
  170. package/dist/session/popup.d.ts.map +0 -1
  171. package/dist/session/popup.js +0 -23
  172. package/dist/session/popup.js.map +0 -1
  173. package/dist/session/stay-signed-in.d.ts +0 -48
  174. package/dist/session/stay-signed-in.d.ts.map +0 -1
  175. package/dist/session/stay-signed-in.js +0 -141
  176. package/dist/session/stay-signed-in.js.map +0 -1
  177. package/dist/storage/blob/directory.d.ts +0 -14
  178. package/dist/storage/blob/directory.d.ts.map +0 -1
  179. package/dist/storage/blob/directory.js +0 -87
  180. package/dist/storage/blob/directory.js.map +0 -1
  181. package/dist/storage/blob/memory.d.ts +0 -6
  182. package/dist/storage/blob/memory.d.ts.map +0 -1
  183. package/dist/storage/blob/memory.js +0 -20
  184. package/dist/storage/blob/memory.js.map +0 -1
  185. package/dist/storage/blob/s3.d.ts +0 -16
  186. package/dist/storage/blob/s3.d.ts.map +0 -1
  187. package/dist/storage/blob/s3.js +0 -91
  188. package/dist/storage/blob/s3.js.map +0 -1
  189. package/dist/storage/directory-access.d.ts +0 -36
  190. package/dist/storage/directory-access.d.ts.map +0 -1
  191. package/dist/storage/directory-access.js +0 -89
  192. package/dist/storage/directory-access.js.map +0 -1
  193. package/dist/storage/folder-adapter.d.ts +0 -100
  194. package/dist/storage/folder-adapter.d.ts.map +0 -1
  195. package/dist/storage/folder-adapter.js +0 -232
  196. package/dist/storage/folder-adapter.js.map +0 -1
  197. package/dist/storage/folder-reconcile.d.ts +0 -33
  198. package/dist/storage/folder-reconcile.d.ts.map +0 -1
  199. package/dist/storage/folder-reconcile.js.map +0 -1
  200. package/dist/storage/index.d.ts +0 -6
  201. package/dist/storage/index.d.ts.map +0 -1
  202. package/dist/storage/index.js +0 -5
  203. package/dist/storage/index.js.map +0 -1
  204. package/dist/storage/indexeddb-adapter.d.ts +0 -8
  205. package/dist/storage/indexeddb-adapter.d.ts.map +0 -1
  206. package/dist/storage/indexeddb-adapter.js +0 -128
  207. package/dist/storage/indexeddb-adapter.js.map +0 -1
  208. package/dist/storage/sqlite-adapter.d.ts +0 -57
  209. package/dist/storage/sqlite-adapter.d.ts.map +0 -1
  210. package/dist/storage/sqlite-adapter.js +0 -213
  211. package/dist/storage/sqlite-adapter.js.map +0 -1
  212. /package/dist/{session → hosting}/hosting.js +0 -0
@@ -1,127 +0,0 @@
1
- /**
2
- * @module session/connect-code
3
- * Connecting a program that has no browser of its own (`minca connect`) to an
4
- * account. The program makes a one-time code and opens the account home with
5
- * it (`<home>/connect#mc_…`). The two meet on the code's channel
6
- * (`identity/channel.ts`, `CODE_CHANNEL`): the home says where it lives, the
7
- * program says which key it holds, the person signs in and allows it there,
8
- * and the home hands back a records-only note made out to the program's key.
9
- * The relay learns and changes nothing, and a recording of the room is no use
10
- * to someone who sees the code later.
11
- */
12
- import type { PeerTransport } from '../network/transport.js';
13
- import { type AppKey, type Grant, type IncomingRequest } from './connect.js';
14
- /** Who is asking, as the program said */
15
- export interface CodeAsking {
16
- /** The program's key: the note is made out to it */
17
- readonly did: string;
18
- /** What the program calls itself, e.g. "Agent on leifs-macbook". Shown, not trusted. */
19
- readonly name: string;
20
- /** The key's proof that it holds itself, for a records-only note (`keyProof`, `via: code`, the home's origin) */
21
- readonly proof: string;
22
- }
23
- /** Where the two sides meet */
24
- interface CodeNetwork {
25
- /** Relays to meet on. The home's and the program's must share one. */
26
- readonly relays: ReadonlyArray<string>;
27
- /** A transport instead of WebRTC — for tests */
28
- readonly transport?: (did: string) => PeerTransport;
29
- }
30
- /** A new code: `mc_` and 128 random bits */
31
- export declare function newConnectCode(): string;
32
- /** Where the person allows a program: the home's connect page, with the code after `#` so it never reaches a server */
33
- export declare const connectCodeUrl: (home: string, code: string) => string;
34
- /**
35
- * The secret a code holds, from anything it is found in: the code, or the
36
- * link the program opened.
37
- * @throws When there is no code in it
38
- */
39
- export declare function readConnectCode(input: string): Uint8Array;
40
- /** The code in a link the home was opened at, or null: `#mc_…` */
41
- export declare function connectCodeIn(hash: string): string | null;
42
- export type ConnectCodeStage = {
43
- readonly kind: 'waiting';
44
- }
45
- /**
46
- * The program is there. Show `check`, for the person to give the program,
47
- * then sign it a records-only note and `allow` it, or `deny`.
48
- */
49
- | {
50
- readonly kind: 'asking';
51
- readonly asking: CodeAsking;
52
- readonly check: string;
53
- allow(grant: Grant): Promise<void>;
54
- deny(reason?: string): void;
55
- } | {
56
- readonly kind: 'connected';
57
- readonly asking: CodeAsking;
58
- } | {
59
- readonly kind: 'failed';
60
- readonly reason: string;
61
- };
62
- /**
63
- * Answers the program that opened the home with a code. Keep it running while
64
- * the page is open: the first program whose sealed ask opens is the one asked
65
- * about, and nobody after it.
66
- *
67
- * @param options.code The code from the link the home was opened at
68
- * @param options.origin Where this home lives: the program's proof names it. Default: this page's.
69
- * @returns A way to stop listening; the code stops working
70
- */
71
- export declare function answerConnectCode(options: CodeNetwork & {
72
- readonly code: string;
73
- readonly origin?: string;
74
- /** How long to wait for the program to ask. Default 60 s: it is waiting when its link opens, unless it has gone or another home answered it. */
75
- readonly findTimeoutMs?: number;
76
- }, onStage: (stage: ConnectCodeStage) => void): Promise<{
77
- stop(): void;
78
- }>;
79
- /**
80
- * The account home's connect page, opened at a code: answers the program and
81
- * hands its ask to the same approval as an app's, as a request for records in
82
- * the whole account. `approve` sends the note, `deny` says no. `onAnswered`
83
- * says how it went, since this page was opened by a person, not an app, and
84
- * stays open: allowed only once the program says it has the note.
85
- *
86
- * @returns The program's request, or null when none came
87
- */
88
- export declare function receiveConnectCode(options: CodeNetwork & {
89
- readonly code: string;
90
- readonly origin?: string;
91
- readonly onAnswered?: (answer: {
92
- readonly allowed: boolean;
93
- }) => void;
94
- }): Promise<IncomingRequest | null>;
95
- /**
96
- * Connects this program with a code it made ({@link newConnectCode}): open
97
- * {@link connectCodeUrl} for the person, then wait here for their home.
98
- *
99
- * @param params.home The account home it opened: only a peer saying it is that home is asked, and the grant keeps it
100
- * @param params.key This program's key — the note will be made out to it, and it signs the proof for the home's origin
101
- * @param params.name What the person sees, e.g. "Agent on leifs-macbook"
102
- * @param params.onWaiting Told once the home has heard, and the person is deciding, with where the home lives
103
- * @returns The grant, checked: a records-only note for this key, with `home` the one it opened
104
- * @throws When the person says no, or nothing answers in time
105
- */
106
- export declare function connectWithCode(params: {
107
- readonly code: string;
108
- readonly home: string;
109
- readonly key: AppKey;
110
- readonly name: string;
111
- readonly network: CodeNetwork;
112
- readonly onWaiting?: (home: {
113
- readonly origin: string;
114
- }) => void;
115
- /**
116
- * Asks the person for the check code the home shows, until `matches` says
117
- * it does; rejecting gives up. The note is kept only once it matches: so a
118
- * home the person never saw can't connect it.
119
- */
120
- readonly check: (matches: (typed: string) => boolean) => Promise<void>;
121
- /** How long to wait for the home to open at all. Default 10 minutes: the person may make an account first. */
122
- readonly findTimeoutMs?: number;
123
- /** How long the person has to decide once it has. Default 30 minutes. */
124
- readonly decideTimeoutMs?: number;
125
- }): Promise<Grant>;
126
- export {};
127
- //# sourceMappingURL=connect-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-code.d.ts","sourceRoot":"","sources":["../../src/session/connect-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAU7D,OAAO,EAAwB,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAuBnG,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iHAAiH;IACjH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAKD,+BAA+B;AAC/B,UAAU,WAAW;IACnB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAA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,IAAI,CAAA;CAAE,CAAC,CA2G3B;AAKD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,WAAW,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CACvE,GACA,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAuCjC;AAID;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,8GAA8G;IAC9G,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC,GAAG,OAAO,CAAC,KAAK,CAAC,CAmHjB"}
@@ -1,408 +0,0 @@
1
- import { channelKeyPair, CODE_CHANNEL, deriveChannel } from '../identity/channel.js';
2
- import { base64UrlDecode, base64UrlEncode } from '../utils/encoding.js';
3
- import { sha256 } from '../utils/hash.js';
4
- import { isObject } from '../utils/guards.js';
5
- import { grantsRecordsOnly } from '../identity/abilities.js';
6
- import { checkGrant, keyProof } from './connect.js';
7
- import { bytesField, meetOnChannel } from './channel-room.js';
8
- const CODE_PREFIX = 'mc_';
9
- const SECRET_BYTES = 16;
10
- /** base64url characters for the secret, unpadded */
11
- const CODE_CHARS = Math.ceil((SECRET_BYTES * 4) / 3);
12
- /** Messages on the channel: the key exchange in the clear, the rest sealed */
13
- const HELLO = 'code:hello';
14
- const KEY = 'code:key';
15
- const POINT = 'code:point';
16
- const HOME = 'code:home';
17
- const ASK = 'code:ask';
18
- const HEARD = 'code:heard';
19
- const ANSWER = 'code:answer';
20
- const DONE = 'code:done';
21
- /** Longest name a program may give itself */
22
- const MAX_NAME = 80;
23
- /** Longest origin a home may give */
24
- const MAX_ORIGIN = 200;
25
- // ─── The code ────────────────────────────────────────────────────────
26
- /** What the program says first: a hash of its point, so neither side can pick a key to steer the check code */
27
- const commitTo = async (point) => base64UrlEncode(await sha256(point));
28
- const CHECK_LABEL = 'minca/code-check/v1';
29
- /**
30
- * The six digits the home shows and the person gives the program, from the
31
- * exchange's channel: only the two ends of one exchange share them.
32
- */
33
- async function connectCheck(channel) {
34
- const bytes = await channel.derive(CHECK_LABEL, 4);
35
- const value = new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0) % 1_000_000;
36
- return String(value).padStart(6, '0');
37
- }
38
- /** A new code: `mc_` and 128 random bits */
39
- export function newConnectCode() {
40
- return CODE_PREFIX + base64UrlEncode(globalThis.crypto.getRandomValues(new Uint8Array(SECRET_BYTES)));
41
- }
42
- /** Where the person allows a program: the home's connect page, with the code after `#` so it never reaches a server */
43
- export const connectCodeUrl = (home, code) => `${new URL('/connect', home).href}#${code}`;
44
- const CODE_PATTERN = new RegExp(`mc_([A-Za-z0-9_-]{${CODE_CHARS}})(?![A-Za-z0-9_-])`);
45
- /**
46
- * The secret a code holds, from anything it is found in: the code, or the
47
- * link the program opened.
48
- * @throws When there is no code in it
49
- */
50
- export function readConnectCode(input) {
51
- const match = CODE_PATTERN.exec(input);
52
- const bytes = match ? base64UrlDecode(match[1]) : null;
53
- if (!bytes || bytes.length !== SECRET_BYTES) {
54
- throw new Error('That is not a connect code. Open the whole link the program showed.');
55
- }
56
- return bytes;
57
- }
58
- /** The code in a link the home was opened at, or null: `#mc_…` */
59
- export function connectCodeIn(hash) {
60
- const match = CODE_PATTERN.exec(hash);
61
- return match && base64UrlDecode(match[1])?.length === SECRET_BYTES ? match[0] : null;
62
- }
63
- /** An origin as a browser reports one, e.g. `https://app.example`, or null */
64
- function readOrigin(value) {
65
- if (!isObject(value) || typeof value.origin !== 'string' || value.origin.length > MAX_ORIGIN)
66
- return null;
67
- try {
68
- const { origin } = new URL(value.origin);
69
- return origin === value.origin && origin !== 'null' ? origin : null;
70
- }
71
- catch {
72
- return null;
73
- }
74
- }
75
- function readAsk(value) {
76
- if (!isObject(value))
77
- return null;
78
- const { did, proof, name } = value;
79
- if (typeof did !== 'string' || !did.startsWith('did:key:') || did.length > 200)
80
- return null;
81
- // Without its proof the home refuses to sign anything for it.
82
- if (typeof proof !== 'string' || proof.length > 200)
83
- return null;
84
- const shown = typeof name === 'string' && name.trim() ? name.trim().slice(0, MAX_NAME) : 'A program';
85
- return { did, proof, name: shown };
86
- }
87
- /**
88
- * Answers the program that opened the home with a code. Keep it running while
89
- * the page is open: the first program whose sealed ask opens is the one asked
90
- * about, and nobody after it.
91
- *
92
- * @param options.code The code from the link the home was opened at
93
- * @param options.origin Where this home lives: the program's proof names it. Default: this page's.
94
- * @returns A way to stop listening; the code stops working
95
- */
96
- export async function answerConnectCode(options, onStage) {
97
- if (options.relays.length === 0 && !options.transport)
98
- throw new Error('Connecting by code needs a relay, and none is configured.');
99
- const origin = options.origin ?? globalThis.location?.origin;
100
- if (!origin || readOrigin({ origin }) === null)
101
- throw new Error('Connecting by code needs the home’s origin.');
102
- const secret = readConnectCode(options.code);
103
- const room = await meetOnChannel(CODE_CHANNEL, options, secret);
104
- /**
105
- * What each peer that said hello committed to, and the key made for that
106
- * exchange alone (one key for every peer would let a peer learn it in one
107
- * exchange and steer the check in another), then its exchange once it
108
- * showed its point, until one asks
109
- */
110
- const commits = new Map();
111
- const channels = new Map();
112
- let asked = null;
113
- let settled = false;
114
- const finish = (stage) => {
115
- if (settled)
116
- return;
117
- settled = true;
118
- globalThis.clearTimeout(timer);
119
- room.leave();
120
- if (stage)
121
- onStage(stage);
122
- };
123
- const handle = async (message) => {
124
- if (settled)
125
- return;
126
- if (message.type === HELLO && !asked) {
127
- // One exchange, with the first peer to commit, as pairing has: with several, someone in the
128
- // room could run many and pick a pair whose checks match.
129
- if (commits.size > 0)
130
- return;
131
- const commit = bytesField(message, 'commit');
132
- if (!commit)
133
- return;
134
- const mine = await channelKeyPair();
135
- commits.set(message.from, { commit: base64UrlEncode(commit), mine });
136
- // Its point comes only after this one: it committed to it before seeing it.
137
- room.send(message.from, KEY, { key: base64UrlEncode(mine.point) });
138
- }
139
- else if (message.type === POINT && !asked) {
140
- if (channels.has(message.from))
141
- return;
142
- const point = bytesField(message, 'key');
143
- const said = commits.get(message.from);
144
- if (!point || !said || (await commitTo(point)) !== said.commit)
145
- return;
146
- const channel = await deriveChannel({
147
- kind: CODE_CHANNEL,
148
- secret,
149
- privateKey: said.mine.privateKey,
150
- offer: said.mine.point,
151
- join: point,
152
- side: 'offer',
153
- }).catch(() => null);
154
- if (!channel)
155
- return;
156
- channels.set(message.from, channel);
157
- // Where the home lives: the program's proof names it, so the proof is no use anywhere else.
158
- await room.seal(message.from, HOME, channel, { origin });
159
- }
160
- else if (message.type === ASK && !asked) {
161
- const channel = channels.get(message.from);
162
- if (!channel)
163
- return;
164
- // Opens only for a program that holds the code and is the other end of this exchange.
165
- const asking = readAsk(await room.open(message, channel));
166
- if (!asking)
167
- return;
168
- const peer = message.from;
169
- // The code is spent: nobody after this program is answered.
170
- asked = { peer, channel, asking };
171
- globalThis.clearTimeout(timer);
172
- // So the program knows it was right, and the person is deciding.
173
- await room.seal(peer, HEARD, channel, {});
174
- onStage({
175
- kind: 'asking',
176
- asking,
177
- check: await connectCheck(channel),
178
- allow: async (grant) => {
179
- if (grant.note.payload.aud !== asking.did)
180
- throw new Error('That note is for a different key.');
181
- if (!grantsRecordsOnly(grant.note))
182
- throw new Error('A program connected by code gets records only.');
183
- await room.seal(peer, ANSWER, channel, { grant });
184
- },
185
- deny: (reason = 'The person said no.') => {
186
- void room
187
- .seal(peer, ANSWER, channel, { denied: reason })
188
- .then(() => finish({ kind: 'failed', reason: 'You said no. The program can ask again.' }));
189
- },
190
- });
191
- }
192
- else if (message.type === DONE && asked && message.from === asked.peer) {
193
- if (await room.open(message, asked.channel))
194
- finish({ kind: 'connected', asking: asked.asking });
195
- }
196
- };
197
- // One message at a time, in the order they came: each may depend on what the one before settled.
198
- let handling = Promise.resolve();
199
- room.net.on('message', (message) => {
200
- handling = handling.then(() => handle(message)).catch(() => { });
201
- });
202
- onStage({ kind: 'waiting' });
203
- // Declared last: everything above that clears it runs only once the room is joined.
204
- const timer = globalThis.setTimeout(() => finish({ kind: 'failed', reason: 'The program that opened this link isn’t waiting for it any more.' }), options.findTimeoutMs ?? 60_000);
205
- await room.net.connect();
206
- return {
207
- stop: () => {
208
- finish();
209
- room.net.disconnect();
210
- },
211
- };
212
- }
213
- /** How long a program connected by code stays in sync before it asks again */
214
- const CODE_DAYS = 30;
215
- /**
216
- * The account home's connect page, opened at a code: answers the program and
217
- * hands its ask to the same approval as an app's, as a request for records in
218
- * the whole account. `approve` sends the note, `deny` says no. `onAnswered`
219
- * says how it went, since this page was opened by a person, not an app, and
220
- * stays open: allowed only once the program says it has the note.
221
- *
222
- * @returns The program's request, or null when none came
223
- */
224
- export function receiveConnectCode(options) {
225
- const origin = options.origin ?? globalThis.location?.origin ?? '';
226
- return new Promise((resolve) => {
227
- let asked = false;
228
- void answerConnectCode({ ...options, origin }, (stage) => {
229
- // The room is left by the exchange itself, after a moment for the last message to go.
230
- if (stage.kind === 'connected')
231
- options.onAnswered?.({ allowed: true });
232
- if (stage.kind === 'failed') {
233
- if (asked)
234
- options.onAnswered?.({ allowed: false });
235
- else
236
- resolve(null);
237
- }
238
- if (stage.kind !== 'asking')
239
- return;
240
- asked = true;
241
- const { asking, check } = stage;
242
- resolve({
243
- origin,
244
- check,
245
- request: {
246
- v: 1,
247
- audience: asking.did,
248
- proof: asking.proof,
249
- name: asking.name,
250
- access: 'write',
251
- scope: 'account',
252
- chooseSpaces: false,
253
- recordsOnly: true,
254
- via: 'code',
255
- days: CODE_DAYS,
256
- },
257
- approve: (answer) => {
258
- if (!('note' in answer))
259
- return stage.deny('The home answered with something other than a note.');
260
- void stage
261
- .allow({ ...answer, home: `${origin}/connect` })
262
- .catch(() => stage.deny('The home could not send the note.'));
263
- },
264
- deny: (reason) => stage.deny(reason),
265
- });
266
- }).catch(() => resolve(null));
267
- });
268
- }
269
- // ─── The program's side ──────────────────────────────────────────────
270
- /**
271
- * Connects this program with a code it made ({@link newConnectCode}): open
272
- * {@link connectCodeUrl} for the person, then wait here for their home.
273
- *
274
- * @param params.home The account home it opened: only a peer saying it is that home is asked, and the grant keeps it
275
- * @param params.key This program's key — the note will be made out to it, and it signs the proof for the home's origin
276
- * @param params.name What the person sees, e.g. "Agent on leifs-macbook"
277
- * @param params.onWaiting Told once the home has heard, and the person is deciding, with where the home lives
278
- * @returns The grant, checked: a records-only note for this key, with `home` the one it opened
279
- * @throws When the person says no, or nothing answers in time
280
- */
281
- export async function connectWithCode(params) {
282
- const secret = readConnectCode(params.code);
283
- const opened = new URL('/connect', params.home);
284
- const room = await meetOnChannel(CODE_CHANNEL, params.network, secret);
285
- /** A key for each peer it says hello to, for that exchange alone, as the home makes one for each */
286
- const keys = new Map();
287
- return new Promise((resolve, reject) => {
288
- /** The person giving the check code: started once the home has heard */
289
- let checked = null;
290
- const channels = new Map();
291
- /** Where each peer that holds the code says its home lives, once it has said */
292
- const origins = new Map();
293
- let home = null;
294
- let settled = false;
295
- let timer;
296
- const settle = (done) => {
297
- if (settled)
298
- return;
299
- settled = true;
300
- globalThis.clearTimeout(timer);
301
- room.leave();
302
- done();
303
- };
304
- const fail = (reason) => settle(() => reject(new Error(reason)));
305
- const wait = (ms, reason) => {
306
- globalThis.clearTimeout(timer);
307
- timer = globalThis.setTimeout(() => fail(reason), ms);
308
- };
309
- room.net.on('peer-connected', (peer) => {
310
- if (home || keys.has(peer.did))
311
- return;
312
- const mine = channelKeyPair();
313
- keys.set(peer.did, mine);
314
- void mine
315
- .then(async ({ point }) => room.send(peer.did, HELLO, { commit: await commitTo(point) }))
316
- .catch(() => { });
317
- });
318
- const handle = async (message) => {
319
- if (settled)
320
- return;
321
- if (message.type === KEY && !home) {
322
- // One exchange, with the first peer to answer: the home runs one too.
323
- if (channels.size > 0)
324
- return;
325
- const point = bytesField(message, 'key');
326
- const mine = await keys.get(message.from);
327
- if (!point || !mine)
328
- return;
329
- const channel = await deriveChannel({
330
- kind: CODE_CHANNEL,
331
- secret,
332
- privateKey: mine.privateKey,
333
- offer: point,
334
- join: mine.point,
335
- side: 'join',
336
- }).catch(() => null);
337
- if (!channel)
338
- return;
339
- channels.set(message.from, channel);
340
- room.send(message.from, POINT, { key: base64UrlEncode(mine.point) });
341
- }
342
- else if (message.type === HOME && !home) {
343
- const channel = channels.get(message.from);
344
- if (!channel || origins.has(message.from))
345
- return;
346
- const origin = readOrigin(await room.open(message, channel));
347
- // Only the home it opened: the proof names it, and so does the grant it keeps.
348
- if (origin !== opened.origin)
349
- return;
350
- origins.set(message.from, origin);
351
- // The proof names the home's origin: any other home refuses it.
352
- const proof = await keyProof(params.key, { via: 'code', recordsOnly: true, origin });
353
- await room.seal(message.from, ASK, channel, {
354
- did: params.key.did,
355
- proof,
356
- name: params.name.slice(0, MAX_NAME),
357
- });
358
- }
359
- else if (message.type === HEARD && !home) {
360
- const channel = channels.get(message.from);
361
- const origin = origins.get(message.from);
362
- // Only a home that holds the code, at the other end of this exchange, can seal this.
363
- if (!channel || !origin || !(await room.open(message, channel)))
364
- return;
365
- const expected = await connectCheck(channel);
366
- // Asked for before anything else runs: no answer is kept without it.
367
- checked = params.check((typed) => typed.replace(/\D/g, '') === expected);
368
- checked.catch((error) => fail(error instanceof Error ? error.message : String(error)));
369
- home = { peer: message.from, channel, origin };
370
- params.onWaiting?.({ origin });
371
- // Once the home has the question, the person gets longer to answer it.
372
- wait(params.decideTimeoutMs ?? 30 * 60_000, 'Nobody answered at the account home. Try again.');
373
- }
374
- else if (message.type === ANSWER && home && message.from === home.peer) {
375
- const answer = await room.open(message, home.channel);
376
- if (!isObject(answer))
377
- return;
378
- if (typeof answer.denied === 'string') {
379
- fail(answer.denied.slice(0, 200));
380
- return;
381
- }
382
- try {
383
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- checkGrant checks it
384
- const grant = answer.grant;
385
- await checkGrant(grant, params.key.did, { recordsOnly: true });
386
- // Kept only once the person gave the code their own home showed.
387
- if (!checked)
388
- return;
389
- await checked;
390
- await room.seal(message.from, DONE, home.channel, {});
391
- // Where to connect again is the home it opened, never one the answer names.
392
- settle(() => resolve({ ...grant, home: opened.href }));
393
- }
394
- catch (error) {
395
- settle(() => reject(error instanceof Error ? error : new Error(String(error))));
396
- }
397
- }
398
- };
399
- // One message at a time, in the order they came: an answer counts only once `heard` has opened.
400
- let handling = Promise.resolve();
401
- room.net.on('message', (message) => {
402
- handling = handling.then(() => handle(message)).catch(() => { });
403
- });
404
- wait(params.findTimeoutMs ?? 10 * 60_000, 'The account home was not opened in time. Try again.');
405
- room.net.connect().catch(() => fail('Could not reach the relay.'));
406
- });
407
- }
408
- //# sourceMappingURL=connect-code.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-code.js","sourceRoot":"","sources":["../../src/session/connect-code.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AAInG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MA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