@xyo-network/os-runtime 3.0.0 → 3.0.2
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/index.d.ts +2 -2
- package/dist/neutral/index.mjs +264 -102
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +28 -28
- package/src/Caller.ts +5 -2
- package/src/DefaultsQueries.ts +6 -2
- package/src/XyOs.ts +20 -9
- package/src/XyOsBase.ts +10 -3
- package/src/XyOsDapp.ts +9 -3
- package/src/access-interfaces/ValidDappAccessInterfaces.ts +4 -4
- package/src/access-interfaces/registered-names/helpers/AccessNodeQueries.ts +6 -2
- package/src/access-interfaces/registered-names/helpers/resource/RegistrationsResource.ts +8 -8
- package/src/adapter/Base.ts +11 -3
- package/src/adapters/OsPubSubBridgeNetwork.ts +3 -1
- package/src/classes/cache/RunningDappCache.ts +16 -4
- package/src/classes/dapp/DefaultsResource.ts +9 -3
- package/src/classes/dapp/access/Caller.ts +5 -4
- package/src/classes/dapp/access/Queries.ts +6 -2
- package/src/classes/dapp/access/Resource.ts +9 -3
- package/src/classes/lib/DappCreatorParams.ts +3 -1
- package/src/classes/lib/Insertable.ts +5 -7
- package/src/classes/menu/Caller.ts +5 -2
- package/src/classes/menu/Queries.ts +5 -2
- package/src/classes/menu/Resource.ts +12 -4
- package/src/classes/node/Creator.ts +19 -7
- package/src/classes/node/DefaultPayloads/DappAccessPayloads.ts +3 -1
- package/src/classes/node/DefaultPayloads/DefaultPayloads.ts +3 -1
- package/src/classes/node/DefaultPayloads/NodeInfoPayload.ts +3 -1
- package/src/classes/node/DefaultPayloads/SigningKeyPayloads.ts +9 -10
- package/src/classes/node/ExternalModulePermissions/ExternalModulePermissions.ts +6 -2
- package/src/classes/node/createDappContext.ts +16 -4
- package/src/classes/registration/DappRegistrationService.ts +25 -7
- package/src/classes/registration/DappRegistry.ts +16 -8
- package/src/classes/registration/ValidateDappAccessDiviner/Config.ts +10 -3
- package/src/classes/registration/ValidateDappAccessDiviner/Diviner.ts +14 -8
- package/src/classes/settings/Caller.ts +3 -1
- package/src/classes/settings/Resource.ts +9 -3
- package/src/classes/settings/SettingsQueries.ts +6 -2
- package/src/classes/settings/badge/Resource.ts +5 -7
- package/src/classes/system/ManageSystemDapps.ts +7 -2
- package/src/classes/system/Queries.ts +2 -1
- package/src/event/bus/Connection.ts +3 -1
- package/src/event/bus/EventBus.ts +13 -4
- package/src/helpers/monitor/XyOsMonitor.ts +9 -7
- package/src/helpers/monitor/types.ts +4 -1
- package/src/intent/Caller.ts +6 -2
- package/src/intent/Resource.ts +6 -2
- package/src/lib/ModuleAccountPaths.ts +6 -10
- package/src/lib/PayloadStore.ts +9 -3
- package/src/lib/isPayload.ts +3 -1
- package/src/manifest/ManifestReplaceableTokens.ts +4 -3
- package/src/profileModuleEvents.ts +6 -2
- package/src/stack/Base.ts +18 -6
- package/src/stack/Manager.ts +8 -8
- package/src/stack/Map.ts +3 -1
- package/src/stack/OsPubSubNetworkStack.ts +12 -4
- package/src/stack/OsSettingsStack.ts +6 -2
- package/src/stack/XyoPublicNetworkStack.ts +6 -2
- package/src/utils/buildWalletSeedPhrasePayload.ts +22 -6
- package/src/wallet/DappSeedPhraseRepository.ts +6 -2
package/src/stack/Base.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type { ModuleIdentifier } from '@xyo-network/module-model'
|
|
|
6
6
|
import { isModuleInstance } from '@xyo-network/module-model'
|
|
7
7
|
import type { AttachableNodeInstance } from '@xyo-network/node-model'
|
|
8
8
|
import { asAttachableNodeInstance } from '@xyo-network/node-model'
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
AdapterSetCreator, NodeAdapter, NodeAdapterBaseEvents, StackBaseEvents, StackInitializer, XyOsContext,
|
|
11
|
+
} from '@xyo-network/os-model'
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Stack Base Class
|
|
@@ -33,8 +35,12 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
33
35
|
|
|
34
36
|
// list of listeners - lister type not important since its only recalled to stop listening
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
private listeners: {
|
|
39
|
+
adapter: NodeAdapter
|
|
40
|
+
eventName: string
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
listener: (args: any) => void
|
|
43
|
+
}[] = []
|
|
38
44
|
|
|
39
45
|
constructor(context: XyOsContext, adapterSet: AdapterSetCreator, stackNodeModuleId: ModuleIdentifier) {
|
|
40
46
|
super({})
|
|
@@ -66,7 +72,9 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
66
72
|
// listen for driver ready events
|
|
67
73
|
const driverReadyListener = async ({ node }: NodeAdapterBaseEvents['driverReady']) => await this.handleDriverReady(node)
|
|
68
74
|
adapter.on('driverReady', driverReadyListener)
|
|
69
|
-
this.listeners.push({
|
|
75
|
+
this.listeners.push({
|
|
76
|
+
adapter: adapter, eventName: 'driverReady', listener: driverReadyListener,
|
|
77
|
+
})
|
|
70
78
|
|
|
71
79
|
// listen for driver error events
|
|
72
80
|
const driverErrorListener = async ({ error }: NodeAdapterBaseEvents['driverError']) => {
|
|
@@ -74,7 +82,9 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
74
82
|
await this.emit('driverError', { error })
|
|
75
83
|
}
|
|
76
84
|
adapter.on('driverError', driverErrorListener)
|
|
77
|
-
this.listeners.push({
|
|
85
|
+
this.listeners.push({
|
|
86
|
+
adapter: adapter, eventName: 'driverError', listener: driverErrorListener,
|
|
87
|
+
})
|
|
78
88
|
|
|
79
89
|
// start the adapter
|
|
80
90
|
const startAdapter = async () => await adapter.start()
|
|
@@ -86,7 +96,9 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
86
96
|
* Stops the stack
|
|
87
97
|
*/
|
|
88
98
|
stop() {
|
|
89
|
-
for (const {
|
|
99
|
+
for (const {
|
|
100
|
+
eventName, listener, adapter,
|
|
101
|
+
} of this.listeners) {
|
|
90
102
|
// stop the adapter
|
|
91
103
|
adapter.off(eventName, listener)
|
|
92
104
|
}
|
package/src/stack/Manager.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AdapterSetCreator, StackInitializer, XyOsContext,
|
|
3
|
+
} from '@xyo-network/os-model'
|
|
2
4
|
|
|
3
5
|
import type { StackBase } from './Base.ts'
|
|
4
6
|
|
|
5
|
-
export interface StackConstructor {
|
|
6
|
-
new (context: XyOsContext, adapters: AdapterSetCreator): StackBase
|
|
7
|
-
}
|
|
7
|
+
export interface StackConstructor { new (context: XyOsContext, adapters: AdapterSetCreator): StackBase }
|
|
8
8
|
|
|
9
9
|
export interface UninitializedStackSet {
|
|
10
10
|
adapters: AdapterSetCreator
|
|
11
11
|
stack: StackConstructor
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface UninitializedStackMap {
|
|
15
|
-
[key: string]: UninitializedStackSet
|
|
16
|
-
}
|
|
14
|
+
export interface UninitializedStackMap { [key: string]: UninitializedStackSet }
|
|
17
15
|
|
|
18
16
|
export class StackManager {
|
|
19
17
|
private initializedStacksMap: Map<string, StackInitializer> = new Map()
|
|
@@ -33,7 +31,9 @@ export class StackManager {
|
|
|
33
31
|
|
|
34
32
|
initialize(context: XyOsContext) {
|
|
35
33
|
for (const [key, stackSet] of Object.entries(this.stackMap)) {
|
|
36
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
stack: Stack, adapters: stackNodeModuleId,
|
|
36
|
+
} = stackSet
|
|
37
37
|
const initializedStack = new Stack(context, stackNodeModuleId)
|
|
38
38
|
initializedStack.initialize()
|
|
39
39
|
this.stacks.set(key, initializedStack)
|
package/src/stack/Map.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
OsPubSubBridgeNetworkAdapters, OsSettingsAdapters, OsXyoPublicNetworkAdapters,
|
|
3
|
+
} from '../adapters/index.ts'
|
|
2
4
|
import type { UninitializedStackMap } from './Manager.ts'
|
|
3
5
|
import { OsPubSubNetworkStack } from './OsPubSubNetworkStack.ts'
|
|
4
6
|
import { OsSettingsStack } from './OsSettingsStack.ts'
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import type { NodeInstance } from '@xyo-network/node-model'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
asAttachableNodeInstance, asNodeInstance,
|
|
5
|
+
} from '@xyo-network/node-model'
|
|
6
|
+
import type {
|
|
7
|
+
AdapterSetCreator, XyOsContext,
|
|
8
|
+
} from '@xyo-network/os-model'
|
|
9
|
+
import {
|
|
10
|
+
ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName,
|
|
11
|
+
} from '@xyo-network/os-model'
|
|
6
12
|
|
|
7
13
|
import type { EventBusPubSubConnection } from '../event/index.ts'
|
|
8
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
osPubSubNetworkReadyConnection, OsPubSubNetworkReadyEvent,
|
|
16
|
+
} from '../event/index.ts'
|
|
9
17
|
import { initializeXns } from '../lib/index.ts'
|
|
10
18
|
import { StackBase } from './Base.ts'
|
|
11
19
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AdapterSetCreator, XyOsContext,
|
|
3
|
+
} from '@xyo-network/os-model'
|
|
2
4
|
|
|
3
5
|
import type { EventBusPubSubConnection } from '../event/index.ts'
|
|
4
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
osSettingsReadyConnection, OsSettingsReadyEvent,
|
|
8
|
+
} from '../event/index.ts'
|
|
5
9
|
import { StackBase } from './Base.ts'
|
|
6
10
|
|
|
7
11
|
export class OsSettingsStack extends StackBase {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AdapterSetCreator, XyOsContext,
|
|
3
|
+
} from '@xyo-network/os-model'
|
|
2
4
|
import { XyoPublicNodeName } from '@xyo-network/os-model'
|
|
3
5
|
|
|
4
6
|
import type { EventBusPubSubConnection } from '../event/index.ts'
|
|
5
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
osXyoPublicNetworkReadyConnection, OsXyoPublicNetworkReadyEvent,
|
|
9
|
+
} from '../event/index.ts'
|
|
6
10
|
import { StackBase } from './Base.ts'
|
|
7
11
|
|
|
8
12
|
export class XyoPublicNetworkStack extends StackBase {
|
|
@@ -22,13 +22,26 @@ export type WalletLabel = typeof userWalletLabel // TODO: More wallet types 'osW
|
|
|
22
22
|
* @param label The wallet label
|
|
23
23
|
* @returns A WalletSeedPhrase payload and its root hash
|
|
24
24
|
*/
|
|
25
|
-
export const buildWalletSeedPhrasePayload = async (mnemonic: string, label: WalletLabel): Promise<{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
export const buildWalletSeedPhrasePayload = async (mnemonic: string, label: WalletLabel): Promise<{
|
|
26
|
+
payload: WalletSeedPhrase
|
|
27
|
+
rootHash: Hash
|
|
28
|
+
}> => {
|
|
29
|
+
const fields = {
|
|
30
|
+
mnemonic: {
|
|
31
|
+
language, mnemonic: mnemonic.split(' '), standard,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
const meta = {
|
|
35
|
+
label, timestamp: Date.now(),
|
|
36
|
+
}
|
|
37
|
+
const builder = new PayloadBuilder<WalletSeedPhrase>({
|
|
38
|
+
fields, meta, schema: WalletSeedPhraseSchema,
|
|
39
|
+
})
|
|
29
40
|
const payload = await builder.build()
|
|
30
41
|
const rootHash = await PayloadBuilder.hash(payload)
|
|
31
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
payload, rootHash,
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
/**
|
|
@@ -36,6 +49,9 @@ export const buildWalletSeedPhrasePayload = async (mnemonic: string, label: Wall
|
|
|
36
49
|
* @param mnemonic The mnemonic seed phrase
|
|
37
50
|
* @returns A user WalletSeedPhrase payload and its root hash
|
|
38
51
|
*/
|
|
39
|
-
export const buildUserWalletSeedPhrasePayload = (mnemonic: string): Promise<{
|
|
52
|
+
export const buildUserWalletSeedPhrasePayload = (mnemonic: string): Promise<{
|
|
53
|
+
payload: WalletSeedPhrase
|
|
54
|
+
rootHash: Hash
|
|
55
|
+
}> => {
|
|
40
56
|
return buildWalletSeedPhrasePayload(mnemonic, userWalletLabel)
|
|
41
57
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { HDWallet } from '@xyo-network/account'
|
|
2
2
|
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
DappId, DappWalletSeedPhrase, WalletId, XyOsContext,
|
|
5
|
+
} from '@xyo-network/os-model'
|
|
4
6
|
import { DappWalletSeedPhraseSchema } from '@xyo-network/os-model'
|
|
5
7
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
6
8
|
import { v4 as uuid } from 'uuid'
|
|
7
9
|
|
|
8
10
|
import { OsCallerBase } from '../OsCallerBase.ts'
|
|
9
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
SeedPhraseId, SeedPhraseRepository,
|
|
13
|
+
} from './SeedPhraseRepository.ts'
|
|
10
14
|
|
|
11
15
|
export class DappSeedPhraseRepository extends OsCallerBase implements SeedPhraseRepository {
|
|
12
16
|
// record of all dapps that have requested a seed phrase with the OS
|