Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/api/account/createApiKey.ts
7461 views
1
import http from '@/api/http';
2
import { ApiKey, rawDataToApiKey } from '@/api/account/getApiKeys';
3
4
export default (description: string, allowedIps: string): Promise<ApiKey & { secretToken: string }> => {
5
return new Promise((resolve, reject) => {
6
http.post('/api/client/account/api-keys', {
7
description,
8
allowed_ips: allowedIps.length > 0 ? allowedIps.split('\n') : [],
9
})
10
.then(({ data }) =>
11
resolve({
12
...rawDataToApiKey(data.attributes),
13
// eslint-disable-next-line camelcase
14
secretToken: data.meta?.secret_token ?? '',
15
})
16
)
17
.catch(reject);
18
});
19
};
20
21