diff --git a/extensions/securehub-file-upload/README-DE.md b/extensions/securehub-file-upload/README-DE.md new file mode 100644 index 00000000..8bac250a --- /dev/null +++ b/extensions/securehub-file-upload/README-DE.md @@ -0,0 +1,37 @@ +## Auf SecureHub hochladen + +Dieses benutzerdefinierte Modul ermöglicht es uns, Dateien auf ein Speicherkonto eines Drittanbieters hochzuladen, wodurch das ``securehub-file-upload``-Webchat-[Plugin](https://github.com/Cognigy/WebchatPlugins/tree/master/plugins/file) ausgelöst wird -hochladen). + +**WICHTIG (CORS):** + +Beim Ausführen dieser benutzerdefinierten Knoten könnte eine Fehlermeldung angezeigt werden, die besagt, dass der *origin https://webchat-demo.cognigy.ai durch die CORS-Richtlinie* blockiert wurde. Um dies zu beheben, muss die **CORS-Konfiguration** angepasst werden – Sie müssen zulassen, dass der Webchat Dateien am richtigen Ort speichert. + +## Auf Securehub-Speicher hochladen + +Um das benutzerdefinierte Modul korrekt nutzen zu können, sind einige Elemente erforderlich. + +* Ordnernamen + +Dies ist der Name des Ordners, in den die Dateien hochgeladen werden. + +* Base URL + +Die Base URL für die SecureHub-Umgebung. Normalerweise *securehub.yourcompanyname.com* oder ein ähnliches Muster. "https://" usw. sind nicht erforderlich. + +* SecureHub Verbindung + +Für die Verbindung benötigen wir Ihren Benutzernamen und Ihr Passwort. + +## Zusätzliche Einstellungen + +* Nicht auhorisierte Zertifikate ablehnen + +Wird automatisch auf „false“ gesetzt. Lassen Sie „false“, wenn Sie Zertifikatsfehler von SecureHub erhalten. + +* Ablauf des Links festlegen + +Soll der Standard-Linkablauf verwendet werden oder möchten Sie ein benutzerdefiniertes Datum verwenden? + +* Linkablauf (in Tagen) + +In wie vielen Tagen ab dem aktuellen Tag sollte der Link ablaufen? \ No newline at end of file diff --git a/extensions/securehub-file-upload/README.md b/extensions/securehub-file-upload/README.md new file mode 100644 index 00000000..2d83205e --- /dev/null +++ b/extensions/securehub-file-upload/README.md @@ -0,0 +1,37 @@ +## Upload To SecureHub + +This Custom Module will allow us to upload files to a third party storage account triggering the ``securehub-file-upload`` Webchat [plugin](https://github.com/Cognigy/WebchatPlugins/tree/master/plugins/file-upload). + +**IMPORTANT (CORS):** + +One could get an error message while executing these Custom Nodes where it says that the *origin https://webchat-demo.cognigy.ai has been blocked by CORS policy*. In order to fix this, the **CORS Configuration** needs to be adjusted -- you need to allow the webchat to store files in the correct location. + +## Upload To Securehub Storage + +In order to use the custom module correctly, some items are needed. + +* Folder Name + +This is the name given to the folder where the files will be uploaded. + +* Base URL + +The base URL for the SecureHub environment. Usually *securehub.yourcompanyname.com* or a similar pattern. "https://" etc. are not required. + +* Connection + +In the connection we will need your username and password. + +## Additional Options + +* Reject Unauthorized Certificates + +Automatically set to false. Leave as false if you receive certificate errors from SecureHub. + +* Define Link Expiration + +Should the standard link expiration be used or would you like to use a custom date. + +* Link Expiration (in Days) + +In how many days from the current day should the link expire? \ No newline at end of file diff --git a/extensions/securehub-file-upload/icon.png b/extensions/securehub-file-upload/icon.png new file mode 100644 index 00000000..55327c4c Binary files /dev/null and b/extensions/securehub-file-upload/icon.png differ diff --git a/extensions/securehub-file-upload/package-lock.json b/extensions/securehub-file-upload/package-lock.json new file mode 100644 index 00000000..8765a509 --- /dev/null +++ b/extensions/securehub-file-upload/package-lock.json @@ -0,0 +1,467 @@ +{ + "name": "file-upload", + "version": "4.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "file-upload", + "version": "4.0.0", + "license": "MIT", + "dependencies": { + "@cognigy/extension-tools": "^0.15.1", + "axios": "^0.21.1", + "https": "^1.0.0", + "luxon": "^3.4.3", + "tslint": "^6.1.2" + }, + "devDependencies": { + "@types/node": "^13.13.15", + "typescript": "^3.8.3" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", + "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "dependencies": { + "@babel/highlight": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@cognigy/extension-tools": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/@cognigy/extension-tools/-/extension-tools-0.15.1.tgz", + "integrity": "sha512-bfhB5jMVPqNkL8tv8cDWSH56P8K9TlTaQKwOsIzBysdpx33PQ/eIJRVO4aFVTlnBuIllxaKJTEF59ZtoV2qDwg==" + }, + "node_modules/@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", + "dev": true + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/https": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz", + "integrity": "sha512-4EC57ddXrkaF0x83Oj8sM6SLQHAWXw90Skqu2M4AEWENZ3F02dFJE/GARA8igO79tcgYqGrD7ae4f5L3um2lgg==" + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-core-module": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", + "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/luxon": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.4.3.tgz", + "integrity": "sha512-tFWBiv3h7z+T/tDaoxA8rqTxy1CHV6gHS//QdaH4pulbq/JuBSGgQspQQqcgnwdAx6pNI7cmvz5Sv/addzHmUg==", + "engines": { + "node": ">=12" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/resolve": { + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", + "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "dependencies": { + "is-core-module": "^2.11.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + }, + "node_modules/tslint": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", + "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", + "deprecated": "TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^4.0.1", + "glob": "^7.1.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.3", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.13.0", + "tsutils": "^2.29.0" + }, + "bin": { + "tslint": "bin/tslint" + }, + "engines": { + "node": ">=4.8.0" + }, + "peerDependencies": { + "typescript": ">=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 4.0.0-dev" + } + }, + "node_modules/tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dependencies": { + "tslib": "^1.8.1" + }, + "peerDependencies": { + "typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev" + } + }, + "node_modules/typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + } + } +} diff --git a/extensions/securehub-file-upload/package.json b/extensions/securehub-file-upload/package.json new file mode 100644 index 00000000..ac07e9e6 --- /dev/null +++ b/extensions/securehub-file-upload/package.json @@ -0,0 +1,29 @@ +{ + "name": "file-upload", + "version": "4.1.0", + "description": "Triggers the securehub-file-upload webchat plugin", + "main": "build/module.js", + "scripts": { + "transpile": "tsc -p .", + "zip": "tar cfz securehub-file-upload.tar.gz build/* package.json package-lock.json README.md icon.png", + "build": "npm run transpile && npm run lint && npm run zip", + "lint": "tslint -c tslint.json src/**/*.ts" + }, + "keywords": [ + "securehub", + "Storage" + ], + "author": "Cognigy GmbH", + "license": "MIT", + "dependencies": { + "@cognigy/extension-tools": "^0.15.1", + "axios": "^0.21.1", + "https": "^1.0.0", + "luxon": "^3.4.3", + "tslint": "^6.1.2" + }, + "devDependencies": { + "@types/node": "^13.13.15", + "typescript": "^3.8.3" + } +} diff --git a/extensions/securehub-file-upload/src/connections/securehubConnection.ts b/extensions/securehub-file-upload/src/connections/securehubConnection.ts new file mode 100644 index 00000000..640f3e85 --- /dev/null +++ b/extensions/securehub-file-upload/src/connections/securehubConnection.ts @@ -0,0 +1,9 @@ +import { IConnectionSchema } from "@cognigy/extension-tools"; + +export const securehubConnection: IConnectionSchema = { + type: "securehub", + label: "SecureHub Name and Password", + fields: [ + { fieldName: "username" }, + { fieldName: "password"} ] +}; \ No newline at end of file diff --git a/extensions/securehub-file-upload/src/module.ts b/extensions/securehub-file-upload/src/module.ts new file mode 100644 index 00000000..d0a9b901 --- /dev/null +++ b/extensions/securehub-file-upload/src/module.ts @@ -0,0 +1,16 @@ +import { createExtension } from "@cognigy/extension-tools"; +import { uploadToSecureHubNode } from "./nodes/uploadToSecureHub"; +import { securehubConnection } from "./connections/securehubConnection"; + +export default createExtension({ + nodes: [ + uploadToSecureHubNode + ], + + connections: [ + securehubConnection + ], + options: { + label: "SecureHub File Upload" + } +}); \ No newline at end of file diff --git a/extensions/securehub-file-upload/src/nodes/uploadToSecureHub.ts b/extensions/securehub-file-upload/src/nodes/uploadToSecureHub.ts new file mode 100644 index 00000000..a06b1d5b --- /dev/null +++ b/extensions/securehub-file-upload/src/nodes/uploadToSecureHub.ts @@ -0,0 +1,180 @@ +import { createNodeDescriptor, INodeFunctionBaseParams } from "@cognigy/extension-tools"; +import axios, { AxiosRequestConfig, AxiosResponse } from "axios"; +const https = require('https'); +const { DateTime } = require('luxon'); + +export interface IUploadToSecureHubParams extends INodeFunctionBaseParams { + config: { + connection: { + username: string; + password: string; + }; + folderName: string; + baseUrl: string; + rejectUnauthCert: boolean; + defineLinkExpiration: boolean; + daysExpiration: number; + }; +} +export const uploadToSecureHubNode = createNodeDescriptor({ + type: "uploadToSecureHub", + defaultLabel: { + default: "Upload To SecureHub", + deDE: "Auf SecureHub hochladen" + }, + summary: { + default: "Triggers the process required for the SecureHub upload plugin as well as retrieving the bearer token for the SecureHub API.", + deDE: "Vereinfacht der SecureHub-Webchat-Plugin-Upload-Prozess und erstellt einen Bearer Token für die SecureHub API." + }, + fields: [ + { + key: "connection", + label: { + default: "SecureHub Connection", + deDE: "SecureHub Verbindung" + }, + type: "connection", + params: { + connectionType: "securehub", + required: true + } + }, + { + key: "folderName", + label: { + default: "Folder Name", + deDE: "Ordnername" + }, + type: "cognigyText", + defaultValue: "Test-Folder", + params: { + required: true + } + }, + { + key: "baseUrl", + label: { + default: "Base URL", + deDE: "Base URL" + }, + type: "cognigyText", + defaultValue: "securehub.example.com", + params: { + required: true + } + }, + { + key: "rejectUnauthCert", + label: { + default: "Reject Unauthorized Certificates", + deDE: "Nicht auhorisierte Zertifikate ablehnen" + }, + description: { + default: "Should unauthorized certificates from the SecureHub server be rejected? If turned off this will fix the upload process in the event of an expired certificate but might be a security risk.", + deDE: "Sollten nicht autorisierte Zertifikate vom SecureHub-Server abgelehnt werden? Deaktiviert man dieser Option, behebt es Zertifikatprobleme beim Upload-Vorgang. Achtung: mögliche Sicherheitsrisiko.", + }, + type: "toggle", + defaultValue: false + }, + { + key: "defineLinkExpiration", + label: { + default: "Define Link Expiration", + deDE: "Ablauf des Links festlegen" + }, + description: { + default: "Customize how many days the link should remain active?", + deDE: "Anpassen wie viele Tage der Link aktiv bleiben soll.", + }, + type: "toggle", + defaultValue: false + }, + { + key: "daysExpiration", + label: { + default: "Link Expiration (in Days)", + deDE: "Linkablauf (in Tagen)" + }, + type: "number", + defaultValue: 14, + params: { + max: 90 + }, + condition: { + key: "defineLinkExpiration", + value: true + } + }, + ], + form: [ + { type: "field", key: "connection" }, + { type: "field", key: "folderName" }, + { type: "field", key: "baseUrl" }, + { type: "field", key: "rejectUnauthCert" }, + { type: "field", key: "defineLinkExpiration" }, + { type: "field", key: "daysExpiration" } + + ], + appearance: { + color: "#c80f2e" + }, + function: async ({ cognigy, config }: IUploadToSecureHubParams) => { + const { api } = cognigy; + const { connection, folderName, baseUrl, rejectUnauthCert, defineLinkExpiration, daysExpiration } = config; + const { username, password } = connection; + + + const agent = new https.Agent({ + rejectUnauthorized: false + }); + + let tokenUrl = `https://${baseUrl}/api/v1/oauth/token`; + + let data = { + "username": username, + "password": password, + "grant_type": "password" + }; + + const axiosConfig: AxiosRequestConfig = { + headers: { + "Content-Type": "application/json" + } + }; + + if (rejectUnauthCert === false) { + axiosConfig["httpsAgent"] = agent; + } + + let linkExpirationDate; + if (defineLinkExpiration === true) { + // Get the current date and time using Luxon + let currentDate = DateTime.utc(); + + // Add the specified number of days + let newDate = currentDate.plus({ days: daysExpiration }); + + // Format the date in the desired format: YYYY-MM-DDTHH:mm:ssZ (without milliseconds) + linkExpirationDate = newDate.toFormat('yyyy-MM-dd\'T\'HH:mm:ss\'Z\''); + } + + try { + const response: AxiosResponse = await axios.post(tokenUrl, data, axiosConfig); + let bearerToken = response.data.access_token; + api.say('', { + _plugin: { + type: 'securehub-file-upload', + baseUrl, + folderName, + bearerToken, + rejectCertificate: rejectUnauthCert, + defineLinkExpiration, + linkExpirationDate + } + }); + } catch (error) { + console.log("error", error); + api.addToContext("error", error, "simple"); + } + } +}); \ No newline at end of file diff --git a/extensions/securehub-file-upload/tsconfig.json b/extensions/securehub-file-upload/tsconfig.json new file mode 100644 index 00000000..13de74b6 --- /dev/null +++ b/extensions/securehub-file-upload/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es2017", + "module": "commonjs", + "rootDir": "src", + "outDir": "build", + "sourceMap": true, + "moduleResolution": "node" } +} \ No newline at end of file diff --git a/extensions/securehub-file-upload/tslint.json b/extensions/securehub-file-upload/tslint.json new file mode 100644 index 00000000..05996a97 --- /dev/null +++ b/extensions/securehub-file-upload/tslint.json @@ -0,0 +1,32 @@ +{ + "rules": { + "prefer-for-of": true, + "only-arrow-functions": [true, "allow-declarations", "allow-named-functions"], + "no-var-keyword": true, + "no-var-requires": false, + "comment-format": [true, "check-space"], + "no-duplicate-variable": true, + "no-eval": false, + "no-internal-module": true, + "no-trailing-whitespace": true, + "one-line": [true, "check-open-brace", "check-whitespace", "check-catch", "check-finally", "check-else"], + "semicolon": [true, "always"], + "triple-equals": [true, "allow-null-check"], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }], + "typedef": [true, "call-signature", "parameter", "member-variable-declaration"], + "variable-name": [true, "ban-keywords"], + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} \ No newline at end of file