@peacom/core 0.0.164 → 0.0.166

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/package.json CHANGED
@@ -1,34 +1,25 @@
1
1
  {
2
2
  "name": "@peacom/core",
3
- "version": "0.0.164",
3
+ "version": "0.0.166",
4
4
  "type": "commonjs",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-s3": "^3.350.0",
7
7
  "@aws-sdk/s3-request-presigner": "^3.350.0",
8
8
  "bullmq": "^3.15.5",
9
- "dotenv": "10.0.0",
10
9
  "google-libphonenumber": "^3.2.32",
11
10
  "mime-types": "^2.1.35",
12
11
  "moment": "^2.29.4",
13
12
  "moment-timezone": "^0.5.43",
14
- "mustache": "^4.2.0",
15
- "uuid": "^9.0.0"
13
+ "uuid": "^9.0.0",
14
+ "mustache": "^4.2.0"
16
15
  },
17
16
  "devDependencies": {
18
17
  "@types/google-libphonenumber": "^7.4.23",
19
18
  "@types/mime-types": "^2.1.1",
20
- "@types/mustache": "^4.2.2",
21
19
  "@types/node": "^20.3.1",
20
+ "@types/mustache": "^4.2.2",
22
21
  "@types/uuid": "^9.0.1",
23
22
  "dotenv": "^16.1.4"
24
23
  },
25
- "exports": {
26
- "default": "./src/index.js",
27
- "react-native": "./src/index-react-native.js"
28
- },
29
- "peerDependencies": {
30
- "tslib": "2.4.1"
31
- },
32
- "main": "./src/index.js",
33
- "types": "./src/index.d.ts"
24
+ "main": "./src/index.js"
34
25
  }
@@ -1,4 +1,8 @@
1
- export * from './lib/model/index-react-native';
2
- export * from './lib/util';
1
+ export * from './lib/core';
2
+ export * from './lib/model';
3
+ export * from './lib/util/message/message.util';
4
+ export * from './lib/util/string.util';
5
+ export * from './lib/util/general.util';
6
+ export * from './lib/util/phone.util';
7
+ export * from './lib/util/date/index';
3
8
  export * from './lib/api';
4
- export * from './lib/service';
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/model/index-react-native"), exports);
5
- tslib_1.__exportStar(require("./lib/util"), exports);
4
+ tslib_1.__exportStar(require("./lib/core"), exports);
5
+ tslib_1.__exportStar(require("./lib/model"), exports);
6
+ tslib_1.__exportStar(require("./lib/util/message/message.util"), exports);
7
+ tslib_1.__exportStar(require("./lib/util/string.util"), exports);
8
+ tslib_1.__exportStar(require("./lib/util/general.util"), exports);
9
+ tslib_1.__exportStar(require("./lib/util/phone.util"), exports);
10
+ tslib_1.__exportStar(require("./lib/util/date/index"), exports);
6
11
  tslib_1.__exportStar(require("./lib/api"), exports);
7
- tslib_1.__exportStar(require("./lib/service"), exports);
8
12
  //# sourceMappingURL=index-react-native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-react-native.js","sourceRoot":"","sources":["../../../../packages/core/src/index-react-native.ts"],"names":[],"mappings":";;;AAAA,yEAA+C;AAC/C,qDAA0B;AAC1B,oDAAyB;AACzB,wDAA6B"}
1
+ {"version":3,"file":"index-react-native.js","sourceRoot":"","sources":["../../../../packages/core/src/index-react-native.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,0EAA+C;AAC/C,iEAAsC;AACtC,kEAAuC;AACvC,gEAAqC;AACrC,gEAAqC;AACrC,oDAAyB"}
package/src/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  export * from './lib/core';
2
2
  export * from './lib/model';
3
- export * from './lib/util/message/message.util';
4
- export * from './lib/util/string.util';
5
- export * from './lib/util/general.util';
6
- export * from './lib/util/phone.util';
7
- export * from './lib/util/date/index';
3
+ export * from './lib/util';
8
4
  export * from './lib/api';
9
5
  export * from './lib/service';
package/src/index.js CHANGED
@@ -3,11 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./lib/core"), exports);
5
5
  tslib_1.__exportStar(require("./lib/model"), exports);
6
- tslib_1.__exportStar(require("./lib/util/message/message.util"), exports);
7
- tslib_1.__exportStar(require("./lib/util/string.util"), exports);
8
- tslib_1.__exportStar(require("./lib/util/general.util"), exports);
9
- tslib_1.__exportStar(require("./lib/util/phone.util"), exports);
10
- tslib_1.__exportStar(require("./lib/util/date/index"), exports);
6
+ tslib_1.__exportStar(require("./lib/util"), exports);
11
7
  tslib_1.__exportStar(require("./lib/api"), exports);
12
8
  tslib_1.__exportStar(require("./lib/service"), exports);
13
9
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,0EAA+C;AAC/C,iEAAsC;AACtC,kEAAuC;AACvC,gEAAqC;AACrC,gEAAqC;AACrC,oDAAyB;AACzB,wDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,qDAA0B;AAC1B,oDAAyB;AACzB,wDAA6B"}
@@ -38,4 +38,4 @@ export declare enum BULK_CAMPAIGN_CONTACT_ORIGIN {
38
38
  USER_AUTO_JOIN = 3,
39
39
  FROM_APPLICATION = 4
40
40
  }
41
- export declare const getBulkCampaignContactProcessStatus: (status: BULK_CAMPAIGN_CONTACT_PROCESSING_STATUS) => "DRAFT" | "NOT SEND" | "PROCESSING" | "DONE" | "FAIL" | "SENT" | "DELIVERED" | "READ" | "BLACK LIST" | "COMPLIANCE" | "UNKNOWN";
41
+ export declare const getBulkCampaignContactProcessStatus: (status: BULK_CAMPAIGN_CONTACT_PROCESSING_STATUS) => "COMPLIANCE" | "DRAFT" | "NOT SEND" | "PROCESSING" | "DONE" | "FAIL" | "SENT" | "DELIVERED" | "READ" | "BLACK LIST" | "UNKNOWN";
@@ -1,2 +1,4 @@
1
1
  export declare const encryptPublic: (data: string) => string;
2
2
  export declare const decryptPrivate: (data: string, privateKeyPath: string) => string;
3
+ export declare const encryptAESStr: (text: string | number, key?: null) => string;
4
+ export declare const decryptAESStr: (text: string, key?: null) => string;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decryptPrivate = exports.encryptPublic = void 0;
3
+ exports.decryptAESStr = exports.encryptAESStr = exports.decryptPrivate = exports.encryptPublic = void 0;
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
6
  const crypto = require("crypto");
7
7
  const process = require("process");
8
8
  const string_util_1 = require("../string.util");
9
+ const crypto_1 = require("crypto");
9
10
  let PUBLIC_KEY = '';
10
11
  const getPublicKey = () => {
11
12
  if (!PUBLIC_KEY) {
@@ -34,4 +35,26 @@ const decryptPrivate = (data, privateKeyPath) => {
34
35
  return decrypted.toString("utf8");
35
36
  };
36
37
  exports.decryptPrivate = decryptPrivate;
38
+ const ALGORITHM = "aes-256-ctr";
39
+ const encryptAESStr = (text, key = null) => {
40
+ const iv = (0, crypto_1.randomBytes)(16);
41
+ const cipher = (0, crypto_1.createCipheriv)(ALGORITHM, key || "ENQudMWJ6AOKyWVTI28291WisR1Cluqb", iv);
42
+ const encrypted = Buffer.concat([cipher.update(`${text}`), cipher.final()]);
43
+ return `${iv.toString("hex")}${encrypted.toString("hex")}`;
44
+ };
45
+ exports.encryptAESStr = encryptAESStr;
46
+ const decryptAESStr = (text, key = null) => {
47
+ if (text.length < 32) {
48
+ throw new Error(`Invalid encrypt string ${text}`);
49
+ }
50
+ const iv = (0, string_util_1.leftString)(text, 32);
51
+ const content = (0, string_util_1.rightString)(text, text.length - 32);
52
+ const decipher = (0, crypto_1.createDecipheriv)(ALGORITHM, key || "ENQudMWJ6AOKyWVTI28291WisR1Cluqb", Buffer.from(iv, "hex"));
53
+ const decrypted = Buffer.concat([
54
+ decipher.update(Buffer.from(content, "hex")),
55
+ decipher.final()
56
+ ]);
57
+ return decrypted.toString();
58
+ };
59
+ exports.decryptAESStr = decryptAESStr;
37
60
  //# sourceMappingURL=crypto.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/crypto/crypto.util.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAgC;AAChC,mCAAmC;AACnC,gDAAuC;AAEvC,IAAI,UAAU,GAAG,EAAE,CAAA;AACnB,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,IAAI,CAAC,UAAU,EAAE;QACf,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAA,qBAAO,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;YACnE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;SACtD;QACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;YAC5C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;SACnD;QACD,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;KAChE;IACD,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAEM,MAAM,aAAa,GAAG,CAC3B,IAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC1D,OAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC;AAPW,QAAA,aAAa,iBAOxB;AAEK,MAAM,cAAc,GAAG,CAC5B,IAAY,EAAE,cAAsB,EACpC,EAAE;IACF,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB"}
1
+ {"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../../../../packages/core/src/lib/util/crypto/crypto.util.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AACzB,iCAAgC;AAChC,mCAAmC;AACnC,gDAAkE;AAClE,mCAAuE;AAEvE,IAAI,UAAU,GAAG,EAAE,CAAA;AACnB,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,IAAI,CAAC,UAAU,EAAE;QACf,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAA,qBAAO,EAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;YACnE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;SACtD;QACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE;YAC5C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;SACnD;QACD,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;KAChE;IACD,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAEM,MAAM,aAAa,GAAG,CAC3B,IAAY,EACZ,EAAE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GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;AAC7D,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB;AAEK,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAG,GAAG,IAAI,EAAE,EAAE;IACxD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;KACnD;IACD,MAAM,EAAE,GAAG,IAAA,wBAAU,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,IAAA,yBAAW,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAA,yBAAgB,EAC/B,SAAS,EACT,GAAG,IAAI,kCAAkC,EACzC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CACvB,CAAC;IACF,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC5C,QAAQ,CAAC,KAAK,EAAE;KACjB,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB"}
@@ -5,3 +5,4 @@ export * from './general.util';
5
5
  export * from './phone.util';
6
6
  export * from './date/index';
7
7
  export * from './performance';
8
+ export * from './crypto/crypto.util';
@@ -8,4 +8,5 @@ tslib_1.__exportStar(require("./general.util"), exports);
8
8
  tslib_1.__exportStar(require("./phone.util"), exports);
9
9
  tslib_1.__exportStar(require("./date/index"), exports);
10
10
  tslib_1.__exportStar(require("./performance"), exports);
11
+ tslib_1.__exportStar(require("./crypto/crypto.util"), exports);
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,2DAAgC;AAChC,wDAA6B;AAC7B,yDAA8B;AAC9B,uDAA4B;AAC5B,uDAA4B;AAC5B,wDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/lib/util/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,2DAAgC;AAChC,wDAA6B;AAC7B,yDAA8B;AAC9B,uDAA4B;AAC5B,uDAA4B;AAC5B,wDAA6B;AAC7B,+DAAoC"}