This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetch = require('node-fetch'); | |
| const FormData = require('form-data'); | |
| const JSONWebToken = require('jsonwebtoken'); | |
| const getAuthToken = async function (args){ | |
| args.duration = args.duration || 60; | |
| args.scope = args.scope instanceof Array? args.scope.join(' ') : args.scope; | |
| let form = new FormData(); | |
| form.append('grant_type', 'urn:ietf:params:oauth:grant-type:jwt-bearer'); | |
| form.append('scope', args.scope); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # @see https://developers.google.com/identity/sign-in/web/backend-auth | |
| sub verify_with_google { | |
| my $self = shift; | |
| my $res = LWP::UserAgent->new()->get( | |
| 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=' | |
| . $self->{id_token} | |
| ); | |
| if ($res->is_success() and | |
| $res->decoded_content =~ /"aud"\s*:\s*"$self->{client_id}"/ | |
| ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| require JSON::XS; | |
| require JSON::WebToken; | |
| require LWP::UserAgent; | |
| my $google_ua = signin_with_google( | |
| service_account_id => $SERVICE_AC_ID, | |
| private_key => $PRIVATE_KEY, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loginWithGoogle( | |
| process.env.PROJ_TEST1_GMAIL_USER, | |
| process.env.PROJ_TEST1_GMAIL_PASS | |
| ) | |
| /** | |
| * Uses the dreaded `sleep` method because finding the password | |
| * by any css selector tried fails. | |
| * @param {string} username - A Google username. | |
| * @param {string} passphrase - A Google passpharse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Wizard = function (state) { | |
| this.state = {}; | |
| // pageName: null, | |
| // lastPageName: null | |
| // window.history.popstate();? | |
| Object.keys(state).forEach((key) => { | |
| this.state[key] = state[key]; | |
| }); | |
| this.pageEl = null; | |
| this.el = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| el.main.innerHTML = Handlebars.compile( | |
| el.innerHTML.toString() | |
| )( | |
| { myContext: this } | |
| ); | |
| // {{#includeDomTemplate "publish-tables-and-skus"}}{{/includeDomTemplate}} | |
| Handlebars.registerHelper('includeDomTemplate', function(templateId) { | |
| var html = Handlebars.compile( | |
| document.getElementById(templateId).innerHTML.toString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Wizard = function (access_token) { | |
| this.access_token = access_token; | |
| this.page = 0; | |
| this.el = { | |
| main: document.getElementById('main'), | |
| pageNumber: document.getElementById('pageNumber') | |
| }; | |
| this.el.pageNumber.setAttribute('style', 'display:block"'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dns = require('dns'), cache = {}; | |
| dns._lookup = dns.lookup; | |
| dns.lookup = function(domain) { | |
| return new Promise( (resolve, reject) => { | |
| var key = domain; | |
| if (key in cache) { | |
| var ip = cache[key], | |
| ipv = ip.indexOf('.') !== -1 ? 4 : 6; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // base.js | |
| function Base(options) { | |
| var category; | |
| // https://github.com/v8/v8/wiki/Stack-Trace-API | |
| try { | |
| category = ((new Error).stack.split('\n'))[2].match(/^\s+at\sBase\.(\w+)/)[1]; | |
| } | |
| catch (e) { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Base.prototype.ERROR = []; | |
| Base.errorNames = [ | |
| 'PageContext', 'NotYetSupported', 'NaN', 'ColDefPropertyNotFound', | |
| 'ColDefValueNotFound', 'InvalidArgument', 'MissingArgument', | |
| 'UnknownError', 'InvalidCssSelector' | |
| ]; | |
| Base.errorNames.forEach(function(errName) { | |
| Base.prototype.ERROR[errName] = function (message) { | |
| Error.captureStackTrace(this, this.constructor); |