Skip to content

feat: add rejectUnauthorized to RequestOptions#741

Open
Copilot wants to merge 5 commits intomasterfrom
copilot/add-reject-unauthorized-to-request-options
Open

feat: add rejectUnauthorized to RequestOptions#741
Copilot wants to merge 5 commits intomasterfrom
copilot/add-reject-unauthorized-to-request-options

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

  • Add rejectUnauthorized property to the RequestOptions type in src/Request.ts
  • Remove the duplicate rejectUnauthorized from the private UrllibRequestOptions interface in src/index.ts
  • Add type check unit test verifying rejectUnauthorized is accepted on RequestOptions type
  • Verify existing tests pass
  • Typecheck passes

Copilot AI linked an issue Apr 12, 2026 that may be closed by this pull request
Move rejectUnauthorized from the private UrllibRequestOptions interface
to the public RequestOptions type, making it available to all users of
the library without needing to create a custom HttpClient.

Agent-Logs-Url: https://github.com/node-modules/urllib/sessions/a83a8fb1-4491-44da-aa68-7bf7d05a4ad4

Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
Copilot AI changed the title [WIP] Add rejectUnauthorized to RequestOptions interface Add rejectUnauthorized to RequestOptions Apr 12, 2026
Copilot AI requested a review from fengmk2 April 12, 2026 12:08
@fengmk2 fengmk2 marked this pull request as ready for review April 16, 2026 11:45
Copilot AI review requested due to automatic review settings April 16, 2026 11:45
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@741

commit: 87fe4b2

@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented Apr 16, 2026

@copilot add type check unit test for this change.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.60%. Comparing base (7fbbc0a) to head (87fe4b2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #741   +/-   ##
=======================================
  Coverage   94.60%   94.60%           
=======================================
  Files          10       10           
  Lines         723      723           
  Branches      226      226           
=======================================
  Hits          684      684           
  Misses         36       36           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 16, 2026

@copilot add type check unit test for this change.

Added a type check unit test in test/options.rejectUnauthorized.typecheck.test.ts that explicitly types options as RequestOptions with rejectUnauthorized set, verifying the type compiles and works at runtime (commit 701a8e0).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes rejectUnauthorized part of the exported RequestOptions type so library consumers can pass it without TypeScript errors when typing options as RequestOptions.

Changes:

  • Moved rejectUnauthorized?: boolean from the internal UrllibRequestOptions in src/index.ts into the public RequestOptions type in src/Request.ts.
  • UrllibRequestOptions now inherits rejectUnauthorized via extends RequestOptions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/index.ts Removes the internal-only rejectUnauthorized option from UrllibRequestOptions now that it’s provided by RequestOptions.
src/Request.ts Adds rejectUnauthorized?: boolean to the exported RequestOptions type (with JSDoc).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Request.ts Outdated
Comment thread src/Request.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
Copilot AI review requested due to automatic review settings April 16, 2026 14:33
@fengmk2 fengmk2 changed the title Add rejectUnauthorized to RequestOptions feat: add rejectUnauthorized to RequestOptions Apr 16, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Request.ts
Comment on lines +164 to +174
/**
* If `true`, the server certificate is verified against the list of supplied CAs.
* If verification fails, the request promise is rejected.
*
* This option is only effective when using the top-level request/curl wrapper with
* its default dispatcher. It may be ignored when using `HttpClient.request()`
* directly or when `dispatcher` is explicitly provided.
*
* Default: `true`
*/
rejectUnauthorized?: boolean;
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RequestOptions is also the options type for HttpClient.request(), but HttpClient never reads options.rejectUnauthorized (it only comes from ClientOptions.connect.rejectUnauthorized or a provided dispatcher). With this change, TypeScript will now accept httpclient.request(url, { rejectUnauthorized: false }), but it will be a no-op at runtime. Consider scoping this to a wrapper-only options type (e.g. exporting a separate UrllibRequestOptions) or implementing per-request handling so the type matches behavior.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rejectUnauthorized to RequestOptions

3 participants