@jd-data-limited/easy-fm 3.2.5 → 3.2.7
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/package.json +1 -2
- package/src/connection/database.d.ts +2 -2
- package/src/connection/database.js +9 -5
- package/src/connection/database.ts +11 -6
- package/src/records/getOperations/recordGetOperation.js +1 -1
- package/src/records/getOperations/recordGetOperation.ts +1 -1
- package/src/types.ts +1 -2
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jd-data-limited/easy-fm",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.7",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@types/btoa": "^1.2.3",
|
|
6
6
|
"@types/events": "^3.0.0",
|
|
7
|
-
"follow-redirects": "^1.15.3",
|
|
8
7
|
"moment": "^2.29.4",
|
|
9
8
|
"node-fetch": "3.2.8",
|
|
10
9
|
"typescript": "^5.2.2",
|
|
@@ -3,7 +3,7 @@ import { EventEmitter } from "events";
|
|
|
3
3
|
import { Request } from "node-fetch";
|
|
4
4
|
import { LayoutInterface } from "../layouts/layoutInterface.js";
|
|
5
5
|
import { Layout } from "../layouts/layout.js";
|
|
6
|
-
import
|
|
6
|
+
import HTTP_REDIRECT from "follow-redirects";
|
|
7
7
|
import { databaseOptionsWithExternalSources, DatabaseStructure, Script } from "../types.js";
|
|
8
8
|
import { HostBase } from "./HostBase.js";
|
|
9
9
|
import { DatabaseBase } from "./databaseBase";
|
|
@@ -25,5 +25,5 @@ export declare class Database<T extends DatabaseStructure> extends EventEmitter
|
|
|
25
25
|
setGlobals(globalFields: any): Promise<void>;
|
|
26
26
|
script(name: any, parameter?: string): Script;
|
|
27
27
|
_tokenExpired(): void;
|
|
28
|
-
streamContainer(field: any, url: any): Promise<
|
|
28
|
+
streamContainer(field: any, url: any): Promise<HTTP_REDIRECT.http.IncomingMessage>;
|
|
29
29
|
}
|
|
@@ -15,7 +15,7 @@ import fetch from "node-fetch";
|
|
|
15
15
|
import { generateAuthorizationHeaders } from "./generateAuthorizationHeaders.js";
|
|
16
16
|
import { FMError } from "../FMError.js";
|
|
17
17
|
import { Layout } from "../layouts/layout.js";
|
|
18
|
-
import
|
|
18
|
+
import HTTP_REDIRECT from "follow-redirects";
|
|
19
19
|
export class Database extends EventEmitter {
|
|
20
20
|
constructor(host, conn) {
|
|
21
21
|
super();
|
|
@@ -175,10 +175,7 @@ export class Database extends EventEmitter {
|
|
|
175
175
|
})
|
|
176
176
|
.join("; ");
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
(url.startsWith("https") ? redirecter.https : redirecter.http).get(url, {
|
|
180
|
-
headers
|
|
181
|
-
}, (res) => {
|
|
178
|
+
const check_for_cookies = (res) => {
|
|
182
179
|
// Check for the 'set-cookie' header. If it exists, remember it and strip it for better security.
|
|
183
180
|
if (res.headers['set-cookie']) {
|
|
184
181
|
for (let cookie of res.headers['set-cookie']) {
|
|
@@ -187,6 +184,13 @@ export class Database extends EventEmitter {
|
|
|
187
184
|
}
|
|
188
185
|
res.headers['set-cookie'] = null;
|
|
189
186
|
}
|
|
187
|
+
};
|
|
188
|
+
// Automatically switch between the http and https modules, based on which is needed
|
|
189
|
+
(url.startsWith("https") ? HTTP_REDIRECT.https : HTTP_REDIRECT.http).get(url, {
|
|
190
|
+
headers,
|
|
191
|
+
beforeRedirect: (options, res, req) => check_for_cookies(res)
|
|
192
|
+
}, (res) => {
|
|
193
|
+
check_for_cookies(res);
|
|
190
194
|
resolve(res);
|
|
191
195
|
});
|
|
192
196
|
});
|
|
@@ -8,7 +8,7 @@ import {generateAuthorizationHeaders} from "./generateAuthorizationHeaders.js";
|
|
|
8
8
|
import {FMError} from "../FMError.js";
|
|
9
9
|
import {LayoutInterface} from "../layouts/layoutInterface.js";
|
|
10
10
|
import {Layout} from "../layouts/layout.js";
|
|
11
|
-
import
|
|
11
|
+
import HTTP_REDIRECT from "follow-redirects"
|
|
12
12
|
import {
|
|
13
13
|
databaseOptionsBase,
|
|
14
14
|
databaseOptionsWithExternalSources, DatabaseStructure,
|
|
@@ -180,7 +180,7 @@ export class Database<T extends DatabaseStructure> extends EventEmitter implemen
|
|
|
180
180
|
this.emit("token_expired")
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
streamContainer(field, url): Promise<
|
|
183
|
+
streamContainer(field, url): Promise<HTTP_REDIRECT.http.IncomingMessage> {
|
|
184
184
|
return new Promise((resolve, reject) => {
|
|
185
185
|
if (field.metadata.result !== "container") {
|
|
186
186
|
reject("Cannot stream the field " + field.id + " as it is not a container")
|
|
@@ -200,10 +200,7 @@ export class Database<T extends DatabaseStructure> extends EventEmitter implemen
|
|
|
200
200
|
.join("; ")
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
(url.startsWith("https") ? redirecter.https : redirecter.http).get(url, {
|
|
205
|
-
headers
|
|
206
|
-
}, (res) => {
|
|
203
|
+
const check_for_cookies = (res) => {
|
|
207
204
|
// Check for the 'set-cookie' header. If it exists, remember it and strip it for better security.
|
|
208
205
|
if (res.headers['set-cookie']) {
|
|
209
206
|
for (let cookie of res.headers['set-cookie']) {
|
|
@@ -212,6 +209,14 @@ export class Database<T extends DatabaseStructure> extends EventEmitter implemen
|
|
|
212
209
|
}
|
|
213
210
|
res.headers['set-cookie'] = null
|
|
214
211
|
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Automatically switch between the http and https modules, based on which is needed
|
|
215
|
+
(url.startsWith("https") ? HTTP_REDIRECT.https : HTTP_REDIRECT.http).get(url, {
|
|
216
|
+
headers,
|
|
217
|
+
beforeRedirect: (options, res, req) => check_for_cookies(res)
|
|
218
|
+
}, (res) => {
|
|
219
|
+
check_for_cookies(res)
|
|
215
220
|
|
|
216
221
|
resolve(res)
|
|
217
222
|
})
|
package/src/types.ts
CHANGED