Skip to content

Commit aae4923

Browse files
committed
fix: fix the knock URL
1 parent 0819fef commit aae4923

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/cli.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ describe('commands should work', () => {
1212
);
1313

1414
expect({
15-
stdout: replacePaths(stdout),
16-
stderr: replacePaths(stderr)
17-
}).toMatchInlineSnapshot(`
15+
stdout: replacePaths(stdout),
16+
stderr: replacePaths(stderr),
17+
}).toMatchInlineSnapshot(`
1818
{
1919
"stderr": "⚡ - Loading configurations from "file:///project/dist/config/local/config.js".
2020
🤖 - Initializing the \`$autoload\` service.

src/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ describe('runProcess', () => {
101101
test('should work', async () => {
102102
expect(logger.output.mock.calls.length).toEqual(0);
103103
expect({
104-
debugCalls: logger.debug.mock.calls.map(filterPaths).sort(sortLogs),
105-
logErrorCalls: logger.error.mock.calls.map(filterPaths).sort(sortLogs)
106-
}).toMatchInlineSnapshot(`
104+
debugCalls: logger.debug.mock.calls.map(filterPaths).sort(sortLogs),
105+
logErrorCalls: logger.error.mock.calls.map(filterPaths).sort(sortLogs),
106+
}).toMatchInlineSnapshot(`
107107
{
108108
"debugCalls": [
109109
[

src/services/smtpServer.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type SmtpServerConfig = {
1717
};
1818
export 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 & {
2627
async 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

Comments
 (0)