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

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 (352) hide show
  1. package/dist/api/control-plane.d.ts +52 -6
  2. package/dist/api/control-plane.js +174 -72
  3. package/dist/api/figma-api.d.ts +22 -1
  4. package/dist/api/figma-api.js +78 -25
  5. package/dist/auth/callback-server.js +2 -1
  6. package/dist/auth/credentials.d.ts +21 -0
  7. package/dist/auth/credentials.js +21 -0
  8. package/dist/auth/crypto-utils.d.ts +6 -0
  9. package/dist/auth/crypto-utils.js +16 -14
  10. package/dist/auth/jwt-validator.d.ts +2 -1
  11. package/dist/auth/jwt-validator.js +2 -2
  12. package/dist/auth/oauth-flow.d.ts +17 -3
  13. package/dist/auth/oauth-flow.js +63 -16
  14. package/dist/auth/project-token.js +16 -11
  15. package/dist/auth/refresh.d.ts +2 -1
  16. package/dist/auth/refresh.js +25 -12
  17. package/dist/auth/token-store.d.ts +42 -1
  18. package/dist/auth/token-store.js +118 -14
  19. package/dist/auth/types.d.ts +17 -4
  20. package/dist/cli.js +68 -5
  21. package/dist/commands/build-lambda-zip.d.ts +5 -0
  22. package/dist/commands/build-lambda-zip.js +19 -0
  23. package/dist/commands/debug.d.ts +8 -0
  24. package/dist/commands/debug.js +176 -0
  25. package/dist/commands/deploy.d.ts +9 -0
  26. package/dist/commands/deploy.js +178 -151
  27. package/dist/commands/env.d.ts +13 -0
  28. package/dist/commands/env.js +88 -0
  29. package/dist/commands/init.d.ts +3 -5
  30. package/dist/commands/init.js +165 -148
  31. package/dist/commands/list-tokens.d.ts +3 -3
  32. package/dist/commands/list-tokens.js +22 -7
  33. package/dist/commands/login.d.ts +8 -1
  34. package/dist/commands/login.js +33 -15
  35. package/dist/commands/logout.d.ts +5 -4
  36. package/dist/commands/logout.js +56 -13
  37. package/dist/commands/upgrade.d.ts +5 -0
  38. package/dist/commands/upgrade.js +331 -0
  39. package/dist/config/oauth.d.ts +4 -14
  40. package/dist/config/oauth.js +18 -40
  41. package/dist/constants.d.ts +44 -19
  42. package/dist/constants.js +73 -20
  43. package/dist/db-content-api/README.md +98 -0
  44. package/dist/db-content-api/generated/content-api-types.d.ts +3972 -0
  45. package/dist/db-content-api/generated/content-api-types.js +7 -0
  46. package/dist/db-content-api/index.d.ts +21 -0
  47. package/dist/db-content-api/index.js +914 -0
  48. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  49. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  50. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  51. package/dist/db-content-api/temp-utilities/sorting.js +39 -0
  52. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  53. package/dist/db-content-api/temp-utilities/types.js +15 -0
  54. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
  55. package/dist/db-content-api/temp-utilities/unwrapDocument.js +59 -0
  56. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  57. package/dist/db-content-api/utilities/auth.js +81 -0
  58. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  59. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  60. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  61. package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
  62. package/dist/db-content-api/utilities/data/index.d.ts +49 -0
  63. package/dist/db-content-api/utilities/data/index.js +301 -0
  64. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  65. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  66. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  67. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  68. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  69. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  70. package/dist/db-content-api/utilities/joins.d.ts +53 -0
  71. package/dist/db-content-api/utilities/joins.js +139 -0
  72. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  73. package/dist/db-content-api/utilities/locale/index.js +21 -0
  74. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  75. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
  76. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
  77. package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
  78. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
  79. package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
  80. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
  81. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
  82. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
  83. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
  84. package/dist/db-content-api/utilities/where.d.ts +20 -0
  85. package/dist/db-content-api/utilities/where.js +108 -0
  86. package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
  87. package/dist/deploy/schedule-extract-plugin.js +34 -0
  88. package/dist/endpoints/health.d.ts +3 -0
  89. package/dist/endpoints/health.js +11 -0
  90. package/dist/endpoints/schema.d.ts +3 -0
  91. package/dist/endpoints/schema.js +29 -0
  92. package/dist/exports/client.d.ts +3 -0
  93. package/dist/exports/client.js +3 -0
  94. package/dist/index.d.ts +2 -1
  95. package/dist/index.js +3 -1
  96. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  97. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  98. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  99. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  100. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  101. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  102. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  103. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  104. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  105. package/dist/oauth/components/LoginButton/index.js +50 -6
  106. package/dist/oauth/components/LoginButton/index.scss +50 -3
  107. package/dist/oauth/components/LogoutButton/index.js +5 -4
  108. package/dist/oauth/defaults.js +67 -10
  109. package/dist/oauth/endpoints/getLoginEndpoint.js +77 -24
  110. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  111. package/dist/oauth/index.js +40 -13
  112. package/dist/oauth/strategy/index.d.ts +0 -2
  113. package/dist/oauth/strategy/index.js +40 -17
  114. package/dist/oauth/types.d.ts +6 -6
  115. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  116. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  117. package/dist/oauth/utilities/refreshTokens.js +6 -3
  118. package/dist/plugin/build-config.d.ts +18 -15
  119. package/dist/plugin/build-config.js +213 -18
  120. package/dist/storage-content-api/api-types.d.ts +168 -0
  121. package/dist/storage-content-api/api-types.js +6 -0
  122. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  123. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  124. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  125. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  126. package/dist/storage-content-api/client.d.ts +6 -0
  127. package/dist/storage-content-api/client.js +36 -0
  128. package/dist/storage-content-api/generateURL.d.ts +7 -0
  129. package/dist/storage-content-api/generateURL.js +8 -0
  130. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  131. package/dist/storage-content-api/handleDelete.js +17 -0
  132. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  133. package/dist/storage-content-api/handleUpload.js +144 -0
  134. package/dist/storage-content-api/index.d.ts +5 -0
  135. package/dist/storage-content-api/index.js +31 -0
  136. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  137. package/dist/storage-content-api/staticHandler.js +56 -0
  138. package/dist/storage-content-api/types.d.ts +10 -0
  139. package/dist/storage-content-api/types.js +3 -0
  140. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  141. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  142. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  143. package/dist/storage-content-api/utilities/index.js +3 -0
  144. package/dist/templates/.env.example +5 -0
  145. package/dist/templates/README.md +19 -0
  146. package/dist/types/config.d.ts +2 -1
  147. package/dist/types/config.js +0 -2
  148. package/dist/types.d.ts +8 -1
  149. package/dist/utils/adapters/nextjs.d.ts +9 -0
  150. package/dist/utils/adapters/nextjs.js +64 -0
  151. package/dist/utils/adapters/nitro.d.ts +9 -0
  152. package/dist/utils/adapters/nitro.js +169 -0
  153. package/dist/utils/adapters/vite.d.ts +10 -0
  154. package/dist/utils/adapters/vite.js +33 -0
  155. package/dist/utils/asset-collection.d.ts +27 -6
  156. package/dist/utils/asset-collection.js +59 -30
  157. package/dist/utils/build-detection.d.ts +5 -11
  158. package/dist/utils/build-detection.js +74 -11
  159. package/dist/utils/build-lambda-zip.d.ts +14 -0
  160. package/dist/utils/build-lambda-zip.js +81 -0
  161. package/dist/utils/cache-bootstrap.d.ts +8 -0
  162. package/dist/utils/cache-bootstrap.js +18 -0
  163. package/dist/utils/config.js +1 -1
  164. package/dist/utils/deploy-adapter.d.ts +40 -0
  165. package/dist/utils/deploy-adapter.js +58 -0
  166. package/dist/utils/download-template.js +3 -2
  167. package/dist/utils/env-management.d.ts +24 -7
  168. package/dist/utils/env-management.js +119 -64
  169. package/dist/utils/format-env-suffix.d.ts +12 -0
  170. package/dist/utils/format-env-suffix.js +13 -0
  171. package/dist/utils/formatter.js +23 -11
  172. package/dist/utils/fs-utils.d.ts +6 -0
  173. package/dist/utils/fs-utils.js +27 -0
  174. package/dist/utils/handle-upgrade.d.ts +9 -0
  175. package/dist/utils/handle-upgrade.js +41 -0
  176. package/dist/utils/lambda-config.d.ts +3 -1
  177. package/dist/utils/lambda-config.js +75 -78
  178. package/dist/utils/messages.d.ts +1 -2
  179. package/dist/utils/messages.js +29 -11
  180. package/dist/utils/package-manager.d.ts +24 -0
  181. package/dist/utils/package-manager.js +53 -0
  182. package/dist/utils/payload-config-ast.d.ts +27 -6
  183. package/dist/utils/payload-config-ast.js +106 -58
  184. package/dist/utils/payload-config-finder.d.ts +2 -2
  185. package/dist/utils/payload-config-finder.js +48 -9
  186. package/dist/utils/payload-config-modifier.d.ts +1 -1
  187. package/dist/utils/payload-config-modifier.js +70 -11
  188. package/dist/utils/payload-package-check.d.ts +12 -1
  189. package/dist/utils/payload-package-check.js +63 -5
  190. package/dist/utils/project.d.ts +3 -2
  191. package/dist/utils/project.js +29 -15
  192. package/dist/utils/resolve-environment.d.ts +14 -0
  193. package/dist/utils/resolve-environment.js +31 -0
  194. package/dist/utils/s3-upload.d.ts +7 -2
  195. package/dist/utils/s3-upload.js +39 -6
  196. package/dist/utils/token-display.js +11 -5
  197. package/dist/utils/typescript-validator.js +4 -6
  198. package/dist/utils/version-check.d.ts +3 -0
  199. package/dist/utils/version-check.js +38 -0
  200. package/package.json +33 -15
  201. package/dist/api/control-plane.d.ts.map +0 -1
  202. package/dist/api/control-plane.js.map +0 -1
  203. package/dist/api/figma-api.d.ts.map +0 -1
  204. package/dist/api/figma-api.js.map +0 -1
  205. package/dist/auth/browser.d.ts.map +0 -1
  206. package/dist/auth/browser.js.map +0 -1
  207. package/dist/auth/callback-server.d.ts.map +0 -1
  208. package/dist/auth/callback-server.js.map +0 -1
  209. package/dist/auth/crypto-utils.d.ts.map +0 -1
  210. package/dist/auth/crypto-utils.js.map +0 -1
  211. package/dist/auth/jwt-validator.d.ts.map +0 -1
  212. package/dist/auth/jwt-validator.js.map +0 -1
  213. package/dist/auth/oauth-flow.d.ts.map +0 -1
  214. package/dist/auth/oauth-flow.js.map +0 -1
  215. package/dist/auth/pkce.d.ts.map +0 -1
  216. package/dist/auth/pkce.js.map +0 -1
  217. package/dist/auth/project-token.d.ts.map +0 -1
  218. package/dist/auth/project-token.js.map +0 -1
  219. package/dist/auth/refresh.d.ts.map +0 -1
  220. package/dist/auth/refresh.js.map +0 -1
  221. package/dist/auth/token-store.d.ts.map +0 -1
  222. package/dist/auth/token-store.js.map +0 -1
  223. package/dist/auth/types.d.ts.map +0 -1
  224. package/dist/auth/types.js.map +0 -1
  225. package/dist/cli.d.ts.map +0 -1
  226. package/dist/cli.js.map +0 -1
  227. package/dist/commands/deploy.d.ts.map +0 -1
  228. package/dist/commands/deploy.js.map +0 -1
  229. package/dist/commands/init.d.ts.map +0 -1
  230. package/dist/commands/init.js.map +0 -1
  231. package/dist/commands/list-tokens.d.ts.map +0 -1
  232. package/dist/commands/list-tokens.js.map +0 -1
  233. package/dist/commands/login.d.ts.map +0 -1
  234. package/dist/commands/login.js.map +0 -1
  235. package/dist/commands/logout.d.ts.map +0 -1
  236. package/dist/commands/logout.js.map +0 -1
  237. package/dist/config/oauth.d.ts.map +0 -1
  238. package/dist/config/oauth.js.map +0 -1
  239. package/dist/constants.d.ts.map +0 -1
  240. package/dist/constants.js.map +0 -1
  241. package/dist/exports/client.d.ts.map +0 -1
  242. package/dist/exports/client.js.map +0 -1
  243. package/dist/index.d.ts.map +0 -1
  244. package/dist/index.js.map +0 -1
  245. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  246. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  247. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  248. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  249. package/dist/oauth/defaults.d.ts.map +0 -1
  250. package/dist/oauth/defaults.js.map +0 -1
  251. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  252. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  253. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  254. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  255. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  256. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  257. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  258. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  259. package/dist/oauth/exports/client.d.ts.map +0 -1
  260. package/dist/oauth/exports/client.js.map +0 -1
  261. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  262. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  263. package/dist/oauth/hooks/me.d.ts.map +0 -1
  264. package/dist/oauth/hooks/me.js.map +0 -1
  265. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  266. package/dist/oauth/hooks/refresh.js.map +0 -1
  267. package/dist/oauth/index.d.ts.map +0 -1
  268. package/dist/oauth/index.js.map +0 -1
  269. package/dist/oauth/strategy/index.d.ts.map +0 -1
  270. package/dist/oauth/strategy/index.js.map +0 -1
  271. package/dist/oauth/types.d.ts.map +0 -1
  272. package/dist/oauth/types.js.map +0 -1
  273. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  274. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  275. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  276. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  277. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  278. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  279. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  280. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  281. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  282. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  283. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  284. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  285. package/dist/oauth/utilities/getAdminPath.js +0 -9
  286. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  287. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  288. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  289. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  290. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  291. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  292. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  293. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  294. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  295. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  296. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  297. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  298. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  299. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  300. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  301. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  302. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  303. package/dist/plugin/adapter.d.ts.map +0 -1
  304. package/dist/plugin/adapter.js.map +0 -1
  305. package/dist/plugin/build-config.d.ts.map +0 -1
  306. package/dist/plugin/build-config.js.map +0 -1
  307. package/dist/types/config.d.ts.map +0 -1
  308. package/dist/types/config.js.map +0 -1
  309. package/dist/types.d.ts.map +0 -1
  310. package/dist/types.js.map +0 -1
  311. package/dist/utils/asset-collection.d.ts.map +0 -1
  312. package/dist/utils/asset-collection.js.map +0 -1
  313. package/dist/utils/build-detection.d.ts.map +0 -1
  314. package/dist/utils/build-detection.js.map +0 -1
  315. package/dist/utils/config.d.ts.map +0 -1
  316. package/dist/utils/config.js.map +0 -1
  317. package/dist/utils/download-template.d.ts.map +0 -1
  318. package/dist/utils/download-template.js.map +0 -1
  319. package/dist/utils/env-management.d.ts.map +0 -1
  320. package/dist/utils/env-management.js.map +0 -1
  321. package/dist/utils/format.d.ts.map +0 -1
  322. package/dist/utils/format.js.map +0 -1
  323. package/dist/utils/formatter.d.ts.map +0 -1
  324. package/dist/utils/formatter.js.map +0 -1
  325. package/dist/utils/git.d.ts.map +0 -1
  326. package/dist/utils/git.js.map +0 -1
  327. package/dist/utils/is-debug.d.ts.map +0 -1
  328. package/dist/utils/is-debug.js.map +0 -1
  329. package/dist/utils/lambda-config.d.ts.map +0 -1
  330. package/dist/utils/lambda-config.js.map +0 -1
  331. package/dist/utils/log.d.ts.map +0 -1
  332. package/dist/utils/log.js.map +0 -1
  333. package/dist/utils/messages.d.ts.map +0 -1
  334. package/dist/utils/messages.js.map +0 -1
  335. package/dist/utils/package-manager.d.ts.map +0 -1
  336. package/dist/utils/package-manager.js.map +0 -1
  337. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  338. package/dist/utils/payload-config-ast.js.map +0 -1
  339. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  340. package/dist/utils/payload-config-finder.js.map +0 -1
  341. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  342. package/dist/utils/payload-config-modifier.js.map +0 -1
  343. package/dist/utils/payload-package-check.d.ts.map +0 -1
  344. package/dist/utils/payload-package-check.js.map +0 -1
  345. package/dist/utils/project.d.ts.map +0 -1
  346. package/dist/utils/project.js.map +0 -1
  347. package/dist/utils/s3-upload.d.ts.map +0 -1
  348. package/dist/utils/s3-upload.js.map +0 -1
  349. package/dist/utils/token-display.d.ts.map +0 -1
  350. package/dist/utils/token-display.js.map +0 -1
  351. package/dist/utils/typescript-validator.d.ts.map +0 -1
  352. package/dist/utils/typescript-validator.js.map +0 -1
@@ -1,4 +1,7 @@
1
+ export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js';
2
+ export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
1
3
  export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
2
4
  export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
5
+ export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
3
6
 
4
7
  //# sourceMappingURL=client.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ export { contentAPIAdapter } from './db-content-api/index.js';
1
2
  export { figmaContentSystem } from './plugin/adapter.js';
2
3
  export type { FigmaContentSystemOptions } from './plugin/adapter.js';
3
- export { buildConfig } from './plugin/build-config.js';
4
+ export { buildFigmaConfig } from './plugin/build-config.js';
4
5
  export type { FigmaConfig } from './plugin/build-config.js';
5
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ // Export contentAPIAdapter for testing use cases
2
+ export { contentAPIAdapter } from './db-content-api/index.js';
1
3
  // Export database adapter for advanced use cases
2
4
  export { figmaContentSystem } from './plugin/adapter.js';
3
5
  // Export buildConfig wrapper and its config type
4
- export { buildConfig } from './plugin/build-config.js';
6
+ export { buildFigmaConfig } from './plugin/build-config.js';
5
7
 
6
8
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import './index.scss';
3
+ export declare const FigmaAvatar: React.FC;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,27 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useAuth } from '@payloadcms/ui';
4
+ import { useState } from 'react';
5
+ import { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js';
6
+ import './index.scss';
7
+ const baseClass = 'figma-avatar';
8
+ export const FigmaAvatar = ()=>{
9
+ const { user } = useAuth();
10
+ const [hasError, setHasError] = useState(false);
11
+ const figmaImageUrl = user?.figmaImageUrl;
12
+ if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {
13
+ return /*#__PURE__*/ _jsx(FigmaAvatarPlaceholder, {
14
+ size: 25
15
+ });
16
+ }
17
+ return /*#__PURE__*/ _jsx("img", {
18
+ alt: "Profile",
19
+ className: `${baseClass}__image`,
20
+ height: 25,
21
+ onError: ()=>setHasError(true),
22
+ src: figmaImageUrl,
23
+ width: 25
24
+ });
25
+ };
26
+
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ @layer payload-default {
2
+ .figma-avatar {
3
+ &__image {
4
+ border-radius: 50%;
5
+ border: 1px solid var(--theme-elevation-200);
6
+
7
+ &:hover {
8
+ border-color: var(--theme-elevation-600);
9
+ }
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,5 @@
1
+ import type { DefaultCellComponentProps } from 'payload';
2
+ import type React from 'react';
3
+ import './index.scss';
4
+ export declare const FigmaAvatarCell: React.FC<DefaultCellComponentProps>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js';
5
+ import './index.scss';
6
+ const baseClass = 'figma-avatar-cell';
7
+ export const FigmaAvatarCell = ({ cellData })=>{
8
+ const [hasError, setHasError] = useState(false);
9
+ const figmaImageUrl = cellData;
10
+ if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {
11
+ return /*#__PURE__*/ _jsx(FigmaAvatarPlaceholder, {
12
+ size: 20
13
+ });
14
+ }
15
+ return /*#__PURE__*/ _jsx("img", {
16
+ alt: "Avatar",
17
+ className: `${baseClass}__image`,
18
+ height: 20,
19
+ onError: ()=>setHasError(true),
20
+ src: figmaImageUrl,
21
+ width: 20
22
+ });
23
+ };
24
+
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ .figma-avatar-cell {
2
+ &__image {
3
+ border-radius: 50%;
4
+ }
5
+ }
@@ -0,0 +1,9 @@
1
+ import type React from 'react';
2
+ import './index.scss';
3
+ type FigmaAvatarPlaceholderProps = {
4
+ size?: number;
5
+ };
6
+ export declare const FigmaAvatarPlaceholder: React.FC<FigmaAvatarPlaceholderProps>;
7
+ export declare function isValidImageUrl(url: string): boolean;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import './index.scss';
3
+ const baseClass = 'figma-avatar-placeholder';
4
+ export const FigmaAvatarPlaceholder = ({ size = 25 })=>/*#__PURE__*/ _jsxs("svg", {
5
+ className: baseClass,
6
+ height: size,
7
+ viewBox: "0 0 25 25",
8
+ width: size,
9
+ children: [
10
+ /*#__PURE__*/ _jsx("circle", {
11
+ className: `${baseClass}__bg`,
12
+ cx: "12.5",
13
+ cy: "12.5",
14
+ r: "11.5"
15
+ }),
16
+ /*#__PURE__*/ _jsx("circle", {
17
+ className: `${baseClass}__head`,
18
+ cx: "12.5",
19
+ cy: "10",
20
+ r: "4"
21
+ }),
22
+ /*#__PURE__*/ _jsx("path", {
23
+ className: `${baseClass}__body`,
24
+ d: "M12.5 15c-4 0-7 2-7 4.5v1h14v-1c0-2.5-3-4.5-7-4.5z"
25
+ })
26
+ ]
27
+ });
28
+ export function isValidImageUrl(url) {
29
+ try {
30
+ const parsed = new URL(url);
31
+ return parsed.protocol === 'https:' || parsed.protocol === 'http:';
32
+ } catch {
33
+ return false;
34
+ }
35
+ }
36
+
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,28 @@
1
+ @layer payload-default {
2
+ .figma-avatar-placeholder {
3
+ &__bg {
4
+ fill: var(--theme-elevation-50);
5
+ stroke: var(--theme-elevation-200);
6
+ stroke-width: 1px;
7
+ }
8
+
9
+ &__head,
10
+ &__body {
11
+ fill: var(--theme-elevation-200);
12
+ }
13
+
14
+ &:hover {
15
+ .figma-avatar-placeholder {
16
+ &__bg {
17
+ fill: var(--theme-elevation-200);
18
+ stroke: var(--theme-elevation-600);
19
+ }
20
+
21
+ &__head,
22
+ &__body {
23
+ fill: var(--theme-elevation-600);
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
@@ -1,10 +1,49 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Button, useConfig } from '@payloadcms/ui';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { 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
+ });
8
47
  export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
9
48
  const { config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
10
49
  const [authorizeURL, setAuthorizeURL] = useState('');
@@ -40,11 +79,16 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
40
79
  }
41
80
  return /*#__PURE__*/ _jsx("div", {
42
81
  className: baseClass,
43
- children: /*#__PURE__*/ _jsx(Button, {
82
+ children: /*#__PURE__*/ _jsxs("a", {
44
83
  className: `${baseClass}__btn`,
45
- el: "anchor",
46
- url: authorizeURL,
47
- children: "Log in"
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
+ ]
48
92
  })
49
93
  });
50
94
  };
@@ -1,10 +1,57 @@
1
1
  .oauth-login {
2
2
  display: flex;
3
3
  justify-content: center;
4
+ padding: 1rem 0;
4
5
 
5
- &__btn:focus {
6
- .btn__icon {
7
- background: none;
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);
8
38
  }
9
39
  }
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
+ }
10
57
  }
@@ -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';
4
5
  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,9 +16,10 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
16
16
  if (port) {
17
17
  redirectToSet += `:${port}`;
18
18
  }
19
- redirectToSet += getAdminPath(config);
20
- // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
21
- setRedirect(redirectToSet);
19
+ setRedirect(formatAdminURL({
20
+ adminRoute: config.routes.admin,
21
+ serverURL: redirectToSet
22
+ }));
22
23
  }, [
23
24
  config
24
25
  ]);
@@ -1,5 +1,19 @@
1
+ import { parseCookies } from 'payload';
1
2
  import { v4 as uuid } from 'uuid';
2
3
  import { hasUserTokenPropsChanged } from './utilities/hasUserTokenPropsChanged.js';
4
+ import { isDuplicateKeyError } from './utilities/isDuplicateKeyError.js';
5
+ function getFigmaUserInfo(headers) {
6
+ try {
7
+ const cookies = parseCookies(headers);
8
+ const encoded = cookies.get('figma-user-info');
9
+ if (!encoded) {
10
+ return null;
11
+ }
12
+ return JSON.parse(Buffer.from(encoded, 'base64').toString('utf-8'));
13
+ } catch {
14
+ return null;
15
+ }
16
+ }
3
17
  export const defaultScope = [
4
18
  'openid',
5
19
  'profile',
@@ -14,7 +28,7 @@ export const defaultUsernameField = {
14
28
  },
15
29
  unique: true
16
30
  };
17
- export const defaultVerify = ({ collection, strategyName, usernameField })=>async ({ payload, token })=>{
31
+ export const defaultVerify = ({ collection, strategyName, usernameField })=>async ({ headers, payload, token })=>{
18
32
  let tokenUsername = 'preferred_username';
19
33
  if (usernameField.name !== 'preferredUsername') {
20
34
  tokenUsername = usernameField.name;
@@ -24,6 +38,13 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
24
38
  user: null
25
39
  };
26
40
  }
41
+ const figmaUserInfo = getFigmaUserInfo(headers);
42
+ let responseHeaders;
43
+ // Clear the cookie after reading
44
+ if (figmaUserInfo) {
45
+ responseHeaders = new Headers();
46
+ responseHeaders.append('Set-Cookie', 'figma-user-info=; Max-Age=0; Path=/;');
47
+ }
27
48
  let user = null;
28
49
  const depth = typeof collection.auth === 'object' ? collection.auth.depth : undefined;
29
50
  try {
@@ -40,13 +61,19 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
40
61
  });
41
62
  if (results.docs.length > 0) {
42
63
  user = results.docs[0];
43
- // Update user with new token data
44
- if (hasUserTokenPropsChanged(user, token)) {
64
+ // Check if update needed (token changed OR figma info missing/changed)
65
+ const userWithFigma = user;
66
+ const needsFigmaUpdate = figmaUserInfo && (userWithFigma.figmaHandle !== figmaUserInfo.handle || userWithFigma.figmaImageUrl !== figmaUserInfo.img_url);
67
+ if (hasUserTokenPropsChanged(user, token) || needsFigmaUpdate) {
45
68
  user = await payload.update({
46
69
  id: user.id,
47
70
  collection: collection.slug,
48
71
  data: {
49
- ...token
72
+ ...token,
73
+ ...figmaUserInfo && {
74
+ figmaHandle: figmaUserInfo.handle,
75
+ figmaImageUrl: figmaUserInfo.img_url
76
+ }
50
77
  },
51
78
  depth
52
79
  });
@@ -55,16 +82,43 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
55
82
  const newUser = {
56
83
  email: token.preferredUsername || token.email,
57
84
  [usernameField.name]: token[tokenUsername],
58
- ...token
85
+ ...token,
86
+ ...figmaUserInfo && {
87
+ figmaHandle: figmaUserInfo.handle,
88
+ figmaImageUrl: figmaUserInfo.img_url
89
+ }
59
90
  };
60
91
  if (typeof collection.auth === 'object' && !collection.auth.disableLocalStrategy) {
61
92
  newUser.password = uuid();
62
93
  }
63
- user = await payload.create({
64
- collection: collection.slug,
65
- data: newUser,
66
- depth
67
- });
94
+ try {
95
+ user = await payload.create({
96
+ collection: collection.slug,
97
+ data: newUser,
98
+ depth,
99
+ overrideAccess: true
100
+ });
101
+ } catch (createErr) {
102
+ // Race condition: if unique constraint violation, user was created by concurrent request
103
+ if (isDuplicateKeyError(createErr)) {
104
+ const retryResults = await payload.find({
105
+ collection: collection.slug,
106
+ depth,
107
+ limit: 1,
108
+ pagination: false,
109
+ where: {
110
+ [usernameField.name]: {
111
+ equals: token[tokenUsername]
112
+ }
113
+ }
114
+ });
115
+ if (retryResults.docs.length > 0) {
116
+ user = retryResults.docs[0];
117
+ }
118
+ } else {
119
+ throw createErr;
120
+ }
121
+ }
68
122
  }
69
123
  } catch (err) {
70
124
  payload.logger.error({
@@ -72,6 +126,7 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
72
126
  msg: 'Error verifying user from defaultVerify.'
73
127
  });
74
128
  return {
129
+ responseHeaders,
75
130
  user: null
76
131
  };
77
132
  }
@@ -80,10 +135,12 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
80
135
  user._strategy = strategyName;
81
136
  user.exp = token.exp;
82
137
  return {
138
+ responseHeaders,
83
139
  user
84
140
  };
85
141
  }
86
142
  return {
143
+ responseHeaders,
87
144
  user: null
88
145
  };
89
146
  };
@@ -1,16 +1,15 @@
1
1
  import { APIError, generateCookie, parseCookies } from 'payload';
2
- import { getSafeRedirect } from 'payload/shared';
3
- import { getProjectToken } from '../../api/figma-api.js';
2
+ import { formatAdminURL, getSafeRedirect } from 'payload/shared';
3
+ import { getProjectToken, getUserInfo } 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';
8
7
  import { getCookieExpiration } from '../utilities/getCookieExpiration.js';
9
8
  const isAbsoluteURL = (url)=>/^[a-z][a-z\d+.-]*:/.test(url);
10
9
  export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug, pluginOptions, strategy })=>({
11
10
  handler: async (req)=>{
12
11
  const { config } = req.payload;
13
- const adminPath = getAdminPath(config);
12
+ const adminRoute = config.routes?.admin || '/admin';
14
13
  try {
15
14
  await strategy.ensureMeta();
16
15
  const path = req.pathname;
@@ -37,9 +36,16 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
37
36
  }
38
37
  const stateRaw = jsonBody.state;
39
38
  const state = JSON.parse(Buffer.from(stateRaw, 'base64').toString('utf-8'));
40
- const redirectDestination = state.serverURL || pluginOptions.redirectServerURL || config.serverURL;
41
- let failedRedirect = `${redirectDestination}${adminPath}/login`;
42
- let redirectToUse = `${redirectDestination}${adminPath}`;
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
+ });
43
49
  if (state.redirect) {
44
50
  redirectToUse = state.redirect;
45
51
  }
@@ -126,16 +132,20 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
126
132
  code,
127
133
  code_verifier: req.payload.decrypt(state.verifier),
128
134
  grant_type: 'authorization_code',
129
- redirect_uri: `${redirectDestination}${config?.routes?.api || '/api'}/${collection.slug}/${endpointSlug}/login`
135
+ redirect_uri: formatAdminURL({
136
+ apiRoute: config.routes?.api || '/api',
137
+ path: `/${collection.slug}/${endpointSlug}/login`,
138
+ serverURL: redirectServerURL
139
+ })
130
140
  };
141
+ if (strategy.collectionOptions.clientSecret) {
142
+ body.client_secret = strategy.collectionOptions.clientSecret;
143
+ }
131
144
  debugLogger.info({
132
145
  msg: 'Exchanging code for access token',
133
146
  path,
134
147
  requestBody: body
135
148
  });
136
- if (strategy.clientSecret) {
137
- body.client_secret = strategy.clientSecret;
138
- }
139
149
  const tokenRes = await fetch(strategy.meta?.token_endpoint, {
140
150
  body: new URLSearchParams(body),
141
151
  headers: {
@@ -149,12 +159,48 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
149
159
  tokenRes
150
160
  });
151
161
  const { access_token, error, error_description, expires_in: refreshTokenExpires } = tokenRes;
152
- debugLogger.info({
153
- msg: 'tokenResss',
154
- tokenRes
155
- });
162
+ if (error) {
163
+ req.payload.logger.error('Error swapping access code with access token:');
164
+ req.payload.logger.error({
165
+ err: error,
166
+ error_description
167
+ });
168
+ return Response.redirect(failedRedirect);
169
+ }
170
+ // Fetch Figma user info for handle and profile image
171
+ let figmaUserInfo = null;
172
+ try {
173
+ const oauthCredential = {
174
+ type: 'oauth',
175
+ token: access_token
176
+ };
177
+ figmaUserInfo = await getUserInfo(oauthCredential);
178
+ debugLogger.info({
179
+ figmaUserInfo,
180
+ msg: 'Fetched Figma user info'
181
+ });
182
+ } catch (err) {
183
+ // Non-fatal: user will just not have handle/image
184
+ debugLogger.error({
185
+ err,
186
+ msg: 'Failed to fetch Figma user info'
187
+ });
188
+ }
189
+ if (!access_token) {
190
+ const errMsg = 'No access_token was returned from the identity provider.';
191
+ req.payload.logger.error({
192
+ msg: errMsg,
193
+ path,
194
+ tokenRes
195
+ });
196
+ throw new APIError(errMsg);
197
+ }
156
198
  // Swap for project token
157
- const project_token = await getProjectToken(tokenRes.access_token, 'someproject');
199
+ const oauthCredential = {
200
+ type: 'oauth',
201
+ token: access_token
202
+ };
203
+ const project_token = await getProjectToken(oauthCredential, config.custom.figma.contentSystemId);
158
204
  const refresh_token = access_token;
159
205
  // Store project token as access_token
160
206
  const token = project_token.token;
@@ -172,14 +218,6 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
172
218
  headers: req.headers,
173
219
  pluginOptions
174
220
  });
175
- if (error) {
176
- req.payload.logger.error('Error swapping access code with access token:');
177
- req.payload.logger.error({
178
- err: error,
179
- error_description
180
- });
181
- return Response.redirect(failedRedirect);
182
- }
183
221
  // get the payloadRedirect cookie value
184
222
  const cookies = parseCookies(req.headers);
185
223
  const payloadRedirect = 'payloadRedirect' in cookies ? cookies.payloadRedirect : '';
@@ -216,6 +254,21 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
216
254
  value: token
217
255
  });
218
256
  req.responseHeaders.append('Set-Cookie', tokenCookie);
257
+ // Store user info in short-lived cookie for defaultVerify to consume
258
+ if (figmaUserInfo) {
259
+ const userInfoValue = Buffer.from(JSON.stringify({
260
+ handle: figmaUserInfo.handle,
261
+ img_url: figmaUserInfo.img_url
262
+ })).toString('base64');
263
+ const userInfoCookie = generateCookie({
264
+ ...cookieOptions,
265
+ name: 'figma-user-info',
266
+ expires: new Date(Date.now() + 60_000),
267
+ returnCookieAsObject: false,
268
+ value: userInfoValue
269
+ });
270
+ req.responseHeaders.append('Set-Cookie', userInfoCookie);
271
+ }
219
272
  return Response.redirect(redirectToUse);
220
273
  } catch (err) {
221
274
  req.payload.logger.error({