From 32733f1a350dcb90aa45f0ccbf06f30e0d23e03e Mon Sep 17 00:00:00 2001 From: Mai Ngo Date: Tue, 13 Jan 2026 15:26:58 -0500 Subject: [PATCH 1/2] RGOPS-7273 Node.js Compatibility Issue with rocketgate-nodejs-sdk --- config/rgProperties.json | 2 +- lib/utils.js | 32 ++++++++++++++++++++++++++++---- package.json | 5 ++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/config/rgProperties.json b/config/rgProperties.json index 39a6f86..e0075b8 100644 --- a/config/rgProperties.json +++ b/config/rgProperties.json @@ -10,7 +10,7 @@ "LIVE_HOST_16": "gateway-16.rocketgate.com", "LIVE_HOST_17": "gateway-17.rocketgate.com", "TEST_HOST": "dev-gateway.rocketgate.com", - "VERSION_NUMBER": "K2.6" + "VERSION_NUMBER": "K2.7" }, "responseSettings": { "VERSION_INDICATOR": "version", diff --git a/lib/utils.js b/lib/utils.js index a291e58..48f240b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,18 +1,42 @@ -var xml2json = require('xml2json'), - json2xml = require("json2xml"); +const { XMLParser, XMLBuilder } = require('fast-xml-parser'); + +const parser = new XMLParser({ + attributeNamePrefix: "", + textNodeName: "$t", + parseTagValue: false, + ignoreDeclaration: true, + ignoreAttributes: false, +}); + +const builder = new XMLBuilder({ + ignoreAttributes: false, + attributeNamePrefix: "$", + textNodeName: "$t", +}); var exports = module.exports = { toXML: function (params, callback) { try { - callback(null, json2xml({ gatewayRequest: params }, { header: true })); + // Ensure the root object structure is correct for the builder + const data = { + '?xml': { + '$version': '1.0', + '$encoding': 'UTF-8' + }, + gatewayRequest: params + }; + const xml = builder.build(data); + callback(null, xml); } catch (err) { callback(err); } }, fromXML: function (xmlDocument, callback) { try { - callback(null, JSON.parse(xml2json.toJson(xmlDocument)).gatewayResponse); + const jsonObj = parser.parse(xmlDocument); + const response = jsonObj.gatewayResponse || jsonObj; // Fallback if root is missing + callback(null, response); } catch (err) { callback(err); } diff --git a/package.json b/package.json index 1df30a4..fcdbadd 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,11 @@ ], "dependencies": { "async": "2.1.x", + "fast-xml-parser": "5.3.x", "is_js": "0.9.x", - "json2xml": "0.1.x", "moment": "2.15.x", "request": "2.76.x", - "urlencode": "1.1.x", - "xml2json": "0.10.x" + "urlencode": "1.1.x" }, "devDependencies": { "eslint": "^3.17.1", From 4830b0572bfff80a0818274b5ff3b48f2290166b Mon Sep 17 00:00:00 2001 From: Mai Ngo Date: Mon, 19 Jan 2026 18:26:50 -0500 Subject: [PATCH 2/2] RGOPS-5234 Node.js SDK update - Use the highest value between connectTimeout or readtimeout --- lib/utils.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 48f240b..8cdb9a5 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,32 +1,22 @@ const { XMLParser, XMLBuilder } = require('fast-xml-parser'); const parser = new XMLParser({ - attributeNamePrefix: "", - textNodeName: "$t", - parseTagValue: false, - ignoreDeclaration: true, - ignoreAttributes: false, + parseTagValue: false, // Prefer string only + ignoreDeclaration: true, // No need parse header + ignoreAttributes: true, // To make things simple + trimValues: true // Default is true - To make elements compact }); const builder = new XMLBuilder({ - ignoreAttributes: false, - attributeNamePrefix: "$", - textNodeName: "$t", + ignoreAttributes: true, + suppressEmptyNode: true }); var exports = module.exports = { toXML: function (params, callback) { try { - // Ensure the root object structure is correct for the builder - const data = { - '?xml': { - '$version': '1.0', - '$encoding': 'UTF-8' - }, - gatewayRequest: params - }; - const xml = builder.build(data); + const xml = '' + builder.build({ gatewayRequest: params }); callback(null, xml); } catch (err) { callback(err); @@ -34,9 +24,7 @@ var exports = module.exports = { }, fromXML: function (xmlDocument, callback) { try { - const jsonObj = parser.parse(xmlDocument); - const response = jsonObj.gatewayResponse || jsonObj; // Fallback if root is missing - callback(null, response); + callback(null, parser.parse(xmlDocument).gatewayResponse); } catch (err) { callback(err); }