@drmhse/sso-sdk 0.2.4 → 0.2.6

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.d.mts CHANGED
@@ -263,6 +263,68 @@ interface RefreshTokenResponse {
263
263
  refresh_token: string;
264
264
  expires_in: number;
265
265
  }
266
+ /**
267
+ * Registration request payload
268
+ */
269
+ interface RegisterRequest {
270
+ email: string;
271
+ password: string;
272
+ org_slug?: string;
273
+ }
274
+ /**
275
+ * Registration response
276
+ */
277
+ interface RegisterResponse {
278
+ message: string;
279
+ }
280
+ /**
281
+ * Login request payload
282
+ */
283
+ interface LoginRequest {
284
+ email: string;
285
+ password: string;
286
+ }
287
+ /**
288
+ * Forgot password request payload
289
+ */
290
+ interface ForgotPasswordRequest {
291
+ email: string;
292
+ org_slug?: string;
293
+ }
294
+ /**
295
+ * Forgot password response
296
+ */
297
+ interface ForgotPasswordResponse {
298
+ message: string;
299
+ }
300
+ /**
301
+ * Reset password request payload
302
+ */
303
+ interface ResetPasswordRequest {
304
+ token: string;
305
+ new_password: string;
306
+ }
307
+ /**
308
+ * Reset password response
309
+ */
310
+ interface ResetPasswordResponse {
311
+ message: string;
312
+ }
313
+ /**
314
+ * MFA verification request payload
315
+ */
316
+ interface MfaVerificationRequest {
317
+ preauth_token: string;
318
+ code: string;
319
+ }
320
+ /**
321
+ * MFA verification response (same as refresh token response)
322
+ */
323
+ interface MfaVerificationResponse {
324
+ access_token: string;
325
+ refresh_token: string;
326
+ expires_in: number;
327
+ }
266
328
 
267
329
  /**
268
330
  * User subscription details
@@ -292,6 +354,65 @@ interface Identity {
292
354
  interface StartLinkResponse {
293
355
  authorization_url: string;
294
356
  }
357
+ /**
358
+ * Change password request payload
359
+ */
360
+ interface ChangePasswordRequest {
361
+ current_password: string;
362
+ new_password: string;
363
+ }
364
+ /**
365
+ * Change password response
366
+ */
367
+ interface ChangePasswordResponse {
368
+ message: string;
369
+ }
370
+ /**
371
+ * Set password request payload (for OAuth users without a password)
372
+ */
373
+ interface SetPasswordRequest {
374
+ new_password: string;
375
+ }
376
+ /**
377
+ * Set password response
378
+ */
379
+ interface SetPasswordResponse {
380
+ message: string;
381
+ }
382
+ /**
383
+ * MFA status response
384
+ */
385
+ interface MfaStatusResponse {
386
+ enabled: boolean;
387
+ has_backup_codes: boolean;
388
+ }
389
+ /**
390
+ * MFA setup response
391
+ */
392
+ interface MfaSetupResponse {
393
+ secret: string;
394
+ qr_code_svg: string;
395
+ qr_code_uri: string;
396
+ }
397
+ /**
398
+ * MFA verify request
399
+ */
400
+ interface MfaVerifyRequest {
401
+ code: string;
402
+ }
403
+ /**
404
+ * MFA verify response
405
+ */
406
+ interface MfaVerifyResponse {
407
+ enabled: boolean;
408
+ backup_codes: string[];
409
+ }
410
+ /**
411
+ * Backup codes response
412
+ */
413
+ interface BackupCodesResponse {
414
+ backup_codes: string[];
415
+ }
295
416
 
296
417
  /**
297
418
  * Organization entity
@@ -431,6 +552,211 @@ interface MemberListResponse {
431
552
  source: string;
432
553
  };
433
554
  }
555
+ /**
556
+ * SMTP configuration request
557
+ */
558
+ interface SetSmtpRequest {
559
+ host: string;
560
+ port: number;
561
+ username: string;
562
+ password: string;
563
+ from_email: string;
564
+ from_name?: string;
565
+ }
566
+ /**
567
+ * SMTP configuration response (without password)
568
+ */
569
+ interface SmtpConfigResponse {
570
+ host: string;
571
+ port: number;
572
+ username: string;
573
+ from_email: string;
574
+ from_name?: string;
575
+ configured: boolean;
576
+ }
577
+ /**
578
+ * Organization audit log entry
579
+ */
580
+ interface AuditLog {
581
+ id: string;
582
+ org_id: string;
583
+ actor_user_id: string;
584
+ actor_user_email?: string;
585
+ action: string;
586
+ target_type: string;
587
+ target_id: string;
588
+ ip_address?: string;
589
+ user_agent?: string;
590
+ success: boolean;
591
+ details?: string;
592
+ created_at: string;
593
+ }
594
+ /**
595
+ * Audit log response with pagination
596
+ */
597
+ interface AuditLogResponse {
598
+ logs: AuditLog[];
599
+ pagination: PaginationInfo;
600
+ }
601
+ /**
602
+ * Event type information for filtering
603
+ */
604
+ interface EventTypeInfo {
605
+ value: string;
606
+ label: string;
607
+ category: string;
608
+ }
609
+ /**
610
+ * Audit log query parameters
611
+ */
612
+ interface AuditLogQueryParams extends PaginationParams {
613
+ action?: string;
614
+ target_type?: string;
615
+ target_id?: string;
616
+ }
617
+ /**
618
+ * Webhook configuration
619
+ */
620
+ interface Webhook {
621
+ id: string;
622
+ name: string;
623
+ url: string;
624
+ events: string[];
625
+ is_active: boolean;
626
+ created_at: string;
627
+ updated_at: string;
628
+ }
629
+ /**
630
+ * Webhook response
631
+ */
632
+ interface WebhookResponse {
633
+ id: string;
634
+ name: string;
635
+ url: string;
636
+ events: string[];
637
+ is_active: boolean;
638
+ created_at: string;
639
+ updated_at: string;
640
+ }
641
+ /**
642
+ * Webhook list response
643
+ */
644
+ interface WebhookListResponse {
645
+ webhooks: WebhookResponse[];
646
+ total: number;
647
+ }
648
+ /**
649
+ * Create webhook request
650
+ */
651
+ interface CreateWebhookRequest {
652
+ name: string;
653
+ url: string;
654
+ events: string[];
655
+ }
656
+ /**
657
+ * Update webhook request
658
+ */
659
+ interface UpdateWebhookRequest {
660
+ name?: string;
661
+ url?: string;
662
+ events?: string[];
663
+ is_active?: boolean;
664
+ }
665
+ /**
666
+ * Webhook delivery attempt
667
+ */
668
+ interface WebhookDelivery {
669
+ id: string;
670
+ webhook_id: string;
671
+ webhook_name: string;
672
+ event_type: string;
673
+ payload: any;
674
+ response_status_code?: number;
675
+ response_body?: string;
676
+ attempt_count: number;
677
+ max_attempts: number;
678
+ next_retry_at?: string;
679
+ delivered: boolean;
680
+ delivery_error?: string;
681
+ created_at: string;
682
+ updated_at: string;
683
+ }
684
+ /**
685
+ * Webhook delivery list response
686
+ */
687
+ interface WebhookDeliveryListResponse {
688
+ deliveries: WebhookDelivery[];
689
+ pagination: PaginationInfo;
690
+ }
691
+ /**
692
+ * Webhook delivery query parameters
693
+ */
694
+ interface WebhookDeliveryQueryParams extends PaginationParams {
695
+ event_type?: string;
696
+ delivered?: boolean;
697
+ }
698
+ /**
699
+ * Pagination information
700
+ */
701
+ interface PaginationInfo {
702
+ page: number;
703
+ limit: number;
704
+ total: number;
705
+ total_pages: number;
706
+ has_next: boolean;
707
+ has_prev: boolean;
708
+ }
709
+ /**
710
+ * Custom domain configuration
711
+ */
712
+ interface DomainConfiguration {
713
+ custom_domain: string | null;
714
+ domain_verified: boolean;
715
+ }
716
+ /**
717
+ * Set custom domain request
718
+ */
719
+ interface SetCustomDomainRequest {
720
+ domain: string;
721
+ }
722
+ /**
723
+ * Domain verification method
724
+ */
725
+ interface DomainVerificationMethod {
726
+ method: string;
727
+ instructions: string;
728
+ record_type?: string;
729
+ record_name?: string;
730
+ record_value?: string;
731
+ }
732
+ /**
733
+ * Domain verification response
734
+ */
735
+ interface DomainVerificationResponse {
736
+ verification_token: string;
737
+ verification_methods: DomainVerificationMethod[];
738
+ }
739
+ /**
740
+ * Domain verification result
741
+ */
742
+ interface DomainVerificationResult {
743
+ verified: boolean;
744
+ message: string;
745
+ }
746
+ /**
747
+ * Branding configuration
748
+ */
749
+ interface BrandingConfiguration {
750
+ logo_url: string | null;
751
+ primary_color: string | null;
752
+ }
753
+ /**
754
+ * Update branding request
755
+ */
756
+ interface UpdateBrandingRequest {
757
+ logo_url?: string | null;
758
+ primary_color?: string | null;
759
+ }
434
760
 
435
761
  /**
436
762
  * Service entity
@@ -447,6 +773,14 @@ interface Service {
447
773
  google_scopes: string[];
448
774
  redirect_uris: string[];
449
775
  device_activation_uri?: string;
776
+ saml_enabled: boolean;
777
+ saml_entity_id?: string;
778
+ saml_acs_url?: string;
779
+ saml_slo_url?: string;
780
+ saml_name_id_format?: string;
781
+ saml_attribute_mapping?: Record<string, string>;
782
+ saml_sign_assertions: boolean;
783
+ saml_sign_response: boolean;
450
784
  created_at: string;
451
785
  }
452
786
  /**
@@ -466,12 +800,18 @@ interface Plan {
466
800
  id: string;
467
801
  service_id: string;
468
802
  name: string;
469
- description?: string;
470
- price_monthly?: number;
471
- features: string[];
472
- is_default: boolean;
803
+ price_cents: number;
804
+ currency: string;
805
+ features: string;
473
806
  created_at: string;
474
807
  }
808
+ /**
809
+ * Plan response with metadata
810
+ */
811
+ interface PlanResponse {
812
+ plan: Plan;
813
+ subscription_count: number;
814
+ }
475
815
  /**
476
816
  * Create service payload
477
817
  */
@@ -523,10 +863,18 @@ interface ServiceResponse {
523
863
  */
524
864
  interface CreatePlanPayload {
525
865
  name: string;
526
- description?: string;
527
- price_monthly?: number;
528
- features: string[];
529
- is_default?: boolean;
866
+ price_cents: number;
867
+ currency: string;
868
+ features?: string[];
869
+ }
870
+ /**
871
+ * Update plan payload
872
+ */
873
+ interface UpdatePlanPayload {
874
+ name?: string;
875
+ price_cents?: number;
876
+ currency?: string;
877
+ features?: string[];
530
878
  }
531
879
  /**
532
880
  * Service with aggregated details
@@ -546,6 +894,93 @@ interface ServiceListResponse {
546
894
  tier: string;
547
895
  };
548
896
  }
897
+ /**
898
+ * API Key for service-to-service authentication
899
+ */
900
+ interface ApiKey {
901
+ id: string;
902
+ service_id: string;
903
+ name: string;
904
+ prefix: string;
905
+ permissions: string[];
906
+ last_used_at?: string;
907
+ expires_at?: string;
908
+ created_at: string;
909
+ created_by: string;
910
+ }
911
+ /**
912
+ * API Key creation response (includes the full key - only returned once)
913
+ */
914
+ interface ApiKeyCreateResponse {
915
+ id: string;
916
+ service_id: string;
917
+ name: string;
918
+ prefix: string;
919
+ permissions: string[];
920
+ expires_at?: string;
921
+ created_at: string;
922
+ created_by: string;
923
+ key: string;
924
+ }
925
+ /**
926
+ * Create API key payload
927
+ */
928
+ interface CreateApiKeyPayload {
929
+ name: string;
930
+ permissions: string[];
931
+ expires_in_days?: number;
932
+ }
933
+ /**
934
+ * List API keys response
935
+ */
936
+ interface ListApiKeysResponse {
937
+ api_keys: ApiKey[];
938
+ total: number;
939
+ }
940
+ /**
941
+ * SAML configuration for a service (acting as Identity Provider)
942
+ */
943
+ interface SamlConfig {
944
+ enabled: boolean;
945
+ entity_id?: string;
946
+ acs_url?: string;
947
+ slo_url?: string;
948
+ name_id_format?: string;
949
+ attribute_mapping?: Record<string, string>;
950
+ sign_assertions: boolean;
951
+ sign_response: boolean;
952
+ has_certificate: boolean;
953
+ }
954
+ /**
955
+ * Configure SAML IdP payload
956
+ */
957
+ interface ConfigureSamlPayload {
958
+ enabled: boolean;
959
+ entity_id: string;
960
+ acs_url: string;
961
+ slo_url?: string;
962
+ name_id_format?: string;
963
+ attribute_mapping?: Record<string, string>;
964
+ sign_assertions?: boolean;
965
+ sign_response?: boolean;
966
+ }
967
+ /**
968
+ * SAML configuration response
969
+ */
970
+ interface ConfigureSamlResponse {
971
+ success: boolean;
972
+ message: string;
973
+ }
974
+ /**
975
+ * SAML signing certificate info
976
+ */
977
+ interface SamlCertificate {
978
+ public_key: string;
979
+ valid_from: string;
980
+ valid_until: string;
981
+ is_active: boolean;
982
+ created_at: string;
983
+ }
549
984
 
550
985
  /**
551
986
  * Invitation entity
@@ -1038,7 +1473,8 @@ declare class AuthModule {
1038
1473
  * ```typescript
1039
1474
  * await sso.auth.logout();
1040
1475
  * sso.setAuthToken(null);
1041
- * localStorage.removeItem('jwt');
1476
+ * localStorage.removeItem('sso_access_token');
1477
+ * localStorage.removeItem('sso_refresh_token');
1042
1478
  * ```
1043
1479
  */
1044
1480
  logout(): Promise<void>;
@@ -1059,8 +1495,8 @@ declare class AuthModule {
1059
1495
  * try {
1060
1496
  * const tokens = await sso.auth.refreshToken(storedRefreshToken);
1061
1497
  * sso.setAuthToken(tokens.access_token);
1062
- * localStorage.setItem('access_token', tokens.access_token);
1063
- * localStorage.setItem('refresh_token', tokens.refresh_token);
1498
+ * localStorage.setItem('sso_access_token', tokens.access_token);
1499
+ * localStorage.setItem('sso_refresh_token', tokens.refresh_token);
1064
1500
  * } catch (error) {
1065
1501
  * // Refresh failed - redirect to login
1066
1502
  * window.location.href = '/login';
@@ -1082,6 +1518,107 @@ declare class AuthModule {
1082
1518
  * ```
1083
1519
  */
1084
1520
  getProviderToken(provider: OAuthProvider): Promise<ProviderToken>;
1521
+ /**
1522
+ * Register a new user with email and password.
1523
+ * After registration, the user will receive a verification email.
1524
+ *
1525
+ * @param payload Registration details (email and password)
1526
+ * @returns Registration confirmation message
1527
+ *
1528
+ * @example
1529
+ * ```typescript
1530
+ * const response = await sso.auth.register({
1531
+ * email: 'user@example.com',
1532
+ * password: 'SecurePassword123!'
1533
+ * });
1534
+ * console.log(response.message);
1535
+ * ```
1536
+ */
1537
+ register(payload: RegisterRequest): Promise<RegisterResponse>;
1538
+ /**
1539
+ * Login with email and password.
1540
+ * Returns access token and refresh token on successful authentication.
1541
+ * The user's email must be verified before login.
1542
+ *
1543
+ * @param payload Login credentials (email and password)
1544
+ * @returns Access token, refresh token, and expiration info
1545
+ *
1546
+ * @example
1547
+ * ```typescript
1548
+ * const tokens = await sso.auth.login({
1549
+ * email: 'user@example.com',
1550
+ * password: 'SecurePassword123!'
1551
+ * });
1552
+ * sso.setAuthToken(tokens.access_token);
1553
+ * localStorage.setItem('sso_access_token', tokens.access_token);
1554
+ * localStorage.setItem('sso_refresh_token', tokens.refresh_token);
1555
+ * ```
1556
+ */
1557
+ login(payload: LoginRequest): Promise<RefreshTokenResponse>;
1558
+ /**
1559
+ * Verify MFA code and complete authentication.
1560
+ * This method should be called after login when the user has MFA enabled.
1561
+ * The login will return a pre-auth token with a short expiration (5 minutes).
1562
+ * Exchange the pre-auth token and TOTP code for a full session.
1563
+ *
1564
+ * @param preauthToken The pre-authentication token received from login
1565
+ * @param code The TOTP code from the user's authenticator app or a backup code
1566
+ * @returns Full session tokens (access_token and refresh_token)
1567
+ *
1568
+ * @example
1569
+ * ```typescript
1570
+ * // After login, if MFA is enabled:
1571
+ * const loginResponse = await sso.auth.login({
1572
+ * email: 'user@example.com',
1573
+ * password: 'password'
1574
+ * });
1575
+ *
1576
+ * // Check if this is a pre-auth token (expires_in will be 300 seconds = 5 minutes)
1577
+ * if (loginResponse.expires_in === 300) {
1578
+ * // User needs to provide MFA code
1579
+ * const mfaCode = prompt('Enter your 6-digit code from authenticator app');
1580
+ * const tokens = await sso.auth.verifyMfa(loginResponse.access_token, mfaCode);
1581
+ * sso.setAuthToken(tokens.access_token);
1582
+ * localStorage.setItem('sso_access_token', tokens.access_token);
1583
+ * localStorage.setItem('sso_refresh_token', tokens.refresh_token);
1584
+ * }
1585
+ * ```
1586
+ */
1587
+ verifyMfa(preauthToken: string, code: string, deviceCodeId?: string): Promise<MfaVerificationResponse>;
1588
+ /**
1589
+ * Request a password reset for a user account.
1590
+ * If the email exists, a reset link will be sent to the user.
1591
+ * Returns success regardless of whether the email exists (to prevent email enumeration).
1592
+ *
1593
+ * @param payload Forgot password request (email address)
1594
+ * @returns Confirmation message
1595
+ *
1596
+ * @example
1597
+ * ```typescript
1598
+ * const response = await sso.auth.requestPasswordReset({
1599
+ * email: 'user@example.com'
1600
+ * });
1601
+ * console.log(response.message);
1602
+ * ```
1603
+ */
1604
+ requestPasswordReset(payload: ForgotPasswordRequest): Promise<ForgotPasswordResponse>;
1605
+ /**
1606
+ * Reset a user's password using a reset token from email.
1607
+ * The token is obtained from the password reset email link.
1608
+ *
1609
+ * @param payload Reset password request (token and new password)
1610
+ * @returns Confirmation message
1611
+ *
1612
+ * @example
1613
+ * ```typescript
1614
+ * const response = await sso.auth.resetPassword({
1615
+ * token: 'reset-token-from-email',
1616
+ * new_password: 'NewSecurePassword123!'
1617
+ * });
1618
+ * console.log(response.message);
1619
+ * ```
1620
+ */
1621
+ resetPassword(payload: ResetPasswordRequest): Promise<ResetPasswordResponse>;
1085
1622
  }
1086
1623
 
1087
1624
  /**
@@ -1130,11 +1667,84 @@ declare class IdentitiesModule {
1130
1667
  unlink(provider: string): Promise<void>;
1131
1668
  }
1132
1669
  /**
1133
- * User profile and subscription methods
1670
+ * Multi-Factor Authentication (MFA) methods
1134
1671
  */
1135
- declare class UserModule {
1672
+ declare class MfaModule {
1136
1673
  private http;
1137
- readonly identities: IdentitiesModule;
1674
+ constructor(http: HttpClient);
1675
+ /**
1676
+ * Get the current MFA status for the authenticated user.
1677
+ *
1678
+ * @returns MFA status
1679
+ *
1680
+ * @example
1681
+ * ```typescript
1682
+ * const status = await sso.user.mfa.getStatus();
1683
+ * console.log(status.enabled); // false
1684
+ * ```
1685
+ */
1686
+ getStatus(): Promise<MfaStatusResponse>;
1687
+ /**
1688
+ * Initiate MFA setup. Generates a TOTP secret and QR code.
1689
+ * The user must complete setup by calling verify() with a code from their authenticator app.
1690
+ *
1691
+ * @returns MFA setup details including QR code
1692
+ *
1693
+ * @example
1694
+ * ```typescript
1695
+ * const setup = await sso.user.mfa.setup();
1696
+ * console.log(setup.qr_code_svg); // Display this QR code to the user
1697
+ * // User scans QR code with authenticator app and enters code to verify
1698
+ * ```
1699
+ */
1700
+ setup(): Promise<MfaSetupResponse>;
1701
+ /**
1702
+ * Verify TOTP code and enable MFA.
1703
+ * Returns backup codes that must be stored securely by the user.
1704
+ *
1705
+ * @param code TOTP code from authenticator app
1706
+ * @returns Verification response with backup codes
1707
+ *
1708
+ * @example
1709
+ * ```typescript
1710
+ * const result = await sso.user.mfa.verify('123456');
1711
+ * console.log(result.backup_codes); // Store these securely!
1712
+ * ```
1713
+ */
1714
+ verify(code: string): Promise<MfaVerifyResponse>;
1715
+ /**
1716
+ * Disable MFA for the authenticated user.
1717
+ *
1718
+ * @example
1719
+ * ```typescript
1720
+ * await sso.user.mfa.disable();
1721
+ * ```
1722
+ */
1723
+ disable(): Promise<{
1724
+ success: boolean;
1725
+ message: string;
1726
+ }>;
1727
+ /**
1728
+ * Regenerate backup codes.
1729
+ * Invalidates all previous backup codes and returns new ones.
1730
+ *
1731
+ * @returns New backup codes
1732
+ *
1733
+ * @example
1734
+ * ```typescript
1735
+ * const { backup_codes } = await sso.user.mfa.regenerateBackupCodes();
1736
+ * console.log(backup_codes); // Store these securely!
1737
+ * ```
1738
+ */
1739
+ regenerateBackupCodes(): Promise<BackupCodesResponse>;
1740
+ }
1741
+ /**
1742
+ * User profile and subscription methods
1743
+ */
1744
+ declare class UserModule {
1745
+ private http;
1746
+ readonly identities: IdentitiesModule;
1747
+ readonly mfa: MfaModule;
1138
1748
  constructor(http: HttpClient);
1139
1749
  /**
1140
1750
  * Get the profile of the currently authenticated user.
@@ -1175,6 +1785,251 @@ declare class UserModule {
1175
1785
  * ```
1176
1786
  */
1177
1787
  getSubscription(): Promise<Subscription>;
1788
+ /**
1789
+ * Change the authenticated user's password.
1790
+ * Requires the current password for verification.
1791
+ *
1792
+ * @param payload Change password request (current and new password)
1793
+ * @returns Confirmation message
1794
+ *
1795
+ * @example
1796
+ * ```typescript
1797
+ * const response = await sso.user.changePassword({
1798
+ * current_password: 'OldPassword123!',
1799
+ * new_password: 'NewSecurePassword456!'
1800
+ * });
1801
+ * console.log(response.message);
1802
+ * ```
1803
+ */
1804
+ changePassword(payload: ChangePasswordRequest): Promise<ChangePasswordResponse>;
1805
+ /**
1806
+ * Set a password for the authenticated user (OAuth users only).
1807
+ * This endpoint is for OAuth users who don't have a password yet.
1808
+ * If a password is already set, this will return an error.
1809
+ *
1810
+ * @param payload Set password request (new password only)
1811
+ * @returns Confirmation message
1812
+ *
1813
+ * @example
1814
+ * ```typescript
1815
+ * const response = await sso.user.setPassword({
1816
+ * new_password: 'MyNewSecurePassword123!'
1817
+ * });
1818
+ * console.log(response.message); // "Password set successfully"
1819
+ * ```
1820
+ */
1821
+ setPassword(payload: SetPasswordRequest): Promise<SetPasswordResponse>;
1822
+ }
1823
+
1824
+ /**
1825
+ * Organization audit logs management methods
1826
+ */
1827
+ declare class AuditLogsModule {
1828
+ private http;
1829
+ constructor(http: HttpClient);
1830
+ /**
1831
+ * Get audit logs for an organization.
1832
+ * Requires 'owner' or 'admin' role.
1833
+ *
1834
+ * @param orgSlug Organization slug
1835
+ * @param params Optional query parameters for filtering and pagination
1836
+ * @returns Paginated audit log response
1837
+ *
1838
+ * @example
1839
+ * ```typescript
1840
+ * // Get all audit logs
1841
+ * const logs = await sso.organizations.auditLogs.get('acme-corp');
1842
+ *
1843
+ * // Filter by specific action
1844
+ * const userLogs = await sso.organizations.auditLogs.get('acme-corp', {
1845
+ * action: 'user.role_updated',
1846
+ * page: 1,
1847
+ * limit: 20
1848
+ * });
1849
+ *
1850
+ * // Filter by target
1851
+ * const serviceLogs = await sso.organizations.auditLogs.get('acme-corp', {
1852
+ * target_type: 'service',
1853
+ * target_id: 'service-123'
1854
+ * });
1855
+ * ```
1856
+ */
1857
+ get(orgSlug: string, params?: AuditLogQueryParams): Promise<AuditLogResponse>;
1858
+ /**
1859
+ * Get available audit event types for filtering.
1860
+ * Requires 'owner' or 'admin' role.
1861
+ *
1862
+ * @param orgSlug Organization slug
1863
+ * @returns Array of event type information
1864
+ *
1865
+ * @example
1866
+ * ```typescript
1867
+ * const eventTypes = await sso.organizations.auditLogs.getEventTypes('acme-corp');
1868
+ *
1869
+ * // Group by category for UI display
1870
+ * const byCategory = eventTypes.reduce((acc, event) => {
1871
+ * if (!acc[event.category]) {
1872
+ * acc[event.category] = [];
1873
+ * }
1874
+ * acc[event.category].push(event);
1875
+ * return acc;
1876
+ * }, {});
1877
+ * ```
1878
+ */
1879
+ getEventTypes(orgSlug: string): Promise<EventTypeInfo[]>;
1880
+ }
1881
+
1882
+ /**
1883
+ * Organization webhooks management methods
1884
+ */
1885
+ declare class WebhooksModule {
1886
+ private http;
1887
+ constructor(http: HttpClient);
1888
+ /**
1889
+ * Create a new webhook for an organization.
1890
+ * Requires 'owner' or 'admin' role.
1891
+ *
1892
+ * @param orgSlug Organization slug
1893
+ * @param webhook Webhook creation payload
1894
+ * @returns Created webhook details
1895
+ *
1896
+ * @example
1897
+ * ```typescript
1898
+ * const webhook = await sso.organizations.webhooks.create('acme-corp', {
1899
+ * name: 'User Activity',
1900
+ * url: 'https://api.example.com/webhooks',
1901
+ * events: ['user.invited', 'user.joined', 'user.removed']
1902
+ * });
1903
+ * console.log('Created webhook:', webhook.id);
1904
+ * ```
1905
+ */
1906
+ create(orgSlug: string, webhook: CreateWebhookRequest): Promise<WebhookResponse>;
1907
+ /**
1908
+ * List all webhooks for an organization.
1909
+ * Requires 'owner' or 'admin' role.
1910
+ *
1911
+ * @param orgSlug Organization slug
1912
+ * @returns List of webhooks with total count
1913
+ *
1914
+ * @example
1915
+ * ```typescript
1916
+ * const { webhooks, total } = await sso.organizations.webhooks.list('acme-corp');
1917
+ * console.log(`Found ${total} webhooks`);
1918
+ * webhooks.forEach(w => console.log(w.name, w.is_active));
1919
+ * ```
1920
+ */
1921
+ list(orgSlug: string): Promise<WebhookListResponse>;
1922
+ /**
1923
+ * Get a specific webhook by ID.
1924
+ * Requires 'owner' or 'admin' role.
1925
+ *
1926
+ * @param orgSlug Organization slug
1927
+ * @param webhookId Webhook ID
1928
+ * @returns Webhook details
1929
+ *
1930
+ * @example
1931
+ * ```typescript
1932
+ * const webhook = await sso.organizations.webhooks.get('acme-corp', 'webhook-123');
1933
+ * console.log('Webhook URL:', webhook.url);
1934
+ * console.log('Subscribed events:', webhook.events);
1935
+ * ```
1936
+ */
1937
+ get(orgSlug: string, webhookId: string): Promise<WebhookResponse>;
1938
+ /**
1939
+ * Update an existing webhook.
1940
+ * Requires 'owner' or 'admin' role.
1941
+ *
1942
+ * @param orgSlug Organization slug
1943
+ * @param webhookId Webhook ID
1944
+ * @param updates Partial webhook update payload
1945
+ * @returns Updated webhook details
1946
+ *
1947
+ * @example
1948
+ * ```typescript
1949
+ * // Update webhook URL and add new events
1950
+ * const updated = await sso.organizations.webhooks.update('acme-corp', 'webhook-123', {
1951
+ * url: 'https://api.example.com/webhooks/v2',
1952
+ * events: ['user.invited', 'user.joined', 'user.removed', 'user.role_updated']
1953
+ * });
1954
+ *
1955
+ * // Deactivate webhook temporarily
1956
+ * await sso.organizations.webhooks.update('acme-corp', 'webhook-123', {
1957
+ * is_active: false
1958
+ * });
1959
+ * ```
1960
+ */
1961
+ update(orgSlug: string, webhookId: string, updates: UpdateWebhookRequest): Promise<WebhookResponse>;
1962
+ /**
1963
+ * Delete a webhook.
1964
+ * Requires 'owner' or 'admin' role.
1965
+ * This will also delete all delivery history for this webhook.
1966
+ *
1967
+ * @param orgSlug Organization slug
1968
+ * @param webhookId Webhook ID
1969
+ *
1970
+ * @example
1971
+ * ```typescript
1972
+ * await sso.organizations.webhooks.delete('acme-corp', 'webhook-123');
1973
+ * console.log('Webhook deleted successfully');
1974
+ * ```
1975
+ */
1976
+ delete(orgSlug: string, webhookId: string): Promise<void>;
1977
+ /**
1978
+ * Get delivery history for a specific webhook.
1979
+ * Requires 'owner' or 'admin' role.
1980
+ *
1981
+ * @param orgSlug Organization slug
1982
+ * @param webhookId Webhook ID
1983
+ * @param params Optional query parameters for filtering and pagination
1984
+ * @returns Paginated webhook delivery response
1985
+ *
1986
+ * @example
1987
+ * ```typescript
1988
+ * // Get all delivery attempts
1989
+ * const deliveries = await sso.organizations.webhooks.getDeliveries('acme-corp', 'webhook-123');
1990
+ *
1991
+ * // Get only failed deliveries
1992
+ * const failed = await sso.organizations.webhooks.getDeliveries('acme-corp', 'webhook-123', {
1993
+ * delivered: false,
1994
+ * page: 1,
1995
+ * limit: 20
1996
+ * });
1997
+ *
1998
+ * // Get deliveries for specific event type
1999
+ * const userEvents = await sso.organizations.webhooks.getDeliveries('acme-corp', 'webhook-123', {
2000
+ * event_type: 'user.invited'
2001
+ * });
2002
+ * ```
2003
+ */
2004
+ getDeliveries(orgSlug: string, webhookId: string, params?: WebhookDeliveryQueryParams): Promise<WebhookDeliveryListResponse>;
2005
+ /**
2006
+ * Get available webhook event types that can be subscribed to.
2007
+ * Requires 'owner' or 'admin' role.
2008
+ *
2009
+ * @param orgSlug Organization slug
2010
+ * @returns Array of available event types with categories
2011
+ *
2012
+ * @example
2013
+ * ```typescript
2014
+ * const eventTypes = await sso.organizations.webhooks.getEventTypes('acme-corp');
2015
+ *
2016
+ * // Group events by category for UI display
2017
+ * const byCategory = eventTypes.reduce((acc, event) => {
2018
+ * if (!acc[event.category]) {
2019
+ * acc[event.category] = [];
2020
+ * }
2021
+ * acc[event.category].push(event);
2022
+ * return acc;
2023
+ * }, {});
2024
+ *
2025
+ * // Display available events
2026
+ * Object.entries(byCategory).forEach(([category, events]) => {
2027
+ * console.log(`\n${category}:`);
2028
+ * events.forEach(e => console.log(` - ${e.label} (${e.value})`));
2029
+ * });
2030
+ * ```
2031
+ */
2032
+ getEventTypes(orgSlug: string): Promise<EventTypeInfo[]>;
1178
2033
  }
1179
2034
 
1180
2035
  /**
@@ -1183,6 +2038,14 @@ declare class UserModule {
1183
2038
  declare class OrganizationsModule {
1184
2039
  private http;
1185
2040
  constructor(http: HttpClient);
2041
+ /**
2042
+ * Audit logs management
2043
+ */
2044
+ auditLogs: AuditLogsModule;
2045
+ /**
2046
+ * Webhooks management
2047
+ */
2048
+ webhooks: WebhooksModule;
1186
2049
  /**
1187
2050
  * Create a new organization (public endpoint).
1188
2051
  * The organization will be created with 'pending' status and requires
@@ -1247,6 +2110,26 @@ declare class OrganizationsModule {
1247
2110
  * ```
1248
2111
  */
1249
2112
  update(orgSlug: string, payload: UpdateOrganizationPayload): Promise<OrganizationResponse>;
2113
+ /**
2114
+ * Delete an organization and all its associated data.
2115
+ * This is a destructive operation that cannot be undone.
2116
+ * Requires 'owner' role.
2117
+ *
2118
+ * All related data will be cascaded deleted including:
2119
+ * - Members and invitations
2120
+ * - Services and plans
2121
+ * - Subscriptions
2122
+ * - OAuth credentials
2123
+ * - Audit logs
2124
+ *
2125
+ * @param orgSlug Organization slug
2126
+ *
2127
+ * @example
2128
+ * ```typescript
2129
+ * await sso.organizations.delete('acme-corp');
2130
+ * ```
2131
+ */
2132
+ delete(orgSlug: string): Promise<void>;
1250
2133
  /**
1251
2134
  * Member management methods
1252
2135
  */
@@ -1379,168 +2262,629 @@ declare class OrganizationsModule {
1379
2262
  */
1380
2263
  oauthCredentials: {
1381
2264
  /**
1382
- * Set or update custom OAuth credentials for a provider.
1383
- * This enables white-labeled authentication using the organization's
1384
- * own OAuth application.
2265
+ * Set or update custom OAuth credentials for a provider.
2266
+ * This enables white-labeled authentication using the organization's
2267
+ * own OAuth application.
2268
+ * Requires 'owner' or 'admin' role.
2269
+ *
2270
+ * @param orgSlug Organization slug
2271
+ * @param provider OAuth provider
2272
+ * @param payload OAuth credentials
2273
+ * @returns Created/updated credentials (without secret)
2274
+ *
2275
+ * @example
2276
+ * ```typescript
2277
+ * await sso.organizations.oauthCredentials.set('acme-corp', 'github', {
2278
+ * client_id: 'Iv1.abc123',
2279
+ * client_secret: 'secret-value'
2280
+ * });
2281
+ * ```
2282
+ */
2283
+ set: (orgSlug: string, provider: OAuthProvider, payload: SetOAuthCredentialsPayload) => Promise<OAuthCredentials>;
2284
+ /**
2285
+ * Get the configured OAuth credentials for a provider.
2286
+ * The secret is never returned.
2287
+ *
2288
+ * @param orgSlug Organization slug
2289
+ * @param provider OAuth provider
2290
+ * @returns OAuth credentials (without secret)
2291
+ *
2292
+ * @example
2293
+ * ```typescript
2294
+ * const creds = await sso.organizations.oauthCredentials.get('acme-corp', 'github');
2295
+ * console.log(creds.client_id);
2296
+ * ```
2297
+ */
2298
+ get: (orgSlug: string, provider: OAuthProvider) => Promise<OAuthCredentials>;
2299
+ };
2300
+ /**
2301
+ * Configure SMTP settings for an organization.
2302
+ * Only owners and admins can configure SMTP.
2303
+ * The organization will use these settings for sending transactional emails
2304
+ * (registration, password reset, etc.).
2305
+ *
2306
+ * @param orgSlug Organization slug
2307
+ * @param config SMTP configuration
2308
+ * @returns Success message
2309
+ *
2310
+ * @example
2311
+ * ```typescript
2312
+ * await sso.organizations.setSmtp('acme-corp', {
2313
+ * host: 'smtp.gmail.com',
2314
+ * port: 587,
2315
+ * username: 'notifications@acme.com',
2316
+ * password: 'your-app-password',
2317
+ * from_email: 'notifications@acme.com',
2318
+ * from_name: 'Acme Corp'
2319
+ * });
2320
+ * ```
2321
+ */
2322
+ setSmtp(orgSlug: string, config: SetSmtpRequest): Promise<{
2323
+ message: string;
2324
+ }>;
2325
+ /**
2326
+ * Get SMTP configuration for an organization.
2327
+ * Only owners and admins can view SMTP settings.
2328
+ * Password is never returned for security reasons.
2329
+ *
2330
+ * @param orgSlug Organization slug
2331
+ * @returns SMTP configuration (without password)
2332
+ *
2333
+ * @example
2334
+ * ```typescript
2335
+ * const config = await sso.organizations.getSmtp('acme-corp');
2336
+ * if (config.configured) {
2337
+ * console.log('SMTP host:', config.host);
2338
+ * }
2339
+ * ```
2340
+ */
2341
+ getSmtp(orgSlug: string): Promise<SmtpConfigResponse>;
2342
+ /**
2343
+ * Delete SMTP configuration for an organization.
2344
+ * The organization will revert to using platform-level SMTP.
2345
+ * Only owners and admins can delete SMTP settings.
2346
+ *
2347
+ * @param orgSlug Organization slug
2348
+ * @returns Success message
2349
+ *
2350
+ * @example
2351
+ * ```typescript
2352
+ * await sso.organizations.deleteSmtp('acme-corp');
2353
+ * // Organization now uses platform SMTP
2354
+ * ```
2355
+ */
2356
+ deleteSmtp(orgSlug: string): Promise<{
2357
+ message: string;
2358
+ }>;
2359
+ /**
2360
+ * Set a custom domain for an organization.
2361
+ * This enables white-labeling by allowing the organization to use their own domain
2362
+ * (e.g., auth.acme.com) instead of the platform's domain.
2363
+ * Requires 'owner' or 'admin' role.
2364
+ *
2365
+ * @param orgSlug Organization slug
2366
+ * @param request Custom domain request
2367
+ * @returns Domain verification instructions
2368
+ *
2369
+ * @example
2370
+ * ```typescript
2371
+ * const verification = await sso.organizations.setCustomDomain('acme-corp', {
2372
+ * domain: 'auth.acme.com'
2373
+ * });
2374
+ * console.log('Verification token:', verification.verification_token);
2375
+ * verification.verification_methods.forEach(method => {
2376
+ * console.log(method.method, method.instructions);
2377
+ * });
2378
+ * ```
2379
+ */
2380
+ setCustomDomain(orgSlug: string, request: SetCustomDomainRequest): Promise<DomainVerificationResponse>;
2381
+ /**
2382
+ * Verify a custom domain by checking DNS TXT record or HTTP file.
2383
+ * Requires 'owner' or 'admin' role.
2384
+ *
2385
+ * @param orgSlug Organization slug
2386
+ * @returns Verification result
2387
+ *
2388
+ * @example
2389
+ * ```typescript
2390
+ * const result = await sso.organizations.verifyCustomDomain('acme-corp');
2391
+ * if (result.verified) {
2392
+ * console.log('Domain verified successfully!');
2393
+ * } else {
2394
+ * console.log('Verification failed:', result.message);
2395
+ * }
2396
+ * ```
2397
+ */
2398
+ verifyCustomDomain(orgSlug: string): Promise<DomainVerificationResult>;
2399
+ /**
2400
+ * Get custom domain configuration for an organization.
2401
+ *
2402
+ * @param orgSlug Organization slug
2403
+ * @returns Domain configuration
2404
+ *
2405
+ * @example
2406
+ * ```typescript
2407
+ * const config = await sso.organizations.getDomainConfiguration('acme-corp');
2408
+ * if (config.custom_domain && config.domain_verified) {
2409
+ * console.log('Custom domain active:', config.custom_domain);
2410
+ * }
2411
+ * ```
2412
+ */
2413
+ getDomainConfiguration(orgSlug: string): Promise<DomainConfiguration>;
2414
+ /**
2415
+ * Delete custom domain configuration.
2416
+ * Requires 'owner' or 'admin' role.
2417
+ *
2418
+ * @param orgSlug Organization slug
2419
+ *
2420
+ * @example
2421
+ * ```typescript
2422
+ * await sso.organizations.deleteCustomDomain('acme-corp');
2423
+ * // Organization reverts to using platform domain
2424
+ * ```
2425
+ */
2426
+ deleteCustomDomain(orgSlug: string): Promise<void>;
2427
+ /**
2428
+ * Update branding configuration (logo and primary color).
2429
+ * This controls the visual appearance of authentication pages.
2430
+ * Requires 'owner' or 'admin' role.
2431
+ *
2432
+ * @param orgSlug Organization slug
2433
+ * @param request Branding configuration
2434
+ * @returns Updated branding configuration
2435
+ *
2436
+ * @example
2437
+ * ```typescript
2438
+ * await sso.organizations.updateBranding('acme-corp', {
2439
+ * logo_url: 'https://cdn.acme.com/logo.png',
2440
+ * primary_color: '#FF5733'
2441
+ * });
2442
+ * ```
2443
+ */
2444
+ updateBranding(orgSlug: string, request: UpdateBrandingRequest): Promise<BrandingConfiguration>;
2445
+ /**
2446
+ * Get branding configuration for an organization.
2447
+ *
2448
+ * @param orgSlug Organization slug
2449
+ * @returns Branding configuration
2450
+ *
2451
+ * @example
2452
+ * ```typescript
2453
+ * const branding = await sso.organizations.getBranding('acme-corp');
2454
+ * if (branding.logo_url) {
2455
+ * console.log('Logo URL:', branding.logo_url);
2456
+ * }
2457
+ * ```
2458
+ */
2459
+ getBranding(orgSlug: string): Promise<BrandingConfiguration>;
2460
+ /**
2461
+ * Get public branding configuration (no authentication required).
2462
+ * This endpoint is used by login pages to display organization branding.
2463
+ *
2464
+ * @param orgSlug Organization slug
2465
+ * @returns Branding configuration
2466
+ *
2467
+ * @example
2468
+ * ```typescript
2469
+ * // Can be called without authentication
2470
+ * const branding = await sso.organizations.getPublicBranding('acme-corp');
2471
+ * ```
2472
+ */
2473
+ getPublicBranding(orgSlug: string): Promise<BrandingConfiguration>;
2474
+ }
2475
+
2476
+ /**
2477
+ * Service management methods
2478
+ */
2479
+ declare class ServicesModule {
2480
+ private http;
2481
+ constructor(http: HttpClient);
2482
+ /**
2483
+ * Create a new service for an organization.
2484
+ * Requires 'owner' or 'admin' role.
2485
+ *
2486
+ * @param orgSlug Organization slug
2487
+ * @param payload Service creation payload
2488
+ * @returns Created service with details
2489
+ *
2490
+ * @example
2491
+ * ```typescript
2492
+ * const result = await sso.services.create('acme-corp', {
2493
+ * slug: 'main-app',
2494
+ * name: 'Main Application',
2495
+ * service_type: 'web',
2496
+ * github_scopes: ['user:email', 'read:org'],
2497
+ * redirect_uris: ['https://app.acme.com/callback']
2498
+ * });
2499
+ * console.log(result.service.client_id);
2500
+ * ```
2501
+ */
2502
+ create(orgSlug: string, payload: CreateServicePayload): Promise<CreateServiceResponse>;
2503
+ /**
2504
+ * List all services for an organization.
2505
+ *
2506
+ * @param orgSlug Organization slug
2507
+ * @returns Service list response with usage metadata
2508
+ *
2509
+ * @example
2510
+ * ```typescript
2511
+ * const result = await sso.services.list('acme-corp');
2512
+ * console.log(`Using ${result.usage.current_services} of ${result.usage.max_services} services`);
2513
+ * result.services.forEach(svc => console.log(svc.name, svc.client_id));
2514
+ * ```
2515
+ */
2516
+ list(orgSlug: string): Promise<ServiceListResponse>;
2517
+ /**
2518
+ * Get detailed information for a specific service.
2519
+ *
2520
+ * @param orgSlug Organization slug
2521
+ * @param serviceSlug Service slug
2522
+ * @returns Service with provider grants and plans
2523
+ *
2524
+ * @example
2525
+ * ```typescript
2526
+ * const service = await sso.services.get('acme-corp', 'main-app');
2527
+ * console.log(service.service.redirect_uris);
2528
+ * console.log(service.plans);
2529
+ * ```
2530
+ */
2531
+ get(orgSlug: string, serviceSlug: string): Promise<ServiceResponse>;
2532
+ /**
2533
+ * Update service configuration.
2534
+ * Requires 'owner' or 'admin' role.
2535
+ *
2536
+ * @param orgSlug Organization slug
2537
+ * @param serviceSlug Service slug
2538
+ * @param payload Update payload
2539
+ * @returns Updated service
2540
+ *
2541
+ * @example
2542
+ * ```typescript
2543
+ * const updated = await sso.services.update('acme-corp', 'main-app', {
2544
+ * name: 'Main Application v2',
2545
+ * redirect_uris: ['https://app.acme.com/callback', 'https://app.acme.com/oauth']
2546
+ * });
2547
+ * ```
2548
+ */
2549
+ update(orgSlug: string, serviceSlug: string, payload: UpdateServicePayload): Promise<Service>;
2550
+ /**
2551
+ * Delete a service.
2552
+ * Requires 'owner' role.
2553
+ *
2554
+ * @param orgSlug Organization slug
2555
+ * @param serviceSlug Service slug
2556
+ *
2557
+ * @example
2558
+ * ```typescript
2559
+ * await sso.services.delete('acme-corp', 'old-app');
2560
+ * ```
2561
+ */
2562
+ delete(orgSlug: string, serviceSlug: string): Promise<void>;
2563
+ /**
2564
+ * Plan management methods
2565
+ */
2566
+ plans: {
2567
+ /**
2568
+ * Create a new subscription plan for a service.
2569
+ * Requires 'owner' or 'admin' role.
2570
+ *
2571
+ * @param orgSlug Organization slug
2572
+ * @param serviceSlug Service slug
2573
+ * @param payload Plan creation payload
2574
+ * @returns Created plan with subscription count
2575
+ *
2576
+ * @example
2577
+ * ```typescript
2578
+ * const result = await sso.services.plans.create('acme-corp', 'main-app', {
2579
+ * name: 'pro',
2580
+ * price_cents: 2999,
2581
+ * currency: 'usd',
2582
+ * features: ['api-access', 'advanced-analytics', 'priority-support']
2583
+ * });
2584
+ * console.log(result.plan.name, result.subscription_count);
2585
+ * ```
2586
+ */
2587
+ create: (orgSlug: string, serviceSlug: string, payload: CreatePlanPayload) => Promise<PlanResponse>;
2588
+ /**
2589
+ * List all plans for a service.
2590
+ *
2591
+ * @param orgSlug Organization slug
2592
+ * @param serviceSlug Service slug
2593
+ * @returns Array of plans with subscription counts
2594
+ *
2595
+ * @example
2596
+ * ```typescript
2597
+ * const plans = await sso.services.plans.list('acme-corp', 'main-app');
2598
+ * plans.forEach(p => console.log(p.plan.name, p.subscription_count));
2599
+ * ```
2600
+ */
2601
+ list: (orgSlug: string, serviceSlug: string) => Promise<PlanResponse[]>;
2602
+ /**
2603
+ * Update a subscription plan.
2604
+ * Requires 'owner' or 'admin' role.
2605
+ *
2606
+ * @param orgSlug Organization slug
2607
+ * @param serviceSlug Service slug
2608
+ * @param planId Plan ID
2609
+ * @param payload Plan update payload
2610
+ * @returns Updated plan with subscription count
2611
+ *
2612
+ * @example
2613
+ * ```typescript
2614
+ * const result = await sso.services.plans.update('acme-corp', 'main-app', 'plan_123', {
2615
+ * name: 'Pro Plus',
2616
+ * price_cents: 3999,
2617
+ * currency: 'usd',
2618
+ * features: ['api-access', 'advanced-analytics', 'priority-support', 'custom-integrations']
2619
+ * });
2620
+ * console.log('Updated plan:', result.plan.name);
2621
+ * ```
2622
+ */
2623
+ update: (orgSlug: string, serviceSlug: string, planId: string, payload: UpdatePlanPayload) => Promise<PlanResponse>;
2624
+ /**
2625
+ * Delete a subscription plan.
2626
+ * Requires 'owner' or 'admin' role.
2627
+ *
2628
+ * WARNING: This will fail if the plan has active subscriptions.
2629
+ * You must migrate or cancel all subscriptions before deleting a plan.
2630
+ *
2631
+ * @param orgSlug Organization slug
2632
+ * @param serviceSlug Service slug
2633
+ * @param planId Plan ID
2634
+ *
2635
+ * @example
2636
+ * ```typescript
2637
+ * try {
2638
+ * await sso.services.plans.delete('acme-corp', 'main-app', 'plan_123');
2639
+ * console.log('Plan deleted successfully');
2640
+ * } catch (error) {
2641
+ * console.error('Cannot delete plan with active subscriptions');
2642
+ * }
2643
+ * ```
2644
+ */
2645
+ delete: (orgSlug: string, serviceSlug: string, planId: string) => Promise<void>;
2646
+ };
2647
+ /**
2648
+ * API Key management methods for service-to-service authentication
2649
+ */
2650
+ apiKeys: {
2651
+ /**
2652
+ * Create a new API key for a service.
2653
+ * Requires 'owner' or 'admin' role.
2654
+ *
2655
+ * IMPORTANT: The full API key is only returned once upon creation.
2656
+ * Store it securely as it cannot be retrieved again.
2657
+ *
2658
+ * @param orgSlug Organization slug
2659
+ * @param serviceSlug Service slug
2660
+ * @param payload API key creation payload
2661
+ * @returns Created API key with the full key value
2662
+ *
2663
+ * @example
2664
+ * ```typescript
2665
+ * const apiKey = await sso.services.apiKeys.create('acme-corp', 'main-app', {
2666
+ * name: 'Production Backend',
2667
+ * permissions: ['read:users', 'write:subscriptions'],
2668
+ * expires_in_days: 90
2669
+ * });
2670
+ *
2671
+ * // IMPORTANT: Store this key securely - it won't be shown again
2672
+ * console.log('API Key:', apiKey.key);
2673
+ * console.log('Prefix:', apiKey.prefix);
2674
+ * ```
2675
+ */
2676
+ create: (orgSlug: string, serviceSlug: string, payload: CreateApiKeyPayload) => Promise<ApiKeyCreateResponse>;
2677
+ /**
2678
+ * List all API keys for a service.
2679
+ * Note: The full key values are not included in this response.
2680
+ *
2681
+ * @param orgSlug Organization slug
2682
+ * @param serviceSlug Service slug
2683
+ * @param options Optional query parameters for pagination
2684
+ * @returns List of API keys with metadata
2685
+ *
2686
+ * @example
2687
+ * ```typescript
2688
+ * const result = await sso.services.apiKeys.list('acme-corp', 'main-app', {
2689
+ * limit: 50,
2690
+ * offset: 0
2691
+ * });
2692
+ *
2693
+ * console.log(`Total API keys: ${result.total}`);
2694
+ * result.api_keys.forEach(key => {
2695
+ * console.log(`${key.name} (${key.prefix})`);
2696
+ * console.log(`Permissions: ${key.permissions.join(', ')}`);
2697
+ * console.log(`Last used: ${key.last_used_at || 'Never'}`);
2698
+ * });
2699
+ * ```
2700
+ */
2701
+ list: (orgSlug: string, serviceSlug: string, options?: {
2702
+ limit?: number;
2703
+ offset?: number;
2704
+ }) => Promise<ListApiKeysResponse>;
2705
+ /**
2706
+ * Get details for a specific API key.
2707
+ * Note: The full key value is not included in this response.
2708
+ *
2709
+ * @param orgSlug Organization slug
2710
+ * @param serviceSlug Service slug
2711
+ * @param apiKeyId API key ID
2712
+ * @returns API key details
2713
+ *
2714
+ * @example
2715
+ * ```typescript
2716
+ * const apiKey = await sso.services.apiKeys.get('acme-corp', 'main-app', 'key_abc123');
2717
+ * console.log(`Name: ${apiKey.name}`);
2718
+ * console.log(`Permissions: ${apiKey.permissions.join(', ')}`);
2719
+ * console.log(`Expires: ${apiKey.expires_at || 'Never'}`);
2720
+ * ```
2721
+ */
2722
+ get: (orgSlug: string, serviceSlug: string, apiKeyId: string) => Promise<ApiKey>;
2723
+ /**
2724
+ * Delete an API key.
2725
+ * Requires 'owner' or 'admin' role.
2726
+ *
2727
+ * WARNING: This action is immediate and cannot be undone.
2728
+ * Any services using this key will lose access immediately.
2729
+ *
2730
+ * @param orgSlug Organization slug
2731
+ * @param serviceSlug Service slug
2732
+ * @param apiKeyId API key ID
2733
+ *
2734
+ * @example
2735
+ * ```typescript
2736
+ * await sso.services.apiKeys.delete('acme-corp', 'main-app', 'key_abc123');
2737
+ * console.log('API key deleted successfully');
2738
+ * ```
2739
+ */
2740
+ delete: (orgSlug: string, serviceSlug: string, apiKeyId: string) => Promise<void>;
2741
+ };
2742
+ /**
2743
+ * SAML 2.0 Identity Provider (IdP) management methods
2744
+ *
2745
+ * Configure your service as a SAML IdP to enable SSO into third-party applications
2746
+ * (Salesforce, AWS, Google Workspace, etc.)
2747
+ */
2748
+ saml: {
2749
+ /**
2750
+ * Configure SAML IdP settings for a service.
2751
+ * Requires 'owner' or 'admin' role.
2752
+ *
2753
+ * @param orgSlug Organization slug
2754
+ * @param serviceSlug Service slug
2755
+ * @param payload SAML configuration payload
2756
+ * @returns Configuration success response
2757
+ *
2758
+ * @example
2759
+ * ```typescript
2760
+ * const result = await sso.services.saml.configure('acme-corp', 'main-app', {
2761
+ * enabled: true,
2762
+ * entity_id: 'https://salesforce.example.com',
2763
+ * acs_url: 'https://salesforce.example.com/saml/acs',
2764
+ * name_id_format: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress',
2765
+ * attribute_mapping: {
2766
+ * email: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'
2767
+ * },
2768
+ * sign_assertions: true,
2769
+ * sign_response: true
2770
+ * });
2771
+ * ```
2772
+ */
2773
+ configure: (orgSlug: string, serviceSlug: string, payload: ConfigureSamlPayload) => Promise<ConfigureSamlResponse>;
2774
+ /**
2775
+ * Get current SAML IdP configuration for a service.
2776
+ *
2777
+ * @param orgSlug Organization slug
2778
+ * @param serviceSlug Service slug
2779
+ * @returns Current SAML configuration
2780
+ *
2781
+ * @example
2782
+ * ```typescript
2783
+ * const config = await sso.services.saml.getConfig('acme-corp', 'main-app');
2784
+ * if (config.enabled && config.has_certificate) {
2785
+ * console.log('SAML IdP is ready');
2786
+ * console.log('Entity ID:', config.entity_id);
2787
+ * console.log('ACS URL:', config.acs_url);
2788
+ * }
2789
+ * ```
2790
+ */
2791
+ getConfig: (orgSlug: string, serviceSlug: string) => Promise<SamlConfig>;
2792
+ /**
2793
+ * Delete SAML IdP configuration and deactivate all certificates.
2794
+ * Requires 'owner' or 'admin' role.
2795
+ *
2796
+ * WARNING: This will break SSO for all third-party applications using this IdP.
2797
+ *
2798
+ * @param orgSlug Organization slug
2799
+ * @param serviceSlug Service slug
2800
+ *
2801
+ * @example
2802
+ * ```typescript
2803
+ * await sso.services.saml.deleteConfig('acme-corp', 'main-app');
2804
+ * console.log('SAML IdP configuration deleted');
2805
+ * ```
2806
+ */
2807
+ deleteConfig: (orgSlug: string, serviceSlug: string) => Promise<ConfigureSamlResponse>;
2808
+ /**
2809
+ * Generate a new SAML signing certificate for the IdP.
1385
2810
  * Requires 'owner' or 'admin' role.
1386
2811
  *
2812
+ * IMPORTANT: This automatically deactivates any existing active certificates.
2813
+ * Provide the returned certificate to your Service Provider during SAML setup.
2814
+ *
1387
2815
  * @param orgSlug Organization slug
1388
- * @param provider OAuth provider
1389
- * @param payload OAuth credentials
1390
- * @returns Created/updated credentials (without secret)
2816
+ * @param serviceSlug Service slug
2817
+ * @returns Certificate information including public key
1391
2818
  *
1392
2819
  * @example
1393
2820
  * ```typescript
1394
- * await sso.organizations.oauthCredentials.set('acme-corp', 'github', {
1395
- * client_id: 'Iv1.abc123',
1396
- * client_secret: 'secret-value'
1397
- * });
2821
+ * const cert = await sso.services.saml.generateCertificate('acme-corp', 'main-app');
2822
+ * console.log('Certificate generated, valid until:', cert.valid_until);
2823
+ * console.log('Public certificate:\n', cert.public_key);
2824
+ * // Provide cert.public_key to your Service Provider
1398
2825
  * ```
1399
2826
  */
1400
- set: (orgSlug: string, provider: OAuthProvider, payload: SetOAuthCredentialsPayload) => Promise<OAuthCredentials>;
2827
+ generateCertificate: (orgSlug: string, serviceSlug: string) => Promise<SamlCertificate>;
1401
2828
  /**
1402
- * Get the configured OAuth credentials for a provider.
1403
- * The secret is never returned.
2829
+ * Get the active SAML signing certificate.
1404
2830
  *
1405
2831
  * @param orgSlug Organization slug
1406
- * @param provider OAuth provider
1407
- * @returns OAuth credentials (without secret)
2832
+ * @param serviceSlug Service slug
2833
+ * @returns Active certificate information
1408
2834
  *
1409
2835
  * @example
1410
2836
  * ```typescript
1411
- * const creds = await sso.organizations.oauthCredentials.get('acme-corp', 'github');
1412
- * console.log(creds.client_id);
2837
+ * try {
2838
+ * const cert = await sso.services.saml.getCertificate('acme-corp', 'main-app');
2839
+ * console.log('Certificate expires:', cert.valid_until);
2840
+ * } catch (error) {
2841
+ * console.log('No active certificate - generate one first');
2842
+ * }
1413
2843
  * ```
1414
2844
  */
1415
- get: (orgSlug: string, provider: OAuthProvider) => Promise<OAuthCredentials>;
1416
- };
1417
- }
1418
-
1419
- /**
1420
- * Service management methods
1421
- */
1422
- declare class ServicesModule {
1423
- private http;
1424
- constructor(http: HttpClient);
1425
- /**
1426
- * Create a new service for an organization.
1427
- * Requires 'owner' or 'admin' role.
1428
- *
1429
- * @param orgSlug Organization slug
1430
- * @param payload Service creation payload
1431
- * @returns Created service with details
1432
- *
1433
- * @example
1434
- * ```typescript
1435
- * const result = await sso.services.create('acme-corp', {
1436
- * slug: 'main-app',
1437
- * name: 'Main Application',
1438
- * service_type: 'web',
1439
- * github_scopes: ['user:email', 'read:org'],
1440
- * redirect_uris: ['https://app.acme.com/callback']
1441
- * });
1442
- * console.log(result.service.client_id);
1443
- * ```
1444
- */
1445
- create(orgSlug: string, payload: CreateServicePayload): Promise<CreateServiceResponse>;
1446
- /**
1447
- * List all services for an organization.
1448
- *
1449
- * @param orgSlug Organization slug
1450
- * @returns Service list response with usage metadata
1451
- *
1452
- * @example
1453
- * ```typescript
1454
- * const result = await sso.services.list('acme-corp');
1455
- * console.log(`Using ${result.usage.current_services} of ${result.usage.max_services} services`);
1456
- * result.services.forEach(svc => console.log(svc.name, svc.client_id));
1457
- * ```
1458
- */
1459
- list(orgSlug: string): Promise<ServiceListResponse>;
1460
- /**
1461
- * Get detailed information for a specific service.
1462
- *
1463
- * @param orgSlug Organization slug
1464
- * @param serviceSlug Service slug
1465
- * @returns Service with provider grants and plans
1466
- *
1467
- * @example
1468
- * ```typescript
1469
- * const service = await sso.services.get('acme-corp', 'main-app');
1470
- * console.log(service.service.redirect_uris);
1471
- * console.log(service.plans);
1472
- * ```
1473
- */
1474
- get(orgSlug: string, serviceSlug: string): Promise<ServiceResponse>;
1475
- /**
1476
- * Update service configuration.
1477
- * Requires 'owner' or 'admin' role.
1478
- *
1479
- * @param orgSlug Organization slug
1480
- * @param serviceSlug Service slug
1481
- * @param payload Update payload
1482
- * @returns Updated service
1483
- *
1484
- * @example
1485
- * ```typescript
1486
- * const updated = await sso.services.update('acme-corp', 'main-app', {
1487
- * name: 'Main Application v2',
1488
- * redirect_uris: ['https://app.acme.com/callback', 'https://app.acme.com/oauth']
1489
- * });
1490
- * ```
1491
- */
1492
- update(orgSlug: string, serviceSlug: string, payload: UpdateServicePayload): Promise<Service>;
1493
- /**
1494
- * Delete a service.
1495
- * Requires 'owner' role.
1496
- *
1497
- * @param orgSlug Organization slug
1498
- * @param serviceSlug Service slug
1499
- *
1500
- * @example
1501
- * ```typescript
1502
- * await sso.services.delete('acme-corp', 'old-app');
1503
- * ```
1504
- */
1505
- delete(orgSlug: string, serviceSlug: string): Promise<void>;
1506
- /**
1507
- * Plan management methods
1508
- */
1509
- plans: {
2845
+ getCertificate: (orgSlug: string, serviceSlug: string) => Promise<SamlCertificate>;
1510
2846
  /**
1511
- * Create a new subscription plan for a service.
1512
- * Requires 'owner' or 'admin' role.
2847
+ * Get the SAML IdP metadata URL for this service.
2848
+ * This URL can be provided to Service Providers for automatic configuration.
1513
2849
  *
2850
+ * @param baseURL SSO platform base URL
1514
2851
  * @param orgSlug Organization slug
1515
2852
  * @param serviceSlug Service slug
1516
- * @param payload Plan creation payload
1517
- * @returns Created plan
2853
+ * @returns Metadata URL
1518
2854
  *
1519
2855
  * @example
1520
2856
  * ```typescript
1521
- * const plan = await sso.services.plans.create('acme-corp', 'main-app', {
1522
- * name: 'pro',
1523
- * description: 'Pro tier with advanced features',
1524
- * price_monthly: 29.99,
1525
- * features: ['api-access', 'advanced-analytics', 'priority-support']
1526
- * });
2857
+ * const metadataUrl = sso.services.saml.getMetadataUrl(
2858
+ * 'https://sso.example.com',
2859
+ * 'acme-corp',
2860
+ * 'main-app'
2861
+ * );
2862
+ * console.log('Provide this URL to your SP:', metadataUrl);
2863
+ * // https://sso.example.com/saml/acme-corp/main-app/metadata
1527
2864
  * ```
1528
2865
  */
1529
- create: (orgSlug: string, serviceSlug: string, payload: CreatePlanPayload) => Promise<Plan>;
2866
+ getMetadataUrl: (baseURL: string, orgSlug: string, serviceSlug: string) => string;
1530
2867
  /**
1531
- * List all plans for a service.
2868
+ * Get the SAML SSO endpoint URL for this service.
2869
+ * This is where Service Providers should redirect users to initiate SSO.
1532
2870
  *
2871
+ * @param baseURL SSO platform base URL
1533
2872
  * @param orgSlug Organization slug
1534
2873
  * @param serviceSlug Service slug
1535
- * @returns Array of plans
2874
+ * @returns SSO endpoint URL
1536
2875
  *
1537
2876
  * @example
1538
2877
  * ```typescript
1539
- * const plans = await sso.services.plans.list('acme-corp', 'main-app');
1540
- * plans.forEach(plan => console.log(plan.name, plan.price_monthly));
2878
+ * const ssoUrl = sso.services.saml.getSsoUrl(
2879
+ * 'https://sso.example.com',
2880
+ * 'acme-corp',
2881
+ * 'main-app'
2882
+ * );
2883
+ * console.log('SSO endpoint:', ssoUrl);
2884
+ * // https://sso.example.com/saml/acme-corp/main-app/sso
1541
2885
  * ```
1542
2886
  */
1543
- list: (orgSlug: string, serviceSlug: string) => Promise<Plan[]>;
2887
+ getSsoUrl: (baseURL: string, orgSlug: string, serviceSlug: string) => string;
1544
2888
  };
1545
2889
  }
1546
2890
 
@@ -1743,6 +3087,31 @@ declare class PlatformModule {
1743
3087
  * ```
1744
3088
  */
1745
3089
  updateTier: (orgId: string, payload: UpdateOrganizationTierPayload) => Promise<Organization>;
3090
+ /**
3091
+ * Delete an organization and all its associated data.
3092
+ * This is a destructive operation that cannot be undone.
3093
+ * Only platform owners can delete organizations.
3094
+ *
3095
+ * All related data will be cascaded deleted including:
3096
+ * - Members and invitations
3097
+ * - Services and plans
3098
+ * - Subscriptions
3099
+ * - OAuth credentials
3100
+ * - Audit logs
3101
+ *
3102
+ * @param orgId Organization ID
3103
+ * @returns Success confirmation
3104
+ *
3105
+ * @example
3106
+ * ```typescript
3107
+ * const result = await sso.platform.organizations.delete('org-id');
3108
+ * console.log(result.message); // 'Organization deleted successfully'
3109
+ * ```
3110
+ */
3111
+ delete: (orgId: string) => Promise<{
3112
+ success: boolean;
3113
+ message: string;
3114
+ }>;
1746
3115
  };
1747
3116
  /**
1748
3117
  * Promote an existing user to platform owner.
@@ -1768,6 +3137,70 @@ declare class PlatformModule {
1768
3137
  * ```
1769
3138
  */
1770
3139
  demoteOwner(userId: string): Promise<void>;
3140
+ /**
3141
+ * User MFA management methods for platform administrators
3142
+ */
3143
+ users: {
3144
+ /**
3145
+ * Get MFA status for a specific user.
3146
+ *
3147
+ * @param userId The ID of the user
3148
+ * @returns MFA status information
3149
+ *
3150
+ * @example
3151
+ * ```typescript
3152
+ * const mfaStatus = await sso.platform.users.getMfaStatus('user-uuid-here');
3153
+ * console.log(mfaStatus.enabled, mfaStatus.has_backup_codes);
3154
+ * ```
3155
+ */
3156
+ getMfaStatus: (userId: string) => Promise<{
3157
+ enabled: boolean;
3158
+ has_backup_codes: boolean;
3159
+ }>;
3160
+ /**
3161
+ * Search users by email address or user ID.
3162
+ *
3163
+ * @param query The search query (email or user ID)
3164
+ * @param limit Optional maximum number of results (default: 10, max: 50)
3165
+ * @returns Array of matching users
3166
+ *
3167
+ * @example
3168
+ * ```typescript
3169
+ * const users = await sso.platform.users.search('john@example.com');
3170
+ * console.log(users); // [{ id: 'user-uuid', email: 'john@example.com', ... }]
3171
+ *
3172
+ * // Search by user ID
3173
+ * const users = await sso.platform.users.search('user-uuid-here');
3174
+ *
3175
+ * // Limit results
3176
+ * const users = await sso.platform.users.search('john@', { limit: 5 });
3177
+ * ```
3178
+ */
3179
+ search: (query: string, options?: {
3180
+ limit?: number;
3181
+ }) => Promise<Array<{
3182
+ id: string;
3183
+ email: string;
3184
+ is_platform_owner: boolean;
3185
+ created_at: string;
3186
+ }>>;
3187
+ /**
3188
+ * Force disable MFA for a user (emergency access).
3189
+ *
3190
+ * @param userId The ID of the user
3191
+ * @returns Success confirmation
3192
+ *
3193
+ * @example
3194
+ * ```typescript
3195
+ * await sso.platform.users.forceDisableMfa('user-uuid-here');
3196
+ * console.log('MFA disabled for user');
3197
+ * ```
3198
+ */
3199
+ forceDisableMfa: (userId: string) => Promise<{
3200
+ success: boolean;
3201
+ message: string;
3202
+ }>;
3203
+ };
1771
3204
  /**
1772
3205
  * Retrieve the platform-wide audit log with optional filters.
1773
3206
  *
@@ -1871,6 +3304,155 @@ declare class PlatformModule {
1871
3304
  };
1872
3305
  }
1873
3306
 
3307
+ /**
3308
+ * Request body for creating a user
3309
+ */
3310
+ interface CreateUserRequest {
3311
+ email: string;
3312
+ }
3313
+ /**
3314
+ * Request body for updating a user
3315
+ */
3316
+ interface UpdateUserRequest {
3317
+ email?: string;
3318
+ }
3319
+ /**
3320
+ * Request body for creating a subscription
3321
+ */
3322
+ interface CreateSubscriptionRequest {
3323
+ user_id: string;
3324
+ plan_id: string;
3325
+ status?: string;
3326
+ current_period_end?: string;
3327
+ }
3328
+ /**
3329
+ * Request body for updating a subscription
3330
+ */
3331
+ interface UpdateSubscriptionRequest {
3332
+ status?: string;
3333
+ current_period_end?: string;
3334
+ }
3335
+ /**
3336
+ * Request body for updating service info
3337
+ */
3338
+ interface UpdateServiceInfoRequest {
3339
+ name?: string;
3340
+ }
3341
+ /**
3342
+ * Service API User response
3343
+ */
3344
+ interface ServiceApiUser {
3345
+ id: string;
3346
+ email: string;
3347
+ created_at: string;
3348
+ }
3349
+ /**
3350
+ * Service API Subscription response
3351
+ */
3352
+ interface ServiceApiSubscription {
3353
+ id: string;
3354
+ user_id: string;
3355
+ plan_id: string;
3356
+ plan_name: string;
3357
+ status: string;
3358
+ current_period_end: string;
3359
+ }
3360
+ /**
3361
+ * Service API info response
3362
+ */
3363
+ interface ServiceApiInfo {
3364
+ id: string;
3365
+ name: string;
3366
+ slug: string;
3367
+ service_type: string;
3368
+ created_at: string;
3369
+ }
3370
+ /**
3371
+ * Service API module for API key-based service-to-service operations.
3372
+ * Provides write operations for managing users, subscriptions, and service configuration.
3373
+ *
3374
+ * @example
3375
+ * ```typescript
3376
+ * const sso = new SsoClient({
3377
+ * baseURL: 'https://sso.example.com',
3378
+ * apiKey: 'sk_live_abcd1234...'
3379
+ * });
3380
+ *
3381
+ * // Create a user
3382
+ * const user = await sso.serviceApi.createUser({ email: 'user@example.com' });
3383
+ *
3384
+ * // Create a subscription
3385
+ * const subscription = await sso.serviceApi.createSubscription({
3386
+ * user_id: user.id,
3387
+ * plan_id: 'plan_123',
3388
+ * status: 'active'
3389
+ * });
3390
+ *
3391
+ * // Update user
3392
+ * await sso.serviceApi.updateUser(user.id, { email: 'newemail@example.com' });
3393
+ * ```
3394
+ */
3395
+ declare class ServiceApiModule {
3396
+ private http;
3397
+ constructor(http: HttpClient);
3398
+ /**
3399
+ * Create a new user
3400
+ * Requires 'write:users' permission on the API key
3401
+ *
3402
+ * @param request User creation request
3403
+ * @returns Created user
3404
+ */
3405
+ createUser(request: CreateUserRequest): Promise<ServiceApiUser>;
3406
+ /**
3407
+ * Update user details
3408
+ * Requires 'write:users' permission on the API key
3409
+ *
3410
+ * @param userId User ID to update
3411
+ * @param request User update request
3412
+ * @returns Updated user
3413
+ */
3414
+ updateUser(userId: string, request: UpdateUserRequest): Promise<ServiceApiUser>;
3415
+ /**
3416
+ * Create a new subscription for a user
3417
+ * Requires 'write:subscriptions' permission on the API key
3418
+ *
3419
+ * @param request Subscription creation request
3420
+ * @returns Created subscription
3421
+ */
3422
+ createSubscription(request: CreateSubscriptionRequest): Promise<ServiceApiSubscription>;
3423
+ /**
3424
+ * Update a subscription for a user
3425
+ * Requires 'write:subscriptions' permission on the API key
3426
+ *
3427
+ * @param userId User ID whose subscription to update
3428
+ * @param request Subscription update request
3429
+ * @returns Updated subscription
3430
+ */
3431
+ updateSubscription(userId: string, request: UpdateSubscriptionRequest): Promise<ServiceApiSubscription>;
3432
+ /**
3433
+ * Update service configuration
3434
+ * Requires 'write:service' permission on the API key
3435
+ *
3436
+ * @param request Service update request
3437
+ * @returns Updated service info
3438
+ */
3439
+ updateServiceInfo(request: UpdateServiceInfoRequest): Promise<ServiceApiInfo>;
3440
+ /**
3441
+ * Delete a user
3442
+ * Requires 'delete:users' permission on the API key
3443
+ *
3444
+ * @param userId User ID to delete
3445
+ */
3446
+ deleteUser(userId: string): Promise<void>;
3447
+ /**
3448
+ * Delete a subscription for a user
3449
+ * Requires 'delete:subscriptions' permission on the API key
3450
+ *
3451
+ * @param userId User ID whose subscription to delete
3452
+ */
3453
+ deleteSubscription(userId: string): Promise<void>;
3454
+ }
3455
+
1874
3456
  /**
1875
3457
  * Configuration options for the SSO client
1876
3458
  */
@@ -1880,9 +3462,13 @@ interface SsoClientOptions {
1880
3462
  */
1881
3463
  baseURL: string;
1882
3464
  /**
1883
- * Optional JWT token to initialize with
3465
+ * Optional JWT token to initialize with (for user authentication)
1884
3466
  */
1885
3467
  token?: string;
3468
+ /**
3469
+ * Optional API key for service-to-service authentication
3470
+ */
3471
+ apiKey?: string;
1886
3472
  }
1887
3473
  /**
1888
3474
  * Main SSO client class.
@@ -1892,7 +3478,7 @@ interface SsoClientOptions {
1892
3478
  * ```typescript
1893
3479
  * const sso = new SsoClient({
1894
3480
  * baseURL: 'https://sso.example.com',
1895
- * token: localStorage.getItem('jwt')
3481
+ * token: localStorage.getItem('sso_access_token')
1896
3482
  * });
1897
3483
  *
1898
3484
  * // Use the modules
@@ -1930,6 +3516,10 @@ declare class SsoClient {
1930
3516
  * Platform owner administration methods
1931
3517
  */
1932
3518
  readonly platform: PlatformModule;
3519
+ /**
3520
+ * Service API methods (requires API key authentication)
3521
+ */
3522
+ readonly serviceApi: ServiceApiModule;
1933
3523
  constructor(options: SsoClientOptions);
1934
3524
  /**
1935
3525
  * Sets the JWT for all subsequent authenticated requests.
@@ -1947,6 +3537,22 @@ declare class SsoClient {
1947
3537
  * ```
1948
3538
  */
1949
3539
  setAuthToken(token: string | null): void;
3540
+ /**
3541
+ * Sets the API key for service-to-service authentication.
3542
+ * Pass null to clear the API key.
3543
+ *
3544
+ * @param apiKey The API key string, or null to clear
3545
+ *
3546
+ * @example
3547
+ * ```typescript
3548
+ * // Set API key
3549
+ * sso.setApiKey('sk_live_abcd1234...');
3550
+ *
3551
+ * // Clear API key
3552
+ * sso.setApiKey(null);
3553
+ * ```
3554
+ */
3555
+ setApiKey(apiKey: string | null): void;
1950
3556
  /**
1951
3557
  * Gets the current base URL
1952
3558
  */
@@ -1989,4 +3595,4 @@ declare class SsoApiError extends Error {
1989
3595
  isNotFound(): boolean;
1990
3596
  }
1991
3597
 
1992
- export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApproveOrganizationPayload, type AuditLogEntry, AuthModule, type CreateInvitationPayload, type CreateOrganizationPayload, type CreateOrganizationResponse, type CreatePlanPayload, type CreateServicePayload, type CreateServiceResponse, type DeclineInvitationPayload, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceVerifyResponse, type EndUser, type EndUserDetailResponse, type EndUserIdentity, type EndUserListResponse, type EndUserSubscription, type GetAuditLogParams, type GrowthTrendPoint, type Identity, type Invitation, type InvitationStatus, type InvitationWithOrg, InvitationsModule, type JwtClaims, type ListEndUsersParams, type ListOrganizationsParams, type ListPlatformOrganizationsParams, type LoginActivityPoint, type LoginTrendPoint, type LoginUrlParams, type LoginsByProvider, type LoginsByService, type MemberListResponse, type MemberRole, type Membership, type OAuthCredentials, type OAuthProvider, type Organization, type OrganizationMember, type OrganizationResponse, type OrganizationStatus, type OrganizationStatusBreakdown, type OrganizationTier, OrganizationsModule, type PaginatedResponse, type PaginationParams, type Plan, type PlatformAnalyticsDateRangeParams, PlatformModule, type PlatformOrganizationResponse, type PlatformOrganizationsListResponse, type PlatformOverviewMetrics, type PromotePlatformOwnerPayload, type ProviderToken, type ProviderTokenGrant, type RecentLogin, type RecentOrganization, type RefreshTokenRequest, type RefreshTokenResponse, type RejectOrganizationPayload, type RevokeSessionsResponse, type Service, type ServiceListResponse, type ServiceResponse, type ServiceType, type ServiceWithDetails, ServicesModule, type SetOAuthCredentialsPayload, SsoApiError, SsoClient, type SsoClientOptions, type StartLinkResponse, type Subscription, type TokenRequest, type TokenResponse, type TopOrganization, type TransferOwnershipPayload, type UpdateMemberRolePayload, type UpdateOrganizationPayload, type UpdateOrganizationTierPayload, type UpdateServicePayload, type UpdateUserProfilePayload, type User, UserModule, type UserProfile };
3598
+ export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthModule, type BackupCodesResponse, type BrandingConfiguration, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, type CreateApiKeyPayload, type CreateInvitationPayload, type CreateOrganizationPayload, type CreateOrganizationResponse, type CreatePlanPayload, type CreateServicePayload, type CreateServiceResponse, type CreateWebhookRequest, type DeclineInvitationPayload, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceVerifyResponse, type DomainConfiguration, type DomainVerificationMethod, type DomainVerificationResponse, type DomainVerificationResult, type EndUser, type EndUserDetailResponse, type EndUserIdentity, type EndUserListResponse, type EndUserSubscription, type EventTypeInfo, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetAuditLogParams, type GrowthTrendPoint, type Identity, type Invitation, type InvitationStatus, type InvitationWithOrg, InvitationsModule, type JwtClaims, type ListApiKeysResponse, type ListEndUsersParams, type ListOrganizationsParams, type ListPlatformOrganizationsParams, type LoginActivityPoint, type LoginRequest, type LoginTrendPoint, type LoginUrlParams, type LoginsByProvider, type LoginsByService, type MemberListResponse, type MemberRole, type Membership, type MfaSetupResponse, type MfaStatusResponse, type MfaVerificationRequest, type MfaVerificationResponse, type MfaVerifyRequest, type MfaVerifyResponse, type OAuthCredentials, type OAuthProvider, type Organization, type OrganizationMember, type OrganizationResponse, type OrganizationStatus, type OrganizationStatusBreakdown, type OrganizationTier, OrganizationsModule, type PaginatedResponse, type PaginationInfo, type PaginationParams, type Plan, type PlanResponse, type PlatformAnalyticsDateRangeParams, PlatformModule, type PlatformOrganizationResponse, type PlatformOrganizationsListResponse, type PlatformOverviewMetrics, type PromotePlatformOwnerPayload, type ProviderToken, type ProviderTokenGrant, type RecentLogin, type RecentOrganization, type RefreshTokenRequest, type RefreshTokenResponse, type RegisterRequest, type RegisterResponse, type RejectOrganizationPayload, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeSessionsResponse, type SamlCertificate, type SamlConfig, type Service, ServiceApiModule, type ServiceListResponse, type ServiceResponse, type ServiceType, type ServiceWithDetails, ServicesModule, type SetCustomDomainRequest, type SetOAuthCredentialsPayload, type SetPasswordRequest, type SetPasswordResponse, type SetSmtpRequest, type SmtpConfigResponse, SsoApiError, SsoClient, type SsoClientOptions, type StartLinkResponse, type Subscription, type TokenRequest, type TokenResponse, type TopOrganization, type TransferOwnershipPayload, type UpdateBrandingRequest, type UpdateMemberRolePayload, type UpdateOrganizationPayload, type UpdateOrganizationTierPayload, type UpdatePlanPayload, type UpdateServicePayload, type UpdateUserProfilePayload, type UpdateWebhookRequest, type User, UserModule, type UserProfile, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQueryParams, type WebhookListResponse, type WebhookResponse };