@payloadcms/figma 0.0.1-alpha.9 → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (470) hide show
  1. package/dist/api/control-plane.d.ts +56 -7
  2. package/dist/api/control-plane.js +188 -74
  3. package/dist/api/error-response.d.ts +36 -0
  4. package/dist/api/error-response.js +66 -0
  5. package/dist/api/figma-api.d.ts +24 -3
  6. package/dist/api/figma-api.js +110 -34
  7. package/dist/auth/browser.d.ts +0 -1
  8. package/dist/auth/browser.js +0 -2
  9. package/dist/auth/callback-server.d.ts +19 -8
  10. package/dist/auth/callback-server.js +72 -32
  11. package/dist/auth/credentials.d.ts +20 -0
  12. package/dist/auth/credentials.js +19 -0
  13. package/dist/auth/crypto-utils.d.ts +28 -1
  14. package/dist/auth/crypto-utils.js +132 -23
  15. package/dist/auth/jwt-validator.d.ts +23 -6
  16. package/dist/auth/jwt-validator.js +35 -9
  17. package/dist/auth/oauth-flow.d.ts +19 -4
  18. package/dist/auth/oauth-flow.js +151 -34
  19. package/dist/auth/paste-code.d.ts +33 -0
  20. package/dist/auth/paste-code.js +87 -0
  21. package/dist/auth/pkce.d.ts +0 -1
  22. package/dist/auth/pkce.js +0 -2
  23. package/dist/auth/project-token.d.ts +32 -17
  24. package/dist/auth/project-token.js +176 -68
  25. package/dist/auth/refresh.d.ts +2 -2
  26. package/dist/auth/refresh.js +25 -14
  27. package/dist/auth/token-store-migration.d.ts +57 -0
  28. package/dist/auth/token-store-migration.js +154 -0
  29. package/dist/auth/token-store.d.ts +63 -98
  30. package/dist/auth/token-store.js +405 -124
  31. package/dist/auth/types.d.ts +40 -6
  32. package/dist/auth/types.js +1 -3
  33. package/dist/cli.d.ts +0 -1
  34. package/dist/cli.js +102 -8
  35. package/dist/commands/bootstrap.d.ts +17 -0
  36. package/dist/commands/bootstrap.js +88 -0
  37. package/dist/commands/build-lambda-zip.d.ts +4 -0
  38. package/dist/commands/build-lambda-zip.js +17 -0
  39. package/dist/commands/debug.d.ts +7 -0
  40. package/dist/commands/debug.js +178 -0
  41. package/dist/commands/deploy.d.ts +11 -1
  42. package/dist/commands/deploy.js +193 -153
  43. package/dist/commands/dump-tokens.d.ts +11 -0
  44. package/dist/commands/dump-tokens.js +67 -0
  45. package/dist/commands/env.d.ts +12 -0
  46. package/dist/commands/env.js +86 -0
  47. package/dist/commands/init.d.ts +9 -6
  48. package/dist/commands/init.js +232 -152
  49. package/dist/commands/list-tokens.d.ts +3 -4
  50. package/dist/commands/list-tokens.js +24 -11
  51. package/dist/commands/login.d.ts +8 -2
  52. package/dist/commands/login.js +34 -18
  53. package/dist/commands/logout.d.ts +5 -5
  54. package/dist/commands/logout.js +77 -17
  55. package/dist/commands/upgrade.d.ts +4 -0
  56. package/dist/commands/upgrade.js +329 -0
  57. package/dist/commands/upload-schema.d.ts +8 -0
  58. package/dist/commands/upload-schema.js +91 -0
  59. package/dist/config/oauth.d.ts +17 -12
  60. package/dist/config/oauth.js +38 -39
  61. package/dist/constants.d.ts +63 -19
  62. package/dist/constants.js +158 -20
  63. package/dist/db-content-api/generated/content-api-types.d.ts +7574 -0
  64. package/dist/db-content-api/generated/content-api-types.js +5 -0
  65. package/dist/db-content-api/index.d.ts +37 -0
  66. package/dist/db-content-api/index.js +938 -0
  67. package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
  68. package/dist/db-content-api/temp-utilities/slug.js +1 -0
  69. package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
  70. package/dist/db-content-api/temp-utilities/sorting.js +37 -0
  71. package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
  72. package/dist/db-content-api/temp-utilities/types.js +13 -0
  73. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
  74. package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
  75. package/dist/db-content-api/utilities/auth.d.ts +29 -0
  76. package/dist/db-content-api/utilities/auth.js +82 -0
  77. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
  78. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  79. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
  80. package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
  81. package/dist/db-content-api/utilities/data/index.d.ts +48 -0
  82. package/dist/db-content-api/utilities/data/index.js +299 -0
  83. package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
  84. package/dist/db-content-api/utilities/data/pointShape.js +43 -0
  85. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
  86. package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
  87. package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
  88. package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
  89. package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
  90. package/dist/db-content-api/utilities/data/stripFields.js +170 -0
  91. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
  92. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
  93. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
  94. package/dist/db-content-api/utilities/data/validateRelationships.js +100 -0
  95. package/dist/db-content-api/utilities/joins.d.ts +52 -0
  96. package/dist/db-content-api/utilities/joins.js +137 -0
  97. package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
  98. package/dist/db-content-api/utilities/locale/index.js +19 -0
  99. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +10 -0
  100. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +71 -0
  101. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +41 -0
  102. package/dist/db-content-api/utilities/meta/buildMeta.js +39 -0
  103. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +16 -0
  104. package/dist/db-content-api/utilities/meta/buildPathTypes.js +243 -0
  105. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +12 -0
  106. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +60 -0
  107. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
  108. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
  109. package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
  110. package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
  111. package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +55 -0
  112. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +182 -0
  113. package/dist/db-content-api/utilities/where.d.ts +19 -0
  114. package/dist/db-content-api/utilities/where.js +106 -0
  115. package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
  116. package/dist/deploy/schedule-extract-plugin.js +32 -0
  117. package/dist/endpoints/health.d.ts +2 -0
  118. package/dist/endpoints/health.js +9 -0
  119. package/dist/endpoints/schema.d.ts +2 -0
  120. package/dist/endpoints/schema.js +27 -0
  121. package/dist/exports/client.d.ts +2 -1
  122. package/dist/exports/client.js +2 -2
  123. package/dist/index.d.ts +2 -2
  124. package/dist/index.js +3 -3
  125. package/dist/lib/download-skill.d.ts +12 -0
  126. package/dist/lib/download-skill.js +77 -0
  127. package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
  128. package/dist/oauth/components/FigmaAvatar/index.js +25 -0
  129. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  130. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
  131. package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
  132. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  133. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
  134. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
  135. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  136. package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
  137. package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
  138. package/dist/oauth/components/LoginButton/index.d.ts +0 -1
  139. package/dist/oauth/components/LoginButton/index.js +156 -18
  140. package/dist/oauth/components/LoginButton/index.scss +75 -3
  141. package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
  142. package/dist/oauth/components/LogoutButton/index.js +20 -9
  143. package/dist/oauth/defaults.d.ts +3 -2
  144. package/dist/oauth/defaults.js +79 -12
  145. package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
  146. package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
  147. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
  148. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
  149. package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
  150. package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
  151. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
  152. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
  153. package/dist/oauth/exports/client.d.ts +0 -1
  154. package/dist/oauth/exports/client.js +0 -2
  155. package/dist/oauth/hooks/afterLogout.d.ts +0 -1
  156. package/dist/oauth/hooks/afterLogout.js +0 -2
  157. package/dist/oauth/hooks/me.d.ts +0 -1
  158. package/dist/oauth/hooks/me.js +0 -2
  159. package/dist/oauth/hooks/refresh.d.ts +0 -1
  160. package/dist/oauth/hooks/refresh.js +2 -3
  161. package/dist/oauth/index.d.ts +0 -1
  162. package/dist/oauth/index.js +27 -7
  163. package/dist/oauth/strategy/index.d.ts +0 -3
  164. package/dist/oauth/strategy/index.js +55 -34
  165. package/dist/oauth/types.d.ts +23 -7
  166. package/dist/oauth/types.js +0 -2
  167. package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
  168. package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
  169. package/dist/oauth/utilities/clearCookie.d.ts +0 -1
  170. package/dist/oauth/utilities/clearCookie.js +5 -3
  171. package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
  172. package/dist/oauth/utilities/createCookieOptions.js +9 -4
  173. package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
  174. package/dist/oauth/utilities/createDebugLogger.js +0 -2
  175. package/dist/oauth/utilities/establishSession.d.ts +22 -0
  176. package/dist/oauth/utilities/establishSession.js +80 -0
  177. package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
  178. package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
  179. package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
  180. package/dist/oauth/utilities/extractOrigin.js +0 -2
  181. package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
  182. package/dist/oauth/utilities/figmaHostnames.js +24 -0
  183. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
  184. package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
  185. package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
  186. package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
  187. package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
  188. package/dist/oauth/utilities/getCookieExpiration.js +0 -2
  189. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
  190. package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
  191. package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
  192. package/dist/oauth/utilities/getTokenExp.js +0 -2
  193. package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
  194. package/dist/oauth/utilities/getUsernameField.js +0 -2
  195. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
  196. package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
  197. package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
  198. package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
  199. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
  200. package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
  201. package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
  202. package/dist/oauth/utilities/mergeHeaders.js +0 -2
  203. package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
  204. package/dist/oauth/utilities/refreshTokens.js +21 -13
  205. package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
  206. package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
  207. package/dist/oauth/utils/getSearchParam.d.ts +17 -0
  208. package/dist/oauth/utils/getSearchParam.js +22 -0
  209. package/dist/plugin/adapter.d.ts +0 -1
  210. package/dist/plugin/adapter.js +0 -2
  211. package/dist/plugin/auth-preflight.d.ts +7 -0
  212. package/dist/plugin/auth-preflight.js +18 -0
  213. package/dist/plugin/bootstrap-preflight.d.ts +22 -0
  214. package/dist/plugin/bootstrap-preflight.js +43 -0
  215. package/dist/plugin/build-config.d.ts +27 -15
  216. package/dist/plugin/build-config.js +380 -16
  217. package/dist/plugin/dev-cookie-names.d.ts +13 -0
  218. package/dist/plugin/dev-cookie-names.js +17 -0
  219. package/dist/scss.d.js +2 -0
  220. package/dist/storage-content-api/api-types.d.ts +183 -0
  221. package/dist/storage-content-api/api-types.js +4 -0
  222. package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
  223. package/dist/storage-content-api/client-uploads/generate.js +69 -0
  224. package/dist/storage-content-api/client.d.ts +5 -0
  225. package/dist/storage-content-api/client.js +37 -0
  226. package/dist/storage-content-api/generateURL.d.ts +6 -0
  227. package/dist/storage-content-api/generateURL.js +6 -0
  228. package/dist/storage-content-api/handleDelete.d.ts +7 -0
  229. package/dist/storage-content-api/handleDelete.js +15 -0
  230. package/dist/storage-content-api/handleUpload.d.ts +10 -0
  231. package/dist/storage-content-api/handleUpload.js +162 -0
  232. package/dist/storage-content-api/index.d.ts +4 -0
  233. package/dist/storage-content-api/index.js +37 -0
  234. package/dist/storage-content-api/staticHandler.d.ts +9 -0
  235. package/dist/storage-content-api/staticHandler.js +61 -0
  236. package/dist/storage-content-api/types.d.ts +9 -0
  237. package/dist/storage-content-api/types.js +1 -0
  238. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
  239. package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
  240. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  241. package/dist/storage-content-api/utilities/index.js +2 -0
  242. package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
  243. package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
  244. package/dist/templates/.env.example +5 -0
  245. package/dist/templates/README.md +19 -0
  246. package/dist/types/config.d.ts +2 -2
  247. package/dist/types/config.js +0 -4
  248. package/dist/types.d.ts +10 -2
  249. package/dist/types.js +0 -2
  250. package/dist/utils/adapters/nextjs.d.ts +8 -0
  251. package/dist/utils/adapters/nextjs.js +61 -0
  252. package/dist/utils/adapters/nitro.d.ts +8 -0
  253. package/dist/utils/adapters/nitro.js +172 -0
  254. package/dist/utils/adapters/vite.d.ts +9 -0
  255. package/dist/utils/adapters/vite.js +31 -0
  256. package/dist/utils/asset-collection.d.ts +27 -7
  257. package/dist/utils/asset-collection.js +59 -32
  258. package/dist/utils/build-detection.d.ts +5 -12
  259. package/dist/utils/build-detection.js +74 -13
  260. package/dist/utils/build-lambda-zip.d.ts +25 -0
  261. package/dist/utils/build-lambda-zip.js +90 -0
  262. package/dist/utils/cache-bootstrap.d.ts +7 -0
  263. package/dist/utils/cache-bootstrap.js +16 -0
  264. package/dist/utils/config.d.ts +0 -1
  265. package/dist/utils/config.js +1 -3
  266. package/dist/utils/deploy-adapter.d.ts +45 -0
  267. package/dist/utils/deploy-adapter.js +56 -0
  268. package/dist/utils/download-template.d.ts +9 -2
  269. package/dist/utils/download-template.js +24 -20
  270. package/dist/utils/env-management.d.ts +24 -8
  271. package/dist/utils/env-management.js +119 -66
  272. package/dist/utils/format-env-suffix.d.ts +11 -0
  273. package/dist/utils/format-env-suffix.js +11 -0
  274. package/dist/utils/format.d.ts +0 -1
  275. package/dist/utils/format.js +0 -2
  276. package/dist/utils/formatter.d.ts +0 -1
  277. package/dist/utils/formatter.js +23 -13
  278. package/dist/utils/fs-utils.d.ts +12 -0
  279. package/dist/utils/fs-utils.js +55 -0
  280. package/dist/utils/git.d.ts +0 -1
  281. package/dist/utils/git.js +0 -2
  282. package/dist/utils/handle-upgrade.d.ts +8 -0
  283. package/dist/utils/handle-upgrade.js +39 -0
  284. package/dist/utils/is-debug.d.ts +0 -1
  285. package/dist/utils/is-debug.js +0 -2
  286. package/dist/utils/lambda-config.d.ts +3 -2
  287. package/dist/utils/lambda-config.js +75 -80
  288. package/dist/utils/load-payload-config.d.ts +9 -0
  289. package/dist/utils/load-payload-config.js +27 -0
  290. package/dist/utils/log.d.ts +0 -1
  291. package/dist/utils/log.js +0 -2
  292. package/dist/utils/messages.d.ts +1 -3
  293. package/dist/utils/messages.js +47 -13
  294. package/dist/utils/package-manager.d.ts +24 -1
  295. package/dist/utils/package-manager.js +53 -2
  296. package/dist/utils/parse-template-spec.d.ts +11 -0
  297. package/dist/utils/parse-template-spec.js +60 -0
  298. package/dist/utils/payload-config-ast.d.ts +27 -7
  299. package/dist/utils/payload-config-ast.js +106 -60
  300. package/dist/utils/payload-config-finder.d.ts +2 -3
  301. package/dist/utils/payload-config-finder.js +48 -11
  302. package/dist/utils/payload-config-modifier.d.ts +1 -2
  303. package/dist/utils/payload-config-modifier.js +114 -68
  304. package/dist/utils/payload-package-check.d.ts +28 -3
  305. package/dist/utils/payload-package-check.js +90 -31
  306. package/dist/utils/project.d.ts +8 -4
  307. package/dist/utils/project.js +63 -37
  308. package/dist/utils/resolve-environment.d.ts +13 -0
  309. package/dist/utils/resolve-environment.js +29 -0
  310. package/dist/utils/s3-upload.d.ts +7 -3
  311. package/dist/utils/s3-upload.js +44 -9
  312. package/dist/utils/token-display.d.ts +5 -2
  313. package/dist/utils/token-display.js +49 -24
  314. package/dist/utils/typescript-validator.d.ts +0 -1
  315. package/dist/utils/typescript-validator.js +4 -8
  316. package/dist/utils/version-check.d.ts +2 -0
  317. package/dist/utils/version-check.js +43 -0
  318. package/package.json +47 -16
  319. package/dist/api/control-plane.d.ts.map +0 -1
  320. package/dist/api/control-plane.js.map +0 -1
  321. package/dist/api/figma-api.d.ts.map +0 -1
  322. package/dist/api/figma-api.js.map +0 -1
  323. package/dist/auth/browser.d.ts.map +0 -1
  324. package/dist/auth/browser.js.map +0 -1
  325. package/dist/auth/callback-server.d.ts.map +0 -1
  326. package/dist/auth/callback-server.js.map +0 -1
  327. package/dist/auth/crypto-utils.d.ts.map +0 -1
  328. package/dist/auth/crypto-utils.js.map +0 -1
  329. package/dist/auth/jwt-validator.d.ts.map +0 -1
  330. package/dist/auth/jwt-validator.js.map +0 -1
  331. package/dist/auth/oauth-flow.d.ts.map +0 -1
  332. package/dist/auth/oauth-flow.js.map +0 -1
  333. package/dist/auth/pkce.d.ts.map +0 -1
  334. package/dist/auth/pkce.js.map +0 -1
  335. package/dist/auth/project-token.d.ts.map +0 -1
  336. package/dist/auth/project-token.js.map +0 -1
  337. package/dist/auth/refresh.d.ts.map +0 -1
  338. package/dist/auth/refresh.js.map +0 -1
  339. package/dist/auth/token-store.d.ts.map +0 -1
  340. package/dist/auth/token-store.js.map +0 -1
  341. package/dist/auth/types.d.ts.map +0 -1
  342. package/dist/auth/types.js.map +0 -1
  343. package/dist/cli.d.ts.map +0 -1
  344. package/dist/cli.js.map +0 -1
  345. package/dist/commands/deploy.d.ts.map +0 -1
  346. package/dist/commands/deploy.js.map +0 -1
  347. package/dist/commands/init.d.ts.map +0 -1
  348. package/dist/commands/init.js.map +0 -1
  349. package/dist/commands/list-tokens.d.ts.map +0 -1
  350. package/dist/commands/list-tokens.js.map +0 -1
  351. package/dist/commands/login.d.ts.map +0 -1
  352. package/dist/commands/login.js.map +0 -1
  353. package/dist/commands/logout.d.ts.map +0 -1
  354. package/dist/commands/logout.js.map +0 -1
  355. package/dist/config/oauth.d.ts.map +0 -1
  356. package/dist/config/oauth.js.map +0 -1
  357. package/dist/constants.d.ts.map +0 -1
  358. package/dist/constants.js.map +0 -1
  359. package/dist/exports/client.d.ts.map +0 -1
  360. package/dist/exports/client.js.map +0 -1
  361. package/dist/index.d.ts.map +0 -1
  362. package/dist/index.js.map +0 -1
  363. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  364. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  365. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  366. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  367. package/dist/oauth/defaults.d.ts.map +0 -1
  368. package/dist/oauth/defaults.js.map +0 -1
  369. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  370. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  371. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  372. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  373. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  374. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  375. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  376. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  377. package/dist/oauth/exports/client.d.ts.map +0 -1
  378. package/dist/oauth/exports/client.js.map +0 -1
  379. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  380. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  381. package/dist/oauth/hooks/me.d.ts.map +0 -1
  382. package/dist/oauth/hooks/me.js.map +0 -1
  383. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  384. package/dist/oauth/hooks/refresh.js.map +0 -1
  385. package/dist/oauth/index.d.ts.map +0 -1
  386. package/dist/oauth/index.js.map +0 -1
  387. package/dist/oauth/strategy/index.d.ts.map +0 -1
  388. package/dist/oauth/strategy/index.js.map +0 -1
  389. package/dist/oauth/types.d.ts.map +0 -1
  390. package/dist/oauth/types.js.map +0 -1
  391. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  392. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  393. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  394. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  395. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  396. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  397. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  398. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  399. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  400. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  401. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  402. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  403. package/dist/oauth/utilities/getAdminPath.js +0 -9
  404. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  405. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  406. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  407. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  408. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  409. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  410. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  411. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  412. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  413. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  414. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  415. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  416. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  417. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  418. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  419. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  420. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  421. package/dist/plugin/adapter.d.ts.map +0 -1
  422. package/dist/plugin/adapter.js.map +0 -1
  423. package/dist/plugin/build-config.d.ts.map +0 -1
  424. package/dist/plugin/build-config.js.map +0 -1
  425. package/dist/types/config.d.ts.map +0 -1
  426. package/dist/types/config.js.map +0 -1
  427. package/dist/types.d.ts.map +0 -1
  428. package/dist/types.js.map +0 -1
  429. package/dist/utils/asset-collection.d.ts.map +0 -1
  430. package/dist/utils/asset-collection.js.map +0 -1
  431. package/dist/utils/build-detection.d.ts.map +0 -1
  432. package/dist/utils/build-detection.js.map +0 -1
  433. package/dist/utils/config.d.ts.map +0 -1
  434. package/dist/utils/config.js.map +0 -1
  435. package/dist/utils/download-template.d.ts.map +0 -1
  436. package/dist/utils/download-template.js.map +0 -1
  437. package/dist/utils/env-management.d.ts.map +0 -1
  438. package/dist/utils/env-management.js.map +0 -1
  439. package/dist/utils/format.d.ts.map +0 -1
  440. package/dist/utils/format.js.map +0 -1
  441. package/dist/utils/formatter.d.ts.map +0 -1
  442. package/dist/utils/formatter.js.map +0 -1
  443. package/dist/utils/git.d.ts.map +0 -1
  444. package/dist/utils/git.js.map +0 -1
  445. package/dist/utils/is-debug.d.ts.map +0 -1
  446. package/dist/utils/is-debug.js.map +0 -1
  447. package/dist/utils/lambda-config.d.ts.map +0 -1
  448. package/dist/utils/lambda-config.js.map +0 -1
  449. package/dist/utils/log.d.ts.map +0 -1
  450. package/dist/utils/log.js.map +0 -1
  451. package/dist/utils/messages.d.ts.map +0 -1
  452. package/dist/utils/messages.js.map +0 -1
  453. package/dist/utils/package-manager.d.ts.map +0 -1
  454. package/dist/utils/package-manager.js.map +0 -1
  455. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  456. package/dist/utils/payload-config-ast.js.map +0 -1
  457. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  458. package/dist/utils/payload-config-finder.js.map +0 -1
  459. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  460. package/dist/utils/payload-config-modifier.js.map +0 -1
  461. package/dist/utils/payload-package-check.d.ts.map +0 -1
  462. package/dist/utils/payload-package-check.js.map +0 -1
  463. package/dist/utils/project.d.ts.map +0 -1
  464. package/dist/utils/project.js.map +0 -1
  465. package/dist/utils/s3-upload.d.ts.map +0 -1
  466. package/dist/utils/s3-upload.js.map +0 -1
  467. package/dist/utils/token-display.d.ts.map +0 -1
  468. package/dist/utils/token-display.js.map +0 -1
  469. package/dist/utils/typescript-validator.d.ts.map +0 -1
  470. package/dist/utils/typescript-validator.js.map +0 -1
@@ -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
+ }
@@ -0,0 +1,81 @@
1
+ export interface CmsOAuthCodeMessage {
2
+ code: string;
3
+ state: string;
4
+ }
5
+ /**
6
+ * Validate the shape of a message received from the parent window. Accepts
7
+ * `{ type: 'cms-oauth-code', code: string, state: string }`. Returns null
8
+ * for anything else. The handler additionally verifies `state` matches the
9
+ * value the iframe sent on its outbound `mint-cms-oauth-code` request.
10
+ */
11
+ export declare const parseCmsOAuthCodeMessage: (data: unknown) => CmsOAuthCodeMessage | null;
12
+ export interface ParentOriginSignals {
13
+ /**
14
+ * `ancestorOrigins[0]`: immediate embedder origin. `undefined` where the
15
+ * browser lacks `Location.ancestorOrigins`.
16
+ */
17
+ ancestorOrigin: null | string | undefined;
18
+ /** `window.location.origin` — this iframe's own origin. */
19
+ ownOrigin: null | string | undefined;
20
+ /** `document.referrer`. */
21
+ referrer: null | string | undefined;
22
+ }
23
+ /**
24
+ * Resolve the exact origin for `window.parent.postMessage`, or `null` if we
25
+ * can't establish a trusted embedder (caller must then NOT post). We never
26
+ * target `'*'`: the payload embeds PKCE material in `state`.
27
+ *
28
+ * 1. `ancestorOrigin` present (browser-set, unspoofable): trust iff Figma,
29
+ * else `null` — no fall-through to weaker signals.
30
+ * 2. No `ancestorOrigins`: fall back to `referrer`, but only if
31
+ * it's a Figma origin and not our own. (Payload's `/admin` -> `/admin/login`
32
+ * 307 leaves `referrer` as our own origin, never the embedder.)
33
+ * 3. Otherwise `null`.
34
+ */
35
+ export declare const resolveParentTargetOrigin: ({ ancestorOrigin, ownOrigin, referrer, }: ParentOriginSignals) => null | string;
36
+ export interface IframeAutoLoginDeps {
37
+ doFetch: typeof fetch;
38
+ /**
39
+ * URL of the plugin's `/meta` endpoint. The iframe fetches this on setup
40
+ * to get the OAuth params (`client_id`, `redirect_uri`, `scope`,
41
+ * `code_challenge`, `state`, etc.) it forwards to the parent so the
42
+ * parent can mint a code via Sinatra.
43
+ */
44
+ metaUrl: string;
45
+ navigate: (url: string) => void;
46
+ /**
47
+ * Called on known synchronous failure paths so the host UI can render a
48
+ * manual fallback (e.g. surface the regular login button) instead of
49
+ * leaving the user on a blank screen. Not called on cleanup-driven
50
+ * aborts. Silent failures (parent never responds) are not detected here;
51
+ * the host is expected to apply its own timeout.
52
+ */
53
+ onFailed?: () => void;
54
+ /**
55
+ * Exact origin for `postMessage`, from `resolveParentTargetOrigin`. `null`
56
+ * means no trusted embedder: don't post, trigger `onFailed`. Never `'*'`.
57
+ */
58
+ parentTargetOrigin: null | string;
59
+ postMessageToParent: (message: unknown, targetOrigin: string) => void;
60
+ win: Pick<Window, 'addEventListener' | 'removeEventListener'>;
61
+ }
62
+ /**
63
+ * Wire up the iframe auto-login flow:
64
+ * 1. Fetch the plugin's `/meta` endpoint to get the OAuth params for this
65
+ * flow — same params the regular `/admin/login` button would have used.
66
+ * 2. postMessage to the parent window:
67
+ * { type: 'mint-cms-oauth-code', client_id, redirect_uri, scope,
68
+ * code_challenge, code_challenge_method, state }
69
+ * The parent uses these to mint a code via Sinatra, then echoes `state`
70
+ * back so we can correlate response to request.
71
+ * 3. Listen for the parent's response.
72
+ * 4. On a valid Figma-origin response whose `state` matches what we sent,
73
+ * navigate to `${redirect_uri}?code=${code}&state=${state}` — the same
74
+ * URL shape the IdP uses when it 302s back into the manual flow.
75
+ * 5. `/sso/login` GET handler validates state.sig + PKCE verifier, exchanges
76
+ * the code, sets session cookies, and 302s to `/admin`.
77
+ *
78
+ * Returns a cleanup function that removes the listener and aborts the meta
79
+ * fetch — designed to be returned directly from a React useEffect.
80
+ */
81
+ export declare const setupIframeAutoLogin: (deps: IframeAutoLoginDeps) => (() => void);
@@ -0,0 +1,168 @@
1
+ import { isFigmaOrigin } from '../../utilities/figmaHostnames.js';
2
+ /**
3
+ * Validate the shape of a message received from the parent window. Accepts
4
+ * `{ type: 'cms-oauth-code', code: string, state: string }`. Returns null
5
+ * for anything else. The handler additionally verifies `state` matches the
6
+ * value the iframe sent on its outbound `mint-cms-oauth-code` request.
7
+ */ export const parseCmsOAuthCodeMessage = (data)=>{
8
+ if (!data || typeof data !== 'object') {
9
+ return null;
10
+ }
11
+ const obj = data;
12
+ if (obj.type !== 'cms-oauth-code') {
13
+ return null;
14
+ }
15
+ if (typeof obj.code !== 'string' || obj.code.length === 0) {
16
+ return null;
17
+ }
18
+ if (typeof obj.state !== 'string' || obj.state.length === 0) {
19
+ return null;
20
+ }
21
+ return {
22
+ code: obj.code,
23
+ state: obj.state
24
+ };
25
+ };
26
+ /**
27
+ * Resolve the exact origin for `window.parent.postMessage`, or `null` if we
28
+ * can't establish a trusted embedder (caller must then NOT post). We never
29
+ * target `'*'`: the payload embeds PKCE material in `state`.
30
+ *
31
+ * 1. `ancestorOrigin` present (browser-set, unspoofable): trust iff Figma,
32
+ * else `null` — no fall-through to weaker signals.
33
+ * 2. No `ancestorOrigins`: fall back to `referrer`, but only if
34
+ * it's a Figma origin and not our own. (Payload's `/admin` -> `/admin/login`
35
+ * 307 leaves `referrer` as our own origin, never the embedder.)
36
+ * 3. Otherwise `null`.
37
+ */ export const resolveParentTargetOrigin = ({ ancestorOrigin, ownOrigin, referrer })=>{
38
+ if (ancestorOrigin != null) {
39
+ return isFigmaOrigin(ancestorOrigin) ? ancestorOrigin : null;
40
+ }
41
+ if (referrer) {
42
+ try {
43
+ const candidate = new URL(referrer).origin;
44
+ if (candidate !== ownOrigin && isFigmaOrigin(candidate)) {
45
+ return candidate;
46
+ }
47
+ } catch {
48
+ // unparseable referrer — fall through
49
+ }
50
+ }
51
+ return null;
52
+ };
53
+ /**
54
+ * Wire up the iframe auto-login flow:
55
+ * 1. Fetch the plugin's `/meta` endpoint to get the OAuth params for this
56
+ * flow — same params the regular `/admin/login` button would have used.
57
+ * 2. postMessage to the parent window:
58
+ * { type: 'mint-cms-oauth-code', client_id, redirect_uri, scope,
59
+ * code_challenge, code_challenge_method, state }
60
+ * The parent uses these to mint a code via Sinatra, then echoes `state`
61
+ * back so we can correlate response to request.
62
+ * 3. Listen for the parent's response.
63
+ * 4. On a valid Figma-origin response whose `state` matches what we sent,
64
+ * navigate to `${redirect_uri}?code=${code}&state=${state}` — the same
65
+ * URL shape the IdP uses when it 302s back into the manual flow.
66
+ * 5. `/sso/login` GET handler validates state.sig + PKCE verifier, exchanges
67
+ * the code, sets session cookies, and 302s to `/admin`.
68
+ *
69
+ * Returns a cleanup function that removes the listener and aborts the meta
70
+ * fetch — designed to be returned directly from a React useEffect.
71
+ */ export const setupIframeAutoLogin = (deps)=>{
72
+ const abortController = new AbortController();
73
+ // `flow` is captured atomically from the /meta response. Either both
74
+ // `redirectUri` and `state` are set (after the async fetch completes
75
+ // successfully), or it's null. Bundling them prevents handleMessage
76
+ // from using a half-populated state — e.g. an empty `redirectUri`
77
+ // producing a relative-URL navigation.
78
+ let flow = null;
79
+ const handleMessage = (event)=>{
80
+ // Parse first so we only log rejections for messages that were *intended*
81
+ // to be `cms-oauth-code`. Unrelated postMessages (browser extensions,
82
+ // devtools, etc.) return silently with no log noise.
83
+ const parsed = parseCmsOAuthCodeMessage(event.data);
84
+ if (!parsed) {
85
+ return;
86
+ }
87
+ if (!isFigmaOrigin(event.origin)) {
88
+ // eslint-disable-next-line no-console -- surface why auto-login didn't fire
89
+ console.error(`[payload iframe auto-login] rejected cms-oauth-code: origin "${event.origin}" is not in the Figma allowlist`);
90
+ return;
91
+ }
92
+ if (flow === null) {
93
+ // eslint-disable-next-line no-console -- surface why auto-login didn't fire
94
+ console.error('[payload iframe auto-login] rejected cms-oauth-code: message arrived before /meta resolved, so no expected state to compare against');
95
+ return;
96
+ }
97
+ if (parsed.state !== flow.state) {
98
+ // eslint-disable-next-line no-console -- surface why auto-login didn't fire
99
+ console.error('[payload iframe auto-login] rejected cms-oauth-code: state mismatch — the parent did not echo back the state the iframe sent');
100
+ return;
101
+ }
102
+ // /sso/login expects the same URL shape the IdP would have produced:
103
+ // ${redirect_uri}?code=…&state=…
104
+ deps.navigate(`${flow.redirectUri}?code=${encodeURIComponent(parsed.code)}&state=${encodeURIComponent(parsed.state)}`);
105
+ };
106
+ deps.win.addEventListener('message', handleMessage);
107
+ void (async ()=>{
108
+ try {
109
+ const metaRes = await deps.doFetch(deps.metaUrl, {
110
+ signal: abortController.signal
111
+ });
112
+ if (!metaRes.ok) {
113
+ // eslint-disable-next-line no-console -- surface auto-login failures to dev tools
114
+ console.warn(`[payload iframe auto-login] meta endpoint responded ${metaRes.status}`);
115
+ deps.onFailed?.();
116
+ return;
117
+ }
118
+ const meta = await metaRes.json();
119
+ const clientId = meta.params?.client_id;
120
+ const codeChallenge = meta.params?.code_challenge;
121
+ const codeChallengeMethod = meta.params?.code_challenge_method;
122
+ const redirect = meta.params?.redirect_uri;
123
+ const scope = meta.params?.scope;
124
+ const state = meta.params?.state;
125
+ if (typeof clientId !== 'string' || typeof codeChallenge !== 'string' || typeof codeChallengeMethod !== 'string' || typeof redirect !== 'string' || typeof scope !== 'string' || typeof state !== 'string') {
126
+ // eslint-disable-next-line no-console -- surface auto-login failures to dev tools
127
+ console.warn('[payload iframe auto-login] meta response missing required params');
128
+ deps.onFailed?.();
129
+ return;
130
+ }
131
+ if (abortController.signal.aborted) {
132
+ return;
133
+ }
134
+ // No trusted embedder origin: refuse to post (don't broadcast PKCE-bearing
135
+ // `state` to '*'). See `resolveParentTargetOrigin`.
136
+ if (deps.parentTargetOrigin === null) {
137
+ // eslint-disable-next-line no-console -- surface auto-login failures to dev tools
138
+ console.warn('[payload iframe auto-login] could not determine a trusted parent origin — falling back to manual login');
139
+ deps.onFailed?.();
140
+ return;
141
+ }
142
+ flow = {
143
+ redirectUri: redirect,
144
+ state
145
+ };
146
+ deps.postMessageToParent({
147
+ type: 'mint-cms-oauth-code',
148
+ client_id: clientId,
149
+ code_challenge: codeChallenge,
150
+ code_challenge_method: codeChallengeMethod,
151
+ redirect_uri: redirect,
152
+ scope,
153
+ state
154
+ }, deps.parentTargetOrigin);
155
+ } catch (err) {
156
+ if (abortController.signal.aborted) {
157
+ return;
158
+ }
159
+ // eslint-disable-next-line no-console -- surface auto-login failures to dev tools
160
+ console.warn('[payload iframe auto-login] failed to fetch meta', err);
161
+ deps.onFailed?.();
162
+ }
163
+ })();
164
+ return ()=>{
165
+ deps.win.removeEventListener('message', handleMessage);
166
+ abortController.abort();
167
+ };
168
+ };
@@ -6,4 +6,3 @@ type DefaultLoginButtonProps = {
6
6
  };
7
7
  export declare const DefaultLoginButton: React.FC<DefaultLoginButtonProps>;
8
8
  export {};
9
- //# sourceMappingURL=index.d.ts.map
@@ -1,52 +1,190 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Button, useConfig } from '@payloadcms/ui';
4
- import { useSearchParams } from 'next/navigation.js';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useConfig, useSearchParams } from '@payloadcms/ui';
5
4
  import React, { useEffect, useState } from 'react';
5
+ import { getSearchParam } from '../../utils/getSearchParam.js';
6
+ import { resolveParentTargetOrigin, setupIframeAutoLogin } from './iframeAutoLogin.js';
6
7
  import './index.scss';
7
8
  const baseClass = 'oauth-login';
9
+ // Max time we wait for the parent (figma.com) to respond with a code after
10
+ // posting `mint-cms-oauth-code`. If we hit this without a reply, we assume
11
+ // the parent isn't going to respond and fall back to the manual login button.
12
+ const AUTO_LOGIN_PARENT_REPLY_TIMEOUT_MS = 10000;
13
+ // Figma logo SVG colored version
14
+ // const FigmaIcon: React.FC = () => (
15
+ // <svg fill="none" height="27" viewBox="0 0 400 600" width="18">
16
+ // <path
17
+ // d="M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z"
18
+ // fill="#24CB71"
19
+ // />
20
+ // <path
21
+ // d="M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z"
22
+ // fill="#FF7237"
23
+ // />
24
+ // <path
25
+ // 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"
26
+ // fill="#00B6FF"
27
+ // />
28
+ // <path
29
+ // d="M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z"
30
+ // fill="#FF3737"
31
+ // />
32
+ // <path
33
+ // d="M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z"
34
+ // fill="#874FFF"
35
+ // />
36
+ // </svg>
37
+ // )
38
+ // Figma logo SVG monochrome version
39
+ const FigmaIcon = ()=>/*#__PURE__*/ _jsx("svg", {
40
+ fill: "none",
41
+ height: "20px",
42
+ viewBox: "0 0 15 15",
43
+ width: "20px",
44
+ xmlns: "http://www.w3.org/2000/svg",
45
+ children: /*#__PURE__*/ _jsx("path", {
46
+ clipRule: "evenodd",
47
+ 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",
48
+ fill: "#FFFFFF",
49
+ fillRule: "evenodd"
50
+ })
51
+ });
8
52
  export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
9
53
  const { config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
10
54
  const [authorizeURL, setAuthorizeURL] = useState('');
55
+ const [isInIframe, setIsInIframe] = useState(null);
56
+ const [autoLoginFailed, setAutoLoginFailed] = useState(false);
11
57
  const searchParams = useSearchParams();
12
- const payloadRedirect = searchParams.get('redirect');
58
+ const payloadRedirect = getSearchParam(searchParams, 'redirect');
59
+ useEffect(()=>{
60
+ try {
61
+ setIsInIframe(window.self !== window.top);
62
+ } catch {
63
+ // Cross-origin access throws — that itself means we're in an iframe.
64
+ setIsInIframe(true);
65
+ }
66
+ }, []);
67
+ // Iframe auto-login: ask the parent (figma.com) for a fresh OAuth code, then
68
+ // navigate to `/sso/login?code=…&state=…` — the same handler the manual
69
+ // login button flow reaches. /sso/login exchanges the code, sets session
70
+ // cookies, and redirects to /admin. Runs on initial /admin/login load and
71
+ // after logout. See `./iframeAutoLogin.ts` for the flow + tests.
72
+ //
73
+ // If the flow fails — synchronously via `onFailed`, or silently via the
74
+ // timeout — we flip `autoLoginFailed` so the manual login button renders
75
+ // as a fallback instead of leaving the user on a blank screen.
76
+ useEffect(()=>{
77
+ if (isInIframe !== true || disabled) {
78
+ return;
79
+ }
80
+ const fallbackTimer = window.setTimeout(()=>{
81
+ // eslint-disable-next-line no-console -- surface silent parent failures
82
+ console.warn(`[payload iframe auto-login] parent did not reply with cms-oauth-code within ${AUTO_LOGIN_PARENT_REPLY_TIMEOUT_MS}ms — falling back to manual login`);
83
+ setAutoLoginFailed(true);
84
+ }, AUTO_LOGIN_PARENT_REPLY_TIMEOUT_MS);
85
+ // ancestorOrigins[0] is the immediate embedder's origin (browser-set,
86
+ // unspoofable) where supported; undefined on browsers that don't implement
87
+ // the non-standard Location.ancestorOrigins (older Firefox, pre-148).
88
+ const ancestorOrigins = window.location.ancestorOrigins;
89
+ // encodeURIComponent is required on Coder devbox: there a proxy hop rewrites
90
+ // an unencoded `serverURL=https://<host>` to http before it reaches the
91
+ // server, which then flows into state.serverURL / the OAuth redirect_uri and
92
+ // breaks login with an https→http navigation. Encoding the `://` avoids it.
93
+ const cleanup = setupIframeAutoLogin({
94
+ doFetch: window.fetch.bind(window),
95
+ metaUrl: `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${encodeURIComponent(window.location.origin)}`,
96
+ navigate: (url)=>{
97
+ window.location.href = url;
98
+ },
99
+ onFailed: ()=>setAutoLoginFailed(true),
100
+ parentTargetOrigin: resolveParentTargetOrigin({
101
+ ancestorOrigin: ancestorOrigins?.[0],
102
+ ownOrigin: window.location.origin,
103
+ referrer: document.referrer
104
+ }),
105
+ postMessageToParent: (msg, target)=>window.parent.postMessage(msg, target),
106
+ win: window
107
+ });
108
+ return ()=>{
109
+ window.clearTimeout(fallbackTimer);
110
+ cleanup();
111
+ };
112
+ }, [
113
+ isInIframe,
114
+ disabled,
115
+ serverURL,
116
+ api,
117
+ userSlug,
118
+ endpointSlug
119
+ ]);
13
120
  useEffect(()=>{
14
121
  if (payloadRedirect && !disabled) {
15
- // set cookie to redirect to the original page
16
- document.cookie = `payloadRedirect=${payloadRedirect}; path=/`;
122
+ // set cookie to redirect to the original page. SameSite=None; Secure;
123
+ // Partitioned so it round-trips to /sso/login from the cross-site Make
124
+ // iframe (a Lax/unmarked cookie isn't sent, dropping the deep-link redirect).
125
+ document.cookie = `payloadRedirect=${payloadRedirect}; path=/; Secure; SameSite=None; Partitioned`;
17
126
  }
18
127
  }, [
19
128
  payloadRedirect,
20
129
  disabled
21
130
  ]);
131
+ // Fetch the manual login URL whenever we'd render the button — either we
132
+ // aren't in an iframe, or we're in an iframe but auto-login has given up.
133
+ const shouldRenderButton = !disabled && (isInIframe === false || autoLoginFailed);
22
134
  useEffect(()=>{
135
+ if (!shouldRenderButton) {
136
+ return;
137
+ }
23
138
  const getAuthorizeURL = async ()=>{
24
- const serverURLFromWindow = window.location.origin;
139
+ // Encoded for the same reason as the auto-login metaUrl above.
140
+ const serverURLFromWindow = encodeURIComponent(window.location.origin);
25
141
  const data = await fetch(`${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`).then((res)=>res.json());
26
- if (!disabled) {
27
- setAuthorizeURL(data.authorizeURL);
28
- }
142
+ setAuthorizeURL(data.authorizeURL);
29
143
  };
30
144
  void getAuthorizeURL();
31
145
  }, [
32
146
  api,
33
147
  serverURL,
34
148
  userSlug,
35
- disabled,
149
+ shouldRenderButton,
36
150
  endpointSlug
37
151
  ]);
38
- if (disabled) {
152
+ if (!shouldRenderButton) {
153
+ // In the iframe auto-login window, show a "Signing in…" hint so the
154
+ // user sees something is happening instead of a blank slot until the
155
+ // flow either navigates them away or times out into the manual button.
156
+ if (isInIframe === true && !disabled) {
157
+ return /*#__PURE__*/ _jsx("div", {
158
+ className: baseClass,
159
+ children: /*#__PURE__*/ _jsxs("div", {
160
+ className: `${baseClass}__signing-in`,
161
+ role: "status",
162
+ children: [
163
+ /*#__PURE__*/ _jsx("span", {
164
+ children: "Signing in"
165
+ }),
166
+ /*#__PURE__*/ _jsx("div", {
167
+ "aria-hidden": "true",
168
+ className: `${baseClass}__spinner`
169
+ })
170
+ ]
171
+ })
172
+ });
173
+ }
39
174
  return null;
40
175
  }
41
176
  return /*#__PURE__*/ _jsx("div", {
42
177
  className: baseClass,
43
- children: /*#__PURE__*/ _jsx(Button, {
178
+ children: /*#__PURE__*/ _jsxs("a", {
44
179
  className: `${baseClass}__btn`,
45
- el: "anchor",
46
- url: authorizeURL,
47
- children: "Log in"
180
+ href: authorizeURL,
181
+ children: [
182
+ /*#__PURE__*/ _jsx(FigmaIcon, {}),
183
+ /*#__PURE__*/ _jsx("span", {
184
+ className: `${baseClass}__text`,
185
+ children: "Log in with Figma"
186
+ })
187
+ ]
48
188
  })
49
189
  });
50
190
  };
51
-
52
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,82 @@
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
+ }
57
+
58
+ &__signing-in {
59
+ display: flex;
60
+ flex-direction: column;
61
+ align-items: center;
62
+ gap: 0.75rem;
63
+ font-size: 1rem;
64
+ font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
65
+ Oxygen, Ubuntu, Cantarell, sans-serif;
66
+ }
67
+
68
+ &__spinner {
69
+ width: 24px;
70
+ height: 24px;
71
+ border: 2px solid var(--theme-elevation-200, #e5e5e5);
72
+ border-top-color: currentColor;
73
+ border-radius: 50%;
74
+ animation: oauth-login-spin 0.8s linear infinite;
75
+ }
76
+ }
77
+
78
+ @keyframes oauth-login-spin {
79
+ to {
80
+ transform: rotate(360deg);
81
+ }
10
82
  }
@@ -4,4 +4,3 @@ export declare const LogoutButton: React.FC<{
4
4
  disabled?: boolean;
5
5
  endpointSlug: string;
6
6
  }>;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,24 +1,37 @@
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 })=>{
9
9
  const { config, config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
10
+ // In an iframe (Figma Make Preview) the LoginButton auto-logs the user
11
+ // back in as soon as they hit /admin/login, which would silently undo the
12
+ // logout. Redirect to the site root instead so the user actually stays
13
+ // logged out. Outside an iframe, keep the original behavior of redirecting
14
+ // back to /admin.
10
15
  const [redirect, setRedirect] = React.useState('');
11
16
  React.useEffect(()=>{
12
17
  const protocol = window.location.protocol;
13
18
  const domain = window.location.hostname;
14
19
  const port = window.location.port;
15
- let redirectToSet = `${protocol}//${domain}`;
20
+ let origin = `${protocol}//${domain}`;
16
21
  if (port) {
17
- redirectToSet += `:${port}`;
22
+ origin += `:${port}`;
18
23
  }
19
- redirectToSet += getAdminPath(config);
20
- // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
21
- setRedirect(redirectToSet);
24
+ let isInIframe;
25
+ try {
26
+ isInIframe = window.self !== window.top;
27
+ } catch {
28
+ // Cross-origin access throws — that itself means we're in an iframe.
29
+ isInIframe = true;
30
+ }
31
+ setRedirect(isInIframe ? origin : formatAdminURL({
32
+ adminRoute: config.routes.admin,
33
+ serverURL: origin
34
+ }));
22
35
  }, [
23
36
  config
24
37
  ]);
@@ -32,7 +45,7 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
32
45
  className: baseClass,
33
46
  children: /*#__PURE__*/ _jsx("a", {
34
47
  "aria-label": "Logout",
35
- href: `${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${redirect}`,
48
+ href: `${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${encodeURIComponent(redirect)}`,
36
49
  children: /*#__PURE__*/ _jsxs("svg", {
37
50
  className: "icon icon--logout",
38
51
  fill: "none",
@@ -63,5 +76,3 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
63
76
  })
64
77
  });
65
78
  };
66
-
67
- //# sourceMappingURL=index.js.map
@@ -1,10 +1,11 @@
1
1
  import type { CollectionConfig, EmailField, TextField } from 'payload';
2
2
  import type { VerifyFunction } from './types.js';
3
+ export declare const DEFAULT_USER_INFO_COOKIE_NAME = "figma-user-info";
3
4
  export declare const defaultScope: string[];
4
5
  export declare const defaultUsernameField: TextField;
5
- export declare const defaultVerify: ({ collection, strategyName, usernameField, }: {
6
+ export declare const defaultVerify: ({ collection, strategyName, userInfoCookieName, usernameField, }: {
6
7
  collection: CollectionConfig;
7
8
  strategyName: string;
9
+ userInfoCookieName?: string;
8
10
  usernameField: EmailField | TextField;
9
11
  }) => VerifyFunction;
10
- //# sourceMappingURL=defaults.d.ts.map