From 1f08fa4be5c6f4d974c3f6648bad6dfd61ee9e25 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 30 Oct 2017 17:38:15 -0300 Subject: [PATCH 001/207] Add 'Report an issue' button on user dropdown --- templates/server/admin.hbs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/server/admin.hbs b/templates/server/admin.hbs index d1d9ae0e..4c65f3e3 100644 --- a/templates/server/admin.hbs +++ b/templates/server/admin.hbs @@ -31,6 +31,8 @@ From 8dff7d4f426cd25e0d32ebcafbf2298781756022 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 30 Oct 2017 17:38:43 -0300 Subject: [PATCH 002/207] Validate URL in logo path (by regex) --- api/admin/put_settings.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/admin/put_settings.js b/api/admin/put_settings.js index cf77cde0..37122b2f 100644 --- a/api/admin/put_settings.js +++ b/api/admin/put_settings.js @@ -1,6 +1,9 @@ import Joi from 'joi'; import { setSettings } from '../../lib/storage'; +const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/; +const colorRegex = /^#[A-Fa-f0-9]{6}/; + module.exports = () => ({ method: 'PUT', config: { @@ -10,8 +13,8 @@ module.exports = () => ({ template: Joi.string().required(), locale: Joi.string().required(), title: Joi.string().required(), - color: Joi.string().regex(/^#[A-Fa-f0-9]{6}/).required(), - logoPath: Joi.string().allow('') + color: Joi.string().regex(colorRegex).required(), + logoPath: Joi.string().regex(urlRegex).allow('') } } }, From 6bff9d9315dedf8f35b4cc73c0acfc2a8aad3f45 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 30 Oct 2017 17:57:12 -0300 Subject: [PATCH 003/207] Fix lock button border-radius --- public/css/link.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/link.css b/public/css/link.css index 62f8dc69..09b3c98c 100644 --- a/public/css/link.css +++ b/public/css/link.css @@ -1383,7 +1383,7 @@ width: 100%; height: 70px; overflow: hidden; - border-radius: 0 0 0px 5px; + border-radius: 0 0 5px 5px; -webkit-transition: 0.2s ease-in-out; transition: 0.2s ease-in-out; color: #fff; From 27067fdddc28d8051d0f15506792e737746b1a79 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 30 Oct 2017 18:03:05 -0300 Subject: [PATCH 004/207] Reduce widget drop-shadow --- public/css/link.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/link.css b/public/css/link.css index 09b3c98c..3f0a5861 100644 --- a/public/css/link.css +++ b/public/css/link.css @@ -1766,7 +1766,7 @@ transition: transform 0.6s, opacity 0.6s, -webkit-transform 0.6s; -webkit-transition-delay: 0.5s; transition-delay: 0.5s; - box-shadow: 0 0 40px 4px #111118; + box-shadow: 0 0 40px 4px rgba(0,0,0,0.3); } } @media screen and (max-width: 480px) { From 4bd9834946e885841c7418e09e16f186001bf480 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 30 Oct 2017 18:17:08 -0300 Subject: [PATCH 005/207] Fixes --- public/css/link.css | 5 +++++ templates/utils/auth0widget.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/public/css/link.css b/public/css/link.css index 3f0a5861..f5c184ba 100644 --- a/public/css/link.css +++ b/public/css/link.css @@ -1768,6 +1768,11 @@ transition-delay: 0.5s; box-shadow: 0 0 40px 4px rgba(0,0,0,0.3); } + + .auth0-lock.auth0-lock-outlined .auth0-lock-widget { + box-shadow: none !important; + border: 1px solid #ccc !important; + } } @media screen and (max-width: 480px) { .auth0-lock.auth0-lock.auth0-lock-opened .auth0-lock-widget { diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index 0450745a..ba5c673c 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -9,7 +9,7 @@ export default (hideOverlay = false) => getSettings().then(settings => { resolve(`
-
+
${hideOverlay ? '' : ` From 7330d46dd5b2d5053ca014ee001acada9f354554 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 13:23:20 -0300 Subject: [PATCH 006/207] Implement individual localization --- lib/locale.js | 21 ++++++++++++++++++++- templates/utils/auth0widget.js | 12 ++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/locale.js b/lib/locale.js index e0e9b304..33d0e185 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -3,7 +3,26 @@ import jsonLocales from '../locales.json'; export const allLocales = jsonLocales; +let _settings = null; + +function resolveLocale(key) { + const locales = allLocales[_settings.locale]; + + let locale = locales[key]; + console.log('locale', locale); + + if (typeof locale === 'undefined') { + locale = allLocales.en[key]; + } + + return locale; +} + export default () => new Promise((resolve) => { - getSettings().then(settings => resolve(allLocales[settings.locale])); + getSettings() + .then((settings) => { + _settings = settings; + }) + .then(resolve(resolveLocale)); }); diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index ba5c673c..105720f4 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -63,7 +63,7 @@ export default (hideOverlay = false) => `} -
${settings.title !== '' ? settings.title : t.accountLinking}
+
${settings.title !== '' ? settings.title : t('accountLinking')}
@@ -78,11 +78,11 @@ export default (hideOverlay = false) =>

- ${t.introduction} + ${t('introduction')}

@@ -98,7 +98,7 @@ export default (hideOverlay = false) =>
+
+ Remove widget's overlay +
+ diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index 105720f4..c1025ee6 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -3,14 +3,14 @@ import getCurrentLocale from '../../lib/locale'; import svgDimensions from '../../lib/svgDimensions'; import { getSettings } from '../../lib/storage'; -export default (hideOverlay = false) => +export default () => new Promise(resolve => { getCurrentLocale().then(t => { getSettings().then(settings => { resolve(`
-
- ${hideOverlay +
+ ${settings.removeOverlay ? '' : `
From f72a8960f6bb8911c4436cb2945761d91cc34dfe Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 14:32:05 -0300 Subject: [PATCH 009/207] Change bluebird version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c1616898..47117bff 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "auth0-extension-tools@1.2.1", "auth0-extension-hapi-tools@1.2.0", "boom@3.2.2", - "bluebird@3.4.6", + "bluebird@3.5.0", "compression@1.4.4", "delegates@0.1.0", "depd@1.0.1", @@ -65,7 +65,6 @@ "auth0": "^2.8.0", "auth0-extension-hapi-tools": "1.2.0", "auth0-extension-tools": "^1.2.1", - "bluebird": "^3.5.1", "boom": "3.2.2", "handlebars": "^4.0.11", "hapi": "13.5.0", @@ -95,6 +94,7 @@ "babel-preset-es2017": "^6.24.1", "babel-register": "^6.24.1", "babel-runtime": "^6.25.0", + "bluebird": "^3.5.0", "chai": "^4.1.0", "edge": "^7.10.1", "eslint": "^4.3.0", From 63384c457fe5bec9f408570cde062367d98ed103 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 14:32:50 -0300 Subject: [PATCH 010/207] Fix Indent in config.text.json --- server/config.test.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/config.test.json b/server/config.test.json index ccd36013..7b23cdcf 100644 --- a/server/config.test.json +++ b/server/config.test.json @@ -8,8 +8,7 @@ "LOG_COLOR": true, "AUTH0_DOMAIN": "account-linking-testing.local.dev", "AUTH0_CLIENT_ID": "iAsec-6IaWtJmJhsMz2HR1tPDOvN72Zr", - "AUTH0_CLIENT_SECRET": - "8FLdS-ryDdf0Btipy8UjPGSAABjgiuzlWKKQ2L3QPjYaLNjcXzpUt2tkjJ94wkQT", + "AUTH0_CLIENT_SECRET": "8FLdS-ryDdf0Btipy8UjPGSAABjgiuzlWKKQ2L3QPjYaLNjcXzpUt2tkjJ94wkQT", "WT_URL": "localhost:3001", "EXTENSION_SECRET": "d2h8f03wghjti404-gjfeqihu0cre" } From 5c73104eeb1c04d10846d62f22a7d0895037acf2 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 14:37:50 -0300 Subject: [PATCH 011/207] Remove bluebird as dev dependency --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 47117bff..d609eb9a 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "babel-preset-es2017": "^6.24.1", "babel-register": "^6.24.1", "babel-runtime": "^6.25.0", - "bluebird": "^3.5.0", "chai": "^4.1.0", "edge": "^7.10.1", "eslint": "^4.3.0", From 55f7312d8cc6613f1dfd03d0f869364b4db105eb Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 15:28:16 -0300 Subject: [PATCH 012/207] Use 'api' parameter name on modify rule to make it compatibla with adapter classes --- modifyRule.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modifyRule.js b/modifyRule.js index 32b7e2f5..7ea64147 100644 --- a/modifyRule.js +++ b/modifyRule.js @@ -6,14 +6,14 @@ const RULE_NAME = 'auth0-account-link-extension'; const findIn = rules => rules.find(rule => rule.name === RULE_NAME); // Allowing partial application to make usage with promises nicer -const persistRule = ({create, update}, generatedRule) => (rules = []) => { +const persistRule = (api, generatedRule) => (rules = []) => { const existingRule = rules.find(rule => rule.name === RULE_NAME); if (existingRule) { - return update({ id: existingRule.id }, generatedRule); + return api.update({ id: existingRule.id }, generatedRule); } - return create({ stage: RULE_STAGE, ...generatedRule }); + return api.create({ stage: RULE_STAGE, ...generatedRule }); }; const destroyRule = (api) => (rules = []) => { From b7329bcf831d7b8a0994de84e0cf4eea815196fe Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 15:32:41 -0300 Subject: [PATCH 013/207] Use an adapter for gulpfile rule patching --- gulpfile.js | 26 +++++++++++++----- lib/managementAdapter.js | 56 ++++++++++++++++++++++++++++++++++++++ lib/patchRule.js | 59 ---------------------------------------- 3 files changed, 75 insertions(+), 66 deletions(-) create mode 100644 lib/managementAdapter.js delete mode 100644 lib/patchRule.js diff --git a/gulpfile.js b/gulpfile.js index b0316ebe..acece079 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,10 +1,14 @@ require('babel-register')(); + const gulp = require('gulp'); const util = require('gulp-util'); const ngrok = require('ngrok'); const nodemon = require('gulp-nodemon'); -const patchRule = require('./lib/patchRule').default; +const { install } = require('./modifyRule') +const managementAdapter = require('./lib/managementAdapter'); +const ManagementClientAdapter = managementAdapter.default; +const { getCurrentConfig } = managementAdapter; gulp.task('run', () => { ngrok.connect(3001, (ngrokError, url) => { @@ -37,13 +41,21 @@ gulp.task('run', () => { util.log('Public Url:', publicUrl); util.log('Patching rule on tenant.'); - patchRule(publicUrl) - .then(() => { - util.log('Rule patched on tenant.'); + getCurrentConfig().then((config) => { + const adapter = new ManagementClientAdapter(config); + install(adapter, { + extensionURL: publicUrl, + username: 'Development', + clientID: config.AUTH0_CLIENT_ID, + clientSecret: config.AUTH0_CLIENT_SECRET }) - .catch((error) => { - util.log("Couldn't patch rule in tenant:", error); - }); + .then(() => { + util.log('Rule patched on tenant.'); + }) + .catch((error) => { + util.log("Couldn't patch rule in tenant:", error); + }); + }); }, 4000); }); }); diff --git a/lib/managementAdapter.js b/lib/managementAdapter.js new file mode 100644 index 00000000..2e37a17b --- /dev/null +++ b/lib/managementAdapter.js @@ -0,0 +1,56 @@ +import path from 'path'; +import { readFile } from 'fs'; +import { promisify } from 'bluebird'; +import { ManagementClient } from 'auth0'; +import generateRule from '../rules/link'; + +const RULE_NAME = 'auth0-account-link-extension'; +const readFileAsync = promisify(readFile); + +/** + * Reads the current configuration file and returns its contents. + */ +export async function getCurrentConfig() { + const configFilePath = path.join(__dirname, '../server/config.json'); + const fileContents = await readFileAsync(configFilePath); + + return JSON.parse(fileContents); +} + +export default class ManagementClientAdapter { + /** + * Creates a new management client + */ + constructor({ AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_DOMAIN }) { + this.client = new ManagementClient({ + domain: AUTH0_DOMAIN, + clientId: AUTH0_CLIENT_ID, + clientSecret: AUTH0_CLIENT_SECRET, + scope: 'read:rules update:rules delete:rules create:rules' + }); + } + + /** + * Gets all rules from Auth0 + */ + async getAll() { + return this.client.getRules(); + } + + /** + * Creates a new rule in Auth0 + * @param {object} rule + */ + async create(rule) { + return this.client.createRule(rule); + } + + /** + * Updates a rule in Auth0 + * @param {object} options + * @param {object} generatedRule + */ + async update({ id }, { name, script, enabled }) { + return this.client.updateRule({ id }, { name, script, enabled }); + } +} diff --git a/lib/patchRule.js b/lib/patchRule.js deleted file mode 100644 index 3b3d703a..00000000 --- a/lib/patchRule.js +++ /dev/null @@ -1,59 +0,0 @@ -import path from 'path'; -import { readFile } from 'fs'; -import { promisify } from 'bluebird'; -import { ManagementClient } from 'auth0'; -import generateRule from '../rules/link'; - -const RULE_NAME = 'auth0-account-link-extension'; -const readFileAsync = promisify(readFile); - -/** - * Reads the current configuration file and returns its contents. - */ -async function getCurrentConfig() { - const configFilePath = path.join(__dirname, '../server/config.json'); - const fileContents = await readFileAsync(configFilePath); - - return JSON.parse(fileContents); -} - -/** - * Updates the current rule in Auth0 with the local rule code. - * @param {string} extensionURL - */ -export default async function patchRule(extensionURL) { - const { AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_DOMAIN } = await getCurrentConfig(); - const auth0 = new ManagementClient({ - domain: AUTH0_DOMAIN, - clientId: AUTH0_CLIENT_ID, - clientSecret: AUTH0_CLIENT_SECRET, - scope: 'read:rules update:rules delete:rules create:rules' - }); - - const rules = await auth0.getRules(); - const accountLinkingRule = rules.find(r => r.name === RULE_NAME); - const newRuleContent = generateRule({ - extensionURL, - username: 'Development', - clientID: AUTH0_CLIENT_ID, - clientSecret: AUTH0_CLIENT_SECRET - }); - - if (!accountLinkingRule) { - return auth0 - .createRule({ - name: RULE_NAME, - script: newRuleContent, - enabled: true - }) - .catch((ruleCreationError) => { - throw ruleCreationError; - }); - } - - return auth0 - .updateRule({ id: accountLinkingRule.id }, { script: newRuleContent }) - .catch((ruleUpdateError) => { - throw ruleUpdateError; - }); -} From 0942016d2fd73b58694d8038aba5552b30b2c11a Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 15:33:51 -0300 Subject: [PATCH 014/207] Fixes --- lib/managementAdapter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/managementAdapter.js b/lib/managementAdapter.js index 2e37a17b..5dfea61d 100644 --- a/lib/managementAdapter.js +++ b/lib/managementAdapter.js @@ -2,9 +2,7 @@ import path from 'path'; import { readFile } from 'fs'; import { promisify } from 'bluebird'; import { ManagementClient } from 'auth0'; -import generateRule from '../rules/link'; -const RULE_NAME = 'auth0-account-link-extension'; const readFileAsync = promisify(readFile); /** From f0558ca0ed27d15c0248612e8e780825c5076f20 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 31 Oct 2017 15:49:45 -0300 Subject: [PATCH 015/207] Fix failures_test to work with storage --- test/acceptance/failures_test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/acceptance/failures_test.js b/test/acceptance/failures_test.js index 749836c5..b72df471 100644 --- a/test/acceptance/failures_test.js +++ b/test/acceptance/failures_test.js @@ -1,7 +1,10 @@ -import {expect} from 'chai'; -import { request, createServer } from '../test_helper'; +import path from 'path'; +import { expect } from 'chai'; import { sign } from 'jsonwebtoken'; +import { FileStorageContext } from 'auth0-extension-tools'; +import { request, createServer } from '../test_helper'; import config from '../../lib/config'; +import { init as initStorage } from '../../lib/db'; describe('Requesting the linking route', function() { describe('With an invalid token', function() { @@ -9,6 +12,7 @@ describe('Requesting the linking route', function() { before(function() { server = createServer(); + initStorage(new FileStorageContext(path.join(__dirname, '../../data.json'))); }); after(function() { From 7d936dd3ea39d2d432e8613d6e9abc98bbe8ddbf Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Wed, 1 Nov 2017 15:38:11 -0300 Subject: [PATCH 016/207] Dynamic settings --- api/get_index.js | 13 +++++++++++-- lib/locale.js | 31 +++++++++++-------------------- templates/index.js | 4 ++-- templates/utils/auth0widget.js | 23 +++++++++++------------ 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/api/get_index.js b/api/get_index.js index 2d4025aa..71219160 100644 --- a/api/get_index.js +++ b/api/get_index.js @@ -39,13 +39,21 @@ module.exports = _ => ({ const stylesheetLink = config('NODE_ENV') === 'production' ? CDN_CSS : '/css/link.css'; + const dynamicSettings = {}; + + if (req.query.locale) dynamicSettings.locale = req.query.locale; + if (req.query.color) dynamicSettings.color = '#' + req.query.color; + if (req.query.title) dynamicSettings.title = req.query.title; + if (req.query.logoPath) dynamicSettings.logoPath = req.query.logoPath; + decodeToken(req.query.child_token).then(token => { fetchUsersFromToken(token).then(({currentUser, matchingUsers}) => { reply(indexTemplate({ stylesheetLink, currentUser, matchingUsers, - customCSS: config('CUSTOM_CSS') + customCSS: config('CUSTOM_CSS'), + dynamicSettings })); }) .catch(err => { @@ -62,7 +70,8 @@ module.exports = _ => ({ stylesheetLink, currentUser: null, matchingUsers: [], - customCSS: config('CUSTOM_CSS') + customCSS: config('CUSTOM_CSS'), + dynamicSettings }).then((template) => { reply(template).code(400); }); diff --git a/lib/locale.js b/lib/locale.js index f6252f5a..bb459783 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -3,25 +3,16 @@ import jsonLocales from '../locales.json'; export const allLocales = jsonLocales; -let _settings = null; - -function resolveLocale(key) { - const locales = allLocales[_settings.locale]; - - let locale = locales[key]; - - if (typeof locale === 'undefined') { - locale = allLocales.en[key]; +export default function resolveLocale(locale) { + return function resolve(key) { + const locales = allLocales[locale]; + + let localeStr = locales[key]; + + if (typeof localeStr === 'undefined') { + localeStr = allLocales.en[key]; + } + + return localeStr; } - - return locale; } - -export default () => - new Promise((resolve) => { - getSettings() - .then((settings) => { - _settings = settings; - }) - .then(resolve(resolveLocale)); - }); diff --git a/templates/index.js b/templates/index.js index d85a6222..62c1dfac 100644 --- a/templates/index.js +++ b/templates/index.js @@ -8,12 +8,12 @@ import buildExtensionScripts from './utils/extensionScripts'; const stylesheetTag = href => (href ? `` : ''); -export default ({ stylesheetLink, customCSS, currentUser, matchingUsers }) => +export default ({ stylesheetLink, customCSS, currentUser, matchingUsers, dynamicSettings }) => new Promise((resolve) => { getStorage().read().then((data) => { const template = data.settings ? data.settings.template : defaultTemplate; - buildAuth0Widget().then((Auth0Widget) => { + buildAuth0Widget(dynamicSettings).then((Auth0Widget) => { resolve(render(template, { ExtensionCSS: stylesheetTag(stylesheetLink), CustomCSS: stylesheetTag(customCSS), diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index c1025ee6..9447177a 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -3,16 +3,16 @@ import getCurrentLocale from '../../lib/locale'; import svgDimensions from '../../lib/svgDimensions'; import { getSettings } from '../../lib/storage'; -export default () => +export default dynamicSettings => new Promise(resolve => { - getCurrentLocale().then(t => { - getSettings().then(settings => { - resolve(` + getSettings().then(storedSettings => { + const settings = Object.assign(storedSettings, dynamicSettings); + const t = getCurrentLocale(settings.locale); + + resolve(`
- ${settings.removeOverlay - ? '' - : ` + ${settings.removeOverlay ? '' : `
- ${settings.logoPath !== '' ? ` + ${settings.logoPath !== '' + ? ` - - ` : ` + ` : `
- `; +}; export default dynamicSettings => new Promise(resolve => { @@ -11,29 +57,8 @@ export default dynamicSettings => resolve(`
-
- ${settings.removeOverlay ? '' : ` - - `} +
+ ${lockOverlay(settings.removeOverlay)}
@@ -44,26 +69,8 @@ export default dynamicSettings =>
- ${settings.logoPath !== '' - ? ` - - - ` : ` - - - - `} -
${settings.title !== '' ? settings.title : t('accountLinking')}
+ ${getLogo(settings)} +
${getTitle(settings, t)}
@@ -96,14 +103,7 @@ export default dynamicSettings =>
- + ${getSubmitButton(settings, t)}
diff --git a/templates/utils/lockOverlay.js b/templates/utils/lockOverlay.js new file mode 100644 index 00000000..a062b4c0 --- /dev/null +++ b/templates/utils/lockOverlay.js @@ -0,0 +1,31 @@ +import svgDimensions from '../../lib/svgDimensions'; + +export const lockOutlineClass = (hide = false) => (hide ? 'auth0-lock-outlined' : ''); + +export default function lockOverlay(hide = false) { + if (hide) { + return ''; + } + + return ` + `; +} From 72de040422355d1693684bacdf8558227fc282ad Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Thu, 9 Nov 2017 14:42:17 -0300 Subject: [PATCH 029/207] Quick fix --- api/get_index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/get_index.js b/api/get_index.js index b5a684d7..19823107 100644 --- a/api/get_index.js +++ b/api/get_index.js @@ -67,11 +67,11 @@ module.exports = _ => ({ console.error("An invalid token was provided", err); indexTemplate({ + dynamicSettings, stylesheetLink, currentUser: null, matchingUsers: [], - customCSS: config('CUSTOM_CSS'), - dynamicSettings + customCSS: config('CUSTOM_CSS') }).then((template) => { reply(template).code(400); }); From e50656aa3733c72e69945be0735f38aa90f4433f Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Thu, 9 Nov 2017 14:47:19 -0300 Subject: [PATCH 030/207] Quick fix --- rules/link.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rules/link.js b/rules/link.js index e6e32115..f8e95652 100644 --- a/rules/link.js +++ b/rules/link.js @@ -128,11 +128,9 @@ export default ({extensionURL = '', username = 'Unknown', clientID = '', clientS function promptUser() { return searchUsersWithSameEmail().then(function transformUsers(users) { - users = users.filter(function(u) { + return users.filter(function(u) { return u.user_id !== user.user_id; - }); - - return users.map(function(user) { + }).map(function(user) { return { userId: user.user_id, email: user.email, From c11ac37c420457bd1bc3bf8de9de1cab373dc74d Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 13 Nov 2017 17:33:08 -0300 Subject: [PATCH 031/207] Change joi version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb388ed5..a47e0773 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "hapi": "13.5.0", "hapi-auth-jwt2": "^7.0.1", "inert": "4.0.1", - "joi": "^13.0.1", + "joi": "9.0.4", "jsonwebtoken": "^8.1.0", "jwks-rsa": "^1.2.1", "md5": "^2.2.1", From 6ec21a996cec43f0cce02a36167b78742243bf3a Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 13 Nov 2017 17:44:16 -0300 Subject: [PATCH 032/207] Rename DB test --- test/unit/db_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/db_test.js b/test/unit/db_test.js index 16fbbaef..7d17e2e6 100644 --- a/test/unit/db_test.js +++ b/test/unit/db_test.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { init, get } from '../../lib/db'; describe('DB Tests', () => { - it('throws an error if I try to get an nonexistent DB', () => { + it('throws an error when fetching from an invalid DB', () => { init(null); expect(() => get()).to.throw('The DB has not been initialized.'); }); From 33783fea2746ebe973f032fd13e10d34b0e7c841 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 13 Nov 2017 18:01:02 -0300 Subject: [PATCH 033/207] Small fix --- api/get_index.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/api/get_index.js b/api/get_index.js index ac0ac0e6..5fc77f8f 100644 --- a/api/get_index.js +++ b/api/get_index.js @@ -41,28 +41,35 @@ module.exports = () => ({ const dynamicSettings = {}; if (req.query.locale) dynamicSettings.locale = req.query.locale; - if (req.query.color) dynamicSettings.color = '#' + req.query.color; + if (req.query.color) dynamicSettings.color = `#${req.query.color}`; if (req.query.title) dynamicSettings.title = req.query.title; if (req.query.logoPath) dynamicSettings.logoPath = req.query.logoPath; - decodeToken(req.query.child_token).then(token => { - fetchUsersFromToken(token).then(({currentUser, matchingUsers}) => { - reply(indexTemplate({ - dynamicSettings, - stylesheetLink, - currentUser, - matchingUsers, - customCSS: config('CUSTOM_CSS') - })); - }) - .catch(err => { - const state = req.query.state; - console.error("An error was encountered: ", err); - console.info(`Redirecting to failed link to /continue: ${token.iss}continue?state=${req.query.state}`); + decodeToken(req.query.child_token) + .then((token) => { + fetchUsersFromToken(token) + .then(({ currentUser, matchingUsers }) => { + reply( + indexTemplate({ + dynamicSettings, + stylesheetLink, + currentUser, + matchingUsers, + customCSS: config('CUSTOM_CSS') + }) + ); + }) + .catch((err) => { + const state = req.query.state; + console.error('An error was encountered: ', err); + console.info( + `Redirecting to failed link to /continue: ${token.iss}continue?state=${req.query + .state}` + ); - reply.redirect(`${token.iss}continue?state=${state}`); - }); - }) + reply.redirect(`${token.iss}continue?state=${state}`); + }); + }) .catch((err) => { logger.error('An invalid token was provided', err); @@ -75,5 +82,6 @@ module.exports = () => ({ }).then((template) => { reply(template).code(400); }); + }); } }); From 6c6e77f69081a6ae6773ecf8709230ef412c2a56 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 13 Nov 2017 18:02:01 -0300 Subject: [PATCH 034/207] Syntax fix --- templates/index.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/templates/index.js b/templates/index.js index b4c788bb..f488ebf8 100644 --- a/templates/index.js +++ b/templates/index.js @@ -9,15 +9,20 @@ const stylesheetTag = href => (href ? `` export default ({ stylesheetLink, customCSS, currentUser, matchingUsers, dynamicSettings }) => new Promise((resolve) => { - getStorage().read().then((data) => { - const template = data.settings ? data.settings.template : defaultTemplate; - - buildAuth0Widget(dynamicSettings).then((Auth0Widget) => { - resolve(render(template, { - ExtensionCSS: stylesheetTag(stylesheetLink), - CustomCSS: stylesheetTag(customCSS), - Auth0Widget, - ExtensionScripts: buildExtensionScripts(currentUser, matchingUsers) - })); + getStorage() + .read() + .then((data) => { + const template = data.settings ? data.settings.template : defaultTemplate; + + buildAuth0Widget(dynamicSettings).then((Auth0Widget) => { + resolve( + render(template, { + ExtensionCSS: stylesheetTag(stylesheetLink), + CustomCSS: stylesheetTag(customCSS), + Auth0Widget, + ExtensionScripts: buildExtensionScripts(currentUser, matchingUsers) + }) + ); + }); }); }); From 92888e0b7fe095f1218dad254b917bbd26133e99 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 13 Nov 2017 18:03:43 -0300 Subject: [PATCH 035/207] Linting fixes --- api/get_index.js | 4 ++-- lib/locale.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/api/get_index.js b/api/get_index.js index 5fc77f8f..9d85282e 100644 --- a/api/get_index.js +++ b/api/get_index.js @@ -61,8 +61,8 @@ module.exports = () => ({ }) .catch((err) => { const state = req.query.state; - console.error('An error was encountered: ', err); - console.info( + logger.error('An error was encountered: ', err); + logger.info( `Redirecting to failed link to /continue: ${token.iss}continue?state=${req.query .state}` ); diff --git a/lib/locale.js b/lib/locale.js index 06692638..fb0e9729 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -1,4 +1,3 @@ -import { getSettings } from './storage'; import jsonLocales from '../locales.json'; export const allLocales = jsonLocales; From 3de0ac6c44e960a98a8b61b302d07c68541c06d1 Mon Sep 17 00:00:00 2001 From: Matthew Machuga Date: Mon, 13 Nov 2017 22:10:19 -0500 Subject: [PATCH 036/207] Stripping out incompatible changes --- api/admin/get_index.js | 4 +- lib/avatar.js | 10 +-- package.json | 3 - server/index.js | 10 --- templates/index.js | 10 ++- templates/server/{admin.hbs => admin.js} | 4 +- yarn.lock | 90 ++++++++++++++++++++++-- 7 files changed, 104 insertions(+), 27 deletions(-) rename templates/server/{admin.hbs => admin.js} (99%) diff --git a/api/admin/get_index.js b/api/admin/get_index.js index a83b71b0..7065910d 100644 --- a/api/admin/get_index.js +++ b/api/admin/get_index.js @@ -1,3 +1,5 @@ +import template from '../../templates/server/admin'; + module.exports = () => ({ method: 'GET', path: '/admin', @@ -5,6 +7,6 @@ module.exports = () => ({ auth: false }, handler: (req, reply) => { - reply.view('admin'); + reply(template); } }); diff --git a/lib/avatar.js b/lib/avatar.js index d885e6a2..b892831e 100644 --- a/lib/avatar.js +++ b/lib/avatar.js @@ -1,8 +1,10 @@ -import md5 from 'md5'; +import crypto from 'crypto'; -export default (email) => { - const md5email = md5(email); +const avatarUrl = (email) => { + const hashedEmail = crypto.createHash('md5').update(email).digest('hex'); const letters = email.substr(0, 2); - return `https://s.gravatar.com/avatar/${md5email}?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2F${letters}.png`; + return `https://s.gravatar.com/avatar/${hashedEmail}?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2F${letters}.png`; }; + +export default avatarUrl; \ No newline at end of file diff --git a/package.json b/package.json index 2eabd09e..883c9ada 100644 --- a/package.json +++ b/package.json @@ -74,12 +74,9 @@ "joi": "9.0.4", "jsonwebtoken": "^8.1.0", "jwks-rsa": "^1.2.1", - "md5": "^2.2.1", - "micromustache": "^5.2.0", "nconf": "^0.8.4", "open": "^0.0.5", "request": "2.56.0", - "vision": "^4.1.1", "webtask-tools": "^3.2.0", "winston": "1.0.0" }, diff --git a/server/index.js b/server/index.js index 906c6827..e151c181 100644 --- a/server/index.js +++ b/server/index.js @@ -27,16 +27,6 @@ const createServer = (cb, handlers = defaultHandlers) => { server.register([jwt, Inert], () => {}); - server.register(require('vision'), () => { - server.views({ - engines: { - hbs: require('handlebars') - }, - relativeTo: path.join(__dirname, '../templates'), - path: 'server' - }); - }); - server.route({ method: 'GET', path: '/js/{file*}', diff --git a/templates/index.js b/templates/index.js index f488ebf8..348419f5 100644 --- a/templates/index.js +++ b/templates/index.js @@ -1,10 +1,18 @@ -import { render } from 'micromustache'; import defaultTemplate from './utils/defaultTemplate'; import { get as getStorage } from '../lib/db'; import buildAuth0Widget from './utils/auth0widget'; import buildExtensionScripts from './utils/extensionScripts'; +const VAR_REGEX = /\{\{\s*(.*?)\s*\}\}/g; +const render = (template, locals = {}) => { + if (!template || typeof template !== 'string') { + throw new Error('Invalid template provided'); + } + + return template.replace(VAR_REGEX, (match, name) => locals[name] || ''); +}; + const stylesheetTag = href => (href ? `` : ''); export default ({ stylesheetLink, customCSS, currentUser, matchingUsers, dynamicSettings }) => diff --git a/templates/server/admin.hbs b/templates/server/admin.js similarity index 99% rename from templates/server/admin.hbs rename to templates/server/admin.js index 400521e8..e5198b77 100644 --- a/templates/server/admin.hbs +++ b/templates/server/admin.js @@ -1,3 +1,4 @@ +export default ` @@ -96,4 +97,5 @@ - \ No newline at end of file + +`; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 64f23a36..941cfd59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -367,7 +367,7 @@ auth0-extension-tools@1.2.0: superagent "^2.2.0" webtask-tools "^2.2.0" -auth0-extension-tools@1.2.1: +auth0-extension-tools@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/auth0-extension-tools/-/auth0-extension-tools-1.2.1.tgz#0ad36e725759cb156dd87870e64258809d54e71d" dependencies: @@ -1160,10 +1160,6 @@ bluebird@^3.4.1, bluebird@^3.4.7, bluebird@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" -bluebird@^3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: version "4.11.8" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" @@ -1186,7 +1182,7 @@ boom@4.x.x: dependencies: hoek "4.x.x" -boom@5.x.x: +boom@5.x.x, boom@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" dependencies: @@ -2896,6 +2892,16 @@ gulplog@^1.0.0: dependencies: glogg "^1.0.0" +handlebars@^4.0.11: + version "4.0.11" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" + dependencies: + async "^1.4.0" + optimist "^0.6.1" + source-map "^0.4.4" + optionalDependencies: + uglify-js "^2.6" + handlebars@^4.0.3: version "4.0.10" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" @@ -2914,6 +2920,14 @@ hapi-auth-jwt2@7.0.1: cookie "^0.3.1" jsonwebtoken "^7.0.0" +hapi-auth-jwt2@^7.0.1: + version "7.3.0" + resolved "https://registry.yarnpkg.com/hapi-auth-jwt2/-/hapi-auth-jwt2-7.3.0.tgz#96dd2a09480e9cc94f365d1baec68cd5bc597a37" + dependencies: + boom "^5.1.0" + cookie "^0.3.1" + jsonwebtoken "^7.4.1" + hapi@13.5.0: version "13.5.0" resolved "https://registry.yarnpkg.com/hapi/-/hapi-13.5.0.tgz#a5ffbcac57d370c733c81b1ac074c4f13767ecb3" @@ -3559,6 +3573,16 @@ joi@8.x.x: moment "2.x.x" topo "2.x.x" +joi@9.0.4: + version "9.0.4" + resolved "https://registry.yarnpkg.com/joi/-/joi-9.0.4.tgz#88d64890915abeb127cd757027116d50df3e68df" + dependencies: + hoek "4.x.x" + isemail "2.x.x" + items "2.x.x" + moment "2.x.x" + topo "2.x.x" + joi@9.x.x: version "9.2.0" resolved "https://registry.yarnpkg.com/joi/-/joi-9.2.0.tgz#3385ac790192130cbe230e802ec02c9215bbfeda" @@ -3665,6 +3689,31 @@ jsonwebtoken@^7.0.0, jsonwebtoken@^7.1.9: ms "^2.0.0" xtend "^4.0.1" +jsonwebtoken@^7.4.1: + version "7.4.3" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-7.4.3.tgz#77f5021de058b605a1783fa1283e99812e645638" + dependencies: + joi "^6.10.1" + jws "^3.1.4" + lodash.once "^4.0.0" + ms "^2.0.0" + xtend "^4.0.1" + +jsonwebtoken@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.1.0.tgz#c6397cd2e5fd583d65c007a83dc7bb78e6982b83" + dependencies: + jws "^3.1.4" + lodash.includes "^4.3.0" + lodash.isboolean "^3.0.3" + lodash.isinteger "^4.0.4" + lodash.isnumber "^3.0.3" + lodash.isplainobject "^4.0.6" + lodash.isstring "^4.0.1" + lodash.once "^4.0.0" + ms "^2.0.0" + xtend "^4.0.1" + jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -3705,6 +3754,17 @@ jwks-rsa@^1.1.1: ms "^2.0.0" request "^2.73.0" +jwks-rsa@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/jwks-rsa/-/jwks-rsa-1.2.1.tgz#9949100f5643821107787de2947d46f875f6ab5a" + dependencies: + "@types/express-jwt" "0.0.34" + debug "^2.2.0" + limiter "^1.1.0" + lru-memoizer "^1.6.0" + ms "^2.0.0" + request "^2.73.0" + jws@^3.0.0, jws@^3.1.4: version "3.1.4" resolved "https://registry.yarnpkg.com/jws/-/jws-3.1.4.tgz#f9e8b9338e8a847277d6444b1464f61880e050a2" @@ -3923,6 +3983,10 @@ lodash.escape@^3.0.0: dependencies: lodash._root "^3.0.0" +lodash.includes@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" + lodash.isarguments@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" @@ -3931,7 +3995,19 @@ lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" -lodash.isplainobject@^4.0.4: +lodash.isboolean@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" + +lodash.isinteger@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" + +lodash.isnumber@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" + +lodash.isplainobject@^4.0.4, lodash.isplainobject@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" From a2a4d3788c6dc693ccbdae8bbd6a75bc540166b2 Mon Sep 17 00:00:00 2001 From: Matthew Machuga Date: Mon, 13 Nov 2017 22:29:04 -0500 Subject: [PATCH 037/207] Cleaning up the way the template is rendered & readme --- README.md | 4 ++-- templates/index.js | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 12b0923f..a4e3cacd 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Update the configuration file under `./server/config.json`: "AUTH0_DOMAIN": "me.auth0.com", "AUTH0_CLIENT_ID": "myclientid", "AUTH0_CLIENT_SECRET": "myclientsecret", - "WT_URL": "http://localhost:3000" + "WT_URL": "http://localhost:3000" } ``` @@ -43,4 +43,4 @@ In order to run the tests you'll have to [start the extension server locally](ht Then, you can run the tests running: ```bash yarn test -``` \ No newline at end of file +``` diff --git a/templates/index.js b/templates/index.js index 348419f5..6714b1f5 100644 --- a/templates/index.js +++ b/templates/index.js @@ -16,21 +16,14 @@ const render = (template, locals = {}) => { const stylesheetTag = href => (href ? `` : ''); export default ({ stylesheetLink, customCSS, currentUser, matchingUsers, dynamicSettings }) => - new Promise((resolve) => { - getStorage() - .read() - .then((data) => { - const template = data.settings ? data.settings.template : defaultTemplate; + Promise.all([buildAuth0Widget(dynamicSettings), getStorage().read()]) + .then(([widget, data]) => { + const template = data.settings ? data.settings.template : defaultTemplate; - buildAuth0Widget(dynamicSettings).then((Auth0Widget) => { - resolve( - render(template, { - ExtensionCSS: stylesheetTag(stylesheetLink), - CustomCSS: stylesheetTag(customCSS), - Auth0Widget, - ExtensionScripts: buildExtensionScripts(currentUser, matchingUsers) - }) - ); - }); + return render(template, { + ExtensionCSS: stylesheetTag(stylesheetLink), + CustomCSS: stylesheetTag(customCSS), + Auth0Widget: widget, + ExtensionScripts: buildExtensionScripts(currentUser, matchingUsers) }); - }); + }); From 1a9b0dc5fcf6702b39cc16085ebe55499f1bd8ea Mon Sep 17 00:00:00 2001 From: Matthew Machuga Date: Mon, 13 Nov 2017 22:33:16 -0500 Subject: [PATCH 038/207] Fixing dependencies that were breaking builds --- build/bundle.js | 2 +- package.json | 14 ++++++++------ public/css/link.min.css | 2 +- webtask.json | 2 +- yarn.lock | 25 +++++++------------------ 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/build/bundle.js b/build/bundle.js index 1c0b5c75..3e45702e 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1 @@ -module.exports=function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var t={};return e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=60)}([function(n,e){var t=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)},function(n,e,t){var r=t(38)("wks"),o=t(43),i=t(0).Symbol,u="function"==typeof i;(n.exports=function(n){return r[n]||(r[n]=u&&i[n]||(u?i:o)("Symbol."+n))}).store=r},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(44);e.default=(0,r.config)()},function(n,e){var t=n.exports={version:"2.5.0"};"number"==typeof __e&&(__e=t)},function(n,e,t){var r=t(14);n.exports=function(n){if(!r(n))throw TypeError(n+" is not an object!");return n}},function(n,e,t){var r=t(15),o=t(37);n.exports=t(6)?function(n,e,t){return r.f(n,e,o(1,t))}:function(n,e,t){return n[e]=t,n}},function(n,e,t){n.exports=!t(19)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(n,e,t){var r=t(0),o=t(3),i=t(12),u=t(5),s=function(n,e,t){var c,a,l,f=n&s.F,d=n&s.G,p=n&s.S,h=n&s.P,v=n&s.B,g=n&s.W,m=d?o:o[e]||(o[e]={}),y=m.prototype,_=d?r:p?r[e]:(r[e]||{}).prototype;d&&(t=e);for(c in t)(a=!f&&_&&void 0!==_[c])&&c in m||(l=a?_[c]:t[c],m[c]=d&&"function"!=typeof _[c]?t[c]:v&&a?i(l,r):g&&_[c]==l?function(n){var e=function(e,t,r){if(this instanceof n){switch(arguments.length){case 0:return new n;case 1:return new n(e);case 2:return new n(e,t)}return new n(e,t,r)}return n.apply(this,arguments)};return e.prototype=n.prototype,e}(l):h&&"function"==typeof l?i(Function.call,l):l,h&&((m.virtual||(m.virtual={}))[c]=l,n&s.R&&y&&!y[c]&&u(y,c,l)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,n.exports=s},function(n,e){n.exports={}},function(n,e,t){"use strict";var r=t(107);r.emitErrs=!0;var o=new r.Logger({transports:[new r.transports.Console({timestamp:!0,level:"debug",handleExceptions:!0,json:!1,colorize:!0})],exitOnError:!1});n.exports=o},function(n,e){n.exports=function(n){if("function"!=typeof n)throw TypeError(n+" is not a function!");return n}},function(n,e){var t={}.toString;n.exports=function(n){return t.call(n).slice(8,-1)}},function(n,e,t){var r=t(10);n.exports=function(n,e,t){if(r(n),void 0===e)return n;switch(t){case 1:return function(t){return n.call(e,t)};case 2:return function(t,r){return n.call(e,t,r)};case 3:return function(t,r,o){return n.call(e,t,r,o)}}return function(){return n.apply(e,arguments)}}},function(n,e){var t={}.hasOwnProperty;n.exports=function(n,e){return t.call(n,e)}},function(n,e){n.exports=function(n){return"object"==typeof n?null!==n:"function"==typeof n}},function(n,e,t){var r=t(4),o=t(71),i=t(91),u=Object.defineProperty;e.f=t(6)?Object.defineProperty:function(n,e,t){if(r(n),e=i(e,!0),r(t),o)try{return u(n,e,t)}catch(n){}if("get"in t||"set"in t)throw TypeError("Accessors not supported!");return"value"in t&&(n[e]=t.value),n}},function(n,e,t){n.exports={default:t(66),__esModule:!0}},function(n,e){n.exports=function(n){if(void 0==n)throw TypeError("Can't call method on "+n);return n}},function(n,e,t){var r=t(14),o=t(0).document,i=r(o)&&r(o.createElement);n.exports=function(n){return i?o.createElement(n):{}}},function(n,e){n.exports=function(n){try{return!!n()}catch(n){return!0}}},function(n,e,t){"use strict";function r(n){var e,t;this.promise=new n(function(n,r){if(void 0!==e||void 0!==t)throw TypeError("Bad Promise constructor");e=n,t=r}),this.resolve=o(e),this.reject=o(t)}var o=t(10);n.exports.f=function(n){return new r(n)}},function(n,e,t){var r=t(15).f,o=t(13),i=t(1)("toStringTag");n.exports=function(n,e,t){n&&!o(n=t?n:n.prototype,i)&&r(n,i,{configurable:!0,value:e})}},function(n,e,t){var r=t(38)("keys"),o=t(43);n.exports=function(n){return r[n]||(r[n]=o(n))}},function(n,e){var t=Math.ceil,r=Math.floor;n.exports=function(n){return isNaN(n=+n)?0:(n>0?r:t)(n)}},function(n,e,t){var r=t(31),o=t(17);n.exports=function(n){return r(o(n))}},function(n,e){n.exports=require("auth0-extension-hapi-tools@1.2.0")},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0}),e.uninstall=e.install=void 0;var o=t(27),i=r(o),u=t(55),s=r(u),c="auth0-account-link-extension",a=function(n){return n.find(function(n){return n.name===c})},l=function(n,e){var t=n.create,r=n.update;return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=n.find(function(n){return n.name===c});return o?r({id:o.id},e):t((0,i.default)({stage:"login_success"},e))}},f=function(n){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=a(e);t&&n.delete({id:t.id})}},d=function(n,e){var t={name:c,script:(0,s.default)(e),enabled:!0};return n.getAll().then(l(n,t))},p=function(n){return n.getAll().then(f(n))};e.install=d,e.uninstall=p},function(n,e,t){"use strict";e.__esModule=!0;var r=t(62),o=function(n){return n&&n.__esModule?n:{default:n}}(r);e.default=o.default||function(n){for(var e=1;et;)e.push(arguments[t++]);return m[++g]=function(){s("function"==typeof n?n:Function(n),e)},r(g),g},p=function(n){delete m[n]},"process"==t(11)(f)?r=function(n){f.nextTick(u(y,n,1))}:v&&v.now?r=function(n){v.now(u(y,n,1))}:h?(o=new h,i=o.port2,o.port1.onmessage=_,r=u(i.postMessage,i,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(r=function(n){l.postMessage(n+"","*")},l.addEventListener("message",_,!1)):r="onreadystatechange"in a("script")?function(n){c.appendChild(a("script")).onreadystatechange=function(){c.removeChild(this),y.call(n)}}:function(n){setTimeout(u(y,n,1),0)}),n.exports={set:d,clear:p}},function(n,e,t){var r=t(23),o=Math.min;n.exports=function(n){return n>0?o(r(n),9007199254740991):0}},function(n,e,t){var r=t(17);n.exports=function(n){return Object(r(n))}},function(n,e){var t=0,r=Math.random();n.exports=function(n){return"Symbol(".concat(void 0===n?"":n,")_",(++t+r).toString(36))}},function(n,e){n.exports=require("auth0-extension-tools@1.2.1")},function(n,e){n.exports=require("request@2.56.0")},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(2),i=r(o),u=t(57),s=r(u),c=t(9),a=r(c),l=function(n){n?(a.default.error("Hapi initialization failed."),a.default.error(n)):a.default.info("Hapi initialization completed.")},f=function(n,e,r){return i.default.setProvider(function(e){return n(e)||t.i({NODE_ENV:"production",CLIENT_VERSION:"1.1.3"})[e]}),(0,s.default)(r||l)};n.exports=f},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(16),i=r(o),u=t(2),s=r(u),c=t(105),a=t(52),l=r(a),f=t(59),d=r(f),p=t(101).version,h="https://cdn.auth0.com/extensions/auth0-account-link-extension/"+p+"/link.min.css",v=function(n){return new i.default(function(e,t){try{e((0,c.decode)(n))}catch(n){t(n)}})},g=function(n){var e=n.sub,t=n.email;return(0,l.default)(t).then(function(n){return{currentUser:n.find(function(n){return n.user_id===e}),matchingUsers:n.filter(function(n){return n.user_id!==e})}})};n.exports=function(n){return{method:"GET",path:"/",handler:function(n,e){var t="production"===(0,s.default)("NODE_ENV")?h:"/css/link.css";v(n.query.child_token).then(function(r){g(r).then(function(n){var r=n.currentUser,o=n.matchingUsers;e((0,d.default)({stylesheetLink:t,currentUser:r,matchingUsers:o,customCSS:(0,s.default)("CUSTOM_CSS")}))}).catch(function(t){var o=n.query.state;console.error("An error was encountered: ",t),console.info("Redirecting to failed link to /continue: "+r.iss+"continue?state="+n.query.state),e.redirect(r.iss+"continue?state="+o)})}).catch(function(n){console.error("An invalid token was provided",n),e((0,d.default)({stylesheetLink:t,currentUser:null,matchingUsers:[],customCSS:(0,s.default)("CUSTOM_CSS")})).code(400)})}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(2),i=(r(o),t(102)),u=r(i);n.exports=function(n){return{method:"GET",path:"/meta",config:{auth:!1},handler:function(n,e){return e(u.default)}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(16),i=r(o),u=t(26),s=t(2),c=r(s);n.exports=function(n){return{method:"DELETE",path:"/.extensions/on-uninstall",config:{auth:!1,pre:[n.handlers.validateHookToken("/.extensions/on-uninstall"),n.handlers.managementClient]},handler:function(n,e){console.log("Starting uninstall..."),i.default.all([(0,u.uninstall)(n.pre.auth0.rules),n.pre.auth0.deleteClient({client_id:(0,c.default)("AUTH0_CLIENT_ID")})]).then(function(n){return e().code(204)}).catch(function(n){console.error("Something went wrong while uninstalling Account Link Extension: ",n),e().code(204)})}}}},function(n,e,t){"use strict";var r=t(26),o=t(2),i=function(n){return n&&n.__esModule?n:{default:n}}(o);n.exports=function(n){return{method:"POST",path:"/.extensions/on-install",config:{auth:!1,pre:[n.handlers.validateHookToken("/.extensions/on-install"),n.handlers.managementClient]},handler:function(n,e){console.log("Starting rule installation..."),(0,r.install)(n.pre.auth0.rules,{extensionURL:(0,i.default)("PUBLIC_WT_URL"),clientID:(0,i.default)("AUTH0_CLIENT_ID"),clientSecret:(0,i.default)("AUTH0_CLIENT_SECRET")}).then(function(n){return e().code(204)}).then(function(n){console.log("Rule successfully installed")}).catch(function(n){throw console.error("Something went wrong, ",n),n}).catch(function(n){return e.error(n)})}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(27),i=r(o),u=t(16),s=r(u),c=t(63),a=r(c),l=t(44),f=t(2),d=r(f),p=t(45),h=r(p),v={base:void 0,getBaseUrl:function(){return this.base||(this.base="https://"+(0,d.default)("AUTH0_DOMAIN")+"/api/v2"),this.base},endpoint:function(n){return this.getBaseUrl()+"/"+n}},g=function(){return l.managementApi.getAccessTokenCached((0,d.default)("AUTH0_DOMAIN"),(0,d.default)("AUTH0_CLIENT_ID"),(0,d.default)("AUTH0_CLIENT_SECRET"))},m=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=n.path,t=(0,a.default)(n,["path"]);return g().then(function(n){return new s.default(function(r,o){(0,h.default)((0,i.default)({url:v.endpoint(e),headers:{Authorization:"Bearer "+n,Accept:"application/json"},json:!0},t),function(n,e,t){n?o(n):e.statusCode<200||e.statusCode>=300?(console.error("API call failed: ",e.status,t),o(new Error(t))):r(e.body)})})})};e.default=m},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(45),i=(r(o),t(51)),u=r(i),s=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t='email:"'+n+'"';return e&&(t=t+' -user_id:"'+e+'"'),(0,u.default)({path:"users",qs:{q:t,search_engine:"v2"}})};e.default=s},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={text:"M246.517,0.11 C238.439,0.11 231.607,3.916 226.759,11.115 C221.94,18.271 219.393,28.26 219.393,40 C219.393,51.74 221.94,61.729 226.759,68.884 C231.607,76.084 238.439,79.889 246.517,79.889 C254.595,79.889 261.427,76.084 266.275,68.884 C271.093,61.729 273.64,51.74 273.64,40 C273.64,28.26 271.093,18.271 266.275,11.115 C261.427,3.916 254.595,0.11 246.517,0.11 L246.517,0.11 Z M246.517,70.005 C242.655,70.005 239.604,67.82 237.187,63.324 C234.268,57.893 232.66,49.61 232.66,40 C232.66,30.39 234.268,22.106 237.187,16.676 C239.604,12.18 242.655,9.994 246.517,9.994 C250.378,9.994 253.43,12.18 255.847,16.676 C258.766,22.106 260.373,30.389 260.373,40 C260.373,49.611 258.766,57.895 255.847,63.324 C253.43,67.82 250.378,70.005 246.517,70.005 L246.517,70.005 Z M71.45,29.172 L71.45,63.484 C71.45,72.53 78.81,79.889 87.856,79.889 C95.746,79.889 101.707,75.975 103.902,74.291 C104.024,74.197 104.184,74.169 104.331,74.216 C104.478,74.263 104.592,74.379 104.637,74.527 L105.961,78.86 L115.737,78.86 L115.737,29.172 L103.175,29.172 L103.175,66.326 C103.175,66.501 103.076,66.662 102.921,66.743 C100.559,67.961 95.899,70.006 91.231,70.006 C87.252,70.006 84.012,66.768 84.012,62.787 L84.012,29.172 L71.45,29.172 L71.45,29.172 Z M197.237,78.859 L209.8,78.859 L209.8,44.547 C209.8,35.501 202.44,28.141 193.394,28.141 C186.735,28.141 181.393,31.004 178.802,32.71 C178.657,32.805 178.473,32.813 178.322,32.731 C178.171,32.649 178.075,32.491 178.075,32.318 L178.075,1.141 L165.513,1.141 L165.513,78.859 L178.075,78.859 L178.075,41.704 C178.075,41.529 178.174,41.368 178.33,41.288 C180.691,40.069 185.352,38.025 190.019,38.025 C191.947,38.025 193.76,38.776 195.123,40.139 C196.486,41.502 197.236,43.316 197.236,45.243 L197.236,78.859 L197.237,78.859 Z M124.792,39.055 L132.438,39.055 C132.697,39.055 132.907,39.265 132.907,39.524 L132.907,66.858 C132.907,74.043 138.753,79.888 145.938,79.888 C148.543,79.888 151.113,79.512 153.585,78.77 L153.585,69.796 C152.143,69.923 150.485,70.005 149.313,70.005 C147.193,70.005 145.469,68.28 145.469,66.161 L145.469,39.523 C145.469,39.264 145.679,39.054 145.938,39.054 L153.585,39.054 L153.585,29.171 L145.938,29.171 C145.679,29.171 145.469,28.961 145.469,28.702 L145.469,12.295 L132.907,12.295 L132.907,28.702 C132.907,28.961 132.697,29.171 132.438,29.171 L124.792,29.171 L124.792,39.055 L124.792,39.055 Z M51.361,78.859 L64.429,78.859 L44.555,9.55 C42.962,3.992 37.811,0.11 32.029,0.11 C26.247,0.11 21.096,3.992 19.502,9.55 L-0.372,78.859 L12.697,78.859 L18.449,58.798 C18.507,58.597 18.691,58.459 18.9,58.459 L45.158,58.459 C45.367,58.459 45.552,58.597 45.609,58.798 L51.361,78.859 L51.361,78.859 Z M42.056,48.576 L22.004,48.576 C21.857,48.576 21.718,48.507 21.629,48.388 C21.541,48.272 21.513,48.119 21.553,47.978 L31.579,13.012 C31.637,12.811 31.821,12.673 32.03,12.673 C32.239,12.673 32.423,12.811 32.48,13.012 L42.507,47.978 C42.547,48.12 42.519,48.272 42.43,48.388 C42.342,48.507 42.203,48.576 42.056,48.576 L42.056,48.576 Z",badge:"M119.555,135.861 L102.705,83.997 L146.813,51.952 L92.291,51.952 L75.44,0.09 L75.435,0.076 L129.965,0.076 L146.82,51.947 L146.821,51.946 L146.835,51.938 C156.623,82.03 146.542,116.256 119.555,135.861 L119.555,135.861 Z M31.321,135.861 L31.307,135.871 L75.426,167.924 L119.555,135.862 L75.44,103.808 L31.321,135.861 L31.321,135.861 Z M4.052,51.939 L4.052,51.939 C-6.252,83.66 5.709,117.272 31.312,135.867 L31.316,135.851 L48.168,83.99 L4.07,51.951 L58.579,51.951 L75.431,0.089 L75.435,0.075 L20.902,0.075 L4.052,51.939 L4.052,51.939 Z"};e.default=r},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(n,e){function t(){var n=document.getElementById("error-message");n.innerHTML="Accounts must have matching email addresses. Please try again.",n.style.display="block"}function r(n,e,t){var r,o=document.createElement(n),u=t||[],s=e||{};for(r in i(s))o.setAttribute(r,s[r]);for(r in u)o.appendChild(u[r]);return o}function o(n){return document.createTextNode(n)}function i(n){var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(t);return e}var u=window.Qs.parse(window.location.search,{ignoreQueryPrefix:!0});try{!function(n){var r=document.getElementById("link"),o=document.getElementById("skip"),s=e.reduce(function(n,e){return n.concat(e.identities)},[]).map(function(n){return n.connection}),c=function(n,e){var t=i(e).filter(function(n){return!!e[n]}).map(function(n){return n+"="+encodeURI(e[n])}).join("&");window.location=n+"authorize?"+t};r.addEventListener("click",function(e){c(n.iss,{client_id:u.client_id,redirect_uri:u.redirect_uri,response_type:u.response_type,scope:u.scope,state:u.original_state,nonce:u.nonce,link_account_token:u.child_token,prevent_sign_up:!0,connection:s[0]})}),function(n,e,t){n.href=e+"continue?state="+t}(o,n.iss,u.state),"accountMismatch"===u.error_type&&t()}(window.jwt_decode(u.child_token))}catch(n){console.error(n),function(){var n=document.getElementById("content-container"),e=(document.getElementById("label-value"),document.getElementById("link"));n.innerHTML="",n.appendChild(r("div",{},[r("p",{},[o("You seem to have reached this page in error. Please try logging in again")])])),e.disabled=!0}()}}},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(n){var e=n.extensionURL,t=void 0===e?"":e,r=n.username,o=void 0===r?"Unknown":r,i=n.clientID,u=void 0===i?"":i,s=n.clientSecret,c=void 0===s?"":s;return"function (user, context, callback) {\n /**\n * This rule has been automatically generated by\n * "+o+" at "+(new Date).toISOString()+"\n */\n var request = require('request@2.56.0');\n var queryString = require('querystring');\n var Promise = require('native-or-bluebird@1.2.0');\n var jwt = require('jsonwebtoken@7.1.9');\n\n var CONTINUE_PROTOCOL = 'redirect-callback';\n var LOG_TAG = '[ACCOUNT_LINK]: ';\n console.log(LOG_TAG, 'Entered Account Link Rule');\n\n var config = {\n endpoints: {\n linking: '"+t.replace(/\/$/g,"")+"',\n userApi: auth0.baseUrl + '/users'\n },\n token: {\n clientId: '"+u+"',\n clientSecret: '"+c+"',\n issuer: auth0.domain\n }\n };\n\n createStrategy().then(callbackWithSuccess).catch(callbackWithFailure);\n\n function createStrategy() {\n if (shouldLink()) {\n return linkAccounts();\n } else if (shouldPrompt()) {\n return promptUser();\n\n }\n\n return continueAuth();\n\n function shouldLink() {\n return !!context.request.query.link_account_token;\n }\n\n function shouldPrompt() {\n return !insideRedirect() && !redirectingToContinue() && firstLogin();\n\n // Check if we're inside a redirect\n // in order to avoid a redirect loop\n // TODO: May no longer be necessary\n function insideRedirect() {\n return context.request.query.redirect_uri &&\n context.request.query.redirect_uri.indexOf(config.endpoints.linking) !== -1;\n }\n\n // Check if this is the first login of the user\n // since merging already active accounts can be a\n // destructive action\n function firstLogin() {\n return context.stats.loginsCount <= 1;\n }\n\n // Check if we're coming back from a redirect\n // in order to avoid a redirect loop. User will\n // be sent to /continue at this point. We need\n // to assign them to their primary user if so.\n function redirectingToContinue() {\n return context.protocol === CONTINUE_PROTOCOL;\n }\n }\n }\n\n function verifyToken(token, secret) {\n return new Promise(function(resolve, reject) {\n jwt.verify(token, secret, function(err, decoded) {\n if (err) {\n return reject(err);\n }\n\n return resolve(decoded);\n });\n });\n }\n\n function linkAccounts() {\n var secondAccountToken = context.request.query.link_account_token;\n\n return verifyToken(secondAccountToken, config.token.clientSecret)\n .then(function(decodedToken) {\n // Redirect early if tokens are mismatched\n if (user.email !== decodedToken.email) {\n console.error(LOG_TAG, 'User: ', decodedToken.email, 'tried to link to account ', user.email);\n context.redirect = {\n url: buildRedirectUrl(secondAccountToken, context.request.query, 'accountMismatch')\n };\n\n return user;\n }\n\n var uri = config.endpoints.userApi+'/'+user.user_id+'/identities';\n\n return apiCall({\n method: 'POST',\n url: uri,\n headers: {\n Authorization: 'Bearer ' + createToken(config.token),\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache'\n },\n json: { link_with: secondAccountToken }\n }).then(function(_) {\n // TODO: Ask about this\n console.info(LOG_TAG, 'Successfully linked accounts for user: ', user.email);\n return _;\n });\n });\n }\n\n function continueAuth() {\n return Promise.resolve();\n }\n\n function promptUser() {\n return searchUsersWithSameEmail().then(function transformUsers(users) {\n return users.map(function(user) {\n return {\n userId: user.user_id,\n email: user.email,\n picture: user.picture,\n connections: user.identities.map(function(identity) {\n return identity.connection;\n })\n };\n });\n }).then(function redirectToExtension(targetUsers) {\n if (targetUsers.length > 0) {\n context.redirect = {\n url: buildRedirectUrl(createToken(config.token), context.request.query)\n };\n }\n });\n }\n\n function callbackWithSuccess(_) {\n callback(null, user, context);\n\n return _;\n }\n\n function callbackWithFailure(err) {\n console.error(LOG_TAG, err.message, err.stack);\n\n callback(err, user, context);\n }\n\n function createToken(tokenInfo, targetUsers) {\n var options = {\n expiresIn: '5m',\n audience: tokenInfo.clientId,\n issuer: qualifyDomain(tokenInfo.issuer)\n };\n\n var userSub = {\n sub: user.user_id,\n email: user.email,\n base: auth0.baseUrl\n };\n\n return jwt.sign(userSub, tokenInfo.clientSecret, options);\n }\n\n function searchUsersWithSameEmail() {\n return apiCall({\n url: config.endpoints.userApi,\n qs: {\n search_engine: 'v2',\n q: 'email:\"' + user.email + '\" -user_id:\"' + user.user_id + '\"'\n }\n });\n }\n\n // Consider moving this logic out of the rule and into the extension\n function buildRedirectUrl(token, q, errorType) {\n var params = {\n child_token: token,\n client_id: q.client_id,\n redirect_uri: q.redirect_uri,\n scope: q.scope,\n response_type: q.response_type,\n auth0Client: q.auth0Client,\n original_state: q.original_state || q.state,\n nonce: q.nonce,\n error_type: errorType\n };\n\n return config.endpoints.linking + '?' + queryString.encode(params);\n }\n\n function qualifyDomain(domain) {\n return 'https://'+domain+'/';\n }\n\n function apiCall(options) {\n return new Promise(function(resolve, reject) {\n var reqOptions = Object.assign({\n url: options.url,\n headers: {\n Authorization: 'Bearer ' + auth0.accessToken,\n Accept: 'application/json'\n },\n json: true\n }, options);\n\n request(reqOptions, function handleResponse(err, response, body) {\n if (err) {\n reject(err);\n } else if (response.statusCode < 200 || response.statusCode >= 300) {\n console.error(LOG_TAG, 'API call failed: ', body);\n reject(new Error(body));\n } else {\n resolve(response.body);\n }\n });\n });\n }\n}"}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(25),i=t(2),u=r(i),s=t(9),c=r(s),a=function(n,e,t){n.decorate("server","handlers",{managementClient:o.handlers.managementApiClient({domain:(0,u.default)("AUTH0_DOMAIN"),clientId:(0,u.default)("AUTH0_CLIENT_ID"),clientSecret:(0,u.default)("AUTH0_CLIENT_SECRET"),logger:c.default.error}),validateHookToken:o.handlers.validateHookToken((0,u.default)("AUTH0_DOMAIN"),(0,u.default)("WT_URL"),(0,u.default)("EXTENSION_SECRET"))}),t()};a.attributes={name:"handlers"},e.default=a},function(n,e,t){"use strict";(function(n){function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(106),i=r(o),u=t(103),s=r(u),c=t(104),a=r(c),l=t(2),f=r(l),d=t(9),p=r(d),h=t(58),v=r(h),g=t(56),m=r(g),y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m.default,r=new s.default.Server;return r.connection({host:"localhost",port:(0,f.default)("PORT"),routes:{cors:!0,validate:{},files:{relativeTo:i.default.join(n,"../public")}}}),r.register(a.default,function(){}),r.route({method:"GET",path:"/js/{file*}",handler:{directory:{path:i.default.join(n,"../public/js")}}}),r.route({method:"GET",path:"/css/{file*}",handler:{directory:{path:i.default.join(n,"../public/css")}}}),r.register([t,v.default],function(n){p.default.debug=function(){for(var n=arguments.length,e=Array(n),t=0;t':""};e.default=function(n){var e=n.stylesheetLink,t=n.customCSS,r=n.currentUser,o=n.matchingUsers;return'\n\n\n \n \n \n \n \n Auth0 Account Linking Extension\n \n '+l(e)+"\n "+l(t)+'\n \n \n
\n
\n \n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n \n
Account Linking
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n

\n It looks like you have another account\n with the same email address. We recommend\n you link these accounts.\n

\n

\n \n

\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n \n
\n
\n
\n\n - + -`; \ No newline at end of file +`; From b3b9af40c29ff97a84c81151e4c23af73a3f5016 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Fri, 17 Nov 2017 16:09:40 -0300 Subject: [PATCH 049/207] Rebuild bundle --- build/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/bundle.js b/build/bundle.js index 3602b57c..e71933c1 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1 @@ -module.exports=function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var t={};return e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=79)}([function(n,e){var t=n.exports={version:"2.5.0"};"number"==typeof __e&&(__e=t)},function(n,e,t){var r=t(48)("wks"),o=t(52),i=t(2).Symbol,a="function"==typeof i;(n.exports=function(n){return r[n]||(r[n]=a&&i[n]||(a?i:o)("Symbol."+n))}).store=r},function(n,e){var t=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(34);e.default=(0,r.config)()},function(n,e,t){"use strict";var r=t(138);r.emitErrs=!0;var o=new r.Logger({transports:[new r.transports.Console({timestamp:!0,level:"debug",handleExceptions:!0,json:!1,colorize:!0})],exitOnError:!1});n.exports=o},function(n,e,t){var r=t(16);n.exports=function(n){if(!r(n))throw TypeError(n+" is not an object!");return n}},function(n,e,t){n.exports={default:t(91),__esModule:!0}},function(n,e,t){var r=t(2),o=t(0),i=t(13),a=t(8),u=function(n,e,t){var s,c,l,f=n&u.F,d=n&u.G,p=n&u.S,h=n&u.P,v=n&u.B,m=n&u.W,g=d?o:o[e]||(o[e]={}),y=g.prototype,_=d?r:p?r[e]:(r[e]||{}).prototype;d&&(t=e);for(s in t)(c=!f&&_&&void 0!==_[s])&&s in g||(l=c?_[s]:t[s],g[s]=d&&"function"!=typeof _[s]?t[s]:v&&c?i(l,r):m&&_[s]==l?function(n){var e=function(e,t,r){if(this instanceof n){switch(arguments.length){case 0:return new n;case 1:return new n(e);case 2:return new n(e,t)}return new n(e,t,r)}return n.apply(this,arguments)};return e.prototype=n.prototype,e}(l):h&&"function"==typeof l?i(Function.call,l):l,h&&((g.virtual||(g.virtual={}))[s]=l,n&u.R&&y&&!y[s]&&a(y,s,l)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,n.exports=u},function(n,e,t){var r=t(17),o=t(47);n.exports=t(10)?function(n,e,t){return r.f(n,e,o(1,t))}:function(n,e,t){return n[e]=t,n}},function(n,e){n.exports={}},function(n,e,t){n.exports=!t(14)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(n,e){n.exports=function(n){if("function"!=typeof n)throw TypeError(n+" is not a function!");return n}},function(n,e){var t={}.toString;n.exports=function(n){return t.call(n).slice(8,-1)}},function(n,e,t){var r=t(11);n.exports=function(n,e,t){if(r(n),void 0===e)return n;switch(t){case 1:return function(t){return n.call(e,t)};case 2:return function(t,r){return n.call(e,t,r)};case 3:return function(t,r,o){return n.call(e,t,r,o)}}return function(){return n.apply(e,arguments)}}},function(n,e){n.exports=function(n){try{return!!n()}catch(n){return!0}}},function(n,e){var t={}.hasOwnProperty;n.exports=function(n,e){return t.call(n,e)}},function(n,e){n.exports=function(n){return"object"==typeof n?null!==n:"function"==typeof n}},function(n,e,t){var r=t(5),o=t(96),i=t(117),a=Object.defineProperty;e.f=t(10)?Object.defineProperty:function(n,e,t){if(r(n),e=i(e,!0),r(t),o)try{return a(n,e,t)}catch(n){}if("get"in t||"set"in t)throw TypeError("Accessors not supported!");return"value"in t&&(n[e]=t.value),n}},function(n,e){n.exports=require("auth0-extension-hapi-tools@1.2.0")},function(n,e,t){"use strict";var r=null;n.exports.init=function(n){r=n},n.exports.get=function(){if(!r)throw new Error("The DB has not been initialized.");return r}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}function o(){return new u.default(function(n){(0,s.get)().read().then(function(e){return n(e.settings?e.settings:d)}).catch(function(){return n(d)})})}function i(n){return new u.default(function(e){(0,s.get)().write({settings:n}).then(function(){e({status:f})})})}Object.defineProperty(e,"__esModule",{value:!0}),e.STATUS_ERRORED=e.STATUS_SUCCESSFUL=void 0;var a=t(6),u=r(a);e.getSettings=o,e.setSettings=i;var s=t(19),c=t(38),l=r(c),f=e.STATUS_SUCCESSFUL="ok",d=(e.STATUS_ERRORED="error",{template:l.default,locale:"en",status:f,color:"#eb5424",title:"",logoPath:"",removeOverlay:!1})},function(n,e,t){"use strict";e.__esModule=!0;var r=t(39),o=function(n){return n&&n.__esModule?n:{default:n}}(r);e.default=o.default||function(n){for(var e=1;e0?r:t)(n)}},function(n,e,t){var r=t(42),o=t(23);n.exports=function(n){return r(o(n))}},function(n,e,t){var r=t(23);n.exports=function(n){return Object(r(n))}},function(n,e,t){"use strict";var r=t(115)(!0);t(43)(String,"String",function(n){this._t=String(n),this._i=0},function(){var n,e=this._t,t=this._i;return t>=e.length?{value:void 0,done:!0}:(n=r(e,t),this._i+=n.length,{value:n,done:!1})})},function(n,e,t){t(120);for(var r=t(2),o=t(8),i=t(9),a=t(1)("toStringTag"),u="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),s=0;s1&&void 0!==arguments[1]?arguments[1]:a;return function(t){var r=e[n],o=r[t];return void 0===o&&(o=e.en[t]),o}}Object.defineProperty(e,"__esModule",{value:!0}),e.allLocales=void 0,e.default=r;var o=t(127),i=function(n){return n&&n.__esModule?n:{default:n}}(o),a=e.allLocales=i.default},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={text:"M246.517,0.11 C238.439,0.11 231.607,3.916 226.759,11.115 C221.94,18.271 219.393,28.26 219.393,40 C219.393,51.74 221.94,61.729 226.759,68.884 C231.607,76.084 238.439,79.889 246.517,79.889 C254.595,79.889 261.427,76.084 266.275,68.884 C271.093,61.729 273.64,51.74 273.64,40 C273.64,28.26 271.093,18.271 266.275,11.115 C261.427,3.916 254.595,0.11 246.517,0.11 L246.517,0.11 Z M246.517,70.005 C242.655,70.005 239.604,67.82 237.187,63.324 C234.268,57.893 232.66,49.61 232.66,40 C232.66,30.39 234.268,22.106 237.187,16.676 C239.604,12.18 242.655,9.994 246.517,9.994 C250.378,9.994 253.43,12.18 255.847,16.676 C258.766,22.106 260.373,30.389 260.373,40 C260.373,49.611 258.766,57.895 255.847,63.324 C253.43,67.82 250.378,70.005 246.517,70.005 L246.517,70.005 Z M71.45,29.172 L71.45,63.484 C71.45,72.53 78.81,79.889 87.856,79.889 C95.746,79.889 101.707,75.975 103.902,74.291 C104.024,74.197 104.184,74.169 104.331,74.216 C104.478,74.263 104.592,74.379 104.637,74.527 L105.961,78.86 L115.737,78.86 L115.737,29.172 L103.175,29.172 L103.175,66.326 C103.175,66.501 103.076,66.662 102.921,66.743 C100.559,67.961 95.899,70.006 91.231,70.006 C87.252,70.006 84.012,66.768 84.012,62.787 L84.012,29.172 L71.45,29.172 L71.45,29.172 Z M197.237,78.859 L209.8,78.859 L209.8,44.547 C209.8,35.501 202.44,28.141 193.394,28.141 C186.735,28.141 181.393,31.004 178.802,32.71 C178.657,32.805 178.473,32.813 178.322,32.731 C178.171,32.649 178.075,32.491 178.075,32.318 L178.075,1.141 L165.513,1.141 L165.513,78.859 L178.075,78.859 L178.075,41.704 C178.075,41.529 178.174,41.368 178.33,41.288 C180.691,40.069 185.352,38.025 190.019,38.025 C191.947,38.025 193.76,38.776 195.123,40.139 C196.486,41.502 197.236,43.316 197.236,45.243 L197.236,78.859 L197.237,78.859 Z M124.792,39.055 L132.438,39.055 C132.697,39.055 132.907,39.265 132.907,39.524 L132.907,66.858 C132.907,74.043 138.753,79.888 145.938,79.888 C148.543,79.888 151.113,79.512 153.585,78.77 L153.585,69.796 C152.143,69.923 150.485,70.005 149.313,70.005 C147.193,70.005 145.469,68.28 145.469,66.161 L145.469,39.523 C145.469,39.264 145.679,39.054 145.938,39.054 L153.585,39.054 L153.585,29.171 L145.938,29.171 C145.679,29.171 145.469,28.961 145.469,28.702 L145.469,12.295 L132.907,12.295 L132.907,28.702 C132.907,28.961 132.697,29.171 132.438,29.171 L124.792,29.171 L124.792,39.055 L124.792,39.055 Z M51.361,78.859 L64.429,78.859 L44.555,9.55 C42.962,3.992 37.811,0.11 32.029,0.11 C26.247,0.11 21.096,3.992 19.502,9.55 L-0.372,78.859 L12.697,78.859 L18.449,58.798 C18.507,58.597 18.691,58.459 18.9,58.459 L45.158,58.459 C45.367,58.459 45.552,58.597 45.609,58.798 L51.361,78.859 L51.361,78.859 Z M42.056,48.576 L22.004,48.576 C21.857,48.576 21.718,48.507 21.629,48.388 C21.541,48.272 21.513,48.119 21.553,47.978 L31.579,13.012 C31.637,12.811 31.821,12.673 32.03,12.673 C32.239,12.673 32.423,12.811 32.48,13.012 L42.507,47.978 C42.547,48.12 42.519,48.272 42.43,48.388 C42.342,48.507 42.203,48.576 42.056,48.576 L42.056,48.576 Z",badge:"M119.555,135.861 L102.705,83.997 L146.813,51.952 L92.291,51.952 L75.44,0.09 L75.435,0.076 L129.965,0.076 L146.82,51.947 L146.821,51.946 L146.835,51.938 C156.623,82.03 146.542,116.256 119.555,135.861 L119.555,135.861 Z M31.321,135.861 L31.307,135.871 L75.426,167.924 L119.555,135.862 L75.44,103.808 L31.321,135.861 L31.321,135.861 Z M4.052,51.939 L4.052,51.939 C-6.252,83.66 5.709,117.272 31.312,135.867 L31.316,135.851 L48.168,83.99 L4.07,51.951 L58.579,51.951 L75.431,0.089 L75.435,0.075 L20.902,0.075 L4.052,51.939 L4.052,51.939 Z"};e.default=r},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0}),e.uninstall=e.install=void 0;var o=t(21),i=r(o),a=t(69),u=r(a),s="auth0-account-link-extension",c=function(n){return n.find(function(n){return n.name===s})},l=function(n,e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=t.find(function(n){return n.name===s});return r?n.update({id:r.id},e):n.create((0,i.default)({stage:"login_success"},e))}},f=function(n){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=c(e);t&&n.delete({id:t.id})}},d=function(n,e){var t={name:s,script:(0,u.default)(e),enabled:!0};return n.getAll().then(l(n,t))},p=function(n){return n.getAll().then(f(n))};e.install=d,e.uninstall=p},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default='\n\n\n \n \n \n \n \n Auth0 Account Linking Extension\n \n {{ ExtensionCSS }}\n {{ CustomCSS }}\n \n \n \n {{ Auth0Widget }}\n {{ ExtensionScripts }}\n \n\n'},function(n,e,t){n.exports={default:t(89),__esModule:!0}},function(n,e){n.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(n,e,t){var r=t(2).document;n.exports=r&&r.documentElement},function(n,e,t){var r=t(12);n.exports=Object("z").propertyIsEnumerable(0)?Object:function(n){return"String"==r(n)?n.split(""):Object(n)}},function(n,e,t){"use strict";var r=t(44),o=t(7),i=t(113),a=t(8),u=t(15),s=t(9),c=t(100),l=t(27),f=t(108),d=t(1)("iterator"),p=!([].keys&&"next"in[].keys()),h=function(){return this};n.exports=function(n,e,t,v,m,g,y){c(t,e,v);var _,b,k,x=function(n){if(!p&&n in T)return T[n];switch(n){case"keys":case"values":return function(){return new t(this,n)}}return function(){return new t(this,n)}},w=e+" Iterator",L="values"==m,j=!1,T=n.prototype,S=T[d]||T["@@iterator"]||m&&T[m],C=S||x(m),O=m?L?x("entries"):C:void 0,A="Array"==e?T.entries||S:S;if(A&&(k=f(A.call(new n)))!==Object.prototype&&k.next&&(l(k,w,!0),r||u(k,d)||a(k,d,h)),L&&S&&"values"!==S.name&&(j=!0,C=function(){return S.call(this)}),r&&!y||!p&&!j&&T[d]||a(T,d,C),s[e]=C,s[w]=h,m)if(_={values:L?C:x("values"),keys:g?C:x("keys"),entries:O},y)for(b in _)b in T||i(T,b,_[b]);else o(o.P+o.F*(p||j),e,_);return _}},function(n,e){n.exports=!0},function(n,e){n.exports=function(n){try{return{e:!1,v:n()}}catch(n){return{e:!0,v:n}}}},function(n,e,t){var r=t(25);n.exports=function(n,e){var t=r.f(n);return(0,t.resolve)(e),t.promise}},function(n,e){n.exports=function(n,e){return{enumerable:!(1&n),configurable:!(2&n),writable:!(4&n),value:e}}},function(n,e,t){var r=t(2),o=r["__core-js_shared__"]||(r["__core-js_shared__"]={});n.exports=function(n){return o[n]||(o[n]={})}},function(n,e,t){var r=t(5),o=t(11),i=t(1)("species");n.exports=function(n,e){var t,a=r(n).constructor;return void 0===a||void 0==(t=r(a)[i])?e:o(t)}},function(n,e,t){var r,o,i,a=t(13),u=t(97),s=t(41),c=t(24),l=t(2),f=l.process,d=l.setImmediate,p=l.clearImmediate,h=l.MessageChannel,v=l.Dispatch,m=0,g={},y=function(){var n=+this;if(g.hasOwnProperty(n)){var e=g[n];delete g[n],e()}},_=function(n){y.call(n.data)};d&&p||(d=function(n){for(var e=[],t=1;arguments.length>t;)e.push(arguments[t++]);return g[++m]=function(){u("function"==typeof n?n:Function(n),e)},r(m),m},p=function(n){delete g[n]},"process"==t(12)(f)?r=function(n){f.nextTick(a(y,n,1))}:v&&v.now?r=function(n){v.now(a(y,n,1))}:h?(o=new h,i=o.port2,o.port1.onmessage=_,r=a(i.postMessage,i,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(r=function(n){l.postMessage(n+"","*")},l.addEventListener("message",_,!1)):r="onreadystatechange"in c("script")?function(n){s.appendChild(c("script")).onreadystatechange=function(){s.removeChild(this),y.call(n)}}:function(n){setTimeout(a(y,n,1),0)}),n.exports={set:d,clear:p}},function(n,e,t){var r=t(29),o=Math.min;n.exports=function(n){return n>0?o(r(n),9007199254740991):0}},function(n,e){var t=0,r=Math.random();n.exports=function(n){return"Symbol(".concat(void 0===n?"":n,")_",(++t+r).toString(36))}},function(n,e,t){var r=t(22),o=t(1)("iterator"),i=t(9);n.exports=t(0).getIteratorMethod=function(n){if(void 0!=n)return n[o]||n["@@iterator"]||i[r(n)]}},function(n,e){n.exports=require("jsonwebtoken@7.1.9")},function(n,e){n.exports=require("path")},function(n,e,t){"use strict";(function(e){function r(n){return n&&n.__esModule?n:{default:n}}var o=t(55),i=r(o),a=t(34),u=t(3),s=r(u),c=t(72),l=r(c),f=t(4),d=r(f),p=t(19),h=function(n){n?(d.default.error("Hapi initialization failed."),d.default.error(n)):d.default.info("Hapi initialization completed.")},v=function(n,r,o){return s.default.setProvider(function(e){return n(e)||t.i({NODE_ENV:"production",CLIENT_VERSION:"2.0.0"})[e]}),(0,p.init)(r?new a.WebtaskStorageContext(r,{force:0}):new a.FileStorageContext(i.default.join(e,"../data.json"))),(0,l.default)(o||h)};n.exports=v}).call(e,"/")},function(n,e,t){"use strict";var r=t(75),o=function(n){return n&&n.__esModule?n:{default:n}}(r);n.exports=function(){return{method:"GET",path:"/admin",config:{auth:!1},handler:function(n,e){e(o.default)}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(21),i=r(o),a=t(83),u=r(a),s=t(20),c=t(35);n.exports=function(){return{method:"GET",config:{auth:"jwt"},path:"/admin/settings",handler:function(n,e){var t=(0,u.default)(c.allLocales).map(function(n){return{code:n,name:c.allLocales[n]._name}});(0,s.getSettings)().then(function(n){e((0,i.default)({},n,{availableLocales:t}))})}}}},function(n,e,t){"use strict";var r=t(66),o=function(n){return n&&n.__esModule?n:{default:n}}(r);n.exports=function(){return{method:"GET",path:"/admin/user",config:{auth:"jwt"},handler:function(n,e){e({email:n.auth.credentials.email,avatar:(0,o.default)(n.auth.credentials.email)})}}}},function(n,e,t){"use strict";var r=t(135),o=function(n){return n&&n.__esModule?n:{default:n}}(r),i=t(20),a=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/,u=/^#[A-Fa-f0-9]{6}/;n.exports=function(){return{method:"PUT",config:{auth:"jwt",validate:{payload:{template:o.default.string().required(),locale:o.default.string().required(),title:o.default.string().required(),color:o.default.string().regex(u).required(),logoPath:o.default.string().regex(a).allow(""),removeOverlay:o.default.bool().default(!1)}}},path:"/admin/settings",handler:function(n,e){(0,i.setSettings)(n.payload).then(function(n){e(n)})}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(6),i=r(o),a=t(54),u=t(3),s=r(u),c=t(67),l=r(c),f=t(74),d=r(f),p=t(4),h=r(p),v=t(128).version,m="https://cdn.auth0.com/extensions/auth0-account-link-extension/"+v+"/link.min.css",g=function(n){return new i.default(function(e,t){try{e((0,a.decode)(n))}catch(n){t(n)}})},y=function(n){var e=n.sub,t=n.email;return(0,l.default)(t).then(function(n){return{currentUser:n.find(function(n){return n.user_id===e}),matchingUsers:n.filter(function(n){return n.user_id!==e})}})};n.exports=function(){return{method:"GET",path:"/",config:{auth:!1},handler:function(n,e){var t=n.state["account-linking-admin-state"];if(void 0!==t&&""!==t)return void e.redirect("/admin").state("account-linking-admin-state","");var r="production"===(0,s.default)("NODE_ENV")?m:"/css/link.css",o={};n.query.locale&&(o.locale=n.query.locale),n.query.color&&(o.color="#"+n.query.color),n.query.title&&(o.title=n.query.title),n.query.logoPath&&(o.logoPath=n.query.logoPath),g(n.query.child_token).then(function(t){y(t).then(function(n){var t=n.currentUser,i=n.matchingUsers;e((0,d.default)({dynamicSettings:o,stylesheetLink:r,currentUser:t,matchingUsers:i,customCSS:(0,s.default)("CUSTOM_CSS")}))}).catch(function(r){var o=n.query.state;h.default.error("An error was encountered: ",r),h.default.info("Redirecting to failed link to /continue: "+t.iss+"continue?state="+n.query.state),e.redirect(t.iss+"continue?state="+o)})}).catch(function(n){h.default.error("An invalid token was provided",n),(0,d.default)({dynamicSettings:o,stylesheetLink:r,currentUser:null,matchingUsers:[],customCSS:(0,s.default)("CUSTOM_CSS")}).then(function(n){e(n).code(400)})})}}}},function(n,e,t){"use strict";var r=t(129),o=function(n){return n&&n.__esModule?n:{default:n}}(r);n.exports=function(){return{method:"GET",path:"/meta",config:{auth:!1},handler:function(n,e){return e(o.default)}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(6),i=r(o),a=t(37),u=t(3),s=r(u),c=t(4),l=r(c);n.exports=function(n){return{method:"DELETE",path:"/.extensions/on-uninstall",config:{auth:!1,pre:[n.handlers.validateHookToken("/.extensions/on-uninstall"),n.handlers.managementClient]},handler:function(n,e){l.default.info("Starting uninstall..."),i.default.all([(0,a.uninstall)(n.pre.auth0.rules),n.pre.auth0.deleteClient({client_id:(0,s.default)("AUTH0_CLIENT_ID")})]).then(function(){return e().code(204)}).catch(function(n){l.default.error("Something went wrong while uninstalling Account Link Extension: ",n),e().code(204)})}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(37),i=t(3),a=r(i),u=t(4),s=r(u);n.exports=function(n){return{method:"POST",path:"/.extensions/on-install",config:{auth:!1,pre:[n.handlers.validateHookToken("/.extensions/on-install"),n.handlers.managementClient]},handler:function(n,e){s.default.info("Starting rule installation..."),(0,o.install)(n.pre.auth0.rules,{extensionURL:(0,a.default)("PUBLIC_WT_URL"),clientID:(0,a.default)("AUTH0_CLIENT_ID"),clientSecret:(0,a.default)("AUTH0_CLIENT_SECRET")}).then(function(){return e().code(204)}).then(function(){s.default.info("Rule successfully installed")}).catch(function(n){throw s.default.error("Something went wrong, ",n),n}).catch(function(n){return e.error(n)})}}}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(21),i=r(o),a=t(6),u=r(a),s=t(84),c=r(s),l=t(34),f=t(137),d=r(f),p=t(3),h=r(p),v=t(4),m=r(v),g={base:void 0,getBaseUrl:function(){return this.base||(this.base="https://"+(0,h.default)("AUTH0_DOMAIN")+"/api/v2"),this.base},endpoint:function(n){return this.getBaseUrl()+"/"+n}},y=function(){return l.managementApi.getAccessTokenCached((0,h.default)("AUTH0_DOMAIN"),(0,h.default)("AUTH0_CLIENT_ID"),(0,h.default)("AUTH0_CLIENT_SECRET"))},_=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=n.path,t=(0,c.default)(n,["path"]);return y().then(function(n){return new u.default(function(r,o){(0,d.default)((0,i.default)({url:g.endpoint(e),headers:{Authorization:"Bearer "+n,Accept:"application/json"},json:!0},t),function(n,e,t){n?o(n):e.statusCode<200||e.statusCode>=300?(m.default.error("API call failed: ",e.status,t),o(new Error(t))):r(e.body)})})})};e.default=_},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(131),o=function(n){return n&&n.__esModule?n:{default:n}}(r),i=function(n){return"https://s.gravatar.com/avatar/"+o.default.createHash("md5").update(n).digest("hex")+"?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2F"+n.substr(0,2)+".png"};e.default=i},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(65),o=function(n){return n&&n.__esModule?n:{default:n}}(r),i=function(n){return(0,o.default)({path:"users-by-email",qs:{email:n}})};e.default=i},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(n,e){function t(){var n=document.getElementById("error-message"),e=window.Auth0AccountLinkingExtension.locale.sameEmailAddressError||"Accounts must have matching email addresses. Please try again.";n.innerHTML=e,n.style.display="block"}function r(n,e,t){var r,o=document.createElement(n),a=t||[],u=e||{};for(r in i(u))o.setAttribute(r,u[r]);for(r in a)o.appendChild(a[r]);return o}function o(n){return document.createTextNode(n)}function i(n){var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(t);return e}var a=window.Qs.parse(window.location.search,{ignoreQueryPrefix:!0});try{!function(n){var r=document.getElementById("link"),o=document.getElementById("skip"),u=e.reduce(function(n,e){return n.concat(e.identities)},[]).map(function(n){return n.connection}),s=function(n,e){var t=i(e).filter(function(n){return!!e[n]}).map(function(n){return n+"="+encodeURIComponent(e[n])}).join("&");window.location=n+"authorize?"+t};r.addEventListener("click",function(e){s(n.iss,{client_id:a.client_id,redirect_uri:a.redirect_uri,response_type:a.response_type,scope:a.scope,state:a.original_state,nonce:a.nonce,link_account_token:a.child_token,prevent_sign_up:!0,connection:u[0]})}),function(n,e,t){n.href=e+"continue?state="+t}(o,n.iss,a.state),"accountMismatch"===a.error_type&&t()}(window.jwt_decode(a.child_token))}catch(n){console.error(n),function(){var n=document.getElementById("content-container"),e=(document.getElementById("label-value"),document.getElementById("link"));n.innerHTML="",n.appendChild(r("div",{},[r("p",{},[o(window.Auth0AccountLinkingExtension.locale.pageMismatchError||"You seem to have reached this page in error. Please try logging in again")])])),e.disabled=!0}()}}},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(n){var e=n.extensionURL,t=void 0===e?"":e,r=n.username,o=void 0===r?"Unknown":r,i=n.clientID,a=void 0===i?"":i,u=n.clientSecret,s=void 0===u?"":u;return"function (user, context, callback) {\n /**\n * This rule has been automatically generated by\n * "+o+" at "+(new Date).toISOString()+"\n */\n var request = require('request@2.56.0');\n var queryString = require('querystring');\n var Promise = require('native-or-bluebird@1.2.0');\n var jwt = require('jsonwebtoken@7.1.9');\n\n var CONTINUE_PROTOCOL = 'redirect-callback';\n var LOG_TAG = '[ACCOUNT_LINK]: ';\n console.log(LOG_TAG, 'Entered Account Link Rule');\n\n // 'query' can be undefined when using '/oauth/token' to log in\n context.request.query = context.request.query || {};\n\n var config = {\n endpoints: {\n linking: '"+t.replace(/\/$/g,"")+"',\n userApi: auth0.baseUrl + '/users',\n usersByEmailApi: auth0.baseUrl + '/users-by-email'\n },\n token: {\n clientId: '"+a+"',\n clientSecret: '"+s+"',\n issuer: auth0.domain\n }\n };\n\n createStrategy().then(callbackWithSuccess).catch(callbackWithFailure);\n\n function createStrategy() {\n if (shouldLink()) {\n return linkAccounts();\n } else if (shouldPrompt()) {\n return promptUser();\n\n }\n\n return continueAuth();\n\n function shouldLink() {\n return !!context.request.query.link_account_token;\n }\n\n function shouldPrompt() {\n return !insideRedirect() && !redirectingToContinue() && firstLogin();\n\n // Check if we're inside a redirect\n // in order to avoid a redirect loop\n // TODO: May no longer be necessary\n function insideRedirect() {\n return context.request.query.redirect_uri &&\n context.request.query.redirect_uri.indexOf(config.endpoints.linking) !== -1;\n }\n\n // Check if this is the first login of the user\n // since merging already active accounts can be a\n // destructive action\n function firstLogin() {\n return context.stats.loginsCount <= 1;\n }\n\n // Check if we're coming back from a redirect\n // in order to avoid a redirect loop. User will\n // be sent to /continue at this point. We need\n // to assign them to their primary user if so.\n function redirectingToContinue() {\n return context.protocol === CONTINUE_PROTOCOL;\n }\n }\n }\n\n function verifyToken(token, secret) {\n return new Promise(function(resolve, reject) {\n jwt.verify(token, secret, function(err, decoded) {\n if (err) {\n return reject(err);\n }\n\n return resolve(decoded);\n });\n });\n }\n\n function linkAccounts() {\n var secondAccountToken = context.request.query.link_account_token;\n\n return verifyToken(secondAccountToken, config.token.clientSecret)\n .then(function(decodedToken) {\n // Redirect early if tokens are mismatched\n if (user.email !== decodedToken.email) {\n console.error(LOG_TAG, 'User: ', decodedToken.email, 'tried to link to account ', user.email);\n context.redirect = {\n url: buildRedirectUrl(secondAccountToken, context.request.query, 'accountMismatch')\n };\n\n return user;\n }\n\n var uri = config.endpoints.userApi+'/'+user.user_id+'/identities';\n\n return apiCall({\n method: 'POST',\n url: uri,\n headers: {\n Authorization: 'Bearer ' + createToken(config.token),\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache'\n },\n json: { link_with: secondAccountToken }\n }).then(function(_) {\n // TODO: Ask about this\n console.info(LOG_TAG, 'Successfully linked accounts for user: ', user.email);\n return _;\n });\n });\n }\n\n function continueAuth() {\n return Promise.resolve();\n }\n\n function promptUser() {\n return searchUsersWithSameEmail().then(function transformUsers(users) {\n \n return users.filter(function(u) {\n return u.user_id !== user.user_id;\n }).map(function(user) {\n return {\n userId: user.user_id,\n email: user.email,\n picture: user.picture,\n connections: user.identities.map(function(identity) {\n return identity.connection;\n })\n };\n });\n }).then(function redirectToExtension(targetUsers) {\n if (targetUsers.length > 0) {\n context.redirect = {\n url: buildRedirectUrl(createToken(config.token), context.request.query)\n };\n }\n });\n }\n\n function callbackWithSuccess(_) {\n callback(null, user, context);\n\n return _;\n }\n\n function callbackWithFailure(err) {\n console.error(LOG_TAG, err.message, err.stack);\n\n callback(err, user, context);\n }\n\n function createToken(tokenInfo, targetUsers) {\n var options = {\n expiresIn: '5m',\n audience: tokenInfo.clientId,\n issuer: qualifyDomain(tokenInfo.issuer)\n };\n\n var userSub = {\n sub: user.user_id,\n email: user.email,\n base: auth0.baseUrl\n };\n\n return jwt.sign(userSub, tokenInfo.clientSecret, options);\n }\n\n function searchUsersWithSameEmail() {\n return apiCall({\n url: config.endpoints.usersByEmailApi,\n qs: {\n email: user.email\n }\n });\n }\n\n // Consider moving this logic out of the rule and into the extension\n function buildRedirectUrl(token, q, errorType) {\n var params = {\n child_token: token,\n client_id: q.client_id,\n redirect_uri: q.redirect_uri,\n scope: q.scope,\n response_type: q.response_type,\n auth0Client: q.auth0Client,\n original_state: q.original_state || q.state,\n nonce: q.nonce,\n error_type: errorType\n };\n\n return config.endpoints.linking + '?' + queryString.encode(params);\n }\n\n function qualifyDomain(domain) {\n return 'https://'+domain+'/';\n }\n\n function apiCall(options) {\n return new Promise(function(resolve, reject) {\n var reqOptions = Object.assign({\n url: options.url,\n headers: {\n Authorization: 'Bearer ' + auth0.accessToken,\n Accept: 'application/json'\n },\n json: true\n }, options);\n\n request(reqOptions, function handleResponse(err, response, body) {\n if (err) {\n reject(err);\n } else if (response.statusCode < 200 || response.statusCode >= 300) {\n console.error(LOG_TAG, 'API call failed: ', body);\n reject(new Error(body));\n } else {\n resolve(response.body);\n }\n });\n });\n }\n}"}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}var o=t(130),i=r(o),a=t(136),u=r(a),s=t(54),c=r(s),l=t(18),f=function(n){if(n&&n.__esModule)return n;var e={};if(null!=n)for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}(l),d=t(3),p=r(d),h=[{value:"openid"},{value:"profile"}];n.exports.register=function(n,e,t){var r={dashboardAdmin:{key:(0,p.default)("EXTENSION_SECRET"),verifyOptions:{audience:"urn:api-account-linking",issuer:(0,p.default)("PUBLIC_WT_URL"),algorithms:["HS256"]}},resourceServer:{key:u.default.hapiJwt2Key({cache:!0,rateLimit:!0,jwksRequestsPerMinute:2,jwksUri:"https://"+(0,p.default)("AUTH0_DOMAIN")+"/.well-known/jwks.json"}),verifyOptions:{audience:"urn:auth0-account-linking-api",issuer:"https://"+(0,p.default)("AUTH0_DOMAIN")+"/",algorithms:["RS256"]}}};n.auth.strategy("jwt","jwt",{complete:!0,verifyFunc:function(n,e,t){if(!n)return t(null,!1);var o=e.headers.authorization;if(o&&0===o.indexOf("Bearer ")){var a=o.split(" ")[1];if(n&&n.payload&&n.payload.iss==="https://"+(0,p.default)("AUTH0_DOMAIN")+"/")return r.resourceServer.key(n,function(e,o){return e?t(i.default.wrap(e),null,null):c.default.verify(a,o,r.resourceServer.verifyOptions,function(e){return e?t(i.default.unauthorized("Invalid token","Token"),null,null):n.payload.gty&&"client-credentials"!==n.payload.gty?t(i.default.unauthorized("Invalid token","Token"),null,null):n.payload.sub.endsWith("@clients")?(n.payload.scope&&"string"==typeof n.payload.scope&&(n.payload.scope=n.payload.scope.split(" ")),t(null,!0,n.payload)):t(i.default.unauthorized("Invalid token","Token"),null,null)})});if(n&&n.payload&&n.payload.iss===(0,p.default)("PUBLIC_WT_URL"))return c.default.verify(a,r.dashboardAdmin.key,r.dashboardAdmin.verifyOptions,function(e){return e?t(i.default.unauthorized("Invalid token","Token"),null,null):n.payload.access_token&&n.payload.access_token.length?(n.payload.scope=h.map(function(n){return n.value}),t(null,!0,n.payload)):t(i.default.unauthorized("Invalid token","Token"),null,null)})}return t(null,!1)}}),n.auth.default("jwt");var o={register:f.plugins.dashboardAdminSession,options:{stateKey:"account-linking-admin-state",sessionStorageKey:"com.auth0.account_linking.admin_ui.session_token",rta:(0,p.default)("AUTH0_RTA").replace("https://",""),domain:(0,p.default)("AUTH0_DOMAIN"),scopes:"",baseUrl:(0,p.default)("PUBLIC_WT_URL"),audience:"urn:api-account-linking",secret:(0,p.default)("EXTENSION_SECRET"),clientName:"auth0-account-link",onLoginSuccess:function(n,e,t){return n?(n.scope=h.map(function(n){return n.value}),t(null,!0,n)):t(null,!1)}}};n.register(o,function(n){n&&t(n),t()})},n.exports.register.attributes={name:"auth"}},function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(18),i=t(3),a=r(i),u=t(4),s=r(u),c=function(n,e,t){n.decorate("server","handlers",{managementClient:o.handlers.managementApiClient({domain:(0,a.default)("AUTH0_DOMAIN"),clientId:(0,a.default)("AUTH0_CLIENT_ID"),clientSecret:(0,a.default)("AUTH0_CLIENT_SECRET"),logger:s.default.error}),validateHookToken:o.handlers.validateHookToken((0,a.default)("AUTH0_DOMAIN"),(0,a.default)("WT_URL"),(0,a.default)("EXTENSION_SECRET"))}),t()};c.attributes={name:"handlers"},e.default=c},function(n,e,t){"use strict";(function(n){function r(n){return n&&n.__esModule?n:{default:n}}Object.defineProperty(e,"__esModule",{value:!0});var o=t(55),i=r(o),a=t(133),u=r(a),s=t(134),c=r(s),l=t(132),f=r(l),d=t(3),p=r(d),h=t(4),v=r(h),m=t(73),g=r(m),y=t(71),_=r(y),b=t(70),k=r(b),x=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_.default,r=new u.default.Server;return r.connection({host:"localhost",port:(0,p.default)("PORT"),routes:{cors:!0,validate:{},files:{relativeTo:i.default.join(n,"../public")}}}),r.register([f.default,c.default],function(){}),r.route({method:"GET",path:"/js/{file*}",config:{auth:!1},handler:{directory:{path:i.default.join(n,"../public/js")}}}),r.route({method:"GET",path:"/css/{file*}",config:{auth:!1},handler:{directory:{path:i.default.join(n,"../public/css")}}}),r.register([k.default,t,g.default],function(n){v.default.debug=function(){for(var n=arguments.length,e=Array(n),t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if(!n||"string"!=typeof n)throw new Error("Invalid template provided");return n.replace(v,function(n,t){return e[t]||""})},g=function(n){return n?'':""};e.default=function(n){var e=n.stylesheetLink,t=n.customCSS,r=n.currentUser,o=n.matchingUsers,a=n.dynamicSettings;return u.default.all([(0,d.default)(a),(0,l.get)().read()]).then(function(n){var a=(0,i.default)(n,2),u=a[0],s=a[1],l=s.settings?s.settings.template:c.default;return m(l,{ExtensionCSS:g(e),CustomCSS:g(t),Auth0Widget:u,ExtensionScripts:(0,h.default)(r,o)})})}},function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default='\n\n\n\n \n \n \n Auth0 Account Linking Extension Administrator\n \n \n \n \n \n\n\n \n\n\n
\n
\n
\n
\n
\n\n
\n
\n

Custom Hosted Page

\n\n \n\n

Widget Settings

\n\n
\n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n Remove widget\'s overlay\n
\n\n \n \n
\n
\n\n\n - - - - +${scripts} `; diff --git a/templates/utils/header.js b/templates/utils/header.js new file mode 100644 index 00000000..6b741474 --- /dev/null +++ b/templates/utils/header.js @@ -0,0 +1,37 @@ +export default ` + + +
+
+
+
+
`; diff --git a/templates/utils/scripts.js b/templates/utils/scripts.js new file mode 100644 index 00000000..ca734cd9 --- /dev/null +++ b/templates/utils/scripts.js @@ -0,0 +1,8 @@ +import adminJS from '../../public/admin'; + +export default ` + + + + +`; From f8e2b486ad270bfdc1a5d0e246a09def5f6a5388 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 8 Jan 2018 16:12:03 -0300 Subject: [PATCH 063/207] Include missing routes in index --- server/routes.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/routes.js b/server/routes.js index 23c6acd2..91894624 100644 --- a/server/routes.js +++ b/server/routes.js @@ -3,6 +3,8 @@ import onInstall from '../api/hooks/post_install'; import onUninstall from '../api/hooks/delete_uninstall'; import metaRoute from '../api/get_meta'; import getAdminIndex from '../api/admin/get_index'; +import getLocaleAdminIndex from '../api/admin/get_locale_index'; +import getLocales from '../api/admin/get_locales'; import getAdminSettings from '../api/admin/get_settings'; import putAdminSettings from '../api/admin/put_settings'; import getUserDetails from '../api/admin/get_user_details'; @@ -18,6 +20,8 @@ const register = (server, options, next) => { createRoute(getAdminSettings, server); createRoute(putAdminSettings, server); createRoute(getUserDetails, server); + createRoute(getLocaleAdminIndex, server); + createRoute(getLocales, server); next(); }; From 413dc8c326f76b0269bebae0cd2438034fbd6085 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 8 Jan 2018 16:12:17 -0300 Subject: [PATCH 064/207] Create locale admin panel base template --- templates/server/locale.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 templates/server/locale.js diff --git a/templates/server/locale.js b/templates/server/locale.js new file mode 100644 index 00000000..00ccb072 --- /dev/null +++ b/templates/server/locale.js @@ -0,0 +1,37 @@ +import scripts from '../utils/scripts'; +import header from '../utils/header'; + +export default ({ stylesheetTag, baseURL }) => ` + + + + + + + + Auth0 Account Linking Extension Administrator + + + + + ${stylesheetTag} + + + +${header} + +
+
+
+ +
+
+
+
+
+ + +${scripts} + + +`; From d78cab5e485f53a47220546c15fae699223d95d0 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Mon, 8 Jan 2018 16:12:46 -0300 Subject: [PATCH 065/207] Create locale admin panel base code --- public/admin.js | 337 +++++++++++++++++++++++++------------------ public/css/admin.css | 4 + 2 files changed, 203 insertions(+), 138 deletions(-) diff --git a/public/admin.js b/public/admin.js index c0452ab1..2f9c2a27 100644 --- a/public/admin.js +++ b/public/admin.js @@ -4,183 +4,244 @@ // and eslint is configured to lint ES6. export default function() { + var locales = {}; + var selectedLocale = ""; + var SUCCESS_MESSAGE = 'Success! Your changes has been successfully saved.'; var ERROR_MESSAGE = 'Oops! An error has ocurred while trying to save your changes.'; var TOKEN_KEY = 'com.auth0.account_linking.admin_ui.session_token'; var baseURL = $('base').attr('href'); - var $titleInput = $('#title_input'); - var $logoPathInput = $('#logo_path_input'); - var $colorInput = $('#color_input'); - var $removeOverlayCheck = $('#remove_overlay'); - var $availableLocalesSelect = $('#available-locales'); var $appContainer = $('.app-container'); var $loadingContainer = $('.loading-state-container'); - var $saveChangesBtn = $('#save-changes'); - var $saveResult = $('#save-result'); - var $logoutBtn = $('#logout-btn'); - var $avatarImg = $('.avatar'); - - var token = sessionStorage.getItem(TOKEN_KEY); - - var editor = CodeMirror.fromTextArea(document.getElementById('code-editor'), { - lineNumbers: true, - matchBrackets: true, - tabMode: 'indent', - theme: 'material', - mode: 'xml', - htmlMode: true - }); - - function performLogin() { - window.location.href = baseURL+'/login'; - } - function fillSelectItem(data) { - data.availableLocales.forEach(function(locale) { - var isSelected = data.locale === locale.code ? 'selected' : ''; - $availableLocalesSelect.append( - `` - ); + function mainAdminPanel() { + var $titleInput = $('#title_input'); + var $logoPathInput = $('#logo_path_input'); + var $colorInput = $('#color_input'); + var $removeOverlayCheck = $('#remove_overlay'); + var $availableLocalesSelect = $('#available-locales'); + var $saveChangesBtn = $('#save-changes'); + var $saveResult = $('#save-result'); + var $logoutBtn = $('#logout-btn'); + var $avatarImg = $('.avatar'); + + var token = sessionStorage.getItem(TOKEN_KEY); + + var editor = CodeMirror.fromTextArea(document.getElementById('code-editor'), { + lineNumbers: true, + matchBrackets: true, + tabMode: 'indent', + theme: 'material', + mode: 'xml', + htmlMode: true }); - } - - function fillCodeEditor(editor, data) { - editor.setValue(data.template.trim()); - } - function setSaveButtonDisabled(setDisabled) { - var disabledClass = 'disabled'; + function performLogin() { + window.location.href = baseURL + '/login'; + } - if (setDisabled) { - $saveChangesBtn.addClass(disabledClass).html('Saving changes...'); - } else { - $saveChangesBtn.removeClass(disabledClass).html('Save changes'); + function fillSelectItem(data) { + data.availableLocales.forEach(function(locale) { + var isSelected = data.locale === locale.code ? 'selected' : ''; + $availableLocalesSelect.append( + '' + ); + }); } - } - function setSaveResult(text, options) { - $saveResult.removeClass('alert-danger'); - $saveResult.removeClass('alert-success'); + function fillCodeEditor(editor, data) { + editor.setValue(data.template.trim()); + } - $saveResult.html(text); - $saveResult.show(); + function setSaveButtonDisabled(setDisabled) { + var disabledClass = 'disabled'; - if (options && options.error) { - $saveResult.addClass('alert-danger'); - } else { - $saveResult.addClass('alert-success'); + if (setDisabled) { + $saveChangesBtn.addClass(disabledClass).html('Saving changes...'); + } else { + $saveChangesBtn.removeClass(disabledClass).html('Save changes'); + } } - setTimeout(function() { - $saveResult.html(''); - $saveResult.hide(); + function setSaveResult(text, options) { + $saveResult.removeClass('alert-danger'); + $saveResult.removeClass('alert-success'); + + $saveResult.html(text); + $saveResult.show(); - if (options.error) { - $saveResult.removeClass('alert-danger'); + if (options && options.error) { + $saveResult.addClass('alert-danger'); } else { - $saveResult.removeClass('alert-success'); + $saveResult.addClass('alert-success'); } - }, 10000); - } - if (!token) { - performLogin(); - } + setTimeout(function() { + $saveResult.html(''); + $saveResult.hide(); - editor.setSize(null, 500); + if (options.error) { + $saveResult.removeClass('alert-danger'); + } else { + $saveResult.removeClass('alert-success'); + } + }, 10000); + } - $.ajax({ - url: baseURL+'/admin/settings', - headers: { - Authorization: `Bearer ${token}` + if (!token) { + performLogin(); } - }) - .done(function(data) { - $loadingContainer.hide(); - $appContainer.show(); - - fillCodeEditor(editor, data); - fillSelectItem(data); - $titleInput.val(data.title); - $colorInput.val(data.color); - $logoPathInput.val(data.logoPath); - - $removeOverlayCheck.prop('checked', data.removeOverlay || false); + + editor.setSize(null, 500); + + $.ajax({ + url: baseURL + '/admin/settings', + headers: { + Authorization: 'Bearer ' + token + } }) - .error(function(e) { - if (e.statusText === 'Unauthorized') { - performLogin(); + .done(function(data) { + $loadingContainer.hide(); + $appContainer.show(); + + fillCodeEditor(editor, data); + fillSelectItem(data); + $titleInput.val(data.title); + $colorInput.val(data.color); + $logoPathInput.val(data.logoPath); + + $removeOverlayCheck.prop('checked', data.removeOverlay || false); + }) + .error(function(e) { + if (e.statusText === 'Unauthorized') { + performLogin(); + } + }); + + $.ajax({ + url: baseURL + '/admin/user', + headers: { + Authorization: 'Bearer ' + token } + }) + .done(function(data, status) { + $avatarImg.attr('src', data.avatar); + }) + .error(function(e) { + if (e.statusText === 'Unauthorized') { + performLogin(); + } + }); + + $saveChangesBtn.on('click', function(e) { + e.preventDefault(); + + setSaveButtonDisabled(true); + + $.ajax({ + url: baseURL + '/admin/settings', + method: 'PUT', + data: { + template: editor.getValue(), + locale: $availableLocalesSelect.val(), + logoPath: $logoPathInput.val(), + color: $colorInput.val(), + title: $titleInput.val(), + removeOverlay: $removeOverlayCheck.is(':checked') + }, + headers: { + Authorization: 'Bearer ' + token + } + }) + .done(function(data, status) { + setSaveResult("

" + SUCCESS_MESSAGE + "

"); + setSaveButtonDisabled(false); + }) + .error(function(err) { + if (typeof err.responseJSON.message !== 'undefined') { + setSaveResult("

" + ERROR_MESSAGE + "

" + err.responseJSON.message + "

", { + error: true + }); + } else { + setSaveResult("

" + ERROR_MESSAGE + "

", { error: true }); + } + setSaveButtonDisabled(false); + }); }); - $.ajax({ - url: baseURL+'/admin/user', - headers: { - Authorization: `Bearer ${token}` - } - }) - .done(function(data, status) { - $avatarImg.attr('src', data.avatar); - }) - .error(function(e) { - if (e.statusText === 'Unauthorized') { - performLogin(); + $logoutBtn.on('click', function() { + sessionStorage.removeItem(TOKEN_KEY); + window.location.reload(); + }); + + // Save with Cmd+S / Ctrl+S + $(window).bind('keydown', function(event) { + if (event.ctrlKey || event.metaKey) { + switch (String.fromCharCode(event.which).toLowerCase()) { + case 's': + event.preventDefault(); + $saveChangesBtn.click(); + break; + default: + break; + } } }); + } - $saveChangesBtn.on('click', function(e) { - e.preventDefault(); + function localeAdminPanel() { + var token = sessionStorage.getItem(TOKEN_KEY); + var $localeMenu = $('#locale-menu'); + var $localeDetail = $('#locale-detail'); - setSaveButtonDisabled(true); + function hydrateMenu() { + for (var key in locales) { + $localeMenu.append('
  • ' + locales[key]._name + '
  • ') + } + listenForMenuClicks(); + } + + function hydrateDetail() { + var locale = locales[selectedLocale]; + console.log('locale', locale); + } + + function listenForMenuClicks() { + $('.list-group-item').on('click', function () { + $(this).addClass('active'); + $(this).siblings().removeClass('active'); + selectedLocale = $(this).attr('data-locale-name'); + hydrateDetail(); + }); + } $.ajax({ - url: baseURL+'/admin/settings', - method: 'PUT', - data: { - template: editor.getValue(), - locale: $availableLocalesSelect.val(), - logoPath: $logoPathInput.val(), - color: $colorInput.val(), - title: $titleInput.val(), - removeOverlay: $removeOverlayCheck.is(':checked') - }, + url: baseURL + '/admin/locales', + method: 'GET', headers: { - Authorization: `Bearer ${token}` + Authorization: "Bearer " + token } }) .done(function(data, status) { - setSaveResult(`

    ${SUCCESS_MESSAGE}

    `); - setSaveButtonDisabled(false); + $loadingContainer.hide(); + $appContainer.show(); + + locales = data; + hydrateMenu(); }) .error(function(err) { - if (typeof err.responseJSON.message !== 'undefined') { - setSaveResult(`

    ${ERROR_MESSAGE}

    ${err.responseJSON.message}

    `, { - error: true - }); - } else { - setSaveResult(`

    ${ERROR_MESSAGE}

    `, { error: true }); - } - setSaveButtonDisabled(false); + $loadingContainer.hide(); + alert(err); }); - }); - - $logoutBtn.on('click', function() { - sessionStorage.removeItem(TOKEN_KEY); - window.location.reload(); - }); - - // Save with Cmd+S / Ctrl+S - $(window).bind('keydown', function(event) { - if (event.ctrlKey || event.metaKey) { - switch (String.fromCharCode(event.which).toLowerCase()) { - case 's': - event.preventDefault(); - $saveChangesBtn.click(); - break; - default: - break; - } - } - }); + } + + switch (window.location.pathname) { + case '/admin': + return mainAdminPanel(); + break; + case '/admin/locale': + return localeAdminPanel(); + break; + } } diff --git a/public/css/admin.css b/public/css/admin.css index e5cfe1ae..8aff6b75 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -6,6 +6,10 @@ width: 300px; } +#locale-menu .list-group-item { + cursor: pointer; +} + .loading-state-container { text-align: center; margin-top: calc(50vh - 150px); From ab8bb82ce74457fa13bd7010a591d4aa746eeaf3 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 11:57:40 -0300 Subject: [PATCH 066/207] Render table with locale messages --- public/admin.js | 12 +++++++++++- templates/server/locale.js | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/admin.js b/public/admin.js index 2f9c2a27..27567b2c 100644 --- a/public/admin.js +++ b/public/admin.js @@ -194,6 +194,8 @@ export default function() { var token = sessionStorage.getItem(TOKEN_KEY); var $localeMenu = $('#locale-menu'); var $localeDetail = $('#locale-detail'); + var $localeTitle = $('#locale-title'); + var $managementTable = $('#locale-management-table'); function hydrateMenu() { for (var key in locales) { @@ -204,7 +206,15 @@ export default function() { function hydrateDetail() { var locale = locales[selectedLocale]; - console.log('locale', locale); + $('tr:not(th)').remove(); + + $localeTitle.html(locale._name); + + for (var messageName in locale) { + if (messageName !== '_name') { + $managementTable.append('' + messageName + '') + } + } } function listenForMenuClicks() { diff --git a/templates/server/locale.js b/templates/server/locale.js index 00ccb072..c2989781 100644 --- a/templates/server/locale.js +++ b/templates/server/locale.js @@ -26,6 +26,14 @@ ${header}
    +

    + + + + +
    NameMessage
    + +
    From 7a9a289f0e6438962bcb2050847d6ace4cc071d1 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 14:37:54 -0300 Subject: [PATCH 067/207] Update locales endpoint --- api/admin/put_locales.js | 16 ++++++++++++++++ lib/storage.js | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 api/admin/put_locales.js diff --git a/api/admin/put_locales.js b/api/admin/put_locales.js new file mode 100644 index 00000000..8708201c --- /dev/null +++ b/api/admin/put_locales.js @@ -0,0 +1,16 @@ +/* eslint-disable no-useless-escape */ + +import { setLocales } from '../../lib/storage'; + +module.exports = () => ({ + method: 'PUT', + config: { + auth: 'jwt' + }, + path: '/admin/locales', + handler: (req, reply) => { + setLocales(req.payload).then((response) => { + reply(response); + }); + } +}); diff --git a/lib/storage.js b/lib/storage.js index d9436b46..e1617514 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -1,12 +1,12 @@ import { get as getStorage } from './db'; +import { allLocales } from './locale'; import defTemplate from '../templates/utils/defaultTemplate'; export const STATUS_SUCCESSFUL = 'ok'; export const STATUS_ERRORED = 'error'; // Temporal dummy storage accessor methods -const DEFAULT_LOCALE = 'en'; -const defaultResponse = { +const defaultSettingsResponse = { template: defTemplate, locale: DEFAULT_LOCALE, status: STATUS_SUCCESSFUL, @@ -16,18 +16,21 @@ const defaultResponse = { removeOverlay: false }; +const DEFAULT_LOCALE = 'en'; +const defaultLocaleResponse = allLocales; + export function getSettings() { return new Promise((resolve) => { getStorage() .read() .then((data) => { if (!data.settings) { - return resolve(defaultResponse); + return resolve(defaultSettingsResponse); } return resolve(data.settings); }) - .catch(() => resolve(defaultResponse)); + .catch(() => resolve(defaultSettingsResponse)); }); } @@ -44,3 +47,32 @@ export function setSettings(settings) { }); }); } + +export function getLocales() { + return new Promise((resolve) => { + getStorage() + .read() + .then((data) => { + if (!data.locales) { + return resolve(defaultLocaleResponse); + } + + return resolve(data.locales); + }) + .catch(() => resolve(defaultLocaleResponse)); + }); +} + +export function setLocales(locales) { + return new Promise((resolve) => { + getStorage() + .write({ + locales + }) + .then(() => { + resolve({ + status: STATUS_SUCCESSFUL + }); + }); + }); +} From 2e6b95bd8906701b03d2c3be700fcd2e0b3c6a71 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 14:38:19 -0300 Subject: [PATCH 068/207] Serve saved locales --- api/admin/get_locales.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/admin/get_locales.js b/api/admin/get_locales.js index b01802e3..13d35180 100644 --- a/api/admin/get_locales.js +++ b/api/admin/get_locales.js @@ -1,7 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { getSettings } from '../../lib/storage'; -import { allLocales } from '../../lib/locale'; +import { getSettings, getLocales } from '../../lib/storage'; module.exports = () => ({ method: 'GET', @@ -10,8 +9,8 @@ module.exports = () => ({ }, path: '/admin/locales', handler: (req, reply) => { - getSettings().then((settings) => { - reply(allLocales); + getLocales().then((locales) => { + reply(locales); }); } }); From cf203ebf1bc4f2bef01a50f71407cbdbee9d6603 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 14:38:44 -0300 Subject: [PATCH 069/207] Improve frontend to load and update saved locales --- public/admin.js | 86 +++++++++++++++++++++++++++++++------------- public/css/admin.css | 4 +++ 2 files changed, 65 insertions(+), 25 deletions(-) diff --git a/public/admin.js b/public/admin.js index 27567b2c..de075417 100644 --- a/public/admin.js +++ b/public/admin.js @@ -14,6 +14,27 @@ export default function() { var baseURL = $('base').attr('href'); var $appContainer = $('.app-container'); var $loadingContainer = $('.loading-state-container'); + var $avatarImg = $('.avatar'); + var token = sessionStorage.getItem(TOKEN_KEY); + + $.ajax({ + url: baseURL + '/admin/user', + headers: { + Authorization: 'Bearer ' + token + } + }) + .done(function(data, status) { + $avatarImg.attr('src', data.avatar); + }) + .error(function(e) { + if (e.statusText === 'Unauthorized') { + performLogin(); + } + }); + + function performLogin() { + window.location.href = baseURL + '/login'; + } function mainAdminPanel() { var $titleInput = $('#title_input'); @@ -24,9 +45,6 @@ export default function() { var $saveChangesBtn = $('#save-changes'); var $saveResult = $('#save-result'); var $logoutBtn = $('#logout-btn'); - var $avatarImg = $('.avatar'); - - var token = sessionStorage.getItem(TOKEN_KEY); var editor = CodeMirror.fromTextArea(document.getElementById('code-editor'), { lineNumbers: true, @@ -37,15 +55,11 @@ export default function() { htmlMode: true }); - function performLogin() { - window.location.href = baseURL + '/login'; - } - function fillSelectItem(data) { data.availableLocales.forEach(function(locale) { var isSelected = data.locale === locale.code ? 'selected' : ''; $availableLocalesSelect.append( - '' + '' ); }); } @@ -119,20 +133,6 @@ export default function() { } }); - $.ajax({ - url: baseURL + '/admin/user', - headers: { - Authorization: 'Bearer ' + token - } - }) - .done(function(data, status) { - $avatarImg.attr('src', data.avatar); - }) - .error(function(e) { - if (e.statusText === 'Unauthorized') { - performLogin(); - } - }); $saveChangesBtn.on('click', function(e) { e.preventDefault(); @@ -191,28 +191,31 @@ export default function() { } function localeAdminPanel() { - var token = sessionStorage.getItem(TOKEN_KEY); var $localeMenu = $('#locale-menu'); var $localeDetail = $('#locale-detail'); var $localeTitle = $('#locale-title'); var $managementTable = $('#locale-management-table'); + var $managementSubmit = $('#locale-management-submit'); function hydrateMenu() { for (var key in locales) { $localeMenu.append('
  • ' + locales[key]._name + '
  • ') } listenForMenuClicks(); + + // Select first menu item by default + $('#locale-menu li')[0].click(); } function hydrateDetail() { var locale = locales[selectedLocale]; - $('tr:not(th)').remove(); + $('tr:not(tr.header)').remove(); $localeTitle.html(locale._name); for (var messageName in locale) { if (messageName !== '_name') { - $managementTable.append('' + messageName + '') + $managementTable.append('' + messageName + '') } } } @@ -244,6 +247,39 @@ export default function() { $loadingContainer.hide(); alert(err); }); + + $managementSubmit.on('click', function () { + var editedLocale = { _name: locales[selectedLocale]._name }; + + $managementTable.find('tr').each(function() { + var key = $(this).find('#key').html(); + var message = $(this).find('input').val(); + editedLocale[key] = message; + }) + + locales[selectedLocale] = editedLocale; + + $.ajax({ + url: baseURL + '/admin/locales', + method: 'PUT', + contentType: 'application/json', + data: JSONStringify(locales), + processData: false, + headers: { + Authorization: 'Bearer ' + token + } + }) + .done(function(data, status) { + toastr.success('You have successfully saved your locales.', 'Success!') + }) + .error(function(err) { + if (typeof err.responseJSON.message !== 'undefined') { + toastr.error(err.responseJSON.message, 'Error') + } else { + toastr.error('Please try again later.', 'Error') + } + }); + }); } switch (window.location.pathname) { diff --git a/public/css/admin.css b/public/css/admin.css index 8aff6b75..83f569c9 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -6,6 +6,10 @@ width: 300px; } +#locale-title { + margin-top: 0px; +} + #locale-menu .list-group-item { cursor: pointer; } From 76a1016088d8d1ccde9f537da61afc6186e01175 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 14:38:50 -0300 Subject: [PATCH 070/207] Include missing updates --- server/routes.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/routes.js b/server/routes.js index 91894624..9ea44fc5 100644 --- a/server/routes.js +++ b/server/routes.js @@ -5,6 +5,7 @@ import metaRoute from '../api/get_meta'; import getAdminIndex from '../api/admin/get_index'; import getLocaleAdminIndex from '../api/admin/get_locale_index'; import getLocales from '../api/admin/get_locales'; +import putLocales from '../api/admin/put_locales'; import getAdminSettings from '../api/admin/get_settings'; import putAdminSettings from '../api/admin/put_settings'; import getUserDetails from '../api/admin/get_user_details'; @@ -22,6 +23,7 @@ const register = (server, options, next) => { createRoute(getUserDetails, server); createRoute(getLocaleAdminIndex, server); createRoute(getLocales, server); + createRoute(putLocales, server); next(); }; From c91cbd524f2f84be4980c301cef732e8e763352b Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 14:38:57 -0300 Subject: [PATCH 071/207] Add toastr lib --- templates/server/admin.js | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/server/admin.js b/templates/server/admin.js index 041e945a..8a1ea328 100644 --- a/templates/server/admin.js +++ b/templates/server/admin.js @@ -14,6 +14,7 @@ export default ({ stylesheetTag, baseURL }) => ` + ${stylesheetTag} From 84233d2d824378da820e42e2971ef956f0ced634 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 14:39:52 -0300 Subject: [PATCH 072/207] Add JSON.stringify shim to fix ES6 transpilation ReferenceError when calling it directly from the stringified function --- templates/server/locale.js | 4 ++-- templates/utils/scripts.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/server/locale.js b/templates/server/locale.js index c2989781..c89c40a3 100644 --- a/templates/server/locale.js +++ b/templates/server/locale.js @@ -29,8 +29,8 @@ ${header}

    - - + +
    NameMessageNameMessage
    diff --git a/templates/utils/scripts.js b/templates/utils/scripts.js index ca734cd9..6b61b764 100644 --- a/templates/utils/scripts.js +++ b/templates/utils/scripts.js @@ -1,7 +1,9 @@ import adminJS from '../../public/admin'; export default ` + + From d58ebe3d95ef047f0704d9cf4104a722c33749cb Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 15:09:33 -0300 Subject: [PATCH 073/207] Add new locales (random id, custom name) --- public/admin.js | 16 +++++++++++++++- public/css/admin.css | 4 ++++ templates/server/admin.js | 1 - templates/server/locale.js | 18 ++++++++++++++++-- templates/utils/scripts.js | 15 ++++++++++++++- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/public/admin.js b/public/admin.js index de075417..06edf0f1 100644 --- a/public/admin.js +++ b/public/admin.js @@ -198,6 +198,8 @@ export default function() { var $managementSubmit = $('#locale-management-submit'); function hydrateMenu() { + $localeMenu.find('li').remove(); + for (var key in locales) { $localeMenu.append('
  • ' + locales[key]._name + '
  • ') } @@ -279,7 +281,19 @@ export default function() { toastr.error('Please try again later.', 'Error') } }); - }); + + }); + $('#add-new-locale').on('click', function(e) { + e.preventDefault(); + var $newLocaleNameInput = $('#add-new-locale-name'); + + var newLocaleId = makeid(); + var newLocaleName = $newLocaleNameInput.val(); + locales[newLocaleId] = ObjectAssign({}, locales.en, { _name: `${newLocaleName} (Custom)` }); + + hydrateMenu(); + $newLocaleNameInput.val(''); + }) } switch (window.location.pathname) { diff --git a/public/css/admin.css b/public/css/admin.css index 83f569c9..8d639458 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -14,6 +14,10 @@ cursor: pointer; } +#add-new-locale { + height: 46px; +} + .loading-state-container { text-align: center; margin-top: calc(50vh - 150px); diff --git a/templates/server/admin.js b/templates/server/admin.js index 8a1ea328..041e945a 100644 --- a/templates/server/admin.js +++ b/templates/server/admin.js @@ -14,7 +14,6 @@ export default ({ stylesheetTag, baseURL }) => ` - ${stylesheetTag} diff --git a/templates/server/locale.js b/templates/server/locale.js index c89c40a3..a07d5fd1 100644 --- a/templates/server/locale.js +++ b/templates/server/locale.js @@ -14,6 +14,7 @@ export default ({ stylesheetTag, baseURL }) => ` + ${stylesheetTag} @@ -22,9 +23,22 @@ ${header}
    -
    - +
    +
    +
    +
    +
    + + + + +
    + + +
    + +

    diff --git a/templates/utils/scripts.js b/templates/utils/scripts.js index 6b61b764..fae9cc13 100644 --- a/templates/utils/scripts.js +++ b/templates/utils/scripts.js @@ -1,7 +1,20 @@ import adminJS from '../../public/admin'; export default ` - + From f43f3b9526db7c8ca6edc72bb43f69a62cd9aaa4 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 15:24:18 -0300 Subject: [PATCH 074/207] Add usage support to custom locales --- api/admin/get_settings.js | 6 +++--- lib/locale.js | 23 ++++++++++++++--------- public/admin.js | 2 +- templates/server/locale.js | 14 ++++++-------- templates/utils/auth0widget.js | 8 ++++++-- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/api/admin/get_settings.js b/api/admin/get_settings.js index 0605f838..5593a11d 100644 --- a/api/admin/get_settings.js +++ b/api/admin/get_settings.js @@ -1,7 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { getSettings } from '../../lib/storage'; -import { allLocales as locales } from '../../lib/locale'; +import { getSettings, getLocales } from '../../lib/storage'; module.exports = () => ({ method: 'GET', @@ -9,7 +8,8 @@ module.exports = () => ({ auth: 'jwt' }, path: '/admin/settings', - handler: (req, reply) => { + handler: async (req, reply) => { + const locales = await getLocales(); const availableLocales = Object.keys(locales).map(locale => ({ code: locale, name: locales[locale]._name diff --git a/lib/locale.js b/lib/locale.js index fb0e9729..3fbb0ec3 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -1,17 +1,22 @@ import jsonLocales from '../locales.json'; +import { getLocales } from './storage'; export const allLocales = jsonLocales; -export default function resolveLocale(locale, localeObj = allLocales) { - return function resolve(key) { - const locales = localeObj[locale]; +export default function resolveLocale(locale) { + return new Promise((resolve) => { + getLocales().then((localeObj) => { + resolve((key) => { + const locales = localeObj[locale]; - let localeStr = locales[key]; + let localeStr = locales[key]; - if (typeof localeStr === 'undefined') { - localeStr = localeObj.en[key]; - } + if (typeof localeStr === 'undefined') { + localeStr = localeObj.en[key]; + } - return localeStr; - }; + return localeStr; + }); + }); + }); } diff --git a/public/admin.js b/public/admin.js index 06edf0f1..8cb2fc47 100644 --- a/public/admin.js +++ b/public/admin.js @@ -201,7 +201,7 @@ export default function() { $localeMenu.find('li').remove(); for (var key in locales) { - $localeMenu.append('
  • ' + locales[key]._name + '
  • ') + $localeMenu.append(`
  • ${locales[key]._name}
  • `) } listenForMenuClicks(); diff --git a/templates/server/locale.js b/templates/server/locale.js index a07d5fd1..1794c934 100644 --- a/templates/server/locale.js +++ b/templates/server/locale.js @@ -27,14 +27,12 @@ ${header}
    -
    - - - - -
    - - +
    + + + + +
    diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index 50c4cf7d..909f484d 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -53,9 +53,9 @@ export default dynamicSettings => new Promise(resolve => { getSettings().then(storedSettings => { const settings = Object.assign(storedSettings, dynamicSettings); - const t = getCurrentLocale(settings.locale); + getCurrentLocale(settings.locale).then((t) => { - resolve(` + resolve(`
    ${lockOverlay(settings.removeOverlay)} @@ -119,5 +119,9 @@ export default dynamicSettings => } `); + + }); + + }); }); From b620f501f47b438d68306aae92f139fec9cd79fc Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 15:53:13 -0300 Subject: [PATCH 075/207] Fix tests --- lib/locale.js | 28 +++++++++++++++++----------- test/unit/locale_test.js | 27 +++++++++++++++------------ 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/lib/locale.js b/lib/locale.js index 3fbb0ec3..12985d79 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -3,20 +3,26 @@ import { getLocales } from './storage'; export const allLocales = jsonLocales; -export default function resolveLocale(locale) { - return new Promise((resolve) => { - getLocales().then((localeObj) => { - resolve((key) => { - const locales = localeObj[locale]; +export default function resolveLocale(locale, overrideLocales) { + const returnableFunction = localeObj => (key) => { + const locales = localeObj[locale]; + + let localeStr = locales[key]; - let localeStr = locales[key]; + if (typeof localeStr === 'undefined') { + localeStr = localeObj.en[key]; + } - if (typeof localeStr === 'undefined') { - localeStr = localeObj.en[key]; - } + return localeStr; + }; - return localeStr; - }); + return new Promise((resolve) => { + if (typeof overrideLocales === 'object') { + return resolve(returnableFunction(overrideLocales)); + } + + getLocales().then((localeObj) => { + resolve(returnableFunction(localeObj)); }); }); } diff --git a/test/unit/locale_test.js b/test/unit/locale_test.js index 8c6a0966..0d2cfcaa 100644 --- a/test/unit/locale_test.js +++ b/test/unit/locale_test.js @@ -18,22 +18,25 @@ const sampleLocales = { }; describe('Locale tests', () => { - it('returns a function on initialization', () => { - const t = resolveLocale('en', sampleLocales); - - expect(typeof t).to.equal('function'); + it('returns a function on initialization', (done) => { + resolveLocale('en', sampleLocales).then((t) => { + expect(typeof t).to.equal('function') + done(); + }); }); - it('returns the correct string', () => { - const t = resolveLocale('es', sampleLocales); - - expect(t('a')).to.equal('es-a'); + it('returns the correct string', (done) => { + resolveLocale('es', sampleLocales).then((t) => {; + expect(t('a')).to.equal('es-a'); + done(); + }); }); - it('fallbacks to first locale if single string not found', () => { - const t = resolveLocale('es', sampleLocales); - - expect(t('c')).to.equal('en-c'); + it('fallbacks to first locale if single string not found', (done) => { + resolveLocale('es', sampleLocales).then((t) => {; + expect(t('c')).to.equal('en-c'); + done(); + }); }); it("each locale has a '_name' field", () => { From db63d5acfb33521d29a6e058323bb2cdd9ed3d3d Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 16:01:22 -0300 Subject: [PATCH 076/207] Increase test timeout. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5468ce3f..f54ebc9c 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "scripts": { "start": "node ./index.js", - "test": "nyc --require babel-register --require babel-polyfill mocha test --recursive", + "test": "nyc --require babel-register --require babel-polyfill mocha test --recursive --timeout 5000", "test:integration": "mocha integration --compilers js:babel-core/register --recursive --timeout 50000", "lint": "eslint .", "serve:dev": "gulp run", From 47a1793262962fe3d94bf17b6d60b3a5be87a452 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Tue, 9 Jan 2018 16:29:16 -0300 Subject: [PATCH 077/207] Add default locale --- lib/locale.js | 2 +- lib/storage.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/locale.js b/lib/locale.js index 12985d79..630dbbcd 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -3,7 +3,7 @@ import { getLocales } from './storage'; export const allLocales = jsonLocales; -export default function resolveLocale(locale, overrideLocales) { +export default function resolveLocale(locale = 'en', overrideLocales) { const returnableFunction = localeObj => (key) => { const locales = localeObj[locale]; diff --git a/lib/storage.js b/lib/storage.js index e1617514..ed8d58ff 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -17,7 +17,6 @@ const defaultSettingsResponse = { }; const DEFAULT_LOCALE = 'en'; -const defaultLocaleResponse = allLocales; export function getSettings() { return new Promise((resolve) => { @@ -54,12 +53,12 @@ export function getLocales() { .read() .then((data) => { if (!data.locales) { - return resolve(defaultLocaleResponse); + return resolve(allLocales); } return resolve(data.locales); }) - .catch(() => resolve(defaultLocaleResponse)); + .catch(() => resolve(allLocales)); }); } From 8d773309640675e4bc4c18507d2f8ceea2e4054a Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Wed, 10 Jan 2018 10:40:13 -0300 Subject: [PATCH 078/207] Fix promise chains --- lib/storage.js | 74 +++++++++++++--------------------- templates/utils/auth0widget.js | 20 ++++----- 2 files changed, 35 insertions(+), 59 deletions(-) diff --git a/lib/storage.js b/lib/storage.js index ed8d58ff..b2daebaa 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -19,59 +19,41 @@ const defaultSettingsResponse = { const DEFAULT_LOCALE = 'en'; export function getSettings() { - return new Promise((resolve) => { - getStorage() - .read() - .then((data) => { - if (!data.settings) { - return resolve(defaultSettingsResponse); - } - - return resolve(data.settings); - }) - .catch(() => resolve(defaultSettingsResponse)); - }); + return getStorage() + .read() + .then((data) => { + if (!data.settings) { + return defaultSettingsResponse; + } + + return data.settings; + }); } export function setSettings(settings) { - return new Promise((resolve) => { - getStorage() - .write({ - settings - }) - .then(() => { - resolve({ - status: STATUS_SUCCESSFUL - }); - }); - }); + return getStorage() + .write({ + settings + }) + .then(() => ({ status: STATUS_SUCCESSFUL })); } export function getLocales() { - return new Promise((resolve) => { - getStorage() - .read() - .then((data) => { - if (!data.locales) { - return resolve(allLocales); - } - - return resolve(data.locales); - }) - .catch(() => resolve(allLocales)); - }); + return getStorage() + .read() + .then((data) => { + if (!data.locales) { + return allLocales; + } + + return data.locales; + }); } export function setLocales(locales) { - return new Promise((resolve) => { - getStorage() - .write({ - locales - }) - .then(() => { - resolve({ - status: STATUS_SUCCESSFUL - }); - }); - }); + return getStorage() + .write({ + locales + }) + .then(() => ({ status: STATUS_SUCCESSFUL })); } diff --git a/templates/utils/auth0widget.js b/templates/utils/auth0widget.js index 909f484d..e3cbdf17 100644 --- a/templates/utils/auth0widget.js +++ b/templates/utils/auth0widget.js @@ -4,7 +4,7 @@ import { getSettings } from '../../lib/storage'; import svgDimensions from '../../lib/svgDimensions'; import lockOverlay, { lockOutlineClass } from './lockOverlay'; -const getLogo = (settings) => { +const getLogo = settings => { if (settings.logoPath !== '') { return ``; } @@ -50,14 +50,13 @@ const getSubmitButton = (settings, t) => { }; export default dynamicSettings => - new Promise(resolve => { - getSettings().then(storedSettings => { - const settings = Object.assign(storedSettings, dynamicSettings); - getCurrentLocale(settings.locale).then((t) => { - - resolve(` + getSettings().then(storedSettings => { + const settings = Object.assign(storedSettings, dynamicSettings); + return getCurrentLocale(settings.locale).then(t => `
    -
    +
    ${lockOverlay(settings.removeOverlay)}
    @@ -119,9 +118,4 @@ export default dynamicSettings => } `); - - }); - - - }); }); From 0df6eed2a377ad52f757982024a569fd9824d1b2 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Wed, 10 Jan 2018 10:47:54 -0300 Subject: [PATCH 079/207] Simplify locale function resolution. --- lib/locale.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/locale.js b/lib/locale.js index 630dbbcd..3f6daff9 100644 --- a/lib/locale.js +++ b/lib/locale.js @@ -16,13 +16,7 @@ export default function resolveLocale(locale = 'en', overrideLocales) { return localeStr; }; - return new Promise((resolve) => { - if (typeof overrideLocales === 'object') { - return resolve(returnableFunction(overrideLocales)); - } + const action = typeof overrideLocales === 'object' ? Promise.resolve(overrideLocales) : getLocales(); - getLocales().then((localeObj) => { - resolve(returnableFunction(localeObj)); - }); - }); + return action.then(returnableFunction).catch(() => allLocales); } From 63307b472c1bc9b952ad4a640573d2f89448b0a2 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Wed, 10 Jan 2018 11:12:49 -0300 Subject: [PATCH 080/207] Change logo link path --- templates/utils/header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/utils/header.js b/templates/utils/header.js index 6b741474..ecfe232c 100644 --- a/templates/utils/header.js +++ b/templates/utils/header.js @@ -6,7 +6,7 @@ export default ` -

    Auth0
    Account Linking Extension

    +

    Auth0
    Account Linking Extension

    From 18c3caba7f2203c3f9c6d059963c21a7e569c761 Mon Sep 17 00:00:00 2001 From: Franco Correa Date: Fri, 12 Jan 2018 12:12:31 -0300 Subject: [PATCH 084/207] Fixes and rebundle --- api/admin/get_locales.js | 8 ++------ api/admin/put_locales.js | 6 +----- build/bundle.js | 2 +- lib/storage.js | 16 ++-------------- public/css/admin.min.css | 2 +- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/api/admin/get_locales.js b/api/admin/get_locales.js index 13d35180..9a3e6067 100644 --- a/api/admin/get_locales.js +++ b/api/admin/get_locales.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { getSettings, getLocales } from '../../lib/storage'; +import { getLocales } from '../../lib/storage'; module.exports = () => ({ method: 'GET', @@ -8,9 +8,5 @@ module.exports = () => ({ auth: 'jwt' }, path: '/admin/locales', - handler: (req, reply) => { - getLocales().then((locales) => { - reply(locales); - }); - } + handler: (req, reply) => getLocales().then(reply) }); diff --git a/api/admin/put_locales.js b/api/admin/put_locales.js index 8708201c..06204e73 100644 --- a/api/admin/put_locales.js +++ b/api/admin/put_locales.js @@ -8,9 +8,5 @@ module.exports = () => ({ auth: 'jwt' }, path: '/admin/locales', - handler: (req, reply) => { - setLocales(req.payload).then((response) => { - reply(response); - }); - } + handler: (req, reply) => setLocales(req.payload).then(reply) }); diff --git a/build/bundle.js b/build/bundle.js index 1806c453..17f449ca 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1 @@ -module.exports=function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=81)}([function(e,n){var t=e.exports={version:"2.5.0"};"number"==typeof __e&&(__e=t)},function(e,n,t){var r=t(49)("wks"),o=t(53),i=t(2).Symbol,a="function"==typeof i;(e.exports=function(e){return r[e]||(r[e]=a&&i[e]||(a?i:o)("Symbol."+e))}).store=r},function(e,n){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(34);n.default=(0,r.config)()},function(e,n,t){"use strict";var r=t(140);r.emitErrs=!0;var o=new r.Logger({transports:[new r.transports.Console({timestamp:!0,level:"debug",handleExceptions:!0,json:!1,colorize:!0})],exitOnError:!1});e.exports=o},function(e,n,t){var r=t(16);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,n,t){e.exports={default:t(93),__esModule:!0}},function(e,n,t){var r=t(2),o=t(0),i=t(13),a=t(8),u=function(e,n,t){var s,c,l,d=e&u.F,f=e&u.G,p=e&u.S,h=e&u.P,v=e&u.B,m=e&u.W,g=f?o:o[n]||(o[n]={}),y=g.prototype,_=f?r:p?r[n]:(r[n]||{}).prototype;f&&(t=n);for(s in t)(c=!d&&_&&void 0!==_[s])&&s in g||(l=c?_[s]:t[s],g[s]=f&&"function"!=typeof _[s]?t[s]:v&&c?i(l,r):m&&_[s]==l?function(e){var n=function(n,t,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,t)}return new e(n,t,r)}return e.apply(this,arguments)};return n.prototype=e.prototype,n}(l):h&&"function"==typeof l?i(Function.call,l):l,h&&((g.virtual||(g.virtual={}))[s]=l,e&u.R&&y&&!y[s]&&a(y,s,l)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,e.exports=u},function(e,n,t){var r=t(17),o=t(48);e.exports=t(10)?function(e,n,t){return r.f(e,n,o(1,t))}:function(e,n,t){return e[n]=t,e}},function(e,n){e.exports={}},function(e,n,t){e.exports=!t(14)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,n){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,n){var t={}.toString;e.exports=function(e){return t.call(e).slice(8,-1)}},function(e,n,t){var r=t(11);e.exports=function(e,n,t){if(r(e),void 0===n)return e;switch(t){case 1:return function(t){return e.call(n,t)};case 2:return function(t,r){return e.call(n,t,r)};case 3:return function(t,r,o){return e.call(n,t,r,o)}}return function(){return e.apply(n,arguments)}}},function(e,n){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,n){var t={}.hasOwnProperty;e.exports=function(e,n){return t.call(e,n)}},function(e,n){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,n,t){var r=t(5),o=t(98),i=t(119),a=Object.defineProperty;n.f=t(10)?Object.defineProperty:function(e,n,t){if(r(e),n=i(n,!0),r(t),o)try{return a(e,n,t)}catch(e){}if("get"in t||"set"in t)throw TypeError("Accessors not supported!");return"value"in t&&(e[n]=t.value),e}},function(e,n){e.exports=require("auth0-extension-hapi-tools@1.2.0")},function(e,n,t){"use strict";var r=null;e.exports.init=function(e){r=e},e.exports.get=function(){if(!r)throw new Error("The DB has not been initialized.");return r}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(){return new u.default(function(e){(0,s.get)().read().then(function(n){return e(n.settings?n.settings:f)}).catch(function(){return e(f)})})}function i(e){return new u.default(function(n){(0,s.get)().write({settings:e}).then(function(){n({status:d})})})}Object.defineProperty(n,"__esModule",{value:!0}),n.STATUS_ERRORED=n.STATUS_SUCCESSFUL=void 0;var a=t(6),u=r(a);n.getSettings=o,n.setSettings=i;var s=t(19),c=t(39),l=r(c),d=n.STATUS_SUCCESSFUL="ok",f=(n.STATUS_ERRORED="error",{template:l.default,locale:"en",status:d,color:"#eb5424",title:"",logoPath:"",removeOverlay:!1})},function(e,n,t){"use strict";n.__esModule=!0;var r=t(40),o=function(e){return e&&e.__esModule?e:{default:e}}(r);n.default=o.default||function(e){for(var n=1;n0?r:t)(e)}},function(e,n,t){var r=t(43),o=t(23);e.exports=function(e){return r(o(e))}},function(e,n,t){var r=t(23);e.exports=function(e){return Object(r(e))}},function(e,n,t){"use strict";var r=t(117)(!0);t(44)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,n=this._t,t=this._i;return t>=n.length?{value:void 0,done:!0}:(e=r(n,t),this._i+=e.length,{value:e,done:!1})})},function(e,n,t){t(122);for(var r=t(2),o=t(8),i=t(9),a=t(1)("toStringTag"),u="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),s=0;s1&&void 0!==arguments[1]?arguments[1]:a;return function(t){var r=n[e],o=r[t];return void 0===o&&(o=n.en[t]),o}}Object.defineProperty(n,"__esModule",{value:!0}),n.allLocales=void 0,n.default=r;var o=t(129),i=function(e){return e&&e.__esModule?e:{default:e}}(o),a=n.allLocales=i.default},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(130).version,o="https://cdn.auth0.com/extensions/auth0-account-link-extension/"+r,i=function(e){return e?o:"/css"},a=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=e?"min.css":"css",t=function(t){var r=(t||"").trim();return r?i(e)+"/"+r+"."+n:""};return{link:t,tag:function(e){var n=t(e);return n?'':""}}};n.default=a},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={text:"M246.517,0.11 C238.439,0.11 231.607,3.916 226.759,11.115 C221.94,18.271 219.393,28.26 219.393,40 C219.393,51.74 221.94,61.729 226.759,68.884 C231.607,76.084 238.439,79.889 246.517,79.889 C254.595,79.889 261.427,76.084 266.275,68.884 C271.093,61.729 273.64,51.74 273.64,40 C273.64,28.26 271.093,18.271 266.275,11.115 C261.427,3.916 254.595,0.11 246.517,0.11 L246.517,0.11 Z M246.517,70.005 C242.655,70.005 239.604,67.82 237.187,63.324 C234.268,57.893 232.66,49.61 232.66,40 C232.66,30.39 234.268,22.106 237.187,16.676 C239.604,12.18 242.655,9.994 246.517,9.994 C250.378,9.994 253.43,12.18 255.847,16.676 C258.766,22.106 260.373,30.389 260.373,40 C260.373,49.611 258.766,57.895 255.847,63.324 C253.43,67.82 250.378,70.005 246.517,70.005 L246.517,70.005 Z M71.45,29.172 L71.45,63.484 C71.45,72.53 78.81,79.889 87.856,79.889 C95.746,79.889 101.707,75.975 103.902,74.291 C104.024,74.197 104.184,74.169 104.331,74.216 C104.478,74.263 104.592,74.379 104.637,74.527 L105.961,78.86 L115.737,78.86 L115.737,29.172 L103.175,29.172 L103.175,66.326 C103.175,66.501 103.076,66.662 102.921,66.743 C100.559,67.961 95.899,70.006 91.231,70.006 C87.252,70.006 84.012,66.768 84.012,62.787 L84.012,29.172 L71.45,29.172 L71.45,29.172 Z M197.237,78.859 L209.8,78.859 L209.8,44.547 C209.8,35.501 202.44,28.141 193.394,28.141 C186.735,28.141 181.393,31.004 178.802,32.71 C178.657,32.805 178.473,32.813 178.322,32.731 C178.171,32.649 178.075,32.491 178.075,32.318 L178.075,1.141 L165.513,1.141 L165.513,78.859 L178.075,78.859 L178.075,41.704 C178.075,41.529 178.174,41.368 178.33,41.288 C180.691,40.069 185.352,38.025 190.019,38.025 C191.947,38.025 193.76,38.776 195.123,40.139 C196.486,41.502 197.236,43.316 197.236,45.243 L197.236,78.859 L197.237,78.859 Z M124.792,39.055 L132.438,39.055 C132.697,39.055 132.907,39.265 132.907,39.524 L132.907,66.858 C132.907,74.043 138.753,79.888 145.938,79.888 C148.543,79.888 151.113,79.512 153.585,78.77 L153.585,69.796 C152.143,69.923 150.485,70.005 149.313,70.005 C147.193,70.005 145.469,68.28 145.469,66.161 L145.469,39.523 C145.469,39.264 145.679,39.054 145.938,39.054 L153.585,39.054 L153.585,29.171 L145.938,29.171 C145.679,29.171 145.469,28.961 145.469,28.702 L145.469,12.295 L132.907,12.295 L132.907,28.702 C132.907,28.961 132.697,29.171 132.438,29.171 L124.792,29.171 L124.792,39.055 L124.792,39.055 Z M51.361,78.859 L64.429,78.859 L44.555,9.55 C42.962,3.992 37.811,0.11 32.029,0.11 C26.247,0.11 21.096,3.992 19.502,9.55 L-0.372,78.859 L12.697,78.859 L18.449,58.798 C18.507,58.597 18.691,58.459 18.9,58.459 L45.158,58.459 C45.367,58.459 45.552,58.597 45.609,58.798 L51.361,78.859 L51.361,78.859 Z M42.056,48.576 L22.004,48.576 C21.857,48.576 21.718,48.507 21.629,48.388 C21.541,48.272 21.513,48.119 21.553,47.978 L31.579,13.012 C31.637,12.811 31.821,12.673 32.03,12.673 C32.239,12.673 32.423,12.811 32.48,13.012 L42.507,47.978 C42.547,48.12 42.519,48.272 42.43,48.388 C42.342,48.507 42.203,48.576 42.056,48.576 L42.056,48.576 Z",badge:"M119.555,135.861 L102.705,83.997 L146.813,51.952 L92.291,51.952 L75.44,0.09 L75.435,0.076 L129.965,0.076 L146.82,51.947 L146.821,51.946 L146.835,51.938 C156.623,82.03 146.542,116.256 119.555,135.861 L119.555,135.861 Z M31.321,135.861 L31.307,135.871 L75.426,167.924 L119.555,135.862 L75.44,103.808 L31.321,135.861 L31.321,135.861 Z M4.052,51.939 L4.052,51.939 C-6.252,83.66 5.709,117.272 31.312,135.867 L31.316,135.851 L48.168,83.99 L4.07,51.951 L58.579,51.951 L75.431,0.089 L75.435,0.075 L20.902,0.075 L4.052,51.939 L4.052,51.939 Z"};n.default=r},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.uninstall=n.install=void 0;var o=t(21),i=r(o),a=t(71),u=r(a),s="auth0-account-link-extension",c=function(e){return e.find(function(e){return e.name===s})},l=function(e,n){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=t.find(function(e){return e.name===s});return r?e.update({id:r.id},n):e.create((0,i.default)({stage:"login_success"},n))}},d=function(e){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=c(n);t&&e.delete({id:t.id})}},f=function(e,n){var t={name:s,script:(0,u.default)(n),enabled:!0};return e.getAll().then(l(e,t))},p=function(e){return e.getAll().then(d(e))};n.install=f,n.uninstall=p},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default='\n\n\n \n \n \n \n \n Auth0 Account Linking Extension\n \n {{ ExtensionCSS }}\n {{ CustomCSS }}\n \n \n \n {{ Auth0Widget }}\n {{ ExtensionScripts }}\n \n\n'},function(e,n,t){e.exports={default:t(91),__esModule:!0}},function(e,n){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,n,t){var r=t(2).document;e.exports=r&&r.documentElement},function(e,n,t){var r=t(12);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,n,t){"use strict";var r=t(45),o=t(7),i=t(115),a=t(8),u=t(15),s=t(9),c=t(102),l=t(27),d=t(110),f=t(1)("iterator"),p=!([].keys&&"next"in[].keys()),h=function(){return this};e.exports=function(e,n,t,v,m,g,y){c(t,n,v);var _,b,k,x=function(e){if(!p&&e in j)return j[e];switch(e){case"keys":case"values":return function(){return new t(this,e)}}return function(){return new t(this,e)}},w=n+" Iterator",L="values"==m,T=!1,j=e.prototype,C=j[f]||j["@@iterator"]||m&&j[m],S=C||x(m),O=m?L?x("entries"):S:void 0,A="Array"==n?j.entries||C:C;if(A&&(k=d(A.call(new e)))!==Object.prototype&&k.next&&(l(k,w,!0),r||u(k,f)||a(k,f,h)),L&&C&&"values"!==C.name&&(T=!0,S=function(){return C.call(this)}),r&&!y||!p&&!T&&j[f]||a(j,f,S),s[n]=S,s[w]=h,m)if(_={values:L?S:x("values"),keys:g?S:x("keys"),entries:O},y)for(b in _)b in j||i(j,b,_[b]);else o(o.P+o.F*(p||T),n,_);return _}},function(e,n){e.exports=!0},function(e,n){e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,n,t){var r=t(25);e.exports=function(e,n){var t=r.f(e);return(0,t.resolve)(n),t.promise}},function(e,n){e.exports=function(e,n){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:n}}},function(e,n,t){var r=t(2),o=r["__core-js_shared__"]||(r["__core-js_shared__"]={});e.exports=function(e){return o[e]||(o[e]={})}},function(e,n,t){var r=t(5),o=t(11),i=t(1)("species");e.exports=function(e,n){var t,a=r(e).constructor;return void 0===a||void 0==(t=r(a)[i])?n:o(t)}},function(e,n,t){var r,o,i,a=t(13),u=t(99),s=t(42),c=t(24),l=t(2),d=l.process,f=l.setImmediate,p=l.clearImmediate,h=l.MessageChannel,v=l.Dispatch,m=0,g={},y=function(){var e=+this;if(g.hasOwnProperty(e)){var n=g[e];delete g[e],n()}},_=function(e){y.call(e.data)};f&&p||(f=function(e){for(var n=[],t=1;arguments.length>t;)n.push(arguments[t++]);return g[++m]=function(){u("function"==typeof e?e:Function(e),n)},r(m),m},p=function(e){delete g[e]},"process"==t(12)(d)?r=function(e){d.nextTick(a(y,e,1))}:v&&v.now?r=function(e){v.now(a(y,e,1))}:h?(o=new h,i=o.port2,o.port1.onmessage=_,r=a(i.postMessage,i,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(r=function(e){l.postMessage(e+"","*")},l.addEventListener("message",_,!1)):r="onreadystatechange"in c("script")?function(e){s.appendChild(c("script")).onreadystatechange=function(){s.removeChild(this),y.call(e)}}:function(e){setTimeout(a(y,e,1),0)}),e.exports={set:f,clear:p}},function(e,n,t){var r=t(29),o=Math.min;e.exports=function(e){return e>0?o(r(e),9007199254740991):0}},function(e,n){var t=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++t+r).toString(36))}},function(e,n,t){var r=t(22),o=t(1)("iterator"),i=t(9);e.exports=t(0).getIteratorMethod=function(e){if(void 0!=e)return e[o]||e["@@iterator"]||i[r(e)]}},function(e,n){e.exports=require("jsonwebtoken@7.1.9")},function(e,n){e.exports=require("path")},function(e,n,t){"use strict";(function(n){function r(e){return e&&e.__esModule?e:{default:e}}var o=t(56),i=r(o),a=t(34),u=t(3),s=r(u),c=t(74),l=r(c),d=t(4),f=r(d),p=t(19),h=function(e){e?(f.default.error("Hapi initialization failed."),f.default.error(e)):f.default.info("Hapi initialization completed.")},v=function(e,r,o){return s.default.setProvider(function(n){return e(n)||t.i({NODE_ENV:"production",CLIENT_VERSION:"2.0.2"})[n]}),(0,p.init)(r?new a.WebtaskStorageContext(r,{force:0}):new a.FileStorageContext(i.default.join(n,"../data.json"))),(0,l.default)(o||h)};e.exports=v}).call(n,"/")},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=t(77),i=r(o),a=t(3),u=r(a),s=t(36),c=r(s);e.exports=function(){return{method:"GET",path:"/admin",config:{auth:!1},handler:function(e,n){var t=(0,c.default)("production"===(0,u.default)("NODE_ENV"));n((0,i.default)({stylesheetTag:t.tag("admin"),baseURL:(0,u.default)("PUBLIC_WT_URL")}))}}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=t(21),i=r(o),a=t(85),u=r(a),s=t(20),c=t(35);e.exports=function(){return{method:"GET",config:{auth:"jwt"},path:"/admin/settings",handler:function(e,n){var t=(0,u.default)(c.allLocales).map(function(e){return{code:e,name:c.allLocales[e]._name}});(0,s.getSettings)().then(function(e){n((0,i.default)({},e,{availableLocales:t}))})}}}},function(e,n,t){"use strict";var r=t(67),o=function(e){return e&&e.__esModule?e:{default:e}}(r);e.exports=function(){return{method:"GET",path:"/admin/user",config:{auth:"jwt"},handler:function(e,n){n({email:e.auth.credentials.email,avatar:(0,o.default)(e.auth.credentials.email)})}}}},function(e,n,t){"use strict";var r=t(137),o=function(e){return e&&e.__esModule?e:{default:e}}(r),i=t(20),a=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/,u=/^#[A-Fa-f0-9]{6}/;e.exports=function(){return{method:"PUT",config:{auth:"jwt",validate:{payload:{template:o.default.string().required(),locale:o.default.string().required(),title:o.default.string().required(),color:o.default.string().regex(u).required(),logoPath:o.default.string().regex(a).allow(""),removeOverlay:o.default.bool().default(!1)}}},path:"/admin/settings",handler:function(e,n){(0,i.setSettings)(e.payload).then(function(e){n(e)})}}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=t(6),i=r(o),a=t(55),u=t(3),s=r(u),c=t(68),l=r(c),d=t(76),f=r(d),p=t(4),h=r(p),v=t(36),m=r(v),g=function(e){return new i.default(function(n,t){try{n((0,a.decode)(e))}catch(e){t(e)}})},y=function(e){var n=e.sub,t=e.email;return(0,l.default)(t).then(function(e){return{currentUser:e.find(function(e){return e.user_id===n}),matchingUsers:e.filter(function(e){return e.user_id!==n})}})};e.exports=function(){return{method:"GET",path:"/",config:{auth:!1},handler:function(e,n){var t=e.state["account-linking-admin-state"];if(void 0!==t&&""!==t)return void n.redirect((0,s.default)("PUBLIC_WT_URL")+"/admin").state("account-linking-admin-state","");var r=(0,m.default)("production"===(0,s.default)("NODE_ENV")),o=r.tag("link"),i=r.tag((0,s.default)("CUSTOM_CSS")),a={};e.query.locale&&(a.locale=e.query.locale),e.query.color&&(a.color="#"+e.query.color),e.query.title&&(a.title=e.query.title),e.query.logoPath&&(a.logoPath=e.query.logoPath),g(e.query.child_token).then(function(t){y(t).then(function(e){var t=e.currentUser,r=e.matchingUsers;n((0,f.default)({dynamicSettings:a,stylesheetTag:o,currentUser:t,matchingUsers:r,customCSSTag:i}))}).catch(function(r){var o=e.query.state;h.default.error("An error was encountered: ",r),h.default.info("Redirecting to failed link to /continue: "+t.iss+"continue?state="+e.query.state),n.redirect(t.iss+"continue?state="+o)})}).catch(function(e){h.default.error("An invalid token was provided",e),(0,f.default)({dynamicSettings:a,stylesheetTag:o,currentUser:null,matchingUsers:[],customCSSTag:i}).then(function(e){n(e).code(400)})})}}}},function(e,n,t){"use strict";var r=t(131),o=function(e){return e&&e.__esModule?e:{default:e}}(r);e.exports=function(){return{method:"GET",path:"/meta",config:{auth:!1},handler:function(e,n){return n(o.default)}}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=t(6),i=r(o),a=t(38),u=t(3),s=r(u),c=t(4),l=r(c);e.exports=function(e){return{method:"DELETE",path:"/.extensions/on-uninstall",config:{auth:!1,pre:[e.handlers.validateHookToken("/.extensions/on-uninstall"),e.handlers.managementClient]},handler:function(e,n){l.default.info("Starting uninstall..."),i.default.all([(0,a.uninstall)(e.pre.auth0.rules),e.pre.auth0.deleteClient({client_id:(0,s.default)("AUTH0_CLIENT_ID")})]).then(function(){return n().code(204)}).catch(function(e){l.default.error("Something went wrong while uninstalling Account Link Extension: ",e),n().code(204)})}}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=t(38),i=t(3),a=r(i),u=t(4),s=r(u);e.exports=function(e){return{method:"POST",path:"/.extensions/on-install",config:{auth:!1,pre:[e.handlers.validateHookToken("/.extensions/on-install"),e.handlers.managementClient]},handler:function(e,n){s.default.info("Starting rule installation..."),(0,o.install)(e.pre.auth0.rules,{extensionURL:(0,a.default)("PUBLIC_WT_URL"),clientID:(0,a.default)("AUTH0_CLIENT_ID"),clientSecret:(0,a.default)("AUTH0_CLIENT_SECRET")}).then(function(){return n().code(204)}).then(function(){s.default.info("Rule successfully installed")}).catch(function(e){throw s.default.error("Something went wrong, ",e),e}).catch(function(e){return n.error(e)})}}}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=t(21),i=r(o),a=t(6),u=r(a),s=t(86),c=r(s),l=t(34),d=t(139),f=r(d),p=t(3),h=r(p),v=t(4),m=r(v),g={base:void 0,getBaseUrl:function(){return this.base||(this.base="https://"+(0,h.default)("AUTH0_DOMAIN")+"/api/v2"),this.base},endpoint:function(e){return this.getBaseUrl()+"/"+e}},y=function(){return l.managementApi.getAccessTokenCached((0,h.default)("AUTH0_DOMAIN"),(0,h.default)("AUTH0_CLIENT_ID"),(0,h.default)("AUTH0_CLIENT_SECRET"))},_=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.path,t=(0,c.default)(e,["path"]);return y().then(function(e){return new u.default(function(r,o){(0,f.default)((0,i.default)({url:g.endpoint(n),headers:{Authorization:"Bearer "+e,Accept:"application/json"},json:!0},t),function(e,n,t){e?o(e):n.statusCode<200||n.statusCode>=300?(m.default.error("API call failed: ",n.status,t),o(new Error(t))):r(n.body)})})})};n.default=_},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(133),o=function(e){return e&&e.__esModule?e:{default:e}}(r),i=function(e){return"https://s.gravatar.com/avatar/"+o.default.createHash("md5").update(e).digest("hex")+"?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2F"+e.substr(0,2)+".png"};n.default=i},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(66),o=function(e){return e&&e.__esModule?e:{default:e}}(r),i=function(e){return(0,o.default)({path:"users-by-email",qs:{email:e}})};n.default=i},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(){function e(){window.location.href=u+"/login"}function n(e){e.availableLocales.forEach(function(n){var t=e.locale===n.code?"selected":"";f.append('")})}function t(e,n){e.setValue(n.template.trim())}function r(e){e?v.addClass("disabled").html("Saving changes..."):v.removeClass("disabled").html("Save changes")}function o(e,n){m.removeClass("alert-danger"),m.removeClass("alert-success"),m.html(e),m.show(),n&&n.error?m.addClass("alert-danger"):m.addClass("alert-success"),setTimeout(function(){m.html(""),m.hide(),n.error?m.removeClass("alert-danger"):m.removeClass("alert-success")},1e4)}var i="Oops! An error has ocurred while trying to save your changes.",a="com.auth0.account_linking.admin_ui.session_token",u=$("base").attr("href"),s=$("#title_input"),c=$("#logo_path_input"),l=$("#color_input"),d=$("#remove_overlay"),f=$("#available-locales"),p=$(".app-container"),h=$(".loading-state-container"),v=$("#save-changes"),m=$("#save-result"),g=$("#logout-btn"),y=$(".avatar"),_=sessionStorage.getItem(a),b=CodeMirror.fromTextArea(document.getElementById("code-editor"),{lineNumbers:!0,matchBrackets:!0,tabMode:"indent",theme:"material",mode:"xml",htmlMode:!0});_||e(),b.setSize(null,500),$.ajax({url:u+"/admin/settings",headers:{Authorization:"Bearer "+_}}).done(function(e){h.hide(),p.show(),t(b,e),n(e),s.val(e.title),l.val(e.color),c.val(e.logoPath),d.prop("checked",e.removeOverlay||!1)}).error(function(n){"Unauthorized"===n.statusText&&e()}),$.ajax({url:u+"/admin/user",headers:{Authorization:"Bearer "+_}}).done(function(e,n){y.attr("src",e.avatar)}).error(function(n){"Unauthorized"===n.statusText&&e()}),v.on("click",function(e){e.preventDefault(),r(!0),$.ajax({url:u+"/admin/settings",method:"PUT",data:{template:b.getValue(),locale:f.val(),logoPath:c.val(),color:l.val(),title:s.val(),removeOverlay:d.is(":checked")},headers:{Authorization:"Bearer "+_}}).done(function(e,n){o("

    Success! Your changes has been successfully saved.

    "),r(!1)}).error(function(e){void 0!==e.responseJSON.message?o("

    "+i+"

    "+e.responseJSON.message+"

    ",{error:!0}):o("

    "+i+"

    ",{error:!0}),r(!1)})}),g.on("click",function(){sessionStorage.removeItem(a),window.location.reload()}),$(window).bind("keydown",function(e){if(e.ctrlKey||e.metaKey)switch(String.fromCharCode(e.which).toLowerCase()){case"s":e.preventDefault(),v.click()}})}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,n){function t(){var e=document.getElementById("error-message"),n=window.Auth0AccountLinkingExtension.locale.sameEmailAddressError||"Accounts must have matching email addresses. Please try again.";e.innerHTML=n,e.style.display="block"}function r(e,n,t){var r,o=document.createElement(e),a=t||[],u=n||{};for(r in i(u))o.setAttribute(r,u[r]);for(r in a)o.appendChild(a[r]);return o}function o(e){return document.createTextNode(e)}function i(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(t);return n}var a=window.Qs.parse(window.location.search,{ignoreQueryPrefix:!0});try{!function(e){var r=document.getElementById("link"),o=document.getElementById("skip"),u=n.reduce(function(e,n){return e.concat(n.identities)},[]).map(function(e){return e.connection}),s=function(e,n){var t=i(n).filter(function(e){return!!n[e]}).map(function(e){return e+"="+encodeURIComponent(n[e])}).join("&");window.location=e+"authorize?"+t};r.addEventListener("click",function(n){s(e.iss,{client_id:a.client_id,redirect_uri:a.redirect_uri,response_type:a.response_type,scope:a.scope,state:a.original_state,nonce:a.nonce,link_account_token:a.child_token,prevent_sign_up:!0,connection:u[0]})}),function(e,n,t){e.href=n+"continue?state="+t}(o,e.iss,a.state),"accountMismatch"===a.error_type&&t()}(window.jwt_decode(a.child_token))}catch(e){console.error(e),function(){var e=document.getElementById("content-container"),n=(document.getElementById("label-value"),document.getElementById("link"));e.innerHTML="",e.appendChild(r("div",{},[r("p",{},[o(window.Auth0AccountLinkingExtension.locale.pageMismatchError||"You seem to have reached this page in error. Please try logging in again")])])),n.disabled=!0}()}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e){var n=e.extensionURL,t=void 0===n?"":n,r=e.username,o=void 0===r?"Unknown":r,i=e.clientID,a=void 0===i?"":i,u=e.clientSecret,s=void 0===u?"":u;return"function (user, context, callback) {\n /**\n * This rule has been automatically generated by\n * "+o+" at "+(new Date).toISOString()+"\n */\n var request = require('request@2.56.0');\n var queryString = require('querystring');\n var Promise = require('native-or-bluebird@1.2.0');\n var jwt = require('jsonwebtoken@7.1.9');\n\n var CONTINUE_PROTOCOL = 'redirect-callback';\n var LOG_TAG = '[ACCOUNT_LINK]: ';\n console.log(LOG_TAG, 'Entered Account Link Rule');\n\n // 'query' can be undefined when using '/oauth/token' to log in\n context.request.query = context.request.query || {};\n\n var config = {\n endpoints: {\n linking: '"+t.replace(/\/$/g,"")+"',\n userApi: auth0.baseUrl + '/users',\n usersByEmailApi: auth0.baseUrl + '/users-by-email'\n },\n token: {\n clientId: '"+a+"',\n clientSecret: '"+s+"',\n issuer: auth0.domain\n }\n };\n\n createStrategy().then(callbackWithSuccess).catch(callbackWithFailure);\n\n function createStrategy() {\n if (shouldLink()) {\n return linkAccounts();\n } else if (shouldPrompt()) {\n return promptUser();\n\n }\n\n return continueAuth();\n\n function shouldLink() {\n return !!context.request.query.link_account_token;\n }\n\n function shouldPrompt() {\n return !insideRedirect() && !redirectingToContinue() && firstLogin();\n\n // Check if we're inside a redirect\n // in order to avoid a redirect loop\n // TODO: May no longer be necessary\n function insideRedirect() {\n return context.request.query.redirect_uri &&\n context.request.query.redirect_uri.indexOf(config.endpoints.linking) !== -1;\n }\n\n // Check if this is the first login of the user\n // since merging already active accounts can be a\n // destructive action\n function firstLogin() {\n return context.stats.loginsCount <= 1;\n }\n\n // Check if we're coming back from a redirect\n // in order to avoid a redirect loop. User will\n // be sent to /continue at this point. We need\n // to assign them to their primary user if so.\n function redirectingToContinue() {\n return context.protocol === CONTINUE_PROTOCOL;\n }\n }\n }\n\n function verifyToken(token, secret) {\n return new Promise(function(resolve, reject) {\n jwt.verify(token, secret, function(err, decoded) {\n if (err) {\n return reject(err);\n }\n\n return resolve(decoded);\n });\n });\n }\n\n function linkAccounts() {\n var secondAccountToken = context.request.query.link_account_token;\n\n return verifyToken(secondAccountToken, config.token.clientSecret)\n .then(function(decodedToken) {\n // Redirect early if tokens are mismatched\n if (user.email !== decodedToken.email) {\n console.error(LOG_TAG, 'User: ', decodedToken.email, 'tried to link to account ', user.email);\n context.redirect = {\n url: buildRedirectUrl(secondAccountToken, context.request.query, 'accountMismatch')\n };\n\n return user;\n }\n\n var uri = config.endpoints.userApi+'/'+user.user_id+'/identities';\n\n return apiCall({\n method: 'POST',\n url: uri,\n headers: {\n Authorization: 'Bearer ' + createToken(config.token),\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache'\n },\n json: { link_with: secondAccountToken }\n }).then(function(_) {\n // TODO: Ask about this\n console.info(LOG_TAG, 'Successfully linked accounts for user: ', user.email);\n return _;\n });\n });\n }\n\n function continueAuth() {\n return Promise.resolve();\n }\n\n function promptUser() {\n return searchUsersWithSameEmail().then(function transformUsers(users) {\n \n return users.filter(function(u) {\n return u.user_id !== user.user_id;\n }).map(function(user) {\n return {\n userId: user.user_id,\n email: user.email,\n picture: user.picture,\n connections: user.identities.map(function(identity) {\n return identity.connection;\n })\n };\n });\n }).then(function redirectToExtension(targetUsers) {\n if (targetUsers.length > 0) {\n context.redirect = {\n url: buildRedirectUrl(createToken(config.token), context.request.query)\n };\n }\n });\n }\n\n function callbackWithSuccess(_) {\n callback(null, user, context);\n\n return _;\n }\n\n function callbackWithFailure(err) {\n console.error(LOG_TAG, err.message, err.stack);\n\n callback(err, user, context);\n }\n\n function createToken(tokenInfo, targetUsers) {\n var options = {\n expiresIn: '5m',\n audience: tokenInfo.clientId,\n issuer: qualifyDomain(tokenInfo.issuer)\n };\n\n var userSub = {\n sub: user.user_id,\n email: user.email,\n base: auth0.baseUrl\n };\n\n return jwt.sign(userSub, tokenInfo.clientSecret, options);\n }\n\n function searchUsersWithSameEmail() {\n return apiCall({\n url: config.endpoints.usersByEmailApi,\n qs: {\n email: user.email\n }\n });\n }\n\n // Consider moving this logic out of the rule and into the extension\n function buildRedirectUrl(token, q, errorType) {\n var params = {\n child_token: token,\n client_id: q.client_id,\n redirect_uri: q.redirect_uri,\n scope: q.scope,\n response_type: q.response_type,\n auth0Client: q.auth0Client,\n original_state: q.original_state || q.state,\n nonce: q.nonce,\n error_type: errorType\n };\n\n return config.endpoints.linking + '?' + queryString.encode(params);\n }\n\n function qualifyDomain(domain) {\n return 'https://'+domain+'/';\n }\n\n function apiCall(options) {\n return new Promise(function(resolve, reject) {\n var reqOptions = Object.assign({\n url: options.url,\n headers: {\n Authorization: 'Bearer ' + auth0.accessToken,\n Accept: 'application/json'\n },\n json: true\n }, options);\n\n request(reqOptions, function handleResponse(err, response, body) {\n if (err) {\n reject(err);\n } else if (response.statusCode < 200 || response.statusCode >= 300) {\n console.error(LOG_TAG, 'API call failed: ', body);\n reject(new Error(body));\n } else {\n resolve(response.body);\n }\n });\n });\n }\n}"}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var o=t(132),i=r(o),a=t(138),u=r(a),s=t(55),c=r(s),l=t(18),d=function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n.default=e,n}(l),f=t(3),p=r(f),h=[{value:"openid"},{value:"profile"}];e.exports.register=function(e,n,t){var r={dashboardAdmin:{key:(0,p.default)("EXTENSION_SECRET"),verifyOptions:{audience:"urn:api-account-linking",issuer:(0,p.default)("PUBLIC_WT_URL"),algorithms:["HS256"]}},resourceServer:{key:u.default.hapiJwt2Key({cache:!0,rateLimit:!0,jwksRequestsPerMinute:2,jwksUri:"https://"+(0,p.default)("AUTH0_DOMAIN")+"/.well-known/jwks.json"}),verifyOptions:{audience:"urn:auth0-account-linking-api",issuer:"https://"+(0,p.default)("AUTH0_DOMAIN")+"/",algorithms:["RS256"]}}};e.auth.strategy("jwt","jwt",{complete:!0,verifyFunc:function(e,n,t){if(!e)return t(null,!1);var o=n.headers.authorization;if(o&&0===o.indexOf("Bearer ")){var a=o.split(" ")[1];if(e&&e.payload&&e.payload.iss==="https://"+(0,p.default)("AUTH0_DOMAIN")+"/")return r.resourceServer.key(e,function(n,o){return n?t(i.default.wrap(n),null,null):c.default.verify(a,o,r.resourceServer.verifyOptions,function(n){return n?t(i.default.unauthorized("Invalid token","Token"),null,null):e.payload.gty&&"client-credentials"!==e.payload.gty?t(i.default.unauthorized("Invalid token","Token"),null,null):e.payload.sub.endsWith("@clients")?(e.payload.scope&&"string"==typeof e.payload.scope&&(e.payload.scope=e.payload.scope.split(" ")),t(null,!0,e.payload)):t(i.default.unauthorized("Invalid token","Token"),null,null)})});if(e&&e.payload&&e.payload.iss===(0,p.default)("PUBLIC_WT_URL"))return c.default.verify(a,r.dashboardAdmin.key,r.dashboardAdmin.verifyOptions,function(n){return n?t(i.default.unauthorized("Invalid token","Token"),null,null):e.payload.access_token&&e.payload.access_token.length?(e.payload.scope=h.map(function(e){return e.value}),t(null,!0,e.payload)):t(i.default.unauthorized("Invalid token","Token"),null,null)})}return t(null,!1)}}),e.auth.default("jwt");var o={register:d.plugins.dashboardAdminSession,options:{stateKey:"account-linking-admin-state",sessionStorageKey:"com.auth0.account_linking.admin_ui.session_token",rta:(0,p.default)("AUTH0_RTA").replace("https://",""),domain:(0,p.default)("AUTH0_DOMAIN"),scopes:"",baseUrl:(0,p.default)("PUBLIC_WT_URL"),audience:"urn:api-account-linking",secret:(0,p.default)("EXTENSION_SECRET"),clientName:"auth0-account-link",onLoginSuccess:function(e,n,t){return e?(e.scope=h.map(function(e){return e.value}),t(null,!0,e)):t(null,!1)}}};e.register(o,function(e){e&&t(e),t()})},e.exports.register.attributes={name:"auth"}},function(e,n,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=t(18),i=t(3),a=r(i),u=t(4),s=r(u),c=function(e,n,t){e.decorate("server","handlers",{managementClient:o.handlers.managementApiClient({domain:(0,a.default)("AUTH0_DOMAIN"),clientId:(0,a.default)("AUTH0_CLIENT_ID"),clientSecret:(0,a.default)("AUTH0_CLIENT_SECRET"),logger:s.default.error}),validateHookToken:o.handlers.validateHookToken((0,a.default)("AUTH0_DOMAIN"),(0,a.default)("WT_URL"),(0,a.default)("EXTENSION_SECRET"))}),t()};c.attributes={name:"handlers"},n.default=c},function(e,n,t){"use strict";(function(e){function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=t(56),i=r(o),a=t(135),u=r(a),s=t(136),c=r(s),l=t(134),d=r(l),f=t(3),p=r(f),h=t(4),v=r(h),m=t(75),g=r(m),y=t(73),_=r(y),b=t(72),k=r(b),x=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_.default,r=new u.default.Server;return r.connection({host:"localhost",port:(0,p.default)("PORT"),routes:{cors:!0,validate:{},files:{relativeTo:i.default.join(e,"../public")}}}),r.register([d.default,c.default],function(){}),r.route({method:"GET",path:"/js/{file*}",config:{auth:!1},handler:{directory:{path:i.default.join(e,"../public/js")}}}),r.route({method:"GET",path:"/css/{file*}",config:{auth:!1},handler:{directory:{path:i.default.join(e,"../public/css")}}}),r.register([k.default,t,g.default],function(e){v.default.debug=function(){for(var e=arguments.length,n=Array(e),t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if(!e||"string"!=typeof e)throw new Error("Invalid template provided");return e.replace(v,function(e,t){return n[t]||""})};n.default=function(e){var n=e.stylesheetTag,t=e.customCSSTag,r=e.currentUser,o=e.matchingUsers,a=e.dynamicSettings;return u.default.all([(0,f.default)(a),(0,l.get)().read()]).then(function(e){var a=(0,i.default)(e,2),u=a[0],s=a[1],l=s.settings?s.settings.template:c.default;return m(l,{ExtensionCSS:n,CustomCSS:t,Auth0Widget:u,ExtensionScripts:(0,h.default)(r,o)})})}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(69),o=function(e){return e&&e.__esModule?e:{default:e}}(r);n.default=function(e){var n=e.stylesheetTag;return'\n\n\n\n \n \n \n \n Auth0 Account Linking Extension Administrator\n \n \n \n \n '+n+'\n\n\n\n\n\n
    \n
    \n
    \n
    \n
    \n\n
    \n \n

    Custom Hosted Page

    \n\n \n\n

    Widget Settings

    \n\n
    \n
    \n\n
    \n \n \n
    \n\n
    \n \n \n
    \n\n
    \n \n \n
    \n\n
    \n \n \n
    \n\n
    \n Remove widget\'s overlay\n
    \n\n \n \n
    \n\n\n - - + diff --git a/public/index.js b/public/index.js index e643ed5e..835c2335 100644 --- a/public/index.js +++ b/public/index.js @@ -2,11 +2,9 @@ // Ignoring this file since it has to be written in ES5 // and eslint is configured to lint ES6. -module.exports = function(currentUser, matchingUsers) { - var params = window.Qs.parse(window.location.search, { ignoreQueryPrefix: true }); - +module.exports = function(currentUser, matchingUsers, params, token) { try { - loadLinkPage(window.jwt_decode(params.child_token)); + loadLinkPage(token); } catch (e) { console.error(e); loadInvalidTokenPage(); @@ -125,4 +123,4 @@ module.exports = function(currentUser, matchingUsers) { return keys; } -} +} \ No newline at end of file diff --git a/templates/index.js b/templates/index.js index 88d5ae9a..0977706c 100644 --- a/templates/index.js +++ b/templates/index.js @@ -14,7 +14,7 @@ const render = (template, locals = {}) => { }; module.exports = ({ - stylesheetTag, customCSSTag, currentUser, matchingUsers, dynamicSettings, identities, locale + stylesheetTag, customCSSTag, currentUser, matchingUsers, dynamicSettings, identities, locale, params, token }) => Promise.all([buildAuth0Widget(dynamicSettings, identities, locale), getStorage().read()]) .then(([widget, data]) => { @@ -24,6 +24,6 @@ module.exports = ({ ExtensionCSS: stylesheetTag, CustomCSS: customCSSTag, Auth0Widget: widget, - ExtensionScripts: buildExtensionScripts(currentUser, matchingUsers) + ExtensionScripts: buildExtensionScripts(currentUser, matchingUsers, params, token) }); }); diff --git a/templates/utils/extensionScripts.js b/templates/utils/extensionScripts.js index d41f0097..57286800 100644 --- a/templates/utils/extensionScripts.js +++ b/templates/utils/extensionScripts.js @@ -1,13 +1,11 @@ const bootstrapApp = require('../../public/index'); -module.exports = (currentUser, matchingUsers) => ` - - +module.exports = (currentUser, matchingUsers, params, token) => ` -`; +`; \ No newline at end of file diff --git a/webtask.json b/webtask.json index f86161be..69e2a920 100644 --- a/webtask.json +++ b/webtask.json @@ -1,8 +1,8 @@ { "title": "Auth0 Account Link", "name": "auth0-account-link", - "version": "2.6.1", - "preVersion": "2.6.0", + "version": "2.6.2", + "preVersion": "2.6.1", "author": "auth0", "description": "This extension gives Auth0 customers the ability to allow their users to link their accounts", From acdf1ab0f53a2105f7155d21f08a2ed9ade9ac93 Mon Sep 17 00:00:00 2001 From: Luis Britos Manriquez Date: Thu, 28 Jan 2021 11:42:10 -0300 Subject: [PATCH 183/207] new bundle --- build/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/bundle.js b/build/bundle.js index bca64258..b0e5cd8e 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1 @@ -module.exports=function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.r=function(n){Object.defineProperty(n,"__esModule",{value:!0})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e.w={},e(e.s=0)}([function(n,t,e){"use strict";var r=e(1),o=e(2),i=e(10),a=e(5),s=r.createServer(function(n,t){return i.info("Starting Account Link Extension - Version:","2.5.0"),i.info(" > WT_URL:",n("WT_URL")),i.info(" > PUBLIC_WT_URL:",n("PUBLIC_WT_URL")),o(n,t)});n.exports=function(n,t,e){t.x_wt&&t.x_wt.ectx&&t.x_wt.ectx.PUBLIC_WT_URL||!1||a.setValue("PUBLIC_WT_URL",r.urlHelpers.getWebtaskUrl(t)),s(n,t,e)}},function(n,t){n.exports=require("auth0-extension-hapi-tools@1.3.1")},function(n,t,e){"use strict";(function(t){var r=e(3),o=e(4),i=o.FileStorageContext,a=o.WebtaskStorageContext,s=e(5),c=e(6),u=e(10),l=e(125).init,f=function(n){n?(u.error("Hapi initialization failed."),u.error(n)):u.info("Hapi initialization completed.")};n.exports=function(n,e,o){return s.setProvider(function(t){return n(t)||Object({NODE_ENV:"production",CLIENT_VERSION:"2.5.0"})[t]}),l(e?new a(e,{force:1}):new i(r.join(t,"../data.json"))),c(o||f)}}).call(this,"/")},function(n,t){n.exports=require("path")},function(n,t){n.exports=require("auth0-extension-tools@1.3.1")},function(n,t,e){"use strict";var r=e(4).config;n.exports=r()},function(n,t,e){"use strict";(function(t){var r=e(3),o=e(7),i=e(8),a=e(9),s=e(5),c=e(10),u=e(12),l=e(180),f=e(181);n.exports=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l,d=new o.Server;return d.connection({host:"localhost",port:s("PORT"),routes:{cors:!0,validate:{},files:{relativeTo:r.join(t,"../public")}}}),d.register([a,i],function(){}),d.route({method:"GET",path:"/js/{file*}",config:{auth:!1},handler:{directory:{path:r.join(t,"../public/js")}}}),d.route({method:"GET",path:"/css/{file*}",config:{auth:!1},handler:{directory:{path:r.join(t,"../public/css")}}}),d.register([f,e,u],function(t){c.debug=function(){for(var n=arguments.length,t=new Array(n),e=0;e0?r[0].identities:[]).map(function(n){return n.provider}).map(f),a=d(i,n("or"));t(c({dynamicSettings:y,stylesheetTag:m,currentUser:e,matchingUsers:r,customCSSTag:g,locale:o,identities:a}))})})}).catch(function(r){var o=n.query.state;u.error("An error was encountered: ",r),u.info(`Redirecting to failed link to /continue: ${e.iss}continue?state=${n.query.state}`),t.redirect(`${e.iss}continue?state=${o}`)})}).catch(function(n){u.error("An invalid token was provided",n),c({dynamicSettings:y,stylesheetTag:m,currentUser:null,matchingUsers:[],customCSSTag:g}).then(function(n){t(n).code(400)})})}}}}},function(n,t){n.exports=function(n){return n&&n.__esModule?n:{default:n}}},function(n,t,e){n.exports=e(16)},function(n,t,e){e(17),e(18),e(62),e(66),e(83),e(84),n.exports=e(26).Promise},function(n,t){},function(n,t,e){"use strict";var r=e(19)(!0);e(22)(String,"String",function(n){this._t=String(n),this._i=0},function(){var n,t=this._t,e=this._i;return e>=t.length?{value:void 0,done:!0}:(n=r(t,e),this._i+=n.length,{value:n,done:!1})})},function(n,t,e){var r=e(20),o=e(21);n.exports=function(n){return function(t,e){var i,a,s=String(o(t)),c=r(e),u=s.length;return c<0||c>=u?n?"":void 0:(i=s.charCodeAt(c))<55296||i>56319||c+1===u||(a=s.charCodeAt(c+1))<56320||a>57343?n?s.charAt(c):i:n?s.slice(c,c+2):a-56320+(i-55296<<10)+65536}}},function(n,t){var e=Math.ceil,r=Math.floor;n.exports=function(n){return isNaN(n=+n)?0:(n>0?r:e)(n)}},function(n,t){n.exports=function(n){if(void 0==n)throw TypeError("Can't call method on "+n);return n}},function(n,t,e){"use strict";var r=e(23),o=e(24),i=e(40),a=e(29),s=e(41),c=e(42),u=e(58),l=e(60),f=e(59)("iterator"),d=!([].keys&&"next"in[].keys()),p=function(){return this};n.exports=function(n,t,e,h,v,m,g){c(e,t,h);var y,b,x,w=function(n){if(!d&&n in S)return S[n];switch(n){case"keys":case"values":return function(){return new e(this,n)}}return function(){return new e(this,n)}},k=t+" Iterator",_="values"==v,L=!1,S=n.prototype,j=S[f]||S["@@iterator"]||v&&S[v],T=j||w(v),E=v?_?w("entries"):T:void 0,C="Array"==t&&S.entries||j;if(C&&(x=l(C.call(new n)))!==Object.prototype&&x.next&&(u(x,k,!0),r||"function"==typeof x[f]||a(x,f,p)),_&&j&&"values"!==j.name&&(L=!0,T=function(){return j.call(this)}),r&&!g||!d&&!L&&S[f]||a(S,f,T),s[t]=T,s[k]=p,v)if(y={values:_?T:w("values"),keys:m?T:w("keys"),entries:E},g)for(b in y)b in S||i(S,b,y[b]);else o(o.P+o.F*(d||L),t,y);return y}},function(n,t){n.exports=!0},function(n,t,e){var r=e(25),o=e(26),i=e(27),a=e(29),s=e(39),c=function(n,t,e){var u,l,f,d=n&c.F,p=n&c.G,h=n&c.S,v=n&c.P,m=n&c.B,g=n&c.W,y=p?o:o[t]||(o[t]={}),b=y.prototype,x=p?r:h?r[t]:(r[t]||{}).prototype;for(u in p&&(e=t),e)(l=!d&&x&&void 0!==x[u])&&s(y,u)||(f=l?x[u]:e[u],y[u]=p&&"function"!=typeof x[u]?e[u]:m&&l?i(f,r):g&&x[u]==f?function(n){var t=function(t,e,r){if(this instanceof n){switch(arguments.length){case 0:return new n;case 1:return new n(t);case 2:return new n(t,e)}return new n(t,e,r)}return n.apply(this,arguments)};return t.prototype=n.prototype,t}(f):v&&"function"==typeof f?i(Function.call,f):f,v&&((y.virtual||(y.virtual={}))[u]=f,n&c.R&&b&&!b[u]&&a(b,u,f)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,n.exports=c},function(n,t){var e=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(n,t){var e=n.exports={version:"2.5.5"};"number"==typeof __e&&(__e=e)},function(n,t,e){var r=e(28);n.exports=function(n,t,e){if(r(n),void 0===t)return n;switch(e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,o){return n.call(t,e,r,o)}}return function(){return n.apply(t,arguments)}}},function(n,t){n.exports=function(n){if("function"!=typeof n)throw TypeError(n+" is not a function!");return n}},function(n,t,e){var r=e(30),o=e(38);n.exports=e(34)?function(n,t,e){return r.f(n,t,o(1,e))}:function(n,t,e){return n[t]=e,n}},function(n,t,e){var r=e(31),o=e(33),i=e(37),a=Object.defineProperty;t.f=e(34)?Object.defineProperty:function(n,t,e){if(r(n),t=i(t,!0),r(e),o)try{return a(n,t,e)}catch(n){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(n[t]=e.value),n}},function(n,t,e){var r=e(32);n.exports=function(n){if(!r(n))throw TypeError(n+" is not an object!");return n}},function(n,t){n.exports=function(n){return"object"==typeof n?null!==n:"function"==typeof n}},function(n,t,e){n.exports=!e(34)&&!e(35)(function(){return 7!=Object.defineProperty(e(36)("div"),"a",{get:function(){return 7}}).a})},function(n,t,e){n.exports=!e(35)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(n,t){n.exports=function(n){try{return!!n()}catch(n){return!0}}},function(n,t,e){var r=e(32),o=e(25).document,i=r(o)&&r(o.createElement);n.exports=function(n){return i?o.createElement(n):{}}},function(n,t,e){var r=e(32);n.exports=function(n,t){if(!r(n))return n;var e,o;if(t&&"function"==typeof(e=n.toString)&&!r(o=e.call(n)))return o;if("function"==typeof(e=n.valueOf)&&!r(o=e.call(n)))return o;if(!t&&"function"==typeof(e=n.toString)&&!r(o=e.call(n)))return o;throw TypeError("Can't convert object to primitive value")}},function(n,t){n.exports=function(n,t){return{enumerable:!(1&n),configurable:!(2&n),writable:!(4&n),value:t}}},function(n,t){var e={}.hasOwnProperty;n.exports=function(n,t){return e.call(n,t)}},function(n,t,e){n.exports=e(29)},function(n,t){n.exports={}},function(n,t,e){"use strict";var r=e(43),o=e(38),i=e(58),a={};e(29)(a,e(59)("iterator"),function(){return this}),n.exports=function(n,t,e){n.prototype=r(a,{next:o(1,e)}),i(n,t+" Iterator")}},function(n,t,e){var r=e(31),o=e(44),i=e(56),a=e(53)("IE_PROTO"),s=function(){},c=function(){var n,t=e(36)("iframe"),r=i.length;for(t.style.display="none",e(57).appendChild(t),t.src="javascript:",(n=t.contentWindow.document).open(),n.write(" -`; \ No newline at end of file +`; From 9f9e6a31d7bd7aaa3b784b547404fb228c5ff832 Mon Sep 17 00:00:00 2001 From: "madhu.sharma" Date: Thu, 25 Mar 2021 13:32:38 -0500 Subject: [PATCH 185/207] fix: make custom css path absolute --- api/get_index.js | 2 +- lib/stylesheet.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/get_index.js b/api/get_index.js index 234293ac..15351939 100644 --- a/api/get_index.js +++ b/api/get_index.js @@ -40,7 +40,7 @@ module.exports = () => ({ } const stylesheetHelper = stylesheet(config('NODE_ENV') === 'production'); const stylesheetTag = stylesheetHelper.tag('link'); - const customCSSTag = stylesheetHelper.tag(config('CUSTOM_CSS')); + const customCSSTag = stylesheetHelper.tag(config('CUSTOM_CSS'), true); const params = req.query; const dynamicSettings = {}; diff --git a/lib/stylesheet.js b/lib/stylesheet.js index 8acb8347..26f6bfa1 100644 --- a/lib/stylesheet.js +++ b/lib/stylesheet.js @@ -7,14 +7,14 @@ const getBase = useCDN => (useCDN ? CDN_BASE : LOCAL_BASE); const generateHelper = (useCDN = false) => { const extension = useCDN ? `${version}.min.css` : 'css'; - const link = (filename) => { + const link = (filename, isAbsolute) => { const name = (filename || '').trim(); - + if (isAbsolute) return name; return name ? `${getBase(useCDN)}/${name}.${extension}` : ''; }; - const tag = (filename) => { - const href = link(filename); + const tag = (name, isAbsolute = false) => { + const href = link(name, isAbsolute); return href ? `` : ''; }; From 9800db25060f17d4e281472b21d7dea71bd191f2 Mon Sep 17 00:00:00 2001 From: "madhu.sharma" Date: Fri, 26 Mar 2021 16:18:22 -0500 Subject: [PATCH 186/207] add tests and change README --- README.md | 4 ++-- test/unit/stylesheet_test.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f971dc82..b0aab6ff 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,6 @@ yarn run build Bundle file (`auth0-account-link.extension.VERSION.js` is found in `/dist` Asset CSS files are found in `/dist/assets` -Before continuing, if you want to quickly test backend-only changes in your production tenant, you can use the webtask editor: https://github.com/auth0-extensions/auth0-webtask-editor-opener. Copy and paste the bundle file file contents into the tab that corresponds with the existing extension to override the backend code. +Before continuing, if you want to quickly test backend-only changes in your production tenant, follow https://auth0team.atlassian.net/wiki/spaces/USER/pages/1931838732/Testing+Dev+Build+of+Extension+with+Production+tenant -Follow the instructions in the deployment tool. This tool will also automatically generate a PR in the `auth0-extensions` repo. Only after the PR is merged will the extension be available in production. Before merging the PR you can use this tool to test the upgrade: https://github.com/auth0-extensions/auth0-extension-update-tester by overriding the `extensions.json` file that is fetched by the dashboard. You will need to clone this repo: https://github.com/auth0/auth0-extensions, update `extensions.json` locally and then run `npx http-server --port 3000 --cors` to serve up the file. Then configure the extension with `http://localhost:3000/extensions.json` as the path. \ No newline at end of file +Follow the instructions in the deployment tool. This tool will also automatically generate a PR in the `auth0-extensions` repo. Only after the PR is merged will the extension be available in production. Before merging the PR you can use this tool to test the upgrade: https://github.com/auth0-extensions/auth0-extension-update-tester by overriding the `extensions.json` file that is fetched by the dashboard. You will need to clone this repo: https://github.com/auth0/auth0-extensions, update `extensions.json` locally and then run `npx http-server --port 3000 --cors` to serve up the file. Then configure the extension with `http://localhost:3000/extensions.json` as the path. diff --git a/test/unit/stylesheet_test.js b/test/unit/stylesheet_test.js index cfdbb2b3..9f6a5ca2 100644 --- a/test/unit/stylesheet_test.js +++ b/test/unit/stylesheet_test.js @@ -23,6 +23,13 @@ describe('Stylesheet helper', () => { expect(result).to.be.empty; }); + it('with absolute URL', () => { + const { tag } = stylesheet(); + const result = tag('htps://custom.css', true); + + expect(result).to.equal('htps://custom.css'); + }); + describe('When using cdn', () => { const { tag } = stylesheet(true); @@ -37,5 +44,11 @@ describe('Stylesheet helper', () => { expect(result).to.match(/\/test\.\d+\.\d+\.\d+\.min\.css/); }); + + it('with absolute URL', () => { + const result = tag('htps://custom.css', true); + + expect(result).to.equal('htps://custom.css'); + }); }); }); From cbd7476c10e3a88b03c8993d77c97732ebb98414 Mon Sep 17 00:00:00 2001 From: "madhu.sharma" Date: Fri, 26 Mar 2021 16:28:45 -0500 Subject: [PATCH 187/207] fix test case --- test/unit/stylesheet_test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/stylesheet_test.js b/test/unit/stylesheet_test.js index 9f6a5ca2..7d5eddbb 100644 --- a/test/unit/stylesheet_test.js +++ b/test/unit/stylesheet_test.js @@ -27,7 +27,7 @@ describe('Stylesheet helper', () => { const { tag } = stylesheet(); const result = tag('htps://custom.css', true); - expect(result).to.equal('htps://custom.css'); + expect(result).to.equal(''); }); describe('When using cdn', () => { @@ -48,7 +48,7 @@ describe('Stylesheet helper', () => { it('with absolute URL', () => { const result = tag('htps://custom.css', true); - expect(result).to.equal('htps://custom.css'); + expect(result).to.equal(''); }); }); }); From e6c003cb7da5fef751762556b16e26242092a7fc Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 6 Apr 2021 14:18:20 -0500 Subject: [PATCH 188/207] Update test/unit/stylesheet_test.js Co-authored-by: Andre Paradis --- test/unit/stylesheet_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/stylesheet_test.js b/test/unit/stylesheet_test.js index 7d5eddbb..567ec2f2 100644 --- a/test/unit/stylesheet_test.js +++ b/test/unit/stylesheet_test.js @@ -27,7 +27,7 @@ describe('Stylesheet helper', () => { const { tag } = stylesheet(); const result = tag('htps://custom.css', true); - expect(result).to.equal(''); + expect(result).to.equal(''); }); describe('When using cdn', () => { From cc0fe21e19b3a001858b0d965f77d76619911a51 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 6 Apr 2021 14:18:26 -0500 Subject: [PATCH 189/207] Update test/unit/stylesheet_test.js Co-authored-by: Andre Paradis --- test/unit/stylesheet_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/stylesheet_test.js b/test/unit/stylesheet_test.js index 567ec2f2..6ec0bca2 100644 --- a/test/unit/stylesheet_test.js +++ b/test/unit/stylesheet_test.js @@ -48,7 +48,7 @@ describe('Stylesheet helper', () => { it('with absolute URL', () => { const result = tag('htps://custom.css', true); - expect(result).to.equal(''); + expect(result).to.equal(''); }); }); }); From 72b11fc28d42092c89e2e5112f3e2ecba2bd3637 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 6 Apr 2021 14:18:33 -0500 Subject: [PATCH 190/207] Update test/unit/stylesheet_test.js Co-authored-by: Andre Paradis --- test/unit/stylesheet_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/stylesheet_test.js b/test/unit/stylesheet_test.js index 6ec0bca2..f23234a8 100644 --- a/test/unit/stylesheet_test.js +++ b/test/unit/stylesheet_test.js @@ -25,7 +25,7 @@ describe('Stylesheet helper', () => { it('with absolute URL', () => { const { tag } = stylesheet(); - const result = tag('htps://custom.css', true); + const result = tag('https://custom.css', true); expect(result).to.equal(''); }); From 4e10226e64129802ccc71e5ccfd512128bf5d877 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 6 Apr 2021 14:20:24 -0500 Subject: [PATCH 191/207] Remove link to internal doc --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b0aab6ff..0c42c8bc 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,4 @@ yarn run build Bundle file (`auth0-account-link.extension.VERSION.js` is found in `/dist` Asset CSS files are found in `/dist/assets` -Before continuing, if you want to quickly test backend-only changes in your production tenant, follow https://auth0team.atlassian.net/wiki/spaces/USER/pages/1931838732/Testing+Dev+Build+of+Extension+with+Production+tenant - Follow the instructions in the deployment tool. This tool will also automatically generate a PR in the `auth0-extensions` repo. Only after the PR is merged will the extension be available in production. Before merging the PR you can use this tool to test the upgrade: https://github.com/auth0-extensions/auth0-extension-update-tester by overriding the `extensions.json` file that is fetched by the dashboard. You will need to clone this repo: https://github.com/auth0/auth0-extensions, update `extensions.json` locally and then run `npx http-server --port 3000 --cors` to serve up the file. Then configure the extension with `http://localhost:3000/extensions.json` as the path. From 48e021715a54089403494400b54ff7e4298d35f5 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 6 Apr 2021 14:23:14 -0500 Subject: [PATCH 192/207] fix test case --- test/unit/stylesheet_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/stylesheet_test.js b/test/unit/stylesheet_test.js index f23234a8..ea16e17e 100644 --- a/test/unit/stylesheet_test.js +++ b/test/unit/stylesheet_test.js @@ -46,7 +46,7 @@ describe('Stylesheet helper', () => { }); it('with absolute URL', () => { - const result = tag('htps://custom.css', true); + const result = tag('https://custom.css', true); expect(result).to.equal(''); }); From ed31bd3a2c0350b213f561011d69f0614a9cc876 Mon Sep 17 00:00:00 2001 From: "madhu.sharma" Date: Thu, 8 Apr 2021 08:56:45 -0500 Subject: [PATCH 193/207] release 2.6.3 --- build/bundle.js | 3 ++- package.json | 2 +- webtask.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/bundle.js b/build/bundle.js index b0e5cd8e..a5a38cfa 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1,2 @@ -module.exports=function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.r=function(n){Object.defineProperty(n,"__esModule",{value:!0})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e.w={},e(e.s=0)}([function(n,t,e){"use strict";var r=e(1),o=e(2),i=e(10),a=e(5),s=r.createServer(function(n,t){return i.info("Starting Account Link Extension - Version:","2.6.2"),i.info(" > WT_URL:",n("WT_URL")),i.info(" > PUBLIC_WT_URL:",n("PUBLIC_WT_URL")),o(n,t)});n.exports=function(n,t,e){t.x_wt&&t.x_wt.ectx&&t.x_wt.ectx.PUBLIC_WT_URL||!1||a.setValue("PUBLIC_WT_URL",r.urlHelpers.getWebtaskUrl(t)),s(n,t,e)}},function(n,t){n.exports=require("auth0-extension-hapi-tools@1.3.1")},function(n,t,e){"use strict";(function(t){var r=e(3),o=e(4),i=o.FileStorageContext,a=o.WebtaskStorageContext,s=e(5),c=e(6),u=e(10),l=e(125).init,f=function(n){n?(u.error("Hapi initialization failed."),u.error(n)):u.info("Hapi initialization completed.")};n.exports=function(n,e,o){return s.setProvider(function(t){return n(t)||Object({NODE_ENV:"production",CLIENT_VERSION:"2.6.2"})[t]}),l(e?new a(e,{force:1}):new i(r.join(t,"../data.json"))),c(o||f)}}).call(this,"/")},function(n,t){n.exports=require("path")},function(n,t){n.exports=require("auth0-extension-tools@1.3.1")},function(n,t,e){"use strict";var r=e(4).config;n.exports=r()},function(n,t,e){"use strict";(function(t){var r=e(3),o=e(7),i=e(8),a=e(9),s=e(5),c=e(10),u=e(12),l=e(180),f=e(181);n.exports=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l,d=new o.Server;return d.connection({host:"localhost",port:s("PORT"),routes:{cors:!0,validate:{},files:{relativeTo:r.join(t,"../public")}}}),d.register([a,i],function(){}),d.route({method:"GET",path:"/js/{file*}",config:{auth:!1},handler:{directory:{path:r.join(t,"../public/js")}}}),d.route({method:"GET",path:"/css/{file*}",config:{auth:!1},handler:{directory:{path:r.join(t,"../public/css")}}}),d.register([f,e,u],function(t){c.debug=function(){for(var n=arguments.length,t=new Array(n),e=0;e0?[o[0].identities[0]]:[]).map(function(n){return n.provider}).map(f),s=d(i,n("or"));t(c({dynamicSettings:b,stylesheetTag:m,currentUser:r,matchingUsers:o,customCSSTag:g,locale:a,identities:s,params:y,token:e}))})})}).catch(function(r){var o=n.query.state;u.error("An error was encountered: ",r),u.info(`Redirecting to failed link to /continue: ${e.iss}continue?state=${n.query.state}`),t.redirect(`${e.iss}continue?state=${o}`)})}).catch(function(n){u.error("An invalid token was provided",n),c({dynamicSettings:b,stylesheetTag:m,currentUser:null,matchingUsers:[],customCSSTag:g}).then(function(n){t(n).code(400)})})}}}}},function(n,t){n.exports=function(n){return n&&n.__esModule?n:{default:n}}},function(n,t,e){n.exports=e(16)},function(n,t,e){e(17),e(18),e(62),e(66),e(83),e(84),n.exports=e(26).Promise},function(n,t){},function(n,t,e){"use strict";var r=e(19)(!0);e(22)(String,"String",function(n){this._t=String(n),this._i=0},function(){var n,t=this._t,e=this._i;return e>=t.length?{value:void 0,done:!0}:(n=r(t,e),this._i+=n.length,{value:n,done:!1})})},function(n,t,e){var r=e(20),o=e(21);n.exports=function(n){return function(t,e){var i,a,s=String(o(t)),c=r(e),u=s.length;return c<0||c>=u?n?"":void 0:(i=s.charCodeAt(c))<55296||i>56319||c+1===u||(a=s.charCodeAt(c+1))<56320||a>57343?n?s.charAt(c):i:n?s.slice(c,c+2):a-56320+(i-55296<<10)+65536}}},function(n,t){var e=Math.ceil,r=Math.floor;n.exports=function(n){return isNaN(n=+n)?0:(n>0?r:e)(n)}},function(n,t){n.exports=function(n){if(void 0==n)throw TypeError("Can't call method on "+n);return n}},function(n,t,e){"use strict";var r=e(23),o=e(24),i=e(40),a=e(29),s=e(41),c=e(42),u=e(58),l=e(60),f=e(59)("iterator"),d=!([].keys&&"next"in[].keys()),p=function(){return this};n.exports=function(n,t,e,h,v,m,g){c(e,t,h);var y,b,x,w=function(n){if(!d&&n in S)return S[n];switch(n){case"keys":case"values":return function(){return new e(this,n)}}return function(){return new e(this,n)}},k=t+" Iterator",_="values"==v,L=!1,S=n.prototype,T=S[f]||S["@@iterator"]||v&&S[v],j=T||w(v),E=v?_?w("entries"):j:void 0,C="Array"==t&&S.entries||T;if(C&&(x=l(C.call(new n)))!==Object.prototype&&x.next&&(u(x,k,!0),r||"function"==typeof x[f]||a(x,f,p)),_&&T&&"values"!==T.name&&(L=!0,j=function(){return T.call(this)}),r&&!g||!d&&!L&&S[f]||a(S,f,j),s[t]=j,s[k]=p,v)if(y={values:_?j:w("values"),keys:m?j:w("keys"),entries:E},g)for(b in y)b in S||i(S,b,y[b]);else o(o.P+o.F*(d||L),t,y);return y}},function(n,t){n.exports=!0},function(n,t,e){var r=e(25),o=e(26),i=e(27),a=e(29),s=e(39),c=function(n,t,e){var u,l,f,d=n&c.F,p=n&c.G,h=n&c.S,v=n&c.P,m=n&c.B,g=n&c.W,y=p?o:o[t]||(o[t]={}),b=y.prototype,x=p?r:h?r[t]:(r[t]||{}).prototype;for(u in p&&(e=t),e)(l=!d&&x&&void 0!==x[u])&&s(y,u)||(f=l?x[u]:e[u],y[u]=p&&"function"!=typeof x[u]?e[u]:m&&l?i(f,r):g&&x[u]==f?function(n){var t=function(t,e,r){if(this instanceof n){switch(arguments.length){case 0:return new n;case 1:return new n(t);case 2:return new n(t,e)}return new n(t,e,r)}return n.apply(this,arguments)};return t.prototype=n.prototype,t}(f):v&&"function"==typeof f?i(Function.call,f):f,v&&((y.virtual||(y.virtual={}))[u]=f,n&c.R&&b&&!b[u]&&a(b,u,f)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,n.exports=c},function(n,t){var e=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(n,t){var e=n.exports={version:"2.5.5"};"number"==typeof __e&&(__e=e)},function(n,t,e){var r=e(28);n.exports=function(n,t,e){if(r(n),void 0===t)return n;switch(e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,o){return n.call(t,e,r,o)}}return function(){return n.apply(t,arguments)}}},function(n,t){n.exports=function(n){if("function"!=typeof n)throw TypeError(n+" is not a function!");return n}},function(n,t,e){var r=e(30),o=e(38);n.exports=e(34)?function(n,t,e){return r.f(n,t,o(1,e))}:function(n,t,e){return n[t]=e,n}},function(n,t,e){var r=e(31),o=e(33),i=e(37),a=Object.defineProperty;t.f=e(34)?Object.defineProperty:function(n,t,e){if(r(n),t=i(t,!0),r(e),o)try{return a(n,t,e)}catch(n){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(n[t]=e.value),n}},function(n,t,e){var r=e(32);n.exports=function(n){if(!r(n))throw TypeError(n+" is not an object!");return n}},function(n,t){n.exports=function(n){return"object"==typeof n?null!==n:"function"==typeof n}},function(n,t,e){n.exports=!e(34)&&!e(35)(function(){return 7!=Object.defineProperty(e(36)("div"),"a",{get:function(){return 7}}).a})},function(n,t,e){n.exports=!e(35)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(n,t){n.exports=function(n){try{return!!n()}catch(n){return!0}}},function(n,t,e){var r=e(32),o=e(25).document,i=r(o)&&r(o.createElement);n.exports=function(n){return i?o.createElement(n):{}}},function(n,t,e){var r=e(32);n.exports=function(n,t){if(!r(n))return n;var e,o;if(t&&"function"==typeof(e=n.toString)&&!r(o=e.call(n)))return o;if("function"==typeof(e=n.valueOf)&&!r(o=e.call(n)))return o;if(!t&&"function"==typeof(e=n.toString)&&!r(o=e.call(n)))return o;throw TypeError("Can't convert object to primitive value")}},function(n,t){n.exports=function(n,t){return{enumerable:!(1&n),configurable:!(2&n),writable:!(4&n),value:t}}},function(n,t){var e={}.hasOwnProperty;n.exports=function(n,t){return e.call(n,t)}},function(n,t,e){n.exports=e(29)},function(n,t){n.exports={}},function(n,t,e){"use strict";var r=e(43),o=e(38),i=e(58),a={};e(29)(a,e(59)("iterator"),function(){return this}),n.exports=function(n,t,e){n.prototype=r(a,{next:o(1,e)}),i(n,t+" Iterator")}},function(n,t,e){var r=e(31),o=e(44),i=e(56),a=e(53)("IE_PROTO"),s=function(){},c=function(){var n,t=e(36)("iframe"),r=i.length;for(t.style.display="none",e(57).appendChild(t),t.src="javascript:",(n=t.contentWindow.document).open(),n.write("