@xyo-network/os-runtime 3.0.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 (132) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +13 -0
  3. package/dist/neutral/index.d.ts +1656 -0
  4. package/dist/neutral/index.mjs +3432 -0
  5. package/dist/neutral/index.mjs.map +1 -0
  6. package/package.json +78 -0
  7. package/src/Caller.ts +221 -0
  8. package/src/DappCallerBase.ts +52 -0
  9. package/src/DefaultsQueries.ts +27 -0
  10. package/src/OsCallerBase.ts +55 -0
  11. package/src/PubSubBridgeCaller.ts +30 -0
  12. package/src/XyOs.ts +125 -0
  13. package/src/XyOsBase.ts +119 -0
  14. package/src/XyOsDapp.ts +90 -0
  15. package/src/access-interfaces/ValidDappAccessInterfaces.ts +8 -0
  16. package/src/access-interfaces/index.ts +2 -0
  17. package/src/access-interfaces/registered-names/helpers/AccessNodeQueries.ts +59 -0
  18. package/src/access-interfaces/registered-names/helpers/index.ts +2 -0
  19. package/src/access-interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +38 -0
  20. package/src/access-interfaces/registered-names/helpers/resource/RegistrationsResource.ts +54 -0
  21. package/src/access-interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +22 -0
  22. package/src/access-interfaces/registered-names/helpers/resource/index.ts +3 -0
  23. package/src/access-interfaces/registered-names/index.ts +1 -0
  24. package/src/adapter/Base.ts +96 -0
  25. package/src/adapter/Network.ts +31 -0
  26. package/src/adapter/Settings.ts +30 -0
  27. package/src/adapter/index.ts +2 -0
  28. package/src/adapters/OsPubSubBridgeNetwork.ts +10 -0
  29. package/src/adapters/OsSettings.ts +7 -0
  30. package/src/adapters/OsXyoPublicNetwork.ts +9 -0
  31. package/src/adapters/index.ts +3 -0
  32. package/src/classes/cache/RunningAccessDappCache.ts +21 -0
  33. package/src/classes/cache/RunningDappCache.ts +50 -0
  34. package/src/classes/cache/index.ts +2 -0
  35. package/src/classes/dapp/DefaultsResource.ts +65 -0
  36. package/src/classes/dapp/access/Caller.ts +73 -0
  37. package/src/classes/dapp/access/Queries.ts +38 -0
  38. package/src/classes/dapp/access/Resource.ts +63 -0
  39. package/src/classes/dapp/access/index.ts +3 -0
  40. package/src/classes/dapp/index.ts +2 -0
  41. package/src/classes/index.ts +8 -0
  42. package/src/classes/lib/DappCreatorParams.ts +16 -0
  43. package/src/classes/lib/Insertable.ts +14 -0
  44. package/src/classes/lib/index.ts +2 -0
  45. package/src/classes/menu/Caller.ts +76 -0
  46. package/src/classes/menu/Queries.ts +59 -0
  47. package/src/classes/menu/Resource.ts +103 -0
  48. package/src/classes/menu/index.ts +2 -0
  49. package/src/classes/node/Creator.ts +96 -0
  50. package/src/classes/node/DefaultPayloads/DappAccessPayloads.ts +17 -0
  51. package/src/classes/node/DefaultPayloads/DefaultPayloads.ts +33 -0
  52. package/src/classes/node/DefaultPayloads/NodeInfoPayload.ts +27 -0
  53. package/src/classes/node/DefaultPayloads/SigningKeyPayloads.ts +85 -0
  54. package/src/classes/node/DefaultPayloads/index.ts +1 -0
  55. package/src/classes/node/ExternalModulePermissions/ExternalModulePermissions.ts +47 -0
  56. package/src/classes/node/ExternalModulePermissions/index.ts +1 -0
  57. package/src/classes/node/createDappContext.ts +52 -0
  58. package/src/classes/node/index.ts +3 -0
  59. package/src/classes/registration/DappRegistrationService.ts +146 -0
  60. package/src/classes/registration/DappRegistry.ts +121 -0
  61. package/src/classes/registration/ValidateDappAccessDiviner/Config.ts +19 -0
  62. package/src/classes/registration/ValidateDappAccessDiviner/Diviner.ts +132 -0
  63. package/src/classes/registration/ValidateDappAccessDiviner/index.ts +2 -0
  64. package/src/classes/registration/index.ts +2 -0
  65. package/src/classes/settings/Caller.ts +76 -0
  66. package/src/classes/settings/CallerBase.ts +24 -0
  67. package/src/classes/settings/Resource.ts +79 -0
  68. package/src/classes/settings/SettingsQueries.ts +38 -0
  69. package/src/classes/settings/badge/Caller.ts +30 -0
  70. package/src/classes/settings/badge/Queries.ts +18 -0
  71. package/src/classes/settings/badge/Resource.ts +54 -0
  72. package/src/classes/settings/badge/index.ts +2 -0
  73. package/src/classes/settings/index.ts +5 -0
  74. package/src/classes/system/ManageSystemDapps.ts +131 -0
  75. package/src/classes/system/Queries.ts +69 -0
  76. package/src/classes/system/index.ts +1 -0
  77. package/src/event/bus/Connection.ts +31 -0
  78. package/src/event/bus/EventBus.ts +145 -0
  79. package/src/event/bus/PubSubConnection.ts +28 -0
  80. package/src/event/bus/index.ts +3 -0
  81. package/src/event/connections/DappAccessRequest.ts +11 -0
  82. package/src/event/connections/DappsReady.ts +9 -0
  83. package/src/event/connections/ExposeDappRequest.ts +11 -0
  84. package/src/event/connections/OsPubSubNetworkReady.ts +12 -0
  85. package/src/event/connections/OsSettingsReady.ts +12 -0
  86. package/src/event/connections/OsXyoPublicReady.ts +12 -0
  87. package/src/event/connections/index.ts +6 -0
  88. package/src/event/index.ts +2 -0
  89. package/src/helpers/index.ts +1 -0
  90. package/src/helpers/monitor/XyOsMonitor.ts +52 -0
  91. package/src/helpers/monitor/index.ts +2 -0
  92. package/src/helpers/monitor/types.ts +5 -0
  93. package/src/index.ts +22 -0
  94. package/src/intent/Caller.ts +72 -0
  95. package/src/intent/Resource.ts +66 -0
  96. package/src/intent/index.ts +2 -0
  97. package/src/lib/ExternalStore.ts +7 -0
  98. package/src/lib/Listener.ts +1 -0
  99. package/src/lib/ModuleAccountPaths.ts +29 -0
  100. package/src/lib/ModuleNames.ts +3 -0
  101. package/src/lib/NameTransforms.ts +31 -0
  102. package/src/lib/PayloadStore.ts +98 -0
  103. package/src/lib/ResourceStores.ts +7 -0
  104. package/src/lib/index.ts +10 -0
  105. package/src/lib/initializeXns.ts +16 -0
  106. package/src/lib/isPayload.ts +24 -0
  107. package/src/lib/tokenPlacesSplit.ts +17 -0
  108. package/src/loadOsNode.ts +43 -0
  109. package/src/manifest/ManifestReplaceableTokens.ts +17 -0
  110. package/src/manifest/index.ts +2 -0
  111. package/src/manifest/os-node.manifest.json +132 -0
  112. package/src/manifests/dapp-window.manifest.json +36 -0
  113. package/src/manifests/index.ts +1 -0
  114. package/src/profileModuleEvents.ts +43 -0
  115. package/src/stack/Base.ts +153 -0
  116. package/src/stack/Manager.ts +48 -0
  117. package/src/stack/Map.ts +20 -0
  118. package/src/stack/OsPubSubNetworkStack.ts +70 -0
  119. package/src/stack/OsSettingsStack.ts +24 -0
  120. package/src/stack/XyoPublicNetworkStack.ts +32 -0
  121. package/src/stack/index.ts +6 -0
  122. package/src/types/global.d.ts +9 -0
  123. package/src/types/images.d.ts +5 -0
  124. package/src/utils/buildWalletSeedPhrasePayload.ts +41 -0
  125. package/src/utils/getApiDomain.ts +14 -0
  126. package/src/utils/index.ts +3 -0
  127. package/src/utils/renameObjKey.ts +22 -0
  128. package/src/wallet/DappSeedPhraseRepository.ts +95 -0
  129. package/src/wallet/SeedPhraseRepository.ts +32 -0
  130. package/src/wallet/index.ts +2 -0
  131. package/typedoc.json +5 -0
  132. package/xy.config.ts +10 -0
@@ -0,0 +1,20 @@
1
+ import { OsPubSubBridgeNetworkAdapters, OsSettingsAdapters, OsXyoPublicNetworkAdapters } from '../adapters/index.ts'
2
+ import type { UninitializedStackMap } from './Manager.ts'
3
+ import { OsPubSubNetworkStack } from './OsPubSubNetworkStack.ts'
4
+ import { OsSettingsStack } from './OsSettingsStack.ts'
5
+ import { XyoPublicNetworkStack } from './XyoPublicNetworkStack.ts'
6
+
7
+ export const OsStackMap: UninitializedStackMap = {
8
+ osPubSubNetworkStack: {
9
+ stack: OsPubSubNetworkStack,
10
+ adapters: OsPubSubBridgeNetworkAdapters,
11
+ },
12
+ xyoPublicNetworkStack: {
13
+ stack: XyoPublicNetworkStack,
14
+ adapters: OsXyoPublicNetworkAdapters,
15
+ },
16
+ osSettingsStack: {
17
+ stack: OsSettingsStack,
18
+ adapters: OsSettingsAdapters,
19
+ },
20
+ }
@@ -0,0 +1,70 @@
1
+ import { assertEx } from '@xylabs/assert'
2
+ import type { NodeInstance } from '@xyo-network/node-model'
3
+ import { asAttachableNodeInstance, asNodeInstance } from '@xyo-network/node-model'
4
+ import type { AdapterSetCreator, XyOsContext } from '@xyo-network/os-model'
5
+ import { ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName } from '@xyo-network/os-model'
6
+
7
+ import type { EventBusPubSubConnection } from '../event/index.ts'
8
+ import { osPubSubNetworkReadyConnection, OsPubSubNetworkReadyEvent } from '../event/index.ts'
9
+ import { initializeXns } from '../lib/index.ts'
10
+ import { StackBase } from './Base.ts'
11
+
12
+ export class OsPubSubNetworkStack extends StackBase {
13
+ protected _exposedNode: NodeInstance | undefined
14
+ protected _exposedNodeOuter: NodeInstance | undefined
15
+
16
+ private busConnection: EventBusPubSubConnection = osPubSubNetworkReadyConnection()
17
+
18
+ constructor(context: XyOsContext, adapters: AdapterSetCreator) {
19
+ super(context, adapters, 'OsPubSubNetworkStackNode')
20
+ }
21
+
22
+ get exposedNode() {
23
+ return this._exposedNode
24
+ }
25
+
26
+ get exposedNodeOuter() {
27
+ return this._exposedNodeOuter
28
+ }
29
+
30
+ override initialize() {
31
+ super.initialize()
32
+ // connect to the bus
33
+ this.context.eventBus.addConnection(this.busConnection)
34
+ this.on('initialized', () => this.busConnection.emit(OsPubSubNetworkReadyEvent, {}))
35
+
36
+ // listen for drivers
37
+ super.on('driverReady', async ({ node }) => {
38
+ if (node.id === PubSubBridgeNodeNodeName) {
39
+ const httpBridge = assertEx(await node.resolve('NsHttpBridge'), () => 'HttpBridge not found')
40
+ const xnsNode = asNodeInstance(await httpBridge.resolve('XNS'))
41
+
42
+ if (xnsNode) {
43
+ const initializedXns = await initializeXns(xnsNode)
44
+ console.log(`Xns: ${initializedXns}`)
45
+ } else {
46
+ console.log('Xns: Failed to contact Xns Node')
47
+ }
48
+ }
49
+ })
50
+
51
+ super.on('driverReady', async ({ node }) => {
52
+ if (node.id === ExposedNodeOuterNodeName) {
53
+ this._exposedNodeOuter = node
54
+ const mod = assertEx(await node.resolve('ExposedNode'), () => 'ExposedNode not found')
55
+ const exposedNode = asAttachableNodeInstance(mod, () => 'ExposedNode is not a node')
56
+ this._exposedNode = exposedNode
57
+ }
58
+ })
59
+ super.on('driverError', error => console.error('Unable to assign exposed node(s) to context', error))
60
+ }
61
+
62
+ override stop() {
63
+ super.stop()
64
+ this._exposedNode = undefined
65
+ this._exposedNodeOuter = undefined
66
+ // prevent throwing an error if the connection is not initialized
67
+ if (this.busConnection._id)
68
+ this.context.eventBus.removeConnection(this.busConnection.id)
69
+ }
70
+ }
@@ -0,0 +1,24 @@
1
+ import type { AdapterSetCreator, XyOsContext } from '@xyo-network/os-model'
2
+
3
+ import type { EventBusPubSubConnection } from '../event/index.ts'
4
+ import { osSettingsReadyConnection, OsSettingsReadyEvent } from '../event/index.ts'
5
+ import { StackBase } from './Base.ts'
6
+
7
+ export class OsSettingsStack extends StackBase {
8
+ private busConnection: EventBusPubSubConnection = osSettingsReadyConnection()
9
+
10
+ constructor(context: XyOsContext, adapters: AdapterSetCreator) {
11
+ super(context, adapters, 'OsSettingsStackNode')
12
+ }
13
+
14
+ override initialize() {
15
+ super.initialize()
16
+ // connect to the bus
17
+ this.context.eventBus.addConnection(this.busConnection)
18
+ this.on('initialized', () => this.busConnection.emit(OsSettingsReadyEvent, {}))
19
+ }
20
+
21
+ override stop() {
22
+ super.stop()
23
+ }
24
+ }
@@ -0,0 +1,32 @@
1
+ import type { AdapterSetCreator, XyOsContext } from '@xyo-network/os-model'
2
+ import { XyoPublicNodeName } from '@xyo-network/os-model'
3
+
4
+ import type { EventBusPubSubConnection } from '../event/index.ts'
5
+ import { osXyoPublicNetworkReadyConnection, OsXyoPublicNetworkReadyEvent } from '../event/index.ts'
6
+ import { StackBase } from './Base.ts'
7
+
8
+ export class XyoPublicNetworkStack extends StackBase {
9
+ private busConnection: EventBusPubSubConnection = osXyoPublicNetworkReadyConnection()
10
+
11
+ constructor(context: XyOsContext, adapters: AdapterSetCreator) {
12
+ super(context, adapters, 'OsXyoPublicNetworkStackNode')
13
+ }
14
+
15
+ override initialize() {
16
+ super.initialize()
17
+ // connect to the bus
18
+ this.context.eventBus.addConnection(this.busConnection)
19
+ this.on('initialized', () => this.busConnection.emit(OsXyoPublicNetworkReadyEvent, {}))
20
+
21
+ this.on('driverReady', ({ node }) => {
22
+ if (node.id === XyoPublicNodeName) {
23
+ console.log('XyoPublicNode ready')
24
+ }
25
+ })
26
+ this.on('driverError', error => console.error('Error loading driver', error))
27
+ }
28
+
29
+ override stop() {
30
+ super.stop()
31
+ }
32
+ }
@@ -0,0 +1,6 @@
1
+ export * from './Base.ts'
2
+ export * from './Manager.ts'
3
+ export * from './Map.ts'
4
+ export * from './OsPubSubNetworkStack.ts'
5
+ export * from './OsSettingsStack.ts'
6
+ export * from './XyoPublicNetworkStack.ts'
@@ -0,0 +1,9 @@
1
+ import type { XyOsGlobal } from '@xyo-network/os-model'
2
+
3
+ export declare global {
4
+ interface Window {
5
+ ethereum: ethers
6
+ getXyOsGlobal: () => XyOsGlobalReact
7
+ }
8
+ function getXyOsGlobal(): XyOsGlobal
9
+ }
@@ -0,0 +1,5 @@
1
+ declare module '*.png'
2
+ declare module '*.jpg'
3
+ declare module '*.svg'
4
+ declare module '*.gif'
5
+ declare module '*.webp'
@@ -0,0 +1,41 @@
1
+ import type { Hash } from '@xylabs/hex'
2
+ import type { WalletSeedPhrase } from '@xyo-network/os-model'
3
+ import { WalletSeedPhraseSchema } from '@xyo-network/os-model'
4
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
5
+
6
+ const language = 'english'
7
+ const standard = 'bip-39'
8
+
9
+ /**
10
+ * The label for the user wallet
11
+ */
12
+ export const userWalletLabel = 'userWallet'
13
+
14
+ /**
15
+ * The valid wallet labels
16
+ */
17
+ export type WalletLabel = typeof userWalletLabel // TODO: More wallet types 'osWallet' | 'deviceWalletBackup' | ...
18
+
19
+ /**
20
+ * Builds a WalletSeedPhrase payload from the supplied mnemonic seed phrase and label
21
+ * @param mnemonic The mnemonic seed phrase
22
+ * @param label The wallet label
23
+ * @returns A WalletSeedPhrase payload and its root hash
24
+ */
25
+ export const buildWalletSeedPhrasePayload = async (mnemonic: string, label: WalletLabel): Promise<{ payload: WalletSeedPhrase; rootHash: Hash }> => {
26
+ const fields = { mnemonic: { language, mnemonic: mnemonic.split(' '), standard } }
27
+ const meta = { label, timestamp: Date.now() }
28
+ const builder = new PayloadBuilder<WalletSeedPhrase>({ fields, meta, schema: WalletSeedPhraseSchema })
29
+ const payload = await builder.build()
30
+ const rootHash = await PayloadBuilder.hash(payload)
31
+ return { payload, rootHash }
32
+ }
33
+
34
+ /**
35
+ * Builds a user WalletSeedPhrase payload from the supplied mnemonic seed phrase and label
36
+ * @param mnemonic The mnemonic seed phrase
37
+ * @returns A user WalletSeedPhrase payload and its root hash
38
+ */
39
+ export const buildUserWalletSeedPhrasePayload = (mnemonic: string): Promise<{ payload: WalletSeedPhrase; rootHash: Hash }> => {
40
+ return buildWalletSeedPhrasePayload(mnemonic, userWalletLabel)
41
+ }
@@ -0,0 +1,14 @@
1
+ const getApiDomain = (scope: 'localhost' | 'beta' | 'prod' | undefined, apiDomain: string | undefined) => {
2
+ if (apiDomain !== undefined) {
3
+ return apiDomain as string
4
+ }
5
+ if (scope === 'localhost') {
6
+ return 'http://localhost:8080'
7
+ }
8
+ if (scope === 'beta') {
9
+ return 'https://beta.archivist.xyo.network'
10
+ }
11
+ return 'https://archivist.xyo.network'
12
+ }
13
+
14
+ export { getApiDomain }
@@ -0,0 +1,3 @@
1
+ export * from './buildWalletSeedPhrasePayload.ts'
2
+ export * from './getApiDomain.ts'
3
+ export * from './renameObjKey.ts'
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Renames a key on an existing object by returning a new one with the same insertion order
3
+ *
4
+ * inspired by - https://stackoverflow.com/a/48110891/2803259
5
+ */
6
+ export const renameObjKey = <T extends Record<string, unknown> = Record<string, unknown>>(oldObj: T, oldKey: keyof T, newKey: string) => {
7
+ const oldObjKeys = Object.keys(oldObj) as Array<keyof T>
8
+ // eslint-disable-next-line unicorn/no-array-reduce
9
+ const newObj = oldObjKeys.reduce(
10
+ (acc, val) => {
11
+ if (val === oldKey) {
12
+ acc[newKey] = oldObj[oldKey]
13
+ } else {
14
+ acc[val as string] = oldObj[val]
15
+ }
16
+ return acc
17
+ },
18
+ {} as Record<string, unknown>,
19
+ )
20
+
21
+ return newObj as T
22
+ }
@@ -0,0 +1,95 @@
1
+ import { HDWallet } from '@xyo-network/account'
2
+ import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
3
+ import type { DappId, DappWalletSeedPhrase, WalletId, XyOsContext } from '@xyo-network/os-model'
4
+ import { DappWalletSeedPhraseSchema } from '@xyo-network/os-model'
5
+ import type { WithMeta } from '@xyo-network/payload-model'
6
+ import { v4 as uuid } from 'uuid'
7
+
8
+ import { OsCallerBase } from '../OsCallerBase.ts'
9
+ import type { SeedPhraseId, SeedPhraseRepository } from './SeedPhraseRepository.ts'
10
+
11
+ export class DappSeedPhraseRepository extends OsCallerBase implements SeedPhraseRepository {
12
+ // record of all dapps that have requested a seed phrase with the OS
13
+ private dappIdRepository = new Map<SeedPhraseId, DappWalletSeedPhrase>()
14
+ // record of all walletIds that have been issued to registered dapps
15
+ private walletIdRepository = new Map<WalletId, DappWalletSeedPhrase>()
16
+
17
+ constructor(
18
+ xyOs: XyOsContext,
19
+ protected readonly allowedNames: string[],
20
+ ) {
21
+ super(xyOs)
22
+ }
23
+
24
+ async add(dappId: DappId): Promise<string> {
25
+ const archivist = await this.getDappsArchivist()
26
+ const seedPhrase = this.newPhrase()
27
+ const walletId = uuid()
28
+ const payload: DappWalletSeedPhrase = {
29
+ dappId,
30
+ schema: DappWalletSeedPhraseSchema,
31
+ seedPhrase,
32
+ walletId,
33
+ }
34
+ await archivist.insert([payload])
35
+ this.dappIdRepository.set(dappId, payload)
36
+ this.walletIdRepository.set(walletId, payload)
37
+ return walletId
38
+ }
39
+
40
+ async findOrCreate(dappName: string): Promise<WalletId> {
41
+ if (this.allowedNames.includes(dappName)) {
42
+ const existingPayload = await this.checkDappId(dappName)
43
+ if (existingPayload) return existingPayload.walletId
44
+
45
+ // new dapp request so generate a new wallet Id and return it
46
+ try {
47
+ await this.add(dappName)
48
+ const existingPayload = await this.checkDappId(dappName)
49
+ if (existingPayload) return existingPayload.walletId
50
+ throw new Error(`failed to add seed phrase: ${dappName}`)
51
+ } catch (e) {
52
+ console.error(e)
53
+ throw new Error(`failed to add seed phrase: ${dappName}`)
54
+ }
55
+ } else {
56
+ throw new Error(`${dappName} is not allowed to register a seed phase. NOTE: this is a safeguard till 3rd party dApps can be validated`)
57
+ }
58
+ }
59
+
60
+ async request(walletId: WalletId) {
61
+ return (await this.checkWalletId(walletId))?.seedPhrase
62
+ }
63
+
64
+ private async checkDappId(dappId: DappId) {
65
+ const diviner = await this.getDappsArchivistPayloadDiviner()
66
+ const query = {
67
+ dappId,
68
+ limit: 1,
69
+ order: 'desc',
70
+ schema: PayloadDivinerQuerySchema,
71
+ schemas: [DappWalletSeedPhraseSchema],
72
+ }
73
+
74
+ const results = (await diviner.divine([query])) as WithMeta<DappWalletSeedPhrase>[]
75
+ return results.length > 0 ? results[0] : undefined
76
+ }
77
+
78
+ private async checkWalletId(walletId: WalletId) {
79
+ const diviner = await this.getDappsArchivistPayloadDiviner()
80
+ const query = {
81
+ limit: 1,
82
+ order: 'desc',
83
+ schema: PayloadDivinerQuerySchema,
84
+ schemas: [DappWalletSeedPhraseSchema],
85
+ walletId,
86
+ }
87
+
88
+ const results = (await diviner.divine([query])) as WithMeta<DappWalletSeedPhrase>[]
89
+ return results.length > 0 ? results[0] : undefined
90
+ }
91
+
92
+ private newPhrase(): string {
93
+ return HDWallet.generateMnemonic()
94
+ }
95
+ }
@@ -0,0 +1,32 @@
1
+ import type { WalletId } from '@xyo-network/os-model'
2
+
3
+ /** Convenience Types for Entities in the Repository */
4
+ export type SeedPhraseId = string
5
+ export type SeedPhrase = string
6
+
7
+ /**
8
+ * A repository for storing wallet seed phrases and requesting them by walletIds (i.e. UUIDs)
9
+ */
10
+ export interface SeedPhraseRepository {
11
+ /**
12
+ * Add a seed phrase for a given SeedPhraseId
13
+ * @param {SeedPhraseId} id
14
+ * @returns Promise
15
+ */
16
+ add(id: SeedPhraseId): Promise<string>
17
+
18
+ /**
19
+ * For a given DappId, find its wallet or create a new wallet and return its walletId
20
+ * @param {SeedPhraseId} dappName
21
+ * @returns Promise
22
+ */
23
+ findOrCreate(dappName: SeedPhraseId): Promise<WalletId>
24
+
25
+ /**
26
+ * Request a seed phrase by supplying a walletId. Note: In the future, the OS might require verification along side the walletId
27
+ *
28
+ * @param {WalletId} walletId
29
+ * @returns DappWalletSeedPhrase
30
+ */
31
+ request(walletId: WalletId): Promise<SeedPhrase | undefined>
32
+ }
@@ -0,0 +1,2 @@
1
+ export * from './DappSeedPhraseRepository.ts'
2
+ export * from './SeedPhraseRepository.ts'
package/typedoc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["./src/index.ts"],
4
+ "tsconfig": "./tsconfig.typedoc.json"
5
+ }
package/xy.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
+ const config: XyTsupConfig = {
3
+ compile: {
4
+ browser: {},
5
+ node: {},
6
+ neutral: { src: true },
7
+ },
8
+ }
9
+
10
+ export default config