Skip to content

Support for async functions in context provider? #10

@jmurty

Description

@jmurty

We would like to use this KnownUser library for server-side queueing from a Next.js application, but we are finding the Node library difficult to apply to our use-case.

The main problem we have is the requirement that context provider (IConnectorContextProvider) functions all return synchronous results instead of async/promises, especially getCryptoProvider().getSha256Hash().

We want to run the KnownUser validation in Next.js middleware but in these run in an Edge Runtime context where we don't have access to native Node libraries like crypto as used in the example. Instead we can use the Web Crypto API, but that only provides async crypto functions.

This means we cannot generate a HMAC/SHA-256 hash value for getCryptoProvider().getSha256Hash() synchronously, only with an async result which doesn't work where this context function is called in the rest of the codebase.

We are attempting to work around this by implementing just the incompatible pieces of KnownUser in own code – specifically token validation and follow-on cookie-setting – but are finding that the relatively few functions & utils exposed by KnownUser is making this difficult without re-implementing much of the library.

If the KnownUser library could support async function implementations in the context provider it would most likely work for us out of the box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions