homebridge-ring 12.0.0-beta.1 → 12.0.0-beta.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # homebridge-ring
2
2
 
3
+ ## 12.0.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bac6b96`](https://github.com/dgreif/ring/commit/bac6b96e1d6b5f115d6c1f67735fd122e32e7311) Thanks [@dgreif](https://github.com/dgreif)! - Wait 30 seconds (instead of 5 seconds) before fetching remote camera status after light is toggled in HomeKit. This may help with issues where camera lights appear to toggle back to old state shortly after turning them on/off.
8
+
9
+ - [`7d198b8`](https://github.com/dgreif/ring/commit/7d198b87ce03531fb75276eac2d89e2af2be4c23) Thanks [@dgreif](https://github.com/dgreif)! - Temporary fix for 2-way audio. This pins werift to an older version while we look into bug fixes. Thanks to @tsightler for debugging and pursuing a real fix!
10
+
11
+ - [`7b9fbec`](https://github.com/dgreif/ring/commit/7b9fbec0950b72f310cecd93a052800e6b7efe36) Thanks [@dgreif](https://github.com/dgreif)! - Switched from a React-based UI to a simple JS UI for the homebridge-ring plugin UI. This should reduce the package size and simplify development. No visual changes should be noticiable in the UI.
12
+
13
+ - Updated dependencies [[`d54168d`](https://github.com/dgreif/ring/commit/d54168dac5f0aa06b50ef805eca98785cb513f83)]:
14
+ - ring-client-api@12.0.0-beta.3
15
+
16
+ ## 12.0.0-beta.2
17
+
18
+ ### Patch Changes
19
+
20
+ - [`02304ba`](https://github.com/dgreif/ring/commit/02304ba6f41e2e8311d152c104c9256bacf87b8c) Thanks [@dgreif](https://github.com/dgreif)! - Another attempt at fixing pvtsutils version
21
+
22
+ - Updated dependencies [[`02304ba`](https://github.com/dgreif/ring/commit/02304ba6f41e2e8311d152c104c9256bacf87b8c)]:
23
+ - ring-client-api@12.0.0-beta.2
24
+
3
25
  ## 12.0.0-beta.1
4
26
 
5
27
  ### Patch Changes
package/lib/camera.js CHANGED
@@ -78,8 +78,8 @@ class Camera extends base_data_accessory_1.BaseDataAccessory {
78
78
  return value;
79
79
  },
80
80
  setValue: (value) => {
81
- // Allow 5 seconds for the light value to update in our status updates from Ring
82
- lightTargetTimer.setTarget(value, 5000);
81
+ // Allow 30 seconds for the light value to update in our status updates from Ring
82
+ lightTargetTimer.setTarget(value, 30000);
83
83
  return device.setLight(value);
84
84
  },
85
85
  requestUpdate: () => device.requestUpdate(),
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ const { homebridge } = window;
3
+ const newTokenButton = document.getElementById('ring-new-token');
4
+ const linkAccountHeader = document.getElementById('ring-link-account-header');
5
+ if (!newTokenButton) {
6
+ homebridge.toast.error('no ring-new-token element found!');
7
+ throw new Error('no ring-new-token element found!');
8
+ }
9
+ if (!linkAccountHeader) {
10
+ homebridge.toast.error('no ring-link-account-header element found!');
11
+ throw new Error('no ring-link-account-header element found!');
12
+ }
13
+ newTokenButton.addEventListener('click', () => {
14
+ showLoginForm();
15
+ });
16
+ /**
17
+ * Render the correct form, based on whether we have an existing refresh token
18
+ */
19
+ async function renderForm() {
20
+ const [config] = await homebridge.getPluginConfig();
21
+ const needToken = !config?.refreshToken;
22
+ homebridge.hideSpinner();
23
+ if (needToken) {
24
+ showLoginForm();
25
+ }
26
+ else {
27
+ showStandardForm();
28
+ }
29
+ }
30
+ renderForm();
31
+ async function setRefreshToken(refreshToken) {
32
+ const [config, ...otherConfigs] = await homebridge.getPluginConfig();
33
+ await homebridge.updatePluginConfig([
34
+ { ...config, refreshToken },
35
+ ...otherConfigs,
36
+ ]);
37
+ homebridge.toast.success('Refresh Token Updated', 'Ring Login Successful');
38
+ showStandardForm();
39
+ }
40
+ function showStandardForm() {
41
+ newTokenButton?.style.setProperty('display', 'block');
42
+ linkAccountHeader?.style.setProperty('display', 'none');
43
+ homebridge.showSchemaForm();
44
+ }
45
+ function showLoginForm() {
46
+ // Hide the standard form
47
+ newTokenButton?.style.setProperty('display', 'none');
48
+ linkAccountHeader?.style.setProperty('display', 'block');
49
+ homebridge.hideSchemaForm();
50
+ // Create a new login form
51
+ const form = homebridge.createForm({
52
+ schema: {
53
+ type: 'object',
54
+ properties: {
55
+ email: {
56
+ title: 'Email',
57
+ type: 'string',
58
+ 'x-schema-form': {
59
+ type: 'email',
60
+ },
61
+ required: true,
62
+ },
63
+ password: {
64
+ title: 'Password',
65
+ type: 'string',
66
+ 'x-schema-form': {
67
+ type: 'password',
68
+ },
69
+ required: true,
70
+ },
71
+ },
72
+ },
73
+ }, {}, 'Log In');
74
+ form.onSubmit(async ({ email, password }) => {
75
+ homebridge.showSpinner();
76
+ try {
77
+ const response = (await homebridge.request('/send-code', {
78
+ email,
79
+ password,
80
+ }));
81
+ if ('refreshToken' in response) {
82
+ // didn't need 2fa, return token without asking for code
83
+ setRefreshToken(response.refreshToken);
84
+ }
85
+ else {
86
+ // Need a token, so show the token form
87
+ showTokenForm({
88
+ email,
89
+ password,
90
+ codePrompt: response.codePrompt,
91
+ });
92
+ }
93
+ }
94
+ catch (e) {
95
+ // eslint-disable-next-line no-console
96
+ console.error(e);
97
+ homebridge.toast.error(e.message, 'Ring Login Failed');
98
+ }
99
+ finally {
100
+ homebridge.hideSpinner();
101
+ }
102
+ });
103
+ }
104
+ function showTokenForm(loginInfo) {
105
+ const form = homebridge.createForm({
106
+ schema: {
107
+ type: 'object',
108
+ properties: {
109
+ code: {
110
+ title: 'Code',
111
+ type: 'string',
112
+ required: true,
113
+ description: loginInfo.codePrompt,
114
+ },
115
+ },
116
+ },
117
+ }, {}, 'Link Account', 'Change Email');
118
+ form.onSubmit(async ({ code }) => {
119
+ homebridge.showSpinner();
120
+ try {
121
+ const { refreshToken } = await homebridge.request('/token', {
122
+ email: loginInfo.email,
123
+ password: loginInfo.password,
124
+ code,
125
+ });
126
+ setRefreshToken(refreshToken);
127
+ }
128
+ catch (e) {
129
+ // eslint-disable-next-line no-console
130
+ console.error(e);
131
+ homebridge.toast.error(e.message, 'Failed to Link Account');
132
+ }
133
+ finally {
134
+ homebridge.hideSpinner();
135
+ }
136
+ });
137
+ form.onCancel(() => showLoginForm());
138
+ }
@@ -1 +1,22 @@
1
- <head><script defer="defer" src="./static/js/main.e1f36307.js"></script></head><div id="root"></div>
1
+ <button id="ring-new-token" class="btn btn-link m-0 p-0" style="display: none;">
2
+ <i class="fa fa-redo mr-2"></i>
3
+ Generate New Refresh Token
4
+ </button>
5
+
6
+ <h4 id="ring-link-account-header" class="text-center primary-text mb-3" style="display: none;">
7
+ Link Ring Account
8
+ </h4>
9
+
10
+ <script>
11
+ // Show the spinner while the JS is loading
12
+ homebridge.showSpinner()
13
+
14
+ // Create a script tag to load the JS onto the page
15
+ const script = document.createElement('script')
16
+
17
+ // Use the installed version of homebridge to bust the cache for the script
18
+ script.src = `homebridge-ring-ui.js?v=${homebridge.plugin.installedVersion}`
19
+
20
+ // Append the script to the head of the page to load it
21
+ document.head.appendChild(script)
22
+ </script>
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "homebridge-ring",
3
- "version": "12.0.0-beta.1",
3
+ "version": "12.0.0-beta.3",
4
4
  "description": "Homebridge plugin for Ring doorbells, cameras, security alarm system and smart lighting",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
- "build": "rm -rf lib && tsc && cp -r ../homebridge-ui/build ./lib/homebridge-ui/public",
7
+ "build": "rm -rf lib && tsc && cp ./homebridge-ui/public/index.html ./lib/homebridge-ui/public/",
8
8
  "lint": "eslint . --ext .ts && tsc --noEmit",
9
9
  "dev": "concurrently -c yellow,blue --kill-others \"npm:dev:build\" \"npm:dev:run\" ",
10
10
  "dev:build": "tsc --watch --preserveWatchOutput",
@@ -12,15 +12,14 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@homebridge/camera-utils": "^2.2.0",
15
- "@homebridge/plugin-ui-utils": "^0.0.19",
16
- "ring-client-api": "12.0.0-beta.1",
17
- "werift": "0.18.5"
15
+ "@homebridge/plugin-ui-utils": "^0.1.0",
16
+ "ring-client-api": "12.0.0-beta.3",
17
+ "werift": "0.17.6"
18
18
  },
19
19
  "devDependencies": {
20
20
  "concurrently": "^8.2.0",
21
21
  "eslint-config-shared": "*",
22
22
  "homebridge": "1.6.1",
23
- "homebridge-ui": "*",
24
23
  "nodemon": "^3.0.1",
25
24
  "tsconfig": "*",
26
25
  "typescript": "5.1.6"
@@ -1,10 +0,0 @@
1
- {
2
- "files": {
3
- "main.js": "./static/js/main.e1f36307.js",
4
- "index.html": "./index.html",
5
- "main.e1f36307.js.map": "./static/js/main.e1f36307.js.map"
6
- },
7
- "entrypoints": [
8
- "static/js/main.e1f36307.js"
9
- ]
10
- }