diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..38c5ab0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## [2.1.0] - 2018-09-19 + +- Update `mixpanel` dependency to version 0.9.2 \ No newline at end of file diff --git a/build/bundle.js b/build/bundle.js index 69a4ff0..e650f80 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -1 +1 @@ -module.exports=function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=22)}([function(e,t){e.exports=require("auth0-extension-tools@1.3.1")},function(e,t,n){"use strict";e.exports=n(0).config()},function(e,t){e.exports=require("auth0-extension-express-tools@1.1.6")},function(e,t,n){"use strict";var o=n(33);o.emitErrs=!0;var i=new o.Logger({transports:[new o.transports.Console({timestamp:!0,level:"debug",handleExceptions:!0,json:!1,colorize:!0})],exitOnError:!1});e.exports=i,e.exports.stream={write:function(e){i.info(e.replace(/\n$/,""))}}},function(e,t){e.exports=require("express@4.12.4")},function(e,t){e.exports=require("lodash@3.10.1")},function(e,t,n){function o(e){if(null===e||void 0===e)throw new c.ArgumentError("Must provide an options object");if(null===e.domain||void 0===e.domain)throw new c.ArgumentError("Must provide a valid domain");if("string"!=typeof e.domain||0===e.domain.length)throw new c.ArgumentError("The provided domain is invalid: "+e.domain);if(null===e.clientId||void 0===e.clientId)throw new c.ArgumentError("Must provide a valid clientId");if("string"!=typeof e.clientId||0===e.clientId.length)throw new c.ArgumentError("The provided clientId is invalid: "+e.clientId);if(null===e.clientSecret||void 0===e.clientSecret)throw new c.ArgumentError("Must provide a valid clientSecret");if("string"!=typeof e.clientSecret||0===e.clientSecret.length)throw new c.ArgumentError("The provided clientSecret is invalid: "+e.clientSecret);this.options=e,this.tokenCache=e.tokenCache||{getToken:function(){return i.resolve()},setToken:function(){return i.resolve()}}}const i=n(9),s=n(11),r=n(30),c=n(0);o.prototype.getAccessToken=function(){var e=this;return new i(function(t,n){s.post("https://"+e.options.domain+"/oauth/token").send({audience:"https://"+e.options.domain+"/api/v2/",client_id:e.options.clientId,client_secret:e.options.clientSecret,grant_type:"client_credentials"}).set("Accept","application/json").end(function(o,i){if(o&&401===o.status)return n(new c.ManagementApiError("unauthorized","Invalid credentials for "+e.options.clientId,o.status));if(o&&i&&i.body&&i.body.error)return n(new c.ManagementApiError(i.body.error,i.body.error_description||i.body.error,o.status));if(o)return n(o);if(!i.ok||!i.body.access_token)return n(new c.ManagementApiError("unknown_error","Unknown error from Management API or no access_token was provided: "+(i.text||i.status)));const s=new Date;return t({token:i.body.access_token,expiresAt:s.setSeconds(s.getSeconds()+i.body.expires_in)})})})},o.prototype.getAccessTokenCached=function(){var e=this;return e.tokenCache.getToken().then(function(t){if(t&&t.token){const n=(new Date).valueOf();if(t.expiresAt-n>1e4)return t}return e.getAccessToken(e.options).then(function(t){return e.tokenCache.setToken(t).then(function(){return t})})})},o.prototype.getLogs=function(e){const t=this;return new i(function(n,o){t.getAccessTokenCached(t.options,t.storage).then(function(i){const a=r.stringify(e);s.get("https://"+t.options.domain+"/api/v2/logs?"+a).set("Authorization","Bearer "+i.token).set("Content-Type","application/json").end(function(e,i){if(e&&403===e.status){const s=function(){return o(new c.ManagementApiError(i.body.error,i.body.error_description||i.body.error,e.status))};t.tokenCache.setToken(null).then(s).catch(s)}return e&&i&&i.body&&i.body.error?o(new c.ManagementApiError(i.body.error,i.body.error_description||i.body.error,e.status)):e?o(e):i.ok?n({logs:i.body,limits:{limit:i.headers["x-ratelimit-limit"],remaining:i.headers["x-ratelimit-remaining"],reset:i.headers["x-ratelimit-reset"]}}):o(new c.ManagementApiError("unknown_error","Unknown error from Management API: "+(i.text||i.status)))})})})},e.exports=o},function(e,t){const n={success:"success",error:"error",warning:"warning"},o={s:{name:"Success Login",icon:"icon-budicon-448",severity:n.success,level:1},ssa:{name:"Success Silent Auth",icon:"icon-budicon-448",severity:n.success,level:1},fsa:{name:"Failed Silent Auth",icon:"icon-budicon-448",severity:n.error,level:3},seacft:{name:"Success Exchange",description:"Authorization Code for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},feacft:{name:"Failed Exchange",description:"Authorization Code for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},seccft:{name:"Success Exchange",description:"Client Credentials for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},feccft:{name:"Failed Exchange",description:"Client Credentials for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},sepft:{name:"Success Exchange",description:"Password for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},fepft:{name:"Failed Exchange",description:"Password for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},sertft:{name:"Success Exchange",description:"Refresh Token for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},fertft:{name:"Failed Exchange",description:"Refresh Token for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},seoobft:{name:"Success Exchange",description:"Password and OOB Challenge for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},feoobft:{name:"Failed Exchange",description:"Password and OOB Challenge for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},seotpft:{name:"Success Exchange",description:"Password and OTP Challenge for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},feotpft:{name:"Failed Exchange",description:"Password and OTP Challenge for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},sercft:{name:"Success Exchange",description:"Password and MFA Recovery code for Access Token",icon:"icon-budicon-456",severity:n.success,level:1},fercft:{name:"Failed Exchange",description:"Password and MFA Recovery code for Access Token",icon:"icon-budicon-456",severity:n.error,level:3},f:{name:"Failed Login",icon:"icon-budicon-448",severity:n.error,level:3},w:{name:"Warning",icon:"icon-budicon-354",severity:n.warning,level:2},depnote:{name:"Deprecation Notice",icon:"icon-budicon-354",severity:n.warning,level:2},du:{name:"Deleted User",icon:"icon-budicon-311",severity:n.error,level:3},fu:{name:"Failed Login (invalid email/username)",icon:"icon-budicon-311",severity:n.error,level:3},fp:{name:"Failed Login (wrong password)",icon:"icon-budicon-311",severity:n.error,level:3},fc:{name:"Failed by Connector",icon:"icon-budicon-313",severity:n.error,level:3},fco:{name:"Failed by CORS",icon:"icon-budicon-313",severity:n.error,level:3},con:{name:"Connector Online",icon:"icon-budicon-143",severity:n.success,level:1},coff:{name:"Connector Offline",icon:"icon-budicon-143",severity:n.error,level:3},fcpro:{name:"Failed Connector Provisioning",icon:"icon-budicon-143",severity:n.error,level:4},ss:{name:"Success Signup",icon:"icon-budicon-314",severity:n.success,level:1},fs:{name:"Failed Signup",icon:"icon-budicon-311",severity:n.error,level:3},cs:{name:"Code Sent",icon:"icon-budicon-243",severity:n.success,level:1},cls:{name:"Code/Link Sent",icon:"icon-budicon-781",severity:n.success,level:1},sv:{name:"Success Verification Email",icon:"icon-budicon-781",severity:n.success,level:1},fv:{name:"Failed Verification Email",icon:"icon-budicon-311",severity:n.error,level:3},scp:{name:"Success Change Password",icon:"icon-budicon-280",severity:n.success,level:1},fcp:{name:"Failed Change Password",icon:"icon-budicon-266",severity:n.error,level:3},scph:{name:"Success Post Change Password Hook",icon:"icon-budicon-280",severity:n.success,level:1},fcph:{name:"Failed Post Change Password Hook",icon:"icon-budicon-266",severity:n.error,level:3},sce:{name:"Success Change Email",icon:"icon-budicon-266",severity:n.success,level:1},fce:{name:"Failed Change Email",icon:"icon-budicon-266",severity:n.error,level:3},scu:{name:"Success Change Username",icon:"icon-budicon-266",severity:n.success,level:1},fcu:{name:"Failed Change Username",icon:"icon-budicon-266",severity:n.error,level:3},scpn:{name:"Success Change Phone Number",icon:"icon-budicon-266",severity:n.success,level:1},fcpn:{name:"Failed Change Phone Number",icon:"icon-budicon-266",severity:n.error,level:3},svr:{name:"Success Verification Email Request",icon:"icon-budicon-781",severity:n.success,level:1},fvr:{name:"Failed Verification Email Request",icon:"icon-budicon-311",severity:n.error,level:3},scpr:{name:"Success Change Password Request",icon:"icon-budicon-280",severity:n.success,level:1},fcpr:{name:"Failed Change Password Request",icon:"icon-budicon-311",severity:n.error,level:3},fn:{name:"Failed Sending Notification",icon:"icon-budicon-782",severity:n.error,level:3},sapi:{name:"API Operation",icon:"icon-budicon-546",severity:n.success,level:1,category:"api"},fapi:{name:"Failed API Operation",icon:"icon-budicon-546",severity:n.error,level:3,category:"api"},limit_wc:{name:"Blocked Account",icon:"icon-budicon-313",severity:n.error,level:4},limit_mu:{name:"Blocked IP Address",icon:"icon-budicon-313",severity:n.error,level:4},limit_ui:{name:"Too Many Calls to /userinfo",icon:"icon-budicon-313",severity:n.error,level:4},api_limit:{name:"Rate Limit On API",icon:"icon-budicon-313",severity:n.error,level:4},limit_delegation:{name:"Too Many Calls to /delegation",icon:"icon-budicon-313",severity:n.error,level:4},sdu:{name:"Successful User Deletion",icon:"icon-budicon-312",severity:n.success,level:1},fdu:{name:"Failed User Deletion",icon:"icon-budicon-311",severity:n.error,level:3},admin_update_launch:{name:"Auth0 Update Launched",icon:"icon-budicon-774",severity:n.success,level:1},sys_os_update_start:{name:"Auth0 OS Update Started",icon:"icon-budicon-661",severity:n.success,level:1},sys_os_update_end:{name:"Auth0 OS Update Ended",icon:"icon-budicon-661",severity:n.success,level:1},sys_update_start:{name:"Auth0 Update Started",icon:"icon-budicon-661",severity:n.success,level:1},sys_update_end:{name:"Auth0 Update Ended",icon:"icon-budicon-661",severity:n.success,level:1},slo:{name:"Success Logout",icon:"icon-budicon-449",severity:n.success,level:1},flo:{name:"Failed Logout",icon:"icon-budicon-449",severity:n.error,level:3},sd:{name:"Success Delegation",icon:"icon-budicon-456",severity:n.success,level:1},fd:{name:"Failed Delegation",icon:"icon-budicon-456",severity:n.error,level:3},gd_unenroll:{name:"Unenroll device account",icon:"icon-budicon-298",severity:n.success,level:1},gd_update_device_account:{name:"Update device account",icon:"icon-budicon-257",severity:n.success,level:1},gd_module_switch:{name:"Module switch",icon:"icon-budicon-329",severity:n.success,level:1},gd_tenant_update:{name:"Guardian tenant update",icon:"icon-budicon-170",severity:n.success,level:1},gd_start_auth:{name:"Second factor started",icon:"icon-budicon-285",severity:n.success,level:1},gd_start_enroll:{name:"Enroll started",icon:"icon-budicon-299",severity:n.success,level:1},gd_start_enroll_failed:{name:"MFA Enrollment start failed",icon:"icon-budicon-299",severity:n.error,level:3},gd_user_delete:{name:"User delete",icon:"icon-budicon-298",severity:n.success,level:1},gd_auth_succeed:{name:"OTP Auth suceed",icon:"icon-budicon-mfa-login-succeed",severity:n.success,level:1},gd_auth_failed:{name:"OTP Auth failed",icon:"icon-budicon-mfa-login-failed",severity:n.error,level:3},gd_send_pn:{name:"Push notification sent",icon:"icon-budicon-mfa-send-pn",severity:n.success,level:1},gd_send_pn_failure:{name:"Error sending MFA Push Notification",icon:"icon-budicon-mfa-send-pn",severity:n.error,level:3},gd_auth_rejected:{name:"OTP Auth rejected",icon:"icon-budicon-mfa-login-failed",severity:n.error,level:3},gd_recovery_succeed:{name:"Recovery succeed",icon:"icon-budicon-mfa-recovery-succeed",severity:n.success,level:1},gd_recovery_failed:{name:"Recovery failed",icon:"icon-budicon-mfa-recovery-failed",severity:n.error,level:3},gd_send_sms:{name:"SMS Sent",icon:"icon-budicon-799",severity:n.success,level:1},gd_send_sms_failure:{name:"Error sending MFA SMS",icon:"icon-budicon-799",severity:n.error,level:3},gd_otp_rate_limit_exceed:{name:"Too many failures",icon:"icon-budicon-435",severity:n.warning,level:2},gd_recovery_rate_limit_exceed:{name:"Too many failures",icon:"icon-budicon-435",severity:n.warning,level:2},gd_enrollment_complete:{name:"Guardian enrollment complete",icon:"icon-budicon-299",severity:n.success,level:1},fui:{name:"Users import",icon:"icon-budicon-299",severity:n.warning,level:2},sui:{name:"Users import",icon:"icon-budicon-299",severity:n.success,level:1},pwd_leak:{name:"Breached password",icon:"icon-budicon-313",severity:n.error,level:3},fcoa:{name:"Failed cross origin authentication",icon:"icon-budicon-448",severity:n.error,level:3},scoa:{name:"Success cross origin authentication",icon:"icon-budicon-448",severity:n.success,level:1},ublkdu:{name:"Account unblocked",icon:"icon-budicon-313",severity:n.success,level:1}};e.exports=o,e.exports.get=function(e){return o[e]&&o[e].name||"Unknown Log Type: "+e}},function(e,t,n){function o(e){if(null===e||void 0===e)throw new r.ArgumentError("Must provide an options object");s.call(this,{objectMode:!0}),this.client=new c(e),this.options=e,this.remaining=50,this.lastBatch=0,this.previousCheckpoint=e.checkpointId||null,this.lastCheckpoint=e.checkpointId||null,this.status={start:new Date,end:null,logsProcessed:0}}const i=n(32),s=n(31).Readable,r=n(0),c=n(6);i.inherits(o,s),o.prototype.getQuery=function(e){return e&&e.length?"type:"+e.join(" OR type:"):""},o.prototype.done=function(){this.status.end=new Date,this.push(null)},o.prototype.next=function(e){const t=this,n=t.options.types&&t.options.types.length?100:e;if(t.remaining<1)t.status.warning="Auth0 Management API rate limit reached.",t.done();else{const o=t.lastCheckpoint?{take:n,from:t.lastCheckpoint}:{per_page:n,page:0};o.q=t.getQuery(t.options.types),o.sort="date:1",t.client.getLogs(o).then(function(n){const o=n.logs;if(t.remaining=n.limits.remaining,o&&o.length){var i=o;t.options.types&&t.options.types.length&&(i=o.filter(function(e){return t.options.types.indexOf(e.type)>=0}).slice(0,e||100)),i.length?(t.lastCheckpoint=i[i.length-1]._id,t.lastBatch+=i.length,t.push({logs:i,limits:n.limits})):(t.lastCheckpoint=o[o.length-1]._id,t.lastBatch+=0,t.push({logs:[],limits:n.limits}))}else t.status.end=new Date,t.push(null);return o}).catch(function(e){t.emit("error",e)})}},o.prototype.batchSaved=function(){this.status.logsProcessed+=this.lastBatch,this.previousCheckpoint=this.lastCheckpoint,this.lastBatch=0},o.prototype._read=function(){},e.exports=o},function(e,t){e.exports=require("bluebird@3.4.6")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("superagent@1.2.0")},function(e,t,n){"use strict";(function(t){var o=n(10),i=n(29),s=n(4),r=n(24),c=n(0),a=n(2),l=n(20),u=n(21),d=n(18),p=n(3),f=n(1),g=n(17);e.exports=function(e,n){f.setProvider(e);var v=n?new c.WebtaskStorageContext(n,{force:1}):new c.FileStorageContext(o.join(t,"./data.json"),{mergeWrites:!0}),h=new s;h.use(i(":method :url :status :response-time ms - :res[content-length]",{stream:p.stream}));var m=function(e){return function(t,n,o){return t.webtaskContext&&t.webtaskContext.body?(t.body=t.webtaskContext.body,o()):e(t,n,o)}};return h.use(m(r.json())),h.use(m(r.urlencoded({extended:!1}))),h.use(a.routes.dashboardAdmins({secret:f("EXTENSION_SECRET"),audience:"urn:logs-to-mixpanel",domain:f("AUTH0_DOMAIN"),rta:f("AUTH0_RTA").replace("https://",""),baseUrl:f("PUBLIC_WT_URL")||f("WT_URL"),clientName:"Logs to Mixpanel",urlPrefix:"",sessionStorageKey:"logs-to-mixpanel:apiToken"})),h.use("/meta",u()),h.use("/.extensions",d()),h.use("/app",s.static(o.join(t,"../dist"))),h.use(g(v)),h.use("/",l(v)),h.use(a.middlewares.errorHandler(p.error.bind(p))),h}}).call(t,"/")},function(e,t,n){const o=n(15);e.exports.LogsProcessor=n(14),e.exports.LogsApiClient=n(6),e.exports.LogsApiStream=n(8),e.exports.logTypes=n(7),e.exports.reporters={SlackReporter:o}},function(e,t,n){function o(e,t){if(null===t||void 0===t)throw new s.ArgumentError("Must provide an options object");this.storage=new a(e),this.options=i.assign({},{batchSize:100,maxRetries:5,maxRunTimeSeconds:20},t)}const i=n(5),s=n(0),r=n(7),c=n(8),a=n(16);o.prototype.hasTimeLeft=function(e){const t=(new Date).getTime();return e+1e3*this.options.maxRunTimeSeconds>=t},o.prototype.getLogFilter=function(e){var t=e.logTypes||[];if(e.logLevel){const n=i.map(r,function(e,t){const n=e;return n.type=t,n});t=t.concat(i.map(i.filter(n,function(t){return t.level>=e.logLevel}),"type"))}return i.uniq(t)},o.prototype.getReport=function(e,t){const n=new Date(e).getTime(),o=t?new Date(t).getTime():(new Date).getTime();return this.storage.read().then(function(e){return i.filter(e.logs,function(e){const t=new Date(e.start).getTime(),i=new Date(e.end).getTime();return t>=n&&i<=o})}).then(function(e){const t={type:"report",processed:0,warnings:0,errors:0,checkpoint:""};return i.each(e,function(e){t.processed+=e.logsProcessed,t.checkpoint=e.checkpoint,e.error&&(t.errors+=1),e.warning&&(t.warnings+=1)}),t})},o.prototype.createStream=function(e){const t=this;return t.storage.getCheckpoint(e.startFrom).then(function(n){return e.logger&&e.logger.debug("Starting logs processor from checkpoint:",n),new c({checkpointId:n,types:t.getLogFilter(e),domain:e.domain,clientId:e.clientId,clientSecret:e.clientSecret,tokenCache:t.storage})})},o.prototype.run=function(e){const t=this;return new Promise(function(n,o){const i=(new Date).getTime();var s=0,r=0,c=[];const a=t.storage,l=t.options,u=l.batchSize,d=l.maxRetries,p=function(e,t,i){l.logger&&l.logger.debug("Processor failed:",e),t.error=e,a.done(t,i).then(function(){return n({status:t,checkpoint:i})}).catch(o)},f=function(e,t){if(l.logger&&l.logger.debug("Processor run complete. Logs processed:",e.logsProcessed),e.logsProcessed>0){return(new Date).getTime()-r>=6048e5&&(e.warning="Logs are outdated more than for week. Last processed log has date is "+new Date(r)),a.done(e,t).then(function(){return n({status:e,checkpoint:t})}).catch(o)}return n({status:e,checkpoint:t})},g=function(){var e=u;return e-=c.length,e>100&&(e=100),e},v=function(n,o,r){if(!t.hasTimeLeft(i))return p(n,o.status,o.previousCheckpoint);if(s)":null,l=c.fields;return t.error&&l.push(c.error_field),o.attachments.push({color:t.error?"#d13f42":"#7cd197",fallback:c.fallback,text:c.fallback+(a||""),fields:l}),o},e.exports=o},function(e,t,n){function o(e,t){if(!e)throw new s("The storageContext is required");this.storageContext=e,this.options=i({},{limit:400},t)}const i=n(5).assign,s=n(0).ArgumentError;o.prototype.read=function(){return this.storageContext.read().then(function(e){const t=e||{};return t.logs=t.logs||[],t})},o.prototype.write=function(e){return this.storageContext.write(e)},o.prototype.getCheckpoint=function(e){const t=this;return t.read().then(function(n){return e&&e!==n.startFrom?(n.startFrom=e,n.checkpointId=e,t.write(n).then(function(){return n.checkpointId||e||null})):n.checkpointId})},o.prototype.getToken=function(){return this.read().then(function(e){return e.logs_access_token||null})},o.prototype.setToken=function(e){const t=this;return t.read().then(function(n){return n.logs_access_token=e,t.write(n)})},o.prototype.done=function(e,t){const n=this;return n.read().then(function(o){return Buffer.byteLength(JSON.stringify(o),"utf8")>=1024*n.options.limit&&o.logs&&o.logs.length&&o.logs.splice(0,5),e.checkpoint=t,o.logs.push(e),o.checkpointId=t,n.write(o)})},e.exports=o},function(e,t,n){"use strict";var o=n(28),i=n(27),s=n(13),r=n(1),c=n(3);e.exports=function(e){return function(t,n,a){var l=t.webtaskContext&&t.webtaskContext.body||t.body||{},u=t.webtaskContext&&t.webtaskContext.headers||{};if(!(l.schedule&&"active"===l.state||u.referer===r("AUTH0_MANAGE_URL")+"/"&&u["if-none-match"]))return a();var d=function(e){return e.map(function(e){return{name:e.name,message:e.message,stack:e.stack}})},p=i.init(r("MIXPANEL_TOKEN"),{key:r("MIXPANEL_KEY")}),f=function e(t,n){t&&t.length||n(),p.import_batch(t,function(o){if(o&&o.length>0){if(t.length>10){var i=t.splice(0,10);return p.import_batch(i,function(o){return o&&o.length>0?(c.error(o),n(d(o))):(c.info(i.length+" events successfully sent to mixpanel."),e(t,n))})}return c.error(o),n(d(o))}return c.info(t.length+" events successfully sent to mixpanel."),n()})},g=function(e,t){if(!e||!e.length)return t();c.info(e.length+" logs received.");var n=Date.now(),o=e.map(function(e){var t=s.logTypes.get(e.type);return e.time=n,e.distinct_id=e.user_id||e.user_name||e.client_id||e._id,{event:t,properties:e}});return f(o,t)},v=new s.reporters.SlackReporter({hook:r("SLACK_INCOMING_WEBHOOK_URL"),username:"auth0-logs-to-mixpanel",title:"Logs To Mixpanel"}),h={domain:r("AUTH0_DOMAIN"),clientId:r("AUTH0_CLIENT_ID"),clientSecret:r("AUTH0_CLIENT_SECRET"),batchSize:r("BATCH_SIZE"),startFrom:r("START_FROM"),logTypes:r("LOG_TYPES"),logLevel:r("LOG_LEVEL")};(!h.batchSize||h.batchSize>20)&&(h.batchSize=20),h.logTypes&&!Array.isArray(h.logTypes)&&(h.logTypes=h.logTypes.replace(/\s/g,"").split(","));var m=new s.LogsProcessor(e,h),y=function(t){var n=new Date,o=n.getTime(),i=o-864e5;m.getReport(i,o).then(function(e){return v.send(e,e.checkpoint)}).then(function(){return e.read()}).then(function(n){return n.lastReportDate=t,e.write(n)})},x=function(){e.read().then(function(e){var t=o().format("DD-MM-YYYY"),n=r("DAILY_REPORT_TIME")||16;e.lastReportDate!==t&&(new Date).getHours()>=n&&y(t)})};return m.run(g).then(function(e){e&&e.status&&e.status.error?v.send(e.status,e.checkpoint):!0!==r("SLACK_SEND_SUCCESS")&&"true"!==r("SLACK_SEND_SUCCESS")||v.send(e.status,e.checkpoint),x(),n.json(e)}).catch(function(e){v.send({error:e,logsProcessed:0},null),x(),a(e)})}}},function(e,t,n){"use strict";var o=n(4).Router,i=n(0),s=n(2).middlewares,r=n(1),c=n(3);e.exports=function(){var e=o(),t=s.validateHookToken(r("AUTH0_DOMAIN"),r("WT_URL"),r("EXTENSION_SECRET"));return e.use("/on-uninstall",t("/.extensions/on-uninstall")),e.delete("/on-uninstall",function(e,t){var n=r("AUTH0_CLIENT_ID"),o={domain:r("AUTH0_DOMAIN"),clientSecret:r("AUTH0_CLIENT_SECRET"),clientId:n};i.managementApi.getClient(o).then(function(e){return e.clients.delete({client_id:n})}).then(function(){c.debug("Deleted client "+n),t.sendStatus(204)}).catch(function(e){c.debug("Error deleting client: "+n),c.error(e),t.sendStatus(204)})}),e}},function(e,t,n){"use strict";(function(t){var o=(n(26),n(25)),i=(n(10),n(2).urlHelpers),s=n(1);e.exports=function(){var e='\n \n \n \n <%= config.TITLE %>\n \n \n \n \n \n \n \n \n <% if (assets.style) { %><% } %>\n <% if (assets.version) { %><% } %>\n <% if (assets.customCss) { %><% } %>\n \n \n
\n