@ziqx/auth 0.0.1

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 ADDED
@@ -0,0 +1,106 @@
1
+ # @ziqx/auth
2
+
3
+ A lightweight authentication SDK for ZIQX platforms. Provides an easy interface to trigger the authentication flow from your frontend.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @ziqx/auth
11
+ ```
12
+
13
+ or
14
+
15
+ ```bash
16
+ yarn add @ziqx/auth
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Usage
22
+
23
+ ### Import and Initialize
24
+
25
+ ```typescript
26
+ import { ZAuthClient } from "@ziqx/auth";
27
+
28
+ const auth = new ZAuthClient({
29
+ authKey: "YOUR_AUTH_KEY",
30
+ });
31
+ ```
32
+
33
+ ### Trigger Login
34
+
35
+ ```typescript
36
+ auth.login(); // Redirects to live auth environment
37
+ ```
38
+
39
+ ### Trigger Login in Development Mode
40
+
41
+ If you're working in a development environment, enable dev mode:
42
+
43
+ ```typescript
44
+ auth.login(true); // Redirects to dev auth environment
45
+ ```
46
+
47
+ ---
48
+
49
+ ## API Reference
50
+
51
+ ### Class: `ZAuthClient`
52
+
53
+ #### Constructor
54
+
55
+ ```typescript
56
+ new ZAuthClient(options: { authKey: string });
57
+ ```
58
+
59
+ | Parameter | Type | Required | Description |
60
+ | --------- | ------ | -------- | ----------------------------------------- |
61
+ | `authKey` | string | ✅ Yes | Your unique authentication key from ZIQX. |
62
+
63
+ #### Methods
64
+
65
+ ##### `login(isDev?: boolean): void`
66
+
67
+ Redirects the user to the ZIQX authentication portal.
68
+
69
+ | Parameter | Type | Default | Description |
70
+ | --------- | ------- | ------- | -------------------------------------------------------- |
71
+ | `isDev` | boolean | `false` | Set `true` to redirect to the dev authentication portal. |
72
+
73
+ **Example:**
74
+
75
+ ```typescript
76
+ auth.login(); // Redirects to production portal
77
+ auth.login(true); // Redirects to development portal
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Example Implementation
83
+
84
+ ```typescript
85
+ import { ZAuthClient } from "@ziqx/auth";
86
+
87
+ const auth = new ZAuthClient({ authKey: "12345-xyz" });
88
+
89
+ document.getElementById("loginBtn")?.addEventListener("click", () => {
90
+ auth.login();
91
+ });
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Notes
97
+
98
+ - Make sure your `authKey` is valid and corresponds to your environment.
99
+ - If you’re working on localhost or staging, use `auth.login(true)` to switch to dev mode.
100
+ - This SDK must be used in **client-side code only** — calling `login()` in a Server Component will throw an error.
101
+
102
+ ---
103
+
104
+ ## License
105
+
106
+ MIT License © 2025 [ZIQX]
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ZAuthClient - A lightweight authentication client for ZIQX Auth.
3
+ *
4
+ * This class helps redirect users to the ZIQX authentication gateway.
5
+ *
6
+ * Example:
7
+ * ```ts
8
+ * import { ZAuthClient } from "@ziqx/auth";
9
+ *
10
+ * const auth = new ZAuthClient({
11
+ * authKey: "your-auth-key"
12
+ * });
13
+ *
14
+ * // Redirects user to ZIQX Auth
15
+ * auth.login();
16
+ *
17
+ * // For development mode
18
+ * auth.login(true);
19
+ * ```
20
+ */
21
+ declare class ZAuthClient {
22
+ private authKey;
23
+ /**
24
+ * Creates a new ZAuthClient instance.
25
+ *
26
+ * @param options - The configuration options.
27
+ * @param options.authKey - The authentication key provided by ZIQX.
28
+ */
29
+ constructor({ authKey }: {
30
+ authKey: string;
31
+ });
32
+ /**
33
+ * Redirects the user to the ZIQX authentication page.
34
+ *
35
+ * @param isDev - (Optional) Set to `true` to use development mode. Defaults to `false`.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const client = new ZAuthClient({ authKey: "your-auth-key" });
40
+ * client.login(); // Redirects to production auth page
41
+ * client.login(true); // Redirects to development auth page
42
+ * ```
43
+ */
44
+ login(isDev?: boolean): void;
45
+ }
46
+
47
+ export { ZAuthClient };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ZAuthClient - A lightweight authentication client for ZIQX Auth.
3
+ *
4
+ * This class helps redirect users to the ZIQX authentication gateway.
5
+ *
6
+ * Example:
7
+ * ```ts
8
+ * import { ZAuthClient } from "@ziqx/auth";
9
+ *
10
+ * const auth = new ZAuthClient({
11
+ * authKey: "your-auth-key"
12
+ * });
13
+ *
14
+ * // Redirects user to ZIQX Auth
15
+ * auth.login();
16
+ *
17
+ * // For development mode
18
+ * auth.login(true);
19
+ * ```
20
+ */
21
+ declare class ZAuthClient {
22
+ private authKey;
23
+ /**
24
+ * Creates a new ZAuthClient instance.
25
+ *
26
+ * @param options - The configuration options.
27
+ * @param options.authKey - The authentication key provided by ZIQX.
28
+ */
29
+ constructor({ authKey }: {
30
+ authKey: string;
31
+ });
32
+ /**
33
+ * Redirects the user to the ZIQX authentication page.
34
+ *
35
+ * @param isDev - (Optional) Set to `true` to use development mode. Defaults to `false`.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const client = new ZAuthClient({ authKey: "your-auth-key" });
40
+ * client.login(); // Redirects to production auth page
41
+ * client.login(true); // Redirects to development auth page
42
+ * ```
43
+ */
44
+ login(isDev?: boolean): void;
45
+ }
46
+
47
+ export { ZAuthClient };
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ZAuthClient: () => ZAuthClient
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+
27
+ // src/constants.ts
28
+ var ZAUTH_BASE_URL = "https://ziqx.cc/zauth";
29
+
30
+ // src/ZAuthClient.ts
31
+ var ZAuthClient = class {
32
+ authKey;
33
+ /**
34
+ * Creates a new ZAuthClient instance.
35
+ *
36
+ * @param options - The configuration options.
37
+ * @param options.authKey - The authentication key provided by ZIQX.
38
+ */
39
+ constructor({ authKey }) {
40
+ if (!authKey) {
41
+ throw new Error("ZAuthClient: authKey is required.");
42
+ }
43
+ this.authKey = authKey;
44
+ }
45
+ /**
46
+ * Redirects the user to the ZIQX authentication page.
47
+ *
48
+ * @param isDev - (Optional) Set to `true` to use development mode. Defaults to `false`.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const client = new ZAuthClient({ authKey: "your-auth-key" });
53
+ * client.login(); // Redirects to production auth page
54
+ * client.login(true); // Redirects to development auth page
55
+ * ```
56
+ */
57
+ login(isDev = false) {
58
+ const devQuery = isDev ? "&dev=true" : "";
59
+ const loginUrl = `${ZAUTH_BASE_URL}?key=${this.authKey}${devQuery}`;
60
+ window.location.href = loginUrl;
61
+ }
62
+ };
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ ZAuthClient
66
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,39 @@
1
+ // src/constants.ts
2
+ var ZAUTH_BASE_URL = "https://ziqx.cc/zauth";
3
+
4
+ // src/ZAuthClient.ts
5
+ var ZAuthClient = class {
6
+ authKey;
7
+ /**
8
+ * Creates a new ZAuthClient instance.
9
+ *
10
+ * @param options - The configuration options.
11
+ * @param options.authKey - The authentication key provided by ZIQX.
12
+ */
13
+ constructor({ authKey }) {
14
+ if (!authKey) {
15
+ throw new Error("ZAuthClient: authKey is required.");
16
+ }
17
+ this.authKey = authKey;
18
+ }
19
+ /**
20
+ * Redirects the user to the ZIQX authentication page.
21
+ *
22
+ * @param isDev - (Optional) Set to `true` to use development mode. Defaults to `false`.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const client = new ZAuthClient({ authKey: "your-auth-key" });
27
+ * client.login(); // Redirects to production auth page
28
+ * client.login(true); // Redirects to development auth page
29
+ * ```
30
+ */
31
+ login(isDev = false) {
32
+ const devQuery = isDev ? "&dev=true" : "";
33
+ const loginUrl = `${ZAUTH_BASE_URL}?key=${this.authKey}${devQuery}`;
34
+ window.location.href = loginUrl;
35
+ }
36
+ };
37
+ export {
38
+ ZAuthClient
39
+ };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@ziqx/auth",
3
+ "version": "0.0.1",
4
+ "description": "SDK for Ziqx Authentication",
5
+ "main": "./dist/index.ts",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "homepage": "ziqx.cc",
9
+ "access": "public",
10
+ "repository": {
11
+ "url": "https://github.com/ziqx/ziqx-auth-js"
12
+ },
13
+ "scripts": {
14
+ "build": "tsup"
15
+ },
16
+ "keywords": [
17
+ "zauth",
18
+ "ziqx auth",
19
+ "ziqx.js"
20
+ ],
21
+ "author": "Fathah KA",
22
+ "license": "MIT",
23
+ "devDependencies": {
24
+ "tsup": "^8.0.2",
25
+ "typescript": "^5.4.5"
26
+ }
27
+ }