Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Sources/AuthFoundation/Migration/Migration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class Migration {
nonisolated(unsafe) private(set) var registeredMigrators: [any SDKVersionMigrator]

init(migrators: [any SDKVersionMigrator]? = nil) {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation
self.registeredMigrators = migrators ?? Self.defaultMigrators
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AuthFoundation/OAuth2/OAuth2Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public final class OAuth2Client: UsesDelegateCollection {
/// - configuration: The pre-formed configuration for this client.
/// - session: Optional URLSession to use for network requests.
public init(_ configuration: Configuration, session: (any URLSessionProtocol)? = nil) {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

// Ensure the time coordinator is properly initialized
_ = Date.coordinator
Expand Down
12 changes: 6 additions & 6 deletions Sources/AuthFoundation/User Management/Credential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public final class Credential: Equatable, OAuth2ClientDelegate {
/// This can be used as a convenience to store a user's token within storage, and to access the user in a safe way. If the user's token isn't stored, this will automatically store the token for later use.
public static var `default`: Credential? {
get {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

return CredentialActor.sync {
TaskData.coordinator.default
}
}
set {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

CredentialActor.sync {
TaskData.coordinator.default = newValue
Expand All @@ -46,7 +46,7 @@ public final class Credential: Equatable, OAuth2ClientDelegate {

/// Lists all users currently stored within the user's application.
public static var allIDs: [String] {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

return CredentialActor.sync {
TaskData.coordinator.allIDs
Expand All @@ -72,7 +72,7 @@ public final class Credential: Equatable, OAuth2ClientDelegate {
/// - authenticationContext: Optional `LAContext` to use when retrieving credentials, on systems that support it.
/// - Returns: Credential matching the ID.
public static func with(id: String, prompt: String? = nil, authenticationContext: (any TokenAuthenticationContext)? = nil) throws -> Credential? {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

return try CredentialActor.sync {
try TaskData.coordinator.with(id: id,
Expand Down Expand Up @@ -100,7 +100,7 @@ public final class Credential: Equatable, OAuth2ClientDelegate {
/// - authenticationContext: Optional `LAContext` to use when retrieving credentials, on systems that support it.
/// - Returns: Collection of credentials that matches the given expression.
public static func find(where expression: @Sendable @escaping (Token.Metadata) -> Bool, prompt: String? = nil, authenticationContext: (any TokenAuthenticationContext)? = nil) throws -> [Credential] {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

return try CredentialActor.sync {
try TaskData.coordinator.find(where: expression,
Expand All @@ -127,7 +127,7 @@ public final class Credential: Equatable, OAuth2ClientDelegate {
tags: [String: String] = [:],
security options: [Security] = Security.standard
) throws -> Credential {
assert(SDKVersion.authFoundation != nil)
_ = SDKVersion.authFoundation

return try CredentialActor.sync {
try TaskData.coordinator.store(token: token, tags: tags, security: options)
Expand Down
2 changes: 1 addition & 1 deletion Sources/BrowserSignin/BrowserSignin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
/// - loginFlow: Authorization code flow instance for signing in to this client.
/// - logoutFlow: Session sign out flow to use when signing out from this client.
public init(loginFlow: AuthorizationCodeFlow, logoutFlow: SessionLogoutFlow?) {
assert(SDKVersion.browserSignin != nil)
_ = SDKVersion.browserSignin

self.signInFlow = loginFlow
self.signOutFlow = logoutFlow
Expand All @@ -336,7 +336,7 @@
}

extension BrowserSignin: BrowserSignin.ProviderFactory {
public nonisolated static func createWebAuthenticationProvider(

Check warning on line 339 in Sources/BrowserSignin/BrowserSignin.swift

View workflow job for this annotation

GitHub Actions / Lint Sources

nonisolated modifier should come before public (modifier_order)
for webAuth: BrowserSignin,
from window: BrowserSignin.WindowAnchor?,
options: Option) throws -> any BrowserSignin.Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public actor AuthorizationCodeFlow: AuthenticationFlow {
init(verifiedClient client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public actor DeviceAuthorizationFlow: AuthenticationFlow {
/// - additionalParameters: Optional additional query string parameters you would like to supply to the authorization server.
public init(client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil) {
assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public actor JWTAuthorizationFlow: AuthenticationFlow {
public init(client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
2 changes: 1 addition & 1 deletion Sources/OAuth2Auth/Authentication/ResourceOwnerFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public actor ResourceOwnerFlow: AuthenticationFlow {
public init(client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
2 changes: 1 addition & 1 deletion Sources/OAuth2Auth/Authentication/SessionTokenFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public actor SessionTokenFlow: AuthenticationFlow {
throw OAuth2Error.redirectUriRequired
}

assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
2 changes: 1 addition & 1 deletion Sources/OAuth2Auth/Authentication/TokenExchangeFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public actor TokenExchangeFlow: AuthenticationFlow {
public init(client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
2 changes: 1 addition & 1 deletion Sources/OAuth2Auth/Logout/SessionLogoutFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public actor SessionLogoutFlow: LogoutFlow {
public init(client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.oauth2 != nil)
_ = SDKVersion.oauth2

self.client = client
self.additionalParameters = additionalParameters
Expand Down
4 changes: 2 additions & 2 deletions Sources/OktaDirectAuth/DirectAuthFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public actor DirectAuthenticationFlow: AuthenticationFlow {
supportedGrants grantTypes: [GrantType] = .directAuth,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.directAuth != nil)
_ = SDKVersion.directAuth

self.client = client
self.supportedGrantTypes = grantTypes
Expand All @@ -379,7 +379,7 @@ public actor DirectAuthenticationFlow: AuthenticationFlow {
}

public init(client: OAuth2Client, additionalParameters: [String: any APIRequestArgument]?) throws {
assert(SDKVersion.directAuth != nil)
_ = SDKVersion.directAuth

self.client = client
self.supportedGrantTypes = .directAuth
Expand Down
2 changes: 1 addition & 1 deletion Sources/OktaIdxAuth/InteractionCodeFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public actor InteractionCodeFlow: AuthenticationFlow {
init(verifiedClient client: OAuth2Client,
additionalParameters: [String: any APIRequestArgument]? = nil)
{
assert(SDKVersion.oktaIdx != nil)
_ = SDKVersion.oktaIdx

self.client = client
self.additionalParameters = additionalParameters
Expand Down
30 changes: 30 additions & 0 deletions Tests/AuthFoundationTests/SDKVersionRegistrationTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) 2026-Present, Okta, Inc. and/or its affiliates. All rights reserved.
// The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
//
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and limitations under the License.
//

import XCTest
@testable import AuthFoundation

final class SDKVersionRegistrationTests: XCTestCase {
func testOAuth2ClientInitPopulatesUserAgent() throws {
let client = OAuth2Client(
issuerURL: try XCTUnwrap(URL(string: "https://example.okta.com/oauth2/default")),
clientId: "test-client-id",
scope: ["openid"]
)
_ = client

XCTAssertFalse(SDKVersion.userAgent.isEmpty,
"User-Agent must be populated after OAuth2Client init in any build configuration.")
XCTAssertTrue(SDKVersion.userAgent.contains("okta-authfoundation-swift/"),
"User-Agent must include the AuthFoundation SDK marker; got '\(SDKVersion.userAgent)'.")
}
}
Loading