@riligar/auth-elysia 1.4.2 → 1.6.0

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/index.esm.js CHANGED
@@ -139,7 +139,12 @@ class RiLiGarAuthClient {
139
139
  return null
140
140
  }
141
141
 
142
- return payload
142
+ // Map JWT standard claims to user object format
143
+ // JWT uses 'sub' for subject (user ID), but clients expect 'id'
144
+ return {
145
+ id: payload.sub,
146
+ ...payload,
147
+ }
143
148
  } catch (error) {
144
149
  console.warn('JWT local verification failed:', error.message);
145
150
  return null
@@ -275,9 +280,9 @@ function authPlugin(userConfig = {}) {
275
280
  // Instanciar cliente Auth
276
281
  const authClient = new RiLiGarAuthClient(config.apiUrl, config.secretKey);
277
282
 
278
- return new Elysia({ name: 'auth-plugin' })
283
+ return new Elysia({ name: 'auth-plugin', scoped: false })
279
284
  .onBeforeHandle(createAuthMiddleware(config, authClient))
280
- .resolve(({ request }) => ({
285
+ .derive(({ request }) => ({
281
286
  user: request.user || null,
282
287
  authMeta: request.authMeta || null,
283
288
  }))
package/dist/index.js CHANGED
@@ -143,7 +143,12 @@ class RiLiGarAuthClient {
143
143
  return null
144
144
  }
145
145
 
146
- return payload
146
+ // Map JWT standard claims to user object format
147
+ // JWT uses 'sub' for subject (user ID), but clients expect 'id'
148
+ return {
149
+ id: payload.sub,
150
+ ...payload,
151
+ }
147
152
  } catch (error) {
148
153
  console.warn('JWT local verification failed:', error.message);
149
154
  return null
@@ -279,9 +284,9 @@ function authPlugin(userConfig = {}) {
279
284
  // Instanciar cliente Auth
280
285
  const authClient = new RiLiGarAuthClient(config.apiUrl, config.secretKey);
281
286
 
282
- return new elysia.Elysia({ name: 'auth-plugin' })
287
+ return new elysia.Elysia({ name: 'auth-plugin', scoped: false })
283
288
  .onBeforeHandle(createAuthMiddleware(config, authClient))
284
- .resolve(({ request }) => ({
289
+ .derive(({ request }) => ({
285
290
  user: request.user || null,
286
291
  authMeta: request.authMeta || null,
287
292
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riligar/auth-elysia",
3
- "version": "1.4.2",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "description": "Auth SDK for ElysiaJS with JWT and JWKS",
6
6
  "main": "dist/index.js",
package/src/index.js CHANGED
@@ -138,7 +138,12 @@ class RiLiGarAuthClient {
138
138
  return null
139
139
  }
140
140
 
141
- return payload
141
+ // Map JWT standard claims to user object format
142
+ // JWT uses 'sub' for subject (user ID), but clients expect 'id'
143
+ return {
144
+ id: payload.sub,
145
+ ...payload,
146
+ }
142
147
  } catch (error) {
143
148
  console.warn('JWT local verification failed:', error.message)
144
149
  return null
@@ -274,9 +279,9 @@ export function authPlugin(userConfig = {}) {
274
279
  // Instanciar cliente Auth
275
280
  const authClient = new RiLiGarAuthClient(config.apiUrl, config.secretKey)
276
281
 
277
- return new Elysia({ name: 'auth-plugin' })
282
+ return new Elysia({ name: 'auth-plugin', scoped: false })
278
283
  .onBeforeHandle(createAuthMiddleware(config, authClient))
279
- .resolve(({ request }) => ({
284
+ .derive(({ request }) => ({
280
285
  user: request.user || null,
281
286
  authMeta: request.authMeta || null,
282
287
  }))