6 Commits

Author SHA1 Message Date
bc8bf48679 3.0.2 2023-01-09 16:38:10 +01:00
ef06e465cb fix(core): update 2023-01-09 16:38:09 +01:00
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
16 changed files with 4410 additions and 11322 deletions

View File

@ -12,6 +12,9 @@ stages:
- release - release
- metadata - metadata
before_script:
- npm install -g @shipzone/npmci
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
@ -36,6 +39,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
allow_failure: true
auditDevDependencies: auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
@ -96,10 +100,9 @@ codequality:
only: only:
- tags - tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker
@ -119,11 +122,10 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install lts - npmci node install stable
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command npm run buildDocs
tags: tags:
- lossless - lossless
- docker - 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", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${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"
} }
] ]
} }

View File

View File

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

11240
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

4347
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,31 @@
import { tap, expect } from '@pushrocks/tapbundle'; 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 () => { tap.test('sha256FromStringSync should convert a String to sha256 hash synchronously', async () => {
const testHash = smarthash.sha256FromStringSync('test'); const testHash = smarthash.sha256FromStringSync('test');
const testHash2 = smarthash.sha256FromStringSync('testString'); const testHash2 = smarthash.sha256FromStringSync('testString');
const testHash3 = smarthash.sha256FromStringSync('test'); const testHash3 = smarthash.sha256FromStringSync('test');
expect(testHash).to.equal(testHash3); expect(testHash).toEqual(testHash3);
expect(testHash).to.not.equal('test'); expect(testHash).not.toEqual('test');
}); });
tap.test('sha256fromStringSync should convert a String to sha256 hash synchronously', async () => { tap.test('sha256fromStringSync should convert a String to sha256 hash synchronously', async () => {
const resultString = await smarthash.sha256FromString('test'); const resultString = await smarthash.sha256FromString('test');
const compareString = smarthash.sha256FromStringSync('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) => { tap.test('sha256fromStream should convert a Stream to sha256', async (tools) => {
const readStream = fs.createReadStream('./test/testImageForHash.jpg'); const readStream = fs.createReadStream('./test/testImageForHash.jpg');
const resultString: string = await smarthash.sha256FromStream(readStream); 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 () => { tap.test('sha256fromFile should convert a Stream to sha256', async () => {
const resultString = await smarthash.sha256FromFile('./test/testImageForHash.jpg'); 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 () => { tap.test('should produce reproducible hash from Object', async () => {
@ -43,13 +43,13 @@ tap.test('should produce reproducible hash from Object', async () => {
wow: 'twoe', wow: 'twoe',
hithere: 1, hithere: 1,
}); });
expect(hash1).to.equal(hash2); expect(hash1).toEqual(hash2);
expect(hash1).to.not.equal(hash3); expect(hash1).not.toEqual(hash3);
}); });
tap.test('should create md5hash from string', async () => { tap.test('should create md5hash from string', async () => {
const md5Hash = await smarthash.md5FromString('hellothere'); const md5Hash = await smarthash.md5FromString('hellothere');
expect(md5Hash).to.equal('c6f7c372641dd25e0fddf0215375561f'); expect(md5Hash).toEqual('c6f7c372641dd25e0fddf0215375561f');
}); });
tap.start(); 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.2',
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.sha256.js';
export * from './nodehash.md5'; 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) => { export const hashStreamPipeStop = (resolveFunctionArg: (inputArg: string) => any) => {
const forEach = (chunk: Buffer, enc, cb) => { const forEach = (chunk: Buffer, enc: any, cb: any) => {
resolveFuntion(chunk.toString('utf8')); resolveFunctionArg(chunk.toString('utf8'));
cb(null, chunk); cb(null, chunk);
}; };
const atEnd = (cb) => { const atEnd = (cb: any) => {
cb(); 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) => { export const md5FromString = async (stringToHash: string) => {
return plugins.crypto.createHash('md5').update(stringToHash).digest('hex'); return plugins.crypto.createHash('md5').update(stringToHash).digest('hex');

View File

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

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

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"
}