redirect-uri 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +34 -0
- data/.rspec +2 -0
- data/.rubocop +3 -0
- data/.rubocop.yml +15 -0
- data/.ruby-version +1 -0
- data/.simplecov +11 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +37 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +104 -0
- data/Rakefile +6 -0
- data/lib/redirect_uri.rb +16 -0
- data/lib/redirect_uri/client.rb +21 -0
- data/lib/redirect_uri/discover.rb +63 -0
- data/lib/redirect_uri/error.rb +13 -0
- data/lib/redirect_uri/response.rb +27 -0
- data/lib/redirect_uri/version.rb +3 -0
- data/redirect-uri.gemspec +36 -0
- metadata +238 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 778b09eeb561e789796765815c13da77454903d2
|
4
|
+
data.tar.gz: 2d2bb96ffd0667dbba0f8ae9d14290bb067683f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0569c21515012e72baaf7f223ace294038beedb637e6d3e404dd98e3413a1af8c1c41ebe7510a8418b5c9af2c9d41035234ed1e19c66f8ec390af841fbd396ca'
|
7
|
+
data.tar.gz: ecc1d843779a6d4f352ee6c4603ffecf0945022ef43a99c998c4758921f3a8efd18c267b83bc41caf35d64f302f4d47ff6b0bc26a74c56bcb5f15c6d5b5093bc
|
data/.editorconfig
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
2
|
+
root = true
|
3
|
+
|
4
|
+
[*]
|
5
|
+
charset = utf-8
|
6
|
+
end_of_line = lf
|
7
|
+
insert_final_newline = true
|
8
|
+
indent_size = 2
|
9
|
+
indent_style = space
|
10
|
+
trim_trailing_whitespace = true
|
11
|
+
|
12
|
+
[*.md]
|
13
|
+
indent_size = 4
|
14
|
+
indent_style = tab
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Documentation cache and generated files:
|
17
|
+
/.yardoc/
|
18
|
+
/_yardoc/
|
19
|
+
/doc/
|
20
|
+
/rdoc/
|
21
|
+
|
22
|
+
# Environment normalization:
|
23
|
+
/.bundle/
|
24
|
+
/vendor/bundle
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
data/.rubocop
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.4
|
data/.simplecov
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'simplecov-console'
|
2
|
+
|
3
|
+
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
4
|
+
|
5
|
+
if RSpec.configuration.files_to_run.length > 1
|
6
|
+
formatters << SimpleCov::Formatter::Console
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.start do
|
10
|
+
formatter SimpleCov::Formatter::MultiFormatter.new(formatters)
|
11
|
+
end
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.4.4
|
4
|
+
- 2.5.3
|
5
|
+
cache:
|
6
|
+
- bundler
|
7
|
+
before_install:
|
8
|
+
- gem install bundler
|
9
|
+
before_script:
|
10
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
11
|
+
- chmod +x ./cc-test-reporter
|
12
|
+
- ./cc-test-reporter before-build
|
13
|
+
script:
|
14
|
+
- bundle exec rubocop
|
15
|
+
- bundle exec rake
|
16
|
+
after_script:
|
17
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
18
|
+
notifications:
|
19
|
+
email: false
|
20
|
+
slack:
|
21
|
+
rooms:
|
22
|
+
secure: Qs0XoSMT2nFO6KW4ex3Ur1aDlb6CBWBL5J2TClwK00xfcdAFPEqZbD1PKxPiZ4qqBvEGD9r4UvWzsTOPcPIC1c0pwTQSgDe7R2rgWfVeCCLZutD6DgdePqQ2KfC2IlUOFujl5FoxeIJO8EN/5IAvoqEeRK90MNOtziNY8lYB2aHqboVEAQlPH2bMEsPQTZVQ7WkCZqN5UMQTtWYiLa6rI6FHiw0UKLjQLKNO8KS4Va+wgKsIqEDUe1WhpaaY0K+VOz9/HLq6j4Xo7YwYVp04Yhwd2tvX7Te6a6S1qkSNCBWx7G0556eH28H3hoJnirxcXa4QIdt7qiPIJhzTF3JzQv+kc0MK/+HoiuxSBjuzliZzXdFzXWcuOOwzOxA+JNsTDgRSc2iFD6scEz2+BaXrjb3HublkMSGjiIQ03QVpAfe551I1Z4toF7iJd1k9UUkNxJY8BDkuJ22ZPt8TiUvY6WYGkxZ/MBvu83rqbiK3CytfrEk3GPv1tjCXkiTl57Dtqepyj4JNIv020Rhx2/E0ibIdVsWoKet16MBon+JBYt+XRDV/n2z3Xsu66jn7BW2gnxhRzixbXQsIm8vDNnJNIymizrLmsUKP/0BLc18h9O4ETIGdrv5mqU/UQLTVyT98q42mPFTsblQprPO5lQucCd23o6tAtn8CiXOlqFajb2E=
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Contributing to redirect-uri-ruby
|
2
|
+
|
3
|
+
There are a couple ways you can help improve redirect-uri-ruby:
|
4
|
+
|
5
|
+
1. Fix an existing [issue][issues] and submit a [pull request][pulls].
|
6
|
+
1. Review open [pull requests][pulls].
|
7
|
+
1. Report a new [issue][issues]. _Only do this after you've made sure the behavior or problem you're observing isn't already documented in an open issue._
|
8
|
+
|
9
|
+
## Getting Started
|
10
|
+
|
11
|
+
redirect-uri-ruby is developed using Ruby 2.4.4 and is additionally tested against Ruby 2.5.3 using [Travis CI](https://travis-ci.com/jgarber623/redirect-uri-ruby).
|
12
|
+
|
13
|
+
Before making changes to redirect-uri-ruby, you'll want to install Ruby 2.4.4. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.4.4 using your method of choice, install the project's gems by running:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## Making Changes
|
20
|
+
|
21
|
+
1. Fork and clone the project's repo.
|
22
|
+
1. Install development dependencies as outlined above.
|
23
|
+
1. Create a feature branch for the code changes you're looking to make: `git checkout -b my-new-feature`.
|
24
|
+
1. _Write some code!_
|
25
|
+
1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `bundle exec rspec`.
|
26
|
+
1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`. _(See [this excellent article](https://chris.beams.io/posts/git-commit/) for tips on writing useful Git commit messages.)_
|
27
|
+
1. Push the branch to your fork: `git push -u origin my-new-feature`.
|
28
|
+
1. Create a new [pull request][pulls] and we'll review your changes.
|
29
|
+
|
30
|
+
## Code Style
|
31
|
+
|
32
|
+
Code formatting conventions are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org) syntax. There are [plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. We recommended you install the EditorConfig plugin for your editor of choice.
|
33
|
+
|
34
|
+
Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier.
|
35
|
+
|
36
|
+
[issues]: https://github.com/jgarber623/redirect-uri-ruby/issues
|
37
|
+
[pulls]: https://github.com/jgarber623/redirect-uri-ruby/pulls
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jason Garber
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# redirect-uri-ruby
|
2
|
+
|
3
|
+
**A Ruby gem for discovering a URL’s registered callback URLs for use with [Micropub](https://indieweb.org/Micropub) and [IndieAuth](https://indieweb.org/IndieAuth) clients.**
|
4
|
+
|
5
|
+
[![Gem](https://img.shields.io/gem/v/redirect-uri.svg?style=for-the-badge)](https://rubygems.org/gems/redirect-uri)
|
6
|
+
[![Downloads](https://img.shields.io/gem/dt/redirect-uri.svg?style=for-the-badge)](https://rubygems.org/gems/redirect-uri)
|
7
|
+
[![Build](https://img.shields.io/travis/com/jgarber623/redirect-uri-ruby/master.svg?style=for-the-badge)](https://travis-ci.com/jgarber623/redirect-uri-ruby)
|
8
|
+
[![Dependencies](https://img.shields.io/depfu/jgarber623/redirect-uri-ruby.svg?style=for-the-badge)](https://depfu.com/github/jgarber623/redirect-uri-ruby)
|
9
|
+
[![Maintainability](https://img.shields.io/codeclimate/maintainability/jgarber623/redirect-uri-ruby.svg?style=for-the-badge)](https://codeclimate.com/github/jgarber623/redirect-uri-ruby)
|
10
|
+
[![Coverage](https://img.shields.io/codeclimate/c/jgarber623/redirect-uri-ruby.svg?style=for-the-badge)](https://codeclimate.com/github/jgarber623/redirect-uri-ruby/code)
|
11
|
+
|
12
|
+
## Key Features
|
13
|
+
|
14
|
+
- Implements [Section 4.2.2](https://www.w3.org/TR/indieauth/#redirect-url) of [the W3C's IndieAuth Working Group Note](https://www.w3.org/TR/indieauth/).
|
15
|
+
- Supports Ruby 2.4 and newer.
|
16
|
+
|
17
|
+
## Getting Started
|
18
|
+
|
19
|
+
Before installing and using redirect-uri-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.4 (or newer) installed. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm).
|
20
|
+
|
21
|
+
redirect-uri-ruby is developed using Ruby 2.4.4 and is additionally tested against Ruby 2.5.3 using [Travis CI](https://travis-ci.com/jgarber623/redirect-uri-ruby).
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
If you're using [Bundler](https://bundler.io), add redirect-uri-ruby to your project's `Gemfile`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
source 'https://rubygems.org'
|
29
|
+
|
30
|
+
gem 'redirect-uri'
|
31
|
+
```
|
32
|
+
|
33
|
+
…and hop over to your command prompt and run…
|
34
|
+
|
35
|
+
```sh
|
36
|
+
$ bundle install
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### Basic Usage
|
42
|
+
|
43
|
+
With redirect-uri-ruby added to your project's `Gemfile` and installed, you may discover a URL's registered callback URLs by doing:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
require 'redirect-uri'
|
47
|
+
|
48
|
+
endpoints = RedirectUri.discover('https://sixtwothree.org')
|
49
|
+
|
50
|
+
puts endpoints # returns Array: ['https://sixtwothree.org/auth']
|
51
|
+
```
|
52
|
+
|
53
|
+
This example will search `https://sixtwothree.org` for valid callback URLs using the same rules described in [the W3C's IndieAuth Working Group Note](https://www.w3.org/TR/indieauth/#redirect-url). In this case, the program returns an array: `['https://sixtwothree.org/auth']`.
|
54
|
+
|
55
|
+
If no endpoints are discovered at the provided URL, the program will return an empty array:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
require 'redirect-uri'
|
59
|
+
|
60
|
+
endpoints = RedirectUri.discover('https://example.com')
|
61
|
+
|
62
|
+
puts endpoints # returns Array: []
|
63
|
+
```
|
64
|
+
|
65
|
+
### Advanced Usage
|
66
|
+
|
67
|
+
Should the need arise, you may work directly with the `RedirectUri::Client` class:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'redirect-uri'
|
71
|
+
|
72
|
+
client = RedirectUri::Client.new('https://sixtwothree.org')
|
73
|
+
|
74
|
+
puts client.response # returns HTTP::Response
|
75
|
+
puts client.endpoints # returns Array: ['https://sixtwothree.org/auth']
|
76
|
+
```
|
77
|
+
|
78
|
+
### Exception Handling
|
79
|
+
|
80
|
+
There are several exceptions that may be raised by redirect-uri-ruby's underlying dependencies. These errors are raised as subclasses of `RedirectUri::Error` (which itself is a subclass of `StandardError`).
|
81
|
+
|
82
|
+
From [jgarber623/absolutely](https://github.com/jgarber623/absolutely) and [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
|
83
|
+
|
84
|
+
- `RedirectUri::InvalidURIError`
|
85
|
+
|
86
|
+
From [httprb/http](https://github.com/httprb/http):
|
87
|
+
|
88
|
+
- `RedirectUri::ConnectionError`
|
89
|
+
- `RedirectUri::TimeoutError`
|
90
|
+
- `RedirectUri::TooManyRedirectsError`
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Interested in helping improve redirect-uri-ruby? Awesome! Your help is greatly appreciated. See [CONTRIBUTING.md](https://github.com/jgarber623/redirect-uri-ruby/blob/master/CONTRIBUTING.md) for details.
|
95
|
+
|
96
|
+
## Acknowledgments
|
97
|
+
|
98
|
+
redirect-uri-ruby wouldn't exist without Micropub, IndieAuth, and the hard work put in by everyone involved in the [IndieWeb](https://indieweb.org) movement.
|
99
|
+
|
100
|
+
redirect-uri-ruby is written and maintained by [Jason Garber](https://sixtwothree.org).
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
redirect-uri-ruby is freely available under the [MIT License](https://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.
|
data/Rakefile
ADDED
data/lib/redirect_uri.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'absolutely'
|
2
|
+
require 'addressable/uri'
|
3
|
+
require 'http'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
require 'redirect_uri/version'
|
7
|
+
require 'redirect_uri/error'
|
8
|
+
require 'redirect_uri/client'
|
9
|
+
require 'redirect_uri/discover'
|
10
|
+
require 'redirect_uri/response'
|
11
|
+
|
12
|
+
module RedirectUri
|
13
|
+
def self.discover(url)
|
14
|
+
Client.new(url).endpoints
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RedirectUri
|
2
|
+
class Client
|
3
|
+
def initialize(url)
|
4
|
+
raise ArgumentError, "url must be a String (given #{url.class.name})" unless url.is_a?(String)
|
5
|
+
|
6
|
+
@uri = Addressable::URI.parse(url)
|
7
|
+
|
8
|
+
raise ArgumentError, 'url must be an absolute URI (e.g. https://example.com)' unless @uri.absolute?
|
9
|
+
rescue Addressable::URI::InvalidURIError => error
|
10
|
+
raise InvalidURIError, error
|
11
|
+
end
|
12
|
+
|
13
|
+
def endpoints
|
14
|
+
@endpoints ||= Discover.new(response).endpoints
|
15
|
+
end
|
16
|
+
|
17
|
+
def response
|
18
|
+
@response ||= Response.new(@uri).response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module RedirectUri
|
2
|
+
class Discover
|
3
|
+
# Ultra-orthodox pattern matching allowed values in HTTP Link header `rel` parameter
|
4
|
+
# https://tools.ietf.org/html/rfc8288#section-3.3
|
5
|
+
REGEXP_REG_REL_TYPE_PATTERN = '[a-z\d][a-z\d\-\.]*'.freeze
|
6
|
+
|
7
|
+
# Liberal pattern matching a string of text between angle brackets
|
8
|
+
# https://tools.ietf.org/html/rfc5988#section-5.1
|
9
|
+
REGEXP_TARGET_URI_PATTERN = /^<(.*)>;/.freeze
|
10
|
+
|
11
|
+
# Ultra-orthodox pattern matching HTTP Link header `rel` parameter including an `redirect_uri` value
|
12
|
+
# https://www.w3.org/TR/indieauth/#x4-discovery
|
13
|
+
REGEXP_REDIRECT_URI_REL_PATTERN = /(?:;|\s)rel="?(?:#{REGEXP_REG_REL_TYPE_PATTERN}+\s)?redirect_uri(?:\s#{REGEXP_REG_REL_TYPE_PATTERN})?"?/.freeze
|
14
|
+
|
15
|
+
def initialize(response)
|
16
|
+
raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response)
|
17
|
+
|
18
|
+
@response = response
|
19
|
+
end
|
20
|
+
|
21
|
+
def endpoints
|
22
|
+
@endpoints ||= endpoints_from_http_request.map { |endpoint| Absolutely.to_absolute_uri(base: @response.uri.to_s, relative: endpoint) }.uniq.sort
|
23
|
+
rescue Absolutely::InvalidURIError => error
|
24
|
+
raise InvalidURIError, error
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def endpoints_from_body
|
30
|
+
return unless @response.mime_type == 'text/html'
|
31
|
+
|
32
|
+
doc = Nokogiri::HTML(@response.body.to_s)
|
33
|
+
|
34
|
+
# Search response body for all `link` elements with valid `rel` attribute
|
35
|
+
link_elements = doc.css('link[rel~="redirect_uri"][href]')
|
36
|
+
|
37
|
+
link_elements.map { |link_element| link_element['href'] }
|
38
|
+
end
|
39
|
+
|
40
|
+
def endpoints_from_headers
|
41
|
+
link_headers = @response.headers.get('link')
|
42
|
+
|
43
|
+
return unless link_headers
|
44
|
+
|
45
|
+
# Split Link headers with multiple values, flatten the resulting array, and strip whitespace
|
46
|
+
link_headers = link_headers.map { |header| header.split(',') }.flatten.map(&:strip)
|
47
|
+
|
48
|
+
redirect_uri_headers = link_headers.find_all { |header| header.match?(REGEXP_REDIRECT_URI_REL_PATTERN) }
|
49
|
+
|
50
|
+
return unless redirect_uri_headers.any?
|
51
|
+
|
52
|
+
redirect_uri_headers.map do |header|
|
53
|
+
endpoint_match_data = header.match(REGEXP_TARGET_URI_PATTERN)
|
54
|
+
|
55
|
+
endpoint_match_data[1] if endpoint_match_data
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def endpoints_from_http_request
|
60
|
+
@endpoints_from_http_request ||= [endpoints_from_headers, endpoints_from_body].flatten.compact
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RedirectUri
|
2
|
+
class Error < StandardError; end
|
3
|
+
|
4
|
+
class ArgumentError < Error; end
|
5
|
+
|
6
|
+
class ConnectionError < Error; end
|
7
|
+
|
8
|
+
class InvalidURIError < Error; end
|
9
|
+
|
10
|
+
class TimeoutError < Error; end
|
11
|
+
|
12
|
+
class TooManyRedirectsError < Error; end
|
13
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RedirectUri
|
2
|
+
class Response
|
3
|
+
HTTP_HEADERS_OPTS = {
|
4
|
+
accept: '*/*',
|
5
|
+
user_agent: 'Redirect URI Discovery (https://rubygems.org/gems/redirect-uri)'
|
6
|
+
}.freeze
|
7
|
+
|
8
|
+
def initialize(uri)
|
9
|
+
raise ArgumentError, "uri must be an Addressable::URI (given #{uri.class.name})" unless uri.is_a?(Addressable::URI)
|
10
|
+
|
11
|
+
@uri = uri
|
12
|
+
end
|
13
|
+
|
14
|
+
def response
|
15
|
+
@response ||= HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout(
|
16
|
+
connect: 10,
|
17
|
+
read: 10
|
18
|
+
).get(@uri)
|
19
|
+
rescue HTTP::ConnectionError => error
|
20
|
+
raise ConnectionError, error
|
21
|
+
rescue HTTP::TimeoutError => error
|
22
|
+
raise TimeoutError, error
|
23
|
+
rescue HTTP::Redirector::TooManyRedirectsError => error
|
24
|
+
raise TooManyRedirectsError, error
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'redirect_uri/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.required_ruby_version = ['>= 2.4', '< 2.6']
|
8
|
+
|
9
|
+
spec.name = 'redirect-uri'
|
10
|
+
spec.version = RedirectUri::VERSION
|
11
|
+
spec.authors = ['Jason Garber']
|
12
|
+
spec.email = ['jason@sixtwothree.org']
|
13
|
+
|
14
|
+
spec.summary = 'Discover a URL’s registered callback URLs for use with Micropub and IndieAuth clients.'
|
15
|
+
spec.description = spec.summary
|
16
|
+
spec.homepage = 'https://github.com/jgarber623/redirect-uri-ruby'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|spec)/}) }
|
20
|
+
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
24
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.60.0'
|
27
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.30'
|
28
|
+
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
29
|
+
spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
|
30
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'absolutely', '~> 1.1'
|
33
|
+
spec.add_runtime_dependency 'addressable', '~> 2.5'
|
34
|
+
spec.add_runtime_dependency 'http', '~> 4.0'
|
35
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.8'
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,238 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redirect-uri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Garber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.60.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.60.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.30'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.30'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.16.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.16.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov-console
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.4.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.4.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: absolutely
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.1'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: addressable
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.5'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '2.5'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: http
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '4.0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '4.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: nokogiri
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.8'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.8'
|
181
|
+
description: Discover a URL’s registered callback URLs for use with Micropub and IndieAuth
|
182
|
+
clients.
|
183
|
+
email:
|
184
|
+
- jason@sixtwothree.org
|
185
|
+
executables: []
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files: []
|
188
|
+
files:
|
189
|
+
- ".editorconfig"
|
190
|
+
- ".gitignore"
|
191
|
+
- ".rspec"
|
192
|
+
- ".rubocop"
|
193
|
+
- ".rubocop.yml"
|
194
|
+
- ".ruby-version"
|
195
|
+
- ".simplecov"
|
196
|
+
- ".travis.yml"
|
197
|
+
- CHANGELOG.md
|
198
|
+
- CONTRIBUTING.md
|
199
|
+
- Gemfile
|
200
|
+
- LICENSE
|
201
|
+
- README.md
|
202
|
+
- Rakefile
|
203
|
+
- lib/redirect_uri.rb
|
204
|
+
- lib/redirect_uri/client.rb
|
205
|
+
- lib/redirect_uri/discover.rb
|
206
|
+
- lib/redirect_uri/error.rb
|
207
|
+
- lib/redirect_uri/response.rb
|
208
|
+
- lib/redirect_uri/version.rb
|
209
|
+
- redirect-uri.gemspec
|
210
|
+
homepage: https://github.com/jgarber623/redirect-uri-ruby
|
211
|
+
licenses:
|
212
|
+
- MIT
|
213
|
+
metadata: {}
|
214
|
+
post_install_message:
|
215
|
+
rdoc_options: []
|
216
|
+
require_paths:
|
217
|
+
- lib
|
218
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '2.4'
|
223
|
+
- - "<"
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '2.6'
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
requirements: []
|
232
|
+
rubyforge_project:
|
233
|
+
rubygems_version: 2.6.14.1
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
236
|
+
summary: Discover a URL’s registered callback URLs for use with Micropub and IndieAuth
|
237
|
+
clients.
|
238
|
+
test_files: []
|