@ibgib/web-gib 0.0.62 → 0.0.64

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 (98) hide show
  1. package/README.md +4 -0
  2. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  3. package/dist/AUTO-GENERATED-version.mjs +1 -1
  4. package/dist/helpers.web.d.mts +17 -2
  5. package/dist/helpers.web.d.mts.map +1 -1
  6. package/dist/helpers.web.mjs +67 -2
  7. package/dist/helpers.web.mjs.map +1 -1
  8. package/dist/helpers.web.respec.mjs +37 -10
  9. package/dist/helpers.web.respec.mjs.map +1 -1
  10. package/dist/identity/passkey-helper.d.mts +7 -2
  11. package/dist/identity/passkey-helper.d.mts.map +1 -1
  12. package/dist/identity/passkey-helper.mjs +33 -12
  13. package/dist/identity/passkey-helper.mjs.map +1 -1
  14. package/dist/index.d.mts +3 -0
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +4 -0
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/ui/component/identity/keystone-creator/keystone-creator.css +26 -0
  19. package/dist/ui/component/identity/keystone-creator/keystone-creator.d.mts.map +1 -1
  20. package/dist/ui/component/identity/keystone-creator/keystone-creator.html +18 -1
  21. package/dist/ui/component/identity/keystone-creator/keystone-creator.mjs +10 -2
  22. package/dist/ui/component/identity/keystone-creator/keystone-creator.mjs.map +1 -1
  23. package/dist/ui/component/identity/keystone-details/keystone-details.d.mts +12 -0
  24. package/dist/ui/component/identity/keystone-details/keystone-details.d.mts.map +1 -1
  25. package/dist/ui/component/identity/keystone-details/keystone-details.html +8 -0
  26. package/dist/ui/component/identity/keystone-details/keystone-details.mjs +419 -305
  27. package/dist/ui/component/identity/keystone-details/keystone-details.mjs.map +1 -1
  28. package/dist/ui/ui-helpers.d.mts.map +1 -1
  29. package/dist/ui/ui-helpers.mjs +7 -2
  30. package/dist/ui/ui-helpers.mjs.map +1 -1
  31. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-constants.d.mts +7 -0
  32. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-constants.d.mts.map +1 -0
  33. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-constants.mjs +7 -0
  34. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-constants.mjs.map +1 -0
  35. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-types.d.mts +24 -0
  36. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-types.d.mts.map +1 -0
  37. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-types.mjs +23 -0
  38. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-types.mjs.map +1 -0
  39. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.d.mts +85 -0
  40. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.d.mts.map +1 -0
  41. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.mjs +343 -0
  42. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.mjs.map +1 -0
  43. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.respec.d.mts +8 -0
  44. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.respec.d.mts.map +1 -0
  45. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.respec.mjs +249 -0
  46. package/dist/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.respec.mjs.map +1 -0
  47. package/package.json +2 -2
  48. package/src/AUTO-GENERATED-version.mts +1 -1
  49. package/src/helpers.mts +1 -1
  50. package/src/helpers.web.mts +95 -5
  51. package/src/helpers.web.respec.mts +41 -10
  52. package/src/identity/passkey-helper.mts +43 -10
  53. package/src/index.mts +5 -0
  54. package/src/ui/component/identity/keystone-creator/keystone-creator.css +26 -0
  55. package/src/ui/component/identity/keystone-creator/keystone-creator.html +18 -1
  56. package/src/ui/component/identity/keystone-creator/keystone-creator.mts +12 -2
  57. package/src/ui/component/identity/keystone-details/keystone-details.html +8 -0
  58. package/src/ui/component/identity/keystone-details/keystone-details.mts +474 -339
  59. package/src/ui/ui-helpers.mts +6 -2
  60. package/src/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-constants.mts +8 -0
  61. package/src/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-types.mts +53 -0
  62. package/src/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.mts +424 -0
  63. package/src/witness/space/web-in-memory-workspace-projection-space/web-in-memory-workspace-projection-space-v1.respec.mts +304 -0
  64. package/tools/auto-generated-agent-skills/skills/ibgib-create-app/SKILL.md +65 -39
  65. package/tools/auto-generated-agent-skills/skills/ibgib-create-client-app/SKILL.md +51 -0
  66. package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/SKILL.md +26 -22
  67. package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-witness → ibgib-create-client-app-witness}/SKILL.md +11 -7
  68. package/tools/auto-generated-agent-skills/skills/ibgib-create-client-identity/SKILL.md +78 -0
  69. package/tools/auto-generated-agent-skills/skills/ibgib-create-client-shell/SKILL.md +42 -0
  70. package/tools/auto-generated-agent-skills/skills/ibgib-create-server-app/SKILL.md +50 -0
  71. package/tools/auto-generated-agent-skills/skills/ibgib-create-server-app/templates/Dockerfile.template +14 -0
  72. package/tools/auto-generated-agent-skills/skills/ibgib-create-server-app/templates/docker-compose.yml.template +33 -0
  73. package/tools/auto-generated-agent-skills/skills/ibgib-create-server-app/templates/server.mts.template +97 -0
  74. package/tools/auto-generated-agent-skills/skills/ibgib-create-server-app/templates/tsconfig.server.json.template +29 -0
  75. package/tools/auto-generated-agent-skills/skills/ibgib-implementation-plan/SKILL.md +4 -1
  76. package/src/identity/custodian-delegate-helper.mts.bak +0 -7
  77. package/src/identity/sso/sso-config-helper.mts.bak +0 -52
  78. package/src/identity/sso/sso-custodian-service.mts.bak +0 -566
  79. package/src/identity/sso/sso-custodian-service.respec.mts.bak +0 -298
  80. package/tools/auto-generated-agent-skills/skills/ibgib-create-shell/SKILL.md +0 -40
  81. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/generate-id.js +0 -0
  82. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/generate-version-file.js +0 -0
  83. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/bootstrap.mts.template +0 -0
  84. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/constants.mts.template +0 -0
  85. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/declarations.d.ts.template +0 -0
  86. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/helpers.web.mts.template +0 -0
  87. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/index.html.template +0 -0
  88. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/index.mts.template +0 -0
  89. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/script.mts.template +0 -0
  90. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-core → ibgib-create-client-app-core}/templates/types.mts.template +0 -0
  91. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-witness → ibgib-create-client-app-witness}/templates/api/function-infos.web.mts.template +0 -0
  92. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-witness → ibgib-create-client-app-witness}/templates/witness/app/app-v1.mts.template +0 -0
  93. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-witness → ibgib-create-client-app-witness}/templates/witness/app/constants.mts.template +0 -0
  94. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-witness → ibgib-create-client-app-witness}/templates/witness/app/helper.mts.template +0 -0
  95. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-app-witness → ibgib-create-client-app-witness}/templates/witness/app/types.mts.template +0 -0
  96. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-shell → ibgib-create-client-shell}/templates/ui/shell/shell-constants.mts.template +0 -0
  97. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-shell → ibgib-create-client-shell}/templates/ui/shell/shell-service.mts.template +0 -0
  98. /package/tools/auto-generated-agent-skills/skills/{ibgib-create-shell → ibgib-create-client-shell}/templates/ui/shell/shell-types.mts.template +0 -0
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: ibgib-create-client-identity
3
+ description: Scaffolds drop-in Keystone identity UI Web Components registration and remote Hub sync wiring for an ibgib client application.
4
+ ---
5
+
6
+ # Skill: ibgib-create-client-identity
7
+
8
+ ## What This Skill Does
9
+
10
+ This skill wires prebuilt Keystone identity UI components and symmetric peer sync into an `ibgib` client application. Downstream applications do not need to build custom authentication screens, passkey genesis flows, or device management dialogs.
11
+
12
+ This skill automates:
13
+ 1. **Component Registration**: Registering all native Web Components from `@ibgib/web-gib/dist/ui/component/identity/index.mjs` in `bootstrap.mts`.
14
+ 2. **HTML Integration**: Embedding `<ibgib-identity-manager>`, `<ibgib-keystone-creator>`, `<ibgib-keystone-details>`, or `<ibgib-identity-header>` into the application shell.
15
+ 3. **Hub Sync Wiring**: Initializing `SyncWebsocketPeer_V1` and `KeystoneSyncService` using `APP_CONFIG.hubUrl`.
16
+
17
+ For complete architectural details, refer to [`docs/IBGIB_CLIENT_APPS_GUIDE.md`](file:///c:/Users/billm/antigravity/ibgib/docs/IBGIB_CLIENT_APPS_GUIDE.md).
18
+
19
+ ---
20
+
21
+ ## Pre-Requisites
22
+ - Ensure `ibgib-create-client-app-core` and `ibgib-create-client-app-witness` have been scaffolded.
23
+
24
+ ---
25
+
26
+ ## Integration Steps
27
+
28
+ ### 1. Register Components in `bootstrap.mts`
29
+ Add the following import and invocation to `src/bootstrap.mts` (or `src/client/bootstrap.mts`):
30
+
31
+ ```typescript
32
+ import { registerIdentityComponents } from '@ibgib/web-gib/dist/ui/component/identity/index.mjs';
33
+
34
+ // Inside your bootstrap / init function:
35
+ registerIdentityComponents();
36
+ ```
37
+
38
+ ### 2. Embed Identity Elements in DOM / Shell Template
39
+ Add identity components to `index.html` or inside your main component's HTML template:
40
+
41
+ ```html
42
+ <!-- Header Identity Badge -->
43
+ <header class="app-header">
44
+ <h1>{{APP_HUMAN_NAME}}</h1>
45
+ <ibgib-identity-header></ibgib-identity-header>
46
+ </header>
47
+
48
+ <!-- Main Identity View (shown in Settings or Auth Modal) -->
49
+ <section id="identity-section" class="hidden">
50
+ <ibgib-identity-manager></ibgib-identity-manager>
51
+ </section>
52
+ ```
53
+
54
+ ### 3. Initialize Remote Hub Sync Service
55
+ In `bootstrap.mts` (or an `identity-sync.mts` helper), wire up symmetric sync:
56
+
57
+ ```typescript
58
+ import { KeystoneSyncService, SyncWebsocketPeer_V1 } from '@ibgib/web-gib';
59
+ import { APP_CONFIG } from './config.mjs';
60
+
61
+ export async function initHubSync({ metaspace, localSpace }: { metaspace: any, localSpace: any }) {
62
+ const wsUrl = APP_CONFIG.hubUrl.replace(/^http/, 'ws') + '/api/sync';
63
+
64
+ const peerWitness = new SyncWebsocketPeer_V1({
65
+ url: wsUrl,
66
+ metaspace,
67
+ localSpace
68
+ });
69
+
70
+ const syncService = new KeystoneSyncService({
71
+ peerWitness,
72
+ metaspace,
73
+ localSpace
74
+ });
75
+
76
+ return syncService;
77
+ }
78
+ ```
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: ibgib-create-client-shell
3
+ description: Scaffolds the foundational UI Shell for an ibgib client app. Generates the shell service, constants, and types required for UI management and component registration.
4
+ ---
5
+
6
+ # Skill: ibgib-create-client-shell
7
+
8
+ ## What This Skill Does
9
+
10
+ This skill scaffolds the UI Shell architecture for an `ibgib` client application. The Shell Service acts as a singleton on `globalThis` that manages DOM interactions, handles shell-specific events (e.g. burger menus, window resizing), and coordinates UI activation once the Metaspace and App Witness are initialized.
11
+
12
+ For full architectural context, refer to [`docs/IBGIB_CLIENT_APPS_GUIDE.md`](file:///c:/Users/billm/antigravity/ibgib/docs/IBGIB_CLIENT_APPS_GUIDE.md).
13
+
14
+ ---
15
+
16
+ ## Parameters (Tokens)
17
+ - `{{APP_NAME}}`: kebab-case (e.g. `test-app`)
18
+ - `{{APP_DIR_NAME}}`: folder name (e.g. `test-app`)
19
+ - `{{APP_CLASSNAME_PREFIX}}`: PascalCase (e.g. `TestApp`)
20
+ - `{{APP_CLASSNAME}}`: e.g. `TestAppApp_V1`
21
+ - `{{APP_HUMAN_NAME}}`: e.g. `Test App`
22
+ - `{{APP_VAR_NAME}}`: camelCase (e.g. `testApp`)
23
+
24
+ ---
25
+
26
+ ## Output Files
27
+ The skill generates:
28
+ 1. `src/ui/shell/{{APP_DIR_NAME}}-shell-service.mts` (or `src/client/ui/shell/...`)
29
+ 2. `src/ui/shell/{{APP_DIR_NAME}}-shell-constants.mts`
30
+ 3. `src/ui/shell/{{APP_DIR_NAME}}-shell-types.mts`
31
+
32
+ ---
33
+
34
+ ## Usage Instructions
35
+ 1. Ensure the `src/ui/shell` (or `src/client/ui/shell`) directory exists.
36
+ 2. Generate the shell service, constants, and types from templates in `templates/ui/shell/`.
37
+ 3. Update `script.mts` to import and call the shell factory:
38
+ ```typescript
39
+ import { get{{APP_CLASSNAME_PREFIX}}ShellSvc } from "./ui/shell/{{APP_DIR_NAME}}-shell-service.mjs";
40
+ get{{APP_CLASSNAME_PREFIX}}ShellSvc();
41
+ ```
42
+ 4. Update `bootstrap.mts` to invoke `get{{APP_CLASSNAME_PREFIX}}ShellSvc().onEngineReady()` inside the `onReady` lifecycle hook.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: ibgib-create-server-app
3
+ description: Scaffolds the backend Node.js server for an ibgib full-stack application using serve-gib from @ibgib/node-gib, including WebSocket sync upgrade, Traefik Docker Compose, and server TypeScript configuration.
4
+ ---
5
+
6
+ # Skill: ibgib-create-server-app
7
+
8
+ ## What This Skill Does
9
+
10
+ Generates the backend server infrastructure for an `ibgib` server application or the server backend of a full-stack project. This includes:
11
+ - **`src/server/server.mts`**: Node.js HTTP/WebSocket server utilizing `serve-gib`, `getStandardServeGibHandlers()`, and `SyncUpgradeHandler`.
12
+ - **`tsconfig.server.json`**: TypeScript compiler configuration targeted for Node.js ESNext.
13
+ - **`Dockerfile`**: Lightweight Alpine container packaging the bundled server and static client SPA.
14
+ - **`docker-compose.yml`**: Local multi-container orchestration behind the Traefik reverse proxy with automatic local HTTPS (`*.localhost` and `local.ibgib.space` SSO loopback).
15
+
16
+ For architectural context, refer to [`docs/IBGIB_SERVER_APPS_GUIDE.md`](file:///c:/Users/billm/antigravity/ibgib/docs/IBGIB_SERVER_APPS_GUIDE.md).
17
+
18
+ ---
19
+
20
+ ## Token Reference
21
+
22
+ | Token | Example value | How it's computed |
23
+ |---|---|---|
24
+ | `{{APP_NAME}}` | `my-app` | kebab-case application name |
25
+ | `{{APP_DIR_NAME}}` | `my-app` | Folder name |
26
+ | `{{APP_HUMAN_NAME}}` | `My App` | Natural language name |
27
+ | `{{PORT}}` | `3000` | Server port (default `3000`) |
28
+ | `{{DATA_DIR_REL}}` | `../../.data/my-app-space` | Local storage directory relative to server |
29
+ | `{{LOCAL_DOMAIN}}` | `my-app.localhost` | Local HTTPS subdomain |
30
+ | `{{APP_UUID}}` | `4b810a9c...` | Unique 32-char hex string from `generate-id.js` |
31
+
32
+ ---
33
+
34
+ ## Generation Steps
35
+
36
+ ### 1. Confirm token values
37
+ Derive tokens from the developer's inputs and generate fresh UUIDs using `node .agents/skills/ibgib-create-client-app-core/generate-id.js`.
38
+
39
+ ### 2. Generate files
40
+ Apply token substitutions to templates in `templates/` and write to the target application directory:
41
+
42
+ | Template file | Output file |
43
+ |---|---|
44
+ | `templates/server.mts.template` | `src/server/server.mts` |
45
+ | `templates/tsconfig.server.json.template` | `tsconfig.server.json` |
46
+ | `templates/Dockerfile.template` | `Dockerfile` |
47
+ | `templates/docker-compose.yml.template` | `docker-compose.yml` (or app service block) |
48
+
49
+ ### 3. Update Build Script
50
+ Ensure the application's `build-[app-name].mts` script configures `tsconfigConfigs` for both client (`tsconfig.json`) and server (`tsconfig.server.json`), and builds the server entry point via `buildServer()`.
@@ -0,0 +1,14 @@
1
+ FROM node:22-alpine
2
+ WORKDIR /app
3
+
4
+ # The server is bundled into a single zero-dependency ESM file via esbuild
5
+ COPY dist/server ./server
6
+
7
+ # Client SPA (served as static files by the node server)
8
+ COPY dist/client ./client
9
+
10
+ ENV PORT={{PORT}}
11
+ ENV DATA_DIR=/data/{{APP_DIR_NAME}}-space
12
+
13
+ EXPOSE {{PORT}}
14
+ CMD ["node", "server/server.mjs"]
@@ -0,0 +1,33 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ # ==========================================
5
+ # {{APP_NAME_UPPER}} SERVICE
6
+ # ==========================================
7
+ {{APP_DIR_NAME}}:
8
+ build: ./apps/{{APP_DIR_NAME}}
9
+ restart: unless-stopped
10
+ volumes:
11
+ - ./apps/{{APP_DIR_NAME}}/.data:/data/{{APP_DIR_NAME}}-space
12
+ - ./apps/{{APP_DIR_NAME}}/dist/client:/app/client
13
+ - ./apps/{{APP_DIR_NAME}}/dist/server:/app/server
14
+ environment:
15
+ - PORT={{PORT}}
16
+ - DATA_DIR=/data/{{APP_DIR_NAME}}-space
17
+ - KEYSTONE_PROFILE_SOVEREIGN_PRIMARY=${KEYSTONE_PROFILE_SOVEREIGN_PRIMARY}
18
+ - KEYSTONE_PROFILE_SOVEREIGN_SYNC=${KEYSTONE_PROFILE_SOVEREIGN_SYNC}
19
+ - KEYSTONE_PROFILE_CUSTODIAN_PRIMARY=${KEYSTONE_PROFILE_CUSTODIAN_PRIMARY}
20
+ - KEYSTONE_PROFILE_CUSTODIAN_SYNC=${KEYSTONE_PROFILE_CUSTODIAN_SYNC}
21
+ - EMAIL_MODE=${EMAIL_MODE}
22
+ - SSO_SERVER_KDF_SECRET=${SSO_SERVER_KDF_SECRET}
23
+ - SESSION_SECRET=${SESSION_SECRET}
24
+ - GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
25
+ - GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
26
+ - GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
27
+ - GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
28
+ labels:
29
+ - "traefik.enable=true"
30
+ - "traefik.http.routers.{{APP_DIR_NAME}}.rule=Host(`{{LOCAL_DOMAIN}}`) || Host(`local.ibgib.space`)"
31
+ - "traefik.http.routers.{{APP_DIR_NAME}}.entrypoints=websecure"
32
+ - "traefik.http.routers.{{APP_DIR_NAME}}.tls=true"
33
+ - "traefik.http.services.{{APP_DIR_NAME}}.loadbalancer.server.port={{PORT}}"
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @module server
3
+ *
4
+ * Native Node.js HTTP & WebSocket server for {{APP_NAME}} — using serve-gib from @ibgib/node-gib.
5
+ */
6
+
7
+ import { createServer } from 'node:http';
8
+ import { join, dirname } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+
11
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
+ import {
13
+ ServeGib_V1,
14
+ ErrorHandler,
15
+ SyncUpgradeHandler,
16
+ canHandleWsUpgrade,
17
+ handleWsEchoUpgrade,
18
+ getStandardServeGibHandlers,
19
+ } from '@ibgib/node-gib/dist/serve-gib/index.mjs';
20
+
21
+ const __dirname = dirname(fileURLToPath(import.meta.url));
22
+
23
+ // ---------------------------------------------------------------------------
24
+ // Config
25
+ // ---------------------------------------------------------------------------
26
+
27
+ const PORT = parseInt(process.env.PORT ?? '{{PORT}}', 10);
28
+ const DATA_DIR = process.env.DATA_DIR ?? join(__dirname, '{{DATA_DIR_REL}}');
29
+ const CLIENT_DIR = join(__dirname, '../client');
30
+
31
+ // ---------------------------------------------------------------------------
32
+ // Main
33
+ // ---------------------------------------------------------------------------
34
+
35
+ async function main(): Promise<void> {
36
+ const lc = '[{{APP_NAME}} server]';
37
+ try {
38
+ console.log(`${lc} starting...`);
39
+ console.log(`${lc} dataDir: ${DATA_DIR}`);
40
+
41
+ const custodianPrimaryProfile = (process.env.KEYSTONE_PROFILE_CUSTODIAN_PRIMARY || '').trim();
42
+ if (!custodianPrimaryProfile) {
43
+ throw new Error(`${lc} Fatal Error: KEYSTONE_PROFILE_CUSTODIAN_PRIMARY environment variable is missing or blank. (E: {{APP_UUID}})`);
44
+ }
45
+
46
+ const isProdEnv = process.env.NODE_ENV === 'production';
47
+ if (isProdEnv && !custodianPrimaryProfile.endsWith('.prod')) {
48
+ throw new Error(`${lc} Security Violation: Non-production keystone profile '${custodianPrimaryProfile}' is prohibited when NODE_ENV=production. (E: {{APP_UUID}})`);
49
+ }
50
+
51
+ console.log(`${lc} KEYSTONE_PROFILE_CUSTODIAN_PRIMARY: ${custodianPrimaryProfile} (I: {{APP_UUID}})`);
52
+
53
+ if (custodianPrimaryProfile.endsWith('.dev')) {
54
+ console.warn(`\n==========================================================\n⚠️ WARNING: CUSTODIAN KEYSTONE PROFILE IS SET TO DEVELOPMENT ('${custodianPrimaryProfile}')!\nCUSTODIAL KEYSTONES WILL USE LOW-SECURITY DEV PARAMETERS.\nFOR LOCAL TESTING ONLY — DO NOT USE FOR REAL SECRETS OR PRODUCTION DATA!\n==========================================================\n (W: {{APP_UUID}})`);
55
+ } else if (custodianPrimaryProfile.endsWith('.staging')) {
56
+ console.info(`${lc} ℹ️ STAGING CUSTODIAN KEYSTONE PROFILE ACTIVE ('${custodianPrimaryProfile}')`);
57
+ }
58
+
59
+ const syncUpgradeHandler = new SyncUpgradeHandler();
60
+
61
+ // Initialize serve-gib using standard handler preset from @ibgib/node-gib
62
+ const serveGib = new ServeGib_V1({
63
+ port: PORT,
64
+ dataDir: DATA_DIR,
65
+ handlers: getStandardServeGibHandlers({ clientDir: CLIENT_DIR }),
66
+ errorHandler: new ErrorHandler()
67
+ });
68
+
69
+ const server = createServer(async (req, res) => {
70
+ await serveGib.handleRequest(req, res);
71
+ });
72
+
73
+ // WebSocket upgrade handling for symmetric sync
74
+ server.on('upgrade', async (req, socket, head) => {
75
+ const reqCtx = await serveGib.prepareContext(req);
76
+
77
+ const isSync = await syncUpgradeHandler.handleUpgrade(reqCtx, socket as any, head);
78
+
79
+ if (!isSync && canHandleWsUpgrade(req)) {
80
+ handleWsEchoUpgrade(req, socket as any, head);
81
+ } else if (!isSync) {
82
+ socket.write('HTTP/1.1 404 Not Found\r\n\r\n');
83
+ socket.destroy();
84
+ }
85
+ });
86
+
87
+ server.listen(PORT, '0.0.0.0', () => {
88
+ console.log(`${lc} listening on http://0.0.0.0:${PORT}`);
89
+ });
90
+
91
+ } catch (error) {
92
+ console.error(`${lc} fatal: ${extractErrorMsg(error)}`);
93
+ process.exit(1);
94
+ }
95
+ }
96
+
97
+ main();
@@ -0,0 +1,29 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "declaration": false,
5
+ "declarationMap": false,
6
+ "sourceMap": false,
7
+ "rootDir": "./src",
8
+ "composite": false,
9
+ "outDir": "./dist/server",
10
+ "module": "ESNext",
11
+ "lib": [
12
+ "ES2022",
13
+ "ES2023"
14
+ ],
15
+ "types": ["node"]
16
+ },
17
+ "include": [
18
+ "src/server/**/*.ts",
19
+ "src/server/**/*.mts",
20
+ "src/server/**/*.d.ts",
21
+ "src/common/**/*.ts",
22
+ "src/common/**/*.mts"
23
+ ],
24
+ "exclude": [
25
+ "node_modules",
26
+ "**/*.respec.mts",
27
+ "./dist/**/*"
28
+ ]
29
+ }
@@ -36,7 +36,10 @@ Every `[what]_IMPLEMENTATION.md` file MUST follow this high-level structure, ada
36
36
 
37
37
  ## 🛠️ Build Chain & Environment Setup
38
38
 
39
- * **Workspace Build Chain**: Required build commands and dependency propagation steps (e.g., `npm run build:core-gib` vs `npm run chain:build:web-gib`).
39
+ * **Workspace Build Chain**:
40
+ * **Local Library Iteration**: When modifying code in a lower-level library (e.g. `libs/core-gib`), run its specific build and test commands (e.g. `npm run build:core-gib` and `npm run test:core-gib`).
41
+ * **Downstream Chain Propagation**: After local library changes pass, you MUST propagate changes to downstream dependents by running the appropriate chain build command (e.g. `npm run chain:build:core-gib` or `npm run chain:build:web-gib`).
42
+ * **Application Builds**: Build and run downstream applications with `npm run build:[app]` or `npm run watch:[app]` (e.g. `npm run build:space-gib`).
40
43
  * **Environment Configuration**: Required `.env` variables, port settings, or hardware/OS constraints.
41
44
 
42
45
  ---
@@ -1,7 +0,0 @@
1
- /**
2
- * @module identity/custodian-delegate-helper
3
- *
4
- * Re-exports from {@link ./device-delegate-helper.mjs} for backward compatibility.
5
- */
6
-
7
- export * from './device-delegate-helper.mjs';
@@ -1,52 +0,0 @@
1
- import { SsoServerConfig, SsoProviderServerConfig, SsoProviderId } from './sso-types.mjs';
2
-
3
- /**
4
- * Loads the SSO configuration from environment variables.
5
- * Parses active OAuth2 providers dynamically based on their environment keys.
6
- */
7
- export function loadSsoServerConfig(): SsoServerConfig {
8
- const ssoServerKdfSecret = process.env.SSO_SERVER_KDF_SECRET;
9
- const sessionSecret = process.env.SESSION_SECRET;
10
-
11
- if (!ssoServerKdfSecret) {
12
- throw new Error(
13
- `SSO_SERVER_KDF_SECRET is missing from environment. (E: 840899ab4fdfd23e89cfae1889cfae12)`
14
- );
15
- }
16
- if (!sessionSecret) {
17
- throw new Error(
18
- `SESSION_SECRET is missing from environment. (E: bfa899ab4fdfd23e89cfae23)`
19
- );
20
- }
21
-
22
- const providers: Partial<Record<SsoProviderId, SsoProviderServerConfig>> = {};
23
-
24
- // Load Google Provider if configured
25
- if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
26
- providers.google = {
27
- providerId: 'google',
28
- clientId: process.env.GOOGLE_CLIENT_ID,
29
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
30
- tokenUrl: 'https://oauth2.googleapis.com/token',
31
- userInfoUrl: 'https://openidconnect.googleapis.com/v1/userinfo',
32
- jwksUrl: 'https://www.googleapis.com/oauth2/v3/certs'
33
- };
34
- }
35
-
36
- // Load GitHub Provider if configured
37
- if (process.env.GITHUB_CLIENT_ID && process.env.GITHUB_CLIENT_SECRET) {
38
- providers.github = {
39
- providerId: 'github',
40
- clientId: process.env.GITHUB_CLIENT_ID,
41
- clientSecret: process.env.GITHUB_CLIENT_SECRET,
42
- tokenUrl: 'https://github.com/login/oauth/access_token',
43
- userInfoUrl: 'https://api.github.com/user'
44
- };
45
- }
46
-
47
- return {
48
- ssoServerKdfSecret,
49
- sessionSecret,
50
- providers
51
- };
52
- }