From d079985edec3831ed1e0cd3a66eb5ff97419b6aa Mon Sep 17 00:00:00 2001 From: Sudharshan TK Date: Tue, 21 Dec 2021 08:00:55 +0530 Subject: [PATCH] release: v0.2.0-36 --- CHANGELOG.md | 17 +++++++++++++++++ app.js | 2 +- package.json | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c245660..c2f7900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [0.2.0-36](https://github.com/zyndex-drive/server/compare/v0.2.0-35...v0.2.0-36) (2021-12-21) + + +### Bug Fixes 🛠 + +* **models/policy:** fix policy model schema ([856923a](https://github.com/zyndex-drive/server/commit/856923a6922a8bd635a4c32cf0747567888bb0e1)) + + +### Features 🔥 + +* **plugins/auth:** use policy documents from the database to check policies ([4ff04f8](https://github.com/zyndex-drive/server/commit/4ff04f8b18a407b31beacaa36fb86f693e91aed7)) + + +### Code Refactoring 🖌 + +* **plugins/google:** fix the callback hell with .then chaining ([c614139](https://github.com/zyndex-drive/server/commit/c614139bd77d1a2ba93a3406f5f9ef7447cc8c60)) + ## [0.2.0-35](https://github.com/zyndex-drive/server/compare/v0.2.0-34...v0.2.0-35) (2021-12-20) diff --git a/app.js b/app.js index 37bfd3f..1da5742 100644 --- a/app.js +++ b/app.js @@ -1 +1 @@ -(()=>{"use strict";var e={3864:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5142)),a=n(r(412)),i=n(r(8130)),s=r(819);o.default.config(),(0,s.healthCheckService)(a.default);const l=process.env.PORT;try{a.default.listen(l||3e3,(()=>{console.log("Server Started"),console.log("Connecting to Database"),i.default.connect().then((e=>{e?console.log("Database Connected"):(console.log("No Database Url is Found in Environment Variables"),a.default.close())})).catch((e=>{console.log(`${e.name}: ${e.message}`),a.default.close()}))})),a.default.once("error",(e=>{console.log("There was an error starting the server in the error listener:",e),a.default.close()}))}catch(e){console.log("There was an error starting the server:",e),a.default.close()}},4961:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(1880);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},1880:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7185));t.default=(0,o.model)("BlacklistedUser",a.default)},7185:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4621)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId,ref:"User"},name:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0},blacklisted_from:{type:Number,required:!0},role:[{scope:{type:o.Schema.Types.ObjectId,ref:"Scope",required:!0},role:{type:o.Schema.Types.ObjectId,ref:"Role",required:!0}}],flagged_by:{type:o.Schema.Types.ObjectId,ref:"User",required:!0}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},4621:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},2598:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6325);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},6325:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(2919));t.default=(0,o.model)("Credential",a.default)},2919:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(3361)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},alias:{type:String,required:!0,hash:!0},client_id:{type:String,required:!0,encrypt:!0},client_secret:{type:String,required:!0,encrypt:!0},redirect_uri:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0,unique:!0}});s.plugin((0,i.cryptoPlugin)()),s.plugin((0,i.hashPlugin)()),t.default=(0,a.default)(s)},3361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkID=t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}function a(e){return new Promise(((t,r)=>{this.findById(e).then((e=>{t(!!e)})).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}t.clearAll=o,t.checkID=a,t.default=function(e){return e.statics.clearAll=o,e.statics.checkID=a,e}},3609:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(3528);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},3528:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1146));t.default=(0,o.model)("Frontend",a.default)},1146:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7860)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},domain:{type:String,required:!0,unique:!0},name:{type:String,required:!0},settings:{specifics:[{setting:{type:o.Schema.Types.ObjectId,ref:"GlobalSetting"},flag:{type:String||Boolean||Number,required:!0}}],default_mailer:{type:o.Schema.Types.ObjectId,ref:"SMTPMailer",required:!1},disallowed_roles:{type:o.Schema.Types.ObjectId,ref:"Role"},allowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],disallowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}]}});t.default=(0,a.default)(i)},7860:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getFrontendUrls=t.clearAll=void 0;const o=r(9593);function a(){return(0,o.clearCollection)(this)}function i(){return n(this,void 0,void 0,(function*(){return this.find({},"_id domain name")}))}t.clearAll=a,t.getFrontendUrls=i,t.default=function(e){return e.statics.getFrontendUrls=i,e.statics.clearAll=a,e}},5576:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(4079);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},4079:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(575));t.default=(0,o.model)("GlobalSetting",a.default)},575:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(2670)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},message:{type:String,required:!0},global_flag:{type:Boolean||String||Number||o.Schema.Types.ObjectId,refPath:"reference",required:!0},reference:{type:String,enum:["SMTPMailer","SMTPProvider","MailTemplates"]}});t.default=(0,a.default)(i)},2670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},7382:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SMTPMailers=t.SMTPProviders=t.GlobalSettings=t.Frontends=t.Policies=t.Roles=t.Tokens=t.Credentials=t.BlacklistUsers=t.PendingUsers=t.Scopes=t.ServiceAccs=t.Sessions=t.Users=void 0;var o=r(9500);Object.defineProperty(t,"Users",{enumerable:!0,get:function(){return n(o).default}});var a=r(8183);Object.defineProperty(t,"Sessions",{enumerable:!0,get:function(){return n(a).default}});var i=r(5525);Object.defineProperty(t,"ServiceAccs",{enumerable:!0,get:function(){return n(i).default}});var s=r(4033);Object.defineProperty(t,"Scopes",{enumerable:!0,get:function(){return n(s).default}});var l=r(8378);Object.defineProperty(t,"PendingUsers",{enumerable:!0,get:function(){return n(l).default}});var u=r(4961);Object.defineProperty(t,"BlacklistUsers",{enumerable:!0,get:function(){return n(u).default}});var d=r(2598);Object.defineProperty(t,"Credentials",{enumerable:!0,get:function(){return n(d).default}});var c=r(1951);Object.defineProperty(t,"Tokens",{enumerable:!0,get:function(){return n(c).default}});var f=r(6482);Object.defineProperty(t,"Roles",{enumerable:!0,get:function(){return n(f).default}});var p=r(148);Object.defineProperty(t,"Policies",{enumerable:!0,get:function(){return n(p).default}});var _=r(3609);Object.defineProperty(t,"Frontends",{enumerable:!0,get:function(){return n(_).default}});var m=r(5576);Object.defineProperty(t,"GlobalSettings",{enumerable:!0,get:function(){return n(m).default}});var g=r(4652);Object.defineProperty(t,"SMTPProviders",{enumerable:!0,get:function(){return n(g).default}});var v=r(4901);Object.defineProperty(t,"SMTPMailers",{enumerable:!0,get:function(){return n(v).default}})},8378:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(1566);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},1566:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(9838));t.default=(0,o.model)("PendingUser",a.default)},9838:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5978)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0},message:{type:String,required:!0},role:{type:o.Schema.Types.ObjectId,ref:"Role",required:!0},scopes:[{type:o.Schema.Types.ObjectId,ref:"Scope"}],requested_at:{type:Number,required:!0,default:Date.now},accepted:{type:Boolean,default:!1},accepted_at:{type:Number,default:Date.now}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},5978:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},148:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(7206);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},7206:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(6357));t.default=(0,o.model)("Policy",a.default)},6357:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7208)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},code:{type:String,required:!0},message:{type:String,required:!0},global_flag:{type:Boolean,required:!0}});t.default=(0,a.default)(i)},7208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapCheck=t.clearAll=void 0;const n=r(9593),o=r(5663);function a(){return(0,n.clearCollection)(this)}function i(){return new Promise(((e,t)=>{const r={success:!1,data:!1,error:null};this.find({}).then((t=>{const n=[];r.success=!0;for(let e=0;ee._id===r._id));if(a&&r&&a._id===r._id){const e=a.name===r.name,t=a.message===r.message;n.push(e&&t)}else n.push(!1)}n.includes(!1)?r.data=!1:r.data=!0,e(r)})).catch((e=>{r.error=e,t(new Error(`${e.name}: ${e.message}`))}))}))}t.clearAll=a,t.mapCheck=i,t.default=function(e){return e.statics.clearAll=a,e.statics.mapCheck=i,e}},6482:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(4407);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},4407:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(2314));t.default=(0,o.model)("Role",a.default)},2314:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1241)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},alias:{type:String,required:!0},type:{type:String,enum:["main","sub"],required:!0},delgates_from:{type:o.Schema.Types.ObjectId||null,ref:"Role"},allowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],disallowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],specific_settings:[{setting:{type:o.Schema.Types.ObjectId,ref:"GlobalSetting"},flag:{type:String||Boolean||Number,required:!0}}]});t.default=(0,a.default)(i)},1241:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapCheck=t.clearAll=void 0;const n=r(9593),o=r(3969);function a(){return(0,n.clearCollection)(this)}function i(){return new Promise(((e,t)=>{const r={success:!1,data:!1,error:null};this.find({}).then((t=>{const n=[];r.success=!0;for(let e=0;ee._id===r._id));if(a&&r&&a._id===r._id){const e=a.name===r.name,t=a.allowed_policies.length===r.allowed_policies.length;n.push(e&&t)}else n.push(!1)}n.includes(!1)?r.data=!1:r.data=!0,e(r)})).catch((e=>{r.error=e,t(new Error(`${e.name}: ${e.message}`))}))}))}t.clearAll=a,t.mapCheck=i,t.default=function(e){return e.statics.clearAll=a,e.statics.mapCheck=i,e}},4033:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(1675);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},1675:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5102));t.default=(0,o.model)("Scope",a.default)},5102:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7015)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},added_at:{type:Number,required:!0,default:Date.now},drive_id:{type:String,required:!0,unique:!0},disallowed_frontends:[{type:o.Schema.Types.ObjectId,ref:"Frontend"}],related_to:[{type:o.Schema.Types.ObjectId,ref:"Credential"}]});t.default=(0,a.default)(i)},7015:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},5525:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(5355);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},5355:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7981));t.default=(0,o.model)("ServiceAccount",a.default)},7981:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7333)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},project_id:{type:String,required:!0},unique_id:{type:String,required:!0},private_key:{id:{type:String,required:!0},key:{type:String,required:!0,encrypt:!0}},client:{id:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0}},related_to:{type:o.Schema.Types.ObjectId,ref:"Credential",required:!0}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},7333:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},8183:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6570);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},6570:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(691));t.default=(0,o.model)("Session",a.default)},691:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4436)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},ip:{type:String,required:!0},user_id:{type:o.Schema.Types.ObjectId,ref:"User",required:!0},frontend:{type:o.Schema.Types.ObjectId,ref:"Frontend",required:!0},token_secret:{type:String,required:!0,unique:!0,encrypt:!0},issued_at:{type:Number,required:!0,default:Date.now}});t.default=(0,a.default)(i)},4436:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},4901:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(3263);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},3263:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4125));t.default=(0,o.model)("SMTPMailer",a.default)},4125:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5280)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},email:{type:String,required:!0},password:{type:String,required:!0,encrypt:!0},type:{type:String,enum:["gmail","others"],required:!0},provider:{type:o.Schema.Types.ObjectId,ref:"SMTPProvider"},gmail_data:{type:Object}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},5280:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},4652:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(8541);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},8541:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5006));t.default=(0,o.model)("SMTPProvider",a.default)},5006:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1708)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0,unique:!0},alias:{type:String,required:!0},smtp:{url:{type:String,required:!0},port:{type:Number,required:!0}},imap:{url:{type:String,required:!0},port:{type:Number,required:!0}},dkim_key:{type:String,required:!0,encrypt:!0}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},1708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},1951:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(634);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},634:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4446));t.default=(0,o.model)("Token",a.default)},4446:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1531)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},token:{type:String,required:!0,encrypt:!0},type:{type:String,required:!0},related_to:{type:o.Schema.Types.ObjectId||String,refPath:"ref_model"},ref_model:{type:String,enum:["Credential","ServiceAccount"]},expires_at:{type:Number,required:!0},scopes:[{type:String,required:!0}],website:{type:String,required:!0},additional_tokens:[{type:{type:String},token:{type:String}}]});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},1531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},9500:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(8399);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},8399:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(709));t.default=(0,o.model)("User",a.default)},709:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(6888)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0,encrypt:!0},email:{type:String,lowercase:!0,required:!0,unique:!0},avatar:{type:String,lowercase:!0},registered_at:{type:Number,required:!0,default:Date.now},verified_at:{type:Number,required:!0},token_hash:{type:String,required:!0,encrypt:!0},restricted:{type:Boolean,default:!1},role:[{scope:{type:o.Schema.Types.ObjectId,ref:"Scope",required:!0},role:{type:o.Schema.Types.ObjectId,ref:"Role",required:!0}}],password:{type:String,hash:!0},allowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],disallowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}]});s.plugin((0,i.cryptoPlugin)()),s.plugin((0,i.hashPlugin)()),t.default=(0,a.default)(s)},6888:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},7644:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6199);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},6199:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2167)).default.create();t.default=o},4041:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5666)),a={str:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return o.default.AES.decrypt(e,t).toString(o.default.enc.Utf8);throw new Error("Passphrase not set in Variables, Kindly Set that")},obj:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return JSON.parse(o.default.AES.decrypt(e,t).toString(o.default.enc.Utf8)).data;throw new Error("Passphrase not set in Variables, Kindly Set that")}};t.default=a},6257:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5666)),a={str:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return o.default.AES.encrypt(e,t).toString();throw new Error("Passphrase not set in Variables, Kindly Set that")},obj:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return o.default.AES.encrypt(JSON.stringify(e),t).toString();throw new Error("Passphrase not set in Variables, Kindly Set that")}};t.default=a},248:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=void 0;var o=r(6257);Object.defineProperty(t,"encrypt",{enumerable:!0,get:function(){return n(o).default}});var a=r(4041);Object.defineProperty(t,"decrypt",{enumerable:!0,get:function(){return n(a).default}})},7365:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=o(r(1185));t.default={connect:()=>n(void 0,void 0,void 0,(function*(){const e=process.env.DBURL;return e?yield a.default.connect(e,{useUnifiedTopology:!0,bufferCommands:!1,bufferMaxEntries:0,useNewUrlParser:!0,useCreateIndex:!0}).then((e=>e)):new Promise((e=>e(!1)))})),close:()=>new Promise(((e,t)=>{a.default.connection.close().then((()=>{console.log("Successfully Closed the Database Connection"),e()})).catch((()=>{t(new Error("Failed to Close Database Connection"))}))}))}},411:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeFields=t.encodeFields=void 0;const o=n(r(9387));t.encodeFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(o.default.has(e,t)){const n=o.default.get(e,t);if("string"==typeof n){const e=Buffer.from(n).toString("base64");r=o.default.set(r,t,e)}}})),r},t.decodeFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(o.default.has(e,t)){const n=o.default.get(e,t);let a;"string"==typeof n&&(a=Buffer.from(n,"base64").toString("utf8")),r=o.default.set(r,t,a)}})),r}},8591:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decryptFields=t.encryptFields=void 0;const o=r(248),a=n(r(9387));t.encryptFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(a.default.has(e,t)){const n=a.default.get(e,t);let i;if("string"==typeof n)i=o.encrypt.str(n);else{const e={data:n};i=o.encrypt.obj(e)}r=a.default.set(r,t,i)}})),r},t.decryptFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(a.default.has(e,t)){const n=a.default.get(e,t);let i;"string"==typeof n&&(i=o.decrypt.str(n)),r=a.default.set(r,t,i)}})),r}},3289:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(9387));t.default=function(e,t){const r=[];return e.eachPath(((e,n)=>{const a=Object.keys(n),i=Object.create(n);if(a&&i){const n=i.options;o.default.has(n,t)&&r.push(e)}})),r}},9376:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7096)),a=n(r(9387));t.default=function(e,t){return new Promise(((r,n)=>{try{if(t){const i=new Promise(((r,n)=>{let i=e;t.forEach(((s,l)=>{if(a.default.has(e,s)){const t=a.default.get(e,s);"string"==typeof t&&o.default.hash(t,10).then((e=>{i=a.default.set(i,s,e)})).catch((e=>{n(e)}))}l===t.length-1&&r(i)}))}));i.then((e=>r(e))).catch((e=>{console.log(e),n(e)}))}}catch(e){console.log(e),n(e)}}))}},4458:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.hashString=t.fieldsPicker=t.decodeFields=t.encodeFields=t.decryptFields=t.encryptFields=void 0;var o=r(8591);Object.defineProperty(t,"encryptFields",{enumerable:!0,get:function(){return o.encryptFields}}),Object.defineProperty(t,"decryptFields",{enumerable:!0,get:function(){return o.decryptFields}});var a=r(411);Object.defineProperty(t,"encodeFields",{enumerable:!0,get:function(){return a.encodeFields}}),Object.defineProperty(t,"decodeFields",{enumerable:!0,get:function(){return a.decodeFields}});var i=r(3289);Object.defineProperty(t,"fieldsPicker",{enumerable:!0,get:function(){return n(i).default}});var s=r(9376);Object.defineProperty(t,"hashString",{enumerable:!0,get:function(){return n(s).default}})},8130:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.clearCollection=t.default=void 0;var o=r(7365);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}});var a=r(9593);Object.defineProperty(t,"clearCollection",{enumerable:!0,get:function(){return a.clearCollection}})},8649:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(4458);t.default=function(){return e=>{const t=(0,n.fieldsPicker)(e,"base64encode");e.pre("validate",(function(e){const r=(0,n.encodeFields)(this,t);this.set(r),e()})),e.post("init",(function(){return(0,n.decodeFields)(this,t)}))}}},6e3:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(4458);t.default=function(){return e=>{const t=(0,n.fieldsPicker)(e,"encrypt");e.pre("validate",(function(e){const r=(0,n.encryptFields)(this,t);this.set(r),e()})),e.post("init",(function(){return(0,n.decryptFields)(this,t)}))}}},5447:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(4458);t.default=function(){return e=>{const t=(0,n.fieldsPicker)(e,"hash");e.pre("validate",(function(e){(0,n.hashString)(this,t).then((t=>{this.set(t),e()})).catch((e=>{throw console.log(e),new Error("Password Hashing Failed")}))}))}}},9661:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.hashPlugin=t.base64EncodePlugin=t.cryptoPlugin=void 0;var o=r(6e3);Object.defineProperty(t,"cryptoPlugin",{enumerable:!0,get:function(){return n(o).default}});var a=r(8649);Object.defineProperty(t,"base64EncodePlugin",{enumerable:!0,get:function(){return n(a).default}});var i=r(5447);Object.defineProperty(t,"hashPlugin",{enumerable:!0,get:function(){return n(i).default}})},3275:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return new Promise(((t,r)=>{e.deleteMany({}).then((()=>{t({success:!0,data:"Successfully Cleared the Collection",error:null})})).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}},9593:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.clearCollection=void 0;var o=r(3275);Object.defineProperty(t,"clearCollection",{enumerable:!0,get:function(){return n(o).default}})},5754:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(3853),o=r(4015),a=r(6724),i=r(860);t.default={files:n.api,drives:o.api,about:a.api,permissions:i.api}},5485:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={get:"https://www.googleapis.com/drive/v3/about"}},7580:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["user","storageQuota","maxUploadSize","canCreateTeamDrives","canCreateDrives"]},6724:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(5485);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(3412);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},2629:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5485)),a=r(1084),i=n(r(7580)),s=r(1084);t.default=function(e){const t={fields:(0,s.constructFields)(i.default)};return a.googleApiRequest.get(o.default.get,e,t)}},3412:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2629));t.default={get:o.default}},6073:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:"https://www.googleapis.com/drive/v3/drives",get:e=>`https://www.googleapis.com/drive/v3/drives/${e}`,create:"https://www.googleapis.com/drive/v3/drives",update:e=>`https://www.googleapis.com/drive/v3/drives/${e}`}},6650:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["name","id","capabilities","createdTime","hidden","restrictions"]},4015:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(6073);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(9039);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},8900:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(5828),i=r(1084),s=n(r(6650)),l=r(1084);t.default=function(e,t){const r={requestId:(0,a.v4)(),fields:(0,l.constructFields)(s.default)},n=o.default.create;return i.googleApiRequest.post(n,e,t,r)}},8687:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(1084),i=n(r(6650)),s=r(1084);t.default=function(e,t){const r={fields:(0,s.constructFields)(i.default)};return a.googleApiRequest.get(o.default.get(t),e,r)}},9039:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(8687)),a=n(r(909)),i=n(r(8900)),s=n(r(3715));t.default={get:o.default,list:a.default,create:i.default,update:s.default}},909:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(1084),i=n(r(6650)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default,"drives"),pageToken:t||"",q:r||""};return a.googleApiRequest.get(o.default.list,e,n)}},3715:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(1084),i=n(r(6650)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.update(t);return a.googleApiRequest.patch(l,e,r,n)}},1742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:"https://www.googleapis.com/drive/v3/files",get:e=>`https://www.googleapis.com/drive/v3/files/${e}`,create:{metadata:"https://www.googleapis.com/drive/v3/files",upload:"https://www.googleapis.com/upload/drive/v3/files"},generateId:"https://www.googleapis.com/drive/v3/files/generateIds",delete:e=>`https://www.googleapis.com/drive/v3/files/${e}`}},3853:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.api=void 0;var o=r(1742);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}})},1825:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.api=t.scopes=void 0;var o=r(3918);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(o).default}});var a=r(5754);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(a).default}});var i=r(124);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(i).default}})},124:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(6724),o=r(860);t.default={about:n.methods,permissions:o.methods}},6166:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:e=>`https://www.googleapis.com/drive/v3/files/${e}/permissions`,get:(e,t)=>`https://www.googleapis.com/drive/v3/files/${e}/permissions/${t}`,create:e=>`https://www.googleapis.com/drive/v3/files/${e}/permissions`,delete:(e,t)=>`https://www.googleapis.com/drive/v3/files/${e}/permissions/${t}`,update:(e,t)=>`https://www.googleapis.com/drive/v3/files/${e}/permissions/${t}`}},5602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["id","type","emailAddress","role","domain","photoLink","permissionDetails"]},860:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(6166);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(3612);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},1875:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.create(t);return a.googleApiRequest.post(l,e,r,n)}},8910:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.delete(t,r);return a.googleApiRequest.delete(l,e,n)}},9104:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.get(t,r);return a.googleApiRequest.get(l,e,n)}},3612:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(8915)),a=n(r(9104)),i=n(r(1875)),s=n(r(7949)),l=n(r(8910));t.default={list:o.default,get:a.default,create:i.default,update:s.default,delete:l.default}},8915:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t){const r={fields:(0,s.constructFields)(i.default,"permissions")},n=o.default.list(t);return a.googleApiRequest.get(n,e,r)}},7949:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r,n){const l={fields:(0,s.constructFields)(i.default)},u=o.default.delete(t,r);return a.googleApiRequest.patch(u,e,n,l)}},3918:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive.metadata","https://www.googleapis.com/auth/drive.appdata","https://www.googleapis.com/auth/drive.activity.readonly"]},1004:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.api=void 0;const n=r(6485),o=r(9887);t.api={projects:n.api,serviceAccount:o.api}},4e3:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.api=t.scopes=void 0;var o=r(8049);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(o).default}});var a=r(1004);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return a.api}});var i=r(8604);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(i).default}})},8604:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(6485),o=r(9887);t.default={projects:n.methods,serviceAccount:o.methods}},2741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:"https://cloudresourcemanager.googleapis.com/v1/projects",get:e=>`https://cloudresourcemanager.googleapis.com/v1/projects/${e}`}},6485:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(2741);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(5794);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},5165:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2741)),a=r(1084);t.default=function(e,t){return a.googleApiRequest.get(o.default.get(t),e)}},5794:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5165)),a=n(r(6574));t.default={get:o.default,list:a.default}},6574:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2741)),a=r(1084);t.default=function(e){return a.googleApiRequest.get(o.default.list,e)}},8049:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["https://www.googleapis.com/auth/cloud-platform"]},6308:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={create:e=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts`,delete:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}`,disable:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}:disable`,enable:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}:enable`,get:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}`,list:e=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts`}},9887:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(6308);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(962);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},5214:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(754),a=n(r(6308)),i=r(1084),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",l=`${s}0123456789`,u=(0,o.customAlphabet)(s,6),d=(0,o.customAlphabet)(l,6);t.default=function(e,t,r){const n=`${u()}-${d()}-${d()}`,o=a.default.create(t),s={accountId:n,serviceAccount:r};return i.googleApiRequest.post(o,e,s)}},5798:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){const n=o.default.delete(t,r);return a.googleApiRequest.delete(n,e)}},2348:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){const n=o.default.disable(t,r);return a.googleApiRequest.post(n,e)}},9270:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){const n=o.default.enable(t,r);return a.googleApiRequest.post(n,e)}},7728:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){return a.googleApiRequest.get(o.default.get(t,r),e)}},962:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(4817)),a=n(r(7728)),i=n(r(5214)),s=n(r(5798)),l=n(r(2348)),u=n(r(9270));t.default={list:o.default,get:a.default,create:i.default,delete:s.default,disable:l.default,enable:u.default}},4817:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t){return a.googleApiRequest.get(o.default.list(t),e)}},9432:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.scopes=t.drive=t.iam=void 0;var o=r(4e3);Object.defineProperty(t,"iam",{enumerable:!0,get:function(){return n(o).default}});var a=r(1825);Object.defineProperty(t,"drive",{enumerable:!0,get:function(){return n(a).default}});var i=r(2009);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(i).default}})},2009:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(3918)),a=n(r(8049));t.default={drive:o.default,iam:a.default}},7273:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(7382),i=o(r(2861)),s=r(5001),l=r(248),u=r(5257),d=o(r(5750)),c=r(1849);t.default=function(e,t,r){const{creds:o,code:f,state:p}=e.query;if(console.log(f,o,String(p)),!f&&o)!function(e,t,r){a.Credentials.findById(t).then((t=>{if(t){const n=l.encrypt.str(String(t._id)),o=function(e,t,r){const n=encodeURIComponent(e.client_id),o=encodeURIComponent(e.redirect_uri),a=encodeURIComponent(r),s=(0,d.default)(t),l=`client_id=${n}&redirect_uri=${o}&response_type=code&scope=${encodeURIComponent(s)}&access_type=offline&state=${a}`;return`${i.default.authorize}?${l}`}(t,r,n);e.redirect(o)}else(0,c.notFound)(e,"Credential ID Not found in DB, Kindly Recheck")})).catch((t=>{(0,c.internalServerError)(e,t.name,t.message)}))}(t,String(o),r);else if(f&&p){const e=String(f);!function(e,t,r,o){a.Credentials.findById(t).then((t=>n(this,void 0,void 0,(function*(){if(t){const n=(0,d.default)(o);try{const i=yield(0,u.generateRefreshToken)(t,n,r);if(!i.refresh_token)throw new Error("No Refresh Token Found in Response, Kindly Retry");{const r=yield(0,u.generateAccessToken)(t,i.refresh_token),n=yield function(e,t,r,n){return new Promise(((o,i)=>{const u=Date.now();Promise.all([(0,s.objectID)("t"),(0,s.objectID)("t")]).then((([s,d])=>{const c=[{_id:s,token:l.encrypt.str(r.refresh_token),type:"refresh",related_to:e._id,scopes:t,ref_model:"Credential",expires_at:u+31536e8,website:"google.com"},{_id:d,token:l.encrypt.str(n.access_token),type:"access",related_to:e._id,scopes:t,ref_model:"Credential",expires_at:u+1e3*n.expires_in,website:"google.com"}];a.Tokens.insertMany(c).then((e=>{o(e)})).catch((e=>{i(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{console.log(e),i(new Error("Error Occured while Generating a UID"))}))}))}(t,o,i,r);(0,c.okResponse)(e,n)}}catch(t){console.log(t),(0,c.internalServerError)(e,"Token Generation",String(t))}}else(0,c.notFound)(e,"Credential ID Not found in DB, Kindly Recheck")})))).catch((t=>{(0,c.internalServerError)(e,t.name,t.message)}))}(t,l.decrypt.str(decodeURIComponent(String(p))),e,r)}else(0,c.badRequest)(t,"creds","Query Parameters")}},5257:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateAccessToken=t.generateRefreshToken=void 0;const o=n(r(7644)),a=n(r(2861));function i(e,t,r,n){return new Promise(((i,s)=>{const{url:l,params:u}=function(e,t,r,n){const o=a.default.generateToken;let i="";const s=encodeURIComponent(e.client_id),l=encodeURIComponent(e.client_secret),u=n?encodeURIComponent(n):"",d=encodeURIComponent(e.redirect_uri);return i+="access_token"===t?`client_id=${s}&client_secret=${l}&refresh_token=${r}&grant_type=refresh_token`:`client_id=${s}&client_secret=${l}&code=${r}&scopes=${u}&redirect_uri=${d}&grant_type=authorization_code`,{url:o,params:i}}(t,e,r,n);o.default.post(l,u,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{200===e.status?i(e.data):s(new Error("Error While Generating the Tokens"))})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))}))}t.generateRefreshToken=function(e,t,r){return i("refresh_token",e,r,t)},t.generateAccessToken=function(e,t){return i("access_token",e,t)}},7272:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7273)),a=r(5257),i=n(r(2144));t.default={generateOauth:o.default,generateAccessToken:a.generateAccessToken,generateRefreshToken:a.generateRefreshToken,revokeToken:i.default}},2144:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7644)),a=n(r(2861));t.default=function(e){return new Promise(((t,r)=>{const n=a.default.revokeToken,i=`token=${e}`;o.default.post(n,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{const r={success:!1,data:!1,error:null};200===e.status?(r.success=!0,r.data=!0,t(r)):t(r)})).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}},6401:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(7382),o=r(5001),a=r(248),i=r(2494);t.default=function(e,t){return new Promise(((r,s)=>{n.ServiceAccs.findById(e).then((e=>{e?(0,i.generateAccessToken)(e,t).then((i=>{(function(e,t,r){return new Promise(((i,s)=>{const l=Date.now(),u={_id:(0,o.objectID)("t"),token:a.encrypt.str(r.access_token),type:"access",related_to:e._id,scopes:t,ref_model:"ServiceAccount",expires_at:l+1e3*r.expires_in,website:"google.com"};n.Tokens.create(u).then((e=>{i(e)})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))}))})(e,t,i).then(r).catch((e=>{s(new Error(String(e)))}))})).catch((e=>{s(new Error(String(e)))})):s(new Error("Unable to Find Service Account in the Database"))})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))}))}},2494:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateAccessToken=void 0;const o=n(r(7644)),a=r(1084);t.generateAccessToken=function(e,t){return function(e,t){return new Promise(((r,n)=>{(0,a.createJwtToken)(e,t).then((e=>{const{url:t,params:i}=function(e){return{url:a.api.generateToken,params:`grant_type=${encodeURIComponent("urn:ietf:params:oauth:grant-type:jwt-bearer")}&assertion=${e}`}}(e);o.default.post(t,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{200===e.status?r(e.data):n(new Error("Error While Generating the Tokens"))})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{n(new Error(e))}))}))}(e,t)}},5038:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6401)),a=r(2494);t.default={generateOauth:o.default,generateAccessToken:a.generateAccessToken}},2861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={authorize:"https://accounts.google.com/o/oauth2/v2/auth",generateToken:"https://oauth2.googleapis.com/token",checkToken:"https://oauth2.googleapis.com/tokeninfo",revokeToken:"https://oauth2.googleapis.com/revoke"}},3929:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){let r="";if(t){for(let n=0;n{Object.defineProperty(t,"__esModule",{value:!0}),t.mimeArray=void 0,t.default={audio:"application/vnd.google-apps.audio",docs:"application/vnd.google-apps.document",drawings:"application/vnd.google-apps.drawing",drivesdk:"application/vnd.google-apps.drive-sdk",file:"application/vnd.google-apps.file",folder:"application/vnd.google-apps.folder",form:"application/vnd.google-apps.form",fusiontable:"application/vnd.google-apps.fusiontable",map:"application/vnd.google-apps.map",photo:"application/vnd.google-apps.photo",presentation:"application/vnd.google-apps.presentation",script:"application/vnd.google-apps.script",shortcut:"application/vnd.google-apps.shortcut",site:"application/vnd.google-apps.site",spreadsheet:"application/vnd.google-apps.spreadsheet",unknown:"application/vnd.google-apps.unknown",video:"application/vnd.google-apps.video"},t.mimeArray=["application/vnd.google-apps.audio","application/vnd.google-apps.document","application/vnd.google-apps.drive-sdk","application/vnd.google-apps.drawing","application/vnd.google-apps.file","application/vnd.google-apps.folder","application/vnd.google-apps.form","application/vnd.google-apps.fusiontable","application/vnd.google-apps.map","application/vnd.google-apps.photo","application/vnd.google-apps.presentation","application/vnd.google-apps.script","application/vnd.google-apps.shortcut","application/vnd.google-apps.site","application/vnd.google-apps.spreadsheet","application/vnd.google-apps.unknown","application/vnd.google-apps.video"]},6056:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7644)),a=n(r(6452)),i=n(r(9103));function s(e,t){return t?`${e}?${i.default.stringify(t)}`:`${e}`}function l(e,t,r){return"get"===e?Object.assign({Authorization:`Bearer ${t.token}`,Accept:"application/json"},r):Object.assign({Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},r)}function u(e){return 200===e.status?{success:!0,data:e.data,error:null}:{success:!1,data:void 0,error:null}}const d={get:(e,t,r,n)=>new Promise(((a,i)=>{const d=s(e,r),c=l("get",t,n);o.default.get(d,{headers:c}).then((e=>{const t=u(e);a(t)})).catch((e=>{i(e)}))})),post:(e,t,r,n,a)=>new Promise(((i,d)=>{const c=s(e,n),f=l("post",t,a);o.default.post(c,r,{headers:f}).then((e=>{const t=u(e);i(t)})).catch((e=>{d(e)}))})),patch:(e,t,r,n,a)=>new Promise(((i,d)=>{const c=s(e,n),f=l("post",t,a);o.default.patch(c,r,{headers:f}).then((e=>{const t=u(e);i(t)})).catch((e=>{d(e)}))})),delete:(e,t,r,n)=>new Promise(((a,i)=>{const d=s(e),c=l("post",t,n);o.default.delete(d,{headers:c,data:r}).then((e=>{const t=u(e);a(t)})).catch((e=>{i(e)}))})),stream:(e,t,r)=>{const n=s(e,r),o=l("get",t);return a.default.stream(n,{headers:o})}};t.default=d},2581:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(7382),o=r(5257),a=r(2494),i=r(5001);function s(e){return e.map((e=>{const t=Date.now()+9e5,r={token:e,validity:!1};return e.expires_at>t&&(r.validity=!0),r}))}function l(e){return new Promise(((t,r)=>{const o=e.map((e=>e._id));n.Tokens.deleteMany({_id:{$in:o}}).then((()=>t())).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}function u(e,t,r){return new Promise(((a,s)=>{(0,o.generateAccessToken)(e,r.token).then((r=>{const o=(0,i.objectID)("t"),l=Date.now(),u={_id:o,token:r.access_token,type:"access",related_to:e._id,scopes:t,ref_model:"Credential",expires_at:l+1e3*r.expires_in,website:"google.com"};n.Tokens.create(u).then((e=>{a(e)})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{s(new Error(e))}))}))}function d(e,t){return new Promise(((r,o)=>{(0,a.generateAccessToken)(e,t).then((a=>{const s=(0,i.objectID)("t"),l=Date.now(),u={_id:s,token:a.access_token,type:"access",related_to:e._id,scopes:t,ref_model:"ServiceAccount",expires_at:l+1e3*a.expires_in,website:"google.com"};n.Tokens.create(u).then((e=>{r(e)})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{o(new Error(e))}))}))}t.default=function(e,t){return new Promise(((r,o)=>{(function(e,t){return new Promise(((r,o)=>{const a={success:!1};n.Credentials.findById(e).then((e=>{e&&(a.credential=e,n.ServiceAccs.find({related_to:e._id}).then((i=>{a.serviceAcc=i;const s=i.map((e=>e._id)),l=[{related_to:e._id,scopes:t},...s.map((e=>({related_to:e,scopes:t})))];n.Tokens.find({$or:l}).then((e=>{if(e.length>0){const t=e.filter((e=>"access"===e.type&&"Credential"===e.ref_model)),n=e.filter((e=>"access"===e.type&&"ServiceAccount"===e.ref_model)),o=e.filter((e=>"refresh"===e.type));a.tokens={access:{normal:t,service:n},refresh:o},a.success=!0,r(a)}else a.success=!1,r(a)})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))})))})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))}))}))})(e,t).then((e=>{(function(e,t){return new Promise(((r,n)=>{const{success:o,credential:a,serviceAcc:i,tokens:d}=e;if(o&&a&&d){const{access:e,refresh:o}=d;if(o.length>0){const d={success:!1,credential:a,serviceAcc:i};if(0===e.normal.length)u(a,t,o[0]).then((e=>{d.success=!1,d.tokens={refresh:o,access:{normal:[e]}},r(d)})).catch((e=>{n(new Error(e))}));else{const i=s(e.normal),c=i.filter((e=>e.validity)).map((e=>e.token));l(i.filter((e=>!e.validity)).map((e=>e.token))).then((()=>{d.success=!0,c.length>0?(d.tokens={refresh:o,access:{normal:c}},r(d)):u(a,t,o[0]).then((e=>{d.tokens={refresh:o,access:{normal:[e]}},r(d)})).catch((e=>{n(new Error(e))}))})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))}}else r({success:!1})}else r({success:!1})}))})(e,t).then((n=>{n.tokens?function(e,t){return new Promise(((r,n)=>{const{serviceAcc:o}=e;if(o){const{tokens:a}=e;if(a&&a.access.service){const e=s(a.access.service),i=e.filter((e=>e.validity)).map((e=>e.token));l(e.filter((e=>!e.validity)).map((e=>e.token))).then((()=>{if(i.length>0)r(i);else{const e=[];o.forEach((r=>{d(r,t).then((t=>{e.push(t)})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))})),e.length>1?r(e):r(!1)}})).catch((e=>{n(new Error(e))}))}else{const e=[];o.forEach((r=>{d(r,t).then((t=>{e.push(t)})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))})),e.length>1?r(e):r(!1)}}else r(!1)}))}(e,t).then((e=>{if(n.tokens)if(e){const t={success:!0,tokens:[...n.tokens.access.normal,...e]};r(t)}else{const e={success:!0,tokens:n.tokens.access.normal};r(e)}else o(new Error("No Possible Tokens Found or Generated"))})).catch((()=>{o(new Error("Error While Fetching Service Account Tokens"))})):o(new Error("No Tokens Found"))})).catch((e=>{o(new Error(e))}))})).catch((e=>{o(e)}))}))}},7683:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=r(5175),a=r(1084),i=(new o.Crypto).subtle,s={alg:"RS256",typ:"JWT"};t.default=function(e,t){return n(this,void 0,void 0,(function*(){const r=Date.now()/1e3,o=(0,a.stringizeScope)(t),l={iss:e.private_key.id,scope:o,aud:"https://oauth2.googleapis.com/token",exp:r+3600,iat:r},u=Buffer.from(JSON.stringify(l)).toString("base64"),d=Buffer.from(JSON.stringify(s)).toString("base64"),c=yield function(e){return n(this,void 0,void 0,(function*(){const t=function(e){const t=Buffer.from(e,"base64").toString("utf8"),r=new Uint8Array(t.length);for(let e=0;ee.trim())).filter((e=>e.length&&!e.startsWith("---"))).join(""));return i.importKey("pkcs8",t,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["sign"])}))}(e.private_key.key),f=function(e){let t="";const r=new Uint8Array(e);for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){let t="";return e.forEach(((r,n)=>{n===e.length-1?t+=`${r}`:t+=`${r} `})),t}},3100:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.oauthHelpers=t.serviceAccountHandler=t.normalAccountHandler=t.oauthScopes=t.oauthRouteApis=t.mimeTypes=t.mimeArray=t.oauthAuthenticationApis=void 0;const o=r(1084);var a=r(1084);Object.defineProperty(t,"oauthAuthenticationApis",{enumerable:!0,get:function(){return a.api}}),Object.defineProperty(t,"mimeArray",{enumerable:!0,get:function(){return a.mimeArray}}),Object.defineProperty(t,"mimeTypes",{enumerable:!0,get:function(){return a.mimeTypes}});var i=r(8841);Object.defineProperty(t,"oauthRouteApis",{enumerable:!0,get:function(){return i.api}});var s=r(9432);Object.defineProperty(t,"oauthScopes",{enumerable:!0,get:function(){return s.scopes}});var l=r(7272);Object.defineProperty(t,"normalAccountHandler",{enumerable:!0,get:function(){return n(l).default}});var u=r(5038);Object.defineProperty(t,"serviceAccountHandler",{enumerable:!0,get:function(){return n(u).default}}),t.oauthHelpers={resolveToken:o.resolveToken,stringizeScope:o.stringizeScope,constructFields:o.constructFields,createJwtToken:o.createJwtToken,googleApiRequest:o.googleApiRequest}},8841:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.api=void 0;const n=r(4e3),o=r(1825);t.api={iam:n.api,drives:o.api}},5001:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isUndefined=t.shortuid=t.objectID=t.generateUID=void 0;var o=r(2328);Object.defineProperty(t,"generateUID",{enumerable:!0,get:function(){return n(o).default}}),Object.defineProperty(t,"objectID",{enumerable:!0,get:function(){return o.objectID}}),Object.defineProperty(t,"shortuid",{enumerable:!0,get:function(){return o.shortuid}});var a=r(462);Object.defineProperty(t,"isUndefined",{enumerable:!0,get:function(){return n(a).default}})},462:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=[];return e.forEach((e=>{!e||null===e&&void 0===e?t.push(!1):t.push(!0)})),!!t.includes(!1)}},2328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shortuid=t.objectID=void 0;const n=r(754),o=r(1185),a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",i=`${a}&%^()!@#$*<>?/][}{<>,.|:;`,s=(0,n.customAlphabet)(i,10),l=(0,n.customAlphabet)(a,8);function u(e){if(e&&e.length>1)throw new Error("Prefix Cant be more than one Character");try{const t=s();return`${e?`${e}@`:""}${t}`}catch(e){throw new Error("Unable to Generate UID")}}t.default=u,t.objectID=function(e){try{return o.Types.ObjectId(u(e))}catch(e){throw new Error(String(e))}},t.shortuid=function(e){return`${e?`${e}@`:""}${l()}`}},7324:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointGenerator=void 0;const o=n(r(3648)),a=r(1849);t.EndpointGenerator=class{constructor(e,t){this.response=e,this.router=t}serve(){(0,a.okResponse)(this.response,(0,o.default)(this.router))}}},4523:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointGenerator=void 0;var n=r(7324);Object.defineProperty(t,"EndpointGenerator",{enumerable:!0,get:function(){return n.EndpointGenerator}})},3648:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=e=>{if(e.fast_slash)return"";const t=/^\/\^((?:\\[$()*+./?[\\\]^{|}]|[^$()*+./?[\\\]^{|}])*)\$\//u.exec(e.toString().replace("\\/?","").replace("(?=\\/|$)","$"));return t?t[1].replace(/\\(.)/gu,"$1"):"[Unknown path]"};t.default=function(e){const t={get:[],post:[],put:[],patch:[],delete:[]},n=(e,o="")=>{if("router"===e.name&&e.handle.stack)for(const t of e.handle.stack)n(t,`${o}${r(e.regexp)}`);if(!e.route)return;const{method:a}=e.route.stack[0],{path:i}=e.route;switch(a){case"get":t.get.push(`${o}${i}`);break;case"post":t.post.push(`${o}${i}`);break;case"put":t.put.push(`${o}${i}`);break;case"patch":t.patch.push(`${o}${i}`);break;case"delete":t.delete.push(`${o}${i}`);break;default:throw new Error(`Invalid method ${a}.`)}};for(const t of e.stack)n(t);return t}},8816:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(8130)),a=r(8305);function i(){return console.log("server is starting cleanup"),o.default.close()}function s(){return new Promise((e=>{console.log("cleanup finished, server is shutting down"),e()}))}t.default=function(e){const t={onSignal:i,onShutdown:s};(0,a.createTerminus)(e,t)}},819:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.responseSender=t.healthCheckService=t.getAllRoutes=void 0;var o=r(3648);Object.defineProperty(t,"getAllRoutes",{enumerable:!0,get:function(){return n(o).default}});var a=r(8816);Object.defineProperty(t,"healthCheckService",{enumerable:!0,get:function(){return n(a).default}});var i=r(6694);Object.defineProperty(t,"responseSender",{enumerable:!0,get:function(){return n(i).default}})},6694:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){e.status(t).json(r)}},412:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6466);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},9153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(7382),o=r(1849),{NODE_ENV:a}=process.env;t.default=function(e,t,r){if("development"===a){const n=e.method,a=process.env.LOCAL_SECRET;if(a){const i=e.headers["x-local-dev-pass"];"GET"===n?(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST"),t.setHeader("Access-Control-Allow-Headers","x-local-dev-pass,x-secret-pass,X-Requested-With,content-type, Accept"),r()):i?a===i?(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST"),t.setHeader("Access-Control-Allow-Headers","x-local-dev-pass,x-secret-pass,X-Requested-With,content-type, Accept"),r()):(0,o.unAuthorized)(t,"Local Dev Secret is not Matching with the sent pass"):(0,o.badRequest)(t,"x-local-dev-pass","response headers")}else(0,o.internalServerError)(t,"Secret Error","Project not Configured for Local Development")}else n.Frontends.getFrontendUrls().then((n=>{const o=n.map((e=>e.domain)),{origin:a}=e.headers;a&&o.indexOf(a)>-1&&t.setHeader("Access-Control-Allow-Origin",a),t.setHeader("Access-Control-Allow-Methods","GET, POST"),t.setHeader("Access-Control-Allow-Headers","x-local-dev-pass,x-secret-pass,X-Requested-With,content-type, Accept"),t.setHeader("Access-Control-Allow-Credentials","true"),r()})).catch((e=>{(0,o.internalServerError)(t,e.name,e.message)}))}},1491:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(1185);t.default=function(e,t,r){const o=n.connection.readyState;if([0,2,3].includes(o)){const e={status:500,errorname:`Database is ${n.STATES[o]}`,message:"Internal Server Error Related to Database"};t.status(500).json(e)}else t.locals.dbcheck=!0,r()}},7331:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.checkSecretPass=void 0;const o=r(7382),a=r(1849),i=r(3969),s=r(5663);function l(e,t){return n(this,void 0,void 0,(function*(){return new Promise(((r,n)=>{e.find({}).exec().then((e=>{e?e.length>0?t?t.length===e.length?r(!0):r(!1):r(!0):r(!1):n(new Error("Unknown Error while Querying Collection"))})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))}))}))}t.default=function(e,t,r){const n=[l(o.Credentials),l(o.Frontends),l(o.Policies,s.map),l(o.Roles,i.map),l(o.GlobalSettings),l(o.Scopes),l(o.Users)];Promise.all(n).then((e=>{e.includes(!1)?(t.locals.setups=!0,r()):t.status(200).json({success:!0,setup:!0,message:"All the Collections have been Setup Correctly"})})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))},t.checkSecretPass=function(e,t,r){const n=process.env.SECRET;if(n){const o=e.headers["x-secret-pass"];if(o&&"string"==typeof o){const e=n.toLowerCase();o.toLowerCase()===e?(t.locals.secretcheck=!0,r()):(0,a.unAuthorized)(t,"Header Secret is Not Matching with the Environment Secret, Kindly Send the Correct Pass")}else(0,a.badRequest)(t,"x-secret-pass","Request Headers")}else(0,a.internalServerError)(t,"Secret Error","No Secret Set in the Environment, Kindly Set in Vars")}},8030:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkSecretPass=t.checkSetupStatus=t.checkDBStatus=t.cors=void 0;var o=r(9153);Object.defineProperty(t,"cors",{enumerable:!0,get:function(){return n(o).default}});var a=r(1491);Object.defineProperty(t,"checkDBStatus",{enumerable:!0,get:function(){return n(a).default}});var i=r(7331);Object.defineProperty(t,"checkSetupStatus",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(t,"checkSecretPass",{enumerable:!0,get:function(){return i.checkSecretPass}})},6267:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.okResponse=void 0;const o=n(r(6694));t.okResponse=function(e,t){const r={status:200,data:t};(0,o.default)(e,200,r)}},9041:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notFound=t.unAuthorized=t.badRequest=void 0;const o=n(r(6694));t.badRequest=function(e,t,r){const n={status:400,errorname:"Bad Request",message:`Expected ${t} in ${r}`};(0,o.default)(e,400,n)},t.unAuthorized=function(e,t){const r={status:403,errorname:"UnAuthorized",message:t};(0,o.default)(e,400,r)},t.notFound=function(e,t){const r={status:404,errorname:"Not Found",message:t};(0,o.default)(e,400,r)}},2923:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.badGateway=t.internalServerError=void 0;const o=n(r(6694));t.internalServerError=function(e,t,r){const n={status:500,errorname:t||"Internal Server Error",message:r||"Unknown"};(0,o.default)(e,500,n)},t.badGateway=function(e){(0,o.default)(e,502,{status:502,errorname:"Bad Gateway",message:"Received an Invalid response from the upstream server."})}},1849:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.badGateway=t.internalServerError=t.notFound=t.unAuthorized=t.badRequest=t.okResponse=void 0;var n=r(6267);Object.defineProperty(t,"okResponse",{enumerable:!0,get:function(){return n.okResponse}});var o=r(9041);Object.defineProperty(t,"badRequest",{enumerable:!0,get:function(){return o.badRequest}}),Object.defineProperty(t,"unAuthorized",{enumerable:!0,get:function(){return o.unAuthorized}}),Object.defineProperty(t,"notFound",{enumerable:!0,get:function(){return o.notFound}});var a=r(2923);Object.defineProperty(t,"internalServerError",{enumerable:!0,get:function(){return a.internalServerError}}),Object.defineProperty(t,"badGateway",{enumerable:!0,get:function(){return a.badGateway}})},6466:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(3685)),a=n(r(6860)),i=n(r(7806)),s=n(r(2821)),l=n(r(8285)),u=n(r(1491)),d=n(r(9153)),c=n(r(9796)),f=(0,a.default)();f.use(a.default.json({limit:"50kb"})),f.use((0,i.default)()),f.use((0,l.default)()),f.use((0,s.default)()),f.use([u.default,d.default]),f.use("/",c.default);const p=o.default.createServer(f);t.default=p},544:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(389);t.default={add:n.creds_add,edit:n.creds_edit,remove:n.creds_rm},t.map=[n.creds_add,n.creds_edit,n.creds_rm]},389:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.creds_rm=t.creds_edit=t.creds_add=void 0;const n=r(2328);t.creds_add={_id:(0,n.objectID)("p"),code:"credsadd",name:"Add Credentials to DB",message:"Enable Adding of Credentials from Database",global_flag:!0},t.creds_edit={_id:(0,n.objectID)("p"),code:"credsedit",name:"Edit Credentials in DB",message:"Enable Editing of Credentials from Database",global_flag:!0},t.creds_rm={_id:(0,n.objectID)("p"),code:"credsrm",name:"Remove Credentials from DB",message:"Enable Removal of Credentials from Database",global_flag:!0}},8468:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(2786);t.default={add:n.frontend_add,edit:n.frontend_edit,remove:n.frontend_rm},t.map=[n.frontend_add,n.frontend_edit,n.frontend_rm]},2786:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.frontend_rm=t.frontend_edit=t.frontend_add=void 0;const n=r(2328);t.frontend_add={_id:(0,n.objectID)("p"),code:"ftendadd",name:"Add Frontends",message:"Enable Adding of Frotnends from Database",global_flag:!0},t.frontend_edit={_id:(0,n.objectID)("p"),code:"ftendedit",name:"Edit Frontends",message:"Enable Editing of Frontend Details from Database",global_flag:!0},t.frontend_rm={_id:(0,n.objectID)("p"),code:"ftendrm",name:"Remove Frontends",message:"Enable Removal of Frontends from Database",global_flag:!0}},6683:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4199);t.default={edit:n.global_settings_edit},t.map=[n.global_settings_edit]},4199:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.global_settings_edit=void 0;const n=r(2328);t.global_settings_edit={_id:(0,n.objectID)("p"),code:"gblsetedit",name:"Edit Global Settings",message:"Enable Editing of Global Settings of the Server",global_flag:!0}},5663:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.map=t.smtpProviders=t.smtpMailers=t.serviceAccounts=t.scopes=t.roles=t.policy=t.globalSettings=t.frontends=t.credentials=t.users=void 0;const o=r(8384),a=r(544),i=r(8468),s=r(6683),l=r(7549),u=r(5624),d=r(381),c=r(167),f=r(5735),p=r(9008);var _=r(8384);Object.defineProperty(t,"users",{enumerable:!0,get:function(){return n(_).default}});var m=r(544);Object.defineProperty(t,"credentials",{enumerable:!0,get:function(){return n(m).default}});var g=r(8468);Object.defineProperty(t,"frontends",{enumerable:!0,get:function(){return n(g).default}});var v=r(6683);Object.defineProperty(t,"globalSettings",{enumerable:!0,get:function(){return n(v).default}});var h=r(7549);Object.defineProperty(t,"policy",{enumerable:!0,get:function(){return n(h).default}});var b=r(5624);Object.defineProperty(t,"roles",{enumerable:!0,get:function(){return n(b).default}});var y=r(381);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(y).default}});var P=r(167);Object.defineProperty(t,"serviceAccounts",{enumerable:!0,get:function(){return n(P).default}});var j=r(5735);Object.defineProperty(t,"smtpMailers",{enumerable:!0,get:function(){return n(j).default}});var M=r(9008);Object.defineProperty(t,"smtpProviders",{enumerable:!0,get:function(){return n(M).default}}),t.map=[...o.map,...a.map,...i.map,...s.map,...l.map,...u.map,...d.map,...c.map,...f.map,...p.map]},7549:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(3540);t.default={edit:n.policies_edit},t.map=[n.policies_edit]},3540:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.policies_edit=void 0;const n=r(2328);t.policies_edit={_id:(0,n.objectID)("p"),code:"poledit",name:"Edit Policies",message:"Enable Editing of Organisation Policies",global_flag:!0}},5624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(6645);t.default={add:n.roles_add,edit:n.roles_edit,remove:n.roles_rm},t.map=[n.roles_add,n.roles_edit,n.roles_rm]},6645:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.roles_rm=t.roles_edit=t.roles_add=void 0;const n=r(2328);t.roles_add={_id:(0,n.objectID)("p"),code:"roleadd",name:"Add Sub Roles",message:"Enable Creating of Sub Roles",global_flag:!0},t.roles_edit={_id:(0,n.objectID)("p"),code:"roleedit",name:"Edit Sub Roles",message:"Enable Editing of Settings related to Sub Roles",global_flag:!0},t.roles_rm={_id:(0,n.objectID)("p"),code:"rolerm",name:"Remove Sub Roles",message:"Enable Removal of Sub Roles",global_flag:!0}},381:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4503);t.default={add:n.scope_add,edit:n.scope_edit,remove:n.scope_rm},t.map=[n.scope_add,n.scope_edit,n.scope_rm]},4503:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scope_rm=t.scope_edit=t.scope_add=void 0;const n=r(2328);t.scope_add={_id:(0,n.objectID)("p"),code:"scpadd",name:"Add Scopes",message:"Enable Adding of Scopes to Database",global_flag:!0},t.scope_edit={_id:(0,n.objectID)("p"),code:"scpedit",name:"Edit Scopes",message:"Enable Editing of Scopes in Database",global_flag:!0},t.scope_rm={_id:(0,n.objectID)("p"),code:"scprm",name:"Remove Scopes",message:"Enable Removal of Scopes from Database",global_flag:!0}},167:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(5793);t.default={add:n.sac_add,edit:n.sac_edit,remove:n.sac_rm},t.map=[n.sac_add,n.sac_edit,n.sac_rm]},5793:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sac_rm=t.sac_edit=t.sac_add=void 0;const n=r(2328);t.sac_add={_id:(0,n.objectID)("p"),code:"sacaccadd",name:"Add Service Account",message:"Enable Adding of Service Accounts to Database",global_flag:!0},t.sac_edit={_id:(0,n.objectID)("p"),code:"sacaccedit",name:"Edit Service Account",message:"Enable Editing of Service Accounts in Database",global_flag:!0},t.sac_rm={_id:(0,n.objectID)("p"),code:"sacaccrm",name:"Remove Service Account",message:"Enable Removal of Service Accounts from Database",global_flag:!0}},5735:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(5030);t.default={add:n.smtp_mailer_add,edit:n.smtp_mailer_edit,remove:n.smtp_mailer_rm},t.map=[n.smtp_mailer_add,n.smtp_mailer_edit,n.smtp_mailer_rm]},5030:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.smtp_mailer_rm=t.smtp_mailer_edit=t.smtp_mailer_add=void 0;const n=r(2328),o="smtpmail";t.smtp_mailer_add={_id:(0,n.objectID)("p"),code:`${o}add`,name:"Add SMTP Emails Accounts",message:"Enable Adding of SMTP Emails Accounts to Database",global_flag:!0},t.smtp_mailer_edit={_id:(0,n.objectID)("p"),code:`${o}edit`,name:"Edit SMTP Emails Accounts",message:"Enable Editing of SMTP Emails Accounts in Database",global_flag:!0},t.smtp_mailer_rm={_id:(0,n.objectID)("p"),code:`${o}rm`,name:"Remove SMTP Emails Accounts",message:"Enable Removal of SMTP Emails Accounts from Database",global_flag:!0}},9008:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(9996);t.default={add:n.smtp_provider_add,edit:n.smtp_provider_edit,remove:n.smtp_provider_rm},t.map=[n.smtp_provider_add,n.smtp_provider_edit,n.smtp_provider_rm]},9996:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.smtp_provider_rm=t.smtp_provider_edit=t.smtp_provider_add=void 0;const n=r(2328);t.smtp_provider_add={_id:(0,n.objectID)("p"),code:"smtpproadd",name:"Add SMTP Email Providers",message:"Enable Adding of SMTP Email Providers to Database",global_flag:!0},t.smtp_provider_edit={_id:(0,n.objectID)("p"),code:"smtpproedit",name:"Edit SMTP Email Providers",message:"Enable Editing of SMTP Email Providers in Database",global_flag:!0},t.smtp_provider_rm={_id:(0,n.objectID)("p"),code:"smtpprorm",name:"Remove SMTP Email Providers",message:"Enable Removal of SMTP Email Providers from Database",global_flag:!0}},6228:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(7375),o=r(7375);t.default={accept:{viewer:n.viewer_add,contentMgr:n.content_mgr_add,mods:n.mod_add,manager:n.mgr_add},promote:{contentMgr:o.self_content_mgr_add,mods:o.self_mod_add,manager:o.self_mgr_add}},t.map=[n.viewer_add,n.content_mgr_add,n.mod_add,n.mgr_add,o.self_content_mgr_add,o.self_mod_add,o.self_mgr_add]},7375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.self_mgr_add=t.self_mod_add=t.self_content_mgr_add=t.mgr_add=t.mod_add=t.content_mgr_add=t.viewer_add=void 0;const n=r(2328);t.viewer_add={_id:(0,n.objectID)("p"),code:"usraddvwr",name:"Add Viewer",message:"Enable Accepting of Requests for Viewers and its Delegates",global_flag:!0},t.content_mgr_add={_id:(0,n.objectID)("p"),code:"usraddcntmgr",name:"Add Content Managers",message:"Enable Accepting of Requests for Content Managers and its Delegates",global_flag:!0},t.mod_add={_id:(0,n.objectID)("p"),code:"usraddmdtr",name:"Add Moderators",message:"Enable Accepting of Requests for Moderators and its Delegates",global_flag:!0},t.mgr_add={_id:(0,n.objectID)("p"),code:"usraddmgr",name:"Add Managers",message:"Enable Accepting of Requests for Managers and its Delegates",global_flag:!0},t.self_content_mgr_add={_id:(0,n.objectID)("p"),code:"usrpmtcntmgr",name:"Promote to Content Managers",message:"Enable Promoting of Users to Content Managers without their Request and its Delegates",global_flag:!0},t.self_mod_add={_id:(0,n.objectID)("p"),code:"usrpmtmdtr",name:"Promote to Moderators",message:"Enable Promoting of Users to Moderators without their Request and its Delegates",global_flag:!0},t.self_mgr_add={_id:(0,n.objectID)("p"),code:"usrpmtmgr",name:"Promote to Manager",message:"Enable Promoting of Users to Managers without their Request and its Delegates",global_flag:!0}},883:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(2105);t.default={viewer:n.viewer_blist,contentMgr:n.content_mgr_blist,mods:n.mod_blist,manager:n.mgr_blist},t.map=[n.viewer_blist,n.content_mgr_blist,n.mod_blist,n.mgr_blist]},2105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mgr_blist=t.mod_blist=t.content_mgr_blist=t.viewer_blist=void 0;const n=r(2328);t.viewer_blist={_id:(0,n.objectID)("p"),code:"usrblistvwr",name:"Blacklist Viewer",message:"Enable Blacklisting of Viewers and its Delegates",global_flag:!0},t.content_mgr_blist={_id:(0,n.objectID)("p"),code:"usrblistcntmgr",name:"Blacklist Content Managers",message:"Enable Blacklisting of Content Managers and its Delegates",global_flag:!0},t.mod_blist={_id:(0,n.objectID)("p"),code:"usrblistmod",name:"Blacklist Moderators",message:"Enable Blacklisting of Moderators and its Delegates",global_flag:!0},t.mgr_blist={_id:(0,n.objectID)("p"),code:"usrblistmgr",name:"Blacklist Managers",message:"Enable Blacklisting of Managers and its Delegates",global_flag:!0}},8384:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const i=a(r(6228)),s=a(r(6076)),l=a(r(4540)),u=a(r(883));t.default={add:i.default,remove:s.default,modify:l.default,blacklist:u.default},t.map=[...i.map,...s.map,...u.map,...l.map]},4540:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4999),o=r(4999),a=r(4999),i=r(4999);t.default={viewer:{policy:n.viewer_policies,scope:n.viewer_scope,restrict:n.viewer_restrict},contentMgr:{policy:o.content_mgr_policies,scope:o.content_mgr_scope,restrict:o.content_mgr_restrict},mods:{policy:a.mods_policies,scope:a.mods_scope,restrict:a.mods_restrict},manager:{policy:i.mgr_policies,scope:i.mgr_scope,restrict:i.mgr_restrict}};const s=[n.viewer_policies,n.viewer_scope,n.viewer_restrict],l=[o.content_mgr_policies,o.content_mgr_scope,o.content_mgr_restrict],u=[a.mods_policies,a.mods_scope,a.mods_restrict],d=[i.mgr_policies,i.mgr_scope,i.mgr_restrict];t.map=[...s,...l,...u,...d]},4999:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mgr_restrict=t.mgr_scope=t.mgr_policies=t.mods_restrict=t.mods_scope=t.mods_policies=t.content_mgr_restrict=t.content_mgr_scope=t.content_mgr_policies=t.viewer_restrict=t.viewer_scope=t.viewer_policies=void 0;const n=r(2328);t.viewer_policies={_id:(0,n.objectID)("p"),code:"usrpolvwr",name:"Edit Policies of Viewer",message:"Enable Granting/Removing Policies to Viewers and its Delegates",global_flag:!0},t.viewer_scope={_id:(0,n.objectID)("p"),code:"usrscpvwr",name:"Edit Scopes of Viewers",message:"Enable Granting/Removing of Scopes to Viewers and its Delegates",global_flag:!0},t.viewer_restrict={_id:(0,n.objectID)("p"),code:"usrrestvwr",name:"Restrict Viewers",message:"Restrict Users and its Delegates",global_flag:!0},t.content_mgr_policies={_id:(0,n.objectID)("p"),code:"usrpolcntmgr",name:"Edit Policies of Content Manager",message:"Enable Granting/Removing Policies to Content Managers and its Delegates",global_flag:!0},t.content_mgr_scope={_id:(0,n.objectID)("p"),code:"usrscpcntmgr",name:"Edit Scopes of Content Managers",message:"Enable Granting/Removing of Scopes to Content Managers and its Delegates",global_flag:!0},t.content_mgr_restrict={_id:(0,n.objectID)("p"),code:"usrrestcntmgr",name:"Restrict Content Managers",message:"Restrict Content Managers and its Delegates",global_flag:!0},t.mods_policies={_id:(0,n.objectID)("p"),code:"usrpolmdtr",name:"Edit Policies of Moderators",message:"Enable Granting/Removing Policies to Moderators and its Delegates",global_flag:!0},t.mods_scope={_id:(0,n.objectID)("p"),code:"usrscpmdtr",name:"Edit Scopes of Moderators",message:"Enable Granting/Removing of Scopes to Moderators and its Delegates",global_flag:!0},t.mods_restrict={_id:(0,n.objectID)("p"),code:"usrrestmdtr",name:"Restrict Moderators",message:"Restrict Moderators and its Delegates",global_flag:!0},t.mgr_policies={_id:(0,n.objectID)("p"),code:"usrpolmgr",name:"Edit Policies of Managers",message:"Enable Granting/Removing Policies to Managers and its Delegates",global_flag:!0},t.mgr_scope={_id:(0,n.objectID)("p"),code:"usrscpmgr",name:"Edit Scopes of Managers",message:"Enable Granting/Removing of Scopes to Managers and its Delegates",global_flag:!0},t.mgr_restrict={_id:(0,n.objectID)("p"),code:"usrrestmgr",name:"Restrict Managers",message:"Restrict Managers and its Delegates",global_flag:!0}},6076:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4853);t.default={viewer:n.viewer_rm,contentMgr:n.content_mgr_rm,mod:n.mods_rm,manager:n.mgr_rm},t.map=[n.viewer_rm,n.content_mgr_rm,n.mods_rm,n.mgr_rm]},4853:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mgr_rm=t.mods_rm=t.content_mgr_rm=t.viewer_rm=void 0;const n=r(2328);t.viewer_rm={_id:(0,n.objectID)("p"),code:"usrrmvwr",name:"Remove Viewer",message:"Enable Removal of Viewers and its Delegates",global_flag:!0},t.content_mgr_rm={_id:(0,n.objectID)("p"),code:"usrrmcntmgr",name:"Remove Content Managers",message:"Enable Removal of Content Managers and Delegates",global_flag:!0},t.mods_rm={_id:(0,n.objectID)("p"),code:"usrrmmdtr",name:"Remove Moderators",message:"Enable Removal of Moderators and Delegates",global_flag:!0},t.mgr_rm={_id:(0,n.objectID)("p"),code:"usrrmmgr",name:"Remove Managers",message:"Enable Removal of Managers and Delegates",global_flag:!0}},3969:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.map=t.owner=t.manager=t.moderator=t.contentMgr=t.viewer=void 0;const o=r(2328),a=n(r(7260)),i=n(r(8791)),s=n(r(3269)),l=n(r(3248)),u={viewer:(0,o.objectID)("r"),contentMgr:(0,o.objectID)("r"),moderator:(0,o.objectID)("r"),manager:(0,o.objectID)("r"),owner:(0,o.objectID)("r")};t.viewer={_id:u.viewer,name:"Viewer",alias:"Viewer",type:"main",parent_role:u.contentMgr,allowed_policies:[]},t.contentMgr={_id:u.contentMgr,name:"Content Manager",alias:"Content Manager",type:"main",parent_role:u.moderator,child_role:t.viewer._id,allowed_policies:l.default},t.moderator={_id:u.moderator,name:"Moderator",alias:"Moderator",type:"main",parent_role:u.owner,child_role:u.contentMgr,allowed_policies:s.default},t.manager={_id:u.manager,name:"Manager",alias:"Manager",type:"main",parent_role:u.owner,child_role:u.moderator,allowed_policies:i.default},t.owner={_id:u.owner,name:"Owner",alias:"Owner",type:"main",child_role:u.manager,allowed_policies:a.default},t.map=[t.viewer,t.contentMgr,t.moderator,t.owner]},3248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663),o=[n.users.add.accept.viewer._id,n.users.blacklist.viewer._id,n.users.modify.viewer.policy._id,n.users.modify.viewer.restrict._id,n.users.modify.viewer.scope._id,n.frontends.edit._id];t.default=o},8791:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663),o=[n.users.add.accept.contentMgr._id,n.users.add.accept.mods._id,n.users.add.accept.viewer._id,n.users.blacklist.manager._id,n.users.blacklist.mods._id,n.users.blacklist.viewer._id,n.users.modify.contentMgr.policy._id,n.users.modify.contentMgr.restrict._id,n.users.modify.contentMgr.scope._id,n.users.modify.mods.policy._id,n.users.modify.mods.restrict._id,n.users.modify.mods.scope._id,n.users.modify.viewer.policy._id,n.users.modify.viewer.restrict._id,n.users.modify.viewer.scope._id,n.frontends.edit._id,n.globalSettings.edit._id,n.roles.add._id,n.roles.edit._id,n.roles.remove._id,n.policy.edit._id,n.smtpProviders.add._id,n.smtpProviders.edit._id,n.smtpProviders.remove._id,n.smtpMailers.add._id,n.smtpMailers.edit._id,n.smtpMailers.remove._id];t.default=o},3269:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663),o=[n.users.add.accept.contentMgr._id,n.users.add.accept.viewer._id,n.users.blacklist.manager._id,n.users.blacklist.viewer._id,n.users.modify.contentMgr.policy._id,n.users.modify.contentMgr.restrict._id,n.users.modify.contentMgr.scope._id,n.users.modify.viewer.policy._id,n.users.modify.viewer.restrict._id,n.users.modify.viewer.scope._id];t.default=o},7260:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663).map.map((e=>e._id));t.default=n},2946:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(5001),l=r(4523),u=o.default.Router();u.post("/add",((e,t)=>{const{alias:r,client_id:n,client_secret:o,redirect_uri:l,email:u}=e.body;if((0,s.isUndefined)([r,n,o,l,u]))(0,a.badRequest)(t,"alias, client_id, client_secret, email","Request Body");else{const e={_id:(0,s.objectID)("c"),alias:r,client_id:n,client_secret:o,redirect_uri:l,email:u};i.Credentials.create(e).then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))}})),u.post("/reset",((e,t)=>{i.Credentials.clearAll().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new l.EndpointGenerator(t,u).serve())),t.default=u},1279:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=n(r(9183)),i=n(r(1807)),s=n(r(2946)),l=n(r(6010)),u=r(4523),d=o.default.Router();d.use("/policies",a.default),d.use("/roles",i.default),d.use("/credentials",s.default),d.use("/scopes",l.default),d.post("/endpoints",((e,t)=>new u.EndpointGenerator(t,d).serve())),t.default=d},9183:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(5663),l=r(4523),u=o.default.Router();u.post("/add",((e,t)=>{const r=[],n=[];s.map.forEach((e=>{i.Policies.create(e).then((e=>{r.push(e),n.push(!0)})).catch((e=>{console.log(e),n.push(!1)}))})),n.includes(!1)?(0,a.internalServerError)(t,"Database","Some Internal Error Occured, Not all Records have been Added to Database"):(0,a.okResponse)(t,"Successfully Posted all the Policy Details to Database")})),u.post("/status",((e,t)=>{i.Policies.mapCheck().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/reset",((e,t)=>{i.Policies.clearAll().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new l.EndpointGenerator(t,u).serve())),t.default=u},1807:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(3969),l=r(4523),u=o.default.Router();u.post("/add",((e,t)=>{const r=[],n=[];s.map.forEach((e=>{i.Roles.create(e).then((e=>{r.push(e),n.push(!0)})).catch((e=>{console.log(e),n.push(!1)}))})),n.includes(!1)?(0,a.internalServerError)(t,"Database","Some Internal Error Occured, Not all Records have been Added to Database"):(0,a.okResponse)(t,"Successfully Posted all the Roles Details to Database")})),u.post("/status",((e,t)=>{i.Roles.mapCheck().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/reset",((e,t)=>{i.Roles.clearAll().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new l.EndpointGenerator(t,u).serve())),t.default=u},6010:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(4523),l=r(5001),u=o.default.Router();u.post("/add",((e,t)=>{const{name:r,drive_id:n,credential_id:o}=e.body;(0,l.isUndefined)([r,n,o])?(0,a.badRequest)(t,"name, drive_id, credential_id","Request Body as JSON"):i.Credentials.checkID(o).then((e=>{if(e){const e={_id:(0,l.objectID)("scope"),name:r,added_at:Date.now(),drive_id:n,related_to:[o]};i.Scopes.create(e).then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))}else(0,a.notFound)(t,"Credential ID Not found in the Database, Kindly Send the Correct ID")})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/status",((e,t)=>{i.Scopes.find({}).then((e=>{e.length>0?(0,a.okResponse)(t,e):(0,a.notFound)(t,"No Scopes Saved or Found in the Database")})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/reset",((e,t)=>{i.Scopes.clearAll().then((e=>{(0,a.okResponse)(t,e),t.status(200).json(e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new s.EndpointGenerator(t,u).serve())),t.default=u},9796:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(8030),i=n(r(7331)),s=r(1849),l=n(r(1279)),u=n(r(9527)),d=r(4523),c=o.default.Router();c.use("/setup",[i.default,a.checkSecretPass],l.default),c.use("/login",u.default),c.get("/",((e,t)=>{(0,s.okResponse)(t,"Server Successfully Started")})),c.post("/endpoints",((e,t)=>new d.EndpointGenerator(t,c).serve())),t.default=c},8479:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(3100),i=r(9432),s=r(3100),l=r(7382),u=o.default.Router();u.get("/auth/",((e,t)=>{a.normalAccountHandler.generateOauth(e,t,[...s.oauthScopes.drive,...s.oauthScopes.iam])})),u.post("/sample/",((e,t)=>{l.Credentials.find({}).then((e=>{a.oauthHelpers.resolveToken(e[0]._id,[...s.oauthScopes.drive,...s.oauthScopes.iam]).then((e=>{i.iam.projects.list(e.tokens[0]).then((r=>{t.json({res2:r,result:e})})).catch((e=>{t.send(e)}))})).catch((e=>{t.send(e)}))})).catch((e=>{t.send(e)}))})),t.default=u},9527:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=n(r(8479)),i=o.default.Router();i.use("/google/",a.default),t.default=i},8305:e=>{e.exports=require("@godaddy/terminus")},2167:e=>{e.exports=require("axios")},7096:e=>{e.exports=require("bcrypt")},5666:e=>{e.exports=require("crypto-js")},9387:e=>{e.exports=require("dot-prop")},5142:e=>{e.exports=require("dotenv")},6860:e=>{e.exports=require("express")},2821:e=>{e.exports=require("express-mongo-sanitize")},6452:e=>{e.exports=require("got")},7806:e=>{e.exports=require("helmet")},1185:e=>{e.exports=require("mongoose")},754:e=>{e.exports=require("nanoid")},5175:e=>{e.exports=require("node-webcrypto-ossl")},9103:e=>{e.exports=require("query-string")},5828:e=>{e.exports=require("uuid")},8285:e=>{e.exports=require("x-xss-protection")},3685:e=>{e.exports=require("http")}},t={},r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(3864);for(var n in r)this[n]=r[n];r.__esModule&&Object.defineProperty(this,"__esModule",{value:!0})})(); \ No newline at end of file +(()=>{"use strict";var e={3864:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5142)),a=n(r(412)),i=n(r(8130)),s=r(819);o.default.config(),(0,s.healthCheckService)(a.default);const l=process.env.PORT;try{a.default.listen(l||3e3,(()=>{console.log("Server Started"),console.log("Connecting to Database"),i.default.connect().then((e=>{e?console.log("Database Connected"):(console.log("No Database Url is Found in Environment Variables"),a.default.close())})).catch((e=>{console.log(`${e.name}: ${e.message}`),a.default.close()}))})),a.default.once("error",(e=>{console.log("There was an error starting the server in the error listener:",e),a.default.close()}))}catch(e){console.log("There was an error starting the server:",e),a.default.close()}},4961:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(1880);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},1880:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7185));t.default=(0,o.model)("BlacklistedUser",a.default)},7185:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4621)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId,ref:"User"},name:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0},blacklisted_from:{type:Number,required:!0},role:[{scope:{type:o.Schema.Types.ObjectId,ref:"Scope",required:!0},role:{type:o.Schema.Types.ObjectId,ref:"Role",required:!0}}],flagged_by:{type:o.Schema.Types.ObjectId,ref:"User",required:!0}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},4621:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},2598:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6325);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},6325:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(2919));t.default=(0,o.model)("Credential",a.default)},2919:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(3361)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},alias:{type:String,required:!0,hash:!0},client_id:{type:String,required:!0,encrypt:!0},client_secret:{type:String,required:!0,encrypt:!0},redirect_uri:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0,unique:!0}});s.plugin((0,i.cryptoPlugin)()),s.plugin((0,i.hashPlugin)()),t.default=(0,a.default)(s)},3361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkID=t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}function a(e){return new Promise(((t,r)=>{this.findById(e).then((e=>{t(!!e)})).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}t.clearAll=o,t.checkID=a,t.default=function(e){return e.statics.clearAll=o,e.statics.checkID=a,e}},3609:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(3528);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},3528:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1146));t.default=(0,o.model)("Frontend",a.default)},1146:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7860)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},domain:{type:String,required:!0,unique:!0},name:{type:String,required:!0},settings:{specifics:[{setting:{type:o.Schema.Types.ObjectId,ref:"GlobalSetting"},flag:{type:String||Boolean||Number,required:!0}}],default_mailer:{type:o.Schema.Types.ObjectId,ref:"SMTPMailer",required:!1},disallowed_roles:{type:o.Schema.Types.ObjectId,ref:"Role"},allowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],disallowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}]}});t.default=(0,a.default)(i)},7860:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getFrontendUrls=t.clearAll=void 0;const o=r(9593);function a(){return(0,o.clearCollection)(this)}function i(){return n(this,void 0,void 0,(function*(){return this.find({},"_id domain name")}))}t.clearAll=a,t.getFrontendUrls=i,t.default=function(e){return e.statics.getFrontendUrls=i,e.statics.clearAll=a,e}},5576:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(4079);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},4079:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(575));t.default=(0,o.model)("GlobalSetting",a.default)},575:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(2670)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},message:{type:String,required:!0},global_flag:{type:Boolean||String||Number||o.Schema.Types.ObjectId,refPath:"reference",required:!0},reference:{type:String,enum:["SMTPMailer","SMTPProvider","MailTemplates"]}});t.default=(0,a.default)(i)},2670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},7382:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SMTPMailers=t.SMTPProviders=t.GlobalSettings=t.Frontends=t.Policies=t.Roles=t.Tokens=t.Credentials=t.BlacklistUsers=t.PendingUsers=t.Scopes=t.ServiceAccs=t.Sessions=t.Users=void 0;var o=r(9500);Object.defineProperty(t,"Users",{enumerable:!0,get:function(){return n(o).default}});var a=r(8183);Object.defineProperty(t,"Sessions",{enumerable:!0,get:function(){return n(a).default}});var i=r(5525);Object.defineProperty(t,"ServiceAccs",{enumerable:!0,get:function(){return n(i).default}});var s=r(4033);Object.defineProperty(t,"Scopes",{enumerable:!0,get:function(){return n(s).default}});var l=r(8378);Object.defineProperty(t,"PendingUsers",{enumerable:!0,get:function(){return n(l).default}});var u=r(4961);Object.defineProperty(t,"BlacklistUsers",{enumerable:!0,get:function(){return n(u).default}});var d=r(2598);Object.defineProperty(t,"Credentials",{enumerable:!0,get:function(){return n(d).default}});var c=r(1951);Object.defineProperty(t,"Tokens",{enumerable:!0,get:function(){return n(c).default}});var f=r(6482);Object.defineProperty(t,"Roles",{enumerable:!0,get:function(){return n(f).default}});var p=r(148);Object.defineProperty(t,"Policies",{enumerable:!0,get:function(){return n(p).default}});var _=r(3609);Object.defineProperty(t,"Frontends",{enumerable:!0,get:function(){return n(_).default}});var m=r(5576);Object.defineProperty(t,"GlobalSettings",{enumerable:!0,get:function(){return n(m).default}});var g=r(4652);Object.defineProperty(t,"SMTPProviders",{enumerable:!0,get:function(){return n(g).default}});var v=r(4901);Object.defineProperty(t,"SMTPMailers",{enumerable:!0,get:function(){return n(v).default}})},8378:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(1566);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},1566:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(9838));t.default=(0,o.model)("PendingUser",a.default)},9838:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5978)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0},message:{type:String,required:!0},role:{type:o.Schema.Types.ObjectId,ref:"Role",required:!0},scopes:[{type:o.Schema.Types.ObjectId,ref:"Scope"}],requested_at:{type:Number,required:!0,default:Date.now},accepted:{type:Boolean,default:!1},accepted_at:{type:Number,default:Date.now}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},5978:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},148:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(7206);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},7206:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(6357));t.default=(0,o.model)("Policy",a.default)},6357:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7208)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},code:{type:String,required:!0,unique:!0},message:{type:String,required:!0},global_flag:{type:Boolean,required:!0}});t.default=(0,a.default)(i)},7208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapCheck=t.clearAll=void 0;const n=r(9593),o=r(5663);function a(){return(0,n.clearCollection)(this)}function i(){return new Promise(((e,t)=>{const r={success:!1,data:!1,error:null};this.find({}).then((t=>{const n=[];r.success=!0;for(let e=0;ee._id===r._id));if(a&&r&&a._id===r._id){const e=a.name===r.name,t=a.message===r.message;n.push(e&&t)}else n.push(!1)}n.includes(!1)?r.data=!1:r.data=!0,e(r)})).catch((e=>{r.error=e,t(new Error(`${e.name}: ${e.message}`))}))}))}t.clearAll=a,t.mapCheck=i,t.default=function(e){return e.statics.clearAll=a,e.statics.mapCheck=i,e}},6482:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(4407);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},4407:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(2314));t.default=(0,o.model)("Role",a.default)},2314:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1241)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},alias:{type:String,required:!0},type:{type:String,enum:["main","sub"],required:!0},delgates_from:{type:o.Schema.Types.ObjectId||null,ref:"Role"},allowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],disallowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],specific_settings:[{setting:{type:o.Schema.Types.ObjectId,ref:"GlobalSetting"},flag:{type:String||Boolean||Number,required:!0}}]});t.default=(0,a.default)(i)},1241:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapCheck=t.clearAll=void 0;const n=r(9593),o=r(3969);function a(){return(0,n.clearCollection)(this)}function i(){return new Promise(((e,t)=>{const r={success:!1,data:!1,error:null};this.find({}).then((t=>{const n=[];r.success=!0;for(let e=0;ee._id===r._id));if(a&&r&&a._id===r._id){const e=a.name===r.name,t=a.allowed_policies.length===r.allowed_policies.length;n.push(e&&t)}else n.push(!1)}n.includes(!1)?r.data=!1:r.data=!0,e(r)})).catch((e=>{r.error=e,t(new Error(`${e.name}: ${e.message}`))}))}))}t.clearAll=a,t.mapCheck=i,t.default=function(e){return e.statics.clearAll=a,e.statics.mapCheck=i,e}},4033:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(1675);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},1675:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5102));t.default=(0,o.model)("Scope",a.default)},5102:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7015)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},added_at:{type:Number,required:!0,default:Date.now},drive_id:{type:String,required:!0,unique:!0},disallowed_frontends:[{type:o.Schema.Types.ObjectId,ref:"Frontend"}],related_to:[{type:o.Schema.Types.ObjectId,ref:"Credential"}]});t.default=(0,a.default)(i)},7015:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},5525:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(5355);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},5355:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7981));t.default=(0,o.model)("ServiceAccount",a.default)},7981:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(7333)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},project_id:{type:String,required:!0},unique_id:{type:String,required:!0},private_key:{id:{type:String,required:!0},key:{type:String,required:!0,encrypt:!0}},client:{id:{type:String,required:!0,encrypt:!0},email:{type:String,required:!0}},related_to:{type:o.Schema.Types.ObjectId,ref:"Credential",required:!0}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},7333:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},8183:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6570);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},6570:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(691));t.default=(0,o.model)("Session",a.default)},691:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4436)),i=new o.Schema({_id:{type:o.Schema.Types.ObjectId},ip:{type:String,required:!0},user_id:{type:o.Schema.Types.ObjectId,ref:"User",required:!0},frontend:{type:o.Schema.Types.ObjectId,ref:"Frontend",required:!0},token_secret:{type:String,required:!0,unique:!0,encrypt:!0},issued_at:{type:Number,required:!0,default:Date.now}});t.default=(0,a.default)(i)},4436:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},4901:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(3263);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},3263:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4125));t.default=(0,o.model)("SMTPMailer",a.default)},4125:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5280)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0},email:{type:String,required:!0},password:{type:String,required:!0,encrypt:!0},type:{type:String,enum:["gmail","others"],required:!0},provider:{type:o.Schema.Types.ObjectId,ref:"SMTPProvider"},gmail_data:{type:Object}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},5280:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},4652:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(8541);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},8541:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(5006));t.default=(0,o.model)("SMTPProvider",a.default)},5006:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1708)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0,unique:!0},alias:{type:String,required:!0},smtp:{url:{type:String,required:!0},port:{type:Number,required:!0}},imap:{url:{type:String,required:!0},port:{type:Number,required:!0}},dkim_key:{type:String,required:!0,encrypt:!0}});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},1708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},1951:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(634);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},634:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(4446));t.default=(0,o.model)("Token",a.default)},4446:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(1531)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},token:{type:String,required:!0,encrypt:!0},type:{type:String,required:!0},related_to:{type:o.Schema.Types.ObjectId||String,refPath:"ref_model"},ref_model:{type:String,enum:["Credential","ServiceAccount"]},expires_at:{type:Number,required:!0},scopes:[{type:String,required:!0}],website:{type:String,required:!0},additional_tokens:[{type:{type:String},token:{type:String}}]});s.plugin((0,i.cryptoPlugin)()),t.default=(0,a.default)(s)},1531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},9500:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(8399);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},8399:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(709));t.default=(0,o.model)("User",a.default)},709:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(1185),a=n(r(6888)),i=r(9661),s=new o.Schema({_id:{type:o.Schema.Types.ObjectId},name:{type:String,required:!0,encrypt:!0},email:{type:String,lowercase:!0,required:!0,unique:!0},avatar:{type:String,lowercase:!0},registered_at:{type:Number,required:!0,default:Date.now},verified_at:{type:Number,required:!0},token_hash:{type:String,required:!0,encrypt:!0},restricted:{type:Boolean,default:!1},role:[{scope:{type:o.Schema.Types.ObjectId,ref:"Scope",required:!0},role:{type:o.Schema.Types.ObjectId,ref:"Role",required:!0}}],password:{type:String,hash:!0},allowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}],disallowed_policies:[{type:o.Schema.Types.ObjectId,ref:"Policy"}]});s.plugin((0,i.cryptoPlugin)()),s.plugin((0,i.hashPlugin)()),t.default=(0,a.default)(s)},6888:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearAll=void 0;const n=r(9593);function o(){return(0,n.clearCollection)(this)}t.clearAll=o,t.default=function(e){return e.statics.clearAll=o,e}},7644:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6199);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},6199:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2167)).default.create();t.default=o},4041:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5666)),a={str:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return o.default.AES.decrypt(e,t).toString(o.default.enc.Utf8);throw new Error("Passphrase not set in Variables, Kindly Set that")},obj:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return JSON.parse(o.default.AES.decrypt(e,t).toString(o.default.enc.Utf8)).data;throw new Error("Passphrase not set in Variables, Kindly Set that")}};t.default=a},6257:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5666)),a={str:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return o.default.AES.encrypt(e,t).toString();throw new Error("Passphrase not set in Variables, Kindly Set that")},obj:e=>{const t=process.env.GLOBAL_PASSPHRASE;if(t)return o.default.AES.encrypt(JSON.stringify(e),t).toString();throw new Error("Passphrase not set in Variables, Kindly Set that")}};t.default=a},248:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=void 0;var o=r(6257);Object.defineProperty(t,"encrypt",{enumerable:!0,get:function(){return n(o).default}});var a=r(4041);Object.defineProperty(t,"decrypt",{enumerable:!0,get:function(){return n(a).default}})},7365:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=o(r(1185));t.default={connect:()=>n(void 0,void 0,void 0,(function*(){const e=process.env.DBURL;return e?yield a.default.connect(e,{useUnifiedTopology:!0,bufferCommands:!1,bufferMaxEntries:0,useNewUrlParser:!0,useCreateIndex:!0}).then((e=>e)):new Promise((e=>e(!1)))})),close:()=>new Promise(((e,t)=>{a.default.connection.close().then((()=>{console.log("Successfully Closed the Database Connection"),e()})).catch((()=>{t(new Error("Failed to Close Database Connection"))}))}))}},411:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeFields=t.encodeFields=void 0;const o=n(r(9387));t.encodeFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(o.default.has(e,t)){const n=o.default.get(e,t);if("string"==typeof n){const e=Buffer.from(n).toString("base64");r=o.default.set(r,t,e)}}})),r},t.decodeFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(o.default.has(e,t)){const n=o.default.get(e,t);let a;"string"==typeof n&&(a=Buffer.from(n,"base64").toString("utf8")),r=o.default.set(r,t,a)}})),r}},8591:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decryptFields=t.encryptFields=void 0;const o=r(248),a=n(r(9387));t.encryptFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(a.default.has(e,t)){const n=a.default.get(e,t);let i;if("string"==typeof n)i=o.encrypt.str(n);else{const e={data:n};i=o.encrypt.obj(e)}r=a.default.set(r,t,i)}})),r},t.decryptFields=function(e,t){let r=e;return t&&t.forEach((t=>{if(a.default.has(e,t)){const n=a.default.get(e,t);let i;"string"==typeof n&&(i=o.decrypt.str(n)),r=a.default.set(r,t,i)}})),r}},3289:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(9387));t.default=function(e,t){const r=[];return e.eachPath(((e,n)=>{const a=Object.keys(n),i=Object.create(n);if(a&&i){const n=i.options;o.default.has(n,t)&&r.push(e)}})),r}},9376:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7096)),a=n(r(9387));t.default=function(e,t){return new Promise(((r,n)=>{try{if(t){const i=new Promise(((r,n)=>{let i=e;t.forEach(((s,l)=>{if(a.default.has(e,s)){const t=a.default.get(e,s);"string"==typeof t&&o.default.hash(t,10).then((e=>{i=a.default.set(i,s,e)})).catch((e=>{n(e)}))}l===t.length-1&&r(i)}))}));i.then((e=>r(e))).catch((e=>{console.log(e),n(e)}))}}catch(e){console.log(e),n(e)}}))}},4458:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.hashString=t.fieldsPicker=t.decodeFields=t.encodeFields=t.decryptFields=t.encryptFields=void 0;var o=r(8591);Object.defineProperty(t,"encryptFields",{enumerable:!0,get:function(){return o.encryptFields}}),Object.defineProperty(t,"decryptFields",{enumerable:!0,get:function(){return o.decryptFields}});var a=r(411);Object.defineProperty(t,"encodeFields",{enumerable:!0,get:function(){return a.encodeFields}}),Object.defineProperty(t,"decodeFields",{enumerable:!0,get:function(){return a.decodeFields}});var i=r(3289);Object.defineProperty(t,"fieldsPicker",{enumerable:!0,get:function(){return n(i).default}});var s=r(9376);Object.defineProperty(t,"hashString",{enumerable:!0,get:function(){return n(s).default}})},8130:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.clearCollection=t.default=void 0;var o=r(7365);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}});var a=r(9593);Object.defineProperty(t,"clearCollection",{enumerable:!0,get:function(){return a.clearCollection}})},8649:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(4458);t.default=function(){return e=>{const t=(0,n.fieldsPicker)(e,"base64encode");e.pre("validate",(function(e){const r=(0,n.encodeFields)(this,t);this.set(r),e()})),e.post("init",(function(){return(0,n.decodeFields)(this,t)}))}}},6e3:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(4458);t.default=function(){return e=>{const t=(0,n.fieldsPicker)(e,"encrypt");e.pre("validate",(function(e){const r=(0,n.encryptFields)(this,t);this.set(r),e()})),e.post("init",(function(){return(0,n.decryptFields)(this,t)}))}}},5447:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(4458);t.default=function(){return e=>{const t=(0,n.fieldsPicker)(e,"hash");e.pre("validate",(function(e){(0,n.hashString)(this,t).then((t=>{this.set(t),e()})).catch((e=>{throw console.log(e),new Error("Password Hashing Failed")}))}))}}},9661:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.hashPlugin=t.base64EncodePlugin=t.cryptoPlugin=void 0;var o=r(6e3);Object.defineProperty(t,"cryptoPlugin",{enumerable:!0,get:function(){return n(o).default}});var a=r(8649);Object.defineProperty(t,"base64EncodePlugin",{enumerable:!0,get:function(){return n(a).default}});var i=r(5447);Object.defineProperty(t,"hashPlugin",{enumerable:!0,get:function(){return n(i).default}})},3275:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return new Promise(((t,r)=>{e.deleteMany({}).then((()=>{t({success:!0,data:"Successfully Cleared the Collection",error:null})})).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}},9593:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.clearCollection=void 0;var o=r(3275);Object.defineProperty(t,"clearCollection",{enumerable:!0,get:function(){return n(o).default}})},5754:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(3853),o=r(4015),a=r(6724),i=r(860);t.default={files:n.api,drives:o.api,about:a.api,permissions:i.api}},5485:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={get:"https://www.googleapis.com/drive/v3/about"}},7580:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["user","storageQuota","maxUploadSize","canCreateTeamDrives","canCreateDrives"]},6724:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(5485);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(3412);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},2629:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5485)),a=r(1084),i=n(r(7580)),s=r(1084);t.default=function(e){const t={fields:(0,s.constructFields)(i.default)};return a.googleApiRequest.get(o.default.get,e,t)}},3412:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2629));t.default={get:o.default}},6073:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:"https://www.googleapis.com/drive/v3/drives",get:e=>`https://www.googleapis.com/drive/v3/drives/${e}`,create:"https://www.googleapis.com/drive/v3/drives",update:e=>`https://www.googleapis.com/drive/v3/drives/${e}`}},6650:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["name","id","capabilities","createdTime","hidden","restrictions"]},4015:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(6073);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(9039);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},8900:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(5828),i=r(1084),s=n(r(6650)),l=r(1084);t.default=function(e,t){const r={requestId:(0,a.v4)(),fields:(0,l.constructFields)(s.default)},n=o.default.create;return i.googleApiRequest.post(n,e,t,r)}},8687:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(1084),i=n(r(6650)),s=r(1084);t.default=function(e,t){const r={fields:(0,s.constructFields)(i.default)};return a.googleApiRequest.get(o.default.get(t),e,r)}},9039:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(8687)),a=n(r(909)),i=n(r(8900)),s=n(r(3715));t.default={get:o.default,list:a.default,create:i.default,update:s.default}},909:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(1084),i=n(r(6650)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default,"drives"),pageToken:t||"",q:r||""};return a.googleApiRequest.get(o.default.list,e,n)}},3715:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6073)),a=r(1084),i=n(r(6650)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.update(t);return a.googleApiRequest.patch(l,e,r,n)}},1742:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:"https://www.googleapis.com/drive/v3/files",get:e=>`https://www.googleapis.com/drive/v3/files/${e}`,create:{metadata:"https://www.googleapis.com/drive/v3/files",upload:"https://www.googleapis.com/upload/drive/v3/files"},generateId:"https://www.googleapis.com/drive/v3/files/generateIds",delete:e=>`https://www.googleapis.com/drive/v3/files/${e}`}},3853:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.api=void 0;var o=r(1742);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}})},1825:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.api=t.scopes=void 0;var o=r(3918);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(o).default}});var a=r(5754);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(a).default}});var i=r(124);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(i).default}})},124:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(6724),o=r(860);t.default={about:n.methods,permissions:o.methods}},6166:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:e=>`https://www.googleapis.com/drive/v3/files/${e}/permissions`,get:(e,t)=>`https://www.googleapis.com/drive/v3/files/${e}/permissions/${t}`,create:e=>`https://www.googleapis.com/drive/v3/files/${e}/permissions`,delete:(e,t)=>`https://www.googleapis.com/drive/v3/files/${e}/permissions/${t}`,update:(e,t)=>`https://www.googleapis.com/drive/v3/files/${e}/permissions/${t}`}},5602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["id","type","emailAddress","role","domain","photoLink","permissionDetails"]},860:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(6166);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(3612);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},1875:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.create(t);return a.googleApiRequest.post(l,e,r,n)}},8910:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.delete(t,r);return a.googleApiRequest.delete(l,e,n)}},9104:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r){const n={fields:(0,s.constructFields)(i.default)},l=o.default.get(t,r);return a.googleApiRequest.get(l,e,n)}},3612:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(8915)),a=n(r(9104)),i=n(r(1875)),s=n(r(7949)),l=n(r(8910));t.default={list:o.default,get:a.default,create:i.default,update:s.default,delete:l.default}},8915:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t){const r={fields:(0,s.constructFields)(i.default,"permissions")},n=o.default.list(t);return a.googleApiRequest.get(n,e,r)}},7949:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6166)),a=r(1084),i=n(r(5602)),s=r(1084);t.default=function(e,t,r,n){const l={fields:(0,s.constructFields)(i.default)},u=o.default.delete(t,r);return a.googleApiRequest.patch(u,e,n,l)}},3918:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive.metadata","https://www.googleapis.com/auth/drive.appdata","https://www.googleapis.com/auth/drive.activity.readonly"]},1004:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.api=void 0;const n=r(6485),o=r(9887);t.api={projects:n.api,serviceAccount:o.api}},4e3:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.api=t.scopes=void 0;var o=r(8049);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(o).default}});var a=r(1004);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return a.api}});var i=r(8604);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(i).default}})},8604:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(6485),o=r(9887);t.default={projects:n.methods,serviceAccount:o.methods}},2741:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={list:"https://cloudresourcemanager.googleapis.com/v1/projects",get:e=>`https://cloudresourcemanager.googleapis.com/v1/projects/${e}`}},6485:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(2741);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(5794);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},5165:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2741)),a=r(1084);t.default=function(e,t){return a.googleApiRequest.get(o.default.get(t),e)}},5794:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(5165)),a=n(r(6574));t.default={get:o.default,list:a.default}},6574:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(2741)),a=r(1084);t.default=function(e){return a.googleApiRequest.get(o.default.list,e)}},8049:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=["https://www.googleapis.com/auth/cloud-platform"]},6308:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={create:e=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts`,delete:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}`,disable:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}:disable`,enable:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}:enable`,get:(e,t)=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts/${t}`,list:e=>`https://iam.googleapis.com/v1/projects/${e}/serviceAccounts`}},9887:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.methods=t.api=void 0;var o=r(6308);Object.defineProperty(t,"api",{enumerable:!0,get:function(){return n(o).default}});var a=r(962);Object.defineProperty(t,"methods",{enumerable:!0,get:function(){return n(a).default}})},5214:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(754),a=n(r(6308)),i=r(1084),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",l=`${s}0123456789`,u=(0,o.customAlphabet)(s,6),d=(0,o.customAlphabet)(l,6);t.default=function(e,t,r){const n=`${u()}-${d()}-${d()}`,o=a.default.create(t),s={accountId:n,serviceAccount:r};return i.googleApiRequest.post(o,e,s)}},5798:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){const n=o.default.delete(t,r);return a.googleApiRequest.delete(n,e)}},2348:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){const n=o.default.disable(t,r);return a.googleApiRequest.post(n,e)}},9270:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){const n=o.default.enable(t,r);return a.googleApiRequest.post(n,e)}},7728:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t,r){return a.googleApiRequest.get(o.default.get(t,r),e)}},962:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(4817)),a=n(r(7728)),i=n(r(5214)),s=n(r(5798)),l=n(r(2348)),u=n(r(9270));t.default={list:o.default,get:a.default,create:i.default,delete:s.default,disable:l.default,enable:u.default}},4817:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6308)),a=r(1084);t.default=function(e,t){return a.googleApiRequest.get(o.default.list(t),e)}},9432:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.scopes=t.drive=t.iam=void 0;var o=r(4e3);Object.defineProperty(t,"iam",{enumerable:!0,get:function(){return n(o).default}});var a=r(1825);Object.defineProperty(t,"drive",{enumerable:!0,get:function(){return n(a).default}});var i=r(2009);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(i).default}})},2009:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(3918)),a=n(r(8049));t.default={drive:o.default,iam:a.default}},7273:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(7382),i=o(r(2861)),s=r(5001),l=r(248),u=r(5257),d=o(r(5750)),c=r(1849);t.default=function(e,t,r){const{creds:o,code:f,state:p}=e.query;if(console.log(f,o,String(p)),!f&&o)!function(e,t,r){a.Credentials.findById(t).then((t=>{if(t){const n=l.encrypt.str(String(t._id)),o=function(e,t,r){const n=encodeURIComponent(e.client_id),o=encodeURIComponent(e.redirect_uri),a=encodeURIComponent(r),s=(0,d.default)(t),l=`client_id=${n}&redirect_uri=${o}&response_type=code&scope=${encodeURIComponent(s)}&access_type=offline&state=${a}`;return`${i.default.authorize}?${l}`}(t,r,n);e.redirect(o)}else(0,c.notFound)(e,"Credential ID Not found in DB, Kindly Recheck")})).catch((t=>{(0,c.internalServerError)(e,t.name,t.message)}))}(t,String(o),r);else if(f&&p){const e=String(f);!function(e,t,r,o){a.Credentials.findById(t).then((t=>n(this,void 0,void 0,(function*(){if(t){const n=(0,d.default)(o);try{const i=yield(0,u.generateRefreshToken)(t,n,r);if(!i.refresh_token)throw new Error("No Refresh Token Found in Response, Kindly Retry");{const r=yield(0,u.generateAccessToken)(t,i.refresh_token),n=yield function(e,t,r,n){return new Promise(((o,i)=>{const u=Date.now();Promise.all([(0,s.objectID)("t"),(0,s.objectID)("t")]).then((([s,d])=>{const c=[{_id:s,token:l.encrypt.str(r.refresh_token),type:"refresh",related_to:e._id,scopes:t,ref_model:"Credential",expires_at:u+31536e8,website:"google.com"},{_id:d,token:l.encrypt.str(n.access_token),type:"access",related_to:e._id,scopes:t,ref_model:"Credential",expires_at:u+1e3*n.expires_in,website:"google.com"}];a.Tokens.insertMany(c).then((e=>{o(e)})).catch((e=>{i(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{console.log(e),i(new Error("Error Occured while Generating a UID"))}))}))}(t,o,i,r);(0,c.okResponse)(e,n)}}catch(t){console.log(t),(0,c.internalServerError)(e,"Token Generation",String(t))}}else(0,c.notFound)(e,"Credential ID Not found in DB, Kindly Recheck")})))).catch((t=>{(0,c.internalServerError)(e,t.name,t.message)}))}(t,l.decrypt.str(decodeURIComponent(String(p))),e,r)}else(0,c.badRequest)(t,"creds","Query Parameters")}},5257:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateAccessToken=t.generateRefreshToken=void 0;const o=n(r(7644)),a=n(r(2861));function i(e,t,r,n){return new Promise(((i,s)=>{const{url:l,params:u}=function(e,t,r,n){const o=a.default.generateToken;let i="";const s=encodeURIComponent(e.client_id),l=encodeURIComponent(e.client_secret),u=n?encodeURIComponent(n):"",d=encodeURIComponent(e.redirect_uri);return i+="access_token"===t?`client_id=${s}&client_secret=${l}&refresh_token=${r}&grant_type=refresh_token`:`client_id=${s}&client_secret=${l}&code=${r}&scopes=${u}&redirect_uri=${d}&grant_type=authorization_code`,{url:o,params:i}}(t,e,r,n);o.default.post(l,u,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{200===e.status?i(e.data):s(new Error("Error While Generating the Tokens"))})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))}))}t.generateRefreshToken=function(e,t,r){return i("refresh_token",e,r,t)},t.generateAccessToken=function(e,t){return i("access_token",e,t)}},7272:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7273)),a=r(5257),i=n(r(2144));t.default={generateOauth:o.default,generateAccessToken:a.generateAccessToken,generateRefreshToken:a.generateRefreshToken,revokeToken:i.default}},2144:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7644)),a=n(r(2861));t.default=function(e){return new Promise(((t,r)=>{const n=a.default.revokeToken,i=`token=${e}`;o.default.post(n,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{const r={success:!1,data:!1,error:null};200===e.status?(r.success=!0,r.data=!0,t(r)):t(r)})).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}},6401:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(7382),o=r(5001),a=r(248),i=r(2494);t.default=function(e,t){return new Promise(((r,s)=>{n.ServiceAccs.findById(e).then((e=>{e?(0,i.generateAccessToken)(e,t).then((i=>{(function(e,t,r){return new Promise(((i,s)=>{const l=Date.now(),u={_id:(0,o.objectID)("t"),token:a.encrypt.str(r.access_token),type:"access",related_to:e._id,scopes:t,ref_model:"ServiceAccount",expires_at:l+1e3*r.expires_in,website:"google.com"};n.Tokens.create(u).then((e=>{i(e)})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))}))})(e,t,i).then(r).catch((e=>{s(new Error(String(e)))}))})).catch((e=>{s(new Error(String(e)))})):s(new Error("Unable to Find Service Account in the Database"))})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))}))}},2494:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateAccessToken=void 0;const o=n(r(7644)),a=r(1084);t.generateAccessToken=function(e,t){return function(e,t){return new Promise(((r,n)=>{(0,a.createJwtToken)(e,t).then((e=>{const{url:t,params:i}=function(e){return{url:a.api.generateToken,params:`grant_type=${encodeURIComponent("urn:ietf:params:oauth:grant-type:jwt-bearer")}&assertion=${e}`}}(e);o.default.post(t,i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((e=>{200===e.status?r(e.data):n(new Error("Error While Generating the Tokens"))})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{n(new Error(e))}))}))}(e,t)}},5038:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6401)),a=r(2494);t.default={generateOauth:o.default,generateAccessToken:a.generateAccessToken}},2861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={authorize:"https://accounts.google.com/o/oauth2/v2/auth",generateToken:"https://oauth2.googleapis.com/token",checkToken:"https://oauth2.googleapis.com/tokeninfo",revokeToken:"https://oauth2.googleapis.com/revoke"}},3929:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){let r="";if(t){for(let n=0;n{Object.defineProperty(t,"__esModule",{value:!0}),t.mimeArray=void 0,t.default={audio:"application/vnd.google-apps.audio",docs:"application/vnd.google-apps.document",drawings:"application/vnd.google-apps.drawing",drivesdk:"application/vnd.google-apps.drive-sdk",file:"application/vnd.google-apps.file",folder:"application/vnd.google-apps.folder",form:"application/vnd.google-apps.form",fusiontable:"application/vnd.google-apps.fusiontable",map:"application/vnd.google-apps.map",photo:"application/vnd.google-apps.photo",presentation:"application/vnd.google-apps.presentation",script:"application/vnd.google-apps.script",shortcut:"application/vnd.google-apps.shortcut",site:"application/vnd.google-apps.site",spreadsheet:"application/vnd.google-apps.spreadsheet",unknown:"application/vnd.google-apps.unknown",video:"application/vnd.google-apps.video"},t.mimeArray=["application/vnd.google-apps.audio","application/vnd.google-apps.document","application/vnd.google-apps.drive-sdk","application/vnd.google-apps.drawing","application/vnd.google-apps.file","application/vnd.google-apps.folder","application/vnd.google-apps.form","application/vnd.google-apps.fusiontable","application/vnd.google-apps.map","application/vnd.google-apps.photo","application/vnd.google-apps.presentation","application/vnd.google-apps.script","application/vnd.google-apps.shortcut","application/vnd.google-apps.site","application/vnd.google-apps.spreadsheet","application/vnd.google-apps.unknown","application/vnd.google-apps.video"]},6056:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(7644)),a=n(r(6452)),i=n(r(9103));function s(e,t){return t?`${e}?${i.default.stringify(t)}`:`${e}`}function l(e,t,r){return"get"===e?Object.assign({Authorization:`Bearer ${t.token}`,Accept:"application/json"},r):Object.assign({Authorization:`Bearer ${t.token}`,"Content-Type":"application/json"},r)}function u(e){return 200===e.status?{success:!0,data:e.data,error:null}:{success:!1,data:void 0,error:null}}const d={get:(e,t,r,n)=>new Promise(((a,i)=>{const d=s(e,r),c=l("get",t,n);o.default.get(d,{headers:c}).then((e=>{const t=u(e);a(t)})).catch((e=>{i(e)}))})),post:(e,t,r,n,a)=>new Promise(((i,d)=>{const c=s(e,n),f=l("post",t,a);o.default.post(c,r,{headers:f}).then((e=>{const t=u(e);i(t)})).catch((e=>{d(e)}))})),patch:(e,t,r,n,a)=>new Promise(((i,d)=>{const c=s(e,n),f=l("post",t,a);o.default.patch(c,r,{headers:f}).then((e=>{const t=u(e);i(t)})).catch((e=>{d(e)}))})),delete:(e,t,r,n)=>new Promise(((a,i)=>{const d=s(e),c=l("post",t,n);o.default.delete(d,{headers:c,data:r}).then((e=>{const t=u(e);a(t)})).catch((e=>{i(e)}))})),stream:(e,t,r)=>{const n=s(e,r),o=l("get",t);return a.default.stream(n,{headers:o})}};t.default=d},2581:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(7382),o=r(5257),a=r(2494),i=r(5001);function s(e){return e.map((e=>{const t=Date.now()+9e5,r={token:e,validity:!1};return e.expires_at>t&&(r.validity=!0),r}))}function l(e){return new Promise(((t,r)=>{const o=e.map((e=>e._id));n.Tokens.deleteMany({_id:{$in:o}}).then((()=>t())).catch((e=>{r(new Error(`${e.name}: ${e.message}`))}))}))}function u(e,t,r){return new Promise(((a,s)=>{(0,o.generateAccessToken)(e,r.token).then((r=>{const o=(0,i.objectID)("t"),l=Date.now(),u={_id:o,token:r.access_token,type:"access",related_to:e._id,scopes:t,ref_model:"Credential",expires_at:l+1e3*r.expires_in,website:"google.com"};n.Tokens.create(u).then((e=>{a(e)})).catch((e=>{s(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{s(new Error(e))}))}))}function d(e,t){return new Promise(((r,o)=>{(0,a.generateAccessToken)(e,t).then((a=>{const s=(0,i.objectID)("t"),l=Date.now(),u={_id:s,token:a.access_token,type:"access",related_to:e._id,scopes:t,ref_model:"ServiceAccount",expires_at:l+1e3*a.expires_in,website:"google.com"};n.Tokens.create(u).then((e=>{r(e)})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{o(new Error(e))}))}))}function c(e,t){return new Promise(((r,n)=>{const{serviceAcc:o}=e;if(o){const{tokens:a}=e;if(a&&a.access.service){const e=s(a.access.service),i=e.filter((e=>e.validity)).map((e=>e.token));l(e.filter((e=>!e.validity)).map((e=>e.token))).then((()=>{if(i.length>0)r(i);else{const e=[];o.forEach((r=>{d(r,t).then((t=>{e.push(t)})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))})),e.length>1?r(e):r(!1)}})).catch((e=>{n(new Error(e))}))}else{const e=[];o.forEach((r=>{d(r,t).then((t=>{e.push(t)})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))})),e.length>1?r(e):r(!1)}}else r(!1)}))}function f(e,t){return new Promise(((r,n)=>{const{success:o,credential:a,serviceAcc:i,tokens:d}=e;if(o&&a&&d){const{access:e,refresh:o}=d;if(o.length>0){const d={success:!1,credential:a,serviceAcc:i};if(0===e.normal.length)u(a,t,o[0]).then((e=>{d.success=!1,d.tokens={refresh:o,access:{normal:[e]}},r(d)})).catch((e=>{n(new Error(e))}));else{const i=s(e.normal),c=i.filter((e=>e.validity)).map((e=>e.token));l(i.filter((e=>!e.validity)).map((e=>e.token))).then((()=>{d.success=!0,c.length>0?(d.tokens={refresh:o,access:{normal:c}},r(d)):u(a,t,o[0]).then((e=>{d.tokens={refresh:o,access:{normal:[e]}},r(d)})).catch((e=>{n(new Error(e))}))})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))}}else r({success:!1})}else r({success:!1})}))}t.default=function(e,t){return new Promise(((r,o)=>{(function(e,t){return new Promise(((r,o)=>{const a={success:!1};n.Credentials.findById(e).then((e=>{e&&(a.credential=e,n.ServiceAccs.find({related_to:e._id}).then((i=>{a.serviceAcc=i;const s=i.map((e=>e._id)),l=[{related_to:e._id,scopes:t},...s.map((e=>({related_to:e,scopes:t})))];n.Tokens.find({$or:l}).then((e=>{if(e.length>0){const t=e.filter((e=>"access"===e.type&&"Credential"===e.ref_model)),n=e.filter((e=>"access"===e.type&&"ServiceAccount"===e.ref_model)),o=e.filter((e=>"refresh"===e.type));a.tokens={access:{normal:t,service:n},refresh:o},a.success=!0,r(a)}else a.success=!1,r(a)})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))}))})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))})))})).catch((e=>{o(new Error(`${e.name}: ${e.message}`))}))}))})(e,t).then((e=>Promise.all([e,f(e,t)]))).then((([e,r])=>Promise.all([r,c(e,t)]))).then((([e,t])=>{if(e.tokens)if(t){const n={success:!0,tokens:[...e.tokens.access.normal,...t]};r(n)}else{const t={success:!0,tokens:e.tokens.access.normal};r(t)}else o(new Error("No Tokens Found"))})).catch((e=>{o(new Error(e))}))}))}},7683:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=r(5175),a=r(1084),i=(new o.Crypto).subtle,s={alg:"RS256",typ:"JWT"};t.default=function(e,t){return n(this,void 0,void 0,(function*(){const r=Date.now()/1e3,o=(0,a.stringizeScope)(t),l={iss:e.private_key.id,scope:o,aud:"https://oauth2.googleapis.com/token",exp:r+3600,iat:r},u=Buffer.from(JSON.stringify(l)).toString("base64"),d=Buffer.from(JSON.stringify(s)).toString("base64"),c=yield function(e){return n(this,void 0,void 0,(function*(){const t=function(e){const t=Buffer.from(e,"base64").toString("utf8"),r=new Uint8Array(t.length);for(let e=0;ee.trim())).filter((e=>e.length&&!e.startsWith("---"))).join(""));return i.importKey("pkcs8",t,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["sign"])}))}(e.private_key.key),f=function(e){let t="";const r=new Uint8Array(e);for(let e=0;e{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){let t="";return e.forEach(((r,n)=>{n===e.length-1?t+=`${r}`:t+=`${r} `})),t}},3100:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.oauthHelpers=t.serviceAccountHandler=t.normalAccountHandler=t.oauthScopes=t.oauthRouteApis=t.mimeTypes=t.mimeArray=t.oauthAuthenticationApis=void 0;const o=r(1084);var a=r(1084);Object.defineProperty(t,"oauthAuthenticationApis",{enumerable:!0,get:function(){return a.api}}),Object.defineProperty(t,"mimeArray",{enumerable:!0,get:function(){return a.mimeArray}}),Object.defineProperty(t,"mimeTypes",{enumerable:!0,get:function(){return a.mimeTypes}});var i=r(8841);Object.defineProperty(t,"oauthRouteApis",{enumerable:!0,get:function(){return i.api}});var s=r(9432);Object.defineProperty(t,"oauthScopes",{enumerable:!0,get:function(){return s.scopes}});var l=r(7272);Object.defineProperty(t,"normalAccountHandler",{enumerable:!0,get:function(){return n(l).default}});var u=r(5038);Object.defineProperty(t,"serviceAccountHandler",{enumerable:!0,get:function(){return n(u).default}}),t.oauthHelpers={resolveToken:o.resolveToken,stringizeScope:o.stringizeScope,constructFields:o.constructFields,createJwtToken:o.createJwtToken,googleApiRequest:o.googleApiRequest}},8841:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.api=void 0;const n=r(4e3),o=r(1825);t.api={iam:n.api,drives:o.api}},5001:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isUndefined=t.shortuid=t.objectID=t.generateUID=void 0;var o=r(2328);Object.defineProperty(t,"generateUID",{enumerable:!0,get:function(){return n(o).default}}),Object.defineProperty(t,"objectID",{enumerable:!0,get:function(){return o.objectID}}),Object.defineProperty(t,"shortuid",{enumerable:!0,get:function(){return o.shortuid}});var a=r(462);Object.defineProperty(t,"isUndefined",{enumerable:!0,get:function(){return n(a).default}})},462:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=[];return e.forEach((e=>{!e||null===e&&void 0===e?t.push(!1):t.push(!0)})),!!t.includes(!1)}},2328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shortuid=t.objectID=void 0;const n=r(754),o=r(1185),a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",i=`${a}&%^()!@#$*<>?/][}{<>,.|:;`,s=(0,n.customAlphabet)(i,10),l=(0,n.customAlphabet)(a,8);function u(e){if(e&&e.length>1)throw new Error("Prefix Cant be more than one Character");try{const t=s();return`${e?`${e}@`:""}${t}`}catch(e){throw new Error("Unable to Generate UID")}}t.default=u,t.objectID=function(e){try{return o.Types.ObjectId(u(e))}catch(e){throw new Error(String(e))}},t.shortuid=function(e){return`${e?`${e}@`:""}${l()}`}},7324:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointGenerator=void 0;const o=n(r(3648)),a=r(1849);t.EndpointGenerator=class{constructor(e,t){this.response=e,this.router=t}serve(){(0,a.okResponse)(this.response,(0,o.default)(this.router))}}},4523:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointGenerator=void 0;var n=r(7324);Object.defineProperty(t,"EndpointGenerator",{enumerable:!0,get:function(){return n.EndpointGenerator}})},3648:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});const r=e=>{if(e.fast_slash)return"";const t=/^\/\^((?:\\[$()*+./?[\\\]^{|}]|[^$()*+./?[\\\]^{|}])*)\$\//u.exec(e.toString().replace("\\/?","").replace("(?=\\/|$)","$"));return t?t[1].replace(/\\(.)/gu,"$1"):"[Unknown path]"};t.default=function(e){const t={get:[],post:[],put:[],patch:[],delete:[]},n=(e,o="")=>{if("router"===e.name&&e.handle.stack)for(const t of e.handle.stack)n(t,`${o}${r(e.regexp)}`);if(!e.route)return;const{method:a}=e.route.stack[0],{path:i}=e.route;switch(a){case"get":t.get.push(`${o}${i}`);break;case"post":t.post.push(`${o}${i}`);break;case"put":t.put.push(`${o}${i}`);break;case"patch":t.patch.push(`${o}${i}`);break;case"delete":t.delete.push(`${o}${i}`);break;default:throw new Error(`Invalid method ${a}.`)}};for(const t of e.stack)n(t);return t}},8816:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(8130)),a=r(8305);function i(){return console.log("server is starting cleanup"),o.default.close()}function s(){return new Promise((e=>{console.log("cleanup finished, server is shutting down"),e()}))}t.default=function(e){const t={onSignal:i,onShutdown:s};(0,a.createTerminus)(e,t)}},819:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.responseSender=t.healthCheckService=t.getAllRoutes=void 0;var o=r(3648);Object.defineProperty(t,"getAllRoutes",{enumerable:!0,get:function(){return n(o).default}});var a=r(8816);Object.defineProperty(t,"healthCheckService",{enumerable:!0,get:function(){return n(a).default}});var i=r(6694);Object.defineProperty(t,"responseSender",{enumerable:!0,get:function(){return n(i).default}})},6694:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){e.status(t).json(r)}},412:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6466);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n(o).default}})},9153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(7382),o=r(1849),{NODE_ENV:a}=process.env;t.default=function(e,t,r){if("development"===a){const n=e.method,a=process.env.LOCAL_SECRET;if(a){const i=e.headers["x-local-dev-pass"];"GET"===n?(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST"),t.setHeader("Access-Control-Allow-Headers","x-local-dev-pass,x-secret-pass,X-Requested-With,content-type, Accept"),r()):i?a===i?(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, POST"),t.setHeader("Access-Control-Allow-Headers","x-local-dev-pass,x-secret-pass,X-Requested-With,content-type, Accept"),r()):(0,o.unAuthorized)(t,"Local Dev Secret is not Matching with the sent pass"):(0,o.badRequest)(t,"x-local-dev-pass","response headers")}else(0,o.internalServerError)(t,"Secret Error","Project not Configured for Local Development")}else n.Frontends.getFrontendUrls().then((n=>{const o=n.map((e=>e.domain)),{origin:a}=e.headers;a&&o.indexOf(a)>-1&&t.setHeader("Access-Control-Allow-Origin",a),t.setHeader("Access-Control-Allow-Methods","GET, POST"),t.setHeader("Access-Control-Allow-Headers","x-local-dev-pass,x-secret-pass,X-Requested-With,content-type, Accept"),t.setHeader("Access-Control-Allow-Credentials","true"),r()})).catch((e=>{(0,o.internalServerError)(t,e.name,e.message)}))}},1491:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(1185);t.default=function(e,t,r){const o=n.connection.readyState;if([0,2,3].includes(o)){const e={status:500,errorname:`Database is ${n.STATES[o]}`,message:"Internal Server Error Related to Database"};t.status(500).json(e)}else t.locals.dbcheck=!0,r()}},7331:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.checkSecretPass=void 0;const o=r(7382),a=r(1849),i=r(3969),s=r(5663);function l(e,t){return n(this,void 0,void 0,(function*(){return new Promise(((r,n)=>{e.find({}).exec().then((e=>{e?e.length>0?t?t.length===e.length?r(!0):r(!1):r(!0):r(!1):n(new Error("Unknown Error while Querying Collection"))})).catch((e=>{n(new Error(`${e.name}: ${e.message}`))}))}))}))}t.default=function(e,t,r){const n=[l(o.Credentials),l(o.Frontends),l(o.Policies,s.map),l(o.Roles,i.map),l(o.GlobalSettings),l(o.Scopes),l(o.Users)];Promise.all(n).then((e=>{e.includes(!1)?(t.locals.setups=!0,r()):t.status(200).json({success:!0,setup:!0,message:"All the Collections have been Setup Correctly"})})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))},t.checkSecretPass=function(e,t,r){const n=process.env.SECRET;if(n){const o=e.headers["x-secret-pass"];if(o&&"string"==typeof o){const e=n.toLowerCase();o.toLowerCase()===e?(t.locals.secretcheck=!0,r()):(0,a.unAuthorized)(t,"Header Secret is Not Matching with the Environment Secret, Kindly Send the Correct Pass")}else(0,a.badRequest)(t,"x-secret-pass","Request Headers")}else(0,a.internalServerError)(t,"Secret Error","No Secret Set in the Environment, Kindly Set in Vars")}},8030:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkSecretPass=t.checkSetupStatus=t.checkDBStatus=t.cors=void 0;var o=r(9153);Object.defineProperty(t,"cors",{enumerable:!0,get:function(){return n(o).default}});var a=r(1491);Object.defineProperty(t,"checkDBStatus",{enumerable:!0,get:function(){return n(a).default}});var i=r(7331);Object.defineProperty(t,"checkSetupStatus",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(t,"checkSecretPass",{enumerable:!0,get:function(){return i.checkSecretPass}})},6267:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.okResponse=void 0;const o=n(r(6694));t.okResponse=function(e,t){const r={status:200,data:t};(0,o.default)(e,200,r)}},9041:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notFound=t.unAuthorized=t.badRequest=void 0;const o=n(r(6694));t.badRequest=function(e,t,r){const n={status:400,errorname:"Bad Request",message:`Expected ${t} in ${r}`};(0,o.default)(e,400,n)},t.unAuthorized=function(e,t){const r={status:403,errorname:"UnAuthorized",message:t};(0,o.default)(e,400,r)},t.notFound=function(e,t){const r={status:404,errorname:"Not Found",message:t};(0,o.default)(e,400,r)}},2923:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.badGateway=t.internalServerError=void 0;const o=n(r(6694));t.internalServerError=function(e,t,r){const n={status:500,errorname:t||"Internal Server Error",message:r||"Unknown"};(0,o.default)(e,500,n)},t.badGateway=function(e){(0,o.default)(e,502,{status:502,errorname:"Bad Gateway",message:"Received an Invalid response from the upstream server."})}},1849:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.badGateway=t.internalServerError=t.notFound=t.unAuthorized=t.badRequest=t.okResponse=void 0;var n=r(6267);Object.defineProperty(t,"okResponse",{enumerable:!0,get:function(){return n.okResponse}});var o=r(9041);Object.defineProperty(t,"badRequest",{enumerable:!0,get:function(){return o.badRequest}}),Object.defineProperty(t,"unAuthorized",{enumerable:!0,get:function(){return o.unAuthorized}}),Object.defineProperty(t,"notFound",{enumerable:!0,get:function(){return o.notFound}});var a=r(2923);Object.defineProperty(t,"internalServerError",{enumerable:!0,get:function(){return a.internalServerError}}),Object.defineProperty(t,"badGateway",{enumerable:!0,get:function(){return a.badGateway}})},6466:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(3685)),a=n(r(6860)),i=n(r(7806)),s=n(r(2821)),l=n(r(8285)),u=n(r(1491)),d=n(r(9153)),c=n(r(9796)),f=(0,a.default)();f.use(a.default.json({limit:"50kb"})),f.use((0,i.default)()),f.use((0,l.default)()),f.use((0,s.default)()),f.use([u.default,d.default]),f.use("/",c.default);const p=o.default.createServer(f);t.default=p},544:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(389);t.default={add:n.creds_add,edit:n.creds_edit,remove:n.creds_rm},t.map=[n.creds_add,n.creds_edit,n.creds_rm]},389:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.creds_rm=t.creds_edit=t.creds_add=void 0;const n=r(2328);t.creds_add={_id:(0,n.objectID)("p"),code:"credsadd",name:"Add Credentials to DB",message:"Enable Adding of Credentials from Database",global_flag:!0},t.creds_edit={_id:(0,n.objectID)("p"),code:"credsedit",name:"Edit Credentials in DB",message:"Enable Editing of Credentials from Database",global_flag:!0},t.creds_rm={_id:(0,n.objectID)("p"),code:"credsrm",name:"Remove Credentials from DB",message:"Enable Removal of Credentials from Database",global_flag:!0}},8468:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(2786);t.default={add:n.frontend_add,edit:n.frontend_edit,remove:n.frontend_rm},t.map=[n.frontend_add,n.frontend_edit,n.frontend_rm]},2786:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.frontend_rm=t.frontend_edit=t.frontend_add=void 0;const n=r(2328);t.frontend_add={_id:(0,n.objectID)("p"),code:"ftendadd",name:"Add Frontends",message:"Enable Adding of Frotnends from Database",global_flag:!0},t.frontend_edit={_id:(0,n.objectID)("p"),code:"ftendedit",name:"Edit Frontends",message:"Enable Editing of Frontend Details from Database",global_flag:!0},t.frontend_rm={_id:(0,n.objectID)("p"),code:"ftendrm",name:"Remove Frontends",message:"Enable Removal of Frontends from Database",global_flag:!0}},6683:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4199);t.default={edit:n.global_settings_edit},t.map=[n.global_settings_edit]},4199:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.global_settings_edit=void 0;const n=r(2328);t.global_settings_edit={_id:(0,n.objectID)("p"),code:"gblsetedit",name:"Edit Global Settings",message:"Enable Editing of Global Settings of the Server",global_flag:!0}},5663:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.map=t.smtpProviders=t.smtpMailers=t.serviceAccounts=t.scopes=t.roles=t.policy=t.globalSettings=t.frontends=t.credentials=t.users=void 0;const o=r(8384),a=r(544),i=r(8468),s=r(6683),l=r(7549),u=r(5624),d=r(381),c=r(167),f=r(5735),p=r(9008);var _=r(8384);Object.defineProperty(t,"users",{enumerable:!0,get:function(){return n(_).default}});var m=r(544);Object.defineProperty(t,"credentials",{enumerable:!0,get:function(){return n(m).default}});var g=r(8468);Object.defineProperty(t,"frontends",{enumerable:!0,get:function(){return n(g).default}});var v=r(6683);Object.defineProperty(t,"globalSettings",{enumerable:!0,get:function(){return n(v).default}});var h=r(7549);Object.defineProperty(t,"policy",{enumerable:!0,get:function(){return n(h).default}});var b=r(5624);Object.defineProperty(t,"roles",{enumerable:!0,get:function(){return n(b).default}});var y=r(381);Object.defineProperty(t,"scopes",{enumerable:!0,get:function(){return n(y).default}});var P=r(167);Object.defineProperty(t,"serviceAccounts",{enumerable:!0,get:function(){return n(P).default}});var j=r(5735);Object.defineProperty(t,"smtpMailers",{enumerable:!0,get:function(){return n(j).default}});var M=r(9008);Object.defineProperty(t,"smtpProviders",{enumerable:!0,get:function(){return n(M).default}}),t.map=[...o.map,...a.map,...i.map,...s.map,...l.map,...u.map,...d.map,...c.map,...f.map,...p.map]},7549:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(3540);t.default={edit:n.policies_edit},t.map=[n.policies_edit]},3540:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.policies_edit=void 0;const n=r(2328);t.policies_edit={_id:(0,n.objectID)("p"),code:"poledit",name:"Edit Policies",message:"Enable Editing of Organisation Policies",global_flag:!0}},5624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(6645);t.default={add:n.roles_add,edit:n.roles_edit,remove:n.roles_rm},t.map=[n.roles_add,n.roles_edit,n.roles_rm]},6645:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.roles_rm=t.roles_edit=t.roles_add=void 0;const n=r(2328);t.roles_add={_id:(0,n.objectID)("p"),code:"roleadd",name:"Add Sub Roles",message:"Enable Creating of Sub Roles",global_flag:!0},t.roles_edit={_id:(0,n.objectID)("p"),code:"roleedit",name:"Edit Sub Roles",message:"Enable Editing of Settings related to Sub Roles",global_flag:!0},t.roles_rm={_id:(0,n.objectID)("p"),code:"rolerm",name:"Remove Sub Roles",message:"Enable Removal of Sub Roles",global_flag:!0}},381:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4503);t.default={add:n.scope_add,edit:n.scope_edit,remove:n.scope_rm},t.map=[n.scope_add,n.scope_edit,n.scope_rm]},4503:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scope_rm=t.scope_edit=t.scope_add=void 0;const n=r(2328);t.scope_add={_id:(0,n.objectID)("p"),code:"scpadd",name:"Add Scopes",message:"Enable Adding of Scopes to Database",global_flag:!0},t.scope_edit={_id:(0,n.objectID)("p"),code:"scpedit",name:"Edit Scopes",message:"Enable Editing of Scopes in Database",global_flag:!0},t.scope_rm={_id:(0,n.objectID)("p"),code:"scprm",name:"Remove Scopes",message:"Enable Removal of Scopes from Database",global_flag:!0}},167:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(5793);t.default={add:n.sac_add,edit:n.sac_edit,remove:n.sac_rm},t.map=[n.sac_add,n.sac_edit,n.sac_rm]},5793:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sac_rm=t.sac_edit=t.sac_add=void 0;const n=r(2328);t.sac_add={_id:(0,n.objectID)("p"),code:"sacaccadd",name:"Add Service Account",message:"Enable Adding of Service Accounts to Database",global_flag:!0},t.sac_edit={_id:(0,n.objectID)("p"),code:"sacaccedit",name:"Edit Service Account",message:"Enable Editing of Service Accounts in Database",global_flag:!0},t.sac_rm={_id:(0,n.objectID)("p"),code:"sacaccrm",name:"Remove Service Account",message:"Enable Removal of Service Accounts from Database",global_flag:!0}},5735:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(5030);t.default={add:n.smtp_mailer_add,edit:n.smtp_mailer_edit,remove:n.smtp_mailer_rm},t.map=[n.smtp_mailer_add,n.smtp_mailer_edit,n.smtp_mailer_rm]},5030:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.smtp_mailer_rm=t.smtp_mailer_edit=t.smtp_mailer_add=void 0;const n=r(2328),o="smtpmail";t.smtp_mailer_add={_id:(0,n.objectID)("p"),code:`${o}add`,name:"Add SMTP Emails Accounts",message:"Enable Adding of SMTP Emails Accounts to Database",global_flag:!0},t.smtp_mailer_edit={_id:(0,n.objectID)("p"),code:`${o}edit`,name:"Edit SMTP Emails Accounts",message:"Enable Editing of SMTP Emails Accounts in Database",global_flag:!0},t.smtp_mailer_rm={_id:(0,n.objectID)("p"),code:`${o}rm`,name:"Remove SMTP Emails Accounts",message:"Enable Removal of SMTP Emails Accounts from Database",global_flag:!0}},9008:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(9996);t.default={add:n.smtp_provider_add,edit:n.smtp_provider_edit,remove:n.smtp_provider_rm},t.map=[n.smtp_provider_add,n.smtp_provider_edit,n.smtp_provider_rm]},9996:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.smtp_provider_rm=t.smtp_provider_edit=t.smtp_provider_add=void 0;const n=r(2328);t.smtp_provider_add={_id:(0,n.objectID)("p"),code:"smtpproadd",name:"Add SMTP Email Providers",message:"Enable Adding of SMTP Email Providers to Database",global_flag:!0},t.smtp_provider_edit={_id:(0,n.objectID)("p"),code:"smtpproedit",name:"Edit SMTP Email Providers",message:"Enable Editing of SMTP Email Providers in Database",global_flag:!0},t.smtp_provider_rm={_id:(0,n.objectID)("p"),code:"smtpprorm",name:"Remove SMTP Email Providers",message:"Enable Removal of SMTP Email Providers from Database",global_flag:!0}},6228:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(7375),o=r(7375);t.default={accept:{viewer:n.viewer_add,contentMgr:n.content_mgr_add,mods:n.mod_add,manager:n.mgr_add},promote:{contentMgr:o.self_content_mgr_add,mods:o.self_mod_add,manager:o.self_mgr_add}},t.map=[n.viewer_add,n.content_mgr_add,n.mod_add,n.mgr_add,o.self_content_mgr_add,o.self_mod_add,o.self_mgr_add]},7375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.self_mgr_add=t.self_mod_add=t.self_content_mgr_add=t.mgr_add=t.mod_add=t.content_mgr_add=t.viewer_add=void 0;const n=r(2328);t.viewer_add={_id:(0,n.objectID)("p"),code:"usraddvwr",name:"Add Viewer",message:"Enable Accepting of Requests for Viewers and its Delegates",global_flag:!0},t.content_mgr_add={_id:(0,n.objectID)("p"),code:"usraddcntmgr",name:"Add Content Managers",message:"Enable Accepting of Requests for Content Managers and its Delegates",global_flag:!0},t.mod_add={_id:(0,n.objectID)("p"),code:"usraddmdtr",name:"Add Moderators",message:"Enable Accepting of Requests for Moderators and its Delegates",global_flag:!0},t.mgr_add={_id:(0,n.objectID)("p"),code:"usraddmgr",name:"Add Managers",message:"Enable Accepting of Requests for Managers and its Delegates",global_flag:!0},t.self_content_mgr_add={_id:(0,n.objectID)("p"),code:"usrpmtcntmgr",name:"Promote to Content Managers",message:"Enable Promoting of Users to Content Managers without their Request and its Delegates",global_flag:!0},t.self_mod_add={_id:(0,n.objectID)("p"),code:"usrpmtmdtr",name:"Promote to Moderators",message:"Enable Promoting of Users to Moderators without their Request and its Delegates",global_flag:!0},t.self_mgr_add={_id:(0,n.objectID)("p"),code:"usrpmtmgr",name:"Promote to Manager",message:"Enable Promoting of Users to Managers without their Request and its Delegates",global_flag:!0}},883:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(2105);t.default={viewer:n.viewer_blist,contentMgr:n.content_mgr_blist,mods:n.mod_blist,manager:n.mgr_blist},t.map=[n.viewer_blist,n.content_mgr_blist,n.mod_blist,n.mgr_blist]},2105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mgr_blist=t.mod_blist=t.content_mgr_blist=t.viewer_blist=void 0;const n=r(2328);t.viewer_blist={_id:(0,n.objectID)("p"),code:"usrblistvwr",name:"Blacklist Viewer",message:"Enable Blacklisting of Viewers and its Delegates",global_flag:!0},t.content_mgr_blist={_id:(0,n.objectID)("p"),code:"usrblistcntmgr",name:"Blacklist Content Managers",message:"Enable Blacklisting of Content Managers and its Delegates",global_flag:!0},t.mod_blist={_id:(0,n.objectID)("p"),code:"usrblistmod",name:"Blacklist Moderators",message:"Enable Blacklisting of Moderators and its Delegates",global_flag:!0},t.mgr_blist={_id:(0,n.objectID)("p"),code:"usrblistmgr",name:"Blacklist Managers",message:"Enable Blacklisting of Managers and its Delegates",global_flag:!0}},8384:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const i=a(r(6228)),s=a(r(6076)),l=a(r(4540)),u=a(r(883));t.default={add:i.default,remove:s.default,modify:l.default,blacklist:u.default},t.map=[...i.map,...s.map,...u.map,...l.map]},4540:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4999),o=r(4999),a=r(4999),i=r(4999);t.default={viewer:{policy:n.viewer_policies,scope:n.viewer_scope,restrict:n.viewer_restrict},contentMgr:{policy:o.content_mgr_policies,scope:o.content_mgr_scope,restrict:o.content_mgr_restrict},mods:{policy:a.mods_policies,scope:a.mods_scope,restrict:a.mods_restrict},manager:{policy:i.mgr_policies,scope:i.mgr_scope,restrict:i.mgr_restrict}};const s=[n.viewer_policies,n.viewer_scope,n.viewer_restrict],l=[o.content_mgr_policies,o.content_mgr_scope,o.content_mgr_restrict],u=[a.mods_policies,a.mods_scope,a.mods_restrict],d=[i.mgr_policies,i.mgr_scope,i.mgr_restrict];t.map=[...s,...l,...u,...d]},4999:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mgr_restrict=t.mgr_scope=t.mgr_policies=t.mods_restrict=t.mods_scope=t.mods_policies=t.content_mgr_restrict=t.content_mgr_scope=t.content_mgr_policies=t.viewer_restrict=t.viewer_scope=t.viewer_policies=void 0;const n=r(2328);t.viewer_policies={_id:(0,n.objectID)("p"),code:"usrpolvwr",name:"Edit Policies of Viewer",message:"Enable Granting/Removing Policies to Viewers and its Delegates",global_flag:!0},t.viewer_scope={_id:(0,n.objectID)("p"),code:"usrscpvwr",name:"Edit Scopes of Viewers",message:"Enable Granting/Removing of Scopes to Viewers and its Delegates",global_flag:!0},t.viewer_restrict={_id:(0,n.objectID)("p"),code:"usrrestvwr",name:"Restrict Viewers",message:"Restrict Users and its Delegates",global_flag:!0},t.content_mgr_policies={_id:(0,n.objectID)("p"),code:"usrpolcntmgr",name:"Edit Policies of Content Manager",message:"Enable Granting/Removing Policies to Content Managers and its Delegates",global_flag:!0},t.content_mgr_scope={_id:(0,n.objectID)("p"),code:"usrscpcntmgr",name:"Edit Scopes of Content Managers",message:"Enable Granting/Removing of Scopes to Content Managers and its Delegates",global_flag:!0},t.content_mgr_restrict={_id:(0,n.objectID)("p"),code:"usrrestcntmgr",name:"Restrict Content Managers",message:"Restrict Content Managers and its Delegates",global_flag:!0},t.mods_policies={_id:(0,n.objectID)("p"),code:"usrpolmdtr",name:"Edit Policies of Moderators",message:"Enable Granting/Removing Policies to Moderators and its Delegates",global_flag:!0},t.mods_scope={_id:(0,n.objectID)("p"),code:"usrscpmdtr",name:"Edit Scopes of Moderators",message:"Enable Granting/Removing of Scopes to Moderators and its Delegates",global_flag:!0},t.mods_restrict={_id:(0,n.objectID)("p"),code:"usrrestmdtr",name:"Restrict Moderators",message:"Restrict Moderators and its Delegates",global_flag:!0},t.mgr_policies={_id:(0,n.objectID)("p"),code:"usrpolmgr",name:"Edit Policies of Managers",message:"Enable Granting/Removing Policies to Managers and its Delegates",global_flag:!0},t.mgr_scope={_id:(0,n.objectID)("p"),code:"usrscpmgr",name:"Edit Scopes of Managers",message:"Enable Granting/Removing of Scopes to Managers and its Delegates",global_flag:!0},t.mgr_restrict={_id:(0,n.objectID)("p"),code:"usrrestmgr",name:"Restrict Managers",message:"Restrict Managers and its Delegates",global_flag:!0}},6076:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;const n=r(4853);t.default={viewer:n.viewer_rm,contentMgr:n.content_mgr_rm,mod:n.mods_rm,manager:n.mgr_rm},t.map=[n.viewer_rm,n.content_mgr_rm,n.mods_rm,n.mgr_rm]},4853:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mgr_rm=t.mods_rm=t.content_mgr_rm=t.viewer_rm=void 0;const n=r(2328);t.viewer_rm={_id:(0,n.objectID)("p"),code:"usrrmvwr",name:"Remove Viewer",message:"Enable Removal of Viewers and its Delegates",global_flag:!0},t.content_mgr_rm={_id:(0,n.objectID)("p"),code:"usrrmcntmgr",name:"Remove Content Managers",message:"Enable Removal of Content Managers and Delegates",global_flag:!0},t.mods_rm={_id:(0,n.objectID)("p"),code:"usrrmmdtr",name:"Remove Moderators",message:"Enable Removal of Moderators and Delegates",global_flag:!0},t.mgr_rm={_id:(0,n.objectID)("p"),code:"usrrmmgr",name:"Remove Managers",message:"Enable Removal of Managers and Delegates",global_flag:!0}},3969:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.map=t.owner=t.manager=t.moderator=t.contentMgr=t.viewer=void 0;const o=r(2328),a=n(r(7260)),i=n(r(8791)),s=n(r(3269)),l=n(r(3248)),u={viewer:(0,o.objectID)("r"),contentMgr:(0,o.objectID)("r"),moderator:(0,o.objectID)("r"),manager:(0,o.objectID)("r"),owner:(0,o.objectID)("r")};t.viewer={_id:u.viewer,name:"Viewer",alias:"Viewer",type:"main",parent_role:u.contentMgr,allowed_policies:[]},t.contentMgr={_id:u.contentMgr,name:"Content Manager",alias:"Content Manager",type:"main",parent_role:u.moderator,child_role:t.viewer._id,allowed_policies:l.default},t.moderator={_id:u.moderator,name:"Moderator",alias:"Moderator",type:"main",parent_role:u.owner,child_role:u.contentMgr,allowed_policies:s.default},t.manager={_id:u.manager,name:"Manager",alias:"Manager",type:"main",parent_role:u.owner,child_role:u.moderator,allowed_policies:i.default},t.owner={_id:u.owner,name:"Owner",alias:"Owner",type:"main",child_role:u.manager,allowed_policies:a.default},t.map=[t.viewer,t.contentMgr,t.moderator,t.owner]},3248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663),o=[n.users.add.accept.viewer._id,n.users.blacklist.viewer._id,n.users.modify.viewer.policy._id,n.users.modify.viewer.restrict._id,n.users.modify.viewer.scope._id,n.frontends.edit._id];t.default=o},8791:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663),o=[n.users.add.accept.contentMgr._id,n.users.add.accept.mods._id,n.users.add.accept.viewer._id,n.users.blacklist.manager._id,n.users.blacklist.mods._id,n.users.blacklist.viewer._id,n.users.modify.contentMgr.policy._id,n.users.modify.contentMgr.restrict._id,n.users.modify.contentMgr.scope._id,n.users.modify.mods.policy._id,n.users.modify.mods.restrict._id,n.users.modify.mods.scope._id,n.users.modify.viewer.policy._id,n.users.modify.viewer.restrict._id,n.users.modify.viewer.scope._id,n.frontends.edit._id,n.globalSettings.edit._id,n.roles.add._id,n.roles.edit._id,n.roles.remove._id,n.policy.edit._id,n.smtpProviders.add._id,n.smtpProviders.edit._id,n.smtpProviders.remove._id,n.smtpMailers.add._id,n.smtpMailers.edit._id,n.smtpMailers.remove._id];t.default=o},3269:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663),o=[n.users.add.accept.contentMgr._id,n.users.add.accept.viewer._id,n.users.blacklist.manager._id,n.users.blacklist.viewer._id,n.users.modify.contentMgr.policy._id,n.users.modify.contentMgr.restrict._id,n.users.modify.contentMgr.scope._id,n.users.modify.viewer.policy._id,n.users.modify.viewer.restrict._id,n.users.modify.viewer.scope._id];t.default=o},7260:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(5663).map.map((e=>e._id));t.default=n},2946:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(5001),l=r(4523),u=o.default.Router();u.post("/add",((e,t)=>{const{alias:r,client_id:n,client_secret:o,redirect_uri:l,email:u}=e.body;if((0,s.isUndefined)([r,n,o,l,u]))(0,a.badRequest)(t,"alias, client_id, client_secret, email","Request Body");else{const e={_id:(0,s.objectID)("c"),alias:r,client_id:n,client_secret:o,redirect_uri:l,email:u};i.Credentials.create(e).then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))}})),u.post("/reset",((e,t)=>{i.Credentials.clearAll().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new l.EndpointGenerator(t,u).serve())),t.default=u},1279:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=n(r(9183)),i=n(r(1807)),s=n(r(2946)),l=n(r(6010)),u=r(4523),d=o.default.Router();d.use("/policies",a.default),d.use("/roles",i.default),d.use("/credentials",s.default),d.use("/scopes",l.default),d.post("/endpoints",((e,t)=>new u.EndpointGenerator(t,d).serve())),t.default=d},9183:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(5663),l=r(4523),u=o.default.Router();u.post("/add",((e,t)=>{const r=[],n=[];s.map.forEach((e=>{i.Policies.create(e).then((e=>{r.push(e),n.push(!0)})).catch((e=>{console.log(e),n.push(!1)}))})),n.includes(!1)?(0,a.internalServerError)(t,"Database","Some Internal Error Occured, Not all Records have been Added to Database"):(0,a.okResponse)(t,"Successfully Posted all the Policy Details to Database")})),u.post("/status",((e,t)=>{i.Policies.mapCheck().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/reset",((e,t)=>{i.Policies.clearAll().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new l.EndpointGenerator(t,u).serve())),t.default=u},1807:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(3969),l=r(4523),u=o.default.Router();u.post("/add",((e,t)=>{const r=[],n=[];s.map.forEach((e=>{i.Roles.create(e).then((e=>{r.push(e),n.push(!0)})).catch((e=>{console.log(e),n.push(!1)}))})),n.includes(!1)?(0,a.internalServerError)(t,"Database","Some Internal Error Occured, Not all Records have been Added to Database"):(0,a.okResponse)(t,"Successfully Posted all the Roles Details to Database")})),u.post("/status",((e,t)=>{i.Roles.mapCheck().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/reset",((e,t)=>{i.Roles.clearAll().then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new l.EndpointGenerator(t,u).serve())),t.default=u},6010:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(1849),i=r(7382),s=r(4523),l=r(5001),u=o.default.Router();u.post("/add",((e,t)=>{const{name:r,drive_id:n,credential_id:o}=e.body;(0,l.isUndefined)([r,n,o])?(0,a.badRequest)(t,"name, drive_id, credential_id","Request Body as JSON"):i.Credentials.checkID(o).then((e=>{if(e){const e={_id:(0,l.objectID)("scope"),name:r,added_at:Date.now(),drive_id:n,related_to:[o]};i.Scopes.create(e).then((e=>{(0,a.okResponse)(t,e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))}else(0,a.notFound)(t,"Credential ID Not found in the Database, Kindly Send the Correct ID")})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/status",((e,t)=>{i.Scopes.find({}).then((e=>{e.length>0?(0,a.okResponse)(t,e):(0,a.notFound)(t,"No Scopes Saved or Found in the Database")})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/reset",((e,t)=>{i.Scopes.clearAll().then((e=>{(0,a.okResponse)(t,e),t.status(200).json(e)})).catch((e=>{(0,a.internalServerError)(t,e.name,e.message)}))})),u.post("/endpoints",((e,t)=>new s.EndpointGenerator(t,u).serve())),t.default=u},9796:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(8030),i=n(r(7331)),s=r(1849),l=n(r(1279)),u=n(r(9527)),d=r(4523),c=o.default.Router();c.use("/setup",[i.default,a.checkSecretPass],l.default),c.use("/login",u.default),c.get("/",((e,t)=>{(0,s.okResponse)(t,"Server Successfully Started")})),c.post("/endpoints",((e,t)=>new d.EndpointGenerator(t,c).serve())),t.default=c},8479:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=r(3100),i=r(9432),s=r(3100),l=r(7382),u=o.default.Router();u.get("/auth/",((e,t)=>{a.normalAccountHandler.generateOauth(e,t,[...s.oauthScopes.drive,...s.oauthScopes.iam])})),u.post("/sample/",((e,t)=>{l.Credentials.find({}).then((e=>{a.oauthHelpers.resolveToken(e[0]._id,[...s.oauthScopes.drive,...s.oauthScopes.iam]).then((e=>{i.iam.projects.list(e.tokens[0]).then((r=>{t.json({res2:r,result:e})})).catch((e=>{t.send(e)}))})).catch((e=>{t.send(e)}))})).catch((e=>{t.send(e)}))})),t.default=u},9527:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(r(6860)),a=n(r(8479)),i=o.default.Router();i.use("/google/",a.default),t.default=i},8305:e=>{e.exports=require("@godaddy/terminus")},2167:e=>{e.exports=require("axios")},7096:e=>{e.exports=require("bcrypt")},5666:e=>{e.exports=require("crypto-js")},9387:e=>{e.exports=require("dot-prop")},5142:e=>{e.exports=require("dotenv")},6860:e=>{e.exports=require("express")},2821:e=>{e.exports=require("express-mongo-sanitize")},6452:e=>{e.exports=require("got")},7806:e=>{e.exports=require("helmet")},1185:e=>{e.exports=require("mongoose")},754:e=>{e.exports=require("nanoid")},5175:e=>{e.exports=require("node-webcrypto-ossl")},9103:e=>{e.exports=require("query-string")},5828:e=>{e.exports=require("uuid")},8285:e=>{e.exports=require("x-xss-protection")},3685:e=>{e.exports=require("http")}},t={},r=function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(3864);for(var n in r)this[n]=r[n];r.__esModule&&Object.defineProperty(this,"__esModule",{value:!0})})(); \ No newline at end of file diff --git a/package.json b/package.json index 93377d0..7fec97e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zyndex-server", - "version": "0.2.0-35", + "version": "0.2.0-36", "description": "Backend Server for Handling Zyndex Frontend", "main": "app.js", "scripts": {