@atproto/oauth-provider 0.19.9 → 0.20.1

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 (308) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/account/account-manager.d.ts +11 -11
  3. package/dist/account/account-manager.d.ts.map +1 -1
  4. package/dist/account/account-manager.js.map +1 -1
  5. package/dist/account/account-store.d.ts +5 -10
  6. package/dist/account/account-store.d.ts.map +1 -1
  7. package/dist/account/account-store.js +0 -5
  8. package/dist/account/account-store.js.map +1 -1
  9. package/dist/client/client-auth.d.ts +1 -1
  10. package/dist/client/client-auth.d.ts.map +1 -1
  11. package/dist/client/client-auth.js.map +1 -1
  12. package/dist/client/client-data.d.ts +2 -2
  13. package/dist/client/client-data.d.ts.map +1 -1
  14. package/dist/client/client-data.js.map +1 -1
  15. package/dist/client/client-id.d.ts +1 -1
  16. package/dist/client/client-id.d.ts.map +1 -1
  17. package/dist/client/client-id.js.map +1 -1
  18. package/dist/client/client-manager.d.ts +8 -8
  19. package/dist/client/client-manager.d.ts.map +1 -1
  20. package/dist/client/client-manager.js +1 -1
  21. package/dist/client/client-manager.js.map +1 -1
  22. package/dist/client/client-store.d.ts +4 -6
  23. package/dist/client/client-store.d.ts.map +1 -1
  24. package/dist/client/client-store.js +0 -3
  25. package/dist/client/client-store.js.map +1 -1
  26. package/dist/client/client-utils.d.ts +1 -1
  27. package/dist/client/client-utils.d.ts.map +1 -1
  28. package/dist/client/client-utils.js.map +1 -1
  29. package/dist/client/client.d.ts +6 -6
  30. package/dist/client/client.d.ts.map +1 -1
  31. package/dist/client/client.js +1 -1
  32. package/dist/client/client.js.map +1 -1
  33. package/dist/customization/branding.d.ts +1 -1
  34. package/dist/customization/branding.d.ts.map +1 -1
  35. package/dist/customization/branding.js.map +1 -1
  36. package/dist/customization/build-customization-css.d.ts +1 -1
  37. package/dist/customization/build-customization-css.d.ts.map +1 -1
  38. package/dist/customization/build-customization-css.js.map +1 -1
  39. package/dist/customization/customization.d.ts +1 -1
  40. package/dist/customization/customization.d.ts.map +1 -1
  41. package/dist/customization/customization.js.map +1 -1
  42. package/dist/device/device-data.d.ts +2 -0
  43. package/dist/device/device-data.d.ts.map +1 -1
  44. package/dist/device/device-data.js.map +1 -1
  45. package/dist/device/device-id.js +1 -1
  46. package/dist/device/device-id.js.map +1 -1
  47. package/dist/device/device-manager.d.ts +3 -3
  48. package/dist/device/device-manager.d.ts.map +1 -1
  49. package/dist/device/device-manager.js +1 -1
  50. package/dist/device/device-manager.js.map +1 -1
  51. package/dist/device/device-store.d.ts +5 -7
  52. package/dist/device/device-store.d.ts.map +1 -1
  53. package/dist/device/device-store.js +0 -4
  54. package/dist/device/device-store.js.map +1 -1
  55. package/dist/device/session-id.d.ts.map +1 -1
  56. package/dist/device/session-id.js +1 -1
  57. package/dist/device/session-id.js.map +1 -1
  58. package/dist/dpop/dpop-manager.d.ts +2 -2
  59. package/dist/dpop/dpop-manager.d.ts.map +1 -1
  60. package/dist/dpop/dpop-manager.js +1 -1
  61. package/dist/dpop/dpop-manager.js.map +1 -1
  62. package/dist/dpop/dpop-nonce.js +1 -1
  63. package/dist/dpop/dpop-nonce.js.map +1 -1
  64. package/dist/errors/access-denied-error.d.ts +1 -1
  65. package/dist/errors/access-denied-error.d.ts.map +1 -1
  66. package/dist/errors/access-denied-error.js.map +1 -1
  67. package/dist/errors/account-selection-required-error.d.ts +1 -1
  68. package/dist/errors/account-selection-required-error.d.ts.map +1 -1
  69. package/dist/errors/account-selection-required-error.js.map +1 -1
  70. package/dist/errors/authorization-error.d.ts +2 -2
  71. package/dist/errors/authorization-error.d.ts.map +1 -1
  72. package/dist/errors/authorization-error.js.map +1 -1
  73. package/dist/errors/consent-required-error.d.ts +1 -1
  74. package/dist/errors/consent-required-error.d.ts.map +1 -1
  75. package/dist/errors/consent-required-error.js.map +1 -1
  76. package/dist/errors/handle-unavailable-error.d.ts +1 -1
  77. package/dist/errors/handle-unavailable-error.d.ts.map +1 -1
  78. package/dist/errors/handle-unavailable-error.js.map +1 -1
  79. package/dist/errors/invalid-authorization-details-error.d.ts +1 -1
  80. package/dist/errors/invalid-authorization-details-error.d.ts.map +1 -1
  81. package/dist/errors/invalid-authorization-details-error.js.map +1 -1
  82. package/dist/errors/invalid-client-metadata-error.js +1 -1
  83. package/dist/errors/invalid-client-metadata-error.js.map +1 -1
  84. package/dist/errors/invalid-credentials-error.d.ts +1 -1
  85. package/dist/errors/invalid-credentials-error.d.ts.map +1 -1
  86. package/dist/errors/invalid-credentials-error.js.map +1 -1
  87. package/dist/errors/invalid-scope-error.d.ts +1 -1
  88. package/dist/errors/invalid-scope-error.d.ts.map +1 -1
  89. package/dist/errors/invalid-scope-error.js.map +1 -1
  90. package/dist/errors/login-required-error.d.ts +1 -1
  91. package/dist/errors/login-required-error.d.ts.map +1 -1
  92. package/dist/errors/login-required-error.js.map +1 -1
  93. package/dist/lexicon/lexicon-data.d.ts +1 -1
  94. package/dist/lexicon/lexicon-data.d.ts.map +1 -1
  95. package/dist/lexicon/lexicon-data.js.map +1 -1
  96. package/dist/lexicon/lexicon-getter.d.ts +3 -3
  97. package/dist/lexicon/lexicon-getter.d.ts.map +1 -1
  98. package/dist/lexicon/lexicon-getter.js +1 -1
  99. package/dist/lexicon/lexicon-getter.js.map +1 -1
  100. package/dist/lexicon/lexicon-manager.d.ts +4 -4
  101. package/dist/lexicon/lexicon-manager.d.ts.map +1 -1
  102. package/dist/lexicon/lexicon-manager.js.map +1 -1
  103. package/dist/lexicon/lexicon-store.d.ts +4 -3
  104. package/dist/lexicon/lexicon-store.d.ts.map +1 -1
  105. package/dist/lexicon/lexicon-store.js.map +1 -1
  106. package/dist/lib/csp/index.d.ts +1 -1
  107. package/dist/lib/csp/index.d.ts.map +1 -1
  108. package/dist/lib/csp/index.js.map +1 -1
  109. package/dist/lib/hcaptcha.d.ts +1 -1
  110. package/dist/lib/hcaptcha.d.ts.map +1 -1
  111. package/dist/lib/hcaptcha.js +1 -1
  112. package/dist/lib/hcaptcha.js.map +1 -1
  113. package/dist/lib/html/build-document.d.ts +1 -1
  114. package/dist/lib/html/build-document.d.ts.map +1 -1
  115. package/dist/lib/html/build-document.js.map +1 -1
  116. package/dist/lib/html/escapers.d.ts +1 -1
  117. package/dist/lib/html/escapers.d.ts.map +1 -1
  118. package/dist/lib/html/escapers.js.map +1 -1
  119. package/dist/lib/html/tags.d.ts +1 -1
  120. package/dist/lib/html/tags.d.ts.map +1 -1
  121. package/dist/lib/html/tags.js +1 -0
  122. package/dist/lib/html/tags.js.map +1 -1
  123. package/dist/lib/http/accept.d.ts +2 -2
  124. package/dist/lib/http/accept.d.ts.map +1 -1
  125. package/dist/lib/http/accept.js.map +1 -1
  126. package/dist/lib/http/middleware.d.ts +1 -1
  127. package/dist/lib/http/middleware.d.ts.map +1 -1
  128. package/dist/lib/http/middleware.js.map +1 -1
  129. package/dist/lib/http/request.d.ts +2 -2
  130. package/dist/lib/http/request.d.ts.map +1 -1
  131. package/dist/lib/http/request.js.map +1 -1
  132. package/dist/lib/http/response.d.ts +1 -1
  133. package/dist/lib/http/response.d.ts.map +1 -1
  134. package/dist/lib/http/response.js.map +1 -1
  135. package/dist/lib/http/route.d.ts +4 -4
  136. package/dist/lib/http/route.d.ts.map +1 -1
  137. package/dist/lib/http/route.js.map +1 -1
  138. package/dist/lib/http/router.d.ts +5 -5
  139. package/dist/lib/http/router.d.ts.map +1 -1
  140. package/dist/lib/http/router.js.map +1 -1
  141. package/dist/lib/http/stream.d.ts +2 -2
  142. package/dist/lib/http/stream.d.ts.map +1 -1
  143. package/dist/lib/http/stream.js.map +1 -1
  144. package/dist/lib/util/time.d.ts +1 -1
  145. package/dist/lib/util/time.d.ts.map +1 -1
  146. package/dist/lib/util/time.js.map +1 -1
  147. package/dist/lib/util/zod-error.d.ts +1 -1
  148. package/dist/lib/util/zod-error.d.ts.map +1 -1
  149. package/dist/lib/util/zod-error.js.map +1 -1
  150. package/dist/lib/write-form-redirect.d.ts +1 -1
  151. package/dist/lib/write-form-redirect.d.ts.map +1 -1
  152. package/dist/lib/write-form-redirect.js.map +1 -1
  153. package/dist/lib/write-html.d.ts +3 -3
  154. package/dist/lib/write-html.d.ts.map +1 -1
  155. package/dist/lib/write-html.js.map +1 -1
  156. package/dist/metadata/build-metadata.d.ts +2 -2
  157. package/dist/metadata/build-metadata.d.ts.map +1 -1
  158. package/dist/metadata/build-metadata.js.map +1 -1
  159. package/dist/{constants.d.ts → oauth-constants.d.ts} +1 -1
  160. package/dist/oauth-constants.d.ts.map +1 -0
  161. package/dist/{constants.js → oauth-constants.js} +1 -1
  162. package/dist/oauth-constants.js.map +1 -0
  163. package/dist/oauth-errors.d.ts +2 -3
  164. package/dist/oauth-errors.d.ts.map +1 -1
  165. package/dist/oauth-errors.js +4 -4
  166. package/dist/oauth-errors.js.map +1 -1
  167. package/dist/oauth-hooks.d.ts +20 -24
  168. package/dist/oauth-hooks.d.ts.map +1 -1
  169. package/dist/oauth-hooks.js +1 -8
  170. package/dist/oauth-hooks.js.map +1 -1
  171. package/dist/oauth-middleware.d.ts +4 -4
  172. package/dist/oauth-middleware.d.ts.map +1 -1
  173. package/dist/oauth-middleware.js.map +1 -1
  174. package/dist/oauth-provider.d.ts +46 -37
  175. package/dist/oauth-provider.d.ts.map +1 -1
  176. package/dist/oauth-provider.js +17 -8
  177. package/dist/oauth-provider.js.map +1 -1
  178. package/dist/oauth-store.d.ts +0 -4
  179. package/dist/oauth-store.d.ts.map +1 -1
  180. package/dist/oauth-store.js +0 -4
  181. package/dist/oauth-store.js.map +1 -1
  182. package/dist/oauth-utils.d.ts +14 -0
  183. package/dist/oauth-utils.d.ts.map +1 -0
  184. package/dist/oauth-utils.js +5 -0
  185. package/dist/oauth-utils.js.map +1 -0
  186. package/dist/oauth-verifier.d.ts +6 -6
  187. package/dist/oauth-verifier.d.ts.map +1 -1
  188. package/dist/oauth-verifier.js.map +1 -1
  189. package/dist/replay/replay-manager.d.ts +2 -2
  190. package/dist/replay/replay-manager.d.ts.map +1 -1
  191. package/dist/replay/replay-manager.js +1 -1
  192. package/dist/replay/replay-manager.js.map +1 -1
  193. package/dist/replay/replay-store-redis.d.ts +1 -1
  194. package/dist/replay/replay-store-redis.d.ts.map +1 -1
  195. package/dist/replay/replay-store-redis.js.map +1 -1
  196. package/dist/replay/replay-store.d.ts +1 -1
  197. package/dist/replay/replay-store.d.ts.map +1 -1
  198. package/dist/replay/replay-store.js.map +1 -1
  199. package/dist/request/code.js +1 -1
  200. package/dist/request/code.js.map +1 -1
  201. package/dist/request/request-data.d.ts +7 -7
  202. package/dist/request/request-data.d.ts.map +1 -1
  203. package/dist/request/request-data.js.map +1 -1
  204. package/dist/request/request-id.d.ts.map +1 -1
  205. package/dist/request/request-id.js +1 -1
  206. package/dist/request/request-id.js.map +1 -1
  207. package/dist/request/request-manager.d.ts +13 -13
  208. package/dist/request/request-manager.d.ts.map +1 -1
  209. package/dist/request/request-manager.js +1 -1
  210. package/dist/request/request-manager.js.map +1 -1
  211. package/dist/request/request-store.d.ts +6 -8
  212. package/dist/request/request-store.d.ts.map +1 -1
  213. package/dist/request/request-store.js +0 -4
  214. package/dist/request/request-store.js.map +1 -1
  215. package/dist/request/request-uri.d.ts +1 -1
  216. package/dist/request/request-uri.d.ts.map +1 -1
  217. package/dist/request/request-uri.js.map +1 -1
  218. package/dist/result/authorization-redirect-parameters.d.ts +2 -2
  219. package/dist/result/authorization-redirect-parameters.d.ts.map +1 -1
  220. package/dist/result/authorization-redirect-parameters.js.map +1 -1
  221. package/dist/result/authorization-result-redirect.d.ts +2 -2
  222. package/dist/result/authorization-result-redirect.d.ts.map +1 -1
  223. package/dist/result/authorization-result-redirect.js.map +1 -1
  224. package/dist/router/assets/assets-manifest.d.ts +2 -2
  225. package/dist/router/assets/assets-manifest.d.ts.map +1 -1
  226. package/dist/router/assets/assets-manifest.js.map +1 -1
  227. package/dist/router/assets/assets.d.ts +4 -4
  228. package/dist/router/assets/assets.d.ts.map +1 -1
  229. package/dist/router/assets/assets.js.map +1 -1
  230. package/dist/router/assets/csrf.js.map +1 -1
  231. package/dist/router/assets/send-account-page.d.ts +2 -2
  232. package/dist/router/assets/send-account-page.d.ts.map +1 -1
  233. package/dist/router/assets/send-account-page.js.map +1 -1
  234. package/dist/router/assets/send-authorization-page.d.ts +3 -3
  235. package/dist/router/assets/send-authorization-page.d.ts.map +1 -1
  236. package/dist/router/assets/send-authorization-page.js.map +1 -1
  237. package/dist/router/assets/send-cookie-error-page.d.ts +2 -2
  238. package/dist/router/assets/send-cookie-error-page.d.ts.map +1 -1
  239. package/dist/router/assets/send-cookie-error-page.js.map +1 -1
  240. package/dist/router/assets/send-error-page.d.ts +2 -2
  241. package/dist/router/assets/send-error-page.d.ts.map +1 -1
  242. package/dist/router/assets/send-error-page.js.map +1 -1
  243. package/dist/router/assets/send-redirect.d.ts +4 -4
  244. package/dist/router/assets/send-redirect.d.ts.map +1 -1
  245. package/dist/router/assets/send-redirect.js.map +1 -1
  246. package/dist/router/create-account-page-middleware.d.ts +1 -1
  247. package/dist/router/create-account-page-middleware.d.ts.map +1 -1
  248. package/dist/router/create-account-page-middleware.js.map +1 -1
  249. package/dist/router/create-api-middleware.d.ts +2 -2
  250. package/dist/router/create-api-middleware.d.ts.map +1 -1
  251. package/dist/router/create-api-middleware.js +1 -1
  252. package/dist/router/create-api-middleware.js.map +1 -1
  253. package/dist/router/create-authorization-page-middleware.d.ts +1 -1
  254. package/dist/router/create-authorization-page-middleware.d.ts.map +1 -1
  255. package/dist/router/create-authorization-page-middleware.js.map +1 -1
  256. package/dist/router/create-oauth-middleware.d.ts +1 -1
  257. package/dist/router/create-oauth-middleware.d.ts.map +1 -1
  258. package/dist/router/create-oauth-middleware.js +1 -1
  259. package/dist/router/create-oauth-middleware.js.map +1 -1
  260. package/dist/signer/api-token-payload.d.ts +1 -1
  261. package/dist/signer/api-token-payload.d.ts.map +1 -1
  262. package/dist/signer/api-token-payload.js +1 -1
  263. package/dist/signer/api-token-payload.js.map +1 -1
  264. package/dist/signer/signer.d.ts +4 -4
  265. package/dist/signer/signer.d.ts.map +1 -1
  266. package/dist/signer/signer.js +2 -2
  267. package/dist/signer/signer.js.map +1 -1
  268. package/dist/token/refresh-token.js +1 -1
  269. package/dist/token/refresh-token.js.map +1 -1
  270. package/dist/token/token-claims.d.ts +4 -4
  271. package/dist/token/token-claims.d.ts.map +1 -1
  272. package/dist/token/token-claims.js.map +1 -1
  273. package/dist/token/token-data.d.ts +7 -7
  274. package/dist/token/token-data.d.ts.map +1 -1
  275. package/dist/token/token-data.js.map +1 -1
  276. package/dist/token/token-id.js +1 -1
  277. package/dist/token/token-id.js.map +1 -1
  278. package/dist/token/token-manager.d.ts +14 -14
  279. package/dist/token/token-manager.d.ts.map +1 -1
  280. package/dist/token/token-manager.js +1 -1
  281. package/dist/token/token-manager.js.map +1 -1
  282. package/dist/token/token-store.d.ts +7 -9
  283. package/dist/token/token-store.d.ts.map +1 -1
  284. package/dist/token/token-store.js +0 -4
  285. package/dist/token/token-store.js.map +1 -1
  286. package/dist/types/handle.js.map +1 -1
  287. package/dist/types/rgb-color.d.ts +1 -1
  288. package/dist/types/rgb-color.d.ts.map +1 -1
  289. package/dist/types/rgb-color.js.map +1 -1
  290. package/package.json +47 -20
  291. package/dist/constants.d.ts.map +0 -1
  292. package/dist/constants.js.map +0 -1
  293. package/dist/errors/invalid-invite-code-error.d.ts +0 -5
  294. package/dist/errors/invalid-invite-code-error.d.ts.map +0 -1
  295. package/dist/errors/invalid-invite-code-error.js +0 -7
  296. package/dist/errors/invalid-invite-code-error.js.map +0 -1
  297. package/dist/index.d.ts +0 -15
  298. package/dist/index.d.ts.map +0 -1
  299. package/dist/index.js +0 -16
  300. package/dist/index.js.map +0 -1
  301. package/dist/oauth-client.d.ts +0 -4
  302. package/dist/oauth-client.d.ts.map +0 -1
  303. package/dist/oauth-client.js +0 -3
  304. package/dist/oauth-client.js.map +0 -1
  305. package/dist/oauth-dpop.d.ts +0 -3
  306. package/dist/oauth-dpop.d.ts.map +0 -1
  307. package/dist/oauth-dpop.js +0 -3
  308. package/dist/oauth-dpop.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"send-account-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-account-page.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAElE,MAAM,UAAU,sBAAsB,CACpC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAEzE,OAAO,KAAK,UAAU,eAAe,CACnC,GAAoB,EACpB,GAAmB,EACnB,IAEC;QAED,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,cAAc,EAAE;SAChD,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { ActiveDeviceSession } from '@atproto/oauth-provider-api'\nimport { Customization } from '../../customization/customization.js'\nimport { SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendAccountPageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory('account-page', customization, options)\n\n return async function sendAccountPage(\n req: IncomingMessage,\n res: ServerResponse,\n data: {\n deviceSessions: readonly ActiveDeviceSession[]\n },\n ): Promise<void> {\n return sendApp(req, res, {\n data: { __deviceSessions: data.deviceSessions },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"send-account-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-account-page.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,UAAU,sBAAsB,CACpC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAEzE,OAAO,KAAK,UAAU,eAAe,CACnC,GAAoB,EACpB,GAAmB,EACnB,IAEC;QAED,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,cAAc,EAAE;SAChD,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { ActiveDeviceSession } from '@atproto/oauth-provider-api'\nimport type { Customization } from '../../customization/customization.js'\nimport { type SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendAccountPageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory('account-page', customization, options)\n\n return async function sendAccountPage(\n req: IncomingMessage,\n res: ServerResponse,\n data: {\n deviceSessions: readonly ActiveDeviceSession[]\n },\n ): Promise<void> {\n return sendApp(req, res, {\n data: { __deviceSessions: data.deviceSessions },\n })\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Customization } from '../../customization/customization.js';
3
- import { AuthorizationResultAuthorizePage } from '../../result/authorization-result-authorize-page.js';
4
- import { SendWebAppOptions } from './assets.js';
2
+ import type { Customization } from '../../customization/customization.js';
3
+ import type { AuthorizationResultAuthorizePage } from '../../result/authorization-result-authorize-page.js';
4
+ import { type SendWebAppOptions } from './assets.js';
5
5
  export declare function sendAuthorizePageFactory(customization: Customization, options?: SendWebAppOptions): (req: IncomingMessage, res: ServerResponse, data: AuthorizationResultAuthorizePage) => Promise<void>;
6
6
  //# sourceMappingURL=send-authorization-page.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"send-authorization-page.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-authorization-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAA;AACtG,OAAO,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAElE,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,SASpB,eAAe,OACf,cAAc,QACb,gCAAgC,KACrC,OAAO,CAAC,IAAI,CAAC,CAsBjB"}
1
+ {"version":3,"file":"send-authorization-page.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-authorization-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAA;AAC3G,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAEvE,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,SASpB,eAAe,OACf,cAAc,QACb,gCAAgC,KACrC,OAAO,CAAC,IAAI,CAAC,CAsBjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"send-authorization-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-authorization-page.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAElE,MAAM,UAAU,wBAAwB,CACtC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAC/B,oBAAoB,EACpB,aAAa,EACb,OAAO,CACR,CAAA;IAED,OAAO,KAAK,UAAU,iBAAiB,CACrC,GAAoB,EACpB,GAAmB,EACnB,IAAsC;QAEtC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,IAAI,EAAE;gBACJ,eAAe,EAAE;oBACf,UAAU,EAAE,IAAI,CAAC,UAAU;oBAE3B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;oBACxB,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;oBACpC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;oBACzC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY;oBAE/C,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;oBAC5B,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;oBACrC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;oBACrC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;oBAClC,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC;oBACvD,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B;gBACD,UAAU,EAAE,IAAI,CAAC,QAAQ;aAC1B;SACF,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport { Customization } from '../../customization/customization.js'\nimport { AuthorizationResultAuthorizePage } from '../../result/authorization-result-authorize-page.js'\nimport { SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendAuthorizePageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory(\n 'authorization-page',\n customization,\n options,\n )\n\n return async function sendAuthorizePage(\n req: IncomingMessage,\n res: ServerResponse,\n data: AuthorizationResultAuthorizePage,\n ): Promise<void> {\n return sendApp(req, res, {\n data: {\n __authorizeData: {\n requestUri: data.requestUri,\n\n clientId: data.client.id,\n clientMetadata: data.client.metadata,\n clientTrusted: data.client.info.isTrusted,\n clientFirstParty: data.client.info.isFirstParty,\n\n scope: data.parameters.scope,\n uiLocales: data.parameters.ui_locales,\n loginHint: data.parameters.login_hint,\n promptMode: data.parameters.prompt,\n permissionSets: Object.fromEntries(data.permissionSets),\n selectedDid: data.selectedDid,\n },\n __sessions: data.sessions,\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"send-authorization-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-authorization-page.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,UAAU,wBAAwB,CACtC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAC/B,oBAAoB,EACpB,aAAa,EACb,OAAO,CACR,CAAA;IAED,OAAO,KAAK,UAAU,iBAAiB,CACrC,GAAoB,EACpB,GAAmB,EACnB,IAAsC;QAEtC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,IAAI,EAAE;gBACJ,eAAe,EAAE;oBACf,UAAU,EAAE,IAAI,CAAC,UAAU;oBAE3B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;oBACxB,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;oBACpC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;oBACzC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY;oBAE/C,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;oBAC5B,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;oBACrC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;oBACrC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;oBAClC,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC;oBACvD,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B;gBACD,UAAU,EAAE,IAAI,CAAC,QAAQ;aAC1B;SACF,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Customization } from '../../customization/customization.js'\nimport type { AuthorizationResultAuthorizePage } from '../../result/authorization-result-authorize-page.js'\nimport { type SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendAuthorizePageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory(\n 'authorization-page',\n customization,\n options,\n )\n\n return async function sendAuthorizePage(\n req: IncomingMessage,\n res: ServerResponse,\n data: AuthorizationResultAuthorizePage,\n ): Promise<void> {\n return sendApp(req, res, {\n data: {\n __authorizeData: {\n requestUri: data.requestUri,\n\n clientId: data.client.id,\n clientMetadata: data.client.metadata,\n clientTrusted: data.client.info.isTrusted,\n clientFirstParty: data.client.info.isFirstParty,\n\n scope: data.parameters.scope,\n uiLocales: data.parameters.ui_locales,\n loginHint: data.parameters.login_hint,\n promptMode: data.parameters.prompt,\n permissionSets: Object.fromEntries(data.permissionSets),\n selectedDid: data.selectedDid,\n },\n __sessions: data.sessions,\n },\n })\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Customization } from '../../customization/customization.js';
3
- import { SendWebAppOptions } from './assets.js';
2
+ import type { Customization } from '../../customization/customization.js';
3
+ import { type SendWebAppOptions } from './assets.js';
4
4
  export declare function sendCookieErrorPageFactory(customization: Customization, options?: SendWebAppOptions): (req: IncomingMessage, res: ServerResponse, data: {
5
5
  continueUrl: URL;
6
6
  }) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"send-cookie-error-page.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-cookie-error-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAElE,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,SAKpB,eAAe,OACf,cAAc,QACb;IAAE,WAAW,EAAE,GAAG,CAAA;CAAE,mBAO7B"}
1
+ {"version":3,"file":"send-cookie-error-page.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-cookie-error-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAEvE,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,SAKpB,eAAe,OACf,cAAc,QACb;IAAE,WAAW,EAAE,GAAG,CAAA;CAAE,mBAO7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"send-cookie-error-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-cookie-error-page.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAElE,MAAM,UAAU,0BAA0B,CACxC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,mBAAmB,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAE9E,OAAO,KAAK,UAAU,mBAAmB,CACvC,GAAoB,EACpB,GAAmB,EACnB,IAA0B;QAE1B,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;SACrD,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport { Customization } from '../../customization/customization.js'\nimport { SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendCookieErrorPageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory('cookie-error-page', customization, options)\n\n return async function sendCookieErrorPage(\n req: IncomingMessage,\n res: ServerResponse,\n data: { continueUrl: URL },\n ) {\n return sendApp(req, res, {\n status: 400,\n data: { __continueUrl: data.continueUrl.toString() },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"send-cookie-error-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-cookie-error-page.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,UAAU,0BAA0B,CACxC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,mBAAmB,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAE9E,OAAO,KAAK,UAAU,mBAAmB,CACvC,GAAoB,EACpB,GAAmB,EACnB,IAA0B;QAE1B,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;SACrD,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Customization } from '../../customization/customization.js'\nimport { type SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendCookieErrorPageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory('cookie-error-page', customization, options)\n\n return async function sendCookieErrorPage(\n req: IncomingMessage,\n res: ServerResponse,\n data: { continueUrl: URL },\n ) {\n return sendApp(req, res, {\n status: 400,\n data: { __continueUrl: data.continueUrl.toString() },\n })\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Customization } from '../../customization/customization.js';
3
- import { SendWebAppOptions } from './assets.js';
2
+ import type { Customization } from '../../customization/customization.js';
3
+ import { type SendWebAppOptions } from './assets.js';
4
4
  export declare function sendErrorPageFactory(customization: Customization, options?: SendWebAppOptions): (req: IncomingMessage, res: ServerResponse, err: unknown) => Promise<void>;
5
5
  //# sourceMappingURL=send-error-page.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"send-error-page.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-error-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AAKpE,OAAO,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAElE,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,SAKpB,eAAe,OACf,cAAc,OACd,OAAO,KACX,OAAO,CAAC,IAAI,CAAC,CAMjB"}
1
+ {"version":3,"file":"send-error-page.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-error-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AAKzE,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAEvE,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,SAKpB,eAAe,OACf,cAAc,OACd,OAAO,KACX,OAAO,CAAC,IAAI,CAAC,CAMjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"send-error-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-error-page.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAElE,MAAM,UAAU,oBAAoB,CAClC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAEvE,OAAO,KAAK,UAAU,aAAa,CACjC,GAAoB,EACpB,GAAmB,EACnB,GAAY;QAEZ,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC;YAC7B,IAAI,EAAE,EAAE,WAAW,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE;SAC9C,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport { Customization } from '../../customization/customization.js'\nimport {\n buildErrorPayload,\n buildErrorStatus,\n} from '../../errors/error-parser.js'\nimport { SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendErrorPageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory('error-page', customization, options)\n\n return async function sendErrorPage(\n req: IncomingMessage,\n res: ServerResponse,\n err: unknown,\n ): Promise<void> {\n return sendApp(req, res, {\n status: buildErrorStatus(err),\n data: { __errorData: buildErrorPayload(err) },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"send-error-page.js","sourceRoot":"","sources":["../../../src/router/assets/send-error-page.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAA0B,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,UAAU,oBAAoB,CAClC,aAA4B,EAC5B,OAA2B;IAE3B,MAAM,OAAO,GAAG,iBAAiB,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAEvE,OAAO,KAAK,UAAU,aAAa,CACjC,GAAoB,EACpB,GAAmB,EACnB,GAAY;QAEZ,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;YACvB,MAAM,EAAE,gBAAgB,CAAC,GAAG,CAAC;YAC7B,IAAI,EAAE,EAAE,WAAW,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE;SAC9C,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Customization } from '../../customization/customization.js'\nimport {\n buildErrorPayload,\n buildErrorStatus,\n} from '../../errors/error-parser.js'\nimport { type SendWebAppOptions, sendWebAppFactory } from './assets.js'\n\nexport function sendErrorPageFactory(\n customization: Customization,\n options?: SendWebAppOptions,\n) {\n const sendApp = sendWebAppFactory('error-page', customization, options)\n\n return async function sendErrorPage(\n req: IncomingMessage,\n res: ServerResponse,\n err: unknown,\n ): Promise<void> {\n return sendApp(req, res, {\n status: buildErrorStatus(err),\n data: { __errorData: buildErrorPayload(err) },\n })\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import type { ServerResponse } from 'node:http';
2
- import { OAuthAuthorizationRequestParameters, OAuthResponseMode } from '@atproto/oauth-types';
3
- import { WriteFormRedirectOptions } from '../../lib/write-form-redirect.js';
4
- import { AuthorizationRedirectParameters } from '../../result/authorization-redirect-parameters.js';
5
- import { AuthorizationResultRedirect } from '../../result/authorization-result-redirect.js';
2
+ import type { OAuthAuthorizationRequestParameters, OAuthResponseMode } from '@atproto/oauth-types';
3
+ import { type WriteFormRedirectOptions } from '../../lib/write-form-redirect.js';
4
+ import type { AuthorizationRedirectParameters } from '../../result/authorization-redirect-parameters.js';
5
+ import type { AuthorizationResultRedirect } from '../../result/authorization-result-redirect.js';
6
6
  export declare const SUCCESS_REDIRECT_KEYS: readonly ['code', 'id_token', 'access_token', 'expires_in', 'token_type'];
7
7
  export declare const ERROR_REDIRECT_KEYS: readonly ['error', 'error_description', 'error_uri'];
8
8
  export type OAuthRedirectQueryParameter = 'iss' | 'state' | (typeof SUCCESS_REDIRECT_KEYS)[number] | (typeof ERROR_REDIRECT_KEYS)[number];
@@ -1 +1 @@
1
- {"version":3,"file":"send-redirect.d.ts","sourceRoot":"","sources":["../../../src/router/assets/send-redirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EACL,mCAAmC,EACnC,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,wBAAwB,EAEzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,mDAAmD,CAAA;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAA;AAK3F,eAAO,MAAM,qBAAqB,YAChC,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,EACZ,YAAY,CACJ,CAAA;AAEV,eAAO,MAAM,mBAAmB,YAC9B,OAAO,EACP,mBAAmB,EACnB,WAAW,CACH,CAAA;AAEV,MAAM,MAAM,2BAA2B,GACnC,KAAK,GACL,OAAO,GACP,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,GACtC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AAExC,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,mCAAmC,GAC9C,MAAM,CAKR;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,mCAAmC,GAC9C,iBAAiB,CAGnB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,mCAAmC,EAC/C,QAAQ,EAAE,+BAA+B,GACxC,CAAC,2BAA2B,EAAE,MAAM,CAAC,EAAE,CAgBzC;AAED,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE,wBAAwB,QAanC;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,iBAAiB,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;I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CAAC,CAAC,GAAG,EAAE,CAAA;AACnE,CAAC","sourcesContent":["import type { ServerResponse } from 'node:http'\nimport {\n OAuthAuthorizationRequestParameters,\n OAuthResponseMode,\n} from '@atproto/oauth-types'\nimport { AuthorizationError } from '../../errors/authorization-error.js'\nimport {\n WriteFormRedirectOptions,\n writeFormRedirect,\n} from '../../lib/write-form-redirect.js'\nimport { AuthorizationRedirectParameters } from '../../result/authorization-redirect-parameters.js'\nimport { AuthorizationResultRedirect } from '../../result/authorization-result-redirect.js'\n\n// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-11#section-7.5.4\nconst REDIRECT_STATUS_CODE = 303\n\nexport const SUCCESS_REDIRECT_KEYS = [\n 'code',\n 'id_token',\n 'access_token',\n 'expires_in',\n 'token_type',\n] as const\n\nexport const ERROR_REDIRECT_KEYS = [\n 'error',\n 'error_description',\n 'error_uri',\n] as const\n\nexport type OAuthRedirectQueryParameter =\n | 'iss'\n | 'state'\n | (typeof SUCCESS_REDIRECT_KEYS)[number]\n | (typeof ERROR_REDIRECT_KEYS)[number]\n\nexport function buildRedirectUri(\n parameters: OAuthAuthorizationRequestParameters,\n): string {\n const uri = parameters.redirect_uri\n if (uri) return uri\n\n throw new AuthorizationError(parameters, 'No redirect_uri', 'invalid_request')\n}\n\nexport function buildRedirectMode(\n parameters: OAuthAuthorizationRequestParameters,\n): OAuthResponseMode {\n const mode = parameters.response_mode || 'query' // @TODO default should depend on response_type\n return mode\n}\n\nexport function buildRedirectParams(\n issuer: string,\n parameters: OAuthAuthorizationRequestParameters,\n redirect: AuthorizationRedirectParameters,\n): [OAuthRedirectQueryParameter, string][] {\n const params: [OAuthRedirectQueryParameter, string][] = [\n ['iss', issuer], // rfc9207\n ]\n\n if (parameters.state != null) {\n params.push(['state', parameters.state])\n }\n\n const keys = 'code' in redirect ? SUCCESS_REDIRECT_KEYS : ERROR_REDIRECT_KEYS\n for (const key of keys) {\n const value = redirect[key]\n if (value != null) params.push([key, value])\n }\n\n return params\n}\n\nexport function sendAuthorizationResultRedirect(\n res: ServerResponse,\n result: AuthorizationResultRedirect,\n options?: WriteFormRedirectOptions,\n) {\n const { issuer, parameters, redirect } = result\n\n return sendRedirect(\n res,\n {\n redirectUri: buildRedirectUri(parameters),\n mode: buildRedirectMode(parameters),\n params: buildRedirectParams(issuer, parameters, redirect),\n },\n options,\n )\n}\n\nexport type OAuthRedirectOptions = {\n mode: OAuthResponseMode\n redirectUri: string\n params: Iterable<[string, string]>\n}\n\nexport function sendRedirect(\n res: ServerResponse,\n redirect: OAuthRedirectOptions,\n options?: WriteFormRedirectOptions,\n): void {\n res.setHeader('Cache-Control', 'no-store')\n\n const { mode, redirectUri: uri, params } = redirect\n switch (mode) {\n case 'query':\n return writeQuery(res, uri, params)\n case 'fragment':\n return writeFragment(res, uri, params)\n case 'form_post':\n return writeFormRedirect(res, 'post', uri, params, options)\n }\n\n // @ts-expect-error fool proof\n throw new Error(`Unsupported mode: ${mode}`)\n}\n\nfunction writeQuery(\n res: ServerResponse,\n uri: string,\n params: Iterable<[string, string]>,\n): void {\n const url = new URL(uri)\n for (const [key, value] of params) url.searchParams.set(key, value)\n res.writeHead(REDIRECT_STATUS_CODE, { Location: url.href }).end()\n}\n\nfunction writeFragment(\n res: ServerResponse,\n uri: string,\n params: Iterable<[string, string]>,\n): void {\n const url = new URL(uri)\n const searchParams = new URLSearchParams()\n for (const [key, value] of params) searchParams.set(key, value)\n url.hash = searchParams.toString()\n res.writeHead(REDIRECT_STATUS_CODE, { Location: url.href }).end()\n}\n"]}
1
+ {"version":3,"file":"send-redirect.js","sourceRoot":"","sources":["../../../src/router/assets/send-redirect.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAEL,iBAAiB,GAClB,MAAM,kCAAkC,CAAA;AAIzC,+EAA+E;AAC/E,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC,MAAM,CAAC,MAAM,qBAAqB,G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C,oBAAoB,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAA;AACnE,CAAC;AAED,SAAS,aAAa,CACpB,GAAmB,EACnB,GAAW,EACX,MAAkC;IAElC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACxB,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAA;IAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM;QAAE,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC/D,GAAG,CAAC,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAA;IAClC,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAA;AACnE,CAAC","sourcesContent":["import type { ServerResponse } from 'node:http'\nimport type {\n OAuthAuthorizationRequestParameters,\n OAuthResponseMode,\n} from '@atproto/oauth-types'\nimport { AuthorizationError } from '../../errors/authorization-error.js'\nimport {\n type WriteFormRedirectOptions,\n writeFormRedirect,\n} from '../../lib/write-form-redirect.js'\nimport type { AuthorizationRedirectParameters } from '../../result/authorization-redirect-parameters.js'\nimport type { AuthorizationResultRedirect } from '../../result/authorization-result-redirect.js'\n\n// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-11#section-7.5.4\nconst REDIRECT_STATUS_CODE = 303\n\nexport const SUCCESS_REDIRECT_KEYS = [\n 'code',\n 'id_token',\n 'access_token',\n 'expires_in',\n 'token_type',\n] as const\n\nexport const ERROR_REDIRECT_KEYS = [\n 'error',\n 'error_description',\n 'error_uri',\n] as const\n\nexport type OAuthRedirectQueryParameter =\n | 'iss'\n | 'state'\n | (typeof SUCCESS_REDIRECT_KEYS)[number]\n | (typeof ERROR_REDIRECT_KEYS)[number]\n\nexport function buildRedirectUri(\n parameters: OAuthAuthorizationRequestParameters,\n): string {\n const uri = parameters.redirect_uri\n if (uri) return uri\n\n throw new AuthorizationError(parameters, 'No redirect_uri', 'invalid_request')\n}\n\nexport function buildRedirectMode(\n parameters: OAuthAuthorizationRequestParameters,\n): OAuthResponseMode {\n const mode = parameters.response_mode || 'query' // @TODO default should depend on response_type\n return mode\n}\n\nexport function buildRedirectParams(\n issuer: string,\n parameters: OAuthAuthorizationRequestParameters,\n redirect: AuthorizationRedirectParameters,\n): [OAuthRedirectQueryParameter, string][] {\n const params: [OAuthRedirectQueryParameter, string][] = [\n ['iss', issuer], // rfc9207\n ]\n\n if (parameters.state != null) {\n params.push(['state', parameters.state])\n }\n\n const keys = 'code' in redirect ? SUCCESS_REDIRECT_KEYS : ERROR_REDIRECT_KEYS\n for (const key of keys) {\n const value = redirect[key]\n if (value != null) params.push([key, value])\n }\n\n return params\n}\n\nexport function sendAuthorizationResultRedirect(\n res: ServerResponse,\n result: AuthorizationResultRedirect,\n options?: WriteFormRedirectOptions,\n) {\n const { issuer, parameters, redirect } = result\n\n return sendRedirect(\n res,\n {\n redirectUri: buildRedirectUri(parameters),\n mode: buildRedirectMode(parameters),\n params: buildRedirectParams(issuer, parameters, redirect),\n },\n options,\n )\n}\n\nexport type OAuthRedirectOptions = {\n mode: OAuthResponseMode\n redirectUri: string\n params: Iterable<[string, string]>\n}\n\nexport function sendRedirect(\n res: ServerResponse,\n redirect: OAuthRedirectOptions,\n options?: WriteFormRedirectOptions,\n): void {\n res.setHeader('Cache-Control', 'no-store')\n\n const { mode, redirectUri: uri, params } = redirect\n switch (mode) {\n case 'query':\n return writeQuery(res, uri, params)\n case 'fragment':\n return writeFragment(res, uri, params)\n case 'form_post':\n return writeFormRedirect(res, 'post', uri, params, options)\n }\n\n // @ts-expect-error fool proof\n throw new Error(`Unsupported mode: ${mode}`)\n}\n\nfunction writeQuery(\n res: ServerResponse,\n uri: string,\n params: Iterable<[string, string]>,\n): void {\n const url = new URL(uri)\n for (const [key, value] of params) url.searchParams.set(key, value)\n res.writeHead(REDIRECT_STATUS_CODE, { Location: url.href }).end()\n}\n\nfunction writeFragment(\n res: ServerResponse,\n uri: string,\n params: Iterable<[string, string]>,\n): void {\n const url = new URL(uri)\n const searchParams = new URLSearchParams()\n for (const [key, value] of params) searchParams.set(key, value)\n url.hash = searchParams.toString()\n res.writeHead(REDIRECT_STATUS_CODE, { Location: url.href }).end()\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Middleware } from '../lib/http/index.js';
2
+ import { type Middleware } from '../lib/http/index.js';
3
3
  import type { OAuthProvider } from '../oauth-provider.js';
4
4
  import type { MiddlewareOptions } from './middleware-options.js';
5
5
  export declare function createAccountPageMiddleware<Ctx extends object | void = void, Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse>(server: OAuthProvider, { onError }: MiddlewareOptions<Req, Res>): Middleware<Ctx, Req, Res>;
@@ -1 +1 @@
1
- {"version":3,"file":"create-account-page-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-account-page-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,EACL,UAAU,EAMX,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,wBAAgB,2BAA2B,CACzC,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAgE3B"}
1
+ {"version":3,"file":"create-account-page-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-account-page-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,EACL,KAAK,UAAU,EAMhB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,wBAAgB,2BAA2B,CACzC,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAgE3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-account-page-middleware.js","sourceRoot":"","sources":["../../src/router/create-account-page-middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAGlE,MAAM,UAAU,2BAA2B,CAKzC,MAAqB,EACrB,EAAE,OAAO,EAA+B;IAExC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAA;IAErC,MAAM,eAAe,GAA2B;QAC9C,IAAI,EAAE,SAAS,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,C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Ac,CAAC,GAAG,CAChC,CAAC,aAAa,EAAuB,EAAE,CAAC,CAAC;oBACvC,OAAO,EAAE,aAAa,CAAC,OAAO;oBAC9B,aAAa,EAAE,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC;iBACxD,CAAC,CACH;aACF,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,CACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,2CAA2C,GAAG,CAAC,GAAG,GAAG,CACtD,CAAA;YAED,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,eAAe,EAAE,CAAA;AACjC,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { ActiveDeviceSession } from '@atproto/oauth-provider-api'\nimport {\n Middleware,\n Router,\n validateFetchDest,\n validateFetchMode,\n validateOrigin,\n writeRedirect,\n} from '../lib/http/index.js'\nimport { SecurityHeadersOptions } from '../lib/http/security-headers.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport { sendAccountPageFactory } from './assets/send-account-page.js'\nimport { sendErrorPageFactory } from './assets/send-error-page.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\nexport function createAccountPageMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const issuerUrl = new URL(server.issuer)\n const issuerOrigin = issuerUrl.origin\n\n const securityOptions: SecurityHeadersOptions = {\n hsts: issuerUrl.protocol === 'http:' ? false : undefined,\n }\n\n const sendAccountPage = sendAccountPageFactory(\n server.customization,\n securityOptions,\n )\n const sendErrorPage = sendErrorPageFactory(\n server.customization,\n securityOptions,\n )\n\n const router = new Router<Ctx, Req, Res>(issuerUrl)\n\n // Create password reset discovery endpoint\n // https://www.w3.org/TR/change-password-url/\n router.get('/.well-known/change-password', (_req, res) => {\n writeRedirect(res, new URL('/account/reset-password', issuerUrl).toString())\n })\n\n // Create frontend account pages\n router.get<never>(/^\\/account(?:\\/.*)?$/, async function (req, res) {\n try {\n res.setHeader('Referrer-Policy', 'same-origin')\n\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n validateFetchMode(req, ['navigate'])\n validateFetchDest(req, ['document'])\n validateOrigin(req, issuerOrigin)\n\n const { deviceId } = await server.deviceManager.load(req, res)\n const deviceAccounts =\n await server.accountManager.listDeviceAccounts(deviceId)\n\n sendAccountPage(req, res, {\n deviceSessions: deviceAccounts.map(\n (deviceAccount): ActiveDeviceSession => ({\n account: deviceAccount.account,\n loginRequired: server.checkLoginRequired(deviceAccount),\n }),\n ),\n })\n } catch (err) {\n onError?.(\n req,\n res,\n err,\n `Failed to handle navigation request to \"${req.url}\"`,\n )\n\n if (!res.headersSent) {\n return sendErrorPage(req, res, err)\n }\n }\n })\n\n return router.buildMiddleware()\n}\n"]}
1
+ {"version":3,"file":"create-account-page-middleware.js","sourceRoot":"","sources":["../../src/router/create-account-page-middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAGlE,MAAM,UAAU,2BAA2B,CAKzC,MAAqB,EACrB,EAAE,OAAO,EAA+B;IAExC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAA;IAErC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AAkB,CAAC,QAAQ,CAAC,CAAA;YAE1D,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE;gBACxB,cAAc,EAAE,cAAc,CAAC,GAAG,CAChC,CAAC,aAAa,EAAuB,EAAE,CAAC,CAAC;oBACvC,OAAO,EAAE,aAAa,CAAC,OAAO;oBAC9B,aAAa,EAAE,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC;iBACxD,CAAC,CACH;aACF,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,CACP,GAAG,EACH,GAAG,EACH,GAAG,EACH,2CAA2C,GAAG,CAAC,GAAG,GAAG,CACtD,CAAA;YAED,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,eAAe,EAAE,CAAA;AACjC,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { ActiveDeviceSession } from '@atproto/oauth-provider-api'\nimport {\n type Middleware,\n Router,\n validateFetchDest,\n validateFetchMode,\n validateOrigin,\n writeRedirect,\n} from '../lib/http/index.js'\nimport type { SecurityHeadersOptions } from '../lib/http/security-headers.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport { sendAccountPageFactory } from './assets/send-account-page.js'\nimport { sendErrorPageFactory } from './assets/send-error-page.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\nexport function createAccountPageMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const issuerUrl = new URL(server.issuer)\n const issuerOrigin = issuerUrl.origin\n\n const securityOptions: SecurityHeadersOptions = {\n hsts: issuerUrl.protocol === 'http:' ? false : undefined,\n }\n\n const sendAccountPage = sendAccountPageFactory(\n server.customization,\n securityOptions,\n )\n const sendErrorPage = sendErrorPageFactory(\n server.customization,\n securityOptions,\n )\n\n const router = new Router<Ctx, Req, Res>(issuerUrl)\n\n // Create password reset discovery endpoint\n // https://www.w3.org/TR/change-password-url/\n router.get('/.well-known/change-password', (_req, res) => {\n writeRedirect(res, new URL('/account/reset-password', issuerUrl).toString())\n })\n\n // Create frontend account pages\n router.get<never>(/^\\/account(?:\\/.*)?$/, async function (req, res) {\n try {\n res.setHeader('Referrer-Policy', 'same-origin')\n\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n validateFetchMode(req, ['navigate'])\n validateFetchDest(req, ['document'])\n validateOrigin(req, issuerOrigin)\n\n const { deviceId } = await server.deviceManager.load(req, res)\n const deviceAccounts =\n await server.accountManager.listDeviceAccounts(deviceId)\n\n sendAccountPage(req, res, {\n deviceSessions: deviceAccounts.map(\n (deviceAccount): ActiveDeviceSession => ({\n account: deviceAccount.account,\n loginRequired: server.checkLoginRequired(deviceAccount),\n }),\n ),\n })\n } catch (err) {\n onError?.(\n req,\n res,\n err,\n `Failed to handle navigation request to \"${req.url}\"`,\n )\n\n if (!res.headersSent) {\n return sendErrorPage(req, res, err)\n }\n }\n })\n\n return router.buildMiddleware()\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Middleware } from '../lib/http/index.js';
2
+ import { type Middleware } from '../lib/http/index.js';
3
3
  import type { OAuthProvider } from '../oauth-provider.js';
4
- import { OAuthRedirectOptions } from './assets/send-redirect.js';
4
+ import { type OAuthRedirectOptions } from './assets/send-redirect.js';
5
5
  import type { MiddlewareOptions } from './middleware-options.js';
6
6
  export declare function createApiMiddleware<Ctx extends object | void = void, Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse>(server: OAuthProvider, { onError }: MiddlewareOptions<Req, Res>): Middleware<Ctx, Req, Res>;
7
7
  export declare function parseRedirectUrl(url: URL): OAuthRedirectOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"create-api-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-api-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAgChE,OAAO,EAEL,UAAU,EAaX,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AASzD,OAAO,EAEL,oBAAoB,EAMrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,wBAAgB,mBAAmB,CACjC,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAo4B3B;AA2BD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,oBAAoB,CA4C/D"}
1
+ {"version":3,"file":"create-api-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-api-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAgChE,OAAO,EAEL,KAAK,UAAU,EAahB,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AASzD,OAAO,EAEL,KAAK,oBAAoB,EAM1B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,wBAAgB,mBAAmB,CACjC,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAo4B3B;AA2BD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,oBAAoB,CA4C/D"}
@@ -2,7 +2,7 @@ import createHttpError from 'http-errors';
2
2
  import { z } from 'zod';
3
3
  import { didSchema } from '@atproto/did';
4
4
  import { signedJwtSchema } from '@atproto/jwk';
5
- import { API_ENDPOINT_PREFIX, } from '@atproto/oauth-provider-api';
5
+ import { API_ENDPOINT_PREFIX } from '@atproto/oauth-provider-api';
6
6
  import { oauthRedirectUriSchema, oauthResponseModeSchema, oauthScopeSchema, } from '@atproto/oauth-types';
7
7
  import { signInDataSchema } from '../account/sign-in-data.js';
8
8
  import { signUpInputSchema } from '../account/sign-up-input.js';
@@ -1 +1 @@
1
- {"version":3,"file":"create-api-middleware.js","sourceRoot":"","sources":["../../src/router/create-api-middleware.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAO,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EACL,mBAAmB,GAMpB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAIL,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,O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AAK,IAAI,IAAI;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;SAAM,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACvC,IAAI,KAAK,IAAI,IAAI;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,mBAAmB,CAC3B,oDAAoD,CACrD,CAAA;IACH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAsB,uBAAuB,CAAC,KAAK,CAC3D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,CACtC,CAAA;QAED,MAAM,WAAW,GAAqB,sBAAsB,CAAC,KAAK,CAChE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CACrC,CAAA;QAED,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,mBAAmB,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport createHttpError from 'http-errors'\nimport { z } from 'zod'\nimport { Did, didSchema } from '@atproto/did'\nimport { signedJwtSchema } from '@atproto/jwk'\nimport {\n API_ENDPOINT_PREFIX,\n ActiveAccountSession,\n ActiveDeviceSession,\n ActiveOAuthSession,\n ApiEndpoints,\n ISODateString,\n} from '@atproto/oauth-provider-api'\nimport {\n OAuthAuthorizationRequestParameters,\n OAuthRedirectUri,\n OAuthResponseMode,\n oauthRedirectUriSchema,\n oauthResponseModeSchema,\n oauthScopeSchema,\n} from '@atproto/oauth-types'\nimport { signInDataSchema } from '../account/sign-in-data.js'\nimport { signUpInputSchema } from '../account/sign-up-input.js'\nimport { DeviceId, deviceIdSchema } from '../device/device-id.js'\nimport { AuthorizationError } from '../errors/authorization-error.js'\nimport {\n ErrorPayload,\n buildErrorPayload,\n buildErrorStatus,\n} from '../errors/error-parser.js'\nimport { InvalidRequestError } from '../errors/invalid-request-error.js'\nimport { WWWAuthenticateError } from '../errors/www-authenticate-error.js'\nimport {\n JsonResponse,\n Middleware,\n RequestMetadata,\n Router,\n RouterCtx,\n SubCtx,\n flushStream,\n jsonHandler,\n parseHttpRequest,\n subCtx,\n validateFetchMode,\n validateFetchSite,\n validateOrigin,\n validateReferrer,\n} from '../lib/http/index.js'\nimport { RouteCtx, createRoute } from '../lib/http/route.js'\nimport { asArray } from '../lib/util/cast.js'\nimport { localeSchema } from '../lib/util/locale.js'\nimport type { Awaitable } from '../lib/util/type.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport { RequestUri, requestUriSchema } from '../request/request-uri.js'\nimport { AuthorizationRedirectParameters } from '../result/authorization-redirect-parameters.js'\nimport { tokenIdSchema } from '../token/token-id.js'\nimport { emailOtpSchema } from '../types/email-otp.js'\nimport { emailSchema } from '../types/email.js'\nimport { handleSchema } from '../types/handle.js'\nimport { newPasswordSchema, oldPasswordSchema } from '../types/password.js'\nimport { validateCsrfToken } from './assets/csrf.js'\nimport {\n ERROR_REDIRECT_KEYS,\n OAuthRedirectOptions,\n OAuthRedirectQueryParameter,\n SUCCESS_REDIRECT_KEYS,\n buildRedirectMode,\n buildRedirectParams,\n buildRedirectUri,\n} from './assets/send-redirect.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\nexport function createApiMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const issuerUrl = new URL(server.issuer)\n const issuerOrigin = issuerUrl.origin\n const router = new Router<Ctx, Req, Res>(issuerUrl)\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/verify-handle-availability',\n schema: z.object({ handle: handleSchema }).strict(),\n async handler() {\n await server.accountManager.verifyHandleAvailability(this.input.handle)\n return { json: { available: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/sign-up',\n schema: signUpInputSchema,\n rotateDeviceCookies: true,\n async handler() {\n const { deviceId, deviceMetadata, input, requestUri } = this\n\n const account = await server.accountManager.createAccount(\n deviceId,\n deviceMetadata,\n input,\n )\n\n // Remember when not in the context of a request by default\n const remember = requestUri == null\n\n // Only \"remember\" the newly created account if it was not created during an\n // OAuth flow.\n if (remember) {\n await server.accountManager.upsertDeviceAccount(deviceId, account.did)\n }\n\n const ephemeralToken = remember\n ? undefined\n : await server.signer.createEphemeralToken({\n sub: account.did,\n deviceId,\n requestUri: this.requestUri,\n })\n\n const json = { account, ephemeralToken }\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/sign-in',\n schema: signInDataSchema.extend({ remember: z.boolean().optional() }),\n rotateDeviceCookies: true,\n async handler() {\n const { deviceId, deviceMetadata, requestUri } = this\n\n // Remember when not in the context of a request by default\n const { remember = requestUri == null, ...input } = this.input\n\n // Look up the client identifier associated with the pending OAuth\n // request, if any, so it can be surfaced to the sign-in hooks.\n const clientId = requestUri\n ? await server.requestManager.peekClientId(requestUri)\n : undefined\n\n const account = await server.accountManager.authenticateAccount(\n deviceId,\n deviceMetadata,\n input,\n clientId,\n )\n\n if (remember) {\n await server.accountManager.upsertDeviceAccount(deviceId, account.did)\n } else {\n // In case the user was already signed in, and signed in again, this\n // time without \"remember me\", let's sign them off of the device.\n await server.accountManager.removeDeviceAccount(deviceId, account.did)\n }\n\n const ephemeralToken = remember\n ? undefined\n : await server.signer.createEphemeralToken({\n sub: account.did,\n deviceId,\n requestUri,\n })\n\n const json = { account, ephemeralToken }\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/sign-out',\n schema: z\n .object({\n did: z.union([didSchema, z.array(didSchema)]),\n })\n .strict(),\n rotateDeviceCookies: true,\n async handler() {\n const uniqueSubs = new Set(asArray(this.input.did))\n\n for (const sub of uniqueSubs) {\n await server.accountManager.removeDeviceAccount(this.deviceId, sub)\n }\n\n return { json: { success: true as const } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reset-password-request',\n schema: z\n .object({\n locale: localeSchema,\n email: emailSchema,\n })\n .strict(),\n async handler() {\n await server.accountManager.resetPasswordRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n )\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reset-password-confirm',\n schema: z\n .object({\n token: emailOtpSchema,\n password: newPasswordSchema,\n })\n .strict(),\n async handler() {\n await server.accountManager.resetPasswordConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n )\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/update-email-request',\n schema: z\n .object({\n did: didSchema,\n locale: localeSchema.optional(),\n })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const { tokenRequired } =\n await server.accountManager.updateEmailRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { tokenRequired } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/update-email-confirm',\n schema: z\n .object({\n did: didSchema,\n email: emailSchema,\n token: emailOtpSchema.optional(),\n locale: localeSchema.optional(),\n })\n .strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n account = await server.accountManager.updateEmailConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/verify-email-request',\n schema: z\n .object({\n did: didSchema,\n locale: localeSchema.optional(),\n })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n await server.accountManager.verifyEmailRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/verify-email-confirm',\n schema: z\n .object({\n did: didSchema,\n token: emailOtpSchema,\n email: emailSchema,\n })\n .strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n account = await server.accountManager.verifyEmailConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/update-handle',\n schema: z\n .object({\n did: didSchema,\n handle: handleSchema,\n })\n .strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n account = await server.accountManager.updateHandle(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/deactivate-account',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n if (!account.deactivated) {\n account = await server.accountManager.deactivateAccount(\n this.deviceId,\n this.deviceMetadata,\n account,\n )\n }\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reactivate-account',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n if (account.deactivated) {\n account = await server.accountManager.reactivateAccount(\n this.deviceId,\n this.deviceMetadata,\n account,\n )\n }\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/delete-account-request',\n schema: z\n .object({ did: didSchema, locale: localeSchema.optional() })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n await server.accountManager.deleteAccountRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/delete-account-confirm',\n schema: z\n .object({\n did: didSchema,\n token: emailOtpSchema,\n password: oldPasswordSchema,\n })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n await server.accountManager.deleteAccountConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'GET',\n endpoint: '/device-sessions',\n schema: undefined,\n async handler() {\n const deviceAccounts = await server.accountManager.listDeviceAccounts(\n this.deviceId,\n )\n\n const json = deviceAccounts.map(\n (deviceAccount): ActiveDeviceSession => ({\n account: deviceAccount.account,\n loginRequired: server.checkLoginRequired(deviceAccount),\n }),\n )\n\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'GET',\n endpoint: '/oauth-sessions',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const tokenInfos = await server.tokenManager.listAccountTokens(\n account.did,\n )\n\n const clientIds = tokenInfos.map((tokenInfo) => tokenInfo.data.clientId)\n\n const clients = await server.clientManager.loadClients(clientIds, {\n onError: (err, clientId) => {\n onError?.(req, res, err, `Failed to load client ${clientId}`)\n return undefined // metadata won't be available in the UI\n },\n })\n\n // @TODO: We should ideally filter sessions that are expired (or even\n // expose the expiration date). This requires a change to the way\n // TokenInfo are stored (see TokenManager#isTokenExpired and\n // TokenManager#isTokenInactive).\n const json = tokenInfos.map(({ id, data }): ActiveOAuthSession => {\n return {\n tokenId: id,\n\n createdAt: data.createdAt.toISOString() as ISODateString,\n updatedAt: data.updatedAt.toISOString() as ISODateString,\n\n clientId: data.clientId,\n clientMetadata: clients.get(data.clientId)?.metadata,\n\n scope: data.parameters.scope,\n }\n })\n\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'GET',\n endpoint: '/account-sessions',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const deviceAccounts = await server.accountManager.listAccountDevices(\n account.did,\n )\n\n const json = deviceAccounts.map(\n (accountSession): ActiveAccountSession => ({\n deviceId: accountSession.deviceId,\n deviceMetadata: {\n ipAddress: accountSession.deviceData.ipAddress,\n userAgent: accountSession.deviceData.userAgent,\n lastSeenAt:\n accountSession.deviceData.lastSeenAt.toISOString() as ISODateString,\n },\n\n isCurrentDevice: accountSession.deviceId === this.deviceId,\n }),\n )\n\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/revoke-account-session',\n schema: z.object({ did: didSchema, deviceId: deviceIdSchema }).strict(),\n async handler() {\n // @NOTE This route is not authenticated. If a user is able to steal\n // another user's session cookie, we allow them to revoke the device\n // session.\n\n await server.accountManager.removeDeviceAccount(\n this.input.deviceId,\n this.input.did,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/revoke-oauth-session',\n schema: z.object({ did: didSchema, tokenId: tokenIdSchema }).strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const tokenInfo = await server.tokenManager.getTokenInfo(\n this.input.tokenId,\n )\n\n if (!tokenInfo || tokenInfo.account.did !== account.did) {\n // report this as though the token was not found\n throw new InvalidRequestError(`Invalid token`)\n }\n\n await server.tokenManager.deleteToken(tokenInfo.id)\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/consent',\n schema: z\n .object({ did: didSchema, scope: oauthScopeSchema.optional() })\n .strict(),\n async handler(req, res) {\n if (!this.requestUri) {\n throw new InvalidRequestError(\n 'This endpoint can only be used in the context of an OAuth request',\n )\n }\n\n // Any AuthorizationError caught in this block will result in a redirect\n // to the client's redirect_uri with an error.\n try {\n const { clientId, parameters } = await server.requestManager.get(\n this.requestUri,\n this.deviceId,\n )\n\n // Any error thrown in this block will be transformed into an\n // AuthorizationError.\n try {\n const { account, authorizedClients } = await authenticate.call(\n this,\n req,\n res,\n )\n\n const client = await server.clientManager.getClient(clientId)\n\n const code = await server.requestManager.setAuthorized(\n this.requestUri,\n client,\n account,\n this.deviceId,\n this.deviceMetadata,\n this.input.scope,\n )\n\n const clientData = authorizedClients.get(clientId)\n if (server.checkConsentRequired(parameters, clientData)) {\n const scopes = new Set(clientData?.authorizedScopes)\n\n // Add the newly accepted scopes to the authorized scopes\n\n // @NOTE `oauthScopeSchema` ensures that `scope` contains no\n // leading/trailing/duplicate spaces.\n for (const s of parameters.scope?.split(' ') ?? []) scopes.add(s)\n\n await server.accountManager.setAuthorizedClient(account, client, {\n ...clientData,\n authorizedScopes: [...scopes],\n })\n }\n\n const url = buildRedirectUrl(server.issuer, parameters, { code })\n\n return { json: { url } }\n } catch (err) {\n // Since we have access to the parameters, we can re-throw an\n // AuthorizationError with the redirect_uri parameter.\n throw AuthorizationError.from(parameters, err)\n }\n } catch (err) {\n onError?.(req, res, err, 'Failed to consent authorization request')\n\n // If any error happened (unauthenticated, invalid request, etc.),\n // lets make sure the request can no longer be used.\n try {\n await server.requestManager.delete(this.requestUri)\n } catch (err) {\n onError?.(req, res, err, 'Failed to delete request')\n }\n\n if (err instanceof AuthorizationError) {\n try {\n const url = buildRedirectUrl(\n server.issuer,\n err.parameters,\n err.toJSON(),\n )\n\n return { json: { url } }\n } catch {\n // Unable to build redirect URL, ignore\n }\n }\n\n // @NOTE Not re-throwing the error here, as the error was already\n // handled by the `onError` callback, and apiRoute (`apiMiddleware`)\n // would call `onError` again.\n return buildErrorJsonResponse(err)\n }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reject',\n schema: z.object({}).strict(),\n rotateDeviceCookies: true,\n async handler(req, res) {\n const { requestUri } = this\n if (!requestUri) {\n throw new InvalidRequestError(\n 'This endpoint can only be used in the context of an OAuth request',\n )\n }\n\n // Once this endpoint is called, the request will definitely be\n // rejected.\n try {\n // No need to authenticate the user here as they are not authorizing a\n // particular account (CSRF protection is enough).\n\n // @NOTE that the client could *technically* trigger this endpoint while\n // the user is on the authorize page by forging the request (because the\n // client knows the RequestURI from PAR and has all the info needed to\n // forge the request, including CSRF). This cannot be used as DoS attack\n // as the request ID is not guessable and would only result in a bad UX\n // for misbehaving clients, only for the users of those clients.\n\n const { parameters } = await server.requestManager.get(\n requestUri,\n this.deviceId,\n )\n\n const url = buildRedirectUrl(server.issuer, parameters, {\n error: 'access_denied',\n error_description: 'The user rejected the request',\n })\n\n return { json: { url } }\n } catch (err) {\n onError?.(req, res, err, 'Failed to reject authorization request')\n\n if (err instanceof AuthorizationError) {\n try {\n const url = buildRedirectUrl(\n server.issuer,\n err.parameters,\n err.toJSON(),\n )\n\n return { json: { url } }\n } catch {\n // Unable to build redirect URL, ignore\n }\n }\n\n return buildErrorJsonResponse(err)\n } finally {\n await server.requestManager.delete(requestUri).catch((err) => {\n onError?.(req, res, err, 'Failed to delete request')\n })\n }\n },\n }),\n )\n\n return router.buildMiddleware()\n\n async function authenticate(\n this: ApiContext<void, { did: Did }>,\n req: Req,\n _res: Res,\n ) {\n if (req.headers.authorization?.startsWith('Bearer ')) {\n try {\n // If there is an authorization header, verify that the ephemeral token it\n // contains is a jwt bound to the right [sub, device, request].\n const bearer = req.headers.authorization.slice(7)\n const ephemeralToken = signedJwtSchema.parse(bearer)\n const { payload } =\n await server.signer.verifyEphemeralToken(ephemeralToken)\n\n if (\n payload.sub === this.input.did &&\n payload.deviceId === this.deviceId &&\n payload.requestUri === this.requestUri\n ) {\n return await server.accountManager.getAccount(payload.sub)\n }\n } catch (err) {\n throw new WWWAuthenticateError(\n 'unauthorized',\n `Invalid or expired bearer token`,\n { Bearer: {} },\n err,\n )\n }\n }\n\n try {\n // Ensures the \"sub\" has an active session on the device\n const deviceAccount = await server.accountManager.getDeviceAccount(\n this.deviceId,\n this.input.did,\n )\n\n // The session exists but was created too long ago\n if (server.checkLoginRequired(deviceAccount)) {\n throw new InvalidRequestError('Login required')\n }\n\n return deviceAccount\n } catch (err) {\n throw new WWWAuthenticateError(\n 'unauthorized',\n `User ${this.input.did} not authenticated on this device`,\n { Bearer: {} },\n err,\n )\n }\n }\n\n type ApiContext<T extends object | void, I = void> = SubCtx<\n T,\n {\n deviceId: DeviceId\n deviceMetadata: RequestMetadata\n\n /**\n * The parsed input data (json payload if \"POST\", query params if \"GET\").\n */\n input: I\n\n /**\n * When defined, the request originated from the authorize page.\n */\n requestUri?: RequestUri\n }\n >\n\n type InferValidation<S extends void | z.ZodTypeAny> = S extends z.ZodTypeAny\n ? z.infer<S>\n : void\n\n /**\n * The main purpose of this function is to ensure that the endpoint\n * implementation matches its type definition from {@link ApiEndpoints}.\n * @private\n */\n function apiRoute<\n C extends RouterCtx<Ctx>,\n M extends 'GET' | 'POST',\n E extends `/${string}` &\n // Extract all the endpoint path that match the method (allows for\n // auto-complete & better error reporting)\n {\n [E in keyof ApiEndpoints]: ApiEndpoints[E] extends { method: M }\n ? E\n : never\n }[keyof ApiEndpoints],\n S extends // A schema that validates the POST input or GET params\n ApiEndpoints[E] extends { method: 'POST'; input: infer I }\n ? z.ZodType<I, z.ZodTypeDef, unknown>\n : ApiEndpoints[E] extends { method: 'GET'; params: infer P }\n ? z.ZodType<P, z.ZodTypeDef, unknown>\n : void,\n >(options: {\n method: M\n endpoint: E\n schema: S\n rotateDeviceCookies?: boolean\n handler: (\n this: ApiContext<RouteCtx<C>, InferValidation<S>>,\n req: Req,\n res: Res,\n ) => Awaitable<JsonResponse<ErrorPayload | ApiEndpoints[E]['output']>>\n }): Middleware<C, Req, Res> {\n return createRoute(\n options.method,\n `${API_ENDPOINT_PREFIX}${options.endpoint}`,\n apiMiddleware(options),\n )\n }\n\n function apiMiddleware<C extends RouterCtx, S extends void | z.ZodTypeAny>({\n method,\n schema,\n rotateDeviceCookies,\n handler,\n }: {\n method: 'GET' | 'POST'\n schema: S\n rotateDeviceCookies?: boolean\n handler: (\n this: ApiContext<C, InferValidation<S>>,\n req: Req,\n res: Res,\n ) => Awaitable<JsonResponse>\n }): Middleware<C, Req, Res> {\n const parseInput: (this: C, req: Req) => Promise<InferValidation<S>> =\n schema == null // No schema means endpoint doesn't accept any input\n ? async function (req) {\n await flushStream(req)\n return undefined\n }\n : method === 'POST'\n ? async function (req) {\n const body = await parseHttpRequest(req, ['json'])\n return schema.parseAsync(body, { path: ['body'] })\n }\n : async function (req) {\n await flushStream(req)\n const query = Object.fromEntries(this.url.searchParams)\n return schema.parseAsync(query, { path: ['query'] })\n }\n\n return jsonHandler<C, Req, Res>(async function (req, res) {\n try {\n // Prevent caching of API routes\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n // Prevent CORS requests\n validateFetchMode(req, ['same-origin'])\n validateFetchSite(req, ['same-origin'])\n validateOrigin(req, issuerOrigin)\n const referrer = validateReferrer(req, { origin: issuerOrigin })\n\n // Ensure we are one the right page\n if (\n // trailing slashes are not allowed\n referrer.pathname !== '/oauth/authorize' &&\n referrer.pathname !== '/account' &&\n !referrer.pathname.startsWith(`/account/`)\n ) {\n throw createHttpError(400, `Invalid referrer ${referrer}`)\n }\n\n // Check if the request originated from the authorize page\n const requestUri =\n referrer.pathname === '/oauth/authorize'\n ? await requestUriSchema.parseAsync(\n referrer.searchParams.get('request_uri'),\n )\n : undefined\n\n // Validate CSRF token\n await validateCsrfToken(req, res)\n\n // Parse and validate the input data\n const input = await parseInput.call(this, req)\n\n // Load session data, rotating the session cookie if needed\n const { deviceId, deviceMetadata } = await server.deviceManager.load(\n req,\n res,\n rotateDeviceCookies,\n )\n\n const context: ApiContext<C, InferValidation<S>> = subCtx(this, {\n input,\n requestUri,\n deviceId,\n deviceMetadata,\n })\n\n return await handler.call(context, req, res)\n } catch (err) {\n onError?.(req, res, err, `Failed to handle API request`)\n\n // Make sore to always return a JSON response\n return buildErrorJsonResponse(err)\n }\n })\n }\n}\n\nfunction buildErrorJsonResponse(err: unknown) {\n // @TODO Rework the API error responses (relying on codes)\n const json = buildErrorPayload(err)\n const status = buildErrorStatus(err)\n\n return { json, status }\n}\n\nfunction buildRedirectUrl(\n iss: string,\n parameters: OAuthAuthorizationRequestParameters,\n redirect: AuthorizationRedirectParameters,\n): string {\n const url = new URL('/oauth/authorize/redirect', iss)\n\n url.searchParams.set('redirect_mode', buildRedirectMode(parameters))\n url.searchParams.set('redirect_uri', buildRedirectUri(parameters))\n\n for (const [key, value] of buildRedirectParams(iss, parameters, redirect)) {\n url.searchParams.set(key, value)\n }\n\n return url.href\n}\n\nexport function parseRedirectUrl(url: URL): OAuthRedirectOptions {\n if (url.pathname !== '/oauth/authorize/redirect') {\n throw new InvalidRequestError(\n `Invalid redirect URL: ${url.pathname} is not a valid path`,\n )\n }\n\n const params: [OAuthRedirectQueryParameter, string][] = []\n\n const state = url.searchParams.get('state')\n if (state) params.push(['state', state])\n\n const iss = url.searchParams.get('iss')\n if (iss) params.push(['iss', iss])\n\n if (url.searchParams.has('code')) {\n for (const key of SUCCESS_REDIRECT_KEYS) {\n const value = url.searchParams.get(key)\n if (value != null) params.push([key, value])\n }\n } else if (url.searchParams.has('error')) {\n for (const key of ERROR_REDIRECT_KEYS) {\n const value = url.searchParams.get(key)\n if (value != null) params.push([key, value])\n }\n } else {\n throw new InvalidRequestError(\n 'Invalid redirect URL: neither code nor error found',\n )\n }\n\n try {\n const mode: OAuthResponseMode = oauthResponseModeSchema.parse(\n url.searchParams.get('redirect_mode'),\n )\n\n const redirectUri: OAuthRedirectUri = oauthRedirectUriSchema.parse(\n url.searchParams.get('redirect_uri'),\n )\n\n return { mode, redirectUri, params }\n } catch (err) {\n throw InvalidRequestError.from(err, 'Invalid redirect URL')\n }\n}\n"]}
1
+ {"version":3,"file":"create-api-middleware.js","sourceRoot":"","sources":["../../src/router/create-api-middleware.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAY,SAAS,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAQ9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAIL,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAiB,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAIL,MAAM,EAGN,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAiB,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,EAAmB,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACp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KAAK,CAChE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CACrC,CAAA;QAED,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,mBAAmB,CAAC,IAAI,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport createHttpError from 'http-errors'\nimport { z } from 'zod'\nimport { type Did, didSchema } from '@atproto/did'\nimport { signedJwtSchema } from '@atproto/jwk'\nimport type {\n ActiveAccountSession,\n ActiveDeviceSession,\n ActiveOAuthSession,\n ApiEndpoints,\n ISODateString,\n} from '@atproto/oauth-provider-api'\nimport { API_ENDPOINT_PREFIX } from '@atproto/oauth-provider-api'\nimport {\n type OAuthAuthorizationRequestParameters,\n type OAuthRedirectUri,\n type OAuthResponseMode,\n oauthRedirectUriSchema,\n oauthResponseModeSchema,\n oauthScopeSchema,\n} from '@atproto/oauth-types'\nimport { signInDataSchema } from '../account/sign-in-data.js'\nimport { signUpInputSchema } from '../account/sign-up-input.js'\nimport { type DeviceId, deviceIdSchema } from '../device/device-id.js'\nimport { AuthorizationError } from '../errors/authorization-error.js'\nimport {\n type ErrorPayload,\n buildErrorPayload,\n buildErrorStatus,\n} from '../errors/error-parser.js'\nimport { InvalidRequestError } from '../errors/invalid-request-error.js'\nimport { WWWAuthenticateError } from '../errors/www-authenticate-error.js'\nimport {\n type JsonResponse,\n type Middleware,\n type RequestMetadata,\n Router,\n type RouterCtx,\n type SubCtx,\n flushStream,\n jsonHandler,\n parseHttpRequest,\n subCtx,\n validateFetchMode,\n validateFetchSite,\n validateOrigin,\n validateReferrer,\n} from '../lib/http/index.js'\nimport { type RouteCtx, createRoute } from '../lib/http/route.js'\nimport { asArray } from '../lib/util/cast.js'\nimport { localeSchema } from '../lib/util/locale.js'\nimport type { Awaitable } from '../lib/util/type.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport { type RequestUri, requestUriSchema } from '../request/request-uri.js'\nimport type { AuthorizationRedirectParameters } from '../result/authorization-redirect-parameters.js'\nimport { tokenIdSchema } from '../token/token-id.js'\nimport { emailOtpSchema } from '../types/email-otp.js'\nimport { emailSchema } from '../types/email.js'\nimport { handleSchema } from '../types/handle.js'\nimport { newPasswordSchema, oldPasswordSchema } from '../types/password.js'\nimport { validateCsrfToken } from './assets/csrf.js'\nimport {\n ERROR_REDIRECT_KEYS,\n type OAuthRedirectOptions,\n type OAuthRedirectQueryParameter,\n SUCCESS_REDIRECT_KEYS,\n buildRedirectMode,\n buildRedirectParams,\n buildRedirectUri,\n} from './assets/send-redirect.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\nexport function createApiMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const issuerUrl = new URL(server.issuer)\n const issuerOrigin = issuerUrl.origin\n const router = new Router<Ctx, Req, Res>(issuerUrl)\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/verify-handle-availability',\n schema: z.object({ handle: handleSchema }).strict(),\n async handler() {\n await server.accountManager.verifyHandleAvailability(this.input.handle)\n return { json: { available: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/sign-up',\n schema: signUpInputSchema,\n rotateDeviceCookies: true,\n async handler() {\n const { deviceId, deviceMetadata, input, requestUri } = this\n\n const account = await server.accountManager.createAccount(\n deviceId,\n deviceMetadata,\n input,\n )\n\n // Remember when not in the context of a request by default\n const remember = requestUri == null\n\n // Only \"remember\" the newly created account if it was not created during an\n // OAuth flow.\n if (remember) {\n await server.accountManager.upsertDeviceAccount(deviceId, account.did)\n }\n\n const ephemeralToken = remember\n ? undefined\n : await server.signer.createEphemeralToken({\n sub: account.did,\n deviceId,\n requestUri: this.requestUri,\n })\n\n const json = { account, ephemeralToken }\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/sign-in',\n schema: signInDataSchema.extend({ remember: z.boolean().optional() }),\n rotateDeviceCookies: true,\n async handler() {\n const { deviceId, deviceMetadata, requestUri } = this\n\n // Remember when not in the context of a request by default\n const { remember = requestUri == null, ...input } = this.input\n\n // Look up the client identifier associated with the pending OAuth\n // request, if any, so it can be surfaced to the sign-in hooks.\n const clientId = requestUri\n ? await server.requestManager.peekClientId(requestUri)\n : undefined\n\n const account = await server.accountManager.authenticateAccount(\n deviceId,\n deviceMetadata,\n input,\n clientId,\n )\n\n if (remember) {\n await server.accountManager.upsertDeviceAccount(deviceId, account.did)\n } else {\n // In case the user was already signed in, and signed in again, this\n // time without \"remember me\", let's sign them off of the device.\n await server.accountManager.removeDeviceAccount(deviceId, account.did)\n }\n\n const ephemeralToken = remember\n ? undefined\n : await server.signer.createEphemeralToken({\n sub: account.did,\n deviceId,\n requestUri,\n })\n\n const json = { account, ephemeralToken }\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/sign-out',\n schema: z\n .object({\n did: z.union([didSchema, z.array(didSchema)]),\n })\n .strict(),\n rotateDeviceCookies: true,\n async handler() {\n const uniqueSubs = new Set(asArray(this.input.did))\n\n for (const sub of uniqueSubs) {\n await server.accountManager.removeDeviceAccount(this.deviceId, sub)\n }\n\n return { json: { success: true as const } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reset-password-request',\n schema: z\n .object({\n locale: localeSchema,\n email: emailSchema,\n })\n .strict(),\n async handler() {\n await server.accountManager.resetPasswordRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n )\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reset-password-confirm',\n schema: z\n .object({\n token: emailOtpSchema,\n password: newPasswordSchema,\n })\n .strict(),\n async handler() {\n await server.accountManager.resetPasswordConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n )\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/update-email-request',\n schema: z\n .object({\n did: didSchema,\n locale: localeSchema.optional(),\n })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const { tokenRequired } =\n await server.accountManager.updateEmailRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { tokenRequired } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/update-email-confirm',\n schema: z\n .object({\n did: didSchema,\n email: emailSchema,\n token: emailOtpSchema.optional(),\n locale: localeSchema.optional(),\n })\n .strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n account = await server.accountManager.updateEmailConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/verify-email-request',\n schema: z\n .object({\n did: didSchema,\n locale: localeSchema.optional(),\n })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n await server.accountManager.verifyEmailRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/verify-email-confirm',\n schema: z\n .object({\n did: didSchema,\n token: emailOtpSchema,\n email: emailSchema,\n })\n .strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n account = await server.accountManager.verifyEmailConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/update-handle',\n schema: z\n .object({\n did: didSchema,\n handle: handleSchema,\n })\n .strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n account = await server.accountManager.updateHandle(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/deactivate-account',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n if (!account.deactivated) {\n account = await server.accountManager.deactivateAccount(\n this.deviceId,\n this.deviceMetadata,\n account,\n )\n }\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reactivate-account',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n let { account } = await authenticate.call(this, req, res)\n\n if (account.deactivated) {\n account = await server.accountManager.reactivateAccount(\n this.deviceId,\n this.deviceMetadata,\n account,\n )\n }\n\n return { json: { account } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/delete-account-request',\n schema: z\n .object({ did: didSchema, locale: localeSchema.optional() })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n await server.accountManager.deleteAccountRequest(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/delete-account-confirm',\n schema: z\n .object({\n did: didSchema,\n token: emailOtpSchema,\n password: oldPasswordSchema,\n })\n .strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n await server.accountManager.deleteAccountConfirm(\n this.deviceId,\n this.deviceMetadata,\n this.input,\n account,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'GET',\n endpoint: '/device-sessions',\n schema: undefined,\n async handler() {\n const deviceAccounts = await server.accountManager.listDeviceAccounts(\n this.deviceId,\n )\n\n const json = deviceAccounts.map(\n (deviceAccount): ActiveDeviceSession => ({\n account: deviceAccount.account,\n loginRequired: server.checkLoginRequired(deviceAccount),\n }),\n )\n\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'GET',\n endpoint: '/oauth-sessions',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const tokenInfos = await server.tokenManager.listAccountTokens(\n account.did,\n )\n\n const clientIds = tokenInfos.map((tokenInfo) => tokenInfo.data.clientId)\n\n const clients = await server.clientManager.loadClients(clientIds, {\n onError: (err, clientId) => {\n onError?.(req, res, err, `Failed to load client ${clientId}`)\n return undefined // metadata won't be available in the UI\n },\n })\n\n // @TODO: We should ideally filter sessions that are expired (or even\n // expose the expiration date). This requires a change to the way\n // TokenInfo are stored (see TokenManager#isTokenExpired and\n // TokenManager#isTokenInactive).\n const json = tokenInfos.map(({ id, data }): ActiveOAuthSession => {\n return {\n tokenId: id,\n\n createdAt: data.createdAt.toISOString() as ISODateString,\n updatedAt: data.updatedAt.toISOString() as ISODateString,\n\n clientId: data.clientId,\n clientMetadata: clients.get(data.clientId)?.metadata,\n\n scope: data.parameters.scope,\n }\n })\n\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'GET',\n endpoint: '/account-sessions',\n schema: z.object({ did: didSchema }).strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const deviceAccounts = await server.accountManager.listAccountDevices(\n account.did,\n )\n\n const json = deviceAccounts.map(\n (accountSession): ActiveAccountSession => ({\n deviceId: accountSession.deviceId,\n deviceMetadata: {\n ipAddress: accountSession.deviceData.ipAddress,\n userAgent: accountSession.deviceData.userAgent,\n lastSeenAt:\n accountSession.deviceData.lastSeenAt.toISOString() as ISODateString,\n },\n\n isCurrentDevice: accountSession.deviceId === this.deviceId,\n }),\n )\n\n return { json }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/revoke-account-session',\n schema: z.object({ did: didSchema, deviceId: deviceIdSchema }).strict(),\n async handler() {\n // @NOTE This route is not authenticated. If a user is able to steal\n // another user's session cookie, we allow them to revoke the device\n // session.\n\n await server.accountManager.removeDeviceAccount(\n this.input.deviceId,\n this.input.did,\n )\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/revoke-oauth-session',\n schema: z.object({ did: didSchema, tokenId: tokenIdSchema }).strict(),\n async handler(req, res) {\n const { account } = await authenticate.call(this, req, res)\n\n const tokenInfo = await server.tokenManager.getTokenInfo(\n this.input.tokenId,\n )\n\n if (!tokenInfo || tokenInfo.account.did !== account.did) {\n // report this as though the token was not found\n throw new InvalidRequestError(`Invalid token`)\n }\n\n await server.tokenManager.deleteToken(tokenInfo.id)\n\n return { json: { success: true } }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/consent',\n schema: z\n .object({ did: didSchema, scope: oauthScopeSchema.optional() })\n .strict(),\n async handler(req, res) {\n if (!this.requestUri) {\n throw new InvalidRequestError(\n 'This endpoint can only be used in the context of an OAuth request',\n )\n }\n\n // Any AuthorizationError caught in this block will result in a redirect\n // to the client's redirect_uri with an error.\n try {\n const { clientId, parameters } = await server.requestManager.get(\n this.requestUri,\n this.deviceId,\n )\n\n // Any error thrown in this block will be transformed into an\n // AuthorizationError.\n try {\n const { account, authorizedClients } = await authenticate.call(\n this,\n req,\n res,\n )\n\n const client = await server.clientManager.getClient(clientId)\n\n const code = await server.requestManager.setAuthorized(\n this.requestUri,\n client,\n account,\n this.deviceId,\n this.deviceMetadata,\n this.input.scope,\n )\n\n const clientData = authorizedClients.get(clientId)\n if (server.checkConsentRequired(parameters, clientData)) {\n const scopes = new Set(clientData?.authorizedScopes)\n\n // Add the newly accepted scopes to the authorized scopes\n\n // @NOTE `oauthScopeSchema` ensures that `scope` contains no\n // leading/trailing/duplicate spaces.\n for (const s of parameters.scope?.split(' ') ?? []) scopes.add(s)\n\n await server.accountManager.setAuthorizedClient(account, client, {\n ...clientData,\n authorizedScopes: [...scopes],\n })\n }\n\n const url = buildRedirectUrl(server.issuer, parameters, { code })\n\n return { json: { url } }\n } catch (err) {\n // Since we have access to the parameters, we can re-throw an\n // AuthorizationError with the redirect_uri parameter.\n throw AuthorizationError.from(parameters, err)\n }\n } catch (err) {\n onError?.(req, res, err, 'Failed to consent authorization request')\n\n // If any error happened (unauthenticated, invalid request, etc.),\n // lets make sure the request can no longer be used.\n try {\n await server.requestManager.delete(this.requestUri)\n } catch (err) {\n onError?.(req, res, err, 'Failed to delete request')\n }\n\n if (err instanceof AuthorizationError) {\n try {\n const url = buildRedirectUrl(\n server.issuer,\n err.parameters,\n err.toJSON(),\n )\n\n return { json: { url } }\n } catch {\n // Unable to build redirect URL, ignore\n }\n }\n\n // @NOTE Not re-throwing the error here, as the error was already\n // handled by the `onError` callback, and apiRoute (`apiMiddleware`)\n // would call `onError` again.\n return buildErrorJsonResponse(err)\n }\n },\n }),\n )\n\n router.use(\n apiRoute({\n method: 'POST',\n endpoint: '/reject',\n schema: z.object({}).strict(),\n rotateDeviceCookies: true,\n async handler(req, res) {\n const { requestUri } = this\n if (!requestUri) {\n throw new InvalidRequestError(\n 'This endpoint can only be used in the context of an OAuth request',\n )\n }\n\n // Once this endpoint is called, the request will definitely be\n // rejected.\n try {\n // No need to authenticate the user here as they are not authorizing a\n // particular account (CSRF protection is enough).\n\n // @NOTE that the client could *technically* trigger this endpoint while\n // the user is on the authorize page by forging the request (because the\n // client knows the RequestURI from PAR and has all the info needed to\n // forge the request, including CSRF). This cannot be used as DoS attack\n // as the request ID is not guessable and would only result in a bad UX\n // for misbehaving clients, only for the users of those clients.\n\n const { parameters } = await server.requestManager.get(\n requestUri,\n this.deviceId,\n )\n\n const url = buildRedirectUrl(server.issuer, parameters, {\n error: 'access_denied',\n error_description: 'The user rejected the request',\n })\n\n return { json: { url } }\n } catch (err) {\n onError?.(req, res, err, 'Failed to reject authorization request')\n\n if (err instanceof AuthorizationError) {\n try {\n const url = buildRedirectUrl(\n server.issuer,\n err.parameters,\n err.toJSON(),\n )\n\n return { json: { url } }\n } catch {\n // Unable to build redirect URL, ignore\n }\n }\n\n return buildErrorJsonResponse(err)\n } finally {\n await server.requestManager.delete(requestUri).catch((err) => {\n onError?.(req, res, err, 'Failed to delete request')\n })\n }\n },\n }),\n )\n\n return router.buildMiddleware()\n\n async function authenticate(\n this: ApiContext<void, { did: Did }>,\n req: Req,\n _res: Res,\n ) {\n if (req.headers.authorization?.startsWith('Bearer ')) {\n try {\n // If there is an authorization header, verify that the ephemeral token it\n // contains is a jwt bound to the right [sub, device, request].\n const bearer = req.headers.authorization.slice(7)\n const ephemeralToken = signedJwtSchema.parse(bearer)\n const { payload } =\n await server.signer.verifyEphemeralToken(ephemeralToken)\n\n if (\n payload.sub === this.input.did &&\n payload.deviceId === this.deviceId &&\n payload.requestUri === this.requestUri\n ) {\n return await server.accountManager.getAccount(payload.sub)\n }\n } catch (err) {\n throw new WWWAuthenticateError(\n 'unauthorized',\n `Invalid or expired bearer token`,\n { Bearer: {} },\n err,\n )\n }\n }\n\n try {\n // Ensures the \"sub\" has an active session on the device\n const deviceAccount = await server.accountManager.getDeviceAccount(\n this.deviceId,\n this.input.did,\n )\n\n // The session exists but was created too long ago\n if (server.checkLoginRequired(deviceAccount)) {\n throw new InvalidRequestError('Login required')\n }\n\n return deviceAccount\n } catch (err) {\n throw new WWWAuthenticateError(\n 'unauthorized',\n `User ${this.input.did} not authenticated on this device`,\n { Bearer: {} },\n err,\n )\n }\n }\n\n type ApiContext<T extends object | void, I = void> = SubCtx<\n T,\n {\n deviceId: DeviceId\n deviceMetadata: RequestMetadata\n\n /**\n * The parsed input data (json payload if \"POST\", query params if \"GET\").\n */\n input: I\n\n /**\n * When defined, the request originated from the authorize page.\n */\n requestUri?: RequestUri\n }\n >\n\n type InferValidation<S extends void | z.ZodTypeAny> = S extends z.ZodTypeAny\n ? z.infer<S>\n : void\n\n /**\n * The main purpose of this function is to ensure that the endpoint\n * implementation matches its type definition from {@link ApiEndpoints}.\n * @private\n */\n function apiRoute<\n C extends RouterCtx<Ctx>,\n M extends 'GET' | 'POST',\n E extends `/${string}` &\n // Extract all the endpoint path that match the method (allows for\n // auto-complete & better error reporting)\n {\n [E in keyof ApiEndpoints]: ApiEndpoints[E] extends { method: M }\n ? E\n : never\n }[keyof ApiEndpoints],\n S extends // A schema that validates the POST input or GET params\n ApiEndpoints[E] extends { method: 'POST'; input: infer I }\n ? z.ZodType<I, z.ZodTypeDef, unknown>\n : ApiEndpoints[E] extends { method: 'GET'; params: infer P }\n ? z.ZodType<P, z.ZodTypeDef, unknown>\n : void,\n >(options: {\n method: M\n endpoint: E\n schema: S\n rotateDeviceCookies?: boolean\n handler: (\n this: ApiContext<RouteCtx<C>, InferValidation<S>>,\n req: Req,\n res: Res,\n ) => Awaitable<JsonResponse<ErrorPayload | ApiEndpoints[E]['output']>>\n }): Middleware<C, Req, Res> {\n return createRoute(\n options.method,\n `${API_ENDPOINT_PREFIX}${options.endpoint}`,\n apiMiddleware(options),\n )\n }\n\n function apiMiddleware<C extends RouterCtx, S extends void | z.ZodTypeAny>({\n method,\n schema,\n rotateDeviceCookies,\n handler,\n }: {\n method: 'GET' | 'POST'\n schema: S\n rotateDeviceCookies?: boolean\n handler: (\n this: ApiContext<C, InferValidation<S>>,\n req: Req,\n res: Res,\n ) => Awaitable<JsonResponse>\n }): Middleware<C, Req, Res> {\n const parseInput: (this: C, req: Req) => Promise<InferValidation<S>> =\n schema == null // No schema means endpoint doesn't accept any input\n ? async function (req) {\n await flushStream(req)\n return undefined\n }\n : method === 'POST'\n ? async function (req) {\n const body = await parseHttpRequest(req, ['json'])\n return schema.parseAsync(body, { path: ['body'] })\n }\n : async function (req) {\n await flushStream(req)\n const query = Object.fromEntries(this.url.searchParams)\n return schema.parseAsync(query, { path: ['query'] })\n }\n\n return jsonHandler<C, Req, Res>(async function (req, res) {\n try {\n // Prevent caching of API routes\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n // Prevent CORS requests\n validateFetchMode(req, ['same-origin'])\n validateFetchSite(req, ['same-origin'])\n validateOrigin(req, issuerOrigin)\n const referrer = validateReferrer(req, { origin: issuerOrigin })\n\n // Ensure we are one the right page\n if (\n // trailing slashes are not allowed\n referrer.pathname !== '/oauth/authorize' &&\n referrer.pathname !== '/account' &&\n !referrer.pathname.startsWith(`/account/`)\n ) {\n throw createHttpError(400, `Invalid referrer ${referrer}`)\n }\n\n // Check if the request originated from the authorize page\n const requestUri =\n referrer.pathname === '/oauth/authorize'\n ? await requestUriSchema.parseAsync(\n referrer.searchParams.get('request_uri'),\n )\n : undefined\n\n // Validate CSRF token\n await validateCsrfToken(req, res)\n\n // Parse and validate the input data\n const input = await parseInput.call(this, req)\n\n // Load session data, rotating the session cookie if needed\n const { deviceId, deviceMetadata } = await server.deviceManager.load(\n req,\n res,\n rotateDeviceCookies,\n )\n\n const context: ApiContext<C, InferValidation<S>> = subCtx(this, {\n input,\n requestUri,\n deviceId,\n deviceMetadata,\n })\n\n return await handler.call(context, req, res)\n } catch (err) {\n onError?.(req, res, err, `Failed to handle API request`)\n\n // Make sore to always return a JSON response\n return buildErrorJsonResponse(err)\n }\n })\n }\n}\n\nfunction buildErrorJsonResponse(err: unknown) {\n // @TODO Rework the API error responses (relying on codes)\n const json = buildErrorPayload(err)\n const status = buildErrorStatus(err)\n\n return { json, status }\n}\n\nfunction buildRedirectUrl(\n iss: string,\n parameters: OAuthAuthorizationRequestParameters,\n redirect: AuthorizationRedirectParameters,\n): string {\n const url = new URL('/oauth/authorize/redirect', iss)\n\n url.searchParams.set('redirect_mode', buildRedirectMode(parameters))\n url.searchParams.set('redirect_uri', buildRedirectUri(parameters))\n\n for (const [key, value] of buildRedirectParams(iss, parameters, redirect)) {\n url.searchParams.set(key, value)\n }\n\n return url.href\n}\n\nexport function parseRedirectUrl(url: URL): OAuthRedirectOptions {\n if (url.pathname !== '/oauth/authorize/redirect') {\n throw new InvalidRequestError(\n `Invalid redirect URL: ${url.pathname} is not a valid path`,\n )\n }\n\n const params: [OAuthRedirectQueryParameter, string][] = []\n\n const state = url.searchParams.get('state')\n if (state) params.push(['state', state])\n\n const iss = url.searchParams.get('iss')\n if (iss) params.push(['iss', iss])\n\n if (url.searchParams.has('code')) {\n for (const key of SUCCESS_REDIRECT_KEYS) {\n const value = url.searchParams.get(key)\n if (value != null) params.push([key, value])\n }\n } else if (url.searchParams.has('error')) {\n for (const key of ERROR_REDIRECT_KEYS) {\n const value = url.searchParams.get(key)\n if (value != null) params.push([key, value])\n }\n } else {\n throw new InvalidRequestError(\n 'Invalid redirect URL: neither code nor error found',\n )\n }\n\n try {\n const mode: OAuthResponseMode = oauthResponseModeSchema.parse(\n url.searchParams.get('redirect_mode'),\n )\n\n const redirectUri: OAuthRedirectUri = oauthRedirectUriSchema.parse(\n url.searchParams.get('redirect_uri'),\n )\n\n return { mode, redirectUri, params }\n } catch (err) {\n throw InvalidRequestError.from(err, 'Invalid redirect URL')\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Middleware } from '../lib/http/index.js';
2
+ import { type Middleware } from '../lib/http/index.js';
3
3
  import type { OAuthProvider } from '../oauth-provider.js';
4
4
  import type { MiddlewareOptions } from './middleware-options.js';
5
5
  export declare function createAuthorizationPageMiddleware<Ctx extends object | void = void, Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse>(server: OAuthProvider, { onError }: MiddlewareOptions<Req, Res>): Middleware<Ctx, Req, Res>;
@@ -1 +1 @@
1
- {"version":3,"file":"create-authorization-page-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-authorization-page-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAOhE,OAAO,EACL,UAAU,EAUX,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAUzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,wBAAgB,iCAAiC,CAC/C,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CA6N3B"}
1
+ {"version":3,"file":"create-authorization-page-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-authorization-page-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAOhE,OAAO,EACL,KAAK,UAAU,EAUhB,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAUzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,wBAAgB,iCAAiC,CAC/C,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CA6N3B"}