@lokalise/harmony 1.6.0-exp-jwtutils.22 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +64 -0
  2. package/dist/harmony.cjs +1 -1
  3. package/dist/harmony.mjs +547 -552
  4. package/dist/types/src/components/Sidebar/Sidebar.d.ts +5 -2
  5. package/dist/types/src/components/Sidebar/Sidebar.stories.d.ts +1 -0
  6. package/dist/types/src/components/Sidebar/Widgets/Avatar/Avatar.d.ts +3 -0
  7. package/dist/types/src/components/Sidebar/Widgets/IconLink/IconLink.d.ts +3 -0
  8. package/dist/types/src/components/Sidebar/Widgets/Menu/Menu.d.ts +3 -0
  9. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/ProfileMenu.d.ts +4 -0
  10. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/ProfileSettingsMenuItem/ProfileSettingsMenuItem.d.ts +4 -0
  11. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/TeamMenuItem/TeamMenuItem.d.ts +5 -0
  12. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/TeamSwitch/TeamSwitch.d.ts +3 -0
  13. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/UpgradeMenuItem/UpgradeMenuItem.d.ts +5 -0
  14. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/types.d.ts +9 -6
  15. package/dist/types/src/features/auth/backend/services/getAuthenticatedSessionDetailFromRequest.d.ts +10 -0
  16. package/dist/types/src/features/auth/core/jwtTokenPayload.d.ts +7 -14
  17. package/dist/types/src/features/auth/core/lokaliseAuthAddon.d.ts +8 -0
  18. package/dist/types/src/features/auth/core/middleware/jwtAuthMiddleware.d.ts +1 -1
  19. package/dist/types/src/features/auth/core/middleware/publicApiHeadersMiddleware.d.ts +3 -0
  20. package/dist/types/src/features/auth/core/types/jwtTokenPayload.d.ts +4 -4
  21. package/dist/types/src/features/auth/core/types/jwtTokenPayload.fixture.d.ts +5 -5
  22. package/dist/types/src/features/auth/core/utils/makeAuthHeader.d.ts +2 -3
  23. package/dist/types/src/features/auth/frontend/addon/lokaliseAuthBrowserAddon.d.ts +7 -0
  24. package/dist/types/src/features/auth/frontend/events/NewJwtIssuedEvent.d.ts +1 -1
  25. package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedProjectContributor.d.ts +9 -1
  26. package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedSessionPayload.d.ts +2 -2
  27. package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedUser.d.ts +7 -1
  28. package/dist/types/src/features/auth/frontend/hooks/useGetPromotedClassicSessionJwtQuery.d.ts +11 -202
  29. package/dist/types/src/features/auth/frontend/utils/cookieTokenUtils.d.ts +4 -0
  30. package/dist/types/src/features/auth/frontend/utils/cookieTokenUtils.test.d.ts +1 -0
  31. package/dist/types/src/features/auth/{index.d.ts → node.d.ts} +1 -11
  32. package/dist/types/src/features/node.d.ts +2 -0
  33. package/dist/types/src/features/publicApi/contributors.d.ts +3 -97
  34. package/dist/types/src/features/publicApi/hooks/useCreateProjectMutation.d.ts +11 -6
  35. package/dist/types/src/features/publicApi/hooks/useGetTeamUsersQuery.d.ts +11 -2
  36. package/dist/types/src/features/publicApi/hooks/useGetUserTokenQuery.d.ts +11 -2
  37. package/dist/types/src/features/publicApi/hooks/useListProjectsQuery.d.ts +13 -4
  38. package/dist/types/src/features/publicApi/hooks/useRetrieveContributorQuery.d.ts +11 -2
  39. package/dist/types/src/features/publicApi/hooks/useRetrieveProjectQuery.d.ts +13 -4
  40. package/dist/types/src/features/publicApi/{index.d.ts → node.d.ts} +6 -3
  41. package/dist/types/src/features/publicApi/projects.d.ts +259 -784
  42. package/dist/types/src/features/publicApi/teamUsers.d.ts +3 -70
  43. package/dist/types/src/features/publicApi/types/contributorTypes.d.ts +171 -0
  44. package/dist/types/src/features/publicApi/types/projectTypes.d.ts +1061 -0
  45. package/dist/types/src/features/publicApi/types/teamUserTypes.d.ts +70 -0
  46. package/dist/types/src/features/publicApi/types/userTokenTypes.d.ts +26 -0
  47. package/dist/types/src/features/publicApi/userToken.d.ts +0 -11
  48. package/dist/types/src/node.d.ts +3 -6
  49. package/dist/types/tests/utils.d.ts +1 -6
  50. package/package.json +23 -18
  51. package/dist/types/src/features/auth/bff/services/getAuthenticatedSessionDetailFromRequest.d.ts +0 -18
  52. package/dist/types/src/features/auth/frontend/utils/cookieToken.d.ts +0 -4
  53. package/dist/types/src/features/publicApi/types/project.d.ts +0 -522
  54. /package/dist/types/src/{features/auth/bff/services/getAuthenticatedSessionPayloadFromRequest.test.d.ts → components/Sidebar/Widgets/ProfileMenu/ProfileMenu.test.d.ts} +0 -0
  55. /package/dist/types/src/features/auth/{frontend/utils/cookieToken.test.d.ts → backend/services/getAuthenticatedSessionPayloadFromRequest.test.d.ts} +0 -0
  56. /package/dist/types/src/features/publicApi/types/{language.d.ts → languageTypes.d.ts} +0 -0
  57. /package/dist/types/src/features/publicApi/types/{teamRole.d.ts → teamRoleTypes.d.ts} +0 -0
@@ -2,10 +2,13 @@ import { HTMLProps, PropsWithChildren, ReactNode } from 'react';
2
2
  type SidebarProps = HTMLProps<HTMLElement> & {
3
3
  children: ReactNode;
4
4
  };
5
+ /**
6
+ * Sidebar is a self-contained component using widgets.
7
+ */
5
8
  declare const Sidebar: {
6
9
  ({ children, ...navProps }: SidebarProps): import("react/jsx-runtime").JSX.Element;
7
- Top({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
8
- Bottom({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
10
+ Top: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
11
+ Bottom: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
9
12
  Avatar: ({ src, href, ariaLabel, alt }: {
10
13
  src: string;
11
14
  href?: string;
@@ -87,4 +87,5 @@ import { Sidebar } from './Sidebar';
87
87
  declare const meta: Meta<typeof Sidebar>;
88
88
  type Story = StoryObj<typeof Sidebar>;
89
89
  export declare const FullSidebar: Story;
90
+ export declare const FlowSidebar: Story;
90
91
  export default meta;
@@ -4,5 +4,8 @@ type AvatarProps = {
4
4
  ariaLabel?: string;
5
5
  alt?: string;
6
6
  };
7
+ /**
8
+ * Display company main avatar / logo in the top section
9
+ */
7
10
  export declare const Avatar: ({ src, href, ariaLabel, alt }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
8
11
  export {};
@@ -5,5 +5,8 @@ type IconLinkProps = {
5
5
  label: string;
6
6
  icon: FC<SvgIconProps>;
7
7
  };
8
+ /**
9
+ * Display link with an icon. Mainly used in the top section
10
+ */
8
11
  export declare const IconLink: ({ label, to, icon: Icon }: IconLinkProps) => import("react/jsx-runtime").JSX.Element;
9
12
  export {};
@@ -3,5 +3,8 @@ import { FC, PropsWithChildren } from 'react';
3
3
  type MenuProps = PropsWithChildren<{
4
4
  icon: FC<SvgIconProps>;
5
5
  }>;
6
+ /**
7
+ * Use this widget for simple side menu. Currently utilised for `Help` section
8
+ */
6
9
  export declare const Menu: ({ children, icon: Icon }: MenuProps) => import("react/jsx-runtime").JSX.Element;
7
10
  export {};
@@ -4,5 +4,9 @@ type ProfileMenuProps = {
4
4
  config: SidebarProfileMenuConfig;
5
5
  children: ProfileMenuContentProps['children'];
6
6
  };
7
+ /**
8
+ * Contextual component, requires initial configuration
9
+ * and works with internal widgets
10
+ */
7
11
  export declare const ProfileMenu: ({ config, children }: ProfileMenuProps) => import("react/jsx-runtime").JSX.Element;
8
12
  export {};
@@ -4,5 +4,9 @@ type ProfileSettingsMenuItemProps = {
4
4
  onClick?: () => void;
5
5
  hideBottomDivider?: boolean;
6
6
  };
7
+ /**
8
+ * Menu item that comes with a small user's email and renders conditionally,
9
+ * only if team is not suspended or is not at the end of a trial
10
+ */
7
11
  export declare const ProfileSettingsMenuItem: ({ href, onClick, userEmail, hideBottomDivider, }: ProfileSettingsMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
8
12
  export {};
@@ -4,5 +4,10 @@ type TeamMenuItemProps = {
4
4
  onClick?: (team: SidebarTeam) => void;
5
5
  hidePlanLabel?: boolean;
6
6
  };
7
+ /**
8
+ * Uses context of current team, and depending on ability to switch team or not,
9
+ * it renders as a div or clickable MenuItem. If used with TeamSwitch, it triggers `onSwitchTeams`
10
+ * callback, passing relevant team as an argument
11
+ */
7
12
  export declare const TeamMenuItem: ({ team, onClick, hidePlanLabel }: TeamMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
8
13
  export {};
@@ -2,5 +2,8 @@ import { SidebarTeam } from '../../../types';
2
2
  type TeamSwitchProps = {
3
3
  onSwitchTeam: (team: SidebarTeam) => void;
4
4
  };
5
+ /**
6
+ * Uses available teams (other than current) and allows user to switch between them
7
+ */
5
8
  export declare const TeamSwitch: ({ onSwitchTeam }: TeamSwitchProps) => import("react/jsx-runtime").JSX.Element | null;
6
9
  export {};
@@ -1,5 +1,10 @@
1
1
  type UpgradeMenuItemProps = {
2
2
  upgradeOptionHref: string;
3
3
  };
4
+ /**
5
+ * Menu item conditionally rendering only if `showUpgradeButton` is `true`.
6
+ * It renders correct upgrade note depending on the current team plan
7
+ * and red arrow up to indicate an update option.
8
+ */
4
9
  export declare const UpgradeMenuItem: ({ upgradeOptionHref }: UpgradeMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
5
10
  export {};
@@ -1,22 +1,25 @@
1
- import { SidebarTeam } from '../../types';
1
+ import { SidebarTeam, SidebarTeamRole } from '../../types';
2
+ export type { SidebarTeam, SidebarTeamRole } from '../../types';
2
3
  export type SidebarProfileMenuConfig = {
3
4
  teams: SidebarTeam[];
4
- currentTeamId: number;
5
- planId: number;
6
- isLimitedView: boolean;
7
5
  isTeamSuspended: boolean;
8
- canAccessTeamSettings: boolean;
9
6
  isEndOfTrialActive: boolean;
10
7
  trialDaysLeft: number;
8
+ currentTeamId: number;
9
+ planId: number;
10
+ isFullyAuthenticated: boolean;
11
11
  isProviderAlpha: boolean;
12
+ userTeamRole: SidebarTeamRole;
13
+ userEmail: string;
12
14
  };
13
15
  export type SidebarProfileMenuContextProps = SidebarProfileMenuConfig & {
14
16
  currentTeam?: SidebarTeam;
15
17
  otherTeams: SidebarTeam[];
16
18
  canChangeBilling: boolean;
19
+ canAccessTeamSettings: boolean;
17
20
  isOnFreeOrTrialPlan: boolean;
18
21
  showUpgradeCta: boolean;
19
22
  showBillingButton: boolean;
20
23
  allowTeamCreation: boolean;
21
24
  };
22
- export type SidebarProfileMenuRenderProps = Pick<SidebarProfileMenuContextProps, 'otherTeams' | 'allowTeamCreation' | 'isLimitedView' | 'canAccessTeamSettings' | 'isEndOfTrialActive' | 'isTeamSuspended' | 'showBillingButton' | 'isProviderAlpha'>;
25
+ export type SidebarProfileMenuRenderProps = Pick<SidebarProfileMenuContextProps, 'otherTeams' | 'allowTeamCreation' | 'isEndOfTrialActive' | 'canAccessTeamSettings' | 'showBillingButton' | 'isProviderAlpha' | 'isFullyAuthenticated' | 'isTeamSuspended'>;
@@ -0,0 +1,10 @@
1
+ import { JwtTokenPayload } from '../../core/types/jwtTokenPayload';
2
+ import { JwtToken } from '../../../publicApi/types/userTokenTypes';
3
+ type AuthenticatedSessionDetail = JwtToken & {
4
+ payload: JwtTokenPayload;
5
+ };
6
+ /**
7
+ * Returns the JWT tokens and parses the attached payload.
8
+ */
9
+ export declare function getAuthenticatedSessionDetailFromRequest(): AuthenticatedSessionDetail | undefined;
10
+ export {};
@@ -1,14 +1,7 @@
1
- export declare function parseJwtTokenPayload(token: string): {
2
- isProviderAlpha: boolean;
3
- planId: number;
4
- userEmail: string;
5
- teamId: number;
6
- userId: number;
7
- userUuid: string;
8
- userTeamRole: "member" | "admin" | "biller" | "owner";
9
- userName: string;
10
- userCurrentTeamId: number;
11
- planName: string;
12
- isFullyAuthenticated: boolean;
13
- exp: number;
14
- } | undefined;
1
+ import { JwtTokenPayload } from './types/jwtTokenPayload';
2
+ /**
3
+ * Parses the payload of a JWT token.
4
+ *
5
+ * @param token - The JWT token to parse.
6
+ */
7
+ export declare function parseJwtTokenPayload(token: string): JwtTokenPayload | undefined;
@@ -1,6 +1,14 @@
1
1
  import { Wretch, WretchAddon } from 'wretch/types';
2
2
  import { JwtAuthProps } from './middleware/jwtAuthMiddleware';
3
3
  export interface LokaliseAuthAddon {
4
+ /**
5
+ * Add authentication and automatic token refresh to Lokalise requests.
6
+ */
4
7
  lokaliseAuth<T extends LokaliseAuthAddon>(this: T & Wretch<T>, props: JwtAuthProps): this;
5
8
  }
9
+ /**
10
+ * Addon for Lokalise authentication.
11
+ * This will expose a method that can be used to authenticate requests to Lokalise.
12
+ * It will also handle refreshing the token when it expires.
13
+ */
6
14
  export declare const LokaliseAuthAddon: WretchAddon<LokaliseAuthAddon>;
@@ -1,5 +1,5 @@
1
+ import { JwtToken } from '../../../publicApi/types/userTokenTypes';
1
2
  import { ConfiguredMiddleware, Wretch } from 'wretch';
2
- import { JwtToken } from '../../../publicApi/userToken';
3
3
  export type JwtAuthProps = {
4
4
  /**
5
5
  * This function should return the current JWT token if it exists.
@@ -1,2 +1,5 @@
1
1
  import { ConfiguredMiddleware } from 'wretch';
2
+ /**
3
+ * Adds the required headers to make requests to the public API.
4
+ */
2
5
  export declare function publicApiHeadersMiddleware(): ConfiguredMiddleware;
@@ -14,29 +14,29 @@ export declare const JWT_TOKEN_PAYLOAD_SCHEMA: z.ZodObject<{
14
14
  exp: z.ZodNumber;
15
15
  }, "strip", z.ZodTypeAny, {
16
16
  isProviderAlpha: boolean;
17
+ isFullyAuthenticated: boolean;
17
18
  planId: number;
19
+ userTeamRole: "member" | "admin" | "biller" | "owner";
18
20
  userEmail: string;
19
21
  teamId: number;
20
22
  userId: number;
21
23
  userUuid: string;
22
- userTeamRole: "member" | "admin" | "biller" | "owner";
23
24
  userName: string;
24
25
  userCurrentTeamId: number;
25
26
  planName: string;
26
- isFullyAuthenticated: boolean;
27
27
  exp: number;
28
28
  }, {
29
29
  isProviderAlpha: boolean;
30
+ isFullyAuthenticated: boolean;
30
31
  planId: number;
32
+ userTeamRole: "member" | "admin" | "biller" | "owner";
31
33
  userEmail: string;
32
34
  teamId: number;
33
35
  userId: number;
34
36
  userUuid: string;
35
- userTeamRole: "member" | "admin" | "biller" | "owner";
36
37
  userName: string;
37
38
  userCurrentTeamId: number;
38
39
  planName: string;
39
- isFullyAuthenticated: boolean;
40
40
  exp: number;
41
41
  }>;
42
42
  export type JwtTokenPayload = z.infer<typeof JWT_TOKEN_PAYLOAD_SCHEMA>;
@@ -1,27 +1,27 @@
1
1
  export declare const createMockJwtTokenPayload: (overrides?: {
2
2
  isProviderAlpha?: boolean | undefined;
3
+ isFullyAuthenticated?: boolean | undefined;
3
4
  planId?: number | undefined;
5
+ userTeamRole?: "member" | "admin" | "biller" | "owner" | undefined;
4
6
  userEmail?: string | undefined;
5
7
  teamId?: number | undefined;
6
8
  userId?: number | undefined;
7
9
  userUuid?: string | undefined;
8
- userTeamRole?: "member" | "admin" | "biller" | "owner" | undefined;
9
10
  userName?: string | undefined;
10
11
  userCurrentTeamId?: number | undefined;
11
12
  planName?: string | undefined;
12
- isFullyAuthenticated?: boolean | undefined;
13
13
  exp?: number | undefined;
14
- } | undefined, removeProperties?: ("isProviderAlpha" | "planId" | "userEmail" | "teamId" | "userId" | "userUuid" | "userTeamRole" | "userName" | "userCurrentTeamId" | "planName" | "isFullyAuthenticated" | "exp")[]) => {
14
+ } | undefined, removeProperties?: ("isProviderAlpha" | "isFullyAuthenticated" | "planId" | "userTeamRole" | "userEmail" | "teamId" | "userId" | "userUuid" | "userName" | "userCurrentTeamId" | "planName" | "exp")[]) => {
15
15
  isProviderAlpha: boolean;
16
+ isFullyAuthenticated: boolean;
16
17
  planId: number;
18
+ userTeamRole: "member" | "admin" | "biller" | "owner";
17
19
  userEmail: string;
18
20
  teamId: number;
19
21
  userId: number;
20
22
  userUuid: string;
21
- userTeamRole: "member" | "admin" | "biller" | "owner";
22
23
  userName: string;
23
24
  userCurrentTeamId: number;
24
25
  planName: string;
25
- isFullyAuthenticated: boolean;
26
26
  exp: number;
27
27
  };
@@ -1,3 +1,2 @@
1
- export declare function makeAuthHeader(token: string): {
2
- Authorization: string;
3
- };
1
+ import { AuthenticatedRequestHeader } from '../../../publicApi/types/userTokenTypes';
2
+ export declare function makeAuthHeader(token: string): AuthenticatedRequestHeader;
@@ -24,5 +24,12 @@ export interface LokaliseAuthBrowserAddon {
24
24
  lokaliseAuth<T extends LokaliseAuthBrowserAddon>(this: T & Wretch<T>, props?: BrowserJwtAuthProps): this;
25
25
  promoteClassicSession<T extends LokaliseAuthBrowserAddon>(this: T & Wretch<T>, props: BrowserPromoteAuthProps): this;
26
26
  }
27
+ /**
28
+ * A browser implementation of the LokaliseAuthAddon.
29
+ * This implementation provides default providers that uses cookies to retrieve the JWT token.
30
+ *
31
+ * It exposes another utility method to automatically promote a classic session to a JWT session
32
+ * when a request is made from an environment using class CSRF PHP token authentication.
33
+ */
27
34
  export declare const LokaliseAuthBrowserAddon: WretchAddon<LokaliseAuthBrowserAddon>;
28
35
  export {};
@@ -1,5 +1,5 @@
1
- import { JwtToken } from '../../../publicApi';
2
1
  import { JwtTokenPayload } from '../../core/types/jwtTokenPayload';
2
+ import { JwtToken } from '../../../publicApi/types/userTokenTypes';
3
3
  type NewJwtIssuedEventDetail = {
4
4
  token: JwtToken;
5
5
  payload: JwtTokenPayload | undefined;
@@ -1,5 +1,13 @@
1
1
  import { Wretch } from 'wretch';
2
- export declare function useAuthenticatedProjectContributor<T>(api: Wretch<T>, projectId: string): import('@tanstack/react-query').UseQueryResult<{
2
+ /**
3
+ * Uses the payload attached to the JWT to request the contributor information
4
+ * of the provided project for the authenticated user.
5
+ * This required an active JWT token to be present in the cookie.
6
+ *
7
+ * @param wretchClient - Wretch instance configured to a public API instance.
8
+ * @param projectId - The ID of the project to retrieve the contributor information.
9
+ */
10
+ export declare function useAuthenticatedProjectContributor<T>(wretchClient: Wretch<T>, projectId: string): import('@tanstack/react-query').UseQueryResult<{
3
11
  contributors: {
4
12
  email: string;
5
13
  user_id: number;
@@ -4,15 +4,15 @@
4
4
  */
5
5
  export declare function useAuthenticatedSessionPayload(): {
6
6
  isProviderAlpha: boolean;
7
+ isFullyAuthenticated: boolean;
7
8
  planId: number;
9
+ userTeamRole: "member" | "admin" | "biller" | "owner";
8
10
  userEmail: string;
9
11
  teamId: number;
10
12
  userId: number;
11
13
  userUuid: string;
12
- userTeamRole: "member" | "admin" | "biller" | "owner";
13
14
  userName: string;
14
15
  userCurrentTeamId: number;
15
16
  planName: string;
16
- isFullyAuthenticated: boolean;
17
17
  exp: number;
18
18
  } | undefined;
@@ -1,5 +1,11 @@
1
1
  import { Wretch } from 'wretch';
2
- export declare function useAuthenticatedUser<T>(api: Wretch<T>): import('@tanstack/react-query').UseQueryResult<{
2
+ /**
3
+ * Uses the payload attached to the JWT to request the team-user information for the authenticated user.
4
+ * This required an active JWT token to be present in the cookie.
5
+ *
6
+ * @param wretchClient - Wretch instance configured to a public API instance.
7
+ */
8
+ export declare function useAuthenticatedUser<T>(wretchClient: Wretch<T>): import('@tanstack/react-query').UseQueryResult<{
3
9
  team_id: number;
4
10
  team_user: {
5
11
  role: "member" | "admin" | "biller" | "owner";
@@ -1,203 +1,12 @@
1
1
  import { Wretch } from 'wretch';
2
- export declare function useGetPromotedClassicSessionJwtQuery<T>(api: Wretch<T>, teamId: number): {
3
- isFetching: boolean;
4
- data: {
5
- accessToken: string;
6
- refreshToken: string;
7
- };
8
- error: undefined;
9
- isError: true;
10
- isPending: false;
11
- isLoading: false;
12
- isLoadingError: false;
13
- isRefetchError: true;
14
- isSuccess: false;
15
- isPlaceholderData: false;
16
- status: "error";
17
- dataUpdatedAt: number;
18
- errorUpdatedAt: number;
19
- failureCount: number;
20
- failureReason: null | undefined;
21
- errorUpdateCount: number;
22
- isFetched: boolean;
23
- isFetchedAfterMount: boolean;
24
- isInitialLoading: boolean;
25
- isPaused: boolean;
26
- isRefetching: boolean;
27
- isStale: boolean;
28
- refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<{
29
- accessToken: string;
30
- refreshToken: string;
31
- }, undefined>>;
32
- fetchStatus: import('@tanstack/query-core').FetchStatus;
33
- promise: Promise<{
34
- accessToken: string;
35
- refreshToken: string;
36
- }>;
37
- } | {
38
- isFetching: boolean;
39
- data: {
40
- accessToken: string;
41
- refreshToken: string;
42
- };
43
- error: null;
44
- isError: false;
45
- isPending: false;
46
- isLoading: false;
47
- isLoadingError: false;
48
- isRefetchError: false;
49
- isSuccess: true;
50
- isPlaceholderData: false;
51
- status: "success";
52
- dataUpdatedAt: number;
53
- errorUpdatedAt: number;
54
- failureCount: number;
55
- failureReason: null | undefined;
56
- errorUpdateCount: number;
57
- isFetched: boolean;
58
- isFetchedAfterMount: boolean;
59
- isInitialLoading: boolean;
60
- isPaused: boolean;
61
- isRefetching: boolean;
62
- isStale: boolean;
63
- refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<{
64
- accessToken: string;
65
- refreshToken: string;
66
- }, undefined>>;
67
- fetchStatus: import('@tanstack/query-core').FetchStatus;
68
- promise: Promise<{
69
- accessToken: string;
70
- refreshToken: string;
71
- }>;
72
- } | {
73
- isFetching: boolean;
74
- data: undefined;
75
- error: undefined;
76
- isError: true;
77
- isPending: false;
78
- isLoading: false;
79
- isLoadingError: true;
80
- isRefetchError: false;
81
- isSuccess: false;
82
- isPlaceholderData: false;
83
- status: "error";
84
- dataUpdatedAt: number;
85
- errorUpdatedAt: number;
86
- failureCount: number;
87
- failureReason: null | undefined;
88
- errorUpdateCount: number;
89
- isFetched: boolean;
90
- isFetchedAfterMount: boolean;
91
- isInitialLoading: boolean;
92
- isPaused: boolean;
93
- isRefetching: boolean;
94
- isStale: boolean;
95
- refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<{
96
- accessToken: string;
97
- refreshToken: string;
98
- }, undefined>>;
99
- fetchStatus: import('@tanstack/query-core').FetchStatus;
100
- promise: Promise<{
101
- accessToken: string;
102
- refreshToken: string;
103
- }>;
104
- } | {
105
- isFetching: boolean;
106
- data: undefined;
107
- error: null;
108
- isError: false;
109
- isPending: true;
110
- isLoading: true;
111
- isLoadingError: false;
112
- isRefetchError: false;
113
- isSuccess: false;
114
- isPlaceholderData: false;
115
- status: "pending";
116
- dataUpdatedAt: number;
117
- errorUpdatedAt: number;
118
- failureCount: number;
119
- failureReason: null | undefined;
120
- errorUpdateCount: number;
121
- isFetched: boolean;
122
- isFetchedAfterMount: boolean;
123
- isInitialLoading: boolean;
124
- isPaused: boolean;
125
- isRefetching: boolean;
126
- isStale: boolean;
127
- refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<{
128
- accessToken: string;
129
- refreshToken: string;
130
- }, undefined>>;
131
- fetchStatus: import('@tanstack/query-core').FetchStatus;
132
- promise: Promise<{
133
- accessToken: string;
134
- refreshToken: string;
135
- }>;
136
- } | {
137
- isFetching: boolean;
138
- data: undefined;
139
- error: null;
140
- isError: false;
141
- isPending: true;
142
- isLoadingError: false;
143
- isRefetchError: false;
144
- isSuccess: false;
145
- isPlaceholderData: false;
146
- status: "pending";
147
- dataUpdatedAt: number;
148
- errorUpdatedAt: number;
149
- failureCount: number;
150
- failureReason: null | undefined;
151
- errorUpdateCount: number;
152
- isFetched: boolean;
153
- isFetchedAfterMount: boolean;
154
- isLoading: boolean;
155
- isInitialLoading: boolean;
156
- isPaused: boolean;
157
- isRefetching: boolean;
158
- isStale: boolean;
159
- refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<{
160
- accessToken: string;
161
- refreshToken: string;
162
- }, undefined>>;
163
- fetchStatus: import('@tanstack/query-core').FetchStatus;
164
- promise: Promise<{
165
- accessToken: string;
166
- refreshToken: string;
167
- }>;
168
- } | {
169
- isFetching: boolean;
170
- data: {
171
- accessToken: string;
172
- refreshToken: string;
173
- };
174
- isError: false;
175
- error: null;
176
- isPending: false;
177
- isLoading: false;
178
- isLoadingError: false;
179
- isRefetchError: false;
180
- isSuccess: true;
181
- isPlaceholderData: true;
182
- status: "success";
183
- dataUpdatedAt: number;
184
- errorUpdatedAt: number;
185
- failureCount: number;
186
- failureReason: null | undefined;
187
- errorUpdateCount: number;
188
- isFetched: boolean;
189
- isFetchedAfterMount: boolean;
190
- isInitialLoading: boolean;
191
- isPaused: boolean;
192
- isRefetching: boolean;
193
- isStale: boolean;
194
- refetch: (options?: import('@tanstack/query-core').RefetchOptions) => Promise<import('@tanstack/query-core').QueryObserverResult<{
195
- accessToken: string;
196
- refreshToken: string;
197
- }, undefined>>;
198
- fetchStatus: import('@tanstack/query-core').FetchStatus;
199
- promise: Promise<{
200
- accessToken: string;
201
- refreshToken: string;
202
- }>;
203
- };
2
+ /**
3
+ * For use in environments that are authenticated with a classic CSRF PHP session (e.g. Expert).
4
+ * This hook will send that token to the public API, upgrade to a JWT session.
5
+ *
6
+ * @param wretchClient - Wretch instance configured to a public API instance.
7
+ * @param teamId - The team ID to get the JWT for.
8
+ */
9
+ export declare function useGetPromotedClassicSessionJwtQuery<T>(wretchClient: Wretch<T>, teamId: number): import('@tanstack/react-query').UseQueryResult<{
10
+ accessToken: string;
11
+ refreshToken: string;
12
+ }, undefined>;
@@ -0,0 +1,4 @@
1
+ import { JwtToken } from '../../../publicApi/types/userTokenTypes';
2
+ export declare function getJwtTokenFromCookie(): JwtToken | undefined;
3
+ export declare function getCsrfTokenFromCookie(): string | undefined;
4
+ export declare function getCookie(cookies: string, name: string): string | undefined;
@@ -1,19 +1,9 @@
1
- /**
2
- * Auth
3
- */
4
1
  export * from './frontend/hooks/useGetPromotedClassicSessionJwtQuery';
5
2
  export * from './frontend/hooks/useAuthenticatedSessionPayload';
6
3
  export * from './frontend/hooks/useAuthenticatedUser';
7
4
  export * from './frontend/hooks/useAuthenticatedProjectContributor';
8
- export * from './bff/services/getAuthenticatedSessionDetailFromRequest';
5
+ export * from './backend/services/getAuthenticatedSessionDetailFromRequest';
9
6
  export { parseJwtTokenPayload } from './core/jwtTokenPayload';
10
7
  export { publicApiHeadersMiddleware } from './core/middleware/publicApiHeadersMiddleware';
11
8
  export { LokaliseAuthAddon } from './core/lokaliseAuthAddon';
12
9
  export { LokaliseAuthBrowserAddon } from './frontend/addon/lokaliseAuthBrowserAddon';
13
- /**
14
- * Public API
15
- */
16
- export * from '../publicApi/hooks/useGetUserTokenQuery';
17
- export * from '../publicApi/hooks/useGetTeamUsersQuery';
18
- export * from '../publicApi/hooks/useRetrieveContributorQuery';
19
- export type { JwtTokenPayload } from './core/types/jwtTokenPayload';
@@ -0,0 +1,2 @@
1
+ export * from './auth/node';
2
+ export * from './publicApi/node';