Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Auth] Prefer immutable properties and private access level in *Request types #14001

Merged
merged 13 commits into from
Oct 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ class CreateAuthURIRequest: IdentityToolkitRequest, AuthRPCRequest {
let identifier: String

/// The URI to which the IDP redirects the user after the federated login flow.
let continueURI: String
private let continueURI: String

/// Optional realm for OpenID protocol. The sub string "scheme://domain:port" of the param
/// "continueUri" is used if this is not set.
var openIDRealm: String?
private let openIDRealm: String? = nil

/// The IdP ID. For white listed IdPs it's a short domain name e.g. google.com, aol.com,
/// live.net and yahoo.com. For other OpenID IdPs it's the OP identifier.
var providerID: String?
private let providerID: String? = nil

/// The relying party OAuth client ID.
var clientID: String?
private let clientID: String? = nil

/// The opaque value used by the client to maintain context info between the authentication
/// request and the IDP callback.
var context: String?
private let context: String? = nil

/// The iOS client application's bundle identifier.
var appID: String?
private let appID: String? = nil

init(identifier: String, continueURI: String,
requestConfiguration: AuthRequestConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,38 @@ class GetOOBConfirmationCodeRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = GetOOBConfirmationCodeResponse

/// The types of OOB Confirmation Code to request.
let requestType: GetOOBConfirmationCodeRequestType
private let requestType: GetOOBConfirmationCodeRequestType

/// The email of the user for password reset.
private(set) var email: String?
let email: String?

/// The new email to be updated for verifyBeforeUpdateEmail.
private(set) var updatedEmail: String?
private let updatedEmail: String?

/// The STS Access Token of the authenticated user for email change.
private(set) var accessToken: String?
private let accessToken: String?

/// This URL represents the state/Continue URL in the form of a universal link.
private(set) var continueURL: String?
let continueURL: String?

/// The iOS bundle Identifier, if available.
private(set) var iOSBundleID: String?
private let iOSBundleID: String?

/// The Android package name, if available.
private(set) var androidPackageName: String?
private let androidPackageName: String?

/// The minimum Android version supported, if available.
private(set) var androidMinimumVersion: String?
private let androidMinimumVersion: String?

/// Indicates whether or not the Android app should be installed if not already available.
private(set) var androidInstallApp: Bool
private let androidInstallApp: Bool

/// Indicates whether the action code link will open the app directly or after being
/// redirected from a Firebase owned web widget.
private(set) var handleCodeInApp: Bool
let handleCodeInApp: Bool

/// The Firebase Dynamic Link domain used for out of band code flow.
private(set) var dynamicLinkDomain: String?
private let dynamicLinkDomain: String?

/// Response to the captcha.
var captchaResponse: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,47 @@ class FinalizeMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {

let displayName: String?

var phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?
let phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?

var totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?
let totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?

init(idToken: String?, displayName: String?,
phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.idToken = idToken
self.displayName = displayName
self.phoneVerificationInfo = phoneVerificationInfo
super.init(
endpoint: kFinalizeMFAEnrollmentEndPoint,
requestConfiguration: requestConfiguration,
useIdentityPlatform: true
convenience init(idToken: String?, displayName: String?,
phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.init(
idToken: idToken,
displayName: displayName,
phoneVerificationInfo: phoneVerificationInfo,
totpVerificationInfo: nil,
requestConfiguration: requestConfiguration
)
}

init(idToken: String?, displayName: String?,
totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
convenience init(idToken: String?, displayName: String?,
totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.init(
idToken: idToken,
displayName: displayName,
phoneVerificationInfo: nil,
totpVerificationInfo: totpVerificationInfo,
requestConfiguration: requestConfiguration
)
}

private init(idToken: String?, displayName: String?,
phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?,
totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.idToken = idToken
self.displayName = displayName
self.phoneVerificationInfo = phoneVerificationInfo
self.totpVerificationInfo = totpVerificationInfo
super.init(
endpoint: kFinalizeMFAEnrollmentEndPoint,
requestConfiguration: requestConfiguration,
useIdentityPlatform: true
useIdentityPlatform: true,
useStaging: false
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,43 @@ class StartMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = StartMFAEnrollmentResponse

let idToken: String?
private(set) var phoneEnrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?
private(set) var totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?
let phoneEnrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?
let totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?

init(idToken: String?,
enrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.idToken = idToken
phoneEnrollmentInfo = enrollmentInfo
super.init(
endpoint: kStartMFAEnrollmentEndPoint,
requestConfiguration: requestConfiguration,
useIdentityPlatform: true
convenience init(idToken: String?,
enrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.init(
idToken: idToken,
enrollmentInfo: enrollmentInfo,
totpEnrollmentInfo: nil,
requestConfiguration: requestConfiguration
)
}

init(idToken: String?,
totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
convenience init(idToken: String?,
totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.init(
idToken: idToken,
enrollmentInfo: nil,
totpEnrollmentInfo: totpEnrollmentInfo,
requestConfiguration: requestConfiguration
)
}

private init(idToken: String?,
enrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?,
totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?,
requestConfiguration: AuthRequestConfiguration) {
self.idToken = idToken
phoneEnrollmentInfo = enrollmentInfo
self.totpEnrollmentInfo = totpEnrollmentInfo
super.init(
endpoint: kStartMFAEnrollmentEndPoint,
requestConfiguration: requestConfiguration,
useIdentityPlatform: true
useIdentityPlatform: true,
useStaging: false
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ private let kTenantIDKey = "tenantId"
class FinalizeMFASignInRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = FinalizeMFAEnrollmentResponse

var mfaPendingCredential: String?
var verificationInfo: AuthProto?
let mfaPendingCredential: String?
let verificationInfo: AuthProto?

init(mfaPendingCredential: String?,
verificationInfo: AuthProto?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ private let kTenantIDKey = "tenantId"
class StartMFASignInRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = StartMFASignInResponse

var MFAPendingCredential: String?
var MFAEnrollmentID: String?
var signInInfo: AuthProtoStartMFAPhoneRequestInfo?
let MFAPendingCredential: String?
let MFAEnrollmentID: String?
let signInInfo: AuthProtoStartMFAPhoneRequestInfo?

init(MFAPendingCredential: String?, MFAEnrollmentID: String?,
signInInfo: AuthProtoStartMFAPhoneRequestInfo?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ private let kTenantIDKey = "tenantId"
class WithdrawMFARequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = WithdrawMFAResponse

var idToken: String?
var mfaEnrollmentID: String?
let idToken: String?
let mfaEnrollmentID: String?

init(idToken: String?,
mfaEnrollmentID: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ class RevokeTokenRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = RevokeTokenResponse

/// The provider that issued the token to revoke.
private(set) var providerID: String
let providerID: String

/// The type of the token to revoke.
private(set) var tokenType: TokenType
let tokenType: TokenType

/// The token to be revoked.
private(set) var token: String
let token: String

/// The ID Token associated with this credential.
private(set) var idToken: String
private let idToken: String

enum TokenType: Int {
case unspecified = 0, refreshToken = 1, accessToken = 2, authorizationCode = 3
Expand Down
12 changes: 6 additions & 6 deletions FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ class SecureTokenRequest: AuthRPCRequest {

/// The type of grant requested.
/// See FIRSecureTokenRequestGrantType
var grantType: SecureTokenRequestGrantType
let grantType: SecureTokenRequestGrantType

/// The scopes requested (a comma-delimited list of scope strings).
var scope: String?
let scope: String?

/// The client's refresh token.
var refreshToken: String?
let refreshToken: String?

/// The client's authorization code (legacy Gitkit "ID Token").
var code: String?
let code: String?

/// The client's API Key.
let apiKey: String
Expand Down Expand Up @@ -107,8 +107,8 @@ class SecureTokenRequest: AuthRPCRequest {
)
}

init(grantType: SecureTokenRequestGrantType, scope: String?, refreshToken: String?,
code: String?, requestConfiguration: AuthRequestConfiguration) {
private init(grantType: SecureTokenRequestGrantType, scope: String?, refreshToken: String?,
code: String?, requestConfiguration: AuthRequestConfiguration) {
self.grantType = grantType
self.scope = scope
self.refreshToken = refreshToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ class SetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
var displayName: String?

/// The local ID of the user.
var localID: String?
var localID: String? = nil

/// The email of the user.
var email: String?
var email: String? = nil

/// The photoURL of the user.
var photoURL: URL?

/// The new password of the user.
var password: String?
var password: String? = nil

/// The associated identity providers of the user.
var providers: [String]?
var providers: [String]? = nil

/// The out-of-band code of the change email request.
var oobCode: String?
Expand All @@ -113,16 +113,16 @@ class SetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
var upgradeToFederatedLogin: Bool = false

/// The captcha challenge.
var captchaChallenge: String?
var captchaChallenge: String? = nil

/// Response to the captcha.
var captchaResponse: String?
var captchaResponse: String? = nil

/// The list of user attributes to delete.
///
/// Every element of the list must be one of the predefined constant starts with
/// `SetAccountInfoUserAttribute`.
var deleteAttributes: [String]?
var deleteAttributes: [String]? = nil

/// The list of identity providers to delete.
var deleteProviders: [String]?
Expand All @@ -131,7 +131,8 @@ class SetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
/// The default value is `true` .
var returnSecureToken: Bool = true

init(requestConfiguration: AuthRequestConfiguration) {
init(accessToken: String? = nil, requestConfiguration: AuthRequestConfiguration) {
self.accessToken = accessToken
super.init(endpoint: kSetAccountInfoEndpoint, requestConfiguration: requestConfiguration)
}

Expand Down
Loading
Loading