Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/mdoc/models/device-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ export class DeviceResponse extends CborStructure {
},
ctx: Pick<MdocContext, 'crypto' | 'cose'>
) {
if (!(options.mac && options.signature) || (options.mac && options.signature)) {
throw new EitherSignatureOrMacMustBeProvidedError()
}
const hasMac = !!options.mac
const hasSignature = !!options.signature
if (hasMac === hasSignature) throw new EitherSignatureOrMacMustBeProvidedError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very elegant way to compare it, nice!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of a repeat with the next line const useSignature = !!options.signature but I thought it would be clearer that way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm it seems the type validation fails:

Error: src/mdoc/models/device-response.ts(169,39): error TS18048: 'options.mac' is possibly 'undefined'.
Error: src/mdoc/models/device-response.ts(169,64): error TS18048: 'options.signature' is possibly 'undefined'.
Error: src/mdoc/models/device-response.ts(221,29): error TS2532: Object is possibly 'undefined'.
 ELIFECYCLE  Command failed with exit code 2.
Error: Process completed with exit code 2.

Copy link
Author

@marsouin marsouin Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, weirdly it was already the case, but I've noticed it as well and will do another PR on this as there are more errors down the line anyway.


const useSignature = !!options.signature
const signingKey = useSignature ? options.mac.signingKey : options.signature.signingKey
Expand Down