@stackframe/stack 2.4.6 → 2.4.7
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-core/loading-indicator.d.mts +4 -6
- package/dist/components-core/loading-indicator.d.ts +4 -6
- package/dist/components-core/loading-indicator.js +9 -6
- package/dist/components-core/loading-indicator.js.map +1 -1
- package/dist/components-core-joy/text.d.mts +2 -2
- package/dist/components-core-joy/text.d.ts +2 -2
- package/dist/components-page/oauth-callback.js +21 -6
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/stack-handler.js +8 -0
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-core/loading-indicator.js +9 -6
- package/dist/esm/components-core/loading-indicator.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js +21 -6
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +10 -2
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/lib/stack-app.js +36 -18
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/lib/stack-app.d.mts +9 -3
- package/dist/lib/stack-app.d.ts +9 -3
- package/dist/lib/stack-app.js +35 -17
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/joy-provider.d.mts +2 -2
- package/dist/providers/joy-provider.d.ts +2 -2
- package/package.json +2 -2
package/dist/lib/stack-app.js
CHANGED
|
@@ -53,7 +53,7 @@ var import_objects = require("@stackframe/stack-shared/dist/utils/objects");
|
|
|
53
53
|
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
54
54
|
var import_caches = require("@stackframe/stack-shared/dist/utils/caches");
|
|
55
55
|
var import_react3 = require("@stackframe/stack-shared/dist/utils/react");
|
|
56
|
-
var clientVersion = "js @stackframe/stack@2.4.
|
|
56
|
+
var clientVersion = "js @stackframe/stack@2.4.7";
|
|
57
57
|
function permissionDefinitionScopeToType(scope) {
|
|
58
58
|
return { "any-team": "team", "specific-team": "team", "global": "global" }[scope.type];
|
|
59
59
|
}
|
|
@@ -78,16 +78,16 @@ function getUrls(partial) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
function getDefaultProjectId() {
|
|
81
|
-
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || (0, import_errors.throwErr)("Welcome to Stack! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable.");
|
|
81
|
+
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || (0, import_errors.throwErr)(new Error("Welcome to Stack! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
|
|
82
82
|
}
|
|
83
83
|
function getDefaultPublishableClientKey() {
|
|
84
|
-
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || (0, import_errors.throwErr)("Welcome to Stack! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable.");
|
|
84
|
+
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || (0, import_errors.throwErr)(new Error("Welcome to Stack! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
|
|
85
85
|
}
|
|
86
86
|
function getDefaultSecretServerKey() {
|
|
87
|
-
return process.env.STACK_SECRET_SERVER_KEY || (0, import_errors.throwErr)("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable.");
|
|
87
|
+
return process.env.STACK_SECRET_SERVER_KEY || (0, import_errors.throwErr)(new Error("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable."));
|
|
88
88
|
}
|
|
89
89
|
function getDefaultSuperSecretAdminKey() {
|
|
90
|
-
return process.env.STACK_SUPER_SECRET_ADMIN_KEY || (0, import_errors.throwErr)("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable.");
|
|
90
|
+
return process.env.STACK_SUPER_SECRET_ADMIN_KEY || (0, import_errors.throwErr)(new Error("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable."));
|
|
91
91
|
}
|
|
92
92
|
function getDefaultBaseUrl() {
|
|
93
93
|
return process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
@@ -301,6 +301,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
301
301
|
hasPassword: json.hasPassword,
|
|
302
302
|
authWithEmail: json.authWithEmail,
|
|
303
303
|
oauthProviders: json.oauthProviders,
|
|
304
|
+
async getSelectedTeam() {
|
|
305
|
+
return await this.getTeam(json.selectedTeamId || "");
|
|
306
|
+
},
|
|
307
|
+
useSelectedTeam() {
|
|
308
|
+
return this.useTeam(json.selectedTeamId || "");
|
|
309
|
+
},
|
|
304
310
|
async getTeam(teamId) {
|
|
305
311
|
const teams = await this.listTeams();
|
|
306
312
|
return teams.find((t) => t.id === teamId) ?? null;
|
|
@@ -370,6 +376,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
370
376
|
const currentUser = {
|
|
371
377
|
...this._userFromJson(json),
|
|
372
378
|
tokenStore,
|
|
379
|
+
async updateSelectedTeam(team) {
|
|
380
|
+
await app._updateUser({ selectedTeamId: team?.id ?? null }, tokenStore);
|
|
381
|
+
},
|
|
373
382
|
update(update) {
|
|
374
383
|
return app._updateUser(update, tokenStore);
|
|
375
384
|
},
|
|
@@ -453,11 +462,16 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
453
462
|
get urls() {
|
|
454
463
|
return getUrls(this._urlOptions);
|
|
455
464
|
}
|
|
456
|
-
async _redirectTo(handlerName) {
|
|
457
|
-
|
|
465
|
+
async _redirectTo(handlerName, options) {
|
|
466
|
+
const url = this.urls[handlerName];
|
|
467
|
+
if (!url) {
|
|
458
468
|
throw new Error(`No URL for handler name ${handlerName}`);
|
|
459
469
|
}
|
|
460
|
-
|
|
470
|
+
if (options?.replace) {
|
|
471
|
+
window.location.replace(url);
|
|
472
|
+
} else {
|
|
473
|
+
window.location.assign(url);
|
|
474
|
+
}
|
|
461
475
|
return await (0, import_promises.wait)(2e3);
|
|
462
476
|
}
|
|
463
477
|
async redirectToSignIn() {
|
|
@@ -584,7 +598,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
584
598
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
585
599
|
const errorCode = await this._interface.signInWithCredential(options.email, options.password, tokenStore);
|
|
586
600
|
if (!errorCode) {
|
|
587
|
-
|
|
601
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
588
602
|
}
|
|
589
603
|
return errorCode;
|
|
590
604
|
}
|
|
@@ -599,7 +613,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
599
613
|
tokenStore
|
|
600
614
|
);
|
|
601
615
|
if (!errorCode) {
|
|
602
|
-
|
|
616
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
603
617
|
}
|
|
604
618
|
return errorCode;
|
|
605
619
|
}
|
|
@@ -611,11 +625,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
611
625
|
return result;
|
|
612
626
|
}
|
|
613
627
|
if (result.newUser) {
|
|
614
|
-
|
|
628
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
615
629
|
} else {
|
|
616
|
-
|
|
630
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
617
631
|
}
|
|
618
|
-
await (0, import_promises.neverResolve)();
|
|
619
632
|
}
|
|
620
633
|
async callOAuthCallback() {
|
|
621
634
|
this._ensurePersistentTokenStore();
|
|
@@ -623,16 +636,18 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
623
636
|
const result = await (0, import_auth.callOAuthCallback)(this._interface, tokenStore, this.urls.oauthCallback);
|
|
624
637
|
if (result) {
|
|
625
638
|
if (result.newUser) {
|
|
626
|
-
|
|
639
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
640
|
+
return true;
|
|
627
641
|
} else {
|
|
628
|
-
|
|
642
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
643
|
+
return true;
|
|
629
644
|
}
|
|
630
645
|
}
|
|
631
|
-
|
|
646
|
+
return false;
|
|
632
647
|
}
|
|
633
648
|
async _signOut(tokenStore) {
|
|
634
649
|
await this._interface.signOut(tokenStore);
|
|
635
|
-
|
|
650
|
+
await this.redirectToAfterSignOut();
|
|
636
651
|
}
|
|
637
652
|
async _sendVerificationEmail(tokenStore) {
|
|
638
653
|
const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
@@ -893,6 +908,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
893
908
|
await app._refreshUser(tokenStore);
|
|
894
909
|
return res;
|
|
895
910
|
},
|
|
911
|
+
async updateSelectedTeam(team) {
|
|
912
|
+
await this.update({ selectedTeamId: team?.id ?? null });
|
|
913
|
+
},
|
|
896
914
|
async update(update) {
|
|
897
915
|
const res = await nonCurrentServerUser.update(update);
|
|
898
916
|
await app._refreshUser(tokenStore);
|