@stackframe/react 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 +52 -11
- 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 +52 -11
- 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 +3 -3
|
@@ -48,6 +48,7 @@ var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
|
|
|
48
48
|
var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
|
|
49
49
|
var import_uuids = require("@stackframe/stack-shared/dist/utils/uuids");
|
|
50
50
|
var cookie = __toESM(require("cookie"));
|
|
51
|
+
var import_react2 = __toESM(require("react"));
|
|
51
52
|
var import_url = require("../../../../utils/url.js");
|
|
52
53
|
var import_auth = require("../../../auth.js");
|
|
53
54
|
var import_cookie = require("../../../cookie.js");
|
|
@@ -58,7 +59,6 @@ var import_projects = require("../../projects/index.js");
|
|
|
58
59
|
var import_teams = require("../../teams/index.js");
|
|
59
60
|
var import_users = require("../../users/index.js");
|
|
60
61
|
var import_common2 = require("./common.js");
|
|
61
|
-
var import_react2 = __toESM(require("react"));
|
|
62
62
|
var import_common3 = require("./common.js");
|
|
63
63
|
var isReactServer = false;
|
|
64
64
|
var process = globalThis.process ?? { env: {} };
|
|
@@ -157,6 +157,16 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
157
157
|
return results;
|
|
158
158
|
}
|
|
159
159
|
);
|
|
160
|
+
this._userItemCache = (0, import_common2.createCacheBySession)(
|
|
161
|
+
async (session, [userId, itemId]) => {
|
|
162
|
+
return await this._interface.getItem({ userId, itemId }, session);
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
this._teamItemCache = (0, import_common2.createCacheBySession)(
|
|
166
|
+
async (session, [teamId, itemId]) => {
|
|
167
|
+
return await this._interface.getItem({ teamId, itemId }, session);
|
|
168
|
+
}
|
|
169
|
+
);
|
|
160
170
|
this._anonymousSignUpInProgress = null;
|
|
161
171
|
this._memoryTokenStore = (0, import_common2.createEmptyTokenStore)();
|
|
162
172
|
this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
|
|
@@ -573,6 +583,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
573
583
|
profileImageUrl: crud.profile_image_url,
|
|
574
584
|
clientMetadata: crud.client_metadata,
|
|
575
585
|
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
586
|
+
...this._createCustomer(crud.id, "team", session),
|
|
576
587
|
async inviteUser(options) {
|
|
577
588
|
await app._interface.sendTeamInvitation({
|
|
578
589
|
teamId: crud.id,
|
|
@@ -664,6 +675,14 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
664
675
|
}
|
|
665
676
|
};
|
|
666
677
|
}
|
|
678
|
+
_clientItemFromCrud(crud) {
|
|
679
|
+
const app = this;
|
|
680
|
+
return {
|
|
681
|
+
displayName: crud.display_name,
|
|
682
|
+
quantity: crud.quantity,
|
|
683
|
+
nonNegativeQuantity: Math.max(0, crud.quantity)
|
|
684
|
+
};
|
|
685
|
+
}
|
|
667
686
|
_createAuth(session) {
|
|
668
687
|
const app = this;
|
|
669
688
|
return {
|
|
@@ -965,12 +984,30 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
965
984
|
}
|
|
966
985
|
};
|
|
967
986
|
}
|
|
987
|
+
_createCustomer(userIdOrTeamId, type, session) {
|
|
988
|
+
const app = this;
|
|
989
|
+
const cache = type === "user" ? app._userItemCache : app._teamItemCache;
|
|
990
|
+
return {
|
|
991
|
+
async getItem(itemId) {
|
|
992
|
+
const result = import_results.Result.orThrow(await cache.getOrWait([session, userIdOrTeamId, itemId], "write-only"));
|
|
993
|
+
return app._clientItemFromCrud(result);
|
|
994
|
+
},
|
|
995
|
+
useItem(itemId) {
|
|
996
|
+
const result = (0, import_common3.useAsyncCache)(cache, [session, userIdOrTeamId, itemId], "team.useItem()");
|
|
997
|
+
return app._clientItemFromCrud(result);
|
|
998
|
+
},
|
|
999
|
+
async createCheckoutUrl(offerIdOrInline) {
|
|
1000
|
+
return await app._interface.createCheckoutUrl(userIdOrTeamId, offerIdOrInline, session);
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
968
1004
|
_currentUserFromCrud(crud, session) {
|
|
969
1005
|
const currentUser = {
|
|
970
1006
|
...this._createBaseUser(crud),
|
|
971
1007
|
...this._createAuth(session),
|
|
972
1008
|
...this._createUserExtraFromCurrent(crud, session),
|
|
973
|
-
...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
|
|
1009
|
+
...this._isInternalProject() ? this._createInternalUserExtra(session) : {},
|
|
1010
|
+
...this._createCustomer(crud.id, "user", session)
|
|
974
1011
|
};
|
|
975
1012
|
Object.freeze(currentUser);
|
|
976
1013
|
return currentUser;
|
|
@@ -1172,7 +1209,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1172
1209
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1173
1210
|
const session = await this._getSession(options?.tokenStore);
|
|
1174
1211
|
let crud = import_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
1175
|
-
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists") {
|
|
1212
|
+
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists[deprecated]") {
|
|
1176
1213
|
crud = null;
|
|
1177
1214
|
}
|
|
1178
1215
|
if (crud === null) {
|
|
@@ -1186,10 +1223,10 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1186
1223
|
}
|
|
1187
1224
|
case "anonymous": {
|
|
1188
1225
|
const tokens = await this._signUpAnonymously();
|
|
1189
|
-
return await this.getUser({ tokenStore: tokens, or: "anonymous-if-exists" }) ?? (0, import_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
1226
|
+
return await this.getUser({ tokenStore: tokens, or: "anonymous-if-exists[deprecated]" }) ?? (0, import_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
1190
1227
|
}
|
|
1191
1228
|
case void 0:
|
|
1192
|
-
case "anonymous-if-exists":
|
|
1229
|
+
case "anonymous-if-exists[deprecated]":
|
|
1193
1230
|
case "return-null": {
|
|
1194
1231
|
return null;
|
|
1195
1232
|
}
|
|
@@ -1201,7 +1238,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1201
1238
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1202
1239
|
const session = this._useSession(options?.tokenStore);
|
|
1203
1240
|
let crud = (0, import_common3.useAsyncCache)(this._currentUserCache, [session], "useUser()");
|
|
1204
|
-
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists") {
|
|
1241
|
+
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists[deprecated]") {
|
|
1205
1242
|
crud = null;
|
|
1206
1243
|
}
|
|
1207
1244
|
if (crud === null) {
|
|
@@ -1225,7 +1262,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1225
1262
|
throw new import_errors.StackAssertionError("suspend should never return");
|
|
1226
1263
|
}
|
|
1227
1264
|
case void 0:
|
|
1228
|
-
case "anonymous-if-exists":
|
|
1265
|
+
case "anonymous-if-exists[deprecated]":
|
|
1229
1266
|
case "return-null": {
|
|
1230
1267
|
}
|
|
1231
1268
|
}
|
|
@@ -1244,6 +1281,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1244
1281
|
throw new Error("signInWithOAuth can currently only be called in a browser environment");
|
|
1245
1282
|
}
|
|
1246
1283
|
this._ensurePersistentTokenStore();
|
|
1284
|
+
const session = await this._getSession();
|
|
1247
1285
|
await (0, import_auth.signInWithOAuth)(
|
|
1248
1286
|
this._interface,
|
|
1249
1287
|
{
|
|
@@ -1251,7 +1289,8 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1251
1289
|
redirectUrl: this.urls.oauthCallback,
|
|
1252
1290
|
errorRedirectUrl: this.urls.error,
|
|
1253
1291
|
providerScope: this._oauthScopesOnSignIn[provider]?.join(" ")
|
|
1254
|
-
}
|
|
1292
|
+
},
|
|
1293
|
+
session
|
|
1255
1294
|
);
|
|
1256
1295
|
}
|
|
1257
1296
|
/**
|
|
@@ -1342,10 +1381,11 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1342
1381
|
}
|
|
1343
1382
|
async signInWithMagicLink(code, options) {
|
|
1344
1383
|
this._ensurePersistentTokenStore();
|
|
1384
|
+
const session = await this._getSession();
|
|
1345
1385
|
let result;
|
|
1346
1386
|
try {
|
|
1347
1387
|
result = await this._catchMfaRequiredError(async () => {
|
|
1348
|
-
return await this._interface.signInWithMagicLink(code);
|
|
1388
|
+
return await this._interface.signInWithMagicLink(code, session);
|
|
1349
1389
|
});
|
|
1350
1390
|
} catch (e) {
|
|
1351
1391
|
if (import_stack_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
@@ -1455,10 +1495,11 @@ ${url}`);
|
|
|
1455
1495
|
*/
|
|
1456
1496
|
async signInWithMfa(totp, code, options) {
|
|
1457
1497
|
this._ensurePersistentTokenStore();
|
|
1498
|
+
const session = await this._getSession();
|
|
1458
1499
|
let result;
|
|
1459
1500
|
try {
|
|
1460
1501
|
result = await this._catchMfaRequiredError(async () => {
|
|
1461
|
-
return await this._interface.signInWithMfa(totp, code);
|
|
1502
|
+
return await this._interface.signInWithMfa(totp, code, session);
|
|
1462
1503
|
});
|
|
1463
1504
|
} catch (e) {
|
|
1464
1505
|
if (e instanceof import_stack_shared.KnownErrors.InvalidTotpCode) {
|
|
@@ -1495,7 +1536,7 @@ ${url}`);
|
|
|
1495
1536
|
}
|
|
1496
1537
|
options_json.rpId = window.location.hostname;
|
|
1497
1538
|
const authentication_response = await (0, import_browser.startAuthentication)({ optionsJSON: options_json });
|
|
1498
|
-
return await this._interface.signInWithPasskey({ authentication_response, code });
|
|
1539
|
+
return await this._interface.signInWithPasskey({ authentication_response, code }, session);
|
|
1499
1540
|
});
|
|
1500
1541
|
} catch (error) {
|
|
1501
1542
|
if (error instanceof import_browser.WebAuthnError) {
|