@payloadcms/figma 0.0.1-alpha.73 → 0.0.1-alpha.75
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 +0 -1
- package/dist/api/control-plane.js +0 -2
- package/dist/api/error-response.d.ts +0 -1
- package/dist/api/error-response.js +0 -2
- package/dist/api/figma-api.d.ts +2 -2
- package/dist/api/figma-api.js +33 -5
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +0 -1
- package/dist/auth/callback-server.js +0 -2
- package/dist/auth/credentials.d.ts +0 -1
- package/dist/auth/credentials.js +0 -2
- package/dist/auth/crypto-utils.d.ts +0 -1
- package/dist/auth/crypto-utils.js +0 -2
- package/dist/auth/jwt-validator.d.ts +22 -6
- package/dist/auth/jwt-validator.js +33 -7
- package/dist/auth/oauth-flow.d.ts +0 -1
- package/dist/auth/oauth-flow.js +0 -2
- package/dist/auth/paste-code.d.ts +0 -1
- package/dist/auth/paste-code.js +0 -2
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +0 -1
- package/dist/auth/project-token.js +6 -4
- package/dist/auth/refresh.d.ts +0 -1
- package/dist/auth/refresh.js +0 -2
- package/dist/auth/token-store-migration.d.ts +0 -1
- package/dist/auth/token-store-migration.js +0 -2
- package/dist/auth/token-store.d.ts +0 -1
- package/dist/auth/token-store.js +0 -2
- package/dist/auth/types.d.ts +5 -2
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +7 -2
- package/dist/commands/bootstrap.d.ts +0 -1
- package/dist/commands/bootstrap.js +0 -2
- package/dist/commands/build-lambda-zip.d.ts +0 -1
- package/dist/commands/build-lambda-zip.js +0 -2
- package/dist/commands/debug.d.ts +0 -1
- package/dist/commands/debug.js +0 -2
- package/dist/commands/deploy.d.ts +0 -1
- package/dist/commands/deploy.js +0 -2
- package/dist/commands/dump-tokens.d.ts +0 -1
- package/dist/commands/dump-tokens.js +0 -2
- package/dist/commands/env.d.ts +0 -1
- package/dist/commands/env.js +0 -2
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +0 -2
- package/dist/commands/list-tokens.d.ts +0 -1
- package/dist/commands/list-tokens.js +0 -2
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -2
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -2
- package/dist/commands/upgrade.d.ts +0 -1
- package/dist/commands/upgrade.js +0 -2
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +0 -1
- package/dist/config/oauth.js +0 -2
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -2
- package/dist/db-content-api/generated/content-api-types.d.ts +4188 -592
- package/dist/db-content-api/generated/content-api-types.js +0 -2
- package/dist/db-content-api/index.d.ts +0 -1
- package/dist/db-content-api/index.js +0 -2
- package/dist/db-content-api/temp-utilities/slug.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/slug.js +0 -2
- package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/sorting.js +0 -2
- package/dist/db-content-api/temp-utilities/types.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/types.js +0 -2
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -2
- package/dist/db-content-api/utilities/auth.d.ts +0 -1
- package/dist/db-content-api/utilities/auth.js +0 -2
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -1
- package/dist/db-content-api/utilities/data/applyDefaults.js +0 -2
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js +0 -2
- package/dist/db-content-api/utilities/data/index.d.ts +0 -1
- package/dist/db-content-api/utilities/data/index.js +0 -2
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -1
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -2
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -1
- package/dist/db-content-api/utilities/data/stripFields.js +0 -2
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +0 -1
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +0 -2
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +0 -1
- package/dist/db-content-api/utilities/data/validateRelationships.js +0 -2
- package/dist/db-content-api/utilities/joins.d.ts +0 -1
- package/dist/db-content-api/utilities/joins.js +0 -2
- package/dist/db-content-api/utilities/locale/index.d.ts +0 -1
- package/dist/db-content-api/utilities/locale/index.js +0 -2
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +0 -2
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildMeta.js +0 -2
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +0 -2
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +0 -2
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +0 -2
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +56 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +183 -0
- package/dist/db-content-api/utilities/where.d.ts +0 -1
- package/dist/db-content-api/utilities/where.js +0 -2
- package/dist/deploy/schedule-extract-plugin.d.ts +0 -1
- package/dist/deploy/schedule-extract-plugin.js +0 -2
- package/dist/endpoints/health.d.ts +0 -1
- package/dist/endpoints/health.js +0 -2
- package/dist/endpoints/schema.d.ts +0 -1
- package/dist/endpoints/schema.js +0 -2
- package/dist/exports/client.d.ts +0 -1
- package/dist/exports/client.js +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/download-skill.d.ts +0 -1
- package/dist/lib/download-skill.js +0 -2
- package/dist/oauth/components/FigmaAvatar/index.d.ts +0 -1
- package/dist/oauth/components/FigmaAvatar/index.js +0 -2
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +0 -1
- package/dist/oauth/components/FigmaAvatarCell/index.js +0 -2
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +0 -1
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +0 -2
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +0 -1
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +0 -2
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +3 -5
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +0 -2
- package/dist/oauth/defaults.d.ts +0 -1
- package/dist/oauth/defaults.js +8 -2
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +4 -8
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +0 -2
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +0 -2
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +0 -2
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +0 -2
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +0 -2
- package/dist/oauth/strategy/index.d.ts +0 -1
- package/dist/oauth/strategy/index.js +17 -19
- package/dist/oauth/types.d.ts +0 -1
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +0 -2
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +0 -2
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +4 -5
- package/dist/oauth/utilities/establishSession.js +9 -12
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +0 -1
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +0 -2
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +0 -1
- package/dist/oauth/utilities/figmaHostnames.js +0 -2
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +0 -2
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +0 -1
- package/dist/oauth/utilities/isAbsoluteURL.js +0 -2
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -1
- package/dist/oauth/utilities/isDuplicateKeyError.js +0 -2
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +16 -12
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +0 -1
- package/dist/oauth/utilities/withPartitionedCookie.js +0 -2
- package/dist/oauth/utils/getSearchParam.d.ts +27 -0
- package/dist/oauth/utils/getSearchParam.js +45 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +0 -1
- package/dist/plugin/auth-preflight.js +0 -2
- package/dist/plugin/bootstrap-preflight.d.ts +0 -1
- package/dist/plugin/bootstrap-preflight.js +0 -2
- package/dist/plugin/build-config.d.ts +1 -1
- package/dist/plugin/build-config.js +66 -3
- package/dist/plugin/dev-cookie-names.d.ts +0 -1
- package/dist/plugin/dev-cookie-names.js +0 -2
- package/dist/storage-content-api/api-types.d.ts +0 -1
- package/dist/storage-content-api/api-types.js +0 -2
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -2
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -2
- package/dist/storage-content-api/client.d.ts +0 -1
- package/dist/storage-content-api/client.js +0 -2
- package/dist/storage-content-api/generateURL.d.ts +0 -1
- package/dist/storage-content-api/generateURL.js +0 -2
- package/dist/storage-content-api/handleDelete.d.ts +0 -1
- package/dist/storage-content-api/handleDelete.js +0 -2
- package/dist/storage-content-api/handleUpload.d.ts +0 -1
- package/dist/storage-content-api/handleUpload.js +0 -2
- package/dist/storage-content-api/index.d.ts +0 -1
- package/dist/storage-content-api/index.js +0 -2
- package/dist/storage-content-api/staticHandler.d.ts +0 -1
- package/dist/storage-content-api/staticHandler.js +0 -2
- package/dist/storage-content-api/types.d.ts +0 -1
- package/dist/storage-content-api/types.js +0 -2
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +0 -1
- package/dist/storage-content-api/utilities/getSafeFilename.js +0 -2
- package/dist/storage-content-api/utilities/index.d.ts +0 -1
- package/dist/storage-content-api/utilities/index.js +0 -2
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +0 -1
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +0 -2
- package/dist/types/config.d.ts +0 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +0 -1
- package/dist/utils/adapters/nextjs.js +0 -2
- package/dist/utils/adapters/nitro.d.ts +0 -1
- package/dist/utils/adapters/nitro.js +0 -2
- package/dist/utils/adapters/vite.d.ts +0 -1
- package/dist/utils/adapters/vite.js +0 -2
- package/dist/utils/asset-collection.d.ts +0 -1
- package/dist/utils/asset-collection.js +0 -2
- package/dist/utils/build-detection.d.ts +0 -1
- package/dist/utils/build-detection.js +0 -2
- package/dist/utils/build-lambda-zip.d.ts +0 -1
- package/dist/utils/build-lambda-zip.js +0 -2
- package/dist/utils/cache-bootstrap.d.ts +0 -1
- package/dist/utils/cache-bootstrap.js +0 -2
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +0 -2
- package/dist/utils/deploy-adapter.d.ts +0 -1
- package/dist/utils/deploy-adapter.js +0 -2
- package/dist/utils/download-template.d.ts +0 -1
- package/dist/utils/download-template.js +0 -2
- package/dist/utils/env-management.d.ts +0 -1
- package/dist/utils/env-management.js +0 -2
- package/dist/utils/format-env-suffix.d.ts +0 -1
- package/dist/utils/format-env-suffix.js +0 -2
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +0 -2
- package/dist/utils/fs-utils.d.ts +0 -1
- package/dist/utils/fs-utils.js +0 -2
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +0 -1
- package/dist/utils/handle-upgrade.js +0 -2
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +0 -1
- package/dist/utils/lambda-config.js +0 -2
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +0 -1
- package/dist/utils/messages.js +7 -2
- package/dist/utils/package-manager.d.ts +0 -1
- package/dist/utils/package-manager.js +0 -2
- package/dist/utils/parse-template-spec.d.ts +0 -1
- package/dist/utils/parse-template-spec.js +0 -2
- package/dist/utils/payload-config-ast.d.ts +0 -1
- package/dist/utils/payload-config-ast.js +0 -2
- package/dist/utils/payload-config-finder.d.ts +0 -1
- package/dist/utils/payload-config-finder.js +0 -2
- package/dist/utils/payload-config-modifier.d.ts +0 -1
- package/dist/utils/payload-config-modifier.js +0 -2
- package/dist/utils/payload-package-check.d.ts +0 -1
- package/dist/utils/payload-package-check.js +0 -2
- package/dist/utils/project.d.ts +0 -1
- package/dist/utils/project.js +0 -2
- package/dist/utils/resolve-environment.d.ts +0 -1
- package/dist/utils/resolve-environment.js +0 -2
- package/dist/utils/s3-upload.d.ts +0 -1
- package/dist/utils/s3-upload.js +0 -2
- package/dist/utils/token-display.d.ts +0 -1
- package/dist/utils/token-display.js +0 -2
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +0 -2
- package/dist/utils/version-check.d.ts +0 -1
- package/dist/utils/version-check.js +0 -2
- package/package.json +1 -1
package/dist/endpoints/health.js
CHANGED
package/dist/endpoints/schema.js
CHANGED
package/dist/exports/client.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
|
3
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
4
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
5
5
|
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
6
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/exports/client.js
CHANGED
|
@@ -3,5 +3,3 @@ export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
|
3
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
4
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
5
5
|
export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=client.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { figmaContentSystem } from './plugin/adapter.js';
|
|
|
3
3
|
export type { FigmaContentSystemOptions } from './plugin/adapter.js';
|
|
4
4
|
export { buildFigmaConfig } from './plugin/build-config.js';
|
|
5
5
|
export type { FigmaConfig } from './plugin/build-config.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,3 @@ export { contentAPIAdapter } from './db-content-api/index.js';
|
|
|
4
4
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
5
5
|
// Export buildConfig wrapper and its config type
|
|
6
6
|
export { buildFigmaConfig } from './plugin/build-config.js';
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useConfig } from '@payloadcms/ui';
|
|
4
|
-
import { useSearchParams } from 'next/navigation.js';
|
|
3
|
+
import { useConfig, useSearchParams } from '@payloadcms/ui';
|
|
5
4
|
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import { getSearchParam } from '../../utils/getSearchParam.js';
|
|
6
6
|
import { resolveParentTargetOrigin, setupIframeAutoLogin } from './iframeAutoLogin.js';
|
|
7
7
|
import './index.scss';
|
|
8
8
|
const baseClass = 'oauth-login';
|
|
@@ -55,7 +55,7 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
|
|
|
55
55
|
const [isInIframe, setIsInIframe] = useState(null);
|
|
56
56
|
const [autoLoginFailed, setAutoLoginFailed] = useState(false);
|
|
57
57
|
const searchParams = useSearchParams();
|
|
58
|
-
const payloadRedirect = searchParams
|
|
58
|
+
const payloadRedirect = getSearchParam(searchParams, 'redirect');
|
|
59
59
|
useEffect(()=>{
|
|
60
60
|
try {
|
|
61
61
|
setIsInIframe(window.self !== window.top);
|
|
@@ -188,5 +188,3 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
|
|
|
188
188
|
})
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
|
-
|
|
192
|
-
//# sourceMappingURL=index.js.map
|
package/dist/oauth/defaults.d.ts
CHANGED
package/dist/oauth/defaults.js
CHANGED
|
@@ -138,6 +138,14 @@ export const defaultVerify = ({ collection, strategyName, userInfoCookieName = D
|
|
|
138
138
|
user.collection = collection.slug;
|
|
139
139
|
user._strategy = strategyName;
|
|
140
140
|
user.exp = token.exp;
|
|
141
|
+
// userGroups/makePermission are virtual (never persisted). Surface the live
|
|
142
|
+
// JWT claims on the authenticated user for this request so access control
|
|
143
|
+
// and self-reads see current values. Claims are snake_case on the wire; the
|
|
144
|
+
// collection fields are camelCase. The field afterRead hooks
|
|
145
|
+
// (see build-config.ts) read these back off req.user.
|
|
146
|
+
const userWithFigmaClaims = user;
|
|
147
|
+
userWithFigmaClaims.userGroups = Array.isArray(token.user_groups) ? token.user_groups : undefined;
|
|
148
|
+
userWithFigmaClaims.makePermission = token.make_permission === 'edit' || token.make_permission === 'view' ? token.make_permission : undefined;
|
|
141
149
|
return {
|
|
142
150
|
responseHeaders,
|
|
143
151
|
user
|
|
@@ -148,5 +156,3 @@ export const defaultVerify = ({ collection, strategyName, userInfoCookieName = D
|
|
|
148
156
|
user: null
|
|
149
157
|
};
|
|
150
158
|
};
|
|
151
|
-
|
|
152
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -163,9 +163,8 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
163
163
|
strategy
|
|
164
164
|
});
|
|
165
165
|
debugLogger.info({
|
|
166
|
-
msg: '
|
|
167
|
-
path
|
|
168
|
-
tokenRes
|
|
166
|
+
msg: 'Received token response',
|
|
167
|
+
path
|
|
169
168
|
});
|
|
170
169
|
const { access_token, error, error_description, expires_in: refreshTokenExpires } = tokenRes;
|
|
171
170
|
if (error) {
|
|
@@ -180,8 +179,7 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
180
179
|
const errMsg = 'No access_token was returned from the identity provider.';
|
|
181
180
|
req.payload.logger.error({
|
|
182
181
|
msg: errMsg,
|
|
183
|
-
path
|
|
184
|
-
tokenRes
|
|
182
|
+
path
|
|
185
183
|
});
|
|
186
184
|
throw new APIError(errMsg);
|
|
187
185
|
}
|
|
@@ -206,8 +204,8 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
206
204
|
accessToken: access_token,
|
|
207
205
|
collection,
|
|
208
206
|
collectionOptions,
|
|
209
|
-
contentSystemId: config.custom.figma.contentSystemId,
|
|
210
207
|
debugLogger,
|
|
208
|
+
environmentId: config.custom.figma.environmentId,
|
|
211
209
|
pluginOptions,
|
|
212
210
|
refreshTokenExpiresIn: refreshTokenExpires,
|
|
213
211
|
req,
|
|
@@ -230,5 +228,3 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
230
228
|
method: collectionOptions.authorizationURLParams?.response_mode === 'query' ? 'get' : 'post',
|
|
231
229
|
path: `/${endpointSlug}/login`
|
|
232
230
|
});
|
|
233
|
-
|
|
234
|
-
//# sourceMappingURL=getLoginEndpoint.js.map
|
package/dist/oauth/hooks/me.d.ts
CHANGED
package/dist/oauth/hooks/me.js
CHANGED
package/dist/oauth/index.d.ts
CHANGED
package/dist/oauth/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as jose from 'jose';
|
|
2
2
|
import { APIError, parseCookies } from 'payload';
|
|
3
|
-
import { JWTValidationError,
|
|
3
|
+
import { JWTValidationError, validatePayloadAdminToken } from '../../auth/jwt-validator.js';
|
|
4
4
|
import { getInfraEnvironment } from '../../constants.js';
|
|
5
5
|
import { createDebugLogger } from '../utilities/createDebugLogger.js';
|
|
6
6
|
import { getTokenExp } from '../utilities/getTokenExp.js';
|
|
@@ -45,16 +45,15 @@ export class Strategy {
|
|
|
45
45
|
let oauthToken = cookies.get(this.cookieName);
|
|
46
46
|
const refreshToken = cookies.get(`${this.cookieName}-refresh`);
|
|
47
47
|
debugLogger.info({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
hasOauthToken: !!oauthToken,
|
|
49
|
+
hasRefreshToken: !!refreshToken,
|
|
50
|
+
msg: 'Retrieved tokens from cookies'
|
|
51
51
|
});
|
|
52
52
|
if (!this.collectionOptions.disableJWTFromHeader) {
|
|
53
53
|
// Parse Authorization header if exists
|
|
54
54
|
const jwtFromHeader = headers.get('authorization');
|
|
55
55
|
if (typeof jwtFromHeader === 'string' && jwtFromHeader.startsWith('Bearer ')) {
|
|
56
56
|
debugLogger.info({
|
|
57
|
-
jwtFromHeader,
|
|
58
57
|
msg: 'Found bearer token in authorization header'
|
|
59
58
|
});
|
|
60
59
|
oauthToken = jwtFromHeader.replace('Bearer ', '');
|
|
@@ -67,8 +66,7 @@ export class Strategy {
|
|
|
67
66
|
// full page load when canSetHeaders=true.
|
|
68
67
|
if (refreshToken) {
|
|
69
68
|
debugLogger.info({
|
|
70
|
-
msg: 'No access token found, but refresh token exists. Attempting to refresh...'
|
|
71
|
-
refreshToken
|
|
69
|
+
msg: 'No access token found, but refresh token exists. Attempting to refresh...'
|
|
72
70
|
});
|
|
73
71
|
const refreshed = await refreshTokens({
|
|
74
72
|
payload,
|
|
@@ -103,9 +101,7 @@ export class Strategy {
|
|
|
103
101
|
};
|
|
104
102
|
} else {
|
|
105
103
|
debugLogger.info({
|
|
106
|
-
msg: 'Token refresh failed'
|
|
107
|
-
refreshed,
|
|
108
|
-
refreshToken
|
|
104
|
+
msg: 'Token refresh failed'
|
|
109
105
|
});
|
|
110
106
|
}
|
|
111
107
|
}
|
|
@@ -156,9 +152,7 @@ export class Strategy {
|
|
|
156
152
|
strategy: this
|
|
157
153
|
});
|
|
158
154
|
debugLogger.info({
|
|
159
|
-
msg: 'Token expired. Refreshing...'
|
|
160
|
-
refreshed,
|
|
161
|
-
refreshToken
|
|
155
|
+
msg: 'Token expired. Refreshing...'
|
|
162
156
|
});
|
|
163
157
|
if (refreshed) {
|
|
164
158
|
const verifyResult = await this.verify({
|
|
@@ -185,9 +179,7 @@ export class Strategy {
|
|
|
185
179
|
};
|
|
186
180
|
} else {
|
|
187
181
|
debugLogger.info({
|
|
188
|
-
msg: 'Token refresh failed'
|
|
189
|
-
refreshed,
|
|
190
|
-
refreshToken
|
|
182
|
+
msg: 'Token refresh failed'
|
|
191
183
|
});
|
|
192
184
|
}
|
|
193
185
|
}
|
|
@@ -282,7 +274,15 @@ export class Strategy {
|
|
|
282
274
|
}
|
|
283
275
|
async jwtVerify({ payload, token }) {
|
|
284
276
|
try {
|
|
285
|
-
const
|
|
277
|
+
const audience = payload.config.custom.figma.environmentId;
|
|
278
|
+
if (!audience) {
|
|
279
|
+
throw new Error('Cannot validate token audience: environmentId is not configured');
|
|
280
|
+
}
|
|
281
|
+
const verified = await validatePayloadAdminToken({
|
|
282
|
+
audience,
|
|
283
|
+
environment: getInfraEnvironment(),
|
|
284
|
+
token
|
|
285
|
+
});
|
|
286
286
|
if (typeof verified !== 'string') {
|
|
287
287
|
return verified;
|
|
288
288
|
}
|
|
@@ -299,5 +299,3 @@ export class Strategy {
|
|
|
299
299
|
return null;
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
|
|
303
|
-
//# sourceMappingURL=index.js.map
|
package/dist/oauth/types.d.ts
CHANGED
package/dist/oauth/types.js
CHANGED
|
@@ -5,8 +5,8 @@ interface Args {
|
|
|
5
5
|
accessToken: string;
|
|
6
6
|
collection: CollectionConfig;
|
|
7
7
|
collectionOptions: CollectionOptions;
|
|
8
|
-
contentSystemId: string;
|
|
9
8
|
debugLogger: DebugLogger;
|
|
9
|
+
environmentId: string;
|
|
10
10
|
pluginOptions: PluginOptions;
|
|
11
11
|
/** From the IdP token response (`expires_in`); used as a refresh-cookie expiry fallback. */
|
|
12
12
|
refreshTokenExpiresIn?: number;
|
|
@@ -15,9 +15,8 @@ interface Args {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Given a valid OAuth access_token: fetch user info (non-fatal), mint a
|
|
18
|
-
*
|
|
19
|
-
* `req.responseHeaders`. Throws `APIError` if the
|
|
18
|
+
* Payload Admin token, and write the main + refresh + user-info cookies to
|
|
19
|
+
* `req.responseHeaders`. Throws `APIError` if the Admin token mint fails.
|
|
20
20
|
*/
|
|
21
|
-
export declare const establishSession: ({ accessToken, collection, collectionOptions,
|
|
21
|
+
export declare const establishSession: ({ accessToken, collection, collectionOptions, debugLogger, environmentId, pluginOptions, refreshTokenExpiresIn, req, strategy, }: Args) => Promise<void>;
|
|
22
22
|
export {};
|
|
23
|
-
//# sourceMappingURL=establishSession.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { APIError, generateCookie } from 'payload';
|
|
2
|
-
import {
|
|
2
|
+
import { getPayloadAdminToken, getUserInfo } from '../../api/figma-api.js';
|
|
3
3
|
import { createCookieOptions } from './createCookieOptions.js';
|
|
4
4
|
import { getCookieExpiration } from './getCookieExpiration.js';
|
|
5
5
|
import { withPartitionedCookie } from './withPartitionedCookie.js';
|
|
6
6
|
/**
|
|
7
7
|
* Given a valid OAuth access_token: fetch user info (non-fatal), mint a
|
|
8
|
-
*
|
|
9
|
-
* `req.responseHeaders`. Throws `APIError` if the
|
|
10
|
-
*/ export const establishSession = async ({ accessToken, collection, collectionOptions,
|
|
8
|
+
* Payload Admin token, and write the main + refresh + user-info cookies to
|
|
9
|
+
* `req.responseHeaders`. Throws `APIError` if the Admin token mint fails.
|
|
10
|
+
*/ export const establishSession = async ({ accessToken, collection, collectionOptions, debugLogger, environmentId, pluginOptions, refreshTokenExpiresIn, req, strategy })=>{
|
|
11
11
|
const oauthCredential = {
|
|
12
12
|
type: 'oauth',
|
|
13
13
|
token: accessToken
|
|
@@ -17,7 +17,6 @@ import { withPartitionedCookie } from './withPartitionedCookie.js';
|
|
|
17
17
|
try {
|
|
18
18
|
figmaUserInfo = await getUserInfo(oauthCredential);
|
|
19
19
|
debugLogger.info({
|
|
20
|
-
figmaUserInfo,
|
|
21
20
|
msg: 'Fetched Figma user info'
|
|
22
21
|
});
|
|
23
22
|
} catch (err) {
|
|
@@ -26,9 +25,9 @@ import { withPartitionedCookie } from './withPartitionedCookie.js';
|
|
|
26
25
|
msg: 'Failed to fetch Figma user info'
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
const errMsg = 'No
|
|
28
|
+
const adminToken = await getPayloadAdminToken(oauthCredential, environmentId);
|
|
29
|
+
if (!adminToken.token) {
|
|
30
|
+
const errMsg = 'No Payload Admin token returned from Figma API';
|
|
32
31
|
req.payload.logger.error({
|
|
33
32
|
msg: errMsg
|
|
34
33
|
});
|
|
@@ -54,13 +53,13 @@ import { withPartitionedCookie } from './withPartitionedCookie.js';
|
|
|
54
53
|
});
|
|
55
54
|
req.responseHeaders.append('Set-Cookie', withPartitionedCookie(refreshCookie));
|
|
56
55
|
}
|
|
57
|
-
const tokenExpires = cookieOptions?.expires ? getCookieExpiration(cookieOptions.expires) : new Date(
|
|
56
|
+
const tokenExpires = cookieOptions?.expires ? getCookieExpiration(cookieOptions.expires) : new Date(adminToken.expiresAt);
|
|
58
57
|
const tokenCookie = generateCookie({
|
|
59
58
|
...cookieOptions,
|
|
60
59
|
name: strategy.cookieName,
|
|
61
60
|
expires: tokenExpires,
|
|
62
61
|
returnCookieAsObject: false,
|
|
63
|
-
value:
|
|
62
|
+
value: adminToken.token
|
|
64
63
|
});
|
|
65
64
|
req.responseHeaders.append('Set-Cookie', withPartitionedCookie(tokenCookie));
|
|
66
65
|
// Short-lived handoff cookie consumed by defaultVerify on the next request.
|
|
@@ -79,5 +78,3 @@ import { withPartitionedCookie } from './withPartitionedCookie.js';
|
|
|
79
78
|
req.responseHeaders.append('Set-Cookie', withPartitionedCookie(userInfoCookie));
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=establishSession.js.map
|