Skip to content

Conversation

@marsouin
Copy link

In the DeviceResponse model, I found an always true if statement that throws an error before allowing the creation of the response.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 5027e75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@animo-id/mdoc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

}
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.

@TimoGlastra TimoGlastra enabled auto-merge (squash) October 13, 2025 08:02
auto-merge was automatically disabled October 14, 2025 13:54

Head branch was pushed to by a user without write access

sessionTranscript: options.sessionTranscript,
docType: document.docType,
deviceNamespaces: document.deviceSigned.deviceNamespaces,
deviceNamespaces,
Copy link
Member

Choose a reason for hiding this comment

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

I think this is still incorrect maybe, since we don't want to do any limit disclosure on the device namespaces (as devicenamesaces is the return value of limitDisclosureCb).

See also the 0.5 implementation: https://github.com/animo/mdoc/blob/v0.5.3-alpha-20250322020612/src/mdoc/model/device-response.ts#L353-L376

}

issuerSigned.issuerNamespaces?.issuerNamespaces.set(nameSpace, issuerSignedItems)
deviceNamespaces.set(nameSpace, new DeviceSignedItems({ deviceSignedItems }))
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should set the device namespaces. Also not sure if we should modify the issuer signed directly (input mdoc).

If you look at the 0.5 implementaiton we don't modify the input: https://github.com/animo/mdoc/blob/v0.5.3-alpha-20250322020612/src/mdoc/model/pex-limit-disclosure.ts#L8-L27. So we sohuld update the device namespace to issuer namespaces, and create a new map/object and return that.

const { namespace, digest } = result
const entry = deviceNamespaces.get(namespace)
if (!entry) {
issuerNamespaces.set(namespace, [digest])
Copy link
Member

Choose a reason for hiding this comment

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

SAme here, device namespaces logic needs to be removed, and we only keep issuer namespaces.

Baiscally just copy the 0.5 implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants