@stackframe/stack 2.4.11 → 2.4.12

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,309 @@
1
+ # @stackframe/stack
2
+
3
+ ## 2.4.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Bugfixes
8
+ - Updated dependencies
9
+ - @stackframe/stack-shared@2.4.9
10
+ - @stackframe/stack-sc@1.5.4
11
+
12
+ ## 2.4.11
13
+
14
+ ### Patch Changes
15
+
16
+ - Cloudflare Workers support
17
+
18
+ ## 2.4.10
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @stackframe/stack-shared@2.4.8
24
+
25
+ ## 2.4.9
26
+
27
+ ### Patch Changes
28
+
29
+ - Bugfixes
30
+ - Updated dependencies
31
+ - @stackframe/stack-shared@2.4.7
32
+ - @stackframe/stack-sc@1.5.3
33
+
34
+ ## 2.4.8
35
+
36
+ ### Patch Changes
37
+
38
+ - Remove crypto-browserify dependency
39
+ - Updated dependencies
40
+ - @stackframe/stack-shared@2.4.6
41
+
42
+ ## 2.4.7
43
+
44
+ ### Patch Changes
45
+
46
+ - Team selection
47
+ - Updated dependencies
48
+ - @stackframe/stack-shared@2.4.5
49
+
50
+ ## 2.4.6
51
+
52
+ ### Patch Changes
53
+
54
+ - UX improvements
55
+ - Updated dependencies
56
+ - @stackframe/stack-shared@2.4.4
57
+
58
+ ## 2.4.5
59
+
60
+ ### Patch Changes
61
+
62
+ - CRUD schemas
63
+ - Updated dependencies
64
+ - @stackframe/stack-shared@2.4.3
65
+ - @stackframe/stack-sc@1.5.2
66
+
67
+ ## 2.4.4
68
+
69
+ ### Patch Changes
70
+
71
+ - Theme updates
72
+
73
+ ## 2.4.3
74
+
75
+ ### Patch Changes
76
+
77
+ - New projects page
78
+ - Updated dependencies
79
+ - @stackframe/stack-shared@2.4.2
80
+
81
+ ## 2.4.2
82
+
83
+ ### Patch Changes
84
+
85
+ - @stackframe package namespace
86
+
87
+ ## 2.4.1
88
+
89
+ ### Patch Changes
90
+
91
+ - Teams, permissions and RBAC
92
+ - Updated dependencies
93
+ - @stackframe/stack-shared@2.4.1
94
+ - @stackframe/stack-sc@1.5.1
95
+
96
+ ## 2.4.0
97
+
98
+ ### Minor Changes
99
+
100
+ - Middleware support
101
+
102
+ ### Patch Changes
103
+
104
+ - Updated dependencies
105
+ - @stackframe/stack-shared@2.4.0
106
+ - @stackframe/stack-sc@1.5.0
107
+
108
+ ## 2.3.8
109
+
110
+ ### Patch Changes
111
+
112
+ - Bugfixes
113
+ - Updated dependencies
114
+ - @stackframe/stack-shared@2.3.6
115
+
116
+ ## 2.3.7
117
+
118
+ ### Patch Changes
119
+
120
+ - CommonJS support
121
+ - Updated dependencies
122
+ - @stackframe/stack-shared@2.3.5
123
+
124
+ ## 2.3.6
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies
129
+ - @stackframe/stack-shared@2.3.4
130
+
131
+ ## 2.3.5
132
+
133
+ ### Patch Changes
134
+
135
+ - Partial pre-rendering
136
+ - Updated dependencies
137
+ - @stackframe/stack-shared@2.3.3
138
+
139
+ ## 2.3.4
140
+
141
+ ### Patch Changes
142
+
143
+ - E2E tests and various fixes
144
+
145
+ ## 2.3.3
146
+
147
+ ### Patch Changes
148
+
149
+ - Magic link configuration
150
+ - Updated dependencies
151
+ - @stackframe/stack-shared@2.3.2
152
+
153
+ ## 2.3.2
154
+
155
+ ### Patch Changes
156
+
157
+ - Add README file
158
+ - Updated dependencies
159
+ - @stackframe/stack-shared@2.3.1
160
+ - @stackframe/stack-sc@1.4.1
161
+
162
+ ## 2.3.1
163
+
164
+ ### Patch Changes
165
+
166
+ - Improve e-mail validation and add request timeouts
167
+
168
+ ## 2.3.0
169
+
170
+ ### Minor Changes
171
+
172
+ - 96c26a7: added magic link
173
+
174
+ ### Patch Changes
175
+
176
+ - Various small improvements
177
+ - Updated dependencies
178
+ - Updated dependencies [96c26a7]
179
+ - @stackframe/stack-shared@2.3.0
180
+ - @stackframe/stack-sc@1.4.0
181
+
182
+ ## 2.2.5
183
+
184
+ ### Patch Changes
185
+
186
+ - 5909ecd: fixed bugs
187
+ - Updated dependencies [5909ecd]
188
+ - @stackframe/stack-sc@1.3.2
189
+ - @stackframe/stack-shared@2.2.2
190
+
191
+ ## 2.2.4
192
+
193
+ ### Patch Changes
194
+
195
+ - fixed minor errors
196
+ - Updated dependencies
197
+ - @stackframe/stack-sc@1.3.1
198
+ - @stackframe/stack-shared@2.2.1
199
+
200
+ ## 2.2.3
201
+
202
+ ### Patch Changes
203
+
204
+ - fixed access token parsing error
205
+
206
+ ## 2.2.2
207
+
208
+ ### Patch Changes
209
+
210
+ - fixed mui import problem
211
+
212
+ ## 2.2.1
213
+
214
+ ### Patch Changes
215
+
216
+ - fixed dependency bug
217
+
218
+ ## 2.2.0
219
+
220
+ ### Minor Changes
221
+
222
+ - 2995d96: Added new UserButton component and Account setting page
223
+
224
+ ### Patch Changes
225
+
226
+ - 2995d96: Fixed signin title bug
227
+ - Updated dependencies [2995d96]
228
+ - @stackframe/stack-shared@2.2.0
229
+
230
+ ## 2.1.3
231
+
232
+ ### Patch Changes
233
+
234
+ - 4f985be: Fixed signin title bug
235
+
236
+ ## 2.1.2
237
+
238
+ ### Patch Changes
239
+
240
+ - 2eda71b: Fixed UI bugs
241
+
242
+ ## 2.1.1
243
+
244
+ ### Patch Changes
245
+
246
+ - fixed theme config bug
247
+
248
+ ## 2.1.0
249
+
250
+ ### Minor Changes
251
+
252
+ - 9e9907f: Added new stack UI system
253
+
254
+ ### Patch Changes
255
+
256
+ - Updated dependencies [9e9907f]
257
+ - @stackframe/stack-shared@2.1.0
258
+ - @stackframe/stack-sc@1.3.0
259
+
260
+ ## 2.0.0
261
+
262
+ ### Major Changes
263
+
264
+ - 948252f: removed redirect URL in function options, redirect automatically to default URL
265
+
266
+ ### Patch Changes
267
+
268
+ - Updated dependencies [948252f]
269
+ - @stackframe/stack-shared@2.0.0
270
+
271
+ ## 1.2.1
272
+
273
+ ### Patch Changes
274
+
275
+ - fixed import bugs
276
+ - Updated dependencies
277
+ - @stackframe/stack-sc@1.2.1
278
+ - @stackframe/stack-shared@1.2.1
279
+
280
+ ## 1.2.0
281
+
282
+ ### Minor Changes
283
+
284
+ - Fixed infinite reload bug, added dashboard provider update
285
+
286
+ ### Patch Changes
287
+
288
+ - Updated dependencies
289
+ - @stackframe/stack-sc@1.2.0
290
+ - @stackframe/stack-shared@1.2.0
291
+
292
+ ## 1.1.1
293
+
294
+ ### Patch Changes
295
+
296
+ - Updated dependencies
297
+ - @stackframe/stack-sc@1.1.1
298
+
299
+ ## 1.1.0
300
+
301
+ ### Minor Changes
302
+
303
+ - fixed bugs
304
+
305
+ ### Patch Changes
306
+
307
+ - Updated dependencies
308
+ - @stackframe/stack-shared@1.1.0
309
+ - @stackframe/stack-sc@1.1.0
@@ -19,7 +19,7 @@ declare const Label: React__default.ForwardRefExoticComponent<Omit<Omit<_radix_u
19
19
  declare const Link: React__default.ForwardRefExoticComponent<Omit<Omit<{
20
20
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
21
21
  href: string | url.Url;
22
- } & Omit<React__default.HTMLProps<HTMLLinkElement>, "size" | "href">, "ref"> & React__default.RefAttributes<HTMLAnchorElement>, "ref"> & React__default.RefAttributes<HTMLAnchorElement>>;
22
+ } & Omit<React__default.HTMLProps<HTMLLinkElement>, "href" | "size">, "ref"> & React__default.RefAttributes<HTMLAnchorElement>, "ref"> & React__default.RefAttributes<HTMLAnchorElement>>;
23
23
  declare const Text: React__default.ForwardRefExoticComponent<Omit<Omit<{
24
24
  variant?: "primary" | "secondary" | "warning" | "success" | undefined;
25
25
  as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
@@ -19,7 +19,7 @@ declare const Label: React__default.ForwardRefExoticComponent<Omit<Omit<_radix_u
19
19
  declare const Link: React__default.ForwardRefExoticComponent<Omit<Omit<{
20
20
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
21
21
  href: string | url.Url;
22
- } & Omit<React__default.HTMLProps<HTMLLinkElement>, "size" | "href">, "ref"> & React__default.RefAttributes<HTMLAnchorElement>, "ref"> & React__default.RefAttributes<HTMLAnchorElement>>;
22
+ } & Omit<React__default.HTMLProps<HTMLLinkElement>, "href" | "size">, "ref"> & React__default.RefAttributes<HTMLAnchorElement>, "ref"> & React__default.RefAttributes<HTMLAnchorElement>>;
23
23
  declare const Text: React__default.ForwardRefExoticComponent<Omit<Omit<{
24
24
  variant?: "primary" | "secondary" | "warning" | "success" | undefined;
25
25
  as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
@@ -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.12";
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(),