@xyo-network/os-runtime 3.0.10 → 3.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/os-runtime",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -39,8 +39,8 @@
39
39
  "@xyo-network/archivist": "^3.0.7",
40
40
  "@xyo-network/archivist-indexeddb": "^3.0.7",
41
41
  "@xyo-network/archivist-model": "^3.0.7",
42
- "@xyo-network/bios": "^3.0.10",
43
- "@xyo-network/bios-model": "^3.0.10",
42
+ "@xyo-network/bios": "^3.0.11",
43
+ "@xyo-network/bios-model": "^3.0.11",
44
44
  "@xyo-network/bridge-model": "^3.0.5",
45
45
  "@xyo-network/diviner-abstract": "^3.0.5",
46
46
  "@xyo-network/diviner-model": "^3.0.5",
@@ -48,8 +48,8 @@
48
48
  "@xyo-network/diviner-payload-indexeddb": "^3.0.5",
49
49
  "@xyo-network/diviner-payload-model": "^3.0.5",
50
50
  "@xyo-network/diviner-temporal-indexing-model": "^3.0.5",
51
- "@xyo-network/kernel": "^3.0.10",
52
- "@xyo-network/kernel-model": "^3.0.10",
51
+ "@xyo-network/kernel": "^3.0.11",
52
+ "@xyo-network/kernel-model": "^3.0.11",
53
53
  "@xyo-network/manifest": "^3.0.7",
54
54
  "@xyo-network/manifest-wrapper": "^3.0.7",
55
55
  "@xyo-network/module-abstract": "^3.0.7",
@@ -58,7 +58,7 @@
58
58
  "@xyo-network/module-model": "^3.0.7",
59
59
  "@xyo-network/module-resolver": "^3.0.7",
60
60
  "@xyo-network/node-model": "^3.0.7",
61
- "@xyo-network/os-model": "^3.0.10",
61
+ "@xyo-network/os-model": "^3.0.11",
62
62
  "@xyo-network/payload-builder": "^3.0.7",
63
63
  "@xyo-network/payload-model": "^3.0.7",
64
64
  "@xyo-network/wallet-model": "^3.0.7",
@@ -72,7 +72,7 @@
72
72
  "@types/uuid": "^10.0.0",
73
73
  "@xylabs/ts-scripts-yarn3": "^4.0.0",
74
74
  "@xylabs/tsconfig": "^4.0.0",
75
- "@xyo-network/bios-nodejs": "^3.0.10",
75
+ "@xyo-network/bios-nodejs": "^3.0.11",
76
76
  "typescript": "^5.5.4",
77
77
  "vitest": "^2.0.5"
78
78
  },
package/src/XyOs.ts CHANGED
@@ -10,6 +10,7 @@ import type {
10
10
  DappId,
11
11
  DappPackageManifestPayload,
12
12
  DappParams,
13
+ SignersExternal,
13
14
  StackInitializer,
14
15
  XyOsContext,
15
16
  XyOsDappContext,
@@ -17,6 +18,7 @@ import type {
17
18
  } from '@xyo-network/os-model'
18
19
  import type { WalletInstance } from '@xyo-network/wallet-model'
19
20
 
21
+ import { Signers } from './classes/index.ts'
20
22
  import type { DappRegistrationServiceParams } from './classes/registration/index.ts'
21
23
  import { DappRegistrationService } from './classes/registration/index.ts'
22
24
  import { EventBus } from './event/index.ts'
@@ -41,6 +43,7 @@ export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
41
43
  protected _kernel: KernelExternal
42
44
  protected _locator: ModuleFactoryLocator
43
45
  protected dappRegistrationService: DappRegistrationService
46
+ protected signers: SignersExternal | undefined
44
47
  private stackManager: StackManager
45
48
 
46
49
  constructor({
@@ -59,6 +62,7 @@ export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
59
62
  this._kernel = kernel
60
63
  this.stackManager = new StackManager(stackMap)
61
64
  this.dappRegistrationService = new DappRegistrationService(this, dappsConfiguration, this.locator, developmentMode)
65
+ if (this.signerPaths && this.kernel?.bios?.seedPhraseStore) this.signers = new Signers(this.signerPaths, this.kernel?.bios?.seedPhraseStore)
62
66
  }
63
67
 
64
68
  static get monitoring(): XyOsMonitor | undefined {
@@ -93,6 +97,10 @@ export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
93
97
  return this.stackManager.stacks
94
98
  }
95
99
 
100
+ override get user() {
101
+ return { signers: this.signers?.getWalletKindSigner('user') }
102
+ }
103
+
96
104
  static async monitor<T>(fn: () => Promise<T>, eventConfig: MonitorEventConfig): Promise<T> {
97
105
  const { name, additionalProperties } = eventConfig
98
106
  const monitor = this.monitoring
@@ -119,6 +127,7 @@ export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
119
127
  this._root = root
120
128
 
121
129
  this.stackManager.initialize(this)
130
+ if (this.signers) await this.signers.initialize()
122
131
  })
123
132
  }
124
133
 
package/src/XyOsBase.ts CHANGED
@@ -8,7 +8,8 @@ import { BaseEmitter } from '@xyo-network/module-abstract'
8
8
  import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
9
9
  import type { NodeInstance } from '@xyo-network/node-model'
10
10
  import type {
11
- DappId, DappPackageManifestPayload, DappParams, EventBusInterface, StackInitializer, XyOsContext, XyOsDappContext,
11
+ DappId, DappPackageManifestPayload, DappParams, EventBusInterface, OsUser,
12
+ StackInitializer, WalletKindSignerPaths, XyOsContext, XyOsDappContext,
12
13
  } from '@xyo-network/os-model'
13
14
  import { Mutex } from 'async-mutex'
14
15
 
@@ -17,6 +18,7 @@ export interface XyOsContextParams<TManifest extends PackageManifest = PackageMa
17
18
  locator?: ModuleFactoryLocator
18
19
  manifest?: TManifest
19
20
  platformLocator?: ModuleFactoryLocator
21
+ signerPaths?: WalletKindSignerPaths
20
22
  }
21
23
 
22
24
  export class XyOsContextBase<TParams extends XyOsContextParams | void = void> extends BaseEmitter<
@@ -71,10 +73,18 @@ export class XyOsContextBase<TParams extends XyOsContextParams | void = void> ex
71
73
  return []
72
74
  }
73
75
 
76
+ get signerPaths() {
77
+ return this.params.signerPaths
78
+ }
79
+
74
80
  get state() {
75
81
  return this._root ? 'running' : 'stopped'
76
82
  }
77
83
 
84
+ get user(): OsUser {
85
+ throw new Error('Method not implemented. [user]')
86
+ }
87
+
78
88
  boot(_wallet: WalletInstance, _locator: ModuleFactoryLocator) {
79
89
  throw new Error('Method not implemented. [boot]')
80
90
  }
package/src/XyOsDapp.ts CHANGED
@@ -3,7 +3,7 @@ import type { WalletInstance } from '@xyo-network/account'
3
3
  import { ManifestWrapper } from '@xyo-network/manifest-wrapper'
4
4
  import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
5
5
  import type {
6
- DappPackageManifestPayload, XyOsContext, XyOsDappContext, XyOsDappDetails,
6
+ DappPackageManifestPayload, OsUser, XyOsContext, XyOsDappContext, XyOsDappDetails,
7
7
  } from '@xyo-network/os-model'
8
8
  import { DappPackageManifestPayloadSchema } from '@xyo-network/os-model'
9
9
 
@@ -15,6 +15,7 @@ export interface XyOsDappContextParams extends XyOsContextParams<DappPackageMani
15
15
  dapp: XyOsDappDetails
16
16
  locator: ModuleFactoryLocator
17
17
  parent: XyOsContext
18
+ user: OsUser
18
19
  }
19
20
 
20
21
  export class XyOsDapp extends XyOsContextBase<XyOsDappContextParams> implements XyOsDappContext {
@@ -56,6 +57,10 @@ export class XyOsDapp extends XyOsContextBase<XyOsDappContextParams> implements
56
57
  return []
57
58
  }
58
59
 
60
+ override get user() {
61
+ return this.params.user
62
+ }
63
+
59
64
  override async boot(wallet: WalletInstance, locator?: ModuleFactoryLocator): Promise<void> {
60
65
  return await this._bootMutex.runExclusive(async () => {
61
66
  console.log('XyOsDapp:boot:start', wallet.address, this.dapp.id)
@@ -76,16 +76,17 @@ export class DappRegistrationService {
76
76
  this.addConnectionRequests()
77
77
  }
78
78
 
79
- buildDapp(
79
+ async buildDapp(
80
80
  manifest: DappPackageManifestPayload,
81
81
  dappId = NameTransforms.slug(manifest.nodes[0]?.config.name),
82
82
  name = NameTransforms.moduleName(manifest.nodes[0]?.config.name),
83
- ): Promisable<XyOsDappContext> {
83
+ ): Promise<XyOsDappContext> {
84
84
  const dapp = new XyOsDapp({
85
85
  dapp: { id: dappId, name },
86
86
  locator: this.locator,
87
87
  manifest,
88
88
  parent: this.context,
89
+ user: await this.getUser(),
89
90
  }) as XyOsDappContext
90
91
  this.builtDapps[dappId] = dapp
91
92
  return dapp
@@ -130,6 +131,14 @@ export class DappRegistrationService {
130
131
  this.context.eventBus.addConnection(this.exposeDappRequestConnection)
131
132
  }
132
133
 
134
+ /**
135
+ * A method to get the user property from context and eventually modify it before handing it to a dapp
136
+ * i.e. curating user-approved signers
137
+ */
138
+ private getUser(): Promisable<XyOsContext['user']> {
139
+ return this.context.user
140
+ }
141
+
133
142
  private async postRegistrationHandlers(registeredDapp: RegisteredDappSetResult) {
134
143
  if (registeredDapp.dapp) {
135
144
  if (isRegisteredDappExposedDappSet(registeredDapp)) {
@@ -35,6 +35,10 @@ export class Signers implements SignersExternal {
35
35
  return this.signerAccounts.get(walletKind)?.get(signer)
36
36
  }
37
37
 
38
+ getWalletKindSigner(walletKind: WalletKind): SignerAccounts | undefined {
39
+ return this.signerAccounts.get(walletKind)
40
+ }
41
+
38
42
  async initialize() {
39
43
  for (const [walletKindName, signerPaths] of this.paths) {
40
44
  for (const [signerName, walletPath] of signerPaths.entries()) {