@ibgib/space-gib 0.0.9 → 0.0.13
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.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -0
- package/dist/client/bootstrap.mjs +33 -33
- package/dist/client/bootstrap.mjs.map +3 -3
- package/dist/client/chunk-ROJZUPPE.mjs +19 -0
- package/dist/client/chunk-ROJZUPPE.mjs.map +7 -0
- package/dist/client/chunk-WJHRARK6.mjs +2329 -0
- package/dist/client/chunk-WJHRARK6.mjs.map +7 -0
- package/dist/client/index.mjs +22 -1
- package/dist/client/index.mjs.map +4 -4
- package/dist/client/script.mjs +1 -1
- package/dist/server/server.mjs +19147 -18210
- package/dist/server/server.mjs.map +4 -4
- package/package.json +4 -4
- package/space-gib.localhost-1785337158142.log +75 -0
- package/src/client/AUTO-GENERATED-version.mts +1 -1
- package/src/client/README.md +1 -1
- package/src/client/api/space-gib-api-bridge.mts +8 -224
- package/src/client/ui/shell/space-gib-shell-service.mts +68 -18
- package/src/common/keystone-policies.mts +1 -1
- package/src/server/README.md +3 -2
- package/src/server/server.mts +13 -32
- package/src/server/test.json +0 -0
- package/dist/client/chunk-ACIGPCQW.mjs +0 -2407
- package/dist/client/chunk-ACIGPCQW.mjs.map +0 -7
- package/dist/client/chunk-QRMTJE6M.mjs +0 -42
- package/dist/client/chunk-QRMTJE6M.mjs.map +0 -7
- package/space-gib.localhost-1783713259760.log +0 -45
- package/src/client/components/identity-header/IMPLEMENTATION.md +0 -45
- package/src/client/components/identity-header/identity-header.css +0 -112
- package/src/client/components/identity-header/identity-header.html +0 -11
- package/src/client/components/identity-header/identity-header.mts +0 -439
- package/src/client/components/identity-manager/IMPLEMENTATION.md +0 -100
- package/src/client/components/identity-manager/identity-manager.css +0 -171
- package/src/client/components/identity-manager/identity-manager.html +0 -19
- package/src/client/components/identity-manager/identity-manager.mts +0 -639
- package/src/client/components/keystone-creator/keystone-creator.css +0 -65
- package/src/client/components/keystone-creator/keystone-creator.html +0 -41
- package/src/client/components/keystone-creator/keystone-creator.mts +0 -443
- package/src/client/components/keystone-details/keystone-details.css +0 -611
- package/src/client/components/keystone-details/keystone-details.html +0 -151
- package/src/client/components/keystone-details/keystone-details.mts +0 -1213
- package/src/client/components/keystone-scrubber/SCRUBBER_IMPLEMENTATION.md +0 -33
- package/src/client/components/keystone-scrubber/keystone-scrubber.css +0 -46
- package/src/client/components/keystone-scrubber/keystone-scrubber.html +0 -15
- package/src/client/components/keystone-scrubber/keystone-scrubber.mts +0 -356
- package/src/server/bootstrap-helper.mts +0 -141
- package/src/server/bootstrap-helper.respec.mts +0 -100
- package/src/server/metaspace-nodeindexedspace/metaspace-nodeindexedspace.mts +0 -85
- package/src/server/path-constants.mts +0 -101
- package/src/server/path-helper.mts +0 -101
- package/src/server/path-helper.respec.mts +0 -99
- package/src/server/serve-gib/CHANGELOG.md +0 -29
- package/src/server/serve-gib/README.md +0 -43
- package/src/server/serve-gib/constants.mts +0 -1
- package/src/server/serve-gib/handlers/api/debug/ws-echo.handler.mts +0 -105
- package/src/server/serve-gib/handlers/api/health.handler.mts +0 -23
- package/src/server/serve-gib/handlers/api/health.respec.mts +0 -51
- package/src/server/serve-gib/handlers/api/ibgib/ibgib-handler-types.mts +0 -49
- package/src/server/serve-gib/handlers/api/ibgib/ibgib.handler.mts +0 -176
- package/src/server/serve-gib/handlers/api/keystone/keystone-evolve.handler.mts +0 -150
- package/src/server/serve-gib/handlers/api/keystone/keystone-genesis.handler.mts +0 -146
- package/src/server/serve-gib/handlers/api/keystone/keystone-get.handler.mts +0 -198
- package/src/server/serve-gib/handlers/api/keystone/keystone-get.respec.mts +0 -107
- package/src/server/serve-gib/handlers/api/keystone/keystone-handler-types.mts +0 -29
- package/src/server/serve-gib/handlers/api/keystone/keystone-post.handler.mts +0 -55
- package/src/server/serve-gib/handlers/api/keystone/keystone-post.respec.mts +0 -130
- package/src/server/serve-gib/handlers/api/keystone/sso-config.handler.mts +0 -66
- package/src/server/serve-gib/handlers/api/keystone/sso-link.handler.mts +0 -140
- package/src/server/serve-gib/handlers/api/keystone/sso-login.handler.mts +0 -190
- package/src/server/serve-gib/handlers/error-handler.mts +0 -36
- package/src/server/serve-gib/handlers/handler-base.mts +0 -383
- package/src/server/serve-gib/handlers/static-handler.mts +0 -82
- package/src/server/serve-gib/handlers/ws/sync-upgrade-handler-base.mts +0 -233
- package/src/server/serve-gib/handlers/ws/sync-upgrade.handler.mts +0 -24
- package/src/server/serve-gib/handlers/ws/ws-helper.mts +0 -216
- package/src/server/serve-gib/handlers/ws/ws-types.mts +0 -53
- package/src/server/serve-gib/serve-gib-helpers.mts +0 -32
- package/src/server/serve-gib/serve-gib-v1.mts +0 -172
- package/src/server/serve-gib/serve-gib.respec.mts +0 -90
- package/src/server/serve-gib/types.mts +0 -102
- package/src/server/server-constants.mts +0 -2
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
import styleCss from "../../style.css";
|
|
2
|
-
import thisCss from "./identity-manager.css";
|
|
3
|
-
import thisHtml from "./identity-manager.html";
|
|
4
|
-
|
|
5
|
-
import { delay, extractErrorMsg, pretty } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
6
|
-
import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
|
|
7
|
-
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
8
|
-
import { getIbAndGib, getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
9
|
-
import { ROOT_ADDR } from "@ibgib/ts-gib/dist/V1/constants.mjs";
|
|
10
|
-
import { getGibInfo } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
|
|
11
|
-
import { KeystoneService_V1 } from "@ibgib/core-gib/dist/keystone/keystone-service-v1.mjs";
|
|
12
|
-
import { getTjpAddr } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
|
|
13
|
-
import { mut8Timeline } from "@ibgib/core-gib/dist/timeline/timeline-api.mjs";
|
|
14
|
-
import { MetaspaceService } from "@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs";
|
|
15
|
-
import {
|
|
16
|
-
IbGibDynamicComponentMetaBase,
|
|
17
|
-
IbGibDynamicComponentInstanceBase_ParentOfTabs,
|
|
18
|
-
} from "@ibgib/web-gib/dist/ui/component/ibgib-dynamic-component-bases.mjs";
|
|
19
|
-
import {
|
|
20
|
-
ElementsBase, ChildInfoBase, IbGibDynamicComponentInstance,
|
|
21
|
-
IbGibDynamicComponentInstanceInitOpts,
|
|
22
|
-
} from "@ibgib/web-gib/dist/ui/component/component-types.mjs";
|
|
23
|
-
import { getDeterministicColorInfo, getGlobalMetaspace_waitIfNeeded } from "@ibgib/web-gib/dist/helpers.mjs";
|
|
24
|
-
import { SettingsType } from "@ibgib/web-gib/dist/common/settings/settings-constants.mjs";
|
|
25
|
-
import { Settings_General, Settings_IdentityManager } from "@ibgib/web-gib/dist/common/settings/settings-types.mjs";
|
|
26
|
-
import { getSectionName } from "@ibgib/web-gib/dist/common/settings/settings-helpers.mjs";
|
|
27
|
-
import { getComponentSvc } from "@ibgib/web-gib/dist/ui/component/ibgib-component-service.mjs";
|
|
28
|
-
import { EVENT_IBGIB_IDENTITY_REQUEST_CHANGE, EVENT_IBGIB_IDENTITY_CHANGED } from "@ibgib/web-gib/dist/ui/ui-constants.mjs";
|
|
29
|
-
|
|
30
|
-
import { getComponentCtorArg, getIbGibGlobalThis_SpaceGib } from "../../helpers.web.mjs";
|
|
31
|
-
import { APP_CONFIG } from "../../constants.mjs";
|
|
32
|
-
import { devLog } from "../../dev-tools.mjs";
|
|
33
|
-
import { KEYSTONE_ATOM } from "@ibgib/core-gib/dist/keystone/keystone-constants.mjs";
|
|
34
|
-
|
|
35
|
-
export const IDENTITY_MANAGER_COMPONENT_NAME = 'ibgib-identity-manager';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Metadata for the Identity Manager component.
|
|
39
|
-
*/
|
|
40
|
-
export class IdentityManagerComponentMeta extends IbGibDynamicComponentMetaBase {
|
|
41
|
-
protected lc: string = `[IdentityManagerComponentMeta]`;
|
|
42
|
-
|
|
43
|
-
routeRegExp?: RegExp = new RegExp(`^${IDENTITY_MANAGER_COMPONENT_NAME}$`);
|
|
44
|
-
componentName = IDENTITY_MANAGER_COMPONENT_NAME;
|
|
45
|
-
|
|
46
|
-
constructor() {
|
|
47
|
-
super(getComponentCtorArg());
|
|
48
|
-
if (!customElements.get(this.componentName)) {
|
|
49
|
-
customElements.define(this.componentName, IdentityManagerComponentInstance);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async createInstance({
|
|
54
|
-
path,
|
|
55
|
-
ibGibAddr
|
|
56
|
-
}: {
|
|
57
|
-
path: string;
|
|
58
|
-
ibGibAddr: IbGibAddr;
|
|
59
|
-
}): Promise<IbGibDynamicComponentInstance> {
|
|
60
|
-
const lc = `${this.lc}[${this.createInstance.name}]`;
|
|
61
|
-
const component = document.createElement(this.componentName) as IdentityManagerComponentInstance;
|
|
62
|
-
await component.initialize({
|
|
63
|
-
ibGibAddr,
|
|
64
|
-
meta: this,
|
|
65
|
-
html: thisHtml,
|
|
66
|
-
css: [styleCss, thisCss],
|
|
67
|
-
});
|
|
68
|
-
return component;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface IdentityTabInfo extends ChildInfoBase<IbGibDynamicComponentInstance<any, any>> {
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* References to DOM elements within the component's shadow root.
|
|
77
|
-
*/
|
|
78
|
-
interface IdentityManagerElements extends ElementsBase {
|
|
79
|
-
containerEl: HTMLDivElement;
|
|
80
|
-
titleEl: HTMLHeadingElement;
|
|
81
|
-
tabsListEl: HTMLDivElement;
|
|
82
|
-
btnAddIdentityEl: HTMLButtonElement;
|
|
83
|
-
noIdentityPlaceholderEl: HTMLDivElement;
|
|
84
|
-
btnCreatePlaceholderEl: HTMLButtonElement;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Concrete implementation of the Identity Manager component.
|
|
89
|
-
*/
|
|
90
|
-
export class IdentityManagerComponentInstance
|
|
91
|
-
extends IbGibDynamicComponentInstanceBase_ParentOfTabs<Settings_IdentityManager, IbGib_V1, IdentityManagerElements, IdentityTabInfo>
|
|
92
|
-
implements IbGibDynamicComponentInstance<IbGib_V1, IdentityManagerElements> {
|
|
93
|
-
|
|
94
|
-
protected override lc: string = `[IdentityManagerComponentInstance]`;
|
|
95
|
-
|
|
96
|
-
private globalActiveAddr: string | null = null;
|
|
97
|
-
private _onIdentityChanged: ((e: any) => void) | null = null;
|
|
98
|
-
private keystoneCache: Map<string, { username: string, description: string, isPrimary: boolean, n: number }> = new Map();
|
|
99
|
-
metaspace: MetaspaceService | undefined;
|
|
100
|
-
|
|
101
|
-
protected get settingsType(): SettingsType {
|
|
102
|
-
return SettingsType.identityManager;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
constructor() {
|
|
106
|
-
super();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private async getKeystoneDetails(addr: string): Promise<{ username: string, description: string, isPrimary: boolean, n: number }> {
|
|
110
|
-
const cached = this.keystoneCache.get(addr);
|
|
111
|
-
if (cached) return cached;
|
|
112
|
-
|
|
113
|
-
const metaspace = getIbGibGlobalThis_SpaceGib(APP_CONFIG).metaspace;
|
|
114
|
-
if (!metaspace) return { username: '', description: '', isPrimary: false, n: 0 };
|
|
115
|
-
const space = await metaspace.getLocalUserSpace({ lock: false });
|
|
116
|
-
if (!space) return { username: '', description: '', isPrimary: false, n: 0 };
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const keystoneSvc = new KeystoneService_V1();
|
|
120
|
-
const info = await keystoneSvc.getKeystoneCommonInfo({
|
|
121
|
-
addr,
|
|
122
|
-
metaspace,
|
|
123
|
-
space
|
|
124
|
-
});
|
|
125
|
-
if (info) {
|
|
126
|
-
const details = {
|
|
127
|
-
username: info.name,
|
|
128
|
-
description: info.description,
|
|
129
|
-
isPrimary: info.isPrimary,
|
|
130
|
-
n: info.n
|
|
131
|
-
};
|
|
132
|
-
this.keystoneCache.set(addr, details);
|
|
133
|
-
return details;
|
|
134
|
-
}
|
|
135
|
-
} catch (err) {
|
|
136
|
-
console.warn(`Error getting details for keystone ${addr}: ${extractErrorMsg(err)}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return { username: '', description: '', isPrimary: false, n: 0 };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
override async initialize(opts: IbGibDynamicComponentInstanceInitOpts): Promise<void> {
|
|
143
|
-
if (!this.metaspace) {
|
|
144
|
-
this.metaspace = await getGlobalMetaspace_waitIfNeeded({ delayIntervalMs: 50 });
|
|
145
|
-
}
|
|
146
|
-
opts.ibGibAddr = await this.metaspace.getLatestAddr({ addr: opts.ibGibAddr }) ?? opts.ibGibAddr;
|
|
147
|
-
await super.initialize(opts);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
override async created(): Promise<void> {
|
|
151
|
-
this.elements = {} as IdentityManagerElements;
|
|
152
|
-
|
|
153
|
-
const shadow = this.shadowRoot!;
|
|
154
|
-
this.elements.containerEl = shadow.getElementById('container') as HTMLDivElement;
|
|
155
|
-
this.elements.titleEl = shadow.getElementById('title') as HTMLHeadingElement;
|
|
156
|
-
this.elements.tabsListEl = shadow.getElementById('identity-tabs') as HTMLDivElement;
|
|
157
|
-
this.elements.btnAddIdentityEl = shadow.getElementById('btn-add-identity') as HTMLButtonElement;
|
|
158
|
-
this.elements.noIdentityPlaceholderEl = shadow.getElementById('no-identity-placeholder') as HTMLDivElement;
|
|
159
|
-
this.elements.btnCreatePlaceholderEl = shadow.getElementById('btn-create-placeholder') as HTMLButtonElement;
|
|
160
|
-
|
|
161
|
-
// ElementBase requires contentEl
|
|
162
|
-
this.elements.contentEl = shadow.getElementById('identity-manager-content') as HTMLDivElement;
|
|
163
|
-
|
|
164
|
-
this.initHandlers();
|
|
165
|
-
|
|
166
|
-
// Subscribe to global active identity changes
|
|
167
|
-
this._onIdentityChanged = (e: any) => {
|
|
168
|
-
this.globalActiveAddr = e.detail?.activeIdentityAddr || null;
|
|
169
|
-
this.renderUI();
|
|
170
|
-
};
|
|
171
|
-
window.addEventListener(EVENT_IBGIB_IDENTITY_CHANGED, this._onIdentityChanged);
|
|
172
|
-
|
|
173
|
-
// Listen for requests to view details of a delegate (from child details component)
|
|
174
|
-
this.addEventListener('ibgib-view-keystone-details', async (e: any) => {
|
|
175
|
-
const addr = e.detail?.addr;
|
|
176
|
-
if (addr) {
|
|
177
|
-
await this.activateIbGib({ addr });
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
if (this.ibGibAddr === ROOT_ADDR || !this.ibGib) {
|
|
182
|
-
await this.loadKeystonesIndex();
|
|
183
|
-
} else {
|
|
184
|
-
await this.initSettings();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
await this.renderUI();
|
|
188
|
-
|
|
189
|
-
// Spin off tab restore or defaults to allow createdPromise to resolve first
|
|
190
|
-
this.restoreOrInitTabs();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private async restoreOrInitTabs(): Promise<void> {
|
|
194
|
-
const settings = await this.getSettings<Settings_IdentityManager>({
|
|
195
|
-
settingsType: this.settingsType,
|
|
196
|
-
useCase: 'current',
|
|
197
|
-
});
|
|
198
|
-
if (settings) {
|
|
199
|
-
const validAddrs = (settings.openChildTjpAddrs ?? []).filter(addr => {
|
|
200
|
-
if (!addr || addr === '^' || addr === 'gib') return false;
|
|
201
|
-
const { gib } = getIbAndGib({ ibGibAddr: addr });
|
|
202
|
-
return !!gib && gib !== 'gib' && gib !== '^';
|
|
203
|
-
});
|
|
204
|
-
if (validAddrs.length !== (settings.openChildTjpAddrs ?? []).length) {
|
|
205
|
-
settings.openChildTjpAddrs = validAddrs;
|
|
206
|
-
const metaspace = getIbGibGlobalThis_SpaceGib(APP_CONFIG).metaspace;
|
|
207
|
-
if (metaspace) {
|
|
208
|
-
const sectionName_current = await getSectionName({
|
|
209
|
-
settingsType: this.settingsType,
|
|
210
|
-
useCase: 'current',
|
|
211
|
-
});
|
|
212
|
-
await mut8Timeline({
|
|
213
|
-
timeline: this.settings!.ibGib!,
|
|
214
|
-
metaspace,
|
|
215
|
-
mut8Opts: {
|
|
216
|
-
dataToAddOrPatch: {
|
|
217
|
-
sections: {
|
|
218
|
-
[sectionName_current]: settings,
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (!settings || (settings.openChildTjpAddrs ?? []).length === 0) {
|
|
228
|
-
await this.loadDefaultPrimaryIdentityTabs();
|
|
229
|
-
} else {
|
|
230
|
-
await this.reopenOldTabs();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
override async disconnected(): Promise<void> {
|
|
235
|
-
if (this._onIdentityChanged) {
|
|
236
|
-
window.removeEventListener(EVENT_IBGIB_IDENTITY_CHANGED, this._onIdentityChanged);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
private async loadKeystonesIndex(): Promise<void> {
|
|
241
|
-
const lc = `${this.lc}[loadKeystonesIndex]`;
|
|
242
|
-
try {
|
|
243
|
-
const metaspace = getIbGibGlobalThis_SpaceGib(APP_CONFIG).metaspace;
|
|
244
|
-
if (!metaspace) { return; }
|
|
245
|
-
const space = await metaspace.getLocalUserSpace({ lock: false });
|
|
246
|
-
if (!space) { return; }
|
|
247
|
-
const keystonesIndex = await metaspace.getSpecialIbGib({
|
|
248
|
-
type: "keystones",
|
|
249
|
-
space,
|
|
250
|
-
initialize: true,
|
|
251
|
-
});
|
|
252
|
-
if (keystonesIndex) {
|
|
253
|
-
this.ibGibAddr = getIbGibAddr({ ibGib: keystonesIndex });
|
|
254
|
-
await this.loadIbGib();
|
|
255
|
-
await this.initSettings();
|
|
256
|
-
}
|
|
257
|
-
} catch (error) {
|
|
258
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
private initHandlers() {
|
|
263
|
-
// Buttons
|
|
264
|
-
this.elements!.btnAddIdentityEl.addEventListener('click', () => this.handleAddNewIdentityFlow());
|
|
265
|
-
this.elements!.btnCreatePlaceholderEl.addEventListener('click', () => this.handleAddNewIdentityFlow());
|
|
266
|
-
|
|
267
|
-
// Convert vertical mouse wheel scrolling into horizontal scroll for tabs
|
|
268
|
-
this.elements!.tabsListEl.addEventListener('wheel', (e: WheelEvent) => {
|
|
269
|
-
if (e.deltaY !== 0) {
|
|
270
|
-
e.preventDefault();
|
|
271
|
-
this.elements!.tabsListEl.scrollBy({ left: e.deltaY, behavior: 'smooth' });
|
|
272
|
-
}
|
|
273
|
-
}, { passive: false });
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
protected async handleAddNewIdentityFlow() {
|
|
277
|
-
const lc = `${this.lc}[${this.handleAddNewIdentityFlow.name}]`;
|
|
278
|
-
devLog(`${lc} Triggering identity creation/import flow...`);
|
|
279
|
-
try {
|
|
280
|
-
const componentSvc = await getComponentSvc();
|
|
281
|
-
const creator = await componentSvc.getComponentInstance({
|
|
282
|
-
path: 'ibgib-keystone-creator',
|
|
283
|
-
ibGibAddr: ROOT_ADDR,
|
|
284
|
-
useRegExpPrefilter: true,
|
|
285
|
-
});
|
|
286
|
-
if (creator) {
|
|
287
|
-
// Hide placeholder
|
|
288
|
-
this.elements!.noIdentityPlaceholderEl.classList.add('hidden');
|
|
289
|
-
|
|
290
|
-
// Clear any previous creator/details
|
|
291
|
-
const existing = this.elements!.contentEl.querySelector('ibgib-keystone-creator');
|
|
292
|
-
if (existing) { existing.remove(); }
|
|
293
|
-
|
|
294
|
-
// Clear active child component inside ParentOfTabs to prevent conflict
|
|
295
|
-
const active = this.activeChildInfo;
|
|
296
|
-
if (active) {
|
|
297
|
-
active.childBtnEl.classList.remove('active');
|
|
298
|
-
active.active = false;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
this.elements!.contentEl.innerHTML = '';
|
|
302
|
-
this.elements!.contentEl.appendChild(creator as any);
|
|
303
|
-
devLog(`${lc} Mounted ibgib-keystone-creator successfully.`);
|
|
304
|
-
} else {
|
|
305
|
-
throw new Error("Could not find meta for ibgib-keystone-creator");
|
|
306
|
-
}
|
|
307
|
-
} catch (error) {
|
|
308
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
private async resolveActiveIdentity() {
|
|
313
|
-
const lc = `${this.lc}[resolveActiveIdentity]`;
|
|
314
|
-
try {
|
|
315
|
-
if (!this.settings) {
|
|
316
|
-
this.globalActiveAddr = null;
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const generalSettings = await this.getSettings<Settings_General>({
|
|
320
|
-
settingsType: SettingsType.general,
|
|
321
|
-
useCase: 'current',
|
|
322
|
-
});
|
|
323
|
-
const activeAddrInSettings = (generalSettings as any)?.activeIdentityAddr;
|
|
324
|
-
|
|
325
|
-
const registeredKeystones = this.ibGib?.rel8ns?.keystone ?? [];
|
|
326
|
-
const detailsPromises = registeredKeystones.map(async addr => {
|
|
327
|
-
const details = await this.getKeystoneDetails(addr);
|
|
328
|
-
return { addr, isPrimary: details?.isPrimary ?? false };
|
|
329
|
-
});
|
|
330
|
-
const resolvedDetails = await Promise.all(detailsPromises);
|
|
331
|
-
const primaryKeystones = resolvedDetails
|
|
332
|
-
.filter(item => item.isPrimary)
|
|
333
|
-
.map(item => item.addr);
|
|
334
|
-
|
|
335
|
-
if (activeAddrInSettings && primaryKeystones.includes(activeAddrInSettings)) {
|
|
336
|
-
this.globalActiveAddr = activeAddrInSettings;
|
|
337
|
-
} else if (primaryKeystones.length > 0) {
|
|
338
|
-
this.globalActiveAddr = primaryKeystones[0];
|
|
339
|
-
} else {
|
|
340
|
-
this.globalActiveAddr = null;
|
|
341
|
-
}
|
|
342
|
-
} catch (error) {
|
|
343
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
344
|
-
this.globalActiveAddr = null;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
protected override async renderUI(): Promise<void> {
|
|
349
|
-
const lc = `${this.lc}[${this.renderUI.name}]`;
|
|
350
|
-
if (!this.elements) { return; }
|
|
351
|
-
|
|
352
|
-
await this.resolveActiveIdentity();
|
|
353
|
-
|
|
354
|
-
const keystones = this.ibGib?.rel8ns?.keystone ?? [];
|
|
355
|
-
if (keystones.length === 0 && this.childInfos.length === 0) {
|
|
356
|
-
this.elements.noIdentityPlaceholderEl.classList.remove('hidden');
|
|
357
|
-
this.elements.contentEl.innerHTML = '';
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
this.elements.noIdentityPlaceholderEl.classList.add('hidden');
|
|
362
|
-
|
|
363
|
-
// Render tab highlights
|
|
364
|
-
for (const info of this.childInfos) {
|
|
365
|
-
const btn = info.childBtnEl;
|
|
366
|
-
btn.className = `tab-btn ${info.active ? 'active' : ''} ${info.addr === this.globalActiveAddr ? 'global-active' : ''}`;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
private async loadDefaultPrimaryIdentityTabs() {
|
|
371
|
-
const keystones = (this.ibGib?.rel8ns?.keystone ?? []).filter(addr => {
|
|
372
|
-
if (!addr || addr === '^' || addr === 'gib') return false;
|
|
373
|
-
const { gib } = getIbAndGib({ ibGibAddr: addr });
|
|
374
|
-
return !!gib && gib !== 'gib' && gib !== '^';
|
|
375
|
-
});
|
|
376
|
-
const detailsPromises = keystones.map(async addr => {
|
|
377
|
-
const details = await this.getKeystoneDetails(addr);
|
|
378
|
-
return { addr, isPrimary: details?.isPrimary ?? false };
|
|
379
|
-
});
|
|
380
|
-
const resolvedDetails = await Promise.all(detailsPromises);
|
|
381
|
-
const primaryKeystones = resolvedDetails
|
|
382
|
-
.filter(item => item.isPrimary)
|
|
383
|
-
.map(item => item.addr);
|
|
384
|
-
|
|
385
|
-
if (primaryKeystones.length === 0) {
|
|
386
|
-
this.elements!.noIdentityPlaceholderEl.classList.remove('hidden');
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
this.elements!.noIdentityPlaceholderEl.classList.add('hidden');
|
|
391
|
-
|
|
392
|
-
this.reloadingTabs = true;
|
|
393
|
-
try {
|
|
394
|
-
for (const addr of primaryKeystones) {
|
|
395
|
-
await this.activateIbGib({ addr });
|
|
396
|
-
}
|
|
397
|
-
} finally {
|
|
398
|
-
this.reloadingTabs = false;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// Activate the global active identity (if open), or the first primary one
|
|
402
|
-
const activeToOpen = primaryKeystones.includes(this.globalActiveAddr || '')
|
|
403
|
-
? this.globalActiveAddr!
|
|
404
|
-
: primaryKeystones[0];
|
|
405
|
-
await this.activateIbGib({ addr: activeToOpen });
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
public override async activateIbGib({ addr, ibGib }: { addr?: IbGibAddr; ibGib?: IbGib_V1; }): Promise<void> {
|
|
409
|
-
const lc = `${this.lc}[activateIbGib]`;
|
|
410
|
-
try {
|
|
411
|
-
if (!this.metaspace) { throw new Error(`(UNEXPECTED) this.metaspace falsy? (E: f9e0e9a1427899eba8e469c18d7ae826)`); }
|
|
412
|
-
|
|
413
|
-
await super.activateIbGib({ addr, ibGib });
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (!this.activeChildInfo) { throw new Error(`(UNEXPECTED) activeChildInfo falsy after activateIbGib? (E: d76bd8bc300f3fdc486d50c8b2644826)`); }
|
|
417
|
-
|
|
418
|
-
ibGib ??= this.activeChildInfo.component?.ibGib;
|
|
419
|
-
|
|
420
|
-
if (!ibGib) { throw new Error(`(UNEXPECTED) ibGib falsy? (E: 5b6ec745dd32fd2128635728e3f35e26)`); }
|
|
421
|
-
|
|
422
|
-
if (!ibGib.ib.startsWith(KEYSTONE_ATOM)) {
|
|
423
|
-
throw new Error(`ibGib.ib (${ibGib.ib}) does not start with keystone atom (${KEYSTONE_ATOM}) (E: e0df410381c8e569eb6da996e79b6826)`);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
this.elements!.noIdentityPlaceholderEl.classList.add('hidden');
|
|
427
|
-
|
|
428
|
-
if (!this.reloadingTabs) {
|
|
429
|
-
const settings_current = await this.getSettings<Settings_IdentityManager>({
|
|
430
|
-
settingsType: this.settingsType,
|
|
431
|
-
useCase: 'current',
|
|
432
|
-
});
|
|
433
|
-
if (settings_current) {
|
|
434
|
-
let modified = false;
|
|
435
|
-
const tjpAddr = getTjpAddr({ ibGib: this.activeChildInfo.component?.ibGib || ibGib!, defaultIfNone: 'incomingAddr' });
|
|
436
|
-
if (tjpAddr) {
|
|
437
|
-
if (!settings_current.openChildTjpAddrs.includes(tjpAddr)) {
|
|
438
|
-
settings_current.openChildTjpAddrs.push(tjpAddr);
|
|
439
|
-
modified = true;
|
|
440
|
-
}
|
|
441
|
-
if (settings_current.activeChildTjpAddr !== tjpAddr) {
|
|
442
|
-
settings_current.activeChildTjpAddr = tjpAddr;
|
|
443
|
-
modified = true;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (modified) {
|
|
447
|
-
const metaspace = getIbGibGlobalThis_SpaceGib(APP_CONFIG).metaspace;
|
|
448
|
-
if (metaspace) {
|
|
449
|
-
const sectionName_current = await getSectionName({
|
|
450
|
-
settingsType: this.settingsType,
|
|
451
|
-
useCase: 'current',
|
|
452
|
-
});
|
|
453
|
-
await mut8Timeline({
|
|
454
|
-
timeline: this.settings!.ibGib!,
|
|
455
|
-
metaspace,
|
|
456
|
-
mut8Opts: {
|
|
457
|
-
dataToAddOrPatch: {
|
|
458
|
-
sections: {
|
|
459
|
-
[sectionName_current]: settings_current,
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
await this.renderUI();
|
|
470
|
-
} catch (error) {
|
|
471
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
protected async getLoadedChildInfo({
|
|
476
|
-
addr,
|
|
477
|
-
ibGib,
|
|
478
|
-
}: {
|
|
479
|
-
addr: IbGibAddr,
|
|
480
|
-
ibGib?: IbGib_V1,
|
|
481
|
-
}): Promise<IdentityTabInfo> {
|
|
482
|
-
const lc = `${this.lc}[getLoadedChildInfo]`;
|
|
483
|
-
try {
|
|
484
|
-
if (!addr) { throw new Error(`(UNEXPECTED) addr falsy?`); }
|
|
485
|
-
if (addr === '^' || addr === 'gib' || getIbAndGib({ ibGibAddr: addr }).gib === '^') {
|
|
486
|
-
throw new Error(`Cannot load child info for primitive address ${addr}`);
|
|
487
|
-
}
|
|
488
|
-
const tjpGib = getGibInfo({ ibGibAddr: addr }).tjpGib ?? getIbAndGib({ ibGibAddr: addr }).gib;
|
|
489
|
-
|
|
490
|
-
const fnCreateAndLoadChildComponent = async () => {
|
|
491
|
-
const componentSvc = await getComponentSvc();
|
|
492
|
-
const detailsComponent = await componentSvc.getComponentInstance({
|
|
493
|
-
path: 'ibgib-keystone-scrubber',
|
|
494
|
-
ibGibAddr: addr,
|
|
495
|
-
useRegExpPrefilter: true,
|
|
496
|
-
});
|
|
497
|
-
if (!detailsComponent) {
|
|
498
|
-
throw new Error(`(UNEXPECTED) detailsComponent falsy?`);
|
|
499
|
-
}
|
|
500
|
-
return detailsComponent;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
let tabInfo: IdentityTabInfo;
|
|
504
|
-
|
|
505
|
-
const filtered = this.childInfos.filter(x => {
|
|
506
|
-
const tabGibInfo = getGibInfo({ ibGibAddr: x.addr });
|
|
507
|
-
const tabTjpGib = tabGibInfo.tjpGib ?? getIbAndGib({ ibGibAddr: x.addr }).gib;
|
|
508
|
-
return tabTjpGib === tjpGib;
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
if (filtered.length > 0) {
|
|
512
|
-
if (filtered.length !== 1) { throw new Error(`(UNEXPECTED) filtered.length !== 1?`); }
|
|
513
|
-
tabInfo = filtered[0];
|
|
514
|
-
if (!tabInfo.component) {
|
|
515
|
-
tabInfo.component = await fnCreateAndLoadChildComponent();
|
|
516
|
-
}
|
|
517
|
-
} else {
|
|
518
|
-
const detailsComponent = await fnCreateAndLoadChildComponent();
|
|
519
|
-
let i = 0;
|
|
520
|
-
while (!detailsComponent.ibGib!) {
|
|
521
|
-
await delay(100);
|
|
522
|
-
i++;
|
|
523
|
-
if (i > 50) { // 5 seconds
|
|
524
|
-
debugger; // error loading details component ibgib
|
|
525
|
-
throw new Error(`(UNEXPECTED) detailsComponent.ibGib falsy? didn't load? (E: de50689834124914f770520f1eccb826)`);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
ibGib = detailsComponent.ibGib!;
|
|
529
|
-
addr = getIbGibAddr({ ibGib });
|
|
530
|
-
const tabBtnEl = await this.addChild({ addr, ibGib });
|
|
531
|
-
tabInfo = {
|
|
532
|
-
addr,
|
|
533
|
-
childBtnEl: tabBtnEl,
|
|
534
|
-
component: detailsComponent,
|
|
535
|
-
active: false,
|
|
536
|
-
};
|
|
537
|
-
this.childInfos.push(tabInfo);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
return tabInfo;
|
|
541
|
-
} catch (error) {
|
|
542
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
543
|
-
throw error;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
protected override async addChild({
|
|
548
|
-
addr,
|
|
549
|
-
ibGib,
|
|
550
|
-
}: {
|
|
551
|
-
ibGib: IbGib_V1,
|
|
552
|
-
addr?: IbGibAddr,
|
|
553
|
-
}): Promise<HTMLElement> {
|
|
554
|
-
const lc = `${this.lc}[addChild]`;
|
|
555
|
-
try {
|
|
556
|
-
addr ??= getIbGibAddr({ ibGib });
|
|
557
|
-
if (addr === '^' || addr === 'gib' || getIbAndGib({ ibGibAddr: addr }).gib === '^') {
|
|
558
|
-
throw new Error(`Cannot add child tab for primitive address ${addr}`);
|
|
559
|
-
}
|
|
560
|
-
if (!this.elements) { throw new Error(`(UNEXPECTED) this.elements falsy?`); }
|
|
561
|
-
const { tabsListEl } = this.elements;
|
|
562
|
-
|
|
563
|
-
addr ??= getIbGibAddr({ ibGib });
|
|
564
|
-
|
|
565
|
-
const childBtnEl = document.createElement('button');
|
|
566
|
-
childBtnEl.className = 'tab-btn';
|
|
567
|
-
childBtnEl.id = `identity-tab-button-${addr}`;
|
|
568
|
-
|
|
569
|
-
await this.updateTabTitleAndText({ span: childBtnEl, ibGib, addr });
|
|
570
|
-
|
|
571
|
-
const details = await this.getKeystoneDetails(addr);
|
|
572
|
-
if (!details.isPrimary) {
|
|
573
|
-
const closeBtnEl = document.createElement('span');
|
|
574
|
-
closeBtnEl.className = 'close-tab-button';
|
|
575
|
-
closeBtnEl.textContent = ' ×';
|
|
576
|
-
closeBtnEl.style.marginLeft = '0.5rem';
|
|
577
|
-
closeBtnEl.style.cursor = 'pointer';
|
|
578
|
-
childBtnEl.appendChild(closeBtnEl);
|
|
579
|
-
closeBtnEl.addEventListener('click', async (event) => {
|
|
580
|
-
event.stopPropagation(); // Prevent activating the tab
|
|
581
|
-
await this.closeTab({ ibGib });
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
tabsListEl.appendChild(childBtnEl);
|
|
586
|
-
childBtnEl.addEventListener('click', async (event) => {
|
|
587
|
-
await this.activateIbGib({ addr });
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
return childBtnEl;
|
|
591
|
-
} catch (error) {
|
|
592
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
593
|
-
throw error;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
private async updateTabTitleAndText({
|
|
598
|
-
span,
|
|
599
|
-
ibGib,
|
|
600
|
-
addr,
|
|
601
|
-
}: {
|
|
602
|
-
span: HTMLElement,
|
|
603
|
-
ibGib: IbGib_V1,
|
|
604
|
-
addr: string,
|
|
605
|
-
}): Promise<void> {
|
|
606
|
-
const details = await this.getKeystoneDetails(addr);
|
|
607
|
-
let name = details.username;
|
|
608
|
-
const maxTabLen = 16;
|
|
609
|
-
if (name) {
|
|
610
|
-
if (name.length > maxTabLen) {
|
|
611
|
-
name = name.substring(0, maxTabLen - 3) + '...';
|
|
612
|
-
}
|
|
613
|
-
span.textContent = name;
|
|
614
|
-
} else {
|
|
615
|
-
let displayTab = addr;
|
|
616
|
-
if (displayTab.length > 12) {
|
|
617
|
-
displayTab = displayTab.substring(0, 5) + '...' + displayTab.substring(displayTab.length - 4);
|
|
618
|
-
}
|
|
619
|
-
span.textContent = displayTab;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
const tooltipParts: string[] = [];
|
|
623
|
-
if (details.username) {
|
|
624
|
-
tooltipParts.push(`User: ${details.username}`);
|
|
625
|
-
}
|
|
626
|
-
if (details.description) {
|
|
627
|
-
const desc = details.description.length > 100
|
|
628
|
-
? details.description.substring(0, 97) + '...'
|
|
629
|
-
: details.description;
|
|
630
|
-
tooltipParts.push(`Desc: ${desc}`);
|
|
631
|
-
}
|
|
632
|
-
tooltipParts.push(`Addr: ${addr}`);
|
|
633
|
-
span.title = tooltipParts.join('\n');
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
protected async removeTabBtn({ tabInfo }: { tabInfo: IdentityTabInfo }): Promise<void> {
|
|
637
|
-
this.elements!.tabsListEl.removeChild(tabInfo.childBtnEl);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: block;
|
|
3
|
-
width: 100%;
|
|
4
|
-
max-width: 600px;
|
|
5
|
-
margin: 2rem auto;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
h2 {
|
|
9
|
-
margin-top: 0;
|
|
10
|
-
font-size: 1.5rem;
|
|
11
|
-
color: var(--clr-accent);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.content {
|
|
15
|
-
margin-top: 1.5rem;
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
gap: 1.5rem;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.input-group {
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
gap: 0.5rem;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.input-group label {
|
|
28
|
-
font-size: 0.85rem;
|
|
29
|
-
color: var(--clr-text-secondary);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.status-area {
|
|
33
|
-
margin-top: 0.5rem;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.status-area.hidden {
|
|
37
|
-
display: none;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.result-area {
|
|
41
|
-
padding: 1.5rem;
|
|
42
|
-
background: rgba(255, 255, 255, 0.03);
|
|
43
|
-
border: 1px solid var(--clr-border);
|
|
44
|
-
border-radius: var(--radius-md);
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
gap: 0.75rem;
|
|
48
|
-
transition: opacity var(--t-med);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.result-area.collapsed {
|
|
52
|
-
display: none;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.address-label {
|
|
56
|
-
font-size: 0.8rem;
|
|
57
|
-
color: var(--clr-text-secondary);
|
|
58
|
-
margin: 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.warning {
|
|
62
|
-
font-size: 0.8rem;
|
|
63
|
-
color: var(--clr-warn);
|
|
64
|
-
margin: 0.5rem 0 0;
|
|
65
|
-
}
|