Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat(core): validate if access and id tokens are valid cognito tokens (#13385)" #13410

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {

import { NextServer } from '../types';

import { createTokenValidator } from './createTokenValidator';
import { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext';

export const createRunWithAmplifyServerContext = ({
Expand All @@ -35,11 +34,6 @@ export const createRunWithAmplifyServerContext = ({
createCookieStorageAdapterFromNextServerContext(
nextServerContext,
),
createTokenValidator({
userPoolId: resourcesConfig?.Auth.Cognito?.userPoolId,
userPoolClientId:
resourcesConfig?.Auth.Cognito?.userPoolClientId,
}),
);
const credentialsProvider = createAWSCredentialsAndIdentityIdProvider(
resourcesConfig.Auth,
Expand Down
38 changes: 0 additions & 38 deletions packages/adapter-nextjs/src/utils/createTokenValidator.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,44 +84,5 @@ describe('keyValueStorage', () => {
}).toThrow('This method has not implemented.');
});
});

describe('in conjunction with token validator', () => {
const testKey = 'testKey';
const testValue = 'testValue';

beforeEach(() => {
mockCookiesStorageAdapter.get.mockReturnValueOnce({
name: testKey,
value: testValue,
});
});
afterEach(() => {
jest.clearAllMocks();
});

it('should return item successfully if validation passes when getting item', async () => {
const getItemValidator = jest.fn().mockImplementation(() => true);
const keyValueStorage = createKeyValueStorageFromCookieStorageAdapter(
mockCookiesStorageAdapter,
{ getItem: getItemValidator },
);

const value = await keyValueStorage.getItem(testKey);
expect(value).toBe(testValue);
expect(getItemValidator).toHaveBeenCalledTimes(1);
});

it('should return null if validation fails when getting item', async () => {
const getItemValidator = jest.fn().mockImplementation(() => false);
const keyValueStorage = createKeyValueStorageFromCookieStorageAdapter(
mockCookiesStorageAdapter,
{ getItem: getItemValidator },
);

const value = await keyValueStorage.getItem(testKey);
expect(value).toBe(null);
expect(getItemValidator).toHaveBeenCalledTimes(1);
});
});
});
});
Loading
Loading