@payloadcms/figma 0.0.1-alpha.61 → 0.0.1-alpha.63

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.
Files changed (50) hide show
  1. package/dist/api/control-plane.d.ts +4 -0
  2. package/dist/api/control-plane.js +11 -4
  3. package/dist/auth/crypto-utils.d.ts +11 -0
  4. package/dist/auth/crypto-utils.js +51 -0
  5. package/dist/auth/oauth-flow.js +3 -3
  6. package/dist/auth/project-token.d.ts +17 -6
  7. package/dist/auth/project-token.js +37 -19
  8. package/dist/auth/token-store-migration.d.ts +58 -0
  9. package/dist/auth/token-store-migration.js +156 -0
  10. package/dist/auth/token-store.d.ts +51 -128
  11. package/dist/auth/token-store.js +326 -187
  12. package/dist/auth/types.d.ts +8 -1
  13. package/dist/cli.js +9 -1
  14. package/dist/commands/debug.js +16 -12
  15. package/dist/commands/deploy.js +2 -0
  16. package/dist/commands/dump-tokens.d.ts +12 -0
  17. package/dist/commands/dump-tokens.js +69 -0
  18. package/dist/commands/init.js +8 -4
  19. package/dist/commands/list-tokens.js +2 -2
  20. package/dist/commands/login.js +1 -1
  21. package/dist/commands/logout.js +23 -4
  22. package/dist/config/oauth.d.ts +10 -2
  23. package/dist/config/oauth.js +18 -4
  24. package/dist/constants.d.ts +4 -2
  25. package/dist/constants.js +19 -1
  26. package/dist/db-content-api/index.js +21 -0
  27. package/dist/db-content-api/utilities/auth.js +4 -1
  28. package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
  29. package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
  30. package/dist/oauth/defaults.d.ts +3 -1
  31. package/dist/oauth/defaults.js +6 -5
  32. package/dist/oauth/endpoints/getLoginEndpoint.js +1 -1
  33. package/dist/oauth/index.js +1 -0
  34. package/dist/oauth/types.d.ts +10 -0
  35. package/dist/plugin/auth-preflight.d.ts +8 -0
  36. package/dist/plugin/auth-preflight.js +20 -0
  37. package/dist/plugin/bootstrap-preflight.d.ts +23 -0
  38. package/dist/plugin/bootstrap-preflight.js +45 -0
  39. package/dist/plugin/build-config.js +73 -12
  40. package/dist/plugin/dev-cookie-names.d.ts +14 -0
  41. package/dist/plugin/dev-cookie-names.js +19 -0
  42. package/dist/storage-content-api/client.js +4 -1
  43. package/dist/storage-content-api/staticHandler.js +1 -18
  44. package/dist/utils/build-lambda-zip.d.ts +4 -2
  45. package/dist/utils/build-lambda-zip.js +4 -7
  46. package/dist/utils/messages.js +1 -1
  47. package/dist/utils/token-display.d.ts +5 -1
  48. package/dist/utils/token-display.js +47 -26
  49. package/dist/utils/version-check.js +1 -1
  50. package/package.json +2 -1
@@ -1,151 +1,74 @@
1
1
  import type { Environment } from '../constants.js';
2
- import type { BootstrapData, FigmaTokens, JWTPayload, ProjectToken, TokenStoreConfig } from './types.js';
2
+ import type { BootstrapData, FigmaTokens, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
3
3
  /**
4
- * Get the singleton TokenStore instance for an environment
5
- * Use this for all production code to ensure a single shared instance per environment
6
- *
7
- * @param environment - The environment to get the token store for
8
- * @returns The singleton TokenStore instance for that environment
4
+ * Get the singleton TokenStore instance for an environment.
9
5
  */
10
6
  export declare function getTokenStore(environment?: Environment): TokenStore;
11
7
  /**
12
- * Secure storage manager for Figma OAuth2 tokens
13
- *
14
- * Uses the `conf` library to store tokens in an OS-specific secure location:
15
- * - macOS: ~/Library/Preferences/payloadcms-figma
16
- * - Linux: ~/.config/payloadcms-figma or $XDG_CONFIG_HOME/payloadcms-figma
17
- * - Windows: %APPDATA%/payloadcms-figma/Config
18
- *
19
- * Tokens are encrypted at rest with a machine-specific key and file permissions
20
- * are set to 0600 (owner read/write only)
8
+ * Secure storage manager for OAuth tokens and project-scoped bootstrap/token data.
21
9
  *
22
10
  * For production code, use getTokenStore() to get the singleton instance.
23
11
  * The constructor is still exported for test isolation.
24
12
  */
25
13
  export declare class TokenStore {
26
- private config;
14
+ private baseConfigName;
15
+ private encryptionKey;
27
16
  private environment;
17
+ private legacyRootDir;
18
+ private oauthConfig;
19
+ private projectName;
20
+ private projectStoreConfigs;
28
21
  constructor(options?: TokenStoreConfig);
29
- private safeGet;
30
- /**
31
- * Retrieve stored tokens
32
- * @returns FigmaTokens if stored, null otherwise
33
- */
34
- getTokens(): FigmaTokens | null;
35
- /**
36
- * Store OAuth2 tokens securely
37
- * @param tokens - Figma OAuth2 tokens to store
38
- */
22
+ getOauthInfo(): FigmaTokens | null;
39
23
  setTokens(tokens: FigmaTokens): void;
40
- /**
41
- * Clear all stored tokens (used for logout)
42
- */
43
24
  clearTokens(): void;
44
- /**
45
- * Check if valid (non-expired) tokens exist
46
- * @returns true if tokens exist and are not expired
47
- */
48
- hasValidTokens(): boolean;
49
- /**
50
- * Check if the current access token is expired
51
- * Includes a buffer time to avoid using tokens that are about to expire
52
- * @returns true if token is expired or will expire within buffer time
53
- */
54
- isExpired(): boolean;
55
- /**
56
- * Get the access token if it exists and is valid
57
- * @returns Access token string or null if expired/missing
58
- */
59
- getAccessToken(): null | string;
60
- /**
61
- * Get the refresh token if it exists
62
- * @returns Refresh token string or null if missing
63
- */
64
- getRefreshToken(): null | string;
65
- /**
66
- * Update just the access token after a refresh
67
- * Preserves the existing refresh token and other metadata
68
- * @param accessToken - New access token
69
- * @param expiresIn - Expiration time in seconds
70
- */
25
+ hasValidOauthToken(): boolean;
26
+ isOauthExpired(): boolean;
27
+ getCurrentOauthToken(): null | string;
28
+ getCurrentRefreshToken(): null | string;
71
29
  updateAccessToken(accessToken: string, expiresIn: number): void;
72
30
  /**
73
- * Get the path to the config file (useful for debugging)
74
- * @returns Absolute path to the token storage file
31
+ * Returns the OAuth storage file path.
75
32
  */
76
33
  getStoragePath(): string;
77
- /**
78
- * Retrieve a project token for a specific tenant
79
- * Automatically removes expired tokens from storage
80
- * @param tenantId - The tenant/CMS ID
81
- * @returns ProjectToken if stored and valid, null otherwise
82
- */
83
- getProjectToken(tenantId: string): null | ProjectToken;
84
- /**
85
- * Store a project token for a specific tenant
86
- * @param tenantId - The tenant/CMS ID
87
- * @param projectToken - The project token to store
88
- */
89
- setProjectToken(tenantId: string, projectToken: ProjectToken): void;
90
- /**
91
- * Clear a project token for a specific tenant
92
- * @param tenantId - The tenant/CMS ID
93
- */
94
- clearProjectToken(tenantId: string): void;
95
- /**
96
- * Clear all project tokens
97
- */
98
- clearAllProjectTokens(): void;
99
- /**
100
- * Check if a project token is expired
101
- * Includes a buffer time to avoid using tokens that are about to expire
102
- * @param projectToken - The project token to check
103
- * @returns true if token is expired or will expire within buffer time
104
- */
105
- isProjectTokenExpired(projectToken: ProjectToken): boolean;
106
- /**
107
- * Check if a valid (non-expired) project token exists for a tenant
108
- * @param tenantId - The tenant/CMS ID
109
- * @returns true if token exists and is not expired
110
- */
111
- hasValidProjectToken(tenantId: string): boolean;
112
- /**
113
- * Get validated JWT claims from a project token
114
- * @param tenantId - The tenant/CMS ID
115
- * @returns JWT payload claims or null if token not found or has no claims
116
- */
117
- getProjectTokenClaims(tenantId: string): JWTPayload | null;
118
- /**
119
- * Get all tenant IDs that have stored project tokens
120
- * @returns Array of tenant IDs
121
- */
122
- getAllProjectTokenTenantIds(): string[];
123
- /**
124
- * Build the composite key for bootstrap data storage
125
- * @param projectId - The CMS resource/project ID
126
- * @param environmentName - The environment name (e.g. 'production', 'staging')
127
- * @returns Composite key string
128
- */
129
- private bootstrapKey;
130
- /**
131
- * Retrieve bootstrap data for a project + environment
132
- * @param projectId - The CMS resource/project ID
133
- * @param environmentName - The environment name
134
- * @returns BootstrapData if stored, null otherwise
135
- */
34
+ getProjectToken({ projectInfo, }?: {
35
+ projectInfo?: ProjectStoreScope;
36
+ }): null | ProjectToken;
37
+ setProjectToken({ projectInfo, token, }: {
38
+ projectInfo?: ProjectStoreScope;
39
+ token: ProjectToken;
40
+ }): void;
41
+ clearProjectToken({ projectInfo }?: {
42
+ projectInfo?: ProjectStoreScope;
43
+ }): void;
44
+ isProjectTokenExpired(token: ProjectToken): boolean;
45
+ hasValidProjectToken({ projectInfo }?: {
46
+ projectInfo?: ProjectStoreScope;
47
+ }): boolean;
48
+ /**
49
+ * Get the tenantId (contentSystemId) for the project scope.
50
+ * Returns null if bootstrap data is not available.
51
+ */
52
+ getTenantId({ projectInfo }?: {
53
+ projectInfo?: ProjectStoreScope;
54
+ }): null | string;
55
+ /**
56
+ * Derive project info from environment variables.
57
+ * Returns null if either FIGMA_PROJECT_ID or FIGMA_ENVIRONMENT_NAME is not set.
58
+ */
59
+ private getProjectInfoFromEnv;
136
60
  getBootstrapData(projectId: string, environmentName: string): BootstrapData | null;
137
- /**
138
- * Store bootstrap data for a project + environment
139
- * @param projectId - The CMS resource/project ID
140
- * @param environmentName - The environment name
141
- * @param data - The bootstrap data to store
142
- */
143
61
  setBootstrapData(projectId: string, environmentName: string, data: BootstrapData): void;
144
- /**
145
- * Clear bootstrap data for a project + environment
146
- * @param projectId - The CMS resource/project ID
147
- * @param environmentName - The environment name
148
- */
149
62
  clearBootstrapData(projectId: string, environmentName: string): void;
63
+ private buildOAuthConfigName;
64
+ private buildOAuthStoreCwd;
65
+ private buildProjectStoreConfigName;
66
+ private buildProjectStoreCwd;
67
+ private sanitizeConfigSegment;
68
+ private projectInfoKey;
69
+ private getLegacyRootDir;
70
+ private getProjectStore;
71
+ private createConfig;
72
+ private safeGet;
150
73
  }
151
74
  //# sourceMappingURL=token-store.d.ts.map