connect-sdk-nodejs 4.16.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/captures/get.js +1 -1
- package/lib/captures/index.js +1 -1
- package/lib/captures/refund.js +1 -1
- package/lib/disputes/cancel.js +1 -1
- package/lib/disputes/get.js +1 -1
- package/lib/disputes/index.js +1 -1
- package/lib/disputes/submit.js +1 -1
- package/lib/disputes/uploadFile.js +1 -1
- package/lib/files/getFile.js +1 -1
- package/lib/files/index.js +1 -1
- package/lib/hostedcheckouts/create.js +1 -1
- package/lib/hostedcheckouts/get.js +1 -1
- package/lib/hostedcheckouts/index.js +1 -1
- package/lib/hostedcheckouts/remove.js +1 -1
- package/lib/hostedmandatemanagements/create.js +1 -1
- package/lib/hostedmandatemanagements/get.js +1 -1
- package/lib/hostedmandatemanagements/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/installments/getInstallmentsInfo.js +1 -1
- package/lib/installments/index.js +1 -1
- package/lib/mandates/block.js +1 -1
- package/lib/mandates/create.js +1 -1
- package/lib/mandates/createWithMandateReference.js +1 -1
- package/lib/mandates/get.js +1 -1
- package/lib/mandates/index.js +1 -1
- package/lib/mandates/revoke.js +1 -1
- package/lib/mandates/unblock.js +1 -1
- package/lib/model/domain/definitions/index.d.ts +1 -1
- package/lib/model/domain/errors/definitions/index.js +1 -1
- package/lib/model/domain/file/definitions/index.js +1 -1
- package/lib/model/domain/payment/definitions/index.d.ts +2 -4
- package/lib/model/domain/product/definitions/index.d.ts +1 -0
- package/lib/model/installments/index.d.ts +1 -1
- package/lib/model/webhooks/index.d.ts +2 -27
- package/lib/model/webhooks/index.js +11 -22
- package/lib/model/webhooks/index.js.map +1 -1
- package/lib/model/webhooks/types.d.ts +32 -0
- package/lib/model/webhooks/types.js +25 -0
- package/lib/model/webhooks/types.js.map +1 -0
- package/lib/payments/approve.js +1 -1
- package/lib/payments/cancel.js +1 -1
- package/lib/payments/cancelapproval.js +1 -1
- package/lib/payments/capture.js +1 -1
- package/lib/payments/captures.js +1 -1
- package/lib/payments/complete.js +1 -1
- package/lib/payments/create.js +1 -1
- package/lib/payments/devicefingerprint.js +1 -1
- package/lib/payments/dispute.js +1 -1
- package/lib/payments/disputes.js +1 -1
- package/lib/payments/find.js +1 -1
- package/lib/payments/get.js +1 -1
- package/lib/payments/index.js +1 -1
- package/lib/payments/processchallenged.js +1 -1
- package/lib/payments/refund.js +1 -1
- package/lib/payments/refunds.js +1 -1
- package/lib/payments/thirdPartyStatus.js +1 -1
- package/lib/payments/tokenize.js +1 -1
- package/lib/payouts/approve.js +1 -1
- package/lib/payouts/cancel.js +1 -1
- package/lib/payouts/cancelapproval.js +1 -1
- package/lib/payouts/create.js +1 -1
- package/lib/payouts/find.js +1 -1
- package/lib/payouts/get.js +1 -1
- package/lib/payouts/index.js +1 -1
- package/lib/productgroups/deviceFingerprint.js +1 -1
- package/lib/productgroups/find.js +1 -1
- package/lib/productgroups/get.js +1 -1
- package/lib/productgroups/index.js +1 -1
- package/lib/products/customerDetails.js +1 -1
- package/lib/products/deviceFingerprint.js +1 -1
- package/lib/products/directory.js +1 -1
- package/lib/products/find.js +1 -1
- package/lib/products/get.js +1 -1
- package/lib/products/index.js +1 -1
- package/lib/products/networks.js +1 -1
- package/lib/products/sessions.js +1 -1
- package/lib/refunds/approve.js +1 -1
- package/lib/refunds/cancel.js +1 -1
- package/lib/refunds/cancelapproval.js +1 -1
- package/lib/refunds/find.js +1 -1
- package/lib/refunds/get.js +1 -1
- package/lib/refunds/index.js +1 -1
- package/lib/riskassessments/bankaccounts.js +1 -1
- package/lib/riskassessments/cards.js +1 -1
- package/lib/riskassessments/index.js +1 -1
- package/lib/services/bankaccount.js +1 -1
- package/lib/services/convertAmount.js +1 -1
- package/lib/services/getIINdetails.js +1 -1
- package/lib/services/index.js +1 -1
- package/lib/services/privacypolicy.js +1 -1
- package/lib/services/testconnection.js +1 -1
- package/lib/sessions/create.js +1 -1
- package/lib/sessions/index.js +1 -1
- package/lib/tokens/approvesepadirectdebit.js +1 -1
- package/lib/tokens/create.js +1 -1
- package/lib/tokens/get.js +1 -1
- package/lib/tokens/index.js +1 -1
- package/lib/tokens/remove.js +1 -1
- package/lib/tokens/update.js +1 -1
- package/lib/utils/headers.js +1 -1
- package/lib/webhooks/index.js +3 -55
- package/lib/webhooks/index.js.map +1 -1
- package/lib/webhooks/validation.d.ts +3 -0
- package/lib/webhooks/validation.js +63 -0
- package/lib/webhooks/validation.js.map +1 -0
- package/package.json +1 -1
- package/schemas/hostedcheckout/CreateHostedCheckoutRequest.json +3 -3
- package/schemas/payment/CreatePaymentRequest.json +3 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const crypto = require("crypto");
|
|
3
|
+
const compare = require("secure-compare");
|
|
4
|
+
let secretKeyStore = {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
getSecretKey(_keyId, _cb) {
|
|
7
|
+
throw new Error("getSecretKey not initialized yet");
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function getHeaderValue(requestHeaders, headerName) {
|
|
11
|
+
const lowerCaseHeaderName = headerName.toLowerCase();
|
|
12
|
+
for (const name in requestHeaders) {
|
|
13
|
+
if (name != null && lowerCaseHeaderName === name.toLowerCase()) {
|
|
14
|
+
const value = requestHeaders[name];
|
|
15
|
+
if (typeof value === "string") {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === "undefined") {
|
|
19
|
+
throw new Error("could not find header '" + headerName + "'");
|
|
20
|
+
}
|
|
21
|
+
throw new Error("found multiple values for header '" + headerName + "'");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
throw new Error("could not find header '" + headerName + "'");
|
|
25
|
+
}
|
|
26
|
+
function validate(body, requestHeaders, cb) {
|
|
27
|
+
try {
|
|
28
|
+
const signature = getHeaderValue(requestHeaders, "X-GCS-Signature");
|
|
29
|
+
const keyId = getHeaderValue(requestHeaders, "X-GCS-KeyId");
|
|
30
|
+
secretKeyStore.getSecretKey(keyId, (error, secretKey) => {
|
|
31
|
+
if (error) {
|
|
32
|
+
cb(error);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const expectedSignature = crypto
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
|
+
.createHmac("sha256", secretKey) // if error is falsy, secretKey isn't
|
|
38
|
+
.update(body)
|
|
39
|
+
.digest("base64");
|
|
40
|
+
if (compare(signature, expectedSignature)) {
|
|
41
|
+
cb(null);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
cb(new Error("failed to validate signature '" + signature + "'"));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
cb(e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const validator = {
|
|
54
|
+
init: store => {
|
|
55
|
+
if (!store || typeof store.getSecretKey !== "function") {
|
|
56
|
+
throw new Error("no valid secret key store given");
|
|
57
|
+
}
|
|
58
|
+
secretKeyStore = store;
|
|
59
|
+
},
|
|
60
|
+
validate: validate
|
|
61
|
+
};
|
|
62
|
+
module.exports = validator;
|
|
63
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/webhooks/validation.ts"],"names":[],"mappings":";AAAA,iCAAkC;AAClC,0CAA2C;AAG3C,IAAI,cAAc,GAAmB;IACnC,6DAA6D;IAC7D,YAAY,CAAC,MAAc,EAAE,GAAsB;QACjD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;CACF,CAAC;AAEF,SAAS,cAAc,CAAC,cAA8B,EAAE,UAAkB;IACxE,MAAM,mBAAmB,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IACrD,KAA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AAS,GAAG,GAAG,CAAC,CAAC,CAAC;iBACnE;aACF;QACH,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,EAAE,CAAC,CAAU,CAAC,CAAC;KAChB;AACH,CAAC;AAED,MAAM,SAAS,GAAuB;IACpC,IAAI,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,UAAU,EAAE;YACtD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;SACpD;QACD,cAAc,GAAG,KAAK,CAAC;IACzB,CAAC;IACD,QAAQ,EAAE,QAAQ;CACnB,CAAC;AACF,iBAAS,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "connect-sdk-nodejs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Server API",
|
|
5
5
|
"homepage": "https://github.com/Ingenico-ePayments/connect-sdk-nodejs#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -435,6 +435,9 @@
|
|
|
435
435
|
"CardPaymentMethodSpecificInputBase" : {
|
|
436
436
|
"type" : "object",
|
|
437
437
|
"properties" : {
|
|
438
|
+
"acquirerPromotionCode" : {
|
|
439
|
+
"type" : "string"
|
|
440
|
+
},
|
|
438
441
|
"authorizationMode" : {
|
|
439
442
|
"type" : "string"
|
|
440
443
|
},
|
|
@@ -1657,9 +1660,6 @@
|
|
|
1657
1660
|
"SdkDataInput" : {
|
|
1658
1661
|
"type" : "object",
|
|
1659
1662
|
"properties" : {
|
|
1660
|
-
"deviceInfo" : {
|
|
1661
|
-
"type" : "string"
|
|
1662
|
-
},
|
|
1663
1663
|
"deviceRenderOptions" : {
|
|
1664
1664
|
"$ref" : "#/definitions/DeviceRenderOptions"
|
|
1665
1665
|
},
|
|
@@ -492,6 +492,9 @@
|
|
|
492
492
|
"CardPaymentMethodSpecificInput" : {
|
|
493
493
|
"type" : "object",
|
|
494
494
|
"properties" : {
|
|
495
|
+
"acquirerPromotionCode" : {
|
|
496
|
+
"type" : "string"
|
|
497
|
+
},
|
|
495
498
|
"authorizationMode" : {
|
|
496
499
|
"type" : "string"
|
|
497
500
|
},
|
|
@@ -2001,9 +2004,6 @@
|
|
|
2001
2004
|
"SdkDataInput" : {
|
|
2002
2005
|
"type" : "object",
|
|
2003
2006
|
"properties" : {
|
|
2004
|
-
"deviceInfo" : {
|
|
2005
|
-
"type" : "string"
|
|
2006
|
-
},
|
|
2007
2007
|
"deviceRenderOptions" : {
|
|
2008
2008
|
"$ref" : "#/definitions/DeviceRenderOptions"
|
|
2009
2009
|
},
|