Skip to content

Add nfc support#98

Merged
dlongley merged 5 commits intomainfrom
add-nfc-support
Jan 26, 2026
Merged

Add nfc support#98
dlongley merged 5 commits intomainfrom
add-nfc-support

Conversation

@bparth24
Copy link
Copy Markdown
Contributor

Replaces PR#93 - feedback addressed, rebased cleanly on main.

Note: Once this PR is approved and merged - PR#93 should be closed without merging.

Further details on test case results:

presentations.sign()
    ✔ should successfully sign a presentation with default cryptosuite "eddsa-rdfc-2022" if no "acceptedCryptosuites" is provided.
    ✔ should successfully sign a presentation with default cryptosuite "eddsa-rdfc-2022" if "acceptedCryptosuites" is an empty array.
    ✔ should successfully sign a presentation with updated default signature suite if wallet signatureSuite config is changed.
    ✔ should successfully sign a presentation with "acceptedCryptosuites" "eddsa-rdfc-2022".
    ✔ should successfully sign a presentation with "acceptedCryptosuites" "Ed25519Signature2020".
    ✔ should successfully sign a presentation with the first type specified in the "acceptedCryptosuites" list if all are supported.
    ✔ should successfully sign a presentation with the supported type from the "acceptedCryptosuites" list.
    ✔ should fail to sign a presentation if all the types specified in the "acceptedCryptosuites" list are unsupported.
  NFC Renderer
    supportsNfc()
      Valid NFC Detection
        ✔ should return true for TemplateRenderMethod with outputPreference.mode containing "nfc"
        ✔ should return true when mode array contains multiple values including "nfc"
        ✔ should return true when renderMethod is an array with one NFC-compatible method
        ✔ should return true with full TemplateRenderMethod structure
      Invalid NFC Detection - Missing Required Fields
        ✔ should return false when template is missing (pre-filters invalid methods)
        ✔ should return false when outputPreference is missing
        ✔ should return false when outputPreference.mode is missing
        ✔ should return false for credential without renderMethod
        ✔ should return false for credential with non-NFC renderMethod
      Invalid NFC Detection - Malformed outputPreference
        ✔ should return false when mode is a string instead of array
        ✔ should return false when mode array is empty
        ✔ should return false when mode array does not contain "nfc"
        ✔ should return false when mode value is case-different ("NFC")
      Legacy Format - NfcRenderingTemplate2024
        ✔ should return true for legacy NfcRenderingTemplate2024 with payload field
        ✔ should return false for NfcRenderingTemplate2024 without payload field
        ✔ should return false for NfcRenderingTemplate2024 using template field instead of payload
    renderToNfc() - Template Decoding
      Multibase Encoding
        ✔ should decode base58 multibase template (z prefix)
        ✔ should decode base64url multibase template (u prefix)
      Data URL Encoding
        ✔ should decode data URL with base64 encoding
        ✔ should decode data URL with complex base64 payload
      Field Priority
        ✔ should use template field and ignore payload field for TemplateRenderMethod
      Decoding with renderProperty
        ✔ should decode template when renderProperty is present
        ✔ should decode template with multiple renderProperty fields
    renderToNfc() - renderProperty Validation
      Template Requirement
        ✔ should fail when only renderProperty exists without template
      Field Existence Validation
        ✔ should succeed when renderProperty references existing field
        ✔ should fail when renderProperty references non-existent field
        ✔ should validate all fields when multiple renderProperty pointers
        ✔ should fail if any renderProperty pointer is invalid
      Optional renderProperty
        ✔ should succeed when renderProperty is missing
        ✔ should succeed when renderProperty is empty array
      Nested Field Access
        ✔ should validate deeply nested renderProperty pointers
        ✔ should fail when nested path does not exist
    renderToNfc() - Error Cases
      Missing Credential or RenderMethod
        ✔ should fail when credential has no renderMethod
        ✔ should fail when credential parameter is missing
      Invalid Data URL
        ✔ should fail when data URL has wrong media type
        ✔ should fail when data URL format is malformed
        ✔ should fail when data URL encoding is unsupported
        ✔ should fail when base64 data is invalid
      Invalid Multibase Encoding
        ✔ should fail when template has unknown encoding format
      Invalid Template Type
        ✔ should fail when template is an object instead of string
        ✔ should fail when template is a number
        ✔ should fail when template is null
    Data Model - TemplateRenderMethod Structure
      type Field
        ✔ should fail when type is not TemplateRenderMethod
        ✔ should fail when type field is missing
      renderEngine Field
        ✔ should succeed with renderEngine set to "fixed"
        ✔ should succeed with unknown renderEngine value (ignored)
      outputPreference.mediaType Field
        ✔ should succeed with mediaType set to application/octet-stream
        ✔ should succeed without mediaType (optional field)
        ✔ should succeed with different mediaType value (not enforced)
      Unknown Fields Handling
        ✔ should ignore unknown fields in renderMethod
        ✔ should ignore unknown fields in outputPreference
      Complete Structure
        ✔ should succeed with all optional fields present
        ✔ should succeed with minimal required fields only
      Multiple Render Methods
        ✔ should select NFC method from array of render methods
        ✔ should use first NFC method when multiple exist
    Legacy Format - NfcRenderingTemplate2024
      Rendering with payload Field
        ✔ should render legacy format with base58 multibase payload
        ✔ should render legacy format with base64url multibase payload
        ✔ should render legacy format with data URL payload
      Field Handling
        ✔ should fail when using template field instead of payload
        ✔ should use payload and ignore template when both present
        ✔ should ignore unknown fields in legacy format
      Coexistence with TemplateRenderMethod
        ✔ should select legacy format from mixed render method array
        ✔ should prefer TemplateRenderMethod over legacy when both have NFC
        ✔ should fallback to legacy when TemplateRenderMethod lacks NFC mode
      Error Cases
        ✔ should fail when payload encoding is invalid
        ✔ should fail when payload is not a string
LOG: 'EAD Credential loaded from URL'
    Integration - Real Credentials
      EAD Credential (Legacy NfcRenderingTemplate2024)
        ✔ should have NfcRenderingTemplate2024 type in renderMethod
        ✔ should detect NFC support for EAD credential
        ✔ should render EAD credential to NFC bytes
LOG: 'FirstResponder Credential loaded from URL'
      FirstResponder Credential (TemplateRenderMethod)
        ✔ should have TemplateRenderMethod with NFC mode in renderMethod
        ✔ should detect NFC support for FirstResponder credential
        ✔ should render FirstResponder credential to NFC bytes
LOG: 'EAD renderMethod types:', ['SvgRenderingTemplate2024', 'NfcRenderingTemplate2024']
LOG: 'EAD NFC method fields:', ['type', 'payload']
      Credential Structure Inspection
        ✔ should log EAD credential renderMethod structure
LOG: 'FirstResponder renderMethod types:', ['SvgRenderingTemplate2024', 'TemplateRenderMethod']
LOG: 'FirstResponder NFC method fields:', ['type', 'renderEngine', 'renderProperty', 'name', 'outputPreference', 'template']
LOG: 'FirstResponder NFC outputPreference:', Object{mode: ['nfc'], mediaType: 'application/octet-stream'}
        ✔ should log FirstResponder credential renderMethod structure

Finished in 2.529 secs / 0.342 secs

SUMMARY:
✔ 82 tests completed
All tests passed.

Delegate toNFCPayload and hasNFCPayload to dedicated nfcRenderer.js,
supporting both TemplateRenderMethod and legacy NfcRenderingTemplate2024.

Continues work from PR #93.
@bparth24 bparth24 requested a review from dlongley January 23, 2026 23:58
@bparth24 bparth24 mentioned this pull request Jan 24, 2026
Copy link
Copy Markdown
Member

@dlongley dlongley left a comment

Choose a reason for hiding this comment

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

We need a CHANGELOG entry for a minor release that adds bundled nfcRenderer support.

@bparth24
Copy link
Copy Markdown
Contributor Author

We need a CHANGELOG entry for a minor release that adds bundled nfcRenderer support.

@dlongley

Addressed in this commit - 91e29f1

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.02198% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.52%. Comparing base (d855d6d) to head (91e29f1).

Files with missing lines Patch % Lines
lib/utilBrowser.js 15.38% 11 Missing ⚠️
lib/nfcRenderer.js 90.78% 7 Missing ⚠️
lib/helpers.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
+ Coverage   10.58%   16.52%   +5.94%     
==========================================
  Files          22       24       +2     
  Lines        1011     1071      +60     
==========================================
+ Hits          107      177      +70     
+ Misses        904      894      -10     
Files with missing lines Coverage Δ
lib/helpers.js 41.17% <0.00%> (+11.27%) ⬆️
lib/nfcRenderer.js 90.78% <90.78%> (ø)
lib/utilBrowser.js 15.38% <15.38%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d855d6d...91e29f1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dlongley dlongley merged commit 4e5ebde into main Jan 26, 2026
3 checks passed
@dlongley dlongley deleted the add-nfc-support branch January 26, 2026 22:24
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.

3 participants