@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,62 @@
1
+ import { BASE58_ALLOWED_CHARS } from './internal/base58Utils.js';
2
+ /**
3
+ * Base58 encodes the given string value.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { v4 as uuidv4 } from "uuid";
8
+ *
9
+ * const uuid = uuidv4(); // 92539817-7989-4083-ab80-e9c2b2b66669
10
+ * const dashesRemoved = uuid.replaceAll(/-/g, ""); // 9253981779894083ab80e9c2b2b66669
11
+ * const encoded = encodeBase58(dashesRemoved)
12
+ * console.log(encoded) // K51CbDqxW35osbjPo5ZF77
13
+ * ```
14
+ *
15
+ * @param val string to encode as base58
16
+ * @returns the base58 encoded string
17
+ */
18
+ export function encodeBase58(val) {
19
+ const hex = BigInt(`0x${val}`);
20
+ let remainder = hex;
21
+ const result = []; // Use an array to store encoded characters
22
+ while (remainder > 0n) {
23
+ const mod = remainder % 58n;
24
+ const base58CharAtMod = BASE58_ALLOWED_CHARS[Number(mod)];
25
+ if (base58CharAtMod) {
26
+ result.push(base58CharAtMod);
27
+ }
28
+ remainder = remainder / 58n;
29
+ }
30
+ // Reverse and join the array to get the final Base58 encoded string
31
+ return result.reverse().join('');
32
+ }
33
+ /**
34
+ * Expand the base58 encoded UUID back to its original UUID format
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const uuid = 92539817-7989-4083-ab80-e9c2b2b66669;
39
+ * const encoded = encodeBase58(dashesRemoved); // K51CbDqxW35osbjPo5ZF77
40
+ * const decoded = decodeBase58ToUUID(encoded); // 92539817-7989-4083-ab80-e9c2b2b66669
41
+ *
42
+ * expect(decoded).toEqual(uuid);
43
+ * ```
44
+ *
45
+ * @param encoded base58 encoded UUID
46
+ * @returns the expanded UUID from the base58 encoded value
47
+ */
48
+ export function decodeBase58ToUUID(encoded) {
49
+ let decoded = 0n;
50
+ for (const char of encoded) {
51
+ const index = BASE58_ALLOWED_CHARS.indexOf(char);
52
+ if (index === -1) {
53
+ throw new Error('Invalid Base58 character');
54
+ }
55
+ decoded = decoded * 58n + BigInt(index);
56
+ }
57
+ // Convert the bigint to a hex string, padded to 32 characters
58
+ let hexStr = decoded.toString(16);
59
+ hexStr = hexStr.padStart(32, '0'); // Ensure it is 32 characters
60
+ return [hexStr.slice(0, 8), hexStr.slice(8, 12), hexStr.slice(12, 16), hexStr.slice(16, 20), hexStr.slice(20)].join('-');
61
+ }
62
+ //# sourceMappingURL=base58.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base58.js","names":["BASE58_ALLOWED_CHARS","encodeBase58","val","hex","BigInt","remainder","result","mod","base58CharAtMod","Number","push","reverse","join","decodeBase58ToUUID","encoded","decoded","char","index","indexOf","Error","hexStr","toString","padStart","slice"],"sources":["../../src/utils/base58.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,2BAA2B;AAIhE;;;;;;;;;;;;;;;;AAgBA,OAAM,SAAUC,YAAYA,CAACC,GAAW;EACtC,MAAMC,GAAG,GAAGC,MAAM,CAAC,KAAKF,GAAG,EAAE,CAAC;EAC9B,IAAIG,SAAS,GAAGF,GAAG;EACnB,MAAMG,MAAM,GAAa,EAAE,CAAC,CAAC;EAE7B,OAAOD,SAAS,GAAG,EAAE,EAAE;IACrB,MAAME,GAAG,GAAGF,SAAS,GAAG,GAAG;IAC3B,MAAMG,eAAe,GAAGR,oBAAoB,CAACS,MAAM,CAACF,GAAG,CAAC,CAAC;IACzD,IAAIC,eAAe,EAAE;MACnBF,MAAM,CAACI,IAAI,CAACF,eAAe,CAAC;IAC9B;IACAH,SAAS,GAAGA,SAAS,GAAG,GAAG;EAC7B;EAEA;EACA,OAAOC,MAAM,CAACK,OAAO,EAAE,CAACC,IAAI,CAAC,EAAE,CAAC;AAClC;AAIA;;;;;;;;;;;;;;;AAeA,OAAM,SAAUC,kBAAkBA,CAACC,OAAe;EAChD,IAAIC,OAAO,GAAG,EAAE;EAEhB,KAAK,MAAMC,IAAI,IAAIF,OAAO,EAAE;IAC1B,MAAMG,KAAK,GAAGjB,oBAAoB,CAACkB,OAAO,CAACF,IAAI,CAAC;IAChD,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;MAChB,MAAM,IAAIE,KAAK,CAAC,0BAA0B,CAAC;IAC7C;IACAJ,OAAO,GAAGA,OAAO,GAAG,GAAG,GAAGX,MAAM,CAACa,KAAK,CAAC;EACzC;EAEA;EACA,IAAIG,MAAM,GAAGL,OAAO,CAACM,QAAQ,CAAC,EAAE,CAAC;EACjCD,MAAM,GAAGA,MAAM,CAACE,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;EAEnC,OAAO,CAACF,MAAM,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAEH,MAAM,CAACG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAEH,MAAM,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAEH,MAAM,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAEH,MAAM,CAACG,KAAK,CAAC,EAAE,CAAC,CAAC,CAACX,IAAI,CACjH,GAAG,CACJ;AACH","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const bytesToHex: (bytes: Uint8Array) => string;
2
+ export declare const hexToBytes: (hex: string) => Uint8Array;
3
+ export declare const publicKeyToAddress: (publicKey: string) => string;
4
+ //# sourceMappingURL=hexBytesAddressUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexBytesAddressUtils.d.ts","sourceRoot":"","sources":["../../src/utils/hexBytesAddressUtils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,GAAI,OAAO,UAAU,KAAG,MAE9C,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,UAExC,CAAC;AAUF,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,KAAG,MAGtD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { bytesToHex as nobleBytesToHex, hexToBytes as nobleHexToBytes } from '@noble/ciphers/utils';
2
+ import { ProjectivePoint } from '@noble/secp256k1';
3
+ import { publicKeyToAddress as viemPublicKeyToAddress } from 'viem/accounts';
4
+ export const bytesToHex = bytes => {
5
+ return `0x${nobleBytesToHex(bytes)}`;
6
+ };
7
+ export const hexToBytes = hex => {
8
+ return nobleHexToBytes(hex.slice(2));
9
+ };
10
+ function decompressPublicKey(compressedKey) {
11
+ // Decompress the public key
12
+ const point = ProjectivePoint.fromHex(compressedKey.slice(2));
13
+ // Get the uncompressed public key
14
+ const uncompressedKey = point.toRawBytes(false); // `false` = uncompressed format
15
+ return bytesToHex(uncompressedKey);
16
+ }
17
+ export const publicKeyToAddress = publicKey => {
18
+ const uncompressedKey = decompressPublicKey(publicKey);
19
+ return viemPublicKeyToAddress(uncompressedKey);
20
+ };
21
+ //# sourceMappingURL=hexBytesAddressUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexBytesAddressUtils.js","names":["bytesToHex","nobleBytesToHex","hexToBytes","nobleHexToBytes","ProjectivePoint","publicKeyToAddress","viemPublicKeyToAddress","bytes","hex","slice","decompressPublicKey","compressedKey","point","fromHex","uncompressedKey","toRawBytes","publicKey"],"sources":["../../src/utils/hexBytesAddressUtils.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAU,IAAIC,eAAe,EAAEC,UAAU,IAAIC,eAAe,QAAQ,sBAAsB;AACnG,SAASC,eAAe,QAAQ,kBAAkB;AAElD,SAASC,kBAAkB,IAAIC,sBAAsB,QAAQ,eAAe;AAE5E,OAAO,MAAMN,UAAU,GAAIO,KAAiB,IAAY;EACtD,OAAO,KAAKN,eAAe,CAACM,KAAK,CAAC,EAAE;AACtC,CAAC;AAED,OAAO,MAAML,UAAU,GAAIM,GAAW,IAAgB;EACpD,OAAOL,eAAe,CAACK,GAAG,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAASC,mBAAmBA,CAACC,aAAqB;EAChD;EACA,MAAMC,KAAK,GAAGR,eAAe,CAACS,OAAO,CAACF,aAAa,CAACF,KAAK,CAAC,CAAC,CAAC,CAAC;EAE7D;EACA,MAAMK,eAAe,GAAGF,KAAK,CAACG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;EACjD,OAAOf,UAAU,CAACc,eAAe,CAAC;AACpC;AACA,OAAO,MAAMT,kBAAkB,GAAIW,SAAiB,IAAY;EAC9D,MAAMF,eAAe,GAAGJ,mBAAmB,CAACM,SAAS,CAAC;EACtD,OAAOV,sBAAsB,CAACQ,eAAsB,CAAC;AACvD,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ export * from './assertExhaustive.js';
2
+ export * from './automergeId.js';
3
+ export * from './base58.js';
4
+ export * from './generateId.js';
5
+ export * from './hexBytesAddressUtils.js';
6
+ export * from './isRelationField.js';
7
+ export * from './jsc.js';
8
+ export * from './stringToUint8Array.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,9 @@
1
+ export * from './assertExhaustive.js';
2
+ export * from './automergeId.js';
3
+ export * from './base58.js';
4
+ export * from './generateId.js';
5
+ export * from './hexBytesAddressUtils.js';
6
+ export * from './isRelationField.js';
7
+ export * from './jsc.js';
8
+ export * from './stringToUint8Array.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,kBAAkB;AAChC,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,2BAA2B;AACzC,cAAc,sBAAsB;AACpC,cAAc,UAAU;AACxB,cAAc,yBAAyB","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const BASE58_ALLOWED_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2
+ export declare function decodeBase58(str: string): Uint8Array<ArrayBuffer>;
3
+ export declare function encodeBase58(data: Uint8Array): string;
4
+ //# sourceMappingURL=base58Utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base58Utils.d.ts","sourceRoot":"","sources":["../../../src/utils/internal/base58Utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,+DAA+D,CAAC;AAEjG,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,2BAuBvC;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,UAmB5C"}
@@ -0,0 +1,40 @@
1
+ export const BASE58_ALLOWED_CHARS = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
2
+ export function decodeBase58(str) {
3
+ let x = BigInt(0);
4
+ for (let i = 0; i < str.length; i++) {
5
+ const charIndex = BASE58_ALLOWED_CHARS.indexOf(str[i]);
6
+ if (charIndex < 0) {
7
+ throw new Error('Invalid Base58 character');
8
+ }
9
+ x = x * 58n + BigInt(charIndex);
10
+ }
11
+ const bytes = [];
12
+ while (x > 0) {
13
+ bytes.push(Number(x % 256n));
14
+ x = x >> 8n;
15
+ }
16
+ bytes.reverse();
17
+ // Pad to 16 bytes for a UUID
18
+ while (bytes.length < 16) {
19
+ bytes.unshift(0);
20
+ }
21
+ return new Uint8Array(bytes);
22
+ }
23
+ export function encodeBase58(data) {
24
+ let x = BigInt(0);
25
+ for (const byte of data) {
26
+ x = (x << 8n) + BigInt(byte);
27
+ }
28
+ let encoded = '';
29
+ while (x > 0) {
30
+ const remainder = x % 58n;
31
+ x = x / 58n;
32
+ encoded = BASE58_ALLOWED_CHARS[Number(remainder)] + encoded;
33
+ }
34
+ // deal with leading zeros (0x00 bytes)
35
+ for (let i = 0; i < data.length && data[i] === 0; i++) {
36
+ encoded = `1${encoded}`;
37
+ }
38
+ return encoded;
39
+ }
40
+ //# sourceMappingURL=base58Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base58Utils.js","names":["BASE58_ALLOWED_CHARS","decodeBase58","str","x","BigInt","i","length","charIndex","indexOf","Error","bytes","push","Number","reverse","unshift","Uint8Array","encodeBase58","data","byte","encoded","remainder"],"sources":["../../../src/utils/internal/base58Utils.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,4DAA4D;AAEhG,OAAM,SAAUC,YAAYA,CAACC,GAAW;EACtC,IAAIC,CAAC,GAAGC,MAAM,CAAC,CAAC,CAAC;EACjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,GAAG,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAME,SAAS,GAAGP,oBAAoB,CAACQ,OAAO,CAACN,GAAG,CAACG,CAAC,CAAC,CAAC;IACtD,IAAIE,SAAS,GAAG,CAAC,EAAE;MACjB,MAAM,IAAIE,KAAK,CAAC,0BAA0B,CAAC;IAC7C;IACAN,CAAC,GAAGA,CAAC,GAAG,GAAG,GAAGC,MAAM,CAACG,SAAS,CAAC;EACjC;EAEA,MAAMG,KAAK,GAAa,EAAE;EAC1B,OAAOP,CAAC,GAAG,CAAC,EAAE;IACZO,KAAK,CAACC,IAAI,CAACC,MAAM,CAACT,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5BA,CAAC,GAAGA,CAAC,IAAI,EAAE;EACb;EAEAO,KAAK,CAACG,OAAO,EAAE;EACf;EACA,OAAOH,KAAK,CAACJ,MAAM,GAAG,EAAE,EAAE;IACxBI,KAAK,CAACI,OAAO,CAAC,CAAC,CAAC;EAClB;EAEA,OAAO,IAAIC,UAAU,CAACL,KAAK,CAAC;AAC9B;AAEA,OAAM,SAAUM,YAAYA,CAACC,IAAgB;EAC3C,IAAId,CAAC,GAAGC,MAAM,CAAC,CAAC,CAAC;EACjB,KAAK,MAAMc,IAAI,IAAID,IAAI,EAAE;IACvBd,CAAC,GAAG,CAACA,CAAC,IAAI,EAAE,IAAIC,MAAM,CAACc,IAAI,CAAC;EAC9B;EAEA,IAAIC,OAAO,GAAG,EAAE;EAChB,OAAOhB,CAAC,GAAG,CAAC,EAAE;IACZ,MAAMiB,SAAS,GAAGjB,CAAC,GAAG,GAAG;IACzBA,CAAC,GAAGA,CAAC,GAAG,GAAG;IACXgB,OAAO,GAAGnB,oBAAoB,CAACY,MAAM,CAACQ,SAAS,CAAC,CAAC,GAAGD,OAAO;EAC7D;EAEA;EACA,KAAK,IAAId,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGY,IAAI,CAACX,MAAM,IAAIW,IAAI,CAACZ,CAAC,CAAC,KAAK,CAAC,EAAEA,CAAC,EAAE,EAAE;IACrDc,OAAO,GAAG,IAAIA,OAAO,EAAE;EACzB;EAEA,OAAOA,OAAO;AAChB","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Deeply merges two plain‐object types T and U,
3
+ * returning a new object that has properties of both.
4
+ * Arrays or other non‐object values in `source` simply overwrite.
5
+ */
6
+ export declare const deepMerge: <T extends Record<string, unknown>, U extends Record<string, unknown>>(target: T, source: U) => T & U;
7
+ //# sourceMappingURL=deep-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-merge.d.ts","sourceRoot":"","sources":["../../../src/utils/internal/deep-merge.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5F,QAAQ,CAAC,EACT,QAAQ,CAAC,KACR,CAAC,GAAG,CAyBN,CAAC"}
@@ -0,0 +1,33 @@
1
+ // A “plain object” is any non-null object that isn’t an array
2
+ const isPlainObject = obj => typeof obj === 'object' && obj !== null && !Array.isArray(obj);
3
+ /**
4
+ * Deeply merges two plain‐object types T and U,
5
+ * returning a new object that has properties of both.
6
+ * Arrays or other non‐object values in `source` simply overwrite.
7
+ */
8
+ export const deepMerge = (target, source) => {
9
+ // Start with a shallow clone of target
10
+ const result = {
11
+ ...target
12
+ };
13
+ for (const key of Object.keys(source)) {
14
+ const srcVal = source[key];
15
+ // biome-ignore lint/suspicious/noExplicitAny: good enough
16
+ const tgtVal = target[key];
17
+ if (isPlainObject(srcVal) && isPlainObject(tgtVal)) {
18
+ // Both sides are plain objects → recurse
19
+ // biome-ignore lint/suspicious/noExplicitAny: good enough
20
+ result[key] = deepMerge(tgtVal, srcVal);
21
+ } else if (isPlainObject(srcVal)) {
22
+ // Source is object but target missing or not object → clone source
23
+ // biome-ignore lint/suspicious/noExplicitAny: good enough
24
+ result[key] = deepMerge({}, srcVal);
25
+ } else {
26
+ // Non‐objects (including arrays) overwrite
27
+ // biome-ignore lint/suspicious/noExplicitAny: good enough
28
+ result[key] = srcVal;
29
+ }
30
+ }
31
+ return result;
32
+ };
33
+ //# sourceMappingURL=deep-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-merge.js","names":["isPlainObject","obj","Array","isArray","deepMerge","target","source","result","key","Object","keys","srcVal","tgtVal"],"sources":["../../../src/utils/internal/deep-merge.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA,MAAMA,aAAa,GAAIC,GAAY,IACjC,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,KAAK,IAAI,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,GAAG,CAAC;AAEhE;;;;;AAKA,OAAO,MAAMG,SAAS,GAAGA,CACvBC,MAAS,EACTC,MAAS,KACA;EACT;EACA,MAAMC,MAAM,GAAG;IAAE,GAAGF;EAAM,CAAW;EAErC,KAAK,MAAMG,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACJ,MAAM,CAAgB,EAAE;IACpD,MAAMK,MAAM,GAAGL,MAAM,CAACE,GAAG,CAAC;IAC1B;IACA,MAAMI,MAAM,GAAIP,MAAc,CAACG,GAAG,CAAC;IAEnC,IAAIR,aAAa,CAACW,MAAM,CAAC,IAAIX,aAAa,CAACY,MAAM,CAAC,EAAE;MAClD;MACA;MACAL,MAAM,CAACC,GAAG,CAAC,GAAGJ,SAAS,CAACQ,MAAiC,EAAED,MAAiC,CAAQ;IACtG,CAAC,MAAM,IAAIX,aAAa,CAACW,MAAM,CAAC,EAAE;MAChC;MACA;MACAJ,MAAM,CAACC,GAAG,CAAC,GAAGJ,SAAS,CAAC,EAA6B,EAAEO,MAAiC,CAAQ;IAClG,CAAC,MAAM;MACL;MACA;MACAJ,MAAM,CAACC,GAAG,CAAC,GAAGG,MAAa;IAC7B;EACF;EAEA,OAAOJ,MAAM;AACf,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type * as Schema from 'effect/Schema';
2
+ export declare const isRelationField: (field: Schema.Schema.All | Schema.PropertySignature.All<PropertyKey>) => boolean;
3
+ //# sourceMappingURL=isRelationField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isRelationField.d.ts","sourceRoot":"","sources":["../../src/utils/isRelationField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,WAAW,CAAC,YAMnG,CAAC"}
@@ -0,0 +1,8 @@
1
+ export const isRelationField = field => {
2
+ // TODO: improve this check
3
+ if (field.ast._tag === 'TupleType') {
4
+ return true;
5
+ }
6
+ return false;
7
+ };
8
+ //# sourceMappingURL=isRelationField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isRelationField.js","names":["isRelationField","field","ast","_tag"],"sources":["../../src/utils/isRelationField.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,MAAMA,eAAe,GAAIC,KAAoE,IAAI;EACtG;EACA,IAAIA,KAAK,CAACC,GAAG,CAACC,IAAI,KAAK,WAAW,EAAE;IAClC,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ export declare class NaNNotAllowedError extends Error {
2
+ constructor();
3
+ }
4
+ export declare class InfinityNotAllowedError extends Error {
5
+ constructor();
6
+ }
7
+ /**
8
+ * JSON canonicalize function.
9
+ * Creates crypto safe predictable canocalization of JSON as defined by RFC8785.
10
+ *
11
+ * @see https://tools.ietf.org/html/rfc8785
12
+ * @see https://www.rfc-editor.org/rfc/rfc8785
13
+ *
14
+ * @example <caption>Primitive values</caption>
15
+ * ```ts
16
+ * import { canonicalize } from '@graph-framework/utils'
17
+ *
18
+ * console.log(canonicalize(null)) // 'null'
19
+ * console.log(canonicalize(1)) // '1'
20
+ * console.log(canonicalize("test")) // "string"
21
+ * console.log(canonicalize(true)) // 'true'
22
+ * ```
23
+ *
24
+ * @example <caption>Objects</caption>
25
+ * ```
26
+ * import { canonicalize } from '@graph-framework/utils'
27
+ *
28
+ * const json = {
29
+ * from_account: '543 232 625-3',
30
+ * to_account: '321 567 636-4',
31
+ * amount: 500,
32
+ * currency: 'USD',
33
+ * };
34
+ * console.log(canonicalize(json)) // '{"amount":500,"currency":"USD","from_account":"543 232 625-3","to_account":"321 567 636-4"}'
35
+ * ```
36
+ *
37
+ * @example <caption>Arrays</caption>
38
+ * ```ts
39
+ * import { canonicalize } from '@graph-framework/utils'
40
+ *
41
+ * console.log(canonicalize([1, 'text', null, true, false])) // '[1,"text",null,true,false]'
42
+ * ```
43
+ *
44
+ * @param object object to JSC canonicalize
45
+ * @throws NaNNotAllowedError if given object is of type number, but is not a valid number
46
+ * @throws InfinityNotAllowedError if given object is of type number, but is the infinite number
47
+ */
48
+ export declare function canonicalize<T = unknown>(object: T): string;
49
+ //# sourceMappingURL=jsc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsc.d.ts","sourceRoot":"","sources":["../../src/utils/jsc.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;;CAI5C;AACD,qBAAa,uBAAwB,SAAQ,KAAK;;CAIjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAyC3D"}
@@ -0,0 +1,88 @@
1
+ export class NaNNotAllowedError extends Error {
2
+ constructor() {
3
+ super('NaN is not allowed');
4
+ }
5
+ }
6
+ export class InfinityNotAllowedError extends Error {
7
+ constructor() {
8
+ super('Infinity is not allowed');
9
+ }
10
+ }
11
+ /**
12
+ * JSON canonicalize function.
13
+ * Creates crypto safe predictable canocalization of JSON as defined by RFC8785.
14
+ *
15
+ * @see https://tools.ietf.org/html/rfc8785
16
+ * @see https://www.rfc-editor.org/rfc/rfc8785
17
+ *
18
+ * @example <caption>Primitive values</caption>
19
+ * ```ts
20
+ * import { canonicalize } from '@graph-framework/utils'
21
+ *
22
+ * console.log(canonicalize(null)) // 'null'
23
+ * console.log(canonicalize(1)) // '1'
24
+ * console.log(canonicalize("test")) // "string"
25
+ * console.log(canonicalize(true)) // 'true'
26
+ * ```
27
+ *
28
+ * @example <caption>Objects</caption>
29
+ * ```
30
+ * import { canonicalize } from '@graph-framework/utils'
31
+ *
32
+ * const json = {
33
+ * from_account: '543 232 625-3',
34
+ * to_account: '321 567 636-4',
35
+ * amount: 500,
36
+ * currency: 'USD',
37
+ * };
38
+ * console.log(canonicalize(json)) // '{"amount":500,"currency":"USD","from_account":"543 232 625-3","to_account":"321 567 636-4"}'
39
+ * ```
40
+ *
41
+ * @example <caption>Arrays</caption>
42
+ * ```ts
43
+ * import { canonicalize } from '@graph-framework/utils'
44
+ *
45
+ * console.log(canonicalize([1, 'text', null, true, false])) // '[1,"text",null,true,false]'
46
+ * ```
47
+ *
48
+ * @param object object to JSC canonicalize
49
+ * @throws NaNNotAllowedError if given object is of type number, but is not a valid number
50
+ * @throws InfinityNotAllowedError if given object is of type number, but is the infinite number
51
+ */
52
+ export function canonicalize(object) {
53
+ if (typeof object === 'number' && Number.isNaN(object)) {
54
+ throw new NaNNotAllowedError();
55
+ }
56
+ if (typeof object === 'number' && !Number.isFinite(object)) {
57
+ throw new InfinityNotAllowedError();
58
+ }
59
+ if (object === null || typeof object !== 'object') {
60
+ return JSON.stringify(object);
61
+ }
62
+ // biome-ignore lint/suspicious/noExplicitAny: typeof T is unknown, cast to any to check
63
+ if (object.toJSON instanceof Function) {
64
+ // biome-ignore lint/suspicious/noExplicitAny: typeof T is unknown, cast to any to check
65
+ return canonicalize(object.toJSON());
66
+ }
67
+ if (Array.isArray(object)) {
68
+ const values = object.reduce((t, cv) => {
69
+ if (cv === undefined || typeof cv === 'symbol') {
70
+ return t; // Skip undefined and symbol values entirely
71
+ }
72
+ const comma = t.length === 0 ? '' : ',';
73
+ return `${t}${comma}${canonicalize(cv)}`;
74
+ }, '');
75
+ return `[${values}]`;
76
+ }
77
+ const values = Object.keys(object).sort().reduce((t, cv) => {
78
+ // biome-ignore lint/suspicious/noExplicitAny: typeof T is unknown, cast to any to check
79
+ if (object[cv] === undefined || typeof object[cv] === 'symbol') {
80
+ return t;
81
+ }
82
+ const comma = t.length === 0 ? '' : ',';
83
+ // biome-ignore lint/suspicious/noExplicitAny: typeof T is unknown, cast to any to check
84
+ return `${t}${comma}${canonicalize(cv)}:${canonicalize(object[cv])}`;
85
+ }, '');
86
+ return `{${values}}`;
87
+ }
88
+ //# sourceMappingURL=jsc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsc.js","names":["NaNNotAllowedError","Error","constructor","InfinityNotAllowedError","canonicalize","object","Number","isNaN","isFinite","JSON","stringify","toJSON","Function","Array","isArray","values","reduce","t","cv","undefined","comma","length","Object","keys","sort"],"sources":["../../src/utils/jsc.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAM,MAAOA,kBAAmB,SAAQC,KAAK;EAC3CC,YAAA;IACE,KAAK,CAAC,oBAAoB,CAAC;EAC7B;;AAEF,OAAM,MAAOC,uBAAwB,SAAQF,KAAK;EAChDC,YAAA;IACE,KAAK,CAAC,yBAAyB,CAAC;EAClC;;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,OAAM,SAAUE,YAAYA,CAAcC,MAAS;EACjD,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIC,MAAM,CAACC,KAAK,CAACF,MAAM,CAAC,EAAE;IACtD,MAAM,IAAIL,kBAAkB,EAAE;EAChC;EACA,IAAI,OAAOK,MAAM,KAAK,QAAQ,IAAI,CAACC,MAAM,CAACE,QAAQ,CAACH,MAAM,CAAC,EAAE;IAC1D,MAAM,IAAIF,uBAAuB,EAAE;EACrC;EAEA,IAAIE,MAAM,KAAK,IAAI,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IACjD,OAAOI,IAAI,CAACC,SAAS,CAACL,MAAM,CAAC;EAC/B;EAEA;EACA,IAAKA,MAAc,CAACM,MAAM,YAAYC,QAAQ,EAAE;IAC9C;IACA,OAAOR,YAAY,CAAEC,MAAc,CAACM,MAAM,EAAE,CAAC;EAC/C;EAEA,IAAIE,KAAK,CAACC,OAAO,CAACT,MAAM,CAAC,EAAE;IACzB,MAAMU,MAAM,GAAGV,MAAM,CAACW,MAAM,CAAC,CAACC,CAAC,EAAEC,EAAE,KAAI;MACrC,IAAIA,EAAE,KAAKC,SAAS,IAAI,OAAOD,EAAE,KAAK,QAAQ,EAAE;QAC9C,OAAOD,CAAC,CAAC,CAAC;MACZ;MACA,MAAMG,KAAK,GAAGH,CAAC,CAACI,MAAM,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG;MACvC,OAAO,GAAGJ,CAAC,GAAGG,KAAK,GAAGhB,YAAY,CAACc,EAAE,CAAC,EAAE;IAC1C,CAAC,EAAE,EAAE,CAAC;IACN,OAAO,IAAIH,MAAM,GAAG;EACtB;EAEA,MAAMA,MAAM,GAAGO,MAAM,CAACC,IAAI,CAAClB,MAAM,CAAC,CAC/BmB,IAAI,EAAE,CACNR,MAAM,CAAC,CAACC,CAAC,EAAEC,EAAE,KAAI;IAChB;IACA,IAAKb,MAAc,CAACa,EAAE,CAAC,KAAKC,SAAS,IAAI,OAAQd,MAAc,CAACa,EAAE,CAAC,KAAK,QAAQ,EAAE;MAChF,OAAOD,CAAC;IACV;IACA,MAAMG,KAAK,GAAGH,CAAC,CAACI,MAAM,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG;IACvC;IACA,OAAO,GAAGJ,CAAC,GAAGG,KAAK,GAAGhB,YAAY,CAACc,EAAE,CAAC,IAAId,YAAY,CAAEC,MAAc,CAACa,EAAE,CAAC,CAAC,EAAE;EAC/E,CAAC,EAAE,EAAE,CAAC;EACR,OAAO,IAAIH,MAAM,GAAG;AACtB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export declare const stringToUint8Array: (str: string) => Uint8Array;
2
+ export declare const uint8ArrayToString: (uint8Array: Uint8Array) => string;
3
+ //# sourceMappingURL=stringToUint8Array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringToUint8Array.d.ts","sourceRoot":"","sources":["../../src/utils/stringToUint8Array.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,UAEhD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,YAAY,UAAU,KAAG,MAE3D,CAAC"}
@@ -0,0 +1,9 @@
1
+ const encoder = /*#__PURE__*/new TextEncoder();
2
+ const decoder = /*#__PURE__*/new TextDecoder();
3
+ export const stringToUint8Array = str => {
4
+ return encoder.encode(str);
5
+ };
6
+ export const uint8ArrayToString = uint8Array => {
7
+ return decoder.decode(uint8Array);
8
+ };
9
+ //# sourceMappingURL=stringToUint8Array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringToUint8Array.js","names":["encoder","TextEncoder","decoder","TextDecoder","stringToUint8Array","str","encode","uint8ArrayToString","uint8Array","decode"],"sources":["../../src/utils/stringToUint8Array.ts"],"sourcesContent":[null],"mappings":"AAAA,MAAMA,OAAO,gBAAG,IAAIC,WAAW,EAAE;AACjC,MAAMC,OAAO,gBAAG,IAAIC,WAAW,EAAE;AACjC,OAAO,MAAMC,kBAAkB,GAAIC,GAAW,IAAgB;EAC5D,OAAOL,OAAO,CAACM,MAAM,CAACD,GAAG,CAAC;AAC5B,CAAC;AAED,OAAO,MAAME,kBAAkB,GAAIC,UAAsB,IAAY;EACnE,OAAON,OAAO,CAACO,MAAM,CAACD,UAAU,CAAC;AACnC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/hypergraph",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "SDK for building performant, type-safe, local-first dapps on top of The Graph ecosystem knowledge graphs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,16 +15,19 @@
15
15
  "sideEffects": [],
16
16
  "dependencies": {
17
17
  "@automerge/automerge": "^2.2.9",
18
- "@automerge/automerge-repo": "=2.0.0-beta.5",
18
+ "@automerge/automerge-repo": "^2.0.6",
19
19
  "@effect/experimental": "^0.44.20",
20
+ "@graphprotocol/grc-20": "^0.21.2",
20
21
  "@noble/ciphers": "^1.3.0",
21
22
  "@noble/curves": "^1.9.0",
22
23
  "@noble/hashes": "^1.8.0",
23
24
  "@noble/secp256k1": "^2.2.3",
25
+ "@rhinestone/module-sdk": "^0.2.8",
24
26
  "@serenity-kit/noble-sodium": "^0.2.1",
25
27
  "@xstate/store": "^3.5.1",
26
28
  "bs58check": "^4.0.0",
27
29
  "effect": "^3.16.3",
30
+ "permissionless": "^0.2.47",
28
31
  "siwe": "^3.0.0",
29
32
  "uuid": "^11.1.0",
30
33
  "viem": "^2.30.6"