Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/api/account/getApiKeys.ts
7461 views
1
import http from '@/api/http';
2
3
export interface ApiKey {
4
identifier: string;
5
description: string;
6
allowedIps: string[];
7
createdAt: Date | null;
8
lastUsedAt: Date | null;
9
}
10
11
export const rawDataToApiKey = (data: any): ApiKey => ({
12
identifier: data.identifier,
13
description: data.description,
14
allowedIps: data.allowed_ips,
15
createdAt: data.created_at ? new Date(data.created_at) : null,
16
lastUsedAt: data.last_used_at ? new Date(data.last_used_at) : null,
17
});
18
19
export default (): Promise<ApiKey[]> => {
20
return new Promise((resolve, reject) => {
21
http.get('/api/client/account/api-keys')
22
.then(({ data }) => resolve((data.data || []).map((d: any) => rawDataToApiKey(d.attributes))))
23
.catch(reject);
24
});
25
};
26
27