@stackframe/stack-shared 2.8.5 → 2.8.7
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 +8 -0
- package/dist/schema-fields.js +28 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/schema-fields.js
CHANGED
|
@@ -248,9 +248,36 @@ export const passwordSchema = yupString().max(70);
|
|
|
248
248
|
* `emailSchema` instead until we do the DB migration.
|
|
249
249
|
*/
|
|
250
250
|
// eslint-disable-next-line no-restricted-syntax
|
|
251
|
-
export const strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]
|
|
251
|
+
export const strictEmailSchema = (message) => yupString().email(message).matches(/^[^.]+(\.[^.]+)*@.*\.[^.][^.]+$/, message);
|
|
252
252
|
// eslint-disable-next-line no-restricted-syntax
|
|
253
253
|
export const emailSchema = yupString().email();
|
|
254
|
+
import.meta.vitest?.test('strictEmailSchema', ({ expect }) => {
|
|
255
|
+
const validEmails = [
|
|
256
|
+
"a@example.com",
|
|
257
|
+
"abc@example.com",
|
|
258
|
+
"a.b@example.com",
|
|
259
|
+
"throwaway.mail+token@example.com",
|
|
260
|
+
"email-alt-dash@demo-mail.com",
|
|
261
|
+
"test-account@weird-domain.net",
|
|
262
|
+
"%!~&+{}=|`#@domain.test",
|
|
263
|
+
"admin@a.longtldexample",
|
|
264
|
+
];
|
|
265
|
+
for (const email of validEmails) {
|
|
266
|
+
expect(strictEmailSchema(undefined).validateSync(email)).toBe(email);
|
|
267
|
+
}
|
|
268
|
+
const invalidEmails = [
|
|
269
|
+
"test@localhost",
|
|
270
|
+
"test@gmail",
|
|
271
|
+
"test@gmail.com.a",
|
|
272
|
+
"test@gmail.a",
|
|
273
|
+
"test.@example.com",
|
|
274
|
+
"test..test@example.com",
|
|
275
|
+
".test@example.com",
|
|
276
|
+
];
|
|
277
|
+
for (const email of invalidEmails) {
|
|
278
|
+
expect(() => strictEmailSchema(undefined).validateSync(email)).toThrow();
|
|
279
|
+
}
|
|
280
|
+
});
|
|
254
281
|
// Request auth
|
|
255
282
|
export const clientOrHigherAuthTypeSchema = yupString().oneOf(['client', 'server', 'admin']).defined();
|
|
256
283
|
export const serverOrHigherAuthTypeSchema = yupString().oneOf(['server', 'admin']).defined();
|