Skip to content

Commit a38d173

Browse files
committed
Added an is_jwt function.
1 parent d922bcc commit a38d173

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/cryptojwt/utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import base64
2+
from binascii import unhexlify
3+
from email.message import EmailMessage
24
import functools
35
import importlib
46
import json
57
import re
68
import struct
7-
import warnings
8-
from binascii import unhexlify
9-
from email.message import EmailMessage
109
from typing import List
10+
import warnings
1111

1212
from cryptojwt.exception import BadSyntax
1313

@@ -357,3 +357,11 @@ def is_json_jws(token):
357357
return False
358358

359359
return True
360+
361+
362+
def is_jws(token):
363+
if is_json_jws(token):
364+
return 'json'
365+
elif is_compact_jws(token):
366+
return 'compact'
367+
return False

0 commit comments

Comments
 (0)