feat: add various improvements to the table component (#961)

Co-authored-by: Kyle Mendell <kmendell@ofkm.us>
This commit is contained in:
Elias Schneider
2025-10-13 11:12:55 +02:00
committed by GitHub
parent 24ca6a106d
commit c20e93b55c
76 changed files with 1948 additions and 1434 deletions

View File

@@ -3,45 +3,36 @@ import type { User } from '$lib/types/user.type';
import APIService from './api-service';
import userStore from '$lib/stores/user-store';
import type { AuthenticationResponseJSON, RegistrationResponseJSON } from '@simplewebauthn/browser';
class WebAuthnService extends APIService {
async getRegistrationOptions() {
return (await this.api.get(`/webauthn/register/start`)).data;
}
getRegistrationOptions = async () => (await this.api.get(`/webauthn/register/start`)).data;
async finishRegistration(body: RegistrationResponseJSON) {
return (await this.api.post(`/webauthn/register/finish`, body)).data as Passkey;
}
finishRegistration = async (body: RegistrationResponseJSON) =>
(await this.api.post(`/webauthn/register/finish`, body)).data as Passkey;
async getLoginOptions() {
return (await this.api.get(`/webauthn/login/start`)).data;
}
getLoginOptions = async () => (await this.api.get(`/webauthn/login/start`)).data;
async finishLogin(body: AuthenticationResponseJSON) {
return (await this.api.post(`/webauthn/login/finish`, body)).data as User;
}
finishLogin = async (body: AuthenticationResponseJSON) =>
(await this.api.post(`/webauthn/login/finish`, body)).data as User;
async logout() {
await this.api.post(`/webauthn/logout`);
userStore.clearUser();
}
logout = async () => {
await this.api.post(`/webauthn/logout`);
userStore.clearUser();
};
async listCredentials() {
return (await this.api.get(`/webauthn/credentials`)).data as Passkey[];
}
listCredentials = async () => (await this.api.get(`/webauthn/credentials`)).data as Passkey[];
async removeCredential(id: string) {
await this.api.delete(`/webauthn/credentials/${id}`);
}
removeCredential = async (id: string) => {
await this.api.delete(`/webauthn/credentials/${id}`);
};
async updateCredentialName(id: string, name: string) {
await this.api.patch(`/webauthn/credentials/${id}`, { name });
}
updateCredentialName = async (id: string, name: string) => {
await this.api.patch(`/webauthn/credentials/${id}`, { name });
};
async reauthenticate(body?: AuthenticationResponseJSON) {
const res = await this.api.post('/webauthn/reauthenticate', body);
return res.data.reauthenticationToken as string;
}
reauthenticate = async (body?: AuthenticationResponseJSON) => {
const res = await this.api.post('/webauthn/reauthenticate', body);
return res.data.reauthenticationToken as string;
};
}
export default WebAuthnService;