How to use the base-64.encode function in base-64

To help you get started, we’ve selected a few base-64 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 laurent22 / joplin / ReactNativeClient / lib / WebDavApi.js View on Github external
authToken() {
		if (!this.options_.username() || !this.options_.password()) return null;
		try {
			// Note: Non-ASCII passwords will throw an error about Latin1 characters - https://github.com/laurent22/joplin/issues/246
			// Tried various things like the below, but it didn't work on React Native:
			// return base64.encode(utf8.encode(this.options_.username() + ':' + this.options_.password()));
			return base64.encode(`${this.options_.username()}:${this.options_.password()}`);
		} catch (error) {
			error.message = `Cannot encode username/password: ${error.message}`;
			throw error;
		}
	}
github Krakabek / songSearchBot / src / providers / spotify.ts View on Github external
function getAuth(): Bluebird {
    // 
    const keys = `${config.get("spotify.clientId")}:${config.get("spotify.clientSecret")}`;
    const encodedKeys = base64.encode(utf8.encode(keys));
    return request({
        method: "POST",
        uri: "https://accounts.spotify.com/api/token",
        form: {
            grant_type: "client_credentials"
        },
        headers: {
            "Authorization": `Basic ${encodedKeys}`,
            "Content-Type": "application/x-www-form-urlencoded"
        },
        json: true
    }).then((response: SpotifyAuthResponse) => {
        token = response.access_token;
        const oneMinute = 60;
        const msInMin = 1000;
        const reAuthDelay = response.expires_in - oneMinute;
github expo / expo / tools / expotools / src / Fixtures.ts View on Github external
res.setHeader(header, responseFixture.headers[header]);
    }

    let decodedData = base64.decode(responseFixture.data);
    let publishInfo = responseFixture.metadata ? responseFixture.metadata.publishInfo : null;
    decodedData = await _rewriteManifestAsync(
      publishInfo,
      req,
      decodedData,
      DEBUGGER_HOST_PLACEHOLDER,
      packagerServerUrl,
      MANIFEST_URL_PLACEHOLDER,
      manifestServerUrl
    );

    res.write(new Buffer(base64.encode(decodedData), 'base64'));
    res.end();
    console.log(`[${fixtureResponseId}] Responded to ${req.url}...`);
  };
github linfaservice / cloudgallery / app / pages / gallery / image-modal.component.js View on Github external
this.params = params;
        this.page = page;
        this.translate = translate;
        this.fonticon = fonticon;
        this.util = util;
        this.language = Platform.device.language;
        this.translate.setDefaultLang("en");
        this.translate.use(Platform.device.language.split("-")[0]);
        this.host = Settings.getString("host");
        this.username = Settings.getString("username");
        this.password = Settings.getString("password");
        this.rootdir = Settings.getString("rootdir");
        this.rootdir = (this.rootdir == null) ? "" : this.rootdir;
        this.headers = {
            "OCS-APIREQUEST": "true",
            "Authorization": "Basic " + Base64.encode(this.username + ':' + this.password)
        };
        this.item = params.context.item;
        this.loader = params.context.loader;
    }
    ImageModalComponent.prototype.ngOnInit = function () {
github heroiclabs / nakama-js / src / client.js View on Github external
message["collationId"] = uuidv4();

    const protocol = (this.ssl) ? 'https' : 'http';
    const url = `${protocol}://${this.host}:${this.port}${path}`

    if (this.verbose && window.console) {
      console.log("AuthenticateRequest: %s, %o", url, message);
    }

    var verbose = this.verbose;
    return fetch(url, {
      "method": "POST",
      "body": JSON.stringify(message),
      "headers": {
        "Accept-Language": this.lang,
        "Authorization": 'Basic ' + base64.encode(this.serverKey + ':'),
        "Content-Type": 'application/json',
        "Accept": 'application/json',
        "User-Agent": `nakama/${VERSION}`
      }
    }).then(function(response) {
      if (verbose && window.console) {
        console.log("AuthenticateResponse: %o", response);
      }

      return response.json();
    }).then(function(response) {
      if (verbose && window.console) {
        console.log("AuthenticateResponse (body): %o", response);
      }

      if (response.error) {
github linfaservice / cloudgallery / app / pages / gallery / gallery.component.ts View on Github external
this.translate.use(Platform.device.language.split("-")[0]).subscribe(()=> {
        this.host = Settings.getString("host");
        this.username = Settings.getString("username");
        this.password = Settings.getString("password");
        this.rootdir = Settings.getString("rootdir");  
        this.rootdir = (this.rootdir==null)? "":this.rootdir;
        this.headers = { 
          "OCS-APIREQUEST": "true",
          "Authorization": "Basic "+Base64.encode(this.username+':'+this.password)
        }            

        this.cache.images = new Array();
        this.home();
      });
    }
github filipenatanael / whatsapp-clone-react-native / source / components / ChatsList.js View on Github external
componentWillMount() {
    this.props.fetchAllChats(base64.encode(this.props.email_logged_in));
    this.createDataSource(this.props.chatsList);
  }
github apache / couchdb-fauxton / app / addons / replication / components / newreplication.js View on Github external
checkCredentials(username, password) {
    return json(Helpers.getServerUrl('/'), 'GET', {
      credentials: 'omit',
      headers: {
        'Authorization':'Basic ' + base64.encode(username + ':' + password)
      }
    });
  }
github neiker / analytics-react-native / src / index.js View on Github external
const callbacks = queuedItems.map(item => item.callback);
    callbacks.push(flushCallback);

    const data = {
      batch: queuedItems.map(item => item.message),
      timestamp: new Date(),
      sentAt: new Date(),
    };

    axios(
      `${this.host}/v1/batch`,
      {
        data,
        method: 'post',
        headers: {
          Authorization: `Basic ${base64.encode(this.writeKey)}`,
          'Content-Type': 'application/json; charset=utf-8',
          'X-Requested-With': 'XMLHttpRequest',
        },
      },
    )
      .then(() => {
        callbacks.forEach((callback) => {
          callback(undefined, data);
        });
      })
      .catch((error) => {
        callbacks.forEach((callback) => {
          callback(error);
        });
      });
github hubidu / heimdall-io / report-app / services / get-screenshot-url.js View on Github external
export default (path, filename) => `http://${config.ReportServiceHost}/screenshots/${base64.encode(encodeURIComponent(path))}/${base64.encode(encodeURIComponent(filename))}`

base-64

A robust base64 encoder/decoder that is fully compatible with `atob()` and `btoa()`, written in JavaScript.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis