Class: Layer::IdentityToken

Inherits:
Object
  • Object
show all
Defined in:
lib/layer/identity_token.rb,
lib/layer/identity_token/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id, nonce, expires_at = (Time.now+(86400*14))) ⇒ IdentityToken

Returns a new instance of IdentityToken.



27
28
29
30
31
# File 'lib/layer/identity_token.rb', line 27

def initialize(user_id, nonce, expires_at = (Time.now+(86400*14)))
  @user_id = user_id
  @nonce = nonce
  @expires_at = expires_at
end

Class Attribute Details

.layer_key_idObject



14
15
16
# File 'lib/layer/identity_token.rb', line 14

def layer_key_id
  @layer_key_id || ENV["LAYER_KEY_ID"]
end

.layer_private_keyObject



18
19
20
# File 'lib/layer/identity_token.rb', line 18

def layer_private_key
  @layer_private_key || ENV["LAYER_PRIVATE_KEY"]
end

.layer_provider_idObject



10
11
12
# File 'lib/layer/identity_token.rb', line 10

def layer_provider_id
  @layer_provider_id || ENV["LAYER_PROVIDER_ID"]
end

Instance Attribute Details

#expires_atObject (readonly)

Returns the value of attribute expires_at.



23
24
25
# File 'lib/layer/identity_token.rb', line 23

def expires_at
  @expires_at
end

#nonceObject (readonly)

Returns the value of attribute nonce.



23
24
25
# File 'lib/layer/identity_token.rb', line 23

def nonce
  @nonce
end

#user_idObject (readonly)

Returns the value of attribute user_id.



23
24
25
# File 'lib/layer/identity_token.rb', line 23

def user_id
  @user_id
end

Instance Method Details

#as_json(options = {}) ⇒ Object



37
38
39
# File 'lib/layer/identity_token.rb', line 37

def as_json(options = {})
  encode
end

#encodeObject Also known as: to_s



33
34
35
# File 'lib/layer/identity_token.rb', line 33

def encode
  JWT.encode(claim, private_key, "RS256", headers)
end