session-validator-client 3.0.1 → 3.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: f1816744639488cc1585a2086e282cc605336199ad25b15f37dbd9813c1eb2db
4
- data.tar.gz: e6d8d97f3d41daa67723f0e052ec48cbdfe2f4add832f368085368f76d20e3b0
3
+ metadata.gz: 7a5fbffce84601019f81c281d10264ca718ea083ac84a12aa9ea079f6af56d1c
4
+ data.tar.gz: d73b28d840deed00914f2d5316e222967d0c17b791a52c1fccc44ce54964c8cb
5
5
  SHA512:
6
- metadata.gz: b99f8eb8174d308b0aa05620bd7036ff8a693bf8ec37604a8ae69033e9ca27b9251276b6a5baa9d02e79b517ceba58f2f5b9a95895bb949417978a69af9633d0
7
- data.tar.gz: 9c6363f1a4e1654f3b327f69d0a6dc294b0ef70dec3d81db8f29504c55716e767aa3b4f71bed858a6abad2e05fbd4a5325bb5176e9e7ca3f665049d66d2fd9b2
6
+ metadata.gz: 962e8d27ef646e4a5201a657937fa468639e1b75dacf5a36a2226a5abb6891799ef2eabd8209daa0a552369bbd470bf95822c0a3f0f9fecd0e8d6c5009ce7b14
7
+ data.tar.gz: 85de14cee3adf4f7b07b122023159116d43d91c2e59897273ef47f1ecd6eec3f58d9d33dd31ef4ccc921ed5e9ebee8da9f9c574f7014cc790b8700438b68ff34
data/README.md CHANGED
@@ -10,12 +10,16 @@ gem install session-validator-client
10
10
 
11
11
  ## Usage
12
12
 
13
+
13
14
  setup up the following environment variables:
14
15
 
15
16
  * `KEY_POOL`
16
17
  * `SESSION_VALIDATOR_KEYID`
17
18
  * `SESSION_VALIDATOR_URL`
18
19
 
20
+ ###Validating a single Msid
21
+ `valid?(msid)` returns `true` if `msid` is valid
22
+
19
23
  ```ruby
20
24
  require "session_validator"
21
25
 
@@ -23,6 +27,16 @@ client = SessionValidator::Client.new
23
27
  client.valid?("staging_int_5ad5f96f307cf9.61063404")
24
28
  ```
25
29
 
30
+ ###Batch validating multiple MSIDS
31
+ `filter_invalid(msids)` returns an array of the invalid MSIDS.
32
+
33
+ ```ruby
34
+ require "session_validator"
35
+
36
+ client = SessionValidator::Client.new
37
+ client.filter_invalid(["staging_int_5ad5f96f307cf9.61063404", "staging_int_5ad5f96f307cf9.61063405"])
38
+ ```
39
+
26
40
  ## Running tests
27
41
 
28
42
  ```bash
@@ -15,5 +15,16 @@ module SessionValidator
15
15
  @cache.set msid, result if result
16
16
  end
17
17
  end
18
+
19
+ def filter_invalid(msids)
20
+ @cache.cleanup
21
+
22
+ @client.filter_invalid(msids).tap do |result|
23
+ msids.each do |msid|
24
+ @cache.set msid, true unless result.include?(msid)
25
+ end
26
+ end
27
+ end
28
+
18
29
  end
19
30
  end
@@ -21,6 +21,18 @@ class SessionValidator::Client
21
21
  true
22
22
  end
23
23
 
24
+ def filter_invalid(msids)
25
+ response = client.post("/sessions/filter", JSON.generate({msids:msids}), headers)
26
+ if response.status == 200
27
+ JSON.parse(response.body)
28
+ else
29
+ []
30
+ end
31
+ rescue Faraday::TimeoutError
32
+ []
33
+ end
34
+
35
+
24
36
  private
25
37
 
26
38
  def client
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "session-validator-client"
3
- s.version = "3.0.1"
3
+ s.version = "3.1.1"
4
4
  s.summary = "Ruby client for Emarsys session validator service"
5
5
  s.authors = ["Emarsys Technologies Ltd."]
6
6
  s.email = "security@emarsys.com"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: session-validator-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emarsys Technologies Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-18 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escher-keypool