@payloadcms/figma 0.0.1-alpha.65 → 0.0.1-alpha.66
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.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* to the Content API. Project tokens are scoped to a specific tenant/CMS
|
|
6
6
|
* and have a shorter lifespan (15-30 minutes) than OAuth tokens.
|
|
7
7
|
*/ import { getProjectToken as fetchProjectToken } from '../api/figma-api.js';
|
|
8
|
-
import {
|
|
8
|
+
import { PROJECT_TOKEN_EXPIRY_BUFFER_SECONDS } from '../config/oauth.js';
|
|
9
9
|
import { getInfraEnvironment } from '../constants.js';
|
|
10
10
|
import * as log from '../utils/log.js';
|
|
11
11
|
import { JWTValidationError, validateProjectToken } from './jwt-validator.js';
|
|
@@ -27,7 +27,7 @@ function buildCacheKey(params) {
|
|
|
27
27
|
return `${params.tenantId}::${projectId}::${environmentName}`;
|
|
28
28
|
}
|
|
29
29
|
function isCachedTokenValid(entry) {
|
|
30
|
-
const bufferMs =
|
|
30
|
+
const bufferMs = PROJECT_TOKEN_EXPIRY_BUFFER_SECONDS * 1000;
|
|
31
31
|
return Date.now() < entry.expiresAt - bufferMs;
|
|
32
32
|
}
|
|
33
33
|
/** Test-only: clears the in-memory token cache and any in-flight refresh promises. */ export function __resetProjectTokenCacheForTests() {
|
package/dist/auth/token-store.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import envPaths from 'env-paths';
|
|
3
3
|
import fsSync from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { TOKEN_EXPIRY_BUFFER_SECONDS } from '../config/oauth.js';
|
|
5
|
+
import { PROJECT_TOKEN_EXPIRY_BUFFER_SECONDS, TOKEN_EXPIRY_BUFFER_SECONDS } from '../config/oauth.js';
|
|
6
6
|
import { getInfraEnvironment } from '../constants.js';
|
|
7
7
|
import { getEnvVarSync } from '../utils/env-management.js';
|
|
8
8
|
import * as log from '../utils/log.js';
|
|
@@ -276,7 +276,7 @@ const PROJECT_STORE_SCHEMA_VERSION = 1;
|
|
|
276
276
|
}
|
|
277
277
|
isProjectTokenExpired(token) {
|
|
278
278
|
const now = Date.now();
|
|
279
|
-
const bufferMs =
|
|
279
|
+
const bufferMs = PROJECT_TOKEN_EXPIRY_BUFFER_SECONDS * 1000;
|
|
280
280
|
const expiryWithBuffer = token.expiresAt - bufferMs;
|
|
281
281
|
return now >= expiryWithBuffer;
|
|
282
282
|
}
|
package/dist/config/oauth.d.ts
CHANGED
|
@@ -15,4 +15,11 @@ export declare const DEFAULT_CALLBACK_PORT: number;
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function getOAuthConfig(): OAuthConfig;
|
|
17
17
|
export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
|
|
18
|
+
/**
|
|
19
|
+
* Freshness buffer for project tokens. Figma's `pixie` issues 300-second project
|
|
20
|
+
* tokens, so reusing the 300-second OAuth buffer would treat every fresh token as
|
|
21
|
+
* already-expired and bypass the cache entirely. 30 seconds is well above the
|
|
22
|
+
* round-trip time for the calls these tokens authorize.
|
|
23
|
+
*/
|
|
24
|
+
export declare const PROJECT_TOKEN_EXPIRY_BUFFER_SECONDS = 30;
|
|
18
25
|
//# sourceMappingURL=oauth.d.ts.map
|
package/dist/config/oauth.js
CHANGED
|
@@ -37,5 +37,11 @@ export const DEFAULT_CALLBACK_PORT = DEFAULT_CALLBACK_PORTS[0];
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
export const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
|
|
40
|
+
/**
|
|
41
|
+
* Freshness buffer for project tokens. Figma's `pixie` issues 300-second project
|
|
42
|
+
* tokens, so reusing the 300-second OAuth buffer would treat every fresh token as
|
|
43
|
+
* already-expired and bypass the cache entirely. 30 seconds is well above the
|
|
44
|
+
* round-trip time for the calls these tokens authorize.
|
|
45
|
+
*/ export const PROJECT_TOKEN_EXPIRY_BUFFER_SECONDS = 30;
|
|
40
46
|
|
|
41
47
|
//# sourceMappingURL=oauth.js.map
|