@drmhse/sso-sdk 0.3.3 → 0.3.4

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
@@ -2027,6 +2027,14 @@ interface SessionConfig {
2027
2027
  storageKeyPrefix?: string;
2028
2028
  autoRefresh?: boolean;
2029
2029
  }
2030
+ /**
2031
+ * Snapshot of the current authentication state.
2032
+ * Useful for hydration in SSR frameworks.
2033
+ */
2034
+ interface AuthSnapshot {
2035
+ isAuthenticated: boolean;
2036
+ token: string | null;
2037
+ }
2030
2038
  declare class SessionManager {
2031
2039
  private storage;
2032
2040
  private refreshHandler;
@@ -2061,7 +2069,13 @@ declare class SessionManager {
2061
2069
  refreshSession(): Promise<string>;
2062
2070
  isAuthenticated(): boolean;
2063
2071
  /**
2064
- * Subscribe to auth state changes (useful for UI updates)
2072
+ * Get a synchronous snapshot of the current auth state.
2073
+ * Useful for SSR hydration and initial state.
2074
+ */
2075
+ getSnapshot(): AuthSnapshot;
2076
+ /**
2077
+ * Subscribe to auth state changes (useful for UI updates).
2078
+ * The listener is immediately called with the current state upon subscription.
2065
2079
  */
2066
2080
  subscribe(listener: (isAuthenticated: boolean) => void): () => void;
2067
2081
  private notifyListeners;
@@ -5577,6 +5591,19 @@ declare class SsoClient {
5577
5591
  * Gets the current base URL
5578
5592
  */
5579
5593
  getBaseURL(): string;
5594
+ /**
5595
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
5596
+ * Use this for stateless token verification in edge functions or middleware.
5597
+ *
5598
+ * @returns The full URL to the .well-known/jwks.json endpoint
5599
+ *
5600
+ * @example
5601
+ * ```typescript
5602
+ * const jwksUrl = sso.getJwksUrl();
5603
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
5604
+ * ```
5605
+ */
5606
+ getJwksUrl(): string;
5580
5607
  /**
5581
5608
  * Check if the user is currently authenticated
5582
5609
  */
@@ -5607,6 +5634,52 @@ declare class SsoClient {
5607
5634
  getToken(): Promise<string | null>;
5608
5635
  }
5609
5636
 
5637
+ /**
5638
+ * Standard authentication error codes returned by the AuthOS API.
5639
+ * Use these to reliably switch UI states based on error type.
5640
+ */
5641
+ declare enum AuthErrorCodes {
5642
+ /** Multi-factor authentication is required to complete login */
5643
+ MFA_REQUIRED = "MFA_REQUIRED",
5644
+ /** User must select or create an organization */
5645
+ ORG_REQUIRED = "ORG_REQUIRED",
5646
+ /** The provided credentials are invalid */
5647
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
5648
+ /** The JWT token has expired */
5649
+ TOKEN_EXPIRED = "TOKEN_EXPIRED",
5650
+ /** The refresh token is invalid or has been revoked */
5651
+ REFRESH_TOKEN_INVALID = "REFRESH_TOKEN_INVALID",
5652
+ /** The user is not authorized to perform this action */
5653
+ UNAUTHORIZED = "UNAUTHORIZED",
5654
+ /** The user does not have permission for this resource */
5655
+ FORBIDDEN = "FORBIDDEN",
5656
+ /** The requested resource was not found */
5657
+ NOT_FOUND = "NOT_FOUND",
5658
+ /** The request failed validation */
5659
+ VALIDATION_ERROR = "VALIDATION_ERROR",
5660
+ /** The email address is already registered */
5661
+ EMAIL_ALREADY_EXISTS = "EMAIL_ALREADY_EXISTS",
5662
+ /** Email verification is required */
5663
+ EMAIL_NOT_VERIFIED = "EMAIL_NOT_VERIFIED",
5664
+ /** The account has been suspended */
5665
+ ACCOUNT_SUSPENDED = "ACCOUNT_SUSPENDED",
5666
+ /** The organization has been suspended */
5667
+ ORG_SUSPENDED = "ORG_SUSPENDED",
5668
+ /** Rate limit exceeded */
5669
+ RATE_LIMITED = "RATE_LIMITED",
5670
+ /** The password does not meet requirements */
5671
+ WEAK_PASSWORD = "WEAK_PASSWORD",
5672
+ /** The MFA code is invalid */
5673
+ INVALID_MFA_CODE = "INVALID_MFA_CODE",
5674
+ /** The magic link or verification token has expired */
5675
+ LINK_EXPIRED = "LINK_EXPIRED",
5676
+ /** The device code has expired */
5677
+ DEVICE_CODE_EXPIRED = "DEVICE_CODE_EXPIRED",
5678
+ /** Authorization is still pending (device flow) */
5679
+ AUTHORIZATION_PENDING = "AUTHORIZATION_PENDING",
5680
+ /** The passkey authentication failed */
5681
+ PASSKEY_ERROR = "PASSKEY_ERROR"
5682
+ }
5610
5683
  /**
5611
5684
  * Custom error class for SSO API errors.
5612
5685
  * Provides structured error information from the API.
@@ -5643,4 +5716,4 @@ declare class SsoApiError extends Error {
5643
5716
  isNotFound(): boolean;
5644
5717
  }
5645
5718
 
5646
- 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 };
5719
+ 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, 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 };
package/dist/index.d.ts CHANGED
@@ -2027,6 +2027,14 @@ interface SessionConfig {
2027
2027
  storageKeyPrefix?: string;
2028
2028
  autoRefresh?: boolean;
2029
2029
  }
2030
+ /**
2031
+ * Snapshot of the current authentication state.
2032
+ * Useful for hydration in SSR frameworks.
2033
+ */
2034
+ interface AuthSnapshot {
2035
+ isAuthenticated: boolean;
2036
+ token: string | null;
2037
+ }
2030
2038
  declare class SessionManager {
2031
2039
  private storage;
2032
2040
  private refreshHandler;
@@ -2061,7 +2069,13 @@ declare class SessionManager {
2061
2069
  refreshSession(): Promise<string>;
2062
2070
  isAuthenticated(): boolean;
2063
2071
  /**
2064
- * Subscribe to auth state changes (useful for UI updates)
2072
+ * Get a synchronous snapshot of the current auth state.
2073
+ * Useful for SSR hydration and initial state.
2074
+ */
2075
+ getSnapshot(): AuthSnapshot;
2076
+ /**
2077
+ * Subscribe to auth state changes (useful for UI updates).
2078
+ * The listener is immediately called with the current state upon subscription.
2065
2079
  */
2066
2080
  subscribe(listener: (isAuthenticated: boolean) => void): () => void;
2067
2081
  private notifyListeners;
@@ -5577,6 +5591,19 @@ declare class SsoClient {
5577
5591
  * Gets the current base URL
5578
5592
  */
5579
5593
  getBaseURL(): string;
5594
+ /**
5595
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
5596
+ * Use this for stateless token verification in edge functions or middleware.
5597
+ *
5598
+ * @returns The full URL to the .well-known/jwks.json endpoint
5599
+ *
5600
+ * @example
5601
+ * ```typescript
5602
+ * const jwksUrl = sso.getJwksUrl();
5603
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
5604
+ * ```
5605
+ */
5606
+ getJwksUrl(): string;
5580
5607
  /**
5581
5608
  * Check if the user is currently authenticated
5582
5609
  */
@@ -5607,6 +5634,52 @@ declare class SsoClient {
5607
5634
  getToken(): Promise<string | null>;
5608
5635
  }
5609
5636
 
5637
+ /**
5638
+ * Standard authentication error codes returned by the AuthOS API.
5639
+ * Use these to reliably switch UI states based on error type.
5640
+ */
5641
+ declare enum AuthErrorCodes {
5642
+ /** Multi-factor authentication is required to complete login */
5643
+ MFA_REQUIRED = "MFA_REQUIRED",
5644
+ /** User must select or create an organization */
5645
+ ORG_REQUIRED = "ORG_REQUIRED",
5646
+ /** The provided credentials are invalid */
5647
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
5648
+ /** The JWT token has expired */
5649
+ TOKEN_EXPIRED = "TOKEN_EXPIRED",
5650
+ /** The refresh token is invalid or has been revoked */
5651
+ REFRESH_TOKEN_INVALID = "REFRESH_TOKEN_INVALID",
5652
+ /** The user is not authorized to perform this action */
5653
+ UNAUTHORIZED = "UNAUTHORIZED",
5654
+ /** The user does not have permission for this resource */
5655
+ FORBIDDEN = "FORBIDDEN",
5656
+ /** The requested resource was not found */
5657
+ NOT_FOUND = "NOT_FOUND",
5658
+ /** The request failed validation */
5659
+ VALIDATION_ERROR = "VALIDATION_ERROR",
5660
+ /** The email address is already registered */
5661
+ EMAIL_ALREADY_EXISTS = "EMAIL_ALREADY_EXISTS",
5662
+ /** Email verification is required */
5663
+ EMAIL_NOT_VERIFIED = "EMAIL_NOT_VERIFIED",
5664
+ /** The account has been suspended */
5665
+ ACCOUNT_SUSPENDED = "ACCOUNT_SUSPENDED",
5666
+ /** The organization has been suspended */
5667
+ ORG_SUSPENDED = "ORG_SUSPENDED",
5668
+ /** Rate limit exceeded */
5669
+ RATE_LIMITED = "RATE_LIMITED",
5670
+ /** The password does not meet requirements */
5671
+ WEAK_PASSWORD = "WEAK_PASSWORD",
5672
+ /** The MFA code is invalid */
5673
+ INVALID_MFA_CODE = "INVALID_MFA_CODE",
5674
+ /** The magic link or verification token has expired */
5675
+ LINK_EXPIRED = "LINK_EXPIRED",
5676
+ /** The device code has expired */
5677
+ DEVICE_CODE_EXPIRED = "DEVICE_CODE_EXPIRED",
5678
+ /** Authorization is still pending (device flow) */
5679
+ AUTHORIZATION_PENDING = "AUTHORIZATION_PENDING",
5680
+ /** The passkey authentication failed */
5681
+ PASSKEY_ERROR = "PASSKEY_ERROR"
5682
+ }
5610
5683
  /**
5611
5684
  * Custom error class for SSO API errors.
5612
5685
  * Provides structured error information from the API.
@@ -5643,4 +5716,4 @@ declare class SsoApiError extends Error {
5643
5716
  isNotFound(): boolean;
5644
5717
  }
5645
5718
 
5646
- 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 };
5719
+ 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, 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 };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AuthErrorCodes: () => AuthErrorCodes,
23
24
  AuthMethod: () => AuthMethod,
24
25
  AuthModule: () => AuthModule,
25
26
  BrowserStorage: () => BrowserStorage,
@@ -42,6 +43,29 @@ __export(index_exports, {
42
43
  module.exports = __toCommonJS(index_exports);
43
44
 
44
45
  // src/errors.ts
46
+ var AuthErrorCodes = /* @__PURE__ */ ((AuthErrorCodes2) => {
47
+ AuthErrorCodes2["MFA_REQUIRED"] = "MFA_REQUIRED";
48
+ AuthErrorCodes2["ORG_REQUIRED"] = "ORG_REQUIRED";
49
+ AuthErrorCodes2["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
50
+ AuthErrorCodes2["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
51
+ AuthErrorCodes2["REFRESH_TOKEN_INVALID"] = "REFRESH_TOKEN_INVALID";
52
+ AuthErrorCodes2["UNAUTHORIZED"] = "UNAUTHORIZED";
53
+ AuthErrorCodes2["FORBIDDEN"] = "FORBIDDEN";
54
+ AuthErrorCodes2["NOT_FOUND"] = "NOT_FOUND";
55
+ AuthErrorCodes2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
56
+ AuthErrorCodes2["EMAIL_ALREADY_EXISTS"] = "EMAIL_ALREADY_EXISTS";
57
+ AuthErrorCodes2["EMAIL_NOT_VERIFIED"] = "EMAIL_NOT_VERIFIED";
58
+ AuthErrorCodes2["ACCOUNT_SUSPENDED"] = "ACCOUNT_SUSPENDED";
59
+ AuthErrorCodes2["ORG_SUSPENDED"] = "ORG_SUSPENDED";
60
+ AuthErrorCodes2["RATE_LIMITED"] = "RATE_LIMITED";
61
+ AuthErrorCodes2["WEAK_PASSWORD"] = "WEAK_PASSWORD";
62
+ AuthErrorCodes2["INVALID_MFA_CODE"] = "INVALID_MFA_CODE";
63
+ AuthErrorCodes2["LINK_EXPIRED"] = "LINK_EXPIRED";
64
+ AuthErrorCodes2["DEVICE_CODE_EXPIRED"] = "DEVICE_CODE_EXPIRED";
65
+ AuthErrorCodes2["AUTHORIZATION_PENDING"] = "AUTHORIZATION_PENDING";
66
+ AuthErrorCodes2["PASSKEY_ERROR"] = "PASSKEY_ERROR";
67
+ return AuthErrorCodes2;
68
+ })(AuthErrorCodes || {});
45
69
  var SsoApiError = class _SsoApiError extends Error {
46
70
  constructor(message, statusCode, errorCode, timestamp) {
47
71
  super(message);
@@ -334,10 +358,22 @@ var SessionManager = class {
334
358
  return !!this.accessToken;
335
359
  }
336
360
  /**
337
- * Subscribe to auth state changes (useful for UI updates)
361
+ * Get a synchronous snapshot of the current auth state.
362
+ * Useful for SSR hydration and initial state.
363
+ */
364
+ getSnapshot() {
365
+ return {
366
+ isAuthenticated: !!this.accessToken,
367
+ token: this.accessToken
368
+ };
369
+ }
370
+ /**
371
+ * Subscribe to auth state changes (useful for UI updates).
372
+ * The listener is immediately called with the current state upon subscription.
338
373
  */
339
374
  subscribe(listener) {
340
375
  this.listeners.push(listener);
376
+ listener(this.isAuthenticated());
341
377
  return () => {
342
378
  this.listeners = this.listeners.filter((l) => l !== listener);
343
379
  };
@@ -4484,6 +4520,22 @@ var SsoClient = class {
4484
4520
  getBaseURL() {
4485
4521
  return this.http.defaults.baseURL || "";
4486
4522
  }
4523
+ /**
4524
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
4525
+ * Use this for stateless token verification in edge functions or middleware.
4526
+ *
4527
+ * @returns The full URL to the .well-known/jwks.json endpoint
4528
+ *
4529
+ * @example
4530
+ * ```typescript
4531
+ * const jwksUrl = sso.getJwksUrl();
4532
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
4533
+ * ```
4534
+ */
4535
+ getJwksUrl() {
4536
+ const baseUrl = this.getBaseURL().replace(/\/$/, "");
4537
+ return `${baseUrl}/.well-known/jwks.json`;
4538
+ }
4487
4539
  /**
4488
4540
  * Check if the user is currently authenticated
4489
4541
  */
@@ -4561,6 +4613,7 @@ var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4561
4613
  })(RiskEventOutcome || {});
4562
4614
  // Annotate the CommonJS export names for ESM import in node:
4563
4615
  0 && (module.exports = {
4616
+ AuthErrorCodes,
4564
4617
  AuthMethod,
4565
4618
  AuthModule,
4566
4619
  BrowserStorage,
package/dist/index.mjs CHANGED
@@ -1,4 +1,27 @@
1
1
  // src/errors.ts
2
+ var AuthErrorCodes = /* @__PURE__ */ ((AuthErrorCodes2) => {
3
+ AuthErrorCodes2["MFA_REQUIRED"] = "MFA_REQUIRED";
4
+ AuthErrorCodes2["ORG_REQUIRED"] = "ORG_REQUIRED";
5
+ AuthErrorCodes2["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
6
+ AuthErrorCodes2["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
7
+ AuthErrorCodes2["REFRESH_TOKEN_INVALID"] = "REFRESH_TOKEN_INVALID";
8
+ AuthErrorCodes2["UNAUTHORIZED"] = "UNAUTHORIZED";
9
+ AuthErrorCodes2["FORBIDDEN"] = "FORBIDDEN";
10
+ AuthErrorCodes2["NOT_FOUND"] = "NOT_FOUND";
11
+ AuthErrorCodes2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
12
+ AuthErrorCodes2["EMAIL_ALREADY_EXISTS"] = "EMAIL_ALREADY_EXISTS";
13
+ AuthErrorCodes2["EMAIL_NOT_VERIFIED"] = "EMAIL_NOT_VERIFIED";
14
+ AuthErrorCodes2["ACCOUNT_SUSPENDED"] = "ACCOUNT_SUSPENDED";
15
+ AuthErrorCodes2["ORG_SUSPENDED"] = "ORG_SUSPENDED";
16
+ AuthErrorCodes2["RATE_LIMITED"] = "RATE_LIMITED";
17
+ AuthErrorCodes2["WEAK_PASSWORD"] = "WEAK_PASSWORD";
18
+ AuthErrorCodes2["INVALID_MFA_CODE"] = "INVALID_MFA_CODE";
19
+ AuthErrorCodes2["LINK_EXPIRED"] = "LINK_EXPIRED";
20
+ AuthErrorCodes2["DEVICE_CODE_EXPIRED"] = "DEVICE_CODE_EXPIRED";
21
+ AuthErrorCodes2["AUTHORIZATION_PENDING"] = "AUTHORIZATION_PENDING";
22
+ AuthErrorCodes2["PASSKEY_ERROR"] = "PASSKEY_ERROR";
23
+ return AuthErrorCodes2;
24
+ })(AuthErrorCodes || {});
2
25
  var SsoApiError = class _SsoApiError extends Error {
3
26
  constructor(message, statusCode, errorCode, timestamp) {
4
27
  super(message);
@@ -291,10 +314,22 @@ var SessionManager = class {
291
314
  return !!this.accessToken;
292
315
  }
293
316
  /**
294
- * Subscribe to auth state changes (useful for UI updates)
317
+ * Get a synchronous snapshot of the current auth state.
318
+ * Useful for SSR hydration and initial state.
319
+ */
320
+ getSnapshot() {
321
+ return {
322
+ isAuthenticated: !!this.accessToken,
323
+ token: this.accessToken
324
+ };
325
+ }
326
+ /**
327
+ * Subscribe to auth state changes (useful for UI updates).
328
+ * The listener is immediately called with the current state upon subscription.
295
329
  */
296
330
  subscribe(listener) {
297
331
  this.listeners.push(listener);
332
+ listener(this.isAuthenticated());
298
333
  return () => {
299
334
  this.listeners = this.listeners.filter((l) => l !== listener);
300
335
  };
@@ -4441,6 +4476,22 @@ var SsoClient = class {
4441
4476
  getBaseURL() {
4442
4477
  return this.http.defaults.baseURL || "";
4443
4478
  }
4479
+ /**
4480
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
4481
+ * Use this for stateless token verification in edge functions or middleware.
4482
+ *
4483
+ * @returns The full URL to the .well-known/jwks.json endpoint
4484
+ *
4485
+ * @example
4486
+ * ```typescript
4487
+ * const jwksUrl = sso.getJwksUrl();
4488
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
4489
+ * ```
4490
+ */
4491
+ getJwksUrl() {
4492
+ const baseUrl = this.getBaseURL().replace(/\/$/, "");
4493
+ return `${baseUrl}/.well-known/jwks.json`;
4494
+ }
4444
4495
  /**
4445
4496
  * Check if the user is currently authenticated
4446
4497
  */
@@ -4517,6 +4568,7 @@ var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4517
4568
  return RiskEventOutcome2;
4518
4569
  })(RiskEventOutcome || {});
4519
4570
  export {
4571
+ AuthErrorCodes,
4520
4572
  AuthMethod,
4521
4573
  AuthModule,
4522
4574
  BrowserStorage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drmhse/sso-sdk",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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",