@minca/core 0.1.15 → 0.1.16

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 (427) hide show
  1. package/README.md +2 -2
  2. package/dist/elements/auth-styles.d.ts +1 -1
  3. package/dist/elements/auth-styles.d.ts.map +1 -1
  4. package/dist/elements/auth-styles.js +21 -4
  5. package/dist/elements/auth-styles.js.map +1 -1
  6. package/dist/elements/minca-auth.d.ts.map +1 -1
  7. package/dist/elements/minca-auth.js +151 -57
  8. package/dist/elements/minca-auth.js.map +1 -1
  9. package/dist/identity/abilities.d.ts +2 -0
  10. package/dist/identity/abilities.d.ts.map +1 -1
  11. package/dist/identity/abilities.js +2 -0
  12. package/dist/identity/abilities.js.map +1 -1
  13. package/dist/identity/account-vault.d.ts +15 -71
  14. package/dist/identity/account-vault.d.ts.map +1 -1
  15. package/dist/identity/account-vault.js +45 -104
  16. package/dist/identity/account-vault.js.map +1 -1
  17. package/dist/identity/channel.d.ts +3 -9
  18. package/dist/identity/channel.d.ts.map +1 -1
  19. package/dist/identity/channel.js +42 -42
  20. package/dist/identity/channel.js.map +1 -1
  21. package/dist/identity/contact-key.d.ts +14 -29
  22. package/dist/identity/contact-key.d.ts.map +1 -1
  23. package/dist/identity/contact-key.js +31 -51
  24. package/dist/identity/contact-key.js.map +1 -1
  25. package/dist/identity/crypto-p256.d.ts.map +1 -1
  26. package/dist/identity/crypto-p256.js +39 -53
  27. package/dist/identity/crypto-p256.js.map +1 -1
  28. package/dist/identity/hpke.d.ts.map +1 -1
  29. package/dist/identity/hpke.js +19 -19
  30. package/dist/identity/hpke.js.map +1 -1
  31. package/dist/identity/identity-manager.d.ts.map +1 -1
  32. package/dist/identity/identity-manager.js +1 -2
  33. package/dist/identity/identity-manager.js.map +1 -1
  34. package/dist/identity/policy.d.ts.map +1 -1
  35. package/dist/identity/policy.js +35 -61
  36. package/dist/identity/policy.js.map +1 -1
  37. package/dist/identity/recovery-code.d.ts +2 -8
  38. package/dist/identity/recovery-code.d.ts.map +1 -1
  39. package/dist/identity/recovery-code.js +4 -11
  40. package/dist/identity/recovery-code.js.map +1 -1
  41. package/dist/identity/root-signer.d.ts +1 -6
  42. package/dist/identity/root-signer.d.ts.map +1 -1
  43. package/dist/identity/root-signer.js +12 -15
  44. package/dist/identity/root-signer.js.map +1 -1
  45. package/dist/identity/ucan.d.ts.map +1 -1
  46. package/dist/identity/ucan.js +48 -39
  47. package/dist/identity/ucan.js.map +1 -1
  48. package/dist/identity/webauthn.d.ts +6 -11
  49. package/dist/identity/webauthn.d.ts.map +1 -1
  50. package/dist/identity/webauthn.js +18 -30
  51. package/dist/identity/webauthn.js.map +1 -1
  52. package/dist/inbox/inbox.d.ts.map +1 -1
  53. package/dist/inbox/inbox.js +40 -30
  54. package/dist/inbox/inbox.js.map +1 -1
  55. package/dist/inbox/index.d.ts +2 -0
  56. package/dist/inbox/index.d.ts.map +1 -1
  57. package/dist/inbox/index.js +1 -0
  58. package/dist/inbox/index.js.map +1 -1
  59. package/dist/inbox/names.d.ts +54 -0
  60. package/dist/inbox/names.d.ts.map +1 -0
  61. package/dist/inbox/names.js +299 -0
  62. package/dist/inbox/names.js.map +1 -0
  63. package/dist/index.d.ts +3 -6
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +9 -12
  66. package/dist/index.js.map +1 -1
  67. package/dist/network/mesh.d.ts +7 -20
  68. package/dist/network/mesh.d.ts.map +1 -1
  69. package/dist/network/mesh.js +267 -245
  70. package/dist/network/mesh.js.map +1 -1
  71. package/dist/network/relay-link.d.ts +31 -0
  72. package/dist/network/relay-link.d.ts.map +1 -0
  73. package/dist/network/relay-link.js +62 -0
  74. package/dist/network/relay-link.js.map +1 -0
  75. package/dist/network/relay-minca.d.ts.map +1 -1
  76. package/dist/network/relay-minca.js +11 -49
  77. package/dist/network/relay-minca.js.map +1 -1
  78. package/dist/network/relay-nostr.d.ts.map +1 -1
  79. package/dist/network/relay-nostr.js +23 -63
  80. package/dist/network/relay-nostr.js.map +1 -1
  81. package/dist/network/relay-socket.d.ts +1 -1
  82. package/dist/network/relay-socket.d.ts.map +1 -1
  83. package/dist/network/relay-socket.js +3 -1
  84. package/dist/network/relay-socket.js.map +1 -1
  85. package/dist/node/actions.d.ts.map +1 -1
  86. package/dist/node/actions.js +50 -38
  87. package/dist/node/actions.js.map +1 -1
  88. package/dist/node/api.d.ts +6 -0
  89. package/dist/node/api.d.ts.map +1 -1
  90. package/dist/node/api.js +6 -0
  91. package/dist/node/api.js.map +1 -1
  92. package/dist/node/carrier.d.ts +5 -0
  93. package/dist/node/carrier.d.ts.map +1 -1
  94. package/dist/node/carrier.js +94 -73
  95. package/dist/node/carrier.js.map +1 -1
  96. package/dist/node/copy.d.ts +8 -7
  97. package/dist/node/copy.d.ts.map +1 -1
  98. package/dist/node/copy.js +54 -56
  99. package/dist/node/copy.js.map +1 -1
  100. package/dist/node/host.d.ts +39 -65
  101. package/dist/node/host.d.ts.map +1 -1
  102. package/dist/node/host.js +362 -379
  103. package/dist/node/host.js.map +1 -1
  104. package/dist/node/index.d.ts +2 -2
  105. package/dist/node/index.d.ts.map +1 -1
  106. package/dist/node/index.js +1 -1
  107. package/dist/node/index.js.map +1 -1
  108. package/dist/node/node-carriers.d.ts +35 -0
  109. package/dist/node/node-carriers.d.ts.map +1 -0
  110. package/dist/node/node-carriers.js +562 -0
  111. package/dist/node/node-carriers.js.map +1 -0
  112. package/dist/node/node-contacts.d.ts +11 -0
  113. package/dist/node/node-contacts.d.ts.map +1 -0
  114. package/dist/node/node-contacts.js +808 -0
  115. package/dist/node/node-contacts.js.map +1 -0
  116. package/dist/node/node-context.d.ts +76 -0
  117. package/dist/node/node-context.d.ts.map +1 -0
  118. package/dist/node/node-context.js +54 -0
  119. package/dist/node/node-context.js.map +1 -0
  120. package/dist/node/node-hosting.d.ts +20 -0
  121. package/dist/node/node-hosting.d.ts.map +1 -0
  122. package/dist/node/node-hosting.js +449 -0
  123. package/dist/node/node-hosting.js.map +1 -0
  124. package/dist/node/node-records.d.ts +18 -0
  125. package/dist/node/node-records.d.ts.map +1 -0
  126. package/dist/node/node-records.js +262 -0
  127. package/dist/node/node-records.js.map +1 -0
  128. package/dist/node/node.d.ts.map +1 -1
  129. package/dist/node/node.js +198 -1990
  130. package/dist/node/node.js.map +1 -1
  131. package/dist/node/remote.d.ts +5 -6
  132. package/dist/node/remote.d.ts.map +1 -1
  133. package/dist/node/remote.js +272 -260
  134. package/dist/node/remote.js.map +1 -1
  135. package/dist/node/space-catalog.d.ts +40 -0
  136. package/dist/node/space-catalog.d.ts.map +1 -0
  137. package/dist/node/space-catalog.js +158 -0
  138. package/dist/node/space-catalog.js.map +1 -0
  139. package/dist/node/space-checks.d.ts +25 -0
  140. package/dist/node/space-checks.d.ts.map +1 -0
  141. package/dist/node/space-checks.js +343 -0
  142. package/dist/node/space-checks.js.map +1 -0
  143. package/dist/node/space-history.d.ts +37 -0
  144. package/dist/node/space-history.d.ts.map +1 -0
  145. package/dist/node/space-history.js +350 -0
  146. package/dist/node/space-history.js.map +1 -0
  147. package/dist/node/space-holding.d.ts +49 -0
  148. package/dist/node/space-holding.d.ts.map +1 -0
  149. package/dist/node/space-holding.js +267 -0
  150. package/dist/node/space-holding.js.map +1 -0
  151. package/dist/node/space-index.d.ts +41 -0
  152. package/dist/node/space-index.d.ts.map +1 -0
  153. package/dist/node/space-index.js +217 -0
  154. package/dist/node/space-index.js.map +1 -0
  155. package/dist/node/space-keys.d.ts +34 -0
  156. package/dist/node/space-keys.d.ts.map +1 -0
  157. package/dist/node/space-keys.js +309 -0
  158. package/dist/node/space-keys.js.map +1 -0
  159. package/dist/node/space-lines.d.ts +33 -0
  160. package/dist/node/space-lines.d.ts.map +1 -0
  161. package/dist/node/space-lines.js +145 -0
  162. package/dist/node/space-lines.js.map +1 -0
  163. package/dist/node/space-membership.d.ts +69 -0
  164. package/dist/node/space-membership.d.ts.map +1 -0
  165. package/dist/node/space-membership.js +242 -0
  166. package/dist/node/space-membership.js.map +1 -0
  167. package/dist/node/space-mirrors.d.ts +43 -0
  168. package/dist/node/space-mirrors.d.ts.map +1 -0
  169. package/dist/node/space-mirrors.js +125 -0
  170. package/dist/node/space-mirrors.js.map +1 -0
  171. package/dist/node/space-peers.d.ts +104 -0
  172. package/dist/node/space-peers.d.ts.map +1 -0
  173. package/dist/node/space-peers.js +595 -0
  174. package/dist/node/space-peers.js.map +1 -0
  175. package/dist/node/space-profiles.d.ts +18 -0
  176. package/dist/node/space-profiles.d.ts.map +1 -0
  177. package/dist/node/space-profiles.js +105 -0
  178. package/dist/node/space-profiles.js.map +1 -0
  179. package/dist/node/space-rules.d.ts +29 -0
  180. package/dist/node/space-rules.d.ts.map +1 -0
  181. package/dist/node/space-rules.js +144 -0
  182. package/dist/node/space-rules.js.map +1 -0
  183. package/dist/node/space-runtime.d.ts +103 -142
  184. package/dist/node/space-runtime.d.ts.map +1 -1
  185. package/dist/node/space-runtime.js +290 -3963
  186. package/dist/node/space-runtime.js.map +1 -1
  187. package/dist/node/space-standing.d.ts +20 -0
  188. package/dist/node/space-standing.d.ts.map +1 -0
  189. package/dist/node/space-standing.js +317 -0
  190. package/dist/node/space-standing.js.map +1 -0
  191. package/dist/node/space-versions.d.ts +104 -0
  192. package/dist/node/space-versions.d.ts.map +1 -0
  193. package/dist/node/space-versions.js +153 -0
  194. package/dist/node/space-versions.js.map +1 -0
  195. package/dist/node/space-warrants.d.ts +25 -0
  196. package/dist/node/space-warrants.d.ts.map +1 -0
  197. package/dist/node/space-warrants.js +214 -0
  198. package/dist/node/space-warrants.js.map +1 -0
  199. package/dist/node/space-writing.d.ts +72 -0
  200. package/dist/node/space-writing.d.ts.map +1 -0
  201. package/dist/node/space-writing.js +440 -0
  202. package/dist/node/space-writing.js.map +1 -0
  203. package/dist/node/stores.d.ts +19 -50
  204. package/dist/node/stores.d.ts.map +1 -1
  205. package/dist/node/stores.js +14 -33
  206. package/dist/node/stores.js.map +1 -1
  207. package/dist/node/types.d.ts +225 -306
  208. package/dist/node/types.d.ts.map +1 -1
  209. package/dist/node/usage.d.ts +2 -24
  210. package/dist/node/usage.d.ts.map +1 -1
  211. package/dist/node/usage.js +118 -102
  212. package/dist/node/usage.js.map +1 -1
  213. package/dist/node/watch-notifications.d.ts.map +1 -1
  214. package/dist/node/watch-notifications.js +32 -29
  215. package/dist/node/watch-notifications.js.map +1 -1
  216. package/dist/node/worker.d.ts +5 -6
  217. package/dist/node/worker.d.ts.map +1 -1
  218. package/dist/node/worker.js +80 -72
  219. package/dist/node/worker.js.map +1 -1
  220. package/dist/node/writer-keys.d.ts +5 -6
  221. package/dist/node/writer-keys.d.ts.map +1 -1
  222. package/dist/node/writer-keys.js +66 -57
  223. package/dist/node/writer-keys.js.map +1 -1
  224. package/dist/node/writers.d.ts +12 -19
  225. package/dist/node/writers.d.ts.map +1 -1
  226. package/dist/node/writers.js +7 -15
  227. package/dist/node/writers.js.map +1 -1
  228. package/dist/privacy/direct.d.ts.map +1 -1
  229. package/dist/privacy/direct.js +31 -27
  230. package/dist/privacy/direct.js.map +1 -1
  231. package/dist/privacy/space-encryption.d.ts.map +1 -1
  232. package/dist/privacy/space-encryption.js +5 -9
  233. package/dist/privacy/space-encryption.js.map +1 -1
  234. package/dist/query/computed.d.ts.map +1 -1
  235. package/dist/query/computed.js +78 -77
  236. package/dist/query/computed.js.map +1 -1
  237. package/dist/query/engine.d.ts +3 -4
  238. package/dist/query/engine.d.ts.map +1 -1
  239. package/dist/query/engine.js +93 -86
  240. package/dist/query/engine.js.map +1 -1
  241. package/dist/query/filter.d.ts +8 -10
  242. package/dist/query/filter.d.ts.map +1 -1
  243. package/dist/query/filter.js +144 -161
  244. package/dist/query/filter.js.map +1 -1
  245. package/dist/records/cel-types.d.ts.map +1 -1
  246. package/dist/records/cel-types.js +13 -27
  247. package/dist/records/cel-types.js.map +1 -1
  248. package/dist/records/cel.d.ts.map +1 -1
  249. package/dist/records/cel.js +177 -242
  250. package/dist/records/cel.js.map +1 -1
  251. package/dist/records/rules.d.ts.map +1 -1
  252. package/dist/records/rules.js +46 -50
  253. package/dist/records/rules.js.map +1 -1
  254. package/dist/records/topics.d.ts.map +1 -1
  255. package/dist/records/topics.js +18 -22
  256. package/dist/records/topics.js.map +1 -1
  257. package/dist/schemas/automations.d.ts +8 -15
  258. package/dist/schemas/automations.d.ts.map +1 -1
  259. package/dist/schemas/automations.js +203 -165
  260. package/dist/schemas/automations.js.map +1 -1
  261. package/dist/schemas/blueprints.d.ts.map +1 -1
  262. package/dist/schemas/blueprints.js +14 -13
  263. package/dist/schemas/blueprints.js.map +1 -1
  264. package/dist/schemas/connectors.d.ts.map +1 -1
  265. package/dist/schemas/connectors.js +16 -11
  266. package/dist/schemas/connectors.js.map +1 -1
  267. package/dist/schemas/contacts.d.ts +57 -0
  268. package/dist/schemas/contacts.d.ts.map +1 -1
  269. package/dist/schemas/contacts.js +32 -0
  270. package/dist/schemas/contacts.js.map +1 -1
  271. package/dist/schemas/cron.d.ts.map +1 -1
  272. package/dist/schemas/cron.js +27 -28
  273. package/dist/schemas/cron.js.map +1 -1
  274. package/dist/schemas/defined.d.ts +6 -0
  275. package/dist/schemas/defined.d.ts.map +1 -0
  276. package/dist/schemas/defined.js +7 -0
  277. package/dist/schemas/defined.js.map +1 -0
  278. package/dist/schemas/guides.d.ts +3 -1
  279. package/dist/schemas/guides.d.ts.map +1 -1
  280. package/dist/schemas/guides.js +13 -12
  281. package/dist/schemas/guides.js.map +1 -1
  282. package/dist/schemas/index.d.ts +2 -2
  283. package/dist/schemas/index.d.ts.map +1 -1
  284. package/dist/schemas/index.js +18 -14
  285. package/dist/schemas/index.js.map +1 -1
  286. package/dist/session/account-hint.d.ts.map +1 -1
  287. package/dist/session/account-hint.js +8 -5
  288. package/dist/session/account-hint.js.map +1 -1
  289. package/dist/session/auth.d.ts +36 -2
  290. package/dist/session/auth.d.ts.map +1 -1
  291. package/dist/session/auth.js +95 -2
  292. package/dist/session/auth.js.map +1 -1
  293. package/dist/session/connect.d.ts +1 -0
  294. package/dist/session/connect.d.ts.map +1 -1
  295. package/dist/session/connect.js +3 -1
  296. package/dist/session/connect.js.map +1 -1
  297. package/dist/session/credentials.d.ts +8 -26
  298. package/dist/session/credentials.d.ts.map +1 -1
  299. package/dist/session/credentials.js +14 -32
  300. package/dist/session/credentials.js.map +1 -1
  301. package/dist/session/index.d.ts +1 -0
  302. package/dist/session/index.d.ts.map +1 -1
  303. package/dist/session/index.js +1 -0
  304. package/dist/session/index.js.map +1 -1
  305. package/dist/session/pairing.d.ts.map +1 -1
  306. package/dist/session/pairing.js +92 -88
  307. package/dist/session/pairing.js.map +1 -1
  308. package/dist/session/password-strength.d.ts.map +1 -1
  309. package/dist/session/password-strength.js +37 -37
  310. package/dist/session/password-strength.js.map +1 -1
  311. package/dist/session/places.d.ts.map +1 -1
  312. package/dist/session/places.js +18 -13
  313. package/dist/session/places.js.map +1 -1
  314. package/dist/session/popup.d.ts +13 -0
  315. package/dist/session/popup.d.ts.map +1 -0
  316. package/dist/session/popup.js +23 -0
  317. package/dist/session/popup.js.map +1 -0
  318. package/dist/space/constitution.d.ts.map +1 -1
  319. package/dist/space/constitution.js +22 -29
  320. package/dist/space/constitution.js.map +1 -1
  321. package/dist/space/grants.d.ts.map +1 -1
  322. package/dist/space/grants.js +37 -39
  323. package/dist/space/grants.js.map +1 -1
  324. package/dist/space/invite-link.d.ts.map +1 -1
  325. package/dist/space/invite-link.js +33 -33
  326. package/dist/space/invite-link.js.map +1 -1
  327. package/dist/space/own-automations.d.ts +13 -24
  328. package/dist/space/own-automations.d.ts.map +1 -1
  329. package/dist/space/own-automations.js +47 -37
  330. package/dist/space/own-automations.js.map +1 -1
  331. package/dist/space/roles.d.ts +56 -80
  332. package/dist/space/roles.d.ts.map +1 -1
  333. package/dist/space/roles.js +448 -441
  334. package/dist/space/roles.js.map +1 -1
  335. package/dist/space/space-access.d.ts +3 -4
  336. package/dist/space/space-access.d.ts.map +1 -1
  337. package/dist/space/space-access.js +3 -8
  338. package/dist/space/space-access.js.map +1 -1
  339. package/dist/storage/blob/directory.d.ts.map +1 -1
  340. package/dist/storage/blob/directory.js +39 -32
  341. package/dist/storage/blob/directory.js.map +1 -1
  342. package/dist/storage/blob/s3.d.ts.map +1 -1
  343. package/dist/storage/blob/s3.js +21 -19
  344. package/dist/storage/blob/s3.js.map +1 -1
  345. package/dist/storage/blob-store.d.ts +0 -9
  346. package/dist/storage/blob-store.d.ts.map +1 -1
  347. package/dist/storage/directory-access.d.ts +8 -32
  348. package/dist/storage/directory-access.d.ts.map +1 -1
  349. package/dist/storage/directory-access.js +11 -36
  350. package/dist/storage/directory-access.js.map +1 -1
  351. package/dist/storage/encrypted-adapter.d.ts +12 -32
  352. package/dist/storage/encrypted-adapter.d.ts.map +1 -1
  353. package/dist/storage/encrypted-adapter.js +31 -54
  354. package/dist/storage/encrypted-adapter.js.map +1 -1
  355. package/dist/storage/folder-adapter.d.ts +12 -26
  356. package/dist/storage/folder-adapter.d.ts.map +1 -1
  357. package/dist/storage/folder-adapter.js +37 -54
  358. package/dist/storage/folder-adapter.js.map +1 -1
  359. package/dist/storage/folder-reconcile.d.ts +12 -26
  360. package/dist/storage/folder-reconcile.d.ts.map +1 -1
  361. package/dist/storage/folder-reconcile.js +39 -48
  362. package/dist/storage/folder-reconcile.js.map +1 -1
  363. package/dist/storage/indexeddb-adapter.d.ts +2 -6
  364. package/dist/storage/indexeddb-adapter.d.ts.map +1 -1
  365. package/dist/storage/indexeddb-adapter.js +60 -114
  366. package/dist/storage/indexeddb-adapter.js.map +1 -1
  367. package/dist/storage/mirror.d.ts +0 -29
  368. package/dist/storage/mirror.d.ts.map +1 -1
  369. package/dist/storage/mirror.js +153 -110
  370. package/dist/storage/mirror.js.map +1 -1
  371. package/dist/storage/segment.d.ts.map +1 -1
  372. package/dist/storage/segment.js +3 -7
  373. package/dist/storage/segment.js.map +1 -1
  374. package/dist/storage/storage-provider.d.ts +6 -11
  375. package/dist/storage/storage-provider.d.ts.map +1 -1
  376. package/dist/storage/storage-provider.js +112 -116
  377. package/dist/storage/storage-provider.js.map +1 -1
  378. package/dist/sync/sync-engine.d.ts +10 -44
  379. package/dist/sync/sync-engine.d.ts.map +1 -1
  380. package/dist/sync/sync-engine.js +245 -247
  381. package/dist/sync/sync-engine.js.map +1 -1
  382. package/dist/sync/sync-messages.d.ts +1 -1
  383. package/dist/sync/sync-messages.d.ts.map +1 -1
  384. package/dist/sync/sync-messages.js +1 -1
  385. package/dist/sync/sync-messages.js.map +1 -1
  386. package/dist/utils/guards.d.ts +1 -0
  387. package/dist/utils/guards.d.ts.map +1 -1
  388. package/dist/utils/guards.js +1 -0
  389. package/dist/utils/guards.js.map +1 -1
  390. package/dist/utils/hmac.d.ts +5 -0
  391. package/dist/utils/hmac.d.ts.map +1 -0
  392. package/dist/utils/hmac.js +20 -0
  393. package/dist/utils/hmac.js.map +1 -0
  394. package/dist/utils/map.d.ts +10 -0
  395. package/dist/utils/map.d.ts.map +1 -0
  396. package/dist/utils/map.js +30 -0
  397. package/dist/utils/map.js.map +1 -0
  398. package/dist/utils/serial.d.ts +2 -0
  399. package/dist/utils/serial.d.ts.map +1 -1
  400. package/dist/utils/serial.js +9 -0
  401. package/dist/utils/serial.js.map +1 -1
  402. package/dist/validation/capability-gate.d.ts +7 -15
  403. package/dist/validation/capability-gate.d.ts.map +1 -1
  404. package/dist/validation/capability-gate.js +32 -36
  405. package/dist/validation/capability-gate.js.map +1 -1
  406. package/dist/validation/crypto-gate.d.ts.map +1 -1
  407. package/dist/validation/crypto-gate.js +12 -21
  408. package/dist/validation/crypto-gate.js.map +1 -1
  409. package/docs/README.md +1 -0
  410. package/docs/actions.md +1 -1
  411. package/docs/automations.md +1 -1
  412. package/docs/blueprints-and-guides.md +17 -1
  413. package/docs/building-an-app.md +7 -4
  414. package/docs/collections.md +3 -3
  415. package/docs/contacts.md +34 -1
  416. package/docs/contracts.md +1 -1
  417. package/docs/direct-messages.md +1 -1
  418. package/docs/inbox.md +5 -11
  419. package/docs/node.md +22 -14
  420. package/docs/records-and-queries.md +1 -1
  421. package/docs/sign-in.md +54 -26
  422. package/docs/spaces.md +6 -6
  423. package/docs/standard-library.md +7 -6
  424. package/docs/storage.md +4 -5
  425. package/docs/usernames.md +161 -0
  426. package/docs/warrants.md +1 -1
  427. package/package.json +1 -1
@@ -21,6 +21,7 @@ import { openEnvelope, sealEnvelope } from './envelope.js';
21
21
  const POINT_BYTES = 65;
22
22
  /** Sealed messages longer than this are not tried */
23
23
  const MAX_SEALED = 1_000_000;
24
+ const ECDH = { name: 'ECDH', namedCurve: 'P-256' };
24
25
  /** Handing an account to a phone (`identity/pairing.ts`) */
25
26
  export const PAIRING_CHANNEL = Object.freeze({
26
27
  room: 'minca/pairing-room/v1',
@@ -33,53 +34,45 @@ export const CODE_CHANNEL = Object.freeze({
33
34
  key: 'minca/code-key/v1',
34
35
  message: 'minca/code/v1',
35
36
  });
36
- /**
37
- * The room both sides meet in: a hash of the secret, so only someone who has
38
- * the secret can find it, and a relay sees a new name every time.
39
- */
37
+ /** The room both sides meet in: a hash of the secret, so only its holders find it */
40
38
  export async function channelRoom(kind, secret) {
41
39
  return cidFromBytes(concatBytes(utf8Encode(kind.room), secret));
42
40
  }
43
41
  /** An ephemeral ECDH key for one exchange, and its public point */
44
42
  export async function channelKeyPair() {
45
- const pair = await globalThis.crypto.subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, false, [
46
- 'deriveBits',
47
- ]);
43
+ const pair = await globalThis.crypto.subtle.generateKey(ECDH, false, ['deriveBits']);
48
44
  const point = new Uint8Array(await globalThis.crypto.subtle.exportKey('raw', pair.publicKey));
49
45
  return { privateKey: pair.privateKey, point };
50
46
  }
51
47
  const notAKey = () => protocolError('PAIRING_TICKET_UNREADABLE', 'That device sent a key that is not one.');
52
48
  /**
53
49
  * The channel, from this side's private key, both public points and the secret.
54
- *
55
- * The secret goes into the key, so someone who never had it gets a different
56
- * channel; the shared point goes in too, so a recording opens nothing to
57
- * someone who learns the secret later; both points go into the labels, so a
58
- * message sealed for one exchange opens in no other.
50
+ * The secret and the shared point both go into the keys, so neither alone
51
+ * opens a recording; both points go into the labels, binding it to this exchange.
59
52
  */
60
53
  export async function deriveChannel(params) {
61
- for (const point of [params.offer, params.join]) {
62
- if (point.length !== POINT_BYTES || point[0] !== 0x04)
63
- throw notAKey();
64
- }
65
- let shared;
66
- try {
67
- const peer = await globalThis.crypto.subtle.importKey('raw', bufferSource(params.side === 'offer' ? params.join : params.offer), { name: 'ECDH', namedCurve: 'P-256' }, false, []);
68
- shared = new Uint8Array(await globalThis.crypto.subtle.deriveBits({ name: 'ECDH', public: peer }, params.privateKey, 256));
69
- }
70
- catch {
54
+ const { kind, side, offer, join } = params;
55
+ if (!isPoint(offer) || !isPoint(join))
71
56
  throw notAKey();
72
- }
73
- const { kind } = params;
57
+ const shared = await sharedPoint(params.privateKey, side === 'offer' ? join : offer);
74
58
  const ikm = concatBytes(params.secret, shared);
75
- const transcript = `|${base64UrlEncode(params.offer)}|${base64UrlEncode(params.join)}`;
76
- const other = params.side === 'offer' ? 'join' : 'offer';
77
- const sendKey = await hkdfAesKey(ikm, utf8Encode(`${kind.key}|${params.side}${transcript}`));
59
+ const transcript = `|${base64UrlEncode(offer)}|${base64UrlEncode(join)}`;
60
+ const other = side === 'offer' ? 'join' : 'offer';
61
+ const sendKey = await hkdfAesKey(ikm, utf8Encode(`${kind.key}|${side}${transcript}`));
78
62
  const receiveKey = await hkdfAesKey(ikm, utf8Encode(`${kind.key}|${other}${transcript}`));
79
63
  let sent = 0;
80
64
  let received = 0;
81
65
  // One open at a time, so two messages arriving together are each tried at the count they should have.
82
66
  let opening = Promise.resolve();
67
+ async function openNext(type, sealed) {
68
+ const bytes = decodeSealed(sealed);
69
+ if (!bytes)
70
+ return null;
71
+ const plain = await openEnvelope(receiveKey, kind.message, { type, seq: received }, bytes);
72
+ if (plain)
73
+ received += 1;
74
+ return plain;
75
+ }
83
76
  return Object.freeze({
84
77
  async seal(type, plaintext) {
85
78
  const seq = sent;
@@ -87,25 +80,32 @@ export async function deriveChannel(params) {
87
80
  return base64UrlEncode(await sealEnvelope(sendKey, kind.message, { type, seq }, plaintext));
88
81
  },
89
82
  open(type, sealed) {
90
- const result = opening.then(async () => {
91
- if (typeof sealed !== 'string' || sealed.length > MAX_SEALED)
92
- return null;
93
- let bytes;
94
- try {
95
- bytes = base64UrlDecode(sealed);
96
- }
97
- catch {
98
- return null;
99
- }
100
- const plain = await openEnvelope(receiveKey, kind.message, { type, seq: received }, bytes);
101
- if (plain)
102
- received += 1;
103
- return plain;
104
- });
83
+ const result = opening.then(() => openNext(type, sealed));
105
84
  opening = result;
106
85
  return result;
107
86
  },
108
87
  derive: (label, length) => hkdf(ikm, utf8Encode(label + transcript), length),
109
88
  });
110
89
  }
90
+ const isPoint = (point) => point.length === POINT_BYTES && point[0] === 0x04;
91
+ /** The ECDH shared x coordinate with the other side's point */
92
+ async function sharedPoint(privateKey, theirs) {
93
+ try {
94
+ const peer = await globalThis.crypto.subtle.importKey('raw', bufferSource(theirs), ECDH, false, []);
95
+ return new Uint8Array(await globalThis.crypto.subtle.deriveBits({ name: 'ECDH', public: peer }, privateKey, 256));
96
+ }
97
+ catch {
98
+ throw notAKey();
99
+ }
100
+ }
101
+ function decodeSealed(sealed) {
102
+ if (typeof sealed !== 'string' || sealed.length > MAX_SEALED)
103
+ return null;
104
+ try {
105
+ return base64UrlDecode(sealed);
106
+ }
107
+ catch {
108
+ return null;
109
+ }
110
+ }
111
111
  //# sourceMappingURL=channel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/identity/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE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C,CAC3F,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,MAAe;IACnC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU;QAAE,OAAO,IAAI,CAAC;IAC1E,IAAI,CAAC;QACH,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -4,47 +4,32 @@ export interface ContactKeyPair {
4
4
  /** The private half, for opening what was sealed to the public one. Not extractable. */
5
5
  readonly privateKey: CryptoKey;
6
6
  }
7
- /**
8
- * The contact key's private scalar, from the account seed — 32 bytes. This is
9
- * what an account home hands an app it lets handle contacts.
10
- */
7
+ /** The contact key's 32-byte private scalar, from the seed: what an account home hands an app that handles contacts */
11
8
  export declare function deriveContactKeyBytes(seed: Uint8Array): Promise<Uint8Array>;
12
9
  /**
13
- * An account's **member key** for one space: the same kind of key pair, derived
14
- * from the account key and the space id. When a private space's key
15
- * changes, the new key is sealed to each member's member key (`sys.box`).
16
- *
17
- * One per space, not one per account, so an account home can hand an app the
18
- * member keys for exactly the spaces it grants — and a new space key reaches
19
- * that app without it holding anything that opens other spaces' keys.
10
+ * The account's member key for one space, which new space keys are sealed to
11
+ * (`sys.box`). One per space, so an app granted one space holds nothing that opens another.
20
12
  * @param accountKey The account key (`deriveAccountKey(seed)`)
21
13
  */
22
14
  export declare function deriveMemberKeyBytes(accountKey: Uint8Array, spaceId: string): Promise<Uint8Array>;
23
15
  /**
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`.
28
- *
29
- * Not the contact key itself: that one's public half is on your profile in
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.
16
+ * An inbox key, which knocks are sealed to (spec 07 §1). Not the contact key,
17
+ * whose public half is on every profile: an inbox key says nothing about whose it is.
32
18
  * @param contactKey The contact key's private scalar (`deriveContactKeyBytes`)
33
19
  */
34
20
  export declare function deriveInboxKeyBytes(contactKey: Uint8Array, gen: number): Promise<Uint8Array>;
35
- /**
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
- */
21
+ /** An inbox's signing key: signs the inbox and proves ownership to a relay. Separate, so no key both signs and decrypts. */
41
22
  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>;
44
23
  /**
45
- * Signs with a P-256 private scalar: ECDSA over SHA-256, 64 bytes r ‖ s,
46
- * base64url — for an inbox's signing key.
24
+ * A username's name key, which claims it on a Minca name service
25
+ * (`packages/core/docs/usernames.md`). One per username, and nothing ties it
26
+ * to the account or to an inbox, so a new inbox keeps the name.
27
+ * @param username `name@domain`, as `formatUsername` writes it (`claimUsername` derives it so)
47
28
  */
29
+ export declare function deriveNameKeyBytes(contactKey: Uint8Array, username: string): Promise<Uint8Array>;
30
+ /** A private scalar as an ECDSA signing key */
31
+ export declare function signingKeyOf(secret: Uint8Array): Promise<CryptoKey>;
32
+ /** Signs with a P-256 private scalar: ECDSA over SHA-256, 64 bytes r ‖ s, base64url */
48
33
  export declare function signWithScalar(secret: Uint8Array, data: Uint8Array): Promise<string>;
49
34
  /** The public half, from the private scalar */
50
35
  export declare function contactPublicKey(secret: Uint8Array): string;
@@ -1 +1 @@
1
- {"version":3,"file":"contact-key.d.ts","sourceRoot":"","sources":["../../src/identity/contact-key.ts"],"names":[],"m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- * The contact key: what lets someone seal a message only you can open, while
4
- * you are offline.
3
+ * The contact key: a P-256 ECDH key pair, derived from the seed under its own
4
+ * label, that lets someone seal a message only you can open while you are
5
+ * offline. Not the root key (apps never hold the seed, and one key should not
6
+ * both sign and decrypt), and not a session key (those change every hour).
5
7
  *
6
- * It is a P-256 key pair for key agreement (ECDH), derived from the account's
7
- * seed like the root key but under its own label — the same on every device,
8
- * and back with the recovery code. It is not the root key: apps never hold the
9
- * seed, and one key should not both sign and decrypt. It is not a session key
10
- * either: those change every hour, and a request read next week would be
11
- * locked to a key that is gone.
12
- *
13
- * The public half goes on the account's profile in every space it writes in
14
- * (`sys.profile`). The private half stays with the account home, and goes to
15
- * apps the person lets handle contacts.
16
- *
17
- * Sealing to it is HPKE (`identity/hpke.ts`): a fresh key pair for each
18
- * message, with a label and the place it belongs bound in.
8
+ * Its public half goes on the account's profile (`sys.profile`); sealing to it
9
+ * is HPKE (`identity/hpke.ts`). Member and inbox keys are derived the same way.
19
10
  */
20
11
  import { p256 } from '@noble/curves/nist.js';
21
12
  import { base64UrlDecode, base64UrlEncode, utf8Encode } from '../utils/encoding.js';
22
13
  import { bufferSource } from '../utils/guards.js';
23
14
  import { hkdf } from './hkdf.js';
24
- /** Domain separation for the contact key. Changing it changes every account's contact key. */
15
+ /** Domain separation. Changing a label changes every key derived under it. */
25
16
  const CONTACT_KEY_INFO = 'minca/p256-contact-key/v1';
26
17
  const MEMBER_KEY_INFO = 'minca/p256-member-key/v1';
27
18
  const INBOX_KEY_INFO = 'minca/p256-inbox-key/v1';
28
19
  const INBOX_SIGN_KEY_INFO = 'minca/p256-inbox-sign-key/v1';
20
+ const NAME_KEY_INFO = 'minca/p256-name-key/v1';
29
21
  /** 48 bytes reduce to a P-256 scalar without bias, as for the root key (`crypto-p256.ts`) */
30
22
  const P256_SEED_BYTES = 48;
31
23
  /** A P-256 scalar from key material, under its own label */
@@ -44,60 +36,48 @@ function importScalar(secret, algorithm, usages) {
44
36
  ext: false,
45
37
  }, { name: algorithm, namedCurve: 'P-256' }, false, usages);
46
38
  }
47
- /**
48
- * The contact key's private scalar, from the account seed — 32 bytes. This is
49
- * what an account home hands an app it lets handle contacts.
50
- */
51
- export async function deriveContactKeyBytes(seed) {
39
+ /** The contact key's 32-byte private scalar, from the seed: what an account home hands an app that handles contacts */
40
+ export function deriveContactKeyBytes(seed) {
52
41
  return deriveScalar(seed, CONTACT_KEY_INFO);
53
42
  }
54
43
  /**
55
- * An account's **member key** for one space: the same kind of key pair, derived
56
- * from the account key and the space id. When a private space's key
57
- * changes, the new key is sealed to each member's member key (`sys.box`).
58
- *
59
- * One per space, not one per account, so an account home can hand an app the
60
- * member keys for exactly the spaces it grants — and a new space key reaches
61
- * that app without it holding anything that opens other spaces' keys.
44
+ * The account's member key for one space, which new space keys are sealed to
45
+ * (`sys.box`). One per space, so an app granted one space holds nothing that opens another.
62
46
  * @param accountKey The account key (`deriveAccountKey(seed)`)
63
47
  */
64
- export async function deriveMemberKeyBytes(accountKey, spaceId) {
48
+ export function deriveMemberKeyBytes(accountKey, spaceId) {
65
49
  return deriveScalar(accountKey, `${MEMBER_KEY_INFO}|${spaceId}`);
66
50
  }
67
51
  /**
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`.
72
- *
73
- * Not the contact key itself: that one's public half is on your profile in
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.
52
+ * An inbox key, which knocks are sealed to (spec 07 §1). Not the contact key,
53
+ * whose public half is on every profile: an inbox key says nothing about whose it is.
76
54
  * @param contactKey The contact key's private scalar (`deriveContactKeyBytes`)
77
55
  */
78
- export async function deriveInboxKeyBytes(contactKey, gen) {
56
+ export function deriveInboxKeyBytes(contactKey, gen) {
79
57
  return deriveScalar(contactKey, `${INBOX_KEY_INFO}|${gen}`);
80
58
  }
59
+ /** An inbox's signing key: signs the inbox and proves ownership to a relay. Separate, so no key both signs and decrypts. */
60
+ export function deriveInboxSignKeyBytes(contactKey, gen) {
61
+ return deriveScalar(contactKey, `${INBOX_SIGN_KEY_INFO}|${gen}`);
62
+ }
81
63
  /**
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.
64
+ * A username's name key, which claims it on a Minca name service
65
+ * (`packages/core/docs/usernames.md`). One per username, and nothing ties it
66
+ * to the account or to an inbox, so a new inbox keeps the name.
67
+ * @param username `name@domain`, as `formatUsername` writes it (`claimUsername` derives it so)
86
68
  */
87
- export async function deriveInboxSignKeyBytes(contactKey, gen) {
88
- return deriveScalar(contactKey, `${INBOX_SIGN_KEY_INFO}|${gen}`);
69
+ export function deriveNameKeyBytes(contactKey, username) {
70
+ return deriveScalar(contactKey, `${NAME_KEY_INFO}|${username}`);
89
71
  }
90
- /** A private scalar as a key to sign with (ECDSA), for what an inbox's signing key signs as a version */
72
+ /** A private scalar as an ECDSA signing key */
91
73
  export function signingKeyOf(secret) {
92
74
  return importScalar(secret, 'ECDSA', ['sign']);
93
75
  }
94
- /**
95
- * Signs with a P-256 private scalar: ECDSA over SHA-256, 64 bytes r ‖ s,
96
- * base64url — for an inbox's signing key.
97
- */
76
+ /** Signs with a P-256 private scalar: ECDSA over SHA-256, 64 bytes r ‖ s, base64url */
98
77
  export async function signWithScalar(secret, data) {
99
- const key = await importScalar(secret, 'ECDSA', ['sign']);
100
- return base64UrlEncode(new Uint8Array(await globalThis.crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, key, bufferSource(data))));
78
+ const key = await signingKeyOf(secret);
79
+ const signature = await globalThis.crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, key, bufferSource(data));
80
+ return base64UrlEncode(new Uint8Array(signature));
101
81
  }
102
82
  /** The public half, from the private scalar */
103
83
  export function contactPublicKey(secret) {
@@ -1 +1 @@
1
- {"version":3,"file":"contact-key.js","sourceRoot":"","sources":["../../src/identity/contact-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,8FAA8F;AAC9F,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,eAAe,GAAG,0BAA0B,CAAC;AACnD,MAAM,cAAc,GAAG,yBAAyB,CAAC;AACjD,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAE3D,6FAA6F;AAC7F,MAAM,eAAe,GAAG,EAAE,CAAC;AAS3B,4DAA4D;AAC5D,KAAK,UAAU,YAAY,CAAC,GAAe,EAAE,IAAY;IACvD,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,oFAAoF;AACpF,SAAS,YAAY,CACnB,MAAkB,EAClB,SAA2B,EAC3B,MAAkB;IAElB,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CACvC,KAAK,EACL;QACE,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,OAAO;QACZ,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzC,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,E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U,gBAAgB,CAAC,MAAkB;IACjD,OAAO,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,KAAK,CAAC;IACjE,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAkB;IACrD,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AAC5E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-p256.d.ts","sourceRoot":"","sources":["../../src/identity/crypto-p256.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAgBlE,0EAA0E;AAC1E,wBAAgB,kBAAkB,IAAI,cAAc,CA2HnD"}
1
+ {"version":3,"file":"crypto-p256.d.ts","sourceRoot":"","sources":["../../src/identity/crypto-p256.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAmBlE,0EAA0E;AAC1E,wBAAgB,kBAAkB,IAAI,cAAc,CAwDnD"}
@@ -1,11 +1,13 @@
1
- import { base64UrlEncode, bytesToHex } from '../utils/encoding.js';
1
+ import { base64UrlEncode, bytesToHex, utf8Encode } from '../utils/encoding.js';
2
2
  import { bufferSource } from '../utils/guards.js';
3
3
  import { hkdf } from './hkdf.js';
4
4
  import { p256 } from '@noble/curves/nist.js';
5
+ /** Domain separation for identity keys. Changing it changes every derived DID. */
6
+ const P256_KEY_INFO = utf8Encode('minca/p256-identity-key/v1');
5
7
  /** 48 bytes: the 32-byte group order plus 16 more, so reducing mod n is unbiased */
6
8
  const P256_SEED_BYTES = 48;
7
- /** Domain separation for identity keys. Changing it changes every derived DID. */
8
- const P256_KEY_INFO = new TextEncoder().encode('minca/p256-identity-key/v1');
9
+ const ECDSA = { name: 'ECDSA', namedCurve: 'P-256' };
10
+ const SIGNING = { name: 'ECDSA', hash: { name: 'SHA-256' } };
9
11
  /** Public keys imported for verifying, by their bytes as hex; the oldest let go first */
10
12
  const publicKeys = new Map();
11
13
  const MAX_PUBLIC_KEYS = 1000;
@@ -14,76 +16,60 @@ export function createP256Provider() {
14
16
  return Object.freeze({
15
17
  algorithm: 'ECDSA-P256',
16
18
  async generateKeyPair() {
17
- const keyPair = await globalThis.crypto.subtle.generateKey({
18
- name: 'ECDSA',
19
- namedCurve: 'P-256',
20
- },
21
- // Not extractable: a script that gets into the page can sign with the
22
- // key while it is there, but cannot carry it off and keep signing.
23
- // The public half exports regardless.
24
- false, ['sign', 'verify']);
25
- return Object.freeze({
26
- publicKey: keyPair.publicKey,
27
- privateKey: keyPair.privateKey,
28
- });
19
+ // Not extractable: a script in the page can sign while there, but can't carry the key off.
20
+ const { publicKey, privateKey } = await globalThis.crypto.subtle.generateKey(ECDSA, false, [
21
+ 'sign',
22
+ 'verify',
23
+ ]);
24
+ return Object.freeze({ publicKey, privateKey });
29
25
  },
30
26
  async deriveKeyPairFromSeed(seed) {
31
- // HKDF stretches the seed to the 48 bytes FIPS 186-5 (appendix A.2) asks
32
- // for, and noble reduces them to a scalar in [1, n-1] with negligible bias.
33
- // Web Crypto can sign with a scalar but cannot compute its public point,
34
- // which is the one step noble supplies.
35
- const expanded = await hkdf(seed, P256_KEY_INFO, P256_SEED_BYTES);
36
- const secretKey = p256.utils.randomSecretKey(expanded);
27
+ // FIPS 186-5 A.2. Web Crypto can't compute a scalar's public point; noble does that step.
28
+ const secretKey = p256.utils.randomSecretKey(await hkdf(seed, P256_KEY_INFO, P256_SEED_BYTES));
37
29
  const point = p256.getPublicKey(secretKey, false); // 0x04 ‖ x ‖ y
38
30
  const x = base64UrlEncode(point.subarray(1, 33));
39
31
  const y = base64UrlEncode(point.subarray(33, 65));
40
32
  const d = base64UrlEncode(secretKey);
41
- const algorithm = { name: 'ECDSA', namedCurve: 'P-256' };
42
- const privateKey = await globalThis.crypto.subtle.importKey('jwk', { kty: 'EC', crv: 'P-256', x, y, d, ext: false, key_ops: ['sign'] }, algorithm, false, ['sign']);
43
- const publicKey = await globalThis.crypto.subtle.importKey('jwk', { kty: 'EC', crv: 'P-256', x, y, ext: true, key_ops: ['verify'] }, algorithm, true, ['verify']);
33
+ const privateKey = await importJwk({ x, y, d, ext: false, key_ops: ['sign'] }, false, ['sign']);
34
+ const publicKey = await importJwk({ x, y, ext: true, key_ops: ['verify'] }, true, ['verify']);
44
35
  return Object.freeze({ publicKey, privateKey });
45
36
  },
46
37
  async sign(privateKey, data) {
47
- const signature = await globalThis.crypto.subtle.sign({
48
- name: 'ECDSA',
49
- hash: { name: 'SHA-256' },
50
- }, privateKey, bufferSource(data));
51
- return new Uint8Array(signature);
38
+ return new Uint8Array(await globalThis.crypto.subtle.sign(SIGNING, privateKey, bufferSource(data)));
52
39
  },
53
- async verify(publicKey, signature, data) {
54
- return await globalThis.crypto.subtle.verify({
55
- name: 'ECDSA',
56
- hash: { name: 'SHA-256' },
57
- }, publicKey, bufferSource(signature), bufferSource(data));
40
+ verify(publicKey, signature, data) {
41
+ return globalThis.crypto.subtle.verify(SIGNING, publicKey, bufferSource(signature), bufferSource(data));
58
42
  },
59
43
  /** The 33-byte compressed point — the form did:key specifies for P-256. */
60
44
  async exportPublicKey(key) {
61
45
  const raw = new Uint8Array(await globalThis.crypto.subtle.exportKey('raw', key));
62
46
  return p256.Point.fromBytes(raw).toBytes(true);
63
47
  },
64
- /**
65
- * Accepts a compressed or uncompressed point; Web Crypto only reliably
66
- * imports the latter. Decompressing costs a square root, and a space's
67
- * records are signed by few keys, so each is imported once.
68
- */
48
+ /** Accepts a compressed or uncompressed point, and imports each key once: decompressing costs a square root. */
69
49
  importPublicKey(bytes) {
70
50
  const id = bytesToHex(bytes);
71
- let found = publicKeys.get(id);
72
- if (!found) {
73
- found = globalThis.crypto.subtle.importKey('raw', bufferSource(p256.Point.fromBytes(bytes).toBytes(false)), { name: 'ECDSA', namedCurve: 'P-256' }, true, ['verify']);
74
- publicKeys.set(id, found);
75
- found.catch(() => publicKeys.delete(id));
76
- if (publicKeys.size > MAX_PUBLIC_KEYS)
77
- publicKeys.delete(publicKeys.keys().next().value);
78
- }
79
- return found;
51
+ const cached = publicKeys.get(id);
52
+ if (cached)
53
+ return cached;
54
+ const uncompressed = p256.Point.fromBytes(bytes).toBytes(false);
55
+ const imported = globalThis.crypto.subtle.importKey('raw', bufferSource(uncompressed), ECDSA, true, [
56
+ 'verify',
57
+ ]);
58
+ remember(id, imported);
59
+ return imported;
80
60
  },
81
- async importPrivateKey(bytes) {
82
- return await globalThis.crypto.subtle.importKey('pkcs8', bufferSource(bytes), {
83
- name: 'ECDSA',
84
- namedCurve: 'P-256',
85
- }, false, ['sign']);
61
+ importPrivateKey(bytes) {
62
+ return globalThis.crypto.subtle.importKey('pkcs8', bufferSource(bytes), ECDSA, false, ['sign']);
86
63
  },
87
64
  });
88
65
  }
66
+ function importJwk(fields, extractable, usages) {
67
+ return globalThis.crypto.subtle.importKey('jwk', { kty: 'EC', crv: 'P-256', ...fields }, ECDSA, extractable, usages);
68
+ }
69
+ function remember(id, key) {
70
+ publicKeys.set(id, key);
71
+ key.catch(() => publicKeys.delete(id));
72
+ if (publicKeys.size > MAX_PUBLIC_KEYS)
73
+ publicKeys.delete(publicKeys.keys().next().value);
74
+ }
89
75
  //# sourceMappingURL=crypto-p256.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-p256.js","sourceRoot":"","sources":["../../src/identity/crypto-p256.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,oFAAoF;AACpF,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,kFAAkF;AAClF,MAAM,aAAa,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAE7E,yFAAyF;AACzF,MAAM,UAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;AACzD,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,YAAY;QAEvB,KAAK,CAAC,eAAe;YACnB,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CACxD;gBACE,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE,OAAO;aACpB;YACD,sEAAsE;YACtE,mEAAmE;YACnE,sCAAsC;YACtC,KAAK,EACL,CAAC,MAAM,EAAE,QAAQ,CAAC,CACnB,CAAC;YAEF,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,qBAAqB,CAAC,IAAgB;YAC1C,yEAAyE;YACzE,4EAA4E;YAC5E,yEAAyE;YACzE,wCAAwC;YACxC,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