How to use the react-native-config.CHAT_TOKEN function in react-native-config

To help you get started, we’ve selected a few react-native-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Bit-Nation / BITNATION-Pangea-mobile / src / services / accounts / index.js View on Github external
static async validateMnemonicWithAccount(accountStore: string, profile: Profile, mne: Mnemonic): Promise {
    try {
      await panthalassaStop();
      // eslint-disable-next-line no-empty
    } catch (e) {
      // We ignore exception, since we just need stop it in case it was started earlier.
    }
    const config = JSON.stringify({
      encrypted_key_manager: accountStore,
      enable_debugging: false,
      eth_ws_endpoint: 'wss://mainnet.infura.io/_ws',
      private_chat_endpoint: Config.CHAT_WSS_ENDPOINT,
      private_chat_bearer_token: Config.CHAT_TOKEN,
    });

    try {
      await panthalassaStartFromMnemonic(config, compressMnemonic(mne));
    } catch (e) {
      console.log(`[TEST] Panthalassa start failed: ${e.message}`);
      return false;
    }

    return true;
  }
github Bit-Nation / BITNATION-Pangea-mobile / src / modules / accounts / accounts-services.js View on Github external
try {
      await panthalassaStop();
      // eslint-disable-next-line no-empty
    } catch (e) {
      // We ignore exception, since we just need stop it in case it was started earlier.
    }
    const signedProfile = await AccountsService.signProfileStandalone(profile, accountStore, password).catch(() => {
      throw new InvalidPasswordError();
    });
    const config = JSON.stringify({
      encrypted_key_manager: accountStore,
      signed_profile: signedProfile,
      enable_debugging: false,
      eth_ws_endpoint: networkType === 'main' ? 'wss://mainnet.infura.io/ws' : 'wss://rinkeby.infura.io/ws',
      private_chat_endpoint: Config.CHAT_WSS_ENDPOINT,
      private_chat_bearer_token: Config.CHAT_TOKEN,
    });

    try {
      await panthalassaStart(config, password);
    } catch (e) {
      console.log(`[TEST] Panthalassa start failed: ${e.message}`);
      return false;
    }

    try {
      await ChatService.uploadProfile(signedProfile);
    } catch (e) {
      console.log(`[TEST] Profile upload fail: ${e.message}`);
    }

    return true;
github Bit-Nation / BITNATION-Pangea-mobile / src / services / chat / index.js View on Github external
static async uploadProfile(profile: string): Promise {
    console.log(`[TEST] Profile upload: ${profile}`);
    const URL = `${Config.CHAT_ENDPOINT}/profile`;
    const result = await fetch(URL, {
      body: profile,
      headers: {
        'content-type': 'application/json',
        bearer: Config.CHAT_TOKEN,
      },
      method: 'PUT',
    });
    console.log(`[TEST] Profile upload result: ${JSON.stringify(result)}`);
    if (result.ok !== true) {
      return Promise.reject(new Error('Failed to upload profile'));
    }

    return Promise.resolve();
  }
github Bit-Nation / BITNATION-Pangea-mobile / src / modules / chat / chat-service / index.js View on Github external
static async getProfile(publicKey: string): Promise {
    const URL = `${Config.CHAT_ENDPOINT}/profile`;
    return fetch(URL, {
      headers: {
        'content-type': 'application/json',
        bearer: Config.CHAT_TOKEN,
        'Cache-Control': 'no-cache, no-store, must-revalidate',
        Pragma: 'no-cache',
        Expires: 0,
        Identity: publicKey,
      },
      method: 'GET',
    })
      .then(response => response.text())
      .then(response => Profile.decode(Buffer.from(response, 'base64')))
      .then(response => Profile.toObject(response, { bytes: String }));
  }