diff --git a/.gitignore b/.gitignore index 0e43357..ecf8457 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,4 @@ DerivedData .bundle Pods/ -Carthage/ -!Carthage/Checkouts +Carthage/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1b5f572..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "Carthage/Checkouts/Quick"] - path = Carthage/Checkouts/Quick - url = https://github.com/Quick/Quick.git -[submodule "Carthage/Checkouts/Nimble"] - path = Carthage/Checkouts/Nimble - url = https://github.com/Quick/Nimble.git diff --git a/.travis.yml b/.travis.yml index 6c97740..38c91a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,22 @@ reference: http://www.objc.io/issue-6/travis-ci.html language: objective-c -osx_image: xcode7 +osx_image: xcode7.1 before_install: true install: true -git: - submodules: false -script: - - script/cibuild +script: +- script/cibuild branches: only: - master notifications: slack: secure: UIG9+o5gRYZGpRRBIB/9nFBoXvSOI3Ll63KuUMd/u/CvFpByLY0MSX5LY18v6hYqA3UNjEhOO9x1j91H7JOjbI0NYtq/7+qehUDWORaQc+NSUozKLmkIGm1M6RYayUw61J9fYpyt8AjpbGIb78i7T8ckz7dYkyhEJcGz7L+30pw= +env: + matrix: + - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="9.1" CARTHAGE_BUILD_PLATFORM="iOS" + - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="9.0" CARTHAGE_BUILD_PLATFORM="iOS" + - SCHEME="JWTDecode-iOS" IOS_DESTINATION_VERSION="8.4" CARTHAGE_BUILD_PLATFORM="iOS" + - SCHEME="JWTDecode-OSX" CARTHAGE_BUILD_PLATFORM="Mac" + global: + - secure: hHc0uhSg57mTBfFUX7ZwZe85IlLMS+mMgOx192fnVyeD81S2AFxaO4nWRpXHktkR68HwDsYJ4emVeoaLxZb8tkkej+nf1L3NIY3FFEJpIEAmrYMv9AoFb0ZtT1IwGOt92bll0DqzZotOVOrPVZeS8MspwZAFqXHAgBszfJut/2w= + - secure: dYWR8CvhN1g1ta3+ARWO5wYUIhhA5BjTKE29Df+URdNVuJMvvtNwuE8YpI9yKKz/rp9PbKo+6jAMozbiokj2Baf8xOawQvyiRWA7c5YRslM2oNuVX33yl949JMzpJmKRJiFi59lbu8gAmI090cHiG9HVw7etpNMy3JGCx9GIJhc= diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble deleted file mode 160000 index e239824..0000000 --- a/Carthage/Checkouts/Nimble +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e239824d84105de9e13b815006bc36e938cdd030 diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick deleted file mode 160000 index b47b9eb..0000000 --- a/Carthage/Checkouts/Quick +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b47b9ebf97bc8e377070bd1e868c9f89b870c4fc diff --git a/JWTDecode.xcodeproj/project.pbxproj b/JWTDecode.xcodeproj/project.pbxproj index 4a41b12..82d3394 100644 --- a/JWTDecode.xcodeproj/project.pbxproj +++ b/JWTDecode.xcodeproj/project.pbxproj @@ -16,18 +16,22 @@ 5F00693D1B3C7B630048928E /* JWTDecode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F0068E71B3B46240048928E /* JWTDecode.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5F00693E1B3C7B930048928E /* JWTDecode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F0069021B3B511F0048928E /* JWTDecode.swift */; }; 5F0069411B3C828F0048928E /* A0JWTDecodeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F0069401B3C828F0048928E /* A0JWTDecodeSpec.m */; }; - 5F05AF7F1B62E9C200C4A9E6 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F05AF7D1B62E9C200C4A9E6 /* Nimble.framework */; }; - 5F05AF801B62E9C200C4A9E6 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F05AF7D1B62E9C200C4A9E6 /* Nimble.framework */; }; - 5F05AF811B62E9C200C4A9E6 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F05AF7E1B62E9C200C4A9E6 /* Quick.framework */; }; - 5F05AF821B62E9C200C4A9E6 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F05AF7E1B62E9C200C4A9E6 /* Quick.framework */; }; - 5F8B43691B9F99B400A0D5AE /* A0JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B43681B9F99B400A0D5AE /* A0JWT.swift */; settings = {ASSET_TAGS = (); }; }; - 5F8B436A1B9F99B400A0D5AE /* A0JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B43681B9F99B400A0D5AE /* A0JWT.swift */; settings = {ASSET_TAGS = (); }; }; - 5F8B436C1B9F9EDB00A0D5AE /* JWTHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B436B1B9F9EDB00A0D5AE /* JWTHelper.swift */; settings = {ASSET_TAGS = (); }; }; - 5F8B436D1B9F9EDB00A0D5AE /* JWTHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B436B1B9F9EDB00A0D5AE /* JWTHelper.swift */; settings = {ASSET_TAGS = (); }; }; - 5FE49DCD1BA0D5F700DE57D3 /* JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCC1BA0D5F700DE57D3 /* JWT.swift */; settings = {ASSET_TAGS = (); }; }; - 5FE49DCE1BA0D5F700DE57D3 /* JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCC1BA0D5F700DE57D3 /* JWT.swift */; settings = {ASSET_TAGS = (); }; }; - 5FE49DD01BA0D66F00DE57D3 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCF1BA0D66F00DE57D3 /* Errors.swift */; settings = {ASSET_TAGS = (); }; }; - 5FE49DD11BA0D66F00DE57D3 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCF1BA0D66F00DE57D3 /* Errors.swift */; settings = {ASSET_TAGS = (); }; }; + 5F2614D81C05FE850068DE71 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F2614CD1C05FDDE0068DE71 /* Quick.framework */; }; + 5F2614D91C05FE850068DE71 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F2614CE1C05FDDE0068DE71 /* Nimble.framework */; }; + 5F2614DA1C05FE880068DE71 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F2614D41C05FE720068DE71 /* Quick.framework */; }; + 5F2614DB1C05FE880068DE71 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F2614D51C05FE720068DE71 /* Nimble.framework */; }; + 5F2614DD1C05FEB90068DE71 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5F2614CD1C05FDDE0068DE71 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 5F2614DE1C05FEB90068DE71 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5F2614CE1C05FDDE0068DE71 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 5F2614E01C05FEE20068DE71 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5F2614D41C05FE720068DE71 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 5F2614E11C05FEE20068DE71 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5F2614D51C05FE720068DE71 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 5F8B43691B9F99B400A0D5AE /* A0JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B43681B9F99B400A0D5AE /* A0JWT.swift */; }; + 5F8B436A1B9F99B400A0D5AE /* A0JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B43681B9F99B400A0D5AE /* A0JWT.swift */; }; + 5F8B436C1B9F9EDB00A0D5AE /* JWTHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B436B1B9F9EDB00A0D5AE /* JWTHelper.swift */; }; + 5F8B436D1B9F9EDB00A0D5AE /* JWTHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F8B436B1B9F9EDB00A0D5AE /* JWTHelper.swift */; }; + 5FE49DCD1BA0D5F700DE57D3 /* JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCC1BA0D5F700DE57D3 /* JWT.swift */; }; + 5FE49DCE1BA0D5F700DE57D3 /* JWT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCC1BA0D5F700DE57D3 /* JWT.swift */; }; + 5FE49DD01BA0D66F00DE57D3 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCF1BA0D66F00DE57D3 /* Errors.swift */; }; + 5FE49DD11BA0D66F00DE57D3 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FE49DCF1BA0D66F00DE57D3 /* Errors.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -47,6 +51,31 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 5F2614DC1C05FEAD0068DE71 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 5F2614DD1C05FEB90068DE71 /* Quick.framework in CopyFiles */, + 5F2614DE1C05FEB90068DE71 /* Nimble.framework in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5F2614DF1C05FEDA0068DE71 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 5F2614E01C05FEE20068DE71 /* Quick.framework in CopyFiles */, + 5F2614E11C05FEE20068DE71 /* Nimble.framework in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 5F0068E21B3B46240048928E /* JWTDecode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JWTDecode.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5F0068E61B3B46240048928E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -59,9 +88,11 @@ 5F0069221B3C4A7F0048928E /* JWTDecodeSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JWTDecodeSpec.swift; sourceTree = ""; }; 5F00693F1B3C828E0048928E /* JWTDecode-iOSTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JWTDecode-iOSTests-Bridging-Header.h"; sourceTree = ""; }; 5F0069401B3C828F0048928E /* A0JWTDecodeSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = A0JWTDecodeSpec.m; sourceTree = ""; }; - 5F05AF7D1B62E9C200C4A9E6 /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 5F05AF7E1B62E9C200C4A9E6 /* Quick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Quick.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5F0A5E291B9A6D4A005289CF /* JWTDecode.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = JWTDecode.playground; sourceTree = SOURCE_ROOT; }; + 5F2614CD1C05FDDE0068DE71 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = SOURCE_ROOT; }; + 5F2614CE1C05FDDE0068DE71 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = SOURCE_ROOT; }; + 5F2614D41C05FE720068DE71 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/Mac/Quick.framework; sourceTree = SOURCE_ROOT; }; + 5F2614D51C05FE720068DE71 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = SOURCE_ROOT; }; 5F8B43681B9F99B400A0D5AE /* A0JWT.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = A0JWT.swift; sourceTree = ""; }; 5F8B436B1B9F9EDB00A0D5AE /* JWTHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JWTHelper.swift; sourceTree = ""; }; 5FE49DCC1BA0D5F700DE57D3 /* JWT.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JWT.swift; sourceTree = ""; }; @@ -80,9 +111,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5F2614D91C05FE850068DE71 /* Nimble.framework in Frameworks */, + 5F2614D81C05FE850068DE71 /* Quick.framework in Frameworks */, 5F0068EE1B3B46240048928E /* JWTDecode.framework in Frameworks */, - 5F05AF811B62E9C200C4A9E6 /* Quick.framework in Frameworks */, - 5F05AF7F1B62E9C200C4A9E6 /* Nimble.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -97,9 +128,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5F2614DB1C05FE880068DE71 /* Nimble.framework in Frameworks */, + 5F2614DA1C05FE880068DE71 /* Quick.framework in Frameworks */, 5F0069141B3B532E0048928E /* JWTDecode.framework in Frameworks */, - 5F05AF821B62E9C200C4A9E6 /* Quick.framework in Frameworks */, - 5F05AF801B62E9C200C4A9E6 /* Nimble.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -163,13 +194,39 @@ 5F0068F21B3B46240048928E /* Supporting Files */ = { isa = PBXGroup; children = ( - 5F05AF7D1B62E9C200C4A9E6 /* Nimble.framework */, - 5F05AF7E1B62E9C200C4A9E6 /* Quick.framework */, + 5F2614D11C05FE0A0068DE71 /* Frameworks */, 5F0068F31B3B46240048928E /* Info.plist */, ); name = "Supporting Files"; sourceTree = ""; }; + 5F2614D11C05FE0A0068DE71 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5F2614D31C05FE1B0068DE71 /* OSX */, + 5F2614D21C05FE160068DE71 /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 5F2614D21C05FE160068DE71 /* iOS */ = { + isa = PBXGroup; + children = ( + 5F2614CD1C05FDDE0068DE71 /* Quick.framework */, + 5F2614CE1C05FDDE0068DE71 /* Nimble.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 5F2614D31C05FE1B0068DE71 /* OSX */ = { + isa = PBXGroup; + children = ( + 5F2614D41C05FE720068DE71 /* Quick.framework */, + 5F2614D51C05FE720068DE71 /* Nimble.framework */, + ); + name = OSX; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -217,6 +274,7 @@ 5F0068E91B3B46240048928E /* Sources */, 5F0068EA1B3B46240048928E /* Frameworks */, 5F0068EB1B3B46240048928E /* Resources */, + 5F2614DC1C05FEAD0068DE71 /* CopyFiles */, ); buildRules = ( ); @@ -253,6 +311,7 @@ 5F00690F1B3B532E0048928E /* Sources */, 5F0069101B3B532E0048928E /* Frameworks */, 5F0069111B3B532E0048928E /* Resources */, + 5F2614DF1C05FEDA0068DE71 /* CopyFiles */, ); buildRules = ( ); @@ -495,6 +554,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = JWTDecode/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -515,6 +575,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = JWTDecode/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -531,8 +592,8 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -552,8 +613,8 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = JWTDecodeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -572,6 +633,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -597,6 +659,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = JWTDecode/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -616,8 +679,8 @@ COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -637,8 +700,8 @@ buildSettings = { COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/Mac", ); INFOPLIST_FILE = JWTDecodeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; diff --git a/JWTDecode.xcworkspace/contents.xcworkspacedata b/JWTDecode.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 69deb40..0000000 --- a/JWTDecode.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/JWTDecode/JWT.swift b/JWTDecode/JWT.swift index beead65..50fda04 100644 --- a/JWTDecode/JWT.swift +++ b/JWTDecode/JWT.swift @@ -32,6 +32,9 @@ public protocol JWT { var body: [String: AnyObject] { get } /// token signature part var signature: String? { get } + /// jwt string value + var stringValue: String { get } + /// value of `exp` claim if available var expiresAt: NSDate? { get } diff --git a/JWTDecode/JWTDecode.swift b/JWTDecode/JWTDecode.swift index 3d2dca1..37a6cf3 100644 --- a/JWTDecode/JWTDecode.swift +++ b/JWTDecode/JWTDecode.swift @@ -39,6 +39,7 @@ struct DecodedJWT: JWT { let header: [String: AnyObject] let body: [String: AnyObject] let signature: String? + let stringValue: String init(jwt: String) throws { let parts = jwt.componentsSeparatedByString(".") @@ -49,6 +50,7 @@ struct DecodedJWT: JWT { self.header = try decodeJWTPart(parts[0]) self.body = try decodeJWTPart(parts[1]) self.signature = parts[2] + self.stringValue = jwt } var expiresAt: NSDate? { return claim("exp") } diff --git a/JWTDecodeTests/JWTDecodeSpec.swift b/JWTDecodeTests/JWTDecodeSpec.swift index e60079a..90eabd2 100644 --- a/JWTDecodeTests/JWTDecodeSpec.swift +++ b/JWTDecodeTests/JWTDecodeSpec.swift @@ -47,6 +47,12 @@ class JWTDecodeSpec: QuickSpec { expect(payload).to(equal(["sub": "myid", "name": "Shawarma Monk"])) } + it("should return original jwt string representation") { + let jwtString = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjb20uc29td2hlcmUuZmFyLmJleW9uZDphcGkiLCJpc3MiOiJhdXRoMCIsInVzZXJfcm9sZSI6ImFkbWluIn0.sS84motSLj9HNTgrCPcAjgZIQ99jXNN7_W9fEIIfxz0" + let jwt = try! decode(jwtString) + expect(jwt.stringValue).to(equal(jwtString)) + } + it("should return expire date") { expect(expiredJWT().expiresAt).toNot(beNil()) } diff --git a/script/.env b/script/.env index 044351b..ec6e5fc 100644 --- a/script/.env +++ b/script/.env @@ -1,4 +1,13 @@ +REQUIRED_CARTHAGE_VERSION=0.10 +CARTHAGE_BUILD_PLATFORM=${CARTHAGE_BUILD_PLATFORM:-"iOS"} +CARTHAGE_NO_USE_BINARIES=${CARTHAGE_NO_USE_BINARIES:-"true"} PROJECT_NAME=JWTDecode -XCODE_WORKSPACE=JWTDecode.xcworkspace -XCODE_PROJECT= +XCODE_WORKSPACE= +XCODE_PROJECT=JWTDecode.xcodeproj +IOS_DESTINATION_VERSION=${IOS_DESTINATION_VERSION:-"latest"} +IOS_DESTINATION_SIMULATOR_NAME=${IOS_DESTINATION_SIMULATOR_NAME:-"iPhone 6"} +OSX_DESTINATION_ARCH=${OSX_DESTINATION_ARCH:-""} +LINT_PODSPEC=${LINT_PODSPEC:-"no"} +LINT_PODSPEC_PARAMETERS=${LINT_PODSPEC_PARAMETERS:-" --allow-warnings"} +DISABLE_CARTHAGE_CACHE_CONFIG=yes diff --git a/script/bootstrap b/script/bootstrap index 6350089..007f127 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -12,10 +12,14 @@ install_homebrew () if type brew > /dev/null then echo " ✔ brew is already installed" - echo "" - echo " → Updating homebrew formulas" - brew update > /dev/null || brew update > /dev/null - echo " ✔ formulas updated" + + if [ -z "$SKIP_BREW_FORMULAS_UPDATE" ] + then + echo "" + echo " → Updating homebrew formulas" + brew update > /dev/null || brew update > /dev/null + echo " ✔ formulas updated" + fi else command -v ruby >/dev/null 2>&1 || { echo >&2 "Error: Some ruby of version is required to install homebrew. Aborting"; exit 1; } ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" @@ -87,6 +91,7 @@ bundle_install () "or try to install the gems globally by running the following command:" print_gem_install_cmd printf "\033[0m" + exit 1 fi } @@ -111,16 +116,34 @@ bootstrap_carthage () echo "" echo " → Bootstrapping Carthage" echo "" - carthage_cmd="time carthage bootstrap --platform ios" + carthage_cmd="carthage bootstrap --platform $CARTHAGE_BUILD_PLATFORM" if [ "$USE_SSH" == "true" ] then carthage_cmd="$carthage_cmd --use-ssh" fi + if [ "$USE_SUBMODULES" == "true" ] then carthage_cmd="$carthage_cmd --use-submodules --no-build" fi + + if [ "$CARTHAGE_NO_USE_BINARIES" == "true" ] + then + carthage_cmd="$carthage_cmd --no-use-binaries" + fi + + if [ -z $DISABLE_CARTHAGE_CACHE ] && type bundle > /dev/null && bundle show carthage_cache > /dev/null && [ -f .carthage_cache.yml ] + then + carthage_cmd="(bundle exec carthage_cache install || $carthage_cmd) && bundle exec carthage_cache publish" + fi + + carthage_cmd="time $carthage_cmd" + if [ ! -z "$VERBOSE" ] + then + echo $carthage_cmd + fi + eval $carthage_cmd } @@ -165,6 +188,26 @@ install_dependencies () fi } +install_carthage () +{ + source script/common/carthage + + if type carthage > /dev/null + then + echo "" + echo " → Checking installed version of carthage" + echo "" + check_carthage_version + else + force_install_carthage + fi + + if [ -z "$DISABLE_CARTHAGE_CACHE_CONFIG" ] && type bundle > /dev/null && bundle show carthage_cache > /dev/null && [ ! -f .carthage_cache.yml ] + then + bundle exec carthage_cache config + fi +} + main () { source script/.env @@ -176,15 +219,15 @@ main () install_git_hooks install_dependencies - if [ -f Cartfile ] + if [ -f Gemfile ] then - brew_install "carthage" - bootstrap_carthage + bundle_install fi - if [ -f Gemfile ] + if [ -f Cartfile.resolved ] then - bundle_install + install_carthage + bootstrap_carthage fi if [ -f Podfile ] diff --git a/script/build b/script/build index f141fb4..e0b77b0 100755 --- a/script/build +++ b/script/build @@ -2,9 +2,12 @@ set -e +source script/common/carthage + build_using_carthage () { - carthage_cmd="carthage build --no-skip-current --platform ios" + check_carthage_version + carthage_cmd="carthage build --no-skip-current --platform $CARTHAGE_BUILD_PLATFORM" if [ "$USE_SSH" == "true" ] then carthage_cmd="$carthage_cmd --use-ssh" @@ -42,7 +45,7 @@ build_using_xcodebuild () eval $build_command } -if [ ! -f $XCODE_WORKSPACE ] && [ -f Cartfile ] && type carthage > /dev/null +if [ ! -f $XCODE_WORKSPACE ] && [ -f Cartfile.resolved ] && type carthage > /dev/null then build_using_carthage else diff --git a/script/certificates/.gitkeep b/script/certificates/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/script/certificates/cibot.p12 b/script/certificates/cibot.p12 new file mode 100644 index 0000000..5605fed Binary files /dev/null and b/script/certificates/cibot.p12 differ diff --git a/script/cibuild b/script/cibuild index 1e6f793..334803b 100755 --- a/script/cibuild +++ b/script/cibuild @@ -15,7 +15,7 @@ KEYCHAIN=ios-build.keychain main () { - if [ -f Cartfile ] + if [ -f Cartfile.resolved ] && [ -f "$SCRIPT_DIR/certificates/cibot.p12" ] then echo "" echo "####### Importing Developer Certificates #######" @@ -26,7 +26,7 @@ main () echo "" echo "####### Bootstrap Phase #######" echo "" - script/bootstrap + DISABLE_CARTHAGE_CACHE_CONFIG=true NO_CARTHAGE_UPDATE=true script/bootstrap local status=$? if [ $status -eq 0 ] @@ -50,7 +50,10 @@ main () fi fi - delete_keychain + if [ -f Cartfile.resolved ] && [ -f "$SCRIPT_DIR/certificates/cibot.p12" ] + then + delete_keychain + fi exit $status } diff --git a/script/common/carthage b/script/common/carthage new file mode 100644 index 0000000..d232a49 --- /dev/null +++ b/script/common/carthage @@ -0,0 +1,58 @@ +force_install_carthage () +{ + echo "" + echo " → Installing carthage '$REQUIRED_CARTHAGE_VERSION'" + echo "" + curl -s -L -O https://github.com/Carthage/Carthage/releases/download/$REQUIRED_CARTHAGE_VERSION/Carthage.pkg > /dev/null + sudo installer -pkg Carthage.pkg -target / > /dev/null + rm Carthage.pkg + echo " ✔ carthage '$REQUIRED_CARTHAGE_VERSION' successfully installed" + echo "" +} + +uninstall_carthage () +{ + echo "" + echo " → Uninstalling carthage" + echo "" + local carthage_installed_version=`carthage version` + if type brew > /dev/null && [ ! -z "$(brew list --versions carthage)" ] + then + brew uninstall carthage > /dev/null + else + sudo rm -frd /Library/Frameworks/CarthageKit.framework + sudo rm /usr/local/bin/carthage + fi + echo " ✔ carthage '$carthage_installed_version' successfully uninstalled" +} + +check_carthage_version () +{ + local carthage_installed_version=`carthage version` + local patch_number=`echo $REQUIRED_CARTHAGE_VERSION | cut -d "." -f 4` + if [ -z $patch_number ] + then + REQUIRED_CARTHAGE_VERSION="$REQUIRED_CARTHAGE_VERSION.0" + fi + if [ "$carthage_installed_version" != "$REQUIRED_CARTHAGE_VERSION" ] + then + printf "\033[1;31mError: carthage version '$carthage_installed_version' is not equal to '$REQUIRED_CARTHAGE_VERSION'" + printf "\033[0m" + if [ ! -z "$NO_CARTHAGE_UPDATE" ] + then + exit 1 + else + echo "" + echo "" + echo "Would you like to update carthage to version '$REQUIRED_CARTHAGE_VERSION'? [N/y]" + read update_carthage + if [ "$update_carthage" == "y" ] + then + uninstall_carthage + force_install_carthage + else + exit 1 + fi + fi + fi +} diff --git a/script/script_hooks/destinations b/script/script_hooks/destinations index b26c447..03f20cb 100644 --- a/script/script_hooks/destinations +++ b/script/script_hooks/destinations @@ -1,19 +1,12 @@ #!/bin/bash -if [ -z "$DEFAULT_OSX_DESTINATION" ]; then - DEFAULT_OSX_DESTINATION="'platform=OS X'" -fi - -if [ -z "$IOS_OS_VERSION" ]; then - IOS_OS_VERSION="latest" -fi - -if [ -z "$IOS_SIMULATOR_NAME" ]; then - IOS_SIMULATOR_NAME="iPhone 6" -fi +IOS_DESTINATION="'platform=iOS Simulator,name=$IOS_DESTINATION_SIMULATOR_NAME,OS=$IOS_DESTINATION_VERSION'" -if [ -z "$DEFAULT_IOS_DESTINATION" ]; then - DEFAULT_IOS_DESTINATION="'platform=iOS Simulator,name=$IOS_SIMULATOR_NAME,OS=$IOS_OS_VERSION'" +if [ -z "$OSX_DESTINATION_ARCH" ] +then + OSX_DESTINATION="'platform=OS X'" +else + OSX_DESTINATION="'platform=OS X,arch=$OSX_DESTINATION_ARCH'" fi scheme_destination () @@ -22,13 +15,13 @@ scheme_destination () case "$1" in *iOS) - destination=$DEFAULT_IOS_DESTINATION + destination=$IOS_DESTINATION ;; *OSX) - destination=$DEFAULT_OSX_DESTINATION + destination=$OSX_DESTINATION ;; *) - destination=$DEFAULT_IOS_DESTINATION + destination=$IOS_DESTINATION ;; esac diff --git a/script/script_hooks/schemes b/script/script_hooks/schemes index 16b0b4c..fbe4d47 100755 --- a/script/script_hooks/schemes +++ b/script/script_hooks/schemes @@ -1,4 +1,9 @@ schemes () { - xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1' + if [ -z "$SCHEME" ] + then + xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1' + else + echo $SCHEME + fi } diff --git a/script/test b/script/test index a022842..9a4fbd3 100755 --- a/script/test +++ b/script/test @@ -5,6 +5,7 @@ set -e source script/.env source script/script_hooks/schemes source script/script_hooks/destinations +source script/common/carthage run_tests () { @@ -43,6 +44,11 @@ run_tests () eval $test_command } +if [ -f Cartfile.resolved ] +then + check_carthage_version +fi + current_schemes=$(schemes) if [ -z "$current_schemes" ] then diff --git a/script/update b/script/update index 751db3b..6507c89 100755 --- a/script/update +++ b/script/update @@ -3,10 +3,12 @@ set -e source script/.env +source script/common/carthage -if [ -f Cartfile ] && type carthage > /dev/null +if [ -f Cartfile.resolved ] && type carthage > /dev/null then - carthage_cmd="carthage update --platform ios" + check_carthage_version + carthage_cmd="carthage update --platform $CARTHAGE_BUILD_PLATFORM" if [ "$USE_SSH" == "true" ] then carthage_cmd="$carthage_cmd --use-ssh" @@ -15,6 +17,18 @@ then then carthage_cmd="$carthage_cmd --use-submodules --no-build" fi + if [ "$CARTHAGE_NO_USE_BINARIES" == "true" ] + then + carthage_cmd="$carthage_cmd --no-use-binaries" + fi + if [ -z $DISABLE_CARTHAGE_CACHE ] && type bundle > /dev/null && bundle show carthage_cache > /dev/null && [ -f .carthage_cache.yml ] + then + carthage_cmd="$carthage_cmd && bundle exec carthage_cache publish" + fi + if [ ! -z "$VERBOSE" ] + then + echo $carthage_cmd + fi eval $carthage_cmd elif [ -f Podfile ] then