Skip to content

Commit d836994

Browse files
Merge pull request #411 from razorpay/version-2.9.4
fix: Resolve SSRF vulnerability
2 parents a762b92 + b0eedee commit d836994

25 files changed

+1376
-7764
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 2.9.4 - 2024-05-17
4+
fix: Resolve SSRF vulnerability in request handling
5+
feat: Added new API endpoints
6+
- Added support for `addBankAccount`, `deleteBankAccount`, `requestEligibilityCheck` & `fetchEligibility` on customer
7+
- Added support for [Dispute](https://razorpay.com/docs/api/disputes/)
8+
- Added support for [Document](https://razorpay.com/docs/api/documents/)
9+
- Added support for `viewRtoReview` & `editFulfillment` on order
10+
- Added support for fetch all IINs Supporting native otps & fetch all IINs with business sub-type using `all`
11+
312
## 2.9.3 - 2024-04-18
413
fix: Type definition for Product and Customer has been updated.
514

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ instance.payments.all(
125125
- [Payment Verification](documents/paymentVerfication.md)
126126

127127
- [Webhook](documents/webhook.md)
128+
129+
- [Dispute](documents/disputes.md)
130+
131+
- [Document](documents/documents.md)
132+
128133
---
129134

130135
## Development

lib/api.js

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const request = require('request-promise')
3+
const axios = require('axios').default
44
const nodeify = require('./utils/nodeify')
55
const {
66
isNonNullObject
@@ -33,19 +33,18 @@ function getValidHeaders (headers) {
3333

3434
function normalizeError(err) {
3535
throw {
36-
statusCode: err.statusCode,
37-
error: err.error.error
36+
statusCode: err.response.status,
37+
error: err.response.data.error
3838
}
3939
}
4040

4141
class API {
4242
constructor(options) {
43-
this.rq = request.defaults({
44-
baseUrl: options.hostUrl,
45-
json: true,
43+
this.rq = axios.create({
44+
baseURL: options.hostUrl,
4645
auth: {
47-
user: options.key_id,
48-
pass: options.key_secret
46+
username: options.key_id,
47+
password: options.key_secret
4948
},
5049
headers: Object.assign(
5150
{'User-Agent': options.ua},
@@ -61,48 +60,39 @@ class API {
6160
}
6261

6362
get(params, cb) {
64-
return nodeify(this.rq.get({
65-
url: this.getEntityUrl(params),
66-
qs: params.data,
63+
return nodeify(this.rq.get(this.getEntityUrl(params), {
64+
params: params.data
6765
}).catch(normalizeError), cb)
6866
}
6967

7068
post(params, cb) {
71-
let request = {
72-
url: this.getEntityUrl(params),
73-
body: params.data
74-
};
75-
return nodeify(this.rq.post(request).catch(normalizeError), cb);
69+
return nodeify(this.rq.post(this.getEntityUrl(params), params.data)
70+
.catch(normalizeError), cb);
7671
}
7772

7873
// postFormData method for file uploads.
7974
postFormData(params, cb){
80-
let request = {
81-
url: this.getEntityUrl(params),
82-
formData: params.formData
83-
};
84-
return nodeify(this.rq.post(request).catch(normalizeError), cb);
75+
return nodeify(this.rq.post(this.getEntityUrl(params), params.formData, {
76+
'headers': {
77+
'Content-Type': 'multipart/form-data'
78+
}
79+
})
80+
.catch(normalizeError), cb);
8581
}
8682

8783
put(params, cb) {
88-
return nodeify(this.rq.put({
89-
url: this.getEntityUrl(params),
90-
body: params.data
91-
}).catch(normalizeError), cb)
84+
return nodeify(this.rq.put(this.getEntityUrl(params), params.data)
85+
.catch(normalizeError), cb);
9286
}
9387

9488
patch(params, cb) {
95-
let request = {
96-
url: this.getEntityUrl(params),
97-
body: params.data
98-
};
99-
return nodeify(this.rq.patch(request).catch(normalizeError), cb);
89+
return nodeify(this.rq.patch(this.getEntityUrl(params), params.data)
90+
.catch(normalizeError), cb);
10091
}
10192

10293
delete(params, cb) {
103-
return nodeify(this.rq.delete({
104-
url: this.getEntityUrl(params)
105-
}).catch(normalizeError), cb)
94+
return nodeify(this.rq.delete(this.getEntityUrl(params))
95+
.catch(normalizeError), cb)
10696
}
10797
}
10898

lib/resources/accounts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ module.exports = function (api) {
3636
},
3737

3838
uploadAccountDoc(accountId, params, callback) {
39+
let {file, ...rest} = params
3940
return api.postFormData({
4041
version: 'v2',
4142
url: `${BASE_URL}/${accountId}/documents`,
42-
formData: params
43+
formData: {
44+
file: file.value, ...rest
45+
}
4346
}, callback);
4447
},
4548

lib/resources/addons.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* DOCS: https://razorpay.com/docs/subscriptions/api/
55
*/
66

7-
const Promise = require("promise"),
8-
{ normalizeDate } = require('../utils/razorpay-utils');
7+
const { normalizeDate } = require('../utils/razorpay-utils');
98

109
module.exports = function (api) {
1110

lib/resources/documents.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ module.exports = function (api) {
66

77
return {
88
create(params, callback) {
9+
let {file, ...rest} = params
910
return api.postFormData({
1011
url: `${BASE_URL}`,
11-
formData: params
12+
formData: {
13+
file: file.value, ...rest
14+
}
1215
}, callback);
1316
},
1417

lib/resources/invoices.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* DOCS: https://razorpay.com/docs/invoices/
55
*/
66

7-
const Promise = require("promise"),
8-
{ normalizeDate } = require('../utils/razorpay-utils');
7+
const { normalizeDate } = require('../utils/razorpay-utils');
98

109
module.exports = function invoicesApi (api) {
1110

lib/resources/paymentLink.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* DOCS: https://razorpay.com/docs/payment-links/
55
*/
66

7-
const Promise = require("promise"),
8-
{ normalizeDate, normalizeNotes } = require('../utils/razorpay-utils');
7+
const { normalizeDate } = require('../utils/razorpay-utils');
98

109
module.exports = function paymentLinkApi (api) {
1110

lib/resources/payments.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict'
22

3-
const Promise = require("promise");
4-
53
const { normalizeDate } = require('../utils/razorpay-utils')
64

75
const ID_REQUIRED_MSG = '`payment_id` is mandatory',

lib/resources/plans.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* DOCS: https://razorpay.com/docs/subscriptions/api/
55
*/
66

7-
const Promise = require("promise"),
8-
{ normalizeDate } = require('../utils/razorpay-utils');
7+
const { normalizeDate } = require('../utils/razorpay-utils');
98

109
module.exports = function plansApi (api) {
1110

0 commit comments

Comments
 (0)