Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

namirasoft-core

Package Overview
Dependencies
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

namirasoft-core - npm Package Compare versions

Comparing version 1.2.9 to 1.2.10

4

dist/BaseServer.js

@@ -17,3 +17,3 @@ "use strict";

const axios_1 = __importDefault(require("axios"));
const SignOperation_1 = require("./SignOperation");
const HashOperation_1 = require("./HashOperation");
const URLOperation_1 = require("./URLOperation");

@@ -36,3 +36,3 @@ const ErrorOperation_1 = require("./ErrorOperation");

if (config === null || config === void 0 ? void 0 : config.headers)
config.headers[sign_header] = SignOperation_1.SignOperation.sign(sign_key, data);
config.headers[sign_header] = HashOperation_1.HashOperation.sha256Secret(sign_key, data);
try {

@@ -39,0 +39,0 @@ this.onBeforeRequest(url, config);

export declare class HashOperation {
static sha256<T>(message: T): string;
static sha256Secret<T>(secret: string, message: T): string;
static sha256<T>(message: T): string;
static isValid(values: any, signature: string): boolean;
static isValidSecret(secret: string, values: any, signature: string): boolean;
}

@@ -29,14 +29,20 @@ "use strict";

class HashOperation {
static sha256Secret(secret, message) {
const hash = crypto.createHmac('sha256', secret);
static sha256(message) {
const hash = crypto.createHash('sha256');
hash.update(JSON.stringify(message));
return hash.digest('hex');
}
static sha256(message) {
const hash = crypto.createHash('sha256');
static sha256Secret(secret, message) {
const hash = crypto.createHmac('sha256', secret);
hash.update(JSON.stringify(message));
return hash.digest('hex');
}
static isValid(values, signature) {
return this.sha256(values).toLowerCase() === signature.toLowerCase();
}
static isValidSecret(secret, values, signature) {
return this.sha256Secret(secret, values).toLowerCase() === signature.toLowerCase();
}
}
exports.HashOperation = HashOperation;
//# sourceMappingURL=HashOperation.js.map

@@ -21,3 +21,2 @@ export * from "./BaseDatabaseRow";

export * from "./PhoneOperation";
export * from "./SignOperation";
export * from "./StringOperation";

@@ -24,0 +23,0 @@ export * from "./TimeOperation";

@@ -37,3 +37,2 @@ "use strict";

__exportStar(require("./PhoneOperation"), exports);
__exportStar(require("./SignOperation"), exports);
__exportStar(require("./StringOperation"), exports);

@@ -40,0 +39,0 @@ __exportStar(require("./TimeOperation"), exports);

{
"name": "namirasoft-core",
"description": "Namira Software Corporation Core NPM Package",
"version": "1.2.9",
"version": "1.2.10",
"main": "./dist/index.js",

@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts",

import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
import { SignOperation } from "./SignOperation";
import { HashOperation } from "./HashOperation";
import { URLOperation } from "./URLOperation";

@@ -26,3 +26,3 @@ import { ErrorOperation } from "./ErrorOperation";

if (config?.headers)
config.headers[sign_header] = SignOperation.sign(sign_key, data);
config.headers[sign_header] = HashOperation.sha256Secret(sign_key, data);
try

@@ -29,0 +29,0 @@ {

@@ -5,14 +5,22 @@ import * as crypto from 'node:crypto';

{
static sha256Secret<T>(secret: string, message: T): string
static sha256<T>(message: T): string
{
const hash = crypto.createHmac('sha256', secret);
const hash = crypto.createHash('sha256');
hash.update(JSON.stringify(message));
return hash.digest('hex');
}
static sha256<T>(message: T): string
static sha256Secret<T>(secret: string, message: T): string
{
const hash = crypto.createHash('sha256');
const hash = crypto.createHmac('sha256', secret);
hash.update(JSON.stringify(message));
return hash.digest('hex');
}
static isValid(values: any, signature: string)
{
return this.sha256(values).toLowerCase() === signature.toLowerCase();
}
static isValidSecret(secret: string, values: any, signature: string)
{
return this.sha256Secret(secret, values).toLowerCase() === signature.toLowerCase();
}
}

@@ -21,3 +21,2 @@ export * from "./BaseDatabaseRow";

export * from "./PhoneOperation";
export * from "./SignOperation";
export * from "./StringOperation";

@@ -24,0 +23,0 @@ export * from "./TimeOperation";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc