Skip to content

Commit

Permalink
fix(did-comm): fix potential null exception when unpacking message
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Jul 14, 2021
1 parent c33e39e commit 584766c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/did-comm/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function decodeJoseBlob(blob: string) {
}

export function isDefined<T>(arg: T): arg is Exclude<T, null | undefined> {
return typeof arg !== 'undefined'
return arg && typeof arg !== 'undefined'
}

export function createEcdhWrapper(secretKeyRef: string, context: IAgentContext<IKeyManager>): ECDH {
Expand Down Expand Up @@ -173,7 +173,7 @@ export async function mapIdentifierKeysToDoc(
context,
)

let localKeys = identifier.keys
let localKeys = identifier.keys.filter(isDefined)
if (section === 'keyAgreement') {
localKeys = convertIdentifierEncryptionKeys(identifier)
}
Expand Down

0 comments on commit 584766c

Please sign in to comment.