@camstack/addon-provider-bosch 0.1.3 → 0.1.5
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/account-integration-offline-BhjIPfv5.js +119 -0
- package/dist/account-integration-offline-DW2D0vf8.mjs +102 -0
- package/dist/{dist-B-Un7bqT.js → dist-CIIror0W.js} +390 -294
- package/dist/{dist-BiZi19Lw.mjs → dist-DNznrlG_.mjs} +390 -294
- package/dist/home-connect/addon.js +50 -21
- package/dist/home-connect/addon.mjs +50 -21
- package/dist/homecom/addon.js +546 -123
- package/dist/homecom/addon.mjs +546 -123
- package/dist/shc/addon.js +1 -1
- package/dist/shc/addon.mjs +1 -1
- package/i18n/en.json +27 -1
- package/i18n/it.json +27 -1
- package/package.json +1 -1
- package/dist/account-integration-offline-BBqEtCgz.js +0 -50
- package/dist/account-integration-offline-BfoLYzxz.mjs +0 -39
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const require_dist = require("./dist-CIIror0W.js");
|
|
2
|
+
//#region src/shared/oauth-callback.ts
|
|
3
|
+
/** A code on its own: no scheme, no query, no separators. */
|
|
4
|
+
var BARE_CODE = /^[A-Za-z0-9._~-]+$/;
|
|
5
|
+
/**
|
|
6
|
+
* What a browser puts on the clipboard around the address: whitespace, quotes or angle
|
|
7
|
+
* brackets, and the `Location:` / `Request URL:` label of a developer-tools header row.
|
|
8
|
+
*/
|
|
9
|
+
function cleanPaste(input) {
|
|
10
|
+
return input.trim().replace(/^(?:location|request url)\s*:\s*/i, "").replace(/^["'<]+|["'>]+$/g, "").trim();
|
|
11
|
+
}
|
|
12
|
+
function paramsOf(input) {
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(input);
|
|
15
|
+
const merged = new URLSearchParams(url.search);
|
|
16
|
+
for (const [key, value] of new URLSearchParams(url.hash.replace(/^#/, ""))) if (!merged.has(key)) merged.set(key, value);
|
|
17
|
+
return merged;
|
|
18
|
+
} catch {
|
|
19
|
+
return new URLSearchParams(input.replace(/^[?#]/, ""));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The authorization code from whatever an operator pasted after a browser sign-in: the full
|
|
24
|
+
* app-scheme address, an address copied from the browser's developer tools, a bare
|
|
25
|
+
* `code=…&state=…` query, or the bare code. Anything that carries a query must carry the
|
|
26
|
+
* `state` of THIS attempt; a bare code has none to check.
|
|
27
|
+
*/
|
|
28
|
+
function parseOAuthCallback(input, expectedState) {
|
|
29
|
+
const text = cleanPaste(input);
|
|
30
|
+
if (text.length === 0) return {
|
|
31
|
+
ok: false,
|
|
32
|
+
reason: "empty"
|
|
33
|
+
};
|
|
34
|
+
if (BARE_CODE.test(text)) return {
|
|
35
|
+
ok: true,
|
|
36
|
+
code: text,
|
|
37
|
+
params: new URLSearchParams()
|
|
38
|
+
};
|
|
39
|
+
const params = paramsOf(text);
|
|
40
|
+
if (params.has("error")) return {
|
|
41
|
+
ok: false,
|
|
42
|
+
reason: "denied"
|
|
43
|
+
};
|
|
44
|
+
const code = params.get("code");
|
|
45
|
+
if (code === null || code.length === 0) return {
|
|
46
|
+
ok: false,
|
|
47
|
+
reason: "no-code"
|
|
48
|
+
};
|
|
49
|
+
const state = params.get("state");
|
|
50
|
+
if (state === null) return {
|
|
51
|
+
ok: false,
|
|
52
|
+
reason: "state-missing"
|
|
53
|
+
};
|
|
54
|
+
if (state !== expectedState) return {
|
|
55
|
+
ok: false,
|
|
56
|
+
reason: "state-mismatch"
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
code,
|
|
61
|
+
params
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/shared/account-integration-cascade.ts
|
|
66
|
+
async function cascadeRemoveDevicesForIntegration(input) {
|
|
67
|
+
const { reg, devices, addonId, system, integrationId, logger } = input;
|
|
68
|
+
let removed = 0;
|
|
69
|
+
for (const d of reg.getAllForAddon(addonId)) {
|
|
70
|
+
if (d.parentDeviceId !== null) continue;
|
|
71
|
+
const cfg = await devices.loadConfig(d.id).catch(() => ({}));
|
|
72
|
+
if (cfg["system"] !== system || cfg["brokerId"] !== integrationId) continue;
|
|
73
|
+
try {
|
|
74
|
+
await devices.remove(d.id);
|
|
75
|
+
removed += 1;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
logger.warn(`${system}: integration cascade-remove failed`, {
|
|
78
|
+
tags: { deviceId: d.id },
|
|
79
|
+
meta: {
|
|
80
|
+
integrationId,
|
|
81
|
+
error: require_dist.errMsg(err)
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return removed;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/shared/account-integration-offline.ts
|
|
90
|
+
function setIntegrationDevicesOnline(devices, system, integrationId, online) {
|
|
91
|
+
let count = 0;
|
|
92
|
+
for (const dev of devices) {
|
|
93
|
+
if (dev.config.get("system") !== system) continue;
|
|
94
|
+
if (dev.config.get("brokerId") !== integrationId) continue;
|
|
95
|
+
if (dev.online === online) continue;
|
|
96
|
+
dev.markOnline(online);
|
|
97
|
+
count += 1;
|
|
98
|
+
}
|
|
99
|
+
return count;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
Object.defineProperty(exports, "cascadeRemoveDevicesForIntegration", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function() {
|
|
105
|
+
return cascadeRemoveDevicesForIntegration;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "parseOAuthCallback", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function() {
|
|
111
|
+
return parseOAuthCallback;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(exports, "setIntegrationDevicesOnline", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function() {
|
|
117
|
+
return setIntegrationDevicesOnline;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { b as errMsg } from "./dist-DNznrlG_.mjs";
|
|
2
|
+
//#region src/shared/oauth-callback.ts
|
|
3
|
+
/** A code on its own: no scheme, no query, no separators. */
|
|
4
|
+
var BARE_CODE = /^[A-Za-z0-9._~-]+$/;
|
|
5
|
+
/**
|
|
6
|
+
* What a browser puts on the clipboard around the address: whitespace, quotes or angle
|
|
7
|
+
* brackets, and the `Location:` / `Request URL:` label of a developer-tools header row.
|
|
8
|
+
*/
|
|
9
|
+
function cleanPaste(input) {
|
|
10
|
+
return input.trim().replace(/^(?:location|request url)\s*:\s*/i, "").replace(/^["'<]+|["'>]+$/g, "").trim();
|
|
11
|
+
}
|
|
12
|
+
function paramsOf(input) {
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(input);
|
|
15
|
+
const merged = new URLSearchParams(url.search);
|
|
16
|
+
for (const [key, value] of new URLSearchParams(url.hash.replace(/^#/, ""))) if (!merged.has(key)) merged.set(key, value);
|
|
17
|
+
return merged;
|
|
18
|
+
} catch {
|
|
19
|
+
return new URLSearchParams(input.replace(/^[?#]/, ""));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The authorization code from whatever an operator pasted after a browser sign-in: the full
|
|
24
|
+
* app-scheme address, an address copied from the browser's developer tools, a bare
|
|
25
|
+
* `code=…&state=…` query, or the bare code. Anything that carries a query must carry the
|
|
26
|
+
* `state` of THIS attempt; a bare code has none to check.
|
|
27
|
+
*/
|
|
28
|
+
function parseOAuthCallback(input, expectedState) {
|
|
29
|
+
const text = cleanPaste(input);
|
|
30
|
+
if (text.length === 0) return {
|
|
31
|
+
ok: false,
|
|
32
|
+
reason: "empty"
|
|
33
|
+
};
|
|
34
|
+
if (BARE_CODE.test(text)) return {
|
|
35
|
+
ok: true,
|
|
36
|
+
code: text,
|
|
37
|
+
params: new URLSearchParams()
|
|
38
|
+
};
|
|
39
|
+
const params = paramsOf(text);
|
|
40
|
+
if (params.has("error")) return {
|
|
41
|
+
ok: false,
|
|
42
|
+
reason: "denied"
|
|
43
|
+
};
|
|
44
|
+
const code = params.get("code");
|
|
45
|
+
if (code === null || code.length === 0) return {
|
|
46
|
+
ok: false,
|
|
47
|
+
reason: "no-code"
|
|
48
|
+
};
|
|
49
|
+
const state = params.get("state");
|
|
50
|
+
if (state === null) return {
|
|
51
|
+
ok: false,
|
|
52
|
+
reason: "state-missing"
|
|
53
|
+
};
|
|
54
|
+
if (state !== expectedState) return {
|
|
55
|
+
ok: false,
|
|
56
|
+
reason: "state-mismatch"
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
ok: true,
|
|
60
|
+
code,
|
|
61
|
+
params
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/shared/account-integration-cascade.ts
|
|
66
|
+
async function cascadeRemoveDevicesForIntegration(input) {
|
|
67
|
+
const { reg, devices, addonId, system, integrationId, logger } = input;
|
|
68
|
+
let removed = 0;
|
|
69
|
+
for (const d of reg.getAllForAddon(addonId)) {
|
|
70
|
+
if (d.parentDeviceId !== null) continue;
|
|
71
|
+
const cfg = await devices.loadConfig(d.id).catch(() => ({}));
|
|
72
|
+
if (cfg["system"] !== system || cfg["brokerId"] !== integrationId) continue;
|
|
73
|
+
try {
|
|
74
|
+
await devices.remove(d.id);
|
|
75
|
+
removed += 1;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
logger.warn(`${system}: integration cascade-remove failed`, {
|
|
78
|
+
tags: { deviceId: d.id },
|
|
79
|
+
meta: {
|
|
80
|
+
integrationId,
|
|
81
|
+
error: errMsg(err)
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return removed;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/shared/account-integration-offline.ts
|
|
90
|
+
function setIntegrationDevicesOnline(devices, system, integrationId, online) {
|
|
91
|
+
let count = 0;
|
|
92
|
+
for (const dev of devices) {
|
|
93
|
+
if (dev.config.get("system") !== system) continue;
|
|
94
|
+
if (dev.config.get("brokerId") !== integrationId) continue;
|
|
95
|
+
if (dev.online === online) continue;
|
|
96
|
+
dev.markOnline(online);
|
|
97
|
+
count += 1;
|
|
98
|
+
}
|
|
99
|
+
return count;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { cascadeRemoveDevicesForIntegration as n, parseOAuthCallback as r, setIntegrationDevicesOnline as t };
|