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