@dloizides/auth-web 1.9.0 → 1.9.1
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 +0 -24
- package/dist/index.d.ts +0 -24
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1694,30 +1694,6 @@ declare const enum PasskeyCeremonyStatus {
|
|
|
1694
1694
|
Error = "error"
|
|
1695
1695
|
}
|
|
1696
1696
|
|
|
1697
|
-
/**
|
|
1698
|
-
* Navigation helpers for the passkey (WebAuthn) BFF endpoints.
|
|
1699
|
-
*
|
|
1700
|
-
* Unlike the device-PIN client (which is plain `fetch`), the passkey login and
|
|
1701
|
-
* registration ceremonies are NOT fetches — they are full-page BROWSER
|
|
1702
|
-
* NAVIGATIONS. The BFF (`Bff.AspNetCore` 1.3.x) drives the WebAuthn ceremony
|
|
1703
|
-
* through Keycloak's hosted pages, then redirects the browser back:
|
|
1704
|
-
* - login: `/bff/passkey/login?returnUrl=<rel>` → on success the browser
|
|
1705
|
-
* lands on `returnUrl` with the session cookie already set;
|
|
1706
|
-
* - registration: `/bff/passkey/register?returnUrl=<rel>` → Keycloak re-auths
|
|
1707
|
-
* the user (password) then runs the credential-creation ceremony, returning
|
|
1708
|
-
* the browser to `returnUrl?passkey=registered`;
|
|
1709
|
-
* - failure / cancel: the BFF redirects to `<login>?passkeyError=cancelled` or
|
|
1710
|
-
* `<login>?passkeyError=failed`.
|
|
1711
|
-
*
|
|
1712
|
-
* react-query-FREE by construction: there is NO fetch here at all — every
|
|
1713
|
-
* function is a pure `window.location` read or `window.location.assign`. The
|
|
1714
|
-
* login route group has no QueryClient provider, so the passkey login button
|
|
1715
|
-
* (which lives there) MUST avoid any react-query primitive; navigation satisfies
|
|
1716
|
-
* that trivially.
|
|
1717
|
-
*
|
|
1718
|
-
* All reads are SSR-safe: when `window` is undefined (server render / native)
|
|
1719
|
-
* they return a benign default rather than throwing.
|
|
1720
|
-
*/
|
|
1721
1697
|
/** The recognised passkey error codes the BFF sends back via `?passkeyError=`. */
|
|
1722
1698
|
type PasskeyErrorCode = 'cancelled' | 'failed';
|
|
1723
1699
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1694,30 +1694,6 @@ declare const enum PasskeyCeremonyStatus {
|
|
|
1694
1694
|
Error = "error"
|
|
1695
1695
|
}
|
|
1696
1696
|
|
|
1697
|
-
/**
|
|
1698
|
-
* Navigation helpers for the passkey (WebAuthn) BFF endpoints.
|
|
1699
|
-
*
|
|
1700
|
-
* Unlike the device-PIN client (which is plain `fetch`), the passkey login and
|
|
1701
|
-
* registration ceremonies are NOT fetches — they are full-page BROWSER
|
|
1702
|
-
* NAVIGATIONS. The BFF (`Bff.AspNetCore` 1.3.x) drives the WebAuthn ceremony
|
|
1703
|
-
* through Keycloak's hosted pages, then redirects the browser back:
|
|
1704
|
-
* - login: `/bff/passkey/login?returnUrl=<rel>` → on success the browser
|
|
1705
|
-
* lands on `returnUrl` with the session cookie already set;
|
|
1706
|
-
* - registration: `/bff/passkey/register?returnUrl=<rel>` → Keycloak re-auths
|
|
1707
|
-
* the user (password) then runs the credential-creation ceremony, returning
|
|
1708
|
-
* the browser to `returnUrl?passkey=registered`;
|
|
1709
|
-
* - failure / cancel: the BFF redirects to `<login>?passkeyError=cancelled` or
|
|
1710
|
-
* `<login>?passkeyError=failed`.
|
|
1711
|
-
*
|
|
1712
|
-
* react-query-FREE by construction: there is NO fetch here at all — every
|
|
1713
|
-
* function is a pure `window.location` read or `window.location.assign`. The
|
|
1714
|
-
* login route group has no QueryClient provider, so the passkey login button
|
|
1715
|
-
* (which lives there) MUST avoid any react-query primitive; navigation satisfies
|
|
1716
|
-
* that trivially.
|
|
1717
|
-
*
|
|
1718
|
-
* All reads are SSR-safe: when `window` is undefined (server render / native)
|
|
1719
|
-
* they return a benign default rather than throwing.
|
|
1720
|
-
*/
|
|
1721
1697
|
/** The recognised passkey error codes the BFF sends back via `?passkeyError=`. */
|
|
1722
1698
|
type PasskeyErrorCode = 'cancelled' | 'failed';
|
|
1723
1699
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2520,6 +2520,18 @@ var PasskeyCeremonyMode = /* @__PURE__ */ ((PasskeyCeremonyMode2) => {
|
|
|
2520
2520
|
return PasskeyCeremonyMode2;
|
|
2521
2521
|
})(PasskeyCeremonyMode || {});
|
|
2522
2522
|
|
|
2523
|
+
// src/passkey/browserLocation.ts
|
|
2524
|
+
function getBrowserLocation() {
|
|
2525
|
+
if (typeof window === "undefined") {
|
|
2526
|
+
return null;
|
|
2527
|
+
}
|
|
2528
|
+
const browserLocation = window.location;
|
|
2529
|
+
if (browserLocation === void 0) {
|
|
2530
|
+
return null;
|
|
2531
|
+
}
|
|
2532
|
+
return browserLocation;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2523
2535
|
// src/passkey/passkeyNavigation.ts
|
|
2524
2536
|
var PASSKEY_LOGIN_ENDPOINT = "/bff/passkey/login";
|
|
2525
2537
|
var PASSKEY_REGISTER_ENDPOINT = "/bff/passkey/register";
|
|
@@ -2533,22 +2545,25 @@ function buildNavigationUrl(endpoint, returnUrl) {
|
|
|
2533
2545
|
return `${endpoint}?${RETURN_URL_PARAM}=${encodeURIComponent(returnUrl)}`;
|
|
2534
2546
|
}
|
|
2535
2547
|
function readSearchParams() {
|
|
2536
|
-
|
|
2548
|
+
const browserLocation = getBrowserLocation();
|
|
2549
|
+
if (browserLocation === null) {
|
|
2537
2550
|
return null;
|
|
2538
2551
|
}
|
|
2539
|
-
return new URLSearchParams(
|
|
2552
|
+
return new URLSearchParams(browserLocation.search);
|
|
2540
2553
|
}
|
|
2541
2554
|
function startPasskeyLogin(returnUrl) {
|
|
2542
|
-
|
|
2555
|
+
const browserLocation = getBrowserLocation();
|
|
2556
|
+
if (browserLocation === null) {
|
|
2543
2557
|
return;
|
|
2544
2558
|
}
|
|
2545
|
-
|
|
2559
|
+
browserLocation.assign(buildNavigationUrl(PASSKEY_LOGIN_ENDPOINT, returnUrl));
|
|
2546
2560
|
}
|
|
2547
2561
|
function startPasskeyRegistration(returnUrl) {
|
|
2548
|
-
|
|
2562
|
+
const browserLocation = getBrowserLocation();
|
|
2563
|
+
if (browserLocation === null) {
|
|
2549
2564
|
return;
|
|
2550
2565
|
}
|
|
2551
|
-
|
|
2566
|
+
browserLocation.assign(buildNavigationUrl(PASSKEY_REGISTER_ENDPOINT, returnUrl));
|
|
2552
2567
|
}
|
|
2553
2568
|
function readPasskeyError() {
|
|
2554
2569
|
const params = readSearchParams();
|
|
@@ -2725,8 +2740,9 @@ function usePasskeyCeremony(optionsArg) {
|
|
|
2725
2740
|
onSuccess(user);
|
|
2726
2741
|
return;
|
|
2727
2742
|
}
|
|
2728
|
-
|
|
2729
|
-
|
|
2743
|
+
const browserLocation = getBrowserLocation();
|
|
2744
|
+
if (mode === "login" /* Login */ && browserLocation !== null) {
|
|
2745
|
+
browserLocation.assign(returnUrl);
|
|
2730
2746
|
}
|
|
2731
2747
|
},
|
|
2732
2748
|
[mode, onSuccess, returnUrl]
|
|
@@ -2848,10 +2864,11 @@ function PasskeyLoginButton({
|
|
|
2848
2864
|
}
|
|
2849
2865
|
var DEFAULT_RETURN_PATH = "/";
|
|
2850
2866
|
function readCurrentPath() {
|
|
2851
|
-
|
|
2867
|
+
const browserLocation = getBrowserLocation();
|
|
2868
|
+
if (browserLocation === null) {
|
|
2852
2869
|
return DEFAULT_RETURN_PATH;
|
|
2853
2870
|
}
|
|
2854
|
-
return
|
|
2871
|
+
return browserLocation.pathname;
|
|
2855
2872
|
}
|
|
2856
2873
|
function PasskeySettingsCard({
|
|
2857
2874
|
returnUrl,
|