mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-22 08:13:45 +02:00
ui(account): add security key management
This commit is contained in:
23
resources/scripts/api/account/webauthn/getWebauthnKeys.ts
Normal file
23
resources/scripts/api/account/webauthn/getWebauthnKeys.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import http from '@/api/http';
|
||||
|
||||
export interface WebauthnKey {
|
||||
id: number;
|
||||
name: string;
|
||||
createdAt: Date;
|
||||
lastUsedAt: Date;
|
||||
}
|
||||
|
||||
export const rawDataToWebauthnKey = (data: any): WebauthnKey => ({
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
createdAt: new Date(data.created_at),
|
||||
lastUsedAt: new Date(data.last_used_at) || new Date(),
|
||||
});
|
||||
|
||||
export default (): Promise<WebauthnKey[]> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get('/api/client/account/webauthn')
|
||||
.then(({ data }) => resolve((data.data || []).map((d: any) => rawDataToWebauthnKey(d.attributes))))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user