@lokalise/harmony 1.16.0 → 1.17.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.
- package/README.md +31 -21
- package/dist/harmony.cjs +1 -1
- package/dist/harmony.mjs +1013 -861
- package/dist/types/src/features/auth/core/headers/createHeaderBuilderMiddleware.d.ts +32 -0
- package/dist/types/src/features/auth/core/headers/headerBuilder.d.ts +171 -0
- package/dist/types/src/features/auth/core/middleware/jwtAuthHeaderBuilderMiddleware.d.ts +10 -0
- package/dist/types/src/features/auth/core/middleware/publicApiHeaderBuilderMiddleware.d.ts +3 -0
- package/dist/types/src/features/auth/core/types/jwtTokenPayload.d.ts +2 -2
- package/dist/types/src/features/auth/core/types/jwtTokenPayload.fixture.d.ts +3 -3
- package/dist/types/src/features/auth/core/utils/makeAuthHeader.d.ts +2 -2
- package/dist/types/src/features/auth/errors/UnauthorizedError.d.ts +4 -0
- package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedProjectContributor.d.ts +4 -1
- package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedSessionPayload.d.ts +1 -1
- package/dist/types/src/features/auth/frontend/hooks/useAuthenticatedUser.d.ts +4 -1
- package/dist/types/src/features/auth/frontend/hooks/useGetPromotedClassicSessionJwtQuery.d.ts +4 -2
- package/dist/types/src/features/auth/frontend/services/generateTokenFromClassicSession.d.ts +5 -0
- package/dist/types/src/features/auth/frontend/services/refreshExpiredToken.d.ts +6 -0
- package/dist/types/src/features/auth/frontend/utils/cookieTokenUtils.d.ts +2 -2
- package/dist/types/src/features/auth/node.d.ts +7 -4
- package/dist/types/src/features/publicApi/contributors.d.ts +19 -1
- package/dist/types/src/features/publicApi/hooks/useCreateProjectMutation.d.ts +4 -2
- package/dist/types/src/features/publicApi/hooks/useGetTeamUsersQuery.d.ts +4 -2
- package/dist/types/src/features/publicApi/hooks/useGetUserTokenQuery.d.ts +6 -5
- package/dist/types/src/features/publicApi/hooks/useListProjectLanguagesQuery.d.ts +10 -1
- package/dist/types/src/features/publicApi/hooks/useListProjectsQuery.d.ts +4 -2
- package/dist/types/src/features/publicApi/hooks/useRetrieveContributorQuery.d.ts +4 -2
- package/dist/types/src/features/publicApi/hooks/useRetrieveProjectQuery.d.ts +4 -2
- package/dist/types/src/features/publicApi/hooks/useUpdateProjectMutation.d.ts +4 -2
- package/dist/types/src/features/publicApi/languages.d.ts +19 -1
- package/dist/types/src/features/publicApi/node.d.ts +1 -1
- package/dist/types/src/features/publicApi/projects.d.ts +76 -4
- package/dist/types/src/features/publicApi/teamUsers.d.ts +22 -4
- package/dist/types/src/features/publicApi/types/contributorTypes.d.ts +20 -0
- package/dist/types/src/features/publicApi/types/projectTypes.d.ts +20 -0
- package/dist/types/src/features/publicApi/types/sharedTypes.d.ts +57 -0
- package/dist/types/src/features/publicApi/types/teamUserTypes.d.ts +20 -0
- package/dist/types/src/features/publicApi/types/userTokenTypes.d.ts +2 -2
- package/dist/types/src/features/publicApi/userToken.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types/src/features/auth/core/middleware/jwtAuthMiddleware.d.ts +0 -17
- package/dist/types/src/features/auth/core/middleware/publicApiHeadersMiddleware.d.ts +0 -5
- package/dist/types/src/features/auth/frontend/middleware/clientSideJwtAuthMiddleware.d.ts +0 -9
- package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.d.ts +0 -14
- /package/dist/types/src/features/auth/core/{middleware/jwtAuthMiddleware.test.d.ts → headers/createHeaderBuilderMiddleware.test.d.ts} +0 -0
- /package/dist/types/src/features/auth/{frontend/middleware/promoteClassicSessionToJwtMiddleware.test.d.ts → core/headers/headerBuilder.test.d.ts} +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
import { HeaderBuilder, Headers } from './headerBuilder';
|
2
|
+
/**
|
3
|
+
* A helper function that creates a HeaderBuilderMiddleware, it removed the
|
4
|
+
* complexity of creating a new instance of the middleware class and tracking the input types.
|
5
|
+
*
|
6
|
+
* @param middleware - A function that modifies a HeaderBuilder
|
7
|
+
* @returns - A new instance of HeaderBuilderMiddleware to be used with a HeaderBuilder
|
8
|
+
*/
|
9
|
+
export declare function createHeaderBuilderMiddleware<const H extends Headers>(middleware: (builder: HeaderBuilder) => HeaderBuilder<H> | Promise<HeaderBuilder<H>>): HeaderBuilderMiddleware<H>;
|
10
|
+
export type { HeaderBuilderMiddleware };
|
11
|
+
/**
|
12
|
+
* A middleware class that allows you to modify a HeaderBuilder in a type-safe way.
|
13
|
+
* It receives a builder and returns a new builder with the modifications applied.
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* ```typescript
|
17
|
+
* const authMiddleware = createHeaderBuilderMiddleware(async (builder) => {
|
18
|
+
* const token = await fetchToken()
|
19
|
+
* return builder.add('Authorization', `Bearer ${token}`)
|
20
|
+
* })
|
21
|
+
*
|
22
|
+
* const builder = HeaderBuilder.create()
|
23
|
+
* .with(authMiddleware)
|
24
|
+
*
|
25
|
+
* const headers = await builder.resolve() // Type of headers is { 'Authorization': string }
|
26
|
+
* console.log(headers) // { 'Authorization': 'Bearer <token>' }
|
27
|
+
*/
|
28
|
+
declare class HeaderBuilderMiddleware<const H extends Headers> {
|
29
|
+
private readonly middleware;
|
30
|
+
constructor(middleware: (builder: HeaderBuilder<Headers>) => HeaderBuilder<H> | Promise<HeaderBuilder<H>>);
|
31
|
+
apply<const BH extends Headers>(base: HeaderBuilder<BH>): HeaderBuilder<BH & H>;
|
32
|
+
}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
import { HeaderBuilderMiddleware } from './createHeaderBuilderMiddleware';
|
2
|
+
export type Headers<K extends string = string, V extends string = string> = Record<K, V>;
|
3
|
+
type NoHeaders = {};
|
4
|
+
/**
|
5
|
+
* A builder class that helps to build up a set of headers in a type-safe way.
|
6
|
+
* It allows you to add headers, merge them together, and resolve them into a single object.
|
7
|
+
* The builder is immutable, so every operation returns a new instance of the builder.
|
8
|
+
* It offers a middleware function that allows you to modify the builder, asynchronously, in a type-safe way.
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* ```typescript
|
12
|
+
* const authMiddleware = createHeaderBuilderMiddleware(async (builder) => {
|
13
|
+
* const token = await fetchToken()
|
14
|
+
* return builder.add('Authorization', `Bearer ${token}`)
|
15
|
+
* })
|
16
|
+
*
|
17
|
+
* const builder = HeaderBuilder.create()
|
18
|
+
* .add('Content-Type', 'application/json')
|
19
|
+
* .and({ 'X-Custom-Header': 'custom', 'X-Another-Header': 'another' })
|
20
|
+
* .with(authMiddleware)
|
21
|
+
*
|
22
|
+
* const headers = await builder.resolve()
|
23
|
+
* console.log(headers)
|
24
|
+
* // Prints: {
|
25
|
+
* // 'Content-Type': 'application/json',
|
26
|
+
* // 'X-Custom-Header': 'custom',
|
27
|
+
* // 'X-Another-Header': 'another',
|
28
|
+
* // 'Authorization': 'Bearer <token>'
|
29
|
+
* // }
|
30
|
+
*/
|
31
|
+
export declare class HeaderBuilder<H extends Headers = NoHeaders> {
|
32
|
+
private readonly factories;
|
33
|
+
/**
|
34
|
+
* Creates a new HeaderBuilder, optionally with an initial set of headers.
|
35
|
+
*
|
36
|
+
* @example
|
37
|
+
* ```typescript
|
38
|
+
* const builder = HeaderBuilder.create()
|
39
|
+
*
|
40
|
+
* const builderWithHeaders = HeaderBuilder.create({ 'Content-Type': 'application/json' })
|
41
|
+
*
|
42
|
+
* console.log(builder) // {}
|
43
|
+
* console.log(builderWithHeaders) // { 'Content-Type': 'application/json' }
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
static create<const H extends Headers = {}>(): HeaderBuilder<H>;
|
47
|
+
static create<const H extends Headers>(initialHeaders: H): HeaderBuilder<H>;
|
48
|
+
/**
|
49
|
+
* This constructor is private to prevent the creation of a HeaderBuilder, it's an implementation detail
|
50
|
+
* that users of this class should not be aware of. The only way to create a HeaderBuilder is through the
|
51
|
+
* static create method.
|
52
|
+
*
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
private constructor();
|
56
|
+
/**
|
57
|
+
* Adds a single header to the builder by providing a key and a value.
|
58
|
+
*
|
59
|
+
* @example
|
60
|
+
* ```typescript
|
61
|
+
* const builder = HeaderBuilder.create()
|
62
|
+
* .add('Content-Type', 'application/json')
|
63
|
+
* .add('Authorization', 'Bearer token')
|
64
|
+
*
|
65
|
+
* const headers = await builder.resolve()
|
66
|
+
* console.log(headers)
|
67
|
+
* // { 'Content-Type': 'application/json', 'Authorization': 'Bearer token' }
|
68
|
+
* ```
|
69
|
+
*
|
70
|
+
* @param key - The key of the header
|
71
|
+
* @param value - The value of the header
|
72
|
+
*/
|
73
|
+
add<const K extends string, const V>(key: K, value: V): HeaderBuilder<H & {
|
74
|
+
[k in K]: V;
|
75
|
+
}>;
|
76
|
+
/**
|
77
|
+
* Adds multiple headers to the builder by providing an object or a promise of an object with the headers.
|
78
|
+
*
|
79
|
+
* @example
|
80
|
+
* ```typescript
|
81
|
+
* const builder = HeaderBuilder.create()
|
82
|
+
* .and({ 'Content-Type': 'application/json', 'Authorization': 'Bearer token' })
|
83
|
+
* .and(Promise.resolve({ 'X-Custom-Header': 'custom', 'X-Another-Header': 'another' }))
|
84
|
+
*
|
85
|
+
* const headers = await builder.resolve()
|
86
|
+
* console.log(headers)
|
87
|
+
* // Prints: {
|
88
|
+
* // 'Content-Type': 'application/json',
|
89
|
+
* // 'Authorization': 'Bearer token',
|
90
|
+
* // 'X-Custom-Header': 'custom',
|
91
|
+
* // 'X-Another-Header': 'another'
|
92
|
+
* // }
|
93
|
+
* ```
|
94
|
+
*
|
95
|
+
* @param extension - An object with the headers to add
|
96
|
+
*/
|
97
|
+
and<const K extends string, const V extends string, E extends Headers<K, V>>(extension: E | Promise<E>): HeaderBuilder<H & E>;
|
98
|
+
/**
|
99
|
+
* Adds a factory function that returns a promise of headers to the builder.
|
100
|
+
* This is useful when you need to fetch some data asynchronously to build the headers.
|
101
|
+
*
|
102
|
+
* @example
|
103
|
+
* ```typescript
|
104
|
+
* const builder = HeaderBuilder.create()
|
105
|
+
* .from(async () => {
|
106
|
+
* const token = await fetchToken()
|
107
|
+
* return { 'Authorization': `Bearer ${token}` }
|
108
|
+
* })
|
109
|
+
*
|
110
|
+
* const headers = await builder.resolve()
|
111
|
+
* console.log(headers) // { 'Authorization': 'Bearer <token>' }
|
112
|
+
* ```
|
113
|
+
*
|
114
|
+
* @param factory - A function that returns a promise of headers
|
115
|
+
*/
|
116
|
+
from<E extends Headers>(factory: () => E | Promise<E>): HeaderBuilder<H & E>;
|
117
|
+
/**
|
118
|
+
* Takes a middleware function that receives the current builder and returns a new, modified, builder.
|
119
|
+
*
|
120
|
+
* @example
|
121
|
+
* ```typescript
|
122
|
+
* const authMiddleware = createHeaderBuilderMiddleware(async (builder) => {
|
123
|
+
* const token = await fetchToken()
|
124
|
+
* return builder.add('Authorization', `Bearer ${token}`)
|
125
|
+
* })
|
126
|
+
*
|
127
|
+
* const builder = HeaderBuilder.create()
|
128
|
+
* .with(authMiddleware)
|
129
|
+
*
|
130
|
+
* const headers = await builder.resolve() // Type of headers is { 'Authorization': string }
|
131
|
+
* console.log(headers) // { 'Authorization': 'Bearer <token>' }
|
132
|
+
* ```
|
133
|
+
*
|
134
|
+
* @param middleware
|
135
|
+
*/
|
136
|
+
with<const T extends Headers>(middleware: HeaderBuilderMiddleware<T>): HeaderBuilder<H & T>;
|
137
|
+
/**
|
138
|
+
* Merges the current builder with another builder.
|
139
|
+
*
|
140
|
+
* @example
|
141
|
+
* ```typescript
|
142
|
+
* const builderA = HeaderBuilder.create()
|
143
|
+
* .add('Content-Type', 'application/json')
|
144
|
+
*
|
145
|
+
* const builderB = HeaderBuilder.create()
|
146
|
+
* .add('Authorization', 'Bearer token')
|
147
|
+
*
|
148
|
+
* const mergedBuilder = builderA.merge(builderB)
|
149
|
+
*
|
150
|
+
* const headers = await mergedBuilder.resolve()
|
151
|
+
* console.log(headers)
|
152
|
+
* // { 'Content-Type': 'application/json', 'Authorization': 'Bearer token' }
|
153
|
+
* ```
|
154
|
+
*
|
155
|
+
* @param builder - The builder to merge with
|
156
|
+
*/
|
157
|
+
merge<const T extends Headers>(builder: HeaderBuilder<T>): HeaderBuilder<H & T>;
|
158
|
+
/**
|
159
|
+
* Resolves the headers by waiting for all the promises to resolve and merging them together.
|
160
|
+
*
|
161
|
+
* @example
|
162
|
+
* ```typescript
|
163
|
+
* const builder = HeaderBuilder.create()
|
164
|
+
* .add('Content-Type', 'application/json')
|
165
|
+
*
|
166
|
+
* const headers = await builder.resolve()
|
167
|
+
* console.log(headers) // { 'Content-Type': 'application/json' }
|
168
|
+
*/
|
169
|
+
resolve(): Promise<H>;
|
170
|
+
}
|
171
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
2
|
+
export type JwtAuthHeaderBuilderMiddlewareProps = {
|
3
|
+
refreshToken: (current: JwtToken) => Promise<JwtToken | null>;
|
4
|
+
getCurrentToken: () => JwtToken | null;
|
5
|
+
generateNewToken?: () => Promise<JwtToken | null>;
|
6
|
+
onNewTokenIssued?: (token: JwtToken) => void;
|
7
|
+
};
|
8
|
+
export declare function JwtAuthHeaderBuilderMiddleware(props: JwtAuthHeaderBuilderMiddlewareProps): import('../headers/createHeaderBuilderMiddleware').HeaderBuilderMiddleware<{
|
9
|
+
Authorization: `Bearer ${string}`;
|
10
|
+
}>;
|
@@ -18,9 +18,9 @@ export declare const JWT_TOKEN_PAYLOAD_SCHEMA: z.ZodObject<{
|
|
18
18
|
planId: number;
|
19
19
|
userTeamRole: "member" | "admin" | "biller" | "owner";
|
20
20
|
userEmail: string;
|
21
|
-
teamId: number;
|
22
21
|
userId: number;
|
23
22
|
userUuid: string;
|
23
|
+
teamId: number;
|
24
24
|
userName: string;
|
25
25
|
userCurrentTeamId: number;
|
26
26
|
planName: string;
|
@@ -31,9 +31,9 @@ export declare const JWT_TOKEN_PAYLOAD_SCHEMA: z.ZodObject<{
|
|
31
31
|
planId: number;
|
32
32
|
userTeamRole: "member" | "admin" | "biller" | "owner";
|
33
33
|
userEmail: string;
|
34
|
-
teamId: number;
|
35
34
|
userId: number;
|
36
35
|
userUuid: string;
|
36
|
+
teamId: number;
|
37
37
|
userName: string;
|
38
38
|
userCurrentTeamId: number;
|
39
39
|
planName: string;
|
@@ -4,22 +4,22 @@ export declare const createMockJwtTokenPayload: (overrides?: {
|
|
4
4
|
planId?: number | undefined;
|
5
5
|
userTeamRole?: "member" | "admin" | "biller" | "owner" | undefined;
|
6
6
|
userEmail?: string | undefined;
|
7
|
-
teamId?: number | undefined;
|
8
7
|
userId?: number | undefined;
|
9
8
|
userUuid?: string | undefined;
|
9
|
+
teamId?: number | undefined;
|
10
10
|
userName?: string | undefined;
|
11
11
|
userCurrentTeamId?: number | undefined;
|
12
12
|
planName?: string | undefined;
|
13
13
|
exp?: number | undefined;
|
14
|
-
} | undefined, removeProperties?: ("isProviderAlpha" | "isFullyAuthenticated" | "planId" | "userTeamRole" | "userEmail" | "
|
14
|
+
} | undefined, removeProperties?: ("isProviderAlpha" | "isFullyAuthenticated" | "planId" | "userTeamRole" | "userEmail" | "userId" | "userUuid" | "teamId" | "userName" | "userCurrentTeamId" | "planName" | "exp")[]) => {
|
15
15
|
isProviderAlpha: boolean;
|
16
16
|
isFullyAuthenticated: boolean;
|
17
17
|
planId: number;
|
18
18
|
userTeamRole: "member" | "admin" | "biller" | "owner";
|
19
19
|
userEmail: string;
|
20
|
-
teamId: number;
|
21
20
|
userId: number;
|
22
21
|
userUuid: string;
|
22
|
+
teamId: number;
|
23
23
|
userName: string;
|
24
24
|
userCurrentTeamId: number;
|
25
25
|
planName: string;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import {
|
2
|
-
export declare function makeAuthHeader(token: string):
|
1
|
+
import { UserTokenRequestHeader } from '../../../publicApi/types/userTokenTypes';
|
2
|
+
export declare function makeAuthHeader(token: string): UserTokenRequestHeader;
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { HeaderBuilder } from '../../core/headers/headerBuilder';
|
2
|
+
import { ContributorApiBaseHeader } from '../../../publicApi/types/contributorTypes';
|
1
3
|
import { Wretch } from 'wretch';
|
2
4
|
/**
|
3
5
|
* Uses the payload attached to the JWT to request the contributor information
|
@@ -5,9 +7,10 @@ import { Wretch } from 'wretch';
|
|
5
7
|
* This required an active JWT token to be present in the cookie.
|
6
8
|
*
|
7
9
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
10
|
+
* @param headers - The headers to attach to the request.
|
8
11
|
* @param projectId - The ID of the project to retrieve the contributor information.
|
9
12
|
*/
|
10
|
-
export declare function useAuthenticatedProjectContributor<T>(wretchClient: Wretch<T>, projectId: string): import('@tanstack/react-query').UseQueryResult<{
|
13
|
+
export declare function useAuthenticatedProjectContributor<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ContributorApiBaseHeader>, projectId: string): import('@tanstack/react-query').UseQueryResult<{
|
11
14
|
contributors: {
|
12
15
|
email: string;
|
13
16
|
user_id: number;
|
@@ -8,9 +8,9 @@ export declare function useAuthenticatedSessionPayload(): {
|
|
8
8
|
planId: number;
|
9
9
|
userTeamRole: "member" | "admin" | "biller" | "owner";
|
10
10
|
userEmail: string;
|
11
|
-
teamId: number;
|
12
11
|
userId: number;
|
13
12
|
userUuid: string;
|
13
|
+
teamId: number;
|
14
14
|
userName: string;
|
15
15
|
userCurrentTeamId: number;
|
16
16
|
planName: string;
|
@@ -1,11 +1,14 @@
|
|
1
|
+
import { HeaderBuilder } from '../../core/headers/headerBuilder';
|
2
|
+
import { TeamUserApiBaseHeaders } from '../../../publicApi/types/teamUserTypes';
|
1
3
|
import { Wretch } from 'wretch';
|
2
4
|
/**
|
3
5
|
* Uses the payload attached to the JWT to request the team-user information for the authenticated user.
|
4
6
|
* This required an active JWT token to be present in the cookie.
|
5
7
|
*
|
6
8
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
9
|
+
* @param headers - Headers to be attached to the request.
|
7
10
|
*/
|
8
|
-
export declare function useAuthenticatedUser<T>(wretchClient: Wretch<T>): import('@tanstack/react-query').UseQueryResult<{
|
11
|
+
export declare function useAuthenticatedUser<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<TeamUserApiBaseHeaders>): import('@tanstack/react-query').UseQueryResult<{
|
9
12
|
team_id: number;
|
10
13
|
team_user: {
|
11
14
|
role: "member" | "admin" | "biller" | "owner";
|
package/dist/types/src/features/auth/frontend/hooks/useGetPromotedClassicSessionJwtQuery.d.ts
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
import { HeaderBuilder } from '../../core/headers/headerBuilder';
|
1
2
|
import { Wretch } from 'wretch';
|
2
3
|
/**
|
3
4
|
* For use in environments that are authenticated with a classic CSRF PHP session (e.g. Expert).
|
4
5
|
* This hook will send that token to the public API, upgrade to a JWT session.
|
5
6
|
*
|
6
7
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
8
|
+
* @param headers - The headers to send with the request.
|
7
9
|
* @param teamId - The team ID to get the JWT for.
|
8
10
|
*/
|
9
|
-
export declare function useGetPromotedClassicSessionJwtQuery<T>(wretchClient: Wretch<T>, teamId: number): import('@tanstack/react-query').UseQueryResult<{
|
11
|
+
export declare function useGetPromotedClassicSessionJwtQuery<T>(wretchClient: Wretch<T>, headers: HeaderBuilder, teamId: number): import('@tanstack/react-query').UseQueryResult<{
|
10
12
|
accessToken: string;
|
11
13
|
refreshToken: string;
|
12
|
-
}, undefined>;
|
14
|
+
} | null, undefined>;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
export declare function generateTokenFromClassicSession<T>(authenticationProvider: Wretch<T>, getCsrfToken: () => string | null, getTeamId: () => Promise<string>): () => Promise<{
|
3
|
+
accessToken: string;
|
4
|
+
refreshToken: string;
|
5
|
+
} | null>;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
2
|
+
import { Wretch } from 'wretch';
|
3
|
+
export declare function refreshExpiredToken<T>(authenticationProvider: Wretch<T>, getTeamId: () => Promise<string>): ({ refreshToken }: JwtToken) => Promise<{
|
4
|
+
accessToken: string;
|
5
|
+
refreshToken: string;
|
6
|
+
} | null>;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { JwtToken } from '../../../publicApi/types/userTokenTypes';
|
2
|
-
export declare function getJwtTokenFromCookie(): JwtToken |
|
3
|
-
export declare function getCsrfTokenFromCookie(): string |
|
2
|
+
export declare function getJwtTokenFromCookie(): JwtToken | null;
|
3
|
+
export declare function getCsrfTokenFromCookie(): string | null;
|
4
4
|
export declare function getCookie(cookies: string, name: string): string | undefined;
|
@@ -1,11 +1,14 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export { clientSideJwtAuthMiddleware } from './frontend/middleware/clientSideJwtAuthMiddleware';
|
4
|
-
export { promoteClassicSessionToJwtMiddleware } from './frontend/middleware/promoteClassicSessionToJwtMiddleware';
|
1
|
+
export { JwtAuthHeaderBuilderMiddleware, type JwtAuthHeaderBuilderMiddlewareProps, } from './core/middleware/jwtAuthHeaderBuilderMiddleware';
|
2
|
+
export { PublicApiHeaderBuilderMiddleware } from './core/middleware/publicApiHeaderBuilderMiddleware';
|
5
3
|
export type { JwtTokenPayload } from './core/types/jwtTokenPayload';
|
6
4
|
export { parseJwtTokenPayload } from './core/utils/jwtTokenPayload';
|
5
|
+
export { getJwtTokenFromCookie, getCsrfTokenFromCookie } from './frontend/utils/cookieTokenUtils';
|
6
|
+
export { HeaderBuilder, type Headers, } from './core/headers/headerBuilder';
|
7
7
|
export * from './backend/services/getAuthenticatedSessionDetailFromRequest';
|
8
|
+
export * from './frontend/services/generateTokenFromClassicSession';
|
9
|
+
export * from './frontend/services/refreshExpiredToken';
|
8
10
|
export * from './frontend/hooks/useGetPromotedClassicSessionJwtQuery';
|
9
11
|
export * from './frontend/hooks/useAuthenticatedSessionPayload';
|
10
12
|
export * from './frontend/hooks/useAuthenticatedUser';
|
11
13
|
export * from './frontend/hooks/useAuthenticatedProjectContributor';
|
14
|
+
export { createHeaderBuilderMiddleware, type HeaderBuilderMiddleware, } from './core/headers/createHeaderBuilderMiddleware';
|
@@ -108,4 +108,22 @@ export declare const retrieveContributor: import('@lokalise/universal-ts-utils/n
|
|
108
108
|
}, {
|
109
109
|
projectId: string;
|
110
110
|
contributorId: number;
|
111
|
-
}>, undefined,
|
111
|
+
}>, undefined, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
112
|
+
Authorization: z.ZodString;
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
114
|
+
Authorization: string;
|
115
|
+
}, {
|
116
|
+
Authorization: string;
|
117
|
+
}>, z.ZodObject<{
|
118
|
+
'X-API-Token': z.ZodString;
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
120
|
+
'X-API-Token': string;
|
121
|
+
}, {
|
122
|
+
'X-API-Token': string;
|
123
|
+
}>]>, z.ZodObject<{
|
124
|
+
'X-Lokalise-Plugin': z.ZodString;
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
126
|
+
'X-Lokalise-Plugin': string;
|
127
|
+
}, {
|
128
|
+
'X-Lokalise-Plugin': string;
|
129
|
+
}>>, false, false>;
|
@@ -1,13 +1,15 @@
|
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
1
2
|
import { ApiMutationOverrides } from '../../../utils/types/apiMutationOverrides';
|
2
3
|
import { Wretch } from 'wretch';
|
3
|
-
import { CreateProjectRequestBody, Project } from '../types/projectTypes';
|
4
|
+
import { CreateProjectRequestBody, Project, ProjectApiBaseHeaders } from '../types/projectTypes';
|
4
5
|
/**
|
5
6
|
* A react-router wrapper about the createProject public API endpoint
|
6
7
|
*
|
7
8
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
9
|
+
* @param headers - A header builder instance to resolve the headers for the request.
|
8
10
|
* @param overrides - Additional options to pass to the query.
|
9
11
|
*/
|
10
|
-
export declare function useCreateProjectMutation<T>(wretchClient: Wretch<T>, overrides?: ApiMutationOverrides<Project, CreateProjectRequestBody>): import('@tanstack/react-query').UseMutationResult<{
|
12
|
+
export declare function useCreateProjectMutation<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ProjectApiBaseHeaders>, overrides?: ApiMutationOverrides<Project, CreateProjectRequestBody>): import('@tanstack/react-query').UseMutationResult<{
|
11
13
|
name: string;
|
12
14
|
created_at: string;
|
13
15
|
created_at_timestamp: number;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
2
|
+
import { TeamUserApiBaseHeaders, TeamUserResponse } from '../types/teamUserTypes';
|
2
3
|
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
3
4
|
import { Wretch } from 'wretch/types';
|
4
5
|
/**
|
@@ -11,9 +12,10 @@ export declare const getTeamUsersQueryKey: {
|
|
11
12
|
* A react-router wrapper about the getTeamUser public API endpoint
|
12
13
|
*
|
13
14
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
15
|
+
* @param headers - Instance of the header builder for the public API.
|
14
16
|
* @param overrides - Additional options to pass to the query.
|
15
17
|
*/
|
16
|
-
export declare const useGetTeamUsersQuery: <T>(wretchClient: Wretch<T>, overrides: ApiQueryOverrides<TeamUserResponse, typeof getTeamUsersQueryKey>) => import('@tanstack/react-query').UseQueryResult<{
|
18
|
+
export declare const useGetTeamUsersQuery: <T>(wretchClient: Wretch<T>, headers: HeaderBuilder<TeamUserApiBaseHeaders>, overrides: ApiQueryOverrides<TeamUserResponse, typeof getTeamUsersQueryKey>) => import('@tanstack/react-query').UseQueryResult<{
|
17
19
|
team_id: number;
|
18
20
|
team_user: {
|
19
21
|
role: "member" | "admin" | "biller" | "owner";
|
@@ -1,20 +1,21 @@
|
|
1
|
-
import {
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
2
|
+
import { JwtToken, UserTokenRequestHeader } from '../types/userTokenTypes';
|
2
3
|
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
3
4
|
import { Wretch } from 'wretch/types';
|
4
5
|
/**
|
5
6
|
* Factory for generating keys for the getUserToken public API endpoint
|
6
7
|
*/
|
7
8
|
export declare const getUserTokenKey: {
|
8
|
-
|
9
|
-
teamKeyJwt: (teamId: number, refreshToken: string) => readonly ["getUserToken", "Authorization", `Bearer ${string}`, number];
|
9
|
+
teamKey: (teamId: number) => readonly ["getUserToken", number];
|
10
10
|
};
|
11
11
|
/**
|
12
12
|
* A react-router wrapper about the getUserToken public API endpoint
|
13
13
|
*
|
14
14
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
15
|
+
* @param headers - HeaderBuilder instance to resolve headers for the request.
|
15
16
|
* @param overrides - Additional options to pass to the query.
|
16
17
|
*/
|
17
|
-
export declare const useGetUserTokenQuery: <T>(wretchClient: Wretch<T>, overrides: ApiQueryOverrides<JwtToken, typeof getUserTokenKey>) => import('@tanstack/react-query').UseQueryResult<{
|
18
|
+
export declare const useGetUserTokenQuery: <T>(wretchClient: Wretch<T>, headers: HeaderBuilder<UserTokenRequestHeader>, overrides: ApiQueryOverrides<JwtToken | null, typeof getUserTokenKey>) => import('@tanstack/react-query').UseQueryResult<{
|
18
19
|
accessToken: string;
|
19
20
|
refreshToken: string;
|
20
|
-
}, undefined>;
|
21
|
+
} | null, undefined>;
|
@@ -1,10 +1,19 @@
|
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
1
2
|
import { ListProjectLanguagesResponse } from '../types/languageTypes';
|
3
|
+
import { ProjectApiBaseHeaders } from '../types/projectTypes';
|
2
4
|
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
3
5
|
import { Wretch } from 'wretch/types';
|
4
6
|
export declare const listProjectLanguagesKey: {
|
5
7
|
projectIdKey: (projectId: string) => readonly ["listProjectLanguages", string];
|
6
8
|
};
|
7
|
-
|
9
|
+
/**
|
10
|
+
* A react-router wrapper about the listProjectLanguages public API endpoint
|
11
|
+
*
|
12
|
+
* @param wretchClient - Wretch instance configured to a public API instance.
|
13
|
+
* @param headers - A header builder instance to resolve the headers for the request.
|
14
|
+
* @param overrides - Additional options to pass to the query.
|
15
|
+
*/
|
16
|
+
export declare function useListProjectLanguagesQuery<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ProjectApiBaseHeaders>, overrides: ApiQueryOverrides<ListProjectLanguagesResponse, typeof listProjectLanguagesKey>): import('@tanstack/react-query').UseQueryResult<{
|
8
17
|
languages: {
|
9
18
|
lang_id: number;
|
10
19
|
lang_iso: string;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
2
|
+
import { ListProjectsRequestQuery, ListProjectsSuccessResponseBody, ProjectApiBaseHeaders } from '../types/projectTypes';
|
2
3
|
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
3
4
|
import { Wretch } from 'wretch';
|
4
5
|
/**
|
@@ -19,9 +20,10 @@ export declare const listProjectsKey: {
|
|
19
20
|
* A react-router wrapper about the listProjects public API endpoint
|
20
21
|
*
|
21
22
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
23
|
+
* @param headers - A header builder instance to resolve the headers.
|
22
24
|
* @param overrides - Additional options to pass to the query.
|
23
25
|
*/
|
24
|
-
export declare function useListProjectsQuery<T>(wretchClient: Wretch<T>, overrides: ApiQueryOverrides<ListProjectsSuccessResponseBody, typeof listProjectsKey>): import('@tanstack/react-query').UseQueryResult<{
|
26
|
+
export declare function useListProjectsQuery<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ProjectApiBaseHeaders>, overrides: ApiQueryOverrides<ListProjectsSuccessResponseBody, typeof listProjectsKey>): import('@tanstack/react-query').UseQueryResult<{
|
25
27
|
projects: {
|
26
28
|
name: string;
|
27
29
|
created_at: string;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
2
|
+
import { ContributorApiBaseHeader, RetrieveContributorsResponse } from '../types/contributorTypes';
|
2
3
|
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
3
4
|
import { Wretch } from 'wretch';
|
4
5
|
/**
|
@@ -11,9 +12,10 @@ export declare const retrieveContributorKeys: {
|
|
11
12
|
* A react-router wrapper about the retrieveContributor public API endpoint
|
12
13
|
*
|
13
14
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
15
|
+
* @param headers - A header builder instance to resolve headers for the request.
|
14
16
|
* @param overrides - Additional options to pass to the query.
|
15
17
|
*/
|
16
|
-
export declare const useRetrieveContributorQuery: <T>(wretchClient: Wretch<T>, overrides: ApiQueryOverrides<RetrieveContributorsResponse, typeof retrieveContributorKeys>) => import('@tanstack/react-query').UseQueryResult<{
|
18
|
+
export declare const useRetrieveContributorQuery: <T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ContributorApiBaseHeader>, overrides: ApiQueryOverrides<RetrieveContributorsResponse, typeof retrieveContributorKeys>) => import('@tanstack/react-query').UseQueryResult<{
|
17
19
|
contributors: {
|
18
20
|
email: string;
|
19
21
|
user_id: number;
|
@@ -1,6 +1,7 @@
|
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
1
2
|
import { ApiQueryOverrides } from '../../../utils/types/apiQueryOverrides';
|
2
3
|
import { Wretch } from 'wretch';
|
3
|
-
import { Project } from '../types/projectTypes';
|
4
|
+
import { Project, ProjectApiBaseHeaders } from '../types/projectTypes';
|
4
5
|
/**
|
5
6
|
* Factory function to create the query key for the retrieveProject query
|
6
7
|
*/
|
@@ -11,9 +12,10 @@ export declare const retrieveProjectQueryKey: {
|
|
11
12
|
* A react-router wrapper about the retrieveProject public API endpoint
|
12
13
|
*
|
13
14
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
15
|
+
* @param headers - A header builder instance to resolve the headers for the request.
|
14
16
|
* @param overrides - Additional options to pass to the query.
|
15
17
|
*/
|
16
|
-
export declare function useRetrieveProjectQuery<T>(wretchClient: Wretch<T>, overrides: ApiQueryOverrides<Project, typeof retrieveProjectQueryKey>): import('@tanstack/react-query').UseQueryResult<{
|
18
|
+
export declare function useRetrieveProjectQuery<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ProjectApiBaseHeaders>, overrides: ApiQueryOverrides<Project, typeof retrieveProjectQueryKey>): import('@tanstack/react-query').UseQueryResult<{
|
17
19
|
name: string;
|
18
20
|
created_at: string;
|
19
21
|
created_at_timestamp: number;
|
@@ -1,14 +1,16 @@
|
|
1
|
+
import { HeaderBuilder } from '../../auth/core/headers/headerBuilder';
|
1
2
|
import { ApiMutationOverrides } from '../../../utils/types/apiMutationOverrides';
|
2
3
|
import { Wretch } from 'wretch';
|
3
|
-
import { Project, UpdateProjectPathParams, UpdateProjectRequestBody } from '../types/projectTypes';
|
4
|
+
import { Project, ProjectApiBaseHeaders, UpdateProjectPathParams, UpdateProjectRequestBody } from '../types/projectTypes';
|
4
5
|
/**
|
5
6
|
* A react-query wrapper about the updateProject public API endpoint
|
6
7
|
*
|
7
8
|
* @param wretchClient - Wretch instance configured to a public API instance.
|
9
|
+
* @param headers - Headers to include in the request.
|
8
10
|
* @param params - URL parameters
|
9
11
|
* @param overrides - Additional options to pass to the query.
|
10
12
|
*/
|
11
|
-
export declare function useUpdateProjectMutation<T>(wretchClient: Wretch<T>, params: UpdateProjectPathParams, overrides?: ApiMutationOverrides<Project, UpdateProjectRequestBody>): import('@tanstack/react-query').UseMutationResult<{
|
13
|
+
export declare function useUpdateProjectMutation<T>(wretchClient: Wretch<T>, headers: HeaderBuilder<ProjectApiBaseHeaders>, params: UpdateProjectPathParams, overrides?: ApiMutationOverrides<Project, UpdateProjectRequestBody>): import('@tanstack/react-query').UseMutationResult<{
|
12
14
|
name: string;
|
13
15
|
created_at: string;
|
14
16
|
created_at_timestamp: number;
|
@@ -48,4 +48,22 @@ export declare const listProjectLanguages: import('@lokalise/universal-ts-utils/
|
|
48
48
|
projectId: string;
|
49
49
|
}, {
|
50
50
|
projectId: string;
|
51
|
-
}>, undefined,
|
51
|
+
}>, undefined, import('zod').ZodIntersection<import('zod').ZodUnion<[import('zod').ZodObject<{
|
52
|
+
Authorization: import('zod').ZodString;
|
53
|
+
}, "strip", import('zod').ZodTypeAny, {
|
54
|
+
Authorization: string;
|
55
|
+
}, {
|
56
|
+
Authorization: string;
|
57
|
+
}>, import('zod').ZodObject<{
|
58
|
+
'X-API-Token': import('zod').ZodString;
|
59
|
+
}, "strip", import('zod').ZodTypeAny, {
|
60
|
+
'X-API-Token': string;
|
61
|
+
}, {
|
62
|
+
'X-API-Token': string;
|
63
|
+
}>]>, import('zod').ZodObject<{
|
64
|
+
'X-Lokalise-Plugin': import('zod').ZodString;
|
65
|
+
}, "strip", import('zod').ZodTypeAny, {
|
66
|
+
'X-Lokalise-Plugin': string;
|
67
|
+
}, {
|
68
|
+
'X-Lokalise-Plugin': string;
|
69
|
+
}>>, false, false>;
|
@@ -8,7 +8,7 @@ export type { Project, ProjectQaIssues, ProjectType, ProjectSettings } from './t
|
|
8
8
|
export type { TeamRole } from './types/teamRoleTypes';
|
9
9
|
export type { Contributor, ContributorLanguage } from './types/contributorTypes';
|
10
10
|
export type { TeamUser } from './types/teamUserTypes';
|
11
|
-
export type {
|
11
|
+
export type { UserTokenRequestHeader, JwtToken } from './types/userTokenTypes';
|
12
12
|
export * from './hooks/useCreateProjectMutation';
|
13
13
|
export * from './hooks/useGetTeamUsersQuery';
|
14
14
|
export * from './hooks/useGetUserTokenQuery';
|