@lokalise/harmony 1.5.6 → 1.6.0-exp-jwtutils.2
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/dist/harmony.cjs +1 -1
- package/dist/harmony.mjs +685 -452
- package/dist/types/src/features/auth/core/jwtAuthAddon.d.ts +6 -0
- package/dist/types/src/features/auth/core/jwtTokenPayload.d.ts +48 -0
- package/dist/types/src/features/auth/core/jwtTokenPayload.test.d.ts +1 -0
- package/dist/types/src/features/auth/core/middleware/jwtAuthMiddleware.d.ts +7 -0
- package/dist/types/src/features/auth/core/middleware/jwtAuthMiddleware.test.d.ts +1 -0
- package/dist/types/src/features/auth/core/service/authService.d.ts +40 -0
- package/dist/types/src/features/auth/core/service/contributors.d.ts +205 -0
- package/dist/types/src/features/auth/core/service/teamUsersService.d.ts +128 -0
- package/dist/types/src/features/auth/core/types/teamRole.d.ts +3 -0
- package/dist/types/src/features/auth/core/utils/makeAuthHeader.d.ts +3 -0
- package/dist/types/src/features/auth/core/utils/makeAuthHeader.test.d.ts +1 -0
- package/dist/types/src/features/auth/frontend/addon/browserJwtAuthAddon.d.ts +15 -0
- package/dist/types/src/features/auth/frontend/events/NewJwtIssuedEvent.d.ts +17 -0
- package/dist/types/src/features/auth/frontend/hooks/services/useGetUserTokenQuery.d.ts +10 -0
- package/dist/types/src/features/auth/frontend/hooks/services/useRetrieveContributorQuery.d.ts +25 -0
- package/dist/types/src/features/auth/frontend/hooks/services/userGetTeamUsersQuery.d.ts +17 -0
- package/dist/types/src/features/auth/frontend/hooks/utility/useAuthenticatedProjectContributor.d.ts +23 -0
- package/dist/types/src/features/auth/frontend/hooks/utility/useAuthenticatedUser.d.ts +15 -0
- package/dist/types/src/features/auth/frontend/hooks/utility/useGetPromotedClassicSessionJwtQuery.d.ts +8 -0
- package/dist/types/src/features/auth/frontend/hooks/utility/useJwtTokenPayload.d.ts +16 -0
- package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.d.ts +6 -0
- package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.test.d.ts +1 -0
- package/dist/types/src/features/auth/frontend/utils/cookieToken.d.ts +2 -0
- package/dist/types/src/features/auth/frontend/utils/tokenStorage.d.ts +7 -0
- package/dist/types/src/node.d.ts +15 -0
- package/dist/types/src/utils/types/apiQueryOverrides.d.ts +2 -0
- package/dist/types/tests/utils.d.ts +6 -1
- package/package.json +14 -3
@@ -0,0 +1,6 @@
|
|
1
|
+
import { Wretch, WretchAddon } from 'wretch/types';
|
2
|
+
import { JwtAuthProps } from './middleware/jwtAuthMiddleware';
|
3
|
+
export interface JwtAuthAddonInterface {
|
4
|
+
jwtAuth<T extends JwtAuthAddonInterface>(this: T & Wretch<T>, props: JwtAuthProps): this;
|
5
|
+
}
|
6
|
+
export declare const JwtAuthAddon: WretchAddon<JwtAuthAddonInterface>;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
export declare const JWT_TOKEN_PAYLOAD_SCHEMA: z.ZodObject<{
|
3
|
+
userId: z.ZodNumber;
|
4
|
+
teamId: z.ZodNumber;
|
5
|
+
userTeamRole: z.ZodUnion<[z.ZodLiteral<"owner">, z.ZodLiteral<"admin">, z.ZodLiteral<"biller">, z.ZodLiteral<"member">]>;
|
6
|
+
userEmail: z.ZodString;
|
7
|
+
userCurrentTeamId: z.ZodNumber;
|
8
|
+
planId: z.ZodNumber;
|
9
|
+
planName: z.ZodString;
|
10
|
+
isProviderAlpha: z.ZodBoolean;
|
11
|
+
isFullyAuthenticated: z.ZodBoolean;
|
12
|
+
exp: z.ZodNumber;
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
14
|
+
isProviderAlpha: boolean;
|
15
|
+
planId: number;
|
16
|
+
userEmail: string;
|
17
|
+
userId: number;
|
18
|
+
teamId: number;
|
19
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
20
|
+
userCurrentTeamId: number;
|
21
|
+
planName: string;
|
22
|
+
isFullyAuthenticated: boolean;
|
23
|
+
exp: number;
|
24
|
+
}, {
|
25
|
+
isProviderAlpha: boolean;
|
26
|
+
planId: number;
|
27
|
+
userEmail: string;
|
28
|
+
userId: number;
|
29
|
+
teamId: number;
|
30
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
31
|
+
userCurrentTeamId: number;
|
32
|
+
planName: string;
|
33
|
+
isFullyAuthenticated: boolean;
|
34
|
+
exp: number;
|
35
|
+
}>;
|
36
|
+
export type JwtTokenPayload = z.infer<typeof JWT_TOKEN_PAYLOAD_SCHEMA>;
|
37
|
+
export declare function parseJwtTokenPayload(token: string): {
|
38
|
+
isProviderAlpha: boolean;
|
39
|
+
planId: number;
|
40
|
+
userEmail: string;
|
41
|
+
userId: number;
|
42
|
+
teamId: number;
|
43
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
44
|
+
userCurrentTeamId: number;
|
45
|
+
planName: string;
|
46
|
+
isFullyAuthenticated: boolean;
|
47
|
+
exp: number;
|
48
|
+
} | undefined;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ConfiguredMiddleware, Wretch } from 'wretch';
|
2
|
+
import { JwtToken } from '../service/authService';
|
3
|
+
export type JwtAuthProps = {
|
4
|
+
getCachedJwtToken: () => Promise<JwtToken | undefined>;
|
5
|
+
onNewJwtTokenIssued?: (jwtToken: JwtToken) => Promise<void>;
|
6
|
+
};
|
7
|
+
export declare function jwtAuthMiddleware<T>(client: Wretch<T>, props: JwtAuthProps): ConfiguredMiddleware;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
export declare const JWT_TOKEN_SCHEMA: z.ZodObject<{
|
3
|
+
accessToken: z.ZodString;
|
4
|
+
refreshToken: z.ZodString;
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
6
|
+
accessToken: string;
|
7
|
+
refreshToken: string;
|
8
|
+
}, {
|
9
|
+
accessToken: string;
|
10
|
+
refreshToken: string;
|
11
|
+
}>;
|
12
|
+
export type JwtToken = z.infer<typeof JWT_TOKEN_SCHEMA>;
|
13
|
+
/**
|
14
|
+
* A method of getting a JWT token for a user.
|
15
|
+
* You can call this with either a refresh token or from within the scope of a classic CSRF cookie session.
|
16
|
+
*/
|
17
|
+
export declare const getUserToken: import('@lokalise/universal-ts-utils/node').PayloadRouteDefinition<{
|
18
|
+
teamId: number;
|
19
|
+
}, z.ZodUndefined, z.ZodObject<{
|
20
|
+
accessToken: z.ZodString;
|
21
|
+
refreshToken: z.ZodString;
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
23
|
+
accessToken: string;
|
24
|
+
refreshToken: string;
|
25
|
+
}, {
|
26
|
+
accessToken: string;
|
27
|
+
refreshToken: string;
|
28
|
+
}>, z.ZodObject<{
|
29
|
+
teamId: z.ZodNumber;
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
31
|
+
teamId: number;
|
32
|
+
}, {
|
33
|
+
teamId: number;
|
34
|
+
}>, undefined, z.ZodObject<{
|
35
|
+
Authorization: z.ZodOptional<z.ZodString>;
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
37
|
+
Authorization?: string | undefined;
|
38
|
+
}, {
|
39
|
+
Authorization?: string | undefined;
|
40
|
+
}>, false, false>;
|
@@ -0,0 +1,205 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
declare const RETRIEVE_CONTRIBUTORS_RESPONSE_SCHEMA: z.ZodObject<{
|
3
|
+
project_id: z.ZodString;
|
4
|
+
contributors: z.ZodArray<z.ZodObject<{
|
5
|
+
user_id: z.ZodNumber;
|
6
|
+
email: z.ZodString;
|
7
|
+
fullname: z.ZodString;
|
8
|
+
created_at: z.ZodString;
|
9
|
+
created_at_timestamp: z.ZodNumber;
|
10
|
+
admin_rights: z.ZodArray<z.ZodString, "many">;
|
11
|
+
languages: z.ZodArray<z.ZodObject<{
|
12
|
+
lang_id: z.ZodNumber;
|
13
|
+
lang_iso: z.ZodString;
|
14
|
+
lang_name: z.ZodString;
|
15
|
+
is_writable: z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>;
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
17
|
+
lang_id: number;
|
18
|
+
lang_iso: string;
|
19
|
+
lang_name: string;
|
20
|
+
is_writable: 0 | 1;
|
21
|
+
}, {
|
22
|
+
lang_id: number;
|
23
|
+
lang_iso: string;
|
24
|
+
lang_name: string;
|
25
|
+
is_writable: 0 | 1;
|
26
|
+
}>, "many">;
|
27
|
+
is_admin: z.ZodBoolean;
|
28
|
+
is_reviewer: z.ZodBoolean;
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
30
|
+
email: string;
|
31
|
+
user_id: number;
|
32
|
+
fullname: string;
|
33
|
+
created_at: string;
|
34
|
+
created_at_timestamp: number;
|
35
|
+
admin_rights: string[];
|
36
|
+
languages: {
|
37
|
+
lang_id: number;
|
38
|
+
lang_iso: string;
|
39
|
+
lang_name: string;
|
40
|
+
is_writable: 0 | 1;
|
41
|
+
}[];
|
42
|
+
is_admin: boolean;
|
43
|
+
is_reviewer: boolean;
|
44
|
+
}, {
|
45
|
+
email: string;
|
46
|
+
user_id: number;
|
47
|
+
fullname: string;
|
48
|
+
created_at: string;
|
49
|
+
created_at_timestamp: number;
|
50
|
+
admin_rights: string[];
|
51
|
+
languages: {
|
52
|
+
lang_id: number;
|
53
|
+
lang_iso: string;
|
54
|
+
lang_name: string;
|
55
|
+
is_writable: 0 | 1;
|
56
|
+
}[];
|
57
|
+
is_admin: boolean;
|
58
|
+
is_reviewer: boolean;
|
59
|
+
}>, "many">;
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
61
|
+
contributors: {
|
62
|
+
email: string;
|
63
|
+
user_id: number;
|
64
|
+
fullname: string;
|
65
|
+
created_at: string;
|
66
|
+
created_at_timestamp: number;
|
67
|
+
admin_rights: string[];
|
68
|
+
languages: {
|
69
|
+
lang_id: number;
|
70
|
+
lang_iso: string;
|
71
|
+
lang_name: string;
|
72
|
+
is_writable: 0 | 1;
|
73
|
+
}[];
|
74
|
+
is_admin: boolean;
|
75
|
+
is_reviewer: boolean;
|
76
|
+
}[];
|
77
|
+
project_id: string;
|
78
|
+
}, {
|
79
|
+
contributors: {
|
80
|
+
email: string;
|
81
|
+
user_id: number;
|
82
|
+
fullname: string;
|
83
|
+
created_at: string;
|
84
|
+
created_at_timestamp: number;
|
85
|
+
admin_rights: string[];
|
86
|
+
languages: {
|
87
|
+
lang_id: number;
|
88
|
+
lang_iso: string;
|
89
|
+
lang_name: string;
|
90
|
+
is_writable: 0 | 1;
|
91
|
+
}[];
|
92
|
+
is_admin: boolean;
|
93
|
+
is_reviewer: boolean;
|
94
|
+
}[];
|
95
|
+
project_id: string;
|
96
|
+
}>;
|
97
|
+
export type RetrieveContributorsResponse = z.infer<typeof RETRIEVE_CONTRIBUTORS_RESPONSE_SCHEMA>;
|
98
|
+
export declare const retrieveContributor: import('@lokalise/universal-ts-utils/node').GetRouteDefinition<{
|
99
|
+
projectId: string;
|
100
|
+
contributorId: number;
|
101
|
+
}, z.ZodObject<{
|
102
|
+
project_id: z.ZodString;
|
103
|
+
contributors: z.ZodArray<z.ZodObject<{
|
104
|
+
user_id: z.ZodNumber;
|
105
|
+
email: z.ZodString;
|
106
|
+
fullname: z.ZodString;
|
107
|
+
created_at: z.ZodString;
|
108
|
+
created_at_timestamp: z.ZodNumber;
|
109
|
+
admin_rights: z.ZodArray<z.ZodString, "many">;
|
110
|
+
languages: z.ZodArray<z.ZodObject<{
|
111
|
+
lang_id: z.ZodNumber;
|
112
|
+
lang_iso: z.ZodString;
|
113
|
+
lang_name: z.ZodString;
|
114
|
+
is_writable: z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>;
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
116
|
+
lang_id: number;
|
117
|
+
lang_iso: string;
|
118
|
+
lang_name: string;
|
119
|
+
is_writable: 0 | 1;
|
120
|
+
}, {
|
121
|
+
lang_id: number;
|
122
|
+
lang_iso: string;
|
123
|
+
lang_name: string;
|
124
|
+
is_writable: 0 | 1;
|
125
|
+
}>, "many">;
|
126
|
+
is_admin: z.ZodBoolean;
|
127
|
+
is_reviewer: z.ZodBoolean;
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
129
|
+
email: string;
|
130
|
+
user_id: number;
|
131
|
+
fullname: string;
|
132
|
+
created_at: string;
|
133
|
+
created_at_timestamp: number;
|
134
|
+
admin_rights: string[];
|
135
|
+
languages: {
|
136
|
+
lang_id: number;
|
137
|
+
lang_iso: string;
|
138
|
+
lang_name: string;
|
139
|
+
is_writable: 0 | 1;
|
140
|
+
}[];
|
141
|
+
is_admin: boolean;
|
142
|
+
is_reviewer: boolean;
|
143
|
+
}, {
|
144
|
+
email: string;
|
145
|
+
user_id: number;
|
146
|
+
fullname: string;
|
147
|
+
created_at: string;
|
148
|
+
created_at_timestamp: number;
|
149
|
+
admin_rights: string[];
|
150
|
+
languages: {
|
151
|
+
lang_id: number;
|
152
|
+
lang_iso: string;
|
153
|
+
lang_name: string;
|
154
|
+
is_writable: 0 | 1;
|
155
|
+
}[];
|
156
|
+
is_admin: boolean;
|
157
|
+
is_reviewer: boolean;
|
158
|
+
}>, "many">;
|
159
|
+
}, "strip", z.ZodTypeAny, {
|
160
|
+
contributors: {
|
161
|
+
email: string;
|
162
|
+
user_id: number;
|
163
|
+
fullname: string;
|
164
|
+
created_at: string;
|
165
|
+
created_at_timestamp: number;
|
166
|
+
admin_rights: string[];
|
167
|
+
languages: {
|
168
|
+
lang_id: number;
|
169
|
+
lang_iso: string;
|
170
|
+
lang_name: string;
|
171
|
+
is_writable: 0 | 1;
|
172
|
+
}[];
|
173
|
+
is_admin: boolean;
|
174
|
+
is_reviewer: boolean;
|
175
|
+
}[];
|
176
|
+
project_id: string;
|
177
|
+
}, {
|
178
|
+
contributors: {
|
179
|
+
email: string;
|
180
|
+
user_id: number;
|
181
|
+
fullname: string;
|
182
|
+
created_at: string;
|
183
|
+
created_at_timestamp: number;
|
184
|
+
admin_rights: string[];
|
185
|
+
languages: {
|
186
|
+
lang_id: number;
|
187
|
+
lang_iso: string;
|
188
|
+
lang_name: string;
|
189
|
+
is_writable: 0 | 1;
|
190
|
+
}[];
|
191
|
+
is_admin: boolean;
|
192
|
+
is_reviewer: boolean;
|
193
|
+
}[];
|
194
|
+
project_id: string;
|
195
|
+
}>, z.ZodObject<{
|
196
|
+
projectId: z.ZodString;
|
197
|
+
contributorId: z.ZodNumber;
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
199
|
+
projectId: string;
|
200
|
+
contributorId: number;
|
201
|
+
}, {
|
202
|
+
projectId: string;
|
203
|
+
contributorId: number;
|
204
|
+
}>, undefined, undefined, false, false>;
|
205
|
+
export {};
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import { z } from 'zod';
|
2
|
+
export declare const TEAM_USER_SCHEMA: z.ZodObject<{
|
3
|
+
user_id: z.ZodNumber;
|
4
|
+
email: z.ZodString;
|
5
|
+
fullname: z.ZodString;
|
6
|
+
created_at: z.ZodString;
|
7
|
+
created_at_timestamp: z.ZodNumber;
|
8
|
+
role: z.ZodUnion<[z.ZodLiteral<"owner">, z.ZodLiteral<"admin">, z.ZodLiteral<"biller">, z.ZodLiteral<"member">]>;
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
10
|
+
role: "member" | "admin" | "biller" | "owner";
|
11
|
+
email: string;
|
12
|
+
user_id: number;
|
13
|
+
fullname: string;
|
14
|
+
created_at: string;
|
15
|
+
created_at_timestamp: number;
|
16
|
+
}, {
|
17
|
+
role: "member" | "admin" | "biller" | "owner";
|
18
|
+
email: string;
|
19
|
+
user_id: number;
|
20
|
+
fullname: string;
|
21
|
+
created_at: string;
|
22
|
+
created_at_timestamp: number;
|
23
|
+
}>;
|
24
|
+
export type TeamUser = z.infer<typeof TEAM_USER_SCHEMA>;
|
25
|
+
declare const TEAM_USER_RESPONSE_SCHEMA: z.ZodObject<{
|
26
|
+
team_id: z.ZodNumber;
|
27
|
+
team_user: z.ZodObject<{
|
28
|
+
user_id: z.ZodNumber;
|
29
|
+
email: z.ZodString;
|
30
|
+
fullname: z.ZodString;
|
31
|
+
created_at: z.ZodString;
|
32
|
+
created_at_timestamp: z.ZodNumber;
|
33
|
+
role: z.ZodUnion<[z.ZodLiteral<"owner">, z.ZodLiteral<"admin">, z.ZodLiteral<"biller">, z.ZodLiteral<"member">]>;
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
35
|
+
role: "member" | "admin" | "biller" | "owner";
|
36
|
+
email: string;
|
37
|
+
user_id: number;
|
38
|
+
fullname: string;
|
39
|
+
created_at: string;
|
40
|
+
created_at_timestamp: number;
|
41
|
+
}, {
|
42
|
+
role: "member" | "admin" | "biller" | "owner";
|
43
|
+
email: string;
|
44
|
+
user_id: number;
|
45
|
+
fullname: string;
|
46
|
+
created_at: string;
|
47
|
+
created_at_timestamp: number;
|
48
|
+
}>;
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
50
|
+
team_id: number;
|
51
|
+
team_user: {
|
52
|
+
role: "member" | "admin" | "biller" | "owner";
|
53
|
+
email: string;
|
54
|
+
user_id: number;
|
55
|
+
fullname: string;
|
56
|
+
created_at: string;
|
57
|
+
created_at_timestamp: number;
|
58
|
+
};
|
59
|
+
}, {
|
60
|
+
team_id: number;
|
61
|
+
team_user: {
|
62
|
+
role: "member" | "admin" | "biller" | "owner";
|
63
|
+
email: string;
|
64
|
+
user_id: number;
|
65
|
+
fullname: string;
|
66
|
+
created_at: string;
|
67
|
+
created_at_timestamp: number;
|
68
|
+
};
|
69
|
+
}>;
|
70
|
+
export type TeamUserResponse = z.infer<typeof TEAM_USER_RESPONSE_SCHEMA>;
|
71
|
+
export declare const getTeamUser: import('@lokalise/universal-ts-utils/node').GetRouteDefinition<{
|
72
|
+
userId: number;
|
73
|
+
teamId: number;
|
74
|
+
}, z.ZodObject<{
|
75
|
+
team_id: z.ZodNumber;
|
76
|
+
team_user: z.ZodObject<{
|
77
|
+
user_id: z.ZodNumber;
|
78
|
+
email: z.ZodString;
|
79
|
+
fullname: z.ZodString;
|
80
|
+
created_at: z.ZodString;
|
81
|
+
created_at_timestamp: z.ZodNumber;
|
82
|
+
role: z.ZodUnion<[z.ZodLiteral<"owner">, z.ZodLiteral<"admin">, z.ZodLiteral<"biller">, z.ZodLiteral<"member">]>;
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
84
|
+
role: "member" | "admin" | "biller" | "owner";
|
85
|
+
email: string;
|
86
|
+
user_id: number;
|
87
|
+
fullname: string;
|
88
|
+
created_at: string;
|
89
|
+
created_at_timestamp: number;
|
90
|
+
}, {
|
91
|
+
role: "member" | "admin" | "biller" | "owner";
|
92
|
+
email: string;
|
93
|
+
user_id: number;
|
94
|
+
fullname: string;
|
95
|
+
created_at: string;
|
96
|
+
created_at_timestamp: number;
|
97
|
+
}>;
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
99
|
+
team_id: number;
|
100
|
+
team_user: {
|
101
|
+
role: "member" | "admin" | "biller" | "owner";
|
102
|
+
email: string;
|
103
|
+
user_id: number;
|
104
|
+
fullname: string;
|
105
|
+
created_at: string;
|
106
|
+
created_at_timestamp: number;
|
107
|
+
};
|
108
|
+
}, {
|
109
|
+
team_id: number;
|
110
|
+
team_user: {
|
111
|
+
role: "member" | "admin" | "biller" | "owner";
|
112
|
+
email: string;
|
113
|
+
user_id: number;
|
114
|
+
fullname: string;
|
115
|
+
created_at: string;
|
116
|
+
created_at_timestamp: number;
|
117
|
+
};
|
118
|
+
}>, z.ZodObject<{
|
119
|
+
teamId: z.ZodNumber;
|
120
|
+
userId: z.ZodNumber;
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
122
|
+
userId: number;
|
123
|
+
teamId: number;
|
124
|
+
}, {
|
125
|
+
userId: number;
|
126
|
+
teamId: number;
|
127
|
+
}>, undefined, undefined, false, false>;
|
128
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
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
|
+
getCachedJwtToken?: JwtAuthProps['getCachedJwtToken'];
|
6
|
+
};
|
7
|
+
type BrowserPromoteAuthProps = Omit<PromoteAuthProps, 'getCachedJwtToken'> & {
|
8
|
+
getCachedJwtToken?: PromoteAuthProps['getCachedJwtToken'];
|
9
|
+
};
|
10
|
+
export interface BrowserJwtAuthAddonInterface {
|
11
|
+
jwtAuth<T extends BrowserJwtAuthAddonInterface>(this: T & Wretch<T>, props: BrowserJwtAuthProps): this;
|
12
|
+
jwtAuthWithClassicSessionPromotion<T extends BrowserJwtAuthAddonInterface>(this: T & Wretch<T>, props: BrowserPromoteAuthProps): this;
|
13
|
+
}
|
14
|
+
export declare const BrowserJwtAuthAddon: WretchAddon<BrowserJwtAuthAddonInterface>;
|
15
|
+
export {};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { JwtTokenPayload } from '../../core/jwtTokenPayload';
|
2
|
+
import { JwtToken } from '../../core/service/authService';
|
3
|
+
type NewJwtIssuedEventDetail = {
|
4
|
+
token: JwtToken;
|
5
|
+
payload: JwtTokenPayload | undefined;
|
6
|
+
};
|
7
|
+
export declare class NewJwtIssuedEvent extends CustomEvent<NewJwtIssuedEventDetail> {
|
8
|
+
static readonly eventName: "new-jwt-issued";
|
9
|
+
constructor(token: JwtToken);
|
10
|
+
}
|
11
|
+
export declare const isNewJwtIssuedEvent: (event: Event) => event is NewJwtIssuedEvent;
|
12
|
+
declare global {
|
13
|
+
interface WindowEventMap {
|
14
|
+
[NewJwtIssuedEvent.eventName]: NewJwtIssuedEvent;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ApiQueryOverrides } from '../../../../../utils/types/apiQueryOverrides';
|
2
|
+
import { Wretch } from 'wretch/types';
|
3
|
+
import { JwtToken } from '../../../core/service/authService';
|
4
|
+
export declare const getUserTokenKey: {
|
5
|
+
teamKey: (teamId: number) => readonly ["getUserToken", number];
|
6
|
+
};
|
7
|
+
export declare const useGetUserTokenQuery: <T>(api: Wretch<T>, teamId: number, overrides?: ApiQueryOverrides<JwtToken, typeof getUserTokenKey>) => import('@tanstack/react-query').UseQueryResult<{
|
8
|
+
accessToken: string;
|
9
|
+
refreshToken: string;
|
10
|
+
}, undefined>;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { ApiQueryOverrides } from '../../../../../utils/types/apiQueryOverrides';
|
2
|
+
import { Wretch } from 'wretch';
|
3
|
+
import { RetrieveContributorsResponse } from '../../../core/service/contributors';
|
4
|
+
export declare const retrieveContributorKeys: {
|
5
|
+
projectUserKey: (projectId: string, userId: number) => readonly ["RetrieveContributor", string, number];
|
6
|
+
};
|
7
|
+
export declare const useRetrieveContributorQuery: <T>(api: Wretch<T>, userId: number, projectId: string, overrides?: ApiQueryOverrides<RetrieveContributorsResponse, typeof retrieveContributorKeys>) => import('@tanstack/react-query').UseQueryResult<{
|
8
|
+
contributors: {
|
9
|
+
email: string;
|
10
|
+
user_id: number;
|
11
|
+
fullname: string;
|
12
|
+
created_at: string;
|
13
|
+
created_at_timestamp: number;
|
14
|
+
admin_rights: string[];
|
15
|
+
languages: {
|
16
|
+
lang_id: number;
|
17
|
+
lang_iso: string;
|
18
|
+
lang_name: string;
|
19
|
+
is_writable: 0 | 1;
|
20
|
+
}[];
|
21
|
+
is_admin: boolean;
|
22
|
+
is_reviewer: boolean;
|
23
|
+
}[];
|
24
|
+
project_id: string;
|
25
|
+
}, undefined>;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ApiQueryOverrides } from '../../../../../utils/types/apiQueryOverrides';
|
2
|
+
import { Wretch } from 'wretch/types';
|
3
|
+
import { TeamUserResponse } from '../../../core/service/teamUsersService';
|
4
|
+
export declare const getTeamUsersQueryKey: {
|
5
|
+
teamUserKey: (teamId: number, userId: number) => readonly ["GetTeamUsers", number, number];
|
6
|
+
};
|
7
|
+
export declare const userGetTeamUsersQuery: <T>(api: Wretch<T>, teamId: number, userId: number, overrides: ApiQueryOverrides<TeamUserResponse, typeof getTeamUsersQueryKey>) => import('@tanstack/react-query').UseQueryResult<{
|
8
|
+
team_id: number;
|
9
|
+
team_user: {
|
10
|
+
role: "member" | "admin" | "biller" | "owner";
|
11
|
+
email: string;
|
12
|
+
user_id: number;
|
13
|
+
fullname: string;
|
14
|
+
created_at: string;
|
15
|
+
created_at_timestamp: number;
|
16
|
+
};
|
17
|
+
}, undefined>;
|
package/dist/types/src/features/auth/frontend/hooks/utility/useAuthenticatedProjectContributor.d.ts
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
export declare const authenticatedContributorKeys: {
|
3
|
+
projectUserKey: (projectId: string, userId: number) => readonly ["RetrieveContributor", string, number];
|
4
|
+
};
|
5
|
+
export declare function useAuthenticatedProjectContributor<T>(api: Wretch<T>, projectId: string): import('@tanstack/react-query').UseQueryResult<{
|
6
|
+
contributors: {
|
7
|
+
email: string;
|
8
|
+
user_id: number;
|
9
|
+
fullname: string;
|
10
|
+
created_at: string;
|
11
|
+
created_at_timestamp: number;
|
12
|
+
admin_rights: string[];
|
13
|
+
languages: {
|
14
|
+
lang_id: number;
|
15
|
+
lang_iso: string;
|
16
|
+
lang_name: string;
|
17
|
+
is_writable: 0 | 1;
|
18
|
+
}[];
|
19
|
+
is_admin: boolean;
|
20
|
+
is_reviewer: boolean;
|
21
|
+
}[];
|
22
|
+
project_id: string;
|
23
|
+
}, undefined>;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
export declare const authenticatedUserKeys: {
|
3
|
+
teamUserKey: (teamId: number, userId: number) => readonly ["GetTeamUsers", number, number];
|
4
|
+
};
|
5
|
+
export declare function useAuthenticatedUser<T>(api: Wretch<T>): import('@tanstack/react-query').UseQueryResult<{
|
6
|
+
team_id: number;
|
7
|
+
team_user: {
|
8
|
+
role: "member" | "admin" | "biller" | "owner";
|
9
|
+
email: string;
|
10
|
+
user_id: number;
|
11
|
+
fullname: string;
|
12
|
+
created_at: string;
|
13
|
+
created_at_timestamp: number;
|
14
|
+
};
|
15
|
+
}, undefined>;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Wretch } from 'wretch';
|
2
|
+
export declare const getPromotedClassicSessionJwtKey: {
|
3
|
+
teamKey: (teamId: number) => readonly ["getUserToken", number];
|
4
|
+
};
|
5
|
+
export declare function useGetPromotedClassicSessionJwtQuery<T>(api: Wretch<T>, teamId: number): import('@tanstack/react-query').UseQueryResult<{
|
6
|
+
accessToken: string;
|
7
|
+
refreshToken: string;
|
8
|
+
}, undefined>;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* A hook that will bring the cached JWT token into the React lifecycle.
|
3
|
+
* If the token is updated or removed, the hook will update the state.
|
4
|
+
*/
|
5
|
+
export declare function useJwtTokenPayload(): {
|
6
|
+
isProviderAlpha: boolean;
|
7
|
+
planId: number;
|
8
|
+
userEmail: string;
|
9
|
+
userId: number;
|
10
|
+
teamId: number;
|
11
|
+
userTeamRole: "member" | "admin" | "biller" | "owner";
|
12
|
+
userCurrentTeamId: number;
|
13
|
+
planName: string;
|
14
|
+
isFullyAuthenticated: boolean;
|
15
|
+
exp: number;
|
16
|
+
} | undefined;
|
package/dist/types/src/features/auth/frontend/middleware/promoteClassicSessionToJwtMiddleware.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
import { ConfiguredMiddleware, Wretch } from 'wretch';
|
2
|
+
import { JwtAuthProps } from '../../core/middleware/jwtAuthMiddleware';
|
3
|
+
export type PromoteAuthProps = JwtAuthProps & {
|
4
|
+
getTeamId: () => Promise<number>;
|
5
|
+
};
|
6
|
+
export declare function promoteClassicSessionToJwtMiddleware<T>(client: Wretch<T>, props: PromoteAuthProps): ConfiguredMiddleware;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { JwtToken } from '../../core/service/authService';
|
2
|
+
export declare function getJwtToken(): Promise<{
|
3
|
+
accessToken: string;
|
4
|
+
refreshToken: string;
|
5
|
+
} | undefined>;
|
6
|
+
export declare function storeJwtToken(token: JwtToken): Promise<void>;
|
7
|
+
export declare function listenForTokenChanges(callback: (token: JwtToken | undefined) => void): () => void;
|
package/dist/types/src/node.d.ts
CHANGED
@@ -5,4 +5,19 @@ export { NavigationPanel } from './components/NavigationPanel/NavigationPanel';
|
|
5
5
|
export { Sidebar } from './components/Sidebar/Sidebar';
|
6
6
|
export { Breadcrumbs } from './components/NavigationPanel/components/Breadcrumbs/Breadcrumbs';
|
7
7
|
export { NavigationTabs } from './components/NavigationPanel/components/NavigationTabs/NavigationTabs';
|
8
|
+
/**
|
9
|
+
* HOOKS EXPORTS
|
10
|
+
*/
|
11
|
+
export { useGetPromotedClassicSessionJwtQuery, getPromotedClassicSessionJwtKey, } from './features/auth/frontend/hooks/utility/useGetPromotedClassicSessionJwtQuery';
|
12
|
+
export { useJwtTokenPayload } from './features/auth/frontend/hooks/utility/useJwtTokenPayload';
|
13
|
+
export { useAuthenticatedUser, authenticatedUserKeys, } from './features/auth/frontend/hooks/utility/useAuthenticatedUser';
|
14
|
+
export { useAuthenticatedProjectContributor, authenticatedContributorKeys, } from './features/auth/frontend/hooks/utility/useAuthenticatedProjectContributor';
|
15
|
+
export { useGetUserTokenQuery, getUserTokenKey } from './features/auth/frontend/hooks/services/useGetUserTokenQuery';
|
16
|
+
export { getTeamUsersQueryKey, userGetTeamUsersQuery, } from './features/auth/frontend/hooks/services/userGetTeamUsersQuery';
|
17
|
+
export { useRetrieveContributorQuery, retrieveContributorKeys, } from './features/auth/frontend/hooks/services/useRetrieveContributorQuery';
|
18
|
+
/**
|
19
|
+
* UTILS EXPORTS
|
20
|
+
*/
|
21
|
+
export { JwtAuthAddon } from './features/auth/core/jwtAuthAddon';
|
22
|
+
export { BrowserJwtAuthAddon } from './features/auth/frontend/addon/browserJwtAuthAddon';
|
8
23
|
export * from './utils/node';
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
2
|
+
export type ApiQueryOverrides<Data, QueryKeyFactory extends Record<string, (...args: any[]) => QueryKey>, SelectedData = Data, Error = undefined> = Omit<UseQueryOptions<Data, Error, SelectedData, ReturnType<QueryKeyFactory[keyof QueryKeyFactory]>>, 'queryFn' | 'queryKey'>;
|