How to use the pouchdb-binary-utils.btoa function in pouchdb-binary-utils

To help you get started, we’ve selected a few pouchdb-binary-utils 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 pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-utils / src / preprocessAttachments.js View on Github external
function preprocessString(att, blobType, callback) {
  var asBinary = parseBase64(att.data);
  if (asBinary.error) {
    return callback(asBinary.error);
  }

  att.length = asBinary.length;
  if (blobType === 'blob') {
    att.data = binStringToBlobOrBuffer(asBinary, att.content_type);
  } else if (blobType === 'base64') {
    att.data = btoa(asBinary);
  } else { // binary
    att.data = asBinary;
  }
  binaryMd5(asBinary, function (result) {
    att.digest = 'md5-' + result;
    callback();
  });
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-websql-core / src / index.js View on Github external
tx.executeSql(sql, [digest], function (tx, result) {
      // websql has a bug where \u0000 causes early truncation in strings
      // and blobs. to work around this, we used to use the hex() function,
      // but that's not performant. after migration 6, we remove \u0000
      // and add it back in afterwards
      var item = result.rows.item(0);
      var data = item.escaped ? unescapeBlob(item.body) :
        parseHexString(item.body, encoding);
      if (opts.binary) {
        res = binStringToBlob(data, type);
      } else {
        res = btoa(data);
      }
      callback(null, res);
    });
  };
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-idb / src / utils.js View on Github external
readAsBinaryString(body, function (binary) {
        callback(btoa(binary));
      });
    } else { // no blob support
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-http / src / index.js View on Github external
var ourFetch = function (url, options) {

    options = options || {};
    options.headers = options.headers || new Headers();

    options.credentials = 'include';

    if (opts.auth || host.auth) {
      var nAuth = opts.auth || host.auth;
      var str = nAuth.username + ':' + nAuth.password;
      var token = btoa(unescape(encodeURIComponent(str)));
      options.headers.set('Authorization', 'Basic ' + token);
    }

    var headers = opts.headers || {};
    Object.keys(headers).forEach(function (key) {
      options.headers.append(key, headers[key]);
    });

    /* istanbul ignore if */
    if (shouldCacheBust(options)) {
      url += (url.indexOf('?') === -1 ? '?' : '&') + '_nonce=' + Date.now();
    }

    var fetchFun = opts.fetch || fetch;
    return fetchFun(url, options);
  };
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-asyncstorage-pure / src / get_attachment.js View on Github external
readAsBinaryString(doc.attachments[digest].data, binString => {
      callback(null, btoa(binString))
    })
  })
github pouchdb-community / pouchdb-authentication / src / utils.js View on Github external
if (db.__opts.auth) {
    auth = db.__opts.auth;
  } else {
    var url = urlParse(db.name);
    if (url.auth) {
      auth = url;
    }
  }

  if (!auth) {
    return {};
  }

  var str = auth.username + ':' + auth.password;
  var token = btoa(unescape(encodeURIComponent(str)));
  return {Authorization: 'Basic ' + token};
}
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-indexeddb / src / getAttachment.js View on Github external
readAsBinaryString(attachment, function (binString) {
      cb(null, btoa(binString));
    });
  }
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-indexeddb / src / util.js View on Github external
readAsBinaryString(data, function (binString) {
      doc._attachments[name].data = btoa(binString);
      delete doc._attachments[name].length;
      resolve();
    });
  });