@8ms/helpers 1.42.11 → 1.42.13

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.
@@ -4,7 +4,9 @@
4
4
  * Library: crypto-js
5
5
  */
6
6
  const getDecrypt = async ({ appSalt, input, salt }) => {
7
- const { AES, enc } = await import("crypto-js");
7
+ const cryptoJs = await import("crypto-js");
8
+ const AES = cryptoJs.default?.AES ?? cryptoJs.AES;
9
+ const enc = cryptoJs.default?.enc ?? cryptoJs.enc;
8
10
  const customSalt = `${appSalt}-${salt}`;
9
11
  return AES.decrypt(input, customSalt).toString(enc.Utf8);
10
12
  };
@@ -4,7 +4,9 @@
4
4
  * Library: crypto-js
5
5
  */
6
6
  const getDecrypt = async ({ appSalt, input, salt }) => {
7
- const { AES, enc } = await import("crypto-js");
7
+ const cryptoJs = await import("crypto-js");
8
+ const AES = cryptoJs.default?.AES ?? cryptoJs.AES;
9
+ const enc = cryptoJs.default?.enc ?? cryptoJs.enc;
8
10
  const customSalt = `${appSalt}-${salt}`;
9
11
  return AES.decrypt(input, customSalt).toString(enc.Utf8);
10
12
  };
@@ -4,7 +4,8 @@
4
4
  * Library: crypto-js
5
5
  */
6
6
  const getEncrypt = async ({ appSalt, input, salt }) => {
7
- const { AES } = await import("crypto-js");
7
+ const cryptoJs = await import("crypto-js");
8
+ const AES = cryptoJs.default?.AES ?? cryptoJs.AES;
8
9
  const customSalt = `${appSalt}-${salt}`;
9
10
  return AES.encrypt(input, customSalt).toString();
10
11
  };
@@ -4,7 +4,8 @@
4
4
  * Library: crypto-js
5
5
  */
6
6
  const getEncrypt = async ({ appSalt, input, salt }) => {
7
- const { AES } = await import("crypto-js");
7
+ const cryptoJs = await import("crypto-js");
8
+ const AES = cryptoJs.default?.AES ?? cryptoJs.AES;
8
9
  const customSalt = `${appSalt}-${salt}`;
9
10
  return AES.encrypt(input, customSalt).toString();
10
11
  };
@@ -5,8 +5,8 @@ const require_string_getString = require("../string/getString.cjs");
5
5
  * Library: crypto-js
6
6
  */
7
7
  const getSha256 = async ({ input }) => {
8
- const { SHA256 } = await import("crypto-js");
9
- return SHA256(require_string_getString({ input })).toString();
8
+ const cryptoJs = await import("crypto-js");
9
+ return (cryptoJs.default?.SHA256 ?? cryptoJs.SHA256)(require_string_getString({ input })).toString();
10
10
  };
11
11
  //#endregion
12
12
  module.exports = getSha256;
@@ -5,8 +5,8 @@ import getString from "../string/getString.mjs";
5
5
  * Library: crypto-js
6
6
  */
7
7
  const getSha256 = async ({ input }) => {
8
- const { SHA256 } = await import("crypto-js");
9
- return SHA256(getString({ input })).toString();
8
+ const cryptoJs = await import("crypto-js");
9
+ return (cryptoJs.default?.SHA256 ?? cryptoJs.SHA256)(getString({ input })).toString();
10
10
  };
11
11
  //#endregion
12
12
  export { getSha256 as default };
@@ -1,6 +1,6 @@
1
+ const require_google_storage_getClient = require("../storage/getClient.cjs");
1
2
  const require_google_bigQuery_getClient = require("./getClient.cjs");
2
3
  const require_google_bigQuery_IsTableExists = require("./IsTableExists.cjs");
3
- const require_google_storage_getClient = require("../storage/getClient.cjs");
4
4
  //#region src/google/bigQuery/loadData.ts
5
5
  /**
6
6
  * Load data into a given table.
@@ -11,8 +11,8 @@ const loadData = async ({ file, table }) => {
11
11
  projectId: table.projectId,
12
12
  tableId: table.tableId
13
13
  })) {
14
- let bigqueryClient = require_google_bigQuery_getClient({ projectId: table.projectId });
15
- let storageClient = require_google_storage_getClient({ projectId: file.projectId });
14
+ let bigqueryClient = await require_google_bigQuery_getClient({ projectId: table.projectId });
15
+ let storageClient = await require_google_storage_getClient({ projectId: file.projectId });
16
16
  await bigqueryClient.dataset(table.datasetId).table(table.tableId).load(storageClient.bucket(file.bucket).file(file.key), file.metadata);
17
17
  }
18
18
  };
@@ -1,6 +1,6 @@
1
- import getClient from "./getClient.mjs";
1
+ import getClient from "../storage/getClient.mjs";
2
+ import getClient$1 from "./getClient.mjs";
2
3
  import isTableExists from "./IsTableExists.mjs";
3
- import getClient$1 from "../storage/getClient.mjs";
4
4
  //#region src/google/bigQuery/loadData.ts
5
5
  /**
6
6
  * Load data into a given table.
@@ -11,8 +11,8 @@ const loadData = async ({ file, table }) => {
11
11
  projectId: table.projectId,
12
12
  tableId: table.tableId
13
13
  })) {
14
- let bigqueryClient = getClient({ projectId: table.projectId });
15
- let storageClient = getClient$1({ projectId: file.projectId });
14
+ let bigqueryClient = await getClient$1({ projectId: table.projectId });
15
+ let storageClient = await getClient({ projectId: file.projectId });
16
16
  await bigqueryClient.dataset(table.datasetId).table(table.tableId).load(storageClient.bucket(file.bucket).file(file.key), file.metadata);
17
17
  }
18
18
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.42.11",
4
+ "version": "1.42.13",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -131,6 +131,7 @@
131
131
  "@prisma/adapter-planetscale": "5.22.0",
132
132
  "@prisma/client": "5.22.0",
133
133
  "@types/babel__core": "7.20.5",
134
+ "@types/crypto-js": "^4.2.2",
134
135
  "@types/fs-extra": "11.0.4",
135
136
  "@types/jest": "^30.0.0",
136
137
  "@types/lodash": "4.17.24",