diff --git a/packages/client/src/helpers/requireAuthHeaders.spec.ts b/packages/client/src/helpers/requireAuthHeaders.spec.ts index b8aa7400a0..e6d6aefbe4 100644 --- a/packages/client/src/helpers/requireAuthHeaders.spec.ts +++ b/packages/client/src/helpers/requireAuthHeaders.spec.ts @@ -13,17 +13,6 @@ const context: LensContext = { }; describe(`Given the "${requireAuthHeaders.name}" helper`, () => { - describe(`when the ${Authentication.name} is not provided`, () => { - it(`should return failure with ${NotAuthenticatedError.name}`, async () => { - const result = await requireAuthHeaders(undefined, (header) => { - return Promise.resolve(header); - }); - - expect(result.isFailure()).toBeTruthy(); - expect(() => result.unwrap()).toThrow(NotAuthenticatedError); - }); - }); - describe(`when the ${Authentication.name} is available but not authenticated`, () => { it(`should return failure with ${NotAuthenticatedError.name}`, async () => { const authentication = new Authentication(context); @@ -35,20 +24,4 @@ describe(`Given the "${requireAuthHeaders.name}" helper`, () => { expect(() => result.unwrap()).toThrow(NotAuthenticatedError); }); }); - - // describeAuthenticatedScenario()((getTestSetup) => { - // describe(`when the ${Authentication.name} is available and authenticated`, () => { - // it(`should provide the authentication header`, async () => { - // const { authentication } = getTestSetup(); - // const result = await requireAuthHeaders(authentication, (header) => { - // return Promise.resolve(header); - // }); - - // expect(result.isSuccess()).toBeTruthy(); - // expect(result.unwrap()).toEqual({ - // authorization: expect.any(String), - // }); - // }); - // }); - // }); }); diff --git a/packages/client/src/helpers/requireAuthHeaders.ts b/packages/client/src/helpers/requireAuthHeaders.ts index 444af1d04a..5124ca8f08 100644 --- a/packages/client/src/helpers/requireAuthHeaders.ts +++ b/packages/client/src/helpers/requireAuthHeaders.ts @@ -1,4 +1,4 @@ -import { failure, PromiseResult, success } from '@lens-protocol/shared-kernel'; +import { PromiseResult, success } from '@lens-protocol/shared-kernel'; import type { Authentication } from '../authentication'; import { CredentialsExpiredError, NotAuthenticatedError } from '../errors'; @@ -6,14 +6,9 @@ import { CredentialsExpiredError, NotAuthenticatedError } from '../errors'; type Handler = (headers: Record) => Promise; export async function requireAuthHeaders( - authentication: Authentication | undefined, + authentication: Authentication, handler: Handler, ): PromiseResult { - // TODO revisit this might be actually defined all the time - if (!authentication) { - return failure(new NotAuthenticatedError()); - } - const result = await authentication.getRequestHeader(); if (result.isFailure()) { diff --git a/packages/client/src/submodules/explore/Explore.ts b/packages/client/src/submodules/explore/Explore.ts index a059908ab8..aded72168e 100644 --- a/packages/client/src/submodules/explore/Explore.ts +++ b/packages/client/src/submodules/explore/Explore.ts @@ -28,7 +28,7 @@ export class Explore { constructor( private readonly context: LensContext, - authentication?: Authentication, + authentication: Authentication, ) { const client = new FetchGraphQLClient(context); this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); diff --git a/packages/client/src/submodules/feed/Feed.ts b/packages/client/src/submodules/feed/Feed.ts index fb1c21e697..7db1549f90 100644 --- a/packages/client/src/submodules/feed/Feed.ts +++ b/packages/client/src/submodules/feed/Feed.ts @@ -21,17 +21,14 @@ import { FeedItemFragment, getSdk, Sdk } from './graphql/feed.generated'; * @group LensClient Modules */ export class Feed { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/invites/Invites.ts b/packages/client/src/submodules/invites/Invites.ts index eb8fdcd198..ceaf2b7b30 100644 --- a/packages/client/src/submodules/invites/Invites.ts +++ b/packages/client/src/submodules/invites/Invites.ts @@ -14,17 +14,14 @@ import { InvitedResultFragment, Sdk, getSdk } from './graphql/invites.generated' * @group LensClient Modules */ export class Invites { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication?: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/modules/Modules.ts b/packages/client/src/submodules/modules/Modules.ts index ed02ad7c4a..0609c567f5 100644 --- a/packages/client/src/submodules/modules/Modules.ts +++ b/packages/client/src/submodules/modules/Modules.ts @@ -32,14 +32,14 @@ import { * @group LensClient Modules */ export class Modules { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; - constructor(context: LensContext, authentication: Authentication) { + constructor( + context: LensContext, + private readonly authentication: Authentication, + ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/momoka/Momoka.ts b/packages/client/src/submodules/momoka/Momoka.ts index 1cb40069f1..98b5bded40 100644 --- a/packages/client/src/submodules/momoka/Momoka.ts +++ b/packages/client/src/submodules/momoka/Momoka.ts @@ -32,7 +32,7 @@ export class Momoka { constructor( private readonly context: LensContext, - authentication?: Authentication, + authentication: Authentication, ) { const client = new FetchGraphQLClient(context); this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); diff --git a/packages/client/src/submodules/nfts/Nfts.ts b/packages/client/src/submodules/nfts/Nfts.ts index 89544b9d2c..60f2c10e93 100644 --- a/packages/client/src/submodules/nfts/Nfts.ts +++ b/packages/client/src/submodules/nfts/Nfts.ts @@ -34,14 +34,14 @@ import { * @group LensClient Modules */ export class Nfts { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; - constructor(context: LensContext, authentication?: Authentication) { + constructor( + context: LensContext, + private readonly authentication: Authentication, + ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/notifications/Notifications.ts b/packages/client/src/submodules/notifications/Notifications.ts index 2a0606c6f6..a6a49f6005 100644 --- a/packages/client/src/submodules/notifications/Notifications.ts +++ b/packages/client/src/submodules/notifications/Notifications.ts @@ -40,17 +40,14 @@ export type NotificationFragment = * @group LensClient Modules */ export class Notifications { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/profile/Profile.ts b/packages/client/src/submodules/profile/Profile.ts index 2708674661..0ce0e2df87 100644 --- a/packages/client/src/submodules/profile/Profile.ts +++ b/packages/client/src/submodules/profile/Profile.ts @@ -67,17 +67,15 @@ import { FetchProfileOptions } from './types'; * @group LensClient Modules */ export class Profile { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication?: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/publication/Publication.ts b/packages/client/src/submodules/publication/Publication.ts index 350b823a30..3fc9492723 100644 --- a/packages/client/src/submodules/publication/Publication.ts +++ b/packages/client/src/submodules/publication/Publication.ts @@ -64,17 +64,14 @@ import { FetchPublicationOptions, RequestOverwrites } from './types'; * @group LensClient Modules */ export class Publication { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication?: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/publication/submodules/actions/Actions.ts b/packages/client/src/submodules/publication/submodules/actions/Actions.ts index 0205799f67..00145f003a 100644 --- a/packages/client/src/submodules/publication/submodules/actions/Actions.ts +++ b/packages/client/src/submodules/publication/submodules/actions/Actions.ts @@ -20,14 +20,14 @@ import { * @group LensClient Modules */ export class Actions { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; - constructor(context: LensContext, authentication?: Authentication) { + constructor( + context: LensContext, + private readonly authentication: Authentication, + ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/publication/submodules/bookmarks/Bookmarks.ts b/packages/client/src/submodules/publication/submodules/bookmarks/Bookmarks.ts index 466b6eba50..72c314c24f 100644 --- a/packages/client/src/submodules/publication/submodules/bookmarks/Bookmarks.ts +++ b/packages/client/src/submodules/publication/submodules/bookmarks/Bookmarks.ts @@ -24,17 +24,14 @@ import { getSdk, Sdk } from './graphql/bookmarks.generated'; * @group LensClient Modules */ export class Bookmarks { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication?: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/publication/submodules/notInterested/NotInterested.ts b/packages/client/src/submodules/publication/submodules/notInterested/NotInterested.ts index 6baa7b8551..3c0ede60dd 100644 --- a/packages/client/src/submodules/publication/submodules/notInterested/NotInterested.ts +++ b/packages/client/src/submodules/publication/submodules/notInterested/NotInterested.ts @@ -12,14 +12,14 @@ import { Sdk, getSdk } from './graphql/notInterested.generated'; * @group LensClient Modules */ export class NotInterested { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; - constructor(context: LensContext, authentication?: Authentication) { + constructor( + context: LensContext, + private readonly authentication: Authentication, + ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/publication/submodules/reactions/Reactions.ts b/packages/client/src/submodules/publication/submodules/reactions/Reactions.ts index 16753023ad..8137cd6efc 100644 --- a/packages/client/src/submodules/publication/submodules/reactions/Reactions.ts +++ b/packages/client/src/submodules/publication/submodules/reactions/Reactions.ts @@ -23,17 +23,14 @@ import { getSdk, ProfileWhoReactedResultFragment, Sdk } from './graphql/reaction * @group LensClient Modules */ export class Reactions { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication?: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/revenue/Revenue.ts b/packages/client/src/submodules/revenue/Revenue.ts index 54dc7839c4..88b9c0e22b 100644 --- a/packages/client/src/submodules/revenue/Revenue.ts +++ b/packages/client/src/submodules/revenue/Revenue.ts @@ -29,7 +29,7 @@ export class Revenue { constructor( private readonly context: LensContext, - authentication?: Authentication, + authentication: Authentication, ) { const client = new FetchGraphQLClient(context); this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); diff --git a/packages/client/src/submodules/search/Search.ts b/packages/client/src/submodules/search/Search.ts index cd427a3ca5..dcc952993e 100644 --- a/packages/client/src/submodules/search/Search.ts +++ b/packages/client/src/submodules/search/Search.ts @@ -22,7 +22,7 @@ export class Search { constructor( private readonly context: LensContext, - authentication?: Authentication, + authentication: Authentication, ) { const client = new FetchGraphQLClient(context); this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); diff --git a/packages/client/src/submodules/transaction/Transaction.ts b/packages/client/src/submodules/transaction/Transaction.ts index 67b7aa4fed..56449c4efa 100644 --- a/packages/client/src/submodules/transaction/Transaction.ts +++ b/packages/client/src/submodules/transaction/Transaction.ts @@ -39,14 +39,14 @@ export class TransactionPollingError extends Error { * @group LensClient Modules */ export class Transaction { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; - constructor(context: LensContext, authentication: Authentication) { + constructor( + context: LensContext, + private readonly authentication: Authentication, + ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /** diff --git a/packages/client/src/submodules/wallet/Wallet.ts b/packages/client/src/submodules/wallet/Wallet.ts index 18e304b489..6978fba839 100644 --- a/packages/client/src/submodules/wallet/Wallet.ts +++ b/packages/client/src/submodules/wallet/Wallet.ts @@ -36,17 +36,14 @@ import { * @group LensClient Modules */ export class Wallet { - private readonly authentication: Authentication | undefined; private readonly sdk: Sdk; constructor( private readonly context: LensContext, - authentication?: Authentication, + private readonly authentication: Authentication, ) { const client = new FetchGraphQLClient(context); - this.sdk = getSdk(client, sdkAuthHeaderWrapper(authentication)); - this.authentication = authentication; } /**