@payloadcms/figma 0.0.1-alpha.6 → 0.0.1-alpha.61
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 +52 -6
- package/dist/api/control-plane.js +174 -72
- package/dist/api/figma-api.d.ts +22 -1
- package/dist/api/figma-api.js +78 -25
- package/dist/auth/callback-server.js +2 -1
- package/dist/auth/credentials.d.ts +21 -0
- package/dist/auth/credentials.js +21 -0
- package/dist/auth/crypto-utils.d.ts +6 -0
- package/dist/auth/crypto-utils.js +16 -14
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +17 -3
- package/dist/auth/oauth-flow.js +63 -16
- package/dist/auth/project-token.js +16 -11
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store.d.ts +42 -1
- package/dist/auth/token-store.js +118 -14
- package/dist/auth/types.d.ts +17 -4
- package/dist/cli.js +68 -5
- 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 +176 -0
- package/dist/commands/deploy.d.ts +9 -0
- package/dist/commands/deploy.js +178 -151
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +3 -5
- package/dist/commands/init.js +165 -148
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +22 -7
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +33 -15
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +56 -13
- package/dist/commands/upgrade.d.ts +5 -0
- package/dist/commands/upgrade.js +331 -0
- package/dist/config/oauth.d.ts +4 -14
- package/dist/config/oauth.js +18 -40
- package/dist/constants.d.ts +44 -19
- package/dist/constants.js +73 -20
- package/dist/db-content-api/README.md +98 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +3972 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +21 -0
- package/dist/db-content-api/index.js +914 -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 +59 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +81 -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/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/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/index.js +50 -6
- package/dist/oauth/components/LoginButton/index.scss +50 -3
- package/dist/oauth/components/LogoutButton/index.js +5 -4
- package/dist/oauth/defaults.js +67 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +77 -24
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/index.js +40 -13
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +6 -6
- 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/build-config.d.ts +18 -15
- package/dist/plugin/build-config.js +213 -18
- 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 +42 -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 +36 -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 +56 -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 +2 -0
- package/dist/storage-content-api/utilities/index.js +3 -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 +8 -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 +14 -0
- package/dist/utils/build-lambda-zip.js +81 -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.js +3 -2
- 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 +29 -11
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -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 +70 -11
- package/dist/utils/payload-package-check.d.ts +12 -1
- package/dist/utils/payload-package-check.js +63 -5
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.js +29 -15
- 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.js +11 -5
- 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 +33 -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
package/dist/commands/logout.js
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import {
|
|
3
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
4
|
+
import { getInfraEnvironment } from '../constants.js';
|
|
5
|
+
import { formatEnvSuffix } from '../utils/format-env-suffix.js';
|
|
4
6
|
import * as log from '../utils/log.js';
|
|
7
|
+
const ALL_ENVIRONMENTS = [
|
|
8
|
+
'production',
|
|
9
|
+
'staging'
|
|
10
|
+
];
|
|
5
11
|
/**
|
|
6
12
|
* Handle the `@payloadcms/figma logout` command
|
|
7
13
|
*
|
|
8
|
-
* Clears
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
* Clears stored tokens (OAuth and project tokens) after confirmation.
|
|
15
|
+
* By default clears only current environment. Use --all for all environments.
|
|
16
|
+
*/ export async function logoutCommand(options = {}) {
|
|
17
|
+
const currentEnv = getInfraEnvironment();
|
|
18
|
+
if (options.all) {
|
|
19
|
+
await logoutAllEnvironments();
|
|
20
|
+
} else {
|
|
21
|
+
await logoutSingleEnvironment(currentEnv);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function logoutSingleEnvironment(env) {
|
|
25
|
+
const tokenStore = getTokenStore(env);
|
|
13
26
|
const hasTokens = tokenStore.getTokens() !== null;
|
|
14
27
|
if (!hasTokens) {
|
|
15
|
-
p.log.warn(pc.yellow(
|
|
28
|
+
p.log.warn(pc.yellow(`No tokens found${formatEnvSuffix(env, ' for ')}. Already logged out.`));
|
|
16
29
|
return;
|
|
17
30
|
}
|
|
18
|
-
// Confirm logout
|
|
19
31
|
const confirmed = await p.confirm({
|
|
20
32
|
initialValue: false,
|
|
21
|
-
message:
|
|
33
|
+
message: `This will clear all OAuth and project tokens${formatEnvSuffix(env, ' for ')}. Continue?`
|
|
22
34
|
});
|
|
23
35
|
if (p.isCancel(confirmed) || !confirmed) {
|
|
24
36
|
p.log.info('Logout cancelled');
|
|
@@ -27,12 +39,43 @@ import * as log from '../utils/log.js';
|
|
|
27
39
|
const s = p.spinner();
|
|
28
40
|
s.start('Clearing tokens...');
|
|
29
41
|
try {
|
|
30
|
-
// Clear OAuth tokens
|
|
31
42
|
tokenStore.clearTokens();
|
|
32
|
-
// Clear all project tokens
|
|
33
43
|
tokenStore.clearAllProjectTokens();
|
|
34
|
-
s.stop(pc.green(
|
|
35
|
-
|
|
44
|
+
s.stop(pc.green(`✓ Logged out${formatEnvSuffix(env, ' from ')}`));
|
|
45
|
+
} catch (error) {
|
|
46
|
+
s.stop(pc.red('✗ Failed to clear tokens'));
|
|
47
|
+
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function logoutAllEnvironments() {
|
|
52
|
+
// Check which environments have tokens
|
|
53
|
+
const envsWithTokens = ALL_ENVIRONMENTS.filter((env)=>{
|
|
54
|
+
const store = getTokenStore(env);
|
|
55
|
+
return store.getTokens() !== null;
|
|
56
|
+
});
|
|
57
|
+
if (envsWithTokens.length === 0) {
|
|
58
|
+
p.log.warn(pc.yellow('No tokens found in any environment. Already logged out.'));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const envList = envsWithTokens.join(' and ');
|
|
62
|
+
const confirmed = await p.confirm({
|
|
63
|
+
initialValue: false,
|
|
64
|
+
message: `This will clear all OAuth and project tokens for ${envList}. Continue?`
|
|
65
|
+
});
|
|
66
|
+
if (p.isCancel(confirmed) || !confirmed) {
|
|
67
|
+
p.log.info('Logout cancelled');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const s = p.spinner();
|
|
71
|
+
s.start('Clearing tokens...');
|
|
72
|
+
try {
|
|
73
|
+
for (const env of envsWithTokens){
|
|
74
|
+
const store = getTokenStore(env);
|
|
75
|
+
store.clearTokens();
|
|
76
|
+
store.clearAllProjectTokens();
|
|
77
|
+
}
|
|
78
|
+
s.stop(pc.green('✓ Logged out from all environments'));
|
|
36
79
|
} catch (error) {
|
|
37
80
|
s.stop(pc.red('✗ Failed to clear tokens'));
|
|
38
81
|
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import pc from 'picocolors';
|
|
5
|
+
import { Project } from 'ts-morph';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { getBootstrapInfo, getCmsResourceId } from '../api/control-plane.js';
|
|
8
|
+
import { getValidCredential } from '../auth/oauth-flow.js';
|
|
9
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
10
|
+
import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
|
|
11
|
+
import { addOrUpdateEnvVar, getEnvVar, removeEnvVar } from '../utils/env-management.js';
|
|
12
|
+
import { formatFile } from '../utils/formatter.js';
|
|
13
|
+
import { getPackageManager } from '../utils/package-manager.js';
|
|
14
|
+
import { removeFigmaContentSystemId } from '../utils/payload-config-ast.js';
|
|
15
|
+
import { findPayloadConfig } from '../utils/payload-config-finder.js';
|
|
16
|
+
import { checkPackageInstalled, installPackage } from '../utils/payload-package-check.js';
|
|
17
|
+
import { getOwnVersion } from '../utils/version-check.js';
|
|
18
|
+
export async function upgradeCommand(options = {}) {
|
|
19
|
+
const cwd = process.cwd();
|
|
20
|
+
const { isDryRun = false } = options;
|
|
21
|
+
const changes = [];
|
|
22
|
+
const warnings = [];
|
|
23
|
+
const spinner = p.spinner();
|
|
24
|
+
spinner.start('Checking for needed migrations...');
|
|
25
|
+
spinner.stop('Checking for needed migrations...');
|
|
26
|
+
await migrateEnvRename({
|
|
27
|
+
changes,
|
|
28
|
+
cwd,
|
|
29
|
+
isDryRun
|
|
30
|
+
});
|
|
31
|
+
await migrateProjectId({
|
|
32
|
+
changes,
|
|
33
|
+
cwd,
|
|
34
|
+
isDryRun,
|
|
35
|
+
warnings
|
|
36
|
+
});
|
|
37
|
+
await ensureBootstrapCached({
|
|
38
|
+
changes,
|
|
39
|
+
cwd,
|
|
40
|
+
isDryRun
|
|
41
|
+
});
|
|
42
|
+
await migrateRemoveDeprecatedEnvVars({
|
|
43
|
+
changes,
|
|
44
|
+
cwd,
|
|
45
|
+
isDryRun,
|
|
46
|
+
warnings
|
|
47
|
+
});
|
|
48
|
+
await migrateConfigAst({
|
|
49
|
+
changes,
|
|
50
|
+
cwd,
|
|
51
|
+
isDryRun
|
|
52
|
+
});
|
|
53
|
+
await migratePackageVersion({
|
|
54
|
+
changes,
|
|
55
|
+
cwd,
|
|
56
|
+
isDryRun
|
|
57
|
+
});
|
|
58
|
+
for (const warning of warnings){
|
|
59
|
+
p.log.warning(warning);
|
|
60
|
+
}
|
|
61
|
+
if (changes.length === 0) {
|
|
62
|
+
p.log.success('Everything is up to date.');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (isDryRun) {
|
|
66
|
+
p.log.info(`Dry run: ${changes.length} change(s) detected.`);
|
|
67
|
+
} else {
|
|
68
|
+
p.log.success(`${changes.length} change(s) applied.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const DEPRECATED_ENV_VARS = [
|
|
72
|
+
'FIGMA_CONTENT_API_CONTENT_SYSTEM_ID',
|
|
73
|
+
'FIGMA_TENANT_ID',
|
|
74
|
+
'FIGMA_OAUTH_CLIENT_ID',
|
|
75
|
+
'FIGMA_OAUTH_CLIENT_SECRET'
|
|
76
|
+
];
|
|
77
|
+
async function migrateEnvRename({ changes, cwd, isDryRun }) {
|
|
78
|
+
try {
|
|
79
|
+
const oldValue = await getEnvVar(cwd, 'FIGMA_ENV');
|
|
80
|
+
if (oldValue === null) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (isDryRun) {
|
|
84
|
+
p.log.message(`${pc.dim('○')} Would rename FIGMA_ENV → FIGMA_INFRA_ENV`);
|
|
85
|
+
changes.push('Rename FIGMA_ENV → FIGMA_INFRA_ENV');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await addOrUpdateEnvVar(cwd, 'FIGMA_INFRA_ENV', oldValue);
|
|
89
|
+
await removeEnvVar(cwd, 'FIGMA_ENV');
|
|
90
|
+
p.log.message(`${pc.green('●')} Env: Renamed FIGMA_ENV → FIGMA_INFRA_ENV`);
|
|
91
|
+
changes.push('Renamed FIGMA_ENV → FIGMA_INFRA_ENV');
|
|
92
|
+
} catch (error) {
|
|
93
|
+
const msg = error instanceof Error ? error.message : 'Unknown error';
|
|
94
|
+
p.log.warning(`Env rename migration failed: ${msg}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function migrateProjectId({ changes, cwd, isDryRun, warnings = [] }) {
|
|
98
|
+
try {
|
|
99
|
+
const existingProjectId = await getEnvVar(cwd, 'FIGMA_PROJECT_ID');
|
|
100
|
+
if (existingProjectId) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const oldContentSystemId = await getEnvVar(cwd, 'FIGMA_CONTENT_API_CONTENT_SYSTEM_ID');
|
|
104
|
+
if (!oldContentSystemId) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (isDryRun) {
|
|
108
|
+
p.log.message(`${pc.dim('○')} Would resolve FIGMA_PROJECT_ID from content system ID`);
|
|
109
|
+
changes.push('Resolve FIGMA_PROJECT_ID from content system ID');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const store = getTokenStore();
|
|
113
|
+
const credential = await getValidCredential(store);
|
|
114
|
+
if (!credential) {
|
|
115
|
+
warnings.push('Not authenticated — could not resolve FIGMA_PROJECT_ID. Run `npx @payloadcms/figma login` first.');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const cmsResourceId = await getCmsResourceId(credential, oldContentSystemId);
|
|
119
|
+
await addOrUpdateEnvVar(cwd, 'FIGMA_PROJECT_ID', cmsResourceId);
|
|
120
|
+
// Resolve actual environment name from bootstrap API
|
|
121
|
+
try {
|
|
122
|
+
const bootstrapInfo = await getBootstrapInfo(credential, cmsResourceId);
|
|
123
|
+
cacheAllEnvironments(store, cmsResourceId, bootstrapInfo);
|
|
124
|
+
const envName = bootstrapInfo.environments[0]?.name ?? 'production';
|
|
125
|
+
await addOrUpdateEnvVar(cwd, 'FIGMA_ENVIRONMENT_NAME', envName);
|
|
126
|
+
} catch {
|
|
127
|
+
await addOrUpdateEnvVar(cwd, 'FIGMA_ENVIRONMENT_NAME', 'production');
|
|
128
|
+
}
|
|
129
|
+
p.log.message(`${pc.green('●')} Env: Resolved FIGMA_PROJECT_ID from content system ID`);
|
|
130
|
+
changes.push('Resolved FIGMA_PROJECT_ID from content system ID');
|
|
131
|
+
} catch (error) {
|
|
132
|
+
const msg = error instanceof Error ? error.message : 'Unknown error';
|
|
133
|
+
p.log.warning(`Project ID migration failed: ${msg}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function ensureBootstrapCached(params) {
|
|
137
|
+
try {
|
|
138
|
+
const projectId = await getEnvVar(params.cwd, 'FIGMA_PROJECT_ID');
|
|
139
|
+
if (!projectId) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const environmentName = await getEnvVar(params.cwd, 'FIGMA_ENVIRONMENT_NAME') ?? 'production';
|
|
143
|
+
const store = getTokenStore();
|
|
144
|
+
if (store.getBootstrapData(projectId, environmentName)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const credential = await getValidCredential(store);
|
|
148
|
+
if (!credential) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const bootstrapInfo = await getBootstrapInfo(credential, projectId);
|
|
152
|
+
cacheAllEnvironments(store, projectId, bootstrapInfo);
|
|
153
|
+
// Fix FIGMA_ENVIRONMENT_NAME if it doesn't match any actual environment
|
|
154
|
+
const envNames = bootstrapInfo.environments.map((e)=>e.name);
|
|
155
|
+
if (!envNames.includes(environmentName) && envNames.length > 0) {
|
|
156
|
+
const correctName = envNames[0];
|
|
157
|
+
if (params.isDryRun) {
|
|
158
|
+
p.log.message(`${pc.dim('○')} Would fix FIGMA_ENVIRONMENT_NAME: ${environmentName} → ${correctName}`);
|
|
159
|
+
params.changes.push(`Fix FIGMA_ENVIRONMENT_NAME`);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
await addOrUpdateEnvVar(params.cwd, 'FIGMA_ENVIRONMENT_NAME', correctName);
|
|
163
|
+
p.log.message(`${pc.green('●')} Env: Fixed FIGMA_ENVIRONMENT_NAME: ${environmentName} → ${correctName}`);
|
|
164
|
+
params.changes.push(`Fixed FIGMA_ENVIRONMENT_NAME: ${environmentName} → ${correctName}`);
|
|
165
|
+
}
|
|
166
|
+
} catch {
|
|
167
|
+
// Best-effort — runtime will retry if needed
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async function migrateRemoveDeprecatedEnvVars({ changes, cwd, isDryRun, warnings = [] }) {
|
|
171
|
+
try {
|
|
172
|
+
const presentVars = [];
|
|
173
|
+
for (const key of DEPRECATED_ENV_VARS){
|
|
174
|
+
const value = await getEnvVar(cwd, key);
|
|
175
|
+
if (value !== null) {
|
|
176
|
+
presentVars.push(key);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (presentVars.length === 0) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Only remove when bootstrap data is available (proves the project is set up correctly)
|
|
183
|
+
const projectId = await getEnvVar(cwd, 'FIGMA_PROJECT_ID');
|
|
184
|
+
if (!projectId) {
|
|
185
|
+
warnings.push('Cannot remove deprecated env vars without FIGMA_PROJECT_ID. Run upgrade again after project ID migration.');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const environmentName = await getEnvVar(cwd, 'FIGMA_ENVIRONMENT_NAME') ?? 'production';
|
|
189
|
+
const store = getTokenStore();
|
|
190
|
+
const bootstrapData = store.getBootstrapData(projectId, environmentName);
|
|
191
|
+
if (!bootstrapData) {
|
|
192
|
+
// Try fetching from API
|
|
193
|
+
const credential = await getValidCredential(store);
|
|
194
|
+
if (credential) {
|
|
195
|
+
try {
|
|
196
|
+
const bootstrapInfo = await getBootstrapInfo(credential, projectId);
|
|
197
|
+
cacheAllEnvironments(store, projectId, bootstrapInfo);
|
|
198
|
+
} catch {
|
|
199
|
+
warnings.push('Could not verify bootstrap data — keeping deprecated env vars. Run `npx @payloadcms/figma init` to complete migration.');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
warnings.push('Not authenticated — keeping deprecated env vars. Run `npx @payloadcms/figma login` first.');
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (isDryRun) {
|
|
208
|
+
p.log.message(`${pc.dim('○')} Would remove deprecated env vars: ${presentVars.join(', ')}`);
|
|
209
|
+
changes.push(`Remove deprecated env vars: ${presentVars.join(', ')}`);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const removed = [];
|
|
213
|
+
for (const key of presentVars){
|
|
214
|
+
await removeEnvVar(cwd, key);
|
|
215
|
+
removed.push(key);
|
|
216
|
+
}
|
|
217
|
+
p.log.message(`${pc.green('●')} Env: Removed deprecated env vars: ${removed.join(', ')}`);
|
|
218
|
+
changes.push(`Removed deprecated env vars: ${removed.join(', ')}`);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
const msg = error instanceof Error ? error.message : 'Unknown error';
|
|
221
|
+
p.log.warning(`Deprecated env var removal failed: ${msg}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async function migrateConfigAst({ changes, cwd, isDryRun }) {
|
|
225
|
+
try {
|
|
226
|
+
const configPath = await findPayloadConfig(cwd);
|
|
227
|
+
if (!configPath) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const project = new Project({
|
|
231
|
+
skipAddingFilesFromTsConfig: true
|
|
232
|
+
});
|
|
233
|
+
const sourceFile = project.addSourceFileAtPath(configPath);
|
|
234
|
+
const wouldRemove = removeFigmaContentSystemId(sourceFile);
|
|
235
|
+
if (!wouldRemove) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (isDryRun) {
|
|
239
|
+
p.log.message(`${pc.dim('○')} Would remove contentSystemId from payload.config.ts`);
|
|
240
|
+
changes.push('Remove contentSystemId from payload.config.ts');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// Re-parse fresh since the detection already mutated the AST
|
|
244
|
+
const freshProject = new Project({
|
|
245
|
+
skipAddingFilesFromTsConfig: true
|
|
246
|
+
});
|
|
247
|
+
const freshSourceFile = freshProject.addSourceFileAtPath(configPath);
|
|
248
|
+
removeFigmaContentSystemId(freshSourceFile);
|
|
249
|
+
await freshSourceFile.save();
|
|
250
|
+
try {
|
|
251
|
+
const packageManager = await getPackageManager(cwd);
|
|
252
|
+
await formatFile(configPath, packageManager);
|
|
253
|
+
} catch {
|
|
254
|
+
// Formatting is best-effort
|
|
255
|
+
}
|
|
256
|
+
p.log.message(`${pc.green('●')} Config: Removed contentSystemId from payload.config.ts`);
|
|
257
|
+
changes.push('Removed contentSystemId from payload.config.ts');
|
|
258
|
+
} catch (error) {
|
|
259
|
+
const msg = error instanceof Error ? error.message : 'Unknown error';
|
|
260
|
+
p.log.warning(`Config AST migration failed: ${msg}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
async function migratePackageVersion({ changes, cwd, isDryRun }) {
|
|
264
|
+
try {
|
|
265
|
+
const isInstalled = await checkPackageInstalled(cwd, '@payloadcms/figma');
|
|
266
|
+
if (!isInstalled) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const cliDir = path.dirname(fileURLToPath(import.meta.url));
|
|
270
|
+
const isFromRegistry = cliDir.includes('node_modules') || cliDir.includes('.npm');
|
|
271
|
+
if (isFromRegistry) {
|
|
272
|
+
await migrateRegistryPackageVersion({
|
|
273
|
+
changes,
|
|
274
|
+
cliDir,
|
|
275
|
+
cwd,
|
|
276
|
+
isDryRun
|
|
277
|
+
});
|
|
278
|
+
} else {
|
|
279
|
+
await migrateLocalPackageVersion({
|
|
280
|
+
changes,
|
|
281
|
+
cliDir,
|
|
282
|
+
cwd,
|
|
283
|
+
isDryRun
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
} catch (error) {
|
|
287
|
+
const msg = error instanceof Error ? error.message : 'Unknown error';
|
|
288
|
+
p.log.warning(`Package version sync failed: ${msg}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
async function migrateRegistryPackageVersion({ changes, cliDir: _cliDir, cwd, isDryRun }) {
|
|
292
|
+
const cliVersion = await getOwnVersion();
|
|
293
|
+
const pkgJsonPath = path.join(cwd, 'package.json');
|
|
294
|
+
const pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, 'utf-8'));
|
|
295
|
+
const installedVersion = pkgJson.dependencies?.['@payloadcms/figma']?.replace(/^[\^~>=<]+/, '');
|
|
296
|
+
if (!installedVersion || installedVersion === cliVersion) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (isDryRun) {
|
|
300
|
+
p.log.message(`${pc.dim('○')} Would update @payloadcms/figma ${installedVersion} → ${cliVersion}`);
|
|
301
|
+
changes.push(`Update @payloadcms/figma ${installedVersion} → ${cliVersion}`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const packageManager = await getPackageManager(cwd);
|
|
305
|
+
await installPackage(cwd, '@payloadcms/figma', packageManager, cliVersion);
|
|
306
|
+
p.log.message(`${pc.green('●')} Package: Updated @payloadcms/figma ${installedVersion} → ${cliVersion}`);
|
|
307
|
+
changes.push(`Updated @payloadcms/figma ${installedVersion} → ${cliVersion}`);
|
|
308
|
+
}
|
|
309
|
+
async function migrateLocalPackageVersion({ changes, cliDir, cwd, isDryRun }) {
|
|
310
|
+
if (isDryRun) {
|
|
311
|
+
p.log.message(`${pc.dim('○')} Would install @payloadcms/figma from local build`);
|
|
312
|
+
changes.push('Install @payloadcms/figma from local build');
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// Dynamic import — findPackageRoot and packLocalPackage will be exported in a later task
|
|
316
|
+
const { findPackageRoot, packLocalPackage } = await import('../utils/handle-upgrade.js');
|
|
317
|
+
const pkgDir = await findPackageRoot(cliDir);
|
|
318
|
+
if (!pkgDir) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const packageManager = await getPackageManager(cwd);
|
|
322
|
+
const tgzPath = packLocalPackage(pkgDir);
|
|
323
|
+
const destTgz = path.join(cwd, path.basename(tgzPath));
|
|
324
|
+
await fs.rename(tgzPath, destTgz);
|
|
325
|
+
await installPackage(cwd, destTgz, packageManager);
|
|
326
|
+
await fs.unlink(destTgz).catch(()=>{});
|
|
327
|
+
p.log.message(`${pc.green('●')} Package: Installed @payloadcms/figma from local build`);
|
|
328
|
+
changes.push('Installed @payloadcms/figma from local build');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
//# sourceMappingURL=upgrade.js.map
|
package/dist/config/oauth.d.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import type { OAuthConfig } from '../auth/types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const DEFAULT_CALLBACK_PORT = 34462;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).
|
|
7
|
-
* No client secret is used because CLIs cannot securely store secrets.
|
|
8
|
-
* PKCE provides security through the code_verifier/code_challenge mechanism.
|
|
9
|
-
*
|
|
10
|
-
* For production use, register a public OAuth app with Figma.
|
|
11
|
-
* To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2
|
|
12
|
-
*/
|
|
13
|
-
export declare const OAUTH_CONFIG: OAuthConfig;
|
|
14
|
-
/**
|
|
15
|
-
* Buffer time (in seconds) before token expiration to consider token as expired
|
|
16
|
-
* This helps avoid using tokens that are about to expire
|
|
4
|
+
* Get OAuth configuration for current environment
|
|
5
|
+
* Uses getEnvConfig() to determine staging vs production
|
|
17
6
|
*/
|
|
7
|
+
export declare function getOAuthConfig(): OAuthConfig;
|
|
18
8
|
export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
|
|
19
9
|
//# sourceMappingURL=oauth.d.ts.map
|
package/dist/config/oauth.js
CHANGED
|
@@ -1,43 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
3
|
-
prod: {
|
|
4
|
-
authorizationUrl: 'https://www.figma.com/oauth',
|
|
5
|
-
refreshUrl: 'https://api.figma.com/v1/oauth/refresh',
|
|
6
|
-
tokenUrl: 'https://api.figma.com/v1/oauth/token'
|
|
7
|
-
},
|
|
8
|
-
staging: {
|
|
9
|
-
authorizationUrl: 'https://staging.figma.com/oauth',
|
|
10
|
-
refreshUrl: 'https://api.staging.figma.com/v1/oauth/refresh',
|
|
11
|
-
tokenUrl: 'https://api.staging.figma.com/v1/oauth/token'
|
|
12
|
-
}
|
|
13
|
-
};
|
|
1
|
+
import { getEnvConfig } from '../constants.js';
|
|
2
|
+
export const DEFAULT_CALLBACK_PORT = 34462;
|
|
14
3
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
scopes: [
|
|
32
|
-
'current_user:read'
|
|
33
|
-
],
|
|
34
|
-
// TODO: Dynamically choose between prod and staging based on environment
|
|
35
|
-
...URLS.staging
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Buffer time (in seconds) before token expiration to consider token as expired
|
|
39
|
-
* This helps avoid using tokens that are about to expire
|
|
40
|
-
*/ export const TOKEN_EXPIRY_BUFFER_SECONDS = 300 // 5 minutes
|
|
41
|
-
;
|
|
4
|
+
* Get OAuth configuration for current environment
|
|
5
|
+
* Uses getEnvConfig() to determine staging vs production
|
|
6
|
+
*/ export function getOAuthConfig() {
|
|
7
|
+
const { apiBaseUrl, authorizationUrl, clientId } = getEnvConfig();
|
|
8
|
+
return {
|
|
9
|
+
authorizationUrl,
|
|
10
|
+
clientId: process.env.FIGMA_CLIENT_ID || clientId,
|
|
11
|
+
redirectUri: process.env.FIGMA_REDIRECT_URI || `http://localhost:${DEFAULT_CALLBACK_PORT}/callback`,
|
|
12
|
+
refreshUrl: `${apiBaseUrl}/v1/oauth/refresh`,
|
|
13
|
+
scopes: [
|
|
14
|
+
'current_user:read'
|
|
15
|
+
],
|
|
16
|
+
tokenUrl: `${apiBaseUrl}/v1/oauth/token`
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
|
|
42
20
|
|
|
43
21
|
//# sourceMappingURL=oauth.js.map
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,27 +1,52 @@
|
|
|
1
|
-
export declare const FIGMA_CLIENT_IDS: {
|
|
2
|
-
production: string;
|
|
3
|
-
staging: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const JWKS_URI: {
|
|
6
|
-
production: string;
|
|
7
|
-
staging: string;
|
|
8
|
-
};
|
|
9
1
|
/**
|
|
10
|
-
* Figma environment (production or staging)
|
|
2
|
+
* Figma infrastructure environment (production or staging)
|
|
11
3
|
*/
|
|
12
4
|
export type Environment = 'production' | 'staging';
|
|
5
|
+
type EnvironmentConfig = {
|
|
6
|
+
/** Figma API base URL. Override: FIGMA_API_BASE_URL */
|
|
7
|
+
apiBaseUrl: string;
|
|
8
|
+
/** OAuth authorization URL (CLI auth) */
|
|
9
|
+
authorizationUrl: string;
|
|
10
|
+
/** OAuth client ID. Override: FIGMA_CLIENT_ID or FIGMA_OAUTH_CLIENT_ID */
|
|
11
|
+
clientId: string;
|
|
12
|
+
/** Content API base URL. Override: FIGMA_CONTENT_API_URL */
|
|
13
|
+
contentApiUrl: string;
|
|
14
|
+
/** OIDC discovery endpoint */
|
|
15
|
+
identityMetadata: string;
|
|
16
|
+
/** JSON Web Key Set URL for token validation */
|
|
17
|
+
jwksUri: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Environment-specific configuration for Figma integration.
|
|
21
|
+
* Selected via FIGMA_INFRA_ENV ('production' | 'staging'), defaults to 'production'.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ENV_CONFIG: Record<Environment, EnvironmentConfig>;
|
|
24
|
+
/**
|
|
25
|
+
* User-facing error message when Content API returns 404 or 410.
|
|
26
|
+
* Used by the db adapter for consistent messaging at runtime.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CONTENT_SYSTEM_NOT_FOUND_MESSAGE = "Content system not found. Verify your Content System ID is correct, or contact your team admin for assistance.";
|
|
29
|
+
/**
|
|
30
|
+
* Build a user-facing error message for CLI commands when a project is not found (404/410).
|
|
31
|
+
* Includes infra-env context and actionable suggestions.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getProjectNotFoundMessage(params: {
|
|
34
|
+
environment: Environment;
|
|
35
|
+
projectId: string;
|
|
36
|
+
}): string;
|
|
37
|
+
/**
|
|
38
|
+
* Set infrastructure environment override (used by --infra-env CLI flag)
|
|
39
|
+
* Pass undefined to clear the override
|
|
40
|
+
*/
|
|
41
|
+
export declare function setInfraEnvironment(env: Environment | undefined): void;
|
|
13
42
|
/**
|
|
14
|
-
* Get current Figma
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @returns Current environment
|
|
43
|
+
* Get current Figma infrastructure environment
|
|
44
|
+
* Priority: 1) setInfraEnvironment override, 2) FIGMA_INFRA_ENV env var, 3) .env file, 4) 'production' default
|
|
18
45
|
*/
|
|
19
|
-
export declare function getEnvironment(): Environment;
|
|
20
46
|
/**
|
|
21
|
-
* Get
|
|
22
|
-
*
|
|
23
|
-
* @param env - Environment (defaults to current environment)
|
|
24
|
-
* @returns JWKS URI for the environment
|
|
47
|
+
* Get the resolved EnvironmentConfig for the current infrastructure environment
|
|
25
48
|
*/
|
|
26
|
-
export declare function
|
|
49
|
+
export declare function getEnvConfig(): EnvironmentConfig;
|
|
50
|
+
export declare function getInfraEnvironment(): Environment;
|
|
51
|
+
export {};
|
|
27
52
|
//# sourceMappingURL=constants.d.ts.map
|