Skip to content

Commit 56b0475

Browse files
authored
[Auth] Prefer immutable properties and private access level in *Request types (#14001)
1 parent 283a141 commit 56b0475

14 files changed

+153
-98
lines changed

FirebaseAuth/Sources/Swift/Backend/RPC/CreateAuthURIRequest.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,25 @@ class CreateAuthURIRequest: IdentityToolkitRequest, AuthRPCRequest {
5151
let identifier: String
5252

5353
/// The URI to which the IDP redirects the user after the federated login flow.
54-
let continueURI: String
54+
private let continueURI: String
5555

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

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

6464
/// The relying party OAuth client ID.
65-
var clientID: String?
65+
private let clientID: String? = nil
6666

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

7171
/// The iOS client application's bundle identifier.
72-
var appID: String?
72+
private let appID: String? = nil
7373

7474
init(identifier: String, continueURI: String,
7575
requestConfiguration: AuthRequestConfiguration) {

FirebaseAuth/Sources/Swift/Backend/RPC/GetOOBConfirmationCodeRequest.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,38 +107,38 @@ class GetOOBConfirmationCodeRequest: IdentityToolkitRequest, AuthRPCRequest {
107107
typealias Response = GetOOBConfirmationCodeResponse
108108

109109
/// The types of OOB Confirmation Code to request.
110-
let requestType: GetOOBConfirmationCodeRequestType
110+
private let requestType: GetOOBConfirmationCodeRequestType
111111

112112
/// The email of the user for password reset.
113-
private(set) var email: String?
113+
let email: String?
114114

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

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

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

124124
/// The iOS bundle Identifier, if available.
125-
private(set) var iOSBundleID: String?
125+
private let iOSBundleID: String?
126126

127127
/// The Android package name, if available.
128-
private(set) var androidPackageName: String?
128+
private let androidPackageName: String?
129129

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

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

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

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

143143
/// Response to the captcha.
144144
var captchaResponse: String?

FirebaseAuth/Sources/Swift/Backend/RPC/MultiFactor/Enroll/FinalizeMFAEnrollmentRequest.swift

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,47 @@ class FinalizeMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
2727

2828
let displayName: String?
2929

30-
var phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?
30+
let phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?
3131

32-
var totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?
32+
let totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?
3333

34-
init(idToken: String?, displayName: String?,
35-
phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?,
36-
requestConfiguration: AuthRequestConfiguration) {
37-
self.idToken = idToken
38-
self.displayName = displayName
39-
self.phoneVerificationInfo = phoneVerificationInfo
40-
super.init(
41-
endpoint: kFinalizeMFAEnrollmentEndPoint,
42-
requestConfiguration: requestConfiguration,
43-
useIdentityPlatform: true
34+
convenience init(idToken: String?, displayName: String?,
35+
phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?,
36+
requestConfiguration: AuthRequestConfiguration) {
37+
self.init(
38+
idToken: idToken,
39+
displayName: displayName,
40+
phoneVerificationInfo: phoneVerificationInfo,
41+
totpVerificationInfo: nil,
42+
requestConfiguration: requestConfiguration
4443
)
4544
}
4645

47-
init(idToken: String?, displayName: String?,
48-
totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?,
49-
requestConfiguration: AuthRequestConfiguration) {
46+
convenience init(idToken: String?, displayName: String?,
47+
totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?,
48+
requestConfiguration: AuthRequestConfiguration) {
49+
self.init(
50+
idToken: idToken,
51+
displayName: displayName,
52+
phoneVerificationInfo: nil,
53+
totpVerificationInfo: totpVerificationInfo,
54+
requestConfiguration: requestConfiguration
55+
)
56+
}
57+
58+
private init(idToken: String?, displayName: String?,
59+
phoneVerificationInfo: AuthProtoFinalizeMFAPhoneRequestInfo?,
60+
totpVerificationInfo: AuthProtoFinalizeMFATOTPEnrollmentRequestInfo?,
61+
requestConfiguration: AuthRequestConfiguration) {
5062
self.idToken = idToken
5163
self.displayName = displayName
64+
self.phoneVerificationInfo = phoneVerificationInfo
5265
self.totpVerificationInfo = totpVerificationInfo
5366
super.init(
5467
endpoint: kFinalizeMFAEnrollmentEndPoint,
5568
requestConfiguration: requestConfiguration,
56-
useIdentityPlatform: true
69+
useIdentityPlatform: true,
70+
useStaging: false
5771
)
5872
}
5973

FirebaseAuth/Sources/Swift/Backend/RPC/MultiFactor/Enroll/StartMFAEnrollmentRequest.swift

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,43 @@ class StartMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
2424
typealias Response = StartMFAEnrollmentResponse
2525

2626
let idToken: String?
27-
private(set) var phoneEnrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?
28-
private(set) var totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?
27+
let phoneEnrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?
28+
let totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?
2929

30-
init(idToken: String?,
31-
enrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?,
32-
requestConfiguration: AuthRequestConfiguration) {
33-
self.idToken = idToken
34-
phoneEnrollmentInfo = enrollmentInfo
35-
super.init(
36-
endpoint: kStartMFAEnrollmentEndPoint,
37-
requestConfiguration: requestConfiguration,
38-
useIdentityPlatform: true
30+
convenience init(idToken: String?,
31+
enrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?,
32+
requestConfiguration: AuthRequestConfiguration) {
33+
self.init(
34+
idToken: idToken,
35+
enrollmentInfo: enrollmentInfo,
36+
totpEnrollmentInfo: nil,
37+
requestConfiguration: requestConfiguration
3938
)
4039
}
4140

42-
init(idToken: String?,
43-
totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?,
44-
requestConfiguration: AuthRequestConfiguration) {
41+
convenience init(idToken: String?,
42+
totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?,
43+
requestConfiguration: AuthRequestConfiguration) {
44+
self.init(
45+
idToken: idToken,
46+
enrollmentInfo: nil,
47+
totpEnrollmentInfo: totpEnrollmentInfo,
48+
requestConfiguration: requestConfiguration
49+
)
50+
}
51+
52+
private init(idToken: String?,
53+
enrollmentInfo: AuthProtoStartMFAPhoneRequestInfo?,
54+
totpEnrollmentInfo: AuthProtoStartMFATOTPEnrollmentRequestInfo?,
55+
requestConfiguration: AuthRequestConfiguration) {
4556
self.idToken = idToken
57+
phoneEnrollmentInfo = enrollmentInfo
4658
self.totpEnrollmentInfo = totpEnrollmentInfo
4759
super.init(
4860
endpoint: kStartMFAEnrollmentEndPoint,
4961
requestConfiguration: requestConfiguration,
50-
useIdentityPlatform: true
62+
useIdentityPlatform: true,
63+
useStaging: false
5164
)
5265
}
5366

FirebaseAuth/Sources/Swift/Backend/RPC/MultiFactor/SignIn/FinalizeMFASignInRequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ private let kTenantIDKey = "tenantId"
2323
class FinalizeMFASignInRequest: IdentityToolkitRequest, AuthRPCRequest {
2424
typealias Response = FinalizeMFAEnrollmentResponse
2525

26-
var mfaPendingCredential: String?
27-
var verificationInfo: AuthProto?
26+
let mfaPendingCredential: String?
27+
let verificationInfo: AuthProto?
2828

2929
init(mfaPendingCredential: String?,
3030
verificationInfo: AuthProto?,

FirebaseAuth/Sources/Swift/Backend/RPC/MultiFactor/SignIn/StartMFASignInRequest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ private let kTenantIDKey = "tenantId"
2424
class StartMFASignInRequest: IdentityToolkitRequest, AuthRPCRequest {
2525
typealias Response = StartMFASignInResponse
2626

27-
var MFAPendingCredential: String?
28-
var MFAEnrollmentID: String?
29-
var signInInfo: AuthProtoStartMFAPhoneRequestInfo?
27+
let MFAPendingCredential: String?
28+
let MFAEnrollmentID: String?
29+
let signInInfo: AuthProtoStartMFAPhoneRequestInfo?
3030

3131
init(MFAPendingCredential: String?, MFAEnrollmentID: String?,
3232
signInInfo: AuthProtoStartMFAPhoneRequestInfo?,

FirebaseAuth/Sources/Swift/Backend/RPC/MultiFactor/Unenroll/WithdrawMFARequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ private let kTenantIDKey = "tenantId"
2323
class WithdrawMFARequest: IdentityToolkitRequest, AuthRPCRequest {
2424
typealias Response = WithdrawMFAResponse
2525

26-
var idToken: String?
27-
var mfaEnrollmentID: String?
26+
let idToken: String?
27+
let mfaEnrollmentID: String?
2828

2929
init(idToken: String?,
3030
mfaEnrollmentID: String?,

FirebaseAuth/Sources/Swift/Backend/RPC/RevokeTokenRequest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ class RevokeTokenRequest: IdentityToolkitRequest, AuthRPCRequest {
3737
typealias Response = RevokeTokenResponse
3838

3939
/// The provider that issued the token to revoke.
40-
private(set) var providerID: String
40+
let providerID: String
4141

4242
/// The type of the token to revoke.
43-
private(set) var tokenType: TokenType
43+
let tokenType: TokenType
4444

4545
/// The token to be revoked.
46-
private(set) var token: String
46+
let token: String
4747

4848
/// The ID Token associated with this credential.
49-
private(set) var idToken: String
49+
private let idToken: String
5050

5151
enum TokenType: Int {
5252
case unspecified = 0, refreshToken = 1, accessToken = 2, authorizationCode = 3

FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ class SecureTokenRequest: AuthRPCRequest {
6464

6565
/// The type of grant requested.
6666
/// See FIRSecureTokenRequestGrantType
67-
var grantType: SecureTokenRequestGrantType
67+
let grantType: SecureTokenRequestGrantType
6868

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

7272
/// The client's refresh token.
73-
var refreshToken: String?
73+
let refreshToken: String?
7474

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

7878
/// The client's API Key.
7979
let apiKey: String
@@ -107,8 +107,8 @@ class SecureTokenRequest: AuthRPCRequest {
107107
)
108108
}
109109

110-
init(grantType: SecureTokenRequestGrantType, scope: String?, refreshToken: String?,
111-
code: String?, requestConfiguration: AuthRequestConfiguration) {
110+
private init(grantType: SecureTokenRequestGrantType, scope: String?, refreshToken: String?,
111+
code: String?, requestConfiguration: AuthRequestConfiguration) {
112112
self.grantType = grantType
113113
self.scope = scope
114114
self.refreshToken = refreshToken

FirebaseAuth/Sources/Swift/Backend/RPC/SetAccountInfoRequest.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ class SetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
8989
var displayName: String?
9090

9191
/// The local ID of the user.
92-
var localID: String?
92+
var localID: String? = nil
9393

9494
/// The email of the user.
95-
var email: String?
95+
var email: String? = nil
9696

9797
/// The photoURL of the user.
9898
var photoURL: URL?
9999

100100
/// The new password of the user.
101-
var password: String?
101+
var password: String? = nil
102102

103103
/// The associated identity providers of the user.
104-
var providers: [String]?
104+
var providers: [String]? = nil
105105

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

115115
/// The captcha challenge.
116-
var captchaChallenge: String?
116+
var captchaChallenge: String? = nil
117117

118118
/// Response to the captcha.
119-
var captchaResponse: String?
119+
var captchaResponse: String? = nil
120120

121121
/// The list of user attributes to delete.
122122
///
123123
/// Every element of the list must be one of the predefined constant starts with
124124
/// `SetAccountInfoUserAttribute`.
125-
var deleteAttributes: [String]?
125+
var deleteAttributes: [String]? = nil
126126

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

134-
init(requestConfiguration: AuthRequestConfiguration) {
134+
init(accessToken: String? = nil, requestConfiguration: AuthRequestConfiguration) {
135+
self.accessToken = accessToken
135136
super.init(endpoint: kSetAccountInfoEndpoint, requestConfiguration: requestConfiguration)
136137
}
137138

0 commit comments

Comments
 (0)