import type { AuthenticationResultType, ChallengeNameType, CodeDeliveryDetailsType } from "@aws-sdk/client-cognito-identity-provider"; import type { IAuthConstructConfig } from "@ten24group/fw24"; import { CognitoJwtPayload } from "aws-jwt-verify/jwt-model"; export type SignInResult = AuthenticationResultType | { session: string; challengeName: ChallengeNameType; challengeParameters?: Record; }; export type SignUpResult = { session?: string; UserConfirmed?: boolean; UserSub?: string; CodeDeliveryDetails?: CodeDeliveryDetailsType; }; export type InitiateAuthResult = { session: string; challenges: ChallengeNameType[]; }; export type SignUpOptions = { username: string; password: string; email?: string; autoSignIn?: boolean; [key: string]: any; }; export type CreateUserOptions = { username: string; tempPassword?: string; attributes?: Array<{ Name: string; Value: string; }>; }; export type UpdateUserAttributeOptions = { username: string; attributes: Array<{ Name: string; Value: string; }>; }; export type MfaMethod = 'EMAIL' | 'SMS' | 'SOFTWARE_TOKEN'; export type UserMfaPreferenceOptions = { enabledMethods: MfaMethod[]; preferredMethod?: MfaMethod; }; export type AdminMfaSettings = { username: string; enabledMethods: MfaMethod[]; preferredMethod?: MfaMethod; }; export type UserDetails = { Username: string; email?: string; Enabled?: boolean; UserStatus?: string; Attributes?: Array<{ Name: string; Value: string; }>; }; export interface IAuthService { getUser(usernameOrEmail: string): Promise; getCurrentUser(accessToken: string): Promise; signup(options: SignUpOptions): Promise; signin(username: string, password: string): Promise; signout(accessToken: string): Promise; verify(username: string, code: string): Promise; verifyUserAttribute(accessToken: string, attributeName: string, code: string): Promise; getUserAttributeVerificationCode(accessToken: string, attributeName: string): Promise; resendVerificationCode(username: string): Promise; getCredentials(idToken: string): Promise; verifyToken(idToken: string, type: 'id' | 'access'): Promise; changePassword(accessToken: string, newPassword: string, oldPassword?: string): Promise; forgotPassword(username: string): Promise; confirmForgotPassword(username: string, code: string, newPassword: string): Promise; initiateAuth(username: string): Promise; initiateOtpAuth(username: string, session: string): Promise; respondToOtpChallenge(username: string, session: string, code: string): Promise; respondToNewPasswordChallenge(username: string, newPassword: string, session: string): Promise; refreshToken(refreshToken: string): Promise; initiateSocialSignIn(provider: SocialProvider, redirectUri: string): Promise; completeSocialSignIn(provider: SocialProvider, code: string, redirectUri: string): Promise; linkSocialProvider(accessToken: string, provider: SocialProvider, code: string, redirectUri: string): Promise; unlinkSocialProvider(accessToken: string, provider: SocialProvider): Promise; updateUserMfaPreference(accessToken: string, mfaPreference: UserMfaPreferenceOptions): Promise; getUserMfaPreference(accessToken: string): Promise; createUser(options: CreateUserOptions): Promise; setPassword(username: string, password: string, forceChangePassword?: boolean): Promise; resetPassword(username: string): Promise; setUserGroups(username: string, newGroups: string[]): Promise; updateUserAttributes(options: UpdateUserAttributeOptions): Promise; addUserToGroup(username: string, groupName: string): Promise; getUserGroupNames(username: string): Promise>; removeUserFromGroup(username: string, groupName: string): Promise; setUserMfaSettings(settings: AdminMfaSettings): Promise; deleteUser(username: string): Promise; getSocialSignInConfig(redirectUri: string): Promise; } export type CreateUserAuthenticationOptions = { username: string; password: string; groups?: string[]; userAttributes?: Array<{ Name: string; Value: string; }>; autoLogin?: boolean; autoVerifyEmail?: boolean; autoTriggerForgotPassword?: boolean; }; export type AddUserToGroupOptions = { group: string; username: string; }; export type RemoveUserFromGroupOptions = { group: string; username: string; }; export type SetUserGroupsOptions = { groups?: string[]; username: string; }; export type SetUserPasswordOptions = { username: string; password: string; forceChangePassword?: boolean; }; export type ResetUserPasswordOptions = { username: string; }; export interface IAuthModuleClient { createUserAuth(options: CreateUserAuthenticationOptions): Promise; createUser(options: CreateUserOptions): Promise; getUser(usernameOrEmail: string): Promise; addUserToGroup(options: AddUserToGroupOptions): Promise; setUserGroups(options: SetUserGroupsOptions): Promise; setUserPassword(options: SetUserPasswordOptions): Promise; resetUserPassword(options: ResetUserPasswordOptions): Promise; updateUserAttributes(options: UpdateUserAttributeOptions): Promise; deleteUser(username: string): Promise; verifyToken(idToken: string, type: 'id' | 'access'): Promise; } export interface IAuthModuleConfig extends IAuthConstructConfig { customMessageTemplates?: { signup?: { subject: string; message: string; }; adminCreateUser?: { subject: string; message: string; }; resendCode?: { subject: string; message: string; }; forgotPassword?: { subject: string; message: string; }; updateUserAttribute?: { subject: string; message: string; }; verifyUserAttribute?: { subject: string; message: string; }; authentication?: { subject: string; message: string; }; }; autoVerifyUser?: boolean; } export declare const SOCIAL_PROVIDERS: readonly ["Google", "Facebook"]; export type SocialProvider = typeof SOCIAL_PROVIDERS[number]; export type SocialSignInConfig = { authorizationUrl: string; clientId: string; redirectUri: string; grantType: string; }; export type SocialSignInConfigs = { [key in SocialProvider]?: SocialSignInConfig; }; export type SocialSignInResult = SignInResult & { isNewUser?: boolean; provider?: SocialProvider; };