@effect-auth/core 0.1.0-alpha.16 → 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 +308 -133
- 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 +0 -12
- 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/AuthFlow.d.ts +128 -38
- package/dist/AuthFlow.d.ts.map +1 -1
- package/dist/AuthFlow.js +611 -263
- package/dist/AuthFlow.js.map +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 +1 -4
- 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 +4 -4
- package/dist/DrizzleD1SqliteStorage.d.ts.map +1 -1
- package/dist/DrizzleD1SqliteStorage.js +5 -5
- package/dist/DrizzleD1SqliteStorage.js.map +1 -1
- 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 +13 -4
- package/dist/DrizzleEffectSqliteStorage.d.ts.map +1 -1
- package/dist/DrizzleEffectSqliteStorage.js +71 -4
- package/dist/DrizzleEffectSqliteStorage.js.map +1 -1
- 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 +181 -23
- package/dist/EffectQbSqliteStorage.d.ts.map +1 -1
- package/dist/EffectQbSqliteStorage.js +1728 -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 +879 -877
- 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 +8 -29
- package/dist/Jwt.d.ts.map +1 -1
- package/dist/Jwt.js +67 -56
- package/dist/Jwt.js.map +1 -1
- package/dist/LoginApproval.d.ts +15 -30
- 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 +7 -11
- 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/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 +19 -12
- 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 +93 -96
- 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 +15 -17
- 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 +295 -81
- 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 +83 -11
- 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 +0 -9
- package/dist/RefreshToken.d.ts.map +1 -1
- package/dist/RefreshToken.js +31 -22
- package/dist/RefreshToken.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.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 +192 -34
- 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.map +1 -1
- package/dist/alchemy/cloudflare/Email.js +9 -4
- package/dist/alchemy/cloudflare/Email.js.map +1 -1
- package/dist/cloudflare/Email.js +1 -1
- package/dist/cloudflare/Email.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/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 +301 -2
package/dist/OAuth.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Brand, Context, Data, Duration, Effect, Encoding, Layer, Option, Redact
|
|
|
2
2
|
import { Challenge } from "./Challenge.js";
|
|
3
3
|
import { Crypto } from "./Crypto.js";
|
|
4
4
|
import { ChallengeId, Email, OAuthAccountId, OAuthClientId, OAuthProviderId, UnixMillis, UserId, } from "./Identifiers.js";
|
|
5
|
+
import { globalIdentityScope, normalizeEmail } from "./Identity.js";
|
|
5
6
|
import { currentUnixMillis } from "./Internal.js";
|
|
6
7
|
import { JwtAlgorithms, JwtError, JwtKeyId, JwtKeys, JwtVerifier, } from "./Jwt.js";
|
|
7
8
|
export const OAuthStateToken = Brand.nominal();
|
|
@@ -61,7 +62,11 @@ export const googleOidcOfflineAccessAuthorizationParams = {
|
|
|
61
62
|
export const microsoftOidcProviderId = OAuthProviderId("microsoft");
|
|
62
63
|
export const microsoftOidcLoginBaseUrl = "https://login.microsoftonline.com";
|
|
63
64
|
export const microsoftOidcUserInfoEndpoint = "https://graph.microsoft.com/oidc/userinfo";
|
|
64
|
-
export const microsoftOidcDefaultScopes = [
|
|
65
|
+
export const microsoftOidcDefaultScopes = [
|
|
66
|
+
"openid",
|
|
67
|
+
"email",
|
|
68
|
+
"profile",
|
|
69
|
+
];
|
|
65
70
|
export const microsoftOidcOfflineAccessScopes = [
|
|
66
71
|
"openid",
|
|
67
72
|
"email",
|
|
@@ -85,226 +90,142 @@ export class OAuthClientRegistryError extends Data.TaggedError("OAuthClientRegis
|
|
|
85
90
|
}
|
|
86
91
|
export class OAuthClientRegistry extends Context.Service()("auth/OAuthClientRegistry") {
|
|
87
92
|
}
|
|
88
|
-
(function (OAuthClientRegistry) {
|
|
89
|
-
OAuthClientRegistry.make = (service) => OAuthClientRegistry.of(service);
|
|
90
|
-
})(OAuthClientRegistry || (OAuthClientRegistry = {}));
|
|
91
93
|
export class OAuthClientStoreError extends Data.TaggedError("OAuthClientStoreError") {
|
|
92
94
|
}
|
|
93
95
|
export class OAuthClientStore extends Context.Service()("auth/OAuthClientStore") {
|
|
94
96
|
}
|
|
95
|
-
(function (OAuthClientStore) {
|
|
96
|
-
OAuthClientStore.make = (service) => OAuthClientStore.of(service);
|
|
97
|
-
})(OAuthClientStore || (OAuthClientStore = {}));
|
|
98
97
|
export class OAuthConsentStoreError extends Data.TaggedError("OAuthConsentStoreError") {
|
|
99
98
|
}
|
|
100
99
|
export class OAuthConsentStore extends Context.Service()("auth/OAuthConsentStore") {
|
|
101
100
|
}
|
|
102
|
-
(function (OAuthConsentStore) {
|
|
103
|
-
OAuthConsentStore.make = (service) => OAuthConsentStore.of(service);
|
|
104
|
-
})(OAuthConsentStore || (OAuthConsentStore = {}));
|
|
105
101
|
export class OAuthClientSecretError extends Data.TaggedError("OAuthClientSecretError") {
|
|
106
102
|
}
|
|
107
103
|
export class OAuthClientSecrets extends Context.Service()("auth/OAuthClientSecrets") {
|
|
108
104
|
}
|
|
109
|
-
(function (OAuthClientSecrets) {
|
|
110
|
-
OAuthClientSecrets.make = (service) => OAuthClientSecrets.of(service);
|
|
111
|
-
})(OAuthClientSecrets || (OAuthClientSecrets = {}));
|
|
112
105
|
export class OAuthClientSecretStoreError extends Data.TaggedError("OAuthClientSecretStoreError") {
|
|
113
106
|
}
|
|
114
107
|
export class OAuthClientSecretStore extends Context.Service()("auth/OAuthClientSecretStore") {
|
|
115
108
|
}
|
|
116
|
-
(function (OAuthClientSecretStore) {
|
|
117
|
-
OAuthClientSecretStore.make = (service) => OAuthClientSecretStore.of(service);
|
|
118
|
-
})(OAuthClientSecretStore || (OAuthClientSecretStore = {}));
|
|
119
109
|
export class OAuthClientSecretVerificationError extends Data.TaggedError("OAuthClientSecretVerificationError") {
|
|
120
110
|
}
|
|
121
111
|
export class OAuthClientSecretVerification extends Context.Service()("auth/OAuthClientSecretVerification") {
|
|
122
112
|
}
|
|
123
|
-
(function (OAuthClientSecretVerification) {
|
|
124
|
-
OAuthClientSecretVerification.make = (service) => OAuthClientSecretVerification.of(service);
|
|
125
|
-
})(OAuthClientSecretVerification || (OAuthClientSecretVerification = {}));
|
|
126
113
|
export class OAuthAuthorizationCodeStoreError extends Data.TaggedError("OAuthAuthorizationCodeStoreError") {
|
|
127
114
|
}
|
|
128
115
|
export class OAuthAuthorizationCodeStore extends Context.Service()("auth/OAuthAuthorizationCodeStore") {
|
|
129
116
|
}
|
|
130
|
-
(function (OAuthAuthorizationCodeStore) {
|
|
131
|
-
OAuthAuthorizationCodeStore.make = (service) => OAuthAuthorizationCodeStore.of(service);
|
|
132
|
-
})(OAuthAuthorizationCodeStore || (OAuthAuthorizationCodeStore = {}));
|
|
133
117
|
export class OAuthAuthorizationCodeGrantError extends Data.TaggedError("OAuthAuthorizationCodeGrantError") {
|
|
134
118
|
}
|
|
135
119
|
export class OAuthAuthorizationCodeGrant extends Context.Service()("auth/OAuthAuthorizationCodeGrant") {
|
|
136
120
|
}
|
|
137
|
-
(function (OAuthAuthorizationCodeGrant) {
|
|
138
|
-
OAuthAuthorizationCodeGrant.make = (service) => OAuthAuthorizationCodeGrant.of(service);
|
|
139
|
-
})(OAuthAuthorizationCodeGrant || (OAuthAuthorizationCodeGrant = {}));
|
|
140
121
|
export class OAuthAuthorizationCodeTokenIssuerError extends Data.TaggedError("OAuthAuthorizationCodeTokenIssuerError") {
|
|
141
122
|
}
|
|
142
123
|
export class OAuthAuthorizationCodeTokenIssuer extends Context.Service()("auth/OAuthAuthorizationCodeTokenIssuer") {
|
|
143
124
|
}
|
|
144
|
-
(function (OAuthAuthorizationCodeTokenIssuer) {
|
|
145
|
-
OAuthAuthorizationCodeTokenIssuer.make = (service) => OAuthAuthorizationCodeTokenIssuer.of(service);
|
|
146
|
-
})(OAuthAuthorizationCodeTokenIssuer || (OAuthAuthorizationCodeTokenIssuer = {}));
|
|
147
125
|
export class OAuthAuthorizationCodeTokenGrantError extends Data.TaggedError("OAuthAuthorizationCodeTokenGrantError") {
|
|
148
126
|
}
|
|
149
127
|
export class OAuthAuthorizationCodeTokenGrant extends Context.Service()("auth/OAuthAuthorizationCodeTokenGrant") {
|
|
150
128
|
}
|
|
151
|
-
(function (OAuthAuthorizationCodeTokenGrant) {
|
|
152
|
-
OAuthAuthorizationCodeTokenGrant.make = (service) => OAuthAuthorizationCodeTokenGrant.of(service);
|
|
153
|
-
})(OAuthAuthorizationCodeTokenGrant || (OAuthAuthorizationCodeTokenGrant = {}));
|
|
154
129
|
export class OAuthRefreshTokenIssuerError extends Data.TaggedError("OAuthRefreshTokenIssuerError") {
|
|
155
130
|
}
|
|
156
131
|
export class OAuthRefreshTokenIssuer extends Context.Service()("auth/OAuthRefreshTokenIssuer") {
|
|
157
132
|
}
|
|
158
|
-
(function (OAuthRefreshTokenIssuer) {
|
|
159
|
-
OAuthRefreshTokenIssuer.make = (service) => OAuthRefreshTokenIssuer.of(service);
|
|
160
|
-
})(OAuthRefreshTokenIssuer || (OAuthRefreshTokenIssuer = {}));
|
|
161
133
|
export class OAuthRefreshTokenGrantError extends Data.TaggedError("OAuthRefreshTokenGrantError") {
|
|
162
134
|
}
|
|
163
135
|
export class OAuthRefreshTokenGrant extends Context.Service()("auth/OAuthRefreshTokenGrant") {
|
|
164
136
|
}
|
|
165
|
-
(function (OAuthRefreshTokenGrant) {
|
|
166
|
-
OAuthRefreshTokenGrant.make = (service) => OAuthRefreshTokenGrant.of(service);
|
|
167
|
-
})(OAuthRefreshTokenGrant || (OAuthRefreshTokenGrant = {}));
|
|
168
137
|
export class OAuthClientCredentialsTokenIssuerError extends Data.TaggedError("OAuthClientCredentialsTokenIssuerError") {
|
|
169
138
|
}
|
|
170
139
|
export class OAuthClientCredentialsTokenIssuer extends Context.Service()("auth/OAuthClientCredentialsTokenIssuer") {
|
|
171
140
|
}
|
|
172
|
-
(function (OAuthClientCredentialsTokenIssuer) {
|
|
173
|
-
OAuthClientCredentialsTokenIssuer.make = (service) => OAuthClientCredentialsTokenIssuer.of(service);
|
|
174
|
-
})(OAuthClientCredentialsTokenIssuer || (OAuthClientCredentialsTokenIssuer = {}));
|
|
175
141
|
export class OAuthClientCredentialsGrantError extends Data.TaggedError("OAuthClientCredentialsGrantError") {
|
|
176
142
|
}
|
|
177
143
|
export class OAuthClientCredentialsGrant extends Context.Service()("auth/OAuthClientCredentialsGrant") {
|
|
178
144
|
}
|
|
179
|
-
(function (OAuthClientCredentialsGrant) {
|
|
180
|
-
OAuthClientCredentialsGrant.make = (service) => OAuthClientCredentialsGrant.of(service);
|
|
181
|
-
})(OAuthClientCredentialsGrant || (OAuthClientCredentialsGrant = {}));
|
|
182
145
|
export class OAuthTokenRevokerError extends Data.TaggedError("OAuthTokenRevokerError") {
|
|
183
146
|
}
|
|
184
147
|
export class OAuthTokenRevoker extends Context.Service()("auth/OAuthTokenRevoker") {
|
|
185
148
|
}
|
|
186
|
-
(function (OAuthTokenRevoker) {
|
|
187
|
-
OAuthTokenRevoker.make = (service) => OAuthTokenRevoker.of(service);
|
|
188
|
-
})(OAuthTokenRevoker || (OAuthTokenRevoker = {}));
|
|
189
149
|
export class OAuthTokenRevocationError extends Data.TaggedError("OAuthTokenRevocationError") {
|
|
190
150
|
}
|
|
191
151
|
export class OAuthTokenRevocation extends Context.Service()("auth/OAuthTokenRevocation") {
|
|
192
152
|
}
|
|
193
|
-
(function (OAuthTokenRevocation) {
|
|
194
|
-
OAuthTokenRevocation.make = (service) => OAuthTokenRevocation.of(service);
|
|
195
|
-
})(OAuthTokenRevocation || (OAuthTokenRevocation = {}));
|
|
196
153
|
export class OAuthTokenIntrospectorError extends Data.TaggedError("OAuthTokenIntrospectorError") {
|
|
197
154
|
}
|
|
198
155
|
export class OAuthTokenIntrospector extends Context.Service()("auth/OAuthTokenIntrospector") {
|
|
199
156
|
}
|
|
200
|
-
(function (OAuthTokenIntrospector) {
|
|
201
|
-
OAuthTokenIntrospector.make = (service) => OAuthTokenIntrospector.of(service);
|
|
202
|
-
})(OAuthTokenIntrospector || (OAuthTokenIntrospector = {}));
|
|
203
157
|
export class OAuthTokenIntrospectionError extends Data.TaggedError("OAuthTokenIntrospectionError") {
|
|
204
158
|
}
|
|
205
159
|
export class OAuthTokenIntrospection extends Context.Service()("auth/OAuthTokenIntrospection") {
|
|
206
160
|
}
|
|
207
|
-
(function (OAuthTokenIntrospection) {
|
|
208
|
-
OAuthTokenIntrospection.make = (service) => OAuthTokenIntrospection.of(service);
|
|
209
|
-
})(OAuthTokenIntrospection || (OAuthTokenIntrospection = {}));
|
|
210
161
|
export class OAuthProviderAuthorizationPolicyError extends Data.TaggedError("OAuthProviderAuthorizationPolicyError") {
|
|
211
162
|
}
|
|
212
163
|
export class OAuthProviderAuthorizationPolicy extends Context.Service()("auth/OAuthProviderAuthorizationPolicy") {
|
|
213
164
|
}
|
|
214
|
-
(function (OAuthProviderAuthorizationPolicy) {
|
|
215
|
-
OAuthProviderAuthorizationPolicy.make = (service) => OAuthProviderAuthorizationPolicy.of(service);
|
|
216
|
-
})(OAuthProviderAuthorizationPolicy || (OAuthProviderAuthorizationPolicy = {}));
|
|
217
165
|
export class OAuthProviderAuthorizationError extends Data.TaggedError("OAuthProviderAuthorizationError") {
|
|
218
166
|
}
|
|
219
167
|
export class OAuthProviderAuthorization extends Context.Service()("auth/OAuthProviderAuthorization") {
|
|
220
168
|
}
|
|
221
|
-
(function (OAuthProviderAuthorization) {
|
|
222
|
-
OAuthProviderAuthorization.make = (service) => OAuthProviderAuthorization.of(service);
|
|
223
|
-
})(OAuthProviderAuthorization || (OAuthProviderAuthorization = {}));
|
|
224
169
|
export class OAuthUserInfoError extends Data.TaggedError("OAuthUserInfoError") {
|
|
225
170
|
}
|
|
226
171
|
export class OAuthProviderModeTokenStoreError extends Data.TaggedError("OAuthProviderModeTokenStoreError") {
|
|
227
172
|
}
|
|
228
173
|
export class OAuthProviderModeTokenStore extends Context.Service()("auth/OAuthProviderModeTokenStore") {
|
|
229
174
|
}
|
|
230
|
-
(function (OAuthProviderModeTokenStore) {
|
|
231
|
-
OAuthProviderModeTokenStore.make = (service) => OAuthProviderModeTokenStore.of(service);
|
|
232
|
-
})(OAuthProviderModeTokenStore || (OAuthProviderModeTokenStore = {}));
|
|
233
175
|
export class OAuthProviderTokenVaultError extends Data.TaggedError("OAuthProviderTokenVaultError") {
|
|
234
176
|
}
|
|
235
177
|
export class OAuthProviderTokenVault extends Context.Service()("auth/OAuthProviderTokenVault") {
|
|
236
178
|
}
|
|
237
|
-
(function (OAuthProviderTokenVault) {
|
|
238
|
-
OAuthProviderTokenVault.make = (service) => OAuthProviderTokenVault.of(service);
|
|
239
|
-
})(OAuthProviderTokenVault || (OAuthProviderTokenVault = {}));
|
|
240
179
|
export class OAuthProviderTokenLifecycleError extends Data.TaggedError("OAuthProviderTokenLifecycleError") {
|
|
241
180
|
}
|
|
242
181
|
export class OAuthProviderTokenLifecycle extends Context.Service()("auth/OAuthProviderTokenLifecycle") {
|
|
243
182
|
}
|
|
244
|
-
(function (OAuthProviderTokenLifecycle) {
|
|
245
|
-
OAuthProviderTokenLifecycle.make = (service) => OAuthProviderTokenLifecycle.of(service);
|
|
246
|
-
})(OAuthProviderTokenLifecycle || (OAuthProviderTokenLifecycle = {}));
|
|
247
183
|
export class OidcIdTokenVerifierError extends Data.TaggedError("OidcIdTokenVerifierError") {
|
|
248
184
|
}
|
|
249
185
|
export class OidcIdTokenVerifier extends Context.Service()("auth/OidcIdTokenVerifier") {
|
|
250
186
|
}
|
|
251
|
-
(function (OidcIdTokenVerifier) {
|
|
252
|
-
OidcIdTokenVerifier.make = (service) => OidcIdTokenVerifier.of(service);
|
|
253
|
-
})(OidcIdTokenVerifier || (OidcIdTokenVerifier = {}));
|
|
254
187
|
export class OAuthProfileNormalizationError extends Data.TaggedError("OAuthProfileNormalizationError") {
|
|
255
188
|
}
|
|
256
189
|
export class OAuthProfileNormalizer extends Context.Service()("auth/OAuthProfileNormalizer") {
|
|
257
190
|
}
|
|
258
|
-
(function (OAuthProfileNormalizer) {
|
|
259
|
-
OAuthProfileNormalizer.make = (service) => OAuthProfileNormalizer.of(service);
|
|
260
|
-
})(OAuthProfileNormalizer || (OAuthProfileNormalizer = {}));
|
|
261
191
|
export class OAuthTokenExchangeError extends Data.TaggedError("OAuthTokenExchangeError") {
|
|
262
192
|
}
|
|
263
193
|
export class OAuthTokenExchange extends Context.Service()("auth/OAuthTokenExchange") {
|
|
264
194
|
}
|
|
265
|
-
(function (OAuthTokenExchange) {
|
|
266
|
-
OAuthTokenExchange.make = (service) => OAuthTokenExchange.of(service);
|
|
267
|
-
})(OAuthTokenExchange || (OAuthTokenExchange = {}));
|
|
268
195
|
export class OAuthProviders extends Context.Service()("auth/OAuthProviders") {
|
|
269
196
|
}
|
|
270
|
-
(function (OAuthProviders) {
|
|
271
|
-
OAuthProviders.make = (service) => OAuthProviders.of(service);
|
|
272
|
-
})(OAuthProviders || (OAuthProviders = {}));
|
|
273
197
|
export class OAuthStateError extends Data.TaggedError("OAuthStateError") {
|
|
274
198
|
}
|
|
275
199
|
export class OAuthState extends Context.Service()("auth/OAuthState") {
|
|
276
200
|
}
|
|
277
|
-
(function (OAuthState) {
|
|
278
|
-
OAuthState.make = (service) => OAuthState.of(service);
|
|
279
|
-
})(OAuthState || (OAuthState = {}));
|
|
280
201
|
export class OAuthAccountStoreError extends Data.TaggedError("OAuthAccountStoreError") {
|
|
281
202
|
}
|
|
203
|
+
export class OAuthIdentityBridgeConflictError extends Data.TaggedError("OAuthIdentityBridgeConflictError") {
|
|
204
|
+
}
|
|
205
|
+
export class OAuthIdentityBridgeStoreError extends Data.TaggedError("OAuthIdentityBridgeStoreError") {
|
|
206
|
+
}
|
|
207
|
+
export class OAuthIdentityBridgeStore extends Context.Service()("auth/OAuthIdentityBridgeStore") {
|
|
208
|
+
}
|
|
282
209
|
export class OAuthAccountStore extends Context.Service()("auth/OAuthAccountStore") {
|
|
283
210
|
}
|
|
284
|
-
(function (OAuthAccountStore) {
|
|
285
|
-
OAuthAccountStore.make = (service) => OAuthAccountStore.of(service);
|
|
286
|
-
})(OAuthAccountStore || (OAuthAccountStore = {}));
|
|
287
211
|
export class OAuthAccountLinkingError extends Data.TaggedError("OAuthAccountLinkingError") {
|
|
288
212
|
}
|
|
289
213
|
export class OAuthAccountLinking extends Context.Service()("auth/OAuthAccountLinking") {
|
|
290
214
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
215
|
+
export class OAuthIdentityBridgePolicy extends Context.Service()("auth/OAuthIdentityBridgePolicy") {
|
|
216
|
+
}
|
|
217
|
+
export class OAuthIdentityBridgeError extends Data.TaggedError("OAuthIdentityBridgeError") {
|
|
218
|
+
}
|
|
219
|
+
export class OAuthIdentityBridge extends Context.Service()("auth/OAuthIdentityBridge") {
|
|
220
|
+
}
|
|
294
221
|
export class OAuthAccountUnlinkingError extends Data.TaggedError("OAuthAccountUnlinkingError") {
|
|
295
222
|
}
|
|
296
223
|
export class OAuthAccountUnlinking extends Context.Service()("auth/OAuthAccountUnlinking") {
|
|
297
224
|
}
|
|
298
|
-
(function (OAuthAccountUnlinking) {
|
|
299
|
-
OAuthAccountUnlinking.make = (service) => OAuthAccountUnlinking.of(service);
|
|
300
|
-
})(OAuthAccountUnlinking || (OAuthAccountUnlinking = {}));
|
|
301
225
|
export class OAuthLinkConfirmationError extends Data.TaggedError("OAuthLinkConfirmationError") {
|
|
302
226
|
}
|
|
303
227
|
export class OAuthLinkConfirmation extends Context.Service()("auth/OAuthLinkConfirmation") {
|
|
304
228
|
}
|
|
305
|
-
(function (OAuthLinkConfirmation) {
|
|
306
|
-
OAuthLinkConfirmation.make = (service) => OAuthLinkConfirmation.of(service);
|
|
307
|
-
})(OAuthLinkConfirmation || (OAuthLinkConfirmation = {}));
|
|
308
229
|
const oauthStateError = (operation, message, cause) => new OAuthStateError({ operation, message, cause });
|
|
309
230
|
const oauthAuthorizationCodeGrantError = (operation, message, cause) => new OAuthAuthorizationCodeGrantError({ operation, message, cause });
|
|
310
231
|
const oauthAuthorizationCodeTokenGrantError = (operation, message, cause) => new OAuthAuthorizationCodeTokenGrantError({ operation, message, cause });
|
|
@@ -397,8 +318,10 @@ const parseOAuthClientSecretValue = (secret) => {
|
|
|
397
318
|
}
|
|
398
319
|
return Effect.succeed(OAuthClientSecretPrefix(parts[0]));
|
|
399
320
|
};
|
|
400
|
-
const hashOAuthClientSecretValue = (dependencies, secret, operation) => dependencies.crypto
|
|
401
|
-
|
|
321
|
+
const hashOAuthClientSecretValue = (dependencies, secret, operation) => dependencies.crypto
|
|
322
|
+
.digestSha256({ data: `oauth-client-secret:${secret}` })
|
|
323
|
+
.pipe(Effect.map((hash) => OAuthClientSecretHash(`sha256:${hash}`)), Effect.mapError((cause) => oauthClientSecretError(operation, "Failed to hash OAuth client secret", cause)));
|
|
324
|
+
export const makeOAuthClientSecrets = (dependencies) => OAuthClientSecrets.of({
|
|
402
325
|
generate: Effect.fn("auth.oauth.client_secret.generate")(function* (input) {
|
|
403
326
|
const prefixBytes = yield* validateOAuthClientSecretByteLength(input?.prefixBytes ?? defaultOAuthClientSecretPrefixBytes, "generate", "OAuth client secret prefix");
|
|
404
327
|
const secretBytes = yield* validateOAuthClientSecretByteLength(input?.secretBytes ?? defaultOAuthClientSecretBytes, "generate", "OAuth client secret");
|
|
@@ -446,7 +369,9 @@ export const makeAppleSignInProvider = (input) => ({
|
|
|
446
369
|
...appleSignInDefaultAuthorizationParams,
|
|
447
370
|
...input.authorizationParams,
|
|
448
371
|
},
|
|
449
|
-
...(input.metadata === undefined
|
|
372
|
+
...(input.metadata === undefined
|
|
373
|
+
? {}
|
|
374
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
450
375
|
});
|
|
451
376
|
export const makeGithubOAuthProvider = (input) => ({
|
|
452
377
|
id: input.id ?? githubOAuthProviderId,
|
|
@@ -459,7 +384,9 @@ export const makeGithubOAuthProvider = (input) => ({
|
|
|
459
384
|
...(input.authorizationParams === undefined
|
|
460
385
|
? {}
|
|
461
386
|
: { authorizationParams: { ...input.authorizationParams } }),
|
|
462
|
-
...(input.metadata === undefined
|
|
387
|
+
...(input.metadata === undefined
|
|
388
|
+
? {}
|
|
389
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
463
390
|
});
|
|
464
391
|
export const makeGoogleOidcProvider = (input) => ({
|
|
465
392
|
id: input.id ?? googleOidcProviderId,
|
|
@@ -475,7 +402,9 @@ export const makeGoogleOidcProvider = (input) => ({
|
|
|
475
402
|
...(input.authorizationParams === undefined
|
|
476
403
|
? {}
|
|
477
404
|
: { authorizationParams: { ...input.authorizationParams } }),
|
|
478
|
-
...(input.metadata === undefined
|
|
405
|
+
...(input.metadata === undefined
|
|
406
|
+
? {}
|
|
407
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
479
408
|
});
|
|
480
409
|
export const makeMicrosoftOidcProvider = (input) => ({
|
|
481
410
|
id: input.id ?? microsoftOidcProviderId,
|
|
@@ -490,7 +419,9 @@ export const makeMicrosoftOidcProvider = (input) => ({
|
|
|
490
419
|
...(input.authorizationParams === undefined
|
|
491
420
|
? {}
|
|
492
421
|
: { authorizationParams: { ...input.authorizationParams } }),
|
|
493
|
-
...(input.metadata === undefined
|
|
422
|
+
...(input.metadata === undefined
|
|
423
|
+
? {}
|
|
424
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
494
425
|
});
|
|
495
426
|
export const makeGenericOidcProvider = (input) => ({
|
|
496
427
|
id: input.id,
|
|
@@ -510,7 +441,9 @@ export const makeGenericOidcProvider = (input) => ({
|
|
|
510
441
|
...(input.authorizationParams === undefined
|
|
511
442
|
? {}
|
|
512
443
|
: { authorizationParams: { ...input.authorizationParams } }),
|
|
513
|
-
...(input.metadata === undefined
|
|
444
|
+
...(input.metadata === undefined
|
|
445
|
+
? {}
|
|
446
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
514
447
|
});
|
|
515
448
|
const oauthClientSecretPost = (clientSecret) => ({
|
|
516
449
|
method: "client_secret_post",
|
|
@@ -577,7 +510,9 @@ const cloneProviderConfig = (provider) => ({
|
|
|
577
510
|
...(provider.authorizationParams === undefined
|
|
578
511
|
? {}
|
|
579
512
|
: { authorizationParams: { ...provider.authorizationParams } }),
|
|
580
|
-
...(provider.metadata === undefined
|
|
513
|
+
...(provider.metadata === undefined
|
|
514
|
+
? {}
|
|
515
|
+
: { metadata: metadataValue(provider.metadata) }),
|
|
581
516
|
});
|
|
582
517
|
const cloneOAuthClientRecord = (client) => ({
|
|
583
518
|
...client,
|
|
@@ -587,7 +522,9 @@ const cloneOAuthClientRecord = (client) => ({
|
|
|
587
522
|
...(client.allowedScopes === undefined
|
|
588
523
|
? {}
|
|
589
524
|
: { allowedScopes: [...client.allowedScopes] }),
|
|
590
|
-
...(client.metadata === undefined
|
|
525
|
+
...(client.metadata === undefined
|
|
526
|
+
? {}
|
|
527
|
+
: { metadata: metadataValue(client.metadata) }),
|
|
591
528
|
});
|
|
592
529
|
const validateOAuthClientRedirectUriRecord = (client, input) => {
|
|
593
530
|
if (client === undefined) {
|
|
@@ -630,18 +567,24 @@ const isOAuthConsentActive = (record, now, scopes = []) => record.revokedAt ===
|
|
|
630
567
|
const cloneOAuthClientSecretRecord = (record) => ({
|
|
631
568
|
...record,
|
|
632
569
|
authenticationMethods: [...record.authenticationMethods],
|
|
633
|
-
...(record.metadata === undefined
|
|
570
|
+
...(record.metadata === undefined
|
|
571
|
+
? {}
|
|
572
|
+
: { metadata: metadataValue(record.metadata) }),
|
|
634
573
|
});
|
|
635
574
|
const cloneAuthorizationCodeRecord = (record) => ({
|
|
636
575
|
...record,
|
|
637
576
|
scopes: [...record.scopes],
|
|
638
|
-
...(record.metadata === undefined
|
|
577
|
+
...(record.metadata === undefined
|
|
578
|
+
? {}
|
|
579
|
+
: { metadata: metadataValue(record.metadata) }),
|
|
639
580
|
});
|
|
640
581
|
const cloneOAuthTokenResponse = (tokens) => ({
|
|
641
582
|
accessToken: tokens.accessToken,
|
|
642
583
|
tokenType: tokens.tokenType,
|
|
643
584
|
...(tokens.expiresIn === undefined ? {} : { expiresIn: tokens.expiresIn }),
|
|
644
|
-
...(tokens.refreshToken === undefined
|
|
585
|
+
...(tokens.refreshToken === undefined
|
|
586
|
+
? {}
|
|
587
|
+
: { refreshToken: tokens.refreshToken }),
|
|
645
588
|
...(tokens.idToken === undefined ? {} : { idToken: tokens.idToken }),
|
|
646
589
|
...(tokens.scopes === undefined ? {} : { scopes: [...tokens.scopes] }),
|
|
647
590
|
...(tokens.extra === undefined ? {} : { extra: metadataValue(tokens.extra) }),
|
|
@@ -649,14 +592,30 @@ const cloneOAuthTokenResponse = (tokens) => ({
|
|
|
649
592
|
const cloneOAuthTokenIntrospectionResponse = (response) => response.active
|
|
650
593
|
? {
|
|
651
594
|
active: true,
|
|
652
|
-
...(response.scopes === undefined
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
...(response.
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
...(response.
|
|
659
|
-
|
|
595
|
+
...(response.scopes === undefined
|
|
596
|
+
? {}
|
|
597
|
+
: { scopes: [...response.scopes] }),
|
|
598
|
+
...(response.clientId === undefined
|
|
599
|
+
? {}
|
|
600
|
+
: { clientId: response.clientId }),
|
|
601
|
+
...(response.username === undefined
|
|
602
|
+
? {}
|
|
603
|
+
: { username: response.username }),
|
|
604
|
+
...(response.tokenType === undefined
|
|
605
|
+
? {}
|
|
606
|
+
: { tokenType: response.tokenType }),
|
|
607
|
+
...(response.expiresAt === undefined
|
|
608
|
+
? {}
|
|
609
|
+
: { expiresAt: response.expiresAt }),
|
|
610
|
+
...(response.issuedAt === undefined
|
|
611
|
+
? {}
|
|
612
|
+
: { issuedAt: response.issuedAt }),
|
|
613
|
+
...(response.notBefore === undefined
|
|
614
|
+
? {}
|
|
615
|
+
: { notBefore: response.notBefore }),
|
|
616
|
+
...(response.subject === undefined
|
|
617
|
+
? {}
|
|
618
|
+
: { subject: response.subject }),
|
|
660
619
|
...(response.audience === undefined
|
|
661
620
|
? {}
|
|
662
621
|
: {
|
|
@@ -666,7 +625,9 @@ const cloneOAuthTokenIntrospectionResponse = (response) => response.active
|
|
|
666
625
|
}),
|
|
667
626
|
...(response.issuer === undefined ? {} : { issuer: response.issuer }),
|
|
668
627
|
...(response.jwtId === undefined ? {} : { jwtId: response.jwtId }),
|
|
669
|
-
...(response.extra === undefined
|
|
628
|
+
...(response.extra === undefined
|
|
629
|
+
? {}
|
|
630
|
+
: { extra: metadataValue(response.extra) }),
|
|
670
631
|
}
|
|
671
632
|
: { active: false };
|
|
672
633
|
const cloneOAuthProviderModeTokenRecord = (record) => ({
|
|
@@ -679,7 +640,9 @@ const cloneOAuthProviderModeTokenRecord = (record) => ({
|
|
|
679
640
|
? [...record.audience]
|
|
680
641
|
: record.audience,
|
|
681
642
|
}),
|
|
682
|
-
...(record.metadata === undefined
|
|
643
|
+
...(record.metadata === undefined
|
|
644
|
+
? {}
|
|
645
|
+
: { metadata: metadataValue(record.metadata) }),
|
|
683
646
|
});
|
|
684
647
|
const consumedAuthorizationCode = (record, consumedAt) => ({
|
|
685
648
|
clientId: record.clientId,
|
|
@@ -695,7 +658,9 @@ const consumedAuthorizationCode = (record, consumedAt) => ({
|
|
|
695
658
|
issuedAt: record.issuedAt,
|
|
696
659
|
expiresAt: record.expiresAt,
|
|
697
660
|
consumedAt,
|
|
698
|
-
...(record.metadata === undefined
|
|
661
|
+
...(record.metadata === undefined
|
|
662
|
+
? {}
|
|
663
|
+
: { metadata: metadataValue(record.metadata) }),
|
|
699
664
|
});
|
|
700
665
|
const issuedAuthorizationCode = (input) => ({
|
|
701
666
|
code: Redacted.make(input.code),
|
|
@@ -914,7 +879,9 @@ const oauthLinkConfirmationMetadata = (input) => ({
|
|
|
914
879
|
userId: input.userId,
|
|
915
880
|
providerId: input.identity.providerId,
|
|
916
881
|
providerAccountId: input.identity.providerAccountId,
|
|
917
|
-
...(input.identity.email === undefined
|
|
882
|
+
...(input.identity.email === undefined
|
|
883
|
+
? {}
|
|
884
|
+
: { email: input.identity.email }),
|
|
918
885
|
...(input.identity.emailVerified === undefined
|
|
919
886
|
? {}
|
|
920
887
|
: { emailVerified: input.identity.emailVerified }),
|
|
@@ -922,7 +889,9 @@ const oauthLinkConfirmationMetadata = (input) => ({
|
|
|
922
889
|
? {}
|
|
923
890
|
: { identityMetadata: metadataValue(input.identity.metadata) }),
|
|
924
891
|
reason: input.reason,
|
|
925
|
-
...(input.metadata === undefined
|
|
892
|
+
...(input.metadata === undefined
|
|
893
|
+
? {}
|
|
894
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
926
895
|
});
|
|
927
896
|
const pendingOAuthLinkConfirmationFromChallenge = (challenge, operation) => {
|
|
928
897
|
const metadata = challenge.metadata ?? {};
|
|
@@ -951,10 +920,11 @@ const pendingOAuthLinkConfirmationFromChallenge = (challenge, operation) => {
|
|
|
951
920
|
? {}
|
|
952
921
|
: { metadata: metadataValue(identityMetadata) }),
|
|
953
922
|
},
|
|
954
|
-
reason: stringFromUnknown(metadata.reason) ??
|
|
955
|
-
"manual",
|
|
923
|
+
reason: stringFromUnknown(metadata.reason) ?? "manual",
|
|
956
924
|
expiresAt: challenge.expiresAt,
|
|
957
|
-
...(appMetadata === undefined
|
|
925
|
+
...(appMetadata === undefined
|
|
926
|
+
? {}
|
|
927
|
+
: { metadata: metadataValue(appMetadata) }),
|
|
958
928
|
});
|
|
959
929
|
};
|
|
960
930
|
const confirmedOAuthLinkConfirmationFromPending = (input) => ({
|
|
@@ -988,7 +958,9 @@ const makeOAuthProfile = (input) => ({
|
|
|
988
958
|
...(input.name === undefined ? {} : { name: input.name }),
|
|
989
959
|
...(input.username === undefined ? {} : { username: input.username }),
|
|
990
960
|
...(input.avatarUrl === undefined ? {} : { avatarUrl: input.avatarUrl }),
|
|
991
|
-
...(input.metadata === undefined
|
|
961
|
+
...(input.metadata === undefined
|
|
962
|
+
? {}
|
|
963
|
+
: { metadata: metadataValue(input.metadata) }),
|
|
992
964
|
});
|
|
993
965
|
const oauthJwksPublicJwkFromUnknown = (value) => {
|
|
994
966
|
const record = recordFromUnknown(value);
|
|
@@ -1061,7 +1033,9 @@ const oauthJwksRecordsFromDocument = (provider, document, allowedAlgorithms) =>
|
|
|
1061
1033
|
},
|
|
1062
1034
|
}));
|
|
1063
1035
|
});
|
|
1064
|
-
const oauthJwksKeyUsableAt = (key, now) => now === undefined ||
|
|
1036
|
+
const oauthJwksKeyUsableAt = (key, now) => now === undefined ||
|
|
1037
|
+
key.expiresAt === undefined ||
|
|
1038
|
+
Number(now) < Number(key.expiresAt);
|
|
1065
1039
|
const oauthJwksVerificationKeyMatches = (key, input) => key.id === input.kid &&
|
|
1066
1040
|
key.status !== "disabled" &&
|
|
1067
1041
|
key.publicJwk !== undefined &&
|
|
@@ -1231,7 +1205,7 @@ export const decodeOAuthTokenResponse = (value) => Effect.gen(function* () {
|
|
|
1231
1205
|
extra: tokenResponseExtra(value),
|
|
1232
1206
|
};
|
|
1233
1207
|
});
|
|
1234
|
-
export const makeOidcIdTokenVerifier = (dependencies) => OidcIdTokenVerifier.
|
|
1208
|
+
export const makeOidcIdTokenVerifier = (dependencies) => OidcIdTokenVerifier.of({
|
|
1235
1209
|
verify: Effect.fn("auth.oidc_id_token.verify")(function* (input) {
|
|
1236
1210
|
const { provider } = input;
|
|
1237
1211
|
const { issuer } = provider;
|
|
@@ -1255,7 +1229,10 @@ export const makeOidcIdTokenVerifier = (dependencies) => OidcIdTokenVerifier.mak
|
|
|
1255
1229
|
}
|
|
1256
1230
|
const claims = oidcIdTokenClaims(verified.claims, input);
|
|
1257
1231
|
if (typeof claims === "string") {
|
|
1258
|
-
return {
|
|
1232
|
+
return {
|
|
1233
|
+
valid: false,
|
|
1234
|
+
reason: claims,
|
|
1235
|
+
};
|
|
1259
1236
|
}
|
|
1260
1237
|
return {
|
|
1261
1238
|
valid: true,
|
|
@@ -1305,7 +1282,7 @@ export const makeOAuthJwksJwtKeys = (dependencies) => {
|
|
|
1305
1282
|
};
|
|
1306
1283
|
return records;
|
|
1307
1284
|
});
|
|
1308
|
-
return JwtKeys.
|
|
1285
|
+
return JwtKeys.of({
|
|
1309
1286
|
selectSigningKey: () => Effect.succeed(Option.none()),
|
|
1310
1287
|
findVerificationKey: Effect.fn("auth.oauth_jwks.find_verification_key")(function* (input) {
|
|
1311
1288
|
const now = yield* oauthJwksNow(input.now);
|
|
@@ -1332,7 +1309,9 @@ export const normalizeOidcProfile = (input) => Effect.gen(function* () {
|
|
|
1332
1309
|
return yield* oauthProfileNormalizationError("missing_subject", "OIDC profile is missing subject");
|
|
1333
1310
|
}
|
|
1334
1311
|
const userInfo = yield* userInfoRecord(input.userInfo);
|
|
1335
|
-
const userInfoSubject = userInfo === undefined
|
|
1312
|
+
const userInfoSubject = userInfo === undefined
|
|
1313
|
+
? undefined
|
|
1314
|
+
: nonEmptyStringFromUnknown(userInfo.sub);
|
|
1336
1315
|
if (userInfoSubject !== undefined && userInfoSubject !== subject) {
|
|
1337
1316
|
return yield* oauthProfileNormalizationError("subject_mismatch", "OIDC userinfo subject does not match ID token subject");
|
|
1338
1317
|
}
|
|
@@ -1353,7 +1332,7 @@ export const normalizeOidcProfile = (input) => Effect.gen(function* () {
|
|
|
1353
1332
|
metadata,
|
|
1354
1333
|
});
|
|
1355
1334
|
});
|
|
1356
|
-
export const makeOidcOAuthProfileNormalizer = () => OAuthProfileNormalizer.
|
|
1335
|
+
export const makeOidcOAuthProfileNormalizer = () => OAuthProfileNormalizer.of({
|
|
1357
1336
|
normalize: Effect.fn("auth.oauth_profile.normalize_oidc")(normalizeOidcProfile),
|
|
1358
1337
|
});
|
|
1359
1338
|
export const normalizeOAuthProfile = (input) => OAuthProfileNormalizer.use((normalizer) => normalizer.normalize(input));
|
|
@@ -1361,7 +1340,9 @@ export const verifiedOAuthIdentityFromProfile = (profile) => {
|
|
|
1361
1340
|
const metadata = optionalRecord({
|
|
1362
1341
|
...(profile.name === undefined ? {} : { name: profile.name }),
|
|
1363
1342
|
...(profile.username === undefined ? {} : { username: profile.username }),
|
|
1364
|
-
...(profile.avatarUrl === undefined
|
|
1343
|
+
...(profile.avatarUrl === undefined
|
|
1344
|
+
? {}
|
|
1345
|
+
: { avatarUrl: profile.avatarUrl }),
|
|
1365
1346
|
...(profile.metadata === undefined ? {} : profile.metadata),
|
|
1366
1347
|
});
|
|
1367
1348
|
return {
|
|
@@ -1374,7 +1355,7 @@ export const verifiedOAuthIdentityFromProfile = (profile) => {
|
|
|
1374
1355
|
...(metadata === undefined ? {} : { metadata: metadataValue(metadata) }),
|
|
1375
1356
|
};
|
|
1376
1357
|
};
|
|
1377
|
-
export const makeOAuthTokenExchange = (dependencies) => OAuthTokenExchange.
|
|
1358
|
+
export const makeOAuthTokenExchange = (dependencies) => OAuthTokenExchange.of({
|
|
1378
1359
|
exchangeAuthorizationCode: Effect.fn("auth.oauth_token.exchange_code")(function* (input) {
|
|
1379
1360
|
const request = yield* makeOAuthTokenRequest(input);
|
|
1380
1361
|
const response = yield* dependencies.request(request);
|
|
@@ -1413,9 +1394,13 @@ const storeOAuthProviderTokenResponse = (dependencies, input, operation) => Effe
|
|
|
1413
1394
|
accessTokenCiphertext,
|
|
1414
1395
|
tokenType: input.tokens.tokenType,
|
|
1415
1396
|
updatedAt: now,
|
|
1416
|
-
...(refreshTokenCiphertext === undefined
|
|
1397
|
+
...(refreshTokenCiphertext === undefined
|
|
1398
|
+
? {}
|
|
1399
|
+
: { refreshTokenCiphertext }),
|
|
1417
1400
|
...(idTokenCiphertext === undefined ? {} : { idTokenCiphertext }),
|
|
1418
|
-
...(input.tokens.scopes === undefined
|
|
1401
|
+
...(input.tokens.scopes === undefined
|
|
1402
|
+
? {}
|
|
1403
|
+
: { scopes: input.tokens.scopes }),
|
|
1419
1404
|
...(expiresAt === undefined ? {} : { expiresAt }),
|
|
1420
1405
|
})
|
|
1421
1406
|
.pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError(operation, "Failed to store OAuth provider token ciphertext", cause)));
|
|
@@ -1427,7 +1412,9 @@ const storeOAuthProviderTokenResponse = (dependencies, input, operation) => Effe
|
|
|
1427
1412
|
};
|
|
1428
1413
|
});
|
|
1429
1414
|
const revokeOAuthProviderTokenCiphertext = (dependencies, input, tokenCiphertext, tokenTypeHint) => Effect.gen(function* () {
|
|
1430
|
-
const token = yield* dependencies
|
|
1415
|
+
const token = yield* dependencies
|
|
1416
|
+
.decryptToken(tokenCiphertext)
|
|
1417
|
+
.pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("revoke", `Failed to decrypt OAuth provider ${tokenTypeHint}`, cause)));
|
|
1431
1418
|
const request = yield* makeOAuthTokenRevocationRequest({
|
|
1432
1419
|
provider: input.provider,
|
|
1433
1420
|
token,
|
|
@@ -1437,9 +1424,11 @@ const revokeOAuthProviderTokenCiphertext = (dependencies, input, tokenCiphertext
|
|
|
1437
1424
|
: { clientAuthentication: input.clientAuthentication }),
|
|
1438
1425
|
...(input.params === undefined ? {} : { params: input.params }),
|
|
1439
1426
|
}).pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("revoke", "Failed to build OAuth provider token revocation request", cause)));
|
|
1440
|
-
yield* dependencies
|
|
1427
|
+
yield* dependencies
|
|
1428
|
+
.request(request)
|
|
1429
|
+
.pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("revoke", "Failed to execute OAuth provider token revocation request", cause)));
|
|
1441
1430
|
});
|
|
1442
|
-
export const makeOAuthProviderTokenLifecycle = (dependencies) => OAuthProviderTokenLifecycle.
|
|
1431
|
+
export const makeOAuthProviderTokenLifecycle = (dependencies) => OAuthProviderTokenLifecycle.of({
|
|
1443
1432
|
store: Effect.fn("auth.oauth_provider_token_lifecycle.store")(function* (input) {
|
|
1444
1433
|
return yield* storeOAuthProviderTokenResponse(dependencies, input, "store");
|
|
1445
1434
|
}),
|
|
@@ -1465,7 +1454,9 @@ export const makeOAuthProviderTokenLifecycle = (dependencies) => OAuthProviderTo
|
|
|
1465
1454
|
: { clientAuthentication: input.clientAuthentication }),
|
|
1466
1455
|
...(input.params === undefined ? {} : { params: input.params }),
|
|
1467
1456
|
}).pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("refresh", "Failed to build OAuth provider token refresh request", cause)));
|
|
1468
|
-
const rawResponse = yield* dependencies
|
|
1457
|
+
const rawResponse = yield* dependencies
|
|
1458
|
+
.request(request)
|
|
1459
|
+
.pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("refresh", "Failed to execute OAuth provider token refresh request", cause)));
|
|
1469
1460
|
const tokens = yield* decodeOAuthTokenResponse(rawResponse).pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("refresh", "Failed to decode OAuth provider token refresh response", cause)));
|
|
1470
1461
|
const stored = yield* storeOAuthProviderTokenResponse(dependencies, {
|
|
1471
1462
|
accountId: input.accountId,
|
|
@@ -1531,13 +1522,15 @@ export const completeOAuthCallback = (input) => Effect.gen(function* () {
|
|
|
1531
1522
|
provider: input.provider,
|
|
1532
1523
|
code: input.code,
|
|
1533
1524
|
codeVerifier: input.codeVerifier,
|
|
1534
|
-
redirectUri: input.redirectUri ??
|
|
1525
|
+
redirectUri: input.redirectUri ??
|
|
1526
|
+
verifiedState.redirectUri ??
|
|
1527
|
+
input.provider.redirectUri,
|
|
1535
1528
|
clientAuthentication: input.clientAuthentication,
|
|
1536
1529
|
params: input.tokenParams,
|
|
1537
1530
|
});
|
|
1538
1531
|
return { state: verifiedState, tokens };
|
|
1539
1532
|
});
|
|
1540
|
-
export const makeOAuthAccountLinkingPolicy = (dependencies) => OAuthAccountLinking.
|
|
1533
|
+
export const makeOAuthAccountLinkingPolicy = (dependencies) => OAuthAccountLinking.of({
|
|
1541
1534
|
resolve: Effect.fn("auth.oauth_account_linking.resolve")(function* (input) {
|
|
1542
1535
|
const identity = cloneVerifiedOAuthIdentity(input.identity);
|
|
1543
1536
|
const linked = yield* dependencies.accounts
|
|
@@ -1585,7 +1578,9 @@ export const makeOAuthAccountLinkingPolicy = (dependencies) => OAuthAccountLinki
|
|
|
1585
1578
|
}
|
|
1586
1579
|
return {
|
|
1587
1580
|
type: "require-explicit-linking",
|
|
1588
|
-
reason: identity.emailVerified === true
|
|
1581
|
+
reason: identity.emailVerified === true
|
|
1582
|
+
? "matched-email"
|
|
1583
|
+
: "unverified-email",
|
|
1589
1584
|
identity,
|
|
1590
1585
|
matchedUserId: input.matchedUserId,
|
|
1591
1586
|
};
|
|
@@ -1598,7 +1593,119 @@ export const makeOAuthAccountLinkingPolicy = (dependencies) => OAuthAccountLinki
|
|
|
1598
1593
|
}),
|
|
1599
1594
|
});
|
|
1600
1595
|
export const resolveOAuthAccountLinking = (input) => OAuthAccountLinking.use((linking) => linking.resolve(input));
|
|
1601
|
-
export const
|
|
1596
|
+
export const makeOAuthIdentityBridge = (dependencies) => OAuthIdentityBridge.of({
|
|
1597
|
+
resolve: Effect.fn("auth.oauth_identity_bridge.resolve")(function* (input) {
|
|
1598
|
+
const identity = cloneVerifiedOAuthIdentity(input.identity);
|
|
1599
|
+
const mapError = (message) => (cause) => new OAuthIdentityBridgeError({ message, cause });
|
|
1600
|
+
const initial = yield* dependencies.linking
|
|
1601
|
+
.resolve({ identity, currentUserId: input.currentUserId })
|
|
1602
|
+
.pipe(Effect.mapError(mapError("Failed to resolve OAuth account")));
|
|
1603
|
+
if (initial.type !== "require-explicit-linking") {
|
|
1604
|
+
return initial;
|
|
1605
|
+
}
|
|
1606
|
+
const decision = yield* dependencies.policy.decide({
|
|
1607
|
+
identity,
|
|
1608
|
+
currentUserId: input.currentUserId,
|
|
1609
|
+
});
|
|
1610
|
+
if (decision.type === "deny") {
|
|
1611
|
+
return { type: "deny", reason: decision.reason, identity };
|
|
1612
|
+
}
|
|
1613
|
+
const trustedVerifiedEmail = decision.trustVerifiedEmail === true &&
|
|
1614
|
+
identity.emailVerified === true &&
|
|
1615
|
+
identity.email !== undefined;
|
|
1616
|
+
const normalizedEmail = trustedVerifiedEmail
|
|
1617
|
+
? yield* normalizeEmail(identity.email).pipe(Effect.mapError(mapError("Provider returned an invalid email claim")))
|
|
1618
|
+
: undefined;
|
|
1619
|
+
const matched = normalizedEmail === undefined
|
|
1620
|
+
? Option.none()
|
|
1621
|
+
: yield* dependencies.identities
|
|
1622
|
+
.findByKindAndNormalizedValue({
|
|
1623
|
+
scope: globalIdentityScope,
|
|
1624
|
+
kind: "email",
|
|
1625
|
+
normalizedValue: normalizedEmail,
|
|
1626
|
+
})
|
|
1627
|
+
.pipe(Effect.mapError(mapError("Failed to resolve provider email")));
|
|
1628
|
+
const linking = Option.isNone(matched)
|
|
1629
|
+
? initial
|
|
1630
|
+
: yield* dependencies.linking
|
|
1631
|
+
.resolve({
|
|
1632
|
+
identity,
|
|
1633
|
+
currentUserId: input.currentUserId,
|
|
1634
|
+
matchedUserId: matched.value.userId,
|
|
1635
|
+
})
|
|
1636
|
+
.pipe(Effect.mapError(mapError("Failed to resolve OAuth linking")));
|
|
1637
|
+
if (linking.type !== "require-explicit-linking") {
|
|
1638
|
+
return linking;
|
|
1639
|
+
}
|
|
1640
|
+
if (Option.isSome(matched)) {
|
|
1641
|
+
return linking;
|
|
1642
|
+
}
|
|
1643
|
+
if (!decision.createUser) {
|
|
1644
|
+
return {
|
|
1645
|
+
type: "deny",
|
|
1646
|
+
reason: "user-creation-not-permitted",
|
|
1647
|
+
identity,
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
const user = input.makeUser();
|
|
1651
|
+
const account = input.makeAccount(user.id);
|
|
1652
|
+
if (account.userId !== user.id) {
|
|
1653
|
+
return yield* new OAuthIdentityBridgeError({
|
|
1654
|
+
message: "OAuth account user does not match the new user",
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
const emailIdentity = decision.createEmailIdentity === true && normalizedEmail !== undefined
|
|
1658
|
+
? input.makeEmailIdentity(user.id, identity.email, normalizedEmail)
|
|
1659
|
+
: undefined;
|
|
1660
|
+
if (emailIdentity !== undefined && emailIdentity.userId !== user.id) {
|
|
1661
|
+
return yield* new OAuthIdentityBridgeError({
|
|
1662
|
+
message: "Email identity user does not match the new user",
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
const created = yield* dependencies.store
|
|
1666
|
+
.create({ user, account, identity: emailIdentity })
|
|
1667
|
+
.pipe(Effect.catchTag("OAuthIdentityBridgeConflictError", (conflict) => {
|
|
1668
|
+
if (conflict.reason === "provider-account" ||
|
|
1669
|
+
conflict.reason === "oauth-account-id") {
|
|
1670
|
+
return dependencies.linking
|
|
1671
|
+
.resolve({ identity, currentUserId: input.currentUserId })
|
|
1672
|
+
.pipe(Effect.mapError(mapError("Failed to resolve OAuth race")));
|
|
1673
|
+
}
|
|
1674
|
+
if (conflict.reason === "identity-value") {
|
|
1675
|
+
return dependencies.identities
|
|
1676
|
+
.findByKindAndNormalizedValue({
|
|
1677
|
+
scope: globalIdentityScope,
|
|
1678
|
+
kind: "email",
|
|
1679
|
+
normalizedValue: normalizedEmail,
|
|
1680
|
+
})
|
|
1681
|
+
.pipe(Effect.mapError(mapError("Failed to resolve email collision")), Effect.map((collision) => ({
|
|
1682
|
+
type: "require-explicit-linking",
|
|
1683
|
+
reason: "matched-email",
|
|
1684
|
+
identity,
|
|
1685
|
+
...(Option.isSome(collision)
|
|
1686
|
+
? { matchedUserId: collision.value.userId }
|
|
1687
|
+
: {}),
|
|
1688
|
+
})));
|
|
1689
|
+
}
|
|
1690
|
+
return Effect.fail(new OAuthIdentityBridgeError({
|
|
1691
|
+
message: `OAuth identity creation conflicted on ${conflict.reason}`,
|
|
1692
|
+
cause: conflict,
|
|
1693
|
+
}));
|
|
1694
|
+
}), Effect.mapError((cause) => cause instanceof OAuthIdentityBridgeError
|
|
1695
|
+
? cause
|
|
1696
|
+
: mapError("Failed to create OAuth identity")(cause)));
|
|
1697
|
+
if ("type" in created) {
|
|
1698
|
+
return created;
|
|
1699
|
+
}
|
|
1700
|
+
return {
|
|
1701
|
+
type: "created",
|
|
1702
|
+
reason: "new-provider-account",
|
|
1703
|
+
...created,
|
|
1704
|
+
};
|
|
1705
|
+
}),
|
|
1706
|
+
});
|
|
1707
|
+
export const resolveOAuthIdentityBridge = (input) => OAuthIdentityBridge.use((bridge) => bridge.resolve(input));
|
|
1708
|
+
export const makeOAuthAccountUnlinkingPolicy = (dependencies) => OAuthAccountUnlinking.of({
|
|
1602
1709
|
resolve: Effect.fn("auth.oauth_account_unlinking.resolve")(function* (input) {
|
|
1603
1710
|
const account = yield* dependencies.accounts
|
|
1604
1711
|
.findByProviderAccount({
|
|
@@ -1627,7 +1734,8 @@ export const makeOAuthAccountUnlinkingPolicy = (dependencies) => OAuthAccountUnl
|
|
|
1627
1734
|
const remainingAccounts = yield* dependencies.accounts
|
|
1628
1735
|
.listByUser({ userId: input.userId })
|
|
1629
1736
|
.pipe(Effect.map((accounts) => accounts.filter((linked) => linked.id !== linkedAccount.id)), Effect.mapError((cause) => oauthAccountUnlinkingError("resolve", "Failed to list OAuth provider accounts for user", cause)));
|
|
1630
|
-
if (dependencies.allowLastAccount !== true &&
|
|
1737
|
+
if (dependencies.allowLastAccount !== true &&
|
|
1738
|
+
remainingAccounts.length === 0) {
|
|
1631
1739
|
return {
|
|
1632
1740
|
type: "deny-last-account",
|
|
1633
1741
|
reason: "last-linked-account",
|
|
@@ -1635,7 +1743,8 @@ export const makeOAuthAccountUnlinkingPolicy = (dependencies) => OAuthAccountUnl
|
|
|
1635
1743
|
account: linkedAccount,
|
|
1636
1744
|
};
|
|
1637
1745
|
}
|
|
1638
|
-
if (dependencies.requireStepUp === true &&
|
|
1746
|
+
if (dependencies.requireStepUp === true &&
|
|
1747
|
+
input.stepUpSatisfied !== true) {
|
|
1639
1748
|
return {
|
|
1640
1749
|
type: "requires-step-up",
|
|
1641
1750
|
reason: "step-up-required",
|
|
@@ -1668,7 +1777,7 @@ const findOAuthLinkConfirmationExistingAccount = (dependencies, input) => depend
|
|
|
1668
1777
|
}
|
|
1669
1778
|
return Effect.succeed(account);
|
|
1670
1779
|
}));
|
|
1671
|
-
export const makeOAuthLinkConfirmation = (dependencies) => OAuthLinkConfirmation.
|
|
1780
|
+
export const makeOAuthLinkConfirmation = (dependencies) => OAuthLinkConfirmation.of({
|
|
1672
1781
|
start: Effect.fn("auth.oauth_link_confirmation.start")(function* (input) {
|
|
1673
1782
|
const identity = cloneVerifiedOAuthIdentity(input.identity);
|
|
1674
1783
|
const reason = input.reason ?? "manual";
|
|
@@ -1682,7 +1791,8 @@ export const makeOAuthLinkConfirmation = (dependencies) => OAuthLinkConfirmation
|
|
|
1682
1791
|
}
|
|
1683
1792
|
const secret = input.secret ??
|
|
1684
1793
|
(yield* dependencies.crypto
|
|
1685
|
-
.randomToken(yield* validateOAuthLinkConfirmationSecretBytes(dependencies.secretBytes ??
|
|
1794
|
+
.randomToken(yield* validateOAuthLinkConfirmationSecretBytes(dependencies.secretBytes ??
|
|
1795
|
+
defaultOAuthLinkConfirmationSecretBytes))
|
|
1686
1796
|
.pipe(Effect.map(Redacted.make), Effect.mapError((cause) => oauthLinkConfirmationError("start", "Failed to generate OAuth link confirmation secret", cause))));
|
|
1687
1797
|
const issued = yield* dependencies.challenge
|
|
1688
1798
|
.issue({
|
|
@@ -1735,7 +1845,8 @@ export const makeOAuthLinkConfirmation = (dependencies) => OAuthLinkConfirmation
|
|
|
1735
1845
|
})
|
|
1736
1846
|
.pipe(Effect.mapError((cause) => oauthLinkConfirmationError("confirm", "Invalid OAuth link confirmation challenge", cause)));
|
|
1737
1847
|
const pending = yield* pendingOAuthLinkConfirmationFromChallenge(inspected, "confirm");
|
|
1738
|
-
if (input.currentUserId !== undefined &&
|
|
1848
|
+
if (input.currentUserId !== undefined &&
|
|
1849
|
+
input.currentUserId !== pending.userId) {
|
|
1739
1850
|
return yield* oauthLinkConfirmationError("confirm", "OAuth link confirmation does not match current user");
|
|
1740
1851
|
}
|
|
1741
1852
|
if (input.expectedProviderId !== undefined &&
|
|
@@ -1760,7 +1871,9 @@ export const makeOAuthLinkConfirmation = (dependencies) => OAuthLinkConfirmation
|
|
|
1760
1871
|
.pipe(Effect.mapError((cause) => oauthLinkConfirmationError("confirm", "Failed to consume OAuth link confirmation challenge", cause)));
|
|
1761
1872
|
return confirmedOAuthLinkConfirmationFromPending({
|
|
1762
1873
|
pending,
|
|
1763
|
-
...(Option.isSome(existing)
|
|
1874
|
+
...(Option.isSome(existing)
|
|
1875
|
+
? { existingAccount: existing.value }
|
|
1876
|
+
: {}),
|
|
1764
1877
|
});
|
|
1765
1878
|
}),
|
|
1766
1879
|
});
|
|
@@ -1784,7 +1897,9 @@ const makeOAuthPkceWithCrypto = (dependencies, input) => Effect.gen(function* ()
|
|
|
1784
1897
|
codeChallengeMethod: "S256",
|
|
1785
1898
|
};
|
|
1786
1899
|
});
|
|
1787
|
-
const authorizationCodeHash = (crypto, code, operation) => crypto
|
|
1900
|
+
const authorizationCodeHash = (crypto, code, operation) => crypto
|
|
1901
|
+
.digestSha256({ data: String(code) })
|
|
1902
|
+
.pipe(Effect.mapError((cause) => oauthAuthorizationCodeGrantError(operation, "Failed to hash OAuth authorization code", cause)));
|
|
1788
1903
|
const pkceChallengeForVerifier = (crypto, verifier) => crypto.digestSha256({ data: Redacted.value(verifier) }).pipe(Effect.map(OAuthCodeChallenge), Effect.mapError((cause) => oauthAuthorizationCodeGrantError("consume", "Failed to calculate OAuth PKCE challenge", cause)));
|
|
1789
1904
|
const timingSafeEqualString = (crypto, left, right) => crypto
|
|
1790
1905
|
.timingSafeEqual({
|
|
@@ -1798,7 +1913,7 @@ const authorizationCodeExpiresAt = (input, issuedAt, defaultTtl) => input.expire
|
|
|
1798
1913
|
export const makeOAuthAuthorizationCodeGrant = (dependencies) => {
|
|
1799
1914
|
const codeBytes = dependencies.codeBytes ?? defaultOAuthAuthorizationCodeBytes;
|
|
1800
1915
|
const codeTtl = dependencies.codeTtl ?? defaultOAuthAuthorizationCodeTtl;
|
|
1801
|
-
return OAuthAuthorizationCodeGrant.
|
|
1916
|
+
return OAuthAuthorizationCodeGrant.of({
|
|
1802
1917
|
issue: Effect.fn("auth.oauth.authorization_code.issue")(function* (input) {
|
|
1803
1918
|
const issuedAt = input.issuedAt ?? (yield* currentUnixMillis);
|
|
1804
1919
|
const expiresAt = authorizationCodeExpiresAt(input, issuedAt, codeTtl);
|
|
@@ -1832,13 +1947,17 @@ export const makeOAuthAuthorizationCodeGrant = (dependencies) => {
|
|
|
1832
1947
|
? {}
|
|
1833
1948
|
: { metadata: metadataValue(input.metadata) }),
|
|
1834
1949
|
};
|
|
1835
|
-
yield* dependencies.store
|
|
1950
|
+
yield* dependencies.store
|
|
1951
|
+
.upsert(record)
|
|
1952
|
+
.pipe(Effect.mapError((cause) => oauthAuthorizationCodeGrantError("issue", "Failed to store OAuth authorization code", cause)));
|
|
1836
1953
|
return issuedAuthorizationCode({ code, record });
|
|
1837
1954
|
}),
|
|
1838
1955
|
consume: Effect.fn("auth.oauth.authorization_code.consume")(function* (input) {
|
|
1839
1956
|
const now = input.now ?? (yield* currentUnixMillis);
|
|
1840
1957
|
const codeHash = yield* authorizationCodeHash(dependencies.crypto, authorizationCodeValue(input.code), "consume");
|
|
1841
|
-
const recordOption = yield* dependencies.store
|
|
1958
|
+
const recordOption = yield* dependencies.store
|
|
1959
|
+
.findByHash({ codeHash })
|
|
1960
|
+
.pipe(Effect.mapError((cause) => oauthAuthorizationCodeGrantError("consume", "Failed to load OAuth authorization code", cause)));
|
|
1842
1961
|
if (Option.isNone(recordOption)) {
|
|
1843
1962
|
return { valid: false, reason: "unknown_code" };
|
|
1844
1963
|
}
|
|
@@ -1893,7 +2012,7 @@ const oauthTokenGrantString = (value) => {
|
|
|
1893
2012
|
return trimmed === undefined || trimmed === "" ? undefined : trimmed;
|
|
1894
2013
|
};
|
|
1895
2014
|
const oauthTokenGrantScopes = (scopes) => {
|
|
1896
|
-
const values = typeof scopes === "string" ? scopes.split(/\s+/) : scopes ?? [];
|
|
2015
|
+
const values = typeof scopes === "string" ? scopes.split(/\s+/) : (scopes ?? []);
|
|
1897
2016
|
const unique = new Set();
|
|
1898
2017
|
for (const value of values) {
|
|
1899
2018
|
const scope = value.trim();
|
|
@@ -1903,17 +2022,24 @@ const oauthTokenGrantScopes = (scopes) => {
|
|
|
1903
2022
|
}
|
|
1904
2023
|
return [...unique];
|
|
1905
2024
|
};
|
|
1906
|
-
const oauthTokenGrantScopesAllowed = (scopes, allowedScopes) => allowedScopes === undefined ||
|
|
2025
|
+
const oauthTokenGrantScopesAllowed = (scopes, allowedScopes) => allowedScopes === undefined ||
|
|
2026
|
+
scopes.every((scope) => allowedScopes.includes(scope));
|
|
1907
2027
|
const validateOAuthProviderModeOpaqueTokenBytes = (value, label, error) => Number.isInteger(value) && value >= 16 && value <= 128
|
|
1908
2028
|
? Effect.succeed(value)
|
|
1909
2029
|
: Effect.fail(error(`${label} byte length must be an integer between 16 and 128`));
|
|
1910
2030
|
const generateOAuthProviderModeOpaqueToken = (crypto, byteLength, brand, label, error) => Effect.gen(function* () {
|
|
1911
2031
|
const validByteLength = yield* validateOAuthProviderModeOpaqueTokenBytes(byteLength, label, error);
|
|
1912
|
-
const token = yield* crypto
|
|
2032
|
+
const token = yield* crypto
|
|
2033
|
+
.randomToken(validByteLength)
|
|
2034
|
+
.pipe(Effect.mapError((cause) => error(`Failed to generate OAuth ${label} token`, cause)));
|
|
1913
2035
|
return Redacted.make(brand(token));
|
|
1914
2036
|
});
|
|
1915
2037
|
const oauthProviderModeOpaqueTokenHash = (crypto, token, error) => crypto.digestSha256({ data: Redacted.value(token) }).pipe(Effect.map((digest) => `sha256:${digest}`), Effect.mapError((cause) => error("Failed to hash OAuth provider-mode token", cause)));
|
|
1916
|
-
const oauthProviderModeOpaqueTokenAudience = (audience) => audience === undefined
|
|
2038
|
+
const oauthProviderModeOpaqueTokenAudience = (audience) => audience === undefined
|
|
2039
|
+
? undefined
|
|
2040
|
+
: Array.isArray(audience)
|
|
2041
|
+
? [...audience]
|
|
2042
|
+
: audience;
|
|
1917
2043
|
const oauthProviderModeOpaqueTokenRecord = (dependencies, input) => ({
|
|
1918
2044
|
tokenHash: input.tokenHash,
|
|
1919
2045
|
tokenType: input.tokenType,
|
|
@@ -1925,7 +2051,9 @@ const oauthProviderModeOpaqueTokenRecord = (dependencies, input) => ({
|
|
|
1925
2051
|
...(dependencies.issuer === undefined ? {} : { issuer: dependencies.issuer }),
|
|
1926
2052
|
...(dependencies.audience === undefined
|
|
1927
2053
|
? {}
|
|
1928
|
-
: {
|
|
2054
|
+
: {
|
|
2055
|
+
audience: oauthProviderModeOpaqueTokenAudience(dependencies.audience),
|
|
2056
|
+
}),
|
|
1929
2057
|
...(dependencies.metadata === undefined
|
|
1930
2058
|
? {}
|
|
1931
2059
|
: { metadata: metadataValue(dependencies.metadata) }),
|
|
@@ -1941,7 +2069,9 @@ const oauthProviderModeOpaqueTokenResponse = (input) => ({
|
|
|
1941
2069
|
: { refreshToken: input.refreshToken }),
|
|
1942
2070
|
...(input.scopes.length === 0 ? {} : { scopes: [...input.scopes] }),
|
|
1943
2071
|
});
|
|
1944
|
-
const oauthProviderModeOpaqueStoreToken = (store, record, error) => store
|
|
2072
|
+
const oauthProviderModeOpaqueStoreToken = (store, record, error) => store
|
|
2073
|
+
.upsert(record)
|
|
2074
|
+
.pipe(Effect.mapError((cause) => error("Failed to store OAuth provider-mode token", cause)));
|
|
1945
2075
|
const oauthProviderModeScopesSubset = (scopes, grantedScopes) => scopes.every((scope) => grantedScopes.includes(scope));
|
|
1946
2076
|
const oauthTokenGrantClientId = (value) => {
|
|
1947
2077
|
const clientId = oauthTokenGrantString(value === undefined ? undefined : String(value));
|
|
@@ -1960,7 +2090,7 @@ const oauthAuthorizationCodeConsumeFailureToTokenFailure = (reason) => {
|
|
|
1960
2090
|
}
|
|
1961
2091
|
}
|
|
1962
2092
|
};
|
|
1963
|
-
export const makeOAuthAuthorizationCodeTokenGrant = (dependencies) => OAuthAuthorizationCodeTokenGrant.
|
|
2093
|
+
export const makeOAuthAuthorizationCodeTokenGrant = (dependencies) => OAuthAuthorizationCodeTokenGrant.of({
|
|
1964
2094
|
exchange: Effect.fn("auth.oauth.authorization_code_token.exchange")(function* (input) {
|
|
1965
2095
|
if (input.grantType !== "authorization_code") {
|
|
1966
2096
|
return oauthAuthorizationCodeTokenInvalid("unsupported_grant_type");
|
|
@@ -1968,18 +2098,24 @@ export const makeOAuthAuthorizationCodeTokenGrant = (dependencies) => OAuthAutho
|
|
|
1968
2098
|
const { code } = input;
|
|
1969
2099
|
const clientId = oauthTokenGrantClientId(input.clientId);
|
|
1970
2100
|
const redirectUri = oauthTokenGrantString(input.redirectUri);
|
|
1971
|
-
if (code === undefined ||
|
|
2101
|
+
if (code === undefined ||
|
|
2102
|
+
clientId === undefined ||
|
|
2103
|
+
redirectUri === undefined) {
|
|
1972
2104
|
return oauthAuthorizationCodeTokenInvalid("invalid_request");
|
|
1973
2105
|
}
|
|
1974
|
-
const clientOption = yield* dependencies.clients
|
|
1975
|
-
|
|
2106
|
+
const clientOption = yield* dependencies.clients
|
|
2107
|
+
.find({ clientId })
|
|
2108
|
+
.pipe(Effect.mapError((cause) => oauthAuthorizationCodeTokenGrantError("exchange", "Failed to load OAuth client", cause)));
|
|
2109
|
+
if (Option.isNone(clientOption) ||
|
|
2110
|
+
clientOption.value.status !== "active") {
|
|
1976
2111
|
return oauthAuthorizationCodeTokenInvalid("invalid_client");
|
|
1977
2112
|
}
|
|
1978
2113
|
const client = clientOption.value;
|
|
1979
2114
|
if (!client.allowedGrantTypes.includes("authorization_code")) {
|
|
1980
2115
|
return oauthAuthorizationCodeTokenInvalid("unauthorized_client");
|
|
1981
2116
|
}
|
|
1982
|
-
if (client.type === "confidential" &&
|
|
2117
|
+
if (client.type === "confidential" &&
|
|
2118
|
+
input.clientAuthenticated !== true) {
|
|
1983
2119
|
return oauthAuthorizationCodeTokenInvalid("invalid_client");
|
|
1984
2120
|
}
|
|
1985
2121
|
const now = input.now ?? (yield* currentUnixMillis);
|
|
@@ -2008,7 +2144,7 @@ export const makeOAuthAuthorizationCodeTokenGrant = (dependencies) => OAuthAutho
|
|
|
2008
2144
|
};
|
|
2009
2145
|
}),
|
|
2010
2146
|
});
|
|
2011
|
-
export const makeOAuthRefreshTokenGrant = (dependencies) => OAuthRefreshTokenGrant.
|
|
2147
|
+
export const makeOAuthRefreshTokenGrant = (dependencies) => OAuthRefreshTokenGrant.of({
|
|
2012
2148
|
exchange: Effect.fn("auth.oauth.refresh_token.exchange")(function* (input) {
|
|
2013
2149
|
if (input.grantType !== "refresh_token") {
|
|
2014
2150
|
return oauthRefreshTokenInvalid("unsupported_grant_type");
|
|
@@ -2018,15 +2154,19 @@ export const makeOAuthRefreshTokenGrant = (dependencies) => OAuthRefreshTokenGra
|
|
|
2018
2154
|
if (refreshToken === undefined || clientId === undefined) {
|
|
2019
2155
|
return oauthRefreshTokenInvalid("invalid_request");
|
|
2020
2156
|
}
|
|
2021
|
-
const clientOption = yield* dependencies.clients
|
|
2022
|
-
|
|
2157
|
+
const clientOption = yield* dependencies.clients
|
|
2158
|
+
.find({ clientId })
|
|
2159
|
+
.pipe(Effect.mapError((cause) => oauthRefreshTokenGrantError("exchange", "Failed to load OAuth client", cause)));
|
|
2160
|
+
if (Option.isNone(clientOption) ||
|
|
2161
|
+
clientOption.value.status !== "active") {
|
|
2023
2162
|
return oauthRefreshTokenInvalid("invalid_client");
|
|
2024
2163
|
}
|
|
2025
2164
|
const client = clientOption.value;
|
|
2026
2165
|
if (!client.allowedGrantTypes.includes("refresh_token")) {
|
|
2027
2166
|
return oauthRefreshTokenInvalid("unauthorized_client");
|
|
2028
2167
|
}
|
|
2029
|
-
if (client.type === "confidential" &&
|
|
2168
|
+
if (client.type === "confidential" &&
|
|
2169
|
+
input.clientAuthenticated !== true) {
|
|
2030
2170
|
return oauthRefreshTokenInvalid("invalid_client");
|
|
2031
2171
|
}
|
|
2032
2172
|
const scopes = oauthTokenGrantScopes(input.scopes);
|
|
@@ -2052,7 +2192,7 @@ export const makeOAuthRefreshTokenGrant = (dependencies) => OAuthRefreshTokenGra
|
|
|
2052
2192
|
};
|
|
2053
2193
|
}),
|
|
2054
2194
|
});
|
|
2055
|
-
export const makeOAuthClientCredentialsGrant = (dependencies) => OAuthClientCredentialsGrant.
|
|
2195
|
+
export const makeOAuthClientCredentialsGrant = (dependencies) => OAuthClientCredentialsGrant.of({
|
|
2056
2196
|
exchange: Effect.fn("auth.oauth.client_credentials.exchange")(function* (input) {
|
|
2057
2197
|
if (input.grantType !== "client_credentials") {
|
|
2058
2198
|
return oauthClientCredentialsInvalid("unsupported_grant_type");
|
|
@@ -2061,8 +2201,11 @@ export const makeOAuthClientCredentialsGrant = (dependencies) => OAuthClientCred
|
|
|
2061
2201
|
if (clientId === undefined) {
|
|
2062
2202
|
return oauthClientCredentialsInvalid("invalid_request");
|
|
2063
2203
|
}
|
|
2064
|
-
const clientOption = yield* dependencies.clients
|
|
2065
|
-
|
|
2204
|
+
const clientOption = yield* dependencies.clients
|
|
2205
|
+
.find({ clientId })
|
|
2206
|
+
.pipe(Effect.mapError((cause) => oauthClientCredentialsGrantError("exchange", "Failed to load OAuth client", cause)));
|
|
2207
|
+
if (Option.isNone(clientOption) ||
|
|
2208
|
+
clientOption.value.status !== "active") {
|
|
2066
2209
|
return oauthClientCredentialsInvalid("invalid_client");
|
|
2067
2210
|
}
|
|
2068
2211
|
const client = clientOption.value;
|
|
@@ -2103,7 +2246,7 @@ export const makeOAuthProviderModeOpaqueTokenIssuer = (dependencies) => {
|
|
|
2103
2246
|
const accessTokenTtl = dependencies.accessTokenTtl ?? defaultOAuthProviderModeAccessTokenTtl;
|
|
2104
2247
|
const refreshTokenTtl = dependencies.refreshTokenTtl ?? defaultOAuthProviderModeRefreshTokenTtl;
|
|
2105
2248
|
return {
|
|
2106
|
-
authorizationCode: OAuthAuthorizationCodeTokenIssuer.
|
|
2249
|
+
authorizationCode: OAuthAuthorizationCodeTokenIssuer.of({
|
|
2107
2250
|
issue: Effect.fn("auth.oauth.provider_mode_opaque.authorization_code.issue")(function* (input) {
|
|
2108
2251
|
const scopes = [...input.code.scopes];
|
|
2109
2252
|
const accessToken = yield* generateOAuthProviderModeOpaqueToken(dependencies.crypto, accessTokenBytes, OAuthAccessToken, "access", oauthAuthorizationCodeTokenIssuerError);
|
|
@@ -2148,7 +2291,7 @@ export const makeOAuthProviderModeOpaqueTokenIssuer = (dependencies) => {
|
|
|
2148
2291
|
});
|
|
2149
2292
|
}),
|
|
2150
2293
|
}),
|
|
2151
|
-
refreshToken: OAuthRefreshTokenIssuer.
|
|
2294
|
+
refreshToken: OAuthRefreshTokenIssuer.of({
|
|
2152
2295
|
issue: Effect.fn("auth.oauth.provider_mode_opaque.refresh_token.issue")(function* (input) {
|
|
2153
2296
|
const tokenHash = yield* oauthProviderModeOpaqueTokenHash(dependencies.crypto, input.refreshToken, oauthRefreshTokenIssuerError);
|
|
2154
2297
|
const recordOption = yield* dependencies.tokenStore
|
|
@@ -2216,7 +2359,7 @@ export const makeOAuthProviderModeOpaqueTokenIssuer = (dependencies) => {
|
|
|
2216
2359
|
};
|
|
2217
2360
|
}),
|
|
2218
2361
|
}),
|
|
2219
|
-
clientCredentials: OAuthClientCredentialsTokenIssuer.
|
|
2362
|
+
clientCredentials: OAuthClientCredentialsTokenIssuer.of({
|
|
2220
2363
|
issue: Effect.fn("auth.oauth.provider_mode_opaque.client_credentials.issue")(function* (input) {
|
|
2221
2364
|
const scopes = [...(input.scopes ?? [])];
|
|
2222
2365
|
if (!oauthTokenGrantScopesAllowed(scopes, input.client.allowedScopes)) {
|
|
@@ -2258,9 +2401,11 @@ export const makeOAuthProviderModeOpaqueTokenIssuer = (dependencies) => {
|
|
|
2258
2401
|
}),
|
|
2259
2402
|
};
|
|
2260
2403
|
};
|
|
2261
|
-
export const makeOAuthClientSecretVerification = (dependencies) => OAuthClientSecretVerification.
|
|
2404
|
+
export const makeOAuthClientSecretVerification = (dependencies) => OAuthClientSecretVerification.of({
|
|
2262
2405
|
authenticateClient: Effect.fn("auth.oauth.client_secret.authenticate_client")(function* (input) {
|
|
2263
|
-
const prefix = yield* dependencies.clientSecrets
|
|
2406
|
+
const prefix = yield* dependencies.clientSecrets
|
|
2407
|
+
.parse(input.clientSecret)
|
|
2408
|
+
.pipe(Effect.catchTag("OAuthClientSecretError", () => Effect.succeed(undefined)));
|
|
2264
2409
|
if (prefix === undefined) {
|
|
2265
2410
|
return false;
|
|
2266
2411
|
}
|
|
@@ -2295,13 +2440,15 @@ export const makeOAuthClientSecretVerification = (dependencies) => OAuthClientSe
|
|
|
2295
2440
|
return Option.isSome(updated);
|
|
2296
2441
|
}),
|
|
2297
2442
|
});
|
|
2298
|
-
export const makeOAuthTokenRevocation = (dependencies) => OAuthTokenRevocation.
|
|
2443
|
+
export const makeOAuthTokenRevocation = (dependencies) => OAuthTokenRevocation.of({
|
|
2299
2444
|
revoke: Effect.fn("auth.oauth.token_revocation.revoke")(function* (input) {
|
|
2300
2445
|
const { token } = input;
|
|
2301
2446
|
const tokenValue = token === undefined ? undefined : String(Redacted.value(token)).trim();
|
|
2302
2447
|
const clientId = oauthTokenGrantClientId(input.clientId);
|
|
2303
2448
|
const tokenTypeHint = oauthTokenGrantString(input.tokenTypeHint);
|
|
2304
|
-
if (token === undefined ||
|
|
2449
|
+
if (token === undefined ||
|
|
2450
|
+
tokenValue === undefined ||
|
|
2451
|
+
clientId === undefined) {
|
|
2305
2452
|
return oauthTokenRevocationInvalid("invalid_request");
|
|
2306
2453
|
}
|
|
2307
2454
|
if (tokenTypeHint !== undefined &&
|
|
@@ -2309,12 +2456,16 @@ export const makeOAuthTokenRevocation = (dependencies) => OAuthTokenRevocation.m
|
|
|
2309
2456
|
tokenTypeHint !== "refresh_token") {
|
|
2310
2457
|
return oauthTokenRevocationInvalid("unsupported_token_type");
|
|
2311
2458
|
}
|
|
2312
|
-
const clientOption = yield* dependencies.clients
|
|
2313
|
-
|
|
2459
|
+
const clientOption = yield* dependencies.clients
|
|
2460
|
+
.find({ clientId })
|
|
2461
|
+
.pipe(Effect.mapError((cause) => oauthTokenRevocationError("revoke", "Failed to load OAuth client", cause)));
|
|
2462
|
+
if (Option.isNone(clientOption) ||
|
|
2463
|
+
clientOption.value.status !== "active") {
|
|
2314
2464
|
return oauthTokenRevocationInvalid("invalid_client");
|
|
2315
2465
|
}
|
|
2316
2466
|
const client = clientOption.value;
|
|
2317
|
-
if (client.type !== "confidential" ||
|
|
2467
|
+
if (client.type !== "confidential" ||
|
|
2468
|
+
input.clientAuthenticated !== true) {
|
|
2318
2469
|
return oauthTokenRevocationInvalid("invalid_client");
|
|
2319
2470
|
}
|
|
2320
2471
|
const now = input.now ?? (yield* currentUnixMillis);
|
|
@@ -2332,21 +2483,29 @@ export const makeOAuthTokenRevocation = (dependencies) => OAuthTokenRevocation.m
|
|
|
2332
2483
|
};
|
|
2333
2484
|
}),
|
|
2334
2485
|
});
|
|
2335
|
-
export const makeOAuthTokenIntrospection = (dependencies) => OAuthTokenIntrospection.
|
|
2486
|
+
export const makeOAuthTokenIntrospection = (dependencies) => OAuthTokenIntrospection.of({
|
|
2336
2487
|
introspect: Effect.fn("auth.oauth.token_introspection.introspect")(function* (input) {
|
|
2337
2488
|
const { token } = input;
|
|
2338
|
-
const tokenValue = token === undefined
|
|
2489
|
+
const tokenValue = token === undefined
|
|
2490
|
+
? undefined
|
|
2491
|
+
: String(Redacted.value(token)).trim();
|
|
2339
2492
|
const clientId = oauthTokenGrantClientId(input.clientId);
|
|
2340
2493
|
const tokenTypeHint = oauthTokenGrantString(input.tokenTypeHint);
|
|
2341
|
-
if (token === undefined ||
|
|
2494
|
+
if (token === undefined ||
|
|
2495
|
+
tokenValue === undefined ||
|
|
2496
|
+
clientId === undefined) {
|
|
2342
2497
|
return oauthTokenIntrospectionInvalid("invalid_request");
|
|
2343
2498
|
}
|
|
2344
|
-
const clientOption = yield* dependencies.clients
|
|
2345
|
-
|
|
2499
|
+
const clientOption = yield* dependencies.clients
|
|
2500
|
+
.find({ clientId })
|
|
2501
|
+
.pipe(Effect.mapError((cause) => oauthTokenIntrospectionError("introspect", "Failed to load OAuth client", cause)));
|
|
2502
|
+
if (Option.isNone(clientOption) ||
|
|
2503
|
+
clientOption.value.status !== "active") {
|
|
2346
2504
|
return oauthTokenIntrospectionInvalid("invalid_client");
|
|
2347
2505
|
}
|
|
2348
2506
|
const client = clientOption.value;
|
|
2349
|
-
if (client.type !== "confidential" ||
|
|
2507
|
+
if (client.type !== "confidential" ||
|
|
2508
|
+
input.clientAuthenticated !== true) {
|
|
2350
2509
|
return oauthTokenIntrospectionInvalid("invalid_client");
|
|
2351
2510
|
}
|
|
2352
2511
|
const now = input.now ?? (yield* currentUnixMillis);
|
|
@@ -2368,7 +2527,9 @@ export const makeOAuthTokenIntrospection = (dependencies) => OAuthTokenIntrospec
|
|
|
2368
2527
|
const oauthProviderAuthorizationInvalid = (reason, input) => ({
|
|
2369
2528
|
valid: false,
|
|
2370
2529
|
reason,
|
|
2371
|
-
...(input?.redirectUri === undefined
|
|
2530
|
+
...(input?.redirectUri === undefined
|
|
2531
|
+
? {}
|
|
2532
|
+
: { redirectUri: input.redirectUri }),
|
|
2372
2533
|
...(input?.state === undefined ? {} : { state: input.state }),
|
|
2373
2534
|
...(input?.client === undefined
|
|
2374
2535
|
? {}
|
|
@@ -2386,7 +2547,7 @@ const oauthProviderAuthorizationClientId = (value) => {
|
|
|
2386
2547
|
return clientId === undefined ? undefined : OAuthClientId(clientId);
|
|
2387
2548
|
};
|
|
2388
2549
|
const oauthProviderAuthorizationScopes = (scopes) => {
|
|
2389
|
-
const values = typeof scopes === "string" ? scopes.split(/\s+/) : scopes ?? [];
|
|
2550
|
+
const values = typeof scopes === "string" ? scopes.split(/\s+/) : (scopes ?? []);
|
|
2390
2551
|
const unique = new Set();
|
|
2391
2552
|
for (const value of values) {
|
|
2392
2553
|
const scope = value.trim();
|
|
@@ -2396,13 +2557,14 @@ const oauthProviderAuthorizationScopes = (scopes) => {
|
|
|
2396
2557
|
}
|
|
2397
2558
|
return [...unique];
|
|
2398
2559
|
};
|
|
2399
|
-
const oauthProviderAuthorizationScopeAllowed = (scopes, allowedScopes) => allowedScopes === undefined ||
|
|
2560
|
+
const oauthProviderAuthorizationScopeAllowed = (scopes, allowedScopes) => allowedScopes === undefined ||
|
|
2561
|
+
scopes.every((scope) => allowedScopes.includes(scope));
|
|
2400
2562
|
const oauthProviderAuthorizationScopeSubset = (scopes, requestedScopes) => scopes.every((scope) => requestedScopes.includes(scope));
|
|
2401
2563
|
const oauthProviderAuthorizationClientAllowsCode = (client) => client.allowedResponseTypes.includes("code") &&
|
|
2402
2564
|
client.allowedGrantTypes.includes("authorization_code");
|
|
2403
2565
|
const oauthProviderAuthorizationGrantedScopesValid = (scopes, requestedScopes, allowedScopes) => oauthProviderAuthorizationScopeSubset(scopes, requestedScopes) &&
|
|
2404
2566
|
oauthProviderAuthorizationScopeAllowed(scopes, allowedScopes);
|
|
2405
|
-
export const makeOAuthProviderAuthorization = (dependencies) => OAuthProviderAuthorization.
|
|
2567
|
+
export const makeOAuthProviderAuthorization = (dependencies) => OAuthProviderAuthorization.of({
|
|
2406
2568
|
authorize: Effect.fn("auth.oauth.provider_authorization.authorize")(function* (input) {
|
|
2407
2569
|
const state = oauthProviderAuthorizationString(input.state);
|
|
2408
2570
|
const clientId = oauthProviderAuthorizationClientId(input.clientId);
|
|
@@ -2410,8 +2572,11 @@ export const makeOAuthProviderAuthorization = (dependencies) => OAuthProviderAut
|
|
|
2410
2572
|
if (clientId === undefined || redirectUri === undefined) {
|
|
2411
2573
|
return oauthProviderAuthorizationInvalid("invalid_request");
|
|
2412
2574
|
}
|
|
2413
|
-
const clientOption = yield* dependencies.clients
|
|
2414
|
-
|
|
2575
|
+
const clientOption = yield* dependencies.clients
|
|
2576
|
+
.find({ clientId })
|
|
2577
|
+
.pipe(Effect.mapError((cause) => oauthProviderAuthorizationError("authorize", "Failed to load OAuth client", cause)));
|
|
2578
|
+
if (Option.isNone(clientOption) ||
|
|
2579
|
+
clientOption.value.status !== "active") {
|
|
2415
2580
|
return oauthProviderAuthorizationInvalid("invalid_request");
|
|
2416
2581
|
}
|
|
2417
2582
|
const client = clientOption.value;
|
|
@@ -2430,7 +2595,9 @@ export const makeOAuthProviderAuthorization = (dependencies) => OAuthProviderAut
|
|
|
2430
2595
|
if (!oauthProviderAuthorizationClientAllowsCode(client)) {
|
|
2431
2596
|
return redirectError("unauthorized_client");
|
|
2432
2597
|
}
|
|
2433
|
-
const codeChallenge = oauthProviderAuthorizationString(input.codeChallenge === undefined
|
|
2598
|
+
const codeChallenge = oauthProviderAuthorizationString(input.codeChallenge === undefined
|
|
2599
|
+
? undefined
|
|
2600
|
+
: String(input.codeChallenge));
|
|
2434
2601
|
if (codeChallenge === undefined ||
|
|
2435
2602
|
oauthProviderAuthorizationString(input.codeChallengeMethod) !== "S256") {
|
|
2436
2603
|
return redirectError("invalid_request");
|
|
@@ -2518,10 +2685,12 @@ const makeAuthorizationUrl = (input) => Effect.try({
|
|
|
2518
2685
|
},
|
|
2519
2686
|
catch: (cause) => oauthStateError("authorization-url", "Failed to build OAuth authorization URL", cause),
|
|
2520
2687
|
});
|
|
2521
|
-
export const makeOAuthState = (dependencies) => OAuthState.
|
|
2688
|
+
export const makeOAuthState = (dependencies) => OAuthState.of({
|
|
2522
2689
|
start: Effect.fn("auth.oauth_state.start")(function* (input) {
|
|
2523
2690
|
const stateSecretBytes = yield* validateByteLength(dependencies.stateSecretBytes ?? defaultOAuthStateSecretBytes, "start", "OAuth state secret");
|
|
2524
|
-
const stateSecret = yield* dependencies.crypto
|
|
2691
|
+
const stateSecret = yield* dependencies.crypto
|
|
2692
|
+
.randomToken(stateSecretBytes)
|
|
2693
|
+
.pipe(Effect.map(Redacted.make), Effect.mapError((cause) => oauthStateError("start", "Failed to generate OAuth state secret", cause)));
|
|
2525
2694
|
const pkce = yield* makeOAuthPkceWithCrypto(dependencies, {
|
|
2526
2695
|
codeVerifier: input.codeVerifier,
|
|
2527
2696
|
verifierBytes: dependencies.codeVerifierBytes,
|
|
@@ -2548,11 +2717,16 @@ export const makeOAuthState = (dependencies) => OAuthState.make({
|
|
|
2548
2717
|
scopes,
|
|
2549
2718
|
codeChallenge: pkce.codeChallenge,
|
|
2550
2719
|
...(nonce === undefined ? {} : { nonce }),
|
|
2551
|
-
...(input.metadata === undefined
|
|
2720
|
+
...(input.metadata === undefined
|
|
2721
|
+
? {}
|
|
2722
|
+
: { metadata: input.metadata }),
|
|
2552
2723
|
},
|
|
2553
2724
|
})
|
|
2554
2725
|
.pipe(Effect.mapError((cause) => oauthStateError("start", "Failed to issue OAuth state challenge", cause)));
|
|
2555
|
-
const state = encodeOAuthState({
|
|
2726
|
+
const state = encodeOAuthState({
|
|
2727
|
+
challengeId: issued.id,
|
|
2728
|
+
secret: stateSecret,
|
|
2729
|
+
});
|
|
2556
2730
|
const authorizationUrl = yield* makeAuthorizationUrl({
|
|
2557
2731
|
provider: input.provider,
|
|
2558
2732
|
redirectUri,
|
|
@@ -2673,11 +2847,15 @@ export const OAuthProviderAuthorizationLive = Layer.effect(OAuthProviderAuthoriz
|
|
|
2673
2847
|
const clients = yield* OAuthClientRegistry;
|
|
2674
2848
|
const authorizationCodes = yield* OAuthAuthorizationCodeGrant;
|
|
2675
2849
|
const policy = yield* OAuthProviderAuthorizationPolicy;
|
|
2676
|
-
return makeOAuthProviderAuthorization({
|
|
2850
|
+
return makeOAuthProviderAuthorization({
|
|
2851
|
+
clients,
|
|
2852
|
+
authorizationCodes,
|
|
2853
|
+
policy,
|
|
2854
|
+
});
|
|
2677
2855
|
}));
|
|
2678
2856
|
export const makeOAuthProviders = (providers) => {
|
|
2679
2857
|
const providersById = new Map(providers.map((provider) => [provider.id, cloneProviderConfig(provider)]));
|
|
2680
|
-
return OAuthProviders.
|
|
2858
|
+
return OAuthProviders.of({
|
|
2681
2859
|
get: (id) => Effect.sync(() => {
|
|
2682
2860
|
const provider = providersById.get(id);
|
|
2683
2861
|
return provider === undefined
|
|
@@ -2696,9 +2874,13 @@ export const OAuthClientSecretVerificationLive = Layer.effect(OAuthClientSecretV
|
|
|
2696
2874
|
const secretStore = yield* OAuthClientSecretStore;
|
|
2697
2875
|
return makeOAuthClientSecretVerification({ clientSecrets, secretStore });
|
|
2698
2876
|
}));
|
|
2699
|
-
export const makeOAuthClientRegistryFromStore = (store) => OAuthClientRegistry.
|
|
2700
|
-
find: (input) => store
|
|
2701
|
-
|
|
2877
|
+
export const makeOAuthClientRegistryFromStore = (store) => OAuthClientRegistry.of({
|
|
2878
|
+
find: (input) => store
|
|
2879
|
+
.find(input)
|
|
2880
|
+
.pipe(Effect.mapError((cause) => oauthClientRegistryError("find", "Failed to load OAuth client", cause))),
|
|
2881
|
+
validateRedirectUri: (input) => store
|
|
2882
|
+
.validateRedirectUri(input)
|
|
2883
|
+
.pipe(Effect.mapError((cause) => oauthClientRegistryError("validate-redirect-uri", "Failed to validate OAuth client redirect URI", cause))),
|
|
2702
2884
|
});
|
|
2703
2885
|
export const OAuthClientRegistryFromStoreLive = Layer.effect(OAuthClientRegistry)(Effect.gen(function* () {
|
|
2704
2886
|
const store = yield* OAuthClientStore;
|
|
@@ -2706,7 +2888,7 @@ export const OAuthClientRegistryFromStoreLive = Layer.effect(OAuthClientRegistry
|
|
|
2706
2888
|
}));
|
|
2707
2889
|
export const makeOAuthClientRegistryMemory = (clients = []) => {
|
|
2708
2890
|
const clientsById = new Map(clients.map((client) => [client.id, cloneOAuthClientRecord(client)]));
|
|
2709
|
-
return OAuthClientRegistry.
|
|
2891
|
+
return OAuthClientRegistry.of({
|
|
2710
2892
|
find: (input) => Effect.sync(() => {
|
|
2711
2893
|
const client = clientsById.get(input.clientId);
|
|
2712
2894
|
return client === undefined
|
|
@@ -2722,7 +2904,7 @@ export const makeOAuthClientRegistryMemory = (clients = []) => {
|
|
|
2722
2904
|
export const OAuthClientRegistryMemoryLive = (clients = []) => Layer.succeed(OAuthClientRegistry)(makeOAuthClientRegistryMemory(clients));
|
|
2723
2905
|
export const makeOAuthClientStoreMemory = (clients = []) => {
|
|
2724
2906
|
const clientsById = new Map(clients.map((client) => [client.id, cloneOAuthClientRecord(client)]));
|
|
2725
|
-
return OAuthClientStore.
|
|
2907
|
+
return OAuthClientStore.of({
|
|
2726
2908
|
upsert: (record) => Effect.sync(() => {
|
|
2727
2909
|
clientsById.set(record.id, cloneOAuthClientRecord(record));
|
|
2728
2910
|
}),
|
|
@@ -2738,14 +2920,14 @@ export const makeOAuthClientStoreMemory = (clients = []) => {
|
|
|
2738
2920
|
validateRedirectUri: (input) => Effect.sync(() => validateOAuthClientRedirectUriRecord(clientsById.get(input.clientId), input)),
|
|
2739
2921
|
});
|
|
2740
2922
|
};
|
|
2741
|
-
export const OAuthClientStoreMemoryLive = (clients = []) => Layer.
|
|
2923
|
+
export const OAuthClientStoreMemoryLive = (clients = []) => Layer.sync(OAuthClientStore)(() => makeOAuthClientStoreMemory(clients));
|
|
2742
2924
|
const oauthConsentMemoryKey = (input) => `${input.userId}\u0000${input.clientId}`;
|
|
2743
2925
|
export const makeOAuthConsentStoreMemory = (records = []) => {
|
|
2744
2926
|
const recordsByKey = new Map(records.map((record) => [
|
|
2745
2927
|
oauthConsentMemoryKey(record),
|
|
2746
2928
|
cloneOAuthConsentRecord(record),
|
|
2747
2929
|
]));
|
|
2748
|
-
return OAuthConsentStore.
|
|
2930
|
+
return OAuthConsentStore.of({
|
|
2749
2931
|
upsert: (record) => Effect.sync(() => {
|
|
2750
2932
|
recordsByKey.set(oauthConsentMemoryKey(record), cloneOAuthConsentRecord(record));
|
|
2751
2933
|
}),
|
|
@@ -2795,11 +2977,11 @@ export const makeOAuthConsentStoreMemory = (records = []) => {
|
|
|
2795
2977
|
}),
|
|
2796
2978
|
});
|
|
2797
2979
|
};
|
|
2798
|
-
export const OAuthConsentStoreMemoryLive = (records = []) => Layer.
|
|
2980
|
+
export const OAuthConsentStoreMemoryLive = (records = []) => Layer.sync(OAuthConsentStore)(() => makeOAuthConsentStoreMemory(records));
|
|
2799
2981
|
const oauthClientSecretMemoryKey = (input) => `${input.clientId}\u0000${input.prefix}`;
|
|
2800
2982
|
export const makeOAuthClientSecretStoreMemory = () => {
|
|
2801
2983
|
const recordsByKey = new Map();
|
|
2802
|
-
return OAuthClientSecretStore.
|
|
2984
|
+
return OAuthClientSecretStore.of({
|
|
2803
2985
|
upsert: (record) => Effect.sync(() => {
|
|
2804
2986
|
recordsByKey.set(oauthClientSecretMemoryKey(record), cloneOAuthClientSecretRecord(record));
|
|
2805
2987
|
}),
|
|
@@ -2844,7 +3026,7 @@ export const makeOAuthClientSecretStoreMemory = () => {
|
|
|
2844
3026
|
export const OAuthClientSecretStoreMemoryLive = Layer.sync(OAuthClientSecretStore)(makeOAuthClientSecretStoreMemory);
|
|
2845
3027
|
export const makeOAuthAuthorizationCodeStoreMemory = () => {
|
|
2846
3028
|
const recordsByHash = new Map();
|
|
2847
|
-
return OAuthAuthorizationCodeStore.
|
|
3029
|
+
return OAuthAuthorizationCodeStore.of({
|
|
2848
3030
|
upsert: (record) => Effect.sync(() => {
|
|
2849
3031
|
recordsByHash.set(record.codeHash, cloneAuthorizationCodeRecord(record));
|
|
2850
3032
|
}),
|
|
@@ -2880,7 +3062,7 @@ export const makeOAuthAuthorizationCodeStoreMemory = () => {
|
|
|
2880
3062
|
export const OAuthAuthorizationCodeStoreMemoryLive = Layer.sync(OAuthAuthorizationCodeStore)(makeOAuthAuthorizationCodeStoreMemory);
|
|
2881
3063
|
export const makeOAuthProviderModeTokenStoreMemory = () => {
|
|
2882
3064
|
const recordsByHash = new Map();
|
|
2883
|
-
return OAuthProviderModeTokenStore.
|
|
3065
|
+
return OAuthProviderModeTokenStore.of({
|
|
2884
3066
|
upsert: (record) => Effect.sync(() => {
|
|
2885
3067
|
recordsByHash.set(record.tokenHash, cloneOAuthProviderModeTokenRecord(record));
|
|
2886
3068
|
}),
|
|
@@ -2964,7 +3146,9 @@ export const OAuthLinkConfirmationLive = Layer.effect(OAuthLinkConfirmation)(Eff
|
|
|
2964
3146
|
const accountKey = (input) => `${input.providerId}:${input.providerAccountId}`;
|
|
2965
3147
|
const cloneOAuthAccountRecord = (record) => ({
|
|
2966
3148
|
...record,
|
|
2967
|
-
...(record.metadata === undefined
|
|
3149
|
+
...(record.metadata === undefined
|
|
3150
|
+
? {}
|
|
3151
|
+
: { metadata: metadataValue(record.metadata) }),
|
|
2968
3152
|
});
|
|
2969
3153
|
const cloneProviderTokenVaultRecord = (record) => ({
|
|
2970
3154
|
...record,
|
|
@@ -2986,7 +3170,7 @@ const activeProviderTokenRecord = (record) => record === undefined || record.rev
|
|
|
2986
3170
|
const includeAccount = (record, includeUnlinked) => includeUnlinked === true || record.unlinkedAt === undefined;
|
|
2987
3171
|
export const makeOAuthProviderTokenVaultMemory = () => {
|
|
2988
3172
|
const recordsByAccountId = new Map();
|
|
2989
|
-
return OAuthProviderTokenVault.
|
|
3173
|
+
return OAuthProviderTokenVault.of({
|
|
2990
3174
|
upsert: (record) => Effect.sync(() => {
|
|
2991
3175
|
recordsByAccountId.set(record.accountId, cloneProviderTokenVaultRecord(record));
|
|
2992
3176
|
}),
|
|
@@ -3021,7 +3205,7 @@ export const OAuthProviderTokenVaultMemoryLive = Layer.sync(OAuthProviderTokenVa
|
|
|
3021
3205
|
export const makeOAuthAccountStoreMemory = () => {
|
|
3022
3206
|
const accountsById = new Map();
|
|
3023
3207
|
const idByProviderAccount = new Map();
|
|
3024
|
-
return OAuthAccountStore.
|
|
3208
|
+
return OAuthAccountStore.of({
|
|
3025
3209
|
insert: (row) => Effect.sync(() => {
|
|
3026
3210
|
const cloned = cloneOAuthAccountRecord(row);
|
|
3027
3211
|
accountsById.set(row.id, cloned);
|
|
@@ -3029,7 +3213,9 @@ export const makeOAuthAccountStoreMemory = () => {
|
|
|
3029
3213
|
}),
|
|
3030
3214
|
findById: (id) => Effect.sync(() => {
|
|
3031
3215
|
const row = accountsById.get(id);
|
|
3032
|
-
return row === undefined
|
|
3216
|
+
return row === undefined
|
|
3217
|
+
? Option.none()
|
|
3218
|
+
: Option.some(cloneOAuthAccountRecord(row));
|
|
3033
3219
|
}),
|
|
3034
3220
|
findByProviderAccount: (input) => Effect.sync(() => {
|
|
3035
3221
|
const id = idByProviderAccount.get(accountKey(input));
|
|
@@ -3039,7 +3225,8 @@ export const makeOAuthAccountStoreMemory = () => {
|
|
|
3039
3225
|
: Option.some(cloneOAuthAccountRecord(row));
|
|
3040
3226
|
}),
|
|
3041
3227
|
listByUser: (input) => Effect.sync(() => [...accountsById.values()]
|
|
3042
|
-
.filter((row) => row.userId === input.userId &&
|
|
3228
|
+
.filter((row) => row.userId === input.userId &&
|
|
3229
|
+
includeAccount(row, input.includeUnlinked))
|
|
3043
3230
|
.map(cloneOAuthAccountRecord)),
|
|
3044
3231
|
unlink: (input) => Effect.sync(() => {
|
|
3045
3232
|
const id = idByProviderAccount.get(accountKey(input));
|