@corvushold/guard-sdk 0.7.0 → 0.8.1

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/dist/index.cjs CHANGED
@@ -231,11 +231,11 @@ var HttpClient = class {
231
231
  } catch {
232
232
  }
233
233
  if (status === 429) {
234
- throw buildRateLimitError({ status, message: body && body.message || "Too Many Requests", requestId, headers: res2.headers, raw: body });
234
+ throw buildRateLimitError({ status, message: body && (body.message || body.error) || "Too Many Requests", requestId, headers: res2.headers, raw: body });
235
235
  }
236
236
  throw new ApiError({
237
237
  status,
238
- message: body && body.message || res2.statusText || `HTTP ${status}`,
238
+ message: body && (body.message || body.error) || res2.statusText || `HTTP ${status}`,
239
239
  code: body && body.code ? String(body.code) : void 0,
240
240
  requestId,
241
241
  headers: toHeadersMap(res2.headers),
@@ -279,7 +279,7 @@ var HttpClient = class {
279
279
 
280
280
  // package.json
281
281
  var package_default = {
282
- version: "0.7.0"};
282
+ version: "0.8.1"};
283
283
 
284
284
  // src/client.ts
285
285
  function isTenantSelectionRequired(data) {
@@ -357,7 +357,7 @@ var GuardClient = class {
357
357
  }
358
358
  // Auth: Password login -> returns tokens (200) or MFA challenge (202)
359
359
  async passwordLogin(body) {
360
- const res = await this.request("/v1/auth/password/login", {
360
+ const res = await this.request("/api/v1/auth/password/login", {
361
361
  method: "POST",
362
362
  body: JSON.stringify({ ...body, tenant_id: body.tenant_id ?? this.tenantId })
363
363
  });
@@ -366,7 +366,7 @@ var GuardClient = class {
366
366
  }
367
367
  // Auth: Password signup -> returns tokens (201 Created)
368
368
  async passwordSignup(body) {
369
- const res = await this.request("/v1/auth/password/signup", {
369
+ const res = await this.request("/api/v1/auth/password/signup", {
370
370
  method: "POST",
371
371
  body: JSON.stringify({ ...body, tenant_id: body.tenant_id ?? this.tenantId })
372
372
  });
@@ -375,7 +375,7 @@ var GuardClient = class {
375
375
  }
376
376
  // Auth: Verify MFA challenge -> tokens
377
377
  async mfaVerify(body) {
378
- const res = await this.request("/v1/auth/mfa/verify", {
378
+ const res = await this.request("/api/v1/auth/mfa/verify", {
379
379
  method: "POST",
380
380
  body: JSON.stringify(body)
381
381
  });
@@ -386,7 +386,7 @@ var GuardClient = class {
386
386
  async refresh(body) {
387
387
  let refreshToken = body?.refresh_token ?? null;
388
388
  if (!refreshToken) refreshToken = await Promise.resolve(this.storage.getRefreshToken()) ?? null;
389
- const res = await this.request("/v1/auth/refresh", {
389
+ const res = await this.request("/api/v1/auth/refresh", {
390
390
  method: "POST",
391
391
  body: JSON.stringify({ refresh_token: refreshToken })
392
392
  });
@@ -396,7 +396,7 @@ var GuardClient = class {
396
396
  // Auth: Logout (revoke refresh token) -> 204
397
397
  async logout(body) {
398
398
  const b = body ?? {};
399
- const res = await this.request("/v1/auth/logout", {
399
+ const res = await this.request("/api/v1/auth/logout", {
400
400
  method: "POST",
401
401
  body: JSON.stringify(b)
402
402
  });
@@ -407,14 +407,14 @@ var GuardClient = class {
407
407
  }
408
408
  // Auth: Current user profile
409
409
  async me() {
410
- return this.request("/v1/auth/me", { method: "GET" });
410
+ return this.request("/api/v1/auth/me", { method: "GET" });
411
411
  }
412
412
  // Auth: Email discovery (progressive login)
413
413
  async emailDiscover(body) {
414
414
  const headers = {};
415
415
  const tid = body.tenant_id ?? this.tenantId;
416
416
  if (tid) headers["X-Tenant-ID"] = String(tid);
417
- return this.request(`/v1/auth/email/discover`, {
417
+ return this.request(`/api/v1/auth/email/discover`, {
418
418
  method: "POST",
419
419
  headers,
420
420
  body: JSON.stringify({ email: body.email })
@@ -424,36 +424,36 @@ var GuardClient = class {
424
424
  async getLoginOptions(params) {
425
425
  const tid = params?.tenant_id ?? this.tenantId;
426
426
  const qs = this.buildQuery({ email: params?.email, tenant_id: tid });
427
- return this.request(`/v1/auth/login-options${qs}`, { method: "GET" });
427
+ return this.request(`/api/v1/auth/login-options${qs}`, { method: "GET" });
428
428
  }
429
429
  // --- MFA self-service ---
430
430
  async mfaStartTotp() {
431
- return this.request("/v1/auth/mfa/totp/start", { method: "POST" });
431
+ return this.request("/api/v1/auth/mfa/totp/start", { method: "POST" });
432
432
  }
433
433
  async mfaActivateTotp(body) {
434
- return this.request("/v1/auth/mfa/totp/activate", { method: "POST", body: JSON.stringify(body) });
434
+ return this.request("/api/v1/auth/mfa/totp/activate", { method: "POST", body: JSON.stringify(body) });
435
435
  }
436
436
  async mfaDisableTotp() {
437
- return this.request("/v1/auth/mfa/totp/disable", { method: "POST" });
437
+ return this.request("/api/v1/auth/mfa/totp/disable", { method: "POST" });
438
438
  }
439
439
  async mfaGenerateBackupCodes(body = {}) {
440
- return this.request("/v1/auth/mfa/backup/generate", { method: "POST", body: JSON.stringify({ count: body.count ?? 5 }) });
440
+ return this.request("/api/v1/auth/mfa/backup/generate", { method: "POST", body: JSON.stringify({ count: body.count ?? 5 }) });
441
441
  }
442
442
  async mfaCountBackupCodes() {
443
- return this.request("/v1/auth/mfa/backup/count", { method: "GET" });
443
+ return this.request("/api/v1/auth/mfa/backup/count", { method: "GET" });
444
444
  }
445
445
  // Tenants: Discover tenants for a given email (used by login tenant selection)
446
446
  async discoverTenants(params) {
447
447
  const qs = this.buildQuery({ email: params.email });
448
- return this.request(`/v1/auth/tenants${qs}`, { method: "GET" });
448
+ return this.request(`/api/v1/auth/tenants${qs}`, { method: "GET" });
449
449
  }
450
450
  // Tenants: Create
451
451
  async createTenant(body) {
452
- return this.request(`/tenants`, { method: "POST", body: JSON.stringify({ name: body.name }) });
452
+ return this.request(`/api/v1/tenants`, { method: "POST", body: JSON.stringify({ name: body.name }) });
453
453
  }
454
454
  // Tenants: Get by ID
455
455
  async getTenant(id) {
456
- return this.request(`/tenants/${encodeURIComponent(id)}`, { method: "GET" });
456
+ return this.request(`/api/v1/tenants/${encodeURIComponent(id)}`, { method: "GET" });
457
457
  }
458
458
  // Tenants: List (admin)
459
459
  async listTenants(params = {}) {
@@ -463,18 +463,18 @@ var GuardClient = class {
463
463
  page_size: params.page_size,
464
464
  active: typeof params.active === "boolean" ? params.active ? 1 : 0 : params.active
465
465
  });
466
- return this.request(`/tenants${qs}`, { method: "GET" });
466
+ return this.request(`/api/v1/tenants${qs}`, { method: "GET" });
467
467
  }
468
468
  // Auth: Introspect token (from header or body)
469
469
  async introspect(body) {
470
- return this.request("/v1/auth/introspect", {
470
+ return this.request("/api/v1/auth/introspect", {
471
471
  method: "POST",
472
472
  body: JSON.stringify(body ?? {})
473
473
  });
474
474
  }
475
475
  // Auth: Magic link send
476
476
  async magicSend(body) {
477
- return this.request("/v1/auth/magic/send", {
477
+ return this.request("/api/v1/auth/magic/send", {
478
478
  method: "POST",
479
479
  body: JSON.stringify(body)
480
480
  });
@@ -482,7 +482,7 @@ var GuardClient = class {
482
482
  // Auth: Magic verify (token in query preferred)
483
483
  async magicVerify(params = {}, body) {
484
484
  const qs = this.buildQuery(params);
485
- const res = await this.request(`/v1/auth/magic/verify${qs}`, {
485
+ const res = await this.request(`/api/v1/auth/magic/verify${qs}`, {
486
486
  method: "GET",
487
487
  // Some servers accept body on GET per spec; include if provided
488
488
  ...body ? { body: JSON.stringify(body) } : {}
@@ -492,28 +492,28 @@ var GuardClient = class {
492
492
  }
493
493
  // Auth: Request password reset -> 202 (always, to prevent email enumeration)
494
494
  async passwordResetRequest(body) {
495
- return this.request("/v1/auth/password/reset/request", {
495
+ return this.request("/api/v1/auth/password/reset/request", {
496
496
  method: "POST",
497
497
  body: JSON.stringify({ ...body, tenant_id: body.tenant_id ?? this.tenantId })
498
498
  });
499
499
  }
500
500
  // Auth: Confirm password reset -> 200 on success
501
501
  async passwordResetConfirm(body) {
502
- return this.request("/v1/auth/password/reset/confirm", {
502
+ return this.request("/api/v1/auth/password/reset/confirm", {
503
503
  method: "POST",
504
504
  body: JSON.stringify({ ...body, tenant_id: body.tenant_id ?? this.tenantId })
505
505
  });
506
506
  }
507
507
  // Auth: Change password (requires auth) -> 200 on success
508
508
  async changePassword(body) {
509
- return this.request("/v1/auth/password/change", {
509
+ return this.request("/api/v1/auth/password/change", {
510
510
  method: "POST",
511
511
  body: JSON.stringify(body)
512
512
  });
513
513
  }
514
514
  // Auth: Update profile (first/last name) -> 200 on success
515
515
  async updateProfile(body) {
516
- return this.request("/v1/auth/profile", {
516
+ return this.request("/api/v1/auth/profile", {
517
517
  method: "PATCH",
518
518
  body: JSON.stringify(body)
519
519
  });
@@ -522,37 +522,37 @@ var GuardClient = class {
522
522
  async listUsers(params = {}) {
523
523
  const tenant = params.tenant_id ?? this.tenantId;
524
524
  const qs = this.buildQuery({ tenant_id: tenant });
525
- return this.request(`/v1/auth/admin/users${qs}`, { method: "GET" });
525
+ return this.request(`/api/v1/auth/admin/users${qs}`, { method: "GET" });
526
526
  }
527
527
  // Admin: Update user names
528
528
  async updateUserNames(id, body) {
529
529
  const payload = {};
530
530
  if (typeof body?.first_name === "string") payload.first_name = body.first_name;
531
531
  if (typeof body?.last_name === "string") payload.last_name = body.last_name;
532
- return this.request(`/v1/auth/admin/users/${encodeURIComponent(id)}`, {
532
+ return this.request(`/api/v1/auth/admin/users/${encodeURIComponent(id)}`, {
533
533
  method: "PATCH",
534
534
  body: JSON.stringify(payload)
535
535
  });
536
536
  }
537
537
  // Admin: Block user
538
538
  async blockUser(id) {
539
- return this.request(`/v1/auth/admin/users/${encodeURIComponent(id)}/block`, { method: "POST" });
539
+ return this.request(`/api/v1/auth/admin/users/${encodeURIComponent(id)}/block`, { method: "POST" });
540
540
  }
541
541
  // Admin: Unblock user
542
542
  async unblockUser(id) {
543
- return this.request(`/v1/auth/admin/users/${encodeURIComponent(id)}/unblock`, { method: "POST" });
543
+ return this.request(`/api/v1/auth/admin/users/${encodeURIComponent(id)}/unblock`, { method: "POST" });
544
544
  }
545
545
  // Admin: Verify user email (set email_verified=true)
546
546
  async verifyUserEmail(id) {
547
- return this.request(`/v1/auth/admin/users/${encodeURIComponent(id)}/verify-email`, { method: "POST" });
547
+ return this.request(`/api/v1/auth/admin/users/${encodeURIComponent(id)}/verify-email`, { method: "POST" });
548
548
  }
549
549
  // Admin: Unverify user email (set email_verified=false)
550
550
  async unverifyUserEmail(id) {
551
- return this.request(`/v1/auth/admin/users/${encodeURIComponent(id)}/unverify-email`, { method: "POST" });
551
+ return this.request(`/api/v1/auth/admin/users/${encodeURIComponent(id)}/unverify-email`, { method: "POST" });
552
552
  }
553
553
  // Sessions: List sessions. When includeAll=false, filter to active (non-revoked, not expired) client-side to match example app UX.
554
554
  async listSessions(options = {}) {
555
- const res = await this.request("/v1/auth/sessions", { method: "GET", cache: "no-store" });
555
+ const res = await this.request("/api/v1/auth/sessions", { method: "GET", cache: "no-store" });
556
556
  if (res.meta.status >= 200 && res.meta.status < 300) {
557
557
  const includeAll = !!options.includeAll;
558
558
  const sessions = Array.isArray(res.data?.sessions) ? res.data.sessions : [];
@@ -570,17 +570,17 @@ var GuardClient = class {
570
570
  }
571
571
  // Sessions: Revoke session
572
572
  async revokeSession(id) {
573
- return this.request(`/v1/auth/sessions/${encodeURIComponent(id)}/revoke`, { method: "POST" });
573
+ return this.request(`/api/v1/auth/sessions/${encodeURIComponent(id)}/revoke`, { method: "POST" });
574
574
  }
575
575
  // Tenants: Get settings
576
576
  async getTenantSettings(tenantId) {
577
577
  const id = tenantId ?? this.tenantId;
578
578
  if (!id) throw new Error("tenantId is required");
579
- return this.request(`/v1/tenants/${encodeURIComponent(id)}/settings`, { method: "GET" });
579
+ return this.request(`/api/v1/tenants/${encodeURIComponent(id)}/settings`, { method: "GET" });
580
580
  }
581
581
  // Tenants: Update settings
582
582
  async updateTenantSettings(tenantId, settings) {
583
- return this.request(`/v1/tenants/${encodeURIComponent(tenantId)}/settings`, {
583
+ return this.request(`/api/v1/tenants/${encodeURIComponent(tenantId)}/settings`, {
584
584
  method: "PUT",
585
585
  body: JSON.stringify(settings ?? {})
586
586
  });
@@ -608,7 +608,7 @@ var GuardClient = class {
608
608
  force_authn: params.force_authn
609
609
  });
610
610
  const res = await this.http.requestRaw(
611
- `/auth/sso/t/${encodeURIComponent(tenant)}/${encodeURIComponent(providerSlug)}/login${qs}`,
611
+ `/api/v1/auth/sso/t/${encodeURIComponent(tenant)}/${encodeURIComponent(providerSlug)}/login${qs}`,
612
612
  { method: "GET", redirect: "manual" }
613
613
  );
614
614
  const loc = res.headers.get("location");
@@ -645,7 +645,7 @@ var GuardClient = class {
645
645
  if (!tenant) throw new Error("tenant_id is required for SSO callback");
646
646
  const qs = this.buildQuery({ code: params.code, state: params.state });
647
647
  const res = await this.request(
648
- `/auth/sso/t/${encodeURIComponent(tenant)}/${encodeURIComponent(providerSlug)}/callback${qs}`,
648
+ `/api/v1/auth/sso/t/${encodeURIComponent(tenant)}/${encodeURIComponent(providerSlug)}/callback${qs}`,
649
649
  { method: "GET" }
650
650
  );
651
651
  if (res.meta.status === 200) this.persistTokensFrom(res.data);
@@ -698,20 +698,20 @@ var GuardClient = class {
698
698
  async getSsoOrganizationPortalLink(provider, params) {
699
699
  const tenant = params.tenant_id ?? this.tenantId;
700
700
  if (!tenant) throw new Error("tenant_id is required");
701
- if (!params?.organization_id) throw new Error("organization_id is required");
701
+ if (provider === "workos" && !params?.organization_id) throw new Error("organization_id is required");
702
702
  const qs = this.buildQuery({
703
703
  tenant_id: tenant,
704
704
  organization_id: params.organization_id,
705
705
  intent: params.intent
706
706
  });
707
- return this.request(`/v1/auth/sso/${provider}/portal-link${qs}`, { method: "GET" });
707
+ return this.request(`/api/v1/auth/sso/${provider}/portal-link${qs}`, { method: "GET" });
708
708
  }
709
709
  // SSO: Portal token session exchange (public, portal-token gated)
710
710
  async ssoPortalSession(token) {
711
711
  if (!token || typeof token !== "string") {
712
712
  throw new Error("token is required");
713
713
  }
714
- return this.request("/v1/sso/portal/session", {
714
+ return this.request("/api/v1/sso/portal/session", {
715
715
  method: "POST",
716
716
  body: JSON.stringify({ token })
717
717
  });
@@ -722,7 +722,7 @@ var GuardClient = class {
722
722
  throw new Error("token is required");
723
723
  }
724
724
  const headers = { "X-Portal-Token": token };
725
- return this.request("/v1/sso/portal/provider", {
725
+ return this.request("/api/v1/sso/portal/provider", {
726
726
  method: "GET",
727
727
  headers
728
728
  });
@@ -764,37 +764,37 @@ var GuardClient = class {
764
764
  async ssoListProviders(params = {}) {
765
765
  const tenant = params.tenant_id ?? this.tenantId;
766
766
  const qs = this.buildQuery({ tenant_id: tenant });
767
- return this.request(`/v1/sso/providers${qs}`, { method: "GET" });
767
+ return this.request(`/api/v1/sso/providers${qs}`, { method: "GET" });
768
768
  }
769
769
  // Create a new SSO provider
770
770
  async ssoCreateProvider(body) {
771
- return this.request("/v1/sso/providers", {
771
+ return this.request("/api/v1/sso/providers", {
772
772
  method: "POST",
773
773
  body: JSON.stringify(body)
774
774
  });
775
775
  }
776
776
  // Get a specific SSO provider by ID
777
777
  async ssoGetProvider(id) {
778
- return this.request(`/v1/sso/providers/${encodeURIComponent(id)}`, {
778
+ return this.request(`/api/v1/sso/providers/${encodeURIComponent(id)}`, {
779
779
  method: "GET"
780
780
  });
781
781
  }
782
782
  // Update an existing SSO provider
783
783
  async ssoUpdateProvider(id, body) {
784
- return this.request(`/v1/sso/providers/${encodeURIComponent(id)}`, {
784
+ return this.request(`/api/v1/sso/providers/${encodeURIComponent(id)}`, {
785
785
  method: "PUT",
786
786
  body: JSON.stringify(body)
787
787
  });
788
788
  }
789
789
  // Delete an SSO provider
790
790
  async ssoDeleteProvider(id) {
791
- return this.request(`/v1/sso/providers/${encodeURIComponent(id)}`, {
791
+ return this.request(`/api/v1/sso/providers/${encodeURIComponent(id)}`, {
792
792
  method: "DELETE"
793
793
  });
794
794
  }
795
795
  // Test SSO provider configuration
796
796
  async ssoTestProvider(id) {
797
- return this.request(`/v1/sso/providers/${encodeURIComponent(id)}/test`, {
797
+ return this.request(`/api/v1/sso/providers/${encodeURIComponent(id)}/test`, {
798
798
  method: "POST"
799
799
  });
800
800
  }
@@ -821,78 +821,78 @@ var GuardClient = class {
821
821
  const params = { slug };
822
822
  if (tenant) params.tenant_id = tenant;
823
823
  const qs = this.buildQuery(params);
824
- return this.request(`/v1/sso/sp-info${qs}`, { method: "GET" });
824
+ return this.request(`/api/v1/sso/sp-info${qs}`, { method: "GET" });
825
825
  }
826
826
  // ==============================
827
827
  // RBAC v2 (Admin-only endpoints)
828
828
  // ==============================
829
829
  // RBAC: List all permissions (admin-only)
830
830
  async rbacListPermissions() {
831
- return this.request("/v1/auth/admin/rbac/permissions", { method: "GET" });
831
+ return this.request("/api/v1/auth/admin/rbac/permissions", { method: "GET" });
832
832
  }
833
833
  // RBAC: List roles for a tenant
834
834
  async rbacListRoles(params = {}) {
835
835
  const tenant = params.tenant_id ?? this.tenantId;
836
836
  if (!tenant) throw new Error("tenant_id is required");
837
837
  const qs = this.buildQuery({ tenant_id: tenant });
838
- return this.request(`/v1/auth/admin/rbac/roles${qs}`, { method: "GET" });
838
+ return this.request(`/api/v1/auth/admin/rbac/roles${qs}`, { method: "GET" });
839
839
  }
840
840
  // RBAC: Create role
841
841
  async rbacCreateRole(body) {
842
842
  const tenant = body.tenant_id ?? this.tenantId;
843
843
  if (!tenant) throw new Error("tenant_id is required");
844
844
  const payload = { tenant_id: tenant, name: body.name, description: body.description };
845
- return this.request("/v1/auth/admin/rbac/roles", { method: "POST", body: JSON.stringify(payload) });
845
+ return this.request("/api/v1/auth/admin/rbac/roles", { method: "POST", body: JSON.stringify(payload) });
846
846
  }
847
847
  // RBAC: Update role
848
848
  async rbacUpdateRole(id, body) {
849
849
  const tenant = body.tenant_id ?? this.tenantId;
850
850
  if (!tenant) throw new Error("tenant_id is required");
851
851
  const payload = { tenant_id: tenant, name: body.name, description: body.description };
852
- return this.request(`/v1/auth/admin/rbac/roles/${encodeURIComponent(id)}`, { method: "PATCH", body: JSON.stringify(payload) });
852
+ return this.request(`/api/v1/auth/admin/rbac/roles/${encodeURIComponent(id)}`, { method: "PATCH", body: JSON.stringify(payload) });
853
853
  }
854
854
  // RBAC: Delete role
855
855
  async rbacDeleteRole(id, params = {}) {
856
856
  const tenant = params.tenant_id ?? this.tenantId;
857
857
  if (!tenant) throw new Error("tenant_id is required");
858
858
  const qs = this.buildQuery({ tenant_id: tenant });
859
- return this.request(`/v1/auth/admin/rbac/roles/${encodeURIComponent(id)}${qs}`, { method: "DELETE" });
859
+ return this.request(`/api/v1/auth/admin/rbac/roles/${encodeURIComponent(id)}${qs}`, { method: "DELETE" });
860
860
  }
861
861
  // RBAC: List user roles
862
862
  async rbacListUserRoles(userId, params = {}) {
863
863
  const tenant = params.tenant_id ?? this.tenantId;
864
864
  if (!tenant) throw new Error("tenant_id is required");
865
865
  const qs = this.buildQuery({ tenant_id: tenant });
866
- return this.request(`/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/roles${qs}`, { method: "GET" });
866
+ return this.request(`/api/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/roles${qs}`, { method: "GET" });
867
867
  }
868
868
  // RBAC: Add user role
869
869
  async rbacAddUserRole(userId, body) {
870
870
  const tenant = body.tenant_id ?? this.tenantId;
871
871
  if (!tenant) throw new Error("tenant_id is required");
872
872
  const payload = { tenant_id: tenant, role_id: body.role_id };
873
- return this.request(`/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/roles`, { method: "POST", body: JSON.stringify(payload) });
873
+ return this.request(`/api/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/roles`, { method: "POST", body: JSON.stringify(payload) });
874
874
  }
875
875
  // RBAC: Remove user role
876
876
  async rbacRemoveUserRole(userId, body) {
877
877
  const tenant = body.tenant_id ?? this.tenantId;
878
878
  if (!tenant) throw new Error("tenant_id is required");
879
879
  const payload = { tenant_id: tenant, role_id: body.role_id };
880
- return this.request(`/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/roles`, { method: "DELETE", body: JSON.stringify(payload) });
880
+ return this.request(`/api/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/roles`, { method: "DELETE", body: JSON.stringify(payload) });
881
881
  }
882
882
  // RBAC: Upsert role permission
883
883
  async rbacUpsertRolePermission(roleId, body) {
884
- return this.request(`/v1/auth/admin/rbac/roles/${encodeURIComponent(roleId)}/permissions`, { method: "POST", body: JSON.stringify(body) });
884
+ return this.request(`/api/v1/auth/admin/rbac/roles/${encodeURIComponent(roleId)}/permissions`, { method: "POST", body: JSON.stringify(body) });
885
885
  }
886
886
  // RBAC: Delete role permission
887
887
  async rbacDeleteRolePermission(roleId, body) {
888
- return this.request(`/v1/auth/admin/rbac/roles/${encodeURIComponent(roleId)}/permissions`, { method: "DELETE", body: JSON.stringify(body) });
888
+ return this.request(`/api/v1/auth/admin/rbac/roles/${encodeURIComponent(roleId)}/permissions`, { method: "DELETE", body: JSON.stringify(body) });
889
889
  }
890
890
  // RBAC: Resolve user permissions
891
891
  async rbacResolveUserPermissions(userId, params) {
892
892
  const tenant = params?.tenant_id ?? this.tenantId;
893
893
  if (!tenant) throw new Error("tenant_id is required");
894
894
  const qs = this.buildQuery({ tenant_id: tenant });
895
- return this.request(`/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/permissions/resolve${qs}`, { method: "GET" });
895
+ return this.request(`/api/v1/auth/admin/rbac/users/${encodeURIComponent(userId)}/permissions/resolve${qs}`, { method: "GET" });
896
896
  }
897
897
  // ==============================
898
898
  // FGA (Admin-only endpoints)
@@ -902,45 +902,45 @@ var GuardClient = class {
902
902
  const tenant = params?.tenant_id ?? this.tenantId;
903
903
  if (!tenant) throw new Error("tenant_id is required");
904
904
  const qs = this.buildQuery({ tenant_id: tenant });
905
- return this.request(`/v1/auth/admin/fga/groups${qs}`, { method: "GET" });
905
+ return this.request(`/api/v1/auth/admin/fga/groups${qs}`, { method: "GET" });
906
906
  }
907
907
  // Groups: create
908
908
  async fgaCreateGroup(body) {
909
909
  const tenant = body?.tenant_id ?? this.tenantId;
910
910
  if (!tenant) throw new Error("tenant_id is required");
911
911
  const payload = { tenant_id: tenant, name: body.name, description: body?.description ?? null };
912
- return this.request(`/v1/auth/admin/fga/groups`, { method: "POST", body: JSON.stringify(payload) });
912
+ return this.request(`/api/v1/auth/admin/fga/groups`, { method: "POST", body: JSON.stringify(payload) });
913
913
  }
914
914
  // Groups: delete
915
915
  async fgaDeleteGroup(id, params) {
916
916
  const tenant = params?.tenant_id ?? this.tenantId;
917
917
  if (!tenant) throw new Error("tenant_id is required");
918
918
  const qs = this.buildQuery({ tenant_id: tenant });
919
- return this.request(`/v1/auth/admin/fga/groups/${encodeURIComponent(id)}${qs}`, { method: "DELETE" });
919
+ return this.request(`/api/v1/auth/admin/fga/groups/${encodeURIComponent(id)}${qs}`, { method: "DELETE" });
920
920
  }
921
921
  // Group membership: add
922
922
  async fgaAddGroupMember(groupId, body) {
923
923
  const payload = { user_id: body.user_id };
924
- return this.request(`/v1/auth/admin/fga/groups/${encodeURIComponent(groupId)}/members`, { method: "POST", body: JSON.stringify(payload) });
924
+ return this.request(`/api/v1/auth/admin/fga/groups/${encodeURIComponent(groupId)}/members`, { method: "POST", body: JSON.stringify(payload) });
925
925
  }
926
926
  // Group membership: remove
927
927
  async fgaRemoveGroupMember(groupId, body) {
928
928
  const payload = { user_id: body.user_id };
929
- return this.request(`/v1/auth/admin/fga/groups/${encodeURIComponent(groupId)}/members`, { method: "DELETE", body: JSON.stringify(payload) });
929
+ return this.request(`/api/v1/auth/admin/fga/groups/${encodeURIComponent(groupId)}/members`, { method: "DELETE", body: JSON.stringify(payload) });
930
930
  }
931
931
  // ACL tuples: create
932
932
  async fgaCreateAclTuple(body) {
933
933
  const tenant = body?.tenant_id ?? this.tenantId;
934
934
  if (!tenant) throw new Error("tenant_id is required");
935
935
  const payload = { ...body, tenant_id: tenant };
936
- return this.request(`/v1/auth/admin/fga/acl/tuples`, { method: "POST", body: JSON.stringify(payload) });
936
+ return this.request(`/api/v1/auth/admin/fga/acl/tuples`, { method: "POST", body: JSON.stringify(payload) });
937
937
  }
938
938
  // ACL tuples: delete
939
939
  async fgaDeleteAclTuple(body) {
940
940
  const tenant = body?.tenant_id ?? this.tenantId;
941
941
  if (!tenant) throw new Error("tenant_id is required");
942
942
  const payload = { ...body, tenant_id: tenant };
943
- return this.request(`/v1/auth/admin/fga/acl/tuples`, { method: "DELETE", body: JSON.stringify(payload) });
943
+ return this.request(`/api/v1/auth/admin/fga/acl/tuples`, { method: "DELETE", body: JSON.stringify(payload) });
944
944
  }
945
945
  // ==============================
946
946
  // OAuth2 Discovery (RFC 8414)