Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit dc1191d

Browse files
Release 4.20.0.
1 parent e00e5f5 commit dc1191d

File tree

9 files changed

+28
-5
lines changed

9 files changed

+28
-5
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ root = true
33
[*]
44
indent_style = space
55
indent_size = 2
6+
end_of_line = lf
67
charset = utf-8
78
trim_trailing_whitespace = true
89
insert_final_newline = true

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.gitattributes export-ignore
22
.gitignore export-ignore
3+
4+
* text eol=lf

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ There are two types of tests:
4747
```
4848
npm run test:unit
4949
```
50-
2. Integration tests. Before you can run these, you first need to copy file `__tests__/config.json.dist` to `__tests__/config.json` and replace all values as needed.
50+
2. Integration tests. Before you can run these, you first need to copy file `__tests__/config.json.dist` to `__tests__/config.json` and replace all values as needed. If needed, a `proxy` property can be added with nested properties `host`, `scheme` (defaults to `http`), `port` (defaults to 3128) and `credentials` (optional, in the format `<username>:<password>`).
5151
Run these tests as follows:
5252
5353
```

__tests__/integration/init.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ connectSdk.init({
1212
enableLogging: config.enableLogging, // defaults to false
1313
apiKeyId: config.apiKeyId,
1414
secretApiKey: config.secretApiKey,
15-
integrator: "Integration tests"
15+
integrator: config.integrator,
16+
proxy: config.proxy
1617
});
1718

1819
export default connectSdk;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "connect-sdk-nodejs",
3-
"version": "4.19.0",
3+
"version": "4.20.0",
44
"description": "SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Server API",
55
"homepage": "https://github.com/Ingenico-ePayments/connect-sdk-nodejs#readme",
66
"bugs": {

src/model/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface Context {
2222
shoppingCartExtension?: ShoppingCartExtension;
2323
httpOptions?: https.RequestOptions;
2424
obfuscationRules?: { [key: string]: ObfuscationRule };
25+
proxy?: ProxyConfiguration;
2526
}
2627

2728
export interface FileMetaData {
@@ -82,6 +83,13 @@ export interface PaymentContext {
8283
idemPotence?: IdemPotence;
8384
}
8485

86+
export interface ProxyConfiguration {
87+
host: string;
88+
scheme?: "http" | "https";
89+
port?: number;
90+
credentials?: string;
91+
}
92+
8593
export type SdkCallback = (error: SdkResponseError | null, result: SdkResponse | null) => void;
8694

8795
export interface SdkContext {

src/utils/communicator.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ function prepareRequest(o: SdkRequest, context: Context, options: https.RequestO
5959
extraHeaders.push(serverMetaInfo);
6060

6161
options.headers.Authorization = "GCS v1HMAC:" + context.apiKeyId + ":" + sdkcontext.getSignature(o.method, contentType, date, extraHeaders, options.path);
62+
63+
if (context.proxy) {
64+
options.path = `${options.protocol}//${options.host}:${options.port}${options.path}`;
65+
options.host = context.proxy.host;
66+
options.protocol = (context.proxy.scheme ?? "http") + ":";
67+
options.port = context.proxy.port ?? 3128;
68+
69+
if (context.proxy.credentials) {
70+
options.headers["Proxy-Authorization"] = "Basic " + Buffer.from(context.proxy.credentials).toString("base64");
71+
}
72+
}
6273
}
6374

6475
function handleResponse(error: Error | null, response: http.IncomingMessage | null, cb: SdkCallback): void {

src/utils/headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ServerMetaInfo {
1818
export function serverMetaInfo(sdkContext: SdkContext): Header {
1919
const info: ServerMetaInfo = {
2020
sdkCreator: "Ingenico",
21-
sdkIdentifier: "NodejsServerSDK/v4.19.0",
21+
sdkIdentifier: "NodejsServerSDK/v4.20.0",
2222
platformIdentifier: process.env["OS"] + " Node.js/" + process.versions.node
2323
};
2424
if (sdkContext.getIntegrator() !== null) {

0 commit comments

Comments
 (0)