From e87998f486c511bff455d3f6f5bd73ca3f04cfdf Mon Sep 17 00:00:00 2001 From: Prathmesh Nesarikar Date: Tue, 11 Jul 2023 11:36:35 +0530 Subject: [PATCH 1/6] add name and version --- .gitignore | 2 ++ package-lock.json | 5 ++++- package.json | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ee1e6db --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Dependencies +node_modules \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 77da1d7..af7593e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,12 @@ { - "name": "Node.js - PHP Aligned", + "name": "cardstream-nodejs-sdk", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { + "name": "cardstream-nodejs-sdk", + "version": "0.1.0", "dependencies": { "axios": "^0.21.1", "chai": "^4.2.0", diff --git a/package.json b/package.json index aa29c37..cb31638 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,6 @@ { + "name": "cardstream-nodejs-sdk", + "version": "0.1.0", "dependencies": { "axios": "^0.21.1", "chai": "^4.2.0", From c83f0638fb3c985c0f5de3cd613392816db391e4 Mon Sep 17 00:00:00 2001 From: Prathmesh Nesarikar Date: Tue, 8 Aug 2023 10:48:43 +0530 Subject: [PATCH 2/6] Fix Typo --- gateway.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway.js b/gateway.js index 14603f2..35157c4 100644 --- a/gateway.js +++ b/gateway.js @@ -247,7 +247,7 @@ class Gateway { } if ('hostedUrl' in request) { - requestSetting['hostedUrl'] = request['hostedUrl']; + requestSettings['hostedUrl'] = request['hostedUrl']; delete (request['hostedUrl']); } else { requestSettings['hostedUrl'] = this.hostedUrl; From 8989025e394ee2312690961a9711f77c79b670aa Mon Sep 17 00:00:00 2001 From: Prathmesh Nesarikar Date: Tue, 8 Aug 2023 10:58:43 +0530 Subject: [PATCH 3/6] Fix Typo --- gateway.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway.js b/gateway.js index 35157c4..5371c3f 100644 --- a/gateway.js +++ b/gateway.js @@ -506,7 +506,7 @@ class Gateway { * @return string HTML containing tags */ function fieldToHtml(name, value) { - ret = ''; + let ret = ''; if (typeof value === "object" && !Array.isArray(value)) { Object.entries(value).forEach(([nestedKey, nestedValue]) => { ret += fieldToHtml(`${name}[${nestedKey}]`, nestedValue); From 7f3012a0e71038705b16c95453e92471727c6e85 Mon Sep 17 00:00:00 2001 From: Prathmesh Nesarikar Date: Tue, 8 Aug 2023 13:08:30 +0530 Subject: [PATCH 4/6] Update gateway.js --- gateway.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gateway.js b/gateway.js index 5371c3f..aad57a8 100644 --- a/gateway.js +++ b/gateway.js @@ -464,7 +464,7 @@ class Gateway { } } - ret = ` + let ret = `
${form_fields}
@@ -506,7 +506,7 @@ class Gateway { * @return string HTML containing tags */ function fieldToHtml(name, value) { - let ret = ''; + ret = ''; if (typeof value === "object" && !Array.isArray(value)) { Object.entries(value).forEach(([nestedKey, nestedValue]) => { ret += fieldToHtml(`${name}[${nestedKey}]`, nestedValue); @@ -538,15 +538,17 @@ function htmlentities(str) { if (typeof str == 'number') { return str.toString(); } - + if (typeof str == 'string') { return str.replace(/[&<>'"]/g, - tag => ({ - '&': '&', - '<': '<', - '>': '>', - "'": ''', - '"': '"' - }[tag])); + tag => ({ + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' + }[tag])); + } + return str } /** @@ -565,8 +567,8 @@ function phpCompatibleSort(a, b) { do { // codePointAt helpfully returns undefined if pos > length - achr = a.codePointAt(pos); - bchr = b.codePointAt(pos); + let achr = a.codePointAt(pos); + let bchr = b.codePointAt(pos); if (achr == undefined) { //We don't need to check b at all. return -1 From c30ccb5712e8a2ceeae513674cbb039a4c75e1af Mon Sep 17 00:00:00 2001 From: Prathmesh Nesarikar Date: Tue, 8 Aug 2023 13:10:27 +0530 Subject: [PATCH 5/6] Update gateway.js --- gateway.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway.js b/gateway.js index aad57a8..50dee28 100644 --- a/gateway.js +++ b/gateway.js @@ -506,7 +506,7 @@ class Gateway { * @return string HTML containing tags */ function fieldToHtml(name, value) { - ret = ''; + let ret = ''; if (typeof value === "object" && !Array.isArray(value)) { Object.entries(value).forEach(([nestedKey, nestedValue]) => { ret += fieldToHtml(`${name}[${nestedKey}]`, nestedValue); From 609f4eb1dad69193efed5b3691fff84cb698c349 Mon Sep 17 00:00:00 2001 From: Prathmesh Nesarikar Date: Thu, 10 Aug 2023 08:49:41 +0530 Subject: [PATCH 6/6] check str is string --- gateway.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/gateway.js b/gateway.js index 50dee28..794820a 100644 --- a/gateway.js +++ b/gateway.js @@ -528,9 +528,12 @@ function fieldToHtml(name, value) { * (0x00 to 0x1f consists of whitespace and control characters) */ function ordEntities(str) { - return str.replace(/[(\x00-\x1f)]/g, - match => { return '&#' + match.codePointAt(0) + ';'; - }); + if (typeof str == 'string') { + return str.replace(/[(\x00-\x1f)]/g, + match => { return '&#' + match.codePointAt(0) + ';'; + }); + } + return str; } // https://stackoverflow.com/a/57448862 @@ -538,17 +541,17 @@ function htmlentities(str) { if (typeof str == 'number') { return str.toString(); } - if (typeof str == 'string') { - return str.replace(/[&<>'"]/g, - tag => ({ - '&': '&', - '<': '<', - '>': '>', - "'": ''', - '"': '"' - }[tag])); - } - return str + if (typeof str == 'string') { + return str.replace(/[&<>'"]/g, + tag => ({ + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' + }[tag])); + } + return str; } /**