How to use the js-base64.Base64.encode function in js-base64

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 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 Apicurio / apicurio-studio / front-end / studio / src / app / pages / apis / import / _components / import-form.component.ts View on Github external
public importApi(): void {
        this.error = null;

        let importApi: ImportApi = new ImportApi();
        if (this.model.url) {
            importApi.url = this.model.url;
        } else if (this.model.data) {
            try {
                importApi.data = Base64.encode(this.model.data);
            } catch (e) {
                console.error(e);
            }
        }

        this.onImportApi.emit(importApi);
    }
github surmon-china / angular-admin / src / app / pages / auth / auth.component.ts View on Github external
fetchLogin(password: string): Promise {
    return this.httpService.post(API_PATH.LOGIN, { password: Base64.encode(password) })
      .then(auth => {
        if (auth.result.access_token) {
          localStorage.setItem(TOKEN, auth.result.access_token);
          this.router.navigate(['/dashboard']);
          this.fetchAdminInfo();
        }
      })
      .catch(error => {
        console.warn('登陆系统失败!', error);
      });
  }
github ntblk / block-crawler / index.js View on Github external
bc.on('found', res => {

  res.clientIP = externalIP;

  if (argv.obfuscate) {
    res.urlEncoded = Base64.encode(res.url);
    delete res.url;
  }

  console.log(JSON.stringify(res));

  if (argv.collector)
    axios.post(argv.collector, res)
      .then(function (response) {
      })
      .catch(function (error) {
        console.error(error);
      });
});
github brainnit / adonisjs-scout / src / Paginators / CursorPaginator.js View on Github external
static encodeCursor (cursor) {
    return Base64.encode(JSON.stringify(cursor))
  }
github microsoft / nni / src / nni_manager / training_service / kubernetes / kubernetesTrainingService.ts View on Github external
.toLowerCase());
            await this.genericK8sClient.createSecret(
                {
                    apiVersion: 'v1',
                    kind: 'Secret',
                    metadata: {
                        name: this.azureStorageSecretName,
                        namespace: 'default',
                        labels: {
                            app: this.NNI_KUBERNETES_TRIAL_LABEL,
                            expId: getExperimentId()
                        }
                    },
                    type: 'Opaque',
                    data: {
                        azurestorageaccountname: Base64.encode(this.azureStorageAccountName),
                        azurestorageaccountkey: Base64.encode(storageAccountKey)
                    }
                }
            );
        } catch (error) {
            this.log.error(error);

            return Promise.reject(error);
        }

        return Promise.resolve();
    }
github github-tools / github / lib / Requestable.js View on Github external
constructor(auth, apiBase, AcceptHeader) {
      this.__apiBase = apiBase || 'https://api.github.com';
      this.__auth = {
         token: auth.token,
         username: auth.username,
         password: auth.password,
      };
      this.__AcceptHeader = AcceptHeader || 'v3';

      if (auth.token) {
         this.__authorizationHeader = 'token ' + auth.token;
      } else if (auth.username && auth.password) {
         this.__authorizationHeader = 'Basic ' + Base64.encode(auth.username + ':' + auth.password);
      }
   }