@payloadcms/figma 0.1.0-internal.e071575 → 1.0.0-beta.0
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/LICENSE.md +1 -1
- package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
- package/dist/adapters/asset-collection.js +242 -0
- package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
- package/dist/adapters/build-lambda-zip.js +111 -0
- package/dist/adapters/configureNextjsCache.d.ts +8 -0
- package/dist/adapters/configureNextjsCache.js +55 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/adapters/deploy-output/isFile.d.ts +1 -0
- package/dist/adapters/deploy-output/isFile.js +4 -0
- package/dist/adapters/deploy-output/readJson.d.ts +1 -0
- package/dist/adapters/deploy-output/readJson.js +9 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
- package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/adapters/deploy-output/resolveWithin.js +12 -0
- package/dist/adapters/fs-utils.d.ts +39 -0
- package/dist/adapters/fs-utils.js +135 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
- package/dist/adapters/nextjs.d.ts +12 -0
- package/dist/adapters/nextjs.js +67 -0
- package/dist/adapters/nitro.d.ts +8 -0
- package/dist/adapters/nitro.js +193 -0
- package/dist/adapters/secret-files.d.ts +25 -0
- package/dist/adapters/secret-files.js +50 -0
- package/dist/adapters/types.d.ts +42 -0
- package/dist/adapters/types.js +1 -0
- package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
- package/dist/adapters/vite.js +33 -0
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +12 -9
- package/dist/api/control-plane.js +28 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +73 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +30 -8
- package/dist/auth/refresh.js +12 -12
- package/dist/auth/requested-scopes.d.ts +1 -0
- package/dist/auth/requested-scopes.js +3 -0
- package/dist/auth/token-store.d.ts +20 -1
- package/dist/auth/token-store.js +47 -0
- package/dist/auth/types.d.ts +17 -3
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +5 -1
- package/dist/commands/build-lambda-zip.js +1 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +63 -25
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +235 -80
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/upgrade.js +65 -1
- package/dist/commands/upload-schema.js +3 -4
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/config/oauth.js +6 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -3
- package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
- package/dist/db-content-api/index.d.ts +1 -1
- package/dist/db-content-api/index.js +121 -72
- package/dist/db-content-api/utilities/data/index.js +8 -2
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/joins.js +5 -1
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +9 -4
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.d.ts +2 -6
- package/dist/db-content-api/utilities/where.js +20 -9
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/views.d.ts +1 -0
- package/dist/exports/views.js +1 -0
- package/dist/imageSizeOptions.d.ts +23 -0
- package/dist/imageSizeOptions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/next/image-loader.d.ts +6 -0
- package/dist/next/image-loader.js +14 -0
- package/dist/oauth/components/LoginButton/index.js +66 -19
- package/dist/oauth/components/LoginButton/index.scss +121 -15
- package/dist/oauth/defaults.js +4 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
- package/dist/oauth/index.js +8 -7
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
- package/dist/plugin/build-config.d.ts +13 -3
- package/dist/plugin/build-config.js +250 -49
- package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
- package/dist/plugin/cache-revalidation-hooks.js +69 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +3 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/routes.d.ts +2 -0
- package/dist/plugin/cloud-limits/routes.js +4 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +52 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
- package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
- package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
- package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +22 -20
- package/dist/plugin/sandbox-upload-fetch.js +15 -21
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/storage-content-api/api-types.d.ts +5 -2
- package/dist/storage-content-api/buildBaseMediaResponseHeaders.d.ts +1 -0
- package/dist/storage-content-api/buildBaseMediaResponseHeaders.js +8 -0
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +12 -0
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +26 -0
- package/dist/storage-content-api/buildMediaRequestHeaders.d.ts +1 -0
- package/dist/storage-content-api/buildMediaRequestHeaders.js +14 -0
- package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +4 -0
- package/dist/storage-content-api/buildMediaResponseHeaders.js +52 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +7 -3
- package/dist/storage-content-api/client-uploads/generate.js +22 -21
- package/dist/storage-content-api/copyFile.d.ts +16 -0
- package/dist/storage-content-api/copyFile.js +90 -0
- package/dist/storage-content-api/deleteFile.d.ts +8 -0
- package/dist/storage-content-api/deleteFile.js +18 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +33 -0
- package/dist/storage-content-api/getMediaType.d.ts +1 -0
- package/dist/storage-content-api/getMediaType.js +3 -0
- package/dist/storage-content-api/handleUpload.d.ts +1 -2
- package/dist/storage-content-api/handleUpload.js +13 -157
- package/dist/storage-content-api/hasSupportedContentEncoding.d.ts +1 -0
- package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
- package/dist/storage-content-api/index.js +17 -8
- package/dist/storage-content-api/mediaErrorResponse.d.ts +1 -0
- package/dist/storage-content-api/mediaErrorResponse.js +12 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
- package/dist/storage-content-api/shouldAttachMedia.d.ts +1 -0
- package/dist/storage-content-api/shouldAttachMedia.js +34 -0
- package/dist/storage-content-api/staticHandler.d.ts +2 -1
- package/dist/storage-content-api/staticHandler.js +87 -32
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/storage-content-api/uploadFileData.d.ts +10 -0
- package/dist/storage-content-api/uploadFileData.js +145 -0
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/cache-bootstrap.js +1 -0
- package/dist/utils/deploy-adapter.d.ts +3 -35
- package/dist/utils/deploy-adapter.js +25 -14
- package/dist/utils/env-management.d.ts +15 -0
- package/dist/utils/env-management.js +47 -0
- package/dist/utils/lambda-config.js +18 -23
- package/dist/utils/load-payload-config.js +1 -6
- package/dist/utils/messages.js +24 -3
- package/dist/utils/next-image-loader-config.d.ts +2 -0
- package/dist/utils/next-image-loader-config.js +63 -0
- package/dist/utils/next-image-loader-file.d.ts +2 -0
- package/dist/utils/next-image-loader-file.js +11 -0
- package/dist/utils/payload-config-ast.d.ts +5 -0
- package/dist/utils/payload-config-ast.js +73 -4
- package/dist/utils/payload-config-modifier.js +3 -0
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/payload-secret.d.ts +28 -0
- package/dist/utils/payload-secret.js +34 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/dist/utils/s3-upload.js +4 -1
- package/package.json +32 -7
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/storage-content-api/handleDelete.d.ts +0 -7
- package/dist/storage-content-api/handleDelete.js +0 -15
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +0 -11
- package/dist/storage-content-api/utilities/getSafeFilename.js +0 -59
- package/dist/storage-content-api/utilities/index.d.ts +0 -2
- package/dist/storage-content-api/utilities/index.js +0 -2
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +0 -17
- package/dist/storage-content-api/utilities/parseUploadReference.js +0 -27
- package/dist/utils/adapters/nextjs.d.ts +0 -8
- package/dist/utils/adapters/nextjs.js +0 -61
- package/dist/utils/adapters/nitro.d.ts +0 -8
- package/dist/utils/adapters/nitro.js +0 -172
- package/dist/utils/adapters/vite.js +0 -31
- package/dist/utils/asset-collection.js +0 -144
- package/dist/utils/build-lambda-zip.js +0 -90
- package/dist/utils/fs-utils.d.ts +0 -12
- package/dist/utils/fs-utils.js +0 -55
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getAuthHeaders } from '../auth/credentials.js';
|
|
2
|
+
import { getEnvConfig } from '../constants.js';
|
|
3
|
+
import { controlPlaneFetch } from './control-plane-fetch.js';
|
|
4
|
+
export async function createProject({ name, credential, description, parentPlanKey, region, resourceType, subdomain }) {
|
|
5
|
+
if (process.env.FIGMA_MOCK_CONTROL_PLANE === 'true') {
|
|
6
|
+
return {
|
|
7
|
+
id: `cms_${Math.random().toString(36).substring(2, 11)}`,
|
|
8
|
+
name,
|
|
9
|
+
domainName: `${subdomain}.figmasource.site`
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const response = await controlPlaneFetch({
|
|
13
|
+
context: 'create project',
|
|
14
|
+
options: {
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
name,
|
|
17
|
+
description,
|
|
18
|
+
parent_plan_key: parentPlanKey,
|
|
19
|
+
region,
|
|
20
|
+
resource_type: resourceType,
|
|
21
|
+
subdomain
|
|
22
|
+
}),
|
|
23
|
+
headers: {
|
|
24
|
+
...getAuthHeaders(credential),
|
|
25
|
+
'Content-Type': 'application/json'
|
|
26
|
+
},
|
|
27
|
+
method: 'POST'
|
|
28
|
+
},
|
|
29
|
+
url: `${getEnvConfig().apiBaseUrl}/v1/cms`
|
|
30
|
+
});
|
|
31
|
+
const projectResponse = await response.json();
|
|
32
|
+
return {
|
|
33
|
+
id: projectResponse.meta.tenant.id,
|
|
34
|
+
name: projectResponse.meta.tenant.name,
|
|
35
|
+
domainName: projectResponse.meta.tenant.domain_name
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AuthCredential } from '../auth/credentials.js';
|
|
2
|
+
interface ProjectWorkspace {
|
|
3
|
+
isDefault: boolean;
|
|
4
|
+
name: string;
|
|
5
|
+
planKey: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function listProjectWorkspaces(credential: AuthCredential): Promise<ProjectWorkspace[]>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAuthHeaders } from '../auth/credentials.js';
|
|
2
|
+
import { getEnvConfig } from '../constants.js';
|
|
3
|
+
import { controlPlaneFetch } from './control-plane-fetch.js';
|
|
4
|
+
export async function listProjectWorkspaces(credential) {
|
|
5
|
+
if (process.env.FIGMA_MOCK_CONTROL_PLANE === 'true') {
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
name: 'Mock workspace',
|
|
9
|
+
isDefault: true,
|
|
10
|
+
planKey: 'team::mock-workspace'
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
const response = await controlPlaneFetch({
|
|
15
|
+
context: 'list project workspaces',
|
|
16
|
+
options: {
|
|
17
|
+
headers: getAuthHeaders(credential),
|
|
18
|
+
method: 'POST'
|
|
19
|
+
},
|
|
20
|
+
url: `${getEnvConfig().apiBaseUrl}/v1/cms/workspaces`
|
|
21
|
+
});
|
|
22
|
+
const workspaceResponse = await response.json();
|
|
23
|
+
return workspaceResponse.meta.workspaces.map((workspace)=>({
|
|
24
|
+
name: workspace.name,
|
|
25
|
+
isDefault: workspace.is_default,
|
|
26
|
+
planKey: workspace.plan_key
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ProjectResourceType = 'payload' | 'vite';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TokenStore } from './token-store.js';
|
|
2
|
+
export interface StartHeadlessOAuthFlowResult {
|
|
3
|
+
authorizationUrl: string;
|
|
4
|
+
expiresAt: number;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class HeadlessOAuthFlowError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** Start OAuth without a callback listener so another process can resume it. */
|
|
11
|
+
export declare function startHeadlessOAuthFlow(tokenStore: TokenStore, options?: {
|
|
12
|
+
now?: number;
|
|
13
|
+
}): StartHeadlessOAuthFlowResult;
|
|
14
|
+
/** Complete a previously started headless OAuth flow and store its tokens. */
|
|
15
|
+
export declare function completeHeadlessOAuthFlow({ callbackUrl, now, sessionId, tokenStore, }: {
|
|
16
|
+
callbackUrl: string;
|
|
17
|
+
now?: number;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
tokenStore: TokenStore;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
tokens: import("./types.js").FigmaTokens;
|
|
22
|
+
userId: string | undefined;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { getOAuthConfig } from '../config/oauth.js';
|
|
3
|
+
import { buildAuthorizationUrl } from './browser.js';
|
|
4
|
+
import { parsePastedCode } from './paste-code.js';
|
|
5
|
+
import { generatePKCEPair } from './pkce.js';
|
|
6
|
+
import { exchangeCodeForTokens } from './refresh.js';
|
|
7
|
+
import { hasRequestedScopes } from './requested-scopes.js';
|
|
8
|
+
const HEADLESS_OAUTH_SESSION_TTL_MS = 10 * 60 * 1000;
|
|
9
|
+
export class HeadlessOAuthFlowError extends Error {
|
|
10
|
+
constructor(message){
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'HeadlessOAuthFlowError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Start OAuth without a callback listener so another process can resume it. */ export function startHeadlessOAuthFlow(tokenStore, options = {}) {
|
|
16
|
+
const oauthConfig = getOAuthConfig();
|
|
17
|
+
const { codeChallenge, codeChallengeMethod, codeVerifier } = generatePKCEPair();
|
|
18
|
+
const now = options.now ?? Date.now();
|
|
19
|
+
const session = {
|
|
20
|
+
id: crypto.randomBytes(32).toString('base64url'),
|
|
21
|
+
clientId: oauthConfig.clientId,
|
|
22
|
+
codeVerifier,
|
|
23
|
+
expiresAt: now + HEADLESS_OAUTH_SESSION_TTL_MS,
|
|
24
|
+
redirectUri: oauthConfig.redirectUri,
|
|
25
|
+
state: crypto.randomBytes(32).toString('base64url')
|
|
26
|
+
};
|
|
27
|
+
tokenStore.setHeadlessOAuthSession(session);
|
|
28
|
+
return {
|
|
29
|
+
authorizationUrl: buildAuthorizationUrl({
|
|
30
|
+
authorizationUrl: oauthConfig.authorizationUrl,
|
|
31
|
+
clientId: session.clientId,
|
|
32
|
+
codeChallenge,
|
|
33
|
+
codeChallengeMethod,
|
|
34
|
+
redirectUri: session.redirectUri,
|
|
35
|
+
scopes: oauthConfig.scopes,
|
|
36
|
+
state: session.state
|
|
37
|
+
}),
|
|
38
|
+
expiresAt: session.expiresAt,
|
|
39
|
+
sessionId: session.id
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Complete a previously started headless OAuth flow and store its tokens. */ export async function completeHeadlessOAuthFlow({ callbackUrl, now = Date.now(), sessionId, tokenStore }) {
|
|
43
|
+
const session = tokenStore.getHeadlessOAuthSession();
|
|
44
|
+
if (!session) {
|
|
45
|
+
throw new HeadlessOAuthFlowError('No pending login found. Start login again with --headless.');
|
|
46
|
+
}
|
|
47
|
+
if (session.id !== sessionId) {
|
|
48
|
+
throw new HeadlessOAuthFlowError('Login session does not match. Start login again with --headless.');
|
|
49
|
+
}
|
|
50
|
+
if (now >= session.expiresAt) {
|
|
51
|
+
tokenStore.clearHeadlessOAuthSession();
|
|
52
|
+
throw new HeadlessOAuthFlowError('Login session expired. Start login again with --headless.');
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
try {
|
|
56
|
+
new URL(callbackUrl);
|
|
57
|
+
} catch {
|
|
58
|
+
throw new HeadlessOAuthFlowError('Paste the full redirected URL so the login state can be verified.');
|
|
59
|
+
}
|
|
60
|
+
const code = parsePastedCode(callbackUrl, session.state);
|
|
61
|
+
const tokens = await exchangeCodeForTokens(code, session.codeVerifier, session.redirectUri, session.clientId);
|
|
62
|
+
if (!hasRequestedScopes(tokens.scopes, getOAuthConfig().scopes)) {
|
|
63
|
+
throw new HeadlessOAuthFlowError('Authorization did not grant all requested Cloud scopes');
|
|
64
|
+
}
|
|
65
|
+
tokenStore.setTokens(tokens);
|
|
66
|
+
return {
|
|
67
|
+
tokens,
|
|
68
|
+
userId: tokens.userId
|
|
69
|
+
};
|
|
70
|
+
} finally{
|
|
71
|
+
tokenStore.clearHeadlessOAuthSession();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -16,6 +16,8 @@ export interface OAuthFlowOptions {
|
|
|
16
16
|
clientId?: string;
|
|
17
17
|
/** Callback server fallback ports to try after port */
|
|
18
18
|
fallbackPorts?: number[];
|
|
19
|
+
/** Open the browser without asking for confirmation */
|
|
20
|
+
openBrowserWithoutPrompt?: boolean;
|
|
19
21
|
/** First callback server port to try */
|
|
20
22
|
port?: number;
|
|
21
23
|
/** Redirect URI (defaults to config) */
|
package/dist/auth/oauth-flow.js
CHANGED
|
@@ -7,6 +7,7 @@ import { CallbackError, CallbackServer } from './callback-server.js';
|
|
|
7
7
|
import { parsePastedCode, validatePastedCode } from './paste-code.js';
|
|
8
8
|
import { generatePKCEPair } from './pkce.js';
|
|
9
9
|
import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './refresh.js';
|
|
10
|
+
import { hasRequestedScopes } from './requested-scopes.js';
|
|
10
11
|
/**
|
|
11
12
|
* Error during OAuth flow
|
|
12
13
|
*/ export class OAuthFlowError extends Error {
|
|
@@ -54,7 +55,7 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
// REAL OAUTH IMPLEMENTATION
|
|
57
|
-
const { clientId = oauthConfig.clientId, fallbackPorts, port, redirectUri = oauthConfig.redirectUri, scopes = oauthConfig.scopes, timeoutMs = 120000 } = options;
|
|
58
|
+
const { clientId = oauthConfig.clientId, fallbackPorts, openBrowserWithoutPrompt = false, port, redirectUri = oauthConfig.redirectUri, scopes = oauthConfig.scopes, timeoutMs = 120000 } = options;
|
|
58
59
|
// Generate PKCE pair for enhanced security
|
|
59
60
|
const { codeChallenge, codeChallengeMethod, codeVerifier } = generatePKCEPair();
|
|
60
61
|
// Generate random state for CSRF protection
|
|
@@ -85,13 +86,18 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
85
86
|
scopes,
|
|
86
87
|
state
|
|
87
88
|
});
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
// Ask interactive callers before opening a browser. Automated callers have
|
|
90
|
+
// already accepted defaults with -y, so proceed directly to authorization.
|
|
91
|
+
let shouldOpenBrowser = openBrowserWithoutPrompt;
|
|
92
|
+
if (!openBrowserWithoutPrompt) {
|
|
93
|
+
const browserConfirmation = await p.confirm({
|
|
94
|
+
initialValue: true,
|
|
95
|
+
message: 'Open browser to authenticate with Figma?'
|
|
96
|
+
});
|
|
97
|
+
if (p.isCancel(browserConfirmation)) {
|
|
98
|
+
throw new OAuthFlowError('Authentication cancelled by user');
|
|
99
|
+
}
|
|
100
|
+
shouldOpenBrowser = browserConfirmation;
|
|
95
101
|
}
|
|
96
102
|
let browserOpened = false;
|
|
97
103
|
if (shouldOpenBrowser) {
|
|
@@ -125,6 +131,9 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
125
131
|
} catch (error) {
|
|
126
132
|
throw new OAuthFlowError('Failed to exchange authorization code for tokens', error instanceof Error ? error : undefined);
|
|
127
133
|
}
|
|
134
|
+
if (!hasRequestedScopes(tokens.scopes, scopes)) {
|
|
135
|
+
throw new OAuthFlowError('Authorization did not grant all requested Cloud scopes');
|
|
136
|
+
}
|
|
128
137
|
// Store tokens
|
|
129
138
|
try {
|
|
130
139
|
tokenStore.setTokens(tokens);
|
|
@@ -157,6 +166,13 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
157
166
|
* @returns Promise resolving to AuthCredential (wrapped access token) or null if no valid tokens
|
|
158
167
|
* @throws OAuthFlowError if refresh fails
|
|
159
168
|
*/ export async function getValidOAuthAccessToken(tokenStore) {
|
|
169
|
+
const cached = tokenStore.getOauthInfo();
|
|
170
|
+
const requiredScopes = getOAuthConfig().scopes;
|
|
171
|
+
// Older cached grants lack scope metadata or the Cloud capabilities. Refreshing
|
|
172
|
+
// them cannot add consent, so start a new authorization flow instead.
|
|
173
|
+
if (cached && !hasRequestedScopes(cached.scopes, requiredScopes)) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
160
176
|
// Check if we have valid tokens
|
|
161
177
|
if (tokenStore.hasValidOauthToken()) {
|
|
162
178
|
const token = tokenStore.getCurrentOauthToken();
|
|
@@ -174,6 +190,9 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
174
190
|
try {
|
|
175
191
|
const tokens = await refreshAccessToken(refreshToken);
|
|
176
192
|
tokenStore.setTokens(tokens);
|
|
193
|
+
if (!hasRequestedScopes(tokens.scopes, requiredScopes)) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
177
196
|
return {
|
|
178
197
|
type: 'oauth',
|
|
179
198
|
token: tokens.accessToken
|
|
@@ -185,6 +204,9 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
|
|
|
185
204
|
try {
|
|
186
205
|
const tokens = await refreshAccessToken(refreshToken);
|
|
187
206
|
tokenStore.setTokens(tokens);
|
|
207
|
+
if (!hasRequestedScopes(tokens.scopes, requiredScopes)) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
188
210
|
return {
|
|
189
211
|
type: 'oauth',
|
|
190
212
|
token: tokens.accessToken
|
package/dist/auth/refresh.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/* eslint-disable perfectionist/sort-objects */ import { getOAuthConfig } from '../config/oauth.js';
|
|
2
2
|
import * as log from '../utils/log.js';
|
|
3
|
+
function parseGrantedScopes(scope) {
|
|
4
|
+
return scope?.split(/[\s,]+/).filter(Boolean);
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Error thrown when token refresh fails
|
|
5
8
|
*/ export class TokenRefreshError extends Error {
|
|
@@ -50,15 +53,17 @@ import * as log from '../utils/log.js';
|
|
|
50
53
|
}
|
|
51
54
|
const data = await response.json();
|
|
52
55
|
// Validate response contains required fields
|
|
53
|
-
if (!data.access_token || !data.
|
|
56
|
+
if (!data.access_token || !data.expires_in) {
|
|
54
57
|
throw new TokenRefreshError('Invalid token response: missing required fields');
|
|
55
58
|
}
|
|
56
59
|
// Convert response to our internal token format
|
|
57
60
|
const expiresAt = Date.now() + data.expires_in * 1000;
|
|
58
61
|
return {
|
|
59
62
|
accessToken: data.access_token,
|
|
60
|
-
refreshToken: data.refresh_token,
|
|
63
|
+
refreshToken: data.refresh_token ?? refreshToken,
|
|
61
64
|
expiresAt,
|
|
65
|
+
scopes: parseGrantedScopes(data.scope),
|
|
66
|
+
tokenType: data.token_type,
|
|
62
67
|
userId: data.user_id_string
|
|
63
68
|
};
|
|
64
69
|
} catch (error) {
|
|
@@ -99,12 +104,7 @@ import * as log from '../utils/log.js';
|
|
|
99
104
|
const headers = {
|
|
100
105
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
101
106
|
};
|
|
102
|
-
|
|
103
|
-
log.debug(`Token exchange request: ${JSON.stringify({
|
|
104
|
-
url: oauthConfig.tokenUrl,
|
|
105
|
-
headers,
|
|
106
|
-
body: params.toString()
|
|
107
|
-
})}`);
|
|
107
|
+
log.debug(`Token exchange request to ${oauthConfig.tokenUrl}`);
|
|
108
108
|
const response = await fetch(oauthConfig.tokenUrl, {
|
|
109
109
|
method: 'POST',
|
|
110
110
|
headers,
|
|
@@ -117,17 +117,15 @@ import * as log from '../utils/log.js';
|
|
|
117
117
|
})}`);
|
|
118
118
|
if (!response.ok) {
|
|
119
119
|
const errorText = await response.text();
|
|
120
|
-
log.debug(`
|
|
120
|
+
log.debug(`Token exchange rejected with status ${response.status}`);
|
|
121
121
|
throw new TokenRefreshError(`Token exchange failed: ${response.statusText}. ${errorText}`, response.status);
|
|
122
122
|
}
|
|
123
123
|
const data = await response.json();
|
|
124
124
|
log.debug(`Token response: ${JSON.stringify({
|
|
125
|
-
access_token: data.access_token,
|
|
126
125
|
token_type: data.token_type,
|
|
127
126
|
expires_in: data.expires_in,
|
|
128
127
|
scope: data.scope,
|
|
129
|
-
user_id_string: data.user_id_string
|
|
130
|
-
refresh_token: data.refresh_token?.substring(0, 10) + '...'
|
|
128
|
+
user_id_string: data.user_id_string
|
|
131
129
|
})}`);
|
|
132
130
|
// Validate response contains required fields
|
|
133
131
|
if (!data.access_token || !data.refresh_token || !data.expires_in) {
|
|
@@ -139,6 +137,8 @@ import * as log from '../utils/log.js';
|
|
|
139
137
|
accessToken: data.access_token,
|
|
140
138
|
refreshToken: data.refresh_token,
|
|
141
139
|
expiresAt,
|
|
140
|
+
scopes: parseGrantedScopes(data.scope),
|
|
141
|
+
tokenType: data.token_type,
|
|
142
142
|
userId: data.user_id_string
|
|
143
143
|
};
|
|
144
144
|
} catch (error) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasRequestedScopes(granted: readonly string[] | undefined, required: readonly string[]): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Environment } from '../constants.js';
|
|
2
|
-
import type { BootstrapData, FigmaTokens, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
|
|
2
|
+
import type { BootstrapData, FigmaTokens, HeadlessOAuthSession, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get the singleton TokenStore instance for an environment.
|
|
5
5
|
*/
|
|
@@ -23,6 +23,9 @@ export declare class TokenStore {
|
|
|
23
23
|
getOauthInfo(): FigmaTokens | null;
|
|
24
24
|
setTokens(tokens: FigmaTokens): void;
|
|
25
25
|
clearTokens(): void;
|
|
26
|
+
getHeadlessOAuthSession(): HeadlessOAuthSession | null;
|
|
27
|
+
setHeadlessOAuthSession(session: HeadlessOAuthSession): void;
|
|
28
|
+
clearHeadlessOAuthSession(): void;
|
|
26
29
|
hasValidOauthToken(): boolean;
|
|
27
30
|
isOauthExpired(): boolean;
|
|
28
31
|
getCurrentOauthToken(): null | string;
|
|
@@ -61,6 +64,22 @@ export declare class TokenStore {
|
|
|
61
64
|
getBootstrapData(projectId: string, environmentName: string): BootstrapData | null;
|
|
62
65
|
setBootstrapData(projectId: string, environmentName: string, data: BootstrapData): void;
|
|
63
66
|
clearBootstrapData(projectId: string, environmentName: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* PAYLOAD_SECRET is fetched from the Control Plane during `init` and
|
|
69
|
+
* cached here per (projectId, environmentName). buildFigmaConfig reads
|
|
70
|
+
* it at local dev startup when process.env.PAYLOAD_SECRET is unset.
|
|
71
|
+
* Platform-injected in Lambda, so this path is never hit there.
|
|
72
|
+
*/
|
|
73
|
+
getPayloadSecret({ projectInfo }?: {
|
|
74
|
+
projectInfo?: ProjectStoreScope;
|
|
75
|
+
}): null | string;
|
|
76
|
+
setPayloadSecret({ projectInfo, secret, }: {
|
|
77
|
+
projectInfo?: ProjectStoreScope;
|
|
78
|
+
secret: string;
|
|
79
|
+
}): void;
|
|
80
|
+
clearPayloadSecret({ projectInfo }?: {
|
|
81
|
+
projectInfo?: ProjectStoreScope;
|
|
82
|
+
}): void;
|
|
64
83
|
private buildOAuthConfigName;
|
|
65
84
|
private buildOAuthStoreCwd;
|
|
66
85
|
private buildProjectStoreConfigName;
|
package/dist/auth/token-store.js
CHANGED
|
@@ -186,11 +186,25 @@ const PROJECT_STORE_SCHEMA_VERSION = 1;
|
|
|
186
186
|
clearTokens() {
|
|
187
187
|
this.oauthConfig.delete('accessToken');
|
|
188
188
|
this.oauthConfig.delete('expiresAt');
|
|
189
|
+
this.oauthConfig.delete('headlessOAuthSession');
|
|
189
190
|
this.oauthConfig.delete('refreshToken');
|
|
190
191
|
this.oauthConfig.delete('scopes');
|
|
191
192
|
this.oauthConfig.delete('tokenType');
|
|
192
193
|
this.oauthConfig.delete('userId');
|
|
193
194
|
}
|
|
195
|
+
getHeadlessOAuthSession() {
|
|
196
|
+
return this.safeGet({
|
|
197
|
+
config: this.oauthConfig,
|
|
198
|
+
key: 'headlessOAuthSession'
|
|
199
|
+
}) ?? null;
|
|
200
|
+
}
|
|
201
|
+
setHeadlessOAuthSession(session) {
|
|
202
|
+
this.oauthConfig.set('_schemaVersion', OAUTH_STORE_SCHEMA_VERSION);
|
|
203
|
+
this.oauthConfig.set('headlessOAuthSession', session);
|
|
204
|
+
}
|
|
205
|
+
clearHeadlessOAuthSession() {
|
|
206
|
+
this.oauthConfig.delete('headlessOAuthSession');
|
|
207
|
+
}
|
|
194
208
|
hasValidOauthToken() {
|
|
195
209
|
const tokens = this.getOauthInfo();
|
|
196
210
|
if (!tokens) {
|
|
@@ -340,6 +354,39 @@ const PROJECT_STORE_SCHEMA_VERSION = 1;
|
|
|
340
354
|
});
|
|
341
355
|
config.delete('bootstrapData');
|
|
342
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* PAYLOAD_SECRET is fetched from the Control Plane during `init` and
|
|
359
|
+
* cached here per (projectId, environmentName). buildFigmaConfig reads
|
|
360
|
+
* it at local dev startup when process.env.PAYLOAD_SECRET is unset.
|
|
361
|
+
* Platform-injected in Lambda, so this path is never hit there.
|
|
362
|
+
*/ getPayloadSecret({ projectInfo } = {}) {
|
|
363
|
+
const resolvedProjectInfo = projectInfo ?? this.getProjectInfoFromEnv();
|
|
364
|
+
if (!resolvedProjectInfo) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
const config = this.getProjectStore(resolvedProjectInfo);
|
|
368
|
+
return this.safeGet({
|
|
369
|
+
config,
|
|
370
|
+
key: 'payloadSecret'
|
|
371
|
+
}) ?? null;
|
|
372
|
+
}
|
|
373
|
+
setPayloadSecret({ projectInfo, secret }) {
|
|
374
|
+
const resolvedProjectInfo = projectInfo ?? this.getProjectInfoFromEnv();
|
|
375
|
+
if (!resolvedProjectInfo) {
|
|
376
|
+
throw new Error('Cannot set payload secret: FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME must be set');
|
|
377
|
+
}
|
|
378
|
+
const config = this.getProjectStore(resolvedProjectInfo);
|
|
379
|
+
config.set('_schemaVersion', PROJECT_STORE_SCHEMA_VERSION);
|
|
380
|
+
config.set('payloadSecret', secret);
|
|
381
|
+
}
|
|
382
|
+
clearPayloadSecret({ projectInfo } = {}) {
|
|
383
|
+
const resolvedProjectInfo = projectInfo ?? this.getProjectInfoFromEnv();
|
|
384
|
+
if (!resolvedProjectInfo) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const config = this.getProjectStore(resolvedProjectInfo);
|
|
388
|
+
config.delete('payloadSecret');
|
|
389
|
+
}
|
|
343
390
|
buildOAuthConfigName() {
|
|
344
391
|
// For test isolation: if using a custom config name, use it as-is with -oauth suffix
|
|
345
392
|
// Otherwise use the standard naming that includes environment
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Environment } from '../constants.js';
|
|
|
5
5
|
* Standard OAuth2 scopes for user-level permissions
|
|
6
6
|
* @see https://www.figma.com/developers/api#oauth2
|
|
7
7
|
*/
|
|
8
|
-
export type FigmaOAuthScope = 'current_user:read' | 'file_comments:read' | 'file_comments:write' | 'file_content:read' | 'file_dev_resources:read' | 'file_dev_resources:write' | 'file_metadata:read' | 'file_variables:read' | 'file_variables:write' | 'file_versions:read' | 'files:read' | 'library_analytics:read' | 'library_assets:read' | 'library_content:read' | 'projects:read' | 'team_library_content:read' | 'webhooks:read' | 'webhooks:write';
|
|
8
|
+
export type FigmaOAuthScope = 'cloud:content:read_write' | 'cloud:create' | 'cloud:deploy' | 'cloud:read' | 'cloud:secrets:read' | 'current_user:read' | 'file_comments:read' | 'file_comments:write' | 'file_content:read' | 'file_dev_resources:read' | 'file_dev_resources:write' | 'file_metadata:read' | 'file_variables:read' | 'file_variables:write' | 'file_versions:read' | 'files:read' | 'library_analytics:read' | 'library_assets:read' | 'library_content:read' | 'projects:read' | 'team_library_content:read' | 'webhooks:read' | 'webhooks:write';
|
|
9
9
|
/**
|
|
10
10
|
* Organization-level OAuth2 scopes
|
|
11
11
|
* Requires organization admin permissions
|
|
@@ -32,6 +32,18 @@ export interface FigmaTokens {
|
|
|
32
32
|
/** Figma user ID string */
|
|
33
33
|
userId?: string;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Temporary state for a resumable OAuth login. Stored encrypted on the machine
|
|
37
|
+
* that generated the PKCE verifier and removed after completion or expiry.
|
|
38
|
+
*/
|
|
39
|
+
export interface HeadlessOAuthSession {
|
|
40
|
+
clientId: string;
|
|
41
|
+
codeVerifier: string;
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
id: string;
|
|
44
|
+
redirectUri: string;
|
|
45
|
+
state: string;
|
|
46
|
+
}
|
|
35
47
|
/**
|
|
36
48
|
* Raw token response from Figma OAuth2 token endpoint
|
|
37
49
|
* Response from POST https://api.figma.com/v1/oauth/token
|
|
@@ -41,8 +53,8 @@ export interface FigmaTokenResponse {
|
|
|
41
53
|
access_token: string;
|
|
42
54
|
/** Token expiration time in seconds */
|
|
43
55
|
expires_in: number;
|
|
44
|
-
/** OAuth2 refresh token */
|
|
45
|
-
refresh_token
|
|
56
|
+
/** OAuth2 refresh token; omitted when refreshing an existing grant */
|
|
57
|
+
refresh_token?: string;
|
|
46
58
|
/** Space-separated list of granted scopes */
|
|
47
59
|
scope?: string;
|
|
48
60
|
/** Token type (typically "Bearer") */
|
|
@@ -177,6 +189,8 @@ export type FigmaUser = User;
|
|
|
177
189
|
* Keyed by projectId:environmentName
|
|
178
190
|
*/
|
|
179
191
|
export type BootstrapData = {
|
|
192
|
+
/** Regional Content API base URL. Absent in entries cached before bootstrap returned it. */
|
|
193
|
+
contentApiUrl?: string;
|
|
180
194
|
contentSystemId: string;
|
|
181
195
|
oauthClientId: string;
|
|
182
196
|
oauthClientSecret: string;
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
export declare const cliArgSpec: {
|
|
2
|
+
readonly '--adapter': StringConstructor;
|
|
3
|
+
readonly '--all': BooleanConstructor;
|
|
4
|
+
readonly '--callback-url': StringConstructor;
|
|
5
|
+
readonly '--complete': StringConstructor;
|
|
6
|
+
readonly '--debug': BooleanConstructor;
|
|
7
|
+
readonly '--description': StringConstructor;
|
|
8
|
+
readonly '--dry-run': BooleanConstructor;
|
|
9
|
+
readonly '--env': StringConstructor;
|
|
10
|
+
readonly '--force': BooleanConstructor;
|
|
11
|
+
readonly '--global': BooleanConstructor;
|
|
12
|
+
readonly '--headless': BooleanConstructor;
|
|
13
|
+
readonly '--help': BooleanConstructor;
|
|
14
|
+
readonly '--id': StringConstructor;
|
|
15
|
+
readonly '--infra-env': StringConstructor;
|
|
16
|
+
readonly '--json': BooleanConstructor;
|
|
17
|
+
readonly '--name': StringConstructor;
|
|
18
|
+
readonly '--no-agent': BooleanConstructor;
|
|
19
|
+
readonly '--output': StringConstructor;
|
|
20
|
+
readonly '--payload-version': StringConstructor;
|
|
21
|
+
readonly '--project': BooleanConstructor;
|
|
22
|
+
readonly '--region': StringConstructor;
|
|
23
|
+
readonly '--skip-auth': BooleanConstructor;
|
|
24
|
+
readonly '--skip-build': BooleanConstructor;
|
|
25
|
+
readonly '--skip-size-check': BooleanConstructor;
|
|
26
|
+
readonly '--subdomain': StringConstructor;
|
|
27
|
+
readonly '--template': StringConstructor;
|
|
28
|
+
readonly '--version': BooleanConstructor;
|
|
29
|
+
readonly '--workspace': StringConstructor;
|
|
30
|
+
readonly '--yes': BooleanConstructor;
|
|
31
|
+
readonly '--environment': "--env";
|
|
32
|
+
readonly '-e': "--env";
|
|
33
|
+
readonly '-f': "--force";
|
|
34
|
+
readonly '-h': "--help";
|
|
35
|
+
readonly '-n': "--name";
|
|
36
|
+
readonly '-t': "--template";
|
|
37
|
+
readonly '-v': "--version";
|
|
38
|
+
readonly '-y': "--yes";
|
|
39
|
+
};
|
|
1
40
|
/**
|
|
2
41
|
* Entrypoint for bin/cli.js
|
|
3
42
|
*/
|