@maximemrf/adonisjs-jwt 0.2.1 → 0.2.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/README.md CHANGED
@@ -26,9 +26,13 @@ import { defineConfig } from '@adonisjs/auth'
26
26
  import { InferAuthEvents, Authenticators } from '@adonisjs/auth/types'
27
27
  import { sessionGuard, sessionUserProvider } from '@adonisjs/auth/session'
28
28
  import { jwtGuard } from '@maximemrf/adonisjs-jwt/jwt_config'
29
- import { JwtGuardUser } from '@maximemrf/adonisjs-jwt/types'
29
+ import { JwtGuardUser, BaseJwtContent } from '@maximemrf/adonisjs-jwt/types'
30
30
  import User from '#models/user'
31
31
 
32
+ interface JwtContent extends BaseJwtContent {
33
+ email: string
34
+ }
35
+
32
36
  const authConfig = defineConfig({
33
37
  // define the default authenticator to jwt
34
38
  default: 'jwt',
@@ -49,8 +53,8 @@ const authConfig = defineConfig({
49
53
  model: () => import('#models/user'),
50
54
  }),
51
55
  // content is a function that takes the user and returns the content of the token, it can be optional, by default it returns only the user id
52
- content: (user: JwtGuardUser<User>) => ({
53
- id: user.getId(),
56
+ content: (user: JwtGuardUser<User>): JwtContent => ({
57
+ userId: user.getId(),
54
58
  email: user.getOriginal().email,
55
59
  }),
56
60
  }),
@@ -6,5 +6,5 @@ export declare function jwtGuard<UserProvider extends JwtUserProviderContract<un
6
6
  provider: UserProvider;
7
7
  tokenExpiresIn?: number | string;
8
8
  useCookies?: boolean;
9
- content: <T>(user: JwtGuardUser<T>) => Record<string, any>;
9
+ content: <T>(user: JwtGuardUser<T>) => Record<string | number, any>;
10
10
  }): GuardConfigProvider<(ctx: HttpContext) => JwtGuard<UserProvider>>;
@@ -33,6 +33,9 @@ export interface JwtUserProviderContract<RealUser> {
33
33
  */
34
34
  findById(identifier: string | number | BigInt): Promise<JwtGuardUser<RealUser> | null>;
35
35
  }
36
+ export type BaseJwtContent = {
37
+ userId: string | number | BigInt;
38
+ };
36
39
  export type JwtGuardOptions<RealUser extends any = unknown> = {
37
40
  secret: string;
38
41
  expiresIn?: number | string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maximemrf/adonisjs-jwt",
3
3
  "description": "Adonisjs v6 package for authentication with jwt token",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "engines": {
6
6
  "node": ">=20.6.0"
7
7
  },