trusona 0.16.0

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.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.env.example +4 -0
  5. data/.gitignore +20 -0
  6. data/.rspec +3 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +24 -0
  9. data/Gemfile +8 -0
  10. data/Guardfile +54 -0
  11. data/LICENSE +201 -0
  12. data/README.md +234 -0
  13. data/Rakefile +8 -0
  14. data/bin/console +21 -0
  15. data/bin/setup +8 -0
  16. data/certs/trusona.pem +26 -0
  17. data/checksum/trusona-0.16.0.gem.sha512 +1 -0
  18. data/integrations/device_user_binding_integration_spec.rb +6 -0
  19. data/integrations/identity_documents_spec.rb +28 -0
  20. data/integrations/spec_helper.rb +23 -0
  21. data/integrations/tru_code_spec.rb +80 -0
  22. data/integrations/trusonafication_spec.rb +61 -0
  23. data/integrations/user_accounts_spec.rb +39 -0
  24. data/integrations/user_identifiers_spec.rb +32 -0
  25. data/lib/trusona.rb +157 -0
  26. data/lib/trusona/api/client.rb +60 -0
  27. data/lib/trusona/api/hashed_message.rb +71 -0
  28. data/lib/trusona/api/signed_request.rb +96 -0
  29. data/lib/trusona/api/verified_response.rb +85 -0
  30. data/lib/trusona/device.rb +31 -0
  31. data/lib/trusona/device_user_binding.rb +56 -0
  32. data/lib/trusona/errors.rb +51 -0
  33. data/lib/trusona/helpers/key_normalizer.rb +15 -0
  34. data/lib/trusona/helpers/time_normalizer.rb +17 -0
  35. data/lib/trusona/identity_document.rb +64 -0
  36. data/lib/trusona/mappers/base_mapper.rb +69 -0
  37. data/lib/trusona/mappers/device_mapper.rb +13 -0
  38. data/lib/trusona/mappers/device_user_binding_mapper.rb +13 -0
  39. data/lib/trusona/mappers/identity_document_mapper.rb +17 -0
  40. data/lib/trusona/mappers/nil_mapper.rb +11 -0
  41. data/lib/trusona/mappers/tru_code_mapper.rb +13 -0
  42. data/lib/trusona/mappers/trusonafication_mapper.rb +19 -0
  43. data/lib/trusona/mappers/user_account_mapper.rb +13 -0
  44. data/lib/trusona/mappers/user_identifier_mapper.rb +13 -0
  45. data/lib/trusona/resources/base_resource.rb +29 -0
  46. data/lib/trusona/resources/device.rb +22 -0
  47. data/lib/trusona/resources/device_user_binding.rb +30 -0
  48. data/lib/trusona/resources/device_user_binding_activation.rb +27 -0
  49. data/lib/trusona/resources/identity_document.rb +36 -0
  50. data/lib/trusona/resources/tru_code.rb +42 -0
  51. data/lib/trusona/resources/trusonafication.rb +137 -0
  52. data/lib/trusona/resources/user_account.rb +84 -0
  53. data/lib/trusona/resources/user_identifier.rb +49 -0
  54. data/lib/trusona/resources/validators.rb +22 -0
  55. data/lib/trusona/services/account_lookups_service.rb +17 -0
  56. data/lib/trusona/services/base_service.rb +117 -0
  57. data/lib/trusona/services/device_user_bindings_service.rb +22 -0
  58. data/lib/trusona/services/devices_service.rb +15 -0
  59. data/lib/trusona/services/identity_documents_service.rb +31 -0
  60. data/lib/trusona/services/tru_codes_service.rb +26 -0
  61. data/lib/trusona/services/trusonafication_service.rb +16 -0
  62. data/lib/trusona/services/user_accounts_service.rb +17 -0
  63. data/lib/trusona/services/user_identifiers_service.rb +16 -0
  64. data/lib/trusona/tru_code.rb +38 -0
  65. data/lib/trusona/tru_code_config.rb +45 -0
  66. data/lib/trusona/trusonafication.rb +133 -0
  67. data/lib/trusona/user_account.rb +17 -0
  68. data/lib/trusona/user_identifier.rb +15 -0
  69. data/lib/trusona/version.rb +5 -0
  70. data/lib/trusona/workers/device_finder.rb +18 -0
  71. data/lib/trusona/workers/device_user_binding_activator.rb +25 -0
  72. data/lib/trusona/workers/device_user_binding_creator.rb +26 -0
  73. data/lib/trusona/workers/identity_document_finder.rb +25 -0
  74. data/lib/trusona/workers/tru_code_creator.rb +17 -0
  75. data/lib/trusona/workers/tru_code_finder.rb +19 -0
  76. data/lib/trusona/workers/trusonafication_creator.rb +46 -0
  77. data/lib/trusona/workers/trusonafication_finder.rb +27 -0
  78. data/lib/trusona/workers/user_account_finder.rb +39 -0
  79. data/lib/trusona/workers/user_identifier_creator.rb +17 -0
  80. data/lib/trusona/workers/user_identifier_finder.rb +29 -0
  81. data/release-gem +17 -0
  82. data/trusona.gemspec +43 -0
  83. metadata +333 -0
  84. metadata.gz.sig +1 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 519e854441d793e9eba067df4b8791dc70da7eaedc7859609233705654f88055
4
+ data.tar.gz: c6818b8b372c8c57fa4cd500fd28a3bab84ad8d16b01f57737f03be42a87c01a
5
+ SHA512:
6
+ metadata.gz: 635cde4c085570d92b444ad4c14265fe5ee4d319107927786dd3e76aa52db26b5fed5da016b6d3fc2872a3b6cf1217e2ddab9e4581d6bf6a614b1008b28dbac5
7
+ data.tar.gz: d04c928ad5a57e644c3a65a5287c30a291ddb94054e96e8b5f1d3437b0c877ffbbd7973dc73692a8d3a02f5dc88aba0e8df8c64bf48d44cda63bae340ff37586
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ TRUSONA_TOKEN=
2
+ TRUSONA_SECRET=
3
+ TRUSONA_API_HOST=
4
+ TRU_CODES_HOST=
@@ -0,0 +1,20 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ # dotenv
16
+ .env
17
+ .env.test
18
+
19
+ test.rb
20
+ .vscode
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --fail-fast
@@ -0,0 +1 @@
1
+ 2.4.1
@@ -0,0 +1,24 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache:
4
+ - bundler
5
+ rvm:
6
+ - 2.4.3
7
+ - 2.5.0
8
+
9
+ before_install:
10
+ - gem install bundler -v 1.15.1
11
+ - curl -O https://s3-us-west-2.amazonaws.com/trusona-ci-config/trusona-gem-private_key.pem.enc
12
+ - openssl aes-256-cbc -K $encrypted_e2185801d912_key -iv $encrypted_e2185801d912_iv -in trusona-gem-private_key.pem.enc -out trusona-gem-private_key.pem -d
13
+ script:
14
+ - bundle exec rspec spec -f p
15
+ - bundle exec rubocop lib/**/*.rb -F
16
+ - gem build trusona.gemspec
17
+ before_deploy:
18
+ - gem install bundler -v 1.15.1
19
+ deploy:
20
+ skip_cleanup: true
21
+ provider: script
22
+ script: "./release-gem"
23
+ on:
24
+ tags: true
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in trusona.gemspec
6
+ gemspec
7
+
8
+ gem 'pry'
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # Note: The cmd option is now required due to the increasing number of ways
21
+ # rspec may be run, below are examples of the most common uses.
22
+ # * bundler: 'bundle exec rspec'
23
+ # * bundler binstubs: 'bin/rspec'
24
+ # * spring: 'bin/rspec' (This will use spring if running and you have
25
+ # installed the spring binstubs per the docs)
26
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
27
+ # * 'just' rspec: 'rspec'
28
+
29
+ # guard :rubocop, all_on_start: false, cli: ['-a'] do
30
+ # watch(%r{.+\.rb$})
31
+ # watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
32
+ # end
33
+
34
+ guard :rspec, cmd: 'bundle exec rspec' do
35
+ require 'guard/rspec/dsl'
36
+ dsl = Guard::RSpec::Dsl.new(self)
37
+
38
+ # Feel free to open issues for suggestions and improvements
39
+
40
+ # RSpec files
41
+ rspec = dsl.rspec
42
+ watch(rspec.spec_helper) { rspec.spec_dir }
43
+ watch(rspec.spec_support) { rspec.spec_dir }
44
+ watch(rspec.spec_files)
45
+
46
+ # Ruby files
47
+ ruby = dsl.ruby
48
+ dsl.watch_spec_files_for(ruby.lib_files)
49
+ watch(%r{lib\/.+\.rb})
50
+ end
51
+
52
+ guard 'yard' do
53
+ watch(%r{lib\/.+\.rb})
54
+ end
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,234 @@
1
+ # Trusona Ruby SDK
2
+
3
+ Easily interact with the Trusona REST API.
4
+
5
+ ## Current Status
6
+
7
+ [![Build Status](https://travis-ci.com/lighthauz/trusona-server-sdk-ruby.svg?token=2f2CMAnop6pxz1LFFPky&branch=master)](https://travis-ci.com/lighthauz/trusona-server-sdk-ruby)
8
+
9
+ ## Requirements
10
+ The Trusona SDK requires Ruby version 2.4.0 or higher.
11
+
12
+ ## Examples
13
+
14
+ * [Configuration](#configuration)
15
+ * [Device and User Bindings](#device-and-user-bindings)
16
+ * [Trusonafications](#trusonafications)
17
+ * [Devices](#devices)
18
+
19
+ ### Configuration
20
+
21
+ Configuring the Trusona gem is easy. We recommend using environment variables and a tool like [dotenv](https://github.com/bkeepers/dotenv) for managing those environment variables.
22
+
23
+ ```ruby
24
+ Trusona.config do |c|
25
+ c.tru_codes_host = ENV['TRUCODES_HOST']
26
+ c.api_host = ENV['TRUSONA_API_HOST']
27
+ c.secret = ENV['TRUSONA_SECRET']
28
+ c.token = ENV['TRUSONA_TOKEN']
29
+ end
30
+ ```
31
+
32
+ The value of each required configuration parameter are provided by Trusona.
33
+
34
+ ### Device and User Bindings
35
+
36
+ Before Trusonafications can be created for a user, the device registered with the Trusona Mobile SDK must be bound to a **unique-to-you** user identifier. The user identifier can be any value that helps you uniquely identify the user in your system.
37
+
38
+ Once this binding has been created, the user should be made to verify their account with your system. This may include:
39
+
40
+ * Email verification
41
+ * Logging in with existing credentials
42
+ * Answering security questions
43
+
44
+ Once the account has been verified, the Device and User Binding must be activated, which is your way of telling Trusona that this user is ready to accept Trusonafications.
45
+
46
+ #### Creating a Device and User Binding
47
+
48
+ The binding requires two values, the user identifier that helps you identify the user in your system and the device identifier as generated by the Trusona Mobile SDK on the user's device.
49
+
50
+ ```ruby
51
+
52
+ binding = Trusona::DeviceUserBinding.create(
53
+ user: '83452353-4F7B-4CA2-BBCD-57ACE7279EA0',
54
+ device: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI'
55
+ )
56
+
57
+ ```
58
+
59
+ #### Activating a Device and User Binding
60
+
61
+ ```ruby
62
+ # create the binding
63
+ binding = Trusona::DeviceUserBinding.create(
64
+ user: '83452353-4F7B-4CA2-BBCD-57ACE7279EA0',
65
+ device: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI'
66
+ )
67
+
68
+ # go verify the user...
69
+
70
+ # activate the binding
71
+ Trusona::DeviceUserBinding.activate(id: binding.id)
72
+ ```
73
+
74
+ ### Trusonafications
75
+
76
+ #### Creating a Trusonafication
77
+
78
+ A simple Essential level Trusonafication
79
+
80
+ ```ruby
81
+ Trusona::EssentialTrusonafication.create(params: {
82
+ action: 'login',
83
+ resource: 'Acme Bank',
84
+ device_identifier: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI'
85
+ })
86
+ ```
87
+
88
+ An Executive level Trusonafication
89
+
90
+ ```ruby
91
+ Trusona::ExecutiveTrusonafication.create(params: {
92
+ action: 'login',
93
+ resource: 'Acme Bank',
94
+ device_identifier: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI'
95
+ })
96
+ ```
97
+
98
+ A more complex example, toggling optional fields
99
+
100
+ ```ruby
101
+ Trusona::EssentialTrusonafication.create(params: {
102
+ action: 'login',
103
+ resource: 'Acme Bank',
104
+ device_identifier: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI',
105
+ user_presence: false,
106
+ prompt: false
107
+ })
108
+ ```
109
+
110
+
111
+
112
+ #### Trusonafication Options
113
+
114
+ | Name | Parameter Name | Required | Description |
115
+ | :---------------- | :------------------ | :------: | :-------------------------------------------------------------------------------------------------------------------------------- |
116
+ | Action | `action` | Y | The action you want the user to take (e.g. 'login', 'verify') |
117
+ | Resource | `resource` | Y | The resource to which the user is performing the action (e.g. 'website', 'account') |
118
+ | Device Identifier | `device_identifier` | N[^1] | The device identifier, retrieved from the mobile SDK, of the device to which this Trusonafication will be sent. |
119
+ | User Identifier | `user_identifier` | N[^1] | The user identifier that has been registered with Trusona. |
120
+ | Tru Code ID | `trucode_id` | N[^1] | A Tru Code ID that has/will be paired by a device using the Trusona Mobile SDK that can be used to lookup the `device_identifier` |
121
+ | User Presence | `user_presence` | N | Should the user be required to demonstrate presence (e.g. via Biometric) when accepting this Trusonafication? Defaults to `true`. |
122
+ | Prompt | `prompt` | N | Should the user be prompted to Accept or Reject this Trusonafication? Defaults to `true`. |
123
+ | Callback URL | `callback_url` | N | A URL that will be called when the Trusonafication is completed. |
124
+ | Expiration | `expires_at` | N | The ISO-8601 UTC timestamp of the Trusonafication's expiration. Defaults to 90 seconds from creation. |
125
+
126
+ [^1]: You must provide at least one field that would allow Trusona to determine which user to authenticate. The identifier fields are `device_identifier`, `user_identifier`, and `trucode_id`.
127
+
128
+ #### Retrieving an existing Trusonafication
129
+
130
+ After creating a Trusonafication, you can fetch that Trusonafication using the `id`.
131
+
132
+ ```ruby
133
+ trusonafication = Trusona::EssentialTrusonafication.create(params: {
134
+ action: 'login',
135
+ resource: 'Acme Bank',
136
+ device_identifier: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI'
137
+ })
138
+
139
+ # ...
140
+
141
+ updated = Trusona::Trusonafication.find(trusonafication.id)
142
+ ```
143
+
144
+ #### Automatically polling for Trusonafication status
145
+
146
+ Sometimes, you want to send a Trusonafication and wait for its completion by the user before proceeding. This can be accomplished by passing a block, and optional timeout, when creating a Trusonafication.
147
+
148
+ ```ruby
149
+ params = {
150
+ action: 'login',
151
+ resource: 'Acme Bank',
152
+ device_identifier: 'PBanKaajTmz_Cq1pDkrRzyeISBSBoGjExzp5r6-UjcI'
153
+ }
154
+
155
+ Trusona::EssentialTrusonafication.create(params: params) do | trusonafication |
156
+ # Block will be executed when the user has acted on the Trusonafication
157
+ # OR when the Trusonafication has expired.
158
+
159
+ if trusonafication.accepted?
160
+ # start the parade
161
+ end
162
+ end
163
+ ```
164
+
165
+ ### Devices
166
+
167
+ #### Finding a Device
168
+
169
+ If you want to check whether or not a device has been activated, or when it was activated, you can look it up in Trusona using the device's identifier.
170
+
171
+ ```ruby
172
+ device = Trusona::Device.find(id: 'r1ByVyVKJ7TRgU0RPX0-THMTD_CO3VrCSNqLpJFmhms')
173
+ if device.active
174
+ # dance
175
+ end
176
+ ```
177
+
178
+ ## Development
179
+
180
+ ### Patterns
181
+
182
+ The Trusona gem is built with a few principles in mind:
183
+
184
+ 1. Provide a simple, idomatic, rails-like public interface.
185
+ 1. Reduce the scope of the internals exposed to the end-user of the gem.
186
+
187
+ #### Workers
188
+
189
+ Behind the public facing API are a variety of Workers that complete simple, single-focused tasks. For example, when creating a Trusonafication, the responsibility of creation is offloaded to the `Trusona::Workers::TrusonaficationCreator`. This pattern is used for nearly all aspects of the SDK internals.
190
+
191
+ #### Services
192
+
193
+ Communicating with the Trusona API is done via a set of `Trusona::Services` which are responsible for making HMAC'd requests to the Trusona API and verifying the HMAC'd responses from the Trusona API.
194
+
195
+ #### Resources
196
+
197
+ Resources are designed to be simple representations of entities which are represented by the Trusona API.
198
+
199
+ #### Mappers
200
+
201
+ Mappers help translate JSON representations of Trusona API entities to Resource objects.
202
+
203
+ ### Rubocop
204
+
205
+ `Rubocop` is used to ensure adherence to an known style guide. It can be run
206
+ from the command line. Rubocop standards are currently _not_ enforced during
207
+ continuous integration builds.
208
+
209
+ `bundle exec rubocop lib`
210
+
211
+ ### Testing
212
+
213
+ `bundle exec rake`
214
+
215
+ #### Integration Tests
216
+
217
+ Included in the `integrations` directory are a set of ever growing integration tests which rely on the Trusona config variables in your environment (try `.env`.)
218
+
219
+ `bundle exec rspec integrations/`
220
+
221
+ #### Code Coverage
222
+
223
+ Code coverage is calculated used `SimpleCov` and can be found in the `coverage`
224
+ directory after running the tests
225
+
226
+ ### Deployment
227
+
228
+ To deploy a new version of the gem to Artifactory, use `bump` to bump the
229
+ version by either `major`, `minor` or `patch` and then push the tags to
230
+ github. Travis CI will build and deploy any tagged commits.
231
+
232
+ 1. Ensure a clean working directory
233
+ 1. `bundle exec bump patch --tag`
234
+ 1. `git push origin --tags`