Skip to content

Commit e3c40a9

Browse files
div5yesheeatonawsmikepschneiderlawmichamikschn-aws
authored
chore: sync main (#160)
* fix(core): remove unused dynamic nav dependency (#2132) * fix(datastore): remove typename from ModelMetadata (#2122) * fix(datastore): remove typename from ModelMetadata * Test a potential fix * Test a potential fix * fix: callbacks not invoked when attached using getTransfer api (#2111) * fix: listener not invoked when attached using getTransfer api * address PR comments * default state to unknown * add comment * add comment * override getRequest in storage operation & make SocketExcpetion retryable * add nullable annotation * address nullable request Co-authored-by: Tyler Roach <[email protected]> * Prevent attempting to read backed up EncryptedSharedPreferences that are no longer readable (#2113) * fix(auth): device metadata migration (#2114) * Number of attributes being too high is not retryable (#2112) * Number of attributes being too high is not retryable * Match iOS at not retrying bad request error -- covering multiple 400 errors * Fix lint * Fix lint * Update Kotlin SDK version Co-authored-by: Thomas Leing <[email protected]> * Change errors returned on some apis while federated (#2116) * release: Amplify Android 2.0.0 (#2115) * release: Amplify Android 2.0.0 * add core-kotlin changelog * add more info in changelog * revert unintended change * remove breaking change for analytics * fix(datastore): remove typename from ModelMetadata * fix(datastore): remove typename from ModelMetadata * remove unneeded file * small cleanup * remove print statements * fix comment * force tests * force tests * force tests Co-authored-by: Michael Law <[email protected]> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Sunil Timalsina <[email protected]> * chore: Remove deprecated maven plugin (#2137) * Remove deprecated maven project * Fix task name grep * chore: Remove Javadoc tasks (#2139) * Remove deprecated maven project * Fix task name grep * Remove Javadoc tasks * fix: Change order of updating state in local cache (#2141) * fix: fix integration test and added logger to integration test (#2143) * fix: Change order of updating state in local cache * change order for updating status and add logger to integ tests * change log level to debug * Fix for when move to idle state is called twice (#2152) * Update README.md (#2120) remove dev-preview APIs note. * Dengdan stress test (#2153) * Initial commit * Work in progress * finish codes * change build * update build * test excludeStressTest * Revert "Merge branch 'main' into dengdan-stress-test" This reverts commit b50840e, reversing changes made to 3bacf1b. * remove categories * remove external changes * remove external changes * remove more changes * Update copyright and refactor * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * linting * Update StorageStressTest.kt * Delete StorageStressTest.kt * Delete amplifyconfigurationupdated.json * Delete amplifyconfigurationupdated.json * Update DataStoreStressTest.kt * Fix(Auth): Sign up if successful should return DONE instead of Confirm sign up (#2130) * If sign up is successful in the first try return DONE * Sign up should send DONE if it is successful * revert jsongenerator cleandir fun * lint fix * Feat(Auth Test): Custom party testing for Custom Test without SRP (#2149) * Adding custom auth test cases * Updating test cases for Custom Auth to ensure they pass * lint format * Fix for phone number * Recreate all tests * Unignore storage and pinpoint tests (#2156) * unignore tests * extend timeout to 60s Co-authored-by: Saijad Dhuka <[email protected]> * feat(Geo): Add Kotlin Geo Facade (#2155) * Add Kotlin Geo Facade * Add return docs to the function comments * Add tests to verify options are passed * fix: Add missing apis in storage Kotlin & RxJava facade (#2160) * fix: Add pause, resume api to kotlin and rxJava facade * add unit tests * remove irrelevant code changes * add assertion * Update DeviceFarm build config (#2168) * fix: user metadata was persisted empty in the database (#2165) * fix: usermeta was persisted as empty in the database * fix compilation error * fix compilation error * avoid adding metadata if it is null * Add Geo Rx Bindings (#2159) * chore: Re-add storage tests (#2163) * Readd storage tests * rename file * reduce stress Co-authored-by: Saijad Dhuka <[email protected]> * Add a network status listener to restart DataStore after the network … (#2148) * Add a network status listener to restart DataStore after the network comes back online. * Add Reachability monitor * working pretty well * cleanup * update test * fix: fix integration test and added logger to integration test (#2143) * fix: Change order of updating state in local cache * change order for updating status and add logger to integ tests * change log level to debug * Fix for when move to idle state is called twice (#2152) * Update README.md (#2120) remove dev-preview APIs note. * Dengdan stress test (#2153) * Initial commit * Work in progress * finish codes * change build * update build * test excludeStressTest * Revert "Merge branch 'main' into dengdan-stress-test" This reverts commit b50840e, reversing changes made to 3bacf1b. * remove categories * remove external changes * remove external changes * remove more changes * Update copyright and refactor * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * linting * Update StorageStressTest.kt * Delete StorageStressTest.kt * Delete amplifyconfigurationupdated.json * Delete amplifyconfigurationupdated.json * Update DataStoreStressTest.kt * force build * force build * force build * fix typo * Add a network status listener to restart DataStore after the network comes back online. * Add Reachability monitor * working pretty well * cleanup * update test * force build * force build * force build * fix typo * reply to comments * Add testImplementation lin eto compile tests correctly in intellij * reply to comments * make ReachabilityMonitor expose the observable * Update datastore plugin to use the reachability monitor * cleanup * cleanup * cleanup * force tests Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: dengdan154 <[email protected]> * chore: Upgrade Gradle, AGP, and KtLint (#2172) * Remove deprecated maven project * Fix task name grep * Upgrade Gradle to 7.5.1 * Upgrade AGP * Add VERSION_NAME back to BuildConfig This was removed for library projects in AGP 4.1. We may consider renaming this in the future to disambiguate the Amplify version and the application version. * Update KtLint and fix all new lint errors * Use JDK11 on codebuild * Use JDK11 in workflows * Upgrade compileSdkVersion to 31 * Try using custom commands to install Android SDK 31 * Update device farm buildspec with manual Android SDK install * Fix additional ktlint errors * Upgrade Desugar to JDK11-compatible version * Upgrade Robolectric * Set locale explicitly to match expectation * fix(geo): Increase Geo timeout so that it runs successfully on a Pixel 3a XL (#2177) * Increase Geo timeout so that it runs successfully on a Pixel 3a XL * Fix lint Co-authored-by: Thomas Leing <[email protected]> * Add a buildspec file for nightly tests (#2180) * Chore(Auth): Implementation of the custom auth with SRP parity testing use case (#2167) * Added the test case for custom auth with SRP * ktlint * release: Amplify Android 2.1.0 (manually created) (#2185) Co-authored-by: Thomas Leing <[email protected]> * chore: Add PR checker workflow (#2188) * fix(Auth): Fix for when loading credentials the success/error is fired twice (#2184) * chore: update changelog for Amplify Android 2.1.0 (#2193) * feat(Auth): Overriding sign in when the State machine is already in the signing in state (#2187) * chore: fix inconsistency with endpointWithAttributes test (#2196) * chore: update changelog for v2.1.0 (#2198) * chore: replace md5 with sha-256 for file data validation (#2199) * chore: Remove unused version and group properties (#2186) * chore: Add a label that will disable the PR title check (#2195) Co-authored-by: gpanshu <[email protected]> * chore: add release tag to PR title checker config (#2194) Co-authored-by: Matt Creaser <[email protected]> * fix(datastore): Fix lock contention issue when running DataStore.start() from the callback of DataStore.stop() (#2208) Co-authored-by: Michael Schneider <[email protected]> * chore: Add group and version back to all subprojects (#2213) * chore: Remove the release-kotlin_v block from prepare release script (#2231) * fix(core): Remove unused dependencies (#2207) Co-authored-by: Matt Creaser <[email protected]> * chore: Modify the bump_version branch name to be specific to the base branch (#2240) * fix(geo): Bump MapLibre SDK to 9.6.0 (#2254) * release: Amplify Android 2.1.1 (#2257) Co-authored-by: amplify-android-dev+ghops <[email protected]> * fix(analytics): Remove test dependencies from implementation configuration (#2253) * chore: Ignore clearStopsSyncAndDeletesDatabase test (#2262) * fix(auth): Fix Authorization header for HostedUI fetchToken when appSecret is used (#2264) * chore: Supply base_branch when calling `create_next_release_pr` lane (#2245) * chore: Update PR template to include security checklist item (#2251) * feat(auth): add required hash param to cognito api calls (#2266) Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: AWS Mobile SDK Bot <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> * feat(datastore): Add recoverability improvements (#2201) Co-authored-by: Matt Creaser <[email protected]> * feat(auth): Added parity test for fetchDevices,rememberDevice,forgetDevice and fetchUserAttributes (#2174) Co-authored-by: Sunil Timalsina <[email protected]> Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: Matt Creaser <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: AWS Mobile SDK Bot <[email protected]> * release: Amplify Android 2.2.0 (#2269) Co-authored-by: amplify-android-dev+ghops <[email protected]> * chore: Convert build.gradle files to Kotlin (#2183) * Convert build.gradle files to Kotlin * Fix missing test dependency * Update copyright year * chore: Set the signing information in project extras (#2277) * fix(auth): Moving credential provider to main (#2273) * chore(analytics): Simplify error code checking, uniformly across platforms (#2274) Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Matt Creaser <[email protected]> * feat(auth): added kover plugin for coverage (#2267) Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: gpanshu <[email protected]> * release: Amplify Android 2.2.1 (#2285) Co-authored-by: amplify-android-dev+ghops <[email protected]> Co-authored-by: Matt Creaser <[email protected]> * chore: Remove circleci configuration file (#2279) Co-authored-by: gpanshu <[email protected]> * fix(auth): fix npe in initialize fetch auth session (#2284) Co-authored-by: Banji Jolaoso <[email protected]> * fix(auth): Fix confirm signin when incorrect MFA code is entered (#2286) * release: Amplify Android 2.2.2 (#2292) Co-authored-by: amplify-android-dev+ghops <[email protected]> * chore: Fix using amplify-android in a composite build (#2294) * chore: update device farm configuration for nightly build (#2281) * chore: remove buildspec files (#2308) * chore: remove amplify-data from codeowners (#2252) Co-authored-by: Saijad Dhuka <[email protected]> * fix(datastore): Fix aliasing of column names (#2312) * feat(storage): Add support for S3 acceleration mode (#2304) * feat(aws-datastore): Make the reachability component configurable (#2307) Signed-off-by: Manuel Iglesias <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> * release: Amplify Android 2.3.0 (#2323) Co-authored-by: amplify-android-dev+ghops <[email protected]> * feat(aws-api,aws-datastore): WebSocket improvements (#2283) Signed-off-by: Manuel Iglesias <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: Matt Creaser <[email protected]> --------- Signed-off-by: Manuel Iglesias <[email protected]> Co-authored-by: Erica Eaton <[email protected]> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Michael Law <[email protected]> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Sunil Timalsina <[email protected]> Co-authored-by: Matt Creaser <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: dengdan154 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: amplify-android-dev+ghops <[email protected]> Co-authored-by: banji180 <[email protected]> Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: AWS Mobile SDK Bot <[email protected]> Co-authored-by: Manuel Iglesias <[email protected]> Co-authored-by: Dane Pilcher <[email protected]>
1 parent 2524e21 commit e3c40a9

File tree

55 files changed

+925
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+925
-415
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [Release 2.3.0](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.3.0)
2+
3+
### Features
4+
- **storage:** Add support for S3 acceleration mode ([#2304](https://github.com/aws-amplify/amplify-android/issues/2304))
5+
- **aws-datastore:** Make the reachability component configurable ([#2307](https://github.com/aws-amplify/amplify-android/issues/2307))
6+
7+
### Bug Fixes
8+
- **datastore:** Fix aliasing of column names ([#2312](https://github.com/aws-amplify/amplify-android/issues/2312))
9+
10+
[See all changes between 2.2.2 and 2.3.0](https://github.com/aws-amplify/amplify-android/compare/release_v2.2.2...release_v2.3.0)
11+
112
## [Release 2.2.2](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.2.2)
213

314
### Bug Fixes

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ dependencies section:
6969
```groovy
7070
dependencies {
7171
// Only specify modules that provide functionality your app will use
72-
implementation 'com.amplifyframework:aws-analytics-pinpoint:2.2.2'
73-
implementation 'com.amplifyframework:aws-api:2.2.2'
74-
implementation 'com.amplifyframework:aws-auth-cognito:2.2.2'
75-
implementation 'com.amplifyframework:aws-datastore:2.2.2'
76-
implementation 'com.amplifyframework:aws-predictions:2.2.2'
77-
implementation 'com.amplifyframework:aws-storage-s3:2.2.2'
72+
implementation 'com.amplifyframework:aws-analytics-pinpoint:2.3.0'
73+
implementation 'com.amplifyframework:aws-api:2.3.0'
74+
implementation 'com.amplifyframework:aws-auth-cognito:2.3.0'
75+
implementation 'com.amplifyframework:aws-datastore:2.3.0'
76+
implementation 'com.amplifyframework:aws-predictions:2.3.0'
77+
implementation 'com.amplifyframework:aws-storage-s3:2.3.0'
7878
}
7979
```
8080

aws-api/src/androidTest/java/com/amplifyframework/api/aws/SubscriptionEndpointTest.java

+48-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
import java.util.Set;
3838
import java.util.concurrent.Executor;
3939
import java.util.concurrent.Executors;
40+
import java.util.concurrent.atomic.AtomicInteger;
4041

4142
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
43+
import static org.junit.Assert.assertEquals;
4244
import static org.junit.Assert.assertNotEquals;
4345
import static org.junit.Assert.assertNotNull;
4446

@@ -71,7 +73,7 @@ public void setup() throws ApiException, JSONException {
7173

7274
final GraphQLResponse.Factory responseFactory = new GsonGraphQLResponseFactory();
7375
final SubscriptionAuthorizer authorizer = new SubscriptionAuthorizer(apiConfiguration);
74-
this.subscriptionEndpoint = new SubscriptionEndpoint(apiConfiguration, responseFactory, authorizer);
76+
this.subscriptionEndpoint = new SubscriptionEndpoint(apiConfiguration, null, responseFactory, authorizer);
7577

7678
this.eventId = RandomString.string();
7779
this.subscriptionIdsForRelease = new HashSet<>();
@@ -119,6 +121,51 @@ public void twoSubscriptionsToTheSameThing() throws ApiException {
119121
assertNotEquals(firstSubscriptionId, secondSubscriptionId);
120122
}
121123

124+
/**
125+
* It uses a configurator if present.
126+
*
127+
* This test verifies that a configurator can add an interceptor and that it will be run when establishing
128+
* subscriptions.
129+
* @throws ApiException On failure to load API configuration from config file
130+
* @throws JSONException On failure to manipulate configuration JSON during test arrangement
131+
*/
132+
@Test
133+
public void usesConfiguratorIfPresent() throws ApiException, JSONException {
134+
String endpointConfigKey = "eventsApi"; // The endpoint config in amplifyconfiguration.json with this name
135+
JSONObject configJson = Resources.readAsJson(getApplicationContext(), R.raw.amplifyconfiguration)
136+
.getJSONObject("api")
137+
.getJSONObject("plugins")
138+
.getJSONObject("awsAPIPlugin");
139+
AWSApiPluginConfiguration pluginConfiguration = AWSApiPluginConfigurationReader.readFrom(configJson);
140+
ApiConfiguration apiConfiguration = pluginConfiguration.getApi(endpointConfigKey);
141+
assertNotNull(apiConfiguration);
142+
143+
final GraphQLResponse.Factory responseFactory = new GsonGraphQLResponseFactory();
144+
final SubscriptionAuthorizer authorizer = new SubscriptionAuthorizer(apiConfiguration);
145+
146+
final AtomicInteger counter = new AtomicInteger();
147+
148+
final OkHttpConfigurator configurator = okHttpBuilder -> {
149+
counter.incrementAndGet();
150+
151+
okHttpBuilder.addInterceptor(chain -> {
152+
counter.incrementAndGet();
153+
154+
return chain.proceed(chain.request());
155+
});
156+
};
157+
158+
this.subscriptionEndpoint = new SubscriptionEndpoint(apiConfiguration, configurator, responseFactory,
159+
authorizer);
160+
161+
String firstSubscriptionId = subscribeToEventComments(eventId);
162+
assertNotNull(firstSubscriptionId);
163+
164+
subscriptionIdsForRelease.add(firstSubscriptionId);
165+
166+
assertEquals(2, counter.get());
167+
}
168+
122169
/**
123170
* Subscribe to comments on an event.
124171
* @param eventId ID of event for which comments are being made

aws-api/src/main/java/com/amplifyframework/api/aws/AWSApiPlugin.java

+32-9
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
@SuppressWarnings("TypeParameterHidesVisibleType") // <R> shadows >com.amplifyframework.api.aws.R
7373
public final class AWSApiPlugin extends ApiPlugin<Map<String, OkHttpClient>> {
7474
private final Map<String, ClientDetails> apiDetails;
75-
private final Map<String, OkHttpConfigurator> apiConfigurators;
75+
private final Map<String, OkHttpConfigurator> apiHttpClientConfigurators;
76+
private final Map<String, OkHttpConfigurator> apiWebsocketUpgradeClientConfigurators;
7677
private final GraphQLResponse.Factory gqlResponseFactory;
7778
private final ApiAuthProviders authProvider;
7879
private final ExecutorService executorService;
@@ -106,7 +107,8 @@ private AWSApiPlugin(@NonNull Builder builder) {
106107
this.gqlApis = new HashSet<>();
107108
this.executorService = Executors.newCachedThreadPool();
108109
this.requestDecorator = new AuthRuleRequestDecorator(authProvider);
109-
this.apiConfigurators = Immutable.of(builder.apiConfigurators);
110+
this.apiHttpClientConfigurators = Immutable.of(builder.apiHttpClientConfigurators);
111+
this.apiWebsocketUpgradeClientConfigurators = Immutable.of(builder.apiWebsocketUpgradeClientConfigurators);
110112
}
111113

112114
/**
@@ -140,7 +142,7 @@ public void configure(
140142
okHttpClientBuilder.addNetworkInterceptor(UserAgentInterceptor.using(UserAgent::string));
141143
okHttpClientBuilder.eventListener(new ApiConnectionEventListener());
142144

143-
OkHttpConfigurator configurator = apiConfigurators.get(apiName);
145+
OkHttpConfigurator configurator = apiHttpClientConfigurators.get(apiName);
144146
if (configurator != null) {
145147
configurator.applyConfiguration(okHttpClientBuilder);
146148
}
@@ -174,8 +176,11 @@ public void configure(
174176
} else if (EndpointType.GRAPHQL.equals(endpointType)) {
175177
final SubscriptionAuthorizer subscriptionAuthorizer =
176178
new SubscriptionAuthorizer(apiConfiguration, authProvider);
179+
final OkHttpConfigurator websocketUpgradeConfigurator =
180+
apiWebsocketUpgradeClientConfigurators.get(apiName);
177181
final SubscriptionEndpoint subscriptionEndpoint =
178-
new SubscriptionEndpoint(apiConfiguration, gqlResponseFactory, subscriptionAuthorizer);
182+
new SubscriptionEndpoint(apiConfiguration, websocketUpgradeConfigurator, gqlResponseFactory,
183+
subscriptionAuthorizer);
179184
clientDetails = new ClientDetails(apiConfiguration,
180185
okHttpClientBuilder.build(),
181186
subscriptionEndpoint,
@@ -869,11 +874,13 @@ private void transitionTo(ApiEndpointStatus newStatus) {
869874
*/
870875
public static final class Builder {
871876
private ApiAuthProviders apiAuthProviders;
872-
private final Map<String, OkHttpConfigurator> apiConfigurators;
877+
private final Map<String, OkHttpConfigurator> apiHttpClientConfigurators;
878+
private final Map<String, OkHttpConfigurator> apiWebsocketUpgradeClientConfigurators;
873879

874880
private Builder() {
875881
this.apiAuthProviders = ApiAuthProviders.noProviderOverrides();
876-
this.apiConfigurators = new HashMap<>();
882+
this.apiHttpClientConfigurators = new HashMap<>();
883+
this.apiWebsocketUpgradeClientConfigurators = new HashMap<>();
877884
}
878885

879886
/**
@@ -890,17 +897,33 @@ public Builder apiAuthProviders(@NonNull ApiAuthProviders apiAuthProviders) {
890897

891898
/**
892899
* Apply customizations to an underlying OkHttpClient that will be used
893-
* for a particular API.
900+
* for a particular API's Http operations.
894901
* @param forApiName The name of the API for which these customizations should apply.
895902
This can be found in your `amplifyconfiguration.json` file.
896903
* @param byConfigurator A lambda that hands the user an OkHttpClient.Builder,
897-
* and enables the user to set come configurations on it.
904+
* and enables the user to set some configurations on it.
898905
* @return A builder instance, to continue chaining configurations
899906
*/
900907
@NonNull
901908
public Builder configureClient(
902909
@NonNull String forApiName, @NonNull OkHttpConfigurator byConfigurator) {
903-
this.apiConfigurators.put(forApiName, byConfigurator);
910+
this.apiHttpClientConfigurators.put(forApiName, byConfigurator);
911+
return this;
912+
}
913+
914+
/**
915+
* Apply customizations to an underlying OkHttpClient that will be used
916+
* for the WebSocket protocol upgrade of a particular API.
917+
* @param forApiName The name of the API for which these customizations should apply.
918+
This can be found in your `amplifyconfiguration.json` file.
919+
* @param byConfigurator A lambda that hands the user an OkHttpClient.Builder,
920+
* and enables the user to set some configurations on it.
921+
* @return A builder instance, to continue chaining configurations
922+
*/
923+
@NonNull
924+
public Builder configureWebSocketUpgradeClient(
925+
@NonNull String forApiName, @NonNull OkHttpConfigurator byConfigurator) {
926+
this.apiWebsocketUpgradeClientConfigurators.put(forApiName, byConfigurator);
904927
return this;
905928
}
906929

aws-api/src/main/java/com/amplifyframework/api/aws/SubscriptionEndpoint.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.net.Uri;
1919
import android.util.Base64;
2020
import androidx.annotation.NonNull;
21+
import androidx.annotation.Nullable;
2122
import androidx.core.util.ObjectsCompat;
2223

2324
import com.amplifyframework.AmplifyException;
@@ -76,19 +77,25 @@ final class SubscriptionEndpoint {
7677

7778
SubscriptionEndpoint(
7879
@NonNull ApiConfiguration apiConfiguration,
80+
@Nullable OkHttpConfigurator configurator,
7981
@NonNull GraphQLResponse.Factory responseFactory,
8082
@NonNull SubscriptionAuthorizer authorizer
81-
) throws ApiException {
83+
) {
8284
this.apiConfiguration = Objects.requireNonNull(apiConfiguration);
8385
this.subscriptions = new ConcurrentHashMap<>();
8486
this.responseFactory = Objects.requireNonNull(responseFactory);
8587
this.authorizer = Objects.requireNonNull(authorizer);
8688
this.timeoutWatchdog = new TimeoutWatchdog();
8789
this.pendingSubscriptionIds = Collections.synchronizedSet(new HashSet<>());
88-
this.okHttpClient = new OkHttpClient.Builder()
89-
.addNetworkInterceptor(UserAgentInterceptor.using(UserAgent::string))
90-
.retryOnConnectionFailure(true)
91-
.build();
90+
91+
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder()
92+
.retryOnConnectionFailure(true);
93+
94+
if (configurator != null) {
95+
configurator.applyConfiguration(okHttpClientBuilder);
96+
}
97+
98+
this.okHttpClient = okHttpClientBuilder.build();
9299
}
93100

94101
synchronized <T> void requestSubscription(
@@ -126,6 +133,7 @@ synchronized <T> void requestSubscription(
126133
webSocket = okHttpClient.newWebSocket(new Request.Builder()
127134
.url(buildConnectionRequestUrl(authType))
128135
.addHeader("Sec-WebSocket-Protocol", "graphql-ws")
136+
.header("User-Agent", UserAgent.string())
129137
.build(), webSocketListener);
130138
} catch (ApiException apiException) {
131139
onSubscriptionError.accept(apiException);
@@ -332,7 +340,7 @@ private String buildConnectionRequestUrl(AuthorizationType authType) throws ApiE
332340
return new Uri.Builder()
333341
.scheme("wss")
334342
.authority(authority)
335-
.appendPath(path)
343+
.path(path)
336344
.appendQueryParameter("header", Base64.encodeToString(rawHeader, Base64.DEFAULT))
337345
.appendQueryParameter("payload", "e30=")
338346
.build()
@@ -490,7 +498,6 @@ public int hashCode() {
490498
final class AmplifyWebSocketListener extends WebSocketListener {
491499
private final CountDownLatch connectionResponse;
492500
private final AtomicReference<EndpointStatus> endpointStatus;
493-
private OkHttpClient okHttpClient;
494501

495502
AmplifyWebSocketListener() {
496503
this(new CountDownLatch(1));

aws-api/src/main/java/com/amplifyframework/api/aws/auth/IamRequestDecorator.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@
1818
import com.amplifyframework.api.ApiException.ApiAuthException;
1919
import com.amplifyframework.api.aws.sigv4.AWS4Signer;
2020

21+
import aws.smithy.kotlin.runtime.net.Url;
22+
2123
import java.io.ByteArrayOutputStream;
2224
import java.io.IOException;
2325
import java.util.List;
2426
import java.util.Map;
2527

2628
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider;
29+
import aws.smithy.kotlin.runtime.http.DeferredHeaders;
2730
import aws.smithy.kotlin.runtime.http.Headers;
2831
import aws.smithy.kotlin.runtime.http.HttpMethod;
29-
import aws.smithy.kotlin.runtime.http.Url;
3032
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent;
3133
import aws.smithy.kotlin.runtime.http.request.HttpRequest;
34+
import aws.smithy.kotlin.runtime.http.request.HttpRequestKt;
3235
import okhttp3.MediaType;
3336
import okhttp3.RequestBody;
3437
import okio.Buffer;
@@ -79,7 +82,7 @@ public final okhttp3.Request decorate(okhttp3.Request req) throws ApiAuthExcepti
7982
return null;
8083
});
8184

82-
HttpRequest req2 = new HttpRequest(method, url, headers, body2);
85+
HttpRequest req2 = HttpRequestKt.HttpRequest(method, url, headers, body2, DeferredHeaders.Companion.getEmpty());
8386

8487
HttpRequest request = v4Signer.signBlocking(req2, credentialsProvider, serviceName).getOutput();
8588

@@ -124,8 +127,8 @@ private byte[] getBytes(RequestBody body) throws ApiAuthException {
124127
return output.toByteArray();
125128
} catch (IOException exception) {
126129
throw new ApiAuthException("Unable to calculate SigV4 signature for the request",
127-
exception,
128-
"Check your application logs for details.");
130+
exception,
131+
"Check your application logs for details.");
129132
}
130133
}
131134
}

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/AWSCognitoAuthService.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ package com.amplifyframework.auth.cognito
1717

1818
import aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient
1919
import aws.sdk.kotlin.services.cognitoidentityprovider.CognitoIdentityProviderClient
20-
import aws.smithy.kotlin.runtime.http.endpoints.Endpoint
20+
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
21+
import aws.smithy.kotlin.runtime.client.endpoints.EndpointProvider
2122
import com.amplifyframework.statemachine.codegen.data.AuthConfiguration
2223

2324
interface AWSCognitoAuthService {
@@ -30,8 +31,8 @@ interface AWSCognitoAuthService {
3031

3132
CognitoIdentityProviderClient {
3233
this.region = it.region
33-
this.endpointResolver = it.endpoint?.let { endpoint ->
34-
AWSEndpointResolver(Endpoint(endpoint))
34+
this.endpointProvider = it.endpoint?.let { endpoint ->
35+
EndpointProvider { Endpoint(endpoint) }
3536
}
3637
}
3738
}

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/AWSEndpointResolver.kt

-27
This file was deleted.

aws-datastore/src/main/java/com/amplifyframework/datastore/AWSDataStorePlugin.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,7 @@ Builder storageAdapter(LocalStorageAdapter storageAdapter) {
755755
* @param reachabilityMonitor An instance that implements LocalStorageAdapter.
756756
* @return Current builder instance, for fluent construction of plugin.
757757
*/
758-
@VisibleForTesting
759-
Builder reachabilityMonitor(ReachabilityMonitor reachabilityMonitor) {
758+
public Builder reachabilityMonitor(ReachabilityMonitor reachabilityMonitor) {
760759
this.reachabilityMonitor = reachabilityMonitor;
761760
return this;
762761
}

aws-datastore/src/main/java/com/amplifyframework/datastore/syncengine/ReachabilityMonitor.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit
3636
* The network changes are debounced with a 250 ms delay to allow some time for one network to connect after another
3737
* network has disconnected (for example, wifi is lost, then cellular connects) to reduce thrashing.
3838
*/
39-
internal interface ReachabilityMonitor {
39+
public interface ReachabilityMonitor {
4040
fun configure(context: Context)
4141
@VisibleForTesting
4242
fun configure(context: Context, connectivityProvider: ConnectivityProvider)
@@ -99,7 +99,7 @@ private class ReachabilityMonitorImpl constructor(val schedulerProvider: Schedul
9999
* is a concrete class created within context.getSystemService() it can't be overridden with a test
100100
* implementation, so this interface works around that issue.
101101
*/
102-
internal interface ConnectivityProvider {
102+
public interface ConnectivityProvider {
103103
val hasActiveNetwork: Boolean
104104
fun registerDefaultNetworkCallback(context: Context, callback: NetworkCallback)
105105
}

0 commit comments

Comments
 (0)