Class: Mobius::Client::Auth::Challenge

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/mobius/client/auth/challenge.rb

Overview

Generates challenge transaction on developer’s side.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seed, expire_in = Mobius::Client.challenge_expires_in) ⇒ Object

Parameters:

  • seed (String)

    Developers private key

  • expire_in (Integer) (defaults to: Mobius::Client.challenge_expires_in)

    Session expiration time (seconds from now). 0 means “never”.



10
# File 'lib/mobius/client/auth/challenge.rb', line 10

param :seed

Class Method Details

.call(seed, expire_in = Mobius::Client.challenge_expires_in) ⇒ String

Generates challenge transaction signed by developers private key. Minimum valid time bound is set to current time. Maximum valid time bound is set to ‘expire_in` seconds from now.

Parameters:

  • seed (String)

    Developers private key

  • expire_in (Integer) (defaults to: Mobius::Client.challenge_expires_in)

    Session expiration time (seconds from now). 0 means “never”.

Returns:

  • (String)

    base64-encoded transaction envelope



# File 'lib/mobius/client/auth/challenge.rb', line 13

Instance Method Details

#callString

Returns base64-encoded transaction envelope.

Returns:

  • (String)

    base64-encoded transaction envelope



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mobius/client/auth/challenge.rb', line 22

def call
  payment = Stellar::Transaction.payment(
    source_account: keypair,
    account: Stellar::KeyPair.random,
    destination: keypair,
    sequence: random_sequence,
    amount: micro_xlm,
    memo: memo
  )

  payment.time_bounds = build_time_bounds(expire_in)

  payment.to_envelope(keypair).to_xdr(:base64)
end