@bananacool467/authtics 1.0.11 → 1.0.27
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.js +43 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.authtics = exports.getAccount = void 0;
|
|
18
18
|
const child_process_1 = require("child_process");
|
|
19
|
+
const react_1 = require("react");
|
|
19
20
|
const cookieParser = require("cookie-parser");
|
|
20
21
|
const __runCurl__ = (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, headers = []) {
|
|
21
22
|
var outp;
|
|
@@ -46,21 +47,31 @@ const getAccount = (accessToken, clientId, clientSecret, userIp) => __awaiter(vo
|
|
|
46
47
|
exports.getAccount = getAccount;
|
|
47
48
|
exports.authtics = {
|
|
48
49
|
useAccount: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
const [account, setAccount] = (0, react_1.useState)({});
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
const getAccount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const a = yield fetch('/api/authtics-integration/get-account', {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": "application/json"
|
|
57
|
+
},
|
|
58
|
+
body: JSON.stringify({})
|
|
59
|
+
});
|
|
60
|
+
if (a.status != 200) {
|
|
61
|
+
setAccount({});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
setAccount(yield a.json());
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
getAccount();
|
|
68
|
+
}, []);
|
|
69
|
+
const carriedInfo = {
|
|
70
|
+
action: null,
|
|
71
|
+
failed: false,
|
|
72
|
+
status: null,
|
|
73
|
+
error: null
|
|
74
|
+
};
|
|
64
75
|
const login = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
76
|
window.location.href = "/api/authtics-integration/login?r=" + (window.location.pathname + (window.location.search.replace("&", "%26")));
|
|
66
77
|
});
|
|
@@ -76,7 +87,7 @@ exports.authtics = {
|
|
|
76
87
|
cookieParser(),
|
|
77
88
|
(req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
89
|
var _a;
|
|
79
|
-
if (req.path != '/api/authtics-integration/get-account') {
|
|
90
|
+
if (req.path != '/api/authtics-integration/get-account' && req.path != '/api/authtics-integration/login' && req.path != '/api/authtics-integration/logout') {
|
|
80
91
|
const userIp = req.ip;
|
|
81
92
|
const token = req.query.accessToken;
|
|
82
93
|
const cookie = (_a = req.cookies) === null || _a === void 0 ? void 0 : _a.AUTHTICS_ACCOUNT_ACCESS_TOKEN;
|
|
@@ -108,6 +119,22 @@ exports.authtics = {
|
|
|
108
119
|
res.status(200).json({ account, success: true });
|
|
109
120
|
next();
|
|
110
121
|
}
|
|
122
|
+
else if (req.path == '/api/authtics-integration/login') {
|
|
123
|
+
const { search } = req.body;
|
|
124
|
+
res.status(200).json({ redirect: ("https://eb29e77b-9bd2-4e3b-9469-81d3af2a8fbe-00-1ag45w1mgbsv1.picard.replit.dev/login?client_id=" + clientId + "&redirect=" + (search.replace("&", "%26"))) });
|
|
125
|
+
next();
|
|
126
|
+
}
|
|
127
|
+
else if (req.path == '/api/authtics-integration/logout') {
|
|
128
|
+
const redirect = req.query.r;
|
|
129
|
+
res.clearCookie('AUTHTICS_ACCOUNT_ACCESS_TOKEN', {
|
|
130
|
+
path: '/',
|
|
131
|
+
secure: true,
|
|
132
|
+
sameSite: 'Lax'
|
|
133
|
+
});
|
|
134
|
+
req.authtics_token = null;
|
|
135
|
+
res.status(200).json({ redirect: redirect });
|
|
136
|
+
next();
|
|
137
|
+
}
|
|
111
138
|
})
|
|
112
139
|
];
|
|
113
140
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananacool467/authtics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Use Authtics (An Auth service) to add accounts to your site like Auth0! (This is currently underdevelopment. Issues are expected.)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|