{"version":3,"file":"keycloakify-angular-account-pages-totp.mjs","names":[],"sources":["../../src/account/pages/totp/totp.component.ts","../../src/account/pages/totp/totp.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, forwardRef, inject } from '@angular/core';\nimport { ComponentReference } from '@keycloakify/angular/account/classes/component-reference';\nimport { KcClassDirective } from '@keycloakify/angular/account/directives/kc-class';\nimport type { I18n } from '@keycloakify/angular/account/i18n';\nimport type { KcContext } from '@keycloakify/angular/account/KcContext';\nimport { ACCOUNT_CLASSES } from '@keycloakify/angular/account/tokens/classes';\nimport { ACCOUNT_I18N } from '@keycloakify/angular/account/tokens/i18n';\nimport { KC_ACCOUNT_CONTEXT } from '@keycloakify/angular/account/tokens/kc-context';\nimport { KcSanitizePipe } from '@keycloakify/angular/lib/pipes/kc-sanitize';\nimport { USE_DEFAULT_CSS } from '@keycloakify/angular/lib/tokens/use-default-css';\nimport type { ClassKey } from 'keycloakify/account/lib/kcClsx';\n\n@Component({\n    imports: [KcClassDirective, KcSanitizePipe],\n    selector: 'kc-totp',\n    templateUrl: 'totp.component.html',\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    providers: [\n        {\n            provide: ComponentReference,\n            useExisting: forwardRef(() => TotpComponent)\n        }\n    ]\n})\nexport class TotpComponent extends ComponentReference {\n    i18n = inject<I18n>(ACCOUNT_I18N);\n    kcContext = inject<Extract<KcContext, { pageId: 'totp.ftl' }>>(KC_ACCOUNT_CONTEXT);\n    override doUseDefaultCss = inject<boolean>(USE_DEFAULT_CSS);\n    override classes = inject<Partial<Record<ClassKey, string>>>(ACCOUNT_CLASSES);\n    active = 'totp';\n}\n","@let url = kcContext.url;\n@let mode = kcContext.mode;\n@let messagesPerField = kcContext.messagesPerField;\n@let stateChecker = kcContext.stateChecker;\n@let totp = kcContext.totp;\n\n<div class=\"row\">\n    <div class=\"col-md-10\">\n        <h2>{{ i18n.msgStr('authenticatorTitle') }}</h2>\n    </div>\n    @if (totp.otpCredentials.length) {\n        <div class=\"subtitle col-md-2\">\n            <span class=\"required\">*</span>\n            {{ i18n.msgStr('requiredFields') }}\n        </div>\n    }\n</div>\n@if (totp.enabled) {\n    <table class=\"table table-bordered table-striped\">\n        <thead>\n            @if (totp.otpCredentials.length > 1) {\n                <tr>\n                    <th [colSpan]=\"4\">{{ i18n.msgStr('configureAuthenticators') }}</th>\n                </tr>\n            } @else {\n                <tr>\n                    <th [colSpan]=\"3\">{{ i18n.msgStr('configureAuthenticators') }}</th>\n                </tr>\n            }\n        </thead>\n        <tbody>\n            @for (credential of totp.otpCredentials; track credential; let index = $index) {\n                <tr>\n                    <td class=\"provider\">{{ i18n.msgStr('mobile') }}</td>\n                    @if (totp.otpCredentials.length > 1) {\n                        <td class=\"provider\">{{ credential.id }}</td>\n                    }\n                    <td class=\"provider\">{{ credential.userLabel || '' }}</td>\n                    <td class=\"action\">\n                        <form\n                            method=\"post\"\n                            class=\"form-inline\"\n                            [action]=\"url.totpUrl\"\n                        >\n                            <input\n                                type=\"hidden\"\n                                id=\"stateChecker\"\n                                name=\"stateChecker\"\n                                [value]=\"stateChecker\"\n                            />\n                            <input\n                                type=\"hidden\"\n                                id=\"submitAction\"\n                                name=\"submitAction\"\n                                value=\"Delete\"\n                            />\n                            <input\n                                type=\"hidden\"\n                                id=\"credentialId\"\n                                name=\"credentialId\"\n                                [value]=\"credential.id\"\n                            />\n                            <button\n                                class=\"btn btn-default\"\n                                [id]=\"'remove-mobile-' + index\"\n                            >\n                                <i class=\"pficon pficon-delete\"></i>\n                            </button>\n                        </form>\n                    </td>\n                </tr>\n            }\n        </tbody>\n    </table>\n} @else {\n    <div>\n        <hr />\n        <ol id=\"kc-totp-settings\">\n            <li>\n                <p>{{ i18n.msgStr('totpStep1') }}</p>\n\n                <ul id=\"kc-totp-supported-apps\">\n                    @for (app of totp.supportedApplications; track app) {\n                        <li>{{ i18n.advancedMsgStr(app) }}</li>\n                    }\n                </ul>\n            </li>\n            @if (mode && mode === 'manual') {\n                <li>\n                    <p>{{ i18n.msgStr('totpManualStep2') }}</p>\n                    <p>\n                        <span id=\"kc-totp-secret-key\">{{ totp.totpSecretEncoded }}</span>\n                    </p>\n                    <p>\n                        <a\n                            id=\"mode-barcode\"\n                            [href]=\"totp.qrUrl\"\n                        >\n                            {{ i18n.msgStr('totpScanBarcode') }}\n                        </a>\n                    </p>\n                </li>\n                <li>\n                    <p>{{ i18n.msgStr('totpManualStep3') }}</p>\n                    <ul>\n                        <li id=\"kc-totp-type\">{{ i18n.msgStr('totpType') }}: {{ i18n.msgStr($any('totp.' + totp.policy.type)) }}</li>\n                        <li id=\"kc-totp-algorithm\">{{ i18n.msgStr('totpAlgorithm') }}: {{ totp.policy.getAlgorithmKey() }}</li>\n                        <li id=\"kc-totp-digits\">{{ i18n.msgStr('totpDigits') }}: {{ totp.policy.digits }}</li>\n                        @if (totp.policy.type === 'totp') {\n                            <li id=\"kc-totp-period\">{{ i18n.msgStr('totpInterval') }}: {{ totp.policy.period }}</li>\n                        } @else {\n                            <li id=\"kc-totp-counter\">{{ i18n.msgStr('totpCounter') }}: {{ totp.policy.initialCounter }}</li>\n                        }\n                    </ul>\n                </li>\n            } @else {\n                <li>\n                    <p>{{ i18n.msgStr('totpStep2') }}</p>\n                    <p>\n                        <img\n                            id=\"kc-totp-secret-qr-code\"\n                            alt=\"Figure: Barcode\"\n                            [src]=\"'data:image/png;base64, ' + totp.totpSecretQrCode\"\n                        />\n                    </p>\n                    <p>\n                        <a\n                            id=\"mode-manual\"\n                            [href]=\"totp.manualUrl\"\n                        >\n                            {{ i18n.msgStr('totpUnableToScan') }}\n                        </a>\n                    </p>\n                </li>\n            }\n            <li>\n                <p>{{ i18n.msgStr('totpStep3') }}</p>\n                <p>{{ i18n.msgStr('totpStep3DeviceName') }}</p>\n            </li>\n        </ol>\n        <hr />\n        <form\n            id=\"kc-totp-settings-form\"\n            method=\"post\"\n            [action]=\"url.totpUrl\"\n            [kcClass]=\"'kcFormClass'\"\n        >\n            <input\n                type=\"hidden\"\n                id=\"stateChecker\"\n                name=\"stateChecker\"\n                [value]=\"stateChecker\"\n            />\n            <div [kcClass]=\"'kcFormGroupClass'\">\n                <div class=\"col-sm-2 col-md-2\">\n                    <label\n                        for=\"totp\"\n                        class=\"control-label\"\n                    >\n                        {{ i18n.msgStr('authenticatorCode') }}\n                    </label>\n                    <span class=\"required\">*</span>\n                </div>\n                <div class=\"col-sm-10 col-md-10\">\n                    <input\n                        type=\"text\"\n                        id=\"totp\"\n                        name=\"totp\"\n                        autocomplete=\"off\"\n                        [kcClass]=\"'kcInputClass'\"\n                        [attr.aria-invalid]=\"messagesPerField.existsError('totp')\"\n                    />\n                    @if (messagesPerField.existsError('totp')) {\n                        <span\n                            id=\"input-error-otp-code\"\n                            aria-live=\"polite\"\n                            [kcClass]=\"'kcInputErrorMessageClass'\"\n                            [innerHTML]=\"messagesPerField.get('totp') | kcSanitize: 'html'\"\n                        ></span>\n                    }\n                </div>\n                <input\n                    type=\"hidden\"\n                    id=\"totpSecret\"\n                    name=\"totpSecret\"\n                    [value]=\"totp.totpSecret\"\n                />\n                @if (mode) {\n                    <input\n                        type=\"hidden\"\n                        id=\"mode\"\n                        [value]=\"mode\"\n                    />\n                }\n            </div>\n\n            <div [kcClass]=\"'kcFormGroupClass'\">\n                <div class=\"col-sm-2 col-md-2\">\n                    <label\n                        for=\"userLabel\"\n                        [kcClass]=\"'kcLabelClass'\"\n                    >\n                        {{ i18n.msgStr('totpDeviceName') }}\n                    </label>\n                    @if (totp.otpCredentials.length >= 1) {\n                        <span class=\"required\">*</span>\n                    }\n                </div>\n                <div class=\"col-sm-10 col-md-10\">\n                    <input\n                        type=\"text\"\n                        id=\"userLabel\"\n                        name=\"userLabel\"\n                        autocomplete=\"off\"\n                        [kcClass]=\"'kcInputClass'\"\n                        [attr.aria-invalid]=\"messagesPerField.existsError('userLabel')\"\n                    />\n                    @if (messagesPerField.existsError('userLabel')) {\n                        <span\n                            id=\"input-error-otp-label\"\n                            aria-live=\"polite\"\n                            [kcClass]=\"'kcInputErrorMessageClass'\"\n                            [innerHTML]=\"messagesPerField.get('userLabel') | kcSanitize: 'html'\"\n                        ></span>\n                    }\n                </div>\n            </div>\n\n            <div\n                id=\"kc-form-buttons\"\n                class=\"text-right\"\n                [kcClass]=\"'kcFormGroupClass'\"\n            >\n                <div [kcClass]=\"'kcInputWrapperClass'\">\n                    <input\n                        type=\"submit\"\n                        id=\"saveTOTPBtn\"\n                        [kcClass]=\"['kcButtonClass', 'kcButtonPrimaryClass', 'kcButtonLargeClass']\"\n                        [value]=\"i18n.msgStr('doSave')\"\n                    />\n                    <button\n                        type=\"submit\"\n                        id=\"cancelTOTPBtn\"\n                        name=\"submitAction\"\n                        value=\"Cancel\"\n                        [kcClass]=\"['kcButtonClass', 'kcButtonDefaultClass', 'kcButtonLargeClass']\"\n                    >\n                        {{ i18n.msgStr('doCancel') }}\n                    </button>\n                </div>\n            </div>\n        </form>\n    </div>\n}\n"],"mappings":";;;;;;;;;AAwBA,IAAa,gBAAb,MAAa,sBAAsB,mBAAkB;CAZrD,cAAA;;EAaI,KAAA,OAAO,OAAa,YAAY;EAChC,KAAA,YAAY,OAAmD,kBAAkB;EACxE,KAAA,kBAAkB,OAAgB,eAAe;EACjD,KAAA,UAAU,OAA0C,eAAe;EAC5E,KAAA,SAAS;CACZ;CANY;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAa,MAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAb;EAAA,KAAA,OAAA,GAAA,qBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,MAAA;GAAa,cAAA;GAAA,UAAA;GAAA,WAPX,CACP;IACI,SAAS;IACT,aAAa,iBAAiB,aAAa;GAC9C,CACJ;GAAA,iBAAA;GAAA,UAAA;GAAA,UCtBL;GA8PA,cAAA,CAAA;IAAA,MAAA;IAAA,MDjPc;IAAgB,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;IAAA;GAAA,GAAA;IAAA,MAAA;IAAA,MAAE;IAAc,MAAA;GAAA,CAAA;GAAA,iBAAA,GAAA,wBAAA;EAAA,CAAA;CAAA;;AAWjC,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EAZzB,MAAA;EACY,MAAA,CAAA;GAAA,SAAA,CAAC,kBAAkB,cAAc;GAAC,UACjC;GAAS,iBAEF,wBAAwB;GAAM,WACpC,CACP;IACI,SAAS;IACT,aAAa,iBAAgB,aAAc;GAC9C,CACJ;GAAA,UAAA;EAAA,CAAA"}