@konplit-services/common 1.0.321 → 1.0.322

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.
@@ -27,9 +27,18 @@ export interface TRANSACTION_JWT_DATA {
27
27
  iat?: string;
28
28
  exp?: number;
29
29
  }
30
+ export interface SUBSCRIPTION_JWT_DATA {
31
+ subscriptionId: string;
32
+ merchantId: string;
33
+ usage: Usage;
34
+ iat?: string;
35
+ exp?: number;
36
+ }
30
37
  export declare class JWT {
31
38
  static getToken(data: JWT_Data, options?: SignOptions): Promise<string>;
32
39
  static verifyToken(token: string): Promise<JWT_Data>;
33
40
  static getTransactionToken(data: TRANSACTION_JWT_DATA, options?: SignOptions): Promise<string>;
34
41
  static verifyTransactionToken(token: string): Promise<TRANSACTION_JWT_DATA>;
42
+ static getSubscriptionToken(data: SUBSCRIPTION_JWT_DATA, options?: SignOptions): Promise<string>;
43
+ static verifySubscriptionToken(token: string): Promise<SUBSCRIPTION_JWT_DATA>;
35
44
  }
@@ -23,6 +23,7 @@ var JWTType;
23
23
  })(JWTType = exports.JWTType || (exports.JWTType = {}));
24
24
  const secret = process.env.JWT_KEY;
25
25
  const transactionSecret = process.env.TRANSACTION_JWT_KEY;
26
+ const subscriptionSecret = process.env.SUBSCRIPTION_JWT_KEY;
26
27
  class JWT {
27
28
  static getToken(data, options = {}) {
28
29
  return __awaiter(this, void 0, void 0, function* () {
@@ -56,5 +57,21 @@ class JWT {
56
57
  });
57
58
  });
58
59
  }
60
+ static getSubscriptionToken(data, options = {}) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ return signAsync(data, subscriptionSecret, options);
63
+ });
64
+ }
65
+ static verifySubscriptionToken(token) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ return new Promise((resolve, reject) => {
68
+ jsonwebtoken_1.default.verify(token, subscriptionSecret, function (err, decoded) {
69
+ if (err)
70
+ reject(err);
71
+ resolve(decoded);
72
+ });
73
+ });
74
+ });
75
+ }
59
76
  }
60
77
  exports.JWT = JWT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.321",
3
+ "version": "1.0.322",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "./build/index.d.ts",