@stackframe/tanstack-start 2.8.95 → 2.8.98
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/components-page/stack-handler-client.d.ts.map +1 -1
- package/dist/components-page/stack-handler-client.js +28 -21
- package/dist/components-page/stack-handler-client.js.map +1 -1
- package/dist/esm/components-page/stack-handler-client.d.ts.map +1 -1
- package/dist/esm/components-page/stack-handler-client.js +28 -21
- package/dist/esm/components-page/stack-handler-client.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js +55 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts +9 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +45 -15
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.js +2 -4
- package/dist/esm/lib/stack-app/url-targets.js.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.test.js +5 -4
- package/dist/esm/lib/stack-app/url-targets.test.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +2 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.d.ts +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js +55 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +9 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +45 -15
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +1 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/url-targets.d.ts.map +1 -1
- package/dist/lib/stack-app/url-targets.js +2 -4
- package/dist/lib/stack-app/url-targets.js.map +1 -1
- package/dist/lib/stack-app/url-targets.test.js +5 -4
- package/dist/lib/stack-app/url-targets.test.js.map +1 -1
- package/package.json +3 -3
|
@@ -503,14 +503,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
503
503
|
return currentUrl.toString();
|
|
504
504
|
}
|
|
505
505
|
async _getCurrentRefreshTokenIdIfSignedIn(options) {
|
|
506
|
-
const tokens = await (await this._getSession(
|
|
506
|
+
const tokens = await (await this._getSession(options?.overrideTokenStoreInit, options)).getOrFetchLikelyValidTokens(0, null);
|
|
507
507
|
if (tokens?.refreshToken == null) return null;
|
|
508
508
|
return tokens.accessToken.payload.refresh_token_id;
|
|
509
509
|
}
|
|
510
510
|
async _addNestedCrossDomainAuthParamsToRedirectUrl(options) {
|
|
511
511
|
const targetUrl = new URL(options.url, options.currentUrl);
|
|
512
512
|
if (targetUrl.origin === options.currentUrl.origin) return options.url;
|
|
513
|
-
const refreshTokenId = await this._getCurrentRefreshTokenIdIfSignedIn({
|
|
513
|
+
const refreshTokenId = await this._getCurrentRefreshTokenIdIfSignedIn({
|
|
514
|
+
awaitPendingAuthResolutions: options.awaitPendingAuthResolutions,
|
|
515
|
+
overrideTokenStoreInit: options.overrideTokenStoreInit
|
|
516
|
+
});
|
|
514
517
|
if (refreshTokenId == null) return options.url;
|
|
515
518
|
targetUrl.searchParams.set(nestedCrossDomainAuthQueryParams.refreshTokenId, refreshTokenId);
|
|
516
519
|
targetUrl.searchParams.set(nestedCrossDomainAuthQueryParams.callbackUrl, new URL(this._getOAuthCallbackRedirectUri(), options.currentUrl).toString());
|
|
@@ -958,6 +961,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
958
961
|
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
959
962
|
this._currentUserCache.getOrWait([newSession], "write-only").catch(() => {});
|
|
960
963
|
}
|
|
964
|
+
_getTokenStoreInitForFreshTokens(tokens) {
|
|
965
|
+
if (tokens.accessToken == null) return;
|
|
966
|
+
return {
|
|
967
|
+
accessToken: tokens.accessToken,
|
|
968
|
+
refreshToken: tokens.refreshToken
|
|
969
|
+
};
|
|
970
|
+
}
|
|
961
971
|
_hasPersistentTokenStore(overrideTokenStoreInit) {
|
|
962
972
|
return (overrideTokenStoreInit !== void 0 ? overrideTokenStoreInit : this._tokenStoreInit) !== null;
|
|
963
973
|
}
|
|
@@ -1999,7 +2009,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1999
2009
|
}).oauthCallback;
|
|
2000
2010
|
}
|
|
2001
2011
|
async _createCrossDomainAuthRedirectUrl(options) {
|
|
2002
|
-
const session = await this._getSession(
|
|
2012
|
+
const session = await this._getSession(options.overrideTokenStoreInit, { awaitPendingAuthResolutions: options.awaitPendingAuthResolutions });
|
|
2003
2013
|
const response = await this._interface.sendClientRequest("/auth/oauth/cross-domain/authorize", {
|
|
2004
2014
|
method: "POST",
|
|
2005
2015
|
headers: { "Content-Type": "application/json" },
|
|
@@ -2011,7 +2021,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2011
2021
|
after_callback_redirect_url: options.afterCallbackRedirectUrl
|
|
2012
2022
|
})
|
|
2013
2023
|
}, session);
|
|
2014
|
-
if (!response.ok)
|
|
2024
|
+
if (!response.ok) {
|
|
2025
|
+
const responseBody = await response.text();
|
|
2026
|
+
throw new _stackframe_stack_shared_dist_utils_errors.StackAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${responseBody}`);
|
|
2027
|
+
}
|
|
2015
2028
|
const result = await response.json();
|
|
2016
2029
|
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new _stackframe_stack_shared_dist_utils_errors.StackAssertionError("Cross-domain authorization endpoint returned an invalid payload", { result });
|
|
2017
2030
|
return result.redirect_url;
|
|
@@ -2071,7 +2084,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2071
2084
|
state: plan.state,
|
|
2072
2085
|
codeChallenge: plan.codeChallenge,
|
|
2073
2086
|
afterCallbackRedirectUrl: plan.afterCallbackRedirectUrl,
|
|
2074
|
-
awaitPendingAuthResolutions: internalOptions?.awaitPendingAuthResolutions
|
|
2087
|
+
awaitPendingAuthResolutions: internalOptions?.awaitPendingAuthResolutions,
|
|
2088
|
+
overrideTokenStoreInit: internalOptions?.overrideTokenStoreInit
|
|
2075
2089
|
});
|
|
2076
2090
|
await this._redirectTo({
|
|
2077
2091
|
url: crossDomainRedirectUrl,
|
|
@@ -2082,7 +2096,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2082
2096
|
const redirectUrl = currentUrl != null && handlerName !== "signOut" && handlerName !== "afterSignOut" && handlerName !== "oauthCallback" ? await this._addNestedCrossDomainAuthParamsToRedirectUrl({
|
|
2083
2097
|
url: plan.url,
|
|
2084
2098
|
currentUrl,
|
|
2085
|
-
awaitPendingAuthResolutions: internalOptions?.awaitPendingAuthResolutions
|
|
2099
|
+
awaitPendingAuthResolutions: internalOptions?.awaitPendingAuthResolutions,
|
|
2100
|
+
overrideTokenStoreInit: internalOptions?.overrideTokenStoreInit
|
|
2086
2101
|
}) : plan.url;
|
|
2087
2102
|
await this._redirectIfTrusted(redirectUrl, options);
|
|
2088
2103
|
}
|
|
@@ -2407,7 +2422,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2407
2422
|
}
|
|
2408
2423
|
if (result.status === "ok") {
|
|
2409
2424
|
await this._signInToAccountWithTokens(result.data);
|
|
2410
|
-
if (!options.noRedirect) await this.
|
|
2425
|
+
if (!options.noRedirect) await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2411
2426
|
return _stackframe_stack_shared_dist_utils_results.Result.ok(void 0);
|
|
2412
2427
|
} else return _stackframe_stack_shared_dist_utils_results.Result.error(result.error);
|
|
2413
2428
|
}
|
|
@@ -2433,7 +2448,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2433
2448
|
});
|
|
2434
2449
|
if (result.status === "ok") {
|
|
2435
2450
|
await this._signInToAccountWithTokens(result.data);
|
|
2436
|
-
if (!options.noRedirect) await this.
|
|
2451
|
+
if (!options.noRedirect) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2437
2452
|
return _stackframe_stack_shared_dist_utils_results.Result.ok(void 0);
|
|
2438
2453
|
} else return _stackframe_stack_shared_dist_utils_results.Result.error(result.error);
|
|
2439
2454
|
}
|
|
@@ -2464,8 +2479,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2464
2479
|
}
|
|
2465
2480
|
if (result.status === "ok") {
|
|
2466
2481
|
await this._signInToAccountWithTokens(result.data);
|
|
2467
|
-
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, {
|
|
2468
|
-
|
|
2482
|
+
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, {
|
|
2483
|
+
awaitPendingAuthResolutions: false,
|
|
2484
|
+
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2485
|
+
});
|
|
2486
|
+
else await this._redirectToHandler("afterSignIn", { replace: true }, {
|
|
2487
|
+
awaitPendingAuthResolutions: false,
|
|
2488
|
+
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2489
|
+
});
|
|
2469
2490
|
return _stackframe_stack_shared_dist_utils_results.Result.ok(void 0);
|
|
2470
2491
|
} else return _stackframe_stack_shared_dist_utils_results.Result.error(result.error);
|
|
2471
2492
|
}
|
|
@@ -2547,8 +2568,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2547
2568
|
}
|
|
2548
2569
|
if (result.status === "ok") {
|
|
2549
2570
|
await this._signInToAccountWithTokens(result.data);
|
|
2550
|
-
if (!options?.noRedirect) if (result.data.newUser) await this.
|
|
2551
|
-
else await this.
|
|
2571
|
+
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2572
|
+
else await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2552
2573
|
return _stackframe_stack_shared_dist_utils_results.Result.ok(void 0);
|
|
2553
2574
|
}
|
|
2554
2575
|
return _stackframe_stack_shared_dist_utils_results.Result.error(result.error);
|
|
@@ -2576,7 +2597,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2576
2597
|
}
|
|
2577
2598
|
if (result.status === "ok") {
|
|
2578
2599
|
await this._signInToAccountWithTokens(result.data);
|
|
2579
|
-
await this.
|
|
2600
|
+
await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2580
2601
|
return _stackframe_stack_shared_dist_utils_results.Result.ok(void 0);
|
|
2581
2602
|
} else return _stackframe_stack_shared_dist_utils_results.Result.error(result.error);
|
|
2582
2603
|
}
|
|
@@ -2611,10 +2632,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2611
2632
|
});
|
|
2612
2633
|
return true;
|
|
2613
2634
|
} else if (result.data.newUser) {
|
|
2614
|
-
await this._redirectToHandler("afterSignUp", { replace: true }, {
|
|
2635
|
+
await this._redirectToHandler("afterSignUp", { replace: true }, {
|
|
2636
|
+
awaitPendingAuthResolutions: false,
|
|
2637
|
+
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2638
|
+
});
|
|
2615
2639
|
return true;
|
|
2616
2640
|
} else {
|
|
2617
|
-
await this._redirectToHandler("afterSignIn", { replace: true }, {
|
|
2641
|
+
await this._redirectToHandler("afterSignIn", { replace: true }, {
|
|
2642
|
+
awaitPendingAuthResolutions: false,
|
|
2643
|
+
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2644
|
+
});
|
|
2618
2645
|
return true;
|
|
2619
2646
|
}
|
|
2620
2647
|
}
|
|
@@ -2788,6 +2815,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2788
2815
|
...options
|
|
2789
2816
|
});
|
|
2790
2817
|
},
|
|
2818
|
+
redirectToHandler: async (handlerName, options) => {
|
|
2819
|
+
await this._redirectToHandler(handlerName, options);
|
|
2820
|
+
},
|
|
2791
2821
|
refreshOwnedProjects: async () => {
|
|
2792
2822
|
await this._refreshOwnedProjects(await this._getSession());
|
|
2793
2823
|
},
|