node-alarm-dot-com 2.2.0 → 2.3.0-beta.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/dist/_models/AuthOpts.js +1 -0
- package/dist/_models/AuthOpts.js.map +1 -0
- package/dist/_models/DeviceStates.d.ts +1 -1
- package/dist/_models/DeviceStates.js +1 -0
- package/dist/_models/DeviceStates.js.map +1 -0
- package/dist/_models/IdentityResponse.js +1 -0
- package/dist/_models/IdentityResponse.js.map +1 -0
- package/dist/_models/PartitionActionOptions.js +1 -0
- package/dist/_models/PartitionActionOptions.js.map +1 -0
- package/dist/_models/RequestOptions.d.ts +2 -3
- package/dist/_models/RequestOptions.js +1 -0
- package/dist/_models/RequestOptions.js.map +1 -0
- package/dist/_models/SensorType.js +1 -1
- package/dist/_models/SensorType.js.map +1 -0
- package/dist/_models/States.js +1 -1
- package/dist/_models/States.js.map +1 -0
- package/dist/_models/SystemState.js +1 -0
- package/dist/_models/SystemState.js.map +1 -0
- package/dist/_utils.d.ts +34 -0
- package/dist/_utils.js +147 -0
- package/dist/_utils.js.map +1 -0
- package/dist/core.d.ts +29 -0
- package/dist/core.js +163 -0
- package/dist/core.js.map +1 -0
- package/dist/garages.d.ts +17 -0
- package/dist/garages.js +38 -0
- package/dist/garages.js.map +1 -0
- package/dist/index.d.ts +8 -171
- package/dist/index.js +13 -629
- package/dist/index.js.map +1 -0
- package/dist/lights.d.ts +23 -0
- package/dist/lights.js +76 -0
- package/dist/lights.js.map +1 -0
- package/dist/locks.d.ts +19 -0
- package/dist/locks.js +44 -0
- package/dist/locks.js.map +1 -0
- package/dist/partitions.d.ts +40 -0
- package/dist/partitions.js +83 -0
- package/dist/partitions.js.map +1 -0
- package/dist/thermostats.d.ts +29 -0
- package/dist/thermostats.js +61 -0
- package/dist/thermostats.js.map +1 -0
- package/package.json +11 -6
package/dist/_models/AuthOpts.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthOpts.js","sourceRoot":"","sources":["../../src/_models/AuthOpts.ts"],"names":[],"mappings":""}
|
|
@@ -1097,7 +1097,7 @@ export interface ApiAccessControlState extends ApiDeviceState {
|
|
|
1097
1097
|
remoteCommandsEnabled: boolean;
|
|
1098
1098
|
hasPermissionToChangeState: boolean;
|
|
1099
1099
|
deviceIcon: {
|
|
1100
|
-
|
|
1100
|
+
icon: number;
|
|
1101
1101
|
};
|
|
1102
1102
|
batteryLevelNull: null;
|
|
1103
1103
|
batteryLevelClassification: null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceStates.js","sourceRoot":"","sources":["../../src/_models/DeviceStates.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityResponse.js","sourceRoot":"","sources":["../../src/_models/IdentityResponse.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartitionActionOptions.js","sourceRoot":"","sources":["../../src/_models/PartitionActionOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestOptions.js","sourceRoot":"","sources":["../../src/_models/RequestOptions.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SensorType = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
4
|
/**
|
|
6
5
|
* Number indicating the type of sensor according to the Alarm.com API
|
|
7
6
|
*/
|
|
@@ -19,3 +18,4 @@ var SensorType;
|
|
|
19
18
|
SensorType[SensorType["Panel_Camera"] = 68] = "Panel_Camera";
|
|
20
19
|
SensorType[SensorType["Panel_Glass_Break"] = 83] = "Panel_Glass_Break";
|
|
21
20
|
})(SensorType || (exports.SensorType = SensorType = {}));
|
|
21
|
+
//# sourceMappingURL=SensorType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SensorType.js","sourceRoot":"","sources":["../../src/_models/SensorType.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,+DAAkB,CAAA;IAClB,6DAAiB,CAAA;IACjB,+DAAkB,CAAA;IAClB,yDAAe,CAAA;IACf,6DAAiB,CAAA;IACjB,yCAAO,CAAA;IACP,gDAAW,CAAA;IACX,4DAAiB,CAAA;IACjB,0DAAgB,CAAA;IAChB,4DAAiB,CAAA;IACjB,sEAAsB,CAAA;AACxB,CAAC,EAZW,UAAU,0BAAV,UAAU,QAYrB"}
|
package/dist/_models/States.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.REL_TYPES = exports.THERMOSTAT_STATES = exports.GARAGE_STATES = exports.LOCK_STATES = exports.LIGHT_STATES = exports.SENSOR_STATES = exports.SYSTEM_STATES = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
4
|
/***
|
|
6
5
|
* State of the partition as defined by Alarm.com
|
|
7
6
|
* @readonly
|
|
@@ -93,3 +92,4 @@ var REL_TYPES;
|
|
|
93
92
|
REL_TYPES["SCENE"] = "automation/scene";
|
|
94
93
|
REL_TYPES["ACCESS_CONTROL"] = "devices/access-control-access-point-device";
|
|
95
94
|
})(REL_TYPES || (exports.REL_TYPES = REL_TYPES = {}));
|
|
95
|
+
//# sourceMappingURL=States.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"States.js","sourceRoot":"","sources":["../../src/_models/States.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,yDAAY,CAAA;IACZ,6DAAc,CAAA;IACd,6DAAc,CAAA;IACd,+DAAe,CA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
|
|
1
|
+
{"version":3,"file":"SystemState.js","sourceRoot":"","sources":["../../src/_models/SystemState.ts"],"names":[],"mappings":";;;AAuMA,IAAY,gBAeX;AAfD,WAAY,gBAAgB;IAC1B,mDAA+B,CAAA;IAC/B,yCAAqB,CAAA;IACrB,2CAAuB,CAAA;IACvB,sDAAkC,CAAA;IAClC,8CAA0B,CAAA;IAC1B,6CAAyB,CAAA;IACzB,2CAAuB,CAAA;IACvB,qDAAiC,CAAA;IACjC,wDAAoC,CAAA;IACpC,kDAA8B,CAAA;IAC9B,0DAAsC,CAAA;IACtC,6CAAyB,CAAA;IACzB,gDAA4B,CAAA;IAC5B,gFAA4D,CAAA;AAC9D,CAAC,EAfW,gBAAgB,gCAAhB,gBAAgB,QAe3B;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yDAAuC,CAAA;IACvC,oEAAkD,CAAA;AACpD,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB"}
|
package/dist/_utils.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
import { AuthOpts } from './_models/AuthOpts';
|
|
3
|
+
import { ApiDeviceState } from './_models/DeviceStates';
|
|
4
|
+
export declare const ADCLOGIN_URL = "https://www.alarm.com/login";
|
|
5
|
+
export declare const ADCFORMLOGIN_URL = "https://www.alarm.com/web/Default.aspx";
|
|
6
|
+
export declare const IDENTITIES_URL = "https://www.alarm.com/web/api/identities";
|
|
7
|
+
export declare const HOME_URL = "https://www.alarm.com/web/system/home";
|
|
8
|
+
export declare const SYSTEM_URL = "https://www.alarm.com/web/api/systems/systems/";
|
|
9
|
+
export declare const PARTITIONS_URL = "https://www.alarm.com/web/api/devices/partitions/";
|
|
10
|
+
export declare const SENSORS_URL = "https://www.alarm.com/web/api/devices/sensors";
|
|
11
|
+
export declare const LIGHTS_URL = "https://www.alarm.com/web/api/devices/lights/";
|
|
12
|
+
export declare const GARAGE_URL = "https://www.alarm.com/web/api/devices/garageDoors/";
|
|
13
|
+
export declare const THERMOSTAT_URL = "https://www.alarm.com/web/api/devices/thermostats/";
|
|
14
|
+
export declare const LOCKS_URL = "https://www.alarm.com/web/api/devices/locks/";
|
|
15
|
+
export declare const UA: string;
|
|
16
|
+
export declare function authenticatedGet(url: string, opts: AuthOpts): Promise<any>;
|
|
17
|
+
export declare function authenticatedPost(url: string, opts: AuthOpts & {
|
|
18
|
+
body?: Record<string, unknown>;
|
|
19
|
+
}): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* Get information about groups of components e.g., sensors, lights, locks, garages, etc.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} url Base request url.
|
|
24
|
+
* @param {string} componentIDs Array of ID to retrieve.
|
|
25
|
+
* @param {Object} authOpts Authentication object returned from the login.
|
|
26
|
+
* @returns {Promise}
|
|
27
|
+
*/
|
|
28
|
+
export declare function getComponents(url: string, componentIDs: string[], authOpts: AuthOpts): Promise<ApiDeviceState>;
|
|
29
|
+
export declare function get(url: string, opts?: {
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
headers: fetch.Headers;
|
|
33
|
+
body: any;
|
|
34
|
+
}>;
|
package/dist/_utils.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
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.UA = exports.LOCKS_URL = exports.THERMOSTAT_URL = exports.GARAGE_URL = exports.LIGHTS_URL = exports.SENSORS_URL = exports.PARTITIONS_URL = exports.SYSTEM_URL = exports.HOME_URL = exports.IDENTITIES_URL = exports.ADCFORMLOGIN_URL = exports.ADCLOGIN_URL = void 0;
|
|
7
|
+
exports.authenticatedGet = authenticatedGet;
|
|
8
|
+
exports.authenticatedPost = authenticatedPost;
|
|
9
|
+
exports.getComponents = getComponents;
|
|
10
|
+
exports.get = get;
|
|
11
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
12
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
13
|
+
exports.ADCLOGIN_URL = 'https://www.alarm.com/login';
|
|
14
|
+
exports.ADCFORMLOGIN_URL = 'https://www.alarm.com/web/Default.aspx';
|
|
15
|
+
exports.IDENTITIES_URL = 'https://www.alarm.com/web/api/identities';
|
|
16
|
+
exports.HOME_URL = 'https://www.alarm.com/web/system/home';
|
|
17
|
+
exports.SYSTEM_URL = 'https://www.alarm.com/web/api/systems/systems/';
|
|
18
|
+
exports.PARTITIONS_URL = 'https://www.alarm.com/web/api/devices/partitions/';
|
|
19
|
+
exports.SENSORS_URL = 'https://www.alarm.com/web/api/devices/sensors';
|
|
20
|
+
exports.LIGHTS_URL = 'https://www.alarm.com/web/api/devices/lights/';
|
|
21
|
+
exports.GARAGE_URL = 'https://www.alarm.com/web/api/devices/garageDoors/';
|
|
22
|
+
exports.THERMOSTAT_URL = 'https://www.alarm.com/web/api/devices/thermostats/';
|
|
23
|
+
exports.LOCKS_URL = 'https://www.alarm.com/web/api/devices/locks/';
|
|
24
|
+
exports.UA = `node-alarm-dot-com/${package_json_1.default.version}`;
|
|
25
|
+
async function authenticatedGet(url, opts) {
|
|
26
|
+
const headers = {
|
|
27
|
+
Accept: 'application/vnd.api+json',
|
|
28
|
+
ajaxrequestuniquekey: opts.ajaxKey,
|
|
29
|
+
Cookie: opts.cookie,
|
|
30
|
+
Referer: exports.HOME_URL,
|
|
31
|
+
'User-Agent': exports.UA
|
|
32
|
+
};
|
|
33
|
+
const res = await get(url, { headers });
|
|
34
|
+
return res.body;
|
|
35
|
+
}
|
|
36
|
+
async function authenticatedPost(url, opts) {
|
|
37
|
+
const headers = {
|
|
38
|
+
Accept: 'application/vnd.api+json',
|
|
39
|
+
ajaxrequestuniquekey: opts.ajaxKey,
|
|
40
|
+
Cookie: opts.cookie,
|
|
41
|
+
Referer: exports.HOME_URL,
|
|
42
|
+
'User-Agent': exports.UA,
|
|
43
|
+
'Content-Type': 'application/json; charset=UTF-8'
|
|
44
|
+
};
|
|
45
|
+
const res = await post(url, { headers, body: opts.body });
|
|
46
|
+
return res.body;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get information about groups of components e.g., sensors, lights, locks, garages, etc.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} url Base request url.
|
|
52
|
+
* @param {string} componentIDs Array of ID to retrieve.
|
|
53
|
+
* @param {Object} authOpts Authentication object returned from the login.
|
|
54
|
+
* @returns {Promise}
|
|
55
|
+
*/
|
|
56
|
+
async function getComponents(url, componentIDs, authOpts) {
|
|
57
|
+
const IDs = Array.isArray(componentIDs) ? componentIDs : [componentIDs];
|
|
58
|
+
let requests = [];
|
|
59
|
+
if (IDs.length <= 50) {
|
|
60
|
+
const getUrl = `${url}?${IDs.map((id) => `ids%5B%5D=${id}`).join('&')}`;
|
|
61
|
+
requests.push(authenticatedGet(getUrl, authOpts));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// We have found that the Alarm.com API will return a 404 error when there is an excessive number of query parameters.
|
|
65
|
+
// We get around this by breaking up our GET calls into shorter URIs.
|
|
66
|
+
const shortenedUrls = [];
|
|
67
|
+
while (IDs.length > 50) {
|
|
68
|
+
const currentArray = IDs.splice(0, 50);
|
|
69
|
+
shortenedUrls.push(`${url}?${currentArray.map((id) => `ids%5B%5D=${id}`).join('&')}`);
|
|
70
|
+
}
|
|
71
|
+
shortenedUrls.push(`${url}?${IDs.map((id) => `ids%5B%5D=${id}`).join('&')}`);
|
|
72
|
+
requests = shortenedUrls.map((u) => authenticatedGet(u, authOpts));
|
|
73
|
+
}
|
|
74
|
+
return await combineAPIDeviceAPICalls(requests);
|
|
75
|
+
}
|
|
76
|
+
async function combineAPIDeviceAPICalls(apiCalls) {
|
|
77
|
+
const apiStateCalls = await Promise.all(apiCalls);
|
|
78
|
+
const stateToReturn = {
|
|
79
|
+
data: [],
|
|
80
|
+
included: []
|
|
81
|
+
};
|
|
82
|
+
for (const apiCall of apiStateCalls) {
|
|
83
|
+
for (const apiData of apiCall.data) {
|
|
84
|
+
stateToReturn.data.push(apiData);
|
|
85
|
+
}
|
|
86
|
+
for (const apiInclude of apiCall.included) {
|
|
87
|
+
stateToReturn.included.push(apiInclude);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
stateToReturn.meta = apiStateCalls[0].meta;
|
|
91
|
+
return stateToReturn;
|
|
92
|
+
}
|
|
93
|
+
async function get(url, opts) {
|
|
94
|
+
let status;
|
|
95
|
+
let resHeaders;
|
|
96
|
+
try {
|
|
97
|
+
const res = await (0, node_fetch_1.default)(url, {
|
|
98
|
+
method: 'GET',
|
|
99
|
+
redirect: 'manual',
|
|
100
|
+
headers: opts?.headers
|
|
101
|
+
});
|
|
102
|
+
status = res.status;
|
|
103
|
+
resHeaders = res.headers;
|
|
104
|
+
const type = res.headers.get('content-type') || '';
|
|
105
|
+
const body = await (type.indexOf('json') !== -1 ? (res.status === 204 ? {} : res.json()) : res.text());
|
|
106
|
+
if (status === 409) {
|
|
107
|
+
throw new Error('Two factor is enabled on this account but not setup in the plugin.' + ' See the wiki for details');
|
|
108
|
+
}
|
|
109
|
+
if (status >= 400) {
|
|
110
|
+
throw new Error(body.Message || body || status);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
headers: resHeaders,
|
|
114
|
+
body: body
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
throw new Error(`GET ${url} failed: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function post(url, opts) {
|
|
122
|
+
opts = opts || {};
|
|
123
|
+
let status;
|
|
124
|
+
let resHeaders;
|
|
125
|
+
try {
|
|
126
|
+
const res = await (0, node_fetch_1.default)(url, {
|
|
127
|
+
method: 'POST',
|
|
128
|
+
redirect: 'manual',
|
|
129
|
+
body: opts.body ? JSON.stringify(opts.body) : undefined,
|
|
130
|
+
headers: opts.headers
|
|
131
|
+
});
|
|
132
|
+
status = res.status;
|
|
133
|
+
resHeaders = res.headers;
|
|
134
|
+
const json = await (res.status === 204 ? {} : res.json());
|
|
135
|
+
if (status !== 200) {
|
|
136
|
+
throw new Error(json.Message || status);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
headers: resHeaders,
|
|
140
|
+
body: json
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
throw new Error(`POST ${url} failed: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_utils.js","sourceRoot":"","sources":["../src/_utils.ts"],"names":[],"mappings":";;;;;;AAmBA,4CAUC;AAED,8CAWC;AAUD,sCAmBC;AAwBD,kBAgCC;AA/HD,4DAA4C;AAC5C,mEAA0C;AAK7B,QAAA,YAAY,GAAG,6BAA6B,CAAC;AAC7C,QAAA,gBAAgB,GAAG,wCAAwC,CAAC;AAC5D,QAAA,cAAc,GAAG,0CAA0C,CAAC;AAC5D,QAAA,QAAQ,GAAG,uCAAuC,CAAC;AACnD,QAAA,UAAU,GAAG,gDAAgD,CAAC;AAC9D,QAAA,cAAc,GAAG,mDAAmD,CAAC;AACrE,QAAA,WAAW,GAAG,+CAA+C,CAAC;AAC9D,QAAA,UAAU,GAAG,+CAA+C,CAAC;AAC7D,QAAA,UAAU,GAAG,oDAAoD,CAAC;AAClE,QAAA,cAAc,GAAG,oDAAoD,CAAC;AACtE,QAAA,SAAS,GAAG,8CAA8C,CAAC;AAC3D,QAAA,EAAE,GAAG,sBAAsB,sBAAW,CAAC,OAAO,EAAE,CAAC;AAEvD,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,IAAc;IA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AG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,YAAY,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuthOpts } from './_models/AuthOpts';
|
|
2
|
+
import { IdentityResponse } from './_models/IdentityResponse';
|
|
3
|
+
import { FlattenedSystemState } from './_models/SystemState';
|
|
4
|
+
/**
|
|
5
|
+
* Authenticate with alarm.com.
|
|
6
|
+
* Returns an authentication object that can be passed to other methods.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} username Alarm.com username.
|
|
9
|
+
* @param {string} password Alarm.com password.
|
|
10
|
+
* @param {string} existingMfaToken MFA token from browser used to bypass MFA.
|
|
11
|
+
* @returns {Promise}
|
|
12
|
+
*/
|
|
13
|
+
export declare function login(username: string, password: string, existingMfaToken?: string): Promise<AuthOpts>;
|
|
14
|
+
/**
|
|
15
|
+
* This function returns the alarm.com system identity for the currently logged in system.
|
|
16
|
+
* The information returned is useful for finding current systems and global config.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getIdentitiesState(loginCookies: string, ajaxKey: string): Promise<IdentityResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve information about the current state of a security system including
|
|
21
|
+
* attributes, partitions, accessory components and relationships.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} systemID ID of the system to query. The Authentication
|
|
24
|
+
* object returned from the `login` method contains a `systems` property which
|
|
25
|
+
* is an array of system IDs.
|
|
26
|
+
* @param {Object} authOpts Authentication object returned from the login.
|
|
27
|
+
* @returns {Promise}
|
|
28
|
+
*/
|
|
29
|
+
export declare function getCurrentState(systemID: string, authOpts: AuthOpts): Promise<FlattenedSystemState>;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
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.login = login;
|
|
7
|
+
exports.getIdentitiesState = getIdentitiesState;
|
|
8
|
+
exports.getCurrentState = getCurrentState;
|
|
9
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
10
|
+
const _utils_1 = require("./_utils");
|
|
11
|
+
/**
|
|
12
|
+
* Authenticate with alarm.com.
|
|
13
|
+
* Returns an authentication object that can be passed to other methods.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} username Alarm.com username.
|
|
16
|
+
* @param {string} password Alarm.com password.
|
|
17
|
+
* @param {string} existingMfaToken MFA token from browser used to bypass MFA.
|
|
18
|
+
* @returns {Promise}
|
|
19
|
+
*/
|
|
20
|
+
async function login(username, password, existingMfaToken) {
|
|
21
|
+
let loginCookies = '';
|
|
22
|
+
let ajaxKey = '';
|
|
23
|
+
let loginFormBody = '';
|
|
24
|
+
let identities = {};
|
|
25
|
+
let systems = [];
|
|
26
|
+
// load initial alarm.com page to gather required hidden form fields
|
|
27
|
+
await (0, _utils_1.get)(_utils_1.ADCLOGIN_URL)
|
|
28
|
+
.then((res) => {
|
|
29
|
+
const loginObj = {
|
|
30
|
+
__EVENTTARGET: null,
|
|
31
|
+
__EVENTARGUMENT: null,
|
|
32
|
+
__VIEWSTATEENCRYPTED: null,
|
|
33
|
+
__EVENTVALIDATION: res.body.match(/name="__EVENTVALIDATION".*?value="([^"]*)"/)[1],
|
|
34
|
+
__VIEWSTATE: res.body.match(/name="__VIEWSTATE".*?value="([^"]*)"/)[1],
|
|
35
|
+
__VIEWSTATEGENERATOR: res.body.match(/name="__VIEWSTATEGENERATOR".*?value="([^"]*)"/)[1],
|
|
36
|
+
__PREVIOUSPAGE: res.body.match(/name="__PREVIOUSPAGE".*?value="([^"]*)"/)[1],
|
|
37
|
+
IsFromNewSite: '1',
|
|
38
|
+
ctl00$ContentPlaceHolder1$loginform$txtUserName: username,
|
|
39
|
+
txtPassword: password
|
|
40
|
+
};
|
|
41
|
+
// build login form body
|
|
42
|
+
loginFormBody = Object.keys(loginObj)
|
|
43
|
+
.map((k) => encodeURIComponent(k) + '=' + encodeURIComponent(String(loginObj[k])))
|
|
44
|
+
.join('&');
|
|
45
|
+
})
|
|
46
|
+
.catch((err) => {
|
|
47
|
+
throw new Error(`GET ${_utils_1.ADCLOGIN_URL} failed: ${err.message || err}`);
|
|
48
|
+
});
|
|
49
|
+
await (0, node_fetch_1.default)(_utils_1.ADCFORMLOGIN_URL, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
53
|
+
'User-Agent': _utils_1.UA,
|
|
54
|
+
Cookie: `twoFactorAuthenticationId=${existingMfaToken};`
|
|
55
|
+
},
|
|
56
|
+
body: loginFormBody,
|
|
57
|
+
redirect: 'manual'
|
|
58
|
+
})
|
|
59
|
+
.then((res) => {
|
|
60
|
+
loginCookies = (res.headers.raw()['set-cookie'] ?? []).map((c) => c.split(';')[0]).join('; ');
|
|
61
|
+
// gather ajaxkey for session headers
|
|
62
|
+
const re = /afg=([^;]+);/.exec(loginCookies);
|
|
63
|
+
if (!re) {
|
|
64
|
+
throw new Error(`No afg cookie: ${loginCookies}`);
|
|
65
|
+
}
|
|
66
|
+
ajaxKey = re[1] ?? '';
|
|
67
|
+
})
|
|
68
|
+
.catch((err) => {
|
|
69
|
+
throw new Error(`POST ${_utils_1.ADCFORMLOGIN_URL} failed: ${err.message || err}`);
|
|
70
|
+
});
|
|
71
|
+
await getIdentitiesState(loginCookies, ajaxKey)
|
|
72
|
+
.then((res) => {
|
|
73
|
+
identities = res;
|
|
74
|
+
systems = (res.data || []).map((d) => {
|
|
75
|
+
return d.relationships.selectedSystem.data.id;
|
|
76
|
+
});
|
|
77
|
+
})
|
|
78
|
+
.catch((err) => {
|
|
79
|
+
throw new Error(`GET ${_utils_1.IDENTITIES_URL} failed: ${err.message || err}`);
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
cookie: loginCookies,
|
|
83
|
+
ajaxKey: ajaxKey,
|
|
84
|
+
systems: systems,
|
|
85
|
+
identities: identities
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* This function returns the alarm.com system identity for the currently logged in system.
|
|
90
|
+
* The information returned is useful for finding current systems and global config.
|
|
91
|
+
*/
|
|
92
|
+
async function getIdentitiesState(loginCookies, ajaxKey) {
|
|
93
|
+
return await (0, _utils_1.get)(_utils_1.IDENTITIES_URL, {
|
|
94
|
+
headers: {
|
|
95
|
+
Accept: 'application/vnd.api+json',
|
|
96
|
+
Cookie: loginCookies,
|
|
97
|
+
ajaxrequestuniquekey: ajaxKey,
|
|
98
|
+
Referer: 'https://www.alarm.com/web/system/home',
|
|
99
|
+
'User-Agent': _utils_1.UA
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
.then((res) => {
|
|
103
|
+
// gather identities and systems
|
|
104
|
+
return res.body;
|
|
105
|
+
})
|
|
106
|
+
.catch((err) => {
|
|
107
|
+
throw new Error(`GET ${_utils_1.IDENTITIES_URL} failed: ${err.message || err}`);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Retrieve information about the current state of a security system including
|
|
112
|
+
* attributes, partitions, accessory components and relationships.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} systemID ID of the system to query. The Authentication
|
|
115
|
+
* object returned from the `login` method contains a `systems` property which
|
|
116
|
+
* is an array of system IDs.
|
|
117
|
+
* @param {Object} authOpts Authentication object returned from the login.
|
|
118
|
+
* @returns {Promise}
|
|
119
|
+
*/
|
|
120
|
+
async function getCurrentState(systemID, authOpts) {
|
|
121
|
+
// This call to the systems endpoint retrieves an overview of all devices in a system
|
|
122
|
+
const res = await (0, _utils_1.authenticatedGet)(_utils_1.SYSTEM_URL + systemID, authOpts);
|
|
123
|
+
const rels = res.data.relationships;
|
|
124
|
+
const components = new Map();
|
|
125
|
+
// push the results of getComponents into the components
|
|
126
|
+
// Now we go through and get detailed information about all devices
|
|
127
|
+
const partitionIDs = rels.partitions.data.map((partition) => partition.id);
|
|
128
|
+
if (typeof partitionIDs[0] !== 'undefined') {
|
|
129
|
+
components.set('partitions', await (0, _utils_1.getComponents)(_utils_1.PARTITIONS_URL, partitionIDs, authOpts));
|
|
130
|
+
}
|
|
131
|
+
const sensorIDs = rels.sensors.data.map((sensor) => sensor.id);
|
|
132
|
+
if (typeof sensorIDs[0] !== 'undefined') {
|
|
133
|
+
components.set('sensors', await (0, _utils_1.getComponents)(_utils_1.SENSORS_URL, sensorIDs, authOpts));
|
|
134
|
+
}
|
|
135
|
+
const lightIDs = rels.lights.data.map((light) => light.id);
|
|
136
|
+
if (typeof lightIDs[0] !== 'undefined') {
|
|
137
|
+
components.set('lights', await (0, _utils_1.getComponents)(_utils_1.LIGHTS_URL, lightIDs, authOpts));
|
|
138
|
+
}
|
|
139
|
+
const lockIDs = rels.locks.data.map((lock) => lock.id);
|
|
140
|
+
if (typeof lockIDs[0] !== 'undefined') {
|
|
141
|
+
components.set('locks', await (0, _utils_1.getComponents)(_utils_1.LOCKS_URL, lockIDs, authOpts));
|
|
142
|
+
}
|
|
143
|
+
const garageIDs = rels.garageDoors.data.map((garage) => garage.id);
|
|
144
|
+
if (typeof garageIDs[0] !== 'undefined') {
|
|
145
|
+
components.set('garages', await (0, _utils_1.getComponents)(_utils_1.GARAGE_URL, garageIDs, authOpts));
|
|
146
|
+
}
|
|
147
|
+
const thermostatIDs = rels.thermostats.data.map((thermostat) => thermostat.id);
|
|
148
|
+
if (typeof thermostatIDs[0] !== 'undefined') {
|
|
149
|
+
components.set('thermostats', await (0, _utils_1.getComponents)(_utils_1.THERMOSTAT_URL, thermostatIDs, authOpts));
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
id: res.data.id,
|
|
153
|
+
attributes: res.data.attributes,
|
|
154
|
+
partitions: components.has('partitions') ? components.get('partitions').data : [],
|
|
155
|
+
sensors: components.has('sensors') ? components.get('sensors').data : [],
|
|
156
|
+
lights: components.has('lights') ? components.get('lights').data : [],
|
|
157
|
+
locks: components.has('locks') ? components.get('locks').data : [],
|
|
158
|
+
garages: components.has('garages') ? components.get('garages').data : [],
|
|
159
|
+
thermostats: components.has('thermostats') ? components.get('thermostats').data : [],
|
|
160
|
+
relationships: rels
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;AA+BA,sBAuEC;AAMD,gDAiBC;AAYD,0CA2CC;AApLD,4DAA+B;AAK/B,qCAekB;AAElB;;;;;;;;GAQG;AACI,KAAK,UAAU,KAAK,CAAC,QAAgB,EAAE,QAAgB,EAAE,gBAAyB;IACvF,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,aAAa,GAAG,EAAE,CAAC;IACvB,IAAI,UAAU,GAAqB,EAAsB,CAAC;IAC1D,IAAI,OAAO,GAAa,EAAE,CAAC;IAE3B,oEAAoE;IACpE,MAAM,IAAA,YAAG,EAAC,qBAAY,CAAC;SACpB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QACZ,MAAM,QAAQ,GAAkC;YAC9C,aAAa,EAAE,IAAI;YACnB,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,IAAI;YAC1B,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC,CAAC,CAAC;YAClF,WAAW,EAAE,GAAG,CAAC,IAAI,CA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,CAAC,CAAC,CAAC,EAAE;QACrF,aAAa,EAAE,IAAI;KACI,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthOpts } from './_models/AuthOpts';
|
|
2
|
+
/**
|
|
3
|
+
* Sets a garage to CLOSED.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} garageID Garage ID string.
|
|
6
|
+
* @param {Object} authOpts Authentication object returned from the `login` method.
|
|
7
|
+
* @returns {Promise}
|
|
8
|
+
*/
|
|
9
|
+
export declare function closeGarage(garageID: string, authOpts: AuthOpts): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Sets a garage to OPEN.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} garageID Garage ID string.
|
|
14
|
+
* @param {Object} authOpts Authentication object returned from the `login` method.
|
|
15
|
+
* @returns {Promise}
|
|
16
|
+
*/
|
|
17
|
+
export declare function openGarage(garageID: string, authOpts: AuthOpts): Promise<any>;
|
package/dist/garages.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.closeGarage = closeGarage;
|
|
4
|
+
exports.openGarage = openGarage;
|
|
5
|
+
const _utils_1 = require("./_utils");
|
|
6
|
+
/**
|
|
7
|
+
* Sets a garage to CLOSED.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} garageID Garage ID string.
|
|
10
|
+
* @param {Object} authOpts Authentication object returned from the `login` method.
|
|
11
|
+
* @returns {Promise}
|
|
12
|
+
*/
|
|
13
|
+
function closeGarage(garageID, authOpts) {
|
|
14
|
+
const url = `${_utils_1.GARAGE_URL}${garageID}/close`;
|
|
15
|
+
const postOpts = Object.assign({}, authOpts, {
|
|
16
|
+
body: {
|
|
17
|
+
statePollOnly: false
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return (0, _utils_1.authenticatedPost)(url, postOpts);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Sets a garage to OPEN.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} garageID Garage ID string.
|
|
26
|
+
* @param {Object} authOpts Authentication object returned from the `login` method.
|
|
27
|
+
* @returns {Promise}
|
|
28
|
+
*/
|
|
29
|
+
function openGarage(garageID, authOpts) {
|
|
30
|
+
const url = `${_utils_1.GARAGE_URL}${garageID}/open`;
|
|
31
|
+
const postOpts = Object.assign({}, authOpts, {
|
|
32
|
+
body: {
|
|
33
|
+
statePollOnly: false
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return (0, _utils_1.authenticatedPost)(url, postOpts);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=garages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"garages.js","sourceRoot":"","sources":["../src/garages.ts"],"names":[],"mappings":";;AAUA,kCAQC;AASD,gCAQC;AAlCD,qCAAyD;AAEzD;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,QAAgB,EAAE,QAAkB;IAC9D,MAAM,GAAG,GAAG,GAAG,mBAAU,GAAG,QAAQ,QAAQ,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE;QAC3C,IAAI,EAAE;YACJ,aAAa,EAAE,KAAK;SACrB;KACF,CAAC,CAAC;IACH,OAAO,IAAA,0BAAiB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,QAAgB,EAAE,QAAkB;IAC7D,MAAM,GAAG,GAAG,GAAG,mBAAU,GAAG,QAAQ,OAAO,CAAC;IAC5C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE;QAC3C,IAAI,EAAE;YACJ,aAAa,EAAE,KAAK;SACrB;KACF,CAAC,CAAC;IACH,OAAO,IAAA,0BAAiB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
|