From d52205e87965ba2cb38b43fc50b57d28b9998786 Mon Sep 17 00:00:00 2001 From: Ethan Lee <125412902+ethan-tbd@users.noreply.github.com> Date: Fri, 26 Apr 2024 09:42:12 -0700 Subject: [PATCH] fix: make `BearerDid` null-safe (#74) --- packages/web5/lib/src/dids/bearer_did.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/web5/lib/src/dids/bearer_did.dart b/packages/web5/lib/src/dids/bearer_did.dart index c871880..2426d3f 100644 --- a/packages/web5/lib/src/dids/bearer_did.dart +++ b/packages/web5/lib/src/dids/bearer_did.dart @@ -40,8 +40,12 @@ class BearerDid { } final keyExporter = keyManager as KeyExporter; - for (final vm in document.verificationMethod!) { - final publicKeyJwk = vm.publicKeyJwk!; + for (final vm in document.verificationMethod ?? []) { + if (vm.publicKeyJwk == null) { + continue; + } + + final publicKeyJwk = vm.publicKeyJwk; final keyId = publicKeyJwk.computeThumbprint(); final jwk = await keyExporter.export(keyId);