@darco2903/auth-api 2.1.3 → 2.1.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.
- package/dist/client.d.ts +371 -363
- package/dist/client.js +2 -1
- package/dist/consts.d.ts +2 -3
- package/dist/contract/assets.d.ts +2 -2
- package/dist/contract/assets.js +2 -2
- package/dist/contract/auth.d.ts +12 -756
- package/dist/contract/auth.js +4 -77
- package/dist/contract/index.d.ts +906 -889
- package/dist/contract/index.js +2 -0
- package/dist/contract/requests.d.ts +2 -2
- package/dist/contract/requests.js +2 -2
- package/dist/contract/totp.d.ts +763 -0
- package/dist/contract/totp.js +81 -0
- package/dist/contract/user.d.ts +4 -4
- package/dist/contract/user.js +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/otp.d.ts +2 -0
- package/dist/otp.js +7 -0
- package/dist/server.d.ts +2 -1
- package/dist/server.js +2 -1
- package/dist/types/auth.d.ts +17 -0
- package/dist/types/auth.js +4 -0
- package/dist/types/jwt.d.ts +2 -2
- package/package.json +5 -4
- package/LICENSE +0 -674
package/dist/contract/auth.js
CHANGED
|
@@ -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,
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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")),
|