@jadedm/nestjs-verify-ses 0.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manish Jadhav (jadedm)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @jadedm/nestjs-verify-ses
2
+
3
+ Amazon SES email provider for [`@jadedm/nestjs-verify`](https://www.npmjs.com/package/@jadedm/nestjs-verify). Sends verification codes by email through the SES v2 API.
4
+
5
+ ```bash
6
+ pnpm add @jadedm/nestjs-verify-ses @aws-sdk/client-sesv2
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { VerifyModule } from '@jadedm/nestjs-verify';
13
+ import { SesEmailProvider } from '@jadedm/nestjs-verify-ses';
14
+
15
+ VerifyModule.forRoot({
16
+ email: {
17
+ provider: new SesEmailProvider({
18
+ from: 'Example <no-reply@example.com>', // a verified SES identity
19
+ region: 'ap-south-1',
20
+ configurationSetName: 'otp', // optional
21
+ }),
22
+ subject: 'Your Example sign-in code',
23
+ },
24
+ stores: { /* ... */ },
25
+ });
26
+ ```
27
+
28
+ Start a verification with `channel: 'email'` and an email address in `to`.
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`.
31
+
32
+ ## Errors and retries
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`.
35
+
36
+ ## Requirements
37
+
38
+ Node 20 or newer: current `@aws-sdk/client-sesv2` releases require it, though the core package still supports Node 18.
39
+
40
+ ## Peers
41
+
42
+ - `@jadedm/nestjs-verify` 0.x
43
+ - `@aws-sdk/client-sesv2` 3.x
@@ -0,0 +1,28 @@
1
+ import { EmailProvider, EmailSendParams, EmailSendResult } from '@jadedm/nestjs-verify';
2
+ import { SESv2Client } from '@aws-sdk/client-sesv2';
3
+
4
+ interface SesEmailProviderOptions {
5
+ /** Verified SES identity to send from, e.g. 'no-reply@example.com' or 'Example <no-reply@example.com>'. */
6
+ from: string;
7
+ /** Region of the SES identity, e.g. 'ap-south-1'. Ignored when `client` is given. */
8
+ region?: string;
9
+ /** A configured client, for custom credentials or endpoints. */
10
+ client?: SESv2Client;
11
+ /** Optional SES configuration set, for event publishing. */
12
+ configurationSetName?: string;
13
+ }
14
+ /**
15
+ * Sends verification codes through Amazon SES (API v2). Credentials come from
16
+ * the AWS SDK's default chain unless a client is passed. The SDK retries
17
+ * throttling and server errors itself; anything it gives up on is thrown, so
18
+ * the core can try a fallback provider.
19
+ */
20
+ declare class SesEmailProvider implements EmailProvider {
21
+ private readonly opts;
22
+ readonly name = "ses";
23
+ private readonly client;
24
+ constructor(opts: SesEmailProviderOptions);
25
+ send(params: EmailSendParams): Promise<EmailSendResult>;
26
+ }
27
+
28
+ export { SesEmailProvider, type SesEmailProviderOptions };
@@ -0,0 +1,28 @@
1
+ import { EmailProvider, EmailSendParams, EmailSendResult } from '@jadedm/nestjs-verify';
2
+ import { SESv2Client } from '@aws-sdk/client-sesv2';
3
+
4
+ interface SesEmailProviderOptions {
5
+ /** Verified SES identity to send from, e.g. 'no-reply@example.com' or 'Example <no-reply@example.com>'. */
6
+ from: string;
7
+ /** Region of the SES identity, e.g. 'ap-south-1'. Ignored when `client` is given. */
8
+ region?: string;
9
+ /** A configured client, for custom credentials or endpoints. */
10
+ client?: SESv2Client;
11
+ /** Optional SES configuration set, for event publishing. */
12
+ configurationSetName?: string;
13
+ }
14
+ /**
15
+ * Sends verification codes through Amazon SES (API v2). Credentials come from
16
+ * the AWS SDK's default chain unless a client is passed. The SDK retries
17
+ * throttling and server errors itself; anything it gives up on is thrown, so
18
+ * the core can try a fallback provider.
19
+ */
20
+ declare class SesEmailProvider implements EmailProvider {
21
+ private readonly opts;
22
+ readonly name = "ses";
23
+ private readonly client;
24
+ constructor(opts: SesEmailProviderOptions);
25
+ send(params: EmailSendParams): Promise<EmailSendResult>;
26
+ }
27
+
28
+ export { SesEmailProvider, type SesEmailProviderOptions };
package/dist/index.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ SesEmailProvider: () => SesEmailProvider
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/ses-email.provider.ts
29
+ var import_client_sesv2 = require("@aws-sdk/client-sesv2");
30
+ var SesEmailProvider = class {
31
+ static {
32
+ __name(this, "SesEmailProvider");
33
+ }
34
+ opts;
35
+ name = "ses";
36
+ client;
37
+ constructor(opts) {
38
+ this.opts = opts;
39
+ this.client = opts.client ?? new import_client_sesv2.SESv2Client({
40
+ region: opts.region
41
+ });
42
+ }
43
+ async send(params) {
44
+ const result = await this.client.send(new import_client_sesv2.SendEmailCommand({
45
+ FromEmailAddress: this.opts.from,
46
+ Destination: {
47
+ ToAddresses: [
48
+ params.to
49
+ ]
50
+ },
51
+ Content: {
52
+ Simple: {
53
+ Subject: {
54
+ Data: params.subject,
55
+ Charset: "UTF-8"
56
+ },
57
+ Body: {
58
+ Text: {
59
+ Data: params.text,
60
+ Charset: "UTF-8"
61
+ }
62
+ }
63
+ }
64
+ },
65
+ ConfigurationSetName: this.opts.configurationSetName
66
+ }));
67
+ if (!result.MessageId) throw new Error("SES returned no MessageId");
68
+ return {
69
+ providerMessageId: result.MessageId,
70
+ provider: this.name
71
+ };
72
+ }
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ SesEmailProvider
77
+ });
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;EAEA,MAAMC,KAAKC,QAAmD;AAC5D,UAAMC,SAAS,MAAM,KAAKN,OAAOI,KAC/B,IAAIG,qCAAiB;MACnBC,kBAAkB,KAAKP,KAAKQ;MAC5BC,aAAa;QAAEC,aAAa;UAACN,OAAOO;;MAAI;MACxCC,SAAS;QACPC,QAAQ;UACNC,SAAS;YAAEC,MAAMX,OAAOY;YAASC,SAAS;UAAQ;UAClDC,MAAM;YAAEC,MAAM;cAAEJ,MAAMX,OAAOgB;cAAMH,SAAS;YAAQ;UAAE;QACxD;MACF;MACAI,sBAAsB,KAAKrB,KAAKsB;IAClC,CAAA,CAAA;AAEF,QAAI,CAACjB,OAAOkB,UAAW,OAAM,IAAIC,MAAM,2BAAA;AACvC,WAAO;MAAEC,mBAAmBpB,OAAOkB;MAAWG,UAAU,KAAK5B;IAAK;EACpE;AACF;","names":["SesEmailProvider","name","client","opts","SESv2Client","region","send","params","result","SendEmailCommand","FromEmailAddress","from","Destination","ToAddresses","to","Content","Simple","Subject","Data","subject","Charset","Body","Text","text","ConfigurationSetName","configurationSetName","MessageId","Error","providerMessageId","provider"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/ses-email.provider.ts
5
+ import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2";
6
+ var SesEmailProvider = class {
7
+ static {
8
+ __name(this, "SesEmailProvider");
9
+ }
10
+ opts;
11
+ name = "ses";
12
+ client;
13
+ constructor(opts) {
14
+ this.opts = opts;
15
+ this.client = opts.client ?? new SESv2Client({
16
+ region: opts.region
17
+ });
18
+ }
19
+ async send(params) {
20
+ const result = await this.client.send(new SendEmailCommand({
21
+ FromEmailAddress: this.opts.from,
22
+ Destination: {
23
+ ToAddresses: [
24
+ params.to
25
+ ]
26
+ },
27
+ Content: {
28
+ Simple: {
29
+ Subject: {
30
+ Data: params.subject,
31
+ Charset: "UTF-8"
32
+ },
33
+ Body: {
34
+ Text: {
35
+ Data: params.text,
36
+ Charset: "UTF-8"
37
+ }
38
+ }
39
+ }
40
+ },
41
+ ConfigurationSetName: this.opts.configurationSetName
42
+ }));
43
+ if (!result.MessageId) throw new Error("SES returned no MessageId");
44
+ return {
45
+ providerMessageId: result.MessageId,
46
+ provider: this.name
47
+ };
48
+ }
49
+ };
50
+ export {
51
+ SesEmailProvider
52
+ };
53
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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;EAEA,MAAMC,KAAKC,QAAmD;AAC5D,UAAMC,SAAS,MAAM,KAAKN,OAAOI,KAC/B,IAAIG,iBAAiB;MACnBC,kBAAkB,KAAKP,KAAKQ;MAC5BC,aAAa;QAAEC,aAAa;UAACN,OAAOO;;MAAI;MACxCC,SAAS;QACPC,QAAQ;UACNC,SAAS;YAAEC,MAAMX,OAAOY;YAASC,SAAS;UAAQ;UAClDC,MAAM;YAAEC,MAAM;cAAEJ,MAAMX,OAAOgB;cAAMH,SAAS;YAAQ;UAAE;QACxD;MACF;MACAI,sBAAsB,KAAKrB,KAAKsB;IAClC,CAAA,CAAA;AAEF,QAAI,CAACjB,OAAOkB,UAAW,OAAM,IAAIC,MAAM,2BAAA;AACvC,WAAO;MAAEC,mBAAmBpB,OAAOkB;MAAWG,UAAU,KAAK5B;IAAK;EACpE;AACF;","names":["SendEmailCommand","SESv2Client","SesEmailProvider","name","client","opts","SESv2Client","region","send","params","result","SendEmailCommand","FromEmailAddress","from","Destination","ToAddresses","to","Content","Simple","Subject","Data","subject","Charset","Body","Text","text","ConfigurationSetName","configurationSetName","MessageId","Error","providerMessageId","provider"]}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@jadedm/nestjs-verify-ses",
3
+ "version": "0.6.0",
4
+ "description": "Amazon SES email provider adapter for @jadedm/nestjs-verify.",
5
+ "keywords": [
6
+ "nestjs",
7
+ "otp",
8
+ "verify",
9
+ "ses",
10
+ "email",
11
+ "aws"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "jadedm <jadedmanish@gmail.com>",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/jadedm/nestjs-verify.git",
18
+ "directory": "packages/provider-ses"
19
+ },
20
+ "main": "./dist/index.js",
21
+ "module": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/index.d.mts",
27
+ "default": "./dist/index.mjs"
28
+ },
29
+ "require": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ }
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "peerDependencies": {
41
+ "@aws-sdk/client-sesv2": "^3.500.0",
42
+ "@jadedm/nestjs-verify": "^0.6.0"
43
+ },
44
+ "devDependencies": {
45
+ "@aws-sdk/client-sesv2": "^3.500.0",
46
+ "@jadedm/nestjs-verify": "0.6.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=20"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest run --passWithNoTests",
55
+ "clean": "rm -rf dist"
56
+ }
57
+ }