clerk-rails 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a7fdb8c57b025d5d0f123c73a89229562f25707d4db95131607f8d2a829001a
4
- data.tar.gz: 3d9d1f1bfc333e8097c94e730ba6abd7ed94b3fc697ce9f616c0bc40a017d7cf
3
+ metadata.gz: 3aa49f5e36ccf980e9e08d6e08774bfb2737ca8ebb712d41303dbe6403f01f18
4
+ data.tar.gz: 6e92512d1b887335d9b8cb7cf2cac8741d2a27e23a3898deceee31c8a7b02c90
5
5
  SHA512:
6
- metadata.gz: df4a42eccb6c30f65d354b94141e38c3235879526b4f81ed097d5919487a34d349d1824cbaa8f552af73a9d76fab52ab0a9781f0902ab6a289cbb88a1fb46d26
7
- data.tar.gz: c5c25f85ea49646387a75c23b2b02eb26dad51d205847b2753a89415a5ec963cdebf69ed577b885b067d34ebda5b4dcad9f475dcda0f456be2f3c88ced6db624
6
+ metadata.gz: 47e0a10885a482e4b021f08d59739ddccae6584b786abb6eb36f818a51323f08992b40b3e64908fff960f50fa41a7e1459b5a37e883ddb9dd6a04bc00e147399
7
+ data.tar.gz: 60bd9cb0ec11614d62961c032ddb6f216940b96814e153af23b922a593a0d9a61bd053a49517c02bcb5ed6fd66740d38d7873eecf3cf5c69877520a4a4963806
@@ -9,6 +9,7 @@ module Clerk
9
9
  Clerk::Account.find_by(id: current_account_id)
10
10
  end
11
11
  rescue => e
12
+ puts e
12
13
  nil
13
14
  end
14
15
  end
@@ -29,19 +30,19 @@ module Clerk
29
30
  end
30
31
 
31
32
  def clerk_sign_out_path
32
- "#{Clerk.config.accounts_url}/sign_out"
33
+ "#{Clerk.accounts_url}/sign_out"
33
34
  end
34
35
 
35
36
  def clerk_sign_in_path
36
- "#{Clerk.config.accounts_url}"
37
+ "#{Clerk.accounts_url}"
37
38
  end
38
39
 
39
40
  def clerk_sign_up_path
40
- "#{Clerk.config.accounts_url}/sign_up"
41
+ "#{Clerk.accounts_url}/sign_up"
41
42
  end
42
43
 
43
44
  def clerk_add_card_path(account_id:, redirect_path:)
44
- "#{Clerk.config.accounts_url}/add_card?account_id=#{account_id}&redirect_path=#{redirect_path}"
45
+ "#{Clerk.accounts_url}/add_card?account_id=#{account_id}&redirect_path=#{redirect_path}"
45
46
  end
46
47
  end
47
48
  end
@@ -15,8 +15,8 @@ module Clerk
15
15
  json[:scope_id] = instance.id
16
16
  end
17
17
 
18
- server_url = "#{ENV['CLERK_ACCOUNTS_URL']}/roles"
19
- HTTP.auth("Bearer #{ENV['CLERK_SECRET_KEY']}").post(server_url, :json => json)
18
+ server_url = "#{Clerk.accounts_url}/roles"
19
+ HTTP.auth("Bearer #{Clerk.key}").post(server_url, :json => json)
20
20
  end
21
21
 
22
22
  def has_role?(role, scope)
@@ -3,13 +3,19 @@ module Clerk
3
3
  self.abstract_class = true
4
4
  establish_connection Clerk.database_connection_url
5
5
  def self.clerk_table_name(table_name)
6
- version = Clerk::VERSION.split(".").map{|x| x.rjust(2, '0')}.join
7
- "client.#{table_name}_#{version}_#{Clerk.config.secret_key}"
6
+ version = Clerk::VERSION.split(".").map.with_index{|x, i| (i==2 ? "00" : x.rjust(2, '0')) }.join
7
+ "client.#{table_name}_#{version}_#{Clerk.key_secret}"
8
8
  end
9
9
 
10
10
  def self.clerk_table_name_nc(table_name)
11
11
  version = Clerk::VERSION.split(".").map{|x| x.rjust(2, '0')}.join
12
- "#{table_name}_#{version}_#{Clerk.config.secret_key}"
13
- end
12
+ "#{table_name}_#{version}_#{Clerk.key_secret}"
13
+ end
14
+
15
+ def self.transaction(options = {}, &block)
16
+ # were overriding all the methods that need transactions
17
+ # these interfere with pgbouncer. just yield the block
18
+ yield
19
+ end
14
20
  end
15
21
  end
@@ -6,9 +6,9 @@ module Clerk
6
6
  belongs_to :account, class_name: "Clerk::Account"
7
7
 
8
8
  def self._insert_record(values)
9
- server_url = "#{ENV['CLERK_ACCOUNTS_URL']}/roles"
9
+ server_url = "#{Clerk.accounts_url}/roles"
10
10
  begin
11
- response = HTTP.auth("Bearer #{ENV['CLERK_SECRET_KEY']}").post(server_url, :json => values)
11
+ response = HTTP.auth("Bearer #{Clerk.key_secret}").post(server_url, :json => values)
12
12
  id = JSON.parse(response.body)["id"]
13
13
  rescue
14
14
  raise Clerk::Errors::ClerkServerError.new("Failed to save the role", self)
@@ -27,9 +27,9 @@ module Clerk
27
27
  raise ActiveRecord::RecordNotFound.new("Must pass an id to update a role", self)
28
28
  end
29
29
 
30
- server_url = "#{ENV['CLERK_ACCOUNTS_URL']}/roles/#{update_id}"
30
+ server_url = "#{Clerk.accounts_url}/roles/#{update_id}"
31
31
  begin
32
- response = HTTP.auth("Bearer #{ENV['CLERK_SECRET_KEY']}").patch(server_url, :json => values.merge!(constraints))
32
+ response = HTTP.auth("Bearer #{Clerk.key_secret}").patch(server_url, :json => values.merge!(constraints))
33
33
  rescue
34
34
  raise Clerk::Errors::ClerkServerError.new("Failed to update the role", self)
35
35
  end
@@ -48,10 +48,10 @@ module Clerk
48
48
  raise ActiveRecord::RecordNotFound.new("Must pass an id to delete a role", self)
49
49
  end
50
50
 
51
- server_url = "#{ENV['CLERK_ACCOUNTS_URL']}/roles/#{delete_id}"
51
+ server_url = "#{Clerk.accounts_url}/roles/#{delete_id}"
52
52
 
53
53
  begin
54
- response = HTTP.auth("Bearer #{ENV['CLERK_SECRET_KEY']}").delete(server_url)
54
+ response = HTTP.auth("Bearer #{Clerk.key_secret}").delete(server_url)
55
55
  rescue
56
56
  raise Clerk::Errors::ClerkServerError.new("Failed to delete the role", self)
57
57
  end
data/lib/clerk-rails.rb CHANGED
@@ -1,30 +1,83 @@
1
1
  require "clerk/engine"
2
+ require "clerk/id"
2
3
 
3
4
  module Clerk
4
5
  class << self
5
6
  attr_reader :config
7
+ attr_reader :api
6
8
 
7
9
  def configure
8
10
  @config = Configuration.new
9
11
  yield config
10
- if Rails.env.development?
12
+ # if Rails.env.development?
11
13
  config.environment = :development
12
14
  config.session_mode = :cookie_session
13
15
  config.cookie_host = nil
14
- else
15
- client = Clerk::Client.first
16
- config.environment = client.environment.to_sym
17
- config.session_mode = client.session_mode.to_sym
18
- config.cookie_host = client.cookie_host
19
- end
16
+ # else
17
+ # config.environment = client.environment.to_sym
18
+ # config.session_mode = client.session_mode.to_sym
19
+ # config.cookie_host = client.cookie_host
20
+ # end
20
21
  end
21
22
 
22
23
  def database_connection_url
23
- @database_connection_url ||= "#{Clerk.config.database_url.dup.insert(11,"#{Clerk.config.secret_key}@")}/clerk?prepared_statements=false"
24
+ @database_connection_url ||= "#{Clerk.config.database_url.dup.insert(11,"#{Clerk.key_secret}@")}/clerk?prepared_statements=false"
25
+ end
26
+
27
+ def api
28
+ @conn ||= Clerk::ApiConnection.new
29
+ end
30
+
31
+ def key
32
+ ENV['CLERK_KEY']
33
+ end
34
+
35
+ def key_secret
36
+ ENV['CLERK_KEY']&.slice(5..-1)
37
+ end
38
+
39
+ def accounts_url
40
+ @accounts_url ||= "https://#{Clerk.config.accounts_host}"
41
+ end
42
+
43
+ def app_url
44
+ @app_url ||= "https://#{Clerk.config.app_host}"
45
+ end
46
+ end
47
+
48
+ class ApiConnection
49
+ def initialize
50
+ @c = Faraday.new(:url => (ENV["CLERK_API_PATH"] || "https://clerk-server-prod-test.herokuapp.com")) do |conn|
51
+ conn.authorization :Bearer, Clerk.key_secret
52
+ conn.headers['Content-Type'] = 'application/json'
53
+ conn.adapter Faraday.default_adapter
54
+ end
55
+ end
56
+
57
+ def post(path, fields, &block)
58
+ Clerk::ApiResponse.new(@c.post(path, fields.to_json, &block))
59
+ end
60
+
61
+ def get(*args, &block)
62
+ Clerk::ApiResponse.new(@c.get(*args, &block))
63
+ end
64
+ end
65
+
66
+ class ApiResponse
67
+ def initialize(faraday_response)
68
+ @res = faraday_response
69
+ end
70
+
71
+ def data
72
+ JSON.parse(@res.body, symbolize_names: true)
73
+ end
74
+
75
+ def method_missing(m, *args, &block)
76
+ @res.send(m, *args, &block)
24
77
  end
25
78
  end
26
79
 
27
80
  class Configuration
28
- attr_accessor :accounts_url, :database_url, :secret_key, :public_key, :environment, :session_mode, :last_account, :cookie_host
81
+ attr_accessor :app_host, :accounts_host, :database_url, :tunnel_key, :environment, :session_mode, :last_account, :cookie_host
29
82
  end
30
83
  end
data/lib/clerk/engine.rb CHANGED
@@ -1,6 +1,37 @@
1
1
  module Clerk
2
2
  class Engine < ::Rails::Engine
3
- initializer "clerk.load_helpers" do |app|
3
+ config.before_configuration do
4
+ if Rails.env.development?
5
+ require 'dotenv'
6
+ Dotenv.load
7
+ end
8
+
9
+ if Clerk.key.nil?
10
+ raise "Clerk is installed but not configured. Add your CLERK_KEY to the application root."
11
+ end
12
+
13
+ begin
14
+ config_data = Clerk.api.get('/api/environment').data
15
+ Clerk.configure do |config|
16
+ config.app_host = config_data[:APP_HOST]
17
+ config.accounts_host = config_data[:ACCOUNTS_HOST]
18
+ config.tunnel_key = config_data[:TUNNEL_KEY]
19
+ config.database_url = config_data[:DATABASE_URL]
20
+ end
21
+ rescue => e
22
+ raise "Clerk could not be loaded. #{config_data}"
23
+ end
24
+
25
+ if defined?(Rails::Server) and Rails.env.development?
26
+ require 'clerk/tunnel'
27
+ if !Clerk::Tunnel.ready?
28
+ Clerk::Tunnel.setup!
29
+ end
30
+ Clerk::Tunnel.start!
31
+ end
32
+ end
33
+
34
+ initializer "clerk.load_helpers" do
4
35
  ::ActionController::Base.send :include, Clerk::ApplicationHelper
5
36
  ::ActiveRecord::Base.class_eval do
6
37
 
@@ -54,7 +85,8 @@ module Clerk
54
85
  source: :account
55
86
  ]
56
87
  end
57
- end
88
+ end
58
89
  end
90
+
59
91
  end
60
92
  end
data/lib/clerk/id.rb ADDED
@@ -0,0 +1,12 @@
1
+ module Clerk
2
+ module ID
3
+ def self.[](prefix)
4
+ Module.new do
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ attribute :id, :string, default: ->{ "#{prefix}_#{KSUID.new}" }
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,297 @@
1
+ module Clerk
2
+ module Tunnel
3
+ def self.data_dir
4
+ Rails.root.join(".clerk")
5
+ end
6
+
7
+ def self.crt_path
8
+ data_dir.join("dev.crt")
9
+ end
10
+
11
+ def self.key_path
12
+ data_dir.join("dev.key")
13
+ end
14
+
15
+ def self.ngrok_path
16
+ data_dir.join("clerk_#{executable_type}")
17
+ end
18
+ def self.ngrok_zip_path
19
+ data_dir.join("clerk_#{executable_type}.zip")
20
+ end
21
+
22
+ def self.acc_path
23
+ data_dir.join("account.key")
24
+ end
25
+
26
+ def self.ready?
27
+ crt_ready? and ngrok_ready?
28
+ end
29
+
30
+ def self.crt_ready?
31
+ File.exist? key_path and File.exist? crt_path
32
+ end
33
+
34
+ def self.ngrok_ready?
35
+ File.exist? ngrok_path
36
+ end
37
+
38
+ def self.setup!
39
+ setup_crt! unless self.crt_ready?
40
+ setup_ngrok! unless self.ngrok_ready?
41
+ puts "=> [Clerk] Setup done."
42
+ end
43
+
44
+ def self.setup_ngrok!
45
+ ngrok_paths = {
46
+ darwin_amd64: "/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip",
47
+ darwin_386: "/c/4VmDzA7iaHb/ngrok-stable-darwin-386.zip",
48
+ windows_amd64: "/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip",
49
+ windows_386: "/c/4VmDzA7iaHb/ngrok-stable-windows-386.zip",
50
+ freebsd_amd64: "/c/4VmDzA7iaHb/ngrok-stable-freebsd-amd64.zip",
51
+ freebsd_386: "/c/4VmDzA7iaHb/ngrok-stable-freebsd-386.zip",
52
+ linux_amd64: "/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip",
53
+ linux_386: "/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip",
54
+ linux_arm: "/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip",
55
+ linux_arm64: "/a/nmkK3DkqZEB/ngrok-2.2.8-linux-arm64.zip",
56
+ }
57
+
58
+ puts "=> [Clerk] Downloading tunnnel executable."
59
+ require 'zip'
60
+ http = Net::HTTP.new("bin.equinox.io", 443)
61
+ http.use_ssl = true
62
+ resp = http.get(ngrok_paths[executable_type])
63
+ open(ngrok_zip_path, "wb") do |file|
64
+ file.write(resp.body)
65
+ end
66
+
67
+ puts "=> [Clerk] Unzipping tunnnel executable."
68
+ Zip::File.open(ngrok_zip_path) do |zipfile|
69
+ zipfile.each do |file|
70
+ if file.name == "ngrok"
71
+ zipfile.extract(file, ngrok_path)
72
+ end
73
+ end
74
+ end
75
+
76
+ File.delete(ngrok_zip_path)
77
+ end
78
+
79
+ def self.setup_crt!
80
+ puts "=> [Clerk] First boot detected. Initializing environment."
81
+ require 'acme-client'
82
+ require 'openssl'
83
+
84
+ Dir.mkdir(data_dir) unless Dir.exist? data_dir
85
+
86
+ puts "=> [Clerk] Authenticating with Let's Encrypt."
87
+ if File.exist? acc_path
88
+ acc_private_key = OpenSSL::PKey::RSA.new(File.read(acc_path))
89
+ client = ::Acme::Client.new(private_key: acc_private_key, directory: 'https://acme-v02.api.letsencrypt.org/directory')
90
+ client.kid #Load existing account
91
+ else
92
+ acc_private_key = OpenSSL::PKey::RSA.new(4096)
93
+
94
+ client = ::Acme::Client.new(private_key: acc_private_key, directory: 'https://acme-v02.api.letsencrypt.org/directory')
95
+
96
+ account = client.new_account(contact: 'mailto:sidot3291@gmail.com', terms_of_service_agreed: true)
97
+
98
+ File.write(acc_path, acc_private_key.to_pem)
99
+ end
100
+
101
+ puts "=> [Clerk] Beginning new certificate order for #{Clerk.config.app_host}."
102
+ order = client.new_order(identifiers: [Clerk.config.app_host])
103
+ challenge = order.authorizations.first.dns
104
+
105
+ puts "=> [Clerk] Completing DNS challenge."
106
+ record_name = "#{challenge.record_name}.#{Clerk.config.app_host.gsub(".clerkdev.com", "")}"
107
+ config_data = Clerk.api.post('/api/acme_challenge', {
108
+ name: record_name,
109
+ type: challenge.record_type,
110
+ content: challenge.record_content
111
+ })
112
+
113
+ puts "=> [Clerk] Waiting for DNS to process. This may take a few minutes."
114
+ confirm_url = URI.parse("https://dns.google.com/resolve?name=#{challenge.record_name}.#{Clerk.config.app_host}&type=TXT")
115
+ while true
116
+ confirm_check = JSON.parse(Net::HTTP.get(confirm_url))
117
+ break if confirm_check.dig("Answer", 0, "data")=="\"#{challenge.record_content}\""
118
+ sleep(5)
119
+ puts "=> [Clerk] Checking processing status..."
120
+ end
121
+
122
+ sleep(5) # Sometimes google returns correctly before. Add an extra 10 seconds.
123
+ puts "=> [Clerk] Checking processing status..."
124
+ sleep(5)
125
+
126
+ puts "=> [Clerk] Validating DNS challenge."
127
+ challenge.request_validation
128
+
129
+ while challenge.status == 'pending'
130
+ sleep(2)
131
+ puts "=> [Clerk] Checking validation status..."
132
+ challenge.reload
133
+ end
134
+
135
+ puts "=> [Clerk] Validation complete. Requesting certificate."
136
+ crt_private_key = OpenSSL::PKey::RSA.new(4096)
137
+ File.write(key_path, crt_private_key.to_pem)
138
+
139
+ csr = Acme::Client::CertificateRequest.new(private_key: crt_private_key, subject: { common_name: Clerk.config.app_host })
140
+ order.finalize(csr: csr)
141
+ sleep(1) while order.status == 'processing'
142
+
143
+ File.write(crt_path, order.certificate)
144
+ puts "=> [Clerk] Certificate created."
145
+ end
146
+
147
+ def self.start!
148
+ self.patch_rack_requests
149
+
150
+ server = ObjectSpace.each_object(Rails::Server).first
151
+ server_options = server.instance_variable_get(:@options).dup
152
+ if !server.send(:use_puma?)
153
+ raise "Sorry, Clerk currently only supports Rails using the Puma server."
154
+ elsif server_options[:user_supplied_options].include? :Host
155
+ raise "Sorry, Clerk cannot boot with a custom host: #{server_options[:Host]}"
156
+ else
157
+ server_options[:user_supplied_options] << :Host
158
+ server_options[:Host] = "127.0.0.1"
159
+ # server_options[:Host] = "ssl://127.0.0.1:#{server_options[:Port]}?key=.clerk/dev.key&cert=.clerk/dev.crt"
160
+ server.instance_variable_set(:@options, server_options)
161
+ end
162
+
163
+ require 'ngrok/tunnel'
164
+ self.patch_ngrok_gem
165
+ puts "=> Booting https://#{Clerk.config.app_host} with Clerk"
166
+ options = {
167
+ addr: server_options[:Port],
168
+ authtoken: Clerk.config.tunnel_key,
169
+ hostname: Clerk.config.app_host,
170
+ region: "us",
171
+ crt: Rails.root.join(".clerk/dev.crt"),
172
+ key: Rails.root.join(".clerk/dev.key")
173
+ }
174
+ Ngrok::Tunnel.start(options)
175
+ end
176
+
177
+ private
178
+
179
+ def self.executable_type
180
+ @@executable_type ||= begin
181
+ platform = begin
182
+ case RbConfig::CONFIG['host_os'].downcase
183
+ when /linux/
184
+ "linux"
185
+ when /darwin/
186
+ "darwin"
187
+ when /bsd/
188
+ "freebsd"
189
+ when /mingw|mswin/
190
+ "windows"
191
+ else
192
+ "linux"
193
+ end
194
+ end
195
+
196
+ cpu = begin
197
+ case RbConfig::CONFIG['host_cpu'].downcase
198
+ when /amd64|x86_64/
199
+ "amd64"
200
+ when /^arm/
201
+ RbConfig::CONFIG['host_cpu'].include?("64") ? "arm64" : "arm"
202
+ else
203
+ "386"
204
+ end
205
+ end
206
+
207
+ executable_type = :"#{platform}_#{cpu}"
208
+ end
209
+ end
210
+
211
+ # This configured puma to terminate TLS, but since Puma's TLS terminator has a bug we moved it to ngrok
212
+ # https://github.com/puma/puma/issues/1670
213
+ # def self.configure_puma_options
214
+ # server = ObjectSpace.each_object(Rails::Server).first
215
+ # server_options = server.instance_variable_get(:@options).dup
216
+ # if !server.send(:use_puma?)
217
+ # raise "Sorry, Clerk cannot boot with a custom host: #{server_options[:Host]}"
218
+ # elsif server_options[:user_supplied_options].include? :Host
219
+ # raise "Sorry, Clerk currently only supports Rails using the Puma server."
220
+ # else
221
+ # server_options[:user_supplied_options] << :Host
222
+ # server_options[:Host] = "ssl://127.0.0.1:#{server_options[:Port]}?key=.clerk/dev.key&cert=.clerk/dev.crt"
223
+ # server.instance_variable_set(:@options, server_options)
224
+ # end
225
+ # end
226
+
227
+ def self.patch_rack_requests
228
+ ::ActionDispatch::Request.class_eval do
229
+ def scheme
230
+ "https"
231
+ end
232
+ end
233
+ end
234
+
235
+ def self.patch_ngrok_gem
236
+ # Patch ngrok tunnel gem to work with TLS
237
+ ::Ngrok::Tunnel.class_eval do
238
+ def self.start(params = {})
239
+ init(params)
240
+
241
+ if stopped?
242
+ @params[:log] = (@params[:log]) ? File.open(@params[:log], 'w+') : Tempfile.new('ngrok')
243
+ @pid = spawn("exec #{Clerk::Tunnel.ngrok_path} tls " + ngrok_exec_params)
244
+ at_exit { Ngrok::Tunnel.stop }
245
+ begin
246
+ fetch_urls
247
+ rescue => e
248
+
249
+ end
250
+ end
251
+
252
+ @status = :running
253
+ @ngrok_url.gsub("tls", "https")
254
+ end
255
+
256
+ private
257
+
258
+ def self.ngrok_exec_params
259
+ exec_params = "-log=stdout -log-level=debug "
260
+ exec_params << "-region=#{@params[:region]} " if @params[:region]
261
+ exec_params << "-host-header=#{@params[:host_header]} " if @params[:host_header]
262
+ exec_params << "-authtoken=#{@params[:authtoken]} " if @params[:authtoken]
263
+ exec_params << "-subdomain=#{@params[:subdomain]} " if @params[:subdomain]
264
+ exec_params << "-hostname=#{@params[:hostname]} " if @params[:hostname]
265
+ exec_params << "-crt=#{@params[:crt]} " if @params[:crt]
266
+ exec_params << "-key=#{@params[:key]} " if @params[:key]
267
+ exec_params << "-inspect=#{@params[:inspect]} " if @params.has_key? :inspect
268
+ exec_params << "-config=#{@params[:config]} #{@params[:addr]} > #{@params[:log].path}"
269
+ end
270
+
271
+ def self.fetch_urls
272
+ @params[:timeout].times do
273
+ log_content = @params[:log].read
274
+
275
+ result = log_content.scan(/URL:(.+)\sProto:(tls)\s/)
276
+ if !result.empty?
277
+ result = Hash[*result.flatten].invert
278
+ @ngrok_url = result['tls']
279
+ return @ngrok_url if @ngrok_url
280
+ end
281
+
282
+ error = log_content.scan(/msg="command failed" err="([^"]+)"/).flatten
283
+ unless error.empty?
284
+ self.stop
285
+ raise Ngrok::Error, error.first
286
+ end
287
+
288
+ sleep 1
289
+ @params[:log].rewind
290
+ end
291
+ self.stop
292
+ raise Ngrok::FetchUrlError, "Unable to fetch external url"
293
+ end
294
+ end
295
+ end
296
+ end
297
+ end
data/lib/clerk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Clerk
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clerk-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clerk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-09 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,90 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ngrok-tunnel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: acme-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday_middleware
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: dotenv
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubyzip
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
41
125
  description: Clerk is the easiest way to manage accounts.
42
126
  email:
43
127
  - bsidoti@gmail.com
@@ -58,7 +142,6 @@ files:
58
142
  - app/models/clerk/account.rb
59
143
  - app/models/clerk/application_record.rb
60
144
  - app/models/clerk/client.rb
61
- - app/models/clerk/plan.rb
62
145
  - app/models/clerk/role.rb
63
146
  - app/models/concerns/clerk/clerked.rb
64
147
  - app/models/concerns/clerk/errors.rb
@@ -66,6 +149,8 @@ files:
66
149
  - config/routes.rb
67
150
  - lib/clerk-rails.rb
68
151
  - lib/clerk/engine.rb
152
+ - lib/clerk/id.rb
153
+ - lib/clerk/tunnel.rb
69
154
  - lib/clerk/version.rb
70
155
  - lib/tasks/clerk_tasks.rake
71
156
  homepage:
@@ -1,6 +0,0 @@
1
- module Clerk
2
- class Plan < Clerk::ApplicationRecord
3
- self.table_name = self.clerk_table_name("plans")
4
- self.primary_key = 'id'
5
- end
6
- end