civic_sip_sdk 0.1.1 → 0.1.2
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 +4 -4
- data/lib/civic_sip_sdk/app_config.rb +5 -6
- data/lib/civic_sip_sdk/client.rb +3 -4
- data/lib/civic_sip_sdk/crypto.rb +4 -6
- data/lib/civic_sip_sdk/user_data.rb +3 -4
- data/lib/civic_sip_sdk/user_data_item.rb +5 -6
- data/lib/civic_sip_sdk/version.rb +1 -1
- data/lib/civic_sip_sdk.rb +7 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b2350a52d62754bbc492a61ad0de623918776b60a4a674ef5edc0890959dc92
|
4
|
+
data.tar.gz: 0f5739eec7f397120b709a63e990d727285347c8ee6cf9437d5897a74aa9fbce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89facb51ccee9b4fba488a774335c42109058687e9158e87a37e7745ddd9ab83a75d3bc0baa689012cd7709cc58ff0ca6dc5aa86136577d0f3ae3ad435daa656
|
7
|
+
data.tar.gz: 6f03a906b21e25f6e1b54b3c2059b5bf464e68805c3fa7249d99eb5002f6bf2b3f7197f3cd2b5b6e122df08e27f135533d0d01425942275a552d705f40caf006
|
@@ -11,16 +11,15 @@ module CivicSIPSdk
|
|
11
11
|
{ name: :secret, error: 'Civic application secret is missing!' }
|
12
12
|
].freeze
|
13
13
|
|
14
|
-
# Creates a new instance of
|
14
|
+
# Creates a new instance of +CivicSIPSdk::AppConfig+.
|
15
15
|
# This is used to configure the SDK connection parameters to the Civic SIP service.
|
16
16
|
#
|
17
17
|
# It raises an ArgumentError if any argument is nil.
|
18
18
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# * <tt>secret</tt> - The application secret
|
19
|
+
# @param id [String] The application id.
|
20
|
+
# @param env [Symbol] The application environment. Defaults to +:prod+ if the value is incorrect.
|
21
|
+
# @param private_key [String] The application's private signing key.
|
22
|
+
# @param secret [String] The application secret
|
24
23
|
def initialize(id:, env:, private_key:, secret:)
|
25
24
|
@id = id
|
26
25
|
@env = VALID_ENVS.include?(env.to_sym) ? env.to_sym : VALID_ENVS.last
|
data/lib/civic_sip_sdk/client.rb
CHANGED
@@ -20,8 +20,7 @@ module CivicSIPSdk
|
|
20
20
|
|
21
21
|
# Creates a client
|
22
22
|
#
|
23
|
-
#
|
24
|
-
# * <tt>config</tt> - an instance of CivicSIPSdk::AppConfig
|
23
|
+
# @param config [CivicSIPSdk::AppConfig] app_config that sets all the parameters of the client
|
25
24
|
def initialize(config:)
|
26
25
|
@config = config
|
27
26
|
@test_env = ENV[ENV_VAR] == TEST_ENV
|
@@ -30,8 +29,8 @@ module CivicSIPSdk
|
|
30
29
|
# Exchange authorization code in the form of a JWT Token for the user data
|
31
30
|
# requested in the scope request.
|
32
31
|
#
|
33
|
-
#
|
34
|
-
#
|
32
|
+
# @param jwt_token [String] a JWT token that contains the authorization code
|
33
|
+
# @return [CivicSIPSdk::UserData] user data returned from SIP
|
35
34
|
def exchange_code(jwt_token:)
|
36
35
|
json_body_str = JSON.generate('authToken' => jwt_token)
|
37
36
|
|
data/lib/civic_sip_sdk/crypto.rb
CHANGED
@@ -16,9 +16,8 @@ module CivicSIPSdk
|
|
16
16
|
|
17
17
|
# Create encrypted text using AES-128-CBC with a IV of 16 bytes
|
18
18
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# * <tt>secret</tt> - the Civic application secret in HEX format
|
19
|
+
# @param text [String] the plain text to be encrypted
|
20
|
+
# @param secret [String] the Civic application secret in HEX format
|
22
21
|
def self.encrypt(text:, secret:)
|
23
22
|
cipher = OpenSSL::Cipher.new(CIPHER_ALGO)
|
24
23
|
cipher.encrypt
|
@@ -32,9 +31,8 @@ module CivicSIPSdk
|
|
32
31
|
|
33
32
|
# Decrypt the encrypted text using AES-128-CBC with a IV of 32 bytes
|
34
33
|
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# * <tt>secret</tt> - the Civic application secret in HEX format
|
34
|
+
# @param text [String] the encrypted text to be decrypted
|
35
|
+
# @param secret [String] the Civic application secret in HEX format
|
38
36
|
def self.decrypt(text:, secret:)
|
39
37
|
cipher = OpenSSL::Cipher.new(CIPHER_ALGO)
|
40
38
|
cipher.decrypt
|
@@ -9,10 +9,9 @@ module CivicSIPSdk
|
|
9
9
|
# Creates a UserData insteance, which creates a list of UserDataItem instances from
|
10
10
|
# +data_items+.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# instantiating CivicSIPSdk::UserDataItem instances
|
12
|
+
# @param user_id [String] user id
|
13
|
+
# @param data_items [List] a list of Hash that contains the key-value pairs
|
14
|
+
# for instantiating CivicSIPSdk::UserDataItem instances
|
16
15
|
def initialize(user_id:, data_items:)
|
17
16
|
@user_id = user_id
|
18
17
|
@data_items = data_items
|
@@ -6,12 +6,11 @@ module CivicSIPSdk
|
|
6
6
|
|
7
7
|
# Creates an instance of UserDataItem.
|
8
8
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# the user is in control of the private key originally used in the issuance of the data attestation.
|
9
|
+
# @param label [String] Descriptive value identifier.
|
10
|
+
# @param value [String] Item value of requested user data.
|
11
|
+
# @param is_valid [String] Indicates whether or not the data is still considered valid on the blockchain.
|
12
|
+
# @param is_owner [String] Civic SIP service challenges the user during scope request approval to ensure
|
13
|
+
# the user is in control of the private key originally used in the issuance of the data attestation.
|
15
14
|
def initialize(label:, value:, is_valid:, is_owner:)
|
16
15
|
@label = label
|
17
16
|
@value = value
|
data/lib/civic_sip_sdk.rb
CHANGED
@@ -8,6 +8,13 @@ require 'civic_sip_sdk/client'
|
|
8
8
|
module CivicSIPSdk
|
9
9
|
module_function
|
10
10
|
|
11
|
+
# Creates an instance of +CivicSIPSdk::Client+
|
12
|
+
#
|
13
|
+
# @param id [String] the Civic application id
|
14
|
+
# @param env [Symbol] the Civic application environment
|
15
|
+
# @param private_key [String] the Civic private signing key
|
16
|
+
# @param secret [String] the Civic application secret
|
17
|
+
# @return [CivicSIPSdk::Client] the client to exchange the JWT code for user data
|
11
18
|
def new_client(id, env, private_key, secret)
|
12
19
|
app_config = AppConfig.new(
|
13
20
|
id: id,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: civic_sip_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Han Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.16
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.9.16
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: httparty
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|