@orangecheck/auth-client 2.1.1 → 2.2.0

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.
package/dist/index.mjs CHANGED
@@ -1480,6 +1480,28 @@ function useStepUpAuth(opts) {
1480
1480
  return { status, error, stepUp, reset };
1481
1481
  }
1482
1482
 
1483
- export { DEFAULT_CONFIG, OcAccountChip, OcAccountPill, OcAddressInput, OcSessionProvider, OcSignIn, OcSignInButton, buildSignInUrl, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
1483
+ // src/sudo.tsx
1484
+ function redirectToSudo(args = {}) {
1485
+ if (typeof window === "undefined") {
1486
+ throw new Error(
1487
+ "[@orangecheck/auth-client] redirectToSudo() requires a browser environment"
1488
+ );
1489
+ }
1490
+ const cfg = resolveConfig(args.config);
1491
+ const url = new URL("/sudo", cfg.authOrigin);
1492
+ const returnTo = args.returnTo ?? window.location.href;
1493
+ if (returnTo) url.searchParams.set("return_to", returnTo);
1494
+ if (args.purpose) url.searchParams.set("purpose", args.purpose);
1495
+ window.location.assign(url.toString());
1496
+ }
1497
+ function handleSudoRequired(body, args = {}) {
1498
+ if (body && body.reason === "sudo_required") {
1499
+ redirectToSudo(args);
1500
+ return true;
1501
+ }
1502
+ return false;
1503
+ }
1504
+
1505
+ export { DEFAULT_CONFIG, OcAccountChip, OcAccountPill, OcAddressInput, OcSessionProvider, OcSignIn, OcSignInButton, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
1484
1506
  //# sourceMappingURL=index.mjs.map
1485
1507
  //# sourceMappingURL=index.mjs.map