selfsdk 0.0.145 → 0.0.150

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: 0c59c2a25ba8f895e9a1820e6cf8072c219680ccfc763582f9b8761903ae0f3f
4
- data.tar.gz: 9ca32b859e6f0feeddf5c5e87b38309e691f7459e60d3a9b281f1396dc4bc998
3
+ metadata.gz: '083828e554408cc7a7d07b381cd3f7527c0a39933715f8fbd38090f63e30ac91'
4
+ data.tar.gz: 48611b62819b83b502d976bc82b11ec8be6a32753f52b5655979bf1df955efbe
5
5
  SHA512:
6
- metadata.gz: 65b73466d77d25bfa80dfa9c191f19bb6d525c739754753e653652ebbb59eecb3b3c8936d3205c8b41dd7a71376bef6aa18367fb8f275fe60ef18888633e0a8d
7
- data.tar.gz: c39e65926ddb0923673b5e1109ae54dcc01adfa2408a560182acd8cc3160adb8f7085e9a0f22545078108f2efc1f9d432363255086400833ad5bdd5947091867
6
+ metadata.gz: 0145f18cc63e319a8b90814c7a58e587ce0db0e3da3df03d2bf078b5e802acddf400f8fcf5e023f48b49ce165dfffbf015972b515df47e80d68eb33c5c163c8e
7
+ data.tar.gz: 9925540cfe7ae42fac4ef4b01feaa3856a017dd6c94b15911cfd64e6276a602e0a4c8db2a1967e36b1990683b8644bb590b8af760c4e2fe83a4159978e28baa7
data/lib/acl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'date'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  module SelfSDK
2
4
  class Authenticated
3
5
  attr_accessor :payload, :uuid, :selfsdk, :status
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'httparty'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  require 'self_crypto'
2
4
 
3
5
  module SelfSDK
@@ -44,7 +46,8 @@ module SelfSDK
44
46
  res = @client.get("/v1/identities/#{recipient}/devices/#{recipient_device}/pre_keys")
45
47
 
46
48
  if res.code != 200
47
- Selfid.logger.error "identity response : #{res.body[:message]}"
49
+ b = JSON.parse(res.body)
50
+ ::SelfSDK.logger.error "identity response : #{b['message']}"
48
51
  raise "could not get identity pre_keys"
49
52
  end
50
53
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'base64'
data/lib/log.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'logger'
@@ -7,9 +9,11 @@ module SelfSDK
7
9
  attr_writer :logger
8
10
 
9
11
  def logger
10
- @logger ||= ::Logger.new($stdout).tap do |log|
11
- log.progname = name
12
- end
12
+ @logger ||= Logger.new('/dev/null')
13
+
14
+ #@logger ||= ::Logger.new($stdout).tap do |log|
15
+ # log.progname = name
16
+ #end
13
17
  end
14
18
  end
15
19
  end
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  module SelfSDK
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  module SelfSDK
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative 'attestation'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require_relative "fact_request"
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'json'
@@ -144,7 +146,7 @@ module SelfSDK
144
146
  #
145
147
  # @params msg [Msgproto::Message] message object to be sent
146
148
  def send_and_wait_for_response(msgs, original)
147
- wait_for msg.first.id, original do
149
+ wait_for msgs.first.id, original do
148
150
  msgs.each do |msg|
149
151
  send_message msg
150
152
  end
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'time'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: acl.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: aclcommand.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: auth.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: errtype.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: header.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: message.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: msgtype.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
4
  # source: notification.proto
3
5
 
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'securerandom'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  # Namespace for classes and modules that handle SelfSDK gem
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  # Namespace for classes and modules that handle SelfSDK gem
@@ -130,14 +132,66 @@ module SelfSDK
130
132
  def prepare_facts(facts)
131
133
  fs = []
132
134
  facts.each do |f|
133
- fs << if f.is_a?(Hash)
135
+ fact = if f.is_a?(Hash)
134
136
  f
135
137
  else
136
138
  { fact: f }
137
139
  end
138
- end
140
+ # validate_fact!(fact)
141
+ fs << fact
142
+ end
139
143
  fs
140
144
  end
145
+
146
+ def validate_fact!(f)
147
+ errInvalidFactToSource = 'provided source does not support given fact'
148
+ errInvalidSource = 'provided fact does not specify a valid source'
149
+
150
+ raise 'provided fact does not specify a name' if f[:fact].empty?
151
+ return unless f.has_key? :sources
152
+
153
+ valid_sources = [SOURCE_USER_SPECIFIED, SOURCE_PASSPORT, SOURCE_DRIVING_LICENSE, SOURCE_ID_CARD]
154
+ factsForPassport = [ FACT_DOCUMENT_NUMBER,
155
+ FACT_SURNAME,
156
+ FACT_GIVEN_NAMES,
157
+ FACT_DATE_OF_BIRTH,
158
+ FACT_DATE_OF_EXPIRATION,
159
+ FACT_SEX,
160
+ FACT_NATIONALITY,
161
+ FACT_COUNTRY_OF_ISSUANCE ]
162
+
163
+ factsForDL = [ FACT_DOCUMENT_NUMBER,
164
+ FACT_SURNAME,
165
+ FACT_GIVEN_NAMES,
166
+ FACT_DATE_OF_BIRTH,
167
+ FACT_DATE_OF_ISSUANCE,
168
+ FACT_DATE_OF_EXPIRATION,
169
+ FACT_ADDRESS,
170
+ FACT_ISSUING_AUTHORITY,
171
+ FACT_PLACE_OF_BIRTH,
172
+ FACT_COUNTRY_OF_ISSUANCE ]
173
+
174
+ factsForUser = [ FACT_DOCUMENT_NUMBER,
175
+ FACT_DISPLAY_NAME,
176
+ FACT_EMAIL,
177
+ FACT_PHONE ]
178
+
179
+ f[:sources].each do |s|
180
+ raise errInvalidSource unless valid_sources.include? s.to_s
181
+
182
+ if s.to_s == SOURCE_PASSPORT || s.to_s == SOURCE_ID_CARD
183
+ raise errInvalidFactToSource unless factsForPassport.include? f[:fact]
184
+ end
185
+
186
+ if s.to_s == SOURCE_DRIVING_LICENSE
187
+ raise errInvalidFactToSource unless factsForDL.include? f[:fact]
188
+ end
189
+
190
+ if s.to_s == SOURCE_USER_SPECIFIED
191
+ raise errInvalidFactToSource unless factsForUser.include? f[:fact].to_s
192
+ end
193
+ end
194
+ end
141
195
  end
142
196
  end
143
197
  end
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  # Namespace for classes and modules that handle SelfSDK gem
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  # Namespace for classes and modules that handle SelfSDK gem
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  require 'base64'
@@ -1,3 +1,5 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  module SelfSDK
@@ -15,10 +17,16 @@ module SelfSDK
15
17
  FACT_DATE_OF_BIRTH = "date_of_birth"
16
18
  FACT_DATE_OF_ISSUANCE = "date_of_issuance"
17
19
  FACT_DATE_OF_EXPIRATION = "date_of_expiration"
20
+ FACT_VALID_FROM = "valid_from"
21
+ FACT_VALID_TO = "valid_to"
22
+ FACT_CATEGORIES = "categories"
23
+ FACT_SORT_CODE = "sort_code"
24
+ FACT_COUNTRY_OF_ISSUANCE = "country_of_issuance"
18
25
 
19
26
  SOURCE_USER_SPECIFIED = "user_specified"
20
27
  SOURCE_PASSPORT = "passport"
21
28
  SOURCE_DRIVING_LICENSE = "driving_license"
29
+ SOURCE_ID_CARD = "identity_card"
22
30
 
23
31
  class << self
24
32
  def message_type(s)
@@ -61,7 +69,8 @@ module SelfSDK
61
69
  def source(input)
62
70
  sources = { user_specified: SOURCE_USER_SPECIFIED,
63
71
  passport: SOURCE_PASSPORT,
64
- driving_license: SOURCE_DRIVING_LICENSE }
72
+ driving_license: SOURCE_DRIVING_LICENSE,
73
+ id_card: SOURCE_ID_CARD }
65
74
  get(sources, input, "source")
66
75
  end
67
76
 
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.145
4
+ version: 0.0.150
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures