snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
This commit is contained in:
10
packages/apps/node-runtime/src/error-handlers.ts
Normal file
10
packages/apps/node-runtime/src/error-handlers.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as Messenger from '@rocket.chat/apps/base-runtime/dist/lib/messenger';
|
||||
|
||||
export default function registerErrorListeners() {
|
||||
process.on('uncaughtException', (error: Error, origin: 'uncaughtException' | 'unhandledRejection') => {
|
||||
Messenger.sendNotification({
|
||||
method: origin,
|
||||
params: [error.stack || error],
|
||||
});
|
||||
});
|
||||
}
|
||||
19
packages/apps/node-runtime/src/lib/loader-hook.ts
Normal file
19
packages/apps/node-runtime/src/lib/loader-hook.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { registerHooks } from 'node:module';
|
||||
import path from 'node:path';
|
||||
|
||||
// This file compiles to dist/lib/loader-hook.js.
|
||||
// Three levels up from dist/lib/ lands on packages/apps/ — the @rocket.chat/apps package root.
|
||||
const appsPackageDir = path.resolve(__dirname, '../../..');
|
||||
|
||||
const PACKAGE_PREFIX = '@rocket.chat/apps';
|
||||
|
||||
registerHooks({
|
||||
resolve(specifier, context, nextResolve) {
|
||||
if (specifier === PACKAGE_PREFIX || specifier.startsWith(`${PACKAGE_PREFIX}/`)) {
|
||||
const subpath = specifier.slice(PACKAGE_PREFIX.length).replace(/^\//, '');
|
||||
const localPath = subpath ? path.join(appsPackageDir, subpath) : appsPackageDir;
|
||||
return nextResolve(localPath, context);
|
||||
}
|
||||
return nextResolve(specifier, context);
|
||||
},
|
||||
});
|
||||
37
packages/apps/node-runtime/src/lib/require.ts
Normal file
37
packages/apps/node-runtime/src/lib/require.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
const ALLOWED_MODULES = [
|
||||
'path',
|
||||
'url',
|
||||
'crypto',
|
||||
'buffer',
|
||||
'stream',
|
||||
'net',
|
||||
'http',
|
||||
'https',
|
||||
'zlib',
|
||||
'util',
|
||||
'punycode',
|
||||
'os',
|
||||
'querystring',
|
||||
'fs',
|
||||
// External libraries
|
||||
'uuid',
|
||||
'@rocket.chat/apps-engine',
|
||||
];
|
||||
|
||||
// As the apps are bundled, the only times they will call require are
|
||||
// 1. To require native modules
|
||||
// 2. To require external npm packages we may provide
|
||||
// 3. To require apps-engine files
|
||||
export const sandboxRequire = (module: string) => {
|
||||
// Normalize Node built-in specifiers: accept both 'crypto' and 'node:crypto'
|
||||
const normalized = module.replace('node:', '');
|
||||
|
||||
// We allow variants like 'fs', 'node:fs' or 'node:fs/promises', or even '@rocket.chat/apps-engine/**'
|
||||
if (!ALLOWED_MODULES.some((mod) => normalized.startsWith(mod))) {
|
||||
throw new Error(`Module ${module} is not allowed`);
|
||||
}
|
||||
|
||||
// This is THE purpose of this function, we can't escape a dinamyc require call
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, import-x/no-dynamic-require, @typescript-eslint/no-require-imports
|
||||
return require(normalized);
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { Transport } from '@rocket.chat/apps/base-runtime/dist/lib/messenger';
|
||||
|
||||
/**
|
||||
* Transport that writes messages to the process' standard output.
|
||||
*
|
||||
* This is the transport used when the runtime is executed as a subprocess by
|
||||
* the Apps-Engine framework, and it is specific to platforms that expose a
|
||||
* Node-compatible `process.stdout`.
|
||||
*/
|
||||
export const stdoutTransport: Transport = {
|
||||
async send(message: Uint8Array): Promise<void> {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
process.stdout.write(message, (err) => (err ? reject(err) : resolve()));
|
||||
});
|
||||
},
|
||||
};
|
||||
30
packages/apps/node-runtime/src/main.ts
Normal file
30
packages/apps/node-runtime/src/main.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import './lib/loader-hook';
|
||||
|
||||
import { setSandboxGlobals, setSandboxRequire } from '@rocket.chat/apps/base-runtime/dist/handlers/app/construct';
|
||||
import { setTransport } from '@rocket.chat/apps/base-runtime/dist/lib/messenger';
|
||||
import { startMainLoop } from '@rocket.chat/apps/base-runtime/dist/mainLoop';
|
||||
|
||||
import registerErrorListeners from './error-handlers';
|
||||
import { sandboxRequire } from './lib/require';
|
||||
import { stdoutTransport } from './lib/transports/stdoutTransport';
|
||||
|
||||
if (!process.argv.includes('--subprocess')) {
|
||||
console.error(`
|
||||
This is the Node wrapper for the Rocket.Chat Apps runtime. It is not meant to be executed stand-alone;
|
||||
It is instead meant to be executed as a subprocess by the Apps-Engine framework.
|
||||
`);
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// This runtime communicates with the Apps-Engine host through stdout
|
||||
setTransport(stdoutTransport);
|
||||
|
||||
// The sandbox `require` handed to the app is Node's own global `require`; it
|
||||
// needs no extra globals beyond the common ones the base eval shell binds.
|
||||
setSandboxRequire(sandboxRequire);
|
||||
setSandboxGlobals({});
|
||||
|
||||
registerErrorListeners();
|
||||
|
||||
void startMainLoop();
|
||||
18
packages/apps/node-runtime/tsconfig.json
Normal file
18
packages/apps/node-runtime/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"baseUrl": ".",
|
||||
"types": ["node"],
|
||||
"lib": ["es2023"],
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"target": "es2023",
|
||||
"declaration": true,
|
||||
"paths": {
|
||||
"@rocket.chat/apps/*": ["../*"]
|
||||
}
|
||||
},
|
||||
"include": ["./src/**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user