@payloadcms/figma 1.0.0-beta.0 → 1.0.0-internal.d040868

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 (145) hide show
  1. package/dist/adapters/build-lambda-zip.d.ts +2 -1
  2. package/dist/adapters/build-lambda-zip.js +4 -1
  3. package/dist/adapters/deploy-output/assertDeployableServerActionsKey.d.ts +14 -0
  4. package/dist/adapters/deploy-output/assertDeployableServerActionsKey.js +33 -0
  5. package/dist/commands/upload-schema.js +23 -9
  6. package/dist/content-api/auth.d.ts +34 -0
  7. package/dist/content-api/auth.js +70 -0
  8. package/dist/content-api/awaitWithSignal.d.ts +2 -0
  9. package/dist/content-api/awaitWithSignal.js +27 -0
  10. package/dist/content-api/createContentApiClient.d.ts +18 -0
  11. package/dist/content-api/createContentApiClient.js +90 -0
  12. package/dist/content-api/withRateLimitRetries.d.ts +7 -0
  13. package/dist/content-api/withRateLimitRetries.js +45 -0
  14. package/dist/db-content-api/index.d.ts +5 -5
  15. package/dist/db-content-api/index.js +43 -13
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/oauth/components/FigmaAvatar/index.js +3 -2
  19. package/dist/oauth/components/FigmaAvatarCell/index.js +3 -1
  20. package/dist/oauth/components/LoginButton/index.js +8 -4
  21. package/dist/oauth/components/LogoutButton/index.js +3 -2
  22. package/dist/oauth/endpoints/getLoginEndpoint.js +2 -5
  23. package/dist/oauth/hooks/me.d.ts +4 -3
  24. package/dist/oauth/hooks/me.js +6 -52
  25. package/dist/oauth/hooks/refresh.js +9 -1
  26. package/dist/oauth/index.js +3 -3
  27. package/dist/oauth/strategy/index.d.ts +3 -0
  28. package/dist/oauth/strategy/index.js +49 -3
  29. package/dist/oauth/utilities/clearCookie.d.ts +1 -0
  30. package/dist/oauth/utilities/clearCookie.js +13 -9
  31. package/dist/oauth/utilities/clearSessionCookies.d.ts +5 -0
  32. package/dist/oauth/utilities/clearSessionCookies.js +17 -0
  33. package/dist/oauth/utilities/mergeHeaders.js +11 -23
  34. package/dist/oauth/utilities/refreshTokens.d.ts +9 -3
  35. package/dist/oauth/utilities/refreshTokens.js +45 -34
  36. package/dist/oauth/utilities/resolvePayloadRedirect.d.ts +13 -0
  37. package/dist/oauth/utilities/resolvePayloadRedirect.js +30 -0
  38. package/dist/plugin/build-config.js +14 -13
  39. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +1 -1
  40. package/dist/plugin/cloud-limits/shared.d.ts +5 -1
  41. package/dist/plugin/cloud-limits/utilities/toasts.d.ts +2 -1
  42. package/dist/plugin/dev-cookie-names.d.ts +4 -1
  43. package/dist/plugin/dev-cookie-names.js +6 -3
  44. package/dist/plugin/environment-error.d.ts +4 -0
  45. package/dist/plugin/environment-error.js +22 -0
  46. package/dist/plugin/sandbox-upload-fetch.d.ts +5 -6
  47. package/dist/plugin/sandbox-upload-fetch.js +22 -14
  48. package/dist/storage-content-api/client.d.ts +3 -3
  49. package/dist/storage-content-api/client.js +13 -35
  50. package/dist/storage-content-api/index.js +20 -21
  51. package/dist/storage-content-api/staticHandler.js +4 -1
  52. package/dist/storage-content-api/types.d.ts +2 -2
  53. package/dist/translations/ar.d.ts +9 -0
  54. package/dist/translations/ar.js +10 -1
  55. package/dist/translations/az.d.ts +9 -0
  56. package/dist/translations/az.js +10 -1
  57. package/dist/translations/bg.d.ts +9 -0
  58. package/dist/translations/bg.js +10 -1
  59. package/dist/translations/bnBd.d.ts +9 -0
  60. package/dist/translations/bnBd.js +10 -1
  61. package/dist/translations/bnIn.d.ts +9 -0
  62. package/dist/translations/bnIn.js +10 -1
  63. package/dist/translations/ca.d.ts +9 -0
  64. package/dist/translations/ca.js +10 -1
  65. package/dist/translations/cs.d.ts +9 -0
  66. package/dist/translations/cs.js +10 -1
  67. package/dist/translations/da.d.ts +9 -0
  68. package/dist/translations/da.js +10 -1
  69. package/dist/translations/de.d.ts +9 -0
  70. package/dist/translations/de.js +10 -1
  71. package/dist/translations/en.d.ts +9 -0
  72. package/dist/translations/en.js +10 -1
  73. package/dist/translations/es.d.ts +9 -0
  74. package/dist/translations/es.js +15 -6
  75. package/dist/translations/et.d.ts +9 -0
  76. package/dist/translations/et.js +10 -1
  77. package/dist/translations/fa.d.ts +9 -0
  78. package/dist/translations/fa.js +10 -1
  79. package/dist/translations/fr.d.ts +9 -0
  80. package/dist/translations/fr.js +10 -1
  81. package/dist/translations/he.d.ts +9 -0
  82. package/dist/translations/he.js +10 -1
  83. package/dist/translations/hr.d.ts +9 -0
  84. package/dist/translations/hr.js +10 -1
  85. package/dist/translations/hu.d.ts +9 -0
  86. package/dist/translations/hu.js +10 -1
  87. package/dist/translations/hy.d.ts +9 -0
  88. package/dist/translations/hy.js +10 -1
  89. package/dist/translations/id.d.ts +9 -0
  90. package/dist/translations/id.js +10 -1
  91. package/dist/translations/index.d.ts +400 -3
  92. package/dist/translations/is.d.ts +9 -0
  93. package/dist/translations/is.js +10 -1
  94. package/dist/translations/it.d.ts +9 -0
  95. package/dist/translations/it.js +10 -1
  96. package/dist/translations/ja.d.ts +9 -0
  97. package/dist/translations/ja.js +14 -5
  98. package/dist/translations/ko.d.ts +9 -0
  99. package/dist/translations/ko.js +16 -7
  100. package/dist/translations/lt.d.ts +9 -0
  101. package/dist/translations/lt.js +10 -1
  102. package/dist/translations/lv.d.ts +9 -0
  103. package/dist/translations/lv.js +10 -1
  104. package/dist/translations/my.d.ts +9 -0
  105. package/dist/translations/my.js +10 -1
  106. package/dist/translations/nb.d.ts +9 -0
  107. package/dist/translations/nb.js +10 -1
  108. package/dist/translations/nl.d.ts +9 -0
  109. package/dist/translations/nl.js +10 -1
  110. package/dist/translations/pl.d.ts +9 -0
  111. package/dist/translations/pl.js +10 -1
  112. package/dist/translations/pt.d.ts +9 -0
  113. package/dist/translations/pt.js +15 -6
  114. package/dist/translations/ro.d.ts +9 -0
  115. package/dist/translations/ro.js +10 -1
  116. package/dist/translations/rs.d.ts +9 -0
  117. package/dist/translations/rs.js +10 -1
  118. package/dist/translations/rsLatin.d.ts +9 -0
  119. package/dist/translations/rsLatin.js +10 -1
  120. package/dist/translations/ru.d.ts +9 -0
  121. package/dist/translations/ru.js +10 -1
  122. package/dist/translations/sk.d.ts +9 -0
  123. package/dist/translations/sk.js +10 -1
  124. package/dist/translations/sl.d.ts +9 -0
  125. package/dist/translations/sl.js +10 -1
  126. package/dist/translations/sv.d.ts +9 -0
  127. package/dist/translations/sv.js +10 -1
  128. package/dist/translations/ta.d.ts +9 -0
  129. package/dist/translations/ta.js +10 -1
  130. package/dist/translations/th.d.ts +9 -0
  131. package/dist/translations/th.js +10 -1
  132. package/dist/translations/tr.d.ts +9 -0
  133. package/dist/translations/tr.js +10 -1
  134. package/dist/translations/uk.d.ts +9 -0
  135. package/dist/translations/uk.js +10 -1
  136. package/dist/translations/vi.d.ts +9 -0
  137. package/dist/translations/vi.js +10 -1
  138. package/dist/translations/zh.d.ts +9 -0
  139. package/dist/translations/zh.js +10 -1
  140. package/dist/translations/zhTw.d.ts +9 -0
  141. package/dist/translations/zhTw.js +10 -1
  142. package/dist/utils/env-management.js +7 -0
  143. package/package.json +1 -1
  144. package/dist/db-content-api/utilities/auth.d.ts +0 -29
  145. package/dist/db-content-api/utilities/auth.js +0 -82
@@ -0,0 +1,30 @@
1
+ import { formatAdminURL, getSafeRedirect } from 'payload/shared';
2
+ /**
3
+ * Applies the `payloadRedirect` cookie (Payload's `?redirect=` login param, saved by
4
+ * `LoginButton`) to the post-login redirect URL.
5
+ *
6
+ * Payload sets `?redirect=` to the full admin path, e.g. `/admin/collections/posts`, or to just a
7
+ * query string when login started at the admin root. Appending a path to the admin URL would
8
+ * double the admin route (`/admin/admin/collections/posts`), so paths are resolved from the
9
+ * origin instead. Unsafe values, including absolute URLs, are ignored.
10
+ *
11
+ * @example resolvePayloadRedirect('/admin/collections/posts', 'https://site/admin') // 'https://site/admin/collections/posts'
12
+ * @example resolvePayloadRedirect('?embed=true', 'https://site/admin') // 'https://site/admin?embed=true'
13
+ */ export function resolvePayloadRedirect(payloadRedirect, redirectURL) {
14
+ if (payloadRedirect.startsWith('?')) {
15
+ return redirectURL + payloadRedirect;
16
+ }
17
+ const path = getSafeRedirect({
18
+ fallbackTo: '',
19
+ redirectTo: payloadRedirect
20
+ });
21
+ if (!path) {
22
+ return redirectURL;
23
+ }
24
+ // `adminRoute: '/'` adds no route segment, leaving the origin, any Next.js basePath, and `path`.
25
+ return formatAdminURL({
26
+ adminRoute: '/',
27
+ path: path,
28
+ serverURL: redirectURL
29
+ });
30
+ }
@@ -23,6 +23,7 @@ import { logMissingContentSystemId } from './bootstrap-preflight.js';
23
23
  import { createCacheRevalidationHooksPlugin } from './cache-revalidation-hooks.js';
24
24
  import { LIMIT_REACHED_VIEW_KEY, LIMIT_REACHED_VIEW_PATH } from './cloud-limits/routes.js';
25
25
  import { getDevCookieNames } from './dev-cookie-names.js';
26
+ import { FigmaEnvironmentError } from './environment-error.js';
26
27
  import { passesMakeViewerWriteGate, withMakeViewerWriteBaseAccessDefaults } from './make-permission-access/make-permission-access.js';
27
28
  import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
28
29
  /**
@@ -42,7 +43,7 @@ import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
42
43
  admin: {
43
44
  readOnly: true
44
45
  },
45
- label: 'Name'
46
+ label: ({ t })=>t('general:name')
46
47
  },
47
48
  {
48
49
  name: 'figmaImageUrl',
@@ -57,7 +58,7 @@ import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
57
58
  hidden: true,
58
59
  readOnly: true
59
60
  },
60
- label: 'Profile Picture'
61
+ label: ({ t })=>t('figma:profilePicture')
61
62
  },
62
63
  // Virtual (never persisted): populated per-request from the session JWT. The
63
64
  // afterRead hook surfaces the claim on the requester's OWN user record only —
@@ -79,7 +80,7 @@ import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
79
80
  ({ data, req })=>data?.id !== undefined && req.user?.id === data.id ? req.user.userGroups : undefined
80
81
  ]
81
82
  },
82
- label: 'User Groups',
83
+ label: ({ t })=>t('figma:userGroups'),
83
84
  virtual: true
84
85
  },
85
86
  // KEEP_IN_SYNC(sinatra/controllers/api/api_payload_control_plane.rb) — resolve_make_permission
@@ -97,14 +98,14 @@ import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
97
98
  ({ data, req })=>data?.id !== undefined && req.user?.id === data.id ? req.user.makePermission : undefined
98
99
  ]
99
100
  },
100
- label: 'Make Permission',
101
+ label: ({ t })=>t('figma:makePermission'),
101
102
  options: [
102
103
  {
103
- label: 'View',
104
+ label: ({ t })=>t('figma:view'),
104
105
  value: 'view'
105
106
  },
106
107
  {
107
- label: 'Edit',
108
+ label: ({ t })=>t('general:edit'),
108
109
  value: 'edit'
109
110
  }
110
111
  ],
@@ -200,18 +201,18 @@ function readCachedBootstrapData() {
200
201
  }
201
202
  const scope = readProjectScope();
202
203
  if (!scope) {
203
- throw new Error('Could not resolve the Content API URL.');
204
+ throw new FigmaEnvironmentError('Could not resolve the Content API URL.');
204
205
  }
205
206
  const message = `Could not resolve the Content API URL for environment "${scope.environmentName}" of project ${scope.projectId}.`;
206
207
  if (args.bootstrapFetched) {
207
- throw new Error(message);
208
+ throw new FigmaEnvironmentError(message);
208
209
  }
209
210
  const resolution = await resolveAndCacheBootstrap(getTokenStore(), scope.projectId, scope.environmentName);
210
211
  if (!resolution.ok) {
211
- throw new Error(`${message} ${describeBootstrapFailure(resolution.reason)}`);
212
+ throw new FigmaEnvironmentError(`${message} ${describeBootstrapFailure(resolution.reason)}`);
212
213
  }
213
214
  if (!resolution.data.contentApiUrl) {
214
- throw new Error(message);
215
+ throw new FigmaEnvironmentError(message);
215
216
  }
216
217
  return resolution.data.contentApiUrl;
217
218
  }
@@ -365,13 +366,13 @@ export async function buildFigmaConfig(config) {
365
366
  environmentId = bootstrapData?.tenantInstanceId;
366
367
  }
367
368
  if (!environmentId) {
368
- throw new Error('Environment ID could not be resolved. Set FIGMA_EID or initialize the project.');
369
+ throw new FigmaEnvironmentError('Environment ID could not be resolved. Set FIGMA_EID or initialize the project.');
369
370
  }
370
371
  if (!contentSystemId) {
371
372
  logMissingContentSystemId(bootstrapReason ?? {
372
373
  kind: 'no-config'
373
374
  });
374
- throw new Error('Content System ID could not be resolved. ' + 'Run `npx @payloadcms/figma init` to set up your project.');
375
+ throw new FigmaEnvironmentError('Content System ID could not be resolved. ' + 'Run `npx @payloadcms/figma init` to set up your project.');
375
376
  }
376
377
  // Only the content-system db adapter and cloud storage call the Content API, so a project on a
377
378
  // custom db with storage disabled needs no URL; `url` stays '' and is unused in that case.
@@ -560,7 +561,7 @@ export async function buildFigmaConfig(config) {
560
561
  usernameField: 'email'
561
562
  }
562
563
  ],
563
- ...isProduction ? {} : getDevCookieNames(contentSystemId),
564
+ ...isProduction ? {} : getDevCookieNames(contentSystemId, config.cookiePrefix),
564
565
  debug: !!process.env.DEBUG,
565
566
  disabled: false
566
567
  }),
@@ -54,7 +54,7 @@ export function FigmaCloudLimitDocumentCountModal({ collectionLabel, collectionL
54
54
  onRetry();
55
55
  },
56
56
  size: "medium",
57
- children: t('figma:cloudLimitModalRetry')
57
+ children: t('general:retry')
58
58
  })
59
59
  ]
60
60
  })
@@ -7,4 +7,8 @@ export type CloudLimitErrorCode = (typeof cloudLimitErrorCodes)[keyof typeof clo
7
7
  export declare function isCloudLimitErrorCode(code: unknown): code is CloudLimitErrorCode;
8
8
  export declare function getCloudLimitErrorCode(json: unknown): CloudLimitErrorCode | undefined;
9
9
  export declare const cloudLimitDocumentCountModalSlug = "figma-cloud-limit-document-count";
10
- export declare const cloudLimitToastKeyByCode: Record<CloudLimitErrorCode, string>;
10
+ export declare const cloudLimitToastKeyByCode: {
11
+ "cloud_limit.cms_assets_bytes_exceeded": "figma:cloudLimitAssetStorageError";
12
+ "cloud_limit.document_count_exceeded": "figma:cloudLimitDocumentCountError";
13
+ "cloud_limit.per_document_data_bytes_exceeded": "figma:cloudLimitDocumentDataSizeError";
14
+ };
@@ -1,4 +1,5 @@
1
+ import type { FigmaTranslationKeys } from '../../../translations/index.js';
1
2
  import type { CloudLimitErrorCode } from '../shared.js';
2
- export type Translate = (key: string) => string;
3
+ export type Translate = (key: FigmaTranslationKeys) => string;
3
4
  export declare function dismissSubmittingToast(label: string): void;
4
5
  export declare function showCloudLimitToast(code: CloudLimitErrorCode, translate: Translate): void;
@@ -5,9 +5,12 @@
5
5
  * switching environments in the same checkout; falls back to contentSystemId
6
6
  * when projectId isn't in `.env`.
7
7
  *
8
+ * Names must start with `cookiePrefix`: Payload forwards every other request
9
+ * cookie when it fetches an external upload URL.
10
+ *
8
11
  * In production, cookies are isolated by unique hostnames and this is unused.
9
12
  */
10
- export declare function getDevCookieNames(contentSystemId: string): {
13
+ export declare function getDevCookieNames(contentSystemId: string, cookiePrefix?: string): {
11
14
  cookieName: string;
12
15
  userInfoCookieName: string;
13
16
  };
@@ -6,12 +6,15 @@ import { getEnvVarSync } from '../utils/env-management.js';
6
6
  * switching environments in the same checkout; falls back to contentSystemId
7
7
  * when projectId isn't in `.env`.
8
8
  *
9
+ * Names must start with `cookiePrefix`: Payload forwards every other request
10
+ * cookie when it fetches an external upload URL.
11
+ *
9
12
  * In production, cookies are isolated by unique hostnames and this is unused.
10
- */ export function getDevCookieNames(contentSystemId) {
13
+ */ export function getDevCookieNames(contentSystemId, cookiePrefix = 'payload') {
11
14
  const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID') ?? contentSystemId;
12
15
  const suffix = projectId.slice(0, 8);
13
16
  return {
14
- cookieName: `figma-${suffix}-oauth-token`,
15
- userInfoCookieName: `figma-${suffix}-user-info`
17
+ cookieName: `${cookiePrefix}-figma-${suffix}-oauth-token`,
18
+ userInfoCookieName: `${cookiePrefix}-figma-${suffix}-user-info`
16
19
  };
17
20
  }
@@ -0,0 +1,4 @@
1
+ /** Required Figma environment configuration could not be resolved. */
2
+ export declare class FigmaEnvironmentError extends Error {
3
+ name: string;
4
+ }
@@ -0,0 +1,22 @@
1
+ import * as payload from 'payload';
2
+ /** Required Figma environment configuration could not be resolved. */ export class FigmaEnvironmentError extends Error {
3
+ name = 'FigmaEnvironmentError';
4
+ }
5
+ // Older Payload versions do not expose a CLI error hook and retain their default status 1.
6
+ if ('registerCLIExitCodeHandler' in payload && typeof payload.registerCLIExitCodeHandler === 'function') {
7
+ payload.registerCLIExitCodeHandler({
8
+ handler: (error)=>{
9
+ if (!(error instanceof FigmaEnvironmentError)) {
10
+ return undefined;
11
+ }
12
+ // Figma environments inject this status so the platform can detect
13
+ // and classify environment misconfigurations.
14
+ const rawExitCode = process.env.FIGMA_DEPLOY_FAILURE_EXIT_CODE;
15
+ if (rawExitCode === undefined || !/^\d+$/.test(rawExitCode)) {
16
+ return undefined;
17
+ }
18
+ const exitCode = Number(rawExitCode);
19
+ return exitCode >= 1 && exitCode <= 255 ? exitCode : undefined;
20
+ }
21
+ });
22
+ }
@@ -19,14 +19,13 @@ type SandboxUploadFetchOptions = {
19
19
  * maps external hostnames to unique-local IPv6 addresses (`fc00::/7`) that
20
20
  * `safeFetch` rejects as non-unicast. A no-op elsewhere.
21
21
  *
22
- * Only a default: a collection that set `skipSafeFetch` itself keeps its value.
23
- * `externalFileHeaderFilter` is left unset on purpose, since it would replace
24
- * the cookie logic that forwards credentials for relative URLs.
22
+ * A collection that sets `skipSafeFetch` keeps its value.
23
+ * The default header filter removes current and legacy OAuth cookies from
24
+ * external requests. Trusted same-origin relative URLs retain their cookies.
25
25
  *
26
26
  * SSRF risks, bounded by the routes' auth gate and sandbox network limits:
27
- * `getExternalFile` re-validates redirects only against `pasteURL.allowList`,
28
- * any session can GET an arbitrary URL and read the body, and request cookies
29
- * reach the target.
27
+ * Payload checks each redirect against `pasteURL.allowList`.
28
+ * An authenticated session can fetch an arbitrary URL and read its body.
30
29
  */
31
30
  export declare function createSandboxUploadFetchPlugin({ userCollections }: SandboxUploadFetchOptions): (config: Config) => Config;
32
31
  export {};
@@ -12,14 +12,13 @@ import * as log from '../utils/log.js';
12
12
  * maps external hostnames to unique-local IPv6 addresses (`fc00::/7`) that
13
13
  * `safeFetch` rejects as non-unicast. A no-op elsewhere.
14
14
  *
15
- * Only a default: a collection that set `skipSafeFetch` itself keeps its value.
16
- * `externalFileHeaderFilter` is left unset on purpose, since it would replace
17
- * the cookie logic that forwards credentials for relative URLs.
15
+ * A collection that sets `skipSafeFetch` keeps its value.
16
+ * The default header filter removes current and legacy OAuth cookies from
17
+ * external requests. Trusted same-origin relative URLs retain their cookies.
18
18
  *
19
19
  * SSRF risks, bounded by the routes' auth gate and sandbox network limits:
20
- * `getExternalFile` re-validates redirects only against `pasteURL.allowList`,
21
- * any session can GET an arbitrary URL and read the body, and request cookies
22
- * reach the target.
20
+ * Payload checks each redirect against `pasteURL.allowList`.
21
+ * An authenticated session can fetch an arbitrary URL and read its body.
23
22
  */ export function createSandboxUploadFetchPlugin({ userCollections }) {
24
23
  const appOwnedSlugs = new Set((userCollections ?? []).filter((collection)=>typeof collection.upload === 'object' && 'skipSafeFetch' in collection.upload).map((collection)=>collection.slug));
25
24
  return (config)=>{
@@ -27,27 +26,36 @@ import * as log from '../utils/log.js';
27
26
  return config;
28
27
  }
29
28
  const modifiedSlugs = [];
29
+ let modified = false;
30
30
  const collections = (config.collections ?? []).map((collection)=>{
31
- if (!collection.upload || appOwnedSlugs.has(collection.slug)) {
31
+ if (!collection.upload) {
32
32
  return collection;
33
33
  }
34
- modifiedSlugs.push(collection.slug);
34
+ modified = true;
35
+ if (!appOwnedSlugs.has(collection.slug)) {
36
+ modifiedSlugs.push(collection.slug);
37
+ }
35
38
  const upload = collection.upload === true ? {} : collection.upload;
36
39
  return {
37
40
  ...collection,
38
41
  upload: {
39
42
  ...upload,
40
- skipSafeFetch: true
43
+ ...!appOwnedSlugs.has(collection.slug) ? {
44
+ skipSafeFetch: true
45
+ } : {},
46
+ externalFileHeaderFilter: upload.externalFileHeaderFilter ?? ((headers, context)=>({
47
+ // Payload supplies fresh context for each redirect hop.
48
+ cookie: (headers.cookie ?? '').split(';').filter((cookie)=>context?.isSameOrigin || !cookie.trim().startsWith(config.cookiePrefix ?? 'payload') && !/^figma-.+-(?:oauth-token(?:-refresh)?|user-info)=/.test(cookie.trim())).join(';')
49
+ }))
41
50
  }
42
51
  };
43
52
  });
44
- if (modifiedSlugs.length === 0) {
45
- return config;
53
+ if (modified) {
54
+ log.debug(`Make sandbox detected: skipSafeFetch defaults applied (${modifiedSlugs.join(', ') || 'none'}); all upload collections default to forwarding CMS cookies only to trusted same-origin relative URLs. App-defined header filters are preserved.`);
46
55
  }
47
- log.debug(`Make sandbox detected: upload collections skip safeFetch (${modifiedSlugs.join(', ')})`);
48
- return {
56
+ return modified ? {
49
57
  ...config,
50
58
  collections
51
- };
59
+ } : config;
52
60
  };
53
61
  }
@@ -1,5 +1,5 @@
1
- import createClient from 'openapi-fetch';
2
1
  import type { UploadPaths } from './api-types.js';
3
2
  import type { StorageClientConfig } from './types.js';
4
- export type StorageClient = ReturnType<typeof createClient<UploadPaths>>;
5
- export declare function createStorageClient(config: StorageClientConfig): StorageClient;
3
+ import { createContentApiClient } from '../content-api/createContentApiClient.js';
4
+ export type StorageClient = ReturnType<typeof createContentApiClient<UploadPaths>>['api'];
5
+ export declare function createStorageClient(config: StorageClientConfig, warn?: (message: string) => void): StorageClient;
@@ -1,37 +1,15 @@
1
- import createClient from 'openapi-fetch';
2
- import { getValidProjectToken } from '../auth/project-token.js';
3
- import { fetchDevJwt } from '../db-content-api/utilities/auth.js';
4
- export function createStorageClient(config) {
5
- const client = createClient({
6
- baseUrl: config.baseUrl
7
- });
8
- client.use(createStorageAuthMiddleware(config));
9
- return client;
10
- }
11
- function createStorageAuthMiddleware(config) {
12
- return {
13
- async onRequest ({ request }) {
14
- if ('contentApiKey' in config) {
15
- request.headers.set('X-Api-Key', config.contentApiKey);
16
- } else {
17
- const { auth, contentSystemId } = config;
18
- if (auth.mode === 'apiKey') {
19
- request.headers.set('X-Api-Key', auth.apiKey);
20
- } else if (auth.mode === 'tokenStore') {
21
- const token = await getValidProjectToken({
22
- tenantId: contentSystemId,
23
- tokenStore: auth.tokenStore
24
- });
25
- if (!token) {
26
- throw new Error('Authentication required. Run `npx @payloadcms/figma login` to authenticate.');
27
- }
28
- request.headers.set('Authorization', `Bearer ${token}`);
29
- } else {
30
- const token = await fetchDevJwt(config.baseUrl, contentSystemId);
31
- request.headers.set('Authorization', `Bearer ${token}`);
32
- }
33
- }
34
- return request;
1
+ import { createContentApiClient } from '../content-api/createContentApiClient.js';
2
+ import { warning } from '../utils/log.js';
3
+ export function createStorageClient(config, warn = warning) {
4
+ return createContentApiClient({
5
+ auth: 'contentApiKey' in config ? {
6
+ apiKey: config.contentApiKey,
7
+ mode: 'apiKey'
8
+ } : config.auth,
9
+ baseUrl: config.baseUrl,
10
+ contentSystemId: 'contentSystemId' in config ? config.contentSystemId : '',
11
+ logger: {
12
+ warn
35
13
  }
36
- };
14
+ }).api;
37
15
  }
@@ -7,37 +7,36 @@ import { getHandleUpload } from './handleUpload.js';
7
7
  import { getHandler } from './staticHandler.js';
8
8
  export function contentApiStorageAdapter(config) {
9
9
  return ({ collection, prefix })=>{
10
- const client = createStorageClient(config);
11
10
  const baseUrl = config.baseUrl;
12
- const deleteFile = getDeleteFile({
13
- client
14
- });
11
+ const deleteFile = (args)=>getDeleteFile({
12
+ client: createStorageClient(config, (message)=>args.req.payload.logger.warn(message))
13
+ })(args);
15
14
  return {
16
15
  name: 'content-api',
17
- copyFile: getCopyFile({
18
- client
19
- }),
16
+ copyFile: (args)=>getCopyFile({
17
+ client: createStorageClient(config, (message)=>args.req.payload.logger.warn(message))
18
+ })(args),
20
19
  deleteFile,
21
20
  generateURL: getGenerateURL({
22
21
  baseUrl
23
22
  }),
24
23
  handleDelete: deleteFile,
25
- handleUpload: getHandleUpload({
26
- client,
27
- collection
28
- }),
29
- staticHandler: getHandler({
30
- client,
31
- collection,
32
- prefix
33
- }),
24
+ handleUpload: (args)=>getHandleUpload({
25
+ client: createStorageClient(config, (message)=>args.req.payload.logger.warn(message)),
26
+ collection
27
+ })(args),
28
+ staticHandler: (req, args)=>getHandler({
29
+ client: createStorageClient(config, (message)=>req.payload.logger.warn(message)),
30
+ collection,
31
+ prefix
32
+ })(req, args),
34
33
  uploadInstructions: {
35
34
  enabled: true,
36
- generate: getGenerateUploadInstructions({
37
- access: config.uploadInstructionsAccess,
38
- client,
39
- collectionPrefix: prefix
40
- }),
35
+ generate: (args)=>getGenerateUploadInstructions({
36
+ access: config.uploadInstructionsAccess,
37
+ client: createStorageClient(config, (message)=>args.req.payload.logger.warn(message)),
38
+ collectionPrefix: prefix
39
+ })(args),
41
40
  requiresUploadReceipt: true,
42
41
  useInAdmin: true
43
42
  }
@@ -8,13 +8,16 @@ import { mediaErrorResponse } from './mediaErrorResponse.js';
8
8
  import { resolveDownloadResponseHeaders } from './resolveDownloadResponseHeaders.js';
9
9
  const PRESIGNED_DOWNLOAD_URL_EXPIRES_IN_SECONDS = 300;
10
10
  export const getHandler = ({ client, collection, prefix = '' })=>{
11
- return async (req, { doc, headers, params: { filename, operation, uploadReference } })=>{
11
+ return async (req, { doc, headers, params })=>{
12
+ const { filename, operation, uploadReference } = params;
13
+ const { isOriginal } = params;
12
14
  try {
13
15
  const prefixArgs = {
14
16
  collection,
15
17
  collectionPrefix: prefix,
16
18
  doc,
17
19
  filename,
20
+ isOriginal,
18
21
  req,
19
22
  uploadReference
20
23
  };
@@ -1,9 +1,9 @@
1
1
  import type { UploadInstructionsAccess } from 'payload';
2
- import type { AuthMode } from '../db-content-api/utilities/auth.js';
2
+ import type { ContentApiAuth } from '../content-api/auth.js';
3
3
  export type StorageClientConfig = {
4
4
  uploadInstructionsAccess?: UploadInstructionsAccess;
5
5
  } & ({
6
- auth: AuthMode;
6
+ auth: ContentApiAuth;
7
7
  baseUrl: string;
8
8
  contentSystemId: string;
9
9
  } | {
@@ -1,5 +1,6 @@
1
1
  export declare const arTranslations: {
2
2
  figma: {
3
+ avatar: string;
3
4
  cloudLimitAssetStorageError: string;
4
5
  cloudLimitDocumentCountError: string;
5
6
  cloudLimitDocumentDataSizeError: string;
@@ -8,5 +9,13 @@ export declare const arTranslations: {
8
9
  cloudLimitModalHeading: string;
9
10
  cloudLimitModalRetry: string;
10
11
  cloudLimitModalReviewCollection: string;
12
+ logInWithFigma: string;
13
+ makePermission: string;
14
+ managedByFigma: string;
15
+ profile: string;
16
+ profilePicture: string;
17
+ signingIn: string;
18
+ userGroups: string;
19
+ view: string;
11
20
  };
12
21
  };
@@ -1,5 +1,6 @@
1
1
  export const arTranslations = {
2
2
  figma: {
3
+ avatar: 'الصورة الرمزية',
3
4
  cloudLimitAssetStorageError: 'يتعذر التحميل. يرجى تحرير بعض المساحة للمتابعة.',
4
5
  cloudLimitDocumentCountError: 'غير قادر على إنشاء وثيقة. تم الوصول إلى الحد الأقصى لسعة التخزين.',
5
6
  cloudLimitDocumentDataSizeError: 'تعذر حفظ المستند، النص كبير جدًا.',
@@ -7,6 +8,14 @@ export const arTranslations = {
7
8
  cloudLimitModalConfirm: 'تم فهم ذلك',
8
9
  cloudLimitModalHeading: 'تعذر حفظ المستند',
9
10
  cloudLimitModalRetry: 'إعادة المحاولة',
10
- cloudLimitModalReviewCollection: 'مراجعة {{collection}}'
11
+ cloudLimitModalReviewCollection: 'مراجعة {{collection}}',
12
+ logInWithFigma: 'تسجيل الدخول باستخدام Figma',
13
+ makePermission: 'إذن Make',
14
+ managedByFigma: 'تتم إدارته بواسطة Figma',
15
+ profile: 'الملف الشخصي',
16
+ profilePicture: 'صورة الملف الشخصي',
17
+ signingIn: 'جارٍ تسجيل الدخول',
18
+ userGroups: 'مجموعات المستخدمين',
19
+ view: 'عرض'
11
20
  }
12
21
  };
@@ -1,5 +1,6 @@
1
1
  export declare const azTranslations: {
2
2
  figma: {
3
+ avatar: string;
3
4
  cloudLimitAssetStorageError: string;
4
5
  cloudLimitDocumentCountError: string;
5
6
  cloudLimitDocumentDataSizeError: string;
@@ -8,5 +9,13 @@ export declare const azTranslations: {
8
9
  cloudLimitModalHeading: string;
9
10
  cloudLimitModalRetry: string;
10
11
  cloudLimitModalReviewCollection: string;
12
+ logInWithFigma: string;
13
+ makePermission: string;
14
+ managedByFigma: string;
15
+ profile: string;
16
+ profilePicture: string;
17
+ signingIn: string;
18
+ userGroups: string;
19
+ view: string;
11
20
  };
12
21
  };
@@ -1,5 +1,6 @@
1
1
  export const azTranslations = {
2
2
  figma: {
3
+ avatar: 'Avatar',
3
4
  cloudLimitAssetStorageError: 'Yükləmək mümkün deyil. Davam etmək üçün yer boşaldın.',
4
5
  cloudLimitDocumentCountError: 'Sənəd yaratmaq mümkün deyil. Saxlama limiti aşılmışdır.',
5
6
  cloudLimitDocumentDataSizeError: 'Sənədi saxlamaq mümkün deyil, mətn çox böyükdür.',
@@ -7,6 +8,14 @@ export const azTranslations = {
7
8
  cloudLimitModalConfirm: 'Başa düşdüm',
8
9
  cloudLimitModalHeading: 'Sənədi yadda saxlamaq mümkün olmadı',
9
10
  cloudLimitModalRetry: 'Təkrar cəhd edin',
10
- cloudLimitModalReviewCollection: '{{collection}}-ə baxış'
11
+ cloudLimitModalReviewCollection: '{{collection}}-ə baxış',
12
+ logInWithFigma: 'Figma ilə daxil olun',
13
+ makePermission: 'Make icazəsi',
14
+ managedByFigma: 'Figma tərəfindən idarə olunur',
15
+ profile: 'Profil',
16
+ profilePicture: 'Profil şəkli',
17
+ signingIn: 'Daxil olunur',
18
+ userGroups: 'İstifadəçi qrupları',
19
+ view: 'Baxış'
11
20
  }
12
21
  };
@@ -1,5 +1,6 @@
1
1
  export declare const bgTranslations: {
2
2
  figma: {
3
+ avatar: string;
3
4
  cloudLimitAssetStorageError: string;
4
5
  cloudLimitDocumentCountError: string;
5
6
  cloudLimitDocumentDataSizeError: string;
@@ -8,5 +9,13 @@ export declare const bgTranslations: {
8
9
  cloudLimitModalHeading: string;
9
10
  cloudLimitModalRetry: string;
10
11
  cloudLimitModalReviewCollection: string;
12
+ logInWithFigma: string;
13
+ makePermission: string;
14
+ managedByFigma: string;
15
+ profile: string;
16
+ profilePicture: string;
17
+ signingIn: string;
18
+ userGroups: string;
19
+ view: string;
11
20
  };
12
21
  };
@@ -1,5 +1,6 @@
1
1
  export const bgTranslations = {
2
2
  figma: {
3
+ avatar: 'Аватар',
3
4
  cloudLimitAssetStorageError: 'Не може да се качи. Освободете пространство, за да продължите.',
4
5
  cloudLimitDocumentCountError: 'Неуспешно създаване на документ. Достигнат е лимитът за съхранение.',
5
6
  cloudLimitDocumentDataSizeError: 'Неуспешно записване на документа, текстът е твърде голям.',
@@ -7,6 +8,14 @@ export const bgTranslations = {
7
8
  cloudLimitModalConfirm: 'Разбрах',
8
9
  cloudLimitModalHeading: 'Неуспешно запазване на документа',
9
10
  cloudLimitModalRetry: 'Опитайте отново.',
10
- cloudLimitModalReviewCollection: 'Преглед на {{collection}}'
11
+ cloudLimitModalReviewCollection: 'Преглед на {{collection}}',
12
+ logInWithFigma: 'Вход с Figma',
13
+ makePermission: 'Разрешение за Make',
14
+ managedByFigma: 'Управлява се от Figma',
15
+ profile: 'Профил',
16
+ profilePicture: 'Профилна снимка',
17
+ signingIn: 'Влизане',
18
+ userGroups: 'Потребителски групи',
19
+ view: 'Преглед'
11
20
  }
12
21
  };
@@ -1,5 +1,6 @@
1
1
  export declare const bnBdTranslations: {
2
2
  figma: {
3
+ avatar: string;
3
4
  cloudLimitAssetStorageError: string;
4
5
  cloudLimitDocumentCountError: string;
5
6
  cloudLimitDocumentDataSizeError: string;
@@ -8,5 +9,13 @@ export declare const bnBdTranslations: {
8
9
  cloudLimitModalHeading: string;
9
10
  cloudLimitModalRetry: string;
10
11
  cloudLimitModalReviewCollection: string;
12
+ logInWithFigma: string;
13
+ makePermission: string;
14
+ managedByFigma: string;
15
+ profile: string;
16
+ profilePicture: string;
17
+ signingIn: string;
18
+ userGroups: string;
19
+ view: string;
11
20
  };
12
21
  };