hightjs 0.3.3 → 0.3.4

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.
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@tailwindcss/postcss": "^4.1.16",
14
14
  "autoprefixer": "^10.4.21",
15
- "hightjs": "^0.3.1",
15
+ "hightjs": "../",
16
16
  "postcss": "^8.5.6",
17
17
  "react": "^19.2.0",
18
18
  "react-dom": "^19.2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hightjs",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "HightJS is a high-level framework for building web applications with ease and speed. It provides a robust set of tools and features to streamline development and enhance productivity.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,18 +33,18 @@ export class FrameworkAdapterFactory {
33
33
  if (this.adapter) {
34
34
  return this.adapter;
35
35
  }
36
- const msg = Console.dynamicLine(` ${Colors.FgYellow}● ${Colors.Reset}Detectando framework web...`);
36
+ const msg = Console.dynamicLine(` ${Colors.FgYellow}● ${Colors.Reset}Detecting web framework...`);
37
37
 
38
38
  // Detecta Express
39
39
  if (req.app && req.route && res.locals !== undefined) {
40
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detectado: Express`);
40
+ msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express`);
41
41
  this.adapter = new ExpressAdapter();
42
42
  return this.adapter;
43
43
  }
44
44
 
45
45
  // Detecta Fastify
46
46
  if (req.server && req.routerPath !== undefined && res.request) {
47
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detectado: Fastify`);
47
+ msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify`);
48
48
  this.adapter = new FastifyAdapter();
49
49
  return this.adapter;
50
50
  }
@@ -52,27 +52,27 @@ export class FrameworkAdapterFactory {
52
52
  // Detecta HTTP nativo do Node.js
53
53
  if (req.method !== undefined && req.url !== undefined && req.headers !== undefined &&
54
54
  res.statusCode !== undefined && res.setHeader !== undefined && res.end !== undefined) {
55
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detectado: HightJS Native (HTTP)`);
55
+ msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: HightJS Native (HTTP)`);
56
56
  this.adapter = new NativeAdapter();
57
57
  return this.adapter;
58
58
  }
59
59
 
60
60
  // Fallback mais específico para Express
61
61
  if (res.status && res.send && res.json && res.cookie) {
62
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detectado: Express (fallback)`);
62
+ msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express (fallback)`);
63
63
  this.adapter = new ExpressAdapter();
64
64
  return this.adapter;
65
65
  }
66
66
 
67
67
  // Fallback mais específico para Fastify
68
68
  if (res.code && res.send && res.type && res.setCookie) {
69
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detectado: Fastify (fallback)`);
69
+ msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify (fallback)`);
70
70
  this.adapter = new FastifyAdapter();
71
71
  return this.adapter;
72
72
  }
73
73
 
74
74
  // Default para HightJS Native se não conseguir detectar
75
- msg.end(` ${Colors.FgYellow}● ${Colors.Reset}Não foi possível detectar o framework. Usando HightJS Native como padrão.`);
75
+ msg.end(` ${Colors.FgYellow}● ${Colors.Reset}Unable to detect framework. Using HightJS Native as default.`);
76
76
  this.adapter = new NativeAdapter();
77
77
  return this.adapter;
78
78
  }
@@ -92,7 +92,7 @@ export class FrameworkAdapterFactory {
92
92
  this.adapter = new NativeAdapter();
93
93
  break;
94
94
  default:
95
- throw new Error(`Framework não suportado: ${framework}`);
95
+ throw new Error(`Unsupported framework: ${framework}`);
96
96
  }
97
97
  }
98
98
 
@@ -81,7 +81,7 @@ export class NativeAdapter implements FrameworkAdapter {
81
81
  cookies[name] = decodeURIComponent(rest.join('='));
82
82
  } catch (e) {
83
83
  // Prevenção de crash: Ignora cookies com valores malformados (e.g., URI inválida).
84
- console.error(`Aviso: Cookie malformado com nome "${name}" foi ignorado.`);
84
+ console.error(`Warning: Malformed cookie with name "${name}" was ignored.`);
85
85
  }
86
86
  }
87
87
  });
@@ -114,7 +114,7 @@ class NativeResponseWrapper implements GenericResponse {
114
114
  const sanitizedValue = sanitizeHeaderValue(value);
115
115
 
116
116
  if (name !== sanitizedName || String(value) !== sanitizedValue) {
117
- console.warn(`Aviso: Tentativa potencial de HTTP Header Injection foi detectada e sanitizada. Header original: "${name}"`);
117
+ console.warn(`Warning: Potential HTTP Header Injection attempt detected and sanitized. Original header: "${name}"`);
118
118
  }
119
119
 
120
120
 
@@ -125,7 +125,7 @@ class NativeResponseWrapper implements GenericResponse {
125
125
  cookie(name: string, value: string, options?: CookieOptions): GenericResponse {
126
126
  // Medida de segurança: Valida o nome do cookie.
127
127
  if (!isValidCookieName(name)) {
128
- console.error(`Erro: Nome de cookie inválido "${name}". O cookie não será definido.`);
128
+ console.error(`Error: Invalid cookie name "${name}". The cookie will not be set.`);
129
129
  return this;
130
130
  }
131
131
 
@@ -38,7 +38,7 @@ export async function getSession(): Promise<Session | null> {
38
38
  const data = await response.json();
39
39
  return data.session || null;
40
40
  } catch (error) {
41
- console.error('[hweb-auth] Erro ao buscar sessão:', error);
41
+ console.error('[hweb-auth] Error fetching session:', error);
42
42
  return null;
43
43
  }
44
44
  }
@@ -59,7 +59,7 @@ export async function getCsrfToken(): Promise<string | null> {
59
59
  const data = await response.json();
60
60
  return data.csrfToken || null;
61
61
  } catch (error) {
62
- console.error('[hweb-auth] Erro ao buscar CSRF token:', error);
62
+ console.error('[hweb-auth] Error fetching CSRF token:', error);
63
63
  return null;
64
64
  }
65
65
  }
@@ -80,7 +80,7 @@ export async function getProviders(): Promise<any[] | null> {
80
80
  const data = await response.json();
81
81
  return data.providers || [];
82
82
  } catch (error) {
83
- console.error('[hweb-auth] Erro ao buscar providers:', error);
83
+ console.error('[hweb-auth] Error searching for providers:', error);
84
84
  return null;
85
85
  }
86
86
  }
@@ -143,7 +143,7 @@ export async function signIn(
143
143
  };
144
144
  }
145
145
  } catch (error) {
146
- console.error('[hweb-auth] Erro no signIn:', error);
146
+ console.error('[hweb-auth] Error on signIn:', error);
147
147
  return {
148
148
  error: 'Network error',
149
149
  status: 500,
@@ -166,6 +166,6 @@ export async function signOut(options: { callbackUrl?: string } = {}): Promise<v
166
166
  window.location.href = options.callbackUrl || '/';
167
167
  }
168
168
  } catch (error) {
169
- console.error('[hweb-auth] Erro no signOut:', error);
169
+ console.error('[hweb-auth] Error on signOut:', error);
170
170
  }
171
171
  }
@@ -37,7 +37,7 @@ export function ProtectedRoute({
37
37
 
38
38
  // Ainda carregando
39
39
  if (isLoading) {
40
- return fallback || <div>Carregando...</div>;
40
+ return fallback || <div>Loading...</div>;
41
41
  }
42
42
 
43
43
  // Requer auth mas não está autenticado
@@ -46,7 +46,7 @@ export function ProtectedRoute({
46
46
  window.location.href = redirectTo;
47
47
  return null;
48
48
  }
49
- return fallback || <div>Não autorizado</div>;
49
+ return fallback || <div>Unauthorized</div>;
50
50
  }
51
51
 
52
52
  // Não requer auth mas está autenticado (ex: página de login)
package/src/auth/core.ts CHANGED
@@ -91,7 +91,7 @@ export class HWebAuth {
91
91
 
92
92
  return sessionResult;
93
93
  } catch (error) {
94
- console.error(`[hweb-auth] Erro no signIn com provider ${providerId}:`, error);
94
+ console.error(`[hweb-auth] Error signing in with provider ${providerId}:`, error);
95
95
  return null;
96
96
  }
97
97
  }
@@ -109,7 +109,7 @@ export class HWebAuth {
109
109
  try {
110
110
  await provider.handleSignOut();
111
111
  } catch (error) {
112
- console.error(`[hweb-auth] Erro no signOut do provider ${provider.id}:`, error);
112
+ console.error(`[hweb-auth] Signout error on provider ${provider.id}:`, error);
113
113
  }
114
114
  }
115
115
  }
@@ -61,7 +61,7 @@ export function SessionProvider({
61
61
  return null;
62
62
  }
63
63
  } catch (error) {
64
- console.error('[hweb-auth] Erro ao buscar sessão:', error);
64
+ console.error('[hweb-auth] Error fetching session:', error);
65
65
  setSession(null);
66
66
  setStatus('unauthenticated');
67
67
  return null;
@@ -125,7 +125,7 @@ export function SessionProvider({
125
125
  };
126
126
  }
127
127
  } catch (error) {
128
- console.error('[hweb-auth] Erro no signIn:', error);
128
+ console.error('[hweb-auth] Error on signIn:', error);
129
129
  return {
130
130
  error: 'Network error',
131
131
  status: 500,
@@ -153,7 +153,7 @@ export function SessionProvider({
153
153
  }
154
154
  }
155
155
  } catch (error) {
156
- console.error('[hweb-auth] Erro no signOut:', error);
156
+ console.error('[hweb-auth] Error on signOut:', error);
157
157
  }
158
158
  }, [basePath]);
159
159
 
@@ -215,7 +215,7 @@ export function SessionProvider({
215
215
  export function useSession(): SessionContextType {
216
216
  const context = useContext(SessionContext);
217
217
  if (context === undefined) {
218
- throw new Error('useSession deve ser usado dentro de um SessionProvider');
218
+ throw new Error('useSession must be used inside a SessionProvider');
219
219
  }
220
220
  return context;
221
221
  }
@@ -167,7 +167,7 @@ async function handleSignIn(req: HightJSRequest, auth: HWebAuth) {
167
167
  type: 'session'
168
168
  });
169
169
  } catch (error) {
170
- console.error('[hweb-auth] Erro no handleSignIn:', error);
170
+ console.error('[hweb-auth] Error on handleSignIn:', error);
171
171
  return HightJSResponse.json(
172
172
  { error: 'Authentication failed' },
173
173
  { status: 500 }