@stackframe/stack 2.8.31 → 2.8.34
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 +30 -0
- package/dist/components/team-switcher.js +1 -1
- package/dist/components/team-switcher.js.map +1 -1
- package/dist/esm/components/team-switcher.js +3 -3
- package/dist/esm/components/team-switcher.js.map +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/auth.js +3 -2
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +13 -8
- 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 +53 -12
- 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 +68 -8
- 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/common.js.map +1 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/providers/stack-provider.js +1 -1
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/index.d.mts +43 -7
- package/dist/index.d.ts +43 -7
- package/dist/lib/auth.js +3 -2
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +13 -8
- 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 +53 -12
- 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 +68 -8
- 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/common.js.map +1 -1
- package/dist/lib/stack-app/customers/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/providers/stack-provider.js +1 -1
- package/dist/providers/stack-provider.js.map +1 -1
- package/package.json +4 -4
|
@@ -49,6 +49,8 @@ var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
|
|
|
49
49
|
var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
|
|
50
50
|
var import_uuids = require("@stackframe/stack-shared/dist/utils/uuids");
|
|
51
51
|
var cookie = __toESM(require("cookie"));
|
|
52
|
+
var NextNavigationUnscrambled = __toESM(require("next/navigation"));
|
|
53
|
+
var import_react2 = __toESM(require("react"));
|
|
52
54
|
var import_url = require("../../../../utils/url.js");
|
|
53
55
|
var import_auth = require("../../../auth.js");
|
|
54
56
|
var import_cookie = require("../../../cookie.js");
|
|
@@ -59,8 +61,6 @@ var import_projects = require("../../projects/index.js");
|
|
|
59
61
|
var import_teams = require("../../teams/index.js");
|
|
60
62
|
var import_users = require("../../users/index.js");
|
|
61
63
|
var import_common2 = require("./common.js");
|
|
62
|
-
var NextNavigationUnscrambled = __toESM(require("next/navigation"));
|
|
63
|
-
var import_react2 = __toESM(require("react"));
|
|
64
64
|
var import_common3 = require("./common.js");
|
|
65
65
|
var sc = __toESM(require("@stackframe/stack-sc"));
|
|
66
66
|
var import_stack_sc = require("@stackframe/stack-sc");
|
|
@@ -162,6 +162,16 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
162
162
|
return results;
|
|
163
163
|
}
|
|
164
164
|
);
|
|
165
|
+
this._userItemCache = (0, import_common2.createCacheBySession)(
|
|
166
|
+
async (session, [userId, itemId]) => {
|
|
167
|
+
return await this._interface.getItem({ userId, itemId }, session);
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
this._teamItemCache = (0, import_common2.createCacheBySession)(
|
|
171
|
+
async (session, [teamId, itemId]) => {
|
|
172
|
+
return await this._interface.getItem({ teamId, itemId }, session);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
165
175
|
this._anonymousSignUpInProgress = null;
|
|
166
176
|
this._memoryTokenStore = (0, import_common2.createEmptyTokenStore)();
|
|
167
177
|
this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
|
|
@@ -580,6 +590,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
580
590
|
profileImageUrl: crud.profile_image_url,
|
|
581
591
|
clientMetadata: crud.client_metadata,
|
|
582
592
|
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
593
|
+
...this._createCustomer(crud.id, "team", session),
|
|
583
594
|
async inviteUser(options) {
|
|
584
595
|
await app._interface.sendTeamInvitation({
|
|
585
596
|
teamId: crud.id,
|
|
@@ -671,6 +682,14 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
671
682
|
}
|
|
672
683
|
};
|
|
673
684
|
}
|
|
685
|
+
_clientItemFromCrud(crud) {
|
|
686
|
+
const app = this;
|
|
687
|
+
return {
|
|
688
|
+
displayName: crud.display_name,
|
|
689
|
+
quantity: crud.quantity,
|
|
690
|
+
nonNegativeQuantity: Math.max(0, crud.quantity)
|
|
691
|
+
};
|
|
692
|
+
}
|
|
674
693
|
_createAuth(session) {
|
|
675
694
|
const app = this;
|
|
676
695
|
return {
|
|
@@ -972,12 +991,30 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
972
991
|
}
|
|
973
992
|
};
|
|
974
993
|
}
|
|
994
|
+
_createCustomer(userIdOrTeamId, type, session) {
|
|
995
|
+
const app = this;
|
|
996
|
+
const cache = type === "user" ? app._userItemCache : app._teamItemCache;
|
|
997
|
+
return {
|
|
998
|
+
async getItem(itemId) {
|
|
999
|
+
const result = import_results.Result.orThrow(await cache.getOrWait([session, userIdOrTeamId, itemId], "write-only"));
|
|
1000
|
+
return app._clientItemFromCrud(result);
|
|
1001
|
+
},
|
|
1002
|
+
useItem(itemId) {
|
|
1003
|
+
const result = (0, import_common3.useAsyncCache)(cache, [session, userIdOrTeamId, itemId], "team.useItem()");
|
|
1004
|
+
return app._clientItemFromCrud(result);
|
|
1005
|
+
},
|
|
1006
|
+
async createCheckoutUrl(offerIdOrInline) {
|
|
1007
|
+
return await app._interface.createCheckoutUrl(userIdOrTeamId, offerIdOrInline, session);
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
975
1011
|
_currentUserFromCrud(crud, session) {
|
|
976
1012
|
const currentUser = {
|
|
977
1013
|
...this._createBaseUser(crud),
|
|
978
1014
|
...this._createAuth(session),
|
|
979
1015
|
...this._createUserExtraFromCurrent(crud, session),
|
|
980
|
-
...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
|
|
1016
|
+
...this._isInternalProject() ? this._createInternalUserExtra(session) : {},
|
|
1017
|
+
...this._createCustomer(crud.id, "user", session)
|
|
981
1018
|
};
|
|
982
1019
|
Object.freeze(currentUser);
|
|
983
1020
|
return currentUser;
|
|
@@ -1184,7 +1221,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1184
1221
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1185
1222
|
const session = await this._getSession(options?.tokenStore);
|
|
1186
1223
|
let crud = import_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
1187
|
-
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists") {
|
|
1224
|
+
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists[deprecated]") {
|
|
1188
1225
|
crud = null;
|
|
1189
1226
|
}
|
|
1190
1227
|
if (crud === null) {
|
|
@@ -1198,10 +1235,10 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1198
1235
|
}
|
|
1199
1236
|
case "anonymous": {
|
|
1200
1237
|
const tokens = await this._signUpAnonymously();
|
|
1201
|
-
return await this.getUser({ tokenStore: tokens, or: "anonymous-if-exists" }) ?? (0, import_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
1238
|
+
return await this.getUser({ tokenStore: tokens, or: "anonymous-if-exists[deprecated]" }) ?? (0, import_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
1202
1239
|
}
|
|
1203
1240
|
case void 0:
|
|
1204
|
-
case "anonymous-if-exists":
|
|
1241
|
+
case "anonymous-if-exists[deprecated]":
|
|
1205
1242
|
case "return-null": {
|
|
1206
1243
|
return null;
|
|
1207
1244
|
}
|
|
@@ -1213,7 +1250,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1213
1250
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1214
1251
|
const session = this._useSession(options?.tokenStore);
|
|
1215
1252
|
let crud = (0, import_common3.useAsyncCache)(this._currentUserCache, [session], "useUser()");
|
|
1216
|
-
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists") {
|
|
1253
|
+
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists[deprecated]") {
|
|
1217
1254
|
crud = null;
|
|
1218
1255
|
}
|
|
1219
1256
|
if (crud === null) {
|
|
@@ -1237,7 +1274,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1237
1274
|
throw new import_errors.StackAssertionError("suspend should never return");
|
|
1238
1275
|
}
|
|
1239
1276
|
case void 0:
|
|
1240
|
-
case "anonymous-if-exists":
|
|
1277
|
+
case "anonymous-if-exists[deprecated]":
|
|
1241
1278
|
case "return-null": {
|
|
1242
1279
|
}
|
|
1243
1280
|
}
|
|
@@ -1256,6 +1293,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1256
1293
|
throw new Error("signInWithOAuth can currently only be called in a browser environment");
|
|
1257
1294
|
}
|
|
1258
1295
|
this._ensurePersistentTokenStore();
|
|
1296
|
+
const session = await this._getSession();
|
|
1259
1297
|
await (0, import_auth.signInWithOAuth)(
|
|
1260
1298
|
this._interface,
|
|
1261
1299
|
{
|
|
@@ -1263,7 +1301,8 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1263
1301
|
redirectUrl: this.urls.oauthCallback,
|
|
1264
1302
|
errorRedirectUrl: this.urls.error,
|
|
1265
1303
|
providerScope: this._oauthScopesOnSignIn[provider]?.join(" ")
|
|
1266
|
-
}
|
|
1304
|
+
},
|
|
1305
|
+
session
|
|
1267
1306
|
);
|
|
1268
1307
|
}
|
|
1269
1308
|
/**
|
|
@@ -1354,10 +1393,11 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1354
1393
|
}
|
|
1355
1394
|
async signInWithMagicLink(code, options) {
|
|
1356
1395
|
this._ensurePersistentTokenStore();
|
|
1396
|
+
const session = await this._getSession();
|
|
1357
1397
|
let result;
|
|
1358
1398
|
try {
|
|
1359
1399
|
result = await this._catchMfaRequiredError(async () => {
|
|
1360
|
-
return await this._interface.signInWithMagicLink(code);
|
|
1400
|
+
return await this._interface.signInWithMagicLink(code, session);
|
|
1361
1401
|
});
|
|
1362
1402
|
} catch (e) {
|
|
1363
1403
|
if (import_stack_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
@@ -1467,10 +1507,11 @@ ${url}`);
|
|
|
1467
1507
|
*/
|
|
1468
1508
|
async signInWithMfa(totp, code, options) {
|
|
1469
1509
|
this._ensurePersistentTokenStore();
|
|
1510
|
+
const session = await this._getSession();
|
|
1470
1511
|
let result;
|
|
1471
1512
|
try {
|
|
1472
1513
|
result = await this._catchMfaRequiredError(async () => {
|
|
1473
|
-
return await this._interface.signInWithMfa(totp, code);
|
|
1514
|
+
return await this._interface.signInWithMfa(totp, code, session);
|
|
1474
1515
|
});
|
|
1475
1516
|
} catch (e) {
|
|
1476
1517
|
if (e instanceof import_stack_shared.KnownErrors.InvalidTotpCode) {
|
|
@@ -1507,7 +1548,7 @@ ${url}`);
|
|
|
1507
1548
|
}
|
|
1508
1549
|
options_json.rpId = window.location.hostname;
|
|
1509
1550
|
const authentication_response = await (0, import_browser.startAuthentication)({ optionsJSON: options_json });
|
|
1510
|
-
return await this._interface.signInWithPasskey({ authentication_response, code });
|
|
1551
|
+
return await this._interface.signInWithPasskey({ authentication_response, code }, session);
|
|
1511
1552
|
});
|
|
1512
1553
|
} catch (error) {
|
|
1513
1554
|
if (error instanceof import_browser.WebAuthnError) {
|