mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
The notice after Google sign-in, an emailed code or a reset confirms an address names the step, only the kinds of access that went (shared/accessCleared.ts), and one next step. Nothing named, no notice. The setup wizard's completed-or-skipped flag is kept per account (finance_onboarding:account-<id>, or finance_onboarding:local in local-first), so a second account on one browser is offered setup too. The old browser-wide flag moves to local-first only; for a server account, its profile's settings and the pristine-profile check decide. Specs, unit tests and the marketing shots mark the wizard decided per owner with onboardingDecided (frontend/tests/onboarding-decided.ts).
27 lines
1.3 KiB
TypeScript
27 lines
1.3 KiB
TypeScript
/**
|
|
* The kinds of access that confirming an address can remove and the person would notice, under the
|
|
* names the Worker reports them by and the app reads them back with.
|
|
*
|
|
* The Worker names them on three answers (worker: clearedWorthSaying): the Google sign-in redirect,
|
|
* as `?cleared=password,passkeys`, and the emailed-code sign-in and the password reset, as
|
|
* `cleared: ['password', 'passkeys']`. The app turns them into its notice
|
|
* (frontend: core/accessCleared.ts). Both runtimes import this file, so the names stay one list.
|
|
*/
|
|
|
|
/** In the order a notice names them. */
|
|
export const CLEARED_KINDS = ['password', 'passkeys', 'two-factor', 'api-tokens'] as const;
|
|
|
|
export type ClearedKind = (typeof CLEARED_KINDS)[number];
|
|
|
|
/**
|
|
* The kinds `raw` names, in CLEARED_KINDS order and each once: a list, or a comma-separated query
|
|
* value, with any space around a name ignored. Anything that is not one of the names is left out,
|
|
* so a notice never names what nothing reported.
|
|
*/
|
|
export function readClearedKinds(raw: unknown): ClearedKind[] {
|
|
const listed =
|
|
typeof raw === 'string' ? raw.split(',') : Array.isArray(raw) ? (raw as unknown[]) : [];
|
|
const named = listed.map((name) => (typeof name === 'string' ? name.trim() : name));
|
|
return CLEARED_KINDS.filter((kind) => named.includes(kind));
|
|
}
|