Module: Himari::TokenString::ClassMethods

Defined in:
lib/himari/token_string.rb

Instance Method Summary collapse

Instance Method Details

#default_lifetimeObject

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/himari/token_string.rb', line 19

def default_lifetime
  raise NotImplementedError
end

#magic_headerObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/himari/token_string.rb', line 15

def magic_header
  raise NotImplementedError
end

#make(lifetime: nil, **kwargs) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/himari/token_string.rb', line 23

def make(lifetime: nil, **kwargs)
  new(
    handle: SecureRandom.urlsafe_base64(32),
    secret: SecureRandom.urlsafe_base64(48),
    expiry: Time.now.to_i + (lifetime || default_lifetime),
    **kwargs
  )
end

#parse(str) ⇒ Object



32
33
34
# File 'lib/himari/token_string.rb', line 32

def parse(str)
  Format.parse(magic_header, str)
end