pico-engine 1.6.4 → 1.9.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 (108) hide show
  1. package/README.md +16 -9
  2. package/dist/RulesetRegistryLoaderFs.js +60 -6
  3. package/dist/auth/cookies.js +32 -0
  4. package/dist/auth/index.js +6 -1
  5. package/dist/channelIdentityPolicy.js +22 -0
  6. package/dist/cli.js +106 -69
  7. package/dist/engineConfig.js +291 -0
  8. package/dist/identity/IdentityService.js +90 -0
  9. package/dist/identity/crossPico.js +24 -8
  10. package/dist/identity/didoModule.js +80 -18
  11. package/dist/identity/establishSubscription.js +2 -2
  12. package/dist/identity/identityPortable.js +92 -0
  13. package/dist/identity/index.js +10 -1
  14. package/dist/identity/localPeerReconcile.js +65 -0
  15. package/dist/identity/peerDid4.js +175 -0
  16. package/dist/identity/peerDid4Create.js +90 -0
  17. package/dist/identity/portableExportPrepare.js +196 -0
  18. package/dist/identity/portableMove.js +87 -0
  19. package/dist/identity/skyIntro.js +6 -3
  20. package/dist/identity/skyProtocol.js +26 -1
  21. package/dist/identity/skyRotation.js +121 -0
  22. package/dist/identity/store.js +5 -1
  23. package/dist/identity/subscriptionEntSync.js +72 -0
  24. package/dist/identity/veramoDidComm.js +41 -2
  25. package/dist/identity/webvh.js +4 -2
  26. package/dist/identity/webvhRelocation.js +115 -0
  27. package/dist/index.js +84 -27
  28. package/dist/logging.js +156 -16
  29. package/dist/oauth/OAuthService.js +6 -2
  30. package/dist/policyConfigFromJson.js +112 -0
  31. package/dist/runMcp.js +27 -0
  32. package/dist/server.js +261 -24
  33. package/dist/stageKrl.js +26 -0
  34. package/dist/subtreeWrangler.js +180 -0
  35. package/dist/uiChannelPolicies.js +15 -0
  36. package/dist/xmluiRuntime.js +68 -0
  37. package/krl/io.picolabs.oauth.krl +41 -2
  38. package/krl/io.picolabs.pds.krl +131 -10
  39. package/krl/io.picolabs.pico-engine-ui.krl +217 -94
  40. package/krl/io.picolabs.portable_subtree.krl +97 -0
  41. package/krl/io.picolabs.subscription.krl +180 -72
  42. package/krl/io.picolabs.wrangler.krl +313 -57
  43. package/krl/io.picolabs.xmlui.krl +295 -0
  44. package/mcp/devResources.js +118 -0
  45. package/mcp/devTools.js +351 -0
  46. package/mcp/engineClient.js +133 -0
  47. package/mcp/meshHttp.js +137 -0
  48. package/mcp/meshTools.js +189 -0
  49. package/mcp/runStdio.js +34 -0
  50. package/mcp/schemaToZod.js +56 -0
  51. package/package.json +24 -9
  52. package/public/.DS_Store +0 -0
  53. package/public/docs/_sidebar.md +3 -1
  54. package/public/docs/llms-full.txt +630 -0
  55. package/public/docs/llms.txt +38 -0
  56. package/public/docs/openapi.yaml +78 -0
  57. package/public/docs/pico-engine.md +239 -4
  58. package/public/docs/pico-overview.md +117 -0
  59. package/public/docs/pico-views-xmlui.md +5 -0
  60. package/public/docs/pico-views.md +140 -0
  61. package/public/docs/pico.md +3 -1
  62. package/public/docs/rulesets/README.md +26 -0
  63. package/public/docs/rulesets/io.picolabs.oauth.md +71 -0
  64. package/public/docs/rulesets/io.picolabs.pds.md +327 -0
  65. package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +65 -0
  66. package/public/docs/rulesets/io.picolabs.portable_subtree.md +94 -0
  67. package/public/docs/rulesets/io.picolabs.subscription.md +398 -0
  68. package/public/docs/rulesets/io.picolabs.wrangler.md +471 -0
  69. package/public/pico-engine-ui.css +1 -1
  70. package/public/pico-engine-ui.js +27 -23
  71. package/public/xmlui/0.12.7.js +419 -0
  72. package/public/xmlui/pico-view-boot.js +153 -0
  73. package/src/RulesetRegistryLoaderFs.ts +66 -7
  74. package/src/auth/cookies.ts +34 -0
  75. package/src/auth/index.ts +7 -0
  76. package/src/channelIdentityPolicy.ts +29 -0
  77. package/src/cli.ts +70 -37
  78. package/src/engineConfig.ts +363 -0
  79. package/src/identity/IdentityService.ts +189 -1
  80. package/src/identity/crossPico.ts +57 -8
  81. package/src/identity/didoModule.ts +140 -23
  82. package/src/identity/establishSubscription.ts +2 -2
  83. package/src/identity/identityPortable.ts +153 -0
  84. package/src/identity/index.ts +14 -0
  85. package/src/identity/localPeerReconcile.ts +97 -0
  86. package/src/identity/peerDid4.ts +197 -0
  87. package/src/identity/peerDid4Create.ts +121 -0
  88. package/src/identity/portableExportPrepare.ts +302 -0
  89. package/src/identity/portableMove.ts +193 -0
  90. package/src/identity/skyIntro.ts +11 -11
  91. package/src/identity/skyProtocol.ts +46 -0
  92. package/src/identity/skyRotation.ts +211 -0
  93. package/src/identity/store.ts +5 -1
  94. package/src/identity/subscriptionEntSync.ts +97 -0
  95. package/src/identity/veramoDidComm.ts +52 -2
  96. package/src/identity/webvh.ts +4 -4
  97. package/src/identity/webvhRelocation.ts +167 -0
  98. package/src/index.ts +123 -31
  99. package/src/logging.ts +173 -18
  100. package/src/oauth/OAuthService.ts +11 -3
  101. package/src/policyConfigFromJson.ts +131 -0
  102. package/src/runMcp.ts +30 -0
  103. package/src/server.ts +328 -27
  104. package/src/stageKrl.ts +26 -0
  105. package/src/subtreeWrangler.ts +278 -0
  106. package/src/uiChannelPolicies.ts +15 -0
  107. package/src/xmluiRuntime.ts +66 -0
  108. package/krl/io.picolabs.did-o.krl +0 -349
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Pico view shell (S1): optional Sky bearer for DataSource/APICall when the mesh
3
+ * requires OAuth. Loads the vendored XMLUI runtime after installing fetch hooks.
4
+ */
5
+ (function picoViewBoot() {
6
+ var eci = window.__PICO_VIEW_ECI;
7
+ var xmluiScript = window.__PICO_XMLUI_SCRIPT || "/xmlui/0.12.7.js";
8
+ var authHeaders = {};
9
+
10
+ function normPath(p) {
11
+ if (!p || p === "/") return "/";
12
+ return p.replace(/\/+$/, "") || "/";
13
+ }
14
+
15
+ function appRootPath() {
16
+ return (window.__PUBLIC_PATH || "").replace(/\/+$/, "");
17
+ }
18
+
19
+ function useHashRouting() {
20
+ if (window.__PICO_VIEW_USE_HASH_ROUTING === "false") return false;
21
+ if (window.__PICO_VIEW_USE_HASH_ROUTING === "true") return true;
22
+ return !!window.__PICO_VIEW_ECI;
23
+ }
24
+
25
+ /** XMLUI standalone defaults to hash routing; pathnames stay at the app root. */
26
+ function syncRoutesBeforeXmlui() {
27
+ var root = appRootPath();
28
+ if (!root) return;
29
+
30
+ if (useHashRouting()) {
31
+ var path = window.location.pathname;
32
+ if (path.indexOf(root) === 0) {
33
+ var rest = path.slice(root.length).replace(/^\/+/, "").replace(/\/+$/, "");
34
+ if (rest) {
35
+ var hashRoute = rest.charAt(0) === "/" ? rest : "/" + rest;
36
+ window.history.replaceState(
37
+ null,
38
+ "",
39
+ root + "/" + window.location.search + "#" + hashRoute
40
+ );
41
+ return;
42
+ }
43
+ }
44
+ var fb = window.__XMLUI_FALLBACK_PATH || "/";
45
+ if (!fb.startsWith("/")) fb = "/" + fb;
46
+ var hash = window.location.hash;
47
+ if (!hash || hash === "#") {
48
+ window.history.replaceState(
49
+ null,
50
+ "",
51
+ root + "/" + window.location.search + "#" + fb
52
+ );
53
+ }
54
+ return;
55
+ }
56
+
57
+ if (window.location.pathname === root) {
58
+ window.history.replaceState(
59
+ null,
60
+ "",
61
+ root + "/" + window.location.search + window.location.hash
62
+ );
63
+ }
64
+
65
+ var fbPath = window.__XMLUI_FALLBACK_PATH;
66
+ if (!fbPath || fbPath === "/") return;
67
+ var here = normPath(window.location.pathname);
68
+ if (here !== normPath(root)) return;
69
+ var segment = fbPath.replace(/^\//, "");
70
+ window.history.replaceState(
71
+ null,
72
+ "",
73
+ root + "/" + segment + window.location.search + window.location.hash
74
+ );
75
+ }
76
+
77
+ syncRoutesBeforeXmlui();
78
+
79
+ function patchFetch() {
80
+ var origFetch = window.fetch;
81
+ window.fetch = function (input, init) {
82
+ var url =
83
+ typeof input === "string"
84
+ ? input
85
+ : input && input.url
86
+ ? input.url
87
+ : "";
88
+ if (
89
+ url.indexOf("/sky/query/") !== -1 ||
90
+ url.indexOf("/sky/event/") !== -1 ||
91
+ url.indexOf("/sky/cloud/") !== -1
92
+ ) {
93
+ init = init || {};
94
+ var h = new Headers(init.headers || {});
95
+ if (authHeaders.Authorization) {
96
+ h.set("Authorization", authHeaders.Authorization);
97
+ }
98
+ init.headers = h;
99
+ }
100
+ if (typeof url === "string" && url.indexOf("config.json") !== -1) {
101
+ return origFetch(input, init).then(function (res) {
102
+ if (!res.ok) return res;
103
+ return res.clone().json().then(function (cfg) {
104
+ cfg.appGlobals = cfg.appGlobals || {};
105
+ cfg.appGlobals.auth = authHeaders;
106
+ if (useHashRouting()) {
107
+ cfg.appGlobals.useHashBasedRouting = true;
108
+ cfg.xmluiConfig = cfg.xmluiConfig || {};
109
+ cfg.xmluiConfig.useHashBasedRouting = true;
110
+ }
111
+ return new Response(JSON.stringify(cfg), {
112
+ status: 200,
113
+ headers: { "Content-Type": "application/json" },
114
+ });
115
+ });
116
+ });
117
+ }
118
+ return origFetch(input, init);
119
+ };
120
+ }
121
+
122
+ function loadXmlui() {
123
+ patchFetch();
124
+ var s = document.createElement("script");
125
+ s.src = xmluiScript;
126
+ s.onload = function () {
127
+ if (window.xmlui && typeof window.xmlui.startApp === "function") {
128
+ window.xmlui.startApp();
129
+ }
130
+ };
131
+ document.head.appendChild(s);
132
+ }
133
+
134
+ if (!eci) {
135
+ loadXmlui();
136
+ return;
137
+ }
138
+
139
+ fetch("/api/ui-sky-context?eci=" + encodeURIComponent(eci))
140
+ .then(function (r) {
141
+ return r.ok ? r.json() : { bearerRequired: false };
142
+ })
143
+ .then(function (ctx) {
144
+ if (ctx && ctx.bearerRequired) {
145
+ var tok = sessionStorage.getItem("picoViewBearer");
146
+ if (tok) authHeaders = { Authorization: "Bearer " + tok };
147
+ }
148
+ loadXmlui();
149
+ })
150
+ .catch(function () {
151
+ loadXmlui();
152
+ });
153
+ })();
@@ -11,6 +11,7 @@ import { resolveBundledKrlUrl } from "./bundledKrl";
11
11
  import { openClassicLevelWithRecovery } from "./levelDb";
12
12
  const krlCompiler = require("krl-compiler");
13
13
  const krlCompilerVersion = require("krl-compiler/package.json").version;
14
+ const rulesetCompileGeneration = require("krl-compiler/src/rulesetCompileGeneration");
14
15
  const charwise = require("charwise");
15
16
  const safeJsonCodec = require("level-json-coerce-null");
16
17
 
@@ -33,9 +34,14 @@ interface DbUrlRuleset {
33
34
  compiler: {
34
35
  version: string;
35
36
  warnings: any[];
37
+ compileGeneration?: string;
36
38
  };
37
39
  }
38
40
 
41
+ function compileGenerationDir(): string {
42
+ return rulesetCompileGeneration().replace(/[^a-zA-Z0-9._-]+/g, "_");
43
+ }
44
+
39
45
  export interface RulesetRegistryLoaderFsHandle {
40
46
  loader: RulesetRegistryLoader;
41
47
  close: () => Promise<void>;
@@ -62,11 +68,11 @@ export async function createRulesetRegistryLoaderFs(
62
68
  hash: string
63
69
  ): Promise<{
64
70
  ruleset: Ruleset;
65
- compiler: { version: string; warnings: any[] };
71
+ compiler: DbUrlRuleset["compiler"];
66
72
  }> {
67
73
  const jsFile = path.resolve(
68
74
  rulesetDir,
69
- krlCompilerVersion,
75
+ compileGenerationDir(),
70
76
  hash.substr(0, 2),
71
77
  hash.substr(2, 2),
72
78
  hash + ".js"
@@ -74,9 +80,24 @@ export async function createRulesetRegistryLoaderFs(
74
80
 
75
81
  let compileWarnings: any[] = [];
76
82
 
77
- if (await fsExist(jsFile)) {
78
- // already compiled
79
- } else {
83
+ let needCompile = !(await fsExist(jsFile));
84
+ if (!needCompile) {
85
+ const cached = requireRulesetModule(jsFile);
86
+ if (cached) {
87
+ const compileGeneration = rulesetCompileGeneration();
88
+ return {
89
+ ruleset: cached,
90
+ compiler: {
91
+ version: krlCompilerVersion,
92
+ warnings: compileWarnings,
93
+ compileGeneration,
94
+ },
95
+ };
96
+ }
97
+ needCompile = true;
98
+ }
99
+
100
+ if (needCompile) {
80
101
  const out = krlCompiler(krl, {
81
102
  parser_options: {
82
103
  filename: getUrlFilename(url),
@@ -95,17 +116,31 @@ export async function createRulesetRegistryLoaderFs(
95
116
  });
96
117
  }
97
118
 
98
- const ruleset: Ruleset = require(jsFile);
119
+ const ruleset = requireRulesetModule(jsFile);
120
+ if (!ruleset) {
121
+ throw new Error(
122
+ `Compiled ruleset is missing init (corrupt cache file). Delete ${jsFile} and flush again: ${url}`
123
+ );
124
+ }
99
125
 
126
+ const compileGeneration = rulesetCompileGeneration();
100
127
  return {
101
128
  ruleset,
102
- compiler: { version: krlCompilerVersion, warnings: compileWarnings },
129
+ compiler: {
130
+ version: krlCompilerVersion,
131
+ warnings: compileWarnings,
132
+ compileGeneration,
133
+ },
103
134
  };
104
135
  }
105
136
 
106
137
  const loader: RulesetRegistryLoader = {
107
138
  fetchKrl,
108
139
 
140
+ getCompileGeneration() {
141
+ return rulesetCompileGeneration();
142
+ },
143
+
109
144
  async save({ ruleset, ...rest }) {
110
145
  let toWrite: DbUrlRuleset = rest;
111
146
  await db.put(["url", toWrite.url], toWrite);
@@ -168,6 +203,30 @@ async function fetchKrl(url: string): Promise<string> {
168
203
  return krl;
169
204
  }
170
205
 
206
+ function requireRulesetModule(jsFile: string): Ruleset | null {
207
+ try {
208
+ delete require.cache[require.resolve(jsFile)];
209
+ } catch {
210
+ return null;
211
+ }
212
+ let ruleset: Ruleset;
213
+ try {
214
+ ruleset = require(jsFile) as Ruleset;
215
+ } catch {
216
+ return null;
217
+ }
218
+ if (typeof ruleset?.init !== "function") {
219
+ try {
220
+ delete require.cache[require.resolve(jsFile)];
221
+ fs.unlinkSync(jsFile);
222
+ } catch {
223
+ /* best effort */
224
+ }
225
+ return null;
226
+ }
227
+ return ruleset;
228
+ }
229
+
171
230
  function fsExist(filePath: string): Promise<boolean> {
172
231
  return new Promise((resolve, reject) => {
173
232
  fs.stat(filePath, function (err, stats) {
@@ -0,0 +1,34 @@
1
+ export const DEFAULT_SESSION_COOKIE = "pico-session";
2
+ export const DEFAULT_CEREMONY_COOKIE = "pico-ceremony";
3
+
4
+ export interface AuthCookieNames {
5
+ session: string;
6
+ ceremony: string;
7
+ }
8
+
9
+ /** Session/ceremony cookie names scoped by port on local dev hosts. */
10
+ export function authCookieNames(origin: string): AuthCookieNames {
11
+ try {
12
+ const url = new URL(origin);
13
+ const local =
14
+ url.hostname === "localhost" ||
15
+ url.hostname === "127.0.0.1" ||
16
+ url.hostname.endsWith(".localhost");
17
+ if (local && url.port) {
18
+ return {
19
+ session: `${DEFAULT_SESSION_COOKIE}-${url.port}`,
20
+ ceremony: `${DEFAULT_CEREMONY_COOKIE}-${url.port}`,
21
+ };
22
+ }
23
+ } catch (_e) {
24
+ // fall through
25
+ }
26
+ return {
27
+ session: DEFAULT_SESSION_COOKIE,
28
+ ceremony: DEFAULT_CEREMONY_COOKIE,
29
+ };
30
+ }
31
+
32
+ export function sessionCookieHeader(origin: string, token: string): string {
33
+ return `${authCookieNames(origin).session}=${token}`;
34
+ }
package/src/auth/index.ts CHANGED
@@ -15,3 +15,10 @@ export {
15
15
  VerifiedAuthentication,
16
16
  makeWebAuthnAdapter,
17
17
  } from "./webauthn";
18
+ export {
19
+ authCookieNames,
20
+ sessionCookieHeader,
21
+ DEFAULT_SESSION_COOKIE,
22
+ DEFAULT_CEREMONY_COOKIE,
23
+ type AuthCookieNames,
24
+ } from "./cookies";
@@ -0,0 +1,29 @@
1
+ import {
2
+ ChannelReadOnly,
3
+ hasUnrestrictedEventAllow,
4
+ hasUnrestrictedQueryAllow,
5
+ } from "pico-framework";
6
+
7
+ import { getEngineRuntimeSettings } from "./engineConfig";
8
+
9
+ /** See {@link EngineSettings.wildcardSkyRequireBearer} (config file or env). */
10
+ export function wildcardSkyRequireBearerEnabled(): boolean {
11
+ return getEngineRuntimeSettings().wildcardSkyRequireBearer;
12
+ }
13
+
14
+ /**
15
+ * True when the channel grants unrestricted events or queries (*.* allow rules).
16
+ * Such channels require an authenticated HTTP caller (OAuth bearer or /c/* session).
17
+ */
18
+ export function channelHasUnrestrictedAllow(channel: ChannelReadOnly): boolean {
19
+ return (
20
+ hasUnrestrictedEventAllow(channel.eventPolicy) ||
21
+ hasUnrestrictedQueryAllow(channel.queryPolicy)
22
+ );
23
+ }
24
+
25
+ export function isDidcommIngressChannel(channel: ChannelReadOnly): boolean {
26
+ return (
27
+ channel.tags.includes("didcomm") && channel.tags.includes("ingress")
28
+ );
29
+ }
package/src/cli.ts CHANGED
@@ -1,10 +1,42 @@
1
1
  import { PicoEngine, PicoEngineConfiguration, startEngine } from "./index";
2
+ import { applyConfigCliArgs, resolveEngineSettings } from "./engineConfig";
2
3
  const version = require("../package.json").version;
3
4
 
5
+ let argv: string[];
6
+ try {
7
+ argv = applyConfigCliArgs(process.argv.slice(2));
8
+ } catch (err) {
9
+ console.error(err instanceof Error ? err.message : err);
10
+ process.exit(1);
11
+ }
12
+
13
+ if (argv[0] === "mcp") {
14
+ import("./runMcp")
15
+ .then(({ runMcpCli }) => runMcpCli(argv))
16
+ .catch((err) => {
17
+ console.error(err);
18
+ process.exit(1);
19
+ });
20
+ } else if (argv[0] === "config" && argv[1] === "path") {
21
+ const { resolveEngineConfigFilePath, defaultEngineConfigFilePath } =
22
+ require("./engineConfig");
23
+ const target = resolveEngineConfigFilePath();
24
+ console.log(target);
25
+ if (target === defaultEngineConfigFilePath()) {
26
+ console.error(
27
+ "(default; copy packages/pico-engine/config.example.json here to customize)",
28
+ );
29
+ }
30
+ process.exit(0);
31
+ } else {
32
+ startPicoEngineCli();
33
+ }
34
+
35
+ function startPicoEngineCli() {
4
36
  const args: {
5
37
  help: boolean;
6
38
  version: boolean;
7
- } = require("minimist")(process.argv.slice(2), {
39
+ } = require("minimist")(argv, {
8
40
  boolean: ["help", "version"],
9
41
  alias: {
10
42
  help: "h",
@@ -19,50 +51,50 @@ if (args.help) {
19
51
  console.log(`
20
52
  USAGE
21
53
 
22
- pico-engine [--version] [--help|-h]
54
+ pico-engine [--config|-c <path>] [--version] [--help|-h]
55
+ pico-engine [--config|-c <path>] config path
56
+ pico-engine [--config|-c <path>] mcp --stdio
23
57
 
24
- Environment Variables:
58
+ Multiple engines on one machine: use a separate config file per process (unique
59
+ home, port, baseUrl). Examples: packages/pico-engine/config.instances.example/
60
+ and docker/config/ for compose.
25
61
 
26
- PORT - The port the http server should listen on. By default it's 3000
27
- PICO_ENGINE_HOME - Where the database and other files should be stored. By default it's ~/.pico-engine/
28
- PICO_ENGINE_BASE_URL - The public url prefix to reach this engine. By default it's http://localhost:$PORT
29
- PICO_ENGINE_ALLOW_SELF_SIGNUP - Set to "true" or "1" to allow anyone to register a new account
30
- after the engine is bootstrapped. Default is false (login only; bootstrap and invite still work).
31
- PICO_ENGINE_ALLOW_LOCALHOST_C - Set to "0" to require passkey session on /c/* even from localhost.
32
- Default (unset) allows localhost without session for in-engine ctx:event HTTP loops. See MEMORY.md.
33
- `);
34
- process.exit(0);
35
- }
62
+ Configuration (preferred):
36
63
 
37
- const env: PicoEngineConfiguration = {};
64
+ ~/.config/pico-engine/config.json
65
+ (or --config / PICO_ENGINE_CONFIG to another file path)
38
66
 
39
- if (process.env.PORT) {
40
- const port = parseInt(process.env.PORT, 10);
41
- if (port > 0) {
42
- env.port = port;
43
- }
44
- }
67
+ See packages/pico-engine/config.example.json (and config.policy-ceiling.example.json for 1.8 policy fields).
68
+ Precedence: defaults → environment variables → config file → tests/API overrides.
69
+ (Config file wins over PORT and PICO_ENGINE_HOME when both are set; env fills gaps the file omits.)
45
70
 
46
- if (
47
- typeof process.env.PICO_ENGINE_HOME === "string" &&
48
- process.env.PICO_ENGINE_HOME.length > 0
49
- ) {
50
- env.home = process.env.PICO_ENGINE_HOME;
51
- }
71
+ Environment (optional; Docker/CI when not set in config file):
52
72
 
53
- if (
54
- typeof process.env.PICO_ENGINE_BASE_URL === "string" &&
55
- process.env.PICO_ENGINE_BASE_URL.length > 0
56
- ) {
57
- env.base_url = process.env.PICO_ENGINE_BASE_URL;
73
+ PORT - HTTP listen port
74
+ PICO_ENGINE_CONFIG - Path to config JSON (default ~/.config/pico-engine/config.json)
75
+ PICO_ENGINE_HOME - Data directory (DB, ruleset cache); overridden by config "home" when present
76
+ PICO_ENGINE_BASE_URL - Public URL (WebAuthn, did:webvh)
77
+ PICO_ENGINE_RP_ID / PICO_ENGINE_ORIGIN - WebAuthn (or use webauthn block in config file)
78
+ PICO_ENGINE_ALLOW_SELF_SIGNUP - "true"/"1" or "false"/"0"
79
+ PICO_ENGINE_ALLOW_LOCALHOST_C - "0" disables localhost /c/* bypass (see config allowLocalhostChannelBypass)
80
+ PICO_ENGINE_WILDCARD_SKY_REQUIRE_BEARER - "1" enables wildcard /sky/* bearer requirement
81
+ PICO_ENGINE_LOG_FILE - Log path, or stdout/- / 0 for console-only
82
+ PICO_ENGINE_LOG_MIRROR - "true"/"1" or "false"/"0" (mirror JSON lines to \$PICO_ENGINE_HOME/pico-engine.log when stdout-only; default on)
83
+ PICO_ENGINE_LOG_RING - how many recent transactions per pico the Logging tab keeps in memory (default 200; cleared on restart)
84
+ `);
85
+ process.exit(0);
58
86
  }
59
87
 
60
- const allowSelfSignupEnv = process.env.PICO_ENGINE_ALLOW_SELF_SIGNUP;
61
- if (allowSelfSignupEnv === "true" || allowSelfSignupEnv === "1") {
62
- env.allowSelfSignup = true;
63
- } else if (allowSelfSignupEnv === "false" || allowSelfSignupEnv === "0") {
64
- env.allowSelfSignup = false;
65
- }
88
+ const settings = resolveEngineSettings({});
89
+ const env: PicoEngineConfiguration = {
90
+ home: settings.home,
91
+ port: settings.port,
92
+ base_url: settings.baseUrl,
93
+ rpID: settings.rpID,
94
+ rpName: settings.rpName,
95
+ origin: settings.origin,
96
+ allowSelfSignup: settings.allowSelfSignup,
97
+ };
66
98
 
67
99
  function installGracefulShutdown(engine: PicoEngine) {
68
100
  let shuttingDown = false;
@@ -96,3 +128,4 @@ startEngine(env)
96
128
  console.error(err);
97
129
  process.exit(1);
98
130
  });
131
+ }