@jadedm/nestjs-verify-ses 0.6.0 → 0.7.0
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 +5 -5
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ pnpm add @jadedm/nestjs-verify-ses @aws-sdk/client-sesv2
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import { VerifyModule } from '@jadedm/nestjs-verify';
|
|
12
|
+
import { VerifyModule, createMemoryStores } from '@jadedm/nestjs-verify';
|
|
13
13
|
import { SesEmailProvider } from '@jadedm/nestjs-verify-ses';
|
|
14
14
|
|
|
15
15
|
VerifyModule.forRoot({
|
|
@@ -21,17 +21,17 @@ VerifyModule.forRoot({
|
|
|
21
21
|
}),
|
|
22
22
|
subject: 'Your Example sign-in code',
|
|
23
23
|
},
|
|
24
|
-
stores:
|
|
24
|
+
stores: createMemoryStores(), // or a durable store adapter
|
|
25
25
|
});
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Start a verification with `channel: 'email'` and an email address in `to`.
|
|
29
29
|
|
|
30
|
-
Credentials come from the AWS SDK's default chain (environment, shared config, instance or task role). Pass `client` to use your own `SESv2Client`.
|
|
30
|
+
Credentials and region come from the AWS SDK's default chain (environment, shared config, instance or task role). If no region is set anywhere, every send fails with "Region is missing" and the next provider is tried, so set `region` or `AWS_REGION`. Pass `client` to use your own `SESv2Client`.
|
|
31
31
|
|
|
32
32
|
## Errors and retries
|
|
33
33
|
|
|
34
|
-
The AWS SDK retries throttling and server errors itself (three attempts by default). Anything it gives up on, and any rejection such as an unverified identity or a recipient outside the sandbox, is thrown, so `nestjs-verify` moves on to the next provider in `email.fallbacks`.
|
|
34
|
+
The AWS SDK retries throttling and server errors itself (three attempts by default). Anything it gives up on, and any rejection such as an unverified identity or a recipient outside the sandbox, is thrown, so `nestjs-verify` moves on to the next provider in `email.fallbacks`. The SDK sets no request timeout of its own; the core's `delivery` limits stop waiting and abort the request. Logged errors keep the SES request id.
|
|
35
35
|
|
|
36
36
|
## Requirements
|
|
37
37
|
|
|
@@ -39,5 +39,5 @@ Node 20 or newer: current `@aws-sdk/client-sesv2` releases require it, though th
|
|
|
39
39
|
|
|
40
40
|
## Peers
|
|
41
41
|
|
|
42
|
-
- `@jadedm/nestjs-verify` 0.x
|
|
42
|
+
- `@jadedm/nestjs-verify` within the range in `peerDependencies` (one or more 0.x minors)
|
|
43
43
|
- `@aws-sdk/client-sesv2` 3.x
|
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,9 @@ declare class SesEmailProvider implements EmailProvider {
|
|
|
22
22
|
readonly name = "ses";
|
|
23
23
|
private readonly client;
|
|
24
24
|
constructor(opts: SesEmailProviderOptions);
|
|
25
|
-
send(params: EmailSendParams
|
|
25
|
+
send(params: EmailSendParams, options?: {
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}): Promise<EmailSendResult>;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export { SesEmailProvider, type SesEmailProviderOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ declare class SesEmailProvider implements EmailProvider {
|
|
|
22
22
|
readonly name = "ses";
|
|
23
23
|
private readonly client;
|
|
24
24
|
constructor(opts: SesEmailProviderOptions);
|
|
25
|
-
send(params: EmailSendParams
|
|
25
|
+
send(params: EmailSendParams, options?: {
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}): Promise<EmailSendResult>;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export { SesEmailProvider, type SesEmailProviderOptions };
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,9 @@ var SesEmailProvider = class {
|
|
|
40
40
|
region: opts.region
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
// The options type is written out rather than imported, so these
|
|
44
|
+
// declarations still type-check against a core version that lacks it.
|
|
45
|
+
async send(params, options) {
|
|
44
46
|
const result = await this.client.send(new import_client_sesv2.SendEmailCommand({
|
|
45
47
|
FromEmailAddress: this.opts.from,
|
|
46
48
|
Destination: {
|
|
@@ -63,7 +65,9 @@ var SesEmailProvider = class {
|
|
|
63
65
|
}
|
|
64
66
|
},
|
|
65
67
|
ConfigurationSetName: this.opts.configurationSetName
|
|
66
|
-
})
|
|
68
|
+
}), {
|
|
69
|
+
abortSignal: options?.signal
|
|
70
|
+
});
|
|
67
71
|
if (!result.MessageId) throw new Error("SES returned no MessageId");
|
|
68
72
|
return {
|
|
69
73
|
providerMessageId: result.MessageId,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/ses-email.provider.ts"],"sourcesContent":["export * from './ses-email.provider.js';\n","import type {\n EmailProvider,\n EmailSendParams,\n EmailSendResult,\n} from '@jadedm/nestjs-verify';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport interface SesEmailProviderOptions {\n /** Verified SES identity to send from, e.g. 'no-reply@example.com' or 'Example <no-reply@example.com>'. */\n from: string;\n /** Region of the SES identity, e.g. 'ap-south-1'. Ignored when `client` is given. */\n region?: string;\n /** A configured client, for custom credentials or endpoints. */\n client?: SESv2Client;\n /** Optional SES configuration set, for event publishing. */\n configurationSetName?: string;\n}\n\n/**\n * Sends verification codes through Amazon SES (API v2). Credentials come from\n * the AWS SDK's default chain unless a client is passed. The SDK retries\n * throttling and server errors itself; anything it gives up on is thrown, so\n * the core can try a fallback provider.\n */\nexport class SesEmailProvider implements EmailProvider {\n readonly name = 'ses';\n private readonly client: SESv2Client;\n\n constructor(private readonly opts: SesEmailProviderOptions) {\n this.client = opts.client ?? new SESv2Client({ region: opts.region });\n }\n\n async send(params: EmailSendParams): Promise<EmailSendResult> {\n const result = await this.client.send(\n new SendEmailCommand({\n FromEmailAddress: this.opts.from,\n Destination: { ToAddresses: [params.to] },\n Content: {\n Simple: {\n Subject: { Data: params.subject, Charset: 'UTF-8' },\n Body: { Text: { Data: params.text, Charset: 'UTF-8' } },\n },\n },\n ConfigurationSetName: this.opts.configurationSetName,\n }),\n );\n if (!result.MessageId) throw new Error('SES returned no MessageId');\n return { providerMessageId: result.MessageId, provider: this.name };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACKA,0BAA8C;AAmBvC,IAAMA,mBAAN,MAAMA;EAnBb,OAmBaA;;;;EACFC,OAAO;EACCC;EAEjB,YAA6BC,MAA+B;SAA/BA,OAAAA;AAC3B,SAAKD,SAASC,KAAKD,UAAU,IAAIE,gCAAY;MAAEC,QAAQF,KAAKE;IAAO,CAAA;EACrE
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/ses-email.provider.ts"],"sourcesContent":["export * from './ses-email.provider.js';\n","import type {\n EmailProvider,\n EmailSendParams,\n EmailSendResult,\n} from '@jadedm/nestjs-verify';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport interface SesEmailProviderOptions {\n /** Verified SES identity to send from, e.g. 'no-reply@example.com' or 'Example <no-reply@example.com>'. */\n from: string;\n /** Region of the SES identity, e.g. 'ap-south-1'. Ignored when `client` is given. */\n region?: string;\n /** A configured client, for custom credentials or endpoints. */\n client?: SESv2Client;\n /** Optional SES configuration set, for event publishing. */\n configurationSetName?: string;\n}\n\n/**\n * Sends verification codes through Amazon SES (API v2). Credentials come from\n * the AWS SDK's default chain unless a client is passed. The SDK retries\n * throttling and server errors itself; anything it gives up on is thrown, so\n * the core can try a fallback provider.\n */\nexport class SesEmailProvider implements EmailProvider {\n readonly name = 'ses';\n private readonly client: SESv2Client;\n\n constructor(private readonly opts: SesEmailProviderOptions) {\n this.client = opts.client ?? new SESv2Client({ region: opts.region });\n }\n\n // The options type is written out rather than imported, so these\n // declarations still type-check against a core version that lacks it.\n async send(params: EmailSendParams, options?: { signal?: AbortSignal }): Promise<EmailSendResult> {\n const result = await this.client.send(\n new SendEmailCommand({\n FromEmailAddress: this.opts.from,\n Destination: { ToAddresses: [params.to] },\n Content: {\n Simple: {\n Subject: { Data: params.subject, Charset: 'UTF-8' },\n Body: { Text: { Data: params.text, Charset: 'UTF-8' } },\n },\n },\n ConfigurationSetName: this.opts.configurationSetName,\n }),\n { abortSignal: options?.signal },\n );\n if (!result.MessageId) throw new Error('SES returned no MessageId');\n return { providerMessageId: result.MessageId, provider: this.name };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACKA,0BAA8C;AAmBvC,IAAMA,mBAAN,MAAMA;EAnBb,OAmBaA;;;;EACFC,OAAO;EACCC;EAEjB,YAA6BC,MAA+B;SAA/BA,OAAAA;AAC3B,SAAKD,SAASC,KAAKD,UAAU,IAAIE,gCAAY;MAAEC,QAAQF,KAAKE;IAAO,CAAA;EACrE;;;EAIA,MAAMC,KAAKC,QAAyBC,SAA8D;AAChG,UAAMC,SAAS,MAAM,KAAKP,OAAOI,KAC/B,IAAII,qCAAiB;MACnBC,kBAAkB,KAAKR,KAAKS;MAC5BC,aAAa;QAAEC,aAAa;UAACP,OAAOQ;;MAAI;MACxCC,SAAS;QACPC,QAAQ;UACNC,SAAS;YAAEC,MAAMZ,OAAOa;YAASC,SAAS;UAAQ;UAClDC,MAAM;YAAEC,MAAM;cAAEJ,MAAMZ,OAAOiB;cAAMH,SAAS;YAAQ;UAAE;QACxD;MACF;MACAI,sBAAsB,KAAKtB,KAAKuB;IAClC,CAAA,GACA;MAAEC,aAAanB,SAASoB;IAAO,CAAA;AAEjC,QAAI,CAACnB,OAAOoB,UAAW,OAAM,IAAIC,MAAM,2BAAA;AACvC,WAAO;MAAEC,mBAAmBtB,OAAOoB;MAAWG,UAAU,KAAK/B;IAAK;EACpE;AACF;","names":["SesEmailProvider","name","client","opts","SESv2Client","region","send","params","options","result","SendEmailCommand","FromEmailAddress","from","Destination","ToAddresses","to","Content","Simple","Subject","Data","subject","Charset","Body","Text","text","ConfigurationSetName","configurationSetName","abortSignal","signal","MessageId","Error","providerMessageId","provider"]}
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,9 @@ var SesEmailProvider = class {
|
|
|
16
16
|
region: opts.region
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
// The options type is written out rather than imported, so these
|
|
20
|
+
// declarations still type-check against a core version that lacks it.
|
|
21
|
+
async send(params, options) {
|
|
20
22
|
const result = await this.client.send(new SendEmailCommand({
|
|
21
23
|
FromEmailAddress: this.opts.from,
|
|
22
24
|
Destination: {
|
|
@@ -39,7 +41,9 @@ var SesEmailProvider = class {
|
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
ConfigurationSetName: this.opts.configurationSetName
|
|
42
|
-
})
|
|
44
|
+
}), {
|
|
45
|
+
abortSignal: options?.signal
|
|
46
|
+
});
|
|
43
47
|
if (!result.MessageId) throw new Error("SES returned no MessageId");
|
|
44
48
|
return {
|
|
45
49
|
providerMessageId: result.MessageId,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ses-email.provider.ts"],"sourcesContent":["import type {\n EmailProvider,\n EmailSendParams,\n EmailSendResult,\n} from '@jadedm/nestjs-verify';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport interface SesEmailProviderOptions {\n /** Verified SES identity to send from, e.g. 'no-reply@example.com' or 'Example <no-reply@example.com>'. */\n from: string;\n /** Region of the SES identity, e.g. 'ap-south-1'. Ignored when `client` is given. */\n region?: string;\n /** A configured client, for custom credentials or endpoints. */\n client?: SESv2Client;\n /** Optional SES configuration set, for event publishing. */\n configurationSetName?: string;\n}\n\n/**\n * Sends verification codes through Amazon SES (API v2). Credentials come from\n * the AWS SDK's default chain unless a client is passed. The SDK retries\n * throttling and server errors itself; anything it gives up on is thrown, so\n * the core can try a fallback provider.\n */\nexport class SesEmailProvider implements EmailProvider {\n readonly name = 'ses';\n private readonly client: SESv2Client;\n\n constructor(private readonly opts: SesEmailProviderOptions) {\n this.client = opts.client ?? new SESv2Client({ region: opts.region });\n }\n\n async send(params: EmailSendParams): Promise<EmailSendResult> {\n const result = await this.client.send(\n new SendEmailCommand({\n FromEmailAddress: this.opts.from,\n Destination: { ToAddresses: [params.to] },\n Content: {\n Simple: {\n Subject: { Data: params.subject, Charset: 'UTF-8' },\n Body: { Text: { Data: params.text, Charset: 'UTF-8' } },\n },\n },\n ConfigurationSetName: this.opts.configurationSetName,\n }),\n );\n if (!result.MessageId) throw new Error('SES returned no MessageId');\n return { providerMessageId: result.MessageId, provider: this.name };\n }\n}\n"],"mappings":";;;;AAKA,SAASA,kBAAkBC,mBAAmB;AAmBvC,IAAMC,mBAAN,MAAMA;EAnBb,OAmBaA;;;;EACFC,OAAO;EACCC;EAEjB,YAA6BC,MAA+B;SAA/BA,OAAAA;AAC3B,SAAKD,SAASC,KAAKD,UAAU,IAAIE,YAAY;MAAEC,QAAQF,KAAKE;IAAO,CAAA;EACrE
|
|
1
|
+
{"version":3,"sources":["../src/ses-email.provider.ts"],"sourcesContent":["import type {\n EmailProvider,\n EmailSendParams,\n EmailSendResult,\n} from '@jadedm/nestjs-verify';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\n\nexport interface SesEmailProviderOptions {\n /** Verified SES identity to send from, e.g. 'no-reply@example.com' or 'Example <no-reply@example.com>'. */\n from: string;\n /** Region of the SES identity, e.g. 'ap-south-1'. Ignored when `client` is given. */\n region?: string;\n /** A configured client, for custom credentials or endpoints. */\n client?: SESv2Client;\n /** Optional SES configuration set, for event publishing. */\n configurationSetName?: string;\n}\n\n/**\n * Sends verification codes through Amazon SES (API v2). Credentials come from\n * the AWS SDK's default chain unless a client is passed. The SDK retries\n * throttling and server errors itself; anything it gives up on is thrown, so\n * the core can try a fallback provider.\n */\nexport class SesEmailProvider implements EmailProvider {\n readonly name = 'ses';\n private readonly client: SESv2Client;\n\n constructor(private readonly opts: SesEmailProviderOptions) {\n this.client = opts.client ?? new SESv2Client({ region: opts.region });\n }\n\n // The options type is written out rather than imported, so these\n // declarations still type-check against a core version that lacks it.\n async send(params: EmailSendParams, options?: { signal?: AbortSignal }): Promise<EmailSendResult> {\n const result = await this.client.send(\n new SendEmailCommand({\n FromEmailAddress: this.opts.from,\n Destination: { ToAddresses: [params.to] },\n Content: {\n Simple: {\n Subject: { Data: params.subject, Charset: 'UTF-8' },\n Body: { Text: { Data: params.text, Charset: 'UTF-8' } },\n },\n },\n ConfigurationSetName: this.opts.configurationSetName,\n }),\n { abortSignal: options?.signal },\n );\n if (!result.MessageId) throw new Error('SES returned no MessageId');\n return { providerMessageId: result.MessageId, provider: this.name };\n }\n}\n"],"mappings":";;;;AAKA,SAASA,kBAAkBC,mBAAmB;AAmBvC,IAAMC,mBAAN,MAAMA;EAnBb,OAmBaA;;;;EACFC,OAAO;EACCC;EAEjB,YAA6BC,MAA+B;SAA/BA,OAAAA;AAC3B,SAAKD,SAASC,KAAKD,UAAU,IAAIE,YAAY;MAAEC,QAAQF,KAAKE;IAAO,CAAA;EACrE;;;EAIA,MAAMC,KAAKC,QAAyBC,SAA8D;AAChG,UAAMC,SAAS,MAAM,KAAKP,OAAOI,KAC/B,IAAII,iBAAiB;MACnBC,kBAAkB,KAAKR,KAAKS;MAC5BC,aAAa;QAAEC,aAAa;UAACP,OAAOQ;;MAAI;MACxCC,SAAS;QACPC,QAAQ;UACNC,SAAS;YAAEC,MAAMZ,OAAOa;YAASC,SAAS;UAAQ;UAClDC,MAAM;YAAEC,MAAM;cAAEJ,MAAMZ,OAAOiB;cAAMH,SAAS;YAAQ;UAAE;QACxD;MACF;MACAI,sBAAsB,KAAKtB,KAAKuB;IAClC,CAAA,GACA;MAAEC,aAAanB,SAASoB;IAAO,CAAA;AAEjC,QAAI,CAACnB,OAAOoB,UAAW,OAAM,IAAIC,MAAM,2BAAA;AACvC,WAAO;MAAEC,mBAAmBtB,OAAOoB;MAAWG,UAAU,KAAK/B;IAAK;EACpE;AACF;","names":["SendEmailCommand","SESv2Client","SesEmailProvider","name","client","opts","SESv2Client","region","send","params","options","result","SendEmailCommand","FromEmailAddress","from","Destination","ToAddresses","to","Content","Simple","Subject","Data","subject","Charset","Body","Text","text","ConfigurationSetName","configurationSetName","abortSignal","signal","MessageId","Error","providerMessageId","provider"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jadedm/nestjs-verify-ses",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Amazon SES email provider adapter for @jadedm/nestjs-verify.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"LICENSE"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
41
|
+
"@jadedm/nestjs-verify": ">=0.6.8 <0.8.0",
|
|
42
|
+
"@aws-sdk/client-sesv2": "^3.500.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@aws-sdk/client-sesv2": "^3.500.0",
|
|
46
|
-
"@jadedm/nestjs-verify": "0.
|
|
46
|
+
"@jadedm/nestjs-verify": "0.7.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=20"
|