module Darrrr

Handles binary serialization/deserialization of recovery token data. It does not manage signing/verification of tokens. Only account providers will ever call the decode function

Constants

VERSION

Attributes

account_providers[RW]

recovery provider data is only loaded (and cached) upon use.

allow_unsafe_urls[RW]

recovery provider data is only loaded (and cached) upon use.

authority[RW]

recovery provider data is only loaded (and cached) upon use.

cache[RW]

recovery provider data is only loaded (and cached) upon use.

faraday_config_callback[RW]

recovery provider data is only loaded (and cached) upon use.

icon_152px[RW]

recovery provider data is only loaded (and cached) upon use.

privacy_policy[RW]

recovery provider data is only loaded (and cached) upon use.

recovery_providers[RW]

recovery provider data is only loaded (and cached) upon use.

Public Class Methods

account_and_recovery_provider_config() click to toggle source

Returns a hash of all configuration values, recovery and account provider.

# File lib/darrrr.rb, line 125
def account_and_recovery_provider_config
  provider_data = Darrrr.this_account_provider&.to_h || {}

  if Darrrr.this_recovery_provider
    provider_data.merge!(recovery_provider_config) do |key, lhs, rhs|
      unless lhs == rhs
        raise ArgumentError, "inconsistent config value detected #{key}: #{lhs} != #{rhs}"
      end

      lhs
    end
  end

  provider_data
end
account_provider(provider_origin, &block) click to toggle source

Find and load remote account provider configuration data.

provider_origin: the origin that contains the config data in a well-known location.

# File lib/darrrr.rb, line 93
def account_provider(provider_origin, &block)
  unless self.account_providers
    raise "No account providers configured"
  end
  if provider_origin == this_account_provider&.origin
    this_account_provider
  elsif self.account_providers.include?(provider_origin)
    AccountProvider.new(provider_origin).load
  else
    raise UnknownProviderError, "Unknown account provider: #{provider_origin}"
  end
end
account_provider_config() click to toggle source

returns the account provider information in hash form

# File lib/darrrr.rb, line 142
def account_provider_config
  this_account_provider&.to_h
end
recovery_provider(provider_origin) click to toggle source

Find and load remote recovery provider configuration data.

provider_origin: the origin that contains the config data in a well-known location.

# File lib/darrrr.rb, line 67
def recovery_provider(provider_origin)
  unless self.recovery_providers
    raise "No recovery providers configured"
  end

  if provider_origin == this_recovery_provider&.origin
    this_recovery_provider
  elsif self.recovery_providers.include?(provider_origin)
    RecoveryProvider.new(provider_origin).load
  else
    raise UnknownProviderError, "Unknown recovery provider: #{provider_origin}"
  end
end
recovery_provider_config() click to toggle source

returns the account provider information in hash form

# File lib/darrrr.rb, line 147
def recovery_provider_config
  this_recovery_provider&.to_h
end
register_account_provider(account_origin) click to toggle source

Permit an origin to act as an account provider.

account_origin: the origin to permit

# File lib/darrrr.rb, line 109
def register_account_provider(account_origin)
  self.account_providers ||= []
  self.account_providers << account_origin
end
register_recovery_provider(provider_origin) click to toggle source

Permit an origin to act as a recovery provider.

provider_origin: the origin to permit

# File lib/darrrr.rb, line 84
def register_recovery_provider(provider_origin)
  self.recovery_providers ||= []
  self.recovery_providers << provider_origin
end
this_account_provider() click to toggle source

Provide a reference to the account provider configuration for this web app

# File lib/darrrr.rb, line 115
def this_account_provider
  AccountProvider.this
end
this_recovery_provider() click to toggle source

Provide a reference to the recovery provider configuration for this web app

# File lib/darrrr.rb, line 120
def this_recovery_provider
  RecoveryProvider.this
end