diff --git a/package-lock.json b/package-lock.json index 8ff73d6..3a6dbd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "morgan": "^1.10.0", "nanoid": "^3.2.0", "pug": "^3.0.3", - "ringcentral-chatbot-core": "^1.5.4-beta.1", + "ringcentral-chatbot-core": "^1.6.1", "sequelize": "^6.29.0", "serverless-http": "^2.6.0" }, @@ -2141,9 +2141,9 @@ } }, "node_modules/@mapbox/node-pre-gyp/node_modules/minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "engines": { "node": ">=8" @@ -2257,14 +2257,14 @@ } }, "node_modules/@mapbox/node-pre-gyp/node_modules/tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -5050,15 +5050,15 @@ } }, "node_modules/cacache/node_modules/tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "optional": true, "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -5068,9 +5068,9 @@ } }, "node_modules/cacache/node_modules/tar/node_modules/minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "optional": true, "engines": { @@ -7853,10 +7853,24 @@ "node": ">= 0.10" } }, - "node_modules/ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "optional": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/ip-address/node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", "dev": true, "optional": true }, @@ -9000,6 +9014,13 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true, + "optional": true + }, "node_modules/jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -10480,9 +10501,9 @@ } }, "node_modules/node-gyp/node_modules/minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "optional": true, "engines": { @@ -10608,15 +10629,15 @@ } }, "node_modules/node-gyp/node_modules/tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "optional": true, "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -11771,9 +11792,9 @@ } }, "node_modules/ringcentral-chatbot-core": { - "version": "1.5.4-beta.1", - "resolved": "https://registry.npmjs.org/ringcentral-chatbot-core/-/ringcentral-chatbot-core-1.5.4-beta.1.tgz", - "integrity": "sha512-OQTlhMnNAHx8Shjipv1gdZ9RUUmR0uP78vRmRjteejDQrj3i5ifKiwiNFi1ZDM5cjjkQ7O7pv6hKyqxU9+fA/A==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/ringcentral-chatbot-core/-/ringcentral-chatbot-core-1.6.1.tgz", + "integrity": "sha512-KAePli2v0ptwfXe6U4qVAtnftwzbEIOEke5tAiK67WIpAC5EEkjbWW3ag5ne0eFb1eawYkrsmCwWnm+WRfYX2w==", "dependencies": { "@rc-ex/core": "^1.3.7", "@types/express": "^4.17.13", @@ -12440,9 +12461,9 @@ } }, "node_modules/serverless/node_modules/tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "dependencies": { "chownr": "^2.0.0", @@ -12621,17 +12642,17 @@ } }, "node_modules/socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "dev": true, "optional": true, "dependencies": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" }, "engines": { - "node": ">= 10.13.0", + "node": ">= 10.0.0", "npm": ">= 3.0.0" } }, @@ -12824,9 +12845,9 @@ } }, "node_modules/sqlite3/node_modules/minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "engines": { "node": ">=8" @@ -12870,14 +12891,14 @@ } }, "node_modules/sqlite3/node_modules/tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -16078,9 +16099,9 @@ } }, "minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true }, "minizlib": { @@ -16163,14 +16184,14 @@ } }, "tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -18426,24 +18447,24 @@ "optional": true }, "tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "optional": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" }, "dependencies": { "minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "optional": true } @@ -20574,12 +20595,25 @@ "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", "dev": true }, - "ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", + "ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", "dev": true, - "optional": true + "optional": true, + "requires": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "dependencies": { + "sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true, + "optional": true + } + } }, "ipaddr.js": { "version": "1.9.1", @@ -21443,6 +21477,13 @@ "esprima": "^4.0.0" } }, + "jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true, + "optional": true + }, "jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -22640,9 +22681,9 @@ "optional": true }, "minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true, "optional": true }, @@ -22734,15 +22775,15 @@ } }, "tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "optional": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" @@ -23640,9 +23681,9 @@ } }, "ringcentral-chatbot-core": { - "version": "1.5.4-beta.1", - "resolved": "https://registry.npmjs.org/ringcentral-chatbot-core/-/ringcentral-chatbot-core-1.5.4-beta.1.tgz", - "integrity": "sha512-OQTlhMnNAHx8Shjipv1gdZ9RUUmR0uP78vRmRjteejDQrj3i5ifKiwiNFi1ZDM5cjjkQ7O7pv6hKyqxU9+fA/A==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/ringcentral-chatbot-core/-/ringcentral-chatbot-core-1.6.1.tgz", + "integrity": "sha512-KAePli2v0ptwfXe6U4qVAtnftwzbEIOEke5tAiK67WIpAC5EEkjbWW3ag5ne0eFb1eawYkrsmCwWnm+WRfYX2w==", "requires": { "@rc-ex/core": "^1.3.7", "@types/express": "^4.17.13", @@ -24077,9 +24118,9 @@ } }, "tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "requires": { "chownr": "^2.0.0", @@ -24249,13 +24290,13 @@ "optional": true }, "socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "dev": true, "optional": true, "requires": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" } }, @@ -24408,9 +24449,9 @@ } }, "minipass": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.5.tgz", - "integrity": "sha512-+yQl7SX3bIT83Lhb4BVorMAHVuqsskxRdlmO9kTpyukp8vsm2Sn/fUOV9xlnG8/a5JsypJzap21lz/y3FBMJ8Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", "dev": true }, "minizlib": { @@ -24441,14 +24482,14 @@ "dev": true }, "tar": { - "version": "6.1.13", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", - "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "requires": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", - "minipass": "^4.0.0", + "minipass": "^5.0.0", "minizlib": "^2.1.1", "mkdirp": "^1.0.3", "yallist": "^4.0.0" diff --git a/package.json b/package.json index 6fcf058..d38434e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "morgan": "^1.10.0", "nanoid": "^3.2.0", "pug": "^3.0.3", - "ringcentral-chatbot-core": "^1.5.4-beta.1", + "ringcentral-chatbot-core": "^1.6.1", "sequelize": "^6.29.0", "serverless-http": "^2.6.0" } diff --git a/src/server/handlers/interactiveMessages.js b/src/server/handlers/interactiveMessages.js index cacaf00..a4e1e0c 100644 --- a/src/server/handlers/interactiveMessages.js +++ b/src/server/handlers/interactiveMessages.js @@ -12,6 +12,7 @@ const { getAdaptiveCardFromTemplate } = require('../utils/getAdaptiveCardFromTem const authTokenTemplate = require('../adaptiveCards/authToken.json'); const messageCardTemplate = require('../adaptiveCards/message.json'); const stateOperationLogTemplate = require('../adaptiveCards/stateOperationLog.json'); +const { errorLogger } = require('../utils/logger'); async function saveAuthToken(authToken, body) { if (authToken) { @@ -83,7 +84,7 @@ async function notificationInteractiveMessages(req, res) { ); } } else { - console.error(e && e.message); + errorLogger(e); } } res.status(200); @@ -162,7 +163,7 @@ async function addOperationLogIntoCard(bot, cardId, data, user) { await bot.updateAdaptiveCard(cardId, newCard); } } catch (e) { - console.error(e && e.message); + errorLogger(e); } } @@ -284,7 +285,7 @@ async function botInteractiveMessagesHandler(req, res) { trackResult = 'permissionDenied'; } } else { - console.error(e && e.message); + errorLogger(e); } if (!res.headersSent) { res.status(200); @@ -297,7 +298,7 @@ async function botInteractiveMessagesHandler(req, res) { }); } } catch (e) { - console.error(e && e.message); + errorLogger(e); if (!res.headersSent) { res.status(500); res.send('Internal error'); diff --git a/src/server/index.js b/src/server/index.js index 82fc6d3..9904cb7 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -8,6 +8,7 @@ const notificationRoute = require('./routes/notification'); const subscriptionRoute = require('./routes/subscription'); const { botHandler } = require('./bot/handler'); const { botConfig } = require('./bot/config'); +const { errorLogger } = require('./utils/logger'); const app = express() app.use(morgan(function (tokens, req, res) { @@ -15,6 +16,9 @@ app.use(morgan(function (tokens, req, res) { if (url.indexOf('/bot-notify/') === 0) { url = `/bot-notify/[MASK]-${url.slice(-5)}`; // mask from log } + if (url.indexOf('/bot/oauth') === 0) { + url = '/bot/oauth'; // mask from log + } return [ tokens.method(req, res), url, @@ -40,4 +44,13 @@ app.post('/interactive-messages', notificationRoute.interactiveMessages); extendBotApp(app, [], botHandler, botConfig); app.post('/bot-notify/:id', notificationRoute.botNotification); +app.use(function (err, req, res, next) { + errorLogger(err); + if (res.headersSent) { + return next(err); + } + res.status(500); + res.json({ result: 'error', message: 'Internal server error' }); +}); + exports.app = app; diff --git a/src/server/routes/notification.js b/src/server/routes/notification.js index 6d86e82..b3b9ded 100644 --- a/src/server/routes/notification.js +++ b/src/server/routes/notification.js @@ -4,7 +4,7 @@ const Bot = require('ringcentral-chatbot-core/dist/models/Bot').default; const { decodeToken } = require('../utils/jwt'); const { sendAdaptiveCardToRCWebhook } = require('../utils/messageHelper'); const { Analytics } = require('../utils/analytics'); - +const { errorLogger } = require('../utils/logger'); const { Webhook } = require('../models/webhook'); const { notificationInteractiveMessages, botInteractiveMessagesHandler } = require('../handlers/interactiveMessages'); @@ -36,7 +36,7 @@ async function notification(req, res) { res.status(200); res.send('ok'); } catch (e) { - console.error(e && e.message); + errorLogger(e); res.status(500); res.send('error'); } @@ -68,7 +68,7 @@ async function botNotification(req, res) { userId: bot.id, accountId: bot.token && bot.token.creator_account_id, }); - analytics.trackBotAction('cardPosted', { + await analytics.trackBotAction('cardPosted', { chatId: groupId, }); } diff --git a/src/server/routes/subscription.js b/src/server/routes/subscription.js index bf1cae3..435c8fe 100644 --- a/src/server/routes/subscription.js +++ b/src/server/routes/subscription.js @@ -1,5 +1,6 @@ const { Webhook } = require('../models/webhook'); const { RCWebhook } = require('../models/rc-webhook'); +const { errorLogger } = require('../utils/logger'); // Setup page for install add-in async function setup(req, res) { @@ -72,7 +73,7 @@ async function createWebhook(req, res) { webhookUri: `${process.env.APP_SERVER}/notify/${bugsnagWebhook.id}`, }); } catch (e) { - console.error(e); + errorLogger(e); res.status(500); res.send('Internal server error'); return; diff --git a/src/server/utils/logger.js b/src/server/utils/logger.js new file mode 100644 index 0000000..5a8e55c --- /dev/null +++ b/src/server/utils/logger.js @@ -0,0 +1,33 @@ + +function logErrorResponse(response) { + const status = response.status; + const data = response.data; + const headers = response.headers || {}; + const rcRequestId = headers['rcrequestid']; + console.error( + 'Response error: ', status, + ' RequestId: ', rcRequestId, + ' Data: ', + data + ); +} + +function errorLogger(error) { + if (!error) { + return; + } + if (error.response) { + // https://axios-http.com/docs/handling_errors + // The request was made and the server responded with a status code + logErrorResponse(error.response); + return; + } + if (error.request) { + // The request was made but no response was received + console.error('Request error: ', error.code); + return; + } + console.error('Error: ', error.message); +} + +exports.errorLogger = errorLogger; diff --git a/tests/bot.test.js b/tests/bot.test.js index 6d568e0..3f93ec0 100644 --- a/tests/bot.test.js +++ b/tests/bot.test.js @@ -159,6 +159,90 @@ describe('Bot', () => { rcGroupScope.done(); }); + it('should send response 500 when fetch group message 500', async () => { + const rcGroupScope = nock(process.env.RINGCENTRAL_SERVER) + .get(uri => uri.includes(`/restapi/v1.0/glip/groups/${groupId}`)) + .reply(500, { + message: 'Service Unavailable' + }, { + rcrequestid: 'xxxxxx' + }); + const res = await request(server).post('/bot/webhook').send({ + "uuid": "5794186355105264737", + "event": "/restapi/v1.0/glip/posts", + "timestamp": "2022-02-11T09:49:55.091Z", + "subscriptionId": "0a7fb1f2-9e7c-456f-8078-148d1e7c3638", + "ownerId": botId, + "body": { + "id": "5852045316", + "groupId": groupId, + "type": "TextMessage", + "text": `![:Person](${botId}) help`, + "creatorId": "170848004", + "addedPersonIds": null, + "creationTime": "2022-02-11T09:49:54.614Z", + "lastModifiedTime": "2022-02-11T09:49:54.614Z", + "attachments": null, + "activity": null, + "title": null, + "iconUri": null, + "iconEmoji": null, + "mentions": [ + { + "id": botId, + "type": "Person", + "name": "Bugsnag Bot" + } + ], + "eventType": "PostAdded" + } + }); + expect(res.status).toEqual(500); + expect(res.body.message).toEqual('Internal server error'); + rcGroupScope.done(); + }); + + it('should send response 500 when fetch group message 503', async () => { + const rcGroupScope = nock(process.env.RINGCENTRAL_SERVER) + .get(uri => uri.includes(`/restapi/v1.0/glip/groups/${groupId}`)) + .reply(503, { + message: 'Service Unavailable' + }); + const res = await request(server).post('/bot/webhook').send({ + "uuid": "5794186355105264737", + "event": "/restapi/v1.0/glip/posts", + "timestamp": "2022-02-11T09:49:55.091Z", + "subscriptionId": "0a7fb1f2-9e7c-456f-8078-148d1e7c3638", + "ownerId": botId, + "body": { + "id": "5852045316", + "groupId": groupId, + "type": "TextMessage", + "text": `![:Person](${botId}) help`, + "creatorId": "170848004", + "addedPersonIds": null, + "creationTime": "2022-02-11T09:49:54.614Z", + "lastModifiedTime": "2022-02-11T09:49:54.614Z", + "attachments": null, + "activity": null, + "title": null, + "iconUri": null, + "iconEmoji": null, + "mentions": [ + { + "id": botId, + "type": "Person", + "name": "Bugsnag Bot" + } + ], + "eventType": "PostAdded" + } + }); + expect(res.status).toEqual(500); + expect(res.body.message).toEqual('Internal server error'); + rcGroupScope.done(); + }); + it('should send authorize card when bot get authorize command', async () => { const rcCardScope = nock(process.env.RINGCENTRAL_SERVER) .post(uri => uri.includes(`/restapi/v1.0/glip/chats/${groupId}/adaptive-cards`))