ruby_universign 1.1.1 → 1.5.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/.gitignore +3 -1
- data/CHANGELOG.md +38 -2
- data/README.md +33 -3
- data/lib/universign.rb +1 -2
- data/lib/universign/client.rb +5 -11
- data/lib/universign/configuration.rb +6 -4
- data/lib/universign/document.rb +13 -22
- data/lib/universign/error.rb +31 -11
- data/lib/universign/safeguard.rb +5 -5
- data/lib/universign/service/transaction.rb +2 -1
- data/lib/universign/signature_field.rb +6 -4
- data/lib/universign/version.rb +1 -1
- data/ruby_universign.gemspec +4 -3
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4146faa8f8d27032db64034d6350a8b01fc48867c1eb34fde2c0b23327022bb
|
4
|
+
data.tar.gz: 89bf6f2025a5ee0f25f93d246a43443780d4c314de35dff59f5e025334d0a69d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad3b266194f219e15daeb6a0be93004ebb46ee35dc93ed67ccc1077a6601ae5a91189f0fbd5b5f809c049b05ad98ffe6a284448268e04904c889030b5d20b0e4
|
7
|
+
data.tar.gz: 798fee3c9d80556a8d6dcd4ece8ea5127974e6b16d8075d9ec0fce5bda7f0d7ac3b9f5cc94a2da2e451c505e97db663d1cef759dbe4dfa45532f76b4ac49691e
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,43 @@
|
|
1
|
-
|
1
|
+
v1.4.0
|
2
2
|
-------------------------
|
3
|
+
- Refactor and rename errors. They now all inherit from `Universign::Error`.
|
3
4
|
|
4
|
-
|
5
|
+
v1.3.1
|
6
|
+
-------------------------
|
7
|
+
|
8
|
+
- Fixing regressions added
|
9
|
+
|
10
|
+
v1.3.0 - NOT WORKING
|
11
|
+
-------------------------
|
12
|
+
|
13
|
+
- Adding the possibility to configure proxy and timeout options for the XMLRPC Client
|
14
|
+
|
15
|
+
v1.2.1
|
16
|
+
-------------------------
|
17
|
+
|
18
|
+
- Bumping rake development dependancy due to security issues
|
19
|
+
|
20
|
+
v1.2.0
|
21
|
+
-------------------------
|
22
|
+
|
23
|
+
- Add `chaining_mode` to `Universign::Transaction` options.
|
24
|
+
|
25
|
+
v1.1.1
|
26
|
+
-------------------------
|
27
|
+
|
28
|
+
- bugfix : do not add `name` parameter to SignatureField when it's nil.
|
29
|
+
|
30
|
+
v1.1.0
|
31
|
+
-------------------------
|
32
|
+
|
33
|
+
- SignatureField can be managed with a named field instead of coordinates.
|
34
|
+
|
35
|
+
v1.0.0
|
36
|
+
-------------------------
|
37
|
+
|
38
|
+
- rename gem to `ruby_universign`
|
39
|
+
- rename`ESign` module to `Universign`
|
40
|
+
- release gem on rubygems
|
5
41
|
|
6
42
|
v0.1.6 (26/11/2015)
|
7
43
|
-------------------------
|
data/README.md
CHANGED
@@ -38,9 +38,11 @@ Configuration:
|
|
38
38
|
```ruby
|
39
39
|
# if you're using Rails, put this in an initializer
|
40
40
|
Universign.configure do |config|
|
41
|
-
config.endpoint =
|
42
|
-
config.login =
|
43
|
-
config.password =
|
41
|
+
config.endpoint = 'your_universign_endpoint' # Required ...
|
42
|
+
config.login = 'your_login' # Required ...
|
43
|
+
config.password = 'your_password' # Required ...
|
44
|
+
config.proxy = 'your_proxy_uri:your_proxy_port' # Optionnal ...
|
45
|
+
config.timeout = 30 # Optionnal if you wanna change the default XMLRPC Timeout ...
|
44
46
|
end
|
45
47
|
```
|
46
48
|
|
@@ -83,6 +85,33 @@ transaction = Universign::Transaction.new('9696179e-a43d-4803-beeb-9e5c02fd159b'
|
|
83
85
|
transaction.signed?
|
84
86
|
```
|
85
87
|
|
88
|
+
The gem also supports the updated way of creating multiple signature fields per document:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
doc_1 = Universign::Document.new(
|
92
|
+
name: 'one.pdf',
|
93
|
+
content: File.open('spec/fixtures/universign-guide-8.8.pdf').read,
|
94
|
+
signature_fields: [
|
95
|
+
Universign::SignatureField.new(coordinate: [20, 20], page: 1, signer_index: 0),
|
96
|
+
Universign::SignatureField.new(coordinate: [80, 20], page: 1, signer_index: 0)
|
97
|
+
]
|
98
|
+
)
|
99
|
+
|
100
|
+
doc_2 = Universign::Document.new(
|
101
|
+
name: 'two.pdf',
|
102
|
+
content: File.open('spec/fixtures/universign-guide-8.8.pdf').read,
|
103
|
+
signature_fields: [
|
104
|
+
Universign::SignatureField.new(coordinate: [100, 120], page: 4, signer_index: 0),
|
105
|
+
]
|
106
|
+
)
|
107
|
+
|
108
|
+
transaction = Universign::Transaction.create(
|
109
|
+
documents: [doc_1, doc_2],
|
110
|
+
signers: [signer],
|
111
|
+
options: { profile: 'default', final_doc_sent: true }
|
112
|
+
)
|
113
|
+
```
|
114
|
+
|
86
115
|
### `Universign::Document`
|
87
116
|
|
88
117
|
It can be created with either your file's content or your file's url.
|
@@ -118,6 +147,7 @@ handwritten_signature
|
|
118
147
|
profile
|
119
148
|
final_doc_sent
|
120
149
|
final_doc_requester_sent
|
150
|
+
chaining_mode
|
121
151
|
```
|
122
152
|
|
123
153
|
Default options are:
|
data/lib/universign.rb
CHANGED
@@ -10,11 +10,10 @@ require 'universign/transaction'
|
|
10
10
|
require 'universign/signature_field'
|
11
11
|
require 'universign/signer_infos'
|
12
12
|
require 'universign/transaction_signer'
|
13
|
+
require 'universign/error'
|
13
14
|
require 'universign/client'
|
14
15
|
require 'universign/document'
|
15
16
|
require 'universign/configuration'
|
16
|
-
require 'universign/error'
|
17
17
|
|
18
18
|
module Universign
|
19
|
-
include Error
|
20
19
|
end
|
data/lib/universign/client.rb
CHANGED
@@ -6,7 +6,11 @@ module Universign
|
|
6
6
|
attr_reader :client
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@client = XMLRPC::Client.new2(
|
9
|
+
@client = XMLRPC::Client.new2(
|
10
|
+
Universign.configuration.endpoint,
|
11
|
+
Universign.configuration.proxy,
|
12
|
+
Universign.configuration.timeout
|
13
|
+
)
|
10
14
|
@client.user = Universign.configuration.login
|
11
15
|
@client.password = Universign.configuration.password
|
12
16
|
end
|
@@ -18,15 +22,5 @@ module Universign
|
|
18
22
|
super(method, *args, &block)
|
19
23
|
end
|
20
24
|
end
|
21
|
-
|
22
|
-
# _ _
|
23
|
-
# _____ _____ ___ _ __ | |_(_) ___ _ __ ___
|
24
|
-
# / _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __|
|
25
|
-
# | __/> < (_| __/ |_) | |_| | (_) | | | \__ \
|
26
|
-
# \___/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/
|
27
|
-
# |_|
|
28
|
-
class InvalidCredentials < StandardError; end
|
29
|
-
class ErrorWhenSigningPDF < StandardError; end
|
30
|
-
class UnknownException < StandardError; end
|
31
25
|
end
|
32
26
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Universign
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :login, :password, :endpoint
|
3
|
+
attr_accessor :login, :password, :endpoint, :proxy, :timeout
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@login =
|
7
|
-
@password =
|
8
|
-
@endpoint =
|
6
|
+
@login = nil
|
7
|
+
@password = nil
|
8
|
+
@endpoint = nil
|
9
|
+
@proxy = nil
|
10
|
+
@timeout = nil
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
data/lib/universign/document.rb
CHANGED
@@ -75,6 +75,19 @@ module Universign
|
|
75
75
|
params['name'] = data
|
76
76
|
end
|
77
77
|
|
78
|
+
def signature_fields=(data)
|
79
|
+
if !data.is_a?(Array)
|
80
|
+
raise 'SignatureFieldsMustBeAnArray'
|
81
|
+
end
|
82
|
+
|
83
|
+
@signature_fields = data
|
84
|
+
params['signatureFields'] = data.map do |d|
|
85
|
+
raise 'BadSignatureFieldType' unless d.instance_of?(SignatureField)
|
86
|
+
|
87
|
+
d.params
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
78
91
|
# The meta data of the PDF document
|
79
92
|
#
|
80
93
|
# @return [Hash]
|
@@ -90,27 +103,5 @@ module Universign
|
|
90
103
|
@meta_data = data
|
91
104
|
params['metaData'] = data
|
92
105
|
end
|
93
|
-
|
94
|
-
# _ _
|
95
|
-
# _____ _____ ___ _ __ | |_(_) ___ _ __ ___
|
96
|
-
# / _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __|
|
97
|
-
# | __/> < (_| __/ |_) | |_| | (_) | | | \__ \
|
98
|
-
# \___/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/
|
99
|
-
# |_|
|
100
|
-
class UnknownDocument < StandardError; end
|
101
|
-
class NotSigned < StandardError; end
|
102
|
-
class MissingDocument < StandardError; end
|
103
|
-
class MetaDataMustBeAHash < StandardError; end
|
104
|
-
class DocumentURLInvalid < StandardError
|
105
|
-
attr_accessor :url
|
106
|
-
|
107
|
-
def initialize(url)
|
108
|
-
@url = url
|
109
|
-
end
|
110
|
-
|
111
|
-
def to_s
|
112
|
-
"Can't find document at '#{@url}''"
|
113
|
-
end
|
114
|
-
end
|
115
106
|
end
|
116
107
|
end
|
data/lib/universign/error.rb
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
module Universign
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
class Error < ::StandardError
|
3
|
+
def self.match_class(code)
|
4
|
+
{
|
5
|
+
73002 => Universign::ErrorWhenSigningPDF, # An error occured when signing the PDF document
|
6
|
+
73010 => Universign::InvalidCredentials, # The login and/or password are invalid.
|
7
|
+
73025 => Universign::UnknownDocument, # The used transaction id or custom id is invalid
|
8
|
+
73027 => Universign::DocumentNotSigned
|
9
|
+
}.fetch(code, nil)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class NotEnoughTokens < Error; end
|
14
|
+
|
15
|
+
class ErrorWhenSigningPDF < Error; end
|
16
|
+
class InvalidCredentials < Error; end
|
17
|
+
class UnknownException < Error; end
|
18
|
+
|
19
|
+
class UnknownDocument < Error; end
|
20
|
+
class DocumentNotSigned < Error; end
|
21
|
+
class MissingDocument < Error; end
|
22
|
+
class MetaDataMustBeAHash < Error; end
|
23
|
+
class DocumentURLInvalid < Error
|
24
|
+
attr_accessor :url
|
25
|
+
|
26
|
+
def initialize(url)
|
27
|
+
@url = url
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"Can't find document at '#{@url}'"
|
32
|
+
end
|
13
33
|
end
|
14
34
|
end
|
data/lib/universign/safeguard.rb
CHANGED
@@ -16,27 +16,27 @@ module Universign
|
|
16
16
|
raise ex
|
17
17
|
end
|
18
18
|
|
19
|
-
known_exception = Universign::
|
19
|
+
known_exception = Universign::Error.match_class(ex.faultCode)
|
20
20
|
|
21
21
|
if known_exception
|
22
22
|
raise known_exception
|
23
23
|
elsif ex.faultString.include?('Error on document download for this URL')
|
24
24
|
url = ex.faultString.match(/<(.+)>/)[1] rescue 'unknown URL'
|
25
|
-
raise Universign::
|
25
|
+
raise Universign::DocumentURLInvalid.new(url)
|
26
26
|
elsif ex.faultString.include?('Invalid document URL')
|
27
27
|
url = ex.faultString.match(/<(.+)>/)[1] rescue 'unknown URL'
|
28
|
-
raise Universign::
|
28
|
+
raise Universign::DocumentURLInvalid.new(url)
|
29
29
|
elsif ex.faultString.include?('Not enough tokens')
|
30
30
|
raise Universign::NotEnoughTokens
|
31
31
|
elsif ex.faultString.include?('ID is unknown')
|
32
|
-
raise Universign::
|
32
|
+
raise Universign::UnknownDocument
|
33
33
|
else
|
34
34
|
handle_exception(ex, callback)
|
35
35
|
end
|
36
36
|
|
37
37
|
rescue RuntimeError => ex
|
38
38
|
if ex.message.include?('Authorization failed')
|
39
|
-
raise Universign::
|
39
|
+
raise Universign::InvalidCredentials
|
40
40
|
end
|
41
41
|
raise ex
|
42
42
|
end
|
@@ -11,7 +11,8 @@ module Universign
|
|
11
11
|
handwritten_signature: :handwrittenSignature,
|
12
12
|
profile: :profile,
|
13
13
|
final_doc_sent: :finalDocSent,
|
14
|
-
final_doc_requester_sent: :finalDocRequesterSent
|
14
|
+
final_doc_requester_sent: :finalDocRequesterSent,
|
15
|
+
chaining_mode: :chainingMode
|
15
16
|
}
|
16
17
|
|
17
18
|
DEFAULT_OPTIONS = {
|
@@ -2,15 +2,17 @@ module Universign
|
|
2
2
|
class SignatureField
|
3
3
|
attr_reader :params
|
4
4
|
|
5
|
-
def initialize(coordinate:, name: nil, page:)
|
5
|
+
def initialize(coordinate:, name: nil, page:, signer_index: 0)
|
6
6
|
@coordinate = coordinate || [0, 0]
|
7
7
|
@name = name
|
8
8
|
@page = page
|
9
|
+
@signer_index = signer_index
|
9
10
|
|
10
11
|
@params = {
|
11
|
-
page:
|
12
|
-
x:
|
13
|
-
y:
|
12
|
+
page: @page,
|
13
|
+
x: @coordinate[0],
|
14
|
+
y: @coordinate[1],
|
15
|
+
'signerIndex': @signer_index
|
14
16
|
}
|
15
17
|
|
16
18
|
@params[:name] = @name unless @name.nil?
|
data/lib/universign/version.rb
CHANGED
data/ruby_universign.gemspec
CHANGED
@@ -23,12 +23,13 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.required_ruby_version = '>= 2.
|
26
|
+
spec.required_ruby_version = '>= 2.3'
|
27
27
|
|
28
28
|
spec.add_runtime_dependency 'activesupport', '>= 4.1'
|
29
|
+
spec.add_runtime_dependency "xmlrpc"
|
29
30
|
|
30
|
-
spec.add_development_dependency "bundler", "
|
31
|
-
spec.add_development_dependency "rake", "
|
31
|
+
spec.add_development_dependency "bundler", ">= 1.10"
|
32
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
32
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
33
34
|
spec.add_development_dependency "dotenv", "~> 2.0"
|
34
35
|
spec.add_development_dependency "webmock", "~> 3.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_universign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Besnard
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -26,34 +26,48 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '4.1'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: xmlrpc
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: bundler
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
|
-
- - "
|
47
|
+
- - ">="
|
34
48
|
- !ruby/object:Gem::Version
|
35
49
|
version: '1.10'
|
36
50
|
type: :development
|
37
51
|
prerelease: false
|
38
52
|
version_requirements: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
40
|
-
- - "
|
54
|
+
- - ">="
|
41
55
|
- !ruby/object:Gem::Version
|
42
56
|
version: '1.10'
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: rake
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
|
-
- - "
|
61
|
+
- - ">="
|
48
62
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
63
|
+
version: 12.3.3
|
50
64
|
type: :development
|
51
65
|
prerelease: false
|
52
66
|
version_requirements: !ruby/object:Gem::Requirement
|
53
67
|
requirements:
|
54
|
-
- - "
|
68
|
+
- - ">="
|
55
69
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
70
|
+
version: 12.3.3
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: rspec
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,14 +175,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
175
|
requirements:
|
162
176
|
- - ">="
|
163
177
|
- !ruby/object:Gem::Version
|
164
|
-
version: '2.
|
178
|
+
version: '2.3'
|
165
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
180
|
requirements:
|
167
181
|
- - ">="
|
168
182
|
- !ruby/object:Gem::Version
|
169
183
|
version: '0'
|
170
184
|
requirements: []
|
171
|
-
rubygems_version: 3.0.
|
185
|
+
rubygems_version: 3.0.3
|
172
186
|
signing_key:
|
173
187
|
specification_version: 4
|
174
188
|
summary: Universign's API Wrapper
|