@gjsify/https 0.3.13 → 0.3.14
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/lib/esm/index.js +94 -70
- package/package.json +5 -5
package/lib/esm/index.js
CHANGED
|
@@ -1,80 +1,104 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Server as Server$1, get as get$1, request as request$1 } from "node:http";
|
|
2
2
|
import { TLSSocket, createSecureContext } from "node:tls";
|
|
3
3
|
import { URL } from "node:url";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* HTTPS Agent for connection pooling (stub — Soup.Session handles TLS internally).
|
|
8
|
+
*/
|
|
9
|
+
var Agent = class {
|
|
10
|
+
defaultPort = 443;
|
|
11
|
+
protocol = "https:";
|
|
12
|
+
maxSockets = Infinity;
|
|
13
|
+
maxFreeSockets = 256;
|
|
14
|
+
constructor(_options) {}
|
|
15
|
+
destroy() {}
|
|
16
|
+
};
|
|
14
17
|
const globalAgent = new Agent();
|
|
18
|
+
/**
|
|
19
|
+
* Make an HTTPS request.
|
|
20
|
+
* Soup.Session handles TLS natively — we just ensure protocol is https:.
|
|
21
|
+
*/
|
|
15
22
|
function request(url, options, callback) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
if (typeof url === "string") {
|
|
24
|
+
if (url.startsWith("https://") || url.startsWith("http://")) {
|
|
25
|
+
return request$1(url, options, callback);
|
|
26
|
+
}
|
|
27
|
+
const opts = {
|
|
28
|
+
hostname: url,
|
|
29
|
+
protocol: "https:",
|
|
30
|
+
port: 443
|
|
31
|
+
};
|
|
32
|
+
if (typeof options === "object") Object.assign(opts, options);
|
|
33
|
+
if (typeof options === "function") callback = options;
|
|
34
|
+
return request$1(opts, callback);
|
|
35
|
+
}
|
|
36
|
+
if (url instanceof URL) {
|
|
37
|
+
return request$1(url, options, callback);
|
|
38
|
+
}
|
|
39
|
+
const opts = {
|
|
40
|
+
protocol: "https:",
|
|
41
|
+
port: 443,
|
|
42
|
+
...url
|
|
43
|
+
};
|
|
44
|
+
if (typeof options === "function") callback = options;
|
|
45
|
+
return request$1(opts, callback);
|
|
31
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Make an HTTPS GET request (convenience wrapper).
|
|
49
|
+
*/
|
|
32
50
|
function get(url, options, callback) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (typeof url === "string") {
|
|
52
|
+
if (url.startsWith("https://") || url.startsWith("http://")) {
|
|
53
|
+
return get$1(url, options, callback);
|
|
54
|
+
}
|
|
55
|
+
const opts = {
|
|
56
|
+
hostname: url,
|
|
57
|
+
protocol: "https:",
|
|
58
|
+
port: 443
|
|
59
|
+
};
|
|
60
|
+
if (typeof options === "object") Object.assign(opts, options);
|
|
61
|
+
if (typeof options === "function") callback = options;
|
|
62
|
+
return get$1(opts, callback);
|
|
63
|
+
}
|
|
64
|
+
if (url instanceof URL) {
|
|
65
|
+
return get$1(url, options, callback);
|
|
66
|
+
}
|
|
67
|
+
const opts = {
|
|
68
|
+
protocol: "https:",
|
|
69
|
+
port: 443,
|
|
70
|
+
...url,
|
|
71
|
+
method: "GET"
|
|
72
|
+
};
|
|
73
|
+
if (typeof options === "function") callback = options;
|
|
74
|
+
return get$1(opts, callback);
|
|
53
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* HTTPS Server — wraps TLS server with HTTP request handling.
|
|
78
|
+
* Uses tls.createServer for the TLS layer and processes HTTP
|
|
79
|
+
* requests on top.
|
|
80
|
+
*/
|
|
81
|
+
var Server = class extends Server$1 {
|
|
82
|
+
constructor(options, requestListener) {
|
|
83
|
+
super(requestListener);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
54
86
|
function createServer(optionsOrListener, requestListener) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
87
|
+
if (typeof optionsOrListener === "function") {
|
|
88
|
+
return new Server(undefined, optionsOrListener);
|
|
89
|
+
}
|
|
90
|
+
return new Server(optionsOrListener, requestListener);
|
|
59
91
|
}
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
Agent,
|
|
72
|
-
Server,
|
|
73
|
-
TLSSocket,
|
|
74
|
-
createSecureContext,
|
|
75
|
-
createServer,
|
|
76
|
-
index_default as default,
|
|
77
|
-
get,
|
|
78
|
-
globalAgent,
|
|
79
|
-
request
|
|
92
|
+
var src_default = {
|
|
93
|
+
Agent,
|
|
94
|
+
globalAgent,
|
|
95
|
+
Server,
|
|
96
|
+
request,
|
|
97
|
+
get,
|
|
98
|
+
createServer,
|
|
99
|
+
TLSSocket,
|
|
100
|
+
createSecureContext
|
|
80
101
|
};
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { Agent, Server, TLSSocket, createSecureContext, createServer, src_default as default, get, globalAgent, request };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/https",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "Node.js https module for Gjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"https"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@gjsify/cli": "^0.3.
|
|
34
|
-
"@gjsify/unit": "^0.3.
|
|
33
|
+
"@gjsify/cli": "^0.3.14",
|
|
34
|
+
"@gjsify/unit": "^0.3.14",
|
|
35
35
|
"@types/node": "^25.6.0",
|
|
36
36
|
"typescript": "^6.0.3"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@gjsify/http": "^0.3.
|
|
40
|
-
"@gjsify/tls": "^0.3.
|
|
39
|
+
"@gjsify/http": "^0.3.14",
|
|
40
|
+
"@gjsify/tls": "^0.3.14"
|
|
41
41
|
}
|
|
42
42
|
}
|