SSI-SDK icon indicating copy to clipboard operation
SSI-SDK copied to clipboard

Dynamic update of presentation definitions

Open cre8 opened this issue 4 months ago • 3 comments

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.

cre8 avatar Feb 29 '24 16:02 cre8