tempest-express-sdk 0.5.0 → 0.7.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/README.md +4 -5
- package/dist/chunk-PKUUVK7K.js +6 -0
- package/dist/{chunk-ZU6W433I.js.map → chunk-PKUUVK7K.js.map} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +427 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +370 -6
- package/dist/index.d.ts +370 -6
- package/dist/index.js +416 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ZU6W433I.js +0 -6
package/dist/index.d.cts
CHANGED
|
@@ -2312,23 +2312,30 @@ declare const inboundMessageSchema: z.ZodObject<{
|
|
|
2312
2312
|
type InboundMessage = z.infer<typeof inboundMessageSchema>;
|
|
2313
2313
|
/** Handler invoked for each inbound message. */
|
|
2314
2314
|
type InboundHandler = (message: InboundMessage) => Promise<void> | void;
|
|
2315
|
-
/**
|
|
2315
|
+
/**
|
|
2316
|
+
* A channel-agnostic messaging provider. `sendText`/`sendMedia`/`status` are
|
|
2317
|
+
* universal; `checkNumber` and `onMessage` are optional because not every
|
|
2318
|
+
* channel supports them (e.g. SMS has no persistent subscription — its inbound
|
|
2319
|
+
* arrives via a webhook receiver instead).
|
|
2320
|
+
*/
|
|
2316
2321
|
interface MessagingProvider {
|
|
2317
2322
|
/** Send a text message. */
|
|
2318
2323
|
sendText(to: string, text: string, options?: SendOptions): Promise<OutboundResult>;
|
|
2319
2324
|
/** Send a media message. */
|
|
2320
2325
|
sendMedia(to: string, media: OutboundMedia, options?: SendOptions): Promise<OutboundResult>;
|
|
2321
|
-
/** Whether a number exists on the channel. */
|
|
2322
|
-
checkNumber(number: string): Promise<boolean>;
|
|
2323
2326
|
/** The current session/connection status. */
|
|
2324
2327
|
status(): Promise<string>;
|
|
2328
|
+
/** Whether a number/handle exists on the channel (when supported). */
|
|
2329
|
+
checkNumber?(number: string): Promise<boolean>;
|
|
2325
2330
|
/**
|
|
2326
2331
|
* Subscribe to inbound messages; resolves to an unsubscribe function.
|
|
2332
|
+
* Present only on channels with a live subscription (WhatsApp `/ws`,
|
|
2333
|
+
* Telegram long-polling).
|
|
2327
2334
|
*
|
|
2328
2335
|
* @param handler - Invoked for each inbound message.
|
|
2329
2336
|
* @param room - Conversation to scope to; `"*"` for all. Default `"*"`.
|
|
2330
2337
|
*/
|
|
2331
|
-
onMessage(handler: InboundHandler, room?: string): Promise<() => Promise<void>>;
|
|
2338
|
+
onMessage?(handler: InboundHandler, room?: string): Promise<() => Promise<void>>;
|
|
2332
2339
|
}
|
|
2333
2340
|
|
|
2334
2341
|
/**
|
|
@@ -2398,6 +2405,113 @@ interface WhatsAppWebhookOptions {
|
|
|
2398
2405
|
*/
|
|
2399
2406
|
declare function makeWhatsAppWebhookRouter(options: WhatsAppWebhookOptions): Router;
|
|
2400
2407
|
|
|
2408
|
+
/**
|
|
2409
|
+
* Telegram provider — a client for the Telegram Bot API.
|
|
2410
|
+
*
|
|
2411
|
+
* Implements {@link MessagingProvider} over the built-in {@link HTTPClient}
|
|
2412
|
+
* (no external SDK). Outbound via `sendMessage`/`sendPhoto`/…; inbound via
|
|
2413
|
+
* `getUpdates` long-polling exposed through {@link TelegramProvider.onMessage}.
|
|
2414
|
+
*/
|
|
2415
|
+
|
|
2416
|
+
/** Options for {@link TelegramProvider}. */
|
|
2417
|
+
interface TelegramProviderOptions {
|
|
2418
|
+
/** Bot token from @BotFather. */
|
|
2419
|
+
token: string;
|
|
2420
|
+
/** API base. Default `https://api.telegram.org`. */
|
|
2421
|
+
apiBase?: string;
|
|
2422
|
+
/** Long-poll timeout in seconds for `getUpdates`. Default 30. */
|
|
2423
|
+
pollTimeoutSeconds?: number;
|
|
2424
|
+
}
|
|
2425
|
+
/** A typed Telegram Bot API client. */
|
|
2426
|
+
declare class TelegramProvider implements MessagingProvider {
|
|
2427
|
+
private readonly http;
|
|
2428
|
+
private readonly pollTimeout;
|
|
2429
|
+
/**
|
|
2430
|
+
* @param options - Bot token and API options.
|
|
2431
|
+
*/
|
|
2432
|
+
constructor(options: TelegramProviderOptions);
|
|
2433
|
+
/** Call a Bot API method, returning the `result`, throwing on `ok: false`. */
|
|
2434
|
+
private call;
|
|
2435
|
+
sendText(to: string, text: string): Promise<OutboundResult>;
|
|
2436
|
+
sendMedia(to: string, media: OutboundMedia): Promise<OutboundResult>;
|
|
2437
|
+
status(): Promise<string>;
|
|
2438
|
+
/**
|
|
2439
|
+
* Subscribe to inbound messages via `getUpdates` long-polling.
|
|
2440
|
+
*
|
|
2441
|
+
* @param handler - Invoked for each inbound text message.
|
|
2442
|
+
* @returns A stop function that ends the polling loop.
|
|
2443
|
+
*/
|
|
2444
|
+
onMessage(handler: InboundHandler): Promise<() => Promise<void>>;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
/**
|
|
2448
|
+
* SMS provider — a Twilio client + inbound-webhook receiver.
|
|
2449
|
+
*
|
|
2450
|
+
* Implements {@link MessagingProvider} over the built-in {@link HTTPClient}
|
|
2451
|
+
* (no `twilio` SDK). SMS has no persistent subscription, so `onMessage` is
|
|
2452
|
+
* absent — inbound arrives via {@link makeTwilioWebhookRouter}, which validates
|
|
2453
|
+
* the `X-Twilio-Signature` HMAC.
|
|
2454
|
+
*/
|
|
2455
|
+
|
|
2456
|
+
/** Options for {@link TwilioSmsProvider}. */
|
|
2457
|
+
interface TwilioSmsProviderOptions {
|
|
2458
|
+
/** Twilio Account SID. */
|
|
2459
|
+
accountSid: string;
|
|
2460
|
+
/** Twilio Auth Token. */
|
|
2461
|
+
authToken: string;
|
|
2462
|
+
/** Default `From` number (E.164), e.g. `+15551234567`. */
|
|
2463
|
+
from: string;
|
|
2464
|
+
/** API base. Default `https://api.twilio.com`. */
|
|
2465
|
+
apiBase?: string;
|
|
2466
|
+
}
|
|
2467
|
+
/** A Twilio SMS client. */
|
|
2468
|
+
declare class TwilioSmsProvider implements MessagingProvider {
|
|
2469
|
+
private readonly http;
|
|
2470
|
+
private readonly from;
|
|
2471
|
+
private readonly messagesPath;
|
|
2472
|
+
private readonly accountPath;
|
|
2473
|
+
/**
|
|
2474
|
+
* @param options - Account SID, auth token and default sender.
|
|
2475
|
+
*/
|
|
2476
|
+
constructor(options: TwilioSmsProviderOptions);
|
|
2477
|
+
/** POST a form body to Twilio and parse the JSON, throwing on non-2xx. */
|
|
2478
|
+
private postForm;
|
|
2479
|
+
sendText(to: string, text: string): Promise<OutboundResult>;
|
|
2480
|
+
sendMedia(to: string, media: OutboundMedia): Promise<OutboundResult>;
|
|
2481
|
+
status(): Promise<string>;
|
|
2482
|
+
}
|
|
2483
|
+
/**
|
|
2484
|
+
* Validate a Twilio request signature (`X-Twilio-Signature`).
|
|
2485
|
+
*
|
|
2486
|
+
* @param authToken - The Twilio auth token.
|
|
2487
|
+
* @param url - The full public URL Twilio posted to (scheme + host + path).
|
|
2488
|
+
* @param params - The POST form parameters.
|
|
2489
|
+
* @param signature - The `X-Twilio-Signature` header value.
|
|
2490
|
+
* @returns `true` when the signature matches.
|
|
2491
|
+
*/
|
|
2492
|
+
declare function validateTwilioSignature(authToken: string, url: string, params: Record<string, string>, signature: string): boolean;
|
|
2493
|
+
/** Options for {@link makeTwilioWebhookRouter}. */
|
|
2494
|
+
interface TwilioWebhookOptions {
|
|
2495
|
+
/** Handler invoked for each inbound SMS. */
|
|
2496
|
+
onMessage: InboundHandler;
|
|
2497
|
+
/** Route path. Default `/sms/inbound`. */
|
|
2498
|
+
path?: string;
|
|
2499
|
+
/** Auth token; when set, `X-Twilio-Signature` is validated. */
|
|
2500
|
+
authToken?: string;
|
|
2501
|
+
/** Public URL Twilio posts to (needed for signature validation behind a proxy). */
|
|
2502
|
+
publicUrl?: string;
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Build the Twilio inbound-SMS webhook router.
|
|
2506
|
+
*
|
|
2507
|
+
* Twilio posts `application/x-www-form-urlencoded` (`From`, `Body`,
|
|
2508
|
+
* `MessageSid`, …). Mount after `express.urlencoded()` (included by `createApp`).
|
|
2509
|
+
*
|
|
2510
|
+
* @param options - Handler, path and signature-validation settings.
|
|
2511
|
+
* @returns An Express router with the webhook endpoint mounted.
|
|
2512
|
+
*/
|
|
2513
|
+
declare function makeTwilioWebhookRouter(options: TwilioWebhookOptions): Router;
|
|
2514
|
+
|
|
2401
2515
|
/**
|
|
2402
2516
|
* Admin site + resource registry, mirroring `admin.site` / `admin.config`.
|
|
2403
2517
|
*
|
|
@@ -2657,12 +2771,62 @@ declare const authResponseSchema: z.ZodObject<{
|
|
|
2657
2771
|
expiresIn: number;
|
|
2658
2772
|
};
|
|
2659
2773
|
}>;
|
|
2774
|
+
/** MFA enrollment response (`POST /auth/mfa/enroll`). */
|
|
2775
|
+
declare const mfaEnrollResponseSchema: z.ZodObject<{
|
|
2776
|
+
secret: z.ZodString;
|
|
2777
|
+
otpauthUri: z.ZodString;
|
|
2778
|
+
}, "strip", z.ZodTypeAny, {
|
|
2779
|
+
secret: string;
|
|
2780
|
+
otpauthUri: string;
|
|
2781
|
+
}, {
|
|
2782
|
+
secret: string;
|
|
2783
|
+
otpauthUri: string;
|
|
2784
|
+
}>;
|
|
2785
|
+
/** A 6-digit MFA code body (`POST /auth/mfa/confirm|disable`). */
|
|
2786
|
+
declare const mfaCodeSchema: z.ZodObject<{
|
|
2787
|
+
code: z.ZodString;
|
|
2788
|
+
}, "strip", z.ZodTypeAny, {
|
|
2789
|
+
code: string;
|
|
2790
|
+
}, {
|
|
2791
|
+
code: string;
|
|
2792
|
+
}>;
|
|
2793
|
+
/** Activation body (`POST /auth/activate`). */
|
|
2794
|
+
declare const activationSchema: z.ZodObject<{
|
|
2795
|
+
token: z.ZodString;
|
|
2796
|
+
}, "strip", z.ZodTypeAny, {
|
|
2797
|
+
token: string;
|
|
2798
|
+
}, {
|
|
2799
|
+
token: string;
|
|
2800
|
+
}>;
|
|
2801
|
+
/** Password-reset request body (`POST /auth/password-reset/request`). */
|
|
2802
|
+
declare const passwordResetRequestSchema: z.ZodObject<{
|
|
2803
|
+
email: z.ZodString;
|
|
2804
|
+
}, "strip", z.ZodTypeAny, {
|
|
2805
|
+
email: string;
|
|
2806
|
+
}, {
|
|
2807
|
+
email: string;
|
|
2808
|
+
}>;
|
|
2809
|
+
/** Password-reset confirm body (`POST /auth/password-reset/confirm`). */
|
|
2810
|
+
declare const passwordResetConfirmSchema: z.ZodObject<{
|
|
2811
|
+
token: z.ZodString;
|
|
2812
|
+
password: z.ZodString;
|
|
2813
|
+
}, "strip", z.ZodTypeAny, {
|
|
2814
|
+
password: string;
|
|
2815
|
+
token: string;
|
|
2816
|
+
}, {
|
|
2817
|
+
password: string;
|
|
2818
|
+
token: string;
|
|
2819
|
+
}>;
|
|
2660
2820
|
type SignupInput = z.infer<typeof signupSchema>;
|
|
2661
2821
|
type LoginInput = z.infer<typeof loginSchema>;
|
|
2662
2822
|
type RefreshInput = z.infer<typeof refreshSchema>;
|
|
2663
2823
|
type TokenPair = z.infer<typeof tokenPairSchema>;
|
|
2664
2824
|
type UserPublic = z.infer<typeof userPublicSchema>;
|
|
2665
2825
|
type AuthResponse = z.infer<typeof authResponseSchema>;
|
|
2826
|
+
type MfaCodeInput = z.infer<typeof mfaCodeSchema>;
|
|
2827
|
+
type ActivationInput = z.infer<typeof activationSchema>;
|
|
2828
|
+
type PasswordResetRequestInput = z.infer<typeof passwordResetRequestSchema>;
|
|
2829
|
+
type PasswordResetConfirmInput = z.infer<typeof passwordResetConfirmSchema>;
|
|
2666
2830
|
|
|
2667
2831
|
/**
|
|
2668
2832
|
* User authentication service, mirroring `auth.service.UserAuthService`.
|
|
@@ -2757,6 +2921,197 @@ declare class UserAuthService {
|
|
|
2757
2921
|
refresh(refreshToken: string): Promise<AuthResponse>;
|
|
2758
2922
|
}
|
|
2759
2923
|
|
|
2924
|
+
/**
|
|
2925
|
+
* TOTP MFA enrollment/verification, mirroring the FastAPI SDK MFA flow.
|
|
2926
|
+
*
|
|
2927
|
+
* Orchestrates {@link TOTPHelper} over a pluggable {@link MfaStore}: enroll
|
|
2928
|
+
* (generate + persist a secret, return the provisioning URI), confirm (verify a
|
|
2929
|
+
* code and flip MFA on), verify (login step) and disable.
|
|
2930
|
+
*/
|
|
2931
|
+
|
|
2932
|
+
/** Persistence port for MFA secrets/state. */
|
|
2933
|
+
interface MfaStore {
|
|
2934
|
+
/** Persist a user's TOTP secret (pending until confirmed). */
|
|
2935
|
+
setSecret(userId: string, secret: string): Promise<void>;
|
|
2936
|
+
/** Read a user's TOTP secret, or `null`. */
|
|
2937
|
+
getSecret(userId: string): Promise<string | null>;
|
|
2938
|
+
/** Flip the MFA-enabled flag. */
|
|
2939
|
+
setEnabled(userId: string, enabled: boolean): Promise<void>;
|
|
2940
|
+
/** Whether MFA is enabled for the user. */
|
|
2941
|
+
isEnabled(userId: string): Promise<boolean>;
|
|
2942
|
+
}
|
|
2943
|
+
/** The result of starting enrollment. */
|
|
2944
|
+
interface MfaEnrollment {
|
|
2945
|
+
/** The base32 secret (persist server-side; also shown once for manual entry). */
|
|
2946
|
+
secret: string;
|
|
2947
|
+
/** The `otpauth://` URI to render as a QR code. */
|
|
2948
|
+
otpauthUri: string;
|
|
2949
|
+
}
|
|
2950
|
+
/** Options for {@link MfaService}. */
|
|
2951
|
+
interface MfaServiceOptions {
|
|
2952
|
+
/** The MFA persistence port. */
|
|
2953
|
+
store: MfaStore;
|
|
2954
|
+
/** The TOTP helper (issuer preconfigured). */
|
|
2955
|
+
totp: TOTPHelper;
|
|
2956
|
+
}
|
|
2957
|
+
declare class MfaService {
|
|
2958
|
+
private readonly store;
|
|
2959
|
+
private readonly totp;
|
|
2960
|
+
/**
|
|
2961
|
+
* @param options - Store and TOTP helper.
|
|
2962
|
+
*/
|
|
2963
|
+
constructor(options: MfaServiceOptions);
|
|
2964
|
+
/**
|
|
2965
|
+
* Begin enrollment: generate and persist a secret, return the QR URI.
|
|
2966
|
+
*
|
|
2967
|
+
* @param userId - The enrolling user.
|
|
2968
|
+
* @param accountName - Label shown in the authenticator (usually the email).
|
|
2969
|
+
* @returns The secret and provisioning URI.
|
|
2970
|
+
*/
|
|
2971
|
+
enroll(userId: string, accountName: string): Promise<MfaEnrollment>;
|
|
2972
|
+
/**
|
|
2973
|
+
* Confirm enrollment by verifying a code, enabling MFA on success.
|
|
2974
|
+
*
|
|
2975
|
+
* @param userId - The user.
|
|
2976
|
+
* @param code - The 6-digit code from the authenticator.
|
|
2977
|
+
* @throws {ValidationException} When no secret is pending or the code is wrong.
|
|
2978
|
+
*/
|
|
2979
|
+
confirm(userId: string, code: string): Promise<void>;
|
|
2980
|
+
/**
|
|
2981
|
+
* Verify a code (login step). Returns `false` without throwing.
|
|
2982
|
+
*
|
|
2983
|
+
* @param userId - The user.
|
|
2984
|
+
* @param code - The submitted code.
|
|
2985
|
+
* @returns `true` when the code is valid.
|
|
2986
|
+
*/
|
|
2987
|
+
verify(userId: string, code: string): Promise<boolean>;
|
|
2988
|
+
/**
|
|
2989
|
+
* Disable MFA after verifying a code.
|
|
2990
|
+
*
|
|
2991
|
+
* @param userId - The user.
|
|
2992
|
+
* @param code - The submitted code.
|
|
2993
|
+
* @throws {ValidationException} When the code is invalid.
|
|
2994
|
+
*/
|
|
2995
|
+
disable(userId: string, code: string): Promise<void>;
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2998
|
+
/**
|
|
2999
|
+
* Email-activation flow, mirroring the FastAPI SDK activation flow.
|
|
3000
|
+
*
|
|
3001
|
+
* Issues a single-use opaque token (only its SHA-256 hash is stored), emails
|
|
3002
|
+
* the plaintext to the user, and activates the account when the link is opened.
|
|
3003
|
+
*/
|
|
3004
|
+
/** Persistence port for activation tokens. */
|
|
3005
|
+
interface ActivationStore {
|
|
3006
|
+
/** Persist a token hash + expiry (epoch ms) for a user. */
|
|
3007
|
+
saveActivationToken(userId: string, tokenHash: string, expiresAt: number): Promise<void>;
|
|
3008
|
+
/** Look up a token hash, returning the owner + expiry, or `null`. */
|
|
3009
|
+
findActivationToken(tokenHash: string): Promise<{
|
|
3010
|
+
userId: string;
|
|
3011
|
+
expiresAt: number;
|
|
3012
|
+
} | null>;
|
|
3013
|
+
/** Remove a token hash (single-use). */
|
|
3014
|
+
clearActivationToken(tokenHash: string): Promise<void>;
|
|
3015
|
+
/** Mark a user active. */
|
|
3016
|
+
activate(userId: string): Promise<void>;
|
|
3017
|
+
}
|
|
3018
|
+
/** Options for {@link ActivationService}. */
|
|
3019
|
+
interface ActivationServiceOptions {
|
|
3020
|
+
/** The activation persistence port. */
|
|
3021
|
+
store: ActivationStore;
|
|
3022
|
+
/** Token lifetime in seconds. Default 86400 (24h). */
|
|
3023
|
+
ttlSeconds?: number;
|
|
3024
|
+
}
|
|
3025
|
+
declare class ActivationService {
|
|
3026
|
+
private readonly store;
|
|
3027
|
+
private readonly ttlSeconds;
|
|
3028
|
+
/**
|
|
3029
|
+
* @param options - Store and token TTL.
|
|
3030
|
+
*/
|
|
3031
|
+
constructor(options: ActivationServiceOptions);
|
|
3032
|
+
/**
|
|
3033
|
+
* Start activation: issue a token and persist its hash.
|
|
3034
|
+
*
|
|
3035
|
+
* @param userId - The user to activate.
|
|
3036
|
+
* @returns The one-time plaintext token (embed in the activation link).
|
|
3037
|
+
*/
|
|
3038
|
+
start(userId: string): Promise<string>;
|
|
3039
|
+
/**
|
|
3040
|
+
* Activate an account from a token.
|
|
3041
|
+
*
|
|
3042
|
+
* @param token - The plaintext token from the activation link.
|
|
3043
|
+
* @returns The activated user id.
|
|
3044
|
+
* @throws {InvalidTokenException} When the token is unknown or expired.
|
|
3045
|
+
*/
|
|
3046
|
+
activate(token: string): Promise<string>;
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
/**
|
|
3050
|
+
* Password-reset flow, mirroring the FastAPI SDK reset flow.
|
|
3051
|
+
*
|
|
3052
|
+
* `request` issues a single-use opaque token (hash stored) for a known email,
|
|
3053
|
+
* returning it so the caller can email the reset link — without leaking whether
|
|
3054
|
+
* the email exists. `confirm` validates the token + new password and rehashes.
|
|
3055
|
+
*/
|
|
3056
|
+
|
|
3057
|
+
/** Persistence port for password resets. */
|
|
3058
|
+
interface PasswordResetStore {
|
|
3059
|
+
/** Resolve a (lowercased) email to a user id, or `null`. */
|
|
3060
|
+
findUserIdByEmail(email: string): Promise<string | null>;
|
|
3061
|
+
/** Persist a reset token hash + expiry (epoch ms). */
|
|
3062
|
+
saveResetToken(userId: string, tokenHash: string, expiresAt: number): Promise<void>;
|
|
3063
|
+
/** Look up a reset token hash, returning owner + expiry, or `null`. */
|
|
3064
|
+
findResetToken(tokenHash: string): Promise<{
|
|
3065
|
+
userId: string;
|
|
3066
|
+
expiresAt: number;
|
|
3067
|
+
} | null>;
|
|
3068
|
+
/** Remove a reset token hash (single-use). */
|
|
3069
|
+
clearResetToken(tokenHash: string): Promise<void>;
|
|
3070
|
+
/** Overwrite a user's password hash. */
|
|
3071
|
+
updatePassword(userId: string, passwordHash: string): Promise<void>;
|
|
3072
|
+
}
|
|
3073
|
+
/** Options for {@link PasswordResetService}. */
|
|
3074
|
+
interface PasswordResetServiceOptions {
|
|
3075
|
+
/** The reset persistence port. */
|
|
3076
|
+
store: PasswordResetStore;
|
|
3077
|
+
/** Password hasher. */
|
|
3078
|
+
password: PasswordUtils;
|
|
3079
|
+
/** Token lifetime in seconds. Default 3600 (1h). */
|
|
3080
|
+
ttlSeconds?: number;
|
|
3081
|
+
/** Minimum new-password length. Default 12. */
|
|
3082
|
+
passwordMinLength?: number;
|
|
3083
|
+
}
|
|
3084
|
+
declare class PasswordResetService {
|
|
3085
|
+
private readonly store;
|
|
3086
|
+
private readonly password;
|
|
3087
|
+
private readonly ttlSeconds;
|
|
3088
|
+
private readonly passwordMinLength;
|
|
3089
|
+
/**
|
|
3090
|
+
* @param options - Store, password hasher and policy.
|
|
3091
|
+
*/
|
|
3092
|
+
constructor(options: PasswordResetServiceOptions);
|
|
3093
|
+
/**
|
|
3094
|
+
* Request a reset for `email`.
|
|
3095
|
+
*
|
|
3096
|
+
* Returns the plaintext token only when the email maps to a user; otherwise
|
|
3097
|
+
* `null`. Callers should respond with the same success shape either way to
|
|
3098
|
+
* avoid user enumeration — email the token only when present.
|
|
3099
|
+
*
|
|
3100
|
+
* @param email - The account email.
|
|
3101
|
+
* @returns The one-time token, or `null` when no user matches.
|
|
3102
|
+
*/
|
|
3103
|
+
request(email: string): Promise<string | null>;
|
|
3104
|
+
/**
|
|
3105
|
+
* Confirm a reset: validate the token + new password and rehash.
|
|
3106
|
+
*
|
|
3107
|
+
* @param token - The plaintext reset token.
|
|
3108
|
+
* @param newPassword - The new plaintext password.
|
|
3109
|
+
* @throws {ValidationException} When the new password is too short.
|
|
3110
|
+
* @throws {InvalidTokenException} When the token is unknown or expired.
|
|
3111
|
+
*/
|
|
3112
|
+
confirm(token: string, newPassword: string): Promise<void>;
|
|
3113
|
+
}
|
|
3114
|
+
|
|
2760
3115
|
/**
|
|
2761
3116
|
* JWT auth middleware + role guards, mirroring `api.dependencies.auth`.
|
|
2762
3117
|
*
|
|
@@ -2864,6 +3219,15 @@ interface AuthRouterOptions {
|
|
|
2864
3219
|
prefix?: string;
|
|
2865
3220
|
/** When provided, OpenAPI paths are registered for Swagger/Redoc. */
|
|
2866
3221
|
registry?: OpenAPIRegistry;
|
|
3222
|
+
/** Mount `POST /auth/activate` when provided. */
|
|
3223
|
+
activation?: ActivationService;
|
|
3224
|
+
/** Mount `POST /auth/password-reset/{request,confirm}` when provided. */
|
|
3225
|
+
passwordReset?: PasswordResetService;
|
|
3226
|
+
/**
|
|
3227
|
+
* Mount guarded `POST /auth/mfa/{enroll,confirm,disable}` when provided. The
|
|
3228
|
+
* enrolling account label defaults to the `email` claim (falls back to `sub`).
|
|
3229
|
+
*/
|
|
3230
|
+
mfa?: MfaService;
|
|
2867
3231
|
}
|
|
2868
3232
|
/**
|
|
2869
3233
|
* Build the auth router.
|
|
@@ -3105,6 +3469,6 @@ interface RunServerOptions {
|
|
|
3105
3469
|
declare function runServer(app: Express, options?: RunServerOptions): Promise<Server>;
|
|
3106
3470
|
|
|
3107
3471
|
/** The installed SDK version. Single source of truth for the barrel + CLI. */
|
|
3108
|
-
declare const VERSION = "0.
|
|
3472
|
+
declare const VERSION = "0.7.0";
|
|
3109
3473
|
|
|
3110
|
-
export { type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, type CacheManager, type CachedOptions, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type EmailMessage, type EmailOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTPClient, type HTTPClientOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, type MemoryMetrics, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, type MessagingProvider, MetricsUtils, NotFoundException, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, PHONE_BR_PATTERN, type PaginationFilter, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, RetryPolicy, type RunServerOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|
|
3474
|
+
export { type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, type AuthResponse, type AuthRouterOptions, type AuthUser, type BaseAppSettings, BaseController, BaseModel, type BaseResponse, BaseService, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, type CacheManager, type CachedOptions, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CursorPaginationFilter, DEFAULT_LOCALE, type EmailMessage, type EmailOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FlagContext, ForbiddenException, type GenerateOpenApiOptions, HTTPClient, type HTTPClientOptions, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, LocalUploadStorage, type LocalUploadStorageOptions, type LogExtra, type LogLevel, type LoginInput, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, type MemoryMetrics, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, type MessagingProvider, MetricsUtils, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, PHONE_BR_PATTERN, type PaginationFilter, type PasswordResetConfirmInput, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, RedisCacheManager, type RedisLike, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type ResponseMapper, RetryPolicy, type RunServerOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type StateBR, type SwaggerOptions, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, activationSchema, attachWebSocketHub, authResponseSchema, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, buildContentDisposition, cached, cepField, citiesByUf, cnpjField, coerceFlag, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createdByColumn, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, encodeCursor, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, listStates, loadSettings, loginSchema, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeSessionMiddleware, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaCodeSchema, mfaEnrollResponseSchema, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, phoneBrField, refreshSchema, registerExceptionHandlers, requestIdMiddleware, requireRoles, runServer, runWithRequestContext, serverSettingsShape, sessionCookie, setRequestId, signupSchema, sseResponse, statesByRegion, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, ufField, updatedByColumn, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSubscriptionSchema, wsEnvelopeSchema };
|