Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const row of delta[1].rows) {
const type = types.get(delta[1].name)
const data_sb = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder,
array: row.data
})
const data = type.deserialize(data_sb)
if (this.interested(data[1].sender) || (data[1].sender === '.............' && this.interested(data[1].payer))){
// console.log(row)
// console.log(data[1].sender_id)
const actor = (data[1].sender === '.............')?data[1].payer:data[1].sender;
const packed = Serialize.hexToUint8Array(data[1].packed_trx)
const type_trx = types.get('transaction')
const sb_trx = new Serialize.SerialBuffer({
textEncoder: new TextEncoder,
textDecoder: new TextDecoder,
array: packed
})
const data_trx = type_trx.deserialize(sb_trx)
delete data_trx.max_cpu_usage_ms
delete data_trx.max_net_usage_words
delete data_trx.ref_block_num
delete data_trx.ref_block_prefix
delete data_trx.context_free_actions
delete data_trx.transaction_extensions
var trx_id = crypto.createHash('sha256').update(packed).digest('hex');
async function decodeKey(k: AddKeyArgs): Promise {
// todo: check RP ID hash
// todo: check signature
if (unloadedModule)
return;
// console.log(k);
// console.log(JSON.stringify(JSON.parse(textDecoder.decode(Serialize.hexToUint8Array(k.clientDataJSON))), null, 4));
const att = await (cbor as any).decodeFirst(Serialize.hexToUint8Array(k.attestationObject));
// console.log(att);
// console.log(Serialize.arrayToHex(new Uint8Array(att.authData.buffer)));
const data = new DataView(att.authData.buffer);
let pos = 30; // skip unknown
pos += 32; // RP ID hash
const flags = data.getUint8(pos++);
const signCount = data.getUint32(pos);
pos += 4;
if (!(flags & AttestationFlags.attestedCredentialPresent))
throw new Error('attestedCredentialPresent flag not set');
const aaguid = Serialize.arrayToHex(new Uint8Array(data.buffer, pos, 16));
pos += 16;
const credentialIdLength = data.getUint16(pos);
pos += 2;
const credentialId = new Uint8Array(data.buffer, pos, credentialIdLength);
pos += credentialIdLength;
return abis.map(({ abi, ...rest }) => {
const uInt8Abi = Serialize.hexToUint8Array(abi)
return { abi: api.rawAbiToJson(uInt8Abi), ...rest }
})
}
public async sign(
{ chainId, requiredKeys, serializedTransaction, serializedContextFreeData }: ApiInterfaces.SignatureProviderArgs,
) {
const signBuf = new Serialize.SerialBuffer();
signBuf.pushArray(Serialize.hexToUint8Array(chainId));
signBuf.pushArray(serializedTransaction);
if (serializedContextFreeData)
signBuf.pushArray(new Uint8Array(await crypto.subtle.digest('SHA-256', serializedContextFreeData.buffer)));
else
signBuf.pushArray(new Uint8Array(32));
const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', signBuf.asUint8Array().slice().buffer));
const signatures = [] as string[];
for (const key of requiredKeys) {
const id = Serialize.hexToUint8Array(this.keys.get(key));
const assertion = await (navigator as any).credentials.get({
publicKey: {
timeout: 60000,
allowCredentials: [{
id,
type: 'public-key',
}],
challenge: digest.buffer,
},
});
const e = new ec('p256') as any;
const pubKey = e.keyFromPublic(Numeric.stringToPublicKey(key).data.subarray(0, 33)).getPublic();
function fixup(x: Uint8Array) {
const a = Array.from(x);
while (a.length < 32)
public async getRawAbi(accountName: string): Promise {
const hexAbi = (this.hexAbiInfos.find((hexAbiObject: any) => hexAbiObject.accountName === accountName)).abi
const abi = Serialize.hexToUint8Array(hexAbi)
return { accountName, abi }
}
}
public async sign(
{ chainId, requiredKeys, serializedTransaction, serializedContextFreeData }: ApiInterfaces.SignatureProviderArgs,
) {
const signBuf = new Serialize.SerialBuffer();
signBuf.pushArray(Serialize.hexToUint8Array(chainId));
signBuf.pushArray(serializedTransaction);
if (serializedContextFreeData)
signBuf.pushArray(new Uint8Array(await crypto.subtle.digest('SHA-256', serializedContextFreeData.buffer)));
else
signBuf.pushArray(new Uint8Array(32));
const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', signBuf.asUint8Array().slice().buffer));
const signatures = [] as string[];
for (const key of requiredKeys) {
const id = Serialize.hexToUint8Array(this.keys.get(key));
const assertion = await (navigator as any).credentials.get({
publicKey: {
timeout: 60000,
allowCredentials: [{
id,
type: 'public-key',