tanker-core 2.30.1.alpha.2 → 2.31.0.beta.1
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/tanker/c_tanker/c_lib.rb +18 -4
- data/lib/tanker/c_tanker.rb +1 -12
- data/lib/tanker/core/http.rb +7 -2
- data/lib/tanker/core/init.rb +1 -1
- data/lib/tanker/core/options.rb +3 -1
- data/lib/tanker/core/version.rb +1 -1
- data/vendor/tanker/darwin-aarch64/libctanker.dylib +0 -0
- data/vendor/tanker/darwin-x86_64/libctanker.dylib +0 -0
- data/vendor/tanker/linux-x86_64/libctanker.so +0 -0
- metadata +2 -6
- data/lib/tanker/admin/app.rb +0 -25
- data/lib/tanker/admin/app_update_options.rb +0 -26
- data/lib/tanker/admin/client.rb +0 -79
- data/lib/tanker/admin.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e052ab81cc7efc4ff4c223486bf8c92500d14120c16362eee5745bb0d990a58
|
4
|
+
data.tar.gz: b9bc2facb9a7f2290cbe4e579c0b900a7b9ad95f853979fc62813f2975d4648f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a561e723d259795bec3a01cc1d05efcaee57f42357e1fbd9dfdf8e5301156d214a1e1fa46413e383e503c373d10bb525f33abad80f9327ed54b1d1ba949d14b
|
7
|
+
data.tar.gz: 02c800022efc4505a95393bcc2e1c43a988df20a7966ba34834a948b68c6c50e41e99edbc5432141c36b2fdfac8c3e15d3874eeb967b67672c0653a222d16d67
|
@@ -1,10 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ffi'
|
3
4
|
require 'ffi/platform'
|
4
5
|
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
module FFI::Library
|
7
|
+
# Marking a function blocking releases the global Ruby lock.
|
8
|
+
# This is required for every function that could invoke a callback (including log handler) in another thread
|
9
|
+
def blocking_attach_function(func, args, returns = nil)
|
10
|
+
attach_function func, args, returns, blocking: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Tanker
|
15
|
+
module CTanker
|
16
|
+
def self.get_path(name)
|
17
|
+
File.expand_path "../../../vendor/tanker/#{FFI::Platform::OS}-#{FFI::Platform::ARCH}/"\
|
18
|
+
"#{FFI::Platform::LIBPREFIX}#{name}.#{FFI::Platform::LIBSUFFIX}", __dir__
|
19
|
+
end
|
20
|
+
|
21
|
+
extend FFI::Library
|
22
|
+
ffi_lib get_path('ctanker')
|
9
23
|
end
|
10
24
|
end
|
data/lib/tanker/c_tanker.rb
CHANGED
@@ -1,30 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'ffi'
|
4
|
+
require_relative 'c_tanker/c_lib'
|
4
5
|
require_relative 'core/options'
|
5
6
|
require_relative 'sharing_options'
|
6
7
|
require_relative 'encryption_options'
|
7
8
|
require_relative 'verification_options'
|
8
|
-
require_relative 'c_tanker/c_lib'
|
9
9
|
require_relative 'c_tanker/c_future'
|
10
10
|
require_relative 'c_tanker/c_verification'
|
11
11
|
require_relative 'c_tanker/c_verification_method'
|
12
12
|
require_relative 'c_tanker/c_log_record'
|
13
13
|
require_relative 'c_tanker/c_device_info'
|
14
14
|
|
15
|
-
module FFI::Library
|
16
|
-
# Marking a function blocking releases the global Ruby lock.
|
17
|
-
# This is required for every function that could invoke a callback (including log handler) in another thread
|
18
|
-
def blocking_attach_function(func, args, returns = nil)
|
19
|
-
attach_function func, args, returns, blocking: true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
15
|
module Tanker
|
24
16
|
module CTanker
|
25
|
-
extend FFI::Library
|
26
|
-
ffi_lib get_path('ctanker')
|
27
|
-
|
28
17
|
typedef :pointer, :session_pointer
|
29
18
|
typedef :pointer, :enc_sess_pointer
|
30
19
|
typedef :pointer, :stream_pointer
|
data/lib/tanker/core/http.rb
CHANGED
@@ -92,9 +92,12 @@ module Tanker
|
|
92
92
|
class Client
|
93
93
|
attr_reader :tanker_http_options
|
94
94
|
|
95
|
-
def initialize(sdk_type, sdk_version)
|
95
|
+
def initialize(sdk_type, sdk_version, faraday_adapter)
|
96
96
|
@sdk_type = sdk_type
|
97
97
|
@sdk_version = sdk_version
|
98
|
+
@conn = Faraday.new do |conn|
|
99
|
+
conn.adapter faraday_adapter || Faraday.default_adapter
|
100
|
+
end
|
98
101
|
|
99
102
|
# This could be a proc, but for some reason, ffi gives the wrong type
|
100
103
|
# for crequest if we don't specify it explicitly here
|
@@ -120,7 +123,9 @@ module Tanker
|
|
120
123
|
'X-Tanker-SdkType' => @sdk_type,
|
121
124
|
'X-Tanker-SdkVersion' => @sdk_version,
|
122
125
|
'Authorization' => request.authorization,
|
123
|
-
'X-Tanker-Instanceid' => request.instance_id
|
126
|
+
'X-Tanker-Instanceid' => request.instance_id,
|
127
|
+
# net-http really wants a Content-Type
|
128
|
+
'Content-Type' => 'application/data'
|
124
129
|
}.compact)
|
125
130
|
|
126
131
|
request.complete_if_not_canceled do
|
data/lib/tanker/core/init.rb
CHANGED
@@ -31,7 +31,7 @@ module Tanker
|
|
31
31
|
# Do not spam the console of our users.
|
32
32
|
self.class.set_log_handler { |_| } unless self.class.test_and_set_log_handler == 1 # rubocop:disable Lint/EmptyBlock
|
33
33
|
|
34
|
-
@http_client = Http::Client.new options.sdk_type, VERSION
|
34
|
+
@http_client = Http::Client.new options.sdk_type, VERSION, options.faraday_adapter
|
35
35
|
options[:http_options] = @http_client.tanker_http_options
|
36
36
|
|
37
37
|
@ctanker = CTanker.tanker_create(options).get
|
data/lib/tanker/core/options.rb
CHANGED
@@ -22,8 +22,9 @@ module Tanker
|
|
22
22
|
SDK_VERSION = CTanker.new_cstring Core::VERSION
|
23
23
|
|
24
24
|
attr_reader :sdk_type
|
25
|
+
attr_reader :faraday_adapter
|
25
26
|
|
26
|
-
def initialize(app_id:, url: nil, sdk_type: SDK_TYPE, persistent_path: nil, cache_path: nil)
|
27
|
+
def initialize(app_id:, url: nil, sdk_type: SDK_TYPE, persistent_path: nil, cache_path: nil, faraday_adapter: nil) # rubocop:disable Metrics/ParameterLists
|
27
28
|
super()
|
28
29
|
|
29
30
|
# NOTE: Instance variables are required to keep the CStrings alive
|
@@ -33,6 +34,7 @@ module Tanker
|
|
33
34
|
@c_cache_path = CTanker.new_cstring cache_path
|
34
35
|
@sdk_type = sdk_type
|
35
36
|
@c_sdk_type = CTanker.new_cstring sdk_type
|
37
|
+
@faraday_adapter = faraday_adapter
|
36
38
|
|
37
39
|
self[:version] = 4
|
38
40
|
self[:app_id] = @c_app_id
|
data/lib/tanker/core/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanker-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.31.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanker team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -134,10 +134,6 @@ files:
|
|
134
134
|
- LICENSE
|
135
135
|
- README.rst
|
136
136
|
- lib/tanker-core.rb
|
137
|
-
- lib/tanker/admin.rb
|
138
|
-
- lib/tanker/admin/app.rb
|
139
|
-
- lib/tanker/admin/app_update_options.rb
|
140
|
-
- lib/tanker/admin/client.rb
|
141
137
|
- lib/tanker/c_tanker.rb
|
142
138
|
- lib/tanker/c_tanker/c_datastore.rb
|
143
139
|
- lib/tanker/c_tanker/c_device_info.rb
|
data/lib/tanker/admin/app.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tanker
|
4
|
-
class Admin
|
5
|
-
# Information from the Admin SDK concerning a Tanker application
|
6
|
-
class App
|
7
|
-
attr_reader :admin, :id, :auth_token, :secret
|
8
|
-
|
9
|
-
def initialize(admin:, id:, auth_token:, secret:)
|
10
|
-
@admin = admin
|
11
|
-
@id = id
|
12
|
-
@auth_token = auth_token
|
13
|
-
@secret = secret
|
14
|
-
end
|
15
|
-
|
16
|
-
def get_email_verification_code(email)
|
17
|
-
@admin.get_email_verification_code(@id, @auth_token, email)
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_sms_verification_code(phone_number)
|
21
|
-
@admin.get_sms_verification_code(@id, @auth_token, phone_number)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tanker
|
4
|
-
class Admin
|
5
|
-
class AppUpdateOptions
|
6
|
-
attr_accessor :oidc_client_id, :oidc_client_provider, :preverified_verification, :user_enrollment
|
7
|
-
|
8
|
-
def initialize(oidc_client_id: nil, oidc_client_provider: nil,
|
9
|
-
preverified_verification: nil, user_enrollment: nil)
|
10
|
-
@oidc_client_id = oidc_client_id
|
11
|
-
@oidc_client_provider = oidc_client_provider
|
12
|
-
@preverified_verification = preverified_verification
|
13
|
-
@user_enrollment = user_enrollment
|
14
|
-
end
|
15
|
-
|
16
|
-
def as_json(_options = {})
|
17
|
-
{
|
18
|
-
oidc_client_id: @oidc_client_id,
|
19
|
-
oidc_provider: @oidc_client_provider,
|
20
|
-
preverified_verification_enabled: @preverified_verification,
|
21
|
-
enroll_users_enabled: @user_enrollment
|
22
|
-
}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/tanker/admin/client.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
require 'faraday_middleware'
|
5
|
-
|
6
|
-
require_relative 'app'
|
7
|
-
require_relative 'app_update_options'
|
8
|
-
|
9
|
-
module Tanker
|
10
|
-
class Admin
|
11
|
-
class Client
|
12
|
-
def self.init_conn(conn)
|
13
|
-
conn.request :json
|
14
|
-
conn.response :raise_error
|
15
|
-
## in case of verbosity need
|
16
|
-
# require 'logger'
|
17
|
-
# conn.response :logger, ::Logger.new(STDOUT), bodies: true
|
18
|
-
conn.response :json
|
19
|
-
conn.adapter :net_http
|
20
|
-
conn
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(app_management_token:, app_management_url:, api_url:, environment_name:, trustchain_url:)
|
24
|
-
@app_management_token = app_management_token
|
25
|
-
@app_management_url = app_management_url
|
26
|
-
@api_url = api_url
|
27
|
-
@environment_name = environment_name
|
28
|
-
@trustchain_url = trustchain_url
|
29
|
-
@conn = Faraday.new(url: "#{@app_management_url}/v1/apps") do |conn|
|
30
|
-
conn.request :authorization, 'Bearer', @app_management_token
|
31
|
-
self.class.init_conn(conn)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def create_app(name)
|
36
|
-
response = @conn.post do |req|
|
37
|
-
req.body = { name: name, environment_name: @environment_name }
|
38
|
-
req.headers['Accept'] = 'application/json'
|
39
|
-
end
|
40
|
-
App.new(
|
41
|
-
admin: self,
|
42
|
-
id: response.body['app']['id'],
|
43
|
-
auth_token: response.body['app']['auth_token'],
|
44
|
-
secret: response.body['app']['secret']
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
def delete_app(app_id)
|
49
|
-
capp_id = Faraday::Utils.escape(app_id)
|
50
|
-
@conn.delete(capp_id)
|
51
|
-
end
|
52
|
-
|
53
|
-
def app_update(app_id, app_update_options)
|
54
|
-
capp_id = Faraday::Utils.escape(app_id)
|
55
|
-
response = @conn.patch(capp_id) do |req|
|
56
|
-
req.body = app_update_options.as_json
|
57
|
-
end
|
58
|
-
response.body
|
59
|
-
end
|
60
|
-
|
61
|
-
def get_email_verification_code(app_id, auth_token, email)
|
62
|
-
conn = Faraday.new(url: @api_url) do |f|
|
63
|
-
self.class.init_conn(f)
|
64
|
-
end
|
65
|
-
response = conn.post('/verification/email/code', { email: email, app_id: app_id, auth_token: auth_token })
|
66
|
-
response.body['verification_code']
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_sms_verification_code(app_id, auth_token, phone_number)
|
70
|
-
conn = Faraday.new(url: @api_url) do |f|
|
71
|
-
self.class.init_conn(f)
|
72
|
-
end
|
73
|
-
response = conn.post('/verification/sms/code',
|
74
|
-
{ phone_number: phone_number, app_id: app_id, auth_token: auth_token })
|
75
|
-
response.body['verification_code']
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|