@stackframe/stack 2.4.10 → 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;
@@ -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.10";
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,8 +138,32 @@ var createCacheByTokenStore = (fetcher) => {
138
138
  }
139
139
  );
140
140
  };
141
+ var numberOfAppsCreated = 0;
141
142
  var _StackClientAppImpl = class __StackClientAppImpl {
142
- _uniqueIdentifier;
143
+ constructor(_options) {
144
+ this._options = _options;
145
+ if ("interface" in _options) {
146
+ this._interface = _options.interface;
147
+ } else {
148
+ this._interface = new StackClientInterface({
149
+ baseUrl: _options.baseUrl ?? getDefaultBaseUrl(),
150
+ projectId: _options.projectId ?? getDefaultProjectId(),
151
+ clientVersion,
152
+ publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
153
+ });
154
+ }
155
+ this._tokenStoreInit = _options.tokenStore;
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
+ }
165
+ }
166
+ _uniqueIdentifier = void 0;
143
167
  _interface;
144
168
  _tokenStoreInit;
145
169
  _urlOptions;
@@ -163,24 +187,25 @@ var _StackClientAppImpl = class __StackClientAppImpl {
163
187
  _currentUserTeamsCache = createCacheByTokenStore(async (tokenStore) => {
164
188
  return await this._interface.listClientUserTeams(tokenStore);
165
189
  });
166
- constructor(options) {
167
- if ("interface" in options) {
168
- this._interface = options.interface;
169
- } else {
170
- this._interface = new StackClientInterface({
171
- baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
172
- projectId: options.projectId ?? getDefaultProjectId(),
173
- clientVersion,
174
- publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey()
175
- });
190
+ _initUniqueIdentifier() {
191
+ if (!this._uniqueIdentifier) {
192
+ throw new StackAssertionError("Unique identifier not initialized");
176
193
  }
177
- this._tokenStoreInit = options.tokenStore;
178
- this._urlOptions = options.urls ?? {};
179
- this._uniqueIdentifier = options.uniqueIdentifier ?? generateUuid();
180
194
  if (allClientApps.has(this._uniqueIdentifier)) {
181
195
  throw new StackAssertionError("A Stack client app with the same unique identifier already exists");
182
196
  }
183
- allClientApps.set(this._uniqueIdentifier, [options.checkString ?? "default check string", this]);
197
+ allClientApps.set(this._uniqueIdentifier, [this._options.checkString ?? "default check string", this]);
198
+ }
199
+ /**
200
+ * Cloudflare workers does not allow use of randomness on the global scope (on which the Stack app is probably
201
+ * initialized). For that reason, we generate the unique identifier lazily when it is first needed.
202
+ */
203
+ _getUniqueIdentifier() {
204
+ if (!this._uniqueIdentifier) {
205
+ this._uniqueIdentifier = generateUuid();
206
+ this._initUniqueIdentifier();
207
+ }
208
+ return this._uniqueIdentifier;
184
209
  }
185
210
  _memoryTokenStore = createEmptyTokenStore();
186
211
  _requestTokenStores = /* @__PURE__ */ new Map();
@@ -363,6 +388,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
363
388
  const currentUser = {
364
389
  ...this._userFromJson(json),
365
390
  tokenStore,
391
+ async refreshAccessToken() {
392
+ await app._interface.refreshAccessToken(tokenStore);
393
+ },
366
394
  async updateSelectedTeam(team) {
367
395
  await app._updateUser({ selectedTeamId: team?.id ?? null }, tokenStore);
368
396
  },
@@ -440,7 +468,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
440
468
  baseUrl: this._interface.options.baseUrl,
441
469
  projectId: forProjectId,
442
470
  clientVersion,
443
- projectOwnerTokens: tokenStore
471
+ projectOwnerTokens: tokenStore,
472
+ refreshProjectOwnerTokens: async () => await this._interface.refreshAccessToken(tokenStore)
444
473
  });
445
474
  }
446
475
  get projectId() {
@@ -552,7 +581,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
552
581
  if (userJson === null) {
553
582
  switch (options?.or) {
554
583
  case "redirect": {
555
- router.replace(this.urls.signIn);
584
+ runAsynchronously(async () => {
585
+ await wait(0);
586
+ router.replace(this.urls.signIn);
587
+ });
556
588
  suspend();
557
589
  throw new StackAssertionError("suspend should never return");
558
590
  }
@@ -749,7 +781,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
749
781
  publishableClientKey: this._interface.options.publishableClientKey,
750
782
  tokenStore: this._tokenStoreInit,
751
783
  urls: this._urlOptions,
752
- uniqueIdentifier: this._uniqueIdentifier
784
+ uniqueIdentifier: this._getUniqueIdentifier()
753
785
  };
754
786
  },
755
787
  setCurrentUser: (userJsonPromise) => {
@@ -894,6 +926,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
894
926
  const currentUser = {
895
927
  ...nonCurrentServerUser,
896
928
  tokenStore,
929
+ async refreshAccessToken() {
930
+ await app._interface.refreshAccessToken(tokenStore);
931
+ },
897
932
  async delete() {
898
933
  const res = await nonCurrentServerUser.delete();
899
934
  await app._refreshUser(tokenStore);
@@ -1119,7 +1154,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1119
1154
  projectId: options.projectId ?? getDefaultProjectId(),
1120
1155
  clientVersion,
1121
1156
  ..."projectOwnerTokens" in options ? {
1122
- projectOwnerTokens: options.projectOwnerTokens
1157
+ projectOwnerTokens: options.projectOwnerTokens,
1158
+ refreshProjectOwnerTokens: options.refreshProjectOwnerTokens
1123
1159
  } : {
1124
1160
  publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
1125
1161
  secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey(),