@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.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -165,4 +165,16 @@ interface UseStepUpAuthReturn {
|
|
|
165
165
|
}
|
|
166
166
|
declare function useStepUpAuth(opts?: UseHostOptions): UseStepUpAuthReturn;
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
interface RedirectToSudoArgs {
|
|
169
|
+
returnTo?: string;
|
|
170
|
+
purpose?: string;
|
|
171
|
+
config?: OcAuthConfig;
|
|
172
|
+
}
|
|
173
|
+
declare function redirectToSudo(args?: RedirectToSudoArgs): void;
|
|
174
|
+
declare function handleSudoRequired(body: {
|
|
175
|
+
reason?: string;
|
|
176
|
+
} | null | undefined, args?: Omit<RedirectToSudoArgs, 'returnTo'> & {
|
|
177
|
+
returnTo?: string;
|
|
178
|
+
}): boolean;
|
|
179
|
+
|
|
180
|
+
export { DEFAULT_CONFIG, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnStepUpResult, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
|
package/dist/index.d.ts
CHANGED
|
@@ -165,4 +165,16 @@ interface UseStepUpAuthReturn {
|
|
|
165
165
|
}
|
|
166
166
|
declare function useStepUpAuth(opts?: UseHostOptions): UseStepUpAuthReturn;
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
interface RedirectToSudoArgs {
|
|
169
|
+
returnTo?: string;
|
|
170
|
+
purpose?: string;
|
|
171
|
+
config?: OcAuthConfig;
|
|
172
|
+
}
|
|
173
|
+
declare function redirectToSudo(args?: RedirectToSudoArgs): void;
|
|
174
|
+
declare function handleSudoRequired(body: {
|
|
175
|
+
reason?: string;
|
|
176
|
+
} | null | undefined, args?: Omit<RedirectToSudoArgs, 'returnTo'> & {
|
|
177
|
+
returnTo?: string;
|
|
178
|
+
}): boolean;
|
|
179
|
+
|
|
180
|
+
export { DEFAULT_CONFIG, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnStepUpResult, buildSignInUrl, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
|
package/dist/index.js
CHANGED
|
@@ -1502,6 +1502,28 @@ function useStepUpAuth(opts) {
|
|
|
1502
1502
|
return { status, error, stepUp, reset };
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
|
+
// src/sudo.tsx
|
|
1506
|
+
function redirectToSudo(args = {}) {
|
|
1507
|
+
if (typeof window === "undefined") {
|
|
1508
|
+
throw new Error(
|
|
1509
|
+
"[@orangecheck/auth-client] redirectToSudo() requires a browser environment"
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
const cfg = resolveConfig(args.config);
|
|
1513
|
+
const url = new URL("/sudo", cfg.authOrigin);
|
|
1514
|
+
const returnTo = args.returnTo ?? window.location.href;
|
|
1515
|
+
if (returnTo) url.searchParams.set("return_to", returnTo);
|
|
1516
|
+
if (args.purpose) url.searchParams.set("purpose", args.purpose);
|
|
1517
|
+
window.location.assign(url.toString());
|
|
1518
|
+
}
|
|
1519
|
+
function handleSudoRequired(body, args = {}) {
|
|
1520
|
+
if (body && body.reason === "sudo_required") {
|
|
1521
|
+
redirectToSudo(args);
|
|
1522
|
+
return true;
|
|
1523
|
+
}
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1505
1527
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
1506
1528
|
exports.OcAccountChip = OcAccountChip;
|
|
1507
1529
|
exports.OcAccountPill = OcAccountPill;
|
|
@@ -1510,6 +1532,8 @@ exports.OcSessionProvider = OcSessionProvider;
|
|
|
1510
1532
|
exports.OcSignIn = OcSignIn;
|
|
1511
1533
|
exports.OcSignInButton = OcSignInButton;
|
|
1512
1534
|
exports.buildSignInUrl = buildSignInUrl;
|
|
1535
|
+
exports.handleSudoRequired = handleSudoRequired;
|
|
1536
|
+
exports.redirectToSudo = redirectToSudo;
|
|
1513
1537
|
exports.useOcAddressSuggestion = useOcAddressSuggestion;
|
|
1514
1538
|
exports.useOcSession = useOcSession;
|
|
1515
1539
|
exports.useOptionalOcSession = useOptionalOcSession;
|