From 9ae96b3f2817389ce95826da73e8cc894f884499 Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Mon, 13 Sep 2021 20:23:16 +0300 Subject: [PATCH 1/2] chore: add optional parameter to authorize --- packages/core/src/redocly/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/redocly/index.ts b/packages/core/src/redocly/index.ts index f8158708f6..fd016d81e9 100644 --- a/packages/core/src/redocly/index.ts +++ b/packages/core/src/redocly/index.ts @@ -91,9 +91,9 @@ export class RedoclyClient { }); } - static async authorize(accessToken: string, verbose: boolean = false) { + static async authorize(accessToken: string, verbose: boolean = false, queryName = '') { try { - const queryStr = `{ viewer { id } }`; + const queryStr = `query ${queryName}{ viewer { id } }`; return await query(queryStr, {}, { Authorization: accessToken }); } catch (e) { From 31ae7f6be9b1c202fa650d91185fd1a795f01127 Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Wed, 15 Sep 2021 11:53:01 +0300 Subject: [PATCH 2/2] chore: convert parameters to object in authorize --- packages/core/src/redocly/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/redocly/index.ts b/packages/core/src/redocly/index.ts index fd016d81e9..5dfd3db65a 100644 --- a/packages/core/src/redocly/index.ts +++ b/packages/core/src/redocly/index.ts @@ -36,7 +36,7 @@ export class RedoclyClient { async verifyToken(accessToken: string, verbose: boolean = false): Promise { if (!accessToken) return false; - const authDetails = await RedoclyClient.authorize(accessToken, verbose); + const authDetails = await RedoclyClient.authorize(accessToken, { verbose }); if (!authDetails) return false; return true; } @@ -91,7 +91,8 @@ export class RedoclyClient { }); } - static async authorize(accessToken: string, verbose: boolean = false, queryName = '') { + static async authorize(accessToken: string, options: { queryName?: string; verbose?: boolean }) { + const { queryName = '', verbose = false } = options; try { const queryStr = `query ${queryName}{ viewer { id } }`;