addigy 2.8.2 → 2.10.0
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 +5 -5
- package/index.d.ts +29 -80
- package/index.js +50 -1153
- package/lib/addigy.constants.d.ts +6 -0
- package/lib/addigy.constants.js +10 -0
- package/lib/addigy.d.ts +44 -0
- package/lib/addigy.js +63 -0
- package/lib/addigy.utils.d.ts +6 -0
- package/lib/addigy.utils.js +12 -0
- package/lib/alerts/alert.types.d.ts +5 -0
- package/lib/alerts/alert.types.js +9 -0
- package/lib/alerts/alerts.d.ts +7 -0
- package/lib/alerts/alerts.js +22 -0
- package/lib/applications/applications.d.ts +6 -0
- package/lib/applications/applications.js +18 -0
- package/lib/auth/auth.d.ts +9 -0
- package/lib/auth/auth.js +75 -0
- package/lib/auth/auth.types.d.ts +5 -0
- package/lib/billing/billing.d.ts +5 -0
- package/lib/billing/billing.js +36 -0
- package/lib/certs/certs.d.ts +5 -0
- package/lib/certs/certs.js +43 -0
- package/lib/commands/commands.d.ts +7 -0
- package/lib/commands/commands.js +31 -0
- package/lib/devices/devices.d.ts +11 -0
- package/lib/devices/devices.js +55 -0
- package/lib/facts/facts.d.ts +8 -0
- package/lib/facts/facts.js +66 -0
- package/lib/facts/facts.types.d.ts +22 -0
- package/lib/facts/facts.types.js +2 -0
- package/lib/files/files.d.ts +10 -0
- package/lib/files/files.js +63 -0
- package/lib/files/files.types.d.ts +26 -0
- package/lib/files/files.types.js +2 -0
- package/lib/integrations/integrations.d.ts +8 -0
- package/lib/integrations/integrations.js +63 -0
- package/lib/maintenance/maintenance.d.ts +6 -0
- package/lib/maintenance/maintenance.js +18 -0
- package/lib/mdm/mdm-configurations.d.ts +7 -0
- package/lib/mdm/mdm-configurations.js +41 -0
- package/lib/mdm/mdm-policies.d.ts +20 -0
- package/lib/mdm/mdm-policies.js +347 -0
- package/lib/mdm/mdm-profiles.d.ts +8 -0
- package/lib/mdm/mdm-profiles.js +74 -0
- package/{types.d.ts → lib/mdm/mdm.types.d.ts} +90 -180
- package/lib/mdm/mdm.types.js +2 -0
- package/lib/policies/policies.d.ts +11 -0
- package/lib/policies/policies.js +78 -0
- package/lib/profiles/profiles.d.ts +9 -0
- package/lib/profiles/profiles.js +59 -0
- package/lib/profiles/profiles.types.d.ts +20 -0
- package/lib/profiles/profiles.types.js +2 -0
- package/lib/screenconnect/screenconnect.d.ts +5 -0
- package/lib/screenconnect/screenconnect.js +39 -0
- package/lib/software/software.d.ts +13 -0
- package/lib/software/software.js +73 -0
- package/lib/software/software.types.d.ts +101 -0
- package/lib/software/software.types.js +2 -0
- package/lib/types.d.ts +20 -0
- package/lib/types.js +2 -0
- package/lib/users/user.types.d.ts +5 -0
- package/lib/users/user.types.js +9 -0
- package/lib/users/users.d.ts +9 -0
- package/lib/users/users.js +104 -0
- package/package.json +13 -14
- /package/{types.js → lib/auth/auth.types.js} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Urls = void 0;
|
|
4
|
+
var Urls;
|
|
5
|
+
(function (Urls) {
|
|
6
|
+
Urls["app"] = "https://app.addigy.com";
|
|
7
|
+
Urls["appProd"] = "https://app-prod.addigy.com";
|
|
8
|
+
Urls["api"] = "https://prod.addigy.com";
|
|
9
|
+
Urls["fileManager"] = "https://file-manager-prod.addigy.com";
|
|
10
|
+
})(Urls || (exports.Urls = Urls = {}));
|
package/lib/addigy.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IAddigyConfig } from './types';
|
|
2
|
+
import { Alerts } from './alerts/alerts';
|
|
3
|
+
import { Applications } from './applications/applications';
|
|
4
|
+
import { Billing } from './billing/billing';
|
|
5
|
+
import { Certs } from './certs/certs';
|
|
6
|
+
import { Commands } from './commands/commands';
|
|
7
|
+
import { MdmConfigurations } from './mdm/mdm-configurations';
|
|
8
|
+
import { Devices } from './devices/devices';
|
|
9
|
+
import { Facts } from './facts/facts';
|
|
10
|
+
import { Files } from './files/files';
|
|
11
|
+
import { Integrations } from './integrations/integrations';
|
|
12
|
+
import { Maintenance } from './maintenance/maintenance';
|
|
13
|
+
import { Policies } from './policies/policies';
|
|
14
|
+
import { Profiles } from './profiles/profiles';
|
|
15
|
+
import { ScreenConnect } from './screenconnect/screenconnect';
|
|
16
|
+
import { Software } from './software/software';
|
|
17
|
+
import { Users } from './users/users';
|
|
18
|
+
import { Auth } from './auth/auth';
|
|
19
|
+
import { MdmPolicies } from './mdm/mdm-policies';
|
|
20
|
+
import { MdmProfiles } from './mdm/mdm-profiles';
|
|
21
|
+
export declare class Addigy {
|
|
22
|
+
private readonly config;
|
|
23
|
+
auth: Auth;
|
|
24
|
+
alerts: Alerts;
|
|
25
|
+
apps: Applications;
|
|
26
|
+
billing: Billing;
|
|
27
|
+
certs: Certs;
|
|
28
|
+
commands: Commands;
|
|
29
|
+
devices: Devices;
|
|
30
|
+
facts: Facts;
|
|
31
|
+
files: Files;
|
|
32
|
+
integrations: Integrations;
|
|
33
|
+
maintenance: Maintenance;
|
|
34
|
+
mdmConfigurations: MdmConfigurations;
|
|
35
|
+
mdmPolicies: MdmPolicies;
|
|
36
|
+
mdmProfiles: MdmProfiles;
|
|
37
|
+
policies: Policies;
|
|
38
|
+
profiles: Profiles;
|
|
39
|
+
screenconnect: ScreenConnect;
|
|
40
|
+
software: Software;
|
|
41
|
+
users: Users;
|
|
42
|
+
private readonly http;
|
|
43
|
+
constructor(config: IAddigyConfig);
|
|
44
|
+
}
|
package/lib/addigy.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Addigy = void 0;
|
|
7
|
+
const alerts_1 = require("./alerts/alerts");
|
|
8
|
+
const applications_1 = require("./applications/applications");
|
|
9
|
+
const billing_1 = require("./billing/billing");
|
|
10
|
+
const certs_1 = require("./certs/certs");
|
|
11
|
+
const commands_1 = require("./commands/commands");
|
|
12
|
+
const mdm_configurations_1 = require("./mdm/mdm-configurations");
|
|
13
|
+
const devices_1 = require("./devices/devices");
|
|
14
|
+
const facts_1 = require("./facts/facts");
|
|
15
|
+
const files_1 = require("./files/files");
|
|
16
|
+
const integrations_1 = require("./integrations/integrations");
|
|
17
|
+
const maintenance_1 = require("./maintenance/maintenance");
|
|
18
|
+
const policies_1 = require("./policies/policies");
|
|
19
|
+
const profiles_1 = require("./profiles/profiles");
|
|
20
|
+
const screenconnect_1 = require("./screenconnect/screenconnect");
|
|
21
|
+
const software_1 = require("./software/software");
|
|
22
|
+
const users_1 = require("./users/users");
|
|
23
|
+
const axios_1 = __importDefault(require("axios"));
|
|
24
|
+
const auth_1 = require("./auth/auth");
|
|
25
|
+
const addigy_constants_1 = require("./addigy.constants");
|
|
26
|
+
const mdm_policies_1 = require("./mdm/mdm-policies");
|
|
27
|
+
const addigy_utils_1 = require("./addigy.utils");
|
|
28
|
+
const mdm_profiles_1 = require("./mdm/mdm-profiles");
|
|
29
|
+
class Addigy {
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
this.http = axios_1.default.create({
|
|
33
|
+
baseURL: `${addigy_constants_1.Urls.api}/api`,
|
|
34
|
+
...(0, addigy_utils_1.getAxiosHttpAgents)(),
|
|
35
|
+
headers: {
|
|
36
|
+
'content-type': 'application/json',
|
|
37
|
+
accept: 'application/json',
|
|
38
|
+
'client-id': this.config.clientId,
|
|
39
|
+
'client-secret': this.config.clientSecret,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
this.auth = new auth_1.Auth(config);
|
|
43
|
+
this.alerts = new alerts_1.Alerts(this.http);
|
|
44
|
+
this.apps = new applications_1.Applications(this.http);
|
|
45
|
+
this.billing = new billing_1.Billing();
|
|
46
|
+
this.certs = new certs_1.Certs();
|
|
47
|
+
this.commands = new commands_1.Commands(this.http);
|
|
48
|
+
this.devices = new devices_1.Devices(this.http, this.config);
|
|
49
|
+
this.facts = new facts_1.Facts();
|
|
50
|
+
this.files = new files_1.Files(this.config);
|
|
51
|
+
this.integrations = new integrations_1.Integrations();
|
|
52
|
+
this.maintenance = new maintenance_1.Maintenance(this.http);
|
|
53
|
+
this.mdmConfigurations = new mdm_configurations_1.MdmConfigurations();
|
|
54
|
+
this.mdmPolicies = new mdm_policies_1.MdmPolicies();
|
|
55
|
+
this.mdmProfiles = new mdm_profiles_1.MdmProfiles();
|
|
56
|
+
this.policies = new policies_1.Policies(this.http);
|
|
57
|
+
this.profiles = new profiles_1.Profiles(this.http);
|
|
58
|
+
this.screenconnect = new screenconnect_1.ScreenConnect();
|
|
59
|
+
this.software = new software_1.Software(this.http);
|
|
60
|
+
this.users = new users_1.Users();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.Addigy = Addigy;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAxiosHttpAgents = void 0;
|
|
4
|
+
const http_1 = require("http-cookie-agent/http");
|
|
5
|
+
const tough_cookie_1 = require("tough-cookie");
|
|
6
|
+
function getAxiosHttpAgents() {
|
|
7
|
+
return {
|
|
8
|
+
httpAgent: new http_1.HttpCookieAgent({ cookies: { jar: new tough_cookie_1.CookieJar() } }),
|
|
9
|
+
httpsAgent: new http_1.HttpsCookieAgent({ cookies: { jar: new tough_cookie_1.CookieJar() } }),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.getAxiosHttpAgents = getAxiosHttpAgents;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlertStatus = void 0;
|
|
4
|
+
var AlertStatus;
|
|
5
|
+
(function (AlertStatus) {
|
|
6
|
+
AlertStatus["Acknowledged"] = "Acknowledged";
|
|
7
|
+
AlertStatus["Resolved"] = "Resolved";
|
|
8
|
+
AlertStatus["Unattended"] = "Unattended";
|
|
9
|
+
})(AlertStatus || (exports.AlertStatus = AlertStatus = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AlertStatus } from './alert.types';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
export declare class Alerts {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
getAlerts(status: AlertStatus, page?: number, pageLength?: number): Promise<object[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Alerts = void 0;
|
|
4
|
+
class Alerts {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async getAlerts(status, page = 1, pageLength = 10) {
|
|
9
|
+
let statusUri = '';
|
|
10
|
+
if (status) {
|
|
11
|
+
statusUri = `&status=${status}`;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
let res = await this.http.get(`alerts?page=${page}&per_page=${pageLength}` + statusUri);
|
|
15
|
+
return res.data;
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Alerts = Alerts;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Applications = void 0;
|
|
4
|
+
class Applications {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async getInstalledApplications() {
|
|
9
|
+
try {
|
|
10
|
+
let res = await this.http.get('applications');
|
|
11
|
+
return res.data;
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Applications = Applications;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAddigyConfig } from '../types';
|
|
2
|
+
import { IAddigyInternalAuthObject } from './auth.types';
|
|
3
|
+
export declare class Auth {
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(config: IAddigyConfig);
|
|
7
|
+
getAuthObject(): Promise<IAddigyInternalAuthObject>;
|
|
8
|
+
getImpersonationAuthObject(authObject: IAddigyInternalAuthObject, orgId: string): Promise<IAddigyInternalAuthObject>;
|
|
9
|
+
}
|
package/lib/auth/auth.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Auth = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const addigy_constants_1 = require("../addigy.constants");
|
|
9
|
+
const addigy_utils_1 = require("../addigy.utils");
|
|
10
|
+
class Auth {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.http = axios_1.default.create({
|
|
14
|
+
baseURL: addigy_constants_1.Urls.api,
|
|
15
|
+
...(0, addigy_utils_1.getAxiosHttpAgents)(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async getAuthObject() {
|
|
19
|
+
let postBody = {
|
|
20
|
+
username: this.config.adminUsername,
|
|
21
|
+
password: this.config.adminPassword,
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
if (!this.config.adminUsername || !this.config.adminPassword)
|
|
25
|
+
throw new Error("The function you are using hits Addigy's internal API, but no username or " +
|
|
26
|
+
'password was provided in the constructor. Please fill out the adminUsername and ' +
|
|
27
|
+
'adminPassword parameters.');
|
|
28
|
+
let res = await this.http.post('signin', postBody);
|
|
29
|
+
return {
|
|
30
|
+
orgId: res.data.orgid,
|
|
31
|
+
authToken: res.data.authtoken,
|
|
32
|
+
emailAddress: res.data.email,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async getImpersonationAuthObject(authObject, orgId) {
|
|
40
|
+
let postBody = {
|
|
41
|
+
parent_orgid: authObject.orgId,
|
|
42
|
+
child_orgid: orgId,
|
|
43
|
+
user_email: authObject.emailAddress,
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
let res = await this.http.post('api/impersonation', postBody, {
|
|
47
|
+
headers: {
|
|
48
|
+
Cookie: `prod_auth_token=${authObject.authToken};`,
|
|
49
|
+
origin: addigy_constants_1.Urls.app,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const cookies = res.headers['set-cookie'];
|
|
53
|
+
if (!(cookies && cookies.length))
|
|
54
|
+
throw new Error('No set-cookie found in response');
|
|
55
|
+
const cookie = cookies.find((e) => e.includes('prod_auth_token') && !e.includes('original_auth_token'));
|
|
56
|
+
if (!cookie)
|
|
57
|
+
throw new Error('No auth cookie found');
|
|
58
|
+
const tokenPart1 = cookie.split('auth_token=')[1];
|
|
59
|
+
if (!tokenPart1)
|
|
60
|
+
throw new Error('No token found in cookie');
|
|
61
|
+
const authToken = tokenPart1.split(';')[0];
|
|
62
|
+
if (!authToken)
|
|
63
|
+
throw new Error('No token found in cookie');
|
|
64
|
+
return {
|
|
65
|
+
orgId: orgId,
|
|
66
|
+
authToken,
|
|
67
|
+
emailAddress: authObject.emailAddress,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Auth = Auth;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Billing = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const addigy_constants_1 = require("../addigy.constants");
|
|
9
|
+
const addigy_utils_1 = require("../addigy.utils");
|
|
10
|
+
class Billing {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.http = axios_1.default.create({
|
|
13
|
+
baseURL: `${addigy_constants_1.Urls.appProd}/api/billing`,
|
|
14
|
+
...(0, addigy_utils_1.getAxiosHttpAgents)(),
|
|
15
|
+
headers: {
|
|
16
|
+
origin: addigy_constants_1.Urls.appProd,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async getBillingData(authObject) {
|
|
21
|
+
try {
|
|
22
|
+
let res = await this.http.get('get_chargeover_billing_data', {
|
|
23
|
+
headers: {
|
|
24
|
+
Cookie: `auth_token=${authObject.authToken};`,
|
|
25
|
+
email: authObject.emailAddress,
|
|
26
|
+
orgid: authObject.orgId,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return res.data;
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.Billing = Billing;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Certs = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const addigy_constants_1 = require("../addigy.constants");
|
|
9
|
+
const addigy_utils_1 = require("../addigy.utils");
|
|
10
|
+
class Certs {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.http = axios_1.default.create({
|
|
13
|
+
baseURL: `${addigy_constants_1.Urls.appProd}/api`,
|
|
14
|
+
...(0, addigy_utils_1.getAxiosHttpAgents)(),
|
|
15
|
+
headers: {
|
|
16
|
+
origin: addigy_constants_1.Urls.appProd,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async getApnsCerts(authObject, next, previous) {
|
|
21
|
+
let url = 'apn/user/apn/list';
|
|
22
|
+
if (next) {
|
|
23
|
+
url = `${url}?next=${next}`;
|
|
24
|
+
}
|
|
25
|
+
if (previous) {
|
|
26
|
+
url = `${url}?previous=${previous}`;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
let res = await this.http.get(url, {
|
|
30
|
+
headers: {
|
|
31
|
+
Cookie: `auth_token=${authObject.authToken};`,
|
|
32
|
+
email: authObject.emailAddress,
|
|
33
|
+
orgid: authObject.orgId,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return res.data.items;
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Certs = Certs;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare class Commands {
|
|
3
|
+
private readonly http;
|
|
4
|
+
constructor(http: AxiosInstance);
|
|
5
|
+
runCommand(agentIds: string[], command: string): Promise<object[]>;
|
|
6
|
+
getCommandOutput(actionId: string, agentId: string): Promise<object[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Commands = void 0;
|
|
4
|
+
class Commands {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async runCommand(agentIds, command) {
|
|
9
|
+
let postBody = {
|
|
10
|
+
agent_ids: agentIds,
|
|
11
|
+
command: command,
|
|
12
|
+
};
|
|
13
|
+
try {
|
|
14
|
+
let res = await this.http.post(`devices/commands`, postBody);
|
|
15
|
+
return res.data;
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async getCommandOutput(actionId, agentId) {
|
|
22
|
+
try {
|
|
23
|
+
let res = await this.http.get(`devices/output?action_id=${actionId}&agentid=${agentId}`);
|
|
24
|
+
return res.data;
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Commands = Commands;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { IAddigyConfig } from '../types';
|
|
3
|
+
export declare class Devices {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: IAddigyConfig);
|
|
7
|
+
getOnlineDevices(): Promise<object[]>;
|
|
8
|
+
getDevices(): Promise<object[]>;
|
|
9
|
+
getPolicyDevices(policyId: string): Promise<object[]>;
|
|
10
|
+
updateDevicePolicy(policyId: string, agentId: string): Promise<object[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Devices = void 0;
|
|
4
|
+
class Devices {
|
|
5
|
+
constructor(http, config) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async getOnlineDevices() {
|
|
10
|
+
try {
|
|
11
|
+
let res = await this.http.get(`devices/online`);
|
|
12
|
+
return res.data;
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
throw err;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async getDevices() {
|
|
19
|
+
try {
|
|
20
|
+
let res = await this.http.get(`devices`);
|
|
21
|
+
return res.data;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async getPolicyDevices(policyId) {
|
|
28
|
+
try {
|
|
29
|
+
let res = await this.http.get(`policies/devices?policy_id=${policyId}`);
|
|
30
|
+
return res.data;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async updateDevicePolicy(policyId, agentId) {
|
|
37
|
+
let postBody = {
|
|
38
|
+
policy_id: policyId,
|
|
39
|
+
agent_id: agentId,
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
let res = await this.http.post(`policies/devices`, postBody, {
|
|
43
|
+
headers: {
|
|
44
|
+
'client-id': this.config.clientId,
|
|
45
|
+
'client-secret': this.config.clientSecret,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
return res.data;
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Devices = Devices;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IAddigyInternalAuthObject } from '../auth/auth.types';
|
|
2
|
+
import { CustomFact } from './facts.types';
|
|
3
|
+
export declare class Facts {
|
|
4
|
+
private readonly http;
|
|
5
|
+
createCustomFact(authObject: IAddigyInternalAuthObject, name: string, script: string, scriptType: 'bash' | 'python' | 'zsh'): Promise<CustomFact>;
|
|
6
|
+
getCustomFacts(authObject: IAddigyInternalAuthObject): Promise<CustomFact[]>;
|
|
7
|
+
getCustomFactByName(authObject: IAddigyInternalAuthObject, name: string): Promise<CustomFact | undefined>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Facts = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const addigy_constants_1 = require("../addigy.constants");
|
|
9
|
+
const addigy_utils_1 = require("../addigy.utils");
|
|
10
|
+
class Facts {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.http = axios_1.default.create({
|
|
13
|
+
baseURL: `${addigy_constants_1.Urls.appProd}/api/services/facts`,
|
|
14
|
+
...(0, addigy_utils_1.getAxiosHttpAgents)(),
|
|
15
|
+
headers: {
|
|
16
|
+
origin: addigy_constants_1.Urls.appProd,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async createCustomFact(authObject, name, script, scriptType) {
|
|
21
|
+
const shebang = {
|
|
22
|
+
bash: '#!/bin/bash',
|
|
23
|
+
python: '#!/usr/bin/python',
|
|
24
|
+
zsh: '#!/bin/zsh',
|
|
25
|
+
};
|
|
26
|
+
const body = {
|
|
27
|
+
name,
|
|
28
|
+
os_architectures: {
|
|
29
|
+
linux_arm: {
|
|
30
|
+
is_supported: false,
|
|
31
|
+
language: '',
|
|
32
|
+
shebang: '',
|
|
33
|
+
script: '',
|
|
34
|
+
},
|
|
35
|
+
darwin_amd64: {
|
|
36
|
+
is_supported: true,
|
|
37
|
+
language: scriptType,
|
|
38
|
+
shebang: shebang[scriptType],
|
|
39
|
+
script,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
return_type: 'string',
|
|
43
|
+
};
|
|
44
|
+
const res = await this.http.post('custom', body, {
|
|
45
|
+
headers: {
|
|
46
|
+
Cookie: `auth_token=${authObject.authToken};`,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return res.data;
|
|
50
|
+
}
|
|
51
|
+
async getCustomFacts(authObject) {
|
|
52
|
+
var _a;
|
|
53
|
+
const res = await this.http.get('custom', {
|
|
54
|
+
headers: {
|
|
55
|
+
Cookie: `auth_token=${authObject.authToken};`,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const results = res.data;
|
|
59
|
+
return (_a = results.custom_facts) !== null && _a !== void 0 ? _a : [];
|
|
60
|
+
}
|
|
61
|
+
async getCustomFactByName(authObject, name) {
|
|
62
|
+
const facts = await this.getCustomFacts(authObject);
|
|
63
|
+
return facts.find((e) => e.name === name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Facts = Facts;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface CustomFact {
|
|
2
|
+
organization_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
return_type: string;
|
|
5
|
+
identifier: string;
|
|
6
|
+
version: number;
|
|
7
|
+
os_architectures: CustomFactOSArchitectures;
|
|
8
|
+
notes: string;
|
|
9
|
+
provider: string;
|
|
10
|
+
source: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CustomFactOSArchitectures {
|
|
13
|
+
linux_arm: CustomFactOSArchitecturesData;
|
|
14
|
+
darwin_amd64: CustomFactOSArchitecturesData;
|
|
15
|
+
}
|
|
16
|
+
export interface CustomFactOSArchitecturesData {
|
|
17
|
+
language: string;
|
|
18
|
+
is_supported: boolean;
|
|
19
|
+
shebang: string;
|
|
20
|
+
script: string;
|
|
21
|
+
md5_hash: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAddigyConfig } from '../types';
|
|
2
|
+
import { IAddigyInternalAuthObject } from '../auth/auth.types';
|
|
3
|
+
export declare class Files {
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(config: IAddigyConfig);
|
|
7
|
+
getFileUploadUrl(fileName: string, contentType?: string): Promise<string>;
|
|
8
|
+
uploadFile(uploadUrl: string, file: object, contentType?: string): Promise<object[]>;
|
|
9
|
+
getFileVaultKeys(authObject: IAddigyInternalAuthObject): Promise<object[]>;
|
|
10
|
+
}
|