@nsshunt/stsconfig 1.27.4 → 1.27.6
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/stsconfig.mjs +0 -257
- package/dist/stsconfig.mjs.map +1 -1
- package/dist/stsconfig.umd.js +3 -258
- package/dist/stsconfig.umd.js.map +1 -1
- package/package.json +7 -7
- package/types/index.d.ts +0 -2
- package/types/index.d.ts.map +1 -1
- package/types/agentManager.d.ts +0 -29
- package/types/agentManager.d.ts.map +0 -1
- package/types/stsAxiosConfig.d.ts +0 -16
- package/types/stsAxiosConfig.d.ts.map +0 -1
package/dist/stsconfig.mjs
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
9
|
-
set _(value) {
|
|
10
|
-
__privateSet(obj, member, value, setter);
|
|
11
|
-
},
|
|
12
|
-
get _() {
|
|
13
|
-
return __privateGet(obj, member, getter);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
|
|
17
1
|
import { accessSync, constants, readFileSync } from "node:fs";
|
|
18
2
|
import dotenv from "dotenv";
|
|
19
|
-
import http from "node:http";
|
|
20
|
-
import https from "node:https";
|
|
21
3
|
function getDefaultExportFromCjs(x) {
|
|
22
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
23
5
|
}
|
|
@@ -1665,248 +1647,9 @@ const envOptionsHandler = {
|
|
|
1665
1647
|
}
|
|
1666
1648
|
};
|
|
1667
1649
|
const goptions = new Proxy(envOptions, envOptionsHandler);
|
|
1668
|
-
class AgentManager {
|
|
1669
|
-
constructor(agentManagerOptions) {
|
|
1670
|
-
__privateAdd(this, _options);
|
|
1671
|
-
__privateAdd(this, _httpAgent, null);
|
|
1672
|
-
__privateAdd(this, _httpsAgent, null);
|
|
1673
|
-
__privateAdd(this, _agentResetInterval, null);
|
|
1674
|
-
__privateAdd(this, _requestCount, 0);
|
|
1675
|
-
__privateAdd(this, _SetupResetInterval, () => {
|
|
1676
|
-
if (__privateGet(this, _options).agentResetInterval && __privateGet(this, _options).agentResetInterval > 0) {
|
|
1677
|
-
__privateSet(this, _agentResetInterval, setTimeout(() => {
|
|
1678
|
-
this.ResetAgent();
|
|
1679
|
-
__privateGet(this, _SetupResetInterval).call(this);
|
|
1680
|
-
}, __privateGet(this, _options).agentResetInterval).unref());
|
|
1681
|
-
}
|
|
1682
|
-
});
|
|
1683
|
-
__privateAdd(this, _GetAgentOptions, (https2) => {
|
|
1684
|
-
let options;
|
|
1685
|
-
if (__privateGet(this, _options).agentOptions) {
|
|
1686
|
-
options = {
|
|
1687
|
-
keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
|
|
1688
|
-
maxSockets: __privateGet(this, _options).agentOptions.maxSockets,
|
|
1689
|
-
maxTotalSockets: __privateGet(this, _options).agentOptions.maxTotalSockets,
|
|
1690
|
-
maxFreeSockets: __privateGet(this, _options).agentOptions.maxFreeSockets,
|
|
1691
|
-
timeout: __privateGet(this, _options).agentOptions.timeout
|
|
1692
|
-
//@@ config
|
|
1693
|
-
};
|
|
1694
|
-
if (https2 === true) {
|
|
1695
|
-
options.rejectUnauthorized = __privateGet(this, _options).agentOptions.rejectUnauthorized;
|
|
1696
|
-
}
|
|
1697
|
-
} else {
|
|
1698
|
-
options = {
|
|
1699
|
-
keepAlive: process.env.NODE_ENV === "test" ? false : goptions.keepAlive,
|
|
1700
|
-
maxSockets: goptions.maxSockets,
|
|
1701
|
-
maxTotalSockets: goptions.maxTotalSockets,
|
|
1702
|
-
maxFreeSockets: goptions.maxFreeSockets,
|
|
1703
|
-
timeout: 3e4
|
|
1704
|
-
//@@ config
|
|
1705
|
-
};
|
|
1706
|
-
if (https2 === true) {
|
|
1707
|
-
options.rejectUnauthorized = goptions.isProduction;
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
return options;
|
|
1711
|
-
});
|
|
1712
|
-
__privateSet(this, _options, agentManagerOptions);
|
|
1713
|
-
if (__privateGet(this, _options).agentResetInterval) {
|
|
1714
|
-
__privateGet(this, _SetupResetInterval).call(this);
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
get agentResetInterval() {
|
|
1718
|
-
return __privateGet(this, _options).agentResetInterval;
|
|
1719
|
-
}
|
|
1720
|
-
set agentResetInterval(val) {
|
|
1721
|
-
if (__privateGet(this, _agentResetInterval)) {
|
|
1722
|
-
clearTimeout(__privateGet(this, _agentResetInterval));
|
|
1723
|
-
}
|
|
1724
|
-
__privateGet(this, _options).agentResetInterval = val;
|
|
1725
|
-
__privateGet(this, _SetupResetInterval).call(this);
|
|
1726
|
-
}
|
|
1727
|
-
get agentResetCount() {
|
|
1728
|
-
return __privateGet(this, _options).agentResetCount;
|
|
1729
|
-
}
|
|
1730
|
-
set agentResetCount(val) {
|
|
1731
|
-
__privateGet(this, _options).agentResetCount = val;
|
|
1732
|
-
}
|
|
1733
|
-
IncRequestCount() {
|
|
1734
|
-
__privateWrapper(this, _requestCount)._++;
|
|
1735
|
-
if (__privateGet(this, _options).agentResetCount) {
|
|
1736
|
-
if (__privateGet(this, _requestCount) % __privateGet(this, _options).agentResetCount === 0) {
|
|
1737
|
-
this.ResetAgent();
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
IsHttps(protocol) {
|
|
1742
|
-
if (protocol.toLowerCase().startsWith("https:")) {
|
|
1743
|
-
return true;
|
|
1744
|
-
}
|
|
1745
|
-
return false;
|
|
1746
|
-
}
|
|
1747
|
-
GetAgent(protocol) {
|
|
1748
|
-
if (protocol.toLowerCase().startsWith("https:")) {
|
|
1749
|
-
if (__privateGet(this, _httpsAgent) === null) {
|
|
1750
|
-
__privateSet(this, _httpsAgent, new https.Agent(__privateGet(this, _GetAgentOptions).call(this, true)));
|
|
1751
|
-
}
|
|
1752
|
-
return __privateGet(this, _httpsAgent);
|
|
1753
|
-
} else if (protocol.toLowerCase().startsWith("http:")) {
|
|
1754
|
-
if (__privateGet(this, _httpAgent) === null) {
|
|
1755
|
-
__privateSet(this, _httpAgent, new http.Agent(__privateGet(this, _GetAgentOptions).call(this, false)));
|
|
1756
|
-
}
|
|
1757
|
-
return __privateGet(this, _httpAgent);
|
|
1758
|
-
} else {
|
|
1759
|
-
return null;
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
ResetAgent() {
|
|
1763
|
-
__privateSet(this, _httpAgent, null);
|
|
1764
|
-
__privateSet(this, _httpsAgent, null);
|
|
1765
|
-
}
|
|
1766
|
-
/*
|
|
1767
|
-
url
|
|
1768
|
-
,method: 'post'
|
|
1769
|
-
,data: payload
|
|
1770
|
-
,headers: headers
|
|
1771
|
-
,httpsAgent: this.#agentManager.GetAgent(url)
|
|
1772
|
-
*/
|
|
1773
|
-
/*
|
|
1774
|
-
postgresContainer = await new GenericContainer("postgres")
|
|
1775
|
-
.withExposedPorts(5432)
|
|
1776
|
-
.withEnvironment({
|
|
1777
|
-
POSTGRES_PASSWORD: "postgres",
|
|
1778
|
-
//UV_THREADPOOL_SIZE: "64"
|
|
1779
|
-
})
|
|
1780
|
-
.withCommand(['-c', 'max_connections=20'])
|
|
1781
|
-
.start();
|
|
1782
|
-
*/
|
|
1783
|
-
Terminate() {
|
|
1784
|
-
if (__privateGet(this, _agentResetInterval)) {
|
|
1785
|
-
clearTimeout(__privateGet(this, _agentResetInterval));
|
|
1786
|
-
__privateSet(this, _agentResetInterval, null);
|
|
1787
|
-
}
|
|
1788
|
-
if (__privateGet(this, _httpAgent)) {
|
|
1789
|
-
__privateGet(this, _httpAgent).destroy();
|
|
1790
|
-
__privateSet(this, _httpAgent, null);
|
|
1791
|
-
}
|
|
1792
|
-
if (__privateGet(this, _httpsAgent)) {
|
|
1793
|
-
__privateGet(this, _httpsAgent).destroy();
|
|
1794
|
-
__privateSet(this, _httpsAgent, null);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
_options = new WeakMap();
|
|
1799
|
-
_httpAgent = new WeakMap();
|
|
1800
|
-
_httpsAgent = new WeakMap();
|
|
1801
|
-
_agentResetInterval = new WeakMap();
|
|
1802
|
-
_requestCount = new WeakMap();
|
|
1803
|
-
_SetupResetInterval = new WeakMap();
|
|
1804
|
-
_GetAgentOptions = new WeakMap();
|
|
1805
|
-
class STSAxiosConfig {
|
|
1806
|
-
constructor(url, method, headers, timeout) {
|
|
1807
|
-
__privateAdd(this, _url);
|
|
1808
|
-
__privateAdd(this, _method);
|
|
1809
|
-
__privateAdd(this, _headers);
|
|
1810
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1811
|
-
__privateAdd(this, _data);
|
|
1812
|
-
__privateAdd(this, _agentManager);
|
|
1813
|
-
__privateAdd(this, _timeout);
|
|
1814
|
-
__privateAdd(this, _withCredentials);
|
|
1815
|
-
__privateSet(this, _url, url);
|
|
1816
|
-
__privateSet(this, _method, method);
|
|
1817
|
-
if (headers !== void 0) {
|
|
1818
|
-
__privateSet(this, _headers, headers);
|
|
1819
|
-
}
|
|
1820
|
-
if (timeout !== void 0) {
|
|
1821
|
-
__privateSet(this, _timeout, timeout);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
withCookies(cookies) {
|
|
1825
|
-
if (!__privateGet(this, _headers)) {
|
|
1826
|
-
__privateSet(this, _headers, {});
|
|
1827
|
-
}
|
|
1828
|
-
__privateGet(this, _headers)["Cookie"] = cookies.join("; ");
|
|
1829
|
-
return this;
|
|
1830
|
-
}
|
|
1831
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1832
|
-
withData(data) {
|
|
1833
|
-
__privateSet(this, _data, data);
|
|
1834
|
-
return this;
|
|
1835
|
-
}
|
|
1836
|
-
// 'Content-Type': 'application/json'
|
|
1837
|
-
withAuthHeaders(accesssToken, stsUserId) {
|
|
1838
|
-
if (!__privateGet(this, _headers)) {
|
|
1839
|
-
__privateSet(this, _headers, {});
|
|
1840
|
-
}
|
|
1841
|
-
__privateGet(this, _headers)["Content-Type"] = "application/json";
|
|
1842
|
-
__privateGet(this, _headers)["Authorization"] = "Bearer " + accesssToken;
|
|
1843
|
-
if (stsUserId) {
|
|
1844
|
-
__privateGet(this, _headers)["x-sts_user_id"] = stsUserId;
|
|
1845
|
-
}
|
|
1846
|
-
return this;
|
|
1847
|
-
}
|
|
1848
|
-
withHeaders(headers) {
|
|
1849
|
-
__privateSet(this, _headers, headers);
|
|
1850
|
-
return this;
|
|
1851
|
-
}
|
|
1852
|
-
withDefaultHeaders() {
|
|
1853
|
-
if (!__privateGet(this, _headers)) {
|
|
1854
|
-
__privateSet(this, _headers, {});
|
|
1855
|
-
}
|
|
1856
|
-
__privateGet(this, _headers)["Content-Type"] = "application/json";
|
|
1857
|
-
return this;
|
|
1858
|
-
}
|
|
1859
|
-
withCredentials() {
|
|
1860
|
-
__privateSet(this, _withCredentials, true);
|
|
1861
|
-
return this;
|
|
1862
|
-
}
|
|
1863
|
-
withTimeout(timeout) {
|
|
1864
|
-
__privateSet(this, _timeout, timeout);
|
|
1865
|
-
return this;
|
|
1866
|
-
}
|
|
1867
|
-
withAgentManager(agentManager) {
|
|
1868
|
-
__privateSet(this, _agentManager, agentManager);
|
|
1869
|
-
return this;
|
|
1870
|
-
}
|
|
1871
|
-
get config() {
|
|
1872
|
-
const retVal = {
|
|
1873
|
-
url: __privateGet(this, _url),
|
|
1874
|
-
method: __privateGet(this, _method)
|
|
1875
|
-
};
|
|
1876
|
-
if (__privateGet(this, _headers)) {
|
|
1877
|
-
retVal.headers = __privateGet(this, _headers);
|
|
1878
|
-
}
|
|
1879
|
-
if (__privateGet(this, _agentManager) !== void 0) {
|
|
1880
|
-
if (__privateGet(this, _agentManager).IsHttps(__privateGet(this, _url))) {
|
|
1881
|
-
retVal.httpsAgent = __privateGet(this, _agentManager).GetAgent(__privateGet(this, _url));
|
|
1882
|
-
} else {
|
|
1883
|
-
retVal.httpAgent = __privateGet(this, _agentManager).GetAgent(__privateGet(this, _url));
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
if (__privateGet(this, _data) !== void 0) {
|
|
1887
|
-
retVal.data = __privateGet(this, _data);
|
|
1888
|
-
}
|
|
1889
|
-
if (__privateGet(this, _timeout) !== void 0) {
|
|
1890
|
-
retVal.timeout = __privateGet(this, _timeout);
|
|
1891
|
-
}
|
|
1892
|
-
if (__privateGet(this, _withCredentials) !== void 0 && __privateGet(this, _withCredentials) === true) {
|
|
1893
|
-
retVal.withCredentials = true;
|
|
1894
|
-
}
|
|
1895
|
-
return retVal;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
_url = new WeakMap();
|
|
1899
|
-
_method = new WeakMap();
|
|
1900
|
-
_headers = new WeakMap();
|
|
1901
|
-
_data = new WeakMap();
|
|
1902
|
-
_agentManager = new WeakMap();
|
|
1903
|
-
_timeout = new WeakMap();
|
|
1904
|
-
_withCredentials = new WeakMap();
|
|
1905
1650
|
export {
|
|
1906
1651
|
$ResetOptions,
|
|
1907
1652
|
$ResetOptionsEx,
|
|
1908
|
-
AgentManager,
|
|
1909
|
-
STSAxiosConfig,
|
|
1910
1653
|
goptions
|
|
1911
1654
|
};
|
|
1912
1655
|
//# sourceMappingURL=stsconfig.mjs.map
|