Class: ReplIdentity::Identity
- Inherits:
-
Object
- Object
- ReplIdentity::Identity
- Defined in:
- lib/repl_identity/identity.rb
Instance Attribute Summary collapse
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#ephemeral ⇒ Object
readonly
Returns the value of attribute ephemeral.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#origin_repl_id ⇒ Object
readonly
Returns the value of attribute origin_repl_id.
-
#repl_id ⇒ Object
readonly
Returns the value of attribute repl_id.
-
#repl_slug ⇒ Object
readonly
Returns the value of attribute repl_slug.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(token) ⇒ Identity
constructor
A new instance of Identity.
- #verified?(client_repl_id) ⇒ Boolean
Constructor Details
#initialize(token) ⇒ Identity
Returns a new instance of Identity.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/repl_identity/identity.rb', line 5 def initialize(token) stdout, status = Open3.capture2( REPLIT_CLI_PATH, "identity", "verify", "-audience=#{REPL_ID}", "-token=#{token}", "-json" ) print "\r" + "\e[A\e[K" unless status.success? # Remove error message from replit process identity = status.success? ? JSON.parse(stdout) : {} @success = status.success? @audience = identity["aud"] @repl_slug = identity["slug"] @username = identity["user"] @repl_id = identity["replid"] @origin = identity["origin"] @ephemeral = identity["ephemeral"] @origin_repl_id = identity["originReplid"] end |
Instance Attribute Details
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def audience @audience end |
#ephemeral ⇒ Object (readonly)
Returns the value of attribute ephemeral.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def ephemeral @ephemeral end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def origin @origin end |
#origin_repl_id ⇒ Object (readonly)
Returns the value of attribute origin_repl_id.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def origin_repl_id @origin_repl_id end |
#repl_id ⇒ Object (readonly)
Returns the value of attribute repl_id.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def repl_id @repl_id end |
#repl_slug ⇒ Object (readonly)
Returns the value of attribute repl_slug.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def repl_slug @repl_slug end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
3 4 5 |
# File 'lib/repl_identity/identity.rb', line 3 def username @username end |
Instance Method Details
#verified?(client_repl_id) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/repl_identity/identity.rb', line 26 def verified?(client_repl_id) @success && [@repl_id, @origin_repl_id].include?(client_repl_id) && @audience == REPL_ID end |