summaryrefslogtreecommitdiff
path: root/sleekxmpp/thirdparty
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/thirdparty')
-rw-r--r--sleekxmpp/thirdparty/mini_dateutil.py5
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/__init__.py3
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/cram_md5.py2
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/digest_md5.py2
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/facebook_platform.py39
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/google_token.py22
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/messenger_oauth2.py17
-rw-r--r--sleekxmpp/thirdparty/suelta/mechanisms/plain.py2
-rw-r--r--sleekxmpp/thirdparty/suelta/saslprep.py2
9 files changed, 89 insertions, 5 deletions
diff --git a/sleekxmpp/thirdparty/mini_dateutil.py b/sleekxmpp/thirdparty/mini_dateutil.py
index 6af5ffde..d0d3f2ea 100644
--- a/sleekxmpp/thirdparty/mini_dateutil.py
+++ b/sleekxmpp/thirdparty/mini_dateutil.py
@@ -67,6 +67,7 @@
import re
+import math
import datetime
@@ -240,12 +241,12 @@ except:
if frac != None:
# ok, fractions of hour?
if min == None:
- frac, min = _math.modf(frac * 60.0)
+ frac, min = math.modf(frac * 60.0)
min = int(min)
# fractions of second?
if s == None:
- frac, s = _math.modf(frac * 60.0)
+ frac, s = math.modf(frac * 60.0)
s = int(s)
# and extract microseconds...
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/__init__.py b/sleekxmpp/thirdparty/suelta/mechanisms/__init__.py
index 5cb2ee3d..2044ff80 100644
--- a/sleekxmpp/thirdparty/suelta/mechanisms/__init__.py
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/__init__.py
@@ -3,3 +3,6 @@ from sleekxmpp.thirdparty.suelta.mechanisms.plain import PLAIN
from sleekxmpp.thirdparty.suelta.mechanisms.cram_md5 import CRAM_MD5
from sleekxmpp.thirdparty.suelta.mechanisms.digest_md5 import DIGEST_MD5
from sleekxmpp.thirdparty.suelta.mechanisms.scram_hmac import SCRAM_HMAC
+from sleekxmpp.thirdparty.suelta.mechanisms.messenger_oauth2 import X_MESSENGER_OAUTH2
+from sleekxmpp.thirdparty.suelta.mechanisms.facebook_platform import X_FACEBOOK_PLATFORM
+from sleekxmpp.thirdparty.suelta.mechanisms.google_token import X_GOOGLE_TOKEN
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/cram_md5.py b/sleekxmpp/thirdparty/suelta/mechanisms/cram_md5.py
index ba44befe..e07bb883 100644
--- a/sleekxmpp/thirdparty/suelta/mechanisms/cram_md5.py
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/cram_md5.py
@@ -33,7 +33,7 @@ class CRAM_MD5(Mechanism):
if 'savepass' not in self.values:
del self.values['password']
- def process(self, challenge):
+ def process(self, challenge=None):
"""
"""
if challenge is None:
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/digest_md5.py b/sleekxmpp/thirdparty/suelta/mechanisms/digest_md5.py
index 5492c553..890f3e24 100644
--- a/sleekxmpp/thirdparty/suelta/mechanisms/digest_md5.py
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/digest_md5.py
@@ -1,8 +1,10 @@
import sys
import random
+import hmac
from sleekxmpp.thirdparty.suelta.util import hash, bytes, quote
+from sleekxmpp.thirdparty.suelta.util import num_to_bytes, bytes_to_num
from sleekxmpp.thirdparty.suelta.sasl import Mechanism, register_mechanism
from sleekxmpp.thirdparty.suelta.exceptions import SASLError, SASLCancelled
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/facebook_platform.py b/sleekxmpp/thirdparty/suelta/mechanisms/facebook_platform.py
new file mode 100644
index 00000000..cb0f09d5
--- /dev/null
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/facebook_platform.py
@@ -0,0 +1,39 @@
+from sleekxmpp.thirdparty.suelta.util import bytes
+from sleekxmpp.thirdparty.suelta.sasl import Mechanism, register_mechanism
+
+try:
+ import urlparse
+except ImportError:
+ import urllib.parse as urlparse
+
+
+
+class X_FACEBOOK_PLATFORM(Mechanism):
+
+ def __init__(self, sasl, name):
+ super(X_FACEBOOK_PLATFORM, self).__init__(sasl, name)
+ self.check_values(['access_token', 'api_key'])
+
+ def process(self, challenge=None):
+ if challenge is not None:
+ values = {}
+ for kv in challenge.split(b'&'):
+ key, value = kv.split(b'=')
+ values[key] = value
+
+ resp_data = {
+ b'method': values[b'method'],
+ b'v': b'1.0',
+ b'call_id': b'1.0',
+ b'nonce': values[b'nonce'],
+ b'access_token': self.values['access_token'],
+ b'api_key': self.values['api_key']
+ }
+ resp = '&'.join(['%s=%s' % (k, v) for k, v in resp_data.items()])
+ return bytes(resp)
+ return b''
+
+ def okay(self):
+ return True
+
+register_mechanism('X-FACEBOOK-PLATFORM', 40, X_FACEBOOK_PLATFORM, use_hashes=False)
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/google_token.py b/sleekxmpp/thirdparty/suelta/mechanisms/google_token.py
new file mode 100644
index 00000000..e641bb91
--- /dev/null
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/google_token.py
@@ -0,0 +1,22 @@
+from sleekxmpp.thirdparty.suelta.util import bytes
+from sleekxmpp.thirdparty.suelta.sasl import Mechanism, register_mechanism
+from sleekxmpp.thirdparty.suelta.exceptions import SASLError, SASLCancelled
+
+
+
+class X_GOOGLE_TOKEN(Mechanism):
+
+ def __init__(self, sasl, name):
+ super(X_GOOGLE_TOKEN, self).__init__(sasl, name)
+ self.check_values(['email', 'access_token'])
+
+ def process(self, challenge=None):
+ email = bytes(self.values['email'])
+ token = bytes(self.values['access_token'])
+ return b'\x00' + email + b'\x00' + token
+
+ def okay(self):
+ return True
+
+
+register_mechanism('X-GOOGLE-TOKEN', 3, X_GOOGLE_TOKEN, use_hashes=False)
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/messenger_oauth2.py b/sleekxmpp/thirdparty/suelta/mechanisms/messenger_oauth2.py
new file mode 100644
index 00000000..f5b0ddec
--- /dev/null
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/messenger_oauth2.py
@@ -0,0 +1,17 @@
+from sleekxmpp.thirdparty.suelta.util import bytes
+from sleekxmpp.thirdparty.suelta.sasl import Mechanism, register_mechanism
+
+
+class X_MESSENGER_OAUTH2(Mechanism):
+
+ def __init__(self, sasl, name):
+ super(X_MESSENGER_OAUTH2, self).__init__(sasl, name)
+ self.check_values(['access_token'])
+
+ def process(self, challenge=None):
+ return bytes(self.values['access_token'])
+
+ def okay(self):
+ return True
+
+register_mechanism('X-MESSENGER-OAUTH2', 10, X_MESSENGER_OAUTH2, use_hashes=False)
diff --git a/sleekxmpp/thirdparty/suelta/mechanisms/plain.py b/sleekxmpp/thirdparty/suelta/mechanisms/plain.py
index ab17095e..accae54a 100644
--- a/sleekxmpp/thirdparty/suelta/mechanisms/plain.py
+++ b/sleekxmpp/thirdparty/suelta/mechanisms/plain.py
@@ -58,4 +58,4 @@ class PLAIN(Mechanism):
return True
-register_mechanism('PLAIN', 1, PLAIN, use_hashes=False)
+register_mechanism('PLAIN', 5, PLAIN, use_hashes=False)
diff --git a/sleekxmpp/thirdparty/suelta/saslprep.py b/sleekxmpp/thirdparty/suelta/saslprep.py
index fe58d58b..8022e1cd 100644
--- a/sleekxmpp/thirdparty/suelta/saslprep.py
+++ b/sleekxmpp/thirdparty/suelta/saslprep.py
@@ -16,7 +16,7 @@ def saslprep(text, strict=True):
if sys.version_info < (3, 0):
if type(text) == str:
- text = text.decode('us-ascii')
+ text = text.decode('utf-8')
# Mapping:
#