UNPKG

mya-cli

Version:

MYA - AI-Powered Stock & Options Analysis CLI Tool

52 lines 1.63 kB
/** * Stytch client for OTP authentication */ import { AuthManager } from '../auth/auth-manager.js'; /** * Create a singleton instance of the auth manager */ const authManager = AuthManager.getInstance(); /** * Send a one-time verification code to the specified email * @param email Email address to send the code to * @returns Promise containing the method ID needed for verification */ async function sendOtpCode(email) { const response = await authManager.sendOtpCode(email); return response.method_id || response.methodId; } /** * Verify a one-time password code * @param methodId Method ID returned from sendOtpCode * @param code OTP code entered by the user * @param email Email address used to send the OTP * @returns Promise containing the session token and user ID */ async function verifyOtpCode(methodId, code, email) { const response = await authManager.verifyOtpCode(methodId, code, email); return { session_token: response.session_token, session_jwt: response.session_jwt, user_id: response.user_id, user: response.user ? { user_id: response.user.userId, email: response.user.email, status: response.user.status, } : undefined, status_code: response.status_code, }; } /** * Export functions and types with proper type exports for isolatedModules */ export { sendOtpCode, verifyOtpCode }; /** * Export a stytch object for backward compatibility */ export const stytch = { sendOtpCode, verifyOtpCode, }; //# sourceMappingURL=stytch-client.js.map