@lokalise/harmony 1.14.1 → 1.15.0-exp-removeaddon.1

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.
@@ -1,6 +1,10 @@
1
1
  import { JwtToken } from '../../../publicApi/types/userTokenTypes';
2
2
  import { ConfiguredMiddleware, Wretch } from 'wretch';
3
- export type JwtAuthProps = {
3
+ export type JwtAuthProps<T> = {
4
+ /**
5
+ * A configured Wretch client that is used to make requests to the authentication provider.
6
+ */
7
+ authProviderWretchClient: Wretch<T>;
4
8
  /**
5
9
  * This function should return the current JWT token if it exists.
6
10
  */
@@ -10,4 +14,4 @@ export type JwtAuthProps = {
10
14
  */
11
15
  onNewJwtTokenIssued?: (jwtToken: JwtToken) => Promise<void>;
12
16
  };
13
- export declare function jwtAuthMiddleware<T>(client: Wretch<T>, props: JwtAuthProps): ConfiguredMiddleware;
17
+ export declare function jwtAuthMiddleware<T>(props: JwtAuthProps<T>): ConfiguredMiddleware;
@@ -1,4 +1,4 @@
1
- import { JwtTokenPayload } from './types/jwtTokenPayload';
1
+ import { JwtTokenPayload } from '../types/jwtTokenPayload';
2
2
  /**
3
3
  * Parses the payload of a JWT token.
4
4
  *
@@ -0,0 +1,9 @@
1
+ import { JwtAuthProps } from '../../core/middleware/jwtAuthMiddleware';
2
+ export type ClientSideJwtAuthProps<T> = Omit<JwtAuthProps<T>, 'getCachedJwtToken'> & {
3
+ /**
4
+ * The browser implementation makes this optional, as it can be inferred from the cookie.
5
+ * You can still provide a custom implementation if you want to.
6
+ */
7
+ getCachedJwtToken?: JwtAuthProps<T>['getCachedJwtToken'];
8
+ };
9
+ export declare function clientSideJwtAuthMiddleware<T>(props: ClientSideJwtAuthProps<T>): import('wretch').ConfiguredMiddleware;
@@ -1,6 +1,6 @@
1
- import { ConfiguredMiddleware, Wretch } from 'wretch';
2
- import { JwtAuthProps } from '../../core/middleware/jwtAuthMiddleware';
3
- export type PromoteAuthProps = JwtAuthProps & {
1
+ import { ClientSideJwtAuthProps } from './clientSideJwtAuthMiddleware';
2
+ import { ConfiguredMiddleware } from 'wretch';
3
+ export type PromoteAuthProps<T> = ClientSideJwtAuthProps<T> & {
4
4
  /**
5
5
  * Team ID is required to issue a new JWT token.
6
6
  */
@@ -9,6 +9,6 @@ export type PromoteAuthProps = JwtAuthProps & {
9
9
  * The current CSRF token is required to issue a new JWT token.
10
10
  * So this function should return the CSRF token for the current session.
11
11
  */
12
- getCsrfToken: () => Promise<string | undefined>;
12
+ getCsrfToken?: () => Promise<string | undefined>;
13
13
  };
14
- export declare function promoteClassicSessionToJwtMiddleware<T>(client: Wretch<T>, props: PromoteAuthProps): ConfiguredMiddleware;
14
+ export declare function promoteClassicSessionToJwtMiddleware<T>(overrides: PromoteAuthProps<T>): ConfiguredMiddleware;
@@ -1,9 +1,11 @@
1
+ export { jwtAuthMiddleware } from './core/middleware/jwtAuthMiddleware';
2
+ export { publicApiHeadersMiddleware } from './core/middleware/publicApiHeadersMiddleware';
3
+ export { clientSideJwtAuthMiddleware } from './frontend/middleware/clientSideJwtAuthMiddleware';
4
+ export { promoteClassicSessionToJwtMiddleware } from './frontend/middleware/promoteClassicSessionToJwtMiddleware';
5
+ export type { JwtTokenPayload } from './core/types/jwtTokenPayload';
6
+ export { parseJwtTokenPayload } from './core/utils/jwtTokenPayload';
7
+ export * from './backend/services/getAuthenticatedSessionDetailFromRequest';
1
8
  export * from './frontend/hooks/useGetPromotedClassicSessionJwtQuery';
2
9
  export * from './frontend/hooks/useAuthenticatedSessionPayload';
3
10
  export * from './frontend/hooks/useAuthenticatedUser';
4
11
  export * from './frontend/hooks/useAuthenticatedProjectContributor';
5
- export * from './backend/services/getAuthenticatedSessionDetailFromRequest';
6
- export { parseJwtTokenPayload } from './core/jwtTokenPayload';
7
- export { publicApiHeadersMiddleware } from './core/middleware/publicApiHeadersMiddleware';
8
- export { LokaliseAuthAddon } from './core/lokaliseAuthAddon';
9
- export { LokaliseAuthBrowserAddon } from './frontend/addon/lokaliseAuthBrowserAddon';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/harmony",
3
- "version": "1.14.1",
3
+ "version": "1.15.0-exp-removeaddon.1",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"
@@ -1,14 +0,0 @@
1
- import { Wretch, WretchAddon } from 'wretch/types';
2
- import { JwtAuthProps } from './middleware/jwtAuthMiddleware';
3
- export interface LokaliseAuthAddon {
4
- /**
5
- * Add authentication and automatic token refresh to Lokalise requests.
6
- */
7
- lokaliseAuth<T extends LokaliseAuthAddon>(this: T & Wretch<T>, props: JwtAuthProps): this;
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
- */
14
- export declare const LokaliseAuthAddon: WretchAddon<LokaliseAuthAddon>;
@@ -1,35 +0,0 @@
1
- import { Wretch, WretchAddon } from 'wretch/types';
2
- import { JwtAuthProps } from '../../core/middleware/jwtAuthMiddleware';
3
- import { PromoteAuthProps } from '../middleware/promoteClassicSessionToJwtMiddleware';
4
- type BrowserJwtAuthProps = Omit<JwtAuthProps, 'getCachedJwtToken'> & {
5
- /**
6
- * The browser implementation makes this optional, as it can be inferred from the cookie.
7
- * You can still provide a custom implementation if you want to.
8
- */
9
- getCachedJwtToken?: JwtAuthProps['getCachedJwtToken'];
10
- };
11
- type BrowserPromoteAuthProps = Omit<PromoteAuthProps, 'getCachedJwtToken' | 'getCsrfToken'> & {
12
- /**
13
- * The browser implementation makes this optional, as it can be inferred from the cookie.
14
- * You can still provide a custom implementation if you want to.
15
- */
16
- getCachedJwtToken?: PromoteAuthProps['getCachedJwtToken'];
17
- /**
18
- * The browser implementation makes this optional, as it can be inferred from the cookie.
19
- * You can still provide a custom implementation if you want to.
20
- */
21
- getCsrfToken?: PromoteAuthProps['getCsrfToken'];
22
- };
23
- export interface LokaliseAuthBrowserAddon {
24
- lokaliseAuth<T extends LokaliseAuthBrowserAddon>(this: T & Wretch<T>, props?: BrowserJwtAuthProps): this;
25
- promoteClassicSession<T extends LokaliseAuthBrowserAddon>(this: T & Wretch<T>, props: BrowserPromoteAuthProps): this;
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
- */
34
- export declare const LokaliseAuthBrowserAddon: WretchAddon<LokaliseAuthBrowserAddon>;
35
- export {};