@securitydept/session-context-client 0.3.0-beta.3 → 0.3.0-beta.5

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,28 +0,0 @@
1
- import { assertResolveEnvironment } from "@securitydept/client/web";
2
- //#region src/web/index.ts
3
- const SESSION_PAGE_ENVIRONMENT_ERROR_MESSAGE = "session browser redirect helpers require an explicit page environment.\nCreate one in your composition root with createBrowserPageClientEnvironment(...).";
4
- /**
5
- * One-shot browser redirect to the session login endpoint.
6
- *
7
- * 1. Saves the post-auth redirect intent into the client's pending store
8
- * (when a session store is configured).
9
- * 2. Navigates the current window to the login URL.
10
- *
11
- * This is the recommended browser entry point for initiating session-based
12
- * login. It is intentionally a standalone function (not a method on
13
- * `SessionContextClient`) to keep browser-specific side-effects out of the
14
- * host-neutral client contract.
15
- */
16
- async function loginWithRedirect(client, options = {}) {
17
- const environment = assertResolveEnvironment(options.environment, failMissingPageEnvironment);
18
- const postAuthRedirectUri = options.postAuthRedirectUri ?? environment.location.href;
19
- await client.savePendingLoginRedirect(postAuthRedirectUri);
20
- environment.location.href = client.loginUrl(postAuthRedirectUri);
21
- }
22
- function failMissingPageEnvironment() {
23
- throw new Error(SESSION_PAGE_ENVIRONMENT_ERROR_MESSAGE);
24
- }
25
- //#endregion
26
- export { loginWithRedirect };
27
-
28
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/web/index.ts"],"sourcesContent":["// Session Context Client — Browser Adapter\n//\n// Canonical import path:\n// import { loginWithRedirect } from \"@securitydept/session-context-client/web\"\n//\n// Provides browser-specific convenience helpers that trigger full-page\n// navigation (redirect) for session-based authentication. The root\n// `SessionContextClient` stays host-neutral; this subpath owns the\n// browser side-effect layer.\n//\n// Stability: provisional\n\nimport type { PageLocationCapability } from \"@securitydept/client\";\nimport { assertResolveEnvironment } from \"@securitydept/client/web\";\nimport type { SessionContextClient } from \"../client\";\n\nconst SESSION_PAGE_ENVIRONMENT_ERROR_MESSAGE =\n\t\"session browser redirect helpers require an explicit page environment.\\n\" +\n\t\"Create one in your composition root with createBrowserPageClientEnvironment(...).\";\n\n/**\n * Options for {@link loginWithRedirect}.\n */\nexport interface LoginWithRedirectOptions {\n\tenvironment?: PageLocationCapability;\n\n\t/**\n\t * Where to redirect the user after successful authentication.\n\t *\n\t * When omitted, `environment.location.href` is used as the return URI and\n\t * persisted via the client's pending-login-redirect store for post-auth\n\t * consumption.\n\t */\n\tpostAuthRedirectUri?: string;\n}\n\n/**\n * One-shot browser redirect to the session login endpoint.\n *\n * 1. Saves the post-auth redirect intent into the client's pending store\n * (when a session store is configured).\n * 2. Navigates the current window to the login URL.\n *\n * This is the recommended browser entry point for initiating session-based\n * login. It is intentionally a standalone function (not a method on\n * `SessionContextClient`) to keep browser-specific side-effects out of the\n * host-neutral client contract.\n */\nexport async function loginWithRedirect(\n\tclient: SessionContextClient,\n\toptions: LoginWithRedirectOptions = {},\n): Promise<void> {\n\tconst environment = assertResolveEnvironment(\n\t\toptions.environment,\n\t\tfailMissingPageEnvironment,\n\t);\n\tconst postAuthRedirectUri =\n\t\toptions.postAuthRedirectUri ?? environment.location.href;\n\n\tawait client.savePendingLoginRedirect(postAuthRedirectUri);\n\n\tenvironment.location.href = client.loginUrl(postAuthRedirectUri);\n}\n\nfunction failMissingPageEnvironment(): never {\n\tthrow new Error(SESSION_PAGE_ENVIRONMENT_ERROR_MESSAGE);\n}\n"],"mappings":";;AAgBA,MAAM,yCACL;;;;;;;;;;;;;AA+BD,eAAsB,kBACrB,QACA,UAAoC,EAAE,EACtB;CAChB,MAAM,cAAc,yBACnB,QAAQ,aACR,2BACA;CACD,MAAM,sBACL,QAAQ,uBAAuB,YAAY,SAAS;CAErD,MAAM,OAAO,yBAAyB,oBAAoB;CAE1D,YAAY,SAAS,OAAO,OAAO,SAAS,oBAAoB;;AAGjE,SAAS,6BAAoC;CAC5C,MAAM,IAAI,MAAM,uCAAuC"}