-
Notifications
You must be signed in to change notification settings - Fork 6
fix: always true statement throws error #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
69d23f5
fa8acd6
2ff9058
d07a34f
4e8f737
5baff4f
4a14665
5027e75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@animo-id/mdoc": patch | ||
| --- | ||
|
|
||
| fix: always true statement throws error. In the DeviceResponse model there was an always true if statement that throws an error before allowing the creation of the response. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| import type { DataElementIdentifier } from './data-element-identifier.js' | ||
| import type { DataElementValue } from './data-element-value.js' | ||
| import { DeviceNamespaces } from './device-namespaces.js' | ||
| import { DeviceSignedItems } from './device-signed-items.js' | ||
| import type { DocRequest } from './doc-request.js' | ||
| import type { DocType } from './doctype.js' | ||
| import type { Document } from './document.js' | ||
| import type { IssuerNamespace } from './issuer-namespace.js' | ||
| import type { IssuerSignedItem } from './issuer-signed-item.js' | ||
| import type { IssuerSigned } from './issuer-signed.js' | ||
| import type { InputDescriptor } from './presentation-definition.js' | ||
| import type { DataElementIdentifier } from './data-element-identifier' | ||
| import type { DataElementValue } from './data-element-value' | ||
| import { DeviceNamespaces } from './device-namespaces' | ||
| import { DeviceSignedItems } from './device-signed-items' | ||
| import type { DocRequest } from './doc-request' | ||
| import type { DocType } from './doctype' | ||
| import type { Document } from './document' | ||
| import { IssuerNamespace } from './issuer-namespace' | ||
| import type { IssuerSignedItem } from './issuer-signed-item' | ||
| import type { IssuerSigned } from './issuer-signed' | ||
| import type { InputDescriptor } from './presentation-definition' | ||
|
|
||
| export const limitDisclosureToDeviceRequestNameSpaces = ( | ||
| issuerSigned: IssuerSigned, | ||
|
|
@@ -34,6 +34,7 @@ export const limitDisclosureToDeviceRequestNameSpaces = ( | |
| deviceSignedItems.set(issuerSignedItem.elementIdentifier, issuerSignedItem.elementValue) | ||
| } | ||
|
|
||
| issuerSigned.issuerNamespaces?.issuerNamespaces.set(nameSpace, issuerSignedItems) | ||
| deviceNamespaces.set(nameSpace, new DeviceSignedItems({ deviceSignedItems })) | ||
|
||
| } | ||
|
|
||
|
|
@@ -147,6 +148,8 @@ export const limitDisclosureToInputDescriptor = ( | |
| ): DeviceNamespaces => { | ||
| const deviceNamespaces: Map<string, DeviceSignedItems> = new Map() | ||
|
|
||
| const issuerNamespaces = new Map() | ||
|
|
||
| for (const field of inputDescriptor.constraints.fields) { | ||
| const result = prepareDigestForInputDescriptor(field.path, issuerSigned.issuerNamespaces) | ||
|
|
||
|
|
@@ -163,12 +166,14 @@ export const limitDisclosureToInputDescriptor = ( | |
| const { namespace, digest } = result | ||
| const entry = deviceNamespaces.get(namespace) | ||
| if (!entry) { | ||
| issuerNamespaces.set(namespace, [digest]) | ||
|
||
| deviceNamespaces.set(namespace, issuerSignedItemToDeviceSignedItems(digest)) | ||
| } else { | ||
| issuerNamespaces.get(namespace).push(digest) | ||
| entry.deviceSignedItems.set(digest.elementIdentifier, digest.elementValue) | ||
| } | ||
| } | ||
|
|
||
| issuerSigned.issuerNamespaces = new IssuerNamespace({ issuerNamespaces }) | ||
| return new DeviceNamespaces({ deviceNamespaces }) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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