@absolutejs/auth 0.57.9 → 0.58.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/dist/types.d.ts CHANGED
@@ -12,6 +12,7 @@ import type { AuthIdentityConflict } from './errors';
12
12
  import type { AuthHtmxConfig, AuthHtmxUser } from './htmx/types';
13
13
  import type { LockoutConfig } from './lockout/config';
14
14
  import type { MfaConfig } from './mfa/config';
15
+ import type { VerificationProvider } from './verification/types';
15
16
  import type { OidcProviderConfig } from './oidc/config';
16
17
  import type { OrganizationsConfig } from './organizations/config';
17
18
  import type { PasswordlessConfig } from './passwordless/config';
@@ -286,7 +287,7 @@ export type AuthConfig<UserType> = {
286
287
  * mounts register / verify-email / login / reset-password routes that produce the
287
288
  * same `SessionData<UserType>` as OAuth, transparent to `protectRoute`. */
288
289
  credentials?: CredentialsConfig<NoInfer<UserType>>;
289
- /** Passwordless login: magic links + email/SMS OTP. When present, mounts the magic-link flow
290
+ /** Passwordless login: magic links + email OTP. When present, mounts the magic-link flow
290
291
  * (if `onSendMagicLink` is set) and/or the OTP flow (if `onSendOtp` is set) under
291
292
  * `{passwordlessRoute}`; each verify route resolves the email to a user and mints the same
292
293
  * `SessionData<UserType>` as every other flow. */
@@ -295,6 +296,9 @@ export type AuthConfig<UserType> = {
295
296
  * `auth()` auto-wires the login MFA gate, mounts the enroll/challenge routes, and
296
297
  * promotes the parked session once a factor is verified. */
297
298
  mfa?: MfaConfig<NoInfer<UserType>>;
299
+ /** Provider-managed phone verification (Twilio Verify, etc.). When absent,
300
+ * MFA can use the built-in locally generated code flow through onSendSmsCode. */
301
+ verificationProvider?: VerificationProvider;
298
302
  /** Per-identity attempt throttling + account lockout on the credential login route
299
303
  * (progressive: locks after `maxAttempts` failures within `windowMs`). */
300
304
  lockout?: LockoutConfig;
@@ -0,0 +1,47 @@
1
+ /** Stable purposes let providers apply separate templates, limits, and audit policy. */
2
+ export type VerificationPurpose = 'mfa_challenge' | 'mfa_enrollment';
3
+ export type VerificationStartInput = {
4
+ channel: 'sms';
5
+ purpose: VerificationPurpose;
6
+ /** Stable application subject. Providers must not include it in message text. */
7
+ subject: string;
8
+ /** E.164 destination. */
9
+ to: string;
10
+ };
11
+ export type VerificationStartResult = {
12
+ /** Provider reference safe for audit correlation (for example, a Twilio VE SID). */
13
+ reference: string;
14
+ /** Provider-authoritative expiry. Auth rejects checks after this time. */
15
+ expiresAt: number;
16
+ };
17
+ export type VerificationCheckStatus = 'approved' | 'canceled' | 'expired' | 'failed' | 'max_attempts_reached' | 'pending';
18
+ export type VerificationCheckInput = VerificationStartInput & {
19
+ code: string;
20
+ /** Exact challenge reference returned by start(). */
21
+ reference: string;
22
+ };
23
+ export type VerificationCheckResult = {
24
+ reference?: string;
25
+ status: VerificationCheckStatus;
26
+ };
27
+ export type VerificationProviderErrorKind = 'invalid_destination' | 'rate_limited' | 'unavailable';
28
+ /** Normalized operational failures that auth routes can map safely to HTTP. */
29
+ export declare class VerificationProviderError extends Error {
30
+ readonly kind: VerificationProviderErrorKind;
31
+ readonly provider: string;
32
+ constructor(input: {
33
+ cause?: unknown;
34
+ kind: VerificationProviderErrorKind;
35
+ message: string;
36
+ provider: string;
37
+ });
38
+ }
39
+ /**
40
+ * Provider-owned out-of-band challenge lifecycle. Implementations generate,
41
+ * deliver, rate-limit, and check codes; auth owns enrollment and session policy.
42
+ */
43
+ export type VerificationProvider = {
44
+ readonly name: string;
45
+ check: (input: VerificationCheckInput) => Promise<VerificationCheckResult>;
46
+ start: (input: VerificationStartInput) => Promise<VerificationStartResult>;
47
+ };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.57.9",
2
+ "version": "0.58.0",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {