@fonderie/client 0.22.0 → 0.24.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.
@@ -143,6 +143,7 @@ new AuthClient(http: HttpClient, tokens: TokenStore): AuthClient
143
143
  .mfa: MfaClient
144
144
  .setAccessToken(token: string | undefined): void
145
145
  .providers(): Promise<IApiResponse<IAuthProvidersResult>>
146
+ .unlinkOauth(provider: string): Promise<IApiResponse<null>>
146
147
  .register(input: IRegisterInput): Promise<IApiResponse<IRegisterResult>>
147
148
  .login(input: ILoginInput): Promise<IApiResponse<ILoginResult | IMfaRequiredResult>>
148
149
  .appleNative(input: IAppleNativeInput): Promise<IApiResponse<ILoginResult>>
@@ -261,6 +262,27 @@ new ConfigAdminClient(opts: IConfigAdminClientOptions): ConfigAdminClient
261
262
  .rollbackSecret(key: string, input: IRollbackInput, environment?: string | undefined): Promise<IApiResponse<ISecretEntry>>
262
263
  .revealSecret(key: string, environment?: string | undefined): Promise<IApiResponse<IRevealSecretResult>>
263
264
 
265
+ interface IAdminClientOptions {
266
+ baseUrl: string;
267
+ adminToken: string;
268
+ prefix?: string;
269
+ actor?: string;
270
+ }
271
+
272
+ interface IAdminLogQuery {
273
+ limit?: number;
274
+ before?: string;
275
+ }
276
+
277
+ new AdminClient(opts: IAdminClientOptions): AdminClient
278
+ .attention(): Promise<IApiResponse<IAdminAttention>>
279
+ .manifest(): Promise<IApiResponse<IAdminManifest>>
280
+ .doctor(): Promise<IApiResponse<IAdminDoctorReport>>
281
+ .config(): Promise<IApiResponse<IAdminConfigReport>>
282
+ .routes(): Promise<IApiResponse<IAdminRoutesReport>>
283
+ .tokens(): Promise<IApiResponse<IAdminTokensReport>>
284
+ .adminLog(query?: IAdminLogQuery): Promise<IApiResponse<IAdminLogPage>>
285
+
264
286
  interface ICourierAdminClientOptions {
265
287
  baseUrl: string;
266
288
  adminToken: string;
@@ -598,6 +620,122 @@ interface ICheckoutUrlResult {
598
620
  url: string;
599
621
  }
600
622
 
623
+ type AdminRouteGuard = 'admin' | 'probe' | 'app';
624
+
625
+ interface IAdminAttention {
626
+ generatedAt: string;
627
+ ok: boolean;
628
+ items: IAdminAttentionItem[];
629
+ }
630
+
631
+ interface IAdminAttentionItem {
632
+ source: string;
633
+ severity: 'error' | 'advice';
634
+ message: string;
635
+ }
636
+
637
+ interface IAdminCheckResult {
638
+ name: string;
639
+ module: string;
640
+ ok: boolean;
641
+ findings: string[];
642
+ skipped?: string;
643
+ durationMs: number;
644
+ }
645
+
646
+ interface IAdminConfigReport {
647
+ generatedAt: string;
648
+ readiness: IAdminReadiness;
649
+ modules: Array<{
650
+ name: string;
651
+ problems: IAdminReadinessProblem[];
652
+ }>;
653
+ env: Array<{
654
+ name: string;
655
+ set: boolean;
656
+ }>;
657
+ }
658
+
659
+ interface IAdminDoctorReport {
660
+ generatedAt: string;
661
+ ok: boolean;
662
+ checks: IAdminCheckResult[];
663
+ }
664
+
665
+ interface IAdminLogEntry {
666
+ id: string;
667
+ at: string;
668
+ actor: string;
669
+ method: string;
670
+ path: string;
671
+ route: string;
672
+ module: string;
673
+ status: number;
674
+ durationMs: number;
675
+ requestId: string | null;
676
+ clientIp: string | null;
677
+ }
678
+
679
+ interface IAdminLogPage {
680
+ entries: IAdminLogEntry[];
681
+ next: string | null;
682
+ }
683
+
684
+ interface IAdminManifest {
685
+ generatedAt: string;
686
+ env: string;
687
+ admin: {
688
+ version: string;
689
+ log: boolean;
690
+ };
691
+ modules: IAdminModuleEntry[];
692
+ readiness: IAdminReadiness;
693
+ routes: IAdminRouteEntry[];
694
+ }
695
+
696
+ interface IAdminModuleEntry {
697
+ name: string;
698
+ version: string | null;
699
+ readiness: IAdminReadiness;
700
+ describesAdmin: boolean;
701
+ }
702
+
703
+ interface IAdminReadiness {
704
+ ok: boolean;
705
+ problems: IAdminReadinessProblem[];
706
+ }
707
+
708
+ interface IAdminReadinessProblem {
709
+ module: string;
710
+ severity: 'error' | 'warning';
711
+ message: string;
712
+ }
713
+
714
+ interface IAdminRouteEntry {
715
+ method: string;
716
+ path: string;
717
+ module?: string;
718
+ }
719
+
720
+ interface IAdminRoutesReport {
721
+ generatedAt: string;
722
+ routes: Array<IAdminRouteEntry & {
723
+ guard: AdminRouteGuard;
724
+ }>;
725
+ }
726
+
727
+ interface IAdminTokensReport {
728
+ generatedAt: string;
729
+ admin: {
730
+ ok: boolean;
731
+ problems: IAdminReadinessProblem[];
732
+ };
733
+ legacy: Array<{
734
+ module: string;
735
+ set: boolean;
736
+ }>;
737
+ }
738
+
601
739
  interface IConfigEntry {
602
740
  key: string;
603
741
  value: unknown;
@@ -1055,6 +1193,8 @@ interface IUserDTO {
1055
1193
  isEmailVerified: boolean;
1056
1194
  isPhoneVerified: boolean;
1057
1195
  mfaEnabled: boolean;
1196
+ provider: string;
1197
+ hasPassword: boolean;
1058
1198
  suspended: boolean;
1059
1199
  whitelist: boolean;
1060
1200
  ipWhitelist: string[];
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AdminClient: () => AdminClient,
23
24
  AuditClient: () => AuditClient,
24
25
  AuthClient: () => AuthClient,
25
26
  BillingClient: () => BillingClient,
@@ -295,6 +296,20 @@ var AuthClient = class {
295
296
  path: "/auth/providers"
296
297
  });
297
298
  }
299
+ /**
300
+ * Disconnect the OAuth provider linked to the signed-in account.
301
+ *
302
+ * Refused with 409 PASSWORD_REQUIRED when the account has no password:
303
+ * removing the only credential is account deletion, not a settings toggle.
304
+ * Check `user.hasPassword` before offering the control so the user is asked
305
+ * to set a password first rather than shown an error they can't act on.
306
+ */
307
+ unlinkOauth(provider) {
308
+ return this.http.request({
309
+ method: "DELETE",
310
+ path: `/auth/oauth/${encodeURIComponent(provider)}`
311
+ });
312
+ }
298
313
  register(input) {
299
314
  return this.http.request({
300
315
  method: "POST",
@@ -1688,6 +1703,53 @@ var ConfigAdminClient = class {
1688
1703
  }
1689
1704
  };
1690
1705
 
1706
+ // src/modules/admin.ts
1707
+ var AdminClient = class {
1708
+ http;
1709
+ adminToken;
1710
+ prefix;
1711
+ actorHeaders;
1712
+ constructor(opts) {
1713
+ this.http = new HttpClient(opts.baseUrl);
1714
+ this.adminToken = opts.adminToken;
1715
+ this.prefix = (opts.prefix ?? "/_admin").replace(/\/+$/, "");
1716
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1717
+ }
1718
+ get(suffix) {
1719
+ return this.http.request({
1720
+ method: "GET",
1721
+ path: `${this.prefix}${suffix}`,
1722
+ token: this.adminToken,
1723
+ headers: this.actorHeaders
1724
+ });
1725
+ }
1726
+ attention() {
1727
+ return this.get("");
1728
+ }
1729
+ manifest() {
1730
+ return this.get("/manifest");
1731
+ }
1732
+ doctor() {
1733
+ return this.get("/doctor");
1734
+ }
1735
+ config() {
1736
+ return this.get("/config");
1737
+ }
1738
+ routes() {
1739
+ return this.get("/routes");
1740
+ }
1741
+ tokens() {
1742
+ return this.get("/access/tokens");
1743
+ }
1744
+ adminLog(query = {}) {
1745
+ const q = new URLSearchParams();
1746
+ if (query.limit) q.set("limit", String(query.limit));
1747
+ if (query.before) q.set("before", query.before);
1748
+ const qs = q.toString();
1749
+ return this.get(`/activity/admin-log${qs ? `?${qs}` : ""}`);
1750
+ }
1751
+ };
1752
+
1691
1753
  // src/modules/courier-admin.ts
1692
1754
  var CourierAdminClient = class {
1693
1755
  http;
@@ -1758,6 +1820,7 @@ function isMfaRequired(result) {
1758
1820
  }
1759
1821
  // Annotate the CommonJS export names for ESM import in node:
1760
1822
  0 && (module.exports = {
1823
+ AdminClient,
1761
1824
  AuditClient,
1762
1825
  AuthClient,
1763
1826
  BillingClient,