Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
() => {
const fileData = libs.crypto
.bytesToString(libs.crypto.base64Decode(reader.result.split(',')[1]));
this.backup = FromBackupCtrl.parseUsers(fileData);
this.readError = null;
}
).catch(() => {
static createUserId() {
const date = Date.now();
const random = Math.round(Math.random() * 1000000000);
return libs.crypto.base58Encode(libs.crypto.sha256(libs.crypto.stringToBytes(`${date}-${random}`)));
}
]).then(([seed, privateKey, publicKey, encodedSeed]) => {
let canSeed = encodedSeed && seed && typeof seed === 'string';
try {
canSeed = canSeed && libs.crypto.stringToBytes(seed)
.join(',') === libs.crypto.base58Decode(encodedSeed).join(',');
} catch (e) {
canSeed = false;
}
this.phrase = canSeed ? seed : null;
this.encodedSeed = encodedSeed;
this.privateKey = privateKey;
this.publicKey = publicKey;
this.allowParing = canSeed;
$scope.$digest();
});
}
export function networkByteFromAddress(address: string): string {
return String.fromCharCode(libs.crypto.base58Decode(address)[1]);
}
(() => {
'use strict';
const { libs } = require('@waves/waves-transactions');
const {
encryptSeed,
decryptSeed,
base58Encode,
base58Decode,
blake2b,
stringToBytes,
address: buildAddress,
publicKey: buildPublicKey
} = libs.crypto;
let _password;
let _rounds;
let _users = {};
class MultiAccount {
get isSignedIn() {
return !!_password;
}
signUp(password, rounds) {
_password = password;
_rounds = rounds;
_users = {};
(function () {
'use strict';
const onContentLoad = new Promise((resolve) => {
document.addEventListener('DOMContentLoaded', resolve);
});
const { Money } = require('@waves/data-entities');
const { libs } = require('@waves/waves-transactions');
const { base64Encode, blake2b, stringToBytes } = libs.crypto;
const locationHref = location.href;
const i18next = require('i18next');
const ds = require('data-service');
const { propEq, where, gte, lte, equals, __ } = require('ramda');
const i18nextReady = new Promise(resolve => {
const handler = data => {
resolve(data);
i18next.off('initialized', handler);
};
i18next.on('initialized', handler);
});
const PROGRESS_MAP = {
RUN_SCRIPT: 10,
(function () {
'use strict';
const ds = require('data-service');
const { Money } = require('@waves/data-entities');
const { BigNumber } = require('@waves/bignumber');
const { currentCreateOrderFactory } = require('@waves/signature-adapter');
const { libs } = require('@waves/waves-transactions');
const { address } = libs.crypto;
/**
* @param {app.utils} utils
* @param {app.utils.decorators} decorators
* @param {User} user
* @param {PollCache} PollCache
* @param {ConfigService} configService
* @return {Matcher}
*/
const factory = function (utils, decorators, user, PollCache, configService) {
/**
* @class
*/
class Matcher {
(function () {
'use strict';
const { isEmpty, getPaths, get, Signal } = require('ts-utils');
const tsApiValidator = require('ts-api-validator');
const { splitEvery, pipe, path, map, ifElse, concat, defaultTo, identity, isNil, propEq } = require('ramda');
const { WindowAdapter, Bus } = require('@waves/waves-browser-bus');
const { libs } = require('@waves/waves-transactions');
const { base58Decode, base58Encode, stringToBytes, bytesToString } = libs.crypto;
const ds = require('data-service');
const { SIGN_TYPE } = require('@waves/signature-adapter');
const { Money } = require('@waves/data-entities');
const { STATUS_LIST } = require('@waves/oracle-data');
const { BigNumber } = require('@waves/bignumber');
const GOOD_COLORS_LIST = [
'#39a12c',
'#6a737b',
'#e49616',
'#008ca7',
'#ff5b38',
'#ff6a00',
'#c74124',
'#00a78e',
'#b01e53',
const backup = JSON.parse(data);
if (!backup || (backup.type !== 'wavesBackup' || !backup.lastOpenVersion)) {
throw new Error('wrongFile');
}
const dataObject = JSON.parse(
libs.crypto.bytesToString(libs.crypto.base64Decode(backup.data))
);
const hashSum = dataObject.hashSum;
delete dataObject.hashSum;
const savedDataHash = libs.crypto.base58Encode(
libs.crypto.sha256(libs.crypto.stringToBytes(JSON.stringify(dataObject)))
);
if (savedDataHash !== hashSum) {
throw new Error('Fail is corrupted');
}
return {
...dataObject,
type: backup.type,
lastOpenVersion: backup.lastOpenVersion
};
}