noresponse 5.0.1 → 5.1.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: 173341569ba7e8b13d34cc94a390917880db7efe4c0f74d910199fe7765a2b68
4
- data.tar.gz: 9e24524697bf6de4badc397a3f49ef0ea15a4b8b64a5a31d27a709a06ee89c7c
3
+ metadata.gz: d918e4d2660417ed78b7a4638b1f641f6f43d2b78307b2e5881774d7bc347421
4
+ data.tar.gz: 73a9a476b05a676511ec81bf4d7218eec96776283999ecba97791ba8ca7056be
5
5
  SHA512:
6
- metadata.gz: eb00db291d619fb1c75a2c1f1c2cbfb1790349b0fb53c72fabcc8b959e2af63a69c9bd2a26e946055142b2605e570d98cde844194722a820bb5a40dc6da7e0bf
7
- data.tar.gz: 26a00a45abe434f7e2431edceff0598b13c32803d915e0ca1efe441dc07cbfd2b37765ecb71c26806a638a7c5aabc1ace8cf479f533fd10070687e7197ee67c3
6
+ metadata.gz: 963720145ad3133a5d2e3c1a31dbbc73e3f9189fe5a8521a61cff2800020d8c273a964f5f32c0c1feb9e3241dfb118ad4d29b46fbf783e6bed96d40730745092
7
+ data.tar.gz: 46df6c429316e610ed12de84b3e2f51f3355dc929b44ecfc784763c26dafbc32490cc5417d494f66ac58fcbc8fcc1c5536cbe698f3b15478fbd1240679dae94a
@@ -70,12 +70,20 @@ module NoResponse
70
70
  # strings or symbols) to NONE, REVOKE_SESSIONS or BAN; a decision you
71
71
  # leave out does nothing. An unknown action raises ArgumentError.
72
72
  def action_for(event, policy = DEFAULT_POLICY)
73
- return NONE if event.type != 'assessment.updated' || event.test? || event.expired?
73
+ return NONE if event.test? || event.expired?
74
74
 
75
75
  data = event.data
76
- return NONE if data.status == Models::Shared::Status::PENDING || data.account.nil?
77
-
78
- decision = data.account.risk.decision.to_s
76
+ if event.type == 'account.risk_changed'
77
+ # The event is sent when any flow's decision changes; sessions are about the
78
+ # login decision, so an unchanged login decision acts on nothing.
79
+ decision = data.account.decisions_by_flow.login.to_s
80
+ return NONE if data.previous_decisions_by_flow&.login.to_s == decision
81
+ elsif event.type == 'assessment.updated'
82
+ return NONE if data.status == Models::Shared::Status::PENDING || data.account.nil?
83
+ decision = data.account.risk.decision.to_s
84
+ else
85
+ return NONE
86
+ end
79
87
  return NONE unless DECISIONS.include?(decision)
80
88
 
81
89
  table = policy.to_h.transform_keys(&:to_s)
@@ -105,9 +113,9 @@ module NoResponse
105
113
  def handle(payload, headers, secrets, provider, policy: DEFAULT_POLICY, user_id: nil, **verify)
106
114
  event = Webhooks.construct_event(payload, headers, secrets, **verify)
107
115
  action = action_for(event, policy)
108
- return Result.new(event: event, action: NONE) if action == NONE || event.type != 'assessment.updated'
116
+ return Result.new(event: event, action: NONE) if action == NONE
109
117
 
110
- account_id = event.data.detail.account_id
118
+ account_id = event.type == 'account.risk_changed' ? event.data.account.id : event.data.detail.account_id
111
119
  resolved = user_id ? user_id.call(account_id, event) : account_id
112
120
  return Result.new(event: event, action: NONE) if resolved.nil? || resolved.to_s.empty?
113
121
 
@@ -35,6 +35,12 @@ module NoResponse
35
35
  ::String,
36
36
  {'format_json': {'letter_case': ::NoResponse::Utils.field_name("updated_at"), required: true}}
37
37
  )
38
+ # The version of the account's current risk. It increases every time the account's current risk or decisions_by_flow changes, and does not decrease. Of two copies of an account, the one with the higher risk_version is newer. account.risk_changed carries the risk_version that its change made.
39
+ field(
40
+ :risk_version,
41
+ ::Integer,
42
+ {'format_json': {'letter_case': ::NoResponse::Utils.field_name("risk_version"), required: true}}
43
+ )
38
44
  # Version of the body shape.
39
45
  field(
40
46
  :schema_version,
@@ -49,16 +55,18 @@ module NoResponse
49
55
  decisions_by_flow: Models::Shared::AccountDecisionsByFlow,
50
56
  assessment_id: ::String,
51
57
  updated_at: ::String,
58
+ risk_version: ::Integer,
52
59
  schema_version: ::String
53
60
  )
54
61
  .void
55
62
  }
56
- def initialize(id:, risk:, decisions_by_flow:, assessment_id:, updated_at:, schema_version: "1")
63
+ def initialize(id:, risk:, decisions_by_flow:, assessment_id:, updated_at:, risk_version:, schema_version: "1")
57
64
  @id = id
58
65
  @risk = risk
59
66
  @decisions_by_flow = decisions_by_flow
60
67
  @assessment_id = assessment_id
61
68
  @updated_at = updated_at
69
+ @risk_version = risk_version
62
70
  unless schema_version == "1"
63
71
  raise ArgumentError, "Invalid value for schema_version"
64
72
  end
@@ -74,6 +82,7 @@ module NoResponse
74
82
  return false unless @decisions_by_flow == other.decisions_by_flow
75
83
  return false unless @assessment_id == other.assessment_id
76
84
  return false unless @updated_at == other.updated_at
85
+ return false unless @risk_version == other.risk_version
77
86
  return false unless @schema_version == other.schema_version
78
87
  true
79
88
  end
@@ -36,6 +36,12 @@ class NoResponse::Models::Shared::Account
36
36
  def updated_at=(str_)
37
37
  end
38
38
 
39
+ def risk_version
40
+ end
41
+
42
+ def risk_version=(str_)
43
+ end
44
+
39
45
  def schema_version
40
46
  end
41
47
 
@@ -10,6 +10,7 @@ module NoResponse
10
10
  enums do
11
11
  ASSESS = new("assess")
12
12
  HISTORY = new("history")
13
+ DELETE = new("delete")
13
14
  WEBHOOKS = new("webhooks")
14
15
  DETAILED = new("detailed")
15
16
  INTEGRATIONS = new("integrations")
@@ -95,9 +95,9 @@ module NoResponse
95
95
 
96
96
  @language = "ruby"
97
97
  @openapi_doc_version = "1"
98
- @sdk_version = "5.0.1"
98
+ @sdk_version = "5.1.1"
99
99
  @gen_version = "internal"
100
- @user_agent = "noresponse-sdk/ruby 5.0.1 internal 1 noresponse"
100
+ @user_agent = "noresponse-sdk/ruby 5.1.1 internal 1 noresponse"
101
101
  end
102
102
 
103
103
  sig { returns([String, T::Hash[Symbol, String]]) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noresponse
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - NoResponse