Class: Keybase::User
- Inherits:
-
Object
- Object
- Keybase::User
- Defined in:
- lib/keybase/models/user.rb
Overview
A Keybase user containing all attributes you have permission to see
Instance Attribute Summary collapse
-
#basics ⇒ Object
readonly
Returns the value of attribute basics.
-
#emails ⇒ Object
readonly
Returns the value of attribute emails.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#invitation_stats ⇒ Object
readonly
Returns the value of attribute invitation_stats.
-
#private_keys ⇒ Object
readonly
Returns the value of attribute private_keys.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#public_keys ⇒ Object
readonly
Returns the value of attribute public_keys.
Class Method Summary collapse
-
.login(email_or_username, passphrase) ⇒ Keybase::Model::User
Login to Keybase.
-
.lookup(username) ⇒ Keybase::Model::User
Lookup a user on Keybase.
Instance Method Summary collapse
-
#add_private_key(key) ⇒ String
Add a new private key to Keybase.
-
#add_public_key(key) ⇒ String
Add a new public key to Keybase.
-
#initialize(params) ⇒ User
constructor
A new instance of User.
-
#post_auth(sig) ⇒ String
Post a self-signed authentication certificate to Keybase.
-
#revoke_key(kid) ⇒ Boolean
Revoke a key from Keybase.
Constructor Details
#initialize(params) ⇒ User
Returns a new instance of User.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/keybase/models/user.rb', line 8 def initialize(params) @id = params['id'] @invitation_stats = OpenStruct.new(params['invitation_stats']) set_basics(params['basics']) if params['basics'] set_profile(params['profile']) if params['profile'] set_emails(params['emails']) if params['emails'] set_public_keys(params['public_keys']) if params['public_keys'] set_private_keys(params['private_keys']) if params['private_keys'] end |
Instance Attribute Details
#basics ⇒ Object (readonly)
Returns the value of attribute basics.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def basics @basics end |
#emails ⇒ Object (readonly)
Returns the value of attribute emails.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def emails @emails end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def id @id end |
#invitation_stats ⇒ Object (readonly)
Returns the value of attribute invitation_stats.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def invitation_stats @invitation_stats end |
#private_keys ⇒ Object (readonly)
Returns the value of attribute private_keys.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def private_keys @private_keys end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def profile @profile end |
#public_keys ⇒ Object (readonly)
Returns the value of attribute public_keys.
5 6 7 |
# File 'lib/keybase/models/user.rb', line 5 def public_keys @public_keys end |
Class Method Details
.login(email_or_username, passphrase) ⇒ Keybase::Model::User
Login to Keybase
37 38 39 40 41 42 43 |
# File 'lib/keybase/models/user.rb', line 37 def self.login(email_or_username, passphrase) salt, login_session = Request::Root.get_salt_and_login_session(email_or_username) pwh = Crypto.scrypt(passphrase, salt) hmac_pwh = Crypto.hmac_sha512(pwh, login_session) response = Request::Root.login(email_or_username, hmac_pwh, login_session) return new(response['me']) end |
.lookup(username) ⇒ Keybase::Model::User
Lookup a user on Keybase
25 26 27 |
# File 'lib/keybase/models/user.rb', line 25 def self.lookup(username) new(Request::User.lookup(username)) end |
Instance Method Details
#add_private_key(key) ⇒ String
Add a new private key to Keybase
This requires login first.
108 109 110 |
# File 'lib/keybase/models/user.rb', line 108 def add_private_key(key) Request::Key.add(private_key: key) end |
#add_public_key(key) ⇒ String
Add a new public key to Keybase
This requires login first.
95 96 97 |
# File 'lib/keybase/models/user.rb', line 95 def add_public_key(key) Request::Key.add(public_key: key) end |
#post_auth(sig) ⇒ String
Post a self-signed authentication certificate to Keybase
This requires login first.
The payload of the signature should take the form of other keybase signatures, like self-signing keys, or proving ownership of remote accounts.
An example looks like:
{
"body": {
"key": {
"fingerprint": "da99a6ebeca98b14d944cb6e1ca9bfeab344f0fc",
"host": "keybase.io",
"key_id": "1ca9bfeab344f0fc",
"uid": "15a9e2826313eaf005291a1ae00c3f00",
"username": "taco422107"
},
"nonce": null,
"type": "auth",
"version": 1
},
"ctime": 1386537779,
"expire_in": 86400,
"tag": "signature"
}
The client can provide an optional nonce to randomize the signatures. The server will check the signature for validatity, and on success, will return an auth_token, which is the SHA-256 hash of the full signature body, from the “—- BEGIN” all the way through to the —- END PGP MESSAGE —-.
82 83 84 |
# File 'lib/keybase/models/user.rb', line 82 def post_auth(sig) Request::Sig.post_auth(basics.username, sig) end |
#revoke_key(kid) ⇒ Boolean
Revoke a key from Keybase
This requires login first.
Currently the key is simply deleted - full revokation is due in later revisions of the API.
124 125 126 |
# File 'lib/keybase/models/user.rb', line 124 def revoke_key(kid) Request::Key.revoke(kid) end |