@payloadcms/payload-cloud 3.25.0-canary.f62445f → 3.25.0

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.
@@ -1,7 +1,8 @@
1
- import * as AWS from '@aws-sdk/client-s3';
2
- export type GetStorageClient = () => Promise<{
3
- identityID: string;
4
- storageClient: AWS.S3;
5
- }>;
1
+ import type * as AWS from '@aws-sdk/client-s3';
2
+ import type { CognitoUserSession } from 'amazon-cognito-identity-js';
3
+ import type { GetStorageClient } from './refreshSession.js';
4
+ export declare let storageClient: AWS.S3 | null;
5
+ export declare let session: CognitoUserSession | null;
6
+ export declare let identityID: string;
6
7
  export declare const getStorageClient: GetStorageClient;
7
8
  //# sourceMappingURL=getStorageClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStorageClient.d.ts","sourceRoot":"","sources":["../../src/utilities/getStorageClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAKzC,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,GAAG,CAAC,EAAE,CAAA;CACtB,CAAC,CAAA;AAMF,eAAO,MAAM,gBAAgB,EAAE,gBAkD9B,CAAA"}
1
+ {"version":3,"file":"getStorageClient.d.ts","sourceRoot":"","sources":["../../src/utilities/getStorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAI3D,eAAO,IAAI,aAAa,EAAE,GAAG,CAAC,EAAE,GAAG,IAAW,CAAA;AAC9C,eAAO,IAAI,OAAO,EAAE,kBAAkB,GAAG,IAAW,CAAA;AACpD,eAAO,IAAI,UAAU,EAAE,MAAM,CAAA;AAE7B,eAAO,MAAM,gBAAgB,EAAE,gBAwB9B,CAAA"}
@@ -1,10 +1,7 @@
1
- import { CognitoIdentityClient } from '@aws-sdk/client-cognito-identity';
2
- import * as AWS from '@aws-sdk/client-s3';
3
- import { fromCognitoIdentityPool } from '@aws-sdk/credential-providers';
4
- import { authAsCognitoUser } from './authAsCognitoUser.js';
5
- let storageClient = null;
6
- let session = null;
7
- let identityID;
1
+ import { refreshSession } from './refreshSession.js';
2
+ export let storageClient = null;
3
+ export let session = null;
4
+ export let identityID;
8
5
  export const getStorageClient = async ()=>{
9
6
  if (storageClient && session?.isValid()) {
10
7
  return {
@@ -12,6 +9,8 @@ export const getStorageClient = async ()=>{
12
9
  storageClient
13
10
  };
14
11
  }
12
+ ;
13
+ ({ identityID, session, storageClient } = await refreshSession());
15
14
  if (!process.env.PAYLOAD_CLOUD_PROJECT_ID) {
16
15
  throw new Error('PAYLOAD_CLOUD_PROJECT_ID is required');
17
16
  }
@@ -21,25 +20,6 @@ export const getStorageClient = async ()=>{
21
20
  if (!process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID) {
22
21
  throw new Error('PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID is required');
23
22
  }
24
- session = await authAsCognitoUser(process.env.PAYLOAD_CLOUD_PROJECT_ID, process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD);
25
- const cognitoIdentity = new CognitoIdentityClient({
26
- credentials: fromCognitoIdentityPool({
27
- clientConfig: {
28
- region: 'us-east-1'
29
- },
30
- identityPoolId: process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID,
31
- logins: {
32
- [`cognito-idp.us-east-1.amazonaws.com/${process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID}`]: session.getIdToken().getJwtToken()
33
- }
34
- })
35
- });
36
- const credentials = await cognitoIdentity.config.credentials();
37
- // @ts-expect-error - Incorrect AWS types
38
- identityID = credentials.identityId;
39
- storageClient = new AWS.S3({
40
- credentials,
41
- region: process.env.PAYLOAD_CLOUD_BUCKET_REGION
42
- });
43
23
  return {
44
24
  identityID,
45
25
  storageClient
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/getStorageClient.ts"],"sourcesContent":["import type { CognitoUserSession } from 'amazon-cognito-identity-js'\n\nimport { CognitoIdentityClient } from '@aws-sdk/client-cognito-identity'\nimport * as AWS from '@aws-sdk/client-s3'\nimport { fromCognitoIdentityPool } from '@aws-sdk/credential-providers'\n\nimport { authAsCognitoUser } from './authAsCognitoUser.js'\n\nexport type GetStorageClient = () => Promise<{\n identityID: string\n storageClient: AWS.S3\n}>\n\nlet storageClient: AWS.S3 | null = null\nlet session: CognitoUserSession | null = null\nlet identityID: string\n\nexport const getStorageClient: GetStorageClient = async () => {\n if (storageClient && session?.isValid()) {\n return {\n identityID,\n storageClient,\n }\n }\n\n if (!process.env.PAYLOAD_CLOUD_PROJECT_ID) {\n throw new Error('PAYLOAD_CLOUD_PROJECT_ID is required')\n }\n if (!process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD) {\n throw new Error('PAYLOAD_CLOUD_COGNITO_PASSWORD is required')\n }\n if (!process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID) {\n throw new Error('PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID is required')\n }\n\n session = await authAsCognitoUser(\n process.env.PAYLOAD_CLOUD_PROJECT_ID,\n process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD,\n )\n\n const cognitoIdentity = new CognitoIdentityClient({\n credentials: fromCognitoIdentityPool({\n clientConfig: {\n region: 'us-east-1',\n },\n identityPoolId: process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID,\n logins: {\n [`cognito-idp.us-east-1.amazonaws.com/${process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID}`]:\n session.getIdToken().getJwtToken(),\n },\n }),\n })\n\n const credentials = await cognitoIdentity.config.credentials()\n\n // @ts-expect-error - Incorrect AWS types\n identityID = credentials.identityId\n\n storageClient = new AWS.S3({\n credentials,\n region: process.env.PAYLOAD_CLOUD_BUCKET_REGION,\n })\n\n return {\n identityID,\n storageClient,\n }\n}\n"],"names":["CognitoIdentityClient","AWS","fromCognitoIdentityPool","authAsCognitoUser","storageClient","session","identityID","getStorageClient","isValid","process","env","PAYLOAD_CLOUD_PROJECT_ID","Error","PAYLOAD_CLOUD_COGNITO_PASSWORD","PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID","cognitoIdentity","credentials","clientConfig","region","identityPoolId","logins","PAYLOAD_CLOUD_COGNITO_USER_POOL_ID","getIdToken","getJwtToken","config","identityId","S3","PAYLOAD_CLOUD_BUCKET_REGION"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,mCAAkC;AACxE,YAAYC,SAAS,qBAAoB;AACzC,SAASC,uBAAuB,QAAQ,gCAA+B;AAEvE,SAASC,iBAAiB,QAAQ,yBAAwB;AAO1D,IAAIC,gBAA+B;AACnC,IAAIC,UAAqC;AACzC,IAAIC;AAEJ,OAAO,MAAMC,mBAAqC;IAChD,IAAIH,iBAAiBC,SAASG,WAAW;QACvC,OAAO;YACLF;YACAF;QACF;IACF;IAEA,IAAI,CAACK,QAAQC,GAAG,CAACC,wBAAwB,EAAE;QACzC,MAAM,IAAIC,MAAM;IAClB;IACA,IAAI,CAACH,QAAQC,GAAG,CAACG,8BAA8B,EAAE;QAC/C,MAAM,IAAID,MAAM;IAClB;IACA,IAAI,CAACH,QAAQC,GAAG,CAACI,sCAAsC,EAAE;QACvD,MAAM,IAAIF,MAAM;IAClB;IAEAP,UAAU,MAAMF,kBACdM,QAAQC,GAAG,CAACC,wBAAwB,EACpCF,QAAQC,GAAG,CAACG,8BAA8B;IAG5C,MAAME,kBAAkB,IAAIf,sBAAsB;QAChDgB,aAAad,wBAAwB;YACnCe,cAAc;gBACZC,QAAQ;YACV;YACAC,gBAAgBV,QAAQC,GAAG,CAACI,sCAAsC;YAClEM,QAAQ;gBACN,CAAC,CAAC,oCAAoC,EAAEX,QAAQC,GAAG,CAACW,kCAAkC,EAAE,CAAC,EACvFhB,QAAQiB,UAAU,GAAGC,WAAW;YACpC;QACF;IACF;IAEA,MAAMP,cAAc,MAAMD,gBAAgBS,MAAM,CAACR,WAAW;IAE5D,yCAAyC;IACzCV,aAAaU,YAAYS,UAAU;IAEnCrB,gBAAgB,IAAIH,IAAIyB,EAAE,CAAC;QACzBV;QACAE,QAAQT,QAAQC,GAAG,CAACiB,2BAA2B;IACjD;IAEA,OAAO;QACLrB;QACAF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/getStorageClient.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\nimport type { CognitoUserSession } from 'amazon-cognito-identity-js'\n\nimport type { GetStorageClient } from './refreshSession.js'\n\nimport { refreshSession } from './refreshSession.js'\n\nexport let storageClient: AWS.S3 | null = null\nexport let session: CognitoUserSession | null = null\nexport let identityID: string\n\nexport const getStorageClient: GetStorageClient = async () => {\n if (storageClient && session?.isValid()) {\n return {\n identityID,\n storageClient,\n }\n }\n\n ;({ identityID, session, storageClient } = await refreshSession())\n\n if (!process.env.PAYLOAD_CLOUD_PROJECT_ID) {\n throw new Error('PAYLOAD_CLOUD_PROJECT_ID is required')\n }\n if (!process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD) {\n throw new Error('PAYLOAD_CLOUD_COGNITO_PASSWORD is required')\n }\n if (!process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID) {\n throw new Error('PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID is required')\n }\n\n return {\n identityID,\n storageClient,\n }\n}\n"],"names":["refreshSession","storageClient","session","identityID","getStorageClient","isValid","process","env","PAYLOAD_CLOUD_PROJECT_ID","Error","PAYLOAD_CLOUD_COGNITO_PASSWORD","PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,OAAO,IAAIC,gBAA+B,KAAI;AAC9C,OAAO,IAAIC,UAAqC,KAAI;AACpD,OAAO,IAAIC,WAAkB;AAE7B,OAAO,MAAMC,mBAAqC;IAChD,IAAIH,iBAAiBC,SAASG,WAAW;QACvC,OAAO;YACLF;YACAF;QACF;IACF;;IAEE,CAAA,EAAEE,UAAU,EAAED,OAAO,EAAED,aAAa,EAAE,GAAG,MAAMD,gBAAe;IAEhE,IAAI,CAACM,QAAQC,GAAG,CAACC,wBAAwB,EAAE;QACzC,MAAM,IAAIC,MAAM;IAClB;IACA,IAAI,CAACH,QAAQC,GAAG,CAACG,8BAA8B,EAAE;QAC/C,MAAM,IAAID,MAAM;IAClB;IACA,IAAI,CAACH,QAAQC,GAAG,CAACI,sCAAsC,EAAE;QACvD,MAAM,IAAIF,MAAM;IAClB;IAEA,OAAO;QACLN;QACAF;IACF;AACF,EAAC"}
@@ -0,0 +1,11 @@
1
+ import * as AWS from '@aws-sdk/client-s3';
2
+ export type GetStorageClient = () => Promise<{
3
+ identityID: string;
4
+ storageClient: AWS.S3;
5
+ }>;
6
+ export declare const refreshSession: () => Promise<{
7
+ identityID: any;
8
+ session: import("amazon-cognito-identity-js").CognitoUserSession;
9
+ storageClient: AWS.S3;
10
+ }>;
11
+ //# sourceMappingURL=refreshSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refreshSession.d.ts","sourceRoot":"","sources":["../../src/utilities/refreshSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAKzC,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,GAAG,CAAC,EAAE,CAAA;CACtB,CAAC,CAAA;AAEF,eAAO,MAAM,cAAc;;;;EAkC1B,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { CognitoIdentityClient } from '@aws-sdk/client-cognito-identity';
2
+ import * as AWS from '@aws-sdk/client-s3';
3
+ import { fromCognitoIdentityPool } from '@aws-sdk/credential-providers';
4
+ import { authAsCognitoUser } from './authAsCognitoUser.js';
5
+ export const refreshSession = async ()=>{
6
+ const session = await authAsCognitoUser(process.env.PAYLOAD_CLOUD_PROJECT_ID || '', process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD || '');
7
+ const cognitoIdentity = new CognitoIdentityClient({
8
+ credentials: fromCognitoIdentityPool({
9
+ clientConfig: {
10
+ region: 'us-east-1'
11
+ },
12
+ identityPoolId: process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID || '',
13
+ logins: {
14
+ [`cognito-idp.us-east-1.amazonaws.com/${process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID}`]: session.getIdToken().getJwtToken()
15
+ }
16
+ })
17
+ });
18
+ const credentials = await cognitoIdentity.config.credentials();
19
+ // @ts-expect-error - Incorrect AWS types
20
+ const identityID = credentials.identityId;
21
+ const storageClient = new AWS.S3({
22
+ credentials,
23
+ region: process.env.PAYLOAD_CLOUD_BUCKET_REGION
24
+ });
25
+ return {
26
+ identityID,
27
+ session,
28
+ storageClient
29
+ };
30
+ };
31
+
32
+ //# sourceMappingURL=refreshSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/refreshSession.ts"],"sourcesContent":["import { CognitoIdentityClient } from '@aws-sdk/client-cognito-identity'\nimport * as AWS from '@aws-sdk/client-s3'\nimport { fromCognitoIdentityPool } from '@aws-sdk/credential-providers'\n\nimport { authAsCognitoUser } from './authAsCognitoUser.js'\n\nexport type GetStorageClient = () => Promise<{\n identityID: string\n storageClient: AWS.S3\n}>\n\nexport const refreshSession = async () => {\n const session = await authAsCognitoUser(\n process.env.PAYLOAD_CLOUD_PROJECT_ID || '',\n process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD || '',\n )\n\n const cognitoIdentity = new CognitoIdentityClient({\n credentials: fromCognitoIdentityPool({\n clientConfig: {\n region: 'us-east-1',\n },\n identityPoolId: process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID || '',\n logins: {\n [`cognito-idp.us-east-1.amazonaws.com/${process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID}`]:\n session.getIdToken().getJwtToken(),\n },\n }),\n })\n\n const credentials = await cognitoIdentity.config.credentials()\n\n // @ts-expect-error - Incorrect AWS types\n const identityID = credentials.identityId\n\n const storageClient = new AWS.S3({\n credentials,\n region: process.env.PAYLOAD_CLOUD_BUCKET_REGION,\n })\n\n return {\n identityID,\n session,\n storageClient,\n }\n}\n"],"names":["CognitoIdentityClient","AWS","fromCognitoIdentityPool","authAsCognitoUser","refreshSession","session","process","env","PAYLOAD_CLOUD_PROJECT_ID","PAYLOAD_CLOUD_COGNITO_PASSWORD","cognitoIdentity","credentials","clientConfig","region","identityPoolId","PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID","logins","PAYLOAD_CLOUD_COGNITO_USER_POOL_ID","getIdToken","getJwtToken","config","identityID","identityId","storageClient","S3","PAYLOAD_CLOUD_BUCKET_REGION"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,mCAAkC;AACxE,YAAYC,SAAS,qBAAoB;AACzC,SAASC,uBAAuB,QAAQ,gCAA+B;AAEvE,SAASC,iBAAiB,QAAQ,yBAAwB;AAO1D,OAAO,MAAMC,iBAAiB;IAC5B,MAAMC,UAAU,MAAMF,kBACpBG,QAAQC,GAAG,CAACC,wBAAwB,IAAI,IACxCF,QAAQC,GAAG,CAACE,8BAA8B,IAAI;IAGhD,MAAMC,kBAAkB,IAAIV,sBAAsB;QAChDW,aAAaT,wBAAwB;YACnCU,cAAc;gBACZC,QAAQ;YACV;YACAC,gBAAgBR,QAAQC,GAAG,CAACQ,sCAAsC,IAAI;YACtEC,QAAQ;gBACN,CAAC,CAAC,oCAAoC,EAAEV,QAAQC,GAAG,CAACU,kCAAkC,EAAE,CAAC,EACvFZ,QAAQa,UAAU,GAAGC,WAAW;YACpC;QACF;IACF;IAEA,MAAMR,cAAc,MAAMD,gBAAgBU,MAAM,CAACT,WAAW;IAE5D,yCAAyC;IACzC,MAAMU,aAAaV,YAAYW,UAAU;IAEzC,MAAMC,gBAAgB,IAAItB,IAAIuB,EAAE,CAAC;QAC/Bb;QACAE,QAAQP,QAAQC,GAAG,CAACkB,2BAA2B;IACjD;IAEA,OAAO;QACLJ;QACAhB;QACAkB;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/payload-cloud",
3
- "version": "3.25.0-canary.f62445f",
3
+ "version": "3.25.0",
4
4
  "description": "The official Payload Cloud plugin",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -37,15 +37,15 @@
37
37
  "@aws-sdk/lib-storage": "^3.614.0",
38
38
  "amazon-cognito-identity-js": "^6.1.2",
39
39
  "nodemailer": "6.9.16",
40
- "@payloadcms/email-nodemailer": "3.25.0-canary.f62445f"
40
+ "@payloadcms/email-nodemailer": "3.25.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/jest": "29.5.12",
44
44
  "@types/nodemailer": "6.4.17",
45
- "payload": "3.25.0-canary.f62445f"
45
+ "payload": "3.25.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "payload": "3.25.0-canary.f62445f"
48
+ "payload": "3.25.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "pnpm build:types && pnpm build:swc",