4 Commits

Author SHA1 Message Date
e3eca5528d 3.0.1 2022-06-26 11:37:08 +02:00
d43f568795 fix(core): update 2022-06-26 11:37:07 +02:00
85f2cc4745 3.0.0 2022-06-26 11:34:09 +02:00
143eef8781 BREAKING CHANGE(core): switch to esm 2022-06-26 11:34:09 +02:00
14 changed files with 8726 additions and 9066 deletions

View File

@ -12,6 +12,9 @@ stages:
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
@ -36,6 +39,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
@ -96,10 +100,9 @@ codequality:
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
@ -119,11 +122,10 @@ trigger:
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
- npmci command npm run buildDocs
tags:
- lossless
- docker

4
.snyk
View File

@ -1,4 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.3
ignore: {}
patch: {}

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smarthash",
"shortDescription": "simplifies access to node hash functions",
"description": "simplifies access to node hash functions",
"npmPackagename": "@pushrocks/smarthash",
"license": "MIT"
}

17657
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,14 @@
{
"name": "@pushrocks/smarthash",
"version": "2.1.10",
"version": "3.0.1",
"private": false,
"description": "simplified access to node hash functions",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"keywords": [
"pushrocks",
@ -21,17 +22,15 @@
"author": "Lossless GmbH",
"license": "MIT",
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^14.14.31",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
"@gitzone/tsbuild": "^2.1.63",
"@gitzone/tsrun": "^1.2.37",
"@gitzone/tstest": "^1.0.71",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^18.0.0"
},
"dependencies": {
"@pushrocks/smartjson": "^4.0.6",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartjson": "^5.0.1",
"@pushrocks/smartpromise": "^3.1.7",
"@types/through2": "^2.0.36",
"through2": "^4.0.2"
},
@ -49,5 +48,6 @@
],
"browserslist": [
"last 1 chrome versions"
]
],
"type": "module"
}

View File

@ -1,31 +1,31 @@
import { tap, expect } from '@pushrocks/tapbundle';
import fs = require('fs');
import * as fs from 'fs';
import * as smarthash from '../ts/index';
import * as smarthash from '../ts/index.js';
tap.test('sha256FromStringSync should convert a String to sha256 hash synchronously', async () => {
const testHash = smarthash.sha256FromStringSync('test');
const testHash2 = smarthash.sha256FromStringSync('testString');
const testHash3 = smarthash.sha256FromStringSync('test');
expect(testHash).to.equal(testHash3);
expect(testHash).to.not.equal('test');
expect(testHash).toEqual(testHash3);
expect(testHash).not.toEqual('test');
});
tap.test('sha256fromStringSync should convert a String to sha256 hash synchronously', async () => {
const resultString = await smarthash.sha256FromString('test');
const compareString = smarthash.sha256FromStringSync('test');
expect(resultString).to.equal(compareString);
expect(resultString).toEqual(compareString);
});
tap.test('sha256fromStream should convert a Stream to sha256', async (tools) => {
const readStream = fs.createReadStream('./test/testImageForHash.jpg');
const resultString: string = await smarthash.sha256FromStream(readStream);
expect(resultString).to.equal('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
expect(resultString).toEqual('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
});
tap.test('sha256fromFile should convert a Stream to sha256', async () => {
const resultString = await smarthash.sha256FromFile('./test/testImageForHash.jpg');
expect(resultString).to.equal('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
expect(resultString).toEqual('45b80413ed93acb495691186ce61850449439f9183352b9bff96d5533fa1046c');
});
tap.test('should produce reproducible hash from Object', async () => {
@ -43,13 +43,13 @@ tap.test('should produce reproducible hash from Object', async () => {
wow: 'twoe',
hithere: 1,
});
expect(hash1).to.equal(hash2);
expect(hash1).to.not.equal(hash3);
expect(hash1).toEqual(hash2);
expect(hash1).not.toEqual(hash3);
});
tap.test('should create md5hash from string', async () => {
const md5Hash = await smarthash.md5FromString('hellothere');
expect(md5Hash).to.equal('c6f7c372641dd25e0fddf0215375561f');
expect(md5Hash).toEqual('c6f7c372641dd25e0fddf0215375561f');
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smarthash',
version: '3.0.1',
description: 'simplified access to node hash functions'
}

View File

@ -1,4 +1,4 @@
import * as plugins from './nodehash.plugins';
import * as plugins from './nodehash.plugins.js';
export * from './nodehash.sha256';
export * from './nodehash.md5';
export * from './nodehash.sha256.js';
export * from './nodehash.md5.js';

View File

@ -1,12 +1,12 @@
import * as plugins from './nodehash.plugins';
import * as plugins from './nodehash.plugins.js';
export const hashStreamPipeStop = (resolveFuntion) => {
const forEach = (chunk: Buffer, enc, cb) => {
resolveFuntion(chunk.toString('utf8'));
export const hashStreamPipeStop = (resolveFunctionArg: (inputArg: string) => any) => {
const forEach = (chunk: Buffer, enc: any, cb: any) => {
resolveFunctionArg(chunk.toString('utf8'));
cb(null, chunk);
};
const atEnd = (cb) => {
const atEnd = (cb: any) => {
cb();
};

View File

@ -1,4 +1,4 @@
import * as plugins from './nodehash.plugins';
import * as plugins from './nodehash.plugins.js';
export const md5FromString = async (stringToHash: string) => {
return plugins.crypto.createHash('md5').update(stringToHash).digest('hex');

View File

@ -1,5 +1,5 @@
import * as plugins from './nodehash.plugins';
import * as helpers from './nodehash.helpers';
import * as plugins from './nodehash.plugins.js';
import * as helpers from './nodehash.helpers.js';
/**
* creates sha256 Hash from Stream
@ -56,7 +56,7 @@ export const sha256FromBuffer = async (bufferArg: Buffer): Promise<string> => {
* computes sha265 Hash from Object
*/
export const sha265FromObject = async (objectArg: any): Promise<string> => {
const stringifiedObject = plugins.smartjson.stringify(objectArg, {});
const stringifiedObject = plugins.smartjson.stringify(objectArg);
const hashResult = await sha256FromString(stringifiedObject);
return hashResult;
};

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}