@payloadcms/figma 0.0.1-alpha.7 → 0.0.1-alpha.71
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/api/control-plane.d.ts +56 -6
- package/dist/api/control-plane.js +181 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.d.ts +19 -7
- package/dist/auth/callback-server.js +72 -30
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +28 -0
- package/dist/auth/crypto-utils.js +132 -21
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +19 -3
- package/dist/auth/oauth-flow.js +77 -22
- package/dist/auth/project-token.d.ts +32 -16
- package/dist/auth/project-token.js +171 -65
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store-migration.d.ts +58 -0
- package/dist/auth/token-store-migration.js +156 -0
- package/dist/auth/token-store.d.ts +63 -97
- package/dist/auth/token-store.js +405 -122
- package/dist/auth/types.d.ts +35 -4
- package/dist/cli.js +93 -6
- package/dist/commands/bootstrap.d.ts +18 -0
- package/dist/commands/bootstrap.js +90 -0
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +180 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +180 -151
- package/dist/commands/dump-tokens.d.ts +12 -0
- package/dist/commands/dump-tokens.js +69 -0
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +9 -5
- package/dist/commands/init.js +241 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +24 -9
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +34 -16
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +77 -15
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +17 -11
- package/dist/config/oauth.js +38 -37
- package/dist/constants.d.ts +63 -18
- package/dist/constants.js +158 -18
- package/dist/db-content-api/generated/content-api-types.d.ts +3978 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +923 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +39 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +39 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +64 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +84 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +68 -0
- package/dist/db-content-api/utilities/data/index.d.ts +49 -0
- package/dist/db-content-api/utilities/data/index.js +301 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
- package/dist/db-content-api/utilities/joins.d.ts +53 -0
- package/dist/db-content-api/utilities/joins.js +139 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +74 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +42 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +41 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +17 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +244 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +62 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +102 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +108 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +11 -0
- package/dist/deploy/schedule-extract-plugin.js +34 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/lib/download-skill.d.ts +13 -0
- package/dist/lib/download-skill.js +79 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +82 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +170 -0
- package/dist/oauth/components/LoginButton/index.js +150 -12
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.js +20 -7
- package/dist/oauth/defaults.d.ts +3 -1
- package/dist/oauth/defaults.js +68 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +72 -77
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -3
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -2
- package/dist/oauth/index.js +27 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +23 -6
- package/dist/oauth/utilities/establishSession.d.ts +23 -0
- package/dist/oauth/utilities/establishSession.js +82 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +24 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +28 -0
- package/dist/oauth/utilities/figmaHostnames.d.ts +3 -0
- package/dist/oauth/utilities/figmaHostnames.js +26 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +2 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +3 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +6 -3
- package/dist/plugin/auth-preflight.d.ts +8 -0
- package/dist/plugin/auth-preflight.js +20 -0
- package/dist/plugin/bootstrap-preflight.d.ts +23 -0
- package/dist/plugin/bootstrap-preflight.js +45 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +327 -17
- package/dist/plugin/dev-cookie-names.d.ts +14 -0
- package/dist/plugin/dev-cookie-names.js +19 -0
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +43 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +39 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +63 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +3 -0
- package/dist/storage-content-api/utilities/index.js +4 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +19 -0
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +30 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +10 -1
- package/dist/utils/adapters/nextjs.d.ts +9 -0
- package/dist/utils/adapters/nextjs.js +64 -0
- package/dist/utils/adapters/nitro.d.ts +9 -0
- package/dist/utils/adapters/nitro.js +169 -0
- package/dist/utils/adapters/vite.d.ts +10 -0
- package/dist/utils/adapters/vite.js +33 -0
- package/dist/utils/asset-collection.d.ts +27 -6
- package/dist/utils/asset-collection.js +59 -30
- package/dist/utils/build-detection.d.ts +5 -11
- package/dist/utils/build-detection.js +74 -11
- package/dist/utils/build-lambda-zip.d.ts +16 -0
- package/dist/utils/build-lambda-zip.js +78 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/deploy-adapter.d.ts +40 -0
- package/dist/utils/deploy-adapter.js +58 -0
- package/dist/utils/download-template.d.ts +9 -1
- package/dist/utils/download-template.js +24 -18
- package/dist/utils/env-management.d.ts +24 -7
- package/dist/utils/env-management.js +119 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +23 -11
- package/dist/utils/fs-utils.d.ts +6 -0
- package/dist/utils/fs-utils.js +27 -0
- package/dist/utils/handle-upgrade.d.ts +9 -0
- package/dist/utils/handle-upgrade.js +41 -0
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +75 -78
- package/dist/utils/messages.d.ts +1 -2
- package/dist/utils/messages.js +39 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/parse-template-spec.d.ts +12 -0
- package/dist/utils/parse-template-spec.js +62 -0
- package/dist/utils/payload-config-ast.d.ts +27 -6
- package/dist/utils/payload-config-ast.js +106 -58
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +114 -66
- package/dist/utils/payload-package-check.d.ts +33 -2
- package/dist/utils/payload-package-check.js +129 -28
- package/dist/utils/project.d.ts +7 -2
- package/dist/utils/project.js +60 -32
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +31 -0
- package/dist/utils/s3-upload.d.ts +7 -2
- package/dist/utils/s3-upload.js +39 -6
- package/dist/utils/token-display.d.ts +5 -1
- package/dist/utils/token-display.js +49 -22
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +44 -15
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { APIError, generateCookie } from 'payload';
|
|
2
|
+
import { getProjectToken, getUserInfo } from '../../api/figma-api.js';
|
|
3
|
+
import { createCookieOptions } from './createCookieOptions.js';
|
|
4
|
+
import { getCookieExpiration } from './getCookieExpiration.js';
|
|
5
|
+
/**
|
|
6
|
+
* Given a valid OAuth access_token: fetch user info (non-fatal), mint a
|
|
7
|
+
* project token, and write the main + refresh + user-info cookies to
|
|
8
|
+
* `req.responseHeaders`. Throws `APIError` if the project token mint fails.
|
|
9
|
+
*/ export const establishSession = async ({ accessToken, collection, collectionOptions, contentSystemId, debugLogger, pluginOptions, refreshTokenExpiresIn, req, strategy })=>{
|
|
10
|
+
const oauthCredential = {
|
|
11
|
+
type: 'oauth',
|
|
12
|
+
token: accessToken
|
|
13
|
+
};
|
|
14
|
+
// Non-fatal: user just won't have handle/image on first request.
|
|
15
|
+
let figmaUserInfo = null;
|
|
16
|
+
try {
|
|
17
|
+
figmaUserInfo = await getUserInfo(oauthCredential);
|
|
18
|
+
debugLogger.info({
|
|
19
|
+
figmaUserInfo,
|
|
20
|
+
msg: 'Fetched Figma user info'
|
|
21
|
+
});
|
|
22
|
+
} catch (err) {
|
|
23
|
+
debugLogger.error({
|
|
24
|
+
err,
|
|
25
|
+
msg: 'Failed to fetch Figma user info'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const projectToken = await getProjectToken(oauthCredential, contentSystemId);
|
|
29
|
+
if (!projectToken.token) {
|
|
30
|
+
const errMsg = 'No project token returned from Figma API';
|
|
31
|
+
req.payload.logger.error({
|
|
32
|
+
msg: errMsg
|
|
33
|
+
});
|
|
34
|
+
throw new APIError(errMsg);
|
|
35
|
+
}
|
|
36
|
+
const cookieOptions = createCookieOptions({
|
|
37
|
+
collection,
|
|
38
|
+
headers: req.headers,
|
|
39
|
+
pluginOptions
|
|
40
|
+
});
|
|
41
|
+
if (!req.responseHeaders) {
|
|
42
|
+
req.responseHeaders = new Headers();
|
|
43
|
+
}
|
|
44
|
+
// The -refresh cookie holds the OAuth access_token so refreshTokens can
|
|
45
|
+
// re-mint project_tokens from it on JWT expiry.
|
|
46
|
+
if (!collectionOptions.usePayloadJWT) {
|
|
47
|
+
const refreshCookie = generateCookie({
|
|
48
|
+
...cookieOptions,
|
|
49
|
+
name: `${strategy.cookieName}-refresh`,
|
|
50
|
+
expires: getCookieExpiration(cookieOptions?.expires ?? refreshTokenExpiresIn ?? 31_556_952),
|
|
51
|
+
returnCookieAsObject: false,
|
|
52
|
+
value: accessToken
|
|
53
|
+
});
|
|
54
|
+
req.responseHeaders.append('Set-Cookie', refreshCookie);
|
|
55
|
+
}
|
|
56
|
+
const tokenExpires = cookieOptions?.expires ? getCookieExpiration(cookieOptions.expires) : new Date(projectToken.expiresAt);
|
|
57
|
+
const tokenCookie = generateCookie({
|
|
58
|
+
...cookieOptions,
|
|
59
|
+
name: strategy.cookieName,
|
|
60
|
+
expires: tokenExpires,
|
|
61
|
+
returnCookieAsObject: false,
|
|
62
|
+
value: projectToken.token
|
|
63
|
+
});
|
|
64
|
+
req.responseHeaders.append('Set-Cookie', tokenCookie);
|
|
65
|
+
// Short-lived handoff cookie consumed by defaultVerify on the next request.
|
|
66
|
+
if (figmaUserInfo) {
|
|
67
|
+
const userInfoValue = Buffer.from(JSON.stringify({
|
|
68
|
+
handle: figmaUserInfo.handle,
|
|
69
|
+
img_url: figmaUserInfo.img_url
|
|
70
|
+
})).toString('base64');
|
|
71
|
+
const userInfoCookie = generateCookie({
|
|
72
|
+
...cookieOptions,
|
|
73
|
+
name: pluginOptions?.userInfoCookieName ?? 'figma-user-info',
|
|
74
|
+
expires: new Date(Date.now() + 60_000),
|
|
75
|
+
returnCookieAsObject: false,
|
|
76
|
+
value: userInfoValue
|
|
77
|
+
});
|
|
78
|
+
req.responseHeaders.append('Set-Cookie', userInfoCookie);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=establishSession.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Strategy } from '../strategy/index.js';
|
|
2
|
+
interface Args {
|
|
3
|
+
/** Authorization code received from the IdP redirect. */
|
|
4
|
+
code: string;
|
|
5
|
+
/** PKCE verifier; omit for non-PKCE flows. */
|
|
6
|
+
codeVerifier?: string;
|
|
7
|
+
/** Must match the redirect_uri the authorization request used. */
|
|
8
|
+
redirectUri: string;
|
|
9
|
+
strategy: Strategy;
|
|
10
|
+
}
|
|
11
|
+
export interface TokenEndpointResponse {
|
|
12
|
+
access_token?: null | string;
|
|
13
|
+
error?: string;
|
|
14
|
+
error_description?: string;
|
|
15
|
+
expires_in?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* POSTs an authorization code to the IdP's `token_endpoint` and returns the
|
|
19
|
+
* raw response body. Callers handle error/missing-token logging in their own
|
|
20
|
+
* style — this helper only owns the request shape.
|
|
21
|
+
*/
|
|
22
|
+
export declare const exchangeCodeForAccessToken: ({ code, codeVerifier, redirectUri, strategy, }: Args) => Promise<TokenEndpointResponse>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=exchangeCodeForAccessToken.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POSTs an authorization code to the IdP's `token_endpoint` and returns the
|
|
3
|
+
* raw response body. Callers handle error/missing-token logging in their own
|
|
4
|
+
* style — this helper only owns the request shape.
|
|
5
|
+
*/ export const exchangeCodeForAccessToken = async ({ code, codeVerifier, redirectUri, strategy })=>{
|
|
6
|
+
const body = {
|
|
7
|
+
client_id: strategy.clientID,
|
|
8
|
+
code,
|
|
9
|
+
grant_type: 'authorization_code',
|
|
10
|
+
redirect_uri: redirectUri
|
|
11
|
+
};
|
|
12
|
+
if (codeVerifier) {
|
|
13
|
+
body.code_verifier = codeVerifier;
|
|
14
|
+
}
|
|
15
|
+
if (strategy.collectionOptions.clientSecret) {
|
|
16
|
+
body.client_secret = strategy.collectionOptions.clientSecret;
|
|
17
|
+
}
|
|
18
|
+
const res = await fetch(strategy.meta.token_endpoint, {
|
|
19
|
+
body: new URLSearchParams(body),
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
22
|
+
},
|
|
23
|
+
method: 'POST'
|
|
24
|
+
});
|
|
25
|
+
return await res.json();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=exchangeCodeForAccessToken.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copied from share/figma-url/src/hostnames.ts.
|
|
2
|
+
// This package is published to npm (@payloadcms/figma) and cannot import from
|
|
3
|
+
// the monorepo's internal share/ tree, so the list is duplicated here.
|
|
4
|
+
export const FIGMA_HOSTNAMES = new Set([
|
|
5
|
+
'embed.figma.com',
|
|
6
|
+
'embed.figma-gov.com',
|
|
7
|
+
'embed.local.figma.engineering',
|
|
8
|
+
'embed.staging.figma.com',
|
|
9
|
+
'figma.com',
|
|
10
|
+
'figma-gov.com',
|
|
11
|
+
'local.figma.engineering',
|
|
12
|
+
'localhost',
|
|
13
|
+
'staging.figma.com',
|
|
14
|
+
'www.figma.com',
|
|
15
|
+
'www.figma-gov.com'
|
|
16
|
+
]);
|
|
17
|
+
export const isFigmaOrigin = (origin)=>{
|
|
18
|
+
try {
|
|
19
|
+
const { hostname } = new URL(origin);
|
|
20
|
+
return FIGMA_HOSTNAMES.has(hostname) || hostname.endsWith('.figdev.systems');
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=figmaHostnames.js.map
|
|
@@ -5,6 +5,16 @@ interface Args {
|
|
|
5
5
|
collection: CollectionConfig;
|
|
6
6
|
collectionOptions: CollectionOptions;
|
|
7
7
|
endpointSlug: string;
|
|
8
|
+
/**
|
|
9
|
+
* If the request already has an `__Host-payload-oauth-state_csrf` cookie,
|
|
10
|
+
* pass its value here — `getAuthorizeURL` will reuse it as `state.csrf`
|
|
11
|
+
* instead of minting a fresh nonce. This is what makes `/meta`
|
|
12
|
+
* idempotent across multiple calls in a single browser session (React
|
|
13
|
+
* Strict Mode re-mounts, retry-after-failure, multiple tabs) and
|
|
14
|
+
* prevents the cookie/state mismatch race where one call overwrites
|
|
15
|
+
* another call's cookie.
|
|
16
|
+
*/
|
|
17
|
+
existingCsrfNonce?: null | string;
|
|
8
18
|
failedRedirect?: unknown;
|
|
9
19
|
payload: Payload;
|
|
10
20
|
pluginOptions: PluginOptions;
|
|
@@ -12,6 +22,60 @@ interface Args {
|
|
|
12
22
|
serverURLOverride?: unknown;
|
|
13
23
|
strategy: Strategy;
|
|
14
24
|
}
|
|
15
|
-
export
|
|
25
|
+
export interface AuthorizeURLParams {
|
|
26
|
+
[key: string]: string;
|
|
27
|
+
client_id: string;
|
|
28
|
+
code_challenge: string;
|
|
29
|
+
code_challenge_method: string;
|
|
30
|
+
nonce: string;
|
|
31
|
+
redirect_uri: string;
|
|
32
|
+
response_mode: string;
|
|
33
|
+
response_type: string;
|
|
34
|
+
scope: string;
|
|
35
|
+
state: string;
|
|
36
|
+
}
|
|
37
|
+
export interface AuthorizeURLResult {
|
|
38
|
+
authorizeURL: string;
|
|
39
|
+
/**
|
|
40
|
+
* The plaintext CSRF nonce that the caller MUST set as an HttpOnly
|
|
41
|
+
* cookie on the response (see `OAUTH_STATE_CSRF_COOKIE_NAME`). `/sso/login`
|
|
42
|
+
* compares this value to the cookie on callback — this is the
|
|
43
|
+
* browser-binding required by RFC 6749 §10.12.
|
|
44
|
+
*/
|
|
45
|
+
csrfNonce: string;
|
|
46
|
+
params: AuthorizeURLParams;
|
|
47
|
+
}
|
|
48
|
+
export declare const getAuthorizeURL: ({ collection, collectionOptions, endpointSlug, existingCsrfNonce, failedRedirect, payload, pluginOptions, redirect, serverURLOverride, strategy, }: Args) => Promise<AuthorizeURLResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Name of the HttpOnly cookie that carries the browser-bound CSRF nonce
|
|
51
|
+
* for the OAuth flow. The `__Host-` prefix instructs browsers to enforce:
|
|
52
|
+
* Secure, no Domain attribute (host-only), and Path=/ — which together
|
|
53
|
+
* prevent sibling subdomains from setting or overwriting it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const OAUTH_STATE_CSRF_COOKIE_NAME = "__Host-payload-oauth-state_csrf";
|
|
56
|
+
/**
|
|
57
|
+
* Build the `Set-Cookie` header value for the CSRF cookie. SameSite=None
|
|
58
|
+
* + Secure so the cookie survives the IdP cross-site redirect back into
|
|
59
|
+
* /sso/login, AND so the iframe auto-login path works (the iframe is a
|
|
60
|
+
* third-party context from the top-level Figma page). Path=/ is required
|
|
61
|
+
* by the `__Host-` prefix.
|
|
62
|
+
*
|
|
63
|
+
* `Partitioned` (CHIPS) is required because the Make preview embeds the
|
|
64
|
+
* admin panel in a cross-site iframe. Under Chrome's third-party-cookie
|
|
65
|
+
* restrictions a `SameSite=None` cookie set in a third-party context is
|
|
66
|
+
* NOT sent back unless it is partitioned by the top-level site. Without it
|
|
67
|
+
* the `__Host-payload-oauth-state_csrf` cookie is dropped on the way back
|
|
68
|
+
* to /sso/login, the cookie↔state.csrf binding check fails, and login dies
|
|
69
|
+
* with "CSRF cookie mismatch" (intermittent sign-in loop). `__Host-` and
|
|
70
|
+
* `Partitioned` are mutually compatible.
|
|
71
|
+
*/
|
|
72
|
+
export declare const buildCsrfCookieHeader: (nonce: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* `Set-Cookie` header to clear the CSRF cookie after a successful (or
|
|
75
|
+
* failed) callback. Same attributes as the set version, plus Max-Age=0.
|
|
76
|
+
* Must include `Partitioned` so the clear targets the same partitioned
|
|
77
|
+
* cookie jar the set wrote to (an unpartitioned clear would not match).
|
|
78
|
+
*/
|
|
79
|
+
export declare const buildCsrfCookieClearHeader: () => string;
|
|
16
80
|
export {};
|
|
17
81
|
//# sourceMappingURL=getAuthorizeURL.d.ts.map
|
|
@@ -2,14 +2,21 @@ import crypto from 'crypto';
|
|
|
2
2
|
import * as QueryString from 'qs-esm';
|
|
3
3
|
import { v4 as uuid } from 'uuid';
|
|
4
4
|
import { defaultScope } from '../defaults.js';
|
|
5
|
-
export const getAuthorizeURL = async ({ collection, collectionOptions, endpointSlug, failedRedirect, payload, pluginOptions, redirect, serverURLOverride, strategy })=>{
|
|
5
|
+
export const getAuthorizeURL = async ({ collection, collectionOptions, endpointSlug, existingCsrfNonce, failedRedirect, payload, pluginOptions, redirect, serverURLOverride, strategy })=>{
|
|
6
6
|
const { redirectServerURL } = pluginOptions;
|
|
7
7
|
await strategy.ensureMeta();
|
|
8
8
|
// Generate a random code verifier
|
|
9
9
|
const codeVerifier = crypto.randomBytes(32).toString('base64url');
|
|
10
10
|
// Create a code challenge by hashing the code verifier
|
|
11
11
|
const code_challenge = crypto.createHash('sha256').update(codeVerifier).digest('base64url');
|
|
12
|
+
// Nonce that goes in both `state.csrf` and the `__Host-payload-oauth-state_csrf`
|
|
13
|
+
// HttpOnly cookie. /sso/login compares the two on callback to defeat
|
|
14
|
+
// login-CSRF (RFC 6749 §10.12). Reused from the request's existing cookie
|
|
15
|
+
// when present so `/meta` is idempotent across multiple calls; otherwise
|
|
16
|
+
// freshly minted.
|
|
17
|
+
const csrfNonce = existingCsrfNonce || crypto.randomBytes(32).toString('base64url');
|
|
12
18
|
const state = {
|
|
19
|
+
csrf: csrfNonce,
|
|
13
20
|
sig: payload.encrypt(strategy.name),
|
|
14
21
|
verifier: payload.encrypt(codeVerifier)
|
|
15
22
|
};
|
|
@@ -39,7 +46,55 @@ export const getAuthorizeURL = async ({ collection, collectionOptions, endpointS
|
|
|
39
46
|
const authorizeURL = `${strategy.meta?.authorization_endpoint}?${QueryString.stringify(params, {
|
|
40
47
|
encode: false
|
|
41
48
|
})}`;
|
|
42
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
authorizeURL,
|
|
51
|
+
csrfNonce,
|
|
52
|
+
params
|
|
53
|
+
};
|
|
43
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Name of the HttpOnly cookie that carries the browser-bound CSRF nonce
|
|
57
|
+
* for the OAuth flow. The `__Host-` prefix instructs browsers to enforce:
|
|
58
|
+
* Secure, no Domain attribute (host-only), and Path=/ — which together
|
|
59
|
+
* prevent sibling subdomains from setting or overwriting it.
|
|
60
|
+
*/ export const OAUTH_STATE_CSRF_COOKIE_NAME = '__Host-payload-oauth-state_csrf';
|
|
61
|
+
/**
|
|
62
|
+
* Build the `Set-Cookie` header value for the CSRF cookie. SameSite=None
|
|
63
|
+
* + Secure so the cookie survives the IdP cross-site redirect back into
|
|
64
|
+
* /sso/login, AND so the iframe auto-login path works (the iframe is a
|
|
65
|
+
* third-party context from the top-level Figma page). Path=/ is required
|
|
66
|
+
* by the `__Host-` prefix.
|
|
67
|
+
*
|
|
68
|
+
* `Partitioned` (CHIPS) is required because the Make preview embeds the
|
|
69
|
+
* admin panel in a cross-site iframe. Under Chrome's third-party-cookie
|
|
70
|
+
* restrictions a `SameSite=None` cookie set in a third-party context is
|
|
71
|
+
* NOT sent back unless it is partitioned by the top-level site. Without it
|
|
72
|
+
* the `__Host-payload-oauth-state_csrf` cookie is dropped on the way back
|
|
73
|
+
* to /sso/login, the cookie↔state.csrf binding check fails, and login dies
|
|
74
|
+
* with "CSRF cookie mismatch" (intermittent sign-in loop). `__Host-` and
|
|
75
|
+
* `Partitioned` are mutually compatible.
|
|
76
|
+
*/ export const buildCsrfCookieHeader = (nonce)=>[
|
|
77
|
+
`${OAUTH_STATE_CSRF_COOKIE_NAME}=${nonce}`,
|
|
78
|
+
'HttpOnly',
|
|
79
|
+
'Secure',
|
|
80
|
+
'SameSite=None',
|
|
81
|
+
'Partitioned',
|
|
82
|
+
'Path=/',
|
|
83
|
+
'Max-Age=600'
|
|
84
|
+
].join('; ');
|
|
85
|
+
/**
|
|
86
|
+
* `Set-Cookie` header to clear the CSRF cookie after a successful (or
|
|
87
|
+
* failed) callback. Same attributes as the set version, plus Max-Age=0.
|
|
88
|
+
* Must include `Partitioned` so the clear targets the same partitioned
|
|
89
|
+
* cookie jar the set wrote to (an unpartitioned clear would not match).
|
|
90
|
+
*/ export const buildCsrfCookieClearHeader = ()=>[
|
|
91
|
+
`${OAUTH_STATE_CSRF_COOKIE_NAME}=`,
|
|
92
|
+
'HttpOnly',
|
|
93
|
+
'Secure',
|
|
94
|
+
'SameSite=None',
|
|
95
|
+
'Partitioned',
|
|
96
|
+
'Path=/',
|
|
97
|
+
'Max-Age=0'
|
|
98
|
+
].join('; ');
|
|
44
99
|
|
|
45
100
|
//# sourceMappingURL=getAuthorizeURL.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if an error is a duplicate key/unique constraint violation from Content API.
|
|
3
|
+
*
|
|
4
|
+
* Content API returns HTTP 409 with "conflict" or "already exists" in the message.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isDuplicateKeyError(error: unknown): boolean;
|
|
7
|
+
//# sourceMappingURL=isDuplicateKeyError.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if an error is a duplicate key/unique constraint violation from Content API.
|
|
3
|
+
*
|
|
4
|
+
* Content API returns HTTP 409 with "conflict" or "already exists" in the message.
|
|
5
|
+
*/ export function isDuplicateKeyError(error) {
|
|
6
|
+
if (!error || typeof error !== 'object') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const err = error;
|
|
10
|
+
const message = typeof err.message === 'string' ? err.message : '';
|
|
11
|
+
return message.includes('409') || message.toLowerCase().includes('conflict') || message.toLowerCase().includes('already exists');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=isDuplicateKeyError.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { generateCookie } from 'payload';
|
|
2
2
|
import { getProjectToken } from '../../api/figma-api.js';
|
|
3
3
|
import { validateProjectToken } from '../../auth/jwt-validator.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getInfraEnvironment } from '../../constants.js';
|
|
5
5
|
import { createCookieOptions } from './createCookieOptions.js';
|
|
6
6
|
import { createDebugLogger } from './createDebugLogger.js';
|
|
7
7
|
import { getCookieExpiration } from './getCookieExpiration.js';
|
|
@@ -16,7 +16,10 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
|
16
16
|
// so we will refresh both tokens
|
|
17
17
|
try {
|
|
18
18
|
// Get another project token
|
|
19
|
-
const { expiresAt, token } = await getProjectToken(
|
|
19
|
+
const { expiresAt, token } = await getProjectToken({
|
|
20
|
+
type: 'oauth',
|
|
21
|
+
token: refreshToken
|
|
22
|
+
}, payload.config.custom.figma.contentSystemId);
|
|
20
23
|
debugLogger.info({
|
|
21
24
|
expiresAt,
|
|
22
25
|
msg: 'Received new tokens from Figma API',
|
|
@@ -48,7 +51,7 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
|
48
51
|
value: token
|
|
49
52
|
});
|
|
50
53
|
headers.append('Set-Cookie', tokenCookie);
|
|
51
|
-
const decodedOauthToken = await validateProjectToken(token,
|
|
54
|
+
const decodedOauthToken = await validateProjectToken(token, getInfraEnvironment());
|
|
52
55
|
return {
|
|
53
56
|
decodedOauthToken,
|
|
54
57
|
headers,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TokenStore } from '../auth/token-store.js';
|
|
2
|
+
/**
|
|
3
|
+
* Print a one-shot banner when the plugin is about to use `tokenStore`
|
|
4
|
+
* auth but no valid OAuth credential is present. Keeps the dev loop
|
|
5
|
+
* actionable instead of relying on per-request middleware errors.
|
|
6
|
+
*/
|
|
7
|
+
export declare function logMissingCliAuth(tokenStore: TokenStore): void;
|
|
8
|
+
//# sourceMappingURL=auth-preflight.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
/**
|
|
4
|
+
* Print a one-shot banner when the plugin is about to use `tokenStore`
|
|
5
|
+
* auth but no valid OAuth credential is present. Keeps the dev loop
|
|
6
|
+
* actionable instead of relying on per-request middleware errors.
|
|
7
|
+
*/ export function logMissingCliAuth(tokenStore) {
|
|
8
|
+
if (tokenStore.hasValidOauthToken()) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const lines = [
|
|
12
|
+
'Not logged in to the Figma CLI.',
|
|
13
|
+
'Content API requests will fail until you authenticate.',
|
|
14
|
+
'',
|
|
15
|
+
`Run ${pc.cyan('npx @payloadcms/figma login')} to log in, then restart the dev server.`
|
|
16
|
+
];
|
|
17
|
+
p.note(lines.join('\n'), pc.yellow('Figma authentication required'));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=auth-preflight.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reason the Content System ID could not be resolved. Drives the
|
|
3
|
+
* banner's copy so the dev sees the specific remediation step.
|
|
4
|
+
*/
|
|
5
|
+
export type MissingContentSystemIdReason = {
|
|
6
|
+
environmentName: string;
|
|
7
|
+
kind: 'environment-not-found';
|
|
8
|
+
projectId: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'network';
|
|
11
|
+
message: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'no-config';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'unauthenticated';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Print a banner explaining why Content System ID resolution failed and
|
|
19
|
+
* what to run next. Called just before `buildFigmaConfig` throws, so the
|
|
20
|
+
* actionable step is visible above the stack trace.
|
|
21
|
+
*/
|
|
22
|
+
export declare function logMissingContentSystemId(reason: MissingContentSystemIdReason): void;
|
|
23
|
+
//# sourceMappingURL=bootstrap-preflight.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
/**
|
|
4
|
+
* Print a banner explaining why Content System ID resolution failed and
|
|
5
|
+
* what to run next. Called just before `buildFigmaConfig` throws, so the
|
|
6
|
+
* actionable step is visible above the stack trace.
|
|
7
|
+
*/ export function logMissingContentSystemId(reason) {
|
|
8
|
+
const lines = buildBody(reason);
|
|
9
|
+
p.note(lines.join('\n'), pc.yellow('Figma project not configured'));
|
|
10
|
+
}
|
|
11
|
+
function buildBody(reason) {
|
|
12
|
+
const loginCmd = pc.cyan('npx @payloadcms/figma login');
|
|
13
|
+
const initCmd = pc.cyan('npx @payloadcms/figma init');
|
|
14
|
+
const initForceCmd = pc.cyan('npx @payloadcms/figma init --force');
|
|
15
|
+
if (reason.kind === 'no-config') {
|
|
16
|
+
return [
|
|
17
|
+
'No Figma project configuration found.',
|
|
18
|
+
'',
|
|
19
|
+
`Run ${initCmd} to set up this project.`
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
if (reason.kind === 'unauthenticated') {
|
|
23
|
+
return [
|
|
24
|
+
'Project config found, but you are not logged in.',
|
|
25
|
+
'Cannot fetch bootstrap data without a valid session.',
|
|
26
|
+
'',
|
|
27
|
+
`Run ${loginCmd}, then restart the dev server.`
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
if (reason.kind === 'network') {
|
|
31
|
+
return [
|
|
32
|
+
'Could not reach the Figma API to fetch bootstrap data.',
|
|
33
|
+
`Error: ${reason.message}`,
|
|
34
|
+
'',
|
|
35
|
+
'Check your network, then restart the dev server.'
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
return [
|
|
39
|
+
`Environment ${pc.bold(reason.environmentName)} not found for project ${pc.bold(reason.projectId)}.`,
|
|
40
|
+
'',
|
|
41
|
+
`Run ${initForceCmd} to reconfigure, or set FIGMA_ENVIRONMENT_NAME to a valid environment.`
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=bootstrap-preflight.js.map
|
|
@@ -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
|
*
|
|
@@ -6,38 +15,41 @@ import type { Config, SanitizedConfig } from 'payload';
|
|
|
6
15
|
* - `db`: Omitted (auto-injected by Figma platform)
|
|
7
16
|
* - `secret`: Omitted (auto-injected by Figma platform)
|
|
8
17
|
* - `editor`: Optional (defaults to lexicalEditor() if not provided)
|
|
18
|
+
* - `contentSystemId`: Optional (resolved automatically from env vars or bootstrap cache)
|
|
9
19
|
*
|
|
10
20
|
* @example
|
|
11
|
-
* // Minimal config
|
|
21
|
+
* // Minimal config (contentSystemId resolved automatically)
|
|
12
22
|
* const config: FigmaConfig = {
|
|
23
|
+
* figma: {},
|
|
13
24
|
* collections: [...]
|
|
14
25
|
* }
|
|
15
26
|
*
|
|
16
27
|
* @example
|
|
17
28
|
* // With custom editor
|
|
18
29
|
* const config: FigmaConfig = {
|
|
30
|
+
* figma: {},
|
|
19
31
|
* collections: [...],
|
|
20
32
|
* editor: lexicalEditor({ features: [...] })
|
|
21
33
|
* }
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Disable Content System (use custom db)
|
|
37
|
+
* const config: FigmaConfig = {
|
|
38
|
+
* figma: {
|
|
39
|
+
* useContentSystem: false
|
|
40
|
+
* },
|
|
41
|
+
* db: mongooseAdapter({ url: process.env.DATABASE_URI }),
|
|
42
|
+
* collections: [...]
|
|
43
|
+
* }
|
|
22
44
|
*/
|
|
23
45
|
export type FigmaConfig = {
|
|
24
46
|
editor?: Config['editor'];
|
|
25
47
|
} & {
|
|
26
48
|
figma: {
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
contentSystemId?: string;
|
|
50
|
+
storage?: boolean;
|
|
29
51
|
useContentSystem?: boolean;
|
|
30
52
|
};
|
|
31
|
-
} & Omit<Config, '
|
|
32
|
-
|
|
33
|
-
* Figma platform wrapper for Payload's buildConfig.
|
|
34
|
-
* Automatically injects:
|
|
35
|
-
* - Figma database adapter
|
|
36
|
-
* - Secret (platform-provided)
|
|
37
|
-
* - Default lexicalEditor (if no custom editor specified)
|
|
38
|
-
*
|
|
39
|
-
* @param config - Payload configuration (db and secret omitted, editor optional)
|
|
40
|
-
* @returns Promise<SanitizedConfig> - Built Payload configuration
|
|
41
|
-
*/
|
|
42
|
-
export declare function buildConfig(config: FigmaConfig): Promise<SanitizedConfig>;
|
|
53
|
+
} & Omit<Config, 'db' | 'editor' | 'secret'> & Partial<Pick<Config, 'db'>>;
|
|
54
|
+
export declare function buildFigmaConfig(config: FigmaConfig): Promise<SanitizedConfig>;
|
|
43
55
|
//# sourceMappingURL=build-config.d.ts.map
|