@securitydept/basic-auth-context-client 0.3.0-beta.1 → 0.3.0-beta.10

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.
@@ -1,37 +0,0 @@
1
- import { n as AuthGuardResultKind } from "../types-2IoKrgnl.mjs";
2
- //#region src/web/login-redirect.ts
3
- /**
4
- * One-shot browser redirect to the zone login endpoint for the given path.
5
- *
6
- * 1. Resolves the zone for the current (or specified) path.
7
- * 2. Navigates the current window to the zone's login URL with a
8
- * post-auth redirect parameter.
9
- *
10
- * Returns `false` if no zone matches the path (no redirect performed).
11
- * Returns `true` if the redirect was initiated.
12
- *
13
- * This is the recommended browser entry point for initiating basic-auth
14
- * login. It is intentionally a standalone function (not a method on
15
- * `BasicAuthContextClient`) to keep browser-specific side-effects out
16
- * of the host-neutral client contract.
17
- */
18
- function loginWithRedirect(client, options = {}) {
19
- const currentPath = options.currentPath ?? window.location.pathname;
20
- const zone = client.zoneForPath(currentPath);
21
- if (!zone) return false;
22
- const postAuthRedirectUri = options.postAuthRedirectUri ?? window.location.href;
23
- window.location.href = client.loginUrl(zone, postAuthRedirectUri);
24
- return true;
25
- }
26
- //#endregion
27
- //#region src/web/redirect.ts
28
- /**
29
- * Perform a browser redirect for an `AuthGuardResult` that requires redirection.
30
- */
31
- function performRedirect(result) {
32
- if (result.kind === AuthGuardResultKind.Redirect) globalThis.location.href = result.location;
33
- }
34
- //#endregion
35
- export { loginWithRedirect, performRedirect };
36
-
37
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/web/login-redirect.ts","../../src/web/redirect.ts"],"sourcesContent":["// Basic Auth Context Client — Browser login redirect convenience\n//\n// Provides a one-shot browser redirect to a zone's login page, matching the\n// convenience pattern established by session-context-client/web.\n//\n// Unlike session-context where there is a single login URL, basic-auth is\n// zone-based: the adopter must identify which zone to target. This helper\n// resolves the zone from a path and performs the redirect.\n//\n// Stability: provisional\n\nimport type { BasicAuthContextClient } from \"../client\";\n\n/**\n * Options for {@link loginWithRedirect}.\n */\nexport interface LoginWithRedirectOptions {\n\t/**\n\t * The current request path to resolve the target zone.\n\t *\n\t * When omitted, `window.location.pathname` is used.\n\t */\n\tcurrentPath?: string;\n\n\t/**\n\t * Where to redirect the user after successful authentication.\n\t *\n\t * When omitted, `window.location.href` is used as the return URI.\n\t */\n\tpostAuthRedirectUri?: string;\n}\n\n/**\n * One-shot browser redirect to the zone login endpoint for the given path.\n *\n * 1. Resolves the zone for the current (or specified) path.\n * 2. Navigates the current window to the zone's login URL with a\n * post-auth redirect parameter.\n *\n * Returns `false` if no zone matches the path (no redirect performed).\n * Returns `true` if the redirect was initiated.\n *\n * This is the recommended browser entry point for initiating basic-auth\n * login. It is intentionally a standalone function (not a method on\n * `BasicAuthContextClient`) to keep browser-specific side-effects out\n * of the host-neutral client contract.\n */\nexport function loginWithRedirect(\n\tclient: BasicAuthContextClient,\n\toptions: LoginWithRedirectOptions = {},\n): boolean {\n\tconst currentPath = options.currentPath ?? window.location.pathname;\n\tconst zone = client.zoneForPath(currentPath);\n\tif (!zone) {\n\t\treturn false;\n\t}\n\n\tconst postAuthRedirectUri =\n\t\toptions.postAuthRedirectUri ?? window.location.href;\n\twindow.location.href = client.loginUrl(zone, postAuthRedirectUri);\n\treturn true;\n}\n","import type { AuthGuardResult } from \"../types\";\nimport { AuthGuardResultKind } from \"../types\";\n\n/**\n * Perform a browser redirect for an `AuthGuardResult` that requires redirection.\n */\nexport function performRedirect(result: AuthGuardResult<unknown>): void {\n\tif (result.kind === AuthGuardResultKind.Redirect) {\n\t\t// Accessing location via window to satisfy strict type checks.\n\t\t(globalThis as unknown as { location: { href: string } }).location.href =\n\t\t\tresult.location;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,SAAgB,kBACf,QACA,UAAoC,EAAE,EAC5B;CACV,MAAM,cAAc,QAAQ,eAAe,OAAO,SAAS;CAC3D,MAAM,OAAO,OAAO,YAAY,YAAY;AAC5C,KAAI,CAAC,KACJ,QAAO;CAGR,MAAM,sBACL,QAAQ,uBAAuB,OAAO,SAAS;AAChD,QAAO,SAAS,OAAO,OAAO,SAAS,MAAM,oBAAoB;AACjE,QAAO;;;;;;;ACtDR,SAAgB,gBAAgB,QAAwC;AACvE,KAAI,OAAO,SAAS,oBAAoB,SAEtC,YAAyD,SAAS,OAClE,OAAO"}