@stackframe/stack 2.5.8 → 2.5.10
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/CHANGELOG.md +20 -0
- package/dist/components/credential-sign-in.d.mts +5 -0
- package/dist/components/credential-sign-in.d.ts +5 -0
- package/dist/components/{credential-sign-in-form.js → credential-sign-in.js} +8 -8
- package/dist/components/credential-sign-in.js.map +1 -0
- package/dist/components/credential-sign-up.d.mts +5 -0
- package/dist/components/credential-sign-up.d.ts +5 -0
- package/dist/components/{credential-sign-up-form.js → credential-sign-up.js} +8 -8
- package/dist/components/credential-sign-up.js.map +1 -0
- package/dist/components/elements/user-avatar.d.mts +1 -1
- package/dist/components/elements/user-avatar.d.ts +1 -1
- package/dist/components/magic-link-sign-in.d.mts +5 -0
- package/dist/components/magic-link-sign-in.d.ts +5 -0
- package/dist/components/{magic-link-sign-in-form.js → magic-link-sign-in.js} +8 -8
- package/dist/components/magic-link-sign-in.js.map +1 -0
- package/dist/components/message-cards/predefined-message-card.js +8 -8
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/selected-team-switcher.d.mts +1 -1
- package/dist/components/selected-team-switcher.d.ts +1 -1
- package/dist/components/user-button.js +3 -3
- package/dist/components/user-button.js.map +1 -1
- package/dist/components-page/account-settings.js +4 -4
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.js +21 -8
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/stack-handler.d.mts +2 -2
- package/dist/components-page/stack-handler.d.ts +2 -2
- package/dist/components-page/stack-handler.js +8 -15
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components/{credential-sign-in-form.js → credential-sign-in.js} +4 -4
- package/dist/esm/components/credential-sign-in.js.map +1 -0
- package/dist/esm/components/{credential-sign-up-form.js → credential-sign-up.js} +4 -4
- package/dist/esm/components/credential-sign-up.js.map +1 -0
- package/dist/esm/components/{magic-link-sign-in-form.js → magic-link-sign-in.js} +4 -4
- package/dist/esm/components/magic-link-sign-in.js.map +1 -0
- package/dist/esm/components/message-cards/predefined-message-card.js +8 -8
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/esm/components/user-button.js +3 -3
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +4 -4
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.js +21 -8
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +8 -15
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/index.js +7 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/auth.js +3 -3
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/cookie.js +8 -6
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/stack-app.js +143 -93
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js +1 -3
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/esm/utils/url.js +9 -1
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/auth.js +3 -3
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/cookie.js +6 -6
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/hooks.d.mts +1 -1
- package/dist/lib/hooks.d.ts +1 -1
- package/dist/lib/stack-app.d.mts +59 -23
- package/dist/lib/stack-app.d.ts +59 -23
- package/dist/lib/stack-app.js +143 -93
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/stack-provider-client.d.mts +1 -1
- package/dist/providers/stack-provider-client.d.ts +1 -1
- package/dist/providers/stack-provider-client.js +1 -3
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/dist/providers/stack-provider.d.mts +1 -1
- package/dist/providers/stack-provider.d.ts +1 -1
- package/dist/utils/url.js +9 -1
- package/dist/utils/url.js.map +1 -1
- package/package.json +6 -4
- package/dist/components/credential-sign-in-form.d.mts +0 -5
- package/dist/components/credential-sign-in-form.d.ts +0 -5
- package/dist/components/credential-sign-in-form.js.map +0 -1
- package/dist/components/credential-sign-up-form.d.mts +0 -5
- package/dist/components/credential-sign-up-form.d.ts +0 -5
- package/dist/components/credential-sign-up-form.js.map +0 -1
- package/dist/components/magic-link-sign-in-form.d.mts +0 -5
- package/dist/components/magic-link-sign-in-form.d.ts +0 -5
- package/dist/components/magic-link-sign-in-form.js.map +0 -1
- package/dist/esm/components/credential-sign-in-form.js.map +0 -1
- package/dist/esm/components/credential-sign-up-form.js.map +0 -1
- package/dist/esm/components/magic-link-sign-in-form.js.map +0 -1
|
@@ -14,6 +14,7 @@ import { suspend, suspendIfSsr } from "@stackframe/stack-shared/dist/utils/react
|
|
|
14
14
|
import { Result } from "@stackframe/stack-shared/dist/utils/results";
|
|
15
15
|
import { Store } from "@stackframe/stack-shared/dist/utils/stores";
|
|
16
16
|
import { mergeScopeStrings } from "@stackframe/stack-shared/dist/utils/strings";
|
|
17
|
+
import { getRelativePart, isRelative } from "@stackframe/stack-shared/dist/utils/urls";
|
|
17
18
|
import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
|
|
18
19
|
import * as cookie from "cookie";
|
|
19
20
|
import * as NextNavigationUnscrambled from "next/navigation";
|
|
@@ -22,23 +23,25 @@ import { constructRedirectUrl } from "../utils/url";
|
|
|
22
23
|
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
|
|
23
24
|
import { deleteCookie, getCookie, setOrDeleteCookie } from "./cookie";
|
|
24
25
|
var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
|
|
25
|
-
var clientVersion = "js @stackframe/stack@2.5.
|
|
26
|
+
var clientVersion = "js @stackframe/stack@2.5.10";
|
|
26
27
|
function getUrls(partial) {
|
|
27
28
|
const handler = partial.handler ?? "/handler";
|
|
29
|
+
const home = partial.home ?? "/";
|
|
30
|
+
const afterSignIn = partial.afterSignIn ?? home;
|
|
28
31
|
return {
|
|
29
32
|
handler,
|
|
30
33
|
signIn: `${handler}/sign-in`,
|
|
31
|
-
afterSignIn:
|
|
34
|
+
afterSignIn: home,
|
|
32
35
|
signUp: `${handler}/sign-up`,
|
|
33
|
-
afterSignUp:
|
|
36
|
+
afterSignUp: afterSignIn,
|
|
34
37
|
signOut: `${handler}/sign-out`,
|
|
35
|
-
afterSignOut:
|
|
38
|
+
afterSignOut: home,
|
|
36
39
|
emailVerification: `${handler}/email-verification`,
|
|
37
40
|
passwordReset: `${handler}/password-reset`,
|
|
38
41
|
forgotPassword: `${handler}/forgot-password`,
|
|
39
42
|
oauthCallback: `${handler}/oauth-callback`,
|
|
40
43
|
magicLinkCallback: `${handler}/magic-link-callback`,
|
|
41
|
-
home
|
|
44
|
+
home,
|
|
42
45
|
accountSettings: `${handler}/account-settings`,
|
|
43
46
|
error: `${handler}/error`,
|
|
44
47
|
...filterUndefined(partial)
|
|
@@ -46,7 +49,7 @@ function getUrls(partial) {
|
|
|
46
49
|
}
|
|
47
50
|
async function _redirectTo(url, options) {
|
|
48
51
|
if (isReactServer) {
|
|
49
|
-
NextNavigation.redirect(url, options?.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
|
|
52
|
+
NextNavigation.redirect(url.toString(), options?.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
|
|
50
53
|
} else {
|
|
51
54
|
if (options?.replace) {
|
|
52
55
|
window.location.replace(url);
|
|
@@ -149,7 +152,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
149
152
|
this._currentUserOAuthConnectionAccessTokensCache = createCacheBySession(
|
|
150
153
|
async (session, [accountId, scope]) => {
|
|
151
154
|
try {
|
|
152
|
-
|
|
155
|
+
const result = await this._interface.createProviderAccessToken(accountId, scope || "", session);
|
|
156
|
+
return {
|
|
157
|
+
accessToken: result.access_token
|
|
158
|
+
};
|
|
153
159
|
} catch (err) {
|
|
154
160
|
if (!(err instanceof KnownErrors.OAuthConnectionDoesNotHaveRequiredScope || err instanceof KnownErrors.OAuthConnectionNotConnectedToUser)) {
|
|
155
161
|
throw err;
|
|
@@ -261,12 +267,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
261
267
|
}
|
|
262
268
|
return this._uniqueIdentifier;
|
|
263
269
|
}
|
|
264
|
-
async _checkFeatureSupport(
|
|
265
|
-
return await this._interface.checkFeatureSupport({ ...options,
|
|
270
|
+
async _checkFeatureSupport(name, options) {
|
|
271
|
+
return await this._interface.checkFeatureSupport({ ...options, name });
|
|
266
272
|
}
|
|
267
|
-
_useCheckFeatureSupport(
|
|
268
|
-
runAsynchronously(this._checkFeatureSupport(
|
|
269
|
-
throw new StackAssertionError(`${
|
|
273
|
+
_useCheckFeatureSupport(name, options) {
|
|
274
|
+
runAsynchronously(this._checkFeatureSupport(name, options));
|
|
275
|
+
throw new StackAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
270
276
|
}
|
|
271
277
|
get _refreshTokenCookieName() {
|
|
272
278
|
return `stack-refresh-${this.projectId}`;
|
|
@@ -529,7 +535,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
529
535
|
}
|
|
530
536
|
};
|
|
531
537
|
}
|
|
532
|
-
|
|
538
|
+
_createUserExtra(crud, session) {
|
|
533
539
|
const app = this;
|
|
534
540
|
async function getConnectedAccount(id, options) {
|
|
535
541
|
const scopeString = options?.scopes?.join(" ");
|
|
@@ -599,7 +605,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
599
605
|
return app._updateClientUser(update, session);
|
|
600
606
|
},
|
|
601
607
|
sendVerificationEmail() {
|
|
602
|
-
|
|
608
|
+
if (!crud?.primary_email) {
|
|
609
|
+
throw new StackAssertionError("User does not have a primary email");
|
|
610
|
+
}
|
|
611
|
+
return app._sendVerificationEmail(crud.primary_email, session);
|
|
603
612
|
},
|
|
604
613
|
updatePassword(options) {
|
|
605
614
|
return app._updatePassword(options, session);
|
|
@@ -625,7 +634,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
625
634
|
const currentUser = {
|
|
626
635
|
...this._createBaseUser(crud),
|
|
627
636
|
...this._createAuth(session),
|
|
628
|
-
...this.
|
|
637
|
+
...this._createUserExtra(crud, session),
|
|
629
638
|
...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
|
|
630
639
|
};
|
|
631
640
|
Object.freeze(currentUser);
|
|
@@ -646,57 +655,93 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
646
655
|
get projectId() {
|
|
647
656
|
return this._interface.projectId;
|
|
648
657
|
}
|
|
658
|
+
async _isTrusted(url) {
|
|
659
|
+
return isRelative(url);
|
|
660
|
+
}
|
|
649
661
|
get urls() {
|
|
650
662
|
return getUrls(this._urlOptions);
|
|
651
663
|
}
|
|
652
|
-
async
|
|
653
|
-
|
|
664
|
+
async _redirectIfTrusted(url, options) {
|
|
665
|
+
if (!await this._isTrusted(url)) {
|
|
666
|
+
throw new Error(`Redirect URL ${url} is not trusted; should be relative.`);
|
|
667
|
+
}
|
|
668
|
+
return await _redirectTo(url, options);
|
|
669
|
+
}
|
|
670
|
+
async _redirectToHandler(handlerName, options) {
|
|
671
|
+
let url = this.urls[handlerName];
|
|
654
672
|
if (!url) {
|
|
655
673
|
throw new Error(`No URL for handler name ${handlerName}`);
|
|
656
674
|
}
|
|
657
|
-
|
|
675
|
+
if (handlerName === "afterSignIn" || handlerName === "afterSignUp") {
|
|
676
|
+
if (isReactServer || typeof window === "undefined") {
|
|
677
|
+
try {
|
|
678
|
+
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
679
|
+
} catch (e) {
|
|
680
|
+
}
|
|
681
|
+
} else {
|
|
682
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
683
|
+
url = queryParams.get("after_auth_return_to") || url;
|
|
684
|
+
}
|
|
685
|
+
} else if (handlerName === "signIn" || handlerName === "signUp") {
|
|
686
|
+
if (isReactServer || typeof window === "undefined") {
|
|
687
|
+
try {
|
|
688
|
+
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
689
|
+
} catch (e) {
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
const currentUrl = new URL(window.location.href);
|
|
693
|
+
const nextUrl = new URL(url, currentUrl);
|
|
694
|
+
if (currentUrl.searchParams.has("after_auth_return_to")) {
|
|
695
|
+
nextUrl.searchParams.set("after_auth_return_to", currentUrl.searchParams.get("after_auth_return_to"));
|
|
696
|
+
} else if (currentUrl.protocol === nextUrl.protocol && currentUrl.host === nextUrl.host) {
|
|
697
|
+
nextUrl.searchParams.set("after_auth_return_to", getRelativePart(currentUrl));
|
|
698
|
+
}
|
|
699
|
+
url = getRelativePart(nextUrl);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
await this._redirectIfTrusted(url, options);
|
|
658
703
|
}
|
|
659
|
-
async redirectToSignIn() {
|
|
660
|
-
return await this.
|
|
704
|
+
async redirectToSignIn(options) {
|
|
705
|
+
return await this._redirectToHandler("signIn", options);
|
|
661
706
|
}
|
|
662
|
-
async redirectToSignUp() {
|
|
663
|
-
return await this.
|
|
707
|
+
async redirectToSignUp(options) {
|
|
708
|
+
return await this._redirectToHandler("signUp", options);
|
|
664
709
|
}
|
|
665
|
-
async redirectToSignOut() {
|
|
666
|
-
return await this.
|
|
710
|
+
async redirectToSignOut(options) {
|
|
711
|
+
return await this._redirectToHandler("signOut", options);
|
|
667
712
|
}
|
|
668
|
-
async redirectToEmailVerification() {
|
|
669
|
-
return await this.
|
|
713
|
+
async redirectToEmailVerification(options) {
|
|
714
|
+
return await this._redirectToHandler("emailVerification", options);
|
|
670
715
|
}
|
|
671
|
-
async redirectToPasswordReset() {
|
|
672
|
-
return await this.
|
|
716
|
+
async redirectToPasswordReset(options) {
|
|
717
|
+
return await this._redirectToHandler("passwordReset", options);
|
|
673
718
|
}
|
|
674
|
-
async redirectToForgotPassword() {
|
|
675
|
-
return await this.
|
|
719
|
+
async redirectToForgotPassword(options) {
|
|
720
|
+
return await this._redirectToHandler("forgotPassword", options);
|
|
676
721
|
}
|
|
677
|
-
async redirectToHome() {
|
|
678
|
-
return await this.
|
|
722
|
+
async redirectToHome(options) {
|
|
723
|
+
return await this._redirectToHandler("home", options);
|
|
679
724
|
}
|
|
680
|
-
async redirectToOAuthCallback() {
|
|
681
|
-
return await this.
|
|
725
|
+
async redirectToOAuthCallback(options) {
|
|
726
|
+
return await this._redirectToHandler("oauthCallback", options);
|
|
682
727
|
}
|
|
683
|
-
async redirectToMagicLinkCallback() {
|
|
684
|
-
return await this.
|
|
728
|
+
async redirectToMagicLinkCallback(options) {
|
|
729
|
+
return await this._redirectToHandler("magicLinkCallback", options);
|
|
685
730
|
}
|
|
686
|
-
async redirectToAfterSignIn() {
|
|
687
|
-
return await this.
|
|
731
|
+
async redirectToAfterSignIn(options) {
|
|
732
|
+
return await this._redirectToHandler("afterSignIn", options);
|
|
688
733
|
}
|
|
689
|
-
async redirectToAfterSignUp() {
|
|
690
|
-
return await this.
|
|
734
|
+
async redirectToAfterSignUp(options) {
|
|
735
|
+
return await this._redirectToHandler("afterSignUp", options);
|
|
691
736
|
}
|
|
692
|
-
async redirectToAfterSignOut() {
|
|
693
|
-
return await this.
|
|
737
|
+
async redirectToAfterSignOut(options) {
|
|
738
|
+
return await this._redirectToHandler("afterSignOut", options);
|
|
694
739
|
}
|
|
695
|
-
async redirectToAccountSettings() {
|
|
696
|
-
return await this.
|
|
740
|
+
async redirectToAccountSettings(options) {
|
|
741
|
+
return await this._redirectToHandler("accountSettings", options);
|
|
697
742
|
}
|
|
698
|
-
async redirectToError() {
|
|
699
|
-
return await this.
|
|
743
|
+
async redirectToError(options) {
|
|
744
|
+
return await this._redirectToHandler("error", options);
|
|
700
745
|
}
|
|
701
746
|
async sendForgotPasswordEmail(email) {
|
|
702
747
|
const redirectUrl = constructRedirectUrl(this.urls.passwordReset);
|
|
@@ -725,7 +770,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
725
770
|
if (crud === null) {
|
|
726
771
|
switch (options?.or) {
|
|
727
772
|
case "redirect": {
|
|
728
|
-
await this.redirectToSignIn();
|
|
773
|
+
await this.redirectToSignIn({ replace: true });
|
|
729
774
|
break;
|
|
730
775
|
}
|
|
731
776
|
case "throw": {
|
|
@@ -746,7 +791,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
746
791
|
if (crud === null) {
|
|
747
792
|
switch (options?.or) {
|
|
748
793
|
case "redirect": {
|
|
749
|
-
|
|
794
|
+
runAsynchronously(this.redirectToSignIn({ replace: true }));
|
|
750
795
|
suspend();
|
|
751
796
|
throw new StackAssertionError("suspend should never return");
|
|
752
797
|
}
|
|
@@ -840,9 +885,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
840
885
|
await this._interface.signOut(session);
|
|
841
886
|
await this.redirectToAfterSignOut();
|
|
842
887
|
}
|
|
843
|
-
async _sendVerificationEmail(session) {
|
|
888
|
+
async _sendVerificationEmail(email, session) {
|
|
844
889
|
const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
|
|
845
|
-
return await this._interface.sendVerificationEmail(emailVerificationRedirectUrl, session);
|
|
890
|
+
return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
|
|
846
891
|
}
|
|
847
892
|
async _updatePassword(options, session) {
|
|
848
893
|
return await this._interface.updatePassword(options, session);
|
|
@@ -987,7 +1032,13 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
987
1032
|
return await this._interface.listServerTeamMemberPermissions({ teamId, userId, recursive });
|
|
988
1033
|
});
|
|
989
1034
|
}
|
|
1035
|
+
async _updateServerUser(userId, update) {
|
|
1036
|
+
const result = await this._interface.updateServerUser(userId, userUpdateOptionsToCrud(update));
|
|
1037
|
+
await this._refreshUsers();
|
|
1038
|
+
return result;
|
|
1039
|
+
}
|
|
990
1040
|
_createBaseUser(crud) {
|
|
1041
|
+
const app = this;
|
|
991
1042
|
if (!crud) {
|
|
992
1043
|
throw new StackAssertionError("User not found");
|
|
993
1044
|
}
|
|
@@ -996,10 +1047,41 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
996
1047
|
..."server_metadata" in crud ? {
|
|
997
1048
|
// server user
|
|
998
1049
|
serverMetadata: crud.server_metadata
|
|
999
|
-
} : {}
|
|
1050
|
+
} : {},
|
|
1051
|
+
async setServerMetadata(metadata) {
|
|
1052
|
+
await app._updateServerUser(crud.id, { serverMetadata: metadata });
|
|
1053
|
+
},
|
|
1054
|
+
async setPrimaryEmail(email, options) {
|
|
1055
|
+
await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });
|
|
1056
|
+
},
|
|
1057
|
+
async grantPermission(scope, permissionId) {
|
|
1058
|
+
await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1059
|
+
for (const recursive of [true, false]) {
|
|
1060
|
+
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
async revokePermission(scope, permissionId) {
|
|
1064
|
+
await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1065
|
+
for (const recursive of [true, false]) {
|
|
1066
|
+
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
async delete() {
|
|
1070
|
+
const res = await app._interface.deleteServerServerUser(crud.id);
|
|
1071
|
+
await app._refreshUsers();
|
|
1072
|
+
return res;
|
|
1073
|
+
},
|
|
1074
|
+
async createSession(options) {
|
|
1075
|
+
const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1e3 * 60 * 60 * 24 * 365);
|
|
1076
|
+
return {
|
|
1077
|
+
async getTokens() {
|
|
1078
|
+
return tokens;
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1000
1082
|
};
|
|
1001
1083
|
}
|
|
1002
|
-
|
|
1084
|
+
_createUserExtra(crud) {
|
|
1003
1085
|
if (!crud) {
|
|
1004
1086
|
throw new StackAssertionError("User not found");
|
|
1005
1087
|
}
|
|
@@ -1011,15 +1093,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1011
1093
|
async setClientMetadata(metadata) {
|
|
1012
1094
|
return await this.update({ clientMetadata: metadata });
|
|
1013
1095
|
},
|
|
1014
|
-
async setServerMetadata(metadata) {
|
|
1015
|
-
return await this.update({ serverMetadata: metadata });
|
|
1016
|
-
},
|
|
1017
1096
|
async setSelectedTeam(team) {
|
|
1018
1097
|
return await this.update({ selectedTeamId: team?.id ?? null });
|
|
1019
1098
|
},
|
|
1020
|
-
async setPrimaryEmail(email, options) {
|
|
1021
|
-
return await this.update({ primaryEmail: email, primaryEmailVerified: options?.verified });
|
|
1022
|
-
},
|
|
1023
1099
|
getConnectedAccount: async () => {
|
|
1024
1100
|
return await app._checkFeatureSupport("getConnectedAccount() on ServerUser", {});
|
|
1025
1101
|
},
|
|
@@ -1066,26 +1142,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1066
1142
|
async hasPermission(scope, permissionId) {
|
|
1067
1143
|
return await this.getPermission(scope, permissionId) !== null;
|
|
1068
1144
|
},
|
|
1069
|
-
async grantPermission(scope, permissionId) {
|
|
1070
|
-
await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1071
|
-
for (const recursive of [true, false]) {
|
|
1072
|
-
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1073
|
-
}
|
|
1074
|
-
},
|
|
1075
|
-
async revokePermission(scope, permissionId) {
|
|
1076
|
-
await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
|
|
1077
|
-
for (const recursive of [true, false]) {
|
|
1078
|
-
await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
|
|
1079
|
-
}
|
|
1080
|
-
},
|
|
1081
|
-
async delete() {
|
|
1082
|
-
const res = await app._interface.deleteServerServerUser(crud.id);
|
|
1083
|
-
await app._refreshUsers();
|
|
1084
|
-
return res;
|
|
1085
|
-
},
|
|
1086
1145
|
async update(update) {
|
|
1087
|
-
|
|
1088
|
-
await app._refreshUsers();
|
|
1146
|
+
await app._updateServerUser(crud.id, update);
|
|
1089
1147
|
},
|
|
1090
1148
|
async sendVerificationEmail() {
|
|
1091
1149
|
return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
|
|
@@ -1097,8 +1155,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1097
1155
|
}
|
|
1098
1156
|
_serverUserFromCrud(crud) {
|
|
1099
1157
|
return {
|
|
1100
|
-
...this.
|
|
1101
|
-
...this.
|
|
1158
|
+
...this._createUserExtra(crud),
|
|
1159
|
+
...this._createBaseUser(crud)
|
|
1102
1160
|
};
|
|
1103
1161
|
}
|
|
1104
1162
|
_currentUserFromCrud(crud, session) {
|
|
@@ -1156,7 +1214,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1156
1214
|
if (crud === null) {
|
|
1157
1215
|
switch (options?.or) {
|
|
1158
1216
|
case "redirect": {
|
|
1159
|
-
await this.redirectToSignIn();
|
|
1217
|
+
await this.redirectToSignIn({ replace: true });
|
|
1160
1218
|
break;
|
|
1161
1219
|
}
|
|
1162
1220
|
case "throw": {
|
|
@@ -1185,7 +1243,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1185
1243
|
if (crud === null) {
|
|
1186
1244
|
switch (options?.or) {
|
|
1187
1245
|
case "redirect": {
|
|
1188
|
-
|
|
1246
|
+
runAsynchronously(this.redirectToSignIn({ replace: true }));
|
|
1189
1247
|
suspend();
|
|
1190
1248
|
throw new StackAssertionError("suspend should never return");
|
|
1191
1249
|
}
|
|
@@ -1335,7 +1393,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1335
1393
|
enabled: p.enabled,
|
|
1336
1394
|
type: "standard",
|
|
1337
1395
|
clientId: p.client_id ?? throwErr("Client ID is missing"),
|
|
1338
|
-
clientSecret: p.client_secret ?? throwErr("Client secret is missing")
|
|
1396
|
+
clientSecret: p.client_secret ?? throwErr("Client secret is missing"),
|
|
1397
|
+
facebookConfigId: p.facebook_config_id
|
|
1339
1398
|
}),
|
|
1340
1399
|
emailConfig: data.config.email_config.type === "shared" ? {
|
|
1341
1400
|
type: "shared"
|
|
@@ -1501,16 +1560,6 @@ function userUpdateOptionsToCrud(options) {
|
|
|
1501
1560
|
selected_team_id: options.selectedTeamId
|
|
1502
1561
|
};
|
|
1503
1562
|
}
|
|
1504
|
-
function serverUserUpdateOptionsToCrud(options) {
|
|
1505
|
-
return {
|
|
1506
|
-
display_name: options.displayName,
|
|
1507
|
-
client_metadata: options.clientMetadata,
|
|
1508
|
-
selected_team_id: options.selectedTeamId,
|
|
1509
|
-
primary_email: options.primaryEmail,
|
|
1510
|
-
primary_email_verified: options.primaryEmailVerified,
|
|
1511
|
-
server_metadata: options.serverMetadata
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
1563
|
function adminProjectUpdateOptionsToCrud(options) {
|
|
1515
1564
|
return {
|
|
1516
1565
|
display_name: options.displayName,
|
|
@@ -1527,7 +1576,8 @@ function adminProjectUpdateOptionsToCrud(options) {
|
|
|
1527
1576
|
type: p.type,
|
|
1528
1577
|
...p.type === "standard" && {
|
|
1529
1578
|
client_id: p.clientId,
|
|
1530
|
-
client_secret: p.clientSecret
|
|
1579
|
+
client_secret: p.clientSecret,
|
|
1580
|
+
facebook_config_id: p.facebookConfigId
|
|
1531
1581
|
}
|
|
1532
1582
|
})),
|
|
1533
1583
|
email_config: options.config?.emailConfig && (options.config.emailConfig.type === "shared" ? {
|