adamantite 0.0.2 → 0.0.3
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 +4 -4
- data/lib/adamantite.rb +44 -45
- data/lib/base/editor/password_object_editor.rb +51 -0
- data/lib/base/password_object.rb +15 -0
- data/lib/gui/form/password_object_form_window.rb +72 -0
- data/lib/gui/screen/copy_screen.rb +1 -1
- data/lib/gui/screen/login_screen.rb +1 -1
- data/lib/gui/screen/show_screen.rb +1 -1
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fb2fee60dd29d1cf4e5d3ca9fe052322b5e824769c4fb673068c75ec75bdd700
         | 
| 4 | 
            +
              data.tar.gz: 77b65b3e70c79ea50d945566f9f7b4af841d49449fab4ba69ecde594a0093a0a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8d512ad63718365e1076946093bbf180a2e48d98a74f1ca94ebcf7f3db0f8812a8d2a021b43c653762fecd29741e602ea5c6c92e5021658f550bb1d7bf0c6ede
         | 
| 7 | 
            +
              data.tar.gz: 2e68d7b07925cc5910fa6129371696191f0ca721c7676db9d61aad9daac4694682f3cebda5b7d3c237df3178b08064a6645e87225dbf6352d815e3c694f988d0
         | 
    
        data/lib/adamantite.rb
    CHANGED
    
    | @@ -8,6 +8,7 @@ require "io/console" | |
| 8 8 | 
             
            require "file_utils/file_utils"
         | 
| 9 9 | 
             
            require "pw_utils/pw_utils"
         | 
| 10 10 | 
             
            require "base/adamantite"
         | 
| 11 | 
            +
            require "base/password_object"
         | 
| 11 12 | 
             
            require "gui/screen/login_screen"
         | 
| 12 13 | 
             
            require "gui/screen/copy_screen"
         | 
| 13 14 | 
             
            require "gui/screen/show_screen"
         | 
| @@ -17,6 +18,7 @@ require "gui/request/login_request" | |
| 17 18 | 
             
            require "gui/request/add_password_request"
         | 
| 18 19 | 
             
            require "gui/request/update_master_password_request"
         | 
| 19 20 | 
             
            require "gui/request/set_master_password_request"
         | 
| 21 | 
            +
            require "gui/form/password_object_form_window"
         | 
| 20 22 |  | 
| 21 23 | 
             
            include Adamantite::FileUtils
         | 
| 22 24 | 
             
            include Adamantite::PWUtils
         | 
| @@ -41,7 +43,7 @@ class AdamantiteApp | |
| 41 43 |  | 
| 42 44 | 
             
                @stored_passwords = get_stored_pws.map do |title|
         | 
| 43 45 | 
             
                  pw_info = get_pw_file(title)
         | 
| 44 | 
            -
                  [title, pw_info["username"], 'Copy', 'Show', 'Delete']
         | 
| 46 | 
            +
                  [title, pw_info["username"], 'Edit', 'Copy', 'Show', 'Delete']
         | 
| 45 47 | 
             
                end
         | 
| 46 48 | 
             
                @master_password = login_request.master_password
         | 
| 47 49 | 
             
                @master_password_salt = login_request.master_password_salt
         | 
| @@ -51,13 +53,33 @@ class AdamantiteApp | |
| 51 53 | 
             
              end
         | 
| 52 54 |  | 
| 53 55 | 
             
              body {
         | 
| 54 | 
            -
                window('Adamantite',  | 
| 56 | 
            +
                window('Adamantite', 800, 400) {
         | 
| 55 57 | 
             
                  margined true
         | 
| 56 58 |  | 
| 57 59 | 
             
                  vertical_box {
         | 
| 58 60 | 
             
                    table {
         | 
| 59 61 | 
             
                      text_column('Title')
         | 
| 60 62 | 
             
                      text_column('Username')
         | 
| 63 | 
            +
                      button_column('Edit') {
         | 
| 64 | 
            +
                        on_clicked do |row|
         | 
| 65 | 
            +
                          on_save = lambda { |password_object|
         | 
| 66 | 
            +
                            stored_password = []
         | 
| 67 | 
            +
                            stored_password << password_object.website_title
         | 
| 68 | 
            +
                            stored_password << password_object.username
         | 
| 69 | 
            +
                            stored_password << 'Edit'
         | 
| 70 | 
            +
                            stored_password << 'Copy'
         | 
| 71 | 
            +
                            stored_password << 'Show'
         | 
| 72 | 
            +
                            stored_password << 'Delete'
         | 
| 73 | 
            +
                            @stored_passwords[password_object.row_index] = stored_password
         | 
| 74 | 
            +
                          }
         | 
| 75 | 
            +
                          password_title = @stored_passwords[row].first
         | 
| 76 | 
            +
                          username = @stored_passwords[row][1]
         | 
| 77 | 
            +
                          pw_info = get_pw_file(password_title)
         | 
| 78 | 
            +
                          stored_pw_selection = decrypt_pw(pw_info["iv"], pw_info["password"], @master_password, @master_password_salt)
         | 
| 79 | 
            +
                          password_object = Adamantite::Base::PasswordObject.new(password_title, username, stored_pw_selection, stored_pw_selection, row)
         | 
| 80 | 
            +
                          password_object_form_window(master_pw: @master_password, master_pw_salt: @master_password_salt, on_save: on_save, password_object: password_object).show
         | 
| 81 | 
            +
                        end
         | 
| 82 | 
            +
                      }
         | 
| 61 83 | 
             
                      button_column('Copy') {
         | 
| 62 84 | 
             
                        on_clicked do |row|
         | 
| 63 85 | 
             
                          password_title = @stored_passwords[row].first
         | 
| @@ -80,52 +102,29 @@ class AdamantiteApp | |
| 80 102 | 
             
                          @stored_passwords.delete_at(row)
         | 
| 81 103 | 
             
                        end
         | 
| 82 104 | 
             
                      }
         | 
| 83 | 
            -
             | 
| 84 105 | 
             
                      cell_rows <=> [self, :stored_passwords]
         | 
| 85 | 
            -
             | 
| 86 106 | 
             
                    }
         | 
| 87 | 
            -
                     | 
| 88 | 
            -
                       | 
| 89 | 
            -
                         | 
| 90 | 
            -
                           | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
                           | 
| 100 | 
            -
             | 
| 101 | 
            -
                         | 
| 102 | 
            -
                          label 'Confirm Password'
         | 
| 103 | 
            -
                          text <=> [@add_password_request, :password_confirmation]
         | 
| 104 | 
            -
                        }
         | 
| 107 | 
            +
                    horizontal_box {
         | 
| 108 | 
            +
                      button('Add Password') {
         | 
| 109 | 
            +
                        on_clicked do
         | 
| 110 | 
            +
                          on_save = lambda { |password_object|
         | 
| 111 | 
            +
                            stored_password = []
         | 
| 112 | 
            +
                            stored_password << password_object.website_title
         | 
| 113 | 
            +
                            stored_password << password_object.username
         | 
| 114 | 
            +
                            stored_password << 'Edit'
         | 
| 115 | 
            +
                            stored_password << 'Copy'
         | 
| 116 | 
            +
                            stored_password << 'Show'
         | 
| 117 | 
            +
                            stored_password << 'Delete'
         | 
| 118 | 
            +
                            @stored_passwords << stored_password
         | 
| 119 | 
            +
                          }
         | 
| 120 | 
            +
                          password_object_form_window(master_pw: @master_password, master_pw_salt: @master_password_salt, on_save: on_save).show
         | 
| 121 | 
            +
                        end
         | 
| 105 122 | 
             
                      }
         | 
| 106 | 
            -
                       | 
| 107 | 
            -
                         | 
| 108 | 
            -
                           | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
                              new_stored_password = [@add_password_request.website_title, @add_password_request.username]
         | 
| 112 | 
            -
                              new_stored_password << 'Copy'
         | 
| 113 | 
            -
                              new_stored_password << 'Show'
         | 
| 114 | 
            -
                              new_stored_password << 'Delete'
         | 
| 115 | 
            -
                              @stored_passwords << new_stored_password
         | 
| 116 | 
            -
                              @add_password_request.website_title = ''
         | 
| 117 | 
            -
                              @add_password_request.username = ''
         | 
| 118 | 
            -
                              @add_password_request.password = ''
         | 
| 119 | 
            -
                              @add_password_request.password_confirmation = ''
         | 
| 120 | 
            -
                            end
         | 
| 121 | 
            -
                          end
         | 
| 122 | 
            -
                        }
         | 
| 123 | 
            -
                        button('Update Master Password') {
         | 
| 124 | 
            -
                          on_clicked do
         | 
| 125 | 
            -
                            update_master_password_request = Adamantite::GUI::Request::UpdateMasterPasswordRequest.new(@adamantite_object)
         | 
| 126 | 
            -
                            update_master_password_screen(update_master_password_request: update_master_password_request).show
         | 
| 127 | 
            -
                          end
         | 
| 128 | 
            -
                        }
         | 
| 123 | 
            +
                      button('Update Master Password') {
         | 
| 124 | 
            +
                        on_clicked do
         | 
| 125 | 
            +
                          update_master_password_request = Adamantite::GUI::Request::UpdateMasterPasswordRequest.new(@adamantite_object)
         | 
| 126 | 
            +
                          update_master_password_screen(update_master_password_request: update_master_password_request).show
         | 
| 127 | 
            +
                        end
         | 
| 129 128 | 
             
                      }
         | 
| 130 129 | 
             
                    }
         | 
| 131 130 | 
             
                  }
         | 
| @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            require "base/password_object"
         | 
| 2 | 
            +
            require "file_utils/file_utils"
         | 
| 3 | 
            +
            require "pw_utils/pw_utils"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Adamantite
         | 
| 6 | 
            +
              module Base
         | 
| 7 | 
            +
                module Editor
         | 
| 8 | 
            +
                  class PasswordObjectEditor
         | 
| 9 | 
            +
                    include FileUtils
         | 
| 10 | 
            +
                    include PWUtils
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    # editable_user provides the temporary user object for editing
         | 
| 13 | 
            +
                    attr_reader :editable_password_object
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    # initializes a user editor with nil when creating a new user
         | 
| 16 | 
            +
                    # or with an existing user when editing an existing user
         | 
| 17 | 
            +
                    def initialize(master_pw, master_pw_salt, password_object = nil)
         | 
| 18 | 
            +
                      @password_object = password_object || PasswordObject.new
         | 
| 19 | 
            +
                      @master_pw = master_pw
         | 
| 20 | 
            +
                      @master_pw_salt = master_pw_salt
         | 
| 21 | 
            +
                      reset_editable_password_object
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    def reset_editable_password_object
         | 
| 25 | 
            +
                      @editable_password_object = PasswordObject.new
         | 
| 26 | 
            +
                      @editable_password_object.website_title = @password_object.website_title
         | 
| 27 | 
            +
                      @editable_password_object.username = @password_object.username
         | 
| 28 | 
            +
                      @editable_password_object.password = @password_object.password
         | 
| 29 | 
            +
                      @editable_password_object.password_confirmation = @password_object.password_confirmation
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    # saves editable user data and returns final user to add to DB/File/Array/etc...
         | 
| 33 | 
            +
                    def save
         | 
| 34 | 
            +
                      return false unless @password_object.password == @password_object.password_confirmation
         | 
| 35 | 
            +
                      @password_object.website_title = @editable_password_object.website_title
         | 
| 36 | 
            +
                      @password_object.username = @editable_password_object.username
         | 
| 37 | 
            +
                      @password_object.password = @editable_password_object.password
         | 
| 38 | 
            +
                      @password_object.password_confirmation = @editable_password_object.password_confirmation
         | 
| 39 | 
            +
                      pw_info_for_file = make_pw_info(@password_object.username, @password_object.password, @master_pw, @master_pw_salt)
         | 
| 40 | 
            +
                      write_pw_to_file(@password_object.website_title, **pw_info_for_file)
         | 
| 41 | 
            +
                      @password_object
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    def cancel
         | 
| 45 | 
            +
                      reset_editable_password_object
         | 
| 46 | 
            +
                      nil
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            module Adamantite
         | 
| 2 | 
            +
              module Base
         | 
| 3 | 
            +
                class PasswordObject
         | 
| 4 | 
            +
                  attr_accessor :website_title, :username, :password, :password_confirmation, :row_index
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def initialize(website_title = nil, username = nil, password = nil, password_confirmation = nil, row_index = nil)
         | 
| 7 | 
            +
                    @website_title = website_title
         | 
| 8 | 
            +
                    @username = username
         | 
| 9 | 
            +
                    @password = password
         | 
| 10 | 
            +
                    @password_confirmation = password_confirmation
         | 
| 11 | 
            +
                    @row_index = row_index
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,72 @@ | |
| 1 | 
            +
            require "base/editor/password_object_editor"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Adamantite
         | 
| 4 | 
            +
              module GUI
         | 
| 5 | 
            +
                module Form
         | 
| 6 | 
            +
                  class PasswordObjectFormWindow
         | 
| 7 | 
            +
                    include Glimmer::LibUI::CustomWindow
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                    # This holds the final user produced by the form
         | 
| 10 | 
            +
                    # And, a user can be optionally passed (e.g. `user_form(user: someuser)`) when editing an existing user
         | 
| 11 | 
            +
                    option :password_object, default: nil
         | 
| 12 | 
            +
                    option :on_save, default: lambda { |password_object| }
         | 
| 13 | 
            +
                    option :master_pw
         | 
| 14 | 
            +
                    option :master_pw_salt
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    before_body do
         | 
| 17 | 
            +
                      @password_object_editor = Adamantite::Base::Editor::PasswordObjectEditor.new(master_pw, master_pw_salt, password_object)
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    body {
         | 
| 21 | 
            +
                      window('Password Form', 50, 50) { |password_object_form_editor|
         | 
| 22 | 
            +
                        margined true
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                        vertical_box {
         | 
| 25 | 
            +
                          form {
         | 
| 26 | 
            +
                            entry {
         | 
| 27 | 
            +
                              label 'Website Title'
         | 
| 28 | 
            +
                              text <=> [@password_object_editor.editable_password_object, :website_title]
         | 
| 29 | 
            +
                            }
         | 
| 30 | 
            +
                            entry {
         | 
| 31 | 
            +
                              label 'Username'
         | 
| 32 | 
            +
                              text <=> [@password_object_editor.editable_password_object, :username]
         | 
| 33 | 
            +
                            }
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                            password_entry {
         | 
| 36 | 
            +
                              label 'Password'
         | 
| 37 | 
            +
                              text <=> [@password_object_editor.editable_password_object, :password]
         | 
| 38 | 
            +
                            }
         | 
| 39 | 
            +
                            password_entry {
         | 
| 40 | 
            +
                              label 'Password Confirmation'
         | 
| 41 | 
            +
                              text <=> [@password_object_editor.editable_password_object, :password_confirmation]
         | 
| 42 | 
            +
                            }
         | 
| 43 | 
            +
                          }
         | 
| 44 | 
            +
                          horizontal_box {
         | 
| 45 | 
            +
                            stretchy false
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                            button('Save') {
         | 
| 48 | 
            +
                              on_clicked do
         | 
| 49 | 
            +
                                self.password_object = @password_object_editor.save
         | 
| 50 | 
            +
                                on_save.call(password_object)
         | 
| 51 | 
            +
                                password_object_form_editor.destroy
         | 
| 52 | 
            +
                              end
         | 
| 53 | 
            +
                            }
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                            button('Cancel') {
         | 
| 56 | 
            +
                              on_clicked do
         | 
| 57 | 
            +
                                @password_object_editor.cancel
         | 
| 58 | 
            +
                                password_object_form_editor.destroy
         | 
| 59 | 
            +
                              end
         | 
| 60 | 
            +
                            }
         | 
| 61 | 
            +
                          }
         | 
| 62 | 
            +
                        }
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                        on_closing do
         | 
| 65 | 
            +
                          @password_object_editor.cancel
         | 
| 66 | 
            +
                        end
         | 
| 67 | 
            +
                      }
         | 
| 68 | 
            +
                    }
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: adamantite
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jake Bruemmer
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-11- | 
| 11 | 
            +
            date: 2023-11-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: A local password manager written in Ruby.
         | 
| 14 14 | 
             
            email: jakebruemmer@gmail.com
         | 
| @@ -21,7 +21,10 @@ files: | |
| 21 21 | 
             
            - lib/adamantite.rb
         | 
| 22 22 | 
             
            - lib/adamantite_command_line.rb
         | 
| 23 23 | 
             
            - lib/base/adamantite.rb
         | 
| 24 | 
            +
            - lib/base/editor/password_object_editor.rb
         | 
| 25 | 
            +
            - lib/base/password_object.rb
         | 
| 24 26 | 
             
            - lib/file_utils/file_utils.rb
         | 
| 27 | 
            +
            - lib/gui/form/password_object_form_window.rb
         | 
| 25 28 | 
             
            - lib/gui/request/add_password_request.rb
         | 
| 26 29 | 
             
            - lib/gui/request/login_request.rb
         | 
| 27 30 | 
             
            - lib/gui/request/set_master_password_request.rb
         |