UNPKG

ems-web-app-cognito

Version:

This angular.io module includes a component, service and supporting classes that wrap the Amazon Cognito Identity SDK to enable simple username/password authentication.

46 lines (45 loc) 2.47 kB
import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import 'cross-fetch/polyfill'; import { CognitoUser, CognitoUserSession } from 'amazon-cognito-identity-js'; import { ICognitoResponse, ICognitoUserData } from "./cognito.interfaces"; import { CognitoFormType } from "./cognito.types"; import * as i0 from "@angular/core"; export declare class CognitoService { private http; private sessionSource; session$: Observable<CognitoUserSession | null>; private userSource; user$: Observable<CognitoUser | null>; private formSource; form$: Observable<CognitoFormType | null>; private user; private pool; private accessToken?; private idToken?; private storage; private useLocalStorage; constructor(http: HttpClient); initialize(UserPoolId: string, ClientId: string, useLocalStorage?: boolean, idToken?: string, accessToken?: string, refreshToken?: string): void; setCognitoUserFromToken(UserPoolId: string, ClientId: string, idToken?: string, accessToken?: string, refreshToken?: string): CognitoUser | null; magicLinkAuthenticate(Username: string, ChallengeResponse?: string, SessionId?: string): Promise<any>; passkeyAuthenticate(Username: string, ChallengeResponse?: string): Promise<any>; otpAuthenticate(Username: string, ChallengeResponse?: string): Promise<any>; getUserInfo(url: string): Promise<ICognitoUserData | HttpErrorResponse | undefined>; setUserSession(session: CognitoUserSession): void; showForm(form: CognitoFormType | null): void; logout(): Promise<any>; authenticate(Username: string, Password: string): Promise<ICognitoResponse>; createFederatedSession(IdToken: string, AccessToken: string): void; completePasswordUpdate(password: string, user: CognitoUser, attributes: any): Promise<ICognitoResponse>; requestVerificationCode(Username: string): Promise<ICognitoResponse>; resetPassword(user: CognitoUser, oldPassword: string, newPassword: string): Promise<ICognitoResponse>; forgotPassword(user: CognitoUser): Promise<ICognitoResponse>; confirmPassword(user: CognitoUser, code: string, password: string): Promise<ICognitoResponse>; private authenticateUser; private getUserSession; private handleErrorQuietly; private headers; static ɵfac: i0.ɵɵFactoryDeclaration<CognitoService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<CognitoService>; }