Skip to content

Commit

Permalink
Chore(deps): bump eventsource from 2.0.2 to 3.0.1 in the update-npm-d…
Browse files Browse the repository at this point in the history
…ependencies group across 1 directory (#325)

* Chore(deps): bump eventsource

Bumps the update-npm-dependencies group with 1 update in the / directory: [eventsource](https://github.com/EventSource/eventsource).


Updates `eventsource` from 2.0.2 to 3.0.1
- [Release notes](https://github.com/EventSource/eventsource/releases)
- [Changelog](https://github.com/EventSource/eventsource/blob/main/CHANGELOG.md)
- [Commits](EventSource/eventsource@v2.0.2...v3.0.1)

---
updated-dependencies:
- dependency-name: eventsource
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: update-npm-dependencies
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: simplify import

* fix: update EventSource usage

* refactor: use undici

* chore: remove axios

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Julian König <[email protected]>
  • Loading branch information
dependabot[bot] and jkoenig134 authored Dec 10, 2024
1 parent 8f2fa9a commit bb1852e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
32 changes: 26 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"compression": "1.7.5",
"correlation-id": "^5.2.0",
"cors": "2.8.5",
"eventsource": "^2.0.2",
"eventsource": "^3.0.1",
"express": "4.21.2",
"helmet": "8.0.0",
"json-stringify-safe": "5.0.1",
Expand All @@ -104,6 +104,7 @@
"redis": "^4.7.0",
"reflect-metadata": "0.2.2",
"swagger-ui-express": "5.0.1",
"undici": "^7.1.0",
"yamljs": "0.3.0",
"yargs": "^17.7.2"
},
Expand Down
19 changes: 13 additions & 6 deletions src/modules/sse/SseModule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ILogger } from "@js-soft/logging-abstractions";
import correlator from "correlation-id";
import eventSourceModule from "eventsource";
import { EventSource } from "eventsource";
import { Agent, fetch, ProxyAgent } from "undici";
import { ConnectorMode } from "../../ConnectorMode";
import { ConnectorRuntime } from "../../ConnectorRuntime";
import { ConnectorRuntimeModule, ConnectorRuntimeModuleConfiguration } from "../../ConnectorRuntimeModule";
Expand All @@ -21,7 +22,7 @@ export interface SseModuleConfiguration extends ConnectorRuntimeModuleConfigurat
}

export default class SseModule extends ConnectorRuntimeModule<SseModuleConfiguration> {
private eventSource: eventSourceModule | undefined;
private eventSource: EventSource | undefined;

public constructor(runtime: ConnectorRuntime, configuration: ConnectorRuntimeModuleConfiguration, logger: ILogger, connectorMode: ConnectorMode) {
super(runtime, configuration, logger, connectorMode);
Expand Down Expand Up @@ -53,13 +54,19 @@ export default class SseModule extends ConnectorRuntimeModule<SseModuleConfigura

this.logger.info(`Connecting to SSE endpoint: ${sseUrl}`);

const baseOptions = { connect: { rejectUnauthorized: false } };
const proxy = baseUrl.startsWith("https://") ? (process.env.https_proxy ?? process.env.HTTPS_PROXY) : (process.env.http_proxy ?? process.env.HTTP_PROXY);
const token = await this.runtime.getBackboneAuthenticationToken();

const eventSource = new eventSourceModule(sseUrl, {
https: { rejectUnauthorized: true },
proxy: process.env.HTTPS_PROXY ?? process.env.HTTP_PROXY,
headers: { authorization: `Bearer ${token}` }
const eventSource = new EventSource(sseUrl, {
fetch: (url, options) =>
fetch(url, {
...options,
dispatcher: proxy ? new ProxyAgent({ ...baseOptions, uri: proxy }) : new Agent(baseOptions),
headers: { ...options?.headers, authorization: `Bearer ${token}` }
})
});

this.eventSource = eventSource;

eventSource.addEventListener("ExternalEventCreated", async () => await this.runSync());
Expand Down
4 changes: 2 additions & 2 deletions src/modules/webhooks/WebhooksModule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Event, DataEvent as tsUtilsDataEvent } from "@js-soft/ts-utils";
import { DataEvent } from "@nmshd/runtime";
import agentKeepAlive, { HttpsAgent as AgentKeepAliveHttps } from "agentkeepalive";
import agentKeepAlive from "agentkeepalive";
import axios, { AxiosInstance } from "axios";
import correlator from "correlation-id";
import { ConnectorRuntimeModule } from "../../ConnectorRuntimeModule";
Expand All @@ -17,7 +17,7 @@ export default class WebhooksModule extends ConnectorRuntimeModule<WebhooksModul

this.axios = axios.create({
httpAgent: new agentKeepAlive(),
httpsAgent: new AgentKeepAliveHttps({ rejectUnauthorized: !this.configModel.skipTlsCheck }),
httpsAgent: new agentKeepAlive.HttpsAgent({ rejectUnauthorized: !this.configModel.skipTlsCheck }),
validateStatus: () => true,
maxRedirects: 0
});
Expand Down

0 comments on commit bb1852e

Please sign in to comment.