Sha256: bc718afa705d9c253327696124d56acea0a2b840bad5e874aed7b2a4c1f143c9

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.auth = exports.serializeAuthData = void 0;
/**
 * @module index
 */
const ts_lib_crypto_1 = require("@waves/ts-lib-crypto");
const marshall_1 = require("@waves/marshall");
const { STRING, LEN, SHORT } = marshall_1.serializePrimitives;
const generic_1 = require("../generic");
const validators_1 = require("../validators");
exports.serializeAuthData = (auth) => ts_lib_crypto_1.concat(LEN(SHORT)(STRING)('WavesWalletAuthentication'), LEN(SHORT)(STRING)(auth.host || ''), LEN(SHORT)(STRING)(auth.data || ''));
function auth(params, seed, chainId) {
    const seedsAndIndexes = generic_1.convertToPairs(seed);
    const publicKey = params.publicKey || generic_1.getSenderPublicKey(seedsAndIndexes, { senderPublicKey: undefined });
    validators_1.validate.auth(params);
    const rx = {
        hash: '',
        signature: '',
        host: params.host,
        data: params.data,
        publicKey,
        address: ts_lib_crypto_1.address({ publicKey }, chainId),
    };
    const bytes = exports.serializeAuthData(rx);
    rx.signature = (seed != null && ts_lib_crypto_1.signBytes(seed, bytes)) || '';
    rx.hash = ts_lib_crypto_1.base58Encode(ts_lib_crypto_1.blake2b(Uint8Array.from(bytes)));
    return rx;
}
exports.auth = auth;
//# sourceMappingURL=auth.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/auth.js