salesforce-mobilesdk-cordova-plugin 13.0.0 → 13.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin.xml +7 -7
- package/src/android/libs/mobile_sdk/README.md +1 -1
- package/src/android/libs/mobile_sdk/build.gradle.kts +1 -1
- package/src/android/libs/mobile_sdk/libs/MobileSync/AndroidManifest.xml +2 -2
- package/src/android/libs/mobile_sdk/libs/MobileSync/build.gradle.kts +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceAnalytics/AndroidManifest.xml +2 -2
- package/src/android/libs/mobile_sdk/libs/SalesforceAnalytics/build.gradle.kts +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceHybrid/AndroidManifest.xml +2 -2
- package/src/android/libs/mobile_sdk/libs/SalesforceHybrid/build.gradle.kts +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceHybrid/res/xml/config.xml +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/AndroidManifest.xml +2 -2
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/build.gradle.kts +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/app/SalesforceSDKManager.kt +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/app/SalesforceSDKUpgradeManager.java +7 -0
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/AuthenticationUtilities.kt +22 -17
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/NativeLoginManager.kt +19 -16
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/idp/SPAuthCodeHelper.kt +1 -1
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/security/KeyStoreWrapper.java +30 -0
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/security/SalesforceKeyGenerator.java +6 -0
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/ui/LoginActivity.kt +18 -6
- package/src/android/libs/mobile_sdk/libs/SalesforceSDK/src/com/salesforce/androidsdk/ui/LoginViewModel.kt +3 -2
- package/src/android/libs/mobile_sdk/libs/SmartStore/AndroidManifest.xml +2 -2
- package/src/android/libs/mobile_sdk/libs/SmartStore/build.gradle.kts +1 -1
- package/src/android/libs/mobile_sdk/libs/test/SalesforceHybridTest/res/xml/config.xml +1 -1
- package/src/android/libs/mobile_sdk/libs/test/SalesforceSDKTest/src/com/salesforce/androidsdk/app/SalesforceSDKUpgradeManagerTest.kt +17 -2
- package/src/android/libs/mobile_sdk/libs/test/SalesforceSDKTest/src/com/salesforce/androidsdk/security/KeyStoreWrapperTest.java +23 -0
- package/src/android/libs/mobile_sdk/package.json +1 -1
- package/tools/postinstall-android.js +1 -1
- package/www/com.salesforce.plugin.mobilesync.js +1 -1
- package/www/com.salesforce.plugin.network.js +1 -1
- package/www/com.salesforce.plugin.oauth.js +1 -1
- package/www/com.salesforce.plugin.sdkinfo.js +1 -1
- package/www/com.salesforce.plugin.sfaccountmanager.js +1 -1
- package/www/com.salesforce.plugin.smartstore.client.js +1 -1
- package/www/com.salesforce.plugin.smartstore.js +1 -1
- package/www/com.salesforce.util.bootstrap.js +1 -1
- package/www/com.salesforce.util.event.js +1 -1
- package/www/com.salesforce.util.exec.js +1 -1
- package/www/com.salesforce.util.logger.js +1 -1
- package/www/com.salesforce.util.promiser.js +1 -1
- package/www/com.salesforce.util.push.js +1 -1
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
5
5
|
id="com.salesforce"
|
|
6
|
-
version="13.0.
|
|
6
|
+
version="13.0.2">
|
|
7
7
|
|
|
8
8
|
<name>SalesforceMobileSDK Plugins</name>
|
|
9
9
|
<description>SalesforceMobileSDK Plugins</description>
|
|
@@ -94,12 +94,12 @@
|
|
|
94
94
|
<source url="https://cdn.cocoapods.org"/>
|
|
95
95
|
</config>
|
|
96
96
|
<pods use-frameworks="true">
|
|
97
|
-
<pod name="SalesforceHybridSDK" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Hybrid" tag="v13.0.
|
|
98
|
-
<pod name="MobileSync" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.
|
|
99
|
-
<pod name="SmartStore" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.
|
|
100
|
-
<pod name="SalesforceSDKCore" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.
|
|
101
|
-
<pod name="SalesforceAnalytics" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.
|
|
102
|
-
<pod name="SalesforceSDKCommon" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.
|
|
97
|
+
<pod name="SalesforceHybridSDK" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Hybrid" tag="v13.0.2" />
|
|
98
|
+
<pod name="MobileSync" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.2" />
|
|
99
|
+
<pod name="SmartStore" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.2" />
|
|
100
|
+
<pod name="SalesforceSDKCore" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.2" />
|
|
101
|
+
<pod name="SalesforceAnalytics" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.2" />
|
|
102
|
+
<pod name="SalesforceSDKCommon" git="https://github.com/forcedotcom/SalesforceMobileSDK-iOS" tag="v13.0.2" />
|
|
103
103
|
<!-- Needed until cordova-ios gets posted to cocoapod.org -->
|
|
104
104
|
<pod name="Cordova" git="https://github.com/apache/cordova-ios" tag="7.1.1" />
|
|
105
105
|
</pods>
|
|
@@ -18,7 +18,7 @@ buildscript {
|
|
|
18
18
|
|
|
19
19
|
allprojects {
|
|
20
20
|
group = "com.salesforce.mobilesdk"
|
|
21
|
-
version = "13.0.
|
|
21
|
+
version = "13.0.2"
|
|
22
22
|
|
|
23
23
|
// Ensure that we do not use newer language features that would make the SDK incompatible with
|
|
24
24
|
// apps that do not target the latest version of Kotlin.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
|
|
3
3
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
-
android:versionCode="
|
|
5
|
-
android:versionName="13.0.
|
|
4
|
+
android:versionCode="89"
|
|
5
|
+
android:versionName="13.0.2">
|
|
6
6
|
|
|
7
7
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
8
8
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
|
|
3
3
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
-
android:versionCode="
|
|
5
|
-
android:versionName="13.0.
|
|
4
|
+
android:versionCode="89"
|
|
5
|
+
android:versionName="13.0.2">
|
|
6
6
|
|
|
7
7
|
<application>
|
|
8
8
|
<activity android:name="com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@file:Suppress("UnstableApiUsage")
|
|
2
2
|
|
|
3
3
|
rootProject.ext["PUBLISH_GROUP_ID"] = "com.salesforce.mobilesdk"
|
|
4
|
-
rootProject.ext["PUBLISH_VERSION"] = "13.0.
|
|
4
|
+
rootProject.ext["PUBLISH_VERSION"] = "13.0.2"
|
|
5
5
|
rootProject.ext["PUBLISH_ARTIFACT_ID"] = "SalesforceHybrid"
|
|
6
6
|
|
|
7
7
|
plugins {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
xmlns:tools="http://schemas.android.com/tools"
|
|
5
|
-
android:versionCode="
|
|
6
|
-
android:versionName="13.0.
|
|
5
|
+
android:versionCode="89"
|
|
6
|
+
android:versionName="13.0.2">
|
|
7
7
|
|
|
8
8
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
|
9
9
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
|
@@ -1557,7 +1557,7 @@ open class SalesforceSDKManager protected constructor(
|
|
|
1557
1557
|
protected var INSTANCE: SalesforceSDKManager? = null
|
|
1558
1558
|
|
|
1559
1559
|
/** The current version of this SDK */
|
|
1560
|
-
const val SDK_VERSION = "13.0.
|
|
1560
|
+
const val SDK_VERSION = "13.0.2"
|
|
1561
1561
|
|
|
1562
1562
|
/**
|
|
1563
1563
|
* An intent action meant for instances of Salesforce SDK manager
|
|
@@ -130,6 +130,9 @@ public class SalesforceSDKUpgradeManager {
|
|
|
130
130
|
if (installedVersion.isLessThan(new SdkVersion(12, 0, 0, false))) {
|
|
131
131
|
updateFromBefore12_0_0();
|
|
132
132
|
}
|
|
133
|
+
if (installedVersion.isLessThan(new SdkVersion(13, 0, 2, false))) {
|
|
134
|
+
updateFromBefore13_0_2();
|
|
135
|
+
}
|
|
133
136
|
} catch (Exception e) {
|
|
134
137
|
SalesforceSDKLogger.e(
|
|
135
138
|
TAG,
|
|
@@ -306,4 +309,8 @@ public class SalesforceSDKUpgradeManager {
|
|
|
306
309
|
PushMessaging.setReRegistrationRequested(true);
|
|
307
310
|
}
|
|
308
311
|
|
|
312
|
+
private void updateFromBefore13_0_2() {
|
|
313
|
+
// Re-register all users for push notifications with new keys once push is setup
|
|
314
|
+
PushMessaging.setReRegistrationRequested(true);
|
|
315
|
+
}
|
|
309
316
|
}
|
|
@@ -42,9 +42,9 @@ import com.salesforce.androidsdk.analytics.SalesforceAnalyticsManager
|
|
|
42
42
|
import com.salesforce.androidsdk.app.Features.FEATURE_BIOMETRIC_AUTH
|
|
43
43
|
import com.salesforce.androidsdk.app.Features.FEATURE_SCREEN_LOCK
|
|
44
44
|
import com.salesforce.androidsdk.app.SalesforceSDKManager
|
|
45
|
-
import com.salesforce.androidsdk.auth.OAuth2.IdServiceResponse
|
|
46
45
|
import com.salesforce.androidsdk.auth.OAuth2.TokenEndpointResponse
|
|
47
46
|
import com.salesforce.androidsdk.auth.OAuth2.addAuthorizationHeader
|
|
47
|
+
import com.salesforce.androidsdk.auth.OAuth2.callIdentityService
|
|
48
48
|
import com.salesforce.androidsdk.auth.OAuth2.revokeRefreshToken
|
|
49
49
|
import com.salesforce.androidsdk.config.RuntimeConfig.getRuntimeConfig
|
|
50
50
|
import com.salesforce.androidsdk.push.PushMessaging.register
|
|
@@ -55,8 +55,10 @@ import com.salesforce.androidsdk.security.ScreenLockManager
|
|
|
55
55
|
import com.salesforce.androidsdk.util.SalesforceSDKLogger.e
|
|
56
56
|
import com.salesforce.androidsdk.util.SalesforceSDKLogger.w
|
|
57
57
|
import kotlinx.coroutines.CoroutineScope
|
|
58
|
+
import kotlinx.coroutines.Dispatchers.Default
|
|
58
59
|
import kotlinx.coroutines.Dispatchers.IO
|
|
59
60
|
import kotlinx.coroutines.launch
|
|
61
|
+
import kotlinx.coroutines.withContext
|
|
60
62
|
import okhttp3.HttpUrl
|
|
61
63
|
import okhttp3.Interceptor
|
|
62
64
|
import okhttp3.Request.Builder
|
|
@@ -83,7 +85,7 @@ private const val TAG = "AuthenticationUtilities"
|
|
|
83
85
|
* * Creates an Account.
|
|
84
86
|
* * Checks for any CA/ECA settings such as Screen Lock or Biometric Authentication.
|
|
85
87
|
*/
|
|
86
|
-
internal fun onAuthFlowComplete(
|
|
88
|
+
internal suspend fun onAuthFlowComplete(
|
|
87
89
|
tokenResponse: TokenEndpointResponse,
|
|
88
90
|
loginServer: String,
|
|
89
91
|
consumerKey: String,
|
|
@@ -113,14 +115,17 @@ internal fun onAuthFlowComplete(
|
|
|
113
115
|
return
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
val userIdentity = runCatching {
|
|
119
|
+
withContext(Default) {
|
|
120
|
+
callIdentityService(
|
|
121
|
+
HttpAccess.DEFAULT,
|
|
122
|
+
tokenResponse.idUrlWithInstance,
|
|
123
|
+
tokenResponse.authToken,
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
}.onFailure { throwable ->
|
|
127
|
+
w(TAG, "Cannot fetch user identity due to an error.", throwable)
|
|
128
|
+
}.getOrNull()
|
|
124
129
|
|
|
125
130
|
val mustBeManagedApp = userIdentity?.customPermissions?.optBoolean(MUST_BE_MANAGED_APP_PERM) ?: false
|
|
126
131
|
if (mustBeManagedApp && !getRuntimeConfig(context).isManagedApp) {
|
|
@@ -196,6 +201,8 @@ internal fun onAuthFlowComplete(
|
|
|
196
201
|
|
|
197
202
|
// Save the user account
|
|
198
203
|
addAccount(account)
|
|
204
|
+
userAccountManager.createAccount(account)
|
|
205
|
+
userAccountManager.switchToUser(account)
|
|
199
206
|
|
|
200
207
|
// Init user logging
|
|
201
208
|
SalesforceAnalyticsManager.getInstance(account)?.updateLoggingPrefs()
|
|
@@ -213,8 +220,6 @@ internal fun onAuthFlowComplete(
|
|
|
213
220
|
else -> USER_SWITCH_TYPE_DEFAULT
|
|
214
221
|
}
|
|
215
222
|
userAccountManager.sendUserSwitchIntent(userSwitchType, null)
|
|
216
|
-
userAccountManager.createAccount(account)
|
|
217
|
-
userAccountManager.switchToUser(account)
|
|
218
223
|
|
|
219
224
|
// Kickoff the end of the flow before storing mobile policy to prevent launching
|
|
220
225
|
// the main activity over/after the screen lock.
|
|
@@ -231,10 +236,10 @@ internal fun onAuthFlowComplete(
|
|
|
231
236
|
// Screen lock required by mobile policy
|
|
232
237
|
if (userIdentity?.screenLockTimeout?.compareTo(0) == 1) {
|
|
233
238
|
SalesforceSDKManager.getInstance().registerUsedAppFeature(FEATURE_SCREEN_LOCK)
|
|
234
|
-
val timeoutInMills =
|
|
239
|
+
val timeoutInMills = userIdentity.screenLockTimeout * 1000 * 60
|
|
235
240
|
(SalesforceSDKManager.getInstance().screenLockManager as ScreenLockManager?)?.storeMobilePolicy(
|
|
236
241
|
account,
|
|
237
|
-
userIdentity
|
|
242
|
+
userIdentity.screenLock,
|
|
238
243
|
timeoutInMills
|
|
239
244
|
)
|
|
240
245
|
}
|
|
@@ -242,10 +247,10 @@ internal fun onAuthFlowComplete(
|
|
|
242
247
|
// Biometric authorization required by mobile policy
|
|
243
248
|
if (userIdentity?.biometricAuth == true) {
|
|
244
249
|
SalesforceSDKManager.getInstance().registerUsedAppFeature(FEATURE_BIOMETRIC_AUTH)
|
|
245
|
-
val timeoutInMills =
|
|
250
|
+
val timeoutInMills = userIdentity.biometricAuthTimeout * 60 * 1000
|
|
246
251
|
(SalesforceSDKManager.getInstance().biometricAuthenticationManager as BiometricAuthenticationManager?)?.storeMobilePolicy(
|
|
247
252
|
account,
|
|
248
|
-
userIdentity
|
|
253
|
+
userIdentity.biometricAuth,
|
|
249
254
|
timeoutInMills
|
|
250
255
|
)
|
|
251
256
|
}
|
|
@@ -307,7 +312,7 @@ private fun HttpUrl.isSalesforceUrl(): Boolean {
|
|
|
307
312
|
// List from https://help.salesforce.com/s/articleView?language=en_US&id=sf.domain_name_url_formats.htm&type=5
|
|
308
313
|
val salesforceHosts = listOf(".salesforce.com", ".force.com", ".sfdcopens.com", ".site.com", ".lightning.com",
|
|
309
314
|
".salesforce-sites.com", ".force-user-content.com", ".salesforce-experience.com", ".salesforce-scrt.com")
|
|
310
|
-
return salesforceHosts.map { host.endsWith(it) }.any
|
|
315
|
+
return salesforceHosts.map { host.endsWith(it) }.any { it }
|
|
311
316
|
}
|
|
312
317
|
|
|
313
318
|
private fun addAccount(account: UserAccount?) {
|
|
@@ -75,7 +75,8 @@ import com.salesforce.androidsdk.security.BiometricAuthenticationManager.Compani
|
|
|
75
75
|
import com.salesforce.androidsdk.security.SalesforceKeyGenerator.getRandom128ByteKey
|
|
76
76
|
import com.salesforce.androidsdk.security.SalesforceKeyGenerator.getSHA256Hash
|
|
77
77
|
import com.salesforce.androidsdk.util.SalesforceSDKLogger
|
|
78
|
-
import kotlinx.coroutines.Dispatchers
|
|
78
|
+
import kotlinx.coroutines.Dispatchers.Default
|
|
79
|
+
import kotlinx.coroutines.runBlocking
|
|
79
80
|
import kotlinx.coroutines.withContext
|
|
80
81
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|
81
82
|
import okhttp3.RequestBody
|
|
@@ -196,22 +197,24 @@ internal class NativeLoginManager(
|
|
|
196
197
|
val tokenEndpointResponse = TokenEndpointResponse(tokenResponse.rawResponse)
|
|
197
198
|
tokenResponse.consumeQuietly()
|
|
198
199
|
|
|
199
|
-
return withContext(
|
|
200
|
+
return withContext(Default) {
|
|
200
201
|
suspendCoroutine { continuation ->
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
202
|
+
runBlocking {
|
|
203
|
+
onAuthFlowComplete(
|
|
204
|
+
tokenResponse = tokenEndpointResponse,
|
|
205
|
+
loginServer = loginUrl,
|
|
206
|
+
consumerKey = clientId,
|
|
207
|
+
onAuthFlowError = { error, errorDesc, e ->
|
|
208
|
+
SalesforceSDKLogger.e(TAG, "$error: $errorDesc", e)
|
|
209
|
+
continuation.resume(UnknownError)
|
|
210
|
+
},
|
|
211
|
+
onAuthFlowSuccess = { userAccount ->
|
|
212
|
+
SalesforceSDKLogger.d(TAG, "onAuthFlowSuccess $userAccount")
|
|
213
|
+
continuation.resume(Success)
|
|
214
|
+
},
|
|
215
|
+
nativeLogin = true,
|
|
216
|
+
)
|
|
217
|
+
}
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
}
|
|
@@ -83,7 +83,7 @@ internal class SPAuthCodeHelper private constructor (
|
|
|
83
83
|
return tokenResponse
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
private fun completeLogin(tokenResponse: TokenEndpointResponse) {
|
|
86
|
+
private suspend fun completeLogin(tokenResponse: TokenEndpointResponse) {
|
|
87
87
|
onAuthFlowComplete(
|
|
88
88
|
tokenResponse = tokenResponse,
|
|
89
89
|
loginServer = loginUrl,
|
|
@@ -28,12 +28,14 @@ package com.salesforce.androidsdk.security;
|
|
|
28
28
|
|
|
29
29
|
import android.os.Build;
|
|
30
30
|
import android.security.keystore.KeyGenParameterSpec;
|
|
31
|
+
import android.security.keystore.KeyInfo;
|
|
31
32
|
import android.security.keystore.KeyProperties;
|
|
32
33
|
import android.util.Base64;
|
|
33
34
|
|
|
34
35
|
import com.salesforce.androidsdk.util.SalesforceSDKLogger;
|
|
35
36
|
|
|
36
37
|
import java.io.IOException;
|
|
38
|
+
import java.security.KeyFactory;
|
|
37
39
|
import java.security.KeyPairGenerator;
|
|
38
40
|
import java.security.KeyStore;
|
|
39
41
|
import java.security.KeyStoreException;
|
|
@@ -253,6 +255,34 @@ public class KeyStoreWrapper {
|
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Checks if the RSA key supports OAEP encryption padding.
|
|
260
|
+
*
|
|
261
|
+
* @param name Alias of the key to check.
|
|
262
|
+
* @return true if the key supports OAEP padding, false otherwise.
|
|
263
|
+
*/
|
|
264
|
+
public boolean keySupportsOAEPPadding(String name) {
|
|
265
|
+
try {
|
|
266
|
+
if (keyStore.containsAlias(name)) {
|
|
267
|
+
PrivateKey privateKey = (PrivateKey) keyStore.getKey(name, null);
|
|
268
|
+
KeyFactory keyFactory = KeyFactory.getInstance(privateKey.getAlgorithm(), ANDROID_KEYSTORE);
|
|
269
|
+
KeyInfo keyInfo = keyFactory.getKeySpec(privateKey, KeyInfo.class);
|
|
270
|
+
String[] encryptionPaddings = keyInfo.getEncryptionPaddings();
|
|
271
|
+
|
|
272
|
+
if (encryptionPaddings != null) {
|
|
273
|
+
for (String padding : encryptionPaddings) {
|
|
274
|
+
if (KeyProperties.ENCRYPTION_PADDING_RSA_OAEP.equals(padding)) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
} catch (Exception e) {
|
|
281
|
+
SalesforceSDKLogger.e(TAG, "Could not check key padding capabilities", e);
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
|
|
256
286
|
// For testing only - create key the way we used to before the 11.1.1 cipher change
|
|
257
287
|
synchronized void legacyCreateKeysIfNecessary(String algorithm, String name, int length) {
|
|
258
288
|
try {
|
|
@@ -176,6 +176,12 @@ public class SalesforceKeyGenerator {
|
|
|
176
176
|
|
|
177
177
|
// Encrypt and store unique id if it was just created, or if it had to be decrypted with old cipher mode
|
|
178
178
|
if (storeUniqueId) {
|
|
179
|
+
// Check if existing key supports OAEP padding, recreate if not
|
|
180
|
+
if (!KeyStoreWrapper.getInstance().keySupportsOAEPPadding(KEYSTORE_ALIAS)) {
|
|
181
|
+
SalesforceSDKLogger.i(TAG, "Key doesn't support OAEP padding, recreating key pair with OAEP support");
|
|
182
|
+
KeyStoreWrapper.getInstance().deleteKey(KEYSTORE_ALIAS);
|
|
183
|
+
}
|
|
184
|
+
|
|
179
185
|
final PublicKey publicKey = KeyStoreWrapper.getInstance().getRSAPublicKey(KEYSTORE_ALIAS);
|
|
180
186
|
final String encryptedKey = Encryptor.encryptWithRSA(publicKey, uniqueId, Encryptor.CipherMode.RSA_OAEP_SHA256);
|
|
181
187
|
storeInSharedPrefs(ID_PREFIX + name, encryptedKey);
|
|
@@ -93,10 +93,12 @@ import androidx.browser.customtabs.CustomTabColorSchemeParams
|
|
|
93
93
|
import androidx.browser.customtabs.CustomTabsIntent
|
|
94
94
|
import androidx.compose.material3.MaterialTheme
|
|
95
95
|
import androidx.compose.ui.graphics.Color
|
|
96
|
+
import androidx.compose.ui.graphics.luminance
|
|
96
97
|
import androidx.compose.ui.graphics.toArgb
|
|
97
98
|
import androidx.core.content.ContextCompat
|
|
98
99
|
import androidx.core.content.ContextCompat.getMainExecutor
|
|
99
100
|
import androidx.core.net.toUri
|
|
101
|
+
import androidx.core.view.WindowCompat
|
|
100
102
|
import androidx.fragment.app.FragmentActivity
|
|
101
103
|
import com.salesforce.androidsdk.R.color.sf__background
|
|
102
104
|
import com.salesforce.androidsdk.R.color.sf__background_dark
|
|
@@ -137,6 +139,7 @@ import com.salesforce.androidsdk.util.SalesforceSDKLogger.e
|
|
|
137
139
|
import com.salesforce.androidsdk.util.SalesforceSDKLogger.w
|
|
138
140
|
import com.salesforce.androidsdk.util.UriFragmentParser
|
|
139
141
|
import kotlinx.coroutines.CoroutineScope
|
|
142
|
+
import kotlinx.coroutines.Dispatchers.Default
|
|
140
143
|
import kotlinx.coroutines.Dispatchers.IO
|
|
141
144
|
import kotlinx.coroutines.launch
|
|
142
145
|
import org.json.JSONObject
|
|
@@ -519,7 +522,7 @@ open class LoginActivity : FragmentActivity() {
|
|
|
519
522
|
* @param errorDesc The error description
|
|
520
523
|
* @param e The exception
|
|
521
524
|
*/
|
|
522
|
-
protected fun onAuthFlowError(
|
|
525
|
+
protected open fun onAuthFlowError(
|
|
523
526
|
error: String,
|
|
524
527
|
errorDesc: String?,
|
|
525
528
|
e: Throwable? = null,
|
|
@@ -884,11 +887,13 @@ open class LoginActivity : FragmentActivity() {
|
|
|
884
887
|
)
|
|
885
888
|
|
|
886
889
|
else ->
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
890
|
+
CoroutineScope(Default).launch {
|
|
891
|
+
viewModel.onAuthFlowComplete(
|
|
892
|
+
TokenEndpointResponse(params),
|
|
893
|
+
::onAuthFlowError,
|
|
894
|
+
::onAuthFlowSuccess
|
|
895
|
+
)
|
|
896
|
+
}
|
|
892
897
|
}
|
|
893
898
|
}
|
|
894
899
|
}
|
|
@@ -914,6 +919,13 @@ open class LoginActivity : FragmentActivity() {
|
|
|
914
919
|
|
|
915
920
|
viewModel.dynamicBackgroundColor.value = validateAndExtractBackgroundColor(result)
|
|
916
921
|
?: return@evaluateJavascript
|
|
922
|
+
|
|
923
|
+
// Ensure Status Bar Icons are readable no matter which OS theme is used.
|
|
924
|
+
val titleTextColorLight = viewModel.titleTextColor?.luminance()?.let { it < 0.5 }
|
|
925
|
+
val topAppBarDark = viewModel.topBarColor?.luminance()?.let { it < 0.5 }
|
|
926
|
+
val dynamicThemeIsDark = viewModel.dynamicBackgroundTheme.value == DARK
|
|
927
|
+
val useLightIcons = titleTextColorLight ?: topAppBarDark ?: dynamicThemeIsDark
|
|
928
|
+
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = useLightIcons
|
|
917
929
|
}.also {
|
|
918
930
|
if (!viewModel.authFinished.value) {
|
|
919
931
|
viewModel.loading.value = false
|
|
@@ -54,6 +54,7 @@ import com.salesforce.androidsdk.auth.OAuth2.TokenEndpointResponse
|
|
|
54
54
|
import com.salesforce.androidsdk.auth.OAuth2.exchangeCode
|
|
55
55
|
import com.salesforce.androidsdk.auth.OAuth2.getFrontdoorUrl
|
|
56
56
|
import com.salesforce.androidsdk.auth.defaultBuildAccountName
|
|
57
|
+
import com.salesforce.androidsdk.auth.onAuthFlowComplete
|
|
57
58
|
import com.salesforce.androidsdk.config.BootConfig
|
|
58
59
|
import com.salesforce.androidsdk.security.SalesforceKeyGenerator.getRandom128ByteKey
|
|
59
60
|
import com.salesforce.androidsdk.security.SalesforceKeyGenerator.getSHA256Hash
|
|
@@ -240,7 +241,7 @@ open class LoginViewModel(val bootConfig: BootConfig) : ViewModel() {
|
|
|
240
241
|
* Called when the webview portion of the User Agent flow or the code exchange
|
|
241
242
|
* portion of the Web Server is finished to create and the user.
|
|
242
243
|
*/
|
|
243
|
-
internal fun onAuthFlowComplete(
|
|
244
|
+
internal suspend fun onAuthFlowComplete(
|
|
244
245
|
tr: TokenEndpointResponse,
|
|
245
246
|
onAuthFlowError: (error: String, errorDesc: String?, e: Throwable?) -> Unit,
|
|
246
247
|
onAuthFlowSuccess: (userAccount: UserAccount) -> Unit,
|
|
@@ -249,7 +250,7 @@ open class LoginViewModel(val bootConfig: BootConfig) : ViewModel() {
|
|
|
249
250
|
// if the user tries to add another user right away.
|
|
250
251
|
clearCookies()
|
|
251
252
|
authCodeForJwtFlow = null
|
|
252
|
-
|
|
253
|
+
onAuthFlowComplete(
|
|
253
254
|
tokenResponse = tr,
|
|
254
255
|
loginServer = selectedServer.value ?: "", // This will never actually be null.
|
|
255
256
|
consumerKey = clientId,
|
|
@@ -156,9 +156,24 @@ class SalesforceSDKUpgradeManagerTest {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
@Test
|
|
159
|
-
fun
|
|
159
|
+
fun testUpgradeFromBefore1302() {
|
|
160
|
+
// Set version to a version before 13.0.2
|
|
161
|
+
setVersion("12.2.0")
|
|
162
|
+
|
|
163
|
+
// Create public key for push notifications
|
|
164
|
+
KeyStoreWrapper.getInstance().getRSAPublicString(PushService.pushNotificationKeyName)
|
|
165
|
+
|
|
166
|
+
// Upgrade to latest
|
|
167
|
+
upgradeMgr.upgrade()
|
|
168
|
+
|
|
169
|
+
// Make sure re-registration is requested
|
|
170
|
+
Assert.assertTrue(PushMessaging.reRegistrationRequested)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@Test
|
|
174
|
+
fun testUpgradeAfter1302() {
|
|
160
175
|
// Set version to 12.0.0
|
|
161
|
-
setVersion("
|
|
176
|
+
setVersion("13.0.2")
|
|
162
177
|
|
|
163
178
|
// Create public key for push notifications
|
|
164
179
|
KeyStoreWrapper.getInstance().getRSAPublicString(PushService.pushNotificationKeyName)
|
|
@@ -58,6 +58,7 @@ public class KeyStoreWrapperTest {
|
|
|
58
58
|
|
|
59
59
|
private static final String KEY_1 = "key_1";
|
|
60
60
|
private static final String KEY_2 = "key_2";
|
|
61
|
+
private static final String KEY_OAEP_TEST = "key_oaep_test";
|
|
61
62
|
private static final int RSA_LENGTH = 2048;
|
|
62
63
|
|
|
63
64
|
@Before
|
|
@@ -72,6 +73,7 @@ public class KeyStoreWrapperTest {
|
|
|
72
73
|
final KeyStoreWrapper keyStoreWrapper = KeyStoreWrapper.getInstance();
|
|
73
74
|
keyStoreWrapper.deleteKey(KEY_1);
|
|
74
75
|
keyStoreWrapper.deleteKey(KEY_2);
|
|
76
|
+
keyStoreWrapper.deleteKey(KEY_OAEP_TEST);
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
@Test
|
|
@@ -198,6 +200,27 @@ public class KeyStoreWrapperTest {
|
|
|
198
200
|
tryNewOrUpgradedClientAgainstNewOrOldServer(false, false, false);
|
|
199
201
|
}
|
|
200
202
|
|
|
203
|
+
@Test
|
|
204
|
+
public void testKeySupportsOAEPPadding() {
|
|
205
|
+
final KeyStoreWrapper keyStoreWrapper = KeyStoreWrapper.getInstance();
|
|
206
|
+
Assert.assertNotNull("KeyStoreWrapper instance should not be null", keyStoreWrapper);
|
|
207
|
+
|
|
208
|
+
// Create a legacy key pair without OAEP padding support
|
|
209
|
+
keyStoreWrapper.legacyCreateKeysIfNecessary("RSA", KEY_OAEP_TEST, RSA_LENGTH);
|
|
210
|
+
|
|
211
|
+
// Verify the legacy key does NOT support OAEP padding
|
|
212
|
+
Assert.assertFalse("Legacy key should not support OAEP padding",
|
|
213
|
+
keyStoreWrapper.keySupportsOAEPPadding(KEY_OAEP_TEST));
|
|
214
|
+
|
|
215
|
+
// Delete the legacy key and create a modern key pair
|
|
216
|
+
keyStoreWrapper.deleteKey(KEY_OAEP_TEST);
|
|
217
|
+
keyStoreWrapper.getRSAPublicKey(KEY_OAEP_TEST, RSA_LENGTH); // This creates the key with modern spec
|
|
218
|
+
|
|
219
|
+
// Verify the modern key DOES support OAEP padding
|
|
220
|
+
Assert.assertTrue("Modern key should support OAEP padding",
|
|
221
|
+
keyStoreWrapper.keySupportsOAEPPadding(KEY_OAEP_TEST));
|
|
222
|
+
}
|
|
223
|
+
|
|
201
224
|
/**
|
|
202
225
|
* Helper method for tests for RSA cipher mode change
|
|
203
226
|
* @param newClient true means new client (key generated with new code), false means upgraded client (key generated the old way)
|
|
@@ -88,7 +88,7 @@ if (data.indexOf("SalesforceHybrid") < 0)
|
|
|
88
88
|
const oldAndroidDepTree = "android {";
|
|
89
89
|
const newAndroidDepTree = "android {\n\tpackagingOptions {\n\t\texclude 'META-INF/LICENSE'\n\t\texclude 'META-INF/LICENSE.txt'\n\t\texclude 'META-INF/DEPENDENCIES'\n\t\texclude 'META-INF/NOTICE'\n\t}";
|
|
90
90
|
replaceTextInFile(path.join(appProjectRoot, 'app', 'build.gradle'), oldAndroidDepTree, newAndroidDepTree);
|
|
91
|
-
const newLibDep = "api 'com.salesforce.mobilesdk:SalesforceHybrid:13.0.
|
|
91
|
+
const newLibDep = "api 'com.salesforce.mobilesdk:SalesforceHybrid:13.0.2'";
|
|
92
92
|
replaceTextInFile(path.join(appProjectRoot, 'app', 'build.gradle'), 'implementation(project(path: \":CordovaLib\"))', newLibDep);
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
// Version this js was shipped with
|
|
28
|
-
var SALESFORCE_MOBILE_SDK_VERSION = "13.0.
|
|
28
|
+
var SALESFORCE_MOBILE_SDK_VERSION = "13.0.2";
|
|
29
29
|
|
|
30
30
|
var smartstore = require("com.salesforce.plugin.smartstore");
|
|
31
31
|
var promiser = require("com.salesforce.util.promiser").promiser;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
// Version this js was shipped with
|
|
28
|
-
var SALESFORCE_MOBILE_SDK_VERSION = "13.0.
|
|
28
|
+
var SALESFORCE_MOBILE_SDK_VERSION = "13.0.2";
|
|
29
29
|
var exec = function(pluginVersion, successCB, errorCB, service, action, args) {
|
|
30
30
|
var uniqueNumber = new Date().valueOf() + Math.random();
|
|
31
31
|
var tag = "TIMING " + service + ":" + action + ":" + uniqueNumber;
|