@meowpanel/api 0.3.0 → 0.5.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.
Files changed (201) hide show
  1. package/esm/mod.d.ts +37 -16
  2. package/esm/mod.d.ts.map +1 -1
  3. package/esm/mod.js +25 -7
  4. package/esm/src/client.d.ts +48 -11
  5. package/esm/src/client.d.ts.map +1 -1
  6. package/esm/src/client.js +53 -12
  7. package/esm/src/http.d.ts +2 -2
  8. package/esm/src/http.d.ts.map +1 -1
  9. package/esm/src/http.js +5 -2
  10. package/esm/src/namespace.d.ts +1 -1
  11. package/esm/src/namespace.js +1 -1
  12. package/esm/src/resources/account.d.ts +50 -19
  13. package/esm/src/resources/account.d.ts.map +1 -1
  14. package/esm/src/resources/account.js +51 -13
  15. package/esm/src/resources/api-keys.d.ts +16 -24
  16. package/esm/src/resources/api-keys.d.ts.map +1 -1
  17. package/esm/src/resources/api-keys.js +16 -20
  18. package/esm/src/resources/auth.d.ts +70 -4
  19. package/esm/src/resources/auth.d.ts.map +1 -1
  20. package/esm/src/resources/auth.js +47 -4
  21. package/esm/src/resources/eggs.d.ts +261 -22
  22. package/esm/src/resources/eggs.d.ts.map +1 -1
  23. package/esm/src/resources/eggs.js +261 -25
  24. package/esm/src/resources/features.d.ts +35 -0
  25. package/esm/src/resources/features.d.ts.map +1 -0
  26. package/esm/src/resources/features.js +21 -0
  27. package/esm/src/resources/hosts.d.ts +151 -21
  28. package/esm/src/resources/hosts.d.ts.map +1 -1
  29. package/esm/src/resources/hosts.js +143 -10
  30. package/esm/src/resources/logs.d.ts +39 -0
  31. package/esm/src/resources/logs.d.ts.map +1 -0
  32. package/esm/src/resources/logs.js +38 -0
  33. package/esm/src/resources/nodes.d.ts +108 -33
  34. package/esm/src/resources/nodes.d.ts.map +1 -1
  35. package/esm/src/resources/nodes.js +116 -24
  36. package/esm/src/resources/permissions.d.ts +45 -0
  37. package/esm/src/resources/permissions.d.ts.map +1 -0
  38. package/esm/src/resources/permissions.js +26 -0
  39. package/esm/src/resources/request-logs.d.ts +91 -0
  40. package/esm/src/resources/request-logs.d.ts.map +1 -0
  41. package/esm/src/resources/request-logs.js +70 -0
  42. package/esm/src/resources/roles.d.ts +128 -0
  43. package/esm/src/resources/roles.d.ts.map +1 -0
  44. package/esm/src/resources/roles.js +142 -0
  45. package/esm/src/resources/server-groups.d.ts +141 -7
  46. package/esm/src/resources/server-groups.d.ts.map +1 -1
  47. package/esm/src/resources/server-groups.js +157 -8
  48. package/esm/src/resources/servers/activity.d.ts +50 -8
  49. package/esm/src/resources/servers/activity.d.ts.map +1 -1
  50. package/esm/src/resources/servers/activity.js +54 -13
  51. package/esm/src/resources/servers/allocations.d.ts +3 -3
  52. package/esm/src/resources/servers/allocations.d.ts.map +1 -1
  53. package/esm/src/resources/servers/allocations.js +7 -7
  54. package/esm/src/resources/servers/backups.d.ts +46 -0
  55. package/esm/src/resources/servers/backups.d.ts.map +1 -0
  56. package/esm/src/resources/servers/backups.js +43 -0
  57. package/esm/src/resources/servers/connection.d.ts +33 -13
  58. package/esm/src/resources/servers/connection.d.ts.map +1 -1
  59. package/esm/src/resources/servers/connection.js +32 -11
  60. package/esm/src/resources/servers/features.d.ts +81 -0
  61. package/esm/src/resources/servers/features.d.ts.map +1 -0
  62. package/esm/src/resources/servers/features.js +60 -0
  63. package/esm/src/resources/servers/files.d.ts +41 -53
  64. package/esm/src/resources/servers/files.d.ts.map +1 -1
  65. package/esm/src/resources/servers/files.js +74 -116
  66. package/esm/src/resources/servers/index.d.ts +46 -27
  67. package/esm/src/resources/servers/index.d.ts.map +1 -1
  68. package/esm/src/resources/servers/index.js +26 -12
  69. package/esm/src/resources/servers/jobs.d.ts +88 -0
  70. package/esm/src/resources/servers/jobs.d.ts.map +1 -0
  71. package/esm/src/resources/servers/jobs.js +115 -0
  72. package/esm/src/resources/servers/node-client.d.ts +33 -0
  73. package/esm/src/resources/servers/node-client.d.ts.map +1 -0
  74. package/esm/src/resources/servers/node-client.js +61 -0
  75. package/esm/src/resources/servers/profiles.d.ts +83 -18
  76. package/esm/src/resources/servers/profiles.d.ts.map +1 -1
  77. package/esm/src/resources/servers/profiles.js +78 -11
  78. package/esm/src/resources/servers/server.d.ts +13 -28
  79. package/esm/src/resources/servers/server.d.ts.map +1 -1
  80. package/esm/src/resources/servers/server.js +21 -37
  81. package/esm/src/resources/servers/sftp.d.ts +12 -19
  82. package/esm/src/resources/servers/sftp.d.ts.map +1 -1
  83. package/esm/src/resources/servers/sftp.js +10 -14
  84. package/esm/src/resources/servers/sub-users.d.ts +99 -0
  85. package/esm/src/resources/servers/sub-users.d.ts.map +1 -0
  86. package/esm/src/resources/servers/sub-users.js +94 -0
  87. package/esm/src/resources/servers/types.d.ts +30 -28
  88. package/esm/src/resources/servers/types.d.ts.map +1 -1
  89. package/esm/src/resources/systems.d.ts +124 -0
  90. package/esm/src/resources/systems.d.ts.map +1 -0
  91. package/esm/src/resources/systems.js +139 -0
  92. package/esm/src/resources/users.d.ts +330 -0
  93. package/esm/src/resources/users.d.ts.map +1 -0
  94. package/esm/src/resources/users.js +280 -0
  95. package/esm/src/types.d.ts +18 -1
  96. package/esm/src/types.d.ts.map +1 -1
  97. package/esm/src/types.js +11 -0
  98. package/package.json +1 -1
  99. package/script/mod.d.ts +37 -16
  100. package/script/mod.d.ts.map +1 -1
  101. package/script/mod.js +50 -5
  102. package/script/src/client.d.ts +48 -11
  103. package/script/src/client.d.ts.map +1 -1
  104. package/script/src/client.js +53 -12
  105. package/script/src/http.d.ts +2 -2
  106. package/script/src/http.d.ts.map +1 -1
  107. package/script/src/http.js +5 -2
  108. package/script/src/namespace.d.ts +1 -1
  109. package/script/src/namespace.js +1 -1
  110. package/script/src/resources/account.d.ts +50 -19
  111. package/script/src/resources/account.d.ts.map +1 -1
  112. package/script/src/resources/account.js +50 -12
  113. package/script/src/resources/api-keys.d.ts +16 -24
  114. package/script/src/resources/api-keys.d.ts.map +1 -1
  115. package/script/src/resources/api-keys.js +15 -19
  116. package/script/src/resources/auth.d.ts +70 -4
  117. package/script/src/resources/auth.d.ts.map +1 -1
  118. package/script/src/resources/auth.js +47 -4
  119. package/script/src/resources/eggs.d.ts +261 -22
  120. package/script/src/resources/eggs.d.ts.map +1 -1
  121. package/script/src/resources/eggs.js +267 -26
  122. package/script/src/resources/features.d.ts +35 -0
  123. package/script/src/resources/features.d.ts.map +1 -0
  124. package/script/src/resources/features.js +25 -0
  125. package/script/src/resources/hosts.d.ts +151 -21
  126. package/script/src/resources/hosts.d.ts.map +1 -1
  127. package/script/src/resources/hosts.js +144 -10
  128. package/script/src/resources/logs.d.ts +39 -0
  129. package/script/src/resources/logs.d.ts.map +1 -0
  130. package/script/src/resources/logs.js +42 -0
  131. package/script/src/resources/nodes.d.ts +108 -33
  132. package/script/src/resources/nodes.d.ts.map +1 -1
  133. package/script/src/resources/nodes.js +117 -24
  134. package/script/src/resources/permissions.d.ts +45 -0
  135. package/script/src/resources/permissions.d.ts.map +1 -0
  136. package/script/src/resources/permissions.js +31 -0
  137. package/script/src/resources/request-logs.d.ts +91 -0
  138. package/script/src/resources/request-logs.d.ts.map +1 -0
  139. package/script/src/resources/request-logs.js +75 -0
  140. package/script/src/resources/roles.d.ts +128 -0
  141. package/script/src/resources/roles.d.ts.map +1 -0
  142. package/script/src/resources/roles.js +148 -0
  143. package/script/src/resources/server-groups.d.ts +141 -7
  144. package/script/src/resources/server-groups.d.ts.map +1 -1
  145. package/script/src/resources/server-groups.js +158 -8
  146. package/script/src/resources/servers/activity.d.ts +50 -8
  147. package/script/src/resources/servers/activity.d.ts.map +1 -1
  148. package/script/src/resources/servers/activity.js +54 -12
  149. package/script/src/resources/servers/allocations.d.ts +3 -3
  150. package/script/src/resources/servers/allocations.d.ts.map +1 -1
  151. package/script/src/resources/servers/allocations.js +7 -7
  152. package/script/src/resources/servers/backups.d.ts +46 -0
  153. package/script/src/resources/servers/backups.d.ts.map +1 -0
  154. package/script/src/resources/servers/backups.js +47 -0
  155. package/script/src/resources/servers/connection.d.ts +33 -13
  156. package/script/src/resources/servers/connection.d.ts.map +1 -1
  157. package/script/src/resources/servers/connection.js +32 -11
  158. package/script/src/resources/servers/features.d.ts +81 -0
  159. package/script/src/resources/servers/features.d.ts.map +1 -0
  160. package/script/src/resources/servers/features.js +64 -0
  161. package/script/src/resources/servers/files.d.ts +41 -53
  162. package/script/src/resources/servers/files.d.ts.map +1 -1
  163. package/script/src/resources/servers/files.js +74 -116
  164. package/script/src/resources/servers/index.d.ts +46 -27
  165. package/script/src/resources/servers/index.d.ts.map +1 -1
  166. package/script/src/resources/servers/index.js +26 -12
  167. package/script/src/resources/servers/jobs.d.ts +88 -0
  168. package/script/src/resources/servers/jobs.d.ts.map +1 -0
  169. package/script/src/resources/servers/jobs.js +120 -0
  170. package/script/src/resources/servers/node-client.d.ts +33 -0
  171. package/script/src/resources/servers/node-client.d.ts.map +1 -0
  172. package/script/src/resources/servers/node-client.js +65 -0
  173. package/script/src/resources/servers/profiles.d.ts +83 -18
  174. package/script/src/resources/servers/profiles.d.ts.map +1 -1
  175. package/script/src/resources/servers/profiles.js +77 -10
  176. package/script/src/resources/servers/server.d.ts +13 -28
  177. package/script/src/resources/servers/server.d.ts.map +1 -1
  178. package/script/src/resources/servers/server.js +21 -37
  179. package/script/src/resources/servers/sftp.d.ts +12 -19
  180. package/script/src/resources/servers/sftp.d.ts.map +1 -1
  181. package/script/src/resources/servers/sftp.js +10 -14
  182. package/script/src/resources/servers/sub-users.d.ts +99 -0
  183. package/script/src/resources/servers/sub-users.d.ts.map +1 -0
  184. package/script/src/resources/servers/sub-users.js +99 -0
  185. package/script/src/resources/servers/types.d.ts +30 -28
  186. package/script/src/resources/servers/types.d.ts.map +1 -1
  187. package/script/src/resources/systems.d.ts +124 -0
  188. package/script/src/resources/systems.d.ts.map +1 -0
  189. package/script/src/resources/systems.js +145 -0
  190. package/script/src/resources/users.d.ts +330 -0
  191. package/script/src/resources/users.d.ts.map +1 -0
  192. package/script/src/resources/users.js +287 -0
  193. package/script/src/types.d.ts +18 -1
  194. package/script/src/types.d.ts.map +1 -1
  195. package/script/src/types.js +12 -0
  196. package/esm/src/resources/members.d.ts +0 -138
  197. package/esm/src/resources/members.d.ts.map +0 -1
  198. package/esm/src/resources/members.js +0 -122
  199. package/script/src/resources/members.d.ts +0 -138
  200. package/script/src/resources/members.d.ts.map +0 -1
  201. package/script/src/resources/members.js +0 -127
@@ -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 { MemberData } from './members.js';
6
- import { Member } from './members.js';
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
- owner?: MemberData;
14
- /** Only returned once, at creation time. */
15
- token?: string;
12
+ owner_id: string;
13
+ owner?: UserData;
16
14
  permissions?: string[];
17
- last_used_at?: ISODate | null;
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
- * > **Note:** The `token` field is only populated when the key is first created.
27
- * > It cannot be retrieved again after that. Store it securely.
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 of this API key. Always present as full object. */
39
- owner: Member | undefined;
40
- /**
41
- * The bearer token value.
42
- *
43
- * Only populated immediately after creation via {@link ApiKeysNamespace.create}.
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 last used to authenticate a request, or `null` if never used. */
50
- lastUsedAt: Date | null;
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,EAAY,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,8CAA8C;AAC9C,UAAU,UAAU;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,WA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;;;;;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 members_js_1 = require("./members.js");
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
- * > **Note:** The `token` field is only populated when the key is first created.
14
- * > It cannot be retrieved again after that. Store it securely.
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 of this API key. Always present as full object. */
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 last used to authenticate a request, or `null` if never used. */
37
- lastUsedAt;
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
- this.owner = data.owner ? new members_js_1.Member(data.owner) : undefined;
50
- this.token = data.token;
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.lastUsedAt = data.last_used_at ? new Date(data.last_used_at) : null;
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 { providers } = await api.auth.getMeta();
24
- * if (providers.email) console.log('Email login available');
25
- * if (providers.whmcs) console.log('WHMCS:', providers.whmcs.fields.display_name);
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;AAS7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IAEL,OAAO,CAAC,QAAQ,CAAC,IAAI;IADxC,gBAAgB;gBACoB,IAAI,EAAE,UAAU;IAEpD;;;;OAIG;IACI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;CAGnC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/src/resources/auth.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IG;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,16 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthResource = void 0;
4
+ const account_js_1 = require("./account.js");
4
5
  /**
5
- * Resource for authentication configuration.
6
+ * Resource for authentication configuration and login flows.
6
7
  *
7
8
  * Access via `api.auth`.
8
9
  *
10
+ * The flow: submit credentials ({@link login}) or redeem a code ({@link exchange}) to get an
11
+ * opaque session token, set it as the client token, then call {@link refresh} to obtain the
12
+ * short-lived access token used for all other requests.
13
+ *
9
14
  * @example
10
15
  * ```ts ignore
11
- * const { providers } = await api.auth.getMeta();
12
- * if (providers.email) console.log('Email login available');
13
- * if (providers.whmcs) console.log('WHMCS:', providers.whmcs.fields.display_name);
16
+ * const { token } = await api.auth.loginWithEmail('me@example.com', 'hunter2');
17
+ * api.setToken(token);
18
+ * const { accessToken } = await api.auth.refresh();
19
+ * api.setToken(accessToken);
14
20
  * ```
15
21
  */
16
22
  class AuthResource {
@@ -27,5 +33,42 @@ class AuthResource {
27
33
  getMeta() {
28
34
  return this.http.get('/auth');
29
35
  }
36
+ /**
37
+ * Submit credentials to a login provider.
38
+ *
39
+ * @param provider The provider id, e.g. `"email"`.
40
+ * @param credentials The provider's fields (for `email`: `{ email, password }`).
41
+ */
42
+ login(provider, credentials) {
43
+ return this.http.post(`/auth/${encodeURIComponent(provider)}`, credentials);
44
+ }
45
+ /** Log in with email and password. */
46
+ loginWithEmail(email, password) {
47
+ return this.login('email', { email, password });
48
+ }
49
+ /**
50
+ * Redeem a single-use exchange code (e.g. from a WHMCS SSO redirect) for a session token.
51
+ *
52
+ * @param code The exchange code.
53
+ */
54
+ exchange(code) {
55
+ return this.http.post('/auth/exchange', { code });
56
+ }
57
+ /**
58
+ * Exchange the current (opaque session) token for a short-lived access token.
59
+ *
60
+ * Call this with the session token set as the client's bearer token.
61
+ *
62
+ * @param opts `includeAccount` also returns the authenticated account.
63
+ */
64
+ async refresh(opts = {}) {
65
+ const raw = await this.http.post('/auth/refresh', undefined, opts.includeAccount ? { params: { include: 'account' } } : {});
66
+ return {
67
+ tokenType: raw.token_type,
68
+ expiresInSeconds: raw.expires_in_seconds,
69
+ accessToken: raw.access_token,
70
+ account: raw.account ? account_js_1.Account.create(raw.account, this.http) : undefined,
71
+ };
72
+ }
30
73
  }
31
74
  exports.AuthResource = AuthResource;