Class: Altcha::V2::ChallengeParameters
- Inherits:
-
Object
- Object
- Altcha::V2::ChallengeParameters
- Defined in:
- lib/altcha/v2.rb
Overview
All parameters embedded in a v2 challenge.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#data ⇒ Object
Returns the value of attribute data.
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#key_length ⇒ Object
Returns the value of attribute key_length.
-
#key_prefix ⇒ Object
Returns the value of attribute key_prefix.
-
#key_signature ⇒ Object
Returns the value of attribute key_signature.
-
#memory_cost ⇒ Object
Returns the value of attribute memory_cost.
-
#nonce ⇒ Object
Returns the value of attribute nonce.
-
#parallelism ⇒ Object
Returns the value of attribute parallelism.
-
#salt ⇒ Object
Returns the value of attribute salt.
Instance Method Summary collapse
-
#initialize(algorithm:, nonce:, salt:, cost:, key_length: DEFAULT_KEY_LENGTH, key_prefix: DEFAULT_KEY_PREFIX, key_signature: nil, memory_cost: nil, parallelism: nil, expires_at: nil, data: nil) ⇒ ChallengeParameters
constructor
A new instance of ChallengeParameters.
-
#to_h ⇒ Object
Serializes to a plain Hash with camelCase keys, omitting nil optional fields.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(algorithm:, nonce:, salt:, cost:, key_length: DEFAULT_KEY_LENGTH, key_prefix: DEFAULT_KEY_PREFIX, key_signature: nil, memory_cost: nil, parallelism: nil, expires_at: nil, data: nil) ⇒ ChallengeParameters
Returns a new instance of ChallengeParameters.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/altcha/v2.rb', line 21 def initialize(algorithm:, nonce:, salt:, cost:, key_length: DEFAULT_KEY_LENGTH, key_prefix: DEFAULT_KEY_PREFIX, key_signature: nil, memory_cost: nil, parallelism: nil, expires_at: nil, data: nil) @algorithm = algorithm @nonce = nonce @salt = salt @cost = cost @key_length = key_length @key_prefix = key_prefix @key_signature = key_signature @memory_cost = memory_cost @parallelism = parallelism @expires_at = expires_at @data = data end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def algorithm @algorithm end |
#cost ⇒ Object
Returns the value of attribute cost.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def cost @cost end |
#data ⇒ Object
Returns the value of attribute data.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def data @data end |
#expires_at ⇒ Object
Returns the value of attribute expires_at.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def expires_at @expires_at end |
#key_length ⇒ Object
Returns the value of attribute key_length.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def key_length @key_length end |
#key_prefix ⇒ Object
Returns the value of attribute key_prefix.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def key_prefix @key_prefix end |
#key_signature ⇒ Object
Returns the value of attribute key_signature.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def key_signature @key_signature end |
#memory_cost ⇒ Object
Returns the value of attribute memory_cost.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def memory_cost @memory_cost end |
#nonce ⇒ Object
Returns the value of attribute nonce.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def nonce @nonce end |
#parallelism ⇒ Object
Returns the value of attribute parallelism.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def parallelism @parallelism end |
#salt ⇒ Object
Returns the value of attribute salt.
18 19 20 |
# File 'lib/altcha/v2.rb', line 18 def salt @salt end |
Instance Method Details
#to_h ⇒ Object
Serializes to a plain Hash with camelCase keys, omitting nil optional fields. The resulting hash must be stable across round-trips for HMAC signing to work.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/altcha/v2.rb', line 39 def to_h h = { 'algorithm' => algorithm, 'cost' => cost, 'keyLength' => key_length, 'keyPrefix' => key_prefix, 'nonce' => nonce, 'salt' => salt, } h['data'] = data unless data.nil? h['expiresAt'] = expires_at unless expires_at.nil? h['keySignature'] = key_signature unless key_signature.nil? h['memoryCost'] = memory_cost unless memory_cost.nil? h['parallelism'] = parallelism unless parallelism.nil? h end |
#to_json(options = {}) ⇒ Object
56 57 58 |
# File 'lib/altcha/v2.rb', line 56 def to_json( = {}) to_h.to_json() end |