Skip to content

Commit

Permalink
Revert "feat: Logout previous sessions" RELEASE (#847)
Browse files Browse the repository at this point in the history
Reverts #846
  • Loading branch information
dorsha authored Nov 14, 2024
1 parent dd20924 commit c50c0c5
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 260 deletions.
12 changes: 5 additions & 7 deletions packages/libs/escape-markdown/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
}
},
"licenseCheck": {
"executor": "nx:run-commands",
"options": {
"commands": [
"exit 0"
]
}
}
"executor": "nx:run-commands",
"options": {
"commands": ["exit 0"]
}
}
},
"tags": []
}
1 change: 0 additions & 1 deletion packages/sdks/core-js-sdk/src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default {
selectTenant: '/v1/auth/tenant/select',
logout: '/v1/auth/logout',
logoutAll: '/v1/auth/logoutall',
logoutPrevious: '/v1/auth/logoutprevious',
me: '/v1/auth/me',
myTenants: '/v1/auth/me/tenants',
history: '/v1/auth/me/history',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdks/core-js-sdk/src/sdk/flow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ type JSONSerializable =
| null
| Array<JSONSerializable>;

export type FlowInput = Record<string, JSONSerializable>;
export type FlowInput = Record<string, JSONSerializable>;
9 changes: 0 additions & 9 deletions packages/sdks/core-js-sdk/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,6 @@ export default (httpClient: HttpClient) => ({
httpClient.post(apiPaths.logoutAll, {}, { token }),
),
),
/**
* Logs out all previous sessions for the current user
* @param token A valid refresh token
*/
logoutPrevious: withOptionalTokenValidations((token?: string) =>
transformResponse<never>(
httpClient.post(apiPaths.logoutPrevious, {}, { token }),
),
),
/**
* Returns the current user details
* @param token A valid refresh token
Expand Down
27 changes: 0 additions & 27 deletions packages/sdks/core-js-sdk/test/sdk/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,33 +222,6 @@ describe('sdk', () => {
});
});

describe('logoutPrevious', () => {
it('should throw an error when token is not a string', () => {
expect(() => sdk.logoutPrevious({ a: 'b' })).toThrow(
'"token" must be string or undefined',
);
});
it('should send the correct request', () => {
const httpRespJson = { key: 'val' };
const httpResponse = {
ok: true,
json: () => httpRespJson,
clone: () => ({
json: () => Promise.resolve(httpRespJson),
}),
status: 200,
};
mockHttpClient.post.mockResolvedValue(httpResponse);

sdk.logoutPrevious('token');
expect(mockHttpClient.post).toHaveBeenCalledWith(
apiPaths.logoutPrevious,
{},
{ token: 'token' },
);
});
});

describe('me', () => {
it('should throw an error when token is not a string', () => {
expect(() => sdk.me({ a: 'b' })).toThrow(
Expand Down
3 changes: 1 addition & 2 deletions packages/sdks/react-sdk/test/hooks/useAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jest.mock('@descope/web-js-sdk', () => {
const sdk = {
logout: jest.fn().mockName('logout'),
logoutAll: jest.fn().mockName('logoutAll'),
logoutPrevious: jest.fn().mockName('logoutPrevious'),
otp: {
signIn: {
email: jest.fn().mockName('otp.signIn.email'),
Expand Down Expand Up @@ -65,7 +64,7 @@ describe('hooks', () => {
);
});

it.each(['logoutAll', 'logoutPrevious', 'logout', 'otp.signIn.email'])(
it.each(['logoutAll', 'logout', 'otp.signIn.email'])(
'should throw error when using sdk function before sdk initialization - %s',
(fnName) => {
const { result } = renderHook(() => useDescope(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ export const withAutoRefresh =
return resp;
};

return wrapWith(sdk, ['logout', 'logoutAll', 'logoutPrevious'], wrapper);
return wrapWith(sdk, ['logout', 'logoutAll'], wrapper);
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const withLastLoggedInUser =
let wrappedSdk = wrapWith(sdk, ['flow.start'], startWrapper);
wrappedSdk = wrapWith(
wrappedSdk,
['logout', 'logoutAll', 'logoutPrevious'],
['logout', 'logoutAll'],
logoutWrapper(keepLastAuthenticatedUserAfterLogout),
);
return Object.assign(wrappedSdk, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ export const withNotifications =
return resp;
};

const wrappedSdk = wrapWith(
sdk,
['logout', 'logoutAll', 'logoutPrevious'],
wrapper,
);
const wrappedSdk = wrapWith(sdk, ['logout', 'logoutAll'], wrapper);

return Object.assign(wrappedSdk, {
onSessionTokenChange: sessionPS.sub,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const withPersistTokens =

const wrappedSdk = wrapWith(
sdk,
['logout', 'logoutAll', 'logoutPrevious'],
['logout', 'logoutAll'],
wrapper(storagePrefix),
);

Expand Down
13 changes: 0 additions & 13 deletions packages/sdks/web-js-sdk/test/persistTokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,6 @@ describe('persistTokens', () => {
expect(removeMock).toBeCalledWith('DS');
});

it('should clear tokens on logoutPrevious even when not passing refresh token', async () => {
localStorage.setItem('DSR', authInfo.refreshJwt);
const mockFetch = jest.fn().mockReturnValue(createMockReturnValue({}));
global.fetch = mockFetch;

const sdk = createSdk({ projectId: 'pid', persistTokens: true });
await sdk.logoutPrevious();

expect(localStorage.getItem('DSR')).toBeFalsy();
const removeMock = Cookies.remove as jest.Mock;
expect(removeMock).toBeCalledWith('DS');
});

it('should not log a warning when not running in the browser', () => {
const warnSpy = jest.spyOn(console, 'warn');

Expand Down
Loading

0 comments on commit c50c0c5

Please sign in to comment.