matrix-appservice
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -1,7 +0,24 @@ | ||
0.4.2 (2020-07-24) | ||
0.5.0 (2020-09-14) | ||
=================== | ||
Features | ||
-------- | ||
- Expose `AppService.app` so that services may add their own Express request handlers. ([\#26](https://github.com/matrix-org/matrix-appservice-node/issues/26)) | ||
- Expose `AppService.expressApp` ([\#27](https://github.com/matrix-org/matrix-appservice-node/issues/27)) | ||
- Documentation is now generated for Typescript files ([\#28](https://github.com/matrix-org/matrix-appservice-node/issues/28)) | ||
Internal Changes | ||
---------------- | ||
- Remove `request` dependency ([\#25](https://github.com/matrix-org/matrix-appservice-node/issues/25)) | ||
0.4.2 (2020-07-24) | ||
=================== | ||
Internal Changes | ||
---------------- | ||
- Start using towncrier for changelogs ([\#23](https://github.com/matrix-org/matrix-appservice-node/issues/23)) | ||
@@ -8,0 +25,0 @@ - Update packages. ([\#24](https://github.com/matrix-org/matrix-appservice-node/issues/24)) |
/// <reference types="node" /> | ||
import { Application } from "express"; | ||
import { EventEmitter } from "events"; | ||
export declare class AppService extends EventEmitter { | ||
private config; | ||
export declare interface AppService { | ||
/** | ||
* An HTTP log line. | ||
* @event AppService#http-log | ||
* @type {String} | ||
* Emitted when an event is pushed to the appservice. | ||
* The format of the event object is documented at | ||
* https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid | ||
* @event | ||
* @example | ||
* appService.on("http-log", function(logLine) { | ||
* console.log(logLine); | ||
* appService.on("event", function(ev) { | ||
* console.log("ID: %s", ev.event_id); | ||
* }); | ||
*/ | ||
on(event: "event", cb: (event: Record<string, unknown>) => void): this; | ||
/** | ||
* An incoming Matrix JSON event. | ||
* @event AppService#event | ||
* @type {Object} | ||
* Emitted when the HTTP listener logs some information. | ||
* `access_tokens` are stripped from requests | ||
* @event | ||
* @example | ||
* appService.on("event", function(ev) { | ||
* console.log("ID: %s", ev.event_id); | ||
* appService.on("http-log", function(line) { | ||
* console.log(line); | ||
* }); | ||
*/ | ||
on(event: "http-log", cb: (line: string) => void): this; | ||
/** | ||
* An incoming Matrix JSON event, filtered by <code>event.type</code> | ||
* @event AppService#type:event | ||
* @type {Object} | ||
* Emitted when an event of a particular type is pushed | ||
* to the appservice. This will be emitted *in addition* | ||
* to "event", so ensure your bridge deduplicates events. | ||
* @event | ||
* @param event Should start with "type:" | ||
* @example | ||
* appService.on("type:m.room.message", function(ev) { | ||
* console.log("Body: %s", ev.content.body); | ||
* appService.on("type:m.room.message", function(event) { | ||
* console.log("ID: %s", ev.content.body); | ||
* }); | ||
*/ | ||
private app; | ||
on(event: string, cb: (event: Record<string, unknown>) => void): this; | ||
} | ||
export declare class AppService extends EventEmitter { | ||
private config; | ||
/** | ||
* @deprecated Use `AppService.expressApp` | ||
*/ | ||
readonly app: Application; | ||
private server?; | ||
@@ -83,2 +95,7 @@ private lastProcessedTxnId; | ||
setHomeserverToken(hsToken: string): void; | ||
/** | ||
* The Express App instance for the appservice, which | ||
* can be extended with paths. | ||
*/ | ||
get expressApp(): Application; | ||
private onMorganLog; | ||
@@ -85,0 +102,0 @@ private isInvalidToken; |
@@ -14,2 +14,3 @@ "use strict"; | ||
const https_1 = __importDefault(require("https")); | ||
const http_1 = __importDefault(require("http")); | ||
const MAX_SIZE_BYTES = 5000000; // 5MB | ||
@@ -77,3 +78,3 @@ class AppService extends events_1.EventEmitter { | ||
else { | ||
serverApp = this.app; | ||
serverApp = http_1.default.createServer({}, this.app); | ||
} | ||
@@ -85,10 +86,9 @@ if (callback) { | ||
return new Promise((resolve, reject) => { | ||
this.server = serverApp.listen(port, hostname, backlog, (err) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
else { | ||
resolve(); | ||
} | ||
serverApp.on("error", (err) => { | ||
reject(err); | ||
}); | ||
serverApp.on("listening", () => { | ||
resolve(); | ||
}); | ||
this.server = serverApp.listen(port, hostname, backlog); | ||
}); | ||
@@ -134,2 +134,9 @@ } | ||
} | ||
/** | ||
* The Express App instance for the appservice, which | ||
* can be extended with paths. | ||
*/ | ||
get expressApp() { | ||
return this.app; | ||
} | ||
onMorganLog(str) { | ||
@@ -136,0 +143,0 @@ const redactedStr = str.replace(/access_token=.*?(&|\s|$)/, "access_token=<REDACTED>$1"); |
{ | ||
"name": "matrix-appservice", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Matrix Application Service Framework", | ||
@@ -11,7 +11,7 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"gendoc": "jsdoc -r lib -R README.md -P package.json -d .jsdoc", | ||
"gendoc": "typedoc", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"lint": "eslint -c .eslintrc --max-warnings 0 src/**/*.ts", | ||
"prepublishOnly": "npm run build", | ||
"build": "tsc --project tsconfig.json" | ||
"build": "tsc --project tsconfig.json", | ||
"prepare": "npm run build" | ||
}, | ||
@@ -27,20 +27,19 @@ "repository": { | ||
"dependencies": { | ||
"@types/express": "^4.17.8", | ||
"body-parser": "^1.19.0", | ||
"express": "^4.17.1", | ||
"js-yaml": "^3.14.0", | ||
"morgan": "^1.10.0", | ||
"request": "^2.88.2" | ||
"morgan": "^1.10.0" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^3.7.0", | ||
"@typescript-eslint/parser": "^3.7.0", | ||
"@types/body-parser": "^1.19.0", | ||
"@types/express": "^4.17.7", | ||
"@types/js-yaml": "^3.12.5", | ||
"@types/morgan": "^1.9.1", | ||
"@types/node": "^10.17.0", | ||
"eslint": "^7.5.0", | ||
"jsdoc": "^3.6.4", | ||
"@types/node": "^10.17.29", | ||
"@typescript-eslint/eslint-plugin": "^3.10.1", | ||
"@typescript-eslint/parser": "^3.10.1", | ||
"eslint": "^7.8.1", | ||
"typedoc": "^0.19.1", | ||
"typescript": "^3.9.7" | ||
} | ||
} |
@@ -8,38 +8,48 @@ import {Application, Request, Response, default as express} from "express"; | ||
import https from "https"; | ||
import { Server } from "http"; | ||
import { Server, default as http } from "http"; | ||
const MAX_SIZE_BYTES = 5000000; // 5MB | ||
export class AppService extends EventEmitter { | ||
export declare interface AppService { | ||
/** | ||
* An HTTP log line. | ||
* @event AppService#http-log | ||
* @type {String} | ||
* Emitted when an event is pushed to the appservice. | ||
* The format of the event object is documented at | ||
* https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid | ||
* @event | ||
* @example | ||
* appService.on("http-log", function(logLine) { | ||
* console.log(logLine); | ||
* appService.on("event", function(ev) { | ||
* console.log("ID: %s", ev.event_id); | ||
* }); | ||
*/ | ||
on(event: "event", cb: (event: Record<string, unknown>) => void): this; | ||
/** | ||
* An incoming Matrix JSON event. | ||
* @event AppService#event | ||
* @type {Object} | ||
* Emitted when the HTTP listener logs some information. | ||
* `access_tokens` are stripped from requests | ||
* @event | ||
* @example | ||
* appService.on("event", function(ev) { | ||
* console.log("ID: %s", ev.event_id); | ||
* appService.on("http-log", function(line) { | ||
* console.log(line); | ||
* }); | ||
*/ | ||
on(event: "http-log", cb: (line: string) => void): this; | ||
/** | ||
* An incoming Matrix JSON event, filtered by <code>event.type</code> | ||
* @event AppService#type:event | ||
* @type {Object} | ||
* Emitted when an event of a particular type is pushed | ||
* to the appservice. This will be emitted *in addition* | ||
* to "event", so ensure your bridge deduplicates events. | ||
* @event | ||
* @param event Should start with "type:" | ||
* @example | ||
* appService.on("type:m.room.message", function(ev) { | ||
* console.log("Body: %s", ev.content.body); | ||
* appService.on("type:m.room.message", function(event) { | ||
* console.log("ID: %s", ev.content.body); | ||
* }); | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
on(event: string, cb: (event: Record<string, unknown>) => void): this; | ||
} | ||
private app: Application; | ||
export class AppService extends EventEmitter { | ||
/** | ||
* @deprecated Use `AppService.expressApp` | ||
*/ | ||
public readonly app: Application; | ||
private server?: Server; | ||
@@ -91,3 +101,3 @@ private lastProcessedTxnId = ""; | ||
const tlsCert = process.env.MATRIX_AS_TLS_CERT; | ||
let serverApp: Server|Application; | ||
let serverApp: Server; | ||
if (tlsKey || tlsCert) { | ||
@@ -113,3 +123,3 @@ if (!(tlsKey && tlsCert)) { | ||
else { | ||
serverApp = this.app; | ||
serverApp = http.createServer({}, this.app); | ||
} | ||
@@ -121,9 +131,9 @@ if (callback) { | ||
return new Promise((resolve, reject) => { | ||
this.server = serverApp.listen(port, hostname, backlog, (err: Error|null) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
serverApp.on("error", (err) => { | ||
reject(err) | ||
}); | ||
serverApp.on("listening", () => { | ||
resolve(); | ||
}); | ||
this.server = serverApp.listen(port, hostname, backlog); | ||
}); | ||
@@ -175,2 +185,10 @@ } | ||
/** | ||
* The Express App instance for the appservice, which | ||
* can be extended with paths. | ||
*/ | ||
public get expressApp() { | ||
return this.app; | ||
} | ||
private onMorganLog(str: string) { | ||
@@ -177,0 +195,0 @@ const redactedStr = str.replace(/access_token=.*?(&|\s|$)/, "access_token=<REDACTED>$1"); |
@@ -20,3 +20,10 @@ { | ||
"index.js" | ||
] | ||
], | ||
"typedocOptions": { | ||
"mode": "library", | ||
"out": ".typedoc", | ||
"excludePrivate": true, | ||
"excludeNotExported": false, | ||
"exclude": ["**/index.ts"] | ||
} | ||
} |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
64350
9
1286
2
+ Added@types/express@^4.17.8
+ Added@types/body-parser@1.19.5(transitive)
+ Added@types/connect@3.4.38(transitive)
+ Added@types/express@4.17.21(transitive)
+ Added@types/express-serve-static-core@4.19.6(transitive)
+ Added@types/http-errors@2.0.4(transitive)
+ Added@types/mime@1.3.5(transitive)
+ Added@types/node@22.10.10(transitive)
+ Added@types/qs@6.9.18(transitive)
+ Added@types/range-parser@1.2.7(transitive)
+ Added@types/send@0.17.4(transitive)
+ Added@types/serve-static@1.15.7(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removedrequest@^2.88.2
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)