@payloadcms/figma 0.0.1-alpha.67 → 0.0.1-alpha.68
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.
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { Config, SanitizedConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Worker-trusted marker injected by Figma's sites-worker after it validates the
|
|
4
|
+
* X-Figma-Job-Queues-Auth-Bypass secret on a Payload jobs endpoint. The default
|
|
5
|
+
* `jobs.access.run` below honors this marker so Sinatra (async-job-workflow)
|
|
6
|
+
* can drive job runs without the bypass secret ever reaching tenant code.
|
|
7
|
+
*
|
|
8
|
+
* KEEP_IN_SYNC(cloudflare/wrangler/sites-worker/src/auth.ts): FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER
|
|
9
|
+
*/
|
|
10
|
+
export declare const FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER = "figma-internal-forwarded-has-auth-bypass";
|
|
2
11
|
/**
|
|
3
12
|
* Configuration type for Payload projects on the Figma platform.
|
|
4
13
|
*
|
|
@@ -20,6 +20,14 @@ import * as log from '../utils/log.js';
|
|
|
20
20
|
import { logMissingCliAuth } from './auth-preflight.js';
|
|
21
21
|
import { logMissingContentSystemId } from './bootstrap-preflight.js';
|
|
22
22
|
import { getDevCookieNames } from './dev-cookie-names.js';
|
|
23
|
+
/**
|
|
24
|
+
* Worker-trusted marker injected by Figma's sites-worker after it validates the
|
|
25
|
+
* X-Figma-Job-Queues-Auth-Bypass secret on a Payload jobs endpoint. The default
|
|
26
|
+
* `jobs.access.run` below honors this marker so Sinatra (async-job-workflow)
|
|
27
|
+
* can drive job runs without the bypass secret ever reaching tenant code.
|
|
28
|
+
*
|
|
29
|
+
* KEEP_IN_SYNC(cloudflare/wrangler/sites-worker/src/auth.ts): FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER
|
|
30
|
+
*/ export const FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER = 'figma-internal-forwarded-has-auth-bypass';
|
|
23
31
|
/**
|
|
24
32
|
* Fields added to users collection for Figma profile info
|
|
25
33
|
*/ const figmaUserFields = [
|
|
@@ -243,6 +251,7 @@ export async function buildFigmaConfig(config) {
|
|
|
243
251
|
url
|
|
244
252
|
});
|
|
245
253
|
}
|
|
254
|
+
const userJobsAccessRun = config.jobs?.access?.run;
|
|
246
255
|
// Build complete config with Figma platform defaults
|
|
247
256
|
const configWithFigmaDefaults = {
|
|
248
257
|
...config,
|
|
@@ -267,6 +276,25 @@ export async function buildFigmaConfig(config) {
|
|
|
267
276
|
health,
|
|
268
277
|
schema
|
|
269
278
|
],
|
|
279
|
+
// Gate /api/payload-jobs/run and /api/payload-jobs/handle-schedules. Honor the
|
|
280
|
+
// sites-worker trust marker so Figma infra job runs never break, defer to the
|
|
281
|
+
// tenant's jobs.access.run if they set one, otherwise fall back to Payload's
|
|
282
|
+
// "logged-in user" default so the admin "Run jobs" UI keeps working.
|
|
283
|
+
jobs: {
|
|
284
|
+
...config.jobs ?? {},
|
|
285
|
+
access: {
|
|
286
|
+
...config.jobs?.access ?? {},
|
|
287
|
+
run: (args)=>{
|
|
288
|
+
if (args.req.headers.get(FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER) === '1') {
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
if (userJobsAccessRun) {
|
|
292
|
+
return userJobsAccessRun(args);
|
|
293
|
+
}
|
|
294
|
+
return !!args.req.user;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
270
298
|
...isProduction && !config.logger ? {
|
|
271
299
|
logger: {
|
|
272
300
|
options: {}
|