Steps: Before make any API call to Sumsub endpoints, I have to create a signature in HEX format and also I have to get the number of seconds since Unix Epoch. I have to create this logic as a template for any kind of query to Sumsub endpoints.
Where can I add this javascript logic in order to be executed before each call?
I thought this would be a straightforward problem to solve, but it ended up being more intricate than I expected. At a high level, you should define a custom authentication flow on the resource itself in order to avoid having to redefine these headers on every single request.
Can I return an array in my response with both variables? I think so but could you clarify it to me please. Like "return [signature, timestamp]
To create the signature, I have to access to the current URL. What is the javascript variable where I can get the current method and the current URL?
I need some javascript libraries like "crypto" for HMACSHA256 encryption. I know that I can add some Libraries from settings in each App, but how can I test it from custom flow?
Just to clarify, you need to know the full URL and HTTP method of the individual request when generating the authentication signature? I'm pretty sure that particular information is scoped to the query definition itself. As such, it might not be possible to configure the resource in such a way that it automatically generates the proper signature for all queries.
As a workaround, I might instead recommend defining a workflow that calculates the necessary signature, makes the API request, and then returns its response. You'd be able to pass in the necessary information - path, method, payload, etc. - when triggering the workflow, while still centralizing all authentication logic. If your org is already invested in AWS infrastructure, you could accomplish the same thing with SNS and Lambda.