@drmhse/sso-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +400 -0
- package/dist/index.d.mts +1759 -0
- package/dist/index.d.ts +1759 -0
- package/dist/index.js +1386 -0
- package/dist/index.mjs +1352 -0
- package/package.json +47 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1759 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP response wrapper
|
|
3
|
+
*/
|
|
4
|
+
interface HttpResponse<T = any> {
|
|
5
|
+
data: T;
|
|
6
|
+
status: number;
|
|
7
|
+
headers: Headers;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* HTTP client defaults
|
|
11
|
+
*/
|
|
12
|
+
interface HttpDefaults {
|
|
13
|
+
baseURL: string;
|
|
14
|
+
headers: {
|
|
15
|
+
common: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
timeout: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Custom HTTP client using native fetch API.
|
|
21
|
+
* Provides an interface similar to Axios for easy migration.
|
|
22
|
+
*/
|
|
23
|
+
declare class HttpClient {
|
|
24
|
+
defaults: HttpDefaults;
|
|
25
|
+
constructor(baseURL: string);
|
|
26
|
+
/**
|
|
27
|
+
* Build query string from params object
|
|
28
|
+
*/
|
|
29
|
+
private buildQueryString;
|
|
30
|
+
/**
|
|
31
|
+
* Build full URL from path and params
|
|
32
|
+
*/
|
|
33
|
+
private buildUrl;
|
|
34
|
+
/**
|
|
35
|
+
* Make HTTP request with timeout support
|
|
36
|
+
*/
|
|
37
|
+
private request;
|
|
38
|
+
/**
|
|
39
|
+
* GET request
|
|
40
|
+
*/
|
|
41
|
+
get<T = any>(path: string, config?: {
|
|
42
|
+
params?: Record<string, any>;
|
|
43
|
+
headers?: Record<string, string>;
|
|
44
|
+
}): Promise<HttpResponse<T>>;
|
|
45
|
+
/**
|
|
46
|
+
* POST request
|
|
47
|
+
*/
|
|
48
|
+
post<T = any>(path: string, data?: any, config?: {
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
}): Promise<HttpResponse<T>>;
|
|
51
|
+
/**
|
|
52
|
+
* PATCH request
|
|
53
|
+
*/
|
|
54
|
+
patch<T = any>(path: string, data?: any, config?: {
|
|
55
|
+
headers?: Record<string, string>;
|
|
56
|
+
}): Promise<HttpResponse<T>>;
|
|
57
|
+
/**
|
|
58
|
+
* DELETE request
|
|
59
|
+
*/
|
|
60
|
+
delete<T = any>(path: string, config?: {
|
|
61
|
+
headers?: Record<string, string>;
|
|
62
|
+
}): Promise<HttpResponse<T>>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Common types used across the SDK
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* Represents a user in the system.
|
|
70
|
+
*/
|
|
71
|
+
interface User {
|
|
72
|
+
id: string;
|
|
73
|
+
email: string;
|
|
74
|
+
is_platform_owner: boolean;
|
|
75
|
+
created_at: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* User profile response (includes context from JWT)
|
|
79
|
+
*/
|
|
80
|
+
interface UserProfile {
|
|
81
|
+
id: string;
|
|
82
|
+
email: string;
|
|
83
|
+
org?: string;
|
|
84
|
+
service?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Paginated response wrapper
|
|
88
|
+
*/
|
|
89
|
+
interface PaginatedResponse<T> {
|
|
90
|
+
data: T[];
|
|
91
|
+
total: number;
|
|
92
|
+
page: number;
|
|
93
|
+
limit: number;
|
|
94
|
+
has_more: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Standard pagination parameters
|
|
98
|
+
*/
|
|
99
|
+
interface PaginationParams {
|
|
100
|
+
page?: number;
|
|
101
|
+
limit?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* OAuth provider types
|
|
105
|
+
*/
|
|
106
|
+
type OAuthProvider = 'github' | 'google' | 'microsoft';
|
|
107
|
+
/**
|
|
108
|
+
* Organization status types
|
|
109
|
+
*/
|
|
110
|
+
type OrganizationStatus = 'pending' | 'active' | 'suspended' | 'rejected';
|
|
111
|
+
/**
|
|
112
|
+
* Service types
|
|
113
|
+
*/
|
|
114
|
+
type ServiceType = 'web' | 'mobile' | 'desktop' | 'api';
|
|
115
|
+
/**
|
|
116
|
+
* Organization member roles
|
|
117
|
+
*/
|
|
118
|
+
type MemberRole = 'owner' | 'admin' | 'member';
|
|
119
|
+
/**
|
|
120
|
+
* Invitation status
|
|
121
|
+
*/
|
|
122
|
+
type InvitationStatus = 'pending' | 'accepted' | 'declined' | 'cancelled';
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* JWT Claims payload structure
|
|
126
|
+
*/
|
|
127
|
+
interface JwtClaims {
|
|
128
|
+
/**
|
|
129
|
+
* Subject - the user ID
|
|
130
|
+
*/
|
|
131
|
+
sub: string;
|
|
132
|
+
/**
|
|
133
|
+
* User's email address
|
|
134
|
+
*/
|
|
135
|
+
email: string;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the user is a platform owner
|
|
138
|
+
*/
|
|
139
|
+
is_platform_owner: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Organization slug (present in Org and Service JWTs)
|
|
142
|
+
*/
|
|
143
|
+
org?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Service slug (present only in Service JWTs)
|
|
146
|
+
*/
|
|
147
|
+
service?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Subscription plan name
|
|
150
|
+
*/
|
|
151
|
+
plan?: string;
|
|
152
|
+
/**
|
|
153
|
+
* List of enabled features
|
|
154
|
+
*/
|
|
155
|
+
features?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Expiration timestamp (Unix epoch)
|
|
158
|
+
*/
|
|
159
|
+
exp: number;
|
|
160
|
+
/**
|
|
161
|
+
* Issued at timestamp (Unix epoch)
|
|
162
|
+
*/
|
|
163
|
+
iat: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Device code request payload
|
|
168
|
+
*/
|
|
169
|
+
interface DeviceCodeRequest {
|
|
170
|
+
client_id: string;
|
|
171
|
+
org: string;
|
|
172
|
+
service: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Device code response
|
|
176
|
+
*/
|
|
177
|
+
interface DeviceCodeResponse {
|
|
178
|
+
device_code: string;
|
|
179
|
+
user_code: string;
|
|
180
|
+
verification_uri: string;
|
|
181
|
+
expires_in: number;
|
|
182
|
+
interval: number;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Token request payload for device flow
|
|
186
|
+
*/
|
|
187
|
+
interface TokenRequest {
|
|
188
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:device_code';
|
|
189
|
+
device_code: string;
|
|
190
|
+
client_id: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Token response
|
|
194
|
+
*/
|
|
195
|
+
interface TokenResponse {
|
|
196
|
+
access_token: string;
|
|
197
|
+
token_type: 'Bearer';
|
|
198
|
+
expires_in: number;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Parameters for constructing login URL
|
|
202
|
+
*/
|
|
203
|
+
interface LoginUrlParams {
|
|
204
|
+
/**
|
|
205
|
+
* Organization slug
|
|
206
|
+
*/
|
|
207
|
+
org: string;
|
|
208
|
+
/**
|
|
209
|
+
* Service slug
|
|
210
|
+
*/
|
|
211
|
+
service: string;
|
|
212
|
+
/**
|
|
213
|
+
* Optional redirect URI (must be registered with the service)
|
|
214
|
+
*/
|
|
215
|
+
redirect_uri?: string;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Parameters for constructing admin login URL
|
|
219
|
+
*/
|
|
220
|
+
interface AdminLoginUrlParams {
|
|
221
|
+
/**
|
|
222
|
+
* Optional organization slug to manage
|
|
223
|
+
*/
|
|
224
|
+
org_slug?: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Provider token response
|
|
228
|
+
*/
|
|
229
|
+
interface ProviderToken {
|
|
230
|
+
access_token: string;
|
|
231
|
+
refresh_token?: string;
|
|
232
|
+
expires_at: string;
|
|
233
|
+
scopes: string[];
|
|
234
|
+
provider: OAuthProvider;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* User subscription details
|
|
239
|
+
*/
|
|
240
|
+
interface Subscription {
|
|
241
|
+
service: string;
|
|
242
|
+
plan: string;
|
|
243
|
+
features: string[];
|
|
244
|
+
status: string;
|
|
245
|
+
current_period_end?: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Update user profile payload
|
|
249
|
+
*/
|
|
250
|
+
interface UpdateUserProfilePayload {
|
|
251
|
+
email?: string;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Social identity linked to the user
|
|
255
|
+
*/
|
|
256
|
+
interface Identity {
|
|
257
|
+
provider: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Response when starting a social account link
|
|
261
|
+
*/
|
|
262
|
+
interface StartLinkResponse {
|
|
263
|
+
authorization_url: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Organization entity
|
|
268
|
+
*/
|
|
269
|
+
interface Organization {
|
|
270
|
+
id: string;
|
|
271
|
+
slug: string;
|
|
272
|
+
name: string;
|
|
273
|
+
owner_user_id: string;
|
|
274
|
+
status: OrganizationStatus;
|
|
275
|
+
tier_id: string;
|
|
276
|
+
max_services?: number | null;
|
|
277
|
+
max_users?: number | null;
|
|
278
|
+
approved_by?: string | null;
|
|
279
|
+
approved_at?: string | null;
|
|
280
|
+
rejected_by?: string | null;
|
|
281
|
+
rejected_at?: string | null;
|
|
282
|
+
rejection_reason?: string | null;
|
|
283
|
+
created_at: string;
|
|
284
|
+
updated_at: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Organization tier details
|
|
288
|
+
*/
|
|
289
|
+
interface OrganizationTier {
|
|
290
|
+
id: string;
|
|
291
|
+
name: string;
|
|
292
|
+
display_name?: string;
|
|
293
|
+
default_max_services: number;
|
|
294
|
+
default_max_users: number;
|
|
295
|
+
features: string;
|
|
296
|
+
price_cents?: number;
|
|
297
|
+
currency?: string;
|
|
298
|
+
created_at: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Organization membership
|
|
302
|
+
*/
|
|
303
|
+
interface Membership {
|
|
304
|
+
id: string;
|
|
305
|
+
org_id: string;
|
|
306
|
+
user_id: string;
|
|
307
|
+
role: MemberRole;
|
|
308
|
+
created_at: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Organization response with metadata
|
|
312
|
+
*/
|
|
313
|
+
interface OrganizationResponse {
|
|
314
|
+
organization: Organization;
|
|
315
|
+
membership_count: number;
|
|
316
|
+
service_count: number;
|
|
317
|
+
tier: OrganizationTier;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Organization member details
|
|
321
|
+
*/
|
|
322
|
+
interface OrganizationMember {
|
|
323
|
+
user_id: string;
|
|
324
|
+
email: string;
|
|
325
|
+
role: MemberRole;
|
|
326
|
+
joined_at: string;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Create organization payload (public endpoint)
|
|
330
|
+
*/
|
|
331
|
+
interface CreateOrganizationPayload {
|
|
332
|
+
slug: string;
|
|
333
|
+
name: string;
|
|
334
|
+
owner_email: string;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Create organization response
|
|
338
|
+
*/
|
|
339
|
+
interface CreateOrganizationResponse {
|
|
340
|
+
organization: Organization;
|
|
341
|
+
owner: {
|
|
342
|
+
id: string;
|
|
343
|
+
email: string;
|
|
344
|
+
is_platform_owner: boolean;
|
|
345
|
+
created_at: string;
|
|
346
|
+
};
|
|
347
|
+
membership: Membership;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Update organization payload
|
|
351
|
+
*/
|
|
352
|
+
interface UpdateOrganizationPayload {
|
|
353
|
+
name?: string;
|
|
354
|
+
max_services?: number;
|
|
355
|
+
max_users?: number;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Update member role payload
|
|
359
|
+
*/
|
|
360
|
+
interface UpdateMemberRolePayload {
|
|
361
|
+
role: MemberRole;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Transfer ownership payload
|
|
365
|
+
*/
|
|
366
|
+
interface TransferOwnershipPayload {
|
|
367
|
+
new_owner_user_id: string;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* OAuth credentials payload
|
|
371
|
+
*/
|
|
372
|
+
interface SetOAuthCredentialsPayload {
|
|
373
|
+
client_id: string;
|
|
374
|
+
client_secret: string;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* OAuth credentials response (secret never returned)
|
|
378
|
+
*/
|
|
379
|
+
interface OAuthCredentials {
|
|
380
|
+
id: string;
|
|
381
|
+
org_id: string;
|
|
382
|
+
provider: OAuthProvider;
|
|
383
|
+
client_id: string;
|
|
384
|
+
created_at: string;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* List organizations query params
|
|
388
|
+
*/
|
|
389
|
+
interface ListOrganizationsParams extends PaginationParams {
|
|
390
|
+
status?: OrganizationStatus;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Member list response with pagination metadata
|
|
394
|
+
*/
|
|
395
|
+
interface MemberListResponse {
|
|
396
|
+
members: OrganizationMember[];
|
|
397
|
+
total: number;
|
|
398
|
+
limit: {
|
|
399
|
+
current: number;
|
|
400
|
+
max: number;
|
|
401
|
+
source: string;
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Service entity
|
|
407
|
+
*/
|
|
408
|
+
interface Service {
|
|
409
|
+
id: string;
|
|
410
|
+
org_id: string;
|
|
411
|
+
slug: string;
|
|
412
|
+
name: string;
|
|
413
|
+
service_type: ServiceType;
|
|
414
|
+
client_id: string;
|
|
415
|
+
github_scopes: string[];
|
|
416
|
+
microsoft_scopes: string[];
|
|
417
|
+
google_scopes: string[];
|
|
418
|
+
redirect_uris: string[];
|
|
419
|
+
created_at: string;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Provider token grant configuration
|
|
423
|
+
*/
|
|
424
|
+
interface ProviderTokenGrant {
|
|
425
|
+
id: string;
|
|
426
|
+
service_id: string;
|
|
427
|
+
provider: string;
|
|
428
|
+
scopes: string[];
|
|
429
|
+
created_at: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Subscription plan
|
|
433
|
+
*/
|
|
434
|
+
interface Plan {
|
|
435
|
+
id: string;
|
|
436
|
+
service_id: string;
|
|
437
|
+
name: string;
|
|
438
|
+
description?: string;
|
|
439
|
+
price_monthly?: number;
|
|
440
|
+
features: string[];
|
|
441
|
+
is_default: boolean;
|
|
442
|
+
created_at: string;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Create service payload
|
|
446
|
+
*/
|
|
447
|
+
interface CreateServicePayload {
|
|
448
|
+
slug: string;
|
|
449
|
+
name: string;
|
|
450
|
+
service_type: ServiceType;
|
|
451
|
+
github_scopes?: string[];
|
|
452
|
+
microsoft_scopes?: string[];
|
|
453
|
+
google_scopes?: string[];
|
|
454
|
+
redirect_uris: string[];
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Create service response
|
|
458
|
+
*/
|
|
459
|
+
interface CreateServiceResponse {
|
|
460
|
+
service: Service;
|
|
461
|
+
provider_grants: ProviderTokenGrant[];
|
|
462
|
+
default_plan: Plan;
|
|
463
|
+
usage: {
|
|
464
|
+
current_services: number;
|
|
465
|
+
max_services: number;
|
|
466
|
+
tier: string;
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Update service payload
|
|
471
|
+
*/
|
|
472
|
+
interface UpdateServicePayload {
|
|
473
|
+
name?: string;
|
|
474
|
+
service_type?: ServiceType;
|
|
475
|
+
github_scopes?: string[];
|
|
476
|
+
microsoft_scopes?: string[];
|
|
477
|
+
google_scopes?: string[];
|
|
478
|
+
redirect_uris?: string[];
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Service response with details
|
|
482
|
+
*/
|
|
483
|
+
interface ServiceResponse {
|
|
484
|
+
service: Service;
|
|
485
|
+
provider_grants: ProviderTokenGrant[];
|
|
486
|
+
plans: Plan[];
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Create plan payload
|
|
490
|
+
*/
|
|
491
|
+
interface CreatePlanPayload {
|
|
492
|
+
name: string;
|
|
493
|
+
description?: string;
|
|
494
|
+
price_monthly?: number;
|
|
495
|
+
features: string[];
|
|
496
|
+
is_default?: boolean;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Service with aggregated details
|
|
500
|
+
*/
|
|
501
|
+
interface ServiceWithDetails extends Service {
|
|
502
|
+
plan_count: number;
|
|
503
|
+
subscription_count: number;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Service list response with usage metadata
|
|
507
|
+
*/
|
|
508
|
+
interface ServiceListResponse {
|
|
509
|
+
services: ServiceWithDetails[];
|
|
510
|
+
usage: {
|
|
511
|
+
current_services: number;
|
|
512
|
+
max_services: number;
|
|
513
|
+
tier: string;
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Invitation entity
|
|
519
|
+
*/
|
|
520
|
+
interface Invitation {
|
|
521
|
+
id: string;
|
|
522
|
+
org_id: string;
|
|
523
|
+
inviter_user_id: string;
|
|
524
|
+
invitee_email: string;
|
|
525
|
+
role: MemberRole;
|
|
526
|
+
token: string;
|
|
527
|
+
status: InvitationStatus;
|
|
528
|
+
expires_at: string;
|
|
529
|
+
created_at: string;
|
|
530
|
+
updated_at: string;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Create invitation payload
|
|
534
|
+
*/
|
|
535
|
+
interface CreateInvitationPayload {
|
|
536
|
+
invitee_email: string;
|
|
537
|
+
role: MemberRole;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Accept invitation payload
|
|
541
|
+
*/
|
|
542
|
+
interface AcceptInvitationPayload {
|
|
543
|
+
token: string;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Decline invitation payload
|
|
547
|
+
*/
|
|
548
|
+
interface DeclineInvitationPayload {
|
|
549
|
+
token: string;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Invitation with organization details
|
|
553
|
+
*/
|
|
554
|
+
interface InvitationWithOrg extends Invitation {
|
|
555
|
+
organization_name: string;
|
|
556
|
+
organization_slug: string;
|
|
557
|
+
inviter_email: string;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Platform organization response with additional metadata
|
|
562
|
+
*/
|
|
563
|
+
interface PlatformOrganizationResponse {
|
|
564
|
+
id: string;
|
|
565
|
+
slug: string;
|
|
566
|
+
name: string;
|
|
567
|
+
owner_user_id: string;
|
|
568
|
+
status: OrganizationStatus;
|
|
569
|
+
tier_id: string;
|
|
570
|
+
max_services?: number | null;
|
|
571
|
+
max_users?: number | null;
|
|
572
|
+
approved_by?: string | null;
|
|
573
|
+
approved_at?: string | null;
|
|
574
|
+
rejected_by?: string | null;
|
|
575
|
+
rejected_at?: string | null;
|
|
576
|
+
rejection_reason?: string | null;
|
|
577
|
+
created_at: string;
|
|
578
|
+
updated_at: string;
|
|
579
|
+
tier: OrganizationTier;
|
|
580
|
+
owner: User;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Platform organizations list response
|
|
584
|
+
*/
|
|
585
|
+
interface PlatformOrganizationsListResponse {
|
|
586
|
+
organizations: PlatformOrganizationResponse[];
|
|
587
|
+
total: number;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Approve organization payload
|
|
591
|
+
*/
|
|
592
|
+
interface ApproveOrganizationPayload {
|
|
593
|
+
tier_id: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Reject organization payload
|
|
597
|
+
*/
|
|
598
|
+
interface RejectOrganizationPayload {
|
|
599
|
+
reason: string;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Update organization tier payload
|
|
603
|
+
*/
|
|
604
|
+
interface UpdateOrganizationTierPayload {
|
|
605
|
+
tier_id: string;
|
|
606
|
+
max_services?: number;
|
|
607
|
+
max_users?: number;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Promote user to platform owner payload
|
|
611
|
+
*/
|
|
612
|
+
interface PromotePlatformOwnerPayload {
|
|
613
|
+
user_id: string;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Audit log entry
|
|
617
|
+
*/
|
|
618
|
+
interface AuditLogEntry {
|
|
619
|
+
id: string;
|
|
620
|
+
user_id: string;
|
|
621
|
+
user_email: string;
|
|
622
|
+
action: string;
|
|
623
|
+
resource_type: string;
|
|
624
|
+
resource_id: string;
|
|
625
|
+
details?: Record<string, any>;
|
|
626
|
+
ip_address?: string;
|
|
627
|
+
user_agent?: string;
|
|
628
|
+
created_at: string;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* List platform organizations params
|
|
632
|
+
*/
|
|
633
|
+
interface ListPlatformOrganizationsParams extends PaginationParams {
|
|
634
|
+
status?: OrganizationStatus;
|
|
635
|
+
search?: string;
|
|
636
|
+
tier_id?: string;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Get audit log params
|
|
640
|
+
*/
|
|
641
|
+
interface GetAuditLogParams extends PaginationParams {
|
|
642
|
+
user_id?: string;
|
|
643
|
+
action?: string;
|
|
644
|
+
resource_type?: string;
|
|
645
|
+
start_date?: string;
|
|
646
|
+
end_date?: string;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* End-user subscription details
|
|
651
|
+
*/
|
|
652
|
+
interface EndUserSubscription {
|
|
653
|
+
service_id: string;
|
|
654
|
+
service_slug: string;
|
|
655
|
+
service_name: string;
|
|
656
|
+
plan_id: string;
|
|
657
|
+
plan_name: string;
|
|
658
|
+
status: string;
|
|
659
|
+
current_period_end: string;
|
|
660
|
+
created_at: string;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* End-user identity (OAuth provider link)
|
|
664
|
+
*/
|
|
665
|
+
interface EndUserIdentity {
|
|
666
|
+
provider: string;
|
|
667
|
+
provider_user_id: string;
|
|
668
|
+
created_at: string;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* End-user with subscriptions and identities
|
|
672
|
+
*/
|
|
673
|
+
interface EndUser {
|
|
674
|
+
user: {
|
|
675
|
+
id: string;
|
|
676
|
+
email: string;
|
|
677
|
+
is_platform_owner: boolean;
|
|
678
|
+
created_at: string;
|
|
679
|
+
};
|
|
680
|
+
subscriptions: EndUserSubscription[];
|
|
681
|
+
identities: EndUserIdentity[];
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* End-user list response
|
|
685
|
+
*/
|
|
686
|
+
interface EndUserListResponse {
|
|
687
|
+
users: EndUser[];
|
|
688
|
+
total: number;
|
|
689
|
+
page: number;
|
|
690
|
+
limit: number;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* End-user detail response with session info
|
|
694
|
+
*/
|
|
695
|
+
interface EndUserDetailResponse {
|
|
696
|
+
user: {
|
|
697
|
+
id: string;
|
|
698
|
+
email: string;
|
|
699
|
+
is_platform_owner: boolean;
|
|
700
|
+
created_at: string;
|
|
701
|
+
};
|
|
702
|
+
subscriptions: EndUserSubscription[];
|
|
703
|
+
identities: EndUserIdentity[];
|
|
704
|
+
session_count: number;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* List end-users query params
|
|
708
|
+
*/
|
|
709
|
+
interface ListEndUsersParams extends PaginationParams {
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Revoke sessions response
|
|
713
|
+
*/
|
|
714
|
+
interface RevokeSessionsResponse {
|
|
715
|
+
message: string;
|
|
716
|
+
revoked_count: number;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
interface LoginTrendPoint {
|
|
720
|
+
date: string;
|
|
721
|
+
count: number;
|
|
722
|
+
}
|
|
723
|
+
interface LoginsByService {
|
|
724
|
+
service_id: string;
|
|
725
|
+
service_name: string;
|
|
726
|
+
count: number;
|
|
727
|
+
}
|
|
728
|
+
interface LoginsByProvider {
|
|
729
|
+
provider: 'github' | 'google' | 'microsoft';
|
|
730
|
+
count: number;
|
|
731
|
+
}
|
|
732
|
+
interface RecentLogin {
|
|
733
|
+
id: string;
|
|
734
|
+
user_id: string;
|
|
735
|
+
service_id: string;
|
|
736
|
+
provider: string;
|
|
737
|
+
created_at: string;
|
|
738
|
+
}
|
|
739
|
+
interface AnalyticsQuery {
|
|
740
|
+
start_date?: string;
|
|
741
|
+
end_date?: string;
|
|
742
|
+
limit?: number;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Analytics and login tracking methods
|
|
747
|
+
*/
|
|
748
|
+
declare class AnalyticsModule {
|
|
749
|
+
private http;
|
|
750
|
+
constructor(http: HttpClient);
|
|
751
|
+
/**
|
|
752
|
+
* Get login trends over time.
|
|
753
|
+
* Returns daily login counts grouped by date.
|
|
754
|
+
*
|
|
755
|
+
* @param orgSlug Organization slug
|
|
756
|
+
* @param params Optional query parameters (date range)
|
|
757
|
+
* @returns Array of login trend data points
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const trends = await sso.analytics.getLoginTrends('acme-corp', {
|
|
762
|
+
* start_date: '2025-01-01',
|
|
763
|
+
* end_date: '2025-01-31'
|
|
764
|
+
* });
|
|
765
|
+
* trends.forEach(point => console.log(point.date, point.count));
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
getLoginTrends(orgSlug: string, params?: AnalyticsQuery): Promise<LoginTrendPoint[]>;
|
|
769
|
+
/**
|
|
770
|
+
* Get login counts grouped by service.
|
|
771
|
+
* Shows which services have the most authentication activity.
|
|
772
|
+
*
|
|
773
|
+
* @param orgSlug Organization slug
|
|
774
|
+
* @param params Optional query parameters (date range)
|
|
775
|
+
* @returns Array of login counts per service
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```typescript
|
|
779
|
+
* const byService = await sso.analytics.getLoginsByService('acme-corp', {
|
|
780
|
+
* start_date: '2025-01-01',
|
|
781
|
+
* end_date: '2025-01-31'
|
|
782
|
+
* });
|
|
783
|
+
* byService.forEach(s => console.log(s.service_name, s.count));
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
getLoginsByService(orgSlug: string, params?: AnalyticsQuery): Promise<LoginsByService[]>;
|
|
787
|
+
/**
|
|
788
|
+
* Get login counts grouped by OAuth provider.
|
|
789
|
+
* Shows which authentication providers are being used (GitHub, Google, Microsoft).
|
|
790
|
+
*
|
|
791
|
+
* @param orgSlug Organization slug
|
|
792
|
+
* @param params Optional query parameters (date range)
|
|
793
|
+
* @returns Array of login counts per provider
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```typescript
|
|
797
|
+
* const byProvider = await sso.analytics.getLoginsByProvider('acme-corp', {
|
|
798
|
+
* start_date: '2025-01-01',
|
|
799
|
+
* end_date: '2025-01-31'
|
|
800
|
+
* });
|
|
801
|
+
* byProvider.forEach(p => console.log(p.provider, p.count));
|
|
802
|
+
* ```
|
|
803
|
+
*/
|
|
804
|
+
getLoginsByProvider(orgSlug: string, params?: AnalyticsQuery): Promise<LoginsByProvider[]>;
|
|
805
|
+
/**
|
|
806
|
+
* Get the most recent login events.
|
|
807
|
+
*
|
|
808
|
+
* @param orgSlug Organization slug
|
|
809
|
+
* @param params Optional query parameters (limit)
|
|
810
|
+
* @returns Array of recent login events
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```typescript
|
|
814
|
+
* const recentLogins = await sso.analytics.getRecentLogins('acme-corp', {
|
|
815
|
+
* limit: 10
|
|
816
|
+
* });
|
|
817
|
+
* recentLogins.forEach(login => {
|
|
818
|
+
* console.log(login.user_id, login.provider, login.created_at);
|
|
819
|
+
* });
|
|
820
|
+
* ```
|
|
821
|
+
*/
|
|
822
|
+
getRecentLogins(orgSlug: string, params?: AnalyticsQuery): Promise<RecentLogin[]>;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Authentication and OAuth flow methods
|
|
827
|
+
*/
|
|
828
|
+
declare class AuthModule {
|
|
829
|
+
private http;
|
|
830
|
+
constructor(http: HttpClient);
|
|
831
|
+
/**
|
|
832
|
+
* Constructs the OAuth login URL for end-users.
|
|
833
|
+
* This does not perform the redirect; the consuming application
|
|
834
|
+
* should redirect the user's browser to this URL.
|
|
835
|
+
*
|
|
836
|
+
* @param provider The OAuth provider to use
|
|
837
|
+
* @param params Login parameters (org, service, redirect_uri)
|
|
838
|
+
* @returns The full URL to redirect the user to
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* ```typescript
|
|
842
|
+
* const url = sso.auth.getLoginUrl('github', {
|
|
843
|
+
* org: 'acme-corp',
|
|
844
|
+
* service: 'main-app',
|
|
845
|
+
* redirect_uri: 'https://app.acme.com/callback'
|
|
846
|
+
* });
|
|
847
|
+
* window.location.href = url;
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
getLoginUrl(provider: OAuthProvider, params: LoginUrlParams): string;
|
|
851
|
+
/**
|
|
852
|
+
* Constructs the OAuth login URL for platform/organization admins.
|
|
853
|
+
* This uses the platform's dedicated OAuth credentials.
|
|
854
|
+
*
|
|
855
|
+
* @param provider The OAuth provider to use
|
|
856
|
+
* @param params Optional admin login parameters
|
|
857
|
+
* @returns The full URL to redirect the admin to
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* ```typescript
|
|
861
|
+
* const url = sso.auth.getAdminLoginUrl('github', {
|
|
862
|
+
* org_slug: 'acme-corp'
|
|
863
|
+
* });
|
|
864
|
+
* window.location.href = url;
|
|
865
|
+
* ```
|
|
866
|
+
*/
|
|
867
|
+
getAdminLoginUrl(provider: OAuthProvider, params?: AdminLoginUrlParams): string;
|
|
868
|
+
/**
|
|
869
|
+
* Device Flow: Request a device code for CLI/device authentication.
|
|
870
|
+
*
|
|
871
|
+
* @param payload Device code request payload
|
|
872
|
+
* @returns Device code response with user code and verification URI
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```typescript
|
|
876
|
+
* const response = await sso.auth.deviceCode.request({
|
|
877
|
+
* client_id: 'service-client-id',
|
|
878
|
+
* org: 'acme-corp',
|
|
879
|
+
* service: 'acme-cli'
|
|
880
|
+
* });
|
|
881
|
+
* console.log(`Visit ${response.verification_uri} and enter code: ${response.user_code}`);
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
deviceCode: {
|
|
885
|
+
/**
|
|
886
|
+
* Request a device code
|
|
887
|
+
*/
|
|
888
|
+
request: (payload: DeviceCodeRequest) => Promise<DeviceCodeResponse>;
|
|
889
|
+
/**
|
|
890
|
+
* Exchange a device code for a JWT token.
|
|
891
|
+
* This should be polled by the device/CLI after displaying the user code.
|
|
892
|
+
*
|
|
893
|
+
* @param payload Token request payload
|
|
894
|
+
* @returns Token response with JWT
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```typescript
|
|
898
|
+
* // Poll every 5 seconds
|
|
899
|
+
* const interval = setInterval(async () => {
|
|
900
|
+
* try {
|
|
901
|
+
* const token = await sso.auth.deviceCode.exchangeToken({
|
|
902
|
+
* grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
903
|
+
* device_code: deviceCode,
|
|
904
|
+
* client_id: 'service-client-id'
|
|
905
|
+
* });
|
|
906
|
+
* clearInterval(interval);
|
|
907
|
+
* sso.setAuthToken(token.access_token);
|
|
908
|
+
* } catch (error) {
|
|
909
|
+
* if (error.errorCode !== 'authorization_pending') {
|
|
910
|
+
* clearInterval(interval);
|
|
911
|
+
* throw error;
|
|
912
|
+
* }
|
|
913
|
+
* }
|
|
914
|
+
* }, 5000);
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
exchangeToken: (payload: TokenRequest) => Promise<TokenResponse>;
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* Logout the current user by revoking their JWT.
|
|
921
|
+
* After calling this, you should clear the token from storage
|
|
922
|
+
* and call `sso.setAuthToken(null)`.
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```typescript
|
|
926
|
+
* await sso.auth.logout();
|
|
927
|
+
* sso.setAuthToken(null);
|
|
928
|
+
* localStorage.removeItem('jwt');
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
logout(): Promise<void>;
|
|
932
|
+
/**
|
|
933
|
+
* Get a fresh provider access token for the authenticated user.
|
|
934
|
+
* This will automatically refresh the token if it's expired.
|
|
935
|
+
*
|
|
936
|
+
* @param provider The OAuth provider
|
|
937
|
+
* @returns Fresh provider token
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```typescript
|
|
941
|
+
* const token = await sso.auth.getProviderToken('github');
|
|
942
|
+
* // Use token.access_token to make GitHub API calls
|
|
943
|
+
* ```
|
|
944
|
+
*/
|
|
945
|
+
getProviderToken(provider: OAuthProvider): Promise<ProviderToken>;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Identity (social account linking) methods
|
|
950
|
+
*/
|
|
951
|
+
declare class IdentitiesModule {
|
|
952
|
+
private http;
|
|
953
|
+
constructor(http: HttpClient);
|
|
954
|
+
/**
|
|
955
|
+
* List all social accounts linked to the authenticated user.
|
|
956
|
+
*
|
|
957
|
+
* @returns Array of linked identities
|
|
958
|
+
*
|
|
959
|
+
* @example
|
|
960
|
+
* ```typescript
|
|
961
|
+
* const identities = await sso.user.identities.list();
|
|
962
|
+
* console.log(identities); // [{ provider: 'github' }, { provider: 'google' }]
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
965
|
+
list(): Promise<Identity[]>;
|
|
966
|
+
/**
|
|
967
|
+
* Start linking a new social account to the authenticated user.
|
|
968
|
+
* Returns an authorization URL that the user should be redirected to.
|
|
969
|
+
*
|
|
970
|
+
* @param provider The OAuth provider to link (e.g., 'github', 'google', 'microsoft')
|
|
971
|
+
* @returns Object containing the authorization URL
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* ```typescript
|
|
975
|
+
* const { authorization_url } = await sso.user.identities.startLink('github');
|
|
976
|
+
* window.location.href = authorization_url; // Redirect user to complete OAuth
|
|
977
|
+
* ```
|
|
978
|
+
*/
|
|
979
|
+
startLink(provider: string): Promise<StartLinkResponse>;
|
|
980
|
+
/**
|
|
981
|
+
* Unlink a social account from the authenticated user.
|
|
982
|
+
* Note: Cannot unlink the last remaining identity to prevent account lockout.
|
|
983
|
+
*
|
|
984
|
+
* @param provider The OAuth provider to unlink (e.g., 'github', 'google', 'microsoft')
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
* ```typescript
|
|
988
|
+
* await sso.user.identities.unlink('google');
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
unlink(provider: string): Promise<void>;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* User profile and subscription methods
|
|
995
|
+
*/
|
|
996
|
+
declare class UserModule {
|
|
997
|
+
private http;
|
|
998
|
+
readonly identities: IdentitiesModule;
|
|
999
|
+
constructor(http: HttpClient);
|
|
1000
|
+
/**
|
|
1001
|
+
* Get the profile of the currently authenticated user.
|
|
1002
|
+
* The response includes context from the JWT (org, service).
|
|
1003
|
+
*
|
|
1004
|
+
* @returns User profile
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```typescript
|
|
1008
|
+
* const profile = await sso.user.getProfile();
|
|
1009
|
+
* console.log(profile.email, profile.org, profile.service);
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
getProfile(): Promise<UserProfile>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Update the authenticated user's profile.
|
|
1015
|
+
*
|
|
1016
|
+
* @param payload Update payload
|
|
1017
|
+
* @returns Updated user profile
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```typescript
|
|
1021
|
+
* const updated = await sso.user.updateProfile({
|
|
1022
|
+
* email: 'newemail@example.com'
|
|
1023
|
+
* });
|
|
1024
|
+
* ```
|
|
1025
|
+
*/
|
|
1026
|
+
updateProfile(payload: UpdateUserProfilePayload): Promise<UserProfile>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Get the current user's subscription details for the service in their JWT.
|
|
1029
|
+
*
|
|
1030
|
+
* @returns Subscription details
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* const subscription = await sso.user.getSubscription();
|
|
1035
|
+
* console.log(subscription.plan, subscription.features);
|
|
1036
|
+
* ```
|
|
1037
|
+
*/
|
|
1038
|
+
getSubscription(): Promise<Subscription>;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Organization management methods
|
|
1043
|
+
*/
|
|
1044
|
+
declare class OrganizationsModule {
|
|
1045
|
+
private http;
|
|
1046
|
+
constructor(http: HttpClient);
|
|
1047
|
+
/**
|
|
1048
|
+
* Create a new organization (public endpoint).
|
|
1049
|
+
* The organization will be created with 'pending' status and requires
|
|
1050
|
+
* platform owner approval before becoming active.
|
|
1051
|
+
*
|
|
1052
|
+
* @param payload Organization creation payload
|
|
1053
|
+
* @returns Created organization with owner and membership details
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```typescript
|
|
1057
|
+
* const result = await sso.organizations.createPublic({
|
|
1058
|
+
* slug: 'acme-corp',
|
|
1059
|
+
* name: 'Acme Corporation',
|
|
1060
|
+
* owner_email: 'founder@acme.com'
|
|
1061
|
+
* });
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
createPublic(payload: CreateOrganizationPayload): Promise<CreateOrganizationResponse>;
|
|
1065
|
+
/**
|
|
1066
|
+
* List all organizations the authenticated user is a member of.
|
|
1067
|
+
*
|
|
1068
|
+
* @param params Optional query parameters for filtering and pagination
|
|
1069
|
+
* @returns Array of organization responses
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```typescript
|
|
1073
|
+
* const orgs = await sso.organizations.list({
|
|
1074
|
+
* status: 'active',
|
|
1075
|
+
* page: 1,
|
|
1076
|
+
* limit: 20
|
|
1077
|
+
* });
|
|
1078
|
+
* ```
|
|
1079
|
+
*/
|
|
1080
|
+
list(params?: ListOrganizationsParams): Promise<OrganizationResponse[]>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Get detailed information for a specific organization.
|
|
1083
|
+
*
|
|
1084
|
+
* @param orgSlug Organization slug
|
|
1085
|
+
* @returns Organization details
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```typescript
|
|
1089
|
+
* const org = await sso.organizations.get('acme-corp');
|
|
1090
|
+
* console.log(org.organization.name, org.membership_count);
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
get(orgSlug: string): Promise<OrganizationResponse>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Update organization details.
|
|
1096
|
+
* Requires 'owner' or 'admin' role.
|
|
1097
|
+
*
|
|
1098
|
+
* @param orgSlug Organization slug
|
|
1099
|
+
* @param payload Update payload
|
|
1100
|
+
* @returns Updated organization details
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```typescript
|
|
1104
|
+
* const updated = await sso.organizations.update('acme-corp', {
|
|
1105
|
+
* name: 'Acme Corporation Inc.',
|
|
1106
|
+
* max_services: 20
|
|
1107
|
+
* });
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
update(orgSlug: string, payload: UpdateOrganizationPayload): Promise<OrganizationResponse>;
|
|
1111
|
+
/**
|
|
1112
|
+
* Member management methods
|
|
1113
|
+
*/
|
|
1114
|
+
members: {
|
|
1115
|
+
/**
|
|
1116
|
+
* List all members of an organization.
|
|
1117
|
+
*
|
|
1118
|
+
* @param orgSlug Organization slug
|
|
1119
|
+
* @returns Member list response with pagination metadata
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```typescript
|
|
1123
|
+
* const result = await sso.organizations.members.list('acme-corp');
|
|
1124
|
+
* console.log(`Total members: ${result.total}`);
|
|
1125
|
+
* result.members.forEach(m => console.log(m.email, m.role));
|
|
1126
|
+
* ```
|
|
1127
|
+
*/
|
|
1128
|
+
list: (orgSlug: string) => Promise<MemberListResponse>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Update a member's role.
|
|
1131
|
+
* Requires 'owner' role.
|
|
1132
|
+
*
|
|
1133
|
+
* @param orgSlug Organization slug
|
|
1134
|
+
* @param userId User ID to update
|
|
1135
|
+
* @param payload Role update payload
|
|
1136
|
+
* @returns Updated member details
|
|
1137
|
+
*
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```typescript
|
|
1140
|
+
* await sso.organizations.members.updateRole('acme-corp', 'user-id', {
|
|
1141
|
+
* role: 'admin'
|
|
1142
|
+
* });
|
|
1143
|
+
* ```
|
|
1144
|
+
*/
|
|
1145
|
+
updateRole: (orgSlug: string, userId: string, payload: UpdateMemberRolePayload) => Promise<OrganizationMember>;
|
|
1146
|
+
/**
|
|
1147
|
+
* Remove a member from the organization.
|
|
1148
|
+
* Requires 'owner' or 'admin' role.
|
|
1149
|
+
*
|
|
1150
|
+
* @param orgSlug Organization slug
|
|
1151
|
+
* @param userId User ID to remove
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```typescript
|
|
1155
|
+
* await sso.organizations.members.remove('acme-corp', 'user-id');
|
|
1156
|
+
* ```
|
|
1157
|
+
*/
|
|
1158
|
+
remove: (orgSlug: string, userId: string) => Promise<void>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Transfer organization ownership to another member.
|
|
1161
|
+
* Requires 'owner' role.
|
|
1162
|
+
*
|
|
1163
|
+
* @param orgSlug Organization slug
|
|
1164
|
+
* @param payload Transfer payload with new owner ID
|
|
1165
|
+
*
|
|
1166
|
+
* @example
|
|
1167
|
+
* ```typescript
|
|
1168
|
+
* await sso.organizations.members.transferOwnership('acme-corp', {
|
|
1169
|
+
* new_owner_user_id: 'new-owner-id'
|
|
1170
|
+
* });
|
|
1171
|
+
* ```
|
|
1172
|
+
*/
|
|
1173
|
+
transferOwnership: (orgSlug: string, payload: TransferOwnershipPayload) => Promise<void>;
|
|
1174
|
+
};
|
|
1175
|
+
/**
|
|
1176
|
+
* End-user management methods
|
|
1177
|
+
* Manage organization's customers (end-users with subscriptions)
|
|
1178
|
+
*/
|
|
1179
|
+
endUsers: {
|
|
1180
|
+
/**
|
|
1181
|
+
* List all end-users for an organization.
|
|
1182
|
+
* End-users are customers who have subscriptions to the organization's services.
|
|
1183
|
+
*
|
|
1184
|
+
* @param orgSlug Organization slug
|
|
1185
|
+
* @param params Optional query parameters for pagination
|
|
1186
|
+
* @returns Paginated list of end-users with their subscriptions
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```typescript
|
|
1190
|
+
* const endUsers = await sso.organizations.endUsers.list('acme-corp', {
|
|
1191
|
+
* page: 1,
|
|
1192
|
+
* limit: 20
|
|
1193
|
+
* });
|
|
1194
|
+
* console.log(`Total end-users: ${endUsers.total}`);
|
|
1195
|
+
* ```
|
|
1196
|
+
*/
|
|
1197
|
+
list: (orgSlug: string, params?: ListEndUsersParams) => Promise<EndUserListResponse>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Get detailed information about a specific end-user.
|
|
1200
|
+
*
|
|
1201
|
+
* @param orgSlug Organization slug
|
|
1202
|
+
* @param userId User ID
|
|
1203
|
+
* @returns End-user details with subscriptions, identities, and session count
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* ```typescript
|
|
1207
|
+
* const endUser = await sso.organizations.endUsers.get('acme-corp', 'user-id');
|
|
1208
|
+
* console.log(`Active sessions: ${endUser.session_count}`);
|
|
1209
|
+
* ```
|
|
1210
|
+
*/
|
|
1211
|
+
get: (orgSlug: string, userId: string) => Promise<EndUserDetailResponse>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Revoke all active sessions for an end-user.
|
|
1214
|
+
* Requires admin or owner role.
|
|
1215
|
+
* This will force the user to re-authenticate.
|
|
1216
|
+
*
|
|
1217
|
+
* @param orgSlug Organization slug
|
|
1218
|
+
* @param userId User ID
|
|
1219
|
+
* @returns Response with number of revoked sessions
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```typescript
|
|
1223
|
+
* const result = await sso.organizations.endUsers.revokeSessions('acme-corp', 'user-id');
|
|
1224
|
+
* console.log(`Revoked ${result.revoked_count} sessions`);
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
revokeSessions: (orgSlug: string, userId: string) => Promise<RevokeSessionsResponse>;
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* BYOO (Bring Your Own OAuth) credential management
|
|
1231
|
+
*/
|
|
1232
|
+
oauthCredentials: {
|
|
1233
|
+
/**
|
|
1234
|
+
* Set or update custom OAuth credentials for a provider.
|
|
1235
|
+
* This enables white-labeled authentication using the organization's
|
|
1236
|
+
* own OAuth application.
|
|
1237
|
+
* Requires 'owner' or 'admin' role.
|
|
1238
|
+
*
|
|
1239
|
+
* @param orgSlug Organization slug
|
|
1240
|
+
* @param provider OAuth provider
|
|
1241
|
+
* @param payload OAuth credentials
|
|
1242
|
+
* @returns Created/updated credentials (without secret)
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
* ```typescript
|
|
1246
|
+
* await sso.organizations.oauthCredentials.set('acme-corp', 'github', {
|
|
1247
|
+
* client_id: 'Iv1.abc123',
|
|
1248
|
+
* client_secret: 'secret-value'
|
|
1249
|
+
* });
|
|
1250
|
+
* ```
|
|
1251
|
+
*/
|
|
1252
|
+
set: (orgSlug: string, provider: OAuthProvider, payload: SetOAuthCredentialsPayload) => Promise<OAuthCredentials>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Get the configured OAuth credentials for a provider.
|
|
1255
|
+
* The secret is never returned.
|
|
1256
|
+
*
|
|
1257
|
+
* @param orgSlug Organization slug
|
|
1258
|
+
* @param provider OAuth provider
|
|
1259
|
+
* @returns OAuth credentials (without secret)
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```typescript
|
|
1263
|
+
* const creds = await sso.organizations.oauthCredentials.get('acme-corp', 'github');
|
|
1264
|
+
* console.log(creds.client_id);
|
|
1265
|
+
* ```
|
|
1266
|
+
*/
|
|
1267
|
+
get: (orgSlug: string, provider: OAuthProvider) => Promise<OAuthCredentials>;
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Service management methods
|
|
1273
|
+
*/
|
|
1274
|
+
declare class ServicesModule {
|
|
1275
|
+
private http;
|
|
1276
|
+
constructor(http: HttpClient);
|
|
1277
|
+
/**
|
|
1278
|
+
* Create a new service for an organization.
|
|
1279
|
+
* Requires 'owner' or 'admin' role.
|
|
1280
|
+
*
|
|
1281
|
+
* @param orgSlug Organization slug
|
|
1282
|
+
* @param payload Service creation payload
|
|
1283
|
+
* @returns Created service with details
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```typescript
|
|
1287
|
+
* const result = await sso.services.create('acme-corp', {
|
|
1288
|
+
* slug: 'main-app',
|
|
1289
|
+
* name: 'Main Application',
|
|
1290
|
+
* service_type: 'web',
|
|
1291
|
+
* github_scopes: ['user:email', 'read:org'],
|
|
1292
|
+
* redirect_uris: ['https://app.acme.com/callback']
|
|
1293
|
+
* });
|
|
1294
|
+
* console.log(result.service.client_id);
|
|
1295
|
+
* ```
|
|
1296
|
+
*/
|
|
1297
|
+
create(orgSlug: string, payload: CreateServicePayload): Promise<CreateServiceResponse>;
|
|
1298
|
+
/**
|
|
1299
|
+
* List all services for an organization.
|
|
1300
|
+
*
|
|
1301
|
+
* @param orgSlug Organization slug
|
|
1302
|
+
* @returns Service list response with usage metadata
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```typescript
|
|
1306
|
+
* const result = await sso.services.list('acme-corp');
|
|
1307
|
+
* console.log(`Using ${result.usage.current_services} of ${result.usage.max_services} services`);
|
|
1308
|
+
* result.services.forEach(svc => console.log(svc.name, svc.client_id));
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
list(orgSlug: string): Promise<ServiceListResponse>;
|
|
1312
|
+
/**
|
|
1313
|
+
* Get detailed information for a specific service.
|
|
1314
|
+
*
|
|
1315
|
+
* @param orgSlug Organization slug
|
|
1316
|
+
* @param serviceSlug Service slug
|
|
1317
|
+
* @returns Service with provider grants and plans
|
|
1318
|
+
*
|
|
1319
|
+
* @example
|
|
1320
|
+
* ```typescript
|
|
1321
|
+
* const service = await sso.services.get('acme-corp', 'main-app');
|
|
1322
|
+
* console.log(service.service.redirect_uris);
|
|
1323
|
+
* console.log(service.plans);
|
|
1324
|
+
* ```
|
|
1325
|
+
*/
|
|
1326
|
+
get(orgSlug: string, serviceSlug: string): Promise<ServiceResponse>;
|
|
1327
|
+
/**
|
|
1328
|
+
* Update service configuration.
|
|
1329
|
+
* Requires 'owner' or 'admin' role.
|
|
1330
|
+
*
|
|
1331
|
+
* @param orgSlug Organization slug
|
|
1332
|
+
* @param serviceSlug Service slug
|
|
1333
|
+
* @param payload Update payload
|
|
1334
|
+
* @returns Updated service
|
|
1335
|
+
*
|
|
1336
|
+
* @example
|
|
1337
|
+
* ```typescript
|
|
1338
|
+
* const updated = await sso.services.update('acme-corp', 'main-app', {
|
|
1339
|
+
* name: 'Main Application v2',
|
|
1340
|
+
* redirect_uris: ['https://app.acme.com/callback', 'https://app.acme.com/oauth']
|
|
1341
|
+
* });
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
update(orgSlug: string, serviceSlug: string, payload: UpdateServicePayload): Promise<Service>;
|
|
1345
|
+
/**
|
|
1346
|
+
* Delete a service.
|
|
1347
|
+
* Requires 'owner' role.
|
|
1348
|
+
*
|
|
1349
|
+
* @param orgSlug Organization slug
|
|
1350
|
+
* @param serviceSlug Service slug
|
|
1351
|
+
*
|
|
1352
|
+
* @example
|
|
1353
|
+
* ```typescript
|
|
1354
|
+
* await sso.services.delete('acme-corp', 'old-app');
|
|
1355
|
+
* ```
|
|
1356
|
+
*/
|
|
1357
|
+
delete(orgSlug: string, serviceSlug: string): Promise<void>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Plan management methods
|
|
1360
|
+
*/
|
|
1361
|
+
plans: {
|
|
1362
|
+
/**
|
|
1363
|
+
* Create a new subscription plan for a service.
|
|
1364
|
+
* Requires 'owner' or 'admin' role.
|
|
1365
|
+
*
|
|
1366
|
+
* @param orgSlug Organization slug
|
|
1367
|
+
* @param serviceSlug Service slug
|
|
1368
|
+
* @param payload Plan creation payload
|
|
1369
|
+
* @returns Created plan
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
* ```typescript
|
|
1373
|
+
* const plan = await sso.services.plans.create('acme-corp', 'main-app', {
|
|
1374
|
+
* name: 'pro',
|
|
1375
|
+
* description: 'Pro tier with advanced features',
|
|
1376
|
+
* price_monthly: 29.99,
|
|
1377
|
+
* features: ['api-access', 'advanced-analytics', 'priority-support']
|
|
1378
|
+
* });
|
|
1379
|
+
* ```
|
|
1380
|
+
*/
|
|
1381
|
+
create: (orgSlug: string, serviceSlug: string, payload: CreatePlanPayload) => Promise<Plan>;
|
|
1382
|
+
/**
|
|
1383
|
+
* List all plans for a service.
|
|
1384
|
+
*
|
|
1385
|
+
* @param orgSlug Organization slug
|
|
1386
|
+
* @param serviceSlug Service slug
|
|
1387
|
+
* @returns Array of plans
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* ```typescript
|
|
1391
|
+
* const plans = await sso.services.plans.list('acme-corp', 'main-app');
|
|
1392
|
+
* plans.forEach(plan => console.log(plan.name, plan.price_monthly));
|
|
1393
|
+
* ```
|
|
1394
|
+
*/
|
|
1395
|
+
list: (orgSlug: string, serviceSlug: string) => Promise<Plan[]>;
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Invitation management methods
|
|
1401
|
+
*/
|
|
1402
|
+
declare class InvitationsModule {
|
|
1403
|
+
private http;
|
|
1404
|
+
constructor(http: HttpClient);
|
|
1405
|
+
/**
|
|
1406
|
+
* Create and send an invitation to join an organization.
|
|
1407
|
+
* Requires 'owner' or 'admin' role.
|
|
1408
|
+
*
|
|
1409
|
+
* @param orgSlug Organization slug
|
|
1410
|
+
* @param payload Invitation payload with email and role
|
|
1411
|
+
* @returns Created invitation
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```typescript
|
|
1415
|
+
* const invitation = await sso.invitations.create('acme-corp', {
|
|
1416
|
+
* invitee_email: 'newuser@example.com',
|
|
1417
|
+
* role: 'member'
|
|
1418
|
+
* });
|
|
1419
|
+
* ```
|
|
1420
|
+
*/
|
|
1421
|
+
create(orgSlug: string, payload: CreateInvitationPayload): Promise<Invitation>;
|
|
1422
|
+
/**
|
|
1423
|
+
* List all invitations for an organization.
|
|
1424
|
+
* Requires 'owner' or 'admin' role.
|
|
1425
|
+
*
|
|
1426
|
+
* @param orgSlug Organization slug
|
|
1427
|
+
* @returns Array of invitations
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* const invitations = await sso.invitations.listForOrg('acme-corp');
|
|
1432
|
+
* invitations.forEach(inv => console.log(inv.invitee_email, inv.status));
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
listForOrg(orgSlug: string): Promise<Invitation[]>;
|
|
1436
|
+
/**
|
|
1437
|
+
* Cancel a pending invitation.
|
|
1438
|
+
* Requires 'owner' or 'admin' role.
|
|
1439
|
+
*
|
|
1440
|
+
* @param orgSlug Organization slug
|
|
1441
|
+
* @param invitationId Invitation ID to cancel
|
|
1442
|
+
*
|
|
1443
|
+
* @example
|
|
1444
|
+
* ```typescript
|
|
1445
|
+
* await sso.invitations.cancel('acme-corp', 'invitation-id');
|
|
1446
|
+
* ```
|
|
1447
|
+
*/
|
|
1448
|
+
cancel(orgSlug: string, invitationId: string): Promise<void>;
|
|
1449
|
+
/**
|
|
1450
|
+
* List invitations received by the current authenticated user.
|
|
1451
|
+
*
|
|
1452
|
+
* @returns Array of invitations with organization details
|
|
1453
|
+
*
|
|
1454
|
+
* @example
|
|
1455
|
+
* ```typescript
|
|
1456
|
+
* const myInvitations = await sso.invitations.listForUser();
|
|
1457
|
+
* myInvitations.forEach(inv => {
|
|
1458
|
+
* console.log(`Invited to ${inv.organization_name} as ${inv.role}`);
|
|
1459
|
+
* });
|
|
1460
|
+
* ```
|
|
1461
|
+
*/
|
|
1462
|
+
listForUser(): Promise<InvitationWithOrg[]>;
|
|
1463
|
+
/**
|
|
1464
|
+
* Accept an invitation using its token.
|
|
1465
|
+
*
|
|
1466
|
+
* @param token Invitation token
|
|
1467
|
+
*
|
|
1468
|
+
* @example
|
|
1469
|
+
* ```typescript
|
|
1470
|
+
* await sso.invitations.accept('invitation-token-from-email');
|
|
1471
|
+
* ```
|
|
1472
|
+
*/
|
|
1473
|
+
accept(token: string): Promise<void>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Decline an invitation using its token.
|
|
1476
|
+
*
|
|
1477
|
+
* @param token Invitation token
|
|
1478
|
+
*
|
|
1479
|
+
* @example
|
|
1480
|
+
* ```typescript
|
|
1481
|
+
* await sso.invitations.decline('invitation-token-from-email');
|
|
1482
|
+
* ```
|
|
1483
|
+
*/
|
|
1484
|
+
decline(token: string): Promise<void>;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Platform owner administration methods.
|
|
1489
|
+
* All methods require a Platform Owner JWT.
|
|
1490
|
+
*/
|
|
1491
|
+
declare class PlatformModule {
|
|
1492
|
+
private http;
|
|
1493
|
+
constructor(http: HttpClient);
|
|
1494
|
+
/**
|
|
1495
|
+
* List all available organization tiers.
|
|
1496
|
+
*
|
|
1497
|
+
* @returns Array of organization tiers
|
|
1498
|
+
*
|
|
1499
|
+
* @example
|
|
1500
|
+
* ```typescript
|
|
1501
|
+
* const tiers = await sso.platform.getTiers();
|
|
1502
|
+
* console.log(tiers); // [{ id: 'tier_free', display_name: 'Free Tier', ... }]
|
|
1503
|
+
* ```
|
|
1504
|
+
*/
|
|
1505
|
+
getTiers(): Promise<OrganizationTier[]>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Organization management for platform owners
|
|
1508
|
+
*/
|
|
1509
|
+
organizations: {
|
|
1510
|
+
/**
|
|
1511
|
+
* List all organizations on the platform with optional filters.
|
|
1512
|
+
*
|
|
1513
|
+
* @param params Optional query parameters for filtering
|
|
1514
|
+
* @returns Platform organizations list with pagination info
|
|
1515
|
+
*
|
|
1516
|
+
* @example
|
|
1517
|
+
* ```typescript
|
|
1518
|
+
* const result = await sso.platform.organizations.list({
|
|
1519
|
+
* status: 'pending',
|
|
1520
|
+
* page: 1,
|
|
1521
|
+
* limit: 50
|
|
1522
|
+
* });
|
|
1523
|
+
* console.log(result.total, result.organizations);
|
|
1524
|
+
* ```
|
|
1525
|
+
*/
|
|
1526
|
+
list: (params?: ListPlatformOrganizationsParams) => Promise<PlatformOrganizationsListResponse>;
|
|
1527
|
+
/**
|
|
1528
|
+
* Approve a pending organization and assign it a tier.
|
|
1529
|
+
*
|
|
1530
|
+
* @param orgId Organization ID
|
|
1531
|
+
* @param payload Approval payload with tier assignment
|
|
1532
|
+
* @returns Approved organization
|
|
1533
|
+
*
|
|
1534
|
+
* @example
|
|
1535
|
+
* ```typescript
|
|
1536
|
+
* const approved = await sso.platform.organizations.approve('org-id', {
|
|
1537
|
+
* tier_id: 'tier-starter'
|
|
1538
|
+
* });
|
|
1539
|
+
* ```
|
|
1540
|
+
*/
|
|
1541
|
+
approve: (orgId: string, payload: ApproveOrganizationPayload) => Promise<Organization>;
|
|
1542
|
+
/**
|
|
1543
|
+
* Reject a pending organization with a reason.
|
|
1544
|
+
*
|
|
1545
|
+
* @param orgId Organization ID
|
|
1546
|
+
* @param payload Rejection payload with reason
|
|
1547
|
+
* @returns Rejected organization
|
|
1548
|
+
*
|
|
1549
|
+
* @example
|
|
1550
|
+
* ```typescript
|
|
1551
|
+
* await sso.platform.organizations.reject('org-id', {
|
|
1552
|
+
* reason: 'Does not meet platform requirements'
|
|
1553
|
+
* });
|
|
1554
|
+
* ```
|
|
1555
|
+
*/
|
|
1556
|
+
reject: (orgId: string, payload: RejectOrganizationPayload) => Promise<Organization>;
|
|
1557
|
+
/**
|
|
1558
|
+
* Suspend an active organization.
|
|
1559
|
+
*
|
|
1560
|
+
* @param orgId Organization ID
|
|
1561
|
+
* @returns Suspended organization
|
|
1562
|
+
*
|
|
1563
|
+
* @example
|
|
1564
|
+
* ```typescript
|
|
1565
|
+
* await sso.platform.organizations.suspend('org-id');
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
suspend: (orgId: string) => Promise<Organization>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Re-activate a suspended organization.
|
|
1571
|
+
*
|
|
1572
|
+
* @param orgId Organization ID
|
|
1573
|
+
* @returns Activated organization
|
|
1574
|
+
*
|
|
1575
|
+
* @example
|
|
1576
|
+
* ```typescript
|
|
1577
|
+
* await sso.platform.organizations.activate('org-id');
|
|
1578
|
+
* ```
|
|
1579
|
+
*/
|
|
1580
|
+
activate: (orgId: string) => Promise<Organization>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Update an organization's tier and resource limits.
|
|
1583
|
+
*
|
|
1584
|
+
* @param orgId Organization ID
|
|
1585
|
+
* @param payload Tier update payload
|
|
1586
|
+
* @returns Updated organization
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* ```typescript
|
|
1590
|
+
* await sso.platform.organizations.updateTier('org-id', {
|
|
1591
|
+
* tier_id: 'tier-pro',
|
|
1592
|
+
* max_services: 20,
|
|
1593
|
+
* max_users: 100
|
|
1594
|
+
* });
|
|
1595
|
+
* ```
|
|
1596
|
+
*/
|
|
1597
|
+
updateTier: (orgId: string, payload: UpdateOrganizationTierPayload) => Promise<Organization>;
|
|
1598
|
+
};
|
|
1599
|
+
/**
|
|
1600
|
+
* Promote an existing user to platform owner.
|
|
1601
|
+
*
|
|
1602
|
+
* @param payload Promotion payload with user ID
|
|
1603
|
+
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* ```typescript
|
|
1606
|
+
* await sso.platform.promoteOwner({
|
|
1607
|
+
* user_id: 'user-uuid-here'
|
|
1608
|
+
* });
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
promoteOwner(payload: PromotePlatformOwnerPayload): Promise<void>;
|
|
1612
|
+
/**
|
|
1613
|
+
* Demote a platform owner to regular user.
|
|
1614
|
+
*
|
|
1615
|
+
* @param userId The ID of the user to demote
|
|
1616
|
+
*
|
|
1617
|
+
* @example
|
|
1618
|
+
* ```typescript
|
|
1619
|
+
* await sso.platform.demoteOwner('user-uuid-here');
|
|
1620
|
+
* ```
|
|
1621
|
+
*/
|
|
1622
|
+
demoteOwner(userId: string): Promise<void>;
|
|
1623
|
+
/**
|
|
1624
|
+
* Retrieve the platform-wide audit log with optional filters.
|
|
1625
|
+
*
|
|
1626
|
+
* @param params Optional query parameters for filtering
|
|
1627
|
+
* @returns Array of audit log entries
|
|
1628
|
+
*
|
|
1629
|
+
* @example
|
|
1630
|
+
* ```typescript
|
|
1631
|
+
* const logs = await sso.platform.getAuditLog({
|
|
1632
|
+
* action: 'organization.approved',
|
|
1633
|
+
* start_date: '2024-01-01',
|
|
1634
|
+
* limit: 100
|
|
1635
|
+
* });
|
|
1636
|
+
* ```
|
|
1637
|
+
*/
|
|
1638
|
+
getAuditLog(params?: GetAuditLogParams): Promise<AuditLogEntry[]>;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* Configuration options for the SSO client
|
|
1643
|
+
*/
|
|
1644
|
+
interface SsoClientOptions {
|
|
1645
|
+
/**
|
|
1646
|
+
* Base URL of the SSO API service
|
|
1647
|
+
*/
|
|
1648
|
+
baseURL: string;
|
|
1649
|
+
/**
|
|
1650
|
+
* Optional JWT token to initialize with
|
|
1651
|
+
*/
|
|
1652
|
+
token?: string;
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Main SSO client class.
|
|
1656
|
+
* This is the entry point for all SDK operations.
|
|
1657
|
+
*
|
|
1658
|
+
* @example
|
|
1659
|
+
* ```typescript
|
|
1660
|
+
* const sso = new SsoClient({
|
|
1661
|
+
* baseURL: 'https://sso.example.com',
|
|
1662
|
+
* token: localStorage.getItem('jwt')
|
|
1663
|
+
* });
|
|
1664
|
+
*
|
|
1665
|
+
* // Use the modules
|
|
1666
|
+
* const user = await sso.user.getProfile();
|
|
1667
|
+
* const orgs = await sso.organizations.list();
|
|
1668
|
+
* ```
|
|
1669
|
+
*/
|
|
1670
|
+
declare class SsoClient {
|
|
1671
|
+
private http;
|
|
1672
|
+
/**
|
|
1673
|
+
* Analytics and login tracking methods
|
|
1674
|
+
*/
|
|
1675
|
+
readonly analytics: AnalyticsModule;
|
|
1676
|
+
/**
|
|
1677
|
+
* Authentication and OAuth flow methods
|
|
1678
|
+
*/
|
|
1679
|
+
readonly auth: AuthModule;
|
|
1680
|
+
/**
|
|
1681
|
+
* User profile and subscription methods
|
|
1682
|
+
*/
|
|
1683
|
+
readonly user: UserModule;
|
|
1684
|
+
/**
|
|
1685
|
+
* Organization management methods
|
|
1686
|
+
*/
|
|
1687
|
+
readonly organizations: OrganizationsModule;
|
|
1688
|
+
/**
|
|
1689
|
+
* Service management methods
|
|
1690
|
+
*/
|
|
1691
|
+
readonly services: ServicesModule;
|
|
1692
|
+
/**
|
|
1693
|
+
* Invitation management methods
|
|
1694
|
+
*/
|
|
1695
|
+
readonly invitations: InvitationsModule;
|
|
1696
|
+
/**
|
|
1697
|
+
* Platform owner administration methods
|
|
1698
|
+
*/
|
|
1699
|
+
readonly platform: PlatformModule;
|
|
1700
|
+
constructor(options: SsoClientOptions);
|
|
1701
|
+
/**
|
|
1702
|
+
* Sets the JWT for all subsequent authenticated requests.
|
|
1703
|
+
* Pass null to clear the token.
|
|
1704
|
+
*
|
|
1705
|
+
* @param token The JWT string, or null to clear
|
|
1706
|
+
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* ```typescript
|
|
1709
|
+
* // Set token
|
|
1710
|
+
* sso.setAuthToken(jwt);
|
|
1711
|
+
*
|
|
1712
|
+
* // Clear token
|
|
1713
|
+
* sso.setAuthToken(null);
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
setAuthToken(token: string | null): void;
|
|
1717
|
+
/**
|
|
1718
|
+
* Gets the current base URL
|
|
1719
|
+
*/
|
|
1720
|
+
getBaseURL(): string;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Custom error class for SSO API errors.
|
|
1725
|
+
* Provides structured error information from the API.
|
|
1726
|
+
*/
|
|
1727
|
+
declare class SsoApiError extends Error {
|
|
1728
|
+
/**
|
|
1729
|
+
* The HTTP status code of the error response.
|
|
1730
|
+
*/
|
|
1731
|
+
readonly statusCode: number;
|
|
1732
|
+
/**
|
|
1733
|
+
* The specific error code returned by the API.
|
|
1734
|
+
*/
|
|
1735
|
+
readonly errorCode: string;
|
|
1736
|
+
/**
|
|
1737
|
+
* ISO 8601 timestamp when the error occurred.
|
|
1738
|
+
*/
|
|
1739
|
+
readonly timestamp: string;
|
|
1740
|
+
constructor(message: string, statusCode: number, errorCode: string, timestamp: string);
|
|
1741
|
+
/**
|
|
1742
|
+
* Check if the error is a specific error code.
|
|
1743
|
+
*/
|
|
1744
|
+
is(errorCode: string): boolean;
|
|
1745
|
+
/**
|
|
1746
|
+
* Check if the error is an authentication error.
|
|
1747
|
+
*/
|
|
1748
|
+
isAuthError(): boolean;
|
|
1749
|
+
/**
|
|
1750
|
+
* Check if the error is a permission error.
|
|
1751
|
+
*/
|
|
1752
|
+
isForbidden(): boolean;
|
|
1753
|
+
/**
|
|
1754
|
+
* Check if the error is a not found error.
|
|
1755
|
+
*/
|
|
1756
|
+
isNotFound(): boolean;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
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 };
|