@ibgib/web-gib 0.0.59 → 0.0.61

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 (92) hide show
  1. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  2. package/dist/AUTO-GENERATED-version.mjs +1 -1
  3. package/dist/helpers.d.mts.map +1 -1
  4. package/dist/helpers.mjs +1 -0
  5. package/dist/helpers.mjs.map +1 -1
  6. package/dist/identity/device-delegate-helper.d.mts +43 -0
  7. package/dist/identity/device-delegate-helper.d.mts.map +1 -0
  8. package/dist/identity/device-delegate-helper.mjs +106 -0
  9. package/dist/identity/device-delegate-helper.mjs.map +1 -0
  10. package/dist/identity/device-delegate.respec.d.mts +2 -0
  11. package/dist/identity/device-delegate.respec.d.mts.map +1 -0
  12. package/dist/identity/device-delegate.respec.mjs +106 -0
  13. package/dist/identity/device-delegate.respec.mjs.map +1 -0
  14. package/dist/identity/identity-constants.mjs +2 -2
  15. package/dist/identity/identity-constants.mjs.map +1 -1
  16. package/dist/identity/identity-types.d.mts +4 -4
  17. package/dist/identity/identity-types.d.mts.map +1 -1
  18. package/dist/identity/keystone-sync-service.d.mts +18 -0
  19. package/dist/identity/keystone-sync-service.d.mts.map +1 -1
  20. package/dist/identity/keystone-sync-service.mjs +77 -1
  21. package/dist/identity/keystone-sync-service.mjs.map +1 -1
  22. package/dist/index.d.mts +1 -1
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +1 -2
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/storage/storage-helpers.web.d.mts +9 -0
  27. package/dist/storage/storage-helpers.web.d.mts.map +1 -1
  28. package/dist/storage/storage-helpers.web.mjs +42 -0
  29. package/dist/storage/storage-helpers.web.mjs.map +1 -1
  30. package/dist/ui/component/identity/add-device/add-device.css +93 -17
  31. package/dist/ui/component/identity/add-device/add-device.d.mts +24 -7
  32. package/dist/ui/component/identity/add-device/add-device.d.mts.map +1 -1
  33. package/dist/ui/component/identity/add-device/add-device.html +97 -23
  34. package/dist/ui/component/identity/add-device/add-device.mjs +489 -198
  35. package/dist/ui/component/identity/add-device/add-device.mjs.map +1 -1
  36. package/dist/ui/component/identity/keystone-creator/keystone-creator.d.mts.map +1 -1
  37. package/dist/ui/component/identity/keystone-creator/keystone-creator.mjs +48 -61
  38. package/dist/ui/component/identity/keystone-creator/keystone-creator.mjs.map +1 -1
  39. package/dist/ui/component/identity/keystone-details/keystone-details.css +1 -1
  40. package/dist/ui/component/identity/keystone-details/keystone-details.d.mts +11 -8
  41. package/dist/ui/component/identity/keystone-details/keystone-details.d.mts.map +1 -1
  42. package/dist/ui/component/identity/keystone-details/keystone-details.html +29 -20
  43. package/dist/ui/component/identity/keystone-details/keystone-details.mjs +358 -97
  44. package/dist/ui/component/identity/keystone-details/keystone-details.mjs.map +1 -1
  45. package/dist/ui/component/identity/remove-device/remove-device.d.mts +1 -1
  46. package/dist/ui/component/identity/remove-device/remove-device.d.mts.map +1 -1
  47. package/dist/ui/component/identity/remove-device/remove-device.html +3 -3
  48. package/dist/ui/component/identity/remove-device/remove-device.mjs +7 -7
  49. package/dist/ui/component/identity/remove-device/remove-device.mjs.map +1 -1
  50. package/dist/ui/ui-constants.d.mts +1 -0
  51. package/dist/ui/ui-constants.d.mts.map +1 -1
  52. package/dist/ui/ui-constants.mjs +1 -0
  53. package/dist/ui/ui-constants.mjs.map +1 -1
  54. package/dist/ui/ui-types.d.mts +5 -0
  55. package/dist/ui/ui-types.d.mts.map +1 -1
  56. package/dist/util/device-helper.d.mts +30 -0
  57. package/dist/util/device-helper.d.mts.map +1 -0
  58. package/dist/util/device-helper.mjs +90 -0
  59. package/dist/util/device-helper.mjs.map +1 -0
  60. package/dist/util/device-helper.respec.d.mts +2 -0
  61. package/dist/util/device-helper.respec.d.mts.map +1 -0
  62. package/dist/util/device-helper.respec.mjs +83 -0
  63. package/dist/util/device-helper.respec.mjs.map +1 -0
  64. package/package.json +3 -3
  65. package/src/AUTO-GENERATED-version.mts +1 -1
  66. package/src/helpers.mts +1 -0
  67. package/src/identity/custodian-delegate-helper.mts.bak +7 -0
  68. package/src/identity/device-delegate-helper.mts +135 -0
  69. package/src/identity/device-delegate.respec.mts +125 -0
  70. package/src/identity/identity-constants.mts +2 -2
  71. package/src/identity/identity-types.mts +4 -4
  72. package/src/identity/keystone-sync-service.mts +95 -2
  73. package/src/index.mts +1 -2
  74. package/src/storage/storage-helpers.web.mts +47 -0
  75. package/src/ui/component/identity/add-device/add-device.css +93 -17
  76. package/src/ui/component/identity/add-device/add-device.html +97 -23
  77. package/src/ui/component/identity/add-device/add-device.mts +579 -208
  78. package/src/ui/component/identity/keystone-creator/keystone-creator.mts +55 -69
  79. package/src/ui/component/identity/keystone-details/keystone-details.css +1 -1
  80. package/src/ui/component/identity/keystone-details/keystone-details.html +29 -20
  81. package/src/ui/component/identity/keystone-details/keystone-details.mts +374 -106
  82. package/src/ui/component/identity/remove-device/remove-device.html +3 -3
  83. package/src/ui/component/identity/remove-device/remove-device.mts +8 -8
  84. package/src/ui/ui-constants.mts +1 -0
  85. package/src/ui/ui-types.mts +6 -0
  86. package/src/util/device-helper.mts +104 -0
  87. package/src/util/device-helper.respec.mts +90 -0
  88. package/dist/identity/custodian-delegate-helper.d.mts +0 -22
  89. package/dist/identity/custodian-delegate-helper.d.mts.map +0 -1
  90. package/dist/identity/custodian-delegate-helper.mjs +0 -50
  91. package/dist/identity/custodian-delegate-helper.mjs.map +0 -1
  92. package/src/identity/custodian-delegate-helper.mts +0 -61
@@ -11,8 +11,8 @@
11
11
  </div>
12
12
 
13
13
  <div class="input-group">
14
- <label for="input-passphrase">Master Passphrase</label>
15
- <input type="password" id="input-passphrase" placeholder="Enter your master passphrase..." class="secret-input">
14
+ <label for="input-password">Primary Password</label>
15
+ <input type="password" id="input-password" placeholder="Enter your master password..." class="secret-input">
16
16
  </div>
17
17
 
18
18
  <div class="action-row">
@@ -28,4 +28,4 @@
28
28
  <p class="warning">🔒 The selected device delegate has been unlinked from your primary identity.</p>
29
29
  </div>
30
30
  </div>
31
- </div>
31
+ </div>
@@ -58,7 +58,7 @@ interface RemoveDeviceElements extends ElementsBase {
58
58
  containerEl: HTMLDivElement;
59
59
  titleEl: HTMLHeadingElement;
60
60
  selectDelegateEl: HTMLSelectElement;
61
- inputPassphrase: HTMLInputElement;
61
+ inputPassword: HTMLInputElement;
62
62
  btnRemoveDeviceEl: HTMLButtonElement;
63
63
  statusArea: HTMLDivElement;
64
64
  statusText: HTMLParagraphElement;
@@ -89,7 +89,7 @@ export class RemoveDeviceComponentInstance
89
89
  this.elements.containerEl = this.shadowRoot!.getElementById('container') as HTMLDivElement;
90
90
  this.elements.titleEl = this.shadowRoot!.getElementById('title') as HTMLHeadingElement;
91
91
  this.elements.selectDelegateEl = this.shadowRoot!.getElementById('select-delegate') as HTMLSelectElement;
92
- this.elements.inputPassphrase = this.shadowRoot!.getElementById('input-passphrase') as HTMLInputElement;
92
+ this.elements.inputPassword = this.shadowRoot!.getElementById('input-password') as HTMLInputElement;
93
93
  this.elements.btnRemoveDeviceEl = this.shadowRoot!.getElementById('btn-remove-device') as HTMLButtonElement;
94
94
  this.elements.statusArea = this.shadowRoot!.getElementById('status-area') as HTMLDivElement;
95
95
  this.elements.statusText = this.shadowRoot!.getElementById('status-text') as HTMLParagraphElement;
@@ -108,8 +108,8 @@ export class RemoveDeviceComponentInstance
108
108
 
109
109
  private initHandlers() {
110
110
  this.elements!.btnRemoveDeviceEl.addEventListener('click', () => this.handleRemoveDevice());
111
- this.elements!.inputPassphrase.addEventListener('input', () => {
112
- this.elements!.inputPassphrase.classList.remove('invalid');
111
+ this.elements!.inputPassword.addEventListener('input', () => {
112
+ this.elements!.inputPassword.classList.remove('invalid');
113
113
  });
114
114
  }
115
115
 
@@ -187,11 +187,11 @@ export class RemoveDeviceComponentInstance
187
187
  return;
188
188
  }
189
189
 
190
- const masterSecret = this.elements!.inputPassphrase.value.trim();
191
- this.elements!.inputPassphrase.value = masterSecret;
190
+ const masterSecret = this.elements!.inputPassword.value.trim();
191
+ this.elements!.inputPassword.value = masterSecret;
192
192
  if (!masterSecret) {
193
- this.elements!.inputPassphrase.classList.add('invalid');
194
- this.setStatus("Please enter your master passphrase.", "error");
193
+ this.elements!.inputPassword.classList.add('invalid');
194
+ this.setStatus("Please enter your master password.", "error");
195
195
  return;
196
196
  }
197
197
 
@@ -107,6 +107,7 @@ export const EVENT_IBGIB_UI_MESSAGE = 'ibgib-ui-message';
107
107
  export const EVENT_IBGIB_IDENTITY_REQUEST_CHANGE = 'ibgib-identity-request-change';
108
108
  export const EVENT_IBGIB_IDENTITY_CHANGED = 'ibgib-identity-changed';
109
109
  export const EVENT_IBGIB_IDENTITY_UPDATE_AVAILABLE = 'ibgib-identity-update-available';
110
+ export const EVENT_IBGIB_IDENTITY_RENEWAL_REQUIRED = 'ibgib-identity-renewal-required';
110
111
  // #endregion Custom Events
111
112
 
112
113
 
@@ -17,3 +17,9 @@ export interface EventIbGibIdentityUpdateAvailableDetail {
17
17
  localN: number;
18
18
  serverLatestAddr: string;
19
19
  }
20
+
21
+ export interface EventIbGibIdentityRenewalRequiredDetail {
22
+ activePrimaryAddr: string;
23
+ primaryTjpAddr: string;
24
+ reason: 'expired' | 'missing_secret';
25
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @module util/device-helper
3
+ *
4
+ * Pure utility functions for generating clean, friendly, auto-generated device names/tags.
5
+ */
6
+
7
+ export interface DeviceTagOptions {
8
+ userAgent?: string;
9
+ userAgentData?: {
10
+ mobile?: boolean;
11
+ platform?: string;
12
+ brands?: Array<{ brand: string; version: string }>;
13
+ };
14
+ maxTouchPoints?: number;
15
+ screenWidth?: number;
16
+ randomSuffix?: string;
17
+ }
18
+
19
+ /**
20
+ * Generates a friendly, URL-safe, kebab-cased default device tag.
21
+ * (e.g., `chrome-win-a1b2`, `mobile-safari-ios-3c4d`, `tablet-android-e5f6`).
22
+ *
23
+ * Pure function: Uses global browser objects (`navigator`, `window`) only as fallbacks
24
+ * when explicit options are omitted, enabling deterministic unit testing.
25
+ *
26
+ * @param opts Optional mock options for deterministic unit testing.
27
+ */
28
+ export function generateDefaultDeviceTag(opts?: DeviceTagOptions): string {
29
+ const ua = (opts?.userAgent ?? (typeof navigator !== 'undefined' ? navigator.userAgent : '') ?? '').toLowerCase();
30
+ const uaData = opts?.userAgentData ?? (typeof navigator !== 'undefined' ? (navigator as any).userAgentData : undefined);
31
+ const touchPoints = opts?.maxTouchPoints ?? (typeof navigator !== 'undefined' ? navigator.maxTouchPoints : 0) ?? 0;
32
+ const width = opts?.screenWidth ?? (typeof window !== 'undefined' ? window.innerWidth : 1024) ?? 1024;
33
+
34
+ // 1. Detect Form Factor (Mobile, Tablet, Desktop)
35
+ let formFactor = '';
36
+ const isMobileUaData = uaData?.mobile;
37
+ const isMobileUa = /mobile|iphone|ipod|android.*mobile|windows phone/i.test(ua);
38
+ const isTabletUa = /ipad|tablet|(android(?!.*mobile))/i.test(ua) || (touchPoints > 1 && /macintosh/i.test(ua) && width <= 1366);
39
+
40
+ if (isTabletUa) {
41
+ formFactor = 'tablet';
42
+ } else if (isMobileUaData || isMobileUa) {
43
+ formFactor = 'mobile';
44
+ }
45
+
46
+ // 2. Detect OS / Platform
47
+ let platform = '';
48
+ const uaPlatform = (uaData?.platform || '').toLowerCase();
49
+
50
+ if (uaPlatform.includes('win') || ua.includes('windows')) {
51
+ platform = 'win';
52
+ } else if (uaPlatform.includes('ios') || ua.includes('iphone') || ua.includes('ipad') || ua.includes('ipod')) {
53
+ platform = 'ios';
54
+ } else if (uaPlatform.includes('mac') || ua.includes('macintosh') || ua.includes('mac os')) {
55
+ platform = 'mac';
56
+ } else if (uaPlatform.includes('android') || ua.includes('android')) {
57
+ platform = 'android';
58
+ } else if (uaPlatform.includes('linux') || ua.includes('linux')) {
59
+ platform = 'linux';
60
+ }
61
+
62
+ // 3. Detect Browser
63
+ let browser = '';
64
+ if (ua.includes('edg/') || ua.includes('edge/')) {
65
+ browser = 'edge';
66
+ } else if (ua.includes('chrome/') || ua.includes('crios/')) {
67
+ browser = 'chrome';
68
+ } else if (ua.includes('firefox/') || ua.includes('fxios/')) {
69
+ browser = 'firefox';
70
+ } else if (ua.includes('safari/') && !ua.includes('chrome/') && !ua.includes('crios/')) {
71
+ browser = 'safari';
72
+ }
73
+
74
+ // 4. Generate or use provided 4-character random suffix
75
+ let suffix = opts?.randomSuffix;
76
+ if (!suffix) {
77
+ const chars = '0123456789abcdef';
78
+ suffix = '';
79
+ for (let i = 0; i < 4; i++) {
80
+ suffix += chars.charAt(Math.floor(Math.random() * chars.length));
81
+ }
82
+ }
83
+ suffix = suffix.toLowerCase().replace(/[^a-z0-9]/g, '').slice(0, 8);
84
+
85
+ // 5. Assemble Tokens
86
+ const tokens: string[] = [];
87
+ if (formFactor) {
88
+ tokens.push(formFactor);
89
+ }
90
+ if (browser) {
91
+ tokens.push(browser);
92
+ }
93
+ if (platform) {
94
+ tokens.push(platform);
95
+ }
96
+
97
+ if (tokens.length === 0) {
98
+ tokens.push('device');
99
+ }
100
+
101
+ tokens.push(suffix);
102
+
103
+ return tokens.join('-');
104
+ }
@@ -0,0 +1,90 @@
1
+ import {
2
+ respecfully, iReckon, ifWeMight, ifWe // DO NOT REMOVE ifWeMight or ifWe even if no longer used. We constantly change these when focusing tests
3
+ } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
4
+ const maam = `[${import.meta.url}]`, sir = maam;
5
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
6
+ import { generateDefaultDeviceTag } from './device-helper.mjs';
7
+
8
+ await respecfully(sir, 'device-helper', async () => {
9
+
10
+ await ifWe(sir, 'generate clean tag for Desktop Windows Chrome', async () => {
11
+ const lc = `[generate clean tag for Desktop Windows Chrome]`;
12
+ try {
13
+ const tag = generateDefaultDeviceTag({
14
+ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
15
+ userAgentData: { platform: 'Windows', mobile: false },
16
+ randomSuffix: 'a1b2'
17
+ });
18
+
19
+ iReckon(sir, tag).asTo('tag value').isGonnaBe('chrome-win-a1b2');
20
+ } catch (error) {
21
+ console.error(`${lc} ${extractErrorMsg(error)}`);
22
+ throw error;
23
+ }
24
+ });
25
+
26
+ await ifWe(sir, 'generate clean tag for Mobile iOS Safari (iPhone)', async () => {
27
+ const lc = `[generate clean tag for Mobile iOS Safari (iPhone)]`;
28
+ try {
29
+ const tag = generateDefaultDeviceTag({
30
+ userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
31
+ userAgentData: { platform: 'iOS', mobile: true },
32
+ randomSuffix: '3c4d'
33
+ });
34
+
35
+ iReckon(sir, tag).asTo('tag value').isGonnaBe('mobile-safari-ios-3c4d');
36
+ } catch (error) {
37
+ console.error(`${lc} ${extractErrorMsg(error)}`);
38
+ throw error;
39
+ }
40
+ });
41
+
42
+ await ifWe(sir, 'generate clean tag for Android Chrome Phone', async () => {
43
+ const lc = `[generate clean tag for Android Chrome Phone]`;
44
+ try {
45
+ const tag = generateDefaultDeviceTag({
46
+ userAgent: 'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
47
+ userAgentData: { platform: 'Android', mobile: true },
48
+ randomSuffix: '9e8f'
49
+ });
50
+
51
+ iReckon(sir, tag).asTo('tag value').isGonnaBe('mobile-chrome-android-9e8f');
52
+ } catch (error) {
53
+ console.error(`${lc} ${extractErrorMsg(error)}`);
54
+ throw error;
55
+ }
56
+ });
57
+
58
+ await ifWe(sir, 'generate clean tag for iPad / Tablet', async () => {
59
+ const lc = `[generate clean tag for iPad / Tablet]`;
60
+ try {
61
+ const tag = generateDefaultDeviceTag({
62
+ userAgent: 'Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
63
+ maxTouchPoints: 5,
64
+ screenWidth: 1024,
65
+ randomSuffix: '7a8b'
66
+ });
67
+
68
+ iReckon(sir, tag).asTo('tag value').isGonnaBe('tablet-safari-ios-7a8b');
69
+ } catch (error) {
70
+ console.error(`${lc} ${extractErrorMsg(error)}`);
71
+ throw error;
72
+ }
73
+ });
74
+
75
+ await ifWe(sir, 'generate fallback tag with random 4-char suffix when no hints are present', async () => {
76
+ const lc = `[generate fallback tag with random 4-char suffix]`;
77
+ try {
78
+ const tag = generateDefaultDeviceTag({
79
+ userAgent: '',
80
+ randomSuffix: '1234'
81
+ });
82
+
83
+ iReckon(sir, tag).asTo('tag value').isGonnaBe('device-1234');
84
+ } catch (error) {
85
+ console.error(`${lc} ${extractErrorMsg(error)}`);
86
+ throw error;
87
+ }
88
+ });
89
+
90
+ });
@@ -1,22 +0,0 @@
1
- /**
2
- * @module identity/custodian-delegate-helper
3
- *
4
- * Client-side helper functions for deriving and storing local cryptographic delegate secrets
5
- * for full-custodian / passwordless identities.
6
- */
7
- /**
8
- * Retrieves or generates a high-entropy local delegate secret for a passwordless custodian identity.
9
- * Stored locally in `localStorage` keyed by `primaryTjpAddr`.
10
- *
11
- * @param primaryTjpAddr The primary identity keystone TJP address (`ib^gib`).
12
- */
13
- export declare function deriveLocalCustodianDelegateSecret({ primaryTjpAddr, }: {
14
- primaryTjpAddr: string;
15
- }): Promise<string>;
16
- /**
17
- * Removes the stored local delegate secret for a custodian identity.
18
- */
19
- export declare function clearLocalCustodianDelegateSecret({ primaryTjpAddr, }: {
20
- primaryTjpAddr: string;
21
- }): void;
22
- //# sourceMappingURL=custodian-delegate-helper.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custodian-delegate-helper.d.mts","sourceRoot":"","sources":["../../src/identity/custodian-delegate-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;GAKG;AACH,wBAAsB,kCAAkC,CAAC,EACrD,cAAc,GACjB,EAAE;IACC,cAAc,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CA0BlB;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,EAC9C,cAAc,GACjB,EAAE;IACC,cAAc,EAAE,MAAM,CAAC;CAC1B,GAAG,IAAI,CAIP"}
@@ -1,50 +0,0 @@
1
- /**
2
- * @module identity/custodian-delegate-helper
3
- *
4
- * Client-side helper functions for deriving and storing local cryptographic delegate secrets
5
- * for full-custodian / passwordless identities.
6
- */
7
- import { getUUID, hash, HashAlgorithm, extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
8
- const LOCAL_STORAGE_PREFIX = 'ibgib_custodian_delegate_secret_';
9
- /**
10
- * Retrieves or generates a high-entropy local delegate secret for a passwordless custodian identity.
11
- * Stored locally in `localStorage` keyed by `primaryTjpAddr`.
12
- *
13
- * @param primaryTjpAddr The primary identity keystone TJP address (`ib^gib`).
14
- */
15
- export async function deriveLocalCustodianDelegateSecret({ primaryTjpAddr, }) {
16
- const lc = `[${deriveLocalCustodianDelegateSecret.name}]`;
17
- try {
18
- if (!primaryTjpAddr) {
19
- throw new Error('primaryTjpAddr is required to derive local custodian delegate secret (E: a1b2c3d4e5f67890123456789a000101)');
20
- }
21
- const key = `${LOCAL_STORAGE_PREFIX}${primaryTjpAddr}`;
22
- const existingSecret = localStorage.getItem(key);
23
- if (existingSecret) {
24
- return existingSecret;
25
- }
26
- // Generate high-entropy 512-bit SHA hash secret from fresh UUIDs
27
- const rawEntropy = `${await getUUID()}-${await getUUID()}-${await getUUID()}-${Date.now()}`;
28
- const newSecret = await hash({
29
- s: rawEntropy,
30
- algorithm: HashAlgorithm.sha_512
31
- });
32
- localStorage.setItem(key, newSecret);
33
- return newSecret;
34
- }
35
- catch (error) {
36
- console.error(`${lc} ${extractErrorMsg(error)}`);
37
- throw error;
38
- }
39
- }
40
- /**
41
- * Removes the stored local delegate secret for a custodian identity.
42
- */
43
- export function clearLocalCustodianDelegateSecret({ primaryTjpAddr, }) {
44
- if (!primaryTjpAddr) {
45
- return;
46
- }
47
- const key = `${LOCAL_STORAGE_PREFIX}${primaryTjpAddr}`;
48
- localStorage.removeItem(key);
49
- }
50
- //# sourceMappingURL=custodian-delegate-helper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custodian-delegate-helper.mjs","sourceRoot":"","sources":["../../src/identity/custodian-delegate-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAEhH,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CAAC,EACrD,cAAc,GAGjB;IACG,MAAM,EAAE,GAAG,IAAI,kCAAkC,CAAC,IAAI,GAAG,CAAC;IAC1D,IAAI,CAAC;QACD,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,4GAA4G,CAAC,CAAC;QAClI,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,oBAAoB,GAAG,cAAc,EAAE,CAAC;QACvD,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,cAAc,EAAE,CAAC;YACjB,OAAO,cAAc,CAAC;QAC1B,CAAC;QAED,iEAAiE;QACjE,MAAM,UAAU,GAAG,GAAG,MAAM,OAAO,EAAE,IAAI,MAAM,OAAO,EAAE,IAAI,MAAM,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAC5F,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;YACzB,CAAC,EAAE,UAAU;YACb,SAAS,EAAE,aAAa,CAAC,OAAO;SACnC,CAAC,CAAC;QAEH,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAAC,EAC9C,cAAc,GAGjB;IACG,IAAI,CAAC,cAAc,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAChC,MAAM,GAAG,GAAG,GAAG,oBAAoB,GAAG,cAAc,EAAE,CAAC;IACvD,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC"}
@@ -1,61 +0,0 @@
1
- /**
2
- * @module identity/custodian-delegate-helper
3
- *
4
- * Client-side helper functions for deriving and storing local cryptographic delegate secrets
5
- * for full-custodian / passwordless identities.
6
- */
7
-
8
- import { getUUID, hash, HashAlgorithm, extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
9
-
10
- const LOCAL_STORAGE_PREFIX = 'ibgib_custodian_delegate_secret_';
11
-
12
- /**
13
- * Retrieves or generates a high-entropy local delegate secret for a passwordless custodian identity.
14
- * Stored locally in `localStorage` keyed by `primaryTjpAddr`.
15
- *
16
- * @param primaryTjpAddr The primary identity keystone TJP address (`ib^gib`).
17
- */
18
- export async function deriveLocalCustodianDelegateSecret({
19
- primaryTjpAddr,
20
- }: {
21
- primaryTjpAddr: string;
22
- }): Promise<string> {
23
- const lc = `[${deriveLocalCustodianDelegateSecret.name}]`;
24
- try {
25
- if (!primaryTjpAddr) {
26
- throw new Error('primaryTjpAddr is required to derive local custodian delegate secret (E: a1b2c3d4e5f67890123456789a000101)');
27
- }
28
-
29
- const key = `${LOCAL_STORAGE_PREFIX}${primaryTjpAddr}`;
30
- const existingSecret = localStorage.getItem(key);
31
- if (existingSecret) {
32
- return existingSecret;
33
- }
34
-
35
- // Generate high-entropy 512-bit SHA hash secret from fresh UUIDs
36
- const rawEntropy = `${await getUUID()}-${await getUUID()}-${await getUUID()}-${Date.now()}`;
37
- const newSecret = await hash({
38
- s: rawEntropy,
39
- algorithm: HashAlgorithm.sha_512
40
- });
41
-
42
- localStorage.setItem(key, newSecret);
43
- return newSecret;
44
- } catch (error) {
45
- console.error(`${lc} ${extractErrorMsg(error)}`);
46
- throw error;
47
- }
48
- }
49
-
50
- /**
51
- * Removes the stored local delegate secret for a custodian identity.
52
- */
53
- export function clearLocalCustodianDelegateSecret({
54
- primaryTjpAddr,
55
- }: {
56
- primaryTjpAddr: string;
57
- }): void {
58
- if (!primaryTjpAddr) { return; }
59
- const key = `${LOCAL_STORAGE_PREFIX}${primaryTjpAddr}`;
60
- localStorage.removeItem(key);
61
- }