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

Dynamic update of presentation definitions #167

Open
cre8 opened this issue Feb 29, 2024 · 3 comments
Open

Dynamic update of presentation definitions #167

cre8 opened this issue Feb 29, 2024 · 3 comments

Comments

@cre8
Copy link

cre8 commented Feb 29, 2024

When I started my agent, I want to let the user update the presentation definition. It's possible to write this into the pex-store, but the SIOPv2PR instance is loading the values on start.

I tried to update them like this:

const siop = new SIOPv2RP({
    defaultOpts: {
      didOpts: {
        checkLinkedDomains: CheckLinkedDomain.IF_PRESENT,
        identifierOpts: {
          identifier,
          kid,
        },
      },
    },
    instanceOpts: [],
  });  
  setInterval(() => {
    const rep = agentConfig.datasource.getRepository(KeyValueStoreEntity);
    //TODO: this is not the preferred way since we need to reload the application to get the latest version.
    rep.find({ where: { key: Like('%oid4vp%') } }).then(
      (res) => {
        const instanceOpts = res.map((r) => {
          const content = JSON.parse(r.data).value as IPresentationDefinition;
          return {
            definitionId: content.id,
            definition: content,
          } as IPEXInstanceOptions;
        });
        //@ts-ignore
        siop.opts.instanceOpts = instanceOpts;
      },
      () => {}
    );
  }, 1500);

This works, until the first presentation request for this definition is made. Then the instance is getting saved in the internal map and will always interact with it. So updating the instanceOpts has no effect on this.

Is there another way to update the values without restarting an instance? A restart of the agent could reset an ongoing presentation flow so I want avoid this step.

@nklomp
Copy link
Contributor

nklomp commented Feb 29, 2024

I want to know a bit more about your use case. Because updating a definition mid-flight whilst sessions are running sounds problematic to begin with.

What if certain OPs already have performed a request with the old definition. They will send in a submission based on the old definition. If you in the meantime changed the definition under their feet, it likely cause issues, because the new definition is different from the old one.

@nklomp
Copy link
Contributor

nklomp commented Feb 29, 2024

What probably would be a better approach, and which we will need to look into soon anyway, is to implement new session support with persistence, where we also would store a reference to a full definition. Then you could apply versioning to definitions and then thus also support sessions against multiple versions of the same definition id.

@cre8
Copy link
Author

cre8 commented Mar 1, 2024

I have implemented a multi agent system where a backend is spinning up multiple agent instances that can be managed by different users. Users are able to create update and delete credential templates (to issue credentials) and to define presentations requests via a web application. Each agent can be reached via `exmaple.com/ and is publishing the endpoints to interact with it.

So compared to e.g. your demo application (which is fine for specific use cases) the values can change over time. But restarting the whole agent in the background can lead to some other side effects like you mentioned

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

No branches or pull requests

2 participants