@bendover111222333444/epoxy-transport 3.0.2 → 3.0.3
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/dist/index.js +40 -28
- package/dist/index.mjs +40 -28
- package/package.json +33 -34
- package/src/main.ts +41 -29
package/dist/index.js
CHANGED
|
@@ -1585,39 +1585,51 @@ var EpoxyTransport = class {
|
|
|
1585
1585
|
}
|
|
1586
1586
|
async request(remote, method, body, headers, signal) {
|
|
1587
1587
|
if (body instanceof Blob) body = await body.arrayBuffer();
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1588
|
+
const doRequest = async () => {
|
|
1589
|
+
try {
|
|
1590
|
+
let headersObj = {};
|
|
1591
|
+
for (let [key, value] of headers) {
|
|
1592
|
+
if (headersObj[key]) {
|
|
1593
|
+
console.warn(
|
|
1594
|
+
`Duplicate header key "${key}" detected. Overwriting previous value.`
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
headersObj[key] = value;
|
|
1595
1598
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1599
|
+
let res = await this.client.fetch(remote.href, {
|
|
1600
|
+
method,
|
|
1601
|
+
body,
|
|
1602
|
+
headers: headersObj,
|
|
1603
|
+
redirect: "manual"
|
|
1604
|
+
});
|
|
1605
|
+
let headersEntries = [];
|
|
1606
|
+
for (let [key, value] of Object.entries(res.rawHeaders)) {
|
|
1607
|
+
if (Array.isArray(value)) {
|
|
1608
|
+
for (let v of value) {
|
|
1609
|
+
headersEntries.push([key, v]);
|
|
1610
|
+
}
|
|
1611
|
+
} else {
|
|
1612
|
+
headersEntries.push([key, value]);
|
|
1609
1613
|
}
|
|
1610
|
-
} else {
|
|
1611
|
-
headersEntries.push([key, value]);
|
|
1612
1614
|
}
|
|
1615
|
+
return {
|
|
1616
|
+
body: res.body,
|
|
1617
|
+
headers: headersEntries,
|
|
1618
|
+
status: res.status,
|
|
1619
|
+
statusText: res.statusText
|
|
1620
|
+
};
|
|
1621
|
+
} catch (err) {
|
|
1622
|
+
throw err;
|
|
1613
1623
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
status: res.status,
|
|
1618
|
-
statusText: res.statusText
|
|
1619
|
-
};
|
|
1624
|
+
};
|
|
1625
|
+
try {
|
|
1626
|
+
return await doRequest();
|
|
1620
1627
|
} catch (err) {
|
|
1628
|
+
const msg = String(err);
|
|
1629
|
+
if (msg.includes("tls handshake eof") || msg.includes("MuxTaskEnded") || msg.includes("UnexpectedEof")) {
|
|
1630
|
+
await this.init();
|
|
1631
|
+
return await doRequest();
|
|
1632
|
+
}
|
|
1621
1633
|
console.error(err);
|
|
1622
1634
|
throw err;
|
|
1623
1635
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1556,39 +1556,51 @@ var EpoxyTransport = class {
|
|
|
1556
1556
|
}
|
|
1557
1557
|
async request(remote, method, body, headers, signal) {
|
|
1558
1558
|
if (body instanceof Blob) body = await body.arrayBuffer();
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1559
|
+
const doRequest = async () => {
|
|
1560
|
+
try {
|
|
1561
|
+
let headersObj = {};
|
|
1562
|
+
for (let [key, value] of headers) {
|
|
1563
|
+
if (headersObj[key]) {
|
|
1564
|
+
console.warn(
|
|
1565
|
+
`Duplicate header key "${key}" detected. Overwriting previous value.`
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
headersObj[key] = value;
|
|
1566
1569
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1570
|
+
let res = await this.client.fetch(remote.href, {
|
|
1571
|
+
method,
|
|
1572
|
+
body,
|
|
1573
|
+
headers: headersObj,
|
|
1574
|
+
redirect: "manual"
|
|
1575
|
+
});
|
|
1576
|
+
let headersEntries = [];
|
|
1577
|
+
for (let [key, value] of Object.entries(res.rawHeaders)) {
|
|
1578
|
+
if (Array.isArray(value)) {
|
|
1579
|
+
for (let v of value) {
|
|
1580
|
+
headersEntries.push([key, v]);
|
|
1581
|
+
}
|
|
1582
|
+
} else {
|
|
1583
|
+
headersEntries.push([key, value]);
|
|
1580
1584
|
}
|
|
1581
|
-
} else {
|
|
1582
|
-
headersEntries.push([key, value]);
|
|
1583
1585
|
}
|
|
1586
|
+
return {
|
|
1587
|
+
body: res.body,
|
|
1588
|
+
headers: headersEntries,
|
|
1589
|
+
status: res.status,
|
|
1590
|
+
statusText: res.statusText
|
|
1591
|
+
};
|
|
1592
|
+
} catch (err) {
|
|
1593
|
+
throw err;
|
|
1584
1594
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
status: res.status,
|
|
1589
|
-
statusText: res.statusText
|
|
1590
|
-
};
|
|
1595
|
+
};
|
|
1596
|
+
try {
|
|
1597
|
+
return await doRequest();
|
|
1591
1598
|
} catch (err) {
|
|
1599
|
+
const msg = String(err);
|
|
1600
|
+
if (msg.includes("tls handshake eof") || msg.includes("MuxTaskEnded") || msg.includes("UnexpectedEof")) {
|
|
1601
|
+
await this.init();
|
|
1602
|
+
return await doRequest();
|
|
1603
|
+
}
|
|
1592
1604
|
console.error(err);
|
|
1593
1605
|
throw err;
|
|
1594
1606
|
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bendover111222333444/epoxy-transport",
|
|
3
|
+
"version": "3.0.3",
|
|
4
|
+
"description": "a bare transport that implements end-to-end encryption with epoxy-tls and wisp modified by bendover111222333444",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"license": "AGPL-3.0-only",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/MercuryWorkshop/epoxy-transport.git"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@mercuryworkshop/epoxy-tls": "2.1.19-1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@mercuryworkshop/proxy-transports": "^1.0.2",
|
|
19
|
+
"esbuild": "^0.25.8",
|
|
20
|
+
"esbuild-plugin-d.ts": "^1.3.1",
|
|
21
|
+
"esbuild-plugin-umd-wrapper": "^3.0.0"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"require": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "node esbuild.bundle.mjs"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -78,41 +78,53 @@ export default class EpoxyTransport implements ProxyTransport {
|
|
|
78
78
|
): Promise<TransferrableResponse> {
|
|
79
79
|
if (body instanceof Blob) body = await body.arrayBuffer();
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
const doRequest = async () => {
|
|
82
|
+
try {
|
|
83
|
+
let headersObj: Record<string, string> = {};
|
|
84
|
+
for (let [key, value] of headers) {
|
|
85
|
+
if (headersObj[key]) {
|
|
86
|
+
console.warn(
|
|
87
|
+
`Duplicate header key "${key}" detected. Overwriting previous value.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
headersObj[key] = value;
|
|
89
91
|
}
|
|
90
|
-
headersObj[key] = value;
|
|
91
|
-
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
let res = await this.client.fetch(remote.href, {
|
|
94
|
+
method,
|
|
95
|
+
body,
|
|
96
|
+
headers: headersObj,
|
|
97
|
+
redirect: "manual",
|
|
98
|
+
});
|
|
99
|
+
let headersEntries: RawHeaders = [];
|
|
100
|
+
for (let [key, value] of Object.entries((res as any).rawHeaders) as any) {
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
for (let v of value) {
|
|
103
|
+
headersEntries.push([key, v]);
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
headersEntries.push([key, value]);
|
|
104
107
|
}
|
|
105
|
-
} else {
|
|
106
|
-
headersEntries.push([key, value]);
|
|
107
108
|
}
|
|
109
|
+
return {
|
|
110
|
+
body: res.body!,
|
|
111
|
+
headers: headersEntries,
|
|
112
|
+
status: res.status,
|
|
113
|
+
statusText: res.statusText,
|
|
114
|
+
};
|
|
115
|
+
} catch (err) {
|
|
116
|
+
throw err;
|
|
108
117
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
statusText: res.statusText,
|
|
114
|
-
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
return await doRequest();
|
|
115
122
|
} catch (err) {
|
|
123
|
+
const msg = String(err);
|
|
124
|
+
if (msg.includes("tls handshake eof") || msg.includes("MuxTaskEnded") || msg.includes("UnexpectedEof")) {
|
|
125
|
+
await this.init();
|
|
126
|
+
return await doRequest();
|
|
127
|
+
}
|
|
116
128
|
console.error(err);
|
|
117
129
|
throw err;
|
|
118
130
|
}
|