dps 0.0.0 → 0.0.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 +4 -4
- data/.gitignore +11 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +21 -0
- data/Rakefile +6 -0
- data/dps.gemspec +39 -0
- data/lib/dps.rb +7 -3
- data/lib/dps/dns.rb +88 -0
- data/lib/dps/version.rb +3 -0
- metadata +72 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 232f6b48b815baab22f7738034f0b1c0076304d3
|
4
|
+
data.tar.gz: 18672692759e3de39ace8857c1a18cbf2f716230
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f89eae6be2e14cff1735197cddb701fe998905e551cf247f0e6f5be5a28a99ce75ebb242e208ffa0a7ba77df1cf63c697e73df5f66845e4a4982ecaae535666
|
7
|
+
data.tar.gz: eed3a158391a5a1e63956e714933343c21780d094a026316806bb5a5ef2e04d6afee1742bff0a159a4bc311259d4e9c4799dbefe22ea7fd04f8913ea17df96be
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dps (0.0.0)
|
5
|
+
dnsruby (~> 1.61)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.6.0)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
dnsruby (1.61.2)
|
14
|
+
addressable (~> 2.5)
|
15
|
+
public_suffix (3.0.3)
|
16
|
+
rake (12.3.2)
|
17
|
+
rspec (3.8.0)
|
18
|
+
rspec-core (~> 3.8.0)
|
19
|
+
rspec-expectations (~> 3.8.0)
|
20
|
+
rspec-mocks (~> 3.8.0)
|
21
|
+
rspec-core (3.8.0)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-expectations (3.8.1)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-mocks (3.8.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-support (3.8.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
bundler (~> 1.17.a)
|
36
|
+
dps!
|
37
|
+
rake (~> 12.3)
|
38
|
+
rspec (~> 3.8)
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.17.0.pre.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Mat Holroyd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# DPS Ruby gem
|
2
|
+
|
3
|
+
This Ruby library is a collection of tools to help interact with or implement a DPS (Direct Payment Standard) server.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'dps'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install dps
|
21
|
+
|
data/Rakefile
ADDED
data/dps.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "dps/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "dps"
|
7
|
+
spec.version = DPS::VERSION
|
8
|
+
spec.authors = ["Mat Holroyd"]
|
9
|
+
spec.email = ['dps@matholroyd.com']
|
10
|
+
|
11
|
+
spec.summary = %q{DPS is a collection of tools to help interact with or implement a DPS server}
|
12
|
+
spec.description = %q{Direct Payment Standard (DPS) specifies a common way for entities to advertise payment options as well as facilitate payments directly between 2 parties. This library contains tools to interact with or implement a DPS server.}
|
13
|
+
spec.homepage = "https://github.com/matholroyd/dps-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_dependency "dnsruby", "~> 1.61"
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.17.a"
|
37
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
38
|
+
spec.add_development_dependency "rspec", "~> 3.8"
|
39
|
+
end
|
data/lib/dps.rb
CHANGED
data/lib/dps/dns.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'dnsruby'
|
2
|
+
|
3
|
+
module DPS
|
4
|
+
class DNS
|
5
|
+
|
6
|
+
class NoRecords; end
|
7
|
+
class TooManyRecords; end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def get_records(domain)
|
11
|
+
get_dns_txt_records(domain).
|
12
|
+
collect { |value| decode_txt_record(value) }.select(&:valid?)
|
13
|
+
end
|
14
|
+
|
15
|
+
def decode_txt_record(value)
|
16
|
+
parts = value.gsub('"', '').split
|
17
|
+
|
18
|
+
# Reverse since Ruby #pop starts from end of list.
|
19
|
+
parts.reverse!
|
20
|
+
|
21
|
+
case parts.pop
|
22
|
+
when "dps:endpoint"
|
23
|
+
Endpoint.new(parts)
|
24
|
+
else
|
25
|
+
InvalidRecord
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_endpoint(domain)
|
30
|
+
records = get_records(domain).select { |r| r.is_a?(Endpoint) }
|
31
|
+
|
32
|
+
if records.length > 1
|
33
|
+
TooManyRecords
|
34
|
+
elsif records.length == 0
|
35
|
+
NoRecords
|
36
|
+
else
|
37
|
+
records[0].url
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def get_dns_txt_records(domain)
|
44
|
+
result = []
|
45
|
+
|
46
|
+
::Dnsruby::DNS.open do |dns|
|
47
|
+
record = dns.getresource(domain, "TXT")
|
48
|
+
result << record.data
|
49
|
+
end
|
50
|
+
|
51
|
+
result
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class InvalidRecord
|
56
|
+
def self.valid?
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Endpoint < Struct.new(:data)
|
62
|
+
def valid?
|
63
|
+
uri &&
|
64
|
+
uri.query.nil? &&
|
65
|
+
uri.fragment.nil? &&
|
66
|
+
uri.port == 443
|
67
|
+
end
|
68
|
+
|
69
|
+
def uri
|
70
|
+
@uri ||=
|
71
|
+
begin
|
72
|
+
URI(get_url_part.sub(/^url=/, ''))
|
73
|
+
rescue
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def url
|
79
|
+
uri && uri.to_s
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_url_part
|
83
|
+
data.find { |d| d =~ /^url=/ }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/lib/dps/version.rb
ADDED
metadata
CHANGED
@@ -1,28 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat Holroyd
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-01-22 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dnsruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.61'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.61'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.17.a
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.17.a
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.8'
|
13
69
|
description: Direct Payment Standard (DPS) specifies a common way for entities to
|
14
70
|
advertise payment options as well as facilitate payments directly between 2 parties.
|
15
71
|
This library contains tools to interact with or implement a DPS server.
|
16
|
-
email:
|
72
|
+
email:
|
73
|
+
- dps@matholroyd.com
|
17
74
|
executables: []
|
18
75
|
extensions: []
|
19
76
|
extra_rdoc_files: []
|
20
77
|
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- dps.gemspec
|
21
85
|
- lib/dps.rb
|
86
|
+
- lib/dps/dns.rb
|
87
|
+
- lib/dps/version.rb
|
22
88
|
homepage: https://github.com/matholroyd/dps-ruby
|
23
89
|
licenses:
|
24
90
|
- MIT
|
25
|
-
metadata:
|
91
|
+
metadata:
|
92
|
+
allowed_push_host: https://rubygems.org
|
26
93
|
post_install_message:
|
27
94
|
rdoc_options: []
|
28
95
|
require_paths:
|