@_mustachio/openauth 0.9.2 → 0.11.0

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 (756) hide show
  1. package/dist/esm/adapters/d1/audit-log.js +15 -0
  2. package/dist/esm/adapters/d1/config-store.js +45 -0
  3. package/dist/esm/adapters/d1/index.js +12 -0
  4. package/dist/esm/adapters/d1/key-store.js +116 -0
  5. package/dist/esm/adapters/d1/method-store.js +52 -0
  6. package/dist/esm/adapters/d1/migrations.js +77 -0
  7. package/dist/esm/adapters/d1/session-store.js +134 -0
  8. package/dist/esm/adapters/d1/session.js +18 -0
  9. package/dist/esm/adapters/d1/token-store.js +140 -0
  10. package/dist/esm/adapters/durable-object/index.js +3 -0
  11. package/dist/esm/adapters/durable-object/session-store.js +139 -0
  12. package/dist/esm/adapters/durable-object/types.js +0 -0
  13. package/dist/esm/adapters/dynamo/audit-log.js +23 -0
  14. package/dist/esm/adapters/dynamo/client.js +0 -0
  15. package/dist/esm/adapters/dynamo/config-store.js +57 -0
  16. package/dist/esm/adapters/dynamo/index.js +10 -0
  17. package/dist/esm/adapters/dynamo/key-store.js +188 -0
  18. package/dist/esm/adapters/dynamo/method-store.js +72 -0
  19. package/dist/esm/adapters/dynamo/passkey-credential-store.js +83 -0
  20. package/dist/esm/adapters/dynamo/sdk.js +128 -0
  21. package/dist/esm/adapters/dynamo/session-store.js +173 -0
  22. package/dist/esm/adapters/dynamo/token-store.js +178 -0
  23. package/dist/esm/adapters/kms/in-memory-backing.js +28 -0
  24. package/dist/esm/adapters/kms/index.js +5 -0
  25. package/dist/esm/adapters/kms/key-store.js +129 -0
  26. package/dist/esm/adapters/kms/sdk.js +23 -0
  27. package/dist/esm/adapters/kms/types.js +0 -0
  28. package/dist/esm/adapters/kv/audit-log.js +21 -0
  29. package/dist/esm/adapters/kv/config-store.js +43 -0
  30. package/dist/esm/adapters/kv/index.js +5 -0
  31. package/dist/esm/adapters/kv/method-store.js +63 -0
  32. package/dist/esm/adapters/kv/types.js +0 -0
  33. package/dist/esm/adapters/memory/audit-log.js +16 -0
  34. package/dist/esm/adapters/memory/clock.js +5 -0
  35. package/dist/esm/adapters/memory/config-store.js +31 -0
  36. package/dist/esm/adapters/memory/index.js +10 -0
  37. package/dist/esm/adapters/memory/key-store.js +78 -0
  38. package/dist/esm/adapters/memory/method-store.js +43 -0
  39. package/dist/esm/adapters/memory/passkey-credential-store.js +53 -0
  40. package/dist/esm/adapters/memory/session-store.js +104 -0
  41. package/dist/esm/adapters/memory/token-store.js +104 -0
  42. package/dist/esm/adapters/postgres/audit-log.js +16 -0
  43. package/dist/esm/adapters/postgres/config-store.js +48 -0
  44. package/dist/esm/adapters/postgres/executor.js +21 -0
  45. package/dist/esm/adapters/postgres/index.js +13 -0
  46. package/dist/esm/adapters/postgres/key-store.js +191 -0
  47. package/dist/esm/adapters/postgres/method-store.js +61 -0
  48. package/dist/esm/adapters/postgres/migrations.js +111 -0
  49. package/dist/esm/adapters/postgres/passkey-credential-store.js +80 -0
  50. package/dist/esm/adapters/postgres/session-store.js +135 -0
  51. package/dist/esm/adapters/postgres/token-store.js +151 -0
  52. package/dist/esm/client.js +35 -12
  53. package/dist/esm/domain/audit.js +13 -0
  54. package/dist/esm/domain/authorize.js +217 -0
  55. package/dist/esm/domain/callback.js +176 -0
  56. package/dist/esm/domain/client-auth.js +61 -0
  57. package/dist/esm/domain/client-credentials.js +91 -0
  58. package/dist/esm/domain/crypto.js +97 -0
  59. package/dist/esm/domain/discovery.js +83 -0
  60. package/dist/esm/domain/dpop.js +122 -0
  61. package/dist/esm/domain/id-token.js +94 -0
  62. package/dist/esm/domain/introspect.js +55 -0
  63. package/dist/esm/domain/jwt.js +71 -0
  64. package/dist/esm/domain/logout.js +75 -0
  65. package/dist/esm/domain/method-cache.js +136 -0
  66. package/dist/esm/domain/method-dispatch.js +36 -0
  67. package/dist/esm/domain/method-route.js +111 -0
  68. package/dist/esm/domain/par.js +51 -0
  69. package/dist/esm/domain/pkce.js +16 -0
  70. package/dist/esm/domain/refresh.js +102 -0
  71. package/dist/esm/domain/register.js +74 -0
  72. package/dist/esm/domain/revoke.js +81 -0
  73. package/dist/esm/domain/state-envelope.js +80 -0
  74. package/dist/esm/domain/token-exchange.js +102 -0
  75. package/dist/esm/domain/token.js +246 -0
  76. package/dist/esm/domain/userinfo.js +62 -0
  77. package/dist/esm/http/context.js +7 -0
  78. package/dist/esm/http/cookies.js +98 -0
  79. package/dist/esm/http/errors.js +71 -0
  80. package/dist/esm/http/handlers/authorize.js +250 -0
  81. package/dist/esm/http/handlers/callback.js +53 -0
  82. package/dist/esm/http/handlers/end-session.js +64 -0
  83. package/dist/esm/http/handlers/metadata.js +37 -0
  84. package/dist/esm/http/handlers/method-route.js +87 -0
  85. package/dist/esm/http/handlers/par.js +53 -0
  86. package/dist/esm/http/handlers/register.js +46 -0
  87. package/dist/esm/http/handlers/revocation.js +98 -0
  88. package/dist/esm/http/handlers/token.js +197 -0
  89. package/dist/esm/http/handlers/userinfo.js +60 -0
  90. package/dist/esm/http/middleware/error.js +15 -0
  91. package/dist/esm/http/middleware/tenant.js +102 -0
  92. package/dist/esm/http/resolver.js +15 -0
  93. package/dist/esm/http/router.js +45 -0
  94. package/dist/esm/http/schemas/authorize.js +30 -0
  95. package/dist/esm/http/schemas/end-session.js +13 -0
  96. package/dist/esm/http/schemas/par.js +9 -0
  97. package/dist/esm/http/schemas/register.js +16 -0
  98. package/dist/esm/http/schemas/revocation.js +18 -0
  99. package/dist/esm/http/schemas/token.js +57 -0
  100. package/dist/esm/index.js +126 -9
  101. package/dist/esm/methods/code.js +221 -0
  102. package/dist/esm/methods/m2m.js +41 -0
  103. package/dist/esm/methods/oauth2-factory.js +84 -0
  104. package/dist/esm/methods/oauth2-generic.js +196 -0
  105. package/dist/esm/methods/oidc-generic.js +53 -0
  106. package/dist/esm/methods/passkey.js +275 -0
  107. package/dist/esm/methods/password-hash.js +79 -0
  108. package/dist/esm/methods/password.js +166 -0
  109. package/dist/esm/methods/providers/apple.js +29 -0
  110. package/dist/esm/methods/providers/cognito.js +37 -0
  111. package/dist/esm/methods/providers/discord.js +28 -0
  112. package/dist/esm/methods/providers/facebook.js +42 -0
  113. package/dist/esm/methods/providers/github.js +29 -0
  114. package/dist/esm/methods/providers/google.js +29 -0
  115. package/dist/esm/methods/providers/index.js +17 -0
  116. package/dist/esm/methods/providers/jumpcloud.js +27 -0
  117. package/dist/esm/methods/providers/keycloak.js +32 -0
  118. package/dist/esm/methods/providers/linkedin.js +28 -0
  119. package/dist/esm/methods/providers/microsoft.js +28 -0
  120. package/dist/esm/methods/providers/slack.js +30 -0
  121. package/dist/esm/methods/providers/spotify.js +28 -0
  122. package/dist/esm/methods/providers/twitch.js +28 -0
  123. package/dist/esm/methods/providers/x.js +28 -0
  124. package/dist/esm/methods/providers/yahoo.js +27 -0
  125. package/dist/esm/pkce.js +4 -16
  126. package/dist/esm/ports/audit-log.js +0 -0
  127. package/dist/esm/ports/config-store.js +0 -0
  128. package/dist/esm/ports/key-store.js +0 -0
  129. package/dist/esm/ports/method-store.js +0 -0
  130. package/dist/esm/ports/session-store.js +0 -0
  131. package/dist/esm/ports/token-store.js +0 -0
  132. package/dist/esm/types/authorization.js +0 -0
  133. package/dist/esm/types/error.js +70 -0
  134. package/dist/esm/types/flow.js +0 -0
  135. package/dist/esm/types/idp.js +0 -0
  136. package/dist/esm/types/method.js +0 -0
  137. package/dist/esm/types/picker.js +0 -0
  138. package/dist/esm/types/result.js +11 -0
  139. package/dist/esm/types/subject.js +0 -0
  140. package/dist/esm/types/tenant.js +5 -0
  141. package/dist/esm/types/token.js +0 -0
  142. package/dist/esm/ui/forms.js +253 -0
  143. package/dist/esm/ui/index.js +8 -0
  144. package/dist/esm/ui/picker.js +49 -0
  145. package/dist/types/adapters/d1/audit-log.d.ts +19 -0
  146. package/dist/types/adapters/d1/audit-log.d.ts.map +1 -0
  147. package/dist/types/adapters/d1/config-store.d.ts +20 -0
  148. package/dist/types/adapters/d1/config-store.d.ts.map +1 -0
  149. package/dist/types/adapters/d1/index.d.ts +35 -0
  150. package/dist/types/adapters/d1/index.d.ts.map +1 -0
  151. package/dist/types/adapters/d1/key-store.d.ts +17 -0
  152. package/dist/types/adapters/d1/key-store.d.ts.map +1 -0
  153. package/dist/types/adapters/d1/method-store.d.ts +21 -0
  154. package/dist/types/adapters/d1/method-store.d.ts.map +1 -0
  155. package/dist/types/adapters/d1/migrations.d.ts +18 -0
  156. package/dist/types/adapters/d1/migrations.d.ts.map +1 -0
  157. package/dist/types/adapters/d1/session-store.d.ts +20 -0
  158. package/dist/types/adapters/d1/session-store.d.ts.map +1 -0
  159. package/dist/types/adapters/d1/session.d.ts +18 -0
  160. package/dist/types/adapters/d1/session.d.ts.map +1 -0
  161. package/dist/types/adapters/d1/token-store.d.ts +29 -0
  162. package/dist/types/adapters/d1/token-store.d.ts.map +1 -0
  163. package/dist/types/adapters/d1/types.d.ts +43 -0
  164. package/dist/types/adapters/d1/types.d.ts.map +1 -0
  165. package/dist/types/adapters/durable-object/index.d.ts +17 -0
  166. package/dist/types/adapters/durable-object/index.d.ts.map +1 -0
  167. package/dist/types/adapters/durable-object/session-store.d.ts +21 -0
  168. package/dist/types/adapters/durable-object/session-store.d.ts.map +1 -0
  169. package/dist/types/adapters/durable-object/types.d.ts +23 -0
  170. package/dist/types/adapters/durable-object/types.d.ts.map +1 -0
  171. package/dist/types/adapters/dynamo/audit-log.d.ts +19 -0
  172. package/dist/types/adapters/dynamo/audit-log.d.ts.map +1 -0
  173. package/dist/types/adapters/dynamo/client.d.ts +111 -0
  174. package/dist/types/adapters/dynamo/client.d.ts.map +1 -0
  175. package/dist/types/adapters/dynamo/config-store.d.ts +21 -0
  176. package/dist/types/adapters/dynamo/config-store.d.ts.map +1 -0
  177. package/dist/types/adapters/dynamo/index.d.ts +60 -0
  178. package/dist/types/adapters/dynamo/index.d.ts.map +1 -0
  179. package/dist/types/adapters/dynamo/key-store.d.ts +23 -0
  180. package/dist/types/adapters/dynamo/key-store.d.ts.map +1 -0
  181. package/dist/types/adapters/dynamo/method-store.d.ts +20 -0
  182. package/dist/types/adapters/dynamo/method-store.d.ts.map +1 -0
  183. package/dist/types/adapters/dynamo/passkey-credential-store.d.ts +47 -0
  184. package/dist/types/adapters/dynamo/passkey-credential-store.d.ts.map +1 -0
  185. package/dist/types/adapters/dynamo/sdk.d.ts +23 -0
  186. package/dist/types/adapters/dynamo/sdk.d.ts.map +1 -0
  187. package/dist/types/adapters/dynamo/session-store.d.ts +20 -0
  188. package/dist/types/adapters/dynamo/session-store.d.ts.map +1 -0
  189. package/dist/types/adapters/dynamo/token-store.d.ts +29 -0
  190. package/dist/types/adapters/dynamo/token-store.d.ts.map +1 -0
  191. package/dist/types/adapters/kms/in-memory-backing.d.ts +9 -0
  192. package/dist/types/adapters/kms/in-memory-backing.d.ts.map +1 -0
  193. package/dist/types/adapters/kms/index.d.ts +35 -0
  194. package/dist/types/adapters/kms/index.d.ts.map +1 -0
  195. package/dist/types/adapters/kms/key-store.d.ts +20 -0
  196. package/dist/types/adapters/kms/key-store.d.ts.map +1 -0
  197. package/dist/types/adapters/kms/sdk.d.ts +16 -0
  198. package/dist/types/adapters/kms/sdk.d.ts.map +1 -0
  199. package/dist/types/adapters/kms/types.d.ts +58 -0
  200. package/dist/types/adapters/kms/types.d.ts.map +1 -0
  201. package/dist/types/adapters/kv/audit-log.d.ts +22 -0
  202. package/dist/types/adapters/kv/audit-log.d.ts.map +1 -0
  203. package/dist/types/adapters/kv/config-store.d.ts +25 -0
  204. package/dist/types/adapters/kv/config-store.d.ts.map +1 -0
  205. package/dist/types/adapters/kv/index.d.ts +21 -0
  206. package/dist/types/adapters/kv/index.d.ts.map +1 -0
  207. package/dist/types/adapters/kv/method-store.d.ts +23 -0
  208. package/dist/types/adapters/kv/method-store.d.ts.map +1 -0
  209. package/dist/types/adapters/kv/types.d.ts +28 -0
  210. package/dist/types/adapters/kv/types.d.ts.map +1 -0
  211. package/dist/types/adapters/memory/audit-log.d.ts +18 -0
  212. package/dist/types/adapters/memory/audit-log.d.ts.map +1 -0
  213. package/dist/types/adapters/memory/clock.d.ts +7 -0
  214. package/dist/types/adapters/memory/clock.d.ts.map +1 -0
  215. package/dist/types/adapters/memory/config-store.d.ts +19 -0
  216. package/dist/types/adapters/memory/config-store.d.ts.map +1 -0
  217. package/dist/types/adapters/memory/index.d.ts +15 -0
  218. package/dist/types/adapters/memory/index.d.ts.map +1 -0
  219. package/dist/types/adapters/memory/key-store.d.ts +17 -0
  220. package/dist/types/adapters/memory/key-store.d.ts.map +1 -0
  221. package/dist/types/adapters/memory/method-store.d.ts +26 -0
  222. package/dist/types/adapters/memory/method-store.d.ts.map +1 -0
  223. package/dist/types/adapters/memory/passkey-credential-store.d.ts +43 -0
  224. package/dist/types/adapters/memory/passkey-credential-store.d.ts.map +1 -0
  225. package/dist/types/adapters/memory/session-store.d.ts +21 -0
  226. package/dist/types/adapters/memory/session-store.d.ts.map +1 -0
  227. package/dist/types/adapters/memory/token-store.d.ts +29 -0
  228. package/dist/types/adapters/memory/token-store.d.ts.map +1 -0
  229. package/dist/types/adapters/postgres/audit-log.d.ts +18 -0
  230. package/dist/types/adapters/postgres/audit-log.d.ts.map +1 -0
  231. package/dist/types/adapters/postgres/config-store.d.ts +21 -0
  232. package/dist/types/adapters/postgres/config-store.d.ts.map +1 -0
  233. package/dist/types/adapters/postgres/executor.d.ts +48 -0
  234. package/dist/types/adapters/postgres/executor.d.ts.map +1 -0
  235. package/dist/types/adapters/postgres/index.d.ts +39 -0
  236. package/dist/types/adapters/postgres/index.d.ts.map +1 -0
  237. package/dist/types/adapters/postgres/key-store.d.ts +23 -0
  238. package/dist/types/adapters/postgres/key-store.d.ts.map +1 -0
  239. package/dist/types/adapters/postgres/method-store.d.ts +21 -0
  240. package/dist/types/adapters/postgres/method-store.d.ts.map +1 -0
  241. package/dist/types/adapters/postgres/migrations.d.ts +22 -0
  242. package/dist/types/adapters/postgres/migrations.d.ts.map +1 -0
  243. package/dist/types/adapters/postgres/passkey-credential-store.d.ts +48 -0
  244. package/dist/types/adapters/postgres/passkey-credential-store.d.ts.map +1 -0
  245. package/dist/types/adapters/postgres/session-store.d.ts +20 -0
  246. package/dist/types/adapters/postgres/session-store.d.ts.map +1 -0
  247. package/dist/types/adapters/postgres/token-store.d.ts +30 -0
  248. package/dist/types/adapters/postgres/token-store.d.ts.map +1 -0
  249. package/dist/types/client.d.ts +20 -1
  250. package/dist/types/client.d.ts.map +1 -1
  251. package/dist/types/domain/audit.d.ts +17 -0
  252. package/dist/types/domain/audit.d.ts.map +1 -0
  253. package/dist/types/domain/authorize.d.ts +125 -0
  254. package/dist/types/domain/authorize.d.ts.map +1 -0
  255. package/dist/types/domain/callback.d.ts +70 -0
  256. package/dist/types/domain/callback.d.ts.map +1 -0
  257. package/dist/types/domain/client-auth.d.ts +57 -0
  258. package/dist/types/domain/client-auth.d.ts.map +1 -0
  259. package/dist/types/domain/client-credentials.d.ts +54 -0
  260. package/dist/types/domain/client-credentials.d.ts.map +1 -0
  261. package/dist/types/domain/crypto.d.ts +53 -0
  262. package/dist/types/domain/crypto.d.ts.map +1 -0
  263. package/dist/types/domain/discovery.d.ts +81 -0
  264. package/dist/types/domain/discovery.d.ts.map +1 -0
  265. package/dist/types/domain/dpop.d.ts +61 -0
  266. package/dist/types/domain/dpop.d.ts.map +1 -0
  267. package/dist/types/domain/id-token.d.ts +83 -0
  268. package/dist/types/domain/id-token.d.ts.map +1 -0
  269. package/dist/types/domain/introspect.d.ts +79 -0
  270. package/dist/types/domain/introspect.d.ts.map +1 -0
  271. package/dist/types/domain/jwt.d.ts +74 -0
  272. package/dist/types/domain/jwt.d.ts.map +1 -0
  273. package/dist/types/domain/logout.d.ts +69 -0
  274. package/dist/types/domain/logout.d.ts.map +1 -0
  275. package/dist/types/domain/method-cache.d.ts +42 -0
  276. package/dist/types/domain/method-cache.d.ts.map +1 -0
  277. package/dist/types/domain/method-dispatch.d.ts +37 -0
  278. package/dist/types/domain/method-dispatch.d.ts.map +1 -0
  279. package/dist/types/domain/method-route.d.ts +77 -0
  280. package/dist/types/domain/method-route.d.ts.map +1 -0
  281. package/dist/types/domain/par.d.ts +62 -0
  282. package/dist/types/domain/par.d.ts.map +1 -0
  283. package/dist/types/domain/pkce.d.ts +15 -0
  284. package/dist/types/domain/pkce.d.ts.map +1 -0
  285. package/dist/types/domain/refresh.d.ts +52 -0
  286. package/dist/types/domain/refresh.d.ts.map +1 -0
  287. package/dist/types/domain/register.d.ts +33 -0
  288. package/dist/types/domain/register.d.ts.map +1 -0
  289. package/dist/types/domain/revoke.d.ts +61 -0
  290. package/dist/types/domain/revoke.d.ts.map +1 -0
  291. package/dist/types/domain/state-envelope.d.ts +30 -0
  292. package/dist/types/domain/state-envelope.d.ts.map +1 -0
  293. package/dist/types/domain/token-exchange.d.ts +69 -0
  294. package/dist/types/domain/token-exchange.d.ts.map +1 -0
  295. package/dist/types/domain/token.d.ts +140 -0
  296. package/dist/types/domain/token.d.ts.map +1 -0
  297. package/dist/types/domain/userinfo.d.ts +61 -0
  298. package/dist/types/domain/userinfo.d.ts.map +1 -0
  299. package/dist/types/http/context.d.ts +66 -0
  300. package/dist/types/http/context.d.ts.map +1 -0
  301. package/dist/types/http/cookies.d.ts +45 -0
  302. package/dist/types/http/cookies.d.ts.map +1 -0
  303. package/dist/types/http/errors.d.ts +36 -0
  304. package/dist/types/http/errors.d.ts.map +1 -0
  305. package/dist/types/http/handlers/authorize.d.ts +3 -0
  306. package/dist/types/http/handlers/authorize.d.ts.map +1 -0
  307. package/dist/types/http/handlers/callback.d.ts +3 -0
  308. package/dist/types/http/handlers/callback.d.ts.map +1 -0
  309. package/dist/types/http/handlers/end-session.d.ts +3 -0
  310. package/dist/types/http/handlers/end-session.d.ts.map +1 -0
  311. package/dist/types/http/handlers/metadata.d.ts +4 -0
  312. package/dist/types/http/handlers/metadata.d.ts.map +1 -0
  313. package/dist/types/http/handlers/method-route.d.ts +3 -0
  314. package/dist/types/http/handlers/method-route.d.ts.map +1 -0
  315. package/dist/types/http/handlers/par.d.ts +3 -0
  316. package/dist/types/http/handlers/par.d.ts.map +1 -0
  317. package/dist/types/http/handlers/register.d.ts +3 -0
  318. package/dist/types/http/handlers/register.d.ts.map +1 -0
  319. package/dist/types/http/handlers/revocation.d.ts +4 -0
  320. package/dist/types/http/handlers/revocation.d.ts.map +1 -0
  321. package/dist/types/http/handlers/token.d.ts +3 -0
  322. package/dist/types/http/handlers/token.d.ts.map +1 -0
  323. package/dist/types/http/handlers/userinfo.d.ts +3 -0
  324. package/dist/types/http/handlers/userinfo.d.ts.map +1 -0
  325. package/dist/types/http/middleware/error.d.ts +9 -0
  326. package/dist/types/http/middleware/error.d.ts.map +1 -0
  327. package/dist/types/http/middleware/tenant.d.ts +30 -0
  328. package/dist/types/http/middleware/tenant.d.ts.map +1 -0
  329. package/dist/types/http/resolver.d.ts +22 -0
  330. package/dist/types/http/resolver.d.ts.map +1 -0
  331. package/dist/types/http/router.d.ts +21 -0
  332. package/dist/types/http/router.d.ts.map +1 -0
  333. package/dist/types/http/schemas/authorize.d.ts +92 -0
  334. package/dist/types/http/schemas/authorize.d.ts.map +1 -0
  335. package/dist/types/http/schemas/end-session.d.ts +31 -0
  336. package/dist/types/http/schemas/end-session.d.ts.map +1 -0
  337. package/dist/types/http/schemas/par.d.ts +20 -0
  338. package/dist/types/http/schemas/par.d.ts.map +1 -0
  339. package/dist/types/http/schemas/register.d.ts +42 -0
  340. package/dist/types/http/schemas/register.d.ts.map +1 -0
  341. package/dist/types/http/schemas/revocation.d.ts +41 -0
  342. package/dist/types/http/schemas/revocation.d.ts.map +1 -0
  343. package/dist/types/http/schemas/token.d.ts +227 -0
  344. package/dist/types/http/schemas/token.d.ts.map +1 -0
  345. package/dist/types/index.d.ts +63 -13
  346. package/dist/types/index.d.ts.map +1 -1
  347. package/dist/types/methods/code.d.ts +96 -0
  348. package/dist/types/methods/code.d.ts.map +1 -0
  349. package/dist/types/methods/m2m.d.ts +41 -0
  350. package/dist/types/methods/m2m.d.ts.map +1 -0
  351. package/dist/types/methods/oauth2-factory.d.ts +133 -0
  352. package/dist/types/methods/oauth2-factory.d.ts.map +1 -0
  353. package/dist/types/methods/oauth2-generic.d.ts +75 -0
  354. package/dist/types/methods/oauth2-generic.d.ts.map +1 -0
  355. package/dist/types/methods/oidc-generic.d.ts +26 -0
  356. package/dist/types/methods/oidc-generic.d.ts.map +1 -0
  357. package/dist/types/methods/passkey.d.ts +106 -0
  358. package/dist/types/methods/passkey.d.ts.map +1 -0
  359. package/dist/types/methods/password-hash.d.ts +25 -0
  360. package/dist/types/methods/password-hash.d.ts.map +1 -0
  361. package/dist/types/methods/password.d.ts +70 -0
  362. package/dist/types/methods/password.d.ts.map +1 -0
  363. package/dist/types/methods/providers/apple.d.ts +29 -0
  364. package/dist/types/methods/providers/apple.d.ts.map +1 -0
  365. package/dist/types/methods/providers/cognito.d.ts +36 -0
  366. package/dist/types/methods/providers/cognito.d.ts.map +1 -0
  367. package/dist/types/methods/providers/discord.d.ts +22 -0
  368. package/dist/types/methods/providers/discord.d.ts.map +1 -0
  369. package/dist/types/methods/providers/facebook.d.ts +29 -0
  370. package/dist/types/methods/providers/facebook.d.ts.map +1 -0
  371. package/dist/types/methods/providers/github.d.ts +25 -0
  372. package/dist/types/methods/providers/github.d.ts.map +1 -0
  373. package/dist/types/methods/providers/google.d.ts +28 -0
  374. package/dist/types/methods/providers/google.d.ts.map +1 -0
  375. package/dist/types/methods/providers/index.d.ts +24 -0
  376. package/dist/types/methods/providers/index.d.ts.map +1 -0
  377. package/dist/types/methods/providers/jumpcloud.d.ts +22 -0
  378. package/dist/types/methods/providers/jumpcloud.d.ts.map +1 -0
  379. package/dist/types/methods/providers/keycloak.d.ts +30 -0
  380. package/dist/types/methods/providers/keycloak.d.ts.map +1 -0
  381. package/dist/types/methods/providers/linkedin.d.ts +22 -0
  382. package/dist/types/methods/providers/linkedin.d.ts.map +1 -0
  383. package/dist/types/methods/providers/microsoft.d.ts +30 -0
  384. package/dist/types/methods/providers/microsoft.d.ts.map +1 -0
  385. package/dist/types/methods/providers/slack.d.ts +25 -0
  386. package/dist/types/methods/providers/slack.d.ts.map +1 -0
  387. package/dist/types/methods/providers/spotify.d.ts +22 -0
  388. package/dist/types/methods/providers/spotify.d.ts.map +1 -0
  389. package/dist/types/methods/providers/twitch.d.ts +23 -0
  390. package/dist/types/methods/providers/twitch.d.ts.map +1 -0
  391. package/dist/types/methods/providers/x.d.ts +25 -0
  392. package/dist/types/methods/providers/x.d.ts.map +1 -0
  393. package/dist/types/methods/providers/yahoo.d.ts +22 -0
  394. package/dist/types/methods/providers/yahoo.d.ts.map +1 -0
  395. package/dist/types/pkce.d.ts +1 -2
  396. package/dist/types/pkce.d.ts.map +1 -1
  397. package/dist/types/ports/audit-log.d.ts +166 -0
  398. package/dist/types/ports/audit-log.d.ts.map +1 -0
  399. package/dist/types/ports/config-store.d.ts +32 -0
  400. package/dist/types/ports/config-store.d.ts.map +1 -0
  401. package/dist/types/ports/key-store.d.ts +98 -0
  402. package/dist/types/ports/key-store.d.ts.map +1 -0
  403. package/dist/types/ports/method-store.d.ts +29 -0
  404. package/dist/types/ports/method-store.d.ts.map +1 -0
  405. package/dist/types/ports/session-store.d.ts +109 -0
  406. package/dist/types/ports/session-store.d.ts.map +1 -0
  407. package/dist/types/ports/token-store.d.ts +105 -0
  408. package/dist/types/ports/token-store.d.ts.map +1 -0
  409. package/dist/types/types/authorization.d.ts +75 -0
  410. package/dist/types/types/authorization.d.ts.map +1 -0
  411. package/dist/types/types/error.d.ts +101 -0
  412. package/dist/types/types/error.d.ts.map +1 -0
  413. package/dist/types/types/flow.d.ts +97 -0
  414. package/dist/types/types/flow.d.ts.map +1 -0
  415. package/dist/types/types/idp.d.ts +324 -0
  416. package/dist/types/types/idp.d.ts.map +1 -0
  417. package/dist/types/types/method.d.ts +256 -0
  418. package/dist/types/types/method.d.ts.map +1 -0
  419. package/dist/types/types/picker.d.ts +31 -0
  420. package/dist/types/types/picker.d.ts.map +1 -0
  421. package/dist/types/types/result.d.ts +29 -0
  422. package/dist/types/types/result.d.ts.map +1 -0
  423. package/dist/types/types/subject.d.ts +47 -0
  424. package/dist/types/types/subject.d.ts.map +1 -0
  425. package/dist/types/types/tenant.d.ts +276 -0
  426. package/dist/types/types/tenant.d.ts.map +1 -0
  427. package/dist/types/types/token.d.ts +231 -0
  428. package/dist/types/types/token.d.ts.map +1 -0
  429. package/dist/types/ui/forms.d.ts +35 -0
  430. package/dist/types/ui/forms.d.ts.map +1 -0
  431. package/dist/types/ui/index.d.ts +14 -0
  432. package/dist/types/ui/index.d.ts.map +1 -0
  433. package/dist/types/ui/picker.d.ts +18 -0
  434. package/dist/types/ui/picker.d.ts.map +1 -0
  435. package/package.json +41 -6
  436. package/src/adapters/d1/audit-log.ts +32 -0
  437. package/src/adapters/d1/config-store.ts +67 -0
  438. package/src/adapters/d1/index.ts +41 -0
  439. package/src/adapters/d1/key-store.ts +218 -0
  440. package/src/adapters/d1/method-store.ts +103 -0
  441. package/src/adapters/d1/migrations.ts +89 -0
  442. package/src/adapters/d1/session-store.ts +230 -0
  443. package/src/adapters/d1/session.ts +38 -0
  444. package/src/adapters/d1/token-store.ts +251 -0
  445. package/src/adapters/d1/types.ts +53 -0
  446. package/src/adapters/durable-object/index.ts +23 -0
  447. package/src/adapters/durable-object/session-store.ts +227 -0
  448. package/src/adapters/durable-object/types.ts +25 -0
  449. package/src/adapters/dynamo/audit-log.ts +35 -0
  450. package/src/adapters/dynamo/client.ts +118 -0
  451. package/src/adapters/dynamo/config-store.ts +72 -0
  452. package/src/adapters/dynamo/index.ts +81 -0
  453. package/src/adapters/dynamo/key-store.ts +267 -0
  454. package/src/adapters/dynamo/method-store.ts +105 -0
  455. package/src/adapters/dynamo/passkey-credential-store.ts +132 -0
  456. package/src/adapters/dynamo/sdk.ts +189 -0
  457. package/src/adapters/dynamo/session-store.ts +229 -0
  458. package/src/adapters/dynamo/token-store.ts +248 -0
  459. package/src/adapters/kms/in-memory-backing.ts +36 -0
  460. package/src/adapters/kms/index.ts +39 -0
  461. package/src/adapters/kms/key-store.ts +176 -0
  462. package/src/adapters/kms/sdk.ts +39 -0
  463. package/src/adapters/kms/types.ts +61 -0
  464. package/src/adapters/kv/audit-log.ts +40 -0
  465. package/src/adapters/kv/config-store.ts +63 -0
  466. package/src/adapters/kv/index.ts +20 -0
  467. package/src/adapters/kv/method-store.ts +98 -0
  468. package/src/adapters/kv/types.ts +26 -0
  469. package/src/adapters/memory/audit-log.ts +28 -0
  470. package/src/adapters/memory/clock.ts +7 -0
  471. package/src/adapters/memory/config-store.ts +41 -0
  472. package/src/adapters/memory/index.ts +26 -0
  473. package/src/adapters/memory/key-store.ts +102 -0
  474. package/src/adapters/memory/method-store.ts +75 -0
  475. package/src/adapters/memory/passkey-credential-store.ts +97 -0
  476. package/src/adapters/memory/session-store.ts +171 -0
  477. package/src/adapters/memory/token-store.ts +181 -0
  478. package/src/adapters/postgres/audit-log.ts +34 -0
  479. package/src/adapters/postgres/config-store.ts +72 -0
  480. package/src/adapters/postgres/executor.ts +76 -0
  481. package/src/adapters/postgres/index.ts +60 -0
  482. package/src/adapters/postgres/key-store.ts +334 -0
  483. package/src/adapters/postgres/method-store.ts +104 -0
  484. package/src/adapters/postgres/migrations.ts +131 -0
  485. package/src/adapters/postgres/passkey-credential-store.ts +150 -0
  486. package/src/adapters/postgres/session-store.ts +216 -0
  487. package/src/adapters/postgres/token-store.ts +263 -0
  488. package/src/client.ts +82 -16
  489. package/src/domain/audit.ts +28 -0
  490. package/src/domain/authorize.ts +414 -0
  491. package/src/domain/callback.ts +268 -0
  492. package/src/domain/client-auth.ts +116 -0
  493. package/src/domain/client-credentials.ts +180 -0
  494. package/src/domain/crypto.ts +168 -0
  495. package/src/domain/discovery.ts +161 -0
  496. package/src/domain/dpop.ts +293 -0
  497. package/src/domain/id-token.ts +213 -0
  498. package/src/domain/introspect.ts +155 -0
  499. package/src/domain/jwt.ts +185 -0
  500. package/src/domain/logout.ts +180 -0
  501. package/src/domain/method-cache.ts +220 -0
  502. package/src/domain/method-dispatch.ts +95 -0
  503. package/src/domain/method-route.ts +213 -0
  504. package/src/domain/par.ts +141 -0
  505. package/src/domain/pkce.ts +37 -0
  506. package/src/domain/refresh.ts +210 -0
  507. package/src/domain/register.ts +168 -0
  508. package/src/domain/revoke.ts +161 -0
  509. package/src/domain/state-envelope.ts +142 -0
  510. package/src/domain/token-exchange.ts +243 -0
  511. package/src/domain/token.ts +483 -0
  512. package/src/domain/userinfo.ts +171 -0
  513. package/src/http/context.ts +90 -0
  514. package/src/http/cookies.ts +167 -0
  515. package/src/http/errors.ts +98 -0
  516. package/src/http/handlers/authorize.ts +362 -0
  517. package/src/http/handlers/callback.ts +77 -0
  518. package/src/http/handlers/end-session.ts +106 -0
  519. package/src/http/handlers/metadata.ts +49 -0
  520. package/src/http/handlers/method-route.ts +115 -0
  521. package/src/http/handlers/par.ts +84 -0
  522. package/src/http/handlers/register.ts +70 -0
  523. package/src/http/handlers/revocation.ts +151 -0
  524. package/src/http/handlers/token.ts +300 -0
  525. package/src/http/handlers/userinfo.ts +90 -0
  526. package/src/http/middleware/error.ts +26 -0
  527. package/src/http/middleware/tenant.ts +165 -0
  528. package/src/http/resolver.ts +34 -0
  529. package/src/http/router.ts +85 -0
  530. package/src/http/schemas/authorize.ts +85 -0
  531. package/src/http/schemas/end-session.ts +23 -0
  532. package/src/http/schemas/par.ts +23 -0
  533. package/src/http/schemas/register.ts +29 -0
  534. package/src/http/schemas/revocation.ts +23 -0
  535. package/src/http/schemas/token.ts +85 -0
  536. package/src/index.ts +283 -20
  537. package/src/methods/code.ts +359 -0
  538. package/src/methods/m2m.ts +82 -0
  539. package/src/methods/oauth2-factory.ts +151 -0
  540. package/src/methods/oauth2-generic.ts +360 -0
  541. package/src/methods/oidc-generic.ts +109 -0
  542. package/src/methods/passkey.ts +419 -0
  543. package/src/methods/password-hash.ts +134 -0
  544. package/src/methods/password.ts +298 -0
  545. package/src/methods/providers/apple.ts +42 -0
  546. package/src/methods/providers/cognito.ts +55 -0
  547. package/src/methods/providers/discord.ts +37 -0
  548. package/src/methods/providers/facebook.ts +54 -0
  549. package/src/methods/providers/github.ts +42 -0
  550. package/src/methods/providers/google.ts +43 -0
  551. package/src/methods/providers/index.ts +23 -0
  552. package/src/methods/providers/jumpcloud.ts +36 -0
  553. package/src/methods/providers/keycloak.ts +42 -0
  554. package/src/methods/providers/linkedin.ts +37 -0
  555. package/src/methods/providers/microsoft.ts +42 -0
  556. package/src/methods/providers/slack.ts +42 -0
  557. package/src/methods/providers/spotify.ts +37 -0
  558. package/src/methods/providers/twitch.ts +38 -0
  559. package/src/methods/providers/x.ts +40 -0
  560. package/src/methods/providers/yahoo.ts +36 -0
  561. package/src/pkce.ts +20 -21
  562. package/src/ports/CONSISTENCY.md +119 -0
  563. package/src/ports/audit-log.ts +177 -0
  564. package/src/ports/config-store.ts +34 -0
  565. package/src/ports/key-store.ts +106 -0
  566. package/src/ports/method-store.ts +41 -0
  567. package/src/ports/session-store.ts +131 -0
  568. package/src/ports/token-store.ts +116 -0
  569. package/src/types/authorization.ts +78 -0
  570. package/src/types/error.ts +146 -0
  571. package/src/types/flow.ts +99 -0
  572. package/src/types/idp.ts +365 -0
  573. package/src/types/method.ts +270 -0
  574. package/src/types/picker.ts +32 -0
  575. package/src/types/result.ts +23 -0
  576. package/src/types/subject.ts +50 -0
  577. package/src/types/tenant.ts +285 -0
  578. package/src/types/token.ts +236 -0
  579. package/src/ui/forms.ts +289 -0
  580. package/src/ui/index.ts +14 -0
  581. package/src/ui/picker.ts +63 -0
  582. package/dist/esm/issuer.js +0 -691
  583. package/dist/esm/jwt.js +0 -16
  584. package/dist/esm/keys.js +0 -113
  585. package/dist/esm/provider/apple.js +0 -28
  586. package/dist/esm/provider/arctic.js +0 -43
  587. package/dist/esm/provider/code.js +0 -58
  588. package/dist/esm/provider/cognito.js +0 -16
  589. package/dist/esm/provider/discord.js +0 -15
  590. package/dist/esm/provider/facebook.js +0 -24
  591. package/dist/esm/provider/github.js +0 -15
  592. package/dist/esm/provider/google.js +0 -25
  593. package/dist/esm/provider/index.js +0 -3
  594. package/dist/esm/provider/jumpcloud.js +0 -15
  595. package/dist/esm/provider/keycloak.js +0 -15
  596. package/dist/esm/provider/linkedin.js +0 -15
  597. package/dist/esm/provider/m2m.js +0 -16
  598. package/dist/esm/provider/microsoft.js +0 -24
  599. package/dist/esm/provider/oauth2.js +0 -119
  600. package/dist/esm/provider/oidc.js +0 -69
  601. package/dist/esm/provider/passkey.js +0 -315
  602. package/dist/esm/provider/password.js +0 -306
  603. package/dist/esm/provider/provider.js +0 -10
  604. package/dist/esm/provider/slack.js +0 -15
  605. package/dist/esm/provider/spotify.js +0 -15
  606. package/dist/esm/provider/twitch.js +0 -15
  607. package/dist/esm/provider/x.js +0 -16
  608. package/dist/esm/provider/yahoo.js +0 -15
  609. package/dist/esm/random.js +0 -27
  610. package/dist/esm/storage/aws.js +0 -39
  611. package/dist/esm/storage/cloudflare.js +0 -42
  612. package/dist/esm/storage/dynamo.js +0 -116
  613. package/dist/esm/storage/memory.js +0 -88
  614. package/dist/esm/storage/storage.js +0 -36
  615. package/dist/esm/subject.js +0 -7
  616. package/dist/esm/ui/base.js +0 -407
  617. package/dist/esm/ui/code.js +0 -151
  618. package/dist/esm/ui/form.js +0 -43
  619. package/dist/esm/ui/icon.js +0 -92
  620. package/dist/esm/ui/passkey.js +0 -329
  621. package/dist/esm/ui/password.js +0 -338
  622. package/dist/esm/ui/select.js +0 -187
  623. package/dist/esm/ui/theme.js +0 -115
  624. package/dist/esm/util.js +0 -54
  625. package/dist/types/issuer.d.ts +0 -607
  626. package/dist/types/issuer.d.ts.map +0 -1
  627. package/dist/types/jwt.d.ts +0 -6
  628. package/dist/types/jwt.d.ts.map +0 -1
  629. package/dist/types/keys.d.ts +0 -18
  630. package/dist/types/keys.d.ts.map +0 -1
  631. package/dist/types/provider/apple.d.ts +0 -108
  632. package/dist/types/provider/apple.d.ts.map +0 -1
  633. package/dist/types/provider/arctic.d.ts +0 -16
  634. package/dist/types/provider/arctic.d.ts.map +0 -1
  635. package/dist/types/provider/code.d.ts +0 -74
  636. package/dist/types/provider/code.d.ts.map +0 -1
  637. package/dist/types/provider/cognito.d.ts +0 -64
  638. package/dist/types/provider/cognito.d.ts.map +0 -1
  639. package/dist/types/provider/discord.d.ts +0 -38
  640. package/dist/types/provider/discord.d.ts.map +0 -1
  641. package/dist/types/provider/facebook.d.ts +0 -74
  642. package/dist/types/provider/facebook.d.ts.map +0 -1
  643. package/dist/types/provider/github.d.ts +0 -38
  644. package/dist/types/provider/github.d.ts.map +0 -1
  645. package/dist/types/provider/google.d.ts +0 -74
  646. package/dist/types/provider/google.d.ts.map +0 -1
  647. package/dist/types/provider/index.d.ts +0 -4
  648. package/dist/types/provider/index.d.ts.map +0 -1
  649. package/dist/types/provider/jumpcloud.d.ts +0 -38
  650. package/dist/types/provider/jumpcloud.d.ts.map +0 -1
  651. package/dist/types/provider/keycloak.d.ts +0 -67
  652. package/dist/types/provider/keycloak.d.ts.map +0 -1
  653. package/dist/types/provider/linkedin.d.ts +0 -6
  654. package/dist/types/provider/linkedin.d.ts.map +0 -1
  655. package/dist/types/provider/m2m.d.ts +0 -34
  656. package/dist/types/provider/m2m.d.ts.map +0 -1
  657. package/dist/types/provider/microsoft.d.ts +0 -89
  658. package/dist/types/provider/microsoft.d.ts.map +0 -1
  659. package/dist/types/provider/oauth2.d.ts +0 -133
  660. package/dist/types/provider/oauth2.d.ts.map +0 -1
  661. package/dist/types/provider/oidc.d.ts +0 -91
  662. package/dist/types/provider/oidc.d.ts.map +0 -1
  663. package/dist/types/provider/passkey.d.ts +0 -143
  664. package/dist/types/provider/passkey.d.ts.map +0 -1
  665. package/dist/types/provider/password.d.ts +0 -210
  666. package/dist/types/provider/password.d.ts.map +0 -1
  667. package/dist/types/provider/provider.d.ts +0 -29
  668. package/dist/types/provider/provider.d.ts.map +0 -1
  669. package/dist/types/provider/slack.d.ts +0 -59
  670. package/dist/types/provider/slack.d.ts.map +0 -1
  671. package/dist/types/provider/spotify.d.ts +0 -38
  672. package/dist/types/provider/spotify.d.ts.map +0 -1
  673. package/dist/types/provider/twitch.d.ts +0 -38
  674. package/dist/types/provider/twitch.d.ts.map +0 -1
  675. package/dist/types/provider/x.d.ts +0 -38
  676. package/dist/types/provider/x.d.ts.map +0 -1
  677. package/dist/types/provider/yahoo.d.ts +0 -38
  678. package/dist/types/provider/yahoo.d.ts.map +0 -1
  679. package/dist/types/random.d.ts +0 -3
  680. package/dist/types/random.d.ts.map +0 -1
  681. package/dist/types/storage/aws.d.ts +0 -4
  682. package/dist/types/storage/aws.d.ts.map +0 -1
  683. package/dist/types/storage/cloudflare.d.ts +0 -34
  684. package/dist/types/storage/cloudflare.d.ts.map +0 -1
  685. package/dist/types/storage/dynamo.d.ts +0 -65
  686. package/dist/types/storage/dynamo.d.ts.map +0 -1
  687. package/dist/types/storage/memory.d.ts +0 -49
  688. package/dist/types/storage/memory.d.ts.map +0 -1
  689. package/dist/types/storage/storage.d.ts +0 -15
  690. package/dist/types/storage/storage.d.ts.map +0 -1
  691. package/dist/types/subject.d.ts +0 -122
  692. package/dist/types/subject.d.ts.map +0 -1
  693. package/dist/types/ui/base.d.ts +0 -5
  694. package/dist/types/ui/base.d.ts.map +0 -1
  695. package/dist/types/ui/code.d.ts +0 -104
  696. package/dist/types/ui/code.d.ts.map +0 -1
  697. package/dist/types/ui/form.d.ts +0 -6
  698. package/dist/types/ui/form.d.ts.map +0 -1
  699. package/dist/types/ui/icon.d.ts +0 -6
  700. package/dist/types/ui/icon.d.ts.map +0 -1
  701. package/dist/types/ui/passkey.d.ts +0 -5
  702. package/dist/types/ui/passkey.d.ts.map +0 -1
  703. package/dist/types/ui/password.d.ts +0 -139
  704. package/dist/types/ui/password.d.ts.map +0 -1
  705. package/dist/types/ui/select.d.ts +0 -55
  706. package/dist/types/ui/select.d.ts.map +0 -1
  707. package/dist/types/ui/theme.d.ts +0 -207
  708. package/dist/types/ui/theme.d.ts.map +0 -1
  709. package/dist/types/util.d.ts +0 -8
  710. package/dist/types/util.d.ts.map +0 -1
  711. package/src/css.d.ts +0 -4
  712. package/src/issuer.ts +0 -1628
  713. package/src/jwt.ts +0 -17
  714. package/src/keys.ts +0 -139
  715. package/src/provider/apple.ts +0 -127
  716. package/src/provider/arctic.ts +0 -66
  717. package/src/provider/code.ts +0 -227
  718. package/src/provider/cognito.ts +0 -74
  719. package/src/provider/discord.ts +0 -45
  720. package/src/provider/facebook.ts +0 -84
  721. package/src/provider/github.ts +0 -45
  722. package/src/provider/google.ts +0 -85
  723. package/src/provider/index.ts +0 -3
  724. package/src/provider/jumpcloud.ts +0 -45
  725. package/src/provider/keycloak.ts +0 -75
  726. package/src/provider/linkedin.ts +0 -12
  727. package/src/provider/m2m.ts +0 -56
  728. package/src/provider/microsoft.ts +0 -100
  729. package/src/provider/oauth2.ts +0 -297
  730. package/src/provider/oidc.ts +0 -179
  731. package/src/provider/passkey.ts +0 -655
  732. package/src/provider/password.ts +0 -672
  733. package/src/provider/provider.ts +0 -33
  734. package/src/provider/slack.ts +0 -67
  735. package/src/provider/spotify.ts +0 -45
  736. package/src/provider/twitch.ts +0 -45
  737. package/src/provider/x.ts +0 -46
  738. package/src/provider/yahoo.ts +0 -45
  739. package/src/random.ts +0 -24
  740. package/src/storage/aws.ts +0 -59
  741. package/src/storage/cloudflare.ts +0 -77
  742. package/src/storage/dynamo.ts +0 -193
  743. package/src/storage/memory.ts +0 -135
  744. package/src/storage/storage.ts +0 -46
  745. package/src/subject.ts +0 -130
  746. package/src/ui/base.tsx +0 -118
  747. package/src/ui/code.tsx +0 -215
  748. package/src/ui/form.tsx +0 -40
  749. package/src/ui/icon.tsx +0 -95
  750. package/src/ui/passkey.tsx +0 -321
  751. package/src/ui/password.tsx +0 -405
  752. package/src/ui/select.tsx +0 -221
  753. package/src/ui/theme.ts +0 -319
  754. package/src/ui/ui.css +0 -252
  755. package/src/util.ts +0 -58
  756. /package/dist/esm/{css.d.js → adapters/d1/types.js} +0 -0
@@ -1,672 +0,0 @@
1
- /**
2
- * Configures a provider that supports username and password authentication. This is usually
3
- * paired with the `PasswordUI`.
4
- *
5
- * ```ts
6
- * import { PasswordUI } from "@openauthjs/openauth/ui/password"
7
- * import { PasswordProvider } from "@openauthjs/openauth/provider/password"
8
- *
9
- * export default issuer({
10
- * providers: {
11
- * password: PasswordProvider(
12
- * PasswordUI({
13
- * copy: {
14
- * error_email_taken: "This email is already taken."
15
- * },
16
- * sendCode: (email, code) => console.log(email, code)
17
- * })
18
- * )
19
- * },
20
- * // ...
21
- * })
22
- * ```
23
- *
24
- * Behind the scenes, the `PasswordProvider` expects callbacks that implements request handlers
25
- * that generate the UI for the following.
26
- *
27
- * ```ts
28
- * PasswordProvider({
29
- * // ...
30
- * login: (req, form, error) => Promise<Response>
31
- * register: (req, state, form, error) => Promise<Response>
32
- * change: (req, state, form, error) => Promise<Response>
33
- * })
34
- * ```
35
- *
36
- * This allows you to create your own UI for each of these screens.
37
- *
38
- * @packageDocumentation
39
- */
40
- import { UnknownStateError } from "../error.js"
41
- import { Storage } from "../storage/storage.js"
42
- import { Provider } from "./provider.js"
43
- import { generateUnbiasedDigits, timingSafeCompare } from "../random.js"
44
- import { v1 } from "@standard-schema/spec"
45
-
46
- /**
47
- * @internal
48
- */
49
- export interface PasswordHasher<T> {
50
- hash(password: string): Promise<T>
51
- verify(password: string, compare: T): Promise<boolean>
52
- }
53
-
54
- export interface PasswordConfig {
55
- /**
56
- * @internal
57
- */
58
- length?: number
59
- /**
60
- * @internal
61
- */
62
- hasher?: PasswordHasher<any>
63
- /**
64
- * The request handler to generate the UI for the login screen.
65
- *
66
- * Takes the standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
67
- * and optionally [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
68
- * ojects.
69
- *
70
- * In case of an error, this is called again with the `error`.
71
- *
72
- * Expects the [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object
73
- * in return.
74
- */
75
- login: (
76
- req: Request,
77
- form?: FormData,
78
- error?: PasswordLoginError,
79
- ) => Promise<Response>
80
- /**
81
- * The request handler to generate the UI for the register screen.
82
- *
83
- * Takes the standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
84
- * and optionally [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
85
- * ojects.
86
- *
87
- * Also passes in the current `state` of the flow and any `error` that occurred.
88
- *
89
- * Expects the [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object
90
- * in return.
91
- */
92
- register: (
93
- req: Request,
94
- state: PasswordRegisterState,
95
- form?: FormData,
96
- error?: PasswordRegisterError,
97
- ) => Promise<Response>
98
- /**
99
- * The request handler to generate the UI for the change password screen.
100
- *
101
- * Takes the standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
102
- * and optionally [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
103
- * ojects.
104
- *
105
- * Also passes in the current `state` of the flow and any `error` that occurred.
106
- *
107
- * Expects the [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object
108
- * in return.
109
- */
110
- change: (
111
- req: Request,
112
- state: PasswordChangeState,
113
- form?: FormData,
114
- error?: PasswordChangeError,
115
- ) => Promise<Response>
116
- /**
117
- * Callback to send the confirmation pin code to the user.
118
- *
119
- * @example
120
- * ```ts
121
- * {
122
- * sendCode: async (email, code) => {
123
- * // Send an email with the code
124
- * }
125
- * }
126
- * ```
127
- */
128
- sendCode: (email: string, code: string) => Promise<void>
129
- /**
130
- * Callback to validate the password on sign up and password reset.
131
- *
132
- * @example
133
- * ```ts
134
- * {
135
- * validatePassword: (password) => {
136
- * return password.length < 8 ? "Password must be at least 8 characters" : undefined
137
- * }
138
- * }
139
- * ```
140
- */
141
- validatePassword?:
142
- | v1.StandardSchema
143
- | ((password: string) => Promise<string | undefined> | string | undefined)
144
- }
145
-
146
- /**
147
- * The states that can happen on the register screen.
148
- *
149
- * | State | Description |
150
- * | ----- | ----------- |
151
- * | `start` | The user is asked to enter their email address and password to start the flow. |
152
- * | `code` | The user needs to enter the pin code to verify their email. |
153
- */
154
- export type PasswordRegisterState =
155
- | {
156
- type: "start"
157
- }
158
- | {
159
- type: "code"
160
- code: string
161
- email: string
162
- password: string
163
- }
164
-
165
- /**
166
- * The errors that can happen on the register screen.
167
- *
168
- * | Error | Description |
169
- * | ----- | ----------- |
170
- * | `email_taken` | The email is already taken. |
171
- * | `invalid_email` | The email is invalid. |
172
- * | `invalid_code` | The code is invalid. |
173
- * | `invalid_password` | The password is invalid. |
174
- * | `password_mismatch` | The passwords do not match. |
175
- */
176
- export type PasswordRegisterError =
177
- | {
178
- type: "invalid_code"
179
- }
180
- | {
181
- type: "email_taken"
182
- }
183
- | {
184
- type: "invalid_email"
185
- }
186
- | {
187
- type: "invalid_password"
188
- }
189
- | {
190
- type: "password_mismatch"
191
- }
192
- | {
193
- type: "validation_error"
194
- message?: string
195
- }
196
-
197
- /**
198
- * The state of the password change flow.
199
- *
200
- * | State | Description |
201
- * | ----- | ----------- |
202
- * | `start` | The user is asked to enter their email address to start the flow. |
203
- * | `code` | The user needs to enter the pin code to verify their email. |
204
- * | `update` | The user is asked to enter their new password and confirm it. |
205
- */
206
- export type PasswordChangeState =
207
- | {
208
- type: "start"
209
- redirect: string
210
- }
211
- | {
212
- type: "code"
213
- code: string
214
- email: string
215
- redirect: string
216
- }
217
- | {
218
- type: "update"
219
- redirect: string
220
- email: string
221
- }
222
-
223
- /**
224
- * The errors that can happen on the change password screen.
225
- *
226
- * | Error | Description |
227
- * | ----- | ----------- |
228
- * | `invalid_email` | The email is invalid. |
229
- * | `invalid_code` | The code is invalid. |
230
- * | `invalid_password` | The password is invalid. |
231
- * | `password_mismatch` | The passwords do not match. |
232
- */
233
- export type PasswordChangeError =
234
- | {
235
- type: "invalid_email"
236
- }
237
- | {
238
- type: "invalid_code"
239
- }
240
- | {
241
- type: "invalid_password"
242
- }
243
- | {
244
- type: "password_mismatch"
245
- }
246
- | {
247
- type: "validation_error"
248
- message: string
249
- }
250
-
251
- /**
252
- * The errors that can happen on the login screen.
253
- *
254
- * | Error | Description |
255
- * | ----- | ----------- |
256
- * | `invalid_email` | The email is invalid. |
257
- * | `invalid_password` | The password is invalid. |
258
- */
259
- export type PasswordLoginError =
260
- | {
261
- type: "invalid_password"
262
- }
263
- | {
264
- type: "invalid_email"
265
- }
266
-
267
- export function PasswordProvider(
268
- config: PasswordConfig,
269
- ): Provider<{ email: string }> {
270
- const hasher = config.hasher ?? ScryptHasher()
271
- function generate() {
272
- return generateUnbiasedDigits(6)
273
- }
274
- return {
275
- type: "password",
276
- init(routes, ctx) {
277
- routes.get("/authorize", async (c) =>
278
- ctx.forward(c, await config.login(c.req.raw)),
279
- )
280
-
281
- routes.post("/authorize", async (c) => {
282
- const fd = await c.req.formData()
283
- async function error(err: PasswordLoginError) {
284
- return ctx.forward(c, await config.login(c.req.raw, fd, err))
285
- }
286
- const email = fd.get("email")?.toString()?.toLowerCase()
287
- if (!email) return error({ type: "invalid_email" })
288
- const hash = await Storage.get<HashedPassword>(ctx.storage, [
289
- "email",
290
- email,
291
- "password",
292
- ])
293
- const password = fd.get("password")?.toString()
294
- if (!password || !hash || !(await hasher.verify(password, hash)))
295
- return error({ type: "invalid_password" })
296
- return ctx.success(
297
- c,
298
- {
299
- email: email,
300
- },
301
- {
302
- invalidate: async (subject) => {
303
- await Storage.set(
304
- ctx.storage,
305
- ["email", email, "subject"],
306
- subject,
307
- )
308
- },
309
- },
310
- )
311
- })
312
-
313
- routes.get("/register", async (c) => {
314
- const state: PasswordRegisterState = {
315
- type: "start",
316
- }
317
- await ctx.set(c, "provider", 60 * 60 * 24, state)
318
- return ctx.forward(c, await config.register(c.req.raw, state))
319
- })
320
-
321
- routes.post("/register", async (c) => {
322
- const fd = await c.req.formData()
323
- const email = fd.get("email")?.toString()?.toLowerCase()
324
- const action = fd.get("action")?.toString()
325
- const provider = await ctx.get<PasswordRegisterState>(c, "provider")
326
-
327
- async function transition(
328
- next: PasswordRegisterState,
329
- err?: PasswordRegisterError,
330
- ) {
331
- await ctx.set<PasswordRegisterState>(
332
- c,
333
- "provider",
334
- 60 * 60 * 24,
335
- next,
336
- )
337
- return ctx.forward(c, await config.register(c.req.raw, next, fd, err))
338
- }
339
-
340
- if (action === "register" && provider.type === "start") {
341
- const password = fd.get("password")?.toString()
342
- const repeat = fd.get("repeat")?.toString()
343
- if (!email) return transition(provider, { type: "invalid_email" })
344
- if (!password)
345
- return transition(provider, { type: "invalid_password" })
346
- if (password !== repeat)
347
- return transition(provider, { type: "password_mismatch" })
348
- if (config.validatePassword) {
349
- let validationError: string | undefined
350
- try {
351
- if (typeof config.validatePassword === "function") {
352
- validationError = await config.validatePassword(password)
353
- } else {
354
- const res =
355
- await config.validatePassword["~standard"].validate(password)
356
-
357
- if (res.issues?.length) {
358
- throw new Error(
359
- res.issues.map((issue) => issue.message).join(", "),
360
- )
361
- }
362
- }
363
- } catch (error) {
364
- validationError =
365
- error instanceof Error ? error.message : undefined
366
- }
367
- if (validationError)
368
- return transition(provider, {
369
- type: "validation_error",
370
- message: validationError,
371
- })
372
- }
373
- const existing = await Storage.get(ctx.storage, [
374
- "email",
375
- email,
376
- "password",
377
- ])
378
- if (existing) return transition(provider, { type: "email_taken" })
379
- const code = generate()
380
- await config.sendCode(email, code)
381
- return transition({
382
- type: "code",
383
- code,
384
- password: await hasher.hash(password),
385
- email,
386
- })
387
- }
388
-
389
- if (action === "register" && provider.type === "code") {
390
- const code = generate()
391
- await config.sendCode(provider.email, code)
392
- return transition({
393
- type: "code",
394
- code,
395
- password: provider.password,
396
- email: provider.email,
397
- })
398
- }
399
-
400
- if (action === "verify" && provider.type === "code") {
401
- const code = fd.get("code")?.toString()
402
- if (!code || !timingSafeCompare(code, provider.code))
403
- return transition(provider, { type: "invalid_code" })
404
- const existing = await Storage.get(ctx.storage, [
405
- "email",
406
- provider.email,
407
- "password",
408
- ])
409
- if (existing)
410
- return transition({ type: "start" }, { type: "email_taken" })
411
- await Storage.set(
412
- ctx.storage,
413
- ["email", provider.email, "password"],
414
- provider.password,
415
- )
416
- return ctx.success(c, {
417
- email: provider.email,
418
- })
419
- }
420
-
421
- return transition({ type: "start" })
422
- })
423
-
424
- routes.get("/change", async (c) => {
425
- let redirect =
426
- c.req.query("redirect_uri") || getRelativeUrl(c, "./authorize")
427
- const state: PasswordChangeState = {
428
- type: "start",
429
- redirect,
430
- }
431
- await ctx.set(c, "provider", 60 * 60 * 24, state)
432
- return ctx.forward(c, await config.change(c.req.raw, state))
433
- })
434
-
435
- routes.post("/change", async (c) => {
436
- const fd = await c.req.formData()
437
- const action = fd.get("action")?.toString()
438
- const provider = await ctx.get<PasswordChangeState>(c, "provider")
439
- if (!provider) throw new UnknownStateError()
440
-
441
- async function transition(
442
- next: PasswordChangeState,
443
- err?: PasswordChangeError,
444
- ) {
445
- await ctx.set<PasswordChangeState>(c, "provider", 60 * 60 * 24, next)
446
- return ctx.forward(c, await config.change(c.req.raw, next, fd, err))
447
- }
448
-
449
- if (action === "code") {
450
- const email = fd.get("email")?.toString()?.toLowerCase()
451
- if (!email)
452
- return transition(
453
- { type: "start", redirect: provider.redirect },
454
- { type: "invalid_email" },
455
- )
456
- const code = generate()
457
- await config.sendCode(email, code)
458
-
459
- return transition({
460
- type: "code",
461
- code,
462
- email,
463
- redirect: provider.redirect,
464
- })
465
- }
466
-
467
- if (action === "verify" && provider.type === "code") {
468
- const code = fd.get("code")?.toString()
469
- if (!code || !timingSafeCompare(code, provider.code))
470
- return transition(provider, { type: "invalid_code" })
471
- return transition({
472
- type: "update",
473
- email: provider.email,
474
- redirect: provider.redirect,
475
- })
476
- }
477
-
478
- if (action === "update" && provider.type === "update") {
479
- const existing = await Storage.get(ctx.storage, [
480
- "email",
481
- provider.email,
482
- "password",
483
- ])
484
- if (!existing) return c.redirect(provider.redirect, 302)
485
-
486
- const password = fd.get("password")?.toString()
487
- const repeat = fd.get("repeat")?.toString()
488
- if (!password)
489
- return transition(provider, { type: "invalid_password" })
490
- if (password !== repeat)
491
- return transition(provider, { type: "password_mismatch" })
492
-
493
- if (config.validatePassword) {
494
- let validationError: string | undefined
495
- try {
496
- if (typeof config.validatePassword === "function") {
497
- validationError = await config.validatePassword(password)
498
- } else {
499
- const res =
500
- await config.validatePassword["~standard"].validate(password)
501
-
502
- if (res.issues?.length) {
503
- throw new Error(
504
- res.issues.map((issue) => issue.message).join(", "),
505
- )
506
- }
507
- }
508
- } catch (error) {
509
- validationError =
510
- error instanceof Error ? error.message : undefined
511
- }
512
- if (validationError)
513
- return transition(provider, {
514
- type: "validation_error",
515
- message: validationError,
516
- })
517
- }
518
-
519
- await Storage.set(
520
- ctx.storage,
521
- ["email", provider.email, "password"],
522
- await hasher.hash(password),
523
- )
524
- const subject = await Storage.get<string>(ctx.storage, [
525
- "email",
526
- provider.email,
527
- "subject",
528
- ])
529
- if (subject) await ctx.invalidate(subject)
530
-
531
- return c.redirect(provider.redirect, 302)
532
- }
533
-
534
- return transition({ type: "start", redirect: provider.redirect })
535
- })
536
- },
537
- }
538
- }
539
-
540
- import * as jose from "jose"
541
- import { TextEncoder } from "node:util"
542
-
543
- interface HashedPassword {}
544
-
545
- /**
546
- * @internal
547
- */
548
- export function PBKDF2Hasher(opts?: { iterations?: number }): PasswordHasher<{
549
- hash: string
550
- salt: string
551
- iterations: number
552
- }> {
553
- const iterations = opts?.iterations ?? 600000
554
- return {
555
- async hash(password) {
556
- const encoder = new TextEncoder()
557
- const bytes = encoder.encode(password)
558
- const salt = crypto.getRandomValues(new Uint8Array(16))
559
- const keyMaterial = await crypto.subtle.importKey(
560
- "raw",
561
- bytes,
562
- "PBKDF2",
563
- false,
564
- ["deriveBits"],
565
- )
566
- const hash = await crypto.subtle.deriveBits(
567
- {
568
- name: "PBKDF2",
569
- hash: "SHA-256",
570
- salt: salt,
571
- iterations,
572
- },
573
- keyMaterial,
574
- 256,
575
- )
576
- const hashBase64 = jose.base64url.encode(new Uint8Array(hash))
577
- const saltBase64 = jose.base64url.encode(salt)
578
- return {
579
- hash: hashBase64,
580
- salt: saltBase64,
581
- iterations,
582
- }
583
- },
584
- async verify(password, compare) {
585
- const encoder = new TextEncoder()
586
- const passwordBytes = encoder.encode(password)
587
- const salt = jose.base64url.decode(compare.salt)
588
- const params = {
589
- name: "PBKDF2",
590
- hash: "SHA-256",
591
- salt,
592
- iterations: compare.iterations,
593
- }
594
- const keyMaterial = await crypto.subtle.importKey(
595
- "raw",
596
- passwordBytes,
597
- "PBKDF2",
598
- false,
599
- ["deriveBits"],
600
- )
601
- const hash = await crypto.subtle.deriveBits(params, keyMaterial, 256)
602
- const hashBase64 = jose.base64url.encode(new Uint8Array(hash))
603
- return hashBase64 === compare.hash
604
- },
605
- }
606
- }
607
- import { timingSafeEqual, randomBytes, scrypt } from "node:crypto"
608
- import { getRelativeUrl } from "../util.js"
609
-
610
- /**
611
- * @internal
612
- */
613
- export function ScryptHasher(opts?: {
614
- N?: number
615
- r?: number
616
- p?: number
617
- }): PasswordHasher<{
618
- hash: string
619
- salt: string
620
- N: number
621
- r: number
622
- p: number
623
- }> {
624
- const N = opts?.N ?? 16384
625
- const r = opts?.r ?? 8
626
- const p = opts?.p ?? 1
627
-
628
- return {
629
- async hash(password) {
630
- const salt = randomBytes(16)
631
- const keyLength = 32 // 256 bits
632
-
633
- const derivedKey = await new Promise<Buffer>((resolve, reject) => {
634
- scrypt(password, salt, keyLength, { N, r, p }, (err, derivedKey) => {
635
- if (err) reject(err)
636
- else resolve(derivedKey)
637
- })
638
- })
639
-
640
- const hashBase64 = derivedKey.toString("base64")
641
- const saltBase64 = salt.toString("base64")
642
-
643
- return {
644
- hash: hashBase64,
645
- salt: saltBase64,
646
- N,
647
- r,
648
- p,
649
- }
650
- },
651
-
652
- async verify(password, compare) {
653
- const salt = Buffer.from(compare.salt, "base64")
654
- const keyLength = 32 // 256 bits
655
-
656
- const derivedKey = await new Promise<Buffer>((resolve, reject) => {
657
- scrypt(
658
- password,
659
- salt,
660
- keyLength,
661
- { N: compare.N, r: compare.r, p: compare.p },
662
- (err, derivedKey) => {
663
- if (err) reject(err)
664
- else resolve(derivedKey)
665
- },
666
- )
667
- })
668
-
669
- return timingSafeEqual(derivedKey, Buffer.from(compare.hash, "base64"))
670
- },
671
- }
672
- }
@@ -1,33 +0,0 @@
1
- import type { Context, Hono } from "hono"
2
- import { StorageAdapter } from "../storage/storage.js"
3
-
4
- export type ProviderRoute = Hono
5
-
6
- export interface Provider<Properties = any> {
7
- type: string
8
- init: (route: ProviderRoute, options: ProviderOptions<Properties>) => void
9
- client?: (input: {
10
- clientID: string
11
- clientSecret: string
12
- params: Record<string, string>
13
- }) => Promise<Properties>
14
- }
15
-
16
- export interface ProviderOptions<Properties> {
17
- name: string
18
- success: (
19
- ctx: Context,
20
- properties: Properties,
21
- opts?: {
22
- invalidate?: (subject: string) => Promise<void>
23
- },
24
- ) => Promise<Response>
25
- forward: (ctx: Context, response: Response) => Response
26
- set: <T>(ctx: Context, key: string, maxAge: number, value: T) => Promise<void>
27
- get: <T>(ctx: Context, key: string) => Promise<T>
28
- unset: (ctx: Context, key: string) => Promise<void>
29
- invalidate: (subject: string) => Promise<void>
30
- storage: StorageAdapter
31
- }
32
- export class ProviderError extends Error {}
33
- export class ProviderUnknownError extends ProviderError {}