@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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.8.7
4
+
5
+ ## 2.8.6
6
+
7
+ ### Patch Changes
8
+
9
+ - Various changes
10
+
3
11
  ## 2.8.5
4
12
 
5
13
  ### Patch Changes
@@ -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(/^[^.].*@.*\.[^.][^.]+$/, message);
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.8.5",
3
+ "version": "2.8.7",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",