@hightjs/auth 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 +65 -0
- package/dist/components.d.ts +0 -10
- package/dist/components.js +0 -27
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -2
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://repository-images.githubusercontent.com/1069175740/e5c59d3a-e1fd-446c-a89f-785ed08f6a16">
|
|
4
|
+
<img alt="HightJS logo" src="https://repository-images.githubusercontent.com/1069175740/e5c59d3a-e1fd-446c-a89f-785ed08f6a16" height="128">
|
|
5
|
+
</picture>
|
|
6
|
+
<h1>@hightjs/auth</h1>
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/@hightjs/auth)
|
|
9
|
+
[](../../LICENSE)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
> Official authentication package for **[HightJS](https://www.npmjs.com/package/hightjs)** - Powerful, secure, and flexible authentication system with JWT, OAuth providers, and session management.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ✨ Why @hightjs/auth?
|
|
18
|
+
|
|
19
|
+
A complete authentication solution built specifically for HightJS framework:
|
|
20
|
+
|
|
21
|
+
- **🔐 Secure by Default** - Industry-standard JWT implementation
|
|
22
|
+
- **🎯 Multiple Providers** - OAuth, credentials, and custom providers
|
|
23
|
+
- **⚛️ React Ready** - Built-in hooks and components
|
|
24
|
+
- **🛡️ Type-Safe** - Full TypeScript support
|
|
25
|
+
- **🚀 Zero Config** - Works out of the box
|
|
26
|
+
- **🔒 Production Ready** - HTTP-only cookies, CSRF protection, and more
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 📦 Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install hightjs @hightjs/auth
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 📚 Documentation
|
|
39
|
+
|
|
40
|
+
For complete documentation, installation guides, and tutorials, visit:
|
|
41
|
+
|
|
42
|
+
**[https://docs.hgo.me](https://docs.hgo.me)**
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 💬 Need Help?
|
|
47
|
+
|
|
48
|
+
If you have questions or need support, feel free to reach out:
|
|
49
|
+
|
|
50
|
+
[](https://discord.com/users/1264710048786026588)
|
|
51
|
+
[](mailto:murillofrazaocunha@gmail.com)
|
|
52
|
+
[](https://instagram.com/itsmuh_)
|
|
53
|
+
[](https://github.com/murillo-frazao-cunha)
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🪪 License
|
|
58
|
+
|
|
59
|
+
Copyright 2025 itsmuzin
|
|
60
|
+
|
|
61
|
+
This project is licensed under the [Apache License 2.0](../../LICENSE).
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
|
package/dist/components.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
interface ProtectedRouteProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
fallback?: ReactNode;
|
|
5
|
-
redirectTo?: string;
|
|
6
|
-
requireAuth?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Componente para proteger rotas que requerem autenticação
|
|
10
|
-
*/
|
|
11
|
-
export declare function ProtectedRoute({ children, fallback, redirectTo, requireAuth }: ProtectedRouteProps): string | number | bigint | true | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null;
|
|
12
2
|
interface GuardProps {
|
|
13
3
|
children: ReactNode;
|
|
14
4
|
fallback?: ReactNode;
|
package/dist/components.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ProtectedRoute = ProtectedRoute;
|
|
7
6
|
exports.AuthGuard = AuthGuard;
|
|
8
7
|
exports.GuestOnly = GuestOnly;
|
|
9
8
|
exports.useAuthRedirect = useAuthRedirect;
|
|
@@ -27,32 +26,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
27
26
|
const react_1 = __importDefault(require("react"));
|
|
28
27
|
const react_2 = require("./react");
|
|
29
28
|
const react_3 = require("hightjs/react");
|
|
30
|
-
/**
|
|
31
|
-
* Componente para proteger rotas que requerem autenticação
|
|
32
|
-
*/
|
|
33
|
-
function ProtectedRoute({ children, fallback, redirectTo = '/auth/signin', requireAuth = true }) {
|
|
34
|
-
const { isAuthenticated, isLoading } = (0, react_2.useAuth)();
|
|
35
|
-
// Ainda carregando
|
|
36
|
-
if (isLoading) {
|
|
37
|
-
return fallback || (0, jsx_runtime_1.jsx)("div", { children: "Loading..." });
|
|
38
|
-
}
|
|
39
|
-
// Requer auth mas não está autenticado
|
|
40
|
-
if (requireAuth && !isAuthenticated) {
|
|
41
|
-
if (typeof window !== 'undefined' && redirectTo) {
|
|
42
|
-
window.location.href = redirectTo;
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return fallback || (0, jsx_runtime_1.jsx)("div", { children: "Unauthorized" });
|
|
46
|
-
}
|
|
47
|
-
// Não requer auth mas está autenticado (ex: página de login)
|
|
48
|
-
if (!requireAuth && isAuthenticated && redirectTo) {
|
|
49
|
-
if (typeof window !== 'undefined') {
|
|
50
|
-
window.location.href = redirectTo;
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
55
|
-
}
|
|
56
29
|
/**
|
|
57
30
|
* Guard simples que só renderiza children se estiver autenticado
|
|
58
31
|
*/
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export * from '../client';
|
|
|
3
3
|
export * from '../components';
|
|
4
4
|
export { getSession } from '../client';
|
|
5
5
|
export { useSession, useAuth, SessionProvider } from '../react';
|
|
6
|
-
export {
|
|
6
|
+
export { AuthGuard, GuestOnly } from '../components';
|
package/dist/react/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.GuestOnly = exports.AuthGuard = exports.
|
|
17
|
+
exports.GuestOnly = exports.AuthGuard = exports.SessionProvider = exports.useAuth = exports.useSession = exports.getSession = void 0;
|
|
18
18
|
/*
|
|
19
19
|
* This file is part of the HightJS Project.
|
|
20
20
|
* Copyright (c) 2025 itsmuzin
|
|
@@ -43,6 +43,5 @@ Object.defineProperty(exports, "useSession", { enumerable: true, get: function (
|
|
|
43
43
|
Object.defineProperty(exports, "useAuth", { enumerable: true, get: function () { return react_1.useAuth; } });
|
|
44
44
|
Object.defineProperty(exports, "SessionProvider", { enumerable: true, get: function () { return react_1.SessionProvider; } });
|
|
45
45
|
var components_1 = require("../components");
|
|
46
|
-
Object.defineProperty(exports, "ProtectedRoute", { enumerable: true, get: function () { return components_1.ProtectedRoute; } });
|
|
47
46
|
Object.defineProperty(exports, "AuthGuard", { enumerable: true, get: function () { return components_1.AuthGuard; } });
|
|
48
47
|
Object.defineProperty(exports, "GuestOnly", { enumerable: true, get: function () { return components_1.GuestOnly; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hightjs/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Authentication package for HightJS framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@types/react": "^19.2.2",
|
|
39
39
|
"react": "^19.2.0",
|
|
40
|
-
"hightjs": "0.
|
|
40
|
+
"hightjs": "0.5.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsc",
|