Skip to content

Commit d1263a0

Browse files
authored
feat: Adding visionOS support to the WebAuthn APIs (#171)
1 parent 19eeb30 commit d1263a0

32 files changed

+92
-53
lines changed

Amplify/Categories/Auth/AuthCategory+WebAuthnBehaviour.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ extension AuthCategory: AuthCategoryWebAuthnBehaviour {
1919
options: options
2020
)
2121
}
22+
#elseif os(visionOS)
23+
public func associateWebAuthnCredential(
24+
presentationAnchor: AuthUIPresentationAnchor,
25+
options: AuthAssociateWebAuthnCredentialRequest.Options? = nil
26+
) async throws {
27+
try await plugin.associateWebAuthnCredential(
28+
presentationAnchor:presentationAnchor,
29+
options: options
30+
)
31+
}
2232
#endif
2333

2434
public func listWebAuthnCredentials(

Amplify/Categories/Auth/AuthCategoryWebAuthnBehaviour.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public protocol AuthCategoryWebAuthnBehaviour: AnyObject {
1515
presentationAnchor: AuthUIPresentationAnchor?,
1616
options: AuthAssociateWebAuthnCredentialRequest.Options?
1717
) async throws
18+
#elseif os(visionOS)
19+
func associateWebAuthnCredential(
20+
presentationAnchor: AuthUIPresentationAnchor,
21+
options: AuthAssociateWebAuthnCredentialRequest.Options?
22+
) async throws
1823
#endif
1924

2025
/// - Tag: AuthCategoryWebAuthnBehaviour.list

Amplify/Categories/Auth/Models/AuthFactorType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public enum AuthFactorType: String {
1919
/// An auth factor that uses Email OTP
2020
case emailOTP
2121

22-
#if os(iOS) || os(macOS)
22+
#if os(iOS) || os(macOS) || os(visionOS)
2323
/// An auth factor that uses WebAuthn
24-
@available(iOS 17.4, macOS 13.5, *)
24+
@available(iOS 17.4, macOS 13.5, visionOS 1.0, *)
2525
case webAuthn
2626
#endif
2727
}

Amplify/Categories/Auth/Request/AuthAssociateWebAuthnCredentialRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if os(iOS) || os(macOS)
8+
#if os(iOS) || os(macOS) || os(visionOS)
99
import Foundation
1010

1111
/// Request for creating a new WebAuthn Credential and associating it with the signed in user

Amplify/Categories/Auth/Request/AuthConfirmSignInRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public extension AuthConfirmSignInRequest {
3333
/// key/values
3434
public let pluginOptions: Any?
3535

36-
#if os(iOS) || os(macOS)
36+
#if os(iOS) || os(macOS) || os(visionOS)
3737
/// Provide a presentation anchor if you are confirming sign in with WebAuthn. The WebAuthn assertion will be presented
3838
/// in the presentation anchor provided.
3939
public let presentationAnchorForWebAuthn: AuthUIPresentationAnchor?

Amplify/Categories/Auth/Request/AuthSignInRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public extension AuthSignInRequest {
3535
/// key/values
3636
public let pluginOptions: Any?
3737

38-
#if os(iOS) || os(macOS)
38+
#if os(iOS) || os(macOS) || os(visionOS)
3939
/// Provide a presentation anchor if you are signing in with WebAuthn. The WebAuthn assertion will be presented
4040
/// in the presentation anchor provided.
4141
public let presentationAnchorForWebAuthn: AuthUIPresentationAnchor?

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/VerifySignInChallenge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ struct VerifySignInChallenge: Action {
230230
}
231231

232232
private func isWebAuthn(_ factorType: AuthFactorType?) -> Bool {
233-
#if os(iOS) || os(macOS)
233+
#if os(iOS) || os(macOS) || os(visionOS)
234234
if #available(iOS 17.4, macOS 13.5, *) {
235235
return .webAuthn == factorType
236236
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/AssertWebAuthnCredentials.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if os(iOS) || os(macOS)
8+
#if os(iOS) || os(macOS) || os(visionOS)
99
import Amplify
1010
import Foundation
1111

12-
@available(iOS 17.4, macOS 13.5, *)
12+
@available(iOS 17.4, macOS 13.5, visionOS 1.0, *)
1313
struct AssertWebAuthnCredentials: Action {
1414
let identifier = "AssertWebAuthnCredentials"
1515
let username: String
@@ -75,10 +75,10 @@ struct AssertWebAuthnCredentials: Action {
7575
}
7676
}
7777

78-
@available(iOS 17.4, macOS 13.5, *)
78+
@available(iOS 17.4, macOS 13.5, visionOS 1.0, *)
7979
extension AssertWebAuthnCredentials: DefaultLogger { }
8080

81-
@available(iOS 17.4, macOS 13.5, *)
81+
@available(iOS 17.4, macOS 13.5, visionOS 1.0, *)
8282
extension AssertWebAuthnCredentials: CustomDebugDictionaryConvertible {
8383
var debugDictionary: [String: Any] {
8484
[
@@ -90,7 +90,7 @@ extension AssertWebAuthnCredentials: CustomDebugDictionaryConvertible {
9090
}
9191
}
9292

93-
@available(iOS 17.4, macOS 13.5, *)
93+
@available(iOS 17.4, macOS 13.5, visionOS 1.0, *)
9494
extension AssertWebAuthnCredentials: CustomDebugStringConvertible {
9595
var debugDescription: String {
9696
debugDictionary.debugDescription

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/FetchCredentialOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if os(iOS) || os(macOS)
8+
#if os(iOS) || os(macOS) || os(visionOS)
99
import Amplify
1010
import Foundation
1111
import AWSCognitoIdentityProvider

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/InitializeWebAuthn.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if os(iOS) || os(macOS)
8+
#if os(iOS) || os(macOS) || os(visionOS)
99
import Amplify
1010
import Foundation
1111

0 commit comments

Comments
 (0)