pico-engine 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +188 -0
  2. package/dist/RulesetRegistryLoaderFs.js +2 -0
  3. package/dist/auth/AuthService.js +601 -0
  4. package/dist/auth/index.js +8 -0
  5. package/dist/auth/webauthn.js +97 -0
  6. package/dist/bundledKrl.js +42 -0
  7. package/dist/cli.js +11 -0
  8. package/dist/identity/IdentityService.js +340 -0
  9. package/dist/identity/crossPico.js +238 -0
  10. package/dist/identity/dbHelpers.js +67 -0
  11. package/dist/identity/didcommIngressRoutes.js +44 -0
  12. package/dist/identity/didoModule.js +252 -0
  13. package/dist/identity/errors.js +11 -0
  14. package/dist/identity/establishSubscription.js +97 -0
  15. package/dist/identity/index.js +15 -0
  16. package/dist/identity/peerDid.js +9 -0
  17. package/dist/identity/skyIntro.js +194 -0
  18. package/dist/identity/skyProtocol.js +105 -0
  19. package/dist/identity/store.js +233 -0
  20. package/dist/identity/types.js +13 -0
  21. package/dist/identity/veramoDidComm.js +260 -0
  22. package/dist/identity/webvh.js +266 -0
  23. package/dist/identity/webvhCrypto.js +128 -0
  24. package/dist/identity/webvhRoutes.js +61 -0
  25. package/dist/index.js +100 -44
  26. package/dist/oauth/OAuthService.js +388 -0
  27. package/dist/oauth/acg.js +495 -0
  28. package/dist/oauth/channelEligibility.js +26 -0
  29. package/dist/oauth/errors.js +12 -0
  30. package/dist/oauth/index.js +21 -0
  31. package/dist/oauth/krlModule.js +27 -0
  32. package/dist/oauth/meshOAuth.js +43 -0
  33. package/dist/provisionRoot.js +118 -0
  34. package/dist/server.js +609 -15
  35. package/dist/uiChannelPolicies.js +48 -0
  36. package/krl/io.picolabs.did-o.krl +5 -1
  37. package/krl/io.picolabs.oauth.krl +48 -0
  38. package/krl/io.picolabs.pico-engine-ui.krl +106 -18
  39. package/krl/io.picolabs.subscription.krl +242 -23
  40. package/krl/io.picolabs.wrangler.krl +225 -16
  41. package/package.json +38 -9
  42. package/public/docs/krl/_sidebar.md +1 -0
  43. package/public/docs/krl/discovery.md +144 -0
  44. package/public/docs/krl/modules/ctx.md +8 -0
  45. package/public/docs/krl/modules/event.md +41 -0
  46. package/public/pico-engine-ui.css +1 -1
  47. package/public/pico-engine-ui.js +24 -20
  48. package/public/pico-labs-logo.png +0 -0
  49. package/src/RulesetRegistryLoaderFs.ts +2 -0
  50. package/src/auth/AuthService.ts +850 -0
  51. package/src/auth/index.ts +17 -0
  52. package/src/auth/webauthn.ts +182 -0
  53. package/src/bundledKrl.ts +42 -0
  54. package/src/cli.ts +11 -0
  55. package/src/identity/IdentityService.ts +571 -0
  56. package/src/identity/crossPico.ts +371 -0
  57. package/src/identity/dbHelpers.ts +51 -0
  58. package/src/identity/didcommIngressRoutes.ts +54 -0
  59. package/src/identity/didoModule.ts +388 -0
  60. package/src/identity/errors.ts +8 -0
  61. package/src/identity/establishSubscription.ts +160 -0
  62. package/src/identity/index.ts +24 -0
  63. package/src/identity/peerDid.ts +22 -0
  64. package/src/identity/skyIntro.ts +321 -0
  65. package/src/identity/skyProtocol.ts +192 -0
  66. package/src/identity/store.ts +343 -0
  67. package/src/identity/types.ts +63 -0
  68. package/src/identity/veramoDidComm.ts +363 -0
  69. package/src/identity/webvh.ts +325 -0
  70. package/src/identity/webvhCrypto.ts +200 -0
  71. package/src/identity/webvhRoutes.ts +64 -0
  72. package/src/index.ts +145 -53
  73. package/src/oauth/OAuthService.ts +510 -0
  74. package/src/oauth/acg.ts +666 -0
  75. package/src/oauth/channelEligibility.ts +26 -0
  76. package/src/oauth/errors.ts +10 -0
  77. package/src/oauth/index.ts +14 -0
  78. package/src/oauth/krlModule.ts +31 -0
  79. package/src/oauth/meshOAuth.ts +50 -0
  80. package/src/provisionRoot.ts +151 -0
  81. package/src/server.ts +700 -24
  82. package/src/uiChannelPolicies.ts +49 -0
@@ -0,0 +1,200 @@
1
+ import { ed25519 } from "@noble/curves/ed25519.js";
2
+ import {
3
+ bytesToHex,
4
+ convertEd25519PrivateKeyToX25519,
5
+ convertEd25519PublicKeyToX25519,
6
+ } from "@veramo/utils";
7
+ import type {
8
+ SignableDocument,
9
+ SigningInput,
10
+ SigningOutput,
11
+ VerificationMethod,
12
+ Verifier,
13
+ } from "didwebvh-ts/dist/types/interfaces";
14
+
15
+ type DidWebvhTs = typeof import("didwebvh-ts");
16
+
17
+ export interface StoredWebvhKeyMaterial {
18
+ updateKeyMultibase: string;
19
+ verificationMethodId: string;
20
+ verificationMethod: VerificationMethod & { secretKeyMultibase: string };
21
+ }
22
+
23
+ export async function generateWebvhKeyMaterial(): Promise<StoredWebvhKeyMaterial> {
24
+ const webvh = await loadDidWebvhTs();
25
+ const { secretKey, publicKey } = ed25519.keygen();
26
+ const publicKeyMultibase = webvh.multibaseEncode(
27
+ new Uint8Array([0xed, 0x01, ...publicKey]),
28
+ webvh.MultibaseEncoding.BASE58_BTC
29
+ );
30
+ const secretKeyMultibase = webvh.multibaseEncode(
31
+ new Uint8Array([0x80, 0x26, ...secretKey, ...publicKey]),
32
+ webvh.MultibaseEncoding.BASE58_BTC
33
+ );
34
+ const verificationMethodId = `did:key:${publicKeyMultibase}#${publicKeyMultibase}`;
35
+ return {
36
+ updateKeyMultibase: publicKeyMultibase,
37
+ verificationMethodId,
38
+ verificationMethod: {
39
+ type: "Multikey",
40
+ publicKeyMultibase,
41
+ secretKeyMultibase,
42
+ purpose: "assertionMethod",
43
+ },
44
+ };
45
+ }
46
+
47
+ export async function createWebvhCrypto(
48
+ keys: StoredWebvhKeyMaterial
49
+ ): Promise<WebvhCrypto> {
50
+ const webvh = await loadDidWebvhTs();
51
+ return new WebvhCrypto(webvh, keys);
52
+ }
53
+
54
+ export class WebvhCrypto {
55
+ private webvh: DidWebvhTs;
56
+ readonly keys: StoredWebvhKeyMaterial;
57
+
58
+ constructor(webvh: DidWebvhTs, keys: StoredWebvhKeyMaterial) {
59
+ this.webvh = webvh;
60
+ this.keys = keys;
61
+ }
62
+
63
+ getVerificationMethodId(): string {
64
+ return this.keys.verificationMethodId;
65
+ }
66
+
67
+ async sign(input: SigningInput<SignableDocument>): Promise<SigningOutput> {
68
+ const { bytes: secretKeyBytes } = this.webvh.multibaseDecode(
69
+ this.keys.verificationMethod.secretKeyMultibase
70
+ );
71
+ const seed = secretKeyBytes.slice(2).slice(0, 32);
72
+ const proof = ed25519.sign(
73
+ await this.webvh.prepareDataForSigning(input.document, input.proof),
74
+ seed
75
+ );
76
+ return {
77
+ proofValue: this.webvh.multibaseEncode(
78
+ proof,
79
+ this.webvh.MultibaseEncoding.BASE58_BTC
80
+ ),
81
+ };
82
+ }
83
+
84
+ async verify(
85
+ signature: Uint8Array,
86
+ message: Uint8Array,
87
+ publicKey: Uint8Array
88
+ ): Promise<boolean> {
89
+ return ed25519.verify(signature, message, publicKey, { zip215: false });
90
+ }
91
+ }
92
+
93
+ export function storedKeysFromWebvhKeys(
94
+ raw: Record<string, unknown>
95
+ ): StoredWebvhKeyMaterial | null {
96
+ const updateKeyMultibase = raw.updateKeyMultibase;
97
+ const verificationMethodId = raw.verificationMethodId;
98
+ const verificationMethod = raw.verificationMethod;
99
+ if (
100
+ typeof updateKeyMultibase !== "string" ||
101
+ typeof verificationMethodId !== "string" ||
102
+ !verificationMethod ||
103
+ typeof verificationMethod !== "object"
104
+ ) {
105
+ return null;
106
+ }
107
+ const vm = verificationMethod as VerificationMethod & {
108
+ secretKeyMultibase?: string;
109
+ };
110
+ if (typeof vm.secretKeyMultibase !== "string") {
111
+ return null;
112
+ }
113
+ return {
114
+ updateKeyMultibase,
115
+ verificationMethodId,
116
+ verificationMethod: vm as StoredWebvhKeyMaterial["verificationMethod"],
117
+ };
118
+ }
119
+
120
+ export function webvhKeysToStore(keys: StoredWebvhKeyMaterial): Record<string, unknown> {
121
+ return {
122
+ updateKeyMultibase: keys.updateKeyMultibase,
123
+ verificationMethodId: keys.verificationMethodId,
124
+ verificationMethod: keys.verificationMethod,
125
+ };
126
+ }
127
+
128
+ /** Veramo key material for decrypting DIDComm addressed to this pico's did:webvh. */
129
+ export async function webvhAgreementKeysForVeramo(
130
+ did: string,
131
+ doc: Record<string, unknown>,
132
+ keys: StoredWebvhKeyMaterial
133
+ ): Promise<
134
+ Array<{
135
+ type: string;
136
+ kid: string;
137
+ privateKeyHex: string;
138
+ publicKeyHex: string;
139
+ kms: string;
140
+ }>
141
+ > {
142
+ const webvh = await loadDidWebvhTs();
143
+ const { bytes: secretKeyBytes } = webvh.multibaseDecode(
144
+ keys.verificationMethod.secretKeyMultibase
145
+ );
146
+ const seed = secretKeyBytes.slice(2, 34);
147
+ const { bytes: publicKeyBytes } = webvh.multibaseDecode(
148
+ keys.verificationMethod.publicKeyMultibase as string
149
+ );
150
+ const edPub = publicKeyBytes.slice(2);
151
+ const xPub = convertEd25519PublicKeyToX25519(edPub);
152
+ const xPriv = convertEd25519PrivateKeyToX25519(seed);
153
+
154
+ const keyAgreement = doc.keyAgreement;
155
+ const kids: string[] = [];
156
+ if (Array.isArray(keyAgreement)) {
157
+ for (const entry of keyAgreement) {
158
+ if (typeof entry === "string") {
159
+ kids.push(entry);
160
+ } else if (entry && typeof entry === "object" && typeof (entry as { id?: string }).id === "string") {
161
+ kids.push((entry as { id: string }).id);
162
+ }
163
+ }
164
+ }
165
+ if (kids.length === 0) {
166
+ kids.push(`${did}#didcomm`);
167
+ }
168
+
169
+ return kids.map((kid) => ({
170
+ type: "X25519",
171
+ kid,
172
+ privateKeyHex: bytesToHex(xPriv),
173
+ publicKeyHex: bytesToHex(xPub),
174
+ kms: "local",
175
+ }));
176
+ }
177
+
178
+ let didWebvhTs: DidWebvhTs | undefined;
179
+
180
+ export async function loadDidWebvhTs(): Promise<DidWebvhTs> {
181
+ if (!didWebvhTs) {
182
+ didWebvhTs = await import("didwebvh-ts");
183
+ }
184
+ return didWebvhTs;
185
+ }
186
+
187
+ export type WebvhVerifier = Verifier;
188
+
189
+ export async function createPassthroughVerifier(): Promise<Verifier> {
190
+ return {
191
+ async verify(
192
+ signature: Uint8Array,
193
+ message: Uint8Array,
194
+ publicKey: Uint8Array
195
+ ): Promise<boolean> {
196
+ const { ed25519 } = await import("@noble/curves/ed25519.js");
197
+ return ed25519.verify(signature, message, publicKey, { zip215: false });
198
+ },
199
+ };
200
+ }
@@ -0,0 +1,64 @@
1
+ import { Express, Request, Response } from "express";
2
+ import { IdentityService } from "./IdentityService";
3
+ import { resolveLocalWebvhLog } from "./webvh";
4
+ import { IdentityError } from "./errors";
5
+
6
+ export function registerWebvhRoutes(
7
+ app: Express,
8
+ identity: IdentityService
9
+ ): void {
10
+ app.get("/identity/resolve", async (req: Request, res: Response) => {
11
+ try {
12
+ const did = String(req.query.did || "").trim();
13
+ if (!did) {
14
+ res.status(400).json({ error: "Missing did query parameter" });
15
+ return;
16
+ }
17
+ const doc = await identity.resolveDid("", did);
18
+ res.json({ did, didDocument: doc });
19
+ } catch (err) {
20
+ sendIdentityError(res, err);
21
+ }
22
+ });
23
+
24
+ app.get("/picos/:picoId/did.jsonl", async (req: Request, res: Response) => {
25
+ try {
26
+ const picoId = decodeURIComponent(req.params.picoId);
27
+ const jsonl = await identity.getWebvhLogJsonl(picoId);
28
+ if (!jsonl) {
29
+ res.status(404).send("Not found");
30
+ return;
31
+ }
32
+ const log = jsonl
33
+ .trim()
34
+ .split("\n")
35
+ .map((line) => JSON.parse(line));
36
+ await resolveLocalWebvhLog(log);
37
+ res.type("application/jsonld+json").send(jsonl);
38
+ } catch (err) {
39
+ sendIdentityError(res, err);
40
+ }
41
+ });
42
+
43
+ app.get("/picos/:picoId/did.json", async (req: Request, res: Response) => {
44
+ try {
45
+ const picoId = decodeURIComponent(req.params.picoId);
46
+ const doc = await identity.getParallelWebDoc(picoId);
47
+ if (!doc) {
48
+ res.status(404).send("Not found");
49
+ return;
50
+ }
51
+ res.json(doc);
52
+ } catch (err) {
53
+ sendIdentityError(res, err);
54
+ }
55
+ });
56
+ }
57
+
58
+ function sendIdentityError(res: Response, err: unknown): void {
59
+ if (err instanceof IdentityError) {
60
+ res.status(err.statusCode).json({ error: err.message });
61
+ return;
62
+ }
63
+ res.status(500).json({ error: (err as Error).message || "Internal error" });
64
+ }
package/src/index.ts CHANGED
@@ -5,10 +5,14 @@ import * as makeDir from "make-dir";
5
5
  import * as path from "path";
6
6
  import { PicoEngineCore, RulesetRegistry } from "pico-engine-core";
7
7
  import { PicoDbKey, PicoFramework } from "pico-framework";
8
+ import { AuthService, WebAuthnAdapter, makeWebAuthnAdapter } from "./auth";
9
+ import { IdentityStore, IdentityService, initDidoModule } from "./identity";
10
+ import { registerWebvhRoutes } from "./identity/webvhRoutes";
11
+ import { OAuthService, initOAuthModule } from "./oauth";
8
12
  import { getPicoLogs, makeRotatingFileLogWriter } from "./logging";
13
+ import { provisionRoot, uiECIForRoot } from "./provisionRoot";
9
14
  import { RulesetRegistryLoaderFs } from "./RulesetRegistryLoaderFs";
10
15
  import { server } from "./server";
11
- import { toFileUrl } from "./utils/toFileUrl";
12
16
  const charwise = require("charwise");
13
17
  const safeJsonCodec = require("level-json-coerce-null");
14
18
 
@@ -53,6 +57,43 @@ export interface PicoEngineConfiguration {
53
57
  useEventInputTime?: boolean;
54
58
 
55
59
  log?: KrlLogger;
60
+
61
+ /**
62
+ * WebAuthn relying-party id (a registrable domain). Defaults to the hostname
63
+ * of `base_url` (e.g. "localhost").
64
+ */
65
+ rpID?: string;
66
+
67
+ /**
68
+ * Human-friendly relying-party name shown by the OS passkey UI.
69
+ */
70
+ rpName?: string;
71
+
72
+ /**
73
+ * Expected WebAuthn origin (scheme://host[:port]). Defaults to the origin of
74
+ * `base_url`.
75
+ */
76
+ origin?: string;
77
+
78
+ /**
79
+ * When true, anyone may register additional accounts/roots after bootstrap.
80
+ * When false (default), only bootstrap (zero accounts), legacy claim, or a valid
81
+ * invite may create a new account.
82
+ */
83
+ allowSelfSignup?: boolean;
84
+
85
+ /**
86
+ * Override the WebAuthn ceremony/verification implementation. Intended for
87
+ * testing with a deterministic authenticator.
88
+ */
89
+ webauthn?: WebAuthnAdapter;
90
+
91
+ /**
92
+ * When true, boot auto-creates a single root (historical behavior). Defaults
93
+ * to false — fresh engines start with zero roots until passkey registration.
94
+ * Tests may set this to true.
95
+ */
96
+ autoCreateRootPico?: boolean;
56
97
  }
57
98
 
58
99
  export interface PicoEngine {
@@ -63,8 +104,13 @@ export interface PicoEngine {
63
104
  base_url: string;
64
105
 
65
106
  pf: PicoFramework;
66
- uiECI: string;
107
+ /** UI channel for the session root; null when no roots exist yet at boot. */
108
+ uiECI: string | null;
67
109
  rsRegistry: RulesetRegistry;
110
+ auth: AuthService;
111
+ oauth: OAuthService;
112
+ identity: IdentityStore;
113
+ identityService: IdentityService;
68
114
  }
69
115
 
70
116
  export async function startEngine(
@@ -75,7 +121,16 @@ export async function startEngine(
75
121
  let base_url = configuration.base_url;
76
122
 
77
123
  if (typeof home !== "string") {
78
- home = homeDir(".pico-engine") as string;
124
+ const envHome = process.env.PICO_ENGINE_HOME;
125
+ if (
126
+ typeof envHome === "string" &&
127
+ envHome.length > 0 &&
128
+ process.env.NODE_ENV === "test"
129
+ ) {
130
+ home = envHome;
131
+ } else {
132
+ home = homeDir(".pico-engine") as string;
133
+ }
79
134
  }
80
135
  await makeDir(home);
81
136
 
@@ -93,60 +148,90 @@ export async function startEngine(
93
148
  log,
94
149
  modules: configuration.modules,
95
150
  useEventInputTime: configuration.useEventInputTime,
151
+ autoCreateRootPico: configuration.autoCreateRootPico ?? false,
96
152
  getPicoLogs(picoId) {
97
153
  return getPicoLogs(logFilePath, picoId);
98
154
  },
99
155
  });
156
+ const pf = core.picoFramework;
157
+ const identity = new IdentityStore({ db: pf.db });
158
+ let identityService!: IdentityService;
159
+ identityService = new IdentityService({
160
+ store: identity,
161
+ getBaseUrl: () => core.base_url || base_url || "",
162
+ pf,
163
+ });
164
+ core.onPicoCreated = async (picoId, ctx) => {
165
+ if (core.base_url) {
166
+ await identityService.ensureWebvhDid(picoId, { isRoot: ctx.isRoot });
167
+ }
168
+ };
169
+ core.modules["dido"] = initDidoModule(identityService);
170
+
100
171
  await core.start();
101
172
  const rsRegistry = core.rsRegistry;
102
- const pf = core.picoFramework;
103
173
 
104
- const krl_urls: string[] = [
105
- toFileUrl(
106
- path.resolve(__dirname, "..", "krl", "io.picolabs.pico-engine-ui.krl")
107
- ),
108
- toFileUrl(path.resolve(__dirname, "..", "krl", "io.picolabs.wrangler.krl")),
109
- toFileUrl(
110
- path.resolve(__dirname, "..", "krl", "io.picolabs.subscription.krl")
111
- ),
112
- toFileUrl(path.resolve(__dirname, "..", "krl", "io.picolabs.did-o.krl")),
113
- toFileUrl(path.resolve(__dirname, "..", "krl", "io.picolabs.pds.krl")),
114
- ];
115
- for (const url of krl_urls) {
116
- const { ruleset } = await rsRegistry.flush(url);
117
- await pf.rootPico.install(ruleset, { url, config: {} });
174
+ // Fresh engines boot with zero roots. Adopt + (re)provision only when roots
175
+ // already exist (test harness with autoCreateRootPico, or a migrated DB).
176
+ let uiECI: string | null = null;
177
+ const existingRoots = pf.rootPicos();
178
+ if (existingRoots.length > 0) {
179
+ const provisioned = await provisionRoot(pf, core, { root: existingRoots[0] });
180
+ uiECI = provisioned.uiECI;
118
181
  }
119
182
 
120
- let uiChannel = pf.rootPico
121
- .toReadOnly()
122
- .channels.find(
123
- (chann) => "engine,ui" === chann.tags.slice(0).sort().join(",")
124
- );
125
- if (!uiChannel) {
126
- uiChannel = (
127
- await pf.rootPico.newChannel({
128
- tags: ["engine", "ui"],
129
- eventPolicy: {
130
- allow: [{ domain: "engine_ui", name: "setup" }],
131
- deny: [],
132
- },
133
- })
134
- ).toReadOnly();
135
- }
136
- await pf.eventWait({
137
- eci: uiChannel.id,
138
- domain: "engine_ui",
139
- name: "setup",
140
- data: { attrs: {} },
141
- time: 0,
183
+ const auth = new AuthService({
184
+ db: pf.db,
185
+ webauthn: configuration.webauthn || makeWebAuthnAdapter(),
186
+ getBaseUrl: () => core.base_url,
187
+ rpID: configuration.rpID,
188
+ rpName: configuration.rpName,
189
+ origin: configuration.origin,
190
+ allowSelfSignup: configuration.allowSelfSignup ?? false,
191
+ flushBootstrapUrl: async (url) => {
192
+ const flushed = await rsRegistry.flush(url);
193
+ return { rid: flushed.rid };
194
+ },
195
+ provisionRoot: async (opts) => {
196
+ const { root, uiECI } = await provisionRoot(pf, core, opts);
197
+ if (core.base_url) {
198
+ await identityService.ensureWebvhDid(root.id, { isRoot: true });
199
+ }
200
+ return { rootPicoId: root.id, uiECI };
201
+ },
202
+ getUiECI: (rootPicoId: string) => uiECIForRoot(pf, rootPicoId),
203
+ getPrimaryRootPicoId: () => {
204
+ try {
205
+ return pf.rootPico.id;
206
+ } catch {
207
+ return null;
208
+ }
209
+ },
210
+ onAccountClaimed: async (rootPicoId, displayName) => {
211
+ const uiChannel = uiECIForRoot(pf, rootPicoId);
212
+ if (!uiChannel || !displayName.trim()) {
213
+ return;
214
+ }
215
+ await pf.eventWait({
216
+ eci: uiChannel,
217
+ domain: "engine_ui",
218
+ name: "box",
219
+ data: { attrs: { name: displayName.trim() } },
220
+ time: 0,
221
+ });
222
+ },
142
223
  });
143
224
 
144
- const uiECI = uiChannel.id;
225
+ const oauth = new OAuthService({
226
+ db: pf.db,
227
+ pf,
228
+ });
229
+ core.modules["oauth"] = initOAuthModule(oauth);
145
230
 
146
- const app = server(core, uiECI);
231
+ const app = server(core, uiECI, auth, oauth, identityService);
147
232
 
148
233
  if ((!port || !_.isInteger(port) || port < 1) && port !== 0) {
149
- port = 3000;
234
+ port = process.env.NODE_ENV === "test" ? 0 : 3000;
150
235
  }
151
236
  await new Promise((resolve) => {
152
237
  const listener = app.listen(port, () => {
@@ -165,18 +250,21 @@ export async function startEngine(
165
250
  }
166
251
  core.base_url = base_url;
167
252
 
253
+ await identityService.ensureWebvhForAllLoadedPicos();
254
+
168
255
  log.info(`Listening at ${base_url}`);
169
256
 
170
- pf.event({
171
- eci: uiECI,
172
- domain: "engine",
173
- name: "started",
174
- data: { attrs: {} },
175
- time: 0, // TODO remove this typescript requirement
176
- }).catch((error) => {
177
- log.error("Error signaling engine:started event", { error });
178
- // TODO signal all errors engine:error
179
- });
257
+ if (uiECI) {
258
+ pf.event({
259
+ eci: uiECI,
260
+ domain: "engine",
261
+ name: "started",
262
+ data: { attrs: {} },
263
+ time: 0, // TODO remove this typescript requirement
264
+ }).catch((error) => {
265
+ log.error("Error signaling engine:started event", { error });
266
+ });
267
+ }
180
268
 
181
269
  return {
182
270
  version,
@@ -188,5 +276,9 @@ export async function startEngine(
188
276
  pf,
189
277
  uiECI,
190
278
  rsRegistry,
279
+ auth,
280
+ oauth,
281
+ identity,
282
+ identityService,
191
283
  };
192
284
  }