@darco2903/auth-api 2.1.4 → 2.2.0

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.
@@ -1,7 +1,7 @@
1
1
  import { initContract, ZodErrorSchema } from "@ts-rest/core";
2
2
  import z from "zod";
3
3
  import { apiError, apiSuccess } from "../types.js";
4
- import { authHeaderSchema, accessTokenDataDecodedSchema, accessRefreshSchema, emailCredentialSchema, emailSchema, passwordCredentialSchema, passwordSchema, turnstileSchema, usernameSchema, totpCodeSchema, } from "../types/index.js";
4
+ import { authHeaderSchema, accessTokenDataDecodedSchema, accessRefreshSchema, accessRefreshPendingSchema, emailCredentialSchema, emailSchema, passwordCredentialSchema, passwordSchema, turnstileSchema, usernameSchema, } from "../types/index.js";
5
5
  const c = initContract();
6
6
  export default c.router({
7
7
  auth: {
@@ -31,7 +31,7 @@ export default c.router({
31
31
  turnstile: turnstileSchema,
32
32
  }),
33
33
  responses: {
34
- 200: apiSuccess(accessRefreshSchema),
34
+ 200: apiSuccess(accessRefreshPendingSchema),
35
35
  400: ZodErrorSchema,
36
36
  401: z.union([
37
37
  apiError(z.literal("CREDENTIALS_INVALID"), z.literal("Invalid Credentials")),
@@ -58,79 +58,6 @@ export default c.router({
58
58
  500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
59
59
  },
60
60
  },
61
- totpSetup: {
62
- method: "POST",
63
- path: "/totp/setup",
64
- headers: authHeaderSchema,
65
- body: c.noBody(),
66
- responses: {
67
- 200: apiSuccess(z.object({
68
- secret: z.string(),
69
- otpauthUrl: z.string(),
70
- })),
71
- 400: z.union([
72
- ZodErrorSchema,
73
- apiError(z.literal("TOTP_ALREADY_SETUP"), z.string()),
74
- ]),
75
- 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
76
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
77
- },
78
- },
79
- totpSetupConfirm: {
80
- method: "POST",
81
- path: "/totp/setup/confirm",
82
- headers: authHeaderSchema,
83
- body: z.object({
84
- totpCode: totpCodeSchema,
85
- }),
86
- responses: {
87
- 200: apiSuccess(c.noBody()),
88
- 400: z.union([
89
- ZodErrorSchema,
90
- apiError(z.literal("TOTP_NOT_SETUP"), z.string()),
91
- apiError(z.literal("TOTP_INVALID"), z.string()),
92
- ]),
93
- 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
94
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
95
- },
96
- },
97
- totpVerify: {
98
- method: "POST",
99
- path: "/totp/verify",
100
- headers: authHeaderSchema,
101
- body: z.object({
102
- totpCode: totpCodeSchema,
103
- }),
104
- responses: {
105
- 200: apiSuccess(c.noBody()),
106
- 400: z.union([
107
- ZodErrorSchema,
108
- apiError(z.literal("TOTP_NOT_SETUP"), z.string()),
109
- apiError(z.literal("TOTP_NOT_REQUIRED"), z.string()),
110
- apiError(z.literal("TOTP_INVALID"), z.string()),
111
- ]),
112
- 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
113
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
114
- },
115
- },
116
- totpDisable: {
117
- method: "POST",
118
- path: "/totp/disable",
119
- headers: authHeaderSchema,
120
- body: z.object({
121
- totpCode: totpCodeSchema,
122
- }),
123
- responses: {
124
- 200: apiSuccess(c.noBody()),
125
- 400: z.union([
126
- ZodErrorSchema,
127
- apiError(z.literal("TOTP_NOT_SETUP"), z.string()),
128
- apiError(z.literal("TOTP_INVALID"), z.string()),
129
- ]),
130
- 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
131
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
132
- },
133
- },
134
61
  logout: {
135
62
  method: "POST",
136
63
  path: "/logout",
@@ -140,7 +67,7 @@ export default c.router({
140
67
  })
141
68
  .optional(),
142
69
  responses: {
143
- 200: apiSuccess(c.noBody()),
70
+ 204: apiSuccess(c.noBody()),
144
71
  },
145
72
  },
146
73
  register: {
@@ -153,7 +80,7 @@ export default c.router({
153
80
  turnstile: turnstileSchema,
154
81
  }),
155
82
  responses: {
156
- 200: apiSuccess(c.noBody()),
83
+ 204: apiSuccess(c.noBody()),
157
84
  400: ZodErrorSchema,
158
85
  401: apiError(z.literal("INVALID_TURNSTILE"), z.literal("Invalid Turnstile")),
159
86
  409: apiError(z.literal("USER_EXISTS"), z.literal("User with this email already exists")),