@payloadcms/figma 0.0.1-alpha.1 → 0.0.1-alpha.10
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.map +1 -1
- package/dist/api/control-plane.js +2 -7
- package/dist/api/control-plane.js.map +1 -1
- package/dist/api/figma-api.js +3 -3
- package/dist/api/figma-api.js.map +1 -1
- package/dist/auth/jwt-validator.js.map +1 -1
- package/dist/auth/oauth-flow.d.ts.map +1 -1
- package/dist/auth/oauth-flow.js +3 -6
- package/dist/auth/oauth-flow.js.map +1 -1
- package/dist/auth/project-token.d.ts.map +1 -1
- package/dist/auth/project-token.js +1 -4
- package/dist/auth/project-token.js.map +1 -1
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +19 -28
- package/dist/auth/refresh.js.map +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.js +1 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +17 -10
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +21 -85
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list-tokens.d.ts +1 -1
- package/dist/commands/list-tokens.d.ts.map +1 -1
- package/dist/commands/list-tokens.js +6 -5
- package/dist/commands/list-tokens.js.map +1 -1
- package/dist/commands/login.d.ts +2 -11
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +4 -7
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/oauth/components/LoginButton/index.d.ts +9 -0
- package/dist/oauth/components/LoginButton/index.d.ts.map +1 -0
- package/dist/oauth/components/LoginButton/index.js +52 -0
- package/dist/oauth/components/LoginButton/index.js.map +1 -0
- package/dist/oauth/components/LoginButton/index.scss +10 -0
- package/dist/oauth/components/LogoutButton/index.d.ts +7 -0
- package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -0
- package/dist/oauth/components/LogoutButton/index.js +67 -0
- package/dist/oauth/components/LogoutButton/index.js.map +1 -0
- package/dist/oauth/components/LogoutButton/index.scss +10 -0
- package/dist/oauth/defaults.d.ts +10 -0
- package/dist/oauth/defaults.d.ts.map +1 -0
- package/dist/oauth/defaults.js +91 -0
- package/dist/oauth/defaults.js.map +1 -0
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +13 -0
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getLoginEndpoint.js +237 -0
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +12 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.js +99 -0
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -0
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +13 -0
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getMetaEndpoint.js +25 -0
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +1 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +13 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +1 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +21 -0
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +1 -0
- package/dist/oauth/exports/client.d.ts +3 -0
- package/dist/oauth/exports/client.d.ts.map +1 -0
- package/dist/oauth/exports/client.js +4 -0
- package/dist/oauth/exports/client.js.map +1 -0
- package/dist/oauth/hooks/afterLogout.d.ts +8 -0
- package/dist/oauth/hooks/afterLogout.d.ts.map +1 -0
- package/dist/oauth/hooks/afterLogout.js +27 -0
- package/dist/oauth/hooks/afterLogout.js.map +1 -0
- package/dist/oauth/hooks/me.d.ts +5 -0
- package/dist/oauth/hooks/me.d.ts.map +1 -0
- package/dist/oauth/hooks/me.js +55 -0
- package/dist/oauth/hooks/me.js.map +1 -0
- package/dist/oauth/hooks/refresh.d.ts +8 -0
- package/dist/oauth/hooks/refresh.d.ts.map +1 -0
- package/dist/oauth/hooks/refresh.js +91 -0
- package/dist/oauth/hooks/refresh.js.map +1 -0
- package/dist/oauth/index.d.ts +4 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +222 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/strategy/index.d.ts +54 -0
- package/dist/oauth/strategy/index.d.ts.map +1 -0
- package/dist/oauth/strategy/index.js +280 -0
- package/dist/oauth/strategy/index.js.map +1 -0
- package/dist/oauth/types.d.ts +192 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +3 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/oauth/utilities/clearCookie.d.ts +9 -0
- package/dist/oauth/utilities/clearCookie.d.ts.map +1 -0
- package/dist/oauth/utilities/clearCookie.js +21 -0
- package/dist/oauth/utilities/clearCookie.js.map +1 -0
- package/dist/oauth/utilities/createCookieOptions.d.ts +10 -0
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -0
- package/dist/oauth/utilities/createCookieOptions.js +42 -0
- package/dist/oauth/utilities/createCookieOptions.js.map +1 -0
- package/dist/oauth/utilities/createDebugLogger.d.ts +4 -0
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +1 -0
- package/dist/oauth/utilities/createDebugLogger.js +16 -0
- package/dist/oauth/utilities/createDebugLogger.js.map +1 -0
- package/dist/oauth/utilities/extractOrigin.d.ts +2 -0
- package/dist/oauth/utilities/extractOrigin.d.ts.map +1 -0
- package/dist/oauth/utilities/extractOrigin.js +12 -0
- package/dist/oauth/utilities/extractOrigin.js.map +1 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +3 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +1 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.js +18 -0
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +1 -0
- package/dist/oauth/utilities/getAdminPath.d.ts +8 -0
- package/dist/oauth/utilities/getAdminPath.d.ts.map +1 -0
- package/dist/oauth/utilities/getAdminPath.js +9 -0
- package/dist/oauth/utilities/getAdminPath.js.map +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +17 -0
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +45 -0
- package/dist/oauth/utilities/getAuthorizeURL.js.map +1 -0
- package/dist/oauth/utilities/getCookieExpiration.d.ts +4 -0
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +1 -0
- package/dist/oauth/utilities/getCookieExpiration.js +11 -0
- package/dist/oauth/utilities/getCookieExpiration.js.map +1 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +2 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +1 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +7 -0
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +1 -0
- package/dist/oauth/utilities/getTokenExp.d.ts +6 -0
- package/dist/oauth/utilities/getTokenExp.d.ts.map +1 -0
- package/dist/oauth/utilities/getTokenExp.js +20 -0
- package/dist/oauth/utilities/getTokenExp.js.map +1 -0
- package/dist/oauth/utilities/getUsernameField.d.ts +9 -0
- package/dist/oauth/utilities/getUsernameField.d.ts.map +1 -0
- package/dist/oauth/utilities/getUsernameField.js +20 -0
- package/dist/oauth/utilities/getUsernameField.js.map +1 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +8 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +1 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +25 -0
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +1 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts +2 -0
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +1 -0
- package/dist/oauth/utilities/mergeHeaders.js +37 -0
- package/dist/oauth/utilities/mergeHeaders.js.map +1 -0
- package/dist/oauth/utilities/refreshTokens.d.ts +16 -0
- package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -0
- package/dist/oauth/utilities/refreshTokens.js +67 -0
- package/dist/oauth/utilities/refreshTokens.js.map +1 -0
- package/dist/plugin/build-config.d.ts +7 -1
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +29 -2
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/types/config.d.ts +0 -11
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/utils/config.d.ts +0 -22
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +0 -46
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/messages.js +11 -11
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/payload-config-ast.d.ts +17 -1
- package/dist/utils/payload-config-ast.d.ts.map +1 -1
- package/dist/utils/payload-config-ast.js +166 -14
- package/dist/utils/payload-config-ast.js.map +1 -1
- package/dist/utils/payload-config-modifier.d.ts +2 -1
- package/dist/utils/payload-config-modifier.d.ts.map +1 -1
- package/dist/utils/payload-config-modifier.js +50 -79
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/payload-package-check.d.ts.map +1 -1
- package/dist/utils/payload-package-check.js +14 -33
- package/dist/utils/payload-package-check.js.map +1 -1
- package/dist/utils/project.d.ts +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +3 -5
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/s3-upload.d.ts.map +1 -1
- package/dist/utils/s3-upload.js +3 -8
- package/dist/utils/s3-upload.js.map +1 -1
- package/dist/utils/token-display.d.ts.map +1 -1
- package/dist/utils/token-display.js +3 -2
- package/dist/utils/token-display.js.map +1 -1
- package/package.json +9 -3
- package/dist/api/control-plane.spec.d.ts +0 -2
- package/dist/api/control-plane.spec.d.ts.map +0 -1
- package/dist/api/control-plane.spec.js +0 -296
- package/dist/api/control-plane.spec.js.map +0 -1
- package/dist/api/figma-api.spec.d.ts +0 -14
- package/dist/api/figma-api.spec.d.ts.map +0 -1
- package/dist/api/figma-api.spec.js +0 -201
- package/dist/api/figma-api.spec.js.map +0 -1
- package/dist/auth/__tests__/fixtures.d.ts +0 -26
- package/dist/auth/__tests__/fixtures.d.ts.map +0 -1
- package/dist/auth/__tests__/fixtures.js +0 -67
- package/dist/auth/__tests__/fixtures.js.map +0 -1
- package/dist/auth/__tests__/mocks.d.ts +0 -33
- package/dist/auth/__tests__/mocks.d.ts.map +0 -1
- package/dist/auth/__tests__/mocks.js +0 -63
- package/dist/auth/__tests__/mocks.js.map +0 -1
- package/dist/auth/callback-server.spec.d.ts +0 -2
- package/dist/auth/callback-server.spec.d.ts.map +0 -1
- package/dist/auth/callback-server.spec.js +0 -85
- package/dist/auth/callback-server.spec.js.map +0 -1
- package/dist/auth/crypto-utils.spec.d.ts +0 -2
- package/dist/auth/crypto-utils.spec.d.ts.map +0 -1
- package/dist/auth/crypto-utils.spec.js +0 -36
- package/dist/auth/crypto-utils.spec.js.map +0 -1
- package/dist/auth/jwt-validator.spec.d.ts +0 -10
- package/dist/auth/jwt-validator.spec.d.ts.map +0 -1
- package/dist/auth/jwt-validator.spec.js +0 -236
- package/dist/auth/jwt-validator.spec.js.map +0 -1
- package/dist/auth/oauth-flow.spec.d.ts +0 -2
- package/dist/auth/oauth-flow.spec.d.ts.map +0 -1
- package/dist/auth/oauth-flow.spec.js +0 -134
- package/dist/auth/oauth-flow.spec.js.map +0 -1
- package/dist/auth/pkce.spec.d.ts +0 -2
- package/dist/auth/pkce.spec.d.ts.map +0 -1
- package/dist/auth/pkce.spec.js +0 -32
- package/dist/auth/pkce.spec.js.map +0 -1
- package/dist/auth/project-token.spec.d.ts +0 -2
- package/dist/auth/project-token.spec.d.ts.map +0 -1
- package/dist/auth/project-token.spec.js +0 -332
- package/dist/auth/project-token.spec.js.map +0 -1
- package/dist/auth/refresh.spec.d.ts +0 -2
- package/dist/auth/refresh.spec.d.ts.map +0 -1
- package/dist/auth/refresh.spec.js +0 -105
- package/dist/auth/refresh.spec.js.map +0 -1
- package/dist/auth/token-store.spec.d.ts +0 -2
- package/dist/auth/token-store.spec.d.ts.map +0 -1
- package/dist/auth/token-store.spec.js +0 -276
- package/dist/auth/token-store.spec.js.map +0 -1
- package/dist/commands/__tests__/test-utils.d.ts +0 -28
- package/dist/commands/__tests__/test-utils.d.ts.map +0 -1
- package/dist/commands/__tests__/test-utils.js +0 -34
- package/dist/commands/__tests__/test-utils.js.map +0 -1
- package/dist/commands/deploy.spec.d.ts +0 -2
- package/dist/commands/deploy.spec.d.ts.map +0 -1
- package/dist/commands/deploy.spec.js +0 -18
- package/dist/commands/deploy.spec.js.map +0 -1
- package/dist/commands/init.spec.d.ts +0 -2
- package/dist/commands/init.spec.d.ts.map +0 -1
- package/dist/commands/init.spec.js +0 -283
- package/dist/commands/init.spec.js.map +0 -1
- package/dist/plugin/build-config.spec.d.ts +0 -2
- package/dist/plugin/build-config.spec.d.ts.map +0 -1
- package/dist/plugin/build-config.spec.js +0 -72
- package/dist/plugin/build-config.spec.js.map +0 -1
- package/dist/utils/asset-collection.spec.d.ts +0 -2
- package/dist/utils/asset-collection.spec.d.ts.map +0 -1
- package/dist/utils/asset-collection.spec.js +0 -155
- package/dist/utils/asset-collection.spec.js.map +0 -1
- package/dist/utils/build-detection.spec.d.ts +0 -2
- package/dist/utils/build-detection.spec.d.ts.map +0 -1
- package/dist/utils/build-detection.spec.js +0 -110
- package/dist/utils/build-detection.spec.js.map +0 -1
- package/dist/utils/config.spec.d.ts +0 -2
- package/dist/utils/config.spec.d.ts.map +0 -1
- package/dist/utils/config.spec.js +0 -167
- package/dist/utils/config.spec.js.map +0 -1
- package/dist/utils/download-template.spec.d.ts +0 -2
- package/dist/utils/download-template.spec.d.ts.map +0 -1
- package/dist/utils/download-template.spec.js +0 -76
- package/dist/utils/download-template.spec.js.map +0 -1
- package/dist/utils/env-management.spec.d.ts +0 -2
- package/dist/utils/env-management.spec.d.ts.map +0 -1
- package/dist/utils/env-management.spec.js +0 -123
- package/dist/utils/env-management.spec.js.map +0 -1
- package/dist/utils/git.spec.d.ts +0 -2
- package/dist/utils/git.spec.d.ts.map +0 -1
- package/dist/utils/git.spec.js +0 -99
- package/dist/utils/git.spec.js.map +0 -1
- package/dist/utils/lambda-config.spec.d.ts +0 -2
- package/dist/utils/lambda-config.spec.d.ts.map +0 -1
- package/dist/utils/lambda-config.spec.js +0 -141
- package/dist/utils/lambda-config.spec.js.map +0 -1
- package/dist/utils/payload-config-ast.spec.d.ts +0 -2
- package/dist/utils/payload-config-ast.spec.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.spec.js +0 -303
- package/dist/utils/payload-config-ast.spec.js.map +0 -1
- package/dist/utils/payload-config-modifier.int.spec.d.ts +0 -2
- package/dist/utils/payload-config-modifier.int.spec.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.int.spec.js +0 -116
- package/dist/utils/payload-config-modifier.int.spec.js.map +0 -1
- package/dist/utils/payload-config-modifier.spec.d.ts +0 -2
- package/dist/utils/payload-config-modifier.spec.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.spec.js +0 -162
- package/dist/utils/payload-config-modifier.spec.js.map +0 -1
- package/dist/utils/payload-package-check.spec.d.ts +0 -2
- package/dist/utils/payload-package-check.spec.d.ts.map +0 -1
- package/dist/utils/payload-package-check.spec.js +0 -148
- package/dist/utils/payload-package-check.spec.js.map +0 -1
- package/dist/utils/project.spec.d.ts +0 -2
- package/dist/utils/project.spec.d.ts.map +0 -1
- package/dist/utils/project.spec.js +0 -222
- package/dist/utils/project.spec.js.map +0 -1
- package/dist/utils/s3-upload.spec.d.ts +0 -2
- package/dist/utils/s3-upload.spec.d.ts.map +0 -1
- package/dist/utils/s3-upload.spec.js +0 -140
- package/dist/utils/s3-upload.spec.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const createDebugLogger = (payload, condition)=>{
|
|
2
|
+
return {
|
|
3
|
+
error: (args)=>{
|
|
4
|
+
if (condition) {
|
|
5
|
+
payload.logger.error(args);
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
info: (args)=>{
|
|
9
|
+
if (condition) {
|
|
10
|
+
payload.logger.info(args);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=createDebugLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/createDebugLogger.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport type { DebugLogger } from '../types.js'\n\nexport const createDebugLogger = (payload: Payload, condition?: boolean): DebugLogger => {\n return {\n error: (args: unknown) => {\n if (condition) {\n payload.logger.error(args)\n }\n },\n info: (args: unknown) => {\n if (condition) {\n payload.logger.info(args)\n }\n },\n }\n}\n"],"names":["createDebugLogger","payload","condition","error","args","logger","info"],"mappings":"AAIA,OAAO,MAAMA,oBAAoB,CAACC,SAAkBC;IAClD,OAAO;QACLC,OAAO,CAACC;YACN,IAAIF,WAAW;gBACbD,QAAQI,MAAM,CAACF,KAAK,CAACC;YACvB;QACF;QACAE,MAAM,CAACF;YACL,IAAIF,WAAW;gBACbD,QAAQI,MAAM,CAACC,IAAI,CAACF;YACtB;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractOrigin.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/extractOrigin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,IAAI,GAAG,MAOlD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const extractOrigin = (url)=>{
|
|
2
|
+
try {
|
|
3
|
+
const parsed = new URL(url);
|
|
4
|
+
return parsed.origin // includes protocol, hostname, and port if present
|
|
5
|
+
;
|
|
6
|
+
} catch {
|
|
7
|
+
return null // invalid URL
|
|
8
|
+
;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=extractOrigin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/extractOrigin.ts"],"sourcesContent":["export const extractOrigin = (url: string): null | string => {\n try {\n const parsed = new URL(url)\n return parsed.origin // includes protocol, hostname, and port if present\n } catch {\n return null // invalid URL\n }\n}\n"],"names":["extractOrigin","url","parsed","URL","origin"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,CAACC;IAC5B,IAAI;QACF,MAAMC,SAAS,IAAIC,IAAIF;QACvB,OAAOC,OAAOE,MAAM,CAAC,mDAAmD;;IAC1E,EAAE,OAAM;QACN,OAAO,KAAK,cAAc;;IAC5B;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAdminCollectionSlug.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getAdminCollectionSlug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,sBAAsB,WAAY,MAAM,KAAG,MAmBvD,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const getAdminCollectionSlug = (config)=>{
|
|
2
|
+
// if config specifies admin user collection, find and use it
|
|
3
|
+
if (config.admin?.user) {
|
|
4
|
+
const matchedAdminCollection = config.collections?.find((collection)=>config.admin?.user === collection.slug);
|
|
5
|
+
if (matchedAdminCollection) {
|
|
6
|
+
return matchedAdminCollection.slug;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
// if config does not specify admin user collection, find first collection with auth
|
|
10
|
+
const firstCollectionWithAuth = config.collections?.find(({ auth })=>Boolean(auth));
|
|
11
|
+
if (firstCollectionWithAuth) {
|
|
12
|
+
return firstCollectionWithAuth.slug;
|
|
13
|
+
}
|
|
14
|
+
// Otherwise, assume that it'll be the built-in auth
|
|
15
|
+
return 'users';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=getAdminCollectionSlug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getAdminCollectionSlug.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nexport const getAdminCollectionSlug = (config: Config): string => {\n // if config specifies admin user collection, find and use it\n if (config.admin?.user) {\n const matchedAdminCollection = config.collections?.find(\n (collection) => config.admin?.user === collection.slug,\n )\n if (matchedAdminCollection) {\n return matchedAdminCollection.slug\n }\n }\n\n // if config does not specify admin user collection, find first collection with auth\n const firstCollectionWithAuth = config.collections?.find(({ auth }) => Boolean(auth))\n if (firstCollectionWithAuth) {\n return firstCollectionWithAuth.slug\n }\n\n // Otherwise, assume that it'll be the built-in auth\n return 'users'\n}\n"],"names":["getAdminCollectionSlug","config","admin","user","matchedAdminCollection","collections","find","collection","slug","firstCollectionWithAuth","auth","Boolean"],"mappings":"AAEA,OAAO,MAAMA,yBAAyB,CAACC;IACrC,6DAA6D;IAC7D,IAAIA,OAAOC,KAAK,EAAEC,MAAM;QACtB,MAAMC,yBAAyBH,OAAOI,WAAW,EAAEC,KACjD,CAACC,aAAeN,OAAOC,KAAK,EAAEC,SAASI,WAAWC,IAAI;QAExD,IAAIJ,wBAAwB;YAC1B,OAAOA,uBAAuBI,IAAI;QACpC;IACF;IAEA,oFAAoF;IACpF,MAAMC,0BAA0BR,OAAOI,WAAW,EAAEC,KAAK,CAAC,EAAEI,IAAI,EAAE,GAAKC,QAAQD;IAC/E,IAAID,yBAAyB;QAC3B,OAAOA,wBAAwBD,IAAI;IACrC;IAEA,oDAAoD;IACpD,OAAO;AACT,EAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ClientConfig, SanitizedConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* This is the path to the admin panel WITHOUT domain.
|
|
4
|
+
*
|
|
5
|
+
* This respects the `basePath` property in the Next config.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getAdminPath: (config: ClientConfig | SanitizedConfig) => string;
|
|
8
|
+
//# sourceMappingURL=getAdminPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAdminPath.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getAdminPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,WAAY,YAAY,GAAG,eAAe,WAElE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the path to the admin panel WITHOUT domain.
|
|
3
|
+
*
|
|
4
|
+
* This respects the `basePath` property in the Next config.
|
|
5
|
+
*/ export const getAdminPath = (config)=>{
|
|
6
|
+
return `${process.env.NEXT_BASE_PATH ?? ''}${config.routes?.admin || '/admin'}`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=getAdminPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getAdminPath.ts"],"sourcesContent":["import type { ClientConfig, SanitizedConfig } from 'payload'\n\n/**\n * This is the path to the admin panel WITHOUT domain.\n *\n * This respects the `basePath` property in the Next config.\n */\nexport const getAdminPath = (config: ClientConfig | SanitizedConfig) => {\n return `${process.env.NEXT_BASE_PATH ?? ''}${config.routes?.admin || '/admin'}`\n}\n"],"names":["getAdminPath","config","process","env","NEXT_BASE_PATH","routes","admin"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,eAAe,CAACC;IAC3B,OAAO,GAAGC,QAAQC,GAAG,CAACC,cAAc,IAAI,KAAKH,OAAOI,MAAM,EAAEC,SAAS,UAAU;AACjF,EAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CollectionConfig, Payload } from 'payload';
|
|
2
|
+
import type { Strategy } from '../strategy/index.js';
|
|
3
|
+
import type { CollectionOptions, PluginOptions } from '../types.js';
|
|
4
|
+
interface Args {
|
|
5
|
+
collection: CollectionConfig;
|
|
6
|
+
collectionOptions: CollectionOptions;
|
|
7
|
+
endpointSlug: string;
|
|
8
|
+
failedRedirect?: unknown;
|
|
9
|
+
payload: Payload;
|
|
10
|
+
pluginOptions: PluginOptions;
|
|
11
|
+
redirect?: unknown;
|
|
12
|
+
serverURLOverride?: unknown;
|
|
13
|
+
strategy: Strategy;
|
|
14
|
+
}
|
|
15
|
+
export declare const getAuthorizeURL: ({ collection, collectionOptions, endpointSlug, failedRedirect, payload, pluginOptions, redirect, serverURLOverride, strategy, }: Args) => Promise<string>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=getAuthorizeURL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAuthorizeURL.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getAuthorizeURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAY,MAAM,aAAa,CAAA;AAI7E,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,eAAO,MAAM,eAAe,oIAUzB,IAAI,KAAG,OAAO,CAAC,MAAM,CAoDvB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import * as QueryString from 'qs-esm';
|
|
3
|
+
import { v4 as uuid } from 'uuid';
|
|
4
|
+
import { defaultScope } from '../defaults.js';
|
|
5
|
+
export const getAuthorizeURL = async ({ collection, collectionOptions, endpointSlug, failedRedirect, payload, pluginOptions, redirect, serverURLOverride, strategy })=>{
|
|
6
|
+
const { redirectServerURL } = pluginOptions;
|
|
7
|
+
await strategy.ensureMeta();
|
|
8
|
+
// Generate a random code verifier
|
|
9
|
+
const codeVerifier = crypto.randomBytes(32).toString('base64url');
|
|
10
|
+
// Create a code challenge by hashing the code verifier
|
|
11
|
+
const code_challenge = crypto.createHash('sha256').update(codeVerifier).digest('base64url');
|
|
12
|
+
const state = {
|
|
13
|
+
sig: payload.encrypt(strategy.name),
|
|
14
|
+
verifier: payload.encrypt(codeVerifier)
|
|
15
|
+
};
|
|
16
|
+
if (typeof serverURLOverride === 'string') {
|
|
17
|
+
state.serverURL = serverURLOverride;
|
|
18
|
+
}
|
|
19
|
+
if (typeof redirect === 'string') {
|
|
20
|
+
state.redirect = redirect;
|
|
21
|
+
}
|
|
22
|
+
if (typeof failedRedirect === 'string') {
|
|
23
|
+
state.failedRedirect = failedRedirect;
|
|
24
|
+
}
|
|
25
|
+
const baseRedirectURL = redirectServerURL || payload.config.serverURL || state.serverURL;
|
|
26
|
+
const loginRedirectURL = encodeURI(`${baseRedirectURL}${payload.config.routes?.api || '/api'}/${collection.slug}/${endpointSlug}/login`);
|
|
27
|
+
const params = {
|
|
28
|
+
client_id: collectionOptions.clientID,
|
|
29
|
+
code_challenge,
|
|
30
|
+
code_challenge_method: 'S256',
|
|
31
|
+
nonce: uuid(),
|
|
32
|
+
redirect_uri: loginRedirectURL,
|
|
33
|
+
response_mode: 'form_post',
|
|
34
|
+
response_type: 'id_token%20token%20code',
|
|
35
|
+
scope: (collectionOptions.scope ?? defaultScope).join('+'),
|
|
36
|
+
state: Buffer.from(JSON.stringify(state)).toString('base64'),
|
|
37
|
+
...collectionOptions.authorizationURLParams || {}
|
|
38
|
+
};
|
|
39
|
+
const authorizeURL = `${strategy.meta?.authorization_endpoint}?${QueryString.stringify(params, {
|
|
40
|
+
encode: false
|
|
41
|
+
})}`;
|
|
42
|
+
return authorizeURL;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=getAuthorizeURL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getAuthorizeURL.ts"],"sourcesContent":["import type { CollectionConfig, Payload } from 'payload'\n\nimport crypto from 'crypto'\nimport * as QueryString from 'qs-esm'\nimport { v4 as uuid } from 'uuid'\n\nimport type { Strategy } from '../strategy/index.js'\nimport type { CollectionOptions, PluginOptions, StateObj } from '../types.js'\n\nimport { defaultScope } from '../defaults.js'\n\ninterface Args {\n collection: CollectionConfig\n collectionOptions: CollectionOptions\n endpointSlug: string\n failedRedirect?: unknown\n payload: Payload\n pluginOptions: PluginOptions\n redirect?: unknown\n serverURLOverride?: unknown\n strategy: Strategy\n}\n\nexport const getAuthorizeURL = async ({\n collection,\n collectionOptions,\n endpointSlug,\n failedRedirect,\n payload,\n pluginOptions,\n redirect,\n serverURLOverride,\n strategy,\n}: Args): Promise<string> => {\n const { redirectServerURL } = pluginOptions\n\n await strategy.ensureMeta()\n\n // Generate a random code verifier\n const codeVerifier = crypto.randomBytes(32).toString('base64url')\n\n // Create a code challenge by hashing the code verifier\n const code_challenge = crypto.createHash('sha256').update(codeVerifier).digest('base64url')\n\n const state: StateObj = {\n sig: payload.encrypt(strategy.name),\n verifier: payload.encrypt(codeVerifier),\n }\n\n if (typeof serverURLOverride === 'string') {\n state.serverURL = serverURLOverride\n }\n\n if (typeof redirect === 'string') {\n state.redirect = redirect\n }\n\n if (typeof failedRedirect === 'string') {\n state.failedRedirect = failedRedirect\n }\n\n const baseRedirectURL = redirectServerURL || payload.config.serverURL || state.serverURL\n\n const loginRedirectURL = encodeURI(\n `${baseRedirectURL}${payload.config.routes?.api || '/api'}/${collection.slug}/${endpointSlug}/login`,\n )\n\n const params = {\n client_id: collectionOptions.clientID,\n code_challenge,\n code_challenge_method: 'S256',\n nonce: uuid(),\n redirect_uri: loginRedirectURL,\n response_mode: 'form_post',\n response_type: 'id_token%20token%20code',\n scope: (collectionOptions.scope ?? defaultScope).join('+'),\n state: Buffer.from(JSON.stringify(state)).toString('base64'),\n ...(collectionOptions.authorizationURLParams || {}),\n }\n\n const authorizeURL = `${strategy.meta?.authorization_endpoint}?${QueryString.stringify(params, {\n encode: false,\n })}`\n\n return authorizeURL\n}\n"],"names":["crypto","QueryString","v4","uuid","defaultScope","getAuthorizeURL","collection","collectionOptions","endpointSlug","failedRedirect","payload","pluginOptions","redirect","serverURLOverride","strategy","redirectServerURL","ensureMeta","codeVerifier","randomBytes","toString","code_challenge","createHash","update","digest","state","sig","encrypt","name","verifier","serverURL","baseRedirectURL","config","loginRedirectURL","encodeURI","routes","api","slug","params","client_id","clientID","code_challenge_method","nonce","redirect_uri","response_mode","response_type","scope","join","Buffer","from","JSON","stringify","authorizationURLParams","authorizeURL","meta","authorization_endpoint","encode"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAC3B,YAAYC,iBAAiB,SAAQ;AACrC,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAKjC,SAASC,YAAY,QAAQ,iBAAgB;AAc7C,OAAO,MAAMC,kBAAkB,OAAO,EACpCC,UAAU,EACVC,iBAAiB,EACjBC,YAAY,EACZC,cAAc,EACdC,OAAO,EACPC,aAAa,EACbC,QAAQ,EACRC,iBAAiB,EACjBC,QAAQ,EACH;IACL,MAAM,EAAEC,iBAAiB,EAAE,GAAGJ;IAE9B,MAAMG,SAASE,UAAU;IAEzB,kCAAkC;IAClC,MAAMC,eAAejB,OAAOkB,WAAW,CAAC,IAAIC,QAAQ,CAAC;IAErD,uDAAuD;IACvD,MAAMC,iBAAiBpB,OAAOqB,UAAU,CAAC,UAAUC,MAAM,CAACL,cAAcM,MAAM,CAAC;IAE/E,MAAMC,QAAkB;QACtBC,KAAKf,QAAQgB,OAAO,CAACZ,SAASa,IAAI;QAClCC,UAAUlB,QAAQgB,OAAO,CAACT;IAC5B;IAEA,IAAI,OAAOJ,sBAAsB,UAAU;QACzCW,MAAMK,SAAS,GAAGhB;IACpB;IAEA,IAAI,OAAOD,aAAa,UAAU;QAChCY,MAAMZ,QAAQ,GAAGA;IACnB;IAEA,IAAI,OAAOH,mBAAmB,UAAU;QACtCe,MAAMf,cAAc,GAAGA;IACzB;IAEA,MAAMqB,kBAAkBf,qBAAqBL,QAAQqB,MAAM,CAACF,SAAS,IAAIL,MAAMK,SAAS;IAExF,MAAMG,mBAAmBC,UACvB,GAAGH,kBAAkBpB,QAAQqB,MAAM,CAACG,MAAM,EAAEC,OAAO,OAAO,CAAC,EAAE7B,WAAW8B,IAAI,CAAC,CAAC,EAAE5B,aAAa,MAAM,CAAC;IAGtG,MAAM6B,SAAS;QACbC,WAAW/B,kBAAkBgC,QAAQ;QACrCnB;QACAoB,uBAAuB;QACvBC,OAAOtC;QACPuC,cAAcV;QACdW,eAAe;QACfC,eAAe;QACfC,OAAO,AAACtC,CAAAA,kBAAkBsC,KAAK,IAAIzC,YAAW,EAAG0C,IAAI,CAAC;QACtDtB,OAAOuB,OAAOC,IAAI,CAACC,KAAKC,SAAS,CAAC1B,QAAQL,QAAQ,CAAC;QACnD,GAAIZ,kBAAkB4C,sBAAsB,IAAI,CAAC,CAAC;IACpD;IAEA,MAAMC,eAAe,GAAGtC,SAASuC,IAAI,EAAEC,uBAAuB,CAAC,EAAErD,YAAYiD,SAAS,CAACb,QAAQ;QAC7FkB,QAAQ;IACV,IAAI;IAEJ,OAAOH;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCookieExpiration.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getCookieExpiration.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;AAEvD,eAAO,MAAM,mBAAmB,aAAc,aAAa,KAAG,IAS7D,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const getCookieExpiration = (expires)=>{
|
|
2
|
+
if (expires instanceof Date) {
|
|
3
|
+
return expires;
|
|
4
|
+
}
|
|
5
|
+
const seconds = typeof expires === 'number' ? expires : 7200;
|
|
6
|
+
const currentTime = new Date();
|
|
7
|
+
currentTime.setSeconds(currentTime.getSeconds() + seconds);
|
|
8
|
+
return currentTime;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=getCookieExpiration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getCookieExpiration.ts"],"sourcesContent":["type CookieExpires = Date | number | string | undefined\n\nexport const getCookieExpiration = (expires?: CookieExpires): Date => {\n if (expires instanceof Date) {\n return expires\n }\n\n const seconds = typeof expires === 'number' ? expires : 7200\n const currentTime = new Date()\n currentTime.setSeconds(currentTime.getSeconds() + seconds)\n return currentTime\n}\n"],"names":["getCookieExpiration","expires","Date","seconds","currentTime","setSeconds","getSeconds"],"mappings":"AAEA,OAAO,MAAMA,sBAAsB,CAACC;IAClC,IAAIA,mBAAmBC,MAAM;QAC3B,OAAOD;IACT;IAEA,MAAME,UAAU,OAAOF,YAAY,WAAWA,UAAU;IACxD,MAAMG,cAAc,IAAIF;IACxBE,YAAYC,UAAU,CAACD,YAAYE,UAAU,KAAKH;IAClD,OAAOC;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSecondsFromTokenExp.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getSecondsFromTokenExp.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAG1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getSecondsFromTokenExp.ts"],"sourcesContent":["export function getSecondsFromTokenExp(futureUnixTimestamp: number): number {\n const now = Math.floor(Date.now() / 1000) // current time in seconds\n return futureUnixTimestamp - now\n}\n"],"names":["getSecondsFromTokenExp","futureUnixTimestamp","now","Math","floor","Date"],"mappings":"AAAA,OAAO,SAASA,uBAAuBC,mBAA2B;IAChE,MAAMC,MAAMC,KAAKC,KAAK,CAACC,KAAKH,GAAG,KAAK,MAAM,0BAA0B;;IACpE,OAAOD,sBAAsBC;AAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTokenExp.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getTokenExp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,eAAO,MAAM,WAAW,4BAGrB;IACD,WAAW,EAAE,WAAW,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,KAAG,MAAM,GAAG,SAwBZ,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import jwt from 'jsonwebtoken';
|
|
2
|
+
export const getTokenExp = ({ debugLogger, token })=>{
|
|
3
|
+
if (!token) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
const decoded = jwt.decode(token);
|
|
8
|
+
if (decoded && typeof decoded === 'object' && 'exp' in decoded && typeof decoded.exp === 'number') {
|
|
9
|
+
return decoded.exp;
|
|
10
|
+
}
|
|
11
|
+
} catch (err) {
|
|
12
|
+
debugLogger.error({
|
|
13
|
+
err,
|
|
14
|
+
msg: 'Error decoding token in getTokenExp'
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=getTokenExp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getTokenExp.ts"],"sourcesContent":["import jwt from 'jsonwebtoken'\n\nimport type { DebugLogger } from '../types.js'\n\nexport const getTokenExp = ({\n debugLogger,\n token,\n}: {\n debugLogger: DebugLogger\n token: string\n}): number | undefined => {\n if (!token) {\n return undefined\n }\n\n try {\n const decoded = jwt.decode(token)\n\n if (\n decoded &&\n typeof decoded === 'object' &&\n 'exp' in decoded &&\n typeof decoded.exp === 'number'\n ) {\n return decoded.exp\n }\n } catch (err: unknown) {\n debugLogger.error({\n err,\n msg: 'Error decoding token in getTokenExp',\n })\n }\n\n return undefined\n}\n"],"names":["jwt","getTokenExp","debugLogger","token","undefined","decoded","decode","exp","err","error","msg"],"mappings":"AAAA,OAAOA,SAAS,eAAc;AAI9B,OAAO,MAAMC,cAAc,CAAC,EAC1BC,WAAW,EACXC,KAAK,EAIN;IACC,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IAEA,IAAI;QACF,MAAMC,UAAUL,IAAIM,MAAM,CAACH;QAE3B,IACEE,WACA,OAAOA,YAAY,YACnB,SAASA,WACT,OAAOA,QAAQE,GAAG,KAAK,UACvB;YACA,OAAOF,QAAQE,GAAG;QACpB;IACF,EAAE,OAAOC,KAAc;QACrBN,YAAYO,KAAK,CAAC;YAChBD;YACAE,KAAK;QACP;IACF;IAEA,OAAON;AACT,EAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CollectionConfig, EmailField, TextField } from 'payload';
|
|
2
|
+
import type { CollectionOptions } from '../types.js';
|
|
3
|
+
interface Args {
|
|
4
|
+
collection: CollectionConfig;
|
|
5
|
+
collectionOptions: CollectionOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare const getUsernameField: ({ collection, collectionOptions, }: Args) => EmailField | TextField;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=getUsernameField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUsernameField.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/getUsernameField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAItE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,iBAAiB,EAAE,iBAAiB,CAAA;CACrC;AACD,eAAO,MAAM,gBAAgB,uCAG1B,IAAI,KAAG,UAAU,GAAG,SA0BtB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { flattenTopLevelFields } from 'payload';
|
|
2
|
+
import { defaultUsernameField } from '../defaults.js';
|
|
3
|
+
export const getUsernameField = ({ collection, collectionOptions })=>{
|
|
4
|
+
if (!collectionOptions.usernameField) {
|
|
5
|
+
return defaultUsernameField;
|
|
6
|
+
}
|
|
7
|
+
if (typeof collectionOptions.usernameField === 'string') {
|
|
8
|
+
const matchedField = flattenTopLevelFields(collection.fields).find((field)=>field.name === collectionOptions.usernameField);
|
|
9
|
+
if (!matchedField) {
|
|
10
|
+
throw new Error(`Username field "${collectionOptions.usernameField}" not found in collection "${collection.slug}"`);
|
|
11
|
+
}
|
|
12
|
+
if (matchedField.type !== 'text' && matchedField.type !== 'email') {
|
|
13
|
+
throw new Error(`Username field "${collectionOptions.usernameField}" must be of type "text" or "email"`);
|
|
14
|
+
}
|
|
15
|
+
return matchedField;
|
|
16
|
+
}
|
|
17
|
+
return collectionOptions.usernameField;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=getUsernameField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/getUsernameField.ts"],"sourcesContent":["import type { CollectionConfig, EmailField, TextField } from 'payload'\n\nimport { flattenTopLevelFields } from 'payload'\n\nimport type { CollectionOptions } from '../types.js'\n\nimport { defaultUsernameField } from '../defaults.js'\n\ninterface Args {\n collection: CollectionConfig\n collectionOptions: CollectionOptions\n}\nexport const getUsernameField = ({\n collection,\n collectionOptions,\n}: Args): EmailField | TextField => {\n if (!collectionOptions.usernameField) {\n return defaultUsernameField\n }\n\n if (typeof collectionOptions.usernameField === 'string') {\n const matchedField = flattenTopLevelFields(collection.fields).find(\n (field) => field.name === collectionOptions.usernameField,\n )\n\n if (!matchedField) {\n throw new Error(\n `Username field \"${collectionOptions.usernameField}\" not found in collection \"${collection.slug}\"`,\n )\n }\n\n if (matchedField.type !== 'text' && matchedField.type !== 'email') {\n throw new Error(\n `Username field \"${collectionOptions.usernameField}\" must be of type \"text\" or \"email\"`,\n )\n }\n\n return matchedField\n }\n\n return collectionOptions.usernameField\n}\n"],"names":["flattenTopLevelFields","defaultUsernameField","getUsernameField","collection","collectionOptions","usernameField","matchedField","fields","find","field","name","Error","slug","type"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,UAAS;AAI/C,SAASC,oBAAoB,QAAQ,iBAAgB;AAMrD,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,UAAU,EACVC,iBAAiB,EACZ;IACL,IAAI,CAACA,kBAAkBC,aAAa,EAAE;QACpC,OAAOJ;IACT;IAEA,IAAI,OAAOG,kBAAkBC,aAAa,KAAK,UAAU;QACvD,MAAMC,eAAeN,sBAAsBG,WAAWI,MAAM,EAAEC,IAAI,CAChE,CAACC,QAAUA,MAAMC,IAAI,KAAKN,kBAAkBC,aAAa;QAG3D,IAAI,CAACC,cAAc;YACjB,MAAM,IAAIK,MACR,CAAC,gBAAgB,EAAEP,kBAAkBC,aAAa,CAAC,2BAA2B,EAAEF,WAAWS,IAAI,CAAC,CAAC,CAAC;QAEtG;QAEA,IAAIN,aAAaO,IAAI,KAAK,UAAUP,aAAaO,IAAI,KAAK,SAAS;YACjE,MAAM,IAAIF,MACR,CAAC,gBAAgB,EAAEP,kBAAkBC,aAAa,CAAC,mCAAmC,CAAC;QAE3F;QAEA,OAAOC;IACT;IAEA,OAAOF,kBAAkBC,aAAa;AACxC,EAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type User = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Iterate over the user's properties and compare them to the token's properties.
|
|
4
|
+
* If a property has changed, return true.
|
|
5
|
+
*/
|
|
6
|
+
export declare const hasUserTokenPropsChanged: (user: User, token: Record<string, unknown>) => boolean;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=hasUserTokenPropsChanged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasUserTokenPropsChanged.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/hasUserTokenPropsChanged.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,wBAAwB,SAAU,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAerF,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterate over the user's properties and compare them to the token's properties.
|
|
3
|
+
* If a property has changed, return true.
|
|
4
|
+
*/ export const hasUserTokenPropsChanged = (user, token)=>{
|
|
5
|
+
// For each property in token:
|
|
6
|
+
// - if so, are the values different?
|
|
7
|
+
// - if so, return true
|
|
8
|
+
// Iterate over the user's properties
|
|
9
|
+
for(const key in user){
|
|
10
|
+
if (user[key] && token[key]) {
|
|
11
|
+
if (compareValues(user[key], token[key])) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
18
|
+
function compareValues(userVal, tokenVal) {
|
|
19
|
+
if (Array.isArray(userVal) && Array.isArray(tokenVal)) {
|
|
20
|
+
return userVal.some((val)=>!tokenVal.includes(val)) || tokenVal.some((val)=>!userVal.includes(val));
|
|
21
|
+
}
|
|
22
|
+
return userVal !== tokenVal;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=hasUserTokenPropsChanged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/hasUserTokenPropsChanged.ts"],"sourcesContent":["type User = Record<string, unknown>\n\n/**\n * Iterate over the user's properties and compare them to the token's properties.\n * If a property has changed, return true.\n */\nexport const hasUserTokenPropsChanged = (user: User, token: Record<string, unknown>): boolean => {\n // For each property in token:\n // - if so, are the values different?\n // - if so, return true\n\n // Iterate over the user's properties\n for (const key in user) {\n if (user[key] && token[key]) {\n if (compareValues(user[key], token[key])) {\n return true\n }\n }\n }\n\n return false\n}\n\nfunction compareValues(userVal: unknown, tokenVal: unknown): boolean {\n if (Array.isArray(userVal) && Array.isArray(tokenVal)) {\n return (\n userVal.some((val) => !tokenVal.includes(val)) ||\n tokenVal.some((val) => !userVal.includes(val))\n )\n }\n return userVal !== tokenVal\n}\n"],"names":["hasUserTokenPropsChanged","user","token","key","compareValues","userVal","tokenVal","Array","isArray","some","val","includes"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA,2BAA2B,CAACC,MAAYC;IACnD,8BAA8B;IAC9B,qCAAqC;IACrC,uBAAuB;IAEvB,qCAAqC;IACrC,IAAK,MAAMC,OAAOF,KAAM;QACtB,IAAIA,IAAI,CAACE,IAAI,IAAID,KAAK,CAACC,IAAI,EAAE;YAC3B,IAAIC,cAAcH,IAAI,CAACE,IAAI,EAAED,KAAK,CAACC,IAAI,GAAG;gBACxC,OAAO;YACT;QACF;IACF;IAEA,OAAO;AACT,EAAC;AAED,SAASC,cAAcC,OAAgB,EAAEC,QAAiB;IACxD,IAAIC,MAAMC,OAAO,CAACH,YAAYE,MAAMC,OAAO,CAACF,WAAW;QACrD,OACED,QAAQI,IAAI,CAAC,CAACC,MAAQ,CAACJ,SAASK,QAAQ,CAACD,SACzCJ,SAASG,IAAI,CAAC,CAACC,MAAQ,CAACL,QAAQM,QAAQ,CAACD;IAE7C;IACA,OAAOL,YAAYC;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeHeaders.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/mergeHeaders.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,aAAa,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,GAAG,IAAI,CA8BtF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const headersToJoin = [
|
|
2
|
+
'set-cookie',
|
|
3
|
+
'warning',
|
|
4
|
+
'www-authenticate',
|
|
5
|
+
'proxy-authenticate',
|
|
6
|
+
'vary'
|
|
7
|
+
];
|
|
8
|
+
export function mergeHeaders(sourceHeaders, destinationHeaders) {
|
|
9
|
+
// Create a map to store combined headers
|
|
10
|
+
const combinedHeaders = new Headers();
|
|
11
|
+
// Add existing destination headers to the combined map
|
|
12
|
+
destinationHeaders.forEach((value, key)=>{
|
|
13
|
+
combinedHeaders.set(key, value);
|
|
14
|
+
});
|
|
15
|
+
// Add source headers to the combined map, joining specific headers
|
|
16
|
+
sourceHeaders.forEach((value, key)=>{
|
|
17
|
+
const lowerKey = key.toLowerCase();
|
|
18
|
+
if (headersToJoin.includes(lowerKey)) {
|
|
19
|
+
if (combinedHeaders.has(key)) {
|
|
20
|
+
combinedHeaders.set(key, `${combinedHeaders.get(key)}, ${value}`);
|
|
21
|
+
} else {
|
|
22
|
+
combinedHeaders.set(key, value);
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
combinedHeaders.set(key, value);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// Clear the destination headers and set the combined headers
|
|
29
|
+
destinationHeaders.forEach((_, key)=>{
|
|
30
|
+
destinationHeaders.delete(key);
|
|
31
|
+
});
|
|
32
|
+
combinedHeaders.forEach((value, key)=>{
|
|
33
|
+
destinationHeaders.append(key, value);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=mergeHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/mergeHeaders.ts"],"sourcesContent":["const headersToJoin = ['set-cookie', 'warning', 'www-authenticate', 'proxy-authenticate', 'vary']\n\nexport function mergeHeaders(sourceHeaders: Headers, destinationHeaders: Headers): void {\n // Create a map to store combined headers\n const combinedHeaders = new Headers()\n\n // Add existing destination headers to the combined map\n destinationHeaders.forEach((value, key) => {\n combinedHeaders.set(key, value)\n })\n\n // Add source headers to the combined map, joining specific headers\n sourceHeaders.forEach((value, key) => {\n const lowerKey = key.toLowerCase()\n if (headersToJoin.includes(lowerKey)) {\n if (combinedHeaders.has(key)) {\n combinedHeaders.set(key, `${combinedHeaders.get(key)}, ${value}`)\n } else {\n combinedHeaders.set(key, value)\n }\n } else {\n combinedHeaders.set(key, value)\n }\n })\n\n // Clear the destination headers and set the combined headers\n destinationHeaders.forEach((_, key) => {\n destinationHeaders.delete(key)\n })\n combinedHeaders.forEach((value, key) => {\n destinationHeaders.append(key, value)\n })\n}\n"],"names":["headersToJoin","mergeHeaders","sourceHeaders","destinationHeaders","combinedHeaders","Headers","forEach","value","key","set","lowerKey","toLowerCase","includes","has","get","_","delete","append"],"mappings":"AAAA,MAAMA,gBAAgB;IAAC;IAAc;IAAW;IAAoB;IAAsB;CAAO;AAEjG,OAAO,SAASC,aAAaC,aAAsB,EAAEC,kBAA2B;IAC9E,yCAAyC;IACzC,MAAMC,kBAAkB,IAAIC;IAE5B,uDAAuD;IACvDF,mBAAmBG,OAAO,CAAC,CAACC,OAAOC;QACjCJ,gBAAgBK,GAAG,CAACD,KAAKD;IAC3B;IAEA,mEAAmE;IACnEL,cAAcI,OAAO,CAAC,CAACC,OAAOC;QAC5B,MAAME,WAAWF,IAAIG,WAAW;QAChC,IAAIX,cAAcY,QAAQ,CAACF,WAAW;YACpC,IAAIN,gBAAgBS,GAAG,CAACL,MAAM;gBAC5BJ,gBAAgBK,GAAG,CAACD,KAAK,GAAGJ,gBAAgBU,GAAG,CAACN,KAAK,EAAE,EAAED,OAAO;YAClE,OAAO;gBACLH,gBAAgBK,GAAG,CAACD,KAAKD;YAC3B;QACF,OAAO;YACLH,gBAAgBK,GAAG,CAACD,KAAKD;QAC3B;IACF;IAEA,6DAA6D;IAC7DJ,mBAAmBG,OAAO,CAAC,CAACS,GAAGP;QAC7BL,mBAAmBa,MAAM,CAACR;IAC5B;IACAJ,gBAAgBE,OAAO,CAAC,CAACC,OAAOC;QAC9BL,mBAAmBc,MAAM,CAACT,KAAKD;IACjC;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type jwt from 'jsonwebtoken';
|
|
2
|
+
import type { Payload } from 'payload';
|
|
3
|
+
import type { Strategy } from '../strategy/index.js';
|
|
4
|
+
interface Args {
|
|
5
|
+
payload: Payload;
|
|
6
|
+
refreshToken: string;
|
|
7
|
+
strategy: Strategy;
|
|
8
|
+
}
|
|
9
|
+
type Result = {
|
|
10
|
+
decodedOauthToken: jwt.JwtPayload;
|
|
11
|
+
headers: Headers;
|
|
12
|
+
token: string;
|
|
13
|
+
} | false;
|
|
14
|
+
export declare const refreshTokens: ({ payload, refreshToken, strategy }: Args) => Promise<Result>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=refreshTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refreshTokens.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/refreshTokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AASpD,UAAU,IAAI;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,KAAK,MAAM,GACP;IACE,iBAAiB,EAAE,GAAG,CAAC,UAAU,CAAA;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd,GACD,KAAK,CAAA;AAET,eAAO,MAAM,aAAa,wCAA+C,IAAI,KAAG,OAAO,CAAC,MAAM,CAmE7F,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { generateCookie } from 'payload';
|
|
2
|
+
import { getProjectToken } from '../../api/figma-api.js';
|
|
3
|
+
import { validateProjectToken } from '../../auth/jwt-validator.js';
|
|
4
|
+
import { getEnvironment } from '../../constants.js';
|
|
5
|
+
import { createCookieOptions } from './createCookieOptions.js';
|
|
6
|
+
import { createDebugLogger } from './createDebugLogger.js';
|
|
7
|
+
import { getCookieExpiration } from './getCookieExpiration.js';
|
|
8
|
+
export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
9
|
+
const debugLogger = createDebugLogger(payload, strategy.debug);
|
|
10
|
+
debugLogger.info({
|
|
11
|
+
msg: 'Refreshing tokens'
|
|
12
|
+
});
|
|
13
|
+
const headers = new Headers();
|
|
14
|
+
// At this point, access token is expired
|
|
15
|
+
// but refresh token is still valid
|
|
16
|
+
// so we will refresh both tokens
|
|
17
|
+
try {
|
|
18
|
+
// Get another project token
|
|
19
|
+
const { expiresAt, token } = await getProjectToken(refreshToken, 'someproject');
|
|
20
|
+
debugLogger.info({
|
|
21
|
+
expiresAt,
|
|
22
|
+
msg: 'Received new tokens from Figma API',
|
|
23
|
+
token
|
|
24
|
+
});
|
|
25
|
+
// On error, no user
|
|
26
|
+
if (!token) {
|
|
27
|
+
debugLogger.error({
|
|
28
|
+
msg: 'Error refreshing tokens'
|
|
29
|
+
});
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (token) {
|
|
33
|
+
debugLogger.info({
|
|
34
|
+
msg: 'Successfully refreshed project token',
|
|
35
|
+
token
|
|
36
|
+
});
|
|
37
|
+
const expires_in = new Date(expiresAt);
|
|
38
|
+
const cookieOptions = createCookieOptions({
|
|
39
|
+
collection: strategy.collection,
|
|
40
|
+
headers,
|
|
41
|
+
pluginOptions: strategy.pluginOptions
|
|
42
|
+
});
|
|
43
|
+
const tokenCookie = generateCookie({
|
|
44
|
+
...cookieOptions,
|
|
45
|
+
name: strategy.cookieName,
|
|
46
|
+
expires: getCookieExpiration(expires_in),
|
|
47
|
+
returnCookieAsObject: false,
|
|
48
|
+
value: token
|
|
49
|
+
});
|
|
50
|
+
headers.append('Set-Cookie', tokenCookie);
|
|
51
|
+
const decodedOauthToken = await validateProjectToken(token, getEnvironment());
|
|
52
|
+
return {
|
|
53
|
+
decodedOauthToken,
|
|
54
|
+
headers,
|
|
55
|
+
token
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
debugLogger.error({
|
|
60
|
+
err: error,
|
|
61
|
+
msg: 'Error refreshing tokens'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=refreshTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/oauth/utilities/refreshTokens.ts"],"sourcesContent":["import type jwt from 'jsonwebtoken'\nimport type { Payload } from 'payload'\n\nimport { generateCookie } from 'payload'\n\nimport type { Strategy } from '../strategy/index.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { validateProjectToken } from '../../auth/jwt-validator.js'\nimport { getEnvironment } from '../../constants.js'\nimport { createCookieOptions } from './createCookieOptions.js'\nimport { createDebugLogger } from './createDebugLogger.js'\nimport { getCookieExpiration } from './getCookieExpiration.js'\n\ninterface Args {\n payload: Payload\n refreshToken: string\n strategy: Strategy\n}\n\ntype Result =\n | {\n decodedOauthToken: jwt.JwtPayload\n headers: Headers\n token: string\n }\n | false\n\nexport const refreshTokens = async ({ payload, refreshToken, strategy }: Args): Promise<Result> => {\n const debugLogger = createDebugLogger(payload, strategy.debug)\n\n debugLogger.info({\n msg: 'Refreshing tokens',\n })\n\n const headers = new Headers()\n\n // At this point, access token is expired\n // but refresh token is still valid\n // so we will refresh both tokens\n\n try {\n // Get another project token\n const { expiresAt, token } = await getProjectToken(refreshToken, 'someproject')\n\n debugLogger.info({\n expiresAt,\n msg: 'Received new tokens from Figma API',\n token,\n })\n\n // On error, no user\n if (!token) {\n debugLogger.error({\n msg: 'Error refreshing tokens',\n })\n return false\n }\n\n if (token) {\n debugLogger.info({\n msg: 'Successfully refreshed project token',\n token,\n })\n\n const expires_in = new Date(expiresAt)\n\n const cookieOptions = createCookieOptions({\n collection: strategy.collection,\n headers,\n pluginOptions: strategy.pluginOptions,\n })\n\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: getCookieExpiration(expires_in),\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n headers.append('Set-Cookie', tokenCookie)\n\n const decodedOauthToken = await validateProjectToken(token, getEnvironment())\n\n return { decodedOauthToken, headers, token }\n }\n } catch (error) {\n debugLogger.error({\n err: error,\n msg: 'Error refreshing tokens',\n })\n }\n\n return false\n}\n"],"names":["generateCookie","getProjectToken","validateProjectToken","getEnvironment","createCookieOptions","createDebugLogger","getCookieExpiration","refreshTokens","payload","refreshToken","strategy","debugLogger","debug","info","msg","headers","Headers","expiresAt","token","error","expires_in","Date","cookieOptions","collection","pluginOptions","tokenCookie","name","cookieName","expires","returnCookieAsObject","value","append","decodedOauthToken","err"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,oBAAoB,QAAQ,8BAA6B;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,mBAAmB,QAAQ,2BAA0B;AAgB9D,OAAO,MAAMC,gBAAgB,OAAO,EAAEC,OAAO,EAAEC,YAAY,EAAEC,QAAQ,EAAQ;IAC3E,MAAMC,cAAcN,kBAAkBG,SAASE,SAASE,KAAK;IAE7DD,YAAYE,IAAI,CAAC;QACfC,KAAK;IACP;IAEA,MAAMC,UAAU,IAAIC;IAEpB,yCAAyC;IACzC,mCAAmC;IACnC,iCAAiC;IAEjC,IAAI;QACF,4BAA4B;QAC5B,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAG,MAAMjB,gBAAgBQ,cAAc;QAEjEE,YAAYE,IAAI,CAAC;YACfI;YACAH,KAAK;YACLI;QACF;QAEA,oBAAoB;QACpB,IAAI,CAACA,OAAO;YACVP,YAAYQ,KAAK,CAAC;gBAChBL,KAAK;YACP;YACA,OAAO;QACT;QAEA,IAAII,OAAO;YACTP,YAAYE,IAAI,CAAC;gBACfC,KAAK;gBACLI;YACF;YAEA,MAAME,aAAa,IAAIC,KAAKJ;YAE5B,MAAMK,gBAAgBlB,oBAAoB;gBACxCmB,YAAYb,SAASa,UAAU;gBAC/BR;gBACAS,eAAed,SAASc,aAAa;YACvC;YAEA,MAAMC,cAAczB,eAAe;gBACjC,GAAGsB,aAAa;gBAChBI,MAAMhB,SAASiB,UAAU;gBACzBC,SAAStB,oBAAoBc;gBAC7BS,sBAAsB;gBACtBC,OAAOZ;YACT;YAEAH,QAAQgB,MAAM,CAAC,cAAcN;YAE7B,MAAMO,oBAAoB,MAAM9B,qBAAqBgB,OAAOf;YAE5D,OAAO;gBAAE6B;gBAAmBjB;gBAASG;YAAM;QAC7C;IACF,EAAE,OAAOC,OAAO;QACdR,YAAYQ,KAAK,CAAC;YAChBc,KAAKd;YACLL,KAAK;QACP;IACF;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -22,7 +22,13 @@ import type { Config, SanitizedConfig } from 'payload';
|
|
|
22
22
|
*/
|
|
23
23
|
export type FigmaConfig = {
|
|
24
24
|
editor?: Config['editor'];
|
|
25
|
-
} &
|
|
25
|
+
} & {
|
|
26
|
+
figma: {
|
|
27
|
+
region: string;
|
|
28
|
+
tenantId: string;
|
|
29
|
+
useContentSystem?: boolean;
|
|
30
|
+
};
|
|
31
|
+
} & Omit<Config, 'db' | 'editor' | 'secret'> & Partial<Pick<Config, 'db'>>;
|
|
26
32
|
/**
|
|
27
33
|
* Figma platform wrapper for Payload's buildConfig.
|
|
28
34
|
* Automatically injects:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;CAC1B,GAAG;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7B;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAmC/E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
2
2
|
import { buildConfig as payloadBuildConfig } from 'payload';
|
|
3
|
+
import { oAuth2Plugin } from '../oauth/index.js';
|
|
3
4
|
import { figmaContentSystem } from './adapter.js';
|
|
4
5
|
/**
|
|
5
6
|
* Figma platform wrapper for Payload's buildConfig.
|
|
@@ -14,9 +15,35 @@ import { figmaContentSystem } from './adapter.js';
|
|
|
14
15
|
// Build complete config with Figma platform defaults
|
|
15
16
|
const configWithFigmaDefaults = {
|
|
16
17
|
...config,
|
|
17
|
-
db: figmaContentSystem(),
|
|
18
|
+
db: config.figma.useContentSystem ? figmaContentSystem() : config.db,
|
|
18
19
|
editor: config.editor ?? lexicalEditor(),
|
|
19
|
-
secret: 'MY_SECRET'
|
|
20
|
+
secret: 'MY_SECRET',
|
|
21
|
+
// Add oauth to plugins if not already present
|
|
22
|
+
plugins: [
|
|
23
|
+
...config.plugins ?? [],
|
|
24
|
+
oAuth2Plugin({
|
|
25
|
+
collections: [
|
|
26
|
+
{
|
|
27
|
+
slug: 'users',
|
|
28
|
+
// Use adapter because Figma app doesn't support OIDC scopes
|
|
29
|
+
authorizationURLParams: {
|
|
30
|
+
response_mode: 'query',
|
|
31
|
+
response_type: 'code'
|
|
32
|
+
},
|
|
33
|
+
clientID: process.env.FIGMA_OAUTH_CLIENT_ID,
|
|
34
|
+
clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,
|
|
35
|
+
identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',
|
|
36
|
+
scope: [
|
|
37
|
+
'current_user:read'
|
|
38
|
+
],
|
|
39
|
+
token: 'id_token',
|
|
40
|
+
usernameField: 'email'
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
debug: !!process.env.DEBUG,
|
|
44
|
+
disabled: false
|
|
45
|
+
})
|
|
46
|
+
]
|
|
20
47
|
};
|
|
21
48
|
// Delegate to Payload's buildConfig
|
|
22
49
|
return await payloadBuildConfig(configWithFigmaDefaults);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport { figmaContentSystem } from './adapter.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & Omit<Config, 'db' | 'editor' | 'secret'
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport { oAuth2Plugin } from '../oauth/index.js'\nimport { figmaContentSystem } from './adapter.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n region: string\n tenantId: string\n useContentSystem?: boolean\n }\n} & Omit<Config, 'db' | 'editor' | 'secret'> &\n Partial<Pick<Config, 'db'>>\n\n/**\n * Figma platform wrapper for Payload's buildConfig.\n * Automatically injects:\n * - Figma database adapter\n * - Secret (platform-provided)\n * - Default lexicalEditor (if no custom editor specified)\n *\n * @param config - Payload configuration (db and secret omitted, editor optional)\n * @returns Promise<SanitizedConfig> - Built Payload configuration\n */\nexport async function buildConfig(config: FigmaConfig): Promise<SanitizedConfig> {\n // Build complete config with Figma platform defaults\n const configWithFigmaDefaults: Config = {\n ...config,\n db: config.figma.useContentSystem ? figmaContentSystem() : config.db!,\n editor: config.editor ?? lexicalEditor(),\n secret: 'MY_SECRET',\n // Add oauth to plugins if not already present\n plugins: [\n ...(config.plugins ?? []),\n oAuth2Plugin({\n collections: [\n {\n slug: 'users',\n // Use adapter because Figma app doesn't support OIDC scopes\n authorizationURLParams: {\n response_mode: 'query',\n response_type: 'code',\n },\n clientID: process.env.FIGMA_OAUTH_CLIENT_ID!,\n clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,\n identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',\n scope: ['current_user:read'],\n token: 'id_token', // Adapter creates JWT id_token from Figma user info\n usernameField: 'email',\n },\n ],\n debug: !!process.env.DEBUG,\n disabled: false,\n }),\n ],\n }\n\n // Delegate to Payload's buildConfig\n return await payloadBuildConfig(configWithFigmaDefaults)\n}\n"],"names":["lexicalEditor","buildConfig","payloadBuildConfig","oAuth2Plugin","figmaContentSystem","config","configWithFigmaDefaults","db","figma","useContentSystem","editor","secret","plugins","collections","slug","authorizationURLParams","response_mode","response_type","clientID","process","env","FIGMA_OAUTH_CLIENT_ID","clientSecret","FIGMA_OAUTH_CLIENT_SECRET","identityMetadata","scope","token","usernameField","debug","DEBUG","disabled"],"mappings":"AAEA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,eAAeC,kBAAkB,QAAQ,UAAS;AAE3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,kBAAkB,QAAQ,eAAc;AAkCjD;;;;;;;;;CASC,GACD,OAAO,eAAeH,YAAYI,MAAmB;IACnD,qDAAqD;IACrD,MAAMC,0BAAkC;QACtC,GAAGD,MAAM;QACTE,IAAIF,OAAOG,KAAK,CAACC,gBAAgB,GAAGL,uBAAuBC,OAAOE,EAAE;QACpEG,QAAQL,OAAOK,MAAM,IAAIV;QACzBW,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACHP,OAAOO,OAAO,IAAI,EAAE;YACxBT,aAAa;gBACXU,aAAa;oBACX;wBACEC,MAAM;wBACN,4DAA4D;wBAC5DC,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAUC,QAAQC,GAAG,CAACC,qBAAqB;wBAC3CC,cAAcH,QAAQC,GAAG,CAACG,yBAAyB;wBACnDC,kBAAkB;wBAClBC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO,CAAC,CAACT,QAAQC,GAAG,CAACS,KAAK;gBAC1BC,UAAU;YACZ;SACD;IACH;IAEA,oCAAoC;IACpC,OAAO,MAAM5B,mBAAmBI;AAClC"}
|