@drmhse/sso-sdk 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -162,306 +162,35 @@ interface JwtClaims {
162
162
  iat: number;
163
163
  }
164
164
 
165
- /**
166
- * Risk assessment and engine types
167
- */
168
- /**
169
- * Risk score levels
170
- */
171
- type RiskScore = number;
172
- /**
173
- * Risk assessment results from the risk engine
174
- */
175
- interface RiskAssessment {
176
- /** Overall risk score (0-100, higher is more risky) */
177
- score: RiskScore;
178
- /** Action to take based on risk assessment */
179
- action: RiskAction;
180
- /** Specific risk factors that contributed to the score */
181
- factors: RiskFactor[];
182
- /** Geolocation data if available */
183
- location?: GeolocationData;
184
- /** When the assessment was performed */
185
- assessedAt: string;
186
- /** Additional metadata about the assessment */
187
- metadata?: Record<string, unknown>;
188
- }
189
- /**
190
- * Risk actions the engine can recommend
191
- */
192
- declare enum RiskAction {
193
- /** Allow the authentication to proceed */
194
- ALLOW = "allow",
195
- /** Log only - allow but monitor */
196
- LOG_ONLY = "log_only",
197
- /** Require additional verification (MFA) */
198
- CHALLENGE_MFA = "challenge_mfa",
199
- /** Block the authentication attempt */
200
- BLOCK = "block"
201
- }
202
- /**
203
- * Individual risk factors that contribute to overall risk score
204
- */
205
- interface RiskFactor {
206
- /** Type of risk factor */
207
- type: RiskFactorType;
208
- /** How much this factor contributes to the score */
209
- weight: number;
210
- /** Human-readable description */
211
- description: string;
212
- /** Additional data about this factor */
213
- data?: Record<string, unknown>;
214
- }
215
- /**
216
- * Types of risk factors the engine can detect
217
- */
218
- declare enum RiskFactorType {
219
- /** Unknown IP address or never seen before */
220
- NEW_IP = "new_ip",
221
- /** IP from high-risk country or region */
222
- HIGH_RISK_LOCATION = "high_risk_location",
223
- /** Impossible travel - login from geographically impossible locations */
224
- IMPOSSIBLE_TRAVEL = "impossible_travel",
225
- /** New device or browser fingerprint */
226
- NEW_DEVICE = "new_device",
227
- /** Multiple failed login attempts */
228
- FAILED_ATTEMPTS = "failed_attempts",
229
- /** Login from unusual time of day */
230
- UNUSUAL_TIME = "unusual_time",
231
- /** Suspicious user agent or bot patterns */
232
- SUSPICIOUS_USER_AGENT = "suspicious_user_agent",
233
- /** Tor exit node or VPN detected */
234
- ANONYMOUS_NETWORK = "anonymous_network",
235
- /** Account is new (recently created) */
236
- NEW_ACCOUNT = "new_account",
237
- /** Account has suspicious activity history */
238
- SUSPICIOUS_HISTORY = "suspicious_history",
239
- /** Velocity-based detection (too many actions) */
240
- HIGH_VELOCITY = "high_velocity",
241
- /** Custom rule triggered */
242
- CUSTOM_RULE = "custom_rule"
243
- }
244
- /**
245
- * Geolocation data for risk assessment
246
- */
247
- interface GeolocationData {
248
- /** Two-letter ISO country code */
165
+ interface GeoLocation {
249
166
  country: string;
250
- /** City name if available */
251
167
  city?: string;
252
- /** Region/state if available */
253
- region?: string;
254
- /** Latitude coordinate */
255
- latitude?: number;
256
- /** Longitude coordinate */
257
- longitude?: number;
258
- /** ISP or organization name */
259
- isp?: string;
260
- /** Whether this is a known VPN/proxy */
261
- isVpn?: boolean;
262
- /** Whether this is a Tor exit node */
263
- isTor?: boolean;
264
- }
265
- /**
266
- * Context provided to risk engine for assessment
267
- */
268
- interface RiskContext {
269
- /** User ID being authenticated */
270
- userId: string;
271
- /** Organization ID if applicable */
272
- orgId?: string;
273
- /** IP address of the request */
274
- ipAddress: string;
275
- /** User agent string */
276
- userAgent: string;
277
- /** Device fingerprint or cookie if available */
278
- deviceCookie?: string;
279
- /** Authentication method being used */
280
- authMethod: AuthMethod;
281
- /** Additional context data */
282
- metadata?: Record<string, unknown>;
283
- }
284
- /**
285
- * Authentication methods for risk assessment
286
- */
287
- declare enum AuthMethod {
288
- /** Email and password */
289
- PASSWORD = "password",
290
- /** OAuth provider (Google, GitHub, etc.) */
291
- OAUTH = "oauth",
292
- /** WebAuthn passkeys */
293
- PASSKEY = "passkey",
294
- /** Magic link email */
295
- MAGIC_LINK = "magic_link",
296
- /** Multi-factor authentication */
297
- MFA = "mfa",
298
- /** SAML SSO */
299
- SAML = "saml"
300
- }
301
- /**
302
- * Risk engine configuration for organizations
303
- */
304
- interface RiskEngineConfig {
305
- /** Enable/disable risk engine */
306
- enabled: boolean;
307
- /** Risk score threshold for blocking */
308
- blockThreshold: RiskScore;
309
- /** Risk score threshold for requiring MFA */
310
- mfaThreshold: RiskScore;
311
- /** Which risk factors to consider */
312
- enabledFactors: RiskFactorType[];
313
- /** Custom rules and weights */
314
- customRules?: RiskRule[];
315
- /** How long to remember trusted devices */
316
- deviceTrustDuration: number;
317
- /** Whether to enable location-based risk assessment */
318
- enableLocationTracking: boolean;
319
- /** Max failed attempts before increased risk */
320
- maxFailedAttempts: number;
321
- /** Time window for velocity checks */
322
- velocityWindow: number;
323
- }
324
- /**
325
- * Custom risk rule definition
326
- */
327
- interface RiskRule {
328
- /** Unique rule identifier */
329
- id: string;
330
- /** Rule name for display */
331
- name: string;
332
- /** Rule description */
333
- description: string;
334
- /** Condition to trigger the rule */
335
- condition: RiskRuleCondition;
336
- /** Action to take when rule triggers */
337
- action: RiskAction;
338
- /** How much weight this rule carries */
339
- weight: number;
340
- /** Whether the rule is enabled */
341
- enabled: boolean;
168
+ latitude: number;
169
+ longitude: number;
342
170
  }
343
- /**
344
- * Risk rule condition
345
- */
346
- interface RiskRuleCondition {
347
- /** Field to check */
348
- field: string;
349
- /** Operator for comparison */
350
- operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains' | 'regex';
351
- /** Value to compare against */
352
- value: unknown;
353
- /** Additional conditions (AND logic) */
354
- and?: RiskRuleCondition[];
355
- /** Alternative conditions (OR logic) */
356
- or?: RiskRuleCondition[];
357
- }
358
- /**
359
- * Device trust information
360
- */
361
- interface DeviceTrust {
362
- /** Device ID */
363
- deviceId: string;
364
- /** User ID this device belongs to */
365
- userId: string;
366
- /** Device name or description */
367
- deviceName: string;
368
- /** When the device was first seen */
369
- firstSeenAt: string;
370
- /** When the device was last used */
371
- lastSeenAt: string;
372
- /** When the device trust expires */
373
- expiresAt: string;
374
- /** IP address when device was registered */
375
- registrationIp?: string;
376
- /** Risk score for this device */
377
- riskScore: RiskScore;
378
- /** Whether this device is currently trusted */
379
- isTrusted: boolean;
171
+ type RiskAction = 'allow' | 'challenge_mfa' | 'block' | 'log_only';
172
+ interface RiskAssessment {
173
+ score: number;
174
+ factors: string[];
175
+ action: RiskAction;
176
+ location?: GeoLocation;
380
177
  }
381
- /**
382
- * Risk event for logging and monitoring
383
- */
384
- interface RiskEvent {
385
- /** Unique event ID */
178
+ interface RiskEventResponse {
386
179
  id: string;
387
- /** User ID involved */
388
- userId: string;
389
- /** Organization ID if applicable */
390
- orgId?: string;
391
- /** Risk assessment that triggered this event */
392
- assessment: RiskAssessment;
393
- /** Authentication context */
394
- context: RiskContext;
395
- /** When the event occurred */
396
- timestamp: string;
397
- /** Event outcome */
398
- outcome: RiskEventOutcome;
399
- /** Additional event metadata */
400
- metadata?: Record<string, unknown>;
401
- }
402
- /**
403
- * Risk event outcomes
404
- */
405
- declare enum RiskEventOutcome {
406
- /** Authentication was allowed */
407
- ALLOWED = "allowed",
408
- /** Authentication was blocked */
409
- BLOCKED = "blocked",
410
- /** Additional verification was required */
411
- CHALLENGED = "challenged",
412
- /** Event was logged but no action taken */
413
- LOGGED = "logged"
414
- }
415
- /**
416
- * Risk engine analytics and reporting
417
- */
418
- interface RiskAnalytics {
419
- /** Total risk assessments in time period */
420
- totalAssessments: number;
421
- /** Risk score distribution */
422
- scoreDistribution: {
423
- low: number;
424
- medium: number;
425
- high: number;
426
- critical: number;
427
- };
428
- /** Most common risk factors */
429
- topRiskFactors: Array<{
430
- factor: RiskFactorType;
431
- count: number;
432
- percentage: number;
433
- }>;
434
- /** Blocked authentication attempts */
435
- blockedAttempts: number;
436
- /** MFA challenges issued */
437
- mfaChallenges: number;
438
- /** Geographic risk data */
439
- locationRisk: Array<{
440
- country: string;
441
- riskCount: number;
442
- riskScore: number;
443
- }>;
444
- /** Time-based risk patterns */
445
- temporalPatterns: {
446
- hourly: number[];
447
- daily: number[];
448
- };
180
+ user_id: string;
181
+ user_email?: string;
182
+ created_at: string;
183
+ risk_score: number;
184
+ risk_factors: string[];
185
+ geo_country?: string;
186
+ geo_city?: string;
187
+ ip_address?: string;
188
+ provider: string;
449
189
  }
450
- /**
451
- * Risk enforcement modes
452
- */
453
- type RiskEnforcementMode = 'log_only' | 'monitor' | 'block' | 'challenge_mfa';
454
- /**
455
- * Organization risk settings
456
- */
457
- interface RiskSettings {
458
- enforcement_mode: RiskEnforcementMode;
459
- low_threshold: number;
460
- medium_threshold: number;
461
- new_device_score: number;
462
- impossible_travel_score: number;
463
- velocity_threshold: number;
464
- velocity_score: number;
190
+ interface RiskEventsQuery {
191
+ page?: number;
192
+ limit?: number;
193
+ min_score?: number;
465
194
  }
466
195
 
467
196
  /**
@@ -906,6 +635,16 @@ interface CreateOrganizationResponse {
906
635
  access_token: string;
907
636
  refresh_token: string;
908
637
  }
638
+ /**
639
+ * Select organization response - returned when switching org context
640
+ */
641
+ interface SelectOrganizationResponse {
642
+ organization: Organization;
643
+ membership: Membership;
644
+ access_token: string;
645
+ refresh_token: string;
646
+ expires_in: number;
647
+ }
909
648
  /**
910
649
  * Update organization payload
911
650
  */
@@ -3181,6 +2920,26 @@ declare class OrganizationsModule {
3181
2920
  * ```
3182
2921
  */
3183
2922
  get(orgSlug: string): Promise<OrganizationResponse>;
2923
+ /**
2924
+ * Select/switch to a different organization context.
2925
+ * Issues a new JWT token with the organization context.
2926
+ *
2927
+ * This allows users to seamlessly switch between organizations
2928
+ * they are members of without re-authenticating.
2929
+ *
2930
+ * @param orgSlug Organization slug to switch to
2931
+ * @returns New tokens with organization context
2932
+ *
2933
+ * @example
2934
+ * ```typescript
2935
+ * // Switch to a different organization
2936
+ * const result = await sso.organizations.select('acme-corp');
2937
+ *
2938
+ * // The SDK automatically updates the session with new tokens
2939
+ * // API calls will now be made in the context of 'acme-corp'
2940
+ * ```
2941
+ */
2942
+ select(orgSlug: string): Promise<SelectOrganizationResponse>;
3184
2943
  /**
3185
2944
  * Update organization details.
3186
2945
  * Requires 'owner' or 'admin' role.
@@ -3804,6 +3563,19 @@ declare class OrganizationsModule {
3804
3563
  url: string;
3805
3564
  }>;
3806
3565
  };
3566
+ /**
3567
+ * Security & Risk insights
3568
+ */
3569
+ security: {
3570
+ /**
3571
+ * Get risk events for an organization.
3572
+ * Requires 'owner' or 'admin' role.
3573
+ *
3574
+ * @param orgSlug Organization slug
3575
+ * @param params Query parameters
3576
+ */
3577
+ getRiskEvents: (orgSlug: string, params?: RiskEventsQuery) => Promise<RiskEventResponse[]>;
3578
+ };
3807
3579
  /**
3808
3580
  * BYOP (Bring Your Own Payment) credential management.
3809
3581
  * Allows organizations to configure their own billing provider credentials
@@ -5769,4 +5541,4 @@ declare class SsoApiError extends Error {
5769
5541
  isNotFound(): boolean;
5770
5542
  }
5771
5543
 
5772
- export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthErrorCodes, AuthMethod, AuthModule, type AuthSnapshot, type AuthenticationResponseJSON, type BackupCodesResponse, type BrandingConfiguration, BrowserStorage, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, CookieStorage, 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 ResendVerificationRequest, type ResendVerificationResponse, 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 };
5544
+ export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthErrorCodes, AuthModule, type AuthSnapshot, type AuthenticationResponseJSON, type BackupCodesResponse, type BrandingConfiguration, BrowserStorage, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, CookieStorage, 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 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 GeoLocation, 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 ResendVerificationRequest, type ResendVerificationResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDeviceRequest, type RevokeDeviceResponse, type RevokeSessionsResponse, type RiskAction, type RiskAssessment, type RiskEventResponse, type RiskEventsQuery, type SamlCertificate, type SamlConfig, type ScimTokenResponse, type SelectOrganizationResponse, 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 };
package/dist/index.d.ts CHANGED
@@ -162,306 +162,35 @@ interface JwtClaims {
162
162
  iat: number;
163
163
  }
164
164
 
165
- /**
166
- * Risk assessment and engine types
167
- */
168
- /**
169
- * Risk score levels
170
- */
171
- type RiskScore = number;
172
- /**
173
- * Risk assessment results from the risk engine
174
- */
175
- interface RiskAssessment {
176
- /** Overall risk score (0-100, higher is more risky) */
177
- score: RiskScore;
178
- /** Action to take based on risk assessment */
179
- action: RiskAction;
180
- /** Specific risk factors that contributed to the score */
181
- factors: RiskFactor[];
182
- /** Geolocation data if available */
183
- location?: GeolocationData;
184
- /** When the assessment was performed */
185
- assessedAt: string;
186
- /** Additional metadata about the assessment */
187
- metadata?: Record<string, unknown>;
188
- }
189
- /**
190
- * Risk actions the engine can recommend
191
- */
192
- declare enum RiskAction {
193
- /** Allow the authentication to proceed */
194
- ALLOW = "allow",
195
- /** Log only - allow but monitor */
196
- LOG_ONLY = "log_only",
197
- /** Require additional verification (MFA) */
198
- CHALLENGE_MFA = "challenge_mfa",
199
- /** Block the authentication attempt */
200
- BLOCK = "block"
201
- }
202
- /**
203
- * Individual risk factors that contribute to overall risk score
204
- */
205
- interface RiskFactor {
206
- /** Type of risk factor */
207
- type: RiskFactorType;
208
- /** How much this factor contributes to the score */
209
- weight: number;
210
- /** Human-readable description */
211
- description: string;
212
- /** Additional data about this factor */
213
- data?: Record<string, unknown>;
214
- }
215
- /**
216
- * Types of risk factors the engine can detect
217
- */
218
- declare enum RiskFactorType {
219
- /** Unknown IP address or never seen before */
220
- NEW_IP = "new_ip",
221
- /** IP from high-risk country or region */
222
- HIGH_RISK_LOCATION = "high_risk_location",
223
- /** Impossible travel - login from geographically impossible locations */
224
- IMPOSSIBLE_TRAVEL = "impossible_travel",
225
- /** New device or browser fingerprint */
226
- NEW_DEVICE = "new_device",
227
- /** Multiple failed login attempts */
228
- FAILED_ATTEMPTS = "failed_attempts",
229
- /** Login from unusual time of day */
230
- UNUSUAL_TIME = "unusual_time",
231
- /** Suspicious user agent or bot patterns */
232
- SUSPICIOUS_USER_AGENT = "suspicious_user_agent",
233
- /** Tor exit node or VPN detected */
234
- ANONYMOUS_NETWORK = "anonymous_network",
235
- /** Account is new (recently created) */
236
- NEW_ACCOUNT = "new_account",
237
- /** Account has suspicious activity history */
238
- SUSPICIOUS_HISTORY = "suspicious_history",
239
- /** Velocity-based detection (too many actions) */
240
- HIGH_VELOCITY = "high_velocity",
241
- /** Custom rule triggered */
242
- CUSTOM_RULE = "custom_rule"
243
- }
244
- /**
245
- * Geolocation data for risk assessment
246
- */
247
- interface GeolocationData {
248
- /** Two-letter ISO country code */
165
+ interface GeoLocation {
249
166
  country: string;
250
- /** City name if available */
251
167
  city?: string;
252
- /** Region/state if available */
253
- region?: string;
254
- /** Latitude coordinate */
255
- latitude?: number;
256
- /** Longitude coordinate */
257
- longitude?: number;
258
- /** ISP or organization name */
259
- isp?: string;
260
- /** Whether this is a known VPN/proxy */
261
- isVpn?: boolean;
262
- /** Whether this is a Tor exit node */
263
- isTor?: boolean;
264
- }
265
- /**
266
- * Context provided to risk engine for assessment
267
- */
268
- interface RiskContext {
269
- /** User ID being authenticated */
270
- userId: string;
271
- /** Organization ID if applicable */
272
- orgId?: string;
273
- /** IP address of the request */
274
- ipAddress: string;
275
- /** User agent string */
276
- userAgent: string;
277
- /** Device fingerprint or cookie if available */
278
- deviceCookie?: string;
279
- /** Authentication method being used */
280
- authMethod: AuthMethod;
281
- /** Additional context data */
282
- metadata?: Record<string, unknown>;
283
- }
284
- /**
285
- * Authentication methods for risk assessment
286
- */
287
- declare enum AuthMethod {
288
- /** Email and password */
289
- PASSWORD = "password",
290
- /** OAuth provider (Google, GitHub, etc.) */
291
- OAUTH = "oauth",
292
- /** WebAuthn passkeys */
293
- PASSKEY = "passkey",
294
- /** Magic link email */
295
- MAGIC_LINK = "magic_link",
296
- /** Multi-factor authentication */
297
- MFA = "mfa",
298
- /** SAML SSO */
299
- SAML = "saml"
300
- }
301
- /**
302
- * Risk engine configuration for organizations
303
- */
304
- interface RiskEngineConfig {
305
- /** Enable/disable risk engine */
306
- enabled: boolean;
307
- /** Risk score threshold for blocking */
308
- blockThreshold: RiskScore;
309
- /** Risk score threshold for requiring MFA */
310
- mfaThreshold: RiskScore;
311
- /** Which risk factors to consider */
312
- enabledFactors: RiskFactorType[];
313
- /** Custom rules and weights */
314
- customRules?: RiskRule[];
315
- /** How long to remember trusted devices */
316
- deviceTrustDuration: number;
317
- /** Whether to enable location-based risk assessment */
318
- enableLocationTracking: boolean;
319
- /** Max failed attempts before increased risk */
320
- maxFailedAttempts: number;
321
- /** Time window for velocity checks */
322
- velocityWindow: number;
323
- }
324
- /**
325
- * Custom risk rule definition
326
- */
327
- interface RiskRule {
328
- /** Unique rule identifier */
329
- id: string;
330
- /** Rule name for display */
331
- name: string;
332
- /** Rule description */
333
- description: string;
334
- /** Condition to trigger the rule */
335
- condition: RiskRuleCondition;
336
- /** Action to take when rule triggers */
337
- action: RiskAction;
338
- /** How much weight this rule carries */
339
- weight: number;
340
- /** Whether the rule is enabled */
341
- enabled: boolean;
168
+ latitude: number;
169
+ longitude: number;
342
170
  }
343
- /**
344
- * Risk rule condition
345
- */
346
- interface RiskRuleCondition {
347
- /** Field to check */
348
- field: string;
349
- /** Operator for comparison */
350
- operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains' | 'regex';
351
- /** Value to compare against */
352
- value: unknown;
353
- /** Additional conditions (AND logic) */
354
- and?: RiskRuleCondition[];
355
- /** Alternative conditions (OR logic) */
356
- or?: RiskRuleCondition[];
357
- }
358
- /**
359
- * Device trust information
360
- */
361
- interface DeviceTrust {
362
- /** Device ID */
363
- deviceId: string;
364
- /** User ID this device belongs to */
365
- userId: string;
366
- /** Device name or description */
367
- deviceName: string;
368
- /** When the device was first seen */
369
- firstSeenAt: string;
370
- /** When the device was last used */
371
- lastSeenAt: string;
372
- /** When the device trust expires */
373
- expiresAt: string;
374
- /** IP address when device was registered */
375
- registrationIp?: string;
376
- /** Risk score for this device */
377
- riskScore: RiskScore;
378
- /** Whether this device is currently trusted */
379
- isTrusted: boolean;
171
+ type RiskAction = 'allow' | 'challenge_mfa' | 'block' | 'log_only';
172
+ interface RiskAssessment {
173
+ score: number;
174
+ factors: string[];
175
+ action: RiskAction;
176
+ location?: GeoLocation;
380
177
  }
381
- /**
382
- * Risk event for logging and monitoring
383
- */
384
- interface RiskEvent {
385
- /** Unique event ID */
178
+ interface RiskEventResponse {
386
179
  id: string;
387
- /** User ID involved */
388
- userId: string;
389
- /** Organization ID if applicable */
390
- orgId?: string;
391
- /** Risk assessment that triggered this event */
392
- assessment: RiskAssessment;
393
- /** Authentication context */
394
- context: RiskContext;
395
- /** When the event occurred */
396
- timestamp: string;
397
- /** Event outcome */
398
- outcome: RiskEventOutcome;
399
- /** Additional event metadata */
400
- metadata?: Record<string, unknown>;
401
- }
402
- /**
403
- * Risk event outcomes
404
- */
405
- declare enum RiskEventOutcome {
406
- /** Authentication was allowed */
407
- ALLOWED = "allowed",
408
- /** Authentication was blocked */
409
- BLOCKED = "blocked",
410
- /** Additional verification was required */
411
- CHALLENGED = "challenged",
412
- /** Event was logged but no action taken */
413
- LOGGED = "logged"
414
- }
415
- /**
416
- * Risk engine analytics and reporting
417
- */
418
- interface RiskAnalytics {
419
- /** Total risk assessments in time period */
420
- totalAssessments: number;
421
- /** Risk score distribution */
422
- scoreDistribution: {
423
- low: number;
424
- medium: number;
425
- high: number;
426
- critical: number;
427
- };
428
- /** Most common risk factors */
429
- topRiskFactors: Array<{
430
- factor: RiskFactorType;
431
- count: number;
432
- percentage: number;
433
- }>;
434
- /** Blocked authentication attempts */
435
- blockedAttempts: number;
436
- /** MFA challenges issued */
437
- mfaChallenges: number;
438
- /** Geographic risk data */
439
- locationRisk: Array<{
440
- country: string;
441
- riskCount: number;
442
- riskScore: number;
443
- }>;
444
- /** Time-based risk patterns */
445
- temporalPatterns: {
446
- hourly: number[];
447
- daily: number[];
448
- };
180
+ user_id: string;
181
+ user_email?: string;
182
+ created_at: string;
183
+ risk_score: number;
184
+ risk_factors: string[];
185
+ geo_country?: string;
186
+ geo_city?: string;
187
+ ip_address?: string;
188
+ provider: string;
449
189
  }
450
- /**
451
- * Risk enforcement modes
452
- */
453
- type RiskEnforcementMode = 'log_only' | 'monitor' | 'block' | 'challenge_mfa';
454
- /**
455
- * Organization risk settings
456
- */
457
- interface RiskSettings {
458
- enforcement_mode: RiskEnforcementMode;
459
- low_threshold: number;
460
- medium_threshold: number;
461
- new_device_score: number;
462
- impossible_travel_score: number;
463
- velocity_threshold: number;
464
- velocity_score: number;
190
+ interface RiskEventsQuery {
191
+ page?: number;
192
+ limit?: number;
193
+ min_score?: number;
465
194
  }
466
195
 
467
196
  /**
@@ -906,6 +635,16 @@ interface CreateOrganizationResponse {
906
635
  access_token: string;
907
636
  refresh_token: string;
908
637
  }
638
+ /**
639
+ * Select organization response - returned when switching org context
640
+ */
641
+ interface SelectOrganizationResponse {
642
+ organization: Organization;
643
+ membership: Membership;
644
+ access_token: string;
645
+ refresh_token: string;
646
+ expires_in: number;
647
+ }
909
648
  /**
910
649
  * Update organization payload
911
650
  */
@@ -3181,6 +2920,26 @@ declare class OrganizationsModule {
3181
2920
  * ```
3182
2921
  */
3183
2922
  get(orgSlug: string): Promise<OrganizationResponse>;
2923
+ /**
2924
+ * Select/switch to a different organization context.
2925
+ * Issues a new JWT token with the organization context.
2926
+ *
2927
+ * This allows users to seamlessly switch between organizations
2928
+ * they are members of without re-authenticating.
2929
+ *
2930
+ * @param orgSlug Organization slug to switch to
2931
+ * @returns New tokens with organization context
2932
+ *
2933
+ * @example
2934
+ * ```typescript
2935
+ * // Switch to a different organization
2936
+ * const result = await sso.organizations.select('acme-corp');
2937
+ *
2938
+ * // The SDK automatically updates the session with new tokens
2939
+ * // API calls will now be made in the context of 'acme-corp'
2940
+ * ```
2941
+ */
2942
+ select(orgSlug: string): Promise<SelectOrganizationResponse>;
3184
2943
  /**
3185
2944
  * Update organization details.
3186
2945
  * Requires 'owner' or 'admin' role.
@@ -3804,6 +3563,19 @@ declare class OrganizationsModule {
3804
3563
  url: string;
3805
3564
  }>;
3806
3565
  };
3566
+ /**
3567
+ * Security & Risk insights
3568
+ */
3569
+ security: {
3570
+ /**
3571
+ * Get risk events for an organization.
3572
+ * Requires 'owner' or 'admin' role.
3573
+ *
3574
+ * @param orgSlug Organization slug
3575
+ * @param params Query parameters
3576
+ */
3577
+ getRiskEvents: (orgSlug: string, params?: RiskEventsQuery) => Promise<RiskEventResponse[]>;
3578
+ };
3807
3579
  /**
3808
3580
  * BYOP (Bring Your Own Payment) credential management.
3809
3581
  * Allows organizations to configure their own billing provider credentials
@@ -5769,4 +5541,4 @@ declare class SsoApiError extends Error {
5769
5541
  isNotFound(): boolean;
5770
5542
  }
5771
5543
 
5772
- export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthErrorCodes, AuthMethod, AuthModule, type AuthSnapshot, type AuthenticationResponseJSON, type BackupCodesResponse, type BrandingConfiguration, BrowserStorage, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, CookieStorage, 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 ResendVerificationRequest, type ResendVerificationResponse, 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 };
5544
+ export { type AcceptInvitationPayload, type AdminLoginUrlParams, type AnalyticsQuery, type ApiKey, type ApiKeyCreateResponse, type ApproveOrganizationPayload, type AuditLog, type AuditLogEntry, type AuditLogQueryParams, type AuditLogResponse, AuthErrorCodes, AuthModule, type AuthSnapshot, type AuthenticationResponseJSON, type BackupCodesResponse, type BrandingConfiguration, BrowserStorage, type ChangePasswordRequest, type ChangePasswordResponse, type ConfigureSamlPayload, type ConfigureSamlResponse, CookieStorage, 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 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 GeoLocation, 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 ResendVerificationRequest, type ResendVerificationResponse, type ResetPasswordRequest, type ResetPasswordResponse, type RevokeDeviceRequest, type RevokeDeviceResponse, type RevokeSessionsResponse, type RiskAction, type RiskAssessment, type RiskEventResponse, type RiskEventsQuery, type SamlCertificate, type SamlConfig, type ScimTokenResponse, type SelectOrganizationResponse, 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 };
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AuthErrorCodes: () => AuthErrorCodes,
24
- AuthMethod: () => AuthMethod,
25
24
  AuthModule: () => AuthModule,
26
25
  BrowserStorage: () => BrowserStorage,
27
26
  CookieStorage: () => CookieStorage,
@@ -32,9 +31,6 @@ __export(index_exports, {
32
31
  PasskeysModule: () => PasskeysModule,
33
32
  PermissionsModule: () => PermissionsModule,
34
33
  PlatformModule: () => PlatformModule,
35
- RiskAction: () => RiskAction,
36
- RiskEventOutcome: () => RiskEventOutcome,
37
- RiskFactorType: () => RiskFactorType,
38
34
  ServiceApiModule: () => ServiceApiModule,
39
35
  ServicesModule: () => ServicesModule,
40
36
  SsoApiError: () => SsoApiError,
@@ -2152,6 +2148,25 @@ var OrganizationsModule = class {
2152
2148
  return response.data;
2153
2149
  }
2154
2150
  };
2151
+ /**
2152
+ * Security & Risk insights
2153
+ */
2154
+ this.security = {
2155
+ /**
2156
+ * Get risk events for an organization.
2157
+ * Requires 'owner' or 'admin' role.
2158
+ *
2159
+ * @param orgSlug Organization slug
2160
+ * @param params Query parameters
2161
+ */
2162
+ getRiskEvents: async (orgSlug, params) => {
2163
+ const response = await this.http.get(
2164
+ `/api/organizations/${orgSlug}/risk-events`,
2165
+ { params }
2166
+ );
2167
+ return response.data;
2168
+ }
2169
+ };
2155
2170
  // ============================================================================
2156
2171
  // BYOP - BRING YOUR OWN PAYMENT
2157
2172
  // ============================================================================
@@ -2287,6 +2302,31 @@ var OrganizationsModule = class {
2287
2302
  const response = await this.http.get(`/api/organizations/${orgSlug}`);
2288
2303
  return response.data;
2289
2304
  }
2305
+ /**
2306
+ * Select/switch to a different organization context.
2307
+ * Issues a new JWT token with the organization context.
2308
+ *
2309
+ * This allows users to seamlessly switch between organizations
2310
+ * they are members of without re-authenticating.
2311
+ *
2312
+ * @param orgSlug Organization slug to switch to
2313
+ * @returns New tokens with organization context
2314
+ *
2315
+ * @example
2316
+ * ```typescript
2317
+ * // Switch to a different organization
2318
+ * const result = await sso.organizations.select('acme-corp');
2319
+ *
2320
+ * // The SDK automatically updates the session with new tokens
2321
+ * // API calls will now be made in the context of 'acme-corp'
2322
+ * ```
2323
+ */
2324
+ async select(orgSlug) {
2325
+ const response = await this.http.post(
2326
+ `/api/organizations/${orgSlug}/select`
2327
+ );
2328
+ return response.data;
2329
+ }
2290
2330
  /**
2291
2331
  * Update organization details.
2292
2332
  * Requires 'owner' or 'admin' role.
@@ -4645,50 +4685,9 @@ var SsoClient = class {
4645
4685
  return this.session.getToken();
4646
4686
  }
4647
4687
  };
4648
-
4649
- // src/types/risk.ts
4650
- var RiskAction = /* @__PURE__ */ ((RiskAction2) => {
4651
- RiskAction2["ALLOW"] = "allow";
4652
- RiskAction2["LOG_ONLY"] = "log_only";
4653
- RiskAction2["CHALLENGE_MFA"] = "challenge_mfa";
4654
- RiskAction2["BLOCK"] = "block";
4655
- return RiskAction2;
4656
- })(RiskAction || {});
4657
- var RiskFactorType = /* @__PURE__ */ ((RiskFactorType2) => {
4658
- RiskFactorType2["NEW_IP"] = "new_ip";
4659
- RiskFactorType2["HIGH_RISK_LOCATION"] = "high_risk_location";
4660
- RiskFactorType2["IMPOSSIBLE_TRAVEL"] = "impossible_travel";
4661
- RiskFactorType2["NEW_DEVICE"] = "new_device";
4662
- RiskFactorType2["FAILED_ATTEMPTS"] = "failed_attempts";
4663
- RiskFactorType2["UNUSUAL_TIME"] = "unusual_time";
4664
- RiskFactorType2["SUSPICIOUS_USER_AGENT"] = "suspicious_user_agent";
4665
- RiskFactorType2["ANONYMOUS_NETWORK"] = "anonymous_network";
4666
- RiskFactorType2["NEW_ACCOUNT"] = "new_account";
4667
- RiskFactorType2["SUSPICIOUS_HISTORY"] = "suspicious_history";
4668
- RiskFactorType2["HIGH_VELOCITY"] = "high_velocity";
4669
- RiskFactorType2["CUSTOM_RULE"] = "custom_rule";
4670
- return RiskFactorType2;
4671
- })(RiskFactorType || {});
4672
- var AuthMethod = /* @__PURE__ */ ((AuthMethod2) => {
4673
- AuthMethod2["PASSWORD"] = "password";
4674
- AuthMethod2["OAUTH"] = "oauth";
4675
- AuthMethod2["PASSKEY"] = "passkey";
4676
- AuthMethod2["MAGIC_LINK"] = "magic_link";
4677
- AuthMethod2["MFA"] = "mfa";
4678
- AuthMethod2["SAML"] = "saml";
4679
- return AuthMethod2;
4680
- })(AuthMethod || {});
4681
- var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4682
- RiskEventOutcome2["ALLOWED"] = "allowed";
4683
- RiskEventOutcome2["BLOCKED"] = "blocked";
4684
- RiskEventOutcome2["CHALLENGED"] = "challenged";
4685
- RiskEventOutcome2["LOGGED"] = "logged";
4686
- return RiskEventOutcome2;
4687
- })(RiskEventOutcome || {});
4688
4688
  // Annotate the CommonJS export names for ESM import in node:
4689
4689
  0 && (module.exports = {
4690
4690
  AuthErrorCodes,
4691
- AuthMethod,
4692
4691
  AuthModule,
4693
4692
  BrowserStorage,
4694
4693
  CookieStorage,
@@ -4699,9 +4698,6 @@ var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4699
4698
  PasskeysModule,
4700
4699
  PermissionsModule,
4701
4700
  PlatformModule,
4702
- RiskAction,
4703
- RiskEventOutcome,
4704
- RiskFactorType,
4705
4701
  ServiceApiModule,
4706
4702
  ServicesModule,
4707
4703
  SsoApiError,
package/dist/index.mjs CHANGED
@@ -2107,6 +2107,25 @@ var OrganizationsModule = class {
2107
2107
  return response.data;
2108
2108
  }
2109
2109
  };
2110
+ /**
2111
+ * Security & Risk insights
2112
+ */
2113
+ this.security = {
2114
+ /**
2115
+ * Get risk events for an organization.
2116
+ * Requires 'owner' or 'admin' role.
2117
+ *
2118
+ * @param orgSlug Organization slug
2119
+ * @param params Query parameters
2120
+ */
2121
+ getRiskEvents: async (orgSlug, params) => {
2122
+ const response = await this.http.get(
2123
+ `/api/organizations/${orgSlug}/risk-events`,
2124
+ { params }
2125
+ );
2126
+ return response.data;
2127
+ }
2128
+ };
2110
2129
  // ============================================================================
2111
2130
  // BYOP - BRING YOUR OWN PAYMENT
2112
2131
  // ============================================================================
@@ -2242,6 +2261,31 @@ var OrganizationsModule = class {
2242
2261
  const response = await this.http.get(`/api/organizations/${orgSlug}`);
2243
2262
  return response.data;
2244
2263
  }
2264
+ /**
2265
+ * Select/switch to a different organization context.
2266
+ * Issues a new JWT token with the organization context.
2267
+ *
2268
+ * This allows users to seamlessly switch between organizations
2269
+ * they are members of without re-authenticating.
2270
+ *
2271
+ * @param orgSlug Organization slug to switch to
2272
+ * @returns New tokens with organization context
2273
+ *
2274
+ * @example
2275
+ * ```typescript
2276
+ * // Switch to a different organization
2277
+ * const result = await sso.organizations.select('acme-corp');
2278
+ *
2279
+ * // The SDK automatically updates the session with new tokens
2280
+ * // API calls will now be made in the context of 'acme-corp'
2281
+ * ```
2282
+ */
2283
+ async select(orgSlug) {
2284
+ const response = await this.http.post(
2285
+ `/api/organizations/${orgSlug}/select`
2286
+ );
2287
+ return response.data;
2288
+ }
2245
2289
  /**
2246
2290
  * Update organization details.
2247
2291
  * Requires 'owner' or 'admin' role.
@@ -4600,49 +4644,8 @@ var SsoClient = class {
4600
4644
  return this.session.getToken();
4601
4645
  }
4602
4646
  };
4603
-
4604
- // src/types/risk.ts
4605
- var RiskAction = /* @__PURE__ */ ((RiskAction2) => {
4606
- RiskAction2["ALLOW"] = "allow";
4607
- RiskAction2["LOG_ONLY"] = "log_only";
4608
- RiskAction2["CHALLENGE_MFA"] = "challenge_mfa";
4609
- RiskAction2["BLOCK"] = "block";
4610
- return RiskAction2;
4611
- })(RiskAction || {});
4612
- var RiskFactorType = /* @__PURE__ */ ((RiskFactorType2) => {
4613
- RiskFactorType2["NEW_IP"] = "new_ip";
4614
- RiskFactorType2["HIGH_RISK_LOCATION"] = "high_risk_location";
4615
- RiskFactorType2["IMPOSSIBLE_TRAVEL"] = "impossible_travel";
4616
- RiskFactorType2["NEW_DEVICE"] = "new_device";
4617
- RiskFactorType2["FAILED_ATTEMPTS"] = "failed_attempts";
4618
- RiskFactorType2["UNUSUAL_TIME"] = "unusual_time";
4619
- RiskFactorType2["SUSPICIOUS_USER_AGENT"] = "suspicious_user_agent";
4620
- RiskFactorType2["ANONYMOUS_NETWORK"] = "anonymous_network";
4621
- RiskFactorType2["NEW_ACCOUNT"] = "new_account";
4622
- RiskFactorType2["SUSPICIOUS_HISTORY"] = "suspicious_history";
4623
- RiskFactorType2["HIGH_VELOCITY"] = "high_velocity";
4624
- RiskFactorType2["CUSTOM_RULE"] = "custom_rule";
4625
- return RiskFactorType2;
4626
- })(RiskFactorType || {});
4627
- var AuthMethod = /* @__PURE__ */ ((AuthMethod2) => {
4628
- AuthMethod2["PASSWORD"] = "password";
4629
- AuthMethod2["OAUTH"] = "oauth";
4630
- AuthMethod2["PASSKEY"] = "passkey";
4631
- AuthMethod2["MAGIC_LINK"] = "magic_link";
4632
- AuthMethod2["MFA"] = "mfa";
4633
- AuthMethod2["SAML"] = "saml";
4634
- return AuthMethod2;
4635
- })(AuthMethod || {});
4636
- var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4637
- RiskEventOutcome2["ALLOWED"] = "allowed";
4638
- RiskEventOutcome2["BLOCKED"] = "blocked";
4639
- RiskEventOutcome2["CHALLENGED"] = "challenged";
4640
- RiskEventOutcome2["LOGGED"] = "logged";
4641
- return RiskEventOutcome2;
4642
- })(RiskEventOutcome || {});
4643
4647
  export {
4644
4648
  AuthErrorCodes,
4645
- AuthMethod,
4646
4649
  AuthModule,
4647
4650
  BrowserStorage,
4648
4651
  CookieStorage,
@@ -4653,9 +4656,6 @@ export {
4653
4656
  PasskeysModule,
4654
4657
  PermissionsModule,
4655
4658
  PlatformModule,
4656
- RiskAction,
4657
- RiskEventOutcome,
4658
- RiskFactorType,
4659
4659
  ServiceApiModule,
4660
4660
  ServicesModule,
4661
4661
  SsoApiError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drmhse/sso-sdk",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Zero-dependency TypeScript SDK for AuthOS, the multi-tenant authentication platform",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",