Sha256: ff49a87e4ee9a98cb2f3e8d140b4baf2ee7bf45b9ca2f31e57c342d4d2c3aa36

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wavesAuth = exports.serializeWavesAuthData = void 0;
/**
 * @module index
 */
const ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
const marshall_1 = require("@waves/marshall");
const { LONG, BASE58_STRING } = marshall_1.serializePrimitives;
const generic_1 = require("../generic");
const validators_1 = require("../validators");
exports.serializeWavesAuthData = (auth) => ts_lib_crypto_1.concat(BASE58_STRING(auth.publicKey), LONG(auth.timestamp));
function wavesAuth(params, seed, chainId) {
    const seedsAndIndexes = generic_1.convertToPairs(seed);
    const publicKey = params.publicKey || generic_1.getSenderPublicKey(seedsAndIndexes, { senderPublicKey: undefined });
    const timestamp = params.timestamp || Date.now();
    validators_1.validate.wavesAuth({ publicKey, timestamp });
    const rx = {
        hash: '',
        signature: '',
        timestamp,
        publicKey,
        address: ts_lib_crypto_1.address({ publicKey }, chainId),
    };
    const bytes = exports.serializeWavesAuthData(rx);
    rx.signature = seedsAndIndexes.map(([seed]) => ts_lib_crypto_1.signBytes(seed, bytes))[0] || '';
    rx.hash = ts_lib_crypto_1.base58Encode(ts_lib_crypto_1.blake2b(Uint8Array.from(bytes)));
    return rx;
}
exports.wavesAuth = wavesAuth;
//# sourceMappingURL=wavesAuth.js.map

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/waves-transactions/dist/requests/wavesAuth.js