2019-10-04 12:41:36 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2019-07-11 16:23:35 +02:00
|
|
|
package org.mozilla.fenix.components
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import mozilla.components.service.fxa.ServerConfig
|
2020-03-16 20:52:06 +01:00
|
|
|
import mozilla.components.service.fxa.ServerConfig.Server
|
2020-03-03 00:23:00 +01:00
|
|
|
import org.mozilla.fenix.ext.settings
|
2019-07-11 16:23:35 +02:00
|
|
|
|
2019-10-04 12:41:36 +02:00
|
|
|
/**
|
|
|
|
* Utility to configure Firefox Account servers.
|
|
|
|
*/
|
|
|
|
|
2019-07-11 16:23:35 +02:00
|
|
|
object FxaServer {
|
2020-06-16 00:48:12 +02:00
|
|
|
private const val CLIENT_ID = "a2270f727f45f648"
|
2020-06-16 20:13:17 +02:00
|
|
|
const val REDIRECT_URL = "urn:ietf:wg:oauth:2.0:oob:oauth-redirect-webchannel"
|
2019-07-11 16:23:35 +02:00
|
|
|
|
|
|
|
fun config(context: Context): ServerConfig {
|
2020-03-03 00:23:00 +01:00
|
|
|
val serverOverride = context.settings().overrideFxAServer
|
|
|
|
val tokenServerOverride = context.settings().overrideSyncTokenServer.ifEmpty { null }
|
|
|
|
if (serverOverride.isEmpty()) {
|
2020-06-16 20:21:45 +02:00
|
|
|
return ServerConfig(Server.RELEASE, CLIENT_ID, REDIRECT_URL, tokenServerOverride)
|
2020-03-03 00:23:00 +01:00
|
|
|
}
|
2020-06-16 20:21:45 +02:00
|
|
|
return ServerConfig(serverOverride, CLIENT_ID, REDIRECT_URL, tokenServerOverride)
|
2019-07-11 16:23:35 +02:00
|
|
|
}
|
|
|
|
}
|