diff --git a/lib/middleware.js b/lib/middleware.js index 4a2f769..6d3d541 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -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) { @@ -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); } diff --git a/package.json b/package.json index 6cfbd4b..d7c893e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@envoy/envoy-integrations-sdk", - "version": "1.5.0", + "version": "1.5.1-beta.1", "description": "", "main": "index.js", "scripts": {