hightjs 0.2.3 → 0.2.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.
- package/dist/adapters/native.js +0 -5
- package/dist/auth/providers/credentials.d.ts +1 -9
- package/dist/auth/providers/credentials.js +0 -35
- package/dist/auth/providers/discord.d.ts +0 -4
- package/dist/auth/providers/discord.js +0 -8
- package/dist/auth/react.js +1 -0
- package/package.json +1 -1
- package/src/adapters/native.ts +0 -5
- package/src/auth/providers/credentials.ts +0 -35
- package/src/auth/providers/discord.ts +1 -9
- package/src/auth/react.tsx +1 -0
package/dist/adapters/native.js
CHANGED
|
@@ -90,11 +90,6 @@ class NativeResponseWrapper {
|
|
|
90
90
|
if (name !== sanitizedName || String(value) !== sanitizedValue) {
|
|
91
91
|
console.warn(`Aviso: Tentativa potencial de HTTP Header Injection foi detectada e sanitizada. Header original: "${name}"`);
|
|
92
92
|
}
|
|
93
|
-
// Evita setar o header 'Set-Cookie' diretamente para não conflitar com o método cookie().
|
|
94
|
-
if (sanitizedName.toLowerCase() === 'set-cookie') {
|
|
95
|
-
console.warn(`Aviso: Use o método .cookie() para definir cookies, não o .header().`);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
93
|
this.headers[sanitizedName] = sanitizedValue;
|
|
99
94
|
return this;
|
|
100
95
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthProviderClass, User
|
|
1
|
+
import type { AuthProviderClass, User } from '../types';
|
|
2
2
|
export interface CredentialsConfig {
|
|
3
3
|
id?: string;
|
|
4
4
|
name?: string;
|
|
@@ -45,14 +45,6 @@ export declare class CredentialsProvider implements AuthProviderClass {
|
|
|
45
45
|
* Método principal para autenticar usuário com credenciais
|
|
46
46
|
*/
|
|
47
47
|
handleSignIn(credentials: Record<string, string>): Promise<User | null>;
|
|
48
|
-
/**
|
|
49
|
-
* Método opcional para logout (pode ser sobrescrito se necessário)
|
|
50
|
-
*/
|
|
51
|
-
handleSignOut?(): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Rotas adicionais específicas do provider (opcional)
|
|
54
|
-
*/
|
|
55
|
-
additionalRoutes?: AuthRoute[];
|
|
56
48
|
/**
|
|
57
49
|
* Retorna configuração pública do provider
|
|
58
50
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CredentialsProvider = void 0;
|
|
4
|
-
const http_1 = require("../../api/http");
|
|
5
4
|
/**
|
|
6
5
|
* Provider para autenticação com credenciais (email/senha)
|
|
7
6
|
*
|
|
@@ -31,32 +30,6 @@ const http_1 = require("../../api/http");
|
|
|
31
30
|
class CredentialsProvider {
|
|
32
31
|
constructor(config) {
|
|
33
32
|
this.type = 'credentials';
|
|
34
|
-
/**
|
|
35
|
-
* Rotas adicionais específicas do provider (opcional)
|
|
36
|
-
*/
|
|
37
|
-
this.additionalRoutes = [
|
|
38
|
-
{
|
|
39
|
-
method: 'GET',
|
|
40
|
-
path: '/api/auth/credentials/config',
|
|
41
|
-
handler: async (req, params) => {
|
|
42
|
-
// Retorna configuração das credenciais (sem dados sensíveis)
|
|
43
|
-
const safeConfig = {
|
|
44
|
-
id: this.id,
|
|
45
|
-
name: this.name,
|
|
46
|
-
type: this.type,
|
|
47
|
-
credentials: Object.entries(this.config.credentials).reduce((acc, [key, field]) => {
|
|
48
|
-
acc[key] = {
|
|
49
|
-
label: field.label,
|
|
50
|
-
type: field.type,
|
|
51
|
-
placeholder: field.placeholder
|
|
52
|
-
};
|
|
53
|
-
return acc;
|
|
54
|
-
}, {})
|
|
55
|
-
};
|
|
56
|
-
return http_1.HightJSResponse.json({ config: safeConfig });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
];
|
|
60
33
|
this.config = config;
|
|
61
34
|
this.id = config.id || 'credentials';
|
|
62
35
|
this.name = config.name || 'Credentials';
|
|
@@ -85,14 +58,6 @@ class CredentialsProvider {
|
|
|
85
58
|
return null;
|
|
86
59
|
}
|
|
87
60
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Método opcional para logout (pode ser sobrescrito se necessário)
|
|
90
|
-
*/
|
|
91
|
-
async handleSignOut() {
|
|
92
|
-
// Credentials provider não precisa fazer nada específico no logout
|
|
93
|
-
// O core já cuida de limpar cookies e tokens
|
|
94
|
-
console.log(`[${this.id} Provider] User signed out`);
|
|
95
|
-
}
|
|
96
61
|
/**
|
|
97
62
|
* Retorna configuração pública do provider
|
|
98
63
|
*/
|
|
@@ -48,10 +48,6 @@ export declare class DiscordProvider implements AuthProviderClass {
|
|
|
48
48
|
* Processa o callback OAuth (código → usuário)
|
|
49
49
|
*/
|
|
50
50
|
private processOAuthCallback;
|
|
51
|
-
/**
|
|
52
|
-
* Método opcional para logout
|
|
53
|
-
*/
|
|
54
|
-
handleSignOut?(): Promise<void>;
|
|
55
51
|
/**
|
|
56
52
|
* Rotas adicionais específicas do Discord OAuth
|
|
57
53
|
*/
|
|
@@ -161,14 +161,6 @@ class DiscordProvider {
|
|
|
161
161
|
return null;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Método opcional para logout
|
|
166
|
-
*/
|
|
167
|
-
async handleSignOut() {
|
|
168
|
-
// Discord OAuth não precisa de logout especial
|
|
169
|
-
// O token será invalidado pelo tempo de vida
|
|
170
|
-
console.log(`[${this.id} Provider] User signed out`);
|
|
171
|
-
}
|
|
172
164
|
/**
|
|
173
165
|
* Gera URL de autorização do Discord
|
|
174
166
|
*/
|
package/dist/auth/react.js
CHANGED
|
@@ -57,6 +57,7 @@ function SessionProvider({ children, basePath = '/api/auth', refetchInterval = 0
|
|
|
57
57
|
});
|
|
58
58
|
const data = await response.json();
|
|
59
59
|
if (response.ok && data.success) {
|
|
60
|
+
await fetchSession();
|
|
60
61
|
// Se é OAuth, redireciona para URL fornecida
|
|
61
62
|
if (data.type === 'oauth' && data.redirectUrl) {
|
|
62
63
|
if (redirect && typeof window !== 'undefined') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hightjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.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",
|
package/src/adapters/native.ts
CHANGED
|
@@ -101,11 +101,6 @@ class NativeResponseWrapper implements GenericResponse {
|
|
|
101
101
|
console.warn(`Aviso: Tentativa potencial de HTTP Header Injection foi detectada e sanitizada. Header original: "${name}"`);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
// Evita setar o header 'Set-Cookie' diretamente para não conflitar com o método cookie().
|
|
105
|
-
if (sanitizedName.toLowerCase() === 'set-cookie') {
|
|
106
|
-
console.warn(`Aviso: Use o método .cookie() para definir cookies, não o .header().`);
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
104
|
|
|
110
105
|
this.headers[sanitizedName] = sanitizedValue;
|
|
111
106
|
return this;
|
|
@@ -79,42 +79,7 @@ export class CredentialsProvider implements AuthProviderClass {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Método opcional para logout (pode ser sobrescrito se necessário)
|
|
84
|
-
*/
|
|
85
|
-
async handleSignOut?(): Promise<void> {
|
|
86
|
-
// Credentials provider não precisa fazer nada específico no logout
|
|
87
|
-
// O core já cuida de limpar cookies e tokens
|
|
88
|
-
console.log(`[${this.id} Provider] User signed out`);
|
|
89
|
-
}
|
|
90
82
|
|
|
91
|
-
/**
|
|
92
|
-
* Rotas adicionais específicas do provider (opcional)
|
|
93
|
-
*/
|
|
94
|
-
public additionalRoutes?: AuthRoute[] = [
|
|
95
|
-
{
|
|
96
|
-
method: 'GET',
|
|
97
|
-
path: '/api/auth/credentials/config',
|
|
98
|
-
handler: async (req: HightJSRequest, params: any) => {
|
|
99
|
-
// Retorna configuração das credenciais (sem dados sensíveis)
|
|
100
|
-
const safeConfig = {
|
|
101
|
-
id: this.id,
|
|
102
|
-
name: this.name,
|
|
103
|
-
type: this.type,
|
|
104
|
-
credentials: Object.entries(this.config.credentials).reduce((acc, [key, field]) => {
|
|
105
|
-
acc[key] = {
|
|
106
|
-
label: field.label,
|
|
107
|
-
type: field.type,
|
|
108
|
-
placeholder: field.placeholder
|
|
109
|
-
};
|
|
110
|
-
return acc;
|
|
111
|
-
}, {} as Record<string, any>)
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
return HightJSResponse.json({ config: safeConfig });
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
];
|
|
118
83
|
|
|
119
84
|
/**
|
|
120
85
|
* Retorna configuração pública do provider
|
|
@@ -136,15 +136,6 @@ export class DiscordProvider implements AuthProviderClass {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
/**
|
|
140
|
-
* Método opcional para logout
|
|
141
|
-
*/
|
|
142
|
-
async handleSignOut?(): Promise<void> {
|
|
143
|
-
// Discord OAuth não precisa de logout especial
|
|
144
|
-
// O token será invalidado pelo tempo de vida
|
|
145
|
-
console.log(`[${this.id} Provider] User signed out`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
139
|
/**
|
|
149
140
|
* Rotas adicionais específicas do Discord OAuth
|
|
150
141
|
*/
|
|
@@ -180,6 +171,7 @@ export class DiscordProvider implements AuthProviderClass {
|
|
|
180
171
|
// Propaga o cookie de sessão retornado pelo endpoint de signin
|
|
181
172
|
// e redireciona o usuário para a página de sucesso.
|
|
182
173
|
const setCookieHeader = authResponse.headers.get('set-cookie');
|
|
174
|
+
|
|
183
175
|
if(this.config.successUrl) {
|
|
184
176
|
return HightJSResponse
|
|
185
177
|
.redirect(this.config.successUrl)
|
package/src/auth/react.tsx
CHANGED
|
@@ -75,6 +75,7 @@ export function SessionProvider({
|
|
|
75
75
|
const data = await response.json();
|
|
76
76
|
|
|
77
77
|
if (response.ok && data.success) {
|
|
78
|
+
await fetchSession();
|
|
78
79
|
// Se é OAuth, redireciona para URL fornecida
|
|
79
80
|
if (data.type === 'oauth' && data.redirectUrl) {
|
|
80
81
|
if (redirect && typeof window !== 'undefined') {
|