@drmhse/sso-sdk 0.2.9 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.mts +618 -350
- package/dist/index.d.ts +618 -350
- package/dist/index.js +253 -29
- package/dist/index.mjs +253 -29
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ interface PaginationParams {
|
|
|
71
71
|
/**
|
|
72
72
|
* OAuth provider types
|
|
73
73
|
*/
|
|
74
|
-
type OAuthProvider = 'github' | 'google' | 'microsoft';
|
|
74
|
+
type OAuthProvider = 'github' | 'google' | 'microsoft' | 'oidc';
|
|
75
75
|
/**
|
|
76
76
|
* Organization status types
|
|
77
77
|
*/
|
|
@@ -137,6 +137,308 @@ interface JwtClaims {
|
|
|
137
137
|
iat: number;
|
|
138
138
|
}
|
|
139
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
|
+
|
|
140
442
|
/**
|
|
141
443
|
* Device code request payload
|
|
142
444
|
*/
|
|
@@ -242,6 +544,10 @@ interface RefreshTokenResponse {
|
|
|
242
544
|
access_token: string;
|
|
243
545
|
refresh_token: string;
|
|
244
546
|
expires_in: number;
|
|
547
|
+
/**
|
|
548
|
+
* Risk assessment details (only present if risk engine is enabled)
|
|
549
|
+
*/
|
|
550
|
+
risk_assessment?: RiskAssessment;
|
|
245
551
|
}
|
|
246
552
|
/**
|
|
247
553
|
* Registration request payload
|
|
@@ -642,20 +948,58 @@ interface SmtpConfigResponse {
|
|
|
642
948
|
}
|
|
643
949
|
/**
|
|
644
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.
|
|
645
954
|
*/
|
|
646
955
|
interface AuditLog {
|
|
956
|
+
/** Unique identifier for the audit log entry */
|
|
647
957
|
id: string;
|
|
958
|
+
/** Organization ID this audit log belongs to */
|
|
648
959
|
org_id: string;
|
|
960
|
+
/** User ID who performed the action */
|
|
649
961
|
actor_user_id: string;
|
|
962
|
+
/** Email of the user who performed the action (optional, joined from users table) */
|
|
650
963
|
actor_user_email?: string;
|
|
964
|
+
/** Action that was performed (e.g., 'service.created', 'user.invited') */
|
|
651
965
|
action: string;
|
|
966
|
+
/** Type of resource that was targeted (e.g., 'service', 'user', 'organization') */
|
|
652
967
|
target_type: string;
|
|
968
|
+
/** ID of the resource that was targeted */
|
|
653
969
|
target_id: string;
|
|
970
|
+
/** IP address from which the action was performed */
|
|
654
971
|
ip_address?: string;
|
|
972
|
+
/** User agent string of the client */
|
|
655
973
|
user_agent?: string;
|
|
974
|
+
/** Whether the action was successful */
|
|
656
975
|
success: boolean;
|
|
976
|
+
/** Additional details about the action (JSON string or object) */
|
|
657
977
|
details?: string;
|
|
978
|
+
/** Timestamp when the action was recorded */
|
|
658
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;
|
|
659
1003
|
}
|
|
660
1004
|
/**
|
|
661
1005
|
* Audit log response with pagination
|
|
@@ -854,6 +1198,28 @@ interface UpdateRiskSettingsResponse {
|
|
|
854
1198
|
message: string;
|
|
855
1199
|
settings: GetRiskSettingsResponse;
|
|
856
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
|
+
}
|
|
857
1223
|
|
|
858
1224
|
/**
|
|
859
1225
|
* Service entity
|
|
@@ -1115,7 +1481,7 @@ interface Invitation {
|
|
|
1115
1481
|
* Create invitation payload
|
|
1116
1482
|
*/
|
|
1117
1483
|
interface CreateInvitationPayload {
|
|
1118
|
-
|
|
1484
|
+
email: string;
|
|
1119
1485
|
role: MemberRole;
|
|
1120
1486
|
}
|
|
1121
1487
|
/**
|
|
@@ -1442,368 +1808,83 @@ interface PasskeyRegisterFinishRequest {
|
|
|
1442
1808
|
/**
|
|
1443
1809
|
* Response from finishing passkey registration
|
|
1444
1810
|
*/
|
|
1445
|
-
interface PasskeyRegisterFinishResponse {
|
|
1446
|
-
success: boolean;
|
|
1447
|
-
passkey_id: string;
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* Request to start passkey authentication
|
|
1451
|
-
*/
|
|
1452
|
-
interface PasskeyAuthStartRequest {
|
|
1453
|
-
email: string;
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Response from starting passkey authentication
|
|
1457
|
-
*/
|
|
1458
|
-
interface PasskeyAuthStartResponse {
|
|
1459
|
-
challenge_id: string;
|
|
1460
|
-
options: any;
|
|
1461
|
-
}
|
|
1462
|
-
/**
|
|
1463
|
-
* Request to finish passkey authentication
|
|
1464
|
-
*/
|
|
1465
|
-
interface PasskeyAuthFinishRequest {
|
|
1466
|
-
challenge_id: string;
|
|
1467
|
-
credential: AuthenticationResponseJSON;
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* Response from finishing passkey authentication
|
|
1471
|
-
*/
|
|
1472
|
-
interface PasskeyAuthFinishResponse {
|
|
1473
|
-
token: string;
|
|
1474
|
-
user_id: string;
|
|
1475
|
-
}
|
|
1476
|
-
/**
|
|
1477
|
-
* JSON-serializable version of WebAuthn registration response
|
|
1478
|
-
*/
|
|
1479
|
-
interface RegistrationResponseJSON {
|
|
1480
|
-
id: string;
|
|
1481
|
-
rawId: string;
|
|
1482
|
-
response: {
|
|
1483
|
-
clientDataJSON: string;
|
|
1484
|
-
attestationObject: string;
|
|
1485
|
-
transports?: string[];
|
|
1486
|
-
};
|
|
1487
|
-
authenticatorAttachment?: 'platform' | 'cross-platform';
|
|
1488
|
-
clientExtensionResults: Record<string, unknown>;
|
|
1489
|
-
type: 'public-key';
|
|
1490
|
-
}
|
|
1491
|
-
/**
|
|
1492
|
-
* JSON-serializable version of WebAuthn authentication response
|
|
1493
|
-
*/
|
|
1494
|
-
interface AuthenticationResponseJSON {
|
|
1495
|
-
id: string;
|
|
1496
|
-
rawId: string;
|
|
1497
|
-
response: {
|
|
1498
|
-
clientDataJSON: string;
|
|
1499
|
-
authenticatorData: string;
|
|
1500
|
-
signature: string;
|
|
1501
|
-
userHandle?: string;
|
|
1502
|
-
};
|
|
1503
|
-
authenticatorAttachment?: 'platform' | 'cross-platform';
|
|
1504
|
-
clientExtensionResults: Record<string, unknown>;
|
|
1505
|
-
type: 'public-key';
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Passkey information
|
|
1509
|
-
*/
|
|
1510
|
-
interface Passkey {
|
|
1511
|
-
id: string;
|
|
1512
|
-
user_id: string;
|
|
1513
|
-
credential_id: string;
|
|
1514
|
-
name: string;
|
|
1515
|
-
aaguid?: string;
|
|
1516
|
-
backup_eligible: boolean;
|
|
1517
|
-
backup_state: boolean;
|
|
1518
|
-
transports?: string;
|
|
1519
|
-
last_used_at?: string;
|
|
1520
|
-
created_at: string;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
/**
|
|
1524
|
-
* Risk assessment and engine types
|
|
1525
|
-
*/
|
|
1526
|
-
/**
|
|
1527
|
-
* Risk score levels
|
|
1528
|
-
*/
|
|
1529
|
-
type RiskScore = number;
|
|
1530
|
-
/**
|
|
1531
|
-
* Risk assessment results from the risk engine
|
|
1532
|
-
*/
|
|
1533
|
-
interface RiskAssessment {
|
|
1534
|
-
/** Overall risk score (0-100, higher is more risky) */
|
|
1535
|
-
score: RiskScore;
|
|
1536
|
-
/** Action to take based on risk assessment */
|
|
1537
|
-
action: RiskAction;
|
|
1538
|
-
/** Specific risk factors that contributed to the score */
|
|
1539
|
-
factors: RiskFactor[];
|
|
1540
|
-
/** Geolocation data if available */
|
|
1541
|
-
location?: GeolocationData;
|
|
1542
|
-
/** When the assessment was performed */
|
|
1543
|
-
assessedAt: string;
|
|
1544
|
-
/** Additional metadata about the assessment */
|
|
1545
|
-
metadata?: Record<string, unknown>;
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Risk actions the engine can recommend
|
|
1549
|
-
*/
|
|
1550
|
-
declare enum RiskAction {
|
|
1551
|
-
/** Allow the authentication to proceed */
|
|
1552
|
-
ALLOW = "allow",
|
|
1553
|
-
/** Log only - allow but monitor */
|
|
1554
|
-
LOG_ONLY = "log_only",
|
|
1555
|
-
/** Require additional verification (MFA) */
|
|
1556
|
-
CHALLENGE_MFA = "challenge_mfa",
|
|
1557
|
-
/** Block the authentication attempt */
|
|
1558
|
-
BLOCK = "block"
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
* Individual risk factors that contribute to overall risk score
|
|
1562
|
-
*/
|
|
1563
|
-
interface RiskFactor {
|
|
1564
|
-
/** Type of risk factor */
|
|
1565
|
-
type: RiskFactorType;
|
|
1566
|
-
/** How much this factor contributes to the score */
|
|
1567
|
-
weight: number;
|
|
1568
|
-
/** Human-readable description */
|
|
1569
|
-
description: string;
|
|
1570
|
-
/** Additional data about this factor */
|
|
1571
|
-
data?: Record<string, unknown>;
|
|
1572
|
-
}
|
|
1573
|
-
/**
|
|
1574
|
-
* Types of risk factors the engine can detect
|
|
1575
|
-
*/
|
|
1576
|
-
declare enum RiskFactorType {
|
|
1577
|
-
/** Unknown IP address or never seen before */
|
|
1578
|
-
NEW_IP = "new_ip",
|
|
1579
|
-
/** IP from high-risk country or region */
|
|
1580
|
-
HIGH_RISK_LOCATION = "high_risk_location",
|
|
1581
|
-
/** Impossible travel - login from geographically impossible locations */
|
|
1582
|
-
IMPOSSIBLE_TRAVEL = "impossible_travel",
|
|
1583
|
-
/** New device or browser fingerprint */
|
|
1584
|
-
NEW_DEVICE = "new_device",
|
|
1585
|
-
/** Multiple failed login attempts */
|
|
1586
|
-
FAILED_ATTEMPTS = "failed_attempts",
|
|
1587
|
-
/** Login from unusual time of day */
|
|
1588
|
-
UNUSUAL_TIME = "unusual_time",
|
|
1589
|
-
/** Suspicious user agent or bot patterns */
|
|
1590
|
-
SUSPICIOUS_USER_AGENT = "suspicious_user_agent",
|
|
1591
|
-
/** Tor exit node or VPN detected */
|
|
1592
|
-
ANONYMOUS_NETWORK = "anonymous_network",
|
|
1593
|
-
/** Account is new (recently created) */
|
|
1594
|
-
NEW_ACCOUNT = "new_account",
|
|
1595
|
-
/** Account has suspicious activity history */
|
|
1596
|
-
SUSPICIOUS_HISTORY = "suspicious_history",
|
|
1597
|
-
/** Velocity-based detection (too many actions) */
|
|
1598
|
-
HIGH_VELOCITY = "high_velocity",
|
|
1599
|
-
/** Custom rule triggered */
|
|
1600
|
-
CUSTOM_RULE = "custom_rule"
|
|
1601
|
-
}
|
|
1602
|
-
/**
|
|
1603
|
-
* Geolocation data for risk assessment
|
|
1604
|
-
*/
|
|
1605
|
-
interface GeolocationData {
|
|
1606
|
-
/** Two-letter ISO country code */
|
|
1607
|
-
country: string;
|
|
1608
|
-
/** City name if available */
|
|
1609
|
-
city?: string;
|
|
1610
|
-
/** Region/state if available */
|
|
1611
|
-
region?: string;
|
|
1612
|
-
/** Latitude coordinate */
|
|
1613
|
-
latitude?: number;
|
|
1614
|
-
/** Longitude coordinate */
|
|
1615
|
-
longitude?: number;
|
|
1616
|
-
/** ISP or organization name */
|
|
1617
|
-
isp?: string;
|
|
1618
|
-
/** Whether this is a known VPN/proxy */
|
|
1619
|
-
isVpn?: boolean;
|
|
1620
|
-
/** Whether this is a Tor exit node */
|
|
1621
|
-
isTor?: boolean;
|
|
1622
|
-
}
|
|
1623
|
-
/**
|
|
1624
|
-
* Context provided to risk engine for assessment
|
|
1625
|
-
*/
|
|
1626
|
-
interface RiskContext {
|
|
1627
|
-
/** User ID being authenticated */
|
|
1628
|
-
userId: string;
|
|
1629
|
-
/** Organization ID if applicable */
|
|
1630
|
-
orgId?: string;
|
|
1631
|
-
/** IP address of the request */
|
|
1632
|
-
ipAddress: string;
|
|
1633
|
-
/** User agent string */
|
|
1634
|
-
userAgent: string;
|
|
1635
|
-
/** Device fingerprint or cookie if available */
|
|
1636
|
-
deviceCookie?: string;
|
|
1637
|
-
/** Authentication method being used */
|
|
1638
|
-
authMethod: AuthMethod;
|
|
1639
|
-
/** Additional context data */
|
|
1640
|
-
metadata?: Record<string, unknown>;
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* Authentication methods for risk assessment
|
|
1644
|
-
*/
|
|
1645
|
-
declare enum AuthMethod {
|
|
1646
|
-
/** Email and password */
|
|
1647
|
-
PASSWORD = "password",
|
|
1648
|
-
/** OAuth provider (Google, GitHub, etc.) */
|
|
1649
|
-
OAUTH = "oauth",
|
|
1650
|
-
/** WebAuthn passkeys */
|
|
1651
|
-
PASSKEY = "passkey",
|
|
1652
|
-
/** Magic link email */
|
|
1653
|
-
MAGIC_LINK = "magic_link",
|
|
1654
|
-
/** Multi-factor authentication */
|
|
1655
|
-
MFA = "mfa",
|
|
1656
|
-
/** SAML SSO */
|
|
1657
|
-
SAML = "saml"
|
|
1658
|
-
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Risk engine configuration for organizations
|
|
1661
|
-
*/
|
|
1662
|
-
interface RiskEngineConfig {
|
|
1663
|
-
/** Enable/disable risk engine */
|
|
1664
|
-
enabled: boolean;
|
|
1665
|
-
/** Risk score threshold for blocking */
|
|
1666
|
-
blockThreshold: RiskScore;
|
|
1667
|
-
/** Risk score threshold for requiring MFA */
|
|
1668
|
-
mfaThreshold: RiskScore;
|
|
1669
|
-
/** Which risk factors to consider */
|
|
1670
|
-
enabledFactors: RiskFactorType[];
|
|
1671
|
-
/** Custom rules and weights */
|
|
1672
|
-
customRules?: RiskRule[];
|
|
1673
|
-
/** How long to remember trusted devices */
|
|
1674
|
-
deviceTrustDuration: number;
|
|
1675
|
-
/** Whether to enable location-based risk assessment */
|
|
1676
|
-
enableLocationTracking: boolean;
|
|
1677
|
-
/** Max failed attempts before increased risk */
|
|
1678
|
-
maxFailedAttempts: number;
|
|
1679
|
-
/** Time window for velocity checks */
|
|
1680
|
-
velocityWindow: number;
|
|
1811
|
+
interface PasskeyRegisterFinishResponse {
|
|
1812
|
+
success: boolean;
|
|
1813
|
+
passkey_id: string;
|
|
1681
1814
|
}
|
|
1682
1815
|
/**
|
|
1683
|
-
*
|
|
1816
|
+
* Request to start passkey authentication
|
|
1684
1817
|
*/
|
|
1685
|
-
interface
|
|
1686
|
-
|
|
1687
|
-
id: string;
|
|
1688
|
-
/** Rule name for display */
|
|
1689
|
-
name: string;
|
|
1690
|
-
/** Rule description */
|
|
1691
|
-
description: string;
|
|
1692
|
-
/** Condition to trigger the rule */
|
|
1693
|
-
condition: RiskRuleCondition;
|
|
1694
|
-
/** Action to take when rule triggers */
|
|
1695
|
-
action: RiskAction;
|
|
1696
|
-
/** How much weight this rule carries */
|
|
1697
|
-
weight: number;
|
|
1698
|
-
/** Whether the rule is enabled */
|
|
1699
|
-
enabled: boolean;
|
|
1818
|
+
interface PasskeyAuthStartRequest {
|
|
1819
|
+
email: string;
|
|
1700
1820
|
}
|
|
1701
1821
|
/**
|
|
1702
|
-
*
|
|
1822
|
+
* Response from starting passkey authentication
|
|
1703
1823
|
*/
|
|
1704
|
-
interface
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
/** Operator for comparison */
|
|
1708
|
-
operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains' | 'regex';
|
|
1709
|
-
/** Value to compare against */
|
|
1710
|
-
value: unknown;
|
|
1711
|
-
/** Additional conditions (AND logic) */
|
|
1712
|
-
and?: RiskRuleCondition[];
|
|
1713
|
-
/** Alternative conditions (OR logic) */
|
|
1714
|
-
or?: RiskRuleCondition[];
|
|
1824
|
+
interface PasskeyAuthStartResponse {
|
|
1825
|
+
challenge_id: string;
|
|
1826
|
+
options: any;
|
|
1715
1827
|
}
|
|
1716
1828
|
/**
|
|
1717
|
-
*
|
|
1829
|
+
* Request to finish passkey authentication
|
|
1718
1830
|
*/
|
|
1719
|
-
interface
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
/** User ID this device belongs to */
|
|
1723
|
-
userId: string;
|
|
1724
|
-
/** Device name or description */
|
|
1725
|
-
deviceName: string;
|
|
1726
|
-
/** When the device was first seen */
|
|
1727
|
-
firstSeenAt: string;
|
|
1728
|
-
/** When the device was last used */
|
|
1729
|
-
lastSeenAt: string;
|
|
1730
|
-
/** When the device trust expires */
|
|
1731
|
-
expiresAt: string;
|
|
1732
|
-
/** IP address when device was registered */
|
|
1733
|
-
registrationIp?: string;
|
|
1734
|
-
/** Risk score for this device */
|
|
1735
|
-
riskScore: RiskScore;
|
|
1736
|
-
/** Whether this device is currently trusted */
|
|
1737
|
-
isTrusted: boolean;
|
|
1831
|
+
interface PasskeyAuthFinishRequest {
|
|
1832
|
+
challenge_id: string;
|
|
1833
|
+
credential: AuthenticationResponseJSON;
|
|
1738
1834
|
}
|
|
1739
1835
|
/**
|
|
1740
|
-
*
|
|
1836
|
+
* Response from finishing passkey authentication
|
|
1741
1837
|
*/
|
|
1742
|
-
interface
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
userId: string;
|
|
1747
|
-
/** Organization ID if applicable */
|
|
1748
|
-
orgId?: string;
|
|
1749
|
-
/** Risk assessment that triggered this event */
|
|
1750
|
-
assessment: RiskAssessment;
|
|
1751
|
-
/** Authentication context */
|
|
1752
|
-
context: RiskContext;
|
|
1753
|
-
/** When the event occurred */
|
|
1754
|
-
timestamp: string;
|
|
1755
|
-
/** Event outcome */
|
|
1756
|
-
outcome: RiskEventOutcome;
|
|
1757
|
-
/** Additional event metadata */
|
|
1758
|
-
metadata?: Record<string, unknown>;
|
|
1838
|
+
interface PasskeyAuthFinishResponse {
|
|
1839
|
+
token: string;
|
|
1840
|
+
user_id: string;
|
|
1841
|
+
device_trust_token?: string;
|
|
1759
1842
|
}
|
|
1760
1843
|
/**
|
|
1761
|
-
*
|
|
1844
|
+
* JSON-serializable version of WebAuthn registration response
|
|
1762
1845
|
*/
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
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';
|
|
1772
1857
|
}
|
|
1773
1858
|
/**
|
|
1774
|
-
*
|
|
1859
|
+
* JSON-serializable version of WebAuthn authentication response
|
|
1775
1860
|
*/
|
|
1776
|
-
interface
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
critical: number;
|
|
1785
|
-
};
|
|
1786
|
-
/** Most common risk factors */
|
|
1787
|
-
topRiskFactors: Array<{
|
|
1788
|
-
factor: RiskFactorType;
|
|
1789
|
-
count: number;
|
|
1790
|
-
percentage: number;
|
|
1791
|
-
}>;
|
|
1792
|
-
/** Blocked authentication attempts */
|
|
1793
|
-
blockedAttempts: number;
|
|
1794
|
-
/** MFA challenges issued */
|
|
1795
|
-
mfaChallenges: number;
|
|
1796
|
-
/** Geographic risk data */
|
|
1797
|
-
locationRisk: Array<{
|
|
1798
|
-
country: string;
|
|
1799
|
-
riskCount: number;
|
|
1800
|
-
riskScore: number;
|
|
1801
|
-
}>;
|
|
1802
|
-
/** Time-based risk patterns */
|
|
1803
|
-
temporalPatterns: {
|
|
1804
|
-
hourly: number[];
|
|
1805
|
-
daily: number[];
|
|
1861
|
+
interface AuthenticationResponseJSON {
|
|
1862
|
+
id: string;
|
|
1863
|
+
rawId: string;
|
|
1864
|
+
response: {
|
|
1865
|
+
clientDataJSON: string;
|
|
1866
|
+
authenticatorData: string;
|
|
1867
|
+
signature: string;
|
|
1868
|
+
userHandle?: string;
|
|
1806
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;
|
|
1807
1888
|
}
|
|
1808
1889
|
|
|
1809
1890
|
/**
|
|
@@ -2333,6 +2414,18 @@ declare class AuthModule {
|
|
|
2333
2414
|
* ```
|
|
2334
2415
|
*/
|
|
2335
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>;
|
|
2336
2429
|
/**
|
|
2337
2430
|
* Login with email and password.
|
|
2338
2431
|
* Automatically persists the session and configures the client.
|
|
@@ -3058,6 +3151,28 @@ declare class OrganizationsModule {
|
|
|
3058
3151
|
* ```
|
|
3059
3152
|
*/
|
|
3060
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
|
+
};
|
|
3061
3176
|
/**
|
|
3062
3177
|
* Member management methods
|
|
3063
3178
|
*/
|
|
@@ -3076,6 +3191,16 @@ declare class OrganizationsModule {
|
|
|
3076
3191
|
* ```
|
|
3077
3192
|
*/
|
|
3078
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>;
|
|
3079
3204
|
/**
|
|
3080
3205
|
* Update a member's role.
|
|
3081
3206
|
* Requires 'owner' role.
|
|
@@ -3620,7 +3745,7 @@ declare class ServicesModule {
|
|
|
3620
3745
|
* console.log(service.plans);
|
|
3621
3746
|
* ```
|
|
3622
3747
|
*/
|
|
3623
|
-
get(orgSlug: string, serviceSlug: string): Promise<
|
|
3748
|
+
get(orgSlug: string, serviceSlug: string): Promise<Service>;
|
|
3624
3749
|
/**
|
|
3625
3750
|
* Update service configuration.
|
|
3626
3751
|
* Requires 'owner' or 'admin' role.
|
|
@@ -3897,6 +4022,21 @@ declare class ServicesModule {
|
|
|
3897
4022
|
* ```
|
|
3898
4023
|
*/
|
|
3899
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>;
|
|
3900
4040
|
/**
|
|
3901
4041
|
* Generate a new SAML signing certificate for the IdP.
|
|
3902
4042
|
* Requires 'owner' or 'admin' role.
|
|
@@ -4026,7 +4166,7 @@ declare class InvitationsModule {
|
|
|
4026
4166
|
* @example
|
|
4027
4167
|
* ```typescript
|
|
4028
4168
|
* const invitation = await sso.invitations.create('acme-corp', {
|
|
4029
|
-
*
|
|
4169
|
+
* email: 'newuser@example.com',
|
|
4030
4170
|
* role: 'member'
|
|
4031
4171
|
* });
|
|
4032
4172
|
* ```
|
|
@@ -4520,9 +4660,31 @@ interface ServiceApiInfo {
|
|
|
4520
4660
|
service_type: string;
|
|
4521
4661
|
created_at: string;
|
|
4522
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
|
+
}
|
|
4523
4685
|
/**
|
|
4524
4686
|
* Service API module for API key-based service-to-service operations.
|
|
4525
|
-
* Provides
|
|
4687
|
+
* Provides operations for managing users, subscriptions, and service configuration.
|
|
4526
4688
|
*
|
|
4527
4689
|
* @example
|
|
4528
4690
|
* ```typescript
|
|
@@ -4531,6 +4693,9 @@ interface ServiceApiInfo {
|
|
|
4531
4693
|
* apiKey: 'sk_live_abcd1234...'
|
|
4532
4694
|
* });
|
|
4533
4695
|
*
|
|
4696
|
+
* // List users
|
|
4697
|
+
* const { users, total } = await sso.serviceApi.listUsers({ limit: 50 });
|
|
4698
|
+
*
|
|
4534
4699
|
* // Create a user
|
|
4535
4700
|
* const user = await sso.serviceApi.createUser({ email: 'user@example.com' });
|
|
4536
4701
|
*
|
|
@@ -4548,6 +4713,58 @@ interface ServiceApiInfo {
|
|
|
4548
4713
|
declare class ServiceApiModule {
|
|
4549
4714
|
private http;
|
|
4550
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>;
|
|
4551
4768
|
/**
|
|
4552
4769
|
* Create a new user
|
|
4553
4770
|
* Requires 'write:users' permission on the API key
|
|
@@ -4899,6 +5116,20 @@ declare class PasskeysModule {
|
|
|
4899
5116
|
* }
|
|
4900
5117
|
* ```
|
|
4901
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
|
+
*/
|
|
4902
5133
|
register(displayName?: string): Promise<string>;
|
|
4903
5134
|
/**
|
|
4904
5135
|
* Authenticate with a passkey and obtain a JWT token
|
|
@@ -4922,6 +5153,20 @@ declare class PasskeysModule {
|
|
|
4922
5153
|
* }
|
|
4923
5154
|
* ```
|
|
4924
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
|
+
*/
|
|
4925
5170
|
login(email: string): Promise<PasskeyAuthFinishResponse>;
|
|
4926
5171
|
/**
|
|
4927
5172
|
* Convert Base64URL string to Uint8Array
|
|
@@ -5078,7 +5323,7 @@ interface SsoClientOptions {
|
|
|
5078
5323
|
* ```
|
|
5079
5324
|
*/
|
|
5080
5325
|
declare class SsoClient {
|
|
5081
|
-
|
|
5326
|
+
http: HttpClient;
|
|
5082
5327
|
private session;
|
|
5083
5328
|
/**
|
|
5084
5329
|
* Analytics and login tracking methods
|
|
@@ -5133,6 +5378,10 @@ declare class SsoClient {
|
|
|
5133
5378
|
* Sets the JWT for all subsequent authenticated requests.
|
|
5134
5379
|
* Pass null to clear the token.
|
|
5135
5380
|
*
|
|
5381
|
+
* NOTE: For OAuth callback flows, prefer using setSession() which properly
|
|
5382
|
+
* updates the SessionManager. This method updates both the HTTP headers
|
|
5383
|
+
* AND the SessionManager for backward compatibility.
|
|
5384
|
+
*
|
|
5136
5385
|
* @param token The JWT string, or null to clear
|
|
5137
5386
|
*
|
|
5138
5387
|
* @example
|
|
@@ -5145,6 +5394,25 @@ declare class SsoClient {
|
|
|
5145
5394
|
* ```
|
|
5146
5395
|
*/
|
|
5147
5396
|
setAuthToken(token: string | null): void;
|
|
5397
|
+
/**
|
|
5398
|
+
* Sets the session tokens for OAuth callback flows.
|
|
5399
|
+
* This properly updates the SessionManager and persists tokens to storage.
|
|
5400
|
+
*
|
|
5401
|
+
* @param tokens Object containing access_token and optionally refresh_token
|
|
5402
|
+
*
|
|
5403
|
+
* @example
|
|
5404
|
+
* ```typescript
|
|
5405
|
+
* // After OAuth callback
|
|
5406
|
+
* await sso.setSession({
|
|
5407
|
+
* access_token: accessToken,
|
|
5408
|
+
* refresh_token: refreshToken
|
|
5409
|
+
* });
|
|
5410
|
+
* ```
|
|
5411
|
+
*/
|
|
5412
|
+
setSession(tokens: {
|
|
5413
|
+
access_token: string;
|
|
5414
|
+
refresh_token?: string;
|
|
5415
|
+
}): Promise<void>;
|
|
5148
5416
|
/**
|
|
5149
5417
|
* Sets the API key for service-to-service authentication.
|
|
5150
5418
|
* Pass null to clear the API key.
|
|
@@ -5231,4 +5499,4 @@ declare class SsoApiError extends Error {
|
|
|
5231
5499
|
isNotFound(): boolean;
|
|
5232
5500
|
}
|
|
5233
5501
|
|
|
5234
|
-
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 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 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 RiskEngineConfig, type RiskEvent, RiskEventOutcome, type RiskFactor, RiskFactorType, type RiskRule, type RiskRuleCondition, type RiskScore, 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 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 };
|
|
5502
|
+
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 };
|