Interface for implementing auth handlers
- Source:
Members
manifest :AuthHandlerInterface~AuthManifest
Defines the behaviour of an Auth Handler. This way the handler allows to statically analyse any changes the Handler will make ahead of time.
Type:
- Source:
Methods
init(auth, response, done)
This hook is called with the response from the intermediate request, which was requested from the
pre hook.
Here the auth
can be modified using the response. After this pre hook will be
called again to verify the required parameters.
Parameters:
Name | Type | Description |
---|---|---|
auth |
AuthInterface | |
response |
Response | |
done |
AuthHandlerInterface~authInitHookCallback | Callback function which takes error as the only argument |
- Source:
post(auth, response, done)
This hook is called after the request is made. It receives the response using which it can determine whether
it was a failure or success. It can also modify the auth
and ask to replay the request
.
For this it has to call the done callback with success
as false.
Parameters:
Name | Type | Description |
---|---|---|
auth |
AuthInterface | |
response |
Response | |
done |
AuthHandlerInterface~authPostHookCallback | Callback function which takes error and success as arguments |
- Source:
pre(auth, done)
This hook decides whether all the required parameters are present in the auth or not.
What happens next is dependent upon how the done
callback is called.
Check AuthHandlerInterface~authPreHookCallback for all the possible ways the callback can be called.
Parameters:
Name | Type | Description |
---|---|---|
auth |
AuthInterface | |
done |
AuthHandlerInterface~authPreHookCallback | Callback function which takes error, success, and request as arguments |
- Source:
sign(auth, request, done)
This hook signs the request
using the auth
.
Parameters:
Name | Type | Description |
---|---|---|
auth |
AuthInterface | |
request |
Request | |
done |
AuthHandlerInterface~authSignHookCallback | Callback function which takes error as the only argument |
- Source:
Type Definitions
authInitHookCallback(errnullable)
This callback is called in the init
hook of the auth handler
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
err |
Error |
<nullable> |
- Source:
AuthManifest
Structure of an Auth Manifest. See AuthHandlerInterface#manifest for description.
Type:
- Object
Properties:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
info |
Object |
Properties
|
|||||||||
updates |
Array.<Object> |
- Source:
authPostHookCallback(errnullable, success)
This callback is called in the post
hook of the auth handler
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
err |
Error |
<nullable> |
|
success |
Boolean | Defines whether the request was successful or not. If not, it will be replayed. |
- Source:
authPreHookCallback(errnullable, success, requestopt)
This callback is called in the pre
hook of the auth handler
Depending on what parameters are passed in this callback, one of the following flows will be executed:
- return (err): The request will be stopped and the error will be bubbled up
- return (null, true): The request will be signed and sent
- return (null, false): The request will be sent without being signed
- return (null, false,
request
):
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
err |
Error |
<nullable> |
|
success |
Boolean | Defines whether the pre hook was successful. |
|
request |
Request~definition | String |
<optional> |
It can be either request definition or request URL |
- Source:
authSignHookCallback(errnullable)
This callback is called in the sign
hook of the auth handler
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
err |
Error |
<nullable> |
- Source: