@nauth-toolkit/sms-aws-sns 0.1.3 → 0.1.6
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 +4 -158
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,163 +1,9 @@
|
|
|
1
1
|
# @nauth-toolkit/sms-aws-sns
|
|
2
2
|
|
|
3
|
-
AWS SNS SMS provider for nauth-toolkit
|
|
3
|
+
AWS SNS SMS provider for nauth-toolkit
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Preview Release Notice
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- ✅ **AWS SNS** - Reliable SMS delivery via AWS Simple Notification Service
|
|
9
|
-
- ✅ **Transactional** - All messages sent with highest priority
|
|
10
|
-
- ✅ **Simple** - Minimal configuration, lean implementation
|
|
11
|
-
- ✅ **Configuration Sets** - Optional CloudWatch metrics and event tracking
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
yarn add @nauth-toolkit/sms-aws-sns
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Note:** `@aws-sdk/client-sns` is automatically installed as a dependency.
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### With IAM Role (Recommended)
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { AWSSMSProvider, AWSSMSConfig } from '@nauth-toolkit/sms-aws-sns';
|
|
27
|
-
import { AuthModule } from '@nauth-toolkit/nestjs';
|
|
28
|
-
|
|
29
|
-
// Credentials auto-discovered from IAM role (EC2, ECS, Lambda)
|
|
30
|
-
const config: AWSSMSConfig = {
|
|
31
|
-
region: 'us-east-1',
|
|
32
|
-
originationNumber: '+12345678901',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
@Module({
|
|
36
|
-
imports: [
|
|
37
|
-
AuthModule.forRoot({
|
|
38
|
-
sms: {
|
|
39
|
-
provider: new AWSSMSProvider(config),
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
|
-
],
|
|
43
|
-
})
|
|
44
|
-
export class AppModule {}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### With Explicit Credentials
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
// If not using IAM role, provide credentials explicitly
|
|
51
|
-
const config: AWSSMSConfig = {
|
|
52
|
-
region: 'us-east-1',
|
|
53
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
|
54
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
55
|
-
originationNumber: '+12345678901',
|
|
56
|
-
};
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### With Configuration Set
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
const config: AWSSMSConfig = {
|
|
63
|
-
region: 'us-east-1',
|
|
64
|
-
originationNumber: '+12345678901',
|
|
65
|
-
configurationSetName: 'my-sms-tracking', // Optional: for CloudWatch metrics
|
|
66
|
-
};
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Configuration
|
|
70
|
-
|
|
71
|
-
### Required
|
|
72
|
-
|
|
73
|
-
- `region`: AWS Region (e.g., `'us-east-1'`)
|
|
74
|
-
- `originationNumber`: Phone number (E.164) or sender ID
|
|
75
|
-
|
|
76
|
-
### Optional
|
|
77
|
-
|
|
78
|
-
- `accessKeyId`: AWS Access Key ID (auto-discovered if not provided)
|
|
79
|
-
- `secretAccessKey`: AWS Secret Access Key (required if accessKeyId provided)
|
|
80
|
-
- `configurationSetName`: AWS SNS configuration set name
|
|
81
|
-
|
|
82
|
-
### Credential Discovery
|
|
83
|
-
|
|
84
|
-
AWS SDK automatically discovers credentials from:
|
|
85
|
-
1. **IAM Instance Role** (EC2, ECS, Lambda) - Recommended
|
|
86
|
-
2. **Environment Variables** (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
|
|
87
|
-
3. **AWS Credentials File** (`~/.aws/credentials`)
|
|
88
|
-
4. **AWS Profile** (`AWS_PROFILE` environment variable)
|
|
89
|
-
|
|
90
|
-
Only provide `accessKeyId` and `secretAccessKey` if none of the above are available.
|
|
91
|
-
|
|
92
|
-
### Origination Number
|
|
93
|
-
|
|
94
|
-
**US/Canada** - Must use phone number:
|
|
95
|
-
```typescript
|
|
96
|
-
originationNumber: '+12345678901' // E.164 format
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**Other Regions** - Can use sender ID:
|
|
100
|
-
```typescript
|
|
101
|
-
originationNumber: 'MyApp' // Alphanumeric, max 11 chars
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## AWS Setup
|
|
105
|
-
|
|
106
|
-
### 1. IAM Permissions
|
|
107
|
-
|
|
108
|
-
```json
|
|
109
|
-
{
|
|
110
|
-
"Version": "2012-10-17",
|
|
111
|
-
"Statement": [
|
|
112
|
-
{
|
|
113
|
-
"Effect": "Allow",
|
|
114
|
-
"Action": ["sns:Publish"],
|
|
115
|
-
"Resource": "*"
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### 2. Origination Number
|
|
122
|
-
|
|
123
|
-
**US/Canada:**
|
|
124
|
-
- Go to AWS Console → Amazon Pinpoint → Phone numbers
|
|
125
|
-
- Request a phone number (long code or toll-free)
|
|
126
|
-
- Use in `originationNumber`
|
|
127
|
-
|
|
128
|
-
**Other Regions:**
|
|
129
|
-
- Can use alphanumeric sender ID (no setup required in most countries)
|
|
130
|
-
|
|
131
|
-
### 3. Configuration Set (Optional)
|
|
132
|
-
|
|
133
|
-
Configure in AWS Console for:
|
|
134
|
-
- CloudWatch metrics
|
|
135
|
-
- Delivery status tracking
|
|
136
|
-
- Event destinations (Kinesis, SQS)
|
|
137
|
-
- Spend limits
|
|
138
|
-
|
|
139
|
-
Reference the configuration set name in your config:
|
|
140
|
-
```typescript
|
|
141
|
-
configurationSetName: 'my-sms-tracking'
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Platform-Agnostic Design
|
|
145
|
-
|
|
146
|
-
This package is **framework-agnostic** and works with:
|
|
147
|
-
|
|
148
|
-
- ✅ **NestJS** (via `@nauth-toolkit/nestjs`)
|
|
149
|
-
- 🚧 **Express** (adapter coming soon)
|
|
150
|
-
- 🚧 **Fastify** (adapter coming soon)
|
|
151
|
-
|
|
152
|
-
The `AWSSMSProvider` is a pure TypeScript class with no framework dependencies.
|
|
153
|
-
|
|
154
|
-
## Related Packages
|
|
155
|
-
|
|
156
|
-
- `@nauth-toolkit/core` - Core authentication services
|
|
157
|
-
- `@nauth-toolkit/sms-console` - Console SMS provider (dev only)
|
|
158
|
-
- `@nauth-toolkit/nestjs` - NestJS adapter (for NestJS apps)
|
|
159
|
-
|
|
160
|
-
## License
|
|
161
|
-
|
|
162
|
-
MIT
|
|
7
|
+
**This is a preview release for internal testing. Do not use in production yet.**
|
|
163
8
|
|
|
9
|
+
This package is part of nauth-toolkit and is currently in early access/preview. Features and APIs may change between releases. For production use, please wait for the stable v1.0 release.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/sms-aws-sns",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "AWS SNS SMS provider for nauth-toolkit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@aws-sdk/client-sns": "^3.0.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@nauth-toolkit/core": "^0.1.
|
|
20
|
+
"@nauth-toolkit/core": "^0.1.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/jest": "^29.5.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|
|
34
|
-
"tag": "
|
|
34
|
+
"tag": "latest"
|
|
35
35
|
},
|
|
36
36
|
"license": "UNLICENSED",
|
|
37
37
|
"keywords": [
|