@udibo/oauth2 0.14.0 → 0.15.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 (411) hide show
  1. package/README.md +45 -24
  2. package/{esm → dist}/adapters/hono/_common.d.ts +5 -5
  3. package/{esm → dist}/adapters/hono/_common.js +1 -1
  4. package/{esm → dist}/adapters/hono/authorization-server.d.ts +6 -7
  5. package/{esm → dist}/adapters/hono/authorization-server.js +0 -1
  6. package/{esm → dist}/adapters/hono/bff/auth-request-store.d.ts +2 -2
  7. package/{esm → dist}/adapters/hono/bff/auth-request-store.js +2 -2
  8. package/{esm → dist}/adapters/hono/bff/bff.d.ts +22 -12
  9. package/{esm → dist}/adapters/hono/bff/bff.js +35 -29
  10. package/{esm → dist}/adapters/hono/bff/cookie-prefix.js +1 -2
  11. package/{esm → dist}/adapters/hono/bff/mod.d.ts +5 -6
  12. package/{esm → dist}/adapters/hono/bff/mod.js +1 -2
  13. package/{esm → dist}/adapters/hono/bff/proxy.js +2 -1
  14. package/{esm → dist}/adapters/hono/bff/session-store.d.ts +2 -2
  15. package/{esm → dist}/adapters/hono/bff/session-store.js +7 -6
  16. package/{esm → dist}/adapters/hono/bff/testing.d.ts +7 -8
  17. package/{esm → dist}/adapters/hono/bff/testing.js +19 -22
  18. package/{esm → dist}/adapters/hono/identity.d.ts +1 -2
  19. package/{esm → dist}/adapters/hono/identity.js +10 -10
  20. package/{esm → dist}/adapters/hono/log.d.ts +0 -1
  21. package/{esm → dist}/adapters/hono/log.js +0 -6
  22. package/{esm → dist}/adapters/hono/resource-server.d.ts +5 -6
  23. package/{esm → dist}/adapters/hono/resource-server.js +0 -1
  24. package/dist/cli/bin.d.ts +2 -0
  25. package/dist/cli/bin.js +3 -0
  26. package/dist/cli/idp/config.d.ts +110 -0
  27. package/dist/cli/idp/config.js +269 -0
  28. package/dist/cli/idp/mod.d.ts +20 -0
  29. package/dist/cli/idp/mod.js +175 -0
  30. package/dist/cli/idp/pages.d.ts +56 -0
  31. package/dist/cli/idp/pages.js +190 -0
  32. package/dist/cli/idp/server.d.ts +93 -0
  33. package/dist/cli/idp/server.js +559 -0
  34. package/dist/cli/keygen.d.ts +13 -0
  35. package/dist/cli/keygen.js +30 -0
  36. package/dist/cli/mod.d.ts +34 -0
  37. package/dist/cli/mod.js +94 -0
  38. package/{esm → dist}/client/_http.d.ts +1 -1
  39. package/{esm → dist}/client/base.d.ts +1 -1
  40. package/{esm → dist}/client/bff-client.d.ts +1 -1
  41. package/{esm → dist}/client/bff-client.js +7 -6
  42. package/{esm → dist}/client/browser-storage.d.ts +1 -1
  43. package/{esm → dist}/client/check.js +1 -1
  44. package/{esm → dist}/client/direct-client.d.ts +6 -6
  45. package/{esm → dist}/client/direct-client.js +11 -13
  46. package/{esm → dist}/client/discovery-cache.d.ts +1 -1
  47. package/{esm → dist}/client/discovery-cache.js +2 -2
  48. package/{esm → dist}/client/events.d.ts +1 -1
  49. package/{esm → dist}/client/mod.d.ts +11 -12
  50. package/{esm → dist}/client/mod.js +1 -1
  51. package/{esm → dist}/errors.d.ts +1 -1
  52. package/{esm → dist}/errors.js +1 -1
  53. package/{esm → dist}/identity/events.d.ts +1 -1
  54. package/{esm → dist}/identity/external/_shared.d.ts +1 -1
  55. package/{esm → dist}/identity/external/_shared.js +1 -2
  56. package/{esm → dist}/identity/external/apple-client-secret.d.ts +1 -1
  57. package/{esm → dist}/identity/external/apple-client-secret.js +6 -7
  58. package/{esm → dist}/identity/external/apple.d.ts +5 -5
  59. package/{esm → dist}/identity/external/apple.js +10 -11
  60. package/{esm → dist}/identity/external/discord.d.ts +3 -3
  61. package/{esm → dist}/identity/external/discord.js +2 -2
  62. package/{esm → dist}/identity/external/flow.d.ts +1 -1
  63. package/{esm → dist}/identity/external/flow.js +2 -2
  64. package/{esm → dist}/identity/external/github.d.ts +3 -3
  65. package/{esm → dist}/identity/external/github.js +12 -17
  66. package/{esm → dist}/identity/external/google.d.ts +5 -5
  67. package/{esm → dist}/identity/external/google.js +2 -2
  68. package/{esm → dist}/identity/external/mod.d.ts +12 -13
  69. package/{esm → dist}/identity/external/mod.js +0 -1
  70. package/{esm → dist}/identity/external/oauth2.d.ts +1 -1
  71. package/{esm → dist}/identity/external/oauth2.js +8 -8
  72. package/{esm → dist}/identity/external/oidc.d.ts +4 -4
  73. package/{esm → dist}/identity/external/oidc.js +9 -8
  74. package/{esm → dist}/identity/hibp.d.ts +1 -1
  75. package/{esm → dist}/identity/hibp.js +1 -1
  76. package/{esm → dist}/identity/lockout.js +1 -2
  77. package/{esm → dist}/identity/mfa/mod.d.ts +4 -5
  78. package/{esm → dist}/identity/mfa/mod.js +1 -2
  79. package/{esm → dist}/identity/mfa/service.d.ts +3 -3
  80. package/{esm → dist}/identity/mfa/service.js +4 -3
  81. package/{esm → dist}/identity/mfa/totp.d.ts +1 -1
  82. package/{esm → dist}/identity/mfa/totp.js +2 -2
  83. package/{esm → dist}/identity/migration.d.ts +2 -3
  84. package/{esm → dist}/identity/migration.js +3 -4
  85. package/{esm → dist}/identity/mod.d.ts +14 -15
  86. package/{esm → dist}/identity/mod.js +0 -1
  87. package/{esm → dist}/identity/otp.d.ts +1 -1
  88. package/{esm → dist}/identity/otp.js +4 -2
  89. package/{esm → dist}/identity/password.js +8 -5
  90. package/{esm → dist}/identity/rate-limit.d.ts +1 -1
  91. package/{esm → dist}/identity/service.d.ts +10 -10
  92. package/{esm → dist}/identity/service.js +17 -18
  93. package/{esm → dist}/identity/session.js +2 -2
  94. package/{esm → dist}/identity/token-flow.js +3 -2
  95. package/{esm → dist}/models/authorization-code.d.ts +3 -3
  96. package/{esm → dist}/models/authorization.d.ts +1 -1
  97. package/{esm → dist}/models/authorization.js +1 -2
  98. package/{esm → dist}/models/device-authorization.d.ts +2 -2
  99. package/{esm → dist}/models/token.d.ts +3 -3
  100. package/{esm → dist}/react/callback.d.ts +1 -1
  101. package/{esm → dist}/react/callback.js +0 -1
  102. package/{esm → dist}/react/components/class-names.d.ts +1 -1
  103. package/{esm → dist}/react/components/class-names.js +3 -2
  104. package/{esm → dist}/react/components/internal.d.ts +2 -2
  105. package/{esm → dist}/react/components/internal.js +5 -11
  106. package/{esm → dist}/react/components/mfa-challenge-form.d.ts +2 -2
  107. package/{esm → dist}/react/components/mfa-challenge-form.js +4 -6
  108. package/{esm → dist}/react/components/mfa-enrollment-form.d.ts +2 -2
  109. package/{esm → dist}/react/components/mfa-enrollment-form.js +2 -6
  110. package/{esm → dist}/react/components/mod.d.ts +20 -21
  111. package/{esm → dist}/react/components/mod.js +1 -2
  112. package/{esm → dist}/react/components/request-password-reset-form.d.ts +2 -2
  113. package/{esm → dist}/react/components/request-password-reset-form.js +1 -3
  114. package/{esm → dist}/react/components/reset-password-form.d.ts +2 -2
  115. package/{esm → dist}/react/components/reset-password-form.js +2 -2
  116. package/{esm → dist}/react/components/sign-in-form.d.ts +2 -2
  117. package/{esm → dist}/react/components/sign-in-form.js +1 -5
  118. package/{esm → dist}/react/components/sign-up-form.d.ts +2 -2
  119. package/{esm → dist}/react/components/sign-up-form.js +4 -10
  120. package/{esm → dist}/react/components/types.d.ts +2 -2
  121. package/{esm → dist}/react/components/use-auth-form.d.ts +3 -3
  122. package/{esm → dist}/react/components/use-auth-form.js +4 -7
  123. package/{esm → dist}/react/components/user-menu.d.ts +2 -2
  124. package/{esm → dist}/react/components/user-menu.js +9 -14
  125. package/{esm → dist}/react/context.d.ts +1 -1
  126. package/{esm → dist}/react/mod.d.ts +6 -7
  127. package/{esm → dist}/react/mod.js +0 -1
  128. package/{esm → dist}/react/provider.d.ts +2 -2
  129. package/{esm → dist}/react/require-auth.js +1 -3
  130. package/{esm → dist}/react/testing.d.ts +2 -3
  131. package/{esm → dist}/react/testing.js +1 -2
  132. package/{esm → dist}/react/use-authorization.d.ts +1 -1
  133. package/{esm → dist}/react/use-oauth2.d.ts +8 -1
  134. package/{esm → dist}/react/use-oauth2.js +0 -1
  135. package/{esm → dist}/server/_clock-skew.js +2 -1
  136. package/{esm → dist}/server/authorization-server.d.ts +40 -41
  137. package/{esm → dist}/server/authorization-server.js +32 -42
  138. package/{esm → dist}/server/client-authentication.d.ts +2 -2
  139. package/{esm → dist}/server/grants/authorization-code.d.ts +9 -9
  140. package/{esm → dist}/server/grants/authorization-code.js +5 -6
  141. package/{esm → dist}/server/grants/client-credentials.d.ts +4 -4
  142. package/{esm → dist}/server/grants/device-authorization.d.ts +6 -6
  143. package/{esm → dist}/server/grants/device-authorization.js +4 -4
  144. package/{esm → dist}/server/grants/grant.d.ts +7 -7
  145. package/{esm → dist}/server/grants/grant.js +7 -7
  146. package/{esm → dist}/server/grants/password.d.ts +5 -5
  147. package/{esm → dist}/server/grants/refresh-token.d.ts +4 -4
  148. package/{esm → dist}/server/grants/refresh-token.js +5 -6
  149. package/{esm → dist}/server/introspection-token-reader.d.ts +5 -5
  150. package/{esm → dist}/server/introspection-token-reader.js +4 -4
  151. package/{esm → dist}/server/jwks-token-reader.d.ts +5 -5
  152. package/{esm → dist}/server/jwks-token-reader.js +4 -4
  153. package/{esm → dist}/server/mod.d.ts +12 -13
  154. package/{esm → dist}/server/mod.js +0 -1
  155. package/{esm → dist}/server/public-suffix/mod.d.ts +2 -3
  156. package/{esm → dist}/server/public-suffix/mod.js +1 -2
  157. package/{esm → dist}/server/public-suffix/rules.d.ts +1 -1
  158. package/{esm → dist}/server/public-suffix/rules.js +1 -1
  159. package/{esm → dist}/server/redirect-uri.js +5 -4
  160. package/{esm → dist}/server/resource-server.d.ts +11 -12
  161. package/{esm → dist}/server/resource-server.js +12 -14
  162. package/{esm → dist}/server/services/authorization-code.d.ts +5 -5
  163. package/{esm → dist}/server/services/client.d.ts +1 -1
  164. package/{esm → dist}/server/services/device-authorization.d.ts +3 -3
  165. package/{esm → dist}/server/services/token.d.ts +6 -6
  166. package/{esm → dist}/server/services/token.js +3 -1
  167. package/{esm → dist}/server/services/user.d.ts +1 -1
  168. package/{esm → dist}/server/signing-keys.d.ts +1 -1
  169. package/{esm → dist}/server/signing-keys.js +8 -2
  170. package/{esm → dist}/server/utils/hash.js +1 -1
  171. package/{esm → dist}/testing/contract/auth-request-storage.d.ts +1 -1
  172. package/{esm → dist}/testing/contract/auth-request-storage.js +24 -29
  173. package/{esm → dist}/testing/contract/authorization-code.d.ts +6 -6
  174. package/{esm → dist}/testing/contract/authorization-code.js +16 -17
  175. package/{esm → dist}/testing/contract/client.d.ts +4 -4
  176. package/{esm → dist}/testing/contract/client.js +14 -15
  177. package/{esm → dist}/testing/contract/device-authorization.d.ts +6 -6
  178. package/{esm → dist}/testing/contract/device-authorization.js +37 -39
  179. package/{esm → dist}/testing/contract/identity-session.d.ts +6 -1
  180. package/{esm → dist}/testing/contract/identity-session.js +44 -36
  181. package/{esm → dist}/testing/contract/identity-user-store.d.ts +8 -2
  182. package/{esm → dist}/testing/contract/identity-user-store.js +48 -46
  183. package/{esm → dist}/testing/contract/lockout-store.d.ts +1 -1
  184. package/{esm → dist}/testing/contract/lockout-store.js +23 -24
  185. package/{esm → dist}/testing/contract/mfa-store.d.ts +1 -1
  186. package/{esm → dist}/testing/contract/mfa-store.js +53 -54
  187. package/{esm → dist}/testing/contract/mod.d.ts +15 -16
  188. package/{esm → dist}/testing/contract/mod.js +0 -1
  189. package/{esm → dist}/testing/contract/otp-store.d.ts +1 -1
  190. package/{esm → dist}/testing/contract/otp-store.js +33 -34
  191. package/{esm → dist}/testing/contract/rate-limit-store.d.ts +1 -1
  192. package/{esm → dist}/testing/contract/rate-limit-store.js +15 -16
  193. package/{esm → dist}/testing/contract/tenant.js +361 -330
  194. package/{esm → dist}/testing/contract/token-flow-store.d.ts +1 -1
  195. package/{esm → dist}/testing/contract/token-flow-store.js +27 -32
  196. package/{esm → dist}/testing/contract/token-reader.d.ts +3 -3
  197. package/{esm → dist}/testing/contract/token-reader.js +6 -7
  198. package/{esm → dist}/testing/contract/token.d.ts +7 -7
  199. package/{esm → dist}/testing/contract/token.js +48 -53
  200. package/{esm → dist}/testing/contract/user.d.ts +2 -2
  201. package/{esm → dist}/testing/contract/user.js +8 -9
  202. package/{esm → dist}/testing/mod.d.ts +5 -6
  203. package/{esm → dist}/testing/mod.js +2 -3
  204. package/{esm → dist}/testing/server.d.ts +7 -6
  205. package/{esm → dist}/testing/server.js +2 -1
  206. package/{esm → dist}/testing/services.d.ts +11 -11
  207. package/{esm → dist}/testing/services.js +8 -8
  208. package/{esm → dist}/testing/tenant.d.ts +11 -7
  209. package/{esm → dist}/testing/tenant.js +109 -94
  210. package/dist/utils/_constant-time.d.ts +12 -0
  211. package/dist/utils/_constant-time.js +19 -0
  212. package/{esm → dist}/utils/_default-fetch.js +4 -1
  213. package/dist/utils/_delay.d.ts +13 -0
  214. package/dist/utils/_delay.js +28 -0
  215. package/dist/utils/_encoding.d.ts +39 -0
  216. package/dist/utils/_encoding.js +126 -0
  217. package/{esm → dist}/utils/authentication-context.d.ts +1 -1
  218. package/{esm → dist}/utils/crypto.d.ts +2 -3
  219. package/{esm → dist}/utils/crypto.js +3 -4
  220. package/{esm → dist}/utils/pkce.js +1 -1
  221. package/{esm → dist}/utils/text.js +1 -1
  222. package/{esm → dist}/utils/url.d.ts +0 -1
  223. package/{esm → dist}/utils/url.js +0 -1
  224. package/package.json +156 -33
  225. package/esm/_dnt.polyfills.d.ts +0 -31
  226. package/esm/_dnt.polyfills.js +0 -26
  227. package/esm/deps/jsr.io/@std/assert/1.0.19/almost_equals.d.ts +0 -29
  228. package/esm/deps/jsr.io/@std/assert/1.0.19/almost_equals.js +0 -47
  229. package/esm/deps/jsr.io/@std/assert/1.0.19/array_includes.d.ts +0 -28
  230. package/esm/deps/jsr.io/@std/assert/1.0.19/array_includes.js +0 -65
  231. package/esm/deps/jsr.io/@std/assert/1.0.19/assert.d.ts +0 -16
  232. package/esm/deps/jsr.io/@std/assert/1.0.19/assert.js +0 -23
  233. package/esm/deps/jsr.io/@std/assert/1.0.19/assertion_error.d.ts +0 -25
  234. package/esm/deps/jsr.io/@std/assert/1.0.19/assertion_error.js +0 -30
  235. package/esm/deps/jsr.io/@std/assert/1.0.19/equal.d.ts +0 -24
  236. package/esm/deps/jsr.io/@std/assert/1.0.19/equal.js +0 -193
  237. package/esm/deps/jsr.io/@std/assert/1.0.19/equals.d.ts +0 -36
  238. package/esm/deps/jsr.io/@std/assert/1.0.19/equals.js +0 -61
  239. package/esm/deps/jsr.io/@std/assert/1.0.19/exists.d.ts +0 -17
  240. package/esm/deps/jsr.io/@std/assert/1.0.19/exists.js +0 -27
  241. package/esm/deps/jsr.io/@std/assert/1.0.19/fail.d.ts +0 -14
  242. package/esm/deps/jsr.io/@std/assert/1.0.19/fail.js +0 -20
  243. package/esm/deps/jsr.io/@std/assert/1.0.19/false.d.ts +0 -18
  244. package/esm/deps/jsr.io/@std/assert/1.0.19/false.js +0 -23
  245. package/esm/deps/jsr.io/@std/assert/1.0.19/greater.d.ts +0 -19
  246. package/esm/deps/jsr.io/@std/assert/1.0.19/greater.js +0 -29
  247. package/esm/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.d.ts +0 -19
  248. package/esm/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.js +0 -29
  249. package/esm/deps/jsr.io/@std/assert/1.0.19/instance_of.d.ts +0 -22
  250. package/esm/deps/jsr.io/@std/assert/1.0.19/instance_of.js +0 -52
  251. package/esm/deps/jsr.io/@std/assert/1.0.19/is_error.d.ts +0 -24
  252. package/esm/deps/jsr.io/@std/assert/1.0.19/is_error.js +0 -53
  253. package/esm/deps/jsr.io/@std/assert/1.0.19/less.d.ts +0 -18
  254. package/esm/deps/jsr.io/@std/assert/1.0.19/less.js +0 -28
  255. package/esm/deps/jsr.io/@std/assert/1.0.19/less_or_equal.d.ts +0 -19
  256. package/esm/deps/jsr.io/@std/assert/1.0.19/less_or_equal.js +0 -29
  257. package/esm/deps/jsr.io/@std/assert/1.0.19/match.d.ts +0 -17
  258. package/esm/deps/jsr.io/@std/assert/1.0.19/match.js +0 -26
  259. package/esm/deps/jsr.io/@std/assert/1.0.19/mod.d.ts +0 -43
  260. package/esm/deps/jsr.io/@std/assert/1.0.19/mod.js +0 -45
  261. package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.d.ts +0 -26
  262. package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.js +0 -39
  263. package/esm/deps/jsr.io/@std/assert/1.0.19/not_instance_of.d.ts +0 -19
  264. package/esm/deps/jsr.io/@std/assert/1.0.19/not_instance_of.js +0 -29
  265. package/esm/deps/jsr.io/@std/assert/1.0.19/not_match.d.ts +0 -17
  266. package/esm/deps/jsr.io/@std/assert/1.0.19/not_match.js +0 -26
  267. package/esm/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.d.ts +0 -22
  268. package/esm/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.js +0 -32
  269. package/esm/deps/jsr.io/@std/assert/1.0.19/object_match.d.ts +0 -28
  270. package/esm/deps/jsr.io/@std/assert/1.0.19/object_match.js +0 -177
  271. package/esm/deps/jsr.io/@std/assert/1.0.19/rejects.d.ts +0 -41
  272. package/esm/deps/jsr.io/@std/assert/1.0.19/rejects.js +0 -53
  273. package/esm/deps/jsr.io/@std/assert/1.0.19/strict_equals.d.ts +0 -23
  274. package/esm/deps/jsr.io/@std/assert/1.0.19/strict_equals.js +0 -58
  275. package/esm/deps/jsr.io/@std/assert/1.0.19/string_includes.d.ts +0 -17
  276. package/esm/deps/jsr.io/@std/assert/1.0.19/string_includes.js +0 -26
  277. package/esm/deps/jsr.io/@std/assert/1.0.19/throws.d.ts +0 -44
  278. package/esm/deps/jsr.io/@std/assert/1.0.19/throws.js +0 -44
  279. package/esm/deps/jsr.io/@std/assert/1.0.19/unimplemented.d.ts +0 -14
  280. package/esm/deps/jsr.io/@std/assert/1.0.19/unimplemented.js +0 -20
  281. package/esm/deps/jsr.io/@std/assert/1.0.19/unreachable.d.ts +0 -14
  282. package/esm/deps/jsr.io/@std/assert/1.0.19/unreachable.js +0 -20
  283. package/esm/deps/jsr.io/@std/async/1.5.0/delay.d.ts +0 -44
  284. package/esm/deps/jsr.io/@std/async/1.5.0/delay.js +0 -84
  285. package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts +0 -39
  286. package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.js +0 -61
  287. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common16.d.ts +0 -22
  288. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common16.js +0 -51
  289. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common32.d.ts +0 -34
  290. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common32.js +0 -192
  291. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common64.d.ts +0 -34
  292. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common64.js +0 -113
  293. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common_detach.d.ts +0 -3
  294. package/esm/deps/jsr.io/@std/encoding/1.0.11/_common_detach.js +0 -13
  295. package/esm/deps/jsr.io/@std/encoding/1.0.11/_types.d.ts +0 -8
  296. package/esm/deps/jsr.io/@std/encoding/1.0.11/_types.js +0 -2
  297. package/esm/deps/jsr.io/@std/encoding/1.0.11/_validate_binary_like.d.ts +0 -1
  298. package/esm/deps/jsr.io/@std/encoding/1.0.11/_validate_binary_like.js +0 -26
  299. package/esm/deps/jsr.io/@std/encoding/1.0.11/ascii85.d.ts +0 -60
  300. package/esm/deps/jsr.io/@std/encoding/1.0.11/ascii85.js +0 -152
  301. package/esm/deps/jsr.io/@std/encoding/1.0.11/base32.d.ts +0 -39
  302. package/esm/deps/jsr.io/@std/encoding/1.0.11/base32.js +0 -87
  303. package/esm/deps/jsr.io/@std/encoding/1.0.11/base58.d.ts +0 -39
  304. package/esm/deps/jsr.io/@std/encoding/1.0.11/base58.js +0 -131
  305. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64.d.ts +0 -39
  306. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64.js +0 -82
  307. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64url.d.ts +0 -39
  308. package/esm/deps/jsr.io/@std/encoding/1.0.11/base64url.js +0 -72
  309. package/esm/deps/jsr.io/@std/encoding/1.0.11/hex.d.ts +0 -38
  310. package/esm/deps/jsr.io/@std/encoding/1.0.11/hex.js +0 -87
  311. package/esm/deps/jsr.io/@std/encoding/1.0.11/mod.d.ts +0 -97
  312. package/esm/deps/jsr.io/@std/encoding/1.0.11/mod.js +0 -99
  313. package/esm/deps/jsr.io/@std/encoding/1.0.11/varint.d.ts +0 -119
  314. package/esm/deps/jsr.io/@std/encoding/1.0.11/varint.js +0 -209
  315. package/esm/deps/jsr.io/@std/http/1.1.3/status.d.ts +0 -343
  316. package/esm/deps/jsr.io/@std/http/1.1.3/status.js +0 -343
  317. package/esm/deps/jsr.io/@std/internal/1.0.14/assertion_state.d.ts +0 -159
  318. package/esm/deps/jsr.io/@std/internal/1.0.14/assertion_state.js +0 -223
  319. package/esm/deps/jsr.io/@std/internal/1.0.14/build_message.d.ts +0 -79
  320. package/esm/deps/jsr.io/@std/internal/1.0.14/build_message.js +0 -116
  321. package/esm/deps/jsr.io/@std/internal/1.0.14/diff.d.ts +0 -139
  322. package/esm/deps/jsr.io/@std/internal/1.0.14/diff.js +0 -277
  323. package/esm/deps/jsr.io/@std/internal/1.0.14/diff_str.d.ts +0 -98
  324. package/esm/deps/jsr.io/@std/internal/1.0.14/diff_str.js +0 -181
  325. package/esm/deps/jsr.io/@std/internal/1.0.14/format.d.ts +0 -29
  326. package/esm/deps/jsr.io/@std/internal/1.0.14/format.js +0 -68
  327. package/esm/deps/jsr.io/@std/internal/1.0.14/styles.d.ts +0 -158
  328. package/esm/deps/jsr.io/@std/internal/1.0.14/styles.js +0 -206
  329. package/esm/deps/jsr.io/@std/internal/1.0.14/types.d.ts +0 -24
  330. package/esm/deps/jsr.io/@std/internal/1.0.14/types.js +0 -3
  331. package/esm/deps/jsr.io/@std/testing/1.0.20/_test_suite.d.ts +0 -91
  332. package/esm/deps/jsr.io/@std/testing/1.0.20/_test_suite.js +0 -347
  333. package/esm/deps/jsr.io/@std/testing/1.0.20/bdd.d.ts +0 -382
  334. package/esm/deps/jsr.io/@std/testing/1.0.20/bdd.js +0 -1110
  335. package/esm/deps/jsr.io/@udibo/http-error/0.11.1/mod.d.ts +0 -363
  336. package/esm/deps/jsr.io/@udibo/http-error/0.11.1/mod.js +0 -616
  337. package/esm/package.json +0 -3
  338. /package/{esm → dist}/adapters/hono/bff/cookie-prefix.d.ts +0 -0
  339. /package/{esm → dist}/adapters/hono/bff/proxy.d.ts +0 -0
  340. /package/{esm → dist}/client/_http.js +0 -0
  341. /package/{esm → dist}/client/base.js +0 -0
  342. /package/{esm → dist}/client/browser-storage.js +0 -0
  343. /package/{esm → dist}/client/check.d.ts +0 -0
  344. /package/{esm → dist}/client/events.js +0 -0
  345. /package/{esm → dist}/client/storage.d.ts +0 -0
  346. /package/{esm → dist}/client/storage.js +0 -0
  347. /package/{esm → dist}/identity/captcha.d.ts +0 -0
  348. /package/{esm → dist}/identity/captcha.js +0 -0
  349. /package/{esm → dist}/identity/delivery.d.ts +0 -0
  350. /package/{esm → dist}/identity/delivery.js +0 -0
  351. /package/{esm → dist}/identity/errors.d.ts +0 -0
  352. /package/{esm → dist}/identity/errors.js +0 -0
  353. /package/{esm → dist}/identity/events.js +0 -0
  354. /package/{esm → dist}/identity/external/_token-exchange.d.ts +0 -0
  355. /package/{esm → dist}/identity/external/_token-exchange.js +0 -0
  356. /package/{esm → dist}/identity/external/errors.d.ts +0 -0
  357. /package/{esm → dist}/identity/external/errors.js +0 -0
  358. /package/{esm → dist}/identity/external/provider.d.ts +0 -0
  359. /package/{esm → dist}/identity/external/provider.js +0 -0
  360. /package/{esm → dist}/identity/identifier.d.ts +0 -0
  361. /package/{esm → dist}/identity/identifier.js +0 -0
  362. /package/{esm → dist}/identity/lockout.d.ts +0 -0
  363. /package/{esm → dist}/identity/mfa/recovery-codes.d.ts +0 -0
  364. /package/{esm → dist}/identity/mfa/recovery-codes.js +0 -0
  365. /package/{esm → dist}/identity/password-policy.d.ts +0 -0
  366. /package/{esm → dist}/identity/password-policy.js +0 -0
  367. /package/{esm → dist}/identity/password.d.ts +0 -0
  368. /package/{esm → dist}/identity/rate-limit.js +0 -0
  369. /package/{esm → dist}/identity/session.d.ts +0 -0
  370. /package/{esm → dist}/identity/token-flow.d.ts +0 -0
  371. /package/{esm → dist}/models/authentication.d.ts +0 -0
  372. /package/{esm → dist}/models/authentication.js +0 -0
  373. /package/{esm → dist}/models/authorization-code.js +0 -0
  374. /package/{esm → dist}/models/client.d.ts +0 -0
  375. /package/{esm → dist}/models/client.js +0 -0
  376. /package/{esm → dist}/models/device-authorization.js +0 -0
  377. /package/{esm → dist}/models/responses.d.ts +0 -0
  378. /package/{esm → dist}/models/responses.js +0 -0
  379. /package/{esm → dist}/models/scope.d.ts +0 -0
  380. /package/{esm → dist}/models/scope.js +0 -0
  381. /package/{esm → dist}/models/token.js +0 -0
  382. /package/{esm → dist}/react/components/types.js +0 -0
  383. /package/{esm → dist}/react/context.js +0 -0
  384. /package/{esm → dist}/react/provider.js +0 -0
  385. /package/{esm → dist}/react/require-auth.d.ts +0 -0
  386. /package/{esm → dist}/react/use-authorization.js +0 -0
  387. /package/{esm → dist}/server/_clock-skew.d.ts +0 -0
  388. /package/{esm → dist}/server/client-authentication.js +0 -0
  389. /package/{esm → dist}/server/grants/client-credentials.js +0 -0
  390. /package/{esm → dist}/server/grants/password.js +0 -0
  391. /package/{esm → dist}/server/redirect-uri.d.ts +0 -0
  392. /package/{esm → dist}/server/services/authorization-code.js +0 -0
  393. /package/{esm → dist}/server/services/client.js +0 -0
  394. /package/{esm → dist}/server/services/device-authorization.js +0 -0
  395. /package/{esm → dist}/server/services/user.js +0 -0
  396. /package/{esm → dist}/server/utils/hash.d.ts +0 -0
  397. /package/{esm → dist}/testing/contract/_race.d.ts +0 -0
  398. /package/{esm → dist}/testing/contract/_race.js +0 -0
  399. /package/{esm → dist}/testing/contract/tenant.d.ts +0 -0
  400. /package/{esm → dist}/utils/_body.d.ts +0 -0
  401. /package/{esm → dist}/utils/_body.js +0 -0
  402. /package/{esm → dist}/utils/_buffer.d.ts +0 -0
  403. /package/{esm → dist}/utils/_buffer.js +0 -0
  404. /package/{esm → dist}/utils/_default-fetch.d.ts +0 -0
  405. /package/{esm → dist}/utils/_timing-safe.d.ts +0 -0
  406. /package/{esm → dist}/utils/_timing-safe.js +0 -0
  407. /package/{esm → dist}/utils/authentication-context.js +0 -0
  408. /package/{esm → dist}/utils/basic-auth.d.ts +0 -0
  409. /package/{esm → dist}/utils/basic-auth.js +0 -0
  410. /package/{esm → dist}/utils/pkce.d.ts +0 -0
  411. /package/{esm → dist}/utils/text.d.ts +0 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Command table for the `udibo-oauth2` executable: the one-off operator
3
+ * commands a deployment needs, so generating key material never means pasting
4
+ * a scratch script into a terminal.
5
+ *
6
+ * ```sh
7
+ * npx udibo-oauth2 oidc keygen
8
+ * npx udibo-oauth2 idp dev
9
+ * ```
10
+ *
11
+ * No command writes to disk. `idp dev` serves a socket and reads its config
12
+ * file and `OIDC_SIGNING_KEY` from the environment.
13
+ *
14
+ * @module
15
+ */
16
+ import { idpDev } from "./idp/mod.js";
17
+ import { oidcKeygen } from "./keygen.js";
18
+ const commands = new Map([
19
+ [
20
+ "oidc keygen",
21
+ {
22
+ summary: "Generate an ES256 OIDC signing key for OIDC_SIGNING_KEY.",
23
+ run: oidcKeygen,
24
+ },
25
+ ],
26
+ [
27
+ "idp dev",
28
+ {
29
+ summary: "Run a local identity provider for development and CI.",
30
+ run: idpDev,
31
+ },
32
+ ],
33
+ ]);
34
+ function usage() {
35
+ const width = Math.max(...commands.keys().map((name) => name.length));
36
+ return [
37
+ "@udibo/oauth2 — operator commands for OAuth2/OIDC deployments.",
38
+ "",
39
+ "Usage:",
40
+ " udibo-oauth2 <command>",
41
+ "",
42
+ "Commands:",
43
+ ...commands
44
+ .entries()
45
+ .map(([name, { summary }]) => ` ${name.padEnd(width)} ${summary}`),
46
+ "",
47
+ "Options:",
48
+ ` ${"-h, --help".padEnd(width)} Show this help.`,
49
+ ].join("\n");
50
+ }
51
+ function matchCommand(args) {
52
+ for (const depth of [2, 1]) {
53
+ const command = commands.get(args.slice(0, depth).join(" "));
54
+ if (command)
55
+ return { command, args: args.slice(depth) };
56
+ }
57
+ return undefined;
58
+ }
59
+ /**
60
+ * Runs one CLI invocation and resolves with the exit code the process should
61
+ * use: `0` when the command succeeded or help was requested, `1` for no
62
+ * command, an unknown command, a bad argument, or a command failure.
63
+ *
64
+ * Help text and development-provider banners use stdout. Missing or unknown
65
+ * commands and command failures report on stderr. Successful `oidc keygen`
66
+ * without help writes one JWK line on stdout and guidance on stderr. Use that
67
+ * exact invocation and check its exit code before storing stdout as a secret.
68
+ *
69
+ * The `udibo-oauth2` executable calls this with `process.argv.slice(2)` and
70
+ * sets `process.exitCode` to the result.
71
+ */
72
+ export async function runCli(args, options = {}) {
73
+ if (args.length === 0) {
74
+ console.error(usage());
75
+ return 1;
76
+ }
77
+ if (args.includes("--help") || args.includes("-h")) {
78
+ console.log(usage());
79
+ return 0;
80
+ }
81
+ const match = matchCommand(args);
82
+ if (!match) {
83
+ console.error(`error: unknown command "${args.join(" ")}"\n\n${usage()}`);
84
+ return 1;
85
+ }
86
+ try {
87
+ await match.command.run(match.args, options.signal);
88
+ return 0;
89
+ }
90
+ catch (error) {
91
+ console.error(`error: ${error instanceof Error ? error.message : String(error)}`);
92
+ return 1;
93
+ }
94
+ }
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import { type OAuth2Error } from "../errors.js";
9
+ import { type OAuth2Error } from "../errors.ts";
10
10
  /** Response bytes accepted from an endpoint before the call is refused. */
11
11
  export declare const MAX_RESPONSE_BYTES: number;
12
12
  /** Wall-clock budget for one call, covering the connect and the body read. */
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @module
13
13
  */
14
- import { type OAuth2ClientEvent, type OAuth2ClientEventListener } from "./events.js";
14
+ import { type OAuth2ClientEvent, type OAuth2ClientEventListener } from "./events.ts";
15
15
  /** Generic user-info claims returned by the userinfo or `id_token` helpers. */
16
16
  export type UserInfoClaims = Record<string, unknown>;
17
17
  /**
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @module
10
10
  */
11
- import { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.js";
11
+ import { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.ts";
12
12
  /** Paths (or absolute URLs) for the BFF session endpoints. */
13
13
  export interface BffEndpoints {
14
14
  /** Base URL the BFF is mounted under (e.g. `""` for same-origin). */
@@ -67,14 +67,15 @@ export class BffClient extends OAuth2ClientBase {
67
67
  session: endpoints.session ?? "/auth/session",
68
68
  };
69
69
  this.#authorizePath = options.authorizePath;
70
- this.#csrfHeader = options.csrfHeader === false ? {} : {
71
- [options.csrfHeader?.name ?? "x-csrf"]: options.csrfHeader?.value ?? "1",
72
- };
70
+ this.#csrfHeader =
71
+ options.csrfHeader === false
72
+ ? {}
73
+ : {
74
+ [options.csrfHeader?.name ?? "x-csrf"]: options.csrfHeader?.value ?? "1",
75
+ };
73
76
  }
74
77
  #url(path) {
75
- const origin = typeof location !== "undefined"
76
- ? location.origin
77
- : "http://localhost";
78
+ const origin = typeof location !== "undefined" ? location.origin : "http://localhost";
78
79
  return new URL(`${this.#endpoints.baseUrl}${path}`, origin).toString();
79
80
  }
80
81
  /**
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @module
11
11
  */
12
- import type { AuthRequestRecord, AuthRequestStorage, RefreshTokenStorage } from "./storage.js";
12
+ import type { AuthRequestRecord, AuthRequestStorage, RefreshTokenStorage } from "./storage.ts";
13
13
  /** Options for {@link IndexedDBRefreshTokenStorage}. */
14
14
  export interface IndexedDBRefreshTokenStorageOptions {
15
15
  /**
@@ -94,5 +94,5 @@ export async function checkPermissions(options) {
94
94
  await response.body?.cancel();
95
95
  throw new ServerError(`check request refused: ${response.status}`);
96
96
  }
97
- return await receiveJson(response, CHECK_ENDPOINT);
97
+ return (await receiveJson(response, CHECK_ENDPOINT));
98
98
  }
@@ -10,11 +10,11 @@
10
10
  *
11
11
  * @module
12
12
  */
13
- import type { AuthorizationServerMetadata, DeviceAuthorizationResponse } from "../models/responses.js";
14
- import type { IntrospectionResponse, TokenResponse } from "../models/token.js";
15
- import { type BaseLoginOptions, type BaseOptions, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.js";
16
- import { type DiscoveryCache } from "./discovery-cache.js";
17
- import { type AuthRequestStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage } from "./storage.js";
13
+ import type { AuthorizationServerMetadata, DeviceAuthorizationResponse } from "../models/responses.ts";
14
+ import type { IntrospectionResponse, TokenResponse } from "../models/token.ts";
15
+ import { type BaseLoginOptions, type BaseOptions, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.ts";
16
+ import { type DiscoveryCache } from "./discovery-cache.ts";
17
+ import { type AuthRequestStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage } from "./storage.ts";
18
18
  /** Endpoints resolved via discovery or provided explicitly by the caller. */
19
19
  export interface AuthorizationServerEndpoints {
20
20
  /** URL of the authorization endpoint (required for the auth-code flow). */
@@ -236,7 +236,7 @@ export interface ExchangeResult {
236
236
  *
237
237
  * const client = new DirectClient({
238
238
  * clientId: "worker",
239
- * clientSecret: Deno.env.get("CLIENT_SECRET")!,
239
+ * clientSecret: process.env.CLIENT_SECRET!,
240
240
  * endpoints: { token: "https://auth.example.com/token" },
241
241
  * });
242
242
  *
@@ -10,11 +10,11 @@
10
10
  *
11
11
  * @module
12
12
  */
13
- import { delay } from "../deps/jsr.io/@std/async/1.5.0/delay.js";
14
13
  import { AccessDeniedError, InvalidGrantError, isOAuth2Error, OAuth2Error as OAuth2ErrorClass, ServerError, } from "../errors.js";
15
14
  import { challengeMethods, generateCodeVerifier, generateState, } from "../utils/pkce.js";
16
15
  import { encodeBasicAuth } from "../utils/basic-auth.js";
17
16
  import { base64urlDecode } from "../utils/crypto.js";
17
+ import { delay } from "../utils/_delay.js";
18
18
  import { sanitizeProviderText } from "../utils/text.js";
19
19
  import { assertField, assertTokenResponse, errorFromResponse, receiveJson, sendGuarded, } from "./_http.js";
20
20
  import { mergedHeaders, OAuth2ClientBase, SIGNED_OUT, } from "./base.js";
@@ -66,7 +66,7 @@ const REFRESH_SKEW_MS = 30_000;
66
66
  *
67
67
  * const client = new DirectClient({
68
68
  * clientId: "worker",
69
- * clientSecret: Deno.env.get("CLIENT_SECRET")!,
69
+ * clientSecret: process.env.CLIENT_SECRET!,
70
70
  * endpoints: { token: "https://auth.example.com/token" },
71
71
  * });
72
72
  *
@@ -119,11 +119,12 @@ export class DirectClient extends OAuth2ClientBase {
119
119
  this.#discoveryCache = options.discoveryCache;
120
120
  this.#endpoints = { ...options.endpoints };
121
121
  this.#tokenStorage = options.tokenStorage ?? new MemoryTokenStorage();
122
- this.#refreshTokenStorage = options.refreshTokenStorage ??
123
- new MemoryRefreshTokenStorage();
122
+ this.#refreshTokenStorage =
123
+ options.refreshTokenStorage ?? new MemoryRefreshTokenStorage();
124
124
  this.#authRequestTtlMs = options.authRequestTtlMs ?? 10 * 60 * 1000;
125
- this.#authRequestStorage = options.authRequestStorage ??
126
- defaultAuthRequestStorage(this.#authRequestTtlMs);
125
+ this.#authRequestStorage =
126
+ options.authRequestStorage ??
127
+ defaultAuthRequestStorage(this.#authRequestTtlMs);
127
128
  }
128
129
  /** True when the client was given a secret and authenticates via Basic. */
129
130
  get isConfidential() {
@@ -335,8 +336,7 @@ export class DirectClient extends OAuth2ClientBase {
335
336
  const codeVerifier = generateCodeVerifier();
336
337
  const codeChallenge = await challengeMethods.S256(codeVerifier);
337
338
  const scope = options.scope ?? this.#scope;
338
- const authRequestStorage = options.authRequestStorage ??
339
- this.#authRequestStorage;
339
+ const authRequestStorage = options.authRequestStorage ?? this.#authRequestStorage;
340
340
  await authRequestStorage.set(state, {
341
341
  codeVerifier,
342
342
  returnTo: options.returnTo,
@@ -463,8 +463,7 @@ export class DirectClient extends OAuth2ClientBase {
463
463
  * `cause` is the transport failure.
464
464
  */
465
465
  async exchangeAuthorizationCode(code, state, options = {}) {
466
- const authRequestStorage = options.authRequestStorage ??
467
- this.#authRequestStorage;
466
+ const authRequestStorage = options.authRequestStorage ?? this.#authRequestStorage;
468
467
  const record = await claimAuthRequest(authRequestStorage, state);
469
468
  if (!record)
470
469
  throw new InvalidGrantError("unknown state parameter");
@@ -609,7 +608,7 @@ export class DirectClient extends OAuth2ClientBase {
609
608
  }
610
609
  async #doRefresh(reportTransient, snapshot) {
611
610
  const { version, refreshToken } = await this.#mutateSession(async () => {
612
- const version = snapshot.version = this.#sessionVersion;
611
+ const version = (snapshot.version = this.#sessionVersion);
613
612
  return {
614
613
  version,
615
614
  refreshToken: await this.#readRefreshToken(reportTransient),
@@ -1221,8 +1220,7 @@ function toSearchParams(input) {
1221
1220
  }
1222
1221
  }
1223
1222
  function defaultAuthRequestStorage(ttlMs) {
1224
- const inBrowserDocument = typeof document !== "undefined" &&
1225
- typeof sessionStorage !== "undefined";
1223
+ const inBrowserDocument = typeof document !== "undefined" && typeof sessionStorage !== "undefined";
1226
1224
  return inBrowserDocument
1227
1225
  ? new SessionStorageAuthRequestStorage({ ttlMs })
1228
1226
  : new MemoryAuthRequestStorage({ ttlMs });
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @module
6
6
  */
7
- import type { AuthorizationServerMetadata } from "../models/responses.js";
7
+ import type { AuthorizationServerMetadata } from "../models/responses.ts";
8
8
  /**
9
9
  * Default discovery-document lifetime, one hour: the TTL of a
10
10
  * {@link MemoryDiscoveryCache}, and how long a `DirectClient` without a
@@ -47,8 +47,8 @@ export class MemoryDiscoveryCache {
47
47
  /** Creates a cache with the given TTL and entry ceiling. */
48
48
  constructor(options = {}) {
49
49
  this.#ttlMs = options.ttlMs ?? DEFAULT_DISCOVERY_TTL_MS;
50
- this.#maxEntries = options.maxEntries ??
51
- DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES;
50
+ this.#maxEntries =
51
+ options.maxEntries ?? DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES;
52
52
  }
53
53
  /**
54
54
  * Returns the fresh cached entry for `issuer`, joins the in-flight `load`
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import type { TokenBundle } from "./storage.js";
9
+ import type { TokenBundle } from "./storage.ts";
10
10
  /** The authenticated user has been resolved or has changed. */
11
11
  export interface AuthenticatedEvent {
12
12
  /** Discriminant tag for this event variant. */
@@ -23,15 +23,14 @@
23
23
  *
24
24
  * @module
25
25
  */
26
- import "../_dnt.polyfills.js";
27
- export { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, SIGNED_OUT, type UserInfoClaims, } from "./base.js";
28
- export { BffClient, type BffClientOptions, type BffEndpoints, } from "./bff-client.js";
29
- export { type AuthorizationCallbackResult, type AuthorizationRedirect, type AuthorizationServerEndpoints, type DeviceAuthorizationOptions, DirectClient, type DirectClientOptions, type ExchangeOptions, type ExchangeResult, type IntrospectionResult, type LoginOptions, type PollDeviceTokenOptions, } from "./direct-client.js";
30
- export { DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES, DEFAULT_DISCOVERY_TTL_MS, type DiscoveryCache, type DiscoveryCacheEntry, MemoryDiscoveryCache, type MemoryDiscoveryCacheOptions, } from "./discovery-cache.js";
31
- export { type AuthenticatedEvent, type ErrorEvent, type LoggedOutEvent, type OAuth2ClientEvent, type OAuth2ClientEventListener, type TokenRefreshedEvent, } from "./events.js";
32
- export { type AuthRequestRecord, type AuthRequestStorage, MemoryAuthRequestStorage, type MemoryAuthRequestStorageOptions, MemoryRefreshTokenStorage, MemoryTokenStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage, } from "./storage.js";
33
- export { checkPermissions, type CheckPermissionsOptions, type CheckPermissionsResult, type CheckResource, } from "./check.js";
34
- export { Authorization, authorizationFromClaims, } from "../models/authorization.js";
35
- export type { OrganizationContext } from "../models/authorization.js";
36
- export { isOAuth2Error, OAuth2Error } from "../errors.js";
37
- export { IndexedDBRefreshTokenStorage, type IndexedDBRefreshTokenStorageOptions, SessionStorageAuthRequestStorage, type SessionStorageAuthRequestStorageOptions, } from "./browser-storage.js";
26
+ export { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, SIGNED_OUT, type UserInfoClaims, } from "./base.ts";
27
+ export { BffClient, type BffClientOptions, type BffEndpoints, } from "./bff-client.ts";
28
+ export { type AuthorizationCallbackResult, type AuthorizationRedirect, type AuthorizationServerEndpoints, type DeviceAuthorizationOptions, DirectClient, type DirectClientOptions, type ExchangeOptions, type ExchangeResult, type IntrospectionResult, type LoginOptions, type PollDeviceTokenOptions, } from "./direct-client.ts";
29
+ export { DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES, DEFAULT_DISCOVERY_TTL_MS, type DiscoveryCache, type DiscoveryCacheEntry, MemoryDiscoveryCache, type MemoryDiscoveryCacheOptions, } from "./discovery-cache.ts";
30
+ export { type AuthenticatedEvent, type ErrorEvent, type LoggedOutEvent, type OAuth2ClientEvent, type OAuth2ClientEventListener, type TokenRefreshedEvent, } from "./events.ts";
31
+ export { type AuthRequestRecord, type AuthRequestStorage, MemoryAuthRequestStorage, type MemoryAuthRequestStorageOptions, MemoryRefreshTokenStorage, MemoryTokenStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage, } from "./storage.ts";
32
+ export { checkPermissions, type CheckPermissionsOptions, type CheckPermissionsResult, type CheckResource, } from "./check.ts";
33
+ export { Authorization, authorizationFromClaims, } from "../models/authorization.ts";
34
+ export type { OrganizationContext } from "../models/authorization.ts";
35
+ export { isOAuth2Error, OAuth2Error } from "../errors.ts";
36
+ export { IndexedDBRefreshTokenStorage, type IndexedDBRefreshTokenStorageOptions, SessionStorageAuthRequestStorage, type SessionStorageAuthRequestStorageOptions, } from "./browser-storage.ts";
@@ -23,11 +23,11 @@
23
23
  *
24
24
  * @module
25
25
  */
26
- import "../_dnt.polyfills.js";
27
26
  export { OAuth2ClientBase, SIGNED_OUT, } from "./base.js";
28
27
  export { BffClient, } from "./bff-client.js";
29
28
  export { DirectClient, } from "./direct-client.js";
30
29
  export { DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES, DEFAULT_DISCOVERY_TTL_MS, MemoryDiscoveryCache, } from "./discovery-cache.js";
30
+ export {} from "./events.js";
31
31
  export { MemoryAuthRequestStorage, MemoryRefreshTokenStorage, MemoryTokenStorage, } from "./storage.js";
32
32
  export { checkPermissions, } from "./check.js";
33
33
  export { Authorization, authorizationFromClaims, } from "../models/authorization.js";
@@ -11,7 +11,7 @@
11
11
  * @see https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
12
12
  * @module
13
13
  */
14
- import { HttpError, type HttpErrorOptions } from "./deps/jsr.io/@udibo/http-error/0.11.1/mod.js";
14
+ import { HttpError, type HttpErrorOptions } from "@udibo/http-error";
15
15
  /**
16
16
  * Problem Details extension members carried by every {@linkcode OAuth2Error}.
17
17
  *
@@ -11,7 +11,7 @@
11
11
  * @see https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
12
12
  * @module
13
13
  */
14
- import { createHttpErrorClass, HttpError, } from "./deps/jsr.io/@udibo/http-error/0.11.1/mod.js";
14
+ import { createHttpErrorClass, HttpError, } from "@udibo/http-error";
15
15
  /**
16
16
  * The base OAuth2 error class, an {@linkcode HttpError} subclass that defaults
17
17
  * to the `server_error` code. Used as a catch-all and as the value-side
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * @module
26
26
  */
27
- import type { DeliveryHooks } from "./delivery.js";
27
+ import type { DeliveryHooks } from "./delivery.ts";
28
28
  /** Why a sign-in attempt failed. Internal detail — never shown to the user. */
29
29
  export type SignInFailureReason = "unknown_identifier" | "no_password" | "wrong_password";
30
30
  /**
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @module
10
10
  */
11
- import { PROVIDER_TEXT_MAX_LENGTH, sanitizeProviderText } from "../../utils/text.js";
11
+ import { PROVIDER_TEXT_MAX_LENGTH, sanitizeProviderText } from "../../utils/text.ts";
12
12
  export { PROVIDER_TEXT_MAX_LENGTH, sanitizeProviderText };
13
13
  /**
14
14
  * Clock-skew allowance, in seconds, when checking an id_token's `exp` claim.
@@ -75,8 +75,7 @@ export function assertIdTokenClaims(input) {
75
75
  `configured issuer points at a proxy or the wrong tenant.`);
76
76
  }
77
77
  const aud = claims.aud;
78
- const audienceOk = aud === clientId ||
79
- (Array.isArray(aud) && aud.includes(clientId));
78
+ const audienceOk = aud === clientId || (Array.isArray(aud) && aud.includes(clientId));
80
79
  if (!audienceOk) {
81
80
  throw new ExternalAuthError(provider, "provider_error", `id_token "aud" (${JSON.stringify(aud)}) does not include clientId ` +
82
81
  `"${clientId}" — the token was issued to a different client ` +
@@ -63,7 +63,7 @@ export interface AppleClientSecretOptions {
63
63
  * teamId: "ABCDE12345",
64
64
  * keyId: "KEY1234567",
65
65
  * clientId: "com.example.web",
66
- * privateKey: Deno.env.get("APPLE_PRIVATE_KEY")!,
66
+ * privateKey: process.env.APPLE_PRIVATE_KEY!,
67
67
  * });
68
68
  * ```
69
69
  */
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import { decodeBase64 } from "../../deps/jsr.io/@std/encoding/1.0.11/base64.js";
10
9
  import { toArrayBuffer } from "../../utils/_buffer.js";
10
+ import { decodeBase64 } from "../../utils/_encoding.js";
11
11
  import { base64urlEncode } from "../../utils/crypto.js";
12
12
  import { ExternalAuthError } from "./errors.js";
13
13
  /** Apple's audience for the client-secret JWT. */
@@ -76,7 +76,7 @@ async function importPrivateKey(providerId, pem) {
76
76
  * teamId: "ABCDE12345",
77
77
  * keyId: "KEY1234567",
78
78
  * clientId: "com.example.web",
79
- * privateKey: Deno.env.get("APPLE_PRIVATE_KEY")!,
79
+ * privateKey: process.env.APPLE_PRIVATE_KEY!,
80
80
  * });
81
81
  * ```
82
82
  */
@@ -85,9 +85,9 @@ export async function generateAppleClientSecret(options) {
85
85
  const teamId = requireNonEmpty(providerId, options.teamId, "team id");
86
86
  const keyId = requireNonEmpty(providerId, options.keyId, "key id");
87
87
  const clientId = requireNonEmpty(providerId, options.clientId, "client id (Services ID)");
88
- const ttl = options.expiresInSeconds ??
89
- DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
90
- if (!Number.isFinite(ttl) || ttl <= 0 ||
88
+ const ttl = options.expiresInSeconds ?? DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
89
+ if (!Number.isFinite(ttl) ||
90
+ ttl <= 0 ||
91
91
  ttl > APPLE_CLIENT_SECRET_MAX_TTL_SECONDS) {
92
92
  throw configError(providerId, `Apple client secret TTL must be between 1 and ` +
93
93
  `${APPLE_CLIENT_SECRET_MAX_TTL_SECONDS} seconds (6 months); ` +
@@ -120,8 +120,7 @@ function encodeSegment(value) {
120
120
  * {@link ExternalAuthError}; a failed call caches nothing.
121
121
  */
122
122
  export function createAppleClientSecretFactory(options) {
123
- const ttl = options.expiresInSeconds ??
124
- DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
123
+ const ttl = options.expiresInSeconds ?? DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
125
124
  const renewBefore = options.renewBeforeSeconds ?? 60 * 60;
126
125
  let cached = null;
127
126
  return async () => {
@@ -15,8 +15,8 @@
15
15
  *
16
16
  * @module
17
17
  */
18
- import { type AppleClientSecretFactory, type AppleClientSecretOptions } from "./apple-client-secret.js";
19
- import type { ExternalProvider } from "./provider.js";
18
+ import { type AppleClientSecretFactory, type AppleClientSecretOptions } from "./apple-client-secret.ts";
19
+ import type { ExternalProvider } from "./provider.ts";
20
20
  /** Options for {@link appleProvider}. */
21
21
  export interface AppleProviderOptions extends Pick<AppleClientSecretOptions, "teamId" | "keyId" | "privateKey"> {
22
22
  /** The Services ID configured for web Sign in with Apple (the `client_id`). */
@@ -61,9 +61,9 @@ export interface AppleProviderOptions extends Pick<AppleClientSecretOptions, "te
61
61
  * const flow = new ExternalAuthFlow({
62
62
  * provider: appleProvider({
63
63
  * clientId: "com.example.web",
64
- * teamId: Deno.env.get("APPLE_TEAM_ID")!,
65
- * keyId: Deno.env.get("APPLE_KEY_ID")!,
66
- * privateKey: Deno.env.get("APPLE_PRIVATE_KEY")!,
64
+ * teamId: process.env.APPLE_TEAM_ID!,
65
+ * keyId: process.env.APPLE_KEY_ID!,
66
+ * privateKey: process.env.APPLE_PRIVATE_KEY!,
67
67
  * }),
68
68
  * });
69
69
  * ```
@@ -52,9 +52,9 @@ const SIGNATURE_NOT_VERIFIED = `Apple id_token signature did not verify against
52
52
  * const flow = new ExternalAuthFlow({
53
53
  * provider: appleProvider({
54
54
  * clientId: "com.example.web",
55
- * teamId: Deno.env.get("APPLE_TEAM_ID")!,
56
- * keyId: Deno.env.get("APPLE_KEY_ID")!,
57
- * privateKey: Deno.env.get("APPLE_PRIVATE_KEY")!,
55
+ * teamId: process.env.APPLE_TEAM_ID!,
56
+ * keyId: process.env.APPLE_KEY_ID!,
57
+ * privateKey: process.env.APPLE_PRIVATE_KEY!,
58
58
  * }),
59
59
  * });
60
60
  * ```
@@ -178,8 +178,7 @@ export function appleProvider(options) {
178
178
  match = pick(await loadJwks());
179
179
  }
180
180
  if (!match) {
181
- throw new ExternalAuthError(id, "provider_error", `Apple's JWKS has no key with kid "${String(kid)}" — the id_token was ` +
182
- `signed by a key Apple no longer publishes.`);
181
+ throw new ExternalAuthError(id, "provider_error", `Apple's JWKS has no key with kid "${String(kid)}" — the id_token was ` + `signed by a key Apple no longer publishes.`);
183
182
  }
184
183
  return match;
185
184
  }
@@ -231,16 +230,16 @@ function appleTokenErrorHint(error) {
231
230
  return `Ensure the sign-in requested the "openid" flow scopes.`;
232
231
  }
233
232
  if (error === "invalid_client") {
234
- return `The client-secret JWT is wrong — check the team id, key id, and ` +
235
- `Services ID (client id).`;
233
+ return (`The client-secret JWT is wrong — check the team id, key id, and ` +
234
+ `Services ID (client id).`);
236
235
  }
237
236
  if (error === "invalid_grant") {
238
- return `Apple rejected the code — it expired, was already used, or the ` +
237
+ return (`Apple rejected the code — it expired, was already used, or the ` +
239
238
  `redirect URI does not match the Services ID configuration. Ask the ` +
240
- `user to start again.`;
239
+ `user to start again.`);
241
240
  }
242
- return `See Apple's "Generate and validate tokens" documentation for the ` +
243
- `error's meaning.`;
241
+ return (`See Apple's "Generate and validate tokens" documentation for the ` +
242
+ `error's meaning.`);
244
243
  }
245
244
  function decodeJson(providerId, segment, what) {
246
245
  try {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import type { ExternalProvider } from "./provider.js";
6
+ import type { ExternalProvider } from "./provider.ts";
7
7
  /** Options for {@link discordProvider}. */
8
8
  export interface DiscordProviderOptions {
9
9
  /** Client ID of the Discord application (OAuth2 tab). */
@@ -33,8 +33,8 @@ export interface DiscordProviderOptions {
33
33
  * ```ts
34
34
  * const flow = new ExternalAuthFlow({
35
35
  * provider: discordProvider({
36
- * clientId: Deno.env.get("DISCORD_CLIENT_ID")!,
37
- * clientSecret: Deno.env.get("DISCORD_CLIENT_SECRET")!,
36
+ * clientId: process.env.DISCORD_CLIENT_ID!,
37
+ * clientSecret: process.env.DISCORD_CLIENT_SECRET!,
38
38
  * }),
39
39
  * });
40
40
  * ```
@@ -30,8 +30,8 @@ function avatarUrl(user) {
30
30
  * ```ts
31
31
  * const flow = new ExternalAuthFlow({
32
32
  * provider: discordProvider({
33
- * clientId: Deno.env.get("DISCORD_CLIENT_ID")!,
34
- * clientSecret: Deno.env.get("DISCORD_CLIENT_SECRET")!,
33
+ * clientId: process.env.DISCORD_CLIENT_ID!,
34
+ * clientSecret: process.env.DISCORD_CLIENT_SECRET!,
35
35
  * }),
36
36
  * });
37
37
  * ```
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import type { ExternalAuthTransient, ExternalProfile, ExternalProvider } from "./provider.js";
9
+ import type { ExternalAuthTransient, ExternalProfile, ExternalProvider } from "./provider.ts";
10
10
  /** Default {@link ExternalAuthFlowOptions.maxTransientAgeMs}: 10 minutes. */
11
11
  export declare const DEFAULT_MAX_TRANSIENT_AGE_MS: number;
12
12
  /** Options for {@link ExternalAuthFlow}. */
@@ -48,8 +48,8 @@ export class ExternalAuthFlow {
48
48
  /** Creates a flow for one configured provider. */
49
49
  constructor(options) {
50
50
  this.provider = options.provider;
51
- this.#maxTransientAgeMs = options.maxTransientAgeMs ??
52
- DEFAULT_MAX_TRANSIENT_AGE_MS;
51
+ this.#maxTransientAgeMs =
52
+ options.maxTransientAgeMs ?? DEFAULT_MAX_TRANSIENT_AGE_MS;
53
53
  }
54
54
  /**
55
55
  * Begins a sign-in attempt: generates the per-attempt `state` (plus a PKCE
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @module
6
6
  */
7
- import type { ExternalProvider } from "./provider.js";
7
+ import type { ExternalProvider } from "./provider.ts";
8
8
  /** Options for {@link githubProvider}. */
9
9
  export interface GithubProviderOptions {
10
10
  /** Client ID of the GitHub OAuth App (or GitHub App). */
@@ -37,8 +37,8 @@ export interface GithubProviderOptions {
37
37
  * ```ts
38
38
  * const flow = new ExternalAuthFlow({
39
39
  * provider: githubProvider({
40
- * clientId: Deno.env.get("GITHUB_CLIENT_ID")!,
41
- * clientSecret: Deno.env.get("GITHUB_CLIENT_SECRET")!,
40
+ * clientId: process.env.GITHUB_CLIENT_ID!,
41
+ * clientSecret: process.env.GITHUB_CLIENT_SECRET!,
42
42
  * }),
43
43
  * });
44
44
  * ```