@maysun/common 3.0.3 → 3.0.6

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.
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ export declare const signupSchema: z.ZodObject<{
3
+ domain: z.ZodString;
4
+ phoneNumber: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export declare const signinSchema: z.ZodObject<{
7
+ domain: z.ZodString;
8
+ phoneNumber: z.ZodString;
9
+ otp: z.ZodString;
10
+ }, z.core.$strip>;
11
+ export type SignupInput = z.infer<typeof signupSchema>;
12
+ export type SigninInput = z.infer<typeof signinSchema>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signinSchema = exports.signupSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const phoneNumberSchema = zod_1.z
6
+ .string()
7
+ .length(11, 'Phone number must be 11 digits long')
8
+ .regex(/^09\d{9}$/, 'The phone number must start with 09');
9
+ const domainSchema = zod_1.z
10
+ .string()
11
+ .trim()
12
+ .max(50, 'Domain too long')
13
+ .regex(/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i, 'Domain is not valid (e.g., octolab.ir)');
14
+ exports.signupSchema = zod_1.z.object({
15
+ domain: domainSchema,
16
+ phoneNumber: phoneNumberSchema,
17
+ });
18
+ exports.signinSchema = zod_1.z.object({
19
+ domain: domainSchema,
20
+ phoneNumber: phoneNumberSchema,
21
+ otp: zod_1.z.string().trim().min(4, 'OTP must be at least 4 chars').max(100, 'OTP too long'),
22
+ });
@@ -22,3 +22,4 @@ __exportStar(require("./errors/not-found-error"), exports);
22
22
  __exportStar(require("./errors/request-validation-error"), exports);
23
23
  __exportStar(require("./errors/graphql/graphql-error-handler"), exports);
24
24
  __exportStar(require("./errors/graphql/validationError"), exports);
25
+ //
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("express-rate-limit").RateLimitRequestHandler;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { NextFunction, Request, Response } from 'express';
2
- import 'express-async-errors';
1
+ import { NextFunction, Request, Response } from "express";
2
+ import "express-async-errors";
3
3
  export declare const validateRequest: (req: Request, res: Response, next: NextFunction) => void;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateRequest = void 0;
4
4
  const request_validation_error_1 = require("../errors/request-validation-error");
5
5
  require("express-async-errors");
6
- const validation_1 = require("./validation");
6
+ const validation_1 = require("../../../auth/src/middleware/validation");
7
7
  const validateRequest = (req, res, next) => {
8
8
  const result = validation_1.signinSchema.safeParse(req.body);
9
9
  if (!result.success)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maysun/common",
3
- "version": "3.0.3",
3
+ "version": "3.0.6",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.t.ts",
6
6
  "files": [