4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-11 17:55:51 +00:00

Remove use strict make api full esm compatible

This commit is contained in:
AlphaX-Projects 2024-05-10 18:00:47 +02:00
parent 3cc5d544a2
commit 0b2bceb842
64 changed files with 9391 additions and 9472 deletions

View File

@ -1,9 +1,9 @@
import {Sha256} from 'asmcrypto.js' import { Sha256 } from 'asmcrypto.js'
import Base58 from './api/deps/Base58' import Base58 from './api/deps/Base58'
import Base64 from './api/deps/Base64' import Base64 from './api/deps/Base64'
import {base58PublicKeyToAddress} from './api/wallet/base58PublicKeyToAddress' import { base58PublicKeyToAddress } from './api/wallet/base58PublicKeyToAddress'
import {validateAddress} from './api/wallet/validateAddress' import { validateAddress } from './api/wallet/validateAddress'
import {decryptChatMessage, decryptChatMessageBase64} from './api/transactions/chat/decryptChatMessage' import { decryptChatMessage, decryptChatMessageBase64 } from './api/transactions/chat/decryptChatMessage'
import _ from 'lodash' import _ from 'lodash'
window.Sha256 = Sha256 window.Sha256 = Sha256
@ -15,8 +15,8 @@ window.validateAddress = validateAddress
window.decryptChatMessage = decryptChatMessage window.decryptChatMessage = decryptChatMessage
window.decryptChatMessageBase64 = decryptChatMessageBase64 window.decryptChatMessageBase64 = decryptChatMessageBase64
export { initApi, store } from './api_deps.js' export { initApi, store } from './api_deps'
export * from './api/deps/deps.js' export * from './api/deps/deps'
export * from './api/api.js' export * from './api/api'
export * from './api/registerUsername.js' export * from './api/registerUsername'
export { createWallet } from './api/createWallet.js' export { createWallet } from './api/createWallet'

View File

@ -1,15 +1,12 @@
/* /*
Copyright 2017-2018 @ irontiga and vbcs (original developer) Copyright 2017-2018 @ irontiga and vbcs (original developer)
*/ */
'use strict' import Base58 from './deps/Base58'
import Base58 from './deps/Base58.js' import { Sha256, Sha512 } from 'asmcrypto.js'
import {Sha256, Sha512} from 'asmcrypto.js' import nacl from './deps/nacl-fast'
import nacl from './deps/nacl-fast.js' import utils from './deps/utils'
import utils from './deps/utils.js' import { generateSaveWalletData } from './storeWallet'
import publicKeyToAddress from './wallet/publicKeyToAddress'
import {generateSaveWalletData} from './storeWallet.js'
import publicKeyToAddress from './wallet/publicKeyToAddress.js'
import AltcoinHDWallet from "./bitcoin/AltcoinHDWallet" import AltcoinHDWallet from "./bitcoin/AltcoinHDWallet"
export default class PhraseWallet { export default class PhraseWallet {

View File

@ -1,5 +1,5 @@
export { request } from './fetch-request.js' export { request } from './fetch-request'
export { transactionTypes as transactions } from './transactions/transactions.js' export { transactionTypes as transactions } from './transactions/transactions'
export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction, signArbitraryWithFeeTransaction } from './createTransaction.js' export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction, signArbitraryWithFeeTransaction } from './createTransaction'
export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest.js' export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest'
export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers.js' export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers'

View File

@ -1,10 +1,9 @@
'use strict'; import Base58 from '../deps/Base58'
import Base58 from '../deps/Base58.js' import { Sha256, Sha512 } from 'asmcrypto.js'
import {Sha256, Sha512} from 'asmcrypto.js'
import jsSHA from 'jssha' import jsSHA from 'jssha'
import RIPEMD160 from '../deps/ripemd160.js' import RIPEMD160 from '../deps/ripemd160'
import utils from '../deps/utils.js' import utils from '../deps/utils'
import {BigInteger, EllipticCurve} from './ecbn.js' import { BigInteger, EllipticCurve } from './ecbn'
export default class AltcoinHDWallet { export default class AltcoinHDWallet {
@ -246,12 +245,11 @@ export default class AltcoinHDWallet {
if (isBIP44) { if (isBIP44) {
buffer = utils.appendBuffer(seed.reverse(), utils.int32ToBytes(indicator)) buffer = utils.appendBuffer(seed.reverse(), utils.int32ToBytes(indicator))
} else { } else {
if(indicator !== null) { if (indicator !== null) {
const indicatorString = utils.stringtoUTF8Array(indicator) const indicatorString = utils.stringtoUTF8Array(indicator)
buffer = utils.appendBuffer(seed.reverse(), indicatorString) buffer = utils.appendBuffer(seed.reverse(), indicatorString)
} }
else else {
{
buffer = seed.reverse() buffer = seed.reverse()
} }
} }
@ -335,8 +333,8 @@ export default class AltcoinHDWallet {
s.push(0) s.push(0)
//if the private key length is less than 32 let's add leading zeros //if the private key length is less than 32 let's add leading zeros
if(this.privateKey.length<32){ if (this.privateKey.length < 32) {
for(let i=this.privateKey.length;i<32;i++){ for (let i = this.privateKey.length; i < 32; i++) {
s.push(0) s.push(0)
} }
} }
@ -506,7 +504,6 @@ export default class AltcoinHDWallet {
const childPublicKeySHA256 = new Sha256().process(new Uint8Array(this.childPublicKey)).finish().result const childPublicKeySHA256 = new Sha256().process(new Uint8Array(this.childPublicKey)).finish().result
this.childPublicKeyHash = new RIPEMD160().update(Buffer.from(childPublicKeySHA256)).digest('hex') this.childPublicKeyHash = new RIPEMD160().update(Buffer.from(childPublicKeySHA256)).digest('hex')
// Call deriveExtendedPublicChildKey // WIll be hardcoding the values... // Call deriveExtendedPublicChildKey // WIll be hardcoding the values...
deriveExtendedPublicChildKey(1, 0) deriveExtendedPublicChildKey(1, 0)
} }
@ -524,15 +521,12 @@ export default class AltcoinHDWallet {
const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.chainCode, format: "UINT8ARRAY" } }) const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.chainCode, format: "UINT8ARRAY" } })
_hmacSha512.update(new Uint8Array(s)) _hmacSha512.update(new Uint8Array(s))
const IL = BigInteger.fromByteArrayUnsigned([..._hmacSha512.getHMAC('UINT8ARRAY').slice(0, 32)]) const IL = BigInteger.fromByteArrayUnsigned([..._hmacSha512.getHMAC('UINT8ARRAY').slice(0, 32)])
this.childChainCode = _hmacSha512.getHMAC('UINT8ARRAY').slice(32, 64) // IR according to the SPEC this.childChainCode = _hmacSha512.getHMAC('UINT8ARRAY').slice(32, 64) // IR according to the SPEC
// SECP256k1 init // SECP256k1 init
const epCurve = EllipticCurve.getSECCurveByName("secp256k1") const epCurve = EllipticCurve.getSECCurveByName("secp256k1")
const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.privateKey)).mod(epCurve.getN()) // parse256(IL) + kpar (mod n) ==> ki const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.privateKey)).mod(epCurve.getN()) // parse256(IL) + kpar (mod n) ==> ki
this.childPrivateKey = ki.toByteArrayUnsigned() this.childPrivateKey = ki.toByteArrayUnsigned()
@ -653,7 +647,6 @@ export default class AltcoinHDWallet {
this.grandChildPublicKey.unshift(0x03) // append point indicator this.grandChildPublicKey.unshift(0x03) // append point indicator
} }
// PublicKey Hash // PublicKey Hash
const grandChildPublicKeySHA256 = new Sha256().process(new Uint8Array(this.grandChildPublicKey)).finish().result const grandChildPublicKeySHA256 = new Sha256().process(new Uint8Array(this.grandChildPublicKey)).finish().result
this.grandChildPublicKeyHash = new RIPEMD160().update(Buffer.from(grandChildPublicKeySHA256)).digest('hex') this.grandChildPublicKeyHash = new RIPEMD160().update(Buffer.from(grandChildPublicKeySHA256)).digest('hex')
@ -734,7 +727,6 @@ export default class AltcoinHDWallet {
deriveExtendedPrivateGrandChildKey(2, 0) deriveExtendedPrivateGrandChildKey(2, 0)
} }
const deriveExtendedPrivateGrandChildKey = (i, childIndex) => { const deriveExtendedPrivateGrandChildKey = (i, childIndex) => {
// Serialization Variable // Serialization Variable
@ -816,8 +808,6 @@ export default class AltcoinHDWallet {
this.xPublicGrandChildKey = Base58.encode(s) this.xPublicGrandChildKey = Base58.encode(s)
} }
// Hard Code value.. // Hard Code value..
let childIndex = 0 let childIndex = 0
@ -845,10 +835,6 @@ export default class AltcoinHDWallet {
_tDerivedMasterPrivateKey: this._tMasterPrivateKey, _tDerivedMasterPrivateKey: this._tMasterPrivateKey,
_tDerivedmasterPublicKey: this._tmasterPublicKey, _tDerivedmasterPublicKey: this._tmasterPublicKey,
seed58: this.seed58, seed58: this.seed58,
// derivedPrivateChildKey: this.xPrivateChildKey,
// derivedPublicChildKey: this.xPublicChildKey,
// derivedPrivateGrandChildKey: this.xPrivateGrandChildKey,
// derivedPublicGrandChildKey: this.xPublicGrandChildKey,
address: this.litecoinLegacyAddress, address: this.litecoinLegacyAddress,
_taddress: this._tlitecoinLegacyAddress _taddress: this._tlitecoinLegacyAddress
} }

View File

@ -6,8 +6,6 @@
*/ */
(function () { (function () {
// Copyright (c) 2005 Tom Wu // Copyright (c) 2005 Tom Wu
// All Rights Reserved. // All Rights Reserved.
// See "LICENSE" for details. // See "LICENSE" for details.
@ -1862,8 +1860,6 @@
} }
rng_pptr = 0; rng_pptr = 0;
rng_seed_time(); rng_seed_time();
//rng_seed_int(window.screenX);
//rng_seed_int(window.screenY);
} }
function rng_get_byte() { function rng_get_byte() {
@ -1874,7 +1870,6 @@
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
rng_pool[rng_pptr] = 0; rng_pool[rng_pptr] = 0;
rng_pptr = 0; rng_pptr = 0;
//rng_pool = null;
} }
// TODO: allow reseeding after first request // TODO: allow reseeding after first request
return rng_state.next(); return rng_state.next();
@ -1890,7 +1885,6 @@
SecureRandom.prototype.nextBytes = rng_get_bytes; SecureRandom.prototype.nextBytes = rng_get_bytes;
// prng4.js - uses Arcfour as a PRNG // prng4.js - uses Arcfour as a PRNG
function Arcfour() { function Arcfour() {
this.i = 0; this.i = 0;
this.j = 0; this.j = 0;
@ -1934,9 +1928,6 @@
// An array of bytes the size of the pool will be passed to init() // An array of bytes the size of the pool will be passed to init()
var rng_psize = 256; var rng_psize = 256;
/*! /*!
* Basic Javascript Elliptic Curve implementation * Basic Javascript Elliptic Curve implementation
* Ported loosely from BouncyCastle's Java EC code * Ported loosely from BouncyCastle's Java EC code
@ -1949,7 +1940,6 @@
// Constructor function of Global EllipticCurve object // Constructor function of Global EllipticCurve object
var ec = function () { }; var ec = function () { };
// ---------------- // ----------------
// ECFieldElementFp constructor // ECFieldElementFp constructor
// q instanceof BigInteger // q instanceof BigInteger
@ -2391,7 +2381,6 @@
return R; return R;
}; };
ec.PointFp.prototype.isOnCurve = function () { ec.PointFp.prototype.isOnCurve = function () {
var x = this.getX().toBigInteger(); var x = this.getX().toBigInteger();
var y = this.getY().toBigInteger(); var y = this.getY().toBigInteger();
@ -2444,9 +2433,6 @@
return true; return true;
}; };
// ---------------- // ----------------
// ECCurveFp constructor // ECCurveFp constructor
ec.CurveFp = function (q, a, b) { ec.CurveFp = function (q, a, b) {

View File

@ -1853,8 +1853,6 @@
} }
rng_pptr = 0; rng_pptr = 0;
rng_seed_time(); rng_seed_time();
//rng_seed_int(window.screenX);
//rng_seed_int(window.screenY);
} }
function rng_get_byte() { function rng_get_byte() {
@ -1865,7 +1863,6 @@
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
rng_pool[rng_pptr] = 0; rng_pool[rng_pptr] = 0;
rng_pptr = 0; rng_pptr = 0;
//rng_pool = null;
} }
// TODO: allow reseeding after first request // TODO: allow reseeding after first request
return rng_state.next(); return rng_state.next();

View File

@ -1,5 +1,3 @@
'use strict'
// Qortal TX types // Qortal TX types
const TX_TYPES = { const TX_TYPES = {
1: "Genesis", 1: "Genesis",

View File

@ -1,9 +1,9 @@
import {transactionTypes as transactions} from './transactions/transactions.js' import { transactionTypes as transactions } from './transactions/transactions'
import Base58 from './deps/Base58.js' import Base58 from './deps/Base58'
import {request} from './fetch-request' import { request } from './fetch-request'
import signChat from './transactions/chat/signChat.js' import signChat from './transactions/chat/signChat'
import signArbitrary from './transactions/arbitrary/signArbitrary.js' import signArbitrary from './transactions/arbitrary/signArbitrary'
import signArbitraryWithFee from './transactions/arbitrary/signArbitraryWithFee.js' import signArbitraryWithFee from './transactions/arbitrary/signArbitraryWithFee'
export const createTransaction = (type, keyPair, params) => { export const createTransaction = (type, keyPair, params) => {
const tx = new transactions[type]() const tx = new transactions[type]()

View File

@ -1,7 +1,7 @@
import {kdf} from './kdf.js' import { kdf } from './kdf'
import PhraseWallet from './PhraseWallet.js' import PhraseWallet from './PhraseWallet'
import Base58 from './deps/Base58.js' import Base58 from './deps/Base58'
import {decryptStoredWallet} from './decryptStoredWallet.js' import { decryptStoredWallet } from './decryptStoredWallet'
export const createWallet = async (sourceType, source, statusUpdateFn) => { export const createWallet = async (sourceType, source, statusUpdateFn) => {
let version, seed let version, seed

View File

@ -1,7 +1,7 @@
import Base58 from './deps/Base58.js' import Base58 from './deps/Base58'
import {kdf} from './kdf.js' import { kdf } from './kdf'
import {AES_CBC, HmacSha512} from 'asmcrypto.js' import { AES_CBC, HmacSha512 } from 'asmcrypto.js'
import {get, registerTranslateConfig} from '../../core/translate' import { get, registerTranslateConfig } from '../../core/translate'
registerTranslateConfig({ registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json()) loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())

View File

@ -1,10 +1,6 @@
// Generated by CoffeeScript 1.8.0 // Generated by CoffeeScript 1.8.0
// == Changed for ES6 modules == // // == Changed for ES6 modules == //
//(function() {
//var ALPHABET, ALPHABET_MAP, Base58, i;
//const Base58 = (typeof module !== "undefined" && module !== null ? module.exports : void 0) || (window.Base58 = {});
const Base58 = {}; const Base58 = {};
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@ -14,21 +10,21 @@ const ALPHABET_MAP = {};
let i = 0; let i = 0;
while (i < ALPHABET.length) { while (i < ALPHABET.length) {
ALPHABET_MAP[ALPHABET.charAt(i)] = i; ALPHABET_MAP[ALPHABET.charAt(i)] = i;
i++; i++;
} }
Base58.encode = function(buffer) { Base58.encode = function (buffer) {
buffer = new Uint8Array(buffer); buffer = new Uint8Array(buffer);
var carry, digits, j; var carry, digits, j;
if (buffer.length === 0) { if (buffer.length === 0) {
return ""; return "";
} }
i = void 0; i = void 0;
j = void 0; j = void 0;
digits = [0]; digits = [0];
i = 0; i = 0;
while (i < buffer.length) { while (i < buffer.length) {
j = 0; j = 0;
while (j < digits.length) { while (j < digits.length) {
digits[j] <<= 8; digits[j] <<= 8;
@ -48,27 +44,27 @@ while (i < buffer.length) {
carry = (carry / 58) | 0; carry = (carry / 58) | 0;
} }
i++; i++;
} }
i = 0; i = 0;
while (buffer[i] === 0 && i < buffer.length - 1) { while (buffer[i] === 0 && i < buffer.length - 1) {
digits.push(0); digits.push(0);
i++; i++;
} }
return digits.reverse().map(function(digit) { return digits.reverse().map(function (digit) {
return ALPHABET[digit]; return ALPHABET[digit];
}).join(""); }).join("");
}; };
Base58.decode = function(string) { Base58.decode = function (string) {
var bytes, c, carry, j; var bytes, c, carry, j;
if (string.length === 0) { if (string.length === 0) {
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0); return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0);
} }
i = void 0; i = void 0;
j = void 0; j = void 0;
bytes = [0]; bytes = [0];
i = 0; i = 0;
while (i < string.length) { while (i < string.length) {
c = string[i]; c = string[i];
if (!(c in ALPHABET_MAP)) { if (!(c in ALPHABET_MAP)) {
throw "Base58.decode received unacceptable input. Character '" + c + "' is not in the Base58 alphabet."; throw "Base58.decode received unacceptable input. Character '" + c + "' is not in the Base58 alphabet.";
@ -92,17 +88,14 @@ while (i < string.length) {
carry >>= 8; carry >>= 8;
} }
i++; i++;
} }
i = 0; i = 0;
while (string[i] === "1" && i < string.length - 1) { while (string[i] === "1" && i < string.length - 1) {
bytes.push(0); bytes.push(0);
i++; i++;
} }
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(bytes.reverse()); return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(bytes.reverse());
}; };
// == Changed for ES6 modules == // // == Changed for ES6 modules == //
//}).call(this);
export default Base58; export default Base58;

View File

@ -1,8 +1,6 @@
const Base64 = {}; const Base64 = {};
Base64.decode = function (string) { Base64.decode = function (string) {
const binaryString = atob(string); const binaryString = atob(string);
@ -17,7 +15,4 @@ Base64.decode = function (string) {
return decoder.decode(bytes); return decoder.decode(bytes);
}; };
export default Base64; export default Base64;

View File

@ -31,7 +31,7 @@
* Released under the Apache License, Version 2.0 * Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/bcrypt.js for details * see: https://github.com/dcodeIO/bcrypt.js for details
*/ */
(function(global, factory) { (function (global, factory) {
/* AMD */ if (typeof define === 'function' && define["amd"]) /* AMD */ if (typeof define === 'function' && define["amd"])
define([], factory); define([], factory);
@ -40,8 +40,9 @@
/* Global */ else /* Global */ else
(global["dcodeIO"] = global["dcodeIO"] || {})["bcrypt"] = factory(); (global["dcodeIO"] = global["dcodeIO"] || {})["bcrypt"] = factory();
}(this, function() { }(this, function () {
"use strict"; // == Changed for ESM support == //
// "use strict";
/** /**
* bcrypt namespace. * bcrypt namespace.
@ -68,11 +69,11 @@
/* node */ if (typeof module !== 'undefined' && module && module['exports']) /* node */ if (typeof module !== 'undefined' && module && module['exports'])
try { try {
return require("crypto")['randomBytes'](len); return require("crypto")['randomBytes'](len);
} catch (e) {} } catch (e) { }
/* WCA */ try { /* WCA */ try {
var a; (self['crypto']||self['msCrypto'])['getRandomValues'](a = new Uint32Array(len)); var a; (self['crypto'] || self['msCrypto'])['getRandomValues'](a = new Uint32Array(len));
return Array.prototype.slice.call(a); return Array.prototype.slice.call(a);
} catch (e) {} } catch (e) { }
/* fallback */ if (!randomFallback) /* fallback */ if (!randomFallback)
throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative"); throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");
return randomFallback(len); return randomFallback(len);
@ -83,7 +84,7 @@
try { try {
random(1); random(1);
randomAvailable = true; randomAvailable = true;
} catch (e) {} } catch (e) { }
// Default fallback, if any // Default fallback, if any
randomFallback = null; randomFallback = null;
@ -96,7 +97,7 @@
* @see http://nodejs.org/api/crypto.html * @see http://nodejs.org/api/crypto.html
* @see http://www.w3.org/TR/WebCryptoAPI/ * @see http://www.w3.org/TR/WebCryptoAPI/
*/ */
bcrypt.setRandomFallback = function(random) { bcrypt.setRandomFallback = function (random) {
randomFallback = random; randomFallback = random;
}; };
@ -108,10 +109,10 @@
* @throws {Error} If a random fallback is required but not set * @throws {Error} If a random fallback is required but not set
* @expose * @expose
*/ */
bcrypt.genSaltSync = function(rounds, seed_length) { bcrypt.genSaltSync = function (rounds, seed_length) {
rounds = rounds || GENSALT_DEFAULT_LOG2_ROUNDS; rounds = rounds || GENSALT_DEFAULT_LOG2_ROUNDS;
if (typeof rounds !== 'number') if (typeof rounds !== 'number')
throw Error("Illegal arguments: "+(typeof rounds)+", "+(typeof seed_length)); throw Error("Illegal arguments: " + (typeof rounds) + ", " + (typeof seed_length));
if (rounds < 4) if (rounds < 4)
rounds = 4; rounds = 4;
else if (rounds > 31) else if (rounds > 31)
@ -135,7 +136,7 @@
* @throws {Error} If `callback` is present but not a function * @throws {Error} If `callback` is present but not a function
* @expose * @expose
*/ */
bcrypt.genSalt = function(rounds, seed_length, callback) { bcrypt.genSalt = function (rounds, seed_length, callback) {
if (typeof seed_length === 'function') if (typeof seed_length === 'function')
callback = seed_length, callback = seed_length,
seed_length = undefined; // Not supported. seed_length = undefined; // Not supported.
@ -145,10 +146,10 @@
if (typeof rounds === 'undefined') if (typeof rounds === 'undefined')
rounds = GENSALT_DEFAULT_LOG2_ROUNDS; rounds = GENSALT_DEFAULT_LOG2_ROUNDS;
else if (typeof rounds !== 'number') else if (typeof rounds !== 'number')
throw Error("illegal arguments: "+(typeof rounds)); throw Error("illegal arguments: " + (typeof rounds));
function _async(callback) { function _async(callback) {
nextTick(function() { // Pretty thin, but salting is fast enough nextTick(function () { // Pretty thin, but salting is fast enough
try { try {
callback(null, bcrypt.genSaltSync(rounds)); callback(null, bcrypt.genSaltSync(rounds));
} catch (err) { } catch (err) {
@ -159,11 +160,11 @@
if (callback) { if (callback) {
if (typeof callback !== 'function') if (typeof callback !== 'function')
throw Error("Illegal callback: "+typeof(callback)); throw Error("Illegal callback: " + typeof (callback));
_async(callback); _async(callback);
} else } else
return new Promise(function(resolve, reject) { return new Promise(function (resolve, reject) {
_async(function(err, res) { _async(function (err, res) {
if (err) { if (err) {
reject(err); reject(err);
return; return;
@ -180,13 +181,13 @@
* @returns {string} Resulting hash * @returns {string} Resulting hash
* @expose * @expose
*/ */
bcrypt.hashSync = function(s, salt) { bcrypt.hashSync = function (s, salt) {
if (typeof salt === 'undefined') if (typeof salt === 'undefined')
salt = GENSALT_DEFAULT_LOG2_ROUNDS; salt = GENSALT_DEFAULT_LOG2_ROUNDS;
if (typeof salt === 'number') if (typeof salt === 'number')
salt = bcrypt.genSaltSync(salt); salt = bcrypt.genSaltSync(salt);
if (typeof s !== 'string' || typeof salt !== 'string') if (typeof s !== 'string' || typeof salt !== 'string')
throw Error("Illegal arguments: "+(typeof s)+', '+(typeof salt)); throw Error("Illegal arguments: " + (typeof s) + ', ' + (typeof salt));
return _hash(s, salt); return _hash(s, salt);
}; };
@ -201,26 +202,26 @@
* @throws {Error} If `callback` is present but not a function * @throws {Error} If `callback` is present but not a function
* @expose * @expose
*/ */
bcrypt.hash = function(s, salt, callback, progressCallback) { bcrypt.hash = function (s, salt, callback, progressCallback) {
function _async(callback) { function _async(callback) {
if (typeof s === 'string' && typeof salt === 'number') if (typeof s === 'string' && typeof salt === 'number')
bcrypt.genSalt(salt, function(err, salt) { bcrypt.genSalt(salt, function (err, salt) {
_hash(s, salt, callback, progressCallback); _hash(s, salt, callback, progressCallback);
}); });
else if (typeof s === 'string' && typeof salt === 'string') else if (typeof s === 'string' && typeof salt === 'string')
_hash(s, salt, callback, progressCallback); _hash(s, salt, callback, progressCallback);
else else
nextTick(callback.bind(this, Error("Illegal arguments: "+(typeof s)+', '+(typeof salt)))); nextTick(callback.bind(this, Error("Illegal arguments: " + (typeof s) + ', ' + (typeof salt))));
} }
if (callback) { if (callback) {
if (typeof callback !== 'function') if (typeof callback !== 'function')
throw Error("Illegal callback: "+typeof(callback)); throw Error("Illegal callback: " + typeof (callback));
_async(callback); _async(callback);
} else } else
return new Promise(function(resolve, reject) { return new Promise(function (resolve, reject) {
_async(function(err, res) { _async(function (err, res) {
if (err) { if (err) {
reject(err); reject(err);
return; return;
@ -240,7 +241,7 @@
function safeStringCompare(known, unknown) { function safeStringCompare(known, unknown) {
var right = 0, var right = 0,
wrong = 0; wrong = 0;
for (var i=0, k=known.length; i<k; ++i) { for (var i = 0, k = known.length; i < k; ++i) {
if (known.charCodeAt(i) === unknown.charCodeAt(i)) if (known.charCodeAt(i) === unknown.charCodeAt(i))
++right; ++right;
else else
@ -260,12 +261,12 @@
* @throws {Error} If an argument is illegal * @throws {Error} If an argument is illegal
* @expose * @expose
*/ */
bcrypt.compareSync = function(s, hash) { bcrypt.compareSync = function (s, hash) {
if (typeof s !== "string" || typeof hash !== "string") if (typeof s !== "string" || typeof hash !== "string")
throw Error("Illegal arguments: "+(typeof s)+', '+(typeof hash)); throw Error("Illegal arguments: " + (typeof s) + ', ' + (typeof hash));
if (hash.length !== 60) if (hash.length !== 60)
return false; return false;
return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length-31)), hash); return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length - 31)), hash);
}; };
/** /**
@ -279,18 +280,18 @@
* @throws {Error} If `callback` is present but not a function * @throws {Error} If `callback` is present but not a function
* @expose * @expose
*/ */
bcrypt.compare = function(s, hash, callback, progressCallback) { bcrypt.compare = function (s, hash, callback, progressCallback) {
function _async(callback) { function _async(callback) {
if (typeof s !== "string" || typeof hash !== "string") { if (typeof s !== "string" || typeof hash !== "string") {
nextTick(callback.bind(this, Error("Illegal arguments: "+(typeof s)+', '+(typeof hash)))); nextTick(callback.bind(this, Error("Illegal arguments: " + (typeof s) + ', ' + (typeof hash))));
return; return;
} }
if (hash.length !== 60) { if (hash.length !== 60) {
nextTick(callback.bind(this, null, false)); nextTick(callback.bind(this, null, false));
return; return;
} }
bcrypt.hash(s, hash.substr(0, 29), function(err, comp) { bcrypt.hash(s, hash.substr(0, 29), function (err, comp) {
if (err) if (err)
callback(err); callback(err);
else else
@ -300,11 +301,11 @@
if (callback) { if (callback) {
if (typeof callback !== 'function') if (typeof callback !== 'function')
throw Error("Illegal callback: "+typeof(callback)); throw Error("Illegal callback: " + typeof (callback));
_async(callback); _async(callback);
} else } else
return new Promise(function(resolve, reject) { return new Promise(function (resolve, reject) {
_async(function(err, res) { _async(function (err, res) {
if (err) { if (err) {
reject(err); reject(err);
return; return;
@ -321,9 +322,9 @@
* @throws {Error} If `hash` is not a string * @throws {Error} If `hash` is not a string
* @expose * @expose
*/ */
bcrypt.getRounds = function(hash) { bcrypt.getRounds = function (hash) {
if (typeof hash !== "string") if (typeof hash !== "string")
throw Error("Illegal arguments: "+(typeof hash)); throw Error("Illegal arguments: " + (typeof hash));
return parseInt(hash.split("$")[2], 10); return parseInt(hash.split("$")[2], 10);
}; };
@ -334,11 +335,11 @@
* @throws {Error} If `hash` is not a string or otherwise invalid * @throws {Error} If `hash` is not a string or otherwise invalid
* @expose * @expose
*/ */
bcrypt.getSalt = function(hash) { bcrypt.getSalt = function (hash) {
if (typeof hash !== 'string') if (typeof hash !== 'string')
throw Error("Illegal arguments: "+(typeof hash)); throw Error("Illegal arguments: " + (typeof hash));
if (hash.length !== 60) if (hash.length !== 60)
throw Error("Illegal hash length: "+hash.length+" != 60"); throw Error("Illegal hash length: " + hash.length + " != 60");
return hash.substring(0, 29); return hash.substring(0, 29);
}; };
@ -361,10 +362,10 @@
function stringToBytes(str) { function stringToBytes(str) {
var out = [], var out = [],
i = 0; i = 0;
utfx.encodeUTF16toUTF8(function() { utfx.encodeUTF16toUTF8(function () {
if (i >= str.length) return null; if (i >= str.length) return null;
return str.charCodeAt(i++); return str.charCodeAt(i++);
}, function(b) { }, function (b) {
out.push(b); out.push(b);
}); });
return out; return out;
@ -412,7 +413,7 @@
rs = [], rs = [],
c1, c2; c1, c2;
if (len <= 0 || len > b.length) if (len <= 0 || len > b.length)
throw Error("Illegal len: "+len); throw Error("Illegal len: " + len);
while (off < len) { while (off < len) {
c1 = b[off++] & 0xff; c1 = b[off++] & 0xff;
rs.push(BASE64_CODE[(c1 >> 2) & 0x3f]); rs.push(BASE64_CODE[(c1 >> 2) & 0x3f]);
@ -451,7 +452,7 @@
rs = [], rs = [],
c1, c2, c3, c4, o, code; c1, c2, c3, c4, o, code;
if (len <= 0) if (len <= 0)
throw Error("Illegal len: "+len); throw Error("Illegal len: " + len);
while (off < slen - 1 && olen < len) { while (off < slen - 1 && olen < len) {
code = s.charCodeAt(off++); code = s.charCodeAt(off++);
c1 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1; c1 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
@ -481,7 +482,7 @@
++olen; ++olen;
} }
var res = []; var res = [];
for (off = 0; off<olen; off++) for (off = 0; off < olen; off++)
res.push(rs[off].charCodeAt(0)); res.push(rs[off].charCodeAt(0));
return res; return res;
} }
@ -491,8 +492,9 @@
* Released under the Apache License, Version 2.0 * Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/utfx for details * see: https://github.com/dcodeIO/utfx for details
*/ */
var utfx = function() { var utfx = function () {
"use strict"; // == Changed for ESM support == //
// "use strict";
/** /**
* utfx namespace. * utfx namespace.
@ -514,26 +516,26 @@
* respectively `null` if there are no more code points left or a single numeric code point. * respectively `null` if there are no more code points left or a single numeric code point.
* @param {!function(number)} dst Bytes destination as a function successively called with the next byte * @param {!function(number)} dst Bytes destination as a function successively called with the next byte
*/ */
utfx.encodeUTF8 = function(src, dst) { utfx.encodeUTF8 = function (src, dst) {
var cp = null; var cp = null;
if (typeof src === 'number') if (typeof src === 'number')
cp = src, cp = src,
src = function() { return null; }; src = function () { return null; };
while (cp !== null || (cp = src()) !== null) { while (cp !== null || (cp = src()) !== null) {
if (cp < 0x80) if (cp < 0x80)
dst(cp&0x7F); dst(cp & 0x7F);
else if (cp < 0x800) else if (cp < 0x800)
dst(((cp>>6)&0x1F)|0xC0), dst(((cp >> 6) & 0x1F) | 0xC0),
dst((cp&0x3F)|0x80); dst((cp & 0x3F) | 0x80);
else if (cp < 0x10000) else if (cp < 0x10000)
dst(((cp>>12)&0x0F)|0xE0), dst(((cp >> 12) & 0x0F) | 0xE0),
dst(((cp>>6)&0x3F)|0x80), dst(((cp >> 6) & 0x3F) | 0x80),
dst((cp&0x3F)|0x80); dst((cp & 0x3F) | 0x80);
else else
dst(((cp>>18)&0x07)|0xF0), dst(((cp >> 18) & 0x07) | 0xF0),
dst(((cp>>12)&0x3F)|0x80), dst(((cp >> 12) & 0x3F) | 0x80),
dst(((cp>>6)&0x3F)|0x80), dst(((cp >> 6) & 0x3F) | 0x80),
dst((cp&0x3F)|0x80); dst((cp & 0x3F) | 0x80);
cp = null; cp = null;
} }
}; };
@ -547,8 +549,8 @@
* @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the * @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the
* remaining bytes. * remaining bytes.
*/ */
utfx.decodeUTF8 = function(src, dst) { utfx.decodeUTF8 = function (src, dst) {
var a, b, c, d, fail = function(b) { var a, b, c, d, fail = function (b) {
b = b.slice(0, b.indexOf(null)); b = b.slice(0, b.indexOf(null));
var err = Error(b.toString()); var err = Error(b.toString());
err.name = "TruncatedError"; err.name = "TruncatedError";
@ -556,18 +558,18 @@
throw err; throw err;
}; };
while ((a = src()) !== null) { while ((a = src()) !== null) {
if ((a&0x80) === 0) if ((a & 0x80) === 0)
dst(a); dst(a);
else if ((a&0xE0) === 0xC0) else if ((a & 0xE0) === 0xC0)
((b = src()) === null) && fail([a, b]), ((b = src()) === null) && fail([a, b]),
dst(((a&0x1F)<<6) | (b&0x3F)); dst(((a & 0x1F) << 6) | (b & 0x3F));
else if ((a&0xF0) === 0xE0) else if ((a & 0xF0) === 0xE0)
((b=src()) === null || (c=src()) === null) && fail([a, b, c]), ((b = src()) === null || (c = src()) === null) && fail([a, b, c]),
dst(((a&0x0F)<<12) | ((b&0x3F)<<6) | (c&0x3F)); dst(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F));
else if ((a&0xF8) === 0xF0) else if ((a & 0xF8) === 0xF0)
((b=src()) === null || (c=src()) === null || (d=src()) === null) && fail([a, b, c ,d]), ((b = src()) === null || (c = src()) === null || (d = src()) === null) && fail([a, b, c, d]),
dst(((a&0x07)<<18) | ((b&0x3F)<<12) | ((c&0x3F)<<6) | (d&0x3F)); dst(((a & 0x07) << 18) | ((b & 0x3F) << 12) | ((c & 0x3F) << 6) | (d & 0x3F));
else throw RangeError("Illegal starting byte: "+a); else throw RangeError("Illegal starting byte: " + a);
} }
}; };
@ -578,7 +580,7 @@
* @param {!function(number)} dst Code points destination as a function successively called with each converted code * @param {!function(number)} dst Code points destination as a function successively called with each converted code
* point. * point.
*/ */
utfx.UTF16toUTF8 = function(src, dst) { utfx.UTF16toUTF8 = function (src, dst) {
var c1, c2 = null; var c1, c2 = null;
while (true) { while (true) {
if ((c1 = c2 !== null ? c2 : src()) === null) if ((c1 = c2 !== null ? c2 : src()) === null)
@ -586,7 +588,7 @@
if (c1 >= 0xD800 && c1 <= 0xDFFF) { if (c1 >= 0xD800 && c1 <= 0xDFFF) {
if ((c2 = src()) !== null) { if ((c2 = src()) !== null) {
if (c2 >= 0xDC00 && c2 <= 0xDFFF) { if (c2 >= 0xDC00 && c2 <= 0xDFFF) {
dst((c1-0xD800)*0x400+c2-0xDC00+0x10000); dst((c1 - 0xD800) * 0x400 + c2 - 0xDC00 + 0x10000);
c2 = null; continue; c2 = null; continue;
} }
} }
@ -603,17 +605,17 @@
* @param {!function(number)} dst Characters destination as a function successively called with each converted char code. * @param {!function(number)} dst Characters destination as a function successively called with each converted char code.
* @throws {RangeError} If a code point is out of range * @throws {RangeError} If a code point is out of range
*/ */
utfx.UTF8toUTF16 = function(src, dst) { utfx.UTF8toUTF16 = function (src, dst) {
var cp = null; var cp = null;
if (typeof src === 'number') if (typeof src === 'number')
cp = src, src = function() { return null; }; cp = src, src = function () { return null; };
while (cp !== null || (cp = src()) !== null) { while (cp !== null || (cp = src()) !== null) {
if (cp <= 0xFFFF) if (cp <= 0xFFFF)
dst(cp); dst(cp);
else else
cp -= 0x10000, cp -= 0x10000,
dst((cp>>10)+0xD800), dst((cp >> 10) + 0xD800),
dst((cp%0x400)+0xDC00); dst((cp % 0x400) + 0xDC00);
cp = null; cp = null;
} }
}; };
@ -624,8 +626,8 @@
* if there are no more characters left. * if there are no more characters left.
* @param {!function(number)} dst Bytes destination as a function successively called with the next byte. * @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
*/ */
utfx.encodeUTF16toUTF8 = function(src, dst) { utfx.encodeUTF16toUTF8 = function (src, dst) {
utfx.UTF16toUTF8(src, function(cp) { utfx.UTF16toUTF8(src, function (cp) {
utfx.encodeUTF8(cp, dst); utfx.encodeUTF8(cp, dst);
}); });
}; };
@ -638,8 +640,8 @@
* @throws {RangeError} If a starting byte is invalid in UTF8 * @throws {RangeError} If a starting byte is invalid in UTF8
* @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the remaining bytes. * @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the remaining bytes.
*/ */
utfx.decodeUTF8toUTF16 = function(src, dst) { utfx.decodeUTF8toUTF16 = function (src, dst) {
utfx.decodeUTF8(src, function(cp) { utfx.decodeUTF8(src, function (cp) {
utfx.UTF8toUTF16(cp, dst); utfx.UTF8toUTF16(cp, dst);
}); });
}; };
@ -649,7 +651,7 @@
* @param {number} cp UTF8 code point * @param {number} cp UTF8 code point
* @returns {number} Byte length * @returns {number} Byte length
*/ */
utfx.calculateCodePoint = function(cp) { utfx.calculateCodePoint = function (cp) {
return (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4; return (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4;
}; };
@ -659,8 +661,8 @@
* `null` if there are no more code points left. * `null` if there are no more code points left.
* @returns {number} The number of UTF8 bytes required * @returns {number} The number of UTF8 bytes required
*/ */
utfx.calculateUTF8 = function(src) { utfx.calculateUTF8 = function (src) {
var cp, l=0; var cp, l = 0;
while ((cp = src()) !== null) while ((cp = src()) !== null)
l += utfx.calculateCodePoint(cp); l += utfx.calculateCodePoint(cp);
return l; return l;
@ -672,18 +674,18 @@
* `null` if there are no more characters left. * `null` if there are no more characters left.
* @returns {!Array.<number>} The number of UTF8 code points at index 0 and the number of UTF8 bytes required at index 1. * @returns {!Array.<number>} The number of UTF8 code points at index 0 and the number of UTF8 bytes required at index 1.
*/ */
utfx.calculateUTF16asUTF8 = function(src) { utfx.calculateUTF16asUTF8 = function (src) {
var n=0, l=0; var n = 0, l = 0;
utfx.UTF16toUTF8(src, function(cp) { utfx.UTF16toUTF8(src, function (cp) {
++n; l += utfx.calculateCodePoint(cp); ++n; l += utfx.calculateCodePoint(cp);
}); });
return [n,l]; return [n, l];
}; };
return utfx; return utfx;
}(); }();
Date.now = Date.now || function() { return +new Date; }; Date.now = Date.now || function () { return +new Date; };
/** /**
* @type {number} * @type {number}
@ -1172,7 +1174,7 @@
// Validate // Validate
if (rounds < 4 || rounds > 31) { if (rounds < 4 || rounds > 31) {
err = Error("Illegal number of rounds (4-31): "+rounds); err = Error("Illegal number of rounds (4-31): " + rounds);
if (callback) { if (callback) {
nextTick(callback.bind(this, err)); nextTick(callback.bind(this, err));
return; return;
@ -1180,7 +1182,7 @@
throw err; throw err;
} }
if (salt.length !== BCRYPT_SALT_LEN) { if (salt.length !== BCRYPT_SALT_LEN) {
err =Error("Illegal salt length: "+salt.length+" != "+BCRYPT_SALT_LEN); err = Error("Illegal salt length: " + salt.length + " != " + BCRYPT_SALT_LEN);
if (callback) { if (callback) {
nextTick(callback.bind(this, err)); nextTick(callback.bind(this, err));
return; return;
@ -1247,7 +1249,7 @@
} else { } else {
var res; var res;
while (true) while (true)
if (typeof(res = next()) !== 'undefined') if (typeof (res = next()) !== 'undefined')
return res || []; return res || [];
} }
} }
@ -1277,7 +1279,7 @@
// Validate the salt // Validate the salt
var minor, offset; var minor, offset;
if (salt.charAt(0) !== '$' || salt.charAt(1) !== '2') { if (salt.charAt(0) !== '$' || salt.charAt(1) !== '2') {
err = Error("Invalid salt version: "+salt.substring(0,2)); err = Error("Invalid salt version: " + salt.substring(0, 2));
if (callback) { if (callback) {
nextTick(callback.bind(this, err)); nextTick(callback.bind(this, err));
return; return;
@ -1291,7 +1293,7 @@
else { else {
minor = salt.charAt(2); minor = salt.charAt(2);
if ((minor !== 'a' && minor !== 'b' && minor !== 'y') || salt.charAt(3) !== '$') { if ((minor !== 'a' && minor !== 'b' && minor !== 'y') || salt.charAt(3) !== '$') {
err = Error("Invalid salt revision: "+salt.substring(2,4)); err = Error("Invalid salt revision: " + salt.substring(2, 4));
if (callback) { if (callback) {
nextTick(callback.bind(this, err)); nextTick(callback.bind(this, err));
return; return;
@ -1346,7 +1348,7 @@
// Async // Async
else { else {
_crypt(passwordb, saltb, rounds, function(err, bytes) { _crypt(passwordb, saltb, rounds, function (err, bytes) {
if (err) if (err)
callback(err, null); callback(err, null);
else else

View File

@ -1,6 +1,5 @@
// "Generated from Java with JSweet 1.0.0 - http://www.jsweet.org"; // "Generated from Java with JSweet 1.0.0 - http://www.jsweet.org";
// BAD IMPLEMENTATION. BROKEN, BUT MUST KEEP CAUSE OF NETWORK // BAD IMPLEMENTATION. BROKEN, BUT MUST KEEP CAUSE OF NETWORK
//const RIPEMD160 = (function () {
// == Convert to ES6 module for export == // // == Convert to ES6 module for export == //
const RIPEMD160 = (function () { const RIPEMD160 = (function () {
function RIPEMD160() { function RIPEMD160() {

View File

@ -1,3 +1,2 @@
export { default as Base58 } from './Base58.js' export { default as Base58 } from './Base58'
export { default as utils } from './utils'
export { default as utils } from './utils.js'

View File

@ -10,102 +10,94 @@
Change to es6 import/export Change to es6 import/export
*/ */
import nacl from './nacl-fast.js' import nacl from './nacl-fast'
// (function(root, f) { // -- Operations copied from TweetNaCl.js. --
// 'use strict';
// if (typeof module !== 'undefined' && module.exports) module.exports = f(require('tweetnacl'));
// else root.ed2curve = f(root.nacl);
// }(this, function(nacl) {
// 'use strict';
// if (!nacl) throw new Error('tweetnacl not loaded');
// -- Operations copied from TweetNaCl.js. -- var gf = function (init) {
var gf = function(init) {
var i, r = new Float64Array(16); var i, r = new Float64Array(16);
if (init) for (i = 0; i < init.length; i++) r[i] = init[i]; if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
return r; return r;
}; };
var gf0 = gf(), var gf0 = gf(),
gf1 = gf([1]), gf1 = gf([1]),
D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]), D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]); I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
function car25519(o) { function car25519(o) {
var c; var c;
var i; var i;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
o[i] += 65536; o[i] += 65536;
c = Math.floor(o[i] / 65536); c = Math.floor(o[i] / 65536);
o[(i+1)*(i<15?1:0)] += c - 1 + 37 * (c-1) * (i===15?1:0); o[(i + 1) * (i < 15 ? 1 : 0)] += c - 1 + 37 * (c - 1) * (i === 15 ? 1 : 0);
o[i] -= (c * 65536); o[i] -= (c * 65536);
} }
} }
function sel25519(p, q, b) { function sel25519(p, q, b) {
var t, c = ~(b-1); var t, c = ~(b - 1);
for (var i = 0; i < 16; i++) { for (var i = 0; i < 16; i++) {
t = c & (p[i] ^ q[i]); t = c & (p[i] ^ q[i]);
p[i] ^= t; p[i] ^= t;
q[i] ^= t; q[i] ^= t;
} }
} }
function unpack25519(o, n) { function unpack25519(o, n) {
var i; var i;
for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8); for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
o[15] &= 0x7fff; o[15] &= 0x7fff;
} }
// addition // addition
function A(o, a, b) { function A(o, a, b) {
var i; var i;
for (i = 0; i < 16; i++) o[i] = (a[i] + b[i])|0; for (i = 0; i < 16; i++) o[i] = (a[i] + b[i]) | 0;
} }
// subtraction // subtraction
function Z(o, a, b) { function Z(o, a, b) {
var i; var i;
for (i = 0; i < 16; i++) o[i] = (a[i] - b[i])|0; for (i = 0; i < 16; i++) o[i] = (a[i] - b[i]) | 0;
} }
// multiplication // multiplication
function M(o, a, b) { function M(o, a, b) {
var i, j, t = new Float64Array(31); var i, j, t = new Float64Array(31);
for (i = 0; i < 31; i++) t[i] = 0; for (i = 0; i < 31; i++) t[i] = 0;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
t[i+j] += a[i] * b[j]; t[i + j] += a[i] * b[j];
} }
} }
for (i = 0; i < 15; i++) { for (i = 0; i < 15; i++) {
t[i] += 38 * t[i+16]; t[i] += 38 * t[i + 16];
} }
for (i = 0; i < 16; i++) o[i] = t[i]; for (i = 0; i < 16; i++) o[i] = t[i];
car25519(o); car25519(o);
car25519(o); car25519(o);
} }
// squaring // squaring
function S(o, a) { function S(o, a) {
M(o, a, a); M(o, a, a);
} }
// inversion // inversion
function inv25519(o, i) { function inv25519(o, i) {
var c = gf(); var c = gf();
var a; var a;
for (a = 0; a < 16; a++) c[a] = i[a]; for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 253; a >= 0; a--) { for (a = 253; a >= 0; a--) {
S(c, c); S(c, c);
if(a !== 2 && a !== 4) M(c, c, i); if (a !== 2 && a !== 4) M(c, c, i);
} }
for (a = 0; a < 16; a++) o[a] = c[a]; for (a = 0; a < 16; a++) o[a] = c[a];
} }
function pack25519(o, n) { function pack25519(o, n) {
var i, j, b; var i, j, b;
var m = gf(), t = gf(); var m = gf(), t = gf();
for (i = 0; i < 16; i++) t[i] = n[i]; for (i = 0; i < 16; i++) t[i] = n[i];
@ -115,44 +107,44 @@ import nacl from './nacl-fast.js'
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
m[0] = t[0] - 0xffed; m[0] = t[0] - 0xffed;
for (i = 1; i < 15; i++) { for (i = 1; i < 15; i++) {
m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1); m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1);
m[i-1] &= 0xffff; m[i - 1] &= 0xffff;
} }
m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1); m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1);
b = (m[15]>>16) & 1; b = (m[15] >> 16) & 1;
m[14] &= 0xffff; m[14] &= 0xffff;
sel25519(t, m, 1-b); sel25519(t, m, 1 - b);
} }
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
o[2*i] = t[i] & 0xff; o[2 * i] = t[i] & 0xff;
o[2*i+1] = t[i] >> 8; o[2 * i + 1] = t[i] >> 8;
}
} }
}
function par25519(a) { function par25519(a) {
var d = new Uint8Array(32); var d = new Uint8Array(32);
pack25519(d, a); pack25519(d, a);
return d[0] & 1; return d[0] & 1;
} }
function vn(x, xi, y, yi, n) { function vn(x, xi, y, yi, n) {
var i, d = 0; var i, d = 0;
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i]; for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
return (1 & ((d - 1) >>> 8)) - 1; return (1 & ((d - 1) >>> 8)) - 1;
} }
function crypto_verify_32(x, xi, y, yi) { function crypto_verify_32(x, xi, y, yi) {
return vn(x, xi, y, yi, 32); return vn(x, xi, y, yi, 32);
} }
function neq25519(a, b) { function neq25519(a, b) {
var c = new Uint8Array(32), d = new Uint8Array(32); var c = new Uint8Array(32), d = new Uint8Array(32);
pack25519(c, a); pack25519(c, a);
pack25519(d, b); pack25519(d, b);
return crypto_verify_32(c, 0, d, 0); return crypto_verify_32(c, 0, d, 0);
} }
function pow2523(o, i) { function pow2523(o, i) {
var c = gf(); var c = gf();
var a; var a;
for (a = 0; a < 16; a++) c[a] = i[a]; for (a = 0; a < 16; a++) c[a] = i[a];
@ -161,14 +153,14 @@ import nacl from './nacl-fast.js'
if (a !== 1) M(c, c, i); if (a !== 1) M(c, c, i);
} }
for (a = 0; a < 16; a++) o[a] = c[a]; for (a = 0; a < 16; a++) o[a] = c[a];
} }
function set25519(r, a) { function set25519(r, a) {
var i; var i;
for (i = 0; i < 16; i++) r[i] = a[i] | 0; for (i = 0; i < 16; i++) r[i] = a[i] | 0;
} }
function unpackneg(r, p) { function unpackneg(r, p) {
var t = gf(), chk = gf(), num = gf(), var t = gf(), chk = gf(), num = gf(),
den = gf(), den2 = gf(), den4 = gf(), den = gf(), den2 = gf(), den4 = gf(),
den6 = gf(); den6 = gf();
@ -204,13 +196,13 @@ import nacl from './nacl-fast.js'
M(r[3], r[0], r[1]); M(r[3], r[0], r[1]);
return 0; return 0;
} }
// ---- // ----
// Converts Ed25519 public key to Curve25519 public key. // Converts Ed25519 public key to Curve25519 public key.
// montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p // montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p
function convertPublicKey(pk) { function convertPublicKey(pk) {
var z = new Uint8Array(32), var z = new Uint8Array(32),
q = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()],
a = gf(), b = gf(); a = gf(), b = gf();
@ -226,10 +218,10 @@ import nacl from './nacl-fast.js'
pack25519(z, a); pack25519(z, a);
return z; return z;
} }
// Converts Ed25519 secret key to Curve25519 secret key. // Converts Ed25519 secret key to Curve25519 secret key.
function convertSecretKey(sk) { function convertSecretKey(sk) {
var d = new Uint8Array(64), o = new Uint8Array(32), i; var d = new Uint8Array(64), o = new Uint8Array(32), i;
nacl.lowlevel.crypto_hash(d, sk, 32); nacl.lowlevel.crypto_hash(d, sk, 32);
d[0] &= 248; d[0] &= 248;
@ -238,27 +230,19 @@ import nacl from './nacl-fast.js'
for (i = 0; i < 32; i++) o[i] = d[i]; for (i = 0; i < 32; i++) o[i] = d[i];
for (i = 0; i < 64; i++) d[i] = 0; for (i = 0; i < 64; i++) d[i] = 0;
return o; return o;
} }
function convertKeyPair(edKeyPair) { function convertKeyPair(edKeyPair) {
var publicKey = convertPublicKey(edKeyPair.publicKey); var publicKey = convertPublicKey(edKeyPair.publicKey);
if (!publicKey) return null; if (!publicKey) return null;
return { return {
publicKey: publicKey, publicKey: publicKey,
secretKey: convertSecretKey(edKeyPair.secretKey) secretKey: convertSecretKey(edKeyPair.secretKey)
}; };
} }
// return {
// convertPublicKey: convertPublicKey,
// convertSecretKey: convertSecretKey,
// convertKeyPair: convertKeyPair,
// };
export default { export default {
convertPublicKey: convertPublicKey, convertPublicKey: convertPublicKey,
convertSecretKey: convertSecretKey, convertSecretKey: convertSecretKey,
convertKeyPair: convertKeyPair, convertKeyPair: convertKeyPair,
} }
// }));

File diff suppressed because it is too large Load Diff

View File

@ -26,9 +26,8 @@ const TYPES = {
MESSAGE_TRANSACTION: 17 MESSAGE_TRANSACTION: 17
}; };
function getKeyPairFromSeed(seed, returnBase58) function getKeyPairFromSeed(seed, returnBase58) {
{ if (typeof (seed) == "string") {
if(typeof(seed) == "string") {
seed = new Uint8Array(Base58.decode(seed)); seed = new Uint8Array(Base58.decode(seed));
} }
@ -36,7 +35,7 @@ function getKeyPairFromSeed(seed, returnBase58)
var base58privateKey = Base58.encode(keyPair.secretKey); var base58privateKey = Base58.encode(keyPair.secretKey);
var base58publicKey = Base58.encode(keyPair.publicKey); var base58publicKey = Base58.encode(keyPair.publicKey);
if(returnBase58) { if (returnBase58) {
return { return {
privateKey: Base58.encode(keyPair.secretKey), privateKey: Base58.encode(keyPair.secretKey),
publicKey: Base58.encode(keyPair.publicKey) publicKey: Base58.encode(keyPair.publicKey)
@ -60,7 +59,7 @@ function stringtoUTF8Array(message) {
return message; return message;
} }
function int32ToBytes (word) { function int32ToBytes(word) {
var byteArray = []; var byteArray = [];
for (var b = 0; b < 32; b += 8) { for (var b = 0; b < 32; b += 8) {
byteArray.push((word >>> (24 - b % 32)) & 0xFF); byteArray.push((word >>> (24 - b % 32)) & 0xFF);
@ -68,20 +67,20 @@ function int32ToBytes (word) {
return byteArray; return byteArray;
} }
function int64ToBytes (int64) { function int64ToBytes(int64) {
// we want to represent the input as a 8-bytes array // we want to represent the input as a 8-bytes array
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0]; var byteArray = [0, 0, 0, 0, 0, 0, 0, 0];
for ( var index = 0; index < byteArray.length; index ++ ) { for (var index = 0; index < byteArray.length; index++) {
var byte = int64 & 0xff; var byte = int64 & 0xff;
byteArray [ byteArray.length - index - 1 ] = byte; byteArray[byteArray.length - index - 1] = byte;
int64 = (int64 - byte) / 256 ; int64 = (int64 - byte) / 256;
} }
return byteArray; return byteArray;
} }
function appendBuffer (buffer1, buffer2) { function appendBuffer(buffer1, buffer2) {
buffer1 = new Uint8Array(buffer1); buffer1 = new Uint8Array(buffer1);
buffer2 = new Uint8Array(buffer2); buffer2 = new Uint8Array(buffer2);
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
@ -90,21 +89,18 @@ function appendBuffer (buffer1, buffer2) {
return tmp; return tmp;
} }
function equal (buf1, buf2) function equal(buf1, buf2) {
{
if (buf1.byteLength != buf2.byteLength) return false; if (buf1.byteLength != buf2.byteLength) return false;
var dv1 = new Uint8Array(buf1); var dv1 = new Uint8Array(buf1);
var dv2 = new Uint8Array(buf2); var dv2 = new Uint8Array(buf2);
for (var i = 0; i != buf1.byteLength; i++) for (var i = 0; i != buf1.byteLength; i++) {
{
if (dv1[i] != dv2[i]) return false; if (dv1[i] != dv2[i]) return false;
} }
return true; return true;
} }
function generateAccountSeed(seed, nonce, returnBase58) function generateAccountSeed(seed, nonce, returnBase58) {
{ if (typeof (seed) == "string") {
if(typeof(seed) == "string") {
seed = Base58.decode(seed); seed = Base58.decode(seed);
} }
@ -116,7 +112,7 @@ function generateAccountSeed(seed, nonce, returnBase58)
resultSeed = appendBuffer(resultSeed, seed); resultSeed = appendBuffer(resultSeed, seed);
resultSeed = appendBuffer(resultSeed, nonceBytes); resultSeed = appendBuffer(resultSeed, nonceBytes);
if(returnBase58) { if (returnBase58) {
return Base58.encode(SHA256.digest(SHA256.digest(resultSeed))); return Base58.encode(SHA256.digest(SHA256.digest(resultSeed)));
} else { } else {
return new SHA256.digest(SHA256.digest(resultSeed)); return new SHA256.digest(SHA256.digest(resultSeed));
@ -124,11 +120,10 @@ function generateAccountSeed(seed, nonce, returnBase58)
} }
function getAccountAddressFromPublicKey(publicKey) function getAccountAddressFromPublicKey(publicKey) {
{
var ADDRESS_VERSION = 58; // Q var ADDRESS_VERSION = 58; // Q
if(typeof(publicKey) == "string") { if (typeof (publicKey) == "string") {
publicKey = Base58.decode(publicKey); publicKey = Base58.decode(publicKey);
} }
@ -150,13 +145,12 @@ function getAccountAddressFromPublicKey(publicKey)
return Base58.encode(addressArray); return Base58.encode(addressArray);
} }
function getAccountAddressType(address) function getAccountAddressType(address) {
{
try { try {
var ADDRESS_VERSION = 58; // Q var ADDRESS_VERSION = 58; // Q
var AT_ADDRESS_VERSION = 23; // A var AT_ADDRESS_VERSION = 23; // A
if(typeof(address) == "string") { if (typeof (address) == "string") {
address = Base58.decode(address); address = Base58.decode(address);
} }
@ -166,14 +160,11 @@ function getAccountAddressType(address)
var checkSumTwo = SHA256.digest(SHA256.digest(addressWitoutChecksum)); var checkSumTwo = SHA256.digest(SHA256.digest(addressWitoutChecksum));
checkSumTwo = checkSumTwo.subarray(0, 4); checkSumTwo = checkSumTwo.subarray(0, 4);
if (equal(checkSum, checkSumTwo)) if (equal(checkSum, checkSumTwo)) {
{ if (address[0] == ADDRESS_VERSION) {
if(address[0] == ADDRESS_VERSION)
{
return "standard"; return "standard";
} }
if(address[0] == AT_ADDRESS_VERSION) if (address[0] == AT_ADDRESS_VERSION) {
{
return "at"; return "at";
} }
} }
@ -185,8 +176,7 @@ function getAccountAddressType(address)
} }
} }
function isValidAddress(address) function isValidAddress(address) {
{
return (getAccountAddressType(address) != "invalid"); return (getAccountAddressType(address) != "invalid");
} }
@ -307,8 +297,8 @@ function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner,
} }
function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) { function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) {
return appendBuffer( generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp), return appendBuffer(generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp),
signature ); signature);
} }
function generateRegisterNameTransactionBase(publicKey, lastReference, owner, name, value, fee, timestamp) { function generateRegisterNameTransactionBase(publicKey, lastReference, owner, name, value, fee, timestamp) {

View File

@ -1,5 +1,7 @@
// Extracted from https://github.com/crypto-browserify/ripemd160 // Extracted from https://github.com/crypto-browserify/ripemd160
const ARRAY16 = new Array(16); const ARRAY16 = new Array(16);
const zl = initU8Array([ const zl = initU8Array([
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,

View File

@ -21,7 +21,7 @@ SHA256.K = [
// The digest function returns the hash value (digest) // The digest function returns the hash value (digest)
// as a 32 byte (typed) array. // as a 32 byte (typed) array.
// message: the string or byte array to hash // message: the string or byte array to hash
SHA256.digest = function(message) { SHA256.digest = function (message) {
var h0 = 0x6a09e667; var h0 = 0x6a09e667;
var h1 = 0xbb67ae85; var h1 = 0xbb67ae85;
var h2 = 0x3c6ef372; var h2 = 0x3c6ef372;
@ -127,7 +127,7 @@ SHA256.digest = function(message) {
// The hash function returns the hash value as a hex string. // The hash function returns the hash value as a hex string.
// message: the string or byte array to hash // message: the string or byte array to hash
SHA256.hash = function(message) { SHA256.hash = function (message) {
var digest = SHA256.digest(message); var digest = SHA256.digest(message);
var hex = ''; var hex = '';
for (var i = 0; i < digest.length; i++) { for (var i = 0; i < digest.length; i++) {
@ -137,6 +137,5 @@ SHA256.hash = function(message) {
return hex; return hex;
} }
// == Convert to ES6 Module == // // == Convert to ES6 Module == //
export default SHA256; export default SHA256;

View File

@ -1,4 +1,3 @@
'use strict'
const utils = { const utils = {
int32ToBytes(word) { int32ToBytes(word) {
var byteArray = [] var byteArray = []

View File

@ -1,4 +1,4 @@
import {waitForConfig, watchConfig} from '../config.js' import { waitForConfig, watchConfig } from '../config'
let config = {} let config = {}

View File

@ -1,8 +1,8 @@
import {store} from '../api_deps.js' import { store } from '../api_deps'
import {stateAwait} from './utils/stateAwait.js' import { stateAwait } from './utils/stateAwait'
import {Sha512} from 'asmcrypto.js' import { Sha512 } from 'asmcrypto.js'
import utils from '../api/deps/utils.js' import utils from '../api/deps/utils'
import {get, registerTranslateConfig} from '../../core/translate' import { get, registerTranslateConfig } from '../../core/translate'
registerTranslateConfig({ registerTranslateConfig({
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json()) loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())

View File

@ -1,7 +1,7 @@
/** /**
* Not to be confused with register name...this is a special use case * Not to be confused with register name...this is a special use case
*/ */
import {createTransaction, processTransaction, request} from './api.js' import { createTransaction, processTransaction, request } from './api'
const TX_TYPE = 3 // NAME_REGISTRATION const TX_TYPE = 3 // NAME_REGISTRATION
const CHECK_LAST_REF_INTERVAL = 30 * 1000 // err 30 seconds const CHECK_LAST_REF_INTERVAL = 30 * 1000 // err 30 seconds

View File

@ -1,6 +1,6 @@
import {AES_CBC, HmacSha512} from 'asmcrypto.js' import { AES_CBC, HmacSha512 } from 'asmcrypto.js'
import {kdf} from './kdf.js' import { kdf } from './kdf'
import Base58 from './deps/Base58.js' import Base58 from './deps/Base58'
const getRandomValues = window.crypto ? window.crypto.getRandomValues.bind(window.crypto) : window.msCrypto.getRandomValues.bind(window.msCrypto) const getRandomValues = window.crypto ? window.crypto.getRandomValues.bind(window.crypto) : window.msCrypto.getRandomValues.bind(window.msCrypto)

View File

@ -1,9 +1,9 @@
// Trade Bot // Trade Bot
import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest.js' import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest'
import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest.js' import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest'
import signTradeBotTransaction from './transactions/trade-portal/tradebot/signTradeBotTransaction.js' import signTradeBotTransaction from './transactions/trade-portal/tradebot/signTradeBotTransaction'
import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer.js' import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer'
import {request} from './fetch-request' import { request } from './fetch-request'
// TradeBotCreateRequest // TradeBotCreateRequest
export const tradeBotCreateRequest = (requestObject) => { export const tradeBotCreateRequest = (requestObject) => {

View File

@ -1,5 +1,5 @@
import TransactionBase from './TransactionBase' import TransactionBase from './TransactionBase'
import {QORT_DECIMALS} from '../constants' import { QORT_DECIMALS } from '../constants'
export default class PaymentTransaction extends TransactionBase { export default class PaymentTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,6 +1,6 @@
import TransactionBase from './TransactionBase' import TransactionBase from './TransactionBase'
import {store} from '../../api' import { store } from '../../api'
import {QORT_DECIMALS} from '../constants' import { QORT_DECIMALS } from '../constants'
export default class DeployAtTransaction extends TransactionBase { export default class DeployAtTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,6 +1,6 @@
import TransactionBase from './TransactionBase' import TransactionBase from './TransactionBase'
import Base58 from '../deps/Base58' import Base58 from '../deps/Base58'
import {store} from '../../api' import { store } from '../../api'
export default class PaymentTransaction extends TransactionBase { export default class PaymentTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import ChatBase from './chat/ChatBase' import ChatBase from './chat/ChatBase'
import {QORT_DECIMALS} from '../constants' import { QORT_DECIMALS } from '../constants'
export default class PublicizeTransaction extends ChatBase { export default class PublicizeTransaction extends ChatBase {
constructor() { constructor() {

View File

@ -1,4 +1,4 @@
import {QORT_DECIMALS, TX_TYPES} from '../constants' import { QORT_DECIMALS, TX_TYPES } from '../constants'
import nacl from '../deps/nacl-fast' import nacl from '../deps/nacl-fast'
import Base58 from '../deps/Base58' import Base58 from '../deps/Base58'
import utils from '../deps/utils' import utils from '../deps/utils'

View File

@ -1,6 +1,6 @@
import TransactionBase from './TransactionBase' import TransactionBase from './TransactionBase'
import {store} from '../../api' import { store } from '../../api'
import {QORT_DECIMALS} from '../constants' import { QORT_DECIMALS } from '../constants'
export default class TransferPrivsTransaction extends TransactionBase { export default class TransferPrivsTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,6 +1,4 @@
'use strict' (function () {
(function () {
function generateSignatureArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp) => { function generateSignatureArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp) => {
const data = generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp) const data = generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp)
return nacl.sign.detached(data, keyPair.privateKey) return nacl.sign.detached(data, keyPair.privateKey)
@ -35,4 +33,4 @@
return data return data
} }
}()) }())

View File

@ -1,4 +1,4 @@
import {QORT_DECIMALS, TX_TYPES} from '../../constants' import { QORT_DECIMALS, TX_TYPES } from '../../constants'
import nacl from '../../deps/nacl-fast' import nacl from '../../deps/nacl-fast'
import Base58 from '../../deps/Base58' import Base58 from '../../deps/Base58'
import utils from '../../deps/utils' import utils from '../../deps/utils'

View File

@ -1,8 +1,8 @@
import ChatBase from './ChatBase' import ChatBase from './ChatBase'
import nacl from '../../deps/nacl-fast' import nacl from '../../deps/nacl-fast'
import ed2curve from '../../deps/ed2curve' import ed2curve from '../../deps/ed2curve'
import {Sha256} from 'asmcrypto.js' import { Sha256 } from 'asmcrypto.js'
import {CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP} from '../../constants' import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants'
export default class ChatTransaction extends ChatBase { export default class ChatTransaction extends ChatBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import ChatBase from './ChatBase' import ChatBase from './ChatBase'
import {CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP} from '../../constants' import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants'
export default class GroupChatTransaction extends ChatBase { export default class GroupChatTransaction extends ChatBase {
constructor() { constructor() {

View File

@ -1,7 +1,7 @@
import nacl from '../../deps/nacl-fast' import nacl from '../../deps/nacl-fast'
import Base58 from '../../deps/Base58' import Base58 from '../../deps/Base58'
import ed2curve from '../../deps/ed2curve' import ed2curve from '../../deps/ed2curve'
import {Sha256} from 'asmcrypto.js' import { Sha256 } from 'asmcrypto.js'
export const decryptChatMessage = (encryptedMessage, privateKey, recipientPublicKey, lastReference) => { export const decryptChatMessage = (encryptedMessage, privateKey, recipientPublicKey, lastReference) => {
let _encryptedMessage = Base58.decode(encryptedMessage) let _encryptedMessage = Base58.decode(encryptedMessage)

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class AddGroupAdminTransaction extends TransactionBase { export default class AddGroupAdminTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class CancelGroupBanTransaction extends TransactionBase { export default class CancelGroupBanTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class CancelGroupInviteTransaction extends TransactionBase { export default class CancelGroupInviteTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class CreateGroupTransaction extends TransactionBase { export default class CreateGroupTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class GroupBanTransaction extends TransactionBase { export default class GroupBanTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class GroupInviteTransaction extends TransactionBase { export default class GroupInviteTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class GroupKickTransaction extends TransactionBase { export default class GroupKickTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class JoinGroupTransaction extends TransactionBase { export default class JoinGroupTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class LeaveGroupTransaction extends TransactionBase { export default class LeaveGroupTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class RemoveGroupAdminTransaction extends TransactionBase { export default class RemoveGroupAdminTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class UpdateGroupTransaction extends TransactionBase { export default class UpdateGroupTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class BuyNameTransacion extends TransactionBase { export default class BuyNameTransacion extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class CancelSellNameTransacion extends TransactionBase { export default class CancelSellNameTransacion extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class RegisterNameTransaction extends TransactionBase { export default class RegisterNameTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class SellNameTransacion extends TransactionBase { export default class SellNameTransacion extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class UpdateNameTransaction extends TransactionBase { export default class UpdateNameTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class CreatePollTransaction extends TransactionBase { export default class CreatePollTransaction extends TransactionBase {
constructor() { constructor() {
@ -35,7 +35,7 @@ export default class CreatePollTransaction extends TransactionBase {
this._options.push({ length: optionLength, bytes: optionBytes }) this._options.push({ length: optionLength, bytes: optionBytes })
} }
set feeDialog(feeDialog){ set feeDialog(feeDialog) {
this._feeDialog = feeDialog this._feeDialog = feeDialog
} }
@ -106,7 +106,7 @@ export default class CreatePollTransaction extends TransactionBase {
params.push(this._options[i].length, this._options[i].bytes) params.push(this._options[i].length, this._options[i].bytes)
} }
params.push(this._feeBytes); params.push(this._feeBytes)
return params return params
} }

View File

@ -1,5 +1,5 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import {QORT_DECIMALS} from '../../constants' import { QORT_DECIMALS } from '../../constants'
export default class VoteOnPollTransaction extends TransactionBase { export default class VoteOnPollTransaction extends TransactionBase {
constructor() { constructor() {
@ -20,7 +20,7 @@ export default class VoteOnPollTransaction extends TransactionBase {
` `
} }
set feeDialog(feeDialog){ set feeDialog(feeDialog) {
this._feeDialog = feeDialog this._feeDialog = feeDialog
} }

View File

@ -1,6 +1,4 @@
'use strict' (function () {
(function () {
function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp) => { function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp) => {
const data = generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp) const data = generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp)
return nacl.sign.detached(data, keyPair.privateKey) return nacl.sign.detached(data, keyPair.privateKey)
@ -33,4 +31,4 @@
return data return data
} }
}()) }())

View File

@ -1,7 +1,7 @@
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import publicKeyToAddress from '../../wallet/publicKeyToAddress' import publicKeyToAddress from '../../wallet/publicKeyToAddress'
import {Base58} from '../../deps/deps' import { Base58 } from '../../deps/deps'
import {DYNAMIC_FEE_TIMESTAMP} from '../../constants' import { DYNAMIC_FEE_TIMESTAMP } from '../../constants'
export default class RemoveRewardShareTransaction extends TransactionBase { export default class RemoveRewardShareTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -2,8 +2,8 @@ import publicKeyToAddress from '../../wallet/publicKeyToAddress'
import TransactionBase from '../TransactionBase' import TransactionBase from '../TransactionBase'
import nacl from '../../deps/nacl-fast' import nacl from '../../deps/nacl-fast'
import ed2curve from '../../deps/ed2curve' import ed2curve from '../../deps/ed2curve'
import {Sha256} from 'asmcrypto.js' import { Sha256 } from 'asmcrypto.js'
import {DYNAMIC_FEE_TIMESTAMP} from '../../constants' import { DYNAMIC_FEE_TIMESTAMP } from '../../constants'
export default class RewardShareTransaction extends TransactionBase { export default class RewardShareTransaction extends TransactionBase {
constructor() { constructor() {

View File

@ -1,4 +1,4 @@
import {store} from '../../api.js' import { store } from '../../api'
let subscriptions = [] let subscriptions = []

View File

@ -1,5 +1,5 @@
import publicKeyToAddress from './publicKeyToAddress' import publicKeyToAddress from './publicKeyToAddress'
import Base58 from '../deps/Base58.js' import Base58 from '../deps/Base58'
export const base58PublicKeyToAddress = (base58pubkey, qora = false) => { export const base58PublicKeyToAddress = (base58pubkey, qora = false) => {
const decodePubKey = Base58.decode(base58pubkey) const decodePubKey = Base58.decode(base58pubkey)

View File

@ -1,10 +1,10 @@
import Base58 from '../deps/Base58.js' import Base58 from '../deps/Base58'
import BROKEN_RIPEMD160 from '../deps/broken-ripemd160.js' import BROKEN_RIPEMD160 from '../deps/broken-ripemd160'
import RIPEMD160 from '../deps/ripemd160.js' import RIPEMD160 from '../deps/ripemd160'
import utils from '../deps/utils.js' import utils from '../deps/utils'
import {ADDRESS_VERSION} from '../constants.js' import { ADDRESS_VERSION } from '../constants'
import {Buffer} from 'buffer' import { Buffer } from 'buffer'
import {Sha256} from 'asmcrypto.js' import { Sha256 } from 'asmcrypto.js'
const repeatSHA256 = (passphrase, hashes) => { const repeatSHA256 = (passphrase, hashes) => {
let hash = passphrase let hash = passphrase

View File

@ -1,8 +1,8 @@
import Base58 from '../deps/Base58.js' import Base58 from '../deps/Base58'
export const validateAddress = (address) => { export const validateAddress = (address) => {
const decodePubKey = Base58.decode(address) const decodePubKey = Base58.decode(address)
return decodePubKey instanceof Uint8Array && decodePubKey.length == 25; return decodePubKey instanceof Uint8Array && decodePubKey.length == 25
} }

View File

@ -1,4 +1,4 @@
import {store} from './api.js' import { store } from './api'
let config = false let config = false
let loaded = false let loaded = false