From 97952f64b8380f8068d263f2b5e7750cc551c52c Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 7 Aug 2024 16:21:48 -0600 Subject: [PATCH 1/4] fix: forked group and default history sync url --- android/build.gradle | 2 +- example/ios/Podfile.lock | 14 +++++++------- ios/XMTPReactNative.podspec | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 0cb5235d1..177b43c1b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -98,7 +98,7 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:0.14.16" + implementation "org.xmtp:android:0.15.0" implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.facebook.react:react-native:0.71.3' implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1" diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 170371e12..896d4cb27 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -56,7 +56,7 @@ PODS: - hermes-engine/Pre-built (= 0.71.14) - hermes-engine/Pre-built (0.71.14) - libevent (2.1.12) - - LibXMTP (0.5.6-beta5) + - LibXMTP (0.5.7-beta0) - Logging (1.0.0) - MessagePacker (0.4.7) - MMKV (1.3.9): @@ -449,16 +449,16 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.13.16): + - XMTP (0.14.0): - Connect-Swift (= 0.12.0) - GzipSwift - - LibXMTP (= 0.5.6-beta5) + - LibXMTP (= 0.5.7-beta0) - web3.swift - XMTPReactNative (0.1.0): - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.13.16) + - XMTP (= 0.14.0) - Yoga (1.14.0) DEPENDENCIES: @@ -711,7 +711,7 @@ SPEC CHECKSUMS: GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - LibXMTP: 66f4809682fa68b744d4fc0ba68ea82e1528e7a8 + LibXMTP: d80a1a7c9c748fba81d80b95c62fd075a89224a2 Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26 MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02 MMKV: 817ba1eea17421547e01e087285606eb270a8dcb @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 3427d91eb4625ad8724fd79381990e0c96e88d1f - XMTPReactNative: 3e03286398ac4ddcb14235ce6bfb2c89d87a4c61 + XMTP: 080c130548abb58ec507590ab24565285cebb0e1 + XMTPReactNative: 8ef4ef9cadaf78012e04ca88531fe771df10065d Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index dde1089a5..c50a4bd75 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.13.16" + s.dependency "XMTP", "= 0.14.0" end From 8f98de7473127d2707608545b26750ddcd7f53d7 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 7 Aug 2024 17:10:38 -0600 Subject: [PATCH 2/4] fix up android history url --- .../modules/xmtpreactnativesdk/XMTPModule.kt | 142 ++++++++---------- 1 file changed, 66 insertions(+), 76 deletions(-) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index 03d58ff34..5501c7895 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -146,6 +146,53 @@ class XMTPModule : Module() { } } + private fun clientOptions( + dbEncryptionKey: List?, + authParams: String, + hasCreateIdentityCallback: Boolean? = null, + hasEnableIdentityCallback: Boolean? = null, + hasPreAuthenticateToInboxCallback: Boolean? = null, + ): ClientOptions { + if (hasCreateIdentityCallback == true) + preCreateIdentityCallbackDeferred = CompletableDeferred() + if (hasEnableIdentityCallback == true) + preEnableIdentityCallbackDeferred = CompletableDeferred() + if (hasPreAuthenticateToInboxCallback == true) + preAuthenticateToInboxCallbackDeferred = CompletableDeferred() + val preCreateIdentityCallback: PreEventCallback? = + preCreateIdentityCallback.takeIf { hasCreateIdentityCallback == true } + val preEnableIdentityCallback: PreEventCallback? = + preEnableIdentityCallback.takeIf { hasEnableIdentityCallback == true } + val preAuthenticateToInboxCallback: PreEventCallback? = + preAuthenticateToInboxCallback.takeIf { hasPreAuthenticateToInboxCallback == true } + + val authOptions = AuthParamsWrapper.authParamsFromJson(authParams) + val context = if (authOptions.enableV3) context else null + val encryptionKeyBytes = + dbEncryptionKey?.foldIndexed(ByteArray(dbEncryptionKey.size)) { i, a, v -> + a.apply { set(i, v.toByte()) } + } + + val historySyncUrl = authOptions.historySyncUrl + ?: when (authOptions.environment) { + "production" -> "https://message-history.production.ephemera.network/" + "local" -> "http://0.0.0.0:5558" + else -> "https://message-history.dev.ephemera.network/" + } + + return ClientOptions( + api = apiEnvironments(authOptions.environment, authOptions.appVersion), + preCreateIdentityCallback = preCreateIdentityCallback, + preEnableIdentityCallback = preEnableIdentityCallback, + preAuthenticateToInboxCallback = preAuthenticateToInboxCallback, + enableV3 = authOptions.enableV3, + appContext = context, + dbEncryptionKey = encryptionKeyBytes, + dbDirectory = authOptions.dbDirectory, + historySyncUrl = historySyncUrl + ) + } + private var clients: MutableMap = mutableMapOf() private var xmtpPush: XMTPPush? = null private var signer: ReactNativeSigner? = null @@ -235,36 +282,12 @@ class XMTPModule : Module() { logV("auth") val reactSigner = ReactNativeSigner(module = this@XMTPModule, address = address) signer = reactSigner - val authOptions = AuthParamsWrapper.authParamsFromJson(authParams) - - if (hasCreateIdentityCallback == true) - preCreateIdentityCallbackDeferred = CompletableDeferred() - if (hasEnableIdentityCallback == true) - preEnableIdentityCallbackDeferred = CompletableDeferred() - if (hasAuthInboxCallback == true) - preAuthenticateToInboxCallbackDeferred = CompletableDeferred() - val preCreateIdentityCallback: PreEventCallback? = - preCreateIdentityCallback.takeIf { hasCreateIdentityCallback == true } - val preEnableIdentityCallback: PreEventCallback? = - preEnableIdentityCallback.takeIf { hasEnableIdentityCallback == true } - val preAuthenticateToInboxCallback: PreEventCallback? = - preAuthenticateToInboxCallback.takeIf { hasAuthInboxCallback == true } - val context = if (authOptions.enableV3) context else null - val encryptionKeyBytes = - dbEncryptionKey?.foldIndexed(ByteArray(dbEncryptionKey.size)) { i, a, v -> - a.apply { set(i, v.toByte()) } - } - - val options = ClientOptions( - api = apiEnvironments(authOptions.environment, authOptions.appVersion), - preCreateIdentityCallback = preCreateIdentityCallback, - preEnableIdentityCallback = preEnableIdentityCallback, - preAuthenticateToInboxCallback = preAuthenticateToInboxCallback, - enableV3 = authOptions.enableV3, - appContext = context, - dbEncryptionKey = encryptionKeyBytes, - dbDirectory = authOptions.dbDirectory, - historySyncUrl = authOptions.historySyncUrl + val options = clientOptions( + dbEncryptionKey, + authParams, + hasCreateIdentityCallback, + hasEnableIdentityCallback, + hasAuthInboxCallback, ) val client = Client().create(account = reactSigner, options = options) clients[client.inboxId] = client @@ -284,38 +307,12 @@ class XMTPModule : Module() { withContext(Dispatchers.IO) { logV("createRandom") val privateKey = PrivateKeyBuilder() - - if (hasCreateIdentityCallback == true) - preCreateIdentityCallbackDeferred = CompletableDeferred() - if (hasEnableIdentityCallback == true) - preEnableIdentityCallbackDeferred = CompletableDeferred() - if (hasPreAuthenticateToInboxCallback == true) - preAuthenticateToInboxCallbackDeferred = CompletableDeferred() - val preCreateIdentityCallback: PreEventCallback? = - preCreateIdentityCallback.takeIf { hasCreateIdentityCallback == true } - val preEnableIdentityCallback: PreEventCallback? = - preEnableIdentityCallback.takeIf { hasEnableIdentityCallback == true } - val preAuthenticateToInboxCallback: PreEventCallback? = - preAuthenticateToInboxCallback.takeIf { hasPreAuthenticateToInboxCallback == true } - - val authOptions = AuthParamsWrapper.authParamsFromJson(authParams) - val context = if (authOptions.enableV3) context else null - val encryptionKeyBytes = - dbEncryptionKey?.foldIndexed(ByteArray(dbEncryptionKey.size)) { i, a, v -> - a.apply { set(i, v.toByte()) } - } - - val options = ClientOptions( - api = apiEnvironments(authOptions.environment, authOptions.appVersion), - preCreateIdentityCallback = preCreateIdentityCallback, - preEnableIdentityCallback = preEnableIdentityCallback, - preAuthenticateToInboxCallback = preAuthenticateToInboxCallback, - enableV3 = authOptions.enableV3, - appContext = context, - dbEncryptionKey = encryptionKeyBytes, - dbDirectory = authOptions.dbDirectory, - historySyncUrl = authOptions.historySyncUrl - + val options = clientOptions( + dbEncryptionKey, + authParams, + hasCreateIdentityCallback, + hasEnableIdentityCallback, + hasPreAuthenticateToInboxCallback, ) val randomClient = Client().create(account = privateKey, options = options) @@ -328,20 +325,10 @@ class XMTPModule : Module() { AsyncFunction("createFromKeyBundle") Coroutine { keyBundle: String, dbEncryptionKey: List?, authParams: String -> withContext(Dispatchers.IO) { logV("createFromKeyBundle") - val authOptions = AuthParamsWrapper.authParamsFromJson(authParams) try { - val context = if (authOptions.enableV3) context else null - val encryptionKeyBytes = - dbEncryptionKey?.foldIndexed(ByteArray(dbEncryptionKey.size)) { i, a, v -> - a.apply { set(i, v.toByte()) } - } - val options = ClientOptions( - api = apiEnvironments(authOptions.environment, authOptions.appVersion), - enableV3 = authOptions.enableV3, - appContext = context, - dbEncryptionKey = encryptionKeyBytes, - dbDirectory = authOptions.dbDirectory, - historySyncUrl = authOptions.historySyncUrl + val options = clientOptions( + dbEncryptionKey, + authParams ) val bundle = PrivateKeyOuterClass.PrivateKeyBundle.parseFrom( @@ -921,7 +908,10 @@ class XMTPModule : Module() { val client = clients[inboxId] ?: throw XMTPException("No client") val createGroupParams = CreateGroupParamsWrapper.createGroupParamsFromJson(groupOptionsJson) - val permissionPolicySet = PermissionPolicySetWrapper.createPermissionPolicySetFromJson(permissionPolicySetJson) + val permissionPolicySet = + PermissionPolicySetWrapper.createPermissionPolicySetFromJson( + permissionPolicySetJson + ) val group = client.conversations.newGroupCustomPermissions( peerAddresses, permissionPolicySet, From 209c8597e7d8e90bd4657148799a37576ff077b0 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 7 Aug 2024 17:13:02 -0600 Subject: [PATCH 3/4] bump to the latest ios --- ios/XMTPReactNative.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index c50a4bd75..0121f9abc 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.14.0" + s.dependency "XMTP", "= 0.14.1" end From 323982ba82de9f98e884cc1ef7f242ce44c982ee Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 7 Aug 2024 18:20:28 -0600 Subject: [PATCH 4/4] update lock file --- example/ios/Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 896d4cb27..851eca939 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -449,7 +449,7 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.14.0): + - XMTP (0.14.1): - Connect-Swift (= 0.12.0) - GzipSwift - LibXMTP (= 0.5.7-beta0) @@ -458,7 +458,7 @@ PODS: - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.14.0) + - XMTP (= 0.14.1) - Yoga (1.14.0) DEPENDENCIES: @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 080c130548abb58ec507590ab24565285cebb0e1 - XMTPReactNative: 8ef4ef9cadaf78012e04ca88531fe771df10065d + XMTP: 593cf8bf4e9dc0737a6efc90a0e51fe7602101fd + XMTPReactNative: 1ca02155e4583791c8c99a244206ecf8e057abd2 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2