@bananacool467/authtics 1.0.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/.replit ADDED
@@ -0,0 +1,29 @@
1
+ entrypoint = "index.ts"
2
+ modules = ["nodejs-22"]
3
+ hidden = [".config", "package-lock.json"]
4
+
5
+ [gitHubImport]
6
+ requiredFiles = [".replit", "replit.nix", "package.json", "package-lock.json"]
7
+
8
+ [nix]
9
+ channel = "stable-24_11"
10
+
11
+ [deployment]
12
+ run = ["node", "index.js"]
13
+ deploymentTarget = "autoscale"
14
+ ignorePorts = false
15
+
16
+ [agent]
17
+ expertMode = true
18
+
19
+ [workflows]
20
+ runButton = "Run"
21
+
22
+ [[workflows.workflow]]
23
+ name = "Run"
24
+ mode = "sequential"
25
+ author = 38094588
26
+
27
+ [[workflows.workflow.tasks]]
28
+ task = "shell.exec"
29
+ args = "npx ts-node index.ts"
@@ -0,0 +1 @@
1
+ {"version":2,"languages":{"nodejs-npm":{"specfileHash":"d18cf0a26e6a6fae007898f8dce8efbf","lockfileHash":"9047b0d07f978c7218a90637e3edc20f"}}}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Authtics - Open Source Authentication Utility
3
+ * Developed by bananakitssu (github.com/bananakitssu)
4
+ * This software is provided "as-is" for the community.
5
+ */
6
+ /**
7
+ * Gets the user based on the accessToken.
8
+ * The IP is required to lock all sessions for security reasons.
9
+ */
10
+ export declare const getAccount: (accessToken: string, clientId: string, clientSecret: string, userIp: string) => Promise<any>;
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Authtics - Open Source Authentication Utility
4
+ * Developed by bananakitssu (github.com/bananakitssu)
5
+ * This software is provided "as-is" for the community.
6
+ */
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getAccount = void 0;
18
+ const child_process_1 = require("child_process");
19
+ const __runCurl__ = (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, headers = []) {
20
+ var outp;
21
+ var oute;
22
+ var curlReadableHeaders = headers
23
+ .map((h) => `-H "${h.k}: ${h.v}"`)
24
+ .join(" ");
25
+ return new Promise((r) => {
26
+ (0, child_process_1.exec)(`curl -X GET "${url}" ${curlReadableHeaders}`, (error, stdout, stderr) => {
27
+ if (error) {
28
+ oute = error.message;
29
+ r([undefined, oute]);
30
+ return;
31
+ }
32
+ outp = stdout;
33
+ r([outp, undefined]);
34
+ });
35
+ });
36
+ });
37
+ /**
38
+ * Gets the user based on the accessToken.
39
+ * The IP is required to lock all sessions for security reasons.
40
+ */
41
+ const getAccount = (accessToken, clientId, clientSecret, userIp) => __awaiter(void 0, void 0, void 0, function* () {
42
+ var [output, error] = yield __runCurl__("https://eb29e77b-9bd2-4e3b-9469-81d3af2a8fbe-00-1ag45w1mgbsv1.picard.replit.dev/api/authtics/me", [{ k: "Authorization", v: accessToken }, { k: "x-client-id", v: clientId }, { k: "x-client-secret", v: clientSecret }, { k: "x-user-ip", v: userIp }, { k: "Content-Type", v: "application/json" }]);
43
+ return (yield JSON.parse(output)) || error;
44
+ });
45
+ exports.getAccount = getAccount;
46
+ (() => __awaiter(void 0, void 0, void 0, function* () {
47
+ var [output, error] = yield __runCurl__("https://eb29e77b-9bd2-4e3b-9469-81d3af2a8fbe-00-1ag45w1mgbsv1.picard.replit.dev/api/authtics/me", [
48
+ { k: "Authorization", v: "5" },
49
+ { k: "client_id", v: "xxx" },
50
+ ]);
51
+ console.log(output, error);
52
+ }))();
Binary file
package/index.ts ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Authtics - Open Source Authentication Utility
3
+ * Developed by bananakitssu (github.com/bananakitssu)
4
+ * This software is provided "as-is" for the community.
5
+ */
6
+
7
+ import { exec } from "child_process";
8
+
9
+ interface CurlHeader {
10
+ k: string;
11
+ v: string;
12
+ }
13
+
14
+ interface AuthticsUser {
15
+ uid: string;
16
+ name: string;
17
+ profileImage: string;
18
+ }
19
+
20
+ const __runCurl__ = async (url: string, headers: CurlHeader[] = []) => {
21
+ var outp;
22
+ var oute;
23
+ var curlReadableHeaders = headers
24
+ .map((h: CurlHeader) => `-H "${h.k}: ${h.v}"`)
25
+ .join(" ");
26
+ return new Promise<[String?, String?]>((r) => {
27
+ exec(
28
+ `curl -X GET "${url}" ${curlReadableHeaders}`,
29
+ (error, stdout, stderr) => {
30
+ if (error) {
31
+ oute = error.message;
32
+ r([undefined, oute]);
33
+ return;
34
+ }
35
+ outp = stdout;
36
+ r([outp, undefined]);
37
+ },
38
+ );
39
+ });
40
+ };
41
+
42
+ /**
43
+ * Gets the user based on the accessToken.
44
+ * The IP is required to lock all sessions for security reasons.
45
+ */
46
+ export const getAccount = async (accessToken: string, clientId: string, clientSecret: string, userIp: string) => {
47
+ var [output, error] = await __runCurl__("https://eb29e77b-9bd2-4e3b-9469-81d3af2a8fbe-00-1ag45w1mgbsv1.picard.replit.dev/api/authtics/me", [{k: "Authorization", v: accessToken}, {k: "x-client-id", v: clientId}, {k: "x-client-secret", v: clientSecret}, {k: "x-user-ip", v: userIp}, {k: "Content-Type", v: "application/json"}]);
48
+ return (await JSON.parse(output as string)) || error;
49
+ }
50
+
51
+ (async () => {
52
+ var [output, error] = await __runCurl__(
53
+ "https://eb29e77b-9bd2-4e3b-9469-81d3af2a8fbe-00-1ag45w1mgbsv1.picard.replit.dev/api/authtics/me",
54
+ [
55
+ { k: "Authorization", v: "5" },
56
+ { k: "client_id", v: "xxx" },
57
+ ],
58
+ );
59
+ console.log(output, error);
60
+ })();
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@bananacool467/authtics",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build"
10
+ },
11
+ "keywords": [],
12
+ "author": "",
13
+ "license": "ISC",
14
+ "dependencies": {
15
+ "@types/node": "^22.13.11"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.9.3"
19
+ }
20
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "CommonJS",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "strict": true,
8
+ "esModuleInterop": true
9
+ },
10
+ "include": ["index.ts"]
11
+ }