@payloadcms/figma 0.0.1-alpha.42 → 0.0.1-alpha.6
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 +1 -22
- package/dist/api/control-plane.d.ts.map +1 -1
- package/dist/api/control-plane.js +22 -55
- package/dist/api/control-plane.js.map +1 -1
- package/dist/api/figma-api.d.ts.map +1 -1
- package/dist/api/figma-api.js +21 -45
- package/dist/api/figma-api.js.map +1 -1
- package/dist/auth/callback-server.d.ts.map +1 -1
- package/dist/auth/callback-server.js +1 -2
- package/dist/auth/callback-server.js.map +1 -1
- package/dist/auth/crypto-utils.d.ts.map +1 -1
- package/dist/auth/crypto-utils.js +5 -5
- package/dist/auth/crypto-utils.js.map +1 -1
- package/dist/auth/jwt-validator.d.ts +1 -2
- package/dist/auth/jwt-validator.d.ts.map +1 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/jwt-validator.js.map +1 -1
- package/dist/auth/oauth-flow.d.ts +1 -1
- package/dist/auth/oauth-flow.d.ts.map +1 -1
- package/dist/auth/oauth-flow.js +11 -15
- package/dist/auth/oauth-flow.js.map +1 -1
- package/dist/auth/project-token.d.ts.map +1 -1
- package/dist/auth/project-token.js +4 -9
- package/dist/auth/project-token.js.map +1 -1
- package/dist/auth/refresh.d.ts +1 -2
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +12 -25
- package/dist/auth/refresh.js.map +1 -1
- package/dist/auth/token-store.d.ts +0 -12
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +5 -28
- package/dist/auth/token-store.js.map +1 -1
- package/dist/auth/types.d.ts +4 -7
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -39
- package/dist/cli.js.map +1 -1
- package/dist/commands/deploy.d.ts +0 -4
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +129 -72
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts +5 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +85 -105
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.d.ts.map +1 -1
- package/dist/commands/list-tokens.js +7 -22
- package/dist/commands/list-tokens.js.map +1 -1
- package/dist/commands/login.d.ts +1 -8
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +12 -30
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +4 -5
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +13 -56
- package/dist/commands/logout.js.map +1 -1
- package/dist/config/oauth.d.ts +14 -4
- package/dist/config/oauth.d.ts.map +1 -1
- package/dist/config/oauth.js +40 -19
- package/dist/config/oauth.js.map +1 -1
- package/dist/constants.d.ts +18 -26
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +20 -34
- package/dist/constants.js.map +1 -1
- package/dist/exports/client.d.ts +0 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +0 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
- package/dist/oauth/components/LoginButton/index.js +6 -50
- package/dist/oauth/components/LoginButton/index.js.map +1 -1
- package/dist/oauth/components/LoginButton/index.scss +3 -50
- package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
- package/dist/oauth/components/LogoutButton/index.js +4 -5
- package/dist/oauth/components/LogoutButton/index.js.map +1 -1
- package/dist/oauth/defaults.d.ts.map +1 -1
- package/dist/oauth/defaults.js +5 -29
- package/dist/oauth/defaults.js.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +11 -21
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +4 -7
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -1
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +13 -40
- package/dist/oauth/index.js.map +1 -1
- package/dist/oauth/strategy/index.d.ts +2 -0
- package/dist/oauth/strategy/index.d.ts.map +1 -1
- package/dist/oauth/strategy/index.js +15 -38
- package/dist/oauth/strategy/index.js.map +1 -1
- package/dist/oauth/types.d.ts +6 -6
- package/dist/oauth/types.d.ts.map +1 -1
- package/dist/oauth/types.js.map +1 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +8 -0
- package/dist/oauth/utilities/getAdminPath.d.ts.map +1 -0
- package/dist/oauth/utilities/getAdminPath.js +9 -0
- package/dist/oauth/utilities/getAdminPath.js.map +1 -0
- package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
- package/dist/oauth/utilities/refreshTokens.js +1 -1
- package/dist/oauth/utilities/refreshTokens.js.map +1 -1
- package/dist/plugin/build-config.d.ts +4 -21
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +7 -113
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/asset-collection.d.ts +6 -3
- package/dist/utils/asset-collection.d.ts.map +1 -1
- package/dist/utils/asset-collection.js +34 -10
- package/dist/utils/asset-collection.js.map +1 -1
- package/dist/utils/config.js +1 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/env-management.d.ts +8 -9
- package/dist/utils/env-management.d.ts.map +1 -1
- package/dist/utils/env-management.js +74 -73
- package/dist/utils/env-management.js.map +1 -1
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +5 -3
- package/dist/utils/formatter.js.map +1 -1
- package/dist/utils/lambda-config.d.ts +1 -3
- package/dist/utils/lambda-config.d.ts.map +1 -1
- package/dist/utils/lambda-config.js +32 -38
- package/dist/utils/lambda-config.js.map +1 -1
- package/dist/utils/messages.js +8 -8
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/payload-config-ast.d.ts +3 -22
- package/dist/utils/payload-config-ast.d.ts.map +1 -1
- package/dist/utils/payload-config-ast.js +31 -89
- package/dist/utils/payload-config-ast.js.map +1 -1
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.d.ts.map +1 -1
- package/dist/utils/payload-config-finder.js +9 -48
- package/dist/utils/payload-config-finder.js.map +1 -1
- package/dist/utils/payload-config-modifier.d.ts.map +1 -1
- package/dist/utils/payload-config-modifier.js +6 -54
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/payload-package-check.d.ts +1 -12
- package/dist/utils/payload-package-check.d.ts.map +1 -1
- package/dist/utils/payload-package-check.js +5 -63
- package/dist/utils/payload-package-check.js.map +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +5 -8
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/s3-upload.d.ts +1 -0
- package/dist/utils/s3-upload.d.ts.map +1 -1
- package/dist/utils/s3-upload.js +3 -10
- package/dist/utils/s3-upload.js.map +1 -1
- package/dist/utils/token-display.d.ts.map +1 -1
- package/dist/utils/token-display.js +5 -11
- package/dist/utils/token-display.js.map +1 -1
- package/dist/utils/typescript-validator.d.ts.map +1 -1
- package/dist/utils/typescript-validator.js +6 -4
- package/dist/utils/typescript-validator.js.map +1 -1
- package/package.json +9 -27
- package/dist/commands/build-lambda-zip.d.ts +0 -5
- package/dist/commands/build-lambda-zip.d.ts.map +0 -1
- package/dist/commands/build-lambda-zip.js +0 -19
- package/dist/commands/build-lambda-zip.js.map +0 -1
- package/dist/db-content-api/README.md +0 -98
- package/dist/db-content-api/generated/content-api-types.d.ts +0 -3914
- package/dist/db-content-api/generated/content-api-types.d.ts.map +0 -1
- package/dist/db-content-api/generated/content-api-types.js +0 -7
- package/dist/db-content-api/generated/content-api-types.js.map +0 -1
- package/dist/db-content-api/index.d.ts +0 -18
- package/dist/db-content-api/index.d.ts.map +0 -1
- package/dist/db-content-api/index.js +0 -586
- package/dist/db-content-api/index.js.map +0 -1
- package/dist/db-content-api/temp-utilities/slug.d.ts +0 -2
- package/dist/db-content-api/temp-utilities/slug.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/slug.js +0 -3
- package/dist/db-content-api/temp-utilities/slug.js.map +0 -1
- package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -3
- package/dist/db-content-api/temp-utilities/sorting.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/sorting.js +0 -32
- package/dist/db-content-api/temp-utilities/sorting.js.map +0 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -34
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -53
- package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +0 -1
- package/dist/db-content-api/utilities/auth.d.ts +0 -30
- package/dist/db-content-api/utilities/auth.d.ts.map +0 -1
- package/dist/db-content-api/utilities/auth.js +0 -81
- package/dist/db-content-api/utilities/auth.js.map +0 -1
- package/dist/db-content-api/utilities/buildPathTypes.d.ts +0 -12
- package/dist/db-content-api/utilities/buildPathTypes.d.ts.map +0 -1
- package/dist/db-content-api/utilities/buildPathTypes.js +0 -157
- package/dist/db-content-api/utilities/buildPathTypes.js.map +0 -1
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -7
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/applyDefaults.js +0 -59
- package/dist/db-content-api/utilities/data/applyDefaults.js.map +0 -1
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -11
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js +0 -66
- package/dist/db-content-api/utilities/data/castFieldValue.js.map +0 -1
- package/dist/db-content-api/utilities/data/index.d.ts +0 -32
- package/dist/db-content-api/utilities/data/index.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/index.js +0 -190
- package/dist/db-content-api/utilities/data/index.js.map +0 -1
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -12
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -54
- package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +0 -1
- package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -48
- package/dist/db-content-api/utilities/data/stripFields.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/stripFields.js +0 -195
- package/dist/db-content-api/utilities/data/stripFields.js.map +0 -1
- package/dist/db-content-api/utilities/joins.d.ts +0 -55
- package/dist/db-content-api/utilities/joins.d.ts.map +0 -1
- package/dist/db-content-api/utilities/joins.js +0 -136
- package/dist/db-content-api/utilities/joins.js.map +0 -1
- package/dist/db-content-api/utilities/where.d.ts +0 -12
- package/dist/db-content-api/utilities/where.d.ts.map +0 -1
- package/dist/db-content-api/utilities/where.js +0 -121
- package/dist/db-content-api/utilities/where.js.map +0 -1
- package/dist/endpoints/health.d.ts +0 -3
- package/dist/endpoints/health.d.ts.map +0 -1
- package/dist/endpoints/health.js +0 -11
- package/dist/endpoints/health.js.map +0 -1
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -7
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +0 -1
- package/dist/oauth/utilities/isDuplicateKeyError.js +0 -14
- package/dist/oauth/utilities/isDuplicateKeyError.js.map +0 -1
- package/dist/storage-content-api/api-types.d.ts +0 -168
- package/dist/storage-content-api/api-types.d.ts.map +0 -1
- package/dist/storage-content-api/api-types.js +0 -6
- package/dist/storage-content-api/api-types.js.map +0 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -9
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +0 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -42
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +0 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -13
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +0 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -32
- package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +0 -1
- package/dist/storage-content-api/client.d.ts +0 -6
- package/dist/storage-content-api/client.d.ts.map +0 -1
- package/dist/storage-content-api/client.js +0 -36
- package/dist/storage-content-api/client.js.map +0 -1
- package/dist/storage-content-api/generateURL.d.ts +0 -7
- package/dist/storage-content-api/generateURL.d.ts.map +0 -1
- package/dist/storage-content-api/generateURL.js +0 -8
- package/dist/storage-content-api/generateURL.js.map +0 -1
- package/dist/storage-content-api/handleDelete.d.ts +0 -8
- package/dist/storage-content-api/handleDelete.d.ts.map +0 -1
- package/dist/storage-content-api/handleDelete.js +0 -17
- package/dist/storage-content-api/handleDelete.js.map +0 -1
- package/dist/storage-content-api/handleUpload.d.ts +0 -11
- package/dist/storage-content-api/handleUpload.d.ts.map +0 -1
- package/dist/storage-content-api/handleUpload.js +0 -144
- package/dist/storage-content-api/handleUpload.js.map +0 -1
- package/dist/storage-content-api/index.d.ts +0 -5
- package/dist/storage-content-api/index.d.ts.map +0 -1
- package/dist/storage-content-api/index.js +0 -31
- package/dist/storage-content-api/index.js.map +0 -1
- package/dist/storage-content-api/staticHandler.d.ts +0 -10
- package/dist/storage-content-api/staticHandler.d.ts.map +0 -1
- package/dist/storage-content-api/staticHandler.js +0 -56
- package/dist/storage-content-api/staticHandler.js.map +0 -1
- package/dist/storage-content-api/types.d.ts +0 -10
- package/dist/storage-content-api/types.d.ts.map +0 -1
- package/dist/storage-content-api/types.js +0 -3
- package/dist/storage-content-api/types.js.map +0 -1
- package/dist/templates/README.md +0 -19
- package/dist/utils/build-lambda-zip.d.ts +0 -14
- package/dist/utils/build-lambda-zip.d.ts.map +0 -1
- package/dist/utils/build-lambda-zip.js +0 -81
- package/dist/utils/build-lambda-zip.js.map +0 -1
- package/dist/utils/format-env-suffix.d.ts +0 -12
- package/dist/utils/format-env-suffix.d.ts.map +0 -1
- package/dist/utils/format-env-suffix.js +0 -13
- package/dist/utils/format-env-suffix.js.map +0 -1
- package/dist/utils/version-check.d.ts +0 -3
- package/dist/utils/version-check.d.ts.map +0 -1
- package/dist/utils/version-check.js +0 -38
- package/dist/utils/version-check.js.map +0 -1
package/dist/commands/login.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import { CallbackError } from '../auth/callback-server.js';
|
|
4
3
|
import { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getEnvironment } from '../constants.js';
|
|
8
|
-
import { formatEnvSuffix } from '../utils/format-env-suffix.js';
|
|
4
|
+
import { TokenStore } from '../auth/token-store.js';
|
|
5
|
+
import { OAUTH_CONFIG } from '../config/oauth.js';
|
|
9
6
|
import * as log from '../utils/log.js';
|
|
10
7
|
/**
|
|
11
8
|
* Handle the `@payloadcms/figma login` command
|
|
12
9
|
*
|
|
13
10
|
* Authenticates the user with Figma OAuth2 and stores tokens locally.
|
|
14
11
|
* If valid tokens already exist, shows an error message.
|
|
15
|
-
*/ export async function loginCommand(
|
|
16
|
-
const
|
|
17
|
-
showNextSteps: false
|
|
18
|
-
};
|
|
19
|
-
const env = getEnvironment();
|
|
20
|
-
const tokenStore = getTokenStore(env);
|
|
12
|
+
*/ export async function loginCommand() {
|
|
13
|
+
const tokenStore = new TokenStore();
|
|
21
14
|
// Check for existing valid tokens
|
|
22
15
|
try {
|
|
23
16
|
const existingToken = await getValidAccessToken(tokenStore);
|
|
24
17
|
if (existingToken) {
|
|
25
18
|
const tokens = tokenStore.getTokens();
|
|
26
|
-
p.log.warn(pc.yellow(
|
|
19
|
+
p.log.warn(pc.yellow('Already logged in'));
|
|
27
20
|
if (tokens?.userId) {
|
|
28
21
|
log.info(`User ID: ${tokens.userId}`);
|
|
29
22
|
}
|
|
@@ -37,39 +30,28 @@ import * as log from '../utils/log.js';
|
|
|
37
30
|
}
|
|
38
31
|
// Start OAuth flow
|
|
39
32
|
await handleAuthentication({
|
|
40
|
-
showNextSteps,
|
|
41
33
|
tokenStore
|
|
42
34
|
});
|
|
43
35
|
}
|
|
44
36
|
/**
|
|
45
37
|
* Handle authentication flow
|
|
46
|
-
*/ async function handleAuthentication({
|
|
38
|
+
*/ async function handleAuthentication({ tokenStore }) {
|
|
47
39
|
try {
|
|
48
40
|
// Execute OAuth flow
|
|
49
|
-
const oauthConfig = getOAuthConfig();
|
|
50
41
|
const result = await executeOAuthFlow(tokenStore, {
|
|
51
|
-
clientId:
|
|
52
|
-
redirectUri:
|
|
53
|
-
scopes:
|
|
42
|
+
clientId: OAUTH_CONFIG.clientId,
|
|
43
|
+
redirectUri: OAUTH_CONFIG.redirectUri,
|
|
44
|
+
scopes: OAUTH_CONFIG.scopes
|
|
54
45
|
});
|
|
55
|
-
|
|
56
|
-
p.log.success(pc.green(`✓ Logged in${formatEnvSuffix(env)}`));
|
|
46
|
+
p.log.success(pc.green('✓ You are now authenticated with Figma'));
|
|
57
47
|
if (result.userId) {
|
|
58
48
|
log.debug(`User ID: ${result.userId}`);
|
|
59
49
|
}
|
|
60
50
|
log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`);
|
|
61
|
-
// Show next steps
|
|
62
|
-
|
|
63
|
-
p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps');
|
|
64
|
-
}
|
|
51
|
+
// Show next steps
|
|
52
|
+
p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps');
|
|
65
53
|
} catch (error) {
|
|
66
54
|
if (error instanceof OAuthFlowError) {
|
|
67
|
-
const isTimeout = error.cause instanceof CallbackError && error.cause.code === 'timeout';
|
|
68
|
-
if (isTimeout) {
|
|
69
|
-
p.log.error(pc.red('✗ Authentication timed out.'));
|
|
70
|
-
p.note(`Run ${pc.cyan('@payloadcms/figma login')} to try again.`, 'Tip');
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
55
|
log.error(error.message);
|
|
74
56
|
if (error.cause) {
|
|
75
57
|
log.debug(`Cause: ${error.cause.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/login.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/commands/login.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport { executeOAuthFlow, getValidAccessToken, OAuthFlowError } from '../auth/oauth-flow.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { OAUTH_CONFIG } from '../config/oauth.js'\nimport * as log from '../utils/log.js'\n\n/**\n * Handle the `@payloadcms/figma login` command\n *\n * Authenticates the user with Figma OAuth2 and stores tokens locally.\n * If valid tokens already exist, shows an error message.\n */\nexport async function loginCommand(): Promise<void> {\n const tokenStore = new TokenStore()\n\n // Check for existing valid tokens\n try {\n const existingToken = await getValidAccessToken(tokenStore)\n if (existingToken) {\n const tokens = tokenStore.getTokens()\n p.log.warn(pc.yellow('Already logged in'))\n if (tokens?.userId) {\n log.info(`User ID: ${tokens.userId}`)\n }\n log.info(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n p.note(`To re-authenticate, first run ${pc.cyan('@payloadcms/figma logout')}`, 'Tip')\n return\n }\n } catch {\n // Token refresh failed - continue with new auth flow\n log.warning('Existing tokens are invalid. Starting new authentication...')\n }\n\n // Start OAuth flow\n await handleAuthentication({\n tokenStore,\n })\n}\n\n/**\n * Handle authentication flow\n */\nasync function handleAuthentication({ tokenStore }: { tokenStore: TokenStore }): Promise<void> {\n try {\n // Execute OAuth flow\n const result = await executeOAuthFlow(tokenStore, {\n clientId: OAUTH_CONFIG.clientId,\n redirectUri: OAUTH_CONFIG.redirectUri,\n scopes: OAUTH_CONFIG.scopes,\n })\n\n p.log.success(pc.green('✓ You are now authenticated with Figma'))\n\n if (result.userId) {\n log.debug(`User ID: ${result.userId}`)\n }\n\n log.debug(`Token storage: ${pc.dim(tokenStore.getStoragePath())}`)\n\n // Show next steps\n p.note(` ${pc.cyan('@payloadcms/figma init')} Create a new CMS instance`, 'Next Steps')\n } catch (error) {\n if (error instanceof OAuthFlowError) {\n log.error(error.message)\n\n if (error.cause) {\n log.debug(`Cause: ${error.cause.message}`)\n }\n } else {\n log.error(error instanceof Error ? error.message : 'Unknown error')\n }\n\n process.exit(1)\n }\n}\n"],"names":["p","pc","executeOAuthFlow","getValidAccessToken","OAuthFlowError","TokenStore","OAUTH_CONFIG","log","loginCommand","tokenStore","existingToken","tokens","getTokens","warn","yellow","userId","info","dim","getStoragePath","note","cyan","warning","handleAuthentication","result","clientId","redirectUri","scopes","success","green","debug","error","message","cause","Error","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAE3B,SAASC,gBAAgB,EAAEC,mBAAmB,EAAEC,cAAc,QAAQ,wBAAuB;AAC7F,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,YAAY,QAAQ,qBAAoB;AACjD,YAAYC,SAAS,kBAAiB;AAEtC;;;;;CAKC,GACD,OAAO,eAAeC;IACpB,MAAMC,aAAa,IAAIJ;IAEvB,kCAAkC;IAClC,IAAI;QACF,MAAMK,gBAAgB,MAAMP,oBAAoBM;QAChD,IAAIC,eAAe;YACjB,MAAMC,SAASF,WAAWG,SAAS;YACnCZ,EAAEO,GAAG,CAACM,IAAI,CAACZ,GAAGa,MAAM,CAAC;YACrB,IAAIH,QAAQI,QAAQ;gBAClBR,IAAIS,IAAI,CAAC,CAAC,SAAS,EAAEL,OAAOI,MAAM,EAAE;YACtC;YACAR,IAAIS,IAAI,CAAC,CAAC,eAAe,EAAEf,GAAGgB,GAAG,CAACR,WAAWS,cAAc,KAAK;YAChElB,EAAEmB,IAAI,CAAC,CAAC,8BAA8B,EAAElB,GAAGmB,IAAI,CAAC,6BAA6B,EAAE;YAC/E;QACF;IACF,EAAE,OAAM;QACN,qDAAqD;QACrDb,IAAIc,OAAO,CAAC;IACd;IAEA,mBAAmB;IACnB,MAAMC,qBAAqB;QACzBb;IACF;AACF;AAEA;;CAEC,GACD,eAAea,qBAAqB,EAAEb,UAAU,EAA8B;IAC5E,IAAI;QACF,qBAAqB;QACrB,MAAMc,SAAS,MAAMrB,iBAAiBO,YAAY;YAChDe,UAAUlB,aAAakB,QAAQ;YAC/BC,aAAanB,aAAamB,WAAW;YACrCC,QAAQpB,aAAaoB,MAAM;QAC7B;QAEA1B,EAAEO,GAAG,CAACoB,OAAO,CAAC1B,GAAG2B,KAAK,CAAC;QAEvB,IAAIL,OAAOR,MAAM,EAAE;YACjBR,IAAIsB,KAAK,CAAC,CAAC,SAAS,EAAEN,OAAOR,MAAM,EAAE;QACvC;QAEAR,IAAIsB,KAAK,CAAC,CAAC,eAAe,EAAE5B,GAAGgB,GAAG,CAACR,WAAWS,cAAc,KAAK;QAEjE,kBAAkB;QAClBlB,EAAEmB,IAAI,CAAC,CAAC,EAAE,EAAElB,GAAGmB,IAAI,CAAC,0BAA0B,2BAA2B,CAAC,EAAE;IAC9E,EAAE,OAAOU,OAAO;QACd,IAAIA,iBAAiB1B,gBAAgB;YACnCG,IAAIuB,KAAK,CAACA,MAAMC,OAAO;YAEvB,IAAID,MAAME,KAAK,EAAE;gBACfzB,IAAIsB,KAAK,CAAC,CAAC,OAAO,EAAEC,MAAME,KAAK,CAACD,OAAO,EAAE;YAC3C;QACF,OAAO;YACLxB,IAAIuB,KAAK,CAACA,iBAAiBG,QAAQH,MAAMC,OAAO,GAAG;QACrD;QAEAG,QAAQC,IAAI,CAAC;IACf;AACF"}
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
* Options for logout command
|
|
3
3
|
*/
|
|
4
4
|
export interface LogoutCommandOptions {
|
|
5
|
-
/** Logout from all environments */
|
|
6
|
-
all?: boolean;
|
|
7
5
|
/** Enable debug mode */
|
|
8
6
|
debug?: boolean;
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
11
9
|
* Handle the `@payloadcms/figma logout` command
|
|
12
10
|
*
|
|
13
|
-
* Clears stored tokens (OAuth and project tokens) after confirmation.
|
|
14
|
-
*
|
|
11
|
+
* Clears all stored tokens (OAuth and project tokens) after confirmation.
|
|
12
|
+
*
|
|
13
|
+
* @param _options - Command options (unused)
|
|
15
14
|
*/
|
|
16
|
-
export declare function logoutCommand(
|
|
15
|
+
export declare function logoutCommand(_options?: LogoutCommandOptions): Promise<void>;
|
|
17
16
|
//# sourceMappingURL=logout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wBAAwB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,QAAQ,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCtF"}
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import {
|
|
4
|
-
import { getEnvironment } from '../constants.js';
|
|
5
|
-
import { formatEnvSuffix } from '../utils/format-env-suffix.js';
|
|
3
|
+
import { TokenStore } from '../auth/token-store.js';
|
|
6
4
|
import * as log from '../utils/log.js';
|
|
7
|
-
const ALL_ENVIRONMENTS = [
|
|
8
|
-
'production',
|
|
9
|
-
'staging'
|
|
10
|
-
];
|
|
11
5
|
/**
|
|
12
6
|
* Handle the `@payloadcms/figma logout` command
|
|
13
7
|
*
|
|
14
|
-
* Clears stored tokens (OAuth and project tokens) after confirmation.
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await logoutAllEnvironments();
|
|
20
|
-
} else {
|
|
21
|
-
await logoutSingleEnvironment(currentEnv);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function logoutSingleEnvironment(env) {
|
|
25
|
-
const tokenStore = getTokenStore(env);
|
|
8
|
+
* Clears all stored tokens (OAuth and project tokens) after confirmation.
|
|
9
|
+
*
|
|
10
|
+
* @param _options - Command options (unused)
|
|
11
|
+
*/ export async function logoutCommand(_options = {}) {
|
|
12
|
+
const tokenStore = new TokenStore();
|
|
26
13
|
const hasTokens = tokenStore.getTokens() !== null;
|
|
27
14
|
if (!hasTokens) {
|
|
28
|
-
p.log.warn(pc.yellow(
|
|
15
|
+
p.log.warn(pc.yellow('No tokens found. Already logged out.'));
|
|
29
16
|
return;
|
|
30
17
|
}
|
|
18
|
+
// Confirm logout
|
|
31
19
|
const confirmed = await p.confirm({
|
|
32
20
|
initialValue: false,
|
|
33
|
-
message:
|
|
21
|
+
message: 'This will clear all OAuth and project tokens. Continue?'
|
|
34
22
|
});
|
|
35
23
|
if (p.isCancel(confirmed) || !confirmed) {
|
|
36
24
|
p.log.info('Logout cancelled');
|
|
@@ -39,43 +27,12 @@ async function logoutSingleEnvironment(env) {
|
|
|
39
27
|
const s = p.spinner();
|
|
40
28
|
s.start('Clearing tokens...');
|
|
41
29
|
try {
|
|
30
|
+
// Clear OAuth tokens
|
|
42
31
|
tokenStore.clearTokens();
|
|
32
|
+
// Clear all project tokens
|
|
43
33
|
tokenStore.clearAllProjectTokens();
|
|
44
|
-
s.stop(pc.green(
|
|
45
|
-
|
|
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'));
|
|
34
|
+
s.stop(pc.green('✓ Logged out successfully'));
|
|
35
|
+
p.log.step('All OAuth and project tokens have been cleared');
|
|
79
36
|
} catch (error) {
|
|
80
37
|
s.stop(pc.red('✗ Failed to clear tokens'));
|
|
81
38
|
log.error(error instanceof Error ? error.message : 'Unknown error');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/logout.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/commands/logout.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport pc from 'picocolors'\n\nimport { TokenStore } from '../auth/token-store.js'\nimport * as log from '../utils/log.js'\n\n/**\n * Options for logout command\n */\nexport interface LogoutCommandOptions {\n /** Enable debug mode */\n debug?: boolean\n}\n\n/**\n * Handle the `@payloadcms/figma logout` command\n *\n * Clears all stored tokens (OAuth and project tokens) after confirmation.\n *\n * @param _options - Command options (unused)\n */\nexport async function logoutCommand(_options: LogoutCommandOptions = {}): Promise<void> {\n const tokenStore = new TokenStore()\n\n const hasTokens = tokenStore.getTokens() !== null\n\n if (!hasTokens) {\n p.log.warn(pc.yellow('No tokens found. Already logged out.'))\n return\n }\n\n // Confirm logout\n const confirmed = await p.confirm({\n initialValue: false,\n message: 'This will clear all OAuth and project tokens. Continue?',\n })\n\n if (p.isCancel(confirmed) || !confirmed) {\n p.log.info('Logout cancelled')\n return\n }\n\n const s = p.spinner()\n s.start('Clearing tokens...')\n\n try {\n // Clear OAuth tokens\n tokenStore.clearTokens()\n // Clear all project tokens\n tokenStore.clearAllProjectTokens()\n s.stop(pc.green('✓ Logged out successfully'))\n p.log.step('All OAuth and project tokens have been cleared')\n } catch (error) {\n s.stop(pc.red('✗ Failed to clear tokens'))\n log.error(error instanceof Error ? error.message : 'Unknown error')\n process.exit(1)\n }\n}\n"],"names":["p","pc","TokenStore","log","logoutCommand","_options","tokenStore","hasTokens","getTokens","warn","yellow","confirmed","confirm","initialValue","message","isCancel","info","s","spinner","start","clearTokens","clearAllProjectTokens","stop","green","step","error","red","Error","process","exit"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,QAAQ,aAAY;AAE3B,SAASC,UAAU,QAAQ,yBAAwB;AACnD,YAAYC,SAAS,kBAAiB;AAUtC;;;;;;CAMC,GACD,OAAO,eAAeC,cAAcC,WAAiC,CAAC,CAAC;IACrE,MAAMC,aAAa,IAAIJ;IAEvB,MAAMK,YAAYD,WAAWE,SAAS,OAAO;IAE7C,IAAI,CAACD,WAAW;QACdP,EAAEG,GAAG,CAACM,IAAI,CAACR,GAAGS,MAAM,CAAC;QACrB;IACF;IAEA,iBAAiB;IACjB,MAAMC,YAAY,MAAMX,EAAEY,OAAO,CAAC;QAChCC,cAAc;QACdC,SAAS;IACX;IAEA,IAAId,EAAEe,QAAQ,CAACJ,cAAc,CAACA,WAAW;QACvCX,EAAEG,GAAG,CAACa,IAAI,CAAC;QACX;IACF;IAEA,MAAMC,IAAIjB,EAAEkB,OAAO;IACnBD,EAAEE,KAAK,CAAC;IAER,IAAI;QACF,qBAAqB;QACrBb,WAAWc,WAAW;QACtB,2BAA2B;QAC3Bd,WAAWe,qBAAqB;QAChCJ,EAAEK,IAAI,CAACrB,GAAGsB,KAAK,CAAC;QAChBvB,EAAEG,GAAG,CAACqB,IAAI,CAAC;IACb,EAAE,OAAOC,OAAO;QACdR,EAAEK,IAAI,CAACrB,GAAGyB,GAAG,CAAC;QACdvB,IAAIsB,KAAK,CAACA,iBAAiBE,QAAQF,MAAMX,OAAO,GAAG;QACnDc,QAAQC,IAAI,CAAC;IACf;AACF"}
|
package/dist/config/oauth.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { OAuthConfig } from '../auth/types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const URLS: Record<'prod' | 'staging', Pick<OAuthConfig, 'authorizationUrl' | 'refreshUrl' | 'tokenUrl'>>;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Figma OAuth2 configuration for public CLI client
|
|
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
|
|
6
17
|
*/
|
|
7
|
-
export declare function getOAuthConfig(): OAuthConfig;
|
|
8
18
|
export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
|
|
9
19
|
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/config/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/config/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,eAAO,MAAM,IAAI,EAAE,MAAM,CACvB,MAAM,GAAG,SAAS,EAClB,IAAI,CAAC,WAAW,EAAE,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAAC,CAYlE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,WAe1B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAA"}
|
package/dist/config/oauth.js
CHANGED
|
@@ -1,22 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
1
|
+
import { FIGMA_CLIENT_IDS } from '../constants.js';
|
|
2
|
+
export const URLS = {
|
|
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
|
+
};
|
|
3
14
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
* Figma OAuth2 configuration for public CLI client
|
|
16
|
+
*
|
|
17
|
+
* This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).
|
|
18
|
+
* No client secret is used because CLIs cannot securely store secrets.
|
|
19
|
+
* PKCE provides security through the code_verifier/code_challenge mechanism.
|
|
20
|
+
*
|
|
21
|
+
* For production use, register a public OAuth app with Figma.
|
|
22
|
+
* To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2
|
|
23
|
+
*/ export const OAUTH_CONFIG = {
|
|
24
|
+
// OAuth client ID (public client)
|
|
25
|
+
// Uses staging client ID by default since we use staging endpoints
|
|
26
|
+
clientId: process.env.FIGMA_CLIENT_ID || FIGMA_CLIENT_IDS.staging,
|
|
27
|
+
// No client secret - this is a public OAuth client using PKCE
|
|
28
|
+
// Public clients cannot securely store secrets in CLI environments
|
|
29
|
+
redirectUri: process.env.FIGMA_REDIRECT_URI || 'http://localhost:3000/callback',
|
|
30
|
+
// Only current_user:read scope is needed for basic user info
|
|
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
|
+
;
|
|
21
42
|
|
|
22
43
|
//# sourceMappingURL=oauth.js.map
|
package/dist/config/oauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/oauth.ts"],"sourcesContent":["import type { OAuthConfig } from '../auth/types.js'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/config/oauth.ts"],"sourcesContent":["import type { OAuthConfig } from '../auth/types.js'\n\nimport { FIGMA_CLIENT_IDS } from '../constants.js'\n\nexport const URLS: Record<\n 'prod' | 'staging',\n Pick<OAuthConfig, 'authorizationUrl' | 'refreshUrl' | 'tokenUrl'>\n> = {\n prod: {\n authorizationUrl: 'https://www.figma.com/oauth',\n refreshUrl: 'https://api.figma.com/v1/oauth/refresh',\n tokenUrl: 'https://api.figma.com/v1/oauth/token',\n },\n staging: {\n authorizationUrl: 'https://staging.figma.com/oauth',\n refreshUrl: 'https://api.staging.figma.com/v1/oauth/refresh',\n tokenUrl: 'https://api.staging.figma.com/v1/oauth/token',\n },\n}\n\n/**\n * Figma OAuth2 configuration for public CLI client\n *\n * This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).\n * No client secret is used because CLIs cannot securely store secrets.\n * PKCE provides security through the code_verifier/code_challenge mechanism.\n *\n * For production use, register a public OAuth app with Figma.\n * To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2\n */\nexport const OAUTH_CONFIG: OAuthConfig = {\n // OAuth client ID (public client)\n // Uses staging client ID by default since we use staging endpoints\n clientId: process.env.FIGMA_CLIENT_ID || FIGMA_CLIENT_IDS.staging,\n\n // No client secret - this is a public OAuth client using PKCE\n // Public clients cannot securely store secrets in CLI environments\n\n redirectUri: process.env.FIGMA_REDIRECT_URI || 'http://localhost:3000/callback',\n\n // Only current_user:read scope is needed for basic user info\n scopes: ['current_user:read'],\n\n // TODO: Dynamically choose between prod and staging based on environment\n ...URLS.staging,\n}\n\n/**\n * Buffer time (in seconds) before token expiration to consider token as expired\n * This helps avoid using tokens that are about to expire\n */\nexport const TOKEN_EXPIRY_BUFFER_SECONDS = 300 // 5 minutes\n"],"names":["FIGMA_CLIENT_IDS","URLS","prod","authorizationUrl","refreshUrl","tokenUrl","staging","OAUTH_CONFIG","clientId","process","env","FIGMA_CLIENT_ID","redirectUri","FIGMA_REDIRECT_URI","scopes","TOKEN_EXPIRY_BUFFER_SECONDS"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,kBAAiB;AAElD,OAAO,MAAMC,OAGT;IACFC,MAAM;QACJC,kBAAkB;QAClBC,YAAY;QACZC,UAAU;IACZ;IACAC,SAAS;QACPH,kBAAkB;QAClBC,YAAY;QACZC,UAAU;IACZ;AACF,EAAC;AAED;;;;;;;;;CASC,GACD,OAAO,MAAME,eAA4B;IACvC,kCAAkC;IAClC,mEAAmE;IACnEC,UAAUC,QAAQC,GAAG,CAACC,eAAe,IAAIX,iBAAiBM,OAAO;IAEjE,8DAA8D;IAC9D,mEAAmE;IAEnEM,aAAaH,QAAQC,GAAG,CAACG,kBAAkB,IAAI;IAE/C,6DAA6D;IAC7DC,QAAQ;QAAC;KAAoB;IAE7B,yEAAyE;IACzE,GAAGb,KAAKK,OAAO;AACjB,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMS,8BAA8B,IAAI,YAAY;CAAb"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
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
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Figma environment (production or staging)
|
|
3
11
|
*/
|
|
4
12
|
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
13
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
14
|
+
* Get current Figma environment from environment variable
|
|
15
|
+
* Defaults to 'staging' if not specified
|
|
16
|
+
*
|
|
17
|
+
* @returns Current environment
|
|
22
18
|
*/
|
|
23
|
-
export declare
|
|
24
|
-
/**
|
|
25
|
-
* Set environment override (used by --env CLI flag)
|
|
26
|
-
* Pass undefined to clear the override
|
|
27
|
-
*/
|
|
28
|
-
export declare function setEnvironment(env: Environment | undefined): void;
|
|
19
|
+
export declare function getEnvironment(): Environment;
|
|
29
20
|
/**
|
|
30
|
-
* Get
|
|
31
|
-
*
|
|
21
|
+
* Get JWKS URI for a given environment
|
|
22
|
+
*
|
|
23
|
+
* @param env - Environment (defaults to current environment)
|
|
24
|
+
* @returns JWKS URI for the environment
|
|
32
25
|
*/
|
|
33
|
-
export declare function
|
|
34
|
-
export {};
|
|
26
|
+
export declare function getJWKSUri(env?: Environment): string;
|
|
35
27
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA;AAED,eAAO,MAAM,QAAQ;;;CAGpB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;AAElD;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,MAAM,CAGpD"}
|
package/dist/constants.js
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
apiBaseUrl: 'https://api.figma.com',
|
|
9
|
-
authorizationUrl: 'https://www.figma.com/oauth',
|
|
10
|
-
clientId: 'lelKVTAzOekFnirnlAMbuD',
|
|
11
|
-
contentApiUrl: 'https://us-east-1.cms-tenants-001-production.figmacontent.com',
|
|
12
|
-
identityMetadata: 'https://www.figma.com/.well-known/openid-configuration',
|
|
13
|
-
jwksUri: 'https://static.figmacontent.com/.well_known/jwks.json'
|
|
14
|
-
},
|
|
15
|
-
staging: {
|
|
16
|
-
apiBaseUrl: 'https://api.staging.figma.com',
|
|
17
|
-
authorizationUrl: 'https://staging.figma.com/oauth',
|
|
18
|
-
clientId: 'wqAToBAp4UI9AZ5M6wTfT9',
|
|
19
|
-
contentApiUrl: 'https://us-east-1.cms-tenants-001-staging.figmacontentstaging.com',
|
|
20
|
-
identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',
|
|
21
|
-
jwksUri: 'https://static.figmacontentstaging.com/.well_known/jwks.json'
|
|
22
|
-
}
|
|
1
|
+
export const FIGMA_CLIENT_IDS = {
|
|
2
|
+
production: '',
|
|
3
|
+
staging: 'wqAToBAp4UI9AZ5M6wTfT9'
|
|
4
|
+
};
|
|
5
|
+
export const JWKS_URI = {
|
|
6
|
+
production: 'https://static.figmacontent.com/.well_known/jwks.json',
|
|
7
|
+
staging: 'https://static.figmacontentstaging.com/.well_known/jwks.json'
|
|
23
8
|
};
|
|
24
|
-
let envOverride;
|
|
25
9
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
* Get current Figma environment from environment variable
|
|
11
|
+
* Defaults to 'staging' if not specified
|
|
12
|
+
*
|
|
13
|
+
* @returns Current environment
|
|
14
|
+
*/ export function getEnvironment() {
|
|
15
|
+
return process.env.FIGMA_ENV === 'production' ? 'production' : 'staging';
|
|
30
16
|
}
|
|
31
17
|
/**
|
|
32
|
-
* Get
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
18
|
+
* Get JWKS URI for a given environment
|
|
19
|
+
*
|
|
20
|
+
* @param env - Environment (defaults to current environment)
|
|
21
|
+
* @returns JWKS URI for the environment
|
|
22
|
+
*/ export function getJWKSUri(env) {
|
|
23
|
+
const environment = env || getEnvironment();
|
|
24
|
+
return JWKS_URI[environment];
|
|
39
25
|
}
|
|
40
26
|
|
|
41
27
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const FIGMA_CLIENT_IDS = {\n production: '',\n staging: 'wqAToBAp4UI9AZ5M6wTfT9', // Hard-coded staging client ID\n}\n\nexport const JWKS_URI = {\n production: 'https://static.figmacontent.com/.well_known/jwks.json',\n staging: 'https://static.figmacontentstaging.com/.well_known/jwks.json',\n}\n\n/**\n * Figma environment (production or staging)\n */\nexport type Environment = 'production' | 'staging'\n\n/**\n * Get current Figma environment from environment variable\n * Defaults to 'staging' if not specified\n *\n * @returns Current environment\n */\nexport function getEnvironment(): Environment {\n return process.env.FIGMA_ENV === 'production' ? 'production' : 'staging'\n}\n\n/**\n * Get JWKS URI for a given environment\n *\n * @param env - Environment (defaults to current environment)\n * @returns JWKS URI for the environment\n */\nexport function getJWKSUri(env?: Environment): string {\n const environment = env || getEnvironment()\n return JWKS_URI[environment]\n}\n"],"names":["FIGMA_CLIENT_IDS","production","staging","JWKS_URI","getEnvironment","process","env","FIGMA_ENV","getJWKSUri","environment"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB;IAC9BC,YAAY;IACZC,SAAS;AACX,EAAC;AAED,OAAO,MAAMC,WAAW;IACtBF,YAAY;IACZC,SAAS;AACX,EAAC;AAOD;;;;;CAKC,GACD,OAAO,SAASE;IACd,OAAOC,QAAQC,GAAG,CAACC,SAAS,KAAK,eAAe,eAAe;AACjE;AAEA;;;;;CAKC,GACD,OAAO,SAASC,WAAWF,GAAiB;IAC1C,MAAMG,cAAcH,OAAOF;IAC3B,OAAOD,QAAQ,CAACM,YAAY;AAC9B"}
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
2
2
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
3
|
-
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
4
3
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA"}
|
package/dist/exports/client.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
2
2
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
3
|
-
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
4
3
|
|
|
5
4
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\n"],"names":["DefaultLoginButton","LogoutButton"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,4CAA2C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { contentAPIAdapter } from './db-content-api/index.js';
|
|
2
1
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
3
2
|
export type { FigmaContentSystemOptions } from './plugin/adapter.js';
|
|
4
|
-
export {
|
|
3
|
+
export { buildConfig } from './plugin/build-config.js';
|
|
5
4
|
export type { FigmaConfig } from './plugin/build-config.js';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAGpE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// Export contentAPIAdapter for testing use cases
|
|
2
|
-
export { contentAPIAdapter } from './db-content-api/index.js';
|
|
3
1
|
// Export database adapter for advanced use cases
|
|
4
2
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
5
3
|
// Export buildConfig wrapper and its config type
|
|
6
|
-
export {
|
|
4
|
+
export { buildConfig } from './plugin/build-config.js';
|
|
7
5
|
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export database adapter for advanced use cases\nexport { figmaContentSystem } from './plugin/adapter.js'\nexport type { FigmaContentSystemOptions } from './plugin/adapter.js'\n\n// Export buildConfig wrapper and its config type\nexport { buildConfig } from './plugin/build-config.js'\nexport type { FigmaConfig } from './plugin/build-config.js'\n"],"names":["figmaContentSystem","buildConfig"],"mappings":"AAAA,iDAAiD;AACjD,SAASA,kBAAkB,QAAQ,sBAAqB;AAGxD,iDAAiD;AACjD,SAASC,WAAW,QAAQ,2BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAIrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAoDhE,CAAA"}
|