@fonderie/client 0.27.0 → 0.29.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.
@@ -283,6 +283,8 @@ new AdminClient(opts: IAdminClientOptions): AdminClient
283
283
  .routes(): Promise<IApiResponse<IAdminRoutesReport>>
284
284
  .tokens(): Promise<IApiResponse<IAdminTokensReport>>
285
285
  .adminLog(query?: IAdminLogQuery): Promise<IApiResponse<IAdminLogPage>>
286
+ .issueToken(input: IAdminIssueTokenInput): Promise<IApiResponse<IAdminIssuedToken>>
287
+ .revokeToken(id: string): Promise<IApiResponse<undefined>>
286
288
 
287
289
  interface IAuthAdminClientOptions {
288
290
  baseUrl: string;
@@ -328,6 +330,26 @@ new BillingAdminClient(opts: IBillingAdminClientOptions): BillingAdminClient
328
330
  .walletLedger(type: SubscriberType, id: string, query?: IAdminLedgerQuery): Promise<IApiResponse<IAdminWalletLedgerPage>>
329
331
  .grant(input: IAdminGrantInput): Promise<IApiResponse<unknown>>
330
332
 
333
+ interface IAuditAdminClientOptions {
334
+ baseUrl: string;
335
+ adminToken: string;
336
+ prefix?: string;
337
+ actor?: string;
338
+ }
339
+
340
+ interface IAdminAuditQuery {
341
+ workspaceId?: string;
342
+ type?: string;
343
+ actorId?: string;
344
+ from?: Date;
345
+ to?: Date;
346
+ limit?: number;
347
+ cursor?: string;
348
+ }
349
+
350
+ new AuditAdminClient(opts: IAuditAdminClientOptions): AuditAdminClient
351
+ .listAudit(query?: IAdminAuditQuery): Promise<IApiResponse<IAuditPageResult>>
352
+
331
353
  interface ICourierAdminClientOptions {
332
354
  baseUrl: string;
333
355
  adminToken: string;
@@ -780,6 +802,30 @@ interface IAdminTokensReport {
780
802
  module: string;
781
803
  set: boolean;
782
804
  }>;
805
+ issued: IAdminTokenRecord[] | null;
806
+ }
807
+
808
+ type AdminScope = 'read' | 'write' | 'secrets';
809
+
810
+ interface IAdminTokenRecord {
811
+ id: string;
812
+ name: string;
813
+ scopes: AdminScope[];
814
+ createdBy: string;
815
+ createdAt: string;
816
+ expiresAt: string | null;
817
+ revokedAt: string | null;
818
+ lastUsedAt: string | null;
819
+ }
820
+
821
+ interface IAdminIssueTokenInput {
822
+ name: string;
823
+ scopes: AdminScope[];
824
+ expiresInDays?: number;
825
+ }
826
+
827
+ interface IAdminIssuedToken extends IAdminTokenRecord {
828
+ token: string;
783
829
  }
784
830
 
785
831
  interface IAdminUserDTO extends IUserDTO {
package/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AdminClient: () => AdminClient,
24
+ AuditAdminClient: () => AuditAdminClient,
24
25
  AuditClient: () => AuditClient,
25
26
  AuthAdminClient: () => AuthAdminClient,
26
27
  AuthClient: () => AuthClient,
@@ -1752,11 +1753,15 @@ var AdminClient = class {
1752
1753
  this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1753
1754
  }
1754
1755
  get(suffix) {
1756
+ return this.call("GET", suffix);
1757
+ }
1758
+ call(method, suffix, body) {
1755
1759
  return this.http.request({
1756
- method: "GET",
1760
+ method,
1757
1761
  path: `${this.prefix}${suffix}`,
1758
1762
  token: this.adminToken,
1759
- headers: this.actorHeaders
1763
+ headers: this.actorHeaders,
1764
+ ...body !== void 0 ? { body } : {}
1760
1765
  });
1761
1766
  }
1762
1767
  attention() {
@@ -1784,6 +1789,14 @@ var AdminClient = class {
1784
1789
  const qs = q.toString();
1785
1790
  return this.get(`/activity/admin-log${qs ? `?${qs}` : ""}`);
1786
1791
  }
1792
+ // Root token only. The plaintext comes back once.
1793
+ issueToken(input) {
1794
+ return this.call("POST", "/access/tokens", input);
1795
+ }
1796
+ // Root token only.
1797
+ revokeToken(id) {
1798
+ return this.call("DELETE", `/access/tokens/${encodeURIComponent(id)}`);
1799
+ }
1787
1800
  };
1788
1801
 
1789
1802
  // src/modules/auth-admin.ts
@@ -1897,6 +1910,38 @@ var BillingAdminClient = class {
1897
1910
  }
1898
1911
  };
1899
1912
 
1913
+ // src/modules/audit-admin.ts
1914
+ var AuditAdminClient = class {
1915
+ http;
1916
+ adminToken;
1917
+ prefix;
1918
+ actorHeaders;
1919
+ constructor(opts) {
1920
+ this.http = new HttpClient(opts.baseUrl);
1921
+ this.adminToken = opts.adminToken;
1922
+ this.prefix = (opts.prefix ?? "/_admin").replace(/\/+$/, "");
1923
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1924
+ }
1925
+ // Every workspace unless one is named. Newest first, keyset-paged.
1926
+ listAudit(query = {}) {
1927
+ const q = new URLSearchParams();
1928
+ if (query.workspaceId) q.set("workspaceId", query.workspaceId);
1929
+ if (query.type) q.set("type", query.type);
1930
+ if (query.actorId) q.set("actorId", query.actorId);
1931
+ if (query.from) q.set("from", query.from.toISOString());
1932
+ if (query.to) q.set("to", query.to.toISOString());
1933
+ if (query.limit) q.set("limit", String(query.limit));
1934
+ if (query.cursor) q.set("cursor", query.cursor);
1935
+ const qs = q.toString();
1936
+ return this.http.request({
1937
+ method: "GET",
1938
+ path: `${this.prefix}/audit${qs ? `?${qs}` : ""}`,
1939
+ token: this.adminToken,
1940
+ headers: this.actorHeaders
1941
+ });
1942
+ }
1943
+ };
1944
+
1900
1945
  // src/modules/courier-admin.ts
1901
1946
  var CourierAdminClient = class {
1902
1947
  http;
@@ -1988,6 +2033,7 @@ function isMfaRequired(result) {
1988
2033
  // Annotate the CommonJS export names for ESM import in node:
1989
2034
  0 && (module.exports = {
1990
2035
  AdminClient,
2036
+ AuditAdminClient,
1991
2037
  AuditClient,
1992
2038
  AuthAdminClient,
1993
2039
  AuthClient,