How to use js-base64 - 10 common examples

To help you get started, we’ve selected a few js-base64 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 harpagon210 / steemsmartcontracts / test / nft.js View on Github external
};

console.log(nftContractPayload)

// prepare test contract for issuing & transferring NFT instances
const testSmartContractCode = `
  actions.createSSC = function (payload) {
    // Initialize the smart contract via the create action
  }

  actions.doIssuance = async function (payload) {
    await api.executeSmartContract('nft', 'issue', payload);
  }
`;

base64ContractCode = Base64.encode(testSmartContractCode);

let testContractPayload = {
  name: 'testContract',
  params: '',
  code: base64ContractCode,
};

console.log(testContractPayload)

// nft
describe('nft', function() {
  this.timeout(10000);

  before((done) => {
    new Promise(async (resolve) => {
      client = await MongoClient.connect(conf.databaseURL, { useNewUrlParser: true });
github mermaidjs / mermaid-live-editor / src / components / Preview.js View on Github external
code,
      history,
      match: { url }
    } = this.props
    try {
      mermaid.parse(code)
      // Replacing special characters '<' and '>' with encoded '<' and '>'
      let _code = code
      _code = _code.replace(//g, '>')
      // Overriding the innerHTML with the updated code string
      this.container.innerHTML = _code
      mermaid.init(undefined, this.container)
    } catch (e) {
      // {str, hash}
      const base64 = Base64.encodeURI(e.str || e.message)
      history.push(`${url}/error/${base64}`)
    }
  }
github graphsense / graphsense-dashboard / src / app.js View on Github external
compress (data) {
    return new Uint32Array(
      pack(
        // convert to base64 (utf-16 safe)
        Base64.encode(
          JSON.stringify(data)
        )
      )
    ).buffer
  }
  decompress (data) {
github github-tools / github / lib / Repository.js View on Github external
return {
            content: Utf8.encode(content),
            encoding: 'utf-8',
         };

      } else if (typeof Buffer !== 'undefined' && content instanceof Buffer) {
         log('We appear to be in Node');
         return {
            content: content.toString('base64'),
            encoding: 'base64',
         };

      } else if (typeof Blob !== 'undefined' && content instanceof Blob) {
         log('We appear to be in the browser');
         return {
            content: Base64.encode(content),
            encoding: 'base64',
         };

      } else { // eslint-disable-line
         log(`Not sure what this content is: ${typeof content}, ${JSON.stringify(content)}`);
         throw new Error('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web)');
      }
   }
github GetKitsune / application-development-kit / IDE / src / actions / editor.js View on Github external
const extractCodeValue = (fileType, base64Data, metaData) => {
	const { extensionMap } = config.INTERNAL_SETTINGS;
	const errorCtx = { error: 'unsupported file type', message: 'application zips should be uploaded through Project > import existing application' }

	// Default return the encoded data as is
	let result = base64Data;

	try {
		if (fileType === extensionMap.get('zip')) {
			// Prettify the data, as ace editor will not do this for us
			result = Base64.encode(
				JSON.stringify((metaData.Configuration ?
					JSON.parse(Base64.decode(base64Data)) :
					errorCtx),
					null, '\t')
			);
		}
	}
	catch (e) {
		// Error context can be modified by any closure, and add a throw to get into this block
		toastr.error(errorCtx.error, errorCtx.message);
	}

	return result;
};
github auth0 / angular2-jwt / angular2-jwt.ts View on Github external
public urlBase64Decode(str: string): string {
    let output = str.replace(/-/g, '+').replace(/_/g, '/');
    switch (output.length % 4) {
      case 0: { break; }
      case 2: { output += '=='; break; }
      case 3: { output += '='; break; }
      default: {
        throw 'Illegal base64url string!';
      }
    }
    // This does not use btoa because it does not support unicode and the various fixes were... wonky.
    return Base64.decode(output);
  }
github dpa99c / cordova-check-plugins / lib / remote.js View on Github external
var exec = require('child_process').exec;

    // lib
    var logger = require('./logger.js')();
    var errorHandler = require('./errorHandler.js')();
    var progress = require('./progress.js')();
    var cliArgs = require('./cliArgs.js')().args;

    // 3rd party
    try{
        var fs = require('fs-extra');
        var xml2js = require('xml2js').parseString;
        var _ = require('lodash');
        var semver = require('semver');
        var github = require('octonode');
        var Base64 = require('js-base64').Base64;
    }catch(e){
        errorHandler.handleFatalException(e, "Failed to acquire module dependencies");
    }

    /**********************
     * Internal properties
     *********************/
    var remote = {};

    var opts, plugins, onFinish, pluginCount, unconstrainVersions,
        checkCount, ghClient;

    /**********************
     * Internal functions
     *********************/
github fluidtrends / chunky / cloud / src / firebase.js View on Github external
const firebase = require('firebase-admin')
const firebaseline = require('firebaseline')
const Base64 = require('js-base64').Base64

function operation (name, args) {
  return firebaseline.operations[name](firebase, args)
}

function initialize (config) {
  if (firebase.apps.length > 0) {
    // No need to inititalize again
    return
  }

  // Initialize for the first time
  firebase.initializeApp({
    credential: firebase.credential.cert(config.serviceAccount),
    databaseURL: 'https://' + config.serviceAccount.project_id + '.firebaseio.com'
  })
github chriseth / browser-solidity / src / app.js View on Github external
/* global alert, confirm, prompt, FileReader, Option, Worker, chrome */
'use strict'

var $ = require('jquery')
var base64 = require('js-base64').Base64
var swarmgw = require('swarmgw')

var QueryParams = require('./app/query-params')
var queryParams = new QueryParams()
var GistHandler = require('./app/gist-handler')
var gistHandler = new GistHandler()

var Storage = require('./app/storage')
var Files = require('./app/files')
var Config = require('./app/config')
var Editor = require('./app/editor')
var Renderer = require('./app/renderer')
var Compiler = require('./app/compiler')
var ExecutionContext = require('./app/execution-context')
var UniversalDApp = require('./universal-dapp.js')
var Debugger = require('./app/debugger')
github microsoft / pai / src / rest-server / src / models / template.js View on Github external
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


const base64 = require('js-base64').Base64;
const github = require('@octokit/rest');
const https = require('https');
const url = require('url');
const yaml = require('js-yaml');

const logger = require('../config/logger');
const config = require('../config/github');

const contentUrlPrefix = `https://raw.githubusercontent.com/${config.owner}/${config.repository}`;

/**
 * Get template content by the given qualifier.
 * @param {*} options A MAP object containing keys 'type', 'name', 'version'.
 * @param {*} callback A function object accepting 2 parameters which are error and result.
 */
const load = (options, callback) => {

js-base64

Yet another Base64 transcoder in pure-JS

BSD-3-Clause
Latest version published 4 months ago

Package Health Score

84 / 100
Full package analysis

Popular JavaScript code snippets

Find secure code to use in your application or website