verifyNip05 method
This method will verify the internetIdentifier
with a pubKey
using the NIP05 implementation, and simply will return a Future with a bool that indicates if the verification was successful or not.
example:
final verified = await Nostr.instance.relays.verifyNip05(
internetIdentifier: "localPart@domainPart",
pubKey: "pub key in hex format",
);
Implementation
Future<bool> verifyNip05({
required String internetIdentifier,
required String pubKey,
}) async {
assert(
pubKey.length == 64 || !pubKey.startsWith('npub'),
'pub key is invalid, it must be in hex format and not a npub(nip19) key!',
);
assert(
internetIdentifier.contains('@') &&
internetIdentifier.split('@').length == 2,
'invalid internet identifier',
);
try {
final pubKeyFromResponse = await pubKeyFromIdentifierNip05(
internetIdentifier: internetIdentifier,
);
return pubKey == pubKeyFromResponse;
} catch (e) {
logger.log(
'error while verifying nip05 for internet identifier: $internetIdentifier',
e,
);
rethrow;
}
}