@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/AuditLog.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Context, Data, Effect, Layer } from "effect";
|
|
2
|
-
import {
|
|
1
|
+
import { Context, Data, Effect, Layer, Option, Ref, Schema } from "effect";
|
|
2
|
+
import { AuditEventIdSchema, ChallengeIdSchema, CredentialIdSchema, EmailHashSchema, IdentityIdSchema, IpHashSchema, OAuthAccountIdSchema, OAuthProviderIdSchema, PermissionIdSchema, PolicyIdSchema, RoleIdSchema, SessionIdSchema, UnixMillisSchema, UserAgentHashSchema, UserIdSchema, } from "./Identifiers.js";
|
|
3
|
+
import { compareUtf8Bytes, currentUnixMillis } from "./Internal.js";
|
|
4
|
+
import { WaitUntil } from "./WaitUntil.js";
|
|
3
5
|
export class AuditLogError extends Data.TaggedError("AuditLogError") {
|
|
4
6
|
}
|
|
5
7
|
export class AuditLogStoreError extends Data.TaggedError("AuditLogStoreError") {
|
|
@@ -11,45 +13,485 @@ export const AuditActor = {
|
|
|
11
13
|
userId: input.userId,
|
|
12
14
|
...(input.sessionId === undefined ? {} : { sessionId: input.sessionId }),
|
|
13
15
|
}),
|
|
16
|
+
custom: (input) => ({
|
|
17
|
+
type: "custom",
|
|
18
|
+
actorType: input.actorType,
|
|
19
|
+
...(input.actorReference === undefined
|
|
20
|
+
? {}
|
|
21
|
+
: { actorReference: input.actorReference }),
|
|
22
|
+
}),
|
|
14
23
|
};
|
|
24
|
+
export const AuditActorSchema = Schema.Union([
|
|
25
|
+
Schema.Struct({ type: Schema.Literal("anonymous") }),
|
|
26
|
+
Schema.Struct({
|
|
27
|
+
type: Schema.Literal("user"),
|
|
28
|
+
userId: UserIdSchema,
|
|
29
|
+
sessionId: Schema.optional(SessionIdSchema),
|
|
30
|
+
}),
|
|
31
|
+
Schema.Struct({
|
|
32
|
+
type: Schema.Literal("custom"),
|
|
33
|
+
actorType: Schema.String,
|
|
34
|
+
actorReference: Schema.optional(Schema.String),
|
|
35
|
+
}),
|
|
36
|
+
]);
|
|
15
37
|
export const AuditSubject = {
|
|
16
38
|
anonymous: () => ({ type: "anonymous" }),
|
|
17
39
|
email: (emailHash) => ({ type: "email", emailHash }),
|
|
18
40
|
user: (userId) => ({ type: "user", userId }),
|
|
19
41
|
};
|
|
42
|
+
export const AuditSubjectSchema = Schema.Union([
|
|
43
|
+
Schema.Struct({ type: Schema.Literal("anonymous") }),
|
|
44
|
+
Schema.Struct({ type: Schema.Literal("email"), emailHash: EmailHashSchema }),
|
|
45
|
+
Schema.Struct({ type: Schema.Literal("user"), userId: UserIdSchema }),
|
|
46
|
+
]);
|
|
47
|
+
export const AuditRequestSchema = Schema.Struct({
|
|
48
|
+
ipHash: Schema.optional(IpHashSchema),
|
|
49
|
+
userAgentHash: Schema.optional(UserAgentHashSchema),
|
|
50
|
+
});
|
|
51
|
+
const AuditEventBaseSchema = {
|
|
52
|
+
id: Schema.optional(AuditEventIdSchema),
|
|
53
|
+
request: Schema.optional(AuditRequestSchema),
|
|
54
|
+
occurredAt: UnixMillisSchema,
|
|
55
|
+
};
|
|
56
|
+
const ActorAuditEventBaseSchema = {
|
|
57
|
+
...AuditEventBaseSchema,
|
|
58
|
+
actor: AuditActorSchema,
|
|
59
|
+
};
|
|
60
|
+
const AuthorizationAuditSubjectSchema = Schema.Union([
|
|
61
|
+
Schema.Struct({ type: Schema.Literal("user"), userId: UserIdSchema }),
|
|
62
|
+
Schema.Struct({
|
|
63
|
+
type: Schema.Literal("custom"),
|
|
64
|
+
subjectType: Schema.String,
|
|
65
|
+
subjectReference: Schema.optional(Schema.String),
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
68
|
+
const AuthorizationAuditScopeSchema = Schema.Struct({
|
|
69
|
+
type: Schema.String,
|
|
70
|
+
reference: Schema.optional(Schema.String),
|
|
71
|
+
});
|
|
72
|
+
const IdentityScopeSchema = Schema.Union([
|
|
73
|
+
Schema.Struct({ type: Schema.Literal("global") }),
|
|
74
|
+
Schema.Struct({ type: Schema.Literal("tenant"), tenantId: Schema.String }),
|
|
75
|
+
]);
|
|
76
|
+
const ApiKeyIdSchema = Schema.String.pipe(Schema.brand("auth/ApiKeyId"));
|
|
77
|
+
const PasskeyCredentialIdSchema = Schema.String.pipe(Schema.brand("auth/PasskeyCredentialId"));
|
|
78
|
+
const RefreshTokenIdSchema = Schema.String.pipe(Schema.brand("auth/RefreshTokenId"));
|
|
79
|
+
const RefreshTokenFamilyIdSchema = Schema.String.pipe(Schema.brand("auth/RefreshTokenFamilyId"));
|
|
80
|
+
const AssuranceTransitionSchema = {
|
|
81
|
+
...ActorAuditEventBaseSchema,
|
|
82
|
+
type: Schema.Literals([
|
|
83
|
+
"auth.session.assurance_changed",
|
|
84
|
+
"auth.session.step_up_completed",
|
|
85
|
+
"auth.session.primary_reauthenticated",
|
|
86
|
+
"auth.session.recovery_remediation.entered",
|
|
87
|
+
"auth.session.recovery_remediation.completed",
|
|
88
|
+
]),
|
|
89
|
+
userId: UserIdSchema,
|
|
90
|
+
sessionId: SessionIdSchema,
|
|
91
|
+
oldAal: Schema.Literals(["aal1", "aal2", "aal3"]),
|
|
92
|
+
newAal: Schema.Literals(["aal1", "aal2", "aal3"]),
|
|
93
|
+
amr: Schema.Array(Schema.String),
|
|
94
|
+
method: Schema.String,
|
|
95
|
+
rotatedAt: UnixMillisSchema,
|
|
96
|
+
requirementsEntered: Schema.Array(Schema.String),
|
|
97
|
+
requirementsCleared: Schema.Array(Schema.String),
|
|
98
|
+
};
|
|
99
|
+
const LoginRiskAssessmentSchema = Schema.Struct({
|
|
100
|
+
userId: UserIdSchema,
|
|
101
|
+
method: Schema.String,
|
|
102
|
+
amr: Schema.Array(Schema.String),
|
|
103
|
+
aal: Schema.Literals(["aal1", "aal2", "aal3"]),
|
|
104
|
+
device: Schema.Struct({
|
|
105
|
+
status: Schema.Literals(["known", "new", "unknown"]),
|
|
106
|
+
}),
|
|
107
|
+
risk: Schema.Struct({
|
|
108
|
+
level: Schema.Literals(["unknown", "low", "medium", "high", "critical"]),
|
|
109
|
+
signals: Schema.Array(Schema.Struct({
|
|
110
|
+
type: Schema.String,
|
|
111
|
+
level: Schema.optional(Schema.Literals(["unknown", "low", "medium", "high", "critical"])),
|
|
112
|
+
})),
|
|
113
|
+
}),
|
|
114
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
115
|
+
});
|
|
116
|
+
const IncidentActionResultSchema = Schema.Struct({
|
|
117
|
+
userId: UserIdSchema,
|
|
118
|
+
reason: Schema.optional(Schema.String),
|
|
119
|
+
sessions: Schema.optional(Schema.Struct({
|
|
120
|
+
revokedAll: Schema.Literal(true),
|
|
121
|
+
activeBefore: Schema.Number,
|
|
122
|
+
sessionIds: Schema.Array(SessionIdSchema),
|
|
123
|
+
})),
|
|
124
|
+
trustedDevices: Schema.optional(Schema.Struct({
|
|
125
|
+
revoked: Schema.Number,
|
|
126
|
+
deviceIds: Schema.Array(Schema.String),
|
|
127
|
+
})),
|
|
128
|
+
apiKeys: Schema.optional(Schema.Struct({
|
|
129
|
+
revoked: Schema.Number,
|
|
130
|
+
keyIds: Schema.Array(ApiKeyIdSchema),
|
|
131
|
+
})),
|
|
132
|
+
refreshTokens: Schema.optional(Schema.Struct({
|
|
133
|
+
revokedFamilies: Schema.Number,
|
|
134
|
+
activeBefore: Schema.Number,
|
|
135
|
+
tokenIds: Schema.Array(RefreshTokenIdSchema),
|
|
136
|
+
familyIds: Schema.Array(RefreshTokenFamilyIdSchema),
|
|
137
|
+
})),
|
|
138
|
+
});
|
|
139
|
+
export const AuthAuditEventSchema = Schema.Union([
|
|
140
|
+
Schema.Struct(AssuranceTransitionSchema),
|
|
141
|
+
Schema.Struct({
|
|
142
|
+
...ActorAuditEventBaseSchema,
|
|
143
|
+
type: Schema.Literal("auth.permission_definition.created"),
|
|
144
|
+
permissionId: PermissionIdSchema,
|
|
145
|
+
scopeType: Schema.optional(Schema.String),
|
|
146
|
+
}),
|
|
147
|
+
Schema.Struct({
|
|
148
|
+
...ActorAuditEventBaseSchema,
|
|
149
|
+
type: Schema.Literal("auth.permission_definition.updated"),
|
|
150
|
+
permissionId: PermissionIdSchema,
|
|
151
|
+
scopeType: Schema.optional(Schema.String),
|
|
152
|
+
changedFields: Schema.Array(Schema.Literals(["description", "scopeType"])),
|
|
153
|
+
}),
|
|
154
|
+
Schema.Struct({
|
|
155
|
+
...ActorAuditEventBaseSchema,
|
|
156
|
+
type: Schema.Literals([
|
|
157
|
+
"auth.permission_definition.disabled",
|
|
158
|
+
"auth.permission_definition.enabled",
|
|
159
|
+
"auth.permission_definition.deleted",
|
|
160
|
+
]),
|
|
161
|
+
permissionId: PermissionIdSchema,
|
|
162
|
+
scopeType: Schema.optional(Schema.String),
|
|
163
|
+
}),
|
|
164
|
+
Schema.Struct({
|
|
165
|
+
...ActorAuditEventBaseSchema,
|
|
166
|
+
type: Schema.Literal("auth.role_definition.created"),
|
|
167
|
+
roleId: RoleIdSchema,
|
|
168
|
+
}),
|
|
169
|
+
Schema.Struct({
|
|
170
|
+
...ActorAuditEventBaseSchema,
|
|
171
|
+
type: Schema.Literal("auth.role_definition.updated"),
|
|
172
|
+
roleId: RoleIdSchema,
|
|
173
|
+
changedFields: Schema.Array(Schema.Literal("description")),
|
|
174
|
+
}),
|
|
175
|
+
Schema.Struct({
|
|
176
|
+
...ActorAuditEventBaseSchema,
|
|
177
|
+
type: Schema.Literals([
|
|
178
|
+
"auth.role_definition.disabled",
|
|
179
|
+
"auth.role_definition.enabled",
|
|
180
|
+
"auth.role_definition.deleted",
|
|
181
|
+
]),
|
|
182
|
+
roleId: RoleIdSchema,
|
|
183
|
+
}),
|
|
184
|
+
Schema.Struct({
|
|
185
|
+
...ActorAuditEventBaseSchema,
|
|
186
|
+
type: Schema.Literal("auth.permission.granted"),
|
|
187
|
+
subject: AuthorizationAuditSubjectSchema,
|
|
188
|
+
permissionId: PermissionIdSchema,
|
|
189
|
+
scope: Schema.optional(AuthorizationAuditScopeSchema),
|
|
190
|
+
expiresAt: Schema.optional(UnixMillisSchema),
|
|
191
|
+
}),
|
|
192
|
+
Schema.Struct({
|
|
193
|
+
...ActorAuditEventBaseSchema,
|
|
194
|
+
type: Schema.Literal("auth.permission.revoked"),
|
|
195
|
+
subject: AuthorizationAuditSubjectSchema,
|
|
196
|
+
permissionId: PermissionIdSchema,
|
|
197
|
+
scope: Schema.optional(AuthorizationAuditScopeSchema),
|
|
198
|
+
}),
|
|
199
|
+
Schema.Struct({
|
|
200
|
+
...ActorAuditEventBaseSchema,
|
|
201
|
+
type: Schema.Literal("auth.role.granted"),
|
|
202
|
+
subject: AuthorizationAuditSubjectSchema,
|
|
203
|
+
roleId: RoleIdSchema,
|
|
204
|
+
scope: Schema.optional(AuthorizationAuditScopeSchema),
|
|
205
|
+
expiresAt: Schema.optional(UnixMillisSchema),
|
|
206
|
+
}),
|
|
207
|
+
Schema.Struct({
|
|
208
|
+
...ActorAuditEventBaseSchema,
|
|
209
|
+
type: Schema.Literal("auth.role.revoked"),
|
|
210
|
+
subject: AuthorizationAuditSubjectSchema,
|
|
211
|
+
roleId: RoleIdSchema,
|
|
212
|
+
scope: Schema.optional(AuthorizationAuditScopeSchema),
|
|
213
|
+
}),
|
|
214
|
+
Schema.Struct({
|
|
215
|
+
...ActorAuditEventBaseSchema,
|
|
216
|
+
type: Schema.Literals([
|
|
217
|
+
"auth.role_permission.assigned",
|
|
218
|
+
"auth.role_permission.removed",
|
|
219
|
+
]),
|
|
220
|
+
roleId: RoleIdSchema,
|
|
221
|
+
permissionId: PermissionIdSchema,
|
|
222
|
+
scopeType: Schema.optional(Schema.String),
|
|
223
|
+
}),
|
|
224
|
+
Schema.Struct({
|
|
225
|
+
...ActorAuditEventBaseSchema,
|
|
226
|
+
type: Schema.Literals([
|
|
227
|
+
"auth.identity.added",
|
|
228
|
+
"auth.identity.primary_changed",
|
|
229
|
+
]),
|
|
230
|
+
userId: UserIdSchema,
|
|
231
|
+
identityId: IdentityIdSchema,
|
|
232
|
+
kind: Schema.String,
|
|
233
|
+
scope: IdentityScopeSchema,
|
|
234
|
+
}),
|
|
235
|
+
Schema.Struct({
|
|
236
|
+
...ActorAuditEventBaseSchema,
|
|
237
|
+
type: Schema.Literal("auth.identity.replaced"),
|
|
238
|
+
userId: UserIdSchema,
|
|
239
|
+
identityId: IdentityIdSchema,
|
|
240
|
+
replacementIdentityId: IdentityIdSchema,
|
|
241
|
+
kind: Schema.String,
|
|
242
|
+
scope: IdentityScopeSchema,
|
|
243
|
+
}),
|
|
244
|
+
Schema.Struct({
|
|
245
|
+
...ActorAuditEventBaseSchema,
|
|
246
|
+
type: Schema.Literal("auth.identity.revoked"),
|
|
247
|
+
userId: UserIdSchema,
|
|
248
|
+
identityId: IdentityIdSchema,
|
|
249
|
+
kind: Schema.String,
|
|
250
|
+
scope: IdentityScopeSchema,
|
|
251
|
+
reason: Schema.optional(Schema.String),
|
|
252
|
+
}),
|
|
253
|
+
Schema.Struct({
|
|
254
|
+
...ActorAuditEventBaseSchema,
|
|
255
|
+
type: Schema.Literal("auth.login.succeeded"),
|
|
256
|
+
method: Schema.String,
|
|
257
|
+
}),
|
|
258
|
+
Schema.Struct({
|
|
259
|
+
...AuditEventBaseSchema,
|
|
260
|
+
type: Schema.Literal("auth.login.failed"),
|
|
261
|
+
subject: AuditSubjectSchema,
|
|
262
|
+
method: Schema.String,
|
|
263
|
+
reason: Schema.String,
|
|
264
|
+
}),
|
|
265
|
+
Schema.Struct({
|
|
266
|
+
...ActorAuditEventBaseSchema,
|
|
267
|
+
type: Schema.Literal("auth.session.revoked"),
|
|
268
|
+
sessionId: SessionIdSchema,
|
|
269
|
+
reason: Schema.String,
|
|
270
|
+
}),
|
|
271
|
+
Schema.Struct({
|
|
272
|
+
...ActorAuditEventBaseSchema,
|
|
273
|
+
type: Schema.Literal("auth.risk.assessed"),
|
|
274
|
+
assessment: LoginRiskAssessmentSchema,
|
|
275
|
+
}),
|
|
276
|
+
Schema.Struct({
|
|
277
|
+
...ActorAuditEventBaseSchema,
|
|
278
|
+
type: Schema.Literal("auth.policy.denied"),
|
|
279
|
+
policyId: PolicyIdSchema,
|
|
280
|
+
reason: Schema.String,
|
|
281
|
+
}),
|
|
282
|
+
Schema.Struct({
|
|
283
|
+
...ActorAuditEventBaseSchema,
|
|
284
|
+
type: Schema.Literals([
|
|
285
|
+
"auth.oauth.account.linked",
|
|
286
|
+
"auth.oauth.account.unlinked",
|
|
287
|
+
]),
|
|
288
|
+
userId: UserIdSchema,
|
|
289
|
+
accountId: OAuthAccountIdSchema,
|
|
290
|
+
providerId: OAuthProviderIdSchema,
|
|
291
|
+
providerAccountId: Schema.String,
|
|
292
|
+
reason: Schema.String,
|
|
293
|
+
}),
|
|
294
|
+
Schema.Struct({
|
|
295
|
+
...ActorAuditEventBaseSchema,
|
|
296
|
+
type: Schema.Literals([
|
|
297
|
+
"auth.oauth.link_confirmation.started",
|
|
298
|
+
"auth.oauth.link_confirmation.confirmed",
|
|
299
|
+
]),
|
|
300
|
+
userId: UserIdSchema,
|
|
301
|
+
challengeId: ChallengeIdSchema,
|
|
302
|
+
providerId: OAuthProviderIdSchema,
|
|
303
|
+
providerAccountId: Schema.String,
|
|
304
|
+
reason: Schema.String,
|
|
305
|
+
}),
|
|
306
|
+
Schema.Struct({
|
|
307
|
+
...ActorAuditEventBaseSchema,
|
|
308
|
+
type: Schema.Literal("auth.oauth.provider_token.refreshed"),
|
|
309
|
+
userId: UserIdSchema,
|
|
310
|
+
accountId: OAuthAccountIdSchema,
|
|
311
|
+
providerId: OAuthProviderIdSchema,
|
|
312
|
+
providerAccountId: Schema.String,
|
|
313
|
+
}),
|
|
314
|
+
Schema.Struct({
|
|
315
|
+
...ActorAuditEventBaseSchema,
|
|
316
|
+
type: Schema.Literal("auth.oauth.provider_token.revoked"),
|
|
317
|
+
userId: UserIdSchema,
|
|
318
|
+
accountId: OAuthAccountIdSchema,
|
|
319
|
+
providerId: OAuthProviderIdSchema,
|
|
320
|
+
providerAccountId: Schema.String,
|
|
321
|
+
reason: Schema.String,
|
|
322
|
+
}),
|
|
323
|
+
Schema.Struct({
|
|
324
|
+
...ActorAuditEventBaseSchema,
|
|
325
|
+
type: Schema.Literal("auth.passkey.credential.revoked"),
|
|
326
|
+
userId: UserIdSchema,
|
|
327
|
+
credentialId: PasskeyCredentialIdSchema,
|
|
328
|
+
reason: Schema.String,
|
|
329
|
+
}),
|
|
330
|
+
Schema.Struct({
|
|
331
|
+
...ActorAuditEventBaseSchema,
|
|
332
|
+
type: Schema.Literals([
|
|
333
|
+
"auth.totp.enrollment.started",
|
|
334
|
+
"auth.totp.factor.confirmed",
|
|
335
|
+
"auth.totp.factor.verified",
|
|
336
|
+
]),
|
|
337
|
+
userId: UserIdSchema,
|
|
338
|
+
factorId: CredentialIdSchema,
|
|
339
|
+
}),
|
|
340
|
+
Schema.Struct({
|
|
341
|
+
...ActorAuditEventBaseSchema,
|
|
342
|
+
type: Schema.Literal("auth.totp.factor.revoked"),
|
|
343
|
+
userId: UserIdSchema,
|
|
344
|
+
factorId: CredentialIdSchema,
|
|
345
|
+
reason: Schema.String,
|
|
346
|
+
}),
|
|
347
|
+
Schema.Struct({
|
|
348
|
+
...ActorAuditEventBaseSchema,
|
|
349
|
+
type: Schema.Literal("auth.recovery_code.generated"),
|
|
350
|
+
userId: UserIdSchema,
|
|
351
|
+
count: Schema.Number,
|
|
352
|
+
}),
|
|
353
|
+
Schema.Struct({
|
|
354
|
+
...ActorAuditEventBaseSchema,
|
|
355
|
+
type: Schema.Literal("auth.recovery_code.verified"),
|
|
356
|
+
userId: UserIdSchema,
|
|
357
|
+
codeId: CredentialIdSchema,
|
|
358
|
+
}),
|
|
359
|
+
Schema.Struct({
|
|
360
|
+
...ActorAuditEventBaseSchema,
|
|
361
|
+
type: Schema.Literal("auth.recovery_code.revoked"),
|
|
362
|
+
userId: UserIdSchema,
|
|
363
|
+
codeId: CredentialIdSchema,
|
|
364
|
+
reason: Schema.String,
|
|
365
|
+
}),
|
|
366
|
+
Schema.Struct({
|
|
367
|
+
...ActorAuditEventBaseSchema,
|
|
368
|
+
type: Schema.Literals(["auth.api_key.created", "auth.api_key.verified"]),
|
|
369
|
+
userId: UserIdSchema,
|
|
370
|
+
keyId: ApiKeyIdSchema,
|
|
371
|
+
scopes: Schema.Array(Schema.String),
|
|
372
|
+
}),
|
|
373
|
+
Schema.Struct({
|
|
374
|
+
...ActorAuditEventBaseSchema,
|
|
375
|
+
type: Schema.Literal("auth.api_key.revoked"),
|
|
376
|
+
userId: UserIdSchema,
|
|
377
|
+
keyId: ApiKeyIdSchema,
|
|
378
|
+
reason: Schema.String,
|
|
379
|
+
}),
|
|
380
|
+
Schema.Struct({
|
|
381
|
+
...ActorAuditEventBaseSchema,
|
|
382
|
+
type: Schema.Literal("auth.api_key.verification_failed"),
|
|
383
|
+
reason: Schema.String,
|
|
384
|
+
}),
|
|
385
|
+
Schema.Struct({
|
|
386
|
+
...ActorAuditEventBaseSchema,
|
|
387
|
+
type: Schema.Literal("auth.refresh_token.issued"),
|
|
388
|
+
userId: UserIdSchema,
|
|
389
|
+
tokenId: RefreshTokenIdSchema,
|
|
390
|
+
familyId: RefreshTokenFamilyIdSchema,
|
|
391
|
+
expiresAt: UnixMillisSchema,
|
|
392
|
+
}),
|
|
393
|
+
Schema.Struct({
|
|
394
|
+
...ActorAuditEventBaseSchema,
|
|
395
|
+
type: Schema.Literal("auth.refresh_token.rotated"),
|
|
396
|
+
userId: UserIdSchema,
|
|
397
|
+
previousTokenId: RefreshTokenIdSchema,
|
|
398
|
+
tokenId: RefreshTokenIdSchema,
|
|
399
|
+
familyId: RefreshTokenFamilyIdSchema,
|
|
400
|
+
expiresAt: UnixMillisSchema,
|
|
401
|
+
}),
|
|
402
|
+
Schema.Struct({
|
|
403
|
+
...ActorAuditEventBaseSchema,
|
|
404
|
+
type: Schema.Literal("auth.refresh_token.reuse_detected"),
|
|
405
|
+
userId: UserIdSchema,
|
|
406
|
+
tokenId: RefreshTokenIdSchema,
|
|
407
|
+
familyId: RefreshTokenFamilyIdSchema,
|
|
408
|
+
}),
|
|
409
|
+
Schema.Struct({
|
|
410
|
+
...ActorAuditEventBaseSchema,
|
|
411
|
+
type: Schema.Literal("auth.refresh_token.revoked"),
|
|
412
|
+
userId: UserIdSchema,
|
|
413
|
+
familyId: RefreshTokenFamilyIdSchema,
|
|
414
|
+
tokenId: Schema.optional(RefreshTokenIdSchema),
|
|
415
|
+
reason: Schema.String,
|
|
416
|
+
}),
|
|
417
|
+
Schema.Struct({
|
|
418
|
+
...ActorAuditEventBaseSchema,
|
|
419
|
+
type: Schema.Literal("auth.incident_action.executed"),
|
|
420
|
+
userId: UserIdSchema,
|
|
421
|
+
result: IncidentActionResultSchema,
|
|
422
|
+
}),
|
|
423
|
+
Schema.Struct({
|
|
424
|
+
...ActorAuditEventBaseSchema,
|
|
425
|
+
type: Schema.Literal("auth.jwt.introspected"),
|
|
426
|
+
active: Schema.Boolean,
|
|
427
|
+
jwtId: Schema.optional(Schema.String),
|
|
428
|
+
expiresAt: Schema.optional(UnixMillisSchema),
|
|
429
|
+
reason: Schema.optional(Schema.String),
|
|
430
|
+
}),
|
|
431
|
+
Schema.Struct({
|
|
432
|
+
...ActorAuditEventBaseSchema,
|
|
433
|
+
type: Schema.Literal("auth.jwt.revoked"),
|
|
434
|
+
jwtId: Schema.String,
|
|
435
|
+
expiresAt: Schema.optional(UnixMillisSchema),
|
|
436
|
+
reason: Schema.String,
|
|
437
|
+
}),
|
|
438
|
+
]);
|
|
439
|
+
const CustomAuditEventFields = {
|
|
440
|
+
type: Schema.TemplateLiteral(["app.", Schema.String]),
|
|
441
|
+
version: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
|
|
442
|
+
id: Schema.optional(AuditEventIdSchema),
|
|
443
|
+
actor: AuditActorSchema,
|
|
444
|
+
subject: Schema.optional(AuditSubjectSchema),
|
|
445
|
+
request: Schema.optional(AuditRequestSchema),
|
|
446
|
+
payload: Schema.Record(Schema.String, Schema.Unknown),
|
|
447
|
+
occurredAt: UnixMillisSchema,
|
|
448
|
+
};
|
|
449
|
+
export class CustomAuditEvent extends Schema.Class("CustomAuditEvent")(CustomAuditEventFields) {
|
|
450
|
+
}
|
|
451
|
+
export const CustomAuditEventSchema = Schema.Struct(CustomAuditEventFields);
|
|
452
|
+
export const isCustomAuditEvent = Schema.is(CustomAuditEventSchema);
|
|
453
|
+
export const AuditEventSchema = Schema.Union([
|
|
454
|
+
AuthAuditEventSchema,
|
|
455
|
+
CustomAuditEventSchema,
|
|
456
|
+
]);
|
|
457
|
+
const decodeAuditEventUnknown = Schema.decodeUnknownSync(AuditEventSchema);
|
|
458
|
+
export const decodeAuditEvent = (input) => decodeAuditEventUnknown(input);
|
|
459
|
+
export const isAuthAuditEvent = (event) => event.type.startsWith("auth.");
|
|
20
460
|
export class AuditLog extends Context.Service()("auth/AuditLog") {
|
|
21
461
|
}
|
|
22
|
-
(function (AuditLog) {
|
|
23
|
-
AuditLog.make = (service) => AuditLog.of(service);
|
|
24
|
-
})(AuditLog || (AuditLog = {}));
|
|
25
462
|
export class AuditLogStore extends Context.Service()("auth/AuditLogStore") {
|
|
26
463
|
}
|
|
27
|
-
(function (AuditLogStore) {
|
|
28
|
-
AuditLogStore.make = (service) => AuditLogStore.of(service);
|
|
29
|
-
})(AuditLogStore || (AuditLogStore = {}));
|
|
30
464
|
const occurredAt = (value) => value === undefined ? currentUnixMillis : Effect.succeed(value);
|
|
31
465
|
const clone = (value) => structuredClone(value);
|
|
32
466
|
export const auditEventUserId = (event) => {
|
|
33
|
-
if ("userId" in event) {
|
|
467
|
+
if (isAuthAuditEvent(event) && "userId" in event) {
|
|
34
468
|
return event.userId;
|
|
35
469
|
}
|
|
36
|
-
if (event.type === "auth.risk.assessed") {
|
|
470
|
+
if (isAuthAuditEvent(event) && event.type === "auth.risk.assessed") {
|
|
37
471
|
return event.assessment.userId;
|
|
38
472
|
}
|
|
39
|
-
if ("subject" in event && event.subject
|
|
40
|
-
|
|
473
|
+
if ("subject" in event && event.subject !== undefined) {
|
|
474
|
+
const { subject } = event;
|
|
475
|
+
if (subject.type === "user") {
|
|
476
|
+
return subject.userId;
|
|
477
|
+
}
|
|
41
478
|
}
|
|
42
479
|
if ("actor" in event && event.actor.type === "user") {
|
|
43
480
|
return event.actor.userId;
|
|
44
481
|
}
|
|
45
482
|
return undefined;
|
|
46
483
|
};
|
|
47
|
-
export const auditEventActorUserId = (event) => "actor" in event && event.actor.type === "user"
|
|
484
|
+
export const auditEventActorUserId = (event) => "actor" in event && event.actor.type === "user"
|
|
485
|
+
? event.actor.userId
|
|
486
|
+
: undefined;
|
|
48
487
|
const compareAuditEvents = (left, right) => {
|
|
49
488
|
const occurredAtDifference = Number(right.occurredAt) - Number(left.occurredAt);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
489
|
+
const leftId = String(left.id ?? "");
|
|
490
|
+
const rightId = String(right.id ?? "");
|
|
491
|
+
if (occurredAtDifference !== 0 || leftId === rightId) {
|
|
492
|
+
return occurredAtDifference;
|
|
493
|
+
}
|
|
494
|
+
return -compareUtf8Bytes(leftId, rightId);
|
|
53
495
|
};
|
|
54
496
|
const insertSortedAuditEvent = (events, event) => {
|
|
55
497
|
const index = events.findIndex((existing) => compareAuditEvents(event, existing) < 0);
|
|
@@ -69,23 +511,25 @@ export const filterAuditLogEvents = (events, input = {}) => {
|
|
|
69
511
|
const beforeOccurredAt = input.beforeOccurredAt === undefined
|
|
70
512
|
? undefined
|
|
71
513
|
: Number(input.beforeOccurredAt);
|
|
72
|
-
const limit = input.limit === undefined
|
|
514
|
+
const limit = input.limit === undefined
|
|
515
|
+
? undefined
|
|
516
|
+
: Math.max(0, Math.floor(input.limit));
|
|
73
517
|
const filtered = [...events]
|
|
74
518
|
.filter((event) => input.userId === undefined || auditEventUserId(event) === input.userId)
|
|
75
|
-
.filter((event) => beforeOccurredAt === undefined ||
|
|
519
|
+
.filter((event) => beforeOccurredAt === undefined ||
|
|
520
|
+
Number(event.occurredAt) < beforeOccurredAt)
|
|
76
521
|
.filter((event) => types === undefined || types.has(event.type));
|
|
77
522
|
const sorted = sortAuditEvents(filtered).map(clone);
|
|
78
523
|
return limit === undefined ? sorted : sorted.slice(0, limit);
|
|
79
524
|
};
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export const
|
|
88
|
-
export const insertAuditLogEvent = (event) => AuditLogStore.use((store) => store.insert(event));
|
|
525
|
+
export const emit = (event) => Effect.serviceOption(AuditLog).pipe(Effect.flatMap(Option.match({
|
|
526
|
+
onNone: () => Effect.void,
|
|
527
|
+
onSome: (auditLog) => auditLog
|
|
528
|
+
.emit(event)
|
|
529
|
+
.pipe(Effect.catchTag("AuditLogError", (error) => Effect.logError("Audit log emit failed", error))),
|
|
530
|
+
})));
|
|
531
|
+
export const emitRequired = (event) => AuditLog.use((auditLog) => auditLog.emit(event));
|
|
532
|
+
export const insertAuditLogEvents = (events) => AuditLogStore.use((store) => store.insertMany(events));
|
|
89
533
|
export const listAuditLogEvents = (input = {}) => AuditLogStore.use((store) => store.list(input));
|
|
90
534
|
export const deleteAuditLogEventsBefore = (input) => AuditLogStore.use((store) => store.deleteBefore(input));
|
|
91
535
|
export const loginSucceeded = (input) => Effect.gen(function* () {
|
|
@@ -95,6 +539,17 @@ export const loginSucceeded = (input) => Effect.gen(function* () {
|
|
|
95
539
|
occurredAt: yield* occurredAt(input.occurredAt),
|
|
96
540
|
});
|
|
97
541
|
});
|
|
542
|
+
const identityEvent = (type, input) => occurredAt(input.occurredAt).pipe(Effect.flatMap((at) => emit({ ...input, type, occurredAt: at })));
|
|
543
|
+
export const identityAdded = (input) => identityEvent("auth.identity.added", input);
|
|
544
|
+
export const identityReplaced = (input) => identityEvent("auth.identity.replaced", input);
|
|
545
|
+
export const identityRevoked = (input) => identityEvent("auth.identity.revoked", input);
|
|
546
|
+
export const identityPrimaryChanged = (input) => identityEvent("auth.identity.primary_changed", input);
|
|
547
|
+
const assuranceEvent = (type, input) => occurredAt(input.occurredAt).pipe(Effect.flatMap((at) => emit({ ...input, type, occurredAt: at })));
|
|
548
|
+
export const sessionAssuranceChanged = (input) => assuranceEvent("auth.session.assurance_changed", input);
|
|
549
|
+
export const sessionStepUpCompleted = (input) => assuranceEvent("auth.session.step_up_completed", input);
|
|
550
|
+
export const sessionPrimaryReauthenticated = (input) => assuranceEvent("auth.session.primary_reauthenticated", input);
|
|
551
|
+
export const recoveryRemediationEntered = (input) => assuranceEvent("auth.session.recovery_remediation.entered", input);
|
|
552
|
+
export const recoveryRemediationCompleted = (input) => assuranceEvent("auth.session.recovery_remediation.completed", input);
|
|
98
553
|
export const loginFailed = (input) => Effect.gen(function* () {
|
|
99
554
|
return yield* emit({
|
|
100
555
|
...input,
|
|
@@ -300,9 +755,9 @@ export const jwtRevoked = (input) => Effect.gen(function* () {
|
|
|
300
755
|
});
|
|
301
756
|
export const makeAuditLogStoreMemory = () => {
|
|
302
757
|
const events = [];
|
|
303
|
-
return AuditLogStore.
|
|
304
|
-
|
|
305
|
-
events.push(clone
|
|
758
|
+
return AuditLogStore.of({
|
|
759
|
+
insertMany: (batch) => Effect.sync(() => {
|
|
760
|
+
events.push(...batch.map(clone));
|
|
306
761
|
}),
|
|
307
762
|
list: (input = {}) => Effect.sync(() => filterAuditLogEvents(events, input)),
|
|
308
763
|
deleteBefore: (input) => Effect.sync(() => {
|
|
@@ -310,7 +765,8 @@ export const makeAuditLogStoreMemory = () => {
|
|
|
310
765
|
let deleted = 0;
|
|
311
766
|
for (const event of events) {
|
|
312
767
|
if (Number(event.occurredAt) < Number(input.beforeOccurredAt) &&
|
|
313
|
-
(input.userId === undefined ||
|
|
768
|
+
(input.userId === undefined ||
|
|
769
|
+
auditEventUserId(event) === input.userId)) {
|
|
314
770
|
deleted += 1;
|
|
315
771
|
continue;
|
|
316
772
|
}
|
|
@@ -322,8 +778,30 @@ export const makeAuditLogStoreMemory = () => {
|
|
|
322
778
|
});
|
|
323
779
|
};
|
|
324
780
|
export const AuditLogStoreMemoryLive = Layer.sync(AuditLogStore, makeAuditLogStoreMemory);
|
|
325
|
-
export const
|
|
326
|
-
|
|
781
|
+
export const AuditLogLive = Layer.effect(AuditLog)(Effect.gen(function* () {
|
|
782
|
+
const store = yield* AuditLogStore;
|
|
783
|
+
const waitUntil = yield* Effect.serviceOption(WaitUntil);
|
|
784
|
+
const events = yield* Ref.make([]);
|
|
785
|
+
yield* Effect.addFinalizer(() => Ref.getAndSet(events, []).pipe(Effect.flatMap((batch) => {
|
|
786
|
+
if (batch.length === 0) {
|
|
787
|
+
return Effect.void;
|
|
788
|
+
}
|
|
789
|
+
const flush = store.insertMany(batch);
|
|
790
|
+
return Option.isSome(waitUntil)
|
|
791
|
+
? waitUntil.value.waitUntil(flush).pipe(Effect.mapError((cause) => new AuditLogError({
|
|
792
|
+
message: "Audit log batch scheduling failed",
|
|
793
|
+
cause,
|
|
794
|
+
})))
|
|
795
|
+
: flush.pipe(Effect.mapError((cause) => new AuditLogError({
|
|
796
|
+
message: "Audit log batch flush failed",
|
|
797
|
+
cause,
|
|
798
|
+
})));
|
|
799
|
+
}), Effect.catch(() => Effect.logError("Audit log batch flush failed"))));
|
|
800
|
+
return AuditLog.of({
|
|
801
|
+
emit: (event) => Ref.update(events, (batch) => [...batch, clone(event)]),
|
|
802
|
+
});
|
|
803
|
+
}));
|
|
804
|
+
export const AuditLogNoopLive = Layer.succeed(AuditLog)(AuditLog.of({
|
|
327
805
|
emit: () => Effect.void,
|
|
328
806
|
}));
|
|
329
807
|
//# sourceMappingURL=AuditLog.js.map
|