@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/auth/token-store.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
/* eslint-disable perfectionist/sort-classes */ import Conf from 'conf';
|
|
2
|
+
import fsSync from 'node:fs';
|
|
2
3
|
import { TOKEN_EXPIRY_BUFFER_SECONDS } from '../config/oauth.js';
|
|
4
|
+
import { getInfraEnvironment } from '../constants.js';
|
|
5
|
+
import * as log from '../utils/log.js';
|
|
3
6
|
import { deriveEncryptionKey } from './crypto-utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Environment-keyed instances for singleton pattern
|
|
9
|
+
*/ const instances = {};
|
|
10
|
+
/**
|
|
11
|
+
* Get the singleton TokenStore instance for an environment
|
|
12
|
+
* Use this for all production code to ensure a single shared instance per environment
|
|
13
|
+
*
|
|
14
|
+
* @param environment - The environment to get the token store for
|
|
15
|
+
* @returns The singleton TokenStore instance for that environment
|
|
16
|
+
*/ export function getTokenStore(environment = getInfraEnvironment()) {
|
|
17
|
+
if (!instances[environment]) {
|
|
18
|
+
instances[environment] = new TokenStore({
|
|
19
|
+
environment
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return instances[environment];
|
|
23
|
+
}
|
|
4
24
|
/**
|
|
5
25
|
* Secure storage manager for Figma OAuth2 tokens
|
|
6
26
|
*
|
|
@@ -11,23 +31,62 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
11
31
|
*
|
|
12
32
|
* Tokens are encrypted at rest with a machine-specific key and file permissions
|
|
13
33
|
* are set to 0600 (owner read/write only)
|
|
34
|
+
*
|
|
35
|
+
* For production code, use getTokenStore() to get the singleton instance.
|
|
36
|
+
* The constructor is still exported for test isolation.
|
|
14
37
|
*/ export class TokenStore {
|
|
15
38
|
config;
|
|
39
|
+
environment;
|
|
16
40
|
constructor(options){
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
41
|
+
if (process.env.AWS_EXECUTION_ENV) {
|
|
42
|
+
throw new Error('TokenStore cannot be used in AWS Lambda environments');
|
|
43
|
+
}
|
|
44
|
+
const environment = options?.environment ?? 'production';
|
|
45
|
+
const projectName = environment === 'production' ? 'payloadcms-figma' : `payloadcms-figma-${environment}`;
|
|
46
|
+
this.environment = environment;
|
|
47
|
+
const confOptions = {
|
|
48
|
+
clearInvalidConfig: false,
|
|
49
|
+
configName: options?.configName || projectName,
|
|
21
50
|
encryptionKey: options?.encryptionKey || deriveEncryptionKey(),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
projectName
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
this.config = new Conf(confOptions);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// Deserialization failed (e.g. encryption key changed).
|
|
57
|
+
// Log diagnostics, clear the corrupted file, then create a fresh store.
|
|
58
|
+
if (environment === 'staging') {
|
|
59
|
+
log.warning(`Token store corrupted, resetting. ` + `Error: ${error instanceof Error ? error.message : 'Unknown'}`);
|
|
60
|
+
}
|
|
61
|
+
// Temporarily allow clearing so Conf can reinitialize
|
|
62
|
+
this.config = new Conf({
|
|
63
|
+
...confOptions,
|
|
64
|
+
clearInvalidConfig: true
|
|
65
|
+
});
|
|
66
|
+
// Force a write so the corrupt file is replaced with an empty store.
|
|
67
|
+
// Without this, clearInvalidConfig only ignores bad reads in memory
|
|
68
|
+
// and the corrupt file persists, triggering this fallback every time.
|
|
69
|
+
this.config.clear();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
safeGet(key) {
|
|
73
|
+
try {
|
|
74
|
+
return this.config.get(key);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (this.environment === 'staging') {
|
|
77
|
+
const filePath = this.config.path;
|
|
78
|
+
const fileExists = fsSync.existsSync(filePath);
|
|
79
|
+
const fileSize = fileExists ? fsSync.statSync(filePath).size : 0;
|
|
80
|
+
log.warning(`Token store read failed (key: ${key}). ` + `File: ${filePath}, exists: ${fileExists}, size: ${fileSize}B. ` + `Error: ${error instanceof Error ? error.message : 'Unknown'}`);
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
25
84
|
}
|
|
26
85
|
/**
|
|
27
86
|
* Retrieve stored tokens
|
|
28
87
|
* @returns FigmaTokens if stored, null otherwise
|
|
29
88
|
*/ getTokens() {
|
|
30
|
-
const tokens = this.
|
|
89
|
+
const tokens = this.safeGet('tokens');
|
|
31
90
|
return tokens || null;
|
|
32
91
|
}
|
|
33
92
|
/**
|
|
@@ -35,6 +94,16 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
35
94
|
* @param tokens - Figma OAuth2 tokens to store
|
|
36
95
|
*/ setTokens(tokens) {
|
|
37
96
|
this.config.set('tokens', tokens);
|
|
97
|
+
// Verify the round-trip: read back what we just wrote
|
|
98
|
+
const readBack = this.safeGet('tokens');
|
|
99
|
+
if (!readBack || readBack.accessToken !== tokens.accessToken) {
|
|
100
|
+
if (this.environment === 'staging') {
|
|
101
|
+
const filePath = this.config.path;
|
|
102
|
+
const fileExists = fsSync.existsSync(filePath);
|
|
103
|
+
const fileSize = fileExists ? fsSync.statSync(filePath).size : 0;
|
|
104
|
+
log.warning(`Token verify-after-write FAILED. ` + `File: ${filePath}, exists: ${fileExists}, size: ${fileSize}B. ` + `Written accessToken starts: ${tokens.accessToken.substring(0, 10)}..., ` + `Read back: ${readBack ? readBack.accessToken.substring(0, 10) + '...' : 'null'}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
38
107
|
}
|
|
39
108
|
/**
|
|
40
109
|
* Clear all stored tokens (used for logout)
|
|
@@ -56,8 +125,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
56
125
|
* Includes a buffer time to avoid using tokens that are about to expire
|
|
57
126
|
* @returns true if token is expired or will expire within buffer time
|
|
58
127
|
*/ isExpired() {
|
|
59
|
-
|
|
60
|
-
const tokens = this.config.get('tokens');
|
|
128
|
+
const tokens = this.safeGet('tokens');
|
|
61
129
|
if (!tokens) {
|
|
62
130
|
return true;
|
|
63
131
|
}
|
|
@@ -112,7 +180,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
112
180
|
* @param tenantId - The tenant/CMS ID
|
|
113
181
|
* @returns ProjectToken if stored and valid, null otherwise
|
|
114
182
|
*/ getProjectToken(tenantId) {
|
|
115
|
-
const projectTokens = this.
|
|
183
|
+
const projectTokens = this.safeGet('projectTokens') || {};
|
|
116
184
|
const projectToken = projectTokens[tenantId];
|
|
117
185
|
if (!projectToken) {
|
|
118
186
|
return null;
|
|
@@ -129,7 +197,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
129
197
|
* @param tenantId - The tenant/CMS ID
|
|
130
198
|
* @param projectToken - The project token to store
|
|
131
199
|
*/ setProjectToken(tenantId, projectToken) {
|
|
132
|
-
const projectTokens = this.
|
|
200
|
+
const projectTokens = this.safeGet('projectTokens') || {};
|
|
133
201
|
projectTokens[tenantId] = projectToken;
|
|
134
202
|
this.config.set('projectTokens', projectTokens);
|
|
135
203
|
}
|
|
@@ -137,7 +205,7 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
137
205
|
* Clear a project token for a specific tenant
|
|
138
206
|
* @param tenantId - The tenant/CMS ID
|
|
139
207
|
*/ clearProjectToken(tenantId) {
|
|
140
|
-
const projectTokens = this.
|
|
208
|
+
const projectTokens = this.safeGet('projectTokens') || {};
|
|
141
209
|
delete projectTokens[tenantId];
|
|
142
210
|
this.config.set('projectTokens', projectTokens);
|
|
143
211
|
}
|
|
@@ -180,9 +248,45 @@ import { deriveEncryptionKey } from './crypto-utils.js';
|
|
|
180
248
|
* Get all tenant IDs that have stored project tokens
|
|
181
249
|
* @returns Array of tenant IDs
|
|
182
250
|
*/ getAllProjectTokenTenantIds() {
|
|
183
|
-
const projectTokens = this.
|
|
251
|
+
const projectTokens = this.safeGet('projectTokens') || {};
|
|
184
252
|
return Object.keys(projectTokens);
|
|
185
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Build the composite key for bootstrap data storage
|
|
256
|
+
* @param projectId - The CMS resource/project ID
|
|
257
|
+
* @param environmentName - The environment name (e.g. 'production', 'staging')
|
|
258
|
+
* @returns Composite key string
|
|
259
|
+
*/ bootstrapKey(projectId, environmentName) {
|
|
260
|
+
return `${projectId}:${environmentName}`;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Retrieve bootstrap data for a project + environment
|
|
264
|
+
* @param projectId - The CMS resource/project ID
|
|
265
|
+
* @param environmentName - The environment name
|
|
266
|
+
* @returns BootstrapData if stored, null otherwise
|
|
267
|
+
*/ getBootstrapData(projectId, environmentName) {
|
|
268
|
+
const allData = this.safeGet('bootstrapData') || {};
|
|
269
|
+
return allData[this.bootstrapKey(projectId, environmentName)] || null;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Store bootstrap data for a project + environment
|
|
273
|
+
* @param projectId - The CMS resource/project ID
|
|
274
|
+
* @param environmentName - The environment name
|
|
275
|
+
* @param data - The bootstrap data to store
|
|
276
|
+
*/ setBootstrapData(projectId, environmentName, data) {
|
|
277
|
+
const allData = this.safeGet('bootstrapData') || {};
|
|
278
|
+
allData[this.bootstrapKey(projectId, environmentName)] = data;
|
|
279
|
+
this.config.set('bootstrapData', allData);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Clear bootstrap data for a project + environment
|
|
283
|
+
* @param projectId - The CMS resource/project ID
|
|
284
|
+
* @param environmentName - The environment name
|
|
285
|
+
*/ clearBootstrapData(projectId, environmentName) {
|
|
286
|
+
const allData = this.safeGet('bootstrapData') || {};
|
|
287
|
+
delete allData[this.bootstrapKey(projectId, environmentName)];
|
|
288
|
+
this.config.set('bootstrapData', allData);
|
|
289
|
+
}
|
|
186
290
|
}
|
|
187
291
|
|
|
188
292
|
//# sourceMappingURL=token-store.js.map
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ErrorResponsePayloadWithErrMessage, ErrorResponsePayloadWithErrorBoolean, User } from '@figma/rest-api-spec';
|
|
2
2
|
import type { JWTPayload as JoseJWTPayload } from 'jose';
|
|
3
|
+
import type { Environment } from '../constants.js';
|
|
3
4
|
/**
|
|
4
5
|
* Standard OAuth2 scopes for user-level permissions
|
|
5
6
|
* @see https://www.figma.com/developers/api#oauth2
|
|
@@ -105,12 +106,14 @@ export interface OAuthTokenRefreshParams {
|
|
|
105
106
|
/**
|
|
106
107
|
* Configuration for token storage
|
|
107
108
|
*/
|
|
108
|
-
export
|
|
109
|
-
/**
|
|
109
|
+
export type TokenStoreConfig = {
|
|
110
|
+
/** Config file name (for testing) */
|
|
110
111
|
configName?: string;
|
|
111
|
-
/**
|
|
112
|
+
/** Encryption key (for testing) */
|
|
112
113
|
encryptionKey?: string;
|
|
113
|
-
|
|
114
|
+
/** Environment for config file naming */
|
|
115
|
+
environment?: Environment;
|
|
116
|
+
};
|
|
114
117
|
/**
|
|
115
118
|
* PKCE (Proof Key for Code Exchange) pair for OAuth2 public clients
|
|
116
119
|
* @see https://datatracker.ietf.org/doc/html/rfc7636
|
|
@@ -158,6 +161,16 @@ export type FigmaErrorResponse = ErrorResponsePayloadWithErrMessage | ErrorRespo
|
|
|
158
161
|
* Re-exported from @figma/rest-api-spec
|
|
159
162
|
*/
|
|
160
163
|
export type FigmaUser = User;
|
|
164
|
+
/**
|
|
165
|
+
* Bootstrap data cached in the local encrypted store
|
|
166
|
+
* Keyed by projectId:environmentName
|
|
167
|
+
*/
|
|
168
|
+
export type BootstrapData = {
|
|
169
|
+
contentSystemId: string;
|
|
170
|
+
oauthClientId: string;
|
|
171
|
+
oauthClientSecret: string;
|
|
172
|
+
tenantInstanceId: string;
|
|
173
|
+
};
|
|
161
174
|
/**
|
|
162
175
|
* JWT payload structure from Figma project tokens
|
|
163
176
|
* Extends jose's standard JWTPayload with Figma-specific claims
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import arg from 'arg';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
|
+
import { buildLambdaZipCommand } from './commands/build-lambda-zip.js';
|
|
5
|
+
import { debugCommand } from './commands/debug.js';
|
|
4
6
|
import { deployCommand } from './commands/deploy.js';
|
|
7
|
+
import { envCommand } from './commands/env.js';
|
|
5
8
|
import { initCommand } from './commands/init.js';
|
|
6
9
|
import { listTokensCommand } from './commands/list-tokens.js';
|
|
7
10
|
import { loginCommand } from './commands/login.js';
|
|
8
11
|
import { logoutCommand } from './commands/logout.js';
|
|
9
|
-
import {
|
|
12
|
+
import { upgradeCommand } from './commands/upgrade.js';
|
|
13
|
+
import { setInfraEnvironment } from './constants.js';
|
|
14
|
+
import { helpMessage } from './utils/messages.js';
|
|
10
15
|
/**
|
|
11
16
|
* Entrypoint for bin/cli.js
|
|
12
17
|
*/ export async function main() {
|
|
@@ -24,16 +29,30 @@ class Main {
|
|
|
24
29
|
constructor(){
|
|
25
30
|
// @ts-expect-error bad typings
|
|
26
31
|
this.args = arg({
|
|
32
|
+
// Hidden flag — intentionally not displayed in help output yet.
|
|
33
|
+
// Auto-detection covers most cases; this is an escape hatch for testing.
|
|
34
|
+
// May expose in help text once multi-framework support is public.
|
|
35
|
+
'--adapter': String,
|
|
36
|
+
'--all': Boolean,
|
|
27
37
|
'--debug': Boolean,
|
|
38
|
+
'--dry-run': Boolean,
|
|
39
|
+
'--env': String,
|
|
28
40
|
'--force': Boolean,
|
|
29
41
|
'--help': Boolean,
|
|
30
42
|
'--id': String,
|
|
43
|
+
'--infra-env': String,
|
|
31
44
|
'--name': String,
|
|
32
45
|
'--skip-auth': Boolean,
|
|
46
|
+
'--skip-build': Boolean,
|
|
47
|
+
'--version': Boolean,
|
|
33
48
|
'--yes': Boolean,
|
|
34
49
|
// Aliases
|
|
50
|
+
'--environment': '--env',
|
|
51
|
+
'-e': '--env',
|
|
35
52
|
'-f': '--force',
|
|
36
53
|
'-h': '--help',
|
|
54
|
+
'-n': '--name',
|
|
55
|
+
'-v': '--version',
|
|
37
56
|
'-y': '--yes'
|
|
38
57
|
}, {
|
|
39
58
|
permissive: true
|
|
@@ -42,6 +61,19 @@ class Main {
|
|
|
42
61
|
if (this.args['--debug']) {
|
|
43
62
|
process.env.DEBUG = 'true';
|
|
44
63
|
}
|
|
64
|
+
// Handle --infra-env flag for infrastructure environment switching
|
|
65
|
+
if (this.args['--infra-env']) {
|
|
66
|
+
const infraEnvArg = this.args['--infra-env'].toLowerCase();
|
|
67
|
+
if (infraEnvArg === 'prod' || infraEnvArg === 'production') {
|
|
68
|
+
setInfraEnvironment('production');
|
|
69
|
+
} else if (infraEnvArg === 'staging') {
|
|
70
|
+
setInfraEnvironment('staging');
|
|
71
|
+
} else {
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.error(`Invalid --infra-env value: ${this.args['--infra-env']}. Use 'production' or 'staging'.`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
45
77
|
}
|
|
46
78
|
async init() {
|
|
47
79
|
try {
|
|
@@ -49,30 +81,60 @@ class Main {
|
|
|
49
81
|
helpMessage();
|
|
50
82
|
process.exit(0);
|
|
51
83
|
}
|
|
84
|
+
if (this.args['--version']) {
|
|
85
|
+
const { getOwnVersion } = await import('./utils/version-check.js');
|
|
86
|
+
const version = await getOwnVersion();
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
88
|
+
console.log(version);
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
52
91
|
// Get the subcommand (first non-flag argument)
|
|
53
92
|
const subcommand = this.args._[0];
|
|
93
|
+
if (!subcommand) {
|
|
94
|
+
helpMessage();
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
// Debug command outputs plain text for copy-paste — skip styled intro
|
|
98
|
+
if (subcommand === 'debug') {
|
|
99
|
+
await debugCommand();
|
|
100
|
+
process.exit(0);
|
|
101
|
+
}
|
|
54
102
|
// eslint-disable-next-line no-console
|
|
55
103
|
console.log('\n');
|
|
56
104
|
p.intro(pc.bgCyan(pc.black(' @payloadcms/figma ')));
|
|
57
105
|
// Route to appropriate command handler
|
|
58
106
|
switch(subcommand){
|
|
107
|
+
case 'build-lambda-zip':
|
|
108
|
+
await buildLambdaZipCommand();
|
|
109
|
+
break;
|
|
59
110
|
case 'deploy':
|
|
60
111
|
await deployCommand({
|
|
112
|
+
id: this.args['--id'],
|
|
113
|
+
adapter: this.args['--adapter'],
|
|
61
114
|
debug: this.args['--debug'],
|
|
115
|
+
env: this.args['--env'],
|
|
116
|
+
skipBuild: this.args['--skip-build'],
|
|
62
117
|
yes: this.args['--yes']
|
|
63
118
|
});
|
|
64
119
|
break;
|
|
120
|
+
case 'env':
|
|
121
|
+
await envCommand({
|
|
122
|
+
name: this.args._[1]
|
|
123
|
+
});
|
|
124
|
+
break;
|
|
65
125
|
case 'init':
|
|
66
126
|
await initCommand({
|
|
67
127
|
id: this.args['--id'],
|
|
68
128
|
name: this.args['--name'],
|
|
69
129
|
debug: this.args['--debug'],
|
|
130
|
+
env: this.args['--env'],
|
|
70
131
|
force: this.args['--force'],
|
|
71
132
|
skipAuth: this.args['--skip-auth']
|
|
72
133
|
});
|
|
73
134
|
break;
|
|
74
135
|
case 'list-tokens':
|
|
75
136
|
listTokensCommand({
|
|
137
|
+
all: this.args['--all'],
|
|
76
138
|
debug: this.args['--debug']
|
|
77
139
|
});
|
|
78
140
|
break;
|
|
@@ -81,13 +143,14 @@ class Main {
|
|
|
81
143
|
break;
|
|
82
144
|
case 'logout':
|
|
83
145
|
await logoutCommand({
|
|
146
|
+
all: this.args['--all'],
|
|
84
147
|
debug: this.args['--debug']
|
|
85
148
|
});
|
|
86
149
|
break;
|
|
87
|
-
case
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
150
|
+
case 'upgrade':
|
|
151
|
+
await upgradeCommand({
|
|
152
|
+
isDryRun: this.args['--dry-run']
|
|
153
|
+
});
|
|
91
154
|
break;
|
|
92
155
|
default:
|
|
93
156
|
p.log.error(pc.red(`Unknown command: ${subcommand}`));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import { buildLambdaZip } from '../utils/build-lambda-zip.js';
|
|
4
|
+
/**
|
|
5
|
+
* Build Lambda deployment zip from current directory
|
|
6
|
+
*/ export async function buildLambdaZipCommand() {
|
|
7
|
+
const projectPath = process.cwd();
|
|
8
|
+
const s = p.spinner();
|
|
9
|
+
s.start('Creating lambda.zip');
|
|
10
|
+
try {
|
|
11
|
+
await buildLambdaZip(projectPath);
|
|
12
|
+
s.stop(pc.green('✓ Created lambda.zip'));
|
|
13
|
+
} catch (error) {
|
|
14
|
+
s.stop(pc.red('✗ Failed to create lambda.zip'));
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=build-lambda-zip.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle the `@payloadcms/figma debug` command
|
|
3
|
+
*
|
|
4
|
+
* Outputs environment, auth, project, and package info for debugging.
|
|
5
|
+
* All data is local — no network calls are made.
|
|
6
|
+
*/
|
|
7
|
+
export declare function debugCommand(): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import fsSync from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { getEncryptionKeyHash } from '../auth/crypto-utils.js';
|
|
6
|
+
import { getTokenStore } from '../auth/token-store.js';
|
|
7
|
+
import { getInfraEnvironment } from '../constants.js';
|
|
8
|
+
import { getEnvVarSync } from '../utils/env-management.js';
|
|
9
|
+
import { maskToken } from '../utils/token-display.js';
|
|
10
|
+
import { getOwnVersion } from '../utils/version-check.js';
|
|
11
|
+
/**
|
|
12
|
+
* Handle the `@payloadcms/figma debug` command
|
|
13
|
+
*
|
|
14
|
+
* Outputs environment, auth, project, and package info for debugging.
|
|
15
|
+
* All data is local — no network calls are made.
|
|
16
|
+
*/ export async function debugCommand() {
|
|
17
|
+
const env = getInfraEnvironment();
|
|
18
|
+
const tokenStore = getTokenStore(env);
|
|
19
|
+
const cwd = process.cwd();
|
|
20
|
+
const lines = [
|
|
21
|
+
'Debug Info:',
|
|
22
|
+
''
|
|
23
|
+
];
|
|
24
|
+
appendSystemSection(lines, env);
|
|
25
|
+
appendAuthSection(lines, tokenStore, cwd);
|
|
26
|
+
appendTokenStoreDiagnostics(lines, tokenStore);
|
|
27
|
+
appendProjectSection(lines, tokenStore, cwd);
|
|
28
|
+
await appendPackagesSection(lines);
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.log(lines.join('\n'));
|
|
31
|
+
}
|
|
32
|
+
function appendSystemSection(lines, env) {
|
|
33
|
+
lines.push(`Infra Environment: ${env}`);
|
|
34
|
+
lines.push(`Node: ${process.version}`);
|
|
35
|
+
lines.push(`OS: ${os.platform()} ${os.arch()}`);
|
|
36
|
+
lines.push('');
|
|
37
|
+
}
|
|
38
|
+
function appendAuthSection(lines, tokenStore, cwd) {
|
|
39
|
+
const tokens = tokenStore.getTokens();
|
|
40
|
+
lines.push('Auth:');
|
|
41
|
+
if (!tokens) {
|
|
42
|
+
lines.push(' Status: Not authenticated');
|
|
43
|
+
lines.push('');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const isValid = tokenStore.hasValidTokens();
|
|
47
|
+
lines.push(` Status: ${isValid ? 'Authenticated' : 'Token expired'}`);
|
|
48
|
+
const email = getEmailFromClaims(tokenStore, cwd);
|
|
49
|
+
if (email) {
|
|
50
|
+
lines.push(` Email: ${email}`);
|
|
51
|
+
} else if (tokens.userId) {
|
|
52
|
+
lines.push(` User ID: ${tokens.userId}`);
|
|
53
|
+
}
|
|
54
|
+
lines.push(` Token Expires: ${formatExpiryTime(tokens.expiresAt)}`);
|
|
55
|
+
lines.push('');
|
|
56
|
+
}
|
|
57
|
+
function appendTokenStoreDiagnostics(lines, tokenStore) {
|
|
58
|
+
lines.push('Token Store:');
|
|
59
|
+
const filePath = tokenStore.getStoragePath();
|
|
60
|
+
const fileExists = fsSync.existsSync(filePath);
|
|
61
|
+
const fileSize = fileExists ? fsSync.statSync(filePath).size : 0;
|
|
62
|
+
lines.push(` File: ${filePath}`);
|
|
63
|
+
lines.push(` File Exists: ${fileExists}`);
|
|
64
|
+
lines.push(` File Size: ${fileSize}B`);
|
|
65
|
+
const canRead = tokenStore.getTokens() !== null || tokenStore.getRefreshToken() !== null;
|
|
66
|
+
lines.push(` Decryption: ${fileExists ? canRead || fileSize === 0 ? 'OK' : 'FAILED' : 'N/A'}`);
|
|
67
|
+
lines.push(` Key Hash: ${getEncryptionKeyHash()}`);
|
|
68
|
+
lines.push('');
|
|
69
|
+
}
|
|
70
|
+
function appendProjectSection(lines, tokenStore, cwd) {
|
|
71
|
+
const projectId = getEnvVarSync(cwd, 'FIGMA_PROJECT_ID');
|
|
72
|
+
const environmentName = getEnvVarSync(cwd, 'FIGMA_ENVIRONMENT_NAME');
|
|
73
|
+
lines.push('Project:');
|
|
74
|
+
if (!projectId) {
|
|
75
|
+
lines.push(" Not initialized (run 'init' first)");
|
|
76
|
+
lines.push('');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
lines.push(` Project ID: ${projectId}`);
|
|
80
|
+
lines.push(` Environment: ${environmentName ?? '(not set)'}`);
|
|
81
|
+
// Show bootstrap data from local store
|
|
82
|
+
if (projectId && environmentName) {
|
|
83
|
+
const bootstrapData = tokenStore.getBootstrapData(projectId, environmentName);
|
|
84
|
+
if (bootstrapData) {
|
|
85
|
+
lines.push(` Content System ID: ${bootstrapData.contentSystemId}`);
|
|
86
|
+
lines.push(` Tenant Instance ID: ${bootstrapData.tenantInstanceId}`);
|
|
87
|
+
lines.push(` OAuth Client ID: ${maskToken(bootstrapData.oauthClientId)}`);
|
|
88
|
+
const projectToken = tokenStore.getProjectToken(bootstrapData.contentSystemId);
|
|
89
|
+
if (projectToken) {
|
|
90
|
+
lines.push(` Project Token: ${formatExpiryTime(projectToken.expiresAt)}`);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
lines.push(' Bootstrap Data: (not cached)');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
lines.push('');
|
|
97
|
+
}
|
|
98
|
+
async function appendPackagesSection(lines) {
|
|
99
|
+
lines.push('Packages:');
|
|
100
|
+
const cliVersion = await getOwnVersion();
|
|
101
|
+
lines.push(` @payloadcms/figma: ${cliVersion}`);
|
|
102
|
+
const payloadVersion = getPayloadVersion();
|
|
103
|
+
lines.push(` payload: ${payloadVersion}`);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Try resolving email from bootstrap data, then iterate all stored project tokens.
|
|
107
|
+
*/ function getEmailFromClaims(tokenStore, cwd) {
|
|
108
|
+
const projectId = getEnvVarSync(cwd, 'FIGMA_PROJECT_ID');
|
|
109
|
+
const environmentName = getEnvVarSync(cwd, 'FIGMA_ENVIRONMENT_NAME');
|
|
110
|
+
if (projectId && environmentName) {
|
|
111
|
+
const bootstrapData = tokenStore.getBootstrapData(projectId, environmentName);
|
|
112
|
+
if (bootstrapData) {
|
|
113
|
+
const email = tokenStore.getProjectTokenClaims(bootstrapData.contentSystemId)?.email;
|
|
114
|
+
if (email) {
|
|
115
|
+
return email;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const id of tokenStore.getAllProjectTokenTenantIds()){
|
|
120
|
+
const email = tokenStore.getProjectTokenClaims(id)?.email;
|
|
121
|
+
if (email) {
|
|
122
|
+
return email;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
function getPayloadVersion() {
|
|
128
|
+
try {
|
|
129
|
+
const require = createRequire(path.join(process.cwd(), 'noop.js'));
|
|
130
|
+
const resolved = require.resolve('payload');
|
|
131
|
+
const packageJsonPath = findPackageJson(path.dirname(resolved));
|
|
132
|
+
if (!packageJsonPath) {
|
|
133
|
+
return 'not found';
|
|
134
|
+
}
|
|
135
|
+
const content = fsSync.readFileSync(packageJsonPath, 'utf-8');
|
|
136
|
+
return JSON.parse(content).version;
|
|
137
|
+
} catch {
|
|
138
|
+
return 'not found';
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function findPackageJson(dir) {
|
|
142
|
+
const { root } = path.parse(dir);
|
|
143
|
+
while(dir !== root){
|
|
144
|
+
const candidate = path.join(dir, 'package.json');
|
|
145
|
+
if (fsSync.existsSync(candidate)) {
|
|
146
|
+
return candidate;
|
|
147
|
+
}
|
|
148
|
+
dir = path.dirname(dir);
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Format expiry timestamp as ISO string with relative time
|
|
154
|
+
* e.g. "2026-02-11T10:30:00.000Z (in 23h 15m)" or "2026-02-10T08:00:00.000Z (expired 2h ago)"
|
|
155
|
+
*/ function formatExpiryTime(expiresAt) {
|
|
156
|
+
const iso = new Date(expiresAt).toISOString();
|
|
157
|
+
const diff = expiresAt - Date.now();
|
|
158
|
+
if (diff < 0) {
|
|
159
|
+
return `${iso} (expired ${formatDuration(Math.abs(diff))} ago)`;
|
|
160
|
+
}
|
|
161
|
+
return `${iso} (in ${formatDuration(diff)})`;
|
|
162
|
+
}
|
|
163
|
+
function formatDuration(ms) {
|
|
164
|
+
const minutes = Math.floor(ms / 60000);
|
|
165
|
+
const hours = Math.floor(minutes / 60);
|
|
166
|
+
const days = Math.floor(hours / 24);
|
|
167
|
+
if (days > 0) {
|
|
168
|
+
return `${days}d ${hours % 24}h`;
|
|
169
|
+
}
|
|
170
|
+
if (hours > 0) {
|
|
171
|
+
return `${hours}h ${minutes % 60}m`;
|
|
172
|
+
}
|
|
173
|
+
return `${minutes}m`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import type { AdapterName } from '../utils/deploy-adapter.js';
|
|
1
2
|
/**
|
|
2
3
|
* Options for deploy command
|
|
3
4
|
*/
|
|
4
5
|
export interface DeployCommandOptions {
|
|
6
|
+
/** Framework adapter (nextjs, nitro, vite). Auto-detected if omitted. */
|
|
7
|
+
adapter?: AdapterName;
|
|
5
8
|
/** Enable debug mode */
|
|
6
9
|
debug?: boolean;
|
|
10
|
+
/** Figma environment name (e.g. 'production', 'staging') */
|
|
11
|
+
env?: string;
|
|
12
|
+
/** CMS Resource ID (overrides FIGMA_PROJECT_ID) */
|
|
13
|
+
id?: string;
|
|
14
|
+
/** Skip the build step (use existing build) */
|
|
15
|
+
skipBuild?: boolean;
|
|
7
16
|
/** Skip confirmation prompts */
|
|
8
17
|
yes?: boolean;
|
|
9
18
|
}
|