From 0d642c5bec52ed621309a1dd1d62a4cb87946af9 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Fri, 29 Sep 2023 14:09:29 +0300 Subject: [PATCH] fix(crypto): revert crypto module name --- lib/pubnub/{cryptor.rb => crypto.rb} | 2 +- lib/pubnub/events/history.rb | 2 +- lib/pubnub/formatter.rb | 2 +- lib/pubnub/subscribe_event/formatter.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename lib/pubnub/{cryptor.rb => crypto.rb} (99%) diff --git a/lib/pubnub/cryptor.rb b/lib/pubnub/crypto.rb similarity index 99% rename from lib/pubnub/cryptor.rb rename to lib/pubnub/crypto.rb index b61d0b368..6402b97d8 100644 --- a/lib/pubnub/cryptor.rb +++ b/lib/pubnub/crypto.rb @@ -1,7 +1,7 @@ # Toplevel Pubnub module. module Pubnub # Internal Crypto class used for message encryption and decryption - class Cryptor + class Crypto def initialize(cipher_key, use_random_iv) @alg = 'AES-256-CBC' sha256_key = Digest::SHA256.hexdigest(cipher_key.to_s) diff --git a/lib/pubnub/events/history.rb b/lib/pubnub/events/history.rb index b9812956d..e03f705c4 100644 --- a/lib/pubnub/events/history.rb +++ b/lib/pubnub/events/history.rb @@ -82,7 +82,7 @@ def valid_envelope(parsed_response, req_res_objects) if (@cipher_key || @app.env[:cipher_key] || @cipher_key_selector || @app.env[:cipher_key_selector]) && messages cipher_key = compute_cipher_key(parsed_response) random_iv = compute_random_iv(parsed_response) - crypto = Cryptor.new(cipher_key, random_iv) + crypto = Crypto.new(cipher_key, random_iv) messages = messages.map { |message| decrypt_history(message, crypto) } end diff --git a/lib/pubnub/formatter.rb b/lib/pubnub/formatter.rb index af86c4366..423b20c8f 100644 --- a/lib/pubnub/formatter.rb +++ b/lib/pubnub/formatter.rb @@ -44,7 +44,7 @@ def format_uuid(uuids, should_encode = true) # Transforms message to json and encode it def format_message(message, cipher_key = '', use_random_iv = false, uri_escape = true) if cipher_key && !cipher_key.empty? - pc = Pubnub::Cryptor.new(cipher_key, use_random_iv) + pc = Pubnub::Crypto.new(cipher_key, use_random_iv) message = pc.encrypt(message).to_json message = Addressable::URI.escape(message) if uri_escape else diff --git a/lib/pubnub/subscribe_event/formatter.rb b/lib/pubnub/subscribe_event/formatter.rb index 3f46aa9aa..633c9f328 100644 --- a/lib/pubnub/subscribe_event/formatter.rb +++ b/lib/pubnub/subscribe_event/formatter.rb @@ -43,7 +43,7 @@ def decipher_payload(message) data = message.reject { |k, _v| k == :payload } cipher_key = compute_cipher_key(data) random_iv = compute_random_iv(data) - crypto = Pubnub::Cryptor.new(cipher_key, random_iv) + crypto = Pubnub::Crypto.new(cipher_key, random_iv) JSON.parse(crypto.decrypt(message[:payload]), quirks_mode: true) rescue StandardError, UnknownCryptorError message[:payload]