@payloadcms/figma 1.0.0-beta.3 → 1.0.0-beta.5
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.
- package/dist/adapters/asset-collection.d.ts +15 -0
- package/dist/adapters/asset-collection.js +51 -45
- package/dist/adapters/build-lambda-zip.d.ts +8 -9
- package/dist/adapters/build-lambda-zip.js +36 -44
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/lambdaLimits.d.ts +6 -0
- package/dist/adapters/lambdaLimits.js +5 -0
- package/dist/adapters/nextjs-assets.d.ts +7 -0
- package/dist/adapters/nextjs-assets.js +44 -0
- package/dist/adapters/nextjs.d.ts +8 -0
- package/dist/adapters/nextjs.js +19 -37
- package/dist/adapters/nitro.js +18 -43
- package/dist/adapters/omit-optional-sharp.d.ts +22 -0
- package/dist/adapters/omit-optional-sharp.js +158 -0
- package/dist/adapters/secret-files.js +8 -1
- package/dist/adapters/types.d.ts +8 -0
- package/dist/adapters/v2/core/build.d.ts +69 -0
- package/dist/adapters/v2/core/build.js +183 -0
- package/dist/adapters/v2/core/content-type.d.ts +3 -0
- package/dist/adapters/v2/core/content-type.js +41 -0
- package/dist/adapters/v2/core/getRelativePathError.d.ts +5 -0
- package/dist/adapters/v2/core/getRelativePathError.js +21 -0
- package/dist/adapters/v2/core/index.d.ts +15 -0
- package/dist/adapters/v2/core/index.js +13 -0
- package/dist/adapters/v2/core/limits.d.ts +28 -0
- package/dist/adapters/v2/core/limits.js +26 -0
- package/dist/adapters/v2/core/manifest-version.d.ts +10 -0
- package/dist/adapters/v2/core/manifest-version.js +14 -0
- package/dist/adapters/v2/core/server-zip.d.ts +58 -0
- package/dist/adapters/v2/core/server-zip.js +123 -0
- package/dist/adapters/v2/core/services.d.ts +46 -0
- package/dist/adapters/v2/core/services.js +202 -0
- package/dist/adapters/v2/core/static-path.d.ts +13 -0
- package/dist/adapters/v2/core/static-path.js +32 -0
- package/dist/adapters/v2/core/static-site.d.ts +26 -0
- package/dist/adapters/v2/core/static-site.js +95 -0
- package/dist/adapters/v2/core/types.d.ts +128 -0
- package/dist/adapters/v2/core/types.js +7 -0
- package/dist/adapters/v2/core/upload.d.ts +67 -0
- package/dist/adapters/v2/core/upload.js +198 -0
- package/dist/adapters/v2/core/validateDeployment/createIssue.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/createIssue.js +7 -0
- package/dist/adapters/v2/core/validateDeployment/escapePointer.d.ts +2 -0
- package/dist/adapters/v2/core/validateDeployment/escapePointer.js +3 -0
- package/dist/adapters/v2/core/validateDeployment/singletonHeaders.d.ts +2 -0
- package/dist/adapters/v2/core/validateDeployment/singletonHeaders.js +10 -0
- package/dist/adapters/v2/core/validateDeployment/types.d.ts +16 -0
- package/dist/adapters/v2/core/validateDeployment/types.js +8 -0
- package/dist/adapters/v2/core/validateDeployment/validateArtifacts.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateArtifacts.js +30 -0
- package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.d.ts +8 -0
- package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.js +26 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.js +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateCounts.js +41 -0
- package/dist/adapters/v2/core/validateDeployment/validateFallback.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateFallback.js +21 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderName.d.ts +6 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderName.js +13 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.d.ts +2 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.js +13 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.js +38 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.js +17 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.d.ts +6 -0
- package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.js +24 -0
- package/dist/adapters/v2/core/validateDeployment/validateId.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateId.js +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateMatch.d.ts +15 -0
- package/dist/adapters/v2/core/validateDeployment/validateMatch.js +74 -0
- package/dist/adapters/v2/core/validateDeployment/validatePublicPath.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validatePublicPath.js +21 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.js +16 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.js +48 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.d.ts +10 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.js +16 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.d.ts +8 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.js +25 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateResponses.js +59 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.d.ts +10 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.js +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.d.ts +14 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.js +59 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.js +20 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.d.ts +11 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.js +26 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.d.ts +13 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.js +25 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.d.ts +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.js +35 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes.d.ts +6 -0
- package/dist/adapters/v2/core/validateDeployment/validateRoutes.js +55 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.js +12 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment/validateServers.js +59 -0
- package/dist/adapters/v2/core/validateDeployment/validateStaticMap.d.ts +3 -0
- package/dist/adapters/v2/core/validateDeployment/validateStaticMap.js +22 -0
- package/dist/adapters/v2/core/validateDeployment.d.ts +7 -0
- package/dist/adapters/v2/core/validateDeployment.js +42 -0
- package/dist/adapters/v2/core/write.d.ts +21 -0
- package/dist/adapters/v2/core/write.js +30 -0
- package/dist/adapters/v2/nextjs/coverage.d.ts +45 -0
- package/dist/adapters/v2/nextjs/coverage.js +113 -0
- package/dist/adapters/v2/nextjs/read-build-output.d.ts +116 -0
- package/dist/adapters/v2/nextjs/read-build-output.js +368 -0
- package/dist/adapters/v2/nextjs/translate.d.ts +20 -0
- package/dist/adapters/v2/nextjs/translate.js +400 -0
- package/dist/adapters/vite.d.ts +7 -0
- package/dist/adapters/vite.js +47 -0
- package/dist/adapters/writeZip.d.ts +20 -0
- package/dist/adapters/writeZip.js +28 -0
- package/dist/api/control-plane.d.ts +28 -6
- package/dist/api/control-plane.js +67 -64
- package/dist/auth/cli-build-context.d.ts +3 -0
- package/dist/auth/cli-build-context.js +2 -0
- package/dist/auth/oauth-flow.d.ts +3 -3
- package/dist/auth/oauth-flow.js +13 -3
- package/dist/cli.js +15 -0
- package/dist/commands/build-manifest.d.ts +49 -0
- package/dist/commands/build-manifest.js +111 -0
- package/dist/commands/deploy.js +195 -26
- package/dist/db-content-api/generated/content-api-types.d.ts +18 -14
- package/dist/db-content-api/index.js +4 -1
- package/dist/db-content-api/utilities/where.js +2 -6
- package/dist/endpoints/client-config.d.ts +3 -0
- package/dist/endpoints/client-config.js +87 -0
- package/dist/image-transforms/constants.d.ts +8 -0
- package/dist/image-transforms/constants.js +26 -0
- package/dist/image-transforms/createImageTransformer.d.ts +6 -0
- package/dist/image-transforms/createImageTransformer.js +100 -0
- package/dist/image-transforms/deliverImageResponse.d.ts +11 -0
- package/dist/image-transforms/deliverImageResponse.js +43 -0
- package/dist/image-transforms/imageRevision.d.ts +14 -0
- package/dist/image-transforms/imageRevision.js +115 -0
- package/dist/image-transforms/normalizeMediaType.d.ts +2 -0
- package/dist/image-transforms/normalizeMediaType.js +3 -0
- package/dist/image-transforms/parseImageOverrides.d.ts +4 -0
- package/dist/image-transforms/parseImageOverrides.js +20 -0
- package/dist/image-transforms/preserveImageRedirectHeaders.d.ts +2 -0
- package/dist/image-transforms/preserveImageRedirectHeaders.js +30 -0
- package/dist/image-transforms/preventConflictingImageTransformers.d.ts +9 -0
- package/dist/image-transforms/preventConflictingImageTransformers.js +67 -0
- package/dist/image-transforms/serveImageRequest.d.ts +6 -0
- package/dist/image-transforms/serveImageRequest.js +97 -0
- package/dist/image-transforms/storedImage.d.ts +49 -0
- package/dist/image-transforms/storedImage.js +84 -0
- package/dist/image-transforms/types.d.ts +9 -0
- package/dist/image-transforms/types.js +1 -0
- package/dist/image-transforms/variantMetadata.d.ts +13 -0
- package/dist/image-transforms/variantMetadata.js +164 -0
- package/dist/imageSizeOptions.d.ts +8 -8
- package/dist/imageSizeOptions.js +0 -2
- package/dist/index.d.ts +1 -0
- package/dist/oauth/hooks/refresh.js +9 -4
- package/dist/oauth/strategy/index.js +34 -14
- package/dist/oauth/utilities/createTokenCookie.d.ts +11 -0
- package/dist/oauth/utilities/createTokenCookie.js +21 -0
- package/dist/oauth/utilities/refreshTokens.d.ts +7 -5
- package/dist/oauth/utilities/refreshTokens.js +7 -23
- package/dist/plugin/build-config.d.ts +3 -4
- package/dist/plugin/build-config.js +39 -18
- package/dist/plugin/mcp-oauth.d.ts +18 -7
- package/dist/plugin/mcp-oauth.js +123 -10
- package/dist/skills/deploy-to-figma/SKILL.md +8 -8
- package/dist/skills/deploy-to-figma/references/cli-reference.md +1 -1
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +2 -1
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +2 -1
- package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +2 -1
- package/dist/storage-content-api/buildMediaResponseHeaders.js +11 -5
- package/dist/storage-content-api/isRunningInLambda.d.ts +2 -0
- package/dist/storage-content-api/isRunningInLambda.js +3 -0
- package/dist/storage-content-api/staticHandler.js +13 -51
- package/dist/storage-content-api/streamMediaResponse.d.ts +17 -0
- package/dist/storage-content-api/streamMediaResponse.js +96 -0
- package/dist/utils/lambda-config.js +1 -1
- package/dist/utils/messages.js +8 -0
- package/dist/utils/next-image-loader-config.js +43 -6
- package/dist/utils/next-image-loader-file.js +8 -0
- package/package.json +12 -4
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { UNRESIZABLE_IMAGE_MIME_TYPES } from './constants.js';
|
|
2
|
+
/** Formats Cloudflare always returns when asked. `getOutputMimeType` explains AVIF and PNG. */ const MIME_TYPE_BY_FORMAT = {
|
|
3
|
+
'baseline-jpeg': 'image/jpeg',
|
|
4
|
+
jpeg: 'image/jpeg',
|
|
5
|
+
'png-force': 'image/png',
|
|
6
|
+
webp: 'image/webp'
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Payload stores request-time variants with null dimensions and MIME type. Describe the image
|
|
10
|
+
* Cloudflare will render for each preset, so consumers can lay it out before loading it. A
|
|
11
|
+
* value stays null when it depends on rendered pixels or on the viewer's browser.
|
|
12
|
+
*/ export function addVariantMetadata({ doc, storedImage, variants }) {
|
|
13
|
+
const revisedDoc = {
|
|
14
|
+
...doc
|
|
15
|
+
};
|
|
16
|
+
if (storedImage.mainRenderedAtRequest && Object.hasOwn(doc, 'mimeType')) {
|
|
17
|
+
// The browser can change the output format of a request-time main file.
|
|
18
|
+
revisedDoc.mimeType = null;
|
|
19
|
+
}
|
|
20
|
+
if (!doc.variants) {
|
|
21
|
+
return revisedDoc;
|
|
22
|
+
}
|
|
23
|
+
const revisedVariants = {
|
|
24
|
+
...doc.variants
|
|
25
|
+
};
|
|
26
|
+
for (const [name, variantMetadata] of Object.entries(describeRequestTimeVariants({
|
|
27
|
+
storedImage,
|
|
28
|
+
variants
|
|
29
|
+
}))){
|
|
30
|
+
const variant = doc.variants[name];
|
|
31
|
+
if (variant) {
|
|
32
|
+
// Payload stores these fields as null and removes the ones a read did not select.
|
|
33
|
+
const selectedMetadata = Object.entries(variantMetadata).filter(([key])=>Object.hasOwn(variant, key));
|
|
34
|
+
revisedVariants[name] = {
|
|
35
|
+
...variant,
|
|
36
|
+
...Object.fromEntries(selectedMetadata)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...revisedDoc,
|
|
42
|
+
variants: revisedVariants
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function describeRequestTimeVariants({ storedImage: { requestTimeVariants, savedEdits, upload }, variants }) {
|
|
46
|
+
const source = getRenderedSource({
|
|
47
|
+
crop: savedEdits?.crop,
|
|
48
|
+
upload
|
|
49
|
+
});
|
|
50
|
+
const metadata = {};
|
|
51
|
+
for (const preset of variants){
|
|
52
|
+
if (!requestTimeVariants.includes(preset.name)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// These are served whole, and Payload rejects a saved crop on them, so `source` is the original.
|
|
56
|
+
metadata[preset.name] = UNRESIZABLE_IMAGE_MIME_TYPES.has(upload.mediaType) ? {
|
|
57
|
+
height: source?.height ?? null,
|
|
58
|
+
mimeType: upload.mediaType,
|
|
59
|
+
width: source?.width ?? null
|
|
60
|
+
} : {
|
|
61
|
+
...getPresetDimensions({
|
|
62
|
+
preset,
|
|
63
|
+
source
|
|
64
|
+
}),
|
|
65
|
+
mimeType: getOutputMimeType(preset)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return metadata;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The MIME type Cloudflare returns, when the preset guarantees one. Without a `format`, the
|
|
72
|
+
* Content API signs `fmt=auto`, which varies by browser. AVIF falls back to WebP or JPEG for
|
|
73
|
+
* images too large to encode quickly, and `compression: 'fast'` usually switches to JPEG:
|
|
74
|
+
* https://developers.cloudflare.com/images/transform-images/transform-via-url/
|
|
75
|
+
* Cloudflare does not document its PNG formats, but it offers `png-force` alongside `png`, so
|
|
76
|
+
* only `png-force` is taken to guarantee PNG.
|
|
77
|
+
*/ function getOutputMimeType(preset) {
|
|
78
|
+
if (!preset.format || preset.format === 'avif' || preset.format === 'png' || preset.compression === 'fast') {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return MIME_TYPE_BY_FORMAT[preset.format];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Payload renders variants from the original with the saved crop applied. The saved crop is in
|
|
85
|
+
* original-file pixels: Payload converts the admin editor's percent crop before saving it.
|
|
86
|
+
*/ function getRenderedSource({ crop, upload }) {
|
|
87
|
+
const width = crop?.width ?? upload.width;
|
|
88
|
+
const height = crop?.height ?? upload.height;
|
|
89
|
+
return width && height ? {
|
|
90
|
+
height,
|
|
91
|
+
width
|
|
92
|
+
} : null;
|
|
93
|
+
}
|
|
94
|
+
function getPresetDimensions({ preset, source }) {
|
|
95
|
+
// A border changes the rendered size, so it is left unknown.
|
|
96
|
+
if (!source || preset.border !== undefined) {
|
|
97
|
+
return {
|
|
98
|
+
height: null,
|
|
99
|
+
width: null
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// Cloudflare rotates before resizing, so width and height refer to the rotated axes.
|
|
103
|
+
const rotated = preset.rotate === 90 || preset.rotate === 270 ? {
|
|
104
|
+
height: source.width,
|
|
105
|
+
width: source.height
|
|
106
|
+
} : source;
|
|
107
|
+
return fitDimensions({
|
|
108
|
+
fit: preset.fit ?? 'scale-down',
|
|
109
|
+
source: rotated,
|
|
110
|
+
target: {
|
|
111
|
+
height: preset.height ?? null,
|
|
112
|
+
width: preset.width ?? null
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/** Cloudflare's `fit` modes: https://developers.cloudflare.com/images/transform-images/transform-via-url/#fit */ function fitDimensions({ fit, source, target }) {
|
|
117
|
+
if (target.width === null && target.height === null) {
|
|
118
|
+
return source;
|
|
119
|
+
}
|
|
120
|
+
const widthScale = target.width === null ? null : target.width / source.width;
|
|
121
|
+
const heightScale = target.height === null ? null : target.height / source.height;
|
|
122
|
+
if (widthScale === null || heightScale === null) {
|
|
123
|
+
// With one target dimension, every mode scales proportionally within its enlargement rule.
|
|
124
|
+
return scale(source, limitEnlargement(fit, widthScale ?? heightScale));
|
|
125
|
+
}
|
|
126
|
+
switch(fit){
|
|
127
|
+
case 'contain':
|
|
128
|
+
case 'scale-down':
|
|
129
|
+
case 'scale-up':
|
|
130
|
+
return scale(source, limitEnlargement(fit, Math.min(widthScale, heightScale)));
|
|
131
|
+
case 'cover':
|
|
132
|
+
case 'pad':
|
|
133
|
+
case 'squeeze':
|
|
134
|
+
return target;
|
|
135
|
+
case 'crop':
|
|
136
|
+
{
|
|
137
|
+
// Like cover, then cropped to the target, but never enlarged.
|
|
138
|
+
const scaled = scale(source, Math.min(Math.max(widthScale, heightScale), 1));
|
|
139
|
+
return {
|
|
140
|
+
height: Math.min(target.height, scaled.height),
|
|
141
|
+
width: Math.min(target.width, scaled.width)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
default:
|
|
145
|
+
return {
|
|
146
|
+
height: null,
|
|
147
|
+
width: null
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function limitEnlargement(fit, factor) {
|
|
152
|
+
if (fit === 'scale-down' || fit === 'crop') {
|
|
153
|
+
return Math.min(factor, 1);
|
|
154
|
+
}
|
|
155
|
+
return fit === 'scale-up' ? Math.max(factor, 1) : factor;
|
|
156
|
+
}
|
|
157
|
+
/** No image is 0 pixels on a side, so a thin strip keeps at least one pixel. */ function scale(source, factor) {
|
|
158
|
+
// Avoid losing a pixel when an exact size comes out just below an integer.
|
|
159
|
+
const roundingTolerance = 1e-9;
|
|
160
|
+
return {
|
|
161
|
+
height: Math.max(1, Math.floor(source.height * factor + roundingTolerance)),
|
|
162
|
+
width: Math.max(1, Math.floor(source.width * factor + roundingTolerance))
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { RequestInitCfPropertiesImage } from '@cloudflare/workers-types';
|
|
2
2
|
type CloudflareWorkerImageOptions = RequestInitCfPropertiesImage;
|
|
3
|
-
export declare const supportedCloudflareImageOptionKeys: readonly ["anim", "background", "blur", "border", "brightness", "compression", "contrast", "
|
|
3
|
+
export declare const supportedCloudflareImageOptionKeys: readonly ["anim", "background", "blur", "border", "brightness", "compression", "contrast", "fit", "flip", "format", "gamma", "gravity", "height", "metadata", "quality", "rotate", "saturation", "segment", "sharpen", "upscale", "width", "zoom"];
|
|
4
4
|
type SupportedCloudflareImageOptionKey = (typeof supportedCloudflareImageOptionKeys)[number];
|
|
5
5
|
type SupportedCloudflareImageOptions = Pick<CloudflareWorkerImageOptions, SupportedCloudflareImageOptionKey>;
|
|
6
6
|
type CloudflareImageSizeFormat = Exclude<NonNullable<SupportedCloudflareImageOptions['format']>, 'json' | 'svg'>;
|
|
7
|
-
type
|
|
7
|
+
type PassthroughCloudflareImageOptions = Omit<SupportedCloudflareImageOptions, 'format' | 'rotate'>;
|
|
8
8
|
/**
|
|
9
9
|
* Options accepted for a reusable Payload image-size preset.
|
|
10
10
|
*
|
|
11
11
|
* Presets can control the generated image, but cannot use remote overlays or
|
|
12
12
|
* forward authentication to an image origin. Formats that do not produce a
|
|
13
13
|
* supported stored image are also excluded.
|
|
14
|
+
*
|
|
15
|
+
* Presets cannot set `trim` or `dpr`. An editor's saved crop is sent to Cloudflare as `trim`,
|
|
16
|
+
* which a preset's trim would replace and Cloudflare would multiply by `dpr`. Set a larger
|
|
17
|
+
* `width`, `height` and `border` instead of `dpr`.
|
|
14
18
|
*/
|
|
15
19
|
export type CloudflareImageSizeOptions = {
|
|
16
20
|
format?: CloudflareImageSizeFormat;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
interface RegisteredImageSizeOptions {
|
|
20
|
-
figma: CloudflareImageSizeOptions;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
21
|
+
rotate?: 90 | 180 | 270;
|
|
22
|
+
} & PassthroughCloudflareImageOptions;
|
|
23
23
|
export {};
|
package/dist/imageSizeOptions.js
CHANGED
|
@@ -6,7 +6,6 @@ export const supportedCloudflareImageOptionKeys = [
|
|
|
6
6
|
'brightness',
|
|
7
7
|
'compression',
|
|
8
8
|
'contrast',
|
|
9
|
-
'dpr',
|
|
10
9
|
'fit',
|
|
11
10
|
'flip',
|
|
12
11
|
'format',
|
|
@@ -19,7 +18,6 @@ export const supportedCloudflareImageOptionKeys = [
|
|
|
19
18
|
'saturation',
|
|
20
19
|
'segment',
|
|
21
20
|
'sharpen',
|
|
22
|
-
'trim',
|
|
23
21
|
'upscale',
|
|
24
22
|
'width',
|
|
25
23
|
'zoom'
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { contentAPIAdapter } from './db-content-api/index.js';
|
|
2
|
+
export type { FigmaImageTransformsConfig } from './image-transforms/types.js';
|
|
2
3
|
export type { CloudflareImageSizeOptions } from './imageSizeOptions.js';
|
|
3
4
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
4
5
|
export type { FigmaContentSystemOptions } from './plugin/adapter.js';
|
|
@@ -3,6 +3,7 @@ import { generateCookie, parseCookies } from 'payload';
|
|
|
3
3
|
import { clearSessionCookies } from '../utilities/clearSessionCookies.js';
|
|
4
4
|
import { createCookieOptions } from '../utilities/createCookieOptions.js';
|
|
5
5
|
import { createDebugLogger } from '../utilities/createDebugLogger.js';
|
|
6
|
+
import { createTokenCookie } from '../utilities/createTokenCookie.js';
|
|
6
7
|
import { getCookieExpiration } from '../utilities/getCookieExpiration.js';
|
|
7
8
|
import { getTokenExp } from '../utilities/getTokenExp.js';
|
|
8
9
|
import { mergeHeaders } from '../utilities/mergeHeaders.js';
|
|
@@ -70,10 +71,9 @@ export const getRefreshHook = ({ pluginOptions, strategy })=>async ({ args, user
|
|
|
70
71
|
return undefined;
|
|
71
72
|
}
|
|
72
73
|
const result = await refreshTokens({
|
|
73
|
-
|
|
74
|
+
debug: strategy.debug,
|
|
74
75
|
payload: args.req.payload,
|
|
75
|
-
refreshToken
|
|
76
|
-
strategy
|
|
76
|
+
refreshToken
|
|
77
77
|
});
|
|
78
78
|
if (result.status !== 'success') {
|
|
79
79
|
if (result.status === 'rejected') {
|
|
@@ -84,7 +84,12 @@ export const getRefreshHook = ({ pluginOptions, strategy })=>async ({ args, user
|
|
|
84
84
|
}
|
|
85
85
|
return undefined;
|
|
86
86
|
}
|
|
87
|
-
mergeHeaders(
|
|
87
|
+
mergeHeaders(createTokenCookie({
|
|
88
|
+
expiresAt: result.expiresAt,
|
|
89
|
+
headers: args.req.headers,
|
|
90
|
+
strategy,
|
|
91
|
+
token: result.token
|
|
92
|
+
}), args.req.responseHeaders);
|
|
88
93
|
if (result.decodedOauthToken.exp) {
|
|
89
94
|
return {
|
|
90
95
|
exp: result.decodedOauthToken.exp,
|
|
@@ -4,6 +4,7 @@ import { JWTValidationError, validatePayloadAdminToken } from '../../auth/jwt-va
|
|
|
4
4
|
import { getInfraEnvironment } from '../../constants.js';
|
|
5
5
|
import { clearSessionCookies } from '../utilities/clearSessionCookies.js';
|
|
6
6
|
import { createDebugLogger } from '../utilities/createDebugLogger.js';
|
|
7
|
+
import { createTokenCookie } from '../utilities/createTokenCookie.js';
|
|
7
8
|
import { getTokenExp } from '../utilities/getTokenExp.js';
|
|
8
9
|
import { mergeHeaders } from '../utilities/mergeHeaders.js';
|
|
9
10
|
import { refreshTokens } from '../utilities/refreshTokens.js';
|
|
@@ -76,10 +77,9 @@ export class Strategy {
|
|
|
76
77
|
msg: 'No access token found, but refresh token exists. Attempting to refresh...'
|
|
77
78
|
});
|
|
78
79
|
const refreshed = await refreshTokens({
|
|
79
|
-
|
|
80
|
+
debug: this.debug,
|
|
80
81
|
payload,
|
|
81
|
-
refreshToken
|
|
82
|
-
strategy: this
|
|
82
|
+
refreshToken
|
|
83
83
|
});
|
|
84
84
|
if (refreshed.status === 'success') {
|
|
85
85
|
const tokenExpiration = refreshed.decodedOauthToken.exp;
|
|
@@ -101,11 +101,17 @@ export class Strategy {
|
|
|
101
101
|
// During RSC navigation, canSetHeaders=false because response streaming
|
|
102
102
|
// has already started and cookies cannot be modified.
|
|
103
103
|
if (canSetHeaders) {
|
|
104
|
+
const responseHeaders = createTokenCookie({
|
|
105
|
+
expiresAt: refreshed.expiresAt,
|
|
106
|
+
headers,
|
|
107
|
+
strategy: this,
|
|
108
|
+
token: refreshed.token
|
|
109
|
+
});
|
|
104
110
|
if (verifyResult.responseHeaders) {
|
|
105
|
-
mergeHeaders(verifyResult.responseHeaders,
|
|
111
|
+
mergeHeaders(verifyResult.responseHeaders, responseHeaders);
|
|
106
112
|
}
|
|
107
113
|
return {
|
|
108
|
-
responseHeaders
|
|
114
|
+
responseHeaders,
|
|
109
115
|
user: verifyResult.user
|
|
110
116
|
};
|
|
111
117
|
}
|
|
@@ -177,10 +183,9 @@ export class Strategy {
|
|
|
177
183
|
// but only update cookies when canSetHeaders=true.
|
|
178
184
|
if (oauthTokenVerifyResult instanceof JWTValidationError && oauthTokenVerifyResult.code === 'EXPIRED' && refreshToken && !this.collectionOptions.usePayloadJWT) {
|
|
179
185
|
const refreshed = await refreshTokens({
|
|
180
|
-
|
|
186
|
+
debug: this.debug,
|
|
181
187
|
payload,
|
|
182
|
-
refreshToken
|
|
183
|
-
strategy: this
|
|
188
|
+
refreshToken
|
|
184
189
|
});
|
|
185
190
|
debugLogger.info({
|
|
186
191
|
msg: 'Token expired. Refreshing...'
|
|
@@ -202,11 +207,17 @@ export class Strategy {
|
|
|
202
207
|
verifyResult
|
|
203
208
|
});
|
|
204
209
|
if (canSetHeaders) {
|
|
210
|
+
const responseHeaders = createTokenCookie({
|
|
211
|
+
expiresAt: refreshed.expiresAt,
|
|
212
|
+
headers,
|
|
213
|
+
strategy: this,
|
|
214
|
+
token: refreshed.token
|
|
215
|
+
});
|
|
205
216
|
if (verifyResult.responseHeaders) {
|
|
206
|
-
mergeHeaders(verifyResult.responseHeaders,
|
|
217
|
+
mergeHeaders(verifyResult.responseHeaders, responseHeaders);
|
|
207
218
|
}
|
|
208
219
|
return {
|
|
209
|
-
responseHeaders
|
|
220
|
+
responseHeaders,
|
|
210
221
|
user: verifyResult.user
|
|
211
222
|
};
|
|
212
223
|
}
|
|
@@ -333,10 +344,19 @@ export class Strategy {
|
|
|
333
344
|
return verified;
|
|
334
345
|
}
|
|
335
346
|
} catch (err) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
347
|
+
// Not a JWT at all, like the MCP endpoint's sealed access tokens, which plugin-mcp
|
|
348
|
+
// authenticates after this strategy declines them. The client's mistake, not the server's.
|
|
349
|
+
if (err instanceof JWTValidationError && err.code === 'MISSING_KID') {
|
|
350
|
+
createDebugLogger(payload, this.debug).info({
|
|
351
|
+
err,
|
|
352
|
+
msg: 'Token is not a JWT'
|
|
353
|
+
});
|
|
354
|
+
} else {
|
|
355
|
+
payload.logger.error({
|
|
356
|
+
err,
|
|
357
|
+
msg: 'Error verifying jwt token'
|
|
358
|
+
});
|
|
359
|
+
}
|
|
340
360
|
if (err instanceof Error) {
|
|
341
361
|
return err;
|
|
342
362
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Strategy } from '../strategy/index.js';
|
|
2
|
+
interface Args {
|
|
3
|
+
expiresAt: number;
|
|
4
|
+
/** The request's headers, which decide the cookie's options */
|
|
5
|
+
headers: Headers;
|
|
6
|
+
strategy: Strategy;
|
|
7
|
+
token: string;
|
|
8
|
+
}
|
|
9
|
+
/** Response headers that keep a Payload Admin token from `refreshTokens` in the login's cookie */
|
|
10
|
+
export declare const createTokenCookie: ({ expiresAt, headers: requestHeaders, strategy, token, }: Args) => Headers;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { generateCookie } from 'payload';
|
|
2
|
+
import { createCookieOptions } from './createCookieOptions.js';
|
|
3
|
+
import { getCookieExpiration } from './getCookieExpiration.js';
|
|
4
|
+
import { withPartitionedCookie } from './withPartitionedCookie.js';
|
|
5
|
+
/** Response headers that keep a Payload Admin token from `refreshTokens` in the login's cookie */ export const createTokenCookie = ({ expiresAt, headers: requestHeaders, strategy, token })=>{
|
|
6
|
+
const cookieOptions = createCookieOptions({
|
|
7
|
+
collection: strategy.collection,
|
|
8
|
+
headers: requestHeaders,
|
|
9
|
+
pluginOptions: strategy.pluginOptions
|
|
10
|
+
});
|
|
11
|
+
const tokenCookie = generateCookie({
|
|
12
|
+
...cookieOptions,
|
|
13
|
+
name: strategy.cookieName,
|
|
14
|
+
expires: getCookieExpiration(new Date(expiresAt)),
|
|
15
|
+
returnCookieAsObject: false,
|
|
16
|
+
value: token
|
|
17
|
+
});
|
|
18
|
+
const headers = new Headers();
|
|
19
|
+
headers.append('Set-Cookie', withPartitionedCookie(tokenCookie));
|
|
20
|
+
return headers;
|
|
21
|
+
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type jwt from 'jsonwebtoken';
|
|
2
2
|
import type { Payload } from 'payload';
|
|
3
|
-
import type { Strategy } from '../strategy/index.js';
|
|
4
3
|
interface Args {
|
|
5
|
-
|
|
4
|
+
debug?: boolean;
|
|
6
5
|
payload: Payload;
|
|
7
6
|
refreshToken: string;
|
|
8
|
-
strategy: Strategy;
|
|
9
7
|
}
|
|
10
8
|
export type RefreshResult = {
|
|
11
9
|
decodedOauthToken: jwt.JwtPayload;
|
|
12
|
-
|
|
10
|
+
expiresAt: number;
|
|
13
11
|
status: 'success';
|
|
14
12
|
token: string;
|
|
15
13
|
} | {
|
|
@@ -17,5 +15,9 @@ export type RefreshResult = {
|
|
|
17
15
|
} | {
|
|
18
16
|
status: 'temporary_failure';
|
|
19
17
|
};
|
|
20
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Gets a new Payload Admin token from the login's refresh token. The admin panel keeps the
|
|
20
|
+
* result in a cookie (`createTokenCookie`), and MCP clients get it as their access token.
|
|
21
|
+
*/
|
|
22
|
+
export declare const refreshTokens: ({ debug, payload, refreshToken, }: Args) => Promise<RefreshResult>;
|
|
21
23
|
export {};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { generateCookie } from 'payload';
|
|
2
1
|
import { FigmaApiError, getPayloadAdminToken } from '../../api/figma-api.js';
|
|
3
2
|
import { validatePayloadAdminToken } from '../../auth/jwt-validator.js';
|
|
4
3
|
import { getInfraEnvironment } from '../../constants.js';
|
|
5
|
-
import { createCookieOptions } from './createCookieOptions.js';
|
|
6
4
|
import { createDebugLogger } from './createDebugLogger.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Gets a new Payload Admin token from the login's refresh token. The admin panel keeps the
|
|
7
|
+
* result in a cookie (`createTokenCookie`), and MCP clients get it as their access token.
|
|
8
|
+
*/ export const refreshTokens = async ({ debug, payload, refreshToken })=>{
|
|
9
|
+
const debugLogger = createDebugLogger(payload, debug);
|
|
11
10
|
debugLogger.info({
|
|
12
11
|
msg: 'Refreshing tokens'
|
|
13
12
|
});
|
|
14
|
-
|
|
15
|
-
// The refresh cookie holds an OAuth access token. Use it to mint a new
|
|
13
|
+
// The refresh token is an OAuth access token. Use it to mint a new
|
|
16
14
|
// session JWT; this does not rotate an OAuth refresh token.
|
|
17
15
|
try {
|
|
18
16
|
// Get another Payload Admin token.
|
|
@@ -45,23 +43,9 @@ export const refreshTokens = async ({ headers: requestHeaders, payload, refreshT
|
|
|
45
43
|
environment: getInfraEnvironment(),
|
|
46
44
|
token
|
|
47
45
|
});
|
|
48
|
-
const expires_in = new Date(expiresAt);
|
|
49
|
-
const cookieOptions = createCookieOptions({
|
|
50
|
-
collection: strategy.collection,
|
|
51
|
-
headers: requestHeaders,
|
|
52
|
-
pluginOptions: strategy.pluginOptions
|
|
53
|
-
});
|
|
54
|
-
const tokenCookie = generateCookie({
|
|
55
|
-
...cookieOptions,
|
|
56
|
-
name: strategy.cookieName,
|
|
57
|
-
expires: getCookieExpiration(expires_in),
|
|
58
|
-
returnCookieAsObject: false,
|
|
59
|
-
value: token
|
|
60
|
-
});
|
|
61
|
-
headers.append('Set-Cookie', withPartitionedCookie(tokenCookie));
|
|
62
46
|
return {
|
|
63
47
|
decodedOauthToken,
|
|
64
|
-
|
|
48
|
+
expiresAt,
|
|
65
49
|
status: 'success',
|
|
66
50
|
token
|
|
67
51
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Config, SanitizedConfig, UploadInstructionsAccess } from 'payload';
|
|
2
|
+
import type { FigmaImageTransformsConfig } from '../image-transforms/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Worker-trusted marker injected by Figma's sites-worker after it validates the
|
|
4
5
|
* X-Figma-Job-Queues-Auth-Bypass secret on a Payload jobs endpoint. The default
|
|
@@ -18,10 +19,7 @@ export declare const FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER = "figma-in
|
|
|
18
19
|
* doesn't accept it back in. `buildFigmaConfig` injects the value at
|
|
19
20
|
* runtime from `process.env.PAYLOAD_SECRET` (Lambda) or the encrypted
|
|
20
21
|
* TokenStore cache (local dev) — never written to `.env`.
|
|
21
|
-
* - `previousSecrets`:
|
|
22
|
-
* data written under the old shared hosted secret keeps decrypting after
|
|
23
|
-
* the platform switched to per-tenant secrets; any tenant-supplied entries
|
|
24
|
-
* are preserved in order.
|
|
22
|
+
* - `previousSecrets`: Passed through unchanged; the plugin adds no shared secrets.
|
|
25
23
|
* - `editor`: Optional (defaults to lexicalEditor() if not provided)
|
|
26
24
|
* - `contentSystemId`: Optional (resolved automatically from env vars or bootstrap cache)
|
|
27
25
|
*
|
|
@@ -56,6 +54,7 @@ export type FigmaConfig = {
|
|
|
56
54
|
figma: {
|
|
57
55
|
contentSystemId?: string;
|
|
58
56
|
environmentId?: string;
|
|
57
|
+
imageTransforms?: FigmaImageTransformsConfig;
|
|
59
58
|
storage?: {
|
|
60
59
|
uploadInstructionsAccess?: UploadInstructionsAccess;
|
|
61
60
|
} | boolean;
|
|
@@ -3,13 +3,16 @@ import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
|
3
3
|
import { buildConfig as payloadBuildConfig } from 'payload';
|
|
4
4
|
import { deepMergeSimple } from 'payload/shared';
|
|
5
5
|
import { getBootstrapInfo, getEnvironmentVariableByName } from '../api/control-plane.js';
|
|
6
|
+
import { CLI_BUILD_OAUTH_TOKEN_ENV_VAR_NAME } from '../auth/cli-build-context.js';
|
|
6
7
|
import { getValidCredential } from '../auth/oauth-flow.js';
|
|
7
8
|
import { getTokenStore } from '../auth/token-store.js';
|
|
8
9
|
import { getEnvConfig } from '../constants.js';
|
|
9
10
|
import { contentAPIAdapter } from '../db-content-api/index.js';
|
|
10
11
|
import { scheduleExtractPlugin } from '../deploy/schedule-extract-plugin.js';
|
|
12
|
+
import { clientConfig } from '../endpoints/client-config.js';
|
|
11
13
|
import { health } from '../endpoints/health.js';
|
|
12
14
|
import { schema } from '../endpoints/schema.js';
|
|
15
|
+
import { createImageTransformer } from '../image-transforms/createImageTransformer.js';
|
|
13
16
|
import { oAuth2Plugin } from '../oauth/index.js';
|
|
14
17
|
import { getAdminCollectionSlug } from '../oauth/utilities/getAdminCollectionSlug.js';
|
|
15
18
|
import { createStorageClient } from '../storage-content-api/client.js';
|
|
@@ -306,13 +309,13 @@ function messageOf(error) {
|
|
|
306
309
|
/**
|
|
307
310
|
* Plugin that applies cloud storage configuration to all upload-enabled collections.
|
|
308
311
|
* Runs at the end of the plugin chain so it sees collections added by user plugins too.
|
|
309
|
-
*/ function createStoragePlugin(url, contentSystemId, uploadInstructionsAccess) {
|
|
312
|
+
*/ function createStoragePlugin(url, contentSystemId, uploadInstructionsAccess, imageTransforms) {
|
|
310
313
|
return (incomingConfig)=>{
|
|
311
314
|
const uploadCollections = (incomingConfig.collections || []).filter((c)=>c.upload);
|
|
312
315
|
if (uploadCollections.length === 0) {
|
|
313
316
|
return incomingConfig;
|
|
314
317
|
}
|
|
315
|
-
const { adapter } = createStorageConfig(url, contentSystemId, uploadInstructionsAccess);
|
|
318
|
+
const { adapter, storageClient } = createStorageConfig(url, contentSystemId, uploadInstructionsAccess);
|
|
316
319
|
const collectionsMap = uploadCollections.reduce((acc, c)=>{
|
|
317
320
|
acc[c.slug] = {
|
|
318
321
|
adapter,
|
|
@@ -323,11 +326,28 @@ function messageOf(error) {
|
|
|
323
326
|
const storagePlugin = cloudStoragePlugin({
|
|
324
327
|
collections: collectionsMap
|
|
325
328
|
});
|
|
326
|
-
return storagePlugin(
|
|
329
|
+
return storagePlugin({
|
|
330
|
+
...incomingConfig,
|
|
331
|
+
upload: {
|
|
332
|
+
...incomingConfig.upload,
|
|
333
|
+
transformers: [
|
|
334
|
+
...incomingConfig.upload?.transformers ?? [],
|
|
335
|
+
...imageTransforms ? [
|
|
336
|
+
createImageTransformer({
|
|
337
|
+
client: storageClient,
|
|
338
|
+
...imageTransforms
|
|
339
|
+
})
|
|
340
|
+
] : []
|
|
341
|
+
]
|
|
342
|
+
}
|
|
343
|
+
});
|
|
327
344
|
};
|
|
328
345
|
}
|
|
329
346
|
export async function buildFigmaConfig(config) {
|
|
330
347
|
const envConfig = getEnvConfig();
|
|
348
|
+
if (config.figma.imageTransforms && config.figma.storage === false) {
|
|
349
|
+
throw new Error('Figma image transforms require Figma storage');
|
|
350
|
+
}
|
|
331
351
|
// Resolve contentSystemId: config first, env var, then local store fallback (dev)
|
|
332
352
|
let { contentSystemId } = config.figma;
|
|
333
353
|
let environmentId = config.figma.environmentId ?? process.env.FIGMA_EID;
|
|
@@ -383,12 +403,16 @@ export async function buildFigmaConfig(config) {
|
|
|
383
403
|
bootstrapFetched
|
|
384
404
|
}) : '';
|
|
385
405
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
406
|
+
// The Figma login's cookie names, which local dev keeps apart per app
|
|
407
|
+
const devCookieNames = isProduction ? undefined : getDevCookieNames(contentSystemId, config.cookiePrefix);
|
|
386
408
|
// The deployed Lambda runs all queued jobs; locally there is no runner, so the db adapter logs
|
|
387
409
|
// a heads-up whenever a job is queued. Deployed environments set DISABLE_LOCAL_JOB_QUEUE_NOTIFICATIONS=true
|
|
388
410
|
// (injected by the control plane); end-users can also set it locally to silence the notice.
|
|
389
411
|
const notifyLocalJobQueue = process.env.DISABLE_LOCAL_JOB_QUEUE_NOTIFICATIONS !== 'true';
|
|
390
412
|
const usesTokenStoreAuth = !process.env.FIGMA_CONTENT_API_ACCESS_KEY && process.env.FIGMA_DEV_JWT !== 'true';
|
|
391
|
-
|
|
413
|
+
const cliBuildOAuthToken = process.env[CLI_BUILD_OAUTH_TOKEN_ENV_VAR_NAME];
|
|
414
|
+
const hasCliBuildOAuthToken = cliBuildOAuthToken != null && cliBuildOAuthToken !== '';
|
|
415
|
+
if (usesTokenStoreAuth && !hasCliBuildOAuthToken) {
|
|
392
416
|
logMissingCliAuth(getTokenStore());
|
|
393
417
|
}
|
|
394
418
|
// Determine database adapter based on environment
|
|
@@ -430,11 +454,11 @@ export async function buildFigmaConfig(config) {
|
|
|
430
454
|
}
|
|
431
455
|
const userJobsAccessRun = config.jobs?.access?.run;
|
|
432
456
|
const adminCollectionSlug = getAdminCollectionSlug(config);
|
|
433
|
-
// Hosted runtimes
|
|
434
|
-
// the process env is authoritative. Ordinary local dev still checks the
|
|
457
|
+
// Hosted runtimes and Figma CLI builds inject credentials and PAYLOAD_SECRET
|
|
458
|
+
// together, so the process env is authoritative. Ordinary local dev still checks the
|
|
435
459
|
// TokenStore first so a leftover .env value cannot shadow the platform secret.
|
|
436
460
|
let resolvedSecret;
|
|
437
|
-
if (process.env.AWS_EXECUTION_ENV || process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
461
|
+
if (process.env.AWS_EXECUTION_ENV || process.env.FIGMA_CONTENT_API_ACCESS_KEY || hasCliBuildOAuthToken) {
|
|
438
462
|
resolvedSecret = process.env.PAYLOAD_SECRET;
|
|
439
463
|
} else {
|
|
440
464
|
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID');
|
|
@@ -489,7 +513,8 @@ export async function buildFigmaConfig(config) {
|
|
|
489
513
|
endpoints: [
|
|
490
514
|
...config.endpoints ?? [],
|
|
491
515
|
health,
|
|
492
|
-
schema
|
|
516
|
+
schema,
|
|
517
|
+
clientConfig
|
|
493
518
|
],
|
|
494
519
|
i18n: {
|
|
495
520
|
...config.i18n,
|
|
@@ -530,18 +555,11 @@ export async function buildFigmaConfig(config) {
|
|
|
530
555
|
options: {}
|
|
531
556
|
}
|
|
532
557
|
} : {},
|
|
533
|
-
// The platform owns rotation of PAYLOAD_SECRET; this compat entry lets
|
|
534
|
-
// data encrypted under the old shared hosted secret keep decrypting.
|
|
535
|
-
// Appended last so any tenant-supplied previousSecrets are honored first.
|
|
536
|
-
previousSecrets: [
|
|
537
|
-
...config.previousSecrets ?? [],
|
|
538
|
-
Buffer.from('TVlfU0VDUkVU', 'base64').toString('utf8')
|
|
539
|
-
],
|
|
540
558
|
// Add oauth to plugins if not already present
|
|
541
559
|
plugins: [
|
|
542
560
|
...config.plugins ?? [],
|
|
543
561
|
...config.figma.storage !== false ? [
|
|
544
|
-
createStoragePlugin(url, contentSystemId, typeof config.figma.storage === 'object' ? config.figma.storage.uploadInstructionsAccess : undefined)
|
|
562
|
+
createStoragePlugin(url, contentSystemId, typeof config.figma.storage === 'object' ? config.figma.storage.uploadInstructionsAccess : undefined, config.figma.imageTransforms)
|
|
545
563
|
] : [],
|
|
546
564
|
oAuth2Plugin({
|
|
547
565
|
collections: [
|
|
@@ -562,12 +580,15 @@ export async function buildFigmaConfig(config) {
|
|
|
562
580
|
usernameField: 'email'
|
|
563
581
|
}
|
|
564
582
|
],
|
|
565
|
-
...
|
|
583
|
+
...devCookieNames,
|
|
566
584
|
debug: !!process.env.DEBUG,
|
|
567
585
|
disabled: false
|
|
568
586
|
}),
|
|
569
587
|
scheduleExtractPlugin(),
|
|
570
|
-
createMCPOAuthPlugin(
|
|
588
|
+
createMCPOAuthPlugin({
|
|
589
|
+
// Where the Figma login above keeps its refresh token
|
|
590
|
+
refreshTokenCookie: `${devCookieNames?.cookieName ?? 'payload-oauth-token'}-refresh`
|
|
591
|
+
}),
|
|
571
592
|
// Not folded into createStoragePlugin, which is skipped when
|
|
572
593
|
// figma.storage is false and would break remote uploads for those apps.
|
|
573
594
|
createSandboxUploadFetchPlugin({
|