Commit 066d34e 1 parent d978caa commit 066d34e Copy full SHA for 066d34e
File tree 4 files changed +15
-2
lines changed
4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,15 @@ script:
8
8
branches :
9
9
only :
10
10
- master
11
- - feature-jwt-string
12
11
notifications :
13
12
slack :
14
13
secure : UIG9+o5gRYZGpRRBIB/9nFBoXvSOI3Ll63KuUMd/u/CvFpByLY0MSX5LY18v6hYqA3UNjEhOO9x1j91H7JOjbI0NYtq/7+qehUDWORaQc+NSUozKLmkIGm1M6RYayUw61J9fYpyt8AjpbGIb78i7T8ckz7dYkyhEJcGz7L+30pw=
15
14
env :
16
15
matrix :
17
- - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="9.1" CARTHAGE_BUILD_PLATFORM="iOS"
16
+ - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="9.1" CARTHAGE_BUILD_PLATFORM="iOS"
17
+ - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="9.0" CARTHAGE_BUILD_PLATFORM="iOS"
18
+ - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="8.4" CARTHAGE_BUILD_PLATFORM="iOS"
19
+ - SCHEME="JWTDecode-OSX" CARTHAGE_BUILD_PLATFORM="Mac"
18
20
global :
19
21
- secure : hHc0uhSg57mTBfFUX7ZwZe85IlLMS+mMgOx192fnVyeD81S2AFxaO4nWRpXHktkR68HwDsYJ4emVeoaLxZb8tkkej+nf1L3NIY3FFEJpIEAmrYMv9AoFb0ZtT1IwGOt92bll0DqzZotOVOrPVZeS8MspwZAFqXHAgBszfJut/2w=
20
22
- secure : dYWR8CvhN1g1ta3+ARWO5wYUIhhA5BjTKE29Df+URdNVuJMvvtNwuE8YpI9yKKz/rp9PbKo+6jAMozbiokj2Baf8xOawQvyiRWA7c5YRslM2oNuVX33yl949JMzpJmKRJiFi59lbu8gAmI090cHiG9HVw7etpNMy3JGCx9GIJhc=
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ public protocol JWT {
32
32
var body : [ String : AnyObject ] { get }
33
33
/// token signature part
34
34
var signature : String ? { get }
35
+ /// jwt string value
36
+ var stringValue : String { get }
37
+
35
38
36
39
/// value of `exp` claim if available
37
40
var expiresAt : NSDate ? { get }
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ struct DecodedJWT: JWT {
39
39
let header : [ String : AnyObject ]
40
40
let body : [ String : AnyObject ]
41
41
let signature : String ?
42
+ let stringValue : String
42
43
43
44
init ( jwt: String ) throws {
44
45
let parts = jwt. componentsSeparatedByString ( " . " )
@@ -49,6 +50,7 @@ struct DecodedJWT: JWT {
49
50
self . header = try decodeJWTPart ( parts [ 0 ] )
50
51
self . body = try decodeJWTPart ( parts [ 1 ] )
51
52
self . signature = parts [ 2 ]
53
+ self . stringValue = jwt
52
54
}
53
55
54
56
var expiresAt : NSDate ? { return claim ( " exp " ) }
Original file line number Diff line number Diff line change @@ -47,6 +47,12 @@ class JWTDecodeSpec: QuickSpec {
47
47
expect ( payload) . to ( equal ( [ " sub " : " myid " , " name " : " Shawarma Monk " ] ) )
48
48
}
49
49
50
+ it ( " should return original jwt string representation " ) {
51
+ let jwtString = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjb20uc29td2hlcmUuZmFyLmJleW9uZDphcGkiLCJpc3MiOiJhdXRoMCIsInVzZXJfcm9sZSI6ImFkbWluIn0.sS84motSLj9HNTgrCPcAjgZIQ99jXNN7_W9fEIIfxz0 "
52
+ let jwt = try ! decode ( jwtString)
53
+ expect ( jwt. stringValue) . to ( equal ( jwtString) )
54
+ }
55
+
50
56
it ( " should return expire date " ) {
51
57
expect ( expiredJWT ( ) . expiresAt) . toNot ( beNil ( ) )
52
58
}
You can’t perform that action at this time.
0 commit comments