Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCK-7258: fetch-http-handler #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };