@@ -17,8 +17,8 @@ class SharingClient:
1717
1818 Methods:
1919 refresh_keys: Refresh encryption keys from UID2 servers
20- encrypt_raw_uid_into_sharing_token : encrypt a raw UID2 into a sharing token
21- decrypt_sharing_token_into_raw_uid : decrypt a sharing token
20+ encrypt_raw_uid_into_token : encrypt a raw UID2 into a sharing token
21+ decrypt_token_into_raw_uid : decrypt a sharing token
2222 """
2323
2424 def __init__ (self , base_url , auth_key , secret_key ):
@@ -37,25 +37,28 @@ def __init__(self, base_url, auth_key, secret_key):
3737 self ._auth_key = auth_key
3838 self ._secret_key = base64 .b64decode (secret_key )
3939
40- def encrypt_raw_uid_into_token (self , uid2 , keyset_id = None , now = None ):
40+ def _encrypt_raw_uid_into_token (self , uid2 , keyset_id = None , now = None ):
41+ return encrypt (uid2 , None , self ._keys , keyset_id , now = now )
42+
43+ def _decrypt_token_into_raw_uid (self , token , now = None ):
44+ return decrypt_token (token , self ._keys , None , ClientType .Sharing , now )
45+
46+ def encrypt_raw_uid_into_token (self , uid2 , keyset_id = None ):
4147 """ Encrypt a UID2 into a sharing token
4248
4349 Args:
4450 uid2: the UID2 or EUID to be encrypted
45- keys (EncryptionKeysCollection): collection of keys to choose from for encryption
4651 keyset_id (int) : An optional keyset id to use for the encryption. Will use default keyset if left blank
47- now (Datetime): the datettime to use for now. Defaults to utc now
4852
4953 Returns (str): Sharing Token
5054 """
51- return encrypt (uid2 , None , self . _keys , keyset_id , now = now )
55+ return self . _encrypt_raw_uid_into_token (uid2 , keyset_id , dt . datetime . now ( tz = dt . timezone . utc ) )
5256
53- def decrypt_token_into_raw_uid (self , token , now = None ):
57+ def decrypt_token_into_raw_uid (self , token ):
5458 """Decrypt sharing token to extract UID2 details.
5559
5660 Args:
5761 token (str): sharing token to decrypt
58- now (datetime): date/time to use as "now" when doing token expiration check
5962
6063 Returns:
6164 DecryptedToken: details extracted from the sharing token
@@ -64,7 +67,7 @@ def decrypt_token_into_raw_uid(self, token, now=None):
6467 EncryptionError: if token version is not supported, the token has expired,
6568 or no required decryption keys present in the keys collection
6669 """
67- return decrypt_token (token , self . _keys , None , ClientType . Sharing , now )
70+ return self . _decrypt_token_into_raw_uid (token , dt . datetime . now ( tz = dt . timezone . utc ) )
6871
6972 def refresh_keys (self ):
7073 """Get the latest encryption keys for sharing tokens.
0 commit comments