Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
106 changes: 106 additions & 0 deletions MSAL/MSAL.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ enum MSALNativeAuthErrorMessage {
static let invalidUsername = "Invalid username"
static let generalError = "General error"
static let invalidCode = "Invalid code"
static let delegateNotImplementedV2 = "Delegate %@ is not implemented"
static let invalidContinuationToken = "Invalid continuation token"
Comment on lines 41 to +43
static let invalidChallenge = "Invalid challenge"
static let invalidInput = "Invalid input"
static let refreshTokenExpired = "Refresh token is expired"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public final class MSALNativeAuthPublicClientApplication: MSALPublicClientApplic
}
}

/// Reset the password using parameters
/// Reset the password using parameters.
/// - Parameters:
/// - parameters: Parameters used for the Reset Password flow.
/// - delegate: Delegate that receives callbacks for the Reset Password flow.
Expand Down Expand Up @@ -259,6 +259,62 @@ public final class MSALNativeAuthPublicClientApplication: MSALPublicClientApplic
}
}

// MARK: - Native Auth V2 (server-driven)

/// Sign up a user using the server-driven (V2) flow.
///
/// - Warning: This API is experimental. It may be changed in the future without notice. Do not use in production applications.
/// - Parameters:
/// - parameters: Parameters used for the Sign Up flow.
/// - delegate: Unified delegate that receives callbacks for the flow.
public func signUpV2(
parameters: MSALNativeAuthSignUpParametersV2,
delegate: MSALNativeAuthFlowDelegate
) {
Task { @MainActor in
delegate.onFlowError(
error: MSALNativeAuthFlowError(type: .notImplemented, correlationId: parameters.correlationId ?? UUID()),
scenario: .signUp
)
}
}

/// Sign in a user using the server-driven (V2) flow.
///
/// - Warning: This API is experimental. It may be changed in the future without notice. Do not use in production applications.
/// - Parameters:
/// - parameters: Parameters used for the Sign In flow.
/// - delegate: Unified delegate that receives callbacks for the flow.
public func signInV2(
parameters: MSALNativeAuthSignInParameters,
delegate: MSALNativeAuthFlowDelegate
) {
Task { @MainActor in
delegate.onFlowError(
error: MSALNativeAuthFlowError(type: .notImplemented, correlationId: parameters.correlationId ?? UUID()),
scenario: .signIn
)
Comment on lines +286 to +296
}
}

/// Reset the password using the server-driven (V2) flow.
///
/// - Warning: This API is experimental. It may be changed in the future without notice. Do not use in production applications.
/// - Parameters:
/// - parameters: Parameters used for the Reset Password flow.
/// - delegate: Unified delegate that receives callbacks for the flow.
public func resetPasswordV2(
parameters: MSALNativeAuthResetPasswordParametersV2,
delegate: MSALNativeAuthFlowDelegate
) {
Task { @MainActor in
delegate.onFlowError(
error: MSALNativeAuthFlowError(type: .notImplemented, correlationId: parameters.correlationId ?? UUID()),
scenario: .passwordReset
)
}
}
Comment on lines +264 to +316

/// Retrieve the current signed in account from the cache.
/// - Parameter correlationId: Optional. UUID to correlate this request with the server for debugging.
/// - Returns: An object representing the account information if present in the local cache.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright (c) Microsoft Corporation.
// All rights reserved.
//
// This code is licensed under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

/// Encapsulates the parameters passed to the resetPasswordV2 method of MSALNativeAuthPublicClientApplication.
///
/// - Warning: This API is experimental. It may be changed in the future without notice. Do not use in production applications.
@objcMembers
public class MSALNativeAuthResetPasswordParametersV2: MSALNativeAuthResetPasswordParameters {

/// Permissions you want included in the access token received once the account is signed in
/// at the end of the reset password flow.
/// Not all scopes are guaranteed to be included in the access token returned.
public var scopes: [String]?

public override init(username: String) {
super.init(username: username)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright (c) Microsoft Corporation.
// All rights reserved.
//
// This code is licensed under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

/// Encapsulates the parameters passed to the signUpV2 method of MSALNativeAuthPublicClientApplication.
///
/// - Warning: This API is experimental. It may be changed in the future without notice. Do not use in production applications.
@objcMembers
public class MSALNativeAuthSignUpParametersV2: MSALNativeAuthSignUpParameters {

/// Permissions you want included in the access token received once the account is signed in
/// at the end of the sign up flow.
/// Not all scopes are guaranteed to be included in the access token returned.
public var scopes: [String]?

public override init(username: String) {
super.init(username: username)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public class MFARequestChallengeError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

/// Describes why an error occurred and provides more information about the error.
Expand All @@ -60,9 +67,4 @@ public class MFARequestChallengeError: MSALNativeAuthError {
public var isAuthMethodBlocked: Bool {
return type == .authMethodBlocked
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public class MFASubmitChallengeError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

init(error: VerifyCodeError) {
Expand All @@ -53,7 +60,9 @@ public class MFASubmitChallengeError: MSALNativeAuthError {
message: error.errorDescription,
correlationId: error.correlationId,
errorCodes: error.errorCodes,
errorUri: error.errorUri
errorUri: error.errorUri,
isBrowserRequired: self.type == .browserRequired,
isGeneralError: self.type == .generalError
)
}

Expand All @@ -77,9 +86,4 @@ public class MFASubmitChallengeError: MSALNativeAuthError {
public var isInvalidChallenge: Bool {
return type == .invalidChallenge
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,27 @@ public class MSALNativeAuthError: NSObject, LocalizedError {
/// Error uri that can be followed to get more information about the error returned by the server
public let errorUri: String?

/// Indicates whether the error can only be resolved by falling back to the browser-based interactive flow.
public let isBrowserRequired: Bool

/// Indicates whether the error is an unclassified or unexpected error with no more specific handling.
public let isGeneralError: Bool

private let message: String?

init(message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
init(
message: String? = nil,
correlationId: UUID,
errorCodes: [Int] = [],
errorUri: String? = nil,
isBrowserRequired: Bool = false,
isGeneralError: Bool = false
) {
self.message = message
self.correlationId = correlationId
self.errorCodes = errorCodes
self.errorUri = errorUri
self.isBrowserRequired = isBrowserRequired
self.isGeneralError = isGeneralError
Comment on lines +42 to +63
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ public class MSALNativeAuthGenericError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

/// Describes why an error occurred and provides more information about the error.
Expand All @@ -53,9 +60,4 @@ public class MSALNativeAuthGenericError: MSALNativeAuthError {
}
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public class PasswordRequiredError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

init(signInStartError: SignInStartError) {
Expand All @@ -58,7 +65,9 @@ public class PasswordRequiredError: MSALNativeAuthError {
message: errorDescription,
correlationId: signInStartError.correlationId,
errorCodes: signInStartError.errorCodes,
errorUri: signInStartError.errorUri
errorUri: signInStartError.errorUri,
isBrowserRequired: self.type == .browserRequired,
isGeneralError: self.type == .generalError
)
}

Expand All @@ -78,11 +87,6 @@ public class PasswordRequiredError: MSALNativeAuthError {
}
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}

/// Returns `true` when the password is not valid.
public var isInvalidPassword: Bool {
return type == .invalidPassword
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public class RegisterStrongAuthChallengeError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

/// Describes why an error occurred and provides more information about the error.
Expand All @@ -63,11 +70,6 @@ public class RegisterStrongAuthChallengeError: MSALNativeAuthError {
return type == .invalidInput
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}

/// Returns `true` when the verification contact provided has been blocked. Try using another email or phone number, or select an alternative authentication method.
public var isVerificationContactBlocked: Bool {
return type == .verificationContactBlocked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ public class RegisterStrongAuthSubmitChallengeError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

/// Describes why an error occurred and provides more information about the error.
Expand All @@ -59,9 +66,4 @@ public class RegisterStrongAuthSubmitChallengeError: MSALNativeAuthError {
public var isInvalidChallenge: Bool {
return type == .invalidChallenge
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ public class ResetPasswordStartError: MSALNativeAuthError {

init(type: ErrorType, message: String? = nil, correlationId: UUID, errorCodes: [Int] = [], errorUri: String? = nil) {
self.type = type
super.init(message: message, correlationId: correlationId, errorCodes: errorCodes, errorUri: errorUri)
super.init(
message: message,
correlationId: correlationId,
errorCodes: errorCodes,
errorUri: errorUri,
isBrowserRequired: type == .browserRequired,
isGeneralError: type == .generalError
)
}

/// Describes why an error occurred and provides more information about the error.
Expand All @@ -62,11 +69,6 @@ public class ResetPasswordStartError: MSALNativeAuthError {
}
}

/// Returns `true` if a browser is required to continue the operation.
public var isBrowserRequired: Bool {
return type == .browserRequired
}

/// Returns `true` if the user does not have a password.
public var isUserDoesNotHavePassword: Bool {
return type == .userDoesNotHavePassword
Expand Down
Loading
Loading