This commit is contained in:
parent
904a33a409
commit
023b83aacf
13 changed files with 25598 additions and 35786 deletions
25475
package-lock.json
generated
Normal file
25475
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
68
package.json
68
package.json
|
@ -59,12 +59,12 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/cognitiveservices-computervision": "8.2.0",
|
"@azure/cognitiveservices-computervision": "8.2.0",
|
||||||
"@azure/ms-rest-js": "2.7.0",
|
"@azure/ms-rest-js": "2.7.0",
|
||||||
"@azure/msal-node": "^3.7.3",
|
"@azure/msal-node": "3.7.3",
|
||||||
"@azure/openai": "2.0.0",
|
"@azure/openai": "2.0.0",
|
||||||
"@azure/search-documents": "12.1.0",
|
"@azure/search-documents": "12.1.0",
|
||||||
"@azure/storage-blob": "12.28.0",
|
"@azure/storage-blob": "12.28.0",
|
||||||
"@google-cloud/pubsub": "^5.2.0",
|
"@google-cloud/pubsub": "5.2.0",
|
||||||
"@google-cloud/translate": "^9.2.0",
|
"@google-cloud/translate": "9.2.0",
|
||||||
"@koa/cors": "5.0.0",
|
"@koa/cors": "5.0.0",
|
||||||
"@koa/router": "14.0.0",
|
"@koa/router": "14.0.0",
|
||||||
"@langchain/anthropic": "0.3.27",
|
"@langchain/anthropic": "0.3.27",
|
||||||
|
@ -78,6 +78,7 @@
|
||||||
"@push-rpc/websocket": "1.9.3",
|
"@push-rpc/websocket": "1.9.3",
|
||||||
"@sequelize/core": "7.0.0-alpha.46",
|
"@sequelize/core": "7.0.0-alpha.46",
|
||||||
"@sequelize/postgres": "7.0.0-alpha.46",
|
"@sequelize/postgres": "7.0.0-alpha.46",
|
||||||
|
"@sequelize/sqlite3": "^7.0.0-alpha.46",
|
||||||
"@types/validator": "13.15.3",
|
"@types/validator": "13.15.3",
|
||||||
"adm-zip": "0.5.16",
|
"adm-zip": "0.5.16",
|
||||||
"alasql": "4.6.6",
|
"alasql": "4.6.6",
|
||||||
|
@ -92,11 +93,10 @@
|
||||||
"bluebird": "3.7.2",
|
"bluebird": "3.7.2",
|
||||||
"body-parser": "2.2.0",
|
"body-parser": "2.2.0",
|
||||||
"botbuilder": "4.23.3",
|
"botbuilder": "4.23.3",
|
||||||
"botbuilder-adapter-facebook": "1.0.12",
|
|
||||||
"botbuilder-ai": "4.23.3",
|
"botbuilder-ai": "4.23.3",
|
||||||
"botbuilder-dialogs": "4.23.3",
|
"botbuilder-dialogs": "4.23.3",
|
||||||
"botframework-connector": "4.23.3",
|
"botframework-connector": "4.23.3",
|
||||||
"botlib-legacy": "5.1.1",
|
"botlib-legacy": "5.2.0",
|
||||||
"cd": "0.3.3",
|
"cd": "0.3.3",
|
||||||
"chalk-animation": "2.0.3",
|
"chalk-animation": "2.0.3",
|
||||||
"chrome-remote-interface": "0.33.3",
|
"chrome-remote-interface": "0.33.3",
|
||||||
|
@ -107,24 +107,23 @@
|
||||||
"csv-database": "0.9.2",
|
"csv-database": "0.9.2",
|
||||||
"data-forge": "1.10.4",
|
"data-forge": "1.10.4",
|
||||||
"date-diff": "1.0.2",
|
"date-diff": "1.0.2",
|
||||||
"docximager": "^0.0.4",
|
"docximager": "0.0.4",
|
||||||
"docxtemplater": "^3.66.3",
|
"docxtemplater": "3.66.3",
|
||||||
"dotenv-extended": "2.9.0",
|
"dotenv-extended": "2.9.0",
|
||||||
"exceljs": "^4.4.0",
|
"exceljs": "4.4.0",
|
||||||
"express": "5.1.0",
|
"express": "^4.21.2",
|
||||||
"express-remove-route": "1.0.0",
|
"express-remove-route": "1.0.0",
|
||||||
"facebook-nodejs-business-sdk": "23.0.1",
|
"facebook-nodejs-business-sdk": "23.0.1",
|
||||||
"ffmpeg-static": "5.2.0",
|
"ffmpeg-static": "5.2.0",
|
||||||
"final-stream": "^2.0.4",
|
"final-stream": "2.0.4",
|
||||||
"formidable": "3.5.4",
|
"formidable": "3.5.4",
|
||||||
"get-image-colors": "^4.0.1",
|
|
||||||
"glob": "11.0.3",
|
"glob": "11.0.3",
|
||||||
"google-libphonenumber": "3.2.42",
|
"google-libphonenumber": "3.2.42",
|
||||||
"googleapis": "^159.0.0",
|
"googleapis": "159.0.0",
|
||||||
"hnswlib-node": "3.0.0",
|
"hnswlib-node": "3.0.0",
|
||||||
"html-to-md": "0.8.8",
|
"html-to-md": "0.8.8",
|
||||||
"http-proxy": "1.18.1",
|
"http-proxy": "1.18.1",
|
||||||
"ibm-watson": "^11.0.0",
|
"ibm-watson": "11.0.0",
|
||||||
"icojs": "0.19.5",
|
"icojs": "0.19.5",
|
||||||
"iso-639-1": "3.1.5",
|
"iso-639-1": "3.1.5",
|
||||||
"isomorphic-fetch": "3.0.0",
|
"isomorphic-fetch": "3.0.0",
|
||||||
|
@ -145,20 +144,21 @@
|
||||||
"luxon": "3.7.2",
|
"luxon": "3.7.2",
|
||||||
"mammoth": "1.10.0",
|
"mammoth": "1.10.0",
|
||||||
"mariadb": "3.4.5",
|
"mariadb": "3.4.5",
|
||||||
|
"marked": "16.3.0",
|
||||||
"mime-types": "3.0.1",
|
"mime-types": "3.0.1",
|
||||||
"minio": "8.0.6",
|
"minio": "8.0.6",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
"ms-rest-azure": "^3.0.2",
|
|
||||||
"mysql": "2.18.1",
|
"mysql": "2.18.1",
|
||||||
"node-cron": "4.2.1",
|
"node-cron": "4.2.1",
|
||||||
|
"node-gyp": "^11.4.2",
|
||||||
"node-html-parser": "7.0.1",
|
"node-html-parser": "7.0.1",
|
||||||
"node-nlp": "^4.27.0",
|
"node-nlp": "4.27.0",
|
||||||
"nodemailer": "7.0.6",
|
"nodemailer": "7.0.6",
|
||||||
"nodemon": "3.1.10",
|
"nodemon": "3.1.10",
|
||||||
"npm": "11.6.0",
|
"npm": "11.6.0",
|
||||||
"office-text-extractor": "^3.0.3",
|
"office-text-extractor": "3.0.3",
|
||||||
"open": "10.2.0",
|
"open": "10.2.0",
|
||||||
"open-docxtemplater-image-module": "^1.0.3",
|
"open-docxtemplater-image-module": "1.0.3",
|
||||||
"openai": "4.62.1",
|
"openai": "4.62.1",
|
||||||
"pdf-extraction": "1.0.2",
|
"pdf-extraction": "1.0.2",
|
||||||
"pdf-parse": "1.1.1",
|
"pdf-parse": "1.1.1",
|
||||||
|
@ -172,6 +172,8 @@
|
||||||
"public-ip": "7.0.1",
|
"public-ip": "7.0.1",
|
||||||
"punycode": "2.3.1",
|
"punycode": "2.3.1",
|
||||||
"puppeteer": "24.20.0",
|
"puppeteer": "24.20.0",
|
||||||
|
"puppeteer-extra": "^3.3.6",
|
||||||
|
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
||||||
"qr-scanner": "1.4.2",
|
"qr-scanner": "1.4.2",
|
||||||
"qrcode": "1.5.4",
|
"qrcode": "1.5.4",
|
||||||
"qrcode-reader": "1.0.4",
|
"qrcode-reader": "1.0.4",
|
||||||
|
@ -186,29 +188,27 @@
|
||||||
"sequelize-typescript": "2.1.6",
|
"sequelize-typescript": "2.1.6",
|
||||||
"simple-git": "3.28.0",
|
"simple-git": "3.28.0",
|
||||||
"speakingurl": "14.0.1",
|
"speakingurl": "14.0.1",
|
||||||
|
"sqlite3": "^5.1.7",
|
||||||
"strict-password-generator": "1.1.2",
|
"strict-password-generator": "1.1.2",
|
||||||
"stripe": "18.5.0",
|
"stripe": "18.5.0",
|
||||||
"super-strong-password-generator": "2.0.2",
|
"super-strong-password-generator": "2.0.2",
|
||||||
"super-strong-password-generator-es": "2.0.2",
|
"super-strong-password-generator-es": "2.0.2",
|
||||||
"svg2img": "^1.0.0-beta.2",
|
|
||||||
"swagger-client": "3.35.6",
|
"swagger-client": "3.35.6",
|
||||||
"swagger-ui-dist": "5.29.0",
|
"swagger-ui-dist": "5.29.0",
|
||||||
"tabulator-tables": "6.3.1",
|
"tabulator-tables": "6.3.1",
|
||||||
"tedious": "18.6.1",
|
"tedious": "18.6.1",
|
||||||
"textract": "^2.5.0",
|
|
||||||
"twilio": "5.9.0",
|
"twilio": "5.9.0",
|
||||||
"twitter-api-v2": "1.27.0",
|
"twitter-api-v2": "1.27.0",
|
||||||
"typeorm": "0.3.26",
|
"typeorm": "0.3.26",
|
||||||
"typescript": "5.9.2",
|
"typescript": "5.9.2",
|
||||||
"url-join": "^5.0.0",
|
"url-join": "5.0.0",
|
||||||
"vhost": "3.0.2",
|
"vhost": "3.0.2",
|
||||||
"vm2": "github:n8n-io/vm2",
|
|
||||||
"walk-promise": "0.2.0",
|
"walk-promise": "0.2.0",
|
||||||
"washyourmouthoutwithsoap": "1.0.2",
|
"washyourmouthoutwithsoap": "1.0.2",
|
||||||
"webdav-server": "2.6.2",
|
"webdav-server": "2.6.2",
|
||||||
"webp-converter": "^2.3.3",
|
"webp-converter": "2.3.3",
|
||||||
"whatsapp-cloud-api": "0.3.1",
|
"whatsapp-cloud-api": "0.3.1",
|
||||||
"whatsapp-web.js": "^1.34.1",
|
"whatsapp-web.js": "1.34.1",
|
||||||
"ws": "8.18.3",
|
"ws": "8.18.3",
|
||||||
"yaml": "2.8.1",
|
"yaml": "2.8.1",
|
||||||
"yarn": "1.22.22",
|
"yarn": "1.22.22",
|
||||||
|
@ -319,37 +319,33 @@
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"lodash.trimend": "npm:lodash@4.17.21",
|
"lodash.trimend": "npm:lodash@4.17.21",
|
||||||
"lodash.isequal": "npm:lodash@4.17.21",
|
"lodash.isequal": "npm:lodash@4.17.21",
|
||||||
"node-domexception": "npm:whatwg-url@^11.0.0",
|
"node-domexception": "npm:whatwg-url@11.0.0",
|
||||||
"csv-database": {
|
"csv-database": {
|
||||||
"fast-csv": "4.3.6"
|
"fast-csv": "4.3.6"
|
||||||
},
|
},
|
||||||
"sequelize-typescript": {
|
"sequelize-typescript": {
|
||||||
"glob": "~9.0.0"
|
"glob": "~9.0.0"
|
||||||
},
|
},
|
||||||
"botbuilder-adapter-facebook": {
|
|
||||||
"node-domexception": "npm:whatwg-url@^11.0.0"
|
|
||||||
},
|
|
||||||
"tough-cookie": "4.1.3",
|
"tough-cookie": "4.1.3",
|
||||||
"phin": "3.7.1",
|
"phin": "3.7.1",
|
||||||
"xmldom": "npm:@xmldom/xmldom@^0.8.10",
|
"xmldom": "npm:@xmldom/xmldom@0.8.10",
|
||||||
"form-data": "2.5.5",
|
"form-data": "2.5.5",
|
||||||
"uuid": "9.0.1",
|
"uuid": "9.0.1",
|
||||||
"har-validator": "5.1.5",
|
"har-validator": "5.1.5",
|
||||||
"request": "2.88.2",
|
"yaeti": "npm:events@3.3.0",
|
||||||
"yaeti": "npm:events@^3.3.0",
|
"text-encoding": "npm:text-encoder-lite@1.0.1",
|
||||||
"text-encoding": "npm:text-encoder-lite@^1.0.1",
|
|
||||||
"docximager": {
|
"docximager": {
|
||||||
"xml2js": "^0.5.0"
|
"xml2js": "0.5.0"
|
||||||
},
|
},
|
||||||
"tar-fs": "3.1.0",
|
"tar-fs": "3.1.0",
|
||||||
"ws": "8.18.3",
|
"ws": "8.18.3",
|
||||||
"xml2js": "^0.6.2",
|
"xml2js": "0.6.2",
|
||||||
"inflight": "npm:lru-cache@^10.2.0",
|
"inflight": "npm:lru-cache@10.2.0",
|
||||||
"rimraf": "6.0.1",
|
"rimraf": "6.0.1",
|
||||||
"glob": "11.0.3",
|
"glob": "11.0.3",
|
||||||
"fstream": "npm:fs-extra@^11.0.0",
|
"fstream": "npm:fs-extra@11.0.0",
|
||||||
"puppeteer": "24.20.0",
|
"puppeteer": "24.20.0",
|
||||||
"fluent-ffmpeg": "npm:ffmpeg-static@^5.0.0",
|
"fluent-ffmpeg": "npm:ffmpeg-static@5.0.0",
|
||||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
|
||||||
"@nlpjs/xtables": {
|
"@nlpjs/xtables": {
|
||||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
|
||||||
|
|
|
@ -64,13 +64,13 @@ import { GBUtil } from '../../../src/util.js';
|
||||||
let msRestAzure: any = null;
|
let msRestAzure: any = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const msRestAzure = await import('ms-rest-azure');
|
const msRestAzure = require('ms-rest-azure');
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
let AuthenticationContext: any = null;
|
let AuthenticationContext: any = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const adal = await import('adal-node');
|
const adal = require('adal-node');
|
||||||
AuthenticationContext = adal.AuthenticationContext;
|
AuthenticationContext = adal.AuthenticationContext;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
| GNU Affero General Public License for more details. |
|
| GNU Affero General Public License for more details. |
|
||||||
| |
|
| |
|
||||||
| "General Bots" is a registered trademark of pragmatismo.com.br. |
|
| "General Bots" is a registered trademark of pragmatismo.com.br. |
|
||||||
| The licensing of the program under the AGPLv3 does not imply a |
|
The licensing of the program under the AGPLv3 does not imply a |
|
||||||
| trademark license. Therefore any rights, title and interest in |
|
| trademark license. Therefore any rights, title and interest in |
|
||||||
| our trademarks remain entirely with us. |
|
| our trademarks remain entirely with us. |
|
||||||
| |
|
| |
|
||||||
|
@ -39,10 +39,8 @@ import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||||
import { ScheduleServices } from './ScheduleServices.js';
|
import { ScheduleServices } from './ScheduleServices.js';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||||
import urlJoin from 'url-join';
|
import urlJoin from 'url-join';
|
||||||
import { NodeVM, VMScript } from 'vm2';
|
|
||||||
import { createVm2Pool } from './vm2-process/index.js';
|
import { createVm2Pool } from './vm2-process/index.js';
|
||||||
import { watch } from 'fs';
|
import { watch } from 'fs';
|
||||||
import textract from 'textract';
|
|
||||||
import walkPromise from 'walk-promise';
|
import walkPromise from 'walk-promise';
|
||||||
import child_process from 'child_process';
|
import child_process from 'child_process';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
@ -56,6 +54,21 @@ import { Sequelize, SequelizeOptions } from 'sequelize-typescript';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||||
import { GBUtil } from '../../../src/util.js';
|
import { GBUtil } from '../../../src/util.js';
|
||||||
|
import { createRequire } from 'module';
|
||||||
|
|
||||||
|
// Use .catch() instead of try/catch for dynamic imports
|
||||||
|
const vm2 = await import('vm2' as string).catch(error => {
|
||||||
|
console.log('vm2 not available, running in limited mode');
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
const NodeVM = vm2?.NodeVM;
|
||||||
|
const VMScript = vm2?.VMScript;
|
||||||
|
|
||||||
|
let textract: any = null;
|
||||||
|
try {
|
||||||
|
const textractModule = require('textract');
|
||||||
|
textract = textractModule.default || textractModule;
|
||||||
|
} catch {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fileoverview Decision was to priorize security(isolation) and debugging,
|
* @fileoverview Decision was to priorize security(isolation) and debugging,
|
||||||
|
@ -931,6 +944,11 @@ export class GBVMService extends GBService {
|
||||||
* Executes the converted JavaScript from BASIC code inside execution context.
|
* Executes the converted JavaScript from BASIC code inside execution context.
|
||||||
*/
|
*/
|
||||||
public static async callVM(text: string, min: GBMinInstance, step, pid, debug: boolean = false, params = []) {
|
public static async callVM(text: string, min: GBMinInstance, step, pid, debug: boolean = false, params = []) {
|
||||||
|
if (!vm2) {
|
||||||
|
GBLogEx.info(0, 'VM is disabled.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a class DialogKeywords which is the *this* pointer
|
// Creates a class DialogKeywords which is the *this* pointer
|
||||||
// in BASIC.
|
// in BASIC.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { GBUtil } from '../../../../src/util.js';
|
||||||
|
|
||||||
let finalStream: any = null;
|
let finalStream: any = null;
|
||||||
try {
|
try {
|
||||||
finalStream = await import('final-stream');
|
finalStream = require('final-stream');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
const waitUntil = condition => {
|
const waitUntil = condition => {
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
import { VMScript, NodeVM } from 'vm2';
|
|
||||||
import crypto1 from 'crypto';
|
import crypto1 from 'crypto';
|
||||||
import net1 from 'net';
|
import net1 from 'net';
|
||||||
|
|
||||||
|
let NodeVM, VMScript;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const NodeVM = require('vm2').NodeVM;
|
||||||
|
const VMScript = require('vm2').VMScript;
|
||||||
|
} catch {}
|
||||||
|
|
||||||
const evaluate = async (script, scope) => {
|
const evaluate = async (script, scope) => {
|
||||||
const vm = new NodeVM({
|
const vm = new NodeVM({
|
||||||
allowAsync: true,
|
allowAsync: true,
|
||||||
|
@ -26,13 +32,12 @@ const server = net1.createServer(socket => {
|
||||||
const buffer = [];
|
const buffer = [];
|
||||||
|
|
||||||
const sync = async () => {
|
const sync = async () => {
|
||||||
|
|
||||||
const request = buffer.join('').toString();
|
const request = buffer.join('').toString();
|
||||||
console.log(request);
|
console.log(request);
|
||||||
if (request.includes('\n')) {
|
if (request.includes('\n')) {
|
||||||
try {
|
try {
|
||||||
const { code, scope } = JSON.parse(request);
|
const { code, scope } = JSON.parse(request);
|
||||||
|
|
||||||
const result = await evaluate(code, {
|
const result = await evaluate(code, {
|
||||||
...scope,
|
...scope,
|
||||||
module: null
|
module: null
|
||||||
|
@ -49,11 +54,9 @@ const server = net1.createServer(socket => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
socket.on('error', err => {
|
socket.on('error', err => {
|
||||||
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
socket.on('data', data => {
|
socket.on('data', data => {
|
||||||
buffer.push(data);
|
buffer.push(data);
|
||||||
sync();
|
sync();
|
||||||
|
|
|
@ -555,7 +555,7 @@ export class GBConversationalService {
|
||||||
|
|
||||||
var renderer = new marked.Renderer();
|
var renderer = new marked.Renderer();
|
||||||
renderer['oldImage'] = renderer.image;
|
renderer['oldImage'] = renderer.image;
|
||||||
renderer.image = function (href, title, text) {
|
renderer.image = ({ href, title, text, tokens }) => {
|
||||||
var videos = ['webm', 'mp4', 'mov'];
|
var videos = ['webm', 'mp4', 'mov'];
|
||||||
var filetype = href.split('.').pop();
|
var filetype = href.split('.').pop();
|
||||||
if (videos.indexOf(filetype) > -1) {
|
if (videos.indexOf(filetype) > -1) {
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
import { createRpcServer } from '@push-rpc/core';
|
import { createRpcServer } from '@push-rpc/core';
|
||||||
import AuthenticationContext from 'adal-node';
|
|
||||||
import arrayBufferToBuffer from 'arraybuffer-to-buffer';
|
import arrayBufferToBuffer from 'arraybuffer-to-buffer';
|
||||||
import { Semaphore } from 'async-mutex';
|
import { Semaphore } from 'async-mutex';
|
||||||
import { AccessToken } from 'livekit-server-sdk';
|
import { AccessToken } from 'livekit-server-sdk';
|
||||||
|
@ -49,7 +48,7 @@ import {
|
||||||
TurnContext,
|
TurnContext,
|
||||||
UserState
|
UserState
|
||||||
} from 'botbuilder';
|
} from 'botbuilder';
|
||||||
import { FacebookAdapter } from 'botbuilder-adapter-facebook';
|
|
||||||
import {
|
import {
|
||||||
AttachmentPrompt,
|
AttachmentPrompt,
|
||||||
ConfirmPrompt,
|
ConfirmPrompt,
|
||||||
|
@ -108,6 +107,20 @@ import { GBLogEx } from './GBLogEx.js';
|
||||||
import { GBSSR } from './GBSSR.js';
|
import { GBSSR } from './GBSSR.js';
|
||||||
import Stripe from 'stripe';
|
import Stripe from 'stripe';
|
||||||
|
|
||||||
|
let AuthenticationContext: any = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const adal = require('adal-node');
|
||||||
|
AuthenticationContext = adal.AuthenticationContext;
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
let FacebookAdapter: any = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const facebook = require('botbuilder-adapter-facebook');
|
||||||
|
FacebookAdapter = facebook.FacebookAdapter;
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
||||||
*/
|
*/
|
||||||
|
@ -457,106 +470,52 @@ export class GBMinService {
|
||||||
|
|
||||||
this.createCheckHealthAddress(GBServer.globals.server, min, min.instance);
|
this.createCheckHealthAddress(GBServer.globals.server, min, min.instance);
|
||||||
|
|
||||||
GBServer.globals.server
|
if (process.env.WHATSAPP_ENABLED) {
|
||||||
.all(`/${min.instance.botId}/paymentSuccess`, async (req, res) => {
|
GBServer.globals.server
|
||||||
try {
|
.all(`/${min.instance.botId}/whatsapp`, async (req, res) => {
|
||||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
const challenge = (min.core['getParam'] as any)(min.instance, `Meta Challenge`, null, true);
|
||||||
GBLogEx.info(min, `Payment success webhook received for bot ${min.instance.botId}`);
|
|
||||||
|
|
||||||
const sessionId = req.query.session_id;
|
const status = req.body?.entry?.[0]?.changes?.[0]?.value?.statuses?.[0];
|
||||||
if (!sessionId) {
|
|
||||||
GBLogEx.info(min, 'No session_id parameter found in payment success callback');
|
if (status) {
|
||||||
return res.status(400).json({ success: false, error: 'Missing session_id parameter' });
|
GBLogEx.info(min, `WhatsApp: ${status.recipient_id} ${status.status}`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const session = await stripe.checkout.sessions.retrieve(sessionId);
|
if (req.query['hub.mode'] === 'subscribe') {
|
||||||
|
const val = req.query['hub.verify_token'];
|
||||||
|
|
||||||
if (session.payment_status === 'paid') {
|
if (challenge && val === challenge) {
|
||||||
GBLogEx.info(min, `Payment confirmed for session ${sessionId}`);
|
res.send(req.query['hub.challenge']);
|
||||||
|
res.status(200);
|
||||||
|
} else {
|
||||||
|
res.status(401);
|
||||||
|
}
|
||||||
|
res.end();
|
||||||
|
|
||||||
// Only for successful payment - send HTML to close window
|
return;
|
||||||
res.send(`
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Payment Successful</title>
|
|
||||||
<script>
|
|
||||||
// Close the window after a short delay
|
|
||||||
setTimeout(() => {
|
|
||||||
window.close();
|
|
||||||
}, 1000);
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body style="text-align: center; padding: 40px; font-family: Arial;">
|
|
||||||
<h1 style="color: #4CAF50;">Payment Successful!</h1>
|
|
||||||
<p>General Bots: Your transaction was completed successfully.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`);
|
|
||||||
} else {
|
|
||||||
GBLogEx.info(min, `Payment not completed for session ${sessionId}`);
|
|
||||||
res.status(402).json({
|
|
||||||
success: false,
|
|
||||||
error: 'Payment not completed',
|
|
||||||
sessionId: sessionId
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
GBLogEx.error(min, `Error processing payment success: ${error.message}`);
|
|
||||||
res.status(500).json({
|
|
||||||
success: false,
|
|
||||||
error: error.message
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.bind(min);
|
|
||||||
// Setups official handler for WhatsApp.
|
|
||||||
|
|
||||||
GBServer.globals.server
|
let whatsAppDirectLine = min.whatsAppDirectLine;
|
||||||
.all(`/${min.instance.botId}/whatsapp`, async (req, res) => {
|
|
||||||
const challenge = (min.core['getParam'] as any)(min.instance, `Meta Challenge`, null, true);
|
|
||||||
|
|
||||||
const status = req.body?.entry?.[0]?.changes?.[0]?.value?.statuses?.[0];
|
// Not meta, multiples bots on root bot.
|
||||||
|
|
||||||
if (status) {
|
if (!req.body.object) {
|
||||||
GBLogEx.info(min, `WhatsApp: ${status.recipient_id} ${status.status}`);
|
if (req.body.To) {
|
||||||
return;
|
const to = req.body.To.replace(/whatsapp\:\+/gi, '');
|
||||||
}
|
whatsAppDirectLine = WhatsappDirectLine.botsByNumber[to];
|
||||||
|
} else {
|
||||||
if (req.query['hub.mode'] === 'subscribe') {
|
const minBoot = GBServer.globals.minBoot as GBMinInstance;
|
||||||
const val = req.query['hub.verify_token'];
|
whatsAppDirectLine = minBoot.whatsAppDirectLine;
|
||||||
|
}
|
||||||
if (challenge && val === challenge) {
|
|
||||||
res.send(req.query['hub.challenge']);
|
|
||||||
res.status(200);
|
|
||||||
} else {
|
|
||||||
res.status(401);
|
|
||||||
}
|
}
|
||||||
res.end();
|
|
||||||
|
|
||||||
return;
|
if (whatsAppDirectLine) {
|
||||||
}
|
await whatsAppDirectLine.WhatsAppCallback(req, res, whatsAppDirectLine.botId);
|
||||||
|
|
||||||
let whatsAppDirectLine = min.whatsAppDirectLine;
|
|
||||||
|
|
||||||
// Not meta, multiples bots on root bot.
|
|
||||||
|
|
||||||
if (!req.body.object) {
|
|
||||||
if (req.body.To) {
|
|
||||||
const to = req.body.To.replace(/whatsapp\:\+/gi, '');
|
|
||||||
whatsAppDirectLine = WhatsappDirectLine.botsByNumber[to];
|
|
||||||
} else {
|
|
||||||
const minBoot = GBServer.globals.minBoot as GBMinInstance;
|
|
||||||
whatsAppDirectLine = minBoot.whatsAppDirectLine;
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
.bind(min);
|
||||||
if (whatsAppDirectLine) {
|
}
|
||||||
await whatsAppDirectLine.WhatsAppCallback(req, res, whatsAppDirectLine.botId);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.bind(min);
|
|
||||||
|
|
||||||
GBServer.globals.server.all(`/${min.instance.botId}/meeting-token`, async (req, res) => {
|
GBServer.globals.server.all(`/${min.instance.botId}/meeting-token`, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// Add to your route handler
|
// Add to your route handler
|
||||||
|
|
|
@ -49,7 +49,6 @@ import { EPubLoader } from '@langchain/community/document_loaders/fs/epub';
|
||||||
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
|
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
|
||||||
|
|
||||||
import isICO from 'icojs';
|
import isICO from 'icojs';
|
||||||
import getColors from 'get-image-colors';
|
|
||||||
import { Document } from 'langchain/document';
|
import { Document } from 'langchain/document';
|
||||||
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
|
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
|
||||||
import puppeteer, { executablePath, Page } from 'puppeteer';
|
import puppeteer, { executablePath, Page } from 'puppeteer';
|
||||||
|
@ -87,24 +86,24 @@ import { exec } from 'child_process';
|
||||||
|
|
||||||
let webp: any = null;
|
let webp: any = null;
|
||||||
try {
|
try {
|
||||||
webp = await import('webp-converter');
|
webp = require('webp-converter');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
let svg2img: any = null;
|
let svg2img: any = null;
|
||||||
try {
|
try {
|
||||||
const svg2imgModule = await import('svg2img');
|
const svg2imgModule = require('svg2img');
|
||||||
svg2img = svg2imgModule.default || svg2imgModule;
|
svg2img = svg2imgModule.default || svg2imgModule;
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
let getColors: any = null;
|
let getColors: any = null;
|
||||||
try {
|
try {
|
||||||
const getColorsModule = await import('get-image-colors');
|
const getColorsModule = require('get-image-colors');
|
||||||
getColors = getColorsModule.default || getColorsModule;
|
getColors = getColorsModule.default || getColorsModule;
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
let textract: any = null;
|
let textract: any = null;
|
||||||
try {
|
try {
|
||||||
const textractModule = await import('textract');
|
const textractModule = require('textract');
|
||||||
textract = textractModule.default || textractModule;
|
textract = textractModule.default || textractModule;
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -1,9 +1,12 @@
|
||||||
npm install \
|
npm install \
|
||||||
c3-chart-maker@0.2.8 \
|
c3-chart-maker@0.2.8 \
|
||||||
|
botbuilder-adapter-facebook@1.0.12 \
|
||||||
ms-rest-azure@3.0.2 \
|
ms-rest-azure@3.0.2 \
|
||||||
open-docxtemplater-image-module@1.0.3 \
|
open-docxtemplater-image-module@1.0.3 \
|
||||||
svg2img@1.0.0-beta.2 \
|
svg2img@1.0.0-beta.2 \
|
||||||
get-image-colors@4.0.1 \
|
get-image-colors@4.0.1 \
|
||||||
textract \
|
textract@2.5.0 \
|
||||||
webp-converter \
|
webp-converter \
|
||||||
final-stream
|
final-stream \
|
||||||
|
@sequelize/sqlite3 \
|
||||||
|
vm2@3.9.11
|
||||||
|
|
Loading…
Add table
Reference in a new issue