namirasoft-node 1.4.19 → 1.4.21

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,28 +1,28 @@
1
- import * as express from 'express';
2
- import { ConvertService, ObjectService } from 'namirasoft-core';
3
-
4
- export class RequestHeaderService extends ConvertService
5
- {
6
- private req: express.Request;
7
- private name: string;
8
- constructor(req: express.Request, name: string, mandatory: boolean = false)
9
- {
10
- super(mandatory);
11
- this.req = req;
12
- this.name = name;
13
- }
14
- override getNullString()
15
- {
16
- if (this.req)
17
- if (this.req.headers)
18
- {
19
- let item = this.req.headers[this.name];
20
- return new ObjectService(item).getNullString();
21
- }
22
- return null;
23
- }
24
- protected override onMandatoryError(): void
25
- {
26
- throw new Error(`Request Header value was not provided: ${this.name}`);
27
- }
1
+ import * as express from 'express';
2
+ import { ConvertService, ObjectService } from 'namirasoft-core';
3
+
4
+ export class RequestHeaderService extends ConvertService
5
+ {
6
+ private req: express.Request;
7
+ private name: string;
8
+ constructor(req: express.Request, name: string, mandatory: boolean = false)
9
+ {
10
+ super(mandatory);
11
+ this.req = req;
12
+ this.name = name;
13
+ }
14
+ override getNullString()
15
+ {
16
+ if (this.req)
17
+ if (this.req.headers)
18
+ {
19
+ let item = this.req.headers[this.name];
20
+ return new ObjectService(item).getNullString();
21
+ }
22
+ return null;
23
+ }
24
+ protected override onMandatoryError(): void
25
+ {
26
+ throw new Error(`Request Header value was not provided: ${this.name}`);
27
+ }
28
28
  }
@@ -1,27 +1,27 @@
1
- import { BaseEmailService } from './BaseEmailService';
2
-
3
- export class SMTPService extends BaseEmailService
4
- {
5
- host: string;
6
- port: number;
7
- password: string;
8
- constructor(host: string, port: number, username: string, password: string)
9
- {
10
- super(username);
11
- this.host = host;
12
- this.port = port;
13
- this.password = password;
14
- }
15
- protected override getTransform(): any
16
- {
17
- return {
18
- host: this.host,
19
- port: this.port,
20
- secure: true,
21
- auth: {
22
- user: this.username,
23
- pass: this.password
24
- }
25
- };
26
- }
1
+ import { BaseEmailService } from './BaseEmailService';
2
+
3
+ export class SMTPService extends BaseEmailService
4
+ {
5
+ host: string;
6
+ port: number;
7
+ password: string;
8
+ constructor(host: string, port: number, username: string, password: string)
9
+ {
10
+ super(username);
11
+ this.host = host;
12
+ this.port = port;
13
+ this.password = password;
14
+ }
15
+ protected override getTransform(): any
16
+ {
17
+ return {
18
+ host: this.host,
19
+ port: this.port,
20
+ secure: true,
21
+ auth: {
22
+ user: this.username,
23
+ pass: this.password
24
+ }
25
+ };
26
+ }
27
27
  }
@@ -1,24 +1,24 @@
1
- import * as express from 'express';
2
- import { ErrorOperation, HashOperation } from "namirasoft-core";
3
- import { RequestHeaderService } from './RequestHeaderService';
4
-
5
- export class ServerToServerOperation
6
- {
7
- static isValid(sign_key: string, data: any, req: express.Request, sign_header: string): boolean
8
- {
9
- let signature = new RequestHeaderService(req, sign_header).getString();
10
- return HashOperation.isValidSHA256Secret(sign_key, data, signature);
11
- }
12
- static check(sign_key: string, data: any, req: express.Request, sign_header: string): void
13
- {
14
- if (!sign_key)
15
- ErrorOperation.throwHTTP(401, "Invlid signature - No sign key.");
16
- if (!sign_header)
17
- ErrorOperation.throwHTTP(401, "Invlid signature - No sign header name.");
18
- let signature = new RequestHeaderService(req, sign_header).getString();
19
- if (!signature)
20
- ErrorOperation.throwHTTP(401, "Invlid signature - No signature.");
21
- if (!this.isValid(sign_key, data, req, sign_header))
22
- ErrorOperation.throwHTTP(401, "Invlid signature.");
23
- }
1
+ import * as express from 'express';
2
+ import { ErrorOperation, HashOperation } from "namirasoft-core";
3
+ import { RequestHeaderService } from './RequestHeaderService';
4
+
5
+ export class ServerToServerOperation
6
+ {
7
+ static isValid(sign_key: string, data: any, req: express.Request, sign_header: string): boolean
8
+ {
9
+ let signature = new RequestHeaderService(req, sign_header).getString();
10
+ return HashOperation.isValidSHA256Secret(sign_key, data, signature);
11
+ }
12
+ static check(sign_key: string, data: any, req: express.Request, sign_header: string): void
13
+ {
14
+ if (!sign_key)
15
+ ErrorOperation.throwHTTP(401, "Invlid signature - No sign key.");
16
+ if (!sign_header)
17
+ ErrorOperation.throwHTTP(401, "Invlid signature - No sign header name.");
18
+ let signature = new RequestHeaderService(req, sign_header).getString();
19
+ if (!signature)
20
+ ErrorOperation.throwHTTP(401, "Invlid signature - No signature.");
21
+ if (!this.isValid(sign_key, data, req, sign_header))
22
+ ErrorOperation.throwHTTP(401, "Invlid signature.");
23
+ }
24
24
  }
package/src/index.ts CHANGED
@@ -1,17 +1,17 @@
1
- export * from "./AnomalyDetector";
2
- export * from "./BaseApplication";
3
- export * from "./BaseApplicationLink";
4
- export * from "./BaseController";
5
- export * from "./BaseCron";
6
- export * from "./BaseDatabase";
7
- export * from "./BaseEmailService";
8
- export * from "./BaseTable";
9
- export * from "./CommandOperation";
10
- export * from "./EmptyDatabase";
11
- export * from "./GmailService";
12
- export * from "./IPOperation";
13
- export * from "./Meta";
14
- export * from "./OTPOperation";
15
- export * from "./RequestHeaderService";
16
- export * from "./ServerToServerOperation";
1
+ export * from "./AnomalyDetector";
2
+ export * from "./BaseApplication";
3
+ export * from "./BaseApplicationLink";
4
+ export * from "./BaseController";
5
+ export * from "./BaseCron";
6
+ export * from "./BaseDatabase";
7
+ export * from "./BaseEmailService";
8
+ export * from "./BaseTable";
9
+ export * from "./CommandOperation";
10
+ export * from "./EmptyDatabase";
11
+ export * from "./GmailService";
12
+ export * from "./IPOperation";
13
+ export * from "./Meta";
14
+ export * from "./OTPOperation";
15
+ export * from "./RequestHeaderService";
16
+ export * from "./ServerToServerOperation";
17
17
  export * from "./SMTPService";