ztechno_core 0.0.21 → 0.0.22

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.
@@ -20,10 +20,6 @@ export declare class ZCryptoService {
20
20
  salt: string;
21
21
  }
22
22
  ),
23
- ): {
24
- salt: string;
25
- data: string;
26
- hash: string;
27
- };
23
+ ): string;
28
24
  }
29
25
  export {};
@@ -82,14 +82,12 @@ class ZCryptoService {
82
82
  .join('');
83
83
  }
84
84
  let hash = data;
85
- for (let i = 0; i < itt; i++) hash = crypto.createHash(hashAlgorithm).update(hash).digest('hex');
85
+ for (let i = 0; i < itt; i++) {
86
+ hash = crypto.createHash(hashAlgorithm).update(hash).digest('hex');
87
+ }
86
88
  const cut = itt.toString().length + 1;
87
- hash = `${cut}$${hash.substring(cut)}`;
88
- return {
89
- salt,
90
- data,
91
- hash,
92
- };
89
+ hash = `${itt}$${hash.substring(cut)}`;
90
+ return hash;
93
91
  }
94
92
  }
95
93
  exports.ZCryptoService = ZCryptoService;
@@ -19,6 +19,6 @@ export declare class ZUserService {
19
19
  ensureTableExists(): Promise<void>;
20
20
  register({ name, pass, role, admin }: ZRequiredUserColumns): Promise<void>;
21
21
  auth({ name, pass }: ZUserCredentials): Promise<boolean>;
22
- private saltPass;
22
+ private hashPass;
23
23
  }
24
24
  export {};
@@ -46,7 +46,7 @@ class ZUserService {
46
46
  INSERT INTO \`${this.tableName}\` (name, pass, role, admin)
47
47
  VALUES (?, ?, ?, ?)
48
48
  `,
49
- [name, this.saltPass({ name, pass }), role, admin],
49
+ [name, this.hashPass({ name, pass }), role, admin],
50
50
  );
51
51
  }
52
52
  async auth({ name, pass }) {
@@ -56,14 +56,13 @@ class ZUserService {
56
56
  FROM ${this.tableName}
57
57
  WHERE name=? AND pass=?
58
58
  `,
59
- [name, this.saltPass({ name, pass })],
59
+ [name, this.hashPass({ name, pass })],
60
60
  );
61
61
  return res.length === 1;
62
62
  }
63
- saltPass({ name, pass }) {
63
+ hashPass({ name, pass }) {
64
64
  const salt = name + this.salt;
65
- const { hash } = crypto_service_1.ZCryptoService.hash('sha256', pass, { saltMode: 'simple', salt });
66
- return hash;
65
+ return crypto_service_1.ZCryptoService.hash('sha256', pass, { saltMode: 'simple', salt });
67
66
  }
68
67
  }
69
68
  exports.ZUserService = ZUserService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",