@minca/core 0.1.9 → 0.1.11

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 (195) hide show
  1. package/README.md +2 -2
  2. package/dist/identity/abilities.d.ts +3 -3
  3. package/dist/identity/abilities.d.ts.map +1 -1
  4. package/dist/identity/abilities.js +9 -11
  5. package/dist/identity/abilities.js.map +1 -1
  6. package/dist/identity/contact-key.d.ts +15 -15
  7. package/dist/identity/contact-key.d.ts.map +1 -1
  8. package/dist/identity/contact-key.js +21 -28
  9. package/dist/identity/contact-key.js.map +1 -1
  10. package/dist/identity/root-signer.d.ts +0 -5
  11. package/dist/identity/root-signer.d.ts.map +1 -1
  12. package/dist/identity/root-signer.js +0 -1
  13. package/dist/identity/root-signer.js.map +1 -1
  14. package/dist/inbox/inbox.d.ts +140 -0
  15. package/dist/inbox/inbox.d.ts.map +1 -0
  16. package/dist/inbox/inbox.js +212 -0
  17. package/dist/inbox/inbox.js.map +1 -0
  18. package/dist/inbox/index.d.ts +9 -0
  19. package/dist/inbox/index.d.ts.map +1 -0
  20. package/dist/inbox/index.js +7 -0
  21. package/dist/inbox/index.js.map +1 -0
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/network/mailbox.d.ts +4 -4
  27. package/dist/network/mailbox.d.ts.map +1 -1
  28. package/dist/network/mailbox.js +5 -5
  29. package/dist/network/mailbox.js.map +1 -1
  30. package/dist/node/actions.d.ts.map +1 -1
  31. package/dist/node/actions.js +28 -18
  32. package/dist/node/actions.js.map +1 -1
  33. package/dist/node/api.d.ts +11 -10
  34. package/dist/node/api.d.ts.map +1 -1
  35. package/dist/node/api.js +11 -10
  36. package/dist/node/api.js.map +1 -1
  37. package/dist/node/carrier.d.ts +11 -5
  38. package/dist/node/carrier.d.ts.map +1 -1
  39. package/dist/node/carrier.js +42 -1
  40. package/dist/node/carrier.js.map +1 -1
  41. package/dist/node/copy.d.ts +1 -1
  42. package/dist/node/copy.d.ts.map +1 -1
  43. package/dist/node/copy.js +10 -4
  44. package/dist/node/copy.js.map +1 -1
  45. package/dist/node/host.d.ts +2 -0
  46. package/dist/node/host.d.ts.map +1 -1
  47. package/dist/node/host.js +2 -0
  48. package/dist/node/host.js.map +1 -1
  49. package/dist/node/index.d.ts +1 -1
  50. package/dist/node/index.d.ts.map +1 -1
  51. package/dist/node/node.d.ts.map +1 -1
  52. package/dist/node/node.js +720 -542
  53. package/dist/node/node.js.map +1 -1
  54. package/dist/node/remote.d.ts +6 -5
  55. package/dist/node/remote.d.ts.map +1 -1
  56. package/dist/node/remote.js +140 -195
  57. package/dist/node/remote.js.map +1 -1
  58. package/dist/node/space-runtime.d.ts +2 -1
  59. package/dist/node/space-runtime.d.ts.map +1 -1
  60. package/dist/node/space-runtime.js +71 -84
  61. package/dist/node/space-runtime.js.map +1 -1
  62. package/dist/node/types.d.ts +84 -47
  63. package/dist/node/types.d.ts.map +1 -1
  64. package/dist/node/worker.d.ts +1 -1
  65. package/dist/node/worker.d.ts.map +1 -1
  66. package/dist/node/worker.js +10 -6
  67. package/dist/node/worker.js.map +1 -1
  68. package/dist/react/use-invite-link.d.ts +1 -1
  69. package/dist/react/use-invite-link.d.ts.map +1 -1
  70. package/dist/react/use-invite-link.js +18 -11
  71. package/dist/react/use-invite-link.js.map +1 -1
  72. package/dist/records/loose.d.ts +52 -0
  73. package/dist/records/loose.d.ts.map +1 -0
  74. package/dist/records/loose.js +86 -0
  75. package/dist/records/loose.js.map +1 -0
  76. package/dist/schema/version.d.ts +2 -0
  77. package/dist/schema/version.d.ts.map +1 -1
  78. package/dist/schema/version.js +2 -1
  79. package/dist/schema/version.js.map +1 -1
  80. package/dist/schemas/choosing.d.ts +19 -0
  81. package/dist/schemas/choosing.d.ts.map +1 -0
  82. package/dist/schemas/choosing.js +69 -0
  83. package/dist/schemas/choosing.js.map +1 -0
  84. package/dist/schemas/contacts.d.ts +34 -87
  85. package/dist/schemas/contacts.d.ts.map +1 -1
  86. package/dist/schemas/contacts.js +32 -76
  87. package/dist/schemas/contacts.js.map +1 -1
  88. package/dist/schemas/index.d.ts +2 -2
  89. package/dist/schemas/index.d.ts.map +1 -1
  90. package/dist/schemas/index.js +1 -1
  91. package/dist/schemas/index.js.map +1 -1
  92. package/dist/schemas/library/annotations.d.ts +17 -285
  93. package/dist/schemas/library/annotations.d.ts.map +1 -1
  94. package/dist/schemas/library/annotations.js +9 -65
  95. package/dist/schemas/library/annotations.js.map +1 -1
  96. package/dist/schemas/library/community.d.ts +9 -17
  97. package/dist/schemas/library/community.d.ts.map +1 -1
  98. package/dist/schemas/library/community.js +5 -5
  99. package/dist/schemas/library/community.js.map +1 -1
  100. package/dist/schemas/library/life.d.ts +3 -3
  101. package/dist/schemas/library/life.d.ts.map +1 -1
  102. package/dist/schemas/library/life.js +2 -2
  103. package/dist/schemas/library/life.js.map +1 -1
  104. package/dist/schemas/library/media.d.ts +148 -541
  105. package/dist/schemas/library/media.d.ts.map +1 -1
  106. package/dist/schemas/library/media.js +28 -64
  107. package/dist/schemas/library/media.js.map +1 -1
  108. package/dist/schemas/library/money.d.ts +8 -8
  109. package/dist/schemas/library/money.d.ts.map +1 -1
  110. package/dist/schemas/library/money.js +4 -4
  111. package/dist/schemas/library/money.js.map +1 -1
  112. package/dist/schemas/library/planning.d.ts +23 -87
  113. package/dist/schemas/library/planning.d.ts.map +1 -1
  114. package/dist/schemas/library/planning.js +10 -26
  115. package/dist/schemas/library/planning.js.map +1 -1
  116. package/dist/schemas/library/publishing.d.ts +14 -14
  117. package/dist/schemas/library/publishing.d.ts.map +1 -1
  118. package/dist/schemas/library/publishing.js +7 -7
  119. package/dist/schemas/library/publishing.js.map +1 -1
  120. package/dist/schemas/library/social.d.ts +2 -2
  121. package/dist/schemas/library/social.d.ts.map +1 -1
  122. package/dist/schemas/library/social.js +1 -1
  123. package/dist/schemas/library/social.js.map +1 -1
  124. package/dist/schemas/standard.d.ts +1 -1
  125. package/dist/schemas/standard.d.ts.map +1 -1
  126. package/dist/schemas/standard.js +3 -3
  127. package/dist/schemas/standard.js.map +1 -1
  128. package/dist/session/auth.d.ts +20 -0
  129. package/dist/session/auth.d.ts.map +1 -1
  130. package/dist/session/auth.js +81 -64
  131. package/dist/session/auth.js.map +1 -1
  132. package/dist/session/connect.d.ts +50 -8
  133. package/dist/session/connect.d.ts.map +1 -1
  134. package/dist/session/connect.js +91 -27
  135. package/dist/session/connect.js.map +1 -1
  136. package/dist/session/connection.d.ts +39 -6
  137. package/dist/session/connection.d.ts.map +1 -1
  138. package/dist/session/connection.js +107 -38
  139. package/dist/session/connection.js.map +1 -1
  140. package/dist/session/hosting.d.ts +15 -0
  141. package/dist/session/hosting.d.ts.map +1 -1
  142. package/dist/session/hosting.js +55 -4
  143. package/dist/session/hosting.js.map +1 -1
  144. package/dist/session/index.d.ts +5 -5
  145. package/dist/session/index.d.ts.map +1 -1
  146. package/dist/session/index.js +2 -2
  147. package/dist/session/index.js.map +1 -1
  148. package/dist/space/account-registry.d.ts +36 -4
  149. package/dist/space/account-registry.d.ts.map +1 -1
  150. package/dist/space/account-registry.js +30 -3
  151. package/dist/space/account-registry.js.map +1 -1
  152. package/dist/space/invitation.d.ts +61 -0
  153. package/dist/space/invitation.d.ts.map +1 -0
  154. package/dist/space/invitation.js +84 -0
  155. package/dist/space/invitation.js.map +1 -0
  156. package/dist/space/invite-link.d.ts +64 -0
  157. package/dist/space/invite-link.d.ts.map +1 -0
  158. package/dist/space/invite-link.js +212 -0
  159. package/dist/space/invite-link.js.map +1 -0
  160. package/dist/space/roles.d.ts +59 -140
  161. package/dist/space/roles.d.ts.map +1 -1
  162. package/dist/space/roles.js +328 -427
  163. package/dist/space/roles.js.map +1 -1
  164. package/dist/space/space-manager.d.ts +21 -6
  165. package/dist/space/space-manager.d.ts.map +1 -1
  166. package/dist/space/space-manager.js +40 -23
  167. package/dist/space/space-manager.js.map +1 -1
  168. package/dist/types.d.ts +2 -0
  169. package/dist/types.d.ts.map +1 -1
  170. package/dist/types.js.map +1 -1
  171. package/docs/README.md +2 -2
  172. package/docs/actions.md +40 -40
  173. package/docs/agents.md +2 -2
  174. package/docs/automations.md +2 -2
  175. package/docs/blueprints-and-guides.md +61 -1
  176. package/docs/bots.md +1 -1
  177. package/docs/building-an-app.md +2 -2
  178. package/docs/contacts.md +48 -69
  179. package/docs/inbox.md +145 -0
  180. package/docs/node.md +135 -76
  181. package/docs/query-format.md +1 -1
  182. package/docs/sign-in.md +16 -9
  183. package/docs/spaces.md +33 -5
  184. package/docs/standard-library.md +111 -86
  185. package/docs/storage.md +1 -1
  186. package/package.json +5 -5
  187. package/dist/doors/doors.d.ts +0 -140
  188. package/dist/doors/doors.d.ts.map +0 -1
  189. package/dist/doors/doors.js +0 -226
  190. package/dist/doors/doors.js.map +0 -1
  191. package/dist/doors/index.d.ts +0 -9
  192. package/dist/doors/index.d.ts.map +0 -1
  193. package/dist/doors/index.js +0 -7
  194. package/dist/doors/index.js.map +0 -1
  195. package/docs/doors.md +0 -151
package/README.md CHANGED
@@ -229,12 +229,12 @@ One npm workspace. Everything imports the protocol as `@minca/core`.
229
229
  | Identity: the seed, recovery code, wraps, passkeys, UCAN, root signers | [sign-in](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/sign-in.md), [node](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/node.md#root-signers-and-notes) | [01 Identity](https://github.com/leifriksheim/minca/blob/main/spec/01-identity.md) |
230
230
  | Spaces: the constitution, founders, roles and grants, invites, successors, key changes, profiles | [spaces](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/spaces.md) | [03 Spaces](https://github.com/leifriksheim/minca/blob/main/spec/03-spaces.md) |
231
231
  | Collections, schemas, rules, contracts and computed fields, links, queries, the standard library | [collections](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/collections.md), [contracts](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/contracts.md), [computed fields](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/computed.md), [query format](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/query-format.md), [standard library](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/standard-library.md), [blueprints and guides](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/blueprints-and-guides.md) | [02 Records](https://github.com/leifriksheim/minca/blob/main/spec/02-records.md), [09 Contracts](https://github.com/leifriksheim/minca/blob/main/spec/09-contracts.md) |
232
- | Calls, contacts, doors, direct messages | [calls](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/calls.md), [contacts](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/contacts.md), [doors](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/doors.md), [direct messages](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/direct-messages.md) | [07 Doors](https://github.com/leifriksheim/minca/blob/main/spec/07-doors.md), [04 Network](https://github.com/leifriksheim/minca/blob/main/spec/04-network.md) |
232
+ | Calls, contacts, the inbox, direct messages | [calls](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/calls.md), [contacts](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/contacts.md), [inbox](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/inbox.md), [direct messages](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/direct-messages.md) | [07 Inbox](https://github.com/leifriksheim/minca/blob/main/spec/07-inbox.md), [04 Network](https://github.com/leifriksheim/minca/blob/main/spec/04-network.md) |
233
233
  | Network: the relay, TURN, meeting peers, introductions, pairing a phone | [node](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/node.md#the-network), [packages/relay](https://github.com/leifriksheim/minca/blob/main/packages/relay/README.md) | [04 Network](https://github.com/leifriksheim/minca/blob/main/spec/04-network.md) |
234
234
  | Sync, storage adapters, data folders and locking them, mirrors | [storage](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/storage.md) | [05 Sync and storage](https://github.com/leifriksheim/minca/blob/main/spec/05-sync-and-storage.md) |
235
235
  | Hosting: keeping spaces online, payment, bots a host runs | [packages/cli](https://github.com/leifriksheim/minca/blob/main/packages/cli/README.md) | [08 Hosting](https://github.com/leifriksheim/minca/blob/main/spec/08-hosting.md) |
236
236
  | The CLI, the always-on node, agents and MCP | [packages/cli](https://github.com/leifriksheim/minca/blob/main/packages/cli/README.md), [agents](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/agents.md) | [06 Nodes and sessions](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md) |
237
- | The app, Liquid and mini apps | [apps/example](https://github.com/leifriksheim/minca/blob/main/apps/example/README.md) | — |
237
+ | The app, and its ready-made apps | [apps/example](https://github.com/leifriksheim/minca/blob/main/apps/example/README.md), [apps/liquid](https://github.com/leifriksheim/minca/blob/main/apps/liquid/README.md) | — |
238
238
  | Planned work | [docs](https://github.com/leifriksheim/minca/blob/main/packages/core/docs/README.md#planned-in-the-library) | [spec](https://github.com/leifriksheim/minca/blob/main/spec/README.md) |
239
239
 
240
240
  </details>
@@ -17,9 +17,7 @@ export declare const writeRequirement: (space: string, collection: string) => Re
17
17
  * defines; `/access/change` for anything else, with the version's own.
18
18
  */
19
19
  export declare const accessRequirement: (space: string, collection: string, key: string) => Requirement;
20
- /** What a write in one of the account's own spaces needs besides */
21
- export declare const accountSpaceRequirement: (space: string, collection: string) => Requirement;
22
- /** What acting for the whole account needs — a knock, opening a door: `/account/write`, no arguments */
20
+ /** What acting as the account itself needs: `/account/write` about the whole account, no arguments */
23
21
  export declare const ACCOUNT_REQUIREMENT: Requirement;
24
22
  /**
25
23
  * Whether a proof grants a requirement, by what its note says. A version
@@ -28,6 +26,8 @@ export declare const ACCOUNT_REQUIREMENT: Requirement;
28
26
  * sound is the capability gate's question.
29
27
  */
30
28
  export declare function noteGrants(proof: unknown, required: Requirement): boolean;
29
+ /** Whether a proof lets its key act as the account itself (spec 01 §8). True with no proof: the account signed. */
30
+ export declare const actsForAccount: (proof: unknown) => boolean;
31
31
  /** Whether a note lets its key write records somewhere. False for anything unreadable. */
32
32
  export declare function writesRecords(note: unknown): boolean;
33
33
  /** Whether a note grants records and nothing more: its command is under `/record`. False for anything unreadable. */
@@ -1 +1 @@
1
- {"version":3,"file":"abilities.d.ts","sourceRoot":"","sources":["../../src/identity/abilities.ts"],"names":[],"mappings":"AAoBA,OAAO,EAA8C,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC1G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,oBAAoB;AACpB,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,+BAA+B;AAC/B,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,cAAc,uBAAuB,CAAC;AACnD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAKhD,+GAA+G;AAC/G,eAAO,MAAM,gBAAgB,UAAW,MAAM,cAAc,MAAM,KAAG,WAInE,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,cAAc,MAAM,OAAO,MAAM,KAAG,WAOlB,CAAC;AAElE,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,UAAW,MAAM,cAAc,MAAM,KAAG,WAI1E,CAAC;AAEH,wGAAwG;AACxG,eAAO,MAAM,mBAAmB,EAAE,WAIhC,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAIzE;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAGpD;AAED,qHAAqH;AACrH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAGxD;AAED,2HAA2H;A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EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAIzE;AAED,mHAAmH;AACnH,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,OAAiD,CAAC;AAElG,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAGpD;AAED,qHAAqH;AACrH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAGxD;AAED,2HAA2H;AAC3H,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,SAAS,CAM7F;AAoBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,KAAK,CAe1E"}
@@ -11,11 +11,13 @@
11
11
  * - `/collection/define`: define, change or remove a space's collections;
12
12
  * - `/access/change`: anything else in the access history — roles, members,
13
13
  * invites, revocations, the space's key, relays and keepers;
14
- * - `/account/write`: the account's own spaces (its list of spaces, a
15
- * carrier's passes) and its doors.
14
+ * - `/account/write`, about the whole account: anything about the account
15
+ * itself — its own spaces (its list of spaces, a carrier's passes, its
16
+ * inbox, its knocks), its own place in any space, and its other keys.
16
17
  *
17
- * A person's own sessions, and apps given write, get `/`. A key the account
18
- * trusts less gets `/record`, and proposes what it can't do.
18
+ * So a key is a device or an app by what its note says: a note for `/` about
19
+ * the whole account acts as the account; anything narrower acts in spaces.
20
+ * A key the account trusts less gets `/record`, and proposes what it can't do.
19
21
  */
20
22
  import { DEFINITION_COLLECTION } from '../space/roles.js';
21
23
  import { commandCovers, noteCovers, parseDelegation } from './ucan.js';
@@ -48,13 +50,7 @@ export const accessRequirement = (space, collection, key) => collection === DEFI
48
50
  args: { collection: key.startsWith(DEFINITION_KEY) ? key.slice(DEFINITION_KEY.length) : key, space },
49
51
  }
50
52
  : { space, cmd: ACCESS_COMMAND, args: { collection, space } };
51
- /** What a write in one of the account's own spaces needs besides */
52
- export const accountSpaceRequirement = (space, collection) => ({
53
- space,
54
- cmd: ACCOUNT_COMMAND,
55
- args: { collection, space },
56
- });
57
- /** What acting for the whole account needs — a knock, opening a door: `/account/write`, no arguments */
53
+ /** What acting as the account itself needs: `/account/write` about the whole account, no arguments */
58
54
  export const ACCOUNT_REQUIREMENT = Object.freeze({
59
55
  space: null,
60
56
  cmd: ACCOUNT_COMMAND,
@@ -72,6 +68,8 @@ export function noteGrants(proof, required) {
72
68
  const note = parseDelegation(proof);
73
69
  return note !== null && noteCovers(note, required);
74
70
  }
71
+ /** Whether a proof lets its key act as the account itself (spec 01 §8). True with no proof: the account signed. */
72
+ export const actsForAccount = (proof) => noteGrants(proof, ACCOUNT_REQUIREMENT);
75
73
  /** Whether a note lets its key write records somewhere. False for anything unreadable. */
76
74
  export function writesRecords(note) {
77
75
  const cmd = parseDelegation(note)?.payload.cmd;
@@ -1 +1 @@
1
- {"version":3,"file":"abilities.js","sourceRoot":"","sources":["../../src/identity/abilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAqC,MAAM,WAAW,CAAC;AAG1G,oBAAoB;AACpB,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B,+BAA+B;AAC/B,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AACzC,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAC7C,MAAM,CAAC,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AM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE,CAAC;QAC5B,wDAAwD;QACxD,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY;YAAE,OAAO,EAAE,CAAC;QACvF,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
@@ -21,31 +21,31 @@ export declare function deriveContactKeyBytes(seed: Uint8Array): Promise<Uint8Ar
21
21
  */
22
22
  export declare function deriveMemberKeyBytes(accountKey: Uint8Array, spaceId: string): Promise<Uint8Array>;
23
23
  /**
24
- * A **door key**: the key a door's knocks are sealed to (`doors/doors.ts`).
25
- * Derived from the contact key and the door's id, so every device and app
26
- * holding the contact key opens the same doors, and a new door is a new id.
24
+ * An **inbox key**: the key knocks on the account's inbox are sealed to
25
+ * (`inbox/inbox.ts`, spec 07 §1). Derived from the contact key and the
26
+ * inbox's generation, so every device and app holding the contact key opens
27
+ * the same inbox, and a new inbox is a new `gen`.
27
28
  *
28
29
  * Not the contact key itself: that one's public half is on your profile in
29
- * every space you write in, and a door is handed to people who may not know
30
- * who you are yet. A door key says nothing about the account behind it.
30
+ * every space you write in, and an inbox is handed to people who may not know
31
+ * who you are yet. An inbox key says nothing about the account behind it.
31
32
  * @param contactKey The contact key's private scalar (`deriveContactKeyBytes`)
32
- * @param doorId The door's id, as its `std.door` record names it
33
33
  */
34
- export declare function deriveDoorKeyBytes(contactKey: Uint8Array, doorId: string): Promise<Uint8Array>;
34
+ export declare function deriveInboxKeyBytes(contactKey: Uint8Array, gen: number): Promise<Uint8Array>;
35
35
  /**
36
- * A door's **signing key**: what proves you own a door, without saying whose
37
- * it is — to a relay, when clearing the door's mailbox, and to someone who
38
- * knocked, when you answer. Separate from the door key, which only opens
39
- * knocks: one key should not both sign and decrypt.
36
+ * An inbox's **signing key**: what signs the inbox, and proves to a relay
37
+ * clearing its mailbox that it is the owner, without saying whose it is.
38
+ * Separate from the inbox key, which only opens knocks: one key should not
39
+ * both sign and decrypt.
40
40
  */
41
- export declare function deriveDoorSignKeyBytes(contactKey: Uint8Array, doorId: string): Promise<Uint8Array>;
41
+ export declare function deriveInboxSignKeyBytes(contactKey: Uint8Array, gen: number): Promise<Uint8Array>;
42
+ /** A private scalar as a key to sign with (ECDSA), for what an inbox's signing key signs as a version */
43
+ export declare function signingKeyOf(secret: Uint8Array): Promise<CryptoKey>;
42
44
  /**
43
45
  * Signs with a P-256 private scalar: ECDSA over SHA-256, 64 bytes r ‖ s,
44
- * base64url — for door signing keys.
46
+ * base64url — for an inbox's signing key.
45
47
  */
46
48
  export declare function signWithScalar(secret: Uint8Array, data: Uint8Array): Promise<string>;
47
- /** Checks what `signWithScalar` signed, against a compressed public key (base64url) */
48
- export declare function verifyWithPoint(publicKey: string, data: Uint8Array, signature: string): Promise<boolean>;
49
49
  /** The public half, from the private scalar */
50
50
  export declare function contactPublicKey(secret: Uint8Array): string;
51
51
  /** Whether a string is a contact key's public half: a point on P-256 */
@@ -1 +1 @@
1
- {"version":3,"file":"contact-key.d.ts","sourceRoot":"","sources":["../../src/identity/contact-key.ts"],"names":[],"mappings":"AAiCA,MAAM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M,WAAW,cAAc;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;CAChC;AA8BD;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAEjF;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEvG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAElG;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEtG;AAED,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAEnE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAO1F;AAED,+CAA+C;AAC/C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAE3D;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAQlE;AAED,sEAAsE;AACtE,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAGhF"}
@@ -24,8 +24,8 @@ import { hkdf } from './hkdf.js';
24
24
  /** Domain separation for the contact key. Changing it changes every account's contact key. */
25
25
  const CONTACT_KEY_INFO = 'minca/p256-contact-key/v1';
26
26
  const MEMBER_KEY_INFO = 'minca/p256-member-key/v1';
27
- const DOOR_KEY_INFO = 'minca/p256-door-key/v1';
28
- const DOOR_SIGN_KEY_INFO = 'minca/p256-door-sign-key/v1';
27
+ const INBOX_KEY_INFO = 'minca/p256-inbox-key/v1';
28
+ const INBOX_SIGN_KEY_INFO = 'minca/p256-inbox-sign-key/v1';
29
29
  /** 48 bytes reduce to a P-256 scalar without bias, as for the root key (`crypto-p256.ts`) */
30
30
  const P256_SEED_BYTES = 48;
31
31
  /** A P-256 scalar from key material, under its own label */
@@ -65,47 +65,40 @@ export async function deriveMemberKeyBytes(accountKey, spaceId) {
65
65
  return deriveScalar(accountKey, `${MEMBER_KEY_INFO}|${spaceId}`);
66
66
  }
67
67
  /**
68
- * A **door key**: the key a door's knocks are sealed to (`doors/doors.ts`).
69
- * Derived from the contact key and the door's id, so every device and app
70
- * holding the contact key opens the same doors, and a new door is a new id.
68
+ * An **inbox key**: the key knocks on the account's inbox are sealed to
69
+ * (`inbox/inbox.ts`, spec 07 §1). Derived from the contact key and the
70
+ * inbox's generation, so every device and app holding the contact key opens
71
+ * the same inbox, and a new inbox is a new `gen`.
71
72
  *
72
73
  * Not the contact key itself: that one's public half is on your profile in
73
- * every space you write in, and a door is handed to people who may not know
74
- * who you are yet. A door key says nothing about the account behind it.
74
+ * every space you write in, and an inbox is handed to people who may not know
75
+ * who you are yet. An inbox key says nothing about the account behind it.
75
76
  * @param contactKey The contact key's private scalar (`deriveContactKeyBytes`)
76
- * @param doorId The door's id, as its `std.door` record names it
77
77
  */
78
- export async function deriveDoorKeyBytes(contactKey, doorId) {
79
- return deriveScalar(contactKey, `${DOOR_KEY_INFO}|${doorId}`);
78
+ export async function deriveInboxKeyBytes(contactKey, gen) {
79
+ return deriveScalar(contactKey, `${INBOX_KEY_INFO}|${gen}`);
80
80
  }
81
81
  /**
82
- * A door's **signing key**: what proves you own a door, without saying whose
83
- * it is — to a relay, when clearing the door's mailbox, and to someone who
84
- * knocked, when you answer. Separate from the door key, which only opens
85
- * knocks: one key should not both sign and decrypt.
82
+ * An inbox's **signing key**: what signs the inbox, and proves to a relay
83
+ * clearing its mailbox that it is the owner, without saying whose it is.
84
+ * Separate from the inbox key, which only opens knocks: one key should not
85
+ * both sign and decrypt.
86
86
  */
87
- export async function deriveDoorSignKeyBytes(contactKey, doorId) {
88
- return deriveScalar(contactKey, `${DOOR_SIGN_KEY_INFO}|${doorId}`);
87
+ export async function deriveInboxSignKeyBytes(contactKey, gen) {
88
+ return deriveScalar(contactKey, `${INBOX_SIGN_KEY_INFO}|${gen}`);
89
+ }
90
+ /** A private scalar as a key to sign with (ECDSA), for what an inbox's signing key signs as a version */
91
+ export function signingKeyOf(secret) {
92
+ return importScalar(secret, 'ECDSA', ['sign']);
89
93
  }
90
94
  /**
91
95
  * Signs with a P-256 private scalar: ECDSA over SHA-256, 64 bytes r ‖ s,
92
- * base64url — for door signing keys.
96
+ * base64url — for an inbox's signing key.
93
97
  */
94
98
  export async function signWithScalar(secret, data) {
95
99
  const key = await importScalar(secret, 'ECDSA', ['sign']);
96
100
  return base64UrlEncode(new Uint8Array(await globalThis.crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, key, bufferSource(data))));
97
101
  }
98
- /** Checks what `signWithScalar` signed, against a compressed public key (base64url) */
99
- export async function verifyWithPoint(publicKey, data, signature) {
100
- try {
101
- const point = p256.Point.fromBytes(base64UrlDecode(publicKey)).toBytes(false);
102
- const key = await globalThis.crypto.subtle.importKey('raw', bufferSource(point), { name: 'ECDSA', namedCurve: 'P-256' }, false, ['verify']);
103
- return await globalThis.crypto.subtle.verify({ name: 'ECDSA', hash: 'SHA-256' }, key, bufferSource(base64UrlDecode(signature)), bufferSource(data));
104
- }
105
- catch {
106
- return false;
107
- }
108
- }
109
102
  /** The public half, from the private scalar */
110
103
  export function contactPublicKey(secret) {
111
104
  return base64UrlEncode(p256.getPublicKey(secret, true));
@@ -1 +1 @@
1
- {"version":3,"file":"contact-key.js","sourceRoot":"","sources":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identity being acted for */
26
26
  readonly did: string;
27
- /**
28
- * Where the key lives. Worth showing: "your key is in your account home" and
29
- * "your key is in this tab" are different promises to make to someone.
30
- */
31
- readonly custody: 'local' | 'remote';
32
27
  /** Signs a note from the identity to a key: the session's, an app's, a program's */
33
28
  delegate(params: NoteRequest): Promise<Delegation>;
34
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"root-signer.d.ts","sourceRoot":"","sources":["../../src/identity/root-signer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IACrC,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,EAChD,QAAQ,EAAE,cAAc,GACvB,UAAU,CAmBZ"}
1
+ {"version":3,"file":"root-signer.d.ts","sourceRoot":"","sources":["../../src/identity/root-signer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8FAA8F;IAC9F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,EAChD,QAAQ,EAAE,cAAc,GACvB,UAAU,CAkBZ"}
@@ -14,7 +14,6 @@ import { issueDelegation } from './ucan.js';
14
14
  export function createLocalRootSigner(identity, provider) {
15
15
  return Object.freeze({
16
16
  did: identity.did,
17
- custody: 'local',
18
17
  async delegate(params) {
19
18
  return issueDelegation({
20
19
  issuer: { did: identity.did, privateKey: identity.privateKey },
@@ -1 +1 @@
1
- {"version":3,"file":"root-signer.js","sourceRoot":"","sources":["../../src/identity/root-signer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAmB,MAAM,WAAW,CAAC;AA8B7D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgD,EAChD,QAAwB;IAExB,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,OAAO,EAAE,OAAgB;QAEzB,KAAK,CAAC,QAAQ,CAAC,MAAmB;YAChC,OAAO,eAAe,CACpB;gBACE,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE;gBAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnD,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,EACD,QAAQ,CACT,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"root-signer.js","sourceRoot":"","sources":["../../src/identity/root-signer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAmB,MAAM,WAAW,CAAC;AAyB7D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgD,EAChD,QAAwB;IAExB,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,EAAE,QAAQ,CAAC,GAAG;QAEjB,KAAK,CAAC,QAAQ,CAAC,MAAmB;YAChC,OAAO,eAAe,CACpB;gBACE,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE;gBAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnD,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,EACD,QAAQ,CACT,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @module inbox
3
+ * The inbox: how someone you share no space with can ask to become your
4
+ * contact, and the knock they leave there (spec 07).
5
+ *
6
+ * A DID is a name, not an address — knowing it must not be enough to reach
7
+ * you. An account's **inbox** is an address it hands out on purpose: a key
8
+ * knocks are sealed to, a signing key that proves the inbox is its own, and
9
+ * up to three mailboxes that hold knocks. Both keys are derived from the
10
+ * contact key and a generation, `gen`, so every device opens the same inbox,
11
+ * and a new `gen` is a new inbox nobody can tie to the old one. Neither is the
12
+ * contact key, whose public half is on the account's profile in every space:
13
+ * an inbox says nothing about the account behind it.
14
+ *
15
+ * It travels as a **`sys.inbox`** loose version (spec 02 §3.5), signed by its
16
+ * own signing key, in a link, a QR code or a bio. Someone with it **knocks**:
17
+ * makes a private space for the two of them and leaves a **`sys.knock`**,
18
+ * signed under their account's note and carrying the signed invitation to
19
+ * that space, sealed to the inbox key. The same knock, sealed to the contact
20
+ * key instead, goes in a `std.contact-request` in a space both belong to
21
+ * (`packages/core/docs/contacts.md`).
22
+ * Joining the space is the answer: only the holder of the key could open it.
23
+ *
24
+ * ```
25
+ * inbox = sys.inbox { key, sign, gen, places, name? } — author: did:key of sign
26
+ * knock = sys.knock { invite, secret, name, note? }, to — under a note with /account/write
27
+ * sealed = HPKE(to, "minca/mail/v1", { to }, JSON(knock))
28
+ * topic = base64url(SHA-256("minca/inbox-topic/v1|" + sign))
29
+ * ```
30
+ */
31
+ import type { CryptoProvider, Version } from '../types.js';
32
+ import { type LooseSigner } from '../records/loose.js';
33
+ /** The collection an inbox is a loose version in */
34
+ export declare const INBOX_COLLECTION = "sys.inbox";
35
+ /** The collection a knock is a loose version in */
36
+ export declare const KNOCK_COLLECTION = "sys.knock";
37
+ /** An inbox names at most this many mailboxes: enough that one going away doesn't matter */
38
+ export declare const MAX_INBOX_PLACES = 3;
39
+ /** How long a knock waits in a mailbox, and so how old one may be when opened */
40
+ export declare const KNOCK_TTL_SECONDS: number;
41
+ /**
42
+ * How far a knock's own time may be before when the relay took it. A knock is
43
+ * dropped as soon as it is signed, so its time is checked against the relay's
44
+ * — which the knocker can't choose — and a note that ran out can't be used by
45
+ * dating a knock back to when it was good.
46
+ */
47
+ export declare const KNOCK_DROP_WINDOW_SECONDS = 600;
48
+ /** What an inbox says: where to knock, and who the owner says they are */
49
+ export interface InboxBody {
50
+ /** The inbox key's public half: a compressed P-256 point, base64url. Knocks are sealed to it. */
51
+ readonly key: string;
52
+ /** The inbox's signing key's public half, likewise. It signs the inbox; its hash is the topic. */
53
+ readonly sign: string;
54
+ /** Which inbox of the account this is: a new one is a new number */
55
+ readonly gen: number;
56
+ /** Mailboxes that hold its knocks, 1–3 */
57
+ readonly places: ReadonlyArray<string>;
58
+ /** Who the owner says they are — shown to the knocker, and proves nothing */
59
+ readonly name?: string;
60
+ }
61
+ /** What a knock carries */
62
+ export interface KnockBody {
63
+ /** The signed invitation to the space for two (spec 03 §7.4) */
64
+ readonly invite: Version;
65
+ /** Its invite secret, base64url: it opens the editor role there */
66
+ readonly secret: string;
67
+ /** The name the knocker gives; nothing vouches for it */
68
+ readonly name: string;
69
+ readonly note?: string;
70
+ }
71
+ /** A knock that opened and checked out */
72
+ export interface OpenedKnock {
73
+ /** The knocker's account */
74
+ readonly from: string;
75
+ readonly name: string;
76
+ readonly note?: string;
77
+ /** The invite to the space for two, with its secret: what accepting joins */
78
+ readonly invite: string;
79
+ /** The id of the space for two */
80
+ readonly pairSpace: string;
81
+ /** When it was signed, ms */
82
+ readonly at: number;
83
+ }
84
+ /** Cuts text to at most `max` characters without splitting one (a surrogate pair stays whole) */
85
+ export declare function clip(text: string, max: number): string;
86
+ /** The did:key of an inbox's signing key: who an inbox is signed by */
87
+ export declare const inboxAuthor: (sign: string) => string;
88
+ /** Why an inbox's body is not one, or null */
89
+ export declare function inboxProblem(body: unknown): string | null;
90
+ /**
91
+ * Signs an inbox with its own signing key, which signs for itself: no note,
92
+ * so nothing in it names the account.
93
+ * @param signKey The signing key's private scalar
94
+ * @returns The inbox as its code: what goes in a link or a QR code
95
+ */
96
+ export declare function encodeInbox(signKey: Uint8Array, body: InboxBody, provider: CryptoProvider): Promise<string>;
97
+ /**
98
+ * Reads an inbox's code, or a link carrying one after `#inbox=` or `inbox=`,
99
+ * and checks it: signed by the signing key it names, and well formed.
100
+ * @throws When it isn't one, saying why
101
+ */
102
+ export declare function readInbox(text: string, provider: CryptoProvider): Promise<InboxBody>;
103
+ /**
104
+ * The mailbox topic of an inbox: a hash of its signing key. A relay can't tell
105
+ * whose inbox it is, and can check that whoever clears it holds that key.
106
+ */
107
+ export declare function inboxTopic(sign: string): Promise<string>;
108
+ /**
109
+ * What an inbox's owner signs to clear knocks from a relay's mailbox: the
110
+ * topic, the relay's one-time challenge, and which knocks (`*` for all).
111
+ */
112
+ export declare const purgeMessage: (topic: string, nonce: string, ids: ReadonlyArray<string> | null) => Uint8Array<ArrayBuffer>;
113
+ /** Signs a relay's purge challenge with the inbox's signing key */
114
+ export declare function signPurge(signKey: Uint8Array, topic: string, nonce: string, ids: ReadonlyArray<string> | null): Promise<string>;
115
+ /** A mailbox knock's id: the hash of its sealed blob, as relays file it */
116
+ export declare function knockId(blob: string): Promise<string>;
117
+ /**
118
+ * Makes a knock: signed by the session key under its account's note, and
119
+ * sealed to `to`, an inbox key or a contact key.
120
+ * @param invite The signed invitation to the space for two, and its secret
121
+ * @returns The sealed blob, for a mailbox or a contact request
122
+ */
123
+ export declare function sealKnock(to: string, knock: {
124
+ readonly invite: Version;
125
+ readonly secret: Uint8Array;
126
+ readonly name: string;
127
+ readonly note?: string;
128
+ }, signer: LooseSigner, provider: CryptoProvider): Promise<string>;
129
+ /**
130
+ * Opens a knock and checks it through (spec 07 §6): sealed to one of these
131
+ * keys and naming it; signed under a note from its account that may write for
132
+ * the whole account, valid when it was signed; recent; and carrying a signed
133
+ * invitation from the same account to a private space that account alone
134
+ * founded.
135
+ * @param keys The private scalars it may be sealed to: the inbox keys, or the contact key
136
+ * @param receivedAt For a mailbox, when the relay took it, ms; null for a contact request
137
+ * @returns The knock, or null when it is anything less
138
+ */
139
+ export declare function openKnock(keys: ReadonlyArray<Uint8Array>, blob: string, receivedAt: number | null, provider: CryptoProvider): Promise<OpenedKnock | null>;
140
+ //# sourceMappingURL=inbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../src/inbox/inbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAY3D,OAAO,EAAmD,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQxG,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAC5C,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,iFAAiF;AACjF,eAAO,MAAM,iBAAiB,QAAiB,CAA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