@@ -17,6 +17,7 @@ export type SmtpServerConfig = {
1717} ;
1818export type SmtpServerDependencies = SmtpServerConfig & {
1919 BASE_URL : string ;
20+ BASE_PATH : string ;
2021 sendMail : SendMailService ;
2122 tokenStore : TokenStoreService ;
2223 randomBytes : RandomBytesService ;
@@ -26,6 +27,7 @@ export type SmtpServerDependencies = SmtpServerConfig & {
2627async function initSmtpServer ( {
2728 SMTP_OPTIONS ,
2829 BASE_URL ,
30+ BASE_PATH ,
2931 sendMail,
3032 tokenStore,
3133 randomBytes,
@@ -97,15 +99,15 @@ async function initSmtpServer({
9799 }
98100
99101 if ( token === 'knock' ) {
100-
101102 const newToken = ( await randomBytes ( 32 ) ) . toString ( 'hex' ) ;
102-
103+
103104 await tokenStore . set ( newToken , {
104105 pattern : fromAddress ,
105106 validated : false ,
106107 } ) ;
107-
108- const knockLink = `${ BASE_URL } /knock/${ newToken } /validation` ;
108+
109+ const knockLink = `${ BASE_URL } ${ BASE_PATH } /knock/${ newToken } /validation` ;
110+
109111 await sendMail ( {
110112 from : fromAddress ,
111113 to : toAddress ,
@@ -129,8 +131,8 @@ async function initSmtpServer({
129131 `💌 - Rejected mail from ${ fromAddress } due to invalid token (session: ${ session . id } ).` ,
130132 ) ;
131133 return callback (
132- Object . assign ( new Error ( 'Invalid token' ) , {
133- responseCode : 553
134+ Object . assign ( new Error ( 'Invalid token' ) , {
135+ responseCode : 553 ,
134136 } ) ,
135137 ) ;
136138 }
@@ -153,9 +155,12 @@ async function initSmtpServer({
153155 `💌 - Rejected mail from ${ fromAddress } due to pattern mismatch (session: ${ session . id } ).` ,
154156 ) ;
155157 return callback (
156- Object . assign ( new Error ( 'Email address does not match token pattern' ) , {
157- responseCode : 553 ,
158- } ) ,
158+ Object . assign (
159+ new Error ( 'Email address does not match token pattern' ) ,
160+ {
161+ responseCode : 553 ,
162+ } ,
163+ ) ,
159164 ) ;
160165 }
161166 await sendMail ( {
0 commit comments