From c243f254773677cf24abf5bf0d5e336dbbabbcc1 Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Mon, 9 May 2022 13:26:17 +0200 Subject: [PATCH] fix: deprecating sasjs client id --- src/SASjs.ts | 2 +- src/SASjsApiClient.ts | 4 ++-- src/auth/AuthManager.ts | 20 +++++--------------- src/auth/getAccessTokenForSasjs.ts | 2 -- src/auth/getAuthCodeForSasjs.ts | 5 ++--- src/auth/spec/getAccessTokenForSasjs.spec.ts | 9 ++------- 6 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/SASjs.ts b/src/SASjs.ts index f554947..3ccbc7f 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -598,7 +598,7 @@ export default class SASjs { 'A username, password and clientId are required when using the default login mechanism with server type SASJS.' ) - return this.authManager!.logInSasjs(username, password, clientId) + return this.authManager!.logInSasjs(username, password) } return this.authManager!.logIn(username, password) diff --git a/src/SASjsApiClient.ts b/src/SASjsApiClient.ts index af17911..3d37f18 100644 --- a/src/SASjsApiClient.ts +++ b/src/SASjsApiClient.ts @@ -104,7 +104,7 @@ export class SASjsApiClient { clientId: string, authCode: string ): Promise { - return getAccessTokenForSasjs(this.requestClient, clientId, authCode) + return getAccessTokenForSasjs(this.requestClient, authCode) } /** @@ -126,7 +126,7 @@ export class SASjsApiClient { password: string, clientId: string ) { - return getAuthCodeForSasjs(this.requestClient, username, password, clientId) + return getAuthCodeForSasjs(this.requestClient, username, password) } } diff --git a/src/auth/AuthManager.ts b/src/auth/AuthManager.ts index 5d69c94..4568af3 100644 --- a/src/auth/AuthManager.ts +++ b/src/auth/AuthManager.ts @@ -92,14 +92,9 @@ export class AuthManager { */ public async logInSasjs( username: string, - password: string, - clientId: string + password: string ): Promise { - const isLoggedIn = await this.sendLoginRequestSasjs( - username, - password, - clientId - ) + const isLoggedIn = await this.sendLoginRequestSasjs(username, password) .then((res) => { this.userName = username this.requestClient.saveLocalStorageToken( @@ -215,18 +210,13 @@ export class AuthManager { return loginResponse } - private async sendLoginRequestSasjs( - username: string, - password: string, - clientId: string - ) { + private async sendLoginRequestSasjs(username: string, password: string) { const authCode = await getAuthCodeForSasjs( this.requestClient, username, - password, - clientId + password ) - return getAccessTokenForSasjs(this.requestClient, clientId, authCode) + return getAccessTokenForSasjs(this.requestClient, authCode) } /** * Checks whether a session is active, or login is required. diff --git a/src/auth/getAccessTokenForSasjs.ts b/src/auth/getAccessTokenForSasjs.ts index 7b080bf..57cc4bd 100644 --- a/src/auth/getAccessTokenForSasjs.ts +++ b/src/auth/getAccessTokenForSasjs.ts @@ -9,12 +9,10 @@ import { RequestClient } from '../request/RequestClient' */ export async function getAccessTokenForSasjs( requestClient: RequestClient, - clientId: string, authCode: string ) { const url = '/SASjsApi/auth/token' const data = { - clientId, code: authCode } diff --git a/src/auth/getAuthCodeForSasjs.ts b/src/auth/getAuthCodeForSasjs.ts index aa6d2b2..4b99414 100644 --- a/src/auth/getAuthCodeForSasjs.ts +++ b/src/auth/getAuthCodeForSasjs.ts @@ -11,11 +11,10 @@ import { RequestClient } from '../request/RequestClient' export const getAuthCodeForSasjs = async ( requestClient: RequestClient, username: string, - password: string, - clientId: string + password: string ) => { const url = '/SASjsApi/auth/authorize' - const data = { username, password, clientId } + const data = { username, password } const { code: authCode } = await requestClient .post<{ code: string }>(url, data, undefined) diff --git a/src/auth/spec/getAccessTokenForSasjs.spec.ts b/src/auth/spec/getAccessTokenForSasjs.spec.ts index 075d9b9..8792a25 100644 --- a/src/auth/spec/getAccessTokenForSasjs.spec.ts +++ b/src/auth/spec/getAccessTokenForSasjs.spec.ts @@ -22,15 +22,11 @@ describe('getAccessTokenForSasjs', () => { Promise.resolve({ result: mockSasjsAuthResponse, etag: '' }) ) - await getAccessTokenForSasjs( - requestClient, - authConfig.client, - authConfig.refresh_token - ) + await getAccessTokenForSasjs(requestClient, authConfig.refresh_token) expect(requestClient.post).toHaveBeenCalledWith( '/SASjsApi/auth/token', - { clientId: authConfig.client, code: authConfig.refresh_token }, + { code: authConfig.refresh_token }, undefined ) }) @@ -51,7 +47,6 @@ describe('getAccessTokenForSasjs', () => { const error = await getAccessTokenForSasjs( requestClient, - authConfig.client, authConfig.refresh_token ).catch((e) => e)