@wow-two-beta/fe 0.0.40 → 0.0.42

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.
@@ -5,6 +5,11 @@ export interface BffPerson {
5
5
  /** The stable subject id — the identity key, never the display name. */
6
6
  readonly sub: string;
7
7
  readonly name: string | null;
8
+ /**
9
+ * The link to the person's picture (the ID token's `picture`); `null` without one or without the `profile` scope.
10
+ * Bind it to `AccountMenu`'s `avatarSrc` as is — the avatar shows initials while it is `null` or fails to load.
11
+ */
12
+ readonly picture: string | null;
8
13
  readonly email: string | null;
9
14
  readonly phoneNumber: string | null;
10
15
  }
@@ -32,15 +37,15 @@ export interface BffSessionSnapshot {
32
37
  /** The token unsafe requests echo; `null` while signed out. */
33
38
  readonly csrfToken: string | null;
34
39
  }
35
- /** Defines one decoded `POST {prefix}/logout` response. */
36
- export interface BffLogout {
40
+ /** Defines one decoded `POST {prefix}/sign-out` response. */
41
+ export interface BffSignOut {
37
42
  /** Where the page navigates to end the identity provider's session. */
38
43
  readonly endSessionUrl: string;
39
44
  }
40
45
  /** Decodes the session response; a payload that breaks the contract is a `protocol` failure. */
41
46
  export declare function decodeBffSession(value: unknown): Result<BffSessionSnapshot, ApiFailure>;
42
47
  /** Decodes the logout response; an end-session URL the page may not navigate to is a `protocol` failure. */
43
- export declare function decodeBffLogout(value: unknown): Result<BffLogout, ApiFailure>;
48
+ export declare function decodeBffSignOut(value: unknown): Result<BffSignOut, ApiFailure>;
44
49
  /** Extends a {@link BffUser} with the checks a screen and a bridge need. */
45
50
  export declare const BffSessionExtensions: {
46
51
  /** Whether the user holds `permission`; `false` while signed out. */
@@ -3,6 +3,7 @@ import { ResultExtensions } from "../foundation/results/ResultExtensions.js";
3
3
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4
4
  const isText = (value) => typeof value === "string" && value !== "";
5
5
  const optionalText = (value) => typeof value === "string" ? value : null;
6
+ const optionalLink = (value) => typeof value === "string" && value.trim() !== "" ? value.trim() : null;
6
7
  const protocol = () => ApiFailureFactory.create("protocol");
7
8
  function decodeBffSession(value) {
8
9
  if (!isRecord(value) || typeof value["isAuthenticated"] !== "boolean") return ResultExtensions.fail(protocol());
@@ -24,6 +25,7 @@ function decodeBffSession(value) {
24
25
  person: {
25
26
  sub: person["sub"],
26
27
  name: optionalText(person["name"]),
28
+ picture: optionalLink(person["picture"]),
27
29
  email: optionalText(person["email"]),
28
30
  phoneNumber: optionalText(person["phoneNumber"])
29
31
  },
@@ -42,7 +44,7 @@ function isNavigable(url) {
42
44
  return false;
43
45
  }
44
46
  }
45
- function decodeBffLogout(value) {
47
+ function decodeBffSignOut(value) {
46
48
  if (!isRecord(value) || !isText(value["endSessionUrl"]) || !isNavigable(value["endSessionUrl"])) {
47
49
  return ResultExtensions.fail(protocol());
48
50
  }
@@ -67,7 +69,7 @@ const BffSessionExtensions = {
67
69
  };
68
70
  export {
69
71
  BffSessionExtensions,
70
- decodeBffLogout,
71
- decodeBffSession
72
+ decodeBffSession,
73
+ decodeBffSignOut
72
74
  };
73
75
  //# sourceMappingURL=BffSession.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BffSession.js","sources":["../../src/auth/BffSession.ts"],"sourcesContent":["import { ApiFailureFactory, type ApiFailure } from '../foundation/http';\nimport { ResultExtensions, type Result } from '../foundation/results';\n\n/** Defines the signed-in person a BFF session names. */\nexport interface BffPerson {\n /** The stable subject id — the identity key, never the display name. */\n readonly sub: string;\n readonly name: string | null;\n readonly email: string | null;\n readonly phoneNumber: string | null;\n}\n\n/** Defines the organization the session acts in, and the person's role there. */\nexport interface BffOrganization {\n readonly id: string;\n readonly role: string;\n}\n\n/**\n * Defines the user a BFF session resolves to. The CSRF token is deliberately absent: it never renders, so the\n * strategy keeps it and the HTTP layer echoes it.\n */\nexport interface BffUser {\n readonly person: BffPerson;\n /** `null` for a person acting in no organization. */\n readonly organization: BffOrganization | null;\n readonly permissions: readonly string[];\n /** When the session ends (ISO 8601); `null` when the server sent none that parses. */\n readonly expiresAt: string | null;\n}\n\n/** Defines one decoded `GET {prefix}/session` response. */\nexport interface BffSessionSnapshot {\n /** `null` while signed out. */\n readonly user: BffUser | null;\n /** The token unsafe requests echo; `null` while signed out. */\n readonly csrfToken: string | null;\n}\n\n/** Defines one decoded `POST {prefix}/logout` response. */\nexport interface BffLogout {\n /** Where the page navigates to end the identity provider's session. */\n readonly endSessionUrl: string;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\nconst isText = (value: unknown): value is string => typeof value === 'string' && value !== '';\n/** Reads an optional text field; anything but text reads as absent. */\nconst optionalText = (value: unknown): string | null => (typeof value === 'string' ? value : null);\nconst protocol = (): ApiFailure => ApiFailureFactory.create('protocol');\n\n/** Decodes the session response; a payload that breaks the contract is a `protocol` failure. */\nexport function decodeBffSession(value: unknown): Result<BffSessionSnapshot, ApiFailure> {\n if (!isRecord(value) || typeof value['isAuthenticated'] !== 'boolean') return ResultExtensions.fail(protocol());\n if (!value['isAuthenticated']) return ResultExtensions.ok({ user: null, csrfToken: null });\n\n const person = value['person'];\n const organization = value['organization'];\n const permissions = value['permissions'] ?? [];\n const expiresAt = value['expiresAt'];\n if (!isRecord(person) || !isText(person['sub']) || !isText(value['csrfToken'])) {\n return ResultExtensions.fail(protocol());\n }\n if (organization != null && (!isRecord(organization) || !isText(organization['id']))) {\n return ResultExtensions.fail(protocol());\n }\n if (!Array.isArray(permissions) || !permissions.every(isText)) return ResultExtensions.fail(protocol());\n\n return ResultExtensions.ok({\n csrfToken: value['csrfToken'],\n user: {\n person: {\n sub: person['sub'],\n name: optionalText(person['name']),\n email: optionalText(person['email']),\n phoneNumber: optionalText(person['phoneNumber']),\n },\n organization: isRecord(organization)\n ? { id: organization['id'] as string, role: optionalText(organization['role']) ?? '' }\n : null,\n permissions: Object.freeze([...(permissions as string[])]),\n expiresAt: typeof expiresAt === 'string' && Number.isFinite(Date.parse(expiresAt)) ? expiresAt : null,\n },\n });\n}\n\n/** Whether a page may navigate to `url` to end the provider session: a local path, or an absolute http(s) URL. */\nfunction isNavigable(url: string): boolean {\n if (url.startsWith('/')) return !url.startsWith('//') && !url.includes('\\\\');\n try {\n const { protocol: scheme } = new URL(url);\n return scheme === 'https:' || scheme === 'http:';\n } catch {\n return false;\n }\n}\n\n/** Decodes the logout response; an end-session URL the page may not navigate to is a `protocol` failure. */\nexport function decodeBffLogout(value: unknown): Result<BffLogout, ApiFailure> {\n if (!isRecord(value) || !isText(value['endSessionUrl']) || !isNavigable(value['endSessionUrl'])) {\n return ResultExtensions.fail(protocol());\n }\n return ResultExtensions.ok({ endSessionUrl: value['endSessionUrl'] });\n}\n\n/** Extends a {@link BffUser} with the checks a screen and a bridge need. */\nexport const BffSessionExtensions = {\n /** Whether the user holds `permission`; `false` while signed out. */\n hasPermission(user: BffUser | null | undefined, permission: string): boolean {\n return user?.permissions.includes(permission) ?? false;\n },\n\n /**\n * The stable user-and-organization key: pass it as `createAuthBridge({ getIdentity })` so a refreshed session\n * keeps its caches and a person or organization switch drops them.\n */\n identity(user: BffUser): string {\n return `${user.person.sub}\\u0000${user.organization?.id ?? ''}`;\n },\n\n /** The session end as epoch milliseconds; `null` when the server sent none that parses. */\n expiresAtMs(user: BffUser): number | null {\n return user.expiresAt === null ? null : Date.parse(user.expiresAt);\n },\n} as const;\n"],"names":[],"mappings":";;AA6CA,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AACrE,MAAM,SAAS,CAAC,UAAoC,OAAO,UAAU,YAAY,UAAU;AAE3F,MAAM,eAAe,CAAC,UAAmC,OAAO,UAAU,WAAW,QAAQ;AAC7F,MAAM,WAAW,MAAkB,kBAAkB,OAAO,UAAU;AAG/D,SAAS,iBAAiB,OAAwD;AACvF,MAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,iBAAiB,MAAM,UAAW,QAAO,iBAAiB,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AAG,QAAO,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,IAAI,SAAS,IAAI;AAC3E,MAAI;AACF,UAAM,EAAE,UAAU,OAAA,IAAW,IAAI,IAAI,GAAG;AACxC,WAAO,WAAW,YAAY,WAAW;AAAA,EAC3C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,gBAAgB,OAA+C;AAC7E,MAAI,CAAC,SAAS,KAAK,KAAK,CAAC,OAAO,MAAM,eAAe,CAAC,KAAK,CAAC,YAAY,MAAM,eAAe,CAAC,GAAG;AAC/F,WAAO,iBAAiB,KAAK,UAAU;AAAA,EACzC;AACA,SAAO,iBAAiB,GAAG,EAAE,eAAe,MAAM,eAAe,GAAG;AACtE;AAGO,MAAM,uBAAuB;AAAA;AAAA,EAElC,cAAc,MAAkC,YAA6B;AAC3E,WAAO,MAAM,YAAY,SAAS,UAAU,KAAK;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAS,MAAuB;AAC9B,WAAO,GAAG,KAAK,OAAO,GAAG,KAAS,KAAK,cAAc,MAAM,EAAE;AAAA,EAC/D;AAAA;AAAA,EAGA,YAAY,MAA8B;AACxC,WAAO,KAAK,cAAc,OAAO,OAAO,KAAK,MAAM,KAAK,SAAS;AAAA,EACnE;AACF;"}
1
+ {"version":3,"file":"BffSession.js","sources":["../../src/auth/BffSession.ts"],"sourcesContent":["import { ApiFailureFactory, type ApiFailure } from '../foundation/http';\nimport { ResultExtensions, type Result } from '../foundation/results';\n\n/** Defines the signed-in person a BFF session names. */\nexport interface BffPerson {\n /** The stable subject id — the identity key, never the display name. */\n readonly sub: string;\n readonly name: string | null;\n /**\n * The link to the person's picture (the ID token's `picture`); `null` without one or without the `profile` scope.\n * Bind it to `AccountMenu`'s `avatarSrc` as is — the avatar shows initials while it is `null` or fails to load.\n */\n readonly picture: string | null;\n readonly email: string | null;\n readonly phoneNumber: string | null;\n}\n\n/** Defines the organization the session acts in, and the person's role there. */\nexport interface BffOrganization {\n readonly id: string;\n readonly role: string;\n}\n\n/**\n * Defines the user a BFF session resolves to. The CSRF token is deliberately absent: it never renders, so the\n * strategy keeps it and the HTTP layer echoes it.\n */\nexport interface BffUser {\n readonly person: BffPerson;\n /** `null` for a person acting in no organization. */\n readonly organization: BffOrganization | null;\n readonly permissions: readonly string[];\n /** When the session ends (ISO 8601); `null` when the server sent none that parses. */\n readonly expiresAt: string | null;\n}\n\n/** Defines one decoded `GET {prefix}/session` response. */\nexport interface BffSessionSnapshot {\n /** `null` while signed out. */\n readonly user: BffUser | null;\n /** The token unsafe requests echo; `null` while signed out. */\n readonly csrfToken: string | null;\n}\n\n/** Defines one decoded `POST {prefix}/sign-out` response. */\nexport interface BffSignOut {\n /** Where the page navigates to end the identity provider's session. */\n readonly endSessionUrl: string;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\nconst isText = (value: unknown): value is string => typeof value === 'string' && value !== '';\n/** Reads an optional text field; anything but text reads as absent. */\nconst optionalText = (value: unknown): string | null => (typeof value === 'string' ? value : null);\n/** Reads an optional link; anything but non-blank text reads as absent, since an empty link names no resource. */\nconst optionalLink = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value.trim() : null;\nconst protocol = (): ApiFailure => ApiFailureFactory.create('protocol');\n\n/** Decodes the session response; a payload that breaks the contract is a `protocol` failure. */\nexport function decodeBffSession(value: unknown): Result<BffSessionSnapshot, ApiFailure> {\n if (!isRecord(value) || typeof value['isAuthenticated'] !== 'boolean') return ResultExtensions.fail(protocol());\n if (!value['isAuthenticated']) return ResultExtensions.ok({ user: null, csrfToken: null });\n\n const person = value['person'];\n const organization = value['organization'];\n const permissions = value['permissions'] ?? [];\n const expiresAt = value['expiresAt'];\n if (!isRecord(person) || !isText(person['sub']) || !isText(value['csrfToken'])) {\n return ResultExtensions.fail(protocol());\n }\n if (organization != null && (!isRecord(organization) || !isText(organization['id']))) {\n return ResultExtensions.fail(protocol());\n }\n if (!Array.isArray(permissions) || !permissions.every(isText)) return ResultExtensions.fail(protocol());\n\n return ResultExtensions.ok({\n csrfToken: value['csrfToken'],\n user: {\n person: {\n sub: person['sub'],\n name: optionalText(person['name']),\n picture: optionalLink(person['picture']),\n email: optionalText(person['email']),\n phoneNumber: optionalText(person['phoneNumber']),\n },\n organization: isRecord(organization)\n ? { id: organization['id'] as string, role: optionalText(organization['role']) ?? '' }\n : null,\n permissions: Object.freeze([...(permissions as string[])]),\n expiresAt: typeof expiresAt === 'string' && Number.isFinite(Date.parse(expiresAt)) ? expiresAt : null,\n },\n });\n}\n\n/** Whether a page may navigate to `url` to end the provider session: a local path, or an absolute http(s) URL. */\nfunction isNavigable(url: string): boolean {\n if (url.startsWith('/')) return !url.startsWith('//') && !url.includes('\\\\');\n try {\n const { protocol: scheme } = new URL(url);\n return scheme === 'https:' || scheme === 'http:';\n } catch {\n return false;\n }\n}\n\n/** Decodes the logout response; an end-session URL the page may not navigate to is a `protocol` failure. */\nexport function decodeBffSignOut(value: unknown): Result<BffSignOut, ApiFailure> {\n if (!isRecord(value) || !isText(value['endSessionUrl']) || !isNavigable(value['endSessionUrl'])) {\n return ResultExtensions.fail(protocol());\n }\n return ResultExtensions.ok({ endSessionUrl: value['endSessionUrl'] });\n}\n\n/** Extends a {@link BffUser} with the checks a screen and a bridge need. */\nexport const BffSessionExtensions = {\n /** Whether the user holds `permission`; `false` while signed out. */\n hasPermission(user: BffUser | null | undefined, permission: string): boolean {\n return user?.permissions.includes(permission) ?? false;\n },\n\n /**\n * The stable user-and-organization key: pass it as `createAuthBridge({ getIdentity })` so a refreshed session\n * keeps its caches and a person or organization switch drops them.\n */\n identity(user: BffUser): string {\n return `${user.person.sub}\\u0000${user.organization?.id ?? ''}`;\n },\n\n /** The session end as epoch milliseconds; `null` when the server sent none that parses. */\n expiresAtMs(user: BffUser): number | null {\n return user.expiresAt === null ? null : Date.parse(user.expiresAt);\n },\n} as const;\n"],"names":[],"mappings":";;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KAAK,cAAc,OAAO,OAAO,KAAK,MAAM,KAAK,SAAS;AAAA,EACnE;AACF;"}
@@ -47,8 +47,8 @@ export interface BffSessionLink {
47
47
  * Connects a BFF strategy to its provider for the life of a mounted app:
48
48
  *
49
49
  * - Tab sync: a sign-in here tells the other tabs, a sign-out or expiry here tells them, and a tab that hears a hint
50
- * re-reads `GET /auth/session`. The hint carries no identity, and a tab applying one never announces, so two tabs
51
- * cannot ping-pong.
50
+ * re-reads `GET /api/identity/session`. The hint carries no identity; a tab applying one never announces,
51
+ * so two tabs cannot ping-pong.
52
52
  * - Refresh: one timer per `expiresAt` fires at most twice (`lead`, then `expiry`) and never again for the same
53
53
  * value, so a server that does not extend its session cannot make it loop; a new `expiresAt` earns a new pair, and
54
54
  * `minIntervalMs` floors the pace. A failed refresh retries with doubling delay and stops after `maxRetries`.
@@ -1 +1 @@
1
- {"version":3,"file":"BffSessionSync.js","sources":["../../src/auth/BffSessionSync.ts"],"sourcesContent":["import { createSyncChannel, type SyncChannel, type SyncChannelOptions } from '../foundation/channels';\nimport { AppErrorFactory, ResultExtensions, type AppError, type Result } from '../foundation/results';\nimport { AuthStatus, type AuthSession, type AuthStrategyHost } from './AuthSession';\nimport { BffSessionExtensions, type BffUser } from './BffSession';\n\n/** Names what one tab tells the others. The message is a hint to re-read the session, never a credential. */\nexport const BffSyncKind = {\n SignedIn: 'signed-in',\n SignedOut: 'signed-out',\n} as const;\nexport type BffSyncKind = (typeof BffSyncKind)[keyof typeof BffSyncKind];\n\n/** Defines the cross-tab message. A peer is another copy of the page: receivers re-read the server, not the message. */\nexport interface BffSyncMessage {\n readonly kind: BffSyncKind;\n}\n\n/** Defines the cross-tab sync options; the channel is `BroadcastChannel`, falling back to the `storage` event. */\nexport interface BffSyncOptions extends SyncChannelOptions {\n /** The channel name shared by this app's tabs. Default `wow-two.auth.bff`. */\n readonly channelName?: string;\n\n /** Opens this tab's endpoint. Default `createSyncChannel(channelName, options)`; tests inject a hub channel. */\n readonly open?: (name: string) => SyncChannel<BffSyncMessage>;\n}\n\n/** Defines when a signed-in session is re-read without the person doing anything. */\nexport interface BffRefreshOptions {\n /** How long before `expiresAt` the pre-expiry refresh runs. Default 60 s. */\n readonly leadMs?: number;\n\n /** The least time between two timer-driven refreshes — the floor under any schedule. Default 15 s. */\n readonly minIntervalMs?: number;\n\n /** How old the last read must be before a focus or visibility change re-reads it. Default 30 s. */\n readonly staleAfterMs?: number;\n\n /** The first retry delay after a failed refresh; it doubles up to 5 min. Default 30 s. */\n readonly retryMs?: number;\n\n /** Consecutive failed refreshes after which the timer stops until the next focus or peer hint. Default 5. */\n readonly maxRetries?: number;\n}\n\nconst DefaultChannelName = 'wow-two.auth.bff';\nconst RefreshDefaults = { leadMs: 60_000, minIntervalMs: 15_000, staleAfterMs: 30_000, retryMs: 30_000, maxRetries: 5 };\nconst MaxRetryDelayMs = 300_000;\n/** The longest `setTimeout` delay browsers honour (a 32-bit signed millisecond count). */\nconst MaxTimerMs = 2_147_483_647;\n\n/** Defines the options of {@link connectBffSession}. */\nexport interface BffSessionLinkOptions {\n readonly sync: BffSyncOptions | false;\n readonly refresh: BffRefreshOptions | false;\n readonly now: () => number;\n}\n\n/** Defines the live connection of one strategy to its provider. */\nexport interface BffSessionLink {\n /** Tells the other tabs the session ended. Silent while this tab applies a peer's hint, so tabs never echo. */\n readonly announce: (kind: BffSyncKind) => void;\n readonly dispose: () => void;\n}\n\n/** `lead`: the refresh before `expiresAt`; `expiry`: the one check at it. A stage never repeats for one `expiresAt`. */\ntype Stage = 'lead' | 'expiry';\n\nconst isHint = (message: unknown): message is BffSyncMessage =>\n typeof message === 'object' &&\n message !== null &&\n ((message as BffSyncMessage).kind === BffSyncKind.SignedIn ||\n (message as BffSyncMessage).kind === BffSyncKind.SignedOut);\n\n/**\n * Connects a BFF strategy to its provider for the life of a mounted app:\n *\n * - Tab sync: a sign-in here tells the other tabs, a sign-out or expiry here tells them, and a tab that hears a hint\n * re-reads `GET /auth/session`. The hint carries no identity, and a tab applying one never announces, so two tabs\n * cannot ping-pong.\n * - Refresh: one timer per `expiresAt` fires at most twice (`lead`, then `expiry`) and never again for the same\n * value, so a server that does not extend its session cannot make it loop; a new `expiresAt` earns a new pair, and\n * `minIntervalMs` floors the pace. A failed refresh retries with doubling delay and stops after `maxRetries`.\n * - Wake: a focus or visibility change re-reads a session older than `staleAfterMs`, signed in or out.\n */\nexport function connectBffSession(host: AuthStrategyHost<BffUser>, options: BffSessionLinkOptions): BffSessionLink {\n const refresh = options.refresh === false ? null : { ...RefreshDefaults, ...options.refresh };\n const now = options.now;\n const disposers: Array<() => void> = [];\n\n let closed = false;\n // `undefined` before the first settled snapshot, `null` while signed out, else the signed-in identity key.\n let lastKey: string | null | undefined;\n let peerDepth = 0;\n let lastLoadedAt = Number.NEGATIVE_INFINITY;\n let lastFireAt = Number.NEGATIVE_INFINITY;\n let fired: { readonly expiresAt: string | null; readonly stage: Stage } | null = null;\n let failures = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const sync = options.sync === false ? null : options.sync;\n let channel: SyncChannel<BffSyncMessage> | null = null;\n if (sync) {\n const name = sync.channelName ?? DefaultChannelName;\n channel = sync.open ? sync.open(name) : createSyncChannel<BffSyncMessage>(name, sync);\n }\n\n let pending: Promise<Result<BffUser | null, AppError>> | null = null;\n /**\n * Re-reads the session; callers that arrive mid-read share it. A throwing strategy counts as a failure, so a timer\n * never leaks an unhandled rejection.\n */\n function revalidate(): Promise<Result<BffUser | null, AppError>> {\n if (pending) return pending;\n const read = (async (): Promise<Result<BffUser | null, AppError>> => {\n try {\n const outcome = await host.revalidate();\n if (outcome.ok) lastLoadedAt = now();\n return outcome;\n } catch {\n return ResultExtensions.fail(AppErrorFactory.unexpected());\n }\n })().finally(() => {\n if (pending === read) pending = null;\n });\n pending = read;\n return read;\n }\n\n function clearTimer(): void {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n }\n\n /** Arms the timer for `stage` at `target`, never sooner than `minIntervalMs` after the previous fire. */\n function arm(stage: Stage, target: number): void {\n clearTimer();\n if (!refresh || closed) return;\n const due = Math.max(target, lastFireAt + refresh.minIntervalMs);\n const wake = (): void => {\n timer = undefined;\n if (closed) return;\n // A clamped or early timer fires before `due`: wait out the rest instead of firing early.\n if (now() < due) timer = setTimeout(wake, Math.min(Math.max(due - now(), 1), MaxTimerMs));\n else void fire(stage);\n };\n timer = setTimeout(wake, Math.min(Math.max(due - now(), 0), MaxTimerMs));\n }\n\n /** Schedules the next stage for the current session, or nothing when it has no end or both stages ran. */\n function schedule(session: AuthSession<BffUser>): void {\n clearTimer();\n if (!refresh || closed || session.status !== AuthStatus.Authenticated || session.user === null) return;\n const expiresAt = BffSessionExtensions.expiresAtMs(session.user);\n if (expiresAt === null) return;\n const done = fired?.expiresAt === session.user.expiresAt ? fired.stage : null;\n if (done === 'expiry') return;\n if (done === 'lead') arm('expiry', expiresAt);\n else arm('lead', expiresAt - refresh.leadMs);\n }\n\n async function fire(stage: Stage): Promise<void> {\n const session = host.getSession();\n if (session.status !== AuthStatus.Authenticated || session.user === null) return;\n const before = fired;\n // Recorded before the read: the read republishes the session, and the republish must see this stage as done.\n fired = { expiresAt: session.user.expiresAt, stage };\n lastFireAt = now();\n const outcome = await revalidate();\n if (closed) return;\n if (outcome.ok) {\n failures = 0;\n return;\n }\n // A cancelled read was superseded by a sign-in, sign-out or newer read, which reschedules on its own.\n if (outcome.failure.type === 'cancelled') return;\n fired = before;\n failures += 1;\n if (!refresh || failures > refresh.maxRetries) return;\n arm(stage, now() + Math.min(refresh.retryMs * 2 ** (failures - 1), MaxRetryDelayMs));\n }\n\n function onSession(session: AuthSession<BffUser>): void {\n if (closed) return;\n if (session.status !== AuthStatus.Authenticated && session.status !== AuthStatus.Anonymous) return;\n lastLoadedAt = now();\n const key =\n session.status === AuthStatus.Authenticated && session.user !== null\n ? BffSessionExtensions.identity(session.user)\n : null;\n const previous = lastKey;\n lastKey = key;\n // A signed-out change is announced by the strategy once the server has processed it; announcing here would race it.\n if (key !== null && key !== previous && peerDepth === 0) channel?.post({ kind: BffSyncKind.SignedIn });\n schedule(session);\n }\n\n /** Re-reads when the last read is stale. Both a focus and a visibility event arrive; the second finds it fresh. */\n function wake(): void {\n if (closed || !refresh) return;\n const session = host.getSession();\n if (session.status !== AuthStatus.Authenticated && session.status !== AuthStatus.Anonymous) return;\n if (now() - lastLoadedAt < refresh.staleAfterMs) return;\n failures = 0;\n void revalidate();\n }\n\n async function applyHint(): Promise<void> {\n peerDepth += 1;\n failures = 0;\n try {\n await revalidate();\n } finally {\n peerDepth -= 1;\n }\n }\n\n disposers.push(host.subscribe(onSession));\n onSession(host.getSession());\n\n if (channel) {\n const open = channel;\n disposers.push(\n open.subscribe((message) => {\n if (isHint(message)) void applyHint();\n }),\n () => open.close(),\n );\n }\n\n if (refresh && typeof window !== 'undefined' && typeof document !== 'undefined') {\n const onVisibility = (): void => {\n if (document.visibilityState === 'visible') wake();\n };\n window.addEventListener('focus', wake);\n document.addEventListener('visibilitychange', onVisibility);\n disposers.push(\n () => window.removeEventListener('focus', wake),\n () => document.removeEventListener('visibilitychange', onVisibility),\n );\n }\n\n return {\n announce: (kind) => {\n if (closed || peerDepth > 0) return;\n channel?.post({ kind });\n },\n dispose: () => {\n if (closed) return;\n closed = true;\n clearTimer();\n for (const dispose of disposers.splice(0)) dispose();\n },\n };\n}\n"],"names":["wake"],"mappings":";;;;;AAMO,MAAM,cAAc;AAAA,EACzB,UAAU;AAAA,EACV,WAAW;AACb;AAmCA,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB,EAAE,QAAQ,KAAQ,eAAe,MAAQ,cAAc,KAAQ,SAAS,KAAQ,YAAY,EAAA;AACpH,MAAM,kBAAkB;AAExB,MAAM,aAAa;AAmBnB,MAAM,SAAS,CAAC,YACd,OAAO,YAAY,YACnB,YAAY,SACV,QAA2B,SAAS,YAAY,YAC/C,QAA2B,SAAS,YAAY;AAa9C,SAAS,kBAAkB,MAAiC,SAAgD;AACjH,QAA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AAA,IACxB;AAAA,IACA,SAAS,MAAM;AACb,UAAI,OAAQ;AACZ,eAAS;AACT,iBAAA;AACA,iBAAW,WAAW,UAAU,OAAO,CAAC,EAAG,SAAA;AAAA,IAC7C;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"BffSessionSync.js","sources":["../../src/auth/BffSessionSync.ts"],"sourcesContent":["import { createSyncChannel, type SyncChannel, type SyncChannelOptions } from '../foundation/channels';\nimport { AppErrorFactory, ResultExtensions, type AppError, type Result } from '../foundation/results';\nimport { AuthStatus, type AuthSession, type AuthStrategyHost } from './AuthSession';\nimport { BffSessionExtensions, type BffUser } from './BffSession';\n\n/** Names what one tab tells the others. The message is a hint to re-read the session, never a credential. */\nexport const BffSyncKind = {\n SignedIn: 'signed-in',\n SignedOut: 'signed-out',\n} as const;\nexport type BffSyncKind = (typeof BffSyncKind)[keyof typeof BffSyncKind];\n\n/** Defines the cross-tab message. A peer is another copy of the page: receivers re-read the server, not the message. */\nexport interface BffSyncMessage {\n readonly kind: BffSyncKind;\n}\n\n/** Defines the cross-tab sync options; the channel is `BroadcastChannel`, falling back to the `storage` event. */\nexport interface BffSyncOptions extends SyncChannelOptions {\n /** The channel name shared by this app's tabs. Default `wow-two.auth.bff`. */\n readonly channelName?: string;\n\n /** Opens this tab's endpoint. Default `createSyncChannel(channelName, options)`; tests inject a hub channel. */\n readonly open?: (name: string) => SyncChannel<BffSyncMessage>;\n}\n\n/** Defines when a signed-in session is re-read without the person doing anything. */\nexport interface BffRefreshOptions {\n /** How long before `expiresAt` the pre-expiry refresh runs. Default 60 s. */\n readonly leadMs?: number;\n\n /** The least time between two timer-driven refreshes — the floor under any schedule. Default 15 s. */\n readonly minIntervalMs?: number;\n\n /** How old the last read must be before a focus or visibility change re-reads it. Default 30 s. */\n readonly staleAfterMs?: number;\n\n /** The first retry delay after a failed refresh; it doubles up to 5 min. Default 30 s. */\n readonly retryMs?: number;\n\n /** Consecutive failed refreshes after which the timer stops until the next focus or peer hint. Default 5. */\n readonly maxRetries?: number;\n}\n\nconst DefaultChannelName = 'wow-two.auth.bff';\nconst RefreshDefaults = { leadMs: 60_000, minIntervalMs: 15_000, staleAfterMs: 30_000, retryMs: 30_000, maxRetries: 5 };\nconst MaxRetryDelayMs = 300_000;\n/** The longest `setTimeout` delay browsers honour (a 32-bit signed millisecond count). */\nconst MaxTimerMs = 2_147_483_647;\n\n/** Defines the options of {@link connectBffSession}. */\nexport interface BffSessionLinkOptions {\n readonly sync: BffSyncOptions | false;\n readonly refresh: BffRefreshOptions | false;\n readonly now: () => number;\n}\n\n/** Defines the live connection of one strategy to its provider. */\nexport interface BffSessionLink {\n /** Tells the other tabs the session ended. Silent while this tab applies a peer's hint, so tabs never echo. */\n readonly announce: (kind: BffSyncKind) => void;\n readonly dispose: () => void;\n}\n\n/** `lead`: the refresh before `expiresAt`; `expiry`: the one check at it. A stage never repeats for one `expiresAt`. */\ntype Stage = 'lead' | 'expiry';\n\nconst isHint = (message: unknown): message is BffSyncMessage =>\n typeof message === 'object' &&\n message !== null &&\n ((message as BffSyncMessage).kind === BffSyncKind.SignedIn ||\n (message as BffSyncMessage).kind === BffSyncKind.SignedOut);\n\n/**\n * Connects a BFF strategy to its provider for the life of a mounted app:\n *\n * - Tab sync: a sign-in here tells the other tabs, a sign-out or expiry here tells them, and a tab that hears a hint\n * re-reads `GET /api/identity/session`. The hint carries no identity; a tab applying one never announces,\n * so two tabs cannot ping-pong.\n * - Refresh: one timer per `expiresAt` fires at most twice (`lead`, then `expiry`) and never again for the same\n * value, so a server that does not extend its session cannot make it loop; a new `expiresAt` earns a new pair, and\n * `minIntervalMs` floors the pace. A failed refresh retries with doubling delay and stops after `maxRetries`.\n * - Wake: a focus or visibility change re-reads a session older than `staleAfterMs`, signed in or out.\n */\nexport function connectBffSession(host: AuthStrategyHost<BffUser>, options: BffSessionLinkOptions): BffSessionLink {\n const refresh = options.refresh === false ? null : { ...RefreshDefaults, ...options.refresh };\n const now = options.now;\n const disposers: Array<() => void> = [];\n\n let closed = false;\n // `undefined` before the first settled snapshot, `null` while signed out, else the signed-in identity key.\n let lastKey: string | null | undefined;\n let peerDepth = 0;\n let lastLoadedAt = Number.NEGATIVE_INFINITY;\n let lastFireAt = Number.NEGATIVE_INFINITY;\n let fired: { readonly expiresAt: string | null; readonly stage: Stage } | null = null;\n let failures = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const sync = options.sync === false ? null : options.sync;\n let channel: SyncChannel<BffSyncMessage> | null = null;\n if (sync) {\n const name = sync.channelName ?? DefaultChannelName;\n channel = sync.open ? sync.open(name) : createSyncChannel<BffSyncMessage>(name, sync);\n }\n\n let pending: Promise<Result<BffUser | null, AppError>> | null = null;\n /**\n * Re-reads the session; callers that arrive mid-read share it. A throwing strategy counts as a failure, so a timer\n * never leaks an unhandled rejection.\n */\n function revalidate(): Promise<Result<BffUser | null, AppError>> {\n if (pending) return pending;\n const read = (async (): Promise<Result<BffUser | null, AppError>> => {\n try {\n const outcome = await host.revalidate();\n if (outcome.ok) lastLoadedAt = now();\n return outcome;\n } catch {\n return ResultExtensions.fail(AppErrorFactory.unexpected());\n }\n })().finally(() => {\n if (pending === read) pending = null;\n });\n pending = read;\n return read;\n }\n\n function clearTimer(): void {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n }\n\n /** Arms the timer for `stage` at `target`, never sooner than `minIntervalMs` after the previous fire. */\n function arm(stage: Stage, target: number): void {\n clearTimer();\n if (!refresh || closed) return;\n const due = Math.max(target, lastFireAt + refresh.minIntervalMs);\n const wake = (): void => {\n timer = undefined;\n if (closed) return;\n // A clamped or early timer fires before `due`: wait out the rest instead of firing early.\n if (now() < due) timer = setTimeout(wake, Math.min(Math.max(due - now(), 1), MaxTimerMs));\n else void fire(stage);\n };\n timer = setTimeout(wake, Math.min(Math.max(due - now(), 0), MaxTimerMs));\n }\n\n /** Schedules the next stage for the current session, or nothing when it has no end or both stages ran. */\n function schedule(session: AuthSession<BffUser>): void {\n clearTimer();\n if (!refresh || closed || session.status !== AuthStatus.Authenticated || session.user === null) return;\n const expiresAt = BffSessionExtensions.expiresAtMs(session.user);\n if (expiresAt === null) return;\n const done = fired?.expiresAt === session.user.expiresAt ? fired.stage : null;\n if (done === 'expiry') return;\n if (done === 'lead') arm('expiry', expiresAt);\n else arm('lead', expiresAt - refresh.leadMs);\n }\n\n async function fire(stage: Stage): Promise<void> {\n const session = host.getSession();\n if (session.status !== AuthStatus.Authenticated || session.user === null) return;\n const before = fired;\n // Recorded before the read: the read republishes the session, and the republish must see this stage as done.\n fired = { expiresAt: session.user.expiresAt, stage };\n lastFireAt = now();\n const outcome = await revalidate();\n if (closed) return;\n if (outcome.ok) {\n failures = 0;\n return;\n }\n // A cancelled read was superseded by a sign-in, sign-out or newer read, which reschedules on its own.\n if (outcome.failure.type === 'cancelled') return;\n fired = before;\n failures += 1;\n if (!refresh || failures > refresh.maxRetries) return;\n arm(stage, now() + Math.min(refresh.retryMs * 2 ** (failures - 1), MaxRetryDelayMs));\n }\n\n function onSession(session: AuthSession<BffUser>): void {\n if (closed) return;\n if (session.status !== AuthStatus.Authenticated && session.status !== AuthStatus.Anonymous) return;\n lastLoadedAt = now();\n const key =\n session.status === AuthStatus.Authenticated && session.user !== null\n ? BffSessionExtensions.identity(session.user)\n : null;\n const previous = lastKey;\n lastKey = key;\n // A signed-out change is announced by the strategy once the server has processed it; announcing here would race it.\n if (key !== null && key !== previous && peerDepth === 0) channel?.post({ kind: BffSyncKind.SignedIn });\n schedule(session);\n }\n\n /** Re-reads when the last read is stale. Both a focus and a visibility event arrive; the second finds it fresh. */\n function wake(): void {\n if (closed || !refresh) return;\n const session = host.getSession();\n if (session.status !== AuthStatus.Authenticated && session.status !== AuthStatus.Anonymous) return;\n if (now() - lastLoadedAt < refresh.staleAfterMs) return;\n failures = 0;\n void revalidate();\n }\n\n async function applyHint(): Promise<void> {\n peerDepth += 1;\n failures = 0;\n try {\n await revalidate();\n } finally {\n peerDepth -= 1;\n }\n }\n\n disposers.push(host.subscribe(onSession));\n onSession(host.getSession());\n\n if (channel) {\n const open = channel;\n disposers.push(\n open.subscribe((message) => {\n if (isHint(message)) void applyHint();\n }),\n () => open.close(),\n );\n }\n\n if (refresh && typeof window !== 'undefined' && typeof document !== 'undefined') {\n const onVisibility = (): void => {\n if (document.visibilityState === 'visible') wake();\n };\n window.addEventListener('focus', wake);\n document.addEventListener('visibilitychange', onVisibility);\n disposers.push(\n () => window.removeEventListener('focus', wake),\n () => document.removeEventListener('visibilitychange', onVisibility),\n );\n }\n\n return {\n announce: (kind) => {\n if (closed || peerDepth > 0) return;\n channel?.post({ kind });\n },\n dispose: () => {\n if (closed) return;\n closed = true;\n clearTimer();\n for (const dispose of disposers.splice(0)) dispose();\n },\n };\n}\n"],"names":["wake"],"mappings":";;;;;AAMO,MAAM,cAAc;AAAA,EACzB,UAAU;AAAA,EACV,WAAW;AACb;AAmCA,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB,EAAE,QAAQ,KAAQ,eAAe,MAAQ,cAAc,KAAQ,SAAS,KAAQ,YAAY,EAAA;AACpH,MAAM,kBAAkB;AAExB,MAAM,aAAa;AAmBnB,MAAM,SAAS,CAAC,YACd,OAAO,YAAY,YACnB,YAAY,SACV,QAA2B,SAAS,YAAY,YAC/C,QAA2B,SAAS,YAAY;AAa9C,SAAS,kBAAkB,MAAiC,SAAgD;AACjH,QAAM,UAAU,QAAQ,YAAY,QAAQ,OAAO,EAAE,GAAG,iBAAiB,GAAG,QAAQ,QAAA;AACpF,QAAM,MAAM,QAAQ;AACpB,QAAM,YAA+B,CAAA;AAErC,MAAI,SAAS;AAEb,MAAI;AACJ,MAAI,YAAY;AAChB,MAAI,eAAe,OAAO;AAC1B,MAAI,aAAa,OAAO;AACxB,MAAI,QAA6E;AACjF,MAAI,WAAW;AACf,MAAI;AAEJ,QAAM,OAAO,QAAQ,SAAS,QAAQ,OAAO,QAAQ;AACrD,MAAI,UAA8C;AAClD,MAAI,MAAM;AACR,UAAM,OAA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ACjD,eAAW;AACX,SAAK,WAAA;AAAA,EACP;AAEA,iBAAe,YAA2B;AACxC,iBAAa;AACb,eAAW;AACX,QAAI;AACF,YAAM,WAAA;AAAA,IACR,UAAA;AACE,mBAAa;AAAA,IACf;AAAA,EACF;AAEA,YAAU,KAAK,KAAK,UAAU,SAAS,CAAC;AACxC,YAAU,KAAK,YAAY;AAE3B,MAAI,SAAS;AACX,UAAM,OAAO;AACb,cAAU;AAAA,MACR,KAAK,UAAU,CAAC,YAAY;AAC1B,YAAI,OAAO,OAAO,EAAG,MAAK,UAAA;AAAA,MAC5B,CAAC;AAAA,MACD,MAAM,KAAK,MAAA;AAAA,IAAM;AAAA,EAErB;AAEA,MAAI,WAAW,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AAC/E,UAAM,eAAe,MAAY;AAC/B,UAAI,SAAS,oBAAoB,UAAW,MAAA;AAAA,IAC9C;AACA,WAAO,iBAAiB,SAAS,IAAI;AACrC,aAAS,iBAAiB,oBAAoB,YAAY;AAC1D,cAAU;AAAA,MACR,MAAM,OAAO,oBAAoB,SAAS,IAAI;AAAA,MAC9C,MAAM,SAAS,oBAAoB,oBAAoB,YAAY;AAAA,IAAA;AAAA,EAEvE;AAEA,SAAO;AAAA,IACL,UAAU,CAAC,SAAS;AAClB,UAAI,UAAU,YAAY,EAAG;AAC7B,eAAS,KAAK,EAAE,MAAM;AAAA,IACxB;AAAA,IACA,SAAS,MAAM;AACb,UAAI,OAAQ;AACZ,eAAS;AACT,iBAAA;AACA,iBAAW,WAAW,UAAU,OAAO,CAAC,EAAG,SAAA;AAAA,IAC7C;AAAA,EAAA;AAEJ;"}
@@ -5,7 +5,7 @@ import { BffUser } from './BffSession';
5
5
  import { BffRefreshOptions, BffSyncOptions } from './BffSessionSync';
6
6
  /** Defines the options for {@link createBffStrategy}. */
7
7
  export interface CreateBffStrategyOptions {
8
- /** The route prefix of the BFF's auth endpoints. Default `/auth`. */
8
+ /** The route prefix of the BFF's auth endpoints. Default `/api/identity`. */
9
9
  readonly prefix?: string;
10
10
  /** The origin the auth endpoints live on. Default `''`: the SPA's own origin, the BFF's served shape. */
11
11
  readonly baseUrl?: string;
@@ -33,18 +33,18 @@ export interface BffStrategy extends AuthStrategy<BffUser, string | undefined> {
33
33
  readonly antiforgery: ApiAntiforgeryOptions;
34
34
  /** Reads the current CSRF token; `null` while signed out. */
35
35
  readonly getCsrfToken: () => string | null;
36
- /** Builds `{prefix}/login?returnUrl=…` for a local path; a path that is not local falls back to `/`. */
37
- readonly loginUrl: (returnUrl?: string) => string;
36
+ /** Builds `{prefix}/sign-in?returnUrl=…` for a local path; a path that is not local falls back to `/`. */
37
+ readonly signInUrl: (returnUrl?: string) => string;
38
38
  /**
39
39
  * Sends the person to sign-in with the page they were on. Subscribe it to the bridge:
40
- * `bridge.subscribeExpired(bff.redirectToLogin)`.
40
+ * `bridge.subscribeExpired(bff.redirectToSignIn)`.
41
41
  */
42
- readonly redirectToLogin: SessionExpiredListener;
42
+ readonly redirectToSignIn: SessionExpiredListener;
43
43
  }
44
44
  /**
45
45
  * Creates the BFF session strategy for an SPA served on its BFF's origin. The BFF owns the session cookie; the SPA
46
- * reads `GET {prefix}/session`, signs in by navigating to `{prefix}/login?returnUrl=…`, and signs out with
47
- * `POST {prefix}/logout`, then navigates to the returned `endSessionUrl`.
46
+ * reads `GET {prefix}/session`, signs in by navigating to `{prefix}/sign-in?returnUrl=…`, and signs out with
47
+ * `POST {prefix}/sign-out`, then navigates to the returned `endSessionUrl`.
48
48
  *
49
49
  * Its own HTTP client carries the auth calls, with no request scope — a sign-out must not cancel itself. The app's
50
50
  * client takes {@link BffStrategy.antiforgery} so its writes carry the CSRF token. Pair it with
@@ -1,12 +1,12 @@
1
1
  import { createApiClient } from "../foundation/http/CreateApiClient.js";
2
2
  import { AppErrorFactory } from "../foundation/results/AppErrorFactory.js";
3
3
  import { ResultExtensions } from "../foundation/results/ResultExtensions.js";
4
- import { decodeBffLogout, decodeBffSession } from "./BffSession.js";
4
+ import { decodeBffSignOut, decodeBffSession } from "./BffSession.js";
5
5
  import { connectBffSession } from "./BffSessionSync.js";
6
6
  import { ReturnUrlExtensions } from "./ReturnUrlExtensions.js";
7
7
  function createBffStrategy(options = {}) {
8
8
  const {
9
- prefix = "/auth",
9
+ prefix = "/api/identity",
10
10
  baseUrl = "",
11
11
  csrfHeaderName = "X-Csrf-Token",
12
12
  sync = {},
@@ -32,12 +32,12 @@ function createBffStrategy(options = {}) {
32
32
  }
33
33
  window.location.assign(url);
34
34
  });
35
- const loginUrl = (returnUrl = ReturnUrlExtensions.current()) => `${baseUrl}${root}/login?returnUrl=${encodeURIComponent(ReturnUrlExtensions.isLocal(returnUrl) ? returnUrl : "/")}`;
35
+ const signInUrl = (returnUrl = ReturnUrlExtensions.current()) => `${baseUrl}${root}/sign-in?returnUrl=${encodeURIComponent(ReturnUrlExtensions.isLocal(returnUrl) ? returnUrl : "/")}`;
36
36
  return {
37
37
  antiforgery,
38
38
  getCsrfToken: () => csrfToken,
39
- loginUrl,
40
- redirectToLogin: ({ returnUrl }) => navigate(loginUrl(returnUrl)),
39
+ signInUrl,
40
+ redirectToSignIn: ({ returnUrl }) => navigate(signInUrl(returnUrl)),
41
41
  async resolveUser(context) {
42
42
  const current = ++generation;
43
43
  const outcome = await client.get(`${root}/session`, { ...context, decode: decodeBffSession });
@@ -56,13 +56,13 @@ function createBffStrategy(options = {}) {
56
56
  if (!ReturnUrlExtensions.isLocal(target)) return ResultExtensions.fail(AppErrorFactory.validation());
57
57
  if (!options.navigate && typeof window === "undefined")
58
58
  return ResultExtensions.fail(AppErrorFactory.unavailable());
59
- navigate(loginUrl(target));
59
+ navigate(signInUrl(target));
60
60
  return ResultExtensions.ok(void 0);
61
61
  },
62
62
  async signOut(context) {
63
63
  ++generation;
64
64
  try {
65
- const outcome = await client.post(`${root}/logout`, { ...context, decode: decodeBffLogout });
65
+ const outcome = await client.post(`${root}/sign-out`, { ...context, decode: decodeBffSignOut });
66
66
  if (!outcome.ok) {
67
67
  return outcome.failure.status === 401 ? ResultExtensions.ok(void 0) : outcome;
68
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BffStrategy.js","sources":["../../src/auth/BffStrategy.ts"],"sourcesContent":["import { createApiClient, type ApiAntiforgeryOptions, type ApiClientOptions } from '../foundation/http';\nimport { AppErrorFactory, ResultExtensions, type AppError, type Result } from '../foundation/results';\nimport type { SessionExpiredListener } from './AuthBridge';\nimport type { AuthResolveContext, AuthStrategy, AuthStrategyHost } from './AuthSession';\nimport { decodeBffLogout, decodeBffSession, type BffUser } from './BffSession';\nimport { connectBffSession, type BffRefreshOptions, type BffSessionLink, type BffSyncOptions } from './BffSessionSync';\nimport { ReturnUrlExtensions } from './ReturnUrlExtensions';\n\n/** Defines the options for {@link createBffStrategy}. */\nexport interface CreateBffStrategyOptions {\n /** The route prefix of the BFF's auth endpoints. Default `/auth`. */\n readonly prefix?: string;\n\n /** The origin the auth endpoints live on. Default `''`: the SPA's own origin, the BFF's served shape. */\n readonly baseUrl?: string;\n\n /** The request header the CSRF token travels in. Default `X-Csrf-Token`. */\n readonly csrfHeaderName?: string;\n\n /** Sent with every auth request. Default is the browser's `same-origin`. */\n readonly credentials?: RequestCredentials;\n\n /** Replaces `fetch` — a mocked one in tests. */\n readonly fetch?: typeof globalThis.fetch;\n\n /** Navigates the page. Default `window.location.assign`; inject to drive the strategy without a DOM. */\n readonly navigate?: (url: string) => void;\n\n /** Cross-tab sync. Default on, over `BroadcastChannel` with a `storage`-event fallback; `false` turns it off. */\n readonly sync?: BffSyncOptions | false;\n\n /** Session refresh before `expiresAt` and on focus. Default on; `false` turns it off. */\n readonly refresh?: BffRefreshOptions | false;\n\n /** The clock refresh scheduling reads. Default `Date.now`. */\n readonly now?: () => number;\n}\n\n/** Defines the BFF strategy — an {@link AuthStrategy} plus the pieces the rest of the app wires. */\nexport interface BffStrategy extends AuthStrategy<BffUser, string | undefined> {\n /**\n * Feeds `createApiClient({ antiforgery })`, so every unsafe request echoes the session's CSRF token. The token\n * is read per request, so a refreshed session and a sign-out take effect at once.\n */\n readonly antiforgery: ApiAntiforgeryOptions;\n\n /** Reads the current CSRF token; `null` while signed out. */\n readonly getCsrfToken: () => string | null;\n\n /** Builds `{prefix}/login?returnUrl=…` for a local path; a path that is not local falls back to `/`. */\n readonly loginUrl: (returnUrl?: string) => string;\n\n /**\n * Sends the person to sign-in with the page they were on. Subscribe it to the bridge:\n * `bridge.subscribeExpired(bff.redirectToLogin)`.\n */\n readonly redirectToLogin: SessionExpiredListener;\n}\n\n/**\n * Creates the BFF session strategy for an SPA served on its BFF's origin. The BFF owns the session cookie; the SPA\n * reads `GET {prefix}/session`, signs in by navigating to `{prefix}/login?returnUrl=…`, and signs out with\n * `POST {prefix}/logout`, then navigates to the returned `endSessionUrl`.\n *\n * Its own HTTP client carries the auth calls, with no request scope — a sign-out must not cancel itself. The app's\n * client takes {@link BffStrategy.antiforgery} so its writes carry the CSRF token. Pair it with\n * `createAuthBridge({ getIdentity: BffSessionExtensions.identity })`.\n */\nexport function createBffStrategy(options: CreateBffStrategyOptions = {}): BffStrategy {\n const {\n prefix = '/auth',\n baseUrl = '',\n csrfHeaderName = 'X-Csrf-Token',\n sync = {},\n refresh = {},\n now = () => Date.now(),\n } = options;\n const root = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;\n\n let csrfToken: string | null = null;\n let generation = 0;\n let link: BffSessionLink | undefined;\n\n const antiforgery: ApiAntiforgeryOptions = { headerName: csrfHeaderName, getToken: () => csrfToken };\n const clientOptions: ApiClientOptions = {\n baseUrl,\n antiforgery,\n ...(options.credentials !== undefined ? { credentials: options.credentials } : {}),\n ...(options.fetch !== undefined ? { fetch: options.fetch } : {}),\n };\n const client = createApiClient(clientOptions);\n const cancelled = () => ResultExtensions.fail(AppErrorFactory.cancelled());\n\n const navigate =\n options.navigate ??\n ((url: string) => {\n if (typeof window === 'undefined') {\n throw new Error('createBffStrategy: navigating needs a browser. Pass `navigate` to drive it elsewhere.');\n }\n window.location.assign(url);\n });\n const loginUrl = (returnUrl: string = ReturnUrlExtensions.current()): string =>\n `${baseUrl}${root}/login?returnUrl=${encodeURIComponent(ReturnUrlExtensions.isLocal(returnUrl) ? returnUrl : '/')}`;\n\n return {\n antiforgery,\n getCsrfToken: () => csrfToken,\n loginUrl,\n redirectToLogin: ({ returnUrl }) => navigate(loginUrl(returnUrl)),\n\n async resolveUser(context: AuthResolveContext): Promise<Result<BffUser | null, AppError>> {\n const current = ++generation;\n const outcome = await client.get(`${root}/session`, { ...context, decode: decodeBffSession });\n if (current !== generation || context.signal?.aborted) return cancelled();\n if (!outcome.ok) {\n // A BFF answers a signed-out `GET /session` with 200; a 401 from a proxy in front still means signed out.\n if (outcome.failure.status !== 401) return outcome;\n csrfToken = null;\n return ResultExtensions.ok(null);\n }\n csrfToken = outcome.value.csrfToken;\n return ResultExtensions.ok(outcome.value.user);\n },\n\n // Returns void on purpose: the session stays as it is while the browser navigates to the BFF.\n signIn(returnUrl?: string): Result<void, AppError> {\n const target = returnUrl ?? ReturnUrlExtensions.current();\n if (!ReturnUrlExtensions.isLocal(target)) return ResultExtensions.fail(AppErrorFactory.validation());\n if (!options.navigate && typeof window === 'undefined')\n return ResultExtensions.fail(AppErrorFactory.unavailable());\n navigate(loginUrl(target));\n return ResultExtensions.ok(undefined);\n },\n\n async signOut(context: AuthResolveContext): Promise<Result<void, AppError>> {\n ++generation;\n try {\n // The token is read when the request is sent, so it must outlive the call and clear only afterwards.\n const outcome = await client.post(`${root}/logout`, { ...context, decode: decodeBffLogout });\n if (!outcome.ok) {\n // A 401 means the server session was already gone: signed out either way, with no provider session to end.\n return outcome.failure.status === 401 ? ResultExtensions.ok(undefined) : outcome;\n }\n navigate(outcome.value.endSessionUrl);\n return ResultExtensions.ok(undefined);\n } finally {\n csrfToken = null;\n // Told after the server answered: a hint sent earlier would let a tab read the session before it ended.\n link?.announce('signed-out');\n }\n },\n\n onUnauthorized(): void {\n generation += 1;\n csrfToken = null;\n link?.announce('signed-out');\n },\n\n connect(host: AuthStrategyHost<BffUser>): () => void {\n link?.dispose();\n const own = connectBffSession(host, { sync, refresh, now });\n link = own;\n return () => {\n own.dispose();\n if (link === own) link = undefined;\n };\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AAoEO,SAAS,kBAAkB,UAAoC,IAAiB;AACrF,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,OAAO,CAAA;AAAA,IACP,UAAU,CAAA;AAAA,IACV,MAAM,MAAM,KAAK,IAAA;AAAA,EAAI,IACnB;AACJ,QAAM,OAAO,OAAO,SAAS,GAAG,IAAI,OAAO,MAAM,GAAG,EAAE,IAAI;AAE1D,MAAI,YAA2B;AAC/B,MAAI,aAAa;AACjB,MAAI;AAEJ,QAAM,cAAqC,EAAE,YAAY,gBAAgB,UAAU,MAAM,UAAA;AACzF,QAAM,gBAAkC;AAAA,IACtC;AAAA,IACA;AAAA,IACA,GAAI,QAAQ,gBAAgB,SAAY,EAAE,aAAa,QAAQ,YAAA,IAAgB,CAAA;AAAA,IAC/E,GAAI,QAAQ,UAAU,SAAY,EAAE,OAAO,QAAQ,UAAU,CAAA;AAAA,EAAC;AAEhE,QAAM,SAAS,gBAAgB,aAAa;AAC5C,QAAM,YAAY,MAAM,iBAAiB,KAAK,gBAAgB,WAAW;AAEzE,QAAM,WACJ,QAAQ,aACP,CAAC,QAAgB;AAChB,QAAI,OAAO,WAAW,aAAa;AACjC,YAAM,IAAI,MAAM,uFAAuF;AAAA,IACzG;AACA,WAAO,SAAS,OAAO,GAAG;AAAA,EAC5B;AACF,QAAM,WAAW,CAAC,YAAoB,oBAAoB,cACxD,GAAG,OAAO,GAAG,IAAI,oBAAoB,mBAAmB,oBAAoB,QAAQ,SAAS,IAAI,YAAY,GAAG,CAAC;AAEnH,SAAO;AAAA,IACL;AAAA,IACA,cAAc,MAAM;AAAA,IACpB;AAAA,IACA,iBAAiB,CAAC,EAAE,UAAA,MAA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,YAAY;AAAA,IAC7B;AAAA,IAEA,QAAQ,MAA6C;AACnD,YAAM,QAAA;AACN,YAAM,MAAM,kBAAkB,MAAM,EAAE,MAAM,SAAS,KAAK;AAC1D,aAAO;AACP,aAAO,MAAM;AACX,YAAI,QAAA;AACJ,YAAI,SAAS,IAAK,QAAO;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"BffStrategy.js","sources":["../../src/auth/BffStrategy.ts"],"sourcesContent":["import { createApiClient, type ApiAntiforgeryOptions, type ApiClientOptions } from '../foundation/http';\nimport { AppErrorFactory, ResultExtensions, type AppError, type Result } from '../foundation/results';\nimport type { SessionExpiredListener } from './AuthBridge';\nimport type { AuthResolveContext, AuthStrategy, AuthStrategyHost } from './AuthSession';\nimport { decodeBffSignOut, decodeBffSession, type BffUser } from './BffSession';\nimport { connectBffSession, type BffRefreshOptions, type BffSessionLink, type BffSyncOptions } from './BffSessionSync';\nimport { ReturnUrlExtensions } from './ReturnUrlExtensions';\n\n/** Defines the options for {@link createBffStrategy}. */\nexport interface CreateBffStrategyOptions {\n /** The route prefix of the BFF's auth endpoints. Default `/api/identity`. */\n readonly prefix?: string;\n\n /** The origin the auth endpoints live on. Default `''`: the SPA's own origin, the BFF's served shape. */\n readonly baseUrl?: string;\n\n /** The request header the CSRF token travels in. Default `X-Csrf-Token`. */\n readonly csrfHeaderName?: string;\n\n /** Sent with every auth request. Default is the browser's `same-origin`. */\n readonly credentials?: RequestCredentials;\n\n /** Replaces `fetch` — a mocked one in tests. */\n readonly fetch?: typeof globalThis.fetch;\n\n /** Navigates the page. Default `window.location.assign`; inject to drive the strategy without a DOM. */\n readonly navigate?: (url: string) => void;\n\n /** Cross-tab sync. Default on, over `BroadcastChannel` with a `storage`-event fallback; `false` turns it off. */\n readonly sync?: BffSyncOptions | false;\n\n /** Session refresh before `expiresAt` and on focus. Default on; `false` turns it off. */\n readonly refresh?: BffRefreshOptions | false;\n\n /** The clock refresh scheduling reads. Default `Date.now`. */\n readonly now?: () => number;\n}\n\n/** Defines the BFF strategy — an {@link AuthStrategy} plus the pieces the rest of the app wires. */\nexport interface BffStrategy extends AuthStrategy<BffUser, string | undefined> {\n /**\n * Feeds `createApiClient({ antiforgery })`, so every unsafe request echoes the session's CSRF token. The token\n * is read per request, so a refreshed session and a sign-out take effect at once.\n */\n readonly antiforgery: ApiAntiforgeryOptions;\n\n /** Reads the current CSRF token; `null` while signed out. */\n readonly getCsrfToken: () => string | null;\n\n /** Builds `{prefix}/sign-in?returnUrl=…` for a local path; a path that is not local falls back to `/`. */\n readonly signInUrl: (returnUrl?: string) => string;\n\n /**\n * Sends the person to sign-in with the page they were on. Subscribe it to the bridge:\n * `bridge.subscribeExpired(bff.redirectToSignIn)`.\n */\n readonly redirectToSignIn: SessionExpiredListener;\n}\n\n/**\n * Creates the BFF session strategy for an SPA served on its BFF's origin. The BFF owns the session cookie; the SPA\n * reads `GET {prefix}/session`, signs in by navigating to `{prefix}/sign-in?returnUrl=…`, and signs out with\n * `POST {prefix}/sign-out`, then navigates to the returned `endSessionUrl`.\n *\n * Its own HTTP client carries the auth calls, with no request scope — a sign-out must not cancel itself. The app's\n * client takes {@link BffStrategy.antiforgery} so its writes carry the CSRF token. Pair it with\n * `createAuthBridge({ getIdentity: BffSessionExtensions.identity })`.\n */\nexport function createBffStrategy(options: CreateBffStrategyOptions = {}): BffStrategy {\n const {\n prefix = '/api/identity',\n baseUrl = '',\n csrfHeaderName = 'X-Csrf-Token',\n sync = {},\n refresh = {},\n now = () => Date.now(),\n } = options;\n const root = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;\n\n let csrfToken: string | null = null;\n let generation = 0;\n let link: BffSessionLink | undefined;\n\n const antiforgery: ApiAntiforgeryOptions = { headerName: csrfHeaderName, getToken: () => csrfToken };\n const clientOptions: ApiClientOptions = {\n baseUrl,\n antiforgery,\n ...(options.credentials !== undefined ? { credentials: options.credentials } : {}),\n ...(options.fetch !== undefined ? { fetch: options.fetch } : {}),\n };\n const client = createApiClient(clientOptions);\n const cancelled = () => ResultExtensions.fail(AppErrorFactory.cancelled());\n\n const navigate =\n options.navigate ??\n ((url: string) => {\n if (typeof window === 'undefined') {\n throw new Error('createBffStrategy: navigating needs a browser. Pass `navigate` to drive it elsewhere.');\n }\n window.location.assign(url);\n });\n const signInUrl = (returnUrl: string = ReturnUrlExtensions.current()): string =>\n `${baseUrl}${root}/sign-in?returnUrl=${encodeURIComponent(ReturnUrlExtensions.isLocal(returnUrl) ? returnUrl : '/')}`;\n\n return {\n antiforgery,\n getCsrfToken: () => csrfToken,\n signInUrl,\n redirectToSignIn: ({ returnUrl }) => navigate(signInUrl(returnUrl)),\n\n async resolveUser(context: AuthResolveContext): Promise<Result<BffUser | null, AppError>> {\n const current = ++generation;\n const outcome = await client.get(`${root}/session`, { ...context, decode: decodeBffSession });\n if (current !== generation || context.signal?.aborted) return cancelled();\n if (!outcome.ok) {\n // A BFF answers a signed-out `GET /session` with 200; a 401 from a proxy in front still means signed out.\n if (outcome.failure.status !== 401) return outcome;\n csrfToken = null;\n return ResultExtensions.ok(null);\n }\n csrfToken = outcome.value.csrfToken;\n return ResultExtensions.ok(outcome.value.user);\n },\n\n // Returns void on purpose: the session stays as it is while the browser navigates to the BFF.\n signIn(returnUrl?: string): Result<void, AppError> {\n const target = returnUrl ?? ReturnUrlExtensions.current();\n if (!ReturnUrlExtensions.isLocal(target)) return ResultExtensions.fail(AppErrorFactory.validation());\n if (!options.navigate && typeof window === 'undefined')\n return ResultExtensions.fail(AppErrorFactory.unavailable());\n navigate(signInUrl(target));\n return ResultExtensions.ok(undefined);\n },\n\n async signOut(context: AuthResolveContext): Promise<Result<void, AppError>> {\n ++generation;\n try {\n // The token is read when the request is sent, so it must outlive the call and clear only afterwards.\n const outcome = await client.post(`${root}/sign-out`, { ...context, decode: decodeBffSignOut });\n if (!outcome.ok) {\n // A 401 means the server session was already gone: signed out either way, with no provider session to end.\n return outcome.failure.status === 401 ? ResultExtensions.ok(undefined) : outcome;\n }\n navigate(outcome.value.endSessionUrl);\n return ResultExtensions.ok(undefined);\n } finally {\n csrfToken = null;\n // Told after the server answered: a hint sent earlier would let a tab read the session before it ended.\n link?.announce('signed-out');\n }\n },\n\n onUnauthorized(): void {\n generation += 1;\n csrfToken = null;\n link?.announce('signed-out');\n },\n\n connect(host: AuthStrategyHost<BffUser>): () => void {\n link?.dispose();\n const own = connectBffSession(host, { sync, refresh, now });\n link = own;\n return () => {\n own.dispose();\n if (link === own) link = undefined;\n };\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AAoEO,SAAS,kBAAkB,UAAoC,IAAiB;AACrF,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,OAAO,CAAA;AAAA,IACP,UAAU,CAAA;AAAA,IACV,MAAM,MAAM,KAAK,IAAA;AAAA,EAAI,IACnB;AACJ,QAAM,OAAO,OAAO,SAAS,GAAG,IAAI,OAAO,MAAM,GAAG,EAAE,IAAI;AAE1D,MAAI,YAA2B;AAC/B,MAAI,aAAa;AACjB,MAAI;AAEJ,QAAM,cAAqC,EAAE,YAAY,gBAAgB,UAAU,MAAM,UAAA;AACzF,QAAM,gBAAkC;AAAA,IACtC;AAAA,IACA;AAAA,IACA,GAAI,QAAQ,gBAAgB,SAAY,EAAE,aAAa,QAAQ,YAAA,IAAgB,CAAA;AAAA,IAC/E,GAAI,QAAQ,UAAU,SAAY,EAAE,OAAO,QAAQ,UAAU,CAAA;AAAA,EAAC;AAEhE,QAAM,SAAS,gBAAgB,aAAa;AAC5C,QAAM,YAAY,MAAM,iBAAiB,KAAK,gBAAgB,WAAW;AAEzE,QAAM,WACJ,QAAQ,aACP,CAAC,QAAgB;AAChB,QAAI,OAAO,WAAW,aAAa;AACjC,YAAM,IAAI,MAAM,uFAAuF;AAAA,IACzG;AACA,WAAO,SAAS,OAAO,GAAG;AAAA,EAC5B;AACF,QAAM,YAAY,CAAC,YAAoB,oBAAoB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AAQ,MAAM,aAAa;AACpC,eAAO,iBAAiB,GAAG,MAAS;AAAA,MACtC,UAAA;AACE,oBAAY;AAEZ,cAAM,SAAS,YAAY;AAAA,MAC7B;AAAA,IACF;AAAA,IAEA,iBAAuB;AACrB,oBAAc;AACd,kBAAY;AACZ,YAAM,SAAS,YAAY;AAAA,IAC7B;AAAA,IAEA,QAAQ,MAA6C;AACnD,YAAM,QAAA;AACN,YAAM,MAAM,kBAAkB,MAAM,EAAE,MAAM,SAAS,KAAK;AAC1D,aAAO;AACP,aAAO,MAAM;AACX,YAAI,QAAA;AACJ,YAAI,SAAS,IAAK,QAAO;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAEJ;"}
@@ -7,6 +7,6 @@ export { createBearerStrategy, type CreateBearerStrategyOptions, type BearerStra
7
7
  export { createRedirectStrategy, type CreateRedirectStrategyOptions } from './RedirectStrategy';
8
8
  export { createMemoryTokenStorage, type TokenStorage } from './TokenStorage';
9
9
  export { createBffStrategy, type BffStrategy, type CreateBffStrategyOptions } from './BffStrategy';
10
- export { BffSessionExtensions, decodeBffSession, decodeBffLogout, type BffUser, type BffPerson, type BffOrganization, type BffSessionSnapshot, type BffLogout, } from './BffSession';
10
+ export { BffSessionExtensions, decodeBffSession, decodeBffSignOut, type BffUser, type BffPerson, type BffOrganization, type BffSessionSnapshot, type BffSignOut, } from './BffSession';
11
11
  export { BffSyncKind, type BffSyncMessage, type BffSyncOptions, type BffRefreshOptions } from './BffSessionSync';
12
12
  export { useBffAuth, type BffAuthApi } from './UseBffAuth';
@@ -7,7 +7,7 @@ import { createBearerStrategy } from "./BearerStrategy.js";
7
7
  import { createRedirectStrategy } from "./RedirectStrategy.js";
8
8
  import { createMemoryTokenStorage } from "./TokenStorage.js";
9
9
  import { createBffStrategy } from "./BffStrategy.js";
10
- import { BffSessionExtensions, decodeBffLogout, decodeBffSession } from "./BffSession.js";
10
+ import { BffSessionExtensions, decodeBffSession, decodeBffSignOut } from "./BffSession.js";
11
11
  import { BffSyncKind } from "./BffSessionSync.js";
12
12
  import { useBffAuth } from "./UseBffAuth.js";
13
13
  export {
@@ -21,8 +21,8 @@ export {
21
21
  createCookieStrategy,
22
22
  createMemoryTokenStorage,
23
23
  createRedirectStrategy,
24
- decodeBffLogout,
25
24
  decodeBffSession,
25
+ decodeBffSignOut,
26
26
  useAuth,
27
27
  useBffAuth
28
28
  };
@@ -13,5 +13,11 @@ export interface StorageBroker {
13
13
  * swallowed. Never throws, so a caller never has to guard the storage call.
14
14
  */
15
15
  export declare const localStorageStorageBroker: StorageBroker;
16
+ /**
17
+ * The tab-scoped broker — the {@link localStorageStorageBroker} contract over the browser's `sessionStorage`: the value
18
+ * lives as long as the tab, survives its reloads, and is never shared with another tab, so nothing syncs across tabs.
19
+ * SSR-safe and failure-tolerant the same way; never throws.
20
+ */
21
+ export declare const sessionStorageStorageBroker: StorageBroker;
16
22
  /** Builds an isolated in-memory `StorageBroker` backed by a `Map` — the test double: no cross-tab sync, no DOM. */
17
23
  export declare function memoryStorageBroker(): StorageBroker;
@@ -1,45 +1,49 @@
1
- function resolveLocalStorage() {
1
+ function resolveWebStorage(area) {
2
2
  if (typeof window === "undefined") return null;
3
3
  try {
4
- return window.localStorage;
4
+ return window[area] ?? null;
5
5
  } catch {
6
6
  return null;
7
7
  }
8
8
  }
9
- const localStorageStorageBroker = {
10
- read(key) {
11
- const store = resolveLocalStorage();
12
- if (store === null) return null;
13
- try {
14
- const raw = store.getItem(key);
15
- return raw === null ? null : JSON.parse(raw);
16
- } catch {
17
- return null;
18
- }
19
- },
20
- write(key, value) {
21
- const store = resolveLocalStorage();
22
- if (store === null) return false;
23
- try {
24
- const serialized = JSON.stringify(value);
25
- if (serialized === void 0) return false;
26
- store.setItem(key, serialized);
27
- return true;
28
- } catch {
29
- return false;
30
- }
31
- },
32
- remove(key) {
33
- const store = resolveLocalStorage();
34
- if (store === null) return false;
35
- try {
36
- store.removeItem(key);
37
- return true;
38
- } catch {
39
- return false;
9
+ function webStorageBroker(area) {
10
+ return {
11
+ read(key) {
12
+ const store = resolveWebStorage(area);
13
+ if (store === null) return null;
14
+ try {
15
+ const raw = store.getItem(key);
16
+ return raw === null ? null : JSON.parse(raw);
17
+ } catch {
18
+ return null;
19
+ }
20
+ },
21
+ write(key, value) {
22
+ const store = resolveWebStorage(area);
23
+ if (store === null) return false;
24
+ try {
25
+ const serialized = JSON.stringify(value);
26
+ if (serialized === void 0) return false;
27
+ store.setItem(key, serialized);
28
+ return true;
29
+ } catch {
30
+ return false;
31
+ }
32
+ },
33
+ remove(key) {
34
+ const store = resolveWebStorage(area);
35
+ if (store === null) return false;
36
+ try {
37
+ store.removeItem(key);
38
+ return true;
39
+ } catch {
40
+ return false;
41
+ }
40
42
  }
41
- }
42
- };
43
+ };
44
+ }
45
+ const localStorageStorageBroker = webStorageBroker("localStorage");
46
+ const sessionStorageStorageBroker = webStorageBroker("sessionStorage");
43
47
  function memoryStorageBroker() {
44
48
  const store = /* @__PURE__ */ new Map();
45
49
  return {
@@ -70,6 +74,7 @@ function memoryStorageBroker() {
70
74
  }
71
75
  export {
72
76
  localStorageStorageBroker,
73
- memoryStorageBroker
77
+ memoryStorageBroker,
78
+ sessionStorageStorageBroker
74
79
  };
75
80
  //# sourceMappingURL=StorageBroker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StorageBroker.js","sources":["../../../src/foundation/storage/StorageBroker.ts"],"sourcesContent":["// Generic, domain-agnostic client-side persistence seam. A `StorageBroker` is the sole surface the\n// persistence hooks touch, so a component tree can swap `localStorage` for an in-memory map (tests) or a\n// no-op (SSR) without any hook change. JSON is the wire format; every method is failure-tolerant — a quota,\n// serialization, or parse error degrades to a miss, never a throw.\n\n/** Defines a JSON key/value persistence seam the storage hooks read and write through. */\nexport interface StorageBroker {\n /** Reads and parses the value stored under `key`, or null when absent or unreadable. */\n read<T>(key: string): T | null;\n\n /** Serializes and writes `value`; reports false when storage or serialization is unavailable. */\n write<T>(key: string, value: T): boolean;\n\n /** Removes any value stored under `key`; reports false when storage is unavailable. */\n remove(key: string): boolean;\n}\n\n/** Resolves the ambient `localStorage`, or null when unavailable — SSR, private mode, security exception. */\nfunction resolveLocalStorage(): Storage | null {\n // `typeof window === 'undefined'` guards SSR; the try/catch guards a `localStorage` getter that throws\n // (Safari private mode, sandboxed iframes) rather than merely being absent.\n if (typeof window === 'undefined') return null;\n\n try {\n return window.localStorage;\n } catch {\n return null;\n }\n}\n\n/**\n * The production broker — persists through the browser's `localStorage` as JSON, SSR-safe and failure-tolerant.\n * A read that is absent, malformed, or blocked returns null; a write that exceeds quota or fails to serialize is\n * swallowed. Never throws, so a caller never has to guard the storage call.\n */\nexport const localStorageStorageBroker: StorageBroker = {\n read<T>(key: string): T | null {\n const store = resolveLocalStorage();\n if (store === null) return null;\n\n try {\n const raw = store.getItem(key);\n return raw === null ? null : (JSON.parse(raw) as T);\n } catch {\n return null;\n }\n },\n\n write<T>(key: string, value: T): boolean {\n const store = resolveLocalStorage();\n if (store === null) return false;\n\n try {\n const serialized = JSON.stringify(value);\n if (serialized === undefined) return false;\n store.setItem(key, serialized);\n return true;\n } catch {\n return false;\n }\n },\n\n remove(key: string): boolean {\n const store = resolveLocalStorage();\n if (store === null) return false;\n\n try {\n store.removeItem(key);\n return true;\n } catch {\n return false;\n }\n },\n};\n\n/** Builds an isolated in-memory `StorageBroker` backed by a `Map` — the test double: no cross-tab sync, no DOM. */\nexport function memoryStorageBroker(): StorageBroker {\n const store = new Map<string, string>();\n\n return {\n read<T>(key: string): T | null {\n const raw = store.get(key);\n if (raw === undefined) return null;\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n return null;\n }\n },\n\n write<T>(key: string, value: T): boolean {\n try {\n const serialized = JSON.stringify(value);\n if (serialized === undefined) return false;\n store.set(key, serialized);\n return true;\n } catch {\n return false;\n }\n },\n\n remove(key: string): boolean {\n store.delete(key);\n return true;\n },\n };\n}\n"],"names":[],"mappings":"AAkBA,SAAS,sBAAsC;AAG7C,MAAI,OAAO,W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AAA,IACF;AAAA,IAEA,OAAO,KAAsB;AAC3B,YAAM,OAAO,GAAG;AAChB,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"StorageBroker.js","sources":["../../../src/foundation/storage/StorageBroker.ts"],"sourcesContent":["// Generic, domain-agnostic client-side persistence seam. A `StorageBroker` is the sole surface the\n// persistence hooks touch, so a component tree can swap `localStorage` for an in-memory map (tests) or a\n// no-op (SSR) without any hook change. JSON is the wire format; every method is failure-tolerant — a quota,\n// serialization, or parse error degrades to a miss, never a throw.\n\n/** Defines a JSON key/value persistence seam the storage hooks read and write through. */\nexport interface StorageBroker {\n /** Reads and parses the value stored under `key`, or null when absent or unreadable. */\n read<T>(key: string): T | null;\n\n /** Serializes and writes `value`; reports false when storage or serialization is unavailable. */\n write<T>(key: string, value: T): boolean;\n\n /** Removes any value stored under `key`; reports false when storage is unavailable. */\n remove(key: string): boolean;\n}\n\n/** Names a Web Storage area on `window`: `localStorage` outlives the tab, `sessionStorage` ends with it. */\ntype WebStorageArea = 'localStorage' | 'sessionStorage';\n\n/** Resolves the ambient storage `area`, or null when unavailable — SSR, private mode, security exception. */\nfunction resolveWebStorage(area: WebStorageArea): Storage | null {\n // `typeof window === 'undefined'` guards SSR; the try/catch guards a storage getter that throws\n // (Safari private mode, sandboxed iframes, blocked site data) rather than merely being absent.\n if (typeof window === 'undefined') return null;\n\n try {\n return window[area] ?? null;\n } catch {\n return null;\n }\n}\n\n/** Builds a JSON broker over one Web Storage area, resolved per call and never cached: a blocked store is a miss. */\nfunction webStorageBroker(area: WebStorageArea): StorageBroker {\n return {\n read<T>(key: string): T | null {\n const store = resolveWebStorage(area);\n if (store === null) return null;\n\n try {\n const raw = store.getItem(key);\n return raw === null ? null : (JSON.parse(raw) as T);\n } catch {\n return null;\n }\n },\n\n write<T>(key: string, value: T): boolean {\n const store = resolveWebStorage(area);\n if (store === null) return false;\n\n try {\n const serialized = JSON.stringify(value);\n if (serialized === undefined) return false;\n store.setItem(key, serialized);\n return true;\n } catch {\n return false;\n }\n },\n\n remove(key: string): boolean {\n const store = resolveWebStorage(area);\n if (store === null) return false;\n\n try {\n store.removeItem(key);\n return true;\n } catch {\n return false;\n }\n },\n };\n}\n\n/**\n * The production broker — persists through the browser's `localStorage` as JSON, SSR-safe and failure-tolerant.\n * A read that is absent, malformed, or blocked returns null; a write that exceeds quota or fails to serialize is\n * swallowed. Never throws, so a caller never has to guard the storage call.\n */\nexport const localStorageStorageBroker: StorageBroker = webStorageBroker('localStorage');\n\n/**\n * The tab-scoped broker — the {@link localStorageStorageBroker} contract over the browser's `sessionStorage`: the value\n * lives as long as the tab, survives its reloads, and is never shared with another tab, so nothing syncs across tabs.\n * SSR-safe and failure-tolerant the same way; never throws.\n */\nexport const sessionStorageStorageBroker: StorageBroker = webStorageBroker('sessionStorage');\n\n/** Builds an isolated in-memory `StorageBroker` backed by a `Map` — the test double: no cross-tab sync, no DOM. */\nexport function memoryStorageBroker(): StorageBroker {\n const store = new Map<string, string>();\n\n return {\n read<T>(key: string): T | null {\n const raw = store.get(key);\n if (raw === undefined) return null;\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n return null;\n }\n },\n\n write<T>(key: string, value: T): boolean {\n try {\n const serialized = JSON.stringify(value);\n if (serialized === undefined) return false;\n store.set(key, serialized);\n return true;\n } catch {\n return false;\n }\n },\n\n remove(key: string): boolean {\n store.delete(key);\n return true;\n },\n };\n}\n"],"names":[],"mappings":"AAqBA,SAAS,kBAAkB,MAAsC;AAG/D,MAAI,OAAO,WAAW,YAAa,QAAO;AAE1C,MAAI;AACF,WAAO,OAAO,IAAI,KAAK;AAAA,EACzB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,SAAS,iBAAiB,MAAqC;AAC7D,SAAO;AAAA,IACL,KAAQ,KAAuB;AAC7B,YAAM,QAAQ,kBAAkB,IAAI;AACpC,UAAI,UAAU,KAAM,QAAO;AAE3B,UAAI;AACF,cAAM,MAAM,MAAM,QAAQ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type StorageBroker, localStorageStorageBroker, memoryStorageBroker } from './StorageBroker';
1
+ export { type StorageBroker, localStorageStorageBroker, memoryStorageBroker, sessionStorageStorageBroker, } from './StorageBroker';
2
2
  export { namespacedBroker } from './NamespacedBroker';
3
3
  export { type PersistentDecoder, type PersistentRefOptions, createPersistentRef } from './PersistentRef';
4
4
  export { type Migration, type MigrationMap, type VersionedStore, type VersionedStoreOptions, createVersionedStore, } from './VersionedStore';
@@ -1,4 +1,4 @@
1
- import { localStorageStorageBroker, memoryStorageBroker } from "./StorageBroker.js";
1
+ import { localStorageStorageBroker, memoryStorageBroker, sessionStorageStorageBroker } from "./StorageBroker.js";
2
2
  import { namespacedBroker } from "./NamespacedBroker.js";
3
3
  import { createPersistentRef } from "./PersistentRef.js";
4
4
  import { createVersionedStore } from "./VersionedStore.js";
@@ -12,6 +12,7 @@ export {
12
12
  memoryStorageBroker,
13
13
  namespacedBroker,
14
14
  prependRecent,
15
+ sessionStorageStorageBroker,
15
16
  useAutosave,
16
17
  usePersistentState,
17
18
  useRecentItems
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshButton.vue.js","sources":["../../../../src/presentation/actions/refreshButton/RefreshButton.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ButtonProps } from '../button';\n\n/** @internal The `ButtonProps` this preset decides itself. */\ntype OwnedButtonProp = keyof Pick<ButtonProps, 'isLoading' | 'shape' | 'leadingSlot'>;\n\n/** Defines the forwarded `ButtonProps`, minus the ones the refresh preset sets. */\ntype RefreshButtonAttributes = Omit<ButtonProps, OwnedButtonProp>;\n\n/** Defines props for the one refresh control a region shows. */\nexport interface RefreshButtonProps extends /* @vue-ignore */ RefreshButtonAttributes {\n /** True from the click until the refresh settles — `useRefresh`'s `refreshing`; the icon spins and clicks wait. */\n readonly isRefreshing?: boolean;\n\n /** The visible label, or the accessible name of an icon-only button. Default `\"Refresh\"`, localized. */\n readonly label?: string;\n\n /** Renders the icon alone, square at its size, named by `label`. */\n readonly isIconOnly?: boolean;\n\n /** The visual surface style. Default `outline`; `ghost` inside a panel header. */\n readonly variant?: ButtonProps['variant'];\n\n /** The size step. Default `sm`; `md` beside page-level controls. */\n readonly size?: ButtonProps['size'];\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\nimport { RefreshCw } from 'lucide-vue-next';\nimport { useLocaleDefaults } from '../../../foundation/i18n';\nimport { Icon } from '../../../foundation/icons';\nimport Button from '../button/Button.vue';\n\n/**\n * Renders the refresh control a region reruns its reads with — a `Button` preset that swaps the refresh icon for the\n * spinner while `isRefreshing`, keeps its label and width, and swallows repeat clicks until the refresh settles. Pair\n * it with `useRefresh` from `@wow-two-beta/fe/query`, which also drives the region's placeholders.\n */\ndefineOptions({ name: 'RefreshButton', inheritAttrs: false });\n\nconst componentProps = withDefaults(defineProps<RefreshButtonProps>(), {\n isRefreshing: false,\n label: undefined,\n isIconOnly: false,\n variant: 'outline',\n size: 'sm',\n});\nconst props = useLocaleDefaults(componentProps, 'RefreshButton', { label: 'Refresh' });\n\nconst attrs = useAttrs();\n\n/** The icon-only form names itself through `aria-label`, and `title` shows the name on hover. */\nconst naming = computed(() =>\n props.isIconOnly ? { 'aria-label': props.label, title: props.label } : ({} as Record<string, string>),\n);\n</script>\n\n<template>\n <Button\n tone=\"neutral\"\n :variant=\"props.variant\"\n :size=\"props.size\"\n :shape=\"props.isIconOnly ? 'square' : 'default'\"\n :is-loading=\"props.isRefreshing\"\n v-bind=\"{ ...naming, ...attrs }\"\n >\n <template #leading><Icon :icon=\"RefreshCw\" :size=\"14\" /></template>\n <template v-if=\"!props.isIconOnly\">{{ props.label }}</template>\n </Button>\n</template>\n"],"names":["_openBlock","_createBlock","Button","_mergeProps","_unref","_createVNode","Icon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;AA0CA,UAAM,iBAAiB;AAOvB,UAAM,QAAQ,kBAAkB,gBAAgB,iBAAiB,EAAE,OAAO,WAAW;AAErF,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS;AAAA,MAAS,MACtB,MAAM,aAAa,EAAE,cAAc,MAAM,OAAO,OAAO,MAAM,UAAW,CAAA;AAAA,IAAC;;AAKzE,aAAAA,UAAA,GAAAC,YAUSC,aAVTC,WAUS;AAAA,QATP,MAAK;AAAA,QACJ,SAASC,MAAA,KAAA,EAAM;AAAA,QACf,MAAMA,MAAA,KAAA,EAAM;AAAA,QACZ,OAAOA,MAAA,KAAA,EAAM,aAAU,WAAA;AAAA,QACvB,cAAYA,MAAA,KAAA,EAAM;AAAA,MAAA,GACN,EAAA,GAAA,OAAA,UAAWA,MAAA,KAAA,EAAA,CAAK,GAAA;AAAA,QAElB,iBAAQ,MAAqC;AAAA,UAArCC,YAAqCD,MAAAE,WAAA,GAAA;AAAA,YAA9B,MAAMF,MAAA,SAAA;AAAA,YAAY,MAAM;AAAA,UAAA;;yBATuC,MAGjF;AAAA,UAOS,CAAAA,MAAA,KAAA,EAAM,2BAAvBG,mBAA+DC,UAAA,EAAA,KAAA,KAAA;AAAA,YAAzBC,gBAAAC,gBAAAN,MAAA,KAAA,EAAM,KAAK,GAAA,CAAA;AAAA,UAAA;;;;;;;"}
1
+ {"version":3,"file":"RefreshButton.vue.js","sources":["../../../../src/presentation/actions/refreshButton/RefreshButton.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ButtonProps } from '../button';\n\n/** @internal The `ButtonProps` this preset decides itself. */\ntype OwnedButtonProp = keyof Pick<ButtonProps, 'isLoading' | 'shape' | 'leadingSlot'>;\n\n/** Defines the forwarded `ButtonProps`, minus the ones the refresh preset sets. */\ntype RefreshButtonAttributes = Omit<ButtonProps, OwnedButtonProp>;\n\n/** Defines props for the one refresh control a region shows. */\nexport interface RefreshButtonProps extends /* @vue-ignore */ RefreshButtonAttributes {\n /** True from the click until the refresh settles — `useRefresh`'s `refreshing`; the icon spins and clicks wait. */\n readonly isRefreshing?: boolean;\n\n /** The visible label, or the accessible name of an icon-only button. Default `\"Refresh\"`, localized. */\n readonly label?: string;\n\n /** Renders the icon alone, square at its size, named by `label`. */\n readonly isIconOnly?: boolean;\n\n /** The visual surface style. Default `outline`; `ghost` inside a panel header. */\n readonly variant?: ButtonProps['variant'];\n\n /** The size step. Default `sm`; `md` beside page-level controls. */\n readonly size?: ButtonProps['size'];\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\nimport { RefreshCw } from 'lucide-vue-next';\nimport { useLocaleDefaults } from '../../../foundation/i18n';\nimport { Icon } from '../../../foundation/icons';\nimport Button from '../button/Button.vue';\n\n/**\n * Renders the refresh control a region reruns its reads with — a `Button` preset that swaps the refresh icon for the\n * spinner while `isRefreshing`, keeps its label and width, and swallows repeat clicks until the refresh settles. Pair\n * it with `useRefresh` from `@wow-two-beta/fe/query`, which also drives the region's placeholders.\n */\ndefineOptions({ name: 'RefreshButton', inheritAttrs: false });\n\nconst componentProps = withDefaults(defineProps<RefreshButtonProps>(), {\n isRefreshing: false,\n label: undefined,\n isIconOnly: false,\n variant: 'outline',\n size: 'sm',\n});\nconst props = useLocaleDefaults(componentProps, 'RefreshButton', { label: 'Refresh' });\n\nconst attrs = useAttrs();\n\n/** The icon-only form names itself through `aria-label`, and `title` shows the name on hover. */\nconst naming = computed(() =>\n props.isIconOnly ? { 'aria-label': props.label, title: props.label } : ({} as Record<string, string>),\n);\n</script>\n\n<template>\n <Button\n tone=\"neutral\"\n :variant=\"props.variant\"\n :size=\"props.size\"\n :shape=\"props.isIconOnly ? 'square' : 'default'\"\n :is-loading=\"props.isRefreshing\"\n v-bind=\"{ ...naming, ...attrs }\"\n >\n <template #leading><Icon :icon=\"RefreshCw\" :size=\"14\" /></template>\n <template v-if=\"!props.isIconOnly\">{{ props.label }}</template>\n </Button>\n</template>\n"],"names":["_openBlock","_createBlock","Button","_mergeProps","_unref","_createVNode","Icon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;AA0CA,UAAM,iBAAiB;AAOvB,UAAM,QAAQ,kBAAkB,gBAAgB,iBAAiB,EAAE,OAAO,WAAW;AAErF,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS;AAAA,MAAS,MACtB,MAAM,aAAa,EAAE,cAAc,MAAM,OAAO,OAAO,MAAM,UAAW,CAAA;AAAA,IAAC;;AAKzE,aAAAA,UAAA,GAAAC,YAUSC,aAVTC,WAUS;AAAA,QATP,MAAK;AAAA,QACJ,SAASC,MAAA,KAAA,EAAM;AAAA,QACf,MAAMA,MAAA,KAAA,EAAM;AAAA,QACZ,OAAOA,MAAA,KAAA,EAAM,aAAU,WAAA;AAAA,QACvB,cAAYA,MAAA,KAAA,EAAM;AAAA,MAAA,GACN,EAAA,GAAA,OAAA,UAAWA,MAAA,KAAA,EAAA,CAAK,GAAA;AAAA,QAElB,iBAAQ,MAAqC;AAAA,UAArCC,YAAqCD,MAAAE,WAAA,GAAA;AAAA,YAA9B,MAAMF,MAAA,SAAA;AAAA,YAAY,MAAM;AAAA,UAAA;;yBAClD,MAA+D;AAAA,UAA9C,CAAAA,MAAA,KAAA,EAAM,2BAAvBG,mBAA+DC,UAAA,EAAA,KAAA,KAAA;AAAA,YAAzBC,gBAAAC,gBAAAN,MAAA,KAAA,EAAM,KAAK,GAAA,CAAA;AAAA,UAAA;;;;;;;"}
@@ -32,8 +32,11 @@ export interface AccountMenuProps {
32
32
  readonly name?: string;
33
33
  /** The header's second line — the email or the role. */
34
34
  readonly description?: string;
35
- /** The avatar image. Without it, or when it fails, the avatar shows the name's initials. */
36
- readonly avatarSrc?: string;
35
+ /**
36
+ * The avatar image — a BFF session's `person.picture` binds as is. Without it (`null` included), or when it fails,
37
+ * the avatar shows the name's initials, or the person glyph without a name.
38
+ */
39
+ readonly avatarSrc?: string | null;
37
40
  /** The open state, controlled. The `v-model:open` binding target. */
38
41
  readonly open?: boolean;
39
42
  /** The initial open state when uncontrolled. Default `false`. */
@@ -113,7 +116,7 @@ declare const _default: __VLS_WithSlots<import('vue').DefineComponent<AccountMen
113
116
  readonly organization: string;
114
117
  readonly isBusy: boolean;
115
118
  readonly triggerLabel: string;
116
- readonly avatarSrc: string;
119
+ readonly avatarSrc: string | null;
117
120
  readonly showAppearance: boolean;
118
121
  readonly locales: ReadonlyArray<AccountMenuLocale>;
119
122
  readonly organizations: ReadonlyArray<AccountMenuOrganization>;
@@ -1,4 +1,4 @@
1
- import { defineComponent, useSlots, useAttrs, useTemplateRef, inject, computed, watch, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, mergeProps, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createTextVNode, Fragment, renderList, renderSlot } from "vue";
1
+ import { defineComponent, useSlots, useAttrs, useTemplateRef, inject, computed, watch, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, mergeProps, createSlots, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createTextVNode, Fragment, renderList, renderSlot } from "vue";
2
2
  import { Monitor, Sun, Moon, UserRound, ChevronDown, Check, LogOut } from "lucide-vue-next";
3
3
  import { dataAttr } from "../../../foundation/dom/DataAttr.js";
4
4
  import { useLocale } from "../../../foundation/i18n/providers/LocaleContext.js";
@@ -131,6 +131,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
131
131
  if (blocked && isOpen.value) controlled.setValue(false);
132
132
  });
133
133
  const hasName = computed(() => (props.name ?? "").trim() !== "");
134
+ const pictureSrc = computed(() => {
135
+ const src = (props.avatarSrc ?? "").trim();
136
+ return src === "" ? void 0 : src;
137
+ });
134
138
  const triggerName = computed(() => {
135
139
  if (!hasName.value) return props.anonymousTriggerLabel;
136
140
  const name = (props.name ?? "").trim();
@@ -228,15 +232,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
228
232
  disabled: isBlocked.value,
229
233
  "data-busy": unref(dataAttr)(unref(props).isBusy)
230
234
  }, rest.value, { class: triggerClasses.value }), [
231
- hasName.value ? (openBlock(), createBlock(_sfc_main$3, {
235
+ hasName.value || pictureSrc.value ? (openBlock(), createBlock(_sfc_main$3, {
232
236
  key: 0,
233
- name: unref(props).name,
234
- src: unref(props).avatarSrc,
237
+ name: hasName.value ? unref(props).name : void 0,
238
+ src: pictureSrc.value,
235
239
  alt: "",
236
240
  size: "sm",
237
241
  "is-loading": unref(props).isBusy,
238
242
  "data-account-menu-avatar": ""
239
- }, null, 8, ["name", "src", "is-loading"])) : (openBlock(), createElementBlock("span", _hoisted_2, [
243
+ }, createSlots({ _: 2 }, [
244
+ !hasName.value ? {
245
+ name: "fallback",
246
+ fn: withCtx(() => [
247
+ createVNode(unref(_sfc_main$4), {
248
+ icon: unref(UserRound),
249
+ size: 18
250
+ }, null, 8, ["icon"])
251
+ ]),
252
+ key: "0"
253
+ } : void 0
254
+ ]), 1032, ["name", "src", "is-loading"])) : (openBlock(), createElementBlock("span", _hoisted_2, [
240
255
  createVNode(unref(_sfc_main$4), {
241
256
  icon: unref(UserRound),
242
257
  size: 18
@@ -1 +1 @@
1
- {"version":3,"file":"AccountMenu.vue.js","sources":["../../../../src/presentation/nav/accountMenu/AccountMenu.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { HTMLAttributes } from 'vue';\nimport type { Placement } from '@floating-ui/vue';\nimport type { SurfaceVariant } from '../../../foundation/styles';\n\n/** Represents one interface language an `AccountMenu` offers. */\nexport interface AccountMenuLocale {\n /** The locale tag the `locale` model holds — `uz`, `ru`, `en-GB`; also the row's `lang`. */\n readonly value: string;\n\n /** The language's own name in its own language — `O‘zbekcha`, `Русский`, `English`. */\n readonly label: string;\n}\n\n/** Represents one organization the signed-in person belongs to. */\nexport interface AccountMenuOrganization {\n /** The stable identity the `organization` model holds. */\n readonly id: string;\n\n /** The organization name, already translated. */\n readonly label: string;\n\n /** One muted line beside the name — the person's role there, already translated. */\n readonly description?: string;\n}\n\n/** Represents one running service whose version the menu reports. */\nexport interface AccountMenuVersion {\n /** The service name, already translated — `Catalogue`, `API`. */\n readonly label: string;\n\n /** The running version — `0.1.3`, or the caller's translated placeholder while it loads. */\n readonly version: string;\n\n /** The commit the service was built from; the menu shows its first seven characters. */\n readonly commit?: string;\n}\n\n/** Defines props for the avatar menu that ends an app's top bar. */\nexport interface AccountMenuProps {\n /** The signed-in person's display name. Omitted, the trigger shows a person glyph and the header hides. */\n readonly name?: string;\n\n /** The header's second line — the email or the role. */\n readonly description?: string;\n\n /** The avatar image. Without it, or when it fails, the avatar shows the name's initials. */\n readonly avatarSrc?: string;\n\n /** The open state, controlled. The `v-model:open` binding target. */\n readonly open?: boolean;\n\n /** The initial open state when uncontrolled. Default `false`. */\n readonly defaultOpen?: boolean;\n\n /** The Floating UI placement. Default `bottom-end`, for a trigger at the end of the bar. */\n readonly placement?: Placement;\n\n /** The disabled state — the trigger cannot open the menu, and an open menu closes. */\n readonly isDisabled?: boolean;\n\n /** The busy state — a session or sign-out in flight; blocks the trigger like `isDisabled` and marks it busy. */\n readonly isBusy?: boolean;\n\n /** The appearance toggle — the system, light and dark rows. Default `true`; needs a `ColorModeProvider`. */\n readonly showAppearance?: boolean;\n\n /** The interface languages, in display order. Fewer than two hide the language rows. */\n readonly locales?: ReadonlyArray<AccountMenuLocale>;\n\n /** The current interface language's `value`. The `v-model:locale` binding target. */\n readonly locale?: string;\n\n /** The person's organizations, in display order. Fewer than two hide the switcher. */\n readonly organizations?: ReadonlyArray<AccountMenuOrganization>;\n\n /** The current organization's `id`. The `v-model:organization` binding target. */\n readonly organization?: string;\n\n /** Every running service's version, in display order — the frontend first, then each backend service. */\n readonly versions?: ReadonlyArray<AccountMenuVersion>;\n\n /**\n * Fires when the reader picks sign out.\n *\n * Kept a PROP, not an emit: its presence renders the sign-out row, and Vue strips a declared emit's\n * listener out of `useAttrs()`, so an emit could never be detected. Bind it as `@sign-out`.\n */\n readonly onSignOut?: () => unknown;\n\n /** The menu's accessible name. Default `\"Account\"`, localized. */\n readonly menuLabel?: string;\n\n /** The trigger's accessible name; `{name}` becomes the name. Default `\"Account menu for {name}\"`, localized. */\n readonly triggerLabel?: string;\n\n /** The trigger's accessible name without a `name`. Default `\"Account menu\"`, localized. */\n readonly anonymousTriggerLabel?: string;\n\n /** The appearance group heading. Default `\"Appearance\"`, localized. */\n readonly appearanceLabel?: string;\n\n /** The row that follows the device setting. Default `\"System\"`, localized. */\n readonly systemModeLabel?: string;\n\n /** The light row. Default `\"Light\"`, localized. */\n readonly lightModeLabel?: string;\n\n /** The dark row. Default `\"Dark\"`, localized. */\n readonly darkModeLabel?: string;\n\n /** The language group heading. Default `\"Language\"`, localized. */\n readonly languageLabel?: string;\n\n /** The organization group heading. Default `\"Organization\"`, localized. */\n readonly organizationLabel?: string;\n\n /** The versions group heading. Default `\"Versions\"`, localized. */\n readonly versionsLabel?: string;\n\n /** The sign-out row. Default `\"Sign out\"`, localized. */\n readonly signOutLabel?: string;\n\n /** The panel's surface recipe — `glass` or `glass-outline` for translucent chrome. Default the menu's own. */\n readonly variant?: SurfaceVariant;\n\n /** The panel class — the hook for an app's own material. */\n readonly panelClass?: HTMLAttributes['class'];\n}\n\n/** @internal The appearance rows' values; `system` hands the mode back to the device. */\nconst Appearance = {\n System: 'system',\n Light: 'light',\n Dark: 'dark',\n} as const;\n\ntype Appearance = (typeof Appearance)[keyof typeof Appearance];\n\n/** @internal The visible length of a commit hash. */\nconst CommitLength = 7;\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, inject, useAttrs, useTemplateRef, watch } from 'vue';\nimport type { ClassValue } from 'clsx';\nimport { Check, ChevronDown, LogOut, Monitor, Moon, Sun, UserRound } from 'lucide-vue-next';\nimport { dataAttr } from '../../../foundation/dom';\nimport { Icon, type IconAdapter } from '../../../foundation/icons';\nimport { useLocale, useLocaleDefaults } from '../../../foundation/i18n';\nimport { useId } from '../../../foundation/identifiers';\nimport { ColorMode, ColorModeKey } from '../../../foundation/primitives';\nimport { useControlled } from '../../../foundation/state';\nimport { cn } from '../../../foundation/styles';\nimport Avatar from '../../display/avatar/Avatar.vue';\nimport DropdownMenu from '../dropdownMenu/DropdownMenu.vue';\nimport DropdownMenuContent from '../dropdownMenu/DropdownMenuContent.vue';\nimport DropdownMenuTrigger from '../dropdownMenu/DropdownMenuTrigger.vue';\nimport MenuGroup from '../menu/MenuGroup.vue';\nimport MenuItem from '../menu/MenuItem.vue';\nimport MenuRadioGroup from '../menu/MenuRadioGroup.vue';\nimport MenuRadioItem from '../menu/MenuRadioItem.vue';\nimport MenuSeparator from '../menu/MenuSeparator.vue';\n\n/**\n * Renders the account menu that ends an app's top bar: an avatar trigger that opens who is signed in, the\n * organization switcher, the caller's account destinations, the colour mode, the interface language, each\n * service's version and sign out — always last.\n */\ndefineOptions({ name: 'AccountMenu', inheritAttrs: false });\n\nconst slots = defineSlots<{\n /** The account-level destinations — `MenuItem` rows such as account settings, placed after the switcher. */\n items?(): unknown;\n}>();\n\nconst componentProps = withDefaults(defineProps<AccountMenuProps>(), {\n name: undefined,\n description: undefined,\n avatarSrc: undefined,\n open: undefined,\n defaultOpen: false,\n placement: 'bottom-end',\n isDisabled: false,\n isBusy: false,\n showAppearance: true,\n locales: () => [],\n locale: undefined,\n organizations: () => [],\n organization: undefined,\n versions: () => [],\n onSignOut: undefined,\n triggerLabel: undefined,\n variant: undefined,\n panelClass: undefined,\n});\n\nconst props = useLocaleDefaults(componentProps, 'AccountMenu', {\n menuLabel: 'Account',\n anonymousTriggerLabel: 'Account menu',\n appearanceLabel: 'Appearance',\n systemModeLabel: 'System',\n lightModeLabel: 'Light',\n darkModeLabel: 'Dark',\n languageLabel: 'Language',\n organizationLabel: 'Organization',\n versionsLabel: 'Versions',\n signOutLabel: 'Sign out',\n});\n\nconst emit = defineEmits<{\n /** Fires when the menu opens or closes — the `v-model:open` half. */\n 'update:open': [open: boolean];\n\n /** Fires when the reader picks another interface language — the `v-model:locale` half. */\n 'update:locale': [locale: string];\n\n /** Fires when the reader picks another organization — the `v-model:organization` half. */\n 'update:organization': [organization: string];\n}>();\n\nconst attrs = useAttrs();\nconst i18n = useLocale();\nconst identityId = useId('account-menu-identity');\nconst trigger = useTemplateRef<InstanceType<typeof DropdownMenuTrigger>>('trigger');\n\n/* Optional: without a provider the appearance rows hide instead of throwing. */\nconst colorMode = inject(ColorModeKey, null);\n\nconst controlled = useControlled<boolean>({\n controlled: () => props.open,\n default: () => props.defaultOpen,\n onChange: (value) => {\n emit('update:open', value);\n },\n});\n\nconst isOpen = controlled.value;\n\n/** Whether the trigger refuses to open the menu. */\nconst isBlocked = computed(() => props.isDisabled || props.isBusy);\n\nfunction setOpen(open: boolean): void {\n if (open && isBlocked.value) return;\n controlled.setValue(open);\n}\n\n/* A menu open when the trigger becomes disabled or busy closes, since nothing in it may act now. */\nwatch(isBlocked, (blocked) => {\n if (blocked && isOpen.value) controlled.setValue(false);\n});\n\nconst hasName = computed(() => (props.name ?? '').trim() !== '');\n\nconst triggerName = computed(() => {\n if (!hasName.value) return props.anonymousTriggerLabel;\n const name = (props.name ?? '').trim();\n return props.triggerLabel === undefined\n ? i18n.t('AccountMenu.triggerLabel', { name }, 'Account menu for {name}')\n : props.triggerLabel.replaceAll('{name}', name);\n});\n\nconst hasOrganizationSwitcher = computed(() => props.organizations.length > 1);\n\n/** The one organization a person belongs to, named in the header instead of a one-row switcher. */\nconst soleOrganization = computed(() => (props.organizations.length === 1 ? props.organizations[0] : undefined));\n\nconst hasIdentity = computed(() => hasName.value || Boolean(props.description) || soleOrganization.value !== undefined);\n\nconst hasAppearance = computed(() => props.showAppearance && colorMode !== null);\nconst hasLanguages = computed(() => props.locales.length > 1);\nconst hasVersions = computed(() => props.versions.length > 0);\nconst hasSignOut = computed(() => typeof props.onSignOut === 'function');\n\nconst appearances = computed((): ReadonlyArray<{ value: Appearance; label: string; icon: IconAdapter }> => [\n { value: Appearance.System, label: props.systemModeLabel, icon: Monitor },\n { value: Appearance.Light, label: props.lightModeLabel, icon: Sun },\n { value: Appearance.Dark, label: props.darkModeLabel, icon: Moon },\n]);\n\n/** The row the ambient mode marks: `system` while it follows the device, else the mode itself. */\nconst appearance = computed<Appearance | null>(() => {\n if (!colorMode) return null;\n if (colorMode.followsSystem) return Appearance.System;\n return colorMode.mode === ColorMode.Dark ? Appearance.Dark : Appearance.Light;\n});\n\nfunction chooseAppearance(value: string | null): void {\n if (!colorMode) return;\n if (value === Appearance.System) colorMode.followSystem();\n else if (value === Appearance.Light) colorMode.setMode(ColorMode.Light);\n else if (value === Appearance.Dark) colorMode.setMode(ColorMode.Dark);\n}\n\nfunction chooseLocale(value: string | null): void {\n if (value !== null && value !== props.locale) emit('update:locale', value);\n}\n\nfunction chooseOrganization(id: string | null): void {\n if (id !== null && id !== props.organization) emit('update:organization', id);\n}\n\nfunction signOut(): void {\n void props.onSignOut?.();\n}\n\nfunction shortCommit(commit: string): string {\n return commit.trim().slice(0, CommitLength);\n}\n\n/**\n * The sections present, in display order. Read during render, so a section that appears or a slot that is\n * added re-places every separator; a separator sits before each section but the first.\n */\nfunction sections(): ReadonlyArray<string> {\n return [\n hasIdentity.value && 'identity',\n hasOrganizationSwitcher.value && 'organizations',\n slots.items !== undefined && 'items',\n hasAppearance.value && 'appearance',\n hasLanguages.value && 'languages',\n hasVersions.value && 'versions',\n hasSignOut.value && 'signOut',\n ].filter((section): section is string => typeof section === 'string');\n}\n\nfunction isSeparated(section: string): boolean {\n return sections().indexOf(section) > 0;\n}\n\nconst triggerClasses = computed(() =>\n cn(\n 'group/account-menu inline-flex min-h-11 shrink-0 items-center gap-1.5 rounded-xl border border-transparent',\n 'py-1 ps-1 pe-2 text-foreground transition-colors motion-reduce:transition-none',\n 'hover:border-primary/15 hover:bg-primary-soft',\n 'data-[state=open]:border-primary/15 data-[state=open]:bg-primary-soft',\n 'outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60',\n attrs.class as ClassValue,\n ),\n);\n\n/* The panel fits a phone: never wider than the viewport, never taller than the space under a top bar, and\n scrolling inside itself when the sections outgrow it. As the scroll box it spans the surface's inline padding\n (`-mx-1 px-1`): a separator bleeds that padding to meet the surface edges, and inside a narrower scroll box the\n bleed overflowed it by 4px and drew a sideways scrollbar. The width adds the padding back, so the surface keeps\n its size. */\nconst panelClasses = computed(() =>\n cn(\n '-mx-1 flex w-[min(18.5rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-5rem)] flex-col gap-0.5 px-1',\n 'overflow-y-auto overscroll-contain',\n props.panelClass as ClassValue,\n ),\n);\n\n/** Everything but `class`, which is re-applied through `cn` above. */\nconst rest = computed(() => {\n const { class: _class, ...others } = attrs;\n return others;\n});\n\n/** The trigger button. */\nconst el = computed(() => trigger.value?.el ?? null);\n\ndefineExpose({ el });\n</script>\n\n<template>\n <DropdownMenu :open=\"isOpen\" :placement=\"props.placement\" @update:open=\"setOpen\">\n <DropdownMenuTrigger ref=\"trigger\" as-child>\n <button\n type=\"button\"\n :aria-label=\"triggerName\"\n :aria-busy=\"props.isBusy || undefined\"\n :disabled=\"isBlocked\"\n :data-busy=\"dataAttr(props.isBusy)\"\n v-bind=\"rest\"\n :class=\"triggerClasses\"\n >\n <Avatar\n v-if=\"hasName\"\n :name=\"props.name\"\n :src=\"props.avatarSrc\"\n alt=\"\"\n size=\"sm\"\n :is-loading=\"props.isBusy\"\n data-account-menu-avatar\n />\n <span\n v-else\n aria-hidden=\"true\"\n class=\"grid size-8 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground\"\n data-account-menu-avatar\n >\n <Icon :icon=\"UserRound\" :size=\"18\" />\n </span>\n <Icon\n :icon=\"ChevronDown\"\n :size=\"14\"\n class=\"shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]/account-menu:rotate-180 motion-reduce:transition-none\"\n data-account-menu-chevron\n />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n :aria-label=\"props.menuLabel\"\n :aria-describedby=\"hasIdentity ? identityId : undefined\"\n :variant=\"props.variant\"\n :class=\"panelClasses\"\n >\n <div v-if=\"hasIdentity\" :id=\"identityId\" class=\"min-w-0 px-2 py-1.5\" data-account-menu-identity>\n <p v-if=\"hasName\" class=\"truncate text-sm font-semibold text-foreground\">{{ props.name }}</p>\n <p v-if=\"props.description\" class=\"truncate text-xs text-muted-foreground\">{{ props.description }}</p>\n <p v-if=\"soleOrganization\" class=\"truncate text-xs text-muted-foreground\" data-account-menu-organization>\n {{ soleOrganization.label\n }}<template v-if=\"soleOrganization.description\"> · {{ soleOrganization.description }}</template>\n </p>\n </div>\n\n <template v-if=\"hasOrganizationSwitcher\">\n <MenuSeparator v-if=\"isSeparated('organizations')\" />\n <MenuRadioGroup\n :label=\"props.organizationLabel\"\n :model-value=\"props.organization ?? null\"\n data-account-menu-organizations\n @update:model-value=\"chooseOrganization\"\n >\n <!-- Many memberships scroll inside their own band, so appearance and sign out stay in reach. -->\n <div class=\"max-h-44 overflow-y-auto overscroll-contain\" data-account-menu-organization-list>\n <MenuRadioItem v-for=\"entry in props.organizations\" :key=\"entry.id\" :value=\"entry.id\">\n <template #indicator=\"{ checked }\"><Icon v-if=\"checked\" :icon=\"Check\" :size=\"14\" /></template>\n <span class=\"min-w-0 truncate\">{{ entry.label }}</span>\n <span v-if=\"entry.description\" class=\"ms-auto shrink-0 text-xs text-muted-foreground\">\n {{ entry.description }}\n </span>\n </MenuRadioItem>\n </div>\n </MenuRadioGroup>\n </template>\n\n <template v-if=\"slots.items\">\n <MenuSeparator v-if=\"isSeparated('items')\" />\n <slot name=\"items\" />\n </template>\n\n <template v-if=\"hasAppearance\">\n <MenuSeparator v-if=\"isSeparated('appearance')\" />\n <MenuRadioGroup\n :label=\"props.appearanceLabel\"\n :model-value=\"appearance\"\n data-account-menu-appearance\n @update:model-value=\"chooseAppearance\"\n >\n <MenuRadioItem v-for=\"entry in appearances\" :key=\"entry.value\" :value=\"entry.value\">\n <template #indicator=\"{ checked }\"><Icon v-if=\"checked\" :icon=\"Check\" :size=\"14\" /></template>\n <Icon :icon=\"entry.icon\" :size=\"15\" class=\"shrink-0 text-muted-foreground\" />\n {{ entry.label }}\n </MenuRadioItem>\n </MenuRadioGroup>\n </template>\n\n <template v-if=\"hasLanguages\">\n <MenuSeparator v-if=\"isSeparated('languages')\" />\n <MenuRadioGroup\n :label=\"props.languageLabel\"\n :model-value=\"props.locale ?? null\"\n data-account-menu-languages\n @update:model-value=\"chooseLocale\"\n >\n <MenuRadioItem v-for=\"entry in props.locales\" :key=\"entry.value\" :value=\"entry.value\" :lang=\"entry.value\">\n <template #indicator=\"{ checked }\"><Icon v-if=\"checked\" :icon=\"Check\" :size=\"14\" /></template>\n {{ entry.label }}\n </MenuRadioItem>\n </MenuRadioGroup>\n </template>\n\n <template v-if=\"hasVersions\">\n <MenuSeparator v-if=\"isSeparated('versions')\" />\n <MenuGroup :label=\"props.versionsLabel\" data-account-menu-versions>\n <div\n v-for=\"(entry, index) in props.versions\"\n :key=\"`${index}:${entry.label}`\"\n class=\"flex items-baseline justify-between gap-3 px-2 py-0.5 text-xs\"\n data-account-menu-version\n >\n <span class=\"min-w-0 truncate text-muted-foreground\">{{ entry.label }}</span>\n <span class=\"shrink-0 font-mono tabular-nums text-foreground\"\n >{{ entry.version\n }}<span v-if=\"entry.commit\" class=\"text-muted-foreground\"> · {{ shortCommit(entry.commit) }}</span></span\n >\n </div>\n </MenuGroup>\n </template>\n\n <template v-if=\"hasSignOut\">\n <MenuSeparator v-if=\"isSeparated('signOut')\" />\n <MenuItem state=\"destructive\" data-account-menu-sign-out @select=\"signOut\">\n <Icon :icon=\"LogOut\" :size=\"15\" class=\"shrink-0\" />\n {{ props.signOutLabel }}\n </MenuItem>\n </template>\n </DropdownMenuContent>\n </DropdownMenu>\n</template>\n"],"names":["_useSlots","_createBlock","DropdownMenu","_unref","_createVNode","DropdownMenuTrigger","_createElementVNode","_mergeProps","Avatar","_openBlock","_createElementBlock","Icon","DropdownMenuContent","_toDisplayString","_createTextVNode","_Fragment","MenuSeparator","MenuRadioGroup","_renderList","MenuRadioItem","_withCtx","_renderSlot","MenuGroup","MenuItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,KAAK,GAAA,CAAA;AAAA,wBACnEP,mBAGC,QAHD,aAGC;AAAA,0BAFKQ,gBAAAD,gBAAA,MAAM,OAAO,GAAA,CAAA;AAAA,0BACH,MAAM,uBAAlBH,mBAAiG,QAAjG,aAAwD,wBAAM,YAAY,MAAM,MAAM,CAAA,GAAA,CAAA;;;;;;;;cAMhF,WAAA,sBAAhBA,mBAMWK,UAAA,EAAA,KAAA,KAAA;AAAA,gBALY,YAAW,SAAA,kBAAhCd,YAA+Ce,aAAA,EAAA,KAAA,EAAA,CAAA;gBAC/CZ,YAGWmB,aAAA;AAAA,kBAHD,OAAM;AAAA,kBAAc,8BAAA;AAAA,kBAA4B,UAAQ;AAAA,gBAAA;mCAChE,MAAmD;AAAA,oBAAnDnB,YAAmDD,MAAAQ,WAAA,GAAA;AAAA,sBAA5C,MAAMR,MAAA,MAAA;AAAA,sBAAS,MAAM;AAAA,sBAAI,OAAM;AAAA,oBAAA;oCAAa,MACnDU,gBAAGV,MAAA,KAAA,EAAM,YAAY,GAAA,CAAA;AAAA,kBAAA;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"AccountMenu.vue.js","sources":["../../../../src/presentation/nav/accountMenu/AccountMenu.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { HTMLAttributes } from 'vue';\nimport type { Placement } from '@floating-ui/vue';\nimport type { SurfaceVariant } from '../../../foundation/styles';\n\n/** Represents one interface language an `AccountMenu` offers. */\nexport interface AccountMenuLocale {\n /** The locale tag the `locale` model holds — `uz`, `ru`, `en-GB`; also the row's `lang`. */\n readonly value: string;\n\n /** The language's own name in its own language — `O‘zbekcha`, `Русский`, `English`. */\n readonly label: string;\n}\n\n/** Represents one organization the signed-in person belongs to. */\nexport interface AccountMenuOrganization {\n /** The stable identity the `organization` model holds. */\n readonly id: string;\n\n /** The organization name, already translated. */\n readonly label: string;\n\n /** One muted line beside the name — the person's role there, already translated. */\n readonly description?: string;\n}\n\n/** Represents one running service whose version the menu reports. */\nexport interface AccountMenuVersion {\n /** The service name, already translated — `Catalogue`, `API`. */\n readonly label: string;\n\n /** The running version — `0.1.3`, or the caller's translated placeholder while it loads. */\n readonly version: string;\n\n /** The commit the service was built from; the menu shows its first seven characters. */\n readonly commit?: string;\n}\n\n/** Defines props for the avatar menu that ends an app's top bar. */\nexport interface AccountMenuProps {\n /** The signed-in person's display name. Omitted, the trigger shows a person glyph and the header hides. */\n readonly name?: string;\n\n /** The header's second line — the email or the role. */\n readonly description?: string;\n\n /**\n * The avatar image — a BFF session's `person.picture` binds as is. Without it (`null` included), or when it fails,\n * the avatar shows the name's initials, or the person glyph without a name.\n */\n readonly avatarSrc?: string | null;\n\n /** The open state, controlled. The `v-model:open` binding target. */\n readonly open?: boolean;\n\n /** The initial open state when uncontrolled. Default `false`. */\n readonly defaultOpen?: boolean;\n\n /** The Floating UI placement. Default `bottom-end`, for a trigger at the end of the bar. */\n readonly placement?: Placement;\n\n /** The disabled state — the trigger cannot open the menu, and an open menu closes. */\n readonly isDisabled?: boolean;\n\n /** The busy state — a session or sign-out in flight; blocks the trigger like `isDisabled` and marks it busy. */\n readonly isBusy?: boolean;\n\n /** The appearance toggle — the system, light and dark rows. Default `true`; needs a `ColorModeProvider`. */\n readonly showAppearance?: boolean;\n\n /** The interface languages, in display order. Fewer than two hide the language rows. */\n readonly locales?: ReadonlyArray<AccountMenuLocale>;\n\n /** The current interface language's `value`. The `v-model:locale` binding target. */\n readonly locale?: string;\n\n /** The person's organizations, in display order. Fewer than two hide the switcher. */\n readonly organizations?: ReadonlyArray<AccountMenuOrganization>;\n\n /** The current organization's `id`. The `v-model:organization` binding target. */\n readonly organization?: string;\n\n /** Every running service's version, in display order — the frontend first, then each backend service. */\n readonly versions?: ReadonlyArray<AccountMenuVersion>;\n\n /**\n * Fires when the reader picks sign out.\n *\n * Kept a PROP, not an emit: its presence renders the sign-out row, and Vue strips a declared emit's\n * listener out of `useAttrs()`, so an emit could never be detected. Bind it as `@sign-out`.\n */\n readonly onSignOut?: () => unknown;\n\n /** The menu's accessible name. Default `\"Account\"`, localized. */\n readonly menuLabel?: string;\n\n /** The trigger's accessible name; `{name}` becomes the name. Default `\"Account menu for {name}\"`, localized. */\n readonly triggerLabel?: string;\n\n /** The trigger's accessible name without a `name`. Default `\"Account menu\"`, localized. */\n readonly anonymousTriggerLabel?: string;\n\n /** The appearance group heading. Default `\"Appearance\"`, localized. */\n readonly appearanceLabel?: string;\n\n /** The row that follows the device setting. Default `\"System\"`, localized. */\n readonly systemModeLabel?: string;\n\n /** The light row. Default `\"Light\"`, localized. */\n readonly lightModeLabel?: string;\n\n /** The dark row. Default `\"Dark\"`, localized. */\n readonly darkModeLabel?: string;\n\n /** The language group heading. Default `\"Language\"`, localized. */\n readonly languageLabel?: string;\n\n /** The organization group heading. Default `\"Organization\"`, localized. */\n readonly organizationLabel?: string;\n\n /** The versions group heading. Default `\"Versions\"`, localized. */\n readonly versionsLabel?: string;\n\n /** The sign-out row. Default `\"Sign out\"`, localized. */\n readonly signOutLabel?: string;\n\n /** The panel's surface recipe — `glass` or `glass-outline` for translucent chrome. Default the menu's own. */\n readonly variant?: SurfaceVariant;\n\n /** The panel class — the hook for an app's own material. */\n readonly panelClass?: HTMLAttributes['class'];\n}\n\n/** @internal The appearance rows' values; `system` hands the mode back to the device. */\nconst Appearance = {\n System: 'system',\n Light: 'light',\n Dark: 'dark',\n} as const;\n\ntype Appearance = (typeof Appearance)[keyof typeof Appearance];\n\n/** @internal The visible length of a commit hash. */\nconst CommitLength = 7;\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, inject, useAttrs, useTemplateRef, watch } from 'vue';\nimport type { ClassValue } from 'clsx';\nimport { Check, ChevronDown, LogOut, Monitor, Moon, Sun, UserRound } from 'lucide-vue-next';\nimport { dataAttr } from '../../../foundation/dom';\nimport { Icon, type IconAdapter } from '../../../foundation/icons';\nimport { useLocale, useLocaleDefaults } from '../../../foundation/i18n';\nimport { useId } from '../../../foundation/identifiers';\nimport { ColorMode, ColorModeKey } from '../../../foundation/primitives';\nimport { useControlled } from '../../../foundation/state';\nimport { cn } from '../../../foundation/styles';\nimport Avatar from '../../display/avatar/Avatar.vue';\nimport DropdownMenu from '../dropdownMenu/DropdownMenu.vue';\nimport DropdownMenuContent from '../dropdownMenu/DropdownMenuContent.vue';\nimport DropdownMenuTrigger from '../dropdownMenu/DropdownMenuTrigger.vue';\nimport MenuGroup from '../menu/MenuGroup.vue';\nimport MenuItem from '../menu/MenuItem.vue';\nimport MenuRadioGroup from '../menu/MenuRadioGroup.vue';\nimport MenuRadioItem from '../menu/MenuRadioItem.vue';\nimport MenuSeparator from '../menu/MenuSeparator.vue';\n\n/**\n * Renders the account menu that ends an app's top bar: an avatar trigger that opens who is signed in, the\n * organization switcher, the caller's account destinations, the colour mode, the interface language, each\n * service's version and sign out — always last.\n */\ndefineOptions({ name: 'AccountMenu', inheritAttrs: false });\n\nconst slots = defineSlots<{\n /** The account-level destinations — `MenuItem` rows such as account settings, placed after the switcher. */\n items?(): unknown;\n}>();\n\nconst componentProps = withDefaults(defineProps<AccountMenuProps>(), {\n name: undefined,\n description: undefined,\n avatarSrc: undefined,\n open: undefined,\n defaultOpen: false,\n placement: 'bottom-end',\n isDisabled: false,\n isBusy: false,\n showAppearance: true,\n locales: () => [],\n locale: undefined,\n organizations: () => [],\n organization: undefined,\n versions: () => [],\n onSignOut: undefined,\n triggerLabel: undefined,\n variant: undefined,\n panelClass: undefined,\n});\n\nconst props = useLocaleDefaults(componentProps, 'AccountMenu', {\n menuLabel: 'Account',\n anonymousTriggerLabel: 'Account menu',\n appearanceLabel: 'Appearance',\n systemModeLabel: 'System',\n lightModeLabel: 'Light',\n darkModeLabel: 'Dark',\n languageLabel: 'Language',\n organizationLabel: 'Organization',\n versionsLabel: 'Versions',\n signOutLabel: 'Sign out',\n});\n\nconst emit = defineEmits<{\n /** Fires when the menu opens or closes — the `v-model:open` half. */\n 'update:open': [open: boolean];\n\n /** Fires when the reader picks another interface language — the `v-model:locale` half. */\n 'update:locale': [locale: string];\n\n /** Fires when the reader picks another organization — the `v-model:organization` half. */\n 'update:organization': [organization: string];\n}>();\n\nconst attrs = useAttrs();\nconst i18n = useLocale();\nconst identityId = useId('account-menu-identity');\nconst trigger = useTemplateRef<InstanceType<typeof DropdownMenuTrigger>>('trigger');\n\n/* Optional: without a provider the appearance rows hide instead of throwing. */\nconst colorMode = inject(ColorModeKey, null);\n\nconst controlled = useControlled<boolean>({\n controlled: () => props.open,\n default: () => props.defaultOpen,\n onChange: (value) => {\n emit('update:open', value);\n },\n});\n\nconst isOpen = controlled.value;\n\n/** Whether the trigger refuses to open the menu. */\nconst isBlocked = computed(() => props.isDisabled || props.isBusy);\n\nfunction setOpen(open: boolean): void {\n if (open && isBlocked.value) return;\n controlled.setValue(open);\n}\n\n/* A menu open when the trigger becomes disabled or busy closes, since nothing in it may act now. */\nwatch(isBlocked, (blocked) => {\n if (blocked && isOpen.value) controlled.setValue(false);\n});\n\nconst hasName = computed(() => (props.name ?? '').trim() !== '');\n\n/** The picture to show, or `undefined` for none — the avatar then falls back to initials or the glyph. */\nconst pictureSrc = computed(() => {\n const src = (props.avatarSrc ?? '').trim();\n return src === '' ? undefined : src;\n});\n\nconst triggerName = computed(() => {\n if (!hasName.value) return props.anonymousTriggerLabel;\n const name = (props.name ?? '').trim();\n return props.triggerLabel === undefined\n ? i18n.t('AccountMenu.triggerLabel', { name }, 'Account menu for {name}')\n : props.triggerLabel.replaceAll('{name}', name);\n});\n\nconst hasOrganizationSwitcher = computed(() => props.organizations.length > 1);\n\n/** The one organization a person belongs to, named in the header instead of a one-row switcher. */\nconst soleOrganization = computed(() => (props.organizations.length === 1 ? props.organizations[0] : undefined));\n\nconst hasIdentity = computed(() => hasName.value || Boolean(props.description) || soleOrganization.value !== undefined);\n\nconst hasAppearance = computed(() => props.showAppearance && colorMode !== null);\nconst hasLanguages = computed(() => props.locales.length > 1);\nconst hasVersions = computed(() => props.versions.length > 0);\nconst hasSignOut = computed(() => typeof props.onSignOut === 'function');\n\nconst appearances = computed((): ReadonlyArray<{ value: Appearance; label: string; icon: IconAdapter }> => [\n { value: Appearance.System, label: props.systemModeLabel, icon: Monitor },\n { value: Appearance.Light, label: props.lightModeLabel, icon: Sun },\n { value: Appearance.Dark, label: props.darkModeLabel, icon: Moon },\n]);\n\n/** The row the ambient mode marks: `system` while it follows the device, else the mode itself. */\nconst appearance = computed<Appearance | null>(() => {\n if (!colorMode) return null;\n if (colorMode.followsSystem) return Appearance.System;\n return colorMode.mode === ColorMode.Dark ? Appearance.Dark : Appearance.Light;\n});\n\nfunction chooseAppearance(value: string | null): void {\n if (!colorMode) return;\n if (value === Appearance.System) colorMode.followSystem();\n else if (value === Appearance.Light) colorMode.setMode(ColorMode.Light);\n else if (value === Appearance.Dark) colorMode.setMode(ColorMode.Dark);\n}\n\nfunction chooseLocale(value: string | null): void {\n if (value !== null && value !== props.locale) emit('update:locale', value);\n}\n\nfunction chooseOrganization(id: string | null): void {\n if (id !== null && id !== props.organization) emit('update:organization', id);\n}\n\nfunction signOut(): void {\n void props.onSignOut?.();\n}\n\nfunction shortCommit(commit: string): string {\n return commit.trim().slice(0, CommitLength);\n}\n\n/**\n * The sections present, in display order. Read during render, so a section that appears or a slot that is\n * added re-places every separator; a separator sits before each section but the first.\n */\nfunction sections(): ReadonlyArray<string> {\n return [\n hasIdentity.value && 'identity',\n hasOrganizationSwitcher.value && 'organizations',\n slots.items !== undefined && 'items',\n hasAppearance.value && 'appearance',\n hasLanguages.value && 'languages',\n hasVersions.value && 'versions',\n hasSignOut.value && 'signOut',\n ].filter((section): section is string => typeof section === 'string');\n}\n\nfunction isSeparated(section: string): boolean {\n return sections().indexOf(section) > 0;\n}\n\nconst triggerClasses = computed(() =>\n cn(\n 'group/account-menu inline-flex min-h-11 shrink-0 items-center gap-1.5 rounded-xl border border-transparent',\n 'py-1 ps-1 pe-2 text-foreground transition-colors motion-reduce:transition-none',\n 'hover:border-primary/15 hover:bg-primary-soft',\n 'data-[state=open]:border-primary/15 data-[state=open]:bg-primary-soft',\n 'outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-60',\n attrs.class as ClassValue,\n ),\n);\n\n/* The panel fits a phone: never wider than the viewport, never taller than the space under a top bar, and\n scrolling inside itself when the sections outgrow it. As the scroll box it spans the surface's inline padding\n (`-mx-1 px-1`): a separator bleeds that padding to meet the surface edges, and inside a narrower scroll box the\n bleed overflowed it by 4px and drew a sideways scrollbar. The width adds the padding back, so the surface keeps\n its size. */\nconst panelClasses = computed(() =>\n cn(\n '-mx-1 flex w-[min(18.5rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-5rem)] flex-col gap-0.5 px-1',\n 'overflow-y-auto overscroll-contain',\n props.panelClass as ClassValue,\n ),\n);\n\n/** Everything but `class`, which is re-applied through `cn` above. */\nconst rest = computed(() => {\n const { class: _class, ...others } = attrs;\n return others;\n});\n\n/** The trigger button. */\nconst el = computed(() => trigger.value?.el ?? null);\n\ndefineExpose({ el });\n</script>\n\n<template>\n <DropdownMenu :open=\"isOpen\" :placement=\"props.placement\" @update:open=\"setOpen\">\n <DropdownMenuTrigger ref=\"trigger\" as-child>\n <button\n type=\"button\"\n :aria-label=\"triggerName\"\n :aria-busy=\"props.isBusy || undefined\"\n :disabled=\"isBlocked\"\n :data-busy=\"dataAttr(props.isBusy)\"\n v-bind=\"rest\"\n :class=\"triggerClasses\"\n >\n <Avatar\n v-if=\"hasName || pictureSrc\"\n :name=\"hasName ? props.name : undefined\"\n :src=\"pictureSrc\"\n alt=\"\"\n size=\"sm\"\n :is-loading=\"props.isBusy\"\n data-account-menu-avatar\n >\n <!-- A picture without a name that fails to load falls back to the glyph, not to empty initials. -->\n <template v-if=\"!hasName\" #fallback><Icon :icon=\"UserRound\" :size=\"18\" /></template>\n </Avatar>\n <span\n v-else\n aria-hidden=\"true\"\n class=\"grid size-8 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground\"\n data-account-menu-avatar\n >\n <Icon :icon=\"UserRound\" :size=\"18\" />\n </span>\n <Icon\n :icon=\"ChevronDown\"\n :size=\"14\"\n class=\"shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]/account-menu:rotate-180 motion-reduce:transition-none\"\n data-account-menu-chevron\n />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n :aria-label=\"props.menuLabel\"\n :aria-describedby=\"hasIdentity ? identityId : undefined\"\n :variant=\"props.variant\"\n :class=\"panelClasses\"\n >\n <div v-if=\"hasIdentity\" :id=\"identityId\" class=\"min-w-0 px-2 py-1.5\" data-account-menu-identity>\n <p v-if=\"hasName\" class=\"truncate text-sm font-semibold text-foreground\">{{ props.name }}</p>\n <p v-if=\"props.description\" class=\"truncate text-xs text-muted-foreground\">{{ props.description }}</p>\n <p v-if=\"soleOrganization\" class=\"truncate text-xs text-muted-foreground\" data-account-menu-organization>\n {{ soleOrganization.label\n }}<template v-if=\"soleOrganization.description\"> · {{ soleOrganization.description }}</template>\n </p>\n </div>\n\n <template v-if=\"hasOrganizationSwitcher\">\n <MenuSeparator v-if=\"isSeparated('organizations')\" />\n <MenuRadioGroup\n :label=\"props.organizationLabel\"\n :model-value=\"props.organization ?? null\"\n data-account-menu-organizations\n @update:model-value=\"chooseOrganization\"\n >\n <!-- Many memberships scroll inside their own band, so appearance and sign out stay in reach. -->\n <div class=\"max-h-44 overflow-y-auto overscroll-contain\" data-account-menu-organization-list>\n <MenuRadioItem v-for=\"entry in props.organizations\" :key=\"entry.id\" :value=\"entry.id\">\n <template #indicator=\"{ checked }\"><Icon v-if=\"checked\" :icon=\"Check\" :size=\"14\" /></template>\n <span class=\"min-w-0 truncate\">{{ entry.label }}</span>\n <span v-if=\"entry.description\" class=\"ms-auto shrink-0 text-xs text-muted-foreground\">\n {{ entry.description }}\n </span>\n </MenuRadioItem>\n </div>\n </MenuRadioGroup>\n </template>\n\n <template v-if=\"slots.items\">\n <MenuSeparator v-if=\"isSeparated('items')\" />\n <slot name=\"items\" />\n </template>\n\n <template v-if=\"hasAppearance\">\n <MenuSeparator v-if=\"isSeparated('appearance')\" />\n <MenuRadioGroup\n :label=\"props.appearanceLabel\"\n :model-value=\"appearance\"\n data-account-menu-appearance\n @update:model-value=\"chooseAppearance\"\n >\n <MenuRadioItem v-for=\"entry in appearances\" :key=\"entry.value\" :value=\"entry.value\">\n <template #indicator=\"{ checked }\"><Icon v-if=\"checked\" :icon=\"Check\" :size=\"14\" /></template>\n <Icon :icon=\"entry.icon\" :size=\"15\" class=\"shrink-0 text-muted-foreground\" />\n {{ entry.label }}\n </MenuRadioItem>\n </MenuRadioGroup>\n </template>\n\n <template v-if=\"hasLanguages\">\n <MenuSeparator v-if=\"isSeparated('languages')\" />\n <MenuRadioGroup\n :label=\"props.languageLabel\"\n :model-value=\"props.locale ?? null\"\n data-account-menu-languages\n @update:model-value=\"chooseLocale\"\n >\n <MenuRadioItem v-for=\"entry in props.locales\" :key=\"entry.value\" :value=\"entry.value\" :lang=\"entry.value\">\n <template #indicator=\"{ checked }\"><Icon v-if=\"checked\" :icon=\"Check\" :size=\"14\" /></template>\n {{ entry.label }}\n </MenuRadioItem>\n </MenuRadioGroup>\n </template>\n\n <template v-if=\"hasVersions\">\n <MenuSeparator v-if=\"isSeparated('versions')\" />\n <MenuGroup :label=\"props.versionsLabel\" data-account-menu-versions>\n <div\n v-for=\"(entry, index) in props.versions\"\n :key=\"`${index}:${entry.label}`\"\n class=\"flex items-baseline justify-between gap-3 px-2 py-0.5 text-xs\"\n data-account-menu-version\n >\n <span class=\"min-w-0 truncate text-muted-foreground\">{{ entry.label }}</span>\n <span class=\"shrink-0 font-mono tabular-nums text-foreground\"\n >{{ entry.version\n }}<span v-if=\"entry.commit\" class=\"text-muted-foreground\"> · {{ shortCommit(entry.commit) }}</span></span\n >\n </div>\n </MenuGroup>\n </template>\n\n <template v-if=\"hasSignOut\">\n <MenuSeparator v-if=\"isSeparated('signOut')\" />\n <MenuItem state=\"destructive\" data-account-menu-sign-out @select=\"signOut\">\n <Icon :icon=\"LogOut\" :size=\"15\" class=\"shrink-0\" />\n {{ props.signOutLabel }}\n </MenuItem>\n </template>\n </DropdownMenuContent>\n </DropdownMenu>\n</template>\n"],"names":["_useSlots","_createBlock","DropdownMenu","_unref","_createVNode","DropdownMenuTrigger","_createElementVNode","_mergeProps","Avatar","Icon","_openBlock","_createElementBlock","DropdownMenuContent","_toDisplayString","_createTextVNode","_Fragment","MenuSeparator","MenuRadioGroup","_renderList","MenuRadioItem","_withCtx","_renderSlot","MenuGroup","MenuItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIA,MAAM,aAAa;AAAA,EACjB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AACR;AAKA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BrB,UAAM,QAAQA,SAAA;AAKd,UAAM,iBAAiB;AAqBvB,UAAM,QAAQ,kBAAkB,gBAAgB,eAAe;AAAA,MAC7D,WAAW;AAAA,MACX,uBAAuB;AAAA,MACvB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,eAAe;AAAA,MACf,mBAAmB;AAAA,MACnB,eAAe;AAAA,MACf,cAAc;AAAA,IAAA,CACf;AAED,UAAM,OAAO;AAWb,UAAM,QAAQ,SAAA;AACd,UAAM,OAAO,UAAA;AACb,UAAM,aAAa,MAAM,uBAAuB;AAChD,UAAM,UAAU,eAAyD,SAAS;AAGlF,UAAM,YAAY,OAAO,cAAc,IAAI;AAE3C,UAAM,aAAa,cAAuB;AAAA,MACxC,YAAY,MAAM,MAAM;AAAA,MACxB,SAAS,MAAM,MAAM;AAAA,MACrB,UAAU,CAAC,UAAU;AACnB,aAAK,eAAe,KAAK;AAAA,MAC3B;AAAA,IAAA,CACD;AAED,UAAM,SAAS,WAAW;AAG1B,UAAM,YAAY,SAAS,MAAM,MAAM,cAAc,M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A;oCAAa,MACnDU,gBAAGV,MAAA,KAAA,EAAM,YAAY,GAAA,CAAA;AAAA,kBAAA;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wow-two-beta/fe",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "description": "Beta-forever Vue 3 fe sdk for the wow-two ecosystem — components, application adapters and browser capabilities.",
5
5
  "license": "MIT",
6
6
  "repository": {