as2 0.5.1 → 0.5.2
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/as2.gemspec +1 -1
- data/lib/as2/message.rb +28 -9
- data/lib/as2/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc88a7c3befd19715a142f886fcac0429911b1b2c6d4df8e5c6f6797c6469c2
|
4
|
+
data.tar.gz: ba6943a989242be148d7e39c896f61747b8455888883b60ff179d6bf53e25309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14dc1ecb69d8678db913d9ee2425ae35f3e2e1b9a927a3a573e36e9a704dd4a7ab994d7c98182bf0053f40520040f0001fbc8b1390c82ebd57aa7e5c3495e99c
|
7
|
+
data.tar.gz: e43327ebbeac9bd46a2ccc4e3cd13f6354de46a3507fe01b134ecf33feef6643555c63e2ad2310debf8b3a23ec88c985d869087bf4cce29a2c54d8d06cfa753a
|
data/as2.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Simple AS2 server and client implementation}
|
13
13
|
spec.description = %q{Simple AS2 server and client implementation. Follows the AS2 implementation from http://as2.mendelson-e-c.com}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/alexdean/as2"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
data/lib/as2/message.rb
CHANGED
@@ -2,6 +2,28 @@ module As2
|
|
2
2
|
class Message
|
3
3
|
attr_reader :verification_error
|
4
4
|
|
5
|
+
# given multiple parts of a message, choose the one most likely to be the actual content we care about
|
6
|
+
#
|
7
|
+
# @param [Array<Mail::Part>]
|
8
|
+
# @return [Mail::Part, nil]
|
9
|
+
def self.choose_attachment(mail_parts)
|
10
|
+
return nil if mail_parts.nil?
|
11
|
+
|
12
|
+
# if there are multiple content parts, try to prefer the EDI content.
|
13
|
+
candidates = mail_parts
|
14
|
+
.select { |part| part.content_type.to_s['pkcs7-signature'].nil? } # skip signature
|
15
|
+
.sort_by { |part| part.content_type.to_s.match(/^application\/edi/i) ? 0 : 1 }
|
16
|
+
candidates[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [Mail::Part] attachment
|
20
|
+
# @param [String] mic_algorithm
|
21
|
+
# @return [String] message integrity check string
|
22
|
+
def self.mic(attachment, mic_algorithm)
|
23
|
+
digest = As2::DigestSelector.for_code(mic_algorithm)
|
24
|
+
digest.base64digest(attachment.raw_source.lstrip)
|
25
|
+
end
|
26
|
+
|
5
27
|
def initialize(message, private_key, public_certificate)
|
6
28
|
# TODO: might need to use OpenSSL::PKCS7.read_smime rather than .new sometimes
|
7
29
|
@pkcs7 = OpenSSL::PKCS7.new(message)
|
@@ -80,8 +102,7 @@ module As2
|
|
80
102
|
end
|
81
103
|
|
82
104
|
def mic
|
83
|
-
|
84
|
-
digest.base64digest(attachment.raw_source.strip)
|
105
|
+
self.class.mic(attachment, mic_algorithm)
|
85
106
|
end
|
86
107
|
|
87
108
|
def mic_algorithm
|
@@ -90,13 +111,11 @@ module As2
|
|
90
111
|
|
91
112
|
# Return the attached file, use .filename and .body on the return value
|
92
113
|
def attachment
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
mail
|
99
|
-
end
|
114
|
+
self.class.choose_attachment(parts)
|
115
|
+
end
|
116
|
+
|
117
|
+
def parts
|
118
|
+
mail&.parts
|
100
119
|
end
|
101
120
|
|
102
121
|
private
|
data/lib/as2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: as2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OfficeLuv
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
@@ -168,7 +168,7 @@ files:
|
|
168
168
|
- lib/as2/mime_generator.rb
|
169
169
|
- lib/as2/server.rb
|
170
170
|
- lib/as2/version.rb
|
171
|
-
homepage: https://github.com/
|
171
|
+
homepage: https://github.com/alexdean/as2
|
172
172
|
licenses:
|
173
173
|
- MIT
|
174
174
|
metadata:
|