From 84e91c46ae00e39d62fbb20c76c12c8de5c9a300 Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 19 Sep 2022 00:12:56 +0100 Subject: [PATCH] added ability to config key in masterkey, added blacklist removal for dev mask to debugtool --- Live/CWX_DebugTool/dist/src/logging.ts | 14 +++- Live/CWX_DebugTool/src/logging.ts | 14 +++- .../bepInEx/plugins/CWX-MasterKey.dll | Bin 6144 -> 0 bytes .../user/mods/CWX-MasterKey 1.3.5/src/mod.ts | 11 --- .../bepInEx/plugins/CWX-MasterKey.dll | Bin 0 -> 7680 bytes .../mods/CWX-MasterKey 1.3.6}/LICENSE.txt | 0 .../mods/CWX-MasterKey 1.3.6}/package.json | 2 +- .../mods/CWX-MasterKey 1.3.6/src/config.json | 3 + .../user/mods/CWX-MasterKey 1.3.6/src/mod.ts | 50 +++++++++++++ Live/CWX_MasterKey/ConfigClass.cs | 7 ++ Live/CWX_MasterKey/MasterKey.cs | 70 +++++++++++++++--- Live/CWX_MasterKey/server/dist/package.json | 2 +- .../CWX_MasterKey/server/dist/src/config.json | 3 + Live/CWX_MasterKey/server/dist/src/mod.ts | 41 +++++++++- Live/CWX_MasterKey/server/package.json | 2 +- Live/CWX_MasterKey/server/src/config.json | 3 + Live/CWX_MasterKey/server/src/mod.ts | 41 +++++++++- 17 files changed, 231 insertions(+), 32 deletions(-) delete mode 100644 Live/CWX_MasterKey/CWX_MasterKey 1.3.5/bepInEx/plugins/CWX-MasterKey.dll delete mode 100644 Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts create mode 100644 Live/CWX_MasterKey/CWX_MasterKey 1.3.6/bepInEx/plugins/CWX-MasterKey.dll rename Live/CWX_MasterKey/{CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5 => CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6}/LICENSE.txt (100%) rename Live/CWX_MasterKey/{CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5 => CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6}/package.json (97%) create mode 100644 Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json create mode 100644 Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts create mode 100644 Live/CWX_MasterKey/ConfigClass.cs create mode 100644 Live/CWX_MasterKey/server/dist/src/config.json create mode 100644 Live/CWX_MasterKey/server/src/config.json diff --git a/Live/CWX_DebugTool/dist/src/logging.ts b/Live/CWX_DebugTool/dist/src/logging.ts index bd2f5ae..441fae2 100644 --- a/Live/CWX_DebugTool/dist/src/logging.ts +++ b/Live/CWX_DebugTool/dist/src/logging.ts @@ -37,6 +37,7 @@ export class CWX_Logging // items this.changeShrapProps(); this.changeMaxAmmoForKS23(); + this.removeDevFromBlacklist(); } @@ -104,7 +105,7 @@ export class CWX_Logging } } - private changeShrapProps():void + private changeShrapProps(): void { if (this.config.itemsConfig.changeShrapProps) { @@ -112,11 +113,20 @@ export class CWX_Logging } } - private changeMaxAmmoForKS23():void + private changeMaxAmmoForKS23(): void { if (this.config.itemsConfig.changeMaxAmmoForKS23) { this.logger.info("Change Max Ammo For KS23 Activated"); } } + + private removeDevFromBlacklist(): void + { + if (this.config.itemsConfig.removeDevFromBlacklist) + { + this.logger.info("Remove Dev From Blacklist Activated"); + } + } + } \ No newline at end of file diff --git a/Live/CWX_DebugTool/src/logging.ts b/Live/CWX_DebugTool/src/logging.ts index bd2f5ae..441fae2 100644 --- a/Live/CWX_DebugTool/src/logging.ts +++ b/Live/CWX_DebugTool/src/logging.ts @@ -37,6 +37,7 @@ export class CWX_Logging // items this.changeShrapProps(); this.changeMaxAmmoForKS23(); + this.removeDevFromBlacklist(); } @@ -104,7 +105,7 @@ export class CWX_Logging } } - private changeShrapProps():void + private changeShrapProps(): void { if (this.config.itemsConfig.changeShrapProps) { @@ -112,11 +113,20 @@ export class CWX_Logging } } - private changeMaxAmmoForKS23():void + private changeMaxAmmoForKS23(): void { if (this.config.itemsConfig.changeMaxAmmoForKS23) { this.logger.info("Change Max Ammo For KS23 Activated"); } } + + private removeDevFromBlacklist(): void + { + if (this.config.itemsConfig.removeDevFromBlacklist) + { + this.logger.info("Remove Dev From Blacklist Activated"); + } + } + } \ No newline at end of file diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/bepInEx/plugins/CWX-MasterKey.dll b/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/bepInEx/plugins/CWX-MasterKey.dll deleted file mode 100644 index f57a5ec68f0b8a86bc33242fc48a55efcdadf6ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6144 zcmeHLYiu0V6+U-&y|y>;+Ph91NFbTSsaWh}WXH~nlHkX#lZEvI@5TpWxb{8woO91T=iGD8eaw!2=27w!Q2_PwWulkSav6~D+F%vk;cY(&(~p|p z*#5Fey|F#BXgEsIwiaxypyV{uv|J^tEB2D97^V^*Pb&p$PFGu6LOV;UClW*{;it~K zpZHGM+C|!-tP?#%ZQukw?)@rS1$6+GdlW#Q=QlG-VnnMRpLu?oJuj889#$sXO2bT2 zp?92-0irku;>t2hv>v>k-9(uy`>sVRL`^mQO`wm~(5kC1yPzKm1E5d(hWXSMg=ki_ z9Xki6^lbnLFH{t@rVPM))zy6FSg`K(u|`G_r|uRCTCGH(_CWV- z(Lf9<6>4vwNW+;3uoxyB+7&5N&5-X{6WwA{doU8*6^57%OT{m+ETR*LZ2+?S<#$@6 zfwc~p-(qd#p5IZUg^+~W8)2g{wu#XuiZs>PC{Z;wnj_6@qp8kDW9+)JjmEVO%&TIf z$-15uhhQTV+sx=Xima=%QKD*WtdFc`8|&(9gkoFDHbQG12w25NvvmV2Zh?)K*o};0 zaJbG!iK?;D8fj%4;W`^Fv8`nrEo&WEiL#9@tYJUr#6C*hPgokpzfP$?mhm-8-7ZS} ztVq4!;q5(sf^VFD5qfhQl*9l+b|2Pf+lH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VAmSDGXt;Vi79S&V;?#*DV%3a zRkz5DmAz+124cq4-TwW1JmK=8r55LKVICdavllN+&x;-1}%rk}e#%_84*|$Ue zXQoPDi#(Yk;|gO}m-1Jo*K-0_Ts)s2#YyB{(Yh`VM6dVqr=aD^kX)_u6VCr30{mtt z!k6u8y)p0WtLH=bEO!+3_yEzL-q}<){pLHEr&c|!%=)p-VD*jGEhYc;&`SlWiDX6p; zmHmz52O}XP#J8D^*=mSM)#H!0rQ+_( zOMH$j+bYkODZX8=6{D(6FU}LtWx?JZ7gL%j%06@E}fdBvi diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts b/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts deleted file mode 100644 index 04faadb..0000000 --- a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { DependencyContainer } from "tsyringe"; -import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; - -class CWX_MasterKey implements IPreAkiLoadMod -{ - public preAkiLoad(container: DependencyContainer): void - { - } -} - -module.exports = { mod: new CWX_MasterKey() } \ No newline at end of file diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/bepInEx/plugins/CWX-MasterKey.dll b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/bepInEx/plugins/CWX-MasterKey.dll new file mode 100644 index 0000000000000000000000000000000000000000..052c745ba13b28166449c6bca7b2c0fb8a7eee17 GIT binary patch literal 7680 zcmeHLdu&_hbwA&|Bt=mYEmF4pQWRRYJKB_4$+E22@mxJfSxhABY0GV#%2(8td@Yif zx%bi*lh{?@HfVvq(seCR6lt3l1=6{Dv|bk%ZHgj6(RN7JBHgeIftL;)nhizQVd#c- znX}*d?xjfDjfefY$4B1topZkPo!9rgcj8?iC6$PLc;0-I=sDC}1|_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DFBN89Zl)P}T-5RUwoka`dbhco~ST3r&d z)DPZUCn1a0p1K}O@TLEb9vb8h!rK8PZ~#8kdZnXn@xSP?xY0wGG4#XFTCe&LK@aru zF!dp?tdVw3B6lYsnTO?BWK~1XcyyL{sK4^}<(F@K{U0CrM%RVMUw`P8ekU~P-G3TTL~KOs7a`JJSwArTI=3c9D0d?9FVZ54uT zv4E6gZic}GgK6kv*Mc!(PueKpI^>Jt0;mMSu&IQbprc|2`c(w1xcxG&I4agM;ZmrW zf@+R!x}iZ0M}yIzpOkP|fp737%(jER1`*YQB%YjSmT)c2rX5?%^cMc64bcHMDZ?d?AOY7Ls!T!VKdGXqs=LI6&wD&!q z`{H}^BPRyF^V8xlyswz-eX#PSxHc3IuYB!v$pzdUQ@Pv(PDS^ctn2b@cU#}wOR+mr z@>_KNZ({Lx0r`1(y*?^lL&V$k9ekGKZw_Y$iC*W4=attL9+K18G#3EVGy^PyFYPBm zX8=dtukQ3s-#^`Q-|yIhA8$=={SHqLzi-v3mE07dfL7j&N9EC{Lnj|{rflCM-_qvL zs)1|cXw>9^$OoZY{@6DLr9y7$mUmR%scDat=|SA?k56ypfR0fZeMjU$T9h`*h{!!8 zSigIiAE-ObAH<=-_k)z|Td|b_*T!+jJ{0SGyqk_5Y;9sA^3%{^L5m>|dbZz-uW5aF z`th*8DT+d#Gvr<@3h*^oV zq{rt=2-~W}%M>4_cgs=Lrkm#}=rZ9)33+mAyuO% literal 0 HcmV?d00001 diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/LICENSE.txt b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/LICENSE.txt similarity index 100% rename from Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/LICENSE.txt rename to Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/LICENSE.txt diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/package.json b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/package.json similarity index 97% rename from Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/package.json rename to Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/package.json index 5ec29d5..4ef5e2a 100644 --- a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/package.json +++ b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/package.json @@ -1,7 +1,7 @@ { "name": "MasterKey", "author": "CWX", - "version": "1.3.5", + "version": "1.3.6", "license": "NCSA", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json new file mode 100644 index 0000000..a17c1d5 --- /dev/null +++ b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json @@ -0,0 +1,3 @@ +{ + "keyId": "5c1d0d6d86f7744bb2683e1f" +} \ No newline at end of file diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts new file mode 100644 index 0000000..c7452ef --- /dev/null +++ b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts @@ -0,0 +1,50 @@ +import { DependencyContainer } from "tsyringe"; +import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; +import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; + +class CWX_MasterKey implements IPreAkiLoadMod +{ + + private router: DynamicRouterModService; + private cfg; + private http: HttpResponseUtil; + + public preAkiLoad(container: DependencyContainer): void + { + this.router = container.resolve("DynamicRouterModService"); + this.http = container.resolve("HttpResponseUtil"); + this.cfg = require("./config.json"); + + this.addRoute(); + } + + private addRoute() : void + { + this.router.registerDynamicRouter( + "MasterKey", + [ + { + url: "/cwx/masterkey", + action: (url, info, sessionId, output) => + { + return this.onRequestConfig(); + } + } + ], + "MasterKey" + ) + } + + private onRequestConfig(): any + { + if (typeof this.cfg.keyId !== "string") + { + return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" }); + } + + return this.http.noBody({ keyId: this.cfg.keyId}); + } +} + +module.exports = { mod: new CWX_MasterKey() } \ No newline at end of file diff --git a/Live/CWX_MasterKey/ConfigClass.cs b/Live/CWX_MasterKey/ConfigClass.cs new file mode 100644 index 0000000..f98e0db --- /dev/null +++ b/Live/CWX_MasterKey/ConfigClass.cs @@ -0,0 +1,7 @@ +namespace CWX_MasterKey +{ + public class ConfigClass + { + public string keyId { get; set; } + } +} diff --git a/Live/CWX_MasterKey/MasterKey.cs b/Live/CWX_MasterKey/MasterKey.cs index dd3e6b2..cf5b727 100644 --- a/Live/CWX_MasterKey/MasterKey.cs +++ b/Live/CWX_MasterKey/MasterKey.cs @@ -2,49 +2,95 @@ using EFT.Interactive; using System.Linq; using UnityEngine; +using System.Net; +using System.Threading; +using System.Collections.Generic; +using Aki.Common.Http; +using Aki.Common.Utils; namespace CWX_MasterKey { public static class MasterKey { + static object lockObject = new object(); + + // Black, Blue, Green, Red, Yellow, Violet + static string[] keys = new string[] { "5c1d0f4986f7744bb01837fa", "5c1d0c5f86f7744bb2683cf0", "5c1d0dc586f7744baf2e7b79", "5c1d0efb86f7744baf2e7b7b", "5c1d0d6d86f7744bb2683e1f", "5c1e495a86f7743109743dfb" }; + public static void Start() { - var allDoors = GameObject.FindObjectsOfType().ToList(); // mechanical doors - var allKeyCardDoors = GameObject.FindObjectsOfType().ToList(); // keycard doors - var allKeyContainers = GameObject.FindObjectsOfType().ToList(); // locked loot containers - var allTrunks = GameObject.FindObjectsOfType().ToList(); // locked car trunks + ConfigClass config = new ConfigClass(); + bool lockWasTaken = false; - foreach (var door in allDoors) // mechanical doors + string keyToUse = "5c1d0d6d86f7744bb2683e1f"; + + try + { + Monitor.Enter(lockObject, ref lockWasTaken); + + config = GetConfig(); + } + catch (WebException) + { + Debug.LogError("[CWX_Masterkey] Issue happened whilst getting config from server"); + } + finally + { + if (lockWasTaken) + { + Monitor.Exit(lockObject); + } + } + + if (keys.Any(x => x == config.keyId)) + { + keyToUse = config.keyId; + } + + List allDoors = GameObject.FindObjectsOfType().ToList(); // mechanical doors + List allKeyCardDoors = GameObject.FindObjectsOfType().ToList(); // keycard doors + List allKeyContainers = GameObject.FindObjectsOfType().ToList(); // locked loot containers + List allTrunks = GameObject.FindObjectsOfType().ToList(); // locked car trunks + + foreach (Door door in allDoors) // mechanical doors { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } - foreach (var door in allKeyCardDoors) // keycard doors + foreach (KeycardDoor door in allKeyCardDoors) // keycard doors { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } - foreach (var door in allKeyContainers) // locked loot containers + foreach (LootableContainer door in allKeyContainers) // locked loot containers { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } - foreach (var door in allTrunks) // locked car trunks + foreach (Trunk door in allTrunks) // locked car trunks { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } } + + public static ConfigClass GetConfig() + { + var json = RequestHandler.GetJson($"/cwx/masterkey"); + var jsonClass = Json.Deserialize(json); + + return jsonClass; + } } } \ No newline at end of file diff --git a/Live/CWX_MasterKey/server/dist/package.json b/Live/CWX_MasterKey/server/dist/package.json index 5ec29d5..4ef5e2a 100644 --- a/Live/CWX_MasterKey/server/dist/package.json +++ b/Live/CWX_MasterKey/server/dist/package.json @@ -1,7 +1,7 @@ { "name": "MasterKey", "author": "CWX", - "version": "1.3.5", + "version": "1.3.6", "license": "NCSA", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/Live/CWX_MasterKey/server/dist/src/config.json b/Live/CWX_MasterKey/server/dist/src/config.json new file mode 100644 index 0000000..a17c1d5 --- /dev/null +++ b/Live/CWX_MasterKey/server/dist/src/config.json @@ -0,0 +1,3 @@ +{ + "keyId": "5c1d0d6d86f7744bb2683e1f" +} \ No newline at end of file diff --git a/Live/CWX_MasterKey/server/dist/src/mod.ts b/Live/CWX_MasterKey/server/dist/src/mod.ts index 04faadb..c7452ef 100644 --- a/Live/CWX_MasterKey/server/dist/src/mod.ts +++ b/Live/CWX_MasterKey/server/dist/src/mod.ts @@ -1,10 +1,49 @@ import { DependencyContainer } from "tsyringe"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; +import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; class CWX_MasterKey implements IPreAkiLoadMod { + + private router: DynamicRouterModService; + private cfg; + private http: HttpResponseUtil; + public preAkiLoad(container: DependencyContainer): void - { + { + this.router = container.resolve("DynamicRouterModService"); + this.http = container.resolve("HttpResponseUtil"); + this.cfg = require("./config.json"); + + this.addRoute(); + } + + private addRoute() : void + { + this.router.registerDynamicRouter( + "MasterKey", + [ + { + url: "/cwx/masterkey", + action: (url, info, sessionId, output) => + { + return this.onRequestConfig(); + } + } + ], + "MasterKey" + ) + } + + private onRequestConfig(): any + { + if (typeof this.cfg.keyId !== "string") + { + return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" }); + } + + return this.http.noBody({ keyId: this.cfg.keyId}); } } diff --git a/Live/CWX_MasterKey/server/package.json b/Live/CWX_MasterKey/server/package.json index 5ec29d5..4ef5e2a 100644 --- a/Live/CWX_MasterKey/server/package.json +++ b/Live/CWX_MasterKey/server/package.json @@ -1,7 +1,7 @@ { "name": "MasterKey", "author": "CWX", - "version": "1.3.5", + "version": "1.3.6", "license": "NCSA", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/Live/CWX_MasterKey/server/src/config.json b/Live/CWX_MasterKey/server/src/config.json new file mode 100644 index 0000000..a17c1d5 --- /dev/null +++ b/Live/CWX_MasterKey/server/src/config.json @@ -0,0 +1,3 @@ +{ + "keyId": "5c1d0d6d86f7744bb2683e1f" +} \ No newline at end of file diff --git a/Live/CWX_MasterKey/server/src/mod.ts b/Live/CWX_MasterKey/server/src/mod.ts index 04faadb..c7452ef 100644 --- a/Live/CWX_MasterKey/server/src/mod.ts +++ b/Live/CWX_MasterKey/server/src/mod.ts @@ -1,10 +1,49 @@ import { DependencyContainer } from "tsyringe"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; +import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; class CWX_MasterKey implements IPreAkiLoadMod { + + private router: DynamicRouterModService; + private cfg; + private http: HttpResponseUtil; + public preAkiLoad(container: DependencyContainer): void - { + { + this.router = container.resolve("DynamicRouterModService"); + this.http = container.resolve("HttpResponseUtil"); + this.cfg = require("./config.json"); + + this.addRoute(); + } + + private addRoute() : void + { + this.router.registerDynamicRouter( + "MasterKey", + [ + { + url: "/cwx/masterkey", + action: (url, info, sessionId, output) => + { + return this.onRequestConfig(); + } + } + ], + "MasterKey" + ) + } + + private onRequestConfig(): any + { + if (typeof this.cfg.keyId !== "string") + { + return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" }); + } + + return this.http.noBody({ keyId: this.cfg.keyId}); } }