diff --git a/demo.py b/demo.py index 19a2e6d..39bd5e0 100644 --- a/demo.py +++ b/demo.py @@ -42,7 +42,7 @@ except FileNotFoundError: CONFIG = {} # Re-register if the commit hash has changed -if CONFIG.get("commit_hash") != commit_hash: +if CONFIG.get("commit_hash") != commit_hash or True: logging.warning("pypush commit is different, forcing re-registration...") CONFIG["commit_hash"] = commit_hash if "id" in CONFIG: diff --git a/ids/__init__.py b/ids/__init__.py index d6afd76..d15c878 100644 --- a/ids/__init__.py +++ b/ids/__init__.py @@ -59,6 +59,7 @@ class IDSUser: self.user_id = user_id self.handles = handles self.current_handle = self.handles[0] + self.ngm = encryption.NGMIdentity(self.extra.get("device_key"), self.extra.get("prekey")) # This is a separate call so that the user can make sure the first part succeeds before asking for validation data def register(self, validation_data: str): @@ -67,7 +68,6 @@ class IDSUser: if they are not already set """ - self.ngm = encryption.NGMIdentity(self.extra.get("device_key"), self.extra.get("prekey")) self.extra["device_key"] = self.ngm.device_key self.extra["prekey"] = self.ngm.pre_key @@ -90,8 +90,7 @@ class IDSUser: self._id_keypair = id_keypair def auth_and_set_encryption_from_config(self, config: dict[str, dict[str, Any]]): - if "extra" in config: - self.extra = config["extra"] + self.extra = config.get("extra", {}) auth = config.get("auth", {}) if ( diff --git a/ids/encryption.py b/ids/encryption.py index db79d9c..368f236 100644 --- a/ids/encryption.py +++ b/ids/encryption.py @@ -16,17 +16,12 @@ class NGMIdentity: self.device_key = device_key self.pre_key = pre_key - @staticmethod - def serialize_timestamp(timestamp: float): - import struct - return struct.pack("