@vritti/api-sdk 0.3.2 → 0.3.5
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/auth.cjs +942 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +95 -0
- package/dist/auth.d.ts +95 -0
- package/dist/auth.js +884 -0
- package/dist/auth.js.map +1 -0
- package/dist/cache.cjs +182 -14
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.cts +48 -4
- package/dist/cache.d.ts +48 -4
- package/dist/cache.js +177 -12
- package/dist/cache.js.map +1 -1
- package/dist/catalog-resolver.cjs +226 -51
- package/dist/catalog-resolver.cjs.map +1 -1
- package/dist/catalog-resolver.d.cts +41 -19
- package/dist/catalog-resolver.d.ts +41 -19
- package/dist/catalog-resolver.js +212 -46
- package/dist/catalog-resolver.js.map +1 -1
- package/dist/code-pattern-BP4zkNtT.d.cts +12 -0
- package/dist/code-pattern-BP4zkNtT.d.ts +12 -0
- package/dist/context.cjs +93 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +19 -0
- package/dist/context.d.ts +19 -0
- package/dist/context.js +64 -0
- package/dist/context.js.map +1 -0
- package/dist/countries.cjs +1559 -0
- package/dist/countries.cjs.map +1 -0
- package/dist/countries.d.cts +13 -0
- package/dist/countries.d.ts +13 -0
- package/dist/countries.js +1532 -0
- package/dist/countries.js.map +1 -0
- package/dist/data-table.cjs +1280 -0
- package/dist/data-table.cjs.map +1 -0
- package/dist/data-table.d.cts +123 -0
- package/dist/data-table.d.ts +123 -0
- package/dist/data-table.js +1260 -0
- package/dist/data-table.js.map +1 -0
- package/dist/database.cjs +1510 -0
- package/dist/database.cjs.map +1 -0
- package/dist/database.d.cts +287 -0
- package/dist/database.d.ts +287 -0
- package/dist/database.js +1469 -0
- package/dist/database.js.map +1 -0
- package/dist/decimal.d.cts +0 -1
- package/dist/decimal.d.ts +0 -1
- package/dist/decorators.cjs +1817 -0
- package/dist/decorators.cjs.map +1 -0
- package/dist/decorators.d.cts +24 -0
- package/dist/decorators.d.ts +24 -0
- package/dist/decorators.js +1780 -0
- package/dist/decorators.js.map +1 -0
- package/dist/document-BoS0NIbf.d.cts +12 -0
- package/dist/document-BoS0NIbf.d.ts +12 -0
- package/dist/drizzle-pg-core.cjs +25 -0
- package/dist/drizzle-pg-core.cjs.map +1 -1
- package/dist/drizzle-pg-core.d.cts +7 -0
- package/dist/drizzle-pg-core.d.ts +7 -0
- package/dist/drizzle-pg-core.js +22 -0
- package/dist/drizzle-pg-core.js.map +1 -1
- package/dist/exceptions.cjs +301 -0
- package/dist/exceptions.cjs.map +1 -0
- package/dist/exceptions.d.cts +90 -0
- package/dist/exceptions.d.ts +90 -0
- package/dist/exceptions.js +257 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/filter.types-PuARU9XD.d.cts +50 -0
- package/dist/filter.types-PuARU9XD.d.ts +50 -0
- package/dist/filters.cjs +407 -0
- package/dist/filters.cjs.map +1 -0
- package/dist/filters.d.cts +55 -0
- package/dist/filters.d.ts +55 -0
- package/dist/filters.js +377 -0
- package/dist/filters.js.map +1 -0
- package/dist/index.cjs +0 -5423
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -854
- package/dist/index.d.ts +93 -854
- package/dist/index.js +0 -5301
- package/dist/index.js.map +1 -1
- package/dist/is-country.decorator-CcNwSSr5.d.cts +5 -0
- package/dist/is-country.decorator-CcNwSSr5.d.ts +5 -0
- package/dist/license.cjs +9 -56
- package/dist/license.cjs.map +1 -1
- package/dist/license.d.cts +3 -14
- package/dist/license.d.ts +3 -14
- package/dist/license.js +8 -51
- package/dist/license.js.map +1 -1
- package/dist/lodash.cjs.map +1 -1
- package/dist/lodash.js.map +1 -1
- package/dist/logger.cjs +862 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +118 -0
- package/dist/logger.d.ts +118 -0
- package/dist/logger.js +816 -0
- package/dist/logger.js.map +1 -0
- package/dist/migrate.cjs +2 -2
- package/dist/migrate.cjs.map +1 -1
- package/dist/migrate.d.cts +2 -0
- package/dist/migrate.d.ts +2 -0
- package/dist/migrate.js +2 -2
- package/dist/migrate.js.map +1 -1
- package/dist/money.cjs +18 -3
- package/dist/money.cjs.map +1 -1
- package/dist/money.d.cts +13 -13
- package/dist/money.d.ts +13 -13
- package/dist/money.js +18 -3
- package/dist/money.js.map +1 -1
- package/dist/nats.cjs +34 -35
- package/dist/nats.cjs.map +1 -1
- package/dist/nats.d.cts +14 -14
- package/dist/nats.d.ts +14 -14
- package/dist/nats.js +32 -33
- package/dist/nats.js.map +1 -1
- package/dist/root.cjs +225 -0
- package/dist/root.cjs.map +1 -0
- package/dist/root.d.cts +4 -0
- package/dist/root.d.ts +4 -0
- package/dist/root.js +200 -0
- package/dist/root.js.map +1 -0
- package/dist/signing.cjs +159 -0
- package/dist/signing.cjs.map +1 -0
- package/dist/signing.d.cts +35 -0
- package/dist/signing.d.ts +35 -0
- package/dist/signing.js +128 -0
- package/dist/signing.js.map +1 -0
- package/dist/{types-DQRwj5rr.d.cts → types-C9jPdQqH.d.cts} +32 -6
- package/dist/{types-DQRwj5rr.d.ts → types-C9jPdQqH.d.ts} +32 -6
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +17 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.cjs +273 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +245 -0
- package/dist/utils.js.map +1 -0
- package/package.json +132 -1
- package/dist/cache.service-_SuJIcNA.d.cts +0 -20
- package/dist/cache.service-_SuJIcNA.d.ts +0 -20
- package/dist/fastify-augmentation-CQPBNS5a.d.cts +0 -105
- package/dist/fastify-augmentation-CQPBNS5a.d.ts +0 -105
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vritti/api-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.5",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -86,6 +86,16 @@
|
|
|
86
86
|
"default": "./dist/lodash.cjs"
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
+
"./exceptions": {
|
|
90
|
+
"import": {
|
|
91
|
+
"types": "./dist/exceptions.d.ts",
|
|
92
|
+
"default": "./dist/exceptions.js"
|
|
93
|
+
},
|
|
94
|
+
"require": {
|
|
95
|
+
"types": "./dist/exceptions.d.cts",
|
|
96
|
+
"default": "./dist/exceptions.cjs"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
89
99
|
"./money": {
|
|
90
100
|
"import": {
|
|
91
101
|
"types": "./dist/money.d.ts",
|
|
@@ -96,6 +106,16 @@
|
|
|
96
106
|
"default": "./dist/money.cjs"
|
|
97
107
|
}
|
|
98
108
|
},
|
|
109
|
+
"./countries": {
|
|
110
|
+
"import": {
|
|
111
|
+
"types": "./dist/countries.d.ts",
|
|
112
|
+
"default": "./dist/countries.js"
|
|
113
|
+
},
|
|
114
|
+
"require": {
|
|
115
|
+
"types": "./dist/countries.d.cts",
|
|
116
|
+
"default": "./dist/countries.cjs"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
99
119
|
"./icons": {
|
|
100
120
|
"import": {
|
|
101
121
|
"types": "./dist/icons.d.ts",
|
|
@@ -126,6 +146,16 @@
|
|
|
126
146
|
"default": "./dist/license.cjs"
|
|
127
147
|
}
|
|
128
148
|
},
|
|
149
|
+
"./signing": {
|
|
150
|
+
"import": {
|
|
151
|
+
"types": "./dist/signing.d.ts",
|
|
152
|
+
"default": "./dist/signing.js"
|
|
153
|
+
},
|
|
154
|
+
"require": {
|
|
155
|
+
"types": "./dist/signing.d.cts",
|
|
156
|
+
"default": "./dist/signing.cjs"
|
|
157
|
+
}
|
|
158
|
+
},
|
|
129
159
|
"./cache": {
|
|
130
160
|
"import": {
|
|
131
161
|
"types": "./dist/cache.d.ts",
|
|
@@ -145,6 +175,106 @@
|
|
|
145
175
|
"types": "./dist/email.d.cts",
|
|
146
176
|
"default": "./dist/email.cjs"
|
|
147
177
|
}
|
|
178
|
+
},
|
|
179
|
+
"./auth": {
|
|
180
|
+
"import": {
|
|
181
|
+
"types": "./dist/auth.d.ts",
|
|
182
|
+
"default": "./dist/auth.js"
|
|
183
|
+
},
|
|
184
|
+
"require": {
|
|
185
|
+
"types": "./dist/auth.d.cts",
|
|
186
|
+
"default": "./dist/auth.cjs"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"./context": {
|
|
190
|
+
"import": {
|
|
191
|
+
"types": "./dist/context.d.ts",
|
|
192
|
+
"default": "./dist/context.js"
|
|
193
|
+
},
|
|
194
|
+
"require": {
|
|
195
|
+
"types": "./dist/context.d.cts",
|
|
196
|
+
"default": "./dist/context.cjs"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"./data-table": {
|
|
200
|
+
"import": {
|
|
201
|
+
"types": "./dist/data-table.d.ts",
|
|
202
|
+
"default": "./dist/data-table.js"
|
|
203
|
+
},
|
|
204
|
+
"require": {
|
|
205
|
+
"types": "./dist/data-table.d.cts",
|
|
206
|
+
"default": "./dist/data-table.cjs"
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
"./database": {
|
|
210
|
+
"import": {
|
|
211
|
+
"types": "./dist/database.d.ts",
|
|
212
|
+
"default": "./dist/database.js"
|
|
213
|
+
},
|
|
214
|
+
"require": {
|
|
215
|
+
"types": "./dist/database.d.cts",
|
|
216
|
+
"default": "./dist/database.cjs"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"./decorators": {
|
|
220
|
+
"import": {
|
|
221
|
+
"types": "./dist/decorators.d.ts",
|
|
222
|
+
"default": "./dist/decorators.js"
|
|
223
|
+
},
|
|
224
|
+
"require": {
|
|
225
|
+
"types": "./dist/decorators.d.cts",
|
|
226
|
+
"default": "./dist/decorators.cjs"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"./filters": {
|
|
230
|
+
"import": {
|
|
231
|
+
"types": "./dist/filters.d.ts",
|
|
232
|
+
"default": "./dist/filters.js"
|
|
233
|
+
},
|
|
234
|
+
"require": {
|
|
235
|
+
"types": "./dist/filters.d.cts",
|
|
236
|
+
"default": "./dist/filters.cjs"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"./logger": {
|
|
240
|
+
"import": {
|
|
241
|
+
"types": "./dist/logger.d.ts",
|
|
242
|
+
"default": "./dist/logger.js"
|
|
243
|
+
},
|
|
244
|
+
"require": {
|
|
245
|
+
"types": "./dist/logger.d.cts",
|
|
246
|
+
"default": "./dist/logger.cjs"
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
"./root": {
|
|
250
|
+
"import": {
|
|
251
|
+
"types": "./dist/root.d.ts",
|
|
252
|
+
"default": "./dist/root.js"
|
|
253
|
+
},
|
|
254
|
+
"require": {
|
|
255
|
+
"types": "./dist/root.d.cts",
|
|
256
|
+
"default": "./dist/root.cjs"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"./types": {
|
|
260
|
+
"import": {
|
|
261
|
+
"types": "./dist/types.d.ts",
|
|
262
|
+
"default": "./dist/types.js"
|
|
263
|
+
},
|
|
264
|
+
"require": {
|
|
265
|
+
"types": "./dist/types.d.cts",
|
|
266
|
+
"default": "./dist/types.cjs"
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"./utils": {
|
|
270
|
+
"import": {
|
|
271
|
+
"types": "./dist/utils.d.ts",
|
|
272
|
+
"default": "./dist/utils.js"
|
|
273
|
+
},
|
|
274
|
+
"require": {
|
|
275
|
+
"types": "./dist/utils.d.cts",
|
|
276
|
+
"default": "./dist/utils.cjs"
|
|
277
|
+
}
|
|
148
278
|
}
|
|
149
279
|
},
|
|
150
280
|
"files": [
|
|
@@ -167,6 +297,7 @@
|
|
|
167
297
|
"drizzle-orm": "1.0.0-rc.3",
|
|
168
298
|
"ioredis": "^5.4.1",
|
|
169
299
|
"lodash": "^4.18.1",
|
|
300
|
+
"lru-cache": "^11.5.1",
|
|
170
301
|
"nats": "^2.29.3",
|
|
171
302
|
"pg": "^8.16.0",
|
|
172
303
|
"winston": "^3.11.0",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface ICacheProvider {
|
|
2
|
-
set<T>(key: string, value: T, ttlSeconds: number): Promise<void>;
|
|
3
|
-
get<T>(key: string): Promise<T | null>;
|
|
4
|
-
del(...keys: string[]): Promise<void>;
|
|
5
|
-
scanKeys(pattern: string): Promise<string[]>;
|
|
6
|
-
getMemoryInfo(): Promise<string>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare class CacheService {
|
|
10
|
-
private readonly provider;
|
|
11
|
-
private readonly logger;
|
|
12
|
-
constructor(provider: ICacheProvider);
|
|
13
|
-
set<T>(key: string, value: T, ttlSeconds: number): Promise<void>;
|
|
14
|
-
get<T>(key: string): Promise<T | null>;
|
|
15
|
-
del(...keys: string[]): Promise<void>;
|
|
16
|
-
scanKeys(pattern: string): Promise<string[]>;
|
|
17
|
-
getMemoryInfo(): Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { CacheService as C, type ICacheProvider as I };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface ICacheProvider {
|
|
2
|
-
set<T>(key: string, value: T, ttlSeconds: number): Promise<void>;
|
|
3
|
-
get<T>(key: string): Promise<T | null>;
|
|
4
|
-
del(...keys: string[]): Promise<void>;
|
|
5
|
-
scanKeys(pattern: string): Promise<string[]>;
|
|
6
|
-
getMemoryInfo(): Promise<string>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare class CacheService {
|
|
10
|
-
private readonly provider;
|
|
11
|
-
private readonly logger;
|
|
12
|
-
constructor(provider: ICacheProvider);
|
|
13
|
-
set<T>(key: string, value: T, ttlSeconds: number): Promise<void>;
|
|
14
|
-
get<T>(key: string): Promise<T | null>;
|
|
15
|
-
del(...keys: string[]): Promise<void>;
|
|
16
|
-
scanKeys(pattern: string): Promise<string[]>;
|
|
17
|
-
getMemoryInfo(): Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { CacheService as C, type ICacheProvider as I };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { FastifyRequest } from 'fastify';
|
|
2
|
-
|
|
3
|
-
declare class RequestService {
|
|
4
|
-
private readonly injectedRequest;
|
|
5
|
-
private readonly config;
|
|
6
|
-
constructor(injectedRequest: FastifyRequest, config: AuthConfig);
|
|
7
|
-
private get request();
|
|
8
|
-
getAccessToken(): string | null;
|
|
9
|
-
getRefreshToken(): string | null;
|
|
10
|
-
getHeader(key: string): string | string[] | undefined;
|
|
11
|
-
getHostname(): string;
|
|
12
|
-
getAllHeaders(): FastifyRequest['headers'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare const AUTH_CONFIG: unique symbol;
|
|
16
|
-
type OnAuthenticatedCallback = (requestService: RequestService, sessionInfo: NonNullable<FastifyRequest['sessionInfo']>) => void | Promise<void>;
|
|
17
|
-
type TokenExpiryString = `${number}${'s' | 'm' | 'h' | 'd' | 'w' | 'y'}`;
|
|
18
|
-
interface TokenExpiry {
|
|
19
|
-
access: TokenExpiryString;
|
|
20
|
-
refresh: TokenExpiryString;
|
|
21
|
-
}
|
|
22
|
-
interface CookieConfig {
|
|
23
|
-
refreshCookieName: string;
|
|
24
|
-
refreshCookieMaxAge: number;
|
|
25
|
-
refreshCookiePath: string;
|
|
26
|
-
refreshCookieSecure: boolean;
|
|
27
|
-
refreshCookieSameSite: 'strict' | 'lax' | 'none';
|
|
28
|
-
refreshCookieDomain?: string;
|
|
29
|
-
}
|
|
30
|
-
interface GuardConfig {
|
|
31
|
-
authHeaderName: string;
|
|
32
|
-
tokenPrefix: string;
|
|
33
|
-
csrfExemptSessionTypes?: string[];
|
|
34
|
-
csrfExemptTransports?: string[];
|
|
35
|
-
refreshTokenBindingExemptSessionTypes?: string[];
|
|
36
|
-
onAuthenticated?: OnAuthenticatedCallback;
|
|
37
|
-
}
|
|
38
|
-
interface AuthConfig {
|
|
39
|
-
tokenExpiry: TokenExpiry;
|
|
40
|
-
cookie: CookieConfig;
|
|
41
|
-
guard: GuardConfig;
|
|
42
|
-
}
|
|
43
|
-
declare const AUTH_CONFIG_DEFAULTS: {
|
|
44
|
-
cookie: {
|
|
45
|
-
refreshCookieName: string;
|
|
46
|
-
refreshCookieMaxAge: number;
|
|
47
|
-
refreshCookiePath: string;
|
|
48
|
-
refreshCookieSecure: boolean;
|
|
49
|
-
refreshCookieSameSite: "strict";
|
|
50
|
-
refreshCookieDomain: string;
|
|
51
|
-
};
|
|
52
|
-
guard: {
|
|
53
|
-
authHeaderName: string;
|
|
54
|
-
tokenPrefix: string;
|
|
55
|
-
csrfExemptSessionTypes: never[];
|
|
56
|
-
csrfExemptTransports: never[];
|
|
57
|
-
refreshTokenBindingExemptSessionTypes: never[];
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
interface CookieSerializeOptions {
|
|
61
|
-
httpOnly: boolean;
|
|
62
|
-
secure: boolean;
|
|
63
|
-
sameSite: 'strict' | 'lax' | 'none';
|
|
64
|
-
path: string;
|
|
65
|
-
maxAge: number;
|
|
66
|
-
domain: string;
|
|
67
|
-
}
|
|
68
|
-
declare enum TokenType {
|
|
69
|
-
ACCESS = "access",
|
|
70
|
-
REFRESH = "refresh"
|
|
71
|
-
}
|
|
72
|
-
interface JwtClaims {
|
|
73
|
-
exp: number;
|
|
74
|
-
iat: number;
|
|
75
|
-
}
|
|
76
|
-
interface AccessTokenPayload {
|
|
77
|
-
sessionType: string;
|
|
78
|
-
tokenType: TokenType.ACCESS;
|
|
79
|
-
userId: string;
|
|
80
|
-
sessionId: string;
|
|
81
|
-
refreshTokenHash: string;
|
|
82
|
-
}
|
|
83
|
-
type DecodedAccessToken = AccessTokenPayload & JwtClaims;
|
|
84
|
-
interface RefreshTokenPayload {
|
|
85
|
-
sessionType: string;
|
|
86
|
-
tokenType: TokenType.REFRESH;
|
|
87
|
-
userId: string;
|
|
88
|
-
sessionId: string;
|
|
89
|
-
}
|
|
90
|
-
type DecodedRefreshToken = RefreshTokenPayload & JwtClaims;
|
|
91
|
-
|
|
92
|
-
declare module 'fastify' {
|
|
93
|
-
interface VrittiSessionInfo {
|
|
94
|
-
userId: string;
|
|
95
|
-
sessionId: string;
|
|
96
|
-
sessionType: string;
|
|
97
|
-
}
|
|
98
|
-
interface FastifyRequest {
|
|
99
|
-
sessionInfo?: VrittiSessionInfo;
|
|
100
|
-
authConfig?: AuthConfig;
|
|
101
|
-
cookies?: Record<string, string>;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { type AuthConfig as A, type CookieConfig as C, type DecodedAccessToken as D, type GuardConfig as G, type OnAuthenticatedCallback as O, RequestService as R, type TokenExpiry as T, TokenType as a, type DecodedRefreshToken as b, type AccessTokenPayload as c, AUTH_CONFIG as d, AUTH_CONFIG_DEFAULTS as e, type CookieSerializeOptions as f, type RefreshTokenPayload as g, type TokenExpiryString as h };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { FastifyRequest } from 'fastify';
|
|
2
|
-
|
|
3
|
-
declare class RequestService {
|
|
4
|
-
private readonly injectedRequest;
|
|
5
|
-
private readonly config;
|
|
6
|
-
constructor(injectedRequest: FastifyRequest, config: AuthConfig);
|
|
7
|
-
private get request();
|
|
8
|
-
getAccessToken(): string | null;
|
|
9
|
-
getRefreshToken(): string | null;
|
|
10
|
-
getHeader(key: string): string | string[] | undefined;
|
|
11
|
-
getHostname(): string;
|
|
12
|
-
getAllHeaders(): FastifyRequest['headers'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare const AUTH_CONFIG: unique symbol;
|
|
16
|
-
type OnAuthenticatedCallback = (requestService: RequestService, sessionInfo: NonNullable<FastifyRequest['sessionInfo']>) => void | Promise<void>;
|
|
17
|
-
type TokenExpiryString = `${number}${'s' | 'm' | 'h' | 'd' | 'w' | 'y'}`;
|
|
18
|
-
interface TokenExpiry {
|
|
19
|
-
access: TokenExpiryString;
|
|
20
|
-
refresh: TokenExpiryString;
|
|
21
|
-
}
|
|
22
|
-
interface CookieConfig {
|
|
23
|
-
refreshCookieName: string;
|
|
24
|
-
refreshCookieMaxAge: number;
|
|
25
|
-
refreshCookiePath: string;
|
|
26
|
-
refreshCookieSecure: boolean;
|
|
27
|
-
refreshCookieSameSite: 'strict' | 'lax' | 'none';
|
|
28
|
-
refreshCookieDomain?: string;
|
|
29
|
-
}
|
|
30
|
-
interface GuardConfig {
|
|
31
|
-
authHeaderName: string;
|
|
32
|
-
tokenPrefix: string;
|
|
33
|
-
csrfExemptSessionTypes?: string[];
|
|
34
|
-
csrfExemptTransports?: string[];
|
|
35
|
-
refreshTokenBindingExemptSessionTypes?: string[];
|
|
36
|
-
onAuthenticated?: OnAuthenticatedCallback;
|
|
37
|
-
}
|
|
38
|
-
interface AuthConfig {
|
|
39
|
-
tokenExpiry: TokenExpiry;
|
|
40
|
-
cookie: CookieConfig;
|
|
41
|
-
guard: GuardConfig;
|
|
42
|
-
}
|
|
43
|
-
declare const AUTH_CONFIG_DEFAULTS: {
|
|
44
|
-
cookie: {
|
|
45
|
-
refreshCookieName: string;
|
|
46
|
-
refreshCookieMaxAge: number;
|
|
47
|
-
refreshCookiePath: string;
|
|
48
|
-
refreshCookieSecure: boolean;
|
|
49
|
-
refreshCookieSameSite: "strict";
|
|
50
|
-
refreshCookieDomain: string;
|
|
51
|
-
};
|
|
52
|
-
guard: {
|
|
53
|
-
authHeaderName: string;
|
|
54
|
-
tokenPrefix: string;
|
|
55
|
-
csrfExemptSessionTypes: never[];
|
|
56
|
-
csrfExemptTransports: never[];
|
|
57
|
-
refreshTokenBindingExemptSessionTypes: never[];
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
interface CookieSerializeOptions {
|
|
61
|
-
httpOnly: boolean;
|
|
62
|
-
secure: boolean;
|
|
63
|
-
sameSite: 'strict' | 'lax' | 'none';
|
|
64
|
-
path: string;
|
|
65
|
-
maxAge: number;
|
|
66
|
-
domain: string;
|
|
67
|
-
}
|
|
68
|
-
declare enum TokenType {
|
|
69
|
-
ACCESS = "access",
|
|
70
|
-
REFRESH = "refresh"
|
|
71
|
-
}
|
|
72
|
-
interface JwtClaims {
|
|
73
|
-
exp: number;
|
|
74
|
-
iat: number;
|
|
75
|
-
}
|
|
76
|
-
interface AccessTokenPayload {
|
|
77
|
-
sessionType: string;
|
|
78
|
-
tokenType: TokenType.ACCESS;
|
|
79
|
-
userId: string;
|
|
80
|
-
sessionId: string;
|
|
81
|
-
refreshTokenHash: string;
|
|
82
|
-
}
|
|
83
|
-
type DecodedAccessToken = AccessTokenPayload & JwtClaims;
|
|
84
|
-
interface RefreshTokenPayload {
|
|
85
|
-
sessionType: string;
|
|
86
|
-
tokenType: TokenType.REFRESH;
|
|
87
|
-
userId: string;
|
|
88
|
-
sessionId: string;
|
|
89
|
-
}
|
|
90
|
-
type DecodedRefreshToken = RefreshTokenPayload & JwtClaims;
|
|
91
|
-
|
|
92
|
-
declare module 'fastify' {
|
|
93
|
-
interface VrittiSessionInfo {
|
|
94
|
-
userId: string;
|
|
95
|
-
sessionId: string;
|
|
96
|
-
sessionType: string;
|
|
97
|
-
}
|
|
98
|
-
interface FastifyRequest {
|
|
99
|
-
sessionInfo?: VrittiSessionInfo;
|
|
100
|
-
authConfig?: AuthConfig;
|
|
101
|
-
cookies?: Record<string, string>;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { type AuthConfig as A, type CookieConfig as C, type DecodedAccessToken as D, type GuardConfig as G, type OnAuthenticatedCallback as O, RequestService as R, type TokenExpiry as T, TokenType as a, type DecodedRefreshToken as b, type AccessTokenPayload as c, AUTH_CONFIG as d, AUTH_CONFIG_DEFAULTS as e, type CookieSerializeOptions as f, type RefreshTokenPayload as g, type TokenExpiryString as h };
|