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.

1,159 lines 79.2 kB
import { __awaiter } from 'tslib';
import * as i0 from '@angular/core';
import { Injectable, Pipe, EventEmitter, Component, HostBinding, Input, Output, NgModule } from '@angular/core';
import * as i1 from '@angular/common/http';
import { HttpHeaders, HttpClientModule } from '@angular/common/http';
import { BehaviorSubject, of } from 'rxjs';
import { map } from 'rxjs/operators';
import 'cross-fetch/polyfill';
import { CognitoUserPool, CognitoUser, CognitoIdToken, CognitoAccessToken, CognitoRefreshToken, CognitoUserSession, AuthenticationDetails } from 'amazon-cognito-identity-js';
import { jwtDecode } from 'jwt-decode';
import { startAuthentication, startRegistration } from '@simplewebauthn/browser';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3 from '@angular/forms';
import { FormsModule } from '@angular/forms';

var CognitoResponseType;
(function (CognitoResponseType) {
    CognitoResponseType["Authenticated"] = "authenticated";
    CognitoResponseType["PasswordReset"] = "NEW_PASSWORD_REQUIRED";
    CognitoResponseType["NotAuthorized"] = "NotAuthorizedException";
    CognitoResponseType["ForcePasswordReset"] = "PasswordResetRequiredException";
    CognitoResponseType["InvalidCode"] = "CodeMismatchException";
    CognitoResponseType["LimitExceededException"] = "LimitExceededException";
    CognitoResponseType["OtpChallenge"] = "OtpChallenge";
    CognitoResponseType["MagicLink"] = "MagicLink";
    CognitoResponseType["Passkey"] = "Passkey";
    CognitoResponseType["Success"] = "SUCCESS";
})(CognitoResponseType || (CognitoResponseType = {}));
var CognitoRequestType;
(function (CognitoRequestType) {
    CognitoRequestType["Authentication"] = "authentication";
    CognitoRequestType["NewUserPasswordReset"] = "new-user-password-reset";
    CognitoRequestType["ForcePasswordReset"] = "force-password-reset";
    CognitoRequestType["ForgotPassword"] = "forgot-password";
    CognitoRequestType["UpdatePasswordWithCode"] = "update-password-with-code";
    CognitoRequestType["PasswordReset"] = "password-reset";
    CognitoRequestType["ConfirmPassword"] = "confirm-password";
    CognitoRequestType["OtpChallenge"] = "otp-challenge";
    CognitoRequestType["Passkey"] = "passkey";
    CognitoRequestType["MagicLink"] = "magic-link";
})(CognitoRequestType || (CognitoRequestType = {}));
var CognitoFormType;
(function (CognitoFormType) {
    CognitoFormType["Login"] = "login";
    CognitoFormType["NewUser"] = "new-user";
    CognitoFormType["ForcePasswordReset"] = "force-password-reset";
    CognitoFormType["UserPasswordReset"] = "user-password-reset";
    CognitoFormType["UserVerificationRequest"] = "user-verification-request";
    CognitoFormType["PasswordUpdateSuccessful"] = "password-update-successful";
    CognitoFormType["GoogleSignIn"] = "google-sign-in";
})(CognitoFormType || (CognitoFormType = {}));

class CognitoStrings {
}
CognitoStrings.onUserPasswordChangeSuccessful = "Update successful. Please log in with your new password.";
CognitoStrings.onVerificationCodeSent = "Enter your email below to generate a verification code.";
CognitoStrings.onNewPasswordRequired = "You need to create a new password. Please check your email for a verification code and then complete the form below.";
CognitoStrings.onFirstLogin = "Please complete the fields below to finish account creation.";
CognitoStrings.onTooManyAttempts = "Too many attempts. Please try again in 15 minutes.";
CognitoStrings.onPasswordUpdated = "Your password has been updated successfully.";
CognitoStrings.labelEmail = "Email Address";
CognitoStrings.labelPassword = "Password";
CognitoStrings.labelForgotPassword = "Forgot Password";
CognitoStrings.labelNewPassword = "New Password";
CognitoStrings.labelCurrentPassword = "Current Password";
CognitoStrings.labelConfirmNewPassword = "Confirm New Password";
CognitoStrings.labelSubmit = "Submit";
CognitoStrings.labelCode = "Code";
CognitoStrings.labelClose = "Close";
CognitoStrings.labelUseRegularPassword = "Use Standard Password";
CognitoStrings.labelOtp = "Email me a One Time Password (OTP)";
CognitoStrings.labelOtpEnter = "Enter the code that was just emailed to you.";
CognitoStrings.labelMagicLink = "Email me a magic link";
CognitoStrings.labelPasskeys = "Use a passkey";
CognitoStrings.labelPasskeyEnter = "Enter the code that was just emailed to you.";
CognitoStrings.labelPasswordRequirement = "Must be at least 8 characters and contain a number, special character, uppercase and lowercase letter.";
CognitoStrings.labelSso = "SSO";
CognitoStrings.labelOrSignInWith = "Or sign in with...";
class EphemeralStorage {
    constructor() {
        this._cache = {};
    }
    getItem(key) {
        return this._cache[key];
    }
    setItem(key, value) {
        this._cache[key] = value;
        return this.getItem(key);
    }
    removeItem(key) {
        delete this._cache[key];
    }
    clear() {
        this._cache = {};
    }
}

function unsnake(input = "") {
    return input
        .split("_")
        .map(p => p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase())
        .join(" ");
}
function tick(duration = 0) {
    return new Promise((resolve) => {
        window.setTimeout(() => resolve(duration), duration);
    });
}
function trim(input) {
    if (!input)
        return input;
    return input.replace(/^\s+/, '').replace(/\s+$/, '');
}
function params(requestedProperty) {
    const vars = {};
    const parts = window.location.href.replace(/[?&#]+([^=&]+)=([^&]*)/gi, ((m, key, value) => {
        vars[key] = value;
    }));
    for (const prop in vars) {
        if (vars[prop].toLowerCase() === 'true')
            vars[prop] = true;
        else if (vars[prop].toLowerCase() === 'false')
            vars[prop] = false;
        else if (!isNaN(parseFloat(vars[prop])) && !vars[prop].match(/[^0-9]+/gim))
            vars[prop] = parseFloat(vars[prop]);
    }
    if (requestedProperty)
        return vars[requestedProperty];
    return vars;
}

class CognitoService {
    constructor(http) {
        this.http = http;
        this.sessionSource = new BehaviorSubject(null);
        this.session$ = this.sessionSource.asObservable();
        this.userSource = new BehaviorSubject(null);
        this.user$ = this.userSource.asObservable();
        this.formSource = new BehaviorSubject(null);
        this.form$ = this.formSource.asObservable();
        this.user = null;
        this.storage = new EphemeralStorage();
        this.useLocalStorage = true;
    }
    initialize(UserPoolId, ClientId, useLocalStorage = true, idToken, accessToken, refreshToken) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
        //for federated users
        const access = (_c = (_b = (_a = params("access_token")) !== null && _a !== void 0 ? _a : accessToken) !== null && _b !== void 0 ? _b : localStorage.getItem("ems_access_token")) !== null && _c !== void 0 ? _c : null;
        const id = (_f = (_e = (_d = params("id_token")) !== null && _d !== void 0 ? _d : idToken) !== null && _e !== void 0 ? _e : localStorage.getItem("ems_id_token")) !== null && _f !== void 0 ? _f : null;
        const sessionId = (_g = params("sessionId")) !== null && _g !== void 0 ? _g : null;
        const otp = (_h = params("otp")) !== null && _h !== void 0 ? _h : null;
        this.useLocalStorage = useLocalStorage;
        if (useLocalStorage && access && id) {
            localStorage.setItem("ems_access_token", access);
            localStorage.setItem("ems_id_token", id);
            window.location.hash = "";
        }
        this.accessToken = access;
        this.idToken = id;
        //for srp users
        if (useLocalStorage) {
            this.pool = new CognitoUserPool({ UserPoolId, ClientId });
            this.user = this.pool.getCurrentUser();
            this.userSource.next(this.user);
            (_j = this.user) === null || _j === void 0 ? void 0 : _j.getSession((e, session) => this.sessionSource.next(session));
        }
        else {
            this.setCognitoUserFromToken(UserPoolId, ClientId, idToken, accessToken, refreshToken);
        }
    }
    setCognitoUserFromToken(UserPoolId, ClientId, idToken, accessToken, refreshToken) {
        var _a;
        this.pool = new CognitoUserPool({ UserPoolId, ClientId, Storage: this.storage });
        if (idToken) {
            const decoded = jwtDecode(idToken);
            this.user = new CognitoUser({
                Username: decoded['cognito:username'],
                Pool: this.pool,
                Storage: this.storage
            });
            const idTokenObj = new CognitoIdToken({ IdToken: idToken });
            const accessTokenObj = new CognitoAccessToken({ AccessToken: accessToken });
            const refreshTokenObj = new CognitoRefreshToken({ RefreshToken: refreshToken });
            const session = new CognitoUserSession({ IdToken: idTokenObj, AccessToken: accessTokenObj, RefreshToken: refreshTokenObj });
            // Set the session to the Cognito user
            this.user.setSignInUserSession(session);
        }
        else {
            this.user = this.pool.getCurrentUser();
        }
        this.userSource.next(this.user);
        (_a = this.user) === null || _a === void 0 ? void 0 : _a.getSession((e, session) => this.sessionSource.next(session));
        return this.user;
    }
    ;
    magicLinkAuthenticate(Username, ChallengeResponse, SessionId) {
        var _a;
        const request = ChallengeResponse ? CognitoRequestType.MagicLink : CognitoRequestType.Authentication;
        const details = new AuthenticationDetails({ Username });
        const data = { Username, Pool: this.pool };
        if (!this.useLocalStorage)
            data.Storage = this.storage;
        const user = this.user = (_a = this.user) !== null && _a !== void 0 ? _a : new CognitoUser(data);
        this.user.setAuthenticationFlowType('CUSTOM_AUTH');
        //@ts-ignore
        if (SessionId)
            this.user.Session = SessionId;
        return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
            const handler = {
                onSuccess: (session) => {
                    this.sessionSource.next(session);
                    this.userSource.next(this.user);
                    resolve({ type: CognitoResponseType.Authenticated, session, user, request });
                },
                onFailure: (error) => reject({ type: CognitoResponseType.NotAuthorized, error, user, request, session: null }),
                customChallenge: (challengeParameters) => {
                    resolve({ type: CognitoResponseType.MagicLink, user, request, challengeParameters });
                }
            };
            if (ChallengeResponse)
                user.sendCustomChallengeAnswer(ChallengeResponse, handler);
            else
                user.initiateAuth(details, handler);
        }));
    }
    passkeyAuthenticate(Username, ChallengeResponse) {
        var _a;
        const request = ChallengeResponse ? CognitoRequestType.Passkey : CognitoRequestType.Authentication;
        const details = new AuthenticationDetails({ Username });
        const data = { Username, Pool: this.pool };
        if (!this.useLocalStorage)
            data.Storage = this.storage;
        const user = this.user = (_a = this.user) !== null && _a !== void 0 ? _a : new CognitoUser(data);
        this.user.setAuthenticationFlowType('CUSTOM_AUTH');
        return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
            const handler = {
                onSuccess: (session) => {
                    this.sessionSource.next(session);
                    this.userSource.next(this.user);
                    resolve({ type: CognitoResponseType.Authenticated, session, user, request });
                },
                onFailure: (error) => reject({ type: CognitoResponseType.NotAuthorized, error, user, request, session: null }),
                customChallenge: (challengeParameters) => resolve({ type: CognitoResponseType.Passkey, user, request, challengeParameters })
            };
            if (ChallengeResponse)
                user.sendCustomChallengeAnswer(ChallengeResponse, handler);
            else
                user.initiateAuth(details, handler);
        }));
    }
    otpAuthenticate(Username, ChallengeResponse) {
        var _a;
        const request = ChallengeResponse ? CognitoRequestType.OtpChallenge : CognitoRequestType.Authentication;
        const details = new AuthenticationDetails({ Username });
        const data = { Username, Pool: this.pool };
        if (!this.useLocalStorage)
            data.Storage = this.storage;
        const user = this.user = (_a = this.user) !== null && _a !== void 0 ? _a : new CognitoUser(data);
        this.user.setAuthenticationFlowType('CUSTOM_AUTH');
        return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
            const handler = {
                onSuccess: (session) => {
                    this.sessionSource.next(session);
                    this.userSource.next(this.user);
                    resolve({ type: CognitoResponseType.Authenticated, session, user, request });
                },
                onFailure: (error) => reject({ type: CognitoResponseType.NotAuthorized, error, user, request, session: null }),
                customChallenge: (challengeParameters) => resolve({ type: CognitoResponseType.OtpChallenge, user, request, challengeParameters })
            };
            if (ChallengeResponse)
                user.sendCustomChallengeAnswer(ChallengeResponse, handler);
            else
                user.initiateAuth(details, handler);
        }));
    }
    getUserInfo(url) {
        const request = `${url}/oauth2/userInfo`;
        const headers = this.headers();
        return this.http.get(request, { headers, withCredentials: true }).pipe(map((result) => {
            return {
                email: result.email,
                username: result.username,
                sub: result.sub,
                firstName: result.given_name,
                lastName: result.family_name,
                accessToken: this.accessToken,
                idToken: this.idToken
            };
        })).toPromise();
        //, catchError(this.handleErrorQuietly)
    }
    setUserSession(session) {
        this.sessionSource.next(session);
    }
    showForm(form) {
        this.formSource.next(form);
    }
    logout() {
        return new Promise((resolve, reject) => {
            if (this.user) {
                this.userSource.next(null);
                this.sessionSource.next(null);
                localStorage.removeItem("ems_id_token");
                localStorage.removeItem("ems_access_token");
                this.user.globalSignOut({
                    onSuccess: resolve,
                    onFailure: () => {
                        //if user is disabled, must manually clear local storage (apparently)
                        for (let prop in localStorage) {
                            if (prop.match(/cognito/i))
                                localStorage.removeItem(prop);
                        }
                        resolve(null);
                    }
                });
            }
            else {
                resolve(null);
            }
        });
    }
    authenticate(Username, Password) {
        const details = new AuthenticationDetails({ Username, Password });
        const data = { Username, Pool: this.pool };
        if (!this.useLocalStorage)
            data.Storage = this.storage;
        const user = new CognitoUser(data);
        return new Promise((resolve, reject) => {
            if (!this.user)
                this.authenticateUser(user, details, resolve, reject);
            else
                this.getUserSession(resolve, reject);
        });
    }
    createFederatedSession(IdToken, AccessToken) {
        const session = new CognitoUserSession({
            IdToken: new CognitoIdToken({ IdToken }),
            AccessToken: new CognitoAccessToken({ AccessToken }),
        });
        const Username = session.getIdToken().payload["cognito:username"];
        const data = { Username, Pool: this.pool };
        if (!this.useLocalStorage)
            data.Storage = this.storage;
        this.user = new CognitoUser(data);
        this.userSource.next(this.user);
        this.sessionSource.next(session);
    }
    completePasswordUpdate(password, user, attributes) {
        const request = CognitoRequestType.NewUserPasswordReset;
        return new Promise((resolve, reject) => {
            user.completeNewPasswordChallenge(password, attributes, {
                onSuccess: (session) => {
                    this.user = user;
                    this.userSource.next(user);
                    this.sessionSource.next(session);
                    resolve({ type: CognitoResponseType.Authenticated, session, user, request: CognitoRequestType.Authentication });
                },
                onFailure: (error) => reject({ type: CognitoResponseType.NotAuthorized, error, user, request, session: null })
            });
        });
    }
    requestVerificationCode(Username) {
        const data = { Username, Pool: this.pool };
        if (!this.useLocalStorage)
            data.Storage = this.storage;
        const user = new CognitoUser(data);
        return this.forgotPassword(user);
    }
    resetPassword(user, oldPassword, newPassword) {
        const request = CognitoRequestType.PasswordReset;
        return new Promise((resolve, reject) => {
            user.changePassword(oldPassword, newPassword, (error, result) => {
                if (error)
                    reject({ type: CognitoResponseType.LimitExceededException, user, request, error, session: null });
                else
                    resolve({ type: CognitoResponseType.Success, user, request, session: null });
            });
        });
    }
    forgotPassword(user) {
        const request = CognitoRequestType.ForgotPassword;
        return new Promise((resolve, reject) => {
            user.forgotPassword({
                onSuccess: (response) => resolve({ type: CognitoResponseType.Success, user, request, session: null }),
                onFailure: (error) => reject({ type: CognitoResponseType.LimitExceededException, error, user, request, session: null })
            });
        });
    }
    confirmPassword(user, code, password) {
        const request = CognitoRequestType.ConfirmPassword;
        return new Promise((resolve, reject) => {
            user.confirmPassword(code, password, {
                onSuccess: (response) => { resolve({ type: CognitoResponseType.Success, user, request, session: null }); },
                onFailure: (error) => reject({ type: CognitoResponseType.InvalidCode, error, user, request, session: null })
            });
        });
    }
    authenticateUser(user, details, resolve, reject) {
        const request = CognitoRequestType.Authentication;
        user.authenticateUser(details, {
            onSuccess: (session) => {
                this.sessionSource.next(session);
                this.userSource.next(user);
                this.user = user;
                resolve({ type: CognitoResponseType.Authenticated, session, user, request });
            },
            onFailure: (error) => reject({ type: CognitoResponseType.NotAuthorized, error, user, request, session: null }),
            newPasswordRequired: (userAttributes, requiredAttributes) => {
                resolve({ type: CognitoResponseType.PasswordReset, userAttributes, requiredAttributes, user, request, session: null });
            }
        });
    }
    getUserSession(resolve, reject) {
        const request = CognitoRequestType.Authentication;
        this.user.getSession((error, session) => {
            if (error)
                reject({ type: CognitoResponseType.Authenticated, session, user: this.user, request, error });
            else {
                this.sessionSource.next(session);
                resolve({ type: CognitoResponseType.Authenticated, session, user: this.user, request });
            }
        });
    }
    handleErrorQuietly(error) {
        return of(error);
    }
    headers(custom = {}) {
        const headers = {
            "Content-Type": "application/json",
            "Authorization": this.accessToken ? `Bearer ${this.accessToken}` : ""
        };
        return new HttpHeaders(headers);
    }
}
CognitoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
CognitoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });

class LabelerPipe {
    transform(label) {
        if (label === null || label === void 0 ? void 0 : label.match(/given name/i))
            return "First Name";
        if (label === null || label === void 0 ? void 0 : label.match(/family name/i))
            return "Last Name";
        return label;
    }
}
LabelerPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LabelerPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
LabelerPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LabelerPipe, name: "labeler" });
LabelerPipe.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LabelerPipe });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LabelerPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'labeler'
                }]
        }, {
            type: Injectable
        }] });

class CognitoComponent {
    constructor(cognito) {
        this.cognito = cognito;
        this.hostStyle = {};
        this.showForm = false;
        this.transitioning = false;
        this.providerName = "Google";
        this.modalBackground = "rgba(255,255,255,0.5)";
        this.zIndex = 1000;
        this.srp = true;
        this.otp = false;
        this.sso = false;
        this.magicLink = false;
        this.reloadAfterLinkAuthentication = true;
        this.passkeys = false;
        this.useLocalStorage = true;
        this.ssoProviders = [];
        this.onReady = new EventEmitter();
        this.onConnecting = new EventEmitter();
        this.onAuthenticated = new EventEmitter();
        this.onResponse = new EventEmitter();
        this.onUsernameEntered = new EventEmitter();
        this.onProviderSelect = new EventEmitter();
        this.model = { username: null, password: null };
        this.componentStyle = {};
        this.formType = null;
        this.CognitoFormType = CognitoFormType;
        this.rows = [];
        this.error = null;
        this.prompt = null;
        this.cache = null;
        this.strings = CognitoStrings;
        this.showPasswordField = true;
        this.showEmailSubmitButton = true;
        this.disableUsername = false;
        this.session = null;
        this.user = null;
    }
    ngOnInit() {
        this.cognito.initialize(this.poolId, this.clientId, this.useLocalStorage, this.idToken, this.accessToken, this.refreshToken);
        this.cognito.form$.subscribe(form => {
            this.formType = form;
            this.showCurrentForm();
        });
        this.cognito.session$.subscribe(session => {
            this.session = session;
        });
        this.cognito.user$.subscribe(user => {
            this.user = user;
        });
        this.updateButtons();
    }
    ngAfterViewInit() {
        setTimeout(() => this.initialize());
    }
    onEnterUsername() {
        this.showEmailSubmitButton = false;
        this.onUsernameEntered.emit(this.model.username.replace(/\s+/gim, ""));
    }
    selectProvider(providerId, event) {
        if (event) {
            event.preventDefault();
            event.stopPropagation();
        }
        this.onProviderSelect.emit(providerId);
    }
    trackByProviderId(index, provider) {
        return provider.id;
    }
    updateButtons() {
        if (this.otp || this.magicLink || this.passkeys) {
            this.showPasswordField = false;
        }
    }
    login() {
        return __awaiter(this, void 0, void 0, function* () {
            if (!this.srp && this.otp) {
                return this.getOtp();
            }
            else if (!this.srp && this.magicLink) {
                return this.getMagicLink();
            }
            else if (!this.srp && this.passkeys) {
                return this.getPasskey();
            }
            else if (!this.srp) {
                return this.onEnterUsername();
            }
            let response;
            this.error = null;
            this.model.password = trim(this.model.password);
            if (this.hook) {
                const proceed = yield this.hook({ "state": "before-login", model: this.model });
                if (!proceed)
                    return;
            }
            try {
                const username = this.model.username.replace(/\s+/gim, "");
                this.onConnecting.emit(true);
                response = yield this.cognito.authenticate(username, this.model.password);
            }
            catch (e) {
                response = e;
            }
            finally {
                this.handleResponse(response);
            }
        });
    }
    getOtp() {
        return __awaiter(this, void 0, void 0, function* () {
            let response;
            this.error = null;
            try {
                this.onConnecting.emit(true);
                const username = this.model.username.replace(/\s+/gim, "");
                const otp = this.model.otp ? trim(this.model.otp) : undefined;
                this.srp = false;
                this.magicLink = false;
                this.passkeys = false;
                if (this.hook) {
                    const proceed = yield this.hook({ "state": "before-otp-request", model: this.model });
                    if (!proceed)
                        return this.connectionComplete();
                }
                response = yield this.cognito.otpAuthenticate(username, otp);
                if (this.hook) {
                    //@ts-ignore
                    const proceed = yield this.hook({ "state": "after-otp-request", model: this.model, sessionId: response.user.Session });
                    if (!proceed)
                        throw new Error("Unable to proceed");
                }
            }
            catch (e) {
                response = e;
            }
            finally {
                this.handleResponse(response);
            }
        });
    }
    getMagicLink() {
        return __awaiter(this, void 0, void 0, function* () {
            let response;
            this.error = null;
            try {
                const username = this.model.username.replace(/\s+/gim, "");
                this.onConnecting.emit(true);
                if (this.hook) {
                    const proceed = yield this.hook({ "state": "before-magic-link-request", model: this.model });
                    if (!proceed)
                        return this.connectionComplete();
                }
                response = yield this.cognito.magicLinkAuthenticate(username);
                if (this.hook) {
                    //@ts-ignore
                    const proceed = yield this.hook({ "state": "after-magic-link-request", model: this.model, sessionId: response.user.Session });
                    if (!proceed)
                        return this.connectionComplete();
                }
            }
            catch (e) {
                response = e;
            }
            finally {
                this.connectionComplete();
            }
        });
    }
    processMagicLink(email, code, sessionId) {
        return __awaiter(this, void 0, void 0, function* () {
            try {
                this.onConnecting.emit(true);
                yield this.cognito.magicLinkAuthenticate(email, code, sessionId);
                if (this.reloadAfterLinkAuthentication) {
                    window.location.href = window.location.origin;
                }
                else {
                    this.onAuthenticated.emit(this.getUserData()); //connected
                    this.showForm = false;
                    this.connectionComplete();
                }
            }
            catch (e) { }
        });
    }
    getPasskey() {
        var _a, _b;
        return __awaiter(this, void 0, void 0, function* () {
            const username = this.model.username.replace(/\s+/gim, "");
            this.passkeyAuthOptions = yield this.generateAuthenticationOptions(username);
            const credentials = (_b = (_a = this.passkeyAuthOptions) === null || _a === void 0 ? void 0 : _a.allowCredentials) !== null && _b !== void 0 ? _b : [];
            if (!credentials.length && !this.model.passkey)
                this.sendPasskeyCode();
            else if (!credentials.length)
                this.registerPasskey();
            else
                this.usePasskey();
        });
    }
    sendPasskeyCode() {
        return __awaiter(this, void 0, void 0, function* () {
            const username = this.model.username.replace(/\s+/gim, "");
            const token = yield this.getUserId(username);
            this.srp = false;
            this.otp = false;
            this.magicLink = false;
            this.model.showChallengeEntry = true;
        });
    }
    usePasskey() {
        return __awaiter(this, void 0, void 0, function* () {
            const username = this.model.username.replace(/\s+/gim, "");
            this.onConnecting.emit(true);
            const authentication = yield startAuthentication(this.passkeyAuthOptions);
            const outcome = yield this.verifyAuthentication(authentication);
            yield this.cognito.passkeyAuthenticate(username);
            if (outcome.verified) {
                yield this.cognito.passkeyAuthenticate(username, outcome.uid);
                this.onAuthenticated.emit(this.getUserData());
                this.showForm = false;
                this.connectionComplete();
            }
        });
    }
    registerPasskey() {
        return __awaiter(this, void 0, void 0, function* () {
            const username = this.model.username.replace(/\s+/gim, "");
            const code = this.model.passkey.replace(/\s+/gim, "");
            this.onConnecting.emit(true);
            const options = yield this.generateRegistrationOptions(code);
            const registration = yield startRegistration(options);
            const outcome = yield this.verifyRegistration(registration, code);
            yield this.cognito.passkeyAuthenticate(username);
            if (outcome.verified) {
                yield this.cognito.passkeyAuthenticate(username, outcome.uid);
                this.onAuthenticated.emit(this.getUserData());
                this.showForm = false;
                this.connectionComplete();
            }
        });
    }
    onNewUser() {
        return __awaiter(this, void 0, void 0, function* () {
            let response;
            this.error = null;
            this.model.newPassword = trim(this.model.newPassword);
            if (this.hook) {
                const proceed = yield this.hook({ "state": "before-registration", model: this.model });
                if (!proceed)
                    return;
            }
            try {
                this.onConnecting.emit(true);
                response = yield this.cognito.completePasswordUpdate(this.model.newPassword, this.cache.user, this.getUserAttributes());
            }
            catch (e) {
                response = e;
            }
            finally {
                this.handleResponse(response);
            }
        });
    }
    onForcePasswordReset() {
        return __awaiter(this, void 0, void 0, function* () {
            this.model.code = trim(this.model.code);
            this.model.newPassword = trim(this.model.newPassword);
            this.onConnecting.emit(true);
            if (this.hook) {
                const proceed = yield this.hook({ "state": "before-force-password-reset", model: this.model });
                if (!proceed)
                    return;
            }
            try {
                const response = yield this.cognito.confirmPassword(this.cache.user, this.model.code, this.model.newPassword);
                this.error = null;
                this.transitioning = true;
                yield tick(250);
                this.formType = CognitoFormType.Login;
                this.setMessaging(response, CognitoStrings.onUserPasswordChangeSuccessful);
                yield tick(0);
                this.transitioning = false;
            }
            catch (e) {
                this.setMessaging(e);
            }
            finally {
                this.onConnecting.emit(false);
            }
        });
    }
    onUserPasswordReset() {
        return __awaiter(this, void 0, void 0, function* () {
            this.error = null;
            this.onConnecting.emit(true);
            this.model.password = trim(this.model.password);
            this.model.newPassword = trim(this.model.newPassword);
            if (this.hook) {
                const proceed = yield this.hook({ "state": "before-user-password-reset", model: this.model });
                if (!proceed)
                    return;
            }
            try {
                const response = yield this.cognito.resetPassword(this.user, this.model.password, this.model.newPassword);
                this.transitioning = true;
                yield tick(250);
                this.formType = CognitoFormType.PasswordUpdateSuccessful;
                this.prompt = CognitoStrings.onPasswordUpdated;
                this.error = null;
                yield tick();
                this.transitioning = false;
            }
            catch (e) {
                this.setMessaging(e);
            }
            finally {
                this.onConnecting.emit(false);
            }
        });
    }
    onForgotPassword($event) {
        return __awaiter(this, void 0, void 0, function* () {
            $event.preventDefault();
            $event.stopImmediatePropagation();
            this.transitioning = true;
            yield tick(250);
            this.formType = CognitoFormType.UserVerificationRequest;
            this.prompt = CognitoStrings.onVerificationCodeSent;
            this.error = null;
            yield tick();
            this.transitioning = false;
        });
    }
    onRequestVerificationCode() {
        return __awaiter(this, void 0, void 0, function* () {
            const username = this.model.username.replace(/\s+/gim, "");
            const model = { username };
            if (this.hook) {
                const proceed = yield this.hook({ "state": "request-verification-code", "username": username, model });
                if (!proceed)
                    return;
                this.model.username = model.username;
            }
            this.onConnecting.emit(true);
            this.error = null;
            try {
                const response = yield this.cognito.requestVerificationCode(model.username);
                this.transitioning = true;
                yield tick(250);
                this.setMessaging(response, CognitoStrings.onNewPasswordRequired);
                this.showPasswordResetForm(response, false);
            }
            catch (e) {
                this.setMessaging(e);
            }
            finally {
                this.connectionComplete();
            }
        });
    }
    newUserFormDisabled() {
        var _a, _b;
        let disabled = false;
        (_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.requiredAttributes) === null || _b === void 0 ? void 0 : _b.forEach(key => {
            if (!this.model[key])
                disabled = true;
        });
        if (!this.model.newPassword || !this.model.newPasswordConfirm) {
            disabled = true;
        }
        if (this.model.newPassword !== this.model.newPasswordConfirm) {
            disabled = true;
        }
        return disabled;
    }
    initialize() {
        return __awaiter(this, void 0, void 0, function* () {
            try {
                if (this.cognitoUrl && localStorage.getItem("ems_access_token")) {
                    const info = yield this.cognito.getUserInfo(this.cognitoUrl);
                    //emulate cognito user/session for federated login
                    this.session = new CognitoUserSession({
                        IdToken: new CognitoIdToken({ IdToken: info.idToken }),
                        AccessToken: new CognitoAccessToken({ AccessToken: info.accessToken }),
                    });
                    this.cognito.createFederatedSession(info.idToken, info.accessToken);
                }
            }
            catch (error) {
            }
            finally {
                if (this.session) {
                    this.onAuthenticated.emit(this.getUserData());
                }
            }
        });
    }
    handleResponse(response) {
        var _a, _b, _c;
        return __awaiter(this, void 0, void 0, function* () {
            this.transitioning = true;
            yield tick(250);
            this.setMessaging(response);
            this.cache = response.userAttributes ? response : this.cache;
            if (((_a = response.error) === null || _a === void 0 ? void 0 : _a.code) === CognitoResponseType.NotAuthorized && response.request === CognitoRequestType.Authentication) {
                this.connectionComplete(); //likely bad password or too many attempts
            }
            else if (((_b = response.error) === null || _b === void 0 ? void 0 : _b.code) === CognitoResponseType.ForcePasswordReset && response.request === CognitoRequestType.Authentication) {
                this.initiatePasswordReset(response); //admin has forced user password reset
            }
            else if (response.type === CognitoResponseType.OtpChallenge) {
                this.model.showChallengeEntry = true;
                this.connectionComplete();
            }
            else if (response.type === CognitoResponseType.PasswordReset && response.request === CognitoRequestType.Authentication) {
                this.prompt = CognitoStrings.onFirstLogin;
                this.showPasswordResetForm(response); //new user
            }
            else if (!((_c = response.error) === null || _c === void 0 ? void 0 : _c.code) && (response.request === CognitoRequestType.Authentication || response.type === CognitoResponseType.Authenticated)) {
                this.onAuthenticated.emit(this.getUserData()); //connected
                this.showForm = false;
                this.connectionComplete();
            }
            else {
                this.connectionComplete(); //unsupported response -- hopefully described in messaging
            }
            this.onResponse.emit({ response, model: this.model });
        });
    }
    initiatePasswordReset(response) {
        return __awaiter(this, void 0, void 0, function* () {
            this.error = null;
            try {
                const result = yield this.cognito.forgotPassword(response.user);
                this.setMessaging(result, CognitoStrings.onNewPasswordRequired);
                yield tick(250);
                this.showPasswordResetForm(response, false);
            }
            catch (e) {
                this.setMessaging(e);
            }
            finally {
                this.connectionComplete();
            }
        });
    }
    setMessaging(response, prompt = null) {
        var _a, _b, _c;
        if (((_a = response.error) === null || _a === void 0 ? void 0 : _a.code) === CognitoResponseType.LimitExceededException) {
            this.error = CognitoStrings.onTooManyAttempts;
        }
        else {
            this.error = (_c = (_b = response.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : null;
        }
        this.prompt = prompt;
    }
    connectionComplete() {
        return __awaiter(this, void 0, void 0, function* () {
            yield tick();
            this.transitioning = false;
            this.onConnecting.emit(false);
        });
    }
    showCurrentForm() {
        return __awaiter(this, void 0, void 0, function* () {
            if (!this.formType)
                return;
            if (this.formType === CognitoFormType.GoogleSignIn) {
                return this.signInWithGoogle();
            }
            this.hostStyle = {
                "background": this.modalBackground,
                "z-index": this.zIndex
            };
            yield tick();
            this.showForm = true;
            this.onReady.emit();
        });
    }
    showPasswordResetForm(result, isNewUser = true) {
        var _a, _b;
        return __awaiter(this, void 0, void 0, function* () {
            this.cache = result;
            this.rows = [];
            this.formType = isNewUser ? CognitoFormType.NewUser : CognitoFormType.ForcePasswordReset;
            //bubble first and last name fields to the top of the attributes list
            (_a = result.requiredAttributes) === null || _a === void 0 ? void 0 : _a.sort((a, b) => {
                if (a === "given_name" && b === "family_name")
                    return -1;
                if (b === "given_name" && a === "family_name")
                    return 1;
                if (a === "given_name")
                    return -1;
                if (a === "family_name")
                    return -1;
                if (b === "given_name")
                    return 1;
                if (b === "family_name")
                    return 1;
                return a > b ? 1 : -1;
            });
            //inject formrows for required attributes
            (_b = result.requiredAttributes) === null || _b === void 0 ? void 0 : _b.forEach(key => {
                if (key.match(/^email/))
                    return;
                const value = result.userAttributes[key];
                this.rows.push({
                    label: unsnake(key),
                    key
                });
                this.model[key] = value && value.length ? value : undefined;
            });
            yield tick();
            this.connectionComplete();
        });
    }
    getUserAttributes() {
        var _a;
        const attributes = {};
        if (!((_a = this.cache) === null || _a === void 0 ? void 0 : _a.requiredAttributes))
            return attributes;
        this.cache.requiredAttributes.forEach(key => attributes[key] = this.model[key]);
        return attributes;
    }
    signInWithGoogle() {
        const url = `${this.cognitoUrl}/oauth2/authorize?identity_provider=${this.providerName}&redirect_uri=${window.location.origin}&response_type=TOKEN&client_id=${this.clientId}&scope=email openid profile aws.cognito.signin.user.admin`;
        window.location.href = url;
    }
    getUserData() {
        return {
            email: this.session.getIdToken().payload["email"],
            username: this.session.getIdToken().payload["cognito:username"],
            sub: this.session.getIdToken().payload["sub"],
            firstName: this.session.getIdToken().payload["given_name"],
            lastName: this.session.getIdToken().payload["family_name"],
            idToken: this.session.getIdToken().getJwtToken(),
            accessToken: this.session.getAccessToken().getJwtToken(),
        };
    }
}
CognitoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoComponent, deps: [{ token: CognitoService }], target: i0.ɵɵFactoryTarget.Component });
CognitoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: CognitoComponent, selector: "cognito", inputs: { poolId: ["pool-id", "poolId"], providerName: ["provider-name", "providerName"], clientId: ["client-id", "clientId"], cognitoUrl: ["cognito-signin-url", "cognitoUrl"], region: "region", modalBackground: ["modal-background", "modalBackground"], zIndex: ["z-index", "zIndex"], hook: "hook", srp: "srp", otp: "otp", sso: "sso", magicLink: ["magic-link", "magicLink"], magicLinkGenerator: ["magic-link-generator", "magicLinkGenerator"], reloadAfterLinkAuthentication: ["reload-after-link-authentication", "reloadAfterLinkAuthentication"], passkeys: "passkeys", useLocalStorage: "useLocalStorage", idToken: "idToken", accessToken: "accessToken", refreshToken: "refreshToken", ssoLink: ["sso-link", "ssoLink"], ssoProviders: ["sso-providers", "ssoProviders"], getUserId: ["passkeys-get-user-id", "getUserId"], generateAuthenticationOptions: ["passkeys-generate-authentication-options", "generateAuthenticationOptions"], generateRegistrationOptions: ["passkeys-generate-registration-options", "generateRegistrationOptions"], verifyRegistration: ["passkeys-verify-registration", "verifyRegistration"], verifyAuthentication: ["passkeys-verify-authentication", "verifyAuthentication"] }, outputs: { onReady: "ready", onConnecting: "connecting", onAuthenticated: "authenticated", onResponse: "response", onUsernameEntered: "usernameEntered", onProviderSelect: "providerSelect" }, host: { properties: { "style": "this.hostStyle", "class.render": "this.showForm", "class.transitioning": "this.transitioning" } }, ngImport: i0, template: "<form *ngIf=\"showForm && formType === CognitoFormType.Login\" class=\"cognito-form\" (submit)=\"login()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\" [disabled]=\"disableUsername\"/>\n\t</div>\n\t<div *ngIf=\"!srp && !otp && !passkeys && !magicLink && showEmailSubmitButton\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"onEnterUsername()\" [disabled]=\"!model.username\">{{ strings.labelSubmit }}</button>\n\t</div>\n\t<div *ngIf=\"srp && !showPasswordField\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"showPasswordField = true; otp = false; magicLink = false; passkeys = false; sso = false;\" [disabled]=\"!model.username\">{{ strings.labelUseRegularPassword }}</button>\n\t</div>\n\t<div *ngIf=\"srp && showPasswordField\" class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password\">{{ strings.labelPassword }}</label>\n\t\t<input id=\"password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password\" [(ngModel)]=\"model.password\"/>\n\t</div>\n\t<div *ngIf=\"srp && showPasswordField\" class=\"cognito-buttons\">\n\t\t<button type=\"button\" class=\"a\" (click)=\"onForgotPassword($event)\">{{ strings.labelForgotPassword }}</button>\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [value]=\"strings.labelSubmit\"/>\n\t</div>\n\t<div *ngIf=\"ssoProviders.length\" class=\"cognito-sso-section\">\n\t\t<hr class=\"cognito-sso-divider\" />\n\t\t<p class=\"cognito-sso-label\">{{ strings.labelOrSignInWith }}</p>\n\t\t<div class=\"cognito-sso-buttons\">\n\t\t\t<button *ngFor=\"let provider of ssoProviders; trackBy: trackByProviderId\" type=\"button\" class=\"cognito-input cognito-button cognito-sso-provider\" (click)=\"selectProvider(provider.id, $event)\" [title]=\"provider.hoverText\">\n\t\t\t\t<img [src]=\"provider.icon\" [alt]=\"provider.label\" class=\"cognito-sso-icon\" /><span>{{ provider.label }}</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>\n\t<div *ngIf=\"otp && model.showChallengeEntry\" class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"otp\">{{ strings.labelOtpEnter }}</label>\n\t\t<input id=\"otp\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"text\" name=\"otp\" [(ngModel)]=\"model.otp\"/>\n\t</div>\n\t<div *ngIf=\"passkeys && model.showChallengeEntry\" class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"passkey-reg\">{{ strings.labelPasskeyEnter }}</label>\n\t\t<textarea id=\"passkey-reg\" autocomplete=\"off\" class=\"cognito-input cognito-text\" name=\"passkey-reg\" [(ngModel)]=\"model.passkey\"></textarea>\n\t</div>\n\t<div *ngIf=\"otp\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"getOtp()\" [disabled]=\"!model.username\">{{ model.showChallengeEntry ? strings.labelSubmit : strings.labelOtp }}</button>\n\t</div>\t\n\t<div *ngIf=\"magicLink\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"getMagicLink()\" [disabled]=\"!model.username\">{{ strings.labelMagicLink }}</button>\n\t</div>\t\n\t<div *ngIf=\"passkeys\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"getPasskey()\" [disabled]=\"!model.username\">{{ model.showChallengeEntry ? strings.labelSubmit : strings.labelPasskeys }}</button>\n\t</div>\t\n\t<div *ngIf=\"sso && ssoLink\" class=\"cognito-buttons\">\n\t\t<a class=\"cognito-input cognito-submit cognito-button\" type=\"button\" [href]=\"ssoLink\">{{ strings.labelSso }}</a>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.NewUser\" class=\"cognito-form\" (submit)=\"onNewUser()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\" disabled />\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label no-mb\" for=\"new-password\">{{ strings.labelNewPassword }}</label>\n\t\t<p class=\"cognito-sublabel\">{{ strings.labelPasswordRequirement }}</p>\n\t\t<input id=\"new-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-new\" [(ngModel)]=\"model.newPassword\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password-confirm\">{{ strings.labelConfirmNewPassword }}</label>\n\t\t<input id=\"password-confirm\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-confirm\" [(ngModel)]=\"model.newPasswordConfirm\"/>\n\t</div>\n\t<div class=\"cognito-formrow\" *ngFor=\"let row of rows\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ row.label|labeler }}</label>\n\t\t<input [id]=\"row.key\"  class=\"cognito-input cognito-text\" type=\"text\" [name]=\"row.key\" [(ngModel)]=\"model[row.key]\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"newUserFormDisabled()\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.ForcePasswordReset\" class=\"cognito-form\" (submit)=\"onForcePasswordReset()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\" disabled />\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"code\">{{ strings.labelCode }}</label>\n\t\t<input id=\"code\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"text\" name=\"code\" [(ngModel)]=\"model.code\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"new-password\">{{ strings.labelNewPassword }}</label>\n\t\t<p class=\"cognito-sublabel\">{{ strings.labelPasswordRequirement }}</p>\n\t\t<input id=\"new-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-new\" [(ngModel)]=\"model.newPassword\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password-confirm\">{{ strings.labelConfirmNewPassword }}</label>\n\t\t<input id=\"password-confirm\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-confirm\" [(ngModel)]=\"model.newPasswordConfirm\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"newUserFormDisabled()\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.UserVerificationRequest\" class=\"cognito-form\" (submit)=\"onRequestVerificationCode()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"!model.username\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.UserPasswordReset\" class=\"cognito-form\" (submit)=\"onUserPasswordReset()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"current-password\">{{ strings.labelCurrentPassword }}</label>\n\t\t<input id=\"current-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password\" [(ngModel)]=\"model.password\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"new-password\">{{ strings.labelNewPassword }}</label>\n\t\t<p class=\"cognito-sublabel\">{{ strings.labelPasswordRequirement }}</p>\n\t\t<input id=\"new-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-new\" [(ngModel)]=\"model.newPassword\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password-confirm\">{{ strings.labelConfirmNewPassword }}</label>\n\t\t<input id=\"password-confirm\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-confirm\" [(ngModel)]=\"model.newPasswordConfirm\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"newUserFormDisabled()\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.PasswordUpdateSuccessful\" class=\"cognito-form\" (submit)=\"showForm = false\">\n\t<div class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [value]=\"strings.labelClose\"/>\n\t</div>\t\n</form>", styles: [":host{position:fixed;top:0;left:0;right:0;bottom:0;display:flex;z-index:0;opacity:0;justify-content:center;align-items:center;pointer-events:none;color:#4d4d4d}:host p{margin:0;padding:0}:host.render{opacity:1;transition:opacity 1s;pointer-events:auto}.cognito-form{position:relative;background:white;transition:all .25s;box-sizing:border-box;padding:2rem 1rem;width:calc(100% - 2rem);max-height:calc(100% - 2rem);max-width:30rem;overflow:auto;border:solid 1px #ccc;box-shadow:0 0 8px 2px #0000000d}:host.transitioning .cognito-form{opacity:0;transition:all .25s;pointer-events:none}.cognito-form .button.close{position:absolute;right:1rem;top:1rem;width:1rem;height:1rem;overflow:hidden;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-appearance:none;appearance:none;background:none;border:solid 1px #ccc}.cognito-form .button.close .buttontext{position:absolute;opacity:0}.cognito-form .button.close:after{content:\"x\"}.cognito-form .prompt{font-weight:700;font-style:italic;margin-bottom:1rem;text-align:center}.cognito-form .error{font-style:italic;color:red;text-align:center;margin-top:1rem}.cognito-label{display:block;text-transform:uppercase;font-family:inherit;font-size:.875rem;font-weight:700}:host p.cognito-sublabel{font-size:14px;font-style:italic;margin-left:1rem}.cognito-text{display:block;width:100%;font-size:1.125rem;padding:.25rem;box-sizing:border-box;color:inherit;font-family:inherit;margin-top:.5rem}.cognito-formrow+.cognito-formrow{margin-top:1.25rem}.cognito-buttons{margin-top:2rem;text-align:center}.cognito-buttons button+button,.cognito-buttons button+input{margin-left:2rem}.cognito-buttons button.a{-webkit-appearance:none;appearance:none;background:none;border:0;text-decoration:underline;cursor:pointer}#passkey-reg{resize:none;height:8rem}.cognito-sso-section{margin-top:2rem}.cognito-sso-divider{border:none;border-top:solid 1px #ccc;margin:0 0 1rem}.cognito-sso-label{text-align:center;font-size:.875rem;color:#666;margin-bottom:1rem}.cognito-sso-buttons{display:flex;justify-content:center;gap:1rem;flex-wrap:wrap}.cognito-sso-provider{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;cursor:pointer}.cognito-sso-icon{width:1.25rem;height:1.25rem;object-fit:contain}\n"], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i3.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "labeler": LabelerPipe } });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoComponent, decorators: [{
            type: Component,
            args: [{ selector: 'cognito', template: "<form *ngIf=\"showForm && formType === CognitoFormType.Login\" class=\"cognito-form\" (submit)=\"login()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\" [disabled]=\"disableUsername\"/>\n\t</div>\n\t<div *ngIf=\"!srp && !otp && !passkeys && !magicLink && showEmailSubmitButton\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"onEnterUsername()\" [disabled]=\"!model.username\">{{ strings.labelSubmit }}</button>\n\t</div>\n\t<div *ngIf=\"srp && !showPasswordField\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"showPasswordField = true; otp = false; magicLink = false; passkeys = false; sso = false;\" [disabled]=\"!model.username\">{{ strings.labelUseRegularPassword }}</button>\n\t</div>\n\t<div *ngIf=\"srp && showPasswordField\" class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password\">{{ strings.labelPassword }}</label>\n\t\t<input id=\"password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password\" [(ngModel)]=\"model.password\"/>\n\t</div>\n\t<div *ngIf=\"srp && showPasswordField\" class=\"cognito-buttons\">\n\t\t<button type=\"button\" class=\"a\" (click)=\"onForgotPassword($event)\">{{ strings.labelForgotPassword }}</button>\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [value]=\"strings.labelSubmit\"/>\n\t</div>\n\t<div *ngIf=\"ssoProviders.length\" class=\"cognito-sso-section\">\n\t\t<hr class=\"cognito-sso-divider\" />\n\t\t<p class=\"cognito-sso-label\">{{ strings.labelOrSignInWith }}</p>\n\t\t<div class=\"cognito-sso-buttons\">\n\t\t\t<button *ngFor=\"let provider of ssoProviders; trackBy: trackByProviderId\" type=\"button\" class=\"cognito-input cognito-button cognito-sso-provider\" (click)=\"selectProvider(provider.id, $event)\" [title]=\"provider.hoverText\">\n\t\t\t\t<img [src]=\"provider.icon\" [alt]=\"provider.label\" class=\"cognito-sso-icon\" /><span>{{ provider.label }}</span>\n\t\t\t</button>\n\t\t</div>\n\t</div>\n\t<div *ngIf=\"otp && model.showChallengeEntry\" class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"otp\">{{ strings.labelOtpEnter }}</label>\n\t\t<input id=\"otp\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"text\" name=\"otp\" [(ngModel)]=\"model.otp\"/>\n\t</div>\n\t<div *ngIf=\"passkeys && model.showChallengeEntry\" class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"passkey-reg\">{{ strings.labelPasskeyEnter }}</label>\n\t\t<textarea id=\"passkey-reg\" autocomplete=\"off\" class=\"cognito-input cognito-text\" name=\"passkey-reg\" [(ngModel)]=\"model.passkey\"></textarea>\n\t</div>\n\t<div *ngIf=\"otp\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"getOtp()\" [disabled]=\"!model.username\">{{ model.showChallengeEntry ? strings.labelSubmit : strings.labelOtp }}</button>\n\t</div>\t\n\t<div *ngIf=\"magicLink\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"getMagicLink()\" [disabled]=\"!model.username\">{{ strings.labelMagicLink }}</button>\n\t</div>\t\n\t<div *ngIf=\"passkeys\" class=\"cognito-buttons\">\n\t\t<button class=\"cognito-input cognito-submit cognito-button\" type=\"button\" (click)=\"getPasskey()\" [disabled]=\"!model.username\">{{ model.showChallengeEntry ? strings.labelSubmit : strings.labelPasskeys }}</button>\n\t</div>\t\n\t<div *ngIf=\"sso && ssoLink\" class=\"cognito-buttons\">\n\t\t<a class=\"cognito-input cognito-submit cognito-button\" type=\"button\" [href]=\"ssoLink\">{{ strings.labelSso }}</a>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.NewUser\" class=\"cognito-form\" (submit)=\"onNewUser()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\" disabled />\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label no-mb\" for=\"new-password\">{{ strings.labelNewPassword }}</label>\n\t\t<p class=\"cognito-sublabel\">{{ strings.labelPasswordRequirement }}</p>\n\t\t<input id=\"new-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-new\" [(ngModel)]=\"model.newPassword\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password-confirm\">{{ strings.labelConfirmNewPassword }}</label>\n\t\t<input id=\"password-confirm\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-confirm\" [(ngModel)]=\"model.newPasswordConfirm\"/>\n\t</div>\n\t<div class=\"cognito-formrow\" *ngFor=\"let row of rows\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ row.label|labeler }}</label>\n\t\t<input [id]=\"row.key\"  class=\"cognito-input cognito-text\" type=\"text\" [name]=\"row.key\" [(ngModel)]=\"model[row.key]\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"newUserFormDisabled()\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.ForcePasswordReset\" class=\"cognito-form\" (submit)=\"onForcePasswordReset()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\" disabled />\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"code\">{{ strings.labelCode }}</label>\n\t\t<input id=\"code\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"text\" name=\"code\" [(ngModel)]=\"model.code\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"new-password\">{{ strings.labelNewPassword }}</label>\n\t\t<p class=\"cognito-sublabel\">{{ strings.labelPasswordRequirement }}</p>\n\t\t<input id=\"new-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-new\" [(ngModel)]=\"model.newPassword\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password-confirm\">{{ strings.labelConfirmNewPassword }}</label>\n\t\t<input id=\"password-confirm\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-confirm\" [(ngModel)]=\"model.newPasswordConfirm\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"newUserFormDisabled()\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.UserVerificationRequest\" class=\"cognito-form\" (submit)=\"onRequestVerificationCode()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"username\">{{ strings.labelEmail }}</label>\n\t\t<input id=\"username\" class=\"cognito-input cognito-text\" type=\"text\" name=\"username\" [(ngModel)]=\"model.username\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"!model.username\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.UserPasswordReset\" class=\"cognito-form\" (submit)=\"onUserPasswordReset()\">\n\t<button class=\"button close\" (click)=\"showForm=false\" type=\"button\"><span class=\"buttontext\">{{ strings.labelClose }}</span></button>\n\t<div *ngIf=\"prompt\" class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"current-password\">{{ strings.labelCurrentPassword }}</label>\n\t\t<input id=\"current-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password\" [(ngModel)]=\"model.password\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"new-password\">{{ strings.labelNewPassword }}</label>\n\t\t<p class=\"cognito-sublabel\">{{ strings.labelPasswordRequirement }}</p>\n\t\t<input id=\"new-password\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-new\" [(ngModel)]=\"model.newPassword\"/>\n\t</div>\n\t<div class=\"cognito-formrow\">\n\t\t<label class=\"cognito-label\" for=\"password-confirm\">{{ strings.labelConfirmNewPassword }}</label>\n\t\t<input id=\"password-confirm\" autocomplete=\"off\" class=\"cognito-input cognito-text\" type=\"password\" name=\"password-confirm\" [(ngModel)]=\"model.newPasswordConfirm\"/>\n\t</div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [disabled]=\"newUserFormDisabled()\" [value]=\"strings.labelSubmit\"/>\n\t</div>\t\n\t<div *ngIf=\"error\" class=\"error\" [innerHtml]=\"error\"></div>\n</form>\n<form *ngIf=\"showForm && formType === CognitoFormType.PasswordUpdateSuccessful\" class=\"cognito-form\" (submit)=\"showForm = false\">\n\t<div class=\"prompt\" [innerHtml]=\"prompt\"></div>\n\t<div class=\"cognito-buttons\">\n\t\t<input class=\"cognito-input cognito-submit cognito-button\" type=\"submit\" [value]=\"strings.labelClose\"/>\n\t</div>\t\n</form>", styles: [":host{position:fixed;top:0;left:0;right:0;bottom:0;display:flex;z-index:0;opacity:0;justify-content:center;align-items:center;pointer-events:none;color:#4d4d4d}:host p{margin:0;padding:0}:host.render{opacity:1;transition:opacity 1s;pointer-events:auto}.cognito-form{position:relative;background:white;transition:all .25s;box-sizing:border-box;padding:2rem 1rem;width:calc(100% - 2rem);max-height:calc(100% - 2rem);max-width:30rem;overflow:auto;border:solid 1px #ccc;box-shadow:0 0 8px 2px #0000000d}:host.transitioning .cognito-form{opacity:0;transition:all .25s;pointer-events:none}.cognito-form .button.close{position:absolute;right:1rem;top:1rem;width:1rem;height:1rem;overflow:hidden;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-appearance:none;appearance:none;background:none;border:solid 1px #ccc}.cognito-form .button.close .buttontext{position:absolute;opacity:0}.cognito-form .button.close:after{content:\"x\"}.cognito-form .prompt{font-weight:700;font-style:italic;margin-bottom:1rem;text-align:center}.cognito-form .error{font-style:italic;color:red;text-align:center;margin-top:1rem}.cognito-label{display:block;text-transform:uppercase;font-family:inherit;font-size:.875rem;font-weight:700}:host p.cognito-sublabel{font-size:14px;font-style:italic;margin-left:1rem}.cognito-text{display:block;width:100%;font-size:1.125rem;padding:.25rem;box-sizing:border-box;color:inherit;font-family:inherit;margin-top:.5rem}.cognito-formrow+.cognito-formrow{margin-top:1.25rem}.cognito-buttons{margin-top:2rem;text-align:center}.cognito-buttons button+button,.cognito-buttons button+input{margin-left:2rem}.cognito-buttons button.a{-webkit-appearance:none;appearance:none;background:none;border:0;text-decoration:underline;cursor:pointer}#passkey-reg{resize:none;height:8rem}.cognito-sso-section{margin-top:2rem}.cognito-sso-divider{border:none;border-top:solid 1px #ccc;margin:0 0 1rem}.cognito-sso-label{text-align:center;font-size:.875rem;color:#666;margin-bottom:1rem}.cognito-sso-buttons{display:flex;justify-content:center;gap:1rem;flex-wrap:wrap}.cognito-sso-provider{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;cursor:pointer}.cognito-sso-icon{width:1.25rem;height:1.25rem;object-fit:contain}\n"] }]
        }], ctorParameters: function () { return [{ type: CognitoService }]; }, propDecorators: { hostStyle: [{
                type: HostBinding,
                args: ["style"]
            }], showForm: [{
                type: HostBinding,
                args: ["class.render"]
            }], transitioning: [{
                type: HostBinding,
                args: ["class.transitioning"]
            }], poolId: [{
                type: Input,
                args: ["pool-id"]
            }], providerName: [{
                type: Input,
                args: ["provider-name"]
            }], clientId: [{
                type: Input,
                args: ["client-id"]
            }], cognitoUrl: [{
                type: Input,
                args: ["cognito-signin-url"]
            }], region: [{
                type: Input,
                args: ["region"]
            }], modalBackground: [{
                type: Input,
                args: ["modal-background"]
            }], zIndex: [{
                type: Input,
                args: ["z-index"]
            }], hook: [{
                type: Input,
                args: ["hook"]
            }], srp: [{
                type: Input,
                args: ["srp"]
            }], otp: [{
                type: Input,
                args: ["otp"]
            }], sso: [{
                type: Input,
                args: ["sso"]
            }], magicLink: [{
                type: Input,
                args: ["magic-link"]
            }], magicLinkGenerator: [{
                type: Input,
                args: ["magic-link-generator"]
            }], reloadAfterLinkAuthentication: [{
                type: Input,
                args: ["reload-after-link-authentication"]
            }], passkeys: [{
                type: Input,
                args: ["passkeys"]
            }], useLocalStorage: [{
                type: Input,
                args: ["useLocalStorage"]
            }], idToken: [{
                type: Input,
                args: ["idToken"]
            }], accessToken: [{
                type: Input,
                args: ["accessToken"]
            }], refreshToken: [{
                type: Input,
                args: ["refreshToken"]
            }], ssoLink: [{
                type: Input,
                args: ["sso-link"]
            }], ssoProviders: [{
                type: Input,
                args: ["sso-providers"]
            }], getUserId: [{
                type: Input,
                args: ["passkeys-get-user-id"]
            }], generateAuthenticationOptions: [{
                type: Input,
                args: ["passkeys-generate-authentication-options"]
            }], generateRegistrationOptions: [{
                type: Input,
                args: ["passkeys-generate-registration-options"]
            }], verifyRegistration: [{
                type: Input,
                args: ["passkeys-verify-registration"]
            }], verifyAuthentication: [{
                type: Input,
                args: ["passkeys-verify-authentication"]
            }], onReady: [{
                type: Output,
                args: ["ready"]
            }], onConnecting: [{
                type: Output,
                args: ["connecting"]
            }], onAuthenticated: [{
                type: Output,
                args: ["authenticated"]
            }], onResponse: [{
                type: Output,
                args: ["response"]
            }], onUsernameEntered: [{
                type: Output,
                args: ["usernameEntered"]
            }], onProviderSelect: [{
                type: Output,
                args: ["providerSelect"]
            }] } });

class CognitoModule {
}
CognitoModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
CognitoModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoModule, declarations: [CognitoComponent,
        LabelerPipe], imports: [FormsModule,
        CommonModule,
        HttpClientModule], exports: [CognitoComponent] });
CognitoModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoModule, imports: [[
            FormsModule,
            CommonModule,
            HttpClientModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: CognitoModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        CognitoComponent,
                        LabelerPipe
                    ],
                    imports: [
                        FormsModule,
                        CommonModule,
                        HttpClientModule
                    ],
                    exports: [
                        CognitoComponent
                    ]
                }]
        }] });

/*
 * Public API Surface of cognito
 */

/**
 * Generated bundle index. Do not edit.
 */

export { CognitoComponent, CognitoFormType, CognitoModule, CognitoService, CognitoStrings, EphemeralStorage };
//# sourceMappingURL=ems-web-app-cognito.mjs.map