hightjs 0.4.0 → 0.5.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/README.md +48 -116
- package/dist/bin/hightjs.js +51 -23
- package/dist/builder.js +139 -4
- package/dist/client/DefaultNotFound.d.ts +1 -1
- package/dist/client/DefaultNotFound.js +72 -46
- package/dist/client/client.d.ts +3 -0
- package/dist/{client.js → client/client.js} +4 -4
- package/dist/client/entry.client.js +39 -29
- package/dist/global/global.d.ts +117 -0
- package/dist/{auth/types.js → global/global.js} +0 -1
- package/dist/helpers.js +80 -2
- package/dist/hotReload.js +2 -2
- package/dist/index.js +16 -16
- package/dist/loaders.d.ts +1 -0
- package/dist/loaders.js +46 -0
- package/dist/renderer.js +158 -4
- package/dist/types.d.ts +44 -0
- package/package.json +36 -31
- package/.idea/HightJS.iml +0 -9
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/copilotDiffState.xml +0 -67
- package/.idea/inspectionProfiles/Project_Default.xml +0 -13
- package/.idea/libraries/test_package.xml +0 -9
- package/.idea/libraries/ts_commonjs_default_export.xml +0 -9
- package/.idea/misc.xml +0 -7
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/auth/client.d.ts +0 -24
- package/dist/auth/client.js +0 -146
- package/dist/auth/components.d.ts +0 -29
- package/dist/auth/components.js +0 -100
- package/dist/auth/core.d.ts +0 -55
- package/dist/auth/core.js +0 -189
- package/dist/auth/index.d.ts +0 -7
- package/dist/auth/index.js +0 -45
- package/dist/auth/jwt.d.ts +0 -41
- package/dist/auth/jwt.js +0 -185
- package/dist/auth/providers/credentials.d.ts +0 -60
- package/dist/auth/providers/credentials.js +0 -97
- package/dist/auth/providers/discord.d.ts +0 -63
- package/dist/auth/providers/discord.js +0 -190
- package/dist/auth/providers/google.d.ts +0 -63
- package/dist/auth/providers/google.js +0 -186
- package/dist/auth/providers/index.d.ts +0 -2
- package/dist/auth/providers/index.js +0 -35
- package/dist/auth/providers.d.ts +0 -3
- package/dist/auth/providers.js +0 -26
- package/dist/auth/react/index.d.ts +0 -6
- package/dist/auth/react/index.js +0 -48
- package/dist/auth/react.d.ts +0 -22
- package/dist/auth/react.js +0 -199
- package/dist/auth/routes.d.ts +0 -16
- package/dist/auth/routes.js +0 -152
- package/dist/auth/types.d.ts +0 -76
- package/dist/client.d.ts +0 -3
- package/docs/README.md +0 -58
- package/docs/arquivos-especiais.md +0 -10
- package/docs/autenticacao.md +0 -212
- package/docs/checklist.md +0 -9
- package/docs/cli.md +0 -72
- package/docs/config.md +0 -216
- package/docs/estrutura.md +0 -20
- package/docs/faq.md +0 -10
- package/docs/hot-reload.md +0 -5
- package/docs/integracoes.md +0 -240
- package/docs/middlewares.md +0 -73
- package/docs/rotas-backend.md +0 -45
- package/docs/rotas-frontend.md +0 -66
- package/docs/seguranca.md +0 -8
- package/docs/websocket.md +0 -45
- package/example/certs/cert.pem +0 -20
- package/example/certs/key.pem +0 -27
- package/example/hightjs.config.ts +0 -87
- package/example/package-lock.json +0 -1174
- package/example/package.json +0 -26
- package/example/postcss.config.js +0 -8
- package/example/src/backend/auth.ts +0 -42
- package/example/src/backend/routes/auth.ts +0 -3
- package/example/src/backend/routes/version.ts +0 -13
- package/example/src/web/components/Home.tsx +0 -140
- package/example/src/web/components/LoginPage.tsx +0 -149
- package/example/src/web/globals.css +0 -5
- package/example/src/web/layout.tsx +0 -100
- package/example/src/web/routes/index.tsx +0 -13
- package/example/src/web/routes/login.tsx +0 -30
- package/example/tailwind.config.js +0 -12
- package/example/tsconfig.json +0 -15
- package/src/adapters/express.ts +0 -87
- package/src/adapters/factory.ts +0 -112
- package/src/adapters/fastify.ts +0 -104
- package/src/adapters/native.ts +0 -234
- package/src/api/console.ts +0 -305
- package/src/api/http.ts +0 -535
- package/src/auth/client.ts +0 -171
- package/src/auth/components.tsx +0 -125
- package/src/auth/core.ts +0 -215
- package/src/auth/index.ts +0 -25
- package/src/auth/jwt.ts +0 -210
- package/src/auth/providers/credentials.ts +0 -139
- package/src/auth/providers/discord.ts +0 -239
- package/src/auth/providers/google.ts +0 -234
- package/src/auth/providers/index.ts +0 -20
- package/src/auth/providers.ts +0 -20
- package/src/auth/react/index.ts +0 -25
- package/src/auth/react.tsx +0 -234
- package/src/auth/routes.ts +0 -183
- package/src/auth/types.ts +0 -108
- package/src/bin/hightjs.js +0 -222
- package/src/builder.js +0 -472
- package/src/client/DefaultNotFound.tsx +0 -84
- package/src/client/clientRouter.ts +0 -153
- package/src/client/entry.client.tsx +0 -511
- package/src/client.ts +0 -24
- package/src/components/Link.tsx +0 -38
- package/src/helpers.ts +0 -542
- package/src/hotReload.ts +0 -569
- package/src/index.ts +0 -555
- package/src/renderer.tsx +0 -263
- package/src/router.ts +0 -730
- package/src/types/framework.ts +0 -58
- package/src/types.ts +0 -207
- package/tsconfig.json +0 -17
package/dist/auth/react.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SessionProvider = SessionProvider;
|
|
4
|
-
exports.useSession = useSession;
|
|
5
|
-
exports.useAuth = useAuth;
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
/*
|
|
8
|
-
* This file is part of the HightJS Project.
|
|
9
|
-
* Copyright (c) 2025 itsmuzin
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
const react_1 = require("react");
|
|
24
|
-
const clientRouter_1 = require("../client/clientRouter");
|
|
25
|
-
const SessionContext = (0, react_1.createContext)(undefined);
|
|
26
|
-
function SessionProvider({ children, basePath = '/api/auth', refetchInterval = 0, refetchOnWindowFocus = true }) {
|
|
27
|
-
const [session, setSession] = (0, react_1.useState)(null);
|
|
28
|
-
const [status, setStatus] = (0, react_1.useState)('loading');
|
|
29
|
-
// Fetch da sessão atual
|
|
30
|
-
const fetchSession = (0, react_1.useCallback)(async () => {
|
|
31
|
-
try {
|
|
32
|
-
const response = await fetch(`${basePath}/session`, {
|
|
33
|
-
credentials: 'include'
|
|
34
|
-
});
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
setStatus('unauthenticated');
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const data = await response.json();
|
|
40
|
-
const sessionData = data.session;
|
|
41
|
-
if (sessionData) {
|
|
42
|
-
setSession(sessionData);
|
|
43
|
-
setStatus('authenticated');
|
|
44
|
-
return sessionData;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
setSession(null);
|
|
48
|
-
setStatus('unauthenticated');
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
console.error('[hweb-auth] Error fetching session:', error);
|
|
54
|
-
setSession(null);
|
|
55
|
-
setStatus('unauthenticated');
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}, [basePath]);
|
|
59
|
-
// SignIn function
|
|
60
|
-
const signIn = (0, react_1.useCallback)(async (provider = 'credentials', options = {}) => {
|
|
61
|
-
try {
|
|
62
|
-
const { redirect = true, callbackUrl, ...credentials } = options;
|
|
63
|
-
const response = await fetch(`${basePath}/signin`, {
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type': 'application/json',
|
|
67
|
-
},
|
|
68
|
-
credentials: 'include',
|
|
69
|
-
body: JSON.stringify({
|
|
70
|
-
provider,
|
|
71
|
-
...credentials
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
const data = await response.json();
|
|
75
|
-
if (response.ok && data.success) {
|
|
76
|
-
await fetchSession();
|
|
77
|
-
// Se é OAuth, redireciona para URL fornecida
|
|
78
|
-
if (data.type === 'oauth' && data.redirectUrl) {
|
|
79
|
-
if (redirect && typeof window !== 'undefined') {
|
|
80
|
-
window.location.href = data.redirectUrl;
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
ok: true,
|
|
84
|
-
status: 200,
|
|
85
|
-
url: data.redirectUrl
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
// Se é sessão (credentials), redireciona para callbackUrl
|
|
89
|
-
if (data.type === 'session') {
|
|
90
|
-
if (redirect && typeof window !== 'undefined') {
|
|
91
|
-
window.location.href = callbackUrl || '/';
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
ok: true,
|
|
95
|
-
status: 200,
|
|
96
|
-
url: callbackUrl || '/'
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return {
|
|
102
|
-
error: data.error || 'Authentication failed',
|
|
103
|
-
status: response.status,
|
|
104
|
-
ok: false
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
console.error('[hweb-auth] Error on signIn:', error);
|
|
110
|
-
return {
|
|
111
|
-
error: 'Network error',
|
|
112
|
-
status: 500,
|
|
113
|
-
ok: false
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}, [basePath, fetchSession]);
|
|
117
|
-
// SignOut function
|
|
118
|
-
const signOut = (0, react_1.useCallback)(async (options = {}) => {
|
|
119
|
-
try {
|
|
120
|
-
await fetch(`${basePath}/signout`, {
|
|
121
|
-
method: 'POST',
|
|
122
|
-
credentials: 'include'
|
|
123
|
-
});
|
|
124
|
-
setSession(null);
|
|
125
|
-
setStatus('unauthenticated');
|
|
126
|
-
if (typeof window !== 'undefined') {
|
|
127
|
-
try {
|
|
128
|
-
clientRouter_1.router.push(options.callbackUrl || '/');
|
|
129
|
-
}
|
|
130
|
-
catch (e) {
|
|
131
|
-
window.location.href = options.callbackUrl || '/';
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
console.error('[hweb-auth] Error on signOut:', error);
|
|
137
|
-
}
|
|
138
|
-
}, [basePath]);
|
|
139
|
-
// Update session
|
|
140
|
-
const update = (0, react_1.useCallback)(async () => {
|
|
141
|
-
return await fetchSession();
|
|
142
|
-
}, [fetchSession]);
|
|
143
|
-
// Initial session fetch
|
|
144
|
-
(0, react_1.useEffect)(() => {
|
|
145
|
-
fetchSession();
|
|
146
|
-
}, [fetchSession]);
|
|
147
|
-
// Refetch interval
|
|
148
|
-
(0, react_1.useEffect)(() => {
|
|
149
|
-
if (refetchInterval > 0) {
|
|
150
|
-
const interval = setInterval(() => {
|
|
151
|
-
if (status === 'authenticated') {
|
|
152
|
-
fetchSession();
|
|
153
|
-
}
|
|
154
|
-
}, refetchInterval * 1000);
|
|
155
|
-
return () => clearInterval(interval);
|
|
156
|
-
}
|
|
157
|
-
}, [refetchInterval, status, fetchSession]);
|
|
158
|
-
// Refetch on window focus
|
|
159
|
-
(0, react_1.useEffect)(() => {
|
|
160
|
-
if (refetchOnWindowFocus) {
|
|
161
|
-
const handleFocus = () => {
|
|
162
|
-
if (status === 'authenticated') {
|
|
163
|
-
fetchSession();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
window.addEventListener('focus', handleFocus);
|
|
167
|
-
return () => window.removeEventListener('focus', handleFocus);
|
|
168
|
-
}
|
|
169
|
-
}, [refetchOnWindowFocus, status, fetchSession]);
|
|
170
|
-
const value = {
|
|
171
|
-
data: session,
|
|
172
|
-
status,
|
|
173
|
-
signIn,
|
|
174
|
-
signOut,
|
|
175
|
-
update
|
|
176
|
-
};
|
|
177
|
-
return ((0, jsx_runtime_1.jsx)(SessionContext.Provider, { value: value, children: children }));
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Hook para acessar a sessão atual
|
|
181
|
-
*/
|
|
182
|
-
function useSession() {
|
|
183
|
-
const context = (0, react_1.useContext)(SessionContext);
|
|
184
|
-
if (context === undefined) {
|
|
185
|
-
throw new Error('useSession must be used inside a SessionProvider');
|
|
186
|
-
}
|
|
187
|
-
return context;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Hook para verificar se o usuário está autenticado
|
|
191
|
-
*/
|
|
192
|
-
function useAuth() {
|
|
193
|
-
const { data: session, status } = useSession();
|
|
194
|
-
return {
|
|
195
|
-
user: session?.user || null,
|
|
196
|
-
isAuthenticated: status === 'authenticated',
|
|
197
|
-
isLoading: status === 'loading'
|
|
198
|
-
};
|
|
199
|
-
}
|
package/dist/auth/routes.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { HightJSRequest } from '../api/http';
|
|
2
|
-
import type { AuthConfig } from './types';
|
|
3
|
-
import { HWebAuth } from './core';
|
|
4
|
-
/**
|
|
5
|
-
* Cria o handler catch-all para /api/auth/[...value]
|
|
6
|
-
*/
|
|
7
|
-
export declare function createAuthRoutes(config: AuthConfig): {
|
|
8
|
-
pattern: string;
|
|
9
|
-
GET(req: HightJSRequest, params: {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
}): Promise<any>;
|
|
12
|
-
POST(req: HightJSRequest, params: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
}): Promise<any>;
|
|
15
|
-
auth: HWebAuth;
|
|
16
|
-
};
|
package/dist/auth/routes.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAuthRoutes = createAuthRoutes;
|
|
4
|
-
/*
|
|
5
|
-
* This file is part of the HightJS Project.
|
|
6
|
-
* Copyright (c) 2025 itsmuzin
|
|
7
|
-
*
|
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
const http_1 = require("../api/http");
|
|
21
|
-
const core_1 = require("./core");
|
|
22
|
-
/**
|
|
23
|
-
* Cria o handler catch-all para /api/auth/[...value]
|
|
24
|
-
*/
|
|
25
|
-
function createAuthRoutes(config) {
|
|
26
|
-
const auth = new core_1.HWebAuth(config);
|
|
27
|
-
/**
|
|
28
|
-
* Handler principal que gerencia todas as rotas de auth
|
|
29
|
-
* Uso: /api/auth/[...value].ts
|
|
30
|
-
*/
|
|
31
|
-
return {
|
|
32
|
-
pattern: '/api/auth/[...value]',
|
|
33
|
-
async GET(req, params) {
|
|
34
|
-
const path = params["value"];
|
|
35
|
-
const route = Array.isArray(path) ? path.join('/') : path || '';
|
|
36
|
-
// Verifica rotas adicionais dos providers primeiro
|
|
37
|
-
const additionalRoutes = auth.getAllAdditionalRoutes();
|
|
38
|
-
for (const { provider, route: additionalRoute } of additionalRoutes) {
|
|
39
|
-
if (additionalRoute.method === 'GET' && additionalRoute.path.includes(route)) {
|
|
40
|
-
try {
|
|
41
|
-
return await additionalRoute.handler(req, params);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
console.error(`[${provider} Provider] Error in additional route:`, error);
|
|
45
|
-
return http_1.HightJSResponse.json({ error: 'Provider route error' }, { status: 500 });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// Rotas padrão do sistema
|
|
50
|
-
switch (route) {
|
|
51
|
-
case 'session':
|
|
52
|
-
return await handleSession(req, auth);
|
|
53
|
-
case 'csrf':
|
|
54
|
-
return await handleCsrf(req);
|
|
55
|
-
case 'providers':
|
|
56
|
-
return await handleProviders(auth);
|
|
57
|
-
default:
|
|
58
|
-
return http_1.HightJSResponse.json({ error: 'Route not found' }, { status: 404 });
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
async POST(req, params) {
|
|
62
|
-
const path = params["value"];
|
|
63
|
-
const route = Array.isArray(path) ? path.join('/') : path || '';
|
|
64
|
-
// Verifica rotas adicionais dos providers primeiro
|
|
65
|
-
const additionalRoutes = auth.getAllAdditionalRoutes();
|
|
66
|
-
for (const { provider, route: additionalRoute } of additionalRoutes) {
|
|
67
|
-
if (additionalRoute.method === 'POST' && additionalRoute.path.includes(route)) {
|
|
68
|
-
try {
|
|
69
|
-
return await additionalRoute.handler(req, params);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error(`[${provider} Provider] Error in additional route:`, error);
|
|
73
|
-
return http_1.HightJSResponse.json({ error: 'Provider route error' }, { status: 500 });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Rotas padrão do sistema
|
|
78
|
-
switch (route) {
|
|
79
|
-
case 'signin':
|
|
80
|
-
return await handleSignIn(req, auth);
|
|
81
|
-
case 'signout':
|
|
82
|
-
return await handleSignOut(req, auth);
|
|
83
|
-
default:
|
|
84
|
-
return http_1.HightJSResponse.json({ error: 'Route not found' }, { status: 404 });
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
// Instância do auth para uso manual
|
|
88
|
-
auth
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Handler para GET /api/auth/session
|
|
93
|
-
*/
|
|
94
|
-
async function handleSession(req, auth) {
|
|
95
|
-
const session = await auth.getSession(req);
|
|
96
|
-
if (!session) {
|
|
97
|
-
return http_1.HightJSResponse.json({ session: null });
|
|
98
|
-
}
|
|
99
|
-
return http_1.HightJSResponse.json({ session });
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Handler para GET /api/auth/csrf
|
|
103
|
-
*/
|
|
104
|
-
async function handleCsrf(req) {
|
|
105
|
-
// Token CSRF simples para proteção
|
|
106
|
-
const csrfToken = Math.random().toString(36).substring(2, 15) +
|
|
107
|
-
Math.random().toString(36).substring(2, 15);
|
|
108
|
-
return http_1.HightJSResponse.json({ csrfToken });
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Handler para GET /api/auth/providers
|
|
112
|
-
*/
|
|
113
|
-
async function handleProviders(auth) {
|
|
114
|
-
const providers = auth.getProviders();
|
|
115
|
-
return http_1.HightJSResponse.json({ providers });
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Handler para POST /api/auth/signin
|
|
119
|
-
*/
|
|
120
|
-
async function handleSignIn(req, auth) {
|
|
121
|
-
try {
|
|
122
|
-
const { provider = 'credentials', ...credentials } = await req.json();
|
|
123
|
-
const result = await auth.signIn(provider, credentials);
|
|
124
|
-
if (!result) {
|
|
125
|
-
return http_1.HightJSResponse.json({ error: 'Invalid credentials' }, { status: 401 });
|
|
126
|
-
}
|
|
127
|
-
// Se tem redirectUrl, é OAuth - retorna URL para redirecionamento
|
|
128
|
-
if ('redirectUrl' in result) {
|
|
129
|
-
return http_1.HightJSResponse.json({
|
|
130
|
-
success: true,
|
|
131
|
-
redirectUrl: result.redirectUrl,
|
|
132
|
-
type: 'oauth'
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
// Se tem session, é credentials - retorna sessão
|
|
136
|
-
return auth.createAuthResponse(result.token, {
|
|
137
|
-
success: true,
|
|
138
|
-
user: result.session.user,
|
|
139
|
-
type: 'session'
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
console.error('[hweb-auth] Error on handleSignIn:', error);
|
|
144
|
-
return http_1.HightJSResponse.json({ error: 'Authentication failed' }, { status: 500 });
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Handler para POST /api/auth/signout
|
|
149
|
-
*/
|
|
150
|
-
async function handleSignOut(req, auth) {
|
|
151
|
-
return await auth.signOut(req);
|
|
152
|
-
}
|
package/dist/auth/types.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export type User = Record<string, any>;
|
|
2
|
-
export interface Session {
|
|
3
|
-
user: User;
|
|
4
|
-
expires: string;
|
|
5
|
-
accessToken?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SignInOptions {
|
|
8
|
-
redirect?: boolean;
|
|
9
|
-
callbackUrl?: string;
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}
|
|
12
|
-
export interface SignInResult {
|
|
13
|
-
error?: string;
|
|
14
|
-
status?: number;
|
|
15
|
-
ok?: boolean;
|
|
16
|
-
url?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface SessionContextType {
|
|
19
|
-
data: Session | null;
|
|
20
|
-
status: 'loading' | 'authenticated' | 'unauthenticated';
|
|
21
|
-
signIn: (provider?: string, options?: SignInOptions) => Promise<SignInResult | undefined>;
|
|
22
|
-
signOut: (options?: {
|
|
23
|
-
callbackUrl?: string;
|
|
24
|
-
}) => Promise<void>;
|
|
25
|
-
update: () => Promise<Session | null>;
|
|
26
|
-
}
|
|
27
|
-
export interface AuthRoute {
|
|
28
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
29
|
-
path: string;
|
|
30
|
-
handler: (req: any, params: any) => Promise<any>;
|
|
31
|
-
}
|
|
32
|
-
export interface AuthProviderClass {
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
type: string;
|
|
36
|
-
handleOauth?(credentials: Record<string, string>): Promise<string> | string;
|
|
37
|
-
handleSignIn(credentials: Record<string, string>): Promise<User | string | null>;
|
|
38
|
-
handleSignOut?(): Promise<void>;
|
|
39
|
-
additionalRoutes?: AuthRoute[];
|
|
40
|
-
getConfig?(): any;
|
|
41
|
-
}
|
|
42
|
-
export interface AuthConfig {
|
|
43
|
-
providers: AuthProviderClass[];
|
|
44
|
-
pages?: {
|
|
45
|
-
signIn?: string;
|
|
46
|
-
signOut?: string;
|
|
47
|
-
error?: string;
|
|
48
|
-
};
|
|
49
|
-
callbacks?: {
|
|
50
|
-
signIn?: (user: User, account: any, profile: any) => boolean | Promise<boolean>;
|
|
51
|
-
session?: ({ session, user, provider }: {
|
|
52
|
-
session: Session;
|
|
53
|
-
user: User;
|
|
54
|
-
provider: string;
|
|
55
|
-
}) => Session | Promise<Session>;
|
|
56
|
-
jwt?: (token: any, user: User, account: any, profile: any) => any | Promise<any>;
|
|
57
|
-
};
|
|
58
|
-
session?: {
|
|
59
|
-
strategy?: 'jwt' | 'database';
|
|
60
|
-
maxAge?: number;
|
|
61
|
-
updateAge?: number;
|
|
62
|
-
};
|
|
63
|
-
secret?: string;
|
|
64
|
-
debug?: boolean;
|
|
65
|
-
secureCookies?: boolean;
|
|
66
|
-
}
|
|
67
|
-
export interface CredentialsConfig {
|
|
68
|
-
id?: string;
|
|
69
|
-
name?: string;
|
|
70
|
-
credentials: Record<string, {
|
|
71
|
-
label: string;
|
|
72
|
-
type: string;
|
|
73
|
-
placeholder?: string;
|
|
74
|
-
}>;
|
|
75
|
-
authorize: (credentials: Record<string, string>) => Promise<User | null> | User | null;
|
|
76
|
-
}
|
package/dist/client.d.ts
DELETED
package/docs/README.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# 📚 Documentação HightJS
|
|
2
|
-
|
|
3
|
-
Bem-vindo à documentação completa do HightJS!
|
|
4
|
-
|
|
5
|
-
## 📑 Índice
|
|
6
|
-
|
|
7
|
-
### Fundamentos
|
|
8
|
-
- [📦 Estrutura Recomendada](./estrutura.md) - Como organizar seu projeto
|
|
9
|
-
- [🖥️ Rotas Frontend](./rotas-frontend.md) - Criando páginas React
|
|
10
|
-
- [🌐 Rotas Backend](./rotas-backend.md) - Criando APIs e endpoints
|
|
11
|
-
|
|
12
|
-
### Recursos Avançados
|
|
13
|
-
- [🛜 WebSocket](./websocket.md) - Comunicação em tempo real
|
|
14
|
-
- [🧩 Middlewares](./middlewares.md) - Interceptando requisições
|
|
15
|
-
- [🔐 Autenticação](./autenticacao.md) - Sistema JWT integrado
|
|
16
|
-
|
|
17
|
-
### Ferramentas e Configuração
|
|
18
|
-
- [🛠️ CLI](./cli.md) - Comandos e opções
|
|
19
|
-
- [📂 Arquivos Especiais](./arquivos-especiais.md) - Arquivos com funções especiais
|
|
20
|
-
- [🔌 Integrações](./integracoes.md) - Como integrar com Express, Fastify e usar SSL
|
|
21
|
-
- [🔐 Segurança Interna](./seguranca.md) - Proteções nativas
|
|
22
|
-
- [♻️ Hot Reload](./hot-reload.md) - Desenvolvimento com recarregamento automático
|
|
23
|
-
|
|
24
|
-
### Ajuda
|
|
25
|
-
- [❓ FAQ Rápido](./faq.md) - Perguntas frequentes
|
|
26
|
-
- [✅ Checklist Mental](./checklist.md) - Guia rápido de referência
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## 🚀 Início Rápido
|
|
31
|
-
|
|
32
|
-
Se você está começando agora, recomendamos seguir esta ordem:
|
|
33
|
-
|
|
34
|
-
1. [Estrutura Recomendada](./estrutura.md) - Entenda como organizar seu projeto
|
|
35
|
-
2. [Rotas Frontend](./rotas-frontend.md) - Crie sua primeira página
|
|
36
|
-
3. [Rotas Backend](./rotas-backend.md) - Crie sua primeira API
|
|
37
|
-
4. [CLI](./cli.md) - Aprenda os comandos básicos
|
|
38
|
-
|
|
39
|
-
## 💡 Recursos Avançados
|
|
40
|
-
|
|
41
|
-
Quando estiver confortável com o básico, explore:
|
|
42
|
-
|
|
43
|
-
- [Autenticação](./autenticacao.md) - Adicione login e proteção de rotas
|
|
44
|
-
- [WebSocket](./websocket.md) - Implemente recursos em tempo real
|
|
45
|
-
- [Middlewares](./middlewares.md) - Adicione lógica customizada nas requisições
|
|
46
|
-
|
|
47
|
-
## 📖 Referência Completa
|
|
48
|
-
|
|
49
|
-
Consulte estas páginas quando precisar de informações específicas:
|
|
50
|
-
|
|
51
|
-
- [Arquivos Especiais](./arquivos-especiais.md) - Todos os arquivos especiais do framework
|
|
52
|
-
- [Segurança Interna](./seguranca.md) - Como o HightJS protege sua aplicação
|
|
53
|
-
- [Hot Reload](./hot-reload.md) - Como funciona o recarregamento automático
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
Voltar para o [README principal](../README.md)
|
|
58
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# 📂 Arquivos Especiais
|
|
2
|
-
|
|
3
|
-
| Arquivo | Localização | Função |
|
|
4
|
-
|-----------------------------|---------------------------------------|------------------------------------------------|
|
|
5
|
-
| `layout.tsx` | `/src/web` | Layout global + `export const metadata` |
|
|
6
|
-
| `notFound.tsx` | `/src/web` | Página 404 customizada |
|
|
7
|
-
| `middleware.ts` | dentro de `/src/web/backend/routes` | Middlewares globais por pasta backend |
|
|
8
|
-
| `hightweb.ts` / `.tsx` | `/src/hightweb` | Instrumentação opcional executada no boot |
|
|
9
|
-
| `public/` | `/public` | Arquivos estáticos servidos diretamente |
|
|
10
|
-
|