@minimoth/sdk-node 0.1.0 → 0.1.2
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 +16 -7
- package/package.json +21 -3
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ const client = new MiniMoth({
|
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
// Send OTP
|
|
23
|
-
await client.otp.send({ phone: '919876543210' })
|
|
23
|
+
const { otpId } = await client.otp.send({ phone: '919876543210' })
|
|
24
24
|
|
|
25
25
|
// Verify OTP
|
|
26
26
|
const result = await client.otp.verify({ phone: '919876543210', otp: '123456' })
|
|
@@ -133,9 +133,17 @@ const { session } = result
|
|
|
133
133
|
Send an OTP to the given phone number.
|
|
134
134
|
|
|
135
135
|
- `phone` (string, required): Indian phone number (e.g. `919876543210`)
|
|
136
|
-
- Returns: Promise<
|
|
136
|
+
- Returns: `Promise<{ otpId: string }>`
|
|
137
137
|
- Throws: `MiniMothError` on rate limit or network error
|
|
138
138
|
|
|
139
|
+
#### `status(otpId)`
|
|
140
|
+
|
|
141
|
+
Check the delivery status of a sent OTP.
|
|
142
|
+
|
|
143
|
+
- `otpId` (string, required): ID returned by `send()`
|
|
144
|
+
- Returns: `Promise<{ otpId: string, channel: string | null, status: 'queued' | 'delivered' | 'failed', deliveredAt: string | null }>`
|
|
145
|
+
- Throws: `MiniMothError` on invalid ID or network error
|
|
146
|
+
|
|
139
147
|
#### `verify(options)`
|
|
140
148
|
|
|
141
149
|
Verify the OTP code and establish a session.
|
|
@@ -184,11 +192,12 @@ Revoke all tokens for a session.
|
|
|
184
192
|
Common `MiniMothError.code` values:
|
|
185
193
|
|
|
186
194
|
- `INVALID_OTP`: OTP code does not match
|
|
187
|
-
- `
|
|
188
|
-
- `
|
|
189
|
-
- `
|
|
190
|
-
- `
|
|
191
|
-
- `
|
|
195
|
+
- `OTP_NOT_FOUND`: No active OTP found — expired (10 min) or already used
|
|
196
|
+
- `OTP_RATE_LIMITED`: Too many OTP requests for this number — wait 10 minutes
|
|
197
|
+
- `VERIFY_RATE_LIMITED`: Too many incorrect attempts for this OTP — request a new one
|
|
198
|
+
- `INVALID_ACCESS_TOKEN`: Access token is invalid or expired
|
|
199
|
+
- `SESSION_EXPIRED`: Session has expired or was revoked — user must re-verify
|
|
200
|
+
- `INVALID_PHONE`: Phone number format is invalid
|
|
192
201
|
- `INSUFFICIENT_BALANCE`: Account has insufficient credits/balance
|
|
193
202
|
- `NETWORK_ERROR`: Network request failed
|
|
194
203
|
- `UNKNOWN_ERROR`: Unexpected server error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minimoth/sdk-node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Official MiniMoth Node.js SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -13,8 +13,26 @@
|
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
17
|
-
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"email": "dev@minimoth.dev"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"otp",
|
|
25
|
+
"sms",
|
|
26
|
+
"authentication",
|
|
27
|
+
"india",
|
|
28
|
+
"session",
|
|
29
|
+
"sdk",
|
|
30
|
+
"minimoth",
|
|
31
|
+
"whatsapp"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
18
36
|
"scripts": {
|
|
19
37
|
"build": "tsup",
|
|
20
38
|
"test": "vitest run --reporter=verbose",
|