feat: add rejectUnauthorized to RequestOptions#741
Conversation
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>
commit: |
|
@copilot add type check unit test for this change. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/node-modules/urllib/sessions/2e15ca49-d44d-4289-a8a5-330ea939ca53 Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
There was a problem hiding this comment.
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?: booleanfrom the internalUrllibRequestOptionsinsrc/index.tsinto the publicRequestOptionstype insrc/Request.ts. UrllibRequestOptionsnow inheritsrejectUnauthorizedviaextends 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
There was a problem hiding this comment.
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.
| /** | ||
| * 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; |
There was a problem hiding this comment.
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.
rejectUnauthorizedproperty to theRequestOptionstype insrc/Request.tsrejectUnauthorizedfrom the privateUrllibRequestOptionsinterface insrc/index.tsrejectUnauthorizedis accepted onRequestOptionstype