@ibgib/web-gib 0.0.56 → 0.0.57

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 (46) hide show
  1. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  2. package/dist/AUTO-GENERATED-version.mjs +1 -1
  3. package/dist/api/api-index.mjs +1 -1
  4. package/dist/api/api-index.mjs.map +1 -1
  5. package/dist/api/ibgib-api-bridge.d.mts +35 -0
  6. package/dist/api/ibgib-api-bridge.d.mts.map +1 -1
  7. package/dist/api/ibgib-api-bridge.mjs +70 -3
  8. package/dist/api/ibgib-api-bridge.mjs.map +1 -1
  9. package/dist/ui/component/identity/add-device/add-device.d.mts.map +1 -1
  10. package/dist/ui/component/identity/add-device/add-device.html +6 -7
  11. package/dist/ui/component/identity/add-device/add-device.mjs +13 -10
  12. package/dist/ui/component/identity/add-device/add-device.mjs.map +1 -1
  13. package/dist/ui/component/identity/keystone-creator/keystone-creator.css +19 -0
  14. package/dist/ui/component/identity/keystone-creator/keystone-creator.d.mts +1 -0
  15. package/dist/ui/component/identity/keystone-creator/keystone-creator.d.mts.map +1 -1
  16. package/dist/ui/component/identity/keystone-creator/keystone-creator.html +10 -0
  17. package/dist/ui/component/identity/keystone-creator/keystone-creator.mjs +164 -41
  18. package/dist/ui/component/identity/keystone-creator/keystone-creator.mjs.map +1 -1
  19. package/dist/ui/component/identity/keystone-details/keystone-details.d.mts.map +1 -1
  20. package/dist/ui/component/identity/keystone-details/keystone-details.mjs +9 -8
  21. package/dist/ui/component/identity/keystone-details/keystone-details.mjs.map +1 -1
  22. package/package.json +2 -2
  23. package/src/AUTO-GENERATED-version.mts +1 -1
  24. package/src/api/api-index.mts +1 -1
  25. package/src/api/ibgib-api-bridge.mts +94 -4
  26. package/src/identity/sso/{sso-custodian-service.mts → sso-custodian-service.mts.bak} +65 -38
  27. package/src/identity/sso/{sso-custodian-service.respec.mts → sso-custodian-service.respec.mts.bak} +15 -14
  28. package/src/ui/component/identity/add-device/add-device.html +6 -7
  29. package/src/ui/component/identity/add-device/add-device.mts +17 -16
  30. package/src/ui/component/identity/keystone-creator/keystone-creator.css +19 -0
  31. package/src/ui/component/identity/keystone-creator/keystone-creator.html +10 -0
  32. package/src/ui/component/identity/keystone-creator/keystone-creator.mts +180 -55
  33. package/src/ui/component/identity/keystone-details/keystone-details.mts +16 -15
  34. package/dist/identity/sso/sso-config-helper.d.mts +0 -7
  35. package/dist/identity/sso/sso-config-helper.d.mts.map +0 -1
  36. package/dist/identity/sso/sso-config-helper.mjs +0 -42
  37. package/dist/identity/sso/sso-config-helper.mjs.map +0 -1
  38. package/dist/identity/sso/sso-custodian-service.d.mts +0 -139
  39. package/dist/identity/sso/sso-custodian-service.d.mts.map +0 -1
  40. package/dist/identity/sso/sso-custodian-service.mjs +0 -443
  41. package/dist/identity/sso/sso-custodian-service.mjs.map +0 -1
  42. package/dist/identity/sso/sso-custodian-service.respec.d.mts +0 -2
  43. package/dist/identity/sso/sso-custodian-service.respec.d.mts.map +0 -1
  44. package/dist/identity/sso/sso-custodian-service.respec.mjs +0 -254
  45. package/dist/identity/sso/sso-custodian-service.respec.mjs.map +0 -1
  46. /package/src/identity/sso/{sso-config-helper.mts → sso-config-helper.mts.bak} +0 -0
@@ -2,39 +2,29 @@ import thisCss from "./keystone-creator.css";
2
2
  import thisHtml from "./keystone-creator.html";
3
3
  import commonComponentStylesCss from "../../common-component-styles.css";
4
4
 
5
- import { delay, extractErrorMsg, hash } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
6
- import { HashAlgorithm } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
5
+ import { delay, extractErrorMsg, } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
7
6
  import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
8
7
  import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
9
8
  import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
9
+ import { getGibInfo } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
10
10
  import { KeystoneService_V1 } from "@ibgib/core-gib/dist/keystone/keystone-service-v1.mjs";
11
- import {
12
- KeystonePoolConfig, KeystoneChallengeType, KeystoneReplenishStrategy
13
- } from "@ibgib/core-gib/dist/keystone/keystone-types.mjs";
14
11
  import { KeystoneProfileBuilder } from "@ibgib/core-gib/dist/keystone/policy/keystone-profile-builder.mjs";
15
- import { getGlobalMetaspace_waitIfNeeded, getLocalCoupledIbGibForDomainIbGib } from "../../../../helpers.mjs";
16
- import {
17
- IbGibDynamicComponentMetaBase, IbGibFormInstanceBase,
18
- } from "../../ibgib-dynamic-component-bases.mjs";
12
+ import { updateSpecialIndex, } from "@ibgib/core-gib/dist/timeline/timeline-api.mjs";
13
+ import { toDto, getTjpAddr } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
14
+ import { validateEmail } from "@ibgib/core-gib/dist/keystone/keystone-helpers.mjs";
15
+ import { KEYSTONE_USERNAME_REGEXP, KEYSTONE_DESCRIPTION_REGEXP, KEYSTONE_VERB_SYNC, KEYSTONE_VERB_CONNECT } from "@ibgib/core-gib/dist/keystone/keystone-constants.mjs";
16
+ import { deriveDelegateSecret } from "@ibgib/core-gib/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs";
17
+
18
+ import { getGlobalMetaspace_waitIfNeeded, } from "../../../../helpers.mjs";
19
+ import { IbGibDynamicComponentMetaBase, IbGibFormInstanceBase, } from "../../ibgib-dynamic-component-bases.mjs";
19
20
  import {
20
21
  ElementsBase, IbGibDynamicComponentInstance,
21
22
  IbGibDynamicComponentInstanceInitOpts,
22
23
  } from "../../component-types.mjs";
23
-
24
24
  import { getComponentCtorArg } from "../../../../app-bootstrap/init-orchestration.mjs";
25
25
  import { getApiBridge } from "../../../../api/ibgib-api-bridge.mjs";
26
-
27
- import {
28
- createSettings, getSectionName, getSettingsScope
29
- } from "../../../../common/settings/settings-helpers.mjs";
30
- import { SettingsType } from "../../../../common/settings/settings-constants.mjs";
31
- import { SettingsIbGib_V1 } from "../../../../common/settings/settings-types.mjs";
32
- import { updateSpecialIndex, mut8Timeline } from "@ibgib/core-gib/dist/timeline/timeline-api.mjs";
33
- import { toDto } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
34
- import { validateEmail } from "@ibgib/core-gib/dist/keystone/keystone-helpers.mjs";
35
- import { KEYSTONE_USERNAME_REGEXP, KEYSTONE_DESCRIPTION_REGEXP, KEYSTONE_VERB_SYNC, KEYSTONE_VERB_CONNECT } from "@ibgib/core-gib/dist/keystone/keystone-constants.mjs";
36
26
  import { EVENT_IBGIB_IDENTITY_REQUEST_CHANGE, EVENT_IBGIB_UI_MESSAGE } from "../../../ui-constants.mjs";
37
- import { deriveDelegateSecret } from "@ibgib/core-gib/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs";
27
+ import { shadowRoot_getElementById } from "../../../../helpers.web.mjs";
38
28
 
39
29
  export const KEYSTONE_CREATOR_COMPONENT_NAME = 'ibgib-keystone-creator';
40
30
 
@@ -293,7 +283,12 @@ export class KeystoneCreatorComponentInstance
293
283
  });
294
284
 
295
285
  // 1. Prepare Primary/Domain Keystone Configs
296
- const builder = KeystoneProfileBuilder.buildKeystone('domain')
286
+ const isProd = process.env.NODE_ENV === 'production';
287
+ const requestedProfile = (process.env.KEYSTONE_PROFILE || 'domain').toLowerCase();
288
+ const profileName = (isProd && requestedProfile === 'test') ? 'domain' : requestedProfile;
289
+ console.log(`${lc} Using keystone policy profile '${profileName}' (I: 90123456789abcdef0123456789abcde)`);
290
+
291
+ const builder = KeystoneProfileBuilder.buildKeystone(profileName as any)
297
292
  .withUsername(username)
298
293
  .withDescription(description);
299
294
  if (email) {
@@ -328,11 +323,11 @@ export class KeystoneCreatorComponentInstance
328
323
  isPrimary: true
329
324
  });
330
325
 
331
- const addr = getIbGibAddr({ ibGib: keystoneIbGib });
332
- console.log(`${lc} local genesis complete: ${addr}`);
326
+ const primaryTjpAddr = getTjpAddr({ ibGib: keystoneIbGib, defaultIfNone: 'incomingAddr' })!;
327
+ console.log(`${lc} local genesis complete: ${primaryTjpAddr}`);
333
328
  await delay(humanEyeDelay); // for human eyes, not needed for functionality
334
329
  this.setStatus("Local genesis complete. Creating sync delegate...", "info");
335
- console.log(`✓ Local genesis complete: ${addr}`);
330
+ console.log(`✓ Local genesis complete: ${primaryTjpAddr}`);
336
331
 
337
332
  // Automatically generate Sync Delegate Keystone
338
333
  this.showBusy({
@@ -343,12 +338,13 @@ export class KeystoneCreatorComponentInstance
343
338
  });
344
339
 
345
340
  const delegateSecret = await deriveDelegateSecret({ masterSecret });
346
- const delegateBuilder = KeystoneProfileBuilder.buildKeystone('sync')
341
+ const delegateBuilder = KeystoneProfileBuilder.buildKeystone(profileName as any)
347
342
  .withUsername(`${username}-sync`)
348
343
  .withDescription(`Sync Delegate for ${username}`)
349
344
  .withDetails({
350
345
  client: 'space-gib-web',
351
- role: 'sync-delegate'
346
+ role: 'sync-delegate',
347
+ primaryTjpAddr: primaryTjpAddr,
352
348
  });
353
349
  const delegateConfigs = await delegateBuilder.compileConfigs();
354
350
 
@@ -385,15 +381,11 @@ export class KeystoneCreatorComponentInstance
385
381
  await delay(humanEyeDelay);
386
382
 
387
383
  // 4. Post to Server
388
- console.log(`Posting genesis keystone to server...`);
389
- this.setStatus("Syncing genesis to server...", "info");
384
+ this.setStatus("Syncing genesis keystone to server...", "info");
390
385
  this.showBusy({
391
386
  isBusy: true,
392
387
  title: 'Syncing to Server...',
393
- msg: [
394
- 'Posting genesis keystone to server sync node...',
395
- '(may take awhile, depending on strength of keystone...)',
396
- ].join('\n'),
388
+ msg: 'Quarantining staging genesis keystone on server...',
397
389
  animationEmoji: '🔄'
398
390
  });
399
391
  const resSync = await getApiBridge().postGenesisKeystone(keystoneIbGib);
@@ -406,26 +398,116 @@ export class KeystoneCreatorComponentInstance
406
398
  return;
407
399
  }
408
400
 
409
- // Post evolved keystone + delegate keystone
410
- this.setStatus("Syncing delegate registration to server...", "info");
411
- this.showBusy({
412
- isBusy: true,
413
- title: 'Syncing Delegate...',
414
- msg: 'Posting evolved domain identity and sync delegate to server...',
415
- animationEmoji: '🔄'
416
- });
417
- const resEvolve = await getApiBridge().putEvolveKeystone({
418
- domainAddr: addr,
419
- keystoneIbGib: evolvedParentKeystoneIbGib,
420
- relatedKeystoneIbGibs: [delegateKeystoneIbGib]
421
- });
422
- if (!resEvolve.success) {
423
- const msg = `Delegate registration sync failed: ${resEvolve.message}`;
424
- console.error(`${lc} ${msg}`);
425
- this.setStatus(msg, "error");
401
+ const isPending = (resSync as any).pending || (resSync as any).statusCode === 202;
402
+
403
+ if (isPending) {
404
+ console.log(`${lc} Genesis keystone quarantined in pending staging area. Prompting for 6-digit verification code.`);
426
405
  this.showBusy({ isBusy: false });
427
- this.setButtonLoading(false);
428
- return;
406
+ this.setFormDisabled(true);
407
+
408
+ if (!this.shadowRoot) { throw new Error(`(UNEXPECTED) this.shadowRoot falsy? (E: 6d316f5a2bf8e6a0286306468d35c826)`); }
409
+ const secVerify = shadowRoot_getElementById<HTMLDivElement>(this.shadowRoot, 'section-code-verification');
410
+ const inputVerifyCode =
411
+ shadowRoot_getElementById<HTMLInputElement>(this.shadowRoot, 'input-verify-code');
412
+ const btnSubmitCode =
413
+ shadowRoot_getElementById<HTMLButtonElement>(this.shadowRoot, 'btn-submit-code');
414
+ const btnResendCode =
415
+ shadowRoot_getElementById<HTMLButtonElement>(this.shadowRoot, 'btn-resend-code');
416
+
417
+ secVerify.classList.remove('hidden');
418
+ secVerify.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
419
+ this.setStatus("✉️ Verification code sent to your email. Enter 6-digit code below:", "info");
420
+
421
+ const onResendCode = async () => {
422
+ btnResendCode.disabled = true;
423
+ btnResendCode.textContent = "Sending...";
424
+ this.setStatus("Resending verification code to your email...", "info");
425
+ const resResend = await getApiBridge().postVerificationCode({ email, primaryTjpAddr: primaryTjpAddr });
426
+ if (resResend.success) {
427
+ this.setStatus("✉️ New verification code sent to your email!", "success");
428
+ } else {
429
+ this.setStatus(resResend.message || "Failed to resend verification code.", "error");
430
+ }
431
+ btnResendCode.disabled = false;
432
+ btnResendCode.textContent = "Resend Code";
433
+ };
434
+ btnResendCode.addEventListener('click', onResendCode);
435
+
436
+ await new Promise<void>((resolve, reject) => {
437
+ const onSubmitCode = async () => {
438
+ const code = inputVerifyCode.value.trim();
439
+ if (!code || code.length !== 6 || !/^\d{6}$/.test(code)) {
440
+ this.setStatus("Please enter a valid 6-digit numeric verification code (e.g. 482901).", "error");
441
+ return;
442
+ }
443
+
444
+ btnSubmitCode.disabled = true;
445
+ btnSubmitCode.textContent = "Verifying...";
446
+ this.showBusy({
447
+ isBusy: true,
448
+ title: 'Verifying & Activating...',
449
+ msg: 'Great! Juust a moment...\n(Validating code, promoting server domain space, other security stuff...)',
450
+ animationEmoji: '🔐'
451
+ });
452
+
453
+ const resVerify = await getApiBridge().postVerifyCode({ email, primaryTjpAddr: primaryTjpAddr, code });
454
+ if (!resVerify.success) {
455
+ this.showBusy({ isBusy: false });
456
+ this.setStatus(resVerify.message || "Incorrect verification code.", "error");
457
+ btnSubmitCode.disabled = false;
458
+ btnSubmitCode.textContent = "Verify Code";
459
+ return;
460
+ }
461
+
462
+ console.log(`${lc} Code verified & server domain promoted! Syncing delegate...`);
463
+ this.showBusy({
464
+ isBusy: true,
465
+ title: 'Syncing Delegate...',
466
+ msg: 'Posting evolved domain identity and sync delegate to server...',
467
+ animationEmoji: '⚡'
468
+ });
469
+
470
+ btnSubmitCode.removeEventListener('click', onSubmitCode);
471
+ secVerify.classList.add('hidden');
472
+ this.setFormDisabled(false);
473
+
474
+ // Now that server domain space is promoted, post evolved keystone + delegate
475
+ const resEvolve = await getApiBridge().putEvolveKeystone({
476
+ domainAddr: primaryTjpAddr,
477
+ keystoneIbGib: evolvedParentKeystoneIbGib,
478
+ relatedKeystoneIbGibs: [delegateKeystoneIbGib]
479
+ });
480
+ if (!resEvolve.success) {
481
+ console.warn(`${lc} Delegate sync warning after code verification: ${resEvolve.message}`);
482
+ }
483
+
484
+ resolve();
485
+ };
486
+
487
+ btnSubmitCode.addEventListener('click', onSubmitCode);
488
+ });
489
+ } else {
490
+ // Post evolved keystone + delegate keystone immediately (no email or pre-verified)
491
+ this.setStatus("Syncing delegate registration to server...", "info");
492
+ this.showBusy({
493
+ isBusy: true,
494
+ title: 'Syncing Delegate...',
495
+ msg: 'Posting evolved domain identity and sync delegate to server...',
496
+ animationEmoji: '🔄'
497
+ });
498
+ const resEvolve = await getApiBridge().putEvolveKeystone({
499
+ domainAddr: primaryTjpAddr,
500
+ keystoneIbGib: evolvedParentKeystoneIbGib,
501
+ relatedKeystoneIbGibs: [delegateKeystoneIbGib]
502
+ });
503
+ if (!resEvolve.success) {
504
+ const msg = `Delegate registration sync failed: ${resEvolve.message}`;
505
+ console.error(`${lc} ${msg}`);
506
+ this.setStatus(msg, "error");
507
+ this.showBusy({ isBusy: false });
508
+ this.setButtonLoading(false);
509
+ return;
510
+ }
429
511
  }
430
512
 
431
513
  // 5. Register with the keystones special index
@@ -468,11 +550,28 @@ export class KeystoneCreatorComponentInstance
468
550
  }
469
551
 
470
552
  // 7. Success
553
+ const successMsg = "Identity successfully created and activated! Just a sec...";
554
+ this.showBusy({
555
+ isBusy: true,
556
+ title: 'Success!',
557
+ msg: successMsg,
558
+ animationEmoji: '✅'
559
+ });
560
+ await delay(humanEyeDelay); // for human eyes, not needed for functionality, because we'll redirect
561
+ await delay(humanEyeDelay); // for human eyes, not needed for functionality, because we'll redirect
562
+ await delay(humanEyeDelay); // for human eyes, not needed for functionality, because we'll redirect
563
+ await delay(humanEyeDelay); // for human eyes, not needed for functionality, because we'll redirect
471
564
  this.elements!.keystoneAddrEl.textContent = evolvedParentAddr;
472
565
  this.elements!.statusArea.classList.remove('hidden');
473
- this.setStatus("Keystone successfully created and synced!", "success");
474
- await delay(humanEyeDelay); // for human eyes, not needed for functionality
475
- console.log(`✓ Keystone successfully created and synced!`);
566
+ this.setStatus(successMsg, "success");
567
+ console.log(`${lc} ${successMsg} (I: 3396d8261978d7027895b71e27e9ab26)`);
568
+
569
+ // Dispatch UI message to close keystone-creator and show identity-manager
570
+ window.dispatchEvent(new CustomEvent(EVENT_IBGIB_UI_MESSAGE, {
571
+ detail: { action: 'show-identity-manager', addr: evolvedParentAddr },
572
+ bubbles: true,
573
+ composed: true
574
+ }));
476
575
 
477
576
  } catch (error) {
478
577
  const emsg = extractErrorMsg(error);
@@ -487,6 +586,32 @@ export class KeystoneCreatorComponentInstance
487
586
  }
488
587
  }
489
588
 
589
+ private setFormDisabled(disabled: boolean): void {
590
+ const root = this.shadowRoot!;
591
+ const inputIds = [
592
+ 'input-username',
593
+ 'input-description',
594
+ 'input-email',
595
+ 'input-secret',
596
+ 'checkbox-make-active',
597
+ 'btn-generate',
598
+ 'btn-switch-sign-in',
599
+ ];
600
+ for (const id of inputIds) {
601
+ const el = root.getElementById(id) as HTMLInputElement | HTMLButtonElement | null;
602
+ if (el) {
603
+ el.disabled = disabled;
604
+ if (disabled) {
605
+ el.style.opacity = '0.5';
606
+ el.style.pointerEvents = 'none';
607
+ } else {
608
+ el.style.opacity = '1';
609
+ el.style.pointerEvents = 'auto';
610
+ }
611
+ }
612
+ }
613
+ }
614
+
490
615
  protected override async renderUI(): Promise<void> {
491
616
  // No complex rendering needed for this simple creator component yet
492
617
  }
@@ -951,9 +951,9 @@ export class KeystoneDetailsComponentInstance
951
951
  });
952
952
 
953
953
  // Put evolved parent keystone to server via putEvolveKeystone
954
- const parentTjp = getTjpAddr({ ibGib: this.ibGib! }) || getIbGibAddr({ ibGib: this.ibGib! });
954
+ const parentTjpAddr = getTjpAddr({ ibGib: this.ibGib! }) || getIbGibAddr({ ibGib: this.ibGib! });
955
955
  const syncRes = await getApiBridge().putEvolveKeystone({
956
- domainAddr: parentTjp,
956
+ domainAddr: parentTjpAddr,
957
957
  keystoneIbGib: evolvedParent,
958
958
  relatedKeystoneIbGibs: []
959
959
  });
@@ -1389,20 +1389,21 @@ export class KeystoneDetailsComponentInstance
1389
1389
  this.setChangePassphraseStatus("Evolving primary identity keystone...", "info");
1390
1390
 
1391
1391
  const metaspace = await getGlobalMetaspace_waitIfNeeded();
1392
- if (!metaspace) throw new Error("Metaspace not found");
1392
+ if (!metaspace) { throw new Error(`(UNEXPECTED) metaspace falsy? (E: 95e3c8374b0f088f339f5c5a8700f826)`); }
1393
1393
  const space = await metaspace.getLocalUserSpace({ lock: false });
1394
- if (!space) { throw new Error("Local space not found"); }
1394
+ if (!space) { throw new Error(`(UNEXPECTED) couldn't get default local space? (E: 2fc1281c28351fd378a1d7f88eaa0526)`); }
1395
1395
 
1396
1396
  // 2. Rotate parent identity
1397
- debugger; // walk through this...looking for delegate failure
1398
- const { newKeystone: evolvedParent, newDelegates: evolvedDelegates } = await keystoneService.changePassword({
1399
- keystoneIbGib: this.ibGib!,
1400
- newMasterSecret: newPassphrase,
1401
- signingSecret: currentPassphrase,
1402
- signingPoolId: 'manage',
1403
- metaspace,
1404
- space
1405
- });
1397
+ debugger; // walk through this...looking for delegate failure // hmm...I thought we got change password going?
1398
+ const { newKeystone: evolvedParent, newDelegates: evolvedDelegates } =
1399
+ await keystoneService.changePassword({
1400
+ keystoneIbGib: this.ibGib!,
1401
+ newMasterSecret: newPassphrase,
1402
+ signingSecret: currentPassphrase,
1403
+ signingPoolId: 'manage',
1404
+ metaspace,
1405
+ space
1406
+ });
1406
1407
  debugger; // look at evolvedDelegates
1407
1408
 
1408
1409
  this.setChangePassphraseStatus("Resolving and rotating delegate keystones...", "info");
@@ -1458,10 +1459,10 @@ export class KeystoneDetailsComponentInstance
1458
1459
 
1459
1460
  // 4. Sync evolved parent and all evolved delegate keystones atomically
1460
1461
  this.setChangePassphraseStatus("Syncing evolved keystones to server...", "info");
1461
- const parentTjp = getIbGibAddr({ ibGib: this.ibGib! }); // is this.ibGib the tjp always? or is it the latest in the keystone line? Does it matter?
1462
+ const parentTjpAddr = getIbGibAddr({ ibGib: this.ibGib! }); // is this.ibGib the tjp always? or is it the latest in the keystone line? Does it matter?
1462
1463
 
1463
1464
  const syncRes = await getApiBridge().putEvolveKeystone({
1464
- domainAddr: parentTjp,
1465
+ domainAddr: parentTjpAddr,
1465
1466
  keystoneIbGib: evolvedParent,
1466
1467
  relatedKeystoneIbGibs: evolvedDelegates,
1467
1468
  });
@@ -1,7 +0,0 @@
1
- import { SsoServerConfig } from './sso-types.mjs';
2
- /**
3
- * Loads the SSO configuration from environment variables.
4
- * Parses active OAuth2 providers dynamically based on their environment keys.
5
- */
6
- export declare function loadSsoServerConfig(): SsoServerConfig;
7
- //# sourceMappingURL=sso-config-helper.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sso-config-helper.d.mts","sourceRoot":"","sources":["../../../src/identity/sso/sso-config-helper.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA0C,MAAM,iBAAiB,CAAC;AAE1F;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,eAAe,CA6CrD"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Loads the SSO configuration from environment variables.
3
- * Parses active OAuth2 providers dynamically based on their environment keys.
4
- */
5
- export function loadSsoServerConfig() {
6
- const ssoServerKdfSecret = process.env.SSO_SERVER_KDF_SECRET;
7
- const sessionSecret = process.env.SESSION_SECRET;
8
- if (!ssoServerKdfSecret) {
9
- throw new Error(`SSO_SERVER_KDF_SECRET is missing from environment. (E: 840899ab4fdfd23e89cfae1889cfae12)`);
10
- }
11
- if (!sessionSecret) {
12
- throw new Error(`SESSION_SECRET is missing from environment. (E: bfa899ab4fdfd23e89cfae23)`);
13
- }
14
- const providers = {};
15
- // Load Google Provider if configured
16
- if (process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET) {
17
- providers.google = {
18
- providerId: 'google',
19
- clientId: process.env.GOOGLE_CLIENT_ID,
20
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
21
- tokenUrl: 'https://oauth2.googleapis.com/token',
22
- userInfoUrl: 'https://openidconnect.googleapis.com/v1/userinfo',
23
- jwksUrl: 'https://www.googleapis.com/oauth2/v3/certs'
24
- };
25
- }
26
- // Load GitHub Provider if configured
27
- if (process.env.GITHUB_CLIENT_ID && process.env.GITHUB_CLIENT_SECRET) {
28
- providers.github = {
29
- providerId: 'github',
30
- clientId: process.env.GITHUB_CLIENT_ID,
31
- clientSecret: process.env.GITHUB_CLIENT_SECRET,
32
- tokenUrl: 'https://github.com/login/oauth/access_token',
33
- userInfoUrl: 'https://api.github.com/user'
34
- };
35
- }
36
- return {
37
- ssoServerKdfSecret,
38
- sessionSecret,
39
- providers
40
- };
41
- }
42
- //# sourceMappingURL=sso-config-helper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sso-config-helper.mjs","sourceRoot":"","sources":["../../../src/identity/sso/sso-config-helper.mts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IAC/B,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC7D,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAEjD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACX,0FAA0F,CAC7F,CAAC;IACN,CAAC;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACX,2EAA2E,CAC9E,CAAC;IACN,CAAC;IAED,MAAM,SAAS,GAA4D,EAAE,CAAC;IAE9E,qCAAqC;IACrC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;QACnE,SAAS,CAAC,MAAM,GAAG;YACf,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;YACtC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;YAC9C,QAAQ,EAAE,qCAAqC;YAC/C,WAAW,EAAE,kDAAkD;YAC/D,OAAO,EAAE,4CAA4C;SACxD,CAAC;IACN,CAAC;IAED,qCAAqC;IACrC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;QACnE,SAAS,CAAC,MAAM,GAAG;YACf,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;YACtC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;YAC9C,QAAQ,EAAE,6CAA6C;YACvD,WAAW,EAAE,6BAA6B;SAC7C,CAAC;IACN,CAAC;IAED,OAAO;QACH,kBAAkB;QAClB,aAAa;QACb,SAAS;KACZ,CAAC;AACN,CAAC"}
@@ -1,139 +0,0 @@
1
- import { KeystoneChallengePool } from '@ibgib/core-gib/dist/keystone/keystone-types.mjs';
2
- import { MetaspaceService } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
3
- import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
4
- import { SsoServerConfig, SsoProviderId, OAuthUserInfo, SsoProviderServerConfig, SsoProviderClientConfig } from './sso-types.mjs';
5
- /**
6
- * Server-side service for token exchange, JWT validation, and user profile normalization.
7
- */
8
- export declare class SsoCustodianService {
9
- private config;
10
- private lc;
11
- private jwksCache;
12
- private jwksTtlMs;
13
- /**
14
- * @param config The server's global SSO configuration.
15
- * - Visibility: Private (Contains high-entropy secrets like `ssoServerKdfSecret` and `sessionSecret`).
16
- * - Generator: Server (Bootstrapped from node environment variables on server initialization).
17
- */
18
- constructor(config: SsoServerConfig);
19
- /**
20
- * Exchanges an authorization code for an OAuth2 token and retrieves normalized user info.
21
- *
22
- * @param providerId The string identifier of the OAuth provider (e.g. 'google' or 'github').
23
- * - Visibility: Public (Non-sensitive metadata string).
24
- * - Generator: Client (Sent from browser UI selection).
25
- *
26
- * @param code The temporary authorization code returned by the OAuth provider.
27
- * - Visibility: Private (Confidential short-lived bearer credential. Must be kept private).
28
- * - Generator: Provider (Created by provider's OAuth page and sent to client redirect URI).
29
- *
30
- * @param redirectUri The redirect URI registered in the provider portal.
31
- * - Visibility: Public (Configuration URL).
32
- * - Generator: Client/Server (Derived from environmental configuration and sent by client).
33
- */
34
- getOAuthUserInfo(providerId: SsoProviderId, code: string, redirectUri: string): Promise<OAuthUserInfo>;
35
- /**
36
- * Directly validates a Google ID Token (JWT) locally and returns normalized user info.
37
- * Useful for client-side authentication handshakes.
38
- *
39
- * @param idToken The raw base64-encoded signed JSON Web Token (JWT) ID token returned by Google.
40
- * - Visibility: Private (Sensitive bearer credential containing signature and claims. Must be kept private).
41
- * - Generator: Provider (Generated and signed cryptographically by Google authentication servers).
42
- */
43
- verifyAndNormalizeGoogleToken(idToken: string): Promise<OAuthUserInfo>;
44
- /**
45
- * Internal: Exchange authorization code for access token / ID token.
46
- *
47
- * @param providerConfig Server configuration settings for the specific provider.
48
- * - Visibility: Private (Contains provider client secrets. Must stay server-side).
49
- * - Generator: Server (Configured from node environment variables).
50
- *
51
- * @param code The temporary authorization code to exchange.
52
- * - Visibility: Private (Short-lived credential. Must be kept private).
53
- * - Generator: Provider (Via OAuth flow).
54
- *
55
- * @param redirectUri The redirect URI registered for the exchange.
56
- * - Visibility: Public (Configuration URL).
57
- * - Generator: Client/Server (From app configuration).
58
- */
59
- private exchangeCodeForTokens;
60
- /**
61
- * Internal: Fetch GitHub user profile and normalize.
62
- *
63
- * @param providerConfig Server configuration settings for GitHub.
64
- * - Visibility: Private (Contains GitHub client secret).
65
- * - Generator: Server (From environment config).
66
- *
67
- * @param accessToken The active OAuth2 access token to authorize the API call.
68
- * - Visibility: Private (Bearer token. Must be kept private).
69
- * - Generator: Provider (GitHub token endpoint).
70
- */
71
- private fetchAndNormalizeGithubUser;
72
- /**
73
- * Internal: Decodes and cryptographically verifies a JWT signature using JWKS public keys.
74
- *
75
- * @param token The raw base64-encoded JWT token to verify.
76
- * - Visibility: Private (Sensitive token. Must be kept private).
77
- * - Generator: Provider (Google / OIDC server).
78
- *
79
- * @param providerConfig The target provider server settings containing `jwksUrl`.
80
- * - Visibility: Private (Contains secrets).
81
- * - Generator: Server (From environment config).
82
- */
83
- verifyJwt(token: string, providerConfig: SsoProviderServerConfig): Promise<any>;
84
- /**
85
- * Internal: Retrieves JWKS keys from cache or fetches them from the provider's jwksUrl.
86
- *
87
- * @param providerConfig The provider config containing the target `jwksUrl`.
88
- * - Visibility: Private (Contains client secrets).
89
- * - Generator: Server (From environment config).
90
- */
91
- private getJwksKeys;
92
- /**
93
- * Derives a server-delegate master secret deterministically using the server's private KDF secret,
94
- * the providerKey, and the user's public nonce.
95
- *
96
- * @param providerKey The unique key identifying the provider and user sub ID (e.g. `google:123...`).
97
- * - Visibility: Public (Identifier saved on parent's delegate claim, safe for log/ledger storage).
98
- * - Generator: Provider/Server (Derived by mapping provider user sub ID after authentication).
99
- *
100
- * @param userNonce The public, high-entropy nonce generated by the client to salt the KDF derivation.
101
- * - Visibility: Public (Salt value stored on parent's delegate claim, safe for ledger storage).
102
- * - Generator: Client (Generated offline on user's device).
103
- */
104
- deriveServerDelegateSecret(providerKey: string, userNonce: string): Promise<string>;
105
- /**
106
- * Creates a public custodian challenge pool (custodian-manage) derived deterministically
107
- * from the server's private KDF secret, providerKey, and userNonce.
108
- *
109
- * @param providerKey The unique key identifying the provider and user sub ID (e.g. `google:123...`).
110
- * - Visibility: Public (Mapped identifier, safe for ledger).
111
- * - Generator: Provider/Server (Derived after successful token exchange).
112
- *
113
- * @param userNonce The public, high-entropy nonce.
114
- * - Visibility: Public (Derivation salt, safe for ledger).
115
- * - Generator: Client (Generated on user's device).
116
- */
117
- createCustodianChallengePool({ providerId, providerKey, userNonce, keystoneAddr, metaspace, space, }: {
118
- providerId: string;
119
- providerKey: string;
120
- userNonce: string;
121
- keystoneAddr: string;
122
- metaspace: MetaspaceService;
123
- space: IbGibSpaceAny;
124
- }): Promise<KeystoneChallengePool>;
125
- /**
126
- * Maps private server configuration to safe public client configurations.
127
- *
128
- * @param hostUrl The root URL host address of the server (e.g. `https://space-gib.localhost` or `https://ibgib.space`).
129
- * - Visibility: Public (Non-sensitive hostname configuration).
130
- * - Generator: Server (Extracted from the HTTP request context headers/protocol).
131
- */
132
- getSsoClientConfigs(hostUrl: string): SsoProviderClientConfig[];
133
- /**
134
- * Revokes an active OAuth access or refresh token with the provider.
135
- * Keeps token revocation logic DRY and centralized.
136
- */
137
- revokeToken(providerId: SsoProviderId, token: string): Promise<void>;
138
- }
139
- //# sourceMappingURL=sso-custodian-service.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sso-custodian-service.d.mts","sourceRoot":"","sources":["../../../src/identity/sso/sso-custodian-service.mts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,qBAAqB,EAAsB,MAAM,kDAAkD,CAAC;AAK/H,OAAO,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AACrF,OAAO,EACH,eAAe,EACf,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,uBAAuB,EAC1B,MAAM,iBAAiB,CAAC;AAgBzB;;GAEG;AACH,qBAAa,mBAAmB;IAYhB,OAAO,CAAC,MAAM;IAX1B,OAAO,CAAC,EAAE,CAAmC;IAG7C,OAAO,CAAC,SAAS,CAAwE;IACzF,OAAO,CAAC,SAAS,CAAuB;IAExC;;;;OAIG;IACH,YAAoB,MAAM,EAAE,eAAe,EAAI;IAE/C;;;;;;;;;;;;;;OAcG;IACG,gBAAgB,CAAC,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA4B3G;IAED;;;;;;;OAOG;IACG,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA+B3E;IAED;;;;;;;;;;;;;;OAcG;YACW,qBAAqB;IAoCnC;;;;;;;;;;OAUG;YACW,2BAA2B;IAkCzC;;;;;;;;;;OAUG;IACU,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,CAqD3F;IAED;;;;;;OAMG;YACW,WAAW;IA8BzB;;;;;;;;;;;OAWG;IACG,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWxF;IAED;;;;;;;;;;;OAWG;IACG,4BAA4B,CAAC,EAC/B,UAAU,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,EACT,KAAK,GACR,EAAE;QACC,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,gBAAgB,CAAC;QAC5B,KAAK,EAAE,aAAa,CAAC;KACxB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAuEjC;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAwB9D;IAED;;;OAGG;IACG,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwCzE;CACJ"}