@stackframe/stack-shared 2.5.27 → 2.5.28

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.5.28
4
+
5
+ ### Patch Changes
6
+
7
+ - Bugfixes
8
+ - @stackframe/stack-sc@2.5.28
9
+
3
10
  ## 2.5.27
4
11
 
5
12
  ### Patch Changes
@@ -23,6 +23,7 @@ export declare class StackClientInterface {
23
23
  get projectId(): string;
24
24
  getApiUrl(): string;
25
25
  runNetworkDiagnostics(session?: InternalSession | null, requestType?: "client" | "server" | "admin"): Promise<{
26
+ "navigator?.onLine": any;
26
27
  cfTrace: string;
27
28
  apiRoot: string;
28
29
  baseUrlBackend: string;
@@ -60,6 +60,7 @@ export class StackClientInterface {
60
60
  }
61
61
  });
62
62
  return {
63
+ "navigator?.onLine": globalVar.navigator?.onLine,
63
64
  cfTrace,
64
65
  apiRoot,
65
66
  baseUrlBackend,
@@ -71,7 +72,7 @@ export class StackClientInterface {
71
72
  const retriedResult = await Result.retry(cb, 5, { exponentialDelayBase: 1000 });
72
73
  // try to diagnose the error for the user
73
74
  if (retriedResult.status === "error") {
74
- if (!navigator.onLine) {
75
+ if (globalVar.navigator && !globalVar.navigator.onLine) {
75
76
  throw new Error("Failed to send Stack network request. It seems like you are offline. (window.navigator.onLine is falsy)", { cause: retriedResult.error });
76
77
  }
77
78
  throw new Error(deindent `
@@ -256,7 +257,7 @@ export class StackClientInterface {
256
257
  else {
257
258
  const error = await res.text();
258
259
  // Do not retry, throw error instead of returning one
259
- throw new Error(`Failed to send request to ${url}: ${res.status} ${error}`);
260
+ throw new StackAssertionError(`Failed to send request to ${url}: ${res.status} ${error}`, { request: params, res });
260
261
  }
261
262
  }
262
263
  async _processResponse(rawRes) {
@@ -73,6 +73,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
73
73
  client_metadata: undefined;
74
74
  client_read_only_metadata: undefined;
75
75
  server_metadata: undefined;
76
+ last_active_at_millis: undefined;
76
77
  }, "">;
77
78
  serverReadSchema: import("yup").ObjectSchema<{
78
79
  id: string;
@@ -125,6 +126,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
125
126
  client_metadata: {} | null;
126
127
  client_read_only_metadata: {} | null;
127
128
  server_metadata: {} | null;
129
+ last_active_at_millis: number;
128
130
  } | null, import("yup").AnyObject, {
129
131
  id: undefined;
130
132
  primary_email: undefined;
@@ -151,6 +153,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
151
153
  client_metadata: undefined;
152
154
  client_read_only_metadata: undefined;
153
155
  server_metadata: undefined;
156
+ last_active_at_millis: undefined;
154
157
  }, "">;
155
158
  clientUpdateSchema: import("yup").ObjectSchema<{
156
159
  display_name: string | null | undefined;
@@ -67,6 +67,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
67
67
  provider_user_id: string;
68
68
  };
69
69
  }[];
70
+ last_active_at_millis: number;
70
71
  };
71
72
  }>, import("yup").AnyObject, {
72
73
  team_id: undefined;
@@ -99,6 +100,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
99
100
  client_metadata: undefined;
100
101
  client_read_only_metadata: undefined;
101
102
  server_metadata: undefined;
103
+ last_active_at_millis: undefined;
102
104
  };
103
105
  }, "">;
104
106
  export declare const teamMemberProfilesCrudClientUpdateSchema: import("yup").ObjectSchema<{
@@ -177,6 +179,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
177
179
  provider_user_id: string;
178
180
  };
179
181
  }[];
182
+ last_active_at_millis: number;
180
183
  };
181
184
  }>, import("yup").AnyObject, {
182
185
  team_id: undefined;
@@ -209,6 +212,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
209
212
  client_metadata: undefined;
210
213
  client_read_only_metadata: undefined;
211
214
  server_metadata: undefined;
215
+ last_active_at_millis: undefined;
212
216
  };
213
217
  }, "">;
214
218
  clientUpdateSchema: import("yup").ObjectSchema<{
@@ -75,6 +75,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
75
75
  client_metadata: {} | null;
76
76
  client_read_only_metadata: {} | null;
77
77
  server_metadata: {} | null;
78
+ last_active_at_millis: number;
78
79
  }, import("yup").AnyObject, {
79
80
  id: undefined;
80
81
  primary_email: undefined;
@@ -101,6 +102,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
101
102
  client_metadata: undefined;
102
103
  client_read_only_metadata: undefined;
103
104
  server_metadata: undefined;
105
+ last_active_at_millis: undefined;
104
106
  }, "">;
105
107
  export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
106
108
  display_name: string | null | undefined;
@@ -187,6 +189,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
187
189
  client_metadata: {} | null;
188
190
  client_read_only_metadata: {} | null;
189
191
  server_metadata: {} | null;
192
+ last_active_at_millis: number;
190
193
  }, import("yup").AnyObject, {
191
194
  id: undefined;
192
195
  primary_email: undefined;
@@ -213,6 +216,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
213
216
  client_metadata: undefined;
214
217
  client_read_only_metadata: undefined;
215
218
  server_metadata: undefined;
219
+ last_active_at_millis: undefined;
216
220
  }, "">;
217
221
  serverUpdateSchema: import("yup").ObjectSchema<{
218
222
  display_name: string | null | undefined;
@@ -354,6 +358,7 @@ export declare const userCreatedWebhookEvent: {
354
358
  client_metadata: {} | null;
355
359
  client_read_only_metadata: {} | null;
356
360
  server_metadata: {} | null;
361
+ last_active_at_millis: number;
357
362
  }, import("yup").AnyObject, {
358
363
  id: undefined;
359
364
  primary_email: undefined;
@@ -380,6 +385,7 @@ export declare const userCreatedWebhookEvent: {
380
385
  client_metadata: undefined;
381
386
  client_read_only_metadata: undefined;
382
387
  server_metadata: undefined;
388
+ last_active_at_millis: undefined;
383
389
  }, "">;
384
390
  metadata: {
385
391
  summary: string;
@@ -440,6 +446,7 @@ export declare const userUpdatedWebhookEvent: {
440
446
  client_metadata: {} | null;
441
447
  client_read_only_metadata: {} | null;
442
448
  server_metadata: {} | null;
449
+ last_active_at_millis: number;
443
450
  }, import("yup").AnyObject, {
444
451
  id: undefined;
445
452
  primary_email: undefined;
@@ -466,6 +473,7 @@ export declare const userUpdatedWebhookEvent: {
466
473
  client_metadata: undefined;
467
474
  client_read_only_metadata: undefined;
468
475
  server_metadata: undefined;
476
+ last_active_at_millis: undefined;
469
477
  }, "">;
470
478
  metadata: {
471
479
  summary: string;
@@ -60,6 +60,7 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
60
60
  client_metadata: fieldSchema.userClientMetadataSchema,
61
61
  client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema,
62
62
  server_metadata: fieldSchema.userServerMetadataSchema,
63
+ last_active_at_millis: fieldSchema.userLastActiveAtMillisSchema.required(),
63
64
  }).required();
64
65
  export const usersCrudServerCreateSchema = usersCrudServerUpdateSchema.concat(fieldSchema.yupObject({
65
66
  oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
@@ -61,6 +61,7 @@ export declare const webhookEvents: readonly [{
61
61
  client_metadata: {} | null;
62
62
  client_read_only_metadata: {} | null;
63
63
  server_metadata: {} | null;
64
+ last_active_at_millis: number;
64
65
  }, yup.AnyObject, {
65
66
  id: undefined;
66
67
  primary_email: undefined;
@@ -87,6 +88,7 @@ export declare const webhookEvents: readonly [{
87
88
  client_metadata: undefined;
88
89
  client_read_only_metadata: undefined;
89
90
  server_metadata: undefined;
91
+ last_active_at_millis: undefined;
90
92
  }, "">;
91
93
  metadata: {
92
94
  summary: string;
@@ -146,6 +148,7 @@ export declare const webhookEvents: readonly [{
146
148
  client_metadata: {} | null;
147
149
  client_read_only_metadata: {} | null;
148
150
  server_metadata: {} | null;
151
+ last_active_at_millis: number;
149
152
  }, yup.AnyObject, {
150
153
  id: undefined;
151
154
  primary_email: undefined;
@@ -172,6 +175,7 @@ export declare const webhookEvents: readonly [{
172
175
  client_metadata: undefined;
173
176
  client_read_only_metadata: undefined;
174
177
  server_metadata: undefined;
178
+ last_active_at_millis: undefined;
175
179
  }, "">;
176
180
  metadata: {
177
181
  summary: string;
@@ -75,6 +75,7 @@ export declare const userOAuthProviderSchema: yup.ObjectSchema<{
75
75
  type: undefined;
76
76
  provider_user_id: undefined;
77
77
  }, "">;
78
+ export declare const userLastActiveAtMillisSchema: yup.NumberSchema<number | null | undefined, yup.AnyObject, undefined, "">;
78
79
  export declare const signInEmailSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
79
80
  export declare const emailOtpSignInCallbackUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
80
81
  export declare const emailVerificationCallbackUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -12,6 +12,7 @@ const _serverMetaDataDescription = (identify) => `Server metadata. Used as a dat
12
12
  const _atMillisDescription = (identify) => `(the number of milliseconds since epoch, January 1, 1970, UTC)`;
13
13
  const _createdAtMillisDescription = (identify) => `The time the ${identify} was created ${_atMillisDescription(identify)}`;
14
14
  const _signedUpAtMillisDescription = `The time the user signed up ${_atMillisDescription}`;
15
+ const _lastActiveAtMillisDescription = `The time the user was last active ${_atMillisDescription}`;
15
16
  // Built-in replacements
16
17
  /* eslint-disable no-restricted-syntax */
17
18
  export function yupString(...args) {
@@ -201,6 +202,7 @@ export const userOAuthProviderSchema = yupObject({
201
202
  type: yupString().required(),
202
203
  provider_user_id: yupString().required(),
203
204
  });
205
+ export const userLastActiveAtMillisSchema = yupNumber().nullable().meta({ openapiField: { description: _lastActiveAtMillisDescription, exampleValue: 1630000000000 } });
204
206
  // Auth
205
207
  export const signInEmailSchema = emailSchema.meta({ openapiField: { description: 'The email to sign in with.', exampleValue: 'johndoe@example.com' } });
206
208
  export const emailOtpSignInCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct the magic link from. A query argument `code` with the verification code will be appended to it. The page should then make a request to the `/auth/otp/sign-in` endpoint.', exampleValue: 'https://example.com/handler/magic-link-callback' } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.5.27",
3
+ "version": "2.5.28",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -36,7 +36,7 @@
36
36
  "jose": "^5.2.2",
37
37
  "oauth4webapi": "^2.10.3",
38
38
  "uuid": "^9.0.1",
39
- "@stackframe/stack-sc": "2.5.27"
39
+ "@stackframe/stack-sc": "2.5.28"
40
40
  },
41
41
  "devDependencies": {
42
42
  "rimraf": "^5.0.5",