How to use issuer method in Puppeteer

Best JavaScript code snippet using puppeteer

issuing.js

Source:issuing.js Github

copy

Full Screen

1/* eslint camelcase: ["error", {properties: "never"}]*/2'use strict';3var _ = require('lodash');4function createInstance(options, client, callback) {5 var opts = {6 path: 'v1/issuer/issuers/' + options.relative_path,7 data: options.data,8 default: []9 };10 client._remote.post(opts, callback);11}12function createBadgeInstance(options, callback) {13 if (!callback) {14 callback = options;15 options = {};16 }17 // POST /v1/issuer/issuers/{issuerSlug}/badges/{badgeSlug}/assertions + 3 form properties (in data object)18 options.relative_path = options.issuerSlug + '/badges/' + options.badgeSlug + '/assertions';19 options.data = {20 recipient_identifier: options.recipient_identifier,21 evidence: options.evidence,22 create_notification: options.create_notification23 };24 createInstance(options, this, callback);25}26function getInstances(options, client, callback) {27 var opts = {28 path: 'v1/issuer/issuers/' + options.relative_path,29 qs: options.qs,30 default: []31 };32 client._remote.get(opts, callback);33}34function getBadgeInstances(options, callback) {35 // Types of filtering:36 // Badgr-server allows filtering by Badge class and by Recipient separately, but not by Evidence.37 // If there's no filtering, get all instances (1 function: number 0)38 // If there's only one type, we have a function for each (3 functions: number 1, 2, and 4).39 // If there's more than one type (4 functions):40 // Badge + Recipient = sort by Recipient and filter by badge (less recipients expected) (number 3)41 // Badge + Evidence = sort by badge and filter evidence (number 5)42 // Recipient + Evidence = sort by Recipient and filter by Evidence (number 6)43 // Badge + Recipient + Evidence = sort by Recipient (less expected) and then filter by the other two (number 7)44 // Calculate a number from 0 to 7 depending on the options passed45 // This is a binary conversion: evidenceFlag*4 + recipientFlag*2 + badgeSlugFlag*1 where the flags can be 0 or 1.46 var evidenceFlag, recipientFlag, badgeSlugFlag;47 evidenceFlag = options.evidence ? 4 : 0;48 recipientFlag = options.recipient ? 2 : 0;49 badgeSlugFlag = options.badgeSlug ? 1 : 0;50 var caseValue = evidenceFlag + recipientFlag + badgeSlugFlag;51 switch (caseValue) {52 case 0:53 getAllBadgeInstances(options, this, callback);54 break;55 case 1:56 getBadgeInstancesByBadge(options, this, callback);57 break;58 case 2:59 getBadgeInstancesByRecipient(options, this, callback);60 break;61 case 3:62 getBadgeInstancesByRecipientAndBadge(options, this, callback);63 break;64 case 4:65 getBadgeInstancesByEvidence(options, this, callback);66 break;67 case 5:68 getBadgeInstancesByBadgeAndEvidence(options, this, callback);69 break;70 case 6:71 getBadgeInstancesByRecipientAndEvidence(options, this, callback);72 break;73 case 7:74 getBadgeInstancesByRecipientAndEvidenceAndBadge(options, this, callback);75 break;76 default:77 console.log('This should never happen');78 callback(new Error('getBadgeInstances called with wrongn number of flags for filtering'));79 }80}81function getAllBadgeInstances(options, client, callback) {82 if (!options && !client && !callback) {83 throw new Error('All parameters are needed: options, client, and callback');84 }85 if (!options.issuerSlug) {86 return callback(new Error('Not enough information to return Badge Instances; please review the issuer slug.'));87 }88 // GET /v1/issuer/issuers/{issuerSlug}/assertions89 options.relative_path = options.issuerSlug + '/assertions';90 getInstances(options, client, callback);91}92function getBadgeInstancesByBadge(options, client, callback) {93 if (!options && !client && !callback) {94 throw new Error('All parameters are needed: options, client, and callback');95 }96 if (!options.issuerSlug || !options.badgeSlug) {97 return callback(new Error('Not enough information to return Badge Instances; please review the issuer and badge slugs.'));98 }99 // GET /v1/issuer/issuers/{issuerSlug}/badges/{badgeSlug}/assertions100 options.relative_path = options.issuerSlug + '/badges/' + options.badgeSlug + '/assertions';101 getInstances(options, client, callback);102}103function getBadgeInstancesByRecipient(options, client, callback) {104 if (!options && !client && !callback) {105 throw new Error('All parameters are needed: options, client, and callback');106 }107 options.qs = {108 recipient: options.recipient109 };110 if (!options.issuerSlug || !options.recipient) {111 return callback(new Error('Not enough information to return Badge Instances by Recipient;' +112 'please review the issuer slug and recipient id.'));113 }114 // GET /v1/issuer/issuers/{issuerSlug}/assertions with issuerSlug='mozilla-science' and recipient='someId@orcid.org'115 options.relative_path = options.issuerSlug + '/assertions';116 getInstances(options, client, callback);117}118function getBadgeInstancesByRecipientAndBadge(options, client, callback) {119 if (!options && !client && !callback) {120 throw new Error('All parameters are needed: options, client, and callback');121 }122 options.qs = {123 recipient: options.recipient124 };125 if (!options.issuerSlug || !options.recipient || !options.badgeSlug) {126 return callback(new Error('Not enough information to return Badge Instances by Recipient and Badge;' +127 'please review the issuer and badge slugs, and recipient id.'));128 }129 // This is basically filter by recipient, with an additional filtering step for Badge class130 // GET /v1/issuer/issuers/{issuerSlug}/assertions with issuerSlug='mozilla-science' and recipient='someId@orcid.org'131 options.relative_path = options.issuerSlug + '/assertions';132 getInstances(options, client, function(err, data) {133 if (err) {134 return callback(err);135 }136 var filteredByBadge = data.filter(function(item) {137 if (_.endsWith(item.badge_class, options.badgeSlug)) {138 return item.badge_class;139 }140 });141 callback(null, filteredByBadge);142 });143}144/**145 * There is no API call for evidence (which is used as DOI) so this method first grabs all badge instances, and then146 * filters by json.evidence field. TODO This may be a problem for scaling the system; keep an eye on it.147 */148function getBadgeInstancesByEvidence(options, client, callback) {149 if (!options && !client && !callback) {150 throw new Error('All parameters are needed: options, client, and callback');151 }152 if (!options.issuerSlug || !options.evidence) {153 return callback(new Error('Not enough information to return Badge Instances by Evidence'));154 }155 // GET /v1/issuer/issuers/{issuerSlug}/assertions with issuerSlug='mozilla-science'156 options.relative_path = options.issuerSlug + '/assertions';157 getInstances(options, client, function(err, data){158 if (err) {159 return callback(err);160 }161 var byEvidence = _.filter(data, function(badgeInstance) {162 if (badgeInstance.json && badgeInstance.json.evidence) {163 return badgeInstance.json.evidence === options.evidence;164 }165 });166 callback(null, byEvidence);167 });168}169function getBadgeInstancesByBadgeAndEvidence(options, client, callback) {170 if (!options && !client && !callback) {171 throw new Error('All parameters are needed: options, client, and callback');172 }173 if (!options.issuerSlug || !options.badgeSlug || !options.evidence) {174 return callback(new Error('Not enough information to return Badge Instances; ' +175 'please review the issuer and badge slugs, and the evidence url.'));176 }177 // This is basically return by Badge class with an added step to filter by Evidence178 // GET /v1/issuer/issuers/{issuerSlug}/badges/{badgeSlug}/assertions179 options.relative_path = options.issuerSlug + '/badges/' + options.badgeSlug + '/assertions';180 getInstances(options, client, function(err, data) {181 if (err) {182 return callback(err);183 }184 var byEvidence = _.filter(data, function(badgeInstance) {185 if (badgeInstance.json && badgeInstance.json.evidence) {186 return badgeInstance.json.evidence === options.evidence;187 }188 });189 callback(null, byEvidence);190 });191}192function getBadgeInstancesByRecipientAndEvidence(options, client, callback) {193 if (!options && !client && !callback) {194 throw new Error('All parameters are needed: options, client, and callback');195 }196 options.qs = {197 recipient: options.recipient198 };199 if (!options.issuerSlug || !options.recipient || !options.evidence) {200 return callback(new Error('Not enough information to return Badge Instances by Recipient and Evidence url;' +201 'please review the issuer slug, evidence url, and recipient id.'));202 }203 // This is basically filter by recipient, with an additional filtering step for Evidence204 // GET /v1/issuer/issuers/{issuerSlug}/assertions with issuerSlug='mozilla-science' and recipient='someId@orcid.org'205 options.relative_path = options.issuerSlug + '/assertions';206 getInstances(options, client, function(err, data) {207 if (err) {208 return callback(err);209 }210 var byEvidence = _.filter(data, function(badgeInstance) {211 if (badgeInstance.json && badgeInstance.json.evidence) {212 return badgeInstance.json.evidence === options.evidence;213 }214 });215 callback(null, byEvidence);216 });217}218function getBadgeInstancesByRecipientAndEvidenceAndBadge(options, client, callback) {219 if (!options && !client && !callback) {220 throw new Error('All parameters are needed: options, client, and callback');221 }222 options.qs = {223 recipient: options.recipient224 };225 if (!options.issuerSlug || !options.recipient || !options.evidence || !options.badgeSlug) {226 return callback(new Error('Not enough information to return Badge Instances by Recipient, Evidence url and Badge;' +227 'please review the issuer and badge slugs, evidence url, and recipient id.'));228 }229 // This is basically filter by recipient, with an additional filtering step for Evidence, and another one for Badge230 // GET /v1/issuer/issuers/{issuerSlug}/assertions with issuerSlug='mozilla-science' and recipient='someId@orcid.org'231 options.relative_path = options.issuerSlug + '/assertions';232 getInstances(options, client, function(err, data) {233 if (err) {234 return callback(err);235 }236 var byEvidence = _.filter(data, function(badgeInstance) {237 if (badgeInstance.json && badgeInstance.json.evidence) {238 return badgeInstance.json.evidence === options.evidence;239 }240 });241 var byBadge = byEvidence.filter(function(item) {242 if (_.endsWith(item.badge_class, options.badgeSlug)) {243 return item.badge_class;244 }245 });246 callback(null, byBadge);247 });248}249module.exports = {250 createBadgeInstance: createBadgeInstance,251 getBadgeInstances: getBadgeInstances...

Full Screen

Full Screen

manage-gateways.js

Source:manage-gateways.js Github

copy

Full Screen

1angular.module( 'ripplecharts.manage-gateways', [2 'ui.state',3 'ui.bootstrap'4])5.config(function config( $stateProvider ) {6 $stateProvider.state( 'manage-gateway', {7 url: '/manage-gateway',8 views: {9 "main": {10 controller: 'ManageGatewaysCtrl',11 templateUrl: 'manage-gateways/manage-gateways.tpl.html'12 }13 },14 data:{ pageTitle: 'Manage Gateways' },15 resolve : {16 gateInit : function (gateways) {17 return gateways.promise;18 }19 }20 });21})22.controller( 'ManageGatewaysCtrl', function ManageGatewaysCtrl( $scope, $state, $location, gateways ) {23 var addButton, addBox, newGateway, description, response;24 //load settings from session, local storage, options, or defaults25 $scope.base = store.session.get('base') || store.get('base') ||26 Options.base || {currency:"XRP", issuer:""};27 $scope.trade = store.session.get('trade') || store.get('trade') ||28 Options.trade || {currency:"USD", issuer:"rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"};29 //Figure out query and load dropdown accordingly30 var query = Object.keys($location.search())[0];31 var associatedCurrency;32 var loaded = false;33 var dropdownA;34 if (query === 'trade') query = 'trade';35 else query = 'base';36 //swap it if XRP is the currency37 //this can happen if base/trade isnt38 //indicated in the URL39 if ($scope[query].currency === 'XRP') {40 query = query === 'trade' ? 'base' : 'trade';41 }42 dropdownA = d3.select('#dropdown').append('div')43 .attr('id', query).attr('class', 'dropdown');44 loadDropdowns(dropdownA);45 //Add custom gateway46 addButton = d3.select('#btnAdd').on('click', function(){47 add();48 });49 $('#txtName').keypress(function(event) {50 if (event.keyCode == 13) {51 add();52 }53 });54 function add(){55 addBox = d3.select('#txtName');56 newGateway = addBox.property('value');57 addBox.property('value', '');58 description = d3.select('.description').html('Loading...');59 d3.xhr('https://id.ripple.com/v1/user/'+newGateway, function(err, res){60 if (!err) {61 var response = JSON.parse(res.response);62 if (response.exists) {63 addCheckbox(associatedCurrency, response.address, response.username);64 description.html('');65 return;66 }67 }68 if (newGateway.length >= 30 && newGateway.length <= 40 && newGateway[0] === "r"){69 addCheckbox(associatedCurrency, newGateway, "");70 description.html('');71 }72 else {73 description.html('Please enter a valid Ripple Address.');74 } 75 });76 }77 var saved = d3.select('.saved');78 function flashSaved() {79 saved.transition()80 .duration(500)81 .style('opacity', 1);82 saved.transition()83 .delay(1500)84 .duration(500)85 .style('opacity', 0);86 }87 //Add custom entry88 function addCheckbox(currency, iss, name) {89 var container = d3.select('#custom_gateway_list');90 var inputWrapper = container.append('div').attr('class', 'inputWrapper');91 addCustom(currency, iss, name);92 inputWrapper.append('input').attr('type', 'checkbox').property('checked', true)93 .on('change', function(){94 changeStatus(this, currency, iss, name);95 });96 if (iss !== name && name !== "")97 inputWrapper.append('text').text(name+" ("+iss+")");98 else inputWrapper.append('text').text(iss);99 inputWrapper.append('a').attr('class', 'removeBtn').text('remove').on('click', function(){100 inputWrapper.transition()101 .transition()102 .duration(500)103 .style('opacity', 0)104 .each('end', function(){105 d3.select(this).remove();106 });107 removeCustom(currency, iss);108 });109 }110 function loadDropdowns(selection) {111 selection.html("");112 var selectionId = selection.attr("id");113 var currencies = gateways.getCurrencies(true);114 var currencySelect = selection.append("div").attr("class", "currency").attr("id", selectionId+"_currency");115 var picked = false;116 var i;117 //remove XRP118 currencies.shift();119 //remove currencies without120 //at least one enabled gateway,121 //except custom ones122 i = currencies.length;123 while(i--) {124 if (!currencies[i].include && !currencies[i].custom) {125 delete currencies[i];126 currencies.splice(i,1);127 }128 }129 associatedCurrency = $scope[selectionId].currency;130 //format currnecies for dropdowns131 for (i=0; i<currencies.length; i++) {132 currencies[i] = {133 text : ripple.Currency.from_json(currencies[i].currency).to_human().substring(0,3),134 value : i,135 currency : currencies[i].currency,136 imageSrc : currencies[i].icon137 };138 if ($scope[selectionId].currency === currencies[i].currency) {139 picked = currencies[i].currency;140 currencies[i].selected = true;141 }142 }143 if (!picked) currencies[1].selected = true;144 function checkThemeLogo(issuer) {145 if ($scope.theme == 'dark') {146 issuer.imageSrc = issuer.assets['logo.grayscale.svg'];147 } else if ($scope.theme == 'light') {148 issuer.imageSrc = issuer.assets['logo.svg'];149 }150 }151 $scope.$watch('theme', function(){152 changeCurrency($scope[selectionId].currency);153 });154 $("#"+selectionId+"_currency").ddslick({155 data: currencies,156 imagePosition: "left",157 width: "120px",158 onSelected: function (data) {159 changeCurrency(data.selectedData.currency);160 }161 });162 function changeCurrency(selected){163 $('#gateway_curr_list').html('');164 $('#irba_gateway_curr_list').html('');165 var issuers = gateways.getIssuers(selected, true);166 var issuer;167 associatedCurrency = selected;168 //Add custom gateways169 var container = d3.select('#custom_gateway_list');170 container.html('');171 issuers.forEach(function(issuer, i) {172 var issuerList, checkbox, inputWrapper;173 issuer.text = issuer.name;174 if (selected != "XRP" && !issuer.custom) {175 //issuer.imageSrc = issuer.assets['logo.svg'];176 checkThemeLogo(issuer);177 }178 if ($scope[selectionId].issuer === issuer.account) issuer.selected = true;179 else issuer.selected = false;180 issuer.value = i;181 if (!issuer.custom && issuer.imageSrc) {182 issuerList = d3.select('#irba_gateway_curr_list');183 inputWrapper = issuerList.append('div').attr('class', 'inputWrapper irba');184 checkbox = inputWrapper;185 } else if (!issuer.custom && !issuer.imageSrc) {186 issuerList = d3.select('#gateway_curr_list');187 inputWrapper = issuerList.append('div').attr('class', 'inputWrapper');188 checkbox = inputWrapper;189 }190 else if (issuer.custom) {191 issuerList = d3.select('#custom_gateway_list');192 inputWrapper = issuerList.append('div').attr('class', 'inputWrapper');193 checkbox = inputWrapper;194 }195 checkbox.append('input').attr('type', 'checkbox').property('checked', issuer.include)196 .on('change', function(){197 changeStatus(this, selected, issuer.account, issuer.name);198 });199 if (issuer.imageSrc) {200 inputWrapper.append("img")201 .attr("class", "gateway_symb")202 .attr("src", issuers[i].imageSrc)203 } else if (!issuer.custom) {204 inputWrapper.append("text").text(issuers[i].name);205 inputWrapper.append("p");206 } else if (issuer.custom) {207 if (issuers[i].account !== issuers[i].name)208 inputWrapper.append('text').text(issuers[i].name+" ("+issuers[i].account+")");209 else inputWrapper.append('text').text(issuers[i].account);210 inputWrapper.append('a').attr('class', 'removeBtn').text('remove').on('click', function(){211 inputWrapper.transition()212 .transition()213 .duration(300)214 .style('opacity', 0)215 .each('end', function(){216 d3.select(this).remove();217 });218 removeCustom(selected, issuer.account);219 });220 }221 });222 }223 }224 function changeStatus(checkbox, currency, issuer, name) {225 var checked = d3.select(checkbox).property('checked');226 gateways.updateIssuer({227 currency : currency,228 issuer : issuer,229 exclude : !checked,230 include : checked231 });232 if (!status) {233 checkLocal(currency, issuer, 'base');234 checkLocal(currency, issuer, 'trade');235 }236 flashSaved();237 }238 function addCustom(currency, issuer, name) {239 gateways.updateIssuer({240 currency : currency,241 issuer : issuer,242 name : name,243 add : true244 });245 flashSaved();246 }247 function removeCustom(currency, issuer) {248 gateways.updateIssuer({249 currency : currency,250 issuer : issuer,251 name : name,252 remove : true253 });254 flashSaved();255 }256 function checkLocal(currency, iss, select) {257 var gateway;258 if ($scope[select].currency === currency && $scope[select].issuer === iss){259 var next = false;260 while (next === false) {261 next = pickNextGateway(currency);262 if (next === false) {263 currency = pickNextCurrency(currency).currency;264 }265 }266 $scope[select] = {currency: currency, issuer: next.account};267 store.set(select, $scope[select]);268 store.session.set(select, $scope[select]);269 }270 }271 function pickNextCurrency(currency) {272 var currencyList = gateways.getCurrencies();273 var picked = false;274 var c;275 for (var i=0; i<currencyList.length; i++) {276 c = currencyList[i];277 if (picked && c.include && c.currency !== "XRP") {278 return c;279 }280 if (c.currency === currency) picked = true;281 }282 for (i=1; i<currencyList.length; i++) {283 c = currencyList[i];284 if (picked && c.include && c.currency !== "XRP"){285 return c;286 }287 }288 return currencyList[0];289 }290 function pickNextGateway(currency) {291 if (currency === "XRP") return "";292 var issuerList = gateways.getIssuers(currency);293 var gateway;294 for (var i=0; i<issuerList.length; i++){295 gateway = issuerList[i];296 if (gateway.include) {297 return gateway;298 }299 }300 return false;301 }302 function getIndex(object, currency, iss) {303 var index = -1;304 var gateway;305 if (currency in object) {306 var array = object[currency];307 for (var i=0; i< array.length; i++) {308 gateway = array[i];309 if (gateway.issuer === iss) {310 index = i;311 break;312 }313 }314 }315 return index;316 }...

Full Screen

Full Screen

CertificateDetail.js

Source:CertificateDetail.js Github

copy

Full Screen

1// Copyright 2012 Hewlett-Packard Development Company, L.P.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14enyo.kind({15 name: "CertificateDetail",16 kind: enyo.VFlexBox,17 published: {18 cert: ""19 },20 components: [21 {name: "commonName"},22 {kind:"RowGroup", caption:$L("Issued By"), components:[23 {name:"displayIssuerCommonName"}24 ]},25 {kind:"RowGroup", caption:$L("Start Date"), components:[26 {name:"startDate"}27 ]},28 {kind:"RowGroup", caption:$L("Expiration Date"), components:[29 {name:"expirationDate"}30 ]},31 {kind: "Divider", caption: $L("Subject information")},32 {kind:"RowGroup", name:"subjectAltNameGroup", caption:$L("Subject Alt Name"), components:[33 {name:"subjectAltName"}34 ]},35 {kind:"RowGroup", name:"subjectCountryGroup", caption:$L("Country"), components:[36 {name:"subjectCountry"}37 ]},38 {kind:"RowGroup", name:"subjectStateGroup", caption:$L("State/Province"), components:[39 {name:"subjectState"}40 ]},41 {kind:"RowGroup", name:"subjectLocationGroup", caption:$L("Location"), components:[42 {name:"subjectLocation"}43 ]},44 {kind:"RowGroup", name:"subjectOrganizationGroup", caption:$L("Organization"), components:[45 {name:"subjectOrganization"}46 ]},47 {kind:"RowGroup", name:"subjectCommonNameGroup", caption:$L("Common Name"), components:[48 {name:"subjectCommonName"}49 ]},50 {kind: "Divider", caption: $L("Issuer Information")},51 {kind:"RowGroup", name:"issuerCountryGroup", caption:$L("Country"), components:[52 {name:"issuerCountry"}53 ]},54 {kind:"RowGroup", name:"issuerStateGroup", caption:$L("State/Province"), components:[55 {name:"issuerState"}56 ]},57 {kind:"RowGroup", name:"issuerLocationGroup", caption:$L("Location"), components:[58 {name:"issuerLocation"}59 ]},60 {kind:"RowGroup", name:"issuerOrganizationGroup", caption:$L("Organization"), components:[61 {name:"issuerOrganization"}62 ]},63 {kind:"RowGroup", name:"issuerCommonNameGroup", caption:$L("Common Name"), components:[64 {name:"issuerCommonName"}65 ]},66 {kind:"RowGroup", caption:$L("Serial Number"), components:[67 {name:"serialNumber"}68 ]},69 {kind:"RowGroup", caption:$L("Version"), components:[70 {name:"version"}71 ]},72 {kind:"RowGroup", caption:$L("Signature Algorithm"), components:[73 {name:"signatureAlgorithm"}74 ]},75// {kind:"RowGroup", caption:$L("Signature"), components:[76// {name:"signature", kind: "RichText", richContent: false}77// ]},78 {kind:"RowGroup", caption:$L("Public Key Algorithm"), components:[79 {name:"publicKeyAlgorithm"}80 ]}81// {kind:"RowGroup", caption:$L("Public Key"), components:[82// {name:"publicKey", kind: "RichText", richContent: false}83// ]}84 ],85 certChanged: function() {86 var alternate_name="";87 this.cert.displayCommonName = "";88 this.cert.displayIssuerCommonName = "";89 90 if(this.cert.subject) {91 this.cert.displayCommonName = this.cert.subject.commonname ? this.cert.subject.commonname : this.cert.subject.organization;92 }93 if(this.cert.issuer) {94 this.cert.displayIssuerCommonName = this.cert.issuer.commonname ? this.cert.issuer.commonname : this.cert.issuer.organization;95 }96 97 if(this.cert.displayCommonName) {98 this.$.commonName.setContent(enyo.string.escapeHtml(this.cert.displayCommonName));99 }100 else {101 for(var j in this.cert.subject.altname){102 alternate_name += this.cert.subject.altname[j] + ' ';103 }104 this.$.certName.setContent(enyo.string.escapeHtml(alternate_name));105 }106 107 if(this.cert.displayIssuerCommonName) {108 this.$.displayIssuerCommonName.setContent(enyo.string.escapeHtml(this.cert.displayIssuerCommonName));109 }110 111 if(this.cert.startdate) {112 var dateFormatter = new enyo.g11n.DateFmt({date:'long'});113 this.$.startDate.setContent(dateFormatter.format(new Date(this.cert.startdate)));114 }115 116 if(this.cert.expiredate) {117 var dateFormatter = new enyo.g11n.DateFmt({date:'long'});118 this.$.expirationDate.setContent(dateFormatter.format(new Date(this.cert.expiredate)));119 }120 121 if(this.cert.subject) {122 123 alternate_name="";124 for(var j in this.cert.subject.altname) {125 alternate_name += this.cert.subject.altname[j] + ' ';126 }127 this.$.subjectAltNameGroup.setShowing(alternate_name ? true : false);128 this.$.subjectAltName.setContent(enyo.string.escapeHtml(alternate_name));129 130 this.$.subjectCountryGroup.setShowing(this.cert.subject.country ? true : false)131 this.$.subjectCountry.setContent(enyo.string.escapeHtml(this.cert.subject.country));132 133 this.$.subjectStateGroup.setShowing(this.cert.subject.state ? true : false);134 this.$.subjectState.setContent(enyo.string.escapeHtml(this.cert.subject.state));135 136 this.$.subjectLocationGroup.setShowing(this.cert.subject.location ? true : false);137 this.$.subjectLocation.setContent(enyo.string.escapeHtml(this.cert.subject.location));138 139 this.$.subjectOrganizationGroup.setShowing(this.cert.subject.organization);140 this.$.subjectOrganization.setContent(enyo.string.escapeHtml(this.cert.subject.organization));141 142 this.$.subjectCommonNameGroup.setShowing(this.cert.subject.commonname ? true : false);143 this.$.subjectCommonName.setContent(enyo.string.escapeHtml(this.cert.subject.commonname));144 }145 146 if(this.cert.issuer) {147 this.$.issuerCountryGroup.setShowing(this.cert.issuer.country ? true : false);148 this.$.issuerCountry.setContent(enyo.string.escapeHtml(this.cert.issuer.country));149 150 this.$.issuerStateGroup.setShowing(this.cert.issuer.state ? true : false);151 this.$.issuerState.setContent(enyo.string.escapeHtml(this.cert.issuer.state));152 153 this.$.issuerLocationGroup.setShowing(this.cert.issuer.location ? true : false);154 this.$.issuerLocation.setContent(enyo.string.escapeHtml(this.cert.issuer.location));155 156 this.$.issuerOrganizationGroup.setShowing(this.cert.issuer.organization ? true : false);157 this.$.issuerOrganization.setContent(enyo.string.escapeHtml(this.cert.issuer.organization));158 159 this.$.issuerCommonNameGroup.setShowing(this.cert.issuer.commonname ? true : false);160 this.$.issuerCommonName.setContent(enyo.string.escapeHtml(this.cert.issuer.commonname));161 }162 163 this.$.serialNumber.setContent(enyo.string.escapeHtml(this.cert.serialNumber));164 this.$.version.setContent(enyo.string.escapeHtml(this.cert.version));165 166 if(this.cert.signature) {167 if(this.cert.signature.algorithm) {168 this.$.signatureAlgorithm.setContent(enyo.string.escapeHtml(this.cert.signature.algorithm));169 }170// this.$.signature.setValue(enyo.string.escapeHtml(this.cert.signature.hexValue));171 }172 173 if(this.cert.publicKey) {174 if(this.cert.publicKey.algorithm) {175 this.$.publicKeyAlgorithm.setContent(enyo.string.escapeHtml(this.cert.publicKey.algorithm));176 }177// this.$.publicKey.setValue(enyo.string.escapeHtml(this.cert.publicKey.hexValue));178 }179 }180});181enyo.kind({182 name: "CertificateDialog",183 kind: "ModalDialog",184 caption: $L("View Certificate"),185 width: "450px",186 layoutKind: "VFlexLayout",187 published: {188 certFile: ""189 },190 events: {191 onCertLoad: "",192 onClose: ""193 },194 components: [195 {name: "getCertificateDetails", kind:"PalmService", service:"palm://com.palm.certificatemanager/",196 method:"getcertificatedetails",197 onResponse:"handleCertificate"198 },199 {kind: "Scroller", height: "500px", flex: 1, horizontal: false, autoHorizontal: false, components: [200 {name: "certDetail", kind: "CertificateDetail"}201 ]},202 {kind: "HFlexBox", pack: "justify", align: "center", components: [203 {kind: "Button", caption: $L("Done"), flex: 1, className: "enyo-button-dark", onclick: "doClose"}204 ]}205 ],206 certFileChanged: function() {207// this.warn("cert file: ", this.certFile);208 this.validateComponents();209 if(this.certFile) {210 this.$.getCertificateDetails.call({'certificateFilename': this.certFile});211 }212 },213 handleCertificate: function(inSender, inResponse) {214// this.warn("cert details: ", enyo.json.stringify(inResponse));215 if(inResponse.returnValue) {216 this.$.certDetail.setCert(inResponse);217 this.doCertLoad();218 }219 }...

Full Screen

Full Screen

chaincode.js

Source:chaincode.js Github

copy

Full Screen

1/**2 * Copyright finetelics . All Rights Reserved.3 * 4 * SPDX-License-Identifier: Apache-2.05 */6/**7 * Schema: 8 * 9 * toker issuer / video provider / ad provider 10 * 11 * token issuer init with one fixed credit,then transfer to ad provider once triggered12 * and ad provider can send fixed amount of token to video provider13 * 14 * Update balance of token issuer15 * 16 * 17 */18const shim = require('fabric-shim');19const util = require('util');20var Chaincode = class {21 22 async Init(stub) {23 console.info('===============Eye network transfer system start================')24 /**25 * Every time this chaincodein Init 26 */27 return shim.success()28 }29 async addAdProvider(stub, name, id, balance) {30 let newAdProvider={31 providerName: name,32 providerId: id,33 balance: balance34 }35 await stub.putState('adProvider '+newAdProvider.providerId, 36 Buffer.from(JSON.stringify(newAdProvider)));37 console.log('adProvider '+newAdProvider.providerId+' has already been added with balance '+newAdProvider.balance);38 }39 async updateTokenBalance(stub, newBalance) {40 console.info('=================Start: update token balance=====================');41 if (newBalance<=0){42 throw new Error('new balance can not be negative');43 }44 let tokenIssuerBytes = await stub.getState('tokenIssuer');45 let tokenIssuer=JSON.parse(tokenIssuerBytes);46 tokenIssuer.balance=newBalance;47 await stub.putState('tokenIssuer',JSON.stringify(tokenIssuer));48 console.info('====================END: token balance is updated================');49 }50 async adProvider2VideoProvider(stub, adPid, vPid, adId, vId, amount, ) {51 console.info('=============Transaction happen===============');52 let adProviderByte= await stub.getState('adProvider '+adPid)53 let adProvider=JSON.parse(adProviderByte);54 let videoProviderByte= await stub.getState('videoProvider '+vPid);55 let videoProvider=JSON.parse(videoProviderByte);56 adProvider.balance=adProvider.balance-amount;57 videoProvider.balance=videoProvider.balance+amount;58 await stub.putState('adProvider '+adPid,JSON.stringify(adProvider));59 await stub.putState('videoProvider '+vPid,JSON.stringify(videoProvider));60 console.info("transaction is done. ad provider "+adPid+" paid "+amount+" token to video provider "61 +vPid+" to attach ad "+adId+ " on video "+vid);62 }63 async tokenIssuer2AdProvider(stub,adPid,amount) {64 console.info('===================Transaction happen=================');65 let adProviderByte= await stub.getState('adProvider '+adPid)66 let adProvider=JSON.parse(adProviderByte);67 let tokenIssuerBytes = await stub.getState('tokenIssuer');68 let tokenIssuer=JSON.parse(tokenIssuerBytes);69 tokenIssuer.balance=tokenIssuer.balance-amount;70 adProvider.balance=adProvider.balance+amount;71 await stub.putState('videoProvider '+vPid,JSON.stringify(videoProvider));72 await stub.putState('tokenIssuer',JSON.stringify(tokenIssuer));73 }74 async videoProvider2TokenIssuer(stub,vPid,amount) {75 console.info('===================Transaction happen=================');76 let tokenIssuerBytes = await stub.getState('tokenIssuer');77 let tokenIssuer=JSON.parse(tokenIssuerBytes);78 let videoProviderByte= await stub.getState('videoProvider '+vPid);79 let videoProvider=JSON.parse(videoProviderByte);80 tokenIssuer.balance=tokenIssuer.balance+amount;81 videoProvider.balance=videoProvider.balance-amount;82 await stub.putState('tokenIssuer',JSON.stringify(tokenIssuer));83 await stub.putState('videoProvider '+vPid,JSON.stringify(videoProvider));84 }85 async addVideoProvider(stub, name, id, balance) {86 let newAdProvider={87 providerName: name,88 providerId: id,89 balance: balance90 }91 await stub.putState('videoProvider'+ newAdProvider.providerId,92 Buffer.from(JSON.stringify(newAdProvider)));93 console.log('videoProvider '+newVideoProvider.providerId+' has already been added with balance '+newVideoProvider.balance);94 }95 async Invoke(stub) {96 let ret = stub.getFunctionAndParameters();97 console.info(ret);98 let args = ret.params;99 let method = this[ret.fcn];100 if (!method) {101 console.error('no function of name :' + ret.fcn + ' found');102 throw new Error('Received unknown function ' + ret.fcn + ' invocation');103 } try{104 let payload = await method(stub,ret.params);105 return shim.success(payload);106 }107 catch(err){108 console.log(err);109 return shim.error(err);110 }111 }112 async initDatabase(stub,args){113 console.info('=====================Start: the system is about to start======================');114 let tokenIssuer={115 balance: "10000"116 };117 await stub.putState('tokenIssuer',Buffer.from(JSON.stringify(tokenIssuer)));118 console.info("tokenIssuer has already been generated with balance: ", tokenIssuer.balance);119 120 }121}...

Full Screen

Full Screen

ProvidersCacheSpec.js

Source:ProvidersCacheSpec.js Github

copy

Full Screen

1/**2 * Test dependencies3 */4const chai = require('chai')5const sinon = require('sinon')6const nock = require('nock')7/**8 * Assertions9 */10chai.use(require('sinon-chai'))11chai.use(require('dirty-chai'))12chai.use(require('chai-as-promised'))13chai.should()14let expect = chai.expect15/**16 * Code under test17 */18const {JWKSet} = require('@solid/jose')19const ProvidersCache = require('../src/ProvidersCache')20/**21 * Tests22 */23describe('ProvidersCache', () => {24 const providerConfig = require('./resources/example.com/openid-configuration.json')25 const providerJwks = require('./resources/example.com/jwks.json')26 afterEach(() => {27 nock.cleanAll()28 })29 describe('constructor', () => {30 it('should initialize an empty providers cache by default', () => {31 let cache = new ProvidersCache()32 expect(cache.providers).to.eql({})33 })34 })35 describe('static from', () => {36 it('should initialize a providers cache instance from empty data', () => {37 let data = {}38 return ProvidersCache.from(data)39 .then(cache => {40 expect(cache.providers).to.eql({})41 })42 })43 it('should import the keys of the provided provider data', () => {44 let data = {45 'https://example.com': {46 jwks: providerJwks47 }48 }49 return ProvidersCache.from(data)50 .then(cache => {51 let provider = cache.providers['https://example.com']52 expect(provider.jwks).to.be.an.instanceof(JWKSet)53 })54 })55 })56 describe('discover', () => {57 it('should fetch the openid configuration for a given issuer', () => {58 let issuer = 'https://example.com'59 nock(issuer)60 .get('/.well-known/openid-configuration')61 .reply(200, providerConfig)62 let cache = new ProvidersCache()63 return cache.discover(issuer)64 .then(res => {65 expect(res.issuer).to.equal(issuer)66 expect(res.authorization_endpoint).to.equal(issuer + '/authorize')67 })68 })69 it('should not have a double slash when the issuer has a trailing slash', () => {70 let issuer = 'https://example.com'71 nock(issuer)72 .get('//.well-known/openid-configuration')73 .reply(200, { passedTest: false })74 nock(issuer)75 .get('/.well-known/openid-configuration')76 .reply(200, { passedTest: true })77 78 let cache = new ProvidersCache()79 return cache.discover(`${issuer}/`)80 .then(res => {81 expect(res.passedTest).to.equal(true)82 })83 })84 })85 describe('jwks', () => {86 it('should fetch the public keys for a given issuer', () => {87 let issuer = 'https://example.com'88 nock(issuer)89 .get('/jwks')90 .reply(200, providerJwks)91 let cache = new ProvidersCache()92 return cache.jwks(issuer + '/jwks')93 .then(jwks => {94 expect(jwks.keys[0].kid).to.equal('2koDA6QjhXU')95 })96 })97 })98 describe('resolve', () => {99 let cache100 beforeEach(() => {101 cache = new ProvidersCache()102 sinon.spy(cache, 'rotate')103 })104 it('should fetch an issuer from cache is available', () => {105 let issuerUri = 'https://example.com'106 let issuer1 = { issuer: issuerUri }107 cache.providers[issuerUri] = issuer1108 return cache.resolve(issuerUri)109 .then(result => {110 expect(result).to.equal(issuer1)111 expect(cache.rotate).to.not.have.been.called()112 })113 })114 it('should discover and resolve an issuer when not available', () => {115 let issuerUri = 'https://example.com'116 let issuer1 = { configuration: { issuer: issuerUri } }117 cache.rotate = sinon.stub().withArgs(issuerUri).resolves(issuer1)118 return cache.resolve(issuerUri)119 .then(result => {120 expect(cache.rotate).to.have.been.called()121 expect(result.configuration.issuer).to.equal(issuerUri)122 })123 })124 })125 describe('rotate', () => {126 const issuerUri = 'https://example.com'127 let cache128 beforeEach(() => {129 cache = new ProvidersCache()130 nock(issuerUri)131 .get('/.well-known/openid-configuration')132 .reply(200, providerConfig)133 nock(issuerUri)134 .get('/jwks')135 .reply(200, providerJwks)136 })137 it('should discover and load provider config and keys', () => {138 return cache.rotate(issuerUri)139 .then(result => {140 expect(result.configuration.issuer).to.equal(issuerUri)141 expect(result.jwks).to.exist()142 })143 })144 it('should add the discovered/loaded provider to its cache', () => {145 return cache.rotate(issuerUri)146 .then(result => {147 expect(cache.providers[issuerUri]).to.equal(result)148 })149 })150 })...

Full Screen

Full Screen

asset.js

Source:asset.js Github

copy

Full Screen

...47 case xdr.AssetType.assetTypeNative():48 return this.native();49 case xdr.AssetType.assetTypeCreditAlphanum4():50 anum = assetXdr.alphaNum4();51 issuer = StrKey.encodeEd25519PublicKey(anum.issuer().ed25519());52 code = trimEnd(anum.assetCode(), '\0');53 return new this(code, issuer);54 case xdr.AssetType.assetTypeCreditAlphanum12():55 anum = assetXdr.alphaNum12();56 issuer = StrKey.encodeEd25519PublicKey(anum.issuer().ed25519());57 code = trimEnd(anum.assetCode(), '\0');58 return new this(code, issuer);59 default:60 throw new Error(`Invalid asset type: ${assetXdr.switch().name}`);61 }62 }63 /**64 * Returns the xdr object for this asset.65 * @returns {xdr.Asset}66 */67 toXDRObject() {68 if (this.isNative()) {69 return xdr.Asset.assetTypeNative();70 } else {...

Full Screen

Full Screen

creditcardgenerator.js

Source:creditcardgenerator.js Github

copy

Full Screen

1'use strict';2module.exports = {3 create: create4};5function create(issuer) {6 issuer = issuer ? issuer : 'visa';7 var number;8 // https://www.nilsonreport.com/upload/Purchase_Transactions_Worldwide_2014.jpg9 if (issuer.match(/^v/i)) {10 issuer = 'Visa';11 number = '4' + randomInt(14);12 } else if (issuer.match(/^master/i)) {13 issuer = 'MasterCard';14 number = '5' + randomInt(1, 1, 5) + randomInt(13);15 } else if (issuer.match(/union/i)) {16 issuer = 'China UnionPay';17 number = '62' + randomInt(13);18 } else if (issuer.match(/^ame/i)) {19 issuer = 'American Express';20 number = '3' + (randomInt(1, 0, 1) === '0' ? '4' : '7') + randomInt(12);21 } else if (issuer.match(/^dine/i)) {22 issuer = 'Diners Club';23 var prefix = [300, 301, 302, 303, 304, 305, 309, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399];24 number = prefix[randomInt(1, 0, 36)] + randomInt(10);25 } else if (issuer.match(/^dis/i)) {26 issuer = 'Discover Card';27 var r = randomInt(1, 0, 3);28 switch (r) {29 case '0':30 number = '6011' + randomInt(11);31 break;32 case '1':33 number = '622' + randomInt(1, 126, 925) + randomInt(9);34 break;35 case '2':36 number = '64' + randomInt(1, 4, 9) + randomInt(12);37 break;38 default:39 number = '65' + randomInt(13);40 break;41 }42 } else if (issuer.match(/^j/i)) {43 issuer = 'JCB';44 number = '35' + randomInt(1, 28, 89) + randomInt(11);45 }46 var number_reverse_list = number.split('').reverse();47 var sum = 0;48 var pos = 0;49 while (pos < number.length) {50 var odd = number_reverse_list[pos] * 2;51 if (odd > 9) {52 odd -= 9;53 }54 sum += odd;55 if (pos != (number.length - 1)) {56 sum += parseInt(number_reverse_list[pos + 1]);57 }58 pos += 2;59 }60 number = number + (((Math.floor(sum / 10) + 1) * 10 - sum) % 10);61 return {62 issuer: issuer,63 number: number64 };65}66function randomInt(count, low, high) {67 if (low === undefined)68 low = 0;69 if (high === undefined)70 high = 9;71 var rtn = '';72 for (var i = 0; i < count; i++) {73 rtn += Math.floor(Math.random() * (high - low + 1) + low).toString();74 }75 return rtn;...

Full Screen

Full Screen

find_issuer.js

Source:find_issuer.js Github

copy

Full Screen

1var issuerRange = {};2var issuerLen = {},3 maxLen = 0;4var add = function(ranges, issuer, lenRanges) {5 ranges.forEach(function(item) {6 maxLen = ((maxLen < item.length) ? item.length : maxLen);7 issuerRange[item] = issuer;8 });9 issuerLen[issuer] = lenRanges;10};11add(['4026', '417500', '4405', '4508', '4844', '4913', '4917'], 'VISAELECTRON', [16]);12add(['4'], 'VISA', [13, 16]);13add(['34', '37'], 'AMEX', [15]);14add(['36'], 'DC', [14]);15function isVisaElectron(cc) {16 var four = cc.substr(0, 4);17 six = cc.substr(0, 6),18 ranges = issuerRange['VISAELECTRON'];19 return (issuerRange[four] || issuerRange[six]);20}21function getIssuer(cc) {22 if(typeof cc == 'undefined'){23 return 'NOT APPLICABLE';24 }25 var prefix = '';26 for (var i = 0; i < maxLen; i++) {27 prefix += cc[i];28 var issuer = issuerRange[ prefix ];29 if (issuer && issuerLen[issuer].indexOf( cc.length ) >= 0) {30 if (issuer === 'VISA') {31 issuer = (isVisaElectron(cc) ? 'VISAELECTRON' : 'VISA');32 }33 return issuer;34 }35 }36 return 'UNAVAILABLE';37}38function assertEqual(cc, expectedIssuer) {39 var actualIssuer = getIssuer(cc);40 if (actualIssuer !== expectedIssuer) {41 throw new Error("test failed expectedIssuer for " + cc + " was " + expectedIssuer + " and actual issuer was " + actualIssuer);42 }43 return true;44}45assertEqual('346416800707698', 'AMEX');46assertEqual('376416800707698', 'AMEX');47assertEqual('37641680070769832112', 'UNAVAILABLE');48assertEqual('36641680070769', 'DC');49assertEqual('54545641680070769', 'UNAVAILABLE');50assertEqual('4175004175004172', 'VISAELECTRON');51assertEqual('4917491749174917', 'VISAELECTRON');52assertEqual('4111111111111111', 'VISA');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.screenshot({path: 'example.png'});6 await browser.close();7})();8const puppeteer = require('puppeteer');9(async () => {10 const browser = await puppeteer.launch();11 const page = await browser.newPage();12 await page.screenshot({path: 'example.png'});13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch();18 const page = await browser.newPage();19 await page.screenshot({path: 'example.png'});20 await browser.close();21})();22const puppeteer = require('puppeteer');23(async () => {24 const browser = await puppeteer.launch();25 const page = await browser.newPage();26 await page.screenshot({path: 'example.png'});27 await browser.close();28})();29const puppeteer = require('puppeteer');30(async () => {31 const browser = await puppeteer.launch();32 const page = await browser.newPage();33 await page.screenshot({path: 'example.png'});34 await browser.close();35})();36const puppeteer = require('puppeteer');37(async () => {38 const browser = await puppeteer.launch();39 const page = await browser.newPage();40 await page.screenshot({path: 'example.png'});41 await browser.close();42})();43const puppeteer = require('puppeteer');44(async () => {45 const browser = await puppeteer.launch();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({4 });5 const page = await browser.newPage();6 await page.screenshot({path: 'google.png'});7 await browser.close();8})();9 -v $(pwd):/app \10![google.png](google.png)

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 const cert = await page.certificate();7 fs.writeFileSync('cert.pem', cert);8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch({5 });6 const page = await browser.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.type('#lst-ib', 'puppeteer');6 await page.keyboard.press('Enter');7 await page.waitForNavigation();8 await page.screenshot({path: 'example.png'});9 await browser.close();10})();11The headless mode of Puppeteer is used to run the browser without the graphical user interface. To use the headless mode of Puppeteer, we need to pass the `headless` option to the `launch()` method of the Puppeteer module. The `headless` option is set to `false` by default. The following code will run the browser in headless mode:12const puppeteer = require('puppeteer');13(async () => {14 const browser = await puppeteer.launch({headless: true});15 const page = await browser.newPage();16 await page.type('#lst-ib', 'puppeteer');17 await page.keyboard.press('Enter');18 await page.waitForNavigation();19 await page.screenshot({path: 'example.png'});20 await browser.close();21})();22In the above code, we are using the `launch()` method of the Puppeteer module to launch a browser in headless mode. Then, we are using the `newPage()` method to create a new page. After that,

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.screenshot({path: 'google.png'});6 await browser.close();7})();8const puppeteer = require('puppeteer');9(async () => {10 const browser = await puppeteer.launch({headless: false});11 const page = await browser.newPage();12 await page.screenshot({path: 'google.png'});13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch({headless: false});18 const page = await browser.newPage();19 await page.screenshot({path: 'google.png'});20 await browser.close();21})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const { issuer } = require('./issuer');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 await page.type('input[name="q"]', 'puppeteer');7 await page.click('input[type="submit"]');8 await page.waitForNavigation();9 await page.waitForSelector('div#resultStats');10 const results = await page.evaluate(() => {11 const elements = Array.from(document.querySelectorAll('div#resultStats'));12 return elements.map(element => element.textContent);13 });14 console.log(results[0]);15 await browser.close();16})();17const puppeteer = require('puppeteer');18(async () => {19 const browser = await puppeteer.launch();20 const page = await browser.newPage();21 await page.authenticate({ username: 'username', password: 'password' });22 await browser.close();23})();24const puppeteer = require('puppeteer');25(async () => {26 const browser = await puppeteer.launch();27 const page = await browser.newPage();28 await page.authenticate({ username: 'username', password: 'password' });29 await browser.close();30})();31const puppeteer = require('puppeteer');32(async () => {33 const browser = await puppeteer.launch();34 const page = await browser.newPage();35 await page.emulateNetworkConditions({

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4const { promisify } = require('util');5const writeFile = promisify(fs.writeFile);6const readFile = promisify(fs.readFile);7(async () => {8 const browser = await puppeteer.launch({ headless: false });9 const page = await browser.newPage();10 await page.screenshot({ path: 'google.png' });11 await browser.close();12})();13const puppeteer = require('puppeteer');14(async () => {15 const browser = await puppeteer.connect({16 });17 const page = await browser.newPage();18 await browser.close();19})();20const puppeteer = require('puppeteer');21(async () => {22 const browser = await puppeteer.connect({23 });24 const page = await browser.newPage();25 await browser.close();26})();27const puppeteer = require('puppeteer');28(async () => {29 const browser = await puppeteer.connect({30 });31 const page = await browser.newPage();32 await browser.close();33})();34const puppeteer = require('puppeteer');35(async () => {36 const browser = await puppeteer.connect({

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 Puppeteer 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