scanii-ruby 1.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +14 -12
- data/lib/scanii/client.rb +15 -1
- data/lib/scanii/target.rb +50 -0
- data/lib/scanii/version.rb +1 -1
- data/lib/scanii.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6eafeea25fdb7195d2f1a0f9599fac6f3a815872b403c170573b9d585c87ea76
|
|
4
|
+
data.tar.gz: 72cb2cd424e382e147c5464f9b8bc6edcd16dcd1887897669ffddabf760e515f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cc93b317de609aa3499ff76343b8a3376c5083211b3bf3fe8b2968f1777211040993e750be8fc1602f39bb2f3cde41cbb4d7cbf3ad7072efd45bdece58a23fd
|
|
7
|
+
data.tar.gz: dc2bfe69e31ccbc2f1ca08dcb1bcc1f8d2c4b38ae800b9c63ed7909689bdaf33454edf4b760125bc7ac6c34b7656a7e7192909b4a795c60c24915e869a73a457
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `scanii-ruby` are documented here. Versions follow [SemVer](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [1.3.0] — deprecate AUTO endpoint
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `Scanii::Target` — typed regional endpoint class with constants `Scanii::Target::US1`,
|
|
10
|
+
`EU1`, `EU2`, `AP1`, `AP2`, `CA1`. Pass to `Scanii::Client.new(endpoint:)` instead of a
|
|
11
|
+
bare URL string for ergonomics and IDE autocomplete. The `endpoint:` keyword still accepts
|
|
12
|
+
bare URL strings (e.g. for scanii-cli), so this is purely additive.
|
|
13
|
+
|
|
14
|
+
### Deprecated
|
|
15
|
+
|
|
16
|
+
- Default `endpoint:` parameter (`https://api.scanii.com`) — latency-based routing does not
|
|
17
|
+
guarantee which region processes your data. Pass an explicit regional endpoint
|
|
18
|
+
(`Scanii::Target::US1`, `Scanii::Target::EU1`, etc.) for data residency compliance.
|
|
19
|
+
Constructing a client without an explicit endpoint now emits a `warn` message.
|
|
20
|
+
Will be removed in a future major version.
|
|
21
|
+
|
|
5
22
|
## [1.2.0] — v2.2 surface
|
|
6
23
|
|
|
7
24
|
### New API
|
data/README.md
CHANGED
|
@@ -35,7 +35,7 @@ Scan a file from disk:
|
|
|
35
35
|
```ruby
|
|
36
36
|
require "scanii"
|
|
37
37
|
|
|
38
|
-
client = Scanii::Client.new(key: "your-key", secret: "your-secret")
|
|
38
|
+
client = Scanii::Client.new(key: "your-key", secret: "your-secret", endpoint: Scanii::Target::US1)
|
|
39
39
|
|
|
40
40
|
result = client.process_file("./file.pdf")
|
|
41
41
|
puts "findings: #{result.findings.inspect}"
|
|
@@ -77,19 +77,21 @@ Full API reference: <https://scanii.github.io/openapi/v22/>.
|
|
|
77
77
|
client = Scanii::Client.new(
|
|
78
78
|
key: "k",
|
|
79
79
|
secret: "s",
|
|
80
|
-
endpoint:
|
|
80
|
+
endpoint: Scanii::Target::EU1
|
|
81
81
|
)
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
The `endpoint:` keyword accepts either a `Scanii::Target` constant or a bare URL String (useful for scanii-cli, e.g. `endpoint: "http://localhost:4000"`).
|
|
85
|
+
|
|
86
|
+
| Constant | Endpoint |
|
|
85
87
|
|---|---|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
88
|
+
| `Scanii::Target::US1` | `https://api-us1.scanii.com` |
|
|
89
|
+
| `Scanii::Target::EU1` | `https://api-eu1.scanii.com` |
|
|
90
|
+
| `Scanii::Target::EU2` | `https://api-eu2.scanii.com` |
|
|
91
|
+
| `Scanii::Target::AP1` | `https://api-ap1.scanii.com` |
|
|
92
|
+
| `Scanii::Target::AP2` | `https://api-ap2.scanii.com` |
|
|
93
|
+
| `Scanii::Target::CA1` | `https://api-ca1.scanii.com` |
|
|
94
|
+
| ~~Auto (default)~~ | ~~`https://api.scanii.com`~~ — **deprecated**, does not guarantee regional data placement |
|
|
93
95
|
|
|
94
96
|
## Errors
|
|
95
97
|
|
|
@@ -120,10 +122,10 @@ Per SDK Principle 3, the SDK does not retry on the caller's behalf — backoff a
|
|
|
120
122
|
Mint a short-lived token server-side and authenticate with it from a less-trusted client:
|
|
121
123
|
|
|
122
124
|
```ruby
|
|
123
|
-
server_client = Scanii::Client.new(key: "k", secret: "s")
|
|
125
|
+
server_client = Scanii::Client.new(key: "k", secret: "s", endpoint: Scanii::Target::US1)
|
|
124
126
|
token = server_client.create_auth_token(300)
|
|
125
127
|
|
|
126
|
-
token_client = Scanii::Client.new(token: token.id)
|
|
128
|
+
token_client = Scanii::Client.new(token: token.id, endpoint: Scanii::Target::US1)
|
|
127
129
|
token_client.ping
|
|
128
130
|
```
|
|
129
131
|
|
data/lib/scanii/client.rb
CHANGED
|
@@ -31,11 +31,25 @@ module Scanii
|
|
|
31
31
|
# @param key [String, nil] API key (mutually exclusive with token)
|
|
32
32
|
# @param secret [String, nil] API secret (required when key is set)
|
|
33
33
|
# @param token [String, nil] auth-token id (mutually exclusive with key/secret)
|
|
34
|
-
# @param endpoint [String] base URL
|
|
34
|
+
# @param endpoint [Scanii::Target, String] base URL or {Scanii::Target} constant;
|
|
35
|
+
# defaults to https://api.scanii.com (deprecated)
|
|
36
|
+
# @deprecated The default endpoint (https://api.scanii.com) uses latency-based routing
|
|
37
|
+
# and does not guarantee which region processes your data. Pass an explicit regional
|
|
38
|
+
# endpoint for data residency compliance: {Scanii::Target::US1}, {Scanii::Target::EU1},
|
|
39
|
+
# {Scanii::Target::EU2}, {Scanii::Target::AP1}, {Scanii::Target::AP2},
|
|
40
|
+
# {Scanii::Target::CA1}. A bare URL String is also accepted (e.g. for scanii-cli).
|
|
41
|
+
# Will be removed in a future major version.
|
|
35
42
|
# @param timeout [Integer] open + read timeout in seconds; default 60
|
|
36
43
|
# @param user_agent [String, nil] optional fragment prepended to the SDK's default User-Agent
|
|
37
44
|
def initialize(key: nil, secret: nil, token: nil, endpoint: DEFAULT_ENDPOINT,
|
|
38
45
|
timeout: DEFAULT_TIMEOUT, user_agent: nil)
|
|
46
|
+
if endpoint == DEFAULT_ENDPOINT
|
|
47
|
+
warn "[scanii] DEPRECATION: No explicit endpoint set; defaulting to " \
|
|
48
|
+
"#{DEFAULT_ENDPOINT} (AUTO routing). This does not guarantee regional data " \
|
|
49
|
+
"placement. Pass an explicit regional endpoint (e.g. Scanii::Target::US1) " \
|
|
50
|
+
"for data residency compliance. The AUTO default will be removed in a " \
|
|
51
|
+
"future major version."
|
|
52
|
+
end
|
|
39
53
|
@auth_header = build_auth_header(key, secret, token)
|
|
40
54
|
@endpoint = endpoint.to_s.sub(%r{/+\z}, "")
|
|
41
55
|
raise ArgumentError, "endpoint must not be empty" if @endpoint.empty?
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Scanii
|
|
2
|
+
# Scanii regional API endpoints.
|
|
3
|
+
#
|
|
4
|
+
# Pass one of the predefined regional constants (e.g. {US1}) to
|
|
5
|
+
# {Scanii::Client#initialize} via the +endpoint:+ keyword. The constructor
|
|
6
|
+
# also accepts an arbitrary URL String for testing against scanii-cli or
|
|
7
|
+
# other local mocks:
|
|
8
|
+
#
|
|
9
|
+
# Scanii::Client.new(key: "k", secret: "s", endpoint: Scanii::Target::US1)
|
|
10
|
+
# Scanii::Client.new(key: "k", secret: "s", endpoint: Scanii::Target.new("http://localhost:4000"))
|
|
11
|
+
#
|
|
12
|
+
# +Scanii::Target::AUTO+ (latency-based routing) is intentionally not provided —
|
|
13
|
+
# customer data residency / chain-of-custody compliance requires an explicit
|
|
14
|
+
# regional choice.
|
|
15
|
+
#
|
|
16
|
+
# @see https://scanii.github.io/openapi/v22/
|
|
17
|
+
class Target
|
|
18
|
+
attr_reader :url
|
|
19
|
+
|
|
20
|
+
# @param url [String] base URL for the target endpoint
|
|
21
|
+
def initialize(url)
|
|
22
|
+
raise ArgumentError, "Target URL must be a non-empty String" if url.nil? || url.to_s.empty?
|
|
23
|
+
|
|
24
|
+
@url = url.to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Coerce to String (the base URL). Lets +Scanii::Target+ instances be used
|
|
28
|
+
# interchangeably with String URLs in +endpoint:+.
|
|
29
|
+
def to_s
|
|
30
|
+
@url
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def ==(other)
|
|
34
|
+
other.is_a?(Target) && other.url == @url
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
alias eql? ==
|
|
38
|
+
|
|
39
|
+
def hash
|
|
40
|
+
@url.hash
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
US1 = new("https://api-us1.scanii.com").freeze
|
|
44
|
+
EU1 = new("https://api-eu1.scanii.com").freeze
|
|
45
|
+
EU2 = new("https://api-eu2.scanii.com").freeze
|
|
46
|
+
AP1 = new("https://api-ap1.scanii.com").freeze
|
|
47
|
+
AP2 = new("https://api-ap2.scanii.com").freeze
|
|
48
|
+
CA1 = new("https://api-ca1.scanii.com").freeze
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/scanii/version.rb
CHANGED
data/lib/scanii.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scanii-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scanii
|
|
@@ -80,6 +80,7 @@ files:
|
|
|
80
80
|
- lib/scanii/multipart.rb
|
|
81
81
|
- lib/scanii/pending_result.rb
|
|
82
82
|
- lib/scanii/processing_result.rb
|
|
83
|
+
- lib/scanii/target.rb
|
|
83
84
|
- lib/scanii/trace_event.rb
|
|
84
85
|
- lib/scanii/trace_result.rb
|
|
85
86
|
- lib/scanii/version.rb
|