Skip to content
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

Implement NFC support query in Service Agent #49

Open
genaris opened this issue Nov 27, 2024 · 2 comments · May be fixed by #70
Open

Implement NFC support query in Service Agent #49

genaris opened this issue Nov 27, 2024 · 2 comments · May be fixed by #70
Assignees

Comments

@genaris
Copy link
Contributor

genaris commented Nov 27, 2024

This issue was created from the need we have in UnicID to know if a certain user is using a phone capable of NFC tag reading. However, we can make it more generic in order to support other use cases in the future.

NFC support can be retrieved by asking the DIDComm agent for mrtd.emrtd-read-support capability (to be more precise, a feature with type capability, name mrtd.emrtd-read-support and value true). This is done through the Discover Features protocol.

@genaris genaris self-assigned this Dec 11, 2024
@genaris
Copy link
Contributor Author

genaris commented Jan 16, 2025

I think it would be nice to have a way to configure the Service Agent in a way that it will automatically request for a number of features (meaning by that protocols, capabilities, constraints, etc.) once a connection with another DIDComm agent is established.

Somewhere in the configuration of Service Agent (e.g. a configuration file) we can have:

query: [{ feature-type: 'capability', match: 'mrtd.*'}]

So once a connection is completed, it will automatically call:

      await agent.discovery.queryFeatures({connectionId, protocolVersion: 'v2', queries: [{featureType: 'capability', match: 'mrtd.*'}] })

And, upon the disclosure by the other party, it will keep track of these features by adding them to connection record, which in the simplest case would be the ConnectionRecord stored in Agent's wallet:

const disclosureListener = async (event: DiscoverFeaturesDisclosureReceivedEvent) => {
    const connection = event.payload.connection
    const connectionService = context.dependencyManager.resolve(ConnectionService)
    
    const features = event.payload.disclosures
    features.forEach(item => connection.metadata.add(`features-${item.type}`, { [item.id]: item.toJSON() }))

    await connectionService.update(context, connection)
  }

  agent.events.on(DiscoverFeaturesEventTypes.DisclosureReceived, disclosureListener)

In the case of the NestJS client, we can store this into the Connection entity metadata. But we will need to send an event somehow from the main Service Agent in order for it to be able to process it.

Probably, a simple idea would be to add a metadata field to the connection-state-updated event webhook and react to any change in ConnectionRecords. This will imply to use repository events instead of ConnectionStateUpdated events (see RepositoryEventTypes in Credo core.

@genaris
Copy link
Contributor Author

genaris commented Jan 17, 2025

@genaris genaris assigned lotharking and unassigned genaris Jan 17, 2025
@lotharking lotharking linked a pull request Jan 20, 2025 that will close this issue
6 tasks
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 a pull request may close this issue.

2 participants