@meowpanel/api 0.2.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 +39 -18
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +26 -8
- 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/errors.d.ts +8 -0
- package/esm/src/errors.d.ts.map +1 -1
- package/esm/src/errors.js +10 -0
- 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 +104 -19
- package/esm/src/resources/account.d.ts.map +1 -1
- package/esm/src/resources/account.js +112 -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 +106 -41
- package/esm/src/resources/nodes.d.ts.map +1 -1
- package/esm/src/resources/nodes.js +121 -28
- 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 +21 -19
- package/esm/src/resources/servers/sftp.d.ts.map +1 -1
- package/esm/src/resources/servers/sftp.js +22 -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 +39 -18
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +52 -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/errors.d.ts +8 -0
- package/script/src/errors.d.ts.map +1 -1
- package/script/src/errors.js +10 -0
- 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 +104 -19
- package/script/src/resources/account.d.ts.map +1 -1
- package/script/src/resources/account.js +114 -13
- 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 +106 -41
- package/script/src/resources/nodes.d.ts.map +1 -1
- package/script/src/resources/nodes.js +122 -28
- 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 +21 -19
- package/script/src/resources/servers/sftp.d.ts.map +1 -1
- package/script/src/resources/servers/sftp.js +22 -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,32 +1,41 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
2
|
import { ReactiveResource } from '../reactive.js';
|
|
3
|
-
import type { IncludeOptions, ISODate, NanoID } from '../types.js';
|
|
4
|
-
|
|
3
|
+
import type { IncludeOptions, ISODate, NanoID, Paginated } from '../types.js';
|
|
4
|
+
import type { UiTheme, UserPreferences, UserPreferencesData } from './users.js';
|
|
5
|
+
import { type ActivityFeedOptions, type ActivityLog } from './servers/activity.js';
|
|
6
|
+
import { type RequestLog, type RequestLogFeedOptions } from './request-logs.js';
|
|
7
|
+
/**
|
|
8
|
+
* Shared issuer-envelope fields present on all account responses.
|
|
9
|
+
*
|
|
10
|
+
* `id` is the namespaced `"<type>:<id>"` form and `ref_id` holds the bare id.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
5
13
|
interface AccountDataBase {
|
|
6
14
|
id: string;
|
|
7
|
-
|
|
15
|
+
type: string;
|
|
16
|
+
ref_id: string;
|
|
8
17
|
permissions?: string[];
|
|
9
18
|
created_at: ISODate;
|
|
10
19
|
updated_at: ISODate;
|
|
11
20
|
}
|
|
12
21
|
/** Raw API shape for a user account. @internal */
|
|
13
22
|
interface UserAccountData extends AccountDataBase {
|
|
14
|
-
|
|
23
|
+
type: 'user';
|
|
15
24
|
email: string;
|
|
25
|
+
email_verified_at: ISODate | null;
|
|
16
26
|
nickname: string | null;
|
|
17
27
|
avatar_uri: string | null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
theme: string | null;
|
|
21
|
-
} | null;
|
|
28
|
+
disabled_at: ISODate | null;
|
|
29
|
+
preferences?: UserPreferencesData | null;
|
|
22
30
|
}
|
|
23
31
|
/** Raw API shape for an API key account. @internal */
|
|
24
32
|
interface ApiKeyAccountData extends AccountDataBase {
|
|
25
|
-
|
|
33
|
+
type: 'api_key';
|
|
26
34
|
name: string;
|
|
27
35
|
description: string | null;
|
|
28
36
|
owner_id: string;
|
|
29
37
|
owner?: UserAccountData;
|
|
38
|
+
revoked_at: ISODate | null;
|
|
30
39
|
}
|
|
31
40
|
type AccountData = UserAccountData | ApiKeyAccountData;
|
|
32
41
|
/**
|
|
@@ -52,16 +61,17 @@ export declare abstract class Account extends ReactiveResource {
|
|
|
52
61
|
export declare class UserAccount extends Account {
|
|
53
62
|
readonly issuerType: "user";
|
|
54
63
|
email: string;
|
|
64
|
+
/** When this user verified their email, or `null` if unverified. */
|
|
65
|
+
emailVerifiedAt: Date | null;
|
|
55
66
|
nickname: string | null;
|
|
56
67
|
avatarUri: string | null;
|
|
68
|
+
/** When this account was disabled, or `null` if active. */
|
|
69
|
+
disabledAt: Date | null;
|
|
57
70
|
/**
|
|
58
|
-
* Display preferences. Populated with `include=
|
|
59
|
-
* Requires `
|
|
71
|
+
* Display and locale preferences. Populated with `include=preferences`.
|
|
72
|
+
* Requires `user.preferences.read` permission or being the account owner.
|
|
60
73
|
*/
|
|
61
|
-
|
|
62
|
-
language: string | null;
|
|
63
|
-
theme: string | null;
|
|
64
|
-
} | undefined;
|
|
74
|
+
preferences: UserPreferences | undefined;
|
|
65
75
|
/** @internal */
|
|
66
76
|
constructor(data: UserAccountData, http: HttpClient);
|
|
67
77
|
/** Update this user account in place. */
|
|
@@ -74,20 +84,77 @@ export declare class ApiKeyAccount extends Account {
|
|
|
74
84
|
readonly issuerType: "api_key";
|
|
75
85
|
name: string;
|
|
76
86
|
description: string | null;
|
|
87
|
+
/** The owner's bare NanoID (parsed from the namespaced `owner_id`). */
|
|
77
88
|
readonly ownerId: NanoID;
|
|
78
|
-
/** The owner
|
|
89
|
+
/** The owner's issuer type, e.g. `'user'` or `'system'`. */
|
|
90
|
+
readonly ownerType: string;
|
|
91
|
+
/** The owner. Requires `?include=owner`. */
|
|
79
92
|
owner: UserAccount | undefined;
|
|
93
|
+
/** When this key was revoked, or `null` if active. */
|
|
94
|
+
revokedAt: Date | null;
|
|
80
95
|
/** @internal */
|
|
81
96
|
constructor(data: ApiKeyAccountData, http: HttpClient);
|
|
82
97
|
}
|
|
98
|
+
/** Raw API shape for an account SSH key. @internal */
|
|
99
|
+
export interface SshKeyData {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
public_key: string;
|
|
103
|
+
created_at: ISODate;
|
|
104
|
+
updated_at: ISODate;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* An SSH public key registered on the authenticated user account, used to
|
|
108
|
+
* authenticate against a server's SFTP endpoint.
|
|
109
|
+
*
|
|
110
|
+
* Retrieved via {@link AccountSshKeysManager.list} or {@link AccountSshKeysManager.create}.
|
|
111
|
+
*/
|
|
112
|
+
export declare class SshKey extends ReactiveResource {
|
|
113
|
+
/** The SSH key's unique NanoID. */
|
|
114
|
+
readonly id: NanoID;
|
|
115
|
+
/** Display name for the key. */
|
|
116
|
+
name: string;
|
|
117
|
+
/** The OpenSSH-format public key, e.g. `"ssh-ed25519 AAAA..."`. */
|
|
118
|
+
publicKey: string;
|
|
119
|
+
/** When this key was added. */
|
|
120
|
+
createdAt: Date;
|
|
121
|
+
/** When this key was last updated. */
|
|
122
|
+
updatedAt: Date;
|
|
123
|
+
/** @internal */
|
|
124
|
+
constructor(data: SshKeyData);
|
|
125
|
+
}
|
|
126
|
+
/** Payload for registering a new SSH key. */
|
|
127
|
+
export interface CreateSshKeyPayload {
|
|
128
|
+
/** Display name for the key. */
|
|
129
|
+
name: string;
|
|
130
|
+
/** The OpenSSH-format public key. */
|
|
131
|
+
publicKey: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Manages SSH public keys on the authenticated user account.
|
|
135
|
+
*
|
|
136
|
+
* Access via `api.account.sshKeys`. Only user accounts can hold SSH keys; the
|
|
137
|
+
* API rejects these calls for non-user credentials.
|
|
138
|
+
*/
|
|
139
|
+
export declare class AccountSshKeysManager {
|
|
140
|
+
private readonly http;
|
|
141
|
+
/** @internal */
|
|
142
|
+
constructor(http: HttpClient);
|
|
143
|
+
/** List the SSH keys registered on the current user account. */
|
|
144
|
+
list(): Promise<SshKey[]>;
|
|
145
|
+
/** Register a new SSH public key on the current user account. */
|
|
146
|
+
create(payload: CreateSshKeyPayload): Promise<SshKey>;
|
|
147
|
+
/** Delete an SSH key from the current user account. */
|
|
148
|
+
delete(id: NanoID): Promise<void>;
|
|
149
|
+
}
|
|
83
150
|
/** Valid include keys for the account endpoint. */
|
|
84
|
-
export type AccountInclude = '
|
|
151
|
+
export type AccountInclude = 'preferences' | 'permissions';
|
|
85
152
|
/** Fields that can be updated on a user account. */
|
|
86
153
|
export interface UpdateAccountPayload {
|
|
87
154
|
nickname?: string;
|
|
88
|
-
|
|
155
|
+
preferences?: {
|
|
156
|
+
theme?: UiTheme;
|
|
89
157
|
language?: string | null;
|
|
90
|
-
theme?: string | null;
|
|
91
158
|
};
|
|
92
159
|
}
|
|
93
160
|
/**
|
|
@@ -120,6 +187,24 @@ export declare class AccountResource {
|
|
|
120
187
|
fetchAvatar(): Promise<Blob>;
|
|
121
188
|
/** Fetch the permission scopes available to the current account. */
|
|
122
189
|
scopes(): Promise<string[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Fetch the current account's activity feed (actions performed on this account).
|
|
192
|
+
*
|
|
193
|
+
* Only user accounts have an activity feed.
|
|
194
|
+
*
|
|
195
|
+
* @param opts Pagination and filter options.
|
|
196
|
+
*/
|
|
197
|
+
activities(opts?: ActivityFeedOptions): Promise<Paginated<ActivityLog>>;
|
|
198
|
+
/**
|
|
199
|
+
* Fetch the current account's own HTTP request log.
|
|
200
|
+
*
|
|
201
|
+
* Scoped to the caller; no permission beyond being that account is required.
|
|
202
|
+
*
|
|
203
|
+
* @param opts Pagination, filters, and includes.
|
|
204
|
+
*/
|
|
205
|
+
requestLogs(opts?: RequestLogFeedOptions): Promise<Paginated<RequestLog>>;
|
|
206
|
+
/** Manage SSH public keys on the current user account. */
|
|
207
|
+
get sshKeys(): AccountSshKeysManager;
|
|
123
208
|
}
|
|
124
209
|
export {};
|
|
125
210
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -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,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
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,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,WAAW,EAAkB,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAmB,KAAK,UAAU,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEjG;;;;;GAKG;AACH,UAAU,eAAe;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,kDAAkD;AAClD,UAAU,eAAgB,SAAQ,eAAe;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,OAAO,GAAG,IAAI,CAA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WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASxF,8CAA8C;IACjC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzC,oEAAoE;IAC7D,MAAM,IAAI,OAAO,CAAC,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,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccountResource = exports.ApiKeyAccount = exports.UserAccount = exports.Account = void 0;
|
|
3
|
+
exports.AccountResource = exports.AccountSshKeysManager = exports.SshKey = exports.ApiKeyAccount = exports.UserAccount = exports.Account = void 0;
|
|
4
4
|
const reactive_js_1 = require("../reactive.js");
|
|
5
5
|
const types_js_1 = require("../types.js");
|
|
6
|
+
const activity_js_1 = require("./servers/activity.js");
|
|
7
|
+
const request_logs_js_1 = require("./request-logs.js");
|
|
6
8
|
/**
|
|
7
9
|
* Base class for the authenticated account.
|
|
8
10
|
*
|
|
@@ -18,7 +20,7 @@ class Account extends reactive_js_1.ReactiveResource {
|
|
|
18
20
|
constructor(data, http) {
|
|
19
21
|
super();
|
|
20
22
|
this.http = http;
|
|
21
|
-
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
23
|
+
this.id = data.ref_id ? (0, types_js_1.toNanoID)(data.ref_id) : (0, types_js_1.parseIssuerRef)(data.id).id;
|
|
22
24
|
this.permissions = data.permissions;
|
|
23
25
|
this.createdAt = new Date(data.created_at);
|
|
24
26
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -31,13 +33,13 @@ class Account extends reactive_js_1.ReactiveResource {
|
|
|
31
33
|
}
|
|
32
34
|
/** @internal */
|
|
33
35
|
static create(data, http) {
|
|
34
|
-
switch (data.
|
|
36
|
+
switch (data.type) {
|
|
35
37
|
case 'user':
|
|
36
38
|
return new UserAccount(data, http);
|
|
37
39
|
case 'api_key':
|
|
38
40
|
return new ApiKeyAccount(data, http);
|
|
39
41
|
default:
|
|
40
|
-
throw new Error(`Unknown account issuer type: ${data.
|
|
42
|
+
throw new Error(`Unknown account issuer type: ${data.type}`);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
@@ -46,29 +48,37 @@ exports.Account = Account;
|
|
|
46
48
|
class UserAccount extends Account {
|
|
47
49
|
issuerType = 'user';
|
|
48
50
|
email;
|
|
51
|
+
/** When this user verified their email, or `null` if unverified. */
|
|
52
|
+
emailVerifiedAt;
|
|
49
53
|
nickname;
|
|
50
54
|
avatarUri;
|
|
55
|
+
/** When this account was disabled, or `null` if active. */
|
|
56
|
+
disabledAt;
|
|
51
57
|
/**
|
|
52
|
-
* Display preferences. Populated with `include=
|
|
53
|
-
* Requires `
|
|
58
|
+
* Display and locale preferences. Populated with `include=preferences`.
|
|
59
|
+
* Requires `user.preferences.read` permission or being the account owner.
|
|
54
60
|
*/
|
|
55
|
-
|
|
61
|
+
preferences;
|
|
56
62
|
/** @internal */
|
|
57
63
|
constructor(data, http) {
|
|
58
64
|
super(data, http);
|
|
59
65
|
this.email = data.email;
|
|
66
|
+
this.emailVerifiedAt = data.email_verified_at ? new Date(data.email_verified_at) : null;
|
|
60
67
|
this.nickname = data.nickname;
|
|
61
68
|
this.avatarUri = data.avatar_uri;
|
|
62
|
-
this.
|
|
69
|
+
this.disabledAt = data.disabled_at ? new Date(data.disabled_at) : null;
|
|
70
|
+
this.preferences = data.preferences ?? undefined;
|
|
63
71
|
}
|
|
64
72
|
/** Update this user account in place. */
|
|
65
73
|
async update(payload) {
|
|
66
74
|
await this.http.patch('/account', payload);
|
|
67
|
-
const data = await this.http.get('/account');
|
|
75
|
+
const data = await this.http.get('/account', { params: { include: 'preferences,permissions' } });
|
|
68
76
|
this.email = data.email;
|
|
77
|
+
this.emailVerifiedAt = data.email_verified_at ? new Date(data.email_verified_at) : null;
|
|
69
78
|
this.nickname = data.nickname;
|
|
70
79
|
this.avatarUri = data.avatar_uri;
|
|
71
|
-
this.
|
|
80
|
+
this.disabledAt = data.disabled_at ? new Date(data.disabled_at) : null;
|
|
81
|
+
this.preferences = data.preferences ?? undefined;
|
|
72
82
|
this.permissions = data.permissions;
|
|
73
83
|
this.createdAt = new Date(data.created_at);
|
|
74
84
|
this.updatedAt = new Date(data.updated_at);
|
|
@@ -86,19 +96,86 @@ class ApiKeyAccount extends Account {
|
|
|
86
96
|
issuerType = 'api_key';
|
|
87
97
|
name;
|
|
88
98
|
description;
|
|
99
|
+
/** The owner's bare NanoID (parsed from the namespaced `owner_id`). */
|
|
89
100
|
ownerId;
|
|
90
|
-
/** The owner
|
|
101
|
+
/** The owner's issuer type, e.g. `'user'` or `'system'`. */
|
|
102
|
+
ownerType;
|
|
103
|
+
/** The owner. Requires `?include=owner`. */
|
|
91
104
|
owner;
|
|
105
|
+
/** When this key was revoked, or `null` if active. */
|
|
106
|
+
revokedAt;
|
|
92
107
|
/** @internal */
|
|
93
108
|
constructor(data, http) {
|
|
94
109
|
super(data, http);
|
|
95
110
|
this.name = data.name;
|
|
96
111
|
this.description = data.description;
|
|
97
|
-
|
|
112
|
+
const owner = (0, types_js_1.parseIssuerRef)(data.owner_id);
|
|
113
|
+
this.ownerId = owner.id;
|
|
114
|
+
this.ownerType = owner.type;
|
|
98
115
|
this.owner = data.owner ? new UserAccount(data.owner, http) : undefined;
|
|
116
|
+
this.revokedAt = data.revoked_at ? new Date(data.revoked_at) : null;
|
|
99
117
|
}
|
|
100
118
|
}
|
|
101
119
|
exports.ApiKeyAccount = ApiKeyAccount;
|
|
120
|
+
/**
|
|
121
|
+
* An SSH public key registered on the authenticated user account, used to
|
|
122
|
+
* authenticate against a server's SFTP endpoint.
|
|
123
|
+
*
|
|
124
|
+
* Retrieved via {@link AccountSshKeysManager.list} or {@link AccountSshKeysManager.create}.
|
|
125
|
+
*/
|
|
126
|
+
class SshKey extends reactive_js_1.ReactiveResource {
|
|
127
|
+
/** The SSH key's unique NanoID. */
|
|
128
|
+
id;
|
|
129
|
+
/** Display name for the key. */
|
|
130
|
+
name;
|
|
131
|
+
/** The OpenSSH-format public key, e.g. `"ssh-ed25519 AAAA..."`. */
|
|
132
|
+
publicKey;
|
|
133
|
+
/** When this key was added. */
|
|
134
|
+
createdAt;
|
|
135
|
+
/** When this key was last updated. */
|
|
136
|
+
updatedAt;
|
|
137
|
+
/** @internal */
|
|
138
|
+
constructor(data) {
|
|
139
|
+
super();
|
|
140
|
+
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
141
|
+
this.name = data.name;
|
|
142
|
+
this.publicKey = data.public_key;
|
|
143
|
+
this.createdAt = new Date(data.created_at);
|
|
144
|
+
this.updatedAt = new Date(data.updated_at);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.SshKey = SshKey;
|
|
148
|
+
/**
|
|
149
|
+
* Manages SSH public keys on the authenticated user account.
|
|
150
|
+
*
|
|
151
|
+
* Access via `api.account.sshKeys`. Only user accounts can hold SSH keys; the
|
|
152
|
+
* API rejects these calls for non-user credentials.
|
|
153
|
+
*/
|
|
154
|
+
class AccountSshKeysManager {
|
|
155
|
+
http;
|
|
156
|
+
/** @internal */
|
|
157
|
+
constructor(http) {
|
|
158
|
+
this.http = http;
|
|
159
|
+
}
|
|
160
|
+
/** List the SSH keys registered on the current user account. */
|
|
161
|
+
async list() {
|
|
162
|
+
const data = await this.http.get('/account/ssh-keys');
|
|
163
|
+
return data.map((d) => new SshKey(d));
|
|
164
|
+
}
|
|
165
|
+
/** Register a new SSH public key on the current user account. */
|
|
166
|
+
async create(payload) {
|
|
167
|
+
const data = await this.http.post('/account/ssh-keys', {
|
|
168
|
+
name: payload.name,
|
|
169
|
+
public_key: payload.publicKey,
|
|
170
|
+
});
|
|
171
|
+
return new SshKey(data);
|
|
172
|
+
}
|
|
173
|
+
/** Delete an SSH key from the current user account. */
|
|
174
|
+
async delete(id) {
|
|
175
|
+
await this.http.delete(`/account/ssh-keys/${id}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.AccountSshKeysManager = AccountSshKeysManager;
|
|
102
179
|
/**
|
|
103
180
|
* Resource for the currently authenticated account.
|
|
104
181
|
*
|
|
@@ -133,7 +210,7 @@ class AccountResource {
|
|
|
133
210
|
/** Update the current user account. Only works for user accounts. */
|
|
134
211
|
async update(payload) {
|
|
135
212
|
await this.http.patch('/account', payload);
|
|
136
|
-
const data = await this.http.get('/account');
|
|
213
|
+
const data = await this.http.get('/account', { params: { include: 'preferences,permissions' } });
|
|
137
214
|
return new UserAccount(data, this.http);
|
|
138
215
|
}
|
|
139
216
|
/** Upload a new avatar image. Only works for user accounts. */
|
|
@@ -154,5 +231,29 @@ class AccountResource {
|
|
|
154
231
|
scopes() {
|
|
155
232
|
return this.http.get('/account/scopes');
|
|
156
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Fetch the current account's activity feed (actions performed on this account).
|
|
236
|
+
*
|
|
237
|
+
* Only user accounts have an activity feed.
|
|
238
|
+
*
|
|
239
|
+
* @param opts Pagination and filter options.
|
|
240
|
+
*/
|
|
241
|
+
activities(opts = {}) {
|
|
242
|
+
return (0, activity_js_1.listActivities)(this.http, '/account/activities', opts);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Fetch the current account's own HTTP request log.
|
|
246
|
+
*
|
|
247
|
+
* Scoped to the caller; no permission beyond being that account is required.
|
|
248
|
+
*
|
|
249
|
+
* @param opts Pagination, filters, and includes.
|
|
250
|
+
*/
|
|
251
|
+
requestLogs(opts = {}) {
|
|
252
|
+
return (0, request_logs_js_1.listRequestLogs)(this.http, '/account/logs', opts);
|
|
253
|
+
}
|
|
254
|
+
/** Manage SSH public keys on the current user account. */
|
|
255
|
+
get sshKeys() {
|
|
256
|
+
return new AccountSshKeysManager(this.http);
|
|
257
|
+
}
|
|
157
258
|
}
|
|
158
259
|
exports.AccountResource = AccountResource;
|
|
@@ -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,EA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AM,EAAE,GAAG,SAAS,CAAC;IACzC,sDAAsD;IAC/C,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAC9B,qCAAqC;IAC9B,SAAS,EAAE,IAAI,CAAC;IACvB,0CAA0C;IACnC,SAAS,EAAE,IAAI,CAAC;IAEvB,gBAAgB;gBACG,IAAI,EAAE,UAAU;CAcnC;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IACnC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,mDAAmD;AACnD,MAAM,WAAW,kBAAkB;IAClC,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC5B,iFAAiF;IACjF,OAAO,EAAE,kBAAkB,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC;IAC5E,gBAAgB;gBACG,IAAI,EAAE,UAAU;IAInC;;;;;;OAMG;IACU,IAAI,CAChB,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,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"}
|
|
@@ -4,37 +4,32 @@ exports.ApiKeysNamespace = exports.ApiKey = void 0;
|
|
|
4
4
|
const namespace_js_1 = require("../namespace.js");
|
|
5
5
|
const reactive_js_1 = require("../reactive.js");
|
|
6
6
|
const types_js_1 = require("../types.js");
|
|
7
|
-
const
|
|
7
|
+
const users_js_1 = require("./users.js");
|
|
8
8
|
/**
|
|
9
9
|
* An API key credential for authenticating programmatic access to the MeowPanel API.
|
|
10
10
|
*
|
|
11
11
|
* Retrieved via {@link ApiKeysNamespace.list} or {@link ApiKeysNamespace.create}.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* The bearer token is returned only once, by {@link ApiKeysNamespace.create}. It
|
|
14
|
+
* is never part of this resource. Store it securely when first received.
|
|
15
15
|
*/
|
|
16
16
|
class ApiKey extends reactive_js_1.ReactiveResource {
|
|
17
17
|
/** The API key's unique NanoID. */
|
|
18
18
|
id;
|
|
19
|
-
/** The issuer type, always `'api_key'`. */
|
|
20
|
-
issuerType;
|
|
21
19
|
/** Display name for this API key. */
|
|
22
20
|
name;
|
|
23
21
|
/** Description for this API key. */
|
|
24
22
|
description;
|
|
25
|
-
/** The owner
|
|
23
|
+
/** The owner's bare NanoID (parsed from the namespaced `owner_id`). */
|
|
24
|
+
ownerId;
|
|
25
|
+
/** The owner's issuer type, e.g. `'user'` or `'system'`. */
|
|
26
|
+
ownerType;
|
|
27
|
+
/** The owner of this API key. Requires `?include=owner`. */
|
|
26
28
|
owner;
|
|
27
|
-
/**
|
|
28
|
-
* The bearer token value.
|
|
29
|
-
*
|
|
30
|
-
* Only populated immediately after creation via {@link ApiKeysNamespace.create}.
|
|
31
|
-
* `undefined` on all subsequent fetches - store it securely when first received.
|
|
32
|
-
*/
|
|
33
|
-
token;
|
|
34
29
|
/** Permissions assigned to this API key. Requires `?include=permissions`. */
|
|
35
30
|
permissions;
|
|
36
|
-
/** When this key was
|
|
37
|
-
|
|
31
|
+
/** When this key was revoked, or `null` if active. */
|
|
32
|
+
revokedAt;
|
|
38
33
|
/** When this API key was created. */
|
|
39
34
|
createdAt;
|
|
40
35
|
/** When this API key was last updated. */
|
|
@@ -43,13 +38,14 @@ class ApiKey extends reactive_js_1.ReactiveResource {
|
|
|
43
38
|
constructor(data) {
|
|
44
39
|
super();
|
|
45
40
|
this.id = (0, types_js_1.toNanoID)(data.id);
|
|
46
|
-
this.issuerType = data.issuer_type;
|
|
47
41
|
this.name = data.name;
|
|
48
42
|
this.description = data.description;
|
|
49
|
-
|
|
50
|
-
this.
|
|
43
|
+
const owner = (0, types_js_1.parseIssuerRef)(data.owner_id);
|
|
44
|
+
this.ownerId = owner.id;
|
|
45
|
+
this.ownerType = owner.type;
|
|
46
|
+
this.owner = data.owner ? new users_js_1.User(data.owner) : undefined;
|
|
51
47
|
this.permissions = data.permissions;
|
|
52
|
-
this.
|
|
48
|
+
this.revokedAt = data.revoked_at ? new Date(data.revoked_at) : null;
|
|
53
49
|
this.createdAt = new Date(data.created_at);
|
|
54
50
|
this.updatedAt = new Date(data.updated_at);
|
|
55
51
|
}
|
|
@@ -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
|