@effect-auth/core 0.1.0-alpha.15 → 0.1.0-alpha.18
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/LICENSE +21 -0
- package/README.md +332 -131
- package/dist/AbuseProtection.d.ts +100 -0
- package/dist/AbuseProtection.d.ts.map +1 -0
- package/dist/AbuseProtection.js +71 -0
- package/dist/AbuseProtection.js.map +1 -0
- package/dist/AccessGrant.d.ts +344 -0
- package/dist/AccessGrant.d.ts.map +1 -0
- package/dist/AccessGrant.js +687 -0
- package/dist/AccessGrant.js.map +1 -0
- package/dist/ApiKey.d.ts +2 -14
- package/dist/ApiKey.d.ts.map +1 -1
- package/dist/ApiKey.js +36 -27
- package/dist/ApiKey.js.map +1 -1
- package/dist/Assurance.d.ts +415 -0
- package/dist/Assurance.d.ts.map +1 -0
- package/dist/Assurance.js +764 -0
- package/dist/Assurance.js.map +1 -0
- package/dist/AtomicPlanExecutor.d.ts +28 -0
- package/dist/AtomicPlanExecutor.d.ts.map +1 -0
- package/dist/AtomicPlanExecutor.js +5 -0
- package/dist/AtomicPlanExecutor.js.map +1 -0
- package/dist/AuditLog.d.ts +2314 -52
- package/dist/AuditLog.d.ts.map +1 -1
- package/dist/AuditLog.js +511 -33
- package/dist/AuditLog.js.map +1 -1
- package/dist/AuthConfig.d.ts.map +1 -1
- package/dist/AuthConfig.js.map +1 -1
- package/dist/AuthFlow.d.ts +326 -220
- package/dist/AuthFlow.d.ts.map +1 -1
- package/dist/AuthFlow.js +611 -263
- package/dist/AuthFlow.js.map +1 -1
- package/dist/AuthKernel.d.ts +1 -1
- package/dist/AuthRateLimit.d.ts +96 -0
- package/dist/AuthRateLimit.d.ts.map +1 -0
- package/dist/AuthRateLimit.js +212 -0
- package/dist/AuthRateLimit.js.map +1 -0
- package/dist/Challenge.d.ts +0 -3
- package/dist/Challenge.d.ts.map +1 -1
- package/dist/Challenge.js +1 -4
- package/dist/Challenge.js.map +1 -1
- package/dist/Client.d.ts +205 -10
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +397 -16
- package/dist/Client.js.map +1 -1
- package/dist/CloudflareTurnstile.d.ts +28 -0
- package/dist/CloudflareTurnstile.d.ts.map +1 -0
- package/dist/CloudflareTurnstile.js +205 -0
- package/dist/CloudflareTurnstile.js.map +1 -0
- package/dist/Crypto.d.ts +0 -3
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +5 -7
- package/dist/Crypto.js.map +1 -1
- package/dist/DelegatedAccessStorageMigrations.d.ts +7 -0
- package/dist/DelegatedAccessStorageMigrations.d.ts.map +1 -0
- package/dist/DelegatedAccessStorageMigrations.js +159 -0
- package/dist/DelegatedAccessStorageMigrations.js.map +1 -0
- package/dist/DisposableEmailDomains.d.ts +19 -0
- package/dist/DisposableEmailDomains.d.ts.map +1 -0
- package/dist/DisposableEmailDomains.js +85 -0
- package/dist/DisposableEmailDomains.js.map +1 -0
- package/dist/DomainVerification.d.ts +0 -9
- package/dist/DomainVerification.d.ts.map +1 -1
- package/dist/DomainVerification.js +36 -22
- package/dist/DomainVerification.js.map +1 -1
- package/dist/DrizzleBunSqliteStorage.d.ts +18 -0
- package/dist/DrizzleBunSqliteStorage.d.ts.map +1 -0
- package/dist/DrizzleBunSqliteStorage.js +11 -0
- package/dist/DrizzleBunSqliteStorage.js.map +1 -0
- package/dist/DrizzleD1SqliteStorage.d.ts +28 -0
- package/dist/DrizzleD1SqliteStorage.d.ts.map +1 -0
- package/dist/DrizzleD1SqliteStorage.js +10 -0
- package/dist/DrizzleD1SqliteStorage.js.map +1 -0
- package/dist/DrizzleDurableObjectSqliteStorage.d.ts +19 -0
- package/dist/DrizzleDurableObjectSqliteStorage.d.ts.map +1 -0
- package/dist/DrizzleDurableObjectSqliteStorage.js +14 -0
- package/dist/DrizzleDurableObjectSqliteStorage.js.map +1 -0
- package/dist/DrizzleEffectSqliteStorage.d.ts +31 -0
- package/dist/DrizzleEffectSqliteStorage.d.ts.map +1 -0
- package/dist/DrizzleEffectSqliteStorage.js +108 -0
- package/dist/DrizzleEffectSqliteStorage.js.map +1 -0
- package/dist/DrizzleNodeSqliteStorage.d.ts +18 -0
- package/dist/DrizzleNodeSqliteStorage.d.ts.map +1 -0
- package/dist/DrizzleNodeSqliteStorage.js +11 -0
- package/dist/DrizzleNodeSqliteStorage.js.map +1 -0
- package/dist/DrizzleWasmSqliteStorage.d.ts +23 -0
- package/dist/DrizzleWasmSqliteStorage.d.ts.map +1 -0
- package/dist/DrizzleWasmSqliteStorage.js +15 -0
- package/dist/DrizzleWasmSqliteStorage.js.map +1 -0
- package/dist/EffectQbPostgresDelegatedAccessStorage.d.ts +34 -0
- package/dist/EffectQbPostgresDelegatedAccessStorage.d.ts.map +1 -0
- package/dist/EffectQbPostgresDelegatedAccessStorage.js +499 -0
- package/dist/EffectQbPostgresDelegatedAccessStorage.js.map +1 -0
- package/dist/EffectQbPostgresStorage.d.ts +171 -0
- package/dist/EffectQbPostgresStorage.d.ts.map +1 -0
- package/dist/EffectQbPostgresStorage.js +4280 -0
- package/dist/EffectQbPostgresStorage.js.map +1 -0
- package/dist/EffectQbSqliteDelegatedAccessStorage.d.ts +112 -0
- package/dist/EffectQbSqliteDelegatedAccessStorage.d.ts.map +1 -0
- package/dist/EffectQbSqliteDelegatedAccessStorage.js +602 -0
- package/dist/EffectQbSqliteDelegatedAccessStorage.js.map +1 -0
- package/dist/EffectQbSqliteStorage.d.ts +184 -27
- package/dist/EffectQbSqliteStorage.d.ts.map +1 -1
- package/dist/EffectQbSqliteStorage.js +1729 -135
- package/dist/EffectQbSqliteStorage.js.map +1 -1
- package/dist/EmailAuth.d.ts +65 -0
- package/dist/EmailAuth.d.ts.map +1 -0
- package/dist/EmailAuth.js +171 -0
- package/dist/EmailAuth.js.map +1 -0
- package/dist/EmailIdentityAuth.d.ts +30 -0
- package/dist/EmailIdentityAuth.d.ts.map +1 -0
- package/dist/EmailIdentityAuth.js +142 -0
- package/dist/EmailIdentityAuth.js.map +1 -0
- package/dist/EmailOtp.d.ts +10 -11
- package/dist/EmailOtp.d.ts.map +1 -1
- package/dist/EmailOtp.js +44 -81
- package/dist/EmailOtp.js.map +1 -1
- package/dist/EmailRisk.d.ts +48 -0
- package/dist/EmailRisk.d.ts.map +1 -0
- package/dist/EmailRisk.js +33 -0
- package/dist/EmailRisk.js.map +1 -0
- package/dist/EmailVerification.d.ts +10 -16
- package/dist/EmailVerification.d.ts.map +1 -1
- package/dist/EmailVerification.js +85 -42
- package/dist/EmailVerification.js.map +1 -1
- package/dist/Guard.d.ts +11 -0
- package/dist/Guard.d.ts.map +1 -0
- package/dist/Guard.js +11 -0
- package/dist/Guard.js.map +1 -0
- package/dist/HibpPwnedPasswords.d.ts +56 -0
- package/dist/HibpPwnedPasswords.d.ts.map +1 -0
- package/dist/HibpPwnedPasswords.js +232 -0
- package/dist/HibpPwnedPasswords.js.map +1 -0
- package/dist/HttpApi/AdminPermissionDefinition.d.ts +4 -0
- package/dist/HttpApi/AdminPermissionDefinition.d.ts.map +1 -0
- package/dist/HttpApi/AdminPermissionDefinition.js +4 -0
- package/dist/HttpApi/AdminPermissionDefinition.js.map +1 -0
- package/dist/HttpApi/AdminSecurityTimeline.d.ts +4 -0
- package/dist/HttpApi/AdminSecurityTimeline.d.ts.map +1 -0
- package/dist/HttpApi/AdminSecurityTimeline.js +4 -0
- package/dist/HttpApi/AdminSecurityTimeline.js.map +1 -0
- package/dist/HttpApi/AdminSession.d.ts +4 -0
- package/dist/HttpApi/AdminSession.d.ts.map +1 -0
- package/dist/HttpApi/AdminSession.js +4 -0
- package/dist/HttpApi/AdminSession.js.map +1 -0
- package/dist/HttpApi/AdminTrustedDevice.d.ts +4 -0
- package/dist/HttpApi/AdminTrustedDevice.d.ts.map +1 -0
- package/dist/HttpApi/AdminTrustedDevice.js +4 -0
- package/dist/HttpApi/AdminTrustedDevice.js.map +1 -0
- package/dist/HttpApi/Api.d.ts +1172 -1172
- package/dist/HttpApi/Api.d.ts.map +1 -1
- package/dist/HttpApi/Api.js +2160 -896
- package/dist/HttpApi/Api.js.map +1 -1
- package/dist/HttpApi/ApiKey.d.ts +4 -0
- package/dist/HttpApi/ApiKey.d.ts.map +1 -0
- package/dist/HttpApi/ApiKey.js +4 -0
- package/dist/HttpApi/ApiKey.js.map +1 -0
- package/dist/HttpApi/Audit.d.ts +6 -0
- package/dist/HttpApi/Audit.d.ts.map +1 -0
- package/dist/HttpApi/Audit.js +10 -0
- package/dist/HttpApi/Audit.js.map +1 -0
- package/dist/HttpApi/ClientApi.d.ts +917 -0
- package/dist/HttpApi/ClientApi.d.ts.map +1 -0
- package/dist/HttpApi/ClientApi.js +101 -0
- package/dist/HttpApi/ClientApi.js.map +1 -0
- package/dist/HttpApi/EmailAuth.d.ts +6 -0
- package/dist/HttpApi/EmailAuth.d.ts.map +1 -0
- package/dist/HttpApi/EmailAuth.js +6 -0
- package/dist/HttpApi/EmailAuth.js.map +1 -0
- package/dist/HttpApi/EmailGuards.d.ts +115 -0
- package/dist/HttpApi/EmailGuards.d.ts.map +1 -0
- package/dist/HttpApi/EmailGuards.js +191 -0
- package/dist/HttpApi/EmailGuards.js.map +1 -0
- package/dist/HttpApi/EmailOtp.d.ts +6 -0
- package/dist/HttpApi/EmailOtp.d.ts.map +1 -0
- package/dist/HttpApi/EmailOtp.js +6 -0
- package/dist/HttpApi/EmailOtp.js.map +1 -0
- package/dist/HttpApi/EmailVerification.d.ts +6 -0
- package/dist/HttpApi/EmailVerification.d.ts.map +1 -0
- package/dist/HttpApi/EmailVerification.js +6 -0
- package/dist/HttpApi/EmailVerification.js.map +1 -0
- package/dist/HttpApi/Endpoints.d.ts +629 -301
- package/dist/HttpApi/Endpoints.d.ts.map +1 -1
- package/dist/HttpApi/Endpoints.js +178 -120
- package/dist/HttpApi/Endpoints.js.map +1 -1
- package/dist/HttpApi/Errors.d.ts +26 -7
- package/dist/HttpApi/Errors.d.ts.map +1 -1
- package/dist/HttpApi/Errors.js +26 -4
- package/dist/HttpApi/Errors.js.map +1 -1
- package/dist/HttpApi/Identity.d.ts +6 -0
- package/dist/HttpApi/Identity.d.ts.map +1 -0
- package/dist/HttpApi/Identity.js +6 -0
- package/dist/HttpApi/Identity.js.map +1 -0
- package/dist/HttpApi/IdentityGuards.d.ts +31 -0
- package/dist/HttpApi/IdentityGuards.d.ts.map +1 -0
- package/dist/HttpApi/IdentityGuards.js +33 -0
- package/dist/HttpApi/IdentityGuards.js.map +1 -0
- package/dist/HttpApi/Jwt.d.ts +4 -0
- package/dist/HttpApi/Jwt.d.ts.map +1 -0
- package/dist/HttpApi/Jwt.js +4 -0
- package/dist/HttpApi/Jwt.js.map +1 -0
- package/dist/HttpApi/JwtDiscovery.d.ts +4 -0
- package/dist/HttpApi/JwtDiscovery.d.ts.map +1 -0
- package/dist/HttpApi/JwtDiscovery.js +4 -0
- package/dist/HttpApi/JwtDiscovery.js.map +1 -0
- package/dist/HttpApi/LoginApproval.d.ts +5 -0
- package/dist/HttpApi/LoginApproval.d.ts.map +1 -0
- package/dist/HttpApi/LoginApproval.js +5 -0
- package/dist/HttpApi/LoginApproval.js.map +1 -0
- package/dist/HttpApi/LoginNotification.d.ts +5 -0
- package/dist/HttpApi/LoginNotification.d.ts.map +1 -0
- package/dist/HttpApi/LoginNotification.js +5 -0
- package/dist/HttpApi/LoginNotification.js.map +1 -0
- package/dist/HttpApi/MagicLink.d.ts +6 -0
- package/dist/HttpApi/MagicLink.d.ts.map +1 -0
- package/dist/HttpApi/MagicLink.js +6 -0
- package/dist/HttpApi/MagicLink.js.map +1 -0
- package/dist/HttpApi/Mfa.d.ts +5 -0
- package/dist/HttpApi/Mfa.d.ts.map +1 -0
- package/dist/HttpApi/Mfa.js +5 -0
- package/dist/HttpApi/Mfa.js.map +1 -0
- package/dist/HttpApi/Middleware.d.ts +14 -0
- package/dist/HttpApi/Middleware.d.ts.map +1 -0
- package/dist/HttpApi/Middleware.js +5 -0
- package/dist/HttpApi/Middleware.js.map +1 -0
- package/dist/HttpApi/OAuth.d.ts +4 -0
- package/dist/HttpApi/OAuth.d.ts.map +1 -0
- package/dist/HttpApi/OAuth.js +4 -0
- package/dist/HttpApi/OAuth.js.map +1 -0
- package/dist/HttpApi/OAuthProviderAuthorization.d.ts +4 -0
- package/dist/HttpApi/OAuthProviderAuthorization.d.ts.map +1 -0
- package/dist/HttpApi/OAuthProviderAuthorization.js +4 -0
- package/dist/HttpApi/OAuthProviderAuthorization.js.map +1 -0
- package/dist/HttpApi/OAuthToken.d.ts +4 -0
- package/dist/HttpApi/OAuthToken.d.ts.map +1 -0
- package/dist/HttpApi/OAuthToken.js +4 -0
- package/dist/HttpApi/OAuthToken.js.map +1 -0
- package/dist/HttpApi/OidcDiscovery.d.ts +4 -0
- package/dist/HttpApi/OidcDiscovery.d.ts.map +1 -0
- package/dist/HttpApi/OidcDiscovery.js +4 -0
- package/dist/HttpApi/OidcDiscovery.js.map +1 -0
- package/dist/HttpApi/Operations/AdminPermissionDefinition.d.ts +28 -0
- package/dist/HttpApi/Operations/AdminPermissionDefinition.d.ts.map +1 -0
- package/dist/HttpApi/Operations/AdminPermissionDefinition.js +5 -0
- package/dist/HttpApi/Operations/AdminPermissionDefinition.js.map +1 -0
- package/dist/HttpApi/Operations/AdminSession.d.ts +16 -0
- package/dist/HttpApi/Operations/AdminSession.d.ts.map +1 -0
- package/dist/HttpApi/Operations/AdminSession.js +5 -0
- package/dist/HttpApi/Operations/AdminSession.js.map +1 -0
- package/dist/HttpApi/Operations/ApiKey.d.ts +16 -0
- package/dist/HttpApi/Operations/ApiKey.d.ts.map +1 -0
- package/dist/HttpApi/Operations/ApiKey.js +5 -0
- package/dist/HttpApi/Operations/ApiKey.js.map +1 -0
- package/dist/HttpApi/Operations/Discovery.d.ts +19 -0
- package/dist/HttpApi/Operations/Discovery.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Discovery.js +7 -0
- package/dist/HttpApi/Operations/Discovery.js.map +1 -0
- package/dist/HttpApi/Operations/EmailAuth.d.ts +12 -0
- package/dist/HttpApi/Operations/EmailAuth.d.ts.map +1 -0
- package/dist/HttpApi/Operations/EmailAuth.js +5 -0
- package/dist/HttpApi/Operations/EmailAuth.js.map +1 -0
- package/dist/HttpApi/Operations/EmailOtp.d.ts +14 -0
- package/dist/HttpApi/Operations/EmailOtp.d.ts.map +1 -0
- package/dist/HttpApi/Operations/EmailOtp.js +5 -0
- package/dist/HttpApi/Operations/EmailOtp.js.map +1 -0
- package/dist/HttpApi/Operations/EmailVerification.d.ts +14 -0
- package/dist/HttpApi/Operations/EmailVerification.d.ts.map +1 -0
- package/dist/HttpApi/Operations/EmailVerification.js +5 -0
- package/dist/HttpApi/Operations/EmailVerification.js.map +1 -0
- package/dist/HttpApi/Operations/HttpOperation.d.ts +4 -0
- package/dist/HttpApi/Operations/HttpOperation.d.ts.map +1 -0
- package/dist/HttpApi/Operations/HttpOperation.js +2 -0
- package/dist/HttpApi/Operations/HttpOperation.js.map +1 -0
- package/dist/HttpApi/Operations/Identity.d.ts +22 -0
- package/dist/HttpApi/Operations/Identity.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Identity.js +5 -0
- package/dist/HttpApi/Operations/Identity.js.map +1 -0
- package/dist/HttpApi/Operations/Jwt.d.ts +14 -0
- package/dist/HttpApi/Operations/Jwt.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Jwt.js +5 -0
- package/dist/HttpApi/Operations/Jwt.js.map +1 -0
- package/dist/HttpApi/Operations/LoginApproval.d.ts +16 -0
- package/dist/HttpApi/Operations/LoginApproval.d.ts.map +1 -0
- package/dist/HttpApi/Operations/LoginApproval.js +5 -0
- package/dist/HttpApi/Operations/LoginApproval.js.map +1 -0
- package/dist/HttpApi/Operations/MagicLink.d.ts +14 -0
- package/dist/HttpApi/Operations/MagicLink.d.ts.map +1 -0
- package/dist/HttpApi/Operations/MagicLink.js +5 -0
- package/dist/HttpApi/Operations/MagicLink.js.map +1 -0
- package/dist/HttpApi/Operations/Mfa.d.ts +24 -0
- package/dist/HttpApi/Operations/Mfa.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Mfa.js +5 -0
- package/dist/HttpApi/Operations/Mfa.js.map +1 -0
- package/dist/HttpApi/Operations/OAuth.d.ts +20 -0
- package/dist/HttpApi/Operations/OAuth.d.ts.map +1 -0
- package/dist/HttpApi/Operations/OAuth.js +5 -0
- package/dist/HttpApi/Operations/OAuth.js.map +1 -0
- package/dist/HttpApi/Operations/OAuthProviderAuthorization.d.ts +12 -0
- package/dist/HttpApi/Operations/OAuthProviderAuthorization.d.ts.map +1 -0
- package/dist/HttpApi/Operations/OAuthProviderAuthorization.js +5 -0
- package/dist/HttpApi/Operations/OAuthProviderAuthorization.js.map +1 -0
- package/dist/HttpApi/Operations/OAuthToken.d.ts +16 -0
- package/dist/HttpApi/Operations/OAuthToken.d.ts.map +1 -0
- package/dist/HttpApi/Operations/OAuthToken.js +5 -0
- package/dist/HttpApi/Operations/OAuthToken.js.map +1 -0
- package/dist/HttpApi/Operations/Passkey.d.ts +22 -0
- package/dist/HttpApi/Operations/Passkey.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Passkey.js +5 -0
- package/dist/HttpApi/Operations/Passkey.js.map +1 -0
- package/dist/HttpApi/Operations/Password.d.ts +22 -0
- package/dist/HttpApi/Operations/Password.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Password.js +5 -0
- package/dist/HttpApi/Operations/Password.js.map +1 -0
- package/dist/HttpApi/Operations/RecoveryCodes.d.ts +20 -0
- package/dist/HttpApi/Operations/RecoveryCodes.d.ts.map +1 -0
- package/dist/HttpApi/Operations/RecoveryCodes.js +5 -0
- package/dist/HttpApi/Operations/RecoveryCodes.js.map +1 -0
- package/dist/HttpApi/Operations/RefreshToken.d.ts +12 -0
- package/dist/HttpApi/Operations/RefreshToken.d.ts.map +1 -0
- package/dist/HttpApi/Operations/RefreshToken.js +5 -0
- package/dist/HttpApi/Operations/RefreshToken.js.map +1 -0
- package/dist/HttpApi/Operations/Security.d.ts +12 -0
- package/dist/HttpApi/Operations/Security.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Security.js +5 -0
- package/dist/HttpApi/Operations/Security.js.map +1 -0
- package/dist/HttpApi/Operations/SecurityTimeline.d.ts +19 -0
- package/dist/HttpApi/Operations/SecurityTimeline.d.ts.map +1 -0
- package/dist/HttpApi/Operations/SecurityTimeline.js +7 -0
- package/dist/HttpApi/Operations/SecurityTimeline.js.map +1 -0
- package/dist/HttpApi/Operations/Session.d.ts +22 -0
- package/dist/HttpApi/Operations/Session.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Session.js +5 -0
- package/dist/HttpApi/Operations/Session.js.map +1 -0
- package/dist/HttpApi/Operations/StepUp.d.ts +22 -0
- package/dist/HttpApi/Operations/StepUp.d.ts.map +1 -0
- package/dist/HttpApi/Operations/StepUp.js +5 -0
- package/dist/HttpApi/Operations/StepUp.js.map +1 -0
- package/dist/HttpApi/Operations/Totp.d.ts +20 -0
- package/dist/HttpApi/Operations/Totp.d.ts.map +1 -0
- package/dist/HttpApi/Operations/Totp.js +5 -0
- package/dist/HttpApi/Operations/Totp.js.map +1 -0
- package/dist/HttpApi/Operations/TrustedDevice.d.ts +23 -0
- package/dist/HttpApi/Operations/TrustedDevice.d.ts.map +1 -0
- package/dist/HttpApi/Operations/TrustedDevice.js +7 -0
- package/dist/HttpApi/Operations/TrustedDevice.js.map +1 -0
- package/dist/HttpApi/Operations/index.d.ts +27 -0
- package/dist/HttpApi/Operations/index.d.ts.map +1 -0
- package/dist/HttpApi/Operations/index.js +27 -0
- package/dist/HttpApi/Operations/index.js.map +1 -0
- package/dist/HttpApi/Passkey.d.ts +5 -0
- package/dist/HttpApi/Passkey.d.ts.map +1 -0
- package/dist/HttpApi/Passkey.js +5 -0
- package/dist/HttpApi/Passkey.js.map +1 -0
- package/dist/HttpApi/Password.d.ts +220 -0
- package/dist/HttpApi/Password.d.ts.map +1 -0
- package/dist/HttpApi/Password.js +237 -0
- package/dist/HttpApi/Password.js.map +1 -0
- package/dist/HttpApi/PasswordContract.d.ts +307 -0
- package/dist/HttpApi/PasswordContract.d.ts.map +1 -0
- package/dist/HttpApi/PasswordContract.js +63 -0
- package/dist/HttpApi/PasswordContract.js.map +1 -0
- package/dist/HttpApi/PasswordGuards.d.ts +82 -0
- package/dist/HttpApi/PasswordGuards.d.ts.map +1 -0
- package/dist/HttpApi/PasswordGuards.js +179 -0
- package/dist/HttpApi/PasswordGuards.js.map +1 -0
- package/dist/HttpApi/RecoveryCodes.d.ts +5 -0
- package/dist/HttpApi/RecoveryCodes.d.ts.map +1 -0
- package/dist/HttpApi/RecoveryCodes.js +5 -0
- package/dist/HttpApi/RecoveryCodes.js.map +1 -0
- package/dist/HttpApi/RefreshToken.d.ts +4 -0
- package/dist/HttpApi/RefreshToken.d.ts.map +1 -0
- package/dist/HttpApi/RefreshToken.js +4 -0
- package/dist/HttpApi/RefreshToken.js.map +1 -0
- package/dist/HttpApi/RequestGuards.d.ts +42 -0
- package/dist/HttpApi/RequestGuards.d.ts.map +1 -0
- package/dist/HttpApi/RequestGuards.js +194 -0
- package/dist/HttpApi/RequestGuards.js.map +1 -0
- package/dist/HttpApi/Schemas.d.ts +361 -84
- package/dist/HttpApi/Schemas.d.ts.map +1 -1
- package/dist/HttpApi/Schemas.js +190 -27
- package/dist/HttpApi/Schemas.js.map +1 -1
- package/dist/HttpApi/Security.d.ts +12 -93
- package/dist/HttpApi/Security.d.ts.map +1 -1
- package/dist/HttpApi/Security.js +65 -356
- package/dist/HttpApi/Security.js.map +1 -1
- package/dist/HttpApi/SecurityTimeline.d.ts +4 -0
- package/dist/HttpApi/SecurityTimeline.d.ts.map +1 -0
- package/dist/HttpApi/SecurityTimeline.js +4 -0
- package/dist/HttpApi/SecurityTimeline.js.map +1 -0
- package/dist/HttpApi/Session.d.ts +5 -0
- package/dist/HttpApi/Session.d.ts.map +1 -0
- package/dist/HttpApi/Session.js +5 -0
- package/dist/HttpApi/Session.js.map +1 -0
- package/dist/HttpApi/SessionGuards.d.ts +15 -0
- package/dist/HttpApi/SessionGuards.d.ts.map +1 -0
- package/dist/HttpApi/SessionGuards.js +37 -0
- package/dist/HttpApi/SessionGuards.js.map +1 -0
- package/dist/HttpApi/StepUp.d.ts +5 -0
- package/dist/HttpApi/StepUp.d.ts.map +1 -0
- package/dist/HttpApi/StepUp.js +5 -0
- package/dist/HttpApi/StepUp.js.map +1 -0
- package/dist/HttpApi/Totp.d.ts +5 -0
- package/dist/HttpApi/Totp.d.ts.map +1 -0
- package/dist/HttpApi/Totp.js +5 -0
- package/dist/HttpApi/Totp.js.map +1 -0
- package/dist/HttpApi/Transport.d.ts +4 -6
- package/dist/HttpApi/Transport.d.ts.map +1 -1
- package/dist/HttpApi/Transport.js +62 -36
- package/dist/HttpApi/Transport.js.map +1 -1
- package/dist/HttpApi/TrustedDevice.d.ts +4 -0
- package/dist/HttpApi/TrustedDevice.d.ts.map +1 -0
- package/dist/HttpApi/TrustedDevice.js +4 -0
- package/dist/HttpApi/TrustedDevice.js.map +1 -0
- package/dist/HttpApi/index.d.ts +9 -3
- package/dist/HttpApi/index.d.ts.map +1 -1
- package/dist/HttpApi/index.js +8 -2
- package/dist/HttpApi/index.js.map +1 -1
- package/dist/Identity.d.ts +138 -0
- package/dist/Identity.d.ts.map +1 -0
- package/dist/Identity.js +105 -0
- package/dist/Identity.js.map +1 -0
- package/dist/IdentityManagement.d.ts +189 -0
- package/dist/IdentityManagement.d.ts.map +1 -0
- package/dist/IdentityManagement.js +317 -0
- package/dist/IdentityManagement.js.map +1 -0
- package/dist/IncidentAction.d.ts +1 -4
- package/dist/IncidentAction.d.ts.map +1 -1
- package/dist/IncidentAction.js +15 -9
- package/dist/IncidentAction.js.map +1 -1
- package/dist/Internal.d.ts +2 -0
- package/dist/Internal.d.ts.map +1 -1
- package/dist/Internal.js +30 -0
- package/dist/Internal.js.map +1 -1
- package/dist/Invitation.d.ts +362 -0
- package/dist/Invitation.d.ts.map +1 -0
- package/dist/Invitation.js +633 -0
- package/dist/Invitation.js.map +1 -0
- package/dist/IpQualityScore.d.ts +38 -0
- package/dist/IpQualityScore.d.ts.map +1 -0
- package/dist/IpQualityScore.js +215 -0
- package/dist/IpQualityScore.js.map +1 -0
- package/dist/Jwt.d.ts +9 -30
- package/dist/Jwt.d.ts.map +1 -1
- package/dist/Jwt.js +72 -60
- package/dist/Jwt.js.map +1 -1
- package/dist/LoginApproval.d.ts +16 -31
- package/dist/LoginApproval.d.ts.map +1 -1
- package/dist/LoginApproval.js +47 -41
- package/dist/LoginApproval.js.map +1 -1
- package/dist/LoginNotification.d.ts +8 -12
- package/dist/LoginNotification.d.ts.map +1 -1
- package/dist/LoginNotification.js +30 -17
- package/dist/LoginNotification.js.map +1 -1
- package/dist/LoginRisk.d.ts +11 -13
- package/dist/LoginRisk.d.ts.map +1 -1
- package/dist/LoginRisk.js +66 -26
- package/dist/LoginRisk.js.map +1 -1
- package/dist/LoginRiskEnrichment.d.ts +145 -0
- package/dist/LoginRiskEnrichment.d.ts.map +1 -0
- package/dist/LoginRiskEnrichment.js +220 -0
- package/dist/LoginRiskEnrichment.js.map +1 -0
- package/dist/MachineAuth.d.ts.map +1 -1
- package/dist/MachineAuth.js.map +1 -1
- package/dist/MagicLink.d.ts +9 -8
- package/dist/MagicLink.d.ts.map +1 -1
- package/dist/MagicLink.js +40 -73
- package/dist/MagicLink.js.map +1 -1
- package/dist/Mailer.d.ts +20 -13
- package/dist/Mailer.d.ts.map +1 -1
- package/dist/Mailer.js +10 -12
- package/dist/Mailer.js.map +1 -1
- package/dist/OAuth.d.ts +100 -103
- package/dist/OAuth.d.ts.map +1 -1
- package/dist/OAuth.js +404 -217
- package/dist/OAuth.js.map +1 -1
- package/dist/Passkey.d.ts +17 -19
- package/dist/Passkey.d.ts.map +1 -1
- package/dist/Passkey.js +86 -39
- package/dist/Passkey.js.map +1 -1
- package/dist/PasskeyBrowser.d.ts +39 -0
- package/dist/PasskeyBrowser.d.ts.map +1 -0
- package/dist/PasskeyBrowser.js +206 -0
- package/dist/PasskeyBrowser.js.map +1 -0
- package/dist/PasskeySimpleWebAuthn.d.ts.map +1 -1
- package/dist/PasskeySimpleWebAuthn.js +19 -7
- package/dist/PasskeySimpleWebAuthn.js.map +1 -1
- package/dist/Password.d.ts +71 -37
- package/dist/Password.d.ts.map +1 -1
- package/dist/Password.js +296 -82
- package/dist/Password.js.map +1 -1
- package/dist/PasswordRisk.d.ts +63 -0
- package/dist/PasswordRisk.d.ts.map +1 -0
- package/dist/PasswordRisk.js +37 -0
- package/dist/PasswordRisk.js.map +1 -0
- package/dist/Permission.d.ts +308 -0
- package/dist/Permission.d.ts.map +1 -0
- package/dist/Permission.js +827 -0
- package/dist/Permission.js.map +1 -0
- package/dist/Policy.d.ts +31 -18
- package/dist/Policy.d.ts.map +1 -1
- package/dist/Policy.js +58 -14
- package/dist/Policy.js.map +1 -1
- package/dist/PostgresDelegatedAccessStorageMigrations.d.ts +7 -0
- package/dist/PostgresDelegatedAccessStorageMigrations.d.ts.map +1 -0
- package/dist/PostgresDelegatedAccessStorageMigrations.js +119 -0
- package/dist/PostgresDelegatedAccessStorageMigrations.js.map +1 -0
- package/dist/PostgresStorageMigrations.d.ts +15 -0
- package/dist/PostgresStorageMigrations.d.ts.map +1 -0
- package/dist/PostgresStorageMigrations.js +620 -0
- package/dist/PostgresStorageMigrations.js.map +1 -0
- package/dist/Privacy.d.ts +0 -3
- package/dist/Privacy.d.ts.map +1 -1
- package/dist/Privacy.js +2 -5
- package/dist/Privacy.js.map +1 -1
- package/dist/RateLimiter.d.ts +0 -3
- package/dist/RateLimiter.d.ts.map +1 -1
- package/dist/RateLimiter.js +1 -4
- package/dist/RateLimiter.js.map +1 -1
- package/dist/RecoveryCode.d.ts +84 -12
- package/dist/RecoveryCode.d.ts.map +1 -1
- package/dist/RecoveryCode.js +273 -75
- package/dist/RecoveryCode.js.map +1 -1
- package/dist/RecoveryPolicy.d.ts +81 -0
- package/dist/RecoveryPolicy.d.ts.map +1 -0
- package/dist/RecoveryPolicy.js +119 -0
- package/dist/RecoveryPolicy.js.map +1 -0
- package/dist/RefreshToken.d.ts +1 -10
- package/dist/RefreshToken.d.ts.map +1 -1
- package/dist/RefreshToken.js +31 -22
- package/dist/RefreshToken.js.map +1 -1
- package/dist/Retention.d.ts.map +1 -1
- package/dist/Retention.js.map +1 -1
- package/dist/SecurityTimeline.d.ts +1 -4
- package/dist/SecurityTimeline.d.ts.map +1 -1
- package/dist/SecurityTimeline.js +110 -17
- package/dist/SecurityTimeline.js.map +1 -1
- package/dist/Sessions.d.ts +124 -29
- package/dist/Sessions.d.ts.map +1 -1
- package/dist/Sessions.js +626 -94
- package/dist/Sessions.js.map +1 -1
- package/dist/StepUp.d.ts +132 -11
- package/dist/StepUp.d.ts.map +1 -1
- package/dist/StepUp.js +387 -19
- package/dist/StepUp.js.map +1 -1
- package/dist/Storage.d.ts +89 -23
- package/dist/Storage.d.ts.map +1 -1
- package/dist/Storage.js +10 -12
- package/dist/Storage.js.map +1 -1
- package/dist/StorageMigrations.d.ts +6 -1
- package/dist/StorageMigrations.d.ts.map +1 -1
- package/dist/StorageMigrations.js +224 -0
- package/dist/StorageMigrations.js.map +1 -1
- package/dist/StorageSchemaGenerator.d.ts +486 -0
- package/dist/StorageSchemaGenerator.d.ts.map +1 -0
- package/dist/StorageSchemaGenerator.js +1022 -0
- package/dist/StorageSchemaGenerator.js.map +1 -0
- package/dist/StrongFactor.d.ts +64 -0
- package/dist/StrongFactor.d.ts.map +1 -0
- package/dist/StrongFactor.js +100 -0
- package/dist/StrongFactor.js.map +1 -0
- package/dist/Testing.d.ts +1 -1
- package/dist/Testing.js +2 -2
- package/dist/Testing.js.map +1 -1
- package/dist/Totp.d.ts +88 -13
- package/dist/Totp.d.ts.map +1 -1
- package/dist/Totp.js +194 -36
- package/dist/Totp.js.map +1 -1
- package/dist/TrustedDevice.d.ts +0 -9
- package/dist/TrustedDevice.d.ts.map +1 -1
- package/dist/TrustedDevice.js +15 -17
- package/dist/TrustedDevice.js.map +1 -1
- package/dist/WaitUntil.d.ts +0 -3
- package/dist/WaitUntil.d.ts.map +1 -1
- package/dist/WaitUntil.js +1 -4
- package/dist/WaitUntil.js.map +1 -1
- package/dist/Webhook.d.ts +42 -12
- package/dist/Webhook.d.ts.map +1 -1
- package/dist/Webhook.js +165 -26
- package/dist/Webhook.js.map +1 -1
- package/dist/alchemy/cloudflare/Email.d.ts +4 -4
- package/dist/alchemy/cloudflare/Email.d.ts.map +1 -1
- package/dist/alchemy/cloudflare/Email.js +10 -5
- package/dist/alchemy/cloudflare/Email.js.map +1 -1
- package/dist/alchemy/cloudflare/RateLimitDurableObject.d.ts +4 -4
- package/dist/alchemy/cloudflare/RateLimitDurableObject.d.ts.map +1 -1
- package/dist/alchemy/cloudflare/RateLimitDurableObject.js +5 -4
- package/dist/alchemy/cloudflare/RateLimitDurableObject.js.map +1 -1
- package/dist/cloudflare/Email.d.ts.map +1 -1
- package/dist/cloudflare/Email.js +1 -1
- package/dist/cloudflare/Email.js.map +1 -1
- package/dist/cloudflare/RateLimitDurableObject.d.ts +6 -5
- package/dist/cloudflare/RateLimitDurableObject.d.ts.map +1 -1
- package/dist/cloudflare/RateLimitDurableObject.js.map +1 -1
- package/dist/cloudflare/RequestMetadata.d.ts +49 -0
- package/dist/cloudflare/RequestMetadata.d.ts.map +1 -0
- package/dist/cloudflare/RequestMetadata.js +71 -0
- package/dist/cloudflare/RequestMetadata.js.map +1 -0
- package/dist/index.d.ts +0 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/AuthFlowFinalizer.d.ts +31 -0
- package/dist/internal/AuthFlowFinalizer.d.ts.map +1 -0
- package/dist/internal/AuthFlowFinalizer.js +182 -0
- package/dist/internal/AuthFlowFinalizer.js.map +1 -0
- package/dist/internal/RateLimitDurableObject.d.ts.map +1 -1
- package/dist/internal/RateLimitDurableObject.js +3 -0
- package/dist/internal/RateLimitDurableObject.js.map +1 -1
- package/migrations/0001_auth_storage.sql +1 -0
- package/migrations/0006_auth_totp_factor.sql +1 -0
- package/migrations/0024_auth_permission.sql +39 -0
- package/migrations/0025_auth_permission_definition.sql +19 -0
- package/migrations/0026_auth_user_identity.sql +59 -0
- package/migrations/0027_auth_audit_log_storage_order.sql +46 -0
- package/migrations/0028_auth_oauth_client_secret_key.sql +39 -0
- package/migrations/delegated-access/0001_auth_delegated_access.sql +152 -0
- package/migrations/postgres/0001_auth_core.sql +77 -0
- package/migrations/postgres/0002_auth_security_oauth.sql +65 -0
- package/migrations/postgres/0003_auth_credentials_tokens.sql +43 -0
- package/migrations/postgres/0004_auth_security_history.sql +103 -0
- package/migrations/postgres/0005_auth_webhooks.sql +29 -0
- package/migrations/postgres/0006_auth_domain_timeline.sql +50 -0
- package/migrations/postgres/0007_auth_oauth_clients.sql +85 -0
- package/migrations/postgres/0008_auth_oauth_tokens.sql +63 -0
- package/migrations/postgres/0009_auth_permissions.sql +66 -0
- package/migrations/postgres/delegated-access/0001_auth_delegated_access.sql +112 -0
- package/package.json +309 -2
package/dist/Password.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { Context, Data, Duration, Effect, Encoding, Layer, Option, Redacted, Result, } from "effect";
|
|
2
|
+
import { passwordEvidence } from "./Assurance.js";
|
|
2
3
|
import { AuthFlow, AuthResult } from "./AuthFlow.js";
|
|
3
4
|
import { Challenge } from "./Challenge.js";
|
|
4
5
|
import { Crypto } from "./Crypto.js";
|
|
5
|
-
import {
|
|
6
|
+
import { EmailAcceptancePolicy, EmailAcceptancePolicyNoopLive, EmailNotAcceptedError, } from "./EmailRisk.js";
|
|
7
|
+
import { CredentialId, Email, IdentityId, UserId } from "./Identifiers.js";
|
|
8
|
+
import { IdentityKindRegistry } from "./Identity.js";
|
|
6
9
|
import { addMillis, currentUnixMillis, timingSafeEqualString, } from "./Internal.js";
|
|
7
10
|
import { AuthMailer } from "./Mailer.js";
|
|
8
|
-
import {
|
|
11
|
+
import { enforcePasswordRisk, PasswordRiskPolicy, PasswordRiskPolicyNoopLive, } from "./PasswordRisk.js";
|
|
12
|
+
import { CredentialStore, IdentityStore, RegistrationStore, SessionStore, UserStore, } from "./Storage.js";
|
|
9
13
|
export class PasswordHashError extends Data.TaggedError("PasswordHashError") {
|
|
10
14
|
}
|
|
11
15
|
export class PasswordHasher extends Context.Service()("auth/PasswordHasher") {
|
|
12
16
|
}
|
|
13
|
-
(function (PasswordHasher) {
|
|
14
|
-
PasswordHasher.make = (service) => PasswordHasher.of(service);
|
|
15
|
-
})(PasswordHasher || (PasswordHasher = {}));
|
|
16
17
|
const textEncoder = new TextEncoder();
|
|
18
|
+
export const defaultPasswordMaxBytes = 1024;
|
|
19
|
+
export class PasswordTooLongError extends Data.TaggedError("PasswordTooLongError") {
|
|
20
|
+
}
|
|
21
|
+
const validatePasswordSize = (password, maximum = defaultPasswordMaxBytes) => textEncoder.encode(Redacted.value(password)).byteLength <= maximum
|
|
22
|
+
? Effect.void
|
|
23
|
+
: Effect.fail(new PasswordTooLongError({
|
|
24
|
+
message: "Password does not meet policy requirements",
|
|
25
|
+
}));
|
|
17
26
|
const passwordHashPrefix = "pbkdf2-sha256";
|
|
18
27
|
const getWebCrypto = (options, operation) => Effect.gen(function* () {
|
|
19
28
|
const crypto = options.webCrypto ?? globalThis.crypto;
|
|
@@ -57,7 +66,7 @@ const derivePbkdf2Sha256 = (input) => Effect.tryPromise({
|
|
|
57
66
|
const bits = await input.webCrypto.subtle.deriveBits({
|
|
58
67
|
name: "PBKDF2",
|
|
59
68
|
hash: "SHA-256",
|
|
60
|
-
salt: input.salt,
|
|
69
|
+
salt: new Uint8Array(input.salt),
|
|
61
70
|
iterations: input.iterations,
|
|
62
71
|
}, key, input.hashBytes * 8);
|
|
63
72
|
return new Uint8Array(bits);
|
|
@@ -72,7 +81,7 @@ export const makePbkdf2PasswordHasher = (dependencies) => {
|
|
|
72
81
|
const iterations = dependencies.iterations ?? 210_000;
|
|
73
82
|
const saltBytes = dependencies.saltBytes ?? 16;
|
|
74
83
|
const hashBytes = dependencies.hashBytes ?? 32;
|
|
75
|
-
return PasswordHasher.
|
|
84
|
+
return PasswordHasher.of({
|
|
76
85
|
hash: Effect.fn("auth.password_hash.pbkdf2.hash")(function* (input) {
|
|
77
86
|
const webCrypto = yield* getWebCrypto(dependencies, "hash");
|
|
78
87
|
const salt = yield* dependencies.crypto.randomBytes(saltBytes).pipe(Effect.mapError((cause) => new PasswordHashError({
|
|
@@ -130,15 +139,25 @@ export const Pbkdf2PasswordHasherLive = (options) => Layer.effect(PasswordHasher
|
|
|
130
139
|
crypto,
|
|
131
140
|
});
|
|
132
141
|
}));
|
|
133
|
-
export class
|
|
142
|
+
export class PasswordPrimaryFactor extends Context.Service()("auth/primary-factor/Password") {
|
|
134
143
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
})(PasswordLogin || (PasswordLogin = {}));
|
|
138
|
-
export const makePasswordLogin = (dependencies) => PasswordLogin.make({
|
|
139
|
-
signIn: Effect.fn("auth.password.sign_in")(function* (input) {
|
|
144
|
+
export const makePasswordPrimaryFactor = (dependencies) => PasswordPrimaryFactor.of({
|
|
145
|
+
verify: Effect.fn("auth.password.primary_factor.verify")(function* (input) {
|
|
140
146
|
yield* Effect.annotateCurrentSpan("auth.method", "password");
|
|
141
|
-
const
|
|
147
|
+
const normalizedOption = yield* dependencies.identityKinds
|
|
148
|
+
.normalize(input.identity)
|
|
149
|
+
.pipe(Effect.option);
|
|
150
|
+
if (Option.isNone(normalizedOption)) {
|
|
151
|
+
yield* Effect.annotateCurrentSpan("auth.result", "InvalidCredentials");
|
|
152
|
+
return AuthResult.InvalidCredentials();
|
|
153
|
+
}
|
|
154
|
+
const normalized = normalizedOption.value;
|
|
155
|
+
const identity = yield* dependencies.identities.findByKindAndNormalizedValue(normalized);
|
|
156
|
+
if (Option.isNone(identity)) {
|
|
157
|
+
yield* Effect.annotateCurrentSpan("auth.result", "InvalidCredentials");
|
|
158
|
+
return AuthResult.InvalidCredentials();
|
|
159
|
+
}
|
|
160
|
+
const user = yield* dependencies.users.findById(identity.value.userId);
|
|
142
161
|
if (Option.isNone(user)) {
|
|
143
162
|
yield* Effect.annotateCurrentSpan("auth.result", "InvalidCredentials");
|
|
144
163
|
return AuthResult.InvalidCredentials();
|
|
@@ -147,7 +166,7 @@ export const makePasswordLogin = (dependencies) => PasswordLogin.make({
|
|
|
147
166
|
yield* Effect.annotateCurrentSpan("auth.result", "AccountDisabled");
|
|
148
167
|
return AuthResult.AccountDisabled();
|
|
149
168
|
}
|
|
150
|
-
const credential = yield* dependencies.credentials.findPasswordByUserId(
|
|
169
|
+
const credential = yield* dependencies.credentials.findPasswordByUserId(identity.value.userId);
|
|
151
170
|
if (Option.isNone(credential) ||
|
|
152
171
|
credential.value.revokedAt !== undefined) {
|
|
153
172
|
yield* Effect.annotateCurrentSpan("auth.result", "InvalidCredentials");
|
|
@@ -161,83 +180,180 @@ export const makePasswordLogin = (dependencies) => PasswordLogin.make({
|
|
|
161
180
|
yield* Effect.annotateCurrentSpan("auth.result", "InvalidCredentials");
|
|
162
181
|
return AuthResult.InvalidCredentials();
|
|
163
182
|
}
|
|
164
|
-
|
|
183
|
+
yield* Effect.annotateCurrentSpan("auth.result", "Verified");
|
|
184
|
+
const verifiedAt = yield* currentUnixMillis;
|
|
185
|
+
return {
|
|
186
|
+
_tag: "Verified",
|
|
165
187
|
userId: user.value.id,
|
|
166
|
-
|
|
188
|
+
identity: {
|
|
189
|
+
identityId: identity.value.id,
|
|
190
|
+
kind: identity.value.kind,
|
|
191
|
+
verified: identity.value.verifiedAt !== undefined,
|
|
192
|
+
},
|
|
193
|
+
...(identity.value.kind === "email"
|
|
194
|
+
? {
|
|
195
|
+
emailDestination: {
|
|
196
|
+
identityId: identity.value.id,
|
|
197
|
+
email: Email(identity.value.value),
|
|
198
|
+
},
|
|
199
|
+
}
|
|
200
|
+
: {}),
|
|
167
201
|
intent: "sign-in",
|
|
168
202
|
method: "password",
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
203
|
+
evidence: [
|
|
204
|
+
passwordEvidence({ credentialId: credential.value.id, verifiedAt }),
|
|
205
|
+
],
|
|
206
|
+
claims: identity.value.verifiedAt === undefined
|
|
207
|
+
? undefined
|
|
208
|
+
: { verifiedIdentityKinds: [identity.value.kind] },
|
|
172
209
|
...(input.trustedDeviceToken === undefined
|
|
173
210
|
? {}
|
|
174
211
|
: { trustedDeviceToken: input.trustedDeviceToken }),
|
|
212
|
+
...(input.deviceKey === undefined
|
|
213
|
+
? {}
|
|
214
|
+
: { deviceKey: input.deviceKey }),
|
|
215
|
+
...(input.locationKey === undefined
|
|
216
|
+
? {}
|
|
217
|
+
: { locationKey: input.locationKey }),
|
|
175
218
|
...(input.request === undefined ? {} : { request: input.request }),
|
|
176
219
|
...(input.metadata === undefined ? {} : { metadata: input.metadata }),
|
|
177
|
-
}
|
|
220
|
+
};
|
|
178
221
|
}),
|
|
179
222
|
});
|
|
223
|
+
export const PasswordPrimaryFactorLive = Layer.effect(PasswordPrimaryFactor)(Effect.gen(function* () {
|
|
224
|
+
const users = yield* UserStore;
|
|
225
|
+
const identities = yield* IdentityStore;
|
|
226
|
+
const identityKinds = yield* IdentityKindRegistry;
|
|
227
|
+
const credentials = yield* CredentialStore;
|
|
228
|
+
const hasher = yield* PasswordHasher;
|
|
229
|
+
return makePasswordPrimaryFactor({
|
|
230
|
+
users,
|
|
231
|
+
identities,
|
|
232
|
+
identityKinds,
|
|
233
|
+
credentials,
|
|
234
|
+
hasher,
|
|
235
|
+
});
|
|
236
|
+
}));
|
|
237
|
+
export class PasswordLogin extends Context.Service()("auth/login/Password") {
|
|
238
|
+
}
|
|
239
|
+
export const makePasswordLogin = (dependencies) => {
|
|
240
|
+
const primaryFactor = makePasswordPrimaryFactor(dependencies);
|
|
241
|
+
return PasswordLogin.of({
|
|
242
|
+
signIn: Effect.fn("auth.password.sign_in")(function* (input) {
|
|
243
|
+
const verified = yield* primaryFactor.verify(input);
|
|
244
|
+
return verified._tag === "Verified"
|
|
245
|
+
? yield* dependencies.authFlow.completePrimaryFactor(verified)
|
|
246
|
+
: verified;
|
|
247
|
+
}),
|
|
248
|
+
});
|
|
249
|
+
};
|
|
180
250
|
export const PasswordLoginLive = Layer.effect(PasswordLogin)(Effect.gen(function* () {
|
|
181
251
|
const users = yield* UserStore;
|
|
252
|
+
const identities = yield* IdentityStore;
|
|
253
|
+
const identityKinds = yield* IdentityKindRegistry;
|
|
182
254
|
const credentials = yield* CredentialStore;
|
|
183
255
|
const hasher = yield* PasswordHasher;
|
|
184
256
|
const authFlow = yield* AuthFlow;
|
|
185
257
|
return makePasswordLogin({
|
|
186
258
|
users,
|
|
259
|
+
identities,
|
|
260
|
+
identityKinds,
|
|
187
261
|
credentials,
|
|
188
262
|
hasher,
|
|
189
263
|
authFlow,
|
|
190
264
|
});
|
|
191
265
|
}));
|
|
192
|
-
export class
|
|
266
|
+
export class IdentityAlreadyRegisteredError extends Data.TaggedError("IdentityAlreadyRegisteredError") {
|
|
193
267
|
}
|
|
194
268
|
export class PasswordRegistration extends Context.Service()("auth/registration/Password") {
|
|
195
269
|
}
|
|
196
|
-
(function (PasswordRegistration) {
|
|
197
|
-
PasswordRegistration.make = (service) => PasswordRegistration.of(service);
|
|
198
|
-
})(PasswordRegistration || (PasswordRegistration = {}));
|
|
199
270
|
export const makePasswordRegistration = (dependencies) => {
|
|
200
271
|
const userIdBytes = dependencies.userIdBytes ?? 16;
|
|
201
272
|
const credentialIdBytes = dependencies.credentialIdBytes ?? 16;
|
|
202
|
-
|
|
273
|
+
const identityIdBytes = dependencies.identityIdBytes ?? 16;
|
|
274
|
+
return PasswordRegistration.of({
|
|
203
275
|
signUp: Effect.fn("auth.password.sign_up")(function* (input) {
|
|
204
276
|
yield* Effect.annotateCurrentSpan("auth.method", "password");
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
277
|
+
yield* validatePasswordSize(input.password, dependencies.passwordMaxBytes);
|
|
278
|
+
const normalized = yield* dependencies.identityKinds.normalize(input.identity);
|
|
279
|
+
if (normalized.kind === "email" && dependencies.emailAcceptancePolicy) {
|
|
280
|
+
const decision = yield* dependencies.emailAcceptancePolicy.decide({
|
|
281
|
+
email: Email(normalized.value),
|
|
282
|
+
operation: "password-sign-up",
|
|
283
|
+
metadata: input.metadata,
|
|
284
|
+
});
|
|
285
|
+
if (decision.type === "Deny") {
|
|
286
|
+
return yield* new EmailNotAcceptedError({
|
|
287
|
+
reason: "email-not-accepted",
|
|
288
|
+
});
|
|
289
|
+
}
|
|
209
290
|
}
|
|
291
|
+
yield* enforcePasswordRisk(dependencies.passwordRiskPolicy, {
|
|
292
|
+
password: input.password,
|
|
293
|
+
operation: "sign-up",
|
|
294
|
+
});
|
|
210
295
|
const now = yield* currentUnixMillis;
|
|
211
|
-
const emailVerified = input.emailVerified ?? false;
|
|
212
296
|
const userId = UserId(yield* dependencies.crypto.randomToken(userIdBytes));
|
|
297
|
+
const identityId = IdentityId(yield* dependencies.crypto.randomToken(identityIdBytes));
|
|
213
298
|
const credentialId = CredentialId(yield* dependencies.crypto.randomToken(credentialIdBytes));
|
|
214
299
|
const passwordHash = yield* dependencies.hasher.hash({
|
|
215
300
|
password: input.password,
|
|
216
301
|
});
|
|
217
|
-
yield* dependencies.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
302
|
+
const registered = yield* dependencies.registration
|
|
303
|
+
.create({
|
|
304
|
+
user: {
|
|
305
|
+
id: userId,
|
|
306
|
+
createdAt: now,
|
|
307
|
+
updatedAt: now,
|
|
308
|
+
metadata: input.metadata,
|
|
309
|
+
},
|
|
310
|
+
identity: {
|
|
311
|
+
id: identityId,
|
|
312
|
+
userId,
|
|
313
|
+
scope: normalized.scope,
|
|
314
|
+
kind: normalized.kind,
|
|
315
|
+
value: normalized.value,
|
|
316
|
+
normalizedValue: normalized.normalizedValue,
|
|
317
|
+
isPrimaryLogin: true,
|
|
318
|
+
createdAt: now,
|
|
319
|
+
},
|
|
320
|
+
passwordCredential: {
|
|
321
|
+
id: credentialId,
|
|
322
|
+
userId,
|
|
323
|
+
passwordHash,
|
|
324
|
+
createdAt: now,
|
|
325
|
+
updatedAt: now,
|
|
326
|
+
},
|
|
327
|
+
})
|
|
328
|
+
.pipe(Effect.mapError((error) => error._tag === "RegistrationConflictError" &&
|
|
329
|
+
error.reason === "identity-value"
|
|
330
|
+
? new IdentityAlreadyRegisteredError({ identity: normalized })
|
|
331
|
+
: error));
|
|
232
332
|
yield* Effect.annotateCurrentSpan("auth.result", "registered");
|
|
233
333
|
return yield* dependencies.authFlow.completePrimaryFactor({
|
|
234
334
|
userId,
|
|
235
|
-
|
|
335
|
+
identity: {
|
|
336
|
+
identityId: registered.identity.id,
|
|
337
|
+
kind: registered.identity.kind,
|
|
338
|
+
verified: false,
|
|
339
|
+
},
|
|
340
|
+
...(registered.identity.kind === "email"
|
|
341
|
+
? {
|
|
342
|
+
emailDestination: {
|
|
343
|
+
identityId: registered.identity.id,
|
|
344
|
+
email: Email(registered.identity.value),
|
|
345
|
+
},
|
|
346
|
+
}
|
|
347
|
+
: {}),
|
|
236
348
|
intent: "sign-up",
|
|
237
349
|
method: "password",
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
350
|
+
evidence: [passwordEvidence({ credentialId, verifiedAt: now })],
|
|
351
|
+
...(input.deviceKey === undefined
|
|
352
|
+
? {}
|
|
353
|
+
: { deviceKey: input.deviceKey }),
|
|
354
|
+
...(input.locationKey === undefined
|
|
355
|
+
? {}
|
|
356
|
+
: { locationKey: input.locationKey }),
|
|
241
357
|
...(input.request === undefined ? {} : { request: input.request }),
|
|
242
358
|
...(input.metadata === undefined ? {} : { metadata: input.metadata }),
|
|
243
359
|
});
|
|
@@ -245,17 +361,21 @@ export const makePasswordRegistration = (dependencies) => {
|
|
|
245
361
|
});
|
|
246
362
|
};
|
|
247
363
|
export const PasswordRegistrationLive = Layer.effect(PasswordRegistration)(Effect.gen(function* () {
|
|
248
|
-
const
|
|
249
|
-
const
|
|
364
|
+
const registration = yield* RegistrationStore;
|
|
365
|
+
const identityKinds = yield* IdentityKindRegistry;
|
|
250
366
|
const hasher = yield* PasswordHasher;
|
|
251
367
|
const authFlow = yield* AuthFlow;
|
|
252
368
|
const crypto = yield* Crypto;
|
|
369
|
+
const passwordRiskPolicy = yield* PasswordRiskPolicy;
|
|
370
|
+
const emailAcceptancePolicy = yield* EmailAcceptancePolicy;
|
|
253
371
|
return makePasswordRegistration({
|
|
254
|
-
|
|
255
|
-
|
|
372
|
+
registration,
|
|
373
|
+
identityKinds,
|
|
256
374
|
hasher,
|
|
257
375
|
authFlow,
|
|
258
376
|
crypto,
|
|
377
|
+
passwordRiskPolicy,
|
|
378
|
+
emailAcceptancePolicy,
|
|
259
379
|
});
|
|
260
380
|
}));
|
|
261
381
|
export class PasswordResetStartError extends Data.TaggedError("PasswordResetStartError") {
|
|
@@ -264,15 +384,23 @@ export class PasswordResetVerifyError extends Data.TaggedError("PasswordResetVer
|
|
|
264
384
|
}
|
|
265
385
|
export class PasswordReset extends Context.Service()("auth/password/Reset") {
|
|
266
386
|
}
|
|
267
|
-
(function (PasswordReset) {
|
|
268
|
-
PasswordReset.make = (service) => PasswordReset.of(service);
|
|
269
|
-
})(PasswordReset || (PasswordReset = {}));
|
|
270
387
|
export const defaultPasswordResetTtl = Duration.minutes(15);
|
|
271
388
|
export const defaultPasswordResetSecretBytes = 32;
|
|
272
|
-
const
|
|
389
|
+
const passwordResetBindingFromMetadata = (metadata) => {
|
|
273
390
|
const userId = metadata?.userId;
|
|
274
|
-
|
|
275
|
-
|
|
391
|
+
const identityId = metadata?.identityId;
|
|
392
|
+
const normalizedValue = metadata?.normalizedValue;
|
|
393
|
+
return typeof userId === "string" &&
|
|
394
|
+
userId.length > 0 &&
|
|
395
|
+
typeof identityId === "string" &&
|
|
396
|
+
identityId.length > 0 &&
|
|
397
|
+
typeof normalizedValue === "string" &&
|
|
398
|
+
normalizedValue.length > 0
|
|
399
|
+
? {
|
|
400
|
+
userId: UserId(userId),
|
|
401
|
+
identityId: IdentityId(identityId),
|
|
402
|
+
normalizedValue,
|
|
403
|
+
}
|
|
276
404
|
: undefined;
|
|
277
405
|
};
|
|
278
406
|
const passwordResetTtlMillis = (ttl) => {
|
|
@@ -307,22 +435,45 @@ export const makePasswordReset = (dependencies) => {
|
|
|
307
435
|
const ttl = dependencies.ttl ?? defaultPasswordResetTtl;
|
|
308
436
|
const secretBytes = dependencies.secretBytes ?? defaultPasswordResetSecretBytes;
|
|
309
437
|
const credentialIdBytes = dependencies.credentialIdBytes ?? 16;
|
|
310
|
-
return PasswordReset.
|
|
438
|
+
return PasswordReset.of({
|
|
311
439
|
start: Effect.fn("auth.password_reset.start")(function* (input) {
|
|
312
440
|
yield* Effect.annotateCurrentSpan("auth.method", "password-reset");
|
|
313
441
|
const resolvedTtl = input.ttl ?? ttl;
|
|
314
442
|
const expiresIn = yield* passwordResetTtlMillis(resolvedTtl);
|
|
315
443
|
const now = yield* currentUnixMillis;
|
|
444
|
+
const normalized = yield* dependencies.identityKinds
|
|
445
|
+
.normalize(input.identity)
|
|
446
|
+
.pipe(Effect.mapError((cause) => new PasswordResetStartError({
|
|
447
|
+
message: "Invalid password reset identity",
|
|
448
|
+
cause,
|
|
449
|
+
})));
|
|
450
|
+
if (normalized.kind !== "email" || normalized.scope.type !== "global") {
|
|
451
|
+
return yield* new PasswordResetStartError({
|
|
452
|
+
message: "Password reset requires a global email identity",
|
|
453
|
+
});
|
|
454
|
+
}
|
|
316
455
|
const genericStarted = {
|
|
317
|
-
email:
|
|
456
|
+
email: Email(normalized.value),
|
|
318
457
|
expiresAt: addMillis(now, expiresIn),
|
|
319
458
|
};
|
|
320
|
-
const
|
|
459
|
+
const identityOption = yield* dependencies.identities
|
|
460
|
+
.findByKindAndNormalizedValue(normalized)
|
|
461
|
+
.pipe(Effect.mapError((cause) => new PasswordResetStartError({
|
|
462
|
+
message: "Failed to load identity for password reset",
|
|
463
|
+
cause,
|
|
464
|
+
})));
|
|
465
|
+
if (Option.isNone(identityOption)) {
|
|
466
|
+
yield* Effect.annotateCurrentSpan("auth.result", "PasswordResetIgnored");
|
|
467
|
+
return genericStarted;
|
|
468
|
+
}
|
|
469
|
+
const identity = identityOption.value;
|
|
470
|
+
const userOption = yield* dependencies.users
|
|
471
|
+
.findById(identity.userId)
|
|
472
|
+
.pipe(Effect.mapError((cause) => new PasswordResetStartError({
|
|
321
473
|
message: "Failed to load user for password reset",
|
|
322
474
|
cause,
|
|
323
475
|
})));
|
|
324
476
|
if (Option.isNone(userOption)) {
|
|
325
|
-
yield* Effect.annotateCurrentSpan("auth.result", "PasswordResetIgnored");
|
|
326
477
|
return genericStarted;
|
|
327
478
|
}
|
|
328
479
|
const user = userOption.value;
|
|
@@ -345,12 +496,14 @@ export const makePasswordReset = (dependencies) => {
|
|
|
345
496
|
const issued = yield* dependencies.challenge
|
|
346
497
|
.issue({
|
|
347
498
|
type: "reset-password",
|
|
348
|
-
subject:
|
|
499
|
+
subject: identity.value,
|
|
349
500
|
ttl: resolvedTtl,
|
|
350
501
|
secret,
|
|
351
502
|
metadata: {
|
|
352
503
|
...input.metadata,
|
|
353
504
|
userId: user.id,
|
|
505
|
+
identityId: identity.id,
|
|
506
|
+
normalizedValue: identity.normalizedValue,
|
|
354
507
|
},
|
|
355
508
|
})
|
|
356
509
|
.pipe(Effect.mapError((cause) => new PasswordResetStartError({
|
|
@@ -358,7 +511,7 @@ export const makePasswordReset = (dependencies) => {
|
|
|
358
511
|
cause,
|
|
359
512
|
})));
|
|
360
513
|
const started = {
|
|
361
|
-
email:
|
|
514
|
+
email: Email(identity.value),
|
|
362
515
|
expiresAt: issued.expiresAt,
|
|
363
516
|
};
|
|
364
517
|
const url = yield* makePasswordResetUrl(dependencies, {
|
|
@@ -374,7 +527,7 @@ export const makePasswordReset = (dependencies) => {
|
|
|
374
527
|
yield* dependencies.authMailer
|
|
375
528
|
.send({
|
|
376
529
|
_tag: "PasswordReset",
|
|
377
|
-
to:
|
|
530
|
+
to: Email(identity.value),
|
|
378
531
|
challengeId: issued.id,
|
|
379
532
|
url,
|
|
380
533
|
expiresAt: issued.expiresAt,
|
|
@@ -393,6 +546,10 @@ export const makePasswordReset = (dependencies) => {
|
|
|
393
546
|
}),
|
|
394
547
|
verify: Effect.fn("auth.password_reset.verify")(function* (input) {
|
|
395
548
|
yield* Effect.annotateCurrentSpan("auth.method", "password-reset");
|
|
549
|
+
yield* validatePasswordSize(input.password, dependencies.passwordMaxBytes).pipe(Effect.mapError((cause) => new PasswordResetVerifyError({
|
|
550
|
+
message: "Password does not meet policy requirements",
|
|
551
|
+
cause,
|
|
552
|
+
})));
|
|
396
553
|
const verified = yield* dependencies.challenge
|
|
397
554
|
.verify({
|
|
398
555
|
challengeId: input.challengeId,
|
|
@@ -403,25 +560,39 @@ export const makePasswordReset = (dependencies) => {
|
|
|
403
560
|
message: "Invalid password reset challenge",
|
|
404
561
|
cause,
|
|
405
562
|
})));
|
|
406
|
-
const
|
|
407
|
-
if (
|
|
563
|
+
const binding = passwordResetBindingFromMetadata(verified.metadata);
|
|
564
|
+
if (binding === undefined) {
|
|
408
565
|
return yield* new PasswordResetVerifyError({
|
|
409
566
|
message: "Password reset challenge is missing user metadata",
|
|
410
567
|
});
|
|
411
568
|
}
|
|
412
|
-
const
|
|
569
|
+
const identityOption = yield* dependencies.identities
|
|
570
|
+
.findById(binding.identityId)
|
|
571
|
+
.pipe(Effect.mapError((cause) => new PasswordResetVerifyError({
|
|
572
|
+
message: "Failed to load identity for password reset",
|
|
573
|
+
cause,
|
|
574
|
+
})));
|
|
575
|
+
const userOption = yield* dependencies.users
|
|
576
|
+
.findById(binding.userId)
|
|
577
|
+
.pipe(Effect.mapError((cause) => new PasswordResetVerifyError({
|
|
413
578
|
message: "Failed to load user for password reset",
|
|
414
579
|
cause,
|
|
415
580
|
})));
|
|
416
|
-
if (Option.isNone(
|
|
417
|
-
|
|
418
|
-
|
|
581
|
+
if (Option.isNone(identityOption) ||
|
|
582
|
+
identityOption.value.revokedAt !== undefined ||
|
|
583
|
+
identityOption.value.userId !== binding.userId ||
|
|
584
|
+
identityOption.value.kind !== "email" ||
|
|
585
|
+
identityOption.value.scope.type !== "global" ||
|
|
586
|
+
identityOption.value.normalizedValue !== binding.normalizedValue ||
|
|
587
|
+
identityOption.value.value !== verified.subject ||
|
|
588
|
+
Option.isNone(userOption) ||
|
|
589
|
+
userOption.value.disabledAt !== undefined) {
|
|
419
590
|
return yield* new PasswordResetVerifyError({
|
|
420
591
|
message: "Invalid password reset challenge",
|
|
421
592
|
});
|
|
422
593
|
}
|
|
423
594
|
const credentialOption = yield* dependencies.credentials
|
|
424
|
-
.findPasswordByUserId(userId)
|
|
595
|
+
.findPasswordByUserId(binding.userId)
|
|
425
596
|
.pipe(Effect.mapError((cause) => new PasswordResetVerifyError({
|
|
426
597
|
message: "Failed to load password credential for reset",
|
|
427
598
|
cause,
|
|
@@ -432,6 +603,14 @@ export const makePasswordReset = (dependencies) => {
|
|
|
432
603
|
message: "Password credential not found",
|
|
433
604
|
});
|
|
434
605
|
}
|
|
606
|
+
yield* enforcePasswordRisk(dependencies.passwordRiskPolicy, {
|
|
607
|
+
password: input.password,
|
|
608
|
+
operation: "reset",
|
|
609
|
+
}).pipe(Effect.mapError((cause) => new PasswordResetVerifyError({
|
|
610
|
+
message: "Password does not meet policy requirements",
|
|
611
|
+
cause,
|
|
612
|
+
})));
|
|
613
|
+
const { userId } = binding;
|
|
435
614
|
const now = yield* currentUnixMillis;
|
|
436
615
|
const passwordHash = yield* dependencies.hasher
|
|
437
616
|
.hash({ password: input.password })
|
|
@@ -491,25 +670,31 @@ export const makePasswordReset = (dependencies) => {
|
|
|
491
670
|
export const PasswordResetLive = (options) => Layer.effect(PasswordReset)(Effect.gen(function* () {
|
|
492
671
|
const challenge = yield* Challenge;
|
|
493
672
|
const users = yield* UserStore;
|
|
673
|
+
const identities = yield* IdentityStore;
|
|
674
|
+
const identityKinds = yield* IdentityKindRegistry;
|
|
494
675
|
const credentials = yield* CredentialStore;
|
|
495
676
|
const hasher = yield* PasswordHasher;
|
|
496
677
|
const crypto = yield* Crypto;
|
|
497
678
|
const authMailer = yield* AuthMailer;
|
|
498
679
|
const sessionStore = yield* SessionStore;
|
|
680
|
+
const passwordRiskPolicy = yield* PasswordRiskPolicy;
|
|
499
681
|
return makePasswordReset({
|
|
500
682
|
...options,
|
|
501
683
|
challenge,
|
|
502
684
|
users,
|
|
685
|
+
identities,
|
|
686
|
+
identityKinds,
|
|
503
687
|
credentials,
|
|
504
688
|
hasher,
|
|
505
689
|
crypto,
|
|
506
690
|
authMailer,
|
|
507
691
|
sessionStore,
|
|
692
|
+
passwordRiskPolicy,
|
|
508
693
|
});
|
|
509
694
|
}));
|
|
510
|
-
export const
|
|
695
|
+
export const PasswordResetDefaultLive = (options, passwordRiskPolicy = PasswordRiskPolicyNoopLive) => {
|
|
511
696
|
const { passwordHasher, ...resetOptions } = options;
|
|
512
|
-
return PasswordResetLive(resetOptions).pipe(Layer.provideMerge(Pbkdf2PasswordHasherLive(passwordHasher)));
|
|
697
|
+
return PasswordResetLive(resetOptions).pipe(Layer.provideMerge(Pbkdf2PasswordHasherLive(passwordHasher)), Layer.provideMerge(passwordRiskPolicy));
|
|
513
698
|
};
|
|
514
699
|
export class PasswordSetError extends Data.TaggedError("PasswordSetError") {
|
|
515
700
|
}
|
|
@@ -517,13 +702,15 @@ export class PasswordChangeError extends Data.TaggedError("PasswordChangeError")
|
|
|
517
702
|
}
|
|
518
703
|
export class PasswordManagement extends Context.Service()("auth/password/Management") {
|
|
519
704
|
}
|
|
520
|
-
(function (PasswordManagement) {
|
|
521
|
-
PasswordManagement.make = (service) => PasswordManagement.of(service);
|
|
522
|
-
})(PasswordManagement || (PasswordManagement = {}));
|
|
523
705
|
export const makePasswordManagement = (dependencies) => {
|
|
524
706
|
const credentialIdBytes = dependencies.credentialIdBytes ?? 16;
|
|
525
|
-
return PasswordManagement.
|
|
707
|
+
return PasswordManagement.of({
|
|
526
708
|
set: Effect.fn("auth.password.set")(function* (input) {
|
|
709
|
+
yield* validatePasswordSize(input.password, dependencies.passwordMaxBytes).pipe(Effect.mapError((cause) => new PasswordSetError({
|
|
710
|
+
reason: "password_policy_rejected",
|
|
711
|
+
message: "Password does not meet policy requirements",
|
|
712
|
+
cause,
|
|
713
|
+
})));
|
|
527
714
|
const credential = yield* dependencies.credentials
|
|
528
715
|
.findPasswordByUserId(input.userId)
|
|
529
716
|
.pipe(Effect.mapError((cause) => new PasswordSetError({
|
|
@@ -539,6 +726,14 @@ export const makePasswordManagement = (dependencies) => {
|
|
|
539
726
|
message: "Password credential already exists",
|
|
540
727
|
});
|
|
541
728
|
}
|
|
729
|
+
yield* enforcePasswordRisk(dependencies.passwordRiskPolicy, {
|
|
730
|
+
password: input.password,
|
|
731
|
+
operation: "set",
|
|
732
|
+
}).pipe(Effect.mapError((cause) => new PasswordSetError({
|
|
733
|
+
reason: "password_policy_rejected",
|
|
734
|
+
message: "Password does not meet policy requirements",
|
|
735
|
+
cause,
|
|
736
|
+
})));
|
|
542
737
|
const now = yield* currentUnixMillis;
|
|
543
738
|
const credentialId = CredentialId(yield* dependencies.crypto.randomToken(credentialIdBytes).pipe(Effect.mapError((cause) => new PasswordSetError({
|
|
544
739
|
reason: "internal",
|
|
@@ -568,6 +763,11 @@ export const makePasswordManagement = (dependencies) => {
|
|
|
568
763
|
})));
|
|
569
764
|
}),
|
|
570
765
|
change: Effect.fn("auth.password.change")(function* (input) {
|
|
766
|
+
yield* validatePasswordSize(input.newPassword, dependencies.passwordMaxBytes).pipe(Effect.mapError((cause) => new PasswordChangeError({
|
|
767
|
+
reason: "password_policy_rejected",
|
|
768
|
+
message: "Password does not meet policy requirements",
|
|
769
|
+
cause,
|
|
770
|
+
})));
|
|
571
771
|
const credential = yield* dependencies.credentials
|
|
572
772
|
.findPasswordByUserId(input.userId)
|
|
573
773
|
.pipe(Effect.mapError((cause) => new PasswordChangeError({
|
|
@@ -603,6 +803,14 @@ export const makePasswordManagement = (dependencies) => {
|
|
|
603
803
|
message: "Current password is invalid",
|
|
604
804
|
});
|
|
605
805
|
}
|
|
806
|
+
yield* enforcePasswordRisk(dependencies.passwordRiskPolicy, {
|
|
807
|
+
password: input.newPassword,
|
|
808
|
+
operation: "change",
|
|
809
|
+
}).pipe(Effect.mapError((cause) => new PasswordChangeError({
|
|
810
|
+
reason: "password_policy_rejected",
|
|
811
|
+
message: "Password does not meet policy requirements",
|
|
812
|
+
cause,
|
|
813
|
+
})));
|
|
606
814
|
const now = yield* currentUnixMillis;
|
|
607
815
|
const passwordHash = yield* dependencies.hasher
|
|
608
816
|
.hash({ password: input.newPassword })
|
|
@@ -635,7 +843,13 @@ export const PasswordManagementLive = Layer.effect(PasswordManagement)(Effect.ge
|
|
|
635
843
|
const credentials = yield* CredentialStore;
|
|
636
844
|
const hasher = yield* PasswordHasher;
|
|
637
845
|
const crypto = yield* Crypto;
|
|
638
|
-
|
|
846
|
+
const passwordRiskPolicy = yield* PasswordRiskPolicy;
|
|
847
|
+
return makePasswordManagement({
|
|
848
|
+
credentials,
|
|
849
|
+
hasher,
|
|
850
|
+
crypto,
|
|
851
|
+
passwordRiskPolicy,
|
|
852
|
+
});
|
|
639
853
|
}));
|
|
640
|
-
export const
|
|
854
|
+
export const PasswordDefaultLive = (options, passwordRiskPolicy = PasswordRiskPolicyNoopLive, emailAcceptancePolicy = EmailAcceptancePolicyNoopLive) => Layer.mergeAll(PasswordPrimaryFactorLive, PasswordLoginLive, PasswordRegistrationLive, PasswordManagementLive).pipe(Layer.provideMerge(Pbkdf2PasswordHasherLive(options)), Layer.provideMerge(passwordRiskPolicy), Layer.provideMerge(emailAcceptancePolicy));
|
|
641
855
|
//# sourceMappingURL=Password.js.map
|