@bounded-sh/client 0.0.29 → 0.0.30
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/auth/oidc-auth.d.ts +7 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +23 -2
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +23 -2
- package/dist/index.native.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.native.mjs
CHANGED
|
@@ -4230,7 +4230,11 @@ async function buildAuthorize(opts, guestHint) {
|
|
|
4230
4230
|
const cfg = await getConfig();
|
|
4231
4231
|
if (!cfg.appId)
|
|
4232
4232
|
throw new Error('appId is not configured (init the SDK with your appId)');
|
|
4233
|
-
|
|
4233
|
+
// Web: default to the current page so callers don't have to pass redirectUri. Native has no
|
|
4234
|
+
// window — it MUST pass an https universal link (the system auth session needs a real URL).
|
|
4235
|
+
const redirectUri = opts.redirectUri || (hasDOM() ? window.location.origin + window.location.pathname : undefined);
|
|
4236
|
+
if (!redirectUri)
|
|
4237
|
+
throw new Error('redirectUri is required on React Native — pass the https universal link the app owner registered.');
|
|
4234
4238
|
const { verifier, challenge } = await makePkce();
|
|
4235
4239
|
const state = randomState();
|
|
4236
4240
|
const base = await issuerBase();
|
|
@@ -4389,6 +4393,21 @@ async function completeLoginFromRedirect() {
|
|
|
4389
4393
|
const returnedState = url.searchParams.get('state');
|
|
4390
4394
|
if (!code)
|
|
4391
4395
|
return null;
|
|
4396
|
+
// POPUP path: if we're the redirect_uri page running INSIDE the loginWithPopup() window,
|
|
4397
|
+
// hand the code to the opener and close — no separate completeLoginInPopup() call needed.
|
|
4398
|
+
// The opener is the same app/origin, so post to our own origin (the opener's message
|
|
4399
|
+
// handler checks ev.origin === redirect_uri origin). One call now finishes BOTH flows.
|
|
4400
|
+
if (window.opener && window.opener !== window) {
|
|
4401
|
+
try {
|
|
4402
|
+
window.opener.postMessage({ type: 'bounded-oidc-code', code, state: returnedState }, window.location.origin);
|
|
4403
|
+
}
|
|
4404
|
+
catch ( /* ignore */_a) { /* ignore */ }
|
|
4405
|
+
try {
|
|
4406
|
+
window.close();
|
|
4407
|
+
}
|
|
4408
|
+
catch ( /* ignore */_b) { /* ignore */ }
|
|
4409
|
+
return null;
|
|
4410
|
+
}
|
|
4392
4411
|
setAuthLoading(true);
|
|
4393
4412
|
try {
|
|
4394
4413
|
const raw = sessionStorage.getItem(PKCE_STORE_KEY);
|
|
@@ -4422,7 +4441,9 @@ async function loginWithPopup(opts) {
|
|
|
4422
4441
|
const popup = window.open(url, 'bounded-oidc', `width=${w},height=${h},left=${left},top=${top}`);
|
|
4423
4442
|
if (!popup)
|
|
4424
4443
|
throw new Error('Popup blocked — use loginWithRedirect() instead');
|
|
4425
|
-
|
|
4444
|
+
// Use the RESOLVED redirect_uri (buildAuthorize defaulted it to the current page on web),
|
|
4445
|
+
// not opts.redirectUri which may be undefined.
|
|
4446
|
+
const expectedOrigin = new URL(pkce.redirectUri).origin;
|
|
4426
4447
|
return await new Promise((resolve, reject) => {
|
|
4427
4448
|
const onMsg = async (ev) => {
|
|
4428
4449
|
if (ev.origin !== expectedOrigin)
|