abapgit-agent 1.11.0 → 1.11.1
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/.abapGitAgent.example +1 -0
- package/package.json +1 -1
- package/src/config.js +4 -2
- package/src/utils/abap-http.js +5 -5
- package/src/utils/adt-http.js +7 -7
- package/src/utils/version-check.js +4 -3
package/.abapGitAgent.example
CHANGED
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -34,7 +34,8 @@ function loadConfig() {
|
|
|
34
34
|
language: process.env.ABAP_LANGUAGE || 'EN',
|
|
35
35
|
gitUsername: process.env.GIT_USERNAME,
|
|
36
36
|
gitPassword: process.env.GIT_PASSWORD,
|
|
37
|
-
transport: process.env.ABAP_TRANSPORT
|
|
37
|
+
transport: process.env.ABAP_TRANSPORT,
|
|
38
|
+
protocol: process.env.ABAP_PROTOCOL || 'https'
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -51,7 +52,8 @@ function getAbapConfig() {
|
|
|
51
52
|
password: cfg.password,
|
|
52
53
|
language: cfg.language || 'EN',
|
|
53
54
|
gitUsername: cfg.gitUsername || process.env.GIT_USERNAME,
|
|
54
|
-
gitPassword: cfg.gitPassword || process.env.GIT_PASSWORD
|
|
55
|
+
gitPassword: cfg.gitPassword || process.env.GIT_PASSWORD,
|
|
56
|
+
protocol: cfg.protocol || process.env.ABAP_PROTOCOL || 'https'
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
|
package/src/utils/abap-http.js
CHANGED
|
@@ -129,7 +129,7 @@ class AbapHttp {
|
|
|
129
129
|
* @returns {Promise<string>} CSRF token
|
|
130
130
|
*/
|
|
131
131
|
async fetchCsrfToken() {
|
|
132
|
-
const url = new URL(`/sap/bc/z_abapgit_agent/health`,
|
|
132
|
+
const url = new URL(`/sap/bc/z_abapgit_agent/health`, `${this.config.protocol || 'https'}://${this.config.host}:${this.config.sapport}`);
|
|
133
133
|
|
|
134
134
|
return new Promise((resolve, reject) => {
|
|
135
135
|
const options = {
|
|
@@ -144,10 +144,10 @@ class AbapHttp {
|
|
|
144
144
|
'X-CSRF-Token': 'fetch',
|
|
145
145
|
'Content-Type': 'application/json'
|
|
146
146
|
},
|
|
147
|
-
agent: new https.Agent({ rejectUnauthorized: false })
|
|
147
|
+
agent: this.config.protocol === 'http' ? undefined : new https.Agent({ rejectUnauthorized: false })
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
const req = https.request(options, (res) => {
|
|
150
|
+
const req = (this.config.protocol === 'http' ? http : https).request(options, (res) => {
|
|
151
151
|
const csrfToken = res.headers['x-csrf-token'];
|
|
152
152
|
|
|
153
153
|
// Save cookies from response
|
|
@@ -222,7 +222,7 @@ class AbapHttp {
|
|
|
222
222
|
*/
|
|
223
223
|
async _makeRequest(method, urlPath, data = null, options = {}) {
|
|
224
224
|
return new Promise((resolve, reject) => {
|
|
225
|
-
const url = new URL(urlPath,
|
|
225
|
+
const url = new URL(urlPath, `${this.config.protocol || 'https'}://${this.config.host}:${this.config.sapport}`);
|
|
226
226
|
|
|
227
227
|
const headers = {
|
|
228
228
|
'Content-Type': 'application/json',
|
|
@@ -250,7 +250,7 @@ class AbapHttp {
|
|
|
250
250
|
path: url.pathname + url.search,
|
|
251
251
|
method,
|
|
252
252
|
headers,
|
|
253
|
-
agent: new https.Agent({ rejectUnauthorized: false })
|
|
253
|
+
agent: this.config.protocol === 'http' ? undefined : new https.Agent({ rejectUnauthorized: false })
|
|
254
254
|
};
|
|
255
255
|
|
|
256
256
|
const req = (url.protocol === 'https:' ? https : http).request(reqOptions, (res) => {
|
package/src/utils/adt-http.js
CHANGED
|
@@ -75,7 +75,7 @@ class AdtHttp {
|
|
|
75
75
|
*/
|
|
76
76
|
async fetchCsrfToken() {
|
|
77
77
|
return new Promise((resolve, reject) => {
|
|
78
|
-
const url = new URL('/sap/bc/adt/discovery',
|
|
78
|
+
const url = new URL('/sap/bc/adt/discovery', `${this.config.protocol || 'https'}://${this.config.host}:${this.config.sapport}`);
|
|
79
79
|
const options = {
|
|
80
80
|
hostname: url.hostname,
|
|
81
81
|
port: url.port,
|
|
@@ -88,10 +88,10 @@ class AdtHttp {
|
|
|
88
88
|
'X-CSRF-Token': 'fetch',
|
|
89
89
|
'Accept': 'application/atomsvc+xml'
|
|
90
90
|
},
|
|
91
|
-
agent: new https.Agent({ rejectUnauthorized: false })
|
|
91
|
+
agent: this.config.protocol === 'http' ? undefined : new https.Agent({ rejectUnauthorized: false })
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
const req = https.request(options, (res) => {
|
|
94
|
+
const req = (this.config.protocol === 'http' ? http : https).request(options, (res) => {
|
|
95
95
|
const csrfToken = res.headers['x-csrf-token'];
|
|
96
96
|
const setCookie = res.headers['set-cookie'];
|
|
97
97
|
if (setCookie) {
|
|
@@ -140,7 +140,7 @@ class AdtHttp {
|
|
|
140
140
|
|
|
141
141
|
async _makeRequest(method, urlPath, body = null, options = {}) {
|
|
142
142
|
return new Promise((resolve, reject) => {
|
|
143
|
-
const url = new URL(urlPath,
|
|
143
|
+
const url = new URL(urlPath, `${this.config.protocol || 'https'}://${this.config.host}:${this.config.sapport}`);
|
|
144
144
|
|
|
145
145
|
const headers = {
|
|
146
146
|
'Content-Type': options.contentType || 'application/atom+xml',
|
|
@@ -169,7 +169,7 @@ class AdtHttp {
|
|
|
169
169
|
path: url.pathname + url.search,
|
|
170
170
|
method,
|
|
171
171
|
headers,
|
|
172
|
-
agent: new https.Agent({ rejectUnauthorized: false })
|
|
172
|
+
agent: this.config.protocol === 'http' ? undefined : new https.Agent({ rejectUnauthorized: false })
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
const req = (url.protocol === 'https:' ? https : http).request(reqOptions, (res) => {
|
|
@@ -272,7 +272,7 @@ class AdtHttp {
|
|
|
272
272
|
*/
|
|
273
273
|
async postFire(urlPath, body = null, options = {}) {
|
|
274
274
|
return new Promise((resolve, reject) => {
|
|
275
|
-
const url = new URL(urlPath,
|
|
275
|
+
const url = new URL(urlPath, `${this.config.protocol || 'https'}://${this.config.host}:${this.config.sapport}`);
|
|
276
276
|
|
|
277
277
|
const headers = {
|
|
278
278
|
'Content-Type': options.contentType || 'application/atom+xml',
|
|
@@ -301,7 +301,7 @@ class AdtHttp {
|
|
|
301
301
|
path: url.pathname + url.search,
|
|
302
302
|
method: 'POST',
|
|
303
303
|
headers,
|
|
304
|
-
agent: new https.Agent({ rejectUnauthorized: false })
|
|
304
|
+
agent: this.config.protocol === 'http' ? undefined : new https.Agent({ rejectUnauthorized: false })
|
|
305
305
|
};
|
|
306
306
|
|
|
307
307
|
const req = (url.protocol === 'https:' ? https : http).request(reqOptions, (_res) => {
|
|
@@ -5,6 +5,7 @@ const pathModule = require('path');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const https = require('https');
|
|
8
|
+
const http = require('http');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Get cache directory for abapgit-agent
|
|
@@ -49,7 +50,7 @@ async function checkCompatibility(config) {
|
|
|
49
50
|
const cliVersion = getCliVersion();
|
|
50
51
|
|
|
51
52
|
try {
|
|
52
|
-
const url = new URL(`/sap/bc/z_abapgit_agent/health`,
|
|
53
|
+
const url = new URL(`/sap/bc/z_abapgit_agent/health`, `${config.protocol || 'https'}://${config.host}:${config.sapport}`);
|
|
53
54
|
|
|
54
55
|
return new Promise((resolve) => {
|
|
55
56
|
const options = {
|
|
@@ -63,10 +64,10 @@ async function checkCompatibility(config) {
|
|
|
63
64
|
'sap-language': config.language || 'EN',
|
|
64
65
|
'Content-Type': 'application/json'
|
|
65
66
|
},
|
|
66
|
-
agent: new https.Agent({ rejectUnauthorized: false })
|
|
67
|
+
agent: config.protocol === 'http' ? undefined : new https.Agent({ rejectUnauthorized: false })
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
const req = https.request(options, (res) => {
|
|
70
|
+
const req = (config.protocol === 'http' ? http : https).request(options, (res) => {
|
|
70
71
|
let body = '';
|
|
71
72
|
res.on('data', chunk => body += chunk);
|
|
72
73
|
res.on('end', () => {
|