Class: RubyNative::AssetlinksController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/ruby_native/assetlinks_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/ruby_native/assetlinks_controller.rb', line 3

def show
  RubyNative.load_config if Rails.env.development?

  package = RubyNative.config&.dig(:android, :package)
  # The Digital Asset Links spec wants uppercase colon-separated hex, so a
  # lowercase paste from keytool still verifies.
  fingerprints = Array(RubyNative.config&.dig(:android, :cert_fingerprint))
    .map { |fingerprint| fingerprint.to_s.strip.upcase }
    .reject(&:empty?)
  return head :not_found unless package.present? && fingerprints.present?

  response.set_header("Cache-Control", "no-cache")
  render json: [
    {
      relation: [
        "delegate_permission/common.handle_all_urls",
        "delegate_permission/common.get_login_creds"
      ],
      target: {
        namespace: "android_app",
        package_name: package,
        sha256_cert_fingerprints: fingerprints
      }
    }
  ]
end