flyyer 2.0.0 → 2.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/console +3 -3
- data/flyyer.gemspec +1 -1
- data/lib/flyyer.rb +44 -12
- data/lib/flyyer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1e464a893bc3a20b7889928cd9ab42e630219f9a0b6949d7cc932c277fe10d9
|
4
|
+
data.tar.gz: d285616617397391d3f4c424980e39a014d662b3de85850ea50d8be8b931cb80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9068e285b85d5c3fd9d06c23e65eead115f629d99a82bd416441d190ea940a4902478381db17ebe2ee07338bb630b6882d9d9fee1f97e41a6dff5a4785a70528
|
7
|
+
data.tar.gz: 7846e196cbd31432133259794763300f21f332d4a9294f35582b7512f69933d0c228b666ce04b35d125f5797ed24502fc5b067c9ed0aa0fa81140f9a32bf8525
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -75,7 +75,7 @@ You'll get the best results like this:
|
|
75
75
|
|
76
76
|
### 4. Create a `rule` for your project
|
77
77
|
|
78
|
-
|
78
|
+
Go to your dashboard [here](https://flyyer.io/dashboard/_/projects/_/manage) and create a rule like the following:
|
79
79
|
|
80
80
|
[](https://flyyer.io/dashboard)
|
81
81
|
|
@@ -93,7 +93,7 @@ Here you have a detailed full example for project `website-com` and path `/path/
|
|
93
93
|
|
94
94
|
```ruby
|
95
95
|
flyyer = Flyyer::Flyyer.create do |f|
|
96
|
-
# [Required] Your project slug, find it in your dashboard https://flyyer.io/dashboard
|
96
|
+
# [Required] Your project slug, find it in your dashboard https://www.flyyer.io/dashboard/_/projects/_/integrate.
|
97
97
|
f.project = 'website-com'
|
98
98
|
# [Recommended] The current path of your website (by default it's `/`).
|
99
99
|
f.path = '/path/to/product'
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'flyyer'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "flyyer"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/flyyer.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
27
|
end
|
28
28
|
spec.bindir = 'exe'
|
data/lib/flyyer.rb
CHANGED
@@ -72,7 +72,7 @@ module Flyyer
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
# Create a https://
|
75
|
+
# Create a https://FLYYER.io string.
|
76
76
|
# If you are on Ruby on Rails please use .html_safe when rendering this string into the HTML
|
77
77
|
def href
|
78
78
|
raise Error.new('Missing "project" property') if @project.nil?
|
@@ -88,20 +88,22 @@ module Flyyer
|
|
88
88
|
end
|
89
89
|
|
90
90
|
class FlyyerRender
|
91
|
-
attr_accessor :version, :tenant, :deck, :template, :extension, :variables, :meta
|
91
|
+
attr_accessor :version, :tenant, :deck, :template, :extension, :variables, :meta, :secret, :strategy
|
92
92
|
|
93
93
|
def self.create(&block)
|
94
94
|
self.new(&block)
|
95
95
|
end
|
96
96
|
|
97
|
-
def initialize(tenant = nil, deck = nil, template = nil, version = nil, extension =
|
97
|
+
def initialize(tenant = nil, deck = nil, template = nil, version = nil, extension = nil, variables = {}, meta = {}, secret = nil, strategy = nil)
|
98
98
|
@tenant = tenant
|
99
99
|
@deck = deck
|
100
100
|
@template = template
|
101
101
|
@version = version
|
102
102
|
@extension = extension
|
103
|
-
@variables = variables
|
103
|
+
@variables = variables || {}
|
104
104
|
@meta = meta
|
105
|
+
@secret = secret
|
106
|
+
@strategy = strategy
|
105
107
|
yield(self) if block_given?
|
106
108
|
end
|
107
109
|
|
@@ -115,16 +117,38 @@ module Flyyer
|
|
115
117
|
end
|
116
118
|
end
|
117
119
|
|
120
|
+
default_v = {__v: @meta[:v].nil? ? Time.now.to_i : @meta[:v]} # This forces crawlers to refresh the image
|
118
121
|
defaults = {
|
119
|
-
__v: @meta[:v].nil? ? Time.now.to_i : @meta[:v], # This forces crawlers to refresh the image
|
120
122
|
__id: @meta[:id] || nil,
|
121
123
|
_w: @meta[:width] || nil,
|
122
124
|
_h: @meta[:height] || nil,
|
123
125
|
_res: @meta[:resolution] || nil,
|
124
|
-
_ua: @meta[:agent] || nil
|
126
|
+
_ua: @meta[:agent] || nil,
|
127
|
+
}
|
128
|
+
jwt_defaults = {
|
129
|
+
i: @meta[:id] || nil,
|
130
|
+
w: @meta[:width] || nil,
|
131
|
+
h: @meta[:height] || nil,
|
132
|
+
r: @meta[:resolution] || nil,
|
133
|
+
u: @meta[:agent] || nil,
|
134
|
+
var: @variables,
|
125
135
|
}
|
126
|
-
|
127
|
-
|
136
|
+
if @strategy && @secret
|
137
|
+
key = @secret
|
138
|
+
if @strategy.downcase == "hmac"
|
139
|
+
default_query = FlyyerHash.new(defaults).to_query
|
140
|
+
data = [@deck, @template, @version || "", @extension || "", default_query].join("#")
|
141
|
+
__hmac = OpenSSL::HMAC.hexdigest('SHA256', key, data)[0..15]
|
142
|
+
return FlyyerHash.new([defaults, default_v, @variables, {__hmac: __hmac}].inject(&:merge)).to_query
|
143
|
+
end
|
144
|
+
if @strategy.downcase == "jwt"
|
145
|
+
payload = [{ d: @deck, t: @template, v: @version, e: @extension }, jwt_defaults].inject(&:merge)
|
146
|
+
__jwt = JWT.encode(payload, key, 'HS256')
|
147
|
+
return FlyyerHash.new({ __jwt: __jwt }.merge(default_v)).to_query
|
148
|
+
end
|
149
|
+
else
|
150
|
+
return FlyyerHash.new([default_v, defaults, @variables].inject(&:merge)).to_query
|
151
|
+
end
|
128
152
|
end
|
129
153
|
|
130
154
|
# Create a https://flyyer.io string.
|
@@ -133,12 +157,20 @@ module Flyyer
|
|
133
157
|
raise Error.new('Missing "tenant" property') if @tenant.nil?
|
134
158
|
raise Error.new('Missing "deck" property') if @deck.nil?
|
135
159
|
raise Error.new('Missing "template" property') if @template.nil?
|
160
|
+
raise Error.new('Got `secret` but missing `strategy`. Valid options are `HMAC` or `JWT`.') if @secret && @strategy.nil?
|
161
|
+
raise Error.new('Got `strategy` but missing `secret`. You can find it in your project in Advanced settings.') if @strategy && @secret.nil?
|
162
|
+
raise Error.new('Invalid signing `strategy`. Valid options are `HMAC` or `JWT`.') if @strategy && @strategy.downcase != "jwt" && @strategy.downcase != "hmac"
|
136
163
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
"
|
164
|
+
base_href = "https://cdn.flyyer.io/render/v2/#{@tenant}"
|
165
|
+
|
166
|
+
if @strategy and @strategy.downcase == "jwt"
|
167
|
+
return "#{base_href}?#{self.querystring}"
|
141
168
|
end
|
169
|
+
|
170
|
+
final_href = "#{base_href}/#{@deck}/#{@template}"
|
171
|
+
final_href << ".#{@version}" if @version
|
172
|
+
final_href << ".#{@extension}" if @extension
|
173
|
+
final_href << "?#{self.querystring}"
|
142
174
|
end
|
143
175
|
end
|
144
176
|
|
data/lib/flyyer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flyyer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio López Juri
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: FLYYER.io helper classes and methods
|
15
15
|
email:
|