Class: Wix::Apps::SignedInstance
- Inherits:
-
Object
- Object
- Wix::Apps::SignedInstance
- Defined in:
- lib/wix-apps/signed_instance.rb
Overview
This class deal with Wix Signed Instance (dev.wix.com/display/wixdevelopersapi/The+Signed+Instance)
Example: si = SignedInstance.new(‘vrinSv2HB9tqbnJ.…’)
Instance Attribute Summary collapse
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#raw_signed_instance ⇒ Object
readonly
Returns the value of attribute raw_signed_instance.
-
#sign_date ⇒ Object
readonly
Returns the value of attribute sign_date.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(raw_signed_instance, options = {}) ⇒ SignedInstance
constructor
A new instance of SignedInstance.
-
#owner? ⇒ Boolean
Owner mode on?.
-
#valid? ⇒ Boolean
validates signature.
Constructor Details
#initialize(raw_signed_instance, options = {}) ⇒ SignedInstance
Returns a new instance of SignedInstance.
18 19 20 21 22 23 |
# File 'lib/wix-apps/signed_instance.rb', line 18 def initialize(raw_signed_instance, = {}) @raw_signed_instance = raw_signed_instance @secret = [:secret] parse_signed_instance_data end |
Instance Attribute Details
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
15 16 17 |
# File 'lib/wix-apps/signed_instance.rb', line 15 def instance_id @instance_id end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
15 16 17 |
# File 'lib/wix-apps/signed_instance.rb', line 15 def @permissions end |
#raw_signed_instance ⇒ Object (readonly)
Returns the value of attribute raw_signed_instance.
15 16 17 |
# File 'lib/wix-apps/signed_instance.rb', line 15 def raw_signed_instance @raw_signed_instance end |
#sign_date ⇒ Object (readonly)
Returns the value of attribute sign_date.
15 16 17 |
# File 'lib/wix-apps/signed_instance.rb', line 15 def sign_date @sign_date end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
15 16 17 |
# File 'lib/wix-apps/signed_instance.rb', line 15 def uid @uid end |
Instance Method Details
#owner? ⇒ Boolean
Owner mode on?
36 37 38 |
# File 'lib/wix-apps/signed_instance.rb', line 36 def owner? == 'OWNER' end |
#valid? ⇒ Boolean
validates signature
26 27 28 29 30 31 32 33 |
# File 'lib/wix-apps/signed_instance.rb', line 26 def valid? raise SignedInstanceNoSecretKey.new('Please provide secret key') if @secret.nil? digest = OpenSSL::Digest::Digest.new('sha256') hmac_digest = OpenSSL::HMAC.digest(digest, @secret, @encoded_json) my_signature = Base64.urlsafe_encode64(hmac_digest).gsub('=','') return my_signature == @signature end |