@effect-auth/core 0.1.0-alpha.15 → 0.1.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (627) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +332 -131
  3. package/dist/AbuseProtection.d.ts +100 -0
  4. package/dist/AbuseProtection.d.ts.map +1 -0
  5. package/dist/AbuseProtection.js +71 -0
  6. package/dist/AbuseProtection.js.map +1 -0
  7. package/dist/AccessGrant.d.ts +344 -0
  8. package/dist/AccessGrant.d.ts.map +1 -0
  9. package/dist/AccessGrant.js +687 -0
  10. package/dist/AccessGrant.js.map +1 -0
  11. package/dist/ApiKey.d.ts +2 -14
  12. package/dist/ApiKey.d.ts.map +1 -1
  13. package/dist/ApiKey.js +36 -27
  14. package/dist/ApiKey.js.map +1 -1
  15. package/dist/Assurance.d.ts +415 -0
  16. package/dist/Assurance.d.ts.map +1 -0
  17. package/dist/Assurance.js +764 -0
  18. package/dist/Assurance.js.map +1 -0
  19. package/dist/AtomicPlanExecutor.d.ts +28 -0
  20. package/dist/AtomicPlanExecutor.d.ts.map +1 -0
  21. package/dist/AtomicPlanExecutor.js +5 -0
  22. package/dist/AtomicPlanExecutor.js.map +1 -0
  23. package/dist/AuditLog.d.ts +2314 -52
  24. package/dist/AuditLog.d.ts.map +1 -1
  25. package/dist/AuditLog.js +511 -33
  26. package/dist/AuditLog.js.map +1 -1
  27. package/dist/AuthConfig.d.ts.map +1 -1
  28. package/dist/AuthConfig.js.map +1 -1
  29. package/dist/AuthFlow.d.ts +326 -220
  30. package/dist/AuthFlow.d.ts.map +1 -1
  31. package/dist/AuthFlow.js +611 -263
  32. package/dist/AuthFlow.js.map +1 -1
  33. package/dist/AuthKernel.d.ts +1 -1
  34. package/dist/AuthRateLimit.d.ts +96 -0
  35. package/dist/AuthRateLimit.d.ts.map +1 -0
  36. package/dist/AuthRateLimit.js +212 -0
  37. package/dist/AuthRateLimit.js.map +1 -0
  38. package/dist/Challenge.d.ts +0 -3
  39. package/dist/Challenge.d.ts.map +1 -1
  40. package/dist/Challenge.js +1 -4
  41. package/dist/Challenge.js.map +1 -1
  42. package/dist/Client.d.ts +205 -10
  43. package/dist/Client.d.ts.map +1 -1
  44. package/dist/Client.js +397 -16
  45. package/dist/Client.js.map +1 -1
  46. package/dist/CloudflareTurnstile.d.ts +28 -0
  47. package/dist/CloudflareTurnstile.d.ts.map +1 -0
  48. package/dist/CloudflareTurnstile.js +205 -0
  49. package/dist/CloudflareTurnstile.js.map +1 -0
  50. package/dist/Crypto.d.ts +0 -3
  51. package/dist/Crypto.d.ts.map +1 -1
  52. package/dist/Crypto.js +5 -7
  53. package/dist/Crypto.js.map +1 -1
  54. package/dist/DelegatedAccessStorageMigrations.d.ts +7 -0
  55. package/dist/DelegatedAccessStorageMigrations.d.ts.map +1 -0
  56. package/dist/DelegatedAccessStorageMigrations.js +159 -0
  57. package/dist/DelegatedAccessStorageMigrations.js.map +1 -0
  58. package/dist/DisposableEmailDomains.d.ts +19 -0
  59. package/dist/DisposableEmailDomains.d.ts.map +1 -0
  60. package/dist/DisposableEmailDomains.js +85 -0
  61. package/dist/DisposableEmailDomains.js.map +1 -0
  62. package/dist/DomainVerification.d.ts +0 -9
  63. package/dist/DomainVerification.d.ts.map +1 -1
  64. package/dist/DomainVerification.js +36 -22
  65. package/dist/DomainVerification.js.map +1 -1
  66. package/dist/DrizzleBunSqliteStorage.d.ts +18 -0
  67. package/dist/DrizzleBunSqliteStorage.d.ts.map +1 -0
  68. package/dist/DrizzleBunSqliteStorage.js +11 -0
  69. package/dist/DrizzleBunSqliteStorage.js.map +1 -0
  70. package/dist/DrizzleD1SqliteStorage.d.ts +28 -0
  71. package/dist/DrizzleD1SqliteStorage.d.ts.map +1 -0
  72. package/dist/DrizzleD1SqliteStorage.js +10 -0
  73. package/dist/DrizzleD1SqliteStorage.js.map +1 -0
  74. package/dist/DrizzleDurableObjectSqliteStorage.d.ts +19 -0
  75. package/dist/DrizzleDurableObjectSqliteStorage.d.ts.map +1 -0
  76. package/dist/DrizzleDurableObjectSqliteStorage.js +14 -0
  77. package/dist/DrizzleDurableObjectSqliteStorage.js.map +1 -0
  78. package/dist/DrizzleEffectSqliteStorage.d.ts +31 -0
  79. package/dist/DrizzleEffectSqliteStorage.d.ts.map +1 -0
  80. package/dist/DrizzleEffectSqliteStorage.js +108 -0
  81. package/dist/DrizzleEffectSqliteStorage.js.map +1 -0
  82. package/dist/DrizzleNodeSqliteStorage.d.ts +18 -0
  83. package/dist/DrizzleNodeSqliteStorage.d.ts.map +1 -0
  84. package/dist/DrizzleNodeSqliteStorage.js +11 -0
  85. package/dist/DrizzleNodeSqliteStorage.js.map +1 -0
  86. package/dist/DrizzleWasmSqliteStorage.d.ts +23 -0
  87. package/dist/DrizzleWasmSqliteStorage.d.ts.map +1 -0
  88. package/dist/DrizzleWasmSqliteStorage.js +15 -0
  89. package/dist/DrizzleWasmSqliteStorage.js.map +1 -0
  90. package/dist/EffectQbPostgresDelegatedAccessStorage.d.ts +34 -0
  91. package/dist/EffectQbPostgresDelegatedAccessStorage.d.ts.map +1 -0
  92. package/dist/EffectQbPostgresDelegatedAccessStorage.js +499 -0
  93. package/dist/EffectQbPostgresDelegatedAccessStorage.js.map +1 -0
  94. package/dist/EffectQbPostgresStorage.d.ts +171 -0
  95. package/dist/EffectQbPostgresStorage.d.ts.map +1 -0
  96. package/dist/EffectQbPostgresStorage.js +4280 -0
  97. package/dist/EffectQbPostgresStorage.js.map +1 -0
  98. package/dist/EffectQbSqliteDelegatedAccessStorage.d.ts +112 -0
  99. package/dist/EffectQbSqliteDelegatedAccessStorage.d.ts.map +1 -0
  100. package/dist/EffectQbSqliteDelegatedAccessStorage.js +602 -0
  101. package/dist/EffectQbSqliteDelegatedAccessStorage.js.map +1 -0
  102. package/dist/EffectQbSqliteStorage.d.ts +184 -27
  103. package/dist/EffectQbSqliteStorage.d.ts.map +1 -1
  104. package/dist/EffectQbSqliteStorage.js +1729 -135
  105. package/dist/EffectQbSqliteStorage.js.map +1 -1
  106. package/dist/EmailAuth.d.ts +65 -0
  107. package/dist/EmailAuth.d.ts.map +1 -0
  108. package/dist/EmailAuth.js +171 -0
  109. package/dist/EmailAuth.js.map +1 -0
  110. package/dist/EmailIdentityAuth.d.ts +30 -0
  111. package/dist/EmailIdentityAuth.d.ts.map +1 -0
  112. package/dist/EmailIdentityAuth.js +142 -0
  113. package/dist/EmailIdentityAuth.js.map +1 -0
  114. package/dist/EmailOtp.d.ts +10 -11
  115. package/dist/EmailOtp.d.ts.map +1 -1
  116. package/dist/EmailOtp.js +44 -81
  117. package/dist/EmailOtp.js.map +1 -1
  118. package/dist/EmailRisk.d.ts +48 -0
  119. package/dist/EmailRisk.d.ts.map +1 -0
  120. package/dist/EmailRisk.js +33 -0
  121. package/dist/EmailRisk.js.map +1 -0
  122. package/dist/EmailVerification.d.ts +10 -16
  123. package/dist/EmailVerification.d.ts.map +1 -1
  124. package/dist/EmailVerification.js +85 -42
  125. package/dist/EmailVerification.js.map +1 -1
  126. package/dist/Guard.d.ts +11 -0
  127. package/dist/Guard.d.ts.map +1 -0
  128. package/dist/Guard.js +11 -0
  129. package/dist/Guard.js.map +1 -0
  130. package/dist/HibpPwnedPasswords.d.ts +56 -0
  131. package/dist/HibpPwnedPasswords.d.ts.map +1 -0
  132. package/dist/HibpPwnedPasswords.js +232 -0
  133. package/dist/HibpPwnedPasswords.js.map +1 -0
  134. package/dist/HttpApi/AdminPermissionDefinition.d.ts +4 -0
  135. package/dist/HttpApi/AdminPermissionDefinition.d.ts.map +1 -0
  136. package/dist/HttpApi/AdminPermissionDefinition.js +4 -0
  137. package/dist/HttpApi/AdminPermissionDefinition.js.map +1 -0
  138. package/dist/HttpApi/AdminSecurityTimeline.d.ts +4 -0
  139. package/dist/HttpApi/AdminSecurityTimeline.d.ts.map +1 -0
  140. package/dist/HttpApi/AdminSecurityTimeline.js +4 -0
  141. package/dist/HttpApi/AdminSecurityTimeline.js.map +1 -0
  142. package/dist/HttpApi/AdminSession.d.ts +4 -0
  143. package/dist/HttpApi/AdminSession.d.ts.map +1 -0
  144. package/dist/HttpApi/AdminSession.js +4 -0
  145. package/dist/HttpApi/AdminSession.js.map +1 -0
  146. package/dist/HttpApi/AdminTrustedDevice.d.ts +4 -0
  147. package/dist/HttpApi/AdminTrustedDevice.d.ts.map +1 -0
  148. package/dist/HttpApi/AdminTrustedDevice.js +4 -0
  149. package/dist/HttpApi/AdminTrustedDevice.js.map +1 -0
  150. package/dist/HttpApi/Api.d.ts +1172 -1172
  151. package/dist/HttpApi/Api.d.ts.map +1 -1
  152. package/dist/HttpApi/Api.js +2160 -896
  153. package/dist/HttpApi/Api.js.map +1 -1
  154. package/dist/HttpApi/ApiKey.d.ts +4 -0
  155. package/dist/HttpApi/ApiKey.d.ts.map +1 -0
  156. package/dist/HttpApi/ApiKey.js +4 -0
  157. package/dist/HttpApi/ApiKey.js.map +1 -0
  158. package/dist/HttpApi/Audit.d.ts +6 -0
  159. package/dist/HttpApi/Audit.d.ts.map +1 -0
  160. package/dist/HttpApi/Audit.js +10 -0
  161. package/dist/HttpApi/Audit.js.map +1 -0
  162. package/dist/HttpApi/ClientApi.d.ts +917 -0
  163. package/dist/HttpApi/ClientApi.d.ts.map +1 -0
  164. package/dist/HttpApi/ClientApi.js +101 -0
  165. package/dist/HttpApi/ClientApi.js.map +1 -0
  166. package/dist/HttpApi/EmailAuth.d.ts +6 -0
  167. package/dist/HttpApi/EmailAuth.d.ts.map +1 -0
  168. package/dist/HttpApi/EmailAuth.js +6 -0
  169. package/dist/HttpApi/EmailAuth.js.map +1 -0
  170. package/dist/HttpApi/EmailGuards.d.ts +115 -0
  171. package/dist/HttpApi/EmailGuards.d.ts.map +1 -0
  172. package/dist/HttpApi/EmailGuards.js +191 -0
  173. package/dist/HttpApi/EmailGuards.js.map +1 -0
  174. package/dist/HttpApi/EmailOtp.d.ts +6 -0
  175. package/dist/HttpApi/EmailOtp.d.ts.map +1 -0
  176. package/dist/HttpApi/EmailOtp.js +6 -0
  177. package/dist/HttpApi/EmailOtp.js.map +1 -0
  178. package/dist/HttpApi/EmailVerification.d.ts +6 -0
  179. package/dist/HttpApi/EmailVerification.d.ts.map +1 -0
  180. package/dist/HttpApi/EmailVerification.js +6 -0
  181. package/dist/HttpApi/EmailVerification.js.map +1 -0
  182. package/dist/HttpApi/Endpoints.d.ts +629 -301
  183. package/dist/HttpApi/Endpoints.d.ts.map +1 -1
  184. package/dist/HttpApi/Endpoints.js +178 -120
  185. package/dist/HttpApi/Endpoints.js.map +1 -1
  186. package/dist/HttpApi/Errors.d.ts +26 -7
  187. package/dist/HttpApi/Errors.d.ts.map +1 -1
  188. package/dist/HttpApi/Errors.js +26 -4
  189. package/dist/HttpApi/Errors.js.map +1 -1
  190. package/dist/HttpApi/Identity.d.ts +6 -0
  191. package/dist/HttpApi/Identity.d.ts.map +1 -0
  192. package/dist/HttpApi/Identity.js +6 -0
  193. package/dist/HttpApi/Identity.js.map +1 -0
  194. package/dist/HttpApi/IdentityGuards.d.ts +31 -0
  195. package/dist/HttpApi/IdentityGuards.d.ts.map +1 -0
  196. package/dist/HttpApi/IdentityGuards.js +33 -0
  197. package/dist/HttpApi/IdentityGuards.js.map +1 -0
  198. package/dist/HttpApi/Jwt.d.ts +4 -0
  199. package/dist/HttpApi/Jwt.d.ts.map +1 -0
  200. package/dist/HttpApi/Jwt.js +4 -0
  201. package/dist/HttpApi/Jwt.js.map +1 -0
  202. package/dist/HttpApi/JwtDiscovery.d.ts +4 -0
  203. package/dist/HttpApi/JwtDiscovery.d.ts.map +1 -0
  204. package/dist/HttpApi/JwtDiscovery.js +4 -0
  205. package/dist/HttpApi/JwtDiscovery.js.map +1 -0
  206. package/dist/HttpApi/LoginApproval.d.ts +5 -0
  207. package/dist/HttpApi/LoginApproval.d.ts.map +1 -0
  208. package/dist/HttpApi/LoginApproval.js +5 -0
  209. package/dist/HttpApi/LoginApproval.js.map +1 -0
  210. package/dist/HttpApi/LoginNotification.d.ts +5 -0
  211. package/dist/HttpApi/LoginNotification.d.ts.map +1 -0
  212. package/dist/HttpApi/LoginNotification.js +5 -0
  213. package/dist/HttpApi/LoginNotification.js.map +1 -0
  214. package/dist/HttpApi/MagicLink.d.ts +6 -0
  215. package/dist/HttpApi/MagicLink.d.ts.map +1 -0
  216. package/dist/HttpApi/MagicLink.js +6 -0
  217. package/dist/HttpApi/MagicLink.js.map +1 -0
  218. package/dist/HttpApi/Mfa.d.ts +5 -0
  219. package/dist/HttpApi/Mfa.d.ts.map +1 -0
  220. package/dist/HttpApi/Mfa.js +5 -0
  221. package/dist/HttpApi/Mfa.js.map +1 -0
  222. package/dist/HttpApi/Middleware.d.ts +14 -0
  223. package/dist/HttpApi/Middleware.d.ts.map +1 -0
  224. package/dist/HttpApi/Middleware.js +5 -0
  225. package/dist/HttpApi/Middleware.js.map +1 -0
  226. package/dist/HttpApi/OAuth.d.ts +4 -0
  227. package/dist/HttpApi/OAuth.d.ts.map +1 -0
  228. package/dist/HttpApi/OAuth.js +4 -0
  229. package/dist/HttpApi/OAuth.js.map +1 -0
  230. package/dist/HttpApi/OAuthProviderAuthorization.d.ts +4 -0
  231. package/dist/HttpApi/OAuthProviderAuthorization.d.ts.map +1 -0
  232. package/dist/HttpApi/OAuthProviderAuthorization.js +4 -0
  233. package/dist/HttpApi/OAuthProviderAuthorization.js.map +1 -0
  234. package/dist/HttpApi/OAuthToken.d.ts +4 -0
  235. package/dist/HttpApi/OAuthToken.d.ts.map +1 -0
  236. package/dist/HttpApi/OAuthToken.js +4 -0
  237. package/dist/HttpApi/OAuthToken.js.map +1 -0
  238. package/dist/HttpApi/OidcDiscovery.d.ts +4 -0
  239. package/dist/HttpApi/OidcDiscovery.d.ts.map +1 -0
  240. package/dist/HttpApi/OidcDiscovery.js +4 -0
  241. package/dist/HttpApi/OidcDiscovery.js.map +1 -0
  242. package/dist/HttpApi/Operations/AdminPermissionDefinition.d.ts +28 -0
  243. package/dist/HttpApi/Operations/AdminPermissionDefinition.d.ts.map +1 -0
  244. package/dist/HttpApi/Operations/AdminPermissionDefinition.js +5 -0
  245. package/dist/HttpApi/Operations/AdminPermissionDefinition.js.map +1 -0
  246. package/dist/HttpApi/Operations/AdminSession.d.ts +16 -0
  247. package/dist/HttpApi/Operations/AdminSession.d.ts.map +1 -0
  248. package/dist/HttpApi/Operations/AdminSession.js +5 -0
  249. package/dist/HttpApi/Operations/AdminSession.js.map +1 -0
  250. package/dist/HttpApi/Operations/ApiKey.d.ts +16 -0
  251. package/dist/HttpApi/Operations/ApiKey.d.ts.map +1 -0
  252. package/dist/HttpApi/Operations/ApiKey.js +5 -0
  253. package/dist/HttpApi/Operations/ApiKey.js.map +1 -0
  254. package/dist/HttpApi/Operations/Discovery.d.ts +19 -0
  255. package/dist/HttpApi/Operations/Discovery.d.ts.map +1 -0
  256. package/dist/HttpApi/Operations/Discovery.js +7 -0
  257. package/dist/HttpApi/Operations/Discovery.js.map +1 -0
  258. package/dist/HttpApi/Operations/EmailAuth.d.ts +12 -0
  259. package/dist/HttpApi/Operations/EmailAuth.d.ts.map +1 -0
  260. package/dist/HttpApi/Operations/EmailAuth.js +5 -0
  261. package/dist/HttpApi/Operations/EmailAuth.js.map +1 -0
  262. package/dist/HttpApi/Operations/EmailOtp.d.ts +14 -0
  263. package/dist/HttpApi/Operations/EmailOtp.d.ts.map +1 -0
  264. package/dist/HttpApi/Operations/EmailOtp.js +5 -0
  265. package/dist/HttpApi/Operations/EmailOtp.js.map +1 -0
  266. package/dist/HttpApi/Operations/EmailVerification.d.ts +14 -0
  267. package/dist/HttpApi/Operations/EmailVerification.d.ts.map +1 -0
  268. package/dist/HttpApi/Operations/EmailVerification.js +5 -0
  269. package/dist/HttpApi/Operations/EmailVerification.js.map +1 -0
  270. package/dist/HttpApi/Operations/HttpOperation.d.ts +4 -0
  271. package/dist/HttpApi/Operations/HttpOperation.d.ts.map +1 -0
  272. package/dist/HttpApi/Operations/HttpOperation.js +2 -0
  273. package/dist/HttpApi/Operations/HttpOperation.js.map +1 -0
  274. package/dist/HttpApi/Operations/Identity.d.ts +22 -0
  275. package/dist/HttpApi/Operations/Identity.d.ts.map +1 -0
  276. package/dist/HttpApi/Operations/Identity.js +5 -0
  277. package/dist/HttpApi/Operations/Identity.js.map +1 -0
  278. package/dist/HttpApi/Operations/Jwt.d.ts +14 -0
  279. package/dist/HttpApi/Operations/Jwt.d.ts.map +1 -0
  280. package/dist/HttpApi/Operations/Jwt.js +5 -0
  281. package/dist/HttpApi/Operations/Jwt.js.map +1 -0
  282. package/dist/HttpApi/Operations/LoginApproval.d.ts +16 -0
  283. package/dist/HttpApi/Operations/LoginApproval.d.ts.map +1 -0
  284. package/dist/HttpApi/Operations/LoginApproval.js +5 -0
  285. package/dist/HttpApi/Operations/LoginApproval.js.map +1 -0
  286. package/dist/HttpApi/Operations/MagicLink.d.ts +14 -0
  287. package/dist/HttpApi/Operations/MagicLink.d.ts.map +1 -0
  288. package/dist/HttpApi/Operations/MagicLink.js +5 -0
  289. package/dist/HttpApi/Operations/MagicLink.js.map +1 -0
  290. package/dist/HttpApi/Operations/Mfa.d.ts +24 -0
  291. package/dist/HttpApi/Operations/Mfa.d.ts.map +1 -0
  292. package/dist/HttpApi/Operations/Mfa.js +5 -0
  293. package/dist/HttpApi/Operations/Mfa.js.map +1 -0
  294. package/dist/HttpApi/Operations/OAuth.d.ts +20 -0
  295. package/dist/HttpApi/Operations/OAuth.d.ts.map +1 -0
  296. package/dist/HttpApi/Operations/OAuth.js +5 -0
  297. package/dist/HttpApi/Operations/OAuth.js.map +1 -0
  298. package/dist/HttpApi/Operations/OAuthProviderAuthorization.d.ts +12 -0
  299. package/dist/HttpApi/Operations/OAuthProviderAuthorization.d.ts.map +1 -0
  300. package/dist/HttpApi/Operations/OAuthProviderAuthorization.js +5 -0
  301. package/dist/HttpApi/Operations/OAuthProviderAuthorization.js.map +1 -0
  302. package/dist/HttpApi/Operations/OAuthToken.d.ts +16 -0
  303. package/dist/HttpApi/Operations/OAuthToken.d.ts.map +1 -0
  304. package/dist/HttpApi/Operations/OAuthToken.js +5 -0
  305. package/dist/HttpApi/Operations/OAuthToken.js.map +1 -0
  306. package/dist/HttpApi/Operations/Passkey.d.ts +22 -0
  307. package/dist/HttpApi/Operations/Passkey.d.ts.map +1 -0
  308. package/dist/HttpApi/Operations/Passkey.js +5 -0
  309. package/dist/HttpApi/Operations/Passkey.js.map +1 -0
  310. package/dist/HttpApi/Operations/Password.d.ts +22 -0
  311. package/dist/HttpApi/Operations/Password.d.ts.map +1 -0
  312. package/dist/HttpApi/Operations/Password.js +5 -0
  313. package/dist/HttpApi/Operations/Password.js.map +1 -0
  314. package/dist/HttpApi/Operations/RecoveryCodes.d.ts +20 -0
  315. package/dist/HttpApi/Operations/RecoveryCodes.d.ts.map +1 -0
  316. package/dist/HttpApi/Operations/RecoveryCodes.js +5 -0
  317. package/dist/HttpApi/Operations/RecoveryCodes.js.map +1 -0
  318. package/dist/HttpApi/Operations/RefreshToken.d.ts +12 -0
  319. package/dist/HttpApi/Operations/RefreshToken.d.ts.map +1 -0
  320. package/dist/HttpApi/Operations/RefreshToken.js +5 -0
  321. package/dist/HttpApi/Operations/RefreshToken.js.map +1 -0
  322. package/dist/HttpApi/Operations/Security.d.ts +12 -0
  323. package/dist/HttpApi/Operations/Security.d.ts.map +1 -0
  324. package/dist/HttpApi/Operations/Security.js +5 -0
  325. package/dist/HttpApi/Operations/Security.js.map +1 -0
  326. package/dist/HttpApi/Operations/SecurityTimeline.d.ts +19 -0
  327. package/dist/HttpApi/Operations/SecurityTimeline.d.ts.map +1 -0
  328. package/dist/HttpApi/Operations/SecurityTimeline.js +7 -0
  329. package/dist/HttpApi/Operations/SecurityTimeline.js.map +1 -0
  330. package/dist/HttpApi/Operations/Session.d.ts +22 -0
  331. package/dist/HttpApi/Operations/Session.d.ts.map +1 -0
  332. package/dist/HttpApi/Operations/Session.js +5 -0
  333. package/dist/HttpApi/Operations/Session.js.map +1 -0
  334. package/dist/HttpApi/Operations/StepUp.d.ts +22 -0
  335. package/dist/HttpApi/Operations/StepUp.d.ts.map +1 -0
  336. package/dist/HttpApi/Operations/StepUp.js +5 -0
  337. package/dist/HttpApi/Operations/StepUp.js.map +1 -0
  338. package/dist/HttpApi/Operations/Totp.d.ts +20 -0
  339. package/dist/HttpApi/Operations/Totp.d.ts.map +1 -0
  340. package/dist/HttpApi/Operations/Totp.js +5 -0
  341. package/dist/HttpApi/Operations/Totp.js.map +1 -0
  342. package/dist/HttpApi/Operations/TrustedDevice.d.ts +23 -0
  343. package/dist/HttpApi/Operations/TrustedDevice.d.ts.map +1 -0
  344. package/dist/HttpApi/Operations/TrustedDevice.js +7 -0
  345. package/dist/HttpApi/Operations/TrustedDevice.js.map +1 -0
  346. package/dist/HttpApi/Operations/index.d.ts +27 -0
  347. package/dist/HttpApi/Operations/index.d.ts.map +1 -0
  348. package/dist/HttpApi/Operations/index.js +27 -0
  349. package/dist/HttpApi/Operations/index.js.map +1 -0
  350. package/dist/HttpApi/Passkey.d.ts +5 -0
  351. package/dist/HttpApi/Passkey.d.ts.map +1 -0
  352. package/dist/HttpApi/Passkey.js +5 -0
  353. package/dist/HttpApi/Passkey.js.map +1 -0
  354. package/dist/HttpApi/Password.d.ts +220 -0
  355. package/dist/HttpApi/Password.d.ts.map +1 -0
  356. package/dist/HttpApi/Password.js +237 -0
  357. package/dist/HttpApi/Password.js.map +1 -0
  358. package/dist/HttpApi/PasswordContract.d.ts +307 -0
  359. package/dist/HttpApi/PasswordContract.d.ts.map +1 -0
  360. package/dist/HttpApi/PasswordContract.js +63 -0
  361. package/dist/HttpApi/PasswordContract.js.map +1 -0
  362. package/dist/HttpApi/PasswordGuards.d.ts +82 -0
  363. package/dist/HttpApi/PasswordGuards.d.ts.map +1 -0
  364. package/dist/HttpApi/PasswordGuards.js +179 -0
  365. package/dist/HttpApi/PasswordGuards.js.map +1 -0
  366. package/dist/HttpApi/RecoveryCodes.d.ts +5 -0
  367. package/dist/HttpApi/RecoveryCodes.d.ts.map +1 -0
  368. package/dist/HttpApi/RecoveryCodes.js +5 -0
  369. package/dist/HttpApi/RecoveryCodes.js.map +1 -0
  370. package/dist/HttpApi/RefreshToken.d.ts +4 -0
  371. package/dist/HttpApi/RefreshToken.d.ts.map +1 -0
  372. package/dist/HttpApi/RefreshToken.js +4 -0
  373. package/dist/HttpApi/RefreshToken.js.map +1 -0
  374. package/dist/HttpApi/RequestGuards.d.ts +42 -0
  375. package/dist/HttpApi/RequestGuards.d.ts.map +1 -0
  376. package/dist/HttpApi/RequestGuards.js +194 -0
  377. package/dist/HttpApi/RequestGuards.js.map +1 -0
  378. package/dist/HttpApi/Schemas.d.ts +361 -84
  379. package/dist/HttpApi/Schemas.d.ts.map +1 -1
  380. package/dist/HttpApi/Schemas.js +190 -27
  381. package/dist/HttpApi/Schemas.js.map +1 -1
  382. package/dist/HttpApi/Security.d.ts +12 -93
  383. package/dist/HttpApi/Security.d.ts.map +1 -1
  384. package/dist/HttpApi/Security.js +65 -356
  385. package/dist/HttpApi/Security.js.map +1 -1
  386. package/dist/HttpApi/SecurityTimeline.d.ts +4 -0
  387. package/dist/HttpApi/SecurityTimeline.d.ts.map +1 -0
  388. package/dist/HttpApi/SecurityTimeline.js +4 -0
  389. package/dist/HttpApi/SecurityTimeline.js.map +1 -0
  390. package/dist/HttpApi/Session.d.ts +5 -0
  391. package/dist/HttpApi/Session.d.ts.map +1 -0
  392. package/dist/HttpApi/Session.js +5 -0
  393. package/dist/HttpApi/Session.js.map +1 -0
  394. package/dist/HttpApi/SessionGuards.d.ts +15 -0
  395. package/dist/HttpApi/SessionGuards.d.ts.map +1 -0
  396. package/dist/HttpApi/SessionGuards.js +37 -0
  397. package/dist/HttpApi/SessionGuards.js.map +1 -0
  398. package/dist/HttpApi/StepUp.d.ts +5 -0
  399. package/dist/HttpApi/StepUp.d.ts.map +1 -0
  400. package/dist/HttpApi/StepUp.js +5 -0
  401. package/dist/HttpApi/StepUp.js.map +1 -0
  402. package/dist/HttpApi/Totp.d.ts +5 -0
  403. package/dist/HttpApi/Totp.d.ts.map +1 -0
  404. package/dist/HttpApi/Totp.js +5 -0
  405. package/dist/HttpApi/Totp.js.map +1 -0
  406. package/dist/HttpApi/Transport.d.ts +4 -6
  407. package/dist/HttpApi/Transport.d.ts.map +1 -1
  408. package/dist/HttpApi/Transport.js +62 -36
  409. package/dist/HttpApi/Transport.js.map +1 -1
  410. package/dist/HttpApi/TrustedDevice.d.ts +4 -0
  411. package/dist/HttpApi/TrustedDevice.d.ts.map +1 -0
  412. package/dist/HttpApi/TrustedDevice.js +4 -0
  413. package/dist/HttpApi/TrustedDevice.js.map +1 -0
  414. package/dist/HttpApi/index.d.ts +9 -3
  415. package/dist/HttpApi/index.d.ts.map +1 -1
  416. package/dist/HttpApi/index.js +8 -2
  417. package/dist/HttpApi/index.js.map +1 -1
  418. package/dist/Identity.d.ts +138 -0
  419. package/dist/Identity.d.ts.map +1 -0
  420. package/dist/Identity.js +105 -0
  421. package/dist/Identity.js.map +1 -0
  422. package/dist/IdentityManagement.d.ts +189 -0
  423. package/dist/IdentityManagement.d.ts.map +1 -0
  424. package/dist/IdentityManagement.js +317 -0
  425. package/dist/IdentityManagement.js.map +1 -0
  426. package/dist/IncidentAction.d.ts +1 -4
  427. package/dist/IncidentAction.d.ts.map +1 -1
  428. package/dist/IncidentAction.js +15 -9
  429. package/dist/IncidentAction.js.map +1 -1
  430. package/dist/Internal.d.ts +2 -0
  431. package/dist/Internal.d.ts.map +1 -1
  432. package/dist/Internal.js +30 -0
  433. package/dist/Internal.js.map +1 -1
  434. package/dist/Invitation.d.ts +362 -0
  435. package/dist/Invitation.d.ts.map +1 -0
  436. package/dist/Invitation.js +633 -0
  437. package/dist/Invitation.js.map +1 -0
  438. package/dist/IpQualityScore.d.ts +38 -0
  439. package/dist/IpQualityScore.d.ts.map +1 -0
  440. package/dist/IpQualityScore.js +215 -0
  441. package/dist/IpQualityScore.js.map +1 -0
  442. package/dist/Jwt.d.ts +9 -30
  443. package/dist/Jwt.d.ts.map +1 -1
  444. package/dist/Jwt.js +72 -60
  445. package/dist/Jwt.js.map +1 -1
  446. package/dist/LoginApproval.d.ts +16 -31
  447. package/dist/LoginApproval.d.ts.map +1 -1
  448. package/dist/LoginApproval.js +47 -41
  449. package/dist/LoginApproval.js.map +1 -1
  450. package/dist/LoginNotification.d.ts +8 -12
  451. package/dist/LoginNotification.d.ts.map +1 -1
  452. package/dist/LoginNotification.js +30 -17
  453. package/dist/LoginNotification.js.map +1 -1
  454. package/dist/LoginRisk.d.ts +11 -13
  455. package/dist/LoginRisk.d.ts.map +1 -1
  456. package/dist/LoginRisk.js +66 -26
  457. package/dist/LoginRisk.js.map +1 -1
  458. package/dist/LoginRiskEnrichment.d.ts +145 -0
  459. package/dist/LoginRiskEnrichment.d.ts.map +1 -0
  460. package/dist/LoginRiskEnrichment.js +220 -0
  461. package/dist/LoginRiskEnrichment.js.map +1 -0
  462. package/dist/MachineAuth.d.ts.map +1 -1
  463. package/dist/MachineAuth.js.map +1 -1
  464. package/dist/MagicLink.d.ts +9 -8
  465. package/dist/MagicLink.d.ts.map +1 -1
  466. package/dist/MagicLink.js +40 -73
  467. package/dist/MagicLink.js.map +1 -1
  468. package/dist/Mailer.d.ts +20 -13
  469. package/dist/Mailer.d.ts.map +1 -1
  470. package/dist/Mailer.js +10 -12
  471. package/dist/Mailer.js.map +1 -1
  472. package/dist/OAuth.d.ts +100 -103
  473. package/dist/OAuth.d.ts.map +1 -1
  474. package/dist/OAuth.js +404 -217
  475. package/dist/OAuth.js.map +1 -1
  476. package/dist/Passkey.d.ts +17 -19
  477. package/dist/Passkey.d.ts.map +1 -1
  478. package/dist/Passkey.js +86 -39
  479. package/dist/Passkey.js.map +1 -1
  480. package/dist/PasskeyBrowser.d.ts +39 -0
  481. package/dist/PasskeyBrowser.d.ts.map +1 -0
  482. package/dist/PasskeyBrowser.js +206 -0
  483. package/dist/PasskeyBrowser.js.map +1 -0
  484. package/dist/PasskeySimpleWebAuthn.d.ts.map +1 -1
  485. package/dist/PasskeySimpleWebAuthn.js +19 -7
  486. package/dist/PasskeySimpleWebAuthn.js.map +1 -1
  487. package/dist/Password.d.ts +71 -37
  488. package/dist/Password.d.ts.map +1 -1
  489. package/dist/Password.js +296 -82
  490. package/dist/Password.js.map +1 -1
  491. package/dist/PasswordRisk.d.ts +63 -0
  492. package/dist/PasswordRisk.d.ts.map +1 -0
  493. package/dist/PasswordRisk.js +37 -0
  494. package/dist/PasswordRisk.js.map +1 -0
  495. package/dist/Permission.d.ts +308 -0
  496. package/dist/Permission.d.ts.map +1 -0
  497. package/dist/Permission.js +827 -0
  498. package/dist/Permission.js.map +1 -0
  499. package/dist/Policy.d.ts +31 -18
  500. package/dist/Policy.d.ts.map +1 -1
  501. package/dist/Policy.js +58 -14
  502. package/dist/Policy.js.map +1 -1
  503. package/dist/PostgresDelegatedAccessStorageMigrations.d.ts +7 -0
  504. package/dist/PostgresDelegatedAccessStorageMigrations.d.ts.map +1 -0
  505. package/dist/PostgresDelegatedAccessStorageMigrations.js +119 -0
  506. package/dist/PostgresDelegatedAccessStorageMigrations.js.map +1 -0
  507. package/dist/PostgresStorageMigrations.d.ts +15 -0
  508. package/dist/PostgresStorageMigrations.d.ts.map +1 -0
  509. package/dist/PostgresStorageMigrations.js +620 -0
  510. package/dist/PostgresStorageMigrations.js.map +1 -0
  511. package/dist/Privacy.d.ts +0 -3
  512. package/dist/Privacy.d.ts.map +1 -1
  513. package/dist/Privacy.js +2 -5
  514. package/dist/Privacy.js.map +1 -1
  515. package/dist/RateLimiter.d.ts +0 -3
  516. package/dist/RateLimiter.d.ts.map +1 -1
  517. package/dist/RateLimiter.js +1 -4
  518. package/dist/RateLimiter.js.map +1 -1
  519. package/dist/RecoveryCode.d.ts +84 -12
  520. package/dist/RecoveryCode.d.ts.map +1 -1
  521. package/dist/RecoveryCode.js +273 -75
  522. package/dist/RecoveryCode.js.map +1 -1
  523. package/dist/RecoveryPolicy.d.ts +81 -0
  524. package/dist/RecoveryPolicy.d.ts.map +1 -0
  525. package/dist/RecoveryPolicy.js +119 -0
  526. package/dist/RecoveryPolicy.js.map +1 -0
  527. package/dist/RefreshToken.d.ts +1 -10
  528. package/dist/RefreshToken.d.ts.map +1 -1
  529. package/dist/RefreshToken.js +31 -22
  530. package/dist/RefreshToken.js.map +1 -1
  531. package/dist/Retention.d.ts.map +1 -1
  532. package/dist/Retention.js.map +1 -1
  533. package/dist/SecurityTimeline.d.ts +1 -4
  534. package/dist/SecurityTimeline.d.ts.map +1 -1
  535. package/dist/SecurityTimeline.js +110 -17
  536. package/dist/SecurityTimeline.js.map +1 -1
  537. package/dist/Sessions.d.ts +124 -29
  538. package/dist/Sessions.d.ts.map +1 -1
  539. package/dist/Sessions.js +626 -94
  540. package/dist/Sessions.js.map +1 -1
  541. package/dist/StepUp.d.ts +132 -11
  542. package/dist/StepUp.d.ts.map +1 -1
  543. package/dist/StepUp.js +387 -19
  544. package/dist/StepUp.js.map +1 -1
  545. package/dist/Storage.d.ts +89 -23
  546. package/dist/Storage.d.ts.map +1 -1
  547. package/dist/Storage.js +10 -12
  548. package/dist/Storage.js.map +1 -1
  549. package/dist/StorageMigrations.d.ts +6 -1
  550. package/dist/StorageMigrations.d.ts.map +1 -1
  551. package/dist/StorageMigrations.js +224 -0
  552. package/dist/StorageMigrations.js.map +1 -1
  553. package/dist/StorageSchemaGenerator.d.ts +486 -0
  554. package/dist/StorageSchemaGenerator.d.ts.map +1 -0
  555. package/dist/StorageSchemaGenerator.js +1022 -0
  556. package/dist/StorageSchemaGenerator.js.map +1 -0
  557. package/dist/StrongFactor.d.ts +64 -0
  558. package/dist/StrongFactor.d.ts.map +1 -0
  559. package/dist/StrongFactor.js +100 -0
  560. package/dist/StrongFactor.js.map +1 -0
  561. package/dist/Testing.d.ts +1 -1
  562. package/dist/Testing.js +2 -2
  563. package/dist/Testing.js.map +1 -1
  564. package/dist/Totp.d.ts +88 -13
  565. package/dist/Totp.d.ts.map +1 -1
  566. package/dist/Totp.js +194 -36
  567. package/dist/Totp.js.map +1 -1
  568. package/dist/TrustedDevice.d.ts +0 -9
  569. package/dist/TrustedDevice.d.ts.map +1 -1
  570. package/dist/TrustedDevice.js +15 -17
  571. package/dist/TrustedDevice.js.map +1 -1
  572. package/dist/WaitUntil.d.ts +0 -3
  573. package/dist/WaitUntil.d.ts.map +1 -1
  574. package/dist/WaitUntil.js +1 -4
  575. package/dist/WaitUntil.js.map +1 -1
  576. package/dist/Webhook.d.ts +42 -12
  577. package/dist/Webhook.d.ts.map +1 -1
  578. package/dist/Webhook.js +165 -26
  579. package/dist/Webhook.js.map +1 -1
  580. package/dist/alchemy/cloudflare/Email.d.ts +4 -4
  581. package/dist/alchemy/cloudflare/Email.d.ts.map +1 -1
  582. package/dist/alchemy/cloudflare/Email.js +10 -5
  583. package/dist/alchemy/cloudflare/Email.js.map +1 -1
  584. package/dist/alchemy/cloudflare/RateLimitDurableObject.d.ts +4 -4
  585. package/dist/alchemy/cloudflare/RateLimitDurableObject.d.ts.map +1 -1
  586. package/dist/alchemy/cloudflare/RateLimitDurableObject.js +5 -4
  587. package/dist/alchemy/cloudflare/RateLimitDurableObject.js.map +1 -1
  588. package/dist/cloudflare/Email.d.ts.map +1 -1
  589. package/dist/cloudflare/Email.js +1 -1
  590. package/dist/cloudflare/Email.js.map +1 -1
  591. package/dist/cloudflare/RateLimitDurableObject.d.ts +6 -5
  592. package/dist/cloudflare/RateLimitDurableObject.d.ts.map +1 -1
  593. package/dist/cloudflare/RateLimitDurableObject.js.map +1 -1
  594. package/dist/cloudflare/RequestMetadata.d.ts +49 -0
  595. package/dist/cloudflare/RequestMetadata.d.ts.map +1 -0
  596. package/dist/cloudflare/RequestMetadata.js +71 -0
  597. package/dist/cloudflare/RequestMetadata.js.map +1 -0
  598. package/dist/index.d.ts +0 -35
  599. package/dist/index.d.ts.map +1 -1
  600. package/dist/index.js +0 -35
  601. package/dist/index.js.map +1 -1
  602. package/dist/internal/AuthFlowFinalizer.d.ts +31 -0
  603. package/dist/internal/AuthFlowFinalizer.d.ts.map +1 -0
  604. package/dist/internal/AuthFlowFinalizer.js +182 -0
  605. package/dist/internal/AuthFlowFinalizer.js.map +1 -0
  606. package/dist/internal/RateLimitDurableObject.d.ts.map +1 -1
  607. package/dist/internal/RateLimitDurableObject.js +3 -0
  608. package/dist/internal/RateLimitDurableObject.js.map +1 -1
  609. package/migrations/0001_auth_storage.sql +1 -0
  610. package/migrations/0006_auth_totp_factor.sql +1 -0
  611. package/migrations/0024_auth_permission.sql +39 -0
  612. package/migrations/0025_auth_permission_definition.sql +19 -0
  613. package/migrations/0026_auth_user_identity.sql +59 -0
  614. package/migrations/0027_auth_audit_log_storage_order.sql +46 -0
  615. package/migrations/0028_auth_oauth_client_secret_key.sql +39 -0
  616. package/migrations/delegated-access/0001_auth_delegated_access.sql +152 -0
  617. package/migrations/postgres/0001_auth_core.sql +77 -0
  618. package/migrations/postgres/0002_auth_security_oauth.sql +65 -0
  619. package/migrations/postgres/0003_auth_credentials_tokens.sql +43 -0
  620. package/migrations/postgres/0004_auth_security_history.sql +103 -0
  621. package/migrations/postgres/0005_auth_webhooks.sql +29 -0
  622. package/migrations/postgres/0006_auth_domain_timeline.sql +50 -0
  623. package/migrations/postgres/0007_auth_oauth_clients.sql +85 -0
  624. package/migrations/postgres/0008_auth_oauth_tokens.sql +63 -0
  625. package/migrations/postgres/0009_auth_permissions.sql +66 -0
  626. package/migrations/postgres/delegated-access/0001_auth_delegated_access.sql +112 -0
  627. package/package.json +309 -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 = ["openid", "email", "profile"];
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
- (function (OAuthAccountLinking) {
292
- OAuthAccountLinking.make = (service) => OAuthAccountLinking.of(service);
293
- })(OAuthAccountLinking || (OAuthAccountLinking = {}));
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.digestSha256({ data: `oauth-client-secret:${secret}` }).pipe(Effect.map((hash) => OAuthClientSecretHash(`sha256:${hash}`)), Effect.mapError((cause) => oauthClientSecretError(operation, "Failed to hash OAuth client secret", cause)));
401
- export const makeOAuthClientSecrets = (dependencies) => OAuthClientSecrets.make({
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 ? {} : { metadata: metadataValue(provider.metadata) }),
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 ? {} : { metadata: metadataValue(client.metadata) }),
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 ? {} : { metadata: metadataValue(record.metadata) }),
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 ? {} : { metadata: metadataValue(record.metadata) }),
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 ? {} : { refreshToken: tokens.refreshToken }),
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 ? {} : { scopes: [...response.scopes] }),
653
- ...(response.clientId === undefined ? {} : { clientId: response.clientId }),
654
- ...(response.username === undefined ? {} : { username: response.username }),
655
- ...(response.tokenType === undefined ? {} : { tokenType: response.tokenType }),
656
- ...(response.expiresAt === undefined ? {} : { expiresAt: response.expiresAt }),
657
- ...(response.issuedAt === undefined ? {} : { issuedAt: response.issuedAt }),
658
- ...(response.notBefore === undefined ? {} : { notBefore: response.notBefore }),
659
- ...(response.subject === undefined ? {} : { subject: response.subject }),
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 ? {} : { extra: metadataValue(response.extra) }),
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 ? {} : { metadata: metadataValue(record.metadata) }),
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 ? {} : { metadata: metadataValue(record.metadata) }),
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 ? {} : { email: input.identity.email }),
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 ? {} : { metadata: metadataValue(appMetadata) }),
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 ? {} : { metadata: metadataValue(input.metadata) }),
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 || key.expiresAt === undefined || Number(now) < Number(key.expiresAt);
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.make({
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 { valid: false, reason: claims };
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.make({
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 ? undefined : nonEmptyStringFromUnknown(userInfo.sub);
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.make({
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 ? {} : { avatarUrl: profile.avatarUrl }),
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.make({
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 ? {} : { refreshTokenCiphertext }),
1397
+ ...(refreshTokenCiphertext === undefined
1398
+ ? {}
1399
+ : { refreshTokenCiphertext }),
1417
1400
  ...(idTokenCiphertext === undefined ? {} : { idTokenCiphertext }),
1418
- ...(input.tokens.scopes === undefined ? {} : { scopes: input.tokens.scopes }),
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.decryptToken(tokenCiphertext).pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("revoke", `Failed to decrypt OAuth provider ${tokenTypeHint}`, cause)));
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.request(request).pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("revoke", "Failed to execute OAuth provider token revocation request", cause)));
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.make({
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.request(request).pipe(Effect.mapError((cause) => oauthProviderTokenLifecycleError("refresh", "Failed to execute OAuth provider token refresh request", cause)));
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 ?? verifiedState.redirectUri ?? input.provider.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.make({
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 ? "matched-email" : "unverified-email",
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 makeOAuthAccountUnlinkingPolicy = (dependencies) => OAuthAccountUnlinking.make({
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 && remainingAccounts.length === 0) {
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 && input.stepUpSatisfied !== 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.make({
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 ?? defaultOAuthLinkConfirmationSecretBytes))
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 && input.currentUserId !== pending.userId) {
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) ? { existingAccount: existing.value } : {}),
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.digestSha256({ data: String(code) }).pipe(Effect.mapError((cause) => oauthAuthorizationCodeGrantError(operation, "Failed to hash OAuth authorization code", cause)));
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.make({
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.upsert(record).pipe(Effect.mapError((cause) => oauthAuthorizationCodeGrantError("issue", "Failed to store OAuth authorization code", cause)));
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.findByHash({ codeHash }).pipe(Effect.mapError((cause) => oauthAuthorizationCodeGrantError("consume", "Failed to load OAuth authorization code", cause)));
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 || scopes.every((scope) => allowedScopes.includes(scope));
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.randomToken(validByteLength).pipe(Effect.mapError((cause) => error(`Failed to generate OAuth ${label} token`, cause)));
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 ? undefined : Array.isArray(audience) ? [...audience] : audience;
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
- : { audience: oauthProviderModeOpaqueTokenAudience(dependencies.audience) }),
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.upsert(record).pipe(Effect.mapError((cause) => error("Failed to store OAuth provider-mode token", cause)));
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.make({
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 || clientId === undefined || redirectUri === 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.find({ clientId }).pipe(Effect.mapError((cause) => oauthAuthorizationCodeTokenGrantError("exchange", "Failed to load OAuth client", cause)));
1975
- if (Option.isNone(clientOption) || clientOption.value.status !== "active") {
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" && input.clientAuthenticated !== true) {
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.make({
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.find({ clientId }).pipe(Effect.mapError((cause) => oauthRefreshTokenGrantError("exchange", "Failed to load OAuth client", cause)));
2022
- if (Option.isNone(clientOption) || clientOption.value.status !== "active") {
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" && input.clientAuthenticated !== true) {
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.make({
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.find({ clientId }).pipe(Effect.mapError((cause) => oauthClientCredentialsGrantError("exchange", "Failed to load OAuth client", cause)));
2065
- if (Option.isNone(clientOption) || clientOption.value.status !== "active") {
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.make({
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.make({
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.make({
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.make({
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.parse(input.clientSecret).pipe(Effect.catchTag("OAuthClientSecretError", () => Effect.succeed(undefined)));
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.make({
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 || tokenValue === undefined || clientId === 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.find({ clientId }).pipe(Effect.mapError((cause) => oauthTokenRevocationError("revoke", "Failed to load OAuth client", cause)));
2313
- if (Option.isNone(clientOption) || clientOption.value.status !== "active") {
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" || input.clientAuthenticated !== true) {
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.make({
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 ? undefined : String(Redacted.value(token)).trim();
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 || tokenValue === undefined || clientId === 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.find({ clientId }).pipe(Effect.mapError((cause) => oauthTokenIntrospectionError("introspect", "Failed to load OAuth client", cause)));
2345
- if (Option.isNone(clientOption) || clientOption.value.status !== "active") {
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" || input.clientAuthenticated !== true) {
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 ? {} : { redirectUri: input.redirectUri }),
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 || scopes.every((scope) => allowedScopes.includes(scope));
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.make({
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.find({ clientId }).pipe(Effect.mapError((cause) => oauthProviderAuthorizationError("authorize", "Failed to load OAuth client", cause)));
2414
- if (Option.isNone(clientOption) || clientOption.value.status !== "active") {
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 ? undefined : String(input.codeChallenge));
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.make({
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.randomToken(stateSecretBytes).pipe(Effect.map(Redacted.make), Effect.mapError((cause) => oauthStateError("start", "Failed to generate OAuth state secret", cause)));
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 ? {} : { metadata: input.metadata }),
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({ challengeId: issued.id, secret: stateSecret });
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({ clients, authorizationCodes, policy });
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.make({
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.make({
2700
- find: (input) => store.find(input).pipe(Effect.mapError((cause) => oauthClientRegistryError("find", "Failed to load OAuth client", cause))),
2701
- validateRedirectUri: (input) => store.validateRedirectUri(input).pipe(Effect.mapError((cause) => oauthClientRegistryError("validate-redirect-uri", "Failed to validate OAuth client redirect URI", cause))),
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.make({
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.make({
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.succeed(OAuthClientStore)(makeOAuthClientStoreMemory(clients));
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.make({
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.succeed(OAuthConsentStore)(makeOAuthConsentStoreMemory(records));
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.make({
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.make({
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.make({
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 ? {} : { metadata: metadataValue(record.metadata) }),
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.make({
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.make({
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 ? Option.none() : Option.some(cloneOAuthAccountRecord(row));
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 && includeAccount(row, input.includeUnlinked))
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));