@drmhse/sso-sdk 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # AuthOS SDK
1
+ # [AuthOS](https://authos.dev) SDK
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@drmhse/sso-sdk)](https://www.npmjs.com/package/@drmhse/sso-sdk)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- A zero-dependency, strongly-typed TypeScript SDK for AuthOS, the multi-tenant authentication platform.
6
+ A zero-dependency, strongly-typed TypeScript SDK for [AuthOS](https://authos.dev), the multi-tenant authentication platform.
7
7
 
8
8
  **[View Full Documentation →](https://drmhse.com/docs/sso/)**
9
9
 
@@ -331,7 +331,7 @@ sso.onAuthStateChange((isAuthenticated) => {
331
331
 
332
332
  ## Platform Administration
333
333
 
334
- For platform owners managing AuthOS:
334
+ For platform owners managing [AuthOS](https://authos.dev):
335
335
 
336
336
  ```typescript
337
337
  // Approve pending organization
@@ -383,7 +383,7 @@ const login = async (credentials: LoginPayload): Promise<RefreshTokenResponse> =
383
383
 
384
384
  ## Validating JWTs in Your Backend
385
385
 
386
- AuthOS uses RS256 (asymmetric) JWT signing. Your backend can validate tokens without sharing secrets:
386
+ [AuthOS](https://authos.dev) uses RS256 (asymmetric) JWT signing. Your backend can validate tokens without sharing secrets:
387
387
 
388
388
  ```typescript
389
389
  // Fetch JWKS from the SSO platform
package/dist/index.d.mts CHANGED
@@ -23,6 +23,31 @@ declare class BrowserStorage implements TokenStorage {
23
23
  setItem(key: string, value: string): void;
24
24
  removeItem(key: string): void;
25
25
  }
26
+ /**
27
+ * Browser Cookie adapter for SSR frameworks (Next.js, Nuxt, etc.)
28
+ *
29
+ * Uses document.cookie for client-side access. Works with server-side
30
+ * middleware that can read the same cookies.
31
+ *
32
+ * For Next.js App Router, pair this with cookies() from 'next/headers'
33
+ * in server components to pass the initial token.
34
+ */
35
+ declare class CookieStorage implements TokenStorage {
36
+ private options;
37
+ constructor(options?: {
38
+ domain?: string;
39
+ path?: string;
40
+ secure?: boolean;
41
+ sameSite?: 'strict' | 'lax' | 'none';
42
+ maxAge?: number;
43
+ });
44
+ private getCookie;
45
+ private setCookie;
46
+ private deleteCookie;
47
+ getItem(key: string): string | null;
48
+ setItem(key: string, value: string): void;
49
+ removeItem(key: string): void;
50
+ }
26
51
 
27
52
  /**
28
53
  * Common types used across the SDK
@@ -2027,6 +2052,14 @@ interface SessionConfig {
2027
2052
  storageKeyPrefix?: string;
2028
2053
  autoRefresh?: boolean;
2029
2054
  }
2055
+ /**
2056
+ * Snapshot of the current authentication state.
2057
+ * Useful for hydration in SSR frameworks.
2058
+ */
2059
+ interface AuthSnapshot {
2060
+ isAuthenticated: boolean;
2061
+ token: string | null;
2062
+ }
2030
2063
  declare class SessionManager {
2031
2064
  private storage;
2032
2065
  private refreshHandler;
@@ -2061,7 +2094,13 @@ declare class SessionManager {
2061
2094
  refreshSession(): Promise<string>;
2062
2095
  isAuthenticated(): boolean;
2063
2096
  /**
2064
- * Subscribe to auth state changes (useful for UI updates)
2097
+ * Get a synchronous snapshot of the current auth state.
2098
+ * Useful for SSR hydration and initial state.
2099
+ */
2100
+ getSnapshot(): AuthSnapshot;
2101
+ /**
2102
+ * Subscribe to auth state changes (useful for UI updates).
2103
+ * The listener is immediately called with the current state upon subscription.
2065
2104
  */
2066
2105
  subscribe(listener: (isAuthenticated: boolean) => void): () => void;
2067
2106
  private notifyListeners;
@@ -5577,6 +5616,19 @@ declare class SsoClient {
5577
5616
  * Gets the current base URL
5578
5617
  */
5579
5618
  getBaseURL(): string;
5619
+ /**
5620
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
5621
+ * Use this for stateless token verification in edge functions or middleware.
5622
+ *
5623
+ * @returns The full URL to the .well-known/jwks.json endpoint
5624
+ *
5625
+ * @example
5626
+ * ```typescript
5627
+ * const jwksUrl = sso.getJwksUrl();
5628
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
5629
+ * ```
5630
+ */
5631
+ getJwksUrl(): string;
5580
5632
  /**
5581
5633
  * Check if the user is currently authenticated
5582
5634
  */
@@ -5607,6 +5659,52 @@ declare class SsoClient {
5607
5659
  getToken(): Promise<string | null>;
5608
5660
  }
5609
5661
 
5662
+ /**
5663
+ * Standard authentication error codes returned by the AuthOS API.
5664
+ * Use these to reliably switch UI states based on error type.
5665
+ */
5666
+ declare enum AuthErrorCodes {
5667
+ /** Multi-factor authentication is required to complete login */
5668
+ MFA_REQUIRED = "MFA_REQUIRED",
5669
+ /** User must select or create an organization */
5670
+ ORG_REQUIRED = "ORG_REQUIRED",
5671
+ /** The provided credentials are invalid */
5672
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
5673
+ /** The JWT token has expired */
5674
+ TOKEN_EXPIRED = "TOKEN_EXPIRED",
5675
+ /** The refresh token is invalid or has been revoked */
5676
+ REFRESH_TOKEN_INVALID = "REFRESH_TOKEN_INVALID",
5677
+ /** The user is not authorized to perform this action */
5678
+ UNAUTHORIZED = "UNAUTHORIZED",
5679
+ /** The user does not have permission for this resource */
5680
+ FORBIDDEN = "FORBIDDEN",
5681
+ /** The requested resource was not found */
5682
+ NOT_FOUND = "NOT_FOUND",
5683
+ /** The request failed validation */
5684
+ VALIDATION_ERROR = "VALIDATION_ERROR",
5685
+ /** The email address is already registered */
5686
+ EMAIL_ALREADY_EXISTS = "EMAIL_ALREADY_EXISTS",
5687
+ /** Email verification is required */
5688
+ EMAIL_NOT_VERIFIED = "EMAIL_NOT_VERIFIED",
5689
+ /** The account has been suspended */
5690
+ ACCOUNT_SUSPENDED = "ACCOUNT_SUSPENDED",
5691
+ /** The organization has been suspended */
5692
+ ORG_SUSPENDED = "ORG_SUSPENDED",
5693
+ /** Rate limit exceeded */
5694
+ RATE_LIMITED = "RATE_LIMITED",
5695
+ /** The password does not meet requirements */
5696
+ WEAK_PASSWORD = "WEAK_PASSWORD",
5697
+ /** The MFA code is invalid */
5698
+ INVALID_MFA_CODE = "INVALID_MFA_CODE",
5699
+ /** The magic link or verification token has expired */
5700
+ LINK_EXPIRED = "LINK_EXPIRED",
5701
+ /** The device code has expired */
5702
+ DEVICE_CODE_EXPIRED = "DEVICE_CODE_EXPIRED",
5703
+ /** Authorization is still pending (device flow) */
5704
+ AUTHORIZATION_PENDING = "AUTHORIZATION_PENDING",
5705
+ /** The passkey authentication failed */
5706
+ PASSKEY_ERROR = "PASSKEY_ERROR"
5707
+ }
5610
5708
  /**
5611
5709
  * Custom error class for SSO API errors.
5612
5710
  * Provides structured error information from the API.
@@ -5643,4 +5741,4 @@ declare class SsoApiError extends Error {
5643
5741
  isNotFound(): boolean;
5644
5742
  }
5645
5743
 
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 };
5744
+ 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 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
@@ -23,6 +23,31 @@ declare class BrowserStorage implements TokenStorage {
23
23
  setItem(key: string, value: string): void;
24
24
  removeItem(key: string): void;
25
25
  }
26
+ /**
27
+ * Browser Cookie adapter for SSR frameworks (Next.js, Nuxt, etc.)
28
+ *
29
+ * Uses document.cookie for client-side access. Works with server-side
30
+ * middleware that can read the same cookies.
31
+ *
32
+ * For Next.js App Router, pair this with cookies() from 'next/headers'
33
+ * in server components to pass the initial token.
34
+ */
35
+ declare class CookieStorage implements TokenStorage {
36
+ private options;
37
+ constructor(options?: {
38
+ domain?: string;
39
+ path?: string;
40
+ secure?: boolean;
41
+ sameSite?: 'strict' | 'lax' | 'none';
42
+ maxAge?: number;
43
+ });
44
+ private getCookie;
45
+ private setCookie;
46
+ private deleteCookie;
47
+ getItem(key: string): string | null;
48
+ setItem(key: string, value: string): void;
49
+ removeItem(key: string): void;
50
+ }
26
51
 
27
52
  /**
28
53
  * Common types used across the SDK
@@ -2027,6 +2052,14 @@ interface SessionConfig {
2027
2052
  storageKeyPrefix?: string;
2028
2053
  autoRefresh?: boolean;
2029
2054
  }
2055
+ /**
2056
+ * Snapshot of the current authentication state.
2057
+ * Useful for hydration in SSR frameworks.
2058
+ */
2059
+ interface AuthSnapshot {
2060
+ isAuthenticated: boolean;
2061
+ token: string | null;
2062
+ }
2030
2063
  declare class SessionManager {
2031
2064
  private storage;
2032
2065
  private refreshHandler;
@@ -2061,7 +2094,13 @@ declare class SessionManager {
2061
2094
  refreshSession(): Promise<string>;
2062
2095
  isAuthenticated(): boolean;
2063
2096
  /**
2064
- * Subscribe to auth state changes (useful for UI updates)
2097
+ * Get a synchronous snapshot of the current auth state.
2098
+ * Useful for SSR hydration and initial state.
2099
+ */
2100
+ getSnapshot(): AuthSnapshot;
2101
+ /**
2102
+ * Subscribe to auth state changes (useful for UI updates).
2103
+ * The listener is immediately called with the current state upon subscription.
2065
2104
  */
2066
2105
  subscribe(listener: (isAuthenticated: boolean) => void): () => void;
2067
2106
  private notifyListeners;
@@ -5577,6 +5616,19 @@ declare class SsoClient {
5577
5616
  * Gets the current base URL
5578
5617
  */
5579
5618
  getBaseURL(): string;
5619
+ /**
5620
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
5621
+ * Use this for stateless token verification in edge functions or middleware.
5622
+ *
5623
+ * @returns The full URL to the .well-known/jwks.json endpoint
5624
+ *
5625
+ * @example
5626
+ * ```typescript
5627
+ * const jwksUrl = sso.getJwksUrl();
5628
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
5629
+ * ```
5630
+ */
5631
+ getJwksUrl(): string;
5580
5632
  /**
5581
5633
  * Check if the user is currently authenticated
5582
5634
  */
@@ -5607,6 +5659,52 @@ declare class SsoClient {
5607
5659
  getToken(): Promise<string | null>;
5608
5660
  }
5609
5661
 
5662
+ /**
5663
+ * Standard authentication error codes returned by the AuthOS API.
5664
+ * Use these to reliably switch UI states based on error type.
5665
+ */
5666
+ declare enum AuthErrorCodes {
5667
+ /** Multi-factor authentication is required to complete login */
5668
+ MFA_REQUIRED = "MFA_REQUIRED",
5669
+ /** User must select or create an organization */
5670
+ ORG_REQUIRED = "ORG_REQUIRED",
5671
+ /** The provided credentials are invalid */
5672
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
5673
+ /** The JWT token has expired */
5674
+ TOKEN_EXPIRED = "TOKEN_EXPIRED",
5675
+ /** The refresh token is invalid or has been revoked */
5676
+ REFRESH_TOKEN_INVALID = "REFRESH_TOKEN_INVALID",
5677
+ /** The user is not authorized to perform this action */
5678
+ UNAUTHORIZED = "UNAUTHORIZED",
5679
+ /** The user does not have permission for this resource */
5680
+ FORBIDDEN = "FORBIDDEN",
5681
+ /** The requested resource was not found */
5682
+ NOT_FOUND = "NOT_FOUND",
5683
+ /** The request failed validation */
5684
+ VALIDATION_ERROR = "VALIDATION_ERROR",
5685
+ /** The email address is already registered */
5686
+ EMAIL_ALREADY_EXISTS = "EMAIL_ALREADY_EXISTS",
5687
+ /** Email verification is required */
5688
+ EMAIL_NOT_VERIFIED = "EMAIL_NOT_VERIFIED",
5689
+ /** The account has been suspended */
5690
+ ACCOUNT_SUSPENDED = "ACCOUNT_SUSPENDED",
5691
+ /** The organization has been suspended */
5692
+ ORG_SUSPENDED = "ORG_SUSPENDED",
5693
+ /** Rate limit exceeded */
5694
+ RATE_LIMITED = "RATE_LIMITED",
5695
+ /** The password does not meet requirements */
5696
+ WEAK_PASSWORD = "WEAK_PASSWORD",
5697
+ /** The MFA code is invalid */
5698
+ INVALID_MFA_CODE = "INVALID_MFA_CODE",
5699
+ /** The magic link or verification token has expired */
5700
+ LINK_EXPIRED = "LINK_EXPIRED",
5701
+ /** The device code has expired */
5702
+ DEVICE_CODE_EXPIRED = "DEVICE_CODE_EXPIRED",
5703
+ /** Authorization is still pending (device flow) */
5704
+ AUTHORIZATION_PENDING = "AUTHORIZATION_PENDING",
5705
+ /** The passkey authentication failed */
5706
+ PASSKEY_ERROR = "PASSKEY_ERROR"
5707
+ }
5610
5708
  /**
5611
5709
  * Custom error class for SSO API errors.
5612
5710
  * Provides structured error information from the API.
@@ -5643,4 +5741,4 @@ declare class SsoApiError extends Error {
5643
5741
  isNotFound(): boolean;
5644
5742
  }
5645
5743
 
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 };
5744
+ 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 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,9 +20,11 @@ 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,
27
+ CookieStorage: () => CookieStorage,
26
28
  InvitationsModule: () => InvitationsModule,
27
29
  MagicLinks: () => MagicLinks,
28
30
  MemoryStorage: () => MemoryStorage,
@@ -42,6 +44,29 @@ __export(index_exports, {
42
44
  module.exports = __toCommonJS(index_exports);
43
45
 
44
46
  // src/errors.ts
47
+ var AuthErrorCodes = /* @__PURE__ */ ((AuthErrorCodes2) => {
48
+ AuthErrorCodes2["MFA_REQUIRED"] = "MFA_REQUIRED";
49
+ AuthErrorCodes2["ORG_REQUIRED"] = "ORG_REQUIRED";
50
+ AuthErrorCodes2["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
51
+ AuthErrorCodes2["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
52
+ AuthErrorCodes2["REFRESH_TOKEN_INVALID"] = "REFRESH_TOKEN_INVALID";
53
+ AuthErrorCodes2["UNAUTHORIZED"] = "UNAUTHORIZED";
54
+ AuthErrorCodes2["FORBIDDEN"] = "FORBIDDEN";
55
+ AuthErrorCodes2["NOT_FOUND"] = "NOT_FOUND";
56
+ AuthErrorCodes2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
57
+ AuthErrorCodes2["EMAIL_ALREADY_EXISTS"] = "EMAIL_ALREADY_EXISTS";
58
+ AuthErrorCodes2["EMAIL_NOT_VERIFIED"] = "EMAIL_NOT_VERIFIED";
59
+ AuthErrorCodes2["ACCOUNT_SUSPENDED"] = "ACCOUNT_SUSPENDED";
60
+ AuthErrorCodes2["ORG_SUSPENDED"] = "ORG_SUSPENDED";
61
+ AuthErrorCodes2["RATE_LIMITED"] = "RATE_LIMITED";
62
+ AuthErrorCodes2["WEAK_PASSWORD"] = "WEAK_PASSWORD";
63
+ AuthErrorCodes2["INVALID_MFA_CODE"] = "INVALID_MFA_CODE";
64
+ AuthErrorCodes2["LINK_EXPIRED"] = "LINK_EXPIRED";
65
+ AuthErrorCodes2["DEVICE_CODE_EXPIRED"] = "DEVICE_CODE_EXPIRED";
66
+ AuthErrorCodes2["AUTHORIZATION_PENDING"] = "AUTHORIZATION_PENDING";
67
+ AuthErrorCodes2["PASSKEY_ERROR"] = "PASSKEY_ERROR";
68
+ return AuthErrorCodes2;
69
+ })(AuthErrorCodes || {});
45
70
  var SsoApiError = class _SsoApiError extends Error {
46
71
  constructor(message, statusCode, errorCode, timestamp) {
47
72
  super(message);
@@ -334,10 +359,22 @@ var SessionManager = class {
334
359
  return !!this.accessToken;
335
360
  }
336
361
  /**
337
- * Subscribe to auth state changes (useful for UI updates)
362
+ * Get a synchronous snapshot of the current auth state.
363
+ * Useful for SSR hydration and initial state.
364
+ */
365
+ getSnapshot() {
366
+ return {
367
+ isAuthenticated: !!this.accessToken,
368
+ token: this.accessToken
369
+ };
370
+ }
371
+ /**
372
+ * Subscribe to auth state changes (useful for UI updates).
373
+ * The listener is immediately called with the current state upon subscription.
338
374
  */
339
375
  subscribe(listener) {
340
376
  this.listeners.push(listener);
377
+ listener(this.isAuthenticated());
341
378
  return () => {
342
379
  this.listeners = this.listeners.filter((l) => l !== listener);
343
380
  };
@@ -373,6 +410,60 @@ var BrowserStorage = class {
373
410
  if (typeof window !== "undefined") window.localStorage.removeItem(key);
374
411
  }
375
412
  };
413
+ var CookieStorage = class {
414
+ constructor(options = {}) {
415
+ this.options = options;
416
+ }
417
+ getCookie(name) {
418
+ if (typeof window === "undefined") return null;
419
+ const value = `; ${document.cookie}`;
420
+ const parts = value.split(`; ${name}=`);
421
+ if (parts.length === 2) {
422
+ return parts.pop()?.split(";").shift() || null;
423
+ }
424
+ return null;
425
+ }
426
+ setCookie(name, value) {
427
+ if (typeof window === "undefined") return;
428
+ let cookie = `${name}=${value}`;
429
+ if (this.options.path) {
430
+ cookie += `; Path=${this.options.path}`;
431
+ }
432
+ if (this.options.domain) {
433
+ cookie += `; Domain=${this.options.domain}`;
434
+ }
435
+ if (this.options.secure !== false) {
436
+ cookie += "; Secure";
437
+ }
438
+ if (this.options.sameSite ?? "lax") {
439
+ cookie += `; SameSite=${this.options.sameSite ?? "lax"}`;
440
+ }
441
+ if (this.options.maxAge) {
442
+ cookie += `; Max-Age=${this.options.maxAge}`;
443
+ }
444
+ document.cookie = cookie;
445
+ }
446
+ deleteCookie(name) {
447
+ if (typeof window === "undefined") return;
448
+ let cookie = `${name}=; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
449
+ if (this.options.path) {
450
+ cookie += `; Path=${this.options.path}`;
451
+ }
452
+ if (this.options.domain) {
453
+ cookie += `; Domain=${this.options.domain}`;
454
+ }
455
+ document.cookie = cookie;
456
+ }
457
+ getItem(key) {
458
+ return this.getCookie(key);
459
+ }
460
+ setItem(key, value) {
461
+ this.setCookie(key, value);
462
+ }
463
+ removeItem(key) {
464
+ this.deleteCookie(key);
465
+ }
466
+ };
376
467
  function resolveStorage(userStorage) {
377
468
  if (userStorage) return userStorage;
378
469
  if (typeof window !== "undefined" && window.localStorage) return new BrowserStorage();
@@ -4484,6 +4575,22 @@ var SsoClient = class {
4484
4575
  getBaseURL() {
4485
4576
  return this.http.defaults.baseURL || "";
4486
4577
  }
4578
+ /**
4579
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
4580
+ * Use this for stateless token verification in edge functions or middleware.
4581
+ *
4582
+ * @returns The full URL to the .well-known/jwks.json endpoint
4583
+ *
4584
+ * @example
4585
+ * ```typescript
4586
+ * const jwksUrl = sso.getJwksUrl();
4587
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
4588
+ * ```
4589
+ */
4590
+ getJwksUrl() {
4591
+ const baseUrl = this.getBaseURL().replace(/\/$/, "");
4592
+ return `${baseUrl}/.well-known/jwks.json`;
4593
+ }
4487
4594
  /**
4488
4595
  * Check if the user is currently authenticated
4489
4596
  */
@@ -4561,9 +4668,11 @@ var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4561
4668
  })(RiskEventOutcome || {});
4562
4669
  // Annotate the CommonJS export names for ESM import in node:
4563
4670
  0 && (module.exports = {
4671
+ AuthErrorCodes,
4564
4672
  AuthMethod,
4565
4673
  AuthModule,
4566
4674
  BrowserStorage,
4675
+ CookieStorage,
4567
4676
  InvitationsModule,
4568
4677
  MagicLinks,
4569
4678
  MemoryStorage,
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
  };
@@ -330,6 +365,60 @@ var BrowserStorage = class {
330
365
  if (typeof window !== "undefined") window.localStorage.removeItem(key);
331
366
  }
332
367
  };
368
+ var CookieStorage = class {
369
+ constructor(options = {}) {
370
+ this.options = options;
371
+ }
372
+ getCookie(name) {
373
+ if (typeof window === "undefined") return null;
374
+ const value = `; ${document.cookie}`;
375
+ const parts = value.split(`; ${name}=`);
376
+ if (parts.length === 2) {
377
+ return parts.pop()?.split(";").shift() || null;
378
+ }
379
+ return null;
380
+ }
381
+ setCookie(name, value) {
382
+ if (typeof window === "undefined") return;
383
+ let cookie = `${name}=${value}`;
384
+ if (this.options.path) {
385
+ cookie += `; Path=${this.options.path}`;
386
+ }
387
+ if (this.options.domain) {
388
+ cookie += `; Domain=${this.options.domain}`;
389
+ }
390
+ if (this.options.secure !== false) {
391
+ cookie += "; Secure";
392
+ }
393
+ if (this.options.sameSite ?? "lax") {
394
+ cookie += `; SameSite=${this.options.sameSite ?? "lax"}`;
395
+ }
396
+ if (this.options.maxAge) {
397
+ cookie += `; Max-Age=${this.options.maxAge}`;
398
+ }
399
+ document.cookie = cookie;
400
+ }
401
+ deleteCookie(name) {
402
+ if (typeof window === "undefined") return;
403
+ let cookie = `${name}=; Expires=Thu, 01 Jan 1970 00:00:00 GMT`;
404
+ if (this.options.path) {
405
+ cookie += `; Path=${this.options.path}`;
406
+ }
407
+ if (this.options.domain) {
408
+ cookie += `; Domain=${this.options.domain}`;
409
+ }
410
+ document.cookie = cookie;
411
+ }
412
+ getItem(key) {
413
+ return this.getCookie(key);
414
+ }
415
+ setItem(key, value) {
416
+ this.setCookie(key, value);
417
+ }
418
+ removeItem(key) {
419
+ this.deleteCookie(key);
420
+ }
421
+ };
333
422
  function resolveStorage(userStorage) {
334
423
  if (userStorage) return userStorage;
335
424
  if (typeof window !== "undefined" && window.localStorage) return new BrowserStorage();
@@ -4441,6 +4530,22 @@ var SsoClient = class {
4441
4530
  getBaseURL() {
4442
4531
  return this.http.defaults.baseURL || "";
4443
4532
  }
4533
+ /**
4534
+ * Gets the JWKS (JSON Web Key Set) URL for JWT verification.
4535
+ * Use this for stateless token verification in edge functions or middleware.
4536
+ *
4537
+ * @returns The full URL to the .well-known/jwks.json endpoint
4538
+ *
4539
+ * @example
4540
+ * ```typescript
4541
+ * const jwksUrl = sso.getJwksUrl();
4542
+ * // Returns: "https://sso.example.com/.well-known/jwks.json"
4543
+ * ```
4544
+ */
4545
+ getJwksUrl() {
4546
+ const baseUrl = this.getBaseURL().replace(/\/$/, "");
4547
+ return `${baseUrl}/.well-known/jwks.json`;
4548
+ }
4444
4549
  /**
4445
4550
  * Check if the user is currently authenticated
4446
4551
  */
@@ -4517,9 +4622,11 @@ var RiskEventOutcome = /* @__PURE__ */ ((RiskEventOutcome2) => {
4517
4622
  return RiskEventOutcome2;
4518
4623
  })(RiskEventOutcome || {});
4519
4624
  export {
4625
+ AuthErrorCodes,
4520
4626
  AuthMethod,
4521
4627
  AuthModule,
4522
4628
  BrowserStorage,
4629
+ CookieStorage,
4523
4630
  InvitationsModule,
4524
4631
  MagicLinks,
4525
4632
  MemoryStorage,
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.5",
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",