skokov3812 / encrypted-smiley-secure-protocol Goto Github PK
View Code? Open in Web Editor NEWNode.JS library Encrypted Smiley ® Secure Protocol (eSSP, SSP)
License: MIT License
Node.JS library Encrypted Smiley ® Secure Protocol (eSSP, SSP)
License: MIT License
I have 2 devices connected with the module. Each one has an object with a different port. They should work separately, however, after a while with both devices enabled, one of them start getting sequence count numbers (like ACKs) totally random (even negative numbers) so the communication fails.
Also, if I duplicate the module locally and use each copy for each device it works perfectly. I guess there's some kind of interference.
Thank you for this module and keep working. Nice work!
Best Regards,
Iago Loureiro.
Hey is it possible to do another NPM release for this package?
The one currently on npm failed to build on node 17 but the git one works just fine.
Hi @skokov3812!
I see that you are not very active in development of this project. Would be nce if you could allow automated releases using semantic-release and Circle CI when changes are made to the main branch. Another option to add me as contributor on NPM or transfer repository to me, or public organization at github.
I appreciate your investment in this project! Thanks
Had a crash happen while accepting bills. My program isn't too different from the one in the example, it's slightly modified.
/home/siren/projects/nv10d/node_modules/encrypted-smiley-secure-protocol/src/utils.js:236
result.info.name = rejectNote[data[0]].name;
^
TypeError: Cannot read properties of undefined (reading 'name')
at parseData (/home/siren/projects/nv10d/node_modules/encrypted-smiley-secure-protocol/src/utils.js:236:46)
at SSP.parsePacket (/home/siren/projects/nv10d/node_modules/encrypted-smiley-secure-protocol/src/index.js:218:24)
at EventEmitter.<anonymous> (/home/siren/projects/nv10d/node_modules/encrypted-smiley-secure-protocol/src/index.js:172:24)
at Object.onceWrapper (node:events:633:26)
at EventEmitter.emit (node:events:518:28)
at ESSPProtocolParser.<anonymous> (/home/siren/projects/nv10d/node_modules/encrypted-smiley-secure-protocol/src/index.js:58:27)
at ESSPProtocolParser.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushObjectMode (node:internal/streams/readable:536:3)
at Readable.push (node:internal/streams/readable:391:5)
Hi, im stuck at this now....
sorry to bother this much
Port opened!
COM <- 7f0001116608 null 0
COM -> 7f0001f0200a SYNC
{ success: true, status: 'OK', command: 'SYNC', info: {} }
COM <- 7f000206061b94 SYNC 0
COM -> 7f0001f0200a HOST_PROTOCOL_VERSION
{ success: true,
status: 'OK',
command: 'HOST_PROTOCOL_VERSION',
info: {} }
TypeError: buffer.writeBigInt64LE is not a function
at int64LE (/home/lab/encrypted-smiley-secure-protocol/src/utils.js:38:10)
at Promise.all.then.then (/home/lab/encrypted-smiley-secure-protocol/src/index.js:102:46)
hello,
new device https://innovative-technology.com/products/products-main/901-nv4000 is now available, with new commands and events. Is there some library update planned?
I tried some changes, but for this new device I have too much TIMEOUT responses while polling, and also device change status to DISABLED in some strange intervals, maybe because of timeouts.
Hi, command GET_ALL_LEVELS does not work well with NV200 (every other time). What can be done? Thanks
Hi,
When sending the SET_DENOMINATION_ROUTE command with the following parameters in protocol version 6, the error PARAMETER_OUT_OF_RANGE is returned
parameters send:
{route: 'payout', value: 2000, country_code: 'EUR'}
Does anyone know what can it be ?
Hi,
Using the SMART Hopper I noticed when I insert a coin, the poll command doesn't retrieve any event but checking the packet, the protocol do retrieve the VALUE_ADDED event. I guess it's pending to implement in the module.
Greetings and Great Job,
Iago Loureiro.
logs for reading note.
logs.txt
as mentioned in #13 issue
We are also having some issues with receiving “stacked” and “note_stored_in_payout” events. We occasionally see them, but most of the time, nothing comes in after the “credit_note” event.
Do you receive “stack” and “note_stored_in_payout” events?
We’ve been unable to correlate this behavior with anything.
I cant find anywhere some documentation in order to handle the nv9usb with a note float.
I would love to implement it but i cant find anything.
Somebody got any luck ?
So far i get this reply at polling:
GO!!!
COM -> 7f00117e8963ee3072f1284823da48d8e0765dfd4d2e POLL
Decrypted: 0207000000f0c6bab3781966ef0406f4
{
success: true,
status: 'OK',
command: 'POLL',
info: [
{
code: 198,
name: 'PAYOUT_OUT_OF_SERVICE',
description: 'This event is given if the payout goes out of service during operation. If this event is detected after a poll, the host can send the ENABLE PAYOUT DEVICE command to determine if the payout unit comes back into service.'
}
]
}
COM <- 7f80117e00fb221cfeba91f5c3f9ca146ae238676208 POLL 7
and yes, i tried to send the command ENABLE_PAYOUT_DEVICE
but i recevie a COMMAND_CANNOT_BE_PROCESSED errorCode 5 error: Device Error
Warning: require() of ES modules is not supported.
require() of /opt/storage/appdir/node_modules/random-prime/index.js from /opt/storage/appdir/node_modules/encrypted-smiley-secure-protocol/index.js is an ES module file as it is a .js
file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /opt/storage/appdir/node_modules/random-prime/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /opt/storage/appdir/no
de_modules/random-prime/package.json.
Getting the ERR_REQUIRE_ESM error when trying to import the module
Code:
`const sspLib = require("encrypted-smiley-secure-protocol");
let eSSP = new sspLib({
id: 0x00,
debug: false,
timeout: 3000,
fixedKey: "0000000000000000",
});
eSSP
.open("COM8")
.then(() => console.log("Device connected!"))
.catch((e) => console.log(Error: ${e}
));`
Error:
internal/modules/cjs/loader.js:1153
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\Coladaclean\Desktop\billetero\node_modules\random-prime\index.js
require() of ES modules is not supported.
require() of C:\Users\Coladaclean\Desktop\billetero\node_modules\random-prime\index.js from C:\Users\Coladaclean\Desktop\billetero\node_modules\encrypted-smiley-secure-protocol\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename C:\Users\Coladaclean\Desktop\billetero\node_modules\random-prime\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\Coladaclean\Desktop\billetero\node_modules\random-prime\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:13)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Coladaclean\Desktop\billetero\node_modules\encrypted-smiley-secure-protocol\index.js:7:21)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14) {
code: 'ERR_REQUIRE_ESM'
}
`COM -> 7f0009f06c9d0000000000003957 REQUEST_KEY_EXCHANGE
{ success: true,
status: 'OK',
command: 'REQUEST_KEY_EXCHANGE',
info: { key: [ 108, 157, 0, 0, 0, 0, 0, 0 ] } }
(node:19451) UnhandledPromiseRejectionWarning: RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds
at boundsError (internal/buffer.js:47:11)
at Buffer.readBigInt64BE (internal/buffer.js:118:5)
at SSP.createHostEncryptionKeys (/home/pi/encrypted-smiley-secure-protocol/src/index.js:243:56)
at SSP.parsePacket (/home/pi/encrypted-smiley-secure-protocol/src/index.js:225:14)
at EventEmitter.eventEmitter.once.buffer (/home/pi/encrypted-smiley-secure-protocol/src/index.js:172:24)
at Object.onceWrapper (events.js:286:20)
at EventEmitter.emit (events.js:198:13)
at ESSPProtocolParser.parser.on.buffer (/home/pi/encrypted-smiley-secure-protocol/src/index.js:58:27)
at ESSPProtocolParser.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
(node:19451) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19451) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
`
If you call several commands or enable function more than once at the same time it will lead to poll cycles multiplying (multiple subscriptions to events). This is a huge problem cause it will multiply events also like CREDIT_NOTE, STACKED_NOTE, etc. Like this, if you use debug:
COM <- 7f00117ef582eff14bd18fdcfe15b71cd043a2eec145 POLL 162
COM <- 7f00117ef582eff14bd18fdcfe15b71cd043a2eec145 POLL 162
COM <- 7f00117ef582eff14bd18fdcfe15b71cd043a2eec145 POLL 162
I will create a pull request.
hi, i have smart hopper and when i set the comand : setup_request
success: true,
status: 'OK',
command: 'SETUP_REQUEST',
info: {
unit_type: undefined,
firmware_version: '1.25',
country_code: 'EUR',
value_multiplier: 60801,
channel_value: Uint8Array(0) [],
channel_security: Uint8Array(0) [],
real_value_multiplier: 131077,
protocol_version: 0
some one can help me thanks
Hi, I am testing with nv11.
I ran the example, it says enabled 'OK' however the bezel does not light up to accept bills. I am able to run the Payout Last note with success and it dispenses but the Payout Amount function returns Command_NOT_KNOWN.
Any help will be great, thanks in advance.
I have implemented the software to monitor the NV9USB+, it seems to work perfectly,
Open and sync per your example, it was installed on windows 10 ( nodejs)
1 I restarted and after could work normally
2 if I shut it down, my code could not enable the device
3 if power is lost, my code could not enable the device.
==> so I have to use the C# sample application to open the connection to the device and enable it , and after I enable it via C# code, there would not be such a problem until the computer was shut down or power lost.
It seems the device could not be properly connected, after 2 and 3 conditions.
Does any one have such a problem?
I have a Smart hopper and everything seems to work, until I insert a coin.
Then i receive a crash in utils.js and I was able to track it to this piece of code: https://github.com/skokov3812/encrypted-smiley-secure-protocol/blob/master/src/utils.js#L376
Error is something like "out of bounds". Looking at chunk variable mine is:
Uint8Array(8) [
223, 200, 0, 0,
0, 66, 71, 78
]
Having: let count = chunk[1];
make next slices to go out of bounds, since there is clearly no 200 items into array.
I can see that 200, 0, 0, 0
is value of coin I insert (200 stotinki), and next is 66, 71, 78
which is BGN.
These values are not from 2 to 6 and from 6 to 9 like in: https://github.com/skokov3812/encrypted-smiley-secure-protocol/blob/master/src/utils.js#L380, but are offset by one i.e. from 1 to 5 and from 5 to 8.
Now the question is: is chunk
wrong or there is something else what I miss?
Hi, the example works fine till the polling. During the polling i get the following message
{
success: true,
status: 'OK',
command: 'POLL',
info: [
{
code: 198,
name: 'PAYOUT_OUT_OF_SERVICE',
description: 'This event is given if the payout goes out of service during operation. If this event is detected after a poll, the host can send the ENABLE PAYOUT DEVICE command to determine if the payout unit comes back into service.'
}
]
}
and the nv9usb+ is not active (do not accept bill).
I tried to send the command ENABLE_PAYOUT_DEVICE without any success
hello,
is escrow functionality implemented? or do you plan to implement it?
as described here.
http://www.marrginal.ru/files/cashmachine/itl/GA973%20SSP%20Implementation%20Guide%20v2.2.pdf
best wishes
D
Hi, first of all thank you for this amazing project.
I have a bit of a problem: all the command return
{ success: false, status: 'KEY_NOT_SET', command: 'ENABLE', info: {} }
the hardware is an NV9USB and here the config of the lib:
let eSSP = new sspLib({ id: 0, debug: true, timeout: 50000, encryptAllCommand: true, fixedKey: '0123456701234567' });
Thank you for your time
Hi,
I detected a documentation error related to GET_DENOMINATION_ROUTE command. In theory it should get some args (I use {value: x, country_code: 'XXX') but that's not documented.
Greetings and great job,
Iago Loureiro.
Im experiencing some issues with this code on linux based systems.
At first, the randomPrime functions not always returns a prime number, that should be a problem?
Also in the debug mode, my routine always ends with a 232 error, as bellow:
Port opened!
COM <- 7f0001116608 SYNC 0
COM -> 7f0001f0200a | RAW
COM -> 7f0001f0200a SYNC
{ success: true, status: 'OK', command: 'SYNC', info: {} }
COM <- 7f000206061b94 HOST_PROTOCOL_VERSION 0
COM -> 7f0001f0200a | RAW
COM -> 7f0001f0200a HOST_PROTOCOL_VERSION
{
success: true,
status: 'OK',
command: 'HOST_PROTOCOL_VERSION',
info: {}
}
COM <- 7f80094a6b000000000000000e36 SET_GENERATOR 0
COM -> 7f8001f02380 | RAW
COM -> 7f8001f02380 SET_GENERATOR
{ success: true, status: 'OK', command: 'SET_GENERATOR', info: {} }
COM <- 7f00094b0d0000000000000012f1 SET_MODULUS 0
COM -> 7f0001 | RAW
COM -> f0200a | RAW
COM -> 7f0001f0200a SET_MODULUS
{ success: true, status: 'OK', command: 'SET_MODULUS', info: {} }
COM <- 7f80094c03000000000000002aa2 REQUEST_KEY_EXCHANGE 0
COM -> 7f8009f0 | RAW
COM -> 0300000000000000a392 | RAW
COM -> 7f8009f00300000000000000a392 REQUEST_KEY_EXCHANGE
{
success: true,
status: 'OK',
command: 'REQUEST_KEY_EXCHANGE',
info: { key: [
3, 0, 0, 0,
0, 0, 0, 0
] }
}
AES encrypt key: 0x67452301674523010300000000000000
{
fixedKey: '0123456701234567',
generatorKey: 107,
modulusKey: 13,
hostRandom: 7,
hostIntKey: Integer { value: 3n },
slaveIntKey: Integer { value: 3n },
key: Integer { value: 3n }
}
COM <- 7f00117e1c9f2e96552714cdfcbee3d62b0467d262b9 GET_SERIAL_NUMBER 0
COM -> 7f00117e9c8eb731 | RAW
COM -> 71f6409317861f65722abccfe82e | RAW
COM -> 7f00117e9c8eb73171f6409317861f65722abccfe82e GET_SERIAL_NUMBER
Decrypted: 0501000000f000022e1c7b7b7b7bf33b
{
success: true,
status: 'OK',
command: 'GET_SERIAL_NUMBER',
info: { serial_number: 142876 }
}
SERIAL NUMBER: 142876
COM <- 7f80117e44563706a4c7e4c38bc5dcb9d99948ed8993 ENABLE 1
COM -> 7f | RAW
COM -> 80117ed44c63ca38461736407d77 | RAW
COM -> fca317c7cf9d94 | RAW
COM -> 7f80117ed44c63ca38461736407d77fca317c7cf9d94 ENABLE
Decrypted: 0102000000f05f5f5f5f5f5f5f5f807a
{ success: true, status: 'OK', command: 'ENABLE', info: {} }
COM <- 7f00117e5eaea6bfb60caf5371c6a4d4bf33e3751239 POLL 2
GO!!!
COM -> 7f00117e | RAW
COM -> a2f98eb266c49e27d5570792999d | RAW
COM -> 43b255fb | RAW
COM -> 7f00117ea2f98eb266c49e27d5570792999d43b255fb POLL
Decrypted: 0303000000f0e8e89898989898988bf0
{
success: true,
status: 'OK',
command: 'POLL',
info: {
code: 232,
name: 'DISABLED',
description: 'The device is not active and unavailable for normal validation functions.'
}
OS: Raspbian/KDE
Device: BV20
Interface: FTDI RS232 YP-05
Can you provide me any information that can lead me to find the problem?
Свяжитесь со мной пожалуйста с помощью telegram https://t.me/Federal7777
Ubuntu 22 node 19.9.0
Hello, sorry to bother you, but I'm really racking my brain, I'm using your code to try to read banknotes from a BV20 bill acceptor, I configure the correct port to which a USB TTL adapter with Tx + RX + GNT correct cables and bill acceptor configured for SSP however I can't make it work, it gives me the timeout message: Port opened!
WITH <- 7f0001116608 null 0
TIMEOUT SYNC
my code .. :
const { SerialPort } = require('serialport');
const sspLib = require('encrypted-smiley-secure-protocol');
//const sspLib = require('./src/index');
letport;
let eSSP;
async function findDevice(vendorId = '067b') {
console.log(" LOG SerialManager Find VENDORID",vendorId);
const ports = await SerialPort.list();
const device = ports.find(port => port.vendorId === vendorId);
console.log(" LOG SerialManager DEVICE",JSON.stringify(device));
return device ? device.path: null;
}
async function setupSSP(devicePath) {
devicePath = '/dev/ttyUSB1';
console.log('LOG SERIAL MANAGER SETUP-SSP DEVICE = .' , devicePath);
if (eSSP) {
console.log('SSP already configured.');
return;
}
eSSP = new sspLib({
id: 0x00,
debug: true,
timeout: 3000,
fixedKey: '0123456701234567',
});
eSSP.on('OPEN', () => {
console.log('SSP open');
});
eSSP.on('NOTE_READ', result => {
console.log('Note read:', result);
// Here you add the read note processing logic
});
eSSP.on('NOTE_REJECTED', result => {
console.log('Note rejected:', result);
});
try {
console.log(">>>>>>>> >>>
THE SYSTEM STOP HERE HERE IS A PROBLEM >>>>>>>>>>>>>>>>>>>>>> >>");
await eSSP.open(devicePath);
console.log("SERIAL MANAGER >> TRY >> THEN OPEN >>");
await eSSP.initEncryption();
console.log("SERIAL MANAGER >> TRY >> BEFORE ENABLE >>");
await eSSP.enable();
} catch (error) {
console.error('Error configuring SSP:', error);
}
}
function closeSSP() {
if (eSSP) {
eSSP.close();
eSSP = null;
}
}
module.exports = { findDevice, setupSSP, closeSSP }; Please help me!
Хотим использовать этот пакет в своём решении для терминалов на Node.js
Хотелось бы периодических релизов и поддержки репозитория.
Могу взять поддержку на себя или помогать. Спасибо!
hi, sorry to bother.
But whenver i try to insert a banknote the software crash. with no errors
Any idea ?
the hardware is an nv9usb+
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.