@smsdora/otp 0.1.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 +21 -0
- package/README.md +138 -0
- package/dist/index.cjs +361 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +200 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +323 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/** Delivery channel. Only SMS is supported at launch. */
|
|
2
|
+
type OtpChannel = 'sms';
|
|
3
|
+
/** Lifecycle state of an OTP challenge. */
|
|
4
|
+
type OtpStatus = 'pending' | 'verified' | 'expired' | 'failed' | 'locked';
|
|
5
|
+
/** Options for constructing a {@link SmsdoraOtp} client. */
|
|
6
|
+
interface SmsdoraOtpOptions {
|
|
7
|
+
/** Secret API key (`smsgw_...`) with the `otp:send` / `otp:verify` scopes. */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** Base URL of your SmsDora backend, e.g. `https://api.example.com`. */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* Shared `OTP_TOKEN_SECRET` from your backend. Required only if you call
|
|
13
|
+
* {@link SmsdoraOtp.verifyToken} to validate verification tokens locally.
|
|
14
|
+
*/
|
|
15
|
+
tokenSecret?: string;
|
|
16
|
+
/** Per-request timeout in milliseconds. Default: 10000. */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
/** Max retry attempts for network / 5xx / 429 failures. Default: 2. */
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
/** Custom fetch implementation (defaults to the global `fetch`). */
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
interface SendOtpParams {
|
|
24
|
+
/** Recipient phone number (E.164 recommended, e.g. `+14155550100`). */
|
|
25
|
+
recipient: string;
|
|
26
|
+
/** Caller tag echoed back in the verification token, e.g. `"login"`. */
|
|
27
|
+
purpose?: string;
|
|
28
|
+
/** Code length, 4–8. Defaults to the backend's configured length. */
|
|
29
|
+
codeLength?: number;
|
|
30
|
+
/** Time-to-live in seconds, 60–900. Defaults to the backend's config. */
|
|
31
|
+
ttlSeconds?: number;
|
|
32
|
+
/** Override the SMS body. Must contain the `{{code}}` placeholder. */
|
|
33
|
+
templateOverride?: string;
|
|
34
|
+
/** Pin delivery to a specific device id (otherwise auto-selected). */
|
|
35
|
+
deviceId?: string;
|
|
36
|
+
/** Opaque data stored on the challenge. */
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Idempotency key for safe retries. Auto-generated per call if omitted.
|
|
40
|
+
* Reusing a key lets the server de-duplicate retried sends.
|
|
41
|
+
*/
|
|
42
|
+
idempotencyKey?: string;
|
|
43
|
+
}
|
|
44
|
+
interface ResendOtpParams {
|
|
45
|
+
challengeId: string;
|
|
46
|
+
}
|
|
47
|
+
interface VerifyOtpParams {
|
|
48
|
+
challengeId: string;
|
|
49
|
+
/** The numeric code the user supplied. */
|
|
50
|
+
code: string;
|
|
51
|
+
}
|
|
52
|
+
/** A challenge as returned by send / resend / getStatus. */
|
|
53
|
+
interface OtpChallenge {
|
|
54
|
+
id: string;
|
|
55
|
+
/** Masked recipient, e.g. `+141******00`. */
|
|
56
|
+
recipient: string;
|
|
57
|
+
purpose: string | null;
|
|
58
|
+
channel: OtpChannel;
|
|
59
|
+
status: OtpStatus;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
resendAvailableAt: string | null;
|
|
62
|
+
attemptsRemaining: number;
|
|
63
|
+
resendsRemaining: number;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
}
|
|
66
|
+
/** Result of a verify attempt. */
|
|
67
|
+
interface VerifyResult {
|
|
68
|
+
verified: boolean;
|
|
69
|
+
status: OtpStatus;
|
|
70
|
+
attemptsRemaining: number;
|
|
71
|
+
/** Present only when `verified` is true. */
|
|
72
|
+
verificationToken?: string;
|
|
73
|
+
verificationTokenExpiresAt?: string;
|
|
74
|
+
}
|
|
75
|
+
/** Decoded verification-token claims. */
|
|
76
|
+
interface VerificationTokenPayload {
|
|
77
|
+
/** Subject — the verified recipient (E.164). */
|
|
78
|
+
sub: string;
|
|
79
|
+
challengeId: string;
|
|
80
|
+
purpose: string | null;
|
|
81
|
+
/** Unique token id. */
|
|
82
|
+
jti: string;
|
|
83
|
+
/** Issued-at (epoch seconds). */
|
|
84
|
+
iat?: number;
|
|
85
|
+
/** Expiry (epoch seconds). */
|
|
86
|
+
exp?: number;
|
|
87
|
+
}
|
|
88
|
+
/** Result of a server-side single-use token check. */
|
|
89
|
+
interface TokenCheckResult {
|
|
90
|
+
recipient: string;
|
|
91
|
+
purpose: string | null;
|
|
92
|
+
challengeId: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Client for the SmsDora OTP API.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* const otp = new SmsdoraOtp({ apiKey: process.env.SMSDORA_KEY!, baseUrl });
|
|
100
|
+
* const challenge = await otp.send({ recipient: '+14155550100', purpose: 'login' });
|
|
101
|
+
* const result = await otp.verify({ challengeId: challenge.id, code });
|
|
102
|
+
* if (result.verified) { ... }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare class SmsdoraOtp {
|
|
106
|
+
private readonly http;
|
|
107
|
+
private readonly tokenSecret?;
|
|
108
|
+
constructor(options: SmsdoraOtpOptions);
|
|
109
|
+
/** Send a one-time passcode to a phone number. */
|
|
110
|
+
send(params: SendOtpParams): Promise<OtpChallenge>;
|
|
111
|
+
/** Re-deliver the code for an existing challenge (subject to cooldown/cap). */
|
|
112
|
+
resend(params: ResendOtpParams): Promise<OtpChallenge>;
|
|
113
|
+
/** Verify a code. Returns a result; does NOT throw on a wrong code. */
|
|
114
|
+
verify(params: VerifyOtpParams): Promise<VerifyResult>;
|
|
115
|
+
/** Fetch the current status of a challenge. */
|
|
116
|
+
getStatus(challengeId: string): Promise<OtpChallenge>;
|
|
117
|
+
/**
|
|
118
|
+
* Validate a verification token locally (no network). Requires `tokenSecret`
|
|
119
|
+
* in the client options. Use this in your auth flow to trust a verification
|
|
120
|
+
* without an extra round-trip.
|
|
121
|
+
*
|
|
122
|
+
* @throws {ConfigError} if no `tokenSecret` was configured.
|
|
123
|
+
* @throws {TokenVerificationError} if the token is invalid/expired.
|
|
124
|
+
*/
|
|
125
|
+
verifyToken(token: string): VerificationTokenPayload;
|
|
126
|
+
/**
|
|
127
|
+
* Validate a verification token on the server with single-use enforcement.
|
|
128
|
+
* Marks the token consumed so it cannot be replayed.
|
|
129
|
+
*/
|
|
130
|
+
verifyTokenRemote(token: string): Promise<TokenCheckResult>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Verify a SmsDora verification token (HS256 JWT) locally — no network call.
|
|
135
|
+
* Checks the signature against `secret` and enforces `exp` / `nbf`.
|
|
136
|
+
*
|
|
137
|
+
* @throws {TokenVerificationError} if malformed, wrong algorithm, bad
|
|
138
|
+
* signature, or expired.
|
|
139
|
+
*/
|
|
140
|
+
declare function verifyVerificationToken(token: string, secret: string): VerificationTokenPayload;
|
|
141
|
+
|
|
142
|
+
/** Stable error codes — safe to branch on across SDK versions. */
|
|
143
|
+
type SmsdoraOtpErrorCode = 'config_error' | 'auth_error' | 'validation_error' | 'not_found' | 'rate_limited' | 'delivery_failed' | 'server_error' | 'network_error' | 'token_invalid';
|
|
144
|
+
interface SmsdoraOtpErrorContext {
|
|
145
|
+
code: SmsdoraOtpErrorCode;
|
|
146
|
+
/** HTTP status, when the error originated from a response. */
|
|
147
|
+
status?: number;
|
|
148
|
+
/** Server request id, if provided. */
|
|
149
|
+
requestId?: string;
|
|
150
|
+
/** Underlying cause (e.g. a fetch error). */
|
|
151
|
+
cause?: unknown;
|
|
152
|
+
}
|
|
153
|
+
/** Base class for every error the SDK throws. */
|
|
154
|
+
declare class SmsdoraOtpError extends Error {
|
|
155
|
+
readonly code: SmsdoraOtpErrorCode;
|
|
156
|
+
readonly status?: number;
|
|
157
|
+
readonly requestId?: string;
|
|
158
|
+
constructor(message: string, ctx: SmsdoraOtpErrorContext);
|
|
159
|
+
}
|
|
160
|
+
/** Missing/invalid client configuration (no apiKey, no tokenSecret, …). */
|
|
161
|
+
declare class ConfigError extends SmsdoraOtpError {
|
|
162
|
+
constructor(message: string);
|
|
163
|
+
}
|
|
164
|
+
/** 401 / 403 — bad or unauthorized API key, scope, or publishable restriction. */
|
|
165
|
+
declare class AuthError extends SmsdoraOtpError {
|
|
166
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
167
|
+
}
|
|
168
|
+
/** 400 — invalid request parameters. */
|
|
169
|
+
declare class ValidationError extends SmsdoraOtpError {
|
|
170
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
171
|
+
}
|
|
172
|
+
/** 404 — challenge/key not found. */
|
|
173
|
+
declare class NotFoundError extends SmsdoraOtpError {
|
|
174
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
175
|
+
}
|
|
176
|
+
/** 429 — a rate/abuse cap was hit. Inspect {@link retryAfterSeconds}. */
|
|
177
|
+
declare class RateLimitError extends SmsdoraOtpError {
|
|
178
|
+
readonly retryAfterSeconds?: number;
|
|
179
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'> & {
|
|
180
|
+
retryAfterSeconds?: number;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** 502 — the code could not be delivered (no online device / FCM failure). */
|
|
184
|
+
declare class DeliveryError extends SmsdoraOtpError {
|
|
185
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
186
|
+
}
|
|
187
|
+
/** 5xx — an unexpected server error. */
|
|
188
|
+
declare class ServerError extends SmsdoraOtpError {
|
|
189
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
190
|
+
}
|
|
191
|
+
/** Transport failure — connection refused, DNS, timeout, aborted. */
|
|
192
|
+
declare class NetworkError extends SmsdoraOtpError {
|
|
193
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
194
|
+
}
|
|
195
|
+
/** A verification token failed local or remote validation. */
|
|
196
|
+
declare class TokenVerificationError extends SmsdoraOtpError {
|
|
197
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { AuthError, ConfigError, DeliveryError, NetworkError, NotFoundError, type OtpChallenge, type OtpChannel, type OtpStatus, RateLimitError, type ResendOtpParams, type SendOtpParams, ServerError, SmsdoraOtp, SmsdoraOtpError, type SmsdoraOtpErrorCode, type SmsdoraOtpOptions, type TokenCheckResult, TokenVerificationError, ValidationError, type VerificationTokenPayload, type VerifyOtpParams, type VerifyResult, verifyVerificationToken };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/** Delivery channel. Only SMS is supported at launch. */
|
|
2
|
+
type OtpChannel = 'sms';
|
|
3
|
+
/** Lifecycle state of an OTP challenge. */
|
|
4
|
+
type OtpStatus = 'pending' | 'verified' | 'expired' | 'failed' | 'locked';
|
|
5
|
+
/** Options for constructing a {@link SmsdoraOtp} client. */
|
|
6
|
+
interface SmsdoraOtpOptions {
|
|
7
|
+
/** Secret API key (`smsgw_...`) with the `otp:send` / `otp:verify` scopes. */
|
|
8
|
+
apiKey: string;
|
|
9
|
+
/** Base URL of your SmsDora backend, e.g. `https://api.example.com`. */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* Shared `OTP_TOKEN_SECRET` from your backend. Required only if you call
|
|
13
|
+
* {@link SmsdoraOtp.verifyToken} to validate verification tokens locally.
|
|
14
|
+
*/
|
|
15
|
+
tokenSecret?: string;
|
|
16
|
+
/** Per-request timeout in milliseconds. Default: 10000. */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
/** Max retry attempts for network / 5xx / 429 failures. Default: 2. */
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
/** Custom fetch implementation (defaults to the global `fetch`). */
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
interface SendOtpParams {
|
|
24
|
+
/** Recipient phone number (E.164 recommended, e.g. `+14155550100`). */
|
|
25
|
+
recipient: string;
|
|
26
|
+
/** Caller tag echoed back in the verification token, e.g. `"login"`. */
|
|
27
|
+
purpose?: string;
|
|
28
|
+
/** Code length, 4–8. Defaults to the backend's configured length. */
|
|
29
|
+
codeLength?: number;
|
|
30
|
+
/** Time-to-live in seconds, 60–900. Defaults to the backend's config. */
|
|
31
|
+
ttlSeconds?: number;
|
|
32
|
+
/** Override the SMS body. Must contain the `{{code}}` placeholder. */
|
|
33
|
+
templateOverride?: string;
|
|
34
|
+
/** Pin delivery to a specific device id (otherwise auto-selected). */
|
|
35
|
+
deviceId?: string;
|
|
36
|
+
/** Opaque data stored on the challenge. */
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Idempotency key for safe retries. Auto-generated per call if omitted.
|
|
40
|
+
* Reusing a key lets the server de-duplicate retried sends.
|
|
41
|
+
*/
|
|
42
|
+
idempotencyKey?: string;
|
|
43
|
+
}
|
|
44
|
+
interface ResendOtpParams {
|
|
45
|
+
challengeId: string;
|
|
46
|
+
}
|
|
47
|
+
interface VerifyOtpParams {
|
|
48
|
+
challengeId: string;
|
|
49
|
+
/** The numeric code the user supplied. */
|
|
50
|
+
code: string;
|
|
51
|
+
}
|
|
52
|
+
/** A challenge as returned by send / resend / getStatus. */
|
|
53
|
+
interface OtpChallenge {
|
|
54
|
+
id: string;
|
|
55
|
+
/** Masked recipient, e.g. `+141******00`. */
|
|
56
|
+
recipient: string;
|
|
57
|
+
purpose: string | null;
|
|
58
|
+
channel: OtpChannel;
|
|
59
|
+
status: OtpStatus;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
resendAvailableAt: string | null;
|
|
62
|
+
attemptsRemaining: number;
|
|
63
|
+
resendsRemaining: number;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
}
|
|
66
|
+
/** Result of a verify attempt. */
|
|
67
|
+
interface VerifyResult {
|
|
68
|
+
verified: boolean;
|
|
69
|
+
status: OtpStatus;
|
|
70
|
+
attemptsRemaining: number;
|
|
71
|
+
/** Present only when `verified` is true. */
|
|
72
|
+
verificationToken?: string;
|
|
73
|
+
verificationTokenExpiresAt?: string;
|
|
74
|
+
}
|
|
75
|
+
/** Decoded verification-token claims. */
|
|
76
|
+
interface VerificationTokenPayload {
|
|
77
|
+
/** Subject — the verified recipient (E.164). */
|
|
78
|
+
sub: string;
|
|
79
|
+
challengeId: string;
|
|
80
|
+
purpose: string | null;
|
|
81
|
+
/** Unique token id. */
|
|
82
|
+
jti: string;
|
|
83
|
+
/** Issued-at (epoch seconds). */
|
|
84
|
+
iat?: number;
|
|
85
|
+
/** Expiry (epoch seconds). */
|
|
86
|
+
exp?: number;
|
|
87
|
+
}
|
|
88
|
+
/** Result of a server-side single-use token check. */
|
|
89
|
+
interface TokenCheckResult {
|
|
90
|
+
recipient: string;
|
|
91
|
+
purpose: string | null;
|
|
92
|
+
challengeId: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Client for the SmsDora OTP API.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* const otp = new SmsdoraOtp({ apiKey: process.env.SMSDORA_KEY!, baseUrl });
|
|
100
|
+
* const challenge = await otp.send({ recipient: '+14155550100', purpose: 'login' });
|
|
101
|
+
* const result = await otp.verify({ challengeId: challenge.id, code });
|
|
102
|
+
* if (result.verified) { ... }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare class SmsdoraOtp {
|
|
106
|
+
private readonly http;
|
|
107
|
+
private readonly tokenSecret?;
|
|
108
|
+
constructor(options: SmsdoraOtpOptions);
|
|
109
|
+
/** Send a one-time passcode to a phone number. */
|
|
110
|
+
send(params: SendOtpParams): Promise<OtpChallenge>;
|
|
111
|
+
/** Re-deliver the code for an existing challenge (subject to cooldown/cap). */
|
|
112
|
+
resend(params: ResendOtpParams): Promise<OtpChallenge>;
|
|
113
|
+
/** Verify a code. Returns a result; does NOT throw on a wrong code. */
|
|
114
|
+
verify(params: VerifyOtpParams): Promise<VerifyResult>;
|
|
115
|
+
/** Fetch the current status of a challenge. */
|
|
116
|
+
getStatus(challengeId: string): Promise<OtpChallenge>;
|
|
117
|
+
/**
|
|
118
|
+
* Validate a verification token locally (no network). Requires `tokenSecret`
|
|
119
|
+
* in the client options. Use this in your auth flow to trust a verification
|
|
120
|
+
* without an extra round-trip.
|
|
121
|
+
*
|
|
122
|
+
* @throws {ConfigError} if no `tokenSecret` was configured.
|
|
123
|
+
* @throws {TokenVerificationError} if the token is invalid/expired.
|
|
124
|
+
*/
|
|
125
|
+
verifyToken(token: string): VerificationTokenPayload;
|
|
126
|
+
/**
|
|
127
|
+
* Validate a verification token on the server with single-use enforcement.
|
|
128
|
+
* Marks the token consumed so it cannot be replayed.
|
|
129
|
+
*/
|
|
130
|
+
verifyTokenRemote(token: string): Promise<TokenCheckResult>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Verify a SmsDora verification token (HS256 JWT) locally — no network call.
|
|
135
|
+
* Checks the signature against `secret` and enforces `exp` / `nbf`.
|
|
136
|
+
*
|
|
137
|
+
* @throws {TokenVerificationError} if malformed, wrong algorithm, bad
|
|
138
|
+
* signature, or expired.
|
|
139
|
+
*/
|
|
140
|
+
declare function verifyVerificationToken(token: string, secret: string): VerificationTokenPayload;
|
|
141
|
+
|
|
142
|
+
/** Stable error codes — safe to branch on across SDK versions. */
|
|
143
|
+
type SmsdoraOtpErrorCode = 'config_error' | 'auth_error' | 'validation_error' | 'not_found' | 'rate_limited' | 'delivery_failed' | 'server_error' | 'network_error' | 'token_invalid';
|
|
144
|
+
interface SmsdoraOtpErrorContext {
|
|
145
|
+
code: SmsdoraOtpErrorCode;
|
|
146
|
+
/** HTTP status, when the error originated from a response. */
|
|
147
|
+
status?: number;
|
|
148
|
+
/** Server request id, if provided. */
|
|
149
|
+
requestId?: string;
|
|
150
|
+
/** Underlying cause (e.g. a fetch error). */
|
|
151
|
+
cause?: unknown;
|
|
152
|
+
}
|
|
153
|
+
/** Base class for every error the SDK throws. */
|
|
154
|
+
declare class SmsdoraOtpError extends Error {
|
|
155
|
+
readonly code: SmsdoraOtpErrorCode;
|
|
156
|
+
readonly status?: number;
|
|
157
|
+
readonly requestId?: string;
|
|
158
|
+
constructor(message: string, ctx: SmsdoraOtpErrorContext);
|
|
159
|
+
}
|
|
160
|
+
/** Missing/invalid client configuration (no apiKey, no tokenSecret, …). */
|
|
161
|
+
declare class ConfigError extends SmsdoraOtpError {
|
|
162
|
+
constructor(message: string);
|
|
163
|
+
}
|
|
164
|
+
/** 401 / 403 — bad or unauthorized API key, scope, or publishable restriction. */
|
|
165
|
+
declare class AuthError extends SmsdoraOtpError {
|
|
166
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
167
|
+
}
|
|
168
|
+
/** 400 — invalid request parameters. */
|
|
169
|
+
declare class ValidationError extends SmsdoraOtpError {
|
|
170
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
171
|
+
}
|
|
172
|
+
/** 404 — challenge/key not found. */
|
|
173
|
+
declare class NotFoundError extends SmsdoraOtpError {
|
|
174
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
175
|
+
}
|
|
176
|
+
/** 429 — a rate/abuse cap was hit. Inspect {@link retryAfterSeconds}. */
|
|
177
|
+
declare class RateLimitError extends SmsdoraOtpError {
|
|
178
|
+
readonly retryAfterSeconds?: number;
|
|
179
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'> & {
|
|
180
|
+
retryAfterSeconds?: number;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** 502 — the code could not be delivered (no online device / FCM failure). */
|
|
184
|
+
declare class DeliveryError extends SmsdoraOtpError {
|
|
185
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
186
|
+
}
|
|
187
|
+
/** 5xx — an unexpected server error. */
|
|
188
|
+
declare class ServerError extends SmsdoraOtpError {
|
|
189
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
190
|
+
}
|
|
191
|
+
/** Transport failure — connection refused, DNS, timeout, aborted. */
|
|
192
|
+
declare class NetworkError extends SmsdoraOtpError {
|
|
193
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
194
|
+
}
|
|
195
|
+
/** A verification token failed local or remote validation. */
|
|
196
|
+
declare class TokenVerificationError extends SmsdoraOtpError {
|
|
197
|
+
constructor(message: string, ctx?: Omit<SmsdoraOtpErrorContext, 'code'>);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { AuthError, ConfigError, DeliveryError, NetworkError, NotFoundError, type OtpChallenge, type OtpChannel, type OtpStatus, RateLimitError, type ResendOtpParams, type SendOtpParams, ServerError, SmsdoraOtp, SmsdoraOtpError, type SmsdoraOtpErrorCode, type SmsdoraOtpOptions, type TokenCheckResult, TokenVerificationError, ValidationError, type VerificationTokenPayload, type VerifyOtpParams, type VerifyResult, verifyVerificationToken };
|