@xyo-network/os-runtime 4.1.1 → 4.1.3
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/DappCallerBase.d.ts +2 -2
- package/dist/neutral/OsCallerBase.d.ts +2 -2
- package/dist/neutral/XyOs.d.ts +2 -2
- package/dist/neutral/XyOsDapp.d.ts +2 -2
- package/dist/neutral/access-interfaces/registered-names/helpers/AccessNodeQueries.d.ts +1 -1
- package/dist/neutral/access-interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/neutral/adapter/Network.d.ts +1 -1
- package/dist/neutral/adapter/Settings.d.ts +1 -1
- package/dist/neutral/classes/cache/RunningAccessDappCache.d.ts +1 -1
- package/dist/neutral/classes/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
- package/dist/neutral/index.mjs +989 -640
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/stack/OsPubSubNetworkStack.d.ts +2 -2
- package/dist/node/DappCallerBase.d.ts +2 -2
- package/dist/node/OsCallerBase.d.ts +2 -2
- package/dist/node/XyOs.d.ts +2 -2
- package/dist/node/XyOsDapp.d.ts +2 -2
- package/dist/node/access-interfaces/registered-names/helpers/AccessNodeQueries.d.ts +1 -1
- package/dist/node/access-interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/node/adapter/Network.d.ts +1 -1
- package/dist/node/adapter/Settings.d.ts +1 -1
- package/dist/node/classes/cache/RunningAccessDappCache.d.ts +1 -1
- package/dist/node/classes/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/classes/settings/CallerBase.d.ts +1 -1
- package/dist/node/index.mjs +989 -640
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/command/index.mjs +486 -345
- package/dist/node/scripts/xyos/command/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/index.mjs +487 -360
- package/dist/node/scripts/xyos/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/lib/index.mjs +453 -327
- package/dist/node/scripts/xyos/lib/index.mjs.map +1 -1
- package/dist/node/stack/OsPubSubNetworkStack.d.ts +2 -2
- package/package.json +36 -37
- package/src/classes/registration/ValidateDappAccessDiviner/Diviner.ts +6 -7
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/scripts/xyos/command/config.ts
|
|
2
|
-
var commandConfig = (argv) => {
|
|
5
|
+
var commandConfig = /* @__PURE__ */ __name((argv) => {
|
|
3
6
|
return argv.command("config [action] <target>", "Create an xyos project", (yargs) => {
|
|
4
7
|
return yargs.positional("action", {
|
|
5
|
-
choices: [
|
|
8
|
+
choices: [
|
|
9
|
+
"create",
|
|
10
|
+
"validate",
|
|
11
|
+
"display"
|
|
12
|
+
],
|
|
6
13
|
description: "Action to take on config",
|
|
7
14
|
type: "string"
|
|
8
15
|
}).positional("target", {
|
|
@@ -13,13 +20,13 @@ var commandConfig = (argv) => {
|
|
|
13
20
|
console.log(`Taking action [${action}] on manifest at ${target}`);
|
|
14
21
|
return await Promise.resolve();
|
|
15
22
|
});
|
|
16
|
-
};
|
|
23
|
+
}, "commandConfig");
|
|
17
24
|
|
|
18
25
|
// src/scripts/xyos/lib/createFromTemplate.ts
|
|
19
|
-
var createFromTemplate = async ({ target, template }) => {
|
|
26
|
+
var createFromTemplate = /* @__PURE__ */ __name(async ({ target, template }) => {
|
|
20
27
|
console.log("Creating from template", template, "at", target);
|
|
21
28
|
return await Promise.resolve();
|
|
22
|
-
};
|
|
29
|
+
}, "createFromTemplate");
|
|
23
30
|
|
|
24
31
|
// src/scripts/xyos/lib/headless.ts
|
|
25
32
|
import fs from "node:fs";
|
|
@@ -53,6 +60,10 @@ var DappsArchivistPayloadDivinerModuleName = "DappsArchivistPayloadDiviner";
|
|
|
53
60
|
var DappsArchivistPayloadDevelopmentDivinerModuleName = `${DappsArchivistPayloadDivinerModuleName}Development`;
|
|
54
61
|
var RegisteredDappInterfacesArchivistModuleName = "RegisteredDappInterfacesArchivist";
|
|
55
62
|
var OsCallerBase = class {
|
|
63
|
+
static {
|
|
64
|
+
__name(this, "OsCallerBase");
|
|
65
|
+
}
|
|
66
|
+
context;
|
|
56
67
|
constructor(context) {
|
|
57
68
|
this.context = context;
|
|
58
69
|
}
|
|
@@ -63,48 +74,39 @@ var OsCallerBase = class {
|
|
|
63
74
|
}
|
|
64
75
|
// Get the dapps archivist development
|
|
65
76
|
async getDappsArchivistDevelopment() {
|
|
66
|
-
const mod = assertEx(
|
|
67
|
-
await this.context.root.resolve(DappsArchivistDevelopmentModuleName),
|
|
68
|
-
() => `${DappsArchivistDevelopmentModuleName} not found`
|
|
69
|
-
);
|
|
77
|
+
const mod = assertEx(await this.context.root.resolve(DappsArchivistDevelopmentModuleName), () => `${DappsArchivistDevelopmentModuleName} not found`);
|
|
70
78
|
return asArchivistInstance(mod, () => `${DappsArchivistDevelopmentModuleName} is not an archivist`);
|
|
71
79
|
}
|
|
72
80
|
// Get the dapps archivist payload diviner
|
|
73
81
|
async getDappsArchivistPayloadDiviner() {
|
|
74
|
-
const mod = assertEx(
|
|
75
|
-
await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName),
|
|
76
|
-
() => `${DappsArchivistPayloadDivinerModuleName} not found`
|
|
77
|
-
);
|
|
82
|
+
const mod = assertEx(await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName), () => `${DappsArchivistPayloadDivinerModuleName} not found`);
|
|
78
83
|
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
79
84
|
}
|
|
80
85
|
// Get the dapps archivist payload diviner development
|
|
81
86
|
async getDappsArchivistPayloadDivinerDevelopment() {
|
|
82
|
-
const mod = assertEx(
|
|
83
|
-
await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName),
|
|
84
|
-
() => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`
|
|
85
|
-
);
|
|
87
|
+
const mod = assertEx(await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName), () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`);
|
|
86
88
|
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} is not a diviner`);
|
|
87
89
|
}
|
|
88
90
|
// Get the registered dapp interfaces archivist
|
|
89
91
|
async getRegisteredDappInterfacesArchivist() {
|
|
90
|
-
const mod = assertEx(
|
|
91
|
-
await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName),
|
|
92
|
-
() => `${RegisteredDappInterfacesArchivistModuleName} not found`
|
|
93
|
-
);
|
|
92
|
+
const mod = assertEx(await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName), () => `${RegisteredDappInterfacesArchivistModuleName} not found`);
|
|
94
93
|
return asArchivistInstance(mod, () => `${RegisteredDappInterfacesArchivistModuleName} is not an archivist`);
|
|
95
94
|
}
|
|
96
95
|
};
|
|
97
96
|
|
|
98
97
|
// src/wallet/DappSeedPhraseRepository.ts
|
|
99
98
|
var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.allowedNames = allowedNames;
|
|
99
|
+
static {
|
|
100
|
+
__name(this, "DappSeedPhraseRepository");
|
|
103
101
|
}
|
|
102
|
+
allowedNames;
|
|
104
103
|
// record of all dapps that have requested a seed phrase with the OS
|
|
105
|
-
dappIdRepository
|
|
104
|
+
dappIdRepository;
|
|
106
105
|
// record of all walletIds that have been issued to registered dapps
|
|
107
|
-
walletIdRepository
|
|
106
|
+
walletIdRepository;
|
|
107
|
+
constructor(xyOs, allowedNames) {
|
|
108
|
+
super(xyOs), this.allowedNames = allowedNames, this.dappIdRepository = /* @__PURE__ */ new Map(), this.walletIdRepository = /* @__PURE__ */ new Map();
|
|
109
|
+
}
|
|
108
110
|
async add(dappId) {
|
|
109
111
|
const archivist = await this.getDappsArchivist();
|
|
110
112
|
const seedPhrase = this.newPhrase();
|
|
@@ -115,7 +117,9 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
115
117
|
seedPhrase,
|
|
116
118
|
walletId
|
|
117
119
|
};
|
|
118
|
-
await archivist.insert([
|
|
120
|
+
await archivist.insert([
|
|
121
|
+
payload
|
|
122
|
+
]);
|
|
119
123
|
this.dappIdRepository.set(dappId, payload);
|
|
120
124
|
this.walletIdRepository.set(walletId, payload);
|
|
121
125
|
return walletId;
|
|
@@ -147,9 +151,13 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
147
151
|
limit: 1,
|
|
148
152
|
order: "desc",
|
|
149
153
|
schema: PayloadDivinerQuerySchema,
|
|
150
|
-
schemas: [
|
|
154
|
+
schemas: [
|
|
155
|
+
DappWalletSeedPhraseSchema
|
|
156
|
+
]
|
|
151
157
|
};
|
|
152
|
-
const results = await diviner.divine([
|
|
158
|
+
const results = await diviner.divine([
|
|
159
|
+
query
|
|
160
|
+
]);
|
|
153
161
|
return results.length > 0 ? results[0] : void 0;
|
|
154
162
|
}
|
|
155
163
|
async checkWalletId(walletId) {
|
|
@@ -158,10 +166,14 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
158
166
|
limit: 1,
|
|
159
167
|
order: "desc",
|
|
160
168
|
schema: PayloadDivinerQuerySchema,
|
|
161
|
-
schemas: [
|
|
169
|
+
schemas: [
|
|
170
|
+
DappWalletSeedPhraseSchema
|
|
171
|
+
],
|
|
162
172
|
walletId
|
|
163
173
|
};
|
|
164
|
-
const results = await diviner.divine([
|
|
174
|
+
const results = await diviner.divine([
|
|
175
|
+
query
|
|
176
|
+
]);
|
|
165
177
|
return results.length > 0 ? results[0] : void 0;
|
|
166
178
|
}
|
|
167
179
|
newPhrase() {
|
|
@@ -179,42 +191,37 @@ var IntentArchivistModuleName = "IntentArchivist";
|
|
|
179
191
|
var IntentArchivistPayloadDivinerModuleName = "IntentArchivistPayloadDiviner";
|
|
180
192
|
var DappArchivistPayloadDivinerModuleName = "DappArchivistPayloadDiviner";
|
|
181
193
|
var DappCallerBase = class {
|
|
194
|
+
static {
|
|
195
|
+
__name(this, "DappCallerBase");
|
|
196
|
+
}
|
|
197
|
+
context;
|
|
182
198
|
constructor(context) {
|
|
183
199
|
this.context = context;
|
|
184
200
|
}
|
|
185
201
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
202
|
+
* Get the DappArchivist
|
|
203
|
+
*/
|
|
188
204
|
async getDappArchivist() {
|
|
189
|
-
const mod = assertEx2(
|
|
190
|
-
await this.context.root.resolve(DappArchivistModuleName),
|
|
191
|
-
() => `${DappArchivistModuleName} not found [${toJsonString(this.context.root.publicChildren())}]`
|
|
192
|
-
);
|
|
205
|
+
const mod = assertEx2(await this.context.root.resolve(DappArchivistModuleName), () => `${DappArchivistModuleName} not found [${toJsonString(this.context.root.publicChildren())}]`);
|
|
193
206
|
return asArchivistInstance2(mod, () => `${DappArchivistModuleName} is not an archivist`);
|
|
194
207
|
}
|
|
195
208
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
209
|
+
* Get the DappArchivistPayloadDiviner
|
|
210
|
+
*/
|
|
198
211
|
async getDappArchivistPayloadDiviner() {
|
|
199
|
-
const mod = assertEx2(
|
|
200
|
-
await this.context.root.resolve(DappArchivistPayloadDivinerModuleName),
|
|
201
|
-
() => `${DappArchivistPayloadDivinerModuleName} not found`
|
|
202
|
-
);
|
|
212
|
+
const mod = assertEx2(await this.context.root.resolve(DappArchivistPayloadDivinerModuleName), () => `${DappArchivistPayloadDivinerModuleName} not found`);
|
|
203
213
|
return asDivinerInstance2(mod, () => `${DappArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
204
214
|
}
|
|
205
215
|
/**
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
* Get the IntentArchivist
|
|
217
|
+
*/
|
|
208
218
|
async getDappIntentArchivist() {
|
|
209
219
|
const mod = assertEx2(await this.context.root.resolve(IntentArchivistModuleName), () => `${IntentArchivistModuleName} not found`);
|
|
210
220
|
return asArchivistInstance2(mod, () => `${IntentArchivistModuleName} is not an archivist`);
|
|
211
221
|
}
|
|
212
222
|
// Get the IntentArchivistPayloadDiviner
|
|
213
223
|
async getDappIntentArchivistPayloadDiviner() {
|
|
214
|
-
const mod = assertEx2(
|
|
215
|
-
await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName),
|
|
216
|
-
() => `${IntentArchivistPayloadDivinerModuleName} not found`
|
|
217
|
-
);
|
|
224
|
+
const mod = assertEx2(await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName), () => `${IntentArchivistPayloadDivinerModuleName} not found`);
|
|
218
225
|
return asDivinerInstance2(mod, () => `${IntentArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
219
226
|
}
|
|
220
227
|
};
|
|
@@ -357,20 +364,26 @@ var os_node_manifest_default = {
|
|
|
357
364
|
import { asDivinerInstance as asDivinerInstance3 } from "@xyo-network/diviner-model";
|
|
358
365
|
import { ResolveHelper } from "@xyo-network/module-model";
|
|
359
366
|
import { NameRegistrarTransformer } from "@xyo-network/module-resolver";
|
|
360
|
-
var initializeXns = async (xnsNode) => {
|
|
367
|
+
var initializeXns = /* @__PURE__ */ __name(async (xnsNode) => {
|
|
361
368
|
if (ResolveHelper.transformers.length === 0) {
|
|
362
369
|
const registrarDiviner = asDivinerInstance3(await xnsNode?.resolve("AddressRecords:AddressRecordIndexDiviner"));
|
|
363
370
|
if (registrarDiviner) {
|
|
364
371
|
const transformer = new NameRegistrarTransformer(registrarDiviner, "xyo");
|
|
365
|
-
ResolveHelper.transformers = [
|
|
372
|
+
ResolveHelper.transformers = [
|
|
373
|
+
transformer
|
|
374
|
+
];
|
|
366
375
|
return true;
|
|
367
376
|
}
|
|
368
377
|
}
|
|
369
378
|
return false;
|
|
370
|
-
};
|
|
379
|
+
}, "initializeXns");
|
|
371
380
|
|
|
372
381
|
// src/lib/NameTransforms.ts
|
|
373
382
|
var NameTransforms = class _NameTransforms {
|
|
383
|
+
static {
|
|
384
|
+
__name(this, "NameTransforms");
|
|
385
|
+
}
|
|
386
|
+
value;
|
|
374
387
|
constructor(value) {
|
|
375
388
|
this.value = value;
|
|
376
389
|
}
|
|
@@ -398,19 +411,22 @@ var NameTransforms = class _NameTransforms {
|
|
|
398
411
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema2 } from "@xyo-network/diviner-payload-model";
|
|
399
412
|
import { DappIntentSchema, DappMode } from "@xyo-network/os-model";
|
|
400
413
|
var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
414
|
+
static {
|
|
415
|
+
__name(this, "DappIntentCaller");
|
|
416
|
+
}
|
|
401
417
|
static OsDappName = "XyOs";
|
|
402
418
|
constructor(context) {
|
|
403
419
|
super(context);
|
|
404
420
|
}
|
|
405
421
|
/**
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
422
|
+
* Build a new intent
|
|
423
|
+
* @param {DappId} sourceDappId
|
|
424
|
+
* @param {DappIntentTypes} intent
|
|
425
|
+
* @param {DappId} targetDappId
|
|
426
|
+
* @param {DappMode} targetMode
|
|
427
|
+
* @param {DappIntent['params']} params?
|
|
428
|
+
* @returns DappIntent
|
|
429
|
+
*/
|
|
414
430
|
static buildIntent(sourceDappId, intent, targetDappId, targetMode = DappMode.Window, params) {
|
|
415
431
|
return {
|
|
416
432
|
intent,
|
|
@@ -426,7 +442,9 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
426
442
|
async addIntent(id, intent, mode) {
|
|
427
443
|
const intentArchivist = await this.getDappIntentArchivist();
|
|
428
444
|
const newIntent = _DappIntentCaller.buildIntent(id, intent, mode);
|
|
429
|
-
await intentArchivist.insert([
|
|
445
|
+
await intentArchivist.insert([
|
|
446
|
+
newIntent
|
|
447
|
+
]);
|
|
430
448
|
}
|
|
431
449
|
// Get all intents
|
|
432
450
|
async allIntents() {
|
|
@@ -447,7 +465,9 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
447
465
|
schema: PayloadDivinerQuerySchema2,
|
|
448
466
|
sourceDappId: dappName
|
|
449
467
|
};
|
|
450
|
-
return await diviner.divine([
|
|
468
|
+
return await diviner.divine([
|
|
469
|
+
query
|
|
470
|
+
]);
|
|
451
471
|
}
|
|
452
472
|
};
|
|
453
473
|
|
|
@@ -455,17 +475,15 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
455
475
|
import { forget as forget2 } from "@xylabs/forget";
|
|
456
476
|
import { fulfilled, rejected } from "@xylabs/promise";
|
|
457
477
|
import { ModuleFactoryLocator as ModuleFactoryLocator3 } from "@xyo-network/module-factory-locator";
|
|
458
|
-
import {
|
|
459
|
-
DappIntentTypes,
|
|
460
|
-
DappMode as DappMode2,
|
|
461
|
-
isRegisteredDappAccessDappSet,
|
|
462
|
-
isRegisteredDappExposedDappSet
|
|
463
|
-
} from "@xyo-network/os-model";
|
|
478
|
+
import { DappIntentTypes, DappMode as DappMode2, isRegisteredDappAccessDappSet, isRegisteredDappExposedDappSet } from "@xyo-network/os-model";
|
|
464
479
|
|
|
465
480
|
// src/event/bus/Connection.ts
|
|
466
481
|
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
467
482
|
import { BaseEmitter } from "@xyo-network/module-event-emitter";
|
|
468
483
|
var EventBusConnection = class extends BaseEmitter {
|
|
484
|
+
static {
|
|
485
|
+
__name(this, "EventBusConnection");
|
|
486
|
+
}
|
|
469
487
|
_id;
|
|
470
488
|
description;
|
|
471
489
|
type;
|
|
@@ -485,19 +503,15 @@ var EventBusConnection = class extends BaseEmitter {
|
|
|
485
503
|
// src/event/bus/EventBus.ts
|
|
486
504
|
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
487
505
|
import { forget } from "@xylabs/forget";
|
|
488
|
-
import {
|
|
489
|
-
|
|
490
|
-
MemoryArchivist,
|
|
491
|
-
MemoryArchivistConfigSchema
|
|
492
|
-
} from "@xyo-network/archivist";
|
|
493
|
-
import {
|
|
494
|
-
isEventBusEvent,
|
|
495
|
-
isPubSubConnections
|
|
496
|
-
} from "@xyo-network/os-model";
|
|
506
|
+
import { asArchivistInstance as asArchivistInstance3, MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/archivist";
|
|
507
|
+
import { isEventBusEvent, isPubSubConnections } from "@xyo-network/os-model";
|
|
497
508
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
498
509
|
import { Mutex } from "async-mutex";
|
|
499
510
|
import { v4 as uuid2 } from "uuid";
|
|
500
511
|
var EventBus = class {
|
|
512
|
+
static {
|
|
513
|
+
__name(this, "EventBus");
|
|
514
|
+
}
|
|
501
515
|
// Internal Archivist to store event data
|
|
502
516
|
_archivist;
|
|
503
517
|
// Store all connections
|
|
@@ -506,10 +520,7 @@ var EventBus = class {
|
|
|
506
520
|
publisherCallbacks = {};
|
|
507
521
|
startMutex = new Mutex();
|
|
508
522
|
get archivist() {
|
|
509
|
-
return asArchivistInstance3(
|
|
510
|
-
assertEx4(this._archivist, () => "Archivist not found. Did you forget to call start()?"),
|
|
511
|
-
"not a valid archivist instance"
|
|
512
|
-
);
|
|
523
|
+
return asArchivistInstance3(assertEx4(this._archivist, () => "Archivist not found. Did you forget to call start()?"), "not a valid archivist instance");
|
|
513
524
|
}
|
|
514
525
|
addConnection(connection) {
|
|
515
526
|
const id = uuid2();
|
|
@@ -538,7 +549,12 @@ var EventBus = class {
|
|
|
538
549
|
console.warn("EventBus already started");
|
|
539
550
|
return this;
|
|
540
551
|
}
|
|
541
|
-
this._archivist = await MemoryArchivist.create({
|
|
552
|
+
this._archivist = await MemoryArchivist.create({
|
|
553
|
+
config: {
|
|
554
|
+
name: storeName,
|
|
555
|
+
schema: MemoryArchivistConfigSchema
|
|
556
|
+
}
|
|
557
|
+
});
|
|
542
558
|
this.archivist.on("inserted", ({ payloads }) => {
|
|
543
559
|
const eventBusEvent = payloads.find(isEventBusEvent);
|
|
544
560
|
if (!eventBusEvent) return;
|
|
@@ -548,7 +564,9 @@ var EventBus = class {
|
|
|
548
564
|
for (const [eventName, callback] of connection.subscribableEvents.entries()) {
|
|
549
565
|
if (eventName !== eventBusEvent.name) continue;
|
|
550
566
|
if (callback) {
|
|
551
|
-
const forgettable = async () => await callback({
|
|
567
|
+
const forgettable = /* @__PURE__ */ __name(async () => await callback({
|
|
568
|
+
payloads
|
|
569
|
+
}), "forgettable");
|
|
552
570
|
forget(forgettable());
|
|
553
571
|
}
|
|
554
572
|
}
|
|
@@ -560,16 +578,22 @@ var EventBus = class {
|
|
|
560
578
|
}
|
|
561
579
|
handlePublisherAdd(connection) {
|
|
562
580
|
for (const eventName of connection.publishableEvents ?? []) {
|
|
563
|
-
const connectionPublisherCallback = async ({ payloads }) => {
|
|
564
|
-
const event = {
|
|
581
|
+
const connectionPublisherCallback = /* @__PURE__ */ __name(async ({ payloads }) => {
|
|
582
|
+
const event = {
|
|
583
|
+
name: eventName,
|
|
584
|
+
schema: "network.xyo.event.bus.event"
|
|
585
|
+
};
|
|
565
586
|
const eventPayloads = payloads ?? [];
|
|
566
587
|
event.sources = await PayloadBuilder.dataHashes(eventPayloads);
|
|
567
588
|
try {
|
|
568
|
-
await this.archivist.insert([
|
|
589
|
+
await this.archivist.insert([
|
|
590
|
+
event,
|
|
591
|
+
...payloads ?? []
|
|
592
|
+
]);
|
|
569
593
|
} catch (e) {
|
|
570
594
|
console.error("Error inserting event into archivist", e);
|
|
571
595
|
}
|
|
572
|
-
};
|
|
596
|
+
}, "connectionPublisherCallback");
|
|
573
597
|
connection.on(eventName, connectionPublisherCallback);
|
|
574
598
|
const callbackId = connection.id + eventName;
|
|
575
599
|
this.publisherCallbacks[callbackId] = connectionPublisherCallback;
|
|
@@ -586,6 +610,9 @@ var EventBus = class {
|
|
|
586
610
|
|
|
587
611
|
// src/event/bus/PubSubConnection.ts
|
|
588
612
|
var EventBusPubSubConnection = class extends EventBusConnection {
|
|
613
|
+
static {
|
|
614
|
+
__name(this, "EventBusPubSubConnection");
|
|
615
|
+
}
|
|
589
616
|
publishableEvents;
|
|
590
617
|
subscribableEvents;
|
|
591
618
|
constructor(request) {
|
|
@@ -601,42 +628,52 @@ var EventBusPubSubConnection = class extends EventBusConnection {
|
|
|
601
628
|
// src/event/connections/DappAccessRequest.ts
|
|
602
629
|
var DappAccessRequestEvent = "dappAccessRequest";
|
|
603
630
|
var dappAccessRequestConnectionRequest = {
|
|
604
|
-
publishableEvents: [
|
|
631
|
+
publishableEvents: [
|
|
632
|
+
DappAccessRequestEvent
|
|
633
|
+
],
|
|
605
634
|
type: "PubSub"
|
|
606
635
|
};
|
|
607
|
-
var dappAccessRequestConnection = () => new EventBusPubSubConnection(dappAccessRequestConnectionRequest);
|
|
636
|
+
var dappAccessRequestConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(dappAccessRequestConnectionRequest), "dappAccessRequestConnection");
|
|
608
637
|
|
|
609
638
|
// src/event/connections/ExposeDappRequest.ts
|
|
610
639
|
var ExposeDappRequestEvent = "exposeDappRequest";
|
|
611
640
|
var exposeDappConnectionRequest = {
|
|
612
|
-
publishableEvents: [
|
|
641
|
+
publishableEvents: [
|
|
642
|
+
ExposeDappRequestEvent
|
|
643
|
+
],
|
|
613
644
|
type: "PubSub"
|
|
614
645
|
};
|
|
615
|
-
var exposeDappRequestConnection = () => new EventBusPubSubConnection(exposeDappConnectionRequest);
|
|
646
|
+
var exposeDappRequestConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(exposeDappConnectionRequest), "exposeDappRequestConnection");
|
|
616
647
|
|
|
617
648
|
// src/event/connections/OsPubSubNetworkReady.ts
|
|
618
649
|
var OsPubSubNetworkReadyEvent = "osPubSubNetworkReady";
|
|
619
650
|
var osPubSubNetworkConnectionRequest = {
|
|
620
|
-
publishableEvents: [
|
|
651
|
+
publishableEvents: [
|
|
652
|
+
OsPubSubNetworkReadyEvent
|
|
653
|
+
],
|
|
621
654
|
type: "PubSub"
|
|
622
655
|
};
|
|
623
|
-
var osPubSubNetworkReadyConnection = () => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest);
|
|
656
|
+
var osPubSubNetworkReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest), "osPubSubNetworkReadyConnection");
|
|
624
657
|
|
|
625
658
|
// src/event/connections/OsSettingsReady.ts
|
|
626
659
|
var OsSettingsReadyEvent = "osSettingsReady";
|
|
627
660
|
var osSettingsConnectionRequest = {
|
|
628
|
-
publishableEvents: [
|
|
661
|
+
publishableEvents: [
|
|
662
|
+
OsSettingsReadyEvent
|
|
663
|
+
],
|
|
629
664
|
type: "PubSub"
|
|
630
665
|
};
|
|
631
|
-
var osSettingsReadyConnection = () => new EventBusPubSubConnection(osSettingsConnectionRequest);
|
|
666
|
+
var osSettingsReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osSettingsConnectionRequest), "osSettingsReadyConnection");
|
|
632
667
|
|
|
633
668
|
// src/event/connections/OsXyoPublicReady.ts
|
|
634
669
|
var OsXyoPublicNetworkReadyEvent = "osXyoPublicNetworkReady";
|
|
635
670
|
var osXyoPublicNetworkConnectionRequest = {
|
|
636
|
-
publishableEvents: [
|
|
671
|
+
publishableEvents: [
|
|
672
|
+
OsXyoPublicNetworkReadyEvent
|
|
673
|
+
],
|
|
637
674
|
type: "PubSub"
|
|
638
675
|
};
|
|
639
|
-
var osXyoPublicNetworkReadyConnection = () => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest);
|
|
676
|
+
var osXyoPublicNetworkReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest), "osXyoPublicNetworkReadyConnection");
|
|
640
677
|
|
|
641
678
|
// src/XyOsDapp.ts
|
|
642
679
|
import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
@@ -688,6 +725,9 @@ import { BaseEmitter as BaseEmitter2 } from "@xyo-network/module-event-emitter";
|
|
|
688
725
|
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
689
726
|
import { Mutex as Mutex2 } from "async-mutex";
|
|
690
727
|
var XyOsContextBase = class extends BaseEmitter2 {
|
|
728
|
+
static {
|
|
729
|
+
__name(this, "XyOsContextBase");
|
|
730
|
+
}
|
|
691
731
|
_bootMutex = new Mutex2();
|
|
692
732
|
_platformLocator;
|
|
693
733
|
_root;
|
|
@@ -771,10 +811,15 @@ var XyOsContextBase = class extends BaseEmitter2 {
|
|
|
771
811
|
|
|
772
812
|
// src/XyOsDapp.ts
|
|
773
813
|
var XyOsDapp = class extends XyOsContextBase {
|
|
814
|
+
static {
|
|
815
|
+
__name(this, "XyOsDapp");
|
|
816
|
+
}
|
|
774
817
|
dapp;
|
|
775
818
|
constructor(params) {
|
|
776
819
|
super(params);
|
|
777
|
-
this.dapp = {
|
|
820
|
+
this.dapp = {
|
|
821
|
+
...params.dapp
|
|
822
|
+
};
|
|
778
823
|
}
|
|
779
824
|
get eventBus() {
|
|
780
825
|
return this.parent.eventBus;
|
|
@@ -786,12 +831,12 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
786
831
|
return this.parent.exposedNodeOuter;
|
|
787
832
|
}
|
|
788
833
|
/**
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
834
|
+
* @deprecated Dapps should not have access to the bios. This is done for the
|
|
835
|
+
* settings dapp, but should be refactored out. Bios could possibly be an
|
|
836
|
+
* optional property of the parent context passed in for dapps that require
|
|
837
|
+
* elevated permissions.
|
|
838
|
+
* ^^^ I believe we may want this here in that is a dApp requests access to the bios it will optionally be there
|
|
839
|
+
*/
|
|
795
840
|
get kernel() {
|
|
796
841
|
return assertEx6(this.parent.kernel, () => "Missing kernel");
|
|
797
842
|
}
|
|
@@ -810,15 +855,17 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
810
855
|
assertEx6(this._root === void 0, () => "Dapp already booted");
|
|
811
856
|
const finalLocator = locator ? (this.params.locator ?? new ModuleFactoryLocator2()).merge(locator) : this.params.locator ?? new ModuleFactoryLocator2();
|
|
812
857
|
console.log("XyOsDapp:boot:finalLocator", finalLocator);
|
|
813
|
-
const dappNodesWrapper = new ManifestWrapper({
|
|
858
|
+
const dappNodesWrapper = new ManifestWrapper({
|
|
859
|
+
...this.manifest,
|
|
860
|
+
schema: DappPackageManifestPayloadSchema
|
|
861
|
+
}, wallet, finalLocator);
|
|
814
862
|
const dappNodes = await dappNodesWrapper.loadNodes();
|
|
815
863
|
const dappManifestWallet = await wallet.derivePath("99999");
|
|
816
864
|
dapp_window_manifest_default.nodes[0].config.name = this.dapp.name + "Root";
|
|
817
|
-
const wrapper = new ManifestWrapper(
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
);
|
|
865
|
+
const wrapper = new ManifestWrapper({
|
|
866
|
+
...dapp_window_manifest_default,
|
|
867
|
+
schema: DappPackageManifestPayloadSchema
|
|
868
|
+
}, dappManifestWallet, finalLocator);
|
|
822
869
|
const node = await wrapper.loadNodeFromIndex(0);
|
|
823
870
|
for (const dappNode of dappNodes) {
|
|
824
871
|
await node.register(dappNode);
|
|
@@ -840,12 +887,7 @@ import semver from "semver";
|
|
|
840
887
|
|
|
841
888
|
// src/classes/system/Queries.ts
|
|
842
889
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema3 } from "@xyo-network/diviner-payload-model";
|
|
843
|
-
import {
|
|
844
|
-
DappConfigSchema,
|
|
845
|
-
DappIconSchema,
|
|
846
|
-
DappWidgetConfigSchema,
|
|
847
|
-
UnregisteredDappAccessSchema
|
|
848
|
-
} from "@xyo-network/os-model";
|
|
890
|
+
import { DappConfigSchema, DappIconSchema, DappWidgetConfigSchema, UnregisteredDappAccessSchema } from "@xyo-network/os-model";
|
|
849
891
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
850
892
|
var SystemDappQueries = {
|
|
851
893
|
async getDappAccess(diviner, name, version) {
|
|
@@ -853,10 +895,14 @@ var SystemDappQueries = {
|
|
|
853
895
|
order: "desc",
|
|
854
896
|
registeringDappId: name,
|
|
855
897
|
schema: PayloadDivinerQuerySchema3,
|
|
856
|
-
schemas: [
|
|
898
|
+
schemas: [
|
|
899
|
+
UnregisteredDappAccessSchema
|
|
900
|
+
],
|
|
857
901
|
version
|
|
858
902
|
};
|
|
859
|
-
return await diviner.divine([
|
|
903
|
+
return await diviner.divine([
|
|
904
|
+
accessQuery
|
|
905
|
+
]);
|
|
860
906
|
},
|
|
861
907
|
async getLatestConfig(diviner, name) {
|
|
862
908
|
const configQuery = {
|
|
@@ -864,9 +910,13 @@ var SystemDappQueries = {
|
|
|
864
910
|
name,
|
|
865
911
|
order: "desc",
|
|
866
912
|
schema: PayloadDivinerQuerySchema3,
|
|
867
|
-
schemas: [
|
|
913
|
+
schemas: [
|
|
914
|
+
DappConfigSchema
|
|
915
|
+
]
|
|
868
916
|
};
|
|
869
|
-
const [dappConfig] = await diviner.divine([
|
|
917
|
+
const [dappConfig] = await diviner.divine([
|
|
918
|
+
configQuery
|
|
919
|
+
]);
|
|
870
920
|
return dappConfig;
|
|
871
921
|
},
|
|
872
922
|
async getLatestIcon(diviner, name, version) {
|
|
@@ -874,10 +924,14 @@ var SystemDappQueries = {
|
|
|
874
924
|
name,
|
|
875
925
|
order: "desc",
|
|
876
926
|
schema: PayloadDivinerQuerySchema3,
|
|
877
|
-
schemas: [
|
|
927
|
+
schemas: [
|
|
928
|
+
DappIconSchema
|
|
929
|
+
],
|
|
878
930
|
version
|
|
879
931
|
};
|
|
880
|
-
const [dappIcon] = await diviner.divine([
|
|
932
|
+
const [dappIcon] = await diviner.divine([
|
|
933
|
+
iconQuery
|
|
934
|
+
]);
|
|
881
935
|
return dappIcon;
|
|
882
936
|
},
|
|
883
937
|
async getWidgetConfigs(diviner, name, version) {
|
|
@@ -885,10 +939,14 @@ var SystemDappQueries = {
|
|
|
885
939
|
dappId: name,
|
|
886
940
|
order: "desc",
|
|
887
941
|
schema: PayloadDivinerQuerySchema3,
|
|
888
|
-
schemas: [
|
|
942
|
+
schemas: [
|
|
943
|
+
DappWidgetConfigSchema
|
|
944
|
+
],
|
|
889
945
|
version
|
|
890
946
|
};
|
|
891
|
-
const widgetConfigs = await diviner.divine([
|
|
947
|
+
const widgetConfigs = await diviner.divine([
|
|
948
|
+
widgetConfigQuery
|
|
949
|
+
]);
|
|
892
950
|
const uniqueConfigs = {};
|
|
893
951
|
for (const widgetConfig of widgetConfigs) {
|
|
894
952
|
const hash = await PayloadBuilder2.dataHash(widgetConfig);
|
|
@@ -900,25 +958,28 @@ var SystemDappQueries = {
|
|
|
900
958
|
|
|
901
959
|
// src/classes/system/ManageSystemDapps.ts
|
|
902
960
|
var ManageSystemDapps = class extends OsCallerBase {
|
|
961
|
+
static {
|
|
962
|
+
__name(this, "ManageSystemDapps");
|
|
963
|
+
}
|
|
964
|
+
defaultSystemNames;
|
|
965
|
+
defaultSystemDapps;
|
|
966
|
+
defaultSystemDappParams;
|
|
967
|
+
locator;
|
|
968
|
+
developmentMode;
|
|
969
|
+
onErrorCallbacks;
|
|
903
970
|
constructor(context, defaultSystemNames, defaultSystemDapps, defaultSystemDappParams, locator, developmentMode) {
|
|
904
|
-
super(context);
|
|
905
|
-
this.defaultSystemNames = defaultSystemNames;
|
|
906
|
-
this.defaultSystemDapps = defaultSystemDapps;
|
|
907
|
-
this.defaultSystemDappParams = defaultSystemDappParams;
|
|
908
|
-
this.locator = locator;
|
|
909
|
-
this.developmentMode = developmentMode;
|
|
971
|
+
super(context), this.defaultSystemNames = defaultSystemNames, this.defaultSystemDapps = defaultSystemDapps, this.defaultSystemDappParams = defaultSystemDappParams, this.locator = locator, this.developmentMode = developmentMode, this.onErrorCallbacks = [];
|
|
910
972
|
}
|
|
911
|
-
onErrorCallbacks = [];
|
|
912
973
|
/**
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
974
|
+
* Add a callback to listen for errors throwing during system dapp registration
|
|
975
|
+
* @param {ErrorListener} errorListener
|
|
976
|
+
*/
|
|
916
977
|
addErrorListener(errorListener) {
|
|
917
978
|
this.onErrorCallbacks.push(errorListener);
|
|
918
979
|
}
|
|
919
980
|
/**
|
|
920
|
-
|
|
921
|
-
|
|
981
|
+
* Installs the dapps into the OS and builds the appropriate DappSet
|
|
982
|
+
*/
|
|
922
983
|
async install() {
|
|
923
984
|
await this.insertPayloads();
|
|
924
985
|
return await this.latestSets();
|
|
@@ -942,9 +1003,13 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
942
1003
|
console.error(`${systemDappPayload.version} does not appear to be a valid semver value`, e);
|
|
943
1004
|
continue;
|
|
944
1005
|
}
|
|
945
|
-
const [existing] = await archivist.get([
|
|
1006
|
+
const [existing] = await archivist.get([
|
|
1007
|
+
await PayloadBuilder3.dataHash(systemDappPayload)
|
|
1008
|
+
]);
|
|
946
1009
|
if (existing) continue;
|
|
947
|
-
await archivist.insert([
|
|
1010
|
+
await archivist.insert([
|
|
1011
|
+
systemDappPayload
|
|
1012
|
+
]);
|
|
948
1013
|
}
|
|
949
1014
|
return true;
|
|
950
1015
|
} catch (e) {
|
|
@@ -999,11 +1064,7 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
999
1064
|
|
|
1000
1065
|
// src/classes/registration/DappRegistry.ts
|
|
1001
1066
|
import { HDWallet as HDWallet3 } from "@xyo-network/account";
|
|
1002
|
-
import {
|
|
1003
|
-
DappRegisteredSchema,
|
|
1004
|
-
DappRegisteredState,
|
|
1005
|
-
isRegisteredDappAccess
|
|
1006
|
-
} from "@xyo-network/os-model";
|
|
1067
|
+
import { DappRegisteredSchema, DappRegisteredState, isRegisteredDappAccess } from "@xyo-network/os-model";
|
|
1007
1068
|
|
|
1008
1069
|
// src/classes/registration/ValidateDappAccessDiviner/Config.ts
|
|
1009
1070
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
@@ -1015,20 +1076,22 @@ var ValidateDappAccessDivinerConfigSchema = "network.xyo.os.dapp.access.registra
|
|
|
1015
1076
|
import { HDWallet as HDWallet2 } from "@xyo-network/account";
|
|
1016
1077
|
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
1017
1078
|
import { ManifestWrapper as ManifestWrapper2, PackageManifestPayloadSchema } from "@xyo-network/manifest";
|
|
1018
|
-
import {
|
|
1019
|
-
isDappPackageManifestPayload,
|
|
1020
|
-
isUnregisteredDappAccess,
|
|
1021
|
-
RegisteredDappAccessSchema
|
|
1022
|
-
} from "@xyo-network/os-model";
|
|
1023
|
-
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
1079
|
+
import { isDappPackageManifestPayload, isUnregisteredDappAccess, RegisteredDappAccessSchema } from "@xyo-network/os-model";
|
|
1024
1080
|
|
|
1025
1081
|
// src/access-interfaces/ValidDappAccessInterfaces.ts
|
|
1026
1082
|
import { RegisteredNames, RegisteredNamesInterface } from "@xyo-network/os-model";
|
|
1027
|
-
var ValidDappAccessInterfaces = {
|
|
1083
|
+
var ValidDappAccessInterfaces = {
|
|
1084
|
+
[RegisteredNames]: RegisteredNamesInterface
|
|
1085
|
+
};
|
|
1028
1086
|
|
|
1029
1087
|
// src/classes/registration/ValidateDappAccessDiviner/Diviner.ts
|
|
1030
1088
|
var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
1031
|
-
static
|
|
1089
|
+
static {
|
|
1090
|
+
__name(this, "ValidateDappAccessDiviner");
|
|
1091
|
+
}
|
|
1092
|
+
static configSchemas = [
|
|
1093
|
+
ValidateDappAccessDivinerConfigSchema
|
|
1094
|
+
];
|
|
1032
1095
|
async divineHandler(payloads) {
|
|
1033
1096
|
const dappManifest = payloads?.filter(isDappPackageManifestPayload);
|
|
1034
1097
|
const accessors = payloads?.filter(isUnregisteredDappAccess);
|
|
@@ -1054,48 +1117,49 @@ var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
|
1054
1117
|
const interfaceChildren = await getNodeChildren(dappAccessInterface.manifest, dappParams);
|
|
1055
1118
|
const valid = compareChildren(interfaceChildren, dappChildren);
|
|
1056
1119
|
if (valid) {
|
|
1057
|
-
const payload =
|
|
1120
|
+
const payload = {
|
|
1058
1121
|
...access,
|
|
1059
1122
|
schema: RegisteredDappAccessSchema,
|
|
1060
1123
|
timestamp: Date.now()
|
|
1061
|
-
}
|
|
1124
|
+
};
|
|
1062
1125
|
registeredAccessors.push(payload);
|
|
1063
1126
|
} else {
|
|
1064
|
-
const failedRegistration =
|
|
1127
|
+
const failedRegistration = {
|
|
1065
1128
|
accessor: access,
|
|
1066
1129
|
errorMessage: "Invalid dapp access interface",
|
|
1067
1130
|
schema: FailedAccessorSchema
|
|
1068
|
-
}
|
|
1131
|
+
};
|
|
1069
1132
|
failedAccessors.push(failedRegistration);
|
|
1070
1133
|
}
|
|
1071
1134
|
}
|
|
1072
1135
|
} catch (e) {
|
|
1073
|
-
failedAccessors.push(
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
})
|
|
1079
|
-
);
|
|
1136
|
+
failedAccessors.push({
|
|
1137
|
+
accessor: access,
|
|
1138
|
+
errorMessage: e.message,
|
|
1139
|
+
schema: FailedAccessorSchema
|
|
1140
|
+
});
|
|
1080
1141
|
}
|
|
1081
1142
|
}
|
|
1082
|
-
return [
|
|
1143
|
+
return [
|
|
1144
|
+
...registeredAccessors,
|
|
1145
|
+
...failedAccessors
|
|
1146
|
+
];
|
|
1083
1147
|
}
|
|
1084
1148
|
};
|
|
1085
|
-
var compareChildren = (interfaceChildren, dappChildren) => {
|
|
1149
|
+
var compareChildren = /* @__PURE__ */ __name((interfaceChildren, dappChildren) => {
|
|
1086
1150
|
return interfaceChildren.every((interfaceChild) => Object.values(interfaceChild).every((interfaceChildName) => dappChildren.some((dappChild) => Object.values(dappChild).includes(interfaceChildName))));
|
|
1087
|
-
};
|
|
1088
|
-
var dappPackageManifestToPackageManifest = (dappPackageManifest) => {
|
|
1151
|
+
}, "compareChildren");
|
|
1152
|
+
var dappPackageManifestToPackageManifest = /* @__PURE__ */ __name((dappPackageManifest) => {
|
|
1089
1153
|
return {
|
|
1090
1154
|
...dappPackageManifest,
|
|
1091
1155
|
schema: PackageManifestPayloadSchema
|
|
1092
1156
|
};
|
|
1093
|
-
};
|
|
1094
|
-
var getChildrenFromNode = async (node) => {
|
|
1157
|
+
}, "dappPackageManifestToPackageManifest");
|
|
1158
|
+
var getChildrenFromNode = /* @__PURE__ */ __name(async (node) => {
|
|
1095
1159
|
const nodeManifest = (await node.state())?.[0];
|
|
1096
1160
|
return nodeManifest.status?.children;
|
|
1097
|
-
};
|
|
1098
|
-
var getNodeChildren = async (manifestToTest, dappParams) => {
|
|
1161
|
+
}, "getChildrenFromNode");
|
|
1162
|
+
var getNodeChildren = /* @__PURE__ */ __name(async (manifestToTest, dappParams) => {
|
|
1099
1163
|
const testNodes = await getNodeToTest(manifestToTest, dappParams);
|
|
1100
1164
|
const children = [];
|
|
1101
1165
|
for (const node of testNodes) {
|
|
@@ -1105,35 +1169,32 @@ var getNodeChildren = async (manifestToTest, dappParams) => {
|
|
|
1105
1169
|
}
|
|
1106
1170
|
}
|
|
1107
1171
|
return children;
|
|
1108
|
-
};
|
|
1109
|
-
var getNodeToTest = async (manifestToTest, dappParams) => {
|
|
1172
|
+
}, "getNodeChildren");
|
|
1173
|
+
var getNodeToTest = /* @__PURE__ */ __name(async (manifestToTest, dappParams) => {
|
|
1110
1174
|
const dappManifestWrapper = new ManifestWrapper2(manifestToTest, await HDWallet2.random(), dappParams.locator);
|
|
1111
1175
|
return await dappManifestWrapper.loadNodes();
|
|
1112
|
-
};
|
|
1176
|
+
}, "getNodeToTest");
|
|
1113
1177
|
|
|
1114
1178
|
// src/classes/registration/DappRegistry.ts
|
|
1115
1179
|
var DappRegistry = class {
|
|
1180
|
+
static {
|
|
1181
|
+
__name(this, "DappRegistry");
|
|
1182
|
+
}
|
|
1183
|
+
dappSeedPhraseRepository;
|
|
1184
|
+
dappRegistry;
|
|
1116
1185
|
constructor(dappSeedPhraseRepository) {
|
|
1117
1186
|
this.dappSeedPhraseRepository = dappSeedPhraseRepository;
|
|
1187
|
+
this.dappRegistry = /* @__PURE__ */ new Map();
|
|
1118
1188
|
}
|
|
1119
|
-
dappRegistry = /* @__PURE__ */ new Map();
|
|
1120
1189
|
/**
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1190
|
+
* Register a Dapp with window manager and if successful, return its id
|
|
1191
|
+
*
|
|
1192
|
+
* @param {UnregisteredDapp} dapp Manifest and UI of the Dapp to register
|
|
1193
|
+
* @returns {RegisteredDapp} dapp with registration fields
|
|
1194
|
+
**/
|
|
1126
1195
|
async registerDapp(dapp) {
|
|
1127
1196
|
if (dapp) {
|
|
1128
|
-
const {
|
|
1129
|
-
exposedModuleIds,
|
|
1130
|
-
manifest,
|
|
1131
|
-
modes,
|
|
1132
|
-
name,
|
|
1133
|
-
version,
|
|
1134
|
-
params,
|
|
1135
|
-
widgetConfigs
|
|
1136
|
-
} = this.extractDappProperties(dapp);
|
|
1197
|
+
const { exposedModuleIds, manifest, modes, name, version, params, widgetConfigs } = this.extractDappProperties(dapp);
|
|
1137
1198
|
try {
|
|
1138
1199
|
const walletId = await this.dappSeedPhraseRepository.findOrCreate(name);
|
|
1139
1200
|
const registeredAccessors = await this.validateDappAccessPayloads(manifest, dapp.accessors, params);
|
|
@@ -1168,27 +1229,16 @@ var DappRegistry = class {
|
|
|
1168
1229
|
}
|
|
1169
1230
|
}
|
|
1170
1231
|
/**
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1232
|
+
* Unregister a dapp so it can no longer be launched
|
|
1233
|
+
*
|
|
1234
|
+
* @param dappId
|
|
1235
|
+
*/
|
|
1175
1236
|
unregisterDapp(dappId) {
|
|
1176
1237
|
this.dappRegistry.delete(dappId);
|
|
1177
1238
|
}
|
|
1178
1239
|
extractDappProperties(dapp) {
|
|
1179
|
-
const {
|
|
1180
|
-
|
|
1181
|
-
config,
|
|
1182
|
-
widgetConfigs
|
|
1183
|
-
} = dapp;
|
|
1184
|
-
const {
|
|
1185
|
-
exposedModuleIds,
|
|
1186
|
-
manifest,
|
|
1187
|
-
modes,
|
|
1188
|
-
name,
|
|
1189
|
-
sources,
|
|
1190
|
-
version
|
|
1191
|
-
} = config;
|
|
1240
|
+
const { params, config, widgetConfigs } = dapp;
|
|
1241
|
+
const { exposedModuleIds, manifest, modes, name, sources, version } = config;
|
|
1192
1242
|
return {
|
|
1193
1243
|
exposedModuleIds,
|
|
1194
1244
|
manifest,
|
|
@@ -1203,10 +1253,15 @@ var DappRegistry = class {
|
|
|
1203
1253
|
async validateDappAccessPayloads(manifest, accessors = [], params) {
|
|
1204
1254
|
const validateDappAccess = await ValidateDappAccessDiviner.create({
|
|
1205
1255
|
account: await HDWallet3.random(),
|
|
1206
|
-
config: {
|
|
1256
|
+
config: {
|
|
1257
|
+
schema: ValidateDappAccessDivinerConfigSchema
|
|
1258
|
+
},
|
|
1207
1259
|
dappParams: params
|
|
1208
1260
|
});
|
|
1209
|
-
const payloads = await validateDappAccess.divine([
|
|
1261
|
+
const payloads = await validateDappAccess.divine([
|
|
1262
|
+
manifest,
|
|
1263
|
+
...accessors
|
|
1264
|
+
]);
|
|
1210
1265
|
const failedAccessors = payloads.filter(isFailedAccessor);
|
|
1211
1266
|
const registeredAccessors = payloads.filter(isRegisteredDappAccess);
|
|
1212
1267
|
if (failedAccessors.length > 0) {
|
|
@@ -1218,6 +1273,26 @@ var DappRegistry = class {
|
|
|
1218
1273
|
|
|
1219
1274
|
// src/classes/registration/DappRegistrationService.ts
|
|
1220
1275
|
var DappRegistrationService = class {
|
|
1276
|
+
static {
|
|
1277
|
+
__name(this, "DappRegistrationService");
|
|
1278
|
+
}
|
|
1279
|
+
context;
|
|
1280
|
+
params;
|
|
1281
|
+
locator;
|
|
1282
|
+
developmentMode;
|
|
1283
|
+
// Dapps that have been built with their own context
|
|
1284
|
+
builtDapps;
|
|
1285
|
+
dappRegistry;
|
|
1286
|
+
dappSeedPhraseRepository;
|
|
1287
|
+
manageSystemDapps;
|
|
1288
|
+
// Dapps that have been registered with dappAccessRequests
|
|
1289
|
+
registeredAccessDappSets;
|
|
1290
|
+
// Dapps that have been registered with the dapp registry
|
|
1291
|
+
registeredDappSets;
|
|
1292
|
+
// Dapps that have been registered with exposeDappRequests
|
|
1293
|
+
registeredExposedDappSets;
|
|
1294
|
+
dappAccessRequestConnection;
|
|
1295
|
+
exposeDappRequestConnection;
|
|
1221
1296
|
constructor(context, params = {
|
|
1222
1297
|
dappNames: [],
|
|
1223
1298
|
dappParams: {},
|
|
@@ -1227,34 +1302,23 @@ var DappRegistrationService = class {
|
|
|
1227
1302
|
this.params = params;
|
|
1228
1303
|
this.locator = locator;
|
|
1229
1304
|
this.developmentMode = developmentMode;
|
|
1230
|
-
this.
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
);
|
|
1305
|
+
this.builtDapps = {};
|
|
1306
|
+
this.registeredAccessDappSets = /* @__PURE__ */ new Set();
|
|
1307
|
+
this.registeredDappSets = /* @__PURE__ */ new Set();
|
|
1308
|
+
this.registeredExposedDappSets = /* @__PURE__ */ new Set();
|
|
1309
|
+
this.dappAccessRequestConnection = dappAccessRequestConnection();
|
|
1310
|
+
this.exposeDappRequestConnection = exposeDappRequestConnection();
|
|
1311
|
+
this.manageSystemDapps = new ManageSystemDapps(context, this.params?.dappNames ?? [], this.params?.dappPayloads ?? [], this.params?.dappParams ?? {}, this.locator, this.developmentMode);
|
|
1238
1312
|
this.dappSeedPhraseRepository = new DappSeedPhraseRepository(context, this.params?.dappNames ?? []);
|
|
1239
1313
|
this.dappRegistry = new DappRegistry(this.dappSeedPhraseRepository);
|
|
1240
1314
|
this.addConnectionRequests();
|
|
1241
1315
|
}
|
|
1242
|
-
// Dapps that have been built with their own context
|
|
1243
|
-
builtDapps = {};
|
|
1244
|
-
dappRegistry;
|
|
1245
|
-
dappSeedPhraseRepository;
|
|
1246
|
-
manageSystemDapps;
|
|
1247
|
-
// Dapps that have been registered with dappAccessRequests
|
|
1248
|
-
registeredAccessDappSets = /* @__PURE__ */ new Set();
|
|
1249
|
-
// Dapps that have been registered with the dapp registry
|
|
1250
|
-
registeredDappSets = /* @__PURE__ */ new Set();
|
|
1251
|
-
// Dapps that have been registered with exposeDappRequests
|
|
1252
|
-
registeredExposedDappSets = /* @__PURE__ */ new Set();
|
|
1253
|
-
dappAccessRequestConnection = dappAccessRequestConnection();
|
|
1254
|
-
exposeDappRequestConnection = exposeDappRequestConnection();
|
|
1255
1316
|
async buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
|
|
1256
1317
|
const dapp = new XyOsDapp({
|
|
1257
|
-
dapp: {
|
|
1318
|
+
dapp: {
|
|
1319
|
+
id: dappId,
|
|
1320
|
+
name
|
|
1321
|
+
},
|
|
1258
1322
|
locator: this.locator,
|
|
1259
1323
|
manifest,
|
|
1260
1324
|
parent: this.context,
|
|
@@ -1267,37 +1331,43 @@ var DappRegistrationService = class {
|
|
|
1267
1331
|
return this.params?.dappParams[dappId];
|
|
1268
1332
|
}
|
|
1269
1333
|
async start() {
|
|
1270
|
-
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), {
|
|
1334
|
+
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), {
|
|
1335
|
+
name: "Install System dApps"
|
|
1336
|
+
});
|
|
1271
1337
|
const activeDapps = systemDapps.filter(({ dapp }) => dapp.icon.active === true);
|
|
1272
|
-
const results = await Promise.allSettled(
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1338
|
+
const results = await Promise.allSettled(activeDapps.map(async (dappSet) => {
|
|
1339
|
+
const { dapp } = dappSet;
|
|
1340
|
+
const registeredDapp = await this.dappRegistry.registerDapp(dapp);
|
|
1341
|
+
const result = {
|
|
1342
|
+
dapp: registeredDapp,
|
|
1343
|
+
dappIcon: dapp.icon
|
|
1344
|
+
};
|
|
1345
|
+
const forgetHandlers = /* @__PURE__ */ __name(async () => {
|
|
1346
|
+
try {
|
|
1347
|
+
await this.postRegistrationHandlers(result);
|
|
1348
|
+
} catch (e) {
|
|
1349
|
+
console.error("Error in post registration handlers", e);
|
|
1350
|
+
}
|
|
1351
|
+
}, "forgetHandlers");
|
|
1352
|
+
forget2(forgetHandlers());
|
|
1353
|
+
return result;
|
|
1354
|
+
}));
|
|
1288
1355
|
const failed = results.filter(rejected).map((result) => result.reason);
|
|
1289
1356
|
const succeeded = results.filter(fulfilled).map((result) => result.value);
|
|
1290
1357
|
for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp);
|
|
1291
|
-
return {
|
|
1358
|
+
return {
|
|
1359
|
+
failed,
|
|
1360
|
+
succeeded
|
|
1361
|
+
};
|
|
1292
1362
|
}
|
|
1293
1363
|
addConnectionRequests() {
|
|
1294
1364
|
this.context.eventBus.addConnection(this.dappAccessRequestConnection);
|
|
1295
1365
|
this.context.eventBus.addConnection(this.exposeDappRequestConnection);
|
|
1296
1366
|
}
|
|
1297
1367
|
/**
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1368
|
+
* A method to get the user property from context and eventually modify it before handing it to a dapp
|
|
1369
|
+
* i.e. curating user-approved signers
|
|
1370
|
+
*/
|
|
1301
1371
|
getUser() {
|
|
1302
1372
|
return this.context.user;
|
|
1303
1373
|
}
|
|
@@ -1305,17 +1375,19 @@ var DappRegistrationService = class {
|
|
|
1305
1375
|
if (registeredDapp.dapp) {
|
|
1306
1376
|
if (isRegisteredDappExposedDappSet(registeredDapp)) {
|
|
1307
1377
|
this.registeredExposedDappSets.add(registeredDapp);
|
|
1308
|
-
const exposeIntent = DappIntentCaller.buildIntent(
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1378
|
+
const exposeIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes.Launch, registeredDapp.dapp.config.name, DappMode2.Exposed);
|
|
1379
|
+
await this.exposeDappRequestConnection.emit(ExposeDappRequestEvent, {
|
|
1380
|
+
payloads: [
|
|
1381
|
+
registeredDapp.dapp.config,
|
|
1382
|
+
exposeIntent
|
|
1383
|
+
]
|
|
1384
|
+
});
|
|
1315
1385
|
}
|
|
1316
1386
|
if (isRegisteredDappAccessDappSet(registeredDapp)) {
|
|
1317
1387
|
this.registeredAccessDappSets.add(registeredDapp);
|
|
1318
|
-
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, {
|
|
1388
|
+
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, {
|
|
1389
|
+
payloads: registeredDapp.dapp.accessors
|
|
1390
|
+
});
|
|
1319
1391
|
}
|
|
1320
1392
|
}
|
|
1321
1393
|
}
|
|
@@ -1325,6 +1397,9 @@ var DappRegistrationService = class {
|
|
|
1325
1397
|
import { assertEx as assertEx7 } from "@xylabs/assert";
|
|
1326
1398
|
import { HDWallet as HDWallet4 } from "@xyo-network/account";
|
|
1327
1399
|
var Signers = class {
|
|
1400
|
+
static {
|
|
1401
|
+
__name(this, "Signers");
|
|
1402
|
+
}
|
|
1328
1403
|
_paths;
|
|
1329
1404
|
_signerAccounts;
|
|
1330
1405
|
_walletStore;
|
|
@@ -1375,26 +1450,32 @@ import { IndexedDbPayloadDiviner } from "@xyo-network/diviner-payload-indexeddb"
|
|
|
1375
1450
|
import { ManifestWrapper as ManifestWrapper3 } from "@xyo-network/manifest-wrapper";
|
|
1376
1451
|
import { ModuleFactoryLocator as ModuleFactoryLocator4 } from "@xyo-network/module-factory-locator";
|
|
1377
1452
|
var OS_NODE_PATH = "1'";
|
|
1378
|
-
var getDefaultOsNodeLocator = () => {
|
|
1453
|
+
var getDefaultOsNodeLocator = /* @__PURE__ */ __name(() => {
|
|
1379
1454
|
const locator = new ModuleFactoryLocator4();
|
|
1380
|
-
locator.register(IndexedDbArchivist, {
|
|
1381
|
-
|
|
1455
|
+
locator.register(IndexedDbArchivist, {
|
|
1456
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
1457
|
+
});
|
|
1458
|
+
locator.register(IndexedDbPayloadDiviner, {
|
|
1459
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
1460
|
+
});
|
|
1382
1461
|
return locator;
|
|
1383
|
-
};
|
|
1384
|
-
var loadOsNode = async (osWallet, locator) => {
|
|
1462
|
+
}, "getDefaultOsNodeLocator");
|
|
1463
|
+
var loadOsNode = /* @__PURE__ */ __name(async (osWallet, locator) => {
|
|
1385
1464
|
try {
|
|
1386
1465
|
const osNodeWallet = await osWallet.derivePath(OS_NODE_PATH);
|
|
1387
1466
|
const osNodeLocator = locator ?? getDefaultOsNodeLocator();
|
|
1388
1467
|
const manifestWrapper = new ManifestWrapper3(os_node_manifest_default, osNodeWallet, osNodeLocator);
|
|
1389
1468
|
const osNode = (await manifestWrapper.loadNodes())[0];
|
|
1390
|
-
return [
|
|
1469
|
+
return [
|
|
1470
|
+
osNode
|
|
1471
|
+
];
|
|
1391
1472
|
} catch (e) {
|
|
1392
1473
|
const error = e;
|
|
1393
1474
|
console.error(`Error creating os node: ${error.message}`);
|
|
1394
1475
|
console.error(`Error creating os node: ${error.stack}`);
|
|
1395
1476
|
throw new Error(`Error creating os node: ${error.message}`);
|
|
1396
1477
|
}
|
|
1397
|
-
};
|
|
1478
|
+
}, "loadOsNode");
|
|
1398
1479
|
|
|
1399
1480
|
// src/stack/Base.ts
|
|
1400
1481
|
import { assertEx as assertEx8 } from "@xylabs/assert";
|
|
@@ -1403,6 +1484,9 @@ import { BaseEmitter as BaseEmitter3 } from "@xyo-network/module-event-emitter";
|
|
|
1403
1484
|
import { isModuleInstance } from "@xyo-network/module-model";
|
|
1404
1485
|
import { asAttachableNodeInstance } from "@xyo-network/node-model";
|
|
1405
1486
|
var StackBase = class extends BaseEmitter3 {
|
|
1487
|
+
static {
|
|
1488
|
+
__name(this, "StackBase");
|
|
1489
|
+
}
|
|
1406
1490
|
// flag to check that all adapters are initialized
|
|
1407
1491
|
initialized = false;
|
|
1408
1492
|
// adapters to initialize into the stack
|
|
@@ -1437,57 +1521,57 @@ var StackBase = class extends BaseEmitter3 {
|
|
|
1437
1521
|
initialize() {
|
|
1438
1522
|
this.assignStack();
|
|
1439
1523
|
for (const adapter of this.adapterSet) {
|
|
1440
|
-
const driverReadyListener = async ({ node }) => await this.handleDriverReady(node);
|
|
1524
|
+
const driverReadyListener = /* @__PURE__ */ __name(async ({ node }) => await this.handleDriverReady(node), "driverReadyListener");
|
|
1441
1525
|
adapter.on("driverReady", driverReadyListener);
|
|
1442
1526
|
this.listeners.push({
|
|
1443
1527
|
adapter,
|
|
1444
1528
|
eventName: "driverReady",
|
|
1445
1529
|
listener: driverReadyListener
|
|
1446
1530
|
});
|
|
1447
|
-
const driverErrorListener = async ({ error }) => {
|
|
1531
|
+
const driverErrorListener = /* @__PURE__ */ __name(async ({ error }) => {
|
|
1448
1532
|
console.error(`Error updating ${this.stackNodeModuleId} stack node`, error);
|
|
1449
|
-
await this.emit("driverError", {
|
|
1450
|
-
|
|
1533
|
+
await this.emit("driverError", {
|
|
1534
|
+
error
|
|
1535
|
+
});
|
|
1536
|
+
}, "driverErrorListener");
|
|
1451
1537
|
adapter.on("driverError", driverErrorListener);
|
|
1452
1538
|
this.listeners.push({
|
|
1453
1539
|
adapter,
|
|
1454
1540
|
eventName: "driverError",
|
|
1455
1541
|
listener: driverErrorListener
|
|
1456
1542
|
});
|
|
1457
|
-
const startAdapter = async () => await adapter.start();
|
|
1543
|
+
const startAdapter = /* @__PURE__ */ __name(async () => await adapter.start(), "startAdapter");
|
|
1458
1544
|
forget3(startAdapter());
|
|
1459
1545
|
}
|
|
1460
1546
|
}
|
|
1461
1547
|
/**
|
|
1462
|
-
|
|
1463
|
-
|
|
1548
|
+
* Stops the stack
|
|
1549
|
+
*/
|
|
1464
1550
|
stop() {
|
|
1465
|
-
for (const {
|
|
1466
|
-
eventName,
|
|
1467
|
-
listener,
|
|
1468
|
-
adapter
|
|
1469
|
-
} of this.listeners) {
|
|
1551
|
+
for (const { eventName, listener, adapter } of this.listeners) {
|
|
1470
1552
|
adapter.off(eventName, listener);
|
|
1471
1553
|
}
|
|
1472
1554
|
}
|
|
1473
1555
|
/**
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1556
|
+
* Adds a node to the stack. Idempotent to avoid adding the
|
|
1557
|
+
* same node multiple times
|
|
1558
|
+
* @param node The node to add to the stack
|
|
1559
|
+
* @returns
|
|
1560
|
+
*/
|
|
1479
1561
|
async addNodeToStackNode(node) {
|
|
1480
1562
|
const stackNode = await this.getStackNode();
|
|
1481
|
-
const existingModule = await stackNode.resolve(node.address, {
|
|
1563
|
+
const existingModule = await stackNode.resolve(node.address, {
|
|
1564
|
+
direction: "down"
|
|
1565
|
+
});
|
|
1482
1566
|
if (isModuleInstance(existingModule)) return;
|
|
1483
1567
|
await stackNode.register?.(node);
|
|
1484
1568
|
await stackNode.attach?.(node.address, true);
|
|
1485
1569
|
}
|
|
1486
1570
|
assignStack() {
|
|
1487
|
-
const assign = async () => {
|
|
1571
|
+
const assign = /* @__PURE__ */ __name(async () => {
|
|
1488
1572
|
const stackNode = await this.getStackNode();
|
|
1489
1573
|
this._stack = stackNode;
|
|
1490
|
-
};
|
|
1574
|
+
}, "assign");
|
|
1491
1575
|
forget3(assign());
|
|
1492
1576
|
}
|
|
1493
1577
|
async getStackNode() {
|
|
@@ -1496,25 +1580,34 @@ var StackBase = class extends BaseEmitter3 {
|
|
|
1496
1580
|
}
|
|
1497
1581
|
async handleDriverReady(node) {
|
|
1498
1582
|
try {
|
|
1499
|
-
await this.emit("driverReady", {
|
|
1583
|
+
await this.emit("driverReady", {
|
|
1584
|
+
node
|
|
1585
|
+
});
|
|
1500
1586
|
await this.addNodeToStackNode(node);
|
|
1501
1587
|
await this.updateInitializationState(node);
|
|
1502
1588
|
} catch (error) {
|
|
1503
1589
|
console.error(`Error updating ${this.stackNodeModuleId} stack node`, node.id, error);
|
|
1504
|
-
await this.emit("stackError", {
|
|
1590
|
+
await this.emit("stackError", {
|
|
1591
|
+
error
|
|
1592
|
+
});
|
|
1505
1593
|
}
|
|
1506
1594
|
}
|
|
1507
1595
|
async updateInitializationState(node) {
|
|
1508
1596
|
this.initializedNodes.push(node);
|
|
1509
1597
|
this.initialized = this.adapterSet.every((n) => n.initialized);
|
|
1510
1598
|
if (this.initialized) {
|
|
1511
|
-
await this.emit("initialized", {
|
|
1599
|
+
await this.emit("initialized", {
|
|
1600
|
+
stack: await this.getStackNode()
|
|
1601
|
+
});
|
|
1512
1602
|
}
|
|
1513
1603
|
}
|
|
1514
1604
|
};
|
|
1515
1605
|
|
|
1516
1606
|
// src/stack/Manager.ts
|
|
1517
1607
|
var StackManager = class {
|
|
1608
|
+
static {
|
|
1609
|
+
__name(this, "StackManager");
|
|
1610
|
+
}
|
|
1518
1611
|
initializedStacksMap = /* @__PURE__ */ new Map();
|
|
1519
1612
|
stackMap;
|
|
1520
1613
|
constructor(stackMap) {
|
|
@@ -1556,27 +1649,30 @@ import { BaseEmitter as BaseEmitter4 } from "@xyo-network/module-event-emitter";
|
|
|
1556
1649
|
import { asAttachableNodeInstance as asAttachableNodeInstance2 } from "@xyo-network/node-model";
|
|
1557
1650
|
import { v4 as uuid3 } from "uuid";
|
|
1558
1651
|
var NodeAdapterBase = class extends BaseEmitter4 {
|
|
1652
|
+
static {
|
|
1653
|
+
__name(this, "NodeAdapterBase");
|
|
1654
|
+
}
|
|
1655
|
+
kernel;
|
|
1656
|
+
driverName;
|
|
1657
|
+
initialized;
|
|
1658
|
+
_id;
|
|
1559
1659
|
constructor(kernel, driverName) {
|
|
1560
|
-
super({});
|
|
1561
|
-
this.kernel = kernel;
|
|
1562
|
-
this.driverName = driverName;
|
|
1660
|
+
super({}), this.kernel = kernel, this.driverName = driverName, this.initialized = false, this._id = "";
|
|
1563
1661
|
this._id = uuid3();
|
|
1564
1662
|
}
|
|
1565
|
-
initialized = false;
|
|
1566
|
-
_id = "";
|
|
1567
1663
|
get id() {
|
|
1568
1664
|
return assertEx9(this._id, () => "NodeAdapterBase id not initialized");
|
|
1569
1665
|
}
|
|
1570
1666
|
async start() {
|
|
1571
1667
|
try {
|
|
1572
|
-
const moduleAttachedInsertListener = ({ payloads }) => {
|
|
1668
|
+
const moduleAttachedInsertListener = /* @__PURE__ */ __name(({ payloads }) => {
|
|
1573
1669
|
const moduleAttachedEvent = this.findModuleEventPayloads(payloads);
|
|
1574
1670
|
for (const payload of moduleAttachedEvent) {
|
|
1575
1671
|
if (payload.name === this.driverName) {
|
|
1576
1672
|
this.validateAndReturnDriver();
|
|
1577
1673
|
}
|
|
1578
1674
|
}
|
|
1579
|
-
};
|
|
1675
|
+
}, "moduleAttachedInsertListener");
|
|
1580
1676
|
const eventsArchivist = await this.getEventsArchivist();
|
|
1581
1677
|
const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener);
|
|
1582
1678
|
const insertListenerRef = weakRefInsertListener.deref();
|
|
@@ -1585,7 +1681,9 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
1585
1681
|
if (node) return node;
|
|
1586
1682
|
this.initialized = false;
|
|
1587
1683
|
} catch (error) {
|
|
1588
|
-
await this.emit("driverError", {
|
|
1684
|
+
await this.emit("driverError", {
|
|
1685
|
+
error
|
|
1686
|
+
});
|
|
1589
1687
|
}
|
|
1590
1688
|
}
|
|
1591
1689
|
findModuleEventPayloads(payloads) {
|
|
@@ -1603,7 +1701,9 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
1603
1701
|
if (mod) {
|
|
1604
1702
|
const node = asAttachableNodeInstance2(mod, () => `${mod.id} is not a node`);
|
|
1605
1703
|
this.initialized = true;
|
|
1606
|
-
const emit = async () => await this.emit("driverReady", {
|
|
1704
|
+
const emit = /* @__PURE__ */ __name(async () => await this.emit("driverReady", {
|
|
1705
|
+
node
|
|
1706
|
+
}), "emit");
|
|
1607
1707
|
forget4(emit());
|
|
1608
1708
|
return node;
|
|
1609
1709
|
}
|
|
@@ -1612,6 +1712,9 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
1612
1712
|
|
|
1613
1713
|
// src/adapter/Network.ts
|
|
1614
1714
|
var NetworkAdapter = class extends NodeAdapterBase {
|
|
1715
|
+
static {
|
|
1716
|
+
__name(this, "NetworkAdapter");
|
|
1717
|
+
}
|
|
1615
1718
|
_connection;
|
|
1616
1719
|
constructor(kernel, driverName) {
|
|
1617
1720
|
super(kernel, driverName);
|
|
@@ -1632,6 +1735,9 @@ var NetworkAdapter = class extends NodeAdapterBase {
|
|
|
1632
1735
|
|
|
1633
1736
|
// src/adapter/Settings.ts
|
|
1634
1737
|
var SettingsAdapter = class extends NodeAdapterBase {
|
|
1738
|
+
static {
|
|
1739
|
+
__name(this, "SettingsAdapter");
|
|
1740
|
+
}
|
|
1635
1741
|
_settings = void 0;
|
|
1636
1742
|
constructor(kernel, driverName) {
|
|
1637
1743
|
super(kernel, driverName);
|
|
@@ -1651,26 +1757,31 @@ var SettingsAdapter = class extends NodeAdapterBase {
|
|
|
1651
1757
|
};
|
|
1652
1758
|
|
|
1653
1759
|
// src/adapters/OsPubSubBridgeNetwork.ts
|
|
1654
|
-
var OsPubSubBridgeNetworkAdapters = (kernel) => [
|
|
1760
|
+
var OsPubSubBridgeNetworkAdapters = /* @__PURE__ */ __name((kernel) => [
|
|
1655
1761
|
new NetworkAdapter(kernel, PubSubBridgeNodeNodeName),
|
|
1656
1762
|
new NetworkAdapter(kernel, ExposedNodeOuterNodeName)
|
|
1657
|
-
];
|
|
1763
|
+
], "OsPubSubBridgeNetworkAdapters");
|
|
1658
1764
|
|
|
1659
1765
|
// src/adapters/OsSettings.ts
|
|
1660
1766
|
import { OsSettingsNodeName } from "@xyo-network/os-model";
|
|
1661
|
-
var OsSettingsAdapters = (kernel) => [
|
|
1767
|
+
var OsSettingsAdapters = /* @__PURE__ */ __name((kernel) => [
|
|
1768
|
+
new SettingsAdapter(kernel, OsSettingsNodeName)
|
|
1769
|
+
], "OsSettingsAdapters");
|
|
1662
1770
|
|
|
1663
1771
|
// src/adapters/OsXyoPublicNetwork.ts
|
|
1664
1772
|
import { XyoPublicNodeName } from "@xyo-network/os-model";
|
|
1665
|
-
var OsXyoPublicNetworkAdapters = (kernel) => [
|
|
1773
|
+
var OsXyoPublicNetworkAdapters = /* @__PURE__ */ __name((kernel) => [
|
|
1666
1774
|
new NetworkAdapter(kernel, XyoPublicNodeName)
|
|
1667
|
-
];
|
|
1775
|
+
], "OsXyoPublicNetworkAdapters");
|
|
1668
1776
|
|
|
1669
1777
|
// src/stack/OsPubSubNetworkStack.ts
|
|
1670
1778
|
import { assertEx as assertEx10 } from "@xylabs/assert";
|
|
1671
1779
|
import { asAttachableNodeInstance as asAttachableNodeInstance3, asNodeInstance } from "@xyo-network/node-model";
|
|
1672
1780
|
import { ExposedNodeOuterNodeName as ExposedNodeOuterNodeName2, PubSubBridgeNodeNodeName as PubSubBridgeNodeNodeName2 } from "@xyo-network/os-model";
|
|
1673
1781
|
var OsPubSubNetworkStack = class extends StackBase {
|
|
1782
|
+
static {
|
|
1783
|
+
__name(this, "OsPubSubNetworkStack");
|
|
1784
|
+
}
|
|
1674
1785
|
_exposedNode;
|
|
1675
1786
|
_exposedNodeOuter;
|
|
1676
1787
|
busConnection = osPubSubNetworkReadyConnection();
|
|
@@ -1713,13 +1824,15 @@ var OsPubSubNetworkStack = class extends StackBase {
|
|
|
1713
1824
|
super.stop();
|
|
1714
1825
|
this._exposedNode = void 0;
|
|
1715
1826
|
this._exposedNodeOuter = void 0;
|
|
1716
|
-
if (this.busConnection._id)
|
|
1717
|
-
this.context.eventBus.removeConnection(this.busConnection.id);
|
|
1827
|
+
if (this.busConnection._id) this.context.eventBus.removeConnection(this.busConnection.id);
|
|
1718
1828
|
}
|
|
1719
1829
|
};
|
|
1720
1830
|
|
|
1721
1831
|
// src/stack/OsSettingsStack.ts
|
|
1722
1832
|
var OsSettingsStack = class extends StackBase {
|
|
1833
|
+
static {
|
|
1834
|
+
__name(this, "OsSettingsStack");
|
|
1835
|
+
}
|
|
1723
1836
|
busConnection = osSettingsReadyConnection();
|
|
1724
1837
|
constructor(context, adapters) {
|
|
1725
1838
|
super(context, adapters, "OsSettingsStackNode");
|
|
@@ -1737,6 +1850,9 @@ var OsSettingsStack = class extends StackBase {
|
|
|
1737
1850
|
// src/stack/XyoPublicNetworkStack.ts
|
|
1738
1851
|
import { XyoPublicNodeName as XyoPublicNodeName2 } from "@xyo-network/os-model";
|
|
1739
1852
|
var XyoPublicNetworkStack = class extends StackBase {
|
|
1853
|
+
static {
|
|
1854
|
+
__name(this, "XyoPublicNetworkStack");
|
|
1855
|
+
}
|
|
1740
1856
|
busConnection = osXyoPublicNetworkReadyConnection();
|
|
1741
1857
|
constructor(context, adapters) {
|
|
1742
1858
|
super(context, adapters, "OsXyoPublicNetworkStackNode");
|
|
@@ -1775,6 +1891,9 @@ var OsStackMap = {
|
|
|
1775
1891
|
|
|
1776
1892
|
// src/XyOs.ts
|
|
1777
1893
|
var XyOs = class _XyOs extends XyOsContextBase {
|
|
1894
|
+
static {
|
|
1895
|
+
__name(this, "XyOs");
|
|
1896
|
+
}
|
|
1778
1897
|
_exposedNode;
|
|
1779
1898
|
_exposedNodeOuter;
|
|
1780
1899
|
_kernel;
|
|
@@ -1782,16 +1901,9 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
1782
1901
|
dappRegistrationService;
|
|
1783
1902
|
signers;
|
|
1784
1903
|
stackManager;
|
|
1785
|
-
constructor({
|
|
1786
|
-
logger
|
|
1787
|
-
|
|
1788
|
-
kernel = new Kernel({ logger }),
|
|
1789
|
-
locator = new ModuleFactoryLocator5(),
|
|
1790
|
-
dappsConfiguration,
|
|
1791
|
-
developmentMode,
|
|
1792
|
-
stackMap = OsStackMap,
|
|
1793
|
-
...params
|
|
1794
|
-
} = {}) {
|
|
1904
|
+
constructor({ logger = console, eventBus = new EventBus(), kernel = new Kernel({
|
|
1905
|
+
logger
|
|
1906
|
+
}), locator = new ModuleFactoryLocator5(), dappsConfiguration, developmentMode, stackMap = OsStackMap, ...params } = {}) {
|
|
1795
1907
|
super({
|
|
1796
1908
|
eventBus,
|
|
1797
1909
|
kernel,
|
|
@@ -1829,14 +1941,19 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
1829
1941
|
return this.stackManager.stacks;
|
|
1830
1942
|
}
|
|
1831
1943
|
get user() {
|
|
1832
|
-
return {
|
|
1944
|
+
return {
|
|
1945
|
+
signers: this.signers?.getWalletKindSigner("user")
|
|
1946
|
+
};
|
|
1833
1947
|
}
|
|
1834
1948
|
static async monitor(fn, eventConfig) {
|
|
1835
1949
|
const { name, additionalProperties } = eventConfig;
|
|
1836
1950
|
const monitor = this.monitoring;
|
|
1837
1951
|
monitor?.startTimer(name);
|
|
1838
1952
|
const result = await fn();
|
|
1839
|
-
monitor?.stopTimer({
|
|
1953
|
+
monitor?.stopTimer({
|
|
1954
|
+
additionalProperties,
|
|
1955
|
+
name
|
|
1956
|
+
});
|
|
1840
1957
|
return result;
|
|
1841
1958
|
}
|
|
1842
1959
|
async boot(wallet, locator = new ModuleFactoryLocator5()) {
|
|
@@ -1845,13 +1962,18 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
1845
1962
|
return await this._bootMutex.runExclusive(async () => {
|
|
1846
1963
|
await this.eventBus.start();
|
|
1847
1964
|
if (this.kernel?.status === "created") {
|
|
1848
|
-
await this.kernel.boot(await boot(), {
|
|
1965
|
+
await this.kernel.boot(await boot(), {
|
|
1966
|
+
locator: fullLocator,
|
|
1967
|
+
kernelDrivers: []
|
|
1968
|
+
});
|
|
1849
1969
|
}
|
|
1850
1970
|
if (this.kernel?.status !== "booted") {
|
|
1851
1971
|
throw new Error("Kernel not booted");
|
|
1852
1972
|
}
|
|
1853
1973
|
assertEx11(this._root === void 0, () => "XyOs already booted");
|
|
1854
|
-
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), {
|
|
1974
|
+
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), {
|
|
1975
|
+
name: "Load XyOs"
|
|
1976
|
+
});
|
|
1855
1977
|
this._root = root;
|
|
1856
1978
|
this.stackManager.initialize(this);
|
|
1857
1979
|
if (this.signers) await this.signers.initialize();
|
|
@@ -1882,26 +2004,32 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
1882
2004
|
|
|
1883
2005
|
// src/scripts/xyos/lib/headless.ts
|
|
1884
2006
|
var { terminal } = tk;
|
|
1885
|
-
var terminate = () => {
|
|
2007
|
+
var terminate = /* @__PURE__ */ __name(() => {
|
|
1886
2008
|
terminal.grabInput(false);
|
|
1887
2009
|
setTimeout(function() {
|
|
1888
2010
|
process.exit(0);
|
|
1889
2011
|
}, 100);
|
|
1890
|
-
};
|
|
1891
|
-
var headless = async ({
|
|
1892
|
-
manifest,
|
|
1893
|
-
config,
|
|
1894
|
-
kernelDrivers
|
|
1895
|
-
} = {}) => {
|
|
2012
|
+
}, "terminate");
|
|
2013
|
+
var headless = /* @__PURE__ */ __name(async ({ manifest, config, kernelDrivers } = {}) => {
|
|
1896
2014
|
console.log(chalk.green("Starting Headless xyOS..."));
|
|
1897
|
-
const configExplorer = cosmiconfig("xyos", {
|
|
2015
|
+
const configExplorer = cosmiconfig("xyos", {
|
|
2016
|
+
cache: true,
|
|
2017
|
+
loaders: {
|
|
2018
|
+
".ts": TypeScriptLoader()
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
1898
2021
|
const configResult = await (config ? configExplorer.load(config) : configExplorer.search());
|
|
1899
2022
|
const xyosConfig = configResult?.config ?? {};
|
|
1900
2023
|
const manifestToLoad = manifest ?? (typeof xyosConfig.manifest === "string" ? xyosConfig.manifest : void 0);
|
|
1901
2024
|
const manifestObject = manifestToLoad ? JSON.parse(fs.readFileSync(manifestToLoad, "utf8")) : typeof xyosConfig.manifest === "object" ? xyosConfig.manifest : void 0;
|
|
1902
2025
|
const osWallet = await HDWallet5.random();
|
|
1903
|
-
const kernel = new Kernel2({
|
|
1904
|
-
|
|
2026
|
+
const kernel = new Kernel2({
|
|
2027
|
+
logColor: "cyan",
|
|
2028
|
+
logger: console
|
|
2029
|
+
});
|
|
2030
|
+
await kernel.boot(await boot2(), {
|
|
2031
|
+
kernelDrivers
|
|
2032
|
+
});
|
|
1905
2033
|
const xyOs = new XyOs({
|
|
1906
2034
|
kernel,
|
|
1907
2035
|
stackMap: {},
|
|
@@ -1910,20 +2038,28 @@ var headless = async ({
|
|
|
1910
2038
|
});
|
|
1911
2039
|
await xyOs.boot(osWallet);
|
|
1912
2040
|
console.log(chalk.green("Started Headless xyOS..."));
|
|
1913
|
-
terminal.grabInput({
|
|
2041
|
+
terminal.grabInput({
|
|
2042
|
+
mouse: "button"
|
|
2043
|
+
});
|
|
1914
2044
|
terminal.on("key", function(name) {
|
|
1915
2045
|
console.log("'key' event:", name);
|
|
1916
2046
|
if (name === "CTRL_C") {
|
|
1917
2047
|
terminate();
|
|
1918
2048
|
}
|
|
1919
2049
|
});
|
|
1920
|
-
};
|
|
2050
|
+
}, "headless");
|
|
1921
2051
|
|
|
1922
2052
|
// src/scripts/xyos/command/create.ts
|
|
1923
|
-
var commandCreate = (argv) => {
|
|
2053
|
+
var commandCreate = /* @__PURE__ */ __name((argv) => {
|
|
1924
2054
|
return argv.command("create [template] <target>", "Create an xyos project", (yargs) => {
|
|
1925
2055
|
return yargs.positional("template", {
|
|
1926
|
-
choices: [
|
|
2056
|
+
choices: [
|
|
2057
|
+
"react",
|
|
2058
|
+
"headless",
|
|
2059
|
+
"dapp",
|
|
2060
|
+
"diviner",
|
|
2061
|
+
"witness"
|
|
2062
|
+
],
|
|
1927
2063
|
description: "Template to use",
|
|
1928
2064
|
type: "string"
|
|
1929
2065
|
}).positional("target", {
|
|
@@ -1932,15 +2068,22 @@ var commandCreate = (argv) => {
|
|
|
1932
2068
|
});
|
|
1933
2069
|
}, async ({ template, target }) => {
|
|
1934
2070
|
console.log(`Using template ${template} at location ${target}`);
|
|
1935
|
-
return await createFromTemplate({
|
|
2071
|
+
return await createFromTemplate({
|
|
2072
|
+
target,
|
|
2073
|
+
template
|
|
2074
|
+
});
|
|
1936
2075
|
});
|
|
1937
|
-
};
|
|
2076
|
+
}, "commandCreate");
|
|
1938
2077
|
|
|
1939
2078
|
// src/scripts/xyos/command/manifest.ts
|
|
1940
|
-
var commandManifest = (argv) => {
|
|
2079
|
+
var commandManifest = /* @__PURE__ */ __name((argv) => {
|
|
1941
2080
|
return argv.command("manifest [action] <target>", "Create an xyos project", (yargs) => {
|
|
1942
2081
|
return yargs.positional("action", {
|
|
1943
|
-
choices: [
|
|
2082
|
+
choices: [
|
|
2083
|
+
"create",
|
|
2084
|
+
"validate",
|
|
2085
|
+
"display"
|
|
2086
|
+
],
|
|
1944
2087
|
description: "Action to take on manifest",
|
|
1945
2088
|
type: "string"
|
|
1946
2089
|
}).positional("target", {
|
|
@@ -1951,10 +2094,10 @@ var commandManifest = (argv) => {
|
|
|
1951
2094
|
console.log(`Taking action [${action}] on manifest at ${target}`);
|
|
1952
2095
|
return await Promise.resolve();
|
|
1953
2096
|
});
|
|
1954
|
-
};
|
|
2097
|
+
}, "commandManifest");
|
|
1955
2098
|
|
|
1956
2099
|
// src/scripts/xyos/command/start.ts
|
|
1957
|
-
var commandStart = (argv) => {
|
|
2100
|
+
var commandStart = /* @__PURE__ */ __name((argv) => {
|
|
1958
2101
|
return argv.command("start", "Start xyOS in headless mode", (yargs) => {
|
|
1959
2102
|
return yargs.option("config", {
|
|
1960
2103
|
alias: "c",
|
|
@@ -1969,11 +2112,7 @@ var commandStart = (argv) => {
|
|
|
1969
2112
|
description: "Kernel driver to load",
|
|
1970
2113
|
type: "string"
|
|
1971
2114
|
});
|
|
1972
|
-
}, async ({
|
|
1973
|
-
config,
|
|
1974
|
-
manifest,
|
|
1975
|
-
kernelDriver
|
|
1976
|
-
}) => {
|
|
2115
|
+
}, async ({ config, manifest, kernelDriver }) => {
|
|
1977
2116
|
if (config) {
|
|
1978
2117
|
console.log(`Using config: ${config}`);
|
|
1979
2118
|
}
|
|
@@ -1983,10 +2122,12 @@ var commandStart = (argv) => {
|
|
|
1983
2122
|
await headless({
|
|
1984
2123
|
manifest,
|
|
1985
2124
|
config,
|
|
1986
|
-
kernelDrivers: kernelDriver ? [
|
|
2125
|
+
kernelDrivers: kernelDriver ? [
|
|
2126
|
+
kernelDriver
|
|
2127
|
+
] : []
|
|
1987
2128
|
});
|
|
1988
2129
|
});
|
|
1989
|
-
};
|
|
2130
|
+
}, "commandStart");
|
|
1990
2131
|
export {
|
|
1991
2132
|
commandConfig,
|
|
1992
2133
|
commandCreate,
|