@payloadcms/figma 0.0.1-alpha.42 → 0.0.1-alpha.6

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 (286) hide show
  1. package/dist/api/control-plane.d.ts +1 -22
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +22 -55
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +21 -45
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/callback-server.d.ts.map +1 -1
  9. package/dist/auth/callback-server.js +1 -2
  10. package/dist/auth/callback-server.js.map +1 -1
  11. package/dist/auth/crypto-utils.d.ts.map +1 -1
  12. package/dist/auth/crypto-utils.js +5 -5
  13. package/dist/auth/crypto-utils.js.map +1 -1
  14. package/dist/auth/jwt-validator.d.ts +1 -2
  15. package/dist/auth/jwt-validator.d.ts.map +1 -1
  16. package/dist/auth/jwt-validator.js +2 -2
  17. package/dist/auth/jwt-validator.js.map +1 -1
  18. package/dist/auth/oauth-flow.d.ts +1 -1
  19. package/dist/auth/oauth-flow.d.ts.map +1 -1
  20. package/dist/auth/oauth-flow.js +11 -15
  21. package/dist/auth/oauth-flow.js.map +1 -1
  22. package/dist/auth/project-token.d.ts.map +1 -1
  23. package/dist/auth/project-token.js +4 -9
  24. package/dist/auth/project-token.js.map +1 -1
  25. package/dist/auth/refresh.d.ts +1 -2
  26. package/dist/auth/refresh.d.ts.map +1 -1
  27. package/dist/auth/refresh.js +12 -25
  28. package/dist/auth/refresh.js.map +1 -1
  29. package/dist/auth/token-store.d.ts +0 -12
  30. package/dist/auth/token-store.d.ts.map +1 -1
  31. package/dist/auth/token-store.js +5 -28
  32. package/dist/auth/token-store.js.map +1 -1
  33. package/dist/auth/types.d.ts +4 -7
  34. package/dist/auth/types.d.ts.map +1 -1
  35. package/dist/auth/types.js.map +1 -1
  36. package/dist/cli.d.ts.map +1 -1
  37. package/dist/cli.js +6 -39
  38. package/dist/cli.js.map +1 -1
  39. package/dist/commands/deploy.d.ts +0 -4
  40. package/dist/commands/deploy.d.ts.map +1 -1
  41. package/dist/commands/deploy.js +129 -72
  42. package/dist/commands/deploy.js.map +1 -1
  43. package/dist/commands/init.d.ts +5 -1
  44. package/dist/commands/init.d.ts.map +1 -1
  45. package/dist/commands/init.js +85 -105
  46. package/dist/commands/init.js.map +1 -1
  47. package/dist/commands/list-tokens.d.ts +3 -3
  48. package/dist/commands/list-tokens.d.ts.map +1 -1
  49. package/dist/commands/list-tokens.js +7 -22
  50. package/dist/commands/list-tokens.js.map +1 -1
  51. package/dist/commands/login.d.ts +1 -8
  52. package/dist/commands/login.d.ts.map +1 -1
  53. package/dist/commands/login.js +12 -30
  54. package/dist/commands/login.js.map +1 -1
  55. package/dist/commands/logout.d.ts +4 -5
  56. package/dist/commands/logout.d.ts.map +1 -1
  57. package/dist/commands/logout.js +13 -56
  58. package/dist/commands/logout.js.map +1 -1
  59. package/dist/config/oauth.d.ts +14 -4
  60. package/dist/config/oauth.d.ts.map +1 -1
  61. package/dist/config/oauth.js +40 -19
  62. package/dist/config/oauth.js.map +1 -1
  63. package/dist/constants.d.ts +18 -26
  64. package/dist/constants.d.ts.map +1 -1
  65. package/dist/constants.js +20 -34
  66. package/dist/constants.js.map +1 -1
  67. package/dist/exports/client.d.ts +0 -1
  68. package/dist/exports/client.d.ts.map +1 -1
  69. package/dist/exports/client.js +0 -1
  70. package/dist/exports/client.js.map +1 -1
  71. package/dist/index.d.ts +1 -2
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +1 -3
  74. package/dist/index.js.map +1 -1
  75. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  76. package/dist/oauth/components/LoginButton/index.js +6 -50
  77. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  78. package/dist/oauth/components/LoginButton/index.scss +3 -50
  79. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  80. package/dist/oauth/components/LogoutButton/index.js +4 -5
  81. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  82. package/dist/oauth/defaults.d.ts.map +1 -1
  83. package/dist/oauth/defaults.js +5 -29
  84. package/dist/oauth/defaults.js.map +1 -1
  85. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  86. package/dist/oauth/endpoints/getLoginEndpoint.js +11 -21
  87. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  88. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -1
  89. package/dist/oauth/endpoints/getLogoutEndpoint.js +4 -7
  90. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -1
  91. package/dist/oauth/index.d.ts.map +1 -1
  92. package/dist/oauth/index.js +13 -40
  93. package/dist/oauth/index.js.map +1 -1
  94. package/dist/oauth/strategy/index.d.ts +2 -0
  95. package/dist/oauth/strategy/index.d.ts.map +1 -1
  96. package/dist/oauth/strategy/index.js +15 -38
  97. package/dist/oauth/strategy/index.js.map +1 -1
  98. package/dist/oauth/types.d.ts +6 -6
  99. package/dist/oauth/types.d.ts.map +1 -1
  100. package/dist/oauth/types.js.map +1 -1
  101. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  102. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  103. package/dist/oauth/utilities/getAdminPath.d.ts +8 -0
  104. package/dist/oauth/utilities/getAdminPath.d.ts.map +1 -0
  105. package/dist/oauth/utilities/getAdminPath.js +9 -0
  106. package/dist/oauth/utilities/getAdminPath.js.map +1 -0
  107. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  108. package/dist/oauth/utilities/refreshTokens.js +1 -1
  109. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  110. package/dist/plugin/build-config.d.ts +4 -21
  111. package/dist/plugin/build-config.d.ts.map +1 -1
  112. package/dist/plugin/build-config.js +7 -113
  113. package/dist/plugin/build-config.js.map +1 -1
  114. package/dist/types.d.ts +0 -1
  115. package/dist/types.d.ts.map +1 -1
  116. package/dist/types.js.map +1 -1
  117. package/dist/utils/asset-collection.d.ts +6 -3
  118. package/dist/utils/asset-collection.d.ts.map +1 -1
  119. package/dist/utils/asset-collection.js +34 -10
  120. package/dist/utils/asset-collection.js.map +1 -1
  121. package/dist/utils/config.js +1 -1
  122. package/dist/utils/config.js.map +1 -1
  123. package/dist/utils/env-management.d.ts +8 -9
  124. package/dist/utils/env-management.d.ts.map +1 -1
  125. package/dist/utils/env-management.js +74 -73
  126. package/dist/utils/env-management.js.map +1 -1
  127. package/dist/utils/formatter.d.ts.map +1 -1
  128. package/dist/utils/formatter.js +5 -3
  129. package/dist/utils/formatter.js.map +1 -1
  130. package/dist/utils/lambda-config.d.ts +1 -3
  131. package/dist/utils/lambda-config.d.ts.map +1 -1
  132. package/dist/utils/lambda-config.js +32 -38
  133. package/dist/utils/lambda-config.js.map +1 -1
  134. package/dist/utils/messages.js +8 -8
  135. package/dist/utils/messages.js.map +1 -1
  136. package/dist/utils/payload-config-ast.d.ts +3 -22
  137. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  138. package/dist/utils/payload-config-ast.js +31 -89
  139. package/dist/utils/payload-config-ast.js.map +1 -1
  140. package/dist/utils/payload-config-finder.d.ts +2 -2
  141. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  142. package/dist/utils/payload-config-finder.js +9 -48
  143. package/dist/utils/payload-config-finder.js.map +1 -1
  144. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  145. package/dist/utils/payload-config-modifier.js +6 -54
  146. package/dist/utils/payload-config-modifier.js.map +1 -1
  147. package/dist/utils/payload-package-check.d.ts +1 -12
  148. package/dist/utils/payload-package-check.d.ts.map +1 -1
  149. package/dist/utils/payload-package-check.js +5 -63
  150. package/dist/utils/payload-package-check.js.map +1 -1
  151. package/dist/utils/project.d.ts.map +1 -1
  152. package/dist/utils/project.js +5 -8
  153. package/dist/utils/project.js.map +1 -1
  154. package/dist/utils/s3-upload.d.ts +1 -0
  155. package/dist/utils/s3-upload.d.ts.map +1 -1
  156. package/dist/utils/s3-upload.js +3 -10
  157. package/dist/utils/s3-upload.js.map +1 -1
  158. package/dist/utils/token-display.d.ts.map +1 -1
  159. package/dist/utils/token-display.js +5 -11
  160. package/dist/utils/token-display.js.map +1 -1
  161. package/dist/utils/typescript-validator.d.ts.map +1 -1
  162. package/dist/utils/typescript-validator.js +6 -4
  163. package/dist/utils/typescript-validator.js.map +1 -1
  164. package/package.json +9 -27
  165. package/dist/commands/build-lambda-zip.d.ts +0 -5
  166. package/dist/commands/build-lambda-zip.d.ts.map +0 -1
  167. package/dist/commands/build-lambda-zip.js +0 -19
  168. package/dist/commands/build-lambda-zip.js.map +0 -1
  169. package/dist/db-content-api/README.md +0 -98
  170. package/dist/db-content-api/generated/content-api-types.d.ts +0 -3914
  171. package/dist/db-content-api/generated/content-api-types.d.ts.map +0 -1
  172. package/dist/db-content-api/generated/content-api-types.js +0 -7
  173. package/dist/db-content-api/generated/content-api-types.js.map +0 -1
  174. package/dist/db-content-api/index.d.ts +0 -18
  175. package/dist/db-content-api/index.d.ts.map +0 -1
  176. package/dist/db-content-api/index.js +0 -586
  177. package/dist/db-content-api/index.js.map +0 -1
  178. package/dist/db-content-api/temp-utilities/slug.d.ts +0 -2
  179. package/dist/db-content-api/temp-utilities/slug.d.ts.map +0 -1
  180. package/dist/db-content-api/temp-utilities/slug.js +0 -3
  181. package/dist/db-content-api/temp-utilities/slug.js.map +0 -1
  182. package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -3
  183. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +0 -1
  184. package/dist/db-content-api/temp-utilities/sorting.js +0 -32
  185. package/dist/db-content-api/temp-utilities/sorting.js.map +0 -1
  186. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -34
  187. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +0 -1
  188. package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -53
  189. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +0 -1
  190. package/dist/db-content-api/utilities/auth.d.ts +0 -30
  191. package/dist/db-content-api/utilities/auth.d.ts.map +0 -1
  192. package/dist/db-content-api/utilities/auth.js +0 -81
  193. package/dist/db-content-api/utilities/auth.js.map +0 -1
  194. package/dist/db-content-api/utilities/buildPathTypes.d.ts +0 -12
  195. package/dist/db-content-api/utilities/buildPathTypes.d.ts.map +0 -1
  196. package/dist/db-content-api/utilities/buildPathTypes.js +0 -157
  197. package/dist/db-content-api/utilities/buildPathTypes.js.map +0 -1
  198. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -7
  199. package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +0 -1
  200. package/dist/db-content-api/utilities/data/applyDefaults.js +0 -59
  201. package/dist/db-content-api/utilities/data/applyDefaults.js.map +0 -1
  202. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -11
  203. package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +0 -1
  204. package/dist/db-content-api/utilities/data/castFieldValue.js +0 -66
  205. package/dist/db-content-api/utilities/data/castFieldValue.js.map +0 -1
  206. package/dist/db-content-api/utilities/data/index.d.ts +0 -32
  207. package/dist/db-content-api/utilities/data/index.d.ts.map +0 -1
  208. package/dist/db-content-api/utilities/data/index.js +0 -190
  209. package/dist/db-content-api/utilities/data/index.js.map +0 -1
  210. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -12
  211. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +0 -1
  212. package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -54
  213. package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +0 -1
  214. package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -48
  215. package/dist/db-content-api/utilities/data/stripFields.d.ts.map +0 -1
  216. package/dist/db-content-api/utilities/data/stripFields.js +0 -195
  217. package/dist/db-content-api/utilities/data/stripFields.js.map +0 -1
  218. package/dist/db-content-api/utilities/joins.d.ts +0 -55
  219. package/dist/db-content-api/utilities/joins.d.ts.map +0 -1
  220. package/dist/db-content-api/utilities/joins.js +0 -136
  221. package/dist/db-content-api/utilities/joins.js.map +0 -1
  222. package/dist/db-content-api/utilities/where.d.ts +0 -12
  223. package/dist/db-content-api/utilities/where.d.ts.map +0 -1
  224. package/dist/db-content-api/utilities/where.js +0 -121
  225. package/dist/db-content-api/utilities/where.js.map +0 -1
  226. package/dist/endpoints/health.d.ts +0 -3
  227. package/dist/endpoints/health.d.ts.map +0 -1
  228. package/dist/endpoints/health.js +0 -11
  229. package/dist/endpoints/health.js.map +0 -1
  230. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -7
  231. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +0 -1
  232. package/dist/oauth/utilities/isDuplicateKeyError.js +0 -14
  233. package/dist/oauth/utilities/isDuplicateKeyError.js.map +0 -1
  234. package/dist/storage-content-api/api-types.d.ts +0 -168
  235. package/dist/storage-content-api/api-types.d.ts.map +0 -1
  236. package/dist/storage-content-api/api-types.js +0 -6
  237. package/dist/storage-content-api/api-types.js.map +0 -1
  238. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -9
  239. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +0 -1
  240. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -42
  241. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +0 -1
  242. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -13
  243. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +0 -1
  244. package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -32
  245. package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +0 -1
  246. package/dist/storage-content-api/client.d.ts +0 -6
  247. package/dist/storage-content-api/client.d.ts.map +0 -1
  248. package/dist/storage-content-api/client.js +0 -36
  249. package/dist/storage-content-api/client.js.map +0 -1
  250. package/dist/storage-content-api/generateURL.d.ts +0 -7
  251. package/dist/storage-content-api/generateURL.d.ts.map +0 -1
  252. package/dist/storage-content-api/generateURL.js +0 -8
  253. package/dist/storage-content-api/generateURL.js.map +0 -1
  254. package/dist/storage-content-api/handleDelete.d.ts +0 -8
  255. package/dist/storage-content-api/handleDelete.d.ts.map +0 -1
  256. package/dist/storage-content-api/handleDelete.js +0 -17
  257. package/dist/storage-content-api/handleDelete.js.map +0 -1
  258. package/dist/storage-content-api/handleUpload.d.ts +0 -11
  259. package/dist/storage-content-api/handleUpload.d.ts.map +0 -1
  260. package/dist/storage-content-api/handleUpload.js +0 -144
  261. package/dist/storage-content-api/handleUpload.js.map +0 -1
  262. package/dist/storage-content-api/index.d.ts +0 -5
  263. package/dist/storage-content-api/index.d.ts.map +0 -1
  264. package/dist/storage-content-api/index.js +0 -31
  265. package/dist/storage-content-api/index.js.map +0 -1
  266. package/dist/storage-content-api/staticHandler.d.ts +0 -10
  267. package/dist/storage-content-api/staticHandler.d.ts.map +0 -1
  268. package/dist/storage-content-api/staticHandler.js +0 -56
  269. package/dist/storage-content-api/staticHandler.js.map +0 -1
  270. package/dist/storage-content-api/types.d.ts +0 -10
  271. package/dist/storage-content-api/types.d.ts.map +0 -1
  272. package/dist/storage-content-api/types.js +0 -3
  273. package/dist/storage-content-api/types.js.map +0 -1
  274. package/dist/templates/README.md +0 -19
  275. package/dist/utils/build-lambda-zip.d.ts +0 -14
  276. package/dist/utils/build-lambda-zip.d.ts.map +0 -1
  277. package/dist/utils/build-lambda-zip.js +0 -81
  278. package/dist/utils/build-lambda-zip.js.map +0 -1
  279. package/dist/utils/format-env-suffix.d.ts +0 -12
  280. package/dist/utils/format-env-suffix.d.ts.map +0 -1
  281. package/dist/utils/format-env-suffix.js +0 -13
  282. package/dist/utils/format-env-suffix.js.map +0 -1
  283. package/dist/utils/version-check.d.ts +0 -3
  284. package/dist/utils/version-check.d.ts.map +0 -1
  285. package/dist/utils/version-check.js +0 -38
  286. package/dist/utils/version-check.js.map +0 -1
@@ -1,49 +1,10 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useConfig } from '@payloadcms/ui';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Button, useConfig } from '@payloadcms/ui';
4
4
  import { useSearchParams } from 'next/navigation.js';
5
5
  import React, { useEffect, useState } from 'react';
6
6
  import './index.scss';
7
7
  const baseClass = 'oauth-login';
8
- // Figma logo SVG colored version
9
- // const FigmaIcon: React.FC = () => (
10
- // <svg fill="none" height="27" viewBox="0 0 400 600" width="18">
11
- // <path
12
- // d="M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z"
13
- // fill="#24CB71"
14
- // />
15
- // <path
16
- // d="M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z"
17
- // fill="#FF7237"
18
- // />
19
- // <path
20
- // d="M299.167 400C354.395 400 399.167 355.228 399.167 300C399.167 244.772 354.395 200 299.167 200C243.939 200 199.167 244.772 199.167 300C199.167 355.228 243.939 400 299.167 400Z"
21
- // fill="#00B6FF"
22
- // />
23
- // <path
24
- // d="M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z"
25
- // fill="#FF3737"
26
- // />
27
- // <path
28
- // d="M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z"
29
- // fill="#874FFF"
30
- // />
31
- // </svg>
32
- // )
33
- // Figma logo SVG monochrome version
34
- const FigmaIcon = ()=>/*#__PURE__*/ _jsx("svg", {
35
- fill: "none",
36
- height: "20px",
37
- viewBox: "0 0 15 15",
38
- width: "20px",
39
- xmlns: "http://www.w3.org/2000/svg",
40
- children: /*#__PURE__*/ _jsx("path", {
41
- clipRule: "evenodd",
42
- d: "M7.00005 2.04999H5.52505C4.71043 2.04999 4.05005 2.71037 4.05005 3.52499C4.05005 4.33961 4.71043 4.99999 5.52505 4.99999H7.00005V2.04999ZM7.00005 1.04999H8.00005H9.47505C10.842 1.04999 11.95 2.15808 11.95 3.52499C11.95 4.33163 11.5642 5.04815 10.9669 5.49999C11.5642 5.95184 11.95 6.66836 11.95 7.475C11.95 8.8419 10.842 9.95 9.47505 9.95C8.92236 9.95 8.41198 9.76884 8.00005 9.46266V9.95L8.00005 11.425C8.00005 12.7919 6.89195 13.9 5.52505 13.9C4.15814 13.9 3.05005 12.7919 3.05005 11.425C3.05005 10.6183 3.43593 9.90184 4.03317 9.44999C3.43593 8.99814 3.05005 8.28163 3.05005 7.475C3.05005 6.66836 3.43594 5.95184 4.03319 5.5C3.43594 5.04815 3.05005 4.33163 3.05005 3.52499C3.05005 2.15808 4.15814 1.04999 5.52505 1.04999H7.00005ZM8.00005 2.04999V4.99999H9.47505C10.2897 4.99999 10.95 4.33961 10.95 3.52499C10.95 2.71037 10.2897 2.04999 9.47505 2.04999H8.00005ZM5.52505 8.94998H7.00005L7.00005 7.4788L7.00005 7.475L7.00005 7.4712V6H5.52505C4.71043 6 4.05005 6.66038 4.05005 7.475C4.05005 8.28767 4.70727 8.94684 5.5192 8.94999L5.52505 8.94998ZM4.05005 11.425C4.05005 10.6123 4.70727 9.95315 5.5192 9.94999L5.52505 9.95H7.00005L7.00005 11.425C7.00005 12.2396 6.33967 12.9 5.52505 12.9C4.71043 12.9 4.05005 12.2396 4.05005 11.425ZM8.00005 7.47206C8.00164 6.65879 8.66141 6 9.47505 6C10.2897 6 10.95 6.66038 10.95 7.475C10.95 8.28962 10.2897 8.95 9.47505 8.95C8.66141 8.95 8.00164 8.29121 8.00005 7.47794V7.47206Z",
43
- fill: "#FFFFFF",
44
- fillRule: "evenodd"
45
- })
46
- });
47
8
  export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
48
9
  const { config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
49
10
  const [authorizeURL, setAuthorizeURL] = useState('');
@@ -79,16 +40,11 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
79
40
  }
80
41
  return /*#__PURE__*/ _jsx("div", {
81
42
  className: baseClass,
82
- children: /*#__PURE__*/ _jsxs("a", {
43
+ children: /*#__PURE__*/ _jsx(Button, {
83
44
  className: `${baseClass}__btn`,
84
- href: authorizeURL,
85
- children: [
86
- /*#__PURE__*/ _jsx(FigmaIcon, {}),
87
- /*#__PURE__*/ _jsx("span", {
88
- className: `${baseClass}__text`,
89
- children: "Log in with Figma"
90
- })
91
- ]
45
+ el: "anchor",
46
+ url: authorizeURL,
47
+ children: "Log in"
92
48
  })
93
49
  });
94
50
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { useConfig } from '@payloadcms/ui'\nimport { useSearchParams } from 'next/navigation.js'\nimport React, { useEffect, useState } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-login'\n\n// Figma logo SVG colored version\n// const FigmaIcon: React.FC = () => (\n// <svg fill=\"none\" height=\"27\" viewBox=\"0 0 400 600\" width=\"18\">\n// <path\n// d=\"M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z\"\n// fill=\"#24CB71\"\n// />\n// <path\n// d=\"M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z\"\n// fill=\"#FF7237\"\n// />\n// <path\n// d=\"M299.167 400C354.395 400 399.167 355.228 399.167 300C399.167 244.772 354.395 200 299.167 200C243.939 200 199.167 244.772 199.167 300C199.167 355.228 243.939 400 299.167 400Z\"\n// fill=\"#00B6FF\"\n// />\n// <path\n// d=\"M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z\"\n// fill=\"#FF3737\"\n// />\n// <path\n// d=\"M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z\"\n// fill=\"#874FFF\"\n// />\n// </svg>\n// )\n\n// Figma logo SVG monochrome version\nconst FigmaIcon: React.FC = () => (\n <svg\n fill=\"none\"\n height=\"20px\"\n viewBox=\"0 0 15 15\"\n width=\"20px\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n clipRule=\"evenodd\"\n d=\"M7.00005 2.04999H5.52505C4.71043 2.04999 4.05005 2.71037 4.05005 3.52499C4.05005 4.33961 4.71043 4.99999 5.52505 4.99999H7.00005V2.04999ZM7.00005 1.04999H8.00005H9.47505C10.842 1.04999 11.95 2.15808 11.95 3.52499C11.95 4.33163 11.5642 5.04815 10.9669 5.49999C11.5642 5.95184 11.95 6.66836 11.95 7.475C11.95 8.8419 10.842 9.95 9.47505 9.95C8.92236 9.95 8.41198 9.76884 8.00005 9.46266V9.95L8.00005 11.425C8.00005 12.7919 6.89195 13.9 5.52505 13.9C4.15814 13.9 3.05005 12.7919 3.05005 11.425C3.05005 10.6183 3.43593 9.90184 4.03317 9.44999C3.43593 8.99814 3.05005 8.28163 3.05005 7.475C3.05005 6.66836 3.43594 5.95184 4.03319 5.5C3.43594 5.04815 3.05005 4.33163 3.05005 3.52499C3.05005 2.15808 4.15814 1.04999 5.52505 1.04999H7.00005ZM8.00005 2.04999V4.99999H9.47505C10.2897 4.99999 10.95 4.33961 10.95 3.52499C10.95 2.71037 10.2897 2.04999 9.47505 2.04999H8.00005ZM5.52505 8.94998H7.00005L7.00005 7.4788L7.00005 7.475L7.00005 7.4712V6H5.52505C4.71043 6 4.05005 6.66038 4.05005 7.475C4.05005 8.28767 4.70727 8.94684 5.5192 8.94999L5.52505 8.94998ZM4.05005 11.425C4.05005 10.6123 4.70727 9.95315 5.5192 9.94999L5.52505 9.95H7.00005L7.00005 11.425C7.00005 12.2396 6.33967 12.9 5.52505 12.9C4.71043 12.9 4.05005 12.2396 4.05005 11.425ZM8.00005 7.47206C8.00164 6.65879 8.66141 6 9.47505 6C10.2897 6 10.95 6.66038 10.95 7.475C10.95 8.28962 10.2897 8.95 9.47505 8.95C8.66141 8.95 8.00164 8.29121 8.00005 7.47794V7.47206Z\"\n fill=\"#FFFFFF\"\n fillRule=\"evenodd\"\n />\n </svg>\n)\n\ntype DefaultLoginButtonProps = {\n disabled?: boolean\n endpointSlug: string\n}\n\nexport const DefaultLoginButton: React.FC<DefaultLoginButtonProps> = ({\n disabled,\n endpointSlug,\n}: {\n disabled?: boolean\n endpointSlug: string\n}) => {\n const {\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [authorizeURL, setAuthorizeURL] = useState('')\n\n const searchParams = useSearchParams()\n const payloadRedirect = searchParams.get('redirect')\n\n useEffect(() => {\n if (payloadRedirect && !disabled) {\n // set cookie to redirect to the original page\n document.cookie = `payloadRedirect=${payloadRedirect}; path=/`\n }\n }, [payloadRedirect, disabled])\n\n useEffect(() => {\n const getAuthorizeURL = async () => {\n const serverURLFromWindow = window.location.origin\n const data = await fetch(\n `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`,\n ).then((res) => res.json())\n\n if (!disabled) {\n setAuthorizeURL(data.authorizeURL)\n }\n }\n\n void getAuthorizeURL()\n }, [api, serverURL, userSlug, disabled, endpointSlug])\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <a className={`${baseClass}__btn`} href={authorizeURL}>\n <FigmaIcon />\n <span className={`${baseClass}__text`}>Log in with Figma</span>\n </a>\n </div>\n )\n}\n"],"names":["useConfig","useSearchParams","React","useEffect","useState","baseClass","FigmaIcon","svg","fill","height","viewBox","width","xmlns","path","clipRule","d","fillRule","DefaultLoginButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","authorizeURL","setAuthorizeURL","searchParams","payloadRedirect","get","document","cookie","getAuthorizeURL","serverURLFromWindow","window","location","origin","data","fetch","then","res","json","div","className","a","href","span"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,qBAAoB;AACpD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,Q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B,qBAAqB,EACtFM,IAAI,CAAC,CAACC,MAAQA,IAAIC,IAAI;YAExB,IAAI,CAACzB,UAAU;gBACbU,gBAAgBW,KAAKZ,YAAY;YACnC;QACF;QAEA,KAAKO;IACP,GAAG;QAACT;QAAKC;QAAWH;QAAUL;QAAUC;KAAa;IAErD,IAAID,UAAU;QACZ,OAAO;IACT;IAEA,qBACE,KAAC0B;QAAIC,WAAWxC;kBACd,cAAA,MAACyC;YAAED,WAAW,GAAGxC,UAAU,KAAK,CAAC;YAAE0C,MAAMpB;;8BACvC,KAACrB;8BACD,KAAC0C;oBAAKH,WAAW,GAAGxC,UAAU,MAAM,CAAC;8BAAE;;;;;AAI/C,EAAC"}
1
+ {"version":3,"sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Button, useConfig } from '@payloadcms/ui'\nimport { useSearchParams } from 'next/navigation.js'\nimport React, { useEffect, useState } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-login'\n\ntype DefaultLoginButtonProps = {\n disabled?: boolean\n endpointSlug: string\n}\n\nexport const DefaultLoginButton: React.FC<DefaultLoginButtonProps> = ({\n disabled,\n endpointSlug,\n}: {\n disabled?: boolean\n endpointSlug: string\n}) => {\n const {\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [authorizeURL, setAuthorizeURL] = useState('')\n\n const searchParams = useSearchParams()\n const payloadRedirect = searchParams.get('redirect')\n\n useEffect(() => {\n if (payloadRedirect && !disabled) {\n // set cookie to redirect to the original page\n document.cookie = `payloadRedirect=${payloadRedirect}; path=/`\n }\n }, [payloadRedirect, disabled])\n\n useEffect(() => {\n const getAuthorizeURL = async () => {\n const serverURLFromWindow = window.location.origin\n const data = await fetch(\n `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`,\n ).then((res) => res.json())\n\n if (!disabled) {\n setAuthorizeURL(data.authorizeURL)\n }\n }\n\n void getAuthorizeURL()\n }, [api, serverURL, userSlug, disabled, endpointSlug])\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <Button className={`${baseClass}__btn`} el=\"anchor\" url={authorizeURL}>\n Log in\n </Button>\n </div>\n )\n}\n"],"names":["Button","useConfig","useSearchParams","React","useEffect","useState","baseClass","DefaultLoginButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","authorizeURL","setAuthorizeURL","searchParams","payloadRedirect","get","document","cookie","getAuthorizeURL","serverURLFromWindow","window","location","origin","data","fetch","then","res","json","div","className","el","url"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,SAAS,QAAQ,iBAAgB;AAClD,SAASC,eAAe,QAAQ,qBAAoB;AACpD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAOlB,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,QAAQ,EACRC,YAAY,EAIb;IACC,MAAM,EACJC,QAAQ,EACNC,OAAO,EAAEC,MAAMC,QAAQ,EAAE,EACzBC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGf;IACJ,MAAM,CAACgB,cAAcC,gBAAgB,GAAGb,SAAS;IAEjD,MAAMc,eAAejB;IACrB,MAAMkB,kBAAkBD,aAAaE,GAAG,CAAC;IAEzCjB,UAAU;QACR,IAAIgB,mBAAmB,CAACZ,UAAU;YAChC,8CAA8C;YAC9Cc,SAASC,MAAM,GAAG,CAAC,gBAAgB,EAAEH,gBAAgB,QAAQ,CAAC;QAChE;IACF,GAAG;QAACA;QAAiBZ;KAAS;IAE9BJ,UAAU;QACR,MAAMoB,kBAAkB;YACtB,MAAMC,sBAAsBC,OAAOC,QAAQ,CAACC,MAAM;YAClD,MAAMC,OAAO,MAAMC,MACjB,GAAGd,YAAYD,IAAI,CAAC,EAAEF,SAAS,CAAC,EAAEJ,aAAa,gBAAgB,EAAEgB,qBAAqB,EACtFM,IAAI,CAAC,CAACC,MAAQA,IAAIC,IAAI;YAExB,IAAI,CAACzB,UAAU;gBACbU,gBAAgBW,KAAKZ,YAAY;YACnC;QACF;QAEA,KAAKO;IACP,GAAG;QAACT;QAAKC;QAAWH;QAAUL;QAAUC;KAAa;IAErD,IAAID,UAAU;QACZ,OAAO;IACT;IAEA,qBACE,KAAC0B;QAAIC,WAAW7B;kBACd,cAAA,KAACN;YAAOmC,WAAW,GAAG7B,UAAU,KAAK,CAAC;YAAE8B,IAAG;YAASC,KAAKpB;sBAAc;;;AAK7E,EAAC"}
@@ -1,57 +1,10 @@
1
1
  .oauth-login {
2
2
  display: flex;
3
3
  justify-content: center;
4
- padding: 1rem 0;
5
4
 
6
- &__btn {
7
- display: inline-flex;
8
- align-items: center;
9
- justify-content: center;
10
- gap: 0.75rem;
11
- padding: 0.75rem 1.5rem;
12
- min-height: 3rem;
13
- background-color: #4d49fc;
14
- color: #ffffff;
15
- border: none;
16
- border-radius: 0.5rem;
17
- font-size: 1rem;
18
- font-weight: 450;
19
- letter-spacing: 0.05px;
20
- text-decoration: none;
21
- cursor: pointer;
22
- transition: background-color 0.2s ease, transform 0.1s ease;
23
- box-shadow: none;
24
-
25
- &:hover {
26
- background-color: #4440e8;
27
- transform: translateY(-1px);
28
- }
29
-
30
- &:active {
31
- background-color: #3c38d4;
32
- transform: translateY(0);
33
- }
34
-
35
- &:focus {
36
- outline: none;
37
- box-shadow: 0 0 0 2px rgba(77, 73, 252, 0.4);
5
+ &__btn:focus {
6
+ .btn__icon {
7
+ background: none;
38
8
  }
39
9
  }
40
-
41
- &__icon {
42
- flex-shrink: 0;
43
- width: 20px;
44
- height: 20px;
45
- display: flex;
46
- align-items: center;
47
- justify-content: center;
48
- color: #ffffff;
49
- }
50
-
51
- &__text {
52
- white-space: nowrap;
53
- line-height: 1rem;
54
- font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
55
- Oxygen, Ubuntu, Cantarell, sans-serif;
56
- }
57
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA6D/E,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA2D/E,CAAA"}
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Logout, useConfig } from '@payloadcms/ui';
4
- import { formatAdminURL } from 'payload/shared';
5
4
  import React from 'react';
5
+ import { getAdminPath } from '../../utilities/getAdminPath.js';
6
6
  import './index.scss';
7
7
  const baseClass = 'oauth-logout';
8
8
  export const LogoutButton = ({ disabled, endpointSlug })=>{
@@ -16,10 +16,9 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
16
16
  if (port) {
17
17
  redirectToSet += `:${port}`;
18
18
  }
19
- setRedirect(formatAdminURL({
20
- adminRoute: config.routes.admin,
21
- serverURL: redirectToSet
22
- }));
19
+ redirectToSet += getAdminPath(config);
20
+ // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
21
+ setRedirect(redirectToSet);
23
22
  }, [
24
23
  config
25
24
  ]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Logout, useConfig } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-logout'\n\nexport const LogoutButton: React.FC<{ disabled?: boolean; endpointSlug: string }> = ({\n disabled,\n endpointSlug,\n}) => {\n const {\n config,\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const [redirect, setRedirect] = React.useState('')\n React.useEffect(() => {\n const protocol = window.location.protocol\n const domain = window.location.hostname\n const port = window.location.port\n\n let redirectToSet = `${protocol}//${domain}`\n if (port) {\n redirectToSet += `:${port}`\n }\n\n setRedirect(\n formatAdminURL({\n adminRoute: config.routes.admin,\n serverURL: redirectToSet,\n }),\n )\n }, [config])\n\n if (!redirect) {\n return null\n }\n\n if (disabled) {\n return <Logout />\n }\n\n return (\n <div className={baseClass}>\n <a\n aria-label=\"Logout\"\n href={`${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${redirect}`}\n >\n <svg\n className=\"icon icon--logout\"\n fill=\"none\"\n viewBox=\"0 0 25 25\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path className=\"stroke\" d=\"M10 5H18V19H10\" />\n <g>\n <path className=\"stroke\" d=\"M8 8.5L4.46447 12.0355L8 15.5711\" />\n <line className=\"stroke\" x1=\"5\" x2=\"13\" y1=\"12\" y2=\"12\" />\n </g>\n </svg>\n </a>\n </div>\n )\n}\n"],"names":["Logout","useConfig","formatAdminURL","React","baseClass","LogoutButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","redirect","setRedirect","useState","useEffect","protocol","window","location","domain","hostname","port","redirectToSet","adminRoute","div","className","a","aria-label","href","svg","fill","viewBox","xmlns","path","d","g","line","x1","x2","y1","y2"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,SAAS,QAAQ,iBAAgB;AAClD,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,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M/D,EAAC"}
1
+ {"version":3,"sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Logout, useConfig } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { getAdminPath } from '../../utilities/getAdminPath.js'\nimport './index.scss'\n\nconst baseClass = 'oauth-logout'\n\nexport const LogoutButton: React.FC<{ disabled?: boolean; endpointSlug: string }> = ({\n disabled,\n endpointSlug,\n}) => {\n const {\n config,\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const [redirect, setRedirect] = React.useState('')\n React.useEffect(() => {\n const protocol = window.location.protocol\n const domain = window.location.hostname\n const port = window.location.port\n\n let redirectToSet = `${protocol}//${domain}`\n if (port) {\n redirectToSet += `:${port}`\n }\n\n redirectToSet += getAdminPath(config)\n\n // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect\n setRedirect(redirectToSet)\n }, [config])\n\n if (!redirect) {\n return null\n }\n\n if (disabled) {\n return <Logout />\n }\n\n return (\n <div className={baseClass}>\n <a\n aria-label=\"Logout\"\n href={`${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${redirect}`}\n >\n <svg\n className=\"icon icon--logout\"\n fill=\"none\"\n viewBox=\"0 0 25 25\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path className=\"stroke\" d=\"M10 5H18V19H10\" />\n <g>\n <path className=\"stroke\" d=\"M8 8.5L4.46447 12.0355L8 15.5711\" />\n <line className=\"stroke\" x1=\"5\" x2=\"13\" y1=\"12\" y2=\"12\" />\n </g>\n </svg>\n </a>\n </div>\n )\n}\n"],"names":["Logout","useConfig","React","getAdminPath","baseClass","LogoutButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","redirect","setRedirect","useState","useEffect","protocol","window","location","domain","hostname","port","redirectToSet","div","className","a","aria-label","href","svg","fill","viewBox","xmlns","path","d","g","line","x1","x2","y1","y2"],"mappings":"AAAA;;AAEA,SAASA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AAG;gCAAIC,IAAG;gCAAKC,IAAG;gCAAKC,IAAG;;;;;;;;AAM/D,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/oauth/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAQ,MAAM,SAAS,CAAA;AAI5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,eAAO,MAAM,YAAY,UAAiC,CAAA;AAE1D,eAAO,MAAM,oBAAoB,EAAE,SAQlC,CAAA;AAED,eAAO,MAAM,aAAa,iDAKrB;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,UAAU,GAAG,SAAS,CAAA;CACtC,KAAG,cAuGH,CAAA"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/oauth/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAQ,MAAM,SAAS,CAAA;AAI5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIhD,eAAO,MAAM,YAAY,UAAiC,CAAA;AAE1D,eAAO,MAAM,oBAAoB,EAAE,SAQlC,CAAA;AAED,eAAO,MAAM,aAAa,iDAKrB;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,UAAU,GAAG,SAAS,CAAA;CACtC,KAAG,cAiFH,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import { v4 as uuid } from 'uuid';
2
2
  import { hasUserTokenPropsChanged } from './utilities/hasUserTokenPropsChanged.js';
3
- import { isDuplicateKeyError } from './utilities/isDuplicateKeyError.js';
4
3
  export const defaultScope = [
5
4
  'openid',
6
5
  'profile',
@@ -61,34 +60,11 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
61
60
  if (typeof collection.auth === 'object' && !collection.auth.disableLocalStrategy) {
62
61
  newUser.password = uuid();
63
62
  }
64
- try {
65
- user = await payload.create({
66
- collection: collection.slug,
67
- data: newUser,
68
- depth,
69
- overrideAccess: true
70
- });
71
- } catch (createErr) {
72
- // Race condition: if unique constraint violation, user was created by concurrent request
73
- if (isDuplicateKeyError(createErr)) {
74
- const retryResults = await payload.find({
75
- collection: collection.slug,
76
- depth,
77
- limit: 1,
78
- pagination: false,
79
- where: {
80
- [usernameField.name]: {
81
- equals: token[tokenUsername]
82
- }
83
- }
84
- });
85
- if (retryResults.docs.length > 0) {
86
- user = retryResults.docs[0];
87
- }
88
- } else {
89
- throw createErr;
90
- }
91
- }
63
+ user = await payload.create({
64
+ collection: collection.slug,
65
+ data: newUser,
66
+ depth
67
+ });
92
68
  }
93
69
  } catch (err) {
94
70
  payload.logger.error({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/oauth/defaults.ts"],"sourcesContent":["import type { CollectionConfig, EmailField, TextField, User } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { VerifyFunction } from './types.js'\n\nimport { hasUserTokenPropsChanged } from './utilities/hasUserTokenPropsChanged.js'\nimport { isDuplicateKeyError } from './utilities/isDuplicateKeyError.js'\n\nexport const defaultScope = ['openid', 'profile', 'email']\n\nexport const defaultUsernameField: TextField = {\n name: 'preferredUsername',\n type: 'text',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n unique: true,\n}\n\nexport const defaultVerify =\n ({\n collection,\n strategyName,\n usernameField,\n }: {\n collection: CollectionConfig\n strategyName: string\n usernameField: EmailField | TextField\n }): VerifyFunction =>\n async ({ payload, token }) => {\n let tokenUsername = 'preferred_username'\n\n if (usernameField.name !== 'preferredUsername') {\n tokenUsername = usernameField.name\n }\n\n if (!token[tokenUsername]) {\n return {\n user: null,\n }\n }\n\n let user: null | User = null\n const depth = typeof collection.auth === 'object' ? collection.auth.depth : undefined\n\n try {\n const results = await payload.find({\n collection: collection.slug,\n depth,\n limit: 1,\n pagination: false,\n where: {\n [usernameField.name]: { equals: token[tokenUsername] },\n },\n })\n\n if (results.docs.length > 0) {\n user = results.docs[0] as User\n // Update user with new token data\n if (hasUserTokenPropsChanged(user, token)) {\n user = (await payload.update({\n id: user.id,\n collection: collection.slug,\n data: {\n ...token,\n },\n depth,\n })) as User\n }\n } else {\n const newUser = {\n email: token.preferredUsername || token.email,\n [usernameField.name]: token[tokenUsername],\n ...token,\n }\n\n if (typeof collection.auth === 'object' && !collection.auth.disableLocalStrategy) {\n newUser.password = uuid()\n }\n\n try {\n user = (await payload.create({\n collection: collection.slug,\n data: newUser,\n depth,\n overrideAccess: true,\n })) as User\n } catch (createErr: unknown) {\n // Race condition: if unique constraint violation, user was created by concurrent request\n if (isDuplicateKeyError(createErr)) {\n const retryResults = await payload.find({\n collection: collection.slug,\n depth,\n limit: 1,\n pagination: false,\n where: {\n [usernameField.name]: { equals: token[tokenUsername] },\n },\n })\n\n if (retryResults.docs.length > 0) {\n user = retryResults.docs[0] as User\n }\n } else {\n throw createErr\n }\n }\n }\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: 'Error verifying user from defaultVerify.',\n })\n return {\n user: null,\n }\n }\n\n if (user) {\n user.collection = collection.slug\n user._strategy = strategyName\n user.exp = token.exp\n\n return {\n user,\n }\n }\n\n return {\n user: null,\n }\n }\n"],"names":["v4","uuid","hasUserTokenPropsChanged","isDuplicateKeyError","defaultScope","defaultUsernameField","name","type","admin","position","readOnly","unique","defaultVerify","collection","strategyName","usernameField","payload","token","tokenUsername","user","depth","auth","undefined","results","find","slug","limit","pagination","where","equals","docs","length","update","id","data","newUser","email","preferredUsername","disableLocalStrategy","password","create","overrideAccess","createErr","retryResults","err","logger","error","msg","_strategy","exp"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,mBAAmB,QAAQ,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B,cAAcT,IAAI,CAAC,EAAEW,KAAK,CAACC,cAAc;oBAC1C,GAAGD,KAAK;gBACV;gBAEA,IAAI,OAAOJ,WAAWQ,IAAI,KAAK,YAAY,CAACR,WAAWQ,IAAI,CAACiB,oBAAoB,EAAE;oBAChFH,QAAQI,QAAQ,GAAGtC;gBACrB;gBAEA,IAAI;oBACFkB,OAAQ,MAAMH,QAAQwB,MAAM,CAAC;wBAC3B3B,YAAYA,WAAWY,IAAI;wBAC3BS,MAAMC;wBACNf;wBACAqB,gBAAgB;oBAClB;gBACF,EAAE,OAAOC,WAAoB;oBAC3B,yFAAyF;oBACzF,IAAIvC,oBAAoBuC,YAAY;wBAClC,MAAMC,eAAe,MAAM3B,QAAQQ,IAAI,CAAC;4BACtCX,YAAYA,WAAWY,IAAI;4BAC3BL;4BACAM,OAAO;4BACPC,YAAY;4BACZC,OAAO;gCACL,CAACb,cAAcT,IAAI,CAAC,EAAE;oCAAEuB,QAAQZ,KAAK,CAACC,cAAc;gCAAC;4BACvD;wBACF;wBAEA,IAAIyB,aAAab,IAAI,CAACC,MAAM,GAAG,GAAG;4BAChCZ,OAAOwB,aAAab,IAAI,CAAC,EAAE;wBAC7B;oBACF,OAAO;wBACL,MAAMY;oBACR;gBACF;YACF;QACF,EAAE,OAAOE,KAAc;YACrB5B,QAAQ6B,MAAM,CAACC,KAAK,CAAC;gBACnBF;gBACAG,KAAK;YACP;YACA,OAAO;gBACL5B,MAAM;YACR;QACF;QAEA,IAAIA,MAAM;YACRA,KAAKN,UAAU,GAAGA,WAAWY,IAAI;YACjCN,KAAK6B,SAAS,GAAGlC;YACjBK,KAAK8B,GAAG,GAAGhC,MAAMgC,GAAG;YAEpB,OAAO;gBACL9B;YACF;QACF;QAEA,OAAO;YACLA,MAAM;QACR;IACF,EAAC"}
1
+ {"version":3,"sources":["../../src/oauth/defaults.ts"],"sourcesContent":["import type { CollectionConfig, EmailField, TextField, User } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { VerifyFunction } from './types.js'\n\nimport { hasUserTokenPropsChanged } from './utilities/hasUserTokenPropsChanged.js'\n\nexport const defaultScope = ['openid', 'profile', 'email']\n\nexport const defaultUsernameField: TextField = {\n name: 'preferredUsername',\n type: 'text',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n unique: true,\n}\n\nexport const defaultVerify =\n ({\n collection,\n strategyName,\n usernameField,\n }: {\n collection: CollectionConfig\n strategyName: string\n usernameField: EmailField | TextField\n }): VerifyFunction =>\n async ({ payload, token }) => {\n let tokenUsername = 'preferred_username'\n\n if (usernameField.name !== 'preferredUsername') {\n tokenUsername = usernameField.name\n }\n\n if (!token[tokenUsername]) {\n return {\n user: null,\n }\n }\n\n let user: null | User = null\n const depth = typeof collection.auth === 'object' ? collection.auth.depth : undefined\n\n try {\n const results = await payload.find({\n collection: collection.slug,\n depth,\n limit: 1,\n pagination: false,\n where: {\n [usernameField.name]: { equals: token[tokenUsername] },\n },\n })\n\n if (results.docs.length > 0) {\n user = results.docs[0] as User\n // Update user with new token data\n if (hasUserTokenPropsChanged(user, token)) {\n user = (await payload.update({\n id: user.id,\n collection: collection.slug,\n data: {\n ...token,\n },\n depth,\n })) as User\n }\n } else {\n const newUser = {\n email: token.preferredUsername || token.email,\n [usernameField.name]: token[tokenUsername],\n ...token,\n }\n\n if (typeof collection.auth === 'object' && !collection.auth.disableLocalStrategy) {\n newUser.password = uuid()\n }\n\n user = (await payload.create({\n collection: collection.slug,\n data: newUser,\n depth,\n })) as User\n }\n } catch (err: unknown) {\n payload.logger.error({\n err,\n msg: 'Error verifying user from defaultVerify.',\n })\n return {\n user: null,\n }\n }\n\n if (user) {\n user.collection = collection.slug\n user._strategy = strategyName\n user.exp = token.exp\n\n return {\n user,\n }\n }\n\n return {\n user: null,\n }\n }\n"],"names":["v4","uuid","hasUserTokenPropsChanged","defaultScope","defaultUsernameField","name","type","admin","position","readOnly","unique","defaultVerify","collection","strategyName","usernameField","payload","token","tokenUsername","user","depth","auth","undefined","results","find","slug","limit","pagination","where","equals","docs","length","update","id","data","newUser","email","preferredUsername","disableLocalStrategy","password","create","err","logger","error","msg","_strategy","exp"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,wBAAwB,QAAQ,0CAAyC;AAElF,OAAO,MAAMC,eAAe;IAAC;IAAU;IAAW;CAAQ,CAAA;AAE1D,OAAO,MAAMC,uBAAkC;IAC7CC,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,UAAU;QACVC,UAAU;IACZ;IACAC,QAAQ;AACV,EAAC;AAED,OAAO,MAAMC,gBACX,CAAC,EACCC,UAAU,EACVC,YAAY,EACZC,aAAa,EAKd,GACD,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAE;QACvB,IAAIC,gBAAgB;QAEpB,IAAIH,cAAcT,IAAI,KAAK,qBAAqB;YAC9CY,gBAAgBH,cAAcT,IAAI;QACpC;QAEA,IAAI,CAACW,KAAK,CAACC,cAAc,EAAE;YACzB,OAAO;gBACLC,MAAM;YACR;QACF;QAEA,IAAIA,OAAoB;QACxB,MAAMC,QAAQ,OAAOP,WAAWQ,IAAI,KAAK,WAAWR,WAAWQ,IAAI,CAACD,KAAK,GAAGE;QAE5E,IAAI;YACF,MAAMC,UAAU,MAAMP,QAAQQ,IAAI,CAAC;gBACjCX,YAAYA,WAAWY,IAAI;gBAC3BL;gBACAM,OAAO;gBACPC,YAAY;gBACZC,OAAO;oBACL,CAACb,cAAcT,IAAI,CAAC,EAAE;wBAAEuB,QAAQZ,KAAK,CAACC,cAAc;oBAAC;gBACvD;YACF;YAEA,IAAIK,QAAQO,IAAI,CAACC,MAAM,GAAG,GAAG;gBAC3BZ,OAAOI,QAAQO,IAAI,CAAC,EAAE;gBACtB,kCAAkC;gBAClC,IAAI3B,yBAAyBgB,MAAMF,QAAQ;oBACzCE,OAAQ,MAAMH,QAAQgB,MAAM,CAAC;wBAC3BC,IAAId,KAAKc,EAAE;wBACXpB,YAAYA,WAAWY,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MAAM,CAAA;IACpB,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAID,eAAO,MAAM,gBAAgB,8EAM1B,IAAI,KAAG,QA4PR,CAAA"}
1
+ {"version":3,"file":"getLoginEndpoint.d.ts","sourceRoot":"","sources":["../../../src/oauth/endpoints/getLoginEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAMzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAEV,iBAAiB,EACjB,aAAa,EAEd,MAAM,aAAa,CAAA;AAcpB,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAID,eAAO,MAAM,gBAAgB,8EAM1B,IAAI,KAAG,QA+OR,CAAA"}
@@ -1,15 +1,16 @@
1
1
  import { APIError, generateCookie, parseCookies } from 'payload';
2
- import { formatAdminURL, getSafeRedirect } from 'payload/shared';
2
+ import { getSafeRedirect } from 'payload/shared';
3
3
  import { getProjectToken } from '../../api/figma-api.js';
4
4
  import { createCookieOptions } from '../utilities/createCookieOptions.js';
5
5
  import { createDebugLogger } from '../utilities/createDebugLogger.js';
6
6
  import { extractOrigin } from '../utilities/extractOrigin.js';
7
+ import { getAdminPath } from '../utilities/getAdminPath.js';
7
8
  import { getCookieExpiration } from '../utilities/getCookieExpiration.js';
8
9
  const isAbsoluteURL = (url)=>/^[a-z][a-z\d+.-]*:/.test(url);
9
10
  export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug, pluginOptions, strategy })=>({
10
11
  handler: async (req)=>{
11
12
  const { config } = req.payload;
12
- const adminRoute = config.routes?.admin || '/admin';
13
+ const adminPath = getAdminPath(config);
13
14
  try {
14
15
  await strategy.ensureMeta();
15
16
  const path = req.pathname;
@@ -36,16 +37,9 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
36
37
  }
37
38
  const stateRaw = jsonBody.state;
38
39
  const state = JSON.parse(Buffer.from(stateRaw, 'base64').toString('utf-8'));
39
- const redirectServerURL = state.serverURL || pluginOptions.redirectServerURL || config.serverURL;
40
- let failedRedirect = formatAdminURL({
41
- adminRoute,
42
- path: '/login',
43
- serverURL: redirectServerURL
44
- });
45
- let redirectToUse = formatAdminURL({
46
- adminRoute,
47
- serverURL: redirectServerURL
48
- });
40
+ const redirectDestination = state.serverURL || pluginOptions.redirectServerURL || config.serverURL;
41
+ let failedRedirect = `${redirectDestination}${adminPath}/login`;
42
+ let redirectToUse = `${redirectDestination}${adminPath}`;
49
43
  if (state.redirect) {
50
44
  redirectToUse = state.redirect;
51
45
  }
@@ -132,20 +126,16 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
132
126
  code,
133
127
  code_verifier: req.payload.decrypt(state.verifier),
134
128
  grant_type: 'authorization_code',
135
- redirect_uri: formatAdminURL({
136
- apiRoute: config.routes?.api || '/api',
137
- path: `/${collection.slug}/${endpointSlug}/login`,
138
- serverURL: redirectServerURL
139
- })
129
+ redirect_uri: `${redirectDestination}${config?.routes?.api || '/api'}/${collection.slug}/${endpointSlug}/login`
140
130
  };
141
- if (strategy.collectionOptions.clientSecret) {
142
- body.client_secret = strategy.collectionOptions.clientSecret;
143
- }
144
131
  debugLogger.info({
145
132
  msg: 'Exchanging code for access token',
146
133
  path,
147
134
  requestBody: body
148
135
  });
136
+ if (strategy.clientSecret) {
137
+ body.client_secret = strategy.clientSecret;
138
+ }
149
139
  const tokenRes = await fetch(strategy.meta?.token_endpoint, {
150
140
  body: new URLSearchParams(body),
151
141
  headers: {
@@ -164,7 +154,7 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
164
154
  tokenRes
165
155
  });
166
156
  // Swap for project token
167
- const project_token = await getProjectToken(tokenRes.access_token, config.custom.figma.contentSystemId);
157
+ const project_token = await getProjectToken(tokenRes.access_token, 'someproject');
168
158
  const refresh_token = access_token;
169
159
  // Store project token as access_token
170
160
  const token = project_token.token;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/oauth/endpoints/getLoginEndpoint.ts"],"sourcesContent":["import type { CollectionConfig, Endpoint } from 'payload'\n\nimport { APIError, generateCookie, parseCookies } from 'payload'\nimport { formatAdminURL, getSafeRedirect } from 'payload/shared'\n\nimport type { Strategy } from '../strategy/index.js'\nimport type { CollectionOptions, PluginOptions, StateObj } from '../types.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { createCookieOptions } from '../utilities/createCookieOptions.js'\nimport { createDebugLogger } from '../utilities/createDebugLogger.js'\nimport { extractOrigin } from '../utilities/extractOrigin.js'\nimport { getCookieExpiration } from '../utilities/getCookieExpiration.js'\n\ninterface Args {\n collection: CollectionConfig\n collectionOptions: CollectionOptions\n endpointSlug: string\n pluginOptions: PluginOptions\n strategy: Strategy\n}\n\nconst isAbsoluteURL = (url: string) => /^[a-z][a-z\\d+.-]*:/.test(url)\n\nexport const getLoginEndpoint = ({\n collection,\n collectionOptions,\n endpointSlug,\n pluginOptions,\n strategy,\n}: Args): Endpoint => ({\n handler: async (req) => {\n const { config } = req.payload\n const adminRoute = config.routes?.admin || '/admin'\n\n try {\n await strategy.ensureMeta()\n\n const path = req.pathname\n const debugLogger = createDebugLogger(req.payload, pluginOptions.debug)\n\n let jsonBody: Record<string, unknown> = {}\n\n const contentType = req.headers.get('content-type')\n\n // Type narrow PayloadRequst's Partial<Request>\n if (typeof req.json !== 'function' || typeof req.formData !== 'function') {\n debugLogger.info({\n msg: 'Request does not have json or formData methods',\n path,\n })\n\n return Response.redirect(`${pluginOptions.redirectServerURL || config.serverURL}/login`)\n }\n\n if (collectionOptions.authorizationURLParams?.response_mode === 'query') {\n if (Object.keys(req.query).length > 0) {\n jsonBody = req.query\n }\n } else if (contentType === 'application/json') {\n jsonBody = await req.json()\n } else if (contentType === 'application/x-www-form-urlencoded') {\n const formData = await req.formData()\n jsonBody = Object.fromEntries(formData.entries())\n }\n\n const stateRaw = jsonBody.state as string\n const state: StateObj = JSON.parse(Buffer.from(stateRaw, 'base64').toString('utf-8'))\n\n const redirectServerURL =\n state.serverURL || pluginOptions.redirectServerURL || config.serverURL\n let failedRedirect = formatAdminURL({\n adminRoute,\n path: '/login',\n serverURL: redirectServerURL,\n })\n let redirectToUse = formatAdminURL({\n adminRoute,\n serverURL: redirectServerURL,\n })\n\n if (state.redirect) {\n redirectToUse = state.redirect\n }\n\n if (state.failedRedirect) {\n failedRedirect = state.failedRedirect\n }\n\n failedRedirect = getSafeRedirect({ allowAbsoluteUrls: true, redirectTo: failedRedirect })\n redirectToUse = getSafeRedirect({ allowAbsoluteUrls: true, redirectTo: redirectToUse })\n\n if (!isAbsoluteURL(failedRedirect)) {\n return Response.json({ error: 'Invalid failed redirect provided' }, { status: 403 })\n }\n if (!isAbsoluteURL(redirectToUse)) {\n return Response.json({ error: 'Invalid redirect provided' }, { status: 403 })\n }\n\n if (Array.isArray(req.payload.config.csrf) && req.payload.config.csrf.length > 0) {\n const failedRedirectOrigin = extractOrigin(failedRedirect)\n const redirectToUseOrigin = extractOrigin(redirectToUse)\n\n if (failedRedirectOrigin && !req.payload.config.csrf.includes(failedRedirectOrigin)) {\n req.payload.logger.error(\n `Failed redirect origin ${failedRedirectOrigin} is not allowed by CSRF configuration.`,\n )\n return Response.json(\n { error: 'Failed redirect origin is not allowed by CSRF configuration.' },\n { status: 403 },\n )\n }\n\n if (redirectToUseOrigin && !req.payload.config.csrf.includes(redirectToUseOrigin)) {\n req.payload.logger.error(\n `Redirect origin ${redirectToUseOrigin} is not allowed by CSRF configuration.`,\n )\n return Response.json(\n { error: 'Redirect origin is not allowed by CSRF configuration.' },\n { status: 403 },\n )\n }\n }\n\n // Verify signature\n if (strategy.name !== req.payload.decrypt(state.sig)) {\n req.payload.logger.error('Signature mismatch. Failing login and redirecting.')\n return Response.redirect(failedRedirect)\n }\n\n if (!strategy.meta?.token_endpoint) {\n debugLogger.error({\n msg: `No metadata was obtained from the identity provider. Failing login and redirecting.`,\n path,\n })\n return Response.redirect(failedRedirect)\n }\n\n debugLogger.info({ body: jsonBody, msg: 'Received login response body', path })\n\n if (!jsonBody?.code) {\n debugLogger.error({\n msg: `No authorization code present in body. Failing login and redirecting.`,\n path,\n })\n return Response.redirect(failedRedirect)\n }\n\n // Exchange `code` from body for refresh token\n const { code } = jsonBody\n\n if (typeof code !== 'string') {\n debugLogger.error({\n msg: `Authorization code present in body is not a string. Failing login and redirecting.`,\n path,\n })\n return Response.redirect(failedRedirect)\n }\n\n const body: Record<string, string> = {\n client_id: strategy.clientID,\n code,\n code_verifier: req.payload.decrypt(state.verifier),\n grant_type: 'authorization_code',\n redirect_uri: formatAdminURL({\n apiRoute: config.routes?.api || '/api',\n path: `/${collection.slug}/${endpointSlug}/login`,\n serverURL: redirectServerURL,\n }),\n }\n\n if (strategy.collectionOptions.clientSecret) {\n body.client_secret = strategy.collectionOptions.clientSecret\n }\n\n debugLogger.info({\n msg: 'Exchanging code for access token',\n path,\n requestBody: body,\n })\n\n const tokenRes = await fetch(strategy.meta?.token_endpoint, {\n body: new URLSearchParams(body),\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n method: 'POST',\n }).then((r) => r.json())\n\n debugLogger.info({ msg: 'Token Response', path, tokenRes })\n\n const { access_token, error, error_description, expires_in: refreshTokenExpires } = tokenRes\n\n debugLogger.info({ msg: 'tokenResss', tokenRes })\n\n // Swap for project token\n const project_token = await getProjectToken(\n tokenRes.access_token,\n config.custom.figma.contentSystemId,\n )\n const refresh_token = access_token\n\n // Store project token as access_token\n\n const token = project_token.token\n const expiresIn = project_token.expiresAt\n\n if (!token) {\n const errMsg = `No ${\n collectionOptions.token || 'access_token'\n } was returned from the identity provider.`\n req.payload.logger.error({ msg: errMsg, path })\n throw new APIError(errMsg)\n }\n\n const cookieOptions = createCookieOptions({ collection, headers: req.headers, pluginOptions })\n\n if (error) {\n req.payload.logger.error('Error swapping access code with access token:')\n req.payload.logger.error({ err: error, error_description })\n return Response.redirect(failedRedirect)\n }\n\n // get the payloadRedirect cookie value\n const cookies = parseCookies(req.headers)\n\n const payloadRedirect =\n 'payloadRedirect' in cookies ? (cookies.payloadRedirect as string) : ''\n\n if (!req.responseHeaders) {\n req.responseHeaders = new Headers()\n }\n\n if (payloadRedirect) {\n if (isAbsoluteURL(payloadRedirect)) {\n redirectToUse = payloadRedirect\n } else {\n redirectToUse += payloadRedirect\n }\n\n req.responseHeaders.append(\n 'Set-Cookie',\n `payloadRedirect=${redirectToUse}; Max-Age=0; Path=/;`,\n )\n }\n\n if (refresh_token && !collectionOptions.usePayloadJWT) {\n debugLogger.info('Setting refresh token cookie')\n const refreshCookie = generateCookie({\n returnCookieAsObject: false,\n ...cookieOptions,\n name: `${strategy.cookieName}-refresh`,\n value: refresh_token,\n // Default to 1 year if no expiration\n expires: getCookieExpiration(cookieOptions?.expires ?? refreshTokenExpires ?? 31_556_952),\n }) as string\n\n req.responseHeaders.append('Set-Cookie', refreshCookie)\n }\n\n const tokenExpires = cookieOptions?.expires\n ? getCookieExpiration(cookieOptions.expires)\n : new Date(expiresIn) // Project token uses epoch time\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: tokenExpires,\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n req.responseHeaders.append('Set-Cookie', tokenCookie)\n\n return Response.redirect(redirectToUse)\n } catch (err: unknown) {\n req.payload.logger.error({ err, msg: 'Error while attempting to login', path: req.pathname })\n\n return Response.json({ error: 'Error while attempting to login' }, { status: 500 })\n }\n },\n method: collectionOptions.authorizationURLParams?.response_mode === 'query' ? 'get' : 'post',\n path: `/${endpointSlug}/login`,\n})\n"],"names":["APIError","generateCookie","parseCookies","formatAdminURL","getSafeRedirect","getProjectToken","createCookieOptions","createDebugLogger","extractOrigin","getCookieExpiration","isAbsoluteURL","url","test","getLoginEndpoint","collection","collectionOptions","endpointSlug","pluginOptions","strategy","handler","req","config","payload","adminRoute","routes","admin","ensureMeta","path","pathname","debugLogger","debug","jsonBody","contentType","headers","get","json","formData","info","msg","Response","redirect","redirectServerURL","serverURL","authorizationURLParams","response_mode","Object","keys","query","length","fromEntries","entries","stateRaw","state","JSON","parse","Buffer","from","toString","failedRedirect","redirectToUse","allowAbsoluteUrls","redirectTo","error","status","Array","isArray","csrf","failedRedirectOrigin","redirectToUseOrigin","includes","logger","name","decrypt","sig","meta","token_endpoint","body","code","client_id","clientID","code_verifier","verifier","grant_type","redirect_uri","apiRoute","api","slug","clientSecret","client_secret","requestBody","tokenRes","fetch","URLSearchParams","method","then","r","access_token","error_description","expires_in","refreshTokenExpires","project_token","custom","figma","contentSystemId","refresh_token","token","expiresIn","expiresAt","errMsg","cookieOptions","err","cookies","payloadRedirect","responseHeaders","Headers","append","usePayloadJWT","refreshCookie","returnCookieAsObject","cookieName","value","expires","tokenExpires","Date","tokenCookie"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,cAAc,EAAEC,YAAY,QAAQ,UAAS;AAChE,SAASC,cAAc,EAAEC,eAAe,QAAQ,iBAAgB;AAKhE,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,aAAa,QAAQ,gCAA+B;AAC7D,SAASC,mBAAmB,QAAQ,sCAAqC;AAUzE,MAAMC,gBAAgB,CAACC,MAAgB,qBAAqBC,IAAI,CAACD;AAEjE,OAAO,MAAME,mBAAmB,CAAC,EAC/BC,UAAU,EACVC,iBAAiB,EACjBC,YAAY,EACZC,aAAa,EACbC,QAAQ,EACH,GAAgB,CAAA;QACrBC,SAAS,OAAOC;YACd,MAAM,EAAEC,MAAM,EAAE,GAAGD,IAAIE,OAAO;YAC9B,MAAMC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tBE,OAAOf;gBACT;gBAEArF,IAAI6F,eAAe,CAACE,MAAM,CAAC,cAAcS;gBAEzC,OAAOrF,SAASC,QAAQ,CAACmB;YAC3B,EAAE,OAAOmD,KAAc;gBACrB1F,IAAIE,OAAO,CAACgD,MAAM,CAACR,KAAK,CAAC;oBAAEgD;oBAAKxE,KAAK;oBAAmCX,MAAMP,IAAIQ,QAAQ;gBAAC;gBAE3F,OAAOW,SAASJ,IAAI,CAAC;oBAAE2B,OAAO;gBAAkC,GAAG;oBAAEC,QAAQ;gBAAI;YACnF;QACF;QACA8B,QAAQ9E,kBAAkB4B,sBAAsB,EAAEC,kBAAkB,UAAU,QAAQ;QACtFjB,MAAM,CAAC,CAAC,EAAEX,aAAa,MAAM,CAAC;IAChC,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../../src/oauth/endpoints/getLoginEndpoint.ts"],"sourcesContent":["import type { CollectionConfig, Endpoint } from 'payload'\n\nimport jwt from 'jsonwebtoken'\nimport { APIError, generateCookie, parseCookies } from 'payload'\nimport { getSafeRedirect } from 'payload/shared'\n\nimport type { Strategy } from '../strategy/index.js'\nimport type {\n AfterOAuthLoginHookResult,\n CollectionOptions,\n PluginOptions,\n StateObj,\n} from '../types.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { JWTValidationError, validateProjectToken } from '../../auth/jwt-validator.js'\nimport { ProjectTokenError } from '../../auth/project-token.js'\nimport { getEnvironment } from '../../constants.js'\nimport { createCookieOptions } from '../utilities/createCookieOptions.js'\nimport { createDebugLogger } from '../utilities/createDebugLogger.js'\nimport { extractOrigin } from '../utilities/extractOrigin.js'\nimport { getAdminPath } from '../utilities/getAdminPath.js'\nimport { getCookieExpiration } from '../utilities/getCookieExpiration.js'\nimport { getSecondsFromTokenExp } from '../utilities/getSecondsFromTokenExp.js'\nimport { getTokenExp } from '../utilities/getTokenExp.js'\n\ninterface Args {\n collection: CollectionConfig\n collectionOptions: CollectionOptions\n endpointSlug: string\n pluginOptions: PluginOptions\n strategy: Strategy\n}\n\nconst isAbsoluteURL = (url: string) => /^[a-z][a-z\\d+.-]*:/.test(url)\n\nexport const getLoginEndpoint = ({\n collection,\n collectionOptions,\n endpointSlug,\n pluginOptions,\n strategy,\n}: Args): Endpoint => ({\n handler: async (req) => {\n const { config } = req.payload\n const adminPath = getAdminPath(config)\n try {\n await strategy.ensureMeta()\n\n const path = req.pathname\n const debugLogger = createDebugLogger(req.payload, pluginOptions.debug)\n\n let jsonBody: Record<string, unknown> = {}\n\n const contentType = req.headers.get('content-type')\n\n // Type narrow PayloadRequst's Partial<Request>\n if (typeof req.json !== 'function' || typeof req.formData !== 'function') {\n debugLogger.info({\n msg: 'Request does not have json or formData methods',\n path,\n })\n\n return Response.redirect(`${pluginOptions.redirectServerURL || config.serverURL}/login`)\n }\n\n if (collectionOptions.authorizationURLParams?.response_mode === 'query') {\n if (Object.keys(req.query).length > 0) {\n jsonBody = req.query\n }\n } else if (contentType === 'application/json') {\n jsonBody = await req.json()\n } else if (contentType === 'application/x-www-form-urlencoded') {\n const formData = await req.formData()\n jsonBody = Object.fromEntries(formData.entries())\n }\n\n const stateRaw = jsonBody.state as string\n const state: StateObj = JSON.parse(Buffer.from(stateRaw, 'base64').toString('utf-8'))\n\n const redirectDestination =\n state.serverURL || pluginOptions.redirectServerURL || config.serverURL\n let failedRedirect = `${redirectDestination}${adminPath}/login`\n let redirectToUse = `${redirectDestination}${adminPath}`\n\n if (state.redirect) {\n redirectToUse = state.redirect\n }\n\n if (state.failedRedirect) {\n failedRedirect = state.failedRedirect\n }\n\n failedRedirect = getSafeRedirect({ allowAbsoluteUrls: true, redirectTo: failedRedirect })\n redirectToUse = getSafeRedirect({ allowAbsoluteUrls: true, redirectTo: redirectToUse })\n\n if (!isAbsoluteURL(failedRedirect)) {\n return Response.json({ error: 'Invalid failed redirect provided' }, { status: 403 })\n }\n if (!isAbsoluteURL(redirectToUse)) {\n return Response.json({ error: 'Invalid redirect provided' }, { status: 403 })\n }\n\n if (Array.isArray(req.payload.config.csrf) && req.payload.config.csrf.length > 0) {\n const failedRedirectOrigin = extractOrigin(failedRedirect)\n const redirectToUseOrigin = extractOrigin(redirectToUse)\n\n if (failedRedirectOrigin && !req.payload.config.csrf.includes(failedRedirectOrigin)) {\n req.payload.logger.error(\n `Failed redirect origin ${failedRedirectOrigin} is not allowed by CSRF configuration.`,\n )\n return Response.json(\n { error: 'Failed redirect origin is not allowed by CSRF configuration.' },\n { status: 403 },\n )\n }\n\n if (redirectToUseOrigin && !req.payload.config.csrf.includes(redirectToUseOrigin)) {\n req.payload.logger.error(\n `Redirect origin ${redirectToUseOrigin} is not allowed by CSRF configuration.`,\n )\n return Response.json(\n { error: 'Redirect origin is not allowed by CSRF configuration.' },\n { status: 403 },\n )\n }\n }\n\n // Verify signature\n if (strategy.name !== req.payload.decrypt(state.sig)) {\n req.payload.logger.error('Signature mismatch. Failing login and redirecting.')\n return Response.redirect(failedRedirect)\n }\n\n if (!strategy.meta?.token_endpoint) {\n debugLogger.error({\n msg: `No metadata was obtained from the identity provider. Failing login and redirecting.`,\n path,\n })\n return Response.redirect(failedRedirect)\n }\n\n debugLogger.info({ body: jsonBody, msg: 'Received login response body', path })\n\n if (!jsonBody?.code) {\n debugLogger.error({\n msg: `No authorization code present in body. Failing login and redirecting.`,\n path,\n })\n return Response.redirect(failedRedirect)\n }\n\n // Exchange `code` from body for refresh token\n const { code } = jsonBody\n\n if (typeof code !== 'string') {\n debugLogger.error({\n msg: `Authorization code present in body is not a string. Failing login and redirecting.`,\n path,\n })\n return Response.redirect(failedRedirect)\n }\n\n const body: Record<string, string> = {\n client_id: strategy.clientID,\n code,\n code_verifier: req.payload.decrypt(state.verifier),\n grant_type: 'authorization_code',\n redirect_uri: `${redirectDestination}${config?.routes?.api || '/api'}/${\n collection.slug\n }/${endpointSlug}/login`,\n }\n\n debugLogger.info({\n msg: 'Exchanging code for access token',\n path,\n requestBody: body,\n })\n\n if (strategy.clientSecret) {\n body.client_secret = strategy.clientSecret\n }\n\n const tokenRes = await fetch(strategy.meta?.token_endpoint, {\n body: new URLSearchParams(body),\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n method: 'POST',\n }).then((r) => r.json())\n\n debugLogger.info({ msg: 'Token Response', path, tokenRes })\n\n const { access_token, error, error_description, expires_in: refreshTokenExpires } = tokenRes\n\n debugLogger.info({ msg: 'tokenResss', tokenRes })\n\n // Swap for project token\n const project_token = await getProjectToken(tokenRes.access_token, 'someproject')\n const refresh_token = access_token\n\n // Store project token as access_token\n\n const token = project_token.token\n const expiresIn = project_token.expiresAt\n\n if (!token) {\n const errMsg = `No ${\n collectionOptions.token || 'access_token'\n } was returned from the identity provider.`\n req.payload.logger.error({ msg: errMsg, path })\n throw new APIError(errMsg)\n }\n\n const cookieOptions = createCookieOptions({ collection, headers: req.headers, pluginOptions })\n\n if (error) {\n req.payload.logger.error('Error swapping access code with access token:')\n req.payload.logger.error({ err: error, error_description })\n return Response.redirect(failedRedirect)\n }\n\n // get the payloadRedirect cookie value\n const cookies = parseCookies(req.headers)\n\n const payloadRedirect =\n 'payloadRedirect' in cookies ? (cookies.payloadRedirect as string) : ''\n\n if (!req.responseHeaders) {\n req.responseHeaders = new Headers()\n }\n\n if (payloadRedirect) {\n if (isAbsoluteURL(payloadRedirect)) {\n redirectToUse = payloadRedirect\n } else {\n redirectToUse += payloadRedirect\n }\n\n req.responseHeaders.append(\n 'Set-Cookie',\n `payloadRedirect=${redirectToUse}; Max-Age=0; Path=/;`,\n )\n }\n\n if (refresh_token && !collectionOptions.usePayloadJWT) {\n debugLogger.info('Setting refresh token cookie')\n const refreshCookie = generateCookie({\n returnCookieAsObject: false,\n ...cookieOptions,\n name: `${strategy.cookieName}-refresh`,\n value: refresh_token,\n // Default to 1 year if no expiration\n expires: getCookieExpiration(cookieOptions?.expires ?? refreshTokenExpires ?? 31_556_952),\n }) as string\n\n req.responseHeaders.append('Set-Cookie', refreshCookie)\n }\n\n const tokenExpires = cookieOptions?.expires\n ? getCookieExpiration(cookieOptions.expires)\n : new Date(expiresIn) // Project token uses epoch time\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: tokenExpires,\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n req.responseHeaders.append('Set-Cookie', tokenCookie)\n\n return Response.redirect(redirectToUse)\n } catch (err: unknown) {\n req.payload.logger.error({ err, msg: 'Error while attempting to login', path: req.pathname })\n\n return Response.json({ error: 'Error while attempting to login' }, { status: 500 })\n }\n },\n method: collectionOptions.authorizationURLParams?.response_mode === 'query' ? 'get' : 'post',\n path: `/${endpointSlug}/login`,\n})\n"],"names":["APIError","generateCookie","parseCookies","getSafeRedirect","getProjectToken","createCookieOptions","createDebugLogger","extractOrigin","getAdminPath","getCookieExpiration","isAbsoluteURL","url","test","getLoginEndpoint","collection","collectionOptions","endpointSlug","pluginOptions","strategy","handler","req","config","payload","adminPath","ensureMeta","path","pathname","debugLogger","debug","jsonBody","contentType","headers","get","json","formData","info","msg","Response","redirect","redirectServerURL","serverURL","authorizationURLParams","response_mode","Object","keys","query","length","fromEntries","entries","stateRaw","state","JSON","parse","Buffer","from","toString","redirectDestination","failedRedirect","redirectToUse","allowAbsoluteUrls","redirectTo","error","status","Array","isArray","csrf","failedRedirectOrigin","redirectToUseOrigin","includes","logger","name","decrypt","sig","meta","token_endpoint","body","code","client_id","clientID","code_verifier","verifier","grant_type","redirect_uri","routes","api","slug","requestBody","clientSecret","client_secret","tokenRes","fetch","URLSearchParams","method","then","r","access_token","error_description","expires_in","refreshTokenExpires","project_token","refresh_token","token","expiresIn","expiresAt","errMsg","cookieOptions","err","cookies","payloadRedirect","responseHeaders","Headers","append","usePayloadJWT","refreshCookie","returnCookieAsObject","cookieName","value","expires","tokenExpires","Date","tokenCookie"],"mappings":"AAGA,SAASA,QAAQ,EAAEC,cAAc,EAAEC,YAAY,QAAQ,UAAS;AAChE,SAASC,eAAe,QAAQ,iBAAgB;AAUhD,SAASC,eAAe,QAAQ,yBAA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AAiB,2DAK3B,IAAI,KAAG,QA+ER,CAAA"}
1
+ {"version":3,"file":"getLogoutEndpoint.d.ts","sourceRoot":"","sources":["../../../src/oauth/endpoints/getLogoutEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAOhD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,eAAO,MAAM,iBAAiB,2DAK3B,IAAI,KAAG,QA4ER,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import jwt from 'jsonwebtoken';
2
2
  import { parseCookies } from 'payload';
3
- import { formatAdminURL } from 'payload/shared';
4
3
  import { clearCookie } from '../utilities/clearCookie.js';
5
4
  import { createCookieOptions } from '../utilities/createCookieOptions.js';
6
5
  import { createDebugLogger } from '../utilities/createDebugLogger.js';
6
+ import { getAdminPath } from '../utilities/getAdminPath.js';
7
7
  export const getLogoutEndpoint = ({ collection, endpointSlug, pluginOptions, strategy })=>({
8
8
  handler: async (req)=>{
9
9
  const debugLogger = createDebugLogger(req.payload, pluginOptions.debug);
@@ -23,15 +23,12 @@ export const getLogoutEndpoint = ({ collection, endpointSlug, pluginOptions, str
23
23
  }
24
24
  try {
25
25
  await strategy.ensureMeta();
26
- const redirectServerlURL = pluginOptions.redirectServerURL || config.serverURL;
27
- let successfulLogoutRedirectDest = formatAdminURL({
28
- adminRoute: config.routes?.admin || '/admin',
29
- serverURL: redirectServerlURL
30
- });
26
+ const baseRedirectDestination = pluginOptions.redirectServerURL || config.serverURL;
27
+ let successfulLogoutRedirectDest = `${baseRedirectDestination}${getAdminPath(config)}`;
31
28
  if (typeof req.query.redirect === 'string') {
32
29
  successfulLogoutRedirectDest = req.query.redirect;
33
30
  }
34
- if (!redirectServerlURL && !req.query.redirect) {
31
+ if (!baseRedirectDestination && !req.query.redirect) {
35
32
  debugLogger.error({
36
33
  msg: 'No redirect URL provided',
37
34
  path: req.pathname
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/oauth/endpoints/getLogoutEndpoint.ts"],"sourcesContent":["import type { CollectionConfig, Endpoint } from 'payload'\n\nimport jwt from 'jsonwebtoken'\nimport { parseCookies } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\n\nimport type { Strategy } from '../strategy/index.js'\nimport type { PluginOptions } from '../types.js'\n\nimport { clearCookie } from '../utilities/clearCookie.js'\nimport { createCookieOptions } from '../utilities/createCookieOptions.js'\nimport { createDebugLogger } from '../utilities/createDebugLogger.js'\n\ninterface Args {\n collection: CollectionConfig\n endpointSlug: string\n pluginOptions: PluginOptions\n strategy: Strategy\n}\n\nexport const getLogoutEndpoint = ({\n collection,\n endpointSlug,\n pluginOptions,\n strategy,\n}: Args): Endpoint => ({\n handler: async (req) => {\n const debugLogger = createDebugLogger(req.payload, pluginOptions.debug)\n const { config } = req.payload\n\n if (!req) {\n debugLogger.error({ msg: 'Invalid request to logout endpoint' })\n return Response.json({ error: 'Invalid request to logout endpoint' }, { status: 400 })\n }\n\n if (!req.responseHeaders) {\n req.responseHeaders = new Headers()\n }\n\n try {\n await strategy.ensureMeta()\n\n const redirectServerlURL = pluginOptions.redirectServerURL || config.serverURL\n\n let successfulLogoutRedirectDest = formatAdminURL({\n adminRoute: config.routes?.admin || '/admin',\n serverURL: redirectServerlURL,\n })\n\n if (typeof req.query.redirect === 'string') {\n successfulLogoutRedirectDest = req.query.redirect\n }\n\n if (!redirectServerlURL && !req.query.redirect) {\n debugLogger.error({ msg: 'No redirect URL provided', path: req.pathname })\n return Response.json({ error: 'No redirect URL provided' }, { status: 400 })\n }\n\n const cookieOptions = createCookieOptions({ collection, headers: req.headers, pluginOptions })\n\n let redirectDestination = successfulLogoutRedirectDest\n if (strategy.meta?.end_session_endpoint) {\n const cookies = parseCookies(req.headers)\n\n const token = cookies.get(strategy.cookieName)\n if (!token) {\n debugLogger.error({ msg: 'Unable to parse token from cookie.' })\n return Response.json({ error: 'Unable to parse token from cookie.' }, { status: 400 })\n }\n\n const decodedToken = jwt.decode(token)\n const sid = typeof decodedToken === 'object' && decodedToken ? decodedToken.sid : undefined\n\n const body = {\n client_id: strategy.clientID,\n logout_hint: sid,\n post_logout_redirect_uri: successfulLogoutRedirectDest,\n }\n\n const qs = new URLSearchParams(body).toString()\n redirectDestination = `${strategy.meta.end_session_endpoint}?${qs}`\n }\n\n clearCookie({\n cookieName: strategy.cookieName,\n cookieOptions,\n req,\n })\n\n clearCookie({\n cookieName: `${strategy.cookieName}-refresh`,\n cookieOptions,\n req,\n })\n\n return Response.redirect(redirectDestination)\n } catch (err: unknown) {\n req.payload.logger.error({ err, msg: 'Error while attempting to logout', path: req.pathname })\n\n return Response.json({ error: 'Error while attempting to logout' }, { status: 500 })\n }\n },\n method: 'get',\n path: `/${endpointSlug}/logout`,\n})\n"],"names":["jwt","parseCookies","formatAdminURL","clearCookie","createCookieOptions","createDebugLogger","getLogoutEndpoint","collection","endpointSlug","pluginOptions","strategy","handler","req","debugLogger","payload","debug","config","error","msg","Response","json","status","responseHeaders","Headers","ensureMeta","redirectServerlURL","redirectServerURL","serverURL","successfulLogoutRedirectDest","adminRoute","routes","admin","query","redirect","path","pathname","cookieOptions","headers","redirectDestination","meta","end_session_endpoint","cookies","token","get","cookieName","decodedToken","decode","sid","undefined","body","client_id","clientID","logout_hint","post_logout_redirect_uri","qs","URLSearchParams","toString","err","logger","method"],"mappings":"AAEA,OAAOA,SAAS,eAAc;AAC9B,SAASC,YAAY,QAAQ,UAAS;AACtC,SAASC,cAAc,QAAQ,iBAAgB;AAK/C,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,mBAAmB,QAAQ,sCA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Content":["import type { CollectionConfig, Endpoint } from 'payload'\n\nimport jwt from 'jsonwebtoken'\nimport { parseCookies } from 'payload'\n\nimport type { Strategy } from '../strategy/index.js'\nimport type { PluginOptions } from '../types.js'\n\nimport { clearCookie } from '../utilities/clearCookie.js'\nimport { createCookieOptions } from '../utilities/createCookieOptions.js'\nimport { createDebugLogger } from '../utilities/createDebugLogger.js'\nimport { getAdminPath } from '../utilities/getAdminPath.js'\n\ninterface Args {\n collection: CollectionConfig\n endpointSlug: string\n pluginOptions: PluginOptions\n strategy: Strategy\n}\n\nexport const getLogoutEndpoint = ({\n collection,\n endpointSlug,\n pluginOptions,\n strategy,\n}: Args): Endpoint => ({\n handler: async (req) => {\n const debugLogger = createDebugLogger(req.payload, pluginOptions.debug)\n const { config } = req.payload\n\n if (!req) {\n debugLogger.error({ msg: 'Invalid request to logout endpoint' })\n return Response.json({ error: 'Invalid request to logout endpoint' }, { status: 400 })\n }\n\n if (!req.responseHeaders) {\n req.responseHeaders = new Headers()\n }\n\n try {\n await strategy.ensureMeta()\n\n const baseRedirectDestination = pluginOptions.redirectServerURL || config.serverURL\n\n let successfulLogoutRedirectDest = `${baseRedirectDestination}${getAdminPath(config)}`\n\n if (typeof req.query.redirect === 'string') {\n successfulLogoutRedirectDest = req.query.redirect\n }\n\n if (!baseRedirectDestination && !req.query.redirect) {\n debugLogger.error({ msg: 'No redirect URL provided', path: req.pathname })\n return Response.json({ error: 'No redirect URL provided' }, { status: 400 })\n }\n\n const cookieOptions = createCookieOptions({ collection, headers: req.headers, pluginOptions })\n\n let redirectDestination = successfulLogoutRedirectDest\n if (strategy.meta?.end_session_endpoint) {\n const cookies = parseCookies(req.headers)\n\n const token = cookies.get(strategy.cookieName)\n if (!token) {\n debugLogger.error({ msg: 'Unable to parse token from cookie.' })\n return Response.json({ error: 'Unable to parse token from cookie.' }, { status: 400 })\n }\n\n const decodedToken = jwt.decode(token)\n const sid = typeof decodedToken === 'object' && decodedToken ? decodedToken.sid : undefined\n\n const body = {\n client_id: strategy.clientID,\n logout_hint: sid,\n post_logout_redirect_uri: successfulLogoutRedirectDest,\n }\n\n const qs = new URLSearchParams(body).toString()\n redirectDestination = `${strategy.meta.end_session_endpoint}?${qs}`\n }\n\n clearCookie({\n cookieName: strategy.cookieName,\n cookieOptions,\n req,\n })\n\n clearCookie({\n cookieName: `${strategy.cookieName}-refresh`,\n cookieOptions,\n req,\n })\n\n return Response.redirect(redirectDestination)\n } catch (err: unknown) {\n req.payload.logger.error({ err, msg: 'Error while attempting to logout', path: req.pathname })\n\n return Response.json({ error: 'Error while attempting to logout' }, { status: 500 })\n }\n },\n method: 'get',\n path: `/${endpointSlug}/logout`,\n})\n"],"names":["jwt","parseCookies","clearCookie","createCookieOptions","createDebugLogger","getAdminPath","getLogoutEndpoint","collection","endpointSlug","pluginOptions","strategy","handler","req","debugLogger","payload","debug","config","error","msg","Response","json","status","responseHeaders","Headers","ensureMeta","baseRedirectDestination","redirectServerURL","serverURL","successfulLogoutRedirectDest","query","redirect","path","pathname","cookieOptions","headers","redirectDestination","meta","end_session_endpoint","cookies","token","get","cookieName","decodedToken","decode","sid","undefined","body","client_id","clientID","logout_hint","post_logout_redirect_uri","qs","URLSearchParams","toString","err","logger","method"],"mappings":"AAEA,OAAOA,SAAS,eAAc;AAC9B,SAASC,YAAY,QAAQ,UAAS;AAKtC,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,YAAY,QAAQ,+BAA8B;AAS3D,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,QAAQ,EACH,GAAgB,CAAA;QACrBC,SAAS,OAAOC;YACd,MAAMC,cAAcT,kBAAkBQ,IAAIE,OAAO,EAAEL,cAAcM,KAAK;YACtE,MAAM,EAAEC,MAAM,EAAE,GAAGJ,IAAIE,OAAO;YAE9B,IAAI,CAACF,KAA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AMK,MAAM,OAAOF,iBAAiB,YAAYA,eAAeA,aAAaE,GAAG,GAAGC;oBAElF,MAAMC,OAAO;wBACXC,WAAWrC,SAASsC,QAAQ;wBAC5BC,aAAaL;wBACbM,0BAA0BtB;oBAC5B;oBAEA,MAAMuB,KAAK,IAAIC,gBAAgBN,MAAMO,QAAQ;oBAC7ClB,sBAAsB,GAAGzB,SAAS0B,IAAI,CAACC,oBAAoB,CAAC,CAAC,EAAEc,IAAI;gBACrE;gBAEAjD,YAAY;oBACVuC,YAAY/B,SAAS+B,UAAU;oBAC/BR;oBACArB;gBACF;gBAEAV,YAAY;oBACVuC,YAAY,GAAG/B,SAAS+B,UAAU,CAAC,QAAQ,CAAC;oBAC5CR;oBACArB;gBACF;gBAEA,OAAOO,SAASW,QAAQ,CAACK;YAC3B,EAAE,OAAOmB,KAAc;gBACrB1C,IAAIE,OAAO,CAACyC,MAAM,CAACtC,KAAK,CAAC;oBAAEqC;oBAAKpC,KAAK;oBAAoCa,MAAMnB,IAAIoB,QAAQ;gBAAC;gBAE5F,OAAOb,SAASC,IAAI,CAAC;oBAAEH,OAAO;gBAAmC,GAAG;oBAAEI,QAAQ;gBAAI;YACpF;QACF;QACAmC,QAAQ;QACRzB,MAAM,CAAC,CAAC,EAAEvB,aAAa,OAAO,CAAC;IACjC,CAAA,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoD,MAAM,EAAE,MAAM,SAAS,CAAA;AAIvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAc/C,eAAO,MAAM,YAAY,kBACP,aAAa,KAAG,MAgR/B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,MAAM,EAAE,MAAM,SAAS,CAAA;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAc/C,eAAO,MAAM,YAAY,kBACP,aAAa,KAAG,MAiP/B,CAAA"}