@interopio/gateway-server 0.7.0-beta → 0.8.1-beta.0
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/changelog.md +22 -0
- package/dist/gateway-ent.cjs +17 -17
- package/dist/gateway-ent.cjs.map +2 -2
- package/dist/gateway-ent.js +17 -17
- package/dist/gateway-ent.js.map +2 -2
- package/dist/index.cjs +1389 -623
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +1389 -623
- package/dist/index.js.map +4 -4
- package/dist/metrics/publisher/rest.cjs +13 -1
- package/dist/metrics/publisher/rest.cjs.map +3 -3
- package/dist/metrics/publisher/rest.js +14 -2
- package/dist/metrics/publisher/rest.js.map +2 -2
- package/dist/web/test.js +1392 -0
- package/dist/web/test.js.map +7 -0
- package/gateway-server.d.ts +2 -4
- package/license.md +5 -0
- package/package.json +7 -3
- package/readme.md +59 -26
- package/types/web/client.d.ts +12 -0
- package/types/web/http.d.ts +38 -26
- package/types/web/server.d.ts +35 -24
- package/types/web/{ws.d.ts → socket.d.ts} +8 -6
- package/types/web/test.d.ts +14 -0
|
@@ -37,11 +37,23 @@ __export(rest_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(rest_exports);
|
|
38
38
|
var rest = __toESM(require("@interopio/gateway/metrics/publisher/rest"), 1);
|
|
39
39
|
var import_v6 = require("http-cookie-agent/undici/v6");
|
|
40
|
+
var import_undici = require("http-cookie-agent/undici");
|
|
41
|
+
var import_undici2 = require("undici");
|
|
40
42
|
var import_tough_cookie = require("tough-cookie");
|
|
43
|
+
function cookieAgent(jar) {
|
|
44
|
+
const version = process.version;
|
|
45
|
+
const major = Number(version.substring(1, version.indexOf(".")));
|
|
46
|
+
const useUndiciV6 = major >= 18 && major < 24;
|
|
47
|
+
if (useUndiciV6) {
|
|
48
|
+
return new import_v6.CookieAgent({ cookies: { jar } });
|
|
49
|
+
} else {
|
|
50
|
+
return new import_undici.CookieAgent({ cookies: { jar } }).compose(import_undici2.interceptors.redirect());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
var fetchWithCookies = (existing) => {
|
|
42
54
|
const fetchFn = existing ?? globalThis.fetch;
|
|
43
55
|
const jar = new import_tough_cookie.CookieJar();
|
|
44
|
-
const dispatcher =
|
|
56
|
+
const dispatcher = cookieAgent(jar);
|
|
45
57
|
return async (input, request) => {
|
|
46
58
|
const requestWithDispatcher = { ...request, dispatcher };
|
|
47
59
|
return await fetchFn(input, requestWithDispatcher);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/gateway/metrics/rest.ts"],
|
|
4
|
-
"sourcesContent": ["import * as rest from '@interopio/gateway/metrics/publisher/rest';\nimport {IOGateway} from '@interopio/gateway';\nimport {CookieAgent} from 'http-cookie-agent/undici/v6';\nimport {CookieJar} from 'tough-cookie';\n\nexport const fetchWithCookies = (existing?: typeof fetch): typeof fetch => {\n const fetchFn = existing ?? globalThis.fetch;\n const jar = new CookieJar();\n const dispatcher =
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA,cAAAC;AAAA;AAAA;AAAA,WAAsB;AAEtB,
|
|
6
|
-
"names": ["create", "name"]
|
|
4
|
+
"sourcesContent": ["import * as rest from '@interopio/gateway/metrics/publisher/rest';\nimport {IOGateway} from '@interopio/gateway';\nimport {CookieAgent as CookieAgentUndiciV6} from 'http-cookie-agent/undici/v6';\nimport {CookieAgent as CookieAgentUndici} from 'http-cookie-agent/undici';\nimport {interceptors} from 'undici';\nimport {CookieJar} from 'tough-cookie';\n\nfunction cookieAgent(jar: CookieJar) {\n const version = process.version;\n const major = Number(version.substring(1 /*skip v prefix*/, version.indexOf('.')));\n const useUndiciV6 = major >= 18 && major < 24; // undici v6 is used for Node.js 18.x to 23.x\n\n if (useUndiciV6) {\n return new CookieAgentUndiciV6({cookies: {jar}});\n }\n else {\n return new CookieAgentUndici({cookies: {jar}}).compose(interceptors.redirect());\n }\n\n}\nexport const fetchWithCookies = (existing?: typeof fetch): typeof fetch => {\n const fetchFn = existing ?? globalThis.fetch;\n const jar = new CookieJar();\n const dispatcher = cookieAgent(jar);\n return async (input: RequestInfo | URL, request?: RequestInit) => {\n const requestWithDispatcher = {...request, dispatcher};\n return await fetchFn(input, requestWithDispatcher);\n }\n}\nexport const name = rest.name;\n\nexport function create(cfg: rest.RestPublisherConfig, logger: IOGateway.Logging.Logger) {\n return rest.create({...cfg, fetch: fetchWithCookies(cfg.fetch)}, logger);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA,cAAAC;AAAA;AAAA;AAAA,WAAsB;AAEtB,gBAAiD;AACjD,oBAA+C;AAC/C,IAAAC,iBAA2B;AAC3B,0BAAwB;AAExB,SAAS,YAAY,KAAgB;AACjC,QAAM,UAAU,QAAQ;AACxB,QAAM,QAAQ,OAAO,QAAQ,UAAU,GAAqB,QAAQ,QAAQ,GAAG,CAAC,CAAC;AACjF,QAAM,cAAc,SAAS,MAAM,QAAQ;AAE3C,MAAI,aAAa;AACb,WAAO,IAAI,UAAAC,YAAoB,EAAC,SAAS,EAAC,IAAG,EAAC,CAAC;AAAA,EACnD,OACK;AACD,WAAO,IAAI,cAAAC,YAAkB,EAAC,SAAS,EAAC,IAAG,EAAC,CAAC,EAAE,QAAQ,4BAAa,SAAS,CAAC;AAAA,EAClF;AAEJ;AACO,IAAM,mBAAmB,CAAC,aAA0C;AACvE,QAAM,UAAU,YAAY,WAAW;AACvC,QAAM,MAAM,IAAI,8BAAU;AAC1B,QAAM,aAAa,YAAY,GAAG;AAClC,SAAO,OAAO,OAA0B,YAA0B;AAC9D,UAAM,wBAAwB,EAAC,GAAG,SAAS,WAAU;AACrD,WAAO,MAAM,QAAQ,OAAO,qBAAqB;AAAA,EACrD;AACJ;AACO,IAAMH,QAAY;AAElB,SAASD,QAAO,KAA+B,QAAkC;AACpF,SAAY,YAAO,EAAC,GAAG,KAAK,OAAO,iBAAiB,IAAI,KAAK,EAAC,GAAG,MAAM;AAC3E;",
|
|
6
|
+
"names": ["create", "name", "import_undici", "CookieAgentUndiciV6", "CookieAgentUndici"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
// src/gateway/metrics/rest.ts
|
|
2
2
|
import * as rest from "@interopio/gateway/metrics/publisher/rest";
|
|
3
|
-
import { CookieAgent } from "http-cookie-agent/undici/v6";
|
|
3
|
+
import { CookieAgent as CookieAgentUndiciV6 } from "http-cookie-agent/undici/v6";
|
|
4
|
+
import { CookieAgent as CookieAgentUndici } from "http-cookie-agent/undici";
|
|
5
|
+
import { interceptors } from "undici";
|
|
4
6
|
import { CookieJar } from "tough-cookie";
|
|
7
|
+
function cookieAgent(jar) {
|
|
8
|
+
const version = process.version;
|
|
9
|
+
const major = Number(version.substring(1, version.indexOf(".")));
|
|
10
|
+
const useUndiciV6 = major >= 18 && major < 24;
|
|
11
|
+
if (useUndiciV6) {
|
|
12
|
+
return new CookieAgentUndiciV6({ cookies: { jar } });
|
|
13
|
+
} else {
|
|
14
|
+
return new CookieAgentUndici({ cookies: { jar } }).compose(interceptors.redirect());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
5
17
|
var fetchWithCookies = (existing) => {
|
|
6
18
|
const fetchFn = existing ?? globalThis.fetch;
|
|
7
19
|
const jar = new CookieJar();
|
|
8
|
-
const dispatcher =
|
|
20
|
+
const dispatcher = cookieAgent(jar);
|
|
9
21
|
return async (input, request) => {
|
|
10
22
|
const requestWithDispatcher = { ...request, dispatcher };
|
|
11
23
|
return await fetchFn(input, requestWithDispatcher);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/gateway/metrics/rest.ts"],
|
|
4
|
-
"sourcesContent": ["import * as rest from '@interopio/gateway/metrics/publisher/rest';\nimport {IOGateway} from '@interopio/gateway';\nimport {CookieAgent} from 'http-cookie-agent/undici/v6';\nimport {CookieJar} from 'tough-cookie';\n\nexport const fetchWithCookies = (existing?: typeof fetch): typeof fetch => {\n const fetchFn = existing ?? globalThis.fetch;\n const jar = new CookieJar();\n const dispatcher =
|
|
5
|
-
"mappings": ";AAAA,YAAY,UAAU;AAEtB,SAAQ,
|
|
4
|
+
"sourcesContent": ["import * as rest from '@interopio/gateway/metrics/publisher/rest';\nimport {IOGateway} from '@interopio/gateway';\nimport {CookieAgent as CookieAgentUndiciV6} from 'http-cookie-agent/undici/v6';\nimport {CookieAgent as CookieAgentUndici} from 'http-cookie-agent/undici';\nimport {interceptors} from 'undici';\nimport {CookieJar} from 'tough-cookie';\n\nfunction cookieAgent(jar: CookieJar) {\n const version = process.version;\n const major = Number(version.substring(1 /*skip v prefix*/, version.indexOf('.')));\n const useUndiciV6 = major >= 18 && major < 24; // undici v6 is used for Node.js 18.x to 23.x\n\n if (useUndiciV6) {\n return new CookieAgentUndiciV6({cookies: {jar}});\n }\n else {\n return new CookieAgentUndici({cookies: {jar}}).compose(interceptors.redirect());\n }\n\n}\nexport const fetchWithCookies = (existing?: typeof fetch): typeof fetch => {\n const fetchFn = existing ?? globalThis.fetch;\n const jar = new CookieJar();\n const dispatcher = cookieAgent(jar);\n return async (input: RequestInfo | URL, request?: RequestInit) => {\n const requestWithDispatcher = {...request, dispatcher};\n return await fetchFn(input, requestWithDispatcher);\n }\n}\nexport const name = rest.name;\n\nexport function create(cfg: rest.RestPublisherConfig, logger: IOGateway.Logging.Logger) {\n return rest.create({...cfg, fetch: fetchWithCookies(cfg.fetch)}, logger);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,UAAU;AAEtB,SAAQ,eAAe,2BAA0B;AACjD,SAAQ,eAAe,yBAAwB;AAC/C,SAAQ,oBAAmB;AAC3B,SAAQ,iBAAgB;AAExB,SAAS,YAAY,KAAgB;AACjC,QAAM,UAAU,QAAQ;AACxB,QAAM,QAAQ,OAAO,QAAQ,UAAU,GAAqB,QAAQ,QAAQ,GAAG,CAAC,CAAC;AACjF,QAAM,cAAc,SAAS,MAAM,QAAQ;AAE3C,MAAI,aAAa;AACb,WAAO,IAAI,oBAAoB,EAAC,SAAS,EAAC,IAAG,EAAC,CAAC;AAAA,EACnD,OACK;AACD,WAAO,IAAI,kBAAkB,EAAC,SAAS,EAAC,IAAG,EAAC,CAAC,EAAE,QAAQ,aAAa,SAAS,CAAC;AAAA,EAClF;AAEJ;AACO,IAAM,mBAAmB,CAAC,aAA0C;AACvE,QAAM,UAAU,YAAY,WAAW;AACvC,QAAM,MAAM,IAAI,UAAU;AAC1B,QAAM,aAAa,YAAY,GAAG;AAClC,SAAO,OAAO,OAA0B,YAA0B;AAC9D,UAAM,wBAAwB,EAAC,GAAG,SAAS,WAAU;AACrD,WAAO,MAAM,QAAQ,OAAO,qBAAqB;AAAA,EACrD;AACJ;AACO,IAAMA,QAAY;AAElB,SAASC,QAAO,KAA+B,QAAkC;AACpF,SAAY,YAAO,EAAC,GAAG,KAAK,OAAO,iBAAiB,IAAI,KAAK,EAAC,GAAG,MAAM;AAC3E;",
|
|
6
6
|
"names": ["name", "create"]
|
|
7
7
|
}
|