incognia_api 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8091ced0819f517cbe35df392b7f51d7943403f0b6053e97226c5dcb91cf7f5d
4
- data.tar.gz: 07732b958841e661ab36548eabc14d4f55895fec5997f40b2e7f4c654d746eac
3
+ metadata.gz: e4670f0fda3487b76490802caef76aa02c9ef037c552d4fab1e970871d07498f
4
+ data.tar.gz: b8286fe8ba8130ad7512bc8bf2acb065409195ed326a72c9c0a4fb27b9e7cfb0
5
5
  SHA512:
6
- metadata.gz: bd76587fcc7ca3edb6cd011cd8df4d8546d60deaf7026cd2de4241ffccfdafbf288c425627cd437385439ea675269e26e84178233444db02def82c2df2871ee1
7
- data.tar.gz: 6a65cf592482f88de479b5c60233f592e3bfc1ccfe5982e2fb3f37d56285b76d1f3dda133737c03ae771476192708b117632d8813fe3e08f2dd2647883de71c8
6
+ metadata.gz: 191d5b1ee6963347a37a752bedda18bd293a04b7adc245c037b67e5ac6f08e629d36dbe5701c5bb13b6f5e180a2d7e6153b3913da730a2418fcd66d972eb866e
7
+ data.tar.gz: 118a7ea43a3f35709383c24c1b5d372b92152fea8041894666fdeb8839c2b6c472b8ced28bb3b654bbbf9ecd2fa7b6367d37174acc1f434508070937880420c9
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @guiocavalcanti
1
+ * @guiocavalcanti @julianalucena @ottony
@@ -0,0 +1,76 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "main" ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "main" ]
20
+ schedule:
21
+ - cron: '25 9 * * 0'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Use only 'java' to analyze code written in Java, Kotlin or both
38
+ # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
39
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40
+
41
+ steps:
42
+ - name: Checkout repository
43
+ uses: actions/checkout@v3
44
+
45
+ # Initializes the CodeQL tools for scanning.
46
+ - name: Initialize CodeQL
47
+ uses: github/codeql-action/init@v2
48
+ with:
49
+ languages: ${{ matrix.language }}
50
+ # If you wish to specify custom queries, you can do so here or in a config file.
51
+ # By default, queries listed here will override any specified in a config file.
52
+ # Prefix the list here with "+" to use these queries and those in the config file.
53
+
54
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
55
+ queries: security-extended,security-and-quality
56
+
57
+
58
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
59
+ # If this step fails, then you should remove it and run the build manually (see below)
60
+ - name: Autobuild
61
+ uses: github/codeql-action/autobuild@v2
62
+
63
+ # ℹ️ Command-line programs to run using the OS shell.
64
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65
+
66
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
67
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68
+
69
+ # - run: |
70
+ # echo "Run, Build Application using script"
71
+ # ./location_of_script_within_repo/buildscript.sh
72
+
73
+ - name: Perform CodeQL Analysis
74
+ uses: github/codeql-action/analyze@v2
75
+ with:
76
+ category: "/language:${{matrix.language}}"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2023-01-24
4
+
5
+ - Allows optional params on #register_signup
6
+ - Adds Reset feedback event
7
+
8
+ ## [0.3.0] - 2022-05-06
9
+
10
+ - Allow registering feedbacks
11
+ - Allow registering logins
12
+
3
13
  ## [0.2.0] - 2022-05-06
4
14
 
5
15
  - Allow registering signups without address
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incognia_api (0.2.0)
4
+ incognia_api (0.3.1)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
@@ -13,29 +13,33 @@ GEM
13
13
  crack (0.4.5)
14
14
  rexml
15
15
  diff-lcs (1.4.4)
16
- faraday (1.7.1)
16
+ faraday (1.10.3)
17
17
  faraday-em_http (~> 1.0)
18
18
  faraday-em_synchrony (~> 1.0)
19
19
  faraday-excon (~> 1.1)
20
- faraday-httpclient (~> 1.0.1)
20
+ faraday-httpclient (~> 1.0)
21
+ faraday-multipart (~> 1.0)
21
22
  faraday-net_http (~> 1.0)
22
- faraday-net_http_persistent (~> 1.1)
23
+ faraday-net_http_persistent (~> 1.0)
23
24
  faraday-patron (~> 1.0)
24
25
  faraday-rack (~> 1.0)
25
- multipart-post (>= 1.2, < 3)
26
+ faraday-retry (~> 1.0)
26
27
  ruby2_keywords (>= 0.0.4)
27
28
  faraday-em_http (1.0.0)
28
29
  faraday-em_synchrony (1.0.0)
29
30
  faraday-excon (1.1.0)
30
31
  faraday-httpclient (1.0.1)
32
+ faraday-multipart (1.0.4)
33
+ multipart-post (~> 2)
31
34
  faraday-net_http (1.0.1)
32
35
  faraday-net_http_persistent (1.2.0)
33
36
  faraday-patron (1.0.0)
34
37
  faraday-rack (1.0.0)
35
- faraday_middleware (1.0.0)
38
+ faraday-retry (1.0.3)
39
+ faraday_middleware (1.2.0)
36
40
  faraday (~> 1.0)
37
41
  hashdiff (1.0.1)
38
- multipart-post (2.1.1)
42
+ multipart-post (2.2.3)
39
43
  public_suffix (4.0.6)
40
44
  rake (13.0.3)
41
45
  rexml (3.2.5)
data/README.md CHANGED
@@ -64,6 +64,22 @@ assessment = api.register_signup(
64
64
 
65
65
  ```
66
66
 
67
+ It also supports optional parameters, for example:
68
+
69
+ ```ruby
70
+ address = Incognia::Address.new(line: "West 34th Street, New York City, NY 10001")
71
+ installation_id = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
72
+ external_id = "7b02736a-7718-4b83-8982-f68fb6f501fa"
73
+
74
+ assessment = api.register_signup(
75
+ installation_id: installation_id,
76
+ address: address,
77
+ external_id: external_id
78
+ )
79
+
80
+ # => #<OpenStruct id="...", device_id="...", risk_assessment="..", evidence=...>
81
+ ```
82
+
67
83
  ### Getting a Signup
68
84
 
69
85
  This method allows you to query the latest assessment for a given signup event, returning signup assessment, containing the risk assessment and supporting evidence:
@@ -75,6 +91,74 @@ assessment = api.get_signup_assessment(signup_id: "95a9fc56-f65e-436b-a87f-a1338
75
91
 
76
92
  ```
77
93
 
94
+ ### Registering a Login
95
+
96
+ This method registers a new login for the given installation and account, returning a login assessment, containing the risk assessment and supporting evidence:
97
+
98
+ ```ruby
99
+ installation_id = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
100
+ account_id = 'account-identifier-123'
101
+
102
+ assessment = api.register_login(
103
+ installation_id: installation_id,
104
+ account_id: account_id,
105
+ )
106
+
107
+ # => #<OpenStruct id="...", device_id="...", risk_assessment="..", evidence=...>
108
+
109
+ ```
110
+
111
+ It also supports optional parameters, for example:
112
+
113
+ ```ruby
114
+ installation_id = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
115
+ account_id = 'account-identifier-123'
116
+ external_id = 'some-external-identifier'
117
+
118
+ assessment = api.register_login(
119
+ installation_id: installation_id,
120
+ account_id: account_id,
121
+ external_id: external_id,
122
+ eval: false # can be used to register a new login without evaluating it
123
+ )
124
+
125
+ # => #<OpenStruct id="...", device_id="...", risk_assessment="..", evidence=...>
126
+ ```
127
+
128
+ ### Registering a Feedback
129
+
130
+ This method registers a feedback event for the given identifiers (optional arguments), returning true when success.
131
+
132
+ The `timestamp` argument should be a _Time_, _DateTime_ or an _Integer_ being the timestamp in milliseconds:
133
+
134
+ ```ruby
135
+ account_id = "cdb2cfbb-8ad8-4668-b276-5fff9bbfdc96"
136
+ timestamp = DateTime.parse('2022-06-20 23:29:00 UTC-3')
137
+
138
+ success = api.register_feedback(
139
+ event: Incognia::Constants::FeedbackEvent::IDENTITY_FRAUD,
140
+ timestamp: timestamp,
141
+ account_id: account_id
142
+ )
143
+
144
+ # => true
145
+ ```
146
+
147
+ For custom fraud, set the value of `event` with the corresponding code:
148
+
149
+ ```ruby
150
+ success = api.register_feedback(
151
+ event: 'custom_fraud_name'
152
+ timestamp: timestamp,
153
+ account_id: account_id,
154
+ installation_id: installation_id
155
+ )
156
+
157
+ # => true
158
+ ```
159
+
160
+ Check the [documentation](https://developer.incognia.com) to see possible identifiers for each event type.
161
+
78
162
  ## Exception handling
79
163
 
80
164
  Every method call can throw `APIError` and `APIAuthenticationError`.
data/lib/incognia/api.rb CHANGED
@@ -15,9 +15,10 @@ module Incognia
15
15
  host: "https://api.incognia.com/api")
16
16
  end
17
17
 
18
- def register_signup(installation_id:, address: nil)
18
+ def register_signup(installation_id:, address: nil, **opts)
19
19
  params = { installation_id: installation_id }
20
- params.merge!(address.to_hash) if address
20
+ params.merge!(opts)
21
+ params.merge!(address&.to_hash) if address
21
22
 
22
23
  response = connection.request(
23
24
  :post,
@@ -36,6 +37,37 @@ module Incognia
36
37
 
37
38
  SignupAssessment.from_hash(response.body) if response.success?
38
39
  end
39
- end
40
40
 
41
+ def register_login(installation_id:, account_id:, **opts)
42
+ params = {
43
+ type: :login,
44
+ installation_id: installation_id,
45
+ account_id: account_id,
46
+ }
47
+ params.merge!(opts)
48
+
49
+ response = connection.request(
50
+ :post,
51
+ 'v2/authentication/transactions',
52
+ params
53
+ )
54
+
55
+ LoginAssessment.from_hash(response.body) if response.success?
56
+ end
57
+
58
+ def register_feedback(event: , timestamp: nil, **ids)
59
+ timestamp = timestamp.strftime('%s%L') if timestamp.respond_to? :strftime
60
+
61
+ params = { event: event, timestamp: timestamp&.to_i }.compact
62
+ params.merge!(ids)
63
+
64
+ response = connection.request(
65
+ :post,
66
+ '/api/v2/feedbacks',
67
+ params
68
+ )
69
+
70
+ response.success?
71
+ end
72
+ end
41
73
  end
@@ -0,0 +1,33 @@
1
+ module Incognia
2
+ module Constants
3
+ module FeedbackEvent
4
+ ACCOUNT_TAKEOVER = 'account_takeover'.freeze
5
+ CHALLENGE_FAILED = 'challenge_failed'.freeze
6
+ CHALLENGE_PASSED = 'challenge_passed'.freeze
7
+ CHARGEBACK = 'chargeback'.freeze
8
+ CHARGEBACK_NOTIFICATION = 'chargeback_notification'.freeze
9
+ IDENTITY_FRAUD = 'identity_fraud'.freeze
10
+ MPOS_FRAUD = 'mpos_fraud'.freeze
11
+ PASSWORD_CHANGE_FAILED = 'password_change_failed'.freeze
12
+ PASSWORD_CHANGED_SUCCESSFULLY = 'password_changed_successfully'.freeze
13
+ PROMOTION_ABUSE = 'promotion_abuse'.freeze
14
+ RESET = 'reset'.freeze
15
+ VERIFIED = 'verified'.freeze
16
+
17
+ SIGNUP_ACCEPTED = 'signup_accepted'.freeze
18
+ SIGNUP_DECLINED = 'signup_declined'.freeze
19
+
20
+ LOGIN_ACCEPTED = 'login_accepted'.freeze
21
+ LOGIN_DECLINED = 'login_declined'.freeze
22
+
23
+ PAYMENT_ACCEPTED = 'payment_accepted'.freeze
24
+ PAYMENT_ACCEPTED_BY_CONTROL_GROUP = 'payment_accepted_by_control_group'.freeze
25
+ PAYMENT_ACCEPTED_BY_THIRD_PARTY = 'payment_accepted_by_third_party'.freeze
26
+ PAYMENT_DECLINED = 'payment_declined'.freeze
27
+ PAYMENT_DECLINED_BY_ACQUIRER = 'payment_declined_by_acquirer'.freeze
28
+ PAYMENT_DECLINED_BY_BUSINESS = 'payment_declined_by_business'.freeze
29
+ PAYMENT_DECLINED_BY_MANUAL_REVIEW = 'payment_declined_by_manual_review'.freeze
30
+ PAYMENT_DECLINED_BY_RISK_ANALYSIS = 'payment_declined_by_risk_analysis'.freeze
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "api_resource"
2
+
3
+ module Incognia
4
+ class LoginAssessment < APIResource; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Incognia
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/incognia.rb CHANGED
@@ -8,8 +8,11 @@ require_relative "incognia/api"
8
8
 
9
9
  require_relative "incognia/resources/api_resource"
10
10
  require_relative "incognia/resources/signup_assessment"
11
+ require_relative "incognia/resources/login_assessment"
11
12
  require_relative "incognia/resources/credentials"
12
13
 
14
+ require_relative "incognia/constants/feedback_event"
15
+
13
16
  module Incognia
14
17
  class APIError < StandardError
15
18
  attr_reader :message, :errors, :status
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: incognia_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Cavalcanti
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -46,6 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".github/CODEOWNERS"
49
+ - ".github/workflows/codeql.yml"
49
50
  - ".github/workflows/main.yml"
50
51
  - ".gitignore"
51
52
  - ".rspec"
@@ -62,8 +63,10 @@ files:
62
63
  - lib/incognia/address.rb
63
64
  - lib/incognia/api.rb
64
65
  - lib/incognia/client.rb
66
+ - lib/incognia/constants/feedback_event.rb
65
67
  - lib/incognia/resources/api_resource.rb
66
68
  - lib/incognia/resources/credentials.rb
69
+ - lib/incognia/resources/login_assessment.rb
67
70
  - lib/incognia/resources/signup_assessment.rb
68
71
  - lib/incognia/util.rb
69
72
  - lib/incognia/version.rb
@@ -73,7 +76,7 @@ metadata:
73
76
  homepage_uri: https://github.com/inloco/incognia-api-ruby
74
77
  source_code_uri: https://github.com/inloco/incognia-api-ruby
75
78
  changelog_uri: https://github.com/inloco/incognia-api-ruby/blob/master/
76
- post_install_message:
79
+ post_install_message:
77
80
  rdoc_options: []
78
81
  require_paths:
79
82
  - lib
@@ -88,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
91
  - !ruby/object:Gem::Version
89
92
  version: '0'
90
93
  requirements: []
91
- rubygems_version: 3.1.6
92
- signing_key:
94
+ rubygems_version: 3.1.4
95
+ signing_key:
93
96
  specification_version: 4
94
97
  summary: Official Ruby lib for communicating with Incognia API
95
98
  test_files: []