@payloadcms/figma 1.0.0-beta.0 → 1.0.0-beta.2
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/adapters/build-lambda-zip.d.ts +2 -1
- package/dist/adapters/build-lambda-zip.js +4 -1
- package/dist/adapters/deploy-output/assertDeployableServerActionsKey.d.ts +14 -0
- package/dist/adapters/deploy-output/assertDeployableServerActionsKey.js +33 -0
- package/dist/commands/upload-schema.js +23 -9
- package/dist/content-api/auth.d.ts +34 -0
- package/dist/content-api/auth.js +70 -0
- package/dist/content-api/awaitWithSignal.d.ts +2 -0
- package/dist/content-api/awaitWithSignal.js +27 -0
- package/dist/content-api/createContentApiClient.d.ts +18 -0
- package/dist/content-api/createContentApiClient.js +90 -0
- package/dist/content-api/withRateLimitRetries.d.ts +7 -0
- package/dist/content-api/withRateLimitRetries.js +45 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +247 -0
- package/dist/db-content-api/index.d.ts +5 -5
- package/dist/db-content-api/index.js +46 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/oauth/components/FigmaAvatar/index.js +3 -2
- package/dist/oauth/components/FigmaAvatarCell/index.js +3 -1
- package/dist/oauth/components/LoginButton/index.js +8 -4
- package/dist/oauth/components/LogoutButton/index.js +3 -2
- package/dist/oauth/defaults.js +2 -2
- package/dist/oauth/endpoints/getLoginEndpoint.js +2 -5
- package/dist/oauth/hooks/me.d.ts +4 -3
- package/dist/oauth/hooks/me.js +6 -52
- package/dist/oauth/hooks/refresh.js +9 -1
- package/dist/oauth/index.js +3 -3
- package/dist/oauth/strategy/index.d.ts +3 -0
- package/dist/oauth/strategy/index.js +49 -3
- package/dist/oauth/utilities/clearCookie.d.ts +1 -0
- package/dist/oauth/utilities/clearCookie.js +13 -9
- package/dist/oauth/utilities/clearSessionCookies.d.ts +5 -0
- package/dist/oauth/utilities/clearSessionCookies.js +17 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +1 -2
- package/dist/oauth/utilities/mergeHeaders.js +11 -23
- package/dist/oauth/utilities/refreshTokens.d.ts +9 -3
- package/dist/oauth/utilities/refreshTokens.js +45 -34
- package/dist/oauth/utilities/resolvePayloadRedirect.d.ts +13 -0
- package/dist/oauth/utilities/resolvePayloadRedirect.js +30 -0
- package/dist/plugin/build-config.js +16 -13
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +1 -1
- package/dist/plugin/cloud-limits/shared.d.ts +5 -1
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +2 -1
- package/dist/plugin/dev-cookie-names.d.ts +4 -1
- package/dist/plugin/dev-cookie-names.js +6 -3
- package/dist/plugin/environment-error.d.ts +4 -0
- package/dist/plugin/environment-error.js +22 -0
- package/dist/plugin/mcp-oauth.d.ts +10 -0
- package/dist/plugin/mcp-oauth.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +5 -6
- package/dist/plugin/sandbox-upload-fetch.js +22 -14
- package/dist/scss.d.js +1 -1
- package/dist/storage-content-api/api-types.d.ts +22 -1
- package/dist/storage-content-api/api-types.js +2 -1
- package/dist/storage-content-api/client.d.ts +3 -3
- package/dist/storage-content-api/client.js +13 -35
- package/dist/storage-content-api/index.js +20 -21
- package/dist/storage-content-api/staticHandler.js +4 -1
- package/dist/storage-content-api/types.d.ts +2 -2
- package/dist/translations/ar.d.ts +9 -0
- package/dist/translations/ar.js +10 -1
- package/dist/translations/az.d.ts +9 -0
- package/dist/translations/az.js +10 -1
- package/dist/translations/bg.d.ts +9 -0
- package/dist/translations/bg.js +10 -1
- package/dist/translations/bnBd.d.ts +9 -0
- package/dist/translations/bnBd.js +10 -1
- package/dist/translations/bnIn.d.ts +9 -0
- package/dist/translations/bnIn.js +10 -1
- package/dist/translations/ca.d.ts +9 -0
- package/dist/translations/ca.js +10 -1
- package/dist/translations/cs.d.ts +9 -0
- package/dist/translations/cs.js +10 -1
- package/dist/translations/da.d.ts +9 -0
- package/dist/translations/da.js +10 -1
- package/dist/translations/de.d.ts +9 -0
- package/dist/translations/de.js +10 -1
- package/dist/translations/en.d.ts +9 -0
- package/dist/translations/en.js +10 -1
- package/dist/translations/es.d.ts +9 -0
- package/dist/translations/es.js +15 -6
- package/dist/translations/et.d.ts +9 -0
- package/dist/translations/et.js +10 -1
- package/dist/translations/fa.d.ts +9 -0
- package/dist/translations/fa.js +10 -1
- package/dist/translations/fr.d.ts +9 -0
- package/dist/translations/fr.js +10 -1
- package/dist/translations/he.d.ts +9 -0
- package/dist/translations/he.js +10 -1
- package/dist/translations/hr.d.ts +9 -0
- package/dist/translations/hr.js +10 -1
- package/dist/translations/hu.d.ts +9 -0
- package/dist/translations/hu.js +10 -1
- package/dist/translations/hy.d.ts +9 -0
- package/dist/translations/hy.js +10 -1
- package/dist/translations/id.d.ts +9 -0
- package/dist/translations/id.js +10 -1
- package/dist/translations/index.d.ts +400 -3
- package/dist/translations/is.d.ts +9 -0
- package/dist/translations/is.js +10 -1
- package/dist/translations/it.d.ts +9 -0
- package/dist/translations/it.js +10 -1
- package/dist/translations/ja.d.ts +9 -0
- package/dist/translations/ja.js +14 -5
- package/dist/translations/ko.d.ts +9 -0
- package/dist/translations/ko.js +16 -7
- package/dist/translations/lt.d.ts +9 -0
- package/dist/translations/lt.js +10 -1
- package/dist/translations/lv.d.ts +9 -0
- package/dist/translations/lv.js +10 -1
- package/dist/translations/my.d.ts +9 -0
- package/dist/translations/my.js +10 -1
- package/dist/translations/nb.d.ts +9 -0
- package/dist/translations/nb.js +10 -1
- package/dist/translations/nl.d.ts +9 -0
- package/dist/translations/nl.js +10 -1
- package/dist/translations/pl.d.ts +9 -0
- package/dist/translations/pl.js +10 -1
- package/dist/translations/pt.d.ts +9 -0
- package/dist/translations/pt.js +15 -6
- package/dist/translations/ro.d.ts +9 -0
- package/dist/translations/ro.js +10 -1
- package/dist/translations/rs.d.ts +9 -0
- package/dist/translations/rs.js +10 -1
- package/dist/translations/rsLatin.d.ts +9 -0
- package/dist/translations/rsLatin.js +10 -1
- package/dist/translations/ru.d.ts +9 -0
- package/dist/translations/ru.js +10 -1
- package/dist/translations/sk.d.ts +9 -0
- package/dist/translations/sk.js +10 -1
- package/dist/translations/sl.d.ts +9 -0
- package/dist/translations/sl.js +10 -1
- package/dist/translations/sv.d.ts +9 -0
- package/dist/translations/sv.js +10 -1
- package/dist/translations/ta.d.ts +9 -0
- package/dist/translations/ta.js +10 -1
- package/dist/translations/th.d.ts +9 -0
- package/dist/translations/th.js +10 -1
- package/dist/translations/tr.d.ts +9 -0
- package/dist/translations/tr.js +10 -1
- package/dist/translations/uk.d.ts +9 -0
- package/dist/translations/uk.js +10 -1
- package/dist/translations/vi.d.ts +9 -0
- package/dist/translations/vi.js +10 -1
- package/dist/translations/zh.d.ts +9 -0
- package/dist/translations/zh.js +10 -1
- package/dist/translations/zhTw.d.ts +9 -0
- package/dist/translations/zhTw.js +10 -1
- package/dist/utils/env-management.js +7 -0
- package/package.json +20 -22
- package/dist/db-content-api/utilities/auth.d.ts +0 -29
- package/dist/db-content-api/utilities/auth.js +0 -82
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { getValidProjectToken } from '../../auth/project-token.js';
|
|
2
|
-
// Module-level cache for dev JWT tokens
|
|
3
|
-
const devJwtCache = new Map();
|
|
4
|
-
export async function fetchDevJwt(url, contentSystemId) {
|
|
5
|
-
const usesSuperUser = !contentSystemId || contentSystemId === 'test-system' || contentSystemId === '*';
|
|
6
|
-
const contentSystemIdForJWT = usesSuperUser ? '*' : contentSystemId;
|
|
7
|
-
const response = await fetch(`${url}/dev/jwt`, {
|
|
8
|
-
body: JSON.stringify({
|
|
9
|
-
content_system_id: contentSystemIdForJWT
|
|
10
|
-
}),
|
|
11
|
-
headers: {
|
|
12
|
-
'Content-Type': 'application/json'
|
|
13
|
-
},
|
|
14
|
-
method: 'POST'
|
|
15
|
-
});
|
|
16
|
-
if (!response.ok) {
|
|
17
|
-
throw new Error(`Failed to get dev JWT: ${response.status} ${response.statusText}`);
|
|
18
|
-
}
|
|
19
|
-
const { token } = await response.json();
|
|
20
|
-
return token;
|
|
21
|
-
}
|
|
22
|
-
export function createAuthMiddleware(opts) {
|
|
23
|
-
return {
|
|
24
|
-
async onRequest ({ request }) {
|
|
25
|
-
if (opts.auth.mode === 'apiKey') {
|
|
26
|
-
request.headers.set('X-Api-Key', opts.auth.apiKey);
|
|
27
|
-
} else if (opts.auth.mode === 'tokenStore') {
|
|
28
|
-
const token = await getValidProjectToken({
|
|
29
|
-
tenantId: opts.contentSystemId,
|
|
30
|
-
tokenStore: opts.auth.tokenStore
|
|
31
|
-
});
|
|
32
|
-
if (!token) {
|
|
33
|
-
throw new Error('Authentication required. Run `npx @payloadcms/figma login` to authenticate.');
|
|
34
|
-
}
|
|
35
|
-
request.headers.set('Authorization', `Bearer ${token}`);
|
|
36
|
-
} else {
|
|
37
|
-
let token = devJwtCache.get(opts.contentSystemId);
|
|
38
|
-
if (!token) {
|
|
39
|
-
token = await fetchDevJwt(opts.url, opts.contentSystemId);
|
|
40
|
-
devJwtCache.set(opts.contentSystemId, token);
|
|
41
|
-
opts.logger.info(`Dev JWT acquired for content system: ${opts.contentSystemId}`);
|
|
42
|
-
}
|
|
43
|
-
request.headers.set('Authorization', `Bearer ${token}`);
|
|
44
|
-
}
|
|
45
|
-
return request;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function createErrorMiddleware(opts) {
|
|
50
|
-
return {
|
|
51
|
-
async onResponse ({ request, response }) {
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
// Handle 401 retry for dev JWT
|
|
54
|
-
if (response.status === 401 && opts.auth.mode === 'devJwt') {
|
|
55
|
-
const retryCount = parseInt(request.headers.get('X-Retry-Count') || '0', 10);
|
|
56
|
-
if (retryCount < 1) {
|
|
57
|
-
opts.logger.info('Dev JWT expired, refreshing...');
|
|
58
|
-
devJwtCache.delete(opts.contentSystemId);
|
|
59
|
-
const newToken = await fetchDevJwt(opts.url, opts.contentSystemId);
|
|
60
|
-
devJwtCache.set(opts.contentSystemId, newToken);
|
|
61
|
-
// duplex: 'half' is required for Node.js fetch with streaming body
|
|
62
|
-
const newRequest = new Request(request.url, {
|
|
63
|
-
body: request.body,
|
|
64
|
-
duplex: 'half',
|
|
65
|
-
headers: new Headers(request.headers),
|
|
66
|
-
method: request.method
|
|
67
|
-
});
|
|
68
|
-
newRequest.headers.set('X-Retry-Count', '1');
|
|
69
|
-
newRequest.headers.set('Authorization', `Bearer ${newToken}`);
|
|
70
|
-
return fetch(newRequest);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const text = await response.clone().text();
|
|
74
|
-
opts.logger.error({
|
|
75
|
-
msg: `HTTP ${response.status} from ${request.url}`,
|
|
76
|
-
response: text
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return response;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|