bitwarden-sdk-secrets 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4a8efa2366ad5c6568ce9ec284857674c1b1730263bd538096a2861031ae833
4
- data.tar.gz: 7e15ebee50e29c57357f958f1273fdda182035a490b555510cd95de0f49e14b0
3
+ metadata.gz: 9d3fbb1bb7ea36a7adbc189d3c0b4613aef4db3da8379893b79f4cf49dcf700d
4
+ data.tar.gz: 315a2b1594335ef2a0b9eb72d3c1fb78c6c764b625d3257ba17d9cfa8660f523
5
5
  SHA512:
6
- metadata.gz: ac31e0a25f1ee16b2db1e2949cca718cd268a4ad0b2f18c28ffee48b1cf3ab5d3855bb771869037f00161255529f8d0715f628197e5309391162bca94e799c79
7
- data.tar.gz: 52e926afe59c3d545d0d5441dc2cb356491291a7ffffa6af2ef7a61006dbf6ab3eef8d6662faf87eb1811d4c5eaf17a5a8756627252304868fb3b589ab0070ea
6
+ metadata.gz: c67e222e8f46b4a1cafc7749d3c65e6012dd8b9a9d3732950eed527ba72542551638b8cbe82546ce4a3045e3c3253b49a501ceba722ce30253b13d5482c82d29
7
+ data.tar.gz: 5b5f6de86a461106b094a947d7cb81f5f17ed3f461d60aca598b2fca5dfb80962a8a9657d28b78479f9bb7104aed45fb904c4dcc6e5a3ea4600b664438f30ef4
data/lib/auth.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'bitwarden_error'
3
+
4
+ module BitwardenSDKSecrets
5
+ class AuthClient
6
+ def initialize(command_runner)
7
+ @command_runner = command_runner
8
+ end
9
+
10
+ def login_access_token(access_token, state_file = nil)
11
+ access_token_request = AccessTokenLoginRequest.new(access_token: access_token, state_file: state_file)
12
+ @command_runner.run(SelectiveCommand.new(login_access_token: access_token_request))
13
+ nil
14
+ end
15
+ end
16
+ end
@@ -10,6 +10,7 @@ require_relative 'bitwarden_lib'
10
10
  require_relative 'bitwarden_error'
11
11
  require_relative 'projects'
12
12
  require_relative 'secrets'
13
+ require_relative 'auth'
13
14
 
14
15
  module BitwardenSDKSecrets
15
16
  class BitwardenSettings
@@ -26,7 +27,7 @@ module BitwardenSDKSecrets
26
27
  end
27
28
 
28
29
  class BitwardenClient
29
- attr_reader :bitwarden, :project_client, :secrets_client
30
+ attr_reader :bitwarden, :projects, :secrets, :auth
30
31
 
31
32
  def initialize(bitwarden_settings)
32
33
  client_settings = ClientSettings.new(
@@ -39,14 +40,9 @@ module BitwardenSDKSecrets
39
40
  @bitwarden = BitwardenLib
40
41
  @handle = @bitwarden.init(client_settings.to_dynamic.compact.to_json)
41
42
  @command_runner = CommandRunner.new(@bitwarden, @handle)
42
- @project_client = ProjectsClient.new(@command_runner)
43
- @secrets_client = SecretsClient.new(@command_runner)
44
- end
45
-
46
- def access_token_login(access_token, state_file = nil)
47
- access_token_request = AccessTokenLoginRequest.new(access_token: access_token, state_file: state_file)
48
- @command_runner.run(SelectiveCommand.new(access_token_login: access_token_request))
49
- nil
43
+ @projects = ProjectsClient.new(@command_runner)
44
+ @secrets = SecretsClient.new(@command_runner)
45
+ @auth = AuthClient.new(@command_runner)
50
46
  end
51
47
 
52
48
  def free_mem
@@ -3,23 +3,25 @@ module BitwardenSDKSecrets
3
3
  class SelectiveCommand < Command
4
4
  attribute :password_login, PasswordLoginRequest.optional.default(nil)
5
5
  attribute :api_key_login, APIKeyLoginRequest.optional.default(nil)
6
- attribute :access_token_login, AccessTokenLoginRequest.optional.default(nil)
6
+ attribute :login_access_token, AccessTokenLoginRequest.optional.default(nil)
7
7
  attribute :get_user_api_key, SecretVerificationRequest.optional.default(nil)
8
8
  attribute :fingerprint, FingerprintRequest.optional.default(nil)
9
9
  attribute :sync, SyncRequest.optional.default(nil)
10
10
  attribute :secrets, SecretsCommand.optional.default(nil)
11
11
  attribute :projects, ProjectsCommand.optional.default(nil)
12
+ attribute :generators, GeneratorsCommand.optional.default(nil)
12
13
 
13
14
  def to_dynamic
14
15
  {
15
16
  "passwordLogin" => password_login&.to_dynamic,
16
17
  "apiKeyLogin" => api_key_login&.to_dynamic,
17
- "accessTokenLogin" => access_token_login&.to_dynamic,
18
+ "loginAccessToken" => login_access_token&.to_dynamic,
18
19
  "getUserApiKey" => get_user_api_key&.to_dynamic,
19
20
  "fingerprint" => fingerprint&.to_dynamic,
20
21
  "sync" => sync&.to_dynamic,
21
22
  "secrets" => secrets&.to_dynamic,
22
23
  "projects" => projects&.to_dynamic,
24
+ "generators" => generators&.to_dynamic,
23
25
  }.compact
24
26
  end
25
27
  end
@@ -49,6 +51,7 @@ module BitwardenSDKSecrets
49
51
  attribute :list, SecretIdentifiersRequest.optional.default(nil)
50
52
  attribute :update, SecretPutRequest.optional.default(nil)
51
53
  attribute :delete, SecretsDeleteRequest.optional.default(nil)
54
+ attribute :sync, SecretsSyncRequest.optional.default(nil)
52
55
 
53
56
  def to_dynamic
54
57
  {
@@ -58,7 +61,18 @@ module BitwardenSDKSecrets
58
61
  "list" => list&.to_dynamic,
59
62
  "update" => update&.to_dynamic,
60
63
  "delete" => delete&.to_dynamic,
64
+ "sync" => sync&.to_dynamic,
61
65
  }.compact
62
66
  end
63
67
  end
68
+
69
+ class SelectiveGeneratorsCommand < GeneratorsCommand
70
+ attribute :generate_password, PasswordGeneratorRequest.optional.default(nil)
71
+
72
+ def to_dynamic
73
+ {
74
+ "generate_password" => generate_password&.to_dynamic,
75
+ }.compact
76
+ end
77
+ end
64
78
  end
Binary file
Binary file
Binary file
data/lib/projects.rb CHANGED
@@ -8,7 +8,7 @@ module BitwardenSDKSecrets
8
8
  @command_runner = command_runner
9
9
  end
10
10
 
11
- def create_project(project_name, organization_id)
11
+ def create(organization_id, project_name)
12
12
  project_create_request = ProjectCreateRequest.new(
13
13
  project_create_request_name: project_name,
14
14
  organization_id: organization_id
@@ -43,7 +43,7 @@ module BitwardenSDKSecrets
43
43
  error_response(projects_response)
44
44
  end
45
45
 
46
- def list_projects(organization_id)
46
+ def list(organization_id)
47
47
  project_list_request = ProjectsListRequest.new(organization_id: organization_id)
48
48
  command = create_command(list: project_list_request)
49
49
  response = parse_response(command)
@@ -58,7 +58,7 @@ module BitwardenSDKSecrets
58
58
  error_response(projects_response)
59
59
  end
60
60
 
61
- def update_project(id, project_put_request_name, organization_id)
61
+ def update(organization_id, id, project_put_request_name)
62
62
  project_put_request = ProjectPutRequest.new(
63
63
  id: id,
64
64
  project_put_request_name: project_put_request_name,
@@ -79,7 +79,7 @@ module BitwardenSDKSecrets
79
79
  error_response(projects_response)
80
80
  end
81
81
 
82
- def delete_projects(ids)
82
+ def delete(ids)
83
83
  project_delete_request = ProjectsDeleteRequest.new(ids: ids)
84
84
  command = create_command(delete: project_delete_request)
85
85
  response = parse_response(command)