Skip to content

Commit

Permalink
feat: Add universal resolver #1859
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Sep 1, 2023
1 parent 26b821f commit 4acc7c2
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,44 +346,15 @@ class OIDC4VC {

Future<Response<Map<String, dynamic>>> getDidDocument(String didKey) async {
try {
if (didKey.startsWith('did:ebsi')) {
final didDocument = await client.get<Map<String, dynamic>>(
'https://api-pilot.ebsi.eu/did-registry/v3/identifiers/$didKey',
);
return didDocument;
} else if (didKey.startsWith('did:web')) {
final url = didWebToUrl(didKey);
final didDocument = await client.get<Map<String, dynamic>>(url);
return didDocument;
} else {
throw Exception();
}
final didDocument = await client.get<Map<String, dynamic>>(
'https://unires:[email protected]/1.0/identifiers/$didKey',
);
return didDocument;
} catch (e) {
throw Exception(e);
}
}

String didWebToUrl(String didKey) {
if (!didKey.startsWith('did:web:')) {
throw const FormatException('Invalid DID format');
}

// Extract the path after 'did:web:'
final didPath = didKey.substring('did:web:'.length);

if (didPath.contains(':')) {
final parts = didPath.split(':');
final domain = parts[0];
final issuer = parts[1];

final url = 'https://$domain/$issuer/did.json';
return url;
} else {
final url = 'https://$didPath/.well-known/did.json';
return url;
}
}

Future<String> readTokenEndPoint(
Map<String, dynamic> openidConfigurationResponse,
) async {
Expand Down

0 comments on commit 4acc7c2

Please sign in to comment.