fix(core): update

This commit is contained in:
Philipp Kunz 2020-06-10 09:21:59 +00:00
parent 9f97bacaf5
commit 4b402a097e
3 changed files with 10 additions and 6 deletions

View File

@ -37,4 +37,4 @@
"npmextra.json",
"readme.md"
]
}
}

View File

@ -38,7 +38,7 @@ tap.test('should receive a message', async () => {
id: '123',
type: 'none'
},
message: 'hi there',
message: 'hi there'
}
});
});

View File

@ -3,7 +3,7 @@ import * as plugins from './sl.receiver.plugins';
import {
ILogPackage,
ILogPackageAuthenticated,
ILogDestination,
ILogDestination
} from '@pushrocks/smartlog-interfaces';
export type TValidatorFunction = (logPackage: ILogPackage) => Promise<boolean>;
@ -24,7 +24,11 @@ export class SmartlogReceiver {
constructor(smartlogReceiverOptions: ISmartlogReceiverOptions) {
this.passphrase = smartlogReceiverOptions.passphrase;
this.validatorFunction = smartlogReceiverOptions.validatorFunction || (async (logpackageArg) => {return true});
this.validatorFunction =
smartlogReceiverOptions.validatorFunction ||
(async logpackageArg => {
return true;
});
this.smartlogInstance = smartlogReceiverOptions.smartlogInstance;
}
@ -36,8 +40,8 @@ export class SmartlogReceiver {
const logPackage = authenticatedLogPackageArg.logPackage;
if (
authString === plugins.smarthash.sha256FromStringSync(this.passphrase)
&& await this.validatorFunction(logPackage)
authString === plugins.smarthash.sha256FromStringSync(this.passphrase) &&
(await this.validatorFunction(logPackage))
) {
// Message authenticated lets clean up.
logPackage.correlation ? null : (logPackage.correlation = { id: '123', type: 'none' });