@stackframe/react 2.7.28 → 2.7.30
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/esm/lib/stack-app/apps/implementations/client-app-impl.js +52 -8
- 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 +6 -6
- 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 +27 -4
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.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/index.d.mts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +52 -8
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +6 -6
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +26 -3
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/common.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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @stackframe/stack
|
|
2
2
|
|
|
3
|
+
## 2.7.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Various changes
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @stackframe/stack-shared@2.7.30
|
|
10
|
+
- @stackframe/stack-ui@2.7.30
|
|
11
|
+
- @stackframe/stack-sc@2.7.30
|
|
12
|
+
|
|
13
|
+
## 2.7.29
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Various changes
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @stackframe/stack-shared@2.7.29
|
|
20
|
+
- @stackframe/stack-ui@2.7.29
|
|
21
|
+
- @stackframe/stack-sc@2.7.29
|
|
22
|
+
|
|
3
23
|
## 2.7.28
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -101,6 +101,7 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
101
101
|
return await this._interface.listClientContactChannels(session);
|
|
102
102
|
}
|
|
103
103
|
);
|
|
104
|
+
this._anonymousSignUpInProgress = null;
|
|
104
105
|
this._memoryTokenStore = createEmptyTokenStore();
|
|
105
106
|
this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
|
|
106
107
|
this._requestTokenStores = /* @__PURE__ */ new WeakMap();
|
|
@@ -987,7 +988,10 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
987
988
|
async getUser(options) {
|
|
988
989
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
989
990
|
const session = await this._getSession(options?.tokenStore);
|
|
990
|
-
|
|
991
|
+
let crud = Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
992
|
+
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists") {
|
|
993
|
+
crud = null;
|
|
994
|
+
}
|
|
991
995
|
if (crud === null) {
|
|
992
996
|
switch (options?.or) {
|
|
993
997
|
case "redirect": {
|
|
@@ -997,7 +1001,13 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
997
1001
|
case "throw": {
|
|
998
1002
|
throw new Error("User is not signed in but getUser was called with { or: 'throw' }");
|
|
999
1003
|
}
|
|
1000
|
-
|
|
1004
|
+
case "anonymous": {
|
|
1005
|
+
const tokens = await this._signUpAnonymously();
|
|
1006
|
+
return await this.getUser({ tokenStore: tokens }) ?? throwErr("Something went wrong while signing up anonymously");
|
|
1007
|
+
}
|
|
1008
|
+
case void 0:
|
|
1009
|
+
case "anonymous-if-exists":
|
|
1010
|
+
case "return-null": {
|
|
1001
1011
|
return null;
|
|
1002
1012
|
}
|
|
1003
1013
|
}
|
|
@@ -1007,7 +1017,10 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1007
1017
|
useUser(options) {
|
|
1008
1018
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1009
1019
|
const session = this._useSession(options?.tokenStore);
|
|
1010
|
-
|
|
1020
|
+
let crud = useAsyncCache(this._currentUserCache, [session], "useUser()");
|
|
1021
|
+
if (crud?.is_anonymous && options?.or !== "anonymous" && options?.or !== "anonymous-if-exists") {
|
|
1022
|
+
crud = null;
|
|
1023
|
+
}
|
|
1011
1024
|
if (crud === null) {
|
|
1012
1025
|
switch (options?.or) {
|
|
1013
1026
|
case "redirect": {
|
|
@@ -1018,7 +1031,18 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1018
1031
|
case "throw": {
|
|
1019
1032
|
throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
1020
1033
|
}
|
|
1034
|
+
case "anonymous": {
|
|
1035
|
+
runAsynchronously(async () => {
|
|
1036
|
+
await this._signUpAnonymously();
|
|
1037
|
+
if (typeof window !== "undefined") {
|
|
1038
|
+
window.location.reload();
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
suspend();
|
|
1042
|
+
throw new StackAssertionError("suspend should never return");
|
|
1043
|
+
}
|
|
1021
1044
|
case void 0:
|
|
1045
|
+
case "anonymous-if-exists":
|
|
1022
1046
|
case "return-null": {
|
|
1023
1047
|
}
|
|
1024
1048
|
}
|
|
@@ -1120,7 +1144,25 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1120
1144
|
return Result.error(result.error);
|
|
1121
1145
|
}
|
|
1122
1146
|
}
|
|
1123
|
-
async
|
|
1147
|
+
async _signUpAnonymously() {
|
|
1148
|
+
this._ensurePersistentTokenStore();
|
|
1149
|
+
if (!this._anonymousSignUpInProgress) {
|
|
1150
|
+
this._anonymousSignUpInProgress = (async () => {
|
|
1151
|
+
this._ensurePersistentTokenStore();
|
|
1152
|
+
const session = await this._getSession();
|
|
1153
|
+
const result = await this._interface.signUpAnonymously(session);
|
|
1154
|
+
if (result.status === "ok") {
|
|
1155
|
+
await this._signInToAccountWithTokens(result.data);
|
|
1156
|
+
} else {
|
|
1157
|
+
throw new StackAssertionError("signUpAnonymously() should never return an error");
|
|
1158
|
+
}
|
|
1159
|
+
this._anonymousSignUpInProgress = null;
|
|
1160
|
+
return result.data;
|
|
1161
|
+
})();
|
|
1162
|
+
}
|
|
1163
|
+
return await this._anonymousSignUpInProgress;
|
|
1164
|
+
}
|
|
1165
|
+
async signInWithMagicLink(code, options) {
|
|
1124
1166
|
this._ensurePersistentTokenStore();
|
|
1125
1167
|
let result;
|
|
1126
1168
|
try {
|
|
@@ -1135,10 +1177,12 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1135
1177
|
}
|
|
1136
1178
|
if (result.status === "ok") {
|
|
1137
1179
|
await this._signInToAccountWithTokens(result.data);
|
|
1138
|
-
if (
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1180
|
+
if (!options?.noRedirect) {
|
|
1181
|
+
if (result.data.newUser) {
|
|
1182
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
1183
|
+
} else {
|
|
1184
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
1185
|
+
}
|
|
1142
1186
|
}
|
|
1143
1187
|
return Result.ok(void 0);
|
|
1144
1188
|
} else {
|