Skip to content
Open
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
2 changes: 1 addition & 1 deletion expo-example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.25'

ndkVersion = "26.1.10909125"
}
Expand Down
4 changes: 2 additions & 2 deletions expo-example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().toString())
}
plugins { id("com.facebook.react.settings") }

Expand Down Expand Up @@ -31,7 +31,7 @@ dependencyResolutionManagement {
}
}

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

include ':app'
Expand Down
19 changes: 13 additions & 6 deletions expo-example/app/tests/custom-bug-fix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
Collection,
MutableDocument,
Document,
ConcurrencyControl
ConcurrencyControl,
CollectionConfiguration
} from 'cbl-reactnative';import getFileDefaultPath from '@/service/file/getFileDefaultPath';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and to adhere to standard coding practices, each import statement should be on its own line.

Suggested change
} from 'cbl-reactnative';import getFileDefaultPath from '@/service/file/getFileDefaultPath';
} from 'cbl-reactnative';
import getFileDefaultPath from '@/service/file/getFileDefaultPath';


export default function CustomBugFixScreen() {
Expand Down Expand Up @@ -63,22 +64,28 @@ export default function CustomBugFixScreen() {

const connectToSyncGateway = async () => {
setListOfLogs(prev => [...prev, 'Connecting to Sync Gateway']); // ✅ Use prev
const defaultCollection = await database?.defaultCollection();
if(database === null || database === undefined) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This check for null or undefined can be simplified. Using !database is more concise and idiomatic in TypeScript for this purpose.

Suggested change
if(database === null || database === undefined) {
if(!database) {

throw Error("Database is undefined")
}
const defaultCollection = await database.defaultCollection();

const syncGatewayUrl = "wss://nasm0fvdr-jnehnb.apps.cloud.couchbase.com:4984/testendpoint"
const endpoint = new URLEndpoint(syncGatewayUrl);
const username = "jayantdhingra"
const password = "f9yu5QT4B5jpZep@"
Comment on lines 74 to 75

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Hardcoded credentials found. Storing secrets like usernames and passwords directly in the source code is a major security risk. These credentials can be easily extracted from the compiled application, even from test files. It's highly recommended to use a secure method for managing secrets, such as environment variables or a secrets management service.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this is not going into a release branch, I think it would be good to not publish/expose credentials at all on remote.


const replicatorConfig = new ReplicatorConfiguration(endpoint)

const collectionConfig = new CollectionConfiguration(defaultCollection)


const listOfCollectionConfig = [collectionConfig]

const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint)
Comment on lines +77 to +83

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The code formatting in this section has inconsistent indentation and excessive blank lines, which affects readability. It's recommended to remove the extra lines and fix the indentation.

Suggested change
const collectionConfig = new CollectionConfiguration(defaultCollection)
const listOfCollectionConfig = [collectionConfig]
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint)
const collectionConfig = new CollectionConfiguration(defaultCollection);
const listOfCollectionConfig = [collectionConfig];
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint);

replicatorConfig.setAuthenticator(new BasicAuthenticator(username, password))
// replicatorConfig.setContinuous(true)
replicatorConfig.setAcceptOnlySelfSignedCerts(false);


if (defaultCollection) {
replicatorConfig.addCollection(defaultCollection)
}

const replicator = await Replicator.create(replicatorConfig)

Expand Down
25 changes: 25 additions & 0 deletions expo-example/app/tests/replication-new.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import TestRunnerContainer from '@/components/TestRunnerContainer/TestRunnerContainer';

import { ReplicatorNewApiTests } from '../../cblite-js-tests/cblite-tests/e2e/replicator-new-api-test';

export default function TestsReplicatorScreen() {
function reset() {}

async function update(): Promise<string[]> {
try {
return [''];
} catch (e) {
// @ts-ignore
return [error.message];
Comment on lines +13 to +14

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There's a reference to an undefined variable error inside the catch block. The caught exception is named e, so you should use e.message instead. The // @ts-ignore comment is hiding this compilation error and should be removed.

Suggested change
// @ts-ignore
return [error.message];
return [e.message];

}
}

return (
<TestRunnerContainer
navigationTitle="Replicator Tests"
subTitle="Run Sync Gate before tests - visit tests README.md"
testCases={[ReplicatorNewApiTests]}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
ReplicatorConfiguration,
URLEndpoint,
BasicAuthenticator,
MutableDocument
MutableDocument,
CollectionConfiguration
} from 'cbl-reactnative';
import getFileDefaultPath from '@/service/file/getFileDefaultPath';

Expand Down Expand Up @@ -61,12 +62,18 @@ export default function ReplicatorListenersScreen() {
}

const endpoint = new URLEndpoint(SYNC_GATEWAY_URL);
const replicatorConfig = new ReplicatorConfiguration(endpoint);

//Create CollectionConfiguration
const collectionConfig = new CollectionConfiguration(defaultCollection);

const listOfCollectionConfig = [collectionConfig]

// Pass array of configs and endpoint to constructor
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig , endpoint);
Comment on lines +66 to +72

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comments explaining the API change can be removed as the code is now straightforward. Also, there are extra blank lines and an extra space in the constructor call that can be cleaned up for better readability.

Suggested change
//Create CollectionConfiguration
const collectionConfig = new CollectionConfiguration(defaultCollection);
const listOfCollectionConfig = [collectionConfig]
// Pass array of configs and endpoint to constructor
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig , endpoint);
const collectionConfig = new CollectionConfiguration(defaultCollection);
const listOfCollectionConfig = [collectionConfig];
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint);


replicatorConfig.setAuthenticator(new BasicAuthenticator(USERNAME, PASSWORD));
replicatorConfig.setContinuous(true);
replicatorConfig.setAcceptOnlySelfSignedCerts(false);
replicatorConfig.addCollection(defaultCollection);

const replicator = await Replicator.create(replicatorConfig);
setReplicator(replicator);
Expand Down
Loading