@ofeklabs/horizon-auth 1.0.6 → 1.0.8
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 +123 -1
- package/dist/auth/auth.controller.d.ts +9 -2
- package/dist/auth/auth.controller.js +39 -2
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.module.js +2 -0
- package/dist/auth/auth.module.js.map +1 -1
- package/dist/auth/auth.service.d.ts +8 -1
- package/dist/auth/auth.service.js +100 -7
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/dto/password-reset.dto.d.ts +10 -1
- package/dist/auth/dto/password-reset.dto.js +32 -1
- package/dist/auth/dto/password-reset.dto.js.map +1 -1
- package/dist/auth/services/email.service.d.ts +21 -0
- package/dist/auth/services/email.service.js +294 -0
- package/dist/auth/services/email.service.js.map +1 -0
- package/dist/lib/horizon-auth-config.interface.d.ts +14 -0
- package/dist/lib/horizon-auth.module.js +49 -0
- package/dist/lib/horizon-auth.module.js.map +1 -1
- package/dist/push-tokens/push-token.service.d.ts +3 -3
- package/dist/social-auth/social-auth.service.d.ts +7 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/users/users.service.d.ts +19 -1
- package/dist/users/users.service.js +172 -9
- package/dist/users/users.service.js.map +1 -1
- package/package.json +9 -1
- package/prisma/migrations/add_otp_fields_for_dual_verification.sql +14 -0
- package/prisma/schema.prisma +36 -20
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HorizonAuthConfig } from '../../lib/horizon-auth-config.interface';
|
|
2
|
+
export declare class EmailService {
|
|
3
|
+
private readonly config;
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private readonly emailConfig?;
|
|
6
|
+
constructor(config: HorizonAuthConfig);
|
|
7
|
+
sendPasswordResetEmail(email: string, resetToken: string): Promise<void>;
|
|
8
|
+
sendEmailVerificationEmail(email: string, verificationToken: string): Promise<void>;
|
|
9
|
+
sendOtpEmail(to: string, otp: string, expiryMinutes: number): Promise<void>;
|
|
10
|
+
sendCombinedVerificationEmail(to: string, otp: string, token: string, expiryMinutes: number): Promise<void>;
|
|
11
|
+
sendPasswordResetOtpEmail(to: string, otp: string, expiryMinutes: number): Promise<void>;
|
|
12
|
+
private sendEmail;
|
|
13
|
+
private sendWithResend;
|
|
14
|
+
private sendWithSendGrid;
|
|
15
|
+
private getBaseUrl;
|
|
16
|
+
private generatePasswordResetEmailHtml;
|
|
17
|
+
private generateEmailVerificationHtml;
|
|
18
|
+
private generateOtpEmailHtml;
|
|
19
|
+
private generateCombinedVerificationEmailHtml;
|
|
20
|
+
private generatePasswordResetOtpEmailHtml;
|
|
21
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var EmailService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EmailService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
let EmailService = EmailService_1 = class EmailService {
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.logger = new common_1.Logger(EmailService_1.name);
|
|
22
|
+
this.emailConfig = config.email;
|
|
23
|
+
}
|
|
24
|
+
async sendPasswordResetEmail(email, resetToken) {
|
|
25
|
+
if (!this.emailConfig) {
|
|
26
|
+
console.log(`Password reset token for ${email}: ${resetToken}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const resetLink = `${this.getBaseUrl()}/reset-password?token=${resetToken}`;
|
|
30
|
+
const subject = 'Password Reset Request';
|
|
31
|
+
const html = this.generatePasswordResetEmailHtml(resetLink);
|
|
32
|
+
await this.sendEmail(email, subject, html);
|
|
33
|
+
}
|
|
34
|
+
async sendEmailVerificationEmail(email, verificationToken) {
|
|
35
|
+
if (!this.emailConfig) {
|
|
36
|
+
console.log(`Email verification token for ${email}: ${verificationToken}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const verificationLink = `${this.getBaseUrl()}/verify-email?token=${verificationToken}`;
|
|
40
|
+
const subject = 'Verify Your Email Address';
|
|
41
|
+
const html = this.generateEmailVerificationHtml(verificationLink);
|
|
42
|
+
await this.sendEmail(email, subject, html);
|
|
43
|
+
}
|
|
44
|
+
async sendOtpEmail(to, otp, expiryMinutes) {
|
|
45
|
+
if (!this.emailConfig) {
|
|
46
|
+
console.log(`Email verification OTP for ${to}: ${otp} (expires in ${expiryMinutes} minutes)`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const subject = 'Verify Your Email Address';
|
|
50
|
+
const html = this.generateOtpEmailHtml(otp, expiryMinutes);
|
|
51
|
+
await this.sendEmail(to, subject, html);
|
|
52
|
+
}
|
|
53
|
+
async sendCombinedVerificationEmail(to, otp, token, expiryMinutes) {
|
|
54
|
+
if (!this.emailConfig) {
|
|
55
|
+
console.log(`Email verification for ${to}:\n OTP: ${otp}\n Token: ${token}\n (expires in ${expiryMinutes} minutes)`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const verificationLink = `${this.getBaseUrl()}/verify-email?token=${token}`;
|
|
59
|
+
const subject = 'Verify Your Email Address';
|
|
60
|
+
const html = this.generateCombinedVerificationEmailHtml(otp, verificationLink, expiryMinutes);
|
|
61
|
+
await this.sendEmail(to, subject, html);
|
|
62
|
+
}
|
|
63
|
+
async sendPasswordResetOtpEmail(to, otp, expiryMinutes) {
|
|
64
|
+
if (!this.emailConfig) {
|
|
65
|
+
console.log(`Password reset OTP for ${to}: ${otp} (expires in ${expiryMinutes} minutes)`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const subject = 'Password Reset Request';
|
|
69
|
+
const html = this.generatePasswordResetOtpEmailHtml(otp, expiryMinutes);
|
|
70
|
+
await this.sendEmail(to, subject, html);
|
|
71
|
+
}
|
|
72
|
+
async sendEmail(to, subject, html) {
|
|
73
|
+
if (!this.emailConfig) {
|
|
74
|
+
throw new Error('Email configuration is not provided');
|
|
75
|
+
}
|
|
76
|
+
if (this.emailConfig.customSender) {
|
|
77
|
+
await this.emailConfig.customSender(to, subject, html);
|
|
78
|
+
this.logger.log(`Email sent to ${to} using custom sender`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (this.emailConfig.provider === 'resend') {
|
|
82
|
+
await this.sendWithResend(to, subject, html);
|
|
83
|
+
}
|
|
84
|
+
else if (this.emailConfig.provider === 'sendgrid') {
|
|
85
|
+
await this.sendWithSendGrid(to, subject, html);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
throw new Error(`Unsupported email provider: ${this.emailConfig.provider}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async sendWithResend(to, subject, html) {
|
|
92
|
+
if (!this.emailConfig?.apiKey) {
|
|
93
|
+
throw new Error('Resend API key is not configured');
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const resendModule = await Function('return import("resend")')().catch(() => {
|
|
97
|
+
throw new Error('Resend package is not installed. Install it with: npm install resend');
|
|
98
|
+
});
|
|
99
|
+
const Resend = resendModule.Resend;
|
|
100
|
+
const resend = new Resend(this.emailConfig.apiKey);
|
|
101
|
+
await resend.emails.send({
|
|
102
|
+
from: this.emailConfig.from,
|
|
103
|
+
to,
|
|
104
|
+
subject,
|
|
105
|
+
html,
|
|
106
|
+
});
|
|
107
|
+
this.logger.log(`Email sent to ${to} using Resend`);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
this.logger.error(`Failed to send email via Resend: ${error.message}`);
|
|
111
|
+
throw new Error(`Failed to send email: ${error.message}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async sendWithSendGrid(to, subject, html) {
|
|
115
|
+
if (!this.emailConfig?.apiKey) {
|
|
116
|
+
throw new Error('SendGrid API key is not configured');
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const sgMailModule = await Function('return import("@sendgrid/mail")')().catch(() => {
|
|
120
|
+
throw new Error('SendGrid package is not installed. Install it with: npm install @sendgrid/mail');
|
|
121
|
+
});
|
|
122
|
+
const sgMail = sgMailModule.default;
|
|
123
|
+
sgMail.setApiKey(this.emailConfig.apiKey);
|
|
124
|
+
await sgMail.send({
|
|
125
|
+
from: this.emailConfig.from,
|
|
126
|
+
to,
|
|
127
|
+
subject,
|
|
128
|
+
html,
|
|
129
|
+
});
|
|
130
|
+
this.logger.log(`Email sent to ${to} using SendGrid`);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
this.logger.error(`Failed to send email via SendGrid: ${error.message}`);
|
|
134
|
+
throw new Error(`Failed to send email: ${error.message}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
getBaseUrl() {
|
|
138
|
+
return process.env.APP_URL || 'http://localhost:3000';
|
|
139
|
+
}
|
|
140
|
+
generatePasswordResetEmailHtml(resetLink) {
|
|
141
|
+
return `
|
|
142
|
+
<!DOCTYPE html>
|
|
143
|
+
<html>
|
|
144
|
+
<head>
|
|
145
|
+
<meta charset="utf-8">
|
|
146
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
147
|
+
<title>Password Reset Request</title>
|
|
148
|
+
</head>
|
|
149
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
150
|
+
<div style="background-color: #f4f4f4; padding: 20px; border-radius: 5px;">
|
|
151
|
+
<h2 style="color: #333; margin-top: 0;">Password Reset Request</h2>
|
|
152
|
+
<p>You requested to reset your password. Click the button below to reset it:</p>
|
|
153
|
+
<div style="text-align: center; margin: 30px 0;">
|
|
154
|
+
<a href="${resetLink}" style="background-color: #007bff; color: white; padding: 12px 30px; text-decoration: none; border-radius: 5px; display: inline-block;">Reset Password</a>
|
|
155
|
+
</div>
|
|
156
|
+
<p>Or copy and paste this link into your browser:</p>
|
|
157
|
+
<p style="word-break: break-all; color: #007bff;">${resetLink}</p>
|
|
158
|
+
<p style="color: #666; font-size: 14px; margin-top: 30px;">This link will expire in 1 hour.</p>
|
|
159
|
+
<p style="color: #666; font-size: 14px;">If you didn't request this password reset, please ignore this email.</p>
|
|
160
|
+
</div>
|
|
161
|
+
</body>
|
|
162
|
+
</html>
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
generateEmailVerificationHtml(verificationLink) {
|
|
166
|
+
return `
|
|
167
|
+
<!DOCTYPE html>
|
|
168
|
+
<html>
|
|
169
|
+
<head>
|
|
170
|
+
<meta charset="utf-8">
|
|
171
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
172
|
+
<title>Verify Your Email Address</title>
|
|
173
|
+
</head>
|
|
174
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
175
|
+
<div style="background-color: #f4f4f4; padding: 20px; border-radius: 5px;">
|
|
176
|
+
<h2 style="color: #333; margin-top: 0;">Verify Your Email Address</h2>
|
|
177
|
+
<p>Thank you for registering! Please verify your email address by clicking the button below:</p>
|
|
178
|
+
<div style="text-align: center; margin: 30px 0;">
|
|
179
|
+
<a href="${verificationLink}" style="background-color: #28a745; color: white; padding: 12px 30px; text-decoration: none; border-radius: 5px; display: inline-block;">Verify Email</a>
|
|
180
|
+
</div>
|
|
181
|
+
<p>Or copy and paste this link into your browser:</p>
|
|
182
|
+
<p style="word-break: break-all; color: #28a745;">${verificationLink}</p>
|
|
183
|
+
<p style="color: #666; font-size: 14px; margin-top: 30px;">If you didn't create an account, please ignore this email.</p>
|
|
184
|
+
</div>
|
|
185
|
+
</body>
|
|
186
|
+
</html>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
generateOtpEmailHtml(otp, expiryMinutes) {
|
|
190
|
+
return `
|
|
191
|
+
<!DOCTYPE html>
|
|
192
|
+
<html>
|
|
193
|
+
<head>
|
|
194
|
+
<meta charset="utf-8">
|
|
195
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
196
|
+
<title>Verify Your Email Address</title>
|
|
197
|
+
</head>
|
|
198
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
199
|
+
<div style="background-color: #f4f4f4; padding: 20px; border-radius: 5px;">
|
|
200
|
+
<h2 style="color: #333; margin-top: 0;">Verify Your Email Address</h2>
|
|
201
|
+
<p>Thank you for registering! Please use the verification code below to verify your email address:</p>
|
|
202
|
+
<div style="text-align: center; margin: 30px 0;">
|
|
203
|
+
<div style="background-color: #fff; border: 2px solid #28a745; border-radius: 8px; padding: 20px; display: inline-block;">
|
|
204
|
+
<div style="font-size: 32px; font-weight: bold; letter-spacing: 8px; color: #28a745;">${otp}</div>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
<p style="text-align: center; font-size: 16px; color: #666;">Enter this code to verify your email</p>
|
|
208
|
+
<p style="color: #666; font-size: 14px; margin-top: 30px;">This code will expire in ${expiryMinutes} minutes.</p>
|
|
209
|
+
<p style="color: #666; font-size: 14px;">If you didn't create an account, please ignore this email.</p>
|
|
210
|
+
</div>
|
|
211
|
+
</body>
|
|
212
|
+
</html>
|
|
213
|
+
`;
|
|
214
|
+
}
|
|
215
|
+
generateCombinedVerificationEmailHtml(otp, verificationLink, expiryMinutes) {
|
|
216
|
+
return `
|
|
217
|
+
<!DOCTYPE html>
|
|
218
|
+
<html>
|
|
219
|
+
<head>
|
|
220
|
+
<meta charset="utf-8">
|
|
221
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
222
|
+
<title>Verify Your Email Address</title>
|
|
223
|
+
</head>
|
|
224
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
225
|
+
<div style="background-color: #f4f4f4; padding: 20px; border-radius: 5px;">
|
|
226
|
+
<h2 style="color: #333; margin-top: 0;">Verify Your Email Address</h2>
|
|
227
|
+
<p>Thank you for registering! You can verify your email address using either of the two methods below:</p>
|
|
228
|
+
|
|
229
|
+
<!-- Option 1: Verification Code -->
|
|
230
|
+
<div style="background-color: #fff; border-radius: 8px; padding: 20px; margin: 20px 0;">
|
|
231
|
+
<h3 style="color: #333; margin-top: 0; font-size: 18px;">Option 1: Enter Verification Code</h3>
|
|
232
|
+
<p style="margin: 10px 0;">Use this code in the verification form:</p>
|
|
233
|
+
<div style="text-align: center; margin: 20px 0;">
|
|
234
|
+
<div style="background-color: #f8f9fa; border: 2px solid #28a745; border-radius: 8px; padding: 15px; display: inline-block;">
|
|
235
|
+
<div style="font-size: 28px; font-weight: bold; letter-spacing: 6px; color: #28a745;">${otp}</div>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<!-- Divider -->
|
|
241
|
+
<div style="text-align: center; margin: 30px 0; color: #999; font-weight: bold;">OR</div>
|
|
242
|
+
|
|
243
|
+
<!-- Option 2: Magic Link -->
|
|
244
|
+
<div style="background-color: #fff; border-radius: 8px; padding: 20px; margin: 20px 0;">
|
|
245
|
+
<h3 style="color: #333; margin-top: 0; font-size: 18px;">Option 2: Click Verification Link</h3>
|
|
246
|
+
<p style="margin: 10px 0;">Click the button below to verify instantly:</p>
|
|
247
|
+
<div style="text-align: center; margin: 20px 0;">
|
|
248
|
+
<a href="${verificationLink}" style="background-color: #28a745; color: white; padding: 12px 30px; text-decoration: none; border-radius: 5px; display: inline-block; font-weight: bold;">Verify Email</a>
|
|
249
|
+
</div>
|
|
250
|
+
<p style="font-size: 14px; color: #666; margin: 10px 0;">Or copy and paste this link into your browser:</p>
|
|
251
|
+
<p style="word-break: break-all; color: #28a745; font-size: 12px;">${verificationLink}</p>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<p style="color: #666; font-size: 14px; margin-top: 30px; text-align: center;">Both methods will expire in ${expiryMinutes} minutes.</p>
|
|
255
|
+
<p style="color: #666; font-size: 14px; text-align: center;">If you didn't create an account, please ignore this email.</p>
|
|
256
|
+
</div>
|
|
257
|
+
</body>
|
|
258
|
+
</html>
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
generatePasswordResetOtpEmailHtml(otp, expiryMinutes) {
|
|
262
|
+
return `
|
|
263
|
+
<!DOCTYPE html>
|
|
264
|
+
<html>
|
|
265
|
+
<head>
|
|
266
|
+
<meta charset="utf-8">
|
|
267
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
268
|
+
<title>Password Reset Request</title>
|
|
269
|
+
</head>
|
|
270
|
+
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
271
|
+
<div style="background-color: #f4f4f4; padding: 20px; border-radius: 5px;">
|
|
272
|
+
<h2 style="color: #333; margin-top: 0;">Password Reset Request</h2>
|
|
273
|
+
<p>You requested to reset your password. Please use the verification code below to proceed:</p>
|
|
274
|
+
<div style="text-align: center; margin: 30px 0;">
|
|
275
|
+
<div style="background-color: #fff; border: 2px solid #007bff; border-radius: 8px; padding: 20px; display: inline-block;">
|
|
276
|
+
<div style="font-size: 32px; font-weight: bold; letter-spacing: 8px; color: #007bff;">${otp}</div>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
<p style="text-align: center; font-size: 16px; color: #666;">Enter this code to reset your password</p>
|
|
280
|
+
<p style="color: #666; font-size: 14px; margin-top: 30px;">This code will expire in ${expiryMinutes} minutes.</p>
|
|
281
|
+
<p style="color: #666; font-size: 14px;">If you didn't request this password reset, please ignore this email.</p>
|
|
282
|
+
</div>
|
|
283
|
+
</body>
|
|
284
|
+
</html>
|
|
285
|
+
`;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
exports.EmailService = EmailService;
|
|
289
|
+
exports.EmailService = EmailService = EmailService_1 = __decorate([
|
|
290
|
+
(0, common_1.Injectable)(),
|
|
291
|
+
__param(0, (0, common_1.Inject)('HORIZON_AUTH_CONFIG')),
|
|
292
|
+
__metadata("design:paramtypes", [Object])
|
|
293
|
+
], EmailService);
|
|
294
|
+
//# sourceMappingURL=email.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../src/auth/services/email.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAIrD,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAIvB,YACiC,MAA0C;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAJ1D,WAAM,GAAG,IAAI,eAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;QAMtD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;IAClC,CAAC;IAOD,KAAK,CAAC,sBAAsB,CAAC,KAAa,EAAE,UAAkB;QAC5D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAEtB,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,KAAK,UAAU,EAAE,CAAC,CAAC;YAChE,OAAO;QACT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E,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAMO,UAAU;QAEhB,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,uBAAuB,CAAC;IACxD,CAAC;IAKO,8BAA8B,CAAC,SAAiB;QACtD,OAAO;;;;;;;;;;;;;yBAac,SAAS;;;gEAG8B,SAAS;;;;;;KAMpE,CAAC;IACJ,CAAC;IAKO,6BAA6B,CAAC,gBAAwB;QAC5D,OAAO;;;;;;;;;;;;;yBAac,gBAAgB;;;gEAGuB,gBAAgB;;;;;KAK3E,CAAC;IACJ,CAAC;IAKO,oBAAoB,CAAC,GAAW,EAAE,aAAqB;QAC7D,OAAO;;;;;;;;;;;;;;wGAc6F,GAAG;;;;kGAIT,aAAa;;;;;KAK1G,CAAC;IACJ,CAAC;IAKO,qCAAqC,CAAC,GAAW,EAAE,gBAAwB,EAAE,aAAqB;QACxG,OAAO;;;;;;;;;;;;;;;;;;;0GAmB+F,GAAG;;;;;;;;;;;;;2BAalF,gBAAgB;;;mFAGwC,gBAAgB;;;yHAGsB,aAAa;;;;;KAKjI,CAAC;IACJ,CAAC;IAKO,iCAAiC,CAAC,GAAW,EAAE,aAAqB;QAC1E,OAAO;;;;;;;;;;;;;;wGAc6F,GAAG;;;;kGAIT,aAAa;;;;;KAK1G,CAAC;IACJ,CAAC;CACF,CAAA;AArXY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,qBAAqB,CAAC,CAAA;;GALrB,YAAY,CAqXxB"}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export interface EmailVerificationConfig {
|
|
2
|
+
method: 'otp' | 'magic-link' | 'both';
|
|
3
|
+
otpLength?: number;
|
|
4
|
+
otpExpiry?: number;
|
|
5
|
+
tokenExpiry?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PasswordResetConfig {
|
|
8
|
+
method: 'otp' | 'magic-link' | 'both';
|
|
9
|
+
otpLength?: number;
|
|
10
|
+
otpExpiry?: number;
|
|
11
|
+
tokenExpiry?: number;
|
|
12
|
+
}
|
|
1
13
|
export interface HorizonAuthConfig {
|
|
2
14
|
ssoMode?: boolean;
|
|
3
15
|
authServiceUrl?: string;
|
|
@@ -50,6 +62,8 @@ export interface HorizonAuthConfig {
|
|
|
50
62
|
from: string;
|
|
51
63
|
customSender?: (to: string, subject: string, html: string) => Promise<void>;
|
|
52
64
|
};
|
|
65
|
+
emailVerification?: EmailVerificationConfig;
|
|
66
|
+
passwordReset?: PasswordResetConfig;
|
|
53
67
|
security?: {
|
|
54
68
|
bcryptMigration?: boolean;
|
|
55
69
|
cookieSecure?: boolean;
|
|
@@ -92,6 +92,28 @@ let HorizonAuthModule = HorizonAuthModule_1 = class HorizonAuthModule {
|
|
|
92
92
|
if (!config.jwt.privateKey.includes('BEGIN') || !config.jwt.publicKey.includes('BEGIN')) {
|
|
93
93
|
throw new Error('HorizonAuth: JWT keys must be in PEM format');
|
|
94
94
|
}
|
|
95
|
+
if (config.emailVerification) {
|
|
96
|
+
const validMethods = ['otp', 'magic-link', 'both'];
|
|
97
|
+
if (!validMethods.includes(config.emailVerification.method)) {
|
|
98
|
+
throw new Error('HorizonAuth: emailVerification.method must be one of: otp, magic-link, both');
|
|
99
|
+
}
|
|
100
|
+
if (config.emailVerification.otpLength !== undefined) {
|
|
101
|
+
if (config.emailVerification.otpLength < 4 || config.emailVerification.otpLength > 8) {
|
|
102
|
+
throw new Error('HorizonAuth: emailVerification.otpLength must be between 4 and 8');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (config.passwordReset) {
|
|
107
|
+
const validMethods = ['otp', 'magic-link', 'both'];
|
|
108
|
+
if (!validMethods.includes(config.passwordReset.method)) {
|
|
109
|
+
throw new Error('HorizonAuth: passwordReset.method must be one of: otp, magic-link, both');
|
|
110
|
+
}
|
|
111
|
+
if (config.passwordReset.otpLength !== undefined) {
|
|
112
|
+
if (config.passwordReset.otpLength < 4 || config.passwordReset.otpLength > 8) {
|
|
113
|
+
throw new Error('HorizonAuth: passwordReset.otpLength must be between 4 and 8');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
95
117
|
}
|
|
96
118
|
static applyDefaults(config) {
|
|
97
119
|
return {
|
|
@@ -121,6 +143,33 @@ let HorizonAuthModule = HorizonAuthModule_1 = class HorizonAuthModule {
|
|
|
121
143
|
register: config.rateLimit?.register || { limit: 3, ttl: 60 },
|
|
122
144
|
passwordReset: config.rateLimit?.passwordReset || { limit: 3, ttl: 3600 },
|
|
123
145
|
},
|
|
146
|
+
emailVerification: config.emailVerification ? {
|
|
147
|
+
method: config.emailVerification.method || 'otp',
|
|
148
|
+
otpLength: config.emailVerification.otpLength || 6,
|
|
149
|
+
otpExpiry: config.emailVerification.otpExpiry || 10,
|
|
150
|
+
tokenExpiry: config.emailVerification.tokenExpiry || 24,
|
|
151
|
+
} : {
|
|
152
|
+
method: 'otp',
|
|
153
|
+
otpLength: 6,
|
|
154
|
+
otpExpiry: 10,
|
|
155
|
+
tokenExpiry: 24,
|
|
156
|
+
},
|
|
157
|
+
passwordReset: config.passwordReset ? {
|
|
158
|
+
method: config.passwordReset.method || config.emailVerification?.method || 'otp',
|
|
159
|
+
otpLength: config.passwordReset.otpLength || config.emailVerification?.otpLength || 6,
|
|
160
|
+
otpExpiry: config.passwordReset.otpExpiry || config.emailVerification?.otpExpiry || 10,
|
|
161
|
+
tokenExpiry: config.passwordReset.tokenExpiry || config.emailVerification?.tokenExpiry || 24,
|
|
162
|
+
} : config.emailVerification ? {
|
|
163
|
+
method: config.emailVerification.method || 'otp',
|
|
164
|
+
otpLength: config.emailVerification.otpLength || 6,
|
|
165
|
+
otpExpiry: config.emailVerification.otpExpiry || 10,
|
|
166
|
+
tokenExpiry: config.emailVerification.tokenExpiry || 24,
|
|
167
|
+
} : {
|
|
168
|
+
method: 'otp',
|
|
169
|
+
otpLength: 6,
|
|
170
|
+
otpExpiry: 10,
|
|
171
|
+
tokenExpiry: 24,
|
|
172
|
+
},
|
|
124
173
|
security: {
|
|
125
174
|
bcryptMigration: config.security?.bcryptMigration || false,
|
|
126
175
|
cookieSecure: config.security?.cookieSecure ?? (process.env.NODE_ENV === 'production'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizon-auth.module.js","sourceRoot":"","sources":["../../src/lib/horizon-auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,uCAAyC;AAEzC,qDAAiD;AACjD,wDAAoD;AACpD,wDAAoD;AACpD,kEAA6D;AAwDtD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAY5B,MAAM,CAAC,OAAO,CAAC,MAAyB;QAEtC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAG5B,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAE/C,MAAM,SAAS,GAAe;YAC5B;gBACE,OAAO,EAAE,qBAAqB;gBAC9B,QAAQ,EAAE,WAAW;aACtB;SACF,CAAC;QAGF,IAAI,WAAW,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC;YAC9C,SAAS,CAAC,IAAI,CAAC;gBACb,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,6BAAY;aACvB,CAAC,CAAC;QACL,CAAC;QAGD,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO;gBACL,MAAM,EAAE,mBAAiB;gBACzB,OAAO,EAAE;oBACP,wBAAU,CAAC,UAAU,EAAE;iBACxB;gBACD,SAAS;gBACT,OAAO,EAAE,CAAC,qBAAqB,EAAE,wBAAU,CAAC;aAC7C,CAAC;QACJ,CAAC;QAKD,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE;gBACP,0BAAW,CAAC,OAAO,CAAC,WAAW,CAAC;gBAChC,wBAAU,CAAC,WAAW,CAAC,WAAW,CAAC;gBACnC,0BAAW;aACZ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I,KAAK;gBAChD,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS,IAAI,CAAC;gBAClD,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS,IAAI,EAAE;gBACnD,WAAW,EAAE,MAAM,CAAC,iBAAiB,CAAC,WAAW,IAAI,EAAE;aACxD,CAAC,CAAC,CAAC;gBACF,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,EAAE;gBACb,WAAW,EAAE,EAAE;aAChB;YACD,QAAQ,EAAE;gBACR,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,eAAe,IAAI,KAAK;gBAC1D,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;gBACtF,GAAG,MAAM,CAAC,QAAQ;aACnB;YACD,MAAM,EAAE;gBACN,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,IAAI,KAAK;aACrE;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA5OY,8CAAiB;4BAAjB,iBAAiB;IAF7B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CA4O7B"}
|
|
@@ -12,8 +12,8 @@ export declare class PushTokenService {
|
|
|
12
12
|
id: string;
|
|
13
13
|
createdAt: Date;
|
|
14
14
|
updatedAt: Date;
|
|
15
|
-
userId: string;
|
|
16
15
|
token: string;
|
|
16
|
+
userId: string;
|
|
17
17
|
deviceId: string;
|
|
18
18
|
tokenType: string;
|
|
19
19
|
active: boolean;
|
|
@@ -22,8 +22,8 @@ export declare class PushTokenService {
|
|
|
22
22
|
id: string;
|
|
23
23
|
createdAt: Date;
|
|
24
24
|
updatedAt: Date;
|
|
25
|
-
userId: string;
|
|
26
25
|
token: string;
|
|
26
|
+
userId: string;
|
|
27
27
|
deviceId: string;
|
|
28
28
|
tokenType: string;
|
|
29
29
|
active: boolean;
|
|
@@ -41,8 +41,8 @@ export declare class PushTokenService {
|
|
|
41
41
|
id: string;
|
|
42
42
|
createdAt: Date;
|
|
43
43
|
updatedAt: Date;
|
|
44
|
-
userId: string;
|
|
45
44
|
token: string;
|
|
45
|
+
userId: string;
|
|
46
46
|
deviceId: string;
|
|
47
47
|
tokenType: string;
|
|
48
48
|
active: boolean;
|
|
@@ -28,7 +28,14 @@ export declare class SocialAuthService {
|
|
|
28
28
|
fullName: string | null;
|
|
29
29
|
passwordHash: string | null;
|
|
30
30
|
emailVerified: boolean;
|
|
31
|
+
emailVerificationOtp: string | null;
|
|
32
|
+
emailVerificationSentAt: Date | null;
|
|
33
|
+
emailVerificationExpiresAt: Date | null;
|
|
34
|
+
emailVerificationAttempts: number;
|
|
31
35
|
emailVerifyToken: string | null;
|
|
36
|
+
passwordResetOtp: string | null;
|
|
37
|
+
passwordResetOtpExpiresAt: Date | null;
|
|
38
|
+
passwordResetOtpAttempts: number;
|
|
32
39
|
resetToken: string | null;
|
|
33
40
|
resetTokenExpiry: Date | null;
|
|
34
41
|
tenantId: string;
|