2FAuth/public/build/assets/WebAuthn-BHud-m0I.js.map

1 line
9.8 KiB
Plaintext
Raw Normal View History

2024-11-27 12:03:02 +01:00
{"version":3,"file":"WebAuthn-BHud-m0I.js","sources":["../../../resources/js/views/settings/WebAuthn.vue"],"sourcesContent":["<script setup>\n import SettingTabs from '@/layouts/SettingTabs.vue'\n import userService from '@/services/userService'\n import { webauthnService } from '@/services/webauthn/webauthnService'\n import { useAppSettingsStore } from '@/stores/appSettings'\n import { useUserStore } from '@/stores/user'\n import { useNotifyStore } from '@/stores/notify'\n import { UseColorMode } from '@vueuse/components'\n import Spinner from '@/components/Spinner.vue'\n\n const $2fauth = inject('2fauth')\n const user = useUserStore()\n const appSettings = useAppSettingsStore()\n const notify = useNotifyStore()\n const router = useRouter()\n const returnTo = useStorage($2fauth.prefix + 'returnTo', 'accounts')\n\n const credentials = ref([])\n const isFetching = ref(false)\n\n const isDisabled = computed(() => {\n return (appSettings.enableSso && appSettings.useSsoOnly) || user.authenticated_by_proxy\n })\n \n onMounted(() => {\n fetchCredentials()\n })\n\n watch(() => user.preferences.useWebauthnOnly, () => {\n userService.updatePreference('useWebauthnOnly', user.preferences.useWebauthnOnly).then(response => {\n notify.success({ text: trans('settings.forms.setting_saved') })\n })\n })\n\n /**\n * Register a new security device\n */\n function register() {\n if (isDisabled.value == true) {\n notify.warn({text: trans('errors.unsupported_with_reverseproxy') })\n return false\n }\n\n webauthnService.register().then((response) => {\n router.push({ name: 'settings.webauthn.editCredential', params: { credentialId: JSON.parse(response.config.data).id } })\n })\n .catch(error => {\n if ('webauthn' in error) {\n if (error.name == 'is-warning') {\n notify.warn({ text: trans(error.message) })\n }\n else notify.alert({ text: trans(error.message) })\n }\n else if( error.response?.status === 422 ) {\n notify.alert({ text: error.response.data.message })\n }\n else {\n notify.error(error);\n }\n })\n }\n\n /**\n * revoke a credential\n */\n function revokeCredential(credentialId) {\n if(confirm(trans('auth.confirm.revoke_device'))) {\n userService.revokeWebauthnDevice(credentialId).then(response => {\n // Remove the revoked credential from the collection\n credentials.value = credentials.value.filter(a => a.id !== credentialId)\n\n // Then we disable the useWebauthnOnly preference which is relevant\n // only when at least one device is registered\n if (credentials.value.length == 0) {\n user.preferences.useWebauthnOnly = false\n }\n\n notify.success({ text: trans('auth.webauthn.device_revoked') })\n });\n }\n }\n\n /**\n * Always display a printable name\n */\n function displayName(credential) {\n return credential.alias ? credential.alias : trans('auth.webauthn.my_device') + ' (#' + credential.id.substring(0, 10) + ')'\n }\n\n /**\n * Get all credentials from backend\n */\n function fetchCredentials() {\n isFetching.value = true\n\n userService.getWebauthnDevices({returnError: true})\n .then(response => {\n credentials.value = response.data\n })\n .catch(error => {\n if( error.response.status === 405 ) {\n // The backend returns a 405 response if the user is authenticated by a reverse proxy\n // or if SSO only is enabled.\n // The form is already disabled (see isDisabled) so we do nothing more here\n }\n else {\n notify.error(error)\