@stackframe/stack-shared 2.5.25 → 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 +23 -0
- package/dist/interface/clientInterface.d.ts +1 -0
- package/dist/interface/clientInterface.js +3 -2
- package/dist/interface/crud/current-user.d.ts +5 -1
- package/dist/interface/crud/current-user.js +1 -0
- package/dist/interface/crud/team-member-profiles.d.ts +4 -0
- package/dist/interface/crud/users.d.ts +12 -4
- package/dist/interface/crud/users.js +2 -1
- package/dist/interface/webhooks.d.ts +4 -0
- package/dist/schema-fields.d.ts +1 -0
- package/dist/schema-fields.js +7 -5
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/base64.js +12 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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
|
+
|
|
10
|
+
## 2.5.27
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Bugfixes
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @stackframe/stack-sc@2.5.27
|
|
17
|
+
|
|
18
|
+
## 2.5.26
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Bugfixes
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @stackframe/stack-sc@2.5.26
|
|
25
|
+
|
|
3
26
|
## 2.5.25
|
|
4
27
|
|
|
5
28
|
### 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
|
|
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,9 +153,11 @@ 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;
|
|
160
|
+
profile_image_url: string | null | undefined;
|
|
157
161
|
client_metadata: {} | null | undefined;
|
|
158
162
|
totp_secret_base64: string | null | undefined;
|
|
159
163
|
selected_team_id: string | null | undefined;
|
|
@@ -172,7 +176,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
|
|
|
172
176
|
}, "">;
|
|
173
177
|
serverUpdateSchema: import("yup").ObjectSchema<{
|
|
174
178
|
display_name: string | null | undefined;
|
|
175
|
-
profile_image_url: string | undefined;
|
|
179
|
+
profile_image_url: string | null | undefined;
|
|
176
180
|
client_metadata: {} | null | undefined;
|
|
177
181
|
client_read_only_metadata: {} | null | undefined;
|
|
178
182
|
server_metadata: {} | null | undefined;
|
|
@@ -4,6 +4,7 @@ import { teamsCrudClientReadSchema } from "./teams";
|
|
|
4
4
|
import { usersCrudServerDeleteSchema, usersCrudServerReadSchema, usersCrudServerUpdateSchema } from "./users";
|
|
5
5
|
const clientUpdateSchema = usersCrudServerUpdateSchema.pick([
|
|
6
6
|
"display_name",
|
|
7
|
+
"profile_image_url",
|
|
7
8
|
"client_metadata",
|
|
8
9
|
"selected_team_id",
|
|
9
10
|
"totp_secret_base64",
|
|
@@ -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<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CrudTypeOf } from "../../crud";
|
|
2
2
|
export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
|
|
3
3
|
display_name: string | null | undefined;
|
|
4
|
-
profile_image_url: string | undefined;
|
|
4
|
+
profile_image_url: string | null | undefined;
|
|
5
5
|
client_metadata: {} | null | undefined;
|
|
6
6
|
client_read_only_metadata: {} | null | undefined;
|
|
7
7
|
server_metadata: {} | null | undefined;
|
|
@@ -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,10 +102,11 @@ 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;
|
|
107
|
-
profile_image_url: string | undefined;
|
|
109
|
+
profile_image_url: string | null | undefined;
|
|
108
110
|
client_metadata: {} | null | undefined;
|
|
109
111
|
client_read_only_metadata: {} | null | undefined;
|
|
110
112
|
server_metadata: {} | 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,10 +216,11 @@ 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;
|
|
219
|
-
profile_image_url: string | undefined;
|
|
223
|
+
profile_image_url: string | null | undefined;
|
|
220
224
|
client_metadata: {} | null | undefined;
|
|
221
225
|
client_read_only_metadata: {} | null | undefined;
|
|
222
226
|
server_metadata: {} | null | undefined;
|
|
@@ -241,7 +245,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
241
245
|
}, "">;
|
|
242
246
|
serverCreateSchema: import("yup").ObjectSchema<{
|
|
243
247
|
display_name: string | null | undefined;
|
|
244
|
-
profile_image_url: string | undefined;
|
|
248
|
+
profile_image_url: string | null | undefined;
|
|
245
249
|
client_metadata: {} | null | undefined;
|
|
246
250
|
client_read_only_metadata: {} | null | undefined;
|
|
247
251
|
server_metadata: {} | 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;
|
|
@@ -3,7 +3,7 @@ import * as fieldSchema from "../../schema-fields";
|
|
|
3
3
|
import { teamsCrudServerReadSchema } from "./teams";
|
|
4
4
|
export const usersCrudServerUpdateSchema = fieldSchema.yupObject({
|
|
5
5
|
display_name: fieldSchema.userDisplayNameSchema.optional(),
|
|
6
|
-
profile_image_url: fieldSchema.profileImageUrlSchema.optional(),
|
|
6
|
+
profile_image_url: fieldSchema.profileImageUrlSchema.nullable().optional(),
|
|
7
7
|
client_metadata: fieldSchema.userClientMetadataSchema.optional(),
|
|
8
8
|
client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema.optional(),
|
|
9
9
|
server_metadata: fieldSchema.userServerMetadataSchema.optional(),
|
|
@@ -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;
|
package/dist/schema-fields.d.ts
CHANGED
|
@@ -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, "">;
|
package/dist/schema-fields.js
CHANGED
|
@@ -7,11 +7,12 @@ const _idDescription = (identify) => `The unique identifier of this ${identify}`
|
|
|
7
7
|
const _displayNameDescription = (identify) => `Human-readable ${identify} display name. This is not a unique identifier.`;
|
|
8
8
|
const _clientMetaDataDescription = (identify) => `Client metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client.`;
|
|
9
9
|
const _clientReadOnlyMetaDataDescription = (identify) => `Client read-only, server-writable metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client. The client can read this data, but cannot modify it. This is useful for things like subscription status.`;
|
|
10
|
-
const _profileImageUrlDescription = (identify) => `URL of the profile image for ${identify}. Can be a Base64 encoded image. Please compress and crop to a square before passing in.`;
|
|
10
|
+
const _profileImageUrlDescription = (identify) => `URL of the profile image for ${identify}. Can be a Base64 encoded image. Must be smaller than 100KB. Please compress and crop to a square before passing in.`;
|
|
11
11
|
const _serverMetaDataDescription = (identify) => `Server metadata. Used as a data store, only accessible from the server side. You can store secret information related to the ${identify} here.`;
|
|
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) {
|
|
@@ -93,7 +94,7 @@ export const urlSchema = yupString().test({
|
|
|
93
94
|
name: 'url',
|
|
94
95
|
message: 'Invalid URL',
|
|
95
96
|
test: (value) => {
|
|
96
|
-
if (value
|
|
97
|
+
if (!value)
|
|
97
98
|
return true;
|
|
98
99
|
try {
|
|
99
100
|
new URL(value);
|
|
@@ -192,7 +193,7 @@ export const primaryEmailSchema = emailSchema.meta({ openapiField: { description
|
|
|
192
193
|
export const primaryEmailVerifiedSchema = yupBoolean().meta({ openapiField: { description: 'Whether the primary email has been verified to belong to this user', exampleValue: true } });
|
|
193
194
|
export const userDisplayNameSchema = yupString().nullable().meta({ openapiField: { description: _displayNameDescription('user'), exampleValue: 'John Doe' } });
|
|
194
195
|
export const selectedTeamIdSchema = yupString().uuid().meta({ openapiField: { description: 'ID of the team currently selected by the user', exampleValue: 'team-id' } });
|
|
195
|
-
export const profileImageUrlSchema =
|
|
196
|
+
export const profileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('user'), exampleValue: 'https://example.com/image.jpg' } });
|
|
196
197
|
export const signedUpAtMillisSchema = yupNumber().meta({ openapiField: { description: _signedUpAtMillisDescription, exampleValue: 1630000000000 } });
|
|
197
198
|
export const userClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription('user'), exampleValue: { key: 'value' } } });
|
|
198
199
|
export const userClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription('user'), exampleValue: { key: 'value' } } });
|
|
@@ -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' } });
|
|
@@ -240,7 +242,7 @@ export const containedPermissionIdsSchema = yupArray(teamPermissionDefinitionIdS
|
|
|
240
242
|
// Teams
|
|
241
243
|
export const teamIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('team'), exampleValue: 'ad962777-8244-496a-b6a2-e0c6a449c79e' } });
|
|
242
244
|
export const teamDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team'), exampleValue: 'My Team' } });
|
|
243
|
-
export const teamProfileImageUrlSchema =
|
|
245
|
+
export const teamProfileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('team'), exampleValue: 'https://example.com/image.jpg' } });
|
|
244
246
|
export const teamClientMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientMetaDataDescription('team'), exampleValue: { key: 'value' } } });
|
|
245
247
|
export const teamClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription('team'), exampleValue: { key: 'value' } } });
|
|
246
248
|
export const teamServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription('team'), exampleValue: { key: 'value' } } });
|
|
@@ -249,7 +251,7 @@ export const teamInvitationEmailSchema = emailSchema.meta({ openapiField: { desc
|
|
|
249
251
|
export const teamInvitationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct a verification link for the verification e-mail. A query argument `code` with the verification code will be appended to it. The page should then make a request to the `/contact-channels/verify` endpoint.', exampleValue: 'https://example.com/handler/email-verification' } });
|
|
250
252
|
// Team member profiles
|
|
251
253
|
export const teamMemberDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team member') + ' Note that this is separate from the display_name of the user.', exampleValue: 'John Doe' } });
|
|
252
|
-
export const teamMemberProfileImageUrlSchema =
|
|
254
|
+
export const teamMemberProfileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('team member'), exampleValue: 'https://example.com/image.jpg' } });
|
|
253
255
|
// Utils
|
|
254
256
|
export function yupRequiredWhen(schema, triggerName, isValue) {
|
|
255
257
|
return schema.when(triggerName, {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function fileToBase64(file) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const reader = new FileReader();
|
|
4
|
+
reader.readAsDataURL(file);
|
|
5
|
+
reader.onload = () => resolve(reader.result);
|
|
6
|
+
reader.onerror = error => reject(error);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function validateBase64Image(base64) {
|
|
10
|
+
const base64ImageRegex = /^data:image\/(png|jpg|jpeg|gif|bmp|webp);base64,[A-Za-z0-9+/]+={0,2}$|^[A-Za-z0-9+/]+={0,2}$/;
|
|
11
|
+
return base64ImageRegex.test(base64);
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack-shared",
|
|
3
|
-
"version": "2.5.
|
|
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.
|
|
39
|
+
"@stackframe/stack-sc": "2.5.28"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"rimraf": "^5.0.5",
|