Disallow destructuring internalbinding c#54023
Conversation
|
Review requested:
|
|
I have created the typings for crypto, I don't mind creating the rest, but I wanted to check that I had the correct approach |
typings/internalBinding/crypto.d.ts
Outdated
| setFipsCrypto(bool: boolean): void; | ||
| getSSLCiphers(): unknown; | ||
| getRootCertificates(): unknown; | ||
| } No newline at end of file |
There was a problem hiding this comment.
Can you make sure all files have an EOL?
|
Isn't this something that only matter for certain internal bindings that use the binding object as a receiver, and doesn't apply to all binding objects? Disallowing destructing on all other unrelated bindings would lead to a perf cost and for bindings that are public, this allows users to modify them and affect internals. |
|
I think a better way to enforce the fast API dependency on creation context may be - do not use the receiver. Just make that part of the API - always pass the binding object as the first argument. The linter configs that disallow destructing is not strong enough - someone can still do |
|
|
||
| const { | ||
| codes: { | ||
| ERR_TLS_INVALID_PROTOCOL_VERSION, |
There was a problem hiding this comment.
Destructing symbols and constants should be safe and disallowing this could be way too verbose.
|
@joyeecheung I'm happy to implement your approach, but I'd need some guidance on how to do it and how to identify which bindings need to enforce it |
|
@anonrig can you help me unblock this? |
Basically, look for all the fast APIs (you can probably easily find them by searching |
|
@joyeecheung I created a draft PR with the changes for |
|
Closing in favour of #54408 |
follow up of #53947