test-lib20260119 1.0.7 → 1.0.9

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.
@@ -0,0 +1,35 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Setup Node
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: "20"
23
+ registry-url: "https://registry.npmjs.org"
24
+
25
+ - name: Upgrade npm for OIDC support
26
+ run: npm i -g npm@11.5.1
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Build (if needed)
32
+ run: npm run build --if-present
33
+
34
+ - name: Publish
35
+ run: npm publish
package/npm-proxy.js ADDED
@@ -0,0 +1,44 @@
1
+ const http = require("http");
2
+ const https = require("https");
3
+ const { URL } = require("url");
4
+
5
+ const PORT = process.env.PORT;
6
+ if (!PORT) {
7
+ console.error("PORT is required");
8
+ process.exit(1);
9
+ }
10
+
11
+ const TARGET = new URL("https://registry.npmjs.org");
12
+
13
+ const server = http.createServer((req, res) => {
14
+ const targetUrl = new URL(req.url, TARGET);
15
+ const headers = { ...req.headers, host: TARGET.host };
16
+ const options = {
17
+ protocol: TARGET.protocol,
18
+ hostname: TARGET.hostname,
19
+ port: TARGET.port || 443,
20
+ method: req.method,
21
+ path: `${targetUrl.pathname}${targetUrl.search}`,
22
+ headers,
23
+ };
24
+
25
+ const proxyReq = https.request(options, (proxyRes) => {
26
+ res.writeHead(proxyRes.statusCode || 502, proxyRes.headers);
27
+ proxyRes.pipe(res);
28
+ });
29
+
30
+ proxyReq.on("error", () => {
31
+ res.statusCode = 502;
32
+ res.end("Bad Gateway");
33
+ });
34
+
35
+ req.pipe(proxyReq);
36
+ });
37
+
38
+ server.on("clientError", (_err, socket) => {
39
+ socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
40
+ });
41
+
42
+ server.listen(Number(PORT), "0.0.0.0", () => {
43
+ console.log(`npm proxy listening on :${PORT}`);
44
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-lib20260119",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"