@anzar-auth/core 1.7.4 → 1.7.6

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.cjs CHANGED
@@ -30,10 +30,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- api: () => api
33
+ initApi: () => initApi
34
34
  });
35
35
  module.exports = __toCommonJS(src_exports);
36
36
 
37
37
  // src/client.ts
38
38
  var import_openapi_fetch = __toESM(require("openapi-fetch"), 1);
39
- var api = (0, import_openapi_fetch.default)({ baseUrl: "http://localhost:3000" });
39
+ function initApi(baseUrl, middlewares) {
40
+ const api = (0, import_openapi_fetch.default)({
41
+ baseUrl,
42
+ credentials: "include"
43
+ });
44
+ api.use(...middlewares);
45
+ return api;
46
+ }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as openapi_fetch from 'openapi-fetch';
2
+ import { Middleware } from 'openapi-fetch';
2
3
  export { Client, Middleware } from 'openapi-fetch';
3
4
 
4
5
  /**
@@ -166,13 +167,13 @@ interface paths {
166
167
  path?: never;
167
168
  cookie?: never;
168
169
  };
170
+ get?: never;
171
+ put?: never;
169
172
  /**
170
173
  * Verify user email
171
174
  * @description Validates the email verification token and activates the user account. On success, redirects the user to the confirmation page.
172
175
  */
173
- get: operations["verify_email"];
174
- put?: never;
175
- post?: never;
176
+ post: operations["verify_email"];
176
177
  delete?: never;
177
178
  options?: never;
178
179
  head?: never;
@@ -475,7 +476,7 @@ interface components {
475
476
  token_expires_in: number;
476
477
  };
477
478
  /** @enum {string} */
478
- ErrorCode: "TokenExpired" | "TokenReplay" | "TokenInvalid" | "InvalidCredentials" | "AccountNotVerified" | "TokenInvalidSignature" | "TokenInvalidAudience" | "TokenInvalidIssuer" | "TokenInvalidAlgorithm" | "TokenMalformed" | "InsufficientPermissions" | "AccountSuspended" | "RoleNotFound" | "UserNotFound" | "TokenNotFound" | "AlreadyExists" | "ValidationFailed" | "MalformedField" | "MissingField" | "UnsupportedMediaType" | "BadRequest" | "RateLimitExceeded" | "Internal";
479
+ ErrorCode: "BadRequest" | "ValidationFailed" | "MalformedField" | "MissingField" | "UnsupportedMediaType" | "TokenExpired" | "TokenReplay" | "TokenInvalid" | "InvalidCredentials" | "AccountNotVerified" | "TokenInvalidSignature" | "TokenInvalidAudience" | "TokenInvalidIssuer" | "TokenInvalidAlgorithm" | "TokenMalformed" | "InsufficientPermissions" | "AccountSuspended" | "RoleNotFound" | "UserNotFound" | "TokenNotFound" | "AlreadyExists" | "RateLimitExceeded" | "Internal";
479
480
  /**
480
481
  * @example {
481
482
  * "message": "An Error occured"
@@ -642,6 +643,18 @@ interface components {
642
643
  action: string;
643
644
  resource: string;
644
645
  };
646
+ RateLimit: {
647
+ default?: components["schemas"]["RateLimitConfig"];
648
+ enabled?: boolean;
649
+ ip?: components["schemas"]["RateLimitConfig"];
650
+ strict?: components["schemas"]["RateLimitConfig"];
651
+ };
652
+ RateLimitConfig: {
653
+ /** Format: int32 */
654
+ capacity: number;
655
+ /** Format: int32 */
656
+ duration_minutes: number;
657
+ };
645
658
  RbacConfig: {
646
659
  /** @default User */
647
660
  default_role: string;
@@ -716,6 +729,7 @@ interface components {
716
729
  string,
717
730
  string
718
731
  ][];
732
+ rate_limit?: components["schemas"]["RateLimit"];
719
733
  };
720
734
  Server: {
721
735
  /**
@@ -769,6 +783,8 @@ interface components {
769
783
  expiresAt: string;
770
784
  /** Format: date-time */
771
785
  issuedAt: string;
786
+ permissions: string[];
787
+ roles: string[];
772
788
  token: string;
773
789
  /** Format: date-time */
774
790
  usedAt?: string | null;
@@ -1552,6 +1568,6 @@ interface operations {
1552
1568
  };
1553
1569
  }
1554
1570
 
1555
- declare const api: openapi_fetch.Client<paths, `${string}/${string}`>;
1571
+ declare function initApi(baseUrl: string, middlewares: Middleware[]): openapi_fetch.Client<paths, `${string}/${string}`>;
1556
1572
 
1557
- export { api, type components, type paths };
1573
+ export { type components, initApi, type paths };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as openapi_fetch from 'openapi-fetch';
2
+ import { Middleware } from 'openapi-fetch';
2
3
  export { Client, Middleware } from 'openapi-fetch';
3
4
 
4
5
  /**
@@ -166,13 +167,13 @@ interface paths {
166
167
  path?: never;
167
168
  cookie?: never;
168
169
  };
170
+ get?: never;
171
+ put?: never;
169
172
  /**
170
173
  * Verify user email
171
174
  * @description Validates the email verification token and activates the user account. On success, redirects the user to the confirmation page.
172
175
  */
173
- get: operations["verify_email"];
174
- put?: never;
175
- post?: never;
176
+ post: operations["verify_email"];
176
177
  delete?: never;
177
178
  options?: never;
178
179
  head?: never;
@@ -475,7 +476,7 @@ interface components {
475
476
  token_expires_in: number;
476
477
  };
477
478
  /** @enum {string} */
478
- ErrorCode: "TokenExpired" | "TokenReplay" | "TokenInvalid" | "InvalidCredentials" | "AccountNotVerified" | "TokenInvalidSignature" | "TokenInvalidAudience" | "TokenInvalidIssuer" | "TokenInvalidAlgorithm" | "TokenMalformed" | "InsufficientPermissions" | "AccountSuspended" | "RoleNotFound" | "UserNotFound" | "TokenNotFound" | "AlreadyExists" | "ValidationFailed" | "MalformedField" | "MissingField" | "UnsupportedMediaType" | "BadRequest" | "RateLimitExceeded" | "Internal";
479
+ ErrorCode: "BadRequest" | "ValidationFailed" | "MalformedField" | "MissingField" | "UnsupportedMediaType" | "TokenExpired" | "TokenReplay" | "TokenInvalid" | "InvalidCredentials" | "AccountNotVerified" | "TokenInvalidSignature" | "TokenInvalidAudience" | "TokenInvalidIssuer" | "TokenInvalidAlgorithm" | "TokenMalformed" | "InsufficientPermissions" | "AccountSuspended" | "RoleNotFound" | "UserNotFound" | "TokenNotFound" | "AlreadyExists" | "RateLimitExceeded" | "Internal";
479
480
  /**
480
481
  * @example {
481
482
  * "message": "An Error occured"
@@ -642,6 +643,18 @@ interface components {
642
643
  action: string;
643
644
  resource: string;
644
645
  };
646
+ RateLimit: {
647
+ default?: components["schemas"]["RateLimitConfig"];
648
+ enabled?: boolean;
649
+ ip?: components["schemas"]["RateLimitConfig"];
650
+ strict?: components["schemas"]["RateLimitConfig"];
651
+ };
652
+ RateLimitConfig: {
653
+ /** Format: int32 */
654
+ capacity: number;
655
+ /** Format: int32 */
656
+ duration_minutes: number;
657
+ };
645
658
  RbacConfig: {
646
659
  /** @default User */
647
660
  default_role: string;
@@ -716,6 +729,7 @@ interface components {
716
729
  string,
717
730
  string
718
731
  ][];
732
+ rate_limit?: components["schemas"]["RateLimit"];
719
733
  };
720
734
  Server: {
721
735
  /**
@@ -769,6 +783,8 @@ interface components {
769
783
  expiresAt: string;
770
784
  /** Format: date-time */
771
785
  issuedAt: string;
786
+ permissions: string[];
787
+ roles: string[];
772
788
  token: string;
773
789
  /** Format: date-time */
774
790
  usedAt?: string | null;
@@ -1552,6 +1568,6 @@ interface operations {
1552
1568
  };
1553
1569
  }
1554
1570
 
1555
- declare const api: openapi_fetch.Client<paths, `${string}/${string}`>;
1571
+ declare function initApi(baseUrl: string, middlewares: Middleware[]): openapi_fetch.Client<paths, `${string}/${string}`>;
1556
1572
 
1557
- export { api, type components, type paths };
1573
+ export { type components, initApi, type paths };
package/dist/index.js CHANGED
@@ -1,6 +1,13 @@
1
1
  // src/client.ts
2
2
  import createClient from "openapi-fetch";
3
- var api = createClient({ baseUrl: "http://localhost:3000" });
3
+ function initApi(baseUrl, middlewares) {
4
+ const api = createClient({
5
+ baseUrl,
6
+ credentials: "include"
7
+ });
8
+ api.use(...middlewares);
9
+ return api;
10
+ }
4
11
  export {
5
- api
12
+ initApi
6
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anzar-auth/core",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "Anzar server middleware for verifying tokens",
5
5
  "author": "Hakou Guelfen <hakoudev@gmail.com>",
6
6
  "license": "GPL-3.0",