cheshirecat-typescript-client 1.7.5 → 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/endpoints/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractEndpoint } from "./abstract";
|
|
2
|
-
import { TokenOutput } from "../models/api/tokens";
|
|
2
|
+
import { MeOutput, TokenOutput } from "../models/api/tokens";
|
|
3
3
|
import { Permission } from "../models/dtos";
|
|
4
4
|
export declare class AuthEndpoint extends AbstractEndpoint {
|
|
5
5
|
protected prefix: string;
|
|
@@ -9,11 +9,10 @@ export declare class AuthEndpoint extends AbstractEndpoint {
|
|
|
9
9
|
*
|
|
10
10
|
* @param username The username of the user.
|
|
11
11
|
* @param password The password of the user.
|
|
12
|
-
* @param agentId The ID of the agent.
|
|
13
12
|
*
|
|
14
13
|
* @returns The token for the user.
|
|
15
14
|
*/
|
|
16
|
-
token(username: string, password: string
|
|
15
|
+
token(username: string, password: string): Promise<TokenOutput>;
|
|
17
16
|
/**
|
|
18
17
|
* This endpoint is used to get a list of available permissions in the system. The permissions are used to define
|
|
19
18
|
* the access rights of the users in the system. The permissions are defined by the system administrator.
|
|
@@ -21,4 +20,5 @@ export declare class AuthEndpoint extends AbstractEndpoint {
|
|
|
21
20
|
* @returns The available permissions in the system.
|
|
22
21
|
*/
|
|
23
22
|
getAvailablePermissions(): Promise<Permission>;
|
|
23
|
+
me(token: string): Promise<MeOutput>;
|
|
24
24
|
}
|
package/dist/endpoints/auth.js
CHANGED
|
@@ -10,18 +10,16 @@ class AuthEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
10
10
|
*
|
|
11
11
|
* @param username The username of the user.
|
|
12
12
|
* @param password The password of the user.
|
|
13
|
-
* @param agentId The ID of the agent.
|
|
14
13
|
*
|
|
15
14
|
* @returns The token for the user.
|
|
16
15
|
*/
|
|
17
|
-
async token(username, password
|
|
18
|
-
const headers = agentId ? { "X-Agent-ID": agentId } : undefined;
|
|
16
|
+
async token(username, password) {
|
|
19
17
|
const response = await this.client.getHttpClient().createHttpClient().post(this.formatUrl("/token"), {
|
|
20
18
|
json: {
|
|
21
19
|
username,
|
|
22
20
|
password,
|
|
23
21
|
},
|
|
24
|
-
}
|
|
22
|
+
});
|
|
25
23
|
const result = this.deserialize(response.data);
|
|
26
24
|
this.client.addToken(result.accessToken);
|
|
27
25
|
return result;
|
|
@@ -40,6 +38,19 @@ class AuthEndpoint extends abstract_1.AbstractEndpoint {
|
|
|
40
38
|
}
|
|
41
39
|
return this.deserialize(response.data);
|
|
42
40
|
}
|
|
41
|
+
async me(token) {
|
|
42
|
+
this.client.addToken(token);
|
|
43
|
+
const response = await this.getHttpClient().get("/me");
|
|
44
|
+
if (response.status !== 200) {
|
|
45
|
+
throw new Error(`Failed to fetch data from /me: ${response.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
const agents = response.data.agents || [];
|
|
48
|
+
response.data.agents = agents.map((agent) => {
|
|
49
|
+
agent.user = this.deserialize(agent.user);
|
|
50
|
+
return this.deserialize(agent);
|
|
51
|
+
});
|
|
52
|
+
return this.deserialize(response.data);
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
55
|
exports.AuthEndpoint = AuthEndpoint;
|
|
45
56
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/endpoints/auth.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAI5C,MAAa,YAAa,SAAQ,2BAAgB;IACpC,MAAM,GAAG,OAAO,CAAC;IAE3B
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/endpoints/auth.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAI5C,MAAa,YAAa,SAAQ,2BAAgB;IACpC,MAAM,GAAG,OAAO,CAAC;IAE3B;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,QAAgB,EA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AAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAC1C,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;YAC7C,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAO,KAAK,CAAC,IAAI,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC,WAAW,CAAa,KAAK,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,WAAW,CAAW,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACJ;AA7DD,oCA6DC"}
|
|
@@ -2,3 +2,19 @@ export declare class TokenOutput {
|
|
|
2
2
|
accessToken: string;
|
|
3
3
|
tokenType?: string | null;
|
|
4
4
|
}
|
|
5
|
+
export declare class User {
|
|
6
|
+
id: string;
|
|
7
|
+
username: string;
|
|
8
|
+
permissions: Record<string, string[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare class AgentMatch {
|
|
11
|
+
agentId: string;
|
|
12
|
+
agentName: string;
|
|
13
|
+
agentDescription?: string | null;
|
|
14
|
+
user: User;
|
|
15
|
+
}
|
|
16
|
+
export declare class MeOutput {
|
|
17
|
+
success: boolean;
|
|
18
|
+
agents: AgentMatch[];
|
|
19
|
+
autoSelected: boolean;
|
|
20
|
+
}
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenOutput = void 0;
|
|
3
|
+
exports.MeOutput = exports.AgentMatch = exports.User = exports.TokenOutput = void 0;
|
|
4
4
|
class TokenOutput {
|
|
5
5
|
accessToken;
|
|
6
6
|
tokenType = "Bearer";
|
|
7
7
|
}
|
|
8
8
|
exports.TokenOutput = TokenOutput;
|
|
9
|
+
class User {
|
|
10
|
+
id;
|
|
11
|
+
username;
|
|
12
|
+
permissions;
|
|
13
|
+
}
|
|
14
|
+
exports.User = User;
|
|
15
|
+
class AgentMatch {
|
|
16
|
+
agentId;
|
|
17
|
+
agentName;
|
|
18
|
+
agentDescription = null;
|
|
19
|
+
user;
|
|
20
|
+
}
|
|
21
|
+
exports.AgentMatch = AgentMatch;
|
|
22
|
+
class MeOutput {
|
|
23
|
+
success;
|
|
24
|
+
agents;
|
|
25
|
+
autoSelected;
|
|
26
|
+
}
|
|
27
|
+
exports.MeOutput = MeOutput;
|
|
9
28
|
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/models/api/tokens.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACpB,WAAW,CAAS;IACpB,SAAS,GAAmB,QAAQ,CAAC;CACxC;AAHD,kCAGC"}
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/models/api/tokens.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACpB,WAAW,CAAS;IACpB,SAAS,GAAmB,QAAQ,CAAC;CACxC;AAHD,kCAGC;AAED,MAAa,IAAI;IACb,EAAE,CAAS;IACX,QAAQ,CAAS;IACjB,WAAW,CAA2B;CACzC;AAJD,oBAIC;AAED,MAAa,UAAU;IACnB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,gBAAgB,GAAmB,IAAI,CAAC;IACxC,IAAI,CAAO;CACd;AALD,gCAKC;AAED,MAAa,QAAQ;IACjB,OAAO,CAAU;IACjB,MAAM,CAAe;IACrB,YAAY,CAAU;CACzB;AAJD,4BAIC"}
|