
XMTP decentralize chatting
import { Client , PublicIdentity , ReplyCodec , ConsentRecord , } from ' @xmtp/react-native-sdk ' ; import { IS_SANDBOX } from ' dok-wallet-blockchain-networks/config/config ' ; import { ContentTypeCustomReplyCodec } from ' ./xmtpContentReplyType ' ; import crypto from ' react-native-quick-crypto ' ; import SensitiveInfo from ' react-native-sensitive-info ' ; import { Buffer } from ' buffer ' ; import RNFS from ' react-native-fs ' ; const XMTP_DB_KEY_STORAGE = ' xmtp_db_encryption_key ' ; const KEYCHAIN_SERVICE = ' com.dokwallet.xmtp ' ; const XMTP_ENV = IS_SANDBOX ? ' dev ' : ' production ' ; const getOrCreateDbEncryptionKey = async () => { try { const stored = await SensitiveInfo . getItem ( XMTP_DB_KEY_STORAGE , { keychainService : KEYCHAIN_SERVICE , }); if ( stored ) { return Buffer . from ( stored , ' hex ' ); } } catch ( e ) { console . warn ( ' XMTP: failed to read encryption key from storage ' , e ); } const key = crypto . randomBytes ( 32 ); try { await SensitiveInfo . setItem
Continue reading on Dev.to JavaScript
Opens in a new tab



