Skip to content

Commit fa8905a

Browse files
Merge pull request #7 from SendSafely/v1.0.2
v1.0.2
2 parents 71c979f + c060fea commit fa8905a

File tree

9 files changed

+463
-9
lines changed

9 files changed

+463
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dist
22
build.sh
33
MANIFEST
4+
sendsafely.egg-info

LICENSE.txt

Lines changed: 419 additions & 0 deletions
Large diffs are not rendered by default.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
include README
2+
include requirements.txt

NOTICE.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright 2022 SendSafely Inc.
2+
3+
The purpose of this NOTICE.txt file is to contain notices that are
4+
required by the copyright owners of the incorporated third party components
5+
noted and the respective licenses.
6+
Some of the accompanying products have an attribution requirement
7+
and are set forth below. Other accompanying products do not require
8+
attribution, so are not listed. See also the LICENSE.txt file.
9+
10+
11+
Requests
12+
-----------------
13+
Copyright 2019 Kenneth Reitz
14+
This product includes software developed by Kenneth Reitz
15+

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
requests~=2.24.0
2-
PGPy~=0.5.3
2+
PGPy~=0.6

sendsafely/Package.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import math
33
import os
44
import requests
5+
from cryptography import CryptographyDeprecationWarning
56
from pgpy import PGPMessage
67
from sendsafely.Progress import Progress
8+
import warnings
79

810
from sendsafely.exceptions import CreatePackageFailedException, FinalizePackageFailedException, DownloadFileException, \
911
UploadFileException, DeletePackageException, KeycodeRequiredException, GetPackageInformationFailedException, \
@@ -27,6 +29,7 @@ def __init__(self, sendsafely_instance, package_variables=None):
2729
:param package_variables:
2830
"""
2931
super().__init__()
32+
warnings.filterwarnings('ignore', category=CryptographyDeprecationWarning)
3033
self.initialized_via_keycode = True
3134
if package_variables is None:
3235
self.client_secret = _generate_keycode()
@@ -283,11 +286,14 @@ def delete_file_from_package(self, file_id):
283286
raise DeleteFileException(details=response["message"])
284287
return response
285288

286-
def get_file_information(self, file_id):
289+
def get_file_information(self, file_id, directory_id=None):
287290
"""
288291
Return the file information for a specified fileId
289292
"""
290-
endpoint = "/package/" + self.package_id + "/file/" + file_id
293+
if directory_id:
294+
endpoint = "/package/" + self.package_id + "/directory/" + directory_id + "/file/" + file_id
295+
else:
296+
endpoint = "/package/" + self.package_id + "/file/" + file_id
291297
url = self.sendsafely.BASE_URL + endpoint
292298
headers = make_headers(self.sendsafely.API_SECRET, self.sendsafely.API_KEY, endpoint)
293299
response = requests.get(url=url, headers=headers).json()
@@ -300,7 +306,7 @@ def download_and_decrypt_file(self, file_id, directory_id=None, download_directo
300306
Downloads & decrypts the specified file to the path specified
301307
"""
302308
self._block_operation_without_keycode()
303-
file_info = self.get_file_information(file_id)
309+
file_info = self.get_file_information(file_id, directory_id)
304310
if not file_name:
305311
file_name = file_info["fileName"]
306312
total = file_info["fileParts"]

sendsafely/SendSafely.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import json
22
import re
3+
import warnings
4+
35
import requests
46
import pgpy
7+
from cryptography import CryptographyDeprecationWarning
58
from pgpy import PGPMessage
69
from pgpy.constants import KeyFlags, HashAlgorithm, SymmetricKeyAlgorithm, CompressionAlgorithm
710
from sendsafely.Package import Package
@@ -24,6 +27,7 @@ class SendSafely:
2427

2528
def __init__(self, url, api_key, api_secret):
2629
super().__init__()
30+
warnings.filterwarnings('ignore', category=CryptographyDeprecationWarning)
2731
self.BASE_URL = url + self.API_URL
2832
self.API_KEY = api_key
2933
self.API_SECRET = api_secret
@@ -124,7 +128,11 @@ def get_package_keycode(self, package_id, public_key_id=None, private_key=None):
124128
url = self.BASE_URL + endpoint
125129
headers = make_headers(self.API_SECRET, self.API_KEY, endpoint)
126130
try:
127-
keycode = requests.get(url, headers=headers).json()["message"]
131+
keycode_json = requests.get(url, headers=headers).json();
132+
keycode = keycode_json['message'];
133+
if keycode_json['response'] == 'FAIL':
134+
raise GetKeycodeFailedException(details=str(keycode))
135+
128136
key_pair = pgpy.PGPKey.from_blob(str(private_key))[0]
129137
keycode_message = PGPMessage.from_blob(keycode)
130138
decrypted_keycode = key_pair.decrypt(keycode_message).message

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[metadata]
2-
description-file = README.md
2+
long_description = file: README.md
3+
license_files = LICENSE.txt, NOTICE.txt

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
from distutils.core import setup
1+
from setuptools import setup
22

33
setup(
44
name='sendsafely',
5-
version='1.0.1',
5+
version='1.0.2',
66
packages=['sendsafely'],
77
description='The SendSafely Client API allows programmatic access to SendSafely and provides a layer of abstraction from our REST API, which requires developers to perform several complex tasks in a correct manner.',
8+
long_description_content_type="text/markdown",
89
author='SendSafely',
910
author_email='[email protected]',
1011
url='https://github.com/SendSafely/Python-Client-API',
@@ -13,10 +14,12 @@
1314
'PGPy'
1415
],
1516
python_requires='>=3',
17+
license='Apache License Version 2.0',
1618
classifiers=[
1719
'Development Status :: 5 - Production/Stable',
1820
'Intended Audience :: Developers',
1921
'Topic :: Software Development :: Libraries :: Application Frameworks',
20-
'Programming Language :: Python :: 3'
22+
'Programming Language :: Python :: 3',
23+
'License :: OSI Approved :: Apache Software License'
2124
],
2225
)

0 commit comments

Comments
 (0)