@remit/smtp-service 0.0.13 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/smtp-service",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -158,9 +158,13 @@ describe("sendMail", () => {
158
158
  );
159
159
  });
160
160
 
161
- it("throws a classified auth error on a 535 AUTH rejection", async () => {
161
+ it("throws a classified auth error on a 535 AUTH rejection, in the server's words", async () => {
162
+ // What Microsoft answers a tenant with SMTP AUTH switched off. Signing in
163
+ // again never clears it, so the text has to survive classification for the
164
+ // account card to say what actually has to change.
162
165
  const server = await spawn({
163
- authResponse: "535 5.7.8 Authentication credentials invalid\r\n",
166
+ authResponse:
167
+ "535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant\r\n",
164
168
  });
165
169
 
166
170
  await assert.rejects(
@@ -168,7 +172,7 @@ describe("sendMail", () => {
168
172
  (error: unknown) => {
169
173
  assert.ok(error instanceof SmtpConnectionError);
170
174
  assert.equal(error.kind, "auth");
171
- assert.equal(error.message, "SMTP authentication failed");
175
+ assert.match(error.message, /SmtpClientAuthentication is disabled/);
172
176
  return true;
173
177
  },
174
178
  );
@@ -31,22 +31,6 @@ export class SmtpConnectionError extends Error {
31
31
  }
32
32
  }
33
33
 
34
- /** Password-based SMTP auth (AUTH PLAIN/LOGIN) */
35
- export interface SmtpAuthPassword {
36
- type?: undefined;
37
- user: string;
38
- pass: string;
39
- }
40
-
41
- /** OAuth2 SMTP auth (XOAUTH2 / OAUTHBEARER) */
42
- export interface SmtpAuthOAuth2 {
43
- type: "OAUTH2";
44
- user: string;
45
- accessToken: string;
46
- }
47
-
48
- export type SmtpAuth = SmtpAuthPassword | SmtpAuthOAuth2;
49
-
50
34
  export interface SmtpConfig {
51
35
  host: string;
52
36
  port: number;
@@ -127,6 +111,7 @@ export const sendMail = async (
127
111
  responseCode?: number;
128
112
  code?: string;
129
113
  command?: string;
114
+ response?: string;
130
115
  },
131
116
  ) => {
132
117
  const smtpCode = error.responseCode;
@@ -138,9 +123,15 @@ export const sendMail = async (
138
123
  smtpCode >= 500 &&
139
124
  error.command === "AUTH")
140
125
  ) {
126
+ // The server's own words, when it gave any: a 535 reading
127
+ // "SmtpClientAuthentication is disabled for the Tenant" is not a
128
+ // failure signing in again clears, and the account card can only
129
+ // say so if the text survives the classification.
141
130
  throw new SmtpConnectionError(
142
131
  "auth",
143
- "SMTP authentication failed",
132
+ error.response
133
+ ? `SMTP authentication failed: ${error.response.trim()}`
134
+ : "SMTP authentication failed",
144
135
  error,
145
136
  );
146
137
  }