@drmhse/sso-sdk 0.2.8 → 0.3.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/README.md +72 -31
- package/dist/index.d.mts +2035 -156
- package/dist/index.d.ts +2035 -156
- package/dist/index.js +1637 -106
- package/dist/index.mjs +1628 -106
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,65 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Abstract storage interface for persisting tokens
|
|
3
3
|
*/
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
interface TokenStorage {
|
|
5
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
6
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
7
|
+
removeItem(key: string): Promise<void> | void;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* In-memory storage (Default for Node/Server)
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
timeout: number;
|
|
12
|
+
declare class MemoryStorage implements TokenStorage {
|
|
13
|
+
private store;
|
|
14
|
+
getItem(key: string): string | null;
|
|
15
|
+
setItem(key: string, value: string): void;
|
|
16
|
+
removeItem(key: string): void;
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
21
|
-
* Provides an interface similar to Axios for easy migration.
|
|
19
|
+
* Browser LocalStorage adapter
|
|
22
20
|
*/
|
|
23
|
-
declare class
|
|
24
|
-
|
|
25
|
-
|
|
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>>;
|
|
21
|
+
declare class BrowserStorage implements TokenStorage {
|
|
22
|
+
getItem(key: string): string | null;
|
|
23
|
+
setItem(key: string, value: string): void;
|
|
24
|
+
removeItem(key: string): void;
|
|
63
25
|
}
|
|
64
26
|
|
|
65
27
|
/**
|
|
@@ -75,13 +37,19 @@ interface User {
|
|
|
75
37
|
created_at: string;
|
|
76
38
|
}
|
|
77
39
|
/**
|
|
78
|
-
* User profile response (includes context from JWT)
|
|
40
|
+
* User profile response (includes context from JWT and cached permissions)
|
|
79
41
|
*/
|
|
80
42
|
interface UserProfile {
|
|
81
43
|
id: string;
|
|
82
44
|
email: string;
|
|
45
|
+
is_platform_owner: boolean;
|
|
46
|
+
email_verified_at: string | null;
|
|
47
|
+
created_at: string;
|
|
83
48
|
org?: string;
|
|
84
49
|
service?: string;
|
|
50
|
+
permissions: string[];
|
|
51
|
+
plan: string | null;
|
|
52
|
+
features: string[] | null;
|
|
85
53
|
}
|
|
86
54
|
/**
|
|
87
55
|
* Paginated response wrapper
|
|
@@ -103,7 +71,7 @@ interface PaginationParams {
|
|
|
103
71
|
/**
|
|
104
72
|
* OAuth provider types
|
|
105
73
|
*/
|
|
106
|
-
type OAuthProvider = 'github' | 'google' | 'microsoft';
|
|
74
|
+
type OAuthProvider = 'github' | 'google' | 'microsoft' | 'oidc';
|
|
107
75
|
/**
|
|
108
76
|
* Organization status types
|
|
109
77
|
*/
|
|
@@ -153,6 +121,12 @@ interface JwtClaims {
|
|
|
153
121
|
* List of enabled features
|
|
154
122
|
*/
|
|
155
123
|
features?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* List of user permissions (Zanzibar relation tuples)
|
|
126
|
+
* Format: "namespace:object_id#relation"
|
|
127
|
+
* Example: ["organization:acme#owner", "service:api#admin"]
|
|
128
|
+
*/
|
|
129
|
+
permissions?: string[];
|
|
156
130
|
/**
|
|
157
131
|
* Expiration timestamp (Unix epoch)
|
|
158
132
|
*/
|
|
@@ -163,6 +137,308 @@ interface JwtClaims {
|
|
|
163
137
|
iat: number;
|
|
164
138
|
}
|
|
165
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Risk assessment and engine types
|
|
142
|
+
*/
|
|
143
|
+
/**
|
|
144
|
+
* Risk score levels
|
|
145
|
+
*/
|
|
146
|
+
type RiskScore = number;
|
|
147
|
+
/**
|
|
148
|
+
* Risk assessment results from the risk engine
|
|
149
|
+
*/
|
|
150
|
+
interface RiskAssessment {
|
|
151
|
+
/** Overall risk score (0-100, higher is more risky) */
|
|
152
|
+
score: RiskScore;
|
|
153
|
+
/** Action to take based on risk assessment */
|
|
154
|
+
action: RiskAction;
|
|
155
|
+
/** Specific risk factors that contributed to the score */
|
|
156
|
+
factors: RiskFactor[];
|
|
157
|
+
/** Geolocation data if available */
|
|
158
|
+
location?: GeolocationData;
|
|
159
|
+
/** When the assessment was performed */
|
|
160
|
+
assessedAt: string;
|
|
161
|
+
/** Additional metadata about the assessment */
|
|
162
|
+
metadata?: Record<string, unknown>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Risk actions the engine can recommend
|
|
166
|
+
*/
|
|
167
|
+
declare enum RiskAction {
|
|
168
|
+
/** Allow the authentication to proceed */
|
|
169
|
+
ALLOW = "allow",
|
|
170
|
+
/** Log only - allow but monitor */
|
|
171
|
+
LOG_ONLY = "log_only",
|
|
172
|
+
/** Require additional verification (MFA) */
|
|
173
|
+
CHALLENGE_MFA = "challenge_mfa",
|
|
174
|
+
/** Block the authentication attempt */
|
|
175
|
+
BLOCK = "block"
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Individual risk factors that contribute to overall risk score
|
|
179
|
+
*/
|
|
180
|
+
interface RiskFactor {
|
|
181
|
+
/** Type of risk factor */
|
|
182
|
+
type: RiskFactorType;
|
|
183
|
+
/** How much this factor contributes to the score */
|
|
184
|
+
weight: number;
|
|
185
|
+
/** Human-readable description */
|
|
186
|
+
description: string;
|
|
187
|
+
/** Additional data about this factor */
|
|
188
|
+
data?: Record<string, unknown>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Types of risk factors the engine can detect
|
|
192
|
+
*/
|
|
193
|
+
declare enum RiskFactorType {
|
|
194
|
+
/** Unknown IP address or never seen before */
|
|
195
|
+
NEW_IP = "new_ip",
|
|
196
|
+
/** IP from high-risk country or region */
|
|
197
|
+
HIGH_RISK_LOCATION = "high_risk_location",
|
|
198
|
+
/** Impossible travel - login from geographically impossible locations */
|
|
199
|
+
IMPOSSIBLE_TRAVEL = "impossible_travel",
|
|
200
|
+
/** New device or browser fingerprint */
|
|
201
|
+
NEW_DEVICE = "new_device",
|
|
202
|
+
/** Multiple failed login attempts */
|
|
203
|
+
FAILED_ATTEMPTS = "failed_attempts",
|
|
204
|
+
/** Login from unusual time of day */
|
|
205
|
+
UNUSUAL_TIME = "unusual_time",
|
|
206
|
+
/** Suspicious user agent or bot patterns */
|
|
207
|
+
SUSPICIOUS_USER_AGENT = "suspicious_user_agent",
|
|
208
|
+
/** Tor exit node or VPN detected */
|
|
209
|
+
ANONYMOUS_NETWORK = "anonymous_network",
|
|
210
|
+
/** Account is new (recently created) */
|
|
211
|
+
NEW_ACCOUNT = "new_account",
|
|
212
|
+
/** Account has suspicious activity history */
|
|
213
|
+
SUSPICIOUS_HISTORY = "suspicious_history",
|
|
214
|
+
/** Velocity-based detection (too many actions) */
|
|
215
|
+
HIGH_VELOCITY = "high_velocity",
|
|
216
|
+
/** Custom rule triggered */
|
|
217
|
+
CUSTOM_RULE = "custom_rule"
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Geolocation data for risk assessment
|
|
221
|
+
*/
|
|
222
|
+
interface GeolocationData {
|
|
223
|
+
/** Two-letter ISO country code */
|
|
224
|
+
country: string;
|
|
225
|
+
/** City name if available */
|
|
226
|
+
city?: string;
|
|
227
|
+
/** Region/state if available */
|
|
228
|
+
region?: string;
|
|
229
|
+
/** Latitude coordinate */
|
|
230
|
+
latitude?: number;
|
|
231
|
+
/** Longitude coordinate */
|
|
232
|
+
longitude?: number;
|
|
233
|
+
/** ISP or organization name */
|
|
234
|
+
isp?: string;
|
|
235
|
+
/** Whether this is a known VPN/proxy */
|
|
236
|
+
isVpn?: boolean;
|
|
237
|
+
/** Whether this is a Tor exit node */
|
|
238
|
+
isTor?: boolean;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Context provided to risk engine for assessment
|
|
242
|
+
*/
|
|
243
|
+
interface RiskContext {
|
|
244
|
+
/** User ID being authenticated */
|
|
245
|
+
userId: string;
|
|
246
|
+
/** Organization ID if applicable */
|
|
247
|
+
orgId?: string;
|
|
248
|
+
/** IP address of the request */
|
|
249
|
+
ipAddress: string;
|
|
250
|
+
/** User agent string */
|
|
251
|
+
userAgent: string;
|
|
252
|
+
/** Device fingerprint or cookie if available */
|
|
253
|
+
deviceCookie?: string;
|
|
254
|
+
/** Authentication method being used */
|
|
255
|
+
authMethod: AuthMethod;
|
|
256
|
+
/** Additional context data */
|
|
257
|
+
metadata?: Record<string, unknown>;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Authentication methods for risk assessment
|
|
261
|
+
*/
|
|
262
|
+
declare enum AuthMethod {
|
|
263
|
+
/** Email and password */
|
|
264
|
+
PASSWORD = "password",
|
|
265
|
+
/** OAuth provider (Google, GitHub, etc.) */
|
|
266
|
+
OAUTH = "oauth",
|
|
267
|
+
/** WebAuthn passkeys */
|
|
268
|
+
PASSKEY = "passkey",
|
|
269
|
+
/** Magic link email */
|
|
270
|
+
MAGIC_LINK = "magic_link",
|
|
271
|
+
/** Multi-factor authentication */
|
|
272
|
+
MFA = "mfa",
|
|
273
|
+
/** SAML SSO */
|
|
274
|
+
SAML = "saml"
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Risk engine configuration for organizations
|
|
278
|
+
*/
|
|
279
|
+
interface RiskEngineConfig {
|
|
280
|
+
/** Enable/disable risk engine */
|
|
281
|
+
enabled: boolean;
|
|
282
|
+
/** Risk score threshold for blocking */
|
|
283
|
+
blockThreshold: RiskScore;
|
|
284
|
+
/** Risk score threshold for requiring MFA */
|
|
285
|
+
mfaThreshold: RiskScore;
|
|
286
|
+
/** Which risk factors to consider */
|
|
287
|
+
enabledFactors: RiskFactorType[];
|
|
288
|
+
/** Custom rules and weights */
|
|
289
|
+
customRules?: RiskRule[];
|
|
290
|
+
/** How long to remember trusted devices */
|
|
291
|
+
deviceTrustDuration: number;
|
|
292
|
+
/** Whether to enable location-based risk assessment */
|
|
293
|
+
enableLocationTracking: boolean;
|
|
294
|
+
/** Max failed attempts before increased risk */
|
|
295
|
+
maxFailedAttempts: number;
|
|
296
|
+
/** Time window for velocity checks */
|
|
297
|
+
velocityWindow: number;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Custom risk rule definition
|
|
301
|
+
*/
|
|
302
|
+
interface RiskRule {
|
|
303
|
+
/** Unique rule identifier */
|
|
304
|
+
id: string;
|
|
305
|
+
/** Rule name for display */
|
|
306
|
+
name: string;
|
|
307
|
+
/** Rule description */
|
|
308
|
+
description: string;
|
|
309
|
+
/** Condition to trigger the rule */
|
|
310
|
+
condition: RiskRuleCondition;
|
|
311
|
+
/** Action to take when rule triggers */
|
|
312
|
+
action: RiskAction;
|
|
313
|
+
/** How much weight this rule carries */
|
|
314
|
+
weight: number;
|
|
315
|
+
/** Whether the rule is enabled */
|
|
316
|
+
enabled: boolean;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Risk rule condition
|
|
320
|
+
*/
|
|
321
|
+
interface RiskRuleCondition {
|
|
322
|
+
/** Field to check */
|
|
323
|
+
field: string;
|
|
324
|
+
/** Operator for comparison */
|
|
325
|
+
operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains' | 'regex';
|
|
326
|
+
/** Value to compare against */
|
|
327
|
+
value: unknown;
|
|
328
|
+
/** Additional conditions (AND logic) */
|
|
329
|
+
and?: RiskRuleCondition[];
|
|
330
|
+
/** Alternative conditions (OR logic) */
|
|
331
|
+
or?: RiskRuleCondition[];
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Device trust information
|
|
335
|
+
*/
|
|
336
|
+
interface DeviceTrust {
|
|
337
|
+
/** Device ID */
|
|
338
|
+
deviceId: string;
|
|
339
|
+
/** User ID this device belongs to */
|
|
340
|
+
userId: string;
|
|
341
|
+
/** Device name or description */
|
|
342
|
+
deviceName: string;
|
|
343
|
+
/** When the device was first seen */
|
|
344
|
+
firstSeenAt: string;
|
|
345
|
+
/** When the device was last used */
|
|
346
|
+
lastSeenAt: string;
|
|
347
|
+
/** When the device trust expires */
|
|
348
|
+
expiresAt: string;
|
|
349
|
+
/** IP address when device was registered */
|
|
350
|
+
registrationIp?: string;
|
|
351
|
+
/** Risk score for this device */
|
|
352
|
+
riskScore: RiskScore;
|
|
353
|
+
/** Whether this device is currently trusted */
|
|
354
|
+
isTrusted: boolean;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Risk event for logging and monitoring
|
|
358
|
+
*/
|
|
359
|
+
interface RiskEvent {
|
|
360
|
+
/** Unique event ID */
|
|
361
|
+
id: string;
|
|
362
|
+
/** User ID involved */
|
|
363
|
+
userId: string;
|
|
364
|
+
/** Organization ID if applicable */
|
|
365
|
+
orgId?: string;
|
|
366
|
+
/** Risk assessment that triggered this event */
|
|
367
|
+
assessment: RiskAssessment;
|
|
368
|
+
/** Authentication context */
|
|
369
|
+
context: RiskContext;
|
|
370
|
+
/** When the event occurred */
|
|
371
|
+
timestamp: string;
|
|
372
|
+
/** Event outcome */
|
|
373
|
+
outcome: RiskEventOutcome;
|
|
374
|
+
/** Additional event metadata */
|
|
375
|
+
metadata?: Record<string, unknown>;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Risk event outcomes
|
|
379
|
+
*/
|
|
380
|
+
declare enum RiskEventOutcome {
|
|
381
|
+
/** Authentication was allowed */
|
|
382
|
+
ALLOWED = "allowed",
|
|
383
|
+
/** Authentication was blocked */
|
|
384
|
+
BLOCKED = "blocked",
|
|
385
|
+
/** Additional verification was required */
|
|
386
|
+
CHALLENGED = "challenged",
|
|
387
|
+
/** Event was logged but no action taken */
|
|
388
|
+
LOGGED = "logged"
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Risk engine analytics and reporting
|
|
392
|
+
*/
|
|
393
|
+
interface RiskAnalytics {
|
|
394
|
+
/** Total risk assessments in time period */
|
|
395
|
+
totalAssessments: number;
|
|
396
|
+
/** Risk score distribution */
|
|
397
|
+
scoreDistribution: {
|
|
398
|
+
low: number;
|
|
399
|
+
medium: number;
|
|
400
|
+
high: number;
|
|
401
|
+
critical: number;
|
|
402
|
+
};
|
|
403
|
+
/** Most common risk factors */
|
|
404
|
+
topRiskFactors: Array<{
|
|
405
|
+
factor: RiskFactorType;
|
|
406
|
+
count: number;
|
|
407
|
+
percentage: number;
|
|
408
|
+
}>;
|
|
409
|
+
/** Blocked authentication attempts */
|
|
410
|
+
blockedAttempts: number;
|
|
411
|
+
/** MFA challenges issued */
|
|
412
|
+
mfaChallenges: number;
|
|
413
|
+
/** Geographic risk data */
|
|
414
|
+
locationRisk: Array<{
|
|
415
|
+
country: string;
|
|
416
|
+
riskCount: number;
|
|
417
|
+
riskScore: number;
|
|
418
|
+
}>;
|
|
419
|
+
/** Time-based risk patterns */
|
|
420
|
+
temporalPatterns: {
|
|
421
|
+
hourly: number[];
|
|
422
|
+
daily: number[];
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Risk enforcement modes
|
|
427
|
+
*/
|
|
428
|
+
type RiskEnforcementMode = 'log_only' | 'monitor' | 'block' | 'challenge_mfa';
|
|
429
|
+
/**
|
|
430
|
+
* Organization risk settings
|
|
431
|
+
*/
|
|
432
|
+
interface RiskSettings {
|
|
433
|
+
enforcement_mode: RiskEnforcementMode;
|
|
434
|
+
low_threshold: number;
|
|
435
|
+
medium_threshold: number;
|
|
436
|
+
new_device_score: number;
|
|
437
|
+
impossible_travel_score: number;
|
|
438
|
+
velocity_threshold: number;
|
|
439
|
+
velocity_score: number;
|
|
440
|
+
}
|
|
441
|
+
|
|
166
442
|
/**
|
|
167
443
|
* Device code request payload
|
|
168
444
|
*/
|
|
@@ -225,6 +501,12 @@ interface LoginUrlParams {
|
|
|
225
501
|
* Optional user code for device flow authorization
|
|
226
502
|
*/
|
|
227
503
|
user_code?: string;
|
|
504
|
+
/**
|
|
505
|
+
* Optional connection ID for enterprise IdP routing (from HRD lookup).
|
|
506
|
+
* When provided, routes user to specific upstream provider instead of using default OAuth.
|
|
507
|
+
* Example: "azure-ad-connection", "okta-enterprise"
|
|
508
|
+
*/
|
|
509
|
+
connection_id?: string;
|
|
228
510
|
}
|
|
229
511
|
/**
|
|
230
512
|
* Parameters for constructing admin login URL
|
|
@@ -262,6 +544,10 @@ interface RefreshTokenResponse {
|
|
|
262
544
|
access_token: string;
|
|
263
545
|
refresh_token: string;
|
|
264
546
|
expires_in: number;
|
|
547
|
+
/**
|
|
548
|
+
* Risk assessment details (only present if risk engine is enabled)
|
|
549
|
+
*/
|
|
550
|
+
risk_assessment?: RiskAssessment;
|
|
265
551
|
}
|
|
266
552
|
/**
|
|
267
553
|
* Registration request payload
|
|
@@ -325,6 +611,43 @@ interface MfaVerificationResponse {
|
|
|
325
611
|
refresh_token: string;
|
|
326
612
|
expires_in: number;
|
|
327
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Home Realm Discovery (HRD) request payload
|
|
616
|
+
*/
|
|
617
|
+
interface LookupEmailRequest {
|
|
618
|
+
/**
|
|
619
|
+
* Email address to lookup
|
|
620
|
+
*/
|
|
621
|
+
email: string;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Home Realm Discovery (HRD) response
|
|
625
|
+
*/
|
|
626
|
+
interface LookupEmailResponse {
|
|
627
|
+
/**
|
|
628
|
+
* The connection ID to use for authentication, if any.
|
|
629
|
+
* If present, use this to route the user to their enterprise IdP.
|
|
630
|
+
*/
|
|
631
|
+
connection_id: string | null;
|
|
632
|
+
/**
|
|
633
|
+
* The name of the upstream provider, for display purposes.
|
|
634
|
+
* Example: "Acme Corp Azure AD", "Partner Okta"
|
|
635
|
+
*/
|
|
636
|
+
provider_name: string | null;
|
|
637
|
+
/**
|
|
638
|
+
* Whether the email domain is verified.
|
|
639
|
+
* true = domain is verified and owned by an organization
|
|
640
|
+
* false = domain is not verified, use default auth flow
|
|
641
|
+
*/
|
|
642
|
+
domain_verified: boolean;
|
|
643
|
+
/**
|
|
644
|
+
* The authentication method to use:
|
|
645
|
+
* - "upstream": Route to enterprise IdP via connection_id
|
|
646
|
+
* - "password": Use email/password authentication
|
|
647
|
+
* - "oauth": Use default OAuth providers (GitHub, Google, Microsoft)
|
|
648
|
+
*/
|
|
649
|
+
auth_method: 'upstream' | 'password' | 'oauth';
|
|
650
|
+
}
|
|
328
651
|
|
|
329
652
|
/**
|
|
330
653
|
* User subscription details
|
|
@@ -413,6 +736,54 @@ interface MfaVerifyResponse {
|
|
|
413
736
|
interface BackupCodesResponse {
|
|
414
737
|
backup_codes: string[];
|
|
415
738
|
}
|
|
739
|
+
/**
|
|
740
|
+
* User device information
|
|
741
|
+
*/
|
|
742
|
+
interface UserDevice {
|
|
743
|
+
/** Unique device identifier */
|
|
744
|
+
id: string;
|
|
745
|
+
/** Device name/description */
|
|
746
|
+
device_name: string;
|
|
747
|
+
/** When the device was first seen */
|
|
748
|
+
first_seen_at: string;
|
|
749
|
+
/** When the device was last used */
|
|
750
|
+
last_used_at: string;
|
|
751
|
+
/** When the device trust expires */
|
|
752
|
+
expires_at: string;
|
|
753
|
+
/** IP address when device was registered */
|
|
754
|
+
registration_ip?: string;
|
|
755
|
+
/** Risk score for this device */
|
|
756
|
+
risk_score: number;
|
|
757
|
+
/** Whether this device is currently trusted */
|
|
758
|
+
is_trusted: boolean;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* List devices response
|
|
762
|
+
*/
|
|
763
|
+
interface ListDevicesResponse {
|
|
764
|
+
/** Array of user devices */
|
|
765
|
+
devices: UserDevice[];
|
|
766
|
+
/** Total number of devices */
|
|
767
|
+
total: number;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Revoke device request
|
|
771
|
+
*/
|
|
772
|
+
interface RevokeDeviceRequest {
|
|
773
|
+
/** Device ID to revoke */
|
|
774
|
+
device_id: string;
|
|
775
|
+
/** Optional reason for revocation */
|
|
776
|
+
reason?: string;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Revoke device response
|
|
780
|
+
*/
|
|
781
|
+
interface RevokeDeviceResponse {
|
|
782
|
+
/** Success message */
|
|
783
|
+
message: string;
|
|
784
|
+
/** Whether revocation was successful */
|
|
785
|
+
success: boolean;
|
|
786
|
+
}
|
|
416
787
|
|
|
417
788
|
/**
|
|
418
789
|
* Organization entity
|
|
@@ -577,20 +948,58 @@ interface SmtpConfigResponse {
|
|
|
577
948
|
}
|
|
578
949
|
/**
|
|
579
950
|
* Organization audit log entry
|
|
951
|
+
*
|
|
952
|
+
* This type matches the API response from GET /api/organizations/:slug/audit-log
|
|
953
|
+
* The API joins user information from the users table to provide actor details.
|
|
580
954
|
*/
|
|
581
955
|
interface AuditLog {
|
|
956
|
+
/** Unique identifier for the audit log entry */
|
|
582
957
|
id: string;
|
|
958
|
+
/** Organization ID this audit log belongs to */
|
|
583
959
|
org_id: string;
|
|
960
|
+
/** User ID who performed the action */
|
|
584
961
|
actor_user_id: string;
|
|
962
|
+
/** Email of the user who performed the action (optional, joined from users table) */
|
|
585
963
|
actor_user_email?: string;
|
|
964
|
+
/** Action that was performed (e.g., 'service.created', 'user.invited') */
|
|
586
965
|
action: string;
|
|
966
|
+
/** Type of resource that was targeted (e.g., 'service', 'user', 'organization') */
|
|
587
967
|
target_type: string;
|
|
968
|
+
/** ID of the resource that was targeted */
|
|
588
969
|
target_id: string;
|
|
970
|
+
/** IP address from which the action was performed */
|
|
589
971
|
ip_address?: string;
|
|
972
|
+
/** User agent string of the client */
|
|
590
973
|
user_agent?: string;
|
|
974
|
+
/** Whether the action was successful */
|
|
591
975
|
success: boolean;
|
|
976
|
+
/** Additional details about the action (JSON string or object) */
|
|
592
977
|
details?: string;
|
|
978
|
+
/** Timestamp when the action was recorded */
|
|
593
979
|
created_at: string;
|
|
980
|
+
/**
|
|
981
|
+
* Actor details (optional, joined from users table when available)
|
|
982
|
+
* This field is populated by the API when fetching audit logs
|
|
983
|
+
*/
|
|
984
|
+
actor?: {
|
|
985
|
+
id: string;
|
|
986
|
+
email: string;
|
|
987
|
+
};
|
|
988
|
+
/**
|
|
989
|
+
* Organization ID (deprecated: use org_id)
|
|
990
|
+
* @deprecated Use org_id instead for consistency with backend
|
|
991
|
+
*/
|
|
992
|
+
organization_id?: string;
|
|
993
|
+
/**
|
|
994
|
+
* Actor ID (deprecated: use actor_user_id)
|
|
995
|
+
* @deprecated Use actor_user_id instead for consistency with backend
|
|
996
|
+
*/
|
|
997
|
+
actor_id?: string;
|
|
998
|
+
/**
|
|
999
|
+
* Metadata about the action (optional)
|
|
1000
|
+
* Contains additional structured information about what changed
|
|
1001
|
+
*/
|
|
1002
|
+
metadata?: Record<string, any> | null;
|
|
594
1003
|
}
|
|
595
1004
|
/**
|
|
596
1005
|
* Audit log response with pagination
|
|
@@ -758,6 +1167,59 @@ interface UpdateBrandingRequest {
|
|
|
758
1167
|
logo_url?: string | null;
|
|
759
1168
|
primary_color?: string | null;
|
|
760
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Risk settings response
|
|
1172
|
+
*/
|
|
1173
|
+
interface GetRiskSettingsResponse {
|
|
1174
|
+
enforcement_mode: string;
|
|
1175
|
+
low_threshold: number;
|
|
1176
|
+
medium_threshold: number;
|
|
1177
|
+
new_device_score: number;
|
|
1178
|
+
impossible_travel_score: number;
|
|
1179
|
+
velocity_threshold: number;
|
|
1180
|
+
velocity_score: number;
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Update risk settings request
|
|
1184
|
+
*/
|
|
1185
|
+
interface UpdateRiskSettingsRequest {
|
|
1186
|
+
enforcement_mode?: string;
|
|
1187
|
+
low_threshold?: number;
|
|
1188
|
+
medium_threshold?: number;
|
|
1189
|
+
new_device_score?: number;
|
|
1190
|
+
impossible_travel_score?: number;
|
|
1191
|
+
velocity_threshold?: number;
|
|
1192
|
+
velocity_score?: number;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Update risk settings response
|
|
1196
|
+
*/
|
|
1197
|
+
interface UpdateRiskSettingsResponse {
|
|
1198
|
+
message: string;
|
|
1199
|
+
settings: GetRiskSettingsResponse;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Create SCIM token request
|
|
1203
|
+
*/
|
|
1204
|
+
interface CreateScimTokenRequest {
|
|
1205
|
+
name: string;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* SCIM token response
|
|
1209
|
+
*/
|
|
1210
|
+
interface ScimTokenResponse {
|
|
1211
|
+
id: string;
|
|
1212
|
+
name: string;
|
|
1213
|
+
token?: string;
|
|
1214
|
+
last_used_at?: string;
|
|
1215
|
+
created_at: string;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* List SCIM tokens response
|
|
1219
|
+
*/
|
|
1220
|
+
interface ListScimTokensResponse {
|
|
1221
|
+
tokens: ScimTokenResponse[];
|
|
1222
|
+
}
|
|
761
1223
|
|
|
762
1224
|
/**
|
|
763
1225
|
* Service entity
|
|
@@ -804,6 +1266,7 @@ interface Plan {
|
|
|
804
1266
|
price_cents: number;
|
|
805
1267
|
currency: string;
|
|
806
1268
|
features: string;
|
|
1269
|
+
stripe_price_id?: string;
|
|
807
1270
|
created_at: string;
|
|
808
1271
|
}
|
|
809
1272
|
/**
|
|
@@ -867,6 +1330,7 @@ interface CreatePlanPayload {
|
|
|
867
1330
|
price_cents: number;
|
|
868
1331
|
currency: string;
|
|
869
1332
|
features?: string[];
|
|
1333
|
+
stripe_price_id?: string;
|
|
870
1334
|
}
|
|
871
1335
|
/**
|
|
872
1336
|
* Update plan payload
|
|
@@ -876,6 +1340,7 @@ interface UpdatePlanPayload {
|
|
|
876
1340
|
price_cents?: number;
|
|
877
1341
|
currency?: string;
|
|
878
1342
|
features?: string[];
|
|
1343
|
+
stripe_price_id?: string | null;
|
|
879
1344
|
}
|
|
880
1345
|
/**
|
|
881
1346
|
* Service with aggregated details
|
|
@@ -982,6 +1447,21 @@ interface SamlCertificate {
|
|
|
982
1447
|
is_active: boolean;
|
|
983
1448
|
created_at: string;
|
|
984
1449
|
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Create checkout session payload
|
|
1452
|
+
*/
|
|
1453
|
+
interface CreateCheckoutPayload {
|
|
1454
|
+
plan_id: string;
|
|
1455
|
+
success_url: string;
|
|
1456
|
+
cancel_url: string;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Create checkout session response
|
|
1460
|
+
*/
|
|
1461
|
+
interface CreateCheckoutResponse {
|
|
1462
|
+
checkout_url: string;
|
|
1463
|
+
session_id: string;
|
|
1464
|
+
}
|
|
985
1465
|
|
|
986
1466
|
/**
|
|
987
1467
|
* Invitation entity
|
|
@@ -1001,7 +1481,7 @@ interface Invitation {
|
|
|
1001
1481
|
* Create invitation payload
|
|
1002
1482
|
*/
|
|
1003
1483
|
interface CreateInvitationPayload {
|
|
1004
|
-
|
|
1484
|
+
email: string;
|
|
1005
1485
|
role: MemberRole;
|
|
1006
1486
|
}
|
|
1007
1487
|
/**
|
|
@@ -1176,6 +1656,31 @@ interface PlatformAnalyticsDateRangeParams {
|
|
|
1176
1656
|
start_date?: string;
|
|
1177
1657
|
end_date?: string;
|
|
1178
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Impersonation request payload
|
|
1661
|
+
*/
|
|
1662
|
+
interface ImpersonateRequest {
|
|
1663
|
+
user_id: string;
|
|
1664
|
+
reason: string;
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* User info for impersonation response
|
|
1668
|
+
*/
|
|
1669
|
+
interface ImpersonationUserInfo {
|
|
1670
|
+
id: string;
|
|
1671
|
+
email: string;
|
|
1672
|
+
is_platform_owner: boolean;
|
|
1673
|
+
org_id?: string;
|
|
1674
|
+
org_name?: string;
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Impersonation response
|
|
1678
|
+
*/
|
|
1679
|
+
interface ImpersonateResponse {
|
|
1680
|
+
token: string;
|
|
1681
|
+
target_user: ImpersonationUserInfo;
|
|
1682
|
+
actor_user: ImpersonationUserInfo;
|
|
1683
|
+
}
|
|
1179
1684
|
|
|
1180
1685
|
/**
|
|
1181
1686
|
* End-user subscription details
|
|
@@ -1278,108 +1783,481 @@ interface AnalyticsQuery {
|
|
|
1278
1783
|
}
|
|
1279
1784
|
|
|
1280
1785
|
/**
|
|
1281
|
-
*
|
|
1786
|
+
* WebAuthn/Passkey authentication types
|
|
1282
1787
|
*/
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1788
|
+
/**
|
|
1789
|
+
* Request to start passkey registration
|
|
1790
|
+
*/
|
|
1791
|
+
interface PasskeyRegisterStartRequest {
|
|
1792
|
+
name?: string;
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Response from starting passkey registration
|
|
1796
|
+
*/
|
|
1797
|
+
interface PasskeyRegisterStartResponse {
|
|
1798
|
+
challenge_id: string;
|
|
1799
|
+
options: any;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Request to finish passkey registration
|
|
1803
|
+
*/
|
|
1804
|
+
interface PasskeyRegisterFinishRequest {
|
|
1805
|
+
challenge_id: string;
|
|
1806
|
+
credential: RegistrationResponseJSON;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Response from finishing passkey registration
|
|
1810
|
+
*/
|
|
1811
|
+
interface PasskeyRegisterFinishResponse {
|
|
1812
|
+
success: boolean;
|
|
1813
|
+
passkey_id: string;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Request to start passkey authentication
|
|
1817
|
+
*/
|
|
1818
|
+
interface PasskeyAuthStartRequest {
|
|
1819
|
+
email: string;
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Response from starting passkey authentication
|
|
1823
|
+
*/
|
|
1824
|
+
interface PasskeyAuthStartResponse {
|
|
1825
|
+
challenge_id: string;
|
|
1826
|
+
options: any;
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Request to finish passkey authentication
|
|
1830
|
+
*/
|
|
1831
|
+
interface PasskeyAuthFinishRequest {
|
|
1832
|
+
challenge_id: string;
|
|
1833
|
+
credential: AuthenticationResponseJSON;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Response from finishing passkey authentication
|
|
1837
|
+
*/
|
|
1838
|
+
interface PasskeyAuthFinishResponse {
|
|
1839
|
+
token: string;
|
|
1840
|
+
user_id: string;
|
|
1841
|
+
device_trust_token?: string;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* JSON-serializable version of WebAuthn registration response
|
|
1845
|
+
*/
|
|
1846
|
+
interface RegistrationResponseJSON {
|
|
1847
|
+
id: string;
|
|
1848
|
+
rawId: string;
|
|
1849
|
+
response: {
|
|
1850
|
+
clientDataJSON: string;
|
|
1851
|
+
attestationObject: string;
|
|
1852
|
+
transports?: string[];
|
|
1853
|
+
};
|
|
1854
|
+
authenticatorAttachment?: 'platform' | 'cross-platform';
|
|
1855
|
+
clientExtensionResults: Record<string, unknown>;
|
|
1856
|
+
type: 'public-key';
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* JSON-serializable version of WebAuthn authentication response
|
|
1860
|
+
*/
|
|
1861
|
+
interface AuthenticationResponseJSON {
|
|
1862
|
+
id: string;
|
|
1863
|
+
rawId: string;
|
|
1864
|
+
response: {
|
|
1865
|
+
clientDataJSON: string;
|
|
1866
|
+
authenticatorData: string;
|
|
1867
|
+
signature: string;
|
|
1868
|
+
userHandle?: string;
|
|
1869
|
+
};
|
|
1870
|
+
authenticatorAttachment?: 'platform' | 'cross-platform';
|
|
1871
|
+
clientExtensionResults: Record<string, unknown>;
|
|
1872
|
+
type: 'public-key';
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Passkey information
|
|
1876
|
+
*/
|
|
1877
|
+
interface Passkey {
|
|
1878
|
+
id: string;
|
|
1879
|
+
user_id: string;
|
|
1880
|
+
credential_id: string;
|
|
1881
|
+
name: string;
|
|
1882
|
+
aaguid?: string;
|
|
1883
|
+
backup_eligible: boolean;
|
|
1884
|
+
backup_state: boolean;
|
|
1885
|
+
transports?: string;
|
|
1886
|
+
last_used_at?: string;
|
|
1887
|
+
created_at: string;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* Privacy and GDPR compliance types
|
|
1892
|
+
*/
|
|
1893
|
+
/**
|
|
1894
|
+
* User membership export data
|
|
1895
|
+
*/
|
|
1896
|
+
interface MembershipExport {
|
|
1897
|
+
organization_id: string;
|
|
1898
|
+
organization_slug: string;
|
|
1899
|
+
role: string;
|
|
1900
|
+
joined_at: string;
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Login event export data
|
|
1904
|
+
*/
|
|
1905
|
+
interface LoginEventExport {
|
|
1906
|
+
id: string;
|
|
1907
|
+
timestamp: string;
|
|
1908
|
+
ip_address: string | null;
|
|
1909
|
+
user_agent: string | null;
|
|
1910
|
+
provider: string | null;
|
|
1911
|
+
success: boolean;
|
|
1912
|
+
risk_score: number | null;
|
|
1913
|
+
risk_factors: string | null;
|
|
1914
|
+
geo_country: string | null;
|
|
1915
|
+
geo_city: string | null;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* OAuth identity export data
|
|
1919
|
+
*/
|
|
1920
|
+
interface OAuthIdentityExport {
|
|
1921
|
+
provider: string;
|
|
1922
|
+
provider_user_id: string;
|
|
1923
|
+
linked_at: string;
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* MFA event export data
|
|
1927
|
+
*/
|
|
1928
|
+
interface MfaEventExport {
|
|
1929
|
+
event_type: string;
|
|
1930
|
+
timestamp: string;
|
|
1931
|
+
success: boolean;
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Passkey export data
|
|
1935
|
+
*/
|
|
1936
|
+
interface PasskeyExport {
|
|
1937
|
+
id: string;
|
|
1938
|
+
name: string | null;
|
|
1939
|
+
aaguid: string | null;
|
|
1940
|
+
backup_eligible: boolean;
|
|
1941
|
+
created_at: string;
|
|
1942
|
+
last_used_at: string | null;
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Complete user data export response (GDPR Right to Access)
|
|
1946
|
+
*/
|
|
1947
|
+
interface ExportUserDataResponse {
|
|
1948
|
+
user_id: string;
|
|
1949
|
+
email: string;
|
|
1950
|
+
created_at: string;
|
|
1951
|
+
memberships: MembershipExport[];
|
|
1952
|
+
login_events_count: number;
|
|
1953
|
+
login_events: LoginEventExport[];
|
|
1954
|
+
oauth_identities: OAuthIdentityExport[];
|
|
1955
|
+
mfa_events: MfaEventExport[];
|
|
1956
|
+
passkeys: PasskeyExport[];
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* User anonymization response (GDPR Right to be Forgotten)
|
|
1960
|
+
*/
|
|
1961
|
+
interface ForgetUserResponse {
|
|
1962
|
+
success: boolean;
|
|
1963
|
+
message: string;
|
|
1964
|
+
user_id: string;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* SIEM (Security Information and Event Management) types
|
|
1969
|
+
*/
|
|
1970
|
+
/**
|
|
1971
|
+
* SIEM provider types
|
|
1972
|
+
*/
|
|
1973
|
+
type SiemProviderType = 'Datadog' | 'Splunk' | 'Elastic' | 'Custom';
|
|
1974
|
+
/**
|
|
1975
|
+
* SIEM configuration response
|
|
1976
|
+
*/
|
|
1977
|
+
interface SiemConfigResponse {
|
|
1978
|
+
id: string;
|
|
1979
|
+
org_id: string;
|
|
1980
|
+
name: string;
|
|
1981
|
+
provider_type: SiemProviderType;
|
|
1982
|
+
endpoint_url: string;
|
|
1983
|
+
batch_size: number;
|
|
1984
|
+
enabled: boolean;
|
|
1985
|
+
last_successful_batch_at: string | null;
|
|
1986
|
+
failure_count: number;
|
|
1987
|
+
created_at: string;
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
* Create SIEM configuration request
|
|
1991
|
+
*/
|
|
1992
|
+
interface CreateSiemConfigRequest {
|
|
1993
|
+
name: string;
|
|
1994
|
+
provider_type: SiemProviderType;
|
|
1995
|
+
endpoint_url: string;
|
|
1996
|
+
api_key?: string;
|
|
1997
|
+
auth_header?: string;
|
|
1998
|
+
batch_size?: number;
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* Update SIEM configuration request
|
|
2002
|
+
*/
|
|
2003
|
+
interface UpdateSiemConfigRequest {
|
|
2004
|
+
name?: string;
|
|
2005
|
+
endpoint_url?: string;
|
|
2006
|
+
api_key?: string | null;
|
|
2007
|
+
auth_header?: string | null;
|
|
2008
|
+
batch_size?: number;
|
|
2009
|
+
enabled?: boolean;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* List SIEM configurations response
|
|
2013
|
+
*/
|
|
2014
|
+
interface ListSiemConfigsResponse {
|
|
2015
|
+
siem_configs: SiemConfigResponse[];
|
|
2016
|
+
total: number;
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Test SIEM connection response
|
|
2020
|
+
*/
|
|
2021
|
+
interface TestConnectionResponse {
|
|
2022
|
+
success: boolean;
|
|
2023
|
+
message: string;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
interface SessionConfig {
|
|
2027
|
+
storageKeyPrefix?: string;
|
|
2028
|
+
autoRefresh?: boolean;
|
|
2029
|
+
}
|
|
2030
|
+
declare class SessionManager {
|
|
2031
|
+
private storage;
|
|
2032
|
+
private refreshHandler;
|
|
2033
|
+
private config;
|
|
2034
|
+
private accessToken;
|
|
2035
|
+
private refreshToken;
|
|
2036
|
+
private refreshPromise;
|
|
2037
|
+
private listeners;
|
|
2038
|
+
constructor(storage: TokenStorage, refreshHandler: (token: string) => Promise<RefreshTokenResponse>, config?: SessionConfig);
|
|
2039
|
+
/**
|
|
2040
|
+
* Initialize session from storage
|
|
2041
|
+
*/
|
|
2042
|
+
loadSession(): Promise<void>;
|
|
2043
|
+
/**
|
|
2044
|
+
* Set the session data (used after login/register)
|
|
2045
|
+
*/
|
|
2046
|
+
setSession(tokens: {
|
|
2047
|
+
access_token: string;
|
|
2048
|
+
refresh_token?: string;
|
|
2049
|
+
}): Promise<void>;
|
|
2050
|
+
/**
|
|
2051
|
+
* Clear session (logout)
|
|
2052
|
+
*/
|
|
2053
|
+
clearSession(): Promise<void>;
|
|
2054
|
+
/**
|
|
2055
|
+
* Get the current access token, refreshing it if necessary/possible
|
|
2056
|
+
*/
|
|
2057
|
+
getToken(): Promise<string | null>;
|
|
2058
|
+
/**
|
|
2059
|
+
* Handle logic for when a 401 occurs
|
|
2060
|
+
*/
|
|
2061
|
+
refreshSession(): Promise<string>;
|
|
2062
|
+
isAuthenticated(): boolean;
|
|
2063
|
+
/**
|
|
2064
|
+
* Subscribe to auth state changes (useful for UI updates)
|
|
2065
|
+
*/
|
|
2066
|
+
subscribe(listener: (isAuthenticated: boolean) => void): () => void;
|
|
2067
|
+
private notifyListeners;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* HTTP response wrapper
|
|
2072
|
+
*/
|
|
2073
|
+
interface HttpResponse<T = any> {
|
|
2074
|
+
data: T;
|
|
2075
|
+
status: number;
|
|
2076
|
+
headers: Headers;
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* HTTP client defaults
|
|
2080
|
+
*/
|
|
2081
|
+
interface HttpDefaults {
|
|
2082
|
+
baseURL: string;
|
|
2083
|
+
headers: {
|
|
2084
|
+
common: Record<string, string>;
|
|
2085
|
+
};
|
|
2086
|
+
timeout: number;
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Custom HTTP client using native fetch API.
|
|
2090
|
+
* Provides an interface similar to Axios for easy migration.
|
|
2091
|
+
*/
|
|
2092
|
+
declare class HttpClient {
|
|
2093
|
+
defaults: HttpDefaults;
|
|
2094
|
+
private sessionManager?;
|
|
2095
|
+
constructor(baseURL: string);
|
|
2096
|
+
/**
|
|
2097
|
+
* Allow injecting session manager after construction to avoid circular dep
|
|
2098
|
+
*/
|
|
2099
|
+
setSessionManager(manager: SessionManager): void;
|
|
2100
|
+
/**
|
|
2101
|
+
* Build query string from params object
|
|
2102
|
+
*/
|
|
2103
|
+
private buildQueryString;
|
|
2104
|
+
/**
|
|
2105
|
+
* Build full URL from path and params
|
|
2106
|
+
*/
|
|
2107
|
+
private buildUrl;
|
|
2108
|
+
/**
|
|
2109
|
+
* Make HTTP request with timeout support
|
|
2110
|
+
*/
|
|
2111
|
+
private request;
|
|
2112
|
+
/**
|
|
2113
|
+
* GET request
|
|
2114
|
+
*/
|
|
2115
|
+
get<T = any>(path: string, config?: {
|
|
2116
|
+
params?: Record<string, any>;
|
|
2117
|
+
headers?: Record<string, string>;
|
|
2118
|
+
}): Promise<HttpResponse<T>>;
|
|
2119
|
+
/**
|
|
2120
|
+
* POST request
|
|
2121
|
+
*/
|
|
2122
|
+
post<T = any>(path: string, data?: any, config?: {
|
|
2123
|
+
headers?: Record<string, string>;
|
|
2124
|
+
}): Promise<HttpResponse<T>>;
|
|
2125
|
+
/**
|
|
2126
|
+
* PUT request
|
|
2127
|
+
*/
|
|
2128
|
+
put<T = any>(path: string, data?: any, config?: {
|
|
2129
|
+
headers?: Record<string, string>;
|
|
2130
|
+
}): Promise<HttpResponse<T>>;
|
|
2131
|
+
/**
|
|
2132
|
+
* PATCH request
|
|
2133
|
+
*/
|
|
2134
|
+
patch<T = any>(path: string, data?: any, config?: {
|
|
2135
|
+
headers?: Record<string, string>;
|
|
2136
|
+
}): Promise<HttpResponse<T>>;
|
|
2137
|
+
/**
|
|
2138
|
+
* DELETE request
|
|
2139
|
+
*/
|
|
2140
|
+
delete<T = any>(path: string, config?: {
|
|
2141
|
+
headers?: Record<string, string>;
|
|
2142
|
+
}): Promise<HttpResponse<T>>;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
/**
|
|
2146
|
+
* Analytics and login tracking methods
|
|
2147
|
+
*/
|
|
2148
|
+
declare class AnalyticsModule {
|
|
2149
|
+
private http;
|
|
2150
|
+
constructor(http: HttpClient);
|
|
2151
|
+
/**
|
|
2152
|
+
* Get login trends over time.
|
|
2153
|
+
* Returns daily login counts grouped by date.
|
|
2154
|
+
*
|
|
2155
|
+
* @param orgSlug Organization slug
|
|
2156
|
+
* @param params Optional query parameters (date range)
|
|
2157
|
+
* @returns Array of login trend data points
|
|
2158
|
+
*
|
|
2159
|
+
* @example
|
|
2160
|
+
* ```typescript
|
|
2161
|
+
* const trends = await sso.analytics.getLoginTrends('acme-corp', {
|
|
2162
|
+
* start_date: '2025-01-01',
|
|
2163
|
+
* end_date: '2025-01-31'
|
|
2164
|
+
* });
|
|
2165
|
+
* trends.forEach(point => console.log(point.date, point.count));
|
|
2166
|
+
* ```
|
|
2167
|
+
*/
|
|
2168
|
+
getLoginTrends(orgSlug: string, params?: AnalyticsQuery): Promise<LoginTrendPoint[]>;
|
|
2169
|
+
/**
|
|
2170
|
+
* Get login counts grouped by service.
|
|
2171
|
+
* Shows which services have the most authentication activity.
|
|
2172
|
+
*
|
|
2173
|
+
* @param orgSlug Organization slug
|
|
2174
|
+
* @param params Optional query parameters (date range)
|
|
2175
|
+
* @returns Array of login counts per service
|
|
2176
|
+
*
|
|
2177
|
+
* @example
|
|
2178
|
+
* ```typescript
|
|
2179
|
+
* const byService = await sso.analytics.getLoginsByService('acme-corp', {
|
|
2180
|
+
* start_date: '2025-01-01',
|
|
2181
|
+
* end_date: '2025-01-31'
|
|
2182
|
+
* });
|
|
2183
|
+
* byService.forEach(s => console.log(s.service_name, s.count));
|
|
2184
|
+
* ```
|
|
2185
|
+
*/
|
|
2186
|
+
getLoginsByService(orgSlug: string, params?: AnalyticsQuery): Promise<LoginsByService[]>;
|
|
2187
|
+
/**
|
|
2188
|
+
* Get login counts grouped by OAuth provider.
|
|
2189
|
+
* Shows which authentication providers are being used (GitHub, Google, Microsoft).
|
|
2190
|
+
*
|
|
2191
|
+
* @param orgSlug Organization slug
|
|
2192
|
+
* @param params Optional query parameters (date range)
|
|
2193
|
+
* @returns Array of login counts per provider
|
|
2194
|
+
*
|
|
2195
|
+
* @example
|
|
2196
|
+
* ```typescript
|
|
2197
|
+
* const byProvider = await sso.analytics.getLoginsByProvider('acme-corp', {
|
|
2198
|
+
* start_date: '2025-01-01',
|
|
2199
|
+
* end_date: '2025-01-31'
|
|
2200
|
+
* });
|
|
2201
|
+
* byProvider.forEach(p => console.log(p.provider, p.count));
|
|
2202
|
+
* ```
|
|
2203
|
+
*/
|
|
2204
|
+
getLoginsByProvider(orgSlug: string, params?: AnalyticsQuery): Promise<LoginsByProvider[]>;
|
|
2205
|
+
/**
|
|
2206
|
+
* Get the most recent login events.
|
|
2207
|
+
*
|
|
2208
|
+
* @param orgSlug Organization slug
|
|
2209
|
+
* @param params Optional query parameters (limit)
|
|
2210
|
+
* @returns Array of recent login events
|
|
2211
|
+
*
|
|
2212
|
+
* @example
|
|
2213
|
+
* ```typescript
|
|
2214
|
+
* const recentLogins = await sso.analytics.getRecentLogins('acme-corp', {
|
|
2215
|
+
* limit: 10
|
|
2216
|
+
* });
|
|
2217
|
+
* recentLogins.forEach(login => {
|
|
2218
|
+
* console.log(login.user_id, login.provider, login.created_at);
|
|
2219
|
+
* });
|
|
2220
|
+
* ```
|
|
2221
|
+
*/
|
|
2222
|
+
getRecentLogins(orgSlug: string, params?: AnalyticsQuery): Promise<RecentLogin[]>;
|
|
2223
|
+
}
|
|
2224
|
+
|
|
1360
2225
|
/**
|
|
1361
2226
|
* Authentication and OAuth flow methods
|
|
1362
2227
|
*/
|
|
1363
2228
|
declare class AuthModule {
|
|
1364
2229
|
private http;
|
|
1365
|
-
|
|
2230
|
+
private session;
|
|
2231
|
+
constructor(http: HttpClient, session: SessionManager);
|
|
1366
2232
|
/**
|
|
1367
2233
|
* Constructs the OAuth login URL for end-users.
|
|
1368
2234
|
* This does not perform the redirect; the consuming application
|
|
1369
2235
|
* should redirect the user's browser to this URL.
|
|
1370
2236
|
*
|
|
1371
2237
|
* @param provider The OAuth provider to use
|
|
1372
|
-
* @param params Login parameters (org, service, redirect_uri)
|
|
2238
|
+
* @param params Login parameters (org, service, redirect_uri, connection_id)
|
|
1373
2239
|
* @returns The full URL to redirect the user to
|
|
1374
2240
|
*
|
|
1375
2241
|
* @example
|
|
1376
2242
|
* ```typescript
|
|
2243
|
+
* // Standard OAuth login
|
|
1377
2244
|
* const url = sso.auth.getLoginUrl('github', {
|
|
1378
2245
|
* org: 'acme-corp',
|
|
1379
2246
|
* service: 'main-app',
|
|
1380
2247
|
* redirect_uri: 'https://app.acme.com/callback'
|
|
1381
2248
|
* });
|
|
1382
2249
|
* window.location.href = url;
|
|
2250
|
+
*
|
|
2251
|
+
* // Enterprise IdP login (after HRD lookup)
|
|
2252
|
+
* const hrd = await sso.auth.lookupEmail('user@enterprise.com');
|
|
2253
|
+
* if (hrd.connection_id) {
|
|
2254
|
+
* const url = sso.auth.getLoginUrl('github', {
|
|
2255
|
+
* org: 'acme-corp',
|
|
2256
|
+
* service: 'main-app',
|
|
2257
|
+
* connection_id: hrd.connection_id
|
|
2258
|
+
* });
|
|
2259
|
+
* window.location.href = url;
|
|
2260
|
+
* }
|
|
1383
2261
|
* ```
|
|
1384
2262
|
*/
|
|
1385
2263
|
getLoginUrl(provider: OAuthProvider, params: LoginUrlParams): string;
|
|
@@ -1438,6 +2316,9 @@ declare class AuthModule {
|
|
|
1438
2316
|
/**
|
|
1439
2317
|
* Exchange a device code for a JWT token.
|
|
1440
2318
|
* This should be polled by the device/CLI after displaying the user code.
|
|
2319
|
+
* Note: This returns a TokenResponse (not RefreshTokenResponse) and typically
|
|
2320
|
+
* only includes access_token. For device flows that need persistence,
|
|
2321
|
+
* manually call sso.session.setSession() if needed.
|
|
1441
2322
|
*
|
|
1442
2323
|
* @param payload Token request payload
|
|
1443
2324
|
* @returns Token response with JWT
|
|
@@ -1453,7 +2334,7 @@ declare class AuthModule {
|
|
|
1453
2334
|
* client_id: 'service-client-id'
|
|
1454
2335
|
* });
|
|
1455
2336
|
* clearInterval(interval);
|
|
1456
|
-
*
|
|
2337
|
+
* // Session is automatically configured
|
|
1457
2338
|
* } catch (error) {
|
|
1458
2339
|
* if (error.errorCode !== 'authorization_pending') {
|
|
1459
2340
|
* clearInterval(interval);
|
|
@@ -1467,15 +2348,12 @@ declare class AuthModule {
|
|
|
1467
2348
|
};
|
|
1468
2349
|
/**
|
|
1469
2350
|
* Logout the current user by revoking their JWT.
|
|
1470
|
-
*
|
|
1471
|
-
* and call `sso.setAuthToken(null)`.
|
|
2351
|
+
* Automatically clears the session and tokens from storage.
|
|
1472
2352
|
*
|
|
1473
2353
|
* @example
|
|
1474
2354
|
* ```typescript
|
|
1475
2355
|
* await sso.auth.logout();
|
|
1476
|
-
*
|
|
1477
|
-
* localStorage.removeItem('sso_access_token');
|
|
1478
|
-
* localStorage.removeItem('sso_refresh_token');
|
|
2356
|
+
* // Session is automatically cleared - no need for manual cleanup
|
|
1479
2357
|
* ```
|
|
1480
2358
|
*/
|
|
1481
2359
|
logout(): Promise<void>;
|
|
@@ -1536,10 +2414,21 @@ declare class AuthModule {
|
|
|
1536
2414
|
* ```
|
|
1537
2415
|
*/
|
|
1538
2416
|
register(payload: RegisterRequest): Promise<RegisterResponse>;
|
|
2417
|
+
/**
|
|
2418
|
+
* Verify an email address using the token from the verification email.
|
|
2419
|
+
*
|
|
2420
|
+
* @param token Verification token
|
|
2421
|
+
* @returns HTML success page string
|
|
2422
|
+
*
|
|
2423
|
+
* @example
|
|
2424
|
+
* ```typescript
|
|
2425
|
+
* const html = await sso.auth.verifyEmail('token-from-email');
|
|
2426
|
+
* ```
|
|
2427
|
+
*/
|
|
2428
|
+
verifyEmail(token: string): Promise<string>;
|
|
1539
2429
|
/**
|
|
1540
2430
|
* Login with email and password.
|
|
1541
|
-
*
|
|
1542
|
-
* The user's email must be verified before login.
|
|
2431
|
+
* Automatically persists the session and configures the client.
|
|
1543
2432
|
*
|
|
1544
2433
|
* @param payload Login credentials (email and password)
|
|
1545
2434
|
* @returns Access token, refresh token, and expiration info
|
|
@@ -1550,9 +2439,7 @@ declare class AuthModule {
|
|
|
1550
2439
|
* email: 'user@example.com',
|
|
1551
2440
|
* password: 'SecurePassword123!'
|
|
1552
2441
|
* });
|
|
1553
|
-
*
|
|
1554
|
-
* localStorage.setItem('sso_access_token', tokens.access_token);
|
|
1555
|
-
* localStorage.setItem('sso_refresh_token', tokens.refresh_token);
|
|
2442
|
+
* // Session is automatically saved - no need for manual token management
|
|
1556
2443
|
* ```
|
|
1557
2444
|
*/
|
|
1558
2445
|
login(payload: LoginRequest): Promise<RefreshTokenResponse>;
|
|
@@ -1561,6 +2448,7 @@ declare class AuthModule {
|
|
|
1561
2448
|
* This method should be called after login when the user has MFA enabled.
|
|
1562
2449
|
* The login will return a pre-auth token with a short expiration (5 minutes).
|
|
1563
2450
|
* Exchange the pre-auth token and TOTP code for a full session.
|
|
2451
|
+
* Automatically persists the session after successful MFA verification.
|
|
1564
2452
|
*
|
|
1565
2453
|
* @param preauthToken The pre-authentication token received from login
|
|
1566
2454
|
* @param code The TOTP code from the user's authenticator app or a backup code
|
|
@@ -1579,9 +2467,7 @@ declare class AuthModule {
|
|
|
1579
2467
|
* // User needs to provide MFA code
|
|
1580
2468
|
* const mfaCode = prompt('Enter your 6-digit code from authenticator app');
|
|
1581
2469
|
* const tokens = await sso.auth.verifyMfa(loginResponse.access_token, mfaCode);
|
|
1582
|
-
*
|
|
1583
|
-
* localStorage.setItem('sso_access_token', tokens.access_token);
|
|
1584
|
-
* localStorage.setItem('sso_refresh_token', tokens.refresh_token);
|
|
2470
|
+
* // Session is automatically saved - no need for manual token management
|
|
1585
2471
|
* }
|
|
1586
2472
|
* ```
|
|
1587
2473
|
*/
|
|
@@ -1620,6 +2506,44 @@ declare class AuthModule {
|
|
|
1620
2506
|
* ```
|
|
1621
2507
|
*/
|
|
1622
2508
|
resetPassword(payload: ResetPasswordRequest): Promise<ResetPasswordResponse>;
|
|
2509
|
+
/**
|
|
2510
|
+
* Lookup an email address to determine which authentication method to use.
|
|
2511
|
+
* This implements Home Realm Discovery (HRD), allowing users to simply enter
|
|
2512
|
+
* their email address and be automatically routed to the correct identity provider.
|
|
2513
|
+
*
|
|
2514
|
+
* The system will:
|
|
2515
|
+
* 1. Extract the domain from the email address
|
|
2516
|
+
* 2. Check if the domain is verified and mapped to an enterprise IdP
|
|
2517
|
+
* 3. Return routing information (connection_id) if found
|
|
2518
|
+
* 4. Otherwise, indicate to use default authentication (password or OAuth)
|
|
2519
|
+
*
|
|
2520
|
+
* @param email The user's email address
|
|
2521
|
+
* @returns HRD response with routing information
|
|
2522
|
+
*
|
|
2523
|
+
* @example
|
|
2524
|
+
* ```typescript
|
|
2525
|
+
* // Lookup email to determine authentication flow
|
|
2526
|
+
* const result = await sso.auth.lookupEmail('john@acmecorp.com');
|
|
2527
|
+
*
|
|
2528
|
+
* if (result.auth_method === 'upstream' && result.connection_id) {
|
|
2529
|
+
* // Route to enterprise IdP
|
|
2530
|
+
* console.log(`Redirecting to ${result.provider_name}`);
|
|
2531
|
+
* const url = sso.auth.getLoginUrl('github', {
|
|
2532
|
+
* org: 'acme-corp',
|
|
2533
|
+
* service: 'main-app',
|
|
2534
|
+
* connection_id: result.connection_id
|
|
2535
|
+
* });
|
|
2536
|
+
* window.location.href = url;
|
|
2537
|
+
* } else if (result.auth_method === 'password') {
|
|
2538
|
+
* // Show password login form
|
|
2539
|
+
* showPasswordForm();
|
|
2540
|
+
* } else {
|
|
2541
|
+
* // Show default OAuth provider buttons (GitHub, Google, Microsoft)
|
|
2542
|
+
* showOAuthButtons();
|
|
2543
|
+
* }
|
|
2544
|
+
* ```
|
|
2545
|
+
*/
|
|
2546
|
+
lookupEmail(email: string): Promise<LookupEmailResponse>;
|
|
1623
2547
|
}
|
|
1624
2548
|
|
|
1625
2549
|
/**
|
|
@@ -1739,6 +2663,100 @@ declare class MfaModule {
|
|
|
1739
2663
|
*/
|
|
1740
2664
|
regenerateBackupCodes(): Promise<BackupCodesResponse>;
|
|
1741
2665
|
}
|
|
2666
|
+
/**
|
|
2667
|
+
* Device management methods
|
|
2668
|
+
*/
|
|
2669
|
+
declare class DevicesModule {
|
|
2670
|
+
private http;
|
|
2671
|
+
constructor(http: HttpClient);
|
|
2672
|
+
/**
|
|
2673
|
+
* List all devices associated with the authenticated user.
|
|
2674
|
+
*
|
|
2675
|
+
* @param options Optional query parameters for pagination
|
|
2676
|
+
* @returns Array of user devices
|
|
2677
|
+
*
|
|
2678
|
+
* @example
|
|
2679
|
+
* ```typescript
|
|
2680
|
+
* const { devices, total } = await sso.user.devices.list();
|
|
2681
|
+
* console.log(devices); // Array of trusted devices
|
|
2682
|
+
* ```
|
|
2683
|
+
*/
|
|
2684
|
+
list(options?: {
|
|
2685
|
+
page?: number;
|
|
2686
|
+
limit?: number;
|
|
2687
|
+
sort_by?: 'first_seen_at' | 'last_used_at' | 'device_name';
|
|
2688
|
+
sort_order?: 'asc' | 'desc';
|
|
2689
|
+
}): Promise<ListDevicesResponse>;
|
|
2690
|
+
/**
|
|
2691
|
+
* Get details for a specific device.
|
|
2692
|
+
*
|
|
2693
|
+
* @param deviceId The device ID to retrieve
|
|
2694
|
+
* @returns Device details
|
|
2695
|
+
*
|
|
2696
|
+
* @example
|
|
2697
|
+
* ```typescript
|
|
2698
|
+
* const device = await sso.user.devices.get('device-123');
|
|
2699
|
+
* console.log(device.device_name, device.is_trusted);
|
|
2700
|
+
* ```
|
|
2701
|
+
*/
|
|
2702
|
+
get(deviceId: string): Promise<UserDevice>;
|
|
2703
|
+
/**
|
|
2704
|
+
* Revoke access for a specific device.
|
|
2705
|
+
* This will remove the device's trust and require re-authentication.
|
|
2706
|
+
*
|
|
2707
|
+
* @param deviceId The device ID to revoke
|
|
2708
|
+
* @param reason Optional reason for revocation
|
|
2709
|
+
* @returns Confirmation message
|
|
2710
|
+
*
|
|
2711
|
+
* @example
|
|
2712
|
+
* ```typescript
|
|
2713
|
+
* const result = await sso.user.devices.revoke('device-123', 'Device lost');
|
|
2714
|
+
* console.log(result.message);
|
|
2715
|
+
* ```
|
|
2716
|
+
*/
|
|
2717
|
+
revoke(deviceId: string, reason?: string): Promise<RevokeDeviceResponse>;
|
|
2718
|
+
/**
|
|
2719
|
+
* Revoke all devices except the current one.
|
|
2720
|
+
* This is useful when you suspect account compromise or want to force re-authentication on all devices.
|
|
2721
|
+
*
|
|
2722
|
+
* @returns Confirmation message
|
|
2723
|
+
*
|
|
2724
|
+
* @example
|
|
2725
|
+
* ```typescript
|
|
2726
|
+
* const result = await sso.user.devices.revokeAll();
|
|
2727
|
+
* console.log(result.message); // "All other devices have been revoked"
|
|
2728
|
+
* ```
|
|
2729
|
+
*/
|
|
2730
|
+
revokeAll(): Promise<RevokeDeviceResponse>;
|
|
2731
|
+
/**
|
|
2732
|
+
* Update the name of a device.
|
|
2733
|
+
*
|
|
2734
|
+
* @param deviceId The device ID to update
|
|
2735
|
+
* @param deviceName New device name
|
|
2736
|
+
* @returns Updated device information
|
|
2737
|
+
*
|
|
2738
|
+
* @example
|
|
2739
|
+
* ```typescript
|
|
2740
|
+
* const device = await sso.user.devices.updateName('device-123', 'My Laptop');
|
|
2741
|
+
* console.log(device.device_name); // "My Laptop"
|
|
2742
|
+
* ```
|
|
2743
|
+
*/
|
|
2744
|
+
updateName(deviceId: string, deviceName: string): Promise<UserDevice>;
|
|
2745
|
+
/**
|
|
2746
|
+
* Mark a device as trusted manually.
|
|
2747
|
+
* This is useful for devices that you want to explicitly trust regardless of risk assessment.
|
|
2748
|
+
*
|
|
2749
|
+
* @param deviceId The device ID to trust
|
|
2750
|
+
* @returns Updated device information
|
|
2751
|
+
*
|
|
2752
|
+
* @example
|
|
2753
|
+
* ```typescript
|
|
2754
|
+
* const device = await sso.user.devices.trust('device-123');
|
|
2755
|
+
* console.log(device.is_trusted); // true
|
|
2756
|
+
* ```
|
|
2757
|
+
*/
|
|
2758
|
+
trust(deviceId: string): Promise<UserDevice>;
|
|
2759
|
+
}
|
|
1742
2760
|
/**
|
|
1743
2761
|
* User profile and subscription methods
|
|
1744
2762
|
*/
|
|
@@ -1746,6 +2764,7 @@ declare class UserModule {
|
|
|
1746
2764
|
private http;
|
|
1747
2765
|
readonly identities: IdentitiesModule;
|
|
1748
2766
|
readonly mfa: MfaModule;
|
|
2767
|
+
readonly devices: DevicesModule;
|
|
1749
2768
|
constructor(http: HttpClient);
|
|
1750
2769
|
/**
|
|
1751
2770
|
* Get the profile of the currently authenticated user.
|
|
@@ -2132,6 +3151,28 @@ declare class OrganizationsModule {
|
|
|
2132
3151
|
* ```
|
|
2133
3152
|
*/
|
|
2134
3153
|
delete(orgSlug: string): Promise<void>;
|
|
3154
|
+
/**
|
|
3155
|
+
* SCIM token management methods
|
|
3156
|
+
*/
|
|
3157
|
+
scim: {
|
|
3158
|
+
/**
|
|
3159
|
+
* Create a new SCIM token.
|
|
3160
|
+
* The token is only returned once upon creation.
|
|
3161
|
+
*/
|
|
3162
|
+
createToken: (orgSlug: string, payload: CreateScimTokenRequest) => Promise<ScimTokenResponse>;
|
|
3163
|
+
/**
|
|
3164
|
+
* List all SCIM tokens.
|
|
3165
|
+
*/
|
|
3166
|
+
listTokens: (orgSlug: string) => Promise<ListScimTokensResponse>;
|
|
3167
|
+
/**
|
|
3168
|
+
* Revoke a SCIM token.
|
|
3169
|
+
*/
|
|
3170
|
+
revokeToken: (orgSlug: string, tokenId: string) => Promise<void>;
|
|
3171
|
+
/**
|
|
3172
|
+
* Delete a SCIM token.
|
|
3173
|
+
*/
|
|
3174
|
+
deleteToken: (orgSlug: string, tokenId: string) => Promise<void>;
|
|
3175
|
+
};
|
|
2135
3176
|
/**
|
|
2136
3177
|
* Member management methods
|
|
2137
3178
|
*/
|
|
@@ -2150,6 +3191,16 @@ declare class OrganizationsModule {
|
|
|
2150
3191
|
* ```
|
|
2151
3192
|
*/
|
|
2152
3193
|
list: (orgSlug: string) => Promise<MemberListResponse>;
|
|
3194
|
+
/**
|
|
3195
|
+
* Add a member to the organization (Invite + Accept).
|
|
3196
|
+
* This is a convenience method that creates an invitation and immediately accepts it.
|
|
3197
|
+
* Useful for testing and admin operations.
|
|
3198
|
+
*
|
|
3199
|
+
* @param orgSlug Organization slug
|
|
3200
|
+
* @param payload Member details (email, role)
|
|
3201
|
+
* @returns The created invitation
|
|
3202
|
+
*/
|
|
3203
|
+
add: (orgSlug: string, payload: CreateInvitationPayload) => Promise<Invitation>;
|
|
2153
3204
|
/**
|
|
2154
3205
|
* Update a member's role.
|
|
2155
3206
|
* Requires 'owner' role.
|
|
@@ -2473,6 +3524,170 @@ declare class OrganizationsModule {
|
|
|
2473
3524
|
* ```
|
|
2474
3525
|
*/
|
|
2475
3526
|
getPublicBranding(orgSlug: string): Promise<BrandingConfiguration>;
|
|
3527
|
+
/**
|
|
3528
|
+
* Risk settings management methods
|
|
3529
|
+
*/
|
|
3530
|
+
riskSettings: {
|
|
3531
|
+
/**
|
|
3532
|
+
* Get risk settings for an organization.
|
|
3533
|
+
* Requires 'owner' or 'admin' role.
|
|
3534
|
+
*
|
|
3535
|
+
* @param orgSlug Organization slug
|
|
3536
|
+
* @returns Risk settings configuration
|
|
3537
|
+
*
|
|
3538
|
+
* @example
|
|
3539
|
+
* ```typescript
|
|
3540
|
+
* const settings = await sso.organizations.riskSettings.get('acme-corp');
|
|
3541
|
+
* console.log('Enforcement mode:', settings.enforcement_mode);
|
|
3542
|
+
* console.log('Low threshold:', settings.low_threshold);
|
|
3543
|
+
* ```
|
|
3544
|
+
*/
|
|
3545
|
+
get: (orgSlug: string) => Promise<GetRiskSettingsResponse>;
|
|
3546
|
+
/**
|
|
3547
|
+
* Update risk settings for an organization.
|
|
3548
|
+
* Requires 'owner' or 'admin' role.
|
|
3549
|
+
*
|
|
3550
|
+
* @param orgSlug Organization slug
|
|
3551
|
+
* @param payload Risk settings update payload
|
|
3552
|
+
* @returns Updated risk settings
|
|
3553
|
+
*
|
|
3554
|
+
* @example
|
|
3555
|
+
* ```typescript
|
|
3556
|
+
* const result = await sso.organizations.riskSettings.update('acme-corp', {
|
|
3557
|
+
* enforcement_mode: 'challenge',
|
|
3558
|
+
* low_threshold: 30,
|
|
3559
|
+
* medium_threshold: 70,
|
|
3560
|
+
* new_device_score: 20,
|
|
3561
|
+
* impossible_travel_score: 50
|
|
3562
|
+
* });
|
|
3563
|
+
* console.log(result.message);
|
|
3564
|
+
* ```
|
|
3565
|
+
*/
|
|
3566
|
+
update: (orgSlug: string, payload: UpdateRiskSettingsRequest) => Promise<UpdateRiskSettingsResponse>;
|
|
3567
|
+
/**
|
|
3568
|
+
* Reset risk settings to default values.
|
|
3569
|
+
* Requires 'owner' or 'admin' role.
|
|
3570
|
+
*
|
|
3571
|
+
* @param orgSlug Organization slug
|
|
3572
|
+
* @returns Reset confirmation with default values
|
|
3573
|
+
*
|
|
3574
|
+
* @example
|
|
3575
|
+
* ```typescript
|
|
3576
|
+
* const result = await sso.organizations.riskSettings.reset('acme-corp');
|
|
3577
|
+
* console.log('Risk settings reset to defaults');
|
|
3578
|
+
* ```
|
|
3579
|
+
*/
|
|
3580
|
+
reset: (orgSlug: string) => Promise<UpdateRiskSettingsResponse>;
|
|
3581
|
+
};
|
|
3582
|
+
/**
|
|
3583
|
+
* SIEM (Security Information and Event Management) configuration methods
|
|
3584
|
+
*/
|
|
3585
|
+
siem: {
|
|
3586
|
+
/**
|
|
3587
|
+
* Create a new SIEM configuration.
|
|
3588
|
+
* Requires 'owner' or 'admin' role.
|
|
3589
|
+
*
|
|
3590
|
+
* @param orgSlug Organization slug
|
|
3591
|
+
* @param payload SIEM configuration payload
|
|
3592
|
+
* @returns Created SIEM configuration
|
|
3593
|
+
*
|
|
3594
|
+
* @example
|
|
3595
|
+
* ```typescript
|
|
3596
|
+
* const config = await sso.organizations.siem.create('acme-corp', {
|
|
3597
|
+
* name: 'Datadog Integration',
|
|
3598
|
+
* provider_type: 'Datadog',
|
|
3599
|
+
* endpoint_url: 'https://http-intake.logs.datadoghq.com/v1/input',
|
|
3600
|
+
* api_key: 'dd-api-key',
|
|
3601
|
+
* batch_size: 100
|
|
3602
|
+
* });
|
|
3603
|
+
* ```
|
|
3604
|
+
*/
|
|
3605
|
+
create: (orgSlug: string, payload: CreateSiemConfigRequest) => Promise<SiemConfigResponse>;
|
|
3606
|
+
/**
|
|
3607
|
+
* List all SIEM configurations for an organization.
|
|
3608
|
+
* Requires 'owner' or 'admin' role.
|
|
3609
|
+
*
|
|
3610
|
+
* @param orgSlug Organization slug
|
|
3611
|
+
* @returns List of SIEM configurations
|
|
3612
|
+
*
|
|
3613
|
+
* @example
|
|
3614
|
+
* ```typescript
|
|
3615
|
+
* const result = await sso.organizations.siem.list('acme-corp');
|
|
3616
|
+
* console.log(`Total SIEM configs: ${result.total}`);
|
|
3617
|
+
* result.siem_configs.forEach(config => {
|
|
3618
|
+
* console.log(config.name, config.provider_type, config.enabled);
|
|
3619
|
+
* });
|
|
3620
|
+
* ```
|
|
3621
|
+
*/
|
|
3622
|
+
list: (orgSlug: string) => Promise<ListSiemConfigsResponse>;
|
|
3623
|
+
/**
|
|
3624
|
+
* Get a specific SIEM configuration.
|
|
3625
|
+
* Requires 'owner' or 'admin' role.
|
|
3626
|
+
*
|
|
3627
|
+
* @param orgSlug Organization slug
|
|
3628
|
+
* @param configId SIEM configuration ID
|
|
3629
|
+
* @returns SIEM configuration
|
|
3630
|
+
*
|
|
3631
|
+
* @example
|
|
3632
|
+
* ```typescript
|
|
3633
|
+
* const config = await sso.organizations.siem.get('acme-corp', 'config-id');
|
|
3634
|
+
* console.log(config.name, config.endpoint_url);
|
|
3635
|
+
* ```
|
|
3636
|
+
*/
|
|
3637
|
+
get: (orgSlug: string, configId: string) => Promise<SiemConfigResponse>;
|
|
3638
|
+
/**
|
|
3639
|
+
* Update a SIEM configuration.
|
|
3640
|
+
* Requires 'owner' or 'admin' role.
|
|
3641
|
+
*
|
|
3642
|
+
* @param orgSlug Organization slug
|
|
3643
|
+
* @param configId SIEM configuration ID
|
|
3644
|
+
* @param payload Update payload
|
|
3645
|
+
* @returns Updated SIEM configuration
|
|
3646
|
+
*
|
|
3647
|
+
* @example
|
|
3648
|
+
* ```typescript
|
|
3649
|
+
* const updated = await sso.organizations.siem.update('acme-corp', 'config-id', {
|
|
3650
|
+
* enabled: false,
|
|
3651
|
+
* batch_size: 200
|
|
3652
|
+
* });
|
|
3653
|
+
* ```
|
|
3654
|
+
*/
|
|
3655
|
+
update: (orgSlug: string, configId: string, payload: UpdateSiemConfigRequest) => Promise<SiemConfigResponse>;
|
|
3656
|
+
/**
|
|
3657
|
+
* Delete a SIEM configuration.
|
|
3658
|
+
* Requires 'owner' or 'admin' role.
|
|
3659
|
+
*
|
|
3660
|
+
* @param orgSlug Organization slug
|
|
3661
|
+
* @param configId SIEM configuration ID
|
|
3662
|
+
*
|
|
3663
|
+
* @example
|
|
3664
|
+
* ```typescript
|
|
3665
|
+
* await sso.organizations.siem.delete('acme-corp', 'config-id');
|
|
3666
|
+
* console.log('SIEM configuration deleted');
|
|
3667
|
+
* ```
|
|
3668
|
+
*/
|
|
3669
|
+
delete: (orgSlug: string, configId: string) => Promise<void>;
|
|
3670
|
+
/**
|
|
3671
|
+
* Test connection to a SIEM endpoint.
|
|
3672
|
+
* Sends a test event to verify the configuration.
|
|
3673
|
+
* Requires 'owner' or 'admin' role.
|
|
3674
|
+
*
|
|
3675
|
+
* @param orgSlug Organization slug
|
|
3676
|
+
* @param configId SIEM configuration ID
|
|
3677
|
+
* @returns Test result
|
|
3678
|
+
*
|
|
3679
|
+
* @example
|
|
3680
|
+
* ```typescript
|
|
3681
|
+
* const result = await sso.organizations.siem.test('acme-corp', 'config-id');
|
|
3682
|
+
* if (result.success) {
|
|
3683
|
+
* console.log('Connection successful:', result.message);
|
|
3684
|
+
* } else {
|
|
3685
|
+
* console.error('Connection failed:', result.message);
|
|
3686
|
+
* }
|
|
3687
|
+
* ```
|
|
3688
|
+
*/
|
|
3689
|
+
test: (orgSlug: string, configId: string) => Promise<TestConnectionResponse>;
|
|
3690
|
+
};
|
|
2476
3691
|
}
|
|
2477
3692
|
|
|
2478
3693
|
/**
|
|
@@ -2530,7 +3745,7 @@ declare class ServicesModule {
|
|
|
2530
3745
|
* console.log(service.plans);
|
|
2531
3746
|
* ```
|
|
2532
3747
|
*/
|
|
2533
|
-
get(orgSlug: string, serviceSlug: string): Promise<
|
|
3748
|
+
get(orgSlug: string, serviceSlug: string): Promise<Service>;
|
|
2534
3749
|
/**
|
|
2535
3750
|
* Update service configuration.
|
|
2536
3751
|
* Requires 'owner' or 'admin' role.
|
|
@@ -2807,6 +4022,21 @@ declare class ServicesModule {
|
|
|
2807
4022
|
* ```
|
|
2808
4023
|
*/
|
|
2809
4024
|
deleteConfig: (orgSlug: string, serviceSlug: string) => Promise<ConfigureSamlResponse>;
|
|
4025
|
+
/**
|
|
4026
|
+
* Initiate an IdP-initiated SAML login.
|
|
4027
|
+
* Returns an HTML page with an auto-submitting form that POSTs the SAML assertion to the Service Provider.
|
|
4028
|
+
*
|
|
4029
|
+
* @param orgSlug Organization slug
|
|
4030
|
+
* @param serviceSlug Service slug
|
|
4031
|
+
* @returns HTML page with auto-submitting form
|
|
4032
|
+
*
|
|
4033
|
+
* @example
|
|
4034
|
+
* ```typescript
|
|
4035
|
+
* const html = await sso.services.saml.initiateLogin('acme-corp', 'salesforce');
|
|
4036
|
+
* document.body.innerHTML = html; // Auto-submits
|
|
4037
|
+
* ```
|
|
4038
|
+
*/
|
|
4039
|
+
initiateLogin: (orgSlug: string, serviceSlug: string) => Promise<string>;
|
|
2810
4040
|
/**
|
|
2811
4041
|
* Generate a new SAML signing certificate for the IdP.
|
|
2812
4042
|
* Requires 'owner' or 'admin' role.
|
|
@@ -2888,6 +4118,35 @@ declare class ServicesModule {
|
|
|
2888
4118
|
*/
|
|
2889
4119
|
getSsoUrl: (baseURL: string, orgSlug: string, serviceSlug: string) => string;
|
|
2890
4120
|
};
|
|
4121
|
+
/**
|
|
4122
|
+
* Stripe billing and checkout methods
|
|
4123
|
+
*/
|
|
4124
|
+
billing: {
|
|
4125
|
+
/**
|
|
4126
|
+
* Create a Stripe checkout session for the authenticated user to subscribe to a plan.
|
|
4127
|
+
* Requires organization membership.
|
|
4128
|
+
*
|
|
4129
|
+
* IMPORTANT: The plan must have a `stripe_price_id` configured to be available for purchase.
|
|
4130
|
+
*
|
|
4131
|
+
* @param orgSlug Organization slug
|
|
4132
|
+
* @param serviceSlug Service slug
|
|
4133
|
+
* @param payload Checkout payload containing plan_id and redirect URLs
|
|
4134
|
+
* @returns Checkout session with URL to redirect user to
|
|
4135
|
+
*
|
|
4136
|
+
* @example
|
|
4137
|
+
* ```typescript
|
|
4138
|
+
* const checkout = await sso.services.billing.createCheckout('acme-corp', 'main-app', {
|
|
4139
|
+
* plan_id: 'plan_pro',
|
|
4140
|
+
* success_url: 'https://app.acme.com/billing/success?session_id={CHECKOUT_SESSION_ID}',
|
|
4141
|
+
* cancel_url: 'https://app.acme.com/billing/cancel'
|
|
4142
|
+
* });
|
|
4143
|
+
*
|
|
4144
|
+
* // Redirect user to Stripe checkout
|
|
4145
|
+
* window.location.href = checkout.checkout_url;
|
|
4146
|
+
* ```
|
|
4147
|
+
*/
|
|
4148
|
+
createCheckout: (orgSlug: string, serviceSlug: string, payload: CreateCheckoutPayload) => Promise<CreateCheckoutResponse>;
|
|
4149
|
+
};
|
|
2891
4150
|
}
|
|
2892
4151
|
|
|
2893
4152
|
/**
|
|
@@ -2907,7 +4166,7 @@ declare class InvitationsModule {
|
|
|
2907
4166
|
* @example
|
|
2908
4167
|
* ```typescript
|
|
2909
4168
|
* const invitation = await sso.invitations.create('acme-corp', {
|
|
2910
|
-
*
|
|
4169
|
+
* email: 'newuser@example.com',
|
|
2911
4170
|
* role: 'member'
|
|
2912
4171
|
* });
|
|
2913
4172
|
* ```
|
|
@@ -3304,6 +4563,38 @@ declare class PlatformModule {
|
|
|
3304
4563
|
*/
|
|
3305
4564
|
getRecentOrganizations: (params?: GetAuditLogParams) => Promise<RecentOrganization[]>;
|
|
3306
4565
|
};
|
|
4566
|
+
/**
|
|
4567
|
+
* Impersonate a user (Platform Owner or Org Admin only).
|
|
4568
|
+
* Returns a short-lived JWT (15 minutes) that allows acting as the target user.
|
|
4569
|
+
*
|
|
4570
|
+
* Security:
|
|
4571
|
+
* - Platform Owners can impersonate any user
|
|
4572
|
+
* - Organization Admins can only impersonate users within their organization
|
|
4573
|
+
* - All impersonation actions are logged to the platform audit log with HIGH severity
|
|
4574
|
+
* - Tokens contain RFC 8693 actor claim for full audit trail
|
|
4575
|
+
*
|
|
4576
|
+
* @param payload Impersonation details (user_id and reason)
|
|
4577
|
+
* @returns Impersonation token and user context
|
|
4578
|
+
*
|
|
4579
|
+
* @example
|
|
4580
|
+
* ```typescript
|
|
4581
|
+
* const result = await sso.platform.impersonateUser({
|
|
4582
|
+
* user_id: 'user-uuid-123',
|
|
4583
|
+
* reason: 'Investigating support ticket #456'
|
|
4584
|
+
* });
|
|
4585
|
+
*
|
|
4586
|
+
* // Use the returned token to create a new client acting as the user
|
|
4587
|
+
* const userClient = new SsoClient({
|
|
4588
|
+
* baseURL: 'https://sso.example.com',
|
|
4589
|
+
* token: result.token
|
|
4590
|
+
* });
|
|
4591
|
+
*
|
|
4592
|
+
* // Now all requests with userClient are made as the target user
|
|
4593
|
+
* const profile = await userClient.user.getProfile();
|
|
4594
|
+
* console.log('Acting as:', result.target_user.email);
|
|
4595
|
+
* ```
|
|
4596
|
+
*/
|
|
4597
|
+
impersonateUser(payload: ImpersonateRequest): Promise<ImpersonateResponse>;
|
|
3307
4598
|
}
|
|
3308
4599
|
|
|
3309
4600
|
/**
|
|
@@ -3369,9 +4660,31 @@ interface ServiceApiInfo {
|
|
|
3369
4660
|
service_type: string;
|
|
3370
4661
|
created_at: string;
|
|
3371
4662
|
}
|
|
4663
|
+
/**
|
|
4664
|
+
* Response for list users endpoint
|
|
4665
|
+
*/
|
|
4666
|
+
interface ListUsersResponse {
|
|
4667
|
+
users: ServiceApiUser[];
|
|
4668
|
+
total: number;
|
|
4669
|
+
}
|
|
4670
|
+
/**
|
|
4671
|
+
* Response for list subscriptions endpoint
|
|
4672
|
+
*/
|
|
4673
|
+
interface ListSubscriptionsResponse {
|
|
4674
|
+
subscriptions: ServiceApiSubscription[];
|
|
4675
|
+
total: number;
|
|
4676
|
+
}
|
|
4677
|
+
/**
|
|
4678
|
+
* Service analytics response
|
|
4679
|
+
*/
|
|
4680
|
+
interface ServiceAnalytics {
|
|
4681
|
+
total_users: number;
|
|
4682
|
+
active_subscriptions: number;
|
|
4683
|
+
[key: string]: any;
|
|
4684
|
+
}
|
|
3372
4685
|
/**
|
|
3373
4686
|
* Service API module for API key-based service-to-service operations.
|
|
3374
|
-
* Provides
|
|
4687
|
+
* Provides operations for managing users, subscriptions, and service configuration.
|
|
3375
4688
|
*
|
|
3376
4689
|
* @example
|
|
3377
4690
|
* ```typescript
|
|
@@ -3380,6 +4693,9 @@ interface ServiceApiInfo {
|
|
|
3380
4693
|
* apiKey: 'sk_live_abcd1234...'
|
|
3381
4694
|
* });
|
|
3382
4695
|
*
|
|
4696
|
+
* // List users
|
|
4697
|
+
* const { users, total } = await sso.serviceApi.listUsers({ limit: 50 });
|
|
4698
|
+
*
|
|
3383
4699
|
* // Create a user
|
|
3384
4700
|
* const user = await sso.serviceApi.createUser({ email: 'user@example.com' });
|
|
3385
4701
|
*
|
|
@@ -3397,6 +4713,58 @@ interface ServiceApiInfo {
|
|
|
3397
4713
|
declare class ServiceApiModule {
|
|
3398
4714
|
private http;
|
|
3399
4715
|
constructor(http: HttpClient);
|
|
4716
|
+
/**
|
|
4717
|
+
* List all users for the service
|
|
4718
|
+
* Requires 'read:users' permission on the API key
|
|
4719
|
+
*
|
|
4720
|
+
* @param params Optional pagination parameters
|
|
4721
|
+
* @returns List of users with total count
|
|
4722
|
+
*/
|
|
4723
|
+
listUsers(params?: {
|
|
4724
|
+
limit?: number;
|
|
4725
|
+
offset?: number;
|
|
4726
|
+
}): Promise<ListUsersResponse>;
|
|
4727
|
+
/**
|
|
4728
|
+
* Get a specific user by ID
|
|
4729
|
+
* Requires 'read:users' permission on the API key
|
|
4730
|
+
*
|
|
4731
|
+
* @param userId User ID to retrieve
|
|
4732
|
+
* @returns User details
|
|
4733
|
+
*/
|
|
4734
|
+
getUser(userId: string): Promise<ServiceApiUser>;
|
|
4735
|
+
/**
|
|
4736
|
+
* List all subscriptions for the service
|
|
4737
|
+
* Requires 'read:subscriptions' permission on the API key
|
|
4738
|
+
*
|
|
4739
|
+
* @param params Optional pagination parameters
|
|
4740
|
+
* @returns List of subscriptions with total count
|
|
4741
|
+
*/
|
|
4742
|
+
listSubscriptions(params?: {
|
|
4743
|
+
limit?: number;
|
|
4744
|
+
offset?: number;
|
|
4745
|
+
}): Promise<ListSubscriptionsResponse>;
|
|
4746
|
+
/**
|
|
4747
|
+
* Get subscription for a specific user
|
|
4748
|
+
* Requires 'read:subscriptions' permission on the API key
|
|
4749
|
+
*
|
|
4750
|
+
* @param userId User ID whose subscription to retrieve
|
|
4751
|
+
* @returns User's subscription
|
|
4752
|
+
*/
|
|
4753
|
+
getSubscription(userId: string): Promise<ServiceApiSubscription>;
|
|
4754
|
+
/**
|
|
4755
|
+
* Get analytics for the service
|
|
4756
|
+
* Requires 'read:analytics' permission on the API key
|
|
4757
|
+
*
|
|
4758
|
+
* @returns Service analytics data
|
|
4759
|
+
*/
|
|
4760
|
+
getAnalytics(): Promise<ServiceAnalytics>;
|
|
4761
|
+
/**
|
|
4762
|
+
* Get service information
|
|
4763
|
+
* Requires 'read:service' permission on the API key
|
|
4764
|
+
*
|
|
4765
|
+
* @returns Service information
|
|
4766
|
+
*/
|
|
4767
|
+
getServiceInfo(): Promise<ServiceApiInfo>;
|
|
3400
4768
|
/**
|
|
3401
4769
|
* Create a new user
|
|
3402
4770
|
* Requires 'write:users' permission on the API key
|
|
@@ -3455,6 +4823,463 @@ declare class ServiceApiModule {
|
|
|
3455
4823
|
deleteSubscription(userId: string): Promise<void>;
|
|
3456
4824
|
}
|
|
3457
4825
|
|
|
4826
|
+
/**
|
|
4827
|
+
* Permission checking and management methods
|
|
4828
|
+
*
|
|
4829
|
+
* This module provides utilities for working with ReBAC (Relationship-Based Access Control)
|
|
4830
|
+
* permissions. Permissions use Zanzibar-style relation tuples and are now fetched from the
|
|
4831
|
+
* API instead of being embedded in JWT tokens (for improved security and smaller token size).
|
|
4832
|
+
*/
|
|
4833
|
+
declare class PermissionsModule {
|
|
4834
|
+
private http;
|
|
4835
|
+
constructor(http: HttpClient);
|
|
4836
|
+
/**
|
|
4837
|
+
* Check if user has a specific permission.
|
|
4838
|
+
* Fetches from user profile API (which uses cached permissions).
|
|
4839
|
+
*
|
|
4840
|
+
* @param permission Permission in format "namespace:object_id#relation"
|
|
4841
|
+
* @returns true if the permission is present
|
|
4842
|
+
*
|
|
4843
|
+
* @example
|
|
4844
|
+
* ```typescript
|
|
4845
|
+
* const hasAccess = await sso.permissions.hasPermission('organization:acme#owner');
|
|
4846
|
+
* ```
|
|
4847
|
+
*/
|
|
4848
|
+
hasPermission(permission: string): Promise<boolean>;
|
|
4849
|
+
/**
|
|
4850
|
+
* Get all user permissions.
|
|
4851
|
+
* Fetches from user profile API (which uses cached permissions).
|
|
4852
|
+
*
|
|
4853
|
+
* @returns Array of permission strings
|
|
4854
|
+
*
|
|
4855
|
+
* @example
|
|
4856
|
+
* ```typescript
|
|
4857
|
+
* const permissions = await sso.permissions.listPermissions();
|
|
4858
|
+
* // ["organization:acme#owner", "service:api#admin"]
|
|
4859
|
+
* ```
|
|
4860
|
+
*/
|
|
4861
|
+
listPermissions(): Promise<string[]>;
|
|
4862
|
+
/**
|
|
4863
|
+
* Check if user has access to a feature.
|
|
4864
|
+
*
|
|
4865
|
+
* @param feature Feature name to check
|
|
4866
|
+
* @returns true if the feature is available
|
|
4867
|
+
*
|
|
4868
|
+
* @example
|
|
4869
|
+
* ```typescript
|
|
4870
|
+
* const canExport = await sso.permissions.hasFeature('advanced-export');
|
|
4871
|
+
* ```
|
|
4872
|
+
*/
|
|
4873
|
+
hasFeature(feature: string): Promise<boolean>;
|
|
4874
|
+
/**
|
|
4875
|
+
* Get current plan name.
|
|
4876
|
+
*
|
|
4877
|
+
* @returns Current plan name or null if not in org/service context
|
|
4878
|
+
*
|
|
4879
|
+
* @example
|
|
4880
|
+
* ```typescript
|
|
4881
|
+
* const plan = await sso.permissions.getPlan();
|
|
4882
|
+
* console.log(plan); // "pro", "enterprise", etc.
|
|
4883
|
+
* ```
|
|
4884
|
+
*/
|
|
4885
|
+
getPlan(): Promise<string | null>;
|
|
4886
|
+
/**
|
|
4887
|
+
* Check if user has a specific permission on a resource.
|
|
4888
|
+
*
|
|
4889
|
+
* @param namespace The permission namespace (e.g., "organization", "service")
|
|
4890
|
+
* @param objectId The object ID (e.g., organization slug, service slug)
|
|
4891
|
+
* @param relation The relation type (e.g., "owner", "admin", "member")
|
|
4892
|
+
* @returns true if the user has the permission
|
|
4893
|
+
*
|
|
4894
|
+
* @example
|
|
4895
|
+
* ```typescript
|
|
4896
|
+
* const isOwner = await sso.permissions.can('organization', 'acme-corp', 'owner');
|
|
4897
|
+
* ```
|
|
4898
|
+
*/
|
|
4899
|
+
can(namespace: string, objectId: string, relation: string): Promise<boolean>;
|
|
4900
|
+
/**
|
|
4901
|
+
* Check if user is a member of an organization.
|
|
4902
|
+
*
|
|
4903
|
+
* @param orgId The organization ID or slug
|
|
4904
|
+
* @returns true if the user is a member
|
|
4905
|
+
*
|
|
4906
|
+
* @example
|
|
4907
|
+
* ```typescript
|
|
4908
|
+
* if (await sso.permissions.isOrgMember('acme-corp')) {
|
|
4909
|
+
* // User is a member
|
|
4910
|
+
* }
|
|
4911
|
+
* ```
|
|
4912
|
+
*/
|
|
4913
|
+
isOrgMember(orgId: string): Promise<boolean>;
|
|
4914
|
+
/**
|
|
4915
|
+
* Check if user is an admin of an organization.
|
|
4916
|
+
*
|
|
4917
|
+
* @param orgId The organization ID or slug
|
|
4918
|
+
* @returns true if the user is an admin
|
|
4919
|
+
*
|
|
4920
|
+
* @example
|
|
4921
|
+
* ```typescript
|
|
4922
|
+
* if (await sso.permissions.isOrgAdmin('acme-corp')) {
|
|
4923
|
+
* // User is an admin
|
|
4924
|
+
* }
|
|
4925
|
+
* ```
|
|
4926
|
+
*/
|
|
4927
|
+
isOrgAdmin(orgId: string): Promise<boolean>;
|
|
4928
|
+
/**
|
|
4929
|
+
* Check if user is an owner of an organization.
|
|
4930
|
+
*
|
|
4931
|
+
* @param orgId The organization ID or slug
|
|
4932
|
+
* @returns true if the user is an owner
|
|
4933
|
+
*
|
|
4934
|
+
* @example
|
|
4935
|
+
* ```typescript
|
|
4936
|
+
* if (await sso.permissions.isOrgOwner('acme-corp')) {
|
|
4937
|
+
* // User is an owner
|
|
4938
|
+
* }
|
|
4939
|
+
* ```
|
|
4940
|
+
*/
|
|
4941
|
+
isOrgOwner(orgId: string): Promise<boolean>;
|
|
4942
|
+
/**
|
|
4943
|
+
* Check if user has access to a service.
|
|
4944
|
+
*
|
|
4945
|
+
* @param serviceId The service ID or slug
|
|
4946
|
+
* @returns true if the user has access
|
|
4947
|
+
*
|
|
4948
|
+
* @example
|
|
4949
|
+
* ```typescript
|
|
4950
|
+
* if (await sso.permissions.hasServiceAccess('api-service')) {
|
|
4951
|
+
* // User has access to the service
|
|
4952
|
+
* }
|
|
4953
|
+
* ```
|
|
4954
|
+
*/
|
|
4955
|
+
hasServiceAccess(serviceId: string): Promise<boolean>;
|
|
4956
|
+
/**
|
|
4957
|
+
* Filter permissions by namespace.
|
|
4958
|
+
*
|
|
4959
|
+
* @param namespace The namespace to filter by (e.g., "organization", "service")
|
|
4960
|
+
* @returns Array of permissions matching the namespace
|
|
4961
|
+
*
|
|
4962
|
+
* @example
|
|
4963
|
+
* ```typescript
|
|
4964
|
+
* const orgPermissions = await sso.permissions.getPermissionsByNamespace('organization');
|
|
4965
|
+
* ```
|
|
4966
|
+
*/
|
|
4967
|
+
getPermissionsByNamespace(namespace: string): Promise<string[]>;
|
|
4968
|
+
/**
|
|
4969
|
+
* @deprecated Use `hasPermission()` instead (without token parameter)
|
|
4970
|
+
* Decode a JWT token to extract claims (including permissions)
|
|
4971
|
+
* Note: This does NOT verify the signature - it only decodes the payload
|
|
4972
|
+
*
|
|
4973
|
+
* @param token The JWT access token
|
|
4974
|
+
* @returns The decoded JWT claims
|
|
4975
|
+
* @throws Error if the token is malformed
|
|
4976
|
+
*/
|
|
4977
|
+
decodeToken(token: string): JwtClaims;
|
|
4978
|
+
/**
|
|
4979
|
+
* @deprecated JWT tokens no longer contain permissions. Use `hasPermission(permission)` instead.
|
|
4980
|
+
* Check if a JWT token contains a specific permission
|
|
4981
|
+
*
|
|
4982
|
+
* @param token The JWT access token (ignored)
|
|
4983
|
+
* @param permission Permission in format "namespace:object_id#relation"
|
|
4984
|
+
* @returns true if the permission is present in the token
|
|
4985
|
+
*/
|
|
4986
|
+
hasPermissionFromToken(token: string, permission: string): boolean;
|
|
4987
|
+
/**
|
|
4988
|
+
* @deprecated JWT tokens no longer contain permissions. Use `can(namespace, objectId, relation)` instead.
|
|
4989
|
+
* Check if a user has a specific permission on a resource
|
|
4990
|
+
*
|
|
4991
|
+
* @param token The JWT access token (ignored)
|
|
4992
|
+
* @param namespace The permission namespace (e.g., "organization", "service")
|
|
4993
|
+
* @param objectId The object ID (e.g., organization slug, service slug)
|
|
4994
|
+
* @param relation The relation type (e.g., "owner", "admin", "member")
|
|
4995
|
+
* @returns true if the user has the permission
|
|
4996
|
+
*/
|
|
4997
|
+
canFromToken(token: string, namespace: string, objectId: string, relation: string): boolean;
|
|
4998
|
+
/**
|
|
4999
|
+
* @deprecated JWT tokens no longer contain permissions. Use `isOrgMember(orgId)` instead.
|
|
5000
|
+
* Check if user is a member of an organization
|
|
5001
|
+
*
|
|
5002
|
+
* @param token The JWT access token (ignored)
|
|
5003
|
+
* @param orgId The organization ID or slug
|
|
5004
|
+
* @returns true if the user is a member
|
|
5005
|
+
*/
|
|
5006
|
+
isOrgMemberFromToken(token: string, orgId: string): boolean;
|
|
5007
|
+
/**
|
|
5008
|
+
* @deprecated JWT tokens no longer contain permissions. Use `isOrgAdmin(orgId)` instead.
|
|
5009
|
+
* Check if user is an admin of an organization
|
|
5010
|
+
*
|
|
5011
|
+
* @param token The JWT access token (ignored)
|
|
5012
|
+
* @param orgId The organization ID or slug
|
|
5013
|
+
* @returns true if the user is an admin
|
|
5014
|
+
*/
|
|
5015
|
+
isOrgAdminFromToken(token: string, orgId: string): boolean;
|
|
5016
|
+
/**
|
|
5017
|
+
* @deprecated JWT tokens no longer contain permissions. Use `isOrgOwner(orgId)` instead.
|
|
5018
|
+
* Check if user is an owner of an organization
|
|
5019
|
+
*
|
|
5020
|
+
* @param token The JWT access token (ignored)
|
|
5021
|
+
* @param orgId The organization ID or slug
|
|
5022
|
+
* @returns true if the user is an owner
|
|
5023
|
+
*/
|
|
5024
|
+
isOrgOwnerFromToken(token: string, orgId: string): boolean;
|
|
5025
|
+
/**
|
|
5026
|
+
* @deprecated JWT tokens no longer contain permissions. Use `hasServiceAccess(serviceId)` instead.
|
|
5027
|
+
* Check if user has access to a service
|
|
5028
|
+
*
|
|
5029
|
+
* @param token The JWT access token (ignored)
|
|
5030
|
+
* @param serviceId The service ID or slug
|
|
5031
|
+
* @returns true if the user has access
|
|
5032
|
+
*/
|
|
5033
|
+
hasServiceAccessFromToken(token: string, serviceId: string): boolean;
|
|
5034
|
+
/**
|
|
5035
|
+
* @deprecated JWT tokens no longer contain permissions. Use `listPermissions()` instead.
|
|
5036
|
+
* Get all permissions from a JWT token
|
|
5037
|
+
*
|
|
5038
|
+
* @param token The JWT access token
|
|
5039
|
+
* @returns Array of permission strings, or empty array if none
|
|
5040
|
+
*/
|
|
5041
|
+
getAllPermissionsFromToken(token: string): string[];
|
|
5042
|
+
/**
|
|
5043
|
+
* Parse a permission string into its components
|
|
5044
|
+
*
|
|
5045
|
+
* @param permission Permission string in format "namespace:object_id#relation"
|
|
5046
|
+
* @returns Parsed permission components or null if invalid format
|
|
5047
|
+
*
|
|
5048
|
+
* @example
|
|
5049
|
+
* ```typescript
|
|
5050
|
+
* const parsed = sso.permissions.parsePermission('organization:acme#owner');
|
|
5051
|
+
* // { namespace: 'organization', objectId: 'acme', relation: 'owner' }
|
|
5052
|
+
* ```
|
|
5053
|
+
*/
|
|
5054
|
+
parsePermission(permission: string): {
|
|
5055
|
+
namespace: string;
|
|
5056
|
+
objectId: string;
|
|
5057
|
+
relation: string;
|
|
5058
|
+
} | null;
|
|
5059
|
+
/**
|
|
5060
|
+
* @deprecated JWT tokens no longer contain permissions. Use `getPermissionsByNamespace(namespace)` instead.
|
|
5061
|
+
* Filter permissions by namespace
|
|
5062
|
+
*
|
|
5063
|
+
* @param token The JWT access token (ignored)
|
|
5064
|
+
* @param namespace The namespace to filter by (e.g., "organization", "service")
|
|
5065
|
+
* @returns Array of permissions matching the namespace
|
|
5066
|
+
*/
|
|
5067
|
+
getPermissionsByNamespaceFromToken(token: string, namespace: string): string[];
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5070
|
+
/**
|
|
5071
|
+
* WebAuthn/Passkey authentication module
|
|
5072
|
+
*
|
|
5073
|
+
* Provides methods for registering and authenticating with FIDO2 passkeys.
|
|
5074
|
+
* Requires a browser environment with WebAuthn support.
|
|
5075
|
+
*
|
|
5076
|
+
* @example
|
|
5077
|
+
* ```typescript
|
|
5078
|
+
* // Register a new passkey (requires authenticated session)
|
|
5079
|
+
* await sso.passkeys.register();
|
|
5080
|
+
*
|
|
5081
|
+
* // Login with passkey
|
|
5082
|
+
* const { token } = await sso.passkeys.login('user@example.com');
|
|
5083
|
+
* sso.setToken(token);
|
|
5084
|
+
* ```
|
|
5085
|
+
*/
|
|
5086
|
+
declare class PasskeysModule {
|
|
5087
|
+
private http;
|
|
5088
|
+
constructor(http: HttpClient);
|
|
5089
|
+
/**
|
|
5090
|
+
* Check if WebAuthn is supported in the current browser
|
|
5091
|
+
*/
|
|
5092
|
+
isSupported(): boolean;
|
|
5093
|
+
/**
|
|
5094
|
+
* Check if platform authenticator (like Touch ID, Face ID, Windows Hello) is available
|
|
5095
|
+
*/
|
|
5096
|
+
isPlatformAuthenticatorAvailable(): Promise<boolean>;
|
|
5097
|
+
/**
|
|
5098
|
+
* Register a new passkey for the authenticated user
|
|
5099
|
+
*
|
|
5100
|
+
* This method requires an authenticated session (JWT token must be set).
|
|
5101
|
+
* It starts the WebAuthn registration ceremony, prompts the user to create
|
|
5102
|
+
* a passkey using their device's authenticator (e.g., Touch ID, Face ID,
|
|
5103
|
+
* Windows Hello, or hardware security key), and stores the credential.
|
|
5104
|
+
*
|
|
5105
|
+
* @param displayName Optional display name for the passkey
|
|
5106
|
+
* @returns Promise resolving to the registered passkey ID
|
|
5107
|
+
* @throws {Error} If WebAuthn is not supported or registration fails
|
|
5108
|
+
*
|
|
5109
|
+
* @example
|
|
5110
|
+
* ```typescript
|
|
5111
|
+
* try {
|
|
5112
|
+
* const passkeyId = await sso.passkeys.register('My MacBook Pro');
|
|
5113
|
+
* console.log('Passkey registered:', passkeyId);
|
|
5114
|
+
* } catch (error) {
|
|
5115
|
+
* console.error('Passkey registration failed:', error);
|
|
5116
|
+
* }
|
|
5117
|
+
* ```
|
|
5118
|
+
*/
|
|
5119
|
+
/**
|
|
5120
|
+
* Start the passkey registration ceremony.
|
|
5121
|
+
* returns the options required to create credentials in the browser.
|
|
5122
|
+
*/
|
|
5123
|
+
registerStart(displayName?: string): Promise<PasskeyRegisterStartResponse>;
|
|
5124
|
+
/**
|
|
5125
|
+
* Finish the passkey registration ceremony.
|
|
5126
|
+
* Verifies the credential created by the browser.
|
|
5127
|
+
*/
|
|
5128
|
+
registerFinish(challengeId: string, credential: RegistrationResponseJSON): Promise<PasskeyRegisterFinishResponse>;
|
|
5129
|
+
/**
|
|
5130
|
+
* Register a new passkey for the authenticated user
|
|
5131
|
+
* ...
|
|
5132
|
+
*/
|
|
5133
|
+
register(displayName?: string): Promise<string>;
|
|
5134
|
+
/**
|
|
5135
|
+
* Authenticate with a passkey and obtain a JWT token
|
|
5136
|
+
*
|
|
5137
|
+
* This method prompts the user to authenticate using their passkey.
|
|
5138
|
+
* Upon successful authentication, a JWT token is returned which can
|
|
5139
|
+
* be used to make authenticated API requests.
|
|
5140
|
+
*
|
|
5141
|
+
* @param email User's email address
|
|
5142
|
+
* @returns Promise resolving to authentication response with JWT token
|
|
5143
|
+
* @throws {Error} If WebAuthn is not supported or authentication fails
|
|
5144
|
+
*
|
|
5145
|
+
* @example
|
|
5146
|
+
* ```typescript
|
|
5147
|
+
* try {
|
|
5148
|
+
* const { token, user_id } = await sso.passkeys.login('user@example.com');
|
|
5149
|
+
* sso.setToken(token);
|
|
5150
|
+
* console.log('Logged in as:', user_id);
|
|
5151
|
+
* } catch (error) {
|
|
5152
|
+
* console.error('Passkey login failed:', error);
|
|
5153
|
+
* }
|
|
5154
|
+
* ```
|
|
5155
|
+
*/
|
|
5156
|
+
/**
|
|
5157
|
+
* Start the passkey authentication ceremony.
|
|
5158
|
+
* Returns the options required to get credentials from the browser.
|
|
5159
|
+
*/
|
|
5160
|
+
authenticateStart(email: string): Promise<PasskeyAuthStartResponse>;
|
|
5161
|
+
/**
|
|
5162
|
+
* Finish the passkey authentication ceremony.
|
|
5163
|
+
* Verifies the assertion returned by the browser.
|
|
5164
|
+
*/
|
|
5165
|
+
authenticateFinish(challengeId: string, credential: AuthenticationResponseJSON): Promise<PasskeyAuthFinishResponse>;
|
|
5166
|
+
/**
|
|
5167
|
+
* Authenticate with a passkey and obtain a JWT token
|
|
5168
|
+
* ...
|
|
5169
|
+
*/
|
|
5170
|
+
login(email: string): Promise<PasskeyAuthFinishResponse>;
|
|
5171
|
+
/**
|
|
5172
|
+
* Convert Base64URL string to Uint8Array
|
|
5173
|
+
*/
|
|
5174
|
+
private base64UrlToUint8Array;
|
|
5175
|
+
/**
|
|
5176
|
+
* Convert Uint8Array to Base64URL string
|
|
5177
|
+
*/
|
|
5178
|
+
private uint8ArrayToBase64Url;
|
|
5179
|
+
}
|
|
5180
|
+
|
|
5181
|
+
/**
|
|
5182
|
+
* Magic link request payload
|
|
5183
|
+
*/
|
|
5184
|
+
interface MagicLinkRequest {
|
|
5185
|
+
/** Email address to send the magic link to */
|
|
5186
|
+
email: string;
|
|
5187
|
+
/** Optional organization context */
|
|
5188
|
+
orgSlug?: string;
|
|
5189
|
+
}
|
|
5190
|
+
/**
|
|
5191
|
+
* Magic link response
|
|
5192
|
+
*/
|
|
5193
|
+
interface MagicLinkResponse {
|
|
5194
|
+
/** Success message */
|
|
5195
|
+
message: string;
|
|
5196
|
+
}
|
|
5197
|
+
/**
|
|
5198
|
+
* Magic links module for passwordless authentication
|
|
5199
|
+
*/
|
|
5200
|
+
declare class MagicLinks {
|
|
5201
|
+
private http;
|
|
5202
|
+
constructor(http: HttpClient);
|
|
5203
|
+
/**
|
|
5204
|
+
* Request a magic link to be sent to the user's email
|
|
5205
|
+
*
|
|
5206
|
+
* @param data Magic link request data
|
|
5207
|
+
* @returns Promise resolving to magic link response
|
|
5208
|
+
*/
|
|
5209
|
+
request(data: MagicLinkRequest): Promise<MagicLinkResponse>;
|
|
5210
|
+
/**
|
|
5211
|
+
* Verify a magic link token and complete authentication
|
|
5212
|
+
* Note: This is typically handled by redirecting to the magic link URL
|
|
5213
|
+
* The backend will handle verification and either redirect or return tokens
|
|
5214
|
+
*
|
|
5215
|
+
* @param token The magic link token to verify
|
|
5216
|
+
* @param redirectUri Optional where to redirect after success
|
|
5217
|
+
* @returns URL to redirect to for verification
|
|
5218
|
+
*/
|
|
5219
|
+
getVerificationUrl(token: string, redirectUri?: string): string;
|
|
5220
|
+
/**
|
|
5221
|
+
* Verify a magic link token via API call
|
|
5222
|
+
* This is an alternative to redirect-based verification
|
|
5223
|
+
*
|
|
5224
|
+
* @param token The magic link token
|
|
5225
|
+
* @param redirectUri Optional redirect URI
|
|
5226
|
+
* @returns Promise resolving to authentication response
|
|
5227
|
+
*/
|
|
5228
|
+
verify(token: string, redirectUri?: string): Promise<any>;
|
|
5229
|
+
/**
|
|
5230
|
+
* Construct the complete magic link URL that would be sent via email
|
|
5231
|
+
*
|
|
5232
|
+
* @param token The magic link token
|
|
5233
|
+
* @param redirectUri Optional redirect URI
|
|
5234
|
+
* @returns Complete magic link URL
|
|
5235
|
+
*/
|
|
5236
|
+
constructMagicLink(token: string, redirectUri?: string): string;
|
|
5237
|
+
}
|
|
5238
|
+
|
|
5239
|
+
/**
|
|
5240
|
+
* Privacy and GDPR compliance methods
|
|
5241
|
+
*/
|
|
5242
|
+
declare class PrivacyModule {
|
|
5243
|
+
private http;
|
|
5244
|
+
constructor(http: HttpClient);
|
|
5245
|
+
/**
|
|
5246
|
+
* Export all user data (GDPR Right to Access).
|
|
5247
|
+
* Users can export their own data, or organization owners can export their members' data.
|
|
5248
|
+
*
|
|
5249
|
+
* @param userId User ID to export data for
|
|
5250
|
+
* @returns Complete user data export including memberships, login events, identities, MFA events, and passkeys
|
|
5251
|
+
*
|
|
5252
|
+
* @example
|
|
5253
|
+
* ```typescript
|
|
5254
|
+
* const userData = await sso.privacy.exportData('user-id');
|
|
5255
|
+
* console.log(`Exported ${userData.login_events_count} login events`);
|
|
5256
|
+
* console.log(`User has ${userData.memberships.length} organization memberships`);
|
|
5257
|
+
* ```
|
|
5258
|
+
*/
|
|
5259
|
+
exportData(userId: string): Promise<ExportUserDataResponse>;
|
|
5260
|
+
/**
|
|
5261
|
+
* Anonymize user data (GDPR Right to be Forgotten).
|
|
5262
|
+
* Requires organization owner permission for all organizations the user is a member of.
|
|
5263
|
+
* Platform owners cannot be anonymized.
|
|
5264
|
+
*
|
|
5265
|
+
* This operation:
|
|
5266
|
+
* - Soft-deletes the user account
|
|
5267
|
+
* - Hard-deletes PII from identities and passkeys tables
|
|
5268
|
+
* - Preserves audit logs for compliance
|
|
5269
|
+
*
|
|
5270
|
+
* @param userId User ID to anonymize
|
|
5271
|
+
* @returns Anonymization confirmation response
|
|
5272
|
+
*
|
|
5273
|
+
* @example
|
|
5274
|
+
* ```typescript
|
|
5275
|
+
* const result = await sso.privacy.forgetUser('user-id');
|
|
5276
|
+
* console.log(result.message);
|
|
5277
|
+
* // "User data has been anonymized. PII has been removed while preserving audit logs."
|
|
5278
|
+
* ```
|
|
5279
|
+
*/
|
|
5280
|
+
forgetUser(userId: string): Promise<ForgetUserResponse>;
|
|
5281
|
+
}
|
|
5282
|
+
|
|
3458
5283
|
/**
|
|
3459
5284
|
* Configuration options for the SSO client
|
|
3460
5285
|
*/
|
|
@@ -3471,6 +5296,15 @@ interface SsoClientOptions {
|
|
|
3471
5296
|
* Optional API key for service-to-service authentication
|
|
3472
5297
|
*/
|
|
3473
5298
|
apiKey?: string;
|
|
5299
|
+
/**
|
|
5300
|
+
* Custom storage provider (optional).
|
|
5301
|
+
* Defaults to localStorage in browser, Memory in Node.
|
|
5302
|
+
*/
|
|
5303
|
+
storage?: TokenStorage;
|
|
5304
|
+
/**
|
|
5305
|
+
* Prefix for storage keys. Default: 'sso_'
|
|
5306
|
+
*/
|
|
5307
|
+
storagePrefix?: string;
|
|
3474
5308
|
}
|
|
3475
5309
|
/**
|
|
3476
5310
|
* Main SSO client class.
|
|
@@ -3489,7 +5323,8 @@ interface SsoClientOptions {
|
|
|
3489
5323
|
* ```
|
|
3490
5324
|
*/
|
|
3491
5325
|
declare class SsoClient {
|
|
3492
|
-
|
|
5326
|
+
http: HttpClient;
|
|
5327
|
+
private session;
|
|
3493
5328
|
/**
|
|
3494
5329
|
* Analytics and login tracking methods
|
|
3495
5330
|
*/
|
|
@@ -3522,6 +5357,22 @@ declare class SsoClient {
|
|
|
3522
5357
|
* Service API methods (requires API key authentication)
|
|
3523
5358
|
*/
|
|
3524
5359
|
readonly serviceApi: ServiceApiModule;
|
|
5360
|
+
/**
|
|
5361
|
+
* Permission checking and management methods
|
|
5362
|
+
*/
|
|
5363
|
+
readonly permissions: PermissionsModule;
|
|
5364
|
+
/**
|
|
5365
|
+
* WebAuthn/Passkey authentication methods
|
|
5366
|
+
*/
|
|
5367
|
+
readonly passkeys: PasskeysModule;
|
|
5368
|
+
/**
|
|
5369
|
+
* Magic link authentication methods
|
|
5370
|
+
*/
|
|
5371
|
+
readonly magicLinks: MagicLinks;
|
|
5372
|
+
/**
|
|
5373
|
+
* Privacy and GDPR compliance methods
|
|
5374
|
+
*/
|
|
5375
|
+
readonly privacy: PrivacyModule;
|
|
3525
5376
|
constructor(options: SsoClientOptions);
|
|
3526
5377
|
/**
|
|
3527
5378
|
* Sets the JWT for all subsequent authenticated requests.
|
|
@@ -3559,6 +5410,34 @@ declare class SsoClient {
|
|
|
3559
5410
|
* Gets the current base URL
|
|
3560
5411
|
*/
|
|
3561
5412
|
getBaseURL(): string;
|
|
5413
|
+
/**
|
|
5414
|
+
* Check if the user is currently authenticated
|
|
5415
|
+
*/
|
|
5416
|
+
isAuthenticated(): boolean;
|
|
5417
|
+
/**
|
|
5418
|
+
* Subscribe to authentication state changes.
|
|
5419
|
+
* Useful for updating UI when login/logout/expiration occurs.
|
|
5420
|
+
*
|
|
5421
|
+
* @param listener Callback function that receives the authentication state
|
|
5422
|
+
* @returns Unsubscribe function
|
|
5423
|
+
*
|
|
5424
|
+
* @example
|
|
5425
|
+
* ```typescript
|
|
5426
|
+
* const unsubscribe = sso.onAuthStateChange((isAuth) => {
|
|
5427
|
+
* console.log(isAuth ? 'User is logged in' : 'User is logged out');
|
|
5428
|
+
* });
|
|
5429
|
+
*
|
|
5430
|
+
* // Later, to stop listening
|
|
5431
|
+
* unsubscribe();
|
|
5432
|
+
* ```
|
|
5433
|
+
*/
|
|
5434
|
+
onAuthStateChange(listener: (isAuthenticated: boolean) => void): () => void;
|
|
5435
|
+
/**
|
|
5436
|
+
* Manually retrieve the current access token
|
|
5437
|
+
*
|
|
5438
|
+
* @returns The current access token, or null if not authenticated
|
|
5439
|
+
*/
|
|
5440
|
+
getToken(): Promise<string | null>;
|
|
3562
5441
|
}
|
|
3563
5442
|
|
|
3564
5443
|
/**
|
|
@@ -3597,4 +5476,4 @@ declare class SsoApiError extends Error {
|
|
|
3597
5476
|
isNotFound(): boolean;
|
|
3598
5477
|
}
|
|
3599
5478
|
|
|
3600
|
-
export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthModule, type BackupCodesResponse, type BrandingConfiguration, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, type CreateApiKeyPayload, type CreateInvitationPayload, type CreateOrganizationPayload, type CreateOrganizationResponse, type CreatePlanPayload, type CreateServicePayload, type CreateServiceResponse, type CreateWebhookRequest, type DeclineInvitationPayload, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceVerifyResponse, type DomainConfiguration, type DomainVerificationMethod, type DomainVerificationResponse, type DomainVerificationResult, type EndUser, type EndUserDetailResponse, type EndUserIdentity, type EndUserListResponse, type EndUserSubscription, type EventTypeInfo, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetAuditLogParams, type GrowthTrendPoint, type Identity, type Invitation, type InvitationStatus, type InvitationWithOrg, InvitationsModule, type JwtClaims, type ListApiKeysResponse, type ListEndUsersParams, type ListOrganizationsParams, type ListPlatformOrganizationsParams, type LoginActivityPoint, type LoginRequest, type LoginTrendPoint, type LoginUrlParams, type LoginsByProvider, type LoginsByService, type MemberListResponse, type MemberRole, type Membership, type MfaSetupResponse, type MfaStatusResponse, type MfaVerificationRequest, type MfaVerificationResponse, type MfaVerifyRequest, type MfaVerifyResponse, type OAuthCredentials, type OAuthProvider, type Organization, type OrganizationMember, type OrganizationResponse, type OrganizationStatus, type OrganizationStatusBreakdown, type OrganizationTier, OrganizationsModule, type PaginatedResponse, type PaginationInfo, type PaginationParams, type Plan, type PlanResponse, type PlatformAnalyticsDateRangeParams, PlatformModule, type PlatformOrganizationResponse, type PlatformOrganizationsListResponse, type PlatformOverviewMetrics, type PromotePlatformOwnerPayload, type ProviderToken, type ProviderTokenGrant, type RecentLogin, type RecentOrganization, type RefreshTokenRequest, type RefreshTokenResponse, type RegisterRequest, type RegisterResponse, type RejectOrganizationPayload, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeSessionsResponse, type SamlCertificate, type SamlConfig, type Service, ServiceApiModule, type ServiceListResponse, type ServiceResponse, type ServiceType, type ServiceWithDetails, ServicesModule, type SetCustomDomainRequest, type SetOAuthCredentialsPayload, type SetPasswordRequest, type SetPasswordResponse, type SetSmtpRequest, type SmtpConfigResponse, SsoApiError, SsoClient, type SsoClientOptions, type StartLinkResponse, type Subscription, type TokenRequest, type TokenResponse, type TopOrganization, type TransferOwnershipPayload, type UpdateBrandingRequest, type UpdateMemberRolePayload, type UpdateOrganizationPayload, type UpdateOrganizationTierPayload, type UpdatePlanPayload, type UpdateServicePayload, type UpdateUserProfilePayload, type UpdateWebhookRequest, type User, UserModule, type UserProfile, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQueryParams, type WebhookListResponse, type WebhookResponse };
|
|
5479
|
+
export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthMethod, AuthModule, type AuthenticationResponseJSON, type BackupCodesResponse, type BrandingConfiguration, BrowserStorage, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, type CreateApiKeyPayload, type CreateCheckoutPayload, type CreateCheckoutResponse, type CreateInvitationPayload, type CreateOrganizationPayload, type CreateOrganizationResponse, type CreatePlanPayload, type CreateScimTokenRequest, type CreateServicePayload, type CreateServiceResponse, type CreateSiemConfigRequest, type CreateWebhookRequest, type DeclineInvitationPayload, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceTrust, type DeviceVerifyResponse, type DomainConfiguration, type DomainVerificationMethod, type DomainVerificationResponse, type DomainVerificationResult, type EndUser, type EndUserDetailResponse, type EndUserIdentity, type EndUserListResponse, type EndUserSubscription, type EventTypeInfo, type ExportUserDataResponse, type ForgetUserResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GeolocationData, type GetAuditLogParams, type GetRiskSettingsResponse, type GrowthTrendPoint, type Identity, type ImpersonateRequest, type ImpersonateResponse, type ImpersonationUserInfo, type Invitation, type InvitationStatus, type InvitationWithOrg, InvitationsModule, type JwtClaims, type ListApiKeysResponse, type ListDevicesResponse, type ListEndUsersParams, type ListOrganizationsParams, type ListPlatformOrganizationsParams, type ListScimTokensResponse, type ListSiemConfigsResponse, type LoginActivityPoint, type LoginEventExport, type LoginRequest, type LoginTrendPoint, type LoginUrlParams, type LoginsByProvider, type LoginsByService, type LookupEmailRequest, type LookupEmailResponse, MagicLinks, type MemberListResponse, type MemberRole, type Membership, type MembershipExport, MemoryStorage, type MfaEventExport, type MfaSetupResponse, type MfaStatusResponse, type MfaVerificationRequest, type MfaVerificationResponse, type MfaVerifyRequest, type MfaVerifyResponse, type OAuthCredentials, type OAuthIdentityExport, type OAuthProvider, type Organization, type OrganizationMember, type OrganizationResponse, type OrganizationStatus, type OrganizationStatusBreakdown, type OrganizationTier, OrganizationsModule, type PaginatedResponse, type PaginationInfo, type PaginationParams, type Passkey, type PasskeyAuthFinishRequest, type PasskeyAuthFinishResponse, type PasskeyAuthStartRequest, type PasskeyAuthStartResponse, type PasskeyExport, type PasskeyRegisterFinishRequest, type PasskeyRegisterFinishResponse, type PasskeyRegisterStartRequest, type PasskeyRegisterStartResponse, PasskeysModule, PermissionsModule, type Plan, type PlanResponse, type PlatformAnalyticsDateRangeParams, PlatformModule, type PlatformOrganizationResponse, type PlatformOrganizationsListResponse, type PlatformOverviewMetrics, type PromotePlatformOwnerPayload, type ProviderToken, type ProviderTokenGrant, type RecentLogin, type RecentOrganization, type RefreshTokenRequest, type RefreshTokenResponse, type RegisterRequest, type RegisterResponse, type RegistrationResponseJSON, type RejectOrganizationPayload, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDeviceRequest, type RevokeDeviceResponse, type RevokeSessionsResponse, RiskAction, type RiskAnalytics, type RiskAssessment, type RiskContext, type RiskEnforcementMode, type RiskEngineConfig, type RiskEvent, RiskEventOutcome, type RiskFactor, RiskFactorType, type RiskRule, type RiskRuleCondition, type RiskScore, type RiskSettings, type SamlCertificate, type SamlConfig, type ScimTokenResponse, type Service, ServiceApiModule, type ServiceListResponse, type ServiceResponse, type ServiceType, type ServiceWithDetails, ServicesModule, type SetCustomDomainRequest, type SetOAuthCredentialsPayload, type SetPasswordRequest, type SetPasswordResponse, type SetSmtpRequest, type SiemConfigResponse, type SiemProviderType, type SmtpConfigResponse, SsoApiError, SsoClient, type SsoClientOptions, type StartLinkResponse, type Subscription, type TestConnectionResponse, type TokenRequest, type TokenResponse, type TokenStorage, type TopOrganization, type TransferOwnershipPayload, type UpdateBrandingRequest, type UpdateMemberRolePayload, type UpdateOrganizationPayload, type UpdateOrganizationTierPayload, type UpdatePlanPayload, type UpdateRiskSettingsRequest, type UpdateRiskSettingsResponse, type UpdateServicePayload, type UpdateSiemConfigRequest, type UpdateUserProfilePayload, type UpdateWebhookRequest, type User, type UserDevice, UserModule, type UserProfile, type Webhook, type WebhookDelivery, type WebhookDeliveryListResponse, type WebhookDeliveryQueryParams, type WebhookListResponse, type WebhookResponse };
|