Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const VERIFIED = Symbol('verified');
* Returns an instance of bodyParser.json,
* which also verifies that the request came from Envoy.
*
* @param {SignatureVerifierOptions} [options]
* @param {SignatureVerifierOptions & {customClientId?: string, customClientSecret?: string}} [options]
* @returns {connectMiddleware}
*/
function middleware(options) {
Expand All @@ -55,10 +55,13 @@ function middleware(options) {
try {
const now = Date.now();
if (now > threshold) {
const hasCustomCredentials = options && options.customClientId && options.customClientSecret;
const {
access_token: rawAccessToken,
expires_in: expiresIn,
} = await EnvoyAPI.login();
} = hasCustomCredentials
? await EnvoyAPI.login(options.customClientId, options.customClientSecret)
: await EnvoyAPI.login();
accessToken = rawAccessToken;
threshold = now + (expiresIn * 1000) - (1000 * 60 * 10);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envoy/envoy-integrations-sdk",
"version": "1.5.0",
"version": "1.5.1-beta.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Loading