Skip to content

Commit

Permalink
HCK-7258: fetch-http-handler (#40)
Browse files Browse the repository at this point in the history
* feat: added fetch-http-handler

* chore: move HttpHandler to its own place
  • Loading branch information
chulanovskyi-bs authored Jul 18, 2024
1 parent 06fd128 commit 11581c1
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 13 deletions.
105 changes: 105 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"description": "Hackolade plugin for AWS Glue Data Catalog",
"dependencies": {
"@aws-sdk/client-glue": "3.613.0",
"@aws-sdk/fetch-http-handler": "3.374.0",
"antlr4": "4.8.0",
"lodash": "4.17.21"
},
Expand Down
23 changes: 10 additions & 13 deletions reverse_engineering/helpers/connectionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
const fs = require('fs');
const https = require('https');
const { mapTableData } = require('./tablePropertiesHelper');
const { HttpHandler } = require('../httpHandler/HttpHandler');

let connection;
let databaseLoadContinuationToken;
Expand All @@ -28,6 +29,7 @@ const readCertificateFile = path => {
});
});
};

const getSslOptions = async connectionInfo => {
switch (connectionInfo.sslType) {
case 'Server validation': {
Expand Down Expand Up @@ -57,17 +59,13 @@ const getSslOptions = async connectionInfo => {
const createConnection = async connectionInfo => {
const { accessKeyId, secretAccessKey, region, sessionToken } = connectionInfo;
const sslOptions = await getSslOptions(connectionInfo);
const httpOptions = sslOptions.ssl
? {
httpOptions: {
agent: new https.Agent({
rejectUnauthorized: true,
...sslOptions,
}),
},
...sslOptions,
}
: {};

const agent = new https.Agent({
rejectUnauthorized: true,
...sslOptions,
});

const httpHandler = new HttpHandler(agent);

return new GlueClient({
region,
Expand All @@ -76,8 +74,7 @@ const createConnection = async connectionInfo => {
secretAccessKey,
sessionToken,
},
// TODO: verify ssl options to be applied correctly
...httpOptions,
requestHandler: httpHandler.handler,
});
};
const connect = async connectionInfo => {
Expand Down
16 changes: 16 additions & 0 deletions reverse_engineering/httpHandler/HttpHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { FetchHttpHandler } = require('@aws-sdk/fetch-http-handler');

class HttpHandler {
handler = null;

constructor(agent) {
this.agent = agent;
this.handler = new FetchHttpHandler();
}

get() {
return this.handler;
}
}

module.exports = { HttpHandler };

0 comments on commit 11581c1

Please sign in to comment.