fix(core): update
This commit is contained in:
parent
57893e6962
commit
b95780976b
76
package-lock.json
generated
76
package-lock.json
generated
@ -100,13 +100,29 @@
|
|||||||
"vinyl-file": "^3.0.0"
|
"vinyl-file": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartlog": {
|
"@pushrocks/smarthash": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog/-/smartlog-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@pushrocks/smarthash/-/smarthash-2.0.0.tgz",
|
||||||
"integrity": "sha512-mMJIu4S+6BxLJLB0+6i+M/UhLqi6mUu+x+h+mO0P24kEBCOUWLBz/bP2S8l9ShGV5BIeVSt6OtyvvJeqvyn/Xg==",
|
"integrity": "sha512-+nxpmemy7Tn5tTRlJKR68HJzFDLVMJQSM/GRzb7wgYPVkjs+zeME4oTV6pn8x3//qFio8C3RdrvsQ1iz+xO/jw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartlog-interfaces": "^1.0.9"
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
|
"@types/through2": "^2.0.33",
|
||||||
|
"through2": "^2.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@pushrocks/smartlog": {
|
||||||
|
"version": "2.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog/-/smartlog-2.0.8.tgz",
|
||||||
|
"integrity": "sha512-fZIzmKye+Lsu7rTH+ILZ1u/jJvrAni9c3udQIgrHXtxyNWd8bROO5GAYsSm8pGWbdawv2hpVoG9qa9yKBUQGJA==",
|
||||||
|
"requires": {
|
||||||
|
"@pushrocks/smartlog-interfaces": "^2.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@pushrocks/smartlog-interfaces": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-49nPRfXT1ZJNY5e23ujysHMDx0yaPMrLBpLtjkGxZRDLIfh1HuohMcGt5aeRhvxooLnM88AOM/2Lg4OltpFDPg=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartlog-interfaces": {
|
"@pushrocks/smartlog-interfaces": {
|
||||||
@ -123,8 +139,7 @@
|
|||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartpromise/-/smartpromise-2.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartpromise/-/smartpromise-2.0.5.tgz",
|
||||||
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==",
|
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@pushrocks/smartrequest": {
|
"@pushrocks/smartrequest": {
|
||||||
"version": "1.1.14",
|
"version": "1.1.14",
|
||||||
@ -212,8 +227,15 @@
|
|||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "10.12.1",
|
"version": "10.12.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.1.tgz",
|
||||||
"integrity": "sha512-i1sl+WCX2OCHeUi9oi7PiCNUtYFrpWhpcx878vpeq/tlZTKzcFdHePlyFHVbWqeuKN0SRPl/9ZFDSTsfv9h7VQ==",
|
"integrity": "sha512-i1sl+WCX2OCHeUi9oi7PiCNUtYFrpWhpcx878vpeq/tlZTKzcFdHePlyFHVbWqeuKN0SRPl/9ZFDSTsfv9h7VQ=="
|
||||||
"dev": true
|
},
|
||||||
|
"@types/through2": {
|
||||||
|
"version": "2.0.34",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/through2/-/through2-2.0.34.tgz",
|
||||||
|
"integrity": "sha512-nhRG8+RuG/L+0fAZBQYaRflXKjTrHOKH8MFTChnf+dNVMxA3wHYYrfj0tztK0W51ABXjGfRCDc0vRkecCOrsow==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@types/vinyl": {
|
"@types/vinyl": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
@ -469,8 +491,7 @@
|
|||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
|
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"deep-eql": {
|
"deep-eql": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
@ -617,8 +638,7 @@
|
|||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"is-utf8": {
|
"is-utf8": {
|
||||||
"version": "0.2.1",
|
"version": "0.2.1",
|
||||||
@ -629,8 +649,7 @@
|
|||||||
"isarray": {
|
"isarray": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"isexe": {
|
"isexe": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -783,14 +802,12 @@
|
|||||||
"process-nextick-args": {
|
"process-nextick-args": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||||
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
|
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"readable-stream": {
|
"readable-stream": {
|
||||||
"version": "2.3.6",
|
"version": "2.3.6",
|
||||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"core-util-is": "~1.0.0",
|
"core-util-is": "~1.0.0",
|
||||||
"inherits": "~2.0.3",
|
"inherits": "~2.0.3",
|
||||||
@ -825,8 +842,7 @@
|
|||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "5.6.0",
|
"version": "5.6.0",
|
||||||
@ -874,7 +890,6 @@
|
|||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "~5.1.0"
|
"safe-buffer": "~5.1.0"
|
||||||
}
|
}
|
||||||
@ -922,6 +937,15 @@
|
|||||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
|
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"through2": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
|
||||||
|
"requires": {
|
||||||
|
"readable-stream": "~2.3.6",
|
||||||
|
"xtend": "~4.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
|
||||||
@ -1000,8 +1024,7 @@
|
|||||||
"util-deprecate": {
|
"util-deprecate": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"vinyl": {
|
"vinyl": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
@ -1045,6 +1068,11 @@
|
|||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"xtend": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||||
|
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||||
|
},
|
||||||
"yn": {
|
"yn": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pushrocks/smarthash": "^2.0.0",
|
||||||
|
"@pushrocks/smartlog": "^2.0.8",
|
||||||
"@pushrocks/smartlog-interfaces": "^1.0.15"
|
"@pushrocks/smartlog-interfaces": "^1.0.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
34
test/test.ts
34
test/test.ts
@ -1,10 +1,40 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
import * as smarthash from '@pushrocks/smarthash';
|
||||||
|
|
||||||
import * as smartlogReceiver from '../ts/index';
|
import * as smartlogReceiver from '../ts/index';
|
||||||
|
|
||||||
let testReceiver: smartlogReceiver.SmartlogReceiver;
|
let testReceiver: smartlogReceiver.SmartlogReceiver;
|
||||||
|
let testSmartlog = smartlog.defaultLogger;
|
||||||
|
testSmartlog.enableConsole();
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('should create a valid SmartlogReceiver', async () => {
|
||||||
testReceiver = new smartlogReceiver.SmartlogReceiver();
|
testReceiver = new smartlogReceiver.SmartlogReceiver({
|
||||||
|
passphrase: 'hi',
|
||||||
|
smartlogInstance: testSmartlog,
|
||||||
|
validatorFunction: () => {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(testReceiver).to.be.instanceof(smartlogReceiver.SmartlogReceiver);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should receive a message', async () => {
|
||||||
|
testReceiver.handleAuthenticatedLog({
|
||||||
|
auth: smarthash.sha256FromStringSync('hi'),
|
||||||
|
logPackage: {
|
||||||
|
logContext: {
|
||||||
|
company: 'Lossless GmbH',
|
||||||
|
companyunit: 'Lossless Cloud',
|
||||||
|
containerName: null,
|
||||||
|
environment: 'staging',
|
||||||
|
runtime: 'node',
|
||||||
|
zone: 'gitzone'
|
||||||
|
},
|
||||||
|
logLevel: 'info',
|
||||||
|
message: 'hi there'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1,13 +1,44 @@
|
|||||||
import * as plugins from './sl.receiver.plugins';
|
import * as plugins from './sl.receiver.plugins';
|
||||||
|
|
||||||
import { ILogPackage, ILogPackageAuthenticated } from '@pushrocks/smartlog-interfaces';
|
import { ILogPackage, ILogPackageAuthenticated, ILogDestination } from '@pushrocks/smartlog-interfaces';
|
||||||
|
|
||||||
|
export type TValidatorFunction = () => boolean;
|
||||||
|
|
||||||
|
export interface ISmartlogReceiverOptions {
|
||||||
|
smartlogInstance: plugins.smartlog.Smartlog;
|
||||||
|
passphrase: string;
|
||||||
|
validatorFunction: TValidatorFunction;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a class that receives smartlog packages
|
* a class that receives smartlog packages
|
||||||
*/
|
*/
|
||||||
export class SmartlogReceiver {
|
export class SmartlogReceiver {
|
||||||
|
passphrase: string;
|
||||||
|
validatorFunction: TValidatorFunction;
|
||||||
|
smartlogInstance: plugins.smartlog.Smartlog;
|
||||||
|
|
||||||
|
constructor(smartlogReceiverOptions: ISmartlogReceiverOptions) {
|
||||||
|
this.passphrase = smartlogReceiverOptions.passphrase;
|
||||||
|
this.validatorFunction = smartlogReceiverOptions.validatorFunction;
|
||||||
|
this.smartlogInstance = smartlogReceiverOptions.smartlogInstance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handles a authenticated log
|
* handles a authenticated log
|
||||||
*/
|
*/
|
||||||
private handleAuthenticatedLog(authenticatedLogArg) {}
|
handleAuthenticatedLog(authenticatedLogPackageArg: ILogPackageAuthenticated) {
|
||||||
|
const authString = authenticatedLogPackageArg.auth;
|
||||||
|
const logPackage = authenticatedLogPackageArg.logPackage;
|
||||||
|
|
||||||
|
if(authString === plugins.smarthash.sha256FromStringSync(this.passphrase)) {
|
||||||
|
this.smartlogInstance.log('ok', 'Message accepted');
|
||||||
|
this.smartlogInstance
|
||||||
|
} else {
|
||||||
|
this.smartlogInstance.log('error', 'Message rejected because of bad passphrase');
|
||||||
|
// console.log(plugins.smarthash.sha256FromStringSync(this.passphrase));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
const removeme = {};
|
import * as smarthash from '@pushrocks/smarthash';
|
||||||
export { removeme };
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartlog,
|
||||||
|
smarthash
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user