Best JavaScript code snippet using root
tls.js
Source:tls.js
1// Copyright Joyent, Inc. and other Node contributors.2//3// Permission is hereby granted, free of charge, to any person obtaining a4// copy of this software and associated documentation files (the5// "Software"), to deal in the Software without restriction, including6// without limitation the rights to use, copy, modify, merge, publish,7// distribute, sublicense, and/or sell copies of the Software, and to permit8// persons to whom the Software is furnished to do so, subject to the9// following conditions:10//11// The above copyright notice and this permission notice shall be included12// in all copies or substantial portions of the Software.13//14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS15// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN17// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,18// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20// USE OR OTHER DEALINGS IN THE SOFTWARE.21var crypto = require('crypto');22var util = require('util');23var net = require('net');24var events = require('events');25var stream = require('stream');26var END_OF_FILE = 42;27var assert = require('assert').ok;28var debug;29if (process.env.NODE_DEBUG && /tls/.test(process.env.NODE_DEBUG)) {30 debug = function(a) { console.error('TLS:', a); };31} else {32 debug = function() { };33}34var Connection = null;35try {36 Connection = process.binding('crypto').Connection;37} catch (e) {38 throw new Error('node.js not compiled with openssl crypto support.');39}40// Base class of both CleartextStream and EncryptedStream41function CryptoStream(pair) {42 stream.Stream.call(this);43 this.pair = pair;44 this.readable = this.writable = true;45 this._paused = false;46 this._pending = [];47 this._pendingCallbacks = [];48 this._pendingBytes = 0;49}50util.inherits(CryptoStream, stream.Stream);51CryptoStream.prototype.write = function(data /* , encoding, cb */) {52 if (this == this.pair.cleartext) {53 debug('cleartext.write called with ' + data.length + ' bytes');54 } else {55 debug('encrypted.write called with ' + data.length + ' bytes');56 }57 if (!this.writable) {58 throw new Error('CryptoStream is not writable');59 }60 var encoding, cb;61 // parse arguments62 if (typeof arguments[1] == 'string') {63 encoding = arguments[1];64 cb = arguments[2];65 } else {66 cb = arguments[1];67 }68 // Transform strings into buffers.69 if (typeof data == 'string') {70 data = new Buffer(data, encoding);71 }72 debug('clearIn data');73 this._pending.push(data);74 this._pendingCallbacks.push(cb);75 this._pendingBytes += data.length;76 this.pair._writeCalled = true;77 this.pair.cycle();78 return this._pendingBytes < 128 * 1024;79};80CryptoStream.prototype.pause = function() {81 debug('paused ' + (this == this.pair.cleartext ? 'cleartext' : 'encrypted'));82 this._paused = true;83};84CryptoStream.prototype.resume = function() {85 debug('resume ' + (this == this.pair.cleartext ? 'cleartext' : 'encrypted'));86 this._paused = false;87 this.pair.cycle();88};89CryptoStream.prototype.setTimeout = function(n) {90 if (this.socket) this.socket.setTimeout(n);91};92CryptoStream.prototype.setNoDelay = function() {93 if (this.socket) this.socket.setNoDelay();94};95CryptoStream.prototype.setEncoding = function(encoding) {96 var StringDecoder = require('string_decoder').StringDecoder; // lazy load97 this._decoder = new StringDecoder(encoding);98};99// EG '/C=US/ST=CA/L=SF/O=Joyent/OU=Node.js/CN=ca1/emailAddress=ry@clouds.org'100function parseCertString(s) {101 var out = {};102 var parts = s.split('/');103 // Note: can always skip the first one.104 for (var i = 1; i < parts.length; i++) {105 var sepIndex = parts[i].indexOf('=');106 if (sepIndex > 0) {107 var key = parts[i].slice(0, sepIndex);108 var value = parts[i].slice(sepIndex + 1);109 out[key] = value;110 }111 }112 return out;113}114CryptoStream.prototype.getPeerCertificate = function() {115 if (this.pair.ssl) {116 var c = this.pair.ssl.getPeerCertificate();117 if (c) {118 if (c.issuer) c.issuer = parseCertString(c.issuer);119 if (c.subject) c.subject = parseCertString(c.subject);120 return c;121 }122 }123 return null;124};125CryptoStream.prototype.getCipher = function(err) {126 if (this.pair.ssl) {127 return this.pair.ssl.getCurrentCipher();128 } else {129 return null;130 }131};132CryptoStream.prototype.end = function(d) {133 if (this.pair._doneFlag) return;134 if (!this.writable) return;135 if (d) {136 this.write(d);137 }138 this._pending.push(END_OF_FILE);139 this._pendingCallbacks.push(null);140 // If this is an encrypted stream then we need to disable further 'data'141 // events.142 this.writable = false;143 this.pair.cycle();144};145CryptoStream.prototype.destroySoon = function(err) {146 if (this.writable) {147 this.end();148 } else {149 this.destroy();150 }151};152CryptoStream.prototype.destroy = function(err) {153 if (this.pair._doneFlag) return;154 this.pair.destroy();155};156CryptoStream.prototype._done = function() {157 this._doneFlag = true;158 if (this.pair.cleartext._doneFlag &&159 this.pair.encrypted._doneFlag &&160 !this.pair._doneFlag) {161 // If both streams are done:162 this.pair.destroy();163 }164};165// readyState is deprecated. Don't use it.166Object.defineProperty(CryptoStream.prototype, 'readyState', {167 get: function() {168 if (this._connecting) {169 return 'opening';170 } else if (this.readable && this.writable) {171 return 'open';172 } else if (this.readable && !this.writable) {173 return 'readOnly';174 } else if (!this.readable && this.writable) {175 return 'writeOnly';176 } else {177 return 'closed';178 }179 }180});181// Move decrypted, clear data out into the application.182// From the user's perspective this occurs as a 'data' event183// on the pair.cleartext.184// also185// Move encrypted data to the stream. From the user's perspective this186// occurs as a 'data' event on the pair.encrypted. Usually the application187// will have some code which pipes the stream to a socket:188//189// pair.encrypted.on('data', function (d) {190// socket.write(d);191// });192//193CryptoStream.prototype._push = function() {194 if (this == this.pair.encrypted && !this.writable) {195 // If the encrypted side got EOF, we do not attempt196 // to write out data anymore.197 return;198 }199 while (!this._paused) {200 var bytesRead = 0;201 var chunkBytes = 0;202 var pool = new Buffer(16 * 4096); // alloc every time?203 do {204 chunkBytes = this._pusher(pool, bytesRead, pool.length - bytesRead);205 if (this.pair.ssl && this.pair.ssl.error) {206 this.pair.error();207 return;208 }209 this.pair.maybeInitFinished();210 if (chunkBytes >= 0) {211 bytesRead += chunkBytes;212 }213 } while (chunkBytes > 0 && bytesRead < pool.length);214 assert(bytesRead >= 0);215 // Bail out if we didn't read any data.216 if (bytesRead == 0) {217 if (this._internallyPendingBytes() == 0 && this._destroyAfterPush) {218 this._done();219 }220 return;221 }222 var chunk = pool.slice(0, bytesRead);223 if (this === this.pair.cleartext) {224 debug('cleartext emit "data" with ' + bytesRead + ' bytes');225 } else {226 debug('encrypted emit "data" with ' + bytesRead + ' bytes');227 }228 if (this._decoder) {229 var string = this._decoder.write(chunk);230 if (string.length) this.emit('data', string);231 } else {232 this.emit('data', chunk);233 }234 // Optimization: emit the original buffer with end points235 if (this.ondata) this.ondata(pool, 0, bytesRead);236 }237};238// Push in any clear data coming from the application.239// This arrives via some code like this:240//241// pair.cleartext.write("hello world");242//243// also244//245// Push in incoming encrypted data from the socket.246// This arrives via some code like this:247//248// socket.on('data', function (d) {249// pair.encrypted.write(d)250// });251//252CryptoStream.prototype._pull = function() {253 var havePending = this._pending.length > 0;254 assert(havePending || this._pendingBytes == 0);255 while (this._pending.length > 0) {256 if (!this.pair.ssl) break;257 var tmp = this._pending.shift();258 var cb = this._pendingCallbacks.shift();259 assert(this._pending.length === this._pendingCallbacks.length);260 if (tmp === END_OF_FILE) {261 // Sending EOF262 if (this === this.pair.encrypted) {263 debug('end encrypted ' + this.pair.fd);264 this.pair.cleartext._destroyAfterPush = true;265 } else {266 // CleartextStream267 assert(this === this.pair.cleartext);268 debug('end cleartext');269 this.pair.ssl.shutdown();270 // TODO check if we get EAGAIN From shutdown, would have to do it271 // again. should unshift END_OF_FILE back onto pending and wait for272 // next cycle.273 this.pair.encrypted._destroyAfterPush = true;274 }275 this.pair.cycle();276 this._done()277 return;278 }279 if (tmp.length == 0) continue;280 var rv = this._puller(tmp);281 if (this.pair.ssl && this.pair.ssl.error) {282 this.pair.error();283 return;284 }285 this.pair.maybeInitFinished();286 if (rv === 0 || rv < 0) {287 this._pending.unshift(tmp);288 this._pendingCallbacks.unshift(cb);289 break;290 }291 this._pendingBytes -= tmp.length;292 assert(this._pendingBytes >= 0);293 if (cb) cb();294 assert(rv === tmp.length);295 }296 // If we've cleared all of incoming encrypted data, emit drain.297 if (havePending && this._pending.length === 0) {298 debug('drain');299 this.emit('drain');300 if (this.__destroyOnDrain) this.end();301 }302};303function CleartextStream(pair) {304 CryptoStream.call(this, pair);305}306util.inherits(CleartextStream, CryptoStream);307CleartextStream.prototype._internallyPendingBytes = function() {308 if (this.pair.ssl) {309 return this.pair.ssl.clearPending();310 } else {311 return 0;312 }313};314CleartextStream.prototype._puller = function(b) {315 debug('clearIn ' + b.length + ' bytes');316 return this.pair.ssl.clearIn(b, 0, b.length);317};318CleartextStream.prototype._pusher = function(pool, offset, length) {319 debug('reading from clearOut');320 if (!this.pair.ssl) return -1;321 return this.pair.ssl.clearOut(pool, offset, length);322};323function EncryptedStream(pair) {324 CryptoStream.call(this, pair);325}326util.inherits(EncryptedStream, CryptoStream);327EncryptedStream.prototype._internallyPendingBytes = function() {328 if (this.pair.ssl) {329 return this.pair.ssl.encPending();330 } else {331 return 0;332 }333};334EncryptedStream.prototype._puller = function(b) {335 debug('writing from encIn');336 return this.pair.ssl.encIn(b, 0, b.length);337};338EncryptedStream.prototype._pusher = function(pool, offset, length) {339 debug('reading from encOut');340 if (!this.pair.ssl) return -1;341 return this.pair.ssl.encOut(pool, offset, length);342};343/**344 * Provides a pair of streams to do encrypted communication.345 */346function SecurePair(credentials, isServer, requestCert, rejectUnauthorized) {347 if (!(this instanceof SecurePair)) {348 return new SecurePair(credentials,349 isServer,350 requestCert,351 rejectUnauthorized);352 }353 var self = this;354 events.EventEmitter.call(this);355 this._secureEstablished = false;356 this._isServer = isServer ? true : false;357 this._encWriteState = true;358 this._clearWriteState = true;359 this._doneFlag = false;360 if (!credentials) {361 this.credentials = crypto.createCredentials();362 } else {363 this.credentials = credentials;364 }365 if (!this._isServer) {366 // For clients, we will always have either a given ca list or be using367 // default one368 requestCert = true;369 }370 this._secureEstablished = false;371 this._rejectUnauthorized = rejectUnauthorized ? true : false;372 this._requestCert = requestCert ? true : false;373 this.ssl = new Connection(this.credentials.context,374 this._isServer ? true : false,375 this._requestCert,376 this._rejectUnauthorized);377 /* Acts as a r/w stream to the cleartext side of the stream. */378 this.cleartext = new CleartextStream(this);379 /* Acts as a r/w stream to the encrypted side of the stream. */380 this.encrypted = new EncryptedStream(this);381 process.nextTick(function() {382 /* The Connection may be destroyed by an abort call */383 if (self.ssl) {384 self.ssl.start();385 }386 self.cycle();387 });388}389util.inherits(SecurePair, events.EventEmitter);390exports.createSecurePair = function(credentials,391 isServer,392 requestCert,393 rejectUnauthorized) {394 var pair = new SecurePair(credentials,395 isServer,396 requestCert,397 rejectUnauthorized);398 return pair;399};400/* Attempt to cycle OpenSSLs buffers in various directions.401 *402 * An SSL Connection can be viewed as four separate piplines,403 * interacting with one has no connection to the behavoir of404 * any of the other 3 -- This might not sound reasonable,405 * but consider things like mid-stream renegotiation of406 * the ciphers.407 *408 * The four pipelines, using terminology of the client (server is just409 * reversed):410 * (1) Encrypted Output stream (Writing encrypted data to peer)411 * (2) Encrypted Input stream (Reading encrypted data from peer)412 * (3) Cleartext Output stream (Decrypted content from the peer)413 * (4) Cleartext Input stream (Cleartext content to send to the peer)414 *415 * This function attempts to pull any available data out of the Cleartext416 * input stream (4), and the Encrypted input stream (2). Then it pushes any417 * data available from the cleartext output stream (3), and finally from the418 * Encrypted output stream (1)419 *420 * It is called whenever we do something with OpenSSL -- post reciving421 * content, trying to flush, trying to change ciphers, or shutting down the422 * connection.423 *424 * Because it is also called everywhere, we also check if the connection has425 * completed negotiation and emit 'secure' from here if it has.426 */427SecurePair.prototype.cycle = function(depth) {428 if (this._doneFlag) return;429 depth = depth ? depth : 0;430 if (depth == 0) this._writeCalled = false;431 var established = this._secureEstablished;432 if (!this.cycleEncryptedPullLock) {433 this.cycleEncryptedPullLock = true;434 debug("encrypted._pull");435 this.encrypted._pull();436 this.cycleEncryptedPullLock = false;437 }438 if (!this.cycleCleartextPullLock) {439 this.cycleCleartextPullLock = true;440 debug("cleartext._pull");441 this.cleartext._pull();442 this.cycleCleartextPullLock = false;443 }444 if (!this.cycleCleartextPushLock) {445 this.cycleCleartextPushLock = true;446 debug("cleartext._push");447 this.cleartext._push();448 this.cycleCleartextPushLock = false;449 }450 if (!this.cycleEncryptedPushLock) {451 this.cycleEncryptedPushLock = true;452 debug("encrypted._push");453 this.encrypted._push();454 this.cycleEncryptedPushLock = false;455 }456 if ((!established && this._secureEstablished) ||457 (depth == 0 && this._writeCalled)) {458 // If we were not established but now we are, let's cycle again.459 // Or if there is some data to write...460 this.cycle(depth + 1);461 }462};463SecurePair.prototype.maybeInitFinished = function() {464 if (this.ssl && !this._secureEstablished && this.ssl.isInitFinished()) {465 this._secureEstablished = true;466 debug('secure established');467 this.emit('secure');468 }469};470SecurePair.prototype.destroy = function() {471 var self = this;472 if (!this._doneFlag) {473 this._doneFlag = true;474 this.ssl.error = null;475 this.ssl.close();476 this.ssl = null;477 self.encrypted.writable = self.encrypted.readable = false;478 self.cleartext.writable = self.cleartext.readable = false;479 process.nextTick(function() {480 self.encrypted.emit('close');481 self.cleartext.emit('close');482 });483 }484};485SecurePair.prototype.error = function() {486 if (!this._secureEstablished) {487 this.destroy();488 } else {489 var err = this.ssl.error;490 this.ssl.error = null;491 if (this._isServer &&492 this._rejectUnauthorized &&493 /peer did not return a certificate/.test(err.message)) {494 // Not really an error.495 this.destroy();496 } else {497 this.cleartext.emit('error', err);498 }499 }500};501// TODO: support anonymous (nocert) and PSK502// AUTHENTICATION MODES503//504// There are several levels of authentication that TLS/SSL supports.505// Read more about this in "man SSL_set_verify".506//507// 1. The server sends a certificate to the client but does not request a508// cert from the client. This is common for most HTTPS servers. The browser509// can verify the identity of the server, but the server does not know who510// the client is. Authenticating the client is usually done over HTTP using511// login boxes and cookies and stuff.512//513// 2. The server sends a cert to the client and requests that the client514// also send it a cert. The client knows who the server is and the server is515// requesting the client also identify themselves. There are several516// outcomes:517//518// A) verifyError returns null meaning the client's certificate is signed519// by one of the server's CAs. The server know's the client idenity now520// and the client is authorized.521//522// B) For some reason the client's certificate is not acceptable -523// verifyError returns a string indicating the problem. The server can524// either (i) reject the client or (ii) allow the client to connect as an525// unauthorized connection.526//527// The mode is controlled by two boolean variables.528//529// requestCert530// If true the server requests a certificate from client connections. For531// the common HTTPS case, users will want this to be false, which is what532// it defaults to.533//534// rejectUnauthorized535// If true clients whose certificates are invalid for any reason will not536// be allowed to make connections. If false, they will simply be marked as537// unauthorized but secure communication will continue. By default this is538// false.539//540//541//542// Options:543// - requestCert. Send verify request. Default to false.544// - rejectUnauthorized. Boolean, default to false.545// - key. string.546// - cert: string.547// - ca: string or array of strings.548//549// emit 'secureConnection'550// function (cleartextStream, encryptedStream) { }551//552// 'cleartextStream' has the boolean property 'authorized' to determine if553// it was verified by the CA. If 'authorized' is false, a property554// 'authorizationError' is set on cleartextStream and has the possible555// values:556//557// "UNABLE_TO_GET_ISSUER_CERT", "UNABLE_TO_GET_CRL",558// "UNABLE_TO_DECRYPT_CERT_SIGNATURE", "UNABLE_TO_DECRYPT_CRL_SIGNATURE",559// "UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY", "CERT_SIGNATURE_FAILURE",560// "CRL_SIGNATURE_FAILURE", "CERT_NOT_YET_VALID" "CERT_HAS_EXPIRED",561// "CRL_NOT_YET_VALID", "CRL_HAS_EXPIRED" "ERROR_IN_CERT_NOT_BEFORE_FIELD",562// "ERROR_IN_CERT_NOT_AFTER_FIELD", "ERROR_IN_CRL_LAST_UPDATE_FIELD",563// "ERROR_IN_CRL_NEXT_UPDATE_FIELD", "OUT_OF_MEM",564// "DEPTH_ZERO_SELF_SIGNED_CERT", "SELF_SIGNED_CERT_IN_CHAIN",565// "UNABLE_TO_GET_ISSUER_CERT_LOCALLY", "UNABLE_TO_VERIFY_LEAF_SIGNATURE",566// "CERT_CHAIN_TOO_LONG", "CERT_REVOKED" "INVALID_CA",567// "PATH_LENGTH_EXCEEDED", "INVALID_PURPOSE" "CERT_UNTRUSTED",568// "CERT_REJECTED"569//570//571// TODO:572// cleartext.credentials (by mirroring from pair object)573// cleartext.getCertificate() (by mirroring from pair.credentials.context)574function Server(/* [options], listener */) {575 var options, listener;576 if (typeof arguments[0] == 'object') {577 options = arguments[0];578 listener = arguments[1];579 } else if (typeof arguments[0] == 'function') {580 options = {};581 listener = arguments[0];582 }583 if (!(this instanceof Server)) return new Server(options, listener);584 var self = this;585 // Handle option defaults:586 this.setOptions(options);587 var sharedCreds = crypto.createCredentials({588 key: self.key,589 cert: self.cert,590 ca: self.ca,591 ciphers: self.ciphers,592 secureProtocol: self.secureProtocol,593 crl: self.crl594 });595 sharedCreds.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');596 // constructor call597 net.Server.call(this, function(socket) {598 var creds = crypto.createCredentials(null, sharedCreds.context);599 var pair = new SecurePair(creds,600 true,601 self.requestCert,602 self.rejectUnauthorized);603 var cleartext = pipe(pair, socket);604 cleartext._controlReleased = false;605 pair.on('secure', function() {606 pair.cleartext.authorized = false;607 if (!self.requestCert) {608 cleartext._controlReleased = true;609 self.emit('secureConnection', pair.cleartext, pair.encrypted);610 } else {611 var verifyError = pair.ssl.verifyError();612 if (verifyError) {613 pair.cleartext.authorizationError = verifyError;614 if (self.rejectUnauthorized) {615 socket.destroy();616 pair.destroy();617 } else {618 cleartext._controlReleased = true;619 self.emit('secureConnection', pair.cleartext, pair.encrypted);620 }621 } else {622 pair.cleartext.authorized = true;623 cleartext._controlReleased = true;624 self.emit('secureConnection', pair.cleartext, pair.encrypted);625 }626 }627 });628 });629 if (listener) {630 this.on('secureConnection', listener);631 }632 // Handle option defaults:633 this.setOptions(options);634}635util.inherits(Server, net.Server);636exports.Server = Server;637exports.createServer = function(options, listener) {638 return new Server(options, listener);639};640Server.prototype.setOptions = function(options) {641 if (typeof options.requestCert == 'boolean') {642 this.requestCert = options.requestCert;643 } else {644 this.requestCert = false;645 }646 if (typeof options.rejectUnauthorized == 'boolean') {647 this.rejectUnauthorized = options.rejectUnauthorized;648 } else {649 this.rejectUnauthorized = false;650 }651 if (options.key) this.key = options.key;652 if (options.cert) this.cert = options.cert;653 if (options.ca) this.ca = options.ca;654 if (options.secureProtocol) this.secureProtocol = options.secureProtocol;655 if (options.crl) this.crl = options.crl;656};657// Target API:658//659// var s = tls.connect(8000, "google.com", options, function() {660// if (!s.authorized) {661// s.destroy();662// return;663// }664//665// // s.socket;666//667// s.end("hello world\n");668// });669//670//671// TODO: make port, host part of options!672exports.connect = function(port /* host, options, cb */) {673 // parse args674 var host, options = {}, cb;675 for (var i = 1; i < arguments.length; i++) {676 switch (typeof arguments[i]) {677 case 'string':678 host = arguments[i];679 break;680 case 'object':681 options = arguments[i];682 break;683 case 'function':684 cb = arguments[i];685 break;686 }687 }688 var socket = new net.Stream();689 var sslcontext = crypto.createCredentials(options);690 //sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');691 var pair = new SecurePair(sslcontext, false);692 var cleartext = pipe(pair, socket);693 socket.connect(port, host);694 pair.on('secure', function() {695 var verifyError = pair.ssl.verifyError();696 if (verifyError) {697 cleartext.authorized = false;698 cleartext.authorizationError = verifyError;699 } else {700 cleartext.authorized = true;701 }702 if (cb) cb();703 });704 cleartext._controlReleased = true;705 return cleartext;706};707function pipe(pair, socket) {708 pair.encrypted.pipe(socket);709 socket.pipe(pair.encrypted);710 pair.fd = socket.fd;711 var cleartext = pair.cleartext;712 cleartext.socket = socket;713 cleartext.encrypted = pair.encrypted;714 cleartext.authorized = false;715 function onerror(e) {716 if (cleartext._controlReleased) {717 cleartext.emit('error', e);718 }719 }720 function onclose() {721 socket.removeListener('error', onerror);722 socket.removeListener('close', onclose);723 socket.removeListener('timeout', ontimeout);724 }725 function ontimeout() {726 cleartext.emit('timeout');727 }728 socket.on('error', onerror);729 socket.on('close', onclose);730 socket.on('timeout', ontimeout);731 return cleartext;...
Using AI Code Generation
1var clearText = root.clearText;2var clearText = root.clearText;3var clearText = root.clearText;4var clearText = root.clearText;5var clearText = root.clearText;6var clearText = root.clearText;7var clearText = root.clearText;8var clearText = root.clearText;9var clearText = root.clearText;10var clearText = root.clearText;11var clearText = root.clearText;12var clearText = root.clearText;13var clearText = root.clearText;14var clearText = root.clearText;
Using AI Code Generation
1var clearText = root.clearText;2clearText("Hello World");3var clearText = root.clearText;4clearText("Hello World");5var clearText = root.clearText;6clearText("Hello World");7var clearText = root.clearText;8clearText("Hello World");9var clearText = root.clearText;10clearText("Hello World");11var clearText = root.clearText;12clearText("Hello World");13var clearText = root.clearText;14clearText("Hello World");15var clearText = root.clearText;16clearText("Hello World");17var clearText = root.clearText;18clearText("Hello World");19var clearText = root.clearText;20clearText("Hello World");21var clearText = root.clearText;22clearText("Hello World");23var clearText = root.clearText;24clearText("Hello World");25var clearText = root.clearText;26clearText("Hello World");27var clearText = root.clearText;28clearText("Hello World");29var clearText = root.clearText;30clearText("Hello World");31var clearText = root.clearText;32clearText("Hello World");33var clearText = root.clearText;34clearText("Hello World");35var clearText = root.clearText;36clearText("Hello World");
Using AI Code Generation
1var root = document.getElementById("root");2root.clearText();3root.clearText();4var root = document.getElementById("root");5root.clearText();6root.clearText();
Using AI Code Generation
1var root = require('root');2root.clearText();3exports.clearText = function() {4}5var root = require('root');6root.clearText();7var clearText = function() {8}9exports.clearText = clearText;10var root = require('root');11root.clearText();12module.exports = {13 clearText: function() {14 }15}16var root = require('root');17root.clearText();
Using AI Code Generation
1var root = require('root');2root.clearText();3exports.clearText = function() {4 console.log('clearText method called');5};6var root = require('root');7root.clearText();8exports.clearText = function() {9 console.log('clearText method called');10};11var root = require('root');12root.clearText();13exports.clearText = function() {14 console.log('clearText method called');15};16var root = require('root');17root.clearText();18exports.clearText = function() {19 console.log('clearText method called');20};21var root = require('root');22root.clearText();23exports.clearText = function() {24 console.log('clearText method called');25};26var root = require('root');27root.clearText();28exports.clearText = function() {29 console.log('clearText method called');30};31var root = require('root');32root.clearText();33exports.clearText = function() {34 console.log('clearText method called');35};36var root = require('root');37root.clearText();38exports.clearText = function() {39 console.log('clearText method called');40};41var root = require('root');42root.clearText();
Using AI Code Generation
1var clearText = root.clearText;2clearText("Hello World");3module.exports = {4 clearText: function (text) {5 console.log(text);6 }7};8var clearText = function (text) {9 console.log(text);10}11module.exports = {12};13var clearText = function (text) {14 console.log(text);15}16module.exports = {17};18var clearText = function (text) {19 console.log(text);20}21module.exports = {22};23var clearText = function (text) {24 console.log(text);25}26module.exports = {27};
Using AI Code Generation
1var root = require('./root');2var clearText = root.clearText;3console.log(clearText('I am a secret'));4var root = require('./root');5var clearText = root.clearText;6console.log(clearText('I am a secret'));7var root = require('./root');8var clearText = root.clearText;9console.log(clearText('I am a secret'));10var root = require('./root');11var clearText = root.clearText;12console.log(clearText('I am a secret'));13var root = require('./root');14var clearText = root.clearText;15console.log(clearText('I am a secret'));16var root = require('./root');17var clearText = root.clearText;18console.log(clearText('I am a secret'));19var root = require('./root');20var clearText = root.clearText;21console.log(clearText('I am a secret'));22var root = require('./root');23var clearText = root.clearText;24console.log(clearText('I am a secret'));25var root = require('./root');26var clearText = root.clearText;27console.log(clearText('I am a secret'));28var root = require('./root');29var clearText = root.clearText;30console.log(clearText('I am a secret'));31var root = require('./root');32var clearText = root.clearText;33console.log(clearText('I am a secret'));34var root = require('./root');35var clearText = root.clearText;36console.log(clearText('I am a
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!