diff --git a/plugins/auth-oauth2/src/grants/authorizationCode.ts b/plugins/auth-oauth2/src/grants/authorizationCode.ts index abafcbe3..781cbaab 100644 --- a/plugins/auth-oauth2/src/grants/authorizationCode.ts +++ b/plugins/auth-oauth2/src/grants/authorizationCode.ts @@ -52,7 +52,12 @@ export async function getAuthorizationCode( return token; } - const authorizationUrl = new URL(`${authorizationUrlRaw ?? ''}`); + let authorizationUrl: URL; + try { + authorizationUrl = new URL(`${authorizationUrlRaw ?? ''}`); + } catch { + throw new Error('Invalid authorization URL: ' + authorizationUrlRaw); + } authorizationUrl.searchParams.set('response_type', 'code'); authorizationUrl.searchParams.set('client_id', clientId); if (redirectUri) authorizationUrl.searchParams.set('redirect_uri', redirectUri); diff --git a/plugins/auth-oauth2/src/grants/implicit.ts b/plugins/auth-oauth2/src/grants/implicit.ts index 043d5379..585f0589 100644 --- a/plugins/auth-oauth2/src/grants/implicit.ts +++ b/plugins/auth-oauth2/src/grants/implicit.ts @@ -31,7 +31,12 @@ export async function getImplicit( return token; } - const authorizationUrl = new URL(`${authorizationUrlRaw ?? ''}`); + let authorizationUrl: URL; + try { + authorizationUrl = new URL(`${authorizationUrlRaw ?? ''}`); + } catch { + throw new Error('Invalid authorization URL: ' + authorizationUrlRaw); + } authorizationUrl.searchParams.set('response_type', 'token'); authorizationUrl.searchParams.set('client_id', clientId); if (redirectUri) authorizationUrl.searchParams.set('redirect_uri', redirectUri); diff --git a/plugins/auth-oauth2/src/index.ts b/plugins/auth-oauth2/src/index.ts index 95bb71ef..c76e961a 100644 --- a/plugins/auth-oauth2/src/index.ts +++ b/plugins/auth-oauth2/src/index.ts @@ -312,10 +312,11 @@ export const plugin: PluginDefinition = { const authorizationUrl = stringArg(values, 'authorizationUrl'); const accessTokenUrl = stringArg(values, 'accessTokenUrl'); token = await getAuthorizationCode(ctx, contextId, { - accessTokenUrl: accessTokenUrl.match(/^https?:\/\//) - ? accessTokenUrl - : `https://${accessTokenUrl}`, - authorizationUrl: authorizationUrl.match(/^https?:\/\//) + accessTokenUrl: + accessTokenUrl === '' || accessTokenUrl.match(/^https?:\/\//) + ? accessTokenUrl + : `https://${accessTokenUrl}`, + authorizationUrl: authorizationUrl === '' || authorizationUrl.match(/^https?:\/\//) ? authorizationUrl : `https://${authorizationUrl}`, clientId: stringArg(values, 'clientId'), diff --git a/src-web/components/core/Editor/extensions.ts b/src-web/components/core/Editor/extensions.ts index e013eef6..9bbbc8b3 100644 --- a/src-web/components/core/Editor/extensions.ts +++ b/src-web/components/core/Editor/extensions.ts @@ -139,7 +139,6 @@ export function getLanguageExtension({ onShowInDocs(field, type, parentType) { const activeRequestId = jotaiStore.get(activeRequestIdAtom); if (activeRequestId == null) return; - console.log('SHOW IN DOCS', field); jotaiStore.set(showGraphQLDocExplorerAtom, (v) => ({ ...v, [activeRequestId]: { field, type, parentType },