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

Commit

Permalink
Release 4.20.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
IngenicoEPayments committed Feb 27, 2024
1 parent e00e5f5 commit dc1191d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.gitattributes export-ignore
.gitignore export-ignore

* text eol=lf
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ There are two types of tests:
```
npm run test:unit
```
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.
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>`).
Run these tests as follows:
```
Expand Down
3 changes: 2 additions & 1 deletion __tests__/integration/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ connectSdk.init({
enableLogging: config.enableLogging, // defaults to false
apiKeyId: config.apiKeyId,
secretApiKey: config.secretApiKey,
integrator: "Integration tests"
integrator: config.integrator,
proxy: config.proxy
});

export default connectSdk;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "connect-sdk-nodejs",
"version": "4.19.0",
"version": "4.20.0",
"description": "SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Server API",
"homepage": "https://github.com/Ingenico-ePayments/connect-sdk-nodejs#readme",
"bugs": {
Expand Down
8 changes: 8 additions & 0 deletions src/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Context {
shoppingCartExtension?: ShoppingCartExtension;
httpOptions?: https.RequestOptions;
obfuscationRules?: { [key: string]: ObfuscationRule };
proxy?: ProxyConfiguration;
}

export interface FileMetaData {
Expand Down Expand Up @@ -82,6 +83,13 @@ export interface PaymentContext {
idemPotence?: IdemPotence;
}

export interface ProxyConfiguration {
host: string;
scheme?: "http" | "https";
port?: number;
credentials?: string;
}

export type SdkCallback = (error: SdkResponseError | null, result: SdkResponse | null) => void;

export interface SdkContext {
Expand Down
11 changes: 11 additions & 0 deletions src/utils/communicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ function prepareRequest(o: SdkRequest, context: Context, options: https.RequestO
extraHeaders.push(serverMetaInfo);

options.headers.Authorization = "GCS v1HMAC:" + context.apiKeyId + ":" + sdkcontext.getSignature(o.method, contentType, date, extraHeaders, options.path);

if (context.proxy) {
options.path = `${options.protocol}//${options.host}:${options.port}${options.path}`;
options.host = context.proxy.host;
options.protocol = (context.proxy.scheme ?? "http") + ":";
options.port = context.proxy.port ?? 3128;

if (context.proxy.credentials) {
options.headers["Proxy-Authorization"] = "Basic " + Buffer.from(context.proxy.credentials).toString("base64");
}
}
}

function handleResponse(error: Error | null, response: http.IncomingMessage | null, cb: SdkCallback): void {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ServerMetaInfo {
export function serverMetaInfo(sdkContext: SdkContext): Header {
const info: ServerMetaInfo = {
sdkCreator: "Ingenico",
sdkIdentifier: "NodejsServerSDK/v4.19.0",
sdkIdentifier: "NodejsServerSDK/v4.20.0",
platformIdentifier: process.env["OS"] + " Node.js/" + process.versions.node
};
if (sdkContext.getIntegrator() !== null) {
Expand Down

0 comments on commit dc1191d

Please sign in to comment.