@ibgib/web-gib 0.0.36 → 0.0.43
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 +12 -1
- package/README.md +116 -0
- package/dist/AUTO-GENERATED-version.d.mts +1 -1
- package/dist/AUTO-GENERATED-version.mjs +1 -1
- package/dist/api/commands/ui/ui-index.mjs +2 -2
- package/dist/api/commands/ui/ui-index.mjs.map +1 -1
- package/dist/api/commands/ui/update-css-variables.d.mts +13 -1
- package/dist/api/commands/ui/update-css-variables.d.mts.map +1 -1
- package/dist/api/commands/ui/update-css-variables.mjs +46 -36
- package/dist/api/commands/ui/update-css-variables.mjs.map +1 -1
- package/dist/app-bootstrap/types.d.mts +20 -0
- package/dist/app-bootstrap/types.d.mts.map +1 -1
- package/dist/identity/identity-constants.d.mts +72 -0
- package/dist/identity/identity-constants.d.mts.map +1 -0
- package/dist/identity/identity-constants.mjs +94 -0
- package/dist/identity/identity-constants.mjs.map +1 -0
- package/dist/identity/identity-types.d.mts +214 -0
- package/dist/identity/identity-types.d.mts.map +1 -0
- package/dist/identity/identity-types.mjs +17 -0
- package/dist/identity/identity-types.mjs.map +1 -0
- package/dist/ui/ui-helpers.d.mts +31 -0
- package/dist/ui/ui-helpers.d.mts.map +1 -1
- package/dist/ui/ui-helpers.mjs +50 -1
- package/dist/ui/ui-helpers.mjs.map +1 -1
- package/package.json +5 -26
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/api/commands/ui/ui-index.mts +2 -2
- package/src/api/commands/ui/update-css-variables.mts +53 -35
- package/src/app-bootstrap/types.mts +25 -0
- package/src/identity/identity-constants.mts +107 -0
- package/src/identity/identity-types.mts +250 -0
- package/src/ui/ui-helpers.mts +57 -1
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/SKILL.md +11 -10
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/constants.mts.template +1 -1
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/helpers.web.mts.template +3 -3
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/index.html.template +1 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/index.mts.template +1 -1
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/script.mts.template +17 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/types.mts.template +1 -115
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/witness/app/app-v1.mts.template +1 -1
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/witness/app/helper.mts.template +1 -1
- package/tools/auto-generated-agent-skills/skills/ibgib-create-shell/SKILL.md +8 -2
- package/.vscode/ibgib-snippets.code-snippets +0 -309
- package/.vscode/launch.json +0 -25
- package/.vscode/settings.json +0 -68
- package/.vscode/tasks.json +0 -38
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file identity-constants.mts
|
|
3
|
+
* @description Constants for the ibgib identity layer: pool IDs, verbs, KDF salts,
|
|
4
|
+
* IndexedDB store names, and default pool configuration presets.
|
|
5
|
+
*
|
|
6
|
+
* @see docs/identity/KEYSTONES.md
|
|
7
|
+
* @see docs/identity/TODO.md#02-identity-constants--verbs
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ===========================================================================
|
|
11
|
+
// IDENTITY VERBS
|
|
12
|
+
// These extend the base KeystoneVerb set with identity-tier-specific actions.
|
|
13
|
+
// Used as values in KeystoneClaim.verb and KeystonePoolConfig.allowedVerbs.
|
|
14
|
+
// ===========================================================================
|
|
15
|
+
|
|
16
|
+
/** Evolve META: add a LOCAL keystone to the trusted list. */
|
|
17
|
+
export const IDENTITY_VERB_ADD_DEVICE = 'identity-add-device';
|
|
18
|
+
/** Evolve META: remove a LOCAL keystone from the trusted list. */
|
|
19
|
+
export const IDENTITY_VERB_REMOVE_DEVICE = 'identity-remove-device';
|
|
20
|
+
/** Evolve META: transfer custodianship (custodial → sovereign). */
|
|
21
|
+
export const IDENTITY_VERB_CUSTODY_TRANSFER = 'identity-custody-transfer';
|
|
22
|
+
|
|
23
|
+
/** Evolve LOCAL: register a new APP-LOCAL keystone. */
|
|
24
|
+
export const IDENTITY_VERB_ADD_APP = 'identity-add-app';
|
|
25
|
+
/** Evolve LOCAL: deregister an APP-LOCAL keystone. */
|
|
26
|
+
export const IDENTITY_VERB_REMOVE_APP = 'identity-remove-app';
|
|
27
|
+
|
|
28
|
+
/** Evolve APP-LOCAL: establish a SESSION keystone genesis. */
|
|
29
|
+
export const IDENTITY_VERB_ESTABLISH_SESSION = 'identity-establish-session';
|
|
30
|
+
/** Evolve APP-LOCAL: authorize an app-level action. */
|
|
31
|
+
export const IDENTITY_VERB_AUTHORIZE = 'identity-authorize';
|
|
32
|
+
/**
|
|
33
|
+
* Evolve APP-LOCAL (final frame of old epoch): transition to a new epoch keystone.
|
|
34
|
+
* Uses `consume` replenish strategy — self-contained, no parent evolution needed.
|
|
35
|
+
* @see docs/identity/PARADIGM.md#epoch-rotation-handling-keystone-growth
|
|
36
|
+
*/
|
|
37
|
+
export const IDENTITY_VERB_EPOCH_TRANSITION = 'identity-epoch-transition';
|
|
38
|
+
|
|
39
|
+
// ===========================================================================
|
|
40
|
+
// POOL IDs
|
|
41
|
+
// Conventional pool identifiers for each identity tier's pools.
|
|
42
|
+
// ===========================================================================
|
|
43
|
+
|
|
44
|
+
/** META keystone: structural changes (add/remove device). */
|
|
45
|
+
export const IDENTITY_POOL_ID_ADD_DEVICE = 'identity-add-device';
|
|
46
|
+
/** META keystone: structural changes (remove device). Separate pool allows tighter policy. */
|
|
47
|
+
export const IDENTITY_POOL_ID_REMOVE_DEVICE = 'identity-remove-device';
|
|
48
|
+
/** META keystone: custody transfer (consume strategy — limited uses). */
|
|
49
|
+
export const IDENTITY_POOL_ID_CUSTODY_TRANSFER = 'identity-custody-transfer';
|
|
50
|
+
|
|
51
|
+
/** LOCAL keystone: register/deregister app-local keystones. */
|
|
52
|
+
export const IDENTITY_POOL_ID_ADD_APP = 'identity-add-app';
|
|
53
|
+
/** LOCAL keystone: deregister app-local keystones. */
|
|
54
|
+
export const IDENTITY_POOL_ID_REMOVE_APP = 'identity-remove-app';
|
|
55
|
+
|
|
56
|
+
/** APP-LOCAL keystone: establish session keystones. */
|
|
57
|
+
export const IDENTITY_POOL_ID_APP_SESSION = 'identity-app-session';
|
|
58
|
+
/** APP-LOCAL keystone: general app-level authorization. */
|
|
59
|
+
export const IDENTITY_POOL_ID_APP_AUTHORIZE = 'identity-app-authorize';
|
|
60
|
+
/**
|
|
61
|
+
* APP-LOCAL keystone: epoch transition pool.
|
|
62
|
+
* Strategy: consume — self-authenticates epoch rotation without parent evolution.
|
|
63
|
+
*/
|
|
64
|
+
export const IDENTITY_POOL_ID_APP_EPOCH = 'identity-app-epoch';
|
|
65
|
+
|
|
66
|
+
// ===========================================================================
|
|
67
|
+
// KDF SALTS
|
|
68
|
+
// Used to derive tier-specific MasterSecrets from a root passphrase.
|
|
69
|
+
// Different salt per tier ensures independent secrets even with same passphrase.
|
|
70
|
+
// ===========================================================================
|
|
71
|
+
|
|
72
|
+
export const IDENTITY_KDF_SALT_META = 'ibgib-identity-meta-v1';
|
|
73
|
+
export const IDENTITY_KDF_SALT_LOCAL = 'ibgib-identity-local-v1';
|
|
74
|
+
/**
|
|
75
|
+
* APP-LOCAL salt base. Full derivation:
|
|
76
|
+
* `KDF(MasterSecret_local, IDENTITY_KDF_SALT_APP_LOCAL + appId + deviceSalt)`
|
|
77
|
+
*/
|
|
78
|
+
export const IDENTITY_KDF_SALT_APP_LOCAL = 'ibgib-identity-app-local-v1';
|
|
79
|
+
export const IDENTITY_KDF_SALT_SESSION = 'ibgib-identity-session-v1';
|
|
80
|
+
|
|
81
|
+
// ===========================================================================
|
|
82
|
+
// INDEXEDDB STORE NAMES
|
|
83
|
+
// ===========================================================================
|
|
84
|
+
|
|
85
|
+
/** Stores `LocalIdentityContext` — one record per browser profile. */
|
|
86
|
+
export const IDENTITY_IDB_STORE_LOCAL_CONTEXT = 'identity-local-context';
|
|
87
|
+
/** Stores `AppLocalIdentityContext` — one record per appId per browser profile. */
|
|
88
|
+
export const IDENTITY_IDB_STORE_APP_LOCAL_CONTEXT = 'identity-app-local-context';
|
|
89
|
+
/** Cached META keystone chain — periodically refreshed from identity service. */
|
|
90
|
+
export const IDENTITY_IDB_STORE_META_CACHE = 'identity-meta-cache';
|
|
91
|
+
/** LOCAL keystone frames — genesis through current tip. */
|
|
92
|
+
export const IDENTITY_IDB_STORE_LOCAL_CHAIN = 'identity-local-chain';
|
|
93
|
+
/** APP-LOCAL keystone frames — current epoch genesis through tip. */
|
|
94
|
+
export const IDENTITY_IDB_STORE_APP_LOCAL_CHAIN = 'identity-app-local-chain';
|
|
95
|
+
|
|
96
|
+
// ===========================================================================
|
|
97
|
+
// STALENESS POLICY DEFAULTS (milliseconds)
|
|
98
|
+
// App-level policy: how old can a cached META chain be before re-fetch?
|
|
99
|
+
// @see docs/identity/PARADIGM.md#staleness-policy
|
|
100
|
+
// ===========================================================================
|
|
101
|
+
|
|
102
|
+
/** Default max age for cached META chain for routine verification. */
|
|
103
|
+
export const IDENTITY_META_CACHE_TTL_NORMAL_MS = 60 * 60 * 1000; // 1 hour
|
|
104
|
+
/** For session establishment: always fetch fresh. */
|
|
105
|
+
export const IDENTITY_META_CACHE_TTL_SESSION_MS = 0;
|
|
106
|
+
/** For offline operation: no TTL (accept whatever is cached). */
|
|
107
|
+
export const IDENTITY_META_CACHE_TTL_OFFLINE_MS = Infinity;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file identity-types.mts
|
|
3
|
+
* @description Type definitions for the four-tier ibgib identity hierarchy.
|
|
4
|
+
*
|
|
5
|
+
* ## Tier Overview
|
|
6
|
+
* ```
|
|
7
|
+
* META keystone → universal identity handle (cross-app, cross-device)
|
|
8
|
+
* └─ LOCAL keystone → device/browser-profile-scoped identity
|
|
9
|
+
* └─ APP-LOCAL keystone → app-scoped identity (one per app per browser profile)
|
|
10
|
+
* └─ SESSION keystone → session-scoped (existing sync protocol)
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @see docs/identity/PARADIGM.md
|
|
14
|
+
* @see docs/identity/KEYSTONES.md
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
|
|
18
|
+
import { KeystoneData_V1, KeystoneIbGib_V1 } from "@ibgib/core-gib/dist/keystone/keystone-types.mjs";
|
|
19
|
+
|
|
20
|
+
// ===========================================================================
|
|
21
|
+
// KEYSTONE DATA EXTENSIONS — one per tier
|
|
22
|
+
// ===========================================================================
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Data shape for the META keystone tier.
|
|
26
|
+
*
|
|
27
|
+
* The META keystone is the user's universal identity — stable across all apps,
|
|
28
|
+
* devices, and time. Its `tjpGib` is the user's permanent identity handle.
|
|
29
|
+
*
|
|
30
|
+
* @see docs/identity/KEYSTONES.md#meta-keystone
|
|
31
|
+
* @see docs/identity/PARADIGM.md#meta-keystone
|
|
32
|
+
*/
|
|
33
|
+
export interface MetaKeystoneData extends KeystoneData_V1 {
|
|
34
|
+
/**
|
|
35
|
+
* List of LOCAL keystone `tjpGib` values currently trusted by this identity.
|
|
36
|
+
*
|
|
37
|
+
* This is the **trust register** — an app verifies a user by finding the
|
|
38
|
+
* LOCAL keystone's tjpGib in this list from the current META frame.
|
|
39
|
+
*
|
|
40
|
+
* Mutated by: add-device evolution (append), remove-device evolution (remove).
|
|
41
|
+
*
|
|
42
|
+
* @see docs/identity/PARADIGM.md#cross-app-identity
|
|
43
|
+
*/
|
|
44
|
+
trustedLocalTjpGibs: IbGibAddr[];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* For custodial keystones: the publicly-visible nonce used by the custodian
|
|
48
|
+
* to re-derive `MasterSecret_user = KDF(server_secret, custodialNonce)`.
|
|
49
|
+
*
|
|
50
|
+
* No secrecy requirement — security comes from `server_secret` alone.
|
|
51
|
+
* Stored here so the custodian needs no separate mapping table.
|
|
52
|
+
*
|
|
53
|
+
* Undefined for sovereign (user-held) keystones.
|
|
54
|
+
*
|
|
55
|
+
* @see docs/identity/PARADIGM.md#custodianship--the-oauth2-path
|
|
56
|
+
* @see docs/identity/FLOWS.md#flow-2-first-login--custodial-path-oauth2
|
|
57
|
+
*/
|
|
58
|
+
custodialNonce?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Data shape for the LOCAL keystone tier.
|
|
63
|
+
*
|
|
64
|
+
* Device/browser-profile-scoped identity. Evolves offline. Lives in IndexedDB.
|
|
65
|
+
* One per browser profile per user.
|
|
66
|
+
*
|
|
67
|
+
* @see docs/identity/KEYSTONES.md#local-keystone
|
|
68
|
+
*/
|
|
69
|
+
export interface LocalKeystoneData extends KeystoneData_V1 {
|
|
70
|
+
/**
|
|
71
|
+
* Map of registered APP-LOCAL keystones on this browser profile.
|
|
72
|
+
*
|
|
73
|
+
* Key: `appId`
|
|
74
|
+
* Value: the **first epoch** APP-LOCAL keystone `tjpGib` for that app.
|
|
75
|
+
*
|
|
76
|
+
* Subsequent epochs are authenticated transitively through the APP-LOCAL
|
|
77
|
+
* epoch chain — the LOCAL keystone does NOT need to evolve for epoch rotation.
|
|
78
|
+
*
|
|
79
|
+
* Mutated by: add-app evolution (set), remove-app evolution (delete).
|
|
80
|
+
*
|
|
81
|
+
* @see docs/identity/PARADIGM.md#epoch-rotation-handling-keystone-growth
|
|
82
|
+
*/
|
|
83
|
+
registeredAppLocals: Record<string, IbGibAddr>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Data shape for the APP-LOCAL keystone tier.
|
|
88
|
+
*
|
|
89
|
+
* App-scoped identity for a specific browser profile + app combination.
|
|
90
|
+
* Evolves offline. Lives in IndexedDB (client) and app server (synced).
|
|
91
|
+
* One per app per browser profile per user.
|
|
92
|
+
*
|
|
93
|
+
* @see docs/identity/KEYSTONES.md#app-local-keystone
|
|
94
|
+
*/
|
|
95
|
+
export interface AppLocalKeystoneData extends KeystoneData_V1 {
|
|
96
|
+
/** The app identifier this APP-LOCAL belongs to. */
|
|
97
|
+
appId: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The LOCAL keystone `tjpGib` this APP-LOCAL is derived from.
|
|
101
|
+
* Used by verifiers to link APP-LOCAL trust back to LOCAL → META.
|
|
102
|
+
*/
|
|
103
|
+
localTjpGib: IbGibAddr;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The META keystone `tjpGib` for this identity.
|
|
107
|
+
* Stored for reference/display. The authoritative trust chain is
|
|
108
|
+
* always verified by replaying META → LOCAL → APP-LOCAL.
|
|
109
|
+
*/
|
|
110
|
+
metaTjpGib: IbGibAddr;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* For epoch-chained APP-LOCAL keystones: the ibgib address of the
|
|
114
|
+
* **final frame** of the previous epoch. Establishes the transitive
|
|
115
|
+
* trust chain from the first epoch.
|
|
116
|
+
*
|
|
117
|
+
* Undefined for the first epoch (no prior epoch).
|
|
118
|
+
*
|
|
119
|
+
* @see docs/identity/PARADIGM.md#epoch-rotation-handling-keystone-growth
|
|
120
|
+
*/
|
|
121
|
+
prevEpochFinalFrameAddr?: IbGibAddr;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ===========================================================================
|
|
125
|
+
// BROWSER LOCAL CONTEXT (IndexedDB)
|
|
126
|
+
// ===========================================================================
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The browser-local identity context for a user on this browser profile.
|
|
130
|
+
* Stored in IndexedDB. Reconstructed from keystone chains if lost.
|
|
131
|
+
*
|
|
132
|
+
* @see docs/identity/FLOWS.md#flow-3-return-login--same-browser-profile
|
|
133
|
+
* @see docs/identity/PARTIES.md#party-app-client
|
|
134
|
+
*/
|
|
135
|
+
export interface LocalIdentityContext {
|
|
136
|
+
/** The user's universal identity handle. Used for cross-app identity. */
|
|
137
|
+
metaTjpGib: IbGibAddr;
|
|
138
|
+
|
|
139
|
+
/** URL of the identity service hosting the user's META keystone. */
|
|
140
|
+
identityServiceUrl: string;
|
|
141
|
+
|
|
142
|
+
/** This browser profile's LOCAL keystone `tjpGib`. */
|
|
143
|
+
localTjpGib: IbGibAddr;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Per-app identity context for a specific browser profile + app.
|
|
148
|
+
* Stored in IndexedDB by the app client.
|
|
149
|
+
*
|
|
150
|
+
* @see docs/identity/KEYSTONES.md#app-local-keystone
|
|
151
|
+
*/
|
|
152
|
+
export interface AppLocalIdentityContext {
|
|
153
|
+
/** The user's universal identity handle. */
|
|
154
|
+
metaTjpGib: IbGibAddr;
|
|
155
|
+
|
|
156
|
+
/** This browser profile's LOCAL keystone `tjpGib`. */
|
|
157
|
+
localTjpGib: IbGibAddr;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The **current** (possibly epoch-N) APP-LOCAL keystone `tjpGib`.
|
|
161
|
+
* Updated in-place after each epoch rotation.
|
|
162
|
+
*/
|
|
163
|
+
appLocalTjpGib: IbGibAddr;
|
|
164
|
+
|
|
165
|
+
/** The app identifier. */
|
|
166
|
+
appId: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ===========================================================================
|
|
170
|
+
// IDENTITY SERVICE (Shared Space) INTERFACE
|
|
171
|
+
// ===========================================================================
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The shared identity space — a write-verifying history store.
|
|
175
|
+
*
|
|
176
|
+
* NOT an authority. Verifies chain continuity on writes. Serves raw chain
|
|
177
|
+
* data on reads. Any party can independently verify the chain it returns.
|
|
178
|
+
*
|
|
179
|
+
* Initial deployment: hosted on the app's server. Federated by design.
|
|
180
|
+
*
|
|
181
|
+
* @see docs/identity/PARADIGM.md#the-shared-identity-space
|
|
182
|
+
* @see docs/identity/PARTIES.md#party-identity-service
|
|
183
|
+
*/
|
|
184
|
+
export interface IIdentityService {
|
|
185
|
+
/**
|
|
186
|
+
* POST a genesis frame — accepted unconditionally if internally valid.
|
|
187
|
+
* Genesis is self-legitimizing: Alice's identity IS her genesis frame.
|
|
188
|
+
*
|
|
189
|
+
* @returns the `tjpGib` (ibgib address of the genesis frame)
|
|
190
|
+
* @throws if the frame is internally invalid (malformed structure)
|
|
191
|
+
*/
|
|
192
|
+
postGenesis(frame: KeystoneIbGib_V1): Promise<{ tjpGib: IbGibAddr }>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* POST an evolution frame.
|
|
196
|
+
* Verifies chain continuity: revealed solutions must hash-match prior
|
|
197
|
+
* frame's commitments. Implements CAS: rejects if prior frame is stale.
|
|
198
|
+
*
|
|
199
|
+
* @throws `IdentityServiceStaleTipError` if prior frame is no longer tip
|
|
200
|
+
* @throws `IdentityServiceChainError` if hash pre-images are invalid
|
|
201
|
+
*/
|
|
202
|
+
postEvolution(frame: KeystoneIbGib_V1): Promise<void>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* GET the full keystone chain from genesis to current tip.
|
|
206
|
+
*
|
|
207
|
+
* Does NOT change state. Safe to call without coordination.
|
|
208
|
+
*/
|
|
209
|
+
getChain(tjpGib: IbGibAddr): Promise<KeystoneIbGib_V1[]>;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* GET the current tip frame for a keystone.
|
|
213
|
+
*
|
|
214
|
+
* Does NOT change state.
|
|
215
|
+
*/
|
|
216
|
+
getTip(tjpGib: IbGibAddr): Promise<KeystoneIbGib_V1>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ===========================================================================
|
|
220
|
+
// MASTERSECRET DERIVATION
|
|
221
|
+
// ===========================================================================
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Inputs for deriving a tier-specific MasterSecret from a root passphrase.
|
|
225
|
+
*
|
|
226
|
+
* Each tier uses a different salt to ensure independent MasterSecrets
|
|
227
|
+
* even when the same passphrase is used for all tiers.
|
|
228
|
+
*
|
|
229
|
+
* @see docs/identity/KEYSTONES.md for per-tier salt conventions
|
|
230
|
+
* @see identity-helpers.mts for derivation functions
|
|
231
|
+
*/
|
|
232
|
+
export interface MasterSecretDerivationContext {
|
|
233
|
+
/** The root passphrase (sovereign path) or server secret (custodial path). */
|
|
234
|
+
passphrase: string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Tier-specific salt (e.g., `IDENTITY_KDF_SALT_META`, `IDENTITY_KDF_SALT_LOCAL`).
|
|
238
|
+
* @see identity-constants.mts
|
|
239
|
+
*/
|
|
240
|
+
salt: string;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Additional device-specific entropy for LOCAL and APP-LOCAL tiers.
|
|
244
|
+
* Generated once per browser profile and stored in IndexedDB.
|
|
245
|
+
*/
|
|
246
|
+
deviceSalt?: string;
|
|
247
|
+
|
|
248
|
+
/** For APP-LOCAL tier: the app identifier, mixed into derivation. */
|
|
249
|
+
appId?: string;
|
|
250
|
+
}
|
package/src/ui/ui-helpers.mts
CHANGED
|
@@ -2,8 +2,9 @@ import { delay, extractErrorMsg, } from "@ibgib/helper-gib/dist/helpers/utils-he
|
|
|
2
2
|
|
|
3
3
|
import { GLOBAL_LOG_A_LOT } from "../constants.mjs";
|
|
4
4
|
import { UIThemeInfo } from "./ui-types.mjs";
|
|
5
|
-
import { storageGet } from "../storage/storage-helpers.web.mjs";
|
|
5
|
+
import { storageGet, storagePut } from "../storage/storage-helpers.web.mjs";
|
|
6
6
|
import { UI_THEME_INFO_KEY } from "./ui-constants.mjs";
|
|
7
|
+
import type { getGlobalDbName, getGlobalStoreName } from "../helpers.web.mjs";
|
|
7
8
|
|
|
8
9
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
9
10
|
|
|
@@ -182,6 +183,18 @@ export async function showFullscreenDialog(opts: {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Gets {@link UIThemeInfo} if it exists in the db ({@link dbName}) and store
|
|
188
|
+
* ({@link storeName}) at the given {@link key}.
|
|
189
|
+
*
|
|
190
|
+
* Used with libs\web-gib\src\api\commands\ui\update-css-variables.mts
|
|
191
|
+
*
|
|
192
|
+
* @see {@link putUIInfoInStore}
|
|
193
|
+
* @see {@link UI_THEME_INFO_KEY}
|
|
194
|
+
* @see {@link putUIInfoInStore}
|
|
195
|
+
* @see {@link getGlobalDbName}
|
|
196
|
+
* @see {@link getGlobalStoreName}
|
|
197
|
+
*/
|
|
185
198
|
export async function getExistingUIInfo({
|
|
186
199
|
dbName,
|
|
187
200
|
storeName,
|
|
@@ -220,3 +233,46 @@ export async function getExistingUIInfo({
|
|
|
220
233
|
if (logalot) { console.log(`${lc} complete.`); }
|
|
221
234
|
}
|
|
222
235
|
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Complementing {@link getExistingUIInfo}, this puts {@link newUIInfo} in the
|
|
239
|
+
* db ({@link dbName}) and into the store ({@link storeName}) at the given
|
|
240
|
+
* {@link key}.
|
|
241
|
+
*
|
|
242
|
+
* Used with libs\web-gib\src\api\commands\ui\update-css-variables.mts
|
|
243
|
+
*
|
|
244
|
+
* @see {@link getExistingUIInfo}
|
|
245
|
+
* @see {@link UI_THEME_INFO_KEY}
|
|
246
|
+
* @see {@link putUIInfoInStore}
|
|
247
|
+
* @see {@link getGlobalDbName}
|
|
248
|
+
* @see {@link getGlobalStoreName}
|
|
249
|
+
*/
|
|
250
|
+
export async function putUIInfoInStore({
|
|
251
|
+
dbName,
|
|
252
|
+
storeName,
|
|
253
|
+
key = UI_THEME_INFO_KEY,
|
|
254
|
+
newUIInfo,
|
|
255
|
+
}: {
|
|
256
|
+
dbName: string,
|
|
257
|
+
storeName: string,
|
|
258
|
+
key?: string,
|
|
259
|
+
newUIInfo: UIThemeInfo,
|
|
260
|
+
}): Promise<void> {
|
|
261
|
+
const lc = `[${putUIInfoInStore.name}]`;
|
|
262
|
+
try {
|
|
263
|
+
if (logalot) { console.log(`${lc} starting... (I: 79c9ee707e426fd8c861c4ff4cf16826)`); }
|
|
264
|
+
|
|
265
|
+
await storagePut({
|
|
266
|
+
dbName,
|
|
267
|
+
storeName,
|
|
268
|
+
key,
|
|
269
|
+
value: JSON.stringify(newUIInfo),
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
274
|
+
throw error;
|
|
275
|
+
} finally {
|
|
276
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
277
|
+
}
|
|
278
|
+
};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
name: ibgib-create-app-core
|
|
3
3
|
description: >
|
|
4
4
|
Scaffolds the foundational ibgib bootstrap flow and global state management.
|
|
5
|
-
Generates the
|
|
6
|
-
constants.mts, types.mts, helpers.web.mts, and style.css)
|
|
7
|
-
ibgib app to boot. Supports both greenfield and brownfield projects.
|
|
5
|
+
Generates the 8 foundational files (index.html, index.mts, script.mts,
|
|
6
|
+
bootstrap.mts, constants.mts, types.mts, helpers.web.mts, and style.css)
|
|
7
|
+
required for an ibgib app to boot. Supports both greenfield and brownfield projects.
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# Skill: ibgib-create-app-core
|
|
@@ -62,13 +62,14 @@ Apply token substitutions to templates in `templates/` and write to the target d
|
|
|
62
62
|
|
|
63
63
|
| Template file | Output file |
|
|
64
64
|
|---|---|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
65
|
+
| templates/index.html.template | `index.html` |
|
|
66
|
+
| templates/index.mts.template | `index.mts` |
|
|
67
|
+
| templates/script.mts.template | `script.mts` |
|
|
68
|
+
| templates/bootstrap.mts.template | `bootstrap.mts` |
|
|
69
|
+
| templates/constants.mts.template | `constants.mts` |
|
|
70
|
+
| templates/types.mts.template | `types.mts` |
|
|
71
|
+
| templates/helpers.web.mts.template | `helpers.web.mts` |
|
|
72
|
+
| templates/style.css.template | `style.css` (if missing) |
|
|
72
73
|
|
|
73
74
|
### 3. Replace `genuuid` placeholders
|
|
74
75
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tagTextToIb } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
|
|
2
2
|
import { ZERO_SPACE_ID } from "@ibgib/core-gib/dist/witness/space/space-constants.mjs";
|
|
3
3
|
|
|
4
|
-
import { IbGibAmbientContextConfig } from "
|
|
4
|
+
import { IbGibAmbientContextConfig } from "@ibgib/web-gib/dist/app-bootstrap/types.mjs";
|
|
5
5
|
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// Logging / debug
|
|
@@ -18,11 +18,11 @@ import { delay } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
|
18
18
|
|
|
19
19
|
import { GLOBAL_LOG_A_LOT } from "./constants.mjs";
|
|
20
20
|
import { AUTO_GENERATED_VERSION } from "./AUTO-GENERATED-version.mjs";
|
|
21
|
-
import {
|
|
21
|
+
import { IbGibGlobalThis_{{APP_CLASSNAME_PREFIX}} } from "./types.mjs";
|
|
22
|
+
import {
|
|
22
23
|
IbGibAmbientContextConfig,
|
|
23
|
-
IbGibGlobalThis_{{APP_CLASSNAME_PREFIX}},
|
|
24
24
|
IbGibGlobalThis_Common,
|
|
25
|
-
} from "
|
|
25
|
+
} from "@ibgib/web-gib/dist/app-bootstrap/types.mjs";
|
|
26
26
|
|
|
27
27
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
28
28
|
|
package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/index.html.template
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<meta name="ibgib-app-id" content="{{APP_UUID}}" />
|
|
13
13
|
<title>{{APP_HUMAN_NAME}}</title>
|
|
14
14
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
15
|
+
<script type="module" src="script.mjs" defer></script>
|
|
15
16
|
<script type="module" src="index.mjs" defer></script>
|
|
16
17
|
</head>
|
|
17
18
|
|
package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/index.mts.template
CHANGED
|
@@ -20,7 +20,7 @@ const logalot = GLOBAL_LOG_A_LOT;
|
|
|
20
20
|
* Sequence:
|
|
21
21
|
* 1. Init IndexedDB storage
|
|
22
22
|
* 2. (Optional) trigger shell / router
|
|
23
|
-
* 3. Dynamically import bootstrap.
|
|
23
|
+
* 3. Dynamically import bootstrap.mjs — the heavy ibgib graph loads here
|
|
24
24
|
*/
|
|
25
25
|
async function spinOffStartup(): Promise<void> {
|
|
26
26
|
const lc = `[${spinOffStartup.name}]`;
|
package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/script.mts.template
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* script.mts
|
|
3
|
+
*
|
|
4
|
+
* Early initialization script for the {{APP_HUMAN_NAME}} app.
|
|
5
|
+
*
|
|
6
|
+
* This script is intended to run as soon as the HTML document is parsed,
|
|
7
|
+
* allowing UI Shell logic (like menus and panels) to be interactive
|
|
8
|
+
* immediately, without waiting for the heavier ibgib engine bootstrap.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// import { get{{APP_CLASSNAME_PREFIX}}ShellSvc } from "./ui/shell/{{APP_DIR_NAME}}-shell-service.mjs";
|
|
12
|
+
|
|
13
|
+
// Early init of UI Shell logic so the burger menu responds immediately.
|
|
14
|
+
// Modules execute after the HTML document has been parsed, so elements are ready.
|
|
15
|
+
// get{{APP_CLASSNAME_PREFIX}}ShellSvc();
|
|
16
|
+
|
|
17
|
+
console.log('{{APP_HUMAN_NAME}} early script executing...');
|
package/tools/auto-generated-agent-skills/skills/ibgib-create-app-core/templates/types.mts.template
CHANGED
|
@@ -1,118 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MetaspaceService } from "@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs";
|
|
3
|
-
import { RCLIArgInfo } from "@ibgib/helper-gib/dist/rcli/rcli-types.mjs";
|
|
4
|
-
import { IbGibRel8ns_V1, IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
5
|
-
import { LiveProxyIbGib } from "@ibgib/web-gib/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs";
|
|
6
|
-
import { IbGibGlobalThisInfo } from "@ibgib/web-gib/dist/types.mjs";
|
|
7
|
-
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// App-level ambient context config
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Configuration for the application's global state and storage substrates.
|
|
14
|
-
*/
|
|
15
|
-
export interface IbGibAmbientContextConfig {
|
|
16
|
-
/** Target IndexedDB database name */
|
|
17
|
-
dbName: string;
|
|
18
|
-
/** Primary object store name */
|
|
19
|
-
storeName: string;
|
|
20
|
-
/** Additional stores that need to be initialized (e.g., zero space ID) */
|
|
21
|
-
additionalStoreNames?: string[];
|
|
22
|
-
/** The IndexedDB key under which the AI API key is persisted */
|
|
23
|
-
apiKeyName: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
// Bootstrap request comment (RCLI plumbing)
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
|
|
30
|
-
export interface RequestCommentData_V1 extends CommentData_V1 {
|
|
31
|
-
args: string[];
|
|
32
|
-
interpretedArgInfos: RCLIArgInfo[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface RequestCommentRel8ns_V1 extends IbGibRel8ns_V1 {}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Special Comment that acts as a "request" — the command analog from RCLI.
|
|
39
|
-
*/
|
|
40
|
-
export interface RequestCommentIbGib_V1
|
|
41
|
-
extends IbGib_V1<RequestCommentData_V1, RequestCommentRel8ns_V1> {
|
|
42
|
-
oneOff: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
// Space shim (RCLI pathing compat)
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
|
|
49
|
-
export interface SpaceShimGlobalInfo {
|
|
50
|
-
initialCwd: string;
|
|
51
|
-
cwd: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
// Identity (optional — only populate if the app uses identity)
|
|
56
|
-
// ---------------------------------------------------------------------------
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Framework-level identity interface.
|
|
60
|
-
*
|
|
61
|
-
* ## notes
|
|
62
|
-
*
|
|
63
|
-
* The implementation is entirely consumer-supplied. The framework only defines
|
|
64
|
-
* the shape of the slot so that shells and components can react to auth state
|
|
65
|
-
* without being coupled to a specific identity mechanism.
|
|
66
|
-
*
|
|
67
|
-
* For ibgib apps, the typical implementation will be keystone-based (a
|
|
68
|
-
* Merkle DAG proof of identity), not token-based.
|
|
69
|
-
*/
|
|
70
|
-
export interface IbGibIdentityContext {
|
|
71
|
-
/** Whether identity resolution has completed (does not imply authenticated). */
|
|
72
|
-
resolved: boolean;
|
|
73
|
-
/** Whether the user has a verified identity in this session. */
|
|
74
|
-
authenticated: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* App-specific identity payload.
|
|
77
|
-
* For ibgib: typically includes keystoneAddr, userIbGibAddr, etc.
|
|
78
|
-
*/
|
|
79
|
-
data?: Record<string, any>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// ---------------------------------------------------------------------------
|
|
83
|
-
// GlobalThis state
|
|
84
|
-
// ---------------------------------------------------------------------------
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Base layer: fields shared across ALL ibgib web apps.
|
|
88
|
-
*
|
|
89
|
-
* NOTE: This is a superset of IbGibGlobalThisInfo from @ibgib/web-gib.
|
|
90
|
-
* Intended to be upstreamed eventually.
|
|
91
|
-
*/
|
|
92
|
-
export interface IbGibGlobalThis_Common extends IbGibGlobalThisInfo {
|
|
93
|
-
bootstrapStarted?: boolean;
|
|
94
|
-
bootstrapPromise?: Promise<void>;
|
|
95
|
-
chronologysComponent?: any;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Mid-layer: fields shared by any app that uses the ibgib App witness pattern.
|
|
100
|
-
*
|
|
101
|
-
* NOTE: Intended to be upstreamed into @ibgib/web-gib as IbGibGlobalThis_IbGibApp.
|
|
102
|
-
*/
|
|
103
|
-
export interface IbGibGlobalThis_IbGibApp extends IbGibGlobalThis_Common {
|
|
104
|
-
version?: string;
|
|
105
|
-
spaceShim: { [spaceId: string]: SpaceShimGlobalInfo };
|
|
106
|
-
verbose?: boolean;
|
|
107
|
-
fnDefaultGetAPIKey: () => Promise<string>;
|
|
108
|
-
initialCommentIbGib?: IbGib_V1;
|
|
109
|
-
initialCommentIbGibProxy?: LiveProxyIbGib;
|
|
110
|
-
/**
|
|
111
|
-
* Optional. Populated by the consumer's resolveIdentity() callback.
|
|
112
|
-
* Undefined = identity not configured. Null = unresolved/unauthenticated.
|
|
113
|
-
*/
|
|
114
|
-
identity?: IbGibIdentityContext | null;
|
|
115
|
-
}
|
|
1
|
+
import { IbGibGlobalThis_IbGibApp } from "@ibgib/web-gib/dist/app-bootstrap/types.mjs";
|
|
116
2
|
|
|
117
3
|
// ---------------------------------------------------------------------------
|
|
118
4
|
// App-specific globalThis — add only what this app uniquely needs below
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isRequestComment,
|
|
18
18
|
} from './{{APP_DIR_NAME}}-helper.mjs';
|
|
19
19
|
import { PARAM_INFO_INTERACTIVE, {{APP_CLASSNAME_PREFIX}}Command } from './{{APP_DIR_NAME}}-constants.mjs';
|
|
20
|
-
import { RequestCommentData_V1, RequestCommentIbGib_V1 } from
|
|
20
|
+
import { RequestCommentData_V1, RequestCommentIbGib_V1 } from "@ibgib/web-gib/dist/app-bootstrap/types.mjs";
|
|
21
21
|
|
|
22
22
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
23
23
|
|
|
@@ -7,7 +7,7 @@ import { TransformResult } from '@ibgib/ts-gib/dist/types.mjs';
|
|
|
7
7
|
import { isComment } from '@ibgib/core-gib/dist/common/comment/comment-helper.mjs';
|
|
8
8
|
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
9
9
|
|
|
10
|
-
import { RequestCommentData_V1, RequestCommentIbGib_V1 } from
|
|
10
|
+
import { RequestCommentData_V1, RequestCommentIbGib_V1 } from "@ibgib/web-gib/dist/app-bootstrap/types.mjs";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Validates that no duplicate parameter identifiers exist in the config.
|