@riligar/auth-elysia 1.6.4 → 1.7.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
@@ -117,7 +117,17 @@ function authPlugin(userConfig = {}) {
117
117
  .onBeforeHandle({ as: 'global' }, ({ user, set, request }) => {
118
118
  const path = new URL(request.url).pathname;
119
119
  if (config.excludePaths.some(p => path.startsWith(p))) return
120
- if (!user) return config.onUnauthorized(set)
120
+ if (!user) {
121
+ set.status = 401;
122
+ set.headers['Content-Type'] = 'application/json';
123
+ return {
124
+ success: false,
125
+ error: {
126
+ code: 'UNAUTHORIZED',
127
+ message: 'Sessão inválida ou expirada. Por favor, faça login novamente.',
128
+ },
129
+ }
130
+ }
121
131
  })
122
132
  .error(({ error, set }) => {
123
133
  const errorStr = String(error);
package/dist/index.js CHANGED
@@ -121,7 +121,17 @@ function authPlugin(userConfig = {}) {
121
121
  .onBeforeHandle({ as: 'global' }, ({ user, set, request }) => {
122
122
  const path = new URL(request.url).pathname;
123
123
  if (config.excludePaths.some(p => path.startsWith(p))) return
124
- if (!user) return config.onUnauthorized(set)
124
+ if (!user) {
125
+ set.status = 401;
126
+ set.headers['Content-Type'] = 'application/json';
127
+ return {
128
+ success: false,
129
+ error: {
130
+ code: 'UNAUTHORIZED',
131
+ message: 'Sessão inválida ou expirada. Por favor, faça login novamente.',
132
+ },
133
+ }
134
+ }
125
135
  })
126
136
  .error(({ error, set }) => {
127
137
  const errorStr = String(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riligar/auth-elysia",
3
- "version": "1.6.4",
3
+ "version": "1.7.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
@@ -116,7 +116,17 @@ export function authPlugin(userConfig = {}) {
116
116
  .onBeforeHandle({ as: 'global' }, ({ user, set, request }) => {
117
117
  const path = new URL(request.url).pathname
118
118
  if (config.excludePaths.some(p => path.startsWith(p))) return
119
- if (!user) return config.onUnauthorized(set)
119
+ if (!user) {
120
+ set.status = 401
121
+ set.headers['Content-Type'] = 'application/json'
122
+ return {
123
+ success: false,
124
+ error: {
125
+ code: 'UNAUTHORIZED',
126
+ message: 'Sessão inválida ou expirada. Por favor, faça login novamente.',
127
+ },
128
+ }
129
+ }
120
130
  })
121
131
  .error(({ error, set }) => {
122
132
  const errorStr = String(error)