How to use additionalDataSize method in wpt

Best JavaScript code snippet using wpt

PheCipher.js

Source:PheCipher.js Github

copy

Full Screen

1/**2 * Copyright (C) 2015-2020 Virgil Security, Inc.3 *4 * All rights reserved.5 *6 * Redistribution and use in source and binary forms, with or without7 * modification, are permitted provided that the following conditions are8 * met:9 *10 * (1) Redistributions of source code must retain the above copyright11 * notice, this list of conditions and the following disclaimer.12 *13 * (2) Redistributions in binary form must reproduce the above copyright14 * notice, this list of conditions and the following disclaimer in15 * the documentation and/or other materials provided with the16 * distribution.17 *18 * (3) Neither the name of the copyright holder nor the names of its19 * contributors may be used to endorse or promote products derived from20 * this software without specific prior written permission.21 *22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE25 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,30 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING31 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE32 * POSSIBILITY OF SUCH DAMAGE.33 *34 * Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>35 */36const precondition = require('./precondition');37const initPheCipher = (Module, modules) => {38 /**39 * Class for encryption using PHE account key40 * This class is thread-safe.41 */42 class PheCipher {43 /**44 * Create object with underlying C context.45 *46 * Note. Parameter 'ctxPtr' SHOULD be passed from the generated code only.47 */48 constructor(ctxPtr) {49 this.name = 'PheCipher';50 if (typeof ctxPtr === 'undefined') {51 this.ctxPtr = Module._vsce_phe_cipher_new();52 } else {53 this.ctxPtr = ctxPtr;54 }55 }56 /**57 * Acquire C context by making it's shallow copy.58 *59 * Note. This method is used in generated code only, and SHOULD NOT be used in another way.60 */61 static newAndUseCContext(ctxPtr) {62 // assert(typeof ctxPtr === 'number');63 return new PheCipher(Module._vsce_phe_cipher_shallow_copy(ctxPtr));64 }65 /**66 * Acquire C context by taking it ownership.67 *68 * Note. This method is used in generated code only, and SHOULD NOT be used in another way.69 */70 static newAndTakeCContext(ctxPtr) {71 // assert(typeof ctxPtr === 'number');72 return new PheCipher(ctxPtr);73 }74 /**75 * Release underlying C context.76 */77 delete() {78 if (typeof this.ctxPtr !== 'undefined' && this.ctxPtr !== null) {79 Module._vsce_phe_cipher_delete(this.ctxPtr);80 this.ctxPtr = null;81 }82 }83 /**84 * Random used for salt generation85 */86 set random(random) {87 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);88 precondition.ensureImplementInterface('random', random, 'Foundation.Random', modules.FoundationInterfaceTag.RANDOM, modules.FoundationInterface);89 Module._vsce_phe_cipher_release_random(this.ctxPtr)90 Module._vsce_phe_cipher_use_random(this.ctxPtr, random.ctxPtr)91 }92 /**93 * Setups dependencies with default values.94 */95 setupDefaults() {96 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);97 const proxyResult = Module._vsce_phe_cipher_setup_defaults(this.ctxPtr);98 modules.PheError.handleStatusCode(proxyResult);99 }100 /**101 * Returns buffer capacity needed to fit cipher text102 */103 encryptLen(plainTextLen) {104 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);105 precondition.ensureNumber('plainTextLen', plainTextLen);106 let proxyResult;107 proxyResult = Module._vsce_phe_cipher_encrypt_len(this.ctxPtr, plainTextLen);108 return proxyResult;109 }110 /**111 * Returns buffer capacity needed to fit plain text112 */113 decryptLen(cipherTextLen) {114 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);115 precondition.ensureNumber('cipherTextLen', cipherTextLen);116 let proxyResult;117 proxyResult = Module._vsce_phe_cipher_decrypt_len(this.ctxPtr, cipherTextLen);118 return proxyResult;119 }120 /**121 * Encrypts data using account key122 */123 encrypt(plainText, accountKey) {124 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);125 precondition.ensureByteArray('plainText', plainText);126 precondition.ensureByteArray('accountKey', accountKey);127 // Copy bytes from JS memory to the WASM memory.128 const plainTextSize = plainText.length * plainText.BYTES_PER_ELEMENT;129 const plainTextPtr = Module._malloc(plainTextSize);130 Module.HEAP8.set(plainText, plainTextPtr);131 // Create C structure vsc_data_t.132 const plainTextCtxSize = Module._vsc_data_ctx_size();133 const plainTextCtxPtr = Module._malloc(plainTextCtxSize);134 // Point created vsc_data_t object to the copied bytes.135 Module._vsc_data(plainTextCtxPtr, plainTextPtr, plainTextSize);136 // Copy bytes from JS memory to the WASM memory.137 const accountKeySize = accountKey.length * accountKey.BYTES_PER_ELEMENT;138 const accountKeyPtr = Module._malloc(accountKeySize);139 Module.HEAP8.set(accountKey, accountKeyPtr);140 // Create C structure vsc_data_t.141 const accountKeyCtxSize = Module._vsc_data_ctx_size();142 const accountKeyCtxPtr = Module._malloc(accountKeyCtxSize);143 // Point created vsc_data_t object to the copied bytes.144 Module._vsc_data(accountKeyCtxPtr, accountKeyPtr, accountKeySize);145 const cipherTextCapacity = this.encryptLen(plainText.length);146 const cipherTextCtxPtr = Module._vsc_buffer_new_with_capacity(cipherTextCapacity);147 try {148 const proxyResult = Module._vsce_phe_cipher_encrypt(this.ctxPtr, plainTextCtxPtr, accountKeyCtxPtr, cipherTextCtxPtr);149 modules.PheError.handleStatusCode(proxyResult);150 const cipherTextPtr = Module._vsc_buffer_bytes(cipherTextCtxPtr);151 const cipherTextPtrLen = Module._vsc_buffer_len(cipherTextCtxPtr);152 const cipherText = Module.HEAPU8.slice(cipherTextPtr, cipherTextPtr + cipherTextPtrLen);153 return cipherText;154 } finally {155 Module._free(plainTextPtr);156 Module._free(plainTextCtxPtr);157 Module._free(accountKeyPtr);158 Module._free(accountKeyCtxPtr);159 Module._vsc_buffer_delete(cipherTextCtxPtr);160 }161 }162 /**163 * Decrypts data using account key164 */165 decrypt(cipherText, accountKey) {166 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);167 precondition.ensureByteArray('cipherText', cipherText);168 precondition.ensureByteArray('accountKey', accountKey);169 // Copy bytes from JS memory to the WASM memory.170 const cipherTextSize = cipherText.length * cipherText.BYTES_PER_ELEMENT;171 const cipherTextPtr = Module._malloc(cipherTextSize);172 Module.HEAP8.set(cipherText, cipherTextPtr);173 // Create C structure vsc_data_t.174 const cipherTextCtxSize = Module._vsc_data_ctx_size();175 const cipherTextCtxPtr = Module._malloc(cipherTextCtxSize);176 // Point created vsc_data_t object to the copied bytes.177 Module._vsc_data(cipherTextCtxPtr, cipherTextPtr, cipherTextSize);178 // Copy bytes from JS memory to the WASM memory.179 const accountKeySize = accountKey.length * accountKey.BYTES_PER_ELEMENT;180 const accountKeyPtr = Module._malloc(accountKeySize);181 Module.HEAP8.set(accountKey, accountKeyPtr);182 // Create C structure vsc_data_t.183 const accountKeyCtxSize = Module._vsc_data_ctx_size();184 const accountKeyCtxPtr = Module._malloc(accountKeyCtxSize);185 // Point created vsc_data_t object to the copied bytes.186 Module._vsc_data(accountKeyCtxPtr, accountKeyPtr, accountKeySize);187 const plainTextCapacity = this.decryptLen(cipherText.length);188 const plainTextCtxPtr = Module._vsc_buffer_new_with_capacity(plainTextCapacity);189 try {190 const proxyResult = Module._vsce_phe_cipher_decrypt(this.ctxPtr, cipherTextCtxPtr, accountKeyCtxPtr, plainTextCtxPtr);191 modules.PheError.handleStatusCode(proxyResult);192 const plainTextPtr = Module._vsc_buffer_bytes(plainTextCtxPtr);193 const plainTextPtrLen = Module._vsc_buffer_len(plainTextCtxPtr);194 const plainText = Module.HEAPU8.slice(plainTextPtr, plainTextPtr + plainTextPtrLen);195 return plainText;196 } finally {197 Module._free(cipherTextPtr);198 Module._free(cipherTextCtxPtr);199 Module._free(accountKeyPtr);200 Module._free(accountKeyCtxPtr);201 Module._vsc_buffer_delete(plainTextCtxPtr);202 }203 }204 /**205 * Encrypts data (and authenticates additional data) using account key206 */207 authEncrypt(plainText, additionalData, accountKey) {208 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);209 precondition.ensureByteArray('plainText', plainText);210 precondition.ensureByteArray('additionalData', additionalData);211 precondition.ensureByteArray('accountKey', accountKey);212 // Copy bytes from JS memory to the WASM memory.213 const plainTextSize = plainText.length * plainText.BYTES_PER_ELEMENT;214 const plainTextPtr = Module._malloc(plainTextSize);215 Module.HEAP8.set(plainText, plainTextPtr);216 // Create C structure vsc_data_t.217 const plainTextCtxSize = Module._vsc_data_ctx_size();218 const plainTextCtxPtr = Module._malloc(plainTextCtxSize);219 // Point created vsc_data_t object to the copied bytes.220 Module._vsc_data(plainTextCtxPtr, plainTextPtr, plainTextSize);221 // Copy bytes from JS memory to the WASM memory.222 const additionalDataSize = additionalData.length * additionalData.BYTES_PER_ELEMENT;223 const additionalDataPtr = Module._malloc(additionalDataSize);224 Module.HEAP8.set(additionalData, additionalDataPtr);225 // Create C structure vsc_data_t.226 const additionalDataCtxSize = Module._vsc_data_ctx_size();227 const additionalDataCtxPtr = Module._malloc(additionalDataCtxSize);228 // Point created vsc_data_t object to the copied bytes.229 Module._vsc_data(additionalDataCtxPtr, additionalDataPtr, additionalDataSize);230 // Copy bytes from JS memory to the WASM memory.231 const accountKeySize = accountKey.length * accountKey.BYTES_PER_ELEMENT;232 const accountKeyPtr = Module._malloc(accountKeySize);233 Module.HEAP8.set(accountKey, accountKeyPtr);234 // Create C structure vsc_data_t.235 const accountKeyCtxSize = Module._vsc_data_ctx_size();236 const accountKeyCtxPtr = Module._malloc(accountKeyCtxSize);237 // Point created vsc_data_t object to the copied bytes.238 Module._vsc_data(accountKeyCtxPtr, accountKeyPtr, accountKeySize);239 const cipherTextCapacity = this.encryptLen(plainText.length);240 const cipherTextCtxPtr = Module._vsc_buffer_new_with_capacity(cipherTextCapacity);241 try {242 const proxyResult = Module._vsce_phe_cipher_auth_encrypt(this.ctxPtr, plainTextCtxPtr, additionalDataCtxPtr, accountKeyCtxPtr, cipherTextCtxPtr);243 modules.PheError.handleStatusCode(proxyResult);244 const cipherTextPtr = Module._vsc_buffer_bytes(cipherTextCtxPtr);245 const cipherTextPtrLen = Module._vsc_buffer_len(cipherTextCtxPtr);246 const cipherText = Module.HEAPU8.slice(cipherTextPtr, cipherTextPtr + cipherTextPtrLen);247 return cipherText;248 } finally {249 Module._free(plainTextPtr);250 Module._free(plainTextCtxPtr);251 Module._free(additionalDataPtr);252 Module._free(additionalDataCtxPtr);253 Module._free(accountKeyPtr);254 Module._free(accountKeyCtxPtr);255 Module._vsc_buffer_delete(cipherTextCtxPtr);256 }257 }258 /**259 * Decrypts data (and verifies additional data) using account key260 */261 authDecrypt(cipherText, additionalData, accountKey) {262 precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);263 precondition.ensureByteArray('cipherText', cipherText);264 precondition.ensureByteArray('additionalData', additionalData);265 precondition.ensureByteArray('accountKey', accountKey);266 // Copy bytes from JS memory to the WASM memory.267 const cipherTextSize = cipherText.length * cipherText.BYTES_PER_ELEMENT;268 const cipherTextPtr = Module._malloc(cipherTextSize);269 Module.HEAP8.set(cipherText, cipherTextPtr);270 // Create C structure vsc_data_t.271 const cipherTextCtxSize = Module._vsc_data_ctx_size();272 const cipherTextCtxPtr = Module._malloc(cipherTextCtxSize);273 // Point created vsc_data_t object to the copied bytes.274 Module._vsc_data(cipherTextCtxPtr, cipherTextPtr, cipherTextSize);275 // Copy bytes from JS memory to the WASM memory.276 const additionalDataSize = additionalData.length * additionalData.BYTES_PER_ELEMENT;277 const additionalDataPtr = Module._malloc(additionalDataSize);278 Module.HEAP8.set(additionalData, additionalDataPtr);279 // Create C structure vsc_data_t.280 const additionalDataCtxSize = Module._vsc_data_ctx_size();281 const additionalDataCtxPtr = Module._malloc(additionalDataCtxSize);282 // Point created vsc_data_t object to the copied bytes.283 Module._vsc_data(additionalDataCtxPtr, additionalDataPtr, additionalDataSize);284 // Copy bytes from JS memory to the WASM memory.285 const accountKeySize = accountKey.length * accountKey.BYTES_PER_ELEMENT;286 const accountKeyPtr = Module._malloc(accountKeySize);287 Module.HEAP8.set(accountKey, accountKeyPtr);288 // Create C structure vsc_data_t.289 const accountKeyCtxSize = Module._vsc_data_ctx_size();290 const accountKeyCtxPtr = Module._malloc(accountKeyCtxSize);291 // Point created vsc_data_t object to the copied bytes.292 Module._vsc_data(accountKeyCtxPtr, accountKeyPtr, accountKeySize);293 const plainTextCapacity = this.decryptLen(cipherText.length);294 const plainTextCtxPtr = Module._vsc_buffer_new_with_capacity(plainTextCapacity);295 try {296 const proxyResult = Module._vsce_phe_cipher_auth_decrypt(this.ctxPtr, cipherTextCtxPtr, additionalDataCtxPtr, accountKeyCtxPtr, plainTextCtxPtr);297 modules.PheError.handleStatusCode(proxyResult);298 const plainTextPtr = Module._vsc_buffer_bytes(plainTextCtxPtr);299 const plainTextPtrLen = Module._vsc_buffer_len(plainTextCtxPtr);300 const plainText = Module.HEAPU8.slice(plainTextPtr, plainTextPtr + plainTextPtrLen);301 return plainText;302 } finally {303 Module._free(cipherTextPtr);304 Module._free(cipherTextCtxPtr);305 Module._free(additionalDataPtr);306 Module._free(additionalDataCtxPtr);307 Module._free(accountKeyPtr);308 Module._free(accountKeyCtxPtr);309 Module._vsc_buffer_delete(plainTextCtxPtr);310 }311 }312 }313 return PheCipher;314};...

Full Screen

Full Screen

player-record.js

Source:player-record.js Github

copy

Full Screen

1const constants = require('./constants');2class PlayerRecord {3 constructor (buffer, parser) {4 this.type = buffer.read(1).toString("hex");5 this.id = buffer.read(1).readUIntLE(0, 1);6 this.name = buffer.readUntil(constants.NULL_STRING).toString();7 this.additionalDataSize = buffer.read(1).readUIntLE(0, 1);8 if (this.additionalDataSize == constants.PLAYER_RECORD.LADDER_GAME) { 9 this.runTime = buffer.read(4).readUIntLE(0, 3);10 this.race = buffer.read(4).toString('hex');11 } else {12 this.additionalData = buffer.read(this.additionalDataSize);13 }14 this.unknown = buffer.read(4);15 parser.players[this.id] = this;16 parser.playerSlots.push(this.id);17 }18}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('API_KEY');3test.runTest(url, { location: 'Dulles:Chrome' }, function(err, data) {4 if (data.statusCode == 200) {5 test.additionalDataSize(data.data.testId, function(err, data) {6 console.log(data);7 });8 }9});10var wpt = require('webpagetest');11var test = new wpt('API_KEY');12test.getLocations(function(err, data) {13 console.log(data);14});15var wpt = require('webpagetest');16var test = new wpt('API_KEY');17test.getTesters(function(err, data) {18 console.log(data);19});20var wpt = require('webpagetest');21var test = new wpt('API_KEY');22test.getTesters(function(err, data) {23 console.log(data);24});25var wpt = require('webpagetest');26var test = new wpt('API_KEY');27test.getTesters(function(err, data) {28 console.log(data);29});30var wpt = require('webpagetest');31var test = new wpt('API_KEY');32test.getTesters(function(err, data) {33 console.log(data);34});35var wpt = require('webpagetest');36var test = new wpt('API_KEY');37test.getTesters(function(err, data) {38 console.log(data);39});40var wpt = require('webpagetest');41var test = new wpt('API_KEY');42test.getTesters(function(err, data) {43 console.log(data);44});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptdriver = require('wptdriver');2wptdriver.additionalDataSize(function(size) {3 console.log('Additional data size is ' + size);4});5var wptdriver = require('wptdriver');6wptdriver.additionalDataSize(function(size) {7 console.log('Additional data size is ' + size);8});9var wptdriver = require('wptdriver');10wptdriver.additionalDataSize(function(size) {11 console.log('Additional data size is ' + size);12});13var wptdriver = require('wptdriver');14wptdriver.additionalDataSize(function(size) {15 console.log('Additional data size is ' + size);16});17var wptdriver = require('wptdriver');18wptdriver.additionalDataSize(function(size) {19 console.log('Additional data size is ' + size);20});21var wptdriver = require('wptdriver');22wptdriver.additionalDataSize(function(size) {23 console.log('Additional data size is ' + size);24});25var wptdriver = require('wptdriver');26wptdriver.additionalDataSize(function(size) {27 console.log('Additional data size is ' + size);28});29var wptdriver = require('wptdriver');30wptdriver.additionalDataSize(function(size) {31 console.log('Additional data size is ' + size);32});33var wptdriver = require('wptdriver');34wptdriver.additionalDataSize(function(size) {35 console.log('Additional data size is ' + size);36});37var wptdriver = require('wptdriver');38wptdriver.additionalDataSize(function(size)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('API_KEY');3webPageTest.getLocations(function(err, data) {4 console.log(data);5});6{ Error: getaddrinfo ENOTFOUND www.webpagetest.org www.webpagetest.org:807at errnoException (dns.js:44:10)8at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)9port: 80 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var objWpt = new ActiveXObject("Wpt.Wpt");2var addDataSize = objWpt.additionalDataSize();3WScript.Echo("Additional data size is : " + addDataSize);4var objWpt = new ActiveXObject("Wpt.Wpt");5var addData = objWpt.additionalData();6WScript.Echo("Additional data is : " + addData);7var objWpt = new ActiveXObject("Wpt.Wpt");8objWpt.setAdditionalData("Additional data");9WScript.Echo("Additional data is set");10var objWpt = new ActiveXObject("Wpt.Wpt");11objWpt.setAdditionalDataSize(100);12WScript.Echo("Additional data size is set");13var objWpt = new ActiveXObject("Wpt.Wpt");14objWpt.setAdditionalData("Additional data");15WScript.Echo("Additional data is set");16var objWpt = new ActiveXObject("Wpt.Wpt");17objWpt.setAdditionalDataSize(100);18WScript.Echo("Additional data size is set");19var objWpt = new ActiveXObject("Wpt.Wpt");20objWpt.setAdditionalData("Additional data");21WScript.Echo("Additional data is set");22var objWpt = new ActiveXObject("Wpt.Wpt");23objWpt.setAdditionalDataSize(100);24WScript.Echo("Additional data size is set");25var objWpt = new ActiveXObject("Wpt.Wpt");26objWpt.setAdditionalData("Additional data");27WScript.Echo("Additional data is set");28var objWpt = new ActiveXObject("Wpt.Wpt");29objWpt.setAdditionalDataSize(100);30WScript.Echo("Additional data size is set");

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful