2FA back link: the stale import-map notice never replaces the screen
R2-1: the notice was rendered instead of the 2FA screen, and its flag is a text search of the importMap.js on disk — not the map in the build. A false alarm (map generated in the build with the repository's file in the running image, a re-exporting map) hid a working code form and locked everyone out. The notice is now rendered above the screen, the log line says "may be", and the flag goes to ipal-kit's own provider only. R2-2: views are compared against copies, so a factory that reuses its view objects is guarded too; copyViews, changedViewKeys, SAFE_TOTP_VIEW, totpViewImportKey, findImportMapFile and missingImportMapEntries are exported; ipal-doctor warns when the config registers the 2FA package's own view; docs wording and a misplaced comment fixed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
ad51456eaa
commit
b2c1dca5da
@@ -129,6 +129,19 @@ export function wrapTotpViews<V extends ViewLike>(
|
||||
return { dependencies, views: out }
|
||||
}
|
||||
|
||||
/** Keys whose view object is not the one in `before` — what a plugin added or replaced. */
|
||||
/**
|
||||
* Shallow copies of a config's views. Put these into the config BEFORE calling a 2FA factory and
|
||||
* keep them as `before` for `changedViewKeys`: a view the factory registers is then never the
|
||||
* same object as one that was there, also when the factory reuses its view objects between calls.
|
||||
*/
|
||||
export const copyViews = <V>(views: Record<string, V> | undefined): Record<string, V> =>
|
||||
Object.fromEntries(Object.entries(views ?? {}).map(([key, view]) => [key, view && typeof view === 'object' ? { ...view } : view]))
|
||||
|
||||
/**
|
||||
* Keys whose view object is not the one in `before` — what a plugin added or replaced.
|
||||
* `added` for `wrapTotpViews`: `const before = copyViews(views)` → run the factory on a config
|
||||
* holding `before` → `const keys = changedViewKeys(before, viewsAfter)` → `(key) => keys.has(key)`.
|
||||
* A key alone says nothing: the 2FA package replaces a view that already stands under its keys.
|
||||
*/
|
||||
export const changedViewKeys = (before: Record<string, unknown>, after: Record<string, unknown>): Set<string> =>
|
||||
new Set(Object.keys(after).filter((key) => after[key] !== before[key]))
|
||||
|
||||
Reference in New Issue
Block a user