Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Apply auto lint fixer #56

Merged
merged 7 commits into from
Nov 9, 2022
Merged

Apply auto lint fixer #56

merged 7 commits into from
Nov 9, 2022

Conversation

ddimaria
Copy link
Collaborator

@ddimaria ddimaria commented Nov 3, 2022

  • Apply auto fixer
  • Manually fix remaining lints
  • Fix CI
  • Refactor tests and code (partial)

I started to refactor, but then stopped as this should primarily be a lint-fix PR. We plan to fully document (jsdoc) all public functions, so just placeholders are in there for now. I'll fill those in within another PR.

@ddimaria ddimaria marked this pull request as ready for review November 7, 2022 22:04
Copy link

@GlenDC GlenDC left a comment

Choose a reason for hiding this comment

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

Looks good in general just a couple of questions and remarks on my end.


export class InvalidFingerprintError extends WebRTCTransportError {
constructor (fingerprint: string, source: string) {
super(`Invalid fingerprint "${fingerprint}" within ${source}`)
Copy link

Choose a reason for hiding this comment

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

For security reasons one does usually not add such details to an error, even though it might be UX. Dunno. Up to you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the fingerprint or source reveal any identifying information about the users or system?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no objection to removing the fingerprint from the message. If this happens it would require a pretty in-depth investigation anyhow, and the debugger would have access to their own fingerprints.

@ddimaria - I didn't see your mention of me because notifications to my personal Github account go to spam.

Copy link
Collaborator

@ckousik ckousik Nov 8, 2022

Choose a reason for hiding this comment

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

The fingerprint is public in the multiaddr and cannot reveal any information not available to an attacker.

src/muxer.ts Show resolved Hide resolved
src/sdp.ts Show resolved Hide resolved
src/sdp.ts Show resolved Hide resolved
src/sdp.ts Show resolved Hide resolved
src/sdp.ts Show resolved Hide resolved
src/stream.ts Show resolved Hide resolved
src/stream.ts Show resolved Hide resolved
src/stream.ts Show resolved Hide resolved
src/transport.ts Show resolved Hide resolved
Copy link
Contributor

@plauche plauche left a comment

Choose a reason for hiding this comment

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

Overall the changes look good, but I have my concerns about how it will affect importing this package. I pulled down this branch locally, built it, and imported the local folder into our demo project. I saw breakage related to removing the .js file extensions in internal imports. This may not be an issue when we cut an actual release and import that, but I thought it was still worth raising.


export class InvalidFingerprintError extends WebRTCTransportError {
constructor (fingerprint: string, source: string) {
super(`Invalid fingerprint "${fingerprint}" within ${source}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the fingerprint or source reveal any identifying information about the users or system?

src/maconn.ts Outdated
import { logger } from '@libp2p/logger'
import { Multiaddr } from '@multiformats/multiaddr'
import { Source, Sink } from 'it-stream-types'
import { nopSink, nopSource } from './util'
Copy link
Contributor

Choose a reason for hiding this comment

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

It's interesting that the linter wants to remove the .js file extensions from these imports. I had to add them in order to import this repo as a source dependency. Maybe that is all worked out once actual releases are made for importing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The linter did not request that, but I was able to get it working w/o the extensions, so went that way since it looks cleaner. Do I need to add them back (note: only some imports had the extensions).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll take a look at the dist creation process, seems like this shouldn't be happening.

Copy link
Collaborator Author

@ddimaria ddimaria Nov 8, 2022

Choose a reason for hiding this comment

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

Did you run aegir release?

Copy link
Contributor

Choose a reason for hiding this comment

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

I found it was only required for imports from source files local to the package. It looks like the js-libp2p project retains the extensions for their imports from local package files, see their index.ts as an example.

Copy link
Contributor

@plauche plauche Nov 8, 2022

Choose a reason for hiding this comment

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

I ran npx aegir release on my local copy of this branch, and then attempted to build the demo source which imports the local branch copy. I still saw the same resolution error which even suggests adding the file extension:

Module not found: Error: Can't resolve './transport' in '/Users/ryanplauche/Development/LBL/Protocol/js-libp2p-webrtc/dist/src'
Did you mean 'transport.js'?
BREAKING CHANGE: The request './transport' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting, I thought adding the extensions was an anti-pattern since it's done implicitly. I'll add them back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is reverted. I also separated out the src imports from the package imports and did some OCD reordering.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to be the case in js-libp2p also.

@ddimaria ddimaria requested a review from plauche November 8, 2022 16:34
Copy link
Contributor

@plauche plauche left a comment

Choose a reason for hiding this comment

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

Pulled the source again and was able to build without resolution errors!

constructor(msg: string) {
super('There was a problem with the Multiaddr which was passed in: ' + msg);
this.name = 'WebRTC/InappropriateMultiaddrError';
constructor (msg: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this space very surprising, but if that's what the TS folks want 🤷

@ddimaria ddimaria merged commit f15cafc into develop Nov 9, 2022
@github-actions
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants