import { UnspecifiedError, Profile } from '@lens-protocol/api-bindings';
import { LogoutReason, SessionType } from '@lens-protocol/domain/use-cases/authentication';
import { EvmAddress } from '@lens-protocol/shared-kernel';
import { ReadResult } from "../helpers/reads.js";
import { SuspenseEnabled, SuspenseResult } from "../helpers/suspense.js";
export { LogoutReason, SessionType };
/**
* A not authenticated user's session
*/
export type AnonymousSession = {
/**
* The union discriminant.
*/
type: SessionType.Anonymous;
/**
* Whether the user is authenticated or not.
*/
authenticated: false;
/**
* The reason the previous session ended.
*/
lastLogoutReason?: LogoutReason;
};
/**
* A typical authenticated user's session.
*/
export type ProfileSession = {
/**
* The union discriminant.
*/
type: SessionType.WithProfile;
/**
* Whether the user is authenticated or not.
*/
authenticated: true;
/**
* The Profile Owner or an authorized Profile Manager.
*/
address: EvmAddress;
/**
* The authenticated Profile.
*/
profile: Profile;
};
/**
* An authenticated user's session with just a wallet address.
*
* This is currently not used, but will be used in the future.
*/
export type WalletOnlySession = {
/**
* The union discriminant.
*/
type: SessionType.JustWallet;
/**
* Whether the user is authenticated or not.
*/
authenticated: true;
/**
* The Profile Owner or an authorized Profile Manager.
*/
address: EvmAddress;
};
/**
* Describes the details of a user's session.
*/
export type Session = AnonymousSession | ProfileSession | WalletOnlySession;
/**
* {@link useSession} hook arguments
*/
export type UseSessionArgs = SuspenseEnabled;
/**
* Returns current {@link Session} data.
*
* Use this hook to determine if the user is authenticated or not.
* ```tsx
* function Page() {
* const { data, error, loading } = useSession();
*
* if (loading) return
Something went wrong.
; * * switch (data.type) { * case SessionType.Anonymous: * // data is a AnonymousSession * returnSomething went wrong.
; * } * } * ``` * * @category Authentication * @group Hooks */ export declare function useSession(args: UseSessionArgs): SuspenseResultSomething went wrong.
; * } * } * ``` * * Further session data updates will NOT trigger a suspense. * * @category Authentication * @group Hooks */ export declare function useSession(): ReadResult