@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.70

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 (390) hide show
  1. package/dist/api/control-plane.d.ts +56 -6
  2. package/dist/api/control-plane.js +181 -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.d.ts +19 -7
  6. package/dist/auth/callback-server.js +72 -30
  7. package/dist/auth/credentials.d.ts +21 -0
  8. package/dist/auth/credentials.js +21 -0
  9. package/dist/auth/crypto-utils.d.ts +28 -0
  10. package/dist/auth/crypto-utils.js +132 -21
  11. package/dist/auth/jwt-validator.d.ts +2 -1
  12. package/dist/auth/jwt-validator.js +2 -2
  13. package/dist/auth/oauth-flow.d.ts +19 -3
  14. package/dist/auth/oauth-flow.js +77 -22
  15. package/dist/auth/project-token.d.ts +32 -16
  16. package/dist/auth/project-token.js +171 -65
  17. package/dist/auth/refresh.d.ts +2 -1
  18. package/dist/auth/refresh.js +25 -12
  19. package/dist/auth/token-store-migration.d.ts +58 -0
  20. package/dist/auth/token-store-migration.js +156 -0
  21. package/dist/auth/token-store.d.ts +63 -97
  22. package/dist/auth/token-store.js +405 -122
  23. package/dist/auth/types.d.ts +35 -4
  24. package/dist/cli.js +93 -6
  25. package/dist/commands/bootstrap.d.ts +18 -0
  26. package/dist/commands/bootstrap.js +90 -0
  27. package/dist/commands/build-lambda-zip.d.ts +5 -0
  28. package/dist/commands/build-lambda-zip.js +19 -0
  29. package/dist/commands/debug.d.ts +8 -0
  30. package/dist/commands/debug.js +180 -0
  31. package/dist/commands/deploy.d.ts +9 -0
  32. package/dist/commands/deploy.js +180 -151
  33. package/dist/commands/dump-tokens.d.ts +12 -0
  34. package/dist/commands/dump-tokens.js +69 -0
  35. package/dist/commands/env.d.ts +13 -0
  36. package/dist/commands/env.js +88 -0
  37. package/dist/commands/init.d.ts +9 -5
  38. package/dist/commands/init.js +241 -148
  39. package/dist/commands/list-tokens.d.ts +3 -3
  40. package/dist/commands/list-tokens.js +24 -9
  41. package/dist/commands/login.d.ts +8 -1
  42. package/dist/commands/login.js +34 -16
  43. package/dist/commands/logout.d.ts +5 -4
  44. package/dist/commands/logout.js +77 -15
  45. package/dist/commands/upgrade.d.ts +5 -0
  46. package/dist/commands/upgrade.js +331 -0
  47. package/dist/config/oauth.d.ts +17 -11
  48. package/dist/config/oauth.js +38 -37
  49. package/dist/constants.d.ts +63 -18
  50. package/dist/constants.js +158 -18
  51. package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
  52. package/dist/db-content-api/generated/content-api-types.js +7 -0
  53. package/dist/db-content-api/index.d.ts +37 -0
  54. package/dist/db-content-api/index.js +923 -0
  55. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  56. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  57. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  58. package/dist/db-content-api/temp-utilities/sorting.js +39 -0
  59. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  60. package/dist/db-content-api/temp-utilities/types.js +15 -0
  61. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
  62. package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
  63. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  64. package/dist/db-content-api/utilities/auth.js +84 -0
  65. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  66. package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
  67. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  68. package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
  69. package/dist/db-content-api/utilities/data/index.d.ts +49 -0
  70. package/dist/db-content-api/utilities/data/index.js +301 -0
  71. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  72. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  73. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  74. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  75. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  76. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  77. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
  78. package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
  79. package/dist/db-content-api/utilities/joins.d.ts +53 -0
  80. package/dist/db-content-api/utilities/joins.js +139 -0
  81. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  82. package/dist/db-content-api/utilities/locale/index.js +21 -0
  83. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  84. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
  85. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
  86. package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
  87. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
  88. package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
  89. package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
  90. package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
  91. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
  92. package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
  93. package/dist/db-content-api/utilities/where.d.ts +20 -0
  94. package/dist/db-content-api/utilities/where.js +108 -0
  95. package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
  96. package/dist/deploy/schedule-extract-plugin.js +34 -0
  97. package/dist/endpoints/health.d.ts +3 -0
  98. package/dist/endpoints/health.js +11 -0
  99. package/dist/endpoints/schema.d.ts +3 -0
  100. package/dist/endpoints/schema.js +29 -0
  101. package/dist/exports/client.d.ts +3 -0
  102. package/dist/exports/client.js +3 -0
  103. package/dist/index.d.ts +2 -1
  104. package/dist/index.js +3 -1
  105. package/dist/lib/download-skill.d.ts +13 -0
  106. package/dist/lib/download-skill.js +79 -0
  107. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  108. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  109. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  110. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  111. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  112. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  113. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  114. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  115. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  116. package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
  117. package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
  118. package/dist/oauth/components/LoginButton/index.js +144 -11
  119. package/dist/oauth/components/LoginButton/index.scss +75 -3
  120. package/dist/oauth/components/LogoutButton/index.js +19 -6
  121. package/dist/oauth/defaults.d.ts +3 -1
  122. package/dist/oauth/defaults.js +68 -10
  123. package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
  124. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  125. package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
  126. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
  127. package/dist/oauth/index.js +27 -5
  128. package/dist/oauth/strategy/index.d.ts +0 -2
  129. package/dist/oauth/strategy/index.js +40 -17
  130. package/dist/oauth/types.d.ts +23 -6
  131. package/dist/oauth/utilities/establishSession.d.ts +23 -0
  132. package/dist/oauth/utilities/establishSession.js +82 -0
  133. package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
  134. package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
  135. package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
  136. package/dist/oauth/utilities/figmaHostnames.js +26 -0
  137. package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
  138. package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
  139. package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
  140. package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
  141. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  142. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  143. package/dist/oauth/utilities/refreshTokens.js +6 -3
  144. package/dist/plugin/auth-preflight.d.ts +8 -0
  145. package/dist/plugin/auth-preflight.js +20 -0
  146. package/dist/plugin/bootstrap-preflight.d.ts +23 -0
  147. package/dist/plugin/bootstrap-preflight.js +45 -0
  148. package/dist/plugin/build-config.d.ts +27 -15
  149. package/dist/plugin/build-config.js +327 -17
  150. package/dist/plugin/dev-cookie-names.d.ts +14 -0
  151. package/dist/plugin/dev-cookie-names.js +19 -0
  152. package/dist/storage-content-api/api-types.d.ts +168 -0
  153. package/dist/storage-content-api/api-types.js +6 -0
  154. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  155. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
  156. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  157. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  158. package/dist/storage-content-api/client.d.ts +6 -0
  159. package/dist/storage-content-api/client.js +39 -0
  160. package/dist/storage-content-api/generateURL.d.ts +7 -0
  161. package/dist/storage-content-api/generateURL.js +8 -0
  162. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  163. package/dist/storage-content-api/handleDelete.js +17 -0
  164. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  165. package/dist/storage-content-api/handleUpload.js +144 -0
  166. package/dist/storage-content-api/index.d.ts +5 -0
  167. package/dist/storage-content-api/index.js +31 -0
  168. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  169. package/dist/storage-content-api/staticHandler.js +63 -0
  170. package/dist/storage-content-api/types.d.ts +10 -0
  171. package/dist/storage-content-api/types.js +3 -0
  172. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  173. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  174. package/dist/storage-content-api/utilities/index.d.ts +3 -0
  175. package/dist/storage-content-api/utilities/index.js +4 -0
  176. package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
  177. package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
  178. package/dist/templates/.env.example +5 -0
  179. package/dist/templates/README.md +19 -0
  180. package/dist/types/config.d.ts +2 -1
  181. package/dist/types/config.js +0 -2
  182. package/dist/types.d.ts +10 -1
  183. package/dist/utils/adapters/nextjs.d.ts +9 -0
  184. package/dist/utils/adapters/nextjs.js +64 -0
  185. package/dist/utils/adapters/nitro.d.ts +9 -0
  186. package/dist/utils/adapters/nitro.js +169 -0
  187. package/dist/utils/adapters/vite.d.ts +10 -0
  188. package/dist/utils/adapters/vite.js +33 -0
  189. package/dist/utils/asset-collection.d.ts +27 -6
  190. package/dist/utils/asset-collection.js +59 -30
  191. package/dist/utils/build-detection.d.ts +5 -11
  192. package/dist/utils/build-detection.js +74 -11
  193. package/dist/utils/build-lambda-zip.d.ts +16 -0
  194. package/dist/utils/build-lambda-zip.js +78 -0
  195. package/dist/utils/cache-bootstrap.d.ts +8 -0
  196. package/dist/utils/cache-bootstrap.js +18 -0
  197. package/dist/utils/config.js +1 -1
  198. package/dist/utils/deploy-adapter.d.ts +40 -0
  199. package/dist/utils/deploy-adapter.js +58 -0
  200. package/dist/utils/download-template.d.ts +9 -1
  201. package/dist/utils/download-template.js +24 -18
  202. package/dist/utils/env-management.d.ts +24 -7
  203. package/dist/utils/env-management.js +119 -64
  204. package/dist/utils/format-env-suffix.d.ts +12 -0
  205. package/dist/utils/format-env-suffix.js +13 -0
  206. package/dist/utils/formatter.js +23 -11
  207. package/dist/utils/fs-utils.d.ts +6 -0
  208. package/dist/utils/fs-utils.js +27 -0
  209. package/dist/utils/handle-upgrade.d.ts +9 -0
  210. package/dist/utils/handle-upgrade.js +41 -0
  211. package/dist/utils/lambda-config.d.ts +3 -1
  212. package/dist/utils/lambda-config.js +75 -78
  213. package/dist/utils/messages.d.ts +1 -2
  214. package/dist/utils/messages.js +39 -11
  215. package/dist/utils/package-manager.d.ts +24 -0
  216. package/dist/utils/package-manager.js +53 -0
  217. package/dist/utils/parse-template-spec.d.ts +12 -0
  218. package/dist/utils/parse-template-spec.js +62 -0
  219. package/dist/utils/payload-config-ast.d.ts +27 -6
  220. package/dist/utils/payload-config-ast.js +106 -58
  221. package/dist/utils/payload-config-finder.d.ts +2 -2
  222. package/dist/utils/payload-config-finder.js +48 -9
  223. package/dist/utils/payload-config-modifier.d.ts +1 -1
  224. package/dist/utils/payload-config-modifier.js +114 -66
  225. package/dist/utils/payload-package-check.d.ts +33 -2
  226. package/dist/utils/payload-package-check.js +129 -28
  227. package/dist/utils/project.d.ts +7 -2
  228. package/dist/utils/project.js +60 -32
  229. package/dist/utils/resolve-environment.d.ts +14 -0
  230. package/dist/utils/resolve-environment.js +31 -0
  231. package/dist/utils/s3-upload.d.ts +7 -2
  232. package/dist/utils/s3-upload.js +39 -6
  233. package/dist/utils/token-display.d.ts +5 -1
  234. package/dist/utils/token-display.js +49 -22
  235. package/dist/utils/typescript-validator.js +4 -6
  236. package/dist/utils/version-check.d.ts +3 -0
  237. package/dist/utils/version-check.js +38 -0
  238. package/package.json +44 -15
  239. package/dist/api/control-plane.d.ts.map +0 -1
  240. package/dist/api/control-plane.js.map +0 -1
  241. package/dist/api/figma-api.d.ts.map +0 -1
  242. package/dist/api/figma-api.js.map +0 -1
  243. package/dist/auth/browser.d.ts.map +0 -1
  244. package/dist/auth/browser.js.map +0 -1
  245. package/dist/auth/callback-server.d.ts.map +0 -1
  246. package/dist/auth/callback-server.js.map +0 -1
  247. package/dist/auth/crypto-utils.d.ts.map +0 -1
  248. package/dist/auth/crypto-utils.js.map +0 -1
  249. package/dist/auth/jwt-validator.d.ts.map +0 -1
  250. package/dist/auth/jwt-validator.js.map +0 -1
  251. package/dist/auth/oauth-flow.d.ts.map +0 -1
  252. package/dist/auth/oauth-flow.js.map +0 -1
  253. package/dist/auth/pkce.d.ts.map +0 -1
  254. package/dist/auth/pkce.js.map +0 -1
  255. package/dist/auth/project-token.d.ts.map +0 -1
  256. package/dist/auth/project-token.js.map +0 -1
  257. package/dist/auth/refresh.d.ts.map +0 -1
  258. package/dist/auth/refresh.js.map +0 -1
  259. package/dist/auth/token-store.d.ts.map +0 -1
  260. package/dist/auth/token-store.js.map +0 -1
  261. package/dist/auth/types.d.ts.map +0 -1
  262. package/dist/auth/types.js.map +0 -1
  263. package/dist/cli.d.ts.map +0 -1
  264. package/dist/cli.js.map +0 -1
  265. package/dist/commands/deploy.d.ts.map +0 -1
  266. package/dist/commands/deploy.js.map +0 -1
  267. package/dist/commands/init.d.ts.map +0 -1
  268. package/dist/commands/init.js.map +0 -1
  269. package/dist/commands/list-tokens.d.ts.map +0 -1
  270. package/dist/commands/list-tokens.js.map +0 -1
  271. package/dist/commands/login.d.ts.map +0 -1
  272. package/dist/commands/login.js.map +0 -1
  273. package/dist/commands/logout.d.ts.map +0 -1
  274. package/dist/commands/logout.js.map +0 -1
  275. package/dist/config/oauth.d.ts.map +0 -1
  276. package/dist/config/oauth.js.map +0 -1
  277. package/dist/constants.d.ts.map +0 -1
  278. package/dist/constants.js.map +0 -1
  279. package/dist/exports/client.d.ts.map +0 -1
  280. package/dist/exports/client.js.map +0 -1
  281. package/dist/index.d.ts.map +0 -1
  282. package/dist/index.js.map +0 -1
  283. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  284. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  285. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  286. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  287. package/dist/oauth/defaults.d.ts.map +0 -1
  288. package/dist/oauth/defaults.js.map +0 -1
  289. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  290. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  291. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  292. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  293. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  294. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  295. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  296. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  297. package/dist/oauth/exports/client.d.ts.map +0 -1
  298. package/dist/oauth/exports/client.js.map +0 -1
  299. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  300. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  301. package/dist/oauth/hooks/me.d.ts.map +0 -1
  302. package/dist/oauth/hooks/me.js.map +0 -1
  303. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  304. package/dist/oauth/hooks/refresh.js.map +0 -1
  305. package/dist/oauth/index.d.ts.map +0 -1
  306. package/dist/oauth/index.js.map +0 -1
  307. package/dist/oauth/strategy/index.d.ts.map +0 -1
  308. package/dist/oauth/strategy/index.js.map +0 -1
  309. package/dist/oauth/types.d.ts.map +0 -1
  310. package/dist/oauth/types.js.map +0 -1
  311. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  312. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  313. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  314. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  315. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  316. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  317. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  318. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  319. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  320. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  321. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  322. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  323. package/dist/oauth/utilities/getAdminPath.js +0 -9
  324. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  325. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  326. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  327. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  328. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  329. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  330. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  331. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  332. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  333. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  334. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  335. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  336. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  337. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  338. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  339. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  340. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  341. package/dist/plugin/adapter.d.ts.map +0 -1
  342. package/dist/plugin/adapter.js.map +0 -1
  343. package/dist/plugin/build-config.d.ts.map +0 -1
  344. package/dist/plugin/build-config.js.map +0 -1
  345. package/dist/types/config.d.ts.map +0 -1
  346. package/dist/types/config.js.map +0 -1
  347. package/dist/types.d.ts.map +0 -1
  348. package/dist/types.js.map +0 -1
  349. package/dist/utils/asset-collection.d.ts.map +0 -1
  350. package/dist/utils/asset-collection.js.map +0 -1
  351. package/dist/utils/build-detection.d.ts.map +0 -1
  352. package/dist/utils/build-detection.js.map +0 -1
  353. package/dist/utils/config.d.ts.map +0 -1
  354. package/dist/utils/config.js.map +0 -1
  355. package/dist/utils/download-template.d.ts.map +0 -1
  356. package/dist/utils/download-template.js.map +0 -1
  357. package/dist/utils/env-management.d.ts.map +0 -1
  358. package/dist/utils/env-management.js.map +0 -1
  359. package/dist/utils/format.d.ts.map +0 -1
  360. package/dist/utils/format.js.map +0 -1
  361. package/dist/utils/formatter.d.ts.map +0 -1
  362. package/dist/utils/formatter.js.map +0 -1
  363. package/dist/utils/git.d.ts.map +0 -1
  364. package/dist/utils/git.js.map +0 -1
  365. package/dist/utils/is-debug.d.ts.map +0 -1
  366. package/dist/utils/is-debug.js.map +0 -1
  367. package/dist/utils/lambda-config.d.ts.map +0 -1
  368. package/dist/utils/lambda-config.js.map +0 -1
  369. package/dist/utils/log.d.ts.map +0 -1
  370. package/dist/utils/log.js.map +0 -1
  371. package/dist/utils/messages.d.ts.map +0 -1
  372. package/dist/utils/messages.js.map +0 -1
  373. package/dist/utils/package-manager.d.ts.map +0 -1
  374. package/dist/utils/package-manager.js.map +0 -1
  375. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  376. package/dist/utils/payload-config-ast.js.map +0 -1
  377. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  378. package/dist/utils/payload-config-finder.js.map +0 -1
  379. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  380. package/dist/utils/payload-config-modifier.js.map +0 -1
  381. package/dist/utils/payload-package-check.d.ts.map +0 -1
  382. package/dist/utils/payload-package-check.js.map +0 -1
  383. package/dist/utils/project.d.ts.map +0 -1
  384. package/dist/utils/project.js.map +0 -1
  385. package/dist/utils/s3-upload.d.ts.map +0 -1
  386. package/dist/utils/s3-upload.js.map +0 -1
  387. package/dist/utils/token-display.d.ts.map +0 -1
  388. package/dist/utils/token-display.js.map +0 -1
  389. package/dist/utils/typescript-validator.d.ts.map +0 -1
  390. package/dist/utils/typescript-validator.js.map +0 -1
@@ -1,11 +1,12 @@
1
- /* eslint-disable perfectionist/sort-objects */ import { OAUTH_CONFIG } from '../config/oauth.js';
1
+ /* eslint-disable perfectionist/sort-objects */ import { getOAuthConfig } from '../config/oauth.js';
2
2
  import * as log from '../utils/log.js';
3
3
  /**
4
4
  * Error thrown when token refresh fails
5
5
  */ export class TokenRefreshError extends Error {
6
6
  statusCode;
7
- constructor(message, statusCode){
8
- super(message), this.statusCode = statusCode;
7
+ errorCode;
8
+ constructor(message, statusCode, errorCode){
9
+ super(message), this.statusCode = statusCode, this.errorCode = errorCode;
9
10
  this.name = 'TokenRefreshError';
10
11
  }
11
12
  }
@@ -19,15 +20,17 @@ import * as log from '../utils/log.js';
19
20
  * @param clientId - OAuth2 client ID (defaults to config)
20
21
  * @returns Promise resolving to new tokens
21
22
  * @throws TokenRefreshError if refresh fails
22
- */ export async function refreshAccessToken(refreshToken, clientId = OAUTH_CONFIG.clientId) {
23
+ */ export async function refreshAccessToken(refreshToken, clientId) {
24
+ const oauthConfig = getOAuthConfig();
25
+ const resolvedClientId = clientId ?? oauthConfig.clientId;
23
26
  // Prepare form data for token refresh request (public client)
24
27
  const params = new URLSearchParams({
25
- client_id: clientId,
28
+ client_id: resolvedClientId,
26
29
  grant_type: 'refresh_token',
27
30
  refresh_token: refreshToken
28
31
  });
29
32
  try {
30
- const response = await fetch(OAUTH_CONFIG.refreshUrl, {
33
+ const response = await fetch(oauthConfig.refreshUrl, {
31
34
  method: 'POST',
32
35
  headers: {
33
36
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -36,7 +39,14 @@ import * as log from '../utils/log.js';
36
39
  });
37
40
  if (!response.ok) {
38
41
  const errorText = await response.text();
39
- throw new TokenRefreshError(`Token refresh failed: ${response.statusText}. ${errorText}`, response.status);
42
+ let errorCode;
43
+ try {
44
+ const parsed = JSON.parse(errorText);
45
+ errorCode = parsed.error;
46
+ } catch {
47
+ // Not JSON, leave errorCode undefined
48
+ }
49
+ throw new TokenRefreshError(`Token refresh failed: ${response.statusText}. ${errorText}`, response.status, errorCode);
40
50
  }
41
51
  const data = await response.json();
42
52
  // Validate response contains required fields
@@ -71,14 +81,17 @@ import * as log from '../utils/log.js';
71
81
  * @param clientId - OAuth2 client ID (defaults to config)
72
82
  * @returns Promise resolving to tokens
73
83
  * @throws TokenRefreshError if exchange fails
74
- */ export async function exchangeCodeForTokens(code, codeVerifier, redirectUri = OAUTH_CONFIG.redirectUri, clientId = OAUTH_CONFIG.clientId) {
84
+ */ export async function exchangeCodeForTokens(code, codeVerifier, redirectUri, clientId) {
85
+ const oauthConfig = getOAuthConfig();
86
+ const resolvedRedirectUri = redirectUri ?? oauthConfig.redirectUri;
87
+ const resolvedClientId = clientId ?? oauthConfig.clientId;
75
88
  // Prepare form data for token exchange (public client with PKCE)
76
89
  const params = new URLSearchParams({
77
- client_id: clientId,
90
+ client_id: resolvedClientId,
78
91
  code,
79
92
  code_verifier: codeVerifier,
80
93
  grant_type: 'authorization_code',
81
- redirect_uri: redirectUri
94
+ redirect_uri: resolvedRedirectUri
82
95
  });
83
96
  try {
84
97
  // Public client - no client secret or Basic Auth header needed
@@ -88,11 +101,11 @@ import * as log from '../utils/log.js';
88
101
  };
89
102
  // Debug logging
90
103
  log.debug(`Token exchange request: ${JSON.stringify({
91
- url: OAUTH_CONFIG.tokenUrl,
104
+ url: oauthConfig.tokenUrl,
92
105
  headers,
93
106
  body: params.toString()
94
107
  })}`);
95
- const response = await fetch(OAUTH_CONFIG.tokenUrl, {
108
+ const response = await fetch(oauthConfig.tokenUrl, {
96
109
  method: 'POST',
97
110
  headers,
98
111
  body: params.toString()
@@ -0,0 +1,58 @@
1
+ import type { BootstrapData, FigmaTokens, ProjectToken } from './types.js';
2
+ export type LegacyStoreSchema = {
3
+ bootstrapData?: Record<string, BootstrapData>;
4
+ projectTokens?: Record<string, ProjectToken>;
5
+ tokens?: FigmaTokens;
6
+ };
7
+ export type MigrationCheckParams = {
8
+ checkFileExists?: (filePath: string) => boolean;
9
+ legacyFilePath: string;
10
+ newOAuthFilePath: string;
11
+ };
12
+ export type MigrateOAuthParams = {
13
+ encryptionKey: string;
14
+ legacyConfigName: string;
15
+ legacyCwd?: string;
16
+ newOAuthConfigName: string;
17
+ newOAuthCwd: string;
18
+ projectName: string;
19
+ };
20
+ /**
21
+ * Check if migration is needed.
22
+ * Returns true only when legacy file exists AND new oauth file does not.
23
+ */
24
+ export declare function needsMigration(params: MigrationCheckParams): boolean;
25
+ /**
26
+ * Migrate OAuth tokens from legacy store to new oauth store.
27
+ * Reads from legacy location, writes to new location with root-level keys.
28
+ *
29
+ * `clearInvalidConfig` is deliberately OFF so a transient decrypt error does
30
+ * not wipe the legacy file — older CLI versions elsewhere on disk still read
31
+ * it. If we cannot open the file, we log and skip migration.
32
+ */
33
+ export declare function migrateOAuth(params: MigrateOAuthParams): void;
34
+ export type ResolveProjectStorePath = (scope: {
35
+ environmentName: string;
36
+ projectId: string;
37
+ }) => {
38
+ configName: string;
39
+ cwd: string;
40
+ };
41
+ export type MigrateProjectDataParams = {
42
+ encryptionKey: string;
43
+ legacyConfigName: string;
44
+ legacyCwd?: string;
45
+ projectName: string;
46
+ resolveProjectStorePath: ResolveProjectStorePath;
47
+ };
48
+ /**
49
+ * Migrate per-project bootstrap data and project tokens from the legacy
50
+ * combined store into individual per-project stores.
51
+ *
52
+ * Walks legacy `bootstrapData` (keyed by `projectId:environmentName`), writes
53
+ * each entry into its own project store file, and stashes the matching
54
+ * `projectToken` (looked up by `bootstrapData.contentSystemId`) alongside it.
55
+ * Target files that already exist are left alone.
56
+ */
57
+ export declare function migrateProjectData(params: MigrateProjectDataParams): void;
58
+ //# sourceMappingURL=token-store-migration.d.ts.map
@@ -0,0 +1,156 @@
1
+ import Conf from 'conf';
2
+ import fsSync from 'node:fs';
3
+ import path from 'node:path';
4
+ import * as log from '../utils/log.js';
5
+ const OAUTH_STORE_SCHEMA_VERSION = 1;
6
+ const PROJECT_STORE_SCHEMA_VERSION = 1;
7
+ /**
8
+ * Check if migration is needed.
9
+ * Returns true only when legacy file exists AND new oauth file does not.
10
+ */ export function needsMigration(params) {
11
+ const checkExists = params.checkFileExists ?? fsSync.existsSync;
12
+ const newExists = checkExists(params.newOAuthFilePath);
13
+ if (newExists) {
14
+ return false;
15
+ }
16
+ return checkExists(params.legacyFilePath);
17
+ }
18
+ /**
19
+ * Migrate OAuth tokens from legacy store to new oauth store.
20
+ * Reads from legacy location, writes to new location with root-level keys.
21
+ *
22
+ * `clearInvalidConfig` is deliberately OFF so a transient decrypt error does
23
+ * not wipe the legacy file — older CLI versions elsewhere on disk still read
24
+ * it. If we cannot open the file, we log and skip migration.
25
+ */ export function migrateOAuth(params) {
26
+ const legacyConfig = openLegacyConfig({
27
+ encryptionKey: params.encryptionKey,
28
+ legacyConfigName: params.legacyConfigName,
29
+ legacyCwd: params.legacyCwd,
30
+ projectName: params.projectName
31
+ });
32
+ if (!legacyConfig) {
33
+ return;
34
+ }
35
+ const legacyTokens = safeGet(legacyConfig, 'tokens');
36
+ if (!legacyTokens) {
37
+ return;
38
+ }
39
+ // Ensure target directory exists
40
+ if (!fsSync.existsSync(params.newOAuthCwd)) {
41
+ fsSync.mkdirSync(params.newOAuthCwd, {
42
+ recursive: true
43
+ });
44
+ }
45
+ const newOAuthConfig = new Conf({
46
+ configName: params.newOAuthConfigName,
47
+ cwd: params.newOAuthCwd,
48
+ encryptionKey: params.encryptionKey,
49
+ projectName: params.projectName
50
+ });
51
+ // Write root-level keys
52
+ newOAuthConfig.set('_schemaVersion', OAUTH_STORE_SCHEMA_VERSION);
53
+ newOAuthConfig.set('accessToken', legacyTokens.accessToken);
54
+ newOAuthConfig.set('expiresAt', legacyTokens.expiresAt);
55
+ newOAuthConfig.set('refreshToken', legacyTokens.refreshToken);
56
+ if (legacyTokens.scopes) {
57
+ newOAuthConfig.set('scopes', legacyTokens.scopes);
58
+ }
59
+ if (legacyTokens.tokenType) {
60
+ newOAuthConfig.set('tokenType', legacyTokens.tokenType);
61
+ }
62
+ if (legacyTokens.userId) {
63
+ newOAuthConfig.set('userId', legacyTokens.userId);
64
+ }
65
+ // Leave the legacy file untouched so older CLI versions installed in other
66
+ // projects on the same machine can keep reading their last known state.
67
+ }
68
+ /**
69
+ * Migrate per-project bootstrap data and project tokens from the legacy
70
+ * combined store into individual per-project stores.
71
+ *
72
+ * Walks legacy `bootstrapData` (keyed by `projectId:environmentName`), writes
73
+ * each entry into its own project store file, and stashes the matching
74
+ * `projectToken` (looked up by `bootstrapData.contentSystemId`) alongside it.
75
+ * Target files that already exist are left alone.
76
+ */ export function migrateProjectData(params) {
77
+ const legacyConfig = openLegacyConfig({
78
+ encryptionKey: params.encryptionKey,
79
+ legacyConfigName: params.legacyConfigName,
80
+ legacyCwd: params.legacyCwd,
81
+ projectName: params.projectName
82
+ });
83
+ if (!legacyConfig) {
84
+ return;
85
+ }
86
+ const bootstrapData = safeGet(legacyConfig, 'bootstrapData') || {};
87
+ const projectTokens = safeGet(legacyConfig, 'projectTokens') || {};
88
+ if (Object.keys(bootstrapData).length === 0 && Object.keys(projectTokens).length === 0) {
89
+ return;
90
+ }
91
+ for (const [key, bootstrap] of Object.entries(bootstrapData)){
92
+ const separatorIdx = key.indexOf(':');
93
+ if (separatorIdx === -1) {
94
+ continue;
95
+ }
96
+ const projectId = key.slice(0, separatorIdx);
97
+ const environmentName = key.slice(separatorIdx + 1);
98
+ if (!projectId || !environmentName) {
99
+ continue;
100
+ }
101
+ const { configName, cwd } = params.resolveProjectStorePath({
102
+ environmentName,
103
+ projectId
104
+ });
105
+ const targetPath = path.join(cwd, `${configName}.json`);
106
+ if (fsSync.existsSync(targetPath)) {
107
+ continue;
108
+ }
109
+ if (!fsSync.existsSync(cwd)) {
110
+ fsSync.mkdirSync(cwd, {
111
+ recursive: true
112
+ });
113
+ }
114
+ const projectConfig = new Conf({
115
+ configName,
116
+ cwd,
117
+ encryptionKey: params.encryptionKey,
118
+ projectName: params.projectName
119
+ });
120
+ projectConfig.set('_schemaVersion', PROJECT_STORE_SCHEMA_VERSION);
121
+ projectConfig.set('bootstrapData', bootstrap);
122
+ const legacyProjectToken = bootstrap.contentSystemId ? projectTokens[bootstrap.contentSystemId] : undefined;
123
+ if (legacyProjectToken) {
124
+ projectConfig.set('projectToken', legacyProjectToken);
125
+ }
126
+ }
127
+ // Leave the legacy file untouched so older CLI versions installed in other
128
+ // projects on the same machine can keep reading their last known state.
129
+ }
130
+ function safeGet(config, key) {
131
+ try {
132
+ return config.get(key);
133
+ } catch (error) {
134
+ log.debug(`Migration read failed (key: ${String(key)}). ` + `File: ${config.path}. ` + `Error: ${error instanceof Error ? error.message : 'Unknown'}`);
135
+ return undefined;
136
+ }
137
+ }
138
+ /**
139
+ * Open the legacy Conf store without `clearInvalidConfig`, so a decrypt
140
+ * error does not destroy the file. Returns null when the file cannot be
141
+ * opened — callers treat that as "nothing to migrate, leave file alone".
142
+ */ function openLegacyConfig(params) {
143
+ try {
144
+ return new Conf({
145
+ configName: params.legacyConfigName,
146
+ cwd: params.legacyCwd,
147
+ encryptionKey: params.encryptionKey,
148
+ projectName: params.projectName
149
+ });
150
+ } catch (error) {
151
+ log.debug(`Legacy token store could not be opened; skipping migration and leaving file intact. ` + `Error: ${error instanceof Error ? error.message : 'Unknown'}`);
152
+ return null;
153
+ }
154
+ }
155
+
156
+ //# sourceMappingURL=token-store-migration.js.map
@@ -1,110 +1,76 @@
1
- import type { FigmaTokens, JWTPayload, ProjectToken, TokenStoreConfig } from './types.js';
1
+ import type { Environment } from '../constants.js';
2
+ import type { BootstrapData, FigmaTokens, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
2
3
  /**
3
- * Secure storage manager for Figma OAuth2 tokens
4
- *
5
- * Uses the `conf` library to store tokens in an OS-specific secure location:
6
- * - macOS: ~/Library/Preferences/payloadcms-figma
7
- * - Linux: ~/.config/payloadcms-figma or $XDG_CONFIG_HOME/payloadcms-figma
8
- * - Windows: %APPDATA%/payloadcms-figma/Config
4
+ * Get the singleton TokenStore instance for an environment.
5
+ */
6
+ export declare function getTokenStore(environment?: Environment): TokenStore;
7
+ /**
8
+ * Secure storage manager for OAuth tokens and project-scoped bootstrap/token data.
9
9
  *
10
- * Tokens are encrypted at rest with a machine-specific key and file permissions
11
- * are set to 0600 (owner read/write only)
10
+ * For production code, use getTokenStore() to get the singleton instance.
11
+ * The constructor is still exported for test isolation.
12
12
  */
13
13
  export declare class TokenStore {
14
- private config;
14
+ private baseConfigName;
15
+ private deriveLegacyKey;
16
+ private encryptionKey;
17
+ private environment;
18
+ private legacyRootDir;
19
+ private oauthConfig;
20
+ private projectName;
21
+ private projectStoreConfigs;
15
22
  constructor(options?: TokenStoreConfig);
16
- /**
17
- * Retrieve stored tokens
18
- * @returns FigmaTokens if stored, null otherwise
19
- */
20
- getTokens(): FigmaTokens | null;
21
- /**
22
- * Store OAuth2 tokens securely
23
- * @param tokens - Figma OAuth2 tokens to store
24
- */
23
+ getOauthInfo(): FigmaTokens | null;
25
24
  setTokens(tokens: FigmaTokens): void;
26
- /**
27
- * Clear all stored tokens (used for logout)
28
- */
29
25
  clearTokens(): void;
30
- /**
31
- * Check if valid (non-expired) tokens exist
32
- * @returns true if tokens exist and are not expired
33
- */
34
- hasValidTokens(): boolean;
35
- /**
36
- * Check if the current access token is expired
37
- * Includes a buffer time to avoid using tokens that are about to expire
38
- * @returns true if token is expired or will expire within buffer time
39
- */
40
- isExpired(): boolean;
41
- /**
42
- * Get the access token if it exists and is valid
43
- * @returns Access token string or null if expired/missing
44
- */
45
- getAccessToken(): null | string;
46
- /**
47
- * Get the refresh token if it exists
48
- * @returns Refresh token string or null if missing
49
- */
50
- getRefreshToken(): null | string;
51
- /**
52
- * Update just the access token after a refresh
53
- * Preserves the existing refresh token and other metadata
54
- * @param accessToken - New access token
55
- * @param expiresIn - Expiration time in seconds
56
- */
26
+ hasValidOauthToken(): boolean;
27
+ isOauthExpired(): boolean;
28
+ getCurrentOauthToken(): null | string;
29
+ getCurrentRefreshToken(): null | string;
57
30
  updateAccessToken(accessToken: string, expiresIn: number): void;
58
31
  /**
59
- * Get the path to the config file (useful for debugging)
60
- * @returns Absolute path to the token storage file
32
+ * Returns the OAuth storage file path.
61
33
  */
62
34
  getStoragePath(): string;
63
- /**
64
- * Retrieve a project token for a specific tenant
65
- * Automatically removes expired tokens from storage
66
- * @param tenantId - The tenant/CMS ID
67
- * @returns ProjectToken if stored and valid, null otherwise
68
- */
69
- getProjectToken(tenantId: string): null | ProjectToken;
70
- /**
71
- * Store a project token for a specific tenant
72
- * @param tenantId - The tenant/CMS ID
73
- * @param projectToken - The project token to store
74
- */
75
- setProjectToken(tenantId: string, projectToken: ProjectToken): void;
76
- /**
77
- * Clear a project token for a specific tenant
78
- * @param tenantId - The tenant/CMS ID
79
- */
80
- clearProjectToken(tenantId: string): void;
81
- /**
82
- * Clear all project tokens
83
- */
84
- clearAllProjectTokens(): void;
85
- /**
86
- * Check if a project token is expired
87
- * Includes a buffer time to avoid using tokens that are about to expire
88
- * @param projectToken - The project token to check
89
- * @returns true if token is expired or will expire within buffer time
90
- */
91
- isProjectTokenExpired(projectToken: ProjectToken): boolean;
92
- /**
93
- * Check if a valid (non-expired) project token exists for a tenant
94
- * @param tenantId - The tenant/CMS ID
95
- * @returns true if token exists and is not expired
96
- */
97
- hasValidProjectToken(tenantId: string): boolean;
98
- /**
99
- * Get validated JWT claims from a project token
100
- * @param tenantId - The tenant/CMS ID
101
- * @returns JWT payload claims or null if token not found or has no claims
102
- */
103
- getProjectTokenClaims(tenantId: string): JWTPayload | null;
104
- /**
105
- * Get all tenant IDs that have stored project tokens
106
- * @returns Array of tenant IDs
107
- */
108
- getAllProjectTokenTenantIds(): string[];
35
+ getProjectToken({ projectInfo, }?: {
36
+ projectInfo?: ProjectStoreScope;
37
+ }): null | ProjectToken;
38
+ setProjectToken({ projectInfo, token, }: {
39
+ projectInfo?: ProjectStoreScope;
40
+ token: ProjectToken;
41
+ }): void;
42
+ clearProjectToken({ projectInfo }?: {
43
+ projectInfo?: ProjectStoreScope;
44
+ }): void;
45
+ isProjectTokenExpired(token: ProjectToken): boolean;
46
+ hasValidProjectToken({ projectInfo }?: {
47
+ projectInfo?: ProjectStoreScope;
48
+ }): boolean;
49
+ /**
50
+ * Get the tenantId (contentSystemId) for the project scope.
51
+ * Returns null if bootstrap data is not available.
52
+ */
53
+ getTenantId({ projectInfo }?: {
54
+ projectInfo?: ProjectStoreScope;
55
+ }): null | string;
56
+ /**
57
+ * Derive project info from environment variables.
58
+ * Returns null if either FIGMA_PROJECT_ID or FIGMA_ENVIRONMENT_NAME is not set.
59
+ */
60
+ private getProjectInfoFromEnv;
61
+ getBootstrapData(projectId: string, environmentName: string): BootstrapData | null;
62
+ setBootstrapData(projectId: string, environmentName: string, data: BootstrapData): void;
63
+ clearBootstrapData(projectId: string, environmentName: string): void;
64
+ private buildOAuthConfigName;
65
+ private buildOAuthStoreCwd;
66
+ private buildProjectStoreConfigName;
67
+ private buildProjectStoreCwd;
68
+ private sanitizeConfigSegment;
69
+ private projectInfoKey;
70
+ private getLegacyRootDir;
71
+ private getProjectStore;
72
+ private createConfig;
73
+ private tryMigrateLegacyKey;
74
+ private safeGet;
109
75
  }
110
76
  //# sourceMappingURL=token-store.d.ts.map