Skip to content
Merged
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 android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:4.3.3"
implementation "org.xmtp:android:4.4.0-dev.7f5d8e0"
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,34 @@ class XMTPModule : Module() {
return reactContext
}

private fun apiEnvironments(env: String, customLocalUrl: String? = null): ClientOptions.Api {
private fun apiEnvironments(env: String, customLocalUrl: String? = null, appVersion: String? = null): ClientOptions.Api {
return when (env) {
"local" -> {
if (customLocalUrl.isNullOrBlank()) {
ClientOptions.Api(
env = XMTPEnvironment.LOCAL,
isSecure = false,
appVersion = appVersion,
)
} else {
ClientOptions.Api(
env = XMTPEnvironment.LOCAL.withValue(customLocalUrl),
isSecure = false,
appVersion = appVersion,
)
}
}

"production" -> ClientOptions.Api(
env = XMTPEnvironment.PRODUCTION,
isSecure = true,
appVersion = appVersion,
)

else -> ClientOptions.Api(
env = XMTPEnvironment.DEV,
isSecure = true,
appVersion = appVersion,
)
}
}
Expand All @@ -209,7 +213,7 @@ class XMTPModule : Module() {
else -> "https://message-history.dev.ephemera.network/"
}
return ClientOptions(
api = apiEnvironments(authOptions.environment, authOptions.customLocalUrl),
api = apiEnvironments(authOptions.environment, authOptions.customLocalUrl, authOptions.appVersion),
preAuthenticateToInboxCallback = preAuthenticateToInboxCallback,
appContext = context,
dbEncryptionKey = encryptionKeyBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AuthParamsWrapper(
val customLocalUrl: String?,
val deviceSyncEnabled: Boolean,
val debugEventsEnabled: Boolean,
val appVersion: String?,
) {
companion object {
fun authParamsFromJson(authParams: String): AuthParamsWrapper {
Expand All @@ -21,7 +22,8 @@ class AuthParamsWrapper(
if (jsonOptions.has("customLocalUrl")) jsonOptions.get("customLocalUrl").asString else null,
if (jsonOptions.has("deviceSyncEnabled")) jsonOptions.get("deviceSyncEnabled").asBoolean else true,
if (jsonOptions.has("debugEventsEnabled")) jsonOptions.get("debugEventsEnabled").asBoolean else false,
)
if (jsonOptions.has("appVersion")) jsonOptions.get("appVersion").asString else null,
)
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ PODS:
- hermes-engine (0.76.9):
- hermes-engine/Pre-built (= 0.76.9)
- hermes-engine/Pre-built (0.76.9)
- LibXMTP (4.3.4)
- LibXMTP (4.4.0-dev.7f5d8e0)
- MessagePacker (0.4.7)
- MMKV (2.2.2):
- MMKVCore (~> 2.2.2)
Expand Down Expand Up @@ -1737,18 +1737,18 @@ PODS:
- SQLCipher/standard (4.5.7):
- SQLCipher/common
- SwiftProtobuf (1.28.2)
- XMTP (4.3.3):
- XMTP (4.4.0-dev.7f5d8e0.c2ccb07):
- Connect-Swift (= 1.0.0)
- CryptoSwift (= 1.8.3)
- CSecp256k1 (~> 0.2)
- LibXMTP (= 4.3.4)
- LibXMTP (= 4.4.0-dev.7f5d8e0)
- SQLCipher (= 4.5.7)
- XMTPReactNative (4.3.2):
- XMTPReactNative (4.4.0-dev.7f5d8e0):
- CSecp256k1 (~> 0.2)
- ExpoModulesCore
- MessagePacker
- SQLCipher (= 4.5.7)
- XMTP (= 4.3.3)
- XMTP (= 4.4.0-dev.7f5d8e0.c2ccb07)
- Yoga (0.0.0)

DEPENDENCIES:
Expand Down Expand Up @@ -2080,7 +2080,7 @@ SPEC CHECKSUMS:
fmt: 01b82d4ca6470831d1cc0852a1af644be019e8f6
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 9e868dc7be781364296d6ee2f56d0c1a9ef0bb11
LibXMTP: 569954d60a68b6f556cba98ab908827ba6926d48
LibXMTP: 78993f4cbe9bb27959d3efe7a37e335c2b0210b0
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: b4802ebd5a7c68fc0c4a5ccb4926fbdfb62d68e0
MMKVCore: a255341a3746955f50da2ad9121b18cb2b346e61
Expand Down Expand Up @@ -2160,8 +2160,8 @@ SPEC CHECKSUMS:
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
SQLCipher: 5e6bfb47323635c8b657b1b27d25c5f1baf63bf5
SwiftProtobuf: 4dbaffec76a39a8dc5da23b40af1a5dc01a4c02d
XMTP: 6622a70a10c16436b3eafb0ee4c1f3a5a619a7f9
XMTPReactNative: ffdbe5bbe82e519ea6629d82c2001379d995842f
XMTP: 38ed0f18ac789027003bd15088fd831af8809fff
XMTPReactNative: c17fc110b8311fe1babf392cbe5745a2015b2111
Yoga: feb4910aba9742cfedc059e2b2902e22ffe9954a

PODFILE CHECKSUM: 283c313cbc1ba9857a692b5901eb740dad922eca
Expand Down
1 change: 1 addition & 0 deletions example/src/tests/clientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ test('can make a client', async () => {
env: 'local',
dbEncryptionKey: keyBytes,
deviceSyncEnabled: false,
appVersion: '0.0.0',
})

const inboxId = await Client.getOrCreateInboxId(
Expand Down
18 changes: 13 additions & 5 deletions ios/Wrappers/AuthParamsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ struct AuthParamsWrapper {
let customLocalUrl: String?
let deviceSyncEnabled: Bool
let debugEventsEnabled: Bool
let appVersion: String?

init(
environment: String, dbDirectory: String?,
historySyncUrl: String?, customLocalUrl: String?,
deviceSyncEnabled: Bool, debugEventsEnabled: Bool
deviceSyncEnabled: Bool, debugEventsEnabled: Bool,
appVersion: String?
) {
self.environment = environment
self.dbDirectory = dbDirectory
self.historySyncUrl = historySyncUrl
self.customLocalUrl = customLocalUrl
self.deviceSyncEnabled = deviceSyncEnabled
self.debugEventsEnabled = debugEventsEnabled
self.appVersion = appVersion
}

static func authParamsFromJson(_ authParams: String) -> AuthParamsWrapper {
Expand All @@ -37,23 +40,28 @@ struct AuthParamsWrapper {
return AuthParamsWrapper(
environment: "dev", dbDirectory: nil,
historySyncUrl: nil, customLocalUrl: nil,
deviceSyncEnabled: true, debugEventsEnabled: false)
deviceSyncEnabled: true, debugEventsEnabled: false,
appVersion: nil)
}

let environment = jsonOptions["environment"] as? String ?? "dev"
let dbDirectory = jsonOptions["dbDirectory"] as? String
let historySyncUrl = jsonOptions["historySyncUrl"] as? String
let customLocalUrl = jsonOptions["customLocalUrl"] as? String
let deviceSyncEnabled = jsonOptions["deviceSyncEnabled"] as? Bool ?? true
let debugEventsEnabled = jsonOptions["debugEventsEnabled"] as? Bool ?? false
let deviceSyncEnabled =
jsonOptions["deviceSyncEnabled"] as? Bool ?? true
let debugEventsEnabled =
jsonOptions["debugEventsEnabled"] as? Bool ?? false
let appVersion = jsonOptions["appVersion"] as? String

return AuthParamsWrapper(
environment: environment,
dbDirectory: dbDirectory,
historySyncUrl: historySyncUrl,
customLocalUrl: customLocalUrl,
deviceSyncEnabled: deviceSyncEnabled,
debugEventsEnabled: debugEventsEnabled
debugEventsEnabled: debugEventsEnabled,
appVersion: appVersion
)
}
}
Expand Down
14 changes: 9 additions & 5 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2916,7 +2916,7 @@ public class XMTPModule: Module {
case revokeInstallations = "revokeInstallations"
}

func createApiClient(env: String, customLocalUrl: String? = nil)
func createApiClient(env: String, customLocalUrl: String? = nil, appVersion: String? = nil)
-> XMTP.ClientOptions.Api
{
switch env {
Expand All @@ -2926,17 +2926,20 @@ public class XMTPModule: Module {
}
return XMTP.ClientOptions.Api(
env: XMTP.XMTPEnvironment.local,
isSecure: false
isSecure: false,
appVersion: appVersion
)
case "production":
return XMTP.ClientOptions.Api(
env: XMTP.XMTPEnvironment.production,
isSecure: true
isSecure: true,
appVersion: appVersion
)
default:
return XMTP.ClientOptions.Api(
env: XMTP.XMTPEnvironment.dev,
isSecure: true
isSecure: true,
appVersion: appVersion
)
}
}
Expand All @@ -2950,7 +2953,8 @@ public class XMTPModule: Module {
return XMTP.ClientOptions(
api: createApiClient(
env: authOptions.environment,
customLocalUrl: authOptions.customLocalUrl
customLocalUrl: authOptions.customLocalUrl,
appVersion: authOptions.appVersion
),
preAuthenticateToInboxCallback: preAuthenticateToInboxCallback,
dbEncryptionKey: dbEncryptionKey,
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m,swift}"

s.dependency "MessagePacker"
s.dependency "XMTP", "= 4.3.3"
s.dependency "XMTP", "= 4.4.0-dev.7f5d8e0.c2ccb07"
s.dependency 'CSecp256k1', '~> 0.2'
s.dependency "SQLCipher", "= 4.5.7"
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xmtp/react-native-sdk",
"version": "4.3.3",
"version": "4.4.0-dev.7f5d8e0",
"description": "Wraps for native xmtp sdks for react native",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
17 changes: 13 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export async function createRandom(
historySyncUrl?: string | undefined,
customLocalHost?: string | undefined,
deviceSyncEnabled?: boolean | undefined,
debugEventsEnabled?: boolean | undefined
debugEventsEnabled?: boolean | undefined,
appVersion?: string | undefined
): Promise<string> {
const authParams: AuthParams = {
environment,
Expand All @@ -135,6 +136,7 @@ export async function createRandom(
customLocalHost,
deviceSyncEnabled,
debugEventsEnabled,
appVersion,
}
return await XMTPModule.createRandom(
hasPreAuthenticateToInboxCallback,
Expand All @@ -155,7 +157,8 @@ export async function create(
blockNumber?: number | undefined,
customLocalHost?: string | undefined,
deviceSyncEnabled?: boolean | undefined,
debugEventsEnabled?: boolean | undefined
debugEventsEnabled?: boolean | undefined,
appVersion?: string | undefined
): Promise<string> {
const authParams: AuthParams = {
environment,
Expand All @@ -164,6 +167,7 @@ export async function create(
customLocalHost,
deviceSyncEnabled,
debugEventsEnabled,
appVersion,
}
const signerParams: SignerParams = {
signerType,
Expand All @@ -188,7 +192,8 @@ export async function build(
inboxId?: InboxId | undefined,
customLocalHost?: string | undefined,
deviceSyncEnabled?: boolean | undefined,
debugEventsEnabled?: boolean | undefined
debugEventsEnabled?: boolean | undefined,
appVersion?: string | undefined
): Promise<string> {
const authParams: AuthParams = {
environment,
Expand All @@ -197,6 +202,7 @@ export async function build(
customLocalHost,
deviceSyncEnabled,
debugEventsEnabled,
appVersion,
}
return await XMTPModule.build(
JSON.stringify(identity),
Expand All @@ -214,7 +220,8 @@ export async function ffiCreateClient(
historySyncUrl?: string | undefined,
customLocalHost?: string | undefined,
deviceSyncEnabled?: boolean | undefined,
debugEventsEnabled?: boolean | undefined
debugEventsEnabled?: boolean | undefined,
appVersion?: string | undefined
): Promise<string> {
const authParams: AuthParams = {
environment,
Expand All @@ -223,6 +230,7 @@ export async function ffiCreateClient(
customLocalHost,
deviceSyncEnabled,
debugEventsEnabled,
appVersion,
}
return await XMTPModule.ffiCreateClient(
JSON.stringify(identity),
Expand Down Expand Up @@ -1719,6 +1727,7 @@ interface AuthParams {
customLocalHost?: string
deviceSyncEnabled?: boolean
debugEventsEnabled?: boolean
appVersion?: string
}

interface SignerParams {
Expand Down
16 changes: 12 additions & 4 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export class Client<
options.historySyncUrl,
options.customLocalHost,
options.deviceSyncEnabled,
options.debugEventsEnabled
options.debugEventsEnabled,
options.appVersion
)
this.removeSubscription(authInboxSubscription)

Expand Down Expand Up @@ -193,7 +194,8 @@ export class Client<
signingKey.getBlockNumber?.(),
options.customLocalHost,
options.deviceSyncEnabled,
options.debugEventsEnabled
options.debugEventsEnabled,
options.appVersion
)
})().catch((error) => {
this.removeAllSubscriptions(authInboxSubscription)
Expand Down Expand Up @@ -231,7 +233,8 @@ export class Client<
inboxId,
options.customLocalHost,
options.deviceSyncEnabled,
options.debugEventsEnabled
options.debugEventsEnabled,
options.appVersion
)

return new Client(
Expand Down Expand Up @@ -276,7 +279,8 @@ export class Client<
options.historySyncUrl,
options.customLocalHost,
options.deviceSyncEnabled,
options.debugEventsEnabled
options.debugEventsEnabled,
options.appVersion
)

return new Client(
Expand Down Expand Up @@ -1130,6 +1134,10 @@ export type ClientOptions = {
* OPTIONAL specify the XMTP managed database directory
*/
dbDirectory?: string
/**
* OPTIONAL specify an appVersion
*/
appVersion?: string
/**
* OPTIONAL specify a url to sync message history from
*/
Expand Down