<commit_before># Copyright (C) 2013 <NAME> (<EMAIL>).
# Licensed under the terms of the MIT license. See LICENCE for details.

module LastPass
    class Vault
        attr_reader :accounts

        # Fetches a blob from the server and creates a vault
        def self.open_remote username, password, multifactor_password = nil, client_id = nil
            blob = Vault.fetch_blob username, password, multifactor_password, client_id
            open blob, username, password
        end

        # Creates a vault from a locally stored blob
        def self.open_local blob_filename, username, password
            # TODO: read the blob here
        end

        # Creates a vault from a blob object
        def self.open blob, username, password
            new blob, blob.encryption_key(username, password)
        end

        # Just fetches the blob, could be used to store it locally
        def self.fetch_blob username, password, multifactor_password = nil, client_id = nil
            session = Fetcher.login username, password, multifactor_password, client_id
            blob = Fetcher.fetch session
            Fetcher.logout session

            blob
        end

        # This more of an internal method, use one of the static constructors instead
        def initialize blob, encryption_key
            chunks = Parser.extract_chunks blob
            if !complete? chunks
                raise InvalidResponseError, "Blob is truncated"
            end

            @accounts = parse_accounts chunks, encryption_key
        end

        def complete? chunks
            !chunks.empty? && chunks.last.id == "ENDM" && chunks.last.payload == "OK"<commit_msg>Raise not implemented in open_local<commit_after># Copyright (C) 2013 <NAME> (<EMAIL>).
# Licensed under the terms of the MIT license. See LICENCE for details.

module LastPass
    class Vault
        attr_reader :accounts

        # Fetches a blob from the server and creates a vault
        def self.open_remote username, password, multifactor_password = nil, client_id = nil
            blob = Vault.fetch_blob username, password, multifactor_password, client_id
            open blob, username, password
        end

        # Creates a vault from a locally stored blob
        def self.open_local blob_filename, username, password
            # TODO: read the blob here
            raise NotImplementedError
        end

        # Creates a vault from a blob object
        def self.open blob, username, password
            new blob, blob.encryption_key(username, password)
        end

        # Just fetches the blob, could be used to store it locally
        def self.fetch_blob username, password, multifactor_password = nil, client_id = nil
            session = Fetcher.login username, password, multifactor_password, client_id
            blob = Fetcher.fetch session
            Fetcher.logout session

            blob
        end

        # This more of an internal method, use one of the static constructors instead
        def initialize blob, encryption_key
            chunks = Parser.extract_chunks blob
            if !complete? chunks
                raise InvalidResponseError, "Blob is truncated"
            end

            @accounts = parse_accounts chunks, encryption_key
        end

        def complete? chunks
            !chunks.empty? && chunks.last.id == "ENDM" && chunks.last.payload == "OK"
{'fraction_non_alphanumeric': 0.05594817432273263, 'fraction_numerical': 0.002355712603062426, 'mean_word_length': 2.2016965127238453, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2603160', 'n_tokens_mistral': 869, 'n_tokens_neox': 830, 'n_words': 331}