-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hi, there seems to be a bug with mdoc.
Issue Summary
When using @sphereon/ssi-types in an ES modules environment ("type": "module"),
the decodeMdocDeviceResponse function fails with a runtime error: Cannot read
properties of undefined (reading 'sphereon').
Environment
- @sphereon/ssi-types: 0.34.0
- @sphereon/kmp-mdoc-core: 0.2.0-SNAPSHOT.26
- Node.js: ES modules ("type": "module" in package.json)
- TypeScript config: "moduleResolution": "bundler", "esModuleInterop": true
Root Cause
The issue occurs due to a module format mismatch between TypeScript declarations
and JavaScript runtime:
- TypeScript declarations: The .d.ts file declares export declare namespace
com.sphereon.mdoc - JavaScript runtime: The actual UMD module exports create nested objects under
default in ES modules - Import pattern: src/utils/mdoc.ts uses import * as mdoc from
'@sphereon/kmp-mdoc-core'
In ES modules environment:
- mdoc.com is undefined
- mdoc.default.com.sphereon contains the actual exports
Stack Trace
error TypeError: Cannot read properties of undefined (reading 'sphereon')
at decodeMdocDeviceResponse
(/node_modules/@sphereon/ssi-types/src/utils/mdoc.ts:75:35)
at toWrappedVerifiablePresentation
(/node_modules/@sphereon/ssi-types/src/mapper/credential-mapper.ts:163:26)
Expected Behavior
The decodeMdocDeviceResponse function should work correctly in ES modules
environments.
Thanks in advance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels