@meowpanel/api 0.3.0 → 0.4.0
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/esm/mod.d.ts +37 -16
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +25 -7
- package/esm/src/client.d.ts +48 -11
- package/esm/src/client.d.ts.map +1 -1
- package/esm/src/client.js +53 -12
- package/esm/src/http.d.ts +2 -2
- package/esm/src/http.d.ts.map +1 -1
- package/esm/src/http.js +5 -2
- package/esm/src/namespace.d.ts +1 -1
- package/esm/src/namespace.js +1 -1
- package/esm/src/resources/account.d.ts +50 -19
- package/esm/src/resources/account.d.ts.map +1 -1
- package/esm/src/resources/account.js +51 -13
- package/esm/src/resources/api-keys.d.ts +16 -24
- package/esm/src/resources/api-keys.d.ts.map +1 -1
- package/esm/src/resources/api-keys.js +16 -20
- package/esm/src/resources/auth.d.ts +70 -4
- package/esm/src/resources/auth.d.ts.map +1 -1
- package/esm/src/resources/auth.js +47 -4
- package/esm/src/resources/eggs.d.ts +261 -22
- package/esm/src/resources/eggs.d.ts.map +1 -1
- package/esm/src/resources/eggs.js +261 -25
- package/esm/src/resources/features.d.ts +35 -0
- package/esm/src/resources/features.d.ts.map +1 -0
- package/esm/src/resources/features.js +21 -0
- package/esm/src/resources/hosts.d.ts +143 -18
- package/esm/src/resources/hosts.d.ts.map +1 -1
- package/esm/src/resources/hosts.js +145 -10
- package/esm/src/resources/logs.d.ts +39 -0
- package/esm/src/resources/logs.d.ts.map +1 -0
- package/esm/src/resources/logs.js +38 -0
- package/esm/src/resources/nodes.d.ts +92 -17
- package/esm/src/resources/nodes.d.ts.map +1 -1
- package/esm/src/resources/nodes.js +108 -16
- package/esm/src/resources/permissions.d.ts +45 -0
- package/esm/src/resources/permissions.d.ts.map +1 -0
- package/esm/src/resources/permissions.js +26 -0
- package/esm/src/resources/request-logs.d.ts +91 -0
- package/esm/src/resources/request-logs.d.ts.map +1 -0
- package/esm/src/resources/request-logs.js +70 -0
- package/esm/src/resources/roles.d.ts +128 -0
- package/esm/src/resources/roles.d.ts.map +1 -0
- package/esm/src/resources/roles.js +142 -0
- package/esm/src/resources/server-groups.d.ts +141 -7
- package/esm/src/resources/server-groups.d.ts.map +1 -1
- package/esm/src/resources/server-groups.js +157 -8
- package/esm/src/resources/servers/activity.d.ts +50 -8
- package/esm/src/resources/servers/activity.d.ts.map +1 -1
- package/esm/src/resources/servers/activity.js +54 -13
- package/esm/src/resources/servers/allocations.d.ts +3 -3
- package/esm/src/resources/servers/allocations.d.ts.map +1 -1
- package/esm/src/resources/servers/allocations.js +7 -7
- package/esm/src/resources/servers/backups.d.ts +46 -0
- package/esm/src/resources/servers/backups.d.ts.map +1 -0
- package/esm/src/resources/servers/backups.js +43 -0
- package/esm/src/resources/servers/connection.d.ts +27 -7
- package/esm/src/resources/servers/connection.d.ts.map +1 -1
- package/esm/src/resources/servers/connection.js +28 -7
- package/esm/src/resources/servers/features.d.ts +81 -0
- package/esm/src/resources/servers/features.d.ts.map +1 -0
- package/esm/src/resources/servers/features.js +60 -0
- package/esm/src/resources/servers/files.d.ts +41 -53
- package/esm/src/resources/servers/files.d.ts.map +1 -1
- package/esm/src/resources/servers/files.js +74 -116
- package/esm/src/resources/servers/index.d.ts +46 -27
- package/esm/src/resources/servers/index.d.ts.map +1 -1
- package/esm/src/resources/servers/index.js +26 -12
- package/esm/src/resources/servers/jobs.d.ts +88 -0
- package/esm/src/resources/servers/jobs.d.ts.map +1 -0
- package/esm/src/resources/servers/jobs.js +115 -0
- package/esm/src/resources/servers/node-client.d.ts +33 -0
- package/esm/src/resources/servers/node-client.d.ts.map +1 -0
- package/esm/src/resources/servers/node-client.js +61 -0
- package/esm/src/resources/servers/profiles.d.ts +45 -1
- package/esm/src/resources/servers/profiles.d.ts.map +1 -1
- package/esm/src/resources/servers/profiles.js +55 -2
- package/esm/src/resources/servers/server.d.ts +10 -25
- package/esm/src/resources/servers/server.d.ts.map +1 -1
- package/esm/src/resources/servers/server.js +18 -34
- package/esm/src/resources/servers/sftp.d.ts +12 -19
- package/esm/src/resources/servers/sftp.d.ts.map +1 -1
- package/esm/src/resources/servers/sftp.js +10 -14
- package/esm/src/resources/servers/sub-users.d.ts +99 -0
- package/esm/src/resources/servers/sub-users.d.ts.map +1 -0
- package/esm/src/resources/servers/sub-users.js +94 -0
- package/esm/src/resources/servers/types.d.ts +27 -25
- package/esm/src/resources/servers/types.d.ts.map +1 -1
- package/esm/src/resources/systems.d.ts +124 -0
- package/esm/src/resources/systems.d.ts.map +1 -0
- package/esm/src/resources/systems.js +139 -0
- package/esm/src/resources/users.d.ts +330 -0
- package/esm/src/resources/users.d.ts.map +1 -0
- package/esm/src/resources/users.js +280 -0
- package/esm/src/types.d.ts +18 -1
- package/esm/src/types.d.ts.map +1 -1
- package/esm/src/types.js +11 -0
- package/package.json +1 -1
- package/script/mod.d.ts +37 -16
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +50 -5
- package/script/src/client.d.ts +48 -11
- package/script/src/client.d.ts.map +1 -1
- package/script/src/client.js +53 -12
- package/script/src/http.d.ts +2 -2
- package/script/src/http.d.ts.map +1 -1
- package/script/src/http.js +5 -2
- package/script/src/namespace.d.ts +1 -1
- package/script/src/namespace.js +1 -1
- package/script/src/resources/account.d.ts +50 -19
- package/script/src/resources/account.d.ts.map +1 -1
- package/script/src/resources/account.js +50 -12
- package/script/src/resources/api-keys.d.ts +16 -24
- package/script/src/resources/api-keys.d.ts.map +1 -1
- package/script/src/resources/api-keys.js +15 -19
- package/script/src/resources/auth.d.ts +70 -4
- package/script/src/resources/auth.d.ts.map +1 -1
- package/script/src/resources/auth.js +47 -4
- package/script/src/resources/eggs.d.ts +261 -22
- package/script/src/resources/eggs.d.ts.map +1 -1
- package/script/src/resources/eggs.js +267 -26
- package/script/src/resources/features.d.ts +35 -0
- package/script/src/resources/features.d.ts.map +1 -0
- package/script/src/resources/features.js +25 -0
- package/script/src/resources/hosts.d.ts +143 -18
- package/script/src/resources/hosts.d.ts.map +1 -1
- package/script/src/resources/hosts.js +146 -10
- package/script/src/resources/logs.d.ts +39 -0
- package/script/src/resources/logs.d.ts.map +1 -0
- package/script/src/resources/logs.js +42 -0
- package/script/src/resources/nodes.d.ts +92 -17
- package/script/src/resources/nodes.d.ts.map +1 -1
- package/script/src/resources/nodes.js +109 -16
- package/script/src/resources/permissions.d.ts +45 -0
- package/script/src/resources/permissions.d.ts.map +1 -0
- package/script/src/resources/permissions.js +31 -0
- package/script/src/resources/request-logs.d.ts +91 -0
- package/script/src/resources/request-logs.d.ts.map +1 -0
- package/script/src/resources/request-logs.js +75 -0
- package/script/src/resources/roles.d.ts +128 -0
- package/script/src/resources/roles.d.ts.map +1 -0
- package/script/src/resources/roles.js +148 -0
- package/script/src/resources/server-groups.d.ts +141 -7
- package/script/src/resources/server-groups.d.ts.map +1 -1
- package/script/src/resources/server-groups.js +158 -8
- package/script/src/resources/servers/activity.d.ts +50 -8
- package/script/src/resources/servers/activity.d.ts.map +1 -1
- package/script/src/resources/servers/activity.js +54 -12
- package/script/src/resources/servers/allocations.d.ts +3 -3
- package/script/src/resources/servers/allocations.d.ts.map +1 -1
- package/script/src/resources/servers/allocations.js +7 -7
- package/script/src/resources/servers/backups.d.ts +46 -0
- package/script/src/resources/servers/backups.d.ts.map +1 -0
- package/script/src/resources/servers/backups.js +47 -0
- package/script/src/resources/servers/connection.d.ts +27 -7
- package/script/src/resources/servers/connection.d.ts.map +1 -1
- package/script/src/resources/servers/connection.js +28 -7
- package/script/src/resources/servers/features.d.ts +81 -0
- package/script/src/resources/servers/features.d.ts.map +1 -0
- package/script/src/resources/servers/features.js +64 -0
- package/script/src/resources/servers/files.d.ts +41 -53
- package/script/src/resources/servers/files.d.ts.map +1 -1
- package/script/src/resources/servers/files.js +74 -116
- package/script/src/resources/servers/index.d.ts +46 -27
- package/script/src/resources/servers/index.d.ts.map +1 -1
- package/script/src/resources/servers/index.js +26 -12
- package/script/src/resources/servers/jobs.d.ts +88 -0
- package/script/src/resources/servers/jobs.d.ts.map +1 -0
- package/script/src/resources/servers/jobs.js +120 -0
- package/script/src/resources/servers/node-client.d.ts +33 -0
- package/script/src/resources/servers/node-client.d.ts.map +1 -0
- package/script/src/resources/servers/node-client.js +65 -0
- package/script/src/resources/servers/profiles.d.ts +45 -1
- package/script/src/resources/servers/profiles.d.ts.map +1 -1
- package/script/src/resources/servers/profiles.js +55 -2
- package/script/src/resources/servers/server.d.ts +10 -25
- package/script/src/resources/servers/server.d.ts.map +1 -1
- package/script/src/resources/servers/server.js +18 -34
- package/script/src/resources/servers/sftp.d.ts +12 -19
- package/script/src/resources/servers/sftp.d.ts.map +1 -1
- package/script/src/resources/servers/sftp.js +10 -14
- package/script/src/resources/servers/sub-users.d.ts +99 -0
- package/script/src/resources/servers/sub-users.d.ts.map +1 -0
- package/script/src/resources/servers/sub-users.js +99 -0
- package/script/src/resources/servers/types.d.ts +27 -25
- package/script/src/resources/servers/types.d.ts.map +1 -1
- package/script/src/resources/systems.d.ts +124 -0
- package/script/src/resources/systems.d.ts.map +1 -0
- package/script/src/resources/systems.js +145 -0
- package/script/src/resources/users.d.ts +330 -0
- package/script/src/resources/users.d.ts.map +1 -0
- package/script/src/resources/users.js +287 -0
- package/script/src/types.d.ts +18 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +12 -0
- package/esm/src/resources/members.d.ts +0 -138
- package/esm/src/resources/members.d.ts.map +0 -1
- package/esm/src/resources/members.js +0 -122
- package/script/src/resources/members.d.ts +0 -138
- package/script/src/resources/members.d.ts.map +0 -1
- package/script/src/resources/members.js +0 -127
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/src/resources/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAA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AAC,MAAM,EAAE,CAAC;IAIlC;;;;;;OAMG;IACI,UAAU,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAIlF;;;;;;OAMG;IACI,WAAW,CAAC,IAAI,GAAE,qBAA0B,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAIpF,0DAA0D;IAC1D,IAAW,OAAO,IAAI,qBAAqB,CAE1C;CACD"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReactiveResource } from '../reactive.js';
|
|
2
|
-
import { joinIncludes, toNanoID } from '../types.js';
|
|
2
|
+
import { joinIncludes, parseIssuerRef, toNanoID } from '../types.js';
|
|
3
|
+
import { listActivities } from './servers/activity.js';
|
|
4
|
+
import { listRequestLogs } from './request-logs.js';
|
|
3
5
|
/**
|
|
4
6
|
* Base class for the authenticated account.
|
|
5
7
|
*
|
|
@@ -15,7 +17,7 @@ export class Account extends ReactiveResource {
|
|
|
15
17
|
constructor(data, http) {
|
|
16
18
|
super();
|
|
17
19
|
this.http = http;
|
|
18
|
-
this.id = toNanoID(data.id);
|
|
20
|
+
this.id = data.ref_id ? toNanoID(data.ref_id) : parseIssuerRef(data.id).id;
|
|
19
21
|
this.permissions = data.permissions;
|
|
20
22
|
this.createdAt = new Date(data.created_at);
|
|
21
23
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -28,13 +30,13 @@ export class Account extends ReactiveResource {
|
|
|
28
30
|
}
|
|
29
31
|
/** @internal */
|
|
30
32
|
static create(data, http) {
|
|
31
|
-
switch (data.
|
|
33
|
+
switch (data.type) {
|
|
32
34
|
case 'user':
|
|
33
35
|
return new UserAccount(data, http);
|
|
34
36
|
case 'api_key':
|
|
35
37
|
return new ApiKeyAccount(data, http);
|
|
36
38
|
default:
|
|
37
|
-
throw new Error(`Unknown account issuer type: ${data.
|
|
39
|
+
throw new Error(`Unknown account issuer type: ${data.type}`);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -42,29 +44,37 @@ export class Account extends ReactiveResource {
|
|
|
42
44
|
export class UserAccount extends Account {
|
|
43
45
|
issuerType = 'user';
|
|
44
46
|
email;
|
|
47
|
+
/** When this user verified their email, or `null` if unverified. */
|
|
48
|
+
emailVerifiedAt;
|
|
45
49
|
nickname;
|
|
46
50
|
avatarUri;
|
|
51
|
+
/** When this account was disabled, or `null` if active. */
|
|
52
|
+
disabledAt;
|
|
47
53
|
/**
|
|
48
|
-
* Display preferences. Populated with `include=
|
|
49
|
-
* Requires `
|
|
54
|
+
* Display and locale preferences. Populated with `include=preferences`.
|
|
55
|
+
* Requires `user.preferences.read` permission or being the account owner.
|
|
50
56
|
*/
|
|
51
|
-
|
|
57
|
+
preferences;
|
|
52
58
|
/** @internal */
|
|
53
59
|
constructor(data, http) {
|
|
54
60
|
super(data, http);
|
|
55
61
|
this.email = data.email;
|
|
62
|
+
this.emailVerifiedAt = data.email_verified_at ? new Date(data.email_verified_at) : null;
|
|
56
63
|
this.nickname = data.nickname;
|
|
57
64
|
this.avatarUri = data.avatar_uri;
|
|
58
|
-
this.
|
|
65
|
+
this.disabledAt = data.disabled_at ? new Date(data.disabled_at) : null;
|
|
66
|
+
this.preferences = data.preferences ?? undefined;
|
|
59
67
|
}
|
|
60
68
|
/** Update this user account in place. */
|
|
61
69
|
async update(payload) {
|
|
62
70
|
await this.http.patch('/account', payload);
|
|
63
|
-
const data = await this.http.get('/account');
|
|
71
|
+
const data = await this.http.get('/account', { params: { include: 'preferences,permissions' } });
|
|
64
72
|
this.email = data.email;
|
|
73
|
+
this.emailVerifiedAt = data.email_verified_at ? new Date(data.email_verified_at) : null;
|
|
65
74
|
this.nickname = data.nickname;
|
|
66
75
|
this.avatarUri = data.avatar_uri;
|
|
67
|
-
this.
|
|
76
|
+
this.disabledAt = data.disabled_at ? new Date(data.disabled_at) : null;
|
|
77
|
+
this.preferences = data.preferences ?? undefined;
|
|
68
78
|
this.permissions = data.permissions;
|
|
69
79
|
this.createdAt = new Date(data.created_at);
|
|
70
80
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -81,16 +91,24 @@ export class ApiKeyAccount extends Account {
|
|
|
81
91
|
issuerType = 'api_key';
|
|
82
92
|
name;
|
|
83
93
|
description;
|
|
94
|
+
/** The owner's bare NanoID (parsed from the namespaced `owner_id`). */
|
|
84
95
|
ownerId;
|
|
85
|
-
/** The owner
|
|
96
|
+
/** The owner's issuer type, e.g. `'user'` or `'system'`. */
|
|
97
|
+
ownerType;
|
|
98
|
+
/** The owner. Requires `?include=owner`. */
|
|
86
99
|
owner;
|
|
100
|
+
/** When this key was revoked, or `null` if active. */
|
|
101
|
+
revokedAt;
|
|
87
102
|
/** @internal */
|
|
88
103
|
constructor(data, http) {
|
|
89
104
|
super(data, http);
|
|
90
105
|
this.name = data.name;
|
|
91
106
|
this.description = data.description;
|
|
92
|
-
|
|
107
|
+
const owner = parseIssuerRef(data.owner_id);
|
|
108
|
+
this.ownerId = owner.id;
|
|
109
|
+
this.ownerType = owner.type;
|
|
93
110
|
this.owner = data.owner ? new UserAccount(data.owner, http) : undefined;
|
|
111
|
+
this.revokedAt = data.revoked_at ? new Date(data.revoked_at) : null;
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
114
|
/**
|
|
@@ -184,7 +202,7 @@ export class AccountResource {
|
|
|
184
202
|
/** Update the current user account. Only works for user accounts. */
|
|
185
203
|
async update(payload) {
|
|
186
204
|
await this.http.patch('/account', payload);
|
|
187
|
-
const data = await this.http.get('/account');
|
|
205
|
+
const data = await this.http.get('/account', { params: { include: 'preferences,permissions' } });
|
|
188
206
|
return new UserAccount(data, this.http);
|
|
189
207
|
}
|
|
190
208
|
/** Upload a new avatar image. Only works for user accounts. */
|
|
@@ -205,6 +223,26 @@ export class AccountResource {
|
|
|
205
223
|
scopes() {
|
|
206
224
|
return this.http.get('/account/scopes');
|
|
207
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Fetch the current account's activity feed (actions performed on this account).
|
|
228
|
+
*
|
|
229
|
+
* Only user accounts have an activity feed.
|
|
230
|
+
*
|
|
231
|
+
* @param opts Pagination and filter options.
|
|
232
|
+
*/
|
|
233
|
+
activities(opts = {}) {
|
|
234
|
+
return listActivities(this.http, '/account/activities', opts);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Fetch the current account's own HTTP request log.
|
|
238
|
+
*
|
|
239
|
+
* Scoped to the caller; no permission beyond being that account is required.
|
|
240
|
+
*
|
|
241
|
+
* @param opts Pagination, filters, and includes.
|
|
242
|
+
*/
|
|
243
|
+
requestLogs(opts = {}) {
|
|
244
|
+
return listRequestLogs(this.http, '/account/logs', opts);
|
|
245
|
+
}
|
|
208
246
|
/** Manage SSH public keys on the current user account. */
|
|
209
247
|
get sshKeys() {
|
|
210
248
|
return new AccountSshKeysManager(this.http);
|
|
@@ -2,19 +2,17 @@ import type { HttpClient } from '../http.js';
|
|
|
2
2
|
import { ResourceNamespace } from '../namespace.js';
|
|
3
3
|
import { ReactiveResource } from '../reactive.js';
|
|
4
4
|
import { type ISODate, type NanoID, type Paginated } from '../types.js';
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
5
|
+
import type { UserData } from './users.js';
|
|
6
|
+
import { User } from './users.js';
|
|
7
7
|
/** Raw API shape for an API key. @internal */
|
|
8
|
-
interface ApiKeyData {
|
|
8
|
+
export interface ApiKeyData {
|
|
9
9
|
id: string;
|
|
10
|
-
issuer_type: string;
|
|
11
10
|
name: string;
|
|
12
11
|
description: string | null;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
token?: string;
|
|
12
|
+
owner_id: string;
|
|
13
|
+
owner?: UserData;
|
|
16
14
|
permissions?: string[];
|
|
17
|
-
|
|
15
|
+
revoked_at: ISODate | null;
|
|
18
16
|
created_at: ISODate;
|
|
19
17
|
updated_at: ISODate;
|
|
20
18
|
}
|
|
@@ -23,31 +21,26 @@ interface ApiKeyData {
|
|
|
23
21
|
*
|
|
24
22
|
* Retrieved via {@link ApiKeysNamespace.list} or {@link ApiKeysNamespace.create}.
|
|
25
23
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* The bearer token is returned only once, by {@link ApiKeysNamespace.create}. It
|
|
25
|
+
* is never part of this resource. Store it securely when first received.
|
|
28
26
|
*/
|
|
29
27
|
export declare class ApiKey extends ReactiveResource {
|
|
30
28
|
/** The API key's unique NanoID. */
|
|
31
29
|
readonly id: NanoID;
|
|
32
|
-
/** The issuer type, always `'api_key'`. */
|
|
33
|
-
readonly issuerType: string;
|
|
34
30
|
/** Display name for this API key. */
|
|
35
31
|
name: string;
|
|
36
32
|
/** Description for this API key. */
|
|
37
33
|
description: string | null;
|
|
38
|
-
/** The owner
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* `undefined` on all subsequent fetches - store it securely when first received.
|
|
45
|
-
*/
|
|
46
|
-
token: string | undefined;
|
|
34
|
+
/** The owner's bare NanoID (parsed from the namespaced `owner_id`). */
|
|
35
|
+
readonly ownerId: NanoID;
|
|
36
|
+
/** The owner's issuer type, e.g. `'user'` or `'system'`. */
|
|
37
|
+
readonly ownerType: string;
|
|
38
|
+
/** The owner of this API key. Requires `?include=owner`. */
|
|
39
|
+
owner: User | undefined;
|
|
47
40
|
/** Permissions assigned to this API key. Requires `?include=permissions`. */
|
|
48
41
|
permissions: string[] | undefined;
|
|
49
|
-
/** When this key was
|
|
50
|
-
|
|
42
|
+
/** When this key was revoked, or `null` if active. */
|
|
43
|
+
revokedAt: Date | null;
|
|
51
44
|
/** When this API key was created. */
|
|
52
45
|
createdAt: Date;
|
|
53
46
|
/** When this API key was last updated. */
|
|
@@ -123,5 +116,4 @@ export declare class ApiKeysNamespace extends ResourceNamespace<ApiKey, ApiKeyEv
|
|
|
123
116
|
*/
|
|
124
117
|
create(payload: CreateApiKeyPayload): Promise<CreateApiKeyResult>;
|
|
125
118
|
}
|
|
126
|
-
export {};
|
|
127
119
|
//# sourceMappingURL=api-keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../../src/src/resources/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../../src/src/resources/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAA4B,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAQD;;;;;;;GAOG;AACH,qBAAa,MAAO,S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AAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAO7B;;;;;;;OAOG;IACU,MAAM,CAClB,OAAO,EAAE,mBAAmB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;CAuB9B"}
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
import { ResourceNamespace } from '../namespace.js';
|
|
2
2
|
import { ReactiveResource } from '../reactive.js';
|
|
3
|
-
import { toNanoID } from '../types.js';
|
|
4
|
-
import {
|
|
3
|
+
import { parseIssuerRef, toNanoID } from '../types.js';
|
|
4
|
+
import { User } from './users.js';
|
|
5
5
|
/**
|
|
6
6
|
* An API key credential for authenticating programmatic access to the MeowPanel API.
|
|
7
7
|
*
|
|
8
8
|
* Retrieved via {@link ApiKeysNamespace.list} or {@link ApiKeysNamespace.create}.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* The bearer token is returned only once, by {@link ApiKeysNamespace.create}. It
|
|
11
|
+
* is never part of this resource. Store it securely when first received.
|
|
12
12
|
*/
|
|
13
13
|
export class ApiKey extends ReactiveResource {
|
|
14
14
|
/** The API key's unique NanoID. */
|
|
15
15
|
id;
|
|
16
|
-
/** The issuer type, always `'api_key'`. */
|
|
17
|
-
issuerType;
|
|
18
16
|
/** Display name for this API key. */
|
|
19
17
|
name;
|
|
20
18
|
/** Description for this API key. */
|
|
21
19
|
description;
|
|
22
|
-
/** The owner
|
|
20
|
+
/** The owner's bare NanoID (parsed from the namespaced `owner_id`). */
|
|
21
|
+
ownerId;
|
|
22
|
+
/** The owner's issuer type, e.g. `'user'` or `'system'`. */
|
|
23
|
+
ownerType;
|
|
24
|
+
/** The owner of this API key. Requires `?include=owner`. */
|
|
23
25
|
owner;
|
|
24
|
-
/**
|
|
25
|
-
* The bearer token value.
|
|
26
|
-
*
|
|
27
|
-
* Only populated immediately after creation via {@link ApiKeysNamespace.create}.
|
|
28
|
-
* `undefined` on all subsequent fetches - store it securely when first received.
|
|
29
|
-
*/
|
|
30
|
-
token;
|
|
31
26
|
/** Permissions assigned to this API key. Requires `?include=permissions`. */
|
|
32
27
|
permissions;
|
|
33
|
-
/** When this key was
|
|
34
|
-
|
|
28
|
+
/** When this key was revoked, or `null` if active. */
|
|
29
|
+
revokedAt;
|
|
35
30
|
/** When this API key was created. */
|
|
36
31
|
createdAt;
|
|
37
32
|
/** When this API key was last updated. */
|
|
@@ -40,13 +35,14 @@ export class ApiKey extends ReactiveResource {
|
|
|
40
35
|
constructor(data) {
|
|
41
36
|
super();
|
|
42
37
|
this.id = toNanoID(data.id);
|
|
43
|
-
this.issuerType = data.issuer_type;
|
|
44
38
|
this.name = data.name;
|
|
45
39
|
this.description = data.description;
|
|
46
|
-
|
|
47
|
-
this.
|
|
40
|
+
const owner = parseIssuerRef(data.owner_id);
|
|
41
|
+
this.ownerId = owner.id;
|
|
42
|
+
this.ownerType = owner.type;
|
|
43
|
+
this.owner = data.owner ? new User(data.owner) : undefined;
|
|
48
44
|
this.permissions = data.permissions;
|
|
49
|
-
this.
|
|
45
|
+
this.revokedAt = data.revoked_at ? new Date(data.revoked_at) : null;
|
|
50
46
|
this.createdAt = new Date(data.created_at);
|
|
51
47
|
this.updatedAt = new Date(data.updated_at);
|
|
52
48
|
}
|
|
@@ -1,28 +1,69 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
|
+
import { type ApiKeyAccount, type UserAccount } from './account.js';
|
|
2
3
|
/**
|
|
3
4
|
* A single authentication provider and its display configuration.
|
|
4
5
|
*/
|
|
5
6
|
export interface AuthProvider {
|
|
7
|
+
/** Relative submission URL for this provider, e.g. `"/v1/auth/email"`. */
|
|
8
|
+
url: string;
|
|
6
9
|
/** Provider-specific display fields, e.g. `{ display_name: 'WHMCS' }`. */
|
|
7
10
|
fields: Record<string, string>;
|
|
8
11
|
}
|
|
12
|
+
/** Email-verification policy for the panel. `'off'` when email is unavailable. */
|
|
13
|
+
export type EmailVerificationMode = 'off' | 'optional' | 'required';
|
|
9
14
|
/**
|
|
10
15
|
* Metadata about the panel's authentication configuration.
|
|
11
16
|
*/
|
|
12
17
|
export interface AuthMeta {
|
|
13
18
|
/** Available auth providers keyed by provider ID (e.g. `'email'`, `'whmcs'`). */
|
|
14
19
|
providers: Record<string, AuthProvider>;
|
|
20
|
+
/** Email capability and verification policy. */
|
|
21
|
+
email: {
|
|
22
|
+
/** `true` when an email transport is configured. */
|
|
23
|
+
available: boolean;
|
|
24
|
+
/** The verification policy in effect. */
|
|
25
|
+
verification: EmailVerificationMode;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** The opaque session token returned by a login or exchange. */
|
|
29
|
+
export interface LoginResult {
|
|
30
|
+
/**
|
|
31
|
+
* The opaque session token. Usable only on `/auth/*` routes; call
|
|
32
|
+
* {@link AuthResource.refresh} with it set as the bearer token to obtain an access token.
|
|
33
|
+
*/
|
|
34
|
+
token: string;
|
|
35
|
+
}
|
|
36
|
+
/** The result of redeeming an exchange code. */
|
|
37
|
+
export interface ExchangeResult extends LoginResult {
|
|
38
|
+
/** The post-login redirect path, or `null`. */
|
|
39
|
+
redirect: string | null;
|
|
40
|
+
}
|
|
41
|
+
/** The access token (and optional account) from a refresh. */
|
|
42
|
+
export interface RefreshResult {
|
|
43
|
+
/** Always `"Bearer"`. */
|
|
44
|
+
tokenType: string;
|
|
45
|
+
/** Lifetime of the access token, in seconds. */
|
|
46
|
+
expiresInSeconds: number;
|
|
47
|
+
/** The JWT access token to use on all non-auth routes. */
|
|
48
|
+
accessToken: string;
|
|
49
|
+
/** The authenticated account. Present only when requested with `includeAccount`. */
|
|
50
|
+
account?: UserAccount | ApiKeyAccount;
|
|
15
51
|
}
|
|
16
52
|
/**
|
|
17
|
-
* Resource for authentication configuration.
|
|
53
|
+
* Resource for authentication configuration and login flows.
|
|
18
54
|
*
|
|
19
55
|
* Access via `api.auth`.
|
|
20
56
|
*
|
|
57
|
+
* The flow: submit credentials ({@link login}) or redeem a code ({@link exchange}) to get an
|
|
58
|
+
* opaque session token, set it as the client token, then call {@link refresh} to obtain the
|
|
59
|
+
* short-lived access token used for all other requests.
|
|
60
|
+
*
|
|
21
61
|
* @example
|
|
22
62
|
* ```ts ignore
|
|
23
|
-
* const {
|
|
24
|
-
*
|
|
25
|
-
*
|
|
63
|
+
* const { token } = await api.auth.loginWithEmail('me@example.com', 'hunter2');
|
|
64
|
+
* api.setToken(token);
|
|
65
|
+
* const { accessToken } = await api.auth.refresh();
|
|
66
|
+
* api.setToken(accessToken);
|
|
26
67
|
* ```
|
|
27
68
|
*/
|
|
28
69
|
export declare class AuthResource {
|
|
@@ -35,5 +76,30 @@ export declare class AuthResource {
|
|
|
35
76
|
* Returns the available login providers and their display fields.
|
|
36
77
|
*/
|
|
37
78
|
getMeta(): Promise<AuthMeta>;
|
|
79
|
+
/**
|
|
80
|
+
* Submit credentials to a login provider.
|
|
81
|
+
*
|
|
82
|
+
* @param provider The provider id, e.g. `"email"`.
|
|
83
|
+
* @param credentials The provider's fields (for `email`: `{ email, password }`).
|
|
84
|
+
*/
|
|
85
|
+
login(provider: string, credentials: Record<string, unknown>): Promise<LoginResult>;
|
|
86
|
+
/** Log in with email and password. */
|
|
87
|
+
loginWithEmail(email: string, password: string): Promise<LoginResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Redeem a single-use exchange code (e.g. from a WHMCS SSO redirect) for a session token.
|
|
90
|
+
*
|
|
91
|
+
* @param code The exchange code.
|
|
92
|
+
*/
|
|
93
|
+
exchange(code: string): Promise<ExchangeResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Exchange the current (opaque session) token for a short-lived access token.
|
|
96
|
+
*
|
|
97
|
+
* Call this with the session token set as the client's bearer token.
|
|
98
|
+
*
|
|
99
|
+
* @param opts `includeAccount` also returns the authenticated account.
|
|
100
|
+
*/
|
|
101
|
+
refresh(opts?: {
|
|
102
|
+
includeAccount?: boolean;
|
|
103
|
+
}): Promise<RefreshResult>;
|
|
38
104
|
}
|
|
39
105
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAW,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAc7E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,kFAAkF;AAClF,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,gDAAgD;IAChD,KAAK,EAAE;QACN,oDAAoD;QACpD,SAAS,EAAE,OAAO,CAAC;QACnB,yCAAyC;QACzC,YAAY,EAAE,qBAAqB,CAAC;KACpC,CAAC;CACF;AAED,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACd;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAe,SAAQ,WAAW;IAClD,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC7B,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,YAAY;IAEL,OAAO,CAAC,QAAQ,CAAC,IAAI;IADxC,gBAAgB;gBACoB,IAAI,EAAE,UAAU;IAEpD;;;;OAIG;IACI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;IAInC;;;;;OAKG;IACI,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAI1F,sCAAsC;IAC/B,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5E;;;;OAIG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAItD;;;;;;OAMG;IACU,OAAO,CAAC,IAAI,GAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CAcrF"}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { Account } from './account.js';
|
|
1
2
|
/**
|
|
2
|
-
* Resource for authentication configuration.
|
|
3
|
+
* Resource for authentication configuration and login flows.
|
|
3
4
|
*
|
|
4
5
|
* Access via `api.auth`.
|
|
5
6
|
*
|
|
7
|
+
* The flow: submit credentials ({@link login}) or redeem a code ({@link exchange}) to get an
|
|
8
|
+
* opaque session token, set it as the client token, then call {@link refresh} to obtain the
|
|
9
|
+
* short-lived access token used for all other requests.
|
|
10
|
+
*
|
|
6
11
|
* @example
|
|
7
12
|
* ```ts ignore
|
|
8
|
-
* const {
|
|
9
|
-
*
|
|
10
|
-
*
|
|
13
|
+
* const { token } = await api.auth.loginWithEmail('me@example.com', 'hunter2');
|
|
14
|
+
* api.setToken(token);
|
|
15
|
+
* const { accessToken } = await api.auth.refresh();
|
|
16
|
+
* api.setToken(accessToken);
|
|
11
17
|
* ```
|
|
12
18
|
*/
|
|
13
19
|
export class AuthResource {
|
|
@@ -24,4 +30,41 @@ export class AuthResource {
|
|
|
24
30
|
getMeta() {
|
|
25
31
|
return this.http.get('/auth');
|
|
26
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Submit credentials to a login provider.
|
|
35
|
+
*
|
|
36
|
+
* @param provider The provider id, e.g. `"email"`.
|
|
37
|
+
* @param credentials The provider's fields (for `email`: `{ email, password }`).
|
|
38
|
+
*/
|
|
39
|
+
login(provider, credentials) {
|
|
40
|
+
return this.http.post(`/auth/${encodeURIComponent(provider)}`, credentials);
|
|
41
|
+
}
|
|
42
|
+
/** Log in with email and password. */
|
|
43
|
+
loginWithEmail(email, password) {
|
|
44
|
+
return this.login('email', { email, password });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Redeem a single-use exchange code (e.g. from a WHMCS SSO redirect) for a session token.
|
|
48
|
+
*
|
|
49
|
+
* @param code The exchange code.
|
|
50
|
+
*/
|
|
51
|
+
exchange(code) {
|
|
52
|
+
return this.http.post('/auth/exchange', { code });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Exchange the current (opaque session) token for a short-lived access token.
|
|
56
|
+
*
|
|
57
|
+
* Call this with the session token set as the client's bearer token.
|
|
58
|
+
*
|
|
59
|
+
* @param opts `includeAccount` also returns the authenticated account.
|
|
60
|
+
*/
|
|
61
|
+
async refresh(opts = {}) {
|
|
62
|
+
const raw = await this.http.post('/auth/refresh', undefined, opts.includeAccount ? { params: { include: 'account' } } : {});
|
|
63
|
+
return {
|
|
64
|
+
tokenType: raw.token_type,
|
|
65
|
+
expiresInSeconds: raw.expires_in_seconds,
|
|
66
|
+
accessToken: raw.access_token,
|
|
67
|
+
account: raw.account ? Account.create(raw.account, this.http) : undefined,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
27
70
|
}
|