@cauth/express 0.0.1 → 0.0.3
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/express-BgF1jv36.d.ts +12 -0
- package/dist/{index.d.cts → index.d.ts} +27 -34
- package/dist/index.js +28 -0
- package/package.json +3 -3
- package/dist/index.cjs +0 -28
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./express-BgF1jv36.js";
|
|
2
|
+
import { RequestHandler } from "express";
|
|
2
3
|
import z$1, { z } from "zod";
|
|
3
4
|
import ms from "ms";
|
|
4
5
|
|
|
@@ -126,7 +127,7 @@ interface DatabaseContract {
|
|
|
126
127
|
//#region ../core/src/types/config.t.d.ts
|
|
127
128
|
declare const CAuthOptionsSchema: z$1.ZodObject<{
|
|
128
129
|
dbContractor: z$1.ZodCustom<DatabaseContract, DatabaseContract>;
|
|
129
|
-
routeContractor: z$1.ZodCustom<RoutesContract
|
|
130
|
+
routeContractor: z$1.ZodCustom<RoutesContract<(...args: any[]) => any>, RoutesContract<(...args: any[]) => any>>;
|
|
130
131
|
roles: z$1.ZodArray<z$1.ZodString>;
|
|
131
132
|
jwtConfig: z$1.ZodObject<{
|
|
132
133
|
refreshTokenSecret: z$1.ZodString;
|
|
@@ -188,13 +189,13 @@ declare class _CAuth<T extends string[]> {
|
|
|
188
189
|
*
|
|
189
190
|
* @default undefined
|
|
190
191
|
*/
|
|
191
|
-
Guard: (roles?: Array<T[number]>) => any;
|
|
192
|
+
Guard: (roles?: Array<T[number]>) => (...args: any[]) => any;
|
|
192
193
|
Routes: {
|
|
193
|
-
Register: () => any;
|
|
194
|
-
Login: () => any;
|
|
195
|
-
Logout: () => any;
|
|
196
|
-
Refresh: () => any;
|
|
197
|
-
ChangePassword: (userId: string) => any;
|
|
194
|
+
Register: () => (...args: any[]) => any;
|
|
195
|
+
Login: () => (...args: any[]) => any;
|
|
196
|
+
Logout: () => (...args: any[]) => any;
|
|
197
|
+
Refresh: () => (...args: any[]) => any;
|
|
198
|
+
ChangePassword: (userId: string) => (...args: any[]) => any;
|
|
198
199
|
};
|
|
199
200
|
FN: {
|
|
200
201
|
Login: ({
|
|
@@ -271,71 +272,63 @@ type AuthGuardDeps = {
|
|
|
271
272
|
tokens: _CAuth<any>['Tokens'];
|
|
272
273
|
roles?: Array<string>;
|
|
273
274
|
};
|
|
274
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Generic RoutesContract
|
|
277
|
+
* THandler is generic, defaults to any function
|
|
278
|
+
*/
|
|
279
|
+
interface RoutesContract<THandler extends (...args: any[]) => any = (...args: any[]) => any> {
|
|
275
280
|
Login({
|
|
276
281
|
...config
|
|
277
|
-
}: RouteDeps):
|
|
282
|
+
}: RouteDeps): THandler;
|
|
278
283
|
Register({
|
|
279
284
|
...config
|
|
280
|
-
}: RouteDeps):
|
|
285
|
+
}: RouteDeps): THandler;
|
|
281
286
|
Logout({
|
|
282
287
|
...config
|
|
283
|
-
}: RouteDeps):
|
|
288
|
+
}: RouteDeps): THandler;
|
|
284
289
|
Guard({
|
|
285
290
|
...config
|
|
286
|
-
}: AuthGuardDeps):
|
|
291
|
+
}: AuthGuardDeps): THandler;
|
|
287
292
|
Refresh({
|
|
288
293
|
...config
|
|
289
|
-
}: AuthGuardDeps):
|
|
294
|
+
}: AuthGuardDeps): THandler;
|
|
290
295
|
ChangePassword({
|
|
291
296
|
...config
|
|
292
297
|
}: RouteDeps & {
|
|
293
298
|
userId: string;
|
|
294
|
-
}):
|
|
299
|
+
}): THandler;
|
|
295
300
|
}
|
|
296
301
|
//#endregion
|
|
297
302
|
//#region src/express.contractor.d.ts
|
|
298
|
-
declare class ExpressContractor implements RoutesContract {
|
|
303
|
+
declare class ExpressContractor<THandler extends (...args: any[]) => any = RequestHandler> implements RoutesContract<THandler> {
|
|
299
304
|
Register: ({
|
|
300
305
|
config,
|
|
301
306
|
tokens
|
|
302
|
-
}: RouteDeps) =>
|
|
307
|
+
}: RouteDeps) => THandler;
|
|
303
308
|
Login: ({
|
|
304
309
|
config,
|
|
305
310
|
tokens
|
|
306
|
-
}: RouteDeps) =>
|
|
311
|
+
}: RouteDeps) => THandler;
|
|
307
312
|
Logout: ({
|
|
308
313
|
config,
|
|
309
314
|
tokens
|
|
310
|
-
}: RouteDeps) =>
|
|
315
|
+
}: RouteDeps) => THandler;
|
|
311
316
|
Refresh: ({
|
|
312
317
|
config,
|
|
313
318
|
tokens
|
|
314
|
-
}: RouteDeps) =>
|
|
319
|
+
}: RouteDeps) => THandler;
|
|
315
320
|
ChangePassword: ({
|
|
316
321
|
config,
|
|
317
322
|
tokens,
|
|
318
323
|
userId
|
|
319
324
|
}: RouteDeps & {
|
|
320
325
|
userId: string;
|
|
321
|
-
}) =>
|
|
326
|
+
}) => THandler;
|
|
322
327
|
Guard: ({
|
|
323
328
|
config,
|
|
324
329
|
tokens,
|
|
325
330
|
roles
|
|
326
|
-
}: AuthGuardDeps) =>
|
|
327
|
-
}
|
|
328
|
-
//#endregion
|
|
329
|
-
//#region src/types/express.d.ts
|
|
330
|
-
declare global {
|
|
331
|
-
namespace Express {
|
|
332
|
-
interface Request {
|
|
333
|
-
cauth?: {
|
|
334
|
-
id: string;
|
|
335
|
-
role: string;
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
}
|
|
331
|
+
}: AuthGuardDeps) => THandler;
|
|
339
332
|
}
|
|
340
333
|
//#endregion
|
|
341
334
|
export { ExpressContractor };
|