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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/dist/api/control-plane.d.ts +1 -22
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +22 -55
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +21 -45
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/callback-server.d.ts.map +1 -1
  9. package/dist/auth/callback-server.js +1 -2
  10. package/dist/auth/callback-server.js.map +1 -1
  11. package/dist/auth/crypto-utils.d.ts.map +1 -1
  12. package/dist/auth/crypto-utils.js +5 -5
  13. package/dist/auth/crypto-utils.js.map +1 -1
  14. package/dist/auth/jwt-validator.d.ts +1 -2
  15. package/dist/auth/jwt-validator.d.ts.map +1 -1
  16. package/dist/auth/jwt-validator.js +2 -2
  17. package/dist/auth/jwt-validator.js.map +1 -1
  18. package/dist/auth/oauth-flow.d.ts +1 -1
  19. package/dist/auth/oauth-flow.d.ts.map +1 -1
  20. package/dist/auth/oauth-flow.js +11 -15
  21. package/dist/auth/oauth-flow.js.map +1 -1
  22. package/dist/auth/project-token.d.ts.map +1 -1
  23. package/dist/auth/project-token.js +4 -9
  24. package/dist/auth/project-token.js.map +1 -1
  25. package/dist/auth/refresh.d.ts +1 -2
  26. package/dist/auth/refresh.d.ts.map +1 -1
  27. package/dist/auth/refresh.js +12 -25
  28. package/dist/auth/refresh.js.map +1 -1
  29. package/dist/auth/token-store.d.ts +0 -12
  30. package/dist/auth/token-store.d.ts.map +1 -1
  31. package/dist/auth/token-store.js +5 -28
  32. package/dist/auth/token-store.js.map +1 -1
  33. package/dist/auth/types.d.ts +4 -7
  34. package/dist/auth/types.d.ts.map +1 -1
  35. package/dist/auth/types.js.map +1 -1
  36. package/dist/cli.d.ts.map +1 -1
  37. package/dist/cli.js +6 -39
  38. package/dist/cli.js.map +1 -1
  39. package/dist/commands/deploy.d.ts +0 -4
  40. package/dist/commands/deploy.d.ts.map +1 -1
  41. package/dist/commands/deploy.js +129 -72
  42. package/dist/commands/deploy.js.map +1 -1
  43. package/dist/commands/init.d.ts +5 -1
  44. package/dist/commands/init.d.ts.map +1 -1
  45. package/dist/commands/init.js +85 -105
  46. package/dist/commands/init.js.map +1 -1
  47. package/dist/commands/list-tokens.d.ts +3 -3
  48. package/dist/commands/list-tokens.d.ts.map +1 -1
  49. package/dist/commands/list-tokens.js +7 -22
  50. package/dist/commands/list-tokens.js.map +1 -1
  51. package/dist/commands/login.d.ts +1 -8
  52. package/dist/commands/login.d.ts.map +1 -1
  53. package/dist/commands/login.js +12 -30
  54. package/dist/commands/login.js.map +1 -1
  55. package/dist/commands/logout.d.ts +4 -5
  56. package/dist/commands/logout.d.ts.map +1 -1
  57. package/dist/commands/logout.js +13 -56
  58. package/dist/commands/logout.js.map +1 -1
  59. package/dist/config/oauth.d.ts +14 -4
  60. package/dist/config/oauth.d.ts.map +1 -1
  61. package/dist/config/oauth.js +40 -19
  62. package/dist/config/oauth.js.map +1 -1
  63. package/dist/constants.d.ts +18 -26
  64. package/dist/constants.d.ts.map +1 -1
  65. package/dist/constants.js +20 -34
  66. package/dist/constants.js.map +1 -1
  67. package/dist/exports/client.d.ts +0 -1
  68. package/dist/exports/client.d.ts.map +1 -1
  69. package/dist/exports/client.js +0 -1
  70. package/dist/exports/client.js.map +1 -1
  71. package/dist/index.d.ts +1 -2
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +1 -3
  74. package/dist/index.js.map +1 -1
  75. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  76. package/dist/oauth/components/LoginButton/index.js +6 -50
  77. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  78. package/dist/oauth/components/LoginButton/index.scss +3 -50
  79. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  80. package/dist/oauth/components/LogoutButton/index.js +4 -5
  81. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  82. package/dist/oauth/defaults.d.ts.map +1 -1
  83. package/dist/oauth/defaults.js +5 -29
  84. package/dist/oauth/defaults.js.map +1 -1
  85. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  86. package/dist/oauth/endpoints/getLoginEndpoint.js +11 -21
  87. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  88. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -1
  89. package/dist/oauth/endpoints/getLogoutEndpoint.js +4 -7
  90. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -1
  91. package/dist/oauth/index.d.ts.map +1 -1
  92. package/dist/oauth/index.js +13 -40
  93. package/dist/oauth/index.js.map +1 -1
  94. package/dist/oauth/strategy/index.d.ts +2 -0
  95. package/dist/oauth/strategy/index.d.ts.map +1 -1
  96. package/dist/oauth/strategy/index.js +15 -38
  97. package/dist/oauth/strategy/index.js.map +1 -1
  98. package/dist/oauth/types.d.ts +6 -6
  99. package/dist/oauth/types.d.ts.map +1 -1
  100. package/dist/oauth/types.js.map +1 -1
  101. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  102. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  103. package/dist/oauth/utilities/getAdminPath.d.ts +8 -0
  104. package/dist/oauth/utilities/getAdminPath.d.ts.map +1 -0
  105. package/dist/oauth/utilities/getAdminPath.js +9 -0
  106. package/dist/oauth/utilities/getAdminPath.js.map +1 -0
  107. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  108. package/dist/oauth/utilities/refreshTokens.js +1 -1
  109. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  110. package/dist/plugin/build-config.d.ts +4 -21
  111. package/dist/plugin/build-config.d.ts.map +1 -1
  112. package/dist/plugin/build-config.js +7 -113
  113. package/dist/plugin/build-config.js.map +1 -1
  114. package/dist/types.d.ts +0 -1
  115. package/dist/types.d.ts.map +1 -1
  116. package/dist/types.js.map +1 -1
  117. package/dist/utils/asset-collection.d.ts +6 -3
  118. package/dist/utils/asset-collection.d.ts.map +1 -1
  119. package/dist/utils/asset-collection.js +34 -10
  120. package/dist/utils/asset-collection.js.map +1 -1
  121. package/dist/utils/config.js +1 -1
  122. package/dist/utils/config.js.map +1 -1
  123. package/dist/utils/env-management.d.ts +8 -9
  124. package/dist/utils/env-management.d.ts.map +1 -1
  125. package/dist/utils/env-management.js +74 -73
  126. package/dist/utils/env-management.js.map +1 -1
  127. package/dist/utils/formatter.d.ts.map +1 -1
  128. package/dist/utils/formatter.js +5 -3
  129. package/dist/utils/formatter.js.map +1 -1
  130. package/dist/utils/lambda-config.d.ts +1 -3
  131. package/dist/utils/lambda-config.d.ts.map +1 -1
  132. package/dist/utils/lambda-config.js +32 -38
  133. package/dist/utils/lambda-config.js.map +1 -1
  134. package/dist/utils/messages.js +8 -8
  135. package/dist/utils/messages.js.map +1 -1
  136. package/dist/utils/payload-config-ast.d.ts +3 -22
  137. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  138. package/dist/utils/payload-config-ast.js +31 -89
  139. package/dist/utils/payload-config-ast.js.map +1 -1
  140. package/dist/utils/payload-config-finder.d.ts +2 -2
  141. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  142. package/dist/utils/payload-config-finder.js +9 -48
  143. package/dist/utils/payload-config-finder.js.map +1 -1
  144. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  145. package/dist/utils/payload-config-modifier.js +6 -54
  146. package/dist/utils/payload-config-modifier.js.map +1 -1
  147. package/dist/utils/payload-package-check.d.ts +1 -12
  148. package/dist/utils/payload-package-check.d.ts.map +1 -1
  149. package/dist/utils/payload-package-check.js +5 -63
  150. package/dist/utils/payload-package-check.js.map +1 -1
  151. package/dist/utils/project.d.ts.map +1 -1
  152. package/dist/utils/project.js +5 -8
  153. package/dist/utils/project.js.map +1 -1
  154. package/dist/utils/s3-upload.d.ts +1 -0
  155. package/dist/utils/s3-upload.d.ts.map +1 -1
  156. package/dist/utils/s3-upload.js +3 -10
  157. package/dist/utils/s3-upload.js.map +1 -1
  158. package/dist/utils/token-display.d.ts.map +1 -1
  159. package/dist/utils/token-display.js +5 -11
  160. package/dist/utils/token-display.js.map +1 -1
  161. package/dist/utils/typescript-validator.d.ts.map +1 -1
  162. package/dist/utils/typescript-validator.js +6 -4
  163. package/dist/utils/typescript-validator.js.map +1 -1
  164. package/package.json +9 -27
  165. package/dist/commands/build-lambda-zip.d.ts +0 -5
  166. package/dist/commands/build-lambda-zip.d.ts.map +0 -1
  167. package/dist/commands/build-lambda-zip.js +0 -19
  168. package/dist/commands/build-lambda-zip.js.map +0 -1
  169. package/dist/db-content-api/README.md +0 -98
  170. package/dist/db-content-api/generated/content-api-types.d.ts +0 -3914
  171. package/dist/db-content-api/generated/content-api-types.d.ts.map +0 -1
  172. package/dist/db-content-api/generated/content-api-types.js +0 -7
  173. package/dist/db-content-api/generated/content-api-types.js.map +0 -1
  174. package/dist/db-content-api/index.d.ts +0 -18
  175. package/dist/db-content-api/index.d.ts.map +0 -1
  176. package/dist/db-content-api/index.js +0 -586
  177. package/dist/db-content-api/index.js.map +0 -1
  178. package/dist/db-content-api/temp-utilities/slug.d.ts +0 -2
  179. package/dist/db-content-api/temp-utilities/slug.d.ts.map +0 -1
  180. package/dist/db-content-api/temp-utilities/slug.js +0 -3
  181. package/dist/db-content-api/temp-utilities/slug.js.map +0 -1
  182. package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -3
  183. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +0 -1
  184. package/dist/db-content-api/temp-utilities/sorting.js +0 -32
  185. package/dist/db-content-api/temp-utilities/sorting.js.map +0 -1
  186. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -34
  187. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +0 -1
  188. package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -53
  189. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +0 -1
  190. package/dist/db-content-api/utilities/auth.d.ts +0 -30
  191. package/dist/db-content-api/utilities/auth.d.ts.map +0 -1
  192. package/dist/db-content-api/utilities/auth.js +0 -81
  193. package/dist/db-content-api/utilities/auth.js.map +0 -1
  194. package/dist/db-content-api/utilities/buildPathTypes.d.ts +0 -12
  195. package/dist/db-content-api/utilities/buildPathTypes.d.ts.map +0 -1
  196. package/dist/db-content-api/utilities/buildPathTypes.js +0 -157
  197. package/dist/db-content-api/utilities/buildPathTypes.js.map +0 -1
  198. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -7
  199. package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +0 -1
  200. package/dist/db-content-api/utilities/data/applyDefaults.js +0 -59
  201. package/dist/db-content-api/utilities/data/applyDefaults.js.map +0 -1
  202. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -11
  203. package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +0 -1
  204. package/dist/db-content-api/utilities/data/castFieldValue.js +0 -66
  205. package/dist/db-content-api/utilities/data/castFieldValue.js.map +0 -1
  206. package/dist/db-content-api/utilities/data/index.d.ts +0 -32
  207. package/dist/db-content-api/utilities/data/index.d.ts.map +0 -1
  208. package/dist/db-content-api/utilities/data/index.js +0 -190
  209. package/dist/db-content-api/utilities/data/index.js.map +0 -1
  210. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -12
  211. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +0 -1
  212. package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -54
  213. package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +0 -1
  214. package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -48
  215. package/dist/db-content-api/utilities/data/stripFields.d.ts.map +0 -1
  216. package/dist/db-content-api/utilities/data/stripFields.js +0 -195
  217. package/dist/db-content-api/utilities/data/stripFields.js.map +0 -1
  218. package/dist/db-content-api/utilities/joins.d.ts +0 -55
  219. package/dist/db-content-api/utilities/joins.d.ts.map +0 -1
  220. package/dist/db-content-api/utilities/joins.js +0 -136
  221. package/dist/db-content-api/utilities/joins.js.map +0 -1
  222. package/dist/db-content-api/utilities/where.d.ts +0 -12
  223. package/dist/db-content-api/utilities/where.d.ts.map +0 -1
  224. package/dist/db-content-api/utilities/where.js +0 -121
  225. package/dist/db-content-api/utilities/where.js.map +0 -1
  226. package/dist/endpoints/health.d.ts +0 -3
  227. package/dist/endpoints/health.d.ts.map +0 -1
  228. package/dist/endpoints/health.js +0 -11
  229. package/dist/endpoints/health.js.map +0 -1
  230. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -7
  231. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +0 -1
  232. package/dist/oauth/utilities/isDuplicateKeyError.js +0 -14
  233. package/dist/oauth/utilities/isDuplicateKeyError.js.map +0 -1
  234. package/dist/storage-content-api/api-types.d.ts +0 -168
  235. package/dist/storage-content-api/api-types.d.ts.map +0 -1
  236. package/dist/storage-content-api/api-types.js +0 -6
  237. package/dist/storage-content-api/api-types.js.map +0 -1
  238. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -9
  239. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +0 -1
  240. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -42
  241. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +0 -1
  242. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -13
  243. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +0 -1
  244. package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -32
  245. package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +0 -1
  246. package/dist/storage-content-api/client.d.ts +0 -6
  247. package/dist/storage-content-api/client.d.ts.map +0 -1
  248. package/dist/storage-content-api/client.js +0 -36
  249. package/dist/storage-content-api/client.js.map +0 -1
  250. package/dist/storage-content-api/generateURL.d.ts +0 -7
  251. package/dist/storage-content-api/generateURL.d.ts.map +0 -1
  252. package/dist/storage-content-api/generateURL.js +0 -8
  253. package/dist/storage-content-api/generateURL.js.map +0 -1
  254. package/dist/storage-content-api/handleDelete.d.ts +0 -8
  255. package/dist/storage-content-api/handleDelete.d.ts.map +0 -1
  256. package/dist/storage-content-api/handleDelete.js +0 -17
  257. package/dist/storage-content-api/handleDelete.js.map +0 -1
  258. package/dist/storage-content-api/handleUpload.d.ts +0 -11
  259. package/dist/storage-content-api/handleUpload.d.ts.map +0 -1
  260. package/dist/storage-content-api/handleUpload.js +0 -144
  261. package/dist/storage-content-api/handleUpload.js.map +0 -1
  262. package/dist/storage-content-api/index.d.ts +0 -5
  263. package/dist/storage-content-api/index.d.ts.map +0 -1
  264. package/dist/storage-content-api/index.js +0 -31
  265. package/dist/storage-content-api/index.js.map +0 -1
  266. package/dist/storage-content-api/staticHandler.d.ts +0 -10
  267. package/dist/storage-content-api/staticHandler.d.ts.map +0 -1
  268. package/dist/storage-content-api/staticHandler.js +0 -56
  269. package/dist/storage-content-api/staticHandler.js.map +0 -1
  270. package/dist/storage-content-api/types.d.ts +0 -10
  271. package/dist/storage-content-api/types.d.ts.map +0 -1
  272. package/dist/storage-content-api/types.js +0 -3
  273. package/dist/storage-content-api/types.js.map +0 -1
  274. package/dist/templates/README.md +0 -19
  275. package/dist/utils/build-lambda-zip.d.ts +0 -14
  276. package/dist/utils/build-lambda-zip.d.ts.map +0 -1
  277. package/dist/utils/build-lambda-zip.js +0 -81
  278. package/dist/utils/build-lambda-zip.js.map +0 -1
  279. package/dist/utils/format-env-suffix.d.ts +0 -12
  280. package/dist/utils/format-env-suffix.d.ts.map +0 -1
  281. package/dist/utils/format-env-suffix.js +0 -13
  282. package/dist/utils/format-env-suffix.js.map +0 -1
  283. package/dist/utils/version-check.d.ts +0 -3
  284. package/dist/utils/version-check.d.ts.map +0 -1
  285. package/dist/utils/version-check.js +0 -38
  286. package/dist/utils/version-check.js.map +0 -1
@@ -1,29 +1,22 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
- import { CallbackError } from '../auth/callback-server.js';
4
3
  import { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js';
5
- import { getTokenStore } from '../auth/token-store.js';
6
- import { getOAuthConfig } from '../config/oauth.js';
7
- import { getEnvironment } from '../constants.js';
8
- import { formatEnvSuffix } from '../utils/format-env-suffix.js';
4
+ import { TokenStore } from '../auth/token-store.js';
5
+ import { OAUTH_CONFIG } from '../config/oauth.js';
9
6
  import * as log from '../utils/log.js';
10
7
  /**
11
8
  * Handle the `@payloadcms/figma login` command
12
9
  *
13
10
  * Authenticates the user with Figma OAuth2 and stores tokens locally.
14
11
  * If valid tokens already exist, shows an error message.
15
- */ export async function loginCommand(args) {
16
- const { showNextSteps } = args || {
17
- showNextSteps: false
18
- };
19
- const env = getEnvironment();
20
- const tokenStore = getTokenStore(env);
12
+ */ export async function loginCommand() {
13
+ const tokenStore = new TokenStore();
21
14
  // Check for existing valid tokens
22
15
  try {
23
16
  const existingToken = await getValidAccessToken(tokenStore);
24
17
  if (existingToken) {
25
18
  const tokens = tokenStore.getTokens();
26
- p.log.warn(pc.yellow(`Already logged in${formatEnvSuffix(env)}`));
19
+ p.log.warn(pc.yellow('Already logged in'));
27
20
  if (tokens?.userId) {
28
21
  log.info(`User ID: ${tokens.userId}`);
29
22
  }
@@ -37,39 +30,28 @@ import * as log from '../utils/log.js';
37
30
  }
38
31
  // Start OAuth flow
39
32
  await handleAuthentication({
40
- showNextSteps,
41
33
  tokenStore
42
34
  });
43
35
  }
44
36
  /**
45
37
  * Handle authentication flow
46
- */ async function handleAuthentication({ showNextSteps, tokenStore }) {
38
+ */ async function handleAuthentication({ tokenStore }) {
47
39
  try {
48
40
  // Execute OAuth flow
49
- const oauthConfig = getOAuthConfig();
50
41
  const result = await executeOAuthFlow(tokenStore, {
51
- clientId: oauthConfig.clientId,
52
- redirectUri: oauthConfig.redirectUri,
53
- scopes: oauthConfig.scopes
42
+ clientId: OAUTH_CONFIG.clientId,
43
+ redirectUri: OAUTH_CONFIG.redirectUri,
44
+ scopes: OAUTH_CONFIG.scopes
54
45
  });
55
- const env = getEnvironment();
56
- p.log.success(pc.green(`✓ Logged in${formatEnvSuffix(env)}`));
46
+ p.log.success(pc.green('✓ You are now authenticated with Figma'));
57
47
  if (result.userId) {
58
48
  log.debug(`User ID: ${result.userId}`);
59
49
  }
60
50
  log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`);
61
- // Show next steps unless disabled
62
- if (showNextSteps !== false) {
63
- p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps');
64
- }
51
+ // Show next steps
52
+ p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps');
65
53
  } catch (error) {
66
54
  if (error instanceof OAuthFlowError) {
67
- const isTimeout = error.cause instanceof CallbackError && error.cause.code === 'timeout';
68
- if (isTimeout) {
69
- p.log.error(pc.red('✗ Authentication timed out.'));
70
- p.note(`Run ${pc.cyan('@payloadcms/figma login')} to try again.`, 'Tip');
71
- process.exit(1);
72
- }
73
55
  log.error(error.message);
74
56
  if (error.cause) {
75
57
  log.debug(`Cause: ${error.cause.message}`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/login.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport type { TokenStore } from '../auth/token-store.js'\n\nimport { CallbackError } from '../auth/callback-server.js'\nimport { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js'\nimport { getTokenStore } from '../auth/token-store.js'\nimport { getOAuthConfig } from '../config/oauth.js'\nimport { getEnvironment } from '../constants.js'\nimport { formatEnvSuffix } from '../utils/format-env-suffix.js'\nimport * as log from '../utils/log.js'\n\ntype LoginArgs = {\n /** Set this to show next steps after login\n * @default true\n */\n showNextSteps: boolean\n}\n\n/**\n * Handle the `@payloadcms/figma login` command\n *\n * Authenticates the user with Figma OAuth2 and stores tokens locally.\n * If valid tokens already exist, shows an error message.\n */\nexport async function loginCommand(args?: LoginArgs): Promise<void> {\n const { showNextSteps } = args || { showNextSteps: false }\n const env = getEnvironment()\n const tokenStore = getTokenStore(env)\n\n // Check for existing valid tokens\n try {\n const existingToken = await getValidAccessToken(tokenStore)\n if (existingToken) {\n const tokens = tokenStore.getTokens()\n p.log.warn(pc.yellow(`Already logged in${formatEnvSuffix(env)}`))\n if (tokens?.userId) {\n log.info(`User ID: ${tokens.userId}`)\n }\n log.info(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n p.note(`To re-authenticate, first run ${pc.cyan('@payloadcms/figma logout')}`, 'Tip')\n return\n }\n } catch {\n // Token refresh failed - continue with new auth flow\n log.warning('Existing tokens are invalid. Starting new authentication...')\n }\n\n // Start OAuth flow\n await handleAuthentication({\n showNextSteps,\n tokenStore,\n })\n}\n\n/**\n * Handle authentication flow\n */\nasync function handleAuthentication({\n showNextSteps,\n tokenStore,\n}: {\n showNextSteps: boolean\n tokenStore: TokenStore\n}): Promise<void> {\n try {\n // Execute OAuth flow\n const oauthConfig = getOAuthConfig()\n const result = await executeOAuthFlow(tokenStore, {\n clientId: oauthConfig.clientId,\n redirectUri: oauthConfig.redirectUri,\n scopes: oauthConfig.scopes,\n })\n\n const env = getEnvironment()\n p.log.success(pc.green(`✓ Logged in${formatEnvSuffix(env)}`))\n\n if (result.userId) {\n log.debug(`User ID: ${result.userId}`)\n }\n\n log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n\n // Show next steps unless disabled\n if (showNextSteps !== false) {\n p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps')\n }\n } catch (error) {\n if (error instanceof OAuthFlowError) {\n const isTimeout = error.cause instanceof CallbackError && error.cause.code === 'timeout'\n\n if (isTimeout) {\n p.log.error(pc.red('✗ Authentication timed out.'))\n p.note(`Run ${pc.cyan('@payloadcms/figma login')} to try again.`, 'Tip')\n process.exit(1)\n }\n\n log.error(error.message)\n\n if (error.cause) {\n log.debug(`Cause: ${error.cause.message}`)\n }\n } else {\n log.error(error instanceof Error ? error.message : 'Unknown error')\n }\n\n process.exit(1)\n }\n}\n"],"names":["p","pc","CallbackError","executeOAuthFlow","getValidAccessToken","OAuthFlowError","getTokenStore","getOAuthConfig","getEnvironment","formatEnvSuffix","log","loginCommand","args","showNextSteps","env","tokenStore","existingToken","tokens","getTokens","warn","yellow","userId","info","dim","getStoragePath","note","cyan","warning","handleAuthentication","oauthConfig","result","clientId","redirectUri","scopes","success","green","debug","error","isTimeout","cause","code","red","process","exit","message","Error"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAI3B,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SAASC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,QAAQ,wBAAuB;AAC7F,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,cAAc,QAAQ,kBAAiB;AAChD,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,YAAYC,SAAS,kBAAiB;AAStC;;;;;CAKC,GACD,OAAO,eAAeC,aAAaC,IAAgB;IACjD,MAAM,EAAEC,aAAa,EAAE,GAAGD,QAAQ;QAAEC,eAAe;IAAM;IACzD,MAAMC,MAAMN;IACZ,MAAMO,aAAaT,cAAcQ;IAEjC,kCAAkC;IAClC,IAAI;QACF,MAAME,gBAAgB,MAAMZ,oBAAoBW;QAChD,IAAIC,eAAe;YACjB,MAAMC,SAASF,WAAWG,SAAS;YACnClB,EAAEU,GAAG,CAACS,IAAI,CAAClB,GAAGmB,MAAM,CAAC,CAAC,iBAAiB,EAAEX,gBAAgBK,MAAM;YAC/D,IAAIG,QAAQI,QAAQ;gBAClBX,IAAIY,IAAI,CAAC,CAAC,SAAS,EAAEL,OAAOI,MAAM,EAAE;YACtC;YACAX,IAAIY,IAAI,CAAC,CAAC,eAAe,EAAErB,GAAGsB,GAAG,CAACR,WAAWS,cAAc,KAAK;YAChExB,EAAEyB,IAAI,CAAC,CAAC,8BAA8B,EAAExB,GAAGyB,IAAI,CAAC,6BAA6B,EAAE;YAC/E;QACF;IACF,EAAE,OAAM;QACN,qDAAqD;QACrDhB,IAAIiB,OAAO,CAAC;IACd;IAEA,mBAAmB;IACnB,MAAMC,qBAAqB;QACzBf;QACAE;IACF;AACF;AAEA;;CAEC,GACD,eAAea,qBAAqB,EAClCf,aAAa,EACbE,UAAU,EAIX;IACC,IAAI;QACF,qBAAqB;QACrB,MAAMc,cAActB;QACpB,MAAMuB,SAAS,MAAM3B,iBAAiBY,YAAY;YAChDgB,UAAUF,YAAYE,QAAQ;YAC9BC,aAAaH,YAAYG,WAAW;YACpCC,QAAQJ,YAAYI,MAAM;QAC5B;QAEA,MAAMnB,MAAMN;QACZR,EAAEU,GAAG,CAACwB,OAAO,CAACjC,GAAGkC,KAAK,CAAC,CAAC,WAAW,EAAE1B,gBAAgBK,MAAM;QAE3D,IAAIgB,OAAOT,MAAM,EAAE;YACjBX,IAAI0B,KAAK,CAAC,CAAC,SAAS,EAAEN,OAAOT,MAAM,EAAE;QACvC;QAEAX,IAAI0B,KAAK,CAAC,CAAC,eAAe,EAAEnC,GAAGsB,GAAG,CAACR,WAAWS,cAAc,KAAK;QAEjE,kCAAkC;QAClC,IAAIX,kBAAkB,OAAO;YAC3Bb,EAAEyB,IAAI,CAAC,CAAC,EAAE,EAAExB,GAAGyB,IAAI,CAAC,0BAA0B,2BAA2B,CAAC,EAAE;QAC9E;IACF,EAAE,OAAOW,OAAO;QACd,IAAIA,iBAAiBhC,gBAAgB;YACnC,MAAMiC,YAAYD,MAAME,KAAK,YAAYrC,iBAAiBmC,MAAME,KAAK,CAACC,IAAI,KAAK;YAE/E,IAAIF,WAAW;gBACbtC,EAAEU,GAAG,CAAC2B,KAAK,CAACpC,GAAGwC,GAAG,CAAC;gBACnBzC,EAAEyB,IAAI,CAAC,CAAC,IAAI,EAAExB,GAAGyB,IAAI,CAAC,2BAA2B,cAAc,CAAC,EAAE;gBAClEgB,QAAQC,IAAI,CAAC;YACf;YAEAjC,IAAI2B,KAAK,CAACA,MAAMO,OAAO;YAEvB,IAAIP,MAAME,KAAK,EAAE;gBACf7B,IAAI0B,KAAK,CAAC,CAAC,OAAO,EAAEC,MAAME,KAAK,CAACK,OAAO,EAAE;YAC3C;QACF,OAAO;YACLlC,IAAI2B,KAAK,CAACA,iBAAiBQ,QAAQR,MAAMO,OAAO,GAAG;QACrD;QAEAF,QAAQC,IAAI,CAAC;IACf;AACF"}
1
+ {"version":3,"sources":["../../src/commands/login.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { OAUTH_CONFIG } from '../config/oauth.js'\nimport * as log from '../utils/log.js'\n\n/**\n * Handle the `@payloadcms/figma login` command\n *\n * Authenticates the user with Figma OAuth2 and stores tokens locally.\n * If valid tokens already exist, shows an error message.\n */\nexport async function loginCommand(): Promise<void> {\n const tokenStore = new TokenStore()\n\n // Check for existing valid tokens\n try {\n const existingToken = await getValidAccessToken(tokenStore)\n if (existingToken) {\n const tokens = tokenStore.getTokens()\n p.log.warn(pc.yellow('Already logged in'))\n if (tokens?.userId) {\n log.info(`User ID: ${tokens.userId}`)\n }\n log.info(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n p.note(`To re-authenticate, first run ${pc.cyan('@payloadcms/figma logout')}`, 'Tip')\n return\n }\n } catch {\n // Token refresh failed - continue with new auth flow\n log.warning('Existing tokens are invalid. Starting new authentication...')\n }\n\n // Start OAuth flow\n await handleAuthentication({\n tokenStore,\n })\n}\n\n/**\n * Handle authentication flow\n */\nasync function handleAuthentication({ tokenStore }: { tokenStore: TokenStore }): Promise<void> {\n try {\n // Execute OAuth flow\n const result = await executeOAuthFlow(tokenStore, {\n clientId: OAUTH_CONFIG.clientId,\n redirectUri: OAUTH_CONFIG.redirectUri,\n scopes: OAUTH_CONFIG.scopes,\n })\n\n p.log.success(pc.green('✓ You are now authenticated with Figma'))\n\n if (result.userId) {\n log.debug(`User ID: ${result.userId}`)\n }\n\n log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n\n // Show next steps\n p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps')\n } catch (error) {\n if (error instanceof OAuthFlowError) {\n log.error(error.message)\n\n if (error.cause) {\n log.debug(`Cause: ${error.cause.message}`)\n }\n } else {\n log.error(error instanceof Error ? error.message : 'Unknown error')\n }\n\n process.exit(1)\n }\n}\n"],"names":["p","pc","executeOAuthFlow","getValidAccessToken","OAuthFlowError","TokenStore","OAUTH_CONFIG","log","loginCommand","tokenStore","existingToken","tokens","getTokens","warn","yellow","userId","info","dim","getStoragePath","note","cyan","warning","handleAuthentication","result","clientId","redirectUri","scopes","success","green","debug","error","message","cause","Error","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAE3B,SAASC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,QAAQ,wBAAuB;AAC7F,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,YAAY,QAAQ,qBAAoB;AACjD,YAAYC,SAAS,kBAAiB;AAEtC;;;;;CAKC,GACD,OAAO,eAAeC;IACpB,MAAMC,aAAa,IAAIJ;IAEvB,kCAAkC;IAClC,IAAI;QACF,MAAMK,gBAAgB,MAAMP,oBAAoBM;QAChD,IAAIC,eAAe;YACjB,MAAMC,SAASF,WAAWG,SAAS;YACnCZ,EAAEO,GAAG,CAACM,IAAI,CAACZ,GAAGa,MAAM,CAAC;YACrB,IAAIH,QAAQI,QAAQ;gBAClBR,IAAIS,IAAI,CAAC,CAAC,SAAS,EAAEL,OAAOI,MAAM,EAAE;YACtC;YACAR,IAAIS,IAAI,CAAC,CAAC,eAAe,EAAEf,GAAGgB,GAAG,CAACR,WAAWS,cAAc,KAAK;YAChElB,EAAEmB,IAAI,CAAC,CAAC,8BAA8B,EAAElB,GAAGmB,IAAI,CAAC,6BAA6B,EAAE;YAC/E;QACF;IACF,EAAE,OAAM;QACN,qDAAqD;QACrDb,IAAIc,OAAO,CAAC;IACd;IAEA,mBAAmB;IACnB,MAAMC,qBAAqB;QACzBb;IACF;AACF;AAEA;;CAEC,GACD,eAAea,qBAAqB,EAAEb,UAAU,EAA8B;IAC5E,IAAI;QACF,qBAAqB;QACrB,MAAMc,SAAS,MAAMrB,iBAAiBO,YAAY;YAChDe,UAAUlB,aAAakB,QAAQ;YAC/BC,aAAanB,aAAamB,WAAW;YACrCC,QAAQpB,aAAaoB,MAAM;QAC7B;QAEA1B,EAAEO,GAAG,CAACoB,OAAO,CAAC1B,GAAG2B,KAAK,CAAC;QAEvB,IAAIL,OAAOR,MAAM,EAAE;YACjBR,IAAIsB,KAAK,CAAC,CAAC,SAAS,EAAEN,OAAOR,MAAM,EAAE;QACvC;QAEAR,IAAIsB,KAAK,CAAC,CAAC,eAAe,EAAE5B,GAAGgB,GAAG,CAACR,WAAWS,cAAc,KAAK;QAEjE,kBAAkB;QAClBlB,EAAEmB,IAAI,CAAC,CAAC,EAAE,EAAElB,GAAGmB,IAAI,CAAC,0BAA0B,2BAA2B,CAAC,EAAE;IAC9E,EAAE,OAAOU,OAAO;QACd,IAAIA,iBAAiB1B,gBAAgB;YACnCG,IAAIuB,KAAK,CAACA,MAAMC,OAAO;YAEvB,IAAID,MAAME,KAAK,EAAE;gBACfzB,IAAIsB,KAAK,CAAC,CAAC,OAAO,EAAEC,MAAME,KAAK,CAACD,OAAO,EAAE;YAC3C;QACF,OAAO;YACLxB,IAAIuB,KAAK,CAACA,iBAAiBG,QAAQH,MAAMC,OAAO,GAAG;QACrD;QAEAG,QAAQC,IAAI,CAAC;IACf;AACF"}
@@ -2,16 +2,15 @@
2
2
  * Options for logout command
3
3
  */
4
4
  export interface LogoutCommandOptions {
5
- /** Logout from all environments */
6
- all?: boolean;
7
5
  /** Enable debug mode */
8
6
  debug?: boolean;
9
7
  }
10
8
  /**
11
9
  * Handle the `@payloadcms/figma logout` command
12
10
  *
13
- * Clears stored tokens (OAuth and project tokens) after confirmation.
14
- * By default clears only current environment. Use --all for all environments.
11
+ * Clears all stored tokens (OAuth and project tokens) after confirmation.
12
+ *
13
+ * @param _options - Command options (unused)
15
14
  */
16
- export declare function logoutCommand(options?: LogoutCommandOptions): Promise<void>;
15
+ export declare function logoutCommand(_options?: LogoutCommandOptions): Promise<void>;
17
16
  //# sourceMappingURL=logout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,wBAAwB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAID;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQrF"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wBAAwB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,QAAQ,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCtF"}
@@ -1,36 +1,24 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
- import { getTokenStore } from '../auth/token-store.js';
4
- import { getEnvironment } from '../constants.js';
5
- import { formatEnvSuffix } from '../utils/format-env-suffix.js';
3
+ import { TokenStore } from '../auth/token-store.js';
6
4
  import * as log from '../utils/log.js';
7
- const ALL_ENVIRONMENTS = [
8
- 'production',
9
- 'staging'
10
- ];
11
5
  /**
12
6
  * Handle the `@payloadcms/figma logout` command
13
7
  *
14
- * Clears stored tokens (OAuth and project tokens) after confirmation.
15
- * By default clears only current environment. Use --all for all environments.
16
- */ export async function logoutCommand(options = {}) {
17
- const currentEnv = getEnvironment();
18
- if (options.all) {
19
- await logoutAllEnvironments();
20
- } else {
21
- await logoutSingleEnvironment(currentEnv);
22
- }
23
- }
24
- async function logoutSingleEnvironment(env) {
25
- const tokenStore = getTokenStore(env);
8
+ * Clears all stored tokens (OAuth and project tokens) after confirmation.
9
+ *
10
+ * @param _options - Command options (unused)
11
+ */ export async function logoutCommand(_options = {}) {
12
+ const tokenStore = new TokenStore();
26
13
  const hasTokens = tokenStore.getTokens() !== null;
27
14
  if (!hasTokens) {
28
- p.log.warn(pc.yellow(`No tokens found${formatEnvSuffix(env, ' for ')}. Already logged out.`));
15
+ p.log.warn(pc.yellow('No tokens found. Already logged out.'));
29
16
  return;
30
17
  }
18
+ // Confirm logout
31
19
  const confirmed = await p.confirm({
32
20
  initialValue: false,
33
- message: `This will clear all OAuth and project tokens${formatEnvSuffix(env, ' for ')}. Continue?`
21
+ message: 'This will clear all OAuth and project tokens. Continue?'
34
22
  });
35
23
  if (p.isCancel(confirmed) || !confirmed) {
36
24
  p.log.info('Logout cancelled');
@@ -39,43 +27,12 @@ async function logoutSingleEnvironment(env) {
39
27
  const s = p.spinner();
40
28
  s.start('Clearing tokens...');
41
29
  try {
30
+ // Clear OAuth tokens
42
31
  tokenStore.clearTokens();
32
+ // Clear all project tokens
43
33
  tokenStore.clearAllProjectTokens();
44
- s.stop(pc.green(`✓ Logged out${formatEnvSuffix(env, ' from ')}`));
45
- } catch (error) {
46
- s.stop(pc.red('✗ Failed to clear tokens'));
47
- log.error(error instanceof Error ? error.message : 'Unknown error');
48
- process.exit(1);
49
- }
50
- }
51
- async function logoutAllEnvironments() {
52
- // Check which environments have tokens
53
- const envsWithTokens = ALL_ENVIRONMENTS.filter((env)=>{
54
- const store = getTokenStore(env);
55
- return store.getTokens() !== null;
56
- });
57
- if (envsWithTokens.length === 0) {
58
- p.log.warn(pc.yellow('No tokens found in any environment. Already logged out.'));
59
- return;
60
- }
61
- const envList = envsWithTokens.join(' and ');
62
- const confirmed = await p.confirm({
63
- initialValue: false,
64
- message: `This will clear all OAuth and project tokens for ${envList}. Continue?`
65
- });
66
- if (p.isCancel(confirmed) || !confirmed) {
67
- p.log.info('Logout cancelled');
68
- return;
69
- }
70
- const s = p.spinner();
71
- s.start('Clearing tokens...');
72
- try {
73
- for (const env of envsWithTokens){
74
- const store = getTokenStore(env);
75
- store.clearTokens();
76
- store.clearAllProjectTokens();
77
- }
78
- s.stop(pc.green('✓ Logged out from all environments'));
34
+ s.stop(pc.green('✓ Logged out successfully'));
35
+ p.log.step('All OAuth and project tokens have been cleared');
79
36
  } catch (error) {
80
37
  s.stop(pc.red('✗ Failed to clear tokens'));
81
38
  log.error(error instanceof Error ? error.message : 'Unknown error');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/logout.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport type { Environment } from '../constants.js'\n\nimport { getTokenStore } from '../auth/token-store.js'\nimport { getEnvironment } from '../constants.js'\nimport { formatEnvSuffix } from '../utils/format-env-suffix.js'\nimport * as log from '../utils/log.js'\n\n/**\n * Options for logout command\n */\nexport interface LogoutCommandOptions {\n /** Logout from all environments */\n all?: boolean\n /** Enable debug mode */\n debug?: boolean\n}\n\nconst ALL_ENVIRONMENTS: Environment[] = ['production', 'staging']\n\n/**\n * Handle the `@payloadcms/figma logout` command\n *\n * Clears stored tokens (OAuth and project tokens) after confirmation.\n * By default clears only current environment. Use --all for all environments.\n */\nexport async function logoutCommand(options: LogoutCommandOptions = {}): Promise<void> {\n const currentEnv = getEnvironment()\n\n if (options.all) {\n await logoutAllEnvironments()\n } else {\n await logoutSingleEnvironment(currentEnv)\n }\n}\n\nasync function logoutSingleEnvironment(env: Environment): Promise<void> {\n const tokenStore = getTokenStore(env)\n const hasTokens = tokenStore.getTokens() !== null\n\n if (!hasTokens) {\n p.log.warn(pc.yellow(`No tokens found${formatEnvSuffix(env, ' for ')}. Already logged out.`))\n return\n }\n\n const confirmed = await p.confirm({\n initialValue: false,\n message: `This will clear all OAuth and project tokens${formatEnvSuffix(env, ' for ')}. Continue?`,\n })\n\n if (p.isCancel(confirmed) || !confirmed) {\n p.log.info('Logout cancelled')\n return\n }\n\n const s = p.spinner()\n s.start('Clearing tokens...')\n\n try {\n tokenStore.clearTokens()\n tokenStore.clearAllProjectTokens()\n s.stop(pc.green(`✓ Logged out${formatEnvSuffix(env, ' from ')}`))\n } catch (error) {\n s.stop(pc.red('✗ Failed to clear tokens'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n process.exit(1)\n }\n}\n\nasync function logoutAllEnvironments(): Promise<void> {\n // Check which environments have tokens\n const envsWithTokens = ALL_ENVIRONMENTS.filter((env) => {\n const store = getTokenStore(env)\n return store.getTokens() !== null\n })\n\n if (envsWithTokens.length === 0) {\n p.log.warn(pc.yellow('No tokens found in any environment. Already logged out.'))\n return\n }\n\n const envList = envsWithTokens.join(' and ')\n const confirmed = await p.confirm({\n initialValue: false,\n message: `This will clear all OAuth and project tokens for ${envList}. Continue?`,\n })\n\n if (p.isCancel(confirmed) || !confirmed) {\n p.log.info('Logout cancelled')\n return\n }\n\n const s = p.spinner()\n s.start('Clearing tokens...')\n\n try {\n for (const env of envsWithTokens) {\n const store = getTokenStore(env)\n store.clearTokens()\n store.clearAllProjectTokens()\n }\n s.stop(pc.green('✓ Logged out from all environments'))\n } catch (error) {\n s.stop(pc.red('✗ Failed to clear tokens'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n process.exit(1)\n }\n}\n"],"names":["p","pc","getTokenStore","getEnvironment","formatEnvSuffix","log","ALL_ENVIRONMENTS","logoutCommand","options","currentEnv","all","logoutAllEnvironments","logoutSingleEnvironment","env","tokenStore","hasTokens","getTokens","warn","yellow","confirmed","confirm","initialValue","message","isCancel","info","s","spinner","start","clearTokens","clearAllProjectTokens","stop","green","error","red","Error","process","exit","envsWithTokens","filter","store","length","envList","join"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAI3B,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,cAAc,QAAQ,kBAAiB;AAChD,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,YAAYC,SAAS,kBAAiB;AAYtC,MAAMC,mBAAkC;IAAC;IAAc;CAAU;AAEjE;;;;;CAKC,GACD,OAAO,eAAeC,cAAcC,UAAgC,CAAC,CAAC;IACpE,MAAMC,aAAaN;IAEnB,IAAIK,QAAQE,GAAG,EAAE;QACf,MAAMC;IACR,OAAO;QACL,MAAMC,wBAAwBH;IAChC;AACF;AAEA,eAAeG,wBAAwBC,GAAgB;IACrD,MAAMC,aAAaZ,cAAcW;IACjC,MAAME,YAAYD,WAAWE,SAAS,OAAO;IAE7C,IAAI,CAACD,WAAW;QACdf,EAAEK,GAAG,CAACY,IAAI,CAAChB,GAAGiB,MAAM,CAAC,CAAC,eAAe,EAAEd,gBAAgBS,KAAK,SAAS,qBAAqB,CAAC;QAC3F;IACF;IAEA,MAAMM,YAAY,MAAMnB,EAAEoB,OAAO,CAAC;QAChCC,cAAc;QACdC,SAAS,CAAC,4CAA4C,EAAElB,gBAAgBS,KAAK,SAAS,WAAW,CAAC;IACpG;IAEA,IAAIb,EAAEuB,QAAQ,CAACJ,cAAc,CAACA,WAAW;QACvCnB,EAAEK,GAAG,CAACmB,IAAI,CAAC;QACX;IACF;IAEA,MAAMC,IAAIzB,EAAE0B,OAAO;IACnBD,EAAEE,KAAK,CAAC;IAER,IAAI;QACFb,WAAWc,WAAW;QACtBd,WAAWe,qBAAqB;QAChCJ,EAAEK,IAAI,CAAC7B,GAAG8B,KAAK,CAAC,CAAC,YAAY,EAAE3B,gBAAgBS,KAAK,WAAW;IACjE,EAAE,OAAOmB,OAAO;QACdP,EAAEK,IAAI,CAAC7B,GAAGgC,GAAG,CAAC;QACd5B,IAAI2B,KAAK,CAACA,iBAAiBE,QAAQF,MAAMV,OAAO,GAAG;QACnDa,QAAQC,IAAI,CAAC;IACf;AACF;AAEA,eAAezB;IACb,uCAAuC;IACvC,MAAM0B,iBAAiB/B,iBAAiBgC,MAAM,CAAC,CAACzB;QAC9C,MAAM0B,QAAQrC,cAAcW;QAC5B,OAAO0B,MAAMvB,SAAS,OAAO;IAC/B;IAEA,IAAIqB,eAAeG,MAAM,KAAK,GAAG;QAC/BxC,EAAEK,GAAG,CAACY,IAAI,CAAChB,GAAGiB,MAAM,CAAC;QACrB;IACF;IAEA,MAAMuB,UAAUJ,eAAeK,IAAI,CAAC;IACpC,MAAMvB,YAAY,MAAMnB,EAAEoB,OAAO,CAAC;QAChCC,cAAc;QACdC,SAAS,CAAC,iDAAiD,EAAEmB,QAAQ,WAAW,CAAC;IACnF;IAEA,IAAIzC,EAAEuB,QAAQ,CAACJ,cAAc,CAACA,WAAW;QACvCnB,EAAEK,GAAG,CAACmB,IAAI,CAAC;QACX;IACF;IAEA,MAAMC,IAAIzB,EAAE0B,OAAO;IACnBD,EAAEE,KAAK,CAAC;IAER,IAAI;QACF,KAAK,MAAMd,OAAOwB,eAAgB;YAChC,MAAME,QAAQrC,cAAcW;YAC5B0B,MAAMX,WAAW;YACjBW,MAAMV,qBAAqB;QAC7B;QACAJ,EAAEK,IAAI,CAAC7B,GAAG8B,KAAK,CAAC;IAClB,EAAE,OAAOC,OAAO;QACdP,EAAEK,IAAI,CAAC7B,GAAGgC,GAAG,CAAC;QACd5B,IAAI2B,KAAK,CAACA,iBAAiBE,QAAQF,MAAMV,OAAO,GAAG;QACnDa,QAAQC,IAAI,CAAC;IACf;AACF"}
1
+ {"version":3,"sources":["../../src/commands/logout.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport { TokenStore } from '../auth/token-store.js'\nimport * as log from '../utils/log.js'\n\n/**\n * Options for logout command\n */\nexport interface LogoutCommandOptions {\n /** Enable debug mode */\n debug?: boolean\n}\n\n/**\n * Handle the `@payloadcms/figma logout` command\n *\n * Clears all stored tokens (OAuth and project tokens) after confirmation.\n *\n * @param _options - Command options (unused)\n */\nexport async function logoutCommand(_options: LogoutCommandOptions = {}): Promise<void> {\n const tokenStore = new TokenStore()\n\n const hasTokens = tokenStore.getTokens() !== null\n\n if (!hasTokens) {\n p.log.warn(pc.yellow('No tokens found. Already logged out.'))\n return\n }\n\n // Confirm logout\n const confirmed = await p.confirm({\n initialValue: false,\n message: 'This will clear all OAuth and project tokens. Continue?',\n })\n\n if (p.isCancel(confirmed) || !confirmed) {\n p.log.info('Logout cancelled')\n return\n }\n\n const s = p.spinner()\n s.start('Clearing tokens...')\n\n try {\n // Clear OAuth tokens\n tokenStore.clearTokens()\n // Clear all project tokens\n tokenStore.clearAllProjectTokens()\n s.stop(pc.green(' Logged out successfully'))\n p.log.step('All OAuth and project tokens have been cleared')\n } catch (error) {\n s.stop(pc.red('✗ Failed to clear tokens'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n process.exit(1)\n }\n}\n"],"names":["p","pc","TokenStore","log","logoutCommand","_options","tokenStore","hasTokens","getTokens","warn","yellow","confirmed","confirm","initialValue","message","isCancel","info","s","spinner","start","clearTokens","clearAllProjectTokens","stop","green","step","error","red","Error","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAE3B,SAASC,UAAU,QAAQ,yBAAwB;AACnD,YAAYC,SAAS,kBAAiB;AAUtC;;;;;;CAMC,GACD,OAAO,eAAeC,cAAcC,WAAiC,CAAC,CAAC;IACrE,MAAMC,aAAa,IAAIJ;IAEvB,MAAMK,YAAYD,WAAWE,SAAS,OAAO;IAE7C,IAAI,CAACD,WAAW;QACdP,EAAEG,GAAG,CAACM,IAAI,CAACR,GAAGS,MAAM,CAAC;QACrB;IACF;IAEA,iBAAiB;IACjB,MAAMC,YAAY,MAAMX,EAAEY,OAAO,CAAC;QAChCC,cAAc;QACdC,SAAS;IACX;IAEA,IAAId,EAAEe,QAAQ,CAACJ,cAAc,CAACA,WAAW;QACvCX,EAAEG,GAAG,CAACa,IAAI,CAAC;QACX;IACF;IAEA,MAAMC,IAAIjB,EAAEkB,OAAO;IACnBD,EAAEE,KAAK,CAAC;IAER,IAAI;QACF,qBAAqB;QACrBb,WAAWc,WAAW;QACtB,2BAA2B;QAC3Bd,WAAWe,qBAAqB;QAChCJ,EAAEK,IAAI,CAACrB,GAAGsB,KAAK,CAAC;QAChBvB,EAAEG,GAAG,CAACqB,IAAI,CAAC;IACb,EAAE,OAAOC,OAAO;QACdR,EAAEK,IAAI,CAACrB,GAAGyB,GAAG,CAAC;QACdvB,IAAIsB,KAAK,CAACA,iBAAiBE,QAAQF,MAAMX,OAAO,GAAG;QACnDc,QAAQC,IAAI,CAAC;IACf;AACF"}
@@ -1,9 +1,19 @@
1
1
  import type { OAuthConfig } from '../auth/types.js';
2
- export declare const DEFAULT_CALLBACK_PORT = 34462;
2
+ export declare const URLS: Record<'prod' | 'staging', Pick<OAuthConfig, 'authorizationUrl' | 'refreshUrl' | 'tokenUrl'>>;
3
3
  /**
4
- * Get OAuth configuration for current environment
5
- * Uses getEnvironment() to determine staging vs production
4
+ * Figma OAuth2 configuration for public CLI client
5
+ *
6
+ * This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).
7
+ * No client secret is used because CLIs cannot securely store secrets.
8
+ * PKCE provides security through the code_verifier/code_challenge mechanism.
9
+ *
10
+ * For production use, register a public OAuth app with Figma.
11
+ * To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2
12
+ */
13
+ export declare const OAUTH_CONFIG: OAuthConfig;
14
+ /**
15
+ * Buffer time (in seconds) before token expiration to consider token as expired
16
+ * This helps avoid using tokens that are about to expire
6
17
  */
7
- export declare function getOAuthConfig(): OAuthConfig;
8
18
  export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
9
19
  //# sourceMappingURL=oauth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/config/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,eAAO,MAAM,qBAAqB,QAAQ,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAa5C;AAED,eAAO,MAAM,2BAA2B,MAAM,CAAA"}
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/config/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,eAAO,MAAM,IAAI,EAAE,MAAM,CACvB,MAAM,GAAG,SAAS,EAClB,IAAI,CAAC,WAAW,EAAE,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAAC,CAYlE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,WAe1B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAA"}
@@ -1,22 +1,43 @@
1
- import { ENV_CONFIG, getEnvironment } from '../constants.js';
2
- export const DEFAULT_CALLBACK_PORT = 34462;
1
+ import { FIGMA_CLIENT_IDS } from '../constants.js';
2
+ export const URLS = {
3
+ prod: {
4
+ authorizationUrl: 'https://www.figma.com/oauth',
5
+ refreshUrl: 'https://api.figma.com/v1/oauth/refresh',
6
+ tokenUrl: 'https://api.figma.com/v1/oauth/token'
7
+ },
8
+ staging: {
9
+ authorizationUrl: 'https://staging.figma.com/oauth',
10
+ refreshUrl: 'https://api.staging.figma.com/v1/oauth/refresh',
11
+ tokenUrl: 'https://api.staging.figma.com/v1/oauth/token'
12
+ }
13
+ };
3
14
  /**
4
- * Get OAuth configuration for current environment
5
- * Uses getEnvironment() to determine staging vs production
6
- */ export function getOAuthConfig() {
7
- const env = getEnvironment();
8
- const { apiBaseUrl, authorizationUrl, clientId } = ENV_CONFIG[env];
9
- return {
10
- authorizationUrl,
11
- clientId: process.env.FIGMA_CLIENT_ID || clientId,
12
- redirectUri: process.env.FIGMA_REDIRECT_URI || `http://localhost:${DEFAULT_CALLBACK_PORT}/callback`,
13
- refreshUrl: `${apiBaseUrl}/v1/oauth/refresh`,
14
- scopes: [
15
- 'current_user:read'
16
- ],
17
- tokenUrl: `${apiBaseUrl}/v1/oauth/token`
18
- };
19
- }
20
- export const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
15
+ * Figma OAuth2 configuration for public CLI client
16
+ *
17
+ * This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).
18
+ * No client secret is used because CLIs cannot securely store secrets.
19
+ * PKCE provides security through the code_verifier/code_challenge mechanism.
20
+ *
21
+ * For production use, register a public OAuth app with Figma.
22
+ * To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2
23
+ */ export const OAUTH_CONFIG = {
24
+ // OAuth client ID (public client)
25
+ // Uses staging client ID by default since we use staging endpoints
26
+ clientId: process.env.FIGMA_CLIENT_ID || FIGMA_CLIENT_IDS.staging,
27
+ // No client secret - this is a public OAuth client using PKCE
28
+ // Public clients cannot securely store secrets in CLI environments
29
+ redirectUri: process.env.FIGMA_REDIRECT_URI || 'http://localhost:3000/callback',
30
+ // Only current_user:read scope is needed for basic user info
31
+ scopes: [
32
+ 'current_user:read'
33
+ ],
34
+ // TODO: Dynamically choose between prod and staging based on environment
35
+ ...URLS.staging
36
+ };
37
+ /**
38
+ * Buffer time (in seconds) before token expiration to consider token as expired
39
+ * This helps avoid using tokens that are about to expire
40
+ */ export const TOKEN_EXPIRY_BUFFER_SECONDS = 300 // 5 minutes
41
+ ;
21
42
 
22
43
  //# sourceMappingURL=oauth.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/oauth.ts"],"sourcesContent":["import type { OAuthConfig } from '../auth/types.js'\n\nimport { ENV_CONFIG, getEnvironment } from '../constants.js'\n\nexport const DEFAULT_CALLBACK_PORT = 34462\n\n/**\n * Get OAuth configuration for current environment\n * Uses getEnvironment() to determine staging vs production\n */\nexport function getOAuthConfig(): OAuthConfig {\n const env = getEnvironment()\n const { apiBaseUrl, authorizationUrl, clientId } = ENV_CONFIG[env]\n\n return {\n authorizationUrl,\n clientId: process.env.FIGMA_CLIENT_ID || clientId,\n redirectUri:\n process.env.FIGMA_REDIRECT_URI || `http://localhost:${DEFAULT_CALLBACK_PORT}/callback`,\n refreshUrl: `${apiBaseUrl}/v1/oauth/refresh`,\n scopes: ['current_user:read'],\n tokenUrl: `${apiBaseUrl}/v1/oauth/token`,\n }\n}\n\nexport const TOKEN_EXPIRY_BUFFER_SECONDS = 300\n"],"names":["ENV_CONFIG","getEnvironment","DEFAULT_CALLBACK_PORT","getOAuthConfig","env","apiBaseUrl","authorizationUrl","clientId","process","FIGMA_CLIENT_ID","redirectUri","FIGMA_REDIRECT_URI","refreshUrl","scopes","tokenUrl","TOKEN_EXPIRY_BUFFER_SECONDS"],"mappings":"AAEA,SAASA,UAAU,EAAEC,cAAc,QAAQ,kBAAiB;AAE5D,OAAO,MAAMC,wBAAwB,MAAK;AAE1C;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMH;IACZ,MAAM,EAAEI,UAAU,EAAEC,gBAAgB,EAAEC,QAAQ,EAAE,GAAGP,UAAU,CAACI,IAAI;IAElE,OAAO;QACLE;QACAC,UAAUC,QAAQJ,GAAG,CAACK,eAAe,IAAIF;QACzCG,aACEF,QAAQJ,GAAG,CAACO,kBAAkB,IAAI,CAAC,iBAAiB,EAAET,sBAAsB,SAAS,CAAC;QACxFU,YAAY,GAAGP,WAAW,iBAAiB,CAAC;QAC5CQ,QAAQ;YAAC;SAAoB;QAC7BC,UAAU,GAAGT,WAAW,eAAe,CAAC;IAC1C;AACF;AAEA,OAAO,MAAMU,8BAA8B,IAAG"}
1
+ {"version":3,"sources":["../../src/config/oauth.ts"],"sourcesContent":["import type { OAuthConfig } from '../auth/types.js'\n\nimport { FIGMA_CLIENT_IDS } from '../constants.js'\n\nexport const URLS: Record<\n 'prod' | 'staging',\n Pick<OAuthConfig, 'authorizationUrl' | 'refreshUrl' | 'tokenUrl'>\n> = {\n prod: {\n authorizationUrl: 'https://www.figma.com/oauth',\n refreshUrl: 'https://api.figma.com/v1/oauth/refresh',\n tokenUrl: 'https://api.figma.com/v1/oauth/token',\n },\n staging: {\n authorizationUrl: 'https://staging.figma.com/oauth',\n refreshUrl: 'https://api.staging.figma.com/v1/oauth/refresh',\n tokenUrl: 'https://api.staging.figma.com/v1/oauth/token',\n },\n}\n\n/**\n * Figma OAuth2 configuration for public CLI client\n *\n * This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).\n * No client secret is used because CLIs cannot securely store secrets.\n * PKCE provides security through the code_verifier/code_challenge mechanism.\n *\n * For production use, register a public OAuth app with Figma.\n * To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2\n */\nexport const OAUTH_CONFIG: OAuthConfig = {\n // OAuth client ID (public client)\n // Uses staging client ID by default since we use staging endpoints\n clientId: process.env.FIGMA_CLIENT_ID || FIGMA_CLIENT_IDS.staging,\n\n // No client secret - this is a public OAuth client using PKCE\n // Public clients cannot securely store secrets in CLI environments\n\n redirectUri: process.env.FIGMA_REDIRECT_URI || 'http://localhost:3000/callback',\n\n // Only current_user:read scope is needed for basic user info\n scopes: ['current_user:read'],\n\n // TODO: Dynamically choose between prod and staging based on environment\n ...URLS.staging,\n}\n\n/**\n * Buffer time (in seconds) before token expiration to consider token as expired\n * This helps avoid using tokens that are about to expire\n */\nexport const TOKEN_EXPIRY_BUFFER_SECONDS = 300 // 5 minutes\n"],"names":["FIGMA_CLIENT_IDS","URLS","prod","authorizationUrl","refreshUrl","tokenUrl","staging","OAUTH_CONFIG","clientId","process","env","FIGMA_CLIENT_ID","redirectUri","FIGMA_REDIRECT_URI","scopes","TOKEN_EXPIRY_BUFFER_SECONDS"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,kBAAiB;AAElD,OAAO,MAAMC,OAGT;IACFC,MAAM;QACJC,kBAAkB;QAClBC,YAAY;QACZC,UAAU;IACZ;IACAC,SAAS;QACPH,kBAAkB;QAClBC,YAAY;QACZC,UAAU;IACZ;AACF,EAAC;AAED;;;;;;;;;CASC,GACD,OAAO,MAAME,eAA4B;IACvC,kCAAkC;IAClC,mEAAmE;IACnEC,UAAUC,QAAQC,GAAG,CAACC,eAAe,IAAIX,iBAAiBM,OAAO;IAEjE,8DAA8D;IAC9D,mEAAmE;IAEnEM,aAAaH,QAAQC,GAAG,CAACG,kBAAkB,IAAI;IAE/C,6DAA6D;IAC7DC,QAAQ;QAAC;KAAoB;IAE7B,yEAAyE;IACzE,GAAGb,KAAKK,OAAO;AACjB,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMS,8BAA8B,IAAI,YAAY;CAAb"}
@@ -1,35 +1,27 @@
1
+ export declare const FIGMA_CLIENT_IDS: {
2
+ production: string;
3
+ staging: string;
4
+ };
5
+ export declare const JWKS_URI: {
6
+ production: string;
7
+ staging: string;
8
+ };
1
9
  /**
2
10
  * Figma environment (production or staging)
3
11
  */
4
12
  export type Environment = 'production' | 'staging';
5
- type EnvironmentConfig = {
6
- /** Figma API base URL. Override: FIGMA_API_BASE_URL */
7
- apiBaseUrl: string;
8
- /** OAuth authorization URL (CLI auth) */
9
- authorizationUrl: string;
10
- /** OAuth client ID. Override: FIGMA_CLIENT_ID or FIGMA_OAUTH_CLIENT_ID */
11
- clientId: string;
12
- /** Content API base URL. Override: FIGMA_CONTENT_API_URL */
13
- contentApiUrl: string;
14
- /** OIDC discovery endpoint */
15
- identityMetadata: string;
16
- /** JSON Web Key Set URL for token validation */
17
- jwksUri: string;
18
- };
19
13
  /**
20
- * Environment-specific configuration for Figma integration.
21
- * Selected via FIGMA_ENV ('production' | 'staging'), defaults to 'production'.
14
+ * Get current Figma environment from environment variable
15
+ * Defaults to 'staging' if not specified
16
+ *
17
+ * @returns Current environment
22
18
  */
23
- export declare const ENV_CONFIG: Record<Environment, EnvironmentConfig>;
24
- /**
25
- * Set environment override (used by --env CLI flag)
26
- * Pass undefined to clear the override
27
- */
28
- export declare function setEnvironment(env: Environment | undefined): void;
19
+ export declare function getEnvironment(): Environment;
29
20
  /**
30
- * Get current Figma environment
31
- * Priority: 1) setEnvironment override, 2) FIGMA_ENV env var, 3) 'production' default
21
+ * Get JWKS URI for a given environment
22
+ *
23
+ * @param env - Environment (defaults to current environment)
24
+ * @returns JWKS URI for the environment
32
25
  */
33
- export declare function getEnvironment(): Environment;
34
- export {};
26
+ export declare function getJWKSUri(env?: Environment): string;
35
27
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;AAElD,KAAK,iBAAiB,GAAG;IACvB,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,gBAAgB,EAAE,MAAM,CAAA;IACxB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAA;IAChB,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAA;IACrB,8BAA8B;IAC9B,gBAAgB,EAAE,MAAM,CAAA;IACxB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAiB7D,CAAA;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAEjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAK5C"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA;AAED,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;AAElD;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,MAAM,CAGpD"}
package/dist/constants.js CHANGED
@@ -1,41 +1,27 @@
1
- /**
2
- * Figma environment (production or staging)
3
- */ /**
4
- * Environment-specific configuration for Figma integration.
5
- * Selected via FIGMA_ENV ('production' | 'staging'), defaults to 'production'.
6
- */ export const ENV_CONFIG = {
7
- production: {
8
- apiBaseUrl: 'https://api.figma.com',
9
- authorizationUrl: 'https://www.figma.com/oauth',
10
- clientId: 'lelKVTAzOekFnirnlAMbuD',
11
- contentApiUrl: 'https://us-east-1.cms-tenants-001-production.figmacontent.com',
12
- identityMetadata: 'https://www.figma.com/.well-known/openid-configuration',
13
- jwksUri: 'https://static.figmacontent.com/.well_known/jwks.json'
14
- },
15
- staging: {
16
- apiBaseUrl: 'https://api.staging.figma.com',
17
- authorizationUrl: 'https://staging.figma.com/oauth',
18
- clientId: 'wqAToBAp4UI9AZ5M6wTfT9',
19
- contentApiUrl: 'https://us-east-1.cms-tenants-001-staging.figmacontentstaging.com',
20
- identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',
21
- jwksUri: 'https://static.figmacontentstaging.com/.well_known/jwks.json'
22
- }
1
+ export const FIGMA_CLIENT_IDS = {
2
+ production: '',
3
+ staging: 'wqAToBAp4UI9AZ5M6wTfT9'
4
+ };
5
+ export const JWKS_URI = {
6
+ production: 'https://static.figmacontent.com/.well_known/jwks.json',
7
+ staging: 'https://static.figmacontentstaging.com/.well_known/jwks.json'
23
8
  };
24
- let envOverride;
25
9
  /**
26
- * Set environment override (used by --env CLI flag)
27
- * Pass undefined to clear the override
28
- */ export function setEnvironment(env) {
29
- envOverride = env;
10
+ * Get current Figma environment from environment variable
11
+ * Defaults to 'staging' if not specified
12
+ *
13
+ * @returns Current environment
14
+ */ export function getEnvironment() {
15
+ return process.env.FIGMA_ENV === 'production' ? 'production' : 'staging';
30
16
  }
31
17
  /**
32
- * Get current Figma environment
33
- * Priority: 1) setEnvironment override, 2) FIGMA_ENV env var, 3) 'production' default
34
- */ export function getEnvironment() {
35
- if (envOverride) {
36
- return envOverride;
37
- }
38
- return process.env.FIGMA_ENV === 'staging' ? 'staging' : 'production';
18
+ * Get JWKS URI for a given environment
19
+ *
20
+ * @param env - Environment (defaults to current environment)
21
+ * @returns JWKS URI for the environment
22
+ */ export function getJWKSUri(env) {
23
+ const environment = env || getEnvironment();
24
+ return JWKS_URI[environment];
39
25
  }
40
26
 
41
27
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Figma environment (production or staging)\n */\nexport type Environment = 'production' | 'staging'\n\ntype EnvironmentConfig = {\n /** Figma API base URL. Override: FIGMA_API_BASE_URL */\n apiBaseUrl: string\n /** OAuth authorization URL (CLI auth) */\n authorizationUrl: string\n /** OAuth client ID. Override: FIGMA_CLIENT_ID or FIGMA_OAUTH_CLIENT_ID */\n clientId: string\n /** Content API base URL. Override: FIGMA_CONTENT_API_URL */\n contentApiUrl: string\n /** OIDC discovery endpoint */\n identityMetadata: string\n /** JSON Web Key Set URL for token validation */\n jwksUri: string\n}\n\n/**\n * Environment-specific configuration for Figma integration.\n * Selected via FIGMA_ENV ('production' | 'staging'), defaults to 'production'.\n */\nexport const ENV_CONFIG: Record<Environment, EnvironmentConfig> = {\n production: {\n apiBaseUrl: 'https://api.figma.com',\n authorizationUrl: 'https://www.figma.com/oauth',\n clientId: 'lelKVTAzOekFnirnlAMbuD',\n contentApiUrl: 'https://us-east-1.cms-tenants-001-production.figmacontent.com',\n identityMetadata: 'https://www.figma.com/.well-known/openid-configuration',\n jwksUri: 'https://static.figmacontent.com/.well_known/jwks.json',\n },\n staging: {\n apiBaseUrl: 'https://api.staging.figma.com',\n authorizationUrl: 'https://staging.figma.com/oauth',\n clientId: 'wqAToBAp4UI9AZ5M6wTfT9',\n contentApiUrl: 'https://us-east-1.cms-tenants-001-staging.figmacontentstaging.com',\n identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',\n jwksUri: 'https://static.figmacontentstaging.com/.well_known/jwks.json',\n },\n}\n\nlet envOverride: Environment | undefined\n\n/**\n * Set environment override (used by --env CLI flag)\n * Pass undefined to clear the override\n */\nexport function setEnvironment(env: Environment | undefined): void {\n envOverride = env\n}\n\n/**\n * Get current Figma environment\n * Priority: 1) setEnvironment override, 2) FIGMA_ENV env var, 3) 'production' default\n */\nexport function getEnvironment(): Environment {\n if (envOverride) {\n return envOverride\n }\n return process.env.FIGMA_ENV === 'staging' ? 'staging' : 'production'\n}\n"],"names":["ENV_CONFIG","production","apiBaseUrl","authorizationUrl","clientId","contentApiUrl","identityMetadata","jwksUri","staging","envOverride","setEnvironment","env","getEnvironment","process","FIGMA_ENV"],"mappings":"AAAA;;CAEC,GAkBD;;;CAGC,GACD,OAAO,MAAMA,aAAqD;IAChEC,YAAY;QACVC,YAAY;QACZC,kBAAkB;QAClBC,UAAU;QACVC,eAAe;QACfC,kBAAkB;QAClBC,SAAS;IACX;IACAC,SAAS;QACPN,YAAY;QACZC,kBAAkB;QAClBC,UAAU;QACVC,eAAe;QACfC,kBAAkB;QAClBC,SAAS;IACX;AACF,EAAC;AAED,IAAIE;AAEJ;;;CAGC,GACD,OAAO,SAASC,eAAeC,GAA4B;IACzDF,cAAcE;AAChB;AAEA;;;CAGC,GACD,OAAO,SAASC;IACd,IAAIH,aAAa;QACf,OAAOA;IACT;IACA,OAAOI,QAAQF,GAAG,CAACG,SAAS,KAAK,YAAY,YAAY;AAC3D"}
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const FIGMA_CLIENT_IDS = {\n production: '',\n staging: 'wqAToBAp4UI9AZ5M6wTfT9', // Hard-coded staging client ID\n}\n\nexport const JWKS_URI = {\n production: 'https://static.figmacontent.com/.well_known/jwks.json',\n staging: 'https://static.figmacontentstaging.com/.well_known/jwks.json',\n}\n\n/**\n * Figma environment (production or staging)\n */\nexport type Environment = 'production' | 'staging'\n\n/**\n * Get current Figma environment from environment variable\n * Defaults to 'staging' if not specified\n *\n * @returns Current environment\n */\nexport function getEnvironment(): Environment {\n return process.env.FIGMA_ENV === 'production' ? 'production' : 'staging'\n}\n\n/**\n * Get JWKS URI for a given environment\n *\n * @param env - Environment (defaults to current environment)\n * @returns JWKS URI for the environment\n */\nexport function getJWKSUri(env?: Environment): string {\n const environment = env || getEnvironment()\n return JWKS_URI[environment]\n}\n"],"names":["FIGMA_CLIENT_IDS","production","staging","JWKS_URI","getEnvironment","process","env","FIGMA_ENV","getJWKSUri","environment"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB;IAC9BC,YAAY;IACZC,SAAS;AACX,EAAC;AAED,OAAO,MAAMC,WAAW;IACtBF,YAAY;IACZC,SAAS;AACX,EAAC;AAOD;;;;;CAKC,GACD,OAAO,SAASE;IACd,OAAOC,QAAQC,GAAG,CAACC,SAAS,KAAK,eAAe,eAAe;AACjE;AAEA;;;;;CAKC,GACD,OAAO,SAASC,WAAWF,GAAiB;IAC1C,MAAMG,cAAcH,OAAOF;IAC3B,OAAOD,QAAQ,CAACM,YAAY;AAC9B"}
@@ -1,4 +1,3 @@
1
1
  export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
2
2
  export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
3
- export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
4
3
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA"}
@@ -1,5 +1,4 @@
1
1
  export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
2
2
  export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
3
- export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
4
3
 
5
4
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\nexport { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js'\n"],"names":["DefaultLoginButton","LogoutButton","ContentApiClientUploadHandler"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,6BAA6B,QAAQ,+DAA8D"}
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\n"],"names":["DefaultLoginButton","LogoutButton"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,4CAA2C"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- export { contentAPIAdapter } from './db-content-api/index.js';
2
1
  export { figmaContentSystem } from './plugin/adapter.js';
3
2
  export type { FigmaContentSystemOptions } from './plugin/adapter.js';
4
- export { buildFigmaConfig } from './plugin/build-config.js';
3
+ export { buildConfig } from './plugin/build-config.js';
5
4
  export type { FigmaConfig } from './plugin/build-config.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAGpE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
- // Export contentAPIAdapter for testing use cases
2
- export { contentAPIAdapter } from './db-content-api/index.js';
3
1
  // Export database adapter for advanced use cases
4
2
  export { figmaContentSystem } from './plugin/adapter.js';
5
3
  // Export buildConfig wrapper and its config type
6
- export { buildFigmaConfig } from './plugin/build-config.js';
4
+ export { buildConfig } from './plugin/build-config.js';
7
5
 
8
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export contentAPIAdapter for testing use cases\nexport { contentAPIAdapter } from './db-content-api/index.js'\n\n// Export database adapter for advanced use cases\nexport { figmaContentSystem } from './plugin/adapter.js'\nexport type { FigmaContentSystemOptions } from './plugin/adapter.js'\n\n// Export buildConfig wrapper and its config type\nexport { buildFigmaConfig } from './plugin/build-config.js'\nexport type { FigmaConfig } from './plugin/build-config.js'\n"],"names":["contentAPIAdapter","figmaContentSystem","buildFigmaConfig"],"mappings":"AAAA,iDAAiD;AACjD,SAASA,iBAAiB,QAAQ,4BAA2B;AAE7D,iDAAiD;AACjD,SAASC,kBAAkB,QAAQ,sBAAqB;AAGxD,iDAAiD;AACjD,SAASC,gBAAgB,QAAQ,2BAA0B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export database adapter for advanced use cases\nexport { figmaContentSystem } from './plugin/adapter.js'\nexport type { FigmaContentSystemOptions } from './plugin/adapter.js'\n\n// Export buildConfig wrapper and its config type\nexport { buildConfig } from './plugin/build-config.js'\nexport type { FigmaConfig } from './plugin/build-config.js'\n"],"names":["figmaContentSystem","buildConfig"],"mappings":"AAAA,iDAAiD;AACjD,SAASA,kBAAkB,QAAQ,sBAAqB;AAGxD,iDAAiD;AACjD,SAASC,WAAW,QAAQ,2BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAgDrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqDhE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAIrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAoDhE,CAAA"}