@gjsify/https 0.3.13 → 0.3.15

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.
Files changed (2) hide show
  1. package/lib/esm/index.js +94 -70
  2. package/package.json +5 -5
package/lib/esm/index.js CHANGED
@@ -1,80 +1,104 @@
1
- import { request as httpRequest, get as httpGet, Server as HttpServer } from "node:http";
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
- class Agent {
5
- defaultPort = 443;
6
- protocol = "https:";
7
- maxSockets = Infinity;
8
- maxFreeSockets = 256;
9
- constructor(_options) {
10
- }
11
- destroy() {
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
- if (typeof url === "string") {
17
- if (url.startsWith("https://") || url.startsWith("http://")) {
18
- return httpRequest(url, options, callback);
19
- }
20
- const opts2 = { hostname: url, protocol: "https:", port: 443 };
21
- if (typeof options === "object") Object.assign(opts2, options);
22
- if (typeof options === "function") callback = options;
23
- return httpRequest(opts2, callback);
24
- }
25
- if (url instanceof URL) {
26
- return httpRequest(url, options, callback);
27
- }
28
- const opts = { protocol: "https:", port: 443, ...url };
29
- if (typeof options === "function") callback = options;
30
- return httpRequest(opts, callback);
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
- if (typeof url === "string") {
34
- if (url.startsWith("https://") || url.startsWith("http://")) {
35
- return httpGet(url, options, callback);
36
- }
37
- const opts2 = { hostname: url, protocol: "https:", port: 443 };
38
- if (typeof options === "object") Object.assign(opts2, options);
39
- if (typeof options === "function") callback = options;
40
- return httpGet(opts2, callback);
41
- }
42
- if (url instanceof URL) {
43
- return httpGet(url, options, callback);
44
- }
45
- const opts = { protocol: "https:", port: 443, ...url, method: "GET" };
46
- if (typeof options === "function") callback = options;
47
- return httpGet(opts, callback);
48
- }
49
- class Server extends HttpServer {
50
- constructor(options, requestListener) {
51
- super(requestListener);
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
- if (typeof optionsOrListener === "function") {
56
- return new Server(void 0, optionsOrListener);
57
- }
58
- return new Server(optionsOrListener, requestListener);
87
+ if (typeof optionsOrListener === "function") {
88
+ return new Server(undefined, optionsOrListener);
89
+ }
90
+ return new Server(optionsOrListener, requestListener);
59
91
  }
60
- var index_default = {
61
- Agent,
62
- globalAgent,
63
- Server,
64
- request,
65
- get,
66
- createServer,
67
- TLSSocket,
68
- createSecureContext
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.13",
3
+ "version": "0.3.15",
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.13",
34
- "@gjsify/unit": "^0.3.13",
33
+ "@gjsify/cli": "^0.3.15",
34
+ "@gjsify/unit": "^0.3.15",
35
35
  "@types/node": "^25.6.0",
36
36
  "typescript": "^6.0.3"
37
37
  },
38
38
  "dependencies": {
39
- "@gjsify/http": "^0.3.13",
40
- "@gjsify/tls": "^0.3.13"
39
+ "@gjsify/http": "^0.3.15",
40
+ "@gjsify/tls": "^0.3.15"
41
41
  }
42
42
  }