How to use importKeys method in wpt

Best JavaScript code snippet using wpt

JWKSetSpec.js

Source:JWKSetSpec.js Github

copy

Full Screen

...146 afterEach(() => {147 JWKSet.prototype.importKeys.restore()148 })149 it('should return a promise', () => {150 return JWKSet.importKeys().should.be.fulfilled151 })152 it('should resolve a JWKSet', () => {153 return JWKSet.importKeys().should.eventually.be.a.instanceOf(JWKSet)154 })155 it('should defer to member importKeys', () => {156 return JWKSet.importKeys(ECDSAKeyGenDescriptor).then(jwks => {157 jwks.importKeys.should.be.calledWith(ECDSAKeyGenDescriptor)158 })159 })160 it('should reject if importKeys rejects', () => {161 JWKSet.prototype.importKeys.restore()162 sinon.stub(JWKSet.prototype, 'importKeys').rejects()163 return JWKSet.importKeys().should.be.rejected164 })165 })166 describe('member', () => {167 let jwks168 let meta = 'abc'169 beforeEach(() => {170 jwks = new JWKSet()171 })172 it('should return a promise', () => {173 return jwks.importKeys(ECPrivateJWK).should.be.fulfilled174 })175 it('should reject on invalid input', () => {176 return jwks.importKeys(null).should.be.rejected177 })178 describe('with array input', () => {179 it('should resolve an array of imported JWKs', () => {180 return jwks.importKeys([ECPrivateJWK]).then(keys => {181 keys.length.should.equal(1)182 keys[0].should.be.an.instanceOf(JWK)183 })184 })185 it('should resolve empty array with empty input', () => {186 return jwks.importKeys([]).then(keys => {187 keys.length.should.equal(0)188 })189 })190 it('should reject with invalid input', () => {191 return jwks.importKeys([null]).should.be.rejected192 })193 it('should reject if at least one array item is invalid input', () => {194 return jwks.importKeys([ECPrivateJWK, null]).should.be.rejected195 })196 })197 describe('with stringified JSON input', () => {198 it('should resolve the imported JWK', () => {199 return jwks.importKeys(JSON.stringify(ECPrivateJWK)).then(key => {200 key.should.be.a.instanceOf(JWK)201 })202 })203 it('should reject with invalid JSON input', () => {204 return jwks.importKeys('{invalid').should.be.rejected205 })206 it('should reject with invalid JWK', () => {207 return jwks.importKeys('{}').should.be.rejected208 })209 it('should accept a JSON array', () => {210 return jwks.importKeys(JSON.stringify([ECPrivateJWK, ECPublicJWK])).then(keys => {211 keys.length.should.equal(2)212 keys[0].should.be.an.instanceOf(JWK)213 })214 })215 })216 describe('with jwks url input', () => {217 let jwks_endpoint218 before(() => {219 jwks_endpoint = nock('http://idp.example.com')220 .get('/jwks')221 .reply(200, { keys: [ECPublicJWK] })222 })223 it('should resolve the array of imported JWKs', () => {224 return jwks.importKeys('http://idp.example.com/jwks').then(keys => {225 expect(Array.isArray(keys)).to.be.true226 keys[0].should.be.an.instanceOf(JWK)227 })228 })229 it('should reject with invalid url', () => {230 return jwks.importKeys('http://localhost:4200/a/b/c').should.be.rejected231 })232 })233 describe('with file path input', () => {234 it('with JWK content should resolve the imported JWK', () => {235 return jwks.importKeys(path.join(cwd, 'test', 'file_import', 'fileImportJWKTestData.json')).then(jwk => {236 jwk.should.be.an.instanceOf(JWK)237 })238 })239 it('with JWKSet content should resolve the array of imported JWKs', () => {240 return jwks.importKeys(path.join(cwd, 'test', 'file_import', 'fileImportJWKSetTestData.json')).then(keys => {241 keys.length.should.equal(1)242 keys[0].should.be.an.instanceOf(JWK)243 })244 })245 it('should reject with invalid file contents', () => {246 return jwks.importKeys(path.join(cwd, 'test', 'file_import', 'fileImportInvalidTestData.json')).should.be.rejected247 })248 it('should reject with invalid file path', () => {249 return jwks.importKeys('invalid').should.be.rejected250 })251 })252 describe('with JWKSet object input', () => {253 it('should resolve the array of imported JWKs', () => {254 return jwks.importKeys({ keys: [ECPrivateJWK, ECPublicJWK] }).then(keys => {255 keys.length.should.equal(2)256 keys[0].should.be.an.instanceOf(JWK)257 })258 })259 it('should retain non-standard metadata on the JWKSet', () => {260 return jwks.importKeys({ meta, keys: [ECPrivateJWK, ECPublicJWK] }).then(() => {261 jwks.meta.should.equal(meta)262 })263 })264 })265 })266 })267 describe('filter', () => {268 let jwks269 before(() => {270 return JWKSet.importKeys([ECPrivateJWK, ECPublicJWK]).then(keys => jwks = keys)271 })272 it('should return an array', () => {273 expect(Array.isArray(jwks.filter(() => false))).to.be.true274 })275 describe('with function predicate', () => {276 it('should return an array of JWKs', () => {277 let keys = jwks.filter(key => key.key_ops.includes('sign'))278 keys.length.should.equal(1)279 keys[0].should.be.an.instanceOf(JWK)280 })281 it('should throw if predicate function is malformed', () => {282 expect(() => jwks.filter(key => key.a.b.c)).to.throw283 })284 })285 describe('with object predicate', () => {286 it('should return an array of JWKs', () => {287 let privateKeys = jwks.filter({ key_ops: 'sign' })288 privateKeys.length.should.equal(1)289 privateKeys[0].should.be.an.instanceOf(JWK)290 let ellipticKeys = jwks.filter({ kty: 'EC' })291 ellipticKeys.length.should.equal(2)292 ellipticKeys[0].should.be.an.instanceOf(JWK)293 })294 it('should throw if predicate object is malformed', () => {295 expect(() => jwks.filter('invalid')).to.throw('Invalid predicate')296 })297 })298 })299 describe('find', () => {300 let jwks301 before(() => {302 return JWKSet.importKeys([ECPrivateJWK, ECPublicJWK]).then(keys => jwks = keys)303 })304 describe('with function predicate', () => {305 it('should return a JWK', () => {306 let jwk = jwks.find(key => true)307 jwk.should.be.an.instanceOf(JWK)308 })309 it('should throw if predicate function is malformed', () => {310 expect(() => jwks.find(key => key.a.b.c)).to.throw311 })312 })313 describe('with object predicate', () => {314 it('should return a JWK', () => {315 let jwk = jwks.find({ key_ops: 'sign' })316 jwk.should.be.an.instanceOf(JWK)317 })318 it('should throw if predicate object is malformed', () => {319 expect(() => jwks.find('invalid')).to.throw('Invalid predicate')320 })321 })322 })323 describe('rotate', () => {324 let jwks = new JWKSet()325 // Placeholder test326 it('should resolve the JWKSet', () => {327 return jwks.rotate().should.eventually.be.an.instanceOf(JWKSet)328 })329 })330 describe('exportKeys', () => {331 let jwks = new JWKSet()332 it('should return a string', () => {333 return jwks.exportKeys().should.be.a('string')334 })335 })336 describe('publicJwks', () => {337 let jwks338 before(() => {339 return JWKSet.importKeys([ECPrivateJWK, ECPublicJWK]).then(keys => jwks = keys)340 })341 it('should return a valid JSON string', () => {342 expect(() => JSON.parse(jwks.publicJwks)).to.not.throw343 })344 it('should include JWKSet metadata', () => {345 jwks.meta = 'abc'346 let json = JSON.parse(jwks.publicJwks)347 json.meta.should.equal('abc')348 })349 })...

Full Screen

Full Screen

ImportKeysForm.js

Source:ImportKeysForm.js Github

copy

Full Screen

1import React, { Component } from "react";2import { FormattedMessage as T } from "react-intl";3import { shell } from "electron";4import { KeyBlueButton, SeedDisplayButton } from "buttons";5import { TextInput } from "inputs";6import { createWallet } from "connectors";7import CreatePassPhrase from "../CreateWalletForm/CreatePassPhrase";8import { ImportKeysFormTypes } from "../../types";9import "style/ImportKeysForm.less";10@autobind11class ImportKeysForm extends Component {12 static propTypes = ImportKeysFormTypes;13 constructor(props) {14 super(props);15 this.state = this.getInitialState();16 }17 getInitialState() {18 return {19 passPhrase: "",20 copayPassphrase: "",21 seedHex: "",22 showDecryptedMnemonic: false,23 createWalletError: ""24 };25 }26 componentDidMount() {27 this.generateSeed();28 }29 resetFormState() {30 const { validator, decryptor, fileHandler } = this.props;31 this.setState(() => this.getInitialState());32 validator.resetErrorMessage();33 decryptor.resetState();34 fileHandler.resetState();35 }36 toggleDecryptedMnemonicVisibility() {37 this.setState({ showDecryptedMnemonic: !this.state.showDecryptedMnemonic });38 }39 componentDidUpdate(prevProps) {40 const { mnemonic } = this.props;41 if (prevProps.mnemonic.length < 12 && mnemonic.length >= 12) {42 this.decodeMnemonic();43 }44 }45 async decodeMnemonic() {46 const { mnemonic } = this.props;47 const { copayPassphrase, decode } = this.state;48 const decoded = await decode(mnemonic.join(" "), copayPassphrase);49 this.setState({ seedHex: Buffer.from(decoded.getDecodedSeed()).toString("hex") });50 }51 async onCreateWallet() {52 if (!this.isValid()) {53 return;54 }55 const { createWalletRequest, mnemonic } = this.props;56 const { passPhrase, copayPassphrase, decode } = this.state;57 const mnemonicStr = mnemonic.join(" ");58 if (mnemonic.length) {59 try {60 const decoded = await decode(mnemonicStr, copayPassphrase);61 createWalletRequest("", passPhrase, decoded.getDecodedSeed(), true);62 } catch (e) {63 this.setState({ createWalletError: e });64 }65 }66 }67 setPassPhrase(passPhrase) {68 this.setState({ passPhrase });69 }70 onCopayPasswordChange(e) {71 this.setState({ copayPassphrase: e.target.value });72 }73 generateSeed() {74 return this.props.seedService.then(({ generate, decode }) =>75 generate().then(() => {76 this.setState({77 decode78 });79 })80 );81 }82 isValid() {83 const { mnemonic, mnemonicHasPassphrase } = this.props;84 const { passPhrase, copayPassphrase } = this.state;85 const mnemonicNotEmpty = mnemonic.length >= 12;86 if (mnemonicHasPassphrase) {87 return Boolean(mnemonicNotEmpty && passPhrase && copayPassphrase);88 }89 return Boolean(mnemonicNotEmpty && passPhrase);90 }91 render() {92 const {93 decryptor,94 fileHandler,95 mnemonic,96 mnemonicHasPassphrase,97 errorMessage,98 selectedFileName,99 encryptedString,100 encryptionPassword,101 onReturnToExistingOrNewScreen,102 isCreatingWallet103 } = this.props;104 const hasMnemonic = Boolean(mnemonic.length);105 const isValid = this.isValid();106 return (107 <div className="import-keys-wrapper">108 <div className="create-wallet-go-back">109 <div className="create-wallet-go-back-button" onClick={onReturnToExistingOrNewScreen} />110 </div>111 <h2>112 <T id="wallet.importKeys.title" m="Import keys from Copay wallet" />113 </h2>114 <div>115 <T116 id="wallet.importKeys.tutorial.info"117 m="If you need more comprehensive guide on importing keys from Copay wallet, you can check it"118 />{" "}119 <span120 className="import-keys-tutorial-link"121 onClick={() =>122 shell.openExternal("https://support.excc.co/hc/en-us/articles/360006702912")123 }>124 <T id="wallet.importKeys.tutorial.link" m="here" />125 </span>126 </div>127 <h3>128 <T id="wallet.importKeys.step1.title" m="1. Export from Copay" />129 </h3>130 <ul>131 <li>132 <T133 id="wallet.importKeys.step1.listItem1"134 m="You can import keys with file only through exporting from Copay wallet"135 />136 </li>137 <li>138 <T139 id="wallet.importKeys.step1.listItem2"140 m="Go to Settings -> Wallets -> Choose your wallet -> More Options -> Export Wallet ->141 File/Text"142 />143 </li>144 <li>145 <T id="wallet.importKeys.step1.listItem3" m="Set up encryption password" />146 </li>147 <li>148 <T149 id="wallet.importKeys.step1.listItem4"150 m="Download the file - save it as '.json' file"151 />152 </li>153 <li>154 <T155 id="wallet.importKeys.step1.listItem5"156 m="Once the file is saved, you can move to step 2"157 />158 </li>159 </ul>160 <h3>161 <T id="wallet.importKeys.step2.title" m="2. Upload file" />162 </h3>163 <div className="keys-import-upload-section">164 {encryptedString ? (165 <button className="key-blue-button" onClick={this.resetFormState}>166 <strong>167 {" "}168 <T id="wallet.importKeys.button.clear" m="Clear" />169 </strong>170 </button>171 ) : (172 <label htmlFor="keys-import-file-upload" className="key-blue-button">173 <strong>174 <T id="wallet.importKeys.button.upload" m="Upload file" />175 </strong>176 </label>177 )}178 <input179 type="file"180 id="keys-import-file-upload"181 name="file"182 onChange={fileHandler.onFileChange}183 />184 <div className="keys-import-selected-file-section">185 {selectedFileName && (186 <h3>187 <T id="wallet.importKeys.selectedFileInfo" m="Selected file" />188 </h3>189 )}190 {selectedFileName}191 </div>192 <div className="keys-import-error-message">{errorMessage}</div>193 </div>194 {encryptedString && (195 <div className="keys-import-decryption-section">196 <h3>197 <T id="wallet.importKeys.step3.title" m="3. Type your encryption password" />198 </h3>199 <TextInput200 type="password"201 className="keys-import-decryption-password-input"202 value={encryptionPassword}203 onChange={decryptor.onPasswordChange}204 placeholder="Password"205 />206 <KeyBlueButton onClick={decryptor.decrypt} disabled={!encryptionPassword}>207 <strong>208 <T id="wallet.importkeys.decryptButton" m="Decrypt" />209 </strong>210 </KeyBlueButton>211 </div>212 )}213 {hasMnemonic && (214 <div className="keys-import-mnemonic-section">215 <h3>216 <T id="wallet.importKeys.step4.title" m="4. Confirm decrypted data" />217 </h3>218 <div>219 {mnemonicHasPassphrase && (220 <React.Fragment>221 <h4>222 <T223 id="wallet.importKeys.mnemonicPassphraseLabel"224 m="It seems that your mnemonic was encrypted by passphrase, please provide it below."225 />226 </h4>227 <div className="keys-import-mnemonic-passphrase-input">228 <TextInput229 type="password"230 value={this.state.copayPassphrase}231 onChange={this.onCopayPasswordChange}232 onBlur={this.decodeMnemonic}233 placeholder="Mnemonic passphrase (optional)"234 />235 </div>236 </React.Fragment>237 )}238 </div>239 <div>240 <SeedDisplayButton241 mnemonic={mnemonic}242 seedHex={this.state.seedHex}243 buttonLabel={244 <strong>245 <T id="wallet.importkeys.showMnemonic" m="Show mnemonic" />246 </strong>247 }248 />249 </div>250 </div>251 )}252 {hasMnemonic && (253 <div className="keys-import-mnemonic-section">254 <h3>255 <T id="wallet.importKeys.step5.title" m="5. Set new wallet passphrase" />256 </h3>257 <CreatePassPhrase onChange={this.setPassPhrase} onSubmit={this.onCreateWallet} />258 </div>259 )}260 {hasMnemonic && (261 <KeyBlueButton262 className="wallet-key-blue-button"263 disabled={!isValid || isCreatingWallet}264 loading={isCreatingWallet}265 onClick={this.onCreateWallet}>266 <strong>267 {" "}268 <T id="createWallet.createWalletBtn" m="Create Wallet" />{" "}269 </strong>270 </KeyBlueButton>271 )}272 <div className="keys-import-error-message">{this.state.createWalletError}</div>273 </div>274 );275 }276}...

Full Screen

Full Screen

181475.user.js

Source:181475.user.js Github

copy

Full Screen

1// ==UserScript==2// @id iitc-plugin-keys-import@dnc3// @name IITC plugin: Import keys4// @category Keys5// @version 0.1.0.@@DATETIMEVERSION@@6// @namespace https://github.com/jonatkins/ingress-intel-total-conversion7// @updateURL http://userscripts.org/scripts/source/181475.user.js8// @downloadURL http://userscripts.org/scripts/source/181475.user.js9// @description [@@BUILDNAME@@-@@BUILDDATE@@] Import the list of portal keys from your inventory. Install the 'Keys' plugin first.10// @include https://www.ingress.com/intel*11// @include http://www.ingress.com/intel*12// @include https://m-dot-betaspike.appspot.com/handshake*13// @match https://www.ingress.com/intel*14// @match http://www.ingress.com/intel*15// @match https://m-dot-betaspike.appspot.com/handshake*16// @grant none17// ==/UserScript==1819function wrapper() {20// ensure plugin framework is there, even if iitc is not yet loaded21if(typeof window.plugin !== 'function') window.plugin = function() {};222324// PLUGIN START ////////////////////////////////////////////////////////2526// use own namespace for plugin27window.plugin.importkeys = function() {};2829window.plugin.importkeys.APPSPOT_URL = 'https://m-dot-betaspike.appspot.com';3031window.plugin.importkeys._dialog = null;3233window.plugin.importkeys.messageCallback = function(event) {34 if (event.origin !== window.plugin.importkeys.APPSPOT_URL) {35 return;36 }37 try {38 var object = window.JSON.parse(event.data);39 localStorage[window.plugin.keys.LOCAL_STORAGE_KEY] = event.data;40 if (window.plugin.importkeys._dialog) {41 $(window.plugin.importkeys._dialog).dialog('close');42 window.plugin.importkeys._dialog = null;43 }44 window.plugin.keys.keys = object['keys'];45 window.plugin.keys.updateDisplayCount();46 window.runHooks('pluginKeysRefreshAll');47 alert('Inventory import was successful');48 } catch (e) {49 alert('There was an error parsing the inventory data\n' + e);50 }51};5253window.plugin.importkeys.openDialog = function(event) {54 if (!window.plugin.keys) {55 alert('Error: The Keys plugin must be installed before using the Import Keys plugin');56 return;57 }58 if (window.plugin.importkeys._dialog) {59 return;60 }61 var handshakeUrl = window.plugin.importkeys.APPSPOT_URL + '/handshake?json='62 + encodeURIComponent(window.JSON.stringify({'nemesisSoftwareVersion': '2013-10-15T22:32:58Z 438a6fac0786 opt', 'deviceSoftwareVersion': '4.1.1'}));63 var div = document.createElement('div');64 var span = document.createElement('span');65 span.appendChild(document.createTextNode('Log in below to import your Ingress inventory. (Or try again in a '));66 var a = document.createElement('a');67 a.appendChild(document.createTextNode('new window'));68 a.setAttribute('href', handshakeUrl);69 a.setAttribute('target', '_blank');70 span.appendChild(a);71 span.appendChild(document.createTextNode(')'));72 div.appendChild(span);73 var br = document.createElement('br');74 div.appendChild(br);75 var iframe = document.createElement('iframe');76 iframe.style.width = '300px';77 iframe.style.height = '200px';78 iframe.setAttribute('src', handshakeUrl);79 div.appendChild(iframe);80 var html = div.innerHTML;81 var dialog = window.dialog({82 html: html,83 title: 'Import Keys',84 dialogClass: 'ui-dialog-import-keys',85 id: 'import-keys-dialog',86 closeCallback: function() {87 window.plugin.importkeys._dialog = null;88 }89 });90 window.plugin.importkeys._dialog = dialog;91}9293var setup = function() {94 $('head').append('<style>' +95 '.ui-dialog-import-keys { max-width: 800px !important; width: auto !important; }' +96 '</style>');97 window.addEventListener('message', window.plugin.importkeys.messageCallback, false);98 var a = document.createElement('a');99 a.appendChild(document.createTextNode('Import keys'));100 a.setAttribute('title', 'Import all the portal keys from your Ingress inventory');101 a.addEventListener('click', window.plugin.importkeys.openDialog, false);102 document.getElementById('toolbox').appendChild(a);103};104105// PLUGIN END //////////////////////////////////////////////////////////106107if(window.iitcLoaded && typeof setup === 'function') {108 setup();109} else {110 if(window.bootPlugins)111 window.bootPlugins.push(setup);112 else113 window.bootPlugins = [setup];114}115} // wrapper end116// inject code into site context117var script = document.createElement('script');118script.appendChild(document.createTextNode('('+ wrapper +')();'));119(document.body || document.head || document.documentElement).appendChild(script);120121// The code below needs to be run on the m-dot-betaspike.appspot.com domain.122// As such, it needs to be outside of the standard IITC plugin wrapper.123(function(){124function inventoryCallback(event)125{126 if (event.target.readyState == 4) {127 if (event.target.status == 200) {128 var json_text = event.target.response;129 var result = window.JSON.parse(json_text);130 var inventory = result['gameBasket']['inventory'];131 var hash = {};132 for (var i = 0; i < inventory.length; i++) {133 if (inventory[i][2]['portalCoupler']) {134 var guid = inventory[i][2]['portalCoupler']['portalGuid'];135 if (hash[guid]) {136 hash[guid]++;137 } else {138 hash[guid] = 1;139 }140 }141 }142 var json_out = window.JSON.stringify({'keys':hash});143 window.top.postMessage(json_out, 'http://www.ingress.com/');144 window.top.postMessage(json_out, 'https://www.ingress.com/');145 } else {146 alert('An error was received from the server\n' + event.target.status + ' ' + event.target.statusText);147 }148 }149}150151if (window.location.host == 'm-dot-betaspike.appspot.com') {152 if (window.location.pathname == '/handshake') {153 var xsrf;154 var re_match = document.body.innerHTML.match(/"xsrfToken":"((?:\\"|[^"])*)"/);155 if (!re_match) {156 alert("Error: Couldn't parse XSRF Token from Ingress handshake reply");157 xsrf = '';158 } else {159 xsrf = re_match[1];160 }161 var xhr = new XMLHttpRequest();162 var url = 'https://m-dot-betaspike.appspot.com/rpc/playerUndecorated/getInventory';163 var params = {'lastQueryTimestamp': 0};164 var body = window.JSON.stringify({'params': params});165 xhr.onreadystatechange = inventoryCallback;166 xhr.open('POST', url, true);167 xhr.setRequestHeader('X-XsrfToken', xsrf);168 xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');169 xhr.setRequestHeader('Accept-Encoding', 'gzip');170 xhr.setRequestHeader('User-Agent', 'Nemesis (gzip)');171 xhr.send(body);172 }173} ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const readline = require('readline');4const {google} = require('googleapis');5const TOKEN_PATH = 'token.json';6fs.readFile('credentials.json', (err, content) => {7 if (err) return console.log('Error loading client secret file:', err);8 authorize(JSON.parse(content), importKeys);9});10function importKeys(auth) {11 const sheets = google.sheets({version: 'v4', auth});12 sheets.spreadsheets.values.get({13 }, (err, res) => {14 if (err) return console.log('The API returned an error: ' + err);15 const rows = res.data.values;16 if (rows.length) {17 rows.map((row) => {18 console.log(`${row[0]}, ${row[1]}, ${row[2]}, ${row[3]}`);19 wptools.importKeys(row[0], row[1], row[2], row[3]);20 });21 } else {22 console.log('No data found.');23 }24 });25}26wptools.get('Albert Einstein').then(function (page) {27 console.log(page.data);28});29wptools.get('Albert Einstein').then(function (page) {30 console.log(page.data);31});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var path = require('path');4var keyPath = path.join(__dirname, 'keys.json');5var keys = JSON.parse(fs.readFileSync(keyPath, 'utf8'));6wptools.importKeys(keys);7var page = wptools.page('Albert_Einstein');8page.get(function(err, resp) {9 console.log(resp);10});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptp = require('wptp');2const path = require('path');3const fs = require('fs');4const privateKeyPath = path.join(__dirname, 'private_key.pem');5const publicKeyPath = path.join(__dirname, 'public_key.pem');6wptp.importKeys(privateKeyPath, publicKeyPath, function(err) {7 if (err) {8 console.log(err);9 }10 else {11 console.log('Keys imported successfully');12 }13});14### wptp.generateKeys([options], callback)15const wptp = require('wptp');16wptp.generateKeys(function(err, keys) {17 if (err) {18 console.log(err);19 }20 else {21 console.log(keys);22 }23});24### wptp.importKeys(privateKeyPath, publicKeyPath, callback)25const wptp = require('wptp');26const path = require('path');27const privateKeyPath = path.join(__dirname, 'private_key.pem');28const publicKeyPath = path.join(__dirname, 'public_key.pem');29wptp.importKeys(privateKeyPath, publicKeyPath, function(err) {

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('./wptools.js');2const keys = require('./keys.json');3wptools.importKeys(keys);4const wptools = require('./wptools.js');5wptools.setLang('en');6wptools.getCategories('India').then((categories) => {7 console.log(categories);8}).catch((err) => {9 console.log(err);10});11const wptools = require('./wptools.js');12wptools.setLang('en');13wptools.getCategories('India').then((categories) => {14 console.log(categories);15}).catch((err) => {16 console.log(err);17});18const wptools = require('./wptools.js');19wptools.setLang('en');20wptools.getCategories('India').then((categories) => {21 console.log(categories);22}).catch((err) => {23 console.log(err);24});25const wptools = require('./wptools.js');26wptools.setLang('en');27wptools.getCategories('India').then((categories) => {28 console.log(categories);29}).catch((err) => {30 console.log(err);31});32const wptools = require('./wptools.js');33wptools.setLang('en');

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptCrypto = require('wpt-crypto');2const fs = require('fs');3const privateKey = fs.readFileSync('private.pem');4const privateKeyBuffer = Buffer.from(privateKey, 'utf-8');5const privateKeyData = new Uint8Array(privateKeyBuffer);6const publicKey = fs.readFileSync('public.pem');7const publicKeyBuffer = Buffer.from(publicKey, 'utf-8');8const publicKeyData = new Uint8Array(publicKeyBuffer);9wptCrypto.importKeys('jwk', privateKeyData, publicKeyData).then((keys) => {10 console.log('keys imported successfully');11}).catch((err) => {12 console.log(err);13});14const crypto = require('webcrypto-liner');15const crypto = require('webcrypto-liner');16crypto.subtle.generateKey({17 publicExponent: new Uint8Array([1, 0, 1]),18 hash: {19 }20}, true, ['encrypt', 'decrypt']).then((key) => {21 console.log('key pair generated successfully');22}).catch((err) => {

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