@ssktechnologies/awsforge
Version:
Enterprise-grade AWS Cognito authentication toolkit for seamless user management, registration, login, and password recovery with JWT token handling
96 lines (95 loc) • 2.19 kB
TypeScript
/**
* Core types and interfaces for AWSForge
*/
export interface AWSForgeConfig {
region: string;
userPoolId: string;
clientId: string;
clientSecret?: string;
accessKeyId?: string;
secretAccessKey?: string;
sessionToken?: string;
}
export interface UserRegistrationData {
email: string;
password: string;
username?: string;
firstName?: string;
lastName?: string;
phoneNumber?: string;
customAttributes?: Record<string, string>;
}
export interface UserLoginData {
username: string;
password: string;
}
export interface ForgotPasswordData {
username: string;
}
export interface ConfirmRegistrationData {
username: string;
confirmationCode: string;
}
export interface ConfirmForgotPasswordData {
username: string;
confirmationCode: string;
newPassword: string;
}
export interface ChangePasswordData {
accessToken: string;
previousPassword: string;
proposedPassword: string;
}
export interface DecodedToken {
sub: string;
iss: string;
aud: string;
exp: number;
iat: number;
token_use: 'access' | 'id';
username?: string;
email?: string;
email_verified?: boolean;
phone_number?: string;
phone_number_verified?: boolean;
given_name?: string;
family_name?: string;
preferred_username?: string;
[key: string]: any;
}
export interface TokenVerificationResult {
isValid: boolean;
decoded?: DecodedToken;
error?: string;
}
export interface UserProfile {
username: string;
attributes: Record<string, string>;
}
export interface AuthTokens {
accessToken: string;
idToken: string;
refreshToken: string;
expiresIn: number;
}
export interface LoginResponse {
tokens: AuthTokens;
user: UserProfile;
}
export interface TokenConfig {
autoRefresh?: boolean;
refreshThreshold?: number;
onTokenRefresh?: (tokens: AuthTokens) => void;
onTokenExpired?: () => void;
}
export interface CognitoError {
code: string;
message: string;
statusCode?: number;
}
export interface UserSession {
tokens: AuthTokens;
user: UserProfile;
expiresAt: Date;
isValid: boolean;
}