Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dfdbd9d
Relocate common concurrency features into a separate library for reuse
AlexNachbaur Sep 24, 2025
35b0e4b
Add test that got missed
AlexNachbaur Sep 24, 2025
e3cd11f
Include CommonSupport in OktaAuthFoundation cocoapod
AlexNachbaur Sep 24, 2025
654180e
Update CommonSupport imports to be contextual for CocoaPods
AlexNachbaur Sep 24, 2025
2d3fff2
Relocate JSON features to its own utility library
AlexNachbaur Sep 24, 2025
0aed5f8
Update cocoapods imports
AlexNachbaur Sep 24, 2025
299c4eb
Refine JSON implementation for mutability, type safety, and performance
AlexNachbaur Aug 20, 2025
e559013
Remove missing test plan from the workspace
AlexNachbaur Aug 20, 2025
b14c61c
Include SwiftTesting framework in older Swift versions
AlexNachbaur Aug 20, 2025
2de5221
Address a Swift 6.2 error
AlexNachbaur Aug 20, 2025
81af928
Remove legacy xcode version xcbuild tests
AlexNachbaur Aug 20, 2025
3c7ba5f
Work around cocoapods silliness
AlexNachbaur Aug 21, 2025
81248c3
Revert 'claimContent' back to 'payload' to limit the impact of the ch…
AlexNachbaur Aug 21, 2025
2adbad6
Update API docs for CoW
AlexNachbaur Aug 21, 2025
69e7ea5
Yield to wait for request mock to complete
AlexNachbaur Aug 21, 2025
e04339e
Attempt to improve race conditions in mock network requests
AlexNachbaur Aug 21, 2025
fc1c0c9
Fix a problem after reverting automatic snake case conversion
AlexNachbaur Aug 22, 2025
d173004
Fix test issues that incorrectly assumed camel-case for OAuth2 responses
AlexNachbaur Aug 22, 2025
7df2700
Debugging network request race conditions
AlexNachbaur Aug 22, 2025
ddbde17
Correct conditional imports to be more accurate
AlexNachbaur Sep 16, 2025
2b551b4
Minor import updates
AlexNachbaur Sep 16, 2025
bc7f429
Migrate away from SwiftTesting since it's flaky on Swift 6.0
AlexNachbaur Sep 18, 2025
5db1a0a
Avoid using sys functions (sleep/usleep) for tests
AlexNachbaur Sep 18, 2025
4a811b4
Unify changes from the common lib migration and mutable JSON workstreams
AlexNachbaur Sep 24, 2025
e1a60d3
Clean up merge / rebase conflicts
AlexNachbaur Sep 24, 2025
9e75c40
Merge branch 'master' into OKTA-998746-mutableJSON
AlexNachbaur Oct 3, 2025
8cf3d03
Remove old JSON class that came back after an upstream rebase
AlexNachbaur Oct 3, 2025
06be342
Remove duplicate imports introduced from a git-rebase
AlexNachbaur Oct 6, 2025
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
103 changes: 103 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/CommonSupport.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CommonSupport"
BuildableName = "CommonSupport"
BlueprintName = "CommonSupport"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CommonSupportTests"
BuildableName = "CommonSupportTests"
BlueprintName = "CommonSupportTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CommonSupport"
BuildableName = "CommonSupport"
BlueprintName = "CommonSupport"
ReferencedContainer = "container:">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CommonSupportTests"
BuildableName = "CommonSupportTests"
BlueprintName = "CommonSupportTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</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 = "CommonSupport"
BuildableName = "CommonSupport"
BlueprintName = "CommonSupport"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
90 changes: 90 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/JSON.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "JSON"
BuildableName = "JSON"
BlueprintName = "JSON"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "JSON"
BuildableName = "JSON"
BlueprintName = "JSON"
ReferencedContainer = "container:">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO"
testExecutionOrdering = "random">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "JSONTests"
BuildableName = "JSONTests"
BlueprintName = "JSONTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</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 = "JSON"
BuildableName = "JSON"
BlueprintName = "JSON"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 0 additions & 4 deletions Sources/AuthFoundation/Debugging/APIRequestObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import OSLog
import CommonSupport
#endif

#if !COCOAPODS
import CommonSupport
#endif

#if compiler(<6.0)
extension OSLog: @unchecked Sendable {}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,83 @@

import Foundation

extension JSON {
var payload: [String: any Sendable] {
get {
value.anyValue as? [String: any Sendable] ?? [:]
}
set { value.anyValue = newValue }
}
}

@_documentation(visibility: private)
extension String: ClaimConvertable {}

@_documentation(visibility: private)
extension Bool: ClaimConvertable {}
extension Bool: ClaimConvertable {
public static func convert(from value: Any?) -> Self? {
if let value = value as? Bool {
return value
}

if let value = value as? Int,
value == 0 || value == 1
{
return value == 1
}

return nil
}
}

@_documentation(visibility: private)
extension Int: ClaimConvertable {}
extension Int: ClaimConvertable {
public static func convert(from value: Any?) -> Self? {
if let value = value as? Int {
return value
}

if let value = value as? Double {
return Int(value)
}

return nil
}
}

@_documentation(visibility: private)
extension Double: ClaimConvertable {}
extension Double: ClaimConvertable {
public static func convert(from value: Any?) -> Self? {
if let value = value as? Double {
return value
}

if let value = value as? Int {
return Double(value)
}

return nil
}
}

@_documentation(visibility: private)
extension Float: ClaimConvertable {}
extension Float: ClaimConvertable {
public static func convert(from value: Any?) -> Self? {
if let value = value as? Float {
return value
}

if let value = value as? Double {
return Float(value)
}

if let value = value as? Int {
return Float(value)
}

return nil
}
}

@_documentation(visibility: private)
extension JWTClaim: ClaimConvertable {}
Expand Down
4 changes: 0 additions & 4 deletions Sources/AuthFoundation/JWT/JWK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import Foundation
import CommonSupport
#endif

#if !COCOAPODS
import CommonSupport
#endif

/// Describes an individual key from an authorization server, which can be used to validate tokens or encrypt content.
///
/// > Warning: At this time, this class only supports RSA Public Keys.
Expand Down
16 changes: 8 additions & 8 deletions Sources/AuthFoundation/JWT/JWT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

import Foundation

#if !COCOAPODS
@_exported import JSON
#endif

/// Represents the contents of a JWT token, providing access to its payload contents.
public struct JWT: RawRepresentable, Sendable, Codable, HasClaims, Expires {
public typealias ClaimType = JWTClaim
Expand Down Expand Up @@ -93,25 +97,21 @@ public struct JWT: RawRepresentable, Sendable, Codable, HasClaims, Expires {
else { throw JWTError.invalidBase64Encoding }

self.header = try JSONDecoder().decode(JWT.Header.self, from: headerData)
guard let payload = try JSONSerialization.jsonObject(with: payloadData,
options: []) as? [String: any Sendable]
else {
throw JWTError.badTokenStructure
}

self.payload = payload
self.body = try JSON(payloadData)

if components.count == 3 {
self.signature = components[2]
}
}

/// Raw paylaod of claims, as a dictionary representation.
public var payload: [String: any Sendable]
public var body: JSON

/// Signature of the JWT token.
public var signature: String?

public var payload: [String: any Sendable] { body.payload }

static func tokenComponents(from token: String) -> [String] {
token
.components(separatedBy: ".")
Expand Down
Loading
Loading