Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
JSONWebToken.xcodeproj/xcuserdata
.swiftpm/xcode/xcuserdata
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/JSONWebToken.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "JSONWebToken"
BuildableName = "JSONWebToken"
BlueprintName = "JSONWebToken"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "JSONWebToken"
BuildableName = "JSONWebToken"
BlueprintName = "JSONWebToken"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
15 changes: 8 additions & 7 deletions JSONWebToken.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
7148BE9C1BFE2FA400CD17E7 /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
7148BEA01BFF0B0B00CD17E7 /* SecKeyUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecKeyUtils.swift; sourceTree = "<group>"; };
7148BEA21BFF6FF500CD17E7 /* ClaimValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClaimValidator.swift; sourceTree = "<group>"; };
71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = JSONWebToken.entitlements; sourceTree = "<group>"; };
71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; name = JSONWebToken.entitlements; path = ../JSONWebToken/JSONWebToken.entitlements; sourceTree = "<group>"; };
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 = "<group>"; };
71642F431D9BB1F2008BBA95 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -192,8 +192,8 @@
71642F4B1D9BB1F2008BBA95 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
71642F4D1D9BB1F2008BBA95 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
717ACFD31BFB6842004E01D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
717ACFD11BFB6842004E01D0 /* JSONWebToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSONWebToken.h; path = JSONWebToken/JSONWebToken.h; sourceTree = "<group>"; };
717ACFD31BFB6842004E01D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = JSONWebToken/Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
717ACFDF1BFB6842004E01D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -312,6 +312,7 @@
71642F401D9BB1F2008BBA95 /* TestContainer */ = {
isa = PBXGroup;
children = (
71642F3A1D9BB138008BBA95 /* JSONWebToken.entitlements */,
71642F411D9BB1F2008BBA95 /* AppDelegate.swift */,
71642F431D9BB1F2008BBA95 /* ViewController.swift */,
71642F451D9BB1F2008BBA95 /* Main.storyboard */,
Expand All @@ -325,6 +326,8 @@
717ACFC41BFB6842004E01D0 = {
isa = PBXGroup;
children = (
717ACFD11BFB6842004E01D0 /* JSONWebToken.h */,
717ACFD31BFB6842004E01D0 /* Info.plist */,
717ACFD01BFB6842004E01D0 /* JSONWebToken */,
717ACFDC1BFB6842004E01D0 /* JSONWebTokenTests */,
719156991D1D3BE900FC55C9 /* JSONWebToken tvOS */,
Expand All @@ -349,8 +352,6 @@
717ACFD01BFB6842004E01D0 /* JSONWebToken */ = {
isa = PBXGroup;
children = (
717ACFD11BFB6842004E01D0 /* JSONWebToken.h */,
717ACFD31BFB6842004E01D0 /* Info.plist */,
717ACFE81BFB69EB004E01D0 /* JSONWebToken.swift */,
717ACFFE1BFC8393004E01D0 /* SignatureAlgorithm.swift */,
71EA699E1C0323320081AF85 /* TokenSigner.swift */,
Expand All @@ -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 = "<group>";
};
717ACFDC1BFB6842004E01D0 /* JSONWebTokenTests */ = {
Expand Down
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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: []),
]
Comment on lines +21 to +27
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to add the test target, in order for people to see how to use the package ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test target needs a container app with an entitlement because the library use a keychain hack to create keys, and I don't know how to do that with SPM.
I'm working on a solution without the keychain hack and CryptoKit and I'll add a test target on the package

)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CryptoKit

extension Data {
func sha(_ hashFunction: SignatureAlgorithm.HashFunction) -> Data {
if #available(iOSApplicationExtension 13.0, *) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a fairly significant change as it means this can no longer be used in an app extension (such as the share extension). Is that really necessary?

if #available(iOS 13.0, *) {
switch hashFunction {
case .sha256: return Data(SHA256.hash(data: self))
case .sha384: return Data(SHA384.hash(data: self))
Expand Down Expand Up @@ -40,7 +40,7 @@ extension Data {
}
}
func hmac(_ hashFunction: SignatureAlgorithm.HashFunction, secret: Data) -> Data {
if #available(iOSApplicationExtension 13.0, *) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a fairly significant change as it means this can no longer be used in an app extension (such as the share extension). Is that really necessary?

if #available(iOS 13.0, *) {
let key = SymmetricKey(data: secret)
switch hashFunction {
case .sha256:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.