@graphprotocol/hypergraph 0.0.1 → 0.0.3

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 (328) hide show
  1. package/dist/connect/abis/MainVotingPlugin.json +1865 -0
  2. package/dist/connect/abis/PersonalSpaceAdminPlugin.json +531 -0
  3. package/dist/connect/abis.d.ts +115 -0
  4. package/dist/connect/abis.d.ts.map +1 -0
  5. package/dist/connect/abis.js +141 -0
  6. package/dist/connect/abis.js.map +1 -0
  7. package/dist/connect/auth-storage.d.ts +15 -0
  8. package/dist/connect/auth-storage.js +53 -0
  9. package/dist/connect/auth-storage.js.map +1 -0
  10. package/dist/connect/create-app-identity.d.ts +7 -0
  11. package/dist/connect/create-app-identity.js +15 -0
  12. package/dist/connect/create-app-identity.js.map +1 -0
  13. package/dist/connect/create-auth-url.d.ts +15 -0
  14. package/dist/connect/create-callback-params.d.ts +28 -0
  15. package/dist/connect/create-callback-params.d.ts.map +1 -1
  16. package/dist/connect/create-callback-params.js.map +1 -1
  17. package/dist/connect/create-identity-keys.d.ts +3 -0
  18. package/dist/connect/create-identity-keys.js +20 -0
  19. package/dist/connect/create-identity-keys.js.map +1 -0
  20. package/dist/connect/identity-encryption.d.ts +12 -0
  21. package/dist/connect/identity-encryption.d.ts.map +1 -1
  22. package/dist/connect/identity-encryption.js +187 -0
  23. package/dist/connect/identity-encryption.js.map +1 -0
  24. package/dist/connect/index.d.ts +11 -0
  25. package/dist/connect/index.d.ts.map +1 -1
  26. package/dist/connect/index.js +11 -0
  27. package/dist/connect/index.js.map +1 -0
  28. package/dist/connect/login.d.ts +22 -0
  29. package/dist/connect/login.d.ts.map +1 -1
  30. package/dist/connect/login.js +172 -0
  31. package/dist/connect/login.js.map +1 -0
  32. package/dist/connect/parse-auth-params.d.ts +14 -0
  33. package/dist/connect/parse-auth-params.d.ts.map +1 -0
  34. package/dist/connect/parse-auth-params.js +40 -0
  35. package/dist/connect/parse-auth-params.js.map +1 -0
  36. package/dist/connect/parse-callback-params.d.ts +13 -0
  37. package/dist/connect/parse-callback-params.d.ts.map +1 -1
  38. package/dist/connect/parse-callback-params.js +4 -1
  39. package/dist/connect/parse-callback-params.js.map +1 -1
  40. package/dist/connect/smart-account.d.ts +96 -0
  41. package/dist/connect/smart-account.d.ts.map +1 -0
  42. package/dist/connect/smart-account.js +761 -0
  43. package/dist/connect/smart-account.js.map +1 -0
  44. package/dist/connect/types.d.ts +2 -0
  45. package/dist/connect/types.d.ts.map +1 -1
  46. package/dist/connect/types.js.map +1 -1
  47. package/dist/entity/create.d.ts +8 -0
  48. package/dist/entity/create.js +51 -0
  49. package/dist/entity/create.js.map +1 -0
  50. package/dist/entity/decodedEntitiesCache.d.ts +23 -0
  51. package/dist/entity/decodedEntitiesCache.d.ts.map +1 -1
  52. package/dist/entity/decodedEntitiesCache.js +2 -0
  53. package/dist/entity/decodedEntitiesCache.js.map +1 -0
  54. package/dist/entity/delete.d.ts +12 -0
  55. package/dist/entity/delete.js +44 -0
  56. package/dist/entity/delete.js.map +1 -0
  57. package/dist/entity/entity.d.ts +18 -0
  58. package/dist/entity/entity.js +19 -0
  59. package/dist/entity/entity.js.map +1 -0
  60. package/dist/entity/entityRelationParentsMap.d.ts +4 -0
  61. package/dist/entity/entityRelationParentsMap.js +2 -0
  62. package/dist/entity/entityRelationParentsMap.js.map +1 -0
  63. package/dist/entity/findMany.d.ts +22 -0
  64. package/dist/entity/findMany.d.ts.map +1 -1
  65. package/dist/entity/findMany.js +8 -8
  66. package/dist/entity/findMany.js.map +1 -1
  67. package/dist/entity/findOne.d.ts +8 -0
  68. package/dist/entity/findOne.js +31 -0
  69. package/dist/entity/findOne.js.map +1 -0
  70. package/dist/entity/getEntityRelations.d.ts +4 -0
  71. package/dist/entity/getEntityRelations.d.ts.map +1 -1
  72. package/dist/entity/getEntityRelations.js +35 -0
  73. package/dist/entity/getEntityRelations.js.map +1 -0
  74. package/dist/entity/hasValidTypesProperty.d.ts +2 -0
  75. package/dist/entity/hasValidTypesProperty.d.ts.map +1 -0
  76. package/dist/entity/hasValidTypesProperty.js +4 -0
  77. package/dist/entity/hasValidTypesProperty.js.map +1 -0
  78. package/dist/entity/index.d.ts +9 -0
  79. package/dist/entity/index.js +9 -0
  80. package/dist/entity/index.js.map +1 -0
  81. package/dist/entity/relationParentsMap.d.ts +4 -0
  82. package/dist/entity/relationParentsMap.js +2 -0
  83. package/dist/entity/relationParentsMap.js.map +1 -0
  84. package/dist/entity/removeRelation.d.ts +7 -0
  85. package/dist/entity/removeRelation.js +17 -0
  86. package/dist/entity/removeRelation.js.map +1 -0
  87. package/dist/entity/test.d.ts +2 -0
  88. package/dist/entity/test.d.ts.map +1 -0
  89. package/dist/entity/test.js +2 -0
  90. package/dist/entity/test.js.map +1 -0
  91. package/dist/entity/types.d.ts +8 -8
  92. package/dist/entity/update.d.ts +8 -0
  93. package/dist/entity/update.js +58 -0
  94. package/dist/entity/update.js.map +1 -0
  95. package/dist/entity/variant-schema.d.ts +247 -0
  96. package/dist/entity/variant-schema.d.ts.map +1 -0
  97. package/dist/entity/variant-schema.js +204 -0
  98. package/dist/entity/variant-schema.js.map +1 -0
  99. package/dist/identity/auth-storage.d.ts +6 -0
  100. package/dist/identity/auth-storage.d.ts.map +1 -1
  101. package/dist/identity/auth-storage.js +52 -0
  102. package/dist/identity/auth-storage.js.map +1 -0
  103. package/dist/identity/get-verified-identity.d.ts +7 -0
  104. package/dist/identity/get-verified-identity.d.ts.map +1 -1
  105. package/dist/identity/get-verified-identity.js +37 -0
  106. package/dist/identity/get-verified-identity.js.map +1 -0
  107. package/dist/identity/identity-encryption.d.ts +7 -0
  108. package/dist/identity/identity-encryption.js +120 -0
  109. package/dist/identity/identity-encryption.js.map +1 -0
  110. package/dist/identity/index.d.ts +7 -0
  111. package/dist/identity/index.d.ts.map +1 -1
  112. package/dist/identity/index.js +7 -0
  113. package/dist/identity/index.js.map +1 -0
  114. package/dist/identity/logout.d.ts +3 -0
  115. package/dist/identity/logout.js +9 -0
  116. package/dist/identity/logout.js.map +1 -0
  117. package/dist/identity/prove-ownership.d.ts +15 -0
  118. package/dist/identity/prove-ownership.d.ts.map +1 -1
  119. package/dist/identity/prove-ownership.js +90 -0
  120. package/dist/identity/prove-ownership.js.map +1 -0
  121. package/dist/identity/types.d.ts +37 -0
  122. package/dist/identity/types.d.ts.map +1 -0
  123. package/dist/identity/types.js +11 -0
  124. package/dist/identity/types.js.map +1 -0
  125. package/dist/inboxes/create-inbox.d.ts +22 -0
  126. package/dist/inboxes/create-inbox.js +76 -0
  127. package/dist/inboxes/create-inbox.js.map +1 -0
  128. package/dist/inboxes/get-list-inboxes.d.ts +20 -0
  129. package/dist/inboxes/get-list-inboxes.js +45 -0
  130. package/dist/inboxes/get-list-inboxes.js.map +1 -0
  131. package/dist/inboxes/index.d.ts +11 -0
  132. package/dist/inboxes/index.js +11 -0
  133. package/dist/inboxes/index.js.map +1 -0
  134. package/dist/inboxes/merge-messages.d.ts +6 -0
  135. package/dist/inboxes/merge-messages.js +23 -0
  136. package/dist/inboxes/merge-messages.js.map +1 -0
  137. package/dist/inboxes/message-encryption.d.ts +15 -0
  138. package/dist/inboxes/message-encryption.js +29 -0
  139. package/dist/inboxes/message-encryption.js.map +1 -0
  140. package/dist/inboxes/message-validation.d.ts +6 -0
  141. package/dist/inboxes/message-validation.d.ts.map +1 -1
  142. package/dist/inboxes/message-validation.js +53 -0
  143. package/dist/inboxes/message-validation.js.map +1 -0
  144. package/dist/inboxes/prepare-message.d.ts +2 -2
  145. package/dist/inboxes/prepare-message.js +78 -0
  146. package/dist/inboxes/prepare-message.js.map +1 -0
  147. package/dist/inboxes/recover-inbox-creator.d.ts +5 -0
  148. package/dist/inboxes/recover-inbox-creator.js +24 -0
  149. package/dist/inboxes/recover-inbox-creator.js.map +1 -0
  150. package/dist/inboxes/recover-inbox-message-signer.d.ts +4 -0
  151. package/dist/inboxes/recover-inbox-message-signer.js +32 -0
  152. package/dist/inboxes/recover-inbox-message-signer.js.map +1 -0
  153. package/dist/inboxes/send-message.d.ts +19 -0
  154. package/dist/inboxes/send-message.js +58 -0
  155. package/dist/inboxes/send-message.js.map +1 -0
  156. package/dist/inboxes/types.d.ts +4 -0
  157. package/dist/inboxes/types.d.ts.map +1 -0
  158. package/dist/inboxes/types.js +3 -0
  159. package/dist/inboxes/types.js.map +1 -0
  160. package/dist/index.d.ts +14 -0
  161. package/dist/index.js +14 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/key/create-key.d.ts +11 -0
  164. package/dist/key/create-key.d.ts.map +1 -0
  165. package/dist/key/create-key.js +22 -0
  166. package/dist/key/create-key.js.map +1 -0
  167. package/dist/key/decrypt-key.d.ts +9 -0
  168. package/dist/key/decrypt-key.d.ts.map +1 -0
  169. package/dist/key/decrypt-key.js +16 -0
  170. package/dist/key/decrypt-key.js.map +1 -0
  171. package/dist/key/encrypt-key.d.ts +11 -0
  172. package/dist/key/encrypt-key.d.ts.map +1 -0
  173. package/dist/key/encrypt-key.js +20 -0
  174. package/dist/key/encrypt-key.js.map +1 -0
  175. package/dist/key/index.d.ts +5 -0
  176. package/dist/key/index.d.ts.map +1 -0
  177. package/dist/key/index.js +5 -0
  178. package/dist/key/index.js.map +1 -0
  179. package/dist/key/key-box.d.ts +19 -0
  180. package/dist/key/key-box.d.ts.map +1 -0
  181. package/dist/key/key-box.js +38 -0
  182. package/dist/key/key-box.js.map +1 -0
  183. package/dist/messages/decrypt-message.d.ts +7 -0
  184. package/dist/messages/decrypt-message.d.ts.map +1 -0
  185. package/dist/messages/decrypt-message.js +11 -0
  186. package/dist/messages/decrypt-message.js.map +1 -0
  187. package/dist/messages/encrypt-message.d.ts +7 -0
  188. package/dist/messages/encrypt-message.d.ts.map +1 -0
  189. package/dist/messages/encrypt-message.js +12 -0
  190. package/dist/messages/encrypt-message.js.map +1 -0
  191. package/dist/messages/index.d.ts +6 -0
  192. package/dist/messages/index.js +6 -0
  193. package/dist/messages/index.js.map +1 -0
  194. package/dist/messages/serialize.d.ts +3 -0
  195. package/dist/messages/serialize.d.ts.map +1 -0
  196. package/dist/messages/serialize.js +30 -0
  197. package/dist/messages/serialize.js.map +1 -0
  198. package/dist/messages/signed-update-message.d.ts +23 -0
  199. package/dist/messages/signed-update-message.js +56 -0
  200. package/dist/messages/signed-update-message.js.map +1 -0
  201. package/dist/messages/types.d.ts +1268 -0
  202. package/dist/messages/types.d.ts.map +1 -1
  203. package/dist/messages/types.js +312 -0
  204. package/dist/messages/types.js.map +1 -0
  205. package/dist/space-events/accept-invitation.d.ts +9 -0
  206. package/dist/space-events/accept-invitation.js +28 -0
  207. package/dist/space-events/accept-invitation.js.map +1 -0
  208. package/dist/space-events/apply-event.d.ts +11 -0
  209. package/dist/space-events/apply-event.js +130 -0
  210. package/dist/space-events/apply-event.js.map +1 -0
  211. package/dist/space-events/create-inbox.d.ts +14 -0
  212. package/dist/space-events/create-inbox.js +41 -0
  213. package/dist/space-events/create-inbox.js.map +1 -0
  214. package/dist/space-events/create-invitation.d.ts +12 -0
  215. package/dist/space-events/create-invitation.js +30 -0
  216. package/dist/space-events/create-invitation.js.map +1 -0
  217. package/dist/space-events/create-space.d.ts +9 -0
  218. package/dist/space-events/create-space.js +29 -0
  219. package/dist/space-events/create-space.js.map +1 -0
  220. package/dist/space-events/delete-space.d.ts +10 -0
  221. package/dist/space-events/delete-space.js +30 -0
  222. package/dist/space-events/delete-space.js.map +1 -0
  223. package/dist/space-events/hash-event.d.ts +3 -0
  224. package/dist/space-events/hash-event.js +7 -0
  225. package/dist/space-events/hash-event.js.map +1 -0
  226. package/dist/space-events/index.d.ts +9 -0
  227. package/dist/space-events/index.js +9 -0
  228. package/dist/space-events/index.js.map +1 -0
  229. package/dist/space-events/types.d.ts +222 -0
  230. package/dist/space-events/types.d.ts.map +1 -0
  231. package/dist/space-events/types.js +102 -0
  232. package/dist/space-events/types.js.map +1 -0
  233. package/dist/space-info/decrypt-space-info.d.ts +7 -0
  234. package/dist/space-info/decrypt-space-info.js +18 -0
  235. package/dist/space-info/decrypt-space-info.js.map +1 -0
  236. package/dist/space-info/encrypt-and-sign-space-info.d.ts +17 -0
  237. package/dist/space-info/encrypt-and-sign-space-info.js +39 -0
  238. package/dist/space-info/encrypt-and-sign-space-info.js.map +1 -0
  239. package/dist/space-info/index.d.ts +4 -0
  240. package/dist/space-info/index.js +4 -0
  241. package/dist/space-info/index.js.map +1 -0
  242. package/dist/space-info/types.d.ts +6 -0
  243. package/dist/space-info/types.d.ts.map +1 -0
  244. package/dist/space-info/types.js +5 -0
  245. package/dist/space-info/types.js.map +1 -0
  246. package/dist/store-connect.d.ts +149 -0
  247. package/dist/store-connect.d.ts.map +1 -1
  248. package/dist/store-connect.js +289 -0
  249. package/dist/store-connect.js.map +1 -0
  250. package/dist/store.d.ts +158 -0
  251. package/dist/store.d.ts.map +1 -1
  252. package/dist/store.js +354 -0
  253. package/dist/store.js.map +1 -0
  254. package/dist/type/type.d.ts +14 -0
  255. package/dist/type/type.d.ts.map +1 -1
  256. package/dist/type/type.js +25 -0
  257. package/dist/type/type.js.map +1 -0
  258. package/dist/types.d.ts +80 -0
  259. package/dist/types.d.ts.map +1 -0
  260. package/dist/types.js +37 -0
  261. package/dist/types.js.map +1 -0
  262. package/dist/utils/assertExhaustive.d.ts +2 -0
  263. package/dist/utils/assertExhaustive.d.ts.map +1 -0
  264. package/dist/utils/assertExhaustive.js +4 -0
  265. package/dist/utils/assertExhaustive.js.map +1 -0
  266. package/dist/utils/automergeId.d.ts +1 -1
  267. package/dist/utils/automergeId.d.ts.map +1 -1
  268. package/dist/utils/automergeId.js +1 -1
  269. package/dist/utils/automergeId.js.map +1 -1
  270. package/dist/utils/base58.d.ts +36 -0
  271. package/dist/utils/base58.d.ts.map +1 -0
  272. package/dist/utils/base58.js +62 -0
  273. package/dist/utils/base58.js.map +1 -0
  274. package/dist/utils/hexBytesAddressUtils.d.ts +4 -0
  275. package/dist/utils/hexBytesAddressUtils.d.ts.map +1 -0
  276. package/dist/utils/hexBytesAddressUtils.js +21 -0
  277. package/dist/utils/hexBytesAddressUtils.js.map +1 -0
  278. package/dist/utils/index.d.ts +9 -0
  279. package/dist/utils/index.js +9 -0
  280. package/dist/utils/index.js.map +1 -0
  281. package/dist/utils/internal/base58Utils.d.ts +4 -0
  282. package/dist/utils/internal/base58Utils.d.ts.map +1 -0
  283. package/dist/utils/internal/base58Utils.js +40 -0
  284. package/dist/utils/internal/base58Utils.js.map +1 -0
  285. package/dist/utils/internal/deep-merge.d.ts +7 -0
  286. package/dist/utils/internal/deep-merge.d.ts.map +1 -0
  287. package/dist/utils/internal/deep-merge.js +33 -0
  288. package/dist/utils/internal/deep-merge.js.map +1 -0
  289. package/dist/utils/isRelationField.d.ts +3 -0
  290. package/dist/utils/isRelationField.d.ts.map +1 -0
  291. package/dist/utils/isRelationField.js +8 -0
  292. package/dist/utils/isRelationField.js.map +1 -0
  293. package/dist/utils/jsc.d.ts +49 -0
  294. package/dist/utils/jsc.d.ts.map +1 -0
  295. package/dist/utils/jsc.js +88 -0
  296. package/dist/utils/jsc.js.map +1 -0
  297. package/dist/utils/stringToUint8Array.d.ts +3 -0
  298. package/dist/utils/stringToUint8Array.d.ts.map +1 -0
  299. package/dist/utils/stringToUint8Array.js +9 -0
  300. package/dist/utils/stringToUint8Array.js.map +1 -0
  301. package/package.json +5 -2
  302. package/src/connect/abis/MainVotingPlugin.json +1865 -0
  303. package/src/connect/abis/PersonalSpaceAdminPlugin.json +531 -0
  304. package/src/connect/abis.ts +183 -0
  305. package/src/connect/create-callback-params.ts +4 -1
  306. package/src/connect/identity-encryption.ts +10 -14
  307. package/src/connect/index.ts +1 -1
  308. package/src/connect/login.ts +106 -18
  309. package/src/connect/parse-callback-params.ts +4 -1
  310. package/src/connect/smart-account.ts +915 -0
  311. package/src/connect/types.ts +2 -0
  312. package/src/entity/decodedEntitiesCache.ts +1 -1
  313. package/src/entity/findMany.ts +16 -14
  314. package/src/entity/getEntityRelations.ts +1 -1
  315. package/src/entity/types.ts +8 -8
  316. package/src/identity/auth-storage.ts +11 -1
  317. package/src/identity/get-verified-identity.ts +6 -1
  318. package/src/identity/index.ts +1 -1
  319. package/src/identity/prove-ownership.ts +52 -8
  320. package/src/inboxes/message-validation.ts +17 -2
  321. package/src/messages/types.ts +6 -0
  322. package/src/store-connect.ts +1 -52
  323. package/src/store.ts +78 -48
  324. package/src/type/type.ts +4 -2
  325. package/src/types.ts +19 -1
  326. package/src/utils/automergeId.ts +1 -1
  327. package/dist/connect/prove-ownership.d.ts.map +0 -1
  328. package/src/connect/prove-ownership.ts +0 -58
@@ -0,0 +1,30 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { Effect } from 'effect';
3
+ import { canonicalize, generateId, hexToBytes, stringToUint8Array } from '../utils/index.js';
4
+ export const createInvitation = ({
5
+ author,
6
+ previousEventHash,
7
+ invitee
8
+ }) => {
9
+ const transaction = {
10
+ id: generateId(),
11
+ type: 'create-invitation',
12
+ inviteeAccountAddress: invitee.accountAddress,
13
+ previousEventHash
14
+ };
15
+ const encodedTransaction = stringToUint8Array(canonicalize(transaction));
16
+ const signatureResult = secp256k1.sign(encodedTransaction, hexToBytes(author.signaturePrivateKey), {
17
+ prehash: true
18
+ });
19
+ return Effect.succeed({
20
+ transaction,
21
+ author: {
22
+ accountAddress: author.accountAddress,
23
+ signature: {
24
+ hex: signatureResult.toCompactHex(),
25
+ recovery: signatureResult.recovery
26
+ }
27
+ }
28
+ });
29
+ };
30
+ //# sourceMappingURL=create-invitation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-invitation.js","names":["secp256k1","Effect","canonicalize","generateId","hexToBytes","stringToUint8Array","createInvitation","author","previousEventHash","invitee","transaction","id","type","inviteeAccountAddress","accountAddress","encodedTransaction","signatureResult","sign","signaturePrivateKey","prehash","succeed","signature","hex","toCompactHex","recovery"],"sources":["../../src/space-events/create-invitation.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAS,QAAQ,yBAAyB;AACnD,SAASC,MAAM,QAAQ,QAAQ;AAE/B,SAASC,YAAY,EAAEC,UAAU,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,mBAAmB;AAW5F,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,MAAM;EACNC,iBAAiB;EACjBC;AAAO,CACA,KAAqD;EAC5D,MAAMC,WAAW,GAAG;IAClBC,EAAE,EAAER,UAAU,EAAE;IAChBS,IAAI,EAAE,mBAA4B;IAClCC,qBAAqB,EAAEJ,OAAO,CAACK,cAAc;IAC7CN;GACD;EACD,MAAMO,kBAAkB,GAAGV,kBAAkB,CAACH,YAAY,CAACQ,WAAW,CAAC,CAAC;EACxE,MAAMM,eAAe,GAAGhB,SAAS,CAACiB,IAAI,CAACF,kBAAkB,EAAEX,UAAU,CAACG,MAAM,CAACW,mBAAmB,CAAC,EAAE;IACjGC,OAAO,EAAE;GACV,CAAC;EAEF,OAAOlB,MAAM,CAACmB,OAAO,CAAC;IACpBV,WAAW;IACXH,MAAM,EAAE;MACNO,cAAc,EAAEP,MAAM,CAACO,cAAc;MACrCO,SAAS,EAAE;QACTC,GAAG,EAAEN,eAAe,CAACO,YAAY,EAAE;QACnCC,QAAQ,EAAER,eAAe,CAACQ;;;GAG/B,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { Effect } from 'effect';
2
+ import type { Author, CreateSpaceEvent } from './types.js';
3
+ type Params = {
4
+ author: Author;
5
+ spaceId?: string;
6
+ };
7
+ export declare const createSpace: ({ author, spaceId }: Params) => Effect.Effect<CreateSpaceEvent, undefined>;
8
+ export {};
9
+ //# sourceMappingURL=create-space.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { Effect } from 'effect';
3
+ import { canonicalize, generateId, hexToBytes, stringToUint8Array } from '../utils/index.js';
4
+ export const createSpace = ({
5
+ author,
6
+ spaceId
7
+ }) => {
8
+ const transaction = {
9
+ type: 'create-space',
10
+ id: spaceId ?? generateId(),
11
+ creatorAccountAddress: author.accountAddress
12
+ };
13
+ const encodedTransaction = stringToUint8Array(canonicalize(transaction));
14
+ const signatureResult = secp256k1.sign(encodedTransaction, hexToBytes(author.signaturePrivateKey), {
15
+ prehash: true
16
+ });
17
+ const event = {
18
+ transaction,
19
+ author: {
20
+ accountAddress: author.accountAddress,
21
+ signature: {
22
+ hex: signatureResult.toCompactHex(),
23
+ recovery: signatureResult.recovery
24
+ }
25
+ }
26
+ };
27
+ return Effect.succeed(event);
28
+ };
29
+ //# sourceMappingURL=create-space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-space.js","names":["secp256k1","Effect","canonicalize","generateId","hexToBytes","stringToUint8Array","createSpace","author","spaceId","transaction","type","id","creatorAccountAddress","accountAddress","encodedTransaction","signatureResult","sign","signaturePrivateKey","prehash","event","signature","hex","toCompactHex","recovery","succeed"],"sources":["../../src/space-events/create-space.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAS,QAAQ,yBAAyB;AACnD,SAASC,MAAM,QAAQ,QAAQ;AAE/B,SAASC,YAAY,EAAEC,UAAU,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,mBAAmB;AAQ5F,OAAO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAAO,CAAU,KAAgD;EACrG,MAAMC,WAAW,GAAG;IAClBC,IAAI,EAAE,cAAuB;IAC7BC,EAAE,EAAEH,OAAO,IAAIL,UAAU,EAAE;IAC3BS,qBAAqB,EAAEL,MAAM,CAACM;GAC/B;EACD,MAAMC,kBAAkB,GAAGT,kBAAkB,CAACH,YAAY,CAACO,WAAW,CAAC,CAAC;EACxE,MAAMM,eAAe,GAAGf,SAAS,CAACgB,IAAI,CAACF,kBAAkB,EAAEV,UAAU,CAACG,MAAM,CAACU,mBAAmB,CAAC,EAAE;IACjGC,OAAO,EAAE;GACV,CAAC;EAEF,MAAMC,KAAK,GAAqB;IAC9BV,WAAW;IACXF,MAAM,EAAE;MACNM,cAAc,EAAEN,MAAM,CAACM,cAAc;MACrCO,SAAS,EAAE;QACTC,GAAG,EAAEN,eAAe,CAACO,YAAY,EAAE;QACnCC,QAAQ,EAAER,eAAe,CAACQ;;;GAG/B;EAED,OAAOtB,MAAM,CAACuB,OAAO,CAACL,KAAK,CAAC;AAC9B,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import { Effect } from 'effect';
2
+ import type { Author, SpaceEvent } from './types.js';
3
+ type Params = {
4
+ author: Author;
5
+ id: string;
6
+ previousEventHash: string;
7
+ };
8
+ export declare const deleteSpace: ({ author, id, previousEventHash }: Params) => Effect.Effect<SpaceEvent, undefined>;
9
+ export {};
10
+ //# sourceMappingURL=delete-space.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { Effect } from 'effect';
3
+ import { canonicalize, hexToBytes, stringToUint8Array } from '../utils/index.js';
4
+ export const deleteSpace = ({
5
+ author,
6
+ id,
7
+ previousEventHash
8
+ }) => {
9
+ const transaction = {
10
+ type: 'delete-space',
11
+ id,
12
+ previousEventHash
13
+ };
14
+ const encodedTransaction = stringToUint8Array(canonicalize(transaction));
15
+ const signatureResult = secp256k1.sign(encodedTransaction, hexToBytes(author.signaturePrivateKey), {
16
+ prehash: true
17
+ });
18
+ const event = {
19
+ transaction,
20
+ author: {
21
+ accountAddress: author.accountAddress,
22
+ signature: {
23
+ hex: signatureResult.toCompactHex(),
24
+ recovery: signatureResult.recovery
25
+ }
26
+ }
27
+ };
28
+ return Effect.succeed(event);
29
+ };
30
+ //# sourceMappingURL=delete-space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-space.js","names":["secp256k1","Effect","canonicalize","hexToBytes","stringToUint8Array","deleteSpace","author","id","previousEventHash","transaction","type","encodedTransaction","signatureResult","sign","signaturePrivateKey","prehash","event","accountAddress","signature","hex","toCompactHex","recovery","succeed"],"sources":["../../src/space-events/delete-space.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAS,QAAQ,yBAAyB;AACnD,SAASC,MAAM,QAAQ,QAAQ;AAE/B,SAASC,YAAY,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,mBAAmB;AAUhF,OAAO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,MAAM;EAAEC,EAAE;EAAEC;AAAiB,CAAU,KAA0C;EAC7G,MAAMC,WAAW,GAAG;IAClBC,IAAI,EAAE,cAAuB;IAC7BH,EAAE;IACFC;GACD;EACD,MAAMG,kBAAkB,GAAGP,kBAAkB,CAACF,YAAY,CAACO,WAAW,CAAC,CAAC;EACxE,MAAMG,eAAe,GAAGZ,SAAS,CAACa,IAAI,CAACF,kBAAkB,EAAER,UAAU,CAACG,MAAM,CAACQ,mBAAmB,CAAC,EAAE;IACjGC,OAAO,EAAE;GACV,CAAC;EAEF,MAAMC,KAAK,GAAqB;IAC9BP,WAAW;IACXH,MAAM,EAAE;MACNW,cAAc,EAAEX,MAAM,CAACW,cAAc;MACrCC,SAAS,EAAE;QACTC,GAAG,EAAEP,eAAe,CAACQ,YAAY,EAAE;QACnCC,QAAQ,EAAET,eAAe,CAACS;;;GAG/B;EACD,OAAOpB,MAAM,CAACqB,OAAO,CAACN,KAAK,CAAC;AAC9B,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { SpaceEvent } from './types.js';
2
+ export declare const hashEvent: (event: SpaceEvent) => string;
3
+ //# sourceMappingURL=hash-event.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { blake3 } from '@noble/hashes/blake3';
2
+ import { bytesToHex, canonicalize } from '../utils/index.js';
3
+ export const hashEvent = event => {
4
+ const hash = blake3(canonicalize(event));
5
+ return bytesToHex(hash);
6
+ };
7
+ //# sourceMappingURL=hash-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-event.js","names":["blake3","bytesToHex","canonicalize","hashEvent","event","hash"],"sources":["../../src/space-events/hash-event.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,sBAAsB;AAE7C,SAASC,UAAU,EAAEC,YAAY,QAAQ,mBAAmB;AAI5D,OAAO,MAAMC,SAAS,GAAIC,KAAiB,IAAY;EACrD,MAAMC,IAAI,GAAGL,MAAM,CAACE,YAAY,CAACE,KAAK,CAAC,CAAC;EACxC,OAAOH,UAAU,CAACI,IAAI,CAAC;AACzB,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ export * from './accept-invitation.js';
2
+ export * from './apply-event.js';
3
+ export * from './create-inbox.js';
4
+ export * from './create-invitation.js';
5
+ export * from './create-space.js';
6
+ export * from './delete-space.js';
7
+ export * from './hash-event.js';
8
+ export * from './types.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,9 @@
1
+ export * from './accept-invitation.js';
2
+ export * from './apply-event.js';
3
+ export * from './create-inbox.js';
4
+ export * from './create-invitation.js';
5
+ export * from './create-space.js';
6
+ export * from './delete-space.js';
7
+ export * from './hash-event.js';
8
+ export * from './types.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/space-events/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,wBAAwB;AACtC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,iBAAiB;AAC/B,cAAc,YAAY","ignoreList":[]}
@@ -0,0 +1,222 @@
1
+ import type { ParseError } from 'effect/ParseResult';
2
+ import * as Schema from 'effect/Schema';
3
+ import type { InvalidIdentityError } from '../identity/types.js';
4
+ export declare const EventAuthor: Schema.Struct<{
5
+ accountAddress: typeof Schema.String;
6
+ signature: Schema.Struct<{
7
+ hex: typeof Schema.String;
8
+ recovery: typeof Schema.Number;
9
+ }>;
10
+ }>;
11
+ export type EventAuthor = Schema.Schema.Type<typeof Author>;
12
+ export declare const SpaceMember: Schema.Struct<{
13
+ accountAddress: typeof Schema.String;
14
+ role: Schema.Union<[Schema.Literal<["admin"]>, Schema.Literal<["member"]>]>;
15
+ }>;
16
+ export type SpaceMember = Schema.Schema.Type<typeof SpaceMember>;
17
+ export declare const SpaceInvitation: Schema.Struct<{
18
+ inviteeAccountAddress: typeof Schema.String;
19
+ }>;
20
+ export type SpaceInvitation = Schema.Schema.Type<typeof SpaceInvitation>;
21
+ export declare const SpaceInbox: Schema.Struct<{
22
+ inboxId: typeof Schema.String;
23
+ encryptionPublicKey: typeof Schema.String;
24
+ isPublic: typeof Schema.Boolean;
25
+ authPolicy: Schema.Union<[Schema.Literal<["anonymous"]>, Schema.Literal<["optional_auth"]>, Schema.Literal<["requires_auth"]>]>;
26
+ secretKey: typeof Schema.String;
27
+ }>;
28
+ export type SpaceInbox = Schema.Schema.Type<typeof SpaceInbox>;
29
+ export declare const SpaceState: Schema.Struct<{
30
+ id: typeof Schema.String;
31
+ invitations: Schema.Record$<typeof Schema.String, Schema.Struct<{
32
+ inviteeAccountAddress: typeof Schema.String;
33
+ }>>;
34
+ members: Schema.Record$<typeof Schema.String, Schema.Struct<{
35
+ accountAddress: typeof Schema.String;
36
+ role: Schema.Union<[Schema.Literal<["admin"]>, Schema.Literal<["member"]>]>;
37
+ }>>;
38
+ removedMembers: Schema.Record$<typeof Schema.String, Schema.Struct<{
39
+ accountAddress: typeof Schema.String;
40
+ role: Schema.Union<[Schema.Literal<["admin"]>, Schema.Literal<["member"]>]>;
41
+ }>>;
42
+ inboxes: Schema.Record$<typeof Schema.String, Schema.Struct<{
43
+ inboxId: typeof Schema.String;
44
+ encryptionPublicKey: typeof Schema.String;
45
+ isPublic: typeof Schema.Boolean;
46
+ authPolicy: Schema.Union<[Schema.Literal<["anonymous"]>, Schema.Literal<["optional_auth"]>, Schema.Literal<["requires_auth"]>]>;
47
+ secretKey: typeof Schema.String;
48
+ }>>;
49
+ lastEventHash: typeof Schema.String;
50
+ }>;
51
+ export type SpaceState = Schema.Schema.Type<typeof SpaceState>;
52
+ export declare const CreateSpaceEvent: Schema.Struct<{
53
+ transaction: Schema.Struct<{
54
+ type: Schema.Literal<["create-space"]>;
55
+ id: typeof Schema.String;
56
+ creatorAccountAddress: typeof Schema.String;
57
+ }>;
58
+ author: Schema.Struct<{
59
+ accountAddress: typeof Schema.String;
60
+ signature: Schema.Struct<{
61
+ hex: typeof Schema.String;
62
+ recovery: typeof Schema.Number;
63
+ }>;
64
+ }>;
65
+ }>;
66
+ export type CreateSpaceEvent = Schema.Schema.Type<typeof CreateSpaceEvent>;
67
+ export declare const DeleteSpaceEvent: Schema.Struct<{
68
+ transaction: Schema.Struct<{
69
+ type: Schema.Literal<["delete-space"]>;
70
+ id: typeof Schema.String;
71
+ previousEventHash: typeof Schema.String;
72
+ }>;
73
+ author: Schema.Struct<{
74
+ accountAddress: typeof Schema.String;
75
+ signature: Schema.Struct<{
76
+ hex: typeof Schema.String;
77
+ recovery: typeof Schema.Number;
78
+ }>;
79
+ }>;
80
+ }>;
81
+ export type DeleteSpaceEvent = Schema.Schema.Type<typeof DeleteSpaceEvent>;
82
+ export declare const CreateInvitationEvent: Schema.Struct<{
83
+ transaction: Schema.Struct<{
84
+ type: Schema.Literal<["create-invitation"]>;
85
+ id: typeof Schema.String;
86
+ inviteeAccountAddress: typeof Schema.String;
87
+ previousEventHash: typeof Schema.String;
88
+ }>;
89
+ author: Schema.Struct<{
90
+ accountAddress: typeof Schema.String;
91
+ signature: Schema.Struct<{
92
+ hex: typeof Schema.String;
93
+ recovery: typeof Schema.Number;
94
+ }>;
95
+ }>;
96
+ }>;
97
+ export type CreateInvitationEvent = Schema.Schema.Type<typeof CreateInvitationEvent>;
98
+ export declare const CreateSpaceInboxEvent: Schema.Struct<{
99
+ transaction: Schema.Struct<{
100
+ type: Schema.Literal<["create-space-inbox"]>;
101
+ id: typeof Schema.String;
102
+ spaceId: typeof Schema.String;
103
+ inboxId: typeof Schema.String;
104
+ encryptionPublicKey: typeof Schema.String;
105
+ secretKey: typeof Schema.String;
106
+ isPublic: typeof Schema.Boolean;
107
+ authPolicy: Schema.Union<[Schema.Literal<["anonymous"]>, Schema.Literal<["optional_auth"]>, Schema.Literal<["requires_auth"]>]>;
108
+ previousEventHash: typeof Schema.String;
109
+ }>;
110
+ author: Schema.Struct<{
111
+ accountAddress: typeof Schema.String;
112
+ signature: Schema.Struct<{
113
+ hex: typeof Schema.String;
114
+ recovery: typeof Schema.Number;
115
+ }>;
116
+ }>;
117
+ }>;
118
+ export type CreateSpaceInboxEvent = Schema.Schema.Type<typeof CreateSpaceInboxEvent>;
119
+ export declare const AcceptInvitationEvent: Schema.Struct<{
120
+ transaction: Schema.Struct<{
121
+ id: typeof Schema.String;
122
+ type: Schema.Literal<["accept-invitation"]>;
123
+ previousEventHash: typeof Schema.String;
124
+ }>;
125
+ author: Schema.Struct<{
126
+ accountAddress: typeof Schema.String;
127
+ signature: Schema.Struct<{
128
+ hex: typeof Schema.String;
129
+ recovery: typeof Schema.Number;
130
+ }>;
131
+ }>;
132
+ }>;
133
+ export type AcceptInvitationEvent = Schema.Schema.Type<typeof AcceptInvitationEvent>;
134
+ export declare const SpaceEvent: Schema.Union<[Schema.Struct<{
135
+ transaction: Schema.Struct<{
136
+ type: Schema.Literal<["create-space"]>;
137
+ id: typeof Schema.String;
138
+ creatorAccountAddress: typeof Schema.String;
139
+ }>;
140
+ author: Schema.Struct<{
141
+ accountAddress: typeof Schema.String;
142
+ signature: Schema.Struct<{
143
+ hex: typeof Schema.String;
144
+ recovery: typeof Schema.Number;
145
+ }>;
146
+ }>;
147
+ }>, Schema.Struct<{
148
+ transaction: Schema.Struct<{
149
+ type: Schema.Literal<["delete-space"]>;
150
+ id: typeof Schema.String;
151
+ previousEventHash: typeof Schema.String;
152
+ }>;
153
+ author: Schema.Struct<{
154
+ accountAddress: typeof Schema.String;
155
+ signature: Schema.Struct<{
156
+ hex: typeof Schema.String;
157
+ recovery: typeof Schema.Number;
158
+ }>;
159
+ }>;
160
+ }>, Schema.Struct<{
161
+ transaction: Schema.Struct<{
162
+ type: Schema.Literal<["create-invitation"]>;
163
+ id: typeof Schema.String;
164
+ inviteeAccountAddress: typeof Schema.String;
165
+ previousEventHash: typeof Schema.String;
166
+ }>;
167
+ author: Schema.Struct<{
168
+ accountAddress: typeof Schema.String;
169
+ signature: Schema.Struct<{
170
+ hex: typeof Schema.String;
171
+ recovery: typeof Schema.Number;
172
+ }>;
173
+ }>;
174
+ }>, Schema.Struct<{
175
+ transaction: Schema.Struct<{
176
+ id: typeof Schema.String;
177
+ type: Schema.Literal<["accept-invitation"]>;
178
+ previousEventHash: typeof Schema.String;
179
+ }>;
180
+ author: Schema.Struct<{
181
+ accountAddress: typeof Schema.String;
182
+ signature: Schema.Struct<{
183
+ hex: typeof Schema.String;
184
+ recovery: typeof Schema.Number;
185
+ }>;
186
+ }>;
187
+ }>, Schema.Struct<{
188
+ transaction: Schema.Struct<{
189
+ type: Schema.Literal<["create-space-inbox"]>;
190
+ id: typeof Schema.String;
191
+ spaceId: typeof Schema.String;
192
+ inboxId: typeof Schema.String;
193
+ encryptionPublicKey: typeof Schema.String;
194
+ secretKey: typeof Schema.String;
195
+ isPublic: typeof Schema.Boolean;
196
+ authPolicy: Schema.Union<[Schema.Literal<["anonymous"]>, Schema.Literal<["optional_auth"]>, Schema.Literal<["requires_auth"]>]>;
197
+ previousEventHash: typeof Schema.String;
198
+ }>;
199
+ author: Schema.Struct<{
200
+ accountAddress: typeof Schema.String;
201
+ signature: Schema.Struct<{
202
+ hex: typeof Schema.String;
203
+ recovery: typeof Schema.Number;
204
+ }>;
205
+ }>;
206
+ }>]>;
207
+ export type SpaceEvent = Schema.Schema.Type<typeof SpaceEvent>;
208
+ export declare const Author: Schema.Struct<{
209
+ accountAddress: typeof Schema.String;
210
+ signaturePublicKey: typeof Schema.String;
211
+ signaturePrivateKey: typeof Schema.String;
212
+ encryptionPublicKey: typeof Schema.String;
213
+ }>;
214
+ export type Author = Schema.Schema.Type<typeof Author>;
215
+ export declare class VerifySignatureError {
216
+ readonly _tag = "VerifySignatureError";
217
+ }
218
+ export declare class InvalidEventError {
219
+ readonly _tag = "InvalidEventError";
220
+ }
221
+ export type ApplyError = ParseError | VerifySignatureError | InvalidEventError | InvalidIdentityError;
222
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/space-events/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE,eAAO,MAAM,WAAW;;;;;;EAGtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5D,eAAO,MAAM,WAAW;;;EAGtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAEjE,eAAO,MAAM,eAAe;;EAE1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAC;AAEzE,eAAO,MAAM,UAAU;;;;;;EAMrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;EAOrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;EAO3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM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+ import * as Schema from 'effect/Schema';
2
+ import { InboxSenderAuthPolicy } from '../inboxes/types.js';
3
+ import { SignatureWithRecovery } from '../types.js';
4
+ export const EventAuthor = /*#__PURE__*/Schema.Struct({
5
+ accountAddress: Schema.String,
6
+ signature: SignatureWithRecovery
7
+ });
8
+ export const SpaceMember = /*#__PURE__*/Schema.Struct({
9
+ accountAddress: Schema.String,
10
+ role: /*#__PURE__*/Schema.Union(/*#__PURE__*/Schema.Literal('admin'), /*#__PURE__*/Schema.Literal('member'))
11
+ });
12
+ export const SpaceInvitation = /*#__PURE__*/Schema.Struct({
13
+ inviteeAccountAddress: Schema.String
14
+ });
15
+ export const SpaceInbox = /*#__PURE__*/Schema.Struct({
16
+ inboxId: Schema.String,
17
+ encryptionPublicKey: Schema.String,
18
+ isPublic: Schema.Boolean,
19
+ authPolicy: InboxSenderAuthPolicy,
20
+ secretKey: Schema.String
21
+ });
22
+ export const SpaceState = /*#__PURE__*/Schema.Struct({
23
+ id: Schema.String,
24
+ invitations: /*#__PURE__*/Schema.Record({
25
+ key: Schema.String,
26
+ value: SpaceInvitation
27
+ }),
28
+ members: /*#__PURE__*/Schema.Record({
29
+ key: Schema.String,
30
+ value: SpaceMember
31
+ }),
32
+ removedMembers: /*#__PURE__*/Schema.Record({
33
+ key: Schema.String,
34
+ value: SpaceMember
35
+ }),
36
+ inboxes: /*#__PURE__*/Schema.Record({
37
+ key: Schema.String,
38
+ value: SpaceInbox
39
+ }),
40
+ lastEventHash: Schema.String
41
+ });
42
+ export const CreateSpaceEvent = /*#__PURE__*/Schema.Struct({
43
+ transaction: /*#__PURE__*/Schema.Struct({
44
+ type: /*#__PURE__*/Schema.Literal('create-space'),
45
+ id: Schema.String,
46
+ creatorAccountAddress: Schema.String
47
+ }),
48
+ author: EventAuthor
49
+ });
50
+ export const DeleteSpaceEvent = /*#__PURE__*/Schema.Struct({
51
+ transaction: /*#__PURE__*/Schema.Struct({
52
+ type: /*#__PURE__*/Schema.Literal('delete-space'),
53
+ id: Schema.String,
54
+ previousEventHash: Schema.String
55
+ }),
56
+ author: EventAuthor
57
+ });
58
+ export const CreateInvitationEvent = /*#__PURE__*/Schema.Struct({
59
+ transaction: /*#__PURE__*/Schema.Struct({
60
+ type: /*#__PURE__*/Schema.Literal('create-invitation'),
61
+ id: Schema.String,
62
+ inviteeAccountAddress: Schema.String,
63
+ previousEventHash: Schema.String
64
+ }),
65
+ author: EventAuthor
66
+ });
67
+ export const CreateSpaceInboxEvent = /*#__PURE__*/Schema.Struct({
68
+ transaction: /*#__PURE__*/Schema.Struct({
69
+ type: /*#__PURE__*/Schema.Literal('create-space-inbox'),
70
+ id: Schema.String,
71
+ spaceId: Schema.String,
72
+ inboxId: Schema.String,
73
+ encryptionPublicKey: Schema.String,
74
+ secretKey: Schema.String,
75
+ isPublic: Schema.Boolean,
76
+ authPolicy: InboxSenderAuthPolicy,
77
+ previousEventHash: Schema.String
78
+ }),
79
+ author: EventAuthor
80
+ });
81
+ export const AcceptInvitationEvent = /*#__PURE__*/Schema.Struct({
82
+ transaction: /*#__PURE__*/Schema.Struct({
83
+ id: Schema.String,
84
+ type: /*#__PURE__*/Schema.Literal('accept-invitation'),
85
+ previousEventHash: Schema.String
86
+ }),
87
+ author: EventAuthor
88
+ });
89
+ export const SpaceEvent = /*#__PURE__*/Schema.Union(CreateSpaceEvent, DeleteSpaceEvent, CreateInvitationEvent, AcceptInvitationEvent, CreateSpaceInboxEvent);
90
+ export const Author = /*#__PURE__*/Schema.Struct({
91
+ accountAddress: Schema.String,
92
+ signaturePublicKey: Schema.String,
93
+ signaturePrivateKey: Schema.String,
94
+ encryptionPublicKey: Schema.String
95
+ });
96
+ export class VerifySignatureError {
97
+ _tag = 'VerifySignatureError';
98
+ }
99
+ export class InvalidEventError {
100
+ _tag = 'InvalidEventError';
101
+ }
102
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":["Schema","InboxSenderAuthPolicy","SignatureWithRecovery","EventAuthor","Struct","accountAddress","String","signature","SpaceMember","role","Union","Literal","SpaceInvitation","inviteeAccountAddress","SpaceInbox","inboxId","encryptionPublicKey","isPublic","Boolean","authPolicy","secretKey","SpaceState","id","invitations","Record","key","value","members","removedMembers","inboxes","lastEventHash","CreateSpaceEvent","transaction","type","creatorAccountAddress","author","DeleteSpaceEvent","previousEventHash","CreateInvitationEvent","CreateSpaceInboxEvent","spaceId","AcceptInvitationEvent","SpaceEvent","Author","signaturePublicKey","signaturePrivateKey","VerifySignatureError","_tag","InvalidEventError"],"sources":["../../src/space-events/types.ts"],"sourcesContent":[null],"mappings":"AACA,OAAO,KAAKA,MAAM,MAAM,eAAe;AAEvC,SAASC,qBAAqB,QAAQ,qBAAqB;AAC3D,SAASC,qBAAqB,QAAQ,aAAa;AAEnD,OAAO,MAAMC,WAAW,gBAAGH,MAAM,CAACI,MAAM,CAAC;EACvCC,cAAc,EAAEL,MAAM,CAACM,MAAM;EAC7BC,SAAS,EAAEL;CACZ,CAAC;AAIF,OAAO,MAAMM,WAAW,gBAAGR,MAAM,CAACI,MAAM,CAAC;EACvCC,cAAc,EAAEL,MAAM,CAACM,MAAM;EAC7BG,IAAI,eAAET,MAAM,CAACU,KAAK,cAACV,MAAM,CAACW,OAAO,CAAC,OAAO,CAAC,eAAEX,MAAM,CAACW,OAAO,CAAC,QAAQ,CAAC;CACrE,CAAC;AAIF,OAAO,MAAMC,eAAe,gBAAGZ,MAAM,CAACI,MAAM,CAAC;EAC3CS,qBAAqB,EAAEb,MAAM,CAACM;CAC/B,CAAC;AAIF,OAAO,MAAMQ,UAAU,gBAAGd,MAAM,CAACI,MAAM,CAAC;EACtCW,OAAO,EAAEf,MAAM,CAACM,MAAM;EACtBU,mBAAmB,EAAEhB,MAAM,CAACM,MAAM;EAClCW,QAAQ,EAAEjB,MAAM,CAACkB,OAAO;EACxBC,UAAU,EAAElB,qBAAqB;EACjCmB,SAAS,EAAEpB,MAAM,CAACM;CACnB,CAAC;AAIF,OAAO,MA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,EAChBE,qBAAqB,EACrBG,qBAAqB,EACrBF,qBAAqB,CACtB;AAID,OAAO,MAAMI,MAAM,gBAAG3C,MAAM,CAACI,MAAM,CAAC;EAClCC,cAAc,EAAEL,MAAM,CAACM,MAAM;EAC7BsC,kBAAkB,EAAE5C,MAAM,CAACM,MAAM;EACjCuC,mBAAmB,EAAE7C,MAAM,CAACM,MAAM;EAClCU,mBAAmB,EAAEhB,MAAM,CAACM;CAC7B,CAAC;AAIF,OAAM,MAAOwC,oBAAoB;EACtBC,IAAI,GAAG,sBAAsB;;AAGxC,OAAM,MAAOC,iBAAiB;EACnBD,IAAI,GAAG,mBAAmB","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ export declare const decryptSpaceInfo: ({ spaceInfo, secretKey, }: {
2
+ spaceInfo: Uint8Array;
3
+ secretKey: string;
4
+ }) => {
5
+ readonly name: string;
6
+ };
7
+ //# sourceMappingURL=decrypt-space-info.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { bytesToUtf8 } from '@noble/hashes/utils';
2
+ import * as Schema from 'effect/Schema';
3
+ import { decryptMessage } from '../messages/index.js';
4
+ import { hexToBytes } from '../utils/index.js';
5
+ import { SpaceInfoContent } from './types.js';
6
+ const decodeSpaceInfoContent = /*#__PURE__*/Schema.decodeSync(SpaceInfoContent);
7
+ export const decryptSpaceInfo = ({
8
+ spaceInfo,
9
+ secretKey
10
+ }) => {
11
+ const decrypted = decryptMessage({
12
+ nonceAndCiphertext: spaceInfo,
13
+ secretKey: hexToBytes(secretKey)
14
+ });
15
+ const spaceInfoContent = decodeSpaceInfoContent(JSON.parse(bytesToUtf8(decrypted)));
16
+ return spaceInfoContent;
17
+ };
18
+ //# sourceMappingURL=decrypt-space-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decrypt-space-info.js","names":["bytesToUtf8","Schema","decryptMessage","hexToBytes","SpaceInfoContent","decodeSpaceInfoContent","decodeSync","decryptSpaceInfo","spaceInfo","secretKey","decrypted","nonceAndCiphertext","spaceInfoContent","JSON","parse"],"sources":["../../src/space-info/decrypt-space-info.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,qBAAqB;AACjD,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,cAAc,QAAQ,sBAAsB;AACrD,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,MAAMC,sBAAsB,gBAAGJ,MAAM,CAACK,UAAU,CAACF,gBAAgB,CAAC;AAElE,OAAO,MAAMG,gBAAgB,GAAGA,CAAC;EAC/BC,SAAS;EACTC;AAAS,CAIV,KAAI;EACH,MAAMC,SAAS,GAAGR,cAAc,CAAC;IAC/BS,kBAAkB,EAAEH,SAAS;IAC7BC,SAAS,EAAEN,UAAU,CAACM,SAAS;GAChC,CAAC;EACF,MAAMG,gBAAgB,GAAGP,sBAAsB,CAACQ,IAAI,CAACC,KAAK,CAACd,WAAW,CAACU,SAAS,CAAC,CAAC,CAAC;EACnF,OAAOE,gBAAgB;AACzB,CAAC","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ interface EncryptAndSignInfoParams {
2
+ accountAddress: string;
3
+ name: string;
4
+ secretKey: string;
5
+ signaturePrivateKey: string;
6
+ spaceId: string;
7
+ }
8
+ export declare const encryptAndSignSpaceInfo: ({ accountAddress, name, secretKey, signaturePrivateKey, spaceId, }: EncryptAndSignInfoParams) => {
9
+ infoContent: Uint8Array<ArrayBuffer>;
10
+ accountAddress: string;
11
+ signature: {
12
+ hex: string;
13
+ recovery: number;
14
+ };
15
+ };
16
+ export {};
17
+ //# sourceMappingURL=encrypt-and-sign-space-info.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1';
2
+ import { utf8ToBytes } from '@noble/hashes/utils';
3
+ import * as Schema from 'effect/Schema';
4
+ import { encryptMessage } from '../messages/encrypt-message.js';
5
+ import { canonicalize, hexToBytes, stringToUint8Array } from '../utils/index.js';
6
+ import { SpaceInfoContent } from './types.js';
7
+ const encodeSpaceInfoContent = /*#__PURE__*/Schema.encodeSync(SpaceInfoContent);
8
+ export const encryptAndSignSpaceInfo = ({
9
+ accountAddress,
10
+ name,
11
+ secretKey,
12
+ signaturePrivateKey,
13
+ spaceId
14
+ }) => {
15
+ const infoContent = encryptMessage({
16
+ message: utf8ToBytes(JSON.stringify(encodeSpaceInfoContent({
17
+ name: name
18
+ }))),
19
+ secretKey: hexToBytes(secretKey)
20
+ });
21
+ const messageToSign = stringToUint8Array(canonicalize({
22
+ accountAddress,
23
+ infoContent,
24
+ spaceId
25
+ }));
26
+ const recoverySignature = secp256k1.sign(messageToSign, hexToBytes(signaturePrivateKey), {
27
+ prehash: true
28
+ });
29
+ const signature = {
30
+ hex: recoverySignature.toCompactHex(),
31
+ recovery: recoverySignature.recovery
32
+ };
33
+ return {
34
+ infoContent,
35
+ accountAddress,
36
+ signature
37
+ };
38
+ };
39
+ //# sourceMappingURL=encrypt-and-sign-space-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encrypt-and-sign-space-info.js","names":["secp256k1","utf8ToBytes","Schema","encryptMessage","canonicalize","hexToBytes","stringToUint8Array","SpaceInfoContent","encodeSpaceInfoContent","encodeSync","encryptAndSignSpaceInfo","accountAddress","name","secretKey","signaturePrivateKey","spaceId","infoContent","message","JSON","stringify","messageToSign","recoverySignature","sign","prehash","signature","hex","toCompactHex","recovery"],"sources":["../../src/space-info/encrypt-and-sign-space-info.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAS,QAAQ,yBAAyB;AACnD,SAASC,WAAW,QAAQ,qBAAqB;AACjD,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,YAAY,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,mBAAmB;AAChF,SAASC,gBAAgB,QAAQ,YAAY;AAU7C,MAAMC,sBAAsB,gBAAGN,MAAM,CAACO,UAAU,CAACF,gBAAgB,CAAC;AAElE,OAAO,MAAMG,uBAAuB,GAAGA,CAAC;EACtCC,cAAc;EACdC,IAAI;EACJC,SAAS;EACTC,mBAAmB;EACnBC;AAAO,CACkB,KAAI;EAC7B,MAAMC,WAAW,GAAGb,cAAc,CAAC;IACjCc,OAAO,EAAEhB,WAAW,CAACiB,IAAI,CAACC,SAAS,CAACX,sBAAsB,CAAC;MAAEI,IAAI,EAAEA;IAAI,CAAE,CAAC,CAAC,CAAC;IAC5EC,SAAS,EAAER,UAAU,CAACQ,SAAS;GAChC,CAAC;EAEF,MAAMO,aAAa,GAAGd,kBAAkB,CACtCF,YAAY,CAAC;IACXO,cAAc;IACdK,WAAW;IACXD;GACD,CAAC,CACH;EAED,MAAMM,iBAAiB,GAAGrB,SAAS,CAACsB,IAAI,CAACF,aAAa,EAAEf,UAAU,CAACS,mBAAmB,CAAC,EAAE;IAAES,OAAO,EAAE;EAAI,CAAE,CAAC;EAE3G,MAAMC,SAAS,GAAG;IAChBC,GAAG,EAAEJ,iBAAiB,CAACK,YAAY,EAAE;IACrCC,QAAQ,EAAEN,iBAAiB,CAACM;GAC7B;EAED,OAAO;IACLX,WAAW;IACXL,cAAc;IACda;GACD;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export * from './decrypt-space-info.js';
2
+ export * from './encrypt-and-sign-space-info.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from './decrypt-space-info.js';
2
+ export * from './encrypt-and-sign-space-info.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/space-info/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,yBAAyB;AACvC,cAAc,kCAAkC;AAChD,cAAc,YAAY","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export declare const SpaceInfoContent: Schema.Struct<{
3
+ name: typeof Schema.String;
4
+ }>;
5
+ export type SpaceInfoContent = Schema.Schema.Type<typeof SpaceInfoContent>;
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/space-info/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,gBAAgB;;EAE3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export const SpaceInfoContent = /*#__PURE__*/Schema.Struct({
3
+ name: Schema.String
4
+ });
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":["Schema","SpaceInfoContent","Struct","name","String"],"sources":["../../src/space-info/types.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,eAAe;AAEvC,OAAO,MAAMC,gBAAgB,gBAAGD,MAAM,CAACE,MAAM,CAAC;EAC5CC,IAAI,EAAEH,MAAM,CAACI;CACd,CAAC","ignoreList":[]}