ztechno_core 0.0.42 → 0.0.44

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,4 +1,4 @@
1
- import { HashStruct } from './typings/crypto_service';
1
+ import { HashStruct } from './typings/crypto_types';
2
2
  export declare class ZCryptoService {
3
3
  static encrypt(text: string): HashStruct;
4
4
  static decrypt(data: HashStruct): string;
package/lib/index.d.ts CHANGED
@@ -4,14 +4,14 @@ import { ZMailService } from './mail_service';
4
4
  import { ZSqlService } from './sql_service';
5
5
  import { ZTranslateService } from './translate_service';
6
6
  import { ZUserService } from './user_service';
7
- export { HashStruct } from './typings/crypto_service';
7
+ export { HashStruct } from './typings/crypto_types';
8
8
  export {
9
9
  MailOptions,
10
10
  MailOptionsBase,
11
11
  MailOptionsHtml,
12
12
  MailOptionsText,
13
13
  MailServiceOptions,
14
- } from './typings/mail_service';
15
- export { TranslateData, ZDom, ZNode, ZNodeText, dbTranslationRow } from './typings/translate_service';
16
- export { ZRequiredUserColumns, ZUser, ZUserCredentials, ZUserSession } from './typings/user_service';
14
+ } from './typings/mail_types';
15
+ export { TranslateData, ZDom, ZNode, ZNodeText, dbTranslationRow } from './typings/translate_types';
16
+ export { ZRequiredUserColumns, ZUser, ZUserCredentials, ZUserSession } from './typings/user_types';
17
17
  export { ZCryptoService, ZMailService, ZSqlService, ZTranslateService, ZUserService, ZEngineBase };
@@ -1,4 +1,4 @@
1
- import { MailOptionsHtml, MailOptionsText, MailServiceOptions } from './typings/mail_service';
1
+ import { MailOptionsHtml, MailOptionsText, MailServiceOptions } from './typings/mail_types';
2
2
  export declare class ZMailService {
3
3
  private opt;
4
4
  constructor(opt: MailServiceOptions);
@@ -0,0 +1,4 @@
1
+ export type HashStruct = {
2
+ iv: string;
3
+ encryptedData: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,22 @@
1
+ export type MailServiceOptions = {
2
+ auth: {
3
+ user: string;
4
+ pass: string;
5
+ };
6
+ mailSender: string;
7
+ };
8
+ export type MailOptionsBase = {
9
+ recipient: string;
10
+ subject: string;
11
+ from?: string;
12
+ };
13
+ export type MailOptionsText = MailOptionsBase & {
14
+ body: string;
15
+ };
16
+ export type MailOptionsHtml = MailOptionsBase & {
17
+ html: string;
18
+ };
19
+ export type MailOptions = MailOptionsBase & {
20
+ body?: string;
21
+ html?: string;
22
+ };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,34 @@
1
+ export type ZDom = {} & ZNode;
2
+ export type ZNode = {
3
+ getAttribute: (attr: string) => string;
4
+ getElementsByTagName: (tag: string) => ZNode[];
5
+ getElementsByClassName: (cls: string) => ZNode[];
6
+ getElementById: (id: string) => ZNode;
7
+ getElementsByName: (name: string) => ZNode[];
8
+ nodeType: string;
9
+ nodeName: string;
10
+ childNodes: ZNode[];
11
+ firstChild: ZNode;
12
+ lastChild: ZNode;
13
+ parentNode: ZNode;
14
+ attributes: any[];
15
+ innerHTML: string;
16
+ outerHTML: string;
17
+ textContent: string;
18
+ text: string;
19
+ };
20
+ export type ZNodeText = {
21
+ text: string;
22
+ } & ZNode;
23
+ export type TranslateData = {
24
+ value: string;
25
+ meta?: {
26
+ prefix: string;
27
+ suffix: string;
28
+ };
29
+ };
30
+ export type dbTranslationRow = {
31
+ lang: string;
32
+ key: string;
33
+ value: string;
34
+ };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,22 @@
1
+ export type ZUser = {
2
+ user_id: number;
3
+ email: string;
4
+ session: string;
5
+ role: string | null;
6
+ admin: 0 | 1;
7
+ updated_at: any;
8
+ created_at: any;
9
+ };
10
+ export type ZRequiredUserColumns = {
11
+ email: string;
12
+ role: string | null;
13
+ pass: string;
14
+ admin: 0 | 1;
15
+ };
16
+ export type ZUserCredentials = {
17
+ email: string;
18
+ pass: string;
19
+ };
20
+ export type ZUserSession = {
21
+ session: string;
22
+ };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,5 +1,5 @@
1
1
  import { ZSqlService } from './sql_service';
2
- import { ZRequiredUserColumns, ZUser, ZUserSession, ZUserCredentials } from './typings/user_service';
2
+ import { ZRequiredUserColumns, ZUser, ZUserSession, ZUserCredentials } from './typings/user_types';
3
3
  export declare class ZUserService {
4
4
  private tableName;
5
5
  private sqlService;
@@ -18,14 +18,14 @@ class ZUserService {
18
18
  }
19
19
  async checkTableHasAdmin() {
20
20
  const res = await this.sqlService.query(`
21
- SELECT id FROM \`${this.tableName}\` WHERE admin=1
21
+ SELECT user_id FROM \`${this.tableName}\` WHERE admin=1
22
22
  `);
23
23
  return res.length > 0;
24
24
  }
25
25
  async createTable() {
26
26
  await this.sqlService.query(`
27
27
  CREATE TABLE \`${this.tableName}\` (
28
- \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
28
+ \`user_id\` int(10) unsigned NOT NULL AUTO_INCREMENT,
29
29
  \`email\` varchar(64) NOT NULL,
30
30
  \`role\` varchar(64) DEFAULT NULL,
31
31
  \`pass\` varchar(512) NOT NULL,
@@ -33,7 +33,7 @@ class ZUserService {
33
33
  \`admin\` tinyint(1) NOT NULL,
34
34
  \`updated_at\` datetime NOT NULL DEFAULT current_timestamp(),
35
35
  \`created_at\` datetime NOT NULL DEFAULT current_timestamp(),
36
- PRIMARY KEY (\`id\`),
36
+ PRIMARY KEY (\`user_id\`),
37
37
  UNIQUE KEY \`email_UNIQUE\` (\`email\`),
38
38
  KEY \`email\` (\`email\`),
39
39
  KEY \`createdat\` (\`created_at\`),
@@ -62,8 +62,8 @@ class ZUserService {
62
62
  async find(opt) {
63
63
  const rows = await this.sqlService.query(
64
64
  `
65
- SELECT id, name, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
66
- WHERE name=?`,
65
+ SELECT user_id, email, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
66
+ WHERE email=?`,
67
67
  [opt.email],
68
68
  );
69
69
  return rows[0];
@@ -75,25 +75,25 @@ class ZUserService {
75
75
  const res = await (opt.session
76
76
  ? this.sqlService.query(
77
77
  `
78
- SELECT id, name, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
78
+ SELECT user_id, email, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
79
79
  WHERE session=?`,
80
80
  [opt.session],
81
81
  )
82
82
  : this.sqlService.query(
83
83
  `
84
- SELECT id, name, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
85
- WHERE name=? AND pass=?`,
84
+ SELECT user_id, email, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
85
+ WHERE email=? AND pass=?`,
86
86
  [opt.email, this.hashPass(opt)],
87
87
  ));
88
88
  return res.length === 0 ? { authenticated: false } : { user: res[0], session: res[0].session, authenticated: true };
89
89
  }
90
- genSession({ email: name }) {
90
+ genSession({ email }) {
91
91
  const salt = this.salt;
92
- const data = name + Date.now() * Math.random();
92
+ const data = email + Date.now() * Math.random();
93
93
  return crypto_service_1.ZCryptoService.hash('sha256', data, { saltMode: 'simple', salt });
94
94
  }
95
95
  hashPass({ email, pass }) {
96
- const salt = name + this.salt;
96
+ const salt = email + this.salt;
97
97
  return crypto_service_1.ZCryptoService.hash('sha256', pass, { saltMode: 'simple', salt });
98
98
  }
99
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",