@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.
- package/dist/api/control-plane.d.ts +4 -0
- package/dist/api/control-plane.js +11 -4
- package/dist/auth/crypto-utils.d.ts +11 -0
- package/dist/auth/crypto-utils.js +51 -0
- package/dist/auth/oauth-flow.js +3 -3
- package/dist/auth/project-token.d.ts +17 -6
- package/dist/auth/project-token.js +37 -19
- package/dist/auth/token-store-migration.d.ts +58 -0
- package/dist/auth/token-store-migration.js +156 -0
- package/dist/auth/token-store.d.ts +51 -128
- package/dist/auth/token-store.js +326 -187
- package/dist/auth/types.d.ts +8 -1
- package/dist/cli.js +9 -1
- package/dist/commands/debug.js +16 -12
- package/dist/commands/deploy.js +2 -0
- package/dist/commands/dump-tokens.d.ts +12 -0
- package/dist/commands/dump-tokens.js +69 -0
- package/dist/commands/init.js +8 -4
- package/dist/commands/list-tokens.js +2 -2
- package/dist/commands/login.js +1 -1
- package/dist/commands/logout.js +23 -4
- package/dist/config/oauth.d.ts +10 -2
- package/dist/config/oauth.js +18 -4
- package/dist/constants.d.ts +4 -2
- package/dist/constants.js +19 -1
- package/dist/db-content-api/index.js +21 -0
- package/dist/db-content-api/utilities/auth.js +4 -1
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +7 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +102 -0
- package/dist/oauth/defaults.d.ts +3 -1
- package/dist/oauth/defaults.js +6 -5
- package/dist/oauth/endpoints/getLoginEndpoint.js +1 -1
- package/dist/oauth/index.js +1 -0
- package/dist/oauth/types.d.ts +10 -0
- package/dist/plugin/auth-preflight.d.ts +8 -0
- package/dist/plugin/auth-preflight.js +20 -0
- package/dist/plugin/bootstrap-preflight.d.ts +23 -0
- package/dist/plugin/bootstrap-preflight.js +45 -0
- package/dist/plugin/build-config.js +73 -12
- package/dist/plugin/dev-cookie-names.d.ts +14 -0
- package/dist/plugin/dev-cookie-names.js +19 -0
- package/dist/storage-content-api/client.js +4 -1
- package/dist/storage-content-api/staticHandler.js +1 -18
- package/dist/utils/build-lambda-zip.d.ts +4 -2
- package/dist/utils/build-lambda-zip.js +4 -7
- package/dist/utils/messages.js +1 -1
- package/dist/utils/token-display.d.ts +5 -1
- package/dist/utils/token-display.js +47 -26
- package/dist/utils/version-check.js +1 -1
- package/package.json +2 -1
|
@@ -1,151 +1,74 @@
|
|
|
1
1
|
import type { Environment } from '../constants.js';
|
|
2
|
-
import type { BootstrapData, FigmaTokens,
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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
|
-
*
|
|
74
|
-
* @returns Absolute path to the token storage file
|
|
31
|
+
* Returns the OAuth storage file path.
|
|
75
32
|
*/
|
|
76
33
|
getStoragePath(): string;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
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
|