retold-facto 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -327,6 +327,37 @@ function commandServe()
327
327
  _Fable.log.info(`API: http://localhost:${_Settings.APIServerPort}/1.0/`);
328
328
  _Fable.log.info(`Facto: http://localhost:${_Settings.APIServerPort}/facto/`);
329
329
  _Fable.log.info(`Web UI: http://localhost:${_Settings.APIServerPort}/`);
330
+
331
+ // Optional auto-connect to an Ultravisor coordinator. Only
332
+ // runs when FACTO_ULTRAVISOR_URL is set; standalone users
333
+ // with no Ultravisor in the loop see no behavior change.
334
+ // Failures are logged but don't kill the process — facto
335
+ // stays useful as a local REST surface. This also triggers
336
+ // the beacon-side WebAuth proxy install, which gates the web
337
+ // UI's session-bearing routes against UV's auth beacon when
338
+ // the upstream UV is in non-promiscuous mode.
339
+ let tmpUVUrl = process.env.FACTO_ULTRAVISOR_URL || '';
340
+ if (tmpUVUrl && _Fable.RetoldFactoBeaconProvider)
341
+ {
342
+ let tmpBeaconConfig =
343
+ {
344
+ ServerURL: tmpUVUrl,
345
+ Name: process.env.FACTO_BEACON_NAME || 'retold-facto',
346
+ Password: process.env.FACTO_BEACON_PASSWORD || '',
347
+ MaxConcurrent: parseInt(process.env.FACTO_MAX_CONCURRENT || '2', 10)
348
+ };
349
+ _Fable.log.info(`Auto-connecting to Ultravisor at ${tmpUVUrl} as "${tmpBeaconConfig.Name}"...`);
350
+ _Fable.RetoldFactoBeaconProvider.connectBeacon(tmpBeaconConfig,
351
+ (pConnectError) =>
352
+ {
353
+ if (pConnectError)
354
+ {
355
+ _Fable.log.error(`Ultravisor auto-connect failed: ${pConnectError.message || pConnectError}`);
356
+ return;
357
+ }
358
+ _Fable.log.info(`Ultravisor auto-connect succeeded — registered as "${tmpBeaconConfig.Name}".`);
359
+ });
360
+ }
330
361
  });
331
362
  }
332
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retold-facto",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Data warehouse and knowledge graph storage for the Retold ecosystem.",
5
5
  "main": "source/Retold-Facto.js",
6
6
  "bin": {
@@ -115,7 +115,7 @@
115
115
  "puppeteer": "^24.40.0",
116
116
  "quackage": "^1.2.3",
117
117
  "retold-sharp": "^1.0.0",
118
- "stricture": "^4.0.3",
118
+ "stricture": "^4.0.6",
119
119
  "supertest": "^7.2.2"
120
120
  },
121
121
  "dependencies": {
@@ -124,29 +124,31 @@
124
124
  "@codemirror/view": "^6.41.0",
125
125
  "bibliograph": "^1.0.0",
126
126
  "codemirror": "^6.0.2",
127
- "fable": "^3.1.73",
127
+ "fable": "^3.1.75",
128
128
  "fable-serviceproviderbase": "^3.0.19",
129
129
  "fast-xml-parser": "^5.5.10",
130
- "meadow": "^2.0.39",
130
+ "meadow": "^2.0.41",
131
131
  "meadow-connection-manager": "^1.1.2",
132
132
  "meadow-connection-mysql": "^1.0.19",
133
133
  "meadow-connection-sqlite": "^1.0.20",
134
- "meadow-endpoints": "^4.0.21",
135
- "meadow-integration": "^1.0.40",
134
+ "meadow-endpoints": "^4.0.22",
135
+ "meadow-integration": "^1.0.41",
136
136
  "orator": "^6.1.2",
137
137
  "orator-serviceserver-restify": "^2.0.11",
138
138
  "orator-static-server": "^2.1.4",
139
- "pict": "^1.0.369",
139
+ "pict": "^1.0.371",
140
140
  "pict-provider-theme": "^1.0.1",
141
141
  "pict-router": "^1.0.10",
142
142
  "pict-section-connection-form": "^1.0.0",
143
143
  "pict-section-flow": "^1.0.1",
144
144
  "pict-section-histogram": "^1.0.1",
145
+ "pict-section-login": "^1.0.0",
145
146
  "pict-section-markdowneditor": "^1.0.15",
146
147
  "pict-section-modal": "^1.1.1",
147
148
  "pict-section-objecteditor": "^1.0.3",
148
149
  "pict-section-theme": "^1.0.5",
149
- "stricture": "^4.0.3",
150
+ "stricture": "^4.0.6",
151
+ "ultravisor-beacon": "^1.0.1",
150
152
  "xlsx": "^0.18.5"
151
153
  },
152
154
  "retold": {
@@ -22,6 +22,7 @@ const libRetoldFactoRecordManager = require('./services/Retold-Facto-RecordManag
22
22
  const libRetoldFactoDatasetManager = require('./services/Retold-Facto-DatasetManager.js');
23
23
  const libRetoldFactoIngestEngine = require('./services/Retold-Facto-IngestEngine.js');
24
24
  const libRetoldFactoProjectionEngine = require('./services/Retold-Facto-ProjectionEngine.js');
25
+ const libRetoldFactoBeaconProvider = require('./services/Retold-Facto-BeaconProvider.js');
25
26
  const libRetoldFactoCatalogManager = require('./services/Retold-Facto-CatalogManager.js');
26
27
  const libRetoldFactoStoreConnectionManager = require('./services/Retold-Facto-StoreConnectionManager.js');
27
28
  const libRetoldFactoDataLakeService = require('./services/Retold-Facto-DataLakeService.js');
@@ -356,6 +357,16 @@ class RetoldFacto extends libFableServiceProviderBase
356
357
  RoutePrefix: this.options.Facto.RoutePrefix
357
358
  });
358
359
 
360
+ // BeaconProvider — exposes connectBeacon() so the CLI can wire
361
+ // facto into the Ultravisor mesh at startup. Registering the
362
+ // type here doesn't initiate a connection; bin/retold-facto.js
363
+ // invokes connectBeacon() when FACTO_ULTRAVISOR_URL is set.
364
+ this.fable.serviceManager.addServiceType('RetoldFactoBeaconProvider', libRetoldFactoBeaconProvider);
365
+ this.fable.serviceManager.instantiateServiceProvider('RetoldFactoBeaconProvider',
366
+ {
367
+ RoutePrefix: this.options.Facto.RoutePrefix
368
+ });
369
+
359
370
  this.fable.serviceManager.addServiceType('RetoldFactoCatalogManager', libRetoldFactoCatalogManager);
360
371
  this.fable.serviceManager.instantiateServiceProvider('RetoldFactoCatalogManager',
361
372
  {
@@ -461,10 +461,56 @@ class RetoldFactoBeaconProvider extends libFableServiceProviderBase
461
461
  }
462
462
 
463
463
  this.log.info(`RetoldFactoBeaconProvider: beacon connected as ${pBeaconInfo.BeaconID}`);
464
+ // Install the beacon-side web-UI auth proxy now that
465
+ // connectBeacon has succeeded. Same pattern as the
466
+ // databeacon — see Ultravisor-Beacon-WebAuth.cjs for the
467
+ // install signature. Non-fatal if it fails (the beacon
468
+ // is still useful; the UI just stays open).
469
+ try { this._installWebAuth(pBeaconConfig); }
470
+ catch (pWebAuthErr)
471
+ {
472
+ this.log.warn(`RetoldFactoBeaconProvider: WebAuth install skipped: ${pWebAuthErr && pWebAuthErr.message}`);
473
+ }
464
474
  return fCallback(null, pBeaconInfo);
465
475
  });
466
476
  }
467
477
 
478
+ /**
479
+ * Wire the SDK's WebAuth helper into facto's Orator server so the
480
+ * web UI's login flow proxies through UV's auth beacon. Idempotent
481
+ * — calling twice just re-registers the same routes (the helper's
482
+ * internal WeakMap tracks installs). Gating list scopes the gate
483
+ * to facto's own data-mutating routes; static assets + the auth
484
+ * routes themselves are always public.
485
+ */
486
+ _installWebAuth(pBeaconConfig)
487
+ {
488
+ if (!libBeaconService || !libBeaconService.WebAuth)
489
+ {
490
+ return;
491
+ }
492
+ if (!this.fable.OratorServiceServer)
493
+ {
494
+ this.log.warn('RetoldFactoBeaconProvider: WebAuth install: OratorServiceServer unavailable on fable; skipping.');
495
+ return;
496
+ }
497
+ this._WebAuthHandle = libBeaconService.WebAuth.install(this.fable.OratorServiceServer,
498
+ {
499
+ UltravisorURL: pBeaconConfig.ServerURL,
500
+ BeaconName: pBeaconConfig.Name || 'retold-facto',
501
+ BeaconID: () => this._BeaconService && this._BeaconService.getBeaconID
502
+ ? this._BeaconService.getBeaconID() : '',
503
+ CookieName: 'SessionID',
504
+ RoutePrefix: '/1.0/',
505
+ StatusPath: '/status',
506
+ // Gate facto's mutation + read endpoints. Auth + status
507
+ // + static UI stay public so login itself can render.
508
+ GatedPathPrefixes: ['/1.0/Source', '/1.0/Dataset', '/1.0/Record', '/1.0/Ingest'],
509
+ Log: this.fable.log
510
+ });
511
+ this.log.info('RetoldFactoBeaconProvider: WebAuth mounted /1.0/{Authenticate,Deauthenticate,CheckSession} + /status proxy');
512
+ }
513
+
468
514
  /**
469
515
  * Disconnect the beacon from the Ultravisor coordinator.
470
516
  *
@@ -1,9 +1,12 @@
1
1
  const libPictApplication = require('pict-application');
2
2
 
3
3
  const libPictSectionModal = require('pict-section-modal');
4
+ const libPictSectionLogin = require('pict-section-login');
5
+ const libBeaconWebAuthClient = require('ultravisor-beacon/webinterface/Pict-Beacon-WebAuth-Client.js');
4
6
  const libProvider = require('./providers/Pict-Provider-Facto.js');
5
7
 
6
8
  const libViewLayout = require('./views/PictView-Facto-Layout.js');
9
+ const libViewLogin = require('./views/PictView-Facto-Login.js');
7
10
  const libViewSources = require('./views/PictView-Facto-Sources.js');
8
11
  const libViewRecords = require('./views/PictView-Facto-Records.js');
9
12
  const libViewDatasets = require('./views/PictView-Facto-Datasets.js');
@@ -27,6 +30,7 @@ class FactoApplication extends libPictApplication
27
30
 
28
31
  // Register views
29
32
  this.pict.addView('Facto-Layout', libViewLayout.default_configuration, libViewLayout);
33
+ this.pict.addView('Facto-Login', libViewLogin.default_configuration, libViewLogin);
30
34
  this.pict.addView('Facto-Sources', libViewSources.default_configuration, libViewSources);
31
35
  this.pict.addView('Facto-Records', libViewRecords.default_configuration, libViewRecords);
32
36
  this.pict.addView('Facto-Datasets', libViewDatasets.default_configuration, libViewDatasets);
@@ -35,6 +39,29 @@ class FactoApplication extends libPictApplication
35
39
  this.pict.addView('Facto-Catalog', libViewCatalog.default_configuration, libViewCatalog);
36
40
  this.pict.addView('Facto-Scanner', libViewScanner.default_configuration, libViewScanner);
37
41
  this.pict.addView('Facto-Throughput', libViewThroughput.default_configuration, libViewThroughput);
42
+
43
+ // Beacon-side login section + client helper. The helper hooks
44
+ // pict-section-login's lifecycle callbacks back into this
45
+ // application so login success / logout / session-check flow
46
+ // through `_showLoginOverlay()` and `_hideLoginOverlay()`. See
47
+ // modules/fable/ultravisor-beacon/webinterface/Pict-Beacon-
48
+ // WebAuth-Client.js for the install signature. When facto's
49
+ // server-side WebAuth proxy reports the UV is in promiscuous
50
+ // mode, the gate stays armed but invisible.
51
+ this._WebAuthClient = libBeaconWebAuthClient.install(this.pict,
52
+ {
53
+ Section: libPictSectionLogin,
54
+ AuthStateAddress: 'AppData.Facto.Auth',
55
+ LoginRoute: 'Facto-Login',
56
+ HomeRoute: 'Facto-Layout',
57
+ StatusURL: '/status',
58
+ LoginEndpoint: '/1.0/Authenticate',
59
+ LogoutEndpoint: '/1.0/Deauthenticate',
60
+ CheckSessionEndpoint: '/1.0/CheckSession',
61
+ OnAfterLogin: () => this._hideLoginOverlay(),
62
+ OnAfterLogout: () => this._showLoginOverlay(),
63
+ OnSessionChecked: (pSess) => { if (!(pSess && pSess.LoggedIn)) { this._showLoginOverlay(); } else { this._hideLoginOverlay(); } }
64
+ });
38
65
  }
39
66
 
40
67
  onAfterInitializeAsync(fCallback)
@@ -58,10 +85,67 @@ class FactoApplication extends libPictApplication
58
85
  // Make pict available for inline onclick handlers
59
86
  window.pict = this.pict;
60
87
 
61
- // Render layout (which cascades child view renders)
88
+ // Ensure the login overlay mount point exists in the DOM
89
+ // before the section view tries to render into it. This is
90
+ // a one-time append so re-renders of the wrapper view don't
91
+ // stack additional overlays.
92
+ this._ensureLoginOverlayMount();
93
+
94
+ // Render layout (which cascades child view renders). We render
95
+ // the layout regardless of auth state; the overlay sits on top
96
+ // of it (z-index 9999) so an unauthenticated user simply can't
97
+ // interact with the underlying UI.
62
98
  this.pict.views['Facto-Layout'].render();
63
99
 
64
- return fCallback();
100
+ // Boot gate: fetch /status to discover whether UV is running in
101
+ // authenticated mode. In promiscuous mode the overlay stays
102
+ // hidden and the UI works as before. In authenticated mode the
103
+ // pict-section-login's CheckSessionOnLoad fires (its default is
104
+ // true); the helper's OnSessionChecked hook then shows/hides
105
+ // the overlay based on whether the user's cookie is still good.
106
+ this._WebAuthClient.loadAuthStatus((pStatusErr) =>
107
+ {
108
+ if (pStatusErr)
109
+ {
110
+ this.pict.log.warn('Facto: /status fetch failed during boot: ' + pStatusErr.message);
111
+ }
112
+ let tmpAuth = (this.pict.AppData.Facto && this.pict.AppData.Facto.Auth) || {};
113
+ if (tmpAuth.Mode === 'authenticated')
114
+ {
115
+ // Show overlay; the section's auto-CheckSession will
116
+ // hide it back if there's a valid cookie.
117
+ this._showLoginOverlay();
118
+ this.pict.views['Facto-Login'].render();
119
+ }
120
+ return fCallback();
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Append `<div id="Facto-Login-Overlay">` to <body> if it isn't
126
+ * already there. The Facto-Login wrapper view targets this element
127
+ * via its DefaultDestinationAddress, so it must exist before the
128
+ * wrapper's first render() call.
129
+ */
130
+ _ensureLoginOverlayMount()
131
+ {
132
+ if (typeof document === 'undefined') { return; }
133
+ if (document.getElementById('Facto-Login-Overlay')) { return; }
134
+ let tmpDiv = document.createElement('div');
135
+ tmpDiv.id = 'Facto-Login-Overlay';
136
+ document.body.appendChild(tmpDiv);
137
+ }
138
+
139
+ _showLoginOverlay()
140
+ {
141
+ let tmpEl = (typeof document !== 'undefined') && document.getElementById('Facto-Login-Overlay');
142
+ if (tmpEl) { tmpEl.classList.add('is-active'); }
143
+ }
144
+
145
+ _hideLoginOverlay()
146
+ {
147
+ let tmpEl = (typeof document !== 'undefined') && document.getElementById('Facto-Login-Overlay');
148
+ if (tmpEl) { tmpEl.classList.remove('is-active'); }
65
149
  }
66
150
  }
67
151
 
@@ -0,0 +1,91 @@
1
+ /**
2
+ * PictView-Facto-Login — full-viewport login overlay
3
+ *
4
+ * Different shape from the databeacon login view because facto's
5
+ * layout is accordion-based (no panel-toggle pattern) and doesn't have
6
+ * a routed content panel we can slot into. Instead this wrapper
7
+ * renders a full-viewport overlay (`position:fixed; inset:0`) that
8
+ * stacks on top of the accordion layout when the boot gate requires
9
+ * login. Hidden by default; the application's boot gate flips
10
+ * `display:block` when the user needs to authenticate.
11
+ *
12
+ * Inside the overlay is `#Pict-Login-Container` — the same mount
13
+ * point name pict-section-login defaults to, so the section's render()
14
+ * targets it without further config.
15
+ */
16
+
17
+ const libPictView = require('pict-view');
18
+
19
+ const _ViewConfiguration =
20
+ {
21
+ ViewIdentifier: 'Facto-Login',
22
+ AutoInitialize: true,
23
+ AutoRender: false,
24
+
25
+ DefaultRenderable: 'Facto-Login-Overlay',
26
+ DefaultDestinationAddress: '#Facto-Login-Overlay',
27
+
28
+ Templates:
29
+ [
30
+ {
31
+ Hash: 'Facto-Login-Overlay-Template',
32
+ Template: /*html*/`
33
+ <div class="facto-login-overlay-card">
34
+ <div id="Pict-Login-Container"></div>
35
+ </div>`
36
+ }
37
+ ],
38
+
39
+ Renderables:
40
+ [
41
+ {
42
+ RenderableHash: 'Facto-Login-Overlay',
43
+ TemplateHash: 'Facto-Login-Overlay-Template',
44
+ ContentDestinationAddress: '#Facto-Login-Overlay',
45
+ RenderMethod: 'replace'
46
+ }
47
+ ],
48
+
49
+ CSS: /*css*/`
50
+ #Facto-Login-Overlay
51
+ {
52
+ position: fixed;
53
+ inset: 0;
54
+ z-index: 9999;
55
+ display: none;
56
+ background: rgba(15, 19, 26, 0.92);
57
+ align-items: center;
58
+ justify-content: center;
59
+ padding: 24px;
60
+ overflow: auto;
61
+ }
62
+ #Facto-Login-Overlay.is-active
63
+ {
64
+ display: flex;
65
+ }
66
+ .facto-login-overlay-card
67
+ {
68
+ width: 100%;
69
+ max-width: 420px;
70
+ }
71
+ `
72
+ };
73
+
74
+ class FactoLoginView extends libPictView
75
+ {
76
+ onAfterRender(pRenderable, pAddress, pRecord, pContent)
77
+ {
78
+ // Render pict-section-login into the mount point we just
79
+ // painted. The section's DefaultDestinationAddress is the
80
+ // same `#Pict-Login-Container`, so a plain render() routes.
81
+ let tmpInner = this.pict && this.pict.views && this.pict.views['Pict-Section-Login'];
82
+ if (tmpInner) { tmpInner.render(); }
83
+ this.pict.CSSMap.injectCSS();
84
+ return super.onAfterRender
85
+ ? super.onAfterRender(pRenderable, pAddress, pRecord, pContent)
86
+ : undefined;
87
+ }
88
+ }
89
+
90
+ module.exports = FactoLoginView;
91
+ module.exports.default_configuration = _ViewConfiguration;