Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHT creation, refactor, and more #53

Closed
wants to merge 43 commits into from
Closed

DHT creation, refactor, and more #53

wants to merge 43 commits into from

Conversation

fingersonfire
Copy link
Contributor

I apologize for the large PR but I will create GitHub issues for now on and tackle smaller pieces via more focused PRs. As for this PR though I've made quite a few updates in hopes of keeping the dream alive.

Changelog:

  • Created DHT DID create method (publishing still needs work, mainly the DNS packet creation)
  • Created new package called keychain and a class that extends KeyManager for interacting with the Apple Keychain
  • Reorganized to more closely resemble the structure of the web5-swift repo
  • Added additional documentation to the DnsHeader class
  • Misc tweaks

@angiejones
Copy link

yoooo @StonePack we appreciate you! 🙌🏾

@mistermoe
Copy link
Contributor

Nice @StonePack !! will dig into this ASAP

@fingersonfire
Copy link
Contributor Author

Nice @StonePack !! will dig into this ASAP

Awesome! I'm still learning the intricacies of web5 as I go and it's probably not perfect so any feedback would be amazing

@mistermoe
Copy link
Contributor

@StonePack regarding restructuring the package, specifically moving jwk, jws, jwt inside crypto:

the reason i kept them outside is to avoid circular imports. the way you've got it makes it such that dids depends on crypto (example) and crypto depends on dids (example).

I'm relatively certain dart's compilation accommodates for circular imports but wasn't 100% sure so this may actually work totally fine. Though conceptually, was trying to keep the dependency tree acyclic to reduce cognitive overhead coming from other languages

@fingersonfire
Copy link
Contributor Author

@mistermoe That makes sense, I tried to avoid circular imports but didn't even notice that one. I'll move those back out because you're right, even if the language handles it, it could still be confusing.

@fingersonfire
Copy link
Contributor Author

@mistermoe Okay I moved jws and jwt back under the /src folder but left jwk under /crypto since that is where it was originally

Comment on lines 4 to 15
import 'package:keychain/keychain.dart';
import 'package:web5/web5.dart';

class IosKeyManager implements KeyManager, KeyImporter, KeyExporter {
@override
Future<String> generatePrivateKey(AlgorithmId algId) async {
final Jwk privateKeyJwk = await Crypto.generatePrivateKey(algId);
final String alias = privateKeyJwk.computeThumbprint();

await Keychain.set(alias, json.encode(privateKeyJwk.toJson()));
return alias;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@mistermoe and @StonePack do we want web5-dart to be flutter aware? I feel like given that it's a "pure dart" package we probably should avoid dependencies that require Flutter.

Maybe an alternative here is to keep this IosKeyManager out of the dart package completely and when it's needed for a Flutter project we could add a web5-flutter package.

Maybe this repo can have the structure:

- packages
  - web5-dart
  - web5-flutter (this one would have the iOSKeyManager and Keychain stuff)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's a great call, this key manager could easily be added to a web5-flutter package which can be used in tandem with the web5-dart package. I'll pull it out for now and if tbd wants to host a web5-flutter package I can create a separate PR or I'll just stash it until that time comes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the iOS key manager code and created a new repo as reference for that work: https://github.com/stonepack/web5-flutter

@ALRubinger
Copy link

Welcome to the TBD Community @StonePack - Thank you!! Great seeing you in the scoping call the other day.

@fingersonfire
Copy link
Contributor Author

fingersonfire commented Mar 27, 2024

@ALRubinger I'm excited to be in the community, I look forward to attending more events!

@fingersonfire
Copy link
Contributor Author

@mistermoe @wesbillman Just wanted to ping and see if there were any other changes or suggestions y'all had before I switch focus to working on other stuffs.

@mistermoe
Copy link
Contributor

@StonePack wrapping up review right now!

@mistermoe
Copy link
Contributor

@StonePack would it be possible to tease out the changes specific to DHT creation and open a smaller PR? would love to get that merged in ASAP bc it's awesome work. We can tackle restructuring the package, renaming files, and moving stuff around in subsequent PRs.

@fingersonfire
Copy link
Contributor Author

@StonePack would it be possible to tease out the changes specific to DHT creation and open a smaller PR? would love to get that merged in ASAP bc it's awesome work. We can tackle restructuring the package, renaming files, and moving stuff around in subsequent PRs.

You bet, I'll go ahead and close this PR and open another for DHT creation.

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.

5 participants