@stackframe/js 2.7.30 → 2.8.2
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 +31 -0
- package/dist/esm/lib/auth.js +6 -6
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +27 -6
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +52 -30
- 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/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +44 -18
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/permissions/index.js +16 -0
- package/dist/esm/lib/stack-app/permissions/index.js.map +1 -1
- package/dist/esm/lib/stack-app/projects/index.js +1 -0
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/utils/url.js +2 -2
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/index.d.mts +46 -2
- package/dist/index.d.ts +46 -2
- package/dist/lib/auth.js +6 -6
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +26 -5
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +52 -30
- 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/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +44 -18
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/permissions/index.js +18 -0
- package/dist/lib/stack-app/permissions/index.js.map +1 -1
- package/dist/lib/stack-app/project-configs/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js +1 -0
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/utils/url.js +2 -2
- package/dist/utils/url.js.map +1 -1
- package/package.json +3 -3
|
@@ -83,6 +83,9 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
83
83
|
this._currentUserPermissionsCache = (0, import_common2.createCacheBySession)(async (session, [teamId, recursive]) => {
|
|
84
84
|
return await this._interface.listCurrentUserTeamPermissions({ teamId, recursive }, session);
|
|
85
85
|
});
|
|
86
|
+
this._currentUserProjectPermissionsCache = (0, import_common2.createCacheBySession)(async (session, [recursive]) => {
|
|
87
|
+
return await this._interface.listCurrentUserProjectPermissions({ recursive }, session);
|
|
88
|
+
});
|
|
86
89
|
this._currentUserTeamsCache = (0, import_common2.createCacheBySession)(async (session) => {
|
|
87
90
|
return await this._interface.listCurrentUserTeams(session);
|
|
88
91
|
});
|
|
@@ -447,7 +450,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
447
450
|
}
|
|
448
451
|
};
|
|
449
452
|
}
|
|
450
|
-
|
|
453
|
+
_clientPermissionFromCrud(crud) {
|
|
451
454
|
return {
|
|
452
455
|
id: crud.id
|
|
453
456
|
};
|
|
@@ -481,14 +484,11 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
481
484
|
clientMetadata: crud.client_metadata,
|
|
482
485
|
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
483
486
|
async inviteUser(options) {
|
|
484
|
-
if (!options.callbackUrl && !await app._getCurrentUrl()) {
|
|
485
|
-
throw new Error("Cannot invite user without a callback URL from the server or without a redirect method. Make sure you pass the `callbackUrl` option: `inviteUser({ email, callbackUrl: ... })`");
|
|
486
|
-
}
|
|
487
487
|
await app._interface.sendTeamInvitation({
|
|
488
488
|
teamId: crud.id,
|
|
489
489
|
email: options.email,
|
|
490
490
|
session,
|
|
491
|
-
callbackUrl: options.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.teamInvitation)
|
|
491
|
+
callbackUrl: options.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.teamInvitation, "callbackUrl")
|
|
492
492
|
});
|
|
493
493
|
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
494
494
|
},
|
|
@@ -519,8 +519,12 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
519
519
|
isVerified: crud.is_verified,
|
|
520
520
|
isPrimary: crud.is_primary,
|
|
521
521
|
usedForAuth: crud.used_for_auth,
|
|
522
|
-
async sendVerificationEmail() {
|
|
523
|
-
await app._interface.sendCurrentUserContactChannelVerificationEmail(
|
|
522
|
+
async sendVerificationEmail(options) {
|
|
523
|
+
await app._interface.sendCurrentUserContactChannelVerificationEmail(
|
|
524
|
+
crud.id,
|
|
525
|
+
options?.callbackUrl || (0, import_url.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"),
|
|
526
|
+
session
|
|
527
|
+
);
|
|
524
528
|
},
|
|
525
529
|
async update(data) {
|
|
526
530
|
await app._interface.updateClientContactChannel(crud.id, (0, import_contact_channels.contactChannelUpdateOptionsToCrud)(data), session);
|
|
@@ -622,6 +626,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
622
626
|
oauthProviders: crud.oauth_providers,
|
|
623
627
|
passkeyAuthEnabled: crud.passkey_auth_enabled,
|
|
624
628
|
isMultiFactorRequired: crud.requires_totp_mfa,
|
|
629
|
+
isAnonymous: crud.is_anonymous,
|
|
625
630
|
toClientJson() {
|
|
626
631
|
return crud;
|
|
627
632
|
}
|
|
@@ -662,22 +667,44 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
662
667
|
async createTeam(data) {
|
|
663
668
|
const crud2 = await app._interface.createClientTeam((0, import_teams.teamCreateOptionsToCrud)(data, "me"), session);
|
|
664
669
|
await app._currentUserTeamsCache.refresh([session]);
|
|
670
|
+
await this.update({ selectedTeamId: crud2.id });
|
|
665
671
|
return app._clientTeamFromCrud(crud2, session);
|
|
666
672
|
},
|
|
667
673
|
async leaveTeam(team) {
|
|
668
674
|
await app._interface.leaveTeam(team.id, session);
|
|
669
675
|
},
|
|
670
|
-
async listPermissions(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
676
|
+
async listPermissions(scopeOrOptions, options) {
|
|
677
|
+
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
678
|
+
const scope = scopeOrOptions;
|
|
679
|
+
const recursive = options?.recursive ?? true;
|
|
680
|
+
const permissions = import_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([session, scope.id, recursive], "write-only"));
|
|
681
|
+
return permissions.map((crud2) => app._clientPermissionFromCrud(crud2));
|
|
682
|
+
} else {
|
|
683
|
+
const opts = scopeOrOptions;
|
|
684
|
+
const recursive = opts?.recursive ?? true;
|
|
685
|
+
const permissions = import_results.Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only"));
|
|
686
|
+
return permissions.map((crud2) => app._clientPermissionFromCrud(crud2));
|
|
687
|
+
}
|
|
674
688
|
},
|
|
675
|
-
async getPermission(
|
|
676
|
-
|
|
677
|
-
|
|
689
|
+
async getPermission(scopeOrPermissionId, permissionId) {
|
|
690
|
+
if (scopeOrPermissionId && typeof scopeOrPermissionId !== "string") {
|
|
691
|
+
const scope = scopeOrPermissionId;
|
|
692
|
+
const permissions = await this.listPermissions(scope);
|
|
693
|
+
return permissions.find((p) => p.id === permissionId) ?? null;
|
|
694
|
+
} else {
|
|
695
|
+
const pid = scopeOrPermissionId;
|
|
696
|
+
const permissions = await this.listPermissions();
|
|
697
|
+
return permissions.find((p) => p.id === pid) ?? null;
|
|
698
|
+
}
|
|
678
699
|
},
|
|
679
|
-
async hasPermission(
|
|
680
|
-
|
|
700
|
+
async hasPermission(scopeOrPermissionId, permissionId) {
|
|
701
|
+
if (scopeOrPermissionId && typeof scopeOrPermissionId !== "string") {
|
|
702
|
+
const scope = scopeOrPermissionId;
|
|
703
|
+
return await this.getPermission(scope, permissionId) !== null;
|
|
704
|
+
} else {
|
|
705
|
+
const pid = scopeOrPermissionId;
|
|
706
|
+
return await this.getPermission(pid) !== null;
|
|
707
|
+
}
|
|
681
708
|
},
|
|
682
709
|
async update(update) {
|
|
683
710
|
return await app._updateClientUser(update, session);
|
|
@@ -686,10 +713,11 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
686
713
|
if (!crud.primary_email) {
|
|
687
714
|
throw new import_errors.StackAssertionError("User does not have a primary email");
|
|
688
715
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
716
|
+
return await app._interface.sendVerificationEmail(
|
|
717
|
+
crud.primary_email,
|
|
718
|
+
options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"),
|
|
719
|
+
session
|
|
720
|
+
);
|
|
693
721
|
},
|
|
694
722
|
async updatePassword(options) {
|
|
695
723
|
const result = await app._interface.updatePassword(options, session);
|
|
@@ -883,16 +911,10 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
883
911
|
return await this._redirectToHandler("teamInvitation", options);
|
|
884
912
|
}
|
|
885
913
|
async sendForgotPasswordEmail(email, options) {
|
|
886
|
-
|
|
887
|
-
throw new Error("Cannot send forgot password email without a callback URL from the server or without a redirect method. Make sure you pass the `callbackUrl` option: `sendForgotPasswordEmail({ email, callbackUrl: ... })`");
|
|
888
|
-
}
|
|
889
|
-
return await this._interface.sendForgotPasswordEmail(email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.passwordReset));
|
|
914
|
+
return await this._interface.sendForgotPasswordEmail(email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.passwordReset, "callbackUrl"));
|
|
890
915
|
}
|
|
891
916
|
async sendMagicLinkEmail(email, options) {
|
|
892
|
-
|
|
893
|
-
throw new Error("Cannot send magic link email without a callback URL from the server or without a redirect method. Make sure you pass the `callbackUrl` option: `sendMagicLinkEmail({ email, callbackUrl: ... })`");
|
|
894
|
-
}
|
|
895
|
-
return await this._interface.sendMagicLinkEmail(email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.magicLinkCallback));
|
|
917
|
+
return await this._interface.sendMagicLinkEmail(email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.magicLinkCallback, "callbackUrl"));
|
|
896
918
|
}
|
|
897
919
|
async resetPassword(options) {
|
|
898
920
|
return await this._interface.resetPassword(options);
|
|
@@ -955,7 +977,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
955
977
|
}
|
|
956
978
|
case "anonymous": {
|
|
957
979
|
const tokens = await this._signUpAnonymously();
|
|
958
|
-
return await this.getUser({ tokenStore: tokens }) ?? (0, import_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
980
|
+
return await this.getUser({ tokenStore: tokens, or: "anonymous-if-exists" }) ?? (0, import_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
959
981
|
}
|
|
960
982
|
case void 0:
|
|
961
983
|
case "anonymous-if-exists":
|
|
@@ -1042,7 +1064,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1042
1064
|
async signUpWithCredential(options) {
|
|
1043
1065
|
this._ensurePersistentTokenStore();
|
|
1044
1066
|
const session = await this._getSession();
|
|
1045
|
-
const emailVerificationRedirectUrl = options.verificationCallbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
1067
|
+
const emailVerificationRedirectUrl = options.verificationCallbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.emailVerification, "verificationCallbackUrl");
|
|
1046
1068
|
const result = await this._interface.signUpWithCredential(
|
|
1047
1069
|
options.email,
|
|
1048
1070
|
options.password,
|