@stackframe/stack 2.4.11 → 2.4.13

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 ADDED
@@ -0,0 +1,318 @@
1
+ # @stackframe/stack
2
+
3
+ ## 2.4.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Bug fixes
8
+ - Updated dependencies
9
+ - @stackframe/stack-shared@2.4.10
10
+ - @stackframe/stack-sc@1.5.5
11
+
12
+ ## 2.4.12
13
+
14
+ ### Patch Changes
15
+
16
+ - Bugfixes
17
+ - Updated dependencies
18
+ - @stackframe/stack-shared@2.4.9
19
+ - @stackframe/stack-sc@1.5.4
20
+
21
+ ## 2.4.11
22
+
23
+ ### Patch Changes
24
+
25
+ - Cloudflare Workers support
26
+
27
+ ## 2.4.10
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies
32
+ - @stackframe/stack-shared@2.4.8
33
+
34
+ ## 2.4.9
35
+
36
+ ### Patch Changes
37
+
38
+ - Bugfixes
39
+ - Updated dependencies
40
+ - @stackframe/stack-shared@2.4.7
41
+ - @stackframe/stack-sc@1.5.3
42
+
43
+ ## 2.4.8
44
+
45
+ ### Patch Changes
46
+
47
+ - Remove crypto-browserify dependency
48
+ - Updated dependencies
49
+ - @stackframe/stack-shared@2.4.6
50
+
51
+ ## 2.4.7
52
+
53
+ ### Patch Changes
54
+
55
+ - Team selection
56
+ - Updated dependencies
57
+ - @stackframe/stack-shared@2.4.5
58
+
59
+ ## 2.4.6
60
+
61
+ ### Patch Changes
62
+
63
+ - UX improvements
64
+ - Updated dependencies
65
+ - @stackframe/stack-shared@2.4.4
66
+
67
+ ## 2.4.5
68
+
69
+ ### Patch Changes
70
+
71
+ - CRUD schemas
72
+ - Updated dependencies
73
+ - @stackframe/stack-shared@2.4.3
74
+ - @stackframe/stack-sc@1.5.2
75
+
76
+ ## 2.4.4
77
+
78
+ ### Patch Changes
79
+
80
+ - Theme updates
81
+
82
+ ## 2.4.3
83
+
84
+ ### Patch Changes
85
+
86
+ - New projects page
87
+ - Updated dependencies
88
+ - @stackframe/stack-shared@2.4.2
89
+
90
+ ## 2.4.2
91
+
92
+ ### Patch Changes
93
+
94
+ - @stackframe package namespace
95
+
96
+ ## 2.4.1
97
+
98
+ ### Patch Changes
99
+
100
+ - Teams, permissions and RBAC
101
+ - Updated dependencies
102
+ - @stackframe/stack-shared@2.4.1
103
+ - @stackframe/stack-sc@1.5.1
104
+
105
+ ## 2.4.0
106
+
107
+ ### Minor Changes
108
+
109
+ - Middleware support
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies
114
+ - @stackframe/stack-shared@2.4.0
115
+ - @stackframe/stack-sc@1.5.0
116
+
117
+ ## 2.3.8
118
+
119
+ ### Patch Changes
120
+
121
+ - Bugfixes
122
+ - Updated dependencies
123
+ - @stackframe/stack-shared@2.3.6
124
+
125
+ ## 2.3.7
126
+
127
+ ### Patch Changes
128
+
129
+ - CommonJS support
130
+ - Updated dependencies
131
+ - @stackframe/stack-shared@2.3.5
132
+
133
+ ## 2.3.6
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies
138
+ - @stackframe/stack-shared@2.3.4
139
+
140
+ ## 2.3.5
141
+
142
+ ### Patch Changes
143
+
144
+ - Partial pre-rendering
145
+ - Updated dependencies
146
+ - @stackframe/stack-shared@2.3.3
147
+
148
+ ## 2.3.4
149
+
150
+ ### Patch Changes
151
+
152
+ - E2E tests and various fixes
153
+
154
+ ## 2.3.3
155
+
156
+ ### Patch Changes
157
+
158
+ - Magic link configuration
159
+ - Updated dependencies
160
+ - @stackframe/stack-shared@2.3.2
161
+
162
+ ## 2.3.2
163
+
164
+ ### Patch Changes
165
+
166
+ - Add README file
167
+ - Updated dependencies
168
+ - @stackframe/stack-shared@2.3.1
169
+ - @stackframe/stack-sc@1.4.1
170
+
171
+ ## 2.3.1
172
+
173
+ ### Patch Changes
174
+
175
+ - Improve e-mail validation and add request timeouts
176
+
177
+ ## 2.3.0
178
+
179
+ ### Minor Changes
180
+
181
+ - 96c26a7: added magic link
182
+
183
+ ### Patch Changes
184
+
185
+ - Various small improvements
186
+ - Updated dependencies
187
+ - Updated dependencies [96c26a7]
188
+ - @stackframe/stack-shared@2.3.0
189
+ - @stackframe/stack-sc@1.4.0
190
+
191
+ ## 2.2.5
192
+
193
+ ### Patch Changes
194
+
195
+ - 5909ecd: fixed bugs
196
+ - Updated dependencies [5909ecd]
197
+ - @stackframe/stack-sc@1.3.2
198
+ - @stackframe/stack-shared@2.2.2
199
+
200
+ ## 2.2.4
201
+
202
+ ### Patch Changes
203
+
204
+ - fixed minor errors
205
+ - Updated dependencies
206
+ - @stackframe/stack-sc@1.3.1
207
+ - @stackframe/stack-shared@2.2.1
208
+
209
+ ## 2.2.3
210
+
211
+ ### Patch Changes
212
+
213
+ - fixed access token parsing error
214
+
215
+ ## 2.2.2
216
+
217
+ ### Patch Changes
218
+
219
+ - fixed mui import problem
220
+
221
+ ## 2.2.1
222
+
223
+ ### Patch Changes
224
+
225
+ - fixed dependency bug
226
+
227
+ ## 2.2.0
228
+
229
+ ### Minor Changes
230
+
231
+ - 2995d96: Added new UserButton component and Account setting page
232
+
233
+ ### Patch Changes
234
+
235
+ - 2995d96: Fixed signin title bug
236
+ - Updated dependencies [2995d96]
237
+ - @stackframe/stack-shared@2.2.0
238
+
239
+ ## 2.1.3
240
+
241
+ ### Patch Changes
242
+
243
+ - 4f985be: Fixed signin title bug
244
+
245
+ ## 2.1.2
246
+
247
+ ### Patch Changes
248
+
249
+ - 2eda71b: Fixed UI bugs
250
+
251
+ ## 2.1.1
252
+
253
+ ### Patch Changes
254
+
255
+ - fixed theme config bug
256
+
257
+ ## 2.1.0
258
+
259
+ ### Minor Changes
260
+
261
+ - 9e9907f: Added new stack UI system
262
+
263
+ ### Patch Changes
264
+
265
+ - Updated dependencies [9e9907f]
266
+ - @stackframe/stack-shared@2.1.0
267
+ - @stackframe/stack-sc@1.3.0
268
+
269
+ ## 2.0.0
270
+
271
+ ### Major Changes
272
+
273
+ - 948252f: removed redirect URL in function options, redirect automatically to default URL
274
+
275
+ ### Patch Changes
276
+
277
+ - Updated dependencies [948252f]
278
+ - @stackframe/stack-shared@2.0.0
279
+
280
+ ## 1.2.1
281
+
282
+ ### Patch Changes
283
+
284
+ - fixed import bugs
285
+ - Updated dependencies
286
+ - @stackframe/stack-sc@1.2.1
287
+ - @stackframe/stack-shared@1.2.1
288
+
289
+ ## 1.2.0
290
+
291
+ ### Minor Changes
292
+
293
+ - Fixed infinite reload bug, added dashboard provider update
294
+
295
+ ### Patch Changes
296
+
297
+ - Updated dependencies
298
+ - @stackframe/stack-sc@1.2.0
299
+ - @stackframe/stack-shared@1.2.0
300
+
301
+ ## 1.1.1
302
+
303
+ ### Patch Changes
304
+
305
+ - Updated dependencies
306
+ - @stackframe/stack-sc@1.1.1
307
+
308
+ ## 1.1.0
309
+
310
+ ### Minor Changes
311
+
312
+ - fixed bugs
313
+
314
+ ### Patch Changes
315
+
316
+ - Updated dependencies
317
+ - @stackframe/stack-shared@1.1.0
318
+ - @stackframe/stack-sc@1.1.0
@@ -3,7 +3,7 @@ import React__default from 'react';
3
3
  declare const Text: React__default.ForwardRefExoticComponent<Omit<Omit<Omit<{
4
4
  variant?: "primary" | "secondary" | "warning" | "success" | undefined;
5
5
  as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
6
- size?: "sm" | "md" | "lg" | "xs" | "xl" | undefined;
6
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
7
7
  } & Omit<React__default.HTMLProps<HTMLParagraphElement>, "size">, "ref"> & React__default.RefAttributes<HTMLParagraphElement>, "ref"> & React__default.RefAttributes<HTMLParagraphElement>, "ref"> & React__default.RefAttributes<HTMLParagraphElement>>;
8
8
 
9
9
  export { Text };
@@ -3,7 +3,7 @@ import React__default from 'react';
3
3
  declare const Text: React__default.ForwardRefExoticComponent<Omit<Omit<Omit<{
4
4
  variant?: "primary" | "secondary" | "warning" | "success" | undefined;
5
5
  as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
6
- size?: "sm" | "md" | "lg" | "xs" | "xl" | undefined;
6
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
7
7
  } & Omit<React__default.HTMLProps<HTMLParagraphElement>, "size">, "ref"> & React__default.RefAttributes<HTMLParagraphElement>, "ref"> & React__default.RefAttributes<HTMLParagraphElement>, "ref"> & React__default.RefAttributes<HTMLParagraphElement>>;
8
8
 
9
9
  export { Text };
@@ -20,7 +20,7 @@ import { scrambleDuringCompileTime } from "@stackframe/stack-shared/dist/utils/c
20
20
  import { isReactServer } from "@stackframe/stack-sc";
21
21
  import * as cookie from "cookie";
22
22
  var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
23
- var clientVersion = "js @stackframe/stack@2.4.11";
23
+ var clientVersion = "js @stackframe/stack@2.4.13";
24
24
  function permissionDefinitionScopeToType(scope) {
25
25
  return { "any-team": "team", "specific-team": "team", "global": "global" }[scope.type];
26
26
  }
@@ -129,7 +129,7 @@ var createCacheByTokenStore = (fetcher) => {
129
129
  {
130
130
  onSubscribe: ([tokenStore], refresh) => {
131
131
  const handlerObj = tokenStore.onChange((newValue, oldValue) => {
132
- if (JSON.stringify(newValue) === JSON.stringify(oldValue))
132
+ if (newValue.refreshToken === oldValue?.refreshToken)
133
133
  return;
134
134
  refresh();
135
135
  });
@@ -138,6 +138,7 @@ var createCacheByTokenStore = (fetcher) => {
138
138
  }
139
139
  );
140
140
  };
141
+ var numberOfAppsCreated = 0;
141
142
  var _StackClientAppImpl = class __StackClientAppImpl {
142
143
  constructor(_options) {
143
144
  this._options = _options;
@@ -153,6 +154,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
153
154
  }
154
155
  this._tokenStoreInit = _options.tokenStore;
155
156
  this._urlOptions = _options.urls ?? {};
157
+ if (_options.uniqueIdentifier) {
158
+ this._uniqueIdentifier = _options.uniqueIdentifier;
159
+ this._initUniqueIdentifier();
160
+ }
161
+ numberOfAppsCreated++;
162
+ if (numberOfAppsCreated > 10) {
163
+ console.warn(`You have created more than 10 Stack apps (${numberOfAppsCreated}). This is usually a sign of a memory leak. Make sure to minimize the number of Stack apps per page (usually, one per project).`);
164
+ }
156
165
  }
157
166
  _uniqueIdentifier = void 0;
158
167
  _interface;
@@ -178,17 +187,23 @@ var _StackClientAppImpl = class __StackClientAppImpl {
178
187
  _currentUserTeamsCache = createCacheByTokenStore(async (tokenStore) => {
179
188
  return await this._interface.listClientUserTeams(tokenStore);
180
189
  });
190
+ _initUniqueIdentifier() {
191
+ if (!this._uniqueIdentifier) {
192
+ throw new StackAssertionError("Unique identifier not initialized");
193
+ }
194
+ if (allClientApps.has(this._uniqueIdentifier)) {
195
+ throw new StackAssertionError("A Stack client app with the same unique identifier already exists");
196
+ }
197
+ allClientApps.set(this._uniqueIdentifier, [this._options.checkString ?? "default check string", this]);
198
+ }
181
199
  /**
182
200
  * Cloudflare workers does not allow use of randomness on the global scope (on which the Stack app is probably
183
201
  * initialized). For that reason, we generate the unique identifier lazily when it is first needed.
184
202
  */
185
203
  _getUniqueIdentifier() {
186
204
  if (!this._uniqueIdentifier) {
187
- this._uniqueIdentifier = this._options.uniqueIdentifier || generateUuid();
188
- if (allClientApps.has(this._uniqueIdentifier)) {
189
- throw new StackAssertionError("A Stack client app with the same unique identifier already exists");
190
- }
191
- allClientApps.set(this._uniqueIdentifier, [this._options.checkString ?? "default check string", this]);
205
+ this._uniqueIdentifier = generateUuid();
206
+ this._initUniqueIdentifier();
192
207
  }
193
208
  return this._uniqueIdentifier;
194
209
  }
@@ -373,6 +388,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
373
388
  const currentUser = {
374
389
  ...this._userFromJson(json),
375
390
  tokenStore,
391
+ async refreshAccessToken() {
392
+ await app._interface.refreshAccessToken(tokenStore);
393
+ },
376
394
  async updateSelectedTeam(team) {
377
395
  await app._updateUser({ selectedTeamId: team?.id ?? null }, tokenStore);
378
396
  },
@@ -450,7 +468,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
450
468
  baseUrl: this._interface.options.baseUrl,
451
469
  projectId: forProjectId,
452
470
  clientVersion,
453
- projectOwnerTokens: tokenStore
471
+ projectOwnerTokens: tokenStore,
472
+ refreshProjectOwnerTokens: async () => await this._interface.refreshAccessToken(tokenStore)
454
473
  });
455
474
  }
456
475
  get projectId() {
@@ -562,7 +581,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
562
581
  if (userJson === null) {
563
582
  switch (options?.or) {
564
583
  case "redirect": {
565
- router.replace(this.urls.signIn);
584
+ runAsynchronously(async () => {
585
+ await wait(0);
586
+ router.replace(this.urls.signIn);
587
+ });
566
588
  suspend();
567
589
  throw new StackAssertionError("suspend should never return");
568
590
  }
@@ -904,6 +926,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
904
926
  const currentUser = {
905
927
  ...nonCurrentServerUser,
906
928
  tokenStore,
929
+ async refreshAccessToken() {
930
+ await app._interface.refreshAccessToken(tokenStore);
931
+ },
907
932
  async delete() {
908
933
  const res = await nonCurrentServerUser.delete();
909
934
  await app._refreshUser(tokenStore);
@@ -1129,7 +1154,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1129
1154
  projectId: options.projectId ?? getDefaultProjectId(),
1130
1155
  clientVersion,
1131
1156
  ..."projectOwnerTokens" in options ? {
1132
- projectOwnerTokens: options.projectOwnerTokens
1157
+ projectOwnerTokens: options.projectOwnerTokens,
1158
+ refreshProjectOwnerTokens: options.refreshProjectOwnerTokens
1133
1159
  } : {
1134
1160
  publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
1135
1161
  secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),