selfsdk 0.0.128 → 0.0.129

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 125110bf24194be23beb2ef32eaffc67cdd4fb0f0124c8b6bc2da283fc7cf999
4
- data.tar.gz: f058e20f529c0c71480b673cb78d511bee67056a2c8aa215663552443311be4d
3
+ metadata.gz: 7ba1c83bef5db464131c2343e7f81500c1e5175fd9f740b7563dad90613dd73c
4
+ data.tar.gz: 12c89161d2837b4f6dba855b43bd554fcb6380dbd207fe7482e9f9fcef4d8493
5
5
  SHA512:
6
- metadata.gz: 1748a529d80ef342b18d4a8a8e9b2ab14191d478ce7d431c5ce192ac6052e05a20b62cc27851cc3f890eacbef65fe2f4850a934d99a50f3879f90698b6abbd86
7
- data.tar.gz: 1648159549fa5474b98a141a7df7fe2901a50f0472e9e0cc03da0e65ab923ed52c8589344b34aff25b9dd9c32e1ad9e9abe65ed6b52c11364520139dde1aae61
6
+ metadata.gz: bd1a8234d5d4ba9ef9589ed41e2a60e9313aa2ba45d3de46f428db95e716125dc9213dff852025643e2c1bafc9342cb3e823eb435e3ed903947161d08c9252bb
7
+ data.tar.gz: 52c50572cf2587106fb160b3042faeb8c129d2bc35d8df9ee6a29a1b7617af7723be54a16b43190c774ed93a4d694a0cfacc85e0882b5867229f8fdd0ce0c390
@@ -59,6 +59,7 @@ module SelfSDK
59
59
  # Lists all public keys stored on self for the given ID
60
60
  #
61
61
  # @param id [string] identity id
62
+ # DEPRECATED
62
63
  def public_keys(id)
63
64
  i = entity(id)
64
65
  i[:public_keys]
@@ -15,7 +15,8 @@ module SelfSDK
15
15
  @to = payload[:sub]
16
16
  @audience = payload[:aud]
17
17
  @source = payload[:source]
18
- @verified = valid_signature?(attestation)
18
+ header = JSON.parse(@messaging.jwt.decode(attestation[:protected]), symbolize_names: true)
19
+ @verified = valid_signature?(attestation, header[:kid])
19
20
  @expected_value = payload[:expected_value]
20
21
  @operator = payload[:operator]
21
22
  @fact_name = name.to_s
@@ -24,8 +25,8 @@ module SelfSDK
24
25
  end
25
26
  end
26
27
 
27
- def valid_signature?(body)
28
- k = @messaging.client.public_keys(@origin).first[:key]
28
+ def valid_signature?(body, kid)
29
+ k = @messaging.client.public_key(@origin, kid).raw_public_key
29
30
  raise ::StandardError.new("invalid signature") unless @messaging.jwt.verify(body, k)
30
31
 
31
32
  true
@@ -72,13 +72,14 @@ module SelfSDK
72
72
 
73
73
  jwt = JSON.parse(body, symbolize_names: true)
74
74
  payload = JSON.parse(@jwt.decode(jwt[:payload]), symbolize_names: true)
75
+ header = JSON.parse(@jwt.decode(jwt[:protected]), symbolize_names: true)
75
76
  @from = payload[:iss]
76
- verify! jwt
77
+ verify! jwt, header[:kid]
77
78
  payload
78
79
  end
79
80
 
80
- def verify!(jwt)
81
- k = @client.public_keys(@from).first[:key]
81
+ def verify!(jwt, kid)
82
+ k = @client.public_key(@from, kid).raw_public_key
82
83
  return if @jwt.verify(jwt, k)
83
84
 
84
85
  SelfSDK.logger.info "skipping message, invalid signature"
@@ -44,7 +44,7 @@ module SelfSDK
44
44
  @offset_file = "#{@storage_dir}/#{@jwt.id}:#{@device_id}.offset"
45
45
  @offset = read_offset
46
46
 
47
- FileUtils.mkdir_p @storage_dir unless File.exists? @storage_dir
47
+ FileUtils.mkdir_p @storage_dir unless File.exist? @storage_dir
48
48
 
49
49
  if options.include? :ws
50
50
  @ws = options[:ws]
@@ -27,9 +27,10 @@ module SelfSDK
27
27
  # Gets an identity public keys
28
28
  #
29
29
  # @param [String] selfid gets the identity details (app/user)
30
+ # @param [String] kid the public key id.
30
31
  # @return [Array] with the identity public keys
31
- def public_keys(selfid)
32
- @client.public_keys(selfid)
32
+ def public_key(selfid, kid)
33
+ @client.public_key(selfid, kid).public_key
33
34
  end
34
35
 
35
36
  # Gets an app/identity details
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.128
4
+ version: 0.0.129
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures