@payloadcms/figma 0.0.1-alpha.8 → 0.1.0-alpha.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/dist/api/control-plane.d.ts +56 -7
- package/dist/api/control-plane.js +188 -74
- package/dist/api/error-response.d.ts +36 -0
- package/dist/api/error-response.js +66 -0
- package/dist/api/figma-api.d.ts +24 -3
- package/dist/api/figma-api.js +110 -34
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +19 -8
- package/dist/auth/callback-server.js +72 -32
- package/dist/auth/credentials.d.ts +20 -0
- package/dist/auth/credentials.js +19 -0
- package/dist/auth/crypto-utils.d.ts +28 -1
- package/dist/auth/crypto-utils.js +132 -23
- package/dist/auth/jwt-validator.d.ts +23 -6
- package/dist/auth/jwt-validator.js +35 -9
- package/dist/auth/oauth-flow.d.ts +19 -4
- package/dist/auth/oauth-flow.js +151 -34
- package/dist/auth/paste-code.d.ts +33 -0
- package/dist/auth/paste-code.js +87 -0
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +32 -17
- package/dist/auth/project-token.js +176 -68
- package/dist/auth/refresh.d.ts +2 -2
- package/dist/auth/refresh.js +25 -14
- package/dist/auth/token-store-migration.d.ts +57 -0
- package/dist/auth/token-store-migration.js +154 -0
- package/dist/auth/token-store.d.ts +63 -98
- package/dist/auth/token-store.js +405 -124
- package/dist/auth/types.d.ts +40 -6
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +102 -8
- package/dist/commands/bootstrap.d.ts +17 -0
- package/dist/commands/bootstrap.js +88 -0
- package/dist/commands/build-lambda-zip.d.ts +4 -0
- package/dist/commands/build-lambda-zip.js +17 -0
- package/dist/commands/debug.d.ts +7 -0
- package/dist/commands/debug.js +178 -0
- package/dist/commands/deploy.d.ts +11 -1
- package/dist/commands/deploy.js +193 -153
- package/dist/commands/dump-tokens.d.ts +11 -0
- package/dist/commands/dump-tokens.js +67 -0
- package/dist/commands/env.d.ts +12 -0
- package/dist/commands/env.js +86 -0
- package/dist/commands/init.d.ts +9 -6
- package/dist/commands/init.js +232 -152
- package/dist/commands/list-tokens.d.ts +3 -4
- package/dist/commands/list-tokens.js +24 -11
- package/dist/commands/login.d.ts +8 -2
- package/dist/commands/login.js +34 -18
- package/dist/commands/logout.d.ts +5 -5
- package/dist/commands/logout.js +77 -17
- package/dist/commands/upgrade.d.ts +4 -0
- package/dist/commands/upgrade.js +329 -0
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +17 -12
- package/dist/config/oauth.js +38 -39
- package/dist/constants.d.ts +63 -19
- package/dist/constants.js +158 -20
- package/dist/db-content-api/generated/content-api-types.d.ts +7574 -0
- package/dist/db-content-api/generated/content-api-types.js +5 -0
- package/dist/db-content-api/index.d.ts +37 -0
- package/dist/db-content-api/index.js +938 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +1 -0
- package/dist/db-content-api/temp-utilities/slug.js +1 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/sorting.js +37 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +21 -0
- package/dist/db-content-api/temp-utilities/types.js +13 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +38 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +62 -0
- package/dist/db-content-api/utilities/auth.d.ts +29 -0
- package/dist/db-content-api/utilities/auth.js +82 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +6 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +75 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +10 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
- package/dist/db-content-api/utilities/data/index.d.ts +48 -0
- package/dist/db-content-api/utilities/data/index.js +299 -0
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +52 -0
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +47 -0
- package/dist/db-content-api/utilities/data/stripFields.js +170 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +22 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +40 -0
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +6 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +100 -0
- package/dist/db-content-api/utilities/joins.d.ts +52 -0
- package/dist/db-content-api/utilities/joins.js +137 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +9 -0
- package/dist/db-content-api/utilities/locale/index.js +19 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +71 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +41 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +39 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +16 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +243 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +12 -0
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +60 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +100 -0
- package/dist/db-content-api/utilities/resolveBlocks.d.ts +19 -0
- package/dist/db-content-api/utilities/resolveBlocks.js +31 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +55 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +182 -0
- package/dist/db-content-api/utilities/where.d.ts +19 -0
- package/dist/db-content-api/utilities/where.js +106 -0
- package/dist/deploy/schedule-extract-plugin.d.ts +10 -0
- package/dist/deploy/schedule-extract-plugin.js +32 -0
- package/dist/endpoints/health.d.ts +2 -0
- package/dist/endpoints/health.js +9 -0
- package/dist/endpoints/schema.d.ts +2 -0
- package/dist/endpoints/schema.js +27 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/download-skill.d.ts +12 -0
- package/dist/lib/download-skill.js +77 -0
- package/dist/oauth/components/FigmaAvatar/index.d.ts +3 -0
- package/dist/oauth/components/FigmaAvatar/index.js +25 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +23 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +8 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +35 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +81 -0
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +168 -0
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +156 -18
- package/dist/oauth/components/LoginButton/index.scss +75 -3
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +20 -9
- package/dist/oauth/defaults.d.ts +3 -2
- package/dist/oauth/defaults.js +79 -12
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +87 -84
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -6
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +18 -5
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +11 -4
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +2 -3
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +27 -7
- package/dist/oauth/strategy/index.d.ts +0 -3
- package/dist/oauth/strategy/index.js +55 -34
- package/dist/oauth/types.d.ts +23 -7
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/buildUnauthorizedRedirect.d.ts +14 -0
- package/dist/oauth/utilities/buildUnauthorizedRedirect.js +28 -0
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +5 -3
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +9 -4
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +22 -0
- package/dist/oauth/utilities/establishSession.js +80 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +23 -0
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +26 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +2 -0
- package/dist/oauth/utilities/figmaHostnames.js +24 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +65 -2
- package/dist/oauth/utilities/getAuthorizeURL.js +57 -4
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +1 -0
- package/dist/oauth/utilities/isAbsoluteURL.js +1 -0
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +6 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +12 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +21 -13
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +19 -0
- package/dist/oauth/utilities/withPartitionedCookie.js +26 -0
- package/dist/oauth/utils/getSearchParam.d.ts +17 -0
- package/dist/oauth/utils/getSearchParam.js +22 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +7 -0
- package/dist/plugin/auth-preflight.js +18 -0
- package/dist/plugin/bootstrap-preflight.d.ts +22 -0
- package/dist/plugin/bootstrap-preflight.js +43 -0
- package/dist/plugin/build-config.d.ts +27 -15
- package/dist/plugin/build-config.js +381 -18
- package/dist/plugin/dev-cookie-names.d.ts +13 -0
- package/dist/plugin/dev-cookie-names.js +17 -0
- package/dist/scss.d.js +2 -0
- package/dist/storage-content-api/api-types.d.ts +183 -0
- package/dist/storage-content-api/api-types.js +4 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +14 -0
- package/dist/storage-content-api/client-uploads/generate.js +69 -0
- package/dist/storage-content-api/client.d.ts +5 -0
- package/dist/storage-content-api/client.js +37 -0
- package/dist/storage-content-api/generateURL.d.ts +6 -0
- package/dist/storage-content-api/generateURL.js +6 -0
- package/dist/storage-content-api/handleDelete.d.ts +7 -0
- package/dist/storage-content-api/handleDelete.js +15 -0
- package/dist/storage-content-api/handleUpload.d.ts +10 -0
- package/dist/storage-content-api/handleUpload.js +162 -0
- package/dist/storage-content-api/index.d.ts +4 -0
- package/dist/storage-content-api/index.js +37 -0
- package/dist/storage-content-api/staticHandler.d.ts +9 -0
- package/dist/storage-content-api/staticHandler.js +61 -0
- package/dist/storage-content-api/types.d.ts +9 -0
- package/dist/storage-content-api/types.js +1 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +11 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +59 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +2 -0
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +17 -0
- package/dist/storage-content-api/utilities/parseUploadReference.js +27 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.js +0 -4
- package/dist/types.d.ts +10 -2
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +8 -0
- package/dist/utils/adapters/nextjs.js +61 -0
- package/dist/utils/adapters/nitro.d.ts +8 -0
- package/dist/utils/adapters/nitro.js +172 -0
- package/dist/utils/adapters/vite.d.ts +9 -0
- package/dist/utils/adapters/vite.js +31 -0
- package/dist/utils/asset-collection.d.ts +27 -7
- package/dist/utils/asset-collection.js +59 -32
- package/dist/utils/build-detection.d.ts +5 -12
- package/dist/utils/build-detection.js +74 -13
- package/dist/utils/build-lambda-zip.d.ts +25 -0
- package/dist/utils/build-lambda-zip.js +90 -0
- package/dist/utils/cache-bootstrap.d.ts +7 -0
- package/dist/utils/cache-bootstrap.js +16 -0
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +1 -3
- package/dist/utils/deploy-adapter.d.ts +45 -0
- package/dist/utils/deploy-adapter.js +56 -0
- package/dist/utils/download-template.d.ts +9 -2
- package/dist/utils/download-template.js +24 -20
- package/dist/utils/env-management.d.ts +24 -8
- package/dist/utils/env-management.js +119 -66
- package/dist/utils/format-env-suffix.d.ts +11 -0
- package/dist/utils/format-env-suffix.js +11 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +23 -13
- package/dist/utils/fs-utils.d.ts +12 -0
- package/dist/utils/fs-utils.js +55 -0
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +8 -0
- package/dist/utils/handle-upgrade.js +39 -0
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +3 -2
- package/dist/utils/lambda-config.js +75 -80
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +1 -3
- package/dist/utils/messages.js +47 -13
- package/dist/utils/package-manager.d.ts +24 -1
- package/dist/utils/package-manager.js +53 -2
- package/dist/utils/parse-template-spec.d.ts +11 -0
- package/dist/utils/parse-template-spec.js +60 -0
- package/dist/utils/payload-config-ast.d.ts +27 -7
- package/dist/utils/payload-config-ast.js +106 -60
- package/dist/utils/payload-config-finder.d.ts +2 -3
- package/dist/utils/payload-config-finder.js +48 -11
- package/dist/utils/payload-config-modifier.d.ts +1 -2
- package/dist/utils/payload-config-modifier.js +114 -68
- package/dist/utils/payload-package-check.d.ts +28 -3
- package/dist/utils/payload-package-check.js +90 -31
- package/dist/utils/project.d.ts +8 -4
- package/dist/utils/project.js +63 -37
- package/dist/utils/resolve-environment.d.ts +13 -0
- package/dist/utils/resolve-environment.js +29 -0
- package/dist/utils/s3-upload.d.ts +7 -3
- package/dist/utils/s3-upload.js +44 -9
- package/dist/utils/token-display.d.ts +5 -2
- package/dist/utils/token-display.js +49 -24
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +4 -8
- package/dist/utils/version-check.d.ts +2 -0
- package/dist/utils/version-check.js +43 -0
- package/package.json +47 -16
- 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
package/dist/oauth/defaults.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
import { parseCookies } from 'payload';
|
|
1
2
|
import { v4 as uuid } from 'uuid';
|
|
2
3
|
import { hasUserTokenPropsChanged } from './utilities/hasUserTokenPropsChanged.js';
|
|
4
|
+
import { isDuplicateKeyError } from './utilities/isDuplicateKeyError.js';
|
|
5
|
+
export const DEFAULT_USER_INFO_COOKIE_NAME = 'figma-user-info';
|
|
6
|
+
function getFigmaUserInfo(headers, cookieName) {
|
|
7
|
+
try {
|
|
8
|
+
const cookies = parseCookies(headers);
|
|
9
|
+
const encoded = cookies.get(cookieName);
|
|
10
|
+
if (!encoded) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return JSON.parse(Buffer.from(encoded, 'base64').toString('utf-8'));
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
3
18
|
export const defaultScope = [
|
|
4
19
|
'openid',
|
|
5
20
|
'profile',
|
|
@@ -14,7 +29,7 @@ export const defaultUsernameField = {
|
|
|
14
29
|
},
|
|
15
30
|
unique: true
|
|
16
31
|
};
|
|
17
|
-
export const defaultVerify = ({ collection, strategyName, usernameField })=>async ({ payload, token })=>{
|
|
32
|
+
export const defaultVerify = ({ collection, strategyName, userInfoCookieName = DEFAULT_USER_INFO_COOKIE_NAME, usernameField })=>async ({ headers, payload, token })=>{
|
|
18
33
|
let tokenUsername = 'preferred_username';
|
|
19
34
|
if (usernameField.name !== 'preferredUsername') {
|
|
20
35
|
tokenUsername = usernameField.name;
|
|
@@ -24,6 +39,16 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
|
|
|
24
39
|
user: null
|
|
25
40
|
};
|
|
26
41
|
}
|
|
42
|
+
const figmaUserInfo = getFigmaUserInfo(headers, userInfoCookieName);
|
|
43
|
+
let responseHeaders;
|
|
44
|
+
// Clear the cookie after reading
|
|
45
|
+
if (figmaUserInfo) {
|
|
46
|
+
responseHeaders = new Headers();
|
|
47
|
+
// SameSite=None; Secure; Partitioned so the clear matches the attributes
|
|
48
|
+
// the cookie was set with (establishSession) and actually removes it in the
|
|
49
|
+
// cross-site Make iframe.
|
|
50
|
+
responseHeaders.append('Set-Cookie', `${userInfoCookieName}=; Max-Age=0; Path=/; Secure; SameSite=None; Partitioned`);
|
|
51
|
+
}
|
|
27
52
|
let user = null;
|
|
28
53
|
const depth = typeof collection.auth === 'object' ? collection.auth.depth : undefined;
|
|
29
54
|
try {
|
|
@@ -40,13 +65,19 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
|
|
|
40
65
|
});
|
|
41
66
|
if (results.docs.length > 0) {
|
|
42
67
|
user = results.docs[0];
|
|
43
|
-
//
|
|
44
|
-
|
|
68
|
+
// Check if update needed (token changed OR figma info missing/changed)
|
|
69
|
+
const userWithFigma = user;
|
|
70
|
+
const needsFigmaUpdate = figmaUserInfo && (userWithFigma.figmaHandle !== figmaUserInfo.handle || userWithFigma.figmaImageUrl !== figmaUserInfo.img_url);
|
|
71
|
+
if (hasUserTokenPropsChanged(user, token) || needsFigmaUpdate) {
|
|
45
72
|
user = await payload.update({
|
|
46
73
|
id: user.id,
|
|
47
74
|
collection: collection.slug,
|
|
48
75
|
data: {
|
|
49
|
-
...token
|
|
76
|
+
...token,
|
|
77
|
+
...figmaUserInfo && {
|
|
78
|
+
figmaHandle: figmaUserInfo.handle,
|
|
79
|
+
figmaImageUrl: figmaUserInfo.img_url
|
|
80
|
+
}
|
|
50
81
|
},
|
|
51
82
|
depth
|
|
52
83
|
});
|
|
@@ -55,16 +86,43 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
|
|
|
55
86
|
const newUser = {
|
|
56
87
|
email: token.preferredUsername || token.email,
|
|
57
88
|
[usernameField.name]: token[tokenUsername],
|
|
58
|
-
...token
|
|
89
|
+
...token,
|
|
90
|
+
...figmaUserInfo && {
|
|
91
|
+
figmaHandle: figmaUserInfo.handle,
|
|
92
|
+
figmaImageUrl: figmaUserInfo.img_url
|
|
93
|
+
}
|
|
59
94
|
};
|
|
60
95
|
if (typeof collection.auth === 'object' && !collection.auth.disableLocalStrategy) {
|
|
61
96
|
newUser.password = uuid();
|
|
62
97
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
try {
|
|
99
|
+
user = await payload.create({
|
|
100
|
+
collection: collection.slug,
|
|
101
|
+
data: newUser,
|
|
102
|
+
depth,
|
|
103
|
+
overrideAccess: true
|
|
104
|
+
});
|
|
105
|
+
} catch (createErr) {
|
|
106
|
+
// Race condition: if unique constraint violation, user was created by concurrent request
|
|
107
|
+
if (isDuplicateKeyError(createErr)) {
|
|
108
|
+
const retryResults = await payload.find({
|
|
109
|
+
collection: collection.slug,
|
|
110
|
+
depth,
|
|
111
|
+
limit: 1,
|
|
112
|
+
pagination: false,
|
|
113
|
+
where: {
|
|
114
|
+
[usernameField.name]: {
|
|
115
|
+
equals: token[tokenUsername]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
if (retryResults.docs.length > 0) {
|
|
120
|
+
user = retryResults.docs[0];
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
throw createErr;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
68
126
|
}
|
|
69
127
|
} catch (err) {
|
|
70
128
|
payload.logger.error({
|
|
@@ -72,6 +130,7 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
|
|
|
72
130
|
msg: 'Error verifying user from defaultVerify.'
|
|
73
131
|
});
|
|
74
132
|
return {
|
|
133
|
+
responseHeaders,
|
|
75
134
|
user: null
|
|
76
135
|
};
|
|
77
136
|
}
|
|
@@ -79,13 +138,21 @@ export const defaultVerify = ({ collection, strategyName, usernameField })=>asyn
|
|
|
79
138
|
user.collection = collection.slug;
|
|
80
139
|
user._strategy = strategyName;
|
|
81
140
|
user.exp = token.exp;
|
|
141
|
+
// userGroups/makePermission are virtual (never persisted). Surface the live
|
|
142
|
+
// JWT claims on the authenticated user for this request so access control
|
|
143
|
+
// and self-reads see current values. Claims are snake_case on the wire; the
|
|
144
|
+
// collection fields are camelCase. The field afterRead hooks
|
|
145
|
+
// (see build-config.ts) read these back off req.user.
|
|
146
|
+
const userWithFigmaClaims = user;
|
|
147
|
+
userWithFigmaClaims.userGroups = Array.isArray(token.user_groups) ? token.user_groups : undefined;
|
|
148
|
+
userWithFigmaClaims.makePermission = token.make_permission === 'edit' || token.make_permission === 'view' ? token.make_permission : undefined;
|
|
82
149
|
return {
|
|
150
|
+
responseHeaders,
|
|
83
151
|
user
|
|
84
152
|
};
|
|
85
153
|
}
|
|
86
154
|
return {
|
|
155
|
+
responseHeaders,
|
|
87
156
|
user: null
|
|
88
157
|
};
|
|
89
158
|
};
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { APIError,
|
|
2
|
-
import { getSafeRedirect } from 'payload/shared';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { APIError, parseCookies } from 'payload';
|
|
2
|
+
import { formatAdminURL, getSafeRedirect } from 'payload/shared';
|
|
3
|
+
import { FigmaApiError } from '../../api/figma-api.js';
|
|
4
|
+
import { buildUnauthorizedRedirect } from '../utilities/buildUnauthorizedRedirect.js';
|
|
5
5
|
import { createDebugLogger } from '../utilities/createDebugLogger.js';
|
|
6
|
+
import { establishSession } from '../utilities/establishSession.js';
|
|
7
|
+
import { exchangeCodeForAccessToken } from '../utilities/exchangeCodeForAccessToken.js';
|
|
6
8
|
import { extractOrigin } from '../utilities/extractOrigin.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
const isAbsoluteURL = (url)=>/^[a-z][a-z\d+.-]*:/.test(url);
|
|
9
|
+
import { buildCsrfCookieClearHeader, OAUTH_STATE_CSRF_COOKIE_NAME } from '../utilities/getAuthorizeURL.js';
|
|
10
|
+
import { isAbsoluteURL } from '../utilities/isAbsoluteURL.js';
|
|
10
11
|
export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug, pluginOptions, strategy })=>({
|
|
11
12
|
handler: async (req)=>{
|
|
12
13
|
const { config } = req.payload;
|
|
13
|
-
const
|
|
14
|
+
const adminRoute = config.routes?.admin || '/admin';
|
|
14
15
|
try {
|
|
15
16
|
await strategy.ensureMeta();
|
|
16
17
|
const path = req.pathname;
|
|
@@ -37,9 +38,26 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
37
38
|
}
|
|
38
39
|
const stateRaw = jsonBody.state;
|
|
39
40
|
const state = JSON.parse(Buffer.from(stateRaw, 'base64').toString('utf-8'));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// Resolve the post-login redirect base. This MUST match the precedence
|
|
42
|
+
// used when the OAuth `redirect_uri` is minted at `/meta`
|
|
43
|
+
// (`getAuthorizeURL`: redirectServerURL → config.serverURL →
|
|
44
|
+
// state.serverURL). `state.serverURL` is the iframe's untrusted
|
|
45
|
+
// `window.location.origin` (a `/meta` query param), so it must rank
|
|
46
|
+
// LAST: trusting it first lets the redirect target diverge from the
|
|
47
|
+
// server-configured origin — in the Make preview that origin is http
|
|
48
|
+
// (mixed content) and, more visibly, it isn't in Payload's auto-derived
|
|
49
|
+
// `config.csrf` allowlist (sanitizeConfig pushes `config.serverURL`),
|
|
50
|
+
// so the CSRF origin check below 403s the callback.
|
|
51
|
+
const redirectServerURL = pluginOptions.redirectServerURL || config.serverURL || state.serverURL;
|
|
52
|
+
let failedRedirect = formatAdminURL({
|
|
53
|
+
adminRoute,
|
|
54
|
+
path: '/login',
|
|
55
|
+
serverURL: redirectServerURL
|
|
56
|
+
});
|
|
57
|
+
let redirectToUse = formatAdminURL({
|
|
58
|
+
adminRoute,
|
|
59
|
+
serverURL: redirectServerURL
|
|
60
|
+
});
|
|
43
61
|
if (state.redirect) {
|
|
44
62
|
redirectToUse = state.redirect;
|
|
45
63
|
}
|
|
@@ -93,6 +111,16 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
93
111
|
req.payload.logger.error('Signature mismatch. Failing login and redirecting.');
|
|
94
112
|
return Response.redirect(failedRedirect);
|
|
95
113
|
}
|
|
114
|
+
// Verify CSRF cookie matches the nonce baked into state at /meta time.
|
|
115
|
+
// This is the browser-binding required by RFC 6749 §10.12 — without
|
|
116
|
+
// it, an attacker who mints (code, state) via /meta + consent could
|
|
117
|
+
// replay them into a victim's browser by URL.
|
|
118
|
+
const cookies = parseCookies(req.headers);
|
|
119
|
+
const cookieCsrf = cookies.get(OAUTH_STATE_CSRF_COOKIE_NAME);
|
|
120
|
+
if (!cookieCsrf || cookieCsrf !== state.csrf) {
|
|
121
|
+
req.payload.logger.error('CSRF cookie mismatch. Failing login and redirecting.');
|
|
122
|
+
return Response.redirect(failedRedirect);
|
|
123
|
+
}
|
|
96
124
|
if (!strategy.meta?.token_endpoint) {
|
|
97
125
|
debugLogger.error({
|
|
98
126
|
msg: `No metadata was obtained from the identity provider. Failing login and redirecting.`,
|
|
@@ -121,57 +149,26 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
121
149
|
});
|
|
122
150
|
return Response.redirect(failedRedirect);
|
|
123
151
|
}
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
redirect_uri: `${redirectDestination}${config?.routes?.api || '/api'}/${collection.slug}/${endpointSlug}/login`
|
|
130
|
-
};
|
|
152
|
+
const redirectUri = formatAdminURL({
|
|
153
|
+
apiRoute: config.routes?.api || '/api',
|
|
154
|
+
path: `/${collection.slug}/${endpointSlug}/login`,
|
|
155
|
+
serverURL: redirectServerURL
|
|
156
|
+
});
|
|
131
157
|
debugLogger.info({
|
|
132
158
|
msg: 'Exchanging code for access token',
|
|
133
|
-
path
|
|
134
|
-
requestBody: body
|
|
159
|
+
path
|
|
135
160
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
headers: {
|
|
142
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
143
|
-
},
|
|
144
|
-
method: 'POST'
|
|
145
|
-
}).then((r)=>r.json());
|
|
146
|
-
debugLogger.info({
|
|
147
|
-
msg: 'Token Response',
|
|
148
|
-
path,
|
|
149
|
-
tokenRes
|
|
161
|
+
const tokenRes = await exchangeCodeForAccessToken({
|
|
162
|
+
code,
|
|
163
|
+
codeVerifier: req.payload.decrypt(state.verifier),
|
|
164
|
+
redirectUri,
|
|
165
|
+
strategy
|
|
150
166
|
});
|
|
151
|
-
const { access_token, error, error_description, expires_in: refreshTokenExpires } = tokenRes;
|
|
152
167
|
debugLogger.info({
|
|
153
|
-
msg: '
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
// Swap for project token
|
|
157
|
-
const project_token = await getProjectToken(tokenRes.access_token, 'someproject');
|
|
158
|
-
const refresh_token = access_token;
|
|
159
|
-
// Store project token as access_token
|
|
160
|
-
const token = project_token.token;
|
|
161
|
-
const expiresIn = project_token.expiresAt;
|
|
162
|
-
if (!token) {
|
|
163
|
-
const errMsg = `No ${collectionOptions.token || 'access_token'} was returned from the identity provider.`;
|
|
164
|
-
req.payload.logger.error({
|
|
165
|
-
msg: errMsg,
|
|
166
|
-
path
|
|
167
|
-
});
|
|
168
|
-
throw new APIError(errMsg);
|
|
169
|
-
}
|
|
170
|
-
const cookieOptions = createCookieOptions({
|
|
171
|
-
collection,
|
|
172
|
-
headers: req.headers,
|
|
173
|
-
pluginOptions
|
|
168
|
+
msg: 'Received token response',
|
|
169
|
+
path
|
|
174
170
|
});
|
|
171
|
+
const { access_token, error, error_description, expires_in: refreshTokenExpires } = tokenRes;
|
|
175
172
|
if (error) {
|
|
176
173
|
req.payload.logger.error('Error swapping access code with access token:');
|
|
177
174
|
req.payload.logger.error({
|
|
@@ -180,42 +177,50 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
180
177
|
});
|
|
181
178
|
return Response.redirect(failedRedirect);
|
|
182
179
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
if (!access_token) {
|
|
181
|
+
const errMsg = 'No access_token was returned from the identity provider.';
|
|
182
|
+
req.payload.logger.error({
|
|
183
|
+
msg: errMsg,
|
|
184
|
+
path
|
|
185
|
+
});
|
|
186
|
+
throw new APIError(errMsg);
|
|
187
|
+
}
|
|
188
|
+
const payloadRedirect = cookies.get('payloadRedirect') ?? '';
|
|
186
189
|
if (!req.responseHeaders) {
|
|
187
190
|
req.responseHeaders = new Headers();
|
|
188
191
|
}
|
|
192
|
+
// Clear the CSRF cookie now that the flow has completed — the nonce
|
|
193
|
+
// is single-use; leaving it around lets a replay try again.
|
|
194
|
+
req.responseHeaders.append('Set-Cookie', buildCsrfCookieClearHeader());
|
|
189
195
|
if (payloadRedirect) {
|
|
190
196
|
if (isAbsoluteURL(payloadRedirect)) {
|
|
191
197
|
redirectToUse = payloadRedirect;
|
|
192
198
|
} else {
|
|
193
199
|
redirectToUse += payloadRedirect;
|
|
194
200
|
}
|
|
195
|
-
req.responseHeaders.append('Set-Cookie',
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
req.responseHeaders.append('Set-Cookie', // Match the attributes the cookie was set with so the clear removes it
|
|
202
|
+
// in the cross-site Make iframe.
|
|
203
|
+
`payloadRedirect=${redirectToUse}; Max-Age=0; Path=/; Secure; SameSite=None; Partitioned`);
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
await establishSession({
|
|
207
|
+
accessToken: access_token,
|
|
208
|
+
collection,
|
|
209
|
+
collectionOptions,
|
|
210
|
+
debugLogger,
|
|
211
|
+
environmentId: config.custom.figma.environmentId,
|
|
212
|
+
pluginOptions,
|
|
213
|
+
refreshTokenExpiresIn: refreshTokenExpires,
|
|
214
|
+
req,
|
|
215
|
+
strategy
|
|
206
216
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
expires: tokenExpires,
|
|
215
|
-
returnCookieAsObject: false,
|
|
216
|
-
value: token
|
|
217
|
-
});
|
|
218
|
-
req.responseHeaders.append('Set-Cookie', tokenCookie);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
// The admin-token endpoint returns 403 when the user cannot access this environment.
|
|
219
|
+
if (err instanceof FigmaApiError && err.statusCode === 403) {
|
|
220
|
+
return buildUnauthorizedRedirect(config);
|
|
221
|
+
}
|
|
222
|
+
throw err;
|
|
223
|
+
}
|
|
219
224
|
return Response.redirect(redirectToUse);
|
|
220
225
|
} catch (err) {
|
|
221
226
|
req.payload.logger.error({
|
|
@@ -233,5 +238,3 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
233
238
|
method: collectionOptions.authorizationURLParams?.response_mode === 'query' ? 'get' : 'post',
|
|
234
239
|
path: `/${endpointSlug}/login`
|
|
235
240
|
});
|
|
236
|
-
|
|
237
|
-
//# sourceMappingURL=getLoginEndpoint.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
2
|
import { parseCookies } from 'payload';
|
|
3
|
+
import { formatAdminURL } from 'payload/shared';
|
|
3
4
|
import { clearCookie } from '../utilities/clearCookie.js';
|
|
4
5
|
import { createCookieOptions } from '../utilities/createCookieOptions.js';
|
|
5
6
|
import { createDebugLogger } from '../utilities/createDebugLogger.js';
|
|
6
|
-
import { getAdminPath } from '../utilities/getAdminPath.js';
|
|
7
7
|
export const getLogoutEndpoint = ({ collection, endpointSlug, pluginOptions, strategy })=>({
|
|
8
8
|
handler: async (req)=>{
|
|
9
9
|
const debugLogger = createDebugLogger(req.payload, pluginOptions.debug);
|
|
@@ -23,12 +23,15 @@ export const getLogoutEndpoint = ({ collection, endpointSlug, pluginOptions, str
|
|
|
23
23
|
}
|
|
24
24
|
try {
|
|
25
25
|
await strategy.ensureMeta();
|
|
26
|
-
const
|
|
27
|
-
let successfulLogoutRedirectDest =
|
|
26
|
+
const redirectServerlURL = pluginOptions.redirectServerURL || config.serverURL;
|
|
27
|
+
let successfulLogoutRedirectDest = formatAdminURL({
|
|
28
|
+
adminRoute: config.routes?.admin || '/admin',
|
|
29
|
+
serverURL: redirectServerlURL
|
|
30
|
+
});
|
|
28
31
|
if (typeof req.query.redirect === 'string') {
|
|
29
32
|
successfulLogoutRedirectDest = req.query.redirect;
|
|
30
33
|
}
|
|
31
|
-
if (!
|
|
34
|
+
if (!redirectServerlURL && !req.query.redirect) {
|
|
32
35
|
debugLogger.error({
|
|
33
36
|
msg: 'No redirect URL provided',
|
|
34
37
|
path: req.pathname
|
|
@@ -95,5 +98,3 @@ export const getLogoutEndpoint = ({ collection, endpointSlug, pluginOptions, str
|
|
|
95
98
|
method: 'get',
|
|
96
99
|
path: `/${endpointSlug}/logout`
|
|
97
100
|
});
|
|
98
|
-
|
|
99
|
-
//# sourceMappingURL=getLogoutEndpoint.js.map
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseCookies } from 'payload';
|
|
2
|
+
import { buildCsrfCookieHeader, getAuthorizeURL, OAUTH_STATE_CSRF_COOKIE_NAME } from '../utilities/getAuthorizeURL.js';
|
|
2
3
|
export const getMetaEndpoint = ({ collection, collectionOptions, endpointSlug, pluginOptions, strategy })=>({
|
|
3
4
|
handler: async (req)=>{
|
|
4
|
-
|
|
5
|
+
// Reuse the CSRF nonce from the existing cookie if one is set. Makes
|
|
6
|
+
// `/meta` idempotent: a second call from the same browser (Strict Mode
|
|
7
|
+
// re-mount, retry, multi-tab) returns the SAME state.csrf, so the
|
|
8
|
+
// cookie never has to change after the first call — no last-write-wins
|
|
9
|
+
// race between the cookie and the iframe's already-captured state.
|
|
10
|
+
const existingCsrfNonce = parseCookies(req.headers).get(OAUTH_STATE_CSRF_COOKIE_NAME);
|
|
11
|
+
const { authorizeURL, csrfNonce, params } = await getAuthorizeURL({
|
|
5
12
|
collection,
|
|
6
13
|
collectionOptions,
|
|
7
14
|
endpointSlug,
|
|
15
|
+
existingCsrfNonce,
|
|
8
16
|
failedRedirect: req.query.failedRedirect,
|
|
9
17
|
payload: req.payload,
|
|
10
18
|
pluginOptions,
|
|
@@ -12,8 +20,15 @@ export const getMetaEndpoint = ({ collection, collectionOptions, endpointSlug, p
|
|
|
12
20
|
serverURLOverride: req.query.serverURL,
|
|
13
21
|
strategy
|
|
14
22
|
});
|
|
23
|
+
if (!req.responseHeaders) {
|
|
24
|
+
req.responseHeaders = new Headers();
|
|
25
|
+
}
|
|
26
|
+
// Always re-emit Set-Cookie — when reusing, this just refreshes Max-Age
|
|
27
|
+
// so long-lived tabs don't expire the cookie mid-consent.
|
|
28
|
+
req.responseHeaders.append('Set-Cookie', buildCsrfCookieHeader(csrfNonce));
|
|
15
29
|
return Response.json({
|
|
16
|
-
authorizeURL
|
|
30
|
+
authorizeURL,
|
|
31
|
+
params
|
|
17
32
|
}, {
|
|
18
33
|
status: 200
|
|
19
34
|
});
|
|
@@ -21,5 +36,3 @@ export const getMetaEndpoint = ({ collection, collectionOptions, endpointSlug, p
|
|
|
21
36
|
method: 'get',
|
|
22
37
|
path: `/${endpointSlug}/meta`
|
|
23
38
|
});
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=getMetaEndpoint.js.map
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseCookies } from 'payload';
|
|
2
|
+
import { buildCsrfCookieHeader, getAuthorizeURL, OAUTH_STATE_CSRF_COOKIE_NAME } from '../utilities/getAuthorizeURL.js';
|
|
2
3
|
export const getRedirectToLoginEndpoint = ({ collection, collectionOptions, endpointSlug, pluginOptions, strategy })=>({
|
|
3
4
|
handler: async (req)=>{
|
|
4
|
-
|
|
5
|
+
// Reuse the CSRF nonce from the existing cookie if one is set. See
|
|
6
|
+
// getMetaEndpoint.ts for the idempotency rationale.
|
|
7
|
+
const existingCsrfNonce = parseCookies(req.headers).get(OAUTH_STATE_CSRF_COOKIE_NAME);
|
|
8
|
+
const { authorizeURL, csrfNonce } = await getAuthorizeURL({
|
|
5
9
|
collection,
|
|
6
10
|
collectionOptions,
|
|
7
11
|
endpointSlug,
|
|
12
|
+
existingCsrfNonce,
|
|
8
13
|
failedRedirect: req.query.failedRedirect,
|
|
9
14
|
payload: req.payload,
|
|
10
15
|
pluginOptions,
|
|
@@ -12,10 +17,12 @@ export const getRedirectToLoginEndpoint = ({ collection, collectionOptions, endp
|
|
|
12
17
|
serverURLOverride: req.query.serverURL,
|
|
13
18
|
strategy
|
|
14
19
|
});
|
|
20
|
+
if (!req.responseHeaders) {
|
|
21
|
+
req.responseHeaders = new Headers();
|
|
22
|
+
}
|
|
23
|
+
req.responseHeaders.append('Set-Cookie', buildCsrfCookieHeader(csrfNonce));
|
|
15
24
|
return Response.redirect(authorizeURL);
|
|
16
25
|
},
|
|
17
26
|
method: 'get',
|
|
18
27
|
path: `/${endpointSlug}/login`
|
|
19
28
|
});
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=getRedirectToLoginEndpoint.js.map
|
package/dist/oauth/hooks/me.d.ts
CHANGED
package/dist/oauth/hooks/me.js
CHANGED
|
@@ -6,6 +6,7 @@ import { getCookieExpiration } from '../utilities/getCookieExpiration.js';
|
|
|
6
6
|
import { getTokenExp } from '../utilities/getTokenExp.js';
|
|
7
7
|
import { mergeHeaders } from '../utilities/mergeHeaders.js';
|
|
8
8
|
import { refreshTokens } from '../utilities/refreshTokens.js';
|
|
9
|
+
import { withPartitionedCookie } from '../utilities/withPartitionedCookie.js';
|
|
9
10
|
export const getRefreshHook = ({ pluginOptions, strategy })=>async ({ args, user })=>{
|
|
10
11
|
if (!args.req.responseHeaders) {
|
|
11
12
|
args.req.responseHeaders = new Headers();
|
|
@@ -47,7 +48,7 @@ export const getRefreshHook = ({ pluginOptions, strategy })=>async ({ args, user
|
|
|
47
48
|
}) ?? 31_556_952),
|
|
48
49
|
value: refreshedToken
|
|
49
50
|
});
|
|
50
|
-
args.req.responseHeaders.append('Set-Cookie', refreshCookie);
|
|
51
|
+
args.req.responseHeaders.append('Set-Cookie', withPartitionedCookie(refreshCookie));
|
|
51
52
|
const newDecoded = jwt.decode(refreshedToken);
|
|
52
53
|
strategy.debugLog('usePayloadJWT: true - Received new refresh token', {
|
|
53
54
|
newDecoded,
|
|
@@ -87,5 +88,3 @@ export const getRefreshHook = ({ pluginOptions, strategy })=>async ({ args, user
|
|
|
87
88
|
}
|
|
88
89
|
return undefined;
|
|
89
90
|
};
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=refresh.js.map
|
package/dist/oauth/index.d.ts
CHANGED