@flexbase/onbo-node-client
Advanced tools
+87
-84
@@ -193,37 +193,37 @@ "use strict"; | ||
| var _a, _b, _c, _d; | ||
| if (typeof arg === 'object' && !(0, __1.isEmpty)(arg)) { | ||
| if (typeof ((_a = arg.address) === null || _a === void 0 ? void 0 : _a.country) === 'string') { | ||
| // only allow 'United States' - not 'US' | ||
| if (arg.address.country.toUpperCase() === 'US') { | ||
| arg.address.country = 'United States'; | ||
| } | ||
| // make a deep copy for mutations | ||
| var rdy = JSON.parse(JSON.stringify(arg)); | ||
| if (typeof ((_a = rdy.address) === null || _a === void 0 ? void 0 : _a.country) === 'string') { | ||
| // only allow 'United States' - not 'US' | ||
| if (rdy.address.country.toUpperCase() === 'US') { | ||
| rdy.address.country = 'United States'; | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.ssn)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_b = arg.ssn.match(/[0-9]/g)) !== null && _b !== void 0 ? _b : []; | ||
| if (dig.length == 9) { | ||
| arg.ssn = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| } | ||
| if (!(0, __1.isEmpty)(rdy.ssn)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_b = rdy.ssn.match(/[0-9]/g)) !== null && _b !== void 0 ? _b : []; | ||
| if (dig.length == 9) { | ||
| rdy.ssn = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.phone)) { | ||
| // they want nothing but digits for the phone | ||
| var dig = (_c = arg.phone.match(/[0-9]/g)) !== null && _c !== void 0 ? _c : []; | ||
| if (dig.length == 10) { | ||
| arg.phone = dig.join(''); | ||
| } | ||
| } | ||
| if (!(0, __1.isEmpty)(rdy.phone)) { | ||
| // they want nothing but digits for the phone | ||
| var dig = (_c = rdy.phone.match(/[0-9]/g)) !== null && _c !== void 0 ? _c : []; | ||
| if (dig.length == 10) { | ||
| rdy.phone = dig.join(''); | ||
| } | ||
| // ...these are for the Business Users... | ||
| if (!(0, __1.isEmpty)(arg.ein)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_d = arg.ein.match(/[0-9]/g)) !== null && _d !== void 0 ? _d : []; | ||
| if (dig.length == 9) { | ||
| arg.ein = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| } | ||
| // ...these are for the Business Users... | ||
| if (!(0, __1.isEmpty)(rdy.ein)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_d = rdy.ein.match(/[0-9]/g)) !== null && _d !== void 0 ? _d : []; | ||
| if (dig.length == 9) { | ||
| rdy.ein = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.keyPeople)) { | ||
| // run each person in the array through the same function... | ||
| arg.keyPeople = arg.keyPeople.map(function (p) { return _this.toOnbo(p); }); | ||
| } | ||
| } | ||
| return arg; | ||
| if (!(0, __1.isEmpty)(rdy.keyPeople)) { | ||
| // run each person in the array through the same function... | ||
| rdy.keyPeople = rdy.keyPeople.map(function (p) { return _this.toOnbo(p); }); | ||
| } | ||
| return rdy; | ||
| }; | ||
@@ -238,25 +238,25 @@ /* | ||
| var _a, _b; | ||
| if (typeof arg === 'object' && !(0, __1.isEmpty)(arg)) { | ||
| if (typeof ((_a = arg.address) === null || _a === void 0 ? void 0 : _a.country) === 'string') { | ||
| // converty to ISO code for 'United States' : 'US' | ||
| if (arg.address.country.toUpperCase() === 'UNITED STATES') { | ||
| arg.address.country = 'US'; | ||
| } | ||
| // make a deep copy for mutations | ||
| var rdy = JSON.parse(JSON.stringify(arg)); | ||
| if (typeof ((_a = rdy.address) === null || _a === void 0 ? void 0 : _a.country) === 'string') { | ||
| // converty to ISO code for 'United States' : 'US' | ||
| if (rdy.address.country.toUpperCase() === 'UNITED STATES') { | ||
| rdy.address.country = 'US'; | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.phone)) { | ||
| // let's stick with XXX-XXX-XXXX | ||
| var dig = (_b = arg.phone.match(/[0-9]/g)) !== null && _b !== void 0 ? _b : []; | ||
| if (dig.length == 10) { | ||
| arg.phone = dig.slice(0, 3).join('') + '-' + | ||
| dig.slice(3, 6).join('') + '-' + | ||
| dig.slice(-4).join(''); | ||
| } | ||
| } | ||
| if (!(0, __1.isEmpty)(rdy.phone)) { | ||
| // let's stick with XXX-XXX-XXXX | ||
| var dig = (_b = rdy.phone.match(/[0-9]/g)) !== null && _b !== void 0 ? _b : []; | ||
| if (dig.length == 10) { | ||
| rdy.phone = dig.slice(0, 3).join('') + '-' + | ||
| dig.slice(3, 6).join('') + '-' + | ||
| dig.slice(-4).join(''); | ||
| } | ||
| // ...these are for the Business Users... | ||
| if (!(0, __1.isEmpty)(arg.keyPeople)) { | ||
| // run each person in the array through the same function... | ||
| arg.keyPeople = arg.keyPeople.map(function (p) { return _this.fromOnbo(p); }); | ||
| } | ||
| } | ||
| return arg; | ||
| // ...these are for the Business Users... | ||
| if (!(0, __1.isEmpty)(rdy.keyPeople)) { | ||
| // run each person in the array through the same function... | ||
| rdy.keyPeople = rdy.keyPeople.map(function (p) { return _this.fromOnbo(p); }); | ||
| } | ||
| return rdy; | ||
| }; | ||
@@ -270,42 +270,45 @@ /* | ||
| var _a, _b, _c, _d; | ||
| if (typeof arg === 'object' && !(0, __1.isEmpty)(arg)) { | ||
| if (typeof ((_a = arg.address) === null || _a === void 0 ? void 0 : _a.country) === 'string') { | ||
| // only allow 'United States' - not 'US' | ||
| console.log('COUNTRY', arg.address.country.toUpperCase()); | ||
| if (arg.address.country.toUpperCase() === 'US') { | ||
| arg.address.country = 'United States'; | ||
| } | ||
| // make a deep copy for mutations | ||
| var rdy = JSON.parse(JSON.stringify(arg)); | ||
| if (typeof ((_a = rdy.address) === null || _a === void 0 ? void 0 : _a.country) === 'string') { | ||
| // only allow 'United States' - not 'US' | ||
| console.log('COUNTRY', rdy.address.country.toUpperCase()); | ||
| if (rdy.address.country.toUpperCase() === 'US') { | ||
| rdy.address.country = 'United States'; | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.ssn)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_b = arg.ssn.match(/[0-9]/g)) !== null && _b !== void 0 ? _b : []; | ||
| console.log('SSN', dig.join(''), dig.length); | ||
| if (dig.length == 9) { | ||
| arg.ssn = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| } | ||
| if (!(0, __1.isEmpty)(rdy.ssn)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_b = rdy.ssn.match(/[0-9]/g)) !== null && _b !== void 0 ? _b : []; | ||
| console.log('SSN', dig.join(''), dig.length); | ||
| if (dig.length == 9) { | ||
| rdy.ssn = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.phone)) { | ||
| // they want nothing but digits for the phone | ||
| var dig = (_c = arg.phone.match(/[0-9]/g)) !== null && _c !== void 0 ? _c : []; | ||
| console.log('PHONE', dig.join(''), dig.length); | ||
| if (dig.length == 10) { | ||
| arg.phone = dig.join(''); | ||
| } | ||
| } | ||
| if (!(0, __1.isEmpty)(rdy.phone)) { | ||
| // they want nothing but digits for the phone | ||
| var dig = (_c = rdy.phone.match(/[0-9]/g)) !== null && _c !== void 0 ? _c : []; | ||
| console.log('PHONE', dig.join(''), dig.length); | ||
| if (dig.length == 10) { | ||
| rdy.phone = dig.join(''); | ||
| } | ||
| // ...these are for the Business Users... | ||
| if (!(0, __1.isEmpty)(arg.ein)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_d = arg.ein.match(/[0-9]/g)) !== null && _d !== void 0 ? _d : []; | ||
| console.log('EIN', dig.join(''), dig.length); | ||
| if (dig.length == 9) { | ||
| arg.ein = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| } | ||
| // ...these are for the Business Users... | ||
| if (!(0, __1.isEmpty)(rdy.ein)) { | ||
| // keep just the digits and AES encrypt them | ||
| var dig = (_d = rdy.ein.match(/[0-9]/g)) !== null && _d !== void 0 ? _d : []; | ||
| console.log('EIN', dig.join(''), dig.length); | ||
| if (dig.length == 9) { | ||
| rdy.ein = (0, __1.aesEncrypt)(dig.join(''), this.client.secret); | ||
| } | ||
| if (!(0, __1.isEmpty)(arg.keyPeople)) { | ||
| // run each person in the array through the same function... | ||
| arg.keyPeople = arg.keyPeople.map(function (p) { return _this.toOnbo(p); }); | ||
| } | ||
| } | ||
| return arg; | ||
| if (!(0, __1.isEmpty)(rdy.keyPeople)) { | ||
| // run each person in the array through the same function... | ||
| rdy.keyPeople = rdy.keyPeople.map(function (p) { return _this.toOnbo(p); }); | ||
| } | ||
| return rdy; | ||
| }; | ||
| /* | ||
| * Do before and after comparisons | ||
| */ | ||
| UserApi.prototype.toCheck = function (arg) { | ||
@@ -312,0 +315,0 @@ return { before: arg, after: this.toOnbo(arg), loggy: this.toOnboLog(arg) }; |
+1
-1
| { | ||
| "name": "@flexbase/onbo-node-client", | ||
| "version": "0.4.10", | ||
| "version": "0.4.11", | ||
| "description": "Node.js Client for Onbo API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
2095
0.14%126410
-0.19%