Skip to content

Commit ed263d7

Browse files
authored
chore: kickoff release
2 parents aef29d1 + edd2aa7 commit ed263d7

File tree

183 files changed

+10617
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+10617
-551
lines changed

.github/workflows/integ_test_auth.yml

+6
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ jobs:
5858
resource_subfolder: auth
5959
timeout-minutes: 30
6060
secrets: inherit
61+
62+
# Disabling the integration test because the job is not able to connect to the local server
63+
# auth-webauthn-integration-test-iOS:
64+
# name: Auth WebAuthn Integration Tests (iOS)
65+
# uses: ./.github/workflows/integ_test_auth_webauthn.yml
66+
# secrets: inherit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Integration Tests | Auth - WebAuthn
2+
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
6+
permissions:
7+
id-token: write
8+
contents: read
9+
10+
jobs:
11+
auth-webauthn-integration-tests:
12+
name: iOS Tests | AuthWebAuthnApp
13+
runs-on: macos-15
14+
timeout-minutes: 30
15+
environment: IntegrationTest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
20+
with:
21+
persist-credentials: false
22+
23+
- name: Get build parameters for iOS
24+
id: platform
25+
uses: ./.github/composite_actions/get_platform_parameters
26+
with:
27+
platform: iOS
28+
29+
- name: Create the test configuration directory
30+
run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/
31+
32+
- name: Download the Integration Test configurations
33+
uses: ./.github/composite_actions/download_test_configuration
34+
with:
35+
resource_subfolder: auth
36+
aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
37+
aws_region: ${{ secrets.AWS_REGION }}
38+
aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }}
39+
destination: ~/.aws-amplify/amplify-ios/testconfiguration/
40+
41+
- name: Set up node
42+
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
43+
with:
44+
node-version: 16.x
45+
46+
- name: Attempt to use the dependencies cache
47+
id: dependencies-cache
48+
timeout-minutes: 4
49+
continue-on-error: true
50+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
51+
with:
52+
path: ~/Library/Developer/Xcode/DerivedData/Amplify
53+
key: amplify-packages-${{ hashFiles('Package.resolved') }}
54+
restore-keys: |
55+
amplify-packages-
56+
57+
- name: Attempt to restore the build cache
58+
id: build-cache
59+
timeout-minutes: 4
60+
continue-on-error: true
61+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
62+
with:
63+
path: ${{ github.workspace }}/Build
64+
key: Amplify-iOS-build-cache
65+
66+
- name: Run Local Server
67+
run: |
68+
cd ./AmplifyPlugins/Auth/Tests/AuthWebAuthnApp/LocalServer
69+
npm install
70+
npm start &
71+
shell: bash
72+
73+
- name: Run iOS Integration Tests
74+
id: run-tests
75+
continue-on-error: true
76+
uses: ./.github/composite_actions/run_xcodebuild_test
77+
with:
78+
scheme: AuthWebAuthnApp
79+
destination: ${{ steps.platform.outputs.destination }}
80+
sdk: ${{ steps.platform.outputs.sdk }}
81+
xcode_path: /Applications/Xcode_${{ steps.platform.outputs.xcode-version }}.app
82+
project_path: ./AmplifyPlugins/Auth/Tests/AuthWebAuthnApp
83+
generate_coverage: false
84+
cloned_source_packages_path: ~/Library/Developer/Xcode/DerivedData/Amplify
85+
derived_data_path: ${{ github.workspace }}/Build
86+
disable_package_resolution: ${{ steps.dependencies-cache.outputs.cache-hit }}
87+
88+
- name: Retry iOS Integration Tests
89+
if: steps.run-tests.outcome=='failure'
90+
id: retry-tests
91+
uses: ./.github/composite_actions/run_xcodebuild_test
92+
with:
93+
scheme: AuthWebAuthnApp
94+
destination: ${{ steps.platform.outputs.destination }}
95+
sdk: ${{ steps.platform.outputs.sdk }}
96+
xcode_path: /Applications/Xcode_${{ steps.platform.outputs.xcode-version }}.app
97+
project_path: ./AmplifyPlugins/Auth/Tests/AuthWebAuthnApp
98+
generate_coverage: false
99+
cloned_source_packages_path: ~/Library/Developer/Xcode/DerivedData/Amplify
100+
derived_data_path: ${{ github.workspace }}/Build
101+
disable_package_resolution: true

Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ extension AuthCategory: AuthCategoryBehavior {
6464
return await plugin.signOut(options: options)
6565
}
6666

67+
public func autoSignIn() async throws -> AuthSignInResult {
68+
try await plugin.autoSignIn()
69+
}
70+
6771
public func deleteUser() async throws {
6872
try await plugin.deleteUser()
6973
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
10+
extension AuthCategory: AuthCategoryWebAuthnBehaviour {
11+
#if os(iOS) || os(macOS)
12+
@available(iOS 17.4, macOS 13.5, *)
13+
public func associateWebAuthnCredential(
14+
presentationAnchor: AuthUIPresentationAnchor? = nil,
15+
options: AuthAssociateWebAuthnCredentialRequest.Options? = nil
16+
) async throws {
17+
try await plugin.associateWebAuthnCredential(
18+
presentationAnchor: presentationAnchor,
19+
options: options
20+
)
21+
}
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+
}
32+
#endif
33+
34+
public func listWebAuthnCredentials(
35+
options: AuthListWebAuthnCredentialsRequest.Options? = nil
36+
) async throws -> AuthListWebAuthnCredentialsResult {
37+
return try await plugin.listWebAuthnCredentials(
38+
options: options
39+
)
40+
}
41+
42+
public func deleteWebAuthnCredential(
43+
credentialId: String,
44+
options: AuthDeleteWebAuthnCredentialRequest.Options? = nil
45+
) async throws {
46+
try await plugin.deleteWebAuthnCredential(
47+
credentialId: credentialId,
48+
options: options
49+
)
50+
}
51+
}

Amplify/Categories/Auth/AuthCategoryBehavior.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public typealias AuthUIPresentationAnchor = ASPresentationAnchor
1212
#endif
1313

1414
/// Behavior of the Auth category that clients will use
15-
public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDeviceBehavior {
15+
public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDeviceBehavior, AuthCategoryWebAuthnBehaviour {
1616

1717
/// SignUp a user with the authentication provider.
1818
///
@@ -102,6 +102,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
102102
options: AuthConfirmSignInRequest.Options?
103103
) async throws -> AuthSignInResult
104104

105+
106+
/// Auto signs in the user for passwordless sign up
107+
func autoSignIn() async throws -> AuthSignInResult
108+
105109
/// Sign out the currently logged-in user.
106110
///
107111
/// - Parameters:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
10+
public protocol AuthCategoryWebAuthnBehaviour: AnyObject {
11+
#if os(iOS) || os(macOS)
12+
/// - Tag: AuthCategoryWebAuthnBehaviour.associate
13+
@available(iOS 17.4, macOS 13.5, *)
14+
func associateWebAuthnCredential(
15+
presentationAnchor: AuthUIPresentationAnchor?,
16+
options: AuthAssociateWebAuthnCredentialRequest.Options?
17+
) async throws
18+
#elseif os(visionOS)
19+
func associateWebAuthnCredential(
20+
presentationAnchor: AuthUIPresentationAnchor,
21+
options: AuthAssociateWebAuthnCredentialRequest.Options?
22+
) async throws
23+
#endif
24+
25+
/// - Tag: AuthCategoryWebAuthnBehaviour.list
26+
func listWebAuthnCredentials(
27+
options: AuthListWebAuthnCredentialsRequest.Options?
28+
) async throws -> AuthListWebAuthnCredentialsResult
29+
30+
/// - Tag: AuthCategoryWebAuthnBehaviour.delete
31+
func deleteWebAuthnCredential(
32+
credentialId: String,
33+
options: AuthDeleteWebAuthnCredentialRequest.Options?
34+
) async throws
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
public enum AuthFactorType: String {
9+
10+
/// An auth factor that uses password
11+
case password
12+
13+
/// An auth factor that uses SRP protocol
14+
case passwordSRP
15+
16+
/// An auth factor that uses SMS OTP
17+
case smsOTP
18+
19+
/// An auth factor that uses Email OTP
20+
case emailOTP
21+
22+
#if os(iOS) || os(macOS) || os(visionOS)
23+
/// An auth factor that uses WebAuthn
24+
@available(iOS 17.4, macOS 13.5, visionOS 1.0, *)
25+
case webAuthn
26+
#endif
27+
}

Amplify/Categories/Auth/Models/AuthSignInStep.swift

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
/// Set of allowed MFA types that would be used for continuing sign in during MFA selection step
99
public typealias AllowedMFATypes = Set<MFAType>
1010

11+
/// Set of available factors that would be used for continuing/confirming sign in
12+
public typealias AvailableAuthFactorTypes = Set<AuthFactorType>
13+
1114
/// Auth SignIn flow steps
1215
///
1316
///
@@ -26,6 +29,10 @@ public enum AuthSignInStep {
2629
///
2730
case confirmSignInWithNewPassword(AdditionalInfo?)
2831

32+
/// Auth step required the user to give a password.
33+
///
34+
case confirmSignInWithPassword
35+
2936
/// Auth step is TOTP multi factor authentication.
3037
///
3138
/// Confirmation code for the MFA will be retrieved from the associated Authenticator app
@@ -52,6 +59,10 @@ public enum AuthSignInStep {
5259
/// OTP for the factor will be sent to the delivery medium.
5360
case confirmSignInWithOTP(AuthCodeDeliveryDetails)
5461

62+
/// Auth step is for continuing sign in by selecting the first factor that would be used for signing in
63+
///
64+
case continueSignInWithFirstFactorSelection(AvailableAuthFactorTypes)
65+
5566
/// Auth step required the user to change their password.
5667
///
5768
case resetPassword(AdditionalInfo?)

Amplify/Categories/Auth/Models/AuthSignUpStep.swift

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
public typealias UserId = String
9+
public typealias Session = String
910

1011
/// SignUp step to be followed.
1112
public enum AuthSignUpStep {
@@ -16,6 +17,10 @@ public enum AuthSignUpStep {
1617
AdditionalInfo? = nil,
1718
UserId? = nil)
1819

20+
/// Sign Up successfully completed
21+
/// The customers can use this step to determine if they want to complete sign in
22+
case completeAutoSignIn(Session)
23+
1924
/// Sign up is complete
2025
case done
2126
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
10+
/// Represents the output of a call to
11+
/// [`AuthCategoryWebAuthnBehaviour.listWebAuthnCredentials(options:)`](x-source-tag://AuthCategoryWebAuthnBehaviour.list)
12+
///
13+
/// - Tag: AuthListWebAuthnCredentialsResult
14+
public struct AuthListWebAuthnCredentialsResult {
15+
/// The list of WebAuthn credentials
16+
///
17+
/// - Tag: AuthListWebAuthnCredentialsResult.credentials
18+
public var credentials: [AuthWebAuthnCredential]
19+
20+
/// String indicating the page offset at which to resume a listing.
21+
///
22+
/// This value is usually copied to
23+
/// [AuthListWebAuthnCredentialsRequest.Options.nextToken](x-source-tag://AuthListWebAuthnCredentialsRequestOptions.nextToken).
24+
///
25+
/// - Tag: AuthListWebAuthnCredentialsResult.nextToken
26+
public let nextToken: String?
27+
28+
/// - Tag: AuthListWebAuthnCredentialsResult.init
29+
public init(
30+
credentials: [AuthWebAuthnCredential],
31+
nextToken: String?
32+
) {
33+
self.credentials = credentials
34+
self.nextToken = nextToken
35+
}
36+
}
37+
38+
/// Defines a WebAuthn credential
39+
/// - Tag: AuthWebAuthnCredential
40+
public protocol AuthWebAuthnCredential {
41+
/// The credential's ID
42+
var credentialId: String { get }
43+
44+
/// The credential's creation date
45+
var createdAt: Date { get }
46+
47+
/// The credential's relying party ID
48+
var relyingPartyId: String { get }
49+
50+
/// The credential's friendly name
51+
var friendlyName: String? { get }
52+
}

0 commit comments

Comments
 (0)