Files
docuseal/lib/docuseal.rb
T

94 lines
2.6 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Docuseal
2024-02-18 10:04:56 +02:00
URL_CACHE = ActiveSupport::Cache::MemoryStore.new
2023-06-26 00:46:01 +03:00
PRODUCT_URL = 'https://www.docuseal.co'
2023-07-01 13:43:46 +03:00
NEWSLETTER_URL = "#{PRODUCT_URL}/newsletters".freeze
2023-10-21 15:33:10 +03:00
ENQUIRIES_URL = "#{PRODUCT_URL}/enquiries".freeze
2023-06-26 00:46:01 +03:00
PRODUCT_NAME = 'DocuSeal'
2024-08-24 14:57:40 +03:00
DEFAULT_APP_URL = ENV.fetch('APP_URL', 'http://localhost:3000')
2023-07-04 23:05:22 +03:00
GITHUB_URL = 'https://github.com/docusealco/docuseal'
2023-07-10 00:13:49 +03:00
DISCORD_URL = 'https://discord.gg/qygYCDGck9'
2023-07-04 23:05:22 +03:00
TWITTER_URL = 'https://twitter.com/docusealco'
2023-07-04 23:21:49 +03:00
TWITTER_HANDLE = '@docusealco'
2024-06-30 16:21:19 +03:00
CHATGPT_URL = 'https://chatgpt.com/g/g-9hg8AAw0r-docuseal'
2023-07-08 17:07:07 +03:00
SUPPORT_EMAIL = 'support@docuseal.co'
2023-08-29 20:47:56 +03:00
HOST = ENV.fetch('HOST', 'localhost')
2023-08-05 11:02:00 +03:00
CONSOLE_URL = if Rails.env.development?
'http://console.localhost.io:3001'
2023-08-30 14:39:14 +03:00
elsif ENV['MULTITENANT'] == 'true'
2023-08-29 20:47:56 +03:00
"https://console.#{HOST}"
2023-08-30 14:39:14 +03:00
else
'https://console.docuseal.co'
2023-08-05 11:02:00 +03:00
end
2024-01-31 02:52:36 +02:00
CLOUD_URL = if Rails.env.development?
'http://localhost:3000'
else
'https://docuseal.co'
end
2023-08-25 23:44:14 +03:00
CDN_URL = if Rails.env.development?
'http://localhost:3000'
2023-08-30 14:39:14 +03:00
elsif ENV['MULTITENANT'] == 'true'
2023-08-29 20:47:56 +03:00
"https://cdn.#{HOST}"
2023-08-30 14:39:14 +03:00
else
'https://cdn.docuseal.co'
2023-08-25 23:44:14 +03:00
end
2023-06-30 20:31:17 +03:00
CERTS = JSON.parse(ENV.fetch('CERTS', '{}'))
2023-12-02 18:14:33 +02:00
TIMESERVER_URL = ENV.fetch('TIMESERVER_URL', nil)
2024-01-06 22:58:26 +02:00
VERSION_FILE_PATH = Rails.root.join('.version')
2023-06-30 20:31:17 +03:00
DEFAULT_URL_OPTIONS = {
2023-08-30 14:39:14 +03:00
host: HOST,
2023-10-29 19:10:41 +02:00
protocol: ENV['FORCE_SSL'].present? ? 'https' : 'http'
2023-06-30 20:31:17 +03:00
}.freeze
module_function
2024-01-06 22:58:26 +02:00
def version
@version ||= VERSION_FILE_PATH.read.strip if VERSION_FILE_PATH.exist?
end
2023-06-26 00:46:01 +03:00
def multitenant?
2023-06-30 20:31:17 +03:00
ENV['MULTITENANT'] == 'true'
2023-06-26 00:46:01 +03:00
end
2023-07-05 00:22:05 +03:00
def demo?
ENV['DEMO'] == 'true'
end
def active_storage_public?
ENV['ACTIVE_STORAGE_PUBLIC'] == 'true'
end
2024-05-01 23:40:09 +03:00
def default_pkcs
@default_pkcs ||= GenerateCertificate.load_pkcs(Docuseal::CERTS)
end
def trusted_certs
@trusted_certs ||=
2024-05-02 13:39:47 +03:00
ENV['TRUSTED_CERTS'].to_s.gsub('\\n', "\n").split("\n\n").map do |base64|
2024-05-01 23:40:09 +03:00
OpenSSL::X509::Certificate.new(base64)
end
end
def default_url_options
2023-06-30 20:31:17 +03:00
return DEFAULT_URL_OPTIONS if multitenant?
@default_url_options ||= begin
2024-08-24 14:57:40 +03:00
value = EncryptedConfig.find_by(key: EncryptedConfig::APP_URL_KEY)&.value if ENV['APP_URL'].blank?
value ||= DEFAULT_APP_URL
url = Addressable::URI.parse(value)
{ host: url.host, port: url.port, protocol: url.scheme }
end
end
2023-10-11 21:05:42 +03:00
def product_name
PRODUCT_NAME
end
def refresh_default_url_options!
@default_url_options = nil
end
end