Class: SelfSDK::Services::Authentication
- Inherits:
-
Object
- Object
- SelfSDK::Services::Authentication
- Defined in:
- lib/services/auth.rb
Overview
Input class to handle authentication requests on self network.
Instance Method Summary collapse
-
#generate_deep_link(callback, opts = {}) ⇒ String
Generates a deep link to authenticate with self app.
-
#generate_qr(opts = {}) ⇒ String
Generates a QR code so users can authenticate to your app.
-
#initialize(requester) ⇒ SelfSDK::Services::Authentication
constructor
Creates a new authentication service.
-
#request(selfid, opts = {}, &block) ⇒ Object
Sends an authentication request to the specified selfid.
-
#subscribe(&block) ⇒ Object
Adds an observer for a fact response Whenever you receive a fact response registered observers will receive a notification.
Constructor Details
#initialize(requester) ⇒ SelfSDK::Services::Authentication
Creates a new authentication service. Authentication service mainly manages authentication requests against self users wanting to authenticate on your app.
19 20 21 |
# File 'lib/services/auth.rb', line 19 def initialize(requester) @requester = requester end |
Instance Method Details
#generate_deep_link(callback, opts = {}) ⇒ String
Generates a deep link to authenticate with self app.
77 78 79 80 81 82 |
# File 'lib/services/auth.rb', line 77 def generate_deep_link(callback, opts = {}) opts[:auth] = true facts = opts.fetch(:facts, []) @requester.generate_deep_link(facts, callback, opts) end |
#generate_qr(opts = {}) ⇒ String
Generates a QR code so users can authenticate to your app.
63 64 65 66 67 68 |
# File 'lib/services/auth.rb', line 63 def generate_qr(opts = {}) opts[:auth] = true facts = opts.fetch(:facts, []) @requester.generate_qr(facts, opts) end |
#request(selfid, opts = {}) {|request| ... } ⇒ String #request(selfid, opts = {}) ⇒ String
Sends an authentication request to the specified selfid. An authentication requests allows your users to authenticate on your app using a secure self app.
42 43 44 45 46 47 |
# File 'lib/services/auth.rb', line 42 def request(selfid, opts = {}, &block) opts[:auth] = true facts = opts.fetch(:facts, []) @requester.request(selfid, facts, opts, &block) end |
#subscribe(&block) ⇒ Object
Adds an observer for a fact response Whenever you receive a fact response registered observers will receive a notification.
@yield [request] Invokes the block with a fact response message.
53 54 55 |
# File 'lib/services/auth.rb', line 53 def subscribe(&block) @requester.subscribe(true, &block) end |