@machhub-dev/sdk-ts 1.0.8 → 1.0.9

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.
@@ -1,5 +1,5 @@
1
1
  import { HTTPService } from "../services/http.service.js";
2
- import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
2
+ import { ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
3
3
  export declare class Auth {
4
4
  private httpService;
5
5
  private applicationID;
@@ -16,8 +16,8 @@ export declare class Auth {
16
16
  getJWTData(): Promise<any>;
17
17
  getCurrentUser(): Promise<User>;
18
18
  validateCurrentUser(): Promise<ValidateJWTResponse>;
19
- checkAction(feature: string, scope: string): Promise<ActionResponse>;
20
- checkPermission(feature: string, scope: string, action: Action): Promise<ActionResponse>;
19
+ checkAction(feature: string): Promise<ActionResponse>;
20
+ checkPermission(feature: string, action: string): Promise<ActionResponse>;
21
21
  getUsers(): Promise<User[]>;
22
22
  getUserById(userId: string): Promise<User>;
23
23
  createUser(firstName: string, lastName: string, username: string, email: string, password: string, number: string, userImage: string): Promise<User>;
@@ -68,18 +68,18 @@ class Auth {
68
68
  }
69
69
  return await this.validateJWT(token);
70
70
  }
71
- async checkAction(feature, scope) {
71
+ async checkAction(feature) {
72
72
  try {
73
- const res = await this.httpService.request.get(`/auth/permission/action/feature/${feature}/scope/${scope}`);
73
+ const res = await this.httpService.request.get(`/auth/permission/action/feature/${feature}`);
74
74
  return res;
75
75
  }
76
76
  catch (e) {
77
77
  throw new Error("failed to checkAction : " + e.message);
78
78
  }
79
79
  }
80
- async checkPermission(feature, scope, action) {
80
+ async checkPermission(feature, action) {
81
81
  try {
82
- const res = await this.httpService.request.get(`/auth/permission/check/feature/${feature}/scope/${scope}/action/${action}`);
82
+ const res = await this.httpService.request.get(`/auth/permission/check/feature/${feature}/action/${action}`);
83
83
  return res;
84
84
  }
85
85
  catch (e) {
@@ -280,7 +280,7 @@ async function findConfigEndpoint() {
280
280
  'Accept': 'application/json',
281
281
  },
282
282
  signal: AbortSignal.timeout(2000)
283
- }).catch(() => { console.log("ERR"); return null; }); // Catch fetch errors silently
283
+ }).catch(() => null); // Catch fetch errors silently
284
284
  if (!testResponse || !testResponse.ok) {
285
285
  continue; // Skip to next candidate
286
286
  }
@@ -1,5 +1,5 @@
1
1
  import { HTTPService } from "../services/http.service.js";
2
- import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
2
+ import { ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
3
3
  export declare class Auth {
4
4
  private httpService;
5
5
  private applicationID;
@@ -16,8 +16,8 @@ export declare class Auth {
16
16
  getJWTData(): Promise<any>;
17
17
  getCurrentUser(): Promise<User>;
18
18
  validateCurrentUser(): Promise<ValidateJWTResponse>;
19
- checkAction(feature: string, scope: string): Promise<ActionResponse>;
20
- checkPermission(feature: string, scope: string, action: Action): Promise<ActionResponse>;
19
+ checkAction(feature: string): Promise<ActionResponse>;
20
+ checkPermission(feature: string, action: string): Promise<ActionResponse>;
21
21
  getUsers(): Promise<User[]>;
22
22
  getUserById(userId: string): Promise<User>;
23
23
  createUser(firstName: string, lastName: string, username: string, email: string, password: string, number: string, userImage: string): Promise<User>;
@@ -65,18 +65,18 @@ export class Auth {
65
65
  }
66
66
  return await this.validateJWT(token);
67
67
  }
68
- async checkAction(feature, scope) {
68
+ async checkAction(feature) {
69
69
  try {
70
- const res = await this.httpService.request.get(`/auth/permission/action/feature/${feature}/scope/${scope}`);
70
+ const res = await this.httpService.request.get(`/auth/permission/action/feature/${feature}`);
71
71
  return res;
72
72
  }
73
73
  catch (e) {
74
74
  throw new Error("failed to checkAction : " + e.message);
75
75
  }
76
76
  }
77
- async checkPermission(feature, scope, action) {
77
+ async checkPermission(feature, action) {
78
78
  try {
79
- const res = await this.httpService.request.get(`/auth/permission/check/feature/${feature}/scope/${scope}/action/${action}`);
79
+ const res = await this.httpService.request.get(`/auth/permission/check/feature/${feature}/action/${action}`);
80
80
  return res;
81
81
  }
82
82
  catch (e) {
package/dist/sdk-ts.js CHANGED
@@ -276,7 +276,7 @@ async function findConfigEndpoint() {
276
276
  'Accept': 'application/json',
277
277
  },
278
278
  signal: AbortSignal.timeout(2000)
279
- }).catch(() => { console.log("ERR"); return null; }); // Catch fetch errors silently
279
+ }).catch(() => null); // Catch fetch errors silently
280
280
  if (!testResponse || !testResponse.ok) {
281
281
  continue; // Skip to next candidate
282
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machhub-dev/sdk-ts",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "MACHHUB TYPESCRIPT SDK",
5
5
  "keywords": [
6
6
  "machhub",
@@ -81,9 +81,9 @@ export class Auth {
81
81
  return await this.validateJWT(token);
82
82
  }
83
83
 
84
- public async checkAction(feature: string, scope: string): Promise<ActionResponse> {
84
+ public async checkAction(feature: string): Promise<ActionResponse> {
85
85
  try {
86
- const res: ActionResponse = await this.httpService.request.get(`/auth/permission/action/feature/${feature}/scope/${scope}`);
86
+ const res: ActionResponse = await this.httpService.request.get(`/auth/permission/action/feature/${feature}`);
87
87
  return res
88
88
  }
89
89
  catch (e: unknown) {
@@ -91,9 +91,9 @@ export class Auth {
91
91
  }
92
92
  }
93
93
 
94
- public async checkPermission(feature: string, scope: string, action: Action): Promise<ActionResponse> {
94
+ public async checkPermission(feature: string, action: string): Promise<ActionResponse> {
95
95
  try {
96
- const res: ActionResponse = await this.httpService.request.get(`/auth/permission/check/feature/${feature}/scope/${scope}/action/${action}`);
96
+ const res: ActionResponse = await this.httpService.request.get(`/auth/permission/check/feature/${feature}/action/${action}`);
97
97
  return res
98
98
  }
99
99
  catch (e: unknown) {
package/src/sdk-ts.ts CHANGED
@@ -324,7 +324,7 @@ async function findConfigEndpoint(): Promise<string> {
324
324
  'Accept': 'application/json',
325
325
  },
326
326
  signal: AbortSignal.timeout(2000)
327
- }).catch(() => { console.log("ERR"); return null }); // Catch fetch errors silently
327
+ }).catch(() => null); // Catch fetch errors silently
328
328
 
329
329
  if (!testResponse || !testResponse.ok) {
330
330
  continue; // Skip to next candidate