Skip to content

Commit 1e94410

Browse files
committed
refac: add input params type validation for certain public web bridge apis
1 parent f80d7f2 commit 1e94410

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Adjust/plugins/sdk-plugin-webbridge/src/main/assets/adjust.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,40 @@ var Adjust = {
8989

9090
addGlobalCallbackParameter: function(key, value) {
9191
if (AdjustBridge) {
92+
if (typeof key !== 'string' || typeof value !== 'string') {
93+
console.log('Passed key or value is not of string type');
94+
return;
95+
}
9296
AdjustBridge.addGlobalCallbackParameter(key, value);
9397
}
9498
},
9599

96100
addGlobalPartnerParameter: function(key, value) {
97101
if (AdjustBridge) {
102+
if (typeof key !== 'string' || typeof value !== 'string') {
103+
console.log('Passed key or value is not of string type');
104+
return;
105+
}
98106
AdjustBridge.addGlobalPartnerParameter(key, value);
99107
}
100108
},
101109

102110
removeGlobalCallbackParameter: function(key) {
103111
if (AdjustBridge) {
112+
if (typeof key !== 'string') {
113+
console.log('Passed key is not of string type');
114+
return;
115+
}
104116
AdjustBridge.removeGlobalCallbackParameter(key);
105117
}
106118
},
107119

108120
removeGlobalPartnerParameter: function(key) {
109121
if (AdjustBridge) {
122+
if (typeof key !== 'string') {
123+
console.log('Passed key is not of string type');
124+
return;
125+
}
110126
AdjustBridge.removeGlobalPartnerParameter(key);
111127
}
112128
},

Adjust/plugins/sdk-plugin-webbridge/src/main/assets/adjust_event.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ AdjustEvent.prototype.setRevenue = function(revenue, currency) {
1414
};
1515

1616
AdjustEvent.prototype.addCallbackParameter = function(key, value) {
17+
if (typeof key !== 'string' || typeof value !== 'string') {
18+
console.log('Passed key or value is not of string type');
19+
return;
20+
}
1721
this.callbackParameters.push(key);
1822
this.callbackParameters.push(value);
1923
};
2024

2125
AdjustEvent.prototype.addPartnerParameter = function(key, value) {
26+
if (typeof key !== 'string' || typeof value !== 'string') {
27+
console.log('Passed key or value is not of string type');
28+
return;
29+
}
2230
this.partnerParameters.push(key);
2331
this.partnerParameters.push(value);
2432
};

Adjust/plugins/sdk-plugin-webbridge/src/main/assets/adjust_third_party_sharing.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ function AdjustThirdPartySharing(isEnabled) {
55
}
66

77
AdjustThirdPartySharing.prototype.addGranularOption = function(partnerName, key, value) {
8+
if (typeof partnerName !== 'string' || typeof key !== 'string' || typeof value !== 'string') {
9+
console.log('Passed partnerName, key or value is not of string type');
10+
return;
11+
}
812
this.granularOptions.push(partnerName);
913
this.granularOptions.push(key);
1014
this.granularOptions.push(value);
1115
};
1216

1317
AdjustThirdPartySharing.prototype.addPartnerSharingSetting = function(partnerName, key, value) {
18+
if (typeof partnerName !== 'string' || typeof key !== 'string' || typeof value !== 'boolean') {
19+
console.log('Passed partnerName or key is not of string type or value is not of boolean type');
20+
return;
21+
}
1422
this.partnerSharingSettings.push(partnerName);
1523
this.partnerSharingSettings.push(key);
1624
this.partnerSharingSettings.push(value);

0 commit comments

Comments
 (0)