@xyo-network/os-runtime 7.2.0 → 7.3.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.
- package/dist/neutral/Caller.d.ts +18 -20
- package/dist/neutral/Caller.d.ts.map +1 -1
- package/dist/neutral/DappCallerBase.d.ts +2 -2
- package/dist/neutral/DappCallerBase.d.ts.map +1 -1
- package/dist/neutral/OsCallerBase.d.ts +2 -2
- package/dist/neutral/PubSubBridgeCaller.d.ts +1 -1
- package/dist/neutral/PubSubBridgeCaller.d.ts.map +1 -1
- package/dist/neutral/RunningDappCache.d.ts.map +1 -1
- package/dist/neutral/XyOs.d.ts +5 -6
- package/dist/neutral/XyOs.d.ts.map +1 -1
- package/dist/neutral/XyOsBase.d.ts +124 -7
- package/dist/neutral/XyOsBase.d.ts.map +1 -1
- package/dist/neutral/XyOsDapp.d.ts +3 -3
- package/dist/neutral/XyOsDapp.d.ts.map +1 -1
- package/dist/neutral/access/Caller.d.ts +2 -2
- package/dist/neutral/access/Caller.d.ts.map +1 -1
- package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/neutral/adapter/Base.d.ts +2 -2
- package/dist/neutral/adapter/Base.d.ts.map +1 -1
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts +3 -3
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
- package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -1
- package/dist/neutral/classes/menu/Caller.d.ts +1 -2
- package/dist/neutral/classes/menu/Caller.d.ts.map +1 -1
- package/dist/neutral/classes/settings/Caller.d.ts +2 -2
- package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
- package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
- package/dist/neutral/classes/settings/badge/Caller.d.ts +2 -2
- package/dist/neutral/classes/settings/badge/Resource.d.ts +1 -1
- package/dist/neutral/classes/settings/badge/Resource.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -1
- package/dist/neutral/event/bus/Connection.d.ts +3 -4
- package/dist/neutral/event/bus/Connection.d.ts.map +1 -1
- package/dist/neutral/event/bus/EventBus.d.ts +1 -1
- package/dist/neutral/event/bus/EventBus.d.ts.map +1 -1
- package/dist/neutral/event/bus/PubSubConnection.d.ts +1 -1
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +2 -2
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/neutral/helpers/monitor/types.d.ts +3 -3
- package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1042 -694
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/intent/Caller.d.ts +5 -5
- package/dist/neutral/lib/Listener.d.ts +1 -1
- package/dist/neutral/lib/Listener.d.ts.map +1 -1
- package/dist/neutral/lib/PayloadStore.d.ts +1 -2
- package/dist/neutral/lib/PayloadStore.d.ts.map +1 -1
- package/dist/neutral/lib/isPayload.d.ts +1 -1
- package/dist/neutral/loadOsNode.d.ts.map +1 -1
- package/dist/neutral/profileModuleEvents.d.ts +2 -4
- package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
- package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistry.d.ts +4 -6
- package/dist/neutral/registration/DappRegistry.d.ts.map +1 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +7 -3
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts +3 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/neutral/signer/Signers.d.ts.map +1 -1
- package/dist/neutral/stack/Base.d.ts +2 -2
- package/dist/neutral/stack/Base.d.ts.map +1 -1
- package/dist/neutral/stack/Manager.d.ts +2 -6
- package/dist/neutral/stack/Manager.d.ts.map +1 -1
- package/dist/neutral/system/ManageSystemDapps.d.ts +3 -3
- package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -1
- package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts +1 -1
- package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -1
- package/dist/neutral/wallet/SeedPhraseRepository.d.ts +3 -4
- package/dist/neutral/wallet/SeedPhraseRepository.d.ts.map +1 -1
- package/dist/node/Caller.d.ts +18 -20
- package/dist/node/Caller.d.ts.map +1 -1
- package/dist/node/DappCallerBase.d.ts +2 -2
- package/dist/node/DappCallerBase.d.ts.map +1 -1
- package/dist/node/OsCallerBase.d.ts +2 -2
- package/dist/node/PubSubBridgeCaller.d.ts +1 -1
- package/dist/node/PubSubBridgeCaller.d.ts.map +1 -1
- package/dist/node/RunningDappCache.d.ts.map +1 -1
- package/dist/node/XyOs.d.ts +5 -6
- package/dist/node/XyOs.d.ts.map +1 -1
- package/dist/node/XyOsBase.d.ts +124 -7
- package/dist/node/XyOsBase.d.ts.map +1 -1
- package/dist/node/XyOsDapp.d.ts +3 -3
- package/dist/node/XyOsDapp.d.ts.map +1 -1
- package/dist/node/access/Caller.d.ts +2 -2
- package/dist/node/access/Caller.d.ts.map +1 -1
- package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/node/adapter/Base.d.ts +2 -2
- package/dist/node/adapter/Base.d.ts.map +1 -1
- package/dist/node/classes/lib/DappCreatorParams.d.ts +3 -3
- package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/node/classes/lib/Insertable.d.ts +1 -3
- package/dist/node/classes/lib/Insertable.d.ts.map +1 -1
- package/dist/node/classes/menu/Caller.d.ts +1 -2
- package/dist/node/classes/menu/Caller.d.ts.map +1 -1
- package/dist/node/classes/settings/Caller.d.ts +2 -2
- package/dist/node/classes/settings/CallerBase.d.ts +1 -1
- package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
- package/dist/node/classes/settings/badge/Caller.d.ts +2 -2
- package/dist/node/classes/settings/badge/Resource.d.ts +1 -1
- package/dist/node/classes/settings/badge/Resource.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -1
- package/dist/node/event/bus/Connection.d.ts +3 -4
- package/dist/node/event/bus/Connection.d.ts.map +1 -1
- package/dist/node/event/bus/EventBus.d.ts +1 -1
- package/dist/node/event/bus/EventBus.d.ts.map +1 -1
- package/dist/node/event/bus/PubSubConnection.d.ts +1 -1
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts +2 -2
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/node/helpers/monitor/types.d.ts +3 -3
- package/dist/node/helpers/monitor/types.d.ts.map +1 -1
- package/dist/node/index.mjs +1042 -694
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/intent/Caller.d.ts +5 -5
- package/dist/node/lib/Listener.d.ts +1 -1
- package/dist/node/lib/Listener.d.ts.map +1 -1
- package/dist/node/lib/PayloadStore.d.ts +1 -2
- package/dist/node/lib/PayloadStore.d.ts.map +1 -1
- package/dist/node/lib/isPayload.d.ts +1 -1
- package/dist/node/loadOsNode.d.ts.map +1 -1
- package/dist/node/profileModuleEvents.d.ts +2 -4
- package/dist/node/profileModuleEvents.d.ts.map +1 -1
- package/dist/node/registration/DappRegistrationService.d.ts +3 -3
- package/dist/node/registration/DappRegistrationService.d.ts.map +1 -1
- package/dist/node/registration/DappRegistry.d.ts +4 -6
- package/dist/node/registration/DappRegistry.d.ts.map +1 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +7 -3
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts +3 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/scripts/xyos/index.mjs +520 -384
- package/dist/node/scripts/xyos/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/node/signer/Signers.d.ts.map +1 -1
- package/dist/node/stack/Base.d.ts +2 -2
- package/dist/node/stack/Base.d.ts.map +1 -1
- package/dist/node/stack/Manager.d.ts +2 -6
- package/dist/node/stack/Manager.d.ts.map +1 -1
- package/dist/node/system/ManageSystemDapps.d.ts +3 -3
- package/dist/node/system/ManageSystemDapps.d.ts.map +1 -1
- package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts +1 -1
- package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -1
- package/dist/node/wallet/SeedPhraseRepository.d.ts +3 -4
- package/dist/node/wallet/SeedPhraseRepository.d.ts.map +1 -1
- package/package.json +165 -55
- package/dist/neutral/signer/Signer.spec.d.ts +0 -2
- package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
- package/dist/neutral/spec/boot.spec.d.ts +0 -2
- package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
- package/dist/node/signer/Signer.spec.d.ts +0 -2
- package/dist/node/signer/Signer.spec.d.ts.map +0 -1
- package/dist/node/spec/boot.spec.d.ts +0 -2
- package/dist/node/spec/boot.spec.d.ts.map +0 -1
- package/src/Caller.ts +0 -202
- package/src/DappCallerBase.ts +0 -56
- package/src/DefaultsQueries.ts +0 -27
- package/src/OsCallerBase.ts +0 -59
- package/src/PubSubBridgeCaller.ts +0 -33
- package/src/RunningDappCache.ts +0 -58
- package/src/XyOs.ts +0 -166
- package/src/XyOsBase.ts +0 -136
- package/src/XyOsDapp.ts +0 -103
- package/src/access/Caller.ts +0 -85
- package/src/access/Queries.ts +0 -38
- package/src/access/Resource.ts +0 -65
- package/src/access/RunningAccessDappCache.ts +0 -21
- package/src/access/index.ts +0 -4
- package/src/access/interfaces/index.ts +0 -1
- package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
- package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
- package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
- package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
- package/src/access/interfaces/registered-names/index.ts +0 -1
- package/src/adapter/Base.ts +0 -104
- package/src/adapter/Network.ts +0 -31
- package/src/adapter/Settings.ts +0 -30
- package/src/adapter/index.ts +0 -2
- package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
- package/src/adapters/OsSettings.ts +0 -7
- package/src/adapters/OsXyoPublicNetwork.ts +0 -9
- package/src/adapters/index.ts +0 -3
- package/src/classes/dapp/DefaultsResource.ts +0 -67
- package/src/classes/dapp/index.ts +0 -1
- package/src/classes/index.ts +0 -4
- package/src/classes/lib/DappCreatorParams.ts +0 -18
- package/src/classes/lib/Insertable.ts +0 -10
- package/src/classes/lib/index.ts +0 -2
- package/src/classes/menu/Caller.ts +0 -77
- package/src/classes/menu/Queries.ts +0 -60
- package/src/classes/menu/Resource.ts +0 -105
- package/src/classes/menu/index.ts +0 -2
- package/src/classes/settings/Caller.ts +0 -78
- package/src/classes/settings/CallerBase.ts +0 -27
- package/src/classes/settings/Resource.ts +0 -81
- package/src/classes/settings/SettingsQueries.ts +0 -56
- package/src/classes/settings/badge/Caller.ts +0 -30
- package/src/classes/settings/badge/Queries.ts +0 -19
- package/src/classes/settings/badge/Resource.ts +0 -50
- package/src/classes/settings/badge/index.ts +0 -2
- package/src/classes/settings/index.ts +0 -5
- package/src/dapp/context/creator/Creator.ts +0 -122
- package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
- package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
- package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
- package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
- package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
- package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
- package/src/dapp/context/creator/createDappContext.ts +0 -61
- package/src/dapp/context/creator/index.ts +0 -3
- package/src/dapp/context/index.ts +0 -1
- package/src/dapp/index.ts +0 -1
- package/src/event/bus/Connection.ts +0 -33
- package/src/event/bus/EventBus.ts +0 -159
- package/src/event/bus/PubSubConnection.ts +0 -28
- package/src/event/bus/index.ts +0 -3
- package/src/event/connections/DappAccessRequest.ts +0 -11
- package/src/event/connections/DappsReady.ts +0 -9
- package/src/event/connections/ExposeDappRequest.ts +0 -11
- package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
- package/src/event/connections/OsSettingsReady.ts +0 -12
- package/src/event/connections/OsXyoPublicReady.ts +0 -12
- package/src/event/connections/index.ts +0 -6
- package/src/event/index.ts +0 -2
- package/src/helpers/index.ts +0 -1
- package/src/helpers/monitor/XyOsMonitor.ts +0 -52
- package/src/helpers/monitor/index.ts +0 -2
- package/src/helpers/monitor/types.ts +0 -8
- package/src/index.ts +0 -29
- package/src/initializer/DappInitializer.ts +0 -57
- package/src/initializer/index.ts +0 -1
- package/src/intent/Caller.ts +0 -74
- package/src/intent/Resource.ts +0 -66
- package/src/intent/index.ts +0 -2
- package/src/lib/ExternalStore.ts +0 -7
- package/src/lib/Listener.ts +0 -1
- package/src/lib/ModuleAccountPaths.ts +0 -23
- package/src/lib/ModuleNames.ts +0 -3
- package/src/lib/NameTransforms.ts +0 -34
- package/src/lib/PayloadStore.ts +0 -106
- package/src/lib/ResourceStores.ts +0 -7
- package/src/lib/index.ts +0 -11
- package/src/lib/initializeXns.ts +0 -16
- package/src/lib/isEqual.ts +0 -42
- package/src/lib/isPayload.ts +0 -24
- package/src/lib/tokenPlacesSplit.ts +0 -17
- package/src/loadOsNode.ts +0 -44
- package/src/manifest/index.ts +0 -2
- package/src/manifest/manifestReplacementTokens.ts +0 -6
- package/src/manifest/os-node.manifest.json +0 -132
- package/src/manifests/dapp-window.manifest.json +0 -36
- package/src/manifests/index.ts +0 -1
- package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
- package/src/models/access/index.ts +0 -1
- package/src/models/index.ts +0 -1
- package/src/profileModuleEvents.ts +0 -43
- package/src/registration/DappRegistrationService.ts +0 -179
- package/src/registration/DappRegistry.ts +0 -131
- package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
- package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
- package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
- package/src/registration/index.ts +0 -2
- package/src/scripts/xyos/command/config.ts +0 -19
- package/src/scripts/xyos/command/create.ts +0 -22
- package/src/scripts/xyos/command/index.ts +0 -7
- package/src/scripts/xyos/command/manifest.ts +0 -19
- package/src/scripts/xyos/command/start.ts +0 -35
- package/src/scripts/xyos/index.ts +0 -32
- package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
- package/src/scripts/xyos/lib/headless.ts +0 -68
- package/src/scripts/xyos/lib/index.ts +0 -2
- package/src/signer/Signer.spec.ts +0 -65
- package/src/signer/Signers.ts +0 -74
- package/src/signer/index.ts +0 -1
- package/src/spec/boot.spec.ts +0 -89
- package/src/stack/Base.ts +0 -166
- package/src/stack/Manager.ts +0 -51
- package/src/stack/Map.ts +0 -22
- package/src/stack/OsPubSubNetworkStack.ts +0 -70
- package/src/stack/OsSettingsStack.ts +0 -24
- package/src/stack/XyoPublicNetworkStack.ts +0 -32
- package/src/stack/index.ts +0 -6
- package/src/system/ManageSystemDapps.ts +0 -148
- package/src/system/Queries.ts +0 -69
- package/src/system/index.ts +0 -1
- package/src/types/global.d.ts +0 -9
- package/src/types/images.d.ts +0 -5
- package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
- package/src/utils/getApiDomain.ts +0 -14
- package/src/utils/index.ts +0 -3
- package/src/utils/renameObjKey.ts +0 -22
- package/src/wallet/DappSeedPhraseRepository.ts +0 -99
- package/src/wallet/SeedPhraseRepository.ts +0 -32
- package/src/wallet/index.ts +0 -2
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
2
|
-
import type {
|
|
3
|
-
DappId, DappWalletSeedPhrase, WalletId, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
import { DappWalletSeedPhraseSchema } from '@xyo-network/os-model'
|
|
6
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
7
|
-
import { v4 as uuid } from 'uuid'
|
|
8
|
-
|
|
9
|
-
import { OsCallerBase } from '../OsCallerBase.ts'
|
|
10
|
-
import type { SeedPhraseId, SeedPhraseRepository } from './SeedPhraseRepository.ts'
|
|
11
|
-
|
|
12
|
-
export class DappSeedPhraseRepository extends OsCallerBase implements SeedPhraseRepository {
|
|
13
|
-
protected readonly allowedNames: string[]
|
|
14
|
-
|
|
15
|
-
// record of all dapps that have requested a seed phrase with the OS
|
|
16
|
-
private dappIdRepository = new Map<SeedPhraseId, DappWalletSeedPhrase>()
|
|
17
|
-
// record of all walletIds that have been issued to registered dapps
|
|
18
|
-
private walletIdRepository = new Map<WalletId, DappWalletSeedPhrase>()
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
xyOs: XyOsContext,
|
|
22
|
-
allowedNames: string[],
|
|
23
|
-
) {
|
|
24
|
-
super(xyOs)
|
|
25
|
-
this.allowedNames = allowedNames
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async add(dappId: DappId): Promise<string> {
|
|
29
|
-
const archivist = await this.getDappsArchivist()
|
|
30
|
-
const seedPhrase = this.newPhrase()
|
|
31
|
-
const walletId = uuid()
|
|
32
|
-
const payload: DappWalletSeedPhrase = {
|
|
33
|
-
dappId,
|
|
34
|
-
schema: DappWalletSeedPhraseSchema,
|
|
35
|
-
seedPhrase,
|
|
36
|
-
walletId,
|
|
37
|
-
}
|
|
38
|
-
await archivist.insert([payload])
|
|
39
|
-
this.dappIdRepository.set(dappId, payload)
|
|
40
|
-
this.walletIdRepository.set(walletId, payload)
|
|
41
|
-
return walletId
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async findOrCreate(dappName: string): Promise<WalletId> {
|
|
45
|
-
if (this.allowedNames.includes(dappName)) {
|
|
46
|
-
const existingPayload = await this.checkDappId(dappName)
|
|
47
|
-
if (existingPayload) return existingPayload.walletId
|
|
48
|
-
|
|
49
|
-
// new dapp request so generate a new wallet Id and return it
|
|
50
|
-
try {
|
|
51
|
-
await this.add(dappName)
|
|
52
|
-
const existingPayload = await this.checkDappId(dappName)
|
|
53
|
-
if (existingPayload) return existingPayload.walletId
|
|
54
|
-
throw new Error(`failed to add seed phrase: ${dappName}`)
|
|
55
|
-
} catch (e) {
|
|
56
|
-
console.error(e)
|
|
57
|
-
throw new Error(`failed to add seed phrase: ${dappName}`)
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
throw new Error(`${dappName} is not allowed to register a seed phase. NOTE: this is a safeguard till 3rd party dApps can be validated`)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async request(walletId: WalletId) {
|
|
65
|
-
return (await this.checkWalletId(walletId))?.seedPhrase
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private async checkDappId(dappId: DappId) {
|
|
69
|
-
const diviner = await this.getDappsArchivistPayloadDiviner()
|
|
70
|
-
const query = {
|
|
71
|
-
dappId,
|
|
72
|
-
limit: 1,
|
|
73
|
-
order: 'desc',
|
|
74
|
-
schema: PayloadDivinerQuerySchema,
|
|
75
|
-
schemas: [DappWalletSeedPhraseSchema],
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const results = (await diviner.divine([query])) as DappWalletSeedPhrase[]
|
|
79
|
-
return results.length > 0 ? results[0] : undefined
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private async checkWalletId(walletId: WalletId) {
|
|
83
|
-
const diviner = await this.getDappsArchivistPayloadDiviner()
|
|
84
|
-
const query = {
|
|
85
|
-
limit: 1,
|
|
86
|
-
order: 'desc',
|
|
87
|
-
schema: PayloadDivinerQuerySchema,
|
|
88
|
-
schemas: [DappWalletSeedPhraseSchema],
|
|
89
|
-
walletId,
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const results = (await diviner.divine([query])) as DappWalletSeedPhrase[]
|
|
93
|
-
return results.length > 0 ? results[0] : undefined
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private newPhrase(): string {
|
|
97
|
-
return HDWallet.generateMnemonic()
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
package/src/wallet/index.ts
DELETED