Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
feat: add default DidResolver (#6)
Browse files Browse the repository at this point in the history
* add default did method resolvers

* update `DapResolver()` to use default method resolvers

* `did:jwk` doesn't support support `service` in did docs
  • Loading branch information
ethanwlee authored Jun 25, 2024
1 parent 8adbeac commit 7f5da75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 11 additions & 2 deletions lib/src/dap_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ class DapResolver {
http.Client client;
DidResolver didResolver;

DapResolver(this.didResolver, {http.Client? client})
: client = client ?? http.Client();
static final _defaultMethodResolvers = [
DidDhtResolver(),
DidWebResolver(),
];

DapResolver({
DidResolver? didResolver,
http.Client? client,
}) : didResolver = didResolver ??
DidResolver(methodResolvers: _defaultMethodResolvers),
client = client ?? http.Client();

Future<List<MoneyAddress>> getMoneyAddresses(Dap dap) async {
throw UnimplementedError();
Expand Down
5 changes: 1 addition & 4 deletions test/dap_resolver_test.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import 'package:dap/dap.dart';
import 'package:test/test.dart';
import 'package:web5/web5.dart';

void main() {
group('DapResolver.resolve', () {
test('should resolve DAP', () async {
final dap = Dap.parse('@moegrammer/didpay.me');

// TODO: use mocks
final resolver = DapResolver(DidResolver(
methodResolvers: [DidWebResolver()],
));
final resolver = DapResolver();

final result = await resolver.resolve(dap);

Expand Down

0 comments on commit 7f5da75

Please sign in to comment.