85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
// Metro module 13751 (f13752).
|
|
import { AuthenticatorType } from "../../flow/Server";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c9565_2 = false;
|
|
const credentials = [];
|
|
let c9565_4 = false;
|
|
class WebAuthnStore extends Module589.Store {
|
|
static displayName = "WebAuthnStore";
|
|
hasFetchedCredentials() {
|
|
return c9565_2;
|
|
}
|
|
get hasCredentials() {
|
|
return credentials.length > 0;
|
|
}
|
|
getCredentials() {
|
|
return credentials;
|
|
}
|
|
hasPendingRegisterTrigger() {
|
|
return c9565_4;
|
|
}
|
|
}
|
|
const webAuthnStore = new WebAuthnStore(Dispatcher, {
|
|
LOGOUT: function handleReset() {
|
|
credentials = [];
|
|
c9565_2 = false;
|
|
c9565_4 = false;
|
|
},
|
|
MFA_WEBAUTHN_CREDENTIALS_LOADED: function handleWebAuthnCredentialsLoaded({ credentials: credentials2 }) {
|
|
let r0 = false;
|
|
if (credentials !== credentials2) {
|
|
credentials = credentials2;
|
|
r0 = true;
|
|
}
|
|
if (!c9565_2) {
|
|
c9565_2 = true;
|
|
r0 = true;
|
|
}
|
|
return r0;
|
|
},
|
|
AUTHENTICATOR_CREATE: function handleAuthenticatorCreate({ credential }) {
|
|
let r2;
|
|
if (credential.type === AuthenticatorType.WEBAUTHN) {
|
|
let r23 = credentials.find((a0) => a0.id === credential.id) === void 0;
|
|
if (r23) {
|
|
credentials = [...credentials, credential];
|
|
r23 = void 0;
|
|
}
|
|
r2 = r23;
|
|
} else {
|
|
credential.type;
|
|
r2 = false;
|
|
}
|
|
return r2;
|
|
},
|
|
AUTHENTICATOR_UPDATE: function handleAuthenticatorUpdate({ credential: credential2 }) {
|
|
if (credential2.type !== AuthenticatorType.WEBAUTHN) {
|
|
credential2.type;
|
|
return false;
|
|
}
|
|
credentials = credentials.map((credential) => credential.id === credential2.id ? credential2 : credential);
|
|
},
|
|
AUTHENTICATOR_DELETE: function handleAuthenticatorDelete({ credential: credential3 }) {
|
|
if (credential3.type !== AuthenticatorType.WEBAUTHN) {
|
|
credential3.type;
|
|
return false;
|
|
}
|
|
credentials = credentials.filter((credential) => credential.id !== credential3.id);
|
|
},
|
|
WEBAUTHN_TRIGGER_REGISTER: function handleTriggerRegister() {
|
|
if (c9565_4) {
|
|
return false;
|
|
}
|
|
c9565_4 = true;
|
|
},
|
|
WEBAUTHN_CLEAR_REGISTER_TRIGGER: function handleClearRegisterTrigger() {
|
|
if (c9565_4) {
|
|
c9565_4 = false;
|
|
return void 0;
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
export default webAuthnStore;
|