Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subfield data element management #46

Open
scalpovich opened this issue Dec 5, 2019 · 11 comments
Open

subfield data element management #46

scalpovich opened this issue Dec 5, 2019 · 11 comments

Comments

@scalpovich
Copy link

Hi Igor,
It's possible to manage subfields as tag for some data element?
For exemple, field 55 contain many subfields with specific length and format.

FLD           | LENTGH    | VALUE
FLD (055) : (101) :                                                                       .
	> TAG (82  ) ....: [3C00]                                                             .
	> TAG (9F33) ....: [E0F8C8]                                                           .
	> TAG (95  ) ....: [0080008000]

Kindly assist

@juks
Copy link
Owner

juks commented Dec 6, 2019

Hi!
What do you mean by "managing"? A callback function?

@scalpovich
Copy link
Author

Hi,
Something like way to define each subfields as you implemented for ISO fields fields before packing the iso message .
Cause according to somes host specifications for VISA or others there as some subfields by each fields like fields 48, fields 55 etc...

juks added a commit that referenced this issue Dec 8, 2019
@juks
Copy link
Owner

juks commented Dec 8, 2019

Well, made an improvement.

Two new methods to mind:

  1. Before the whole packet is packed:
  2. Before each field is packed:
    beforePack: function(fieldValue) {

@scalpovich
Copy link
Author

Hi igor.
thanks for your feedback.
I'm afraid to not understand your implementation.
Kindly provide an use case for exploitation. I mean an example for field 55

@juks
Copy link
Owner

juks commented Dec 9, 2019

You should do like so for the field definition:

  '55': {
    length: 255,
    name:   'EMV Data',
    type:   'll-bin-char',
    alias:  '',
    beforePack: function(fieldValue) {
        // Work with tags (TLV) values here
        return fieldValue;
    }
  },

If your message has no field 55 and you want to add it explicitly, you may use the following code inbeforeBack method:

  beforePack: function(data) {
    data['55'] = Buffer.from('9f2608571f1e10d4fa4aac9f2701809f100706010a03a4b8029f37045bb074729f3602000c950500800010009a031508189c01009f02060000000010005f2a02064382023c009f1a0206439f03060000000000009f3303e0f0c89f34034403029f3501229f1e0835313230323831358407a00000000310109f41030000565f340101', 'hex');
    return data;
  }

@scalpovich
Copy link
Author

scalpovich commented Dec 9, 2019

Thank for your revert.
Something like this i it correct?

  '55': {
    length: 255,
    name:   'EMV Data',
    type:   'll-bin-char',
    alias:  '',
    beforePack: function(fieldValue) {
           '9F26': {
              length: 8,
              name:   'Application cryptogram',
              type:   'fixed-b',
               alias:  ''
               }
          return fieldValue;
       }
  },

@juks
Copy link
Owner

juks commented Dec 9, 2019

Unfortunatelly, there is no tag layer abstraction inside the beforePack right now. So what you get there is entire field 55 value, that you need to break into parts and process on your own.

@scalpovich
Copy link
Author

Ok i see
So what do you mean by

// Work with tags (TLV) values here

Some example

@juks
Copy link
Owner

juks commented Dec 9, 2019

I mean you have fieldValue variable there, representing the field 55 value. So to alter the EMV tags you need to implement it in this method.

@cavebring
Copy link
Contributor

@scalpovich you could implement this:
https://www.npmjs.com/package/node-tlv

@scalpovich
Copy link
Author

@cavebring thanks for the information.
I will take a look quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants