ruby_home 0.2.0 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +41 -0
- data/CHANGELOG.md +13 -0
- data/README.md +47 -84
- data/examples/air_purifier.rb +67 -0
- data/examples/air_quality_sensor.rb +120 -0
- data/examples/battery_service.rb +59 -0
- data/examples/carbon_dioxide_sensor.rb +79 -0
- data/examples/carbon_monoxide_sensor.rb +79 -0
- data/examples/contact_sensor.rb +67 -0
- data/examples/door.rb +49 -0
- data/examples/fan.rb +31 -0
- data/examples/fan_v2.rb +69 -0
- data/examples/garage_door_opener.rb +72 -0
- data/examples/heater_cooler.rb +93 -0
- data/examples/humidifier_dehumidifier.rb +89 -0
- data/examples/humidity_sensor.rb +63 -0
- data/examples/leak_sensor.rb +67 -0
- data/examples/light_sensor.rb +65 -0
- data/examples/lightbulb.rb +32 -0
- data/examples/lock_mechanism.rb +35 -0
- data/examples/motion_sensor.rb +67 -0
- data/examples/occupancy_sensor.rb +67 -0
- data/examples/outlet.rb +30 -0
- data/examples/security_system.rb +54 -0
- data/examples/smoke_sensor.rb +67 -0
- data/examples/switch.rb +17 -0
- data/examples/television.rb +78 -0
- data/examples/temperature_sensor.rb +63 -0
- data/examples/thermostat.rb +114 -0
- data/examples/window.rb +49 -0
- data/examples/window_covering.rb +73 -0
- data/lib/ruby_home.rb +0 -1
- data/lib/ruby_home/characteristic.rb +7 -1
- data/lib/ruby_home/config/categories.yml +39 -0
- data/lib/ruby_home/config/characteristics.yml +479 -3
- data/lib/ruby_home/config/services.yml +79 -4
- data/lib/ruby_home/configuration.rb +19 -0
- data/lib/ruby_home/dns/service.rb +2 -0
- data/lib/ruby_home/dns/text_record.rb +1 -1
- data/lib/ruby_home/errors.rb +4 -0
- data/lib/ruby_home/factories/characteristic_factory.rb +1 -0
- data/lib/ruby_home/factories/templates/characteristic_template.rb +1 -1
- data/lib/ruby_home/factories/templates/service_template.rb +1 -1
- data/lib/ruby_home/hap/server_handler.rb +4 -13
- data/lib/ruby_home/hap/values/uint8_value.rb +11 -1
- data/lib/ruby_home/http/controllers/application_controller.rb +10 -3
- data/lib/ruby_home/http/controllers/pair_setups_controller.rb +3 -3
- data/lib/ruby_home/http/controllers/pair_verifies_controller.rb +10 -12
- data/lib/ruby_home/http/controllers/pairings_controller.rb +1 -1
- data/lib/ruby_home/http/serializers/characteristic_serializer.rb +13 -5
- data/lib/ruby_home/http/serializers/service_serializer.rb +11 -1
- data/lib/ruby_home/http/services/verify_finish_service.rb +56 -0
- data/lib/ruby_home/http/services/verify_srp_service.rb +32 -41
- data/lib/ruby_home/persistable.rb +4 -12
- data/lib/ruby_home/service.rb +3 -0
- data/lib/ruby_home/version.rb +1 -1
- data/rubyhome.gemspec +7 -7
- data/sbin/service_generator.rb +12 -2
- metadata +65 -39
- data/.travis.yml +0 -31
@@ -1,57 +1,48 @@
|
|
1
1
|
module RubyHome
|
2
2
|
class VerifySRPService
|
3
|
-
def initialize(
|
4
|
-
@
|
3
|
+
def initialize(device_proof: , public_key: , srp_session: )
|
4
|
+
@device_proof_bytes = device_proof.to_s.unpack1('H*')
|
5
|
+
@public_key_bytes = public_key.to_s.unpack1('H*')
|
5
6
|
@srp_session = srp_session
|
6
|
-
@public_key = public_key
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
srp_verifier.K
|
20
|
-
end
|
21
|
-
|
22
|
-
def server_proof
|
23
|
-
verify_session_bytes
|
9
|
+
def run
|
10
|
+
if valid_session?
|
11
|
+
OpenStruct.new(
|
12
|
+
success?: true,
|
13
|
+
session_key: session_key,
|
14
|
+
server_proof: verify_session_bytes
|
15
|
+
)
|
16
|
+
else
|
17
|
+
OpenStruct.new(success?: false)
|
18
|
+
end
|
24
19
|
end
|
25
20
|
|
26
21
|
private
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def verify_session_bytes
|
33
|
-
[verify_session].pack('H*')
|
34
|
-
end
|
23
|
+
def valid_session?
|
24
|
+
!!verify_session
|
25
|
+
end
|
35
26
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
device_proof_bytes
|
40
|
-
)
|
41
|
-
end
|
27
|
+
def session_key
|
28
|
+
srp_verifier.K
|
29
|
+
end
|
42
30
|
|
43
|
-
|
44
|
-
|
45
|
-
|
31
|
+
def verify_session_bytes
|
32
|
+
[verify_session].pack('H*')
|
33
|
+
end
|
46
34
|
|
47
|
-
|
48
|
-
|
49
|
-
|
35
|
+
def verify_session
|
36
|
+
srp_verifier.verify_session(
|
37
|
+
srp_session.merge({A: public_key_bytes}),
|
38
|
+
device_proof_bytes
|
39
|
+
)
|
40
|
+
end
|
50
41
|
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
def srp_verifier
|
43
|
+
@_verifier ||= RubyHome::SRP::Verifier.new
|
44
|
+
end
|
54
45
|
|
55
|
-
|
46
|
+
attr_reader :public_key_bytes, :device_proof_bytes, :srp_session
|
56
47
|
end
|
57
48
|
end
|
@@ -10,7 +10,7 @@ module RubyHome
|
|
10
10
|
module ClassMethods
|
11
11
|
def persisted
|
12
12
|
if yaml = read
|
13
|
-
new(yaml)
|
13
|
+
new(**yaml)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -23,19 +23,11 @@ module RubyHome
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def read
|
26
|
-
return false unless
|
26
|
+
return false unless File.exist?(source)
|
27
27
|
|
28
28
|
YAML.load_file(source)
|
29
|
-
|
30
|
-
|
31
|
-
def truncate
|
32
|
-
return false unless file_exists?
|
33
|
-
|
34
|
-
File.truncate(source, 0)
|
35
|
-
end
|
36
|
-
|
37
|
-
def file_exists?
|
38
|
-
File.exists?(source)
|
29
|
+
rescue Errno::EBADF
|
30
|
+
return false
|
39
31
|
end
|
40
32
|
end
|
41
33
|
|
data/lib/ruby_home/service.rb
CHANGED
@@ -12,6 +12,7 @@ module RubyHome
|
|
12
12
|
@description = description
|
13
13
|
@uuid = uuid
|
14
14
|
@characteristics = CharacteristicCollection.new
|
15
|
+
@linked = []
|
15
16
|
end
|
16
17
|
|
17
18
|
attr_reader(
|
@@ -24,6 +25,8 @@ module RubyHome
|
|
24
25
|
:uuid,
|
25
26
|
:instance_id
|
26
27
|
)
|
28
|
+
|
29
|
+
attr_accessor :linked
|
27
30
|
|
28
31
|
def instance_id=(new_id)
|
29
32
|
raise DuplicateServiceError if accessory.contains_instance_id?(new_id)
|
data/lib/ruby_home/version.rb
CHANGED
data/rubyhome.gemspec
CHANGED
@@ -24,22 +24,22 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.bindir = 'bin'
|
25
25
|
spec.executables = ['ruby_home']
|
26
26
|
spec.require_paths = ['lib']
|
27
|
-
spec.required_ruby_version = '>= 2.
|
27
|
+
spec.required_ruby_version = '>= 2.5.0'
|
28
28
|
|
29
|
-
spec.add_dependency 'bindata', '~> 2.4', '>= 2.4.3'
|
30
29
|
spec.add_dependency 'dnssd', '~> 3.0'
|
31
30
|
spec.add_dependency 'facets', '~> 3.1'
|
32
31
|
spec.add_dependency 'hkdf', '~> 0.3.0'
|
33
|
-
spec.add_dependency 'oj', '3.
|
34
|
-
spec.add_dependency 'rbnacl', '~>
|
32
|
+
spec.add_dependency 'oj', '~> 3.10'
|
33
|
+
spec.add_dependency 'rbnacl', '~> 7.0'
|
35
34
|
spec.add_dependency 'ruby_home-srp', '~> 1.3'
|
36
|
-
spec.add_dependency 'ruby_home-tlv', '~> 0.1
|
37
|
-
spec.add_dependency 'sinatra', '2.0
|
35
|
+
spec.add_dependency 'ruby_home-tlv', '~> 0.1'
|
36
|
+
spec.add_dependency 'sinatra', '~> 2.0'
|
37
|
+
spec.add_dependency 'webrick', '~> 1.7'
|
38
38
|
spec.add_dependency 'wisper', '~> 2.0'
|
39
39
|
|
40
40
|
spec.add_development_dependency 'byebug', '~> 11.0'
|
41
41
|
spec.add_development_dependency 'plist', '~> 3.4'
|
42
42
|
spec.add_development_dependency 'rack-test', '~> 1.1.0'
|
43
|
-
spec.add_development_dependency 'rake', '~>
|
43
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
44
44
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
45
45
|
end
|
data/sbin/service_generator.rb
CHANGED
@@ -60,9 +60,19 @@ module RubyHome
|
|
60
60
|
name.downcase.gsub(' ', '_')
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
COLOR_TEMPERATURE_UUID = -'000000CE-0000-1000-8000-0026BB765291'
|
64
64
|
|
65
|
-
|
65
|
+
def optional_characteristics
|
66
|
+
if sanitized_name == 'lightbulb'
|
67
|
+
# HomeKit Accessory Simulator doesnt include color temperature as a characteristic
|
68
|
+
# HAP-Specification-Non-Commercial-Version lists it as a valid optional characteristic
|
69
|
+
@optional_characteristics + [COLOR_TEMPERATURE_UUID]
|
70
|
+
else
|
71
|
+
@optional_characteristics
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
attr_reader :name, :required_characteristics, :uuid
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_home
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Entwistle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bindata
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.4'
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.4.3
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2.4'
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 2.4.3
|
33
13
|
- !ruby/object:Gem::Dependency
|
34
14
|
name: dnssd
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,30 +56,30 @@ dependencies:
|
|
76
56
|
name: oj
|
77
57
|
requirement: !ruby/object:Gem::Requirement
|
78
58
|
requirements:
|
79
|
-
- -
|
59
|
+
- - "~>"
|
80
60
|
- !ruby/object:Gem::Version
|
81
|
-
version: 3.
|
61
|
+
version: '3.10'
|
82
62
|
type: :runtime
|
83
63
|
prerelease: false
|
84
64
|
version_requirements: !ruby/object:Gem::Requirement
|
85
65
|
requirements:
|
86
|
-
- -
|
66
|
+
- - "~>"
|
87
67
|
- !ruby/object:Gem::Version
|
88
|
-
version: 3.
|
68
|
+
version: '3.10'
|
89
69
|
- !ruby/object:Gem::Dependency
|
90
70
|
name: rbnacl
|
91
71
|
requirement: !ruby/object:Gem::Requirement
|
92
72
|
requirements:
|
93
73
|
- - "~>"
|
94
74
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
75
|
+
version: '7.0'
|
96
76
|
type: :runtime
|
97
77
|
prerelease: false
|
98
78
|
version_requirements: !ruby/object:Gem::Requirement
|
99
79
|
requirements:
|
100
80
|
- - "~>"
|
101
81
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
82
|
+
version: '7.0'
|
103
83
|
- !ruby/object:Gem::Dependency
|
104
84
|
name: ruby_home-srp
|
105
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,28 +100,42 @@ dependencies:
|
|
120
100
|
requirements:
|
121
101
|
- - "~>"
|
122
102
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.1
|
103
|
+
version: '0.1'
|
124
104
|
type: :runtime
|
125
105
|
prerelease: false
|
126
106
|
version_requirements: !ruby/object:Gem::Requirement
|
127
107
|
requirements:
|
128
108
|
- - "~>"
|
129
109
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.1
|
110
|
+
version: '0.1'
|
131
111
|
- !ruby/object:Gem::Dependency
|
132
112
|
name: sinatra
|
133
113
|
requirement: !ruby/object:Gem::Requirement
|
134
114
|
requirements:
|
135
|
-
- -
|
115
|
+
- - "~>"
|
136
116
|
- !ruby/object:Gem::Version
|
137
|
-
version: 2.0
|
117
|
+
version: '2.0'
|
138
118
|
type: :runtime
|
139
119
|
prerelease: false
|
140
120
|
version_requirements: !ruby/object:Gem::Requirement
|
141
121
|
requirements:
|
142
|
-
- -
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webrick
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.7'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
138
|
+
version: '1.7'
|
145
139
|
- !ruby/object:Gem::Dependency
|
146
140
|
name: wisper
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,14 +198,14 @@ dependencies:
|
|
204
198
|
requirements:
|
205
199
|
- - "~>"
|
206
200
|
- !ruby/object:Gem::Version
|
207
|
-
version: '
|
201
|
+
version: '13.0'
|
208
202
|
type: :development
|
209
203
|
prerelease: false
|
210
204
|
version_requirements: !ruby/object:Gem::Requirement
|
211
205
|
requirements:
|
212
206
|
- - "~>"
|
213
207
|
- !ruby/object:Gem::Version
|
214
|
-
version: '
|
208
|
+
version: '13.0'
|
215
209
|
- !ruby/object:Gem::Dependency
|
216
210
|
name: rspec
|
217
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,11 +232,12 @@ executables:
|
|
238
232
|
extensions: []
|
239
233
|
extra_rdoc_files: []
|
240
234
|
files:
|
235
|
+
- ".github/workflows/tests.yml"
|
241
236
|
- ".gitignore"
|
242
237
|
- ".hound.yml"
|
243
238
|
- ".rspec"
|
244
239
|
- ".rubocop.yml"
|
245
|
-
-
|
240
|
+
- CHANGELOG.md
|
246
241
|
- Gemfile
|
247
242
|
- LICENSE
|
248
243
|
- README.md
|
@@ -250,18 +245,48 @@ files:
|
|
250
245
|
- bin/console
|
251
246
|
- bin/ruby_home
|
252
247
|
- bin/setup
|
248
|
+
- examples/air_purifier.rb
|
249
|
+
- examples/air_quality_sensor.rb
|
250
|
+
- examples/battery_service.rb
|
251
|
+
- examples/carbon_dioxide_sensor.rb
|
252
|
+
- examples/carbon_monoxide_sensor.rb
|
253
|
+
- examples/contact_sensor.rb
|
254
|
+
- examples/door.rb
|
255
|
+
- examples/fan.rb
|
256
|
+
- examples/fan_v2.rb
|
257
|
+
- examples/garage_door_opener.rb
|
258
|
+
- examples/heater_cooler.rb
|
259
|
+
- examples/humidifier_dehumidifier.rb
|
260
|
+
- examples/humidity_sensor.rb
|
261
|
+
- examples/leak_sensor.rb
|
262
|
+
- examples/light_sensor.rb
|
263
|
+
- examples/lightbulb.rb
|
264
|
+
- examples/lock_mechanism.rb
|
265
|
+
- examples/motion_sensor.rb
|
266
|
+
- examples/occupancy_sensor.rb
|
267
|
+
- examples/outlet.rb
|
268
|
+
- examples/security_system.rb
|
269
|
+
- examples/smoke_sensor.rb
|
270
|
+
- examples/switch.rb
|
271
|
+
- examples/television.rb
|
272
|
+
- examples/temperature_sensor.rb
|
273
|
+
- examples/thermostat.rb
|
274
|
+
- examples/window.rb
|
275
|
+
- examples/window_covering.rb
|
253
276
|
- lib/ruby_home.rb
|
254
277
|
- lib/ruby_home/accessory.rb
|
255
278
|
- lib/ruby_home/accessory_collection.rb
|
256
279
|
- lib/ruby_home/accessory_info.rb
|
257
280
|
- lib/ruby_home/characteristic.rb
|
258
281
|
- lib/ruby_home/characteristic_collection.rb
|
282
|
+
- lib/ruby_home/config/categories.yml
|
259
283
|
- lib/ruby_home/config/characteristics.yml
|
260
284
|
- lib/ruby_home/config/services.yml
|
261
285
|
- lib/ruby_home/configuration.rb
|
262
286
|
- lib/ruby_home/device_id.rb
|
263
287
|
- lib/ruby_home/dns/service.rb
|
264
288
|
- lib/ruby_home/dns/text_record.rb
|
289
|
+
- lib/ruby_home/errors.rb
|
265
290
|
- lib/ruby_home/factories/characteristic_factory.rb
|
266
291
|
- lib/ruby_home/factories/service_factory.rb
|
267
292
|
- lib/ruby_home/factories/templates/characteristic_template.rb
|
@@ -304,6 +329,7 @@ files:
|
|
304
329
|
- lib/ruby_home/http/serializers/uuid_helper.rb
|
305
330
|
- lib/ruby_home/http/services/session_notifier.rb
|
306
331
|
- lib/ruby_home/http/services/start_srp_service.rb
|
332
|
+
- lib/ruby_home/http/services/verify_finish_service.rb
|
307
333
|
- lib/ruby_home/http/services/verify_srp_service.rb
|
308
334
|
- lib/ruby_home/identifier_cache.rb
|
309
335
|
- lib/ruby_home/password.rb
|
@@ -326,14 +352,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
326
352
|
requirements:
|
327
353
|
- - ">="
|
328
354
|
- !ruby/object:Gem::Version
|
329
|
-
version: 2.
|
355
|
+
version: 2.5.0
|
330
356
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
331
357
|
requirements:
|
332
358
|
- - ">="
|
333
359
|
- !ruby/object:Gem::Version
|
334
360
|
version: '0'
|
335
361
|
requirements: []
|
336
|
-
rubygems_version: 3.
|
362
|
+
rubygems_version: 3.1.4
|
337
363
|
signing_key:
|
338
364
|
specification_version: 4
|
339
365
|
summary: Ruby HomeKit support
|
data/.travis.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
dist: xenial
|
2
|
-
cache: bundler
|
3
|
-
language: ruby
|
4
|
-
before_install:
|
5
|
-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y software-properties-common; fi
|
6
|
-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php; fi
|
7
|
-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
|
8
|
-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libsodium-dev; fi
|
9
|
-
install:
|
10
|
-
- 'gem update --system'
|
11
|
-
- 'gem --version'
|
12
|
-
- 'gem install bundler -v 2.0.1'
|
13
|
-
- 'bundle --version'
|
14
|
-
- bundle
|
15
|
-
rvm:
|
16
|
-
- 2.4.1
|
17
|
-
- 2.5
|
18
|
-
- 2.6
|
19
|
-
- ruby-head
|
20
|
-
os:
|
21
|
-
- linux
|
22
|
-
- osx
|
23
|
-
addons:
|
24
|
-
apt:
|
25
|
-
packages:
|
26
|
-
- libavahi-compat-libdnssd-dev
|
27
|
-
homebrew:
|
28
|
-
packages:
|
29
|
-
- libsodium
|
30
|
-
notifications:
|
31
|
-
email: false
|