From 7bf4609d3da014e748cef540f6a629d8e070cded Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 10 Jul 2024 19:16:57 -0700 Subject: [PATCH] homekit: use html setting --- plugins/homekit/package-lock.json | 39 ++++++++++++++++++++++++++----- plugins/homekit/package.json | 4 +++- plugins/homekit/src/hap-utils.ts | 2 +- plugins/homekit/src/main.ts | 5 ++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/plugins/homekit/package-lock.json b/plugins/homekit/package-lock.json index 768d0a131..cee4e621c 100644 --- a/plugins/homekit/package-lock.json +++ b/plugins/homekit/package-lock.json @@ -12,7 +12,8 @@ "check-disk-space": "^3.4.0", "hap-nodejs": "^0.11.2", "lodash": "^4.17.21", - "mkdirp": "^3.0.1" + "mkdirp": "^3.0.1", + "qrcode-svg": "^1.1.0" }, "devDependencies": { "@scrypted/common": "file:../../common", @@ -20,6 +21,7 @@ "@types/debug": "^4.1.12", "@types/lodash": "^4.17.0", "@types/node": "^20.11.28", + "@types/qrcode-svg": "^1.1.4", "@types/url-parse": "^1.4.11" } }, @@ -30,12 +32,12 @@ "license": "ISC", "dependencies": { "@scrypted/sdk": "file:../sdk", - "@scrypted/server": "file:../server", "http-auth-utils": "^5.0.1", - "typescript": "^5.3.3" + "typescript": "^5.5.3" }, "devDependencies": { "@types/node": "^20.11.0", + "monaco-editor": "^0.50.0", "ts-node": "^10.9.2" } }, @@ -121,7 +123,7 @@ }, "../../sdk": { "name": "@scrypted/sdk", - "version": "0.3.29", + "version": "0.3.37", "dev": true, "license": "ISC", "dependencies": { @@ -291,6 +293,12 @@ "undici-types": "~5.26.4" } }, + "node_modules/@types/qrcode-svg": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/qrcode-svg/-/qrcode-svg-1.1.4.tgz", + "integrity": "sha512-gh+atEBHXpU5iO72Tg4q03YdGKoY0zH1Yr4mGl+NSzFpyPuJcgurs8F3aRpH0Gs93GFuB1rDoQj6U4Xshn72PA==", + "dev": true + }, "node_modules/@types/url-parse": { "version": "1.4.11", "resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.11.tgz", @@ -1032,6 +1040,14 @@ "teleport": ">=0.2.0" } }, + "node_modules/qrcode-svg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/qrcode-svg/-/qrcode-svg-1.1.0.tgz", + "integrity": "sha512-XyQCIXux1zEIA3NPb0AeR8UMYvXZzWEhgdBgBjH9gO7M48H9uoHzviNz8pXw3UzrAcxRRRn9gxHewAVK7bn9qw==", + "bin": { + "qrcode-svg": "bin/qrcode-svg.js" + } + }, "node_modules/regexp.prototype.flags": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", @@ -1325,11 +1341,11 @@ "version": "file:../../common", "requires": { "@scrypted/sdk": "file:../sdk", - "@scrypted/server": "file:../server", "@types/node": "^20.11.0", "http-auth-utils": "^5.0.1", + "monaco-editor": "^0.50.0", "ts-node": "^10.9.2", - "typescript": "^5.3.3" + "typescript": "^5.5.3" } }, "@scrypted/sdk": { @@ -1386,6 +1402,12 @@ "undici-types": "~5.26.4" } }, + "@types/qrcode-svg": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/qrcode-svg/-/qrcode-svg-1.1.4.tgz", + "integrity": "sha512-gh+atEBHXpU5iO72Tg4q03YdGKoY0zH1Yr4mGl+NSzFpyPuJcgurs8F3aRpH0Gs93GFuB1rDoQj6U4Xshn72PA==", + "dev": true + }, "@types/url-parse": { "version": "1.4.11", "resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.11.tgz", @@ -1901,6 +1923,11 @@ "resolved": "https://registry.npmjs.org/q/-/q-1.1.2.tgz", "integrity": "sha512-ROtylwux7Vkc4C07oKE/ReigUmb33kVoLtcR4SJ1QVqwaZkBEDL3vX4/kwFzIERQ5PfCl0XafbU8u2YUhyGgVA==" }, + "qrcode-svg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/qrcode-svg/-/qrcode-svg-1.1.0.tgz", + "integrity": "sha512-XyQCIXux1zEIA3NPb0AeR8UMYvXZzWEhgdBgBjH9gO7M48H9uoHzviNz8pXw3UzrAcxRRRn9gxHewAVK7bn9qw==" + }, "regexp.prototype.flags": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", diff --git a/plugins/homekit/package.json b/plugins/homekit/package.json index f3e0568a0..fc8f08626 100644 --- a/plugins/homekit/package.json +++ b/plugins/homekit/package.json @@ -38,7 +38,8 @@ "check-disk-space": "^3.4.0", "hap-nodejs": "^0.11.2", "lodash": "^4.17.21", - "mkdirp": "^3.0.1" + "mkdirp": "^3.0.1", + "qrcode-svg": "^1.1.0" }, "devDependencies": { "@scrypted/common": "file:../../common", @@ -46,6 +47,7 @@ "@types/debug": "^4.1.12", "@types/lodash": "^4.17.0", "@types/node": "^20.11.28", + "@types/qrcode-svg": "^1.1.4", "@types/url-parse": "^1.4.11" } } diff --git a/plugins/homekit/src/hap-utils.ts b/plugins/homekit/src/hap-utils.ts index 6e4752c25..f8fff7b23 100644 --- a/plugins/homekit/src/hap-utils.ts +++ b/plugins/homekit/src/hap-utils.ts @@ -89,7 +89,7 @@ export function createHAPUsernameStorageSettingsDict(device: { storage: Storage, group, // subgroup, title: "Pairing QR Code", - type: 'qrcode', + type: 'html', readonly: true, description: "Scan with your iOS camera to pair this Scrypted with HomeKit.", }, diff --git a/plugins/homekit/src/main.ts b/plugins/homekit/src/main.ts index 6a8321e91..a90357364 100644 --- a/plugins/homekit/src/main.ts +++ b/plugins/homekit/src/main.ts @@ -16,6 +16,7 @@ import './types'; import { VIDEO_CLIPS_NATIVE_ID } from './types/camera/camera-recording-files'; import { reorderDevicesByProvider } from './util'; import { VideoClipsMixinProvider } from './video-clips-provider'; +import QRCode from 'qrcode-svg'; const hapStorage: Storage = { get length() { @@ -283,7 +284,7 @@ export class HomeKitPlugin extends ScryptedDeviceBase implements MixinProvider, await this.publishAccessory(accessory, storageSettings.values.mac, storageSettings.values.pincode, standaloneCategory, storageSettings.values.portOverride, storageSettings.values.addIdentifyingMaterial); if (!hasPublished) { hasPublished = true; - storageSettings.values.qrCode = accessory.setupURI(); + storageSettings.values.qrCode = new QRCode(accessory.setupURI()).svg(); logConnections(mixinConsole, accessory, this.seenConnections); } } @@ -364,7 +365,7 @@ export class HomeKitPlugin extends ScryptedDeviceBase implements MixinProvider, }; this.bridge.publish(publishInfo, true).then(() => { - this.storageSettings.values.qrCode = this.bridge.setupURI(); + this.storageSettings.values.qrCode = new QRCode(this.bridge.setupURI()).svg(); logConnections(this.console, this.bridge, this.seenConnections); });