Class: Command

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Overview

Login with username and password

This command is for initiating an authentication handshake with Bitwarden. Authorization may fail due to requiring 2fa or captcha challenge completion despite accurate credentials.

This command is not capable of handling authentication requiring 2fa or captcha.

Returns: [PasswordLoginResponse](bitwarden::auth::login::PasswordLoginResponse)

Login with API Key

This command is for initiating an authentication handshake with Bitwarden.

Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse)

Login with Secrets Manager Access Token

This command is for initiating an authentication handshake with Bitwarden.

Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse)

> Requires Authentication Get the API key of the currently authenticated user

Returns: [UserApiKeyResponse](bitwarden::platform::UserApiKeyResponse)

Get the user’s passphrase

Returns: String

> Requires Authentication Retrieve all user data, ciphers and organizations the user is a part of

Returns: [SyncResponse](bitwarden::vault::SyncResponse)

Direct Known Subclasses

BitwardenSDKSecrets::SelectiveCommand

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
# File 'lib/schemas.rb', line 1413

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    password_login:     d["passwordLogin"] ? PasswordLoginRequest.from_dynamic!(d["passwordLogin"]) : nil,
    api_key_login:      d["apiKeyLogin"] ? APIKeyLoginRequest.from_dynamic!(d["apiKeyLogin"]) : nil,
    login_access_token: d["loginAccessToken"] ? AccessTokenLoginRequest.from_dynamic!(d["loginAccessToken"]) : nil,
    get_user_api_key:   d["getUserApiKey"] ? SecretVerificationRequest.from_dynamic!(d["getUserApiKey"]) : nil,
    fingerprint:        d["fingerprint"] ? FingerprintRequest.from_dynamic!(d["fingerprint"]) : nil,
    sync:               d["sync"] ? SyncRequest.from_dynamic!(d["sync"]) : nil,
    secrets:            d["secrets"] ? SecretsCommand.from_dynamic!(d["secrets"]) : nil,
    projects:           d["projects"] ? ProjectsCommand.from_dynamic!(d["projects"]) : nil,
    generators:         d["generators"] ? GeneratorsCommand.from_dynamic!(d["generators"]) : nil,
  )
end

.from_json!(json) ⇒ Object



1428
1429
1430
# File 'lib/schemas.rb', line 1428

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
# File 'lib/schemas.rb', line 1432

def to_dynamic
  {
    "passwordLogin"    => &.to_dynamic,
    "apiKeyLogin"      => &.to_dynamic,
    "loginAccessToken" => &.to_dynamic,
    "getUserApiKey"    => get_user_api_key&.to_dynamic,
    "fingerprint"      => fingerprint&.to_dynamic,
    "sync"             => sync&.to_dynamic,
    "secrets"          => secrets&.to_dynamic,
    "projects"         => projects&.to_dynamic,
    "generators"       => generators&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



1446
1447
1448
# File 'lib/schemas.rb', line 1446

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end