@drmhse/sso-sdk 0.1.1 → 0.2.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/README.md +86 -303
- package/dist/index.d.mts +222 -1
- package/dist/index.d.ts +222 -1
- package/dist/index.js +172 -0
- package/dist/index.mjs +172 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -181,6 +181,14 @@ interface DeviceCodeResponse {
|
|
|
181
181
|
expires_in: number;
|
|
182
182
|
interval: number;
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Device verify response - returns context for initiating OAuth flow
|
|
186
|
+
*/
|
|
187
|
+
interface DeviceVerifyResponse {
|
|
188
|
+
org_slug: string;
|
|
189
|
+
service_slug: string;
|
|
190
|
+
available_providers: string[];
|
|
191
|
+
}
|
|
184
192
|
/**
|
|
185
193
|
* Token request payload for device flow
|
|
186
194
|
*/
|
|
@@ -213,6 +221,10 @@ interface LoginUrlParams {
|
|
|
213
221
|
* Optional redirect URI (must be registered with the service)
|
|
214
222
|
*/
|
|
215
223
|
redirect_uri?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Optional user code for device flow authorization
|
|
226
|
+
*/
|
|
227
|
+
user_code?: string;
|
|
216
228
|
}
|
|
217
229
|
/**
|
|
218
230
|
* Parameters for constructing admin login URL
|
|
@@ -222,6 +234,10 @@ interface AdminLoginUrlParams {
|
|
|
222
234
|
* Optional organization slug to manage
|
|
223
235
|
*/
|
|
224
236
|
org_slug?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Optional user code for device flow authorization
|
|
239
|
+
*/
|
|
240
|
+
user_code?: string;
|
|
225
241
|
}
|
|
226
242
|
/**
|
|
227
243
|
* Provider token response
|
|
@@ -233,6 +249,20 @@ interface ProviderToken {
|
|
|
233
249
|
scopes: string[];
|
|
234
250
|
provider: OAuthProvider;
|
|
235
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Refresh token request payload
|
|
254
|
+
*/
|
|
255
|
+
interface RefreshTokenRequest {
|
|
256
|
+
refresh_token: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Refresh token response
|
|
260
|
+
*/
|
|
261
|
+
interface RefreshTokenResponse {
|
|
262
|
+
access_token: string;
|
|
263
|
+
refresh_token: string;
|
|
264
|
+
expires_in: number;
|
|
265
|
+
}
|
|
236
266
|
|
|
237
267
|
/**
|
|
238
268
|
* User subscription details
|
|
@@ -416,6 +446,7 @@ interface Service {
|
|
|
416
446
|
microsoft_scopes: string[];
|
|
417
447
|
google_scopes: string[];
|
|
418
448
|
redirect_uris: string[];
|
|
449
|
+
device_activation_uri?: string;
|
|
419
450
|
created_at: string;
|
|
420
451
|
}
|
|
421
452
|
/**
|
|
@@ -452,6 +483,7 @@ interface CreateServicePayload {
|
|
|
452
483
|
microsoft_scopes?: string[];
|
|
453
484
|
google_scopes?: string[];
|
|
454
485
|
redirect_uris: string[];
|
|
486
|
+
device_activation_uri?: string;
|
|
455
487
|
}
|
|
456
488
|
/**
|
|
457
489
|
* Create service response
|
|
@@ -476,6 +508,7 @@ interface UpdateServicePayload {
|
|
|
476
508
|
microsoft_scopes?: string[];
|
|
477
509
|
google_scopes?: string[];
|
|
478
510
|
redirect_uris?: string[];
|
|
511
|
+
device_activation_uri?: string;
|
|
479
512
|
}
|
|
480
513
|
/**
|
|
481
514
|
* Service response with details
|
|
@@ -645,6 +678,69 @@ interface GetAuditLogParams extends PaginationParams {
|
|
|
645
678
|
start_date?: string;
|
|
646
679
|
end_date?: string;
|
|
647
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Platform overview metrics
|
|
683
|
+
*/
|
|
684
|
+
interface PlatformOverviewMetrics {
|
|
685
|
+
total_organizations: number;
|
|
686
|
+
total_users: number;
|
|
687
|
+
total_end_users: number;
|
|
688
|
+
total_services: number;
|
|
689
|
+
total_logins_24h: number;
|
|
690
|
+
total_logins_30d: number;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Organization status breakdown
|
|
694
|
+
*/
|
|
695
|
+
interface OrganizationStatusBreakdown {
|
|
696
|
+
pending: number;
|
|
697
|
+
active: number;
|
|
698
|
+
suspended: number;
|
|
699
|
+
rejected: number;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Growth trend data point
|
|
703
|
+
*/
|
|
704
|
+
interface GrowthTrendPoint {
|
|
705
|
+
date: string;
|
|
706
|
+
new_organizations: number;
|
|
707
|
+
new_users: number;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Login activity data point
|
|
711
|
+
*/
|
|
712
|
+
interface LoginActivityPoint {
|
|
713
|
+
date: string;
|
|
714
|
+
count: number;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Top organization metrics
|
|
718
|
+
*/
|
|
719
|
+
interface TopOrganization {
|
|
720
|
+
id: string;
|
|
721
|
+
name: string;
|
|
722
|
+
slug: string;
|
|
723
|
+
user_count: number;
|
|
724
|
+
service_count: number;
|
|
725
|
+
login_count_30d: number;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Recent organization data
|
|
729
|
+
*/
|
|
730
|
+
interface RecentOrganization {
|
|
731
|
+
id: string;
|
|
732
|
+
name: string;
|
|
733
|
+
slug: string;
|
|
734
|
+
status: OrganizationStatus;
|
|
735
|
+
created_at: string;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Platform analytics date range query params
|
|
739
|
+
*/
|
|
740
|
+
interface PlatformAnalyticsDateRangeParams {
|
|
741
|
+
start_date?: string;
|
|
742
|
+
end_date?: string;
|
|
743
|
+
}
|
|
648
744
|
|
|
649
745
|
/**
|
|
650
746
|
* End-user subscription details
|
|
@@ -886,6 +982,20 @@ declare class AuthModule {
|
|
|
886
982
|
* Request a device code
|
|
887
983
|
*/
|
|
888
984
|
request: (payload: DeviceCodeRequest) => Promise<DeviceCodeResponse>;
|
|
985
|
+
/**
|
|
986
|
+
* Verify a user code and get the context (org_slug, service_slug)
|
|
987
|
+
* needed for the UI to initiate the appropriate OAuth flow.
|
|
988
|
+
*
|
|
989
|
+
* @param userCode The user-friendly code displayed on the device
|
|
990
|
+
* @returns Context with organization and service information
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```typescript
|
|
994
|
+
* const context = await sso.auth.deviceCode.verify('ABCD-1234');
|
|
995
|
+
* // Use context.org_slug and context.service_slug to determine which OAuth flow to initiate
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
verify: (userCode: string) => Promise<DeviceVerifyResponse>;
|
|
889
999
|
/**
|
|
890
1000
|
* Exchange a device code for a JWT token.
|
|
891
1001
|
* This should be polled by the device/CLI after displaying the user code.
|
|
@@ -929,6 +1039,32 @@ declare class AuthModule {
|
|
|
929
1039
|
* ```
|
|
930
1040
|
*/
|
|
931
1041
|
logout(): Promise<void>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Refresh an expired JWT access token using a refresh token.
|
|
1044
|
+
* This implements token rotation - both the access token and refresh token
|
|
1045
|
+
* will be renewed with each call.
|
|
1046
|
+
*
|
|
1047
|
+
* The refresh token must be stored securely on the client side.
|
|
1048
|
+
* After a successful refresh, update both tokens in storage and call
|
|
1049
|
+
* `sso.setAuthToken(newAccessToken)`.
|
|
1050
|
+
*
|
|
1051
|
+
* @param refreshToken The refresh token obtained during login
|
|
1052
|
+
* @returns New access token and refresh token pair
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```typescript
|
|
1056
|
+
* try {
|
|
1057
|
+
* const tokens = await sso.auth.refreshToken(storedRefreshToken);
|
|
1058
|
+
* sso.setAuthToken(tokens.access_token);
|
|
1059
|
+
* localStorage.setItem('access_token', tokens.access_token);
|
|
1060
|
+
* localStorage.setItem('refresh_token', tokens.refresh_token);
|
|
1061
|
+
* } catch (error) {
|
|
1062
|
+
* // Refresh failed - redirect to login
|
|
1063
|
+
* window.location.href = '/login';
|
|
1064
|
+
* }
|
|
1065
|
+
* ```
|
|
1066
|
+
*/
|
|
1067
|
+
refreshToken(refreshToken: string): Promise<RefreshTokenResponse>;
|
|
932
1068
|
/**
|
|
933
1069
|
* Get a fresh provider access token for the authenticated user.
|
|
934
1070
|
* This will automatically refresh the token if it's expired.
|
|
@@ -1636,6 +1772,91 @@ declare class PlatformModule {
|
|
|
1636
1772
|
* ```
|
|
1637
1773
|
*/
|
|
1638
1774
|
getAuditLog(params?: GetAuditLogParams): Promise<AuditLogEntry[]>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Platform analytics methods
|
|
1777
|
+
*/
|
|
1778
|
+
analytics: {
|
|
1779
|
+
/**
|
|
1780
|
+
* Get platform overview metrics.
|
|
1781
|
+
*
|
|
1782
|
+
* @returns Platform overview metrics
|
|
1783
|
+
*
|
|
1784
|
+
* @example
|
|
1785
|
+
* ```typescript
|
|
1786
|
+
* const metrics = await sso.platform.analytics.getOverview();
|
|
1787
|
+
* console.log(metrics.total_organizations, metrics.total_users);
|
|
1788
|
+
* ```
|
|
1789
|
+
*/
|
|
1790
|
+
getOverview: () => Promise<PlatformOverviewMetrics>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Get organization status breakdown.
|
|
1793
|
+
*
|
|
1794
|
+
* @returns Organization count by status
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* ```typescript
|
|
1798
|
+
* const breakdown = await sso.platform.analytics.getOrganizationStatus();
|
|
1799
|
+
* console.log(breakdown.pending, breakdown.active);
|
|
1800
|
+
* ```
|
|
1801
|
+
*/
|
|
1802
|
+
getOrganizationStatus: () => Promise<OrganizationStatusBreakdown>;
|
|
1803
|
+
/**
|
|
1804
|
+
* Get platform growth trends over time.
|
|
1805
|
+
*
|
|
1806
|
+
* @param params Optional date range parameters
|
|
1807
|
+
* @returns Array of growth trend data points
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* ```typescript
|
|
1811
|
+
* const trends = await sso.platform.analytics.getGrowthTrends({
|
|
1812
|
+
* start_date: '2024-01-01',
|
|
1813
|
+
* end_date: '2024-01-31'
|
|
1814
|
+
* });
|
|
1815
|
+
* ```
|
|
1816
|
+
*/
|
|
1817
|
+
getGrowthTrends: (params?: PlatformAnalyticsDateRangeParams) => Promise<GrowthTrendPoint[]>;
|
|
1818
|
+
/**
|
|
1819
|
+
* Get platform-wide login activity trends.
|
|
1820
|
+
*
|
|
1821
|
+
* @param params Optional date range parameters
|
|
1822
|
+
* @returns Array of login activity data points
|
|
1823
|
+
*
|
|
1824
|
+
* @example
|
|
1825
|
+
* ```typescript
|
|
1826
|
+
* const activity = await sso.platform.analytics.getLoginActivity({
|
|
1827
|
+
* start_date: '2024-01-01',
|
|
1828
|
+
* end_date: '2024-01-31'
|
|
1829
|
+
* });
|
|
1830
|
+
* ```
|
|
1831
|
+
*/
|
|
1832
|
+
getLoginActivity: (params?: PlatformAnalyticsDateRangeParams) => Promise<LoginActivityPoint[]>;
|
|
1833
|
+
/**
|
|
1834
|
+
* Get top organizations by activity.
|
|
1835
|
+
*
|
|
1836
|
+
* @returns Array of top organizations
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```typescript
|
|
1840
|
+
* const topOrgs = await sso.platform.analytics.getTopOrganizations();
|
|
1841
|
+
* console.log(topOrgs[0].login_count_30d);
|
|
1842
|
+
* ```
|
|
1843
|
+
*/
|
|
1844
|
+
getTopOrganizations: () => Promise<TopOrganization[]>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Get recently created organizations.
|
|
1847
|
+
*
|
|
1848
|
+
* @param params Optional query parameters
|
|
1849
|
+
* @returns Array of recent organizations
|
|
1850
|
+
*
|
|
1851
|
+
* @example
|
|
1852
|
+
* ```typescript
|
|
1853
|
+
* const recent = await sso.platform.analytics.getRecentOrganizations({
|
|
1854
|
+
* limit: 10
|
|
1855
|
+
* });
|
|
1856
|
+
* ```
|
|
1857
|
+
*/
|
|
1858
|
+
getRecentOrganizations: (params?: GetAuditLogParams) => Promise<RecentOrganization[]>;
|
|
1859
|
+
};
|
|
1639
1860
|
}
|
|
1640
1861
|
|
|
1641
1862
|
/**
|
|
@@ -1756,4 +1977,4 @@ declare class SsoApiError extends Error {
|
|
|
1756
1977
|
isNotFound(): boolean;
|
|
1757
1978
|
}
|
|
1758
1979
|
|
|
1759
|
-
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 EndUser, type EndUserDetailResponse, type EndUserIdentity, type EndUserListResponse, type EndUserSubscription, type GetAuditLogParams, type Identity, type Invitation, type InvitationStatus, type InvitationWithOrg, InvitationsModule, type JwtClaims, type ListEndUsersParams, type ListOrganizationsParams, type ListPlatformOrganizationsParams, 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 OrganizationTier, OrganizationsModule, type PaginatedResponse, type PaginationParams, type Plan, PlatformModule, type PlatformOrganizationResponse, type PlatformOrganizationsListResponse, type PromotePlatformOwnerPayload, type ProviderToken, type ProviderTokenGrant, type RecentLogin, 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 TransferOwnershipPayload, type UpdateMemberRolePayload, type UpdateOrganizationPayload, type UpdateOrganizationTierPayload, type UpdateServicePayload, type UpdateUserProfilePayload, type User, UserModule, type UserProfile };
|
|
1980
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -181,6 +181,14 @@ interface DeviceCodeResponse {
|
|
|
181
181
|
expires_in: number;
|
|
182
182
|
interval: number;
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Device verify response - returns context for initiating OAuth flow
|
|
186
|
+
*/
|
|
187
|
+
interface DeviceVerifyResponse {
|
|
188
|
+
org_slug: string;
|
|
189
|
+
service_slug: string;
|
|
190
|
+
available_providers: string[];
|
|
191
|
+
}
|
|
184
192
|
/**
|
|
185
193
|
* Token request payload for device flow
|
|
186
194
|
*/
|
|
@@ -213,6 +221,10 @@ interface LoginUrlParams {
|
|
|
213
221
|
* Optional redirect URI (must be registered with the service)
|
|
214
222
|
*/
|
|
215
223
|
redirect_uri?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Optional user code for device flow authorization
|
|
226
|
+
*/
|
|
227
|
+
user_code?: string;
|
|
216
228
|
}
|
|
217
229
|
/**
|
|
218
230
|
* Parameters for constructing admin login URL
|
|
@@ -222,6 +234,10 @@ interface AdminLoginUrlParams {
|
|
|
222
234
|
* Optional organization slug to manage
|
|
223
235
|
*/
|
|
224
236
|
org_slug?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Optional user code for device flow authorization
|
|
239
|
+
*/
|
|
240
|
+
user_code?: string;
|
|
225
241
|
}
|
|
226
242
|
/**
|
|
227
243
|
* Provider token response
|
|
@@ -233,6 +249,20 @@ interface ProviderToken {
|
|
|
233
249
|
scopes: string[];
|
|
234
250
|
provider: OAuthProvider;
|
|
235
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Refresh token request payload
|
|
254
|
+
*/
|
|
255
|
+
interface RefreshTokenRequest {
|
|
256
|
+
refresh_token: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Refresh token response
|
|
260
|
+
*/
|
|
261
|
+
interface RefreshTokenResponse {
|
|
262
|
+
access_token: string;
|
|
263
|
+
refresh_token: string;
|
|
264
|
+
expires_in: number;
|
|
265
|
+
}
|
|
236
266
|
|
|
237
267
|
/**
|
|
238
268
|
* User subscription details
|
|
@@ -416,6 +446,7 @@ interface Service {
|
|
|
416
446
|
microsoft_scopes: string[];
|
|
417
447
|
google_scopes: string[];
|
|
418
448
|
redirect_uris: string[];
|
|
449
|
+
device_activation_uri?: string;
|
|
419
450
|
created_at: string;
|
|
420
451
|
}
|
|
421
452
|
/**
|
|
@@ -452,6 +483,7 @@ interface CreateServicePayload {
|
|
|
452
483
|
microsoft_scopes?: string[];
|
|
453
484
|
google_scopes?: string[];
|
|
454
485
|
redirect_uris: string[];
|
|
486
|
+
device_activation_uri?: string;
|
|
455
487
|
}
|
|
456
488
|
/**
|
|
457
489
|
* Create service response
|
|
@@ -476,6 +508,7 @@ interface UpdateServicePayload {
|
|
|
476
508
|
microsoft_scopes?: string[];
|
|
477
509
|
google_scopes?: string[];
|
|
478
510
|
redirect_uris?: string[];
|
|
511
|
+
device_activation_uri?: string;
|
|
479
512
|
}
|
|
480
513
|
/**
|
|
481
514
|
* Service response with details
|
|
@@ -645,6 +678,69 @@ interface GetAuditLogParams extends PaginationParams {
|
|
|
645
678
|
start_date?: string;
|
|
646
679
|
end_date?: string;
|
|
647
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Platform overview metrics
|
|
683
|
+
*/
|
|
684
|
+
interface PlatformOverviewMetrics {
|
|
685
|
+
total_organizations: number;
|
|
686
|
+
total_users: number;
|
|
687
|
+
total_end_users: number;
|
|
688
|
+
total_services: number;
|
|
689
|
+
total_logins_24h: number;
|
|
690
|
+
total_logins_30d: number;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Organization status breakdown
|
|
694
|
+
*/
|
|
695
|
+
interface OrganizationStatusBreakdown {
|
|
696
|
+
pending: number;
|
|
697
|
+
active: number;
|
|
698
|
+
suspended: number;
|
|
699
|
+
rejected: number;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Growth trend data point
|
|
703
|
+
*/
|
|
704
|
+
interface GrowthTrendPoint {
|
|
705
|
+
date: string;
|
|
706
|
+
new_organizations: number;
|
|
707
|
+
new_users: number;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Login activity data point
|
|
711
|
+
*/
|
|
712
|
+
interface LoginActivityPoint {
|
|
713
|
+
date: string;
|
|
714
|
+
count: number;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Top organization metrics
|
|
718
|
+
*/
|
|
719
|
+
interface TopOrganization {
|
|
720
|
+
id: string;
|
|
721
|
+
name: string;
|
|
722
|
+
slug: string;
|
|
723
|
+
user_count: number;
|
|
724
|
+
service_count: number;
|
|
725
|
+
login_count_30d: number;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Recent organization data
|
|
729
|
+
*/
|
|
730
|
+
interface RecentOrganization {
|
|
731
|
+
id: string;
|
|
732
|
+
name: string;
|
|
733
|
+
slug: string;
|
|
734
|
+
status: OrganizationStatus;
|
|
735
|
+
created_at: string;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Platform analytics date range query params
|
|
739
|
+
*/
|
|
740
|
+
interface PlatformAnalyticsDateRangeParams {
|
|
741
|
+
start_date?: string;
|
|
742
|
+
end_date?: string;
|
|
743
|
+
}
|
|
648
744
|
|
|
649
745
|
/**
|
|
650
746
|
* End-user subscription details
|
|
@@ -886,6 +982,20 @@ declare class AuthModule {
|
|
|
886
982
|
* Request a device code
|
|
887
983
|
*/
|
|
888
984
|
request: (payload: DeviceCodeRequest) => Promise<DeviceCodeResponse>;
|
|
985
|
+
/**
|
|
986
|
+
* Verify a user code and get the context (org_slug, service_slug)
|
|
987
|
+
* needed for the UI to initiate the appropriate OAuth flow.
|
|
988
|
+
*
|
|
989
|
+
* @param userCode The user-friendly code displayed on the device
|
|
990
|
+
* @returns Context with organization and service information
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```typescript
|
|
994
|
+
* const context = await sso.auth.deviceCode.verify('ABCD-1234');
|
|
995
|
+
* // Use context.org_slug and context.service_slug to determine which OAuth flow to initiate
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
verify: (userCode: string) => Promise<DeviceVerifyResponse>;
|
|
889
999
|
/**
|
|
890
1000
|
* Exchange a device code for a JWT token.
|
|
891
1001
|
* This should be polled by the device/CLI after displaying the user code.
|
|
@@ -929,6 +1039,32 @@ declare class AuthModule {
|
|
|
929
1039
|
* ```
|
|
930
1040
|
*/
|
|
931
1041
|
logout(): Promise<void>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Refresh an expired JWT access token using a refresh token.
|
|
1044
|
+
* This implements token rotation - both the access token and refresh token
|
|
1045
|
+
* will be renewed with each call.
|
|
1046
|
+
*
|
|
1047
|
+
* The refresh token must be stored securely on the client side.
|
|
1048
|
+
* After a successful refresh, update both tokens in storage and call
|
|
1049
|
+
* `sso.setAuthToken(newAccessToken)`.
|
|
1050
|
+
*
|
|
1051
|
+
* @param refreshToken The refresh token obtained during login
|
|
1052
|
+
* @returns New access token and refresh token pair
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```typescript
|
|
1056
|
+
* try {
|
|
1057
|
+
* const tokens = await sso.auth.refreshToken(storedRefreshToken);
|
|
1058
|
+
* sso.setAuthToken(tokens.access_token);
|
|
1059
|
+
* localStorage.setItem('access_token', tokens.access_token);
|
|
1060
|
+
* localStorage.setItem('refresh_token', tokens.refresh_token);
|
|
1061
|
+
* } catch (error) {
|
|
1062
|
+
* // Refresh failed - redirect to login
|
|
1063
|
+
* window.location.href = '/login';
|
|
1064
|
+
* }
|
|
1065
|
+
* ```
|
|
1066
|
+
*/
|
|
1067
|
+
refreshToken(refreshToken: string): Promise<RefreshTokenResponse>;
|
|
932
1068
|
/**
|
|
933
1069
|
* Get a fresh provider access token for the authenticated user.
|
|
934
1070
|
* This will automatically refresh the token if it's expired.
|
|
@@ -1636,6 +1772,91 @@ declare class PlatformModule {
|
|
|
1636
1772
|
* ```
|
|
1637
1773
|
*/
|
|
1638
1774
|
getAuditLog(params?: GetAuditLogParams): Promise<AuditLogEntry[]>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Platform analytics methods
|
|
1777
|
+
*/
|
|
1778
|
+
analytics: {
|
|
1779
|
+
/**
|
|
1780
|
+
* Get platform overview metrics.
|
|
1781
|
+
*
|
|
1782
|
+
* @returns Platform overview metrics
|
|
1783
|
+
*
|
|
1784
|
+
* @example
|
|
1785
|
+
* ```typescript
|
|
1786
|
+
* const metrics = await sso.platform.analytics.getOverview();
|
|
1787
|
+
* console.log(metrics.total_organizations, metrics.total_users);
|
|
1788
|
+
* ```
|
|
1789
|
+
*/
|
|
1790
|
+
getOverview: () => Promise<PlatformOverviewMetrics>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Get organization status breakdown.
|
|
1793
|
+
*
|
|
1794
|
+
* @returns Organization count by status
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* ```typescript
|
|
1798
|
+
* const breakdown = await sso.platform.analytics.getOrganizationStatus();
|
|
1799
|
+
* console.log(breakdown.pending, breakdown.active);
|
|
1800
|
+
* ```
|
|
1801
|
+
*/
|
|
1802
|
+
getOrganizationStatus: () => Promise<OrganizationStatusBreakdown>;
|
|
1803
|
+
/**
|
|
1804
|
+
* Get platform growth trends over time.
|
|
1805
|
+
*
|
|
1806
|
+
* @param params Optional date range parameters
|
|
1807
|
+
* @returns Array of growth trend data points
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* ```typescript
|
|
1811
|
+
* const trends = await sso.platform.analytics.getGrowthTrends({
|
|
1812
|
+
* start_date: '2024-01-01',
|
|
1813
|
+
* end_date: '2024-01-31'
|
|
1814
|
+
* });
|
|
1815
|
+
* ```
|
|
1816
|
+
*/
|
|
1817
|
+
getGrowthTrends: (params?: PlatformAnalyticsDateRangeParams) => Promise<GrowthTrendPoint[]>;
|
|
1818
|
+
/**
|
|
1819
|
+
* Get platform-wide login activity trends.
|
|
1820
|
+
*
|
|
1821
|
+
* @param params Optional date range parameters
|
|
1822
|
+
* @returns Array of login activity data points
|
|
1823
|
+
*
|
|
1824
|
+
* @example
|
|
1825
|
+
* ```typescript
|
|
1826
|
+
* const activity = await sso.platform.analytics.getLoginActivity({
|
|
1827
|
+
* start_date: '2024-01-01',
|
|
1828
|
+
* end_date: '2024-01-31'
|
|
1829
|
+
* });
|
|
1830
|
+
* ```
|
|
1831
|
+
*/
|
|
1832
|
+
getLoginActivity: (params?: PlatformAnalyticsDateRangeParams) => Promise<LoginActivityPoint[]>;
|
|
1833
|
+
/**
|
|
1834
|
+
* Get top organizations by activity.
|
|
1835
|
+
*
|
|
1836
|
+
* @returns Array of top organizations
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```typescript
|
|
1840
|
+
* const topOrgs = await sso.platform.analytics.getTopOrganizations();
|
|
1841
|
+
* console.log(topOrgs[0].login_count_30d);
|
|
1842
|
+
* ```
|
|
1843
|
+
*/
|
|
1844
|
+
getTopOrganizations: () => Promise<TopOrganization[]>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Get recently created organizations.
|
|
1847
|
+
*
|
|
1848
|
+
* @param params Optional query parameters
|
|
1849
|
+
* @returns Array of recent organizations
|
|
1850
|
+
*
|
|
1851
|
+
* @example
|
|
1852
|
+
* ```typescript
|
|
1853
|
+
* const recent = await sso.platform.analytics.getRecentOrganizations({
|
|
1854
|
+
* limit: 10
|
|
1855
|
+
* });
|
|
1856
|
+
* ```
|
|
1857
|
+
*/
|
|
1858
|
+
getRecentOrganizations: (params?: GetAuditLogParams) => Promise<RecentOrganization[]>;
|
|
1859
|
+
};
|
|
1639
1860
|
}
|
|
1640
1861
|
|
|
1641
1862
|
/**
|
|
@@ -1756,4 +1977,4 @@ declare class SsoApiError extends Error {
|
|
|
1756
1977
|
isNotFound(): boolean;
|
|
1757
1978
|
}
|
|
1758
1979
|
|
|
1759
|
-
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 EndUser, type EndUserDetailResponse, type EndUserIdentity, type EndUserListResponse, type EndUserSubscription, type GetAuditLogParams, type Identity, type Invitation, type InvitationStatus, type InvitationWithOrg, InvitationsModule, type JwtClaims, type ListEndUsersParams, type ListOrganizationsParams, type ListPlatformOrganizationsParams, 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 OrganizationTier, OrganizationsModule, type PaginatedResponse, type PaginationParams, type Plan, PlatformModule, type PlatformOrganizationResponse, type PlatformOrganizationsListResponse, type PromotePlatformOwnerPayload, type ProviderToken, type ProviderTokenGrant, type RecentLogin, 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 TransferOwnershipPayload, type UpdateMemberRolePayload, type UpdateOrganizationPayload, type UpdateOrganizationTierPayload, type UpdateServicePayload, type UpdateUserProfilePayload, type User, UserModule, type UserProfile };
|
|
1980
|
+
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 };
|