decentralized-identity / veramo

A JavaScript Framework for Verifiable Data
https://veramo.io
Apache License 2.0
432 stars 131 forks source link

[proposal] Make headers call for AgentRestClient dynamic #1313

Closed cre8 closed 8 months ago

cre8 commented 8 months ago

Is your feature request related to a problem? Please describe. I am using keycloak for the authentication flow. Since the access token is only valid for some minutes, it has to be refreshed from time to time. Right now I can only pass a static token to it like:

        new AgentRestClient({
          url: `${environment.agent}/agent`,
          enabledMethods: enabledIssuerMethods,
          headers: {
            Authorization: `Bearer ${token}`,
          },
        }),

Creating an agent on demand could break some of my veramo plugins. So I thought it would be great to pass the headers either as a static value or to pass a function call.

Describe the solution you'd like It should be possible to pass either a Record<string, string> or a (() => Record<string, string>) for the header. It's better to make the whole header variable dynamic and not just one specific entry of the record.

Describe alternatives you've considered Creating an agent from time to time seems not like a best practice. Sphereon updated their client sdks so it should not be a big update. Since a static object can be passed it will not break any existing implementations.

mirceanis commented 8 months ago

closed by #1314