Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(response: ServerApi.AccountRecord) {
this._baseAccount = new BaseAccount(response.account_id, response.sequence);
// Extract response fields
// TODO: do it in type-safe manner.
forIn(response, (value, key) => {
(this as any)[key] = value;
});
}
export function buildChallengeTx(
serverKeypair: Keypair,
clientAccountID: string,
anchorName: string,
timeout: number = 300,
networkPassphrase?: string,
): string {
const account = new Account(serverKeypair.publicKey(), "-1");
const now = Math.floor(Date.now() / 1000);
// A Base64 digit represents 6 bits, to generate a random 64 bytes
// base64 string, we need 48 random bytes = (64 * 6)/8
//
// Each Base64 digit is in ASCII and each ASCII characters when
// turned into binary represents 8 bits = 1 bytes.
const value = randomBytes(48).toString("base64");
const transaction = new TransactionBuilder(account, {
fee: BASE_FEE,
networkPassphrase,
timebounds: {
minTime: now,
maxTime: now + timeout,
},