diff --git a/.gitignore b/.gitignore index 89b6978..08d6ef8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ JSONWebToken.xcodeproj/xcuserdata +.swiftpm/xcode/xcuserdata diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/JSONWebToken.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/JSONWebToken.xcscheme new file mode 100644 index 0000000..86e5224 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/JSONWebToken.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JSONWebToken.xcodeproj/project.pbxproj b/JSONWebToken.xcodeproj/project.pbxproj index ab95736..545a57b 100644 --- a/JSONWebToken.xcodeproj/project.pbxproj +++ b/JSONWebToken.xcodeproj/project.pbxproj @@ -183,7 +183,7 @@ 7148BE9C1BFE2FA400CD17E7 /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = ""; }; 7148BEA01BFF0B0B00CD17E7 /* SecKeyUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecKeyUtils.swift; sourceTree = ""; }; 7148BEA21BFF6FF500CD17E7 /* ClaimValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClaimValidator.swift; sourceTree = ""; }; - 71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = JSONWebToken.entitlements; sourceTree = ""; }; + 71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; name = JSONWebToken.entitlements; path = ../JSONWebToken/JSONWebToken.entitlements; sourceTree = ""; }; 71642F3F1D9BB1F2008BBA95 /* TestContainer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestContainer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 71642F411D9BB1F2008BBA95 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 71642F431D9BB1F2008BBA95 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -192,8 +192,8 @@ 71642F4B1D9BB1F2008BBA95 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 71642F4D1D9BB1F2008BBA95 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 717ACFCE1BFB6842004E01D0 /* JSONWebToken.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JSONWebToken.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 717ACFD11BFB6842004E01D0 /* JSONWebToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSONWebToken.h; sourceTree = ""; }; - 717ACFD31BFB6842004E01D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 717ACFD11BFB6842004E01D0 /* JSONWebToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSONWebToken.h; path = JSONWebToken/JSONWebToken.h; sourceTree = ""; }; + 717ACFD31BFB6842004E01D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = JSONWebToken/Info.plist; sourceTree = ""; }; 717ACFD81BFB6842004E01D0 /* JSONWebTokenTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JSONWebTokenTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 717ACFDD1BFB6842004E01D0 /* RSASSA_PKCS1Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RSASSA_PKCS1Tests.swift; sourceTree = ""; }; 717ACFDF1BFB6842004E01D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -312,6 +312,7 @@ 71642F401D9BB1F2008BBA95 /* TestContainer */ = { isa = PBXGroup; children = ( + 71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */, 71642F411D9BB1F2008BBA95 /* AppDelegate.swift */, 71642F431D9BB1F2008BBA95 /* ViewController.swift */, 71642F451D9BB1F2008BBA95 /* Main.storyboard */, @@ -325,6 +326,8 @@ 717ACFC41BFB6842004E01D0 = { isa = PBXGroup; children = ( + 717ACFD11BFB6842004E01D0 /* JSONWebToken.h */, + 717ACFD31BFB6842004E01D0 /* Info.plist */, 717ACFD01BFB6842004E01D0 /* JSONWebToken */, 717ACFDC1BFB6842004E01D0 /* JSONWebTokenTests */, 719156991D1D3BE900FC55C9 /* JSONWebToken tvOS */, @@ -349,8 +352,6 @@ 717ACFD01BFB6842004E01D0 /* JSONWebToken */ = { isa = PBXGroup; children = ( - 717ACFD11BFB6842004E01D0 /* JSONWebToken.h */, - 717ACFD31BFB6842004E01D0 /* Info.plist */, 717ACFE81BFB69EB004E01D0 /* JSONWebToken.swift */, 717ACFFE1BFC8393004E01D0 /* SignatureAlgorithm.swift */, 71EA699E1C0323320081AF85 /* TokenSigner.swift */, @@ -360,9 +361,9 @@ 71AF7F482474191A00DDF6C0 /* Data+hash.swift */, 717ACFF41BFB8113004E01D0 /* NSData+Base64URLEncoding.swift */, 7148BEA01BFF0B0B00CD17E7 /* SecKeyUtils.swift */, - 71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */, ); - path = JSONWebToken; + name = JSONWebToken; + path = Sources/JSONWebToken; sourceTree = ""; }; 717ACFDC1BFB6842004E01D0 /* JSONWebTokenTests */ = { diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..6102e29 --- /dev/null +++ b/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version:5.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "JSONWebToken", + platforms: [ + .iOS(.v12), .tvOS(.v12) + ], + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "JSONWebToken", + targets: ["JSONWebToken"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "JSONWebToken", + dependencies: []), + ] +) diff --git a/JSONWebToken/ClaimValidator.swift b/Sources/JSONWebToken/ClaimValidator.swift similarity index 100% rename from JSONWebToken/ClaimValidator.swift rename to Sources/JSONWebToken/ClaimValidator.swift diff --git a/JSONWebToken/Data+hash.swift b/Sources/JSONWebToken/Data+hash.swift similarity index 96% rename from JSONWebToken/Data+hash.swift rename to Sources/JSONWebToken/Data+hash.swift index bc6e793..f0171dd 100644 --- a/JSONWebToken/Data+hash.swift +++ b/Sources/JSONWebToken/Data+hash.swift @@ -11,7 +11,7 @@ import CryptoKit extension Data { func sha(_ hashFunction: SignatureAlgorithm.HashFunction) -> Data { - if #available(iOSApplicationExtension 13.0, *) { + if #available(iOS 13.0, *) { switch hashFunction { case .sha256: return Data(SHA256.hash(data: self)) case .sha384: return Data(SHA384.hash(data: self)) @@ -40,7 +40,7 @@ extension Data { } } func hmac(_ hashFunction: SignatureAlgorithm.HashFunction, secret: Data) -> Data { - if #available(iOSApplicationExtension 13.0, *) { + if #available(iOS 13.0, *) { let key = SymmetricKey(data: secret) switch hashFunction { case .sha256: diff --git a/JSONWebToken/HMAC.swift b/Sources/JSONWebToken/HMAC.swift similarity index 100% rename from JSONWebToken/HMAC.swift rename to Sources/JSONWebToken/HMAC.swift diff --git a/JSONWebToken/JSONWebToken.swift b/Sources/JSONWebToken/JSONWebToken.swift similarity index 100% rename from JSONWebToken/JSONWebToken.swift rename to Sources/JSONWebToken/JSONWebToken.swift diff --git a/JSONWebToken/NSData+Base64URLEncoding.swift b/Sources/JSONWebToken/NSData+Base64URLEncoding.swift similarity index 100% rename from JSONWebToken/NSData+Base64URLEncoding.swift rename to Sources/JSONWebToken/NSData+Base64URLEncoding.swift diff --git a/JSONWebToken/RSASSA_PKCS1.swift b/Sources/JSONWebToken/RSASSA_PKCS1.swift similarity index 100% rename from JSONWebToken/RSASSA_PKCS1.swift rename to Sources/JSONWebToken/RSASSA_PKCS1.swift diff --git a/JSONWebToken/SecKeyUtils.swift b/Sources/JSONWebToken/SecKeyUtils.swift similarity index 100% rename from JSONWebToken/SecKeyUtils.swift rename to Sources/JSONWebToken/SecKeyUtils.swift diff --git a/JSONWebToken/SignatureAlgorithm.swift b/Sources/JSONWebToken/SignatureAlgorithm.swift similarity index 100% rename from JSONWebToken/SignatureAlgorithm.swift rename to Sources/JSONWebToken/SignatureAlgorithm.swift diff --git a/JSONWebToken/SignatureValidator.swift b/Sources/JSONWebToken/SignatureValidator.swift similarity index 100% rename from JSONWebToken/SignatureValidator.swift rename to Sources/JSONWebToken/SignatureValidator.swift diff --git a/JSONWebToken/TokenSigner.swift b/Sources/JSONWebToken/TokenSigner.swift similarity index 100% rename from JSONWebToken/TokenSigner.swift rename to Sources/JSONWebToken/TokenSigner.swift diff --git a/JSONWebToken/TokenValidator.swift b/Sources/JSONWebToken/TokenValidator.swift similarity index 100% rename from JSONWebToken/TokenValidator.swift rename to Sources/JSONWebToken/TokenValidator.swift