@ziqx/auth 1.0.0 → 1.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 CHANGED
@@ -98,36 +98,36 @@ if (isValid) {
98
98
  ```typescript
99
99
  new ZAuthClient(options: {
100
100
  authKey: string;
101
- redirectUrl: string;
102
- codeChallenge: string;
103
- codeChallengeMethod?: string;
104
- state?: string;
101
+
105
102
  });
106
103
  ```
107
104
 
108
- | Parameter | Type | Required | Description |
109
- | --------------------- | ------ | -------- | ----------------------------------------------------------------- |
110
- | `authKey` | string | ✅ Yes | Your unique authentication key from ZIQX. |
111
- | `redirectUrl` | string | ✅ Yes | The URL where the user should be redirected after authentication. |
112
- | `codeChallenge` | string | ✅ Yes | The code challenge for PKCE flow. |
113
- | `codeChallengeMethod` | string | ❌ No | (Optional) The code challenge method (e.g., "S256"). |
114
- | `state` | string | ❌ No | (Optional) An opaque value used to maintain state. |
105
+ | Parameter | Type | Required | Description |
106
+ | --------- | ------ | -------- | ----------------------------------------- |
107
+ | `authKey` | string | ✅ Yes | Your unique authentication key from ZIQX. |
115
108
 
116
109
  #### Methods
117
110
 
118
- ##### `login(isDev?: boolean): void`
111
+ ##### `login(): void`
119
112
 
120
113
  Redirects the user to the ZIQX authentication portal.
121
114
 
122
- | Parameter | Type | Default | Description |
123
- | --------- | ------- | ------- | -------------------------------------------------------- |
124
- | `isDev` | boolean | `false` | Set `true` to redirect to the dev authentication portal. |
115
+ | Parameter | Type | Required | Description |
116
+ | --------------------- | ------ | -------- | ----------------------------------------------------------------- |
117
+ | `redirectUrl` | string | Yes | The URL where the user should be redirected after authentication. |
118
+ | `codeChallenge` | string | ✅ Yes | The code challenge for PKCE flow. |
119
+ | `codeChallengeMethod` | string | ❌ No | (Optional) The code challenge method (e.g., "S256"). |
120
+ | `state` | string | ❌ No | (Optional) An opaque value used to maintain state. |
125
121
 
126
122
  **Example:**
127
123
 
128
124
  ```typescript
129
- auth.login(); // Redirects to production portal
130
- auth.login(true); // Redirects to development portal
125
+ auth.login({
126
+ redirectUrl: "";
127
+ codeChallenge: "";
128
+ codeChallengeMethod: "";
129
+ state: "";
130
+ }); // Redirects to production portal
131
131
  ```
132
132
 
133
133
  ---
package/dist/index.d.mts CHANGED
@@ -9,45 +9,43 @@
9
9
  *
10
10
  * const auth = new ZAuthClient({
11
11
  * authKey: "your-auth-key",
12
- * redirectUrl: "http://localhost:3000/callback",
13
- * codeChallenge: "your-code-challenge"
14
12
  * });
15
13
  *
16
14
  * // Redirects user to ZIQX Auth
17
- * auth.login();
18
- *
19
- * // For development mode (redirects to localhost)
20
- * auth.login(true);
15
+ * auth.login({
16
+ * redirectUrl:"",
17
+ * codeChallenge:"",
18
+ * codeChallengeMethod:"",
19
+ * state:"",
20
+ * });
21
21
  * ```
22
22
  */
23
23
  declare class ZAuthClient {
24
24
  private authKey;
25
- private redirectUrl;
26
- private codeChallenge;
27
25
  private codeChallengeMethod?;
28
26
  private state?;
29
27
  /**
30
28
  * Creates a new ZAuthClient instance.
31
- *
32
29
  * @param options - The configuration options.
33
30
  * @param options.authKey - The authentication key provided by ZIQX.
31
+ * @throws Will throw an error if `authKey` is missing.
32
+ */
33
+ constructor({ authKey }: {
34
+ authKey: string;
35
+ });
36
+ /**
37
+ * Redirects the user to the ZIQX authentication page.
34
38
  * @param options.redirectUrl - The URL where the user should be redirected after authentication.
35
39
  * @param options.codeChallenge - The code challenge for PKCE flow.
36
40
  * @param options.codeChallengeMethod - (Optional) The code challenge method (e.g., "S256"). Default is "plaintext".
37
41
  * @param options.state - (Optional) An opaque value used to maintain state between the request and the callback.
38
- * @throws Will throw an error if `authKey`, `redirectUrl`, or `codeChallenge` are missing.
39
42
  */
40
- constructor({ authKey, redirectUrl, codeChallenge, codeChallengeMethod, state, }: {
41
- authKey: string;
42
- redirectUrl: string;
43
- codeChallenge: string;
43
+ login({ redirectUrl, codeChallenge, codeChallengeMethod, state, }: {
44
+ redirectUrl?: string;
45
+ codeChallenge?: string;
44
46
  codeChallengeMethod?: string;
45
47
  state?: string;
46
- });
47
- /**
48
- * Redirects the user to the ZIQX authentication page.
49
- */
50
- login(): void;
48
+ }): void;
51
49
  }
52
50
 
53
51
  type GetAuthTokenParams = {
package/dist/index.d.ts CHANGED
@@ -9,45 +9,43 @@
9
9
  *
10
10
  * const auth = new ZAuthClient({
11
11
  * authKey: "your-auth-key",
12
- * redirectUrl: "http://localhost:3000/callback",
13
- * codeChallenge: "your-code-challenge"
14
12
  * });
15
13
  *
16
14
  * // Redirects user to ZIQX Auth
17
- * auth.login();
18
- *
19
- * // For development mode (redirects to localhost)
20
- * auth.login(true);
15
+ * auth.login({
16
+ * redirectUrl:"",
17
+ * codeChallenge:"",
18
+ * codeChallengeMethod:"",
19
+ * state:"",
20
+ * });
21
21
  * ```
22
22
  */
23
23
  declare class ZAuthClient {
24
24
  private authKey;
25
- private redirectUrl;
26
- private codeChallenge;
27
25
  private codeChallengeMethod?;
28
26
  private state?;
29
27
  /**
30
28
  * Creates a new ZAuthClient instance.
31
- *
32
29
  * @param options - The configuration options.
33
30
  * @param options.authKey - The authentication key provided by ZIQX.
31
+ * @throws Will throw an error if `authKey` is missing.
32
+ */
33
+ constructor({ authKey }: {
34
+ authKey: string;
35
+ });
36
+ /**
37
+ * Redirects the user to the ZIQX authentication page.
34
38
  * @param options.redirectUrl - The URL where the user should be redirected after authentication.
35
39
  * @param options.codeChallenge - The code challenge for PKCE flow.
36
40
  * @param options.codeChallengeMethod - (Optional) The code challenge method (e.g., "S256"). Default is "plaintext".
37
41
  * @param options.state - (Optional) An opaque value used to maintain state between the request and the callback.
38
- * @throws Will throw an error if `authKey`, `redirectUrl`, or `codeChallenge` are missing.
39
42
  */
40
- constructor({ authKey, redirectUrl, codeChallenge, codeChallengeMethod, state, }: {
41
- authKey: string;
42
- redirectUrl: string;
43
- codeChallenge: string;
43
+ login({ redirectUrl, codeChallenge, codeChallengeMethod, state, }: {
44
+ redirectUrl?: string;
45
+ codeChallenge?: string;
44
46
  codeChallengeMethod?: string;
45
47
  state?: string;
46
- });
47
- /**
48
- * Redirects the user to the ZIQX authentication page.
49
- */
50
- login(): void;
48
+ }): void;
51
49
  }
52
50
 
53
51
  type GetAuthTokenParams = {
package/dist/index.js CHANGED
@@ -33,46 +33,38 @@ var VALIDATION_URL_V2 = "https://ziqx.cc/zauth/validate";
33
33
  // src/ZAuthClient.ts
34
34
  var ZAuthClient = class {
35
35
  authKey;
36
- redirectUrl;
37
- codeChallenge;
38
36
  codeChallengeMethod;
39
37
  state;
40
38
  /**
41
39
  * Creates a new ZAuthClient instance.
42
- *
43
40
  * @param options - The configuration options.
44
41
  * @param options.authKey - The authentication key provided by ZIQX.
42
+ * @throws Will throw an error if `authKey` is missing.
43
+ */
44
+ constructor({ authKey }) {
45
+ if (!authKey) {
46
+ throw new Error(
47
+ "ZAuthClient: Missing required parameters. `authKey` is required."
48
+ );
49
+ }
50
+ this.authKey = authKey;
51
+ }
52
+ /**
53
+ * Redirects the user to the ZIQX authentication page.
45
54
  * @param options.redirectUrl - The URL where the user should be redirected after authentication.
46
55
  * @param options.codeChallenge - The code challenge for PKCE flow.
47
56
  * @param options.codeChallengeMethod - (Optional) The code challenge method (e.g., "S256"). Default is "plaintext".
48
57
  * @param options.state - (Optional) An opaque value used to maintain state between the request and the callback.
49
- * @throws Will throw an error if `authKey`, `redirectUrl`, or `codeChallenge` are missing.
50
58
  */
51
- constructor({
52
- authKey,
59
+ login({
53
60
  redirectUrl,
54
61
  codeChallenge,
55
62
  codeChallengeMethod,
56
63
  state
57
64
  }) {
58
- if (!authKey || !redirectUrl || !codeChallenge) {
59
- throw new Error(
60
- "ZAuthClient: Missing required parameters. `authKey`, `redirectUrl`, and `codeChallenge` are required."
61
- );
62
- }
63
- this.authKey = authKey;
64
- this.redirectUrl = redirectUrl;
65
- this.codeChallenge = codeChallenge;
66
- this.codeChallengeMethod = codeChallengeMethod;
67
- this.state = state;
68
- }
69
- /**
70
- * Redirects the user to the ZIQX authentication page.
71
- */
72
- login() {
73
- const stateQuery = this.state ? `&state=${this.state}` : "";
74
- const codeChallengeMethodQuery = this.codeChallengeMethod ? `&challenge_method=${this.codeChallengeMethod}` : "";
75
- const loginUrl = `${ZAUTH_BASE_URL}?key=${this.authKey}&redir=${this.redirectUrl}&code_challenge=${this.codeChallenge}${codeChallengeMethodQuery}${stateQuery}`;
65
+ const stateQuery = state ? `&state=${state}` : "";
66
+ const codeChallengeMethodQuery = codeChallengeMethod ? `&challenge_method=${codeChallengeMethod}` : "";
67
+ const loginUrl = `${ZAUTH_BASE_URL}?key=${this.authKey}&redir=${redirectUrl}&code_challenge=${codeChallenge}${codeChallengeMethodQuery}${stateQuery}`;
76
68
  window.location.href = loginUrl;
77
69
  }
78
70
  };
package/dist/index.mjs CHANGED
@@ -6,46 +6,38 @@ var VALIDATION_URL_V2 = "https://ziqx.cc/zauth/validate";
6
6
  // src/ZAuthClient.ts
7
7
  var ZAuthClient = class {
8
8
  authKey;
9
- redirectUrl;
10
- codeChallenge;
11
9
  codeChallengeMethod;
12
10
  state;
13
11
  /**
14
12
  * Creates a new ZAuthClient instance.
15
- *
16
13
  * @param options - The configuration options.
17
14
  * @param options.authKey - The authentication key provided by ZIQX.
15
+ * @throws Will throw an error if `authKey` is missing.
16
+ */
17
+ constructor({ authKey }) {
18
+ if (!authKey) {
19
+ throw new Error(
20
+ "ZAuthClient: Missing required parameters. `authKey` is required."
21
+ );
22
+ }
23
+ this.authKey = authKey;
24
+ }
25
+ /**
26
+ * Redirects the user to the ZIQX authentication page.
18
27
  * @param options.redirectUrl - The URL where the user should be redirected after authentication.
19
28
  * @param options.codeChallenge - The code challenge for PKCE flow.
20
29
  * @param options.codeChallengeMethod - (Optional) The code challenge method (e.g., "S256"). Default is "plaintext".
21
30
  * @param options.state - (Optional) An opaque value used to maintain state between the request and the callback.
22
- * @throws Will throw an error if `authKey`, `redirectUrl`, or `codeChallenge` are missing.
23
31
  */
24
- constructor({
25
- authKey,
32
+ login({
26
33
  redirectUrl,
27
34
  codeChallenge,
28
35
  codeChallengeMethod,
29
36
  state
30
37
  }) {
31
- if (!authKey || !redirectUrl || !codeChallenge) {
32
- throw new Error(
33
- "ZAuthClient: Missing required parameters. `authKey`, `redirectUrl`, and `codeChallenge` are required."
34
- );
35
- }
36
- this.authKey = authKey;
37
- this.redirectUrl = redirectUrl;
38
- this.codeChallenge = codeChallenge;
39
- this.codeChallengeMethod = codeChallengeMethod;
40
- this.state = state;
41
- }
42
- /**
43
- * Redirects the user to the ZIQX authentication page.
44
- */
45
- login() {
46
- const stateQuery = this.state ? `&state=${this.state}` : "";
47
- const codeChallengeMethodQuery = this.codeChallengeMethod ? `&challenge_method=${this.codeChallengeMethod}` : "";
48
- const loginUrl = `${ZAUTH_BASE_URL}?key=${this.authKey}&redir=${this.redirectUrl}&code_challenge=${this.codeChallenge}${codeChallengeMethodQuery}${stateQuery}`;
38
+ const stateQuery = state ? `&state=${state}` : "";
39
+ const codeChallengeMethodQuery = codeChallengeMethod ? `&challenge_method=${codeChallengeMethod}` : "";
40
+ const loginUrl = `${ZAUTH_BASE_URL}?key=${this.authKey}&redir=${redirectUrl}&code_challenge=${codeChallenge}${codeChallengeMethodQuery}${stateQuery}`;
49
41
  window.location.href = loginUrl;
50
42
  }
51
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziqx/auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "SDK for Ziqx Authentication",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",