fix(ext/node): set socket.authorized to true for https request (#30641)

This PR sets true to `req.socket.authorized` when making https request
from `node:https` module.

This makes yarn classic's https client working (e.g. `yarn add cowsay`).

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Yoshiya Hinosawa 2025-09-09 05:29:41 +09:00 committed by GitHub
parent 928f26db78
commit 6ee7d60ce1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,27 @@
// Copyright 2018-2025 the Deno authors. MIT license.
import https from "node:https";
import { assert } from "../unit/test_util.ts";
Deno.test({
name:
"request.socket.authorized is true when successfully requested to https server",
async fn() {
const server = Deno.serve({
port: 0,
cert: Deno.readTextFileSync("tests/testdata/tls/localhost.crt"),
key: Deno.readTextFileSync("tests/testdata/tls/localhost.key"),
onListen({ port }) {
const req = https.request(`https://localhost:${port}`, (res) => {
// deno-lint-ignore no-explicit-any
assert((req.socket as any).authorized);
res.destroy();
server.shutdown();
});
},
}, () => {
return new Response("hi");
});
await server.finished;
},
});