@ackplus/nest-auth-contracts 1.1.29
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/README.md +25 -0
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +392 -0
- package/dist/index.d.ts +392 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @ackplus/nest-auth-contracts
|
|
2
|
+
|
|
3
|
+
Shared interfaces, types, and DTOs for `@ackplus/nest-auth` ecosystem.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
This package is used as a dependency in projects that need to interact with `nest-auth` APIs but don't need the full NestJS module (e.g., client SDKs, other microservices).
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @ackplus/nest-auth-contracts
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @ackplus/nest-auth-contracts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Importing Types
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import {
|
|
21
|
+
IEmailCredentials,
|
|
22
|
+
INestAuthUser,
|
|
23
|
+
ILoginRequest
|
|
24
|
+
} from '@ackplus/nest-auth-contracts';
|
|
25
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
NestAuthMFAMethodEnum: () => NestAuthMFAMethodEnum,
|
|
23
|
+
NestAuthOTPTypeEnum: () => NestAuthOTPTypeEnum
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/auth.ts
|
|
28
|
+
var NestAuthOTPTypeEnum = /* @__PURE__ */ ((NestAuthOTPTypeEnum2) => {
|
|
29
|
+
NestAuthOTPTypeEnum2["PASSWORD_RESET"] = "password_reset";
|
|
30
|
+
NestAuthOTPTypeEnum2["VERIFICATION"] = "verification";
|
|
31
|
+
NestAuthOTPTypeEnum2["MFA"] = "mfa";
|
|
32
|
+
return NestAuthOTPTypeEnum2;
|
|
33
|
+
})(NestAuthOTPTypeEnum || {});
|
|
34
|
+
var NestAuthMFAMethodEnum = /* @__PURE__ */ ((NestAuthMFAMethodEnum2) => {
|
|
35
|
+
NestAuthMFAMethodEnum2["EMAIL"] = "email";
|
|
36
|
+
NestAuthMFAMethodEnum2["SMS"] = "sms";
|
|
37
|
+
NestAuthMFAMethodEnum2["TOTP"] = "totp";
|
|
38
|
+
return NestAuthMFAMethodEnum2;
|
|
39
|
+
})(NestAuthMFAMethodEnum || {});
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
NestAuthMFAMethodEnum,
|
|
43
|
+
NestAuthOTPTypeEnum
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/auth.ts"],"sourcesContent":["/**\n * @libs/auth-s - Shared authentication s\n */\n\n// Auth s (from auth.ts)\nexport {\n NestAuthMFAMethodEnum,\n NestAuthOTPTypeEnum,\n IEmailCredentials,\n IPhoneCredentials,\n ISocialCredentials,\n ILoginCredentials,\n ILoginRequest,\n ISignupRequest,\n IRefreshRequest,\n ITokenPair,\n IAuthResponse,\n IAuthUser,\n IAuthSession,\n IMessageResponse,\n IAuthCookieResponse,\n IAuthSuccessResponse,\n IUserResponse,\n ITokensResponse,\n // Entities\n INestAuthIdentity,\n INestAuthSession,\n INestAuthAccessKey,\n INestAuthOTP,\n} from './auth';\n\n// MFA (from mfa.ts)\nexport {\n IVerify2faRequest,\n IVerify2faResponse,\n ISendMfaCodeRequest,\n IToggleMfaRequest,\n IVerifyTotpSetupRequest,\n IMfaDevice,\n IMfaStatusResponse,\n IMfaCodeResponse,\n ITotpSetupResponse,\n // Entities\n INestAuthMFASecret,\n INestAuthTrustedDevice,\n} from './mfa';\n\n// Password\nexport {\n IForgotPasswordRequest,\n IResetPasswordRequest,\n IResetPasswordWithTokenRequest,\n IChangePasswordRequest,\n IVerifyForgotPasswordOtpRequest,\n IVerifyOtpResponse,\n} from './password';\n\n// Verification\nexport {\n IVerifyEmailRequest,\n IResendVerificationRequest,\n ISendEmailVerificationRequest,\n ISessionVerifyResponse,\n} from './verification';\n\n// Admin\nexport {\n IInitializeAdminRequest,\n IInitializeAdminResponse,\n IAdminUser,\n} from './admin';\n\n// Config\nexport {\n IEmailAuthConfig,\n IPhoneAuthConfig,\n IProfileFieldOption,\n IProfileField,\n IRegistrationConfig,\n IMfaConfig,\n ITenantOption,\n ITenantsConfig,\n ISsoProviderConfig,\n ISsoConfig,\n IUiConfig,\n IClientConfigResponse,\n} from './config';\n\n// User & Role (from user.ts)\nexport {\n INestAuthUser,\n INestAuthRole,\n INestAuthPermission,\n} from './user';\n\n// Tenant (from tenant.ts)\nexport {\n INestAuthTenant,\n} from './tenant';\n\n","/**\n * Auth Types\n * Contains: Login/Signup/Token types + Auth Entities (Session, Identity, AccessKey, OTP)\n */\n\n// OTP Type Enum\nexport enum NestAuthOTPTypeEnum {\n PASSWORD_RESET = 'password_reset',\n VERIFICATION = 'verification',\n MFA = 'mfa',\n}\n\n// MFA Method Enum (Needed for AuthResponse and others)\nexport enum NestAuthMFAMethodEnum {\n EMAIL = 'email',\n SMS = 'sms',\n TOTP = 'totp',\n}\n\n// --- Entity Interfaces ---\n\nexport interface INestAuthIdentity {\n id: string;\n provider: string;\n providerId: string;\n metadata?: Record<string, any>;\n userId: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface INestAuthSession {\n id: string;\n userId: string;\n data?: any;\n refreshToken?: string;\n expiresAt?: Date;\n userAgent?: string;\n deviceName?: string;\n ipAddress?: string;\n lastActive?: Date;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface INestAuthAccessKey {\n id: string;\n name: string;\n publicKey: string;\n privateKey: string;\n description?: string;\n isActive: boolean;\n expiresAt?: Date;\n lastUsedAt?: Date;\n userId: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface INestAuthOTP {\n id: string;\n userId: string;\n code: string;\n type: NestAuthOTPTypeEnum;\n expiresAt: Date;\n used: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\n// --- Request/Response Interfaces ---\n\nexport interface IEmailCredentials {\n email: string;\n password: string;\n}\n\nexport interface IPhoneCredentials {\n phone: string;\n password: string;\n}\n\nexport interface ISocialCredentials {\n token: string;\n}\n\nexport type ILoginCredentials = IEmailCredentials | IPhoneCredentials | ISocialCredentials | Record<string, any>;\n\nexport interface ILoginRequest {\n providerName?: 'email' | 'phone' | 'google' | 'facebook' | 'apple' | 'github' | string;\n credentials: ILoginCredentials;\n tenantId?: string;\n createUserIfNotExists?: boolean;\n}\n\nexport interface ISignupRequest {\n email?: string;\n phone?: string;\n password: string;\n tenantId?: string;\n [key: string]: any;\n}\n\nexport interface IRefreshRequest {\n refreshToken?: string;\n}\n\nexport interface ITokenPair {\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface IAuthUser {\n id: string;\n email?: string;\n phone?: string;\n isVerified?: boolean;\n isMfaEnabled?: boolean;\n roles?: string[];\n permissions?: string[];\n metadata?: Record<string, any>;\n tenantId?: string;\n}\n\nexport interface IAuthResponse extends ITokenPair {\n message?: string;\n isRequiresMfa?: boolean;\n mfaMethods?: NestAuthMFAMethodEnum[];\n defaultMfaMethod?: NestAuthMFAMethodEnum;\n user?: IAuthUser;\n}\n\nexport interface IAuthSession {\n id: string;\n userId: string;\n expiresAt: string;\n createdAt: string;\n}\n\nexport interface IMessageResponse {\n message: string;\n}\n\nexport interface IAuthCookieResponse {\n message: string;\n isRequiresMfa?: boolean;\n}\n\nexport interface IAuthSuccessResponse {\n message: string;\n isRequiresMfa?: boolean;\n}\n\nexport interface IUserResponse {\n id: string;\n email?: string;\n phone?: string;\n isVerified?: boolean;\n metadata?: Record<string, any>;\n}\n\nexport interface ITokensResponse {\n accessToken: string;\n refreshToken: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAK,sBAAL,kBAAKA,yBAAL;AACH,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,kBAAe;AACf,EAAAA,qBAAA,SAAM;AAHE,SAAAA;AAAA,GAAA;AAOL,IAAK,wBAAL,kBAAKC,2BAAL;AACH,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AAHC,SAAAA;AAAA,GAAA;","names":["NestAuthOTPTypeEnum","NestAuthMFAMethodEnum"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
declare enum NestAuthOTPTypeEnum {
|
|
2
|
+
PASSWORD_RESET = "password_reset",
|
|
3
|
+
VERIFICATION = "verification",
|
|
4
|
+
MFA = "mfa"
|
|
5
|
+
}
|
|
6
|
+
declare enum NestAuthMFAMethodEnum {
|
|
7
|
+
EMAIL = "email",
|
|
8
|
+
SMS = "sms",
|
|
9
|
+
TOTP = "totp"
|
|
10
|
+
}
|
|
11
|
+
interface INestAuthIdentity {
|
|
12
|
+
id: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
providerId: string;
|
|
15
|
+
metadata?: Record<string, any>;
|
|
16
|
+
userId: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
20
|
+
interface INestAuthSession {
|
|
21
|
+
id: string;
|
|
22
|
+
userId: string;
|
|
23
|
+
data?: any;
|
|
24
|
+
refreshToken?: string;
|
|
25
|
+
expiresAt?: Date;
|
|
26
|
+
userAgent?: string;
|
|
27
|
+
deviceName?: string;
|
|
28
|
+
ipAddress?: string;
|
|
29
|
+
lastActive?: Date;
|
|
30
|
+
createdAt?: Date;
|
|
31
|
+
updatedAt?: Date;
|
|
32
|
+
}
|
|
33
|
+
interface INestAuthAccessKey {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
publicKey: string;
|
|
37
|
+
privateKey: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
isActive: boolean;
|
|
40
|
+
expiresAt?: Date;
|
|
41
|
+
lastUsedAt?: Date;
|
|
42
|
+
userId: string;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}
|
|
46
|
+
interface INestAuthOTP {
|
|
47
|
+
id: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
code: string;
|
|
50
|
+
type: NestAuthOTPTypeEnum;
|
|
51
|
+
expiresAt: Date;
|
|
52
|
+
used: boolean;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
}
|
|
56
|
+
interface IEmailCredentials {
|
|
57
|
+
email: string;
|
|
58
|
+
password: string;
|
|
59
|
+
}
|
|
60
|
+
interface IPhoneCredentials {
|
|
61
|
+
phone: string;
|
|
62
|
+
password: string;
|
|
63
|
+
}
|
|
64
|
+
interface ISocialCredentials {
|
|
65
|
+
token: string;
|
|
66
|
+
}
|
|
67
|
+
type ILoginCredentials = IEmailCredentials | IPhoneCredentials | ISocialCredentials | Record<string, any>;
|
|
68
|
+
interface ILoginRequest {
|
|
69
|
+
providerName?: 'email' | 'phone' | 'google' | 'facebook' | 'apple' | 'github' | string;
|
|
70
|
+
credentials: ILoginCredentials;
|
|
71
|
+
tenantId?: string;
|
|
72
|
+
createUserIfNotExists?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface ISignupRequest {
|
|
75
|
+
email?: string;
|
|
76
|
+
phone?: string;
|
|
77
|
+
password: string;
|
|
78
|
+
tenantId?: string;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
81
|
+
interface IRefreshRequest {
|
|
82
|
+
refreshToken?: string;
|
|
83
|
+
}
|
|
84
|
+
interface ITokenPair {
|
|
85
|
+
accessToken: string;
|
|
86
|
+
refreshToken: string;
|
|
87
|
+
}
|
|
88
|
+
interface IAuthUser {
|
|
89
|
+
id: string;
|
|
90
|
+
email?: string;
|
|
91
|
+
phone?: string;
|
|
92
|
+
isVerified?: boolean;
|
|
93
|
+
isMfaEnabled?: boolean;
|
|
94
|
+
roles?: string[];
|
|
95
|
+
permissions?: string[];
|
|
96
|
+
metadata?: Record<string, any>;
|
|
97
|
+
tenantId?: string;
|
|
98
|
+
}
|
|
99
|
+
interface IAuthResponse extends ITokenPair {
|
|
100
|
+
message?: string;
|
|
101
|
+
isRequiresMfa?: boolean;
|
|
102
|
+
mfaMethods?: NestAuthMFAMethodEnum[];
|
|
103
|
+
defaultMfaMethod?: NestAuthMFAMethodEnum;
|
|
104
|
+
user?: IAuthUser;
|
|
105
|
+
}
|
|
106
|
+
interface IAuthSession {
|
|
107
|
+
id: string;
|
|
108
|
+
userId: string;
|
|
109
|
+
expiresAt: string;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
}
|
|
112
|
+
interface IMessageResponse {
|
|
113
|
+
message: string;
|
|
114
|
+
}
|
|
115
|
+
interface IAuthCookieResponse {
|
|
116
|
+
message: string;
|
|
117
|
+
isRequiresMfa?: boolean;
|
|
118
|
+
}
|
|
119
|
+
interface IAuthSuccessResponse {
|
|
120
|
+
message: string;
|
|
121
|
+
isRequiresMfa?: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface IUserResponse {
|
|
124
|
+
id: string;
|
|
125
|
+
email?: string;
|
|
126
|
+
phone?: string;
|
|
127
|
+
isVerified?: boolean;
|
|
128
|
+
metadata?: Record<string, any>;
|
|
129
|
+
}
|
|
130
|
+
interface ITokensResponse {
|
|
131
|
+
accessToken: string;
|
|
132
|
+
refreshToken: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface INestAuthMFASecret {
|
|
136
|
+
id: string;
|
|
137
|
+
userId: string;
|
|
138
|
+
secret: string;
|
|
139
|
+
verified: boolean;
|
|
140
|
+
deviceName?: string;
|
|
141
|
+
lastUsedAt?: Date;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
}
|
|
145
|
+
interface INestAuthTrustedDevice {
|
|
146
|
+
id: string;
|
|
147
|
+
userId: string;
|
|
148
|
+
token: string;
|
|
149
|
+
userAgent?: string;
|
|
150
|
+
ipAddress?: string;
|
|
151
|
+
expiresAt: Date;
|
|
152
|
+
lastUsedAt?: Date;
|
|
153
|
+
createdAt: Date;
|
|
154
|
+
}
|
|
155
|
+
interface IVerify2faRequest {
|
|
156
|
+
otp: string;
|
|
157
|
+
method?: NestAuthMFAMethodEnum;
|
|
158
|
+
trustDevice?: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface IVerify2faResponse {
|
|
161
|
+
accessToken: string;
|
|
162
|
+
refreshToken: string;
|
|
163
|
+
message?: string;
|
|
164
|
+
trustToken?: string;
|
|
165
|
+
}
|
|
166
|
+
interface ISendMfaCodeRequest {
|
|
167
|
+
method: NestAuthMFAMethodEnum;
|
|
168
|
+
}
|
|
169
|
+
interface IToggleMfaRequest {
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface IVerifyTotpSetupRequest {
|
|
173
|
+
otp: string;
|
|
174
|
+
secret: string;
|
|
175
|
+
}
|
|
176
|
+
interface IMfaDevice {
|
|
177
|
+
id: string;
|
|
178
|
+
deviceName: string;
|
|
179
|
+
method: NestAuthMFAMethodEnum;
|
|
180
|
+
lastUsedAt?: Date | string | null;
|
|
181
|
+
verified: boolean;
|
|
182
|
+
createdAt?: Date | string | null;
|
|
183
|
+
}
|
|
184
|
+
interface IMfaStatusResponse {
|
|
185
|
+
isEnabled: boolean;
|
|
186
|
+
verifiedMethods: NestAuthMFAMethodEnum[];
|
|
187
|
+
configuredMethods: NestAuthMFAMethodEnum[];
|
|
188
|
+
allowUserToggle: boolean;
|
|
189
|
+
allowMethodSelection: boolean;
|
|
190
|
+
totpDevices: IMfaDevice[];
|
|
191
|
+
hasRecoveryCode: boolean;
|
|
192
|
+
}
|
|
193
|
+
interface IMfaCodeResponse {
|
|
194
|
+
code: string;
|
|
195
|
+
expiresAt: Date | string;
|
|
196
|
+
used: boolean;
|
|
197
|
+
warning?: string;
|
|
198
|
+
}
|
|
199
|
+
interface ITotpSetupResponse {
|
|
200
|
+
secret: string;
|
|
201
|
+
qrCode: string;
|
|
202
|
+
otpAuthUrl: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface IForgotPasswordRequest {
|
|
206
|
+
email?: string;
|
|
207
|
+
phone?: string;
|
|
208
|
+
}
|
|
209
|
+
interface IResetPasswordRequest {
|
|
210
|
+
otp: string;
|
|
211
|
+
newPassword: string;
|
|
212
|
+
}
|
|
213
|
+
interface IResetPasswordWithTokenRequest {
|
|
214
|
+
token: string;
|
|
215
|
+
newPassword: string;
|
|
216
|
+
}
|
|
217
|
+
interface IChangePasswordRequest {
|
|
218
|
+
currentPassword: string;
|
|
219
|
+
newPassword: string;
|
|
220
|
+
}
|
|
221
|
+
interface IVerifyForgotPasswordOtpRequest {
|
|
222
|
+
email?: string;
|
|
223
|
+
phone?: string;
|
|
224
|
+
otp: string;
|
|
225
|
+
tenantId?: string;
|
|
226
|
+
}
|
|
227
|
+
interface IVerifyOtpResponse {
|
|
228
|
+
message: string;
|
|
229
|
+
resetToken?: string;
|
|
230
|
+
token?: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
interface IVerifyEmailRequest {
|
|
234
|
+
otp: string;
|
|
235
|
+
}
|
|
236
|
+
interface IResendVerificationRequest {
|
|
237
|
+
email?: string;
|
|
238
|
+
}
|
|
239
|
+
interface ISendEmailVerificationRequest {
|
|
240
|
+
tenantId?: string;
|
|
241
|
+
}
|
|
242
|
+
interface ISessionVerifyResponse {
|
|
243
|
+
valid: boolean;
|
|
244
|
+
userId?: string;
|
|
245
|
+
expiresAt?: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface IInitializeAdminRequest {
|
|
249
|
+
email: string;
|
|
250
|
+
password: string;
|
|
251
|
+
secretKey?: string;
|
|
252
|
+
tenantId?: string;
|
|
253
|
+
metadata?: Record<string, any>;
|
|
254
|
+
}
|
|
255
|
+
interface IInitializeAdminResponse {
|
|
256
|
+
message: string;
|
|
257
|
+
user: IUserResponse;
|
|
258
|
+
role: string;
|
|
259
|
+
}
|
|
260
|
+
interface IAdminUser {
|
|
261
|
+
id: string;
|
|
262
|
+
email: string;
|
|
263
|
+
name?: string;
|
|
264
|
+
passwordHash: string;
|
|
265
|
+
metadata?: Record<string, any>;
|
|
266
|
+
lastLoginAt?: Date;
|
|
267
|
+
createdAt: Date;
|
|
268
|
+
updatedAt: Date;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface IEmailAuthConfig {
|
|
272
|
+
enabled: boolean;
|
|
273
|
+
}
|
|
274
|
+
interface IPhoneAuthConfig {
|
|
275
|
+
enabled: boolean;
|
|
276
|
+
}
|
|
277
|
+
interface IProfileFieldOption {
|
|
278
|
+
label: string;
|
|
279
|
+
value: string;
|
|
280
|
+
}
|
|
281
|
+
interface IProfileField {
|
|
282
|
+
id: string;
|
|
283
|
+
label: string;
|
|
284
|
+
required?: boolean;
|
|
285
|
+
type?: 'text' | 'email' | 'phone' | 'select' | 'checkbox' | 'password';
|
|
286
|
+
placeholder?: string;
|
|
287
|
+
options?: IProfileFieldOption[];
|
|
288
|
+
}
|
|
289
|
+
interface IRegistrationConfig {
|
|
290
|
+
enabled: boolean;
|
|
291
|
+
requireInvitation?: boolean;
|
|
292
|
+
collectProfileFields?: IProfileField[];
|
|
293
|
+
}
|
|
294
|
+
interface IMfaConfig {
|
|
295
|
+
enabled: boolean;
|
|
296
|
+
methods?: NestAuthMFAMethodEnum[];
|
|
297
|
+
allowUserToggle?: boolean;
|
|
298
|
+
allowMethodSelection?: boolean;
|
|
299
|
+
}
|
|
300
|
+
interface ITenantOption {
|
|
301
|
+
id: string;
|
|
302
|
+
name: string;
|
|
303
|
+
slug: string;
|
|
304
|
+
isActive: boolean;
|
|
305
|
+
metadata?: Record<string, any>;
|
|
306
|
+
}
|
|
307
|
+
interface ITenantsConfig {
|
|
308
|
+
mode: 'single' | 'multi';
|
|
309
|
+
defaultTenantId: string | null;
|
|
310
|
+
options?: ITenantOption[];
|
|
311
|
+
}
|
|
312
|
+
interface ISsoProviderConfig {
|
|
313
|
+
id: string;
|
|
314
|
+
name: string;
|
|
315
|
+
logoUrl?: string;
|
|
316
|
+
authorizationUrl?: string;
|
|
317
|
+
clientId?: string;
|
|
318
|
+
hint?: string;
|
|
319
|
+
}
|
|
320
|
+
interface ISsoConfig {
|
|
321
|
+
enabled: boolean;
|
|
322
|
+
providers?: ISsoProviderConfig[];
|
|
323
|
+
}
|
|
324
|
+
interface IUiConfig {
|
|
325
|
+
brandName?: string;
|
|
326
|
+
brandColor?: string;
|
|
327
|
+
logoUrl?: string;
|
|
328
|
+
backgroundImageUrl?: string;
|
|
329
|
+
}
|
|
330
|
+
interface IClientConfigResponse {
|
|
331
|
+
emailAuth: IEmailAuthConfig;
|
|
332
|
+
phoneAuth: IPhoneAuthConfig;
|
|
333
|
+
registration: IRegistrationConfig;
|
|
334
|
+
mfa: IMfaConfig;
|
|
335
|
+
tenants: ITenantsConfig;
|
|
336
|
+
sso: ISsoConfig;
|
|
337
|
+
ui?: IUiConfig;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface INestAuthUser {
|
|
341
|
+
id: string;
|
|
342
|
+
email?: string;
|
|
343
|
+
emailVerifiedAt?: Date;
|
|
344
|
+
phone?: string;
|
|
345
|
+
phoneVerifiedAt?: Date;
|
|
346
|
+
passwordHash?: string;
|
|
347
|
+
isVerified: boolean;
|
|
348
|
+
isActive: boolean;
|
|
349
|
+
metadata?: Record<string, any>;
|
|
350
|
+
tenantId?: string;
|
|
351
|
+
isMfaEnabled: boolean;
|
|
352
|
+
mfaRecoveryCode?: string;
|
|
353
|
+
emailTenant?: string;
|
|
354
|
+
phoneTenant?: string;
|
|
355
|
+
createdAt: Date;
|
|
356
|
+
updatedAt: Date;
|
|
357
|
+
}
|
|
358
|
+
interface INestAuthRole {
|
|
359
|
+
id: string;
|
|
360
|
+
name: string;
|
|
361
|
+
guard: string;
|
|
362
|
+
tenantId?: string;
|
|
363
|
+
isSystem: boolean;
|
|
364
|
+
isActive: boolean;
|
|
365
|
+
permissions: string[];
|
|
366
|
+
createdAt: Date;
|
|
367
|
+
updatedAt: Date;
|
|
368
|
+
}
|
|
369
|
+
interface INestAuthPermission {
|
|
370
|
+
id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
guard: string;
|
|
373
|
+
description?: string;
|
|
374
|
+
category?: string;
|
|
375
|
+
metadata?: Record<string, any>;
|
|
376
|
+
createdAt: Date;
|
|
377
|
+
updatedAt: Date;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
interface INestAuthTenant {
|
|
381
|
+
id: string;
|
|
382
|
+
name: string;
|
|
383
|
+
slug: string;
|
|
384
|
+
domain?: string;
|
|
385
|
+
description?: string;
|
|
386
|
+
metadata?: Record<string, any>;
|
|
387
|
+
isActive: boolean;
|
|
388
|
+
createdAt: Date;
|
|
389
|
+
updatedAt: Date;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export { type IAdminUser, type IAuthCookieResponse, type IAuthResponse, type IAuthSession, type IAuthSuccessResponse, type IAuthUser, type IChangePasswordRequest, type IClientConfigResponse, type IEmailAuthConfig, type IEmailCredentials, type IForgotPasswordRequest, type IInitializeAdminRequest, type IInitializeAdminResponse, type ILoginCredentials, type ILoginRequest, type IMessageResponse, type IMfaCodeResponse, type IMfaConfig, type IMfaDevice, type IMfaStatusResponse, type INestAuthAccessKey, type INestAuthIdentity, type INestAuthMFASecret, type INestAuthOTP, type INestAuthPermission, type INestAuthRole, type INestAuthSession, type INestAuthTenant, type INestAuthTrustedDevice, type INestAuthUser, type IPhoneAuthConfig, type IPhoneCredentials, type IProfileField, type IProfileFieldOption, type IRefreshRequest, type IRegistrationConfig, type IResendVerificationRequest, type IResetPasswordRequest, type IResetPasswordWithTokenRequest, type ISendEmailVerificationRequest, type ISendMfaCodeRequest, type ISessionVerifyResponse, type ISignupRequest, type ISocialCredentials, type ISsoConfig, type ISsoProviderConfig, type ITenantOption, type ITenantsConfig, type IToggleMfaRequest, type ITokenPair, type ITokensResponse, type ITotpSetupResponse, type IUiConfig, type IUserResponse, type IVerify2faRequest, type IVerify2faResponse, type IVerifyEmailRequest, type IVerifyForgotPasswordOtpRequest, type IVerifyOtpResponse, type IVerifyTotpSetupRequest, NestAuthMFAMethodEnum, NestAuthOTPTypeEnum };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
declare enum NestAuthOTPTypeEnum {
|
|
2
|
+
PASSWORD_RESET = "password_reset",
|
|
3
|
+
VERIFICATION = "verification",
|
|
4
|
+
MFA = "mfa"
|
|
5
|
+
}
|
|
6
|
+
declare enum NestAuthMFAMethodEnum {
|
|
7
|
+
EMAIL = "email",
|
|
8
|
+
SMS = "sms",
|
|
9
|
+
TOTP = "totp"
|
|
10
|
+
}
|
|
11
|
+
interface INestAuthIdentity {
|
|
12
|
+
id: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
providerId: string;
|
|
15
|
+
metadata?: Record<string, any>;
|
|
16
|
+
userId: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
20
|
+
interface INestAuthSession {
|
|
21
|
+
id: string;
|
|
22
|
+
userId: string;
|
|
23
|
+
data?: any;
|
|
24
|
+
refreshToken?: string;
|
|
25
|
+
expiresAt?: Date;
|
|
26
|
+
userAgent?: string;
|
|
27
|
+
deviceName?: string;
|
|
28
|
+
ipAddress?: string;
|
|
29
|
+
lastActive?: Date;
|
|
30
|
+
createdAt?: Date;
|
|
31
|
+
updatedAt?: Date;
|
|
32
|
+
}
|
|
33
|
+
interface INestAuthAccessKey {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
publicKey: string;
|
|
37
|
+
privateKey: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
isActive: boolean;
|
|
40
|
+
expiresAt?: Date;
|
|
41
|
+
lastUsedAt?: Date;
|
|
42
|
+
userId: string;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}
|
|
46
|
+
interface INestAuthOTP {
|
|
47
|
+
id: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
code: string;
|
|
50
|
+
type: NestAuthOTPTypeEnum;
|
|
51
|
+
expiresAt: Date;
|
|
52
|
+
used: boolean;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
}
|
|
56
|
+
interface IEmailCredentials {
|
|
57
|
+
email: string;
|
|
58
|
+
password: string;
|
|
59
|
+
}
|
|
60
|
+
interface IPhoneCredentials {
|
|
61
|
+
phone: string;
|
|
62
|
+
password: string;
|
|
63
|
+
}
|
|
64
|
+
interface ISocialCredentials {
|
|
65
|
+
token: string;
|
|
66
|
+
}
|
|
67
|
+
type ILoginCredentials = IEmailCredentials | IPhoneCredentials | ISocialCredentials | Record<string, any>;
|
|
68
|
+
interface ILoginRequest {
|
|
69
|
+
providerName?: 'email' | 'phone' | 'google' | 'facebook' | 'apple' | 'github' | string;
|
|
70
|
+
credentials: ILoginCredentials;
|
|
71
|
+
tenantId?: string;
|
|
72
|
+
createUserIfNotExists?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface ISignupRequest {
|
|
75
|
+
email?: string;
|
|
76
|
+
phone?: string;
|
|
77
|
+
password: string;
|
|
78
|
+
tenantId?: string;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
81
|
+
interface IRefreshRequest {
|
|
82
|
+
refreshToken?: string;
|
|
83
|
+
}
|
|
84
|
+
interface ITokenPair {
|
|
85
|
+
accessToken: string;
|
|
86
|
+
refreshToken: string;
|
|
87
|
+
}
|
|
88
|
+
interface IAuthUser {
|
|
89
|
+
id: string;
|
|
90
|
+
email?: string;
|
|
91
|
+
phone?: string;
|
|
92
|
+
isVerified?: boolean;
|
|
93
|
+
isMfaEnabled?: boolean;
|
|
94
|
+
roles?: string[];
|
|
95
|
+
permissions?: string[];
|
|
96
|
+
metadata?: Record<string, any>;
|
|
97
|
+
tenantId?: string;
|
|
98
|
+
}
|
|
99
|
+
interface IAuthResponse extends ITokenPair {
|
|
100
|
+
message?: string;
|
|
101
|
+
isRequiresMfa?: boolean;
|
|
102
|
+
mfaMethods?: NestAuthMFAMethodEnum[];
|
|
103
|
+
defaultMfaMethod?: NestAuthMFAMethodEnum;
|
|
104
|
+
user?: IAuthUser;
|
|
105
|
+
}
|
|
106
|
+
interface IAuthSession {
|
|
107
|
+
id: string;
|
|
108
|
+
userId: string;
|
|
109
|
+
expiresAt: string;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
}
|
|
112
|
+
interface IMessageResponse {
|
|
113
|
+
message: string;
|
|
114
|
+
}
|
|
115
|
+
interface IAuthCookieResponse {
|
|
116
|
+
message: string;
|
|
117
|
+
isRequiresMfa?: boolean;
|
|
118
|
+
}
|
|
119
|
+
interface IAuthSuccessResponse {
|
|
120
|
+
message: string;
|
|
121
|
+
isRequiresMfa?: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface IUserResponse {
|
|
124
|
+
id: string;
|
|
125
|
+
email?: string;
|
|
126
|
+
phone?: string;
|
|
127
|
+
isVerified?: boolean;
|
|
128
|
+
metadata?: Record<string, any>;
|
|
129
|
+
}
|
|
130
|
+
interface ITokensResponse {
|
|
131
|
+
accessToken: string;
|
|
132
|
+
refreshToken: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface INestAuthMFASecret {
|
|
136
|
+
id: string;
|
|
137
|
+
userId: string;
|
|
138
|
+
secret: string;
|
|
139
|
+
verified: boolean;
|
|
140
|
+
deviceName?: string;
|
|
141
|
+
lastUsedAt?: Date;
|
|
142
|
+
createdAt: Date;
|
|
143
|
+
updatedAt: Date;
|
|
144
|
+
}
|
|
145
|
+
interface INestAuthTrustedDevice {
|
|
146
|
+
id: string;
|
|
147
|
+
userId: string;
|
|
148
|
+
token: string;
|
|
149
|
+
userAgent?: string;
|
|
150
|
+
ipAddress?: string;
|
|
151
|
+
expiresAt: Date;
|
|
152
|
+
lastUsedAt?: Date;
|
|
153
|
+
createdAt: Date;
|
|
154
|
+
}
|
|
155
|
+
interface IVerify2faRequest {
|
|
156
|
+
otp: string;
|
|
157
|
+
method?: NestAuthMFAMethodEnum;
|
|
158
|
+
trustDevice?: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface IVerify2faResponse {
|
|
161
|
+
accessToken: string;
|
|
162
|
+
refreshToken: string;
|
|
163
|
+
message?: string;
|
|
164
|
+
trustToken?: string;
|
|
165
|
+
}
|
|
166
|
+
interface ISendMfaCodeRequest {
|
|
167
|
+
method: NestAuthMFAMethodEnum;
|
|
168
|
+
}
|
|
169
|
+
interface IToggleMfaRequest {
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface IVerifyTotpSetupRequest {
|
|
173
|
+
otp: string;
|
|
174
|
+
secret: string;
|
|
175
|
+
}
|
|
176
|
+
interface IMfaDevice {
|
|
177
|
+
id: string;
|
|
178
|
+
deviceName: string;
|
|
179
|
+
method: NestAuthMFAMethodEnum;
|
|
180
|
+
lastUsedAt?: Date | string | null;
|
|
181
|
+
verified: boolean;
|
|
182
|
+
createdAt?: Date | string | null;
|
|
183
|
+
}
|
|
184
|
+
interface IMfaStatusResponse {
|
|
185
|
+
isEnabled: boolean;
|
|
186
|
+
verifiedMethods: NestAuthMFAMethodEnum[];
|
|
187
|
+
configuredMethods: NestAuthMFAMethodEnum[];
|
|
188
|
+
allowUserToggle: boolean;
|
|
189
|
+
allowMethodSelection: boolean;
|
|
190
|
+
totpDevices: IMfaDevice[];
|
|
191
|
+
hasRecoveryCode: boolean;
|
|
192
|
+
}
|
|
193
|
+
interface IMfaCodeResponse {
|
|
194
|
+
code: string;
|
|
195
|
+
expiresAt: Date | string;
|
|
196
|
+
used: boolean;
|
|
197
|
+
warning?: string;
|
|
198
|
+
}
|
|
199
|
+
interface ITotpSetupResponse {
|
|
200
|
+
secret: string;
|
|
201
|
+
qrCode: string;
|
|
202
|
+
otpAuthUrl: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface IForgotPasswordRequest {
|
|
206
|
+
email?: string;
|
|
207
|
+
phone?: string;
|
|
208
|
+
}
|
|
209
|
+
interface IResetPasswordRequest {
|
|
210
|
+
otp: string;
|
|
211
|
+
newPassword: string;
|
|
212
|
+
}
|
|
213
|
+
interface IResetPasswordWithTokenRequest {
|
|
214
|
+
token: string;
|
|
215
|
+
newPassword: string;
|
|
216
|
+
}
|
|
217
|
+
interface IChangePasswordRequest {
|
|
218
|
+
currentPassword: string;
|
|
219
|
+
newPassword: string;
|
|
220
|
+
}
|
|
221
|
+
interface IVerifyForgotPasswordOtpRequest {
|
|
222
|
+
email?: string;
|
|
223
|
+
phone?: string;
|
|
224
|
+
otp: string;
|
|
225
|
+
tenantId?: string;
|
|
226
|
+
}
|
|
227
|
+
interface IVerifyOtpResponse {
|
|
228
|
+
message: string;
|
|
229
|
+
resetToken?: string;
|
|
230
|
+
token?: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
interface IVerifyEmailRequest {
|
|
234
|
+
otp: string;
|
|
235
|
+
}
|
|
236
|
+
interface IResendVerificationRequest {
|
|
237
|
+
email?: string;
|
|
238
|
+
}
|
|
239
|
+
interface ISendEmailVerificationRequest {
|
|
240
|
+
tenantId?: string;
|
|
241
|
+
}
|
|
242
|
+
interface ISessionVerifyResponse {
|
|
243
|
+
valid: boolean;
|
|
244
|
+
userId?: string;
|
|
245
|
+
expiresAt?: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface IInitializeAdminRequest {
|
|
249
|
+
email: string;
|
|
250
|
+
password: string;
|
|
251
|
+
secretKey?: string;
|
|
252
|
+
tenantId?: string;
|
|
253
|
+
metadata?: Record<string, any>;
|
|
254
|
+
}
|
|
255
|
+
interface IInitializeAdminResponse {
|
|
256
|
+
message: string;
|
|
257
|
+
user: IUserResponse;
|
|
258
|
+
role: string;
|
|
259
|
+
}
|
|
260
|
+
interface IAdminUser {
|
|
261
|
+
id: string;
|
|
262
|
+
email: string;
|
|
263
|
+
name?: string;
|
|
264
|
+
passwordHash: string;
|
|
265
|
+
metadata?: Record<string, any>;
|
|
266
|
+
lastLoginAt?: Date;
|
|
267
|
+
createdAt: Date;
|
|
268
|
+
updatedAt: Date;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface IEmailAuthConfig {
|
|
272
|
+
enabled: boolean;
|
|
273
|
+
}
|
|
274
|
+
interface IPhoneAuthConfig {
|
|
275
|
+
enabled: boolean;
|
|
276
|
+
}
|
|
277
|
+
interface IProfileFieldOption {
|
|
278
|
+
label: string;
|
|
279
|
+
value: string;
|
|
280
|
+
}
|
|
281
|
+
interface IProfileField {
|
|
282
|
+
id: string;
|
|
283
|
+
label: string;
|
|
284
|
+
required?: boolean;
|
|
285
|
+
type?: 'text' | 'email' | 'phone' | 'select' | 'checkbox' | 'password';
|
|
286
|
+
placeholder?: string;
|
|
287
|
+
options?: IProfileFieldOption[];
|
|
288
|
+
}
|
|
289
|
+
interface IRegistrationConfig {
|
|
290
|
+
enabled: boolean;
|
|
291
|
+
requireInvitation?: boolean;
|
|
292
|
+
collectProfileFields?: IProfileField[];
|
|
293
|
+
}
|
|
294
|
+
interface IMfaConfig {
|
|
295
|
+
enabled: boolean;
|
|
296
|
+
methods?: NestAuthMFAMethodEnum[];
|
|
297
|
+
allowUserToggle?: boolean;
|
|
298
|
+
allowMethodSelection?: boolean;
|
|
299
|
+
}
|
|
300
|
+
interface ITenantOption {
|
|
301
|
+
id: string;
|
|
302
|
+
name: string;
|
|
303
|
+
slug: string;
|
|
304
|
+
isActive: boolean;
|
|
305
|
+
metadata?: Record<string, any>;
|
|
306
|
+
}
|
|
307
|
+
interface ITenantsConfig {
|
|
308
|
+
mode: 'single' | 'multi';
|
|
309
|
+
defaultTenantId: string | null;
|
|
310
|
+
options?: ITenantOption[];
|
|
311
|
+
}
|
|
312
|
+
interface ISsoProviderConfig {
|
|
313
|
+
id: string;
|
|
314
|
+
name: string;
|
|
315
|
+
logoUrl?: string;
|
|
316
|
+
authorizationUrl?: string;
|
|
317
|
+
clientId?: string;
|
|
318
|
+
hint?: string;
|
|
319
|
+
}
|
|
320
|
+
interface ISsoConfig {
|
|
321
|
+
enabled: boolean;
|
|
322
|
+
providers?: ISsoProviderConfig[];
|
|
323
|
+
}
|
|
324
|
+
interface IUiConfig {
|
|
325
|
+
brandName?: string;
|
|
326
|
+
brandColor?: string;
|
|
327
|
+
logoUrl?: string;
|
|
328
|
+
backgroundImageUrl?: string;
|
|
329
|
+
}
|
|
330
|
+
interface IClientConfigResponse {
|
|
331
|
+
emailAuth: IEmailAuthConfig;
|
|
332
|
+
phoneAuth: IPhoneAuthConfig;
|
|
333
|
+
registration: IRegistrationConfig;
|
|
334
|
+
mfa: IMfaConfig;
|
|
335
|
+
tenants: ITenantsConfig;
|
|
336
|
+
sso: ISsoConfig;
|
|
337
|
+
ui?: IUiConfig;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface INestAuthUser {
|
|
341
|
+
id: string;
|
|
342
|
+
email?: string;
|
|
343
|
+
emailVerifiedAt?: Date;
|
|
344
|
+
phone?: string;
|
|
345
|
+
phoneVerifiedAt?: Date;
|
|
346
|
+
passwordHash?: string;
|
|
347
|
+
isVerified: boolean;
|
|
348
|
+
isActive: boolean;
|
|
349
|
+
metadata?: Record<string, any>;
|
|
350
|
+
tenantId?: string;
|
|
351
|
+
isMfaEnabled: boolean;
|
|
352
|
+
mfaRecoveryCode?: string;
|
|
353
|
+
emailTenant?: string;
|
|
354
|
+
phoneTenant?: string;
|
|
355
|
+
createdAt: Date;
|
|
356
|
+
updatedAt: Date;
|
|
357
|
+
}
|
|
358
|
+
interface INestAuthRole {
|
|
359
|
+
id: string;
|
|
360
|
+
name: string;
|
|
361
|
+
guard: string;
|
|
362
|
+
tenantId?: string;
|
|
363
|
+
isSystem: boolean;
|
|
364
|
+
isActive: boolean;
|
|
365
|
+
permissions: string[];
|
|
366
|
+
createdAt: Date;
|
|
367
|
+
updatedAt: Date;
|
|
368
|
+
}
|
|
369
|
+
interface INestAuthPermission {
|
|
370
|
+
id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
guard: string;
|
|
373
|
+
description?: string;
|
|
374
|
+
category?: string;
|
|
375
|
+
metadata?: Record<string, any>;
|
|
376
|
+
createdAt: Date;
|
|
377
|
+
updatedAt: Date;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
interface INestAuthTenant {
|
|
381
|
+
id: string;
|
|
382
|
+
name: string;
|
|
383
|
+
slug: string;
|
|
384
|
+
domain?: string;
|
|
385
|
+
description?: string;
|
|
386
|
+
metadata?: Record<string, any>;
|
|
387
|
+
isActive: boolean;
|
|
388
|
+
createdAt: Date;
|
|
389
|
+
updatedAt: Date;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export { type IAdminUser, type IAuthCookieResponse, type IAuthResponse, type IAuthSession, type IAuthSuccessResponse, type IAuthUser, type IChangePasswordRequest, type IClientConfigResponse, type IEmailAuthConfig, type IEmailCredentials, type IForgotPasswordRequest, type IInitializeAdminRequest, type IInitializeAdminResponse, type ILoginCredentials, type ILoginRequest, type IMessageResponse, type IMfaCodeResponse, type IMfaConfig, type IMfaDevice, type IMfaStatusResponse, type INestAuthAccessKey, type INestAuthIdentity, type INestAuthMFASecret, type INestAuthOTP, type INestAuthPermission, type INestAuthRole, type INestAuthSession, type INestAuthTenant, type INestAuthTrustedDevice, type INestAuthUser, type IPhoneAuthConfig, type IPhoneCredentials, type IProfileField, type IProfileFieldOption, type IRefreshRequest, type IRegistrationConfig, type IResendVerificationRequest, type IResetPasswordRequest, type IResetPasswordWithTokenRequest, type ISendEmailVerificationRequest, type ISendMfaCodeRequest, type ISessionVerifyResponse, type ISignupRequest, type ISocialCredentials, type ISsoConfig, type ISsoProviderConfig, type ITenantOption, type ITenantsConfig, type IToggleMfaRequest, type ITokenPair, type ITokensResponse, type ITotpSetupResponse, type IUiConfig, type IUserResponse, type IVerify2faRequest, type IVerify2faResponse, type IVerifyEmailRequest, type IVerifyForgotPasswordOtpRequest, type IVerifyOtpResponse, type IVerifyTotpSetupRequest, NestAuthMFAMethodEnum, NestAuthOTPTypeEnum };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/auth.ts
|
|
2
|
+
var NestAuthOTPTypeEnum = /* @__PURE__ */ ((NestAuthOTPTypeEnum2) => {
|
|
3
|
+
NestAuthOTPTypeEnum2["PASSWORD_RESET"] = "password_reset";
|
|
4
|
+
NestAuthOTPTypeEnum2["VERIFICATION"] = "verification";
|
|
5
|
+
NestAuthOTPTypeEnum2["MFA"] = "mfa";
|
|
6
|
+
return NestAuthOTPTypeEnum2;
|
|
7
|
+
})(NestAuthOTPTypeEnum || {});
|
|
8
|
+
var NestAuthMFAMethodEnum = /* @__PURE__ */ ((NestAuthMFAMethodEnum2) => {
|
|
9
|
+
NestAuthMFAMethodEnum2["EMAIL"] = "email";
|
|
10
|
+
NestAuthMFAMethodEnum2["SMS"] = "sms";
|
|
11
|
+
NestAuthMFAMethodEnum2["TOTP"] = "totp";
|
|
12
|
+
return NestAuthMFAMethodEnum2;
|
|
13
|
+
})(NestAuthMFAMethodEnum || {});
|
|
14
|
+
export {
|
|
15
|
+
NestAuthMFAMethodEnum,
|
|
16
|
+
NestAuthOTPTypeEnum
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/auth.ts"],"sourcesContent":["/**\n * Auth Types\n * Contains: Login/Signup/Token types + Auth Entities (Session, Identity, AccessKey, OTP)\n */\n\n// OTP Type Enum\nexport enum NestAuthOTPTypeEnum {\n PASSWORD_RESET = 'password_reset',\n VERIFICATION = 'verification',\n MFA = 'mfa',\n}\n\n// MFA Method Enum (Needed for AuthResponse and others)\nexport enum NestAuthMFAMethodEnum {\n EMAIL = 'email',\n SMS = 'sms',\n TOTP = 'totp',\n}\n\n// --- Entity Interfaces ---\n\nexport interface INestAuthIdentity {\n id: string;\n provider: string;\n providerId: string;\n metadata?: Record<string, any>;\n userId: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface INestAuthSession {\n id: string;\n userId: string;\n data?: any;\n refreshToken?: string;\n expiresAt?: Date;\n userAgent?: string;\n deviceName?: string;\n ipAddress?: string;\n lastActive?: Date;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface INestAuthAccessKey {\n id: string;\n name: string;\n publicKey: string;\n privateKey: string;\n description?: string;\n isActive: boolean;\n expiresAt?: Date;\n lastUsedAt?: Date;\n userId: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface INestAuthOTP {\n id: string;\n userId: string;\n code: string;\n type: NestAuthOTPTypeEnum;\n expiresAt: Date;\n used: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\n// --- Request/Response Interfaces ---\n\nexport interface IEmailCredentials {\n email: string;\n password: string;\n}\n\nexport interface IPhoneCredentials {\n phone: string;\n password: string;\n}\n\nexport interface ISocialCredentials {\n token: string;\n}\n\nexport type ILoginCredentials = IEmailCredentials | IPhoneCredentials | ISocialCredentials | Record<string, any>;\n\nexport interface ILoginRequest {\n providerName?: 'email' | 'phone' | 'google' | 'facebook' | 'apple' | 'github' | string;\n credentials: ILoginCredentials;\n tenantId?: string;\n createUserIfNotExists?: boolean;\n}\n\nexport interface ISignupRequest {\n email?: string;\n phone?: string;\n password: string;\n tenantId?: string;\n [key: string]: any;\n}\n\nexport interface IRefreshRequest {\n refreshToken?: string;\n}\n\nexport interface ITokenPair {\n accessToken: string;\n refreshToken: string;\n}\n\nexport interface IAuthUser {\n id: string;\n email?: string;\n phone?: string;\n isVerified?: boolean;\n isMfaEnabled?: boolean;\n roles?: string[];\n permissions?: string[];\n metadata?: Record<string, any>;\n tenantId?: string;\n}\n\nexport interface IAuthResponse extends ITokenPair {\n message?: string;\n isRequiresMfa?: boolean;\n mfaMethods?: NestAuthMFAMethodEnum[];\n defaultMfaMethod?: NestAuthMFAMethodEnum;\n user?: IAuthUser;\n}\n\nexport interface IAuthSession {\n id: string;\n userId: string;\n expiresAt: string;\n createdAt: string;\n}\n\nexport interface IMessageResponse {\n message: string;\n}\n\nexport interface IAuthCookieResponse {\n message: string;\n isRequiresMfa?: boolean;\n}\n\nexport interface IAuthSuccessResponse {\n message: string;\n isRequiresMfa?: boolean;\n}\n\nexport interface IUserResponse {\n id: string;\n email?: string;\n phone?: string;\n isVerified?: boolean;\n metadata?: Record<string, any>;\n}\n\nexport interface ITokensResponse {\n accessToken: string;\n refreshToken: string;\n}\n"],"mappings":";AAMO,IAAK,sBAAL,kBAAKA,yBAAL;AACH,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,kBAAe;AACf,EAAAA,qBAAA,SAAM;AAHE,SAAAA;AAAA,GAAA;AAOL,IAAK,wBAAL,kBAAKC,2BAAL;AACH,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,UAAO;AAHC,SAAAA;AAAA,GAAA;","names":["NestAuthOTPTypeEnum","NestAuthMFAMethodEnum"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ackplus/nest-auth-contracts",
|
|
3
|
+
"version": "1.1.29",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.0.0",
|
|
23
|
+
"tsup": "^8.3.5"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup"
|
|
27
|
+
}
|
|
28
|
+
}
|