@xyo-network/os-runtime 7.3.0 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (551) hide show
  1. package/package.json +106 -144
  2. package/dist/neutral/Caller.d.ts +0 -68
  3. package/dist/neutral/Caller.d.ts.map +0 -1
  4. package/dist/neutral/DappCallerBase.d.ts +0 -23
  5. package/dist/neutral/DappCallerBase.d.ts.map +0 -1
  6. package/dist/neutral/DefaultsQueries.d.ts +0 -8
  7. package/dist/neutral/DefaultsQueries.d.ts.map +0 -1
  8. package/dist/neutral/OsCallerBase.d.ts +0 -16
  9. package/dist/neutral/OsCallerBase.d.ts.map +0 -1
  10. package/dist/neutral/PubSubBridgeCaller.d.ts +0 -11
  11. package/dist/neutral/PubSubBridgeCaller.d.ts.map +0 -1
  12. package/dist/neutral/RunningDappCache.d.ts +0 -12
  13. package/dist/neutral/RunningDappCache.d.ts.map +0 -1
  14. package/dist/neutral/XyOs.d.ts +0 -48
  15. package/dist/neutral/XyOs.d.ts.map +0 -1
  16. package/dist/neutral/XyOsBase.d.ts +0 -170
  17. package/dist/neutral/XyOsBase.d.ts.map +0 -1
  18. package/dist/neutral/XyOsDapp.d.ts +0 -33
  19. package/dist/neutral/XyOsDapp.d.ts.map +0 -1
  20. package/dist/neutral/access/Caller.d.ts +0 -23
  21. package/dist/neutral/access/Caller.d.ts.map +0 -1
  22. package/dist/neutral/access/Queries.d.ts +0 -8
  23. package/dist/neutral/access/Queries.d.ts.map +0 -1
  24. package/dist/neutral/access/Resource.d.ts +0 -23
  25. package/dist/neutral/access/Resource.d.ts.map +0 -1
  26. package/dist/neutral/access/RunningAccessDappCache.d.ts +0 -12
  27. package/dist/neutral/access/RunningAccessDappCache.d.ts.map +0 -1
  28. package/dist/neutral/access/index.d.ts +0 -5
  29. package/dist/neutral/access/index.d.ts.map +0 -1
  30. package/dist/neutral/access/interfaces/index.d.ts +0 -2
  31. package/dist/neutral/access/interfaces/index.d.ts.map +0 -1
  32. package/dist/neutral/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts +0 -16
  33. package/dist/neutral/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts.map +0 -1
  34. package/dist/neutral/access/interfaces/registered-names/helpers/index.d.ts +0 -3
  35. package/dist/neutral/access/interfaces/registered-names/helpers/index.d.ts.map +0 -1
  36. package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +0 -21
  37. package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts.map +0 -1
  38. package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts +0 -22
  39. package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts.map +0 -1
  40. package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts +0 -9
  41. package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts.map +0 -1
  42. package/dist/neutral/access/interfaces/registered-names/helpers/resource/index.d.ts +0 -4
  43. package/dist/neutral/access/interfaces/registered-names/helpers/resource/index.d.ts.map +0 -1
  44. package/dist/neutral/access/interfaces/registered-names/index.d.ts +0 -2
  45. package/dist/neutral/access/interfaces/registered-names/index.d.ts.map +0 -1
  46. package/dist/neutral/adapter/Base.d.ts +0 -17
  47. package/dist/neutral/adapter/Base.d.ts.map +0 -1
  48. package/dist/neutral/adapter/Network.d.ts +0 -15
  49. package/dist/neutral/adapter/Network.d.ts.map +0 -1
  50. package/dist/neutral/adapter/Settings.d.ts +0 -14
  51. package/dist/neutral/adapter/Settings.d.ts.map +0 -1
  52. package/dist/neutral/adapter/index.d.ts +0 -3
  53. package/dist/neutral/adapter/index.d.ts.map +0 -1
  54. package/dist/neutral/adapters/OsPubSubBridgeNetwork.d.ts +0 -3
  55. package/dist/neutral/adapters/OsPubSubBridgeNetwork.d.ts.map +0 -1
  56. package/dist/neutral/adapters/OsSettings.d.ts +0 -3
  57. package/dist/neutral/adapters/OsSettings.d.ts.map +0 -1
  58. package/dist/neutral/adapters/OsXyoPublicNetwork.d.ts +0 -3
  59. package/dist/neutral/adapters/OsXyoPublicNetwork.d.ts.map +0 -1
  60. package/dist/neutral/adapters/index.d.ts +0 -4
  61. package/dist/neutral/adapters/index.d.ts.map +0 -1
  62. package/dist/neutral/classes/dapp/DefaultsResource.d.ts +0 -26
  63. package/dist/neutral/classes/dapp/DefaultsResource.d.ts.map +0 -1
  64. package/dist/neutral/classes/dapp/index.d.ts +0 -2
  65. package/dist/neutral/classes/dapp/index.d.ts.map +0 -1
  66. package/dist/neutral/classes/index.d.ts +0 -5
  67. package/dist/neutral/classes/index.d.ts.map +0 -1
  68. package/dist/neutral/classes/lib/DappCreatorParams.d.ts +0 -16
  69. package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +0 -1
  70. package/dist/neutral/classes/lib/Insertable.d.ts +0 -10
  71. package/dist/neutral/classes/lib/Insertable.d.ts.map +0 -1
  72. package/dist/neutral/classes/lib/index.d.ts +0 -3
  73. package/dist/neutral/classes/lib/index.d.ts.map +0 -1
  74. package/dist/neutral/classes/menu/Caller.d.ts +0 -14
  75. package/dist/neutral/classes/menu/Caller.d.ts.map +0 -1
  76. package/dist/neutral/classes/menu/Queries.d.ts +0 -10
  77. package/dist/neutral/classes/menu/Queries.d.ts.map +0 -1
  78. package/dist/neutral/classes/menu/Resource.d.ts +0 -46
  79. package/dist/neutral/classes/menu/Resource.d.ts.map +0 -1
  80. package/dist/neutral/classes/menu/index.d.ts +0 -3
  81. package/dist/neutral/classes/menu/index.d.ts.map +0 -1
  82. package/dist/neutral/classes/settings/Caller.d.ts +0 -21
  83. package/dist/neutral/classes/settings/Caller.d.ts.map +0 -1
  84. package/dist/neutral/classes/settings/CallerBase.d.ts +0 -8
  85. package/dist/neutral/classes/settings/CallerBase.d.ts.map +0 -1
  86. package/dist/neutral/classes/settings/Resource.d.ts +0 -30
  87. package/dist/neutral/classes/settings/Resource.d.ts.map +0 -1
  88. package/dist/neutral/classes/settings/SettingsQueries.d.ts +0 -10
  89. package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +0 -1
  90. package/dist/neutral/classes/settings/badge/Caller.d.ts +0 -13
  91. package/dist/neutral/classes/settings/badge/Caller.d.ts.map +0 -1
  92. package/dist/neutral/classes/settings/badge/Queries.d.ts +0 -7
  93. package/dist/neutral/classes/settings/badge/Queries.d.ts.map +0 -1
  94. package/dist/neutral/classes/settings/badge/Resource.d.ts +0 -23
  95. package/dist/neutral/classes/settings/badge/Resource.d.ts.map +0 -1
  96. package/dist/neutral/classes/settings/badge/index.d.ts +0 -3
  97. package/dist/neutral/classes/settings/badge/index.d.ts.map +0 -1
  98. package/dist/neutral/classes/settings/index.d.ts +0 -6
  99. package/dist/neutral/classes/settings/index.d.ts.map +0 -1
  100. package/dist/neutral/dapp/context/creator/Creator.d.ts +0 -23
  101. package/dist/neutral/dapp/context/creator/Creator.d.ts.map +0 -1
  102. package/dist/neutral/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts +0 -8
  103. package/dist/neutral/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts.map +0 -1
  104. package/dist/neutral/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts +0 -10
  105. package/dist/neutral/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts.map +0 -1
  106. package/dist/neutral/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts +0 -8
  107. package/dist/neutral/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts.map +0 -1
  108. package/dist/neutral/dapp/context/creator/DefaultPayloads/index.d.ts +0 -2
  109. package/dist/neutral/dapp/context/creator/DefaultPayloads/index.d.ts.map +0 -1
  110. package/dist/neutral/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts +0 -15
  111. package/dist/neutral/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts.map +0 -1
  112. package/dist/neutral/dapp/context/creator/ExternalModulePermissions/index.d.ts +0 -2
  113. package/dist/neutral/dapp/context/creator/ExternalModulePermissions/index.d.ts.map +0 -1
  114. package/dist/neutral/dapp/context/creator/createDappContext.d.ts +0 -3
  115. package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +0 -1
  116. package/dist/neutral/dapp/context/creator/index.d.ts +0 -4
  117. package/dist/neutral/dapp/context/creator/index.d.ts.map +0 -1
  118. package/dist/neutral/dapp/context/index.d.ts +0 -2
  119. package/dist/neutral/dapp/context/index.d.ts.map +0 -1
  120. package/dist/neutral/dapp/index.d.ts +0 -2
  121. package/dist/neutral/dapp/index.d.ts.map +0 -1
  122. package/dist/neutral/event/bus/Connection.d.ts +0 -16
  123. package/dist/neutral/event/bus/Connection.d.ts.map +0 -1
  124. package/dist/neutral/event/bus/EventBus.d.ts +0 -24
  125. package/dist/neutral/event/bus/EventBus.d.ts.map +0 -1
  126. package/dist/neutral/event/bus/PubSubConnection.d.ts +0 -12
  127. package/dist/neutral/event/bus/PubSubConnection.d.ts.map +0 -1
  128. package/dist/neutral/event/bus/index.d.ts +0 -4
  129. package/dist/neutral/event/bus/index.d.ts.map +0 -1
  130. package/dist/neutral/event/connections/DappAccessRequest.d.ts +0 -4
  131. package/dist/neutral/event/connections/DappAccessRequest.d.ts.map +0 -1
  132. package/dist/neutral/event/connections/DappsReady.d.ts +0 -3
  133. package/dist/neutral/event/connections/DappsReady.d.ts.map +0 -1
  134. package/dist/neutral/event/connections/ExposeDappRequest.d.ts +0 -4
  135. package/dist/neutral/event/connections/ExposeDappRequest.d.ts.map +0 -1
  136. package/dist/neutral/event/connections/OsPubSubNetworkReady.d.ts +0 -4
  137. package/dist/neutral/event/connections/OsPubSubNetworkReady.d.ts.map +0 -1
  138. package/dist/neutral/event/connections/OsSettingsReady.d.ts +0 -4
  139. package/dist/neutral/event/connections/OsSettingsReady.d.ts.map +0 -1
  140. package/dist/neutral/event/connections/OsXyoPublicReady.d.ts +0 -4
  141. package/dist/neutral/event/connections/OsXyoPublicReady.d.ts.map +0 -1
  142. package/dist/neutral/event/connections/index.d.ts +0 -7
  143. package/dist/neutral/event/connections/index.d.ts.map +0 -1
  144. package/dist/neutral/event/index.d.ts +0 -3
  145. package/dist/neutral/event/index.d.ts.map +0 -1
  146. package/dist/neutral/helpers/index.d.ts +0 -2
  147. package/dist/neutral/helpers/index.d.ts.map +0 -1
  148. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +0 -14
  149. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +0 -1
  150. package/dist/neutral/helpers/monitor/index.d.ts +0 -3
  151. package/dist/neutral/helpers/monitor/index.d.ts.map +0 -1
  152. package/dist/neutral/helpers/monitor/types.d.ts +0 -7
  153. package/dist/neutral/helpers/monitor/types.d.ts.map +0 -1
  154. package/dist/neutral/index.d.ts +0 -30
  155. package/dist/neutral/index.d.ts.map +0 -1
  156. package/dist/neutral/index.mjs +0 -3994
  157. package/dist/neutral/index.mjs.map +0 -1
  158. package/dist/neutral/initializer/DappInitializer.d.ts +0 -18
  159. package/dist/neutral/initializer/DappInitializer.d.ts.map +0 -1
  160. package/dist/neutral/initializer/index.d.ts +0 -2
  161. package/dist/neutral/initializer/index.d.ts.map +0 -1
  162. package/dist/neutral/intent/Caller.d.ts +0 -23
  163. package/dist/neutral/intent/Caller.d.ts.map +0 -1
  164. package/dist/neutral/intent/Resource.d.ts +0 -23
  165. package/dist/neutral/intent/Resource.d.ts.map +0 -1
  166. package/dist/neutral/intent/index.d.ts +0 -3
  167. package/dist/neutral/intent/index.d.ts.map +0 -1
  168. package/dist/neutral/lib/ExternalStore.d.ts +0 -7
  169. package/dist/neutral/lib/ExternalStore.d.ts.map +0 -1
  170. package/dist/neutral/lib/Listener.d.ts +0 -2
  171. package/dist/neutral/lib/Listener.d.ts.map +0 -1
  172. package/dist/neutral/lib/ModuleAccountPaths.d.ts +0 -3
  173. package/dist/neutral/lib/ModuleAccountPaths.d.ts.map +0 -1
  174. package/dist/neutral/lib/ModuleNames.d.ts +0 -3
  175. package/dist/neutral/lib/ModuleNames.d.ts.map +0 -1
  176. package/dist/neutral/lib/NameTransforms.d.ts +0 -11
  177. package/dist/neutral/lib/NameTransforms.d.ts.map +0 -1
  178. package/dist/neutral/lib/PayloadStore.d.ts +0 -37
  179. package/dist/neutral/lib/PayloadStore.d.ts.map +0 -1
  180. package/dist/neutral/lib/ResourceStores.d.ts +0 -7
  181. package/dist/neutral/lib/ResourceStores.d.ts.map +0 -1
  182. package/dist/neutral/lib/index.d.ts +0 -12
  183. package/dist/neutral/lib/index.d.ts.map +0 -1
  184. package/dist/neutral/lib/initializeXns.d.ts +0 -3
  185. package/dist/neutral/lib/initializeXns.d.ts.map +0 -1
  186. package/dist/neutral/lib/isEqual.d.ts +0 -2
  187. package/dist/neutral/lib/isEqual.d.ts.map +0 -1
  188. package/dist/neutral/lib/isPayload.d.ts +0 -6
  189. package/dist/neutral/lib/isPayload.d.ts.map +0 -1
  190. package/dist/neutral/lib/tokenPlacesSplit.d.ts +0 -3
  191. package/dist/neutral/lib/tokenPlacesSplit.d.ts.map +0 -1
  192. package/dist/neutral/loadOsNode.d.ts +0 -5
  193. package/dist/neutral/loadOsNode.d.ts.map +0 -1
  194. package/dist/neutral/manifest/index.d.ts +0 -3
  195. package/dist/neutral/manifest/index.d.ts.map +0 -1
  196. package/dist/neutral/manifest/manifestReplacementTokens.d.ts +0 -4
  197. package/dist/neutral/manifest/manifestReplacementTokens.d.ts.map +0 -1
  198. package/dist/neutral/manifests/index.d.ts +0 -2
  199. package/dist/neutral/manifests/index.d.ts.map +0 -1
  200. package/dist/neutral/models/access/ValidDappAccessInterfaces.d.ts +0 -5
  201. package/dist/neutral/models/access/ValidDappAccessInterfaces.d.ts.map +0 -1
  202. package/dist/neutral/models/access/index.d.ts +0 -2
  203. package/dist/neutral/models/access/index.d.ts.map +0 -1
  204. package/dist/neutral/models/index.d.ts +0 -2
  205. package/dist/neutral/models/index.d.ts.map +0 -1
  206. package/dist/neutral/profileModuleEvents.d.ts +0 -9
  207. package/dist/neutral/profileModuleEvents.d.ts.map +0 -1
  208. package/dist/neutral/registration/DappRegistrationService.d.ts +0 -37
  209. package/dist/neutral/registration/DappRegistrationService.d.ts.map +0 -1
  210. package/dist/neutral/registration/DappRegistry.d.ts +0 -26
  211. package/dist/neutral/registration/DappRegistry.d.ts.map +0 -1
  212. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +0 -23
  213. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +0 -1
  214. package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts +0 -9
  215. package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +0 -1
  216. package/dist/neutral/registration/ValidateDappAccessDiviner/index.d.ts +0 -3
  217. package/dist/neutral/registration/ValidateDappAccessDiviner/index.d.ts.map +0 -1
  218. package/dist/neutral/registration/index.d.ts +0 -3
  219. package/dist/neutral/registration/index.d.ts.map +0 -1
  220. package/dist/neutral/scripts/xyos/command/config.d.ts +0 -3
  221. package/dist/neutral/scripts/xyos/command/config.d.ts.map +0 -1
  222. package/dist/neutral/scripts/xyos/command/create.d.ts +0 -3
  223. package/dist/neutral/scripts/xyos/command/create.d.ts.map +0 -1
  224. package/dist/neutral/scripts/xyos/command/index.d.ts +0 -6
  225. package/dist/neutral/scripts/xyos/command/index.d.ts.map +0 -1
  226. package/dist/neutral/scripts/xyos/command/manifest.d.ts +0 -3
  227. package/dist/neutral/scripts/xyos/command/manifest.d.ts.map +0 -1
  228. package/dist/neutral/scripts/xyos/command/start.d.ts +0 -3
  229. package/dist/neutral/scripts/xyos/command/start.d.ts.map +0 -1
  230. package/dist/neutral/scripts/xyos/index.d.ts +0 -2
  231. package/dist/neutral/scripts/xyos/index.d.ts.map +0 -1
  232. package/dist/neutral/scripts/xyos/lib/createFromTemplate.d.ts +0 -7
  233. package/dist/neutral/scripts/xyos/lib/createFromTemplate.d.ts.map +0 -1
  234. package/dist/neutral/scripts/xyos/lib/headless.d.ts +0 -8
  235. package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +0 -1
  236. package/dist/neutral/scripts/xyos/lib/index.d.ts +0 -3
  237. package/dist/neutral/scripts/xyos/lib/index.d.ts.map +0 -1
  238. package/dist/neutral/signer/Signers.d.ts +0 -17
  239. package/dist/neutral/signer/Signers.d.ts.map +0 -1
  240. package/dist/neutral/signer/index.d.ts +0 -2
  241. package/dist/neutral/signer/index.d.ts.map +0 -1
  242. package/dist/neutral/stack/Base.d.ts +0 -41
  243. package/dist/neutral/stack/Base.d.ts.map +0 -1
  244. package/dist/neutral/stack/Manager.d.ts +0 -19
  245. package/dist/neutral/stack/Manager.d.ts.map +0 -1
  246. package/dist/neutral/stack/Map.d.ts +0 -3
  247. package/dist/neutral/stack/Map.d.ts.map +0 -1
  248. package/dist/neutral/stack/OsPubSubNetworkStack.d.ts +0 -14
  249. package/dist/neutral/stack/OsPubSubNetworkStack.d.ts.map +0 -1
  250. package/dist/neutral/stack/OsSettingsStack.d.ts +0 -9
  251. package/dist/neutral/stack/OsSettingsStack.d.ts.map +0 -1
  252. package/dist/neutral/stack/XyoPublicNetworkStack.d.ts +0 -9
  253. package/dist/neutral/stack/XyoPublicNetworkStack.d.ts.map +0 -1
  254. package/dist/neutral/stack/index.d.ts +0 -7
  255. package/dist/neutral/stack/index.d.ts.map +0 -1
  256. package/dist/neutral/system/ManageSystemDapps.d.ts +0 -33
  257. package/dist/neutral/system/ManageSystemDapps.d.ts.map +0 -1
  258. package/dist/neutral/system/Queries.d.ts +0 -9
  259. package/dist/neutral/system/Queries.d.ts.map +0 -1
  260. package/dist/neutral/system/index.d.ts +0 -2
  261. package/dist/neutral/system/index.d.ts.map +0 -1
  262. package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts +0 -30
  263. package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts.map +0 -1
  264. package/dist/neutral/utils/getApiDomain.d.ts +0 -3
  265. package/dist/neutral/utils/getApiDomain.d.ts.map +0 -1
  266. package/dist/neutral/utils/index.d.ts +0 -4
  267. package/dist/neutral/utils/index.d.ts.map +0 -1
  268. package/dist/neutral/utils/renameObjKey.d.ts +0 -7
  269. package/dist/neutral/utils/renameObjKey.d.ts.map +0 -1
  270. package/dist/neutral/wallet/DappSeedPhraseRepository.d.ts +0 -16
  271. package/dist/neutral/wallet/DappSeedPhraseRepository.d.ts.map +0 -1
  272. package/dist/neutral/wallet/SeedPhraseRepository.d.ts +0 -28
  273. package/dist/neutral/wallet/SeedPhraseRepository.d.ts.map +0 -1
  274. package/dist/neutral/wallet/index.d.ts +0 -3
  275. package/dist/neutral/wallet/index.d.ts.map +0 -1
  276. package/dist/node/Caller.d.ts +0 -68
  277. package/dist/node/Caller.d.ts.map +0 -1
  278. package/dist/node/DappCallerBase.d.ts +0 -23
  279. package/dist/node/DappCallerBase.d.ts.map +0 -1
  280. package/dist/node/DefaultsQueries.d.ts +0 -8
  281. package/dist/node/DefaultsQueries.d.ts.map +0 -1
  282. package/dist/node/OsCallerBase.d.ts +0 -16
  283. package/dist/node/OsCallerBase.d.ts.map +0 -1
  284. package/dist/node/PubSubBridgeCaller.d.ts +0 -11
  285. package/dist/node/PubSubBridgeCaller.d.ts.map +0 -1
  286. package/dist/node/RunningDappCache.d.ts +0 -12
  287. package/dist/node/RunningDappCache.d.ts.map +0 -1
  288. package/dist/node/XyOs.d.ts +0 -48
  289. package/dist/node/XyOs.d.ts.map +0 -1
  290. package/dist/node/XyOsBase.d.ts +0 -170
  291. package/dist/node/XyOsBase.d.ts.map +0 -1
  292. package/dist/node/XyOsDapp.d.ts +0 -33
  293. package/dist/node/XyOsDapp.d.ts.map +0 -1
  294. package/dist/node/access/Caller.d.ts +0 -23
  295. package/dist/node/access/Caller.d.ts.map +0 -1
  296. package/dist/node/access/Queries.d.ts +0 -8
  297. package/dist/node/access/Queries.d.ts.map +0 -1
  298. package/dist/node/access/Resource.d.ts +0 -23
  299. package/dist/node/access/Resource.d.ts.map +0 -1
  300. package/dist/node/access/RunningAccessDappCache.d.ts +0 -12
  301. package/dist/node/access/RunningAccessDappCache.d.ts.map +0 -1
  302. package/dist/node/access/index.d.ts +0 -5
  303. package/dist/node/access/index.d.ts.map +0 -1
  304. package/dist/node/access/interfaces/index.d.ts +0 -2
  305. package/dist/node/access/interfaces/index.d.ts.map +0 -1
  306. package/dist/node/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts +0 -16
  307. package/dist/node/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts.map +0 -1
  308. package/dist/node/access/interfaces/registered-names/helpers/index.d.ts +0 -3
  309. package/dist/node/access/interfaces/registered-names/helpers/index.d.ts.map +0 -1
  310. package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +0 -21
  311. package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts.map +0 -1
  312. package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts +0 -22
  313. package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts.map +0 -1
  314. package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts +0 -9
  315. package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts.map +0 -1
  316. package/dist/node/access/interfaces/registered-names/helpers/resource/index.d.ts +0 -4
  317. package/dist/node/access/interfaces/registered-names/helpers/resource/index.d.ts.map +0 -1
  318. package/dist/node/access/interfaces/registered-names/index.d.ts +0 -2
  319. package/dist/node/access/interfaces/registered-names/index.d.ts.map +0 -1
  320. package/dist/node/adapter/Base.d.ts +0 -17
  321. package/dist/node/adapter/Base.d.ts.map +0 -1
  322. package/dist/node/adapter/Network.d.ts +0 -15
  323. package/dist/node/adapter/Network.d.ts.map +0 -1
  324. package/dist/node/adapter/Settings.d.ts +0 -14
  325. package/dist/node/adapter/Settings.d.ts.map +0 -1
  326. package/dist/node/adapter/index.d.ts +0 -3
  327. package/dist/node/adapter/index.d.ts.map +0 -1
  328. package/dist/node/adapters/OsPubSubBridgeNetwork.d.ts +0 -3
  329. package/dist/node/adapters/OsPubSubBridgeNetwork.d.ts.map +0 -1
  330. package/dist/node/adapters/OsSettings.d.ts +0 -3
  331. package/dist/node/adapters/OsSettings.d.ts.map +0 -1
  332. package/dist/node/adapters/OsXyoPublicNetwork.d.ts +0 -3
  333. package/dist/node/adapters/OsXyoPublicNetwork.d.ts.map +0 -1
  334. package/dist/node/adapters/index.d.ts +0 -4
  335. package/dist/node/adapters/index.d.ts.map +0 -1
  336. package/dist/node/classes/dapp/DefaultsResource.d.ts +0 -26
  337. package/dist/node/classes/dapp/DefaultsResource.d.ts.map +0 -1
  338. package/dist/node/classes/dapp/index.d.ts +0 -2
  339. package/dist/node/classes/dapp/index.d.ts.map +0 -1
  340. package/dist/node/classes/index.d.ts +0 -5
  341. package/dist/node/classes/index.d.ts.map +0 -1
  342. package/dist/node/classes/lib/DappCreatorParams.d.ts +0 -16
  343. package/dist/node/classes/lib/DappCreatorParams.d.ts.map +0 -1
  344. package/dist/node/classes/lib/Insertable.d.ts +0 -10
  345. package/dist/node/classes/lib/Insertable.d.ts.map +0 -1
  346. package/dist/node/classes/lib/index.d.ts +0 -3
  347. package/dist/node/classes/lib/index.d.ts.map +0 -1
  348. package/dist/node/classes/menu/Caller.d.ts +0 -14
  349. package/dist/node/classes/menu/Caller.d.ts.map +0 -1
  350. package/dist/node/classes/menu/Queries.d.ts +0 -10
  351. package/dist/node/classes/menu/Queries.d.ts.map +0 -1
  352. package/dist/node/classes/menu/Resource.d.ts +0 -46
  353. package/dist/node/classes/menu/Resource.d.ts.map +0 -1
  354. package/dist/node/classes/menu/index.d.ts +0 -3
  355. package/dist/node/classes/menu/index.d.ts.map +0 -1
  356. package/dist/node/classes/settings/Caller.d.ts +0 -21
  357. package/dist/node/classes/settings/Caller.d.ts.map +0 -1
  358. package/dist/node/classes/settings/CallerBase.d.ts +0 -8
  359. package/dist/node/classes/settings/CallerBase.d.ts.map +0 -1
  360. package/dist/node/classes/settings/Resource.d.ts +0 -30
  361. package/dist/node/classes/settings/Resource.d.ts.map +0 -1
  362. package/dist/node/classes/settings/SettingsQueries.d.ts +0 -10
  363. package/dist/node/classes/settings/SettingsQueries.d.ts.map +0 -1
  364. package/dist/node/classes/settings/badge/Caller.d.ts +0 -13
  365. package/dist/node/classes/settings/badge/Caller.d.ts.map +0 -1
  366. package/dist/node/classes/settings/badge/Queries.d.ts +0 -7
  367. package/dist/node/classes/settings/badge/Queries.d.ts.map +0 -1
  368. package/dist/node/classes/settings/badge/Resource.d.ts +0 -23
  369. package/dist/node/classes/settings/badge/Resource.d.ts.map +0 -1
  370. package/dist/node/classes/settings/badge/index.d.ts +0 -3
  371. package/dist/node/classes/settings/badge/index.d.ts.map +0 -1
  372. package/dist/node/classes/settings/index.d.ts +0 -6
  373. package/dist/node/classes/settings/index.d.ts.map +0 -1
  374. package/dist/node/dapp/context/creator/Creator.d.ts +0 -23
  375. package/dist/node/dapp/context/creator/Creator.d.ts.map +0 -1
  376. package/dist/node/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts +0 -8
  377. package/dist/node/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts.map +0 -1
  378. package/dist/node/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts +0 -10
  379. package/dist/node/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts.map +0 -1
  380. package/dist/node/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts +0 -8
  381. package/dist/node/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts.map +0 -1
  382. package/dist/node/dapp/context/creator/DefaultPayloads/index.d.ts +0 -2
  383. package/dist/node/dapp/context/creator/DefaultPayloads/index.d.ts.map +0 -1
  384. package/dist/node/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts +0 -15
  385. package/dist/node/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts.map +0 -1
  386. package/dist/node/dapp/context/creator/ExternalModulePermissions/index.d.ts +0 -2
  387. package/dist/node/dapp/context/creator/ExternalModulePermissions/index.d.ts.map +0 -1
  388. package/dist/node/dapp/context/creator/createDappContext.d.ts +0 -3
  389. package/dist/node/dapp/context/creator/createDappContext.d.ts.map +0 -1
  390. package/dist/node/dapp/context/creator/index.d.ts +0 -4
  391. package/dist/node/dapp/context/creator/index.d.ts.map +0 -1
  392. package/dist/node/dapp/context/index.d.ts +0 -2
  393. package/dist/node/dapp/context/index.d.ts.map +0 -1
  394. package/dist/node/dapp/index.d.ts +0 -2
  395. package/dist/node/dapp/index.d.ts.map +0 -1
  396. package/dist/node/event/bus/Connection.d.ts +0 -16
  397. package/dist/node/event/bus/Connection.d.ts.map +0 -1
  398. package/dist/node/event/bus/EventBus.d.ts +0 -24
  399. package/dist/node/event/bus/EventBus.d.ts.map +0 -1
  400. package/dist/node/event/bus/PubSubConnection.d.ts +0 -12
  401. package/dist/node/event/bus/PubSubConnection.d.ts.map +0 -1
  402. package/dist/node/event/bus/index.d.ts +0 -4
  403. package/dist/node/event/bus/index.d.ts.map +0 -1
  404. package/dist/node/event/connections/DappAccessRequest.d.ts +0 -4
  405. package/dist/node/event/connections/DappAccessRequest.d.ts.map +0 -1
  406. package/dist/node/event/connections/DappsReady.d.ts +0 -3
  407. package/dist/node/event/connections/DappsReady.d.ts.map +0 -1
  408. package/dist/node/event/connections/ExposeDappRequest.d.ts +0 -4
  409. package/dist/node/event/connections/ExposeDappRequest.d.ts.map +0 -1
  410. package/dist/node/event/connections/OsPubSubNetworkReady.d.ts +0 -4
  411. package/dist/node/event/connections/OsPubSubNetworkReady.d.ts.map +0 -1
  412. package/dist/node/event/connections/OsSettingsReady.d.ts +0 -4
  413. package/dist/node/event/connections/OsSettingsReady.d.ts.map +0 -1
  414. package/dist/node/event/connections/OsXyoPublicReady.d.ts +0 -4
  415. package/dist/node/event/connections/OsXyoPublicReady.d.ts.map +0 -1
  416. package/dist/node/event/connections/index.d.ts +0 -7
  417. package/dist/node/event/connections/index.d.ts.map +0 -1
  418. package/dist/node/event/index.d.ts +0 -3
  419. package/dist/node/event/index.d.ts.map +0 -1
  420. package/dist/node/helpers/index.d.ts +0 -2
  421. package/dist/node/helpers/index.d.ts.map +0 -1
  422. package/dist/node/helpers/monitor/XyOsMonitor.d.ts +0 -14
  423. package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +0 -1
  424. package/dist/node/helpers/monitor/index.d.ts +0 -3
  425. package/dist/node/helpers/monitor/index.d.ts.map +0 -1
  426. package/dist/node/helpers/monitor/types.d.ts +0 -7
  427. package/dist/node/helpers/monitor/types.d.ts.map +0 -1
  428. package/dist/node/index.d.ts +0 -30
  429. package/dist/node/index.d.ts.map +0 -1
  430. package/dist/node/index.mjs +0 -3994
  431. package/dist/node/index.mjs.map +0 -1
  432. package/dist/node/initializer/DappInitializer.d.ts +0 -18
  433. package/dist/node/initializer/DappInitializer.d.ts.map +0 -1
  434. package/dist/node/initializer/index.d.ts +0 -2
  435. package/dist/node/initializer/index.d.ts.map +0 -1
  436. package/dist/node/intent/Caller.d.ts +0 -23
  437. package/dist/node/intent/Caller.d.ts.map +0 -1
  438. package/dist/node/intent/Resource.d.ts +0 -23
  439. package/dist/node/intent/Resource.d.ts.map +0 -1
  440. package/dist/node/intent/index.d.ts +0 -3
  441. package/dist/node/intent/index.d.ts.map +0 -1
  442. package/dist/node/lib/ExternalStore.d.ts +0 -7
  443. package/dist/node/lib/ExternalStore.d.ts.map +0 -1
  444. package/dist/node/lib/Listener.d.ts +0 -2
  445. package/dist/node/lib/Listener.d.ts.map +0 -1
  446. package/dist/node/lib/ModuleAccountPaths.d.ts +0 -3
  447. package/dist/node/lib/ModuleAccountPaths.d.ts.map +0 -1
  448. package/dist/node/lib/ModuleNames.d.ts +0 -3
  449. package/dist/node/lib/ModuleNames.d.ts.map +0 -1
  450. package/dist/node/lib/NameTransforms.d.ts +0 -11
  451. package/dist/node/lib/NameTransforms.d.ts.map +0 -1
  452. package/dist/node/lib/PayloadStore.d.ts +0 -37
  453. package/dist/node/lib/PayloadStore.d.ts.map +0 -1
  454. package/dist/node/lib/ResourceStores.d.ts +0 -7
  455. package/dist/node/lib/ResourceStores.d.ts.map +0 -1
  456. package/dist/node/lib/index.d.ts +0 -12
  457. package/dist/node/lib/index.d.ts.map +0 -1
  458. package/dist/node/lib/initializeXns.d.ts +0 -3
  459. package/dist/node/lib/initializeXns.d.ts.map +0 -1
  460. package/dist/node/lib/isEqual.d.ts +0 -2
  461. package/dist/node/lib/isEqual.d.ts.map +0 -1
  462. package/dist/node/lib/isPayload.d.ts +0 -6
  463. package/dist/node/lib/isPayload.d.ts.map +0 -1
  464. package/dist/node/lib/tokenPlacesSplit.d.ts +0 -3
  465. package/dist/node/lib/tokenPlacesSplit.d.ts.map +0 -1
  466. package/dist/node/loadOsNode.d.ts +0 -5
  467. package/dist/node/loadOsNode.d.ts.map +0 -1
  468. package/dist/node/manifest/index.d.ts +0 -3
  469. package/dist/node/manifest/index.d.ts.map +0 -1
  470. package/dist/node/manifest/manifestReplacementTokens.d.ts +0 -4
  471. package/dist/node/manifest/manifestReplacementTokens.d.ts.map +0 -1
  472. package/dist/node/manifests/index.d.ts +0 -2
  473. package/dist/node/manifests/index.d.ts.map +0 -1
  474. package/dist/node/models/access/ValidDappAccessInterfaces.d.ts +0 -5
  475. package/dist/node/models/access/ValidDappAccessInterfaces.d.ts.map +0 -1
  476. package/dist/node/models/access/index.d.ts +0 -2
  477. package/dist/node/models/access/index.d.ts.map +0 -1
  478. package/dist/node/models/index.d.ts +0 -2
  479. package/dist/node/models/index.d.ts.map +0 -1
  480. package/dist/node/profileModuleEvents.d.ts +0 -9
  481. package/dist/node/profileModuleEvents.d.ts.map +0 -1
  482. package/dist/node/registration/DappRegistrationService.d.ts +0 -37
  483. package/dist/node/registration/DappRegistrationService.d.ts.map +0 -1
  484. package/dist/node/registration/DappRegistry.d.ts +0 -26
  485. package/dist/node/registration/DappRegistry.d.ts.map +0 -1
  486. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +0 -23
  487. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +0 -1
  488. package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts +0 -9
  489. package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +0 -1
  490. package/dist/node/registration/ValidateDappAccessDiviner/index.d.ts +0 -3
  491. package/dist/node/registration/ValidateDappAccessDiviner/index.d.ts.map +0 -1
  492. package/dist/node/registration/index.d.ts +0 -3
  493. package/dist/node/registration/index.d.ts.map +0 -1
  494. package/dist/node/scripts/xyos/command/config.d.ts +0 -3
  495. package/dist/node/scripts/xyos/command/config.d.ts.map +0 -1
  496. package/dist/node/scripts/xyos/command/create.d.ts +0 -3
  497. package/dist/node/scripts/xyos/command/create.d.ts.map +0 -1
  498. package/dist/node/scripts/xyos/command/index.d.ts +0 -6
  499. package/dist/node/scripts/xyos/command/index.d.ts.map +0 -1
  500. package/dist/node/scripts/xyos/command/manifest.d.ts +0 -3
  501. package/dist/node/scripts/xyos/command/manifest.d.ts.map +0 -1
  502. package/dist/node/scripts/xyos/command/start.d.ts +0 -3
  503. package/dist/node/scripts/xyos/command/start.d.ts.map +0 -1
  504. package/dist/node/scripts/xyos/index.d.ts +0 -2
  505. package/dist/node/scripts/xyos/index.d.ts.map +0 -1
  506. package/dist/node/scripts/xyos/index.mjs +0 -2164
  507. package/dist/node/scripts/xyos/index.mjs.map +0 -1
  508. package/dist/node/scripts/xyos/lib/createFromTemplate.d.ts +0 -7
  509. package/dist/node/scripts/xyos/lib/createFromTemplate.d.ts.map +0 -1
  510. package/dist/node/scripts/xyos/lib/headless.d.ts +0 -8
  511. package/dist/node/scripts/xyos/lib/headless.d.ts.map +0 -1
  512. package/dist/node/scripts/xyos/lib/index.d.ts +0 -3
  513. package/dist/node/scripts/xyos/lib/index.d.ts.map +0 -1
  514. package/dist/node/signer/Signers.d.ts +0 -17
  515. package/dist/node/signer/Signers.d.ts.map +0 -1
  516. package/dist/node/signer/index.d.ts +0 -2
  517. package/dist/node/signer/index.d.ts.map +0 -1
  518. package/dist/node/stack/Base.d.ts +0 -41
  519. package/dist/node/stack/Base.d.ts.map +0 -1
  520. package/dist/node/stack/Manager.d.ts +0 -19
  521. package/dist/node/stack/Manager.d.ts.map +0 -1
  522. package/dist/node/stack/Map.d.ts +0 -3
  523. package/dist/node/stack/Map.d.ts.map +0 -1
  524. package/dist/node/stack/OsPubSubNetworkStack.d.ts +0 -14
  525. package/dist/node/stack/OsPubSubNetworkStack.d.ts.map +0 -1
  526. package/dist/node/stack/OsSettingsStack.d.ts +0 -9
  527. package/dist/node/stack/OsSettingsStack.d.ts.map +0 -1
  528. package/dist/node/stack/XyoPublicNetworkStack.d.ts +0 -9
  529. package/dist/node/stack/XyoPublicNetworkStack.d.ts.map +0 -1
  530. package/dist/node/stack/index.d.ts +0 -7
  531. package/dist/node/stack/index.d.ts.map +0 -1
  532. package/dist/node/system/ManageSystemDapps.d.ts +0 -33
  533. package/dist/node/system/ManageSystemDapps.d.ts.map +0 -1
  534. package/dist/node/system/Queries.d.ts +0 -9
  535. package/dist/node/system/Queries.d.ts.map +0 -1
  536. package/dist/node/system/index.d.ts +0 -2
  537. package/dist/node/system/index.d.ts.map +0 -1
  538. package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts +0 -30
  539. package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts.map +0 -1
  540. package/dist/node/utils/getApiDomain.d.ts +0 -3
  541. package/dist/node/utils/getApiDomain.d.ts.map +0 -1
  542. package/dist/node/utils/index.d.ts +0 -4
  543. package/dist/node/utils/index.d.ts.map +0 -1
  544. package/dist/node/utils/renameObjKey.d.ts +0 -7
  545. package/dist/node/utils/renameObjKey.d.ts.map +0 -1
  546. package/dist/node/wallet/DappSeedPhraseRepository.d.ts +0 -16
  547. package/dist/node/wallet/DappSeedPhraseRepository.d.ts.map +0 -1
  548. package/dist/node/wallet/SeedPhraseRepository.d.ts +0 -28
  549. package/dist/node/wallet/SeedPhraseRepository.d.ts.map +0 -1
  550. package/dist/node/wallet/index.d.ts +0 -3
  551. package/dist/node/wallet/index.d.ts.map +0 -1
@@ -1,3994 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/access/Caller.ts
5
- import { assertEx as assertEx16 } from "@xylabs/sdk-js";
6
- import { asNodeInstance as asNodeInstance2 } from "@xyo-network/node-model";
7
- import { isRegisteredDappAccessDappSet as isRegisteredDappAccessDappSet2 } from "@xyo-network/os-model";
8
- import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
9
- import { ModuleFactoryLocator as ModuleFactoryLocator9 } from "@xyo-network/sdk-js";
10
-
11
- // src/OsCallerBase.ts
12
- import { assertEx } from "@xylabs/sdk-js";
13
- import { asArchivistInstance } from "@xyo-network/archivist-model";
14
- import { asDivinerInstance } from "@xyo-network/diviner-model";
15
- var DappsArchivistModuleName = "DappsArchivist";
16
- var DappsArchivistDevelopmentModuleName = `${DappsArchivistModuleName}Development`;
17
- var DappsArchivistPayloadDivinerModuleName = "DappsArchivistPayloadDiviner";
18
- var DappsArchivistPayloadDevelopmentDivinerModuleName = `${DappsArchivistPayloadDivinerModuleName}Development`;
19
- var RegisteredDappInterfacesArchivistModuleName = "RegisteredDappInterfacesArchivist";
20
- var OsCallerBase = class {
21
- static {
22
- __name(this, "OsCallerBase");
23
- }
24
- context;
25
- constructor(context) {
26
- this.context = context;
27
- }
28
- // Get the dapps archivist
29
- async getDappsArchivist() {
30
- const mod = assertEx(await this.context.root.resolve(DappsArchivistModuleName), () => `${DappsArchivistModuleName} not found`);
31
- return asArchivistInstance(mod, () => `${DappsArchivistModuleName} is not an archivist`, {
32
- required: true
33
- });
34
- }
35
- // Get the dapps archivist development
36
- async getDappsArchivistDevelopment() {
37
- const mod = assertEx(await this.context.root.resolve(DappsArchivistDevelopmentModuleName), () => `${DappsArchivistDevelopmentModuleName} not found`);
38
- return asArchivistInstance(mod, () => `${DappsArchivistDevelopmentModuleName} is not an archivist`, {
39
- required: true
40
- });
41
- }
42
- // Get the dapps archivist payload diviner
43
- async getDappsArchivistPayloadDiviner() {
44
- const mod = assertEx(await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName), () => `${DappsArchivistPayloadDivinerModuleName} not found`);
45
- return asDivinerInstance(mod, () => `${DappsArchivistPayloadDivinerModuleName} is not a diviner`, {
46
- required: true
47
- });
48
- }
49
- // Get the dapps archivist payload diviner development
50
- async getDappsArchivistPayloadDivinerDevelopment() {
51
- const mod = assertEx(await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName), () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`);
52
- return asDivinerInstance(mod, () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} is not a diviner`, {
53
- required: true
54
- });
55
- }
56
- // Get the registered dapp interfaces archivist
57
- async getRegisteredDappInterfacesArchivist() {
58
- const mod = assertEx(await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName), () => `${RegisteredDappInterfacesArchivistModuleName} not found`);
59
- return asArchivistInstance(mod, () => `${RegisteredDappInterfacesArchivistModuleName} is not an archivist`, {
60
- required: true
61
- });
62
- }
63
- };
64
-
65
- // src/RunningDappCache.ts
66
- import { assertEx as assertEx15 } from "@xylabs/sdk-js";
67
- import { Mutex as Mutex3 } from "async-mutex";
68
-
69
- // src/dapp/context/creator/createDappContext.ts
70
- import { GenericPayloadDiviner } from "@xyo-network/diviner-payload-generic";
71
- import { HDWallet as HDWallet2, ModuleFactoryLocator as ModuleFactoryLocator2 } from "@xyo-network/sdk-js";
72
-
73
- // src/wallet/DappSeedPhraseRepository.ts
74
- import { PayloadDivinerQuerySchema } from "@xyo-network/diviner-payload-model";
75
- import { DappWalletSeedPhraseSchema } from "@xyo-network/os-model";
76
- import { HDWallet } from "@xyo-network/sdk-js";
77
- import { v4 as uuid } from "uuid";
78
- var DappSeedPhraseRepository = class extends OsCallerBase {
79
- static {
80
- __name(this, "DappSeedPhraseRepository");
81
- }
82
- allowedNames;
83
- // record of all dapps that have requested a seed phrase with the OS
84
- dappIdRepository = /* @__PURE__ */ new Map();
85
- // record of all walletIds that have been issued to registered dapps
86
- walletIdRepository = /* @__PURE__ */ new Map();
87
- constructor(xyOs, allowedNames) {
88
- super(xyOs);
89
- this.allowedNames = allowedNames;
90
- }
91
- async add(dappId) {
92
- const archivist = await this.getDappsArchivist();
93
- const seedPhrase = this.newPhrase();
94
- const walletId = uuid();
95
- const payload = {
96
- dappId,
97
- schema: DappWalletSeedPhraseSchema,
98
- seedPhrase,
99
- walletId
100
- };
101
- await archivist.insert([
102
- payload
103
- ]);
104
- this.dappIdRepository.set(dappId, payload);
105
- this.walletIdRepository.set(walletId, payload);
106
- return walletId;
107
- }
108
- async findOrCreate(dappName) {
109
- if (this.allowedNames.includes(dappName)) {
110
- const existingPayload = await this.checkDappId(dappName);
111
- if (existingPayload) return existingPayload.walletId;
112
- try {
113
- await this.add(dappName);
114
- const existingPayload2 = await this.checkDappId(dappName);
115
- if (existingPayload2) return existingPayload2.walletId;
116
- throw new Error(`failed to add seed phrase: ${dappName}`);
117
- } catch (e) {
118
- console.error(e);
119
- throw new Error(`failed to add seed phrase: ${dappName}`, {
120
- cause: e
121
- });
122
- }
123
- } else {
124
- throw new Error(`${dappName} is not allowed to register a seed phase. NOTE: this is a safeguard till 3rd party dApps can be validated`);
125
- }
126
- }
127
- async request(walletId) {
128
- return (await this.checkWalletId(walletId))?.seedPhrase;
129
- }
130
- async checkDappId(dappId) {
131
- const diviner = await this.getDappsArchivistPayloadDiviner();
132
- const query = {
133
- dappId,
134
- limit: 1,
135
- order: "desc",
136
- schema: PayloadDivinerQuerySchema,
137
- schemas: [
138
- DappWalletSeedPhraseSchema
139
- ]
140
- };
141
- const results = await diviner.divine([
142
- query
143
- ]);
144
- return results.length > 0 ? results[0] : void 0;
145
- }
146
- async checkWalletId(walletId) {
147
- const diviner = await this.getDappsArchivistPayloadDiviner();
148
- const query = {
149
- limit: 1,
150
- order: "desc",
151
- schema: PayloadDivinerQuerySchema,
152
- schemas: [
153
- DappWalletSeedPhraseSchema
154
- ],
155
- walletId
156
- };
157
- const results = await diviner.divine([
158
- query
159
- ]);
160
- return results.length > 0 ? results[0] : void 0;
161
- }
162
- newPhrase() {
163
- return HDWallet.generateMnemonic();
164
- }
165
- };
166
-
167
- // src/dapp/context/creator/Creator.ts
168
- import { assertEx as assertEx3 } from "@xylabs/sdk-js";
169
- import { asArchivistInstance as asArchivistInstance3 } from "@xyo-network/archivist-model";
170
- import { replaceManifestTokens } from "@xyo-network/kernel";
171
- import { DappPackageManifestPayloadSchema } from "@xyo-network/os-model";
172
- import { ModuleFactoryLocator } from "@xyo-network/sdk-js";
173
-
174
- // src/DappCallerBase.ts
175
- import { assertEx as assertEx2, toSafeJsonString } from "@xylabs/sdk-js";
176
- import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/archivist-model";
177
- import { asDivinerInstance as asDivinerInstance2 } from "@xyo-network/diviner-model";
178
- var DappArchivistModuleName = "DappArchivist";
179
- var IntentArchivistModuleName = "IntentArchivist";
180
- var IntentArchivistPayloadDivinerModuleName = "IntentArchivistPayloadDiviner";
181
- var DappArchivistPayloadDivinerModuleName = "DappArchivistPayloadDiviner";
182
- var DappCallerBase = class {
183
- static {
184
- __name(this, "DappCallerBase");
185
- }
186
- context;
187
- constructor(context) {
188
- this.context = context;
189
- }
190
- /**
191
- * Get the DappArchivist
192
- */
193
- async getDappArchivist() {
194
- const mod = assertEx2(await this.context.root.resolve(DappArchivistModuleName), () => `${DappArchivistModuleName} not found [${toSafeJsonString(this.context.root.publicChildren())}]`);
195
- return asArchivistInstance2(mod, () => `${DappArchivistModuleName} is not an archivist`, {
196
- required: true
197
- });
198
- }
199
- /**
200
- * Get the DappArchivistPayloadDiviner
201
- */
202
- async getDappArchivistPayloadDiviner() {
203
- const mod = assertEx2(await this.context.root.resolve(DappArchivistPayloadDivinerModuleName), () => `${DappArchivistPayloadDivinerModuleName} not found`);
204
- return asDivinerInstance2(mod, () => `${DappArchivistPayloadDivinerModuleName} is not a diviner`, {
205
- required: true
206
- });
207
- }
208
- /**
209
- * Get the IntentArchivist
210
- */
211
- async getDappIntentArchivist() {
212
- const mod = assertEx2(await this.context.root.resolve(IntentArchivistModuleName), () => `${IntentArchivistModuleName} not found`);
213
- return asArchivistInstance2(mod, () => `${IntentArchivistModuleName} is not an archivist`, {
214
- required: true
215
- });
216
- }
217
- // Get the IntentArchivistPayloadDiviner
218
- async getDappIntentArchivistPayloadDiviner() {
219
- const mod = assertEx2(await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName), () => `${IntentArchivistPayloadDivinerModuleName} not found`);
220
- return asDivinerInstance2(mod, () => `${IntentArchivistPayloadDivinerModuleName} is not a diviner`, {
221
- required: true
222
- });
223
- }
224
- };
225
-
226
- // src/manifest/manifestReplacementTokens.ts
227
- import { getXnsDomain } from "@xyo-network/kernel";
228
- var manifestReplacementTokens = /* @__PURE__ */ __name((xnsNodeUrl, xnsNetwork) => ({
229
- "[REPLACE_WITH_NS_NODE_URL]": getXnsDomain(xnsNodeUrl, xnsNetwork)
230
- }), "manifestReplacementTokens");
231
-
232
- // src/manifest/os-node.manifest.json
233
- var os_node_manifest_default = {
234
- $schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json",
235
- nodes: [
236
- {
237
- config: {
238
- accountPath: "0'",
239
- name: "OsNode",
240
- schema: "network.xyo.node.config"
241
- },
242
- modules: {
243
- private: [],
244
- public: [
245
- {
246
- config: {
247
- accountPath: "1'",
248
- name: "OSArchivist",
249
- dbName: "OSArchivist-2025-01-13",
250
- labels: {
251
- "network.xyo.archivist.persistence.scope": "device"
252
- },
253
- storeName: "payloads",
254
- parents: {
255
- read: [
256
- "Archivist"
257
- ]
258
- },
259
- schema: "network.xyo.archivist.config"
260
- }
261
- },
262
- {
263
- config: {
264
- accountPath: "3'",
265
- name: "DappsArchivist",
266
- dbName: "DappsArchivist-2025-01-13",
267
- labels: {
268
- "network.xyo.archivist.persistence.scope": "device"
269
- },
270
- storeName: "payloads",
271
- schema: "network.xyo.archivist.config"
272
- }
273
- },
274
- {
275
- config: {
276
- archivist: "DappsArchivist",
277
- dbVersion: 1,
278
- name: "DappsArchivistPayloadDiviner",
279
- labels: {
280
- "network.xyo.archivist.persistence.scope": "device"
281
- },
282
- schema: "network.xyo.diviner.payload.generic.config"
283
- }
284
- },
285
- {
286
- config: {
287
- accountPath: "4'",
288
- dbName: "IntentArchivist-2025-01-13",
289
- name: "IntentArchivist",
290
- storeName: "payloads",
291
- labels: {
292
- "network.xyo.archivist.persistence.scope": "device"
293
- },
294
- schema: "network.xyo.archivist.config"
295
- }
296
- },
297
- {
298
- config: {
299
- accountPath: "7",
300
- archivist: "IntentArchivist",
301
- dbVersion: 1,
302
- name: "IntentArchivistPayloadDiviner",
303
- labels: {
304
- "network.xyo.archivist.persistence.scope": "device"
305
- },
306
- schema: "network.xyo.diviner.payload.generic.config",
307
- storeName: "payloads"
308
- }
309
- },
310
- {
311
- config: {
312
- accountPath: "8",
313
- name: "RegisteredDappInterfacesArchivist",
314
- schema: "network.xyo.archivist.memory.config"
315
- }
316
- },
317
- {
318
- config: {
319
- accountPath: "9'",
320
- name: "DappsArchivistDevelopment",
321
- parents: {
322
- write: [
323
- "DappsArchivist"
324
- ]
325
- },
326
- schema: "network.xyo.archivist.memory.config"
327
- }
328
- },
329
- {
330
- config: {
331
- accountPath: "10",
332
- archivist: "DappsArchivistDevelopment",
333
- dbVersion: 1,
334
- name: "DappsArchivistPayloadDivinerDevelopment",
335
- labels: {
336
- "network.xyo.generic.payload.diviner": "GenericPayloadDiviner"
337
- },
338
- schema: "network.xyo.diviner.payload.generic.config"
339
- }
340
- },
341
- {
342
- config: {
343
- name: "OsPubSubNetworkStackNode",
344
- schema: "network.xyo.node.config"
345
- }
346
- },
347
- {
348
- config: {
349
- name: "OsSettingsStackNode",
350
- schema: "network.xyo.node.config"
351
- }
352
- },
353
- {
354
- config: {
355
- name: "OsXyoPublicNetworkStackNode",
356
- schema: "network.xyo.node.config"
357
- }
358
- }
359
- ]
360
- }
361
- }
362
- ],
363
- schema: "network.xyo.manifest.package.dapp"
364
- };
365
-
366
- // src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts
367
- import { PayloadBuilder } from "@xyo-network/payload-builder";
368
-
369
- // src/classes/lib/Insertable.ts
370
- var createInsertable = /* @__PURE__ */ __name((insertable, ...params) => new insertable(...params), "createInsertable");
371
-
372
- // src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts
373
- var DappAccessPayloads = class {
374
- static {
375
- __name(this, "DappAccessPayloads");
376
- }
377
- context;
378
- constructor(context, _dappName) {
379
- this.context = context;
380
- }
381
- async payloads() {
382
- const osCaller = new OsCallerBase(this.context);
383
- const archivist = await osCaller.getRegisteredDappInterfacesArchivist();
384
- return await archivist.all();
385
- }
386
- };
387
-
388
- // src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts
389
- import { NodeOsInfoSchema } from "@xyo-network/os-model";
390
- var NodeInfoPayload = class {
391
- static {
392
- __name(this, "NodeInfoPayload");
393
- }
394
- _context;
395
- constructor(context, _dappName) {
396
- this._context = context;
397
- }
398
- async payloads() {
399
- const exposedNode = this._context.exposedNode;
400
- if (exposedNode) {
401
- console.debug("[DEBUG]", "Found Exposed Node Address", exposedNode?.address);
402
- } else {
403
- console.error("exposedNode not found");
404
- }
405
- await Promise.resolve();
406
- const nodeOsInfo = {
407
- publicAddress: exposedNode?.address ?? "",
408
- schema: NodeOsInfoSchema
409
- };
410
- return [
411
- nodeOsInfo
412
- ];
413
- }
414
- };
415
-
416
- // src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts
417
- var DefaultPayloads = class {
418
- static {
419
- __name(this, "DefaultPayloads");
420
- }
421
- dappArchivist;
422
- dappName;
423
- xyOs;
424
- constructor(dappArchivist, xyOs, dappName) {
425
- this.dappArchivist = dappArchivist;
426
- this.xyOs = xyOs;
427
- this.dappName = dappName;
428
- }
429
- async insert() {
430
- const insertables = [
431
- NodeInfoPayload,
432
- DappAccessPayloads
433
- ];
434
- const insertPayloads = [];
435
- for (const insertable of insertables) {
436
- const classInstance = createInsertable(insertable, this.xyOs, this.dappName);
437
- const payloads = await classInstance.payloads();
438
- insertPayloads.push(...payloads);
439
- }
440
- for (const payload of insertPayloads) {
441
- const [existing] = await this.dappArchivist.get([
442
- await PayloadBuilder.dataHash(payload)
443
- ]);
444
- if (existing) continue;
445
- await this.dappArchivist.insert([
446
- payload
447
- ]);
448
- }
449
- }
450
- };
451
-
452
- // src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts
453
- var ALLOWED_MODULES_FROM_PARENT = [
454
- "IntentArchivist",
455
- "OsSettingsNode",
456
- "OsPubSubNetworkStackNode",
457
- "OsXyoPublicNetworkStackNode"
458
- ];
459
- var ExternalModulePermissions = class {
460
- static {
461
- __name(this, "ExternalModulePermissions");
462
- }
463
- context;
464
- dappName;
465
- dappWindowNode;
466
- externalPermissions;
467
- constructor(context, dappWindowNode, dappName, externalPermissions) {
468
- this.context = context;
469
- this.dappWindowNode = dappWindowNode;
470
- this.dappName = dappName;
471
- this.externalPermissions = externalPermissions;
472
- }
473
- async permit() {
474
- for (const permission of this.externalPermissions ?? []) {
475
- await this.permitExternalModule(permission);
476
- }
477
- }
478
- getExternalModuleName(permission) {
479
- return permission.name;
480
- }
481
- async permitExternalModule(externalPermission) {
482
- const externalModuleName = this.getExternalModuleName(externalPermission);
483
- if (ALLOWED_MODULES_FROM_PARENT.includes(externalModuleName)) {
484
- const mod = await this.resolveExternalModule(externalModuleName);
485
- await this.registerAndAttachModule(mod);
486
- } else {
487
- console.warn(`${this.dappName} requested ${externalModuleName} but it was not fulfilled`);
488
- }
489
- }
490
- async registerAndAttachModule(mod) {
491
- if (mod) {
492
- await this.dappWindowNode.register?.(mod);
493
- await this.dappWindowNode.attach(mod.address, true);
494
- }
495
- }
496
- async resolveExternalModule(id) {
497
- return await this.context.root.resolve(id);
498
- }
499
- };
500
-
501
- // src/dapp/context/creator/Creator.ts
502
- var DappContextCreator = class _DappContextCreator {
503
- static {
504
- __name(this, "DappContextCreator");
505
- }
506
- // Designated offset path for the wallet used by windowed dapps. In the future, other offsets could be used for other dapp modes
507
- static DAPP_WINDOW_WALLET_PATH = "1";
508
- context;
509
- dappId;
510
- externalPermissions;
511
- rootWallet;
512
- sharedLocator;
513
- targetDappManifestParams;
514
- constructor(targetDappManifestParams, dappId, context, rootWallet, externalPermissions, sharedLocator) {
515
- this.targetDappManifestParams = targetDappManifestParams;
516
- this.dappId = dappId;
517
- this.context = context;
518
- this.rootWallet = rootWallet;
519
- this.externalPermissions = externalPermissions;
520
- this.sharedLocator = sharedLocator;
521
- }
522
- static async create(params, xnsNodeUrl, xnsNetwork) {
523
- const { config, locator, context, wallet } = params;
524
- const { payload, dappName, publicChildren, privateChildren } = config;
525
- const { external, manifestPayload } = this.parseDappPackageManifestPayload(payload, xnsNodeUrl, xnsNetwork);
526
- console.debug("[DEBUG] dApp manifest", manifestPayload);
527
- const dappWallet = await wallet.derivePath(_DappContextCreator.DAPP_WINDOW_WALLET_PATH);
528
- const targetDappManifestParams = [
529
- manifestPayload,
530
- dappWallet,
531
- locator ?? new ModuleFactoryLocator(),
532
- publicChildren,
533
- privateChildren
534
- ];
535
- const instance = new this(targetDappManifestParams, dappName, context, wallet, external?.modules, locator);
536
- return instance;
537
- }
538
- // Add default payloads to the archivist shared between the os and the dapp
539
- static async primeDappArchivist(dappContext, osContext, dappName) {
540
- const dappCaller = new DappCallerBase(dappContext);
541
- const dappArchivist = await dappCaller.getDappArchivist();
542
- const defaultPayloads = new DefaultPayloads(dappArchivist, osContext, dappName);
543
- await defaultPayloads.insert();
544
- }
545
- // Reset the dapp archivist to remove all payloads
546
- static async resetDappArchivist(context) {
547
- const dappModule = await context.root.resolve("DappArchivist");
548
- const dappArchivist = assertEx3(asArchivistInstance3(dappModule), () => "resetDappArchivist: DappArchivist not found");
549
- await dappArchivist.clear();
550
- }
551
- static parseDappPackageManifestPayload(payload, xnsNodeUrl, xnsNetwork) {
552
- const { external, ...manifestWithoutExternals } = payload;
553
- const manifestPayloadRaw = {
554
- ...manifestWithoutExternals,
555
- schema: DappPackageManifestPayloadSchema
556
- };
557
- console.log("DappContextCreator:parseDappPackageManifestPayload", xnsNodeUrl, xnsNetwork);
558
- const manifestPayload = replaceManifestTokens(manifestPayloadRaw, manifestReplacementTokens(xnsNodeUrl, xnsNetwork));
559
- return {
560
- external,
561
- manifestPayload
562
- };
563
- }
564
- async loadDappContext(context) {
565
- console.log("DappNodesCreator:loadDappContext", this.dappId);
566
- const dapp = await context.dappByName(this.dappId) ?? await (async () => {
567
- const dapp2 = await context.buildDapp(this.targetDappManifestParams[0], this.dappId);
568
- await dapp2.boot(this.rootWallet, this.sharedLocator);
569
- return dapp2;
570
- })();
571
- await this.handleExternalModulePermissions(dapp.root);
572
- await _DappContextCreator.primeDappArchivist(dapp, this.context, this.dappId);
573
- return dapp;
574
- }
575
- // try to satisfy the external permissions requested by a dapp
576
- async handleExternalModulePermissions(dappWindowNode) {
577
- const externalModulePermissions = new ExternalModulePermissions(this.context, dappWindowNode, this.dappId, this.externalPermissions);
578
- await externalModulePermissions.permit();
579
- }
580
- };
581
-
582
- // src/dapp/context/creator/createDappContext.ts
583
- var GenericPayloadDivinerTags = {
584
- "network.xyo.generic.payload.diviner": "GenericPayloadDiviner"
585
- };
586
- var resolveLocator = /* @__PURE__ */ __name((existingLocator) => {
587
- const locator = existingLocator ?? new ModuleFactoryLocator2();
588
- locator.register(GenericPayloadDiviner.factory(), GenericPayloadDivinerTags);
589
- return locator;
590
- }, "resolveLocator");
591
- var createDappContext = /* @__PURE__ */ __name(async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwork) => {
592
- console.log("createNodes");
593
- try {
594
- const dappSeedPhraseRepository = new DappSeedPhraseRepository(context, allowedNames);
595
- const seedPhrase = await dappSeedPhraseRepository.request(dapp.config.walletId);
596
- if (!seedPhrase) {
597
- throw new Error(`unable to find seed phrase for walletId: ${JSON.stringify(dapp.config, null, 2)}`);
598
- }
599
- const wallet = await HDWallet2.fromPhrase(seedPhrase);
600
- const dappName = dapp.config.name;
601
- const { config: dappConfig, params: dappParams } = dapp;
602
- const locator = resolveLocator((dappParams.locator ?? new ModuleFactoryLocator2()).merge(context.platformLocator));
603
- const params = {
604
- config: {
605
- dappName,
606
- payload: dappConfig.manifest
607
- },
608
- context,
609
- locator,
610
- wallet
611
- };
612
- const dappContextCreator = await DappContextCreator.create(params, xnsNodeUrl, xnsNetwork);
613
- const dappContext = await dappContextCreator.loadDappContext(context);
614
- return {
615
- context: dappContext,
616
- dappWallet: wallet
617
- };
618
- } catch (e) {
619
- const error = e;
620
- console.error(`Error creating dappWindow node: ${error.message}`);
621
- console.error(`Error creating dappWindow node: ${error.stack}`);
622
- throw new Error(`Error creating dappWindow node: ${error.message}`, {
623
- cause: e
624
- });
625
- }
626
- }, "createDappContext");
627
-
628
- // src/XyOs.ts
629
- import { assertEx as assertEx14 } from "@xylabs/sdk-js";
630
- import { boot } from "@xyo-network/bios";
631
- import { Kernel } from "@xyo-network/kernel";
632
- import { ModuleFactoryLocator as ModuleFactoryLocator8 } from "@xyo-network/sdk-js";
633
-
634
- // src/event/bus/Connection.ts
635
- import { assertEx as assertEx4, BaseEmitter } from "@xylabs/sdk-js";
636
- var EventBusConnection = class extends BaseEmitter {
637
- static {
638
- __name(this, "EventBusConnection");
639
- }
640
- _id;
641
- description;
642
- type;
643
- constructor(request) {
644
- super({});
645
- this.description = request.description;
646
- this.type = request.type;
647
- }
648
- get id() {
649
- return assertEx4(this._id, () => "Connection ID not set. Did you forget to call buildConnection()?");
650
- }
651
- buildConnection(id) {
652
- this._id = id;
653
- }
654
- };
655
-
656
- // src/event/bus/EventBus.ts
657
- import { assertEx as assertEx5, findAs, forget } from "@xylabs/sdk-js";
658
- import { asArchivistInstance as asArchivistInstance4 } from "@xyo-network/archivist";
659
- import { asOptionalEventBusEvent, isPubSubConnections } from "@xyo-network/os-model";
660
- import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
661
- import { asSchema } from "@xyo-network/payload-model";
662
- import { MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/sdk-js";
663
- import { Mutex } from "async-mutex";
664
- import { v4 as uuid2 } from "uuid";
665
- var EventBus = class {
666
- static {
667
- __name(this, "EventBus");
668
- }
669
- // Internal Archivist to store event data
670
- _archivist;
671
- // Store all connections
672
- connections = {};
673
- // Store all publisher callbacks for later removal
674
- publisherCallbacks = {};
675
- startMutex = new Mutex();
676
- get archivist() {
677
- return asArchivistInstance4(assertEx5(this._archivist, () => "Archivist not found. Did you forget to call start()?"), "not a valid archivist instance", {
678
- required: true
679
- });
680
- }
681
- addConnection(connection) {
682
- const id = uuid2();
683
- this.connections[id] = connection;
684
- connection.buildConnection(id);
685
- if (isPubSubConnections(connection)) {
686
- this.handlePublisherAdd(connection);
687
- } else {
688
- throw new Error("Unsupported connection type. Must be PubSub");
689
- }
690
- return connection;
691
- }
692
- removeConnection(connectionId) {
693
- const connection = this.connections[connectionId];
694
- if (!connection) {
695
- throw new Error("Connection not found " + connectionId);
696
- }
697
- if (connection && isPubSubConnections(connection)) {
698
- this.handlePublisherRemove(connection);
699
- }
700
- delete this.connections[connectionId];
701
- }
702
- async start(storeName = "EventBusArchivist") {
703
- return await this.startMutex.runExclusive(async () => {
704
- if (this._archivist) {
705
- console.warn("EventBus already started");
706
- return this;
707
- }
708
- this._archivist = await MemoryArchivist.create({
709
- config: {
710
- name: storeName,
711
- schema: MemoryArchivistConfigSchema
712
- }
713
- });
714
- this.archivist.on("inserted", ({ payloads }) => {
715
- const eventBusEvent = findAs(payloads, asOptionalEventBusEvent);
716
- if (!eventBusEvent) return;
717
- for (const connectionId in this.connections) {
718
- const connection = this.connections[connectionId];
719
- if (isPubSubConnections(connection) && connection.subscribableEvents) {
720
- for (const [eventName, callback] of connection.subscribableEvents.entries()) {
721
- if (eventName !== eventBusEvent.name) continue;
722
- if (callback) {
723
- const forgettable = /* @__PURE__ */ __name(async () => await callback({
724
- payloads
725
- }), "forgettable");
726
- forget(forgettable());
727
- }
728
- }
729
- }
730
- }
731
- });
732
- return this;
733
- });
734
- }
735
- handlePublisherAdd(connection) {
736
- for (const eventName of connection.publishableEvents ?? []) {
737
- const connectionPublisherCallback = /* @__PURE__ */ __name(async ({ payloads }) => {
738
- const event = {
739
- name: eventName,
740
- schema: asSchema("network.xyo.event.bus.event", true)
741
- };
742
- const eventPayloads = payloads ?? [];
743
- event.sources = await PayloadBuilder2.dataHashes(eventPayloads);
744
- try {
745
- await this.archivist.insert([
746
- event,
747
- ...payloads ?? []
748
- ]);
749
- } catch (e) {
750
- console.error("Error inserting event into archivist", e);
751
- }
752
- }, "connectionPublisherCallback");
753
- connection.on(eventName, connectionPublisherCallback);
754
- const callbackId = connection.id + eventName;
755
- this.publisherCallbacks[callbackId] = connectionPublisherCallback;
756
- }
757
- }
758
- handlePublisherRemove(connection) {
759
- for (const [, event] of connection.publishableEvents?.entries() ?? []) {
760
- const id = connection.id + event;
761
- const callback = this.publisherCallbacks[id];
762
- if (callback) connection.off(event, callback);
763
- }
764
- }
765
- };
766
-
767
- // src/event/bus/PubSubConnection.ts
768
- var EventBusPubSubConnection = class extends EventBusConnection {
769
- static {
770
- __name(this, "EventBusPubSubConnection");
771
- }
772
- publishableEvents;
773
- subscribableEvents;
774
- constructor(request) {
775
- super(request);
776
- if (request.type !== "PubSub") {
777
- throw new Error("Invalid connection type. Must be PubSub");
778
- }
779
- this.publishableEvents = request.publishableEvents;
780
- this.subscribableEvents = request.subscribableEvents;
781
- }
782
- };
783
-
784
- // src/event/connections/DappAccessRequest.ts
785
- var DappAccessRequestEvent = "dappAccessRequest";
786
- var dappAccessRequestConnectionRequest = {
787
- publishableEvents: [
788
- DappAccessRequestEvent
789
- ],
790
- type: "PubSub"
791
- };
792
- var dappAccessRequestConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(dappAccessRequestConnectionRequest), "dappAccessRequestConnection");
793
-
794
- // src/event/connections/DappsReady.ts
795
- var dappsReadyConnectionRequest = {
796
- publishableEvents: [
797
- "dappsReady"
798
- ],
799
- type: "PubSub"
800
- };
801
- var dappsReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(dappsReadyConnectionRequest), "dappsReadyConnection");
802
-
803
- // src/event/connections/ExposeDappRequest.ts
804
- var ExposeDappRequestEvent = "exposeDappRequest";
805
- var exposeDappConnectionRequest = {
806
- publishableEvents: [
807
- ExposeDappRequestEvent
808
- ],
809
- type: "PubSub"
810
- };
811
- var exposeDappRequestConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(exposeDappConnectionRequest), "exposeDappRequestConnection");
812
-
813
- // src/event/connections/OsPubSubNetworkReady.ts
814
- var OsPubSubNetworkReadyEvent = "osPubSubNetworkReady";
815
- var osPubSubNetworkConnectionRequest = {
816
- publishableEvents: [
817
- OsPubSubNetworkReadyEvent
818
- ],
819
- type: "PubSub"
820
- };
821
- var osPubSubNetworkReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest), "osPubSubNetworkReadyConnection");
822
-
823
- // src/event/connections/OsSettingsReady.ts
824
- var OsSettingsReadyEvent = "osSettingsReady";
825
- var osSettingsConnectionRequest = {
826
- publishableEvents: [
827
- OsSettingsReadyEvent
828
- ],
829
- type: "PubSub"
830
- };
831
- var osSettingsReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osSettingsConnectionRequest), "osSettingsReadyConnection");
832
-
833
- // src/event/connections/OsXyoPublicReady.ts
834
- var OsXyoPublicNetworkReadyEvent = "osXyoPublicNetworkReady";
835
- var osXyoPublicNetworkConnectionRequest = {
836
- publishableEvents: [
837
- OsXyoPublicNetworkReadyEvent
838
- ],
839
- type: "PubSub"
840
- };
841
- var osXyoPublicNetworkReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest), "osXyoPublicNetworkReadyConnection");
842
-
843
- // src/lib/initializeXns.ts
844
- import { asDivinerInstance as asDivinerInstance3 } from "@xyo-network/diviner-model";
845
- import { ResolveHelper } from "@xyo-network/module";
846
- import { NameRegistrarTransformer } from "@xyo-network/module-resolver";
847
- var initializeXns = /* @__PURE__ */ __name(async (xnsNode) => {
848
- if (ResolveHelper.transformers.length === 0) {
849
- const registrarDiviner = asDivinerInstance3(await xnsNode?.resolve("AddressRecords:AddressRecordIndexDiviner"));
850
- if (registrarDiviner) {
851
- const transformer = new NameRegistrarTransformer(registrarDiviner, "xyo");
852
- ResolveHelper.transformers = [
853
- transformer
854
- ];
855
- return true;
856
- }
857
- }
858
- return false;
859
- }, "initializeXns");
860
-
861
- // src/lib/isEqual.ts
862
- import { isObject } from "@xylabs/sdk-js";
863
- function isEqual(a, b) {
864
- if (a === b) return true;
865
- if (typeof a !== typeof b) return false;
866
- if (isObject(a) && isObject(b)) {
867
- const aRecord = a;
868
- const bRecord = b;
869
- const aKeys = Object.keys(aRecord);
870
- const bKeys = Object.keys(bRecord);
871
- if (aKeys.length !== bKeys.length) {
872
- return false;
873
- }
874
- for (const key of aKeys) {
875
- if (!Object.hasOwn(bRecord, key) || !isEqual(aRecord[key], bRecord[key])) {
876
- return false;
877
- }
878
- }
879
- return true;
880
- }
881
- if (Array.isArray(a) && Array.isArray(b)) {
882
- if (a.length !== b.length) {
883
- return false;
884
- }
885
- for (const [i, element] of a.entries()) {
886
- if (!isEqual(element, b[i])) {
887
- return false;
888
- }
889
- }
890
- return true;
891
- }
892
- return false;
893
- }
894
- __name(isEqual, "isEqual");
895
-
896
- // src/lib/isPayload.ts
897
- import { AsObjectFactory } from "@xylabs/sdk-js";
898
- var isObject2 = /* @__PURE__ */ __name((x) => {
899
- return typeof x === "object" && !Array.isArray(x);
900
- }, "isObject");
901
- var isAnyPayload = /* @__PURE__ */ __name((obj) => {
902
- if (isObject2(obj)) {
903
- return typeof obj.schema === "string";
904
- }
905
- return false;
906
- }, "isAnyPayload");
907
- var isPayload = /* @__PURE__ */ __name((schema) => (obj) => {
908
- if (isAnyPayload(obj)) {
909
- return schema.includes(obj.schema);
910
- }
911
- return false;
912
- }, "isPayload");
913
- var asPayload = /* @__PURE__ */ __name((schema) => AsObjectFactory.create(isPayload(schema)), "asPayload");
914
-
915
- // src/lib/ModuleNames.ts
916
- var DevelopArchivist = "DevelopArchivist";
917
- var NodeSentinel = "NodeSentinel";
918
-
919
- // src/lib/ModuleAccountPaths.ts
920
- var RemoteNodeArchivistOffsetPaths = {
921
- Kerplunk: {
922
- [DevelopArchivist]: "118"
923
- },
924
- Local: {
925
- [DevelopArchivist]: "115"
926
- },
927
- Main: {
928
- [DevelopArchivist]: "121"
929
- }
930
- };
931
- var ModuleOffsetPaths = {
932
- IdWitness: "1",
933
- DomainWitness: "2",
934
- LocationWitness: "3",
935
- SchemaWitness: "4",
936
- CryptoCardsGameWitness: "5",
937
- CryptoCardsMoveWitness: "6",
938
- EthereumGasEtherchainV2Witness: "7",
939
- CoingeckoCryptoMarketWitness: "8",
940
- UniswapCryptoMarketWitness: "9",
941
- EthereumGasEtherscanWitness: "10",
942
- [NodeSentinel]: "11",
943
- [DevelopArchivist]: "12",
944
- BowserSystemInfoPluginWitness: "13"
945
- };
946
-
947
- // src/lib/NameTransforms.ts
948
- var NameTransforms = class _NameTransforms {
949
- static {
950
- __name(this, "NameTransforms");
951
- }
952
- value;
953
- constructor(value) {
954
- this.value = value;
955
- }
956
- static deSlug(value) {
957
- return value.replaceAll("-", " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
958
- }
959
- static moduleName(value) {
960
- return value.replaceAll(" ", "");
961
- }
962
- static slug(value) {
963
- return value.replaceAll(" ", "-").toLocaleLowerCase();
964
- }
965
- deSlug() {
966
- return _NameTransforms.deSlug(this.value);
967
- }
968
- moduleName() {
969
- return _NameTransforms.moduleName(this.value);
970
- }
971
- slug() {
972
- return _NameTransforms.slug(this.value);
973
- }
974
- };
975
-
976
- // src/lib/PayloadStore.ts
977
- var PayloadStore = class {
978
- static {
979
- __name(this, "PayloadStore");
980
- }
981
- latest = [];
982
- archivist;
983
- deleteListeners = [];
984
- insertListeners = [];
985
- listeners = [];
986
- constructor(archivist) {
987
- this.archivist = archivist;
988
- }
989
- /**
990
- * Initialize listeners on the archivist that update class member variables when new payloads are inserted
991
- */
992
- static async create({ archivist, getLatest, idFunction }) {
993
- const instance = new this(archivist);
994
- const insertListener = /* @__PURE__ */ __name(async ({ payloads }) => {
995
- if (payloads.some(idFunction)) {
996
- const latest = await getLatest();
997
- if (isEqual(latest, instance.latest)) return;
998
- instance.latest = latest;
999
- instance.emitChange();
1000
- }
1001
- }, "insertListener");
1002
- const deleteListener = /* @__PURE__ */ __name(async () => {
1003
- instance.latest = await getLatest();
1004
- instance.emitChange();
1005
- }, "deleteListener");
1006
- const weakRefInsertListener = new WeakRef(insertListener);
1007
- const weakRefDeleteListener = new WeakRef(deleteListener);
1008
- const insertListenerRef = weakRefInsertListener.deref();
1009
- const deleteListenerRef = weakRefDeleteListener.deref();
1010
- if (insertListenerRef) instance.archivist.on("inserted", insertListenerRef);
1011
- if (deleteListenerRef) instance.archivist.on("deleted", deleteListenerRef);
1012
- instance.insertListeners.push(weakRefInsertListener);
1013
- instance.deleteListeners.push(weakRefDeleteListener);
1014
- instance.latest = await getLatest();
1015
- return instance;
1016
- }
1017
- /**
1018
- * Remove all listeners and reset their class members
1019
- */
1020
- cleanupListeners() {
1021
- this.removeListeners(this.insertListeners, "inserted");
1022
- this.removeListeners(this.deleteListeners, "deleted");
1023
- this.insertListeners = [];
1024
- this.deleteListeners = [];
1025
- }
1026
- /**
1027
- * Get the current value of the store
1028
- */
1029
- getSnapshot() {
1030
- return this.latest;
1031
- }
1032
- /**
1033
- * Add a call back function that is invoked when new Payloads are inserted
1034
- * @param onStoreChange
1035
- */
1036
- subscribe(onStoreChange) {
1037
- this.listeners.push(onStoreChange);
1038
- return () => {
1039
- this.listeners = this.listeners.filter((l) => l !== onStoreChange);
1040
- };
1041
- }
1042
- emitChange() {
1043
- for (const listener of this.listeners) {
1044
- listener();
1045
- }
1046
- }
1047
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1048
- removeListeners(listeners, eventName) {
1049
- for (const listener of listeners) {
1050
- const listenerRef = listener.deref();
1051
- if (listenerRef) this.archivist.off(eventName, listenerRef);
1052
- }
1053
- }
1054
- };
1055
-
1056
- // src/lib/tokenPlacesSplit.ts
1057
- import { assertEx as assertEx6 } from "@xylabs/sdk-js";
1058
- var tokenPlacesSplit = /* @__PURE__ */ __name((value, places) => {
1059
- assertEx6(places >= 0, () => "Places has to be >= 0");
1060
- const factor = BigInt(10 ** Math.abs(places));
1061
- const remainder = value % factor;
1062
- const wholeValue = value / factor;
1063
- return [
1064
- wholeValue,
1065
- remainder
1066
- ];
1067
- }, "tokenPlacesSplit");
1068
- var tokenPlacesSplitString = /* @__PURE__ */ __name((value, places) => {
1069
- if (value === void 0) {
1070
- return "-";
1071
- }
1072
- const [wholeValue, remainder] = tokenPlacesSplit(value, places);
1073
- return `${wholeValue}.${remainder.toString().padStart(Math.abs(places), "0")}`;
1074
- }, "tokenPlacesSplitString");
1075
-
1076
- // src/loadOsNode.ts
1077
- import { IndexedDbArchivist } from "@xyo-network/archivist-indexeddb";
1078
- import { IndexedDbPayloadDiviner } from "@xyo-network/diviner-payload-indexeddb";
1079
- import { ManifestWrapper, ModuleFactoryLocator as ModuleFactoryLocator3 } from "@xyo-network/sdk-js";
1080
- var OS_NODE_PATH = "1'";
1081
- var getDefaultOsNodeLocator = /* @__PURE__ */ __name(() => {
1082
- const locator = new ModuleFactoryLocator3();
1083
- locator.register(IndexedDbArchivist.factory(), {
1084
- "network.xyo.archivist.persistence.scope": "device"
1085
- });
1086
- locator.register(IndexedDbPayloadDiviner.factory(), {
1087
- "network.xyo.archivist.persistence.scope": "device"
1088
- });
1089
- return locator;
1090
- }, "getDefaultOsNodeLocator");
1091
- var loadOsNode = /* @__PURE__ */ __name(async (osWallet, locator) => {
1092
- try {
1093
- const osNodeWallet = await osWallet.derivePath(OS_NODE_PATH);
1094
- const osNodeLocator = locator ?? getDefaultOsNodeLocator();
1095
- const manifestWrapper = new ManifestWrapper(os_node_manifest_default, osNodeWallet, osNodeLocator);
1096
- const osNode = (await manifestWrapper.loadNodes())[0];
1097
- return [
1098
- osNode
1099
- ];
1100
- } catch (e) {
1101
- const error = e;
1102
- console.error(`Error creating os node: ${error.message}`);
1103
- console.error(`Error creating os node: ${error.stack}`);
1104
- throw new Error(`Error creating os node: ${error.message}`, {
1105
- cause: e
1106
- });
1107
- }
1108
- }, "loadOsNode");
1109
-
1110
- // src/registration/DappRegistrationService.ts
1111
- import { forget as forget2, fulfilled, rejected } from "@xylabs/sdk-js";
1112
- import { DappIntentTypes, DappMode as DappMode2, isRegisteredDappAccessDappSet, isRegisteredDappExposedDappSet } from "@xyo-network/os-model";
1113
- import { ModuleFactoryLocator as ModuleFactoryLocator7 } from "@xyo-network/sdk-js";
1114
-
1115
- // src/intent/Caller.ts
1116
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema2 } from "@xyo-network/diviner-payload-model";
1117
- import { DappIntentSchema, DappMode } from "@xyo-network/os-model";
1118
- var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
1119
- static {
1120
- __name(this, "DappIntentCaller");
1121
- }
1122
- static OsDappName = "XyOs";
1123
- constructor(context) {
1124
- super(context);
1125
- }
1126
- /**
1127
- * Build a new intent
1128
- * @param sourceDappId
1129
- * @param intent
1130
- * @param targetDappId
1131
- * @param targetMode
1132
- * @param params?
1133
- * @returns DappIntent
1134
- */
1135
- static buildIntent(sourceDappId, intent, targetDappId, targetMode = DappMode.Window, params) {
1136
- return {
1137
- intent,
1138
- params: params ?? "",
1139
- schema: DappIntentSchema,
1140
- sourceDappId,
1141
- targetDappId,
1142
- targetMode: targetMode ?? DappMode.Window,
1143
- timestamp: Date.now()
1144
- };
1145
- }
1146
- // Add a new intent
1147
- async addIntent(id, intent, mode) {
1148
- const intentArchivist = await this.getDappIntentArchivist();
1149
- const newIntent = _DappIntentCaller.buildIntent(id, intent, mode);
1150
- await intentArchivist.insert([
1151
- newIntent
1152
- ]);
1153
- }
1154
- // Get all intents
1155
- async allIntents() {
1156
- const archivist = await this.getDappIntentArchivist();
1157
- return await archivist.all();
1158
- }
1159
- // Get the latest intent saved to the archivist
1160
- async latestIntent() {
1161
- const archivist = await this.getDappIntentArchivist();
1162
- return (await archivist.all()).at(-1);
1163
- }
1164
- // Get the latest intent for a dapp
1165
- async latestIntentForDappName(dappName) {
1166
- const diviner = await this.getDappIntentArchivistPayloadDiviner();
1167
- const query = {
1168
- limit: 1,
1169
- order: "desc",
1170
- schema: PayloadDivinerQuerySchema2,
1171
- sourceDappId: dappName
1172
- };
1173
- return await diviner.divine([
1174
- query
1175
- ]);
1176
- }
1177
- };
1178
-
1179
- // src/intent/Resource.ts
1180
- import { assertEx as assertEx7 } from "@xylabs/sdk-js";
1181
- import { isDappIntent } from "@xyo-network/os-model";
1182
- var NO_RESULTS = [];
1183
- var DappIntentResource = class extends DappCallerBase {
1184
- static {
1185
- __name(this, "DappIntentResource");
1186
- }
1187
- _allDappIntents;
1188
- _latestDappIntent;
1189
- constructor(context) {
1190
- super(context);
1191
- }
1192
- get allDappIntents() {
1193
- return assertEx7(this._allDappIntents, () => "allDappIntents not set");
1194
- }
1195
- get latestDappIntent() {
1196
- return assertEx7(this._latestDappIntent, () => "latestDappIntent not set");
1197
- }
1198
- get subscriptions() {
1199
- return {
1200
- allDappIntents: /* @__PURE__ */ __name((cb) => this.allDappIntents.subscribe(cb), "allDappIntents"),
1201
- latestDappIntent: /* @__PURE__ */ __name((cb) => this.latestDappIntent.subscribe(cb), "latestDappIntent")
1202
- };
1203
- }
1204
- get views() {
1205
- return {
1206
- allDappIntents: /* @__PURE__ */ __name(() => this.allDappIntents.getSnapshot(), "allDappIntents"),
1207
- latestDappIntent: /* @__PURE__ */ __name(() => this.latestDappIntent.getSnapshot(), "latestDappIntent")
1208
- };
1209
- }
1210
- cleanupListeners() {
1211
- this.latestDappIntent.cleanupListeners();
1212
- this.allDappIntents.cleanupListeners();
1213
- }
1214
- async start() {
1215
- const archivist = await this.getDappIntentArchivist();
1216
- this._allDappIntents = await PayloadStore.create({
1217
- archivist,
1218
- getLatest: /* @__PURE__ */ __name(async () => await archivist.all(), "getLatest"),
1219
- idFunction: isDappIntent
1220
- });
1221
- this._latestDappIntent = await PayloadStore.create({
1222
- archivist,
1223
- getLatest: /* @__PURE__ */ __name(async () => {
1224
- const all = await archivist.all();
1225
- const result = all.length > 0 ? [
1226
- all.at(-1)
1227
- ] : NO_RESULTS;
1228
- return result;
1229
- }, "getLatest"),
1230
- idFunction: isDappIntent
1231
- });
1232
- }
1233
- };
1234
-
1235
- // src/system/ManageSystemDapps.ts
1236
- import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
1237
- import semver from "semver";
1238
-
1239
- // src/system/Queries.ts
1240
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema3 } from "@xyo-network/diviner-payload-model";
1241
- import { DappConfigSchema, DappIconSchema, DappWidgetConfigSchema, UnregisteredDappAccessSchema } from "@xyo-network/os-model";
1242
- import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
1243
- var SystemDappQueries = {
1244
- async getDappAccess(diviner, name, version) {
1245
- const accessQuery = {
1246
- order: "desc",
1247
- registeringDappId: name,
1248
- schema: PayloadDivinerQuerySchema3,
1249
- schemas: [
1250
- UnregisteredDappAccessSchema
1251
- ],
1252
- version
1253
- };
1254
- return await diviner.divine([
1255
- accessQuery
1256
- ]);
1257
- },
1258
- async getLatestConfig(diviner, name) {
1259
- const configQuery = {
1260
- limit: 1,
1261
- name,
1262
- order: "desc",
1263
- schema: PayloadDivinerQuerySchema3,
1264
- schemas: [
1265
- DappConfigSchema
1266
- ]
1267
- };
1268
- const [dappConfig] = await diviner.divine([
1269
- configQuery
1270
- ]);
1271
- return dappConfig;
1272
- },
1273
- async getLatestIcon(diviner, name, version) {
1274
- const iconQuery = {
1275
- name,
1276
- order: "desc",
1277
- schema: PayloadDivinerQuerySchema3,
1278
- schemas: [
1279
- DappIconSchema
1280
- ],
1281
- version
1282
- };
1283
- const [dappIcon] = await diviner.divine([
1284
- iconQuery
1285
- ]);
1286
- return dappIcon;
1287
- },
1288
- async getWidgetConfigs(diviner, name, version) {
1289
- const widgetConfigQuery = {
1290
- dappId: name,
1291
- order: "desc",
1292
- schema: PayloadDivinerQuerySchema3,
1293
- schemas: [
1294
- DappWidgetConfigSchema
1295
- ],
1296
- version
1297
- };
1298
- const widgetConfigs = await diviner.divine([
1299
- widgetConfigQuery
1300
- ]);
1301
- const uniqueConfigs = {};
1302
- for (const widgetConfig of widgetConfigs) {
1303
- const hash = await PayloadBuilder3.dataHash(widgetConfig);
1304
- uniqueConfigs[widgetConfig.mode ?? hash] = widgetConfig;
1305
- }
1306
- return Object.values(uniqueConfigs);
1307
- }
1308
- };
1309
-
1310
- // src/system/ManageSystemDapps.ts
1311
- var ManageSystemDapps = class extends OsCallerBase {
1312
- static {
1313
- __name(this, "ManageSystemDapps");
1314
- }
1315
- defaultSystemDappParams;
1316
- defaultSystemDapps;
1317
- defaultSystemNames;
1318
- developmentMode;
1319
- locator;
1320
- onErrorCallbacks = [];
1321
- constructor(context, defaultSystemNames, defaultSystemDapps, defaultSystemDappParams, locator, developmentMode) {
1322
- super(context);
1323
- this.defaultSystemNames = defaultSystemNames;
1324
- this.defaultSystemDapps = defaultSystemDapps;
1325
- this.defaultSystemDappParams = defaultSystemDappParams;
1326
- this.locator = locator;
1327
- this.developmentMode = developmentMode;
1328
- }
1329
- /**
1330
- * Add a callback to listen for errors throwing during system dapp registration
1331
- * @param errorListener
1332
- */
1333
- addErrorListener(errorListener) {
1334
- this.onErrorCallbacks.push(errorListener);
1335
- }
1336
- /**
1337
- * Installs the dapps into the OS and builds the appropriate DappSet
1338
- */
1339
- async install() {
1340
- await this.insertPayloads();
1341
- return await this.latestSets();
1342
- }
1343
- async freshInstall(archivist) {
1344
- await archivist.insert(this.defaultSystemDapps);
1345
- }
1346
- async insertPayloads() {
1347
- const archivist = this.developmentMode ? await this.getDappsArchivistDevelopment() : await this.getDappsArchivist();
1348
- try {
1349
- const allPayloads = await archivist.all();
1350
- if (allPayloads.length === 0) {
1351
- await this.freshInstall(archivist);
1352
- return true;
1353
- }
1354
- for (const systemDappPayload of this.defaultSystemDapps) {
1355
- try {
1356
- const validSemver = semver.valid(systemDappPayload.version);
1357
- if (!validSemver) throw new Error("semver is a valid type (string) but was not able to be parsed");
1358
- } catch (e) {
1359
- console.error(`${systemDappPayload.version} does not appear to be a valid semver value`, e);
1360
- continue;
1361
- }
1362
- const [existing] = await archivist.get([
1363
- await PayloadBuilder4.dataHash(systemDappPayload)
1364
- ]);
1365
- if (existing) continue;
1366
- await archivist.insert([
1367
- systemDappPayload
1368
- ]);
1369
- }
1370
- return true;
1371
- } catch (e) {
1372
- console.error("error installing system dapps");
1373
- throw e;
1374
- }
1375
- }
1376
- async latestSets() {
1377
- const diviner = this.developmentMode ? await this.getDappsArchivistPayloadDivinerDevelopment() : await this.getDappsArchivistPayloadDiviner();
1378
- const dappSets = [];
1379
- const failedPayloads = [];
1380
- for (const name of this.defaultSystemNames) {
1381
- try {
1382
- const dappConfig = await SystemDappQueries.getLatestConfig(diviner, name);
1383
- if (!dappConfig) {
1384
- console.error(`No config found for dapp ${name}`);
1385
- continue;
1386
- }
1387
- const dappIcon = await SystemDappQueries.getLatestIcon(diviner, name, dappConfig.version);
1388
- if (!dappIcon) {
1389
- console.error(`No icon found for dapp ${dappConfig.name}`);
1390
- failedPayloads.push(dappConfig);
1391
- continue;
1392
- }
1393
- const dappAccess = await SystemDappQueries.getDappAccess(diviner, name, dappConfig.version);
1394
- const dappParams = this.defaultSystemDappParams[dappConfig.name];
1395
- if (!dappParams) {
1396
- console.error(`No params found for dapp ${dappConfig.name}. Did you forget to add it to OsDappParams?`);
1397
- failedPayloads.push(dappConfig);
1398
- continue;
1399
- }
1400
- const dappWidgetConfigs = await SystemDappQueries.getWidgetConfigs(diviner, name, dappConfig.version);
1401
- dappSets.push({
1402
- dapp: {
1403
- accessors: dappAccess,
1404
- config: dappConfig,
1405
- icon: dappIcon,
1406
- params: dappParams,
1407
- widgetConfigs: dappWidgetConfigs
1408
- }
1409
- });
1410
- } catch {
1411
- console.error(`Failed to build dapp ${name}`);
1412
- }
1413
- }
1414
- if (failedPayloads.length > 0) {
1415
- for (const cb of this.onErrorCallbacks) cb(failedPayloads);
1416
- }
1417
- return dappSets;
1418
- }
1419
- };
1420
-
1421
- // src/XyOsDapp.ts
1422
- import { assertEx as assertEx9 } from "@xylabs/sdk-js";
1423
- import { DappPackageManifestPayloadSchema as DappPackageManifestPayloadSchema2 } from "@xyo-network/os-model";
1424
- import { ManifestWrapper as ManifestWrapper2, ModuleFactoryLocator as ModuleFactoryLocator5 } from "@xyo-network/sdk-js";
1425
-
1426
- // src/manifests/dapp-window.manifest.json
1427
- var dapp_window_manifest_default = {
1428
- $schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json",
1429
- nodes: [
1430
- {
1431
- config: {
1432
- accountPath: "0'",
1433
- name: "Dapp",
1434
- schema: "network.xyo.node.config"
1435
- },
1436
- modules: {
1437
- private: [],
1438
- public: [
1439
- {
1440
- config: {
1441
- accountPath: "0'/0'",
1442
- name: "DappArchivist",
1443
- schema: "network.xyo.archivist.memory.config"
1444
- }
1445
- },
1446
- {
1447
- config: {
1448
- accountPath: "0'/1'",
1449
- archivist: "DappArchivist",
1450
- labels: {
1451
- "network.xyo.generic.payload.diviner": "GenericPayloadDiviner"
1452
- },
1453
- name: "DappArchivistPayloadDiviner",
1454
- schema: "network.xyo.diviner.payload.generic.config"
1455
- }
1456
- }
1457
- ]
1458
- }
1459
- }
1460
- ],
1461
- schema: "network.xyo.manifest.package.dapp"
1462
- };
1463
-
1464
- // src/XyOsBase.ts
1465
- import { assertEx as assertEx8, BaseEmitter as BaseEmitter2 } from "@xylabs/sdk-js";
1466
- import { ModuleFactoryLocator as ModuleFactoryLocator4 } from "@xyo-network/sdk-js";
1467
- import { Mutex as Mutex2 } from "async-mutex";
1468
- var XyOsContextBase = class extends BaseEmitter2 {
1469
- static {
1470
- __name(this, "XyOsContextBase");
1471
- }
1472
- _bootMutex = new Mutex2();
1473
- _platformLocator;
1474
- _root;
1475
- get bios() {
1476
- return this.kernel?.bios;
1477
- }
1478
- get eventBus() {
1479
- return assertEx8(this.params.eventBus, () => "Missing event bus");
1480
- }
1481
- get exposedNode() {
1482
- throw new Error("Method not implemented. [exposedNode]");
1483
- }
1484
- get exposedNodeOuter() {
1485
- throw new Error("Method not implemented. [exposedNodeOuter]");
1486
- }
1487
- get installedDapps() {
1488
- return [];
1489
- }
1490
- get kernel() {
1491
- return void 0;
1492
- }
1493
- get manifest() {
1494
- return assertEx8(this.params.manifest, () => "Missing manifest");
1495
- }
1496
- get platformLocator() {
1497
- this._platformLocator = this._platformLocator ?? this.params.platformLocator ?? new ModuleFactoryLocator4();
1498
- return this._platformLocator;
1499
- }
1500
- get possibleRoot() {
1501
- return this._root;
1502
- }
1503
- get root() {
1504
- return assertEx8(this._root, () => "XyOs root not set (probably not yet booted)");
1505
- }
1506
- get runningDapps() {
1507
- return [];
1508
- }
1509
- get signerPaths() {
1510
- return this.params.signerPaths;
1511
- }
1512
- get state() {
1513
- return this._root ? "running" : "stopped";
1514
- }
1515
- get user() {
1516
- throw new Error("Method not implemented. [user]");
1517
- }
1518
- boot(_wallet, _locator) {
1519
- throw new Error("Method not implemented. [boot]");
1520
- }
1521
- buildDapp(_manifest, _dappId) {
1522
- throw new Error("Method not implemented. [buildDapp]");
1523
- }
1524
- dappByName(_dappId) {
1525
- throw new Error("Method not implemented. [runningDapp]");
1526
- }
1527
- getDappParams(_dappId) {
1528
- throw new Error("Method not implemented. [getDappParams]");
1529
- }
1530
- getStack(_stackName) {
1531
- throw new Error("Method not implemented. [getStack]");
1532
- }
1533
- installDapp(_dappId) {
1534
- throw new Error("Method not implemented. [installDapp]");
1535
- }
1536
- monitor(_fn, _eventConfig) {
1537
- throw new Error("Method not implemented. [monitor]");
1538
- }
1539
- shutdown() {
1540
- throw new Error("Method not implemented. [shutdown]");
1541
- }
1542
- startDapp(_dappId) {
1543
- throw new Error("Method not implemented. [startDapp]");
1544
- }
1545
- stopDapp(_dappId) {
1546
- throw new Error("Method not implemented. [stopDapp]");
1547
- }
1548
- uninstallDapp(_dappId) {
1549
- throw new Error("Method not implemented. [uninstallDapp]");
1550
- }
1551
- };
1552
-
1553
- // src/XyOsDapp.ts
1554
- var XyOsDapp = class extends XyOsContextBase {
1555
- static {
1556
- __name(this, "XyOsDapp");
1557
- }
1558
- dapp;
1559
- constructor(params) {
1560
- super(params);
1561
- this.dapp = {
1562
- ...params.dapp
1563
- };
1564
- }
1565
- get eventBus() {
1566
- return this.parent.eventBus;
1567
- }
1568
- get exposedNode() {
1569
- return this.parent.exposedNode;
1570
- }
1571
- get exposedNodeOuter() {
1572
- return this.parent.exposedNodeOuter;
1573
- }
1574
- /**
1575
- * @deprecated Dapps should not have access to the bios. This is done for the
1576
- * settings dapp, but should be refactored out. Bios could possibly be an
1577
- * optional property of the parent context passed in for dapps that require
1578
- * elevated permissions.
1579
- * ^^^ I believe we may want this here in that is a dApp requests access to the bios it will optionally be there
1580
- */
1581
- get kernel() {
1582
- return assertEx9(this.parent.kernel, () => "Missing kernel");
1583
- }
1584
- get parent() {
1585
- return this.params.parent;
1586
- }
1587
- get stacks() {
1588
- return [];
1589
- }
1590
- get user() {
1591
- return this.params.user;
1592
- }
1593
- async boot(wallet, locator) {
1594
- return await this._bootMutex.runExclusive(async () => {
1595
- console.log("XyOsDapp:boot:start", wallet.address, this.dapp.id);
1596
- assertEx9(this._root === void 0, () => "Dapp already booted");
1597
- const finalLocator = locator ? (this.params.locator ?? new ModuleFactoryLocator5()).merge(locator) : this.params.locator ?? new ModuleFactoryLocator5();
1598
- console.log("XyOsDapp:boot:finalLocator", finalLocator);
1599
- const dappNodesWrapper = new ManifestWrapper2({
1600
- ...this.manifest,
1601
- schema: DappPackageManifestPayloadSchema2
1602
- }, wallet, finalLocator);
1603
- const dappNodes = await dappNodesWrapper.loadNodes();
1604
- const manifest = dapp_window_manifest_default;
1605
- const dappManifestWallet = await wallet.derivePath("99999");
1606
- manifest.nodes[0].config.name = this.dapp.name + "Root";
1607
- const wrapper = new ManifestWrapper2({
1608
- ...manifest,
1609
- schema: DappPackageManifestPayloadSchema2
1610
- }, dappManifestWallet, finalLocator);
1611
- const node = await wrapper.loadNodeFromIndex(0);
1612
- for (const dappNode of dappNodes) {
1613
- await node.register(dappNode);
1614
- await node.attach(dappNode.address, true);
1615
- }
1616
- this._root = node;
1617
- console.log("XyOsDapp:boot:finish", wallet.address, this.dapp.id);
1618
- return this;
1619
- });
1620
- }
1621
- getStack(stackName) {
1622
- return this.parent.getStack(stackName);
1623
- }
1624
- };
1625
-
1626
- // src/registration/DappRegistry.ts
1627
- import { DappRegisteredSchema, DappRegisteredState, isRegisteredDappAccess } from "@xyo-network/os-model";
1628
- import { HDWallet as HDWallet4 } from "@xyo-network/sdk-js";
1629
-
1630
- // src/registration/ValidateDappAccessDiviner/Config.ts
1631
- import { asSchema as asSchema2, isPayloadOfSchemaType } from "@xyo-network/payload-model";
1632
- var FailedAccessorSchema = asSchema2("network.xyo.os.failed.accessor.registration", true);
1633
- var isFailedAccessor = isPayloadOfSchemaType(FailedAccessorSchema);
1634
- var ValidateDappAccessDivinerConfigSchema = asSchema2("network.xyo.os.dapp.access.registration.validate", true);
1635
-
1636
- // src/registration/ValidateDappAccessDiviner/Diviner.ts
1637
- import { AbstractDiviner } from "@xyo-network/diviner-abstract";
1638
- import { isDappPackageManifestPayload, isUnregisteredDappAccess, RegisteredDappAccessSchema } from "@xyo-network/os-model";
1639
- import { HDWallet as HDWallet3, ManifestWrapper as ManifestWrapper3, ModuleFactoryLocator as ModuleFactoryLocator6, PackageManifestPayloadSchema } from "@xyo-network/sdk-js";
1640
-
1641
- // src/models/access/ValidDappAccessInterfaces.ts
1642
- import { RegisteredNames, RegisteredNamesInterface } from "@xyo-network/os-model";
1643
- var ValidDappAccessInterfaces = {
1644
- [RegisteredNames]: RegisteredNamesInterface
1645
- };
1646
-
1647
- // src/registration/ValidateDappAccessDiviner/Diviner.ts
1648
- var ValidateDappAccessDiviner = class extends AbstractDiviner {
1649
- static {
1650
- __name(this, "ValidateDappAccessDiviner");
1651
- }
1652
- static configSchemas = [
1653
- ValidateDappAccessDivinerConfigSchema
1654
- ];
1655
- async divineHandler(payloads) {
1656
- const dappManifest = payloads?.filter(isDappPackageManifestPayload) ?? [];
1657
- const accessors = payloads?.filter(isUnregisteredDappAccess) ?? [];
1658
- const dappParams = this.params.dappParams;
1659
- if (dappManifest.length > 1) {
1660
- throw new Error("Only one dapp manifest payload is allowed");
1661
- }
1662
- if (dappManifest.length === 0 || accessors.length === 0) {
1663
- return [];
1664
- }
1665
- const registeredAccessors = [];
1666
- const failedAccessors = [];
1667
- for (const access of accessors) {
1668
- try {
1669
- if (access) {
1670
- const dappAccessInterface = ValidDappAccessInterfaces[access.name];
1671
- if (!dappAccessInterface) {
1672
- console.warn("Invalid dapp access interface", access.name);
1673
- continue;
1674
- }
1675
- const dappManifestToTest = dappPackageManifestToPackageManifest(dappManifest[0]);
1676
- const dappChildren = await getNodeChildren(dappManifestToTest, dappParams);
1677
- const interfaceChildren = await getNodeChildren(dappAccessInterface.manifest, dappParams);
1678
- const valid = compareChildren(interfaceChildren, dappChildren);
1679
- if (valid) {
1680
- const payload = {
1681
- ...access,
1682
- schema: RegisteredDappAccessSchema,
1683
- timestamp: Date.now()
1684
- };
1685
- registeredAccessors.push(payload);
1686
- } else {
1687
- const failedRegistration = {
1688
- accessor: access,
1689
- errorMessage: "Invalid dapp access interface",
1690
- schema: FailedAccessorSchema
1691
- };
1692
- failedAccessors.push(failedRegistration);
1693
- }
1694
- }
1695
- } catch (e) {
1696
- failedAccessors.push({
1697
- accessor: access,
1698
- errorMessage: e.message,
1699
- schema: FailedAccessorSchema
1700
- });
1701
- }
1702
- }
1703
- return [
1704
- ...registeredAccessors,
1705
- ...failedAccessors
1706
- ];
1707
- }
1708
- };
1709
- var compareChildren = /* @__PURE__ */ __name((interfaceChildren, dappChildren) => {
1710
- return interfaceChildren.every((interfaceChild) => Object.values(interfaceChild).every((interfaceChildName) => dappChildren.some((dappChild) => Object.values(dappChild).includes(interfaceChildName))));
1711
- }, "compareChildren");
1712
- var dappPackageManifestToPackageManifest = /* @__PURE__ */ __name((dappPackageManifest) => {
1713
- return {
1714
- ...dappPackageManifest,
1715
- schema: PackageManifestPayloadSchema
1716
- };
1717
- }, "dappPackageManifestToPackageManifest");
1718
- var getChildrenFromNode = /* @__PURE__ */ __name(async (node) => {
1719
- const nodeManifest = (await node.state())?.[0];
1720
- return nodeManifest.status?.children;
1721
- }, "getChildrenFromNode");
1722
- var getNodeChildren = /* @__PURE__ */ __name(async (manifestToTest, dappParams) => {
1723
- const testNodes = await getNodeToTest(manifestToTest, dappParams);
1724
- const children = [];
1725
- for (const node of testNodes) {
1726
- const nodeChildren = await getChildrenFromNode(node);
1727
- if (nodeChildren) {
1728
- children.push(nodeChildren);
1729
- }
1730
- }
1731
- return children;
1732
- }, "getNodeChildren");
1733
- var getNodeToTest = /* @__PURE__ */ __name(async (manifestToTest, dappParams) => {
1734
- const dappManifestWrapper = new ManifestWrapper3(manifestToTest, await HDWallet3.random(), dappParams.locator ?? new ModuleFactoryLocator6());
1735
- return await dappManifestWrapper.loadNodes();
1736
- }, "getNodeToTest");
1737
-
1738
- // src/registration/DappRegistry.ts
1739
- var DappRegistry = class {
1740
- static {
1741
- __name(this, "DappRegistry");
1742
- }
1743
- dappRegistry = /* @__PURE__ */ new Map();
1744
- dappSeedPhraseRepository;
1745
- constructor(dappSeedPhraseRepository) {
1746
- this.dappSeedPhraseRepository = dappSeedPhraseRepository;
1747
- }
1748
- /**
1749
- * Register a Dapp with window manager and if successful, return its id
1750
- * @param dapp Manifest and UI of the Dapp to register
1751
- * @returns dapp with registration fields
1752
- */
1753
- async registerDapp(dapp) {
1754
- if (dapp) {
1755
- const { exposedModuleIds, manifest, modes, name, version, params, widgetConfigs } = this.extractDappProperties(dapp);
1756
- try {
1757
- const walletId = await this.dappSeedPhraseRepository.findOrCreate(name);
1758
- const registeredAccessors = await this.validateDappAccessPayloads(manifest, dapp.accessors, params);
1759
- const registeredDapp = {
1760
- accessors: registeredAccessors,
1761
- config: {
1762
- exposedModuleIds,
1763
- manifest,
1764
- modes,
1765
- name,
1766
- schema: DappRegisteredSchema,
1767
- state: DappRegisteredState.Registered,
1768
- version,
1769
- // attach the walletId to a registered dapp so it can request it back in the future
1770
- walletId
1771
- },
1772
- params,
1773
- widgetConfigs
1774
- };
1775
- if (this.dappRegistry.get(name)) {
1776
- console.warn("tried to register two dapps with the same name", name);
1777
- return null;
1778
- }
1779
- this.dappRegistry.set(name, registeredDapp);
1780
- return registeredDapp;
1781
- } catch (e) {
1782
- console.error("Error registeringDapp", e);
1783
- return null;
1784
- }
1785
- } else {
1786
- return null;
1787
- }
1788
- }
1789
- /**
1790
- * Unregister a dapp so it can no longer be launched
1791
- * @param dappId
1792
- */
1793
- unregisterDapp(dappId) {
1794
- this.dappRegistry.delete(dappId);
1795
- }
1796
- extractDappProperties(dapp) {
1797
- const { params, config, widgetConfigs } = dapp;
1798
- const { exposedModuleIds, manifest, modes, name, sources, version } = config;
1799
- return {
1800
- exposedModuleIds,
1801
- manifest,
1802
- modes,
1803
- name,
1804
- params,
1805
- sources,
1806
- version,
1807
- widgetConfigs
1808
- };
1809
- }
1810
- async validateDappAccessPayloads(manifest, accessors = [], params) {
1811
- const validateDappAccess = await ValidateDappAccessDiviner.create({
1812
- account: await HDWallet4.random(),
1813
- config: {
1814
- schema: ValidateDappAccessDivinerConfigSchema
1815
- },
1816
- dappParams: params
1817
- });
1818
- const payloads = await validateDappAccess.divine([
1819
- manifest,
1820
- ...accessors
1821
- ]);
1822
- const failedAccessors = payloads.filter(isFailedAccessor);
1823
- const registeredAccessors = payloads.filter(isRegisteredDappAccess);
1824
- if (failedAccessors.length > 0) {
1825
- console.error("Failed to register all dapp accessors", failedAccessors);
1826
- }
1827
- return registeredAccessors;
1828
- }
1829
- };
1830
-
1831
- // src/registration/DappRegistrationService.ts
1832
- var DappRegistrationService = class {
1833
- static {
1834
- __name(this, "DappRegistrationService");
1835
- }
1836
- // Dapps that have been built with their own context
1837
- builtDapps = {};
1838
- dappRegistry;
1839
- dappSeedPhraseRepository;
1840
- manageSystemDapps;
1841
- // Dapps that have been registered with dappAccessRequests
1842
- registeredAccessDappSets = /* @__PURE__ */ new Set();
1843
- // Dapps that have been registered with the dapp registry
1844
- registeredDappSets = /* @__PURE__ */ new Set();
1845
- // Dapps that have been registered with exposeDappRequests
1846
- registeredExposedDappSets = /* @__PURE__ */ new Set();
1847
- context;
1848
- dappAccessRequestConnection = dappAccessRequestConnection();
1849
- developmentMode;
1850
- exposeDappRequestConnection = exposeDappRequestConnection();
1851
- locator;
1852
- params;
1853
- constructor(context, params, locator = new ModuleFactoryLocator7(), developmentMode) {
1854
- this.context = context;
1855
- this.params = params ?? {
1856
- dappNames: [],
1857
- dappParams: {},
1858
- dappPayloads: []
1859
- };
1860
- this.locator = locator;
1861
- this.developmentMode = developmentMode;
1862
- this.manageSystemDapps = new ManageSystemDapps(context, this.params?.dappNames ?? [], this.params?.dappPayloads ?? [], this.params?.dappParams ?? {}, this.locator, this.developmentMode);
1863
- this.dappSeedPhraseRepository = new DappSeedPhraseRepository(context, this.params?.dappNames ?? []);
1864
- this.dappRegistry = new DappRegistry(this.dappSeedPhraseRepository);
1865
- this.addConnectionRequests();
1866
- }
1867
- async buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
1868
- const dapp = new XyOsDapp({
1869
- dapp: {
1870
- id: dappId,
1871
- name
1872
- },
1873
- locator: this.locator,
1874
- manifest,
1875
- parent: this.context,
1876
- user: await this.getUser()
1877
- });
1878
- this.builtDapps[dappId] = dapp;
1879
- return dapp;
1880
- }
1881
- getParamsForRegisteredDapp(dappId) {
1882
- return this.params?.dappParams[dappId];
1883
- }
1884
- async start() {
1885
- const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), {
1886
- name: "Install System dApps"
1887
- });
1888
- const activeDapps = systemDapps.filter(({ dapp }) => dapp.icon.active === true);
1889
- const results = await Promise.allSettled(activeDapps.map(async (dappSet) => {
1890
- const { dapp } = dappSet;
1891
- const registeredDapp = await this.dappRegistry.registerDapp(dapp);
1892
- const result = {
1893
- dapp: registeredDapp,
1894
- dappIcon: dapp.icon
1895
- };
1896
- const forgetHandlers = /* @__PURE__ */ __name(async () => {
1897
- try {
1898
- await this.postRegistrationHandlers(result);
1899
- } catch (e) {
1900
- console.error("Error in post registration handlers", e);
1901
- }
1902
- }, "forgetHandlers");
1903
- forget2(forgetHandlers());
1904
- return result;
1905
- }));
1906
- const failed = results.filter(rejected).map((result) => {
1907
- const reason = result.reason;
1908
- return reason instanceof Error ? reason.message : String(reason);
1909
- });
1910
- const succeeded = results.filter(fulfilled).map((result) => result.value);
1911
- for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp);
1912
- return {
1913
- failed,
1914
- succeeded
1915
- };
1916
- }
1917
- addConnectionRequests() {
1918
- this.context.eventBus.addConnection(this.dappAccessRequestConnection);
1919
- this.context.eventBus.addConnection(this.exposeDappRequestConnection);
1920
- }
1921
- /**
1922
- * A method to get the user property from context and eventually modify it before handing it to a dapp
1923
- * i.e. curating user-approved signers
1924
- */
1925
- getUser() {
1926
- return this.context.user;
1927
- }
1928
- async postRegistrationHandlers(registeredDapp) {
1929
- if (registeredDapp.dapp) {
1930
- if (isRegisteredDappExposedDappSet(registeredDapp)) {
1931
- this.registeredExposedDappSets.add(registeredDapp);
1932
- const exposeIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes.Launch, registeredDapp.dapp.config.name, DappMode2.Exposed);
1933
- await this.exposeDappRequestConnection.emit(ExposeDappRequestEvent, {
1934
- payloads: [
1935
- registeredDapp.dapp.config,
1936
- exposeIntent
1937
- ]
1938
- });
1939
- }
1940
- if (isRegisteredDappAccessDappSet(registeredDapp)) {
1941
- this.registeredAccessDappSets.add(registeredDapp);
1942
- await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, {
1943
- payloads: registeredDapp.dapp.accessors
1944
- });
1945
- }
1946
- }
1947
- }
1948
- };
1949
-
1950
- // src/signer/Signers.ts
1951
- import { assertEx as assertEx10 } from "@xylabs/sdk-js";
1952
- import { HDWallet as HDWallet5 } from "@xyo-network/sdk-js";
1953
- var Signers = class {
1954
- static {
1955
- __name(this, "Signers");
1956
- }
1957
- _paths;
1958
- _signerAccounts;
1959
- _walletStore;
1960
- constructor(paths, walletStore) {
1961
- this._paths = paths;
1962
- this._walletStore = walletStore;
1963
- this._signerAccounts = /* @__PURE__ */ new Map();
1964
- }
1965
- get paths() {
1966
- return assertEx10(this._paths, () => "Paths not initialized");
1967
- }
1968
- get signerAccounts() {
1969
- return assertEx10(this._signerAccounts, () => "Signer accounts not initialized");
1970
- }
1971
- get walletStore() {
1972
- return assertEx10(this._walletStore, () => "Wallet store not initialized");
1973
- }
1974
- getSigner(walletKind, signer) {
1975
- return this.signerAccounts.get(walletKind)?.get(signer);
1976
- }
1977
- getWalletKindSigner(walletKind) {
1978
- return this.signerAccounts.get(walletKind);
1979
- }
1980
- async initialize() {
1981
- for (const [walletKindName, signerPaths] of this.paths) {
1982
- for (const [signerName, walletPath] of signerPaths.entries()) {
1983
- await this.initializeSigners(walletKindName, signerName, walletPath);
1984
- }
1985
- }
1986
- }
1987
- async initializeSigners(walletKindName, signerName, path) {
1988
- assertEx10(signerName, () => "Name not found in signer paths");
1989
- assertEx10(path, () => "Path not found in signer paths");
1990
- const phrase = assertEx10(await this.walletStore.get(walletKindName), () => `Wallet not found: ${walletKindName}`);
1991
- if (path) {
1992
- const signerMap = this.signerAccounts.get(walletKindName) ?? /* @__PURE__ */ new Map();
1993
- const wallet = await HDWallet5.fromPhrase(phrase);
1994
- const derivedWallet = await wallet.derivePath(path);
1995
- signerMap.set(signerName, derivedWallet);
1996
- this.signerAccounts.set(walletKindName, signerMap);
1997
- }
1998
- }
1999
- };
2000
-
2001
- // src/stack/Base.ts
2002
- import { assertEx as assertEx11, BaseEmitter as BaseEmitter3, forget as forget3 } from "@xylabs/sdk-js";
2003
- import { isModuleInstance } from "@xyo-network/module-model";
2004
- import { asAttachableNodeInstance } from "@xyo-network/node-model";
2005
- var StackBase = class extends BaseEmitter3 {
2006
- static {
2007
- __name(this, "StackBase");
2008
- }
2009
- // flag to check that all adapters are initialized
2010
- initialized = false;
2011
- // adapters to initialize into the stack
2012
- _adapterSet;
2013
- _context;
2014
- // stack node
2015
- _stack;
2016
- // stack node module identifier for the stack
2017
- _stackNodeModuleId;
2018
- // list of initialized nodes
2019
- initializedNodes = [];
2020
- // list of listeners - lister type not important since its only recalled to stop listening
2021
- listeners = [];
2022
- constructor(context, adapterSet, stackNodeModuleId) {
2023
- super({});
2024
- this._context = context;
2025
- this._adapterSet = adapterSet(assertEx11(this.context.kernel, () => "Kernel access required"));
2026
- this._stackNodeModuleId = stackNodeModuleId;
2027
- }
2028
- get adapterSet() {
2029
- return assertEx11(this._adapterSet, () => `${this.stackNodeModuleId} adapters not initialized`);
2030
- }
2031
- get context() {
2032
- return assertEx11(this._context, () => `${this.stackNodeModuleId} stack context not initialized`);
2033
- }
2034
- get stack() {
2035
- return assertEx11(this._stack, () => `${this.stackNodeModuleId} stack node not initialized`);
2036
- }
2037
- get stackNodeModuleId() {
2038
- return assertEx11(this._stackNodeModuleId, () => "Stack node module identifier not initialized");
2039
- }
2040
- initialize() {
2041
- this.assignStack();
2042
- for (const adapter of this.adapterSet) {
2043
- const driverReadyListener = /* @__PURE__ */ __name(async ({ node }) => await this.handleDriverReady(node), "driverReadyListener");
2044
- adapter.on("driverReady", driverReadyListener);
2045
- this.listeners.push({
2046
- adapter,
2047
- eventName: "driverReady",
2048
- listener: driverReadyListener
2049
- });
2050
- const driverErrorListener = /* @__PURE__ */ __name(async ({ error }) => {
2051
- console.error(`Error updating ${this.stackNodeModuleId} stack node`, error);
2052
- await this.emit("driverError", {
2053
- error
2054
- });
2055
- }, "driverErrorListener");
2056
- adapter.on("driverError", driverErrorListener);
2057
- this.listeners.push({
2058
- adapter,
2059
- eventName: "driverError",
2060
- listener: driverErrorListener
2061
- });
2062
- const startAdapter = /* @__PURE__ */ __name(async () => await adapter.start(), "startAdapter");
2063
- forget3(startAdapter());
2064
- }
2065
- }
2066
- /**
2067
- * Stops the stack
2068
- */
2069
- stop() {
2070
- for (const { eventName, listener, adapter } of this.listeners) {
2071
- adapter.off(eventName, listener);
2072
- }
2073
- }
2074
- /**
2075
- * Adds a node to the stack. Idempotent to avoid adding the
2076
- * same node multiple times
2077
- * @param node The node to add to the stack
2078
- * @returns
2079
- */
2080
- async addNodeToStackNode(node) {
2081
- const stackNode = await this.getStackNode();
2082
- const existingModule = await stackNode.resolve(node.address, {
2083
- direction: "down"
2084
- });
2085
- if (isModuleInstance(existingModule)) return;
2086
- await stackNode.register?.(node);
2087
- await stackNode.attach?.(node.address, true);
2088
- }
2089
- assignStack() {
2090
- const assign = /* @__PURE__ */ __name(async () => {
2091
- const stackNode = await this.getStackNode();
2092
- this._stack = stackNode;
2093
- }, "assign");
2094
- forget3(assign());
2095
- }
2096
- async getStackNode() {
2097
- const mod = assertEx11(await this.context.root.resolve(this.stackNodeModuleId), () => `${this.stackNodeModuleId} not found`);
2098
- return asAttachableNodeInstance(mod, () => `${this.stackNodeModuleId} not a NodeInstance`, {
2099
- required: true
2100
- });
2101
- }
2102
- async handleDriverReady(node) {
2103
- try {
2104
- await this.emit("driverReady", {
2105
- node
2106
- });
2107
- await this.addNodeToStackNode(node);
2108
- await this.updateInitializationState(node);
2109
- } catch (error) {
2110
- console.error(`Error updating ${this.stackNodeModuleId} stack node`, node.id, error);
2111
- await this.emit("stackError", {
2112
- error
2113
- });
2114
- }
2115
- }
2116
- async updateInitializationState(node) {
2117
- this.initializedNodes.push(node);
2118
- this.initialized = this.adapterSet.every((n) => n.initialized);
2119
- if (this.initialized) {
2120
- await this.emit("initialized", {
2121
- stack: await this.getStackNode()
2122
- });
2123
- }
2124
- }
2125
- };
2126
-
2127
- // src/stack/Manager.ts
2128
- var StackManager = class {
2129
- static {
2130
- __name(this, "StackManager");
2131
- }
2132
- initializedStacksMap = /* @__PURE__ */ new Map();
2133
- stackMap;
2134
- constructor(stackMap) {
2135
- this.stackMap = stackMap;
2136
- }
2137
- get stacks() {
2138
- return Object.keys(this.initializedStacksMap);
2139
- }
2140
- get initializedStacks() {
2141
- return this.initializedStacksMap;
2142
- }
2143
- getStack(key) {
2144
- return this.initializedStacksMap.get(key);
2145
- }
2146
- initialize(context) {
2147
- for (const [key, stackSet] of Object.entries(this.stackMap)) {
2148
- console.log("stack-initialize", key);
2149
- const { stack: Stack, adapters: stackNodeModuleId } = stackSet;
2150
- const initializedStack = new Stack(context, stackNodeModuleId);
2151
- initializedStack.initialize();
2152
- this.initializedStacks.set(key, initializedStack);
2153
- }
2154
- }
2155
- stop() {
2156
- for (const stack of this.initializedStacks.values()) {
2157
- stack.stop();
2158
- }
2159
- }
2160
- };
2161
-
2162
- // src/adapters/OsPubSubBridgeNetwork.ts
2163
- import { ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName } from "@xyo-network/os-model";
2164
-
2165
- // src/adapter/Base.ts
2166
- import { assertEx as assertEx12, BaseEmitter as BaseEmitter4, forget as forget4 } from "@xylabs/sdk-js";
2167
- import { asArchivistInstance as asArchivistInstance5 } from "@xyo-network/archivist";
2168
- import { asAttachableNodeInstance as asAttachableNodeInstance2 } from "@xyo-network/node-model";
2169
- import { asSchema as asSchema3 } from "@xyo-network/payload-model";
2170
- import { v4 as uuid3 } from "uuid";
2171
- var NodeAdapterBase = class extends BaseEmitter4 {
2172
- static {
2173
- __name(this, "NodeAdapterBase");
2174
- }
2175
- initialized = false;
2176
- _id = "";
2177
- driverName;
2178
- kernel;
2179
- constructor(kernel, driverName) {
2180
- super({});
2181
- this._id = uuid3();
2182
- this.kernel = kernel;
2183
- this.driverName = driverName;
2184
- }
2185
- get id() {
2186
- return assertEx12(this._id, () => "NodeAdapterBase id not initialized");
2187
- }
2188
- async start() {
2189
- try {
2190
- const moduleAttachedInsertListener = /* @__PURE__ */ __name(({ payloads }) => {
2191
- const moduleAttachedEvent = this.findModuleEventPayloads(payloads);
2192
- for (const payload of moduleAttachedEvent) {
2193
- if (payload.name === this.driverName) {
2194
- this.validateAndReturnDriver();
2195
- }
2196
- }
2197
- }, "moduleAttachedInsertListener");
2198
- const eventsArchivist = await this.getEventsArchivist();
2199
- const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener);
2200
- const insertListenerRef = weakRefInsertListener.deref();
2201
- if (insertListenerRef) eventsArchivist.on("inserted", insertListenerRef);
2202
- const node = this.validateAndReturnDriver();
2203
- if (node) return node;
2204
- this.initialized = false;
2205
- } catch (error) {
2206
- await this.emit("driverError", {
2207
- error
2208
- });
2209
- }
2210
- }
2211
- findModuleEventPayloads(payloads) {
2212
- return payloads.filter((payload) => {
2213
- const payloadToTest = payload;
2214
- return payloadToTest.event === "driverReady" && payloadToTest.schema === asSchema3("network.xyo.kernel.module.event", true);
2215
- });
2216
- }
2217
- async getEventsArchivist() {
2218
- const mod = assertEx12(await (await this.kernel.getNode()).resolve("KernelNode:ModuleEvents"), () => "KernelNode:ModuleEvents not found");
2219
- return asArchivistInstance5(mod, () => `${mod.id} is not an archivist`, {
2220
- required: true
2221
- });
2222
- }
2223
- validateAndReturnDriver() {
2224
- const mod = this.kernel.initialized[this.driverName];
2225
- if (mod) {
2226
- const node = asAttachableNodeInstance2(mod, () => `${mod.id} is not a node`, {
2227
- required: true
2228
- });
2229
- this.initialized = true;
2230
- const emit = /* @__PURE__ */ __name(async () => await this.emit("driverReady", {
2231
- node
2232
- }), "emit");
2233
- forget4(emit());
2234
- return node;
2235
- }
2236
- }
2237
- };
2238
-
2239
- // src/adapter/Network.ts
2240
- var NetworkAdapter = class extends NodeAdapterBase {
2241
- static {
2242
- __name(this, "NetworkAdapter");
2243
- }
2244
- _connection;
2245
- constructor(kernel, driverName) {
2246
- super(kernel, driverName);
2247
- this.on("driverReady", ({ node }) => {
2248
- this._connection = node;
2249
- });
2250
- }
2251
- get connection() {
2252
- return this._connection;
2253
- }
2254
- get hasConnection() {
2255
- return !!this.connection;
2256
- }
2257
- removeConnection() {
2258
- this._connection = void 0;
2259
- }
2260
- };
2261
-
2262
- // src/adapter/Settings.ts
2263
- var SettingsAdapter = class extends NodeAdapterBase {
2264
- static {
2265
- __name(this, "SettingsAdapter");
2266
- }
2267
- _settings = void 0;
2268
- constructor(kernel, driverName) {
2269
- super(kernel, driverName);
2270
- this.on("driverReady", ({ node }) => {
2271
- this._settings = node;
2272
- });
2273
- }
2274
- get hasSettings() {
2275
- return !!this.settings;
2276
- }
2277
- get settings() {
2278
- return this._settings;
2279
- }
2280
- removeSettings() {
2281
- this._settings = void 0;
2282
- }
2283
- };
2284
-
2285
- // src/adapters/OsPubSubBridgeNetwork.ts
2286
- var OsPubSubBridgeNetworkAdapters = /* @__PURE__ */ __name((kernel) => [
2287
- new NetworkAdapter(kernel, PubSubBridgeNodeNodeName),
2288
- new NetworkAdapter(kernel, ExposedNodeOuterNodeName)
2289
- ], "OsPubSubBridgeNetworkAdapters");
2290
-
2291
- // src/adapters/OsSettings.ts
2292
- import { OsSettingsNodeName } from "@xyo-network/os-model";
2293
- var OsSettingsAdapters = /* @__PURE__ */ __name((kernel) => [
2294
- new SettingsAdapter(kernel, OsSettingsNodeName)
2295
- ], "OsSettingsAdapters");
2296
-
2297
- // src/adapters/OsXyoPublicNetwork.ts
2298
- import { XyoPublicNodeName } from "@xyo-network/os-model";
2299
- var OsXyoPublicNetworkAdapters = /* @__PURE__ */ __name((kernel) => [
2300
- new NetworkAdapter(kernel, XyoPublicNodeName)
2301
- ], "OsXyoPublicNetworkAdapters");
2302
-
2303
- // src/stack/OsPubSubNetworkStack.ts
2304
- import { assertEx as assertEx13 } from "@xylabs/sdk-js";
2305
- import { asAttachableNodeInstance as asAttachableNodeInstance3, asNodeInstance } from "@xyo-network/node-model";
2306
- import { ExposedNodeOuterNodeName as ExposedNodeOuterNodeName2, PubSubBridgeNodeNodeName as PubSubBridgeNodeNodeName2 } from "@xyo-network/os-model";
2307
- var OsPubSubNetworkStack = class extends StackBase {
2308
- static {
2309
- __name(this, "OsPubSubNetworkStack");
2310
- }
2311
- _exposedNode;
2312
- _exposedNodeOuter;
2313
- busConnection = osPubSubNetworkReadyConnection();
2314
- constructor(context, adapters) {
2315
- super(context, adapters, "OsPubSubNetworkStackNode");
2316
- }
2317
- get exposedNode() {
2318
- return this._exposedNode;
2319
- }
2320
- get exposedNodeOuter() {
2321
- return this._exposedNodeOuter;
2322
- }
2323
- initialize() {
2324
- super.initialize();
2325
- this.context.eventBus.addConnection(this.busConnection);
2326
- this.on("initialized", () => this.busConnection.emit(OsPubSubNetworkReadyEvent, {}));
2327
- super.on("driverReady", async ({ node }) => {
2328
- if (node.id === PubSubBridgeNodeNodeName2) {
2329
- const httpBridge = assertEx13(await node.resolve("NsHttpBridge"), () => "HttpBridge not found");
2330
- const xnsNode = asNodeInstance(await httpBridge.resolve("XNS"));
2331
- if (xnsNode) {
2332
- const initializedXns = await initializeXns(xnsNode);
2333
- console.log(`Xns: ${initializedXns}`);
2334
- } else {
2335
- console.log("Xns: Failed to contact Xns Node");
2336
- }
2337
- }
2338
- });
2339
- super.on("driverReady", async ({ node }) => {
2340
- if (node.id === ExposedNodeOuterNodeName2) {
2341
- this._exposedNodeOuter = node;
2342
- const mod = assertEx13(await node.resolve("ExposedNode"), () => "ExposedNode not found");
2343
- const exposedNode = asAttachableNodeInstance3(mod, () => "ExposedNode is not a node");
2344
- this._exposedNode = exposedNode;
2345
- }
2346
- });
2347
- super.on("driverError", (error) => console.error("Unable to assign exposed node(s) to context", error));
2348
- }
2349
- stop() {
2350
- super.stop();
2351
- this._exposedNode = void 0;
2352
- this._exposedNodeOuter = void 0;
2353
- if (this.busConnection._id) this.context.eventBus.removeConnection(this.busConnection.id);
2354
- }
2355
- };
2356
-
2357
- // src/stack/OsSettingsStack.ts
2358
- var OsSettingsStack = class extends StackBase {
2359
- static {
2360
- __name(this, "OsSettingsStack");
2361
- }
2362
- busConnection = osSettingsReadyConnection();
2363
- constructor(context, adapters) {
2364
- super(context, adapters, "OsSettingsStackNode");
2365
- }
2366
- initialize() {
2367
- super.initialize();
2368
- this.context.eventBus.addConnection(this.busConnection);
2369
- this.on("initialized", () => this.busConnection.emit(OsSettingsReadyEvent, {}));
2370
- }
2371
- stop() {
2372
- super.stop();
2373
- }
2374
- };
2375
-
2376
- // src/stack/XyoPublicNetworkStack.ts
2377
- import { XyoPublicNodeName as XyoPublicNodeName2 } from "@xyo-network/os-model";
2378
- var XyoPublicNetworkStack = class extends StackBase {
2379
- static {
2380
- __name(this, "XyoPublicNetworkStack");
2381
- }
2382
- busConnection = osXyoPublicNetworkReadyConnection();
2383
- constructor(context, adapters) {
2384
- super(context, adapters, "OsXyoPublicNetworkStackNode");
2385
- }
2386
- initialize() {
2387
- super.initialize();
2388
- this.context.eventBus.addConnection(this.busConnection);
2389
- this.on("initialized", () => this.busConnection.emit(OsXyoPublicNetworkReadyEvent, {}));
2390
- this.on("driverReady", ({ node }) => {
2391
- if (node.id === XyoPublicNodeName2) {
2392
- console.log("XyoPublicNode ready");
2393
- }
2394
- });
2395
- this.on("driverError", (error) => console.error("Error loading driver", error));
2396
- }
2397
- stop() {
2398
- super.stop();
2399
- }
2400
- };
2401
-
2402
- // src/stack/Map.ts
2403
- var OsStackMap = {
2404
- osPubSubNetworkStack: {
2405
- stack: OsPubSubNetworkStack,
2406
- adapters: OsPubSubBridgeNetworkAdapters
2407
- },
2408
- xyoPublicNetworkStack: {
2409
- stack: XyoPublicNetworkStack,
2410
- adapters: OsXyoPublicNetworkAdapters
2411
- },
2412
- osSettingsStack: {
2413
- stack: OsSettingsStack,
2414
- adapters: OsSettingsAdapters
2415
- }
2416
- };
2417
-
2418
- // src/XyOs.ts
2419
- var XyOs = class _XyOs extends XyOsContextBase {
2420
- static {
2421
- __name(this, "XyOs");
2422
- }
2423
- _exposedNode;
2424
- _exposedNodeOuter;
2425
- _kernel;
2426
- _locator;
2427
- dappRegistrationService;
2428
- signers;
2429
- stackManager;
2430
- constructor({ logger = console, eventBus = new EventBus(), kernel = new Kernel({
2431
- logger
2432
- }), locator = new ModuleFactoryLocator8(), dappsConfiguration, developmentMode, stackMap = OsStackMap, ...params } = {}) {
2433
- super({
2434
- eventBus,
2435
- kernel,
2436
- locator,
2437
- ...params
2438
- });
2439
- this._locator = locator;
2440
- this._kernel = kernel;
2441
- this.stackManager = new StackManager(stackMap);
2442
- this.dappRegistrationService = new DappRegistrationService(this, dappsConfiguration, this.locator, developmentMode);
2443
- if (this.signerPaths && this.kernel?.bios?.seedPhraseStore) this.signers = new Signers(this.signerPaths, this.kernel?.bios?.seedPhraseStore);
2444
- }
2445
- static get monitoring() {
2446
- return;
2447
- }
2448
- static get xyOsGlobal() {
2449
- return getXyOsGlobal();
2450
- }
2451
- get bios() {
2452
- return assertEx14(this.params.kernel?.bios, () => "Missing bios");
2453
- }
2454
- get exposedNode() {
2455
- return this.stackManager.getStack("osPubSubNetworkStack")?.exposedNode;
2456
- }
2457
- get exposedNodeOuter() {
2458
- return this.stackManager.getStack("osPubSubNetworkStack")?.exposedNodeOuter;
2459
- }
2460
- get kernel() {
2461
- return assertEx14(this.params.kernel, () => "Missing kernel");
2462
- }
2463
- get locator() {
2464
- return this._locator;
2465
- }
2466
- get stacks() {
2467
- return this.stackManager.stacks;
2468
- }
2469
- get user() {
2470
- return {
2471
- signers: this.signers?.getWalletKindSigner("user")
2472
- };
2473
- }
2474
- static async monitor(fn, eventConfig) {
2475
- const { name, additionalProperties } = eventConfig;
2476
- const monitor = this.monitoring;
2477
- monitor?.startTimer(name);
2478
- const result = await fn();
2479
- monitor?.stopTimer({
2480
- additionalProperties,
2481
- name
2482
- });
2483
- return result;
2484
- }
2485
- async boot(wallet, locator = new ModuleFactoryLocator8()) {
2486
- console.warn("XyOs:boot", wallet.address);
2487
- const fullLocator = this._locator.merge(locator);
2488
- return await this._bootMutex.runExclusive(async () => {
2489
- await this.eventBus.start();
2490
- if (this.kernel?.status === "created") {
2491
- await this.kernel.boot(await boot(), {
2492
- locator: fullLocator,
2493
- kernelDrivers: []
2494
- });
2495
- }
2496
- if (this.kernel?.status !== "booted") {
2497
- throw new Error("Kernel not booted");
2498
- }
2499
- assertEx14(this._root === void 0, () => "XyOs already booted");
2500
- const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), {
2501
- name: "Load XyOs"
2502
- });
2503
- this._root = root;
2504
- this.stackManager.initialize(this);
2505
- if (this.signers) await this.signers.initialize();
2506
- return this;
2507
- });
2508
- }
2509
- buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
2510
- return this.dappRegistrationService.buildDapp(manifest, dappId, name);
2511
- }
2512
- dappByName(dappId) {
2513
- return this.dappRegistrationService.builtDapps[dappId];
2514
- }
2515
- getDappParams(dappId) {
2516
- return this.dappRegistrationService.getParamsForRegisteredDapp(dappId);
2517
- }
2518
- getStack(stackName) {
2519
- return assertEx14(this.stackManager.getStack(stackName), () => `Stack not found: ${stackName}`);
2520
- }
2521
- async monitor(fn, eventConfig) {
2522
- return await _XyOs.monitor(fn, eventConfig);
2523
- }
2524
- shutdown() {
2525
- assertEx14(this._root !== void 0, () => "XyOs not booted");
2526
- this._root = void 0;
2527
- this.stackManager.stop();
2528
- }
2529
- };
2530
-
2531
- // src/RunningDappCache.ts
2532
- var findOrCreateMutex = new Mutex3();
2533
- var RunningDappCache = class _RunningDappCache {
2534
- static {
2535
- __name(this, "RunningDappCache");
2536
- }
2537
- static _cache = {};
2538
- static async findOrCreate(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork) {
2539
- const dappId = dapp.config.name;
2540
- return await XyOs.monitor(async () => await findOrCreateMutex.runExclusive(async () => {
2541
- const existingWindowDappSet = _RunningDappCache.get(dappId);
2542
- if (existingWindowDappSet) {
2543
- console.debug("[DEBUG]", `RunningDappCache, using existing node for ${dappId}`);
2544
- const existingDappContext = assertEx15(existingWindowDappSet.context, () => "No context found in existing dapp node");
2545
- await DappContextCreator.primeDappArchivist(existingDappContext, xyOs, dappId);
2546
- return existingWindowDappSet;
2547
- }
2548
- console.debug("[DEBUG]", "RunningDappCache:creating", dappId);
2549
- const windowDappSet = await createDappContext(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork);
2550
- _RunningDappCache.set(dappId, windowDappSet);
2551
- return windowDappSet;
2552
- }), {
2553
- additionalProperties: {
2554
- dappId
2555
- },
2556
- name: "Loading dApp"
2557
- });
2558
- }
2559
- static get(key) {
2560
- return this._cache[key];
2561
- }
2562
- static has(key) {
2563
- return key ? !!this._cache[key] : false;
2564
- }
2565
- static set(key, value) {
2566
- this._cache[key] = value;
2567
- }
2568
- };
2569
-
2570
- // src/access/RunningAccessDappCache.ts
2571
- var RunningDappAccessCache = class {
2572
- static {
2573
- __name(this, "RunningDappAccessCache");
2574
- }
2575
- static _cache = {};
2576
- static get(key) {
2577
- return this._cache[key];
2578
- }
2579
- static has(key) {
2580
- return key ? !!this._cache[key] : false;
2581
- }
2582
- static set(key, value) {
2583
- this._cache[key] = value;
2584
- }
2585
- };
2586
-
2587
- // src/access/Caller.ts
2588
- var DappAccessCaller = class extends OsCallerBase {
2589
- static {
2590
- __name(this, "DappAccessCaller");
2591
- }
2592
- allowedNames;
2593
- platformLocator;
2594
- registeredDapps;
2595
- xnsNetwork;
2596
- xnsNodeUrl;
2597
- constructor(context, registeredDapps, allowedNames, xnsNodeUrl, xnsNetwork, platformLocator = new ModuleFactoryLocator9()) {
2598
- super(context);
2599
- this.registeredDapps = registeredDapps;
2600
- this.allowedNames = allowedNames;
2601
- this.xnsNodeUrl = xnsNodeUrl;
2602
- this.xnsNetwork = xnsNetwork;
2603
- this.platformLocator = platformLocator;
2604
- }
2605
- async start() {
2606
- const registeredDappAccessDappSets = this.registeredDapps.filter(isRegisteredDappAccessDappSet2);
2607
- for (const registeredDappSet of registeredDappAccessDappSets) {
2608
- const context = await this.buildRunningDappCache(registeredDappSet, this.allowedNames);
2609
- for (const dappAccessor of registeredDappSet.dapp.accessors) {
2610
- await this.cacheAccessNode(dappAccessor, context);
2611
- await this.saveRegisteredDappInterfaces(dappAccessor);
2612
- }
2613
- }
2614
- }
2615
- async buildRunningDappCache(registeredDappSet, allowedNames) {
2616
- const { context } = await RunningDappCache.findOrCreate(registeredDappSet.dapp, this.context, allowedNames, this.xnsNodeUrl, this.xnsNetwork);
2617
- if (!context) throw new Error("Dapp context not found");
2618
- return context;
2619
- }
2620
- async cacheAccessNode(dappAccessor, context) {
2621
- const accessNodeId = dappAccessor.rootModuleId;
2622
- const accessNodeModule = assertEx16(await context.root.resolve(accessNodeId), () => "Access Node Module not found");
2623
- const accessNode = asNodeInstance2(accessNodeModule, () => "Access Node Module is not a NodeInstance", {
2624
- required: true
2625
- });
2626
- RunningDappAccessCache.set(dappAccessor.registeringDappId, accessNode);
2627
- }
2628
- async saveRegisteredDappInterfaces(registeredDappAccess) {
2629
- const archivist = await this.getRegisteredDappInterfacesArchivist();
2630
- const hash = await PayloadBuilder5.dataHash(registeredDappAccess);
2631
- const [existing] = await archivist.get([
2632
- hash
2633
- ]);
2634
- if (existing) return;
2635
- await archivist.insert([
2636
- registeredDappAccess
2637
- ]);
2638
- console.debug("[DEBUG] -", `Registered ${registeredDappAccess.registeringDappId} with ${registeredDappAccess.name} interface`);
2639
- }
2640
- };
2641
-
2642
- // src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts
2643
- import { assertEx as assertEx17 } from "@xylabs/sdk-js";
2644
- import { asArchivistInstance as asArchivistInstance6 } from "@xyo-network/archivist-model";
2645
- var AccessNodeQueries = class {
2646
- static {
2647
- __name(this, "AccessNodeQueries");
2648
- }
2649
- xyOsContext;
2650
- accessRequest;
2651
- registeredDappAccess;
2652
- constructor(xyOsContext, accessRequest, registeredDappAccess) {
2653
- this.xyOsContext = xyOsContext;
2654
- this.accessRequest = accessRequest;
2655
- this.registeredDappAccess = registeredDappAccess;
2656
- }
2657
- get nameServiceNamesAccessNode() {
2658
- return assertEx17(RunningDappAccessCache.get(this.registeredDappAccess.registeringDappId), () => "No access node found");
2659
- }
2660
- // Refresh the archivist in the dapp
2661
- async refresh() {
2662
- const archivist = await this.getArchivistFromDappNode();
2663
- await archivist.clear();
2664
- await this.run();
2665
- console.log("refreshed");
2666
- }
2667
- // Run the access node queries
2668
- async run() {
2669
- const payloads = await this.getPayloadsFromAccessNode();
2670
- await this.insertAccessNodePayloadsIntoDappNodeArchivist(payloads);
2671
- return payloads;
2672
- }
2673
- async getArchivistFromDappNode() {
2674
- const archivistPath = this.accessRequest?.destinationArchivist ?? "DappArchivist";
2675
- const mod = assertEx17(await this.xyOsContext.root.resolve(archivistPath), () => `Unable to find archivist at ${archivistPath}`);
2676
- return asArchivistInstance6(mod, () => `Module at ${archivistPath} is not an archivist`, {
2677
- required: true
2678
- });
2679
- }
2680
- async getPayloadsFromAccessNode() {
2681
- const archivistFromAccessNode = await this.resolveArchivistFromAccessNode();
2682
- return await archivistFromAccessNode.all();
2683
- }
2684
- async insertAccessNodePayloadsIntoDappNodeArchivist(payloads) {
2685
- const archivist = await this.getArchivistFromDappNode();
2686
- await archivist.clear();
2687
- await archivist.insert(payloads);
2688
- }
2689
- async resolveArchivistFromAccessNode() {
2690
- const archivist = assertEx17(await this.nameServiceNamesAccessNode.resolve("PublicXnsArchivist"), () => "Unable to find archivist at PublicXnsArchivist");
2691
- return asArchivistInstance6(archivist, () => "PublicXnsArchivist is not an archivist", {
2692
- required: true
2693
- });
2694
- }
2695
- };
2696
-
2697
- // src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts
2698
- import { assertEx as assertEx18 } from "@xylabs/sdk-js";
2699
- import { asArchivistInstance as asArchivistInstance7 } from "@xyo-network/archivist-model";
2700
- import { asDivinerInstance as asDivinerInstance4 } from "@xyo-network/diviner-model";
2701
- var XnsArchivistPayloadDivinerModuleName = "XnsArchivistPayloadDiviner";
2702
- var XnsArchivistModuleName = "XnsArchivist";
2703
- var XnsRegistrationsArchivistModuleName = "XnsRegistrationsArchivist";
2704
- var AbstractXnsCaller = class {
2705
- static {
2706
- __name(this, "AbstractXnsCaller");
2707
- }
2708
- context;
2709
- constructor(context) {
2710
- this.context = context;
2711
- }
2712
- /**
2713
- * Get the XnsArchivist
2714
- */
2715
- async getXnsArchivist(pathPrefix) {
2716
- const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistModuleName}` : XnsArchivistModuleName;
2717
- const mod = assertEx18(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
2718
- return asArchivistInstance7(mod, () => `${fullyQualifiedPath} is not an archivist`, {
2719
- required: true
2720
- });
2721
- }
2722
- /**
2723
- * Get the XnsArchivistPayloadDiviner
2724
- */
2725
- async getXnsArchivistPayloadDiviner(pathPrefix) {
2726
- const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistPayloadDivinerModuleName}` : XnsArchivistPayloadDivinerModuleName;
2727
- const mod = assertEx18(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
2728
- return asDivinerInstance4(mod, () => `${fullyQualifiedPath} is not an diviner`, {
2729
- required: true
2730
- });
2731
- }
2732
- /**
2733
- * Get the XnsRegistrationsArchivist
2734
- */
2735
- async getXnsRegistrationsArchivist(pathPrefix) {
2736
- const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsRegistrationsArchivistModuleName}` : XnsRegistrationsArchivistModuleName;
2737
- const mod = assertEx18(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
2738
- return asArchivistInstance7(mod, () => `${fullyQualifiedPath} is not an archivist`, {
2739
- required: true
2740
- });
2741
- }
2742
- };
2743
-
2744
- // src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts
2745
- import { assertEx as assertEx19 } from "@xylabs/sdk-js";
2746
- import { isTemporalIndexingDivinerResultIndex } from "@xyo-network/diviner-temporal-indexing-model";
2747
-
2748
- // src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts
2749
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema4 } from "@xyo-network/diviner-payload-model";
2750
- import { TemporalIndexingDivinerResultIndexSchema } from "@xyo-network/diviner-temporal-indexing-model";
2751
- var XnsRegistrationsResourceQueries = {
2752
- getAllRegistrations: /* @__PURE__ */ __name(async (diviner) => {
2753
- const query = {
2754
- limit: 100,
2755
- order: "desc",
2756
- schema: PayloadDivinerQuerySchema4,
2757
- schemas: [
2758
- TemporalIndexingDivinerResultIndexSchema
2759
- ]
2760
- };
2761
- return await diviner.divine([
2762
- query
2763
- ]);
2764
- }, "getAllRegistrations"),
2765
- getRecentRegistrations: /* @__PURE__ */ __name(async (archivist) => {
2766
- return (await archivist.all()).toReversed();
2767
- }, "getRecentRegistrations")
2768
- };
2769
-
2770
- // src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts
2771
- var XnsRegistrationsResource = class extends AbstractXnsCaller {
2772
- static {
2773
- __name(this, "XnsRegistrationsResource");
2774
- }
2775
- _allRegistrations;
2776
- pathPrefix;
2777
- constructor(context, pathPrefix) {
2778
- super(context);
2779
- this.pathPrefix = pathPrefix;
2780
- }
2781
- get allRegistrations() {
2782
- return assertEx19(this._allRegistrations);
2783
- }
2784
- get subscriptions() {
2785
- return {
2786
- allRegistrations: /* @__PURE__ */ __name((cb) => this.allRegistrations.subscribe(cb), "allRegistrations")
2787
- };
2788
- }
2789
- get views() {
2790
- return {
2791
- allRegistrations: /* @__PURE__ */ __name(() => this.allRegistrations.getSnapshot(), "allRegistrations")
2792
- };
2793
- }
2794
- cleanupListeners() {
2795
- this.allRegistrations.cleanupListeners();
2796
- }
2797
- async start() {
2798
- const xnsArchivistPayloadDiviner = await this.getXnsArchivistPayloadDiviner(this.pathPrefix);
2799
- const xnsArchivist = await this.getXnsArchivist(this.pathPrefix);
2800
- this._allRegistrations = await PayloadStore.create({
2801
- archivist: xnsArchivist,
2802
- getLatest: /* @__PURE__ */ __name(async () => await XnsRegistrationsResourceQueries.getAllRegistrations(xnsArchivistPayloadDiviner), "getLatest"),
2803
- idFunction: isTemporalIndexingDivinerResultIndex
2804
- });
2805
- }
2806
- };
2807
-
2808
- // src/access/Queries.ts
2809
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema5 } from "@xyo-network/diviner-payload-model";
2810
- import { DappAccessRequestSchema, RegisteredDappAccessSchema as RegisteredDappAccessSchema2 } from "@xyo-network/os-model";
2811
- var noResults = [];
2812
- var DappAccessRequestQueries = {
2813
- async getAccessRequests(diviner) {
2814
- const query = {
2815
- limit: 1,
2816
- schema: PayloadDivinerQuerySchema5,
2817
- schemas: [
2818
- DappAccessRequestSchema
2819
- ]
2820
- };
2821
- const results = await diviner.divine([
2822
- query
2823
- ]);
2824
- if (results.length === 0) {
2825
- return noResults;
2826
- }
2827
- return results;
2828
- },
2829
- async getRegisteredInterfaces(diviner) {
2830
- const query = {
2831
- limit: 1,
2832
- schema: PayloadDivinerQuerySchema5,
2833
- schemas: [
2834
- RegisteredDappAccessSchema2
2835
- ]
2836
- };
2837
- const results = await diviner.divine([
2838
- query
2839
- ]);
2840
- if (results.length === 0) {
2841
- return noResults;
2842
- }
2843
- return results;
2844
- }
2845
- };
2846
-
2847
- // src/access/Resource.ts
2848
- import { assertEx as assertEx20 } from "@xylabs/sdk-js";
2849
- import { isDappAccessRequestWithMeta, isRegisteredDappAccess as isRegisteredDappAccess2 } from "@xyo-network/os-model";
2850
- var DappAccessRequestResource = class extends DappCallerBase {
2851
- static {
2852
- __name(this, "DappAccessRequestResource");
2853
- }
2854
- _accessRequestListener;
2855
- _registeredInterfacesListener;
2856
- constructor(context) {
2857
- super(context);
2858
- }
2859
- get accessRequestListener() {
2860
- return assertEx20(this._accessRequestListener, () => "accessRequests note found");
2861
- }
2862
- get registeredInterfacesListener() {
2863
- return assertEx20(this._registeredInterfacesListener, () => "registeredInterfaces note found");
2864
- }
2865
- get subscriptions() {
2866
- return {
2867
- accessRequests: /* @__PURE__ */ __name((cb) => this.accessRequestListener.subscribe(cb), "accessRequests"),
2868
- registeredInterfaces: /* @__PURE__ */ __name((cb) => this.registeredInterfacesListener.subscribe(cb), "registeredInterfaces")
2869
- };
2870
- }
2871
- get views() {
2872
- return {
2873
- accessRequests: /* @__PURE__ */ __name(() => this.accessRequestListener.getSnapshot(), "accessRequests"),
2874
- registeredInterfaces: /* @__PURE__ */ __name(() => this.registeredInterfacesListener.getSnapshot(), "registeredInterfaces")
2875
- };
2876
- }
2877
- cleanupListeners() {
2878
- this.accessRequestListener.cleanupListeners();
2879
- }
2880
- // Start the resource
2881
- async start() {
2882
- const archivist = await this.getDappArchivist();
2883
- const diviner = await this.getDappArchivistPayloadDiviner();
2884
- this._accessRequestListener = await PayloadStore.create({
2885
- archivist,
2886
- getLatest: /* @__PURE__ */ __name(async () => await DappAccessRequestQueries.getAccessRequests(diviner), "getLatest"),
2887
- idFunction: isDappAccessRequestWithMeta
2888
- });
2889
- this._registeredInterfacesListener = await PayloadStore.create({
2890
- archivist,
2891
- getLatest: /* @__PURE__ */ __name(async () => await DappAccessRequestQueries.getRegisteredInterfaces(diviner), "getLatest"),
2892
- idFunction: isRegisteredDappAccess2
2893
- });
2894
- }
2895
- };
2896
-
2897
- // src/Caller.ts
2898
- import { assertEx as assertEx21 } from "@xylabs/sdk-js";
2899
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema7 } from "@xyo-network/diviner-payload-model";
2900
- import { DappAccessRequestSchema as DappAccessRequestSchema2, DappInjectableParamsSchema as DappInjectableParamsSchema2, DappIntentTypes as DappIntentTypes2, DappMode as DappMode3, RegisteredDappAccessSchema as RegisteredDappAccessSchema3 } from "@xyo-network/os-model";
2901
- import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
2902
-
2903
- // src/DefaultsQueries.ts
2904
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema6 } from "@xyo-network/diviner-payload-model";
2905
- import { DappInjectableParamsSchema, NodeOsInfoSchema as NodeOsInfoSchema2 } from "@xyo-network/os-model";
2906
- var DappDefaultsResourceQueries = {
2907
- async getDappInjectableParamsFromRoute(diviner) {
2908
- const query = {
2909
- limit: 1,
2910
- order: "desc",
2911
- schema: PayloadDivinerQuerySchema6,
2912
- schemas: [
2913
- DappInjectableParamsSchema
2914
- ],
2915
- source: "route"
2916
- };
2917
- return await diviner.divine([
2918
- query
2919
- ]);
2920
- },
2921
- async getNodeOsInfo(diviner) {
2922
- const query = {
2923
- limit: 1,
2924
- order: "desc",
2925
- schema: PayloadDivinerQuerySchema6,
2926
- schemas: [
2927
- NodeOsInfoSchema2
2928
- ]
2929
- };
2930
- return await diviner.divine([
2931
- query
2932
- ]);
2933
- }
2934
- };
2935
-
2936
- // src/Caller.ts
2937
- var DappCaller = class extends DappCallerBase {
2938
- static {
2939
- __name(this, "DappCaller");
2940
- }
2941
- constructor(context) {
2942
- super(context);
2943
- }
2944
- /**
2945
- * Add payloads to the dapp archivist
2946
- * @param payloads
2947
- * @param force
2948
- */
2949
- async addPayloadsToDappArchivist(payloads = [], force = false) {
2950
- const dappArchivist = await this.getDappArchivist();
2951
- if (force) {
2952
- await dappArchivist.insert(payloads);
2953
- } else {
2954
- for (const payload of payloads) {
2955
- const hash = await PayloadBuilder6.dataHash(payload);
2956
- const [existing] = await dappArchivist.get([
2957
- hash
2958
- ]);
2959
- if (existing) continue;
2960
- await dappArchivist.insert([
2961
- payload
2962
- ]);
2963
- }
2964
- }
2965
- }
2966
- /**
2967
- * Build Access Request
2968
- * @param mode
2969
- * @param registeredDappAccessHash
2970
- * @param requestingDappId
2971
- * @param destinationArchivist
2972
- */
2973
- buildAccessRequest(mode, registeredDappAccessHash, requestingDappId, destinationArchivist) {
2974
- const accessRequest = {
2975
- destinationArchivist,
2976
- mode,
2977
- registeredDappAccessHash,
2978
- requestingDappId,
2979
- schema: DappAccessRequestSchema2,
2980
- timestamp: Date.now()
2981
- };
2982
- return accessRequest;
2983
- }
2984
- /**
2985
- * Get all available dapp access requests
2986
- */
2987
- async getDappAccessPayloads() {
2988
- const diviner = await this.getDappArchivistPayloadDiviner();
2989
- const query = {
2990
- order: "desc",
2991
- schema: PayloadDivinerQuerySchema7,
2992
- schemas: [
2993
- RegisteredDappAccessSchema3
2994
- ]
2995
- };
2996
- return diviner.divine([
2997
- query
2998
- ]);
2999
- }
3000
- /**
3001
- * Get the most recent dapp injectable params
3002
- * @returns Promise
3003
- */
3004
- async getDappInjectableParams() {
3005
- const diviner = await this.getDappArchivistPayloadDiviner();
3006
- return await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner);
3007
- }
3008
- /**
3009
- * Get the most recent dapp intent
3010
- * @param name
3011
- */
3012
- async getRegisteredDappAccessByName(name) {
3013
- const diviner = await this.getDappArchivistPayloadDiviner();
3014
- const query = {
3015
- limit: 1,
3016
- name,
3017
- schema: PayloadDivinerQuerySchema7,
3018
- schemas: [
3019
- RegisteredDappAccessSchema3
3020
- ]
3021
- };
3022
- const [payload] = assertEx21(await diviner.divine([
3023
- query
3024
- ]), () => "Unable to find registered dapp access");
3025
- return payload;
3026
- }
3027
- /**
3028
- * Get the user wallet
3029
- */
3030
- getUserAccount(dappName) {
3031
- const account = this.context.user.signers?.get(dappName);
3032
- if (account) {
3033
- return account;
3034
- } else {
3035
- throw new Error("Unable to find user wallet");
3036
- }
3037
- }
3038
- /**
3039
- * Get all wallets for the user
3040
- */
3041
- getUserAccountsAll() {
3042
- return [
3043
- ...this.context.user.signers?.values() ?? []
3044
- ];
3045
- }
3046
- /**
3047
- * Make Dapp Access Request
3048
- * @param requestingDappId
3049
- * @param registeredDappAccessHash
3050
- * @param mode
3051
- * @param destinationArchivist
3052
- */
3053
- async makeDappAccessRequest(requestingDappId, registeredDappAccessHash, mode, destinationArchivist) {
3054
- const archivist = await this.getDappArchivist();
3055
- const registeredDappAccessPayload = await archivist.get([
3056
- registeredDappAccessHash
3057
- ]);
3058
- if (!registeredDappAccessPayload) {
3059
- throw new Error("No registered dapp access found");
3060
- }
3061
- const accessRequest = this.buildAccessRequest(mode, registeredDappAccessHash, requestingDappId, destinationArchivist);
3062
- await archivist.insert([
3063
- accessRequest
3064
- ]);
3065
- }
3066
- /**
3067
- * Make Dapp Intent Request
3068
- * @param sourceDappId
3069
- * @param targetDappId
3070
- * @param intent
3071
- * @param mode
3072
- */
3073
- async makeDappIntentRequest(sourceDappId, targetDappId, intent = DappIntentTypes2.Launch, mode = DappMode3.Window, params) {
3074
- if (!sourceDappId) {
3075
- throw new Error("No source dapp id provided, dApps must declare a sourceDappId");
3076
- }
3077
- const archivist = await this.getDappArchivist();
3078
- const dappIntent = DappIntentCaller.buildIntent(sourceDappId, intent, targetDappId, mode, params);
3079
- return await archivist.insert([
3080
- dappIntent
3081
- ]);
3082
- }
3083
- /**
3084
- * Set the dapp injectable params
3085
- * @param searchParams
3086
- * @param pathname
3087
- */
3088
- async setDappInjectableRouteParams(searchParams = new URLSearchParams(), pathname) {
3089
- const dappArchivist = await this.getDappArchivist();
3090
- const params = {};
3091
- for (const [key, value] of searchParams.entries()) {
3092
- params[key] = value;
3093
- }
3094
- const payload = {
3095
- params,
3096
- path: pathname,
3097
- schema: DappInjectableParamsSchema2,
3098
- source: "route",
3099
- timestamp: Date.now()
3100
- };
3101
- await dappArchivist.insert([
3102
- payload
3103
- ]);
3104
- }
3105
- };
3106
-
3107
- // src/classes/dapp/DefaultsResource.ts
3108
- import { assertEx as assertEx22 } from "@xylabs/sdk-js";
3109
- import { isDappInjectableParams, isNodeOsInfo } from "@xyo-network/os-model";
3110
- var DappDefaultsResource = class extends DappCallerBase {
3111
- static {
3112
- __name(this, "DappDefaultsResource");
3113
- }
3114
- _dappInjectableParamsFromRouteListener;
3115
- _nodeOsInfoListener;
3116
- constructor(context) {
3117
- super(context);
3118
- }
3119
- get dappInjectableParamsFromRouteListener() {
3120
- return assertEx22(this._dappInjectableParamsFromRouteListener, () => "DappInjectableParams not found");
3121
- }
3122
- get nodeOsInfoListener() {
3123
- return assertEx22(this._nodeOsInfoListener, () => "NodeOsInfo not found");
3124
- }
3125
- get subscriptions() {
3126
- return {
3127
- dappInjectableParamsFromRoute: /* @__PURE__ */ __name((cb) => this.dappInjectableParamsFromRouteListener.subscribe(cb), "dappInjectableParamsFromRoute"),
3128
- nodeOsInfo: /* @__PURE__ */ __name((cb) => this.nodeOsInfoListener.subscribe(cb), "nodeOsInfo")
3129
- };
3130
- }
3131
- get views() {
3132
- return {
3133
- dappInjectableParamsFromRoute: /* @__PURE__ */ __name(() => this.dappInjectableParamsFromRouteListener.getSnapshot(), "dappInjectableParamsFromRoute"),
3134
- nodeOsInfo: /* @__PURE__ */ __name(() => this.nodeOsInfoListener.getSnapshot(), "nodeOsInfo")
3135
- };
3136
- }
3137
- cleanupListeners() {
3138
- this.nodeOsInfoListener.cleanupListeners();
3139
- }
3140
- async start() {
3141
- const archivist = await this.getDappArchivist();
3142
- const diviner = await this.getDappArchivistPayloadDiviner();
3143
- this._nodeOsInfoListener = await PayloadStore.create({
3144
- archivist,
3145
- getLatest: /* @__PURE__ */ __name(async () => await DappDefaultsResourceQueries.getNodeOsInfo(diviner), "getLatest"),
3146
- idFunction: isNodeOsInfo
3147
- });
3148
- this._dappInjectableParamsFromRouteListener = await PayloadStore.create({
3149
- archivist,
3150
- getLatest: /* @__PURE__ */ __name(async () => await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner), "getLatest"),
3151
- idFunction: isDappInjectableParams
3152
- });
3153
- }
3154
- };
3155
-
3156
- // src/classes/menu/Caller.ts
3157
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema8 } from "@xyo-network/diviner-payload-model";
3158
- import { DappInjectableParamsSchema as DappInjectableParamsSchema3, DappNavItemSelectionSchema } from "@xyo-network/os-model";
3159
- import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
3160
- var DappMenuCaller = class extends DappCaller {
3161
- static {
3162
- __name(this, "DappMenuCaller");
3163
- }
3164
- constructor(context) {
3165
- super(context);
3166
- }
3167
- /**
3168
- * Add new Payloads to the dappArchivist if they haven't already
3169
- * @param payloads
3170
- */
3171
- async add(payloads, force = false) {
3172
- const dappArchivist = await this.getDappArchivist();
3173
- for (const payload of payloads) {
3174
- const hash = await PayloadBuilder7.dataHash(payload);
3175
- const [existing] = await dappArchivist.get([
3176
- hash
3177
- ]);
3178
- if (!existing || force) {
3179
- await dappArchivist.insert(payloads);
3180
- }
3181
- }
3182
- }
3183
- async currentNavSelection() {
3184
- const diviner = await this.getDappArchivistPayloadDiviner();
3185
- const query = {
3186
- limit: 1,
3187
- order: "desc",
3188
- schema: PayloadDivinerQuerySchema8,
3189
- schemas: [
3190
- DappNavItemSelectionSchema
3191
- ]
3192
- };
3193
- return await diviner.divine([
3194
- query
3195
- ]);
3196
- }
3197
- /*
3198
- * Indicate to the system that a nav item was selected
3199
- *
3200
- * @param {string} path
3201
- * @params {string} injectableParamsPath
3202
- * @returns Promise
3203
- */
3204
- async makeNavItemSelection(path, injectableParamsPath) {
3205
- const dappArchivist = await this.getDappArchivist();
3206
- const payload = {
3207
- path,
3208
- schema: DappNavItemSelectionSchema,
3209
- timestamp: Date.now()
3210
- };
3211
- await dappArchivist.insert([
3212
- payload
3213
- ]);
3214
- if (injectableParamsPath) {
3215
- const injectableParams = {
3216
- params: {},
3217
- path: injectableParamsPath,
3218
- schema: DappInjectableParamsSchema3,
3219
- source: "route",
3220
- timestamp: Date.now()
3221
- };
3222
- await dappArchivist.insert([
3223
- injectableParams
3224
- ]);
3225
- }
3226
- }
3227
- };
3228
-
3229
- // src/classes/menu/Resource.ts
3230
- import { assertEx as assertEx23 } from "@xylabs/sdk-js";
3231
- import { isDappNavItemSelection, isDappNavMenuConfig } from "@xyo-network/os-model";
3232
-
3233
- // src/classes/menu/Queries.ts
3234
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema9 } from "@xyo-network/diviner-payload-model";
3235
- import { DappNavItemSchema, DappNavItemSelectionSchema as DappNavItemSelectionSchema2, DappNavMenuConfigSchema } from "@xyo-network/os-model";
3236
- var NO_ITEMS = [];
3237
- var DappMenuQueries = {
3238
- async getMenuConfigs(diviner) {
3239
- const query = {
3240
- limit: 1,
3241
- order: "desc",
3242
- schema: PayloadDivinerQuerySchema9,
3243
- schemas: [
3244
- DappNavMenuConfigSchema
3245
- ]
3246
- };
3247
- return await diviner.divine([
3248
- query
3249
- ]);
3250
- },
3251
- async getMenuItems(diviner) {
3252
- const query = {
3253
- order: "desc",
3254
- schema: PayloadDivinerQuerySchema9,
3255
- schemas: [
3256
- DappNavItemSchema
3257
- ]
3258
- };
3259
- const results = await diviner.divine([
3260
- query
3261
- ]);
3262
- return results.length > 0 ? results : NO_ITEMS;
3263
- },
3264
- async getNavItemSelections(diviner) {
3265
- const query = {
3266
- limit: 1,
3267
- order: "desc",
3268
- schema: PayloadDivinerQuerySchema9,
3269
- schemas: [
3270
- DappNavItemSelectionSchema2
3271
- ]
3272
- };
3273
- const results = await diviner.divine([
3274
- query
3275
- ]);
3276
- return results.length > 0 ? results : NO_ITEMS;
3277
- },
3278
- async getVisibleMenuItems(diviner) {
3279
- const query = {
3280
- order: "desc",
3281
- schema: PayloadDivinerQuerySchema9,
3282
- schemas: [
3283
- DappNavItemSchema
3284
- ]
3285
- };
3286
- const results = await diviner.divine([
3287
- query
3288
- ]);
3289
- return results.filter((menuItem) => menuItem.hidden !== true).toSorted((a, b) => (a.weight ?? 0) > (b.weight ?? 0) ? 1 : -1);
3290
- }
3291
- };
3292
-
3293
- // src/classes/menu/Resource.ts
3294
- var DappMenuResource = class extends DappCaller {
3295
- static {
3296
- __name(this, "DappMenuResource");
3297
- }
3298
- _menuConfigListener;
3299
- _menuItemListener;
3300
- _menuItemSelectionListener;
3301
- _menuItemVisibleListener;
3302
- constructor(xyOsContext) {
3303
- super(xyOsContext);
3304
- }
3305
- get menuConfigListener() {
3306
- return assertEx23(this._menuConfigListener, () => "menuConfigListener note found");
3307
- }
3308
- get menuItemListener() {
3309
- return assertEx23(this._menuItemListener, () => "menuItemListener note found");
3310
- }
3311
- get menuItemSelectionListener() {
3312
- return assertEx23(this._menuItemSelectionListener, () => "menuItemSelectionListener note found");
3313
- }
3314
- get menuItemVisibleListener() {
3315
- return assertEx23(this._menuItemVisibleListener, () => "menuItemVisibleListener note found");
3316
- }
3317
- /** subscribe to latest set of payloads */
3318
- get subscriptions() {
3319
- return {
3320
- menuConfigs: /* @__PURE__ */ __name((cb) => this.menuConfigListener.subscribe(cb), "menuConfigs"),
3321
- menuItemSelections: /* @__PURE__ */ __name((cb) => this.menuItemSelectionListener.subscribe(cb), "menuItemSelections"),
3322
- menuItems: /* @__PURE__ */ __name((cb) => this.menuItemListener.subscribe(cb), "menuItems"),
3323
- menuItemsVisible: /* @__PURE__ */ __name((cb) => this.menuItemVisibleListener.subscribe(cb), "menuItemsVisible")
3324
- };
3325
- }
3326
- /**
3327
- * Return the latest menu payloads from the repository
3328
- */
3329
- get views() {
3330
- return {
3331
- menuConfigs: /* @__PURE__ */ __name(() => this.menuConfigListener.getSnapshot(), "menuConfigs"),
3332
- menuItemSelections: /* @__PURE__ */ __name(() => this.menuItemSelectionListener.getSnapshot(), "menuItemSelections"),
3333
- menuItems: /* @__PURE__ */ __name(() => this.menuItemListener.getSnapshot(), "menuItems"),
3334
- menuItemsVisible: /* @__PURE__ */ __name(() => this.menuItemVisibleListener.getSnapshot(), "menuItemsVisible")
3335
- };
3336
- }
3337
- /**
3338
- * Remove all listeners and reset their class members
3339
- */
3340
- cleanupListeners() {
3341
- this.menuConfigListener.cleanupListeners();
3342
- this.menuItemListener.cleanupListeners();
3343
- this.menuItemSelectionListener.cleanupListeners();
3344
- }
3345
- /**
3346
- * Start the resource
3347
- */
3348
- async start() {
3349
- const dappArchivist = await this.getDappArchivist();
3350
- const dappArchivistPayloadDiviner = await this.getDappArchivistPayloadDiviner();
3351
- this._menuConfigListener = await PayloadStore.create({
3352
- archivist: dappArchivist,
3353
- getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getMenuConfigs(dappArchivistPayloadDiviner), "getLatest"),
3354
- idFunction: isDappNavMenuConfig
3355
- });
3356
- this._menuItemListener = await PayloadStore.create({
3357
- archivist: dappArchivist,
3358
- getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getMenuItems(dappArchivistPayloadDiviner), "getLatest"),
3359
- idFunction: isDappNavMenuConfig
3360
- });
3361
- this._menuItemVisibleListener = await PayloadStore.create({
3362
- archivist: dappArchivist,
3363
- getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getVisibleMenuItems(dappArchivistPayloadDiviner), "getLatest"),
3364
- idFunction: isDappNavMenuConfig
3365
- });
3366
- this._menuItemSelectionListener = await PayloadStore.create({
3367
- archivist: dappArchivist,
3368
- getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getNavItemSelections(dappArchivistPayloadDiviner), "getLatest"),
3369
- idFunction: isDappNavItemSelection
3370
- });
3371
- }
3372
- };
3373
-
3374
- // src/classes/settings/badge/Caller.ts
3375
- import { OsBadgeSchema as OsBadgeSchema2 } from "@xyo-network/os-model";
3376
-
3377
- // src/classes/settings/CallerBase.ts
3378
- import { assertEx as assertEx24 } from "@xylabs/sdk-js";
3379
- import { asArchivistInstance as asArchivistInstance8 } from "@xyo-network/archivist-model";
3380
- import { asDivinerInstance as asDivinerInstance5 } from "@xyo-network/diviner-model";
3381
- var OsSettingsArchivistModuleName = "OsSettingsNode:OsSettingsArchivist";
3382
- var OsSettingsArchivistPayloadDivinerModuleName = "OsSettingsNode:OsSettingsArchivistPayloadDiviner";
3383
- var OsSettingsCallerBase = class {
3384
- static {
3385
- __name(this, "OsSettingsCallerBase");
3386
- }
3387
- context;
3388
- constructor(context) {
3389
- this.context = context;
3390
- }
3391
- async getOsSettingsArchivist() {
3392
- const mod = assertEx24(await this.context.root.resolve(OsSettingsArchivistModuleName), () => `${OsSettingsArchivistModuleName} not found`);
3393
- return asArchivistInstance8(mod, () => `${OsSettingsArchivistModuleName} is not an archivist`, {
3394
- required: true
3395
- });
3396
- }
3397
- async getOsSettingsPayloadDiviner() {
3398
- const mod = assertEx24(await this.context.root.resolve(OsSettingsArchivistPayloadDivinerModuleName), () => `${OsSettingsArchivistPayloadDivinerModuleName} not found`);
3399
- return asDivinerInstance5(mod, () => `${OsSettingsArchivistPayloadDivinerModuleName} is not a diviner`, {
3400
- required: true
3401
- });
3402
- }
3403
- };
3404
-
3405
- // src/classes/settings/badge/Queries.ts
3406
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema10 } from "@xyo-network/diviner-payload-model";
3407
- import { OsBadgeSchema } from "@xyo-network/os-model";
3408
- var OsBadgeQueries = {
3409
- getBadge: /* @__PURE__ */ __name(async (achievement, diviner) => {
3410
- const query = {
3411
- achievement,
3412
- limit: 1,
3413
- order: "desc",
3414
- schema: PayloadDivinerQuerySchema10,
3415
- schemas: [
3416
- OsBadgeSchema
3417
- ]
3418
- };
3419
- return await diviner.divine([
3420
- query
3421
- ]);
3422
- }, "getBadge")
3423
- };
3424
-
3425
- // src/classes/settings/badge/Caller.ts
3426
- var OsBadgeCaller = class extends OsSettingsCallerBase {
3427
- static {
3428
- __name(this, "OsBadgeCaller");
3429
- }
3430
- /**
3431
- * @param achievement
3432
- */
3433
- async getBadge(achievement) {
3434
- const diviner = await this.getOsSettingsPayloadDiviner();
3435
- const results = await OsBadgeQueries.getBadge(achievement, diviner);
3436
- return results[0] ?? null;
3437
- }
3438
- /**
3439
- * @param achievement
3440
- */
3441
- async saveBadge(achievement) {
3442
- const badge = {
3443
- achievement,
3444
- schema: OsBadgeSchema2,
3445
- timestamp: Date.now()
3446
- };
3447
- const archivist = await this.getOsSettingsArchivist();
3448
- return await archivist.insert([
3449
- badge
3450
- ]);
3451
- }
3452
- };
3453
-
3454
- // src/classes/settings/badge/Resource.ts
3455
- import { assertEx as assertEx25 } from "@xylabs/sdk-js";
3456
- import { isBadgeWithMeta } from "@xyo-network/os-model";
3457
- var OsBadgeResource = class extends OsSettingsCallerBase {
3458
- static {
3459
- __name(this, "OsBadgeResource");
3460
- }
3461
- static views = [
3462
- "savedSeedPhrase"
3463
- ];
3464
- _savedSeedPhrase;
3465
- constructor(xyOsContext) {
3466
- super(xyOsContext);
3467
- }
3468
- get savedSeedPhrase() {
3469
- return assertEx25(this._savedSeedPhrase, () => "Saved seed phrase listener not set");
3470
- }
3471
- get subscriptions() {
3472
- return {
3473
- savedSeedPhrase: /* @__PURE__ */ __name((cb) => this.savedSeedPhrase.subscribe(cb), "savedSeedPhrase")
3474
- };
3475
- }
3476
- get views() {
3477
- return {
3478
- savedSeedPhrase: /* @__PURE__ */ __name(() => this.savedSeedPhrase.latest, "savedSeedPhrase")
3479
- };
3480
- }
3481
- cleanupListeners() {
3482
- this.savedSeedPhrase.cleanupListeners();
3483
- }
3484
- /**
3485
- * start listeners
3486
- */
3487
- async start() {
3488
- const diviner = await this.getOsSettingsPayloadDiviner();
3489
- const archivist = await this.getOsSettingsArchivist();
3490
- this._savedSeedPhrase = await PayloadStore.create({
3491
- archivist,
3492
- getLatest: /* @__PURE__ */ __name(async () => await OsBadgeQueries.getBadge("savedSeedPhrase", diviner), "getLatest"),
3493
- idFunction: isBadgeWithMeta
3494
- });
3495
- }
3496
- };
3497
-
3498
- // src/classes/settings/Caller.ts
3499
- import { assertEx as assertEx26 } from "@xylabs/sdk-js";
3500
-
3501
- // src/utils/buildWalletSeedPhrasePayload.ts
3502
- import { WalletSeedPhraseSchema } from "@xyo-network/os-model";
3503
- import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
3504
- var language = "english";
3505
- var standard = "bip-39";
3506
- var userWalletLabel = "userWallet";
3507
- var buildWalletSeedPhrasePayload = /* @__PURE__ */ __name(async (mnemonic, $label) => {
3508
- const fields = {
3509
- mnemonic: {
3510
- language,
3511
- mnemonic: mnemonic.split(" "),
3512
- standard
3513
- },
3514
- $label,
3515
- $timestamp: Date.now()
3516
- };
3517
- const payload = new PayloadBuilder8({
3518
- schema: WalletSeedPhraseSchema
3519
- }).fields(fields).build();
3520
- const rootHash = await PayloadBuilder8.hash(payload);
3521
- return {
3522
- payload,
3523
- rootHash
3524
- };
3525
- }, "buildWalletSeedPhrasePayload");
3526
- var buildUserWalletSeedPhrasePayload = /* @__PURE__ */ __name((mnemonic) => {
3527
- return buildWalletSeedPhrasePayload(mnemonic, userWalletLabel);
3528
- }, "buildUserWalletSeedPhrasePayload");
3529
-
3530
- // src/utils/getApiDomain.ts
3531
- var getApiDomain = /* @__PURE__ */ __name((scope, apiDomain) => {
3532
- if (apiDomain !== void 0) {
3533
- return apiDomain;
3534
- }
3535
- if (scope === "localhost") {
3536
- return "http://localhost:8080";
3537
- }
3538
- if (scope === "beta") {
3539
- return "https://beta.archivist.xyo.network";
3540
- }
3541
- return "https://archivist.xyo.network";
3542
- }, "getApiDomain");
3543
-
3544
- // src/utils/renameObjKey.ts
3545
- var renameObjKey = /* @__PURE__ */ __name((oldObj, oldKey, newKey) => {
3546
- const oldObjKeys = Object.keys(oldObj);
3547
- const newObj = oldObjKeys.reduce((acc, val) => {
3548
- if (val === oldKey) {
3549
- acc[newKey] = oldObj[oldKey];
3550
- } else {
3551
- acc[val] = oldObj[val];
3552
- }
3553
- return acc;
3554
- }, {});
3555
- return newObj;
3556
- }, "renameObjKey");
3557
-
3558
- // src/classes/settings/SettingsQueries.ts
3559
- import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema11 } from "@xyo-network/diviner-payload-model";
3560
- import { NodeBackgroundSchema, WalletSeedPhraseSchema as WalletSeedPhraseSchema2 } from "@xyo-network/os-model";
3561
- import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
3562
- var NO_RESULTS2 = [];
3563
- var OsSettingsQueries = {
3564
- async getLatestUserWallet(diviner, archivist) {
3565
- const query = {
3566
- limit: 1,
3567
- order: "desc",
3568
- schema: PayloadDivinerQuerySchema11,
3569
- schemas: [
3570
- WalletSeedPhraseSchema2
3571
- ]
3572
- };
3573
- const results = await diviner.divine([
3574
- query
3575
- ]);
3576
- const wallet = results.find((payload) => payload.$label === "userWallet");
3577
- if (wallet) return [
3578
- wallet
3579
- ];
3580
- const legacyWallet = results.find((payload) => payload.$meta?.label === "userWallet");
3581
- if (legacyWallet && archivist) {
3582
- const legacyMeta = legacyWallet.$meta;
3583
- const newWalletPayloadFields = {
3584
- mnemonic: legacyWallet.mnemonic,
3585
- $label: legacyMeta?.label,
3586
- $timestamp: legacyMeta?.$timestamp
3587
- };
3588
- const payload = new PayloadBuilder9({
3589
- schema: WalletSeedPhraseSchema2
3590
- }).fields(newWalletPayloadFields).build();
3591
- await archivist.insert([
3592
- payload
3593
- ]);
3594
- return [
3595
- payload
3596
- ];
3597
- }
3598
- return NO_RESULTS2;
3599
- },
3600
- async getNodeBackground(diviner) {
3601
- const query = {
3602
- limit: 1,
3603
- order: "desc",
3604
- schema: PayloadDivinerQuerySchema11,
3605
- schemas: [
3606
- NodeBackgroundSchema
3607
- ]
3608
- };
3609
- return await diviner.divine([
3610
- query
3611
- ]);
3612
- },
3613
- async getWallets(diviner) {
3614
- const query = {
3615
- order: "desc",
3616
- schema: PayloadDivinerQuerySchema11,
3617
- schemas: [
3618
- WalletSeedPhraseSchema2
3619
- ]
3620
- };
3621
- return await diviner.divine([
3622
- query
3623
- ]);
3624
- }
3625
- };
3626
-
3627
- // src/classes/settings/Caller.ts
3628
- var OsSettingsCaller = class extends OsSettingsCallerBase {
3629
- static {
3630
- __name(this, "OsSettingsCaller");
3631
- }
3632
- constructor(context) {
3633
- super(context);
3634
- }
3635
- /**
3636
- * Add a node background to the settings
3637
- * @param payload
3638
- */
3639
- async addNodeBackground(payload) {
3640
- const archivist = await this.getOsSettingsArchivist();
3641
- await archivist.insert([
3642
- payload
3643
- ]);
3644
- }
3645
- /**
3646
- * Add a wallet seed phrase to the settings
3647
- * @param payload
3648
- */
3649
- async addWalletSeedPhrase(payload) {
3650
- const archivist = await this.getOsSettingsArchivist();
3651
- await archivist.insert([
3652
- payload
3653
- ]);
3654
- const phrase = payload.mnemonic.mnemonic.join(" ");
3655
- await this.context.kernel?.bios?.seedPhraseStore.set("user", phrase);
3656
- }
3657
- /**
3658
- * Get the latest node background
3659
- */
3660
- async getLatestNodeBackground() {
3661
- const diviner = await this.getOsSettingsPayloadDiviner();
3662
- const [result] = await OsSettingsQueries.getNodeBackground(diviner);
3663
- return result ?? null;
3664
- }
3665
- async getLatestUserWallet() {
3666
- const diviner = await this.getOsSettingsPayloadDiviner();
3667
- const archivist = await this.getOsSettingsArchivist();
3668
- const storedSeedPhrasePayload = (await OsSettingsQueries.getLatestUserWallet(diviner, archivist)).pop();
3669
- const biosWalletSeedPhrase = assertEx26(await this.context.kernel?.bios?.seedPhraseStore.get("user"), () => "No user seed phrase found from BIOS");
3670
- const biosWalletSeedPhraseParts = biosWalletSeedPhrase.split(" ");
3671
- if (!storedSeedPhrasePayload?.mnemonic?.mnemonic) {
3672
- const { payload: biosSeedPhrasePayload } = await buildUserWalletSeedPhrasePayload(biosWalletSeedPhrase);
3673
- await this.addWalletSeedPhrase(biosSeedPhrasePayload);
3674
- return biosSeedPhrasePayload;
3675
- } else if (!isEqual(storedSeedPhrasePayload.mnemonic.mnemonic, biosWalletSeedPhraseParts)) {
3676
- const updatedBiosSeedPhrase = storedSeedPhrasePayload.mnemonic.mnemonic.join(" ");
3677
- await this.context.kernel?.bios?.seedPhraseStore.set("user", updatedBiosSeedPhrase);
3678
- }
3679
- return storedSeedPhrasePayload;
3680
- }
3681
- };
3682
-
3683
- // src/classes/settings/Resource.ts
3684
- import { assertEx as assertEx27 } from "@xylabs/sdk-js";
3685
- import { isNodeBackground, isWalletSeedPhrase } from "@xyo-network/os-model";
3686
- var OsSettingsResource = class extends OsSettingsCallerBase {
3687
- static {
3688
- __name(this, "OsSettingsResource");
3689
- }
3690
- _latestUserWalletListener;
3691
- _nodeBackgroundListener;
3692
- _walletsListener;
3693
- constructor(context) {
3694
- super(context);
3695
- }
3696
- get latestUserWalletListener() {
3697
- return assertEx27(this._latestUserWalletListener, () => "Latest user wallet listener not set");
3698
- }
3699
- get nodeBackgroundListener() {
3700
- return assertEx27(this._nodeBackgroundListener, () => "Node background listener not set");
3701
- }
3702
- get subscriptions() {
3703
- return {
3704
- latestUserWallet: /* @__PURE__ */ __name((cb) => this.walletsListener.subscribe(cb), "latestUserWallet"),
3705
- nodeBackground: /* @__PURE__ */ __name((cb) => this.nodeBackgroundListener.subscribe(cb), "nodeBackground"),
3706
- wallets: /* @__PURE__ */ __name((cb) => this.walletsListener.subscribe(cb), "wallets")
3707
- };
3708
- }
3709
- get views() {
3710
- return {
3711
- latestUserWallet: /* @__PURE__ */ __name(() => this.latestUserWalletListener.latest, "latestUserWallet"),
3712
- nodeBackground: /* @__PURE__ */ __name(() => this.nodeBackgroundListener.latest, "nodeBackground"),
3713
- wallets: /* @__PURE__ */ __name(() => this.walletsListener.latest, "wallets")
3714
- };
3715
- }
3716
- get walletsListener() {
3717
- return assertEx27(this._walletsListener, () => "Wallets listener not set");
3718
- }
3719
- cleanupListeners() {
3720
- this.walletsListener.cleanupListeners();
3721
- this.latestUserWalletListener.cleanupListeners();
3722
- }
3723
- /**
3724
- * start listeners
3725
- */
3726
- async start() {
3727
- const archivist = await this.getOsSettingsArchivist();
3728
- const diviner = await this.getOsSettingsPayloadDiviner();
3729
- this._walletsListener = await PayloadStore.create({
3730
- archivist,
3731
- getLatest: /* @__PURE__ */ __name(async () => await OsSettingsQueries.getWallets(diviner), "getLatest"),
3732
- idFunction: isWalletSeedPhrase
3733
- });
3734
- this._latestUserWalletListener = await PayloadStore.create({
3735
- archivist,
3736
- getLatest: /* @__PURE__ */ __name(async () => await OsSettingsQueries.getLatestUserWallet(diviner), "getLatest"),
3737
- idFunction: isWalletSeedPhrase
3738
- });
3739
- this._nodeBackgroundListener = await PayloadStore.create({
3740
- archivist,
3741
- getLatest: /* @__PURE__ */ __name(async () => await OsSettingsQueries.getNodeBackground(diviner), "getLatest"),
3742
- idFunction: isNodeBackground
3743
- });
3744
- }
3745
- };
3746
-
3747
- // src/helpers/monitor/XyOsMonitor.ts
3748
- var DEFAULT_MONITORING_EVENT_NAME = "System Task Duration";
3749
- globalThis.getXyOsGlobal = globalThis.getXyOsGlobal ?? (() => {
3750
- return {
3751
- tracking: {
3752
- trackEvent: /* @__PURE__ */ __name((_event, _properties) => void {}, "trackEvent")
3753
- }
3754
- };
3755
- });
3756
- var xyOsGlobal = globalThis.getXyOsGlobal();
3757
- var XyOsMonitor = class _XyOsMonitor {
3758
- static {
3759
- __name(this, "XyOsMonitor");
3760
- }
3761
- static trackEvent = xyOsGlobal.tracking.trackEvent;
3762
- performanceTimers = /* @__PURE__ */ new Map();
3763
- startTimer(name) {
3764
- this.performanceTimers.set(name, performance.now());
3765
- }
3766
- stopTimer(eventConfig) {
3767
- const { additionalProperties, name } = eventConfig;
3768
- const start = this.performanceTimers.get(name);
3769
- if (start) {
3770
- const end = performance.now();
3771
- const duration = end - start;
3772
- this.performanceTimers.delete(name);
3773
- const connection = this.connection();
3774
- _XyOsMonitor.trackEvent(DEFAULT_MONITORING_EVENT_NAME, {
3775
- downloadSpeedMbps: connection?.downlink,
3776
- duration: duration.toString(),
3777
- effectiveConnectionSpeed: connection?.effectiveType,
3778
- name,
3779
- roundTripTime: connection?.rtt,
3780
- ...additionalProperties
3781
- });
3782
- }
3783
- }
3784
- };
3785
-
3786
- // src/initializer/DappInitializer.ts
3787
- import { assertEx as assertEx28 } from "@xylabs/sdk-js";
3788
- var DappInitializer = class {
3789
- static {
3790
- __name(this, "DappInitializer");
3791
- }
3792
- _config;
3793
- constructor(config) {
3794
- this._config = config;
3795
- }
3796
- get config() {
3797
- return assertEx28(this._config, () => new Error("Options not set"));
3798
- }
3799
- async install() {
3800
- const dappWithWalletId = await this.installDappWallet();
3801
- return await this.initializeDappContext(dappWithWalletId);
3802
- }
3803
- async initializeDappContext(dappWithWalletId) {
3804
- const { allowedNames, xnsNetwork, xnsNodeUrl, xyOs } = this.config;
3805
- return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork);
3806
- }
3807
- async installDappWallet() {
3808
- const { xyOs, dapp } = this.config;
3809
- const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [
3810
- dapp.config.name
3811
- ]);
3812
- const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name);
3813
- return {
3814
- ...dapp,
3815
- config: {
3816
- ...dapp.config,
3817
- walletId
3818
- }
3819
- };
3820
- }
3821
- };
3822
-
3823
- // src/profileModuleEvents.ts
3824
- import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
3825
- var DISPLAY_EVENT_COUNT_FREQUENCY = 100;
3826
- var profileData = {};
3827
- var profileModuleEvents = /* @__PURE__ */ __name((mod) => {
3828
- const modRef = new WeakRef(mod);
3829
- mod.onAny(async (eventName, args) => {
3830
- const mod2 = modRef.deref();
3831
- if (mod2) {
3832
- const data = profileData[mod2.address] ?? {
3833
- allEventCount: 0,
3834
- eventCounts: {}
3835
- };
3836
- profileData[mod2.address] = data;
3837
- data.allEventCount += 1;
3838
- data.eventCounts[eventName] = (data.eventCounts[eventName] ?? 0) + 1;
3839
- if (eventName === "querySendStarted") {
3840
- const { query, payloads = [] } = args;
3841
- const pairs = await PayloadBuilder10.dataHashPairs(payloads);
3842
- const foundPair = pairs.find(([, hash]) => hash === query.query);
3843
- if (foundPair) {
3844
- const [payload] = foundPair;
3845
- console.log(`querySendStarted: ${payload.schema}`);
3846
- }
3847
- }
3848
- if (eventName === "querySendFinished") {
3849
- const { query } = args;
3850
- console.log(`querySendFinished: ${query.query}`);
3851
- }
3852
- if (data.allEventCount % DISPLAY_EVENT_COUNT_FREQUENCY === 0) {
3853
- console.log(`[PROFILE] - ${mod2.id} Event Counts:`);
3854
- console.log(data.eventCounts);
3855
- }
3856
- }
3857
- });
3858
- }, "profileModuleEvents");
3859
-
3860
- // src/PubSubBridgeCaller.ts
3861
- import { assertEx as assertEx29 } from "@xylabs/sdk-js";
3862
- import { asBridgeInstance } from "@xyo-network/bridge-model";
3863
- import { BridgedPubSubModuleName } from "@xyo-network/os-model";
3864
- var PubSubBridgeCaller = class {
3865
- static {
3866
- __name(this, "PubSubBridgeCaller");
3867
- }
3868
- node;
3869
- constructor(node) {
3870
- this.node = node;
3871
- }
3872
- async exposeAddresses(addresses, options) {
3873
- const pubSubBridge = await this.getPubSubBridge();
3874
- for (const address of addresses) {
3875
- console.log(`Exposing: ${address}`);
3876
- await pubSubBridge.expose(address, options);
3877
- }
3878
- }
3879
- async unExposeAddresses(addresses) {
3880
- const pubSubBridge = await this.getPubSubBridge();
3881
- for (const address of addresses) {
3882
- await pubSubBridge.unexpose?.(address);
3883
- }
3884
- }
3885
- async getPubSubBridge() {
3886
- const mod = assertEx29(await this.node.resolve(BridgedPubSubModuleName), () => `${BridgedPubSubModuleName} not found`);
3887
- return asBridgeInstance(mod, () => `${BridgedPubSubModuleName} is not a bridge`, {
3888
- required: true
3889
- });
3890
- }
3891
- };
3892
- export {
3893
- AbstractXnsCaller,
3894
- AccessNodeQueries,
3895
- DappAccessCaller,
3896
- DappAccessRequestEvent,
3897
- DappAccessRequestQueries,
3898
- DappAccessRequestResource,
3899
- DappArchivistModuleName,
3900
- DappArchivistPayloadDivinerModuleName,
3901
- DappCaller,
3902
- DappCallerBase,
3903
- DappContextCreator,
3904
- DappDefaultsResource,
3905
- DappDefaultsResourceQueries,
3906
- DappInitializer,
3907
- DappIntentCaller,
3908
- DappIntentResource,
3909
- DappMenuCaller,
3910
- DappMenuResource,
3911
- DappRegistrationService,
3912
- DappRegistry,
3913
- DappSeedPhraseRepository,
3914
- DappsArchivistDevelopmentModuleName,
3915
- DappsArchivistModuleName,
3916
- DappsArchivistPayloadDevelopmentDivinerModuleName,
3917
- DappsArchivistPayloadDivinerModuleName,
3918
- DevelopArchivist,
3919
- EventBus,
3920
- EventBusConnection,
3921
- EventBusPubSubConnection,
3922
- ExposeDappRequestEvent,
3923
- ExternalModulePermissions,
3924
- IntentArchivistModuleName,
3925
- IntentArchivistPayloadDivinerModuleName,
3926
- ManageSystemDapps,
3927
- ModuleOffsetPaths,
3928
- NameTransforms,
3929
- NetworkAdapter,
3930
- NodeSentinel,
3931
- OsBadgeCaller,
3932
- OsBadgeResource,
3933
- OsCallerBase,
3934
- OsPubSubBridgeNetworkAdapters,
3935
- OsPubSubNetworkReadyEvent,
3936
- OsPubSubNetworkStack,
3937
- OsSettingsAdapters,
3938
- OsSettingsCaller,
3939
- OsSettingsCallerBase,
3940
- OsSettingsQueries,
3941
- OsSettingsReadyEvent,
3942
- OsSettingsResource,
3943
- OsSettingsStack,
3944
- OsStackMap,
3945
- OsXyoPublicNetworkAdapters,
3946
- OsXyoPublicNetworkReadyEvent,
3947
- PayloadStore,
3948
- PubSubBridgeCaller,
3949
- RegisteredDappInterfacesArchivistModuleName,
3950
- RemoteNodeArchivistOffsetPaths,
3951
- RunningDappCache,
3952
- SettingsAdapter,
3953
- Signers,
3954
- StackBase,
3955
- StackManager,
3956
- ValidDappAccessInterfaces,
3957
- XnsArchivistModuleName,
3958
- XnsArchivistPayloadDivinerModuleName,
3959
- XnsRegistrationsArchivistModuleName,
3960
- XnsRegistrationsResource,
3961
- XnsRegistrationsResourceQueries,
3962
- XyOs,
3963
- XyOsContextBase,
3964
- XyOsDapp,
3965
- XyOsMonitor,
3966
- XyoPublicNetworkStack,
3967
- asPayload,
3968
- buildUserWalletSeedPhrasePayload,
3969
- buildWalletSeedPhrasePayload,
3970
- createDappContext,
3971
- createInsertable,
3972
- dappAccessRequestConnection,
3973
- dappsReadyConnection,
3974
- exposeDappRequestConnection,
3975
- getApiDomain,
3976
- initializeXns,
3977
- isAnyPayload,
3978
- isEqual,
3979
- isObject2 as isObject,
3980
- isPayload,
3981
- loadOsNode,
3982
- manifestReplacementTokens,
3983
- os_node_manifest_default as osNodeManifest,
3984
- osPubSubNetworkReadyConnection,
3985
- osSettingsReadyConnection,
3986
- osXyoPublicNetworkReadyConnection,
3987
- profileData,
3988
- profileModuleEvents,
3989
- renameObjKey,
3990
- tokenPlacesSplit,
3991
- tokenPlacesSplitString,
3992
- userWalletLabel
3993
- };
3994
- //# sourceMappingURL=index.mjs.map