web_package 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 39e5ffddf3e4348860d6c29e6aec54631d247c7a
4
- data.tar.gz: c1b44063c3c6861c20875709cee60e0f2fa63277
2
+ SHA256:
3
+ metadata.gz: 1ed6ee8b93f831a07db19a0d5417a95016249684b80e4bf4851734eafa981767
4
+ data.tar.gz: 56d44e9da44fccf0ec9930b5d3c413cd40c69804b8ece3f623efe708ce648ba6
5
5
  SHA512:
6
- metadata.gz: b962ea793e579733474c15fe721f8043c9ecd369bc66c99eace2b7a46ac65fd31088812a366a0cd71bdca31c2a33bb52e905555907aca5f58c615d9451778b22
7
- data.tar.gz: 0f437161ae65822e028d1d9177f096007de4935dc236b0cdd56096dbf4f268e3fef68d89117e78b993541ff04f2c8b2fc34dfecce10e150f53943de61db036a6
6
+ metadata.gz: 6c4450c2b1516454768e88c3822a11c6a0ebbb586e23137d63057b567a9a848da0b9d2a23d37094ac6059b73cbd308d373f3522f892e8f2c139b9d695adbaa31
7
+ data.tar.gz: b18b853f8c241626688110dd57757b7dba2b1f3b762dfd0f17c54c530782429bebea6c1b737c029d9950110352c2431ba1ba1f130a9b4a4343fa6c7459de6879
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Web Package
2
- Ruby implementation of Signed HTTP Exchange format, allowing a browser to trust that a HTTP request-response pair was generated by the origin it claims.
2
+ Not to be confused with [webpack](https://webpack.js.org), this repository holds Ruby implementation of Signed HTTP Exchange format, allowing a browser to trust that a HTTP request-response pair was generated by the origin it claims. For details please refer to the [full list of use cases and resulting requirements](https://wicg.github.io/webpackage/draft-yasskin-webpackage-use-cases.html) ([IETF draft](https://tools.ietf.org/html/draft-yasskin-webpackage-use-cases)).
3
3
 
4
4
  ## Ever thought of saving the Internet on a flash?
5
5
 
6
6
  Easily-peasily.
7
7
 
8
- Let's sign a pair of request/response and serve the bundle as `application/signed-exchange` - Chromium browsers understand what it means and unpack them smoothly.
8
+ Let's sign a pair of request/response, store it somewhere out and serve the bundle as `application/signed-exchange`. Chromium browsers understand what such responses mean and unpack them smoothly making it look as if a page is served directly from originating servers.
9
9
 
10
- For that we need a certificate with a special "CanSignHttpExchanges" extension, but for the purpose of this guide we will use just a self-signed one. Please refer [here](https://github.com/WICG/webpackage/tree/master/go/signedexchange#creating-our-first-signed-exchange) to create such.
10
+ For that we need a certificate with a special "CanSignHttpExchanges" extension. However below we will use just a self-signed one for simplicity. Please refer [here](https://github.com/WICG/webpackage/tree/master/go/signedexchange#creating-our-first-signed-exchange) to create such.
11
11
 
12
12
  Also we need an `https` cdn serving static certificate in `application/cert-chain+cbor` format. We can use `gen-certurl` tool from [here](https://github.com/WICG/webpackage/tree/master/go/signedexchange#creating-our-first-signed-exchange) to convert PEM certificate into this format, so we could than serve it from a cdn.
13
13
 
@@ -18,7 +18,7 @@ E.g.
18
18
  ```ruby
19
19
  # variables can be set all at once:
20
20
  WebPackage::Settings.merge! expires_in: ->(uri) { uri.path.start_with?('/news') ? 7.days : 1.day },
21
- url_filter: ->(uri) { uri.host.start_with?('amp') },
21
+ filter: ->(env) { env['HTTP_HOST'].start_with?('amp') },
22
22
  sub_extension: '.html'
23
23
  # or individually via dot-methods:
24
24
  WebPackage::Settings.cert_url = 'https://my.cdn.com/cert.cbor'
@@ -39,10 +39,10 @@ A `String` or `nil`, representing an extension to use for proxying `.sxg` reques
39
39
 
40
40
  Default value is `nil`, which means that `.sxg` extension is just removed from the path for the rest of Rack middlewares.
41
41
 
42
- #### url_filter
43
- A `Proc`, accepting a single argument of original URI and returning boolean value. The filter determines for which paths `.sxg` formatted routes should be added.
42
+ #### filter
43
+ A `Proc`, accepting a single argument of environment and returning boolean value. The filter determines for which requests `.sxg` formatted routes should be added.
44
44
 
45
- Default value is `->(uri) { true }`, which means that all known paths are permitted and hence can be processed in SXG format using `.sxg` extension.
45
+ Default value is `->(env) { true }`, which means that all requests are permitted and hence can be processed in SXG format using `.sxg` extension.
46
46
 
47
47
  #### cert_url, cert_path, priv_path
48
48
 
@@ -9,7 +9,7 @@ module WebPackage
9
9
  end
10
10
 
11
11
  def call(env)
12
- Settings.url_filter[uri(env)] ? process(env) : @app.call(env)
12
+ Settings.filter[env] ? process(env) : @app.call(env)
13
13
  end
14
14
 
15
15
  private
@@ -1,5 +1,5 @@
1
1
  module WebPackage
2
- OPTIONS = %i[headers expires_in sub_extension url_filter cert_url cert_path priv_path].freeze
2
+ OPTIONS = %i[headers expires_in sub_extension filter cert_url cert_path priv_path].freeze
3
3
  ENV_KEYS = Set.new(%w[SXG_CERT_URL SXG_CERT_PATH SXG_PRIV_PATH]).freeze
4
4
  DEFAULTS = {
5
5
  headers: { 'Content-Type' => 'application/signed-exchange;v=b3',
@@ -7,7 +7,7 @@ module WebPackage
7
7
  'X-Content-Type-Options' => 'nosniff' },
8
8
  expires_in: 60 * 60 * 24 * 7, # 7.days
9
9
  sub_extension: nil, # proxy as default format (html)
10
- url_filter: ->(_uri) { true } # all paths are permitted
10
+ filter: ->(_env) { true } # all requests are permitted
11
11
  }.freeze
12
12
 
13
13
  Settings = ConfigurationHash.new(OPTIONS) do |config, key|
@@ -1,3 +1,3 @@
1
1
  module WebPackage
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Afanasyev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-05-16 00:00:00.000000000 Z
12
+ date: 2019-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -69,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubyforge_project:
73
- rubygems_version: 2.6.13
72
+ rubygems_version: 3.0.3
74
73
  signing_key:
75
74
  specification_version: 4
76
75
  summary: Packaging Websites with Ruby.