@pelican.ts/sdk 0.3.4-next.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -995,12 +995,12 @@ declare class ServerWebsocket {
995
995
  sendCommand(cmd: string): void;
996
996
  }
997
997
 
998
- type ServerStatus = 'starting' | 'stopping' | 'online' | 'offline';
998
+ type ServerStatus = "starting" | "stopping" | "online" | "offline";
999
999
  declare enum SERVER_SIGNAL {
1000
- 'START' = "start",
1001
- 'STOP' = "stop",
1002
- 'RESTART' = "restart",
1003
- 'KILL' = "kill"
1000
+ START = "start",
1001
+ STOP = "stop",
1002
+ RESTART = "restart",
1003
+ KILL = "kill"
1004
1004
  }
1005
1005
  type WebsocketEvent = AuthSuccessWsEvent | StatusWsEvent | ConsoleLogWsEvent | StatsWsEvent | TokenExpiringWsEvent | TokenExpiredWsEvent | DaemonErrorEvent | DaemonMessageEvent | InstallOutputEvent | InstallStartedEvent | InstallCompletedEvent | TransferLogsEvent | TransferStatusEvent | BackupCompletedEvent | BackupRestoreCompletedEvent | JwtErrorEvent;
1006
1006
  /**
@@ -1048,7 +1048,7 @@ type BackupCompletedEvent = {
1048
1048
  };
1049
1049
  type BackupCompletedJson = {
1050
1050
  checksum: string;
1051
- checksum_type: 'sha1';
1051
+ checksum_type: "sha1";
1052
1052
  file_size: number;
1053
1053
  is_successful: boolean;
1054
1054
  uuid: string;
@@ -1063,7 +1063,7 @@ type StatusWsEvent = {
1063
1063
  event: SOCKET_EVENT.STATUS;
1064
1064
  args: [PowerState];
1065
1065
  };
1066
- type PowerState = 'starting' | 'stopping' | 'running' | 'offline';
1066
+ type PowerState = "starting" | "stopping" | "running" | "offline";
1067
1067
  type ConsoleLogWsEvent = {
1068
1068
  event: SOCKET_EVENT.CONSOLE_OUTPUT;
1069
1069
  args: [string];
@@ -1151,7 +1151,7 @@ type Server = {
1151
1151
  limits: ServerLimits;
1152
1152
  invocation: string;
1153
1153
  docker_image: string;
1154
- egg_features: string[] | null;
1154
+ egg_features: Nullable<string[]>;
1155
1155
  feature_limits: FeatureLimits;
1156
1156
  status: Nullable<unknown>;
1157
1157
  is_suspended: boolean;
@@ -1164,7 +1164,7 @@ type Server = {
1164
1164
  uuid: string;
1165
1165
  name: string;
1166
1166
  }, "egg">;
1167
- subusers: GenericListResponse<GenericResponse<ServerSubuser, "server_subuser">>;
1167
+ subusers?: GenericListResponse<GenericResponse<ServerSubuser, "server_subuser">>;
1168
1168
  };
1169
1169
  };
1170
1170
  type ServerStats = {
@@ -1199,7 +1199,7 @@ type User = {
1199
1199
  image: string;
1200
1200
  admin: boolean;
1201
1201
  root_admin: boolean;
1202
- "2fa_enabled": number;
1202
+ "2fa_enabled": boolean;
1203
1203
  created_at: string;
1204
1204
  updated_at: string;
1205
1205
  };
package/package.json CHANGED
@@ -1,53 +1,64 @@
1
1
  {
2
- "name": "@pelican.ts/sdk",
3
- "version": "0.3.4-next.4",
4
- "description": "Pelican panel SDK for TypeScript",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
12
- "import": "./dist/index.mjs"
2
+ "name": "@pelican.ts/sdk",
3
+ "version": "0.4.1",
4
+ "description": "Pelican panel SDK for TypeScript",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./api": {
15
+ "types": "./dist/api/index.d.ts",
16
+ "require": "./dist/api/index.js",
17
+ "import": "./dist/api/index.mjs"
18
+ },
19
+ "./types": {
20
+ "types": "./dist/types.d.ts"
21
+ }
13
22
  },
14
- "./types": {
15
- "types": "./dist/types.d.ts"
23
+ "scripts": {
24
+ "build:api": "tsup src/api/index.ts --format esm,cjs --dts --target esnext -d dist/api",
25
+ "build:humane": "tsup src/index.ts --format esm,cjs --dts --target esnext",
26
+ "build:types": "tsup src/types.ts --dts-only --target esnext",
27
+ "build": "rm -rf ./dist && npm run build:api && npm run build:humane && npm run build:types",
28
+ "pub": "npm publish --access=public",
29
+ "pub:next": "npm publish --access=public --tag=next",
30
+ "generate-types": "bun run scripts/create-types.ts",
31
+ "pipeline:next": "bun run generate-types && bun run build && bun run pub:next",
32
+ "pipeline": "bun run generate-types && bun run build && bun run pub",
33
+ "format": "biome format --no-errors-on-unmatched --files-ignore-unknown=true --write .",
34
+ "prepare": "husky"
35
+ },
36
+ "keywords": [
37
+ "pterodactyl",
38
+ "pterodactyl.ts",
39
+ "pterodactyl.js",
40
+ "pelican",
41
+ "pelican.ts",
42
+ "pelican.js"
43
+ ],
44
+ "author": "M41den",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "url": "git+https://github.com/m41denx/Pelican.ts"
48
+ },
49
+ "devDependencies": {
50
+ "@biomejs/biome": "2.3.6",
51
+ "@types/node": "^22.18.12",
52
+ "@types/strip-color": "^0.1.2",
53
+ "husky": "^9.1.7",
54
+ "tsc-alias": "^1.8.16",
55
+ "tsup": "^8.5.0",
56
+ "typescript": "^5.9.3"
57
+ },
58
+ "dependencies": {
59
+ "axios": "^1.12.2",
60
+ "isomorphic-ws": "^5.0.0",
61
+ "strip-color": "^0.1.0",
62
+ "zod": "^4.1.12"
16
63
  }
17
- },
18
- "scripts": {
19
- "build:code": "tsup src/index.ts --format esm,cjs --dts --target esnext",
20
- "build:types": "tsup src/types.ts --dts-only --target esnext",
21
- "build": "rm -rf ./dist && npm run build:code && npm run build:types",
22
- "pub": "npm publish --access=public",
23
- "pub:next": "npm publish --access=public --tag=next",
24
- "generate-types": "bun run scripts/create-types.ts",
25
- "pipeline": "bun run generate-types && bun run build && bun run pub:next"
26
- },
27
- "keywords": [
28
- "pterodactyl",
29
- "pterodactyl.ts",
30
- "pterodactyl.js",
31
- "pelican",
32
- "pelican.ts",
33
- "pelican.js"
34
- ],
35
- "author": "M41den",
36
- "license": "MIT",
37
- "repository": {
38
- "url": "git+https://github.com/m41denx/Pelican.ts"
39
- },
40
- "devDependencies": {
41
- "@types/node": "^22.18.12",
42
- "@types/strip-color": "^0.1.2",
43
- "tsc-alias": "^1.8.16",
44
- "tsup": "^8.5.0",
45
- "typescript": "^5.9.3"
46
- },
47
- "dependencies": {
48
- "axios": "^1.12.2",
49
- "isomorphic-ws": "^5.0.0",
50
- "strip-color": "^0.1.0",
51
- "zod": "^4.1.12"
52
- }
53
64
  }
@@ -1,69 +1,82 @@
1
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
2
- import {EggVariable} from "@/api/common/types/egg";
3
- import {ServerSubuser} from "@/api/client/types/server_subuser";
4
- import {FeatureLimits, ServerLimits} from "@/api/common/types/server_limits";
5
- import {ServerAllocation} from "@/api/client/types/server_allocation";
6
- import {Nullable} from "@/utils/types";
1
+ import { GenericListResponse, GenericResponse } from "@/api/base/types"
2
+ import { EggVariable } from "@/api/common/types/egg"
3
+ import { ServerSubuser } from "@/api/client/types/server_subuser"
4
+ import { FeatureLimits, ServerLimits } from "@/api/common/types/server_limits"
5
+ import { ServerAllocation } from "@/api/client/types/server_allocation"
6
+ import { Nullable } from "@/utils/types"
7
7
 
8
8
  export type Server = {
9
- server_owner: boolean,
10
- identifier: string,
11
- internal_id?: number,
12
- uuid: string,
13
- name: string,
14
- node: string,
15
- is_node_under_maintenance: boolean,
9
+ server_owner: boolean
10
+ identifier: string
11
+ internal_id?: number
12
+ uuid: string
13
+ name: string
14
+ node: string
15
+ is_node_under_maintenance: boolean
16
16
  sftp_details: {
17
- ip: string,
18
- alias: Nullable<string>,
17
+ ip: string
18
+ alias: Nullable<string>
19
19
  port: number
20
- },
21
- description: string,
22
- limits: ServerLimits,
23
- invocation: string,
24
- docker_image: string,
25
- egg_features: string[] | null,
26
- feature_limits: FeatureLimits,
27
- status: Nullable<unknown>,
28
- is_suspended: boolean,
29
- is_installing: boolean,
30
- is_transferring: boolean,
20
+ }
21
+ description: string
22
+ limits: ServerLimits
23
+ invocation: string
24
+ docker_image: string
25
+ egg_features: Nullable<string[]>
26
+ feature_limits: FeatureLimits
27
+ status: Nullable<unknown>
28
+ is_suspended: boolean
29
+ is_installing: boolean
30
+ is_transferring: boolean
31
31
  relationships: {
32
- allocations: GenericListResponse<GenericResponse<ServerAllocation, "allocation">>,
33
- variables: GenericListResponse<GenericResponse<EggVariable, "egg_variable">>,
34
- egg?: GenericResponse<{
35
- uuid: string,
36
- name: string
37
- }, "egg">,
38
- subusers: GenericListResponse<GenericResponse<ServerSubuser, "server_subuser">>
32
+ allocations: GenericListResponse<
33
+ GenericResponse<ServerAllocation, "allocation">
34
+ >
35
+ variables: GenericListResponse<
36
+ GenericResponse<EggVariable, "egg_variable">
37
+ >
38
+ egg?: GenericResponse<
39
+ {
40
+ uuid: string
41
+ name: string
42
+ },
43
+ "egg"
44
+ >
45
+ subusers?: GenericListResponse<
46
+ GenericResponse<ServerSubuser, "server_subuser">
47
+ >
39
48
  }
40
49
  }
41
50
 
42
-
43
51
  export type ServerStats = {
44
- current_state: "installing" | "install_failed" | "reinstall_failed" | "suspended"
45
- | "restoring_backup" | "running" | "stopped" | "offline",
46
- is_suspended: boolean,
52
+ current_state:
53
+ | "installing"
54
+ | "install_failed"
55
+ | "reinstall_failed"
56
+ | "suspended"
57
+ | "restoring_backup"
58
+ | "running"
59
+ | "stopped"
60
+ | "offline"
61
+ is_suspended: boolean
47
62
  resources: ServerResources
48
63
  }
49
64
 
50
65
  type ServerResources = {
51
- memory_bytes: number,
52
- cpu_absolute: number,
53
- disk_bytes: number,
54
- network_tx_bytes: number,
55
- network_rx_bytes: number,
66
+ memory_bytes: number
67
+ cpu_absolute: number
68
+ disk_bytes: number
69
+ network_tx_bytes: number
70
+ network_rx_bytes: number
56
71
  uptime: number
57
72
  }
58
73
  export type ServerActivityLog = {
59
- id: string,
60
- event: string,
61
- is_api: boolean,
62
- ip: string,
63
- description: Nullable<string>,
64
- properties: Record<string, string>,
65
- has_additional_metadata: boolean,
74
+ id: string
75
+ event: string
76
+ is_api: boolean
77
+ ip: string
78
+ description: Nullable<string>
79
+ properties: Record<string, string>
80
+ has_additional_metadata: boolean
66
81
  timestamp: string
67
82
  }
68
-
69
-
@@ -1,35 +1,34 @@
1
- import {Nullable} from "@/utils/types";
1
+ import { Nullable } from "@/utils/types"
2
2
 
3
3
  export type User = {
4
- uuid: string,
5
- username: string,
6
- email: string,
4
+ uuid: string
5
+ username: string
6
+ email: string
7
7
  language: string
8
- image: string,
9
- admin: boolean,
10
- root_admin: boolean,
11
- "2fa_enabled": number,
12
- created_at: string,
8
+ image: string
9
+ admin: boolean
10
+ root_admin: boolean
11
+ "2fa_enabled": boolean
12
+ created_at: string
13
13
  updated_at: string
14
-
15
14
  }
16
15
 
17
16
  export type APIKey = {
18
- identifier: string,
19
- description: string,
20
- allowed_ips: string[],
21
- last_used_at: Nullable<string>,
17
+ identifier: string
18
+ description: string
19
+ allowed_ips: string[]
20
+ last_used_at: Nullable<string>
22
21
  created_at: string
23
22
  }
24
23
 
25
24
  export type SSHKey = {
26
- name: string,
27
- fingerprint: string,
28
- pubic_key: string,
25
+ name: string
26
+ fingerprint: string
27
+ pubic_key: string
29
28
  created_at: string
30
29
  }
31
30
 
32
31
  export type Permission = {
33
- description: string,
32
+ description: string
34
33
  keys: Record<string, string>
35
- }
34
+ }
@@ -3,13 +3,13 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- export type ServerStatus = 'starting' | 'stopping' | 'online' | 'offline';
6
+ export type ServerStatus = "starting" | "stopping" | "online" | "offline"
7
7
 
8
8
  export enum SERVER_SIGNAL {
9
- 'START' = 'start',
10
- 'STOP' = 'stop',
11
- 'RESTART' = 'restart',
12
- 'KILL' = 'kill',
9
+ START = "start",
10
+ STOP = "stop",
11
+ RESTART = "restart",
12
+ KILL = "kill",
13
13
  }
14
14
 
15
15
  export type WebsocketEvent =
@@ -28,101 +28,101 @@ export type WebsocketEvent =
28
28
  | TransferStatusEvent
29
29
  | BackupCompletedEvent
30
30
  | BackupRestoreCompletedEvent
31
- | JwtErrorEvent;
31
+ | JwtErrorEvent
32
32
 
33
33
  /**
34
34
  * Source: https://github.com/pterodactyl/panel/blob/1.0-develop/resources/scripts/components/server/events.ts
35
35
  */
36
36
  export enum SOCKET_EVENT {
37
- AUTH_SUCCESS = 'auth success',
38
- DAEMON_MESSAGE = 'daemon message',
39
- DAEMON_ERROR = 'daemon error',
40
- INSTALL_OUTPUT = 'install output',
41
- INSTALL_STARTED = 'install started',
42
- INSTALL_COMPLETED = 'install completed',
43
- CONSOLE_OUTPUT = 'console output',
44
- STATUS = 'status',
45
- STATS = 'stats',
46
- TRANSFER_LOGS = 'transfer logs',
47
- TRANSFER_STATUS = 'transfer status',
48
- BACKUP_COMPLETED = 'backup completed',
49
- BACKUP_RESTORE_COMPLETED = 'backup restore completed',
50
- TOKEN_EXPIRING = 'token expiring',
51
- TOKEN_EXPIRED = 'token expired',
52
- JWT_ERROR = 'jwt error',
37
+ AUTH_SUCCESS = "auth success",
38
+ DAEMON_MESSAGE = "daemon message",
39
+ DAEMON_ERROR = "daemon error",
40
+ INSTALL_OUTPUT = "install output",
41
+ INSTALL_STARTED = "install started",
42
+ INSTALL_COMPLETED = "install completed",
43
+ CONSOLE_OUTPUT = "console output",
44
+ STATUS = "status",
45
+ STATS = "stats",
46
+ TRANSFER_LOGS = "transfer logs",
47
+ TRANSFER_STATUS = "transfer status",
48
+ BACKUP_COMPLETED = "backup completed",
49
+ BACKUP_RESTORE_COMPLETED = "backup restore completed",
50
+ TOKEN_EXPIRING = "token expiring",
51
+ TOKEN_EXPIRED = "token expired",
52
+ JWT_ERROR = "jwt error",
53
53
  }
54
54
 
55
55
  export type InstallOutputEvent = {
56
- event: SOCKET_EVENT.INSTALL_OUTPUT;
57
- args: [string];
58
- };
56
+ event: SOCKET_EVENT.INSTALL_OUTPUT
57
+ args: [string]
58
+ }
59
59
 
60
60
  export type InstallStartedEvent = {
61
- event: SOCKET_EVENT.INSTALL_STARTED;
62
- };
61
+ event: SOCKET_EVENT.INSTALL_STARTED
62
+ }
63
63
 
64
64
  export type InstallCompletedEvent = {
65
- event: SOCKET_EVENT.INSTALL_COMPLETED;
66
- };
65
+ event: SOCKET_EVENT.INSTALL_COMPLETED
66
+ }
67
67
 
68
68
  export type TransferLogsEvent = {
69
- event: SOCKET_EVENT.TRANSFER_LOGS;
70
- args: [string];
71
- };
69
+ event: SOCKET_EVENT.TRANSFER_LOGS
70
+ args: [string]
71
+ }
72
72
 
73
73
  export type TransferStatusEvent = {
74
- event: SOCKET_EVENT.TRANSFER_STATUS;
75
- args: [string];
76
- };
74
+ event: SOCKET_EVENT.TRANSFER_STATUS
75
+ args: [string]
76
+ }
77
77
 
78
78
  export type BackupCompletedEvent = {
79
- event: SOCKET_EVENT.BACKUP_COMPLETED;
80
- args: [string];
81
- };
79
+ event: SOCKET_EVENT.BACKUP_COMPLETED
80
+ args: [string]
81
+ }
82
82
 
83
83
  export type BackupCompletedJson = {
84
- checksum: string;
85
- checksum_type: 'sha1';
86
- file_size: number;
87
- is_successful: boolean;
88
- uuid: string;
89
- };
84
+ checksum: string
85
+ checksum_type: "sha1"
86
+ file_size: number
87
+ is_successful: boolean
88
+ uuid: string
89
+ }
90
90
 
91
91
  export type BackupRestoreCompletedEvent = {
92
- event: SOCKET_EVENT.BACKUP_RESTORE_COMPLETED;
93
- };
92
+ event: SOCKET_EVENT.BACKUP_RESTORE_COMPLETED
93
+ }
94
94
 
95
95
  export type AuthSuccessWsEvent = {
96
- event: SOCKET_EVENT.AUTH_SUCCESS;
97
- };
96
+ event: SOCKET_EVENT.AUTH_SUCCESS
97
+ }
98
98
 
99
- export type StatusWsEvent = { event: SOCKET_EVENT.STATUS; args: [PowerState] };
99
+ export type StatusWsEvent = { event: SOCKET_EVENT.STATUS; args: [PowerState] }
100
100
 
101
- export type PowerState = 'starting' | 'stopping' | 'running' | 'offline';
101
+ export type PowerState = "starting" | "stopping" | "running" | "offline"
102
102
 
103
103
  export type ConsoleLogWsEvent = {
104
- event: SOCKET_EVENT.CONSOLE_OUTPUT;
105
- args: [string];
106
- };
104
+ event: SOCKET_EVENT.CONSOLE_OUTPUT
105
+ args: [string]
106
+ }
107
107
 
108
108
  export type StatsWsEvent = {
109
- event: SOCKET_EVENT.STATS;
110
- args: [string];
111
- };
109
+ event: SOCKET_EVENT.STATS
110
+ args: [string]
111
+ }
112
112
 
113
113
  export type StatsWsJson = {
114
- memory_bytes: number;
115
- memory_limit_bytes: number;
116
- cpu_absolute: number;
117
- network: { rx_bytes: number; tx_bytes: number };
118
- state: PowerState;
119
- uptime: number;
120
- disk_bytes: number;
121
- };
114
+ memory_bytes: number
115
+ memory_limit_bytes: number
116
+ cpu_absolute: number
117
+ network: { rx_bytes: number; tx_bytes: number }
118
+ state: PowerState
119
+ uptime: number
120
+ disk_bytes: number
121
+ }
122
122
 
123
- export type TokenExpiringWsEvent = { event: SOCKET_EVENT.TOKEN_EXPIRING };
123
+ export type TokenExpiringWsEvent = { event: SOCKET_EVENT.TOKEN_EXPIRING }
124
124
 
125
- export type TokenExpiredWsEvent = { event: SOCKET_EVENT.TOKEN_EXPIRED };
125
+ export type TokenExpiredWsEvent = { event: SOCKET_EVENT.TOKEN_EXPIRED }
126
126
 
127
127
  /**
128
128
  * Example:
@@ -133,18 +133,18 @@ export type TokenExpiredWsEvent = { event: SOCKET_EVENT.TOKEN_EXPIRED };
133
133
  * {"event":"daemon message","args":["Completed server restoration from local backup."]}
134
134
  */
135
135
  export type DaemonMessageEvent = {
136
- event: SOCKET_EVENT.DAEMON_MESSAGE;
137
- args: [string];
138
- };
136
+ event: SOCKET_EVENT.DAEMON_MESSAGE
137
+ args: [string]
138
+ }
139
139
 
140
140
  export type DaemonErrorEvent = {
141
- event: SOCKET_EVENT.DAEMON_ERROR;
142
- args: [string];
143
- };
141
+ event: SOCKET_EVENT.DAEMON_ERROR
142
+ args: [string]
143
+ }
144
144
 
145
145
  export type JwtErrorEvent = {
146
- event: SOCKET_EVENT.JWT_ERROR;
147
- args: [string];
148
- };
146
+ event: SOCKET_EVENT.JWT_ERROR
147
+ args: [string]
148
+ }
149
149
 
150
- export {ServerWebsocket} from "@/api/client/server_websocket";
150
+ export { ServerWebsocket } from "@/api/client/server_websocket"
@@ -0,0 +1,17 @@
1
+ import { Client as UserClient } from "@/api/client/client"
2
+ import { Client as AppClient } from "@/api/application/client"
3
+ import { Agent } from "@/api/base/request"
4
+
5
+ export class PelicanAPIClient extends UserClient {
6
+ constructor(url: string, token: string, suffix: string = "/api") {
7
+ const ax = new Agent(url, token, "client", suffix)
8
+ super(ax.requester)
9
+ }
10
+ }
11
+
12
+ export class PelicanAPIApplication extends AppClient {
13
+ constructor(url: string, token: string, suffix: string = "/api") {
14
+ const ax = new Agent(url, token, "application", suffix)
15
+ super(ax.requester)
16
+ }
17
+ }
@@ -0,0 +1,73 @@
1
+ import type { Client } from "@/api/client/client"
2
+ import type { User } from "@/api/client/types/user"
3
+
4
+ export class Account {
5
+ private readonly client: Client
6
+ readonly uuid: string
7
+ readonly username: string
8
+ private $email: string
9
+ get email() {
10
+ return this.$email
11
+ }
12
+ readonly language: string
13
+ readonly image: string
14
+ readonly admin: boolean
15
+ readonly root_admin: boolean
16
+ private $has2faEnabled: boolean
17
+ get has2faEnabled() {
18
+ return this.$has2faEnabled
19
+ }
20
+ readonly createdAt: Date
21
+ readonly updatedAt: Date
22
+
23
+ constructor(client: Client, user: User) {
24
+ this.client = client
25
+ this.uuid = user.uuid
26
+ this.username = user.username
27
+ this.$email = user.email
28
+ this.language = user.language
29
+ this.image = user.image
30
+ this.admin = user.admin
31
+ this.root_admin = user.root_admin
32
+ this.$has2faEnabled = user["2fa_enabled"]
33
+ this.createdAt = new Date(user.created_at)
34
+ this.updatedAt = new Date(user.updated_at)
35
+ }
36
+
37
+ updateEmail = async (newEmail: string, password: string) => {
38
+ await this.client.account.updateEmail(newEmail, password)
39
+ this.$email = newEmail
40
+ }
41
+
42
+ updatePassword = async (newPassword: string) =>
43
+ this.client.account.updatePassword(newPassword)
44
+
45
+ listApiKeys = async () => this.client.account.apiKeys.list()
46
+
47
+ createApiKey = async (description: string, allowed_ips?: string[]) =>
48
+ this.client.account.apiKeys.create(description, allowed_ips)
49
+
50
+ deleteApiKey = async (identifier: string) =>
51
+ this.client.account.apiKeys.delete(identifier)
52
+
53
+ listSshKeys = async () => this.client.account.sshKeys.list()
54
+
55
+ createSshKey = async (name: string, public_key: string) =>
56
+ this.client.account.sshKeys.create(name, public_key)
57
+
58
+ deleteSshKey = async (fingerprint: string) =>
59
+ this.client.account.sshKeys.delete(fingerprint)
60
+
61
+ get2faQR = async () => this.client.account.twoFactor.info()
62
+
63
+ enable2fa = async (code: string) => {
64
+ const tokens = await this.client.account.twoFactor.enable(code)
65
+ this.$has2faEnabled = true
66
+ return tokens
67
+ }
68
+
69
+ disable2fa = async (password: string) => {
70
+ await this.client.account.twoFactor.disable(password)
71
+ this.$has2faEnabled = false
72
+ }
73
+ }