Class: Bankid::Secret
- Inherits:
-
Object
- Object
- Bankid::Secret
- Defined in:
- lib/bankid/secret.rb
Constant Summary collapse
- RESOLUTION =
1
Instance Attribute Summary collapse
-
#order_ref ⇒ Object
readonly
Returns the value of attribute order_ref.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #autostart_link(return_url = nil) ⇒ Object
- #desktop_link(return_url) ⇒ Object
- #elapsed_seconds ⇒ Object
-
#initialize(orderRef:, autoStartToken:, qrStartToken:, qrStartSecret:, created_at:) ⇒ Secret
constructor
A new instance of Secret.
- #qr_code ⇒ Object
Constructor Details
#initialize(orderRef:, autoStartToken:, qrStartToken:, qrStartSecret:, created_at:) ⇒ Secret
Returns a new instance of Secret.
9 10 11 12 13 14 15 |
# File 'lib/bankid/secret.rb', line 9 def initialize(orderRef:, autoStartToken:, qrStartToken:, qrStartSecret:, created_at:) @order_ref = orderRef @auto_start_token = autoStartToken @qr_start_token = qrStartToken @qr_start_secret = qrStartSecret @created_at = created_at end |
Instance Attribute Details
#order_ref ⇒ Object (readonly)
Returns the value of attribute order_ref.
7 8 9 |
# File 'lib/bankid/secret.rb', line 7 def order_ref @order_ref end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/bankid/secret.rb', line 7 def result @result end |
Instance Method Details
#autostart_link(return_url = nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/bankid/secret.rb', line 17 def autostart_link(return_url = nil) if return_url "https://app.bankid.com/?autostarttoken=#{@auto_start_token}&redirect=#{return_url}" else "https://app.bankid.com/?autostarttoken=#{@auto_start_token}" end end |
#desktop_link(return_url) ⇒ Object
25 26 27 |
# File 'lib/bankid/secret.rb', line 25 def desktop_link(return_url) "bankid:///?autostarttoken=#{@auto_start_token}&redirect=#{CGI.escape(return_url)}" end |
#elapsed_seconds ⇒ Object
29 30 31 |
# File 'lib/bankid/secret.rb', line 29 def elapsed_seconds ((Time.zone.now - @created_at).to_f / RESOLUTION).floor * RESOLUTION end |
#qr_code ⇒ Object
33 34 35 36 |
# File 'lib/bankid/secret.rb', line 33 def qr_code auth_code = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("SHA256"), @qr_start_secret, elapsed_seconds.to_s) RQRCode::QRCode.new("bankid.#{@qr_start_token}.#{elapsed_seconds}.#{auth_code}") end |