web_package 0.2.0 → 0.3.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 +5 -5
- data/README.md +7 -7
- data/lib/web_package/middleware.rb +1 -1
- data/lib/web_package/settings.rb +2 -2
- data/lib/web_package/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1ed6ee8b93f831a07db19a0d5417a95016249684b80e4bf4851734eafa981767
|
4
|
+
data.tar.gz: 56d44e9da44fccf0ec9930b5d3c413cd40c69804b8ece3f623efe708ce648ba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
-
|
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
|
-
####
|
43
|
-
A `Proc`, accepting a single argument of
|
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 `->(
|
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
|
|
data/lib/web_package/settings.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module WebPackage
|
2
|
-
OPTIONS = %i[headers expires_in sub_extension
|
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
|
-
|
10
|
+
filter: ->(_env) { true } # all requests are permitted
|
11
11
|
}.freeze
|
12
12
|
|
13
13
|
Settings = ConfigurationHash.new(OPTIONS) do |config, key|
|
data/lib/web_package/version.rb
CHANGED
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.
|
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-
|
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
|
-
|
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.
|