zemuldo / iso_8583

:credit_card::moneybag: JavaScript library for iso 8583 messaging. Handles message validation & conversion between interfaces using iso 8583 standard. Contributors are welcome.
https://zemuldo.github.io/iso_8583/
MIT License
85 stars 50 forks source link

Secondary Bitmap - exclusion #100

Closed miztli closed 2 years ago

miztli commented 3 years ago

Hi, Zemuldo. First of all, thanks for sharing this useful library, it's been of great help for us.

We've been looking forward for an enhancement, maybe we don't know your initial use case, but we see that library always includes the secondary bitmap, altough all bytes are set to 0 (no fields present from field 65 to 127).

We think we can check for the presence of fields 65 to 127 in the assembleBitmap.js#assembleBitmap function and avoid hardcoding always the presence of the secondary bitmap _map[0] = 1; line 14.

We'll be working on a POC to see how this behaves for us, let us know if you have some feedback.

zemuldo commented 3 years ago

Thank you for the gesture of appreciation. It means a lot for me. This is a generic library for ISO 8583 and my initial usecase was to connect to a Postilion Post-Bridge interface.

I see your point, I will have a look at the line you mentioned and see what we can do. I think this can be made configurable so that when these fields are absent, you can choose to always not include the secondary bitmap.

csvdf commented 2 years ago

Hi zemuldo, First of all, thanks for producing a very useful library, been trying it for a proof of concept and its been useful. I am also running into this issue above, where the optional Secondary bitmap is always being added. Have you looked into this issue any further? Thanks

zemuldo commented 2 years ago

Hi, I have a branch that I can push for you to test. Does make the library configurable to exclude the secondary bitmap seem like a solution that can work for you? In this case when initialising there would be a way to pass that in the init config object. Let me know if this will work for you.

csvdf commented 2 years ago

Hi, I think being able to pass in configuration should work. Let me try it out when you have a branch available, Thanks

zemuldo commented 2 years ago

I have tried something that looks like this

let isopack = new Main(data);
isopack.optionalSecondaryBitmap = true;

After the second line, packaging a message that results without any of field 64-128 will have no secondary bitmap. Also calling unpack on a buffer message that has 0 on the first value of primary bitmap will also be treated without secondary bitmap.

One part of this unpacking part existed before and this seems like a bug. The flag is for backward compatibility on someone using the library with the bug. Let me know what you think.

zemuldo commented 2 years ago

@csvdf check this change and see if it solves the problem. The branch is on https://github.com/zemuldo/iso_8583/pull/113

zemuldo commented 2 years ago

Merged

csvdf commented 2 years ago

Hi, just checking if this was added to a release build yet?