From e1c12f5213bfa7b0cb62c229bb0b79ae2417fc10 Mon Sep 17 00:00:00 2001 From: souvik Date: Fri, 29 Sep 2023 15:58:15 +0530 Subject: [PATCH] fix: security --- src/adapters/mqtt/index.ts | 12 ++++++------ src/adapters/ws/client.ts | 2 +- src/lib/adapter.ts | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/adapters/mqtt/index.ts b/src/adapters/mqtt/index.ts index 40b9453ff..7e9acf7cb 100644 --- a/src/adapters/mqtt/index.ts +++ b/src/adapters/mqtt/index.ts @@ -48,14 +48,14 @@ class MqttAdapter extends Adapter { const securityRequirements = this.AsyncAPIServer.security().map(e => e.map(e => e.scheme())) - securityRequirements.forEach(sec => { - for (const security of sec) { - if(security.type() === 'userPassword') { - userAndPasswordSecurityReq = security + securityRequirements.forEach(security => { + for (const sec of security) { + if(sec.type() === 'userPassword') { + userAndPasswordSecurityReq = sec } - if (security.type() === 'x509') { - X509SecurityReq = security + if (sec.type() === 'x509') { + X509SecurityReq = sec } } }) diff --git a/src/adapters/ws/client.ts b/src/adapters/ws/client.ts index 6bed92d88..6fa9fe188 100644 --- a/src/adapters/ws/client.ts +++ b/src/adapters/ws/client.ts @@ -78,7 +78,7 @@ class WsClientAdapter extends Adapter { const channels = [] for (const channel of this.channelNames) { if (this.parsedAsyncAPI.channels().get(channel).bindings().get('ws')) { - if (this.parsedAsyncAPI.channels().get(channel).servers().length !== 0) { // NOSONAR + if (this.parsedAsyncAPI.channels().get(channel).servers().all().length !== 0) { // NOSONAR if ( this.parsedAsyncAPI .channels().get(channel) diff --git a/src/lib/adapter.ts b/src/lib/adapter.ts index 3d85f333c..6f6115f65 100644 --- a/src/lib/adapter.ts +++ b/src/lib/adapter.ts @@ -27,6 +27,7 @@ class GleeAdapter extends EventEmitter { private _AsyncAPIServer: Server private _parsedAsyncAPI: AsyncAPIDocument private _channelNames: string[] + private _channelAddresses: string[] private _connections: GleeConnection[] private _serverUrlExpanded: string @@ -52,6 +53,7 @@ class GleeAdapter extends EventEmitter { this._parsedAsyncAPI = parsedAsyncAPI this._channelNames = this._parsedAsyncAPI.channels().all().map(e => e.address()) + this._channelAddresses = this._parsedAsyncAPI.channels().all().map(c => c.address()) this._connections = [] const uriTemplateValues = new Map() @@ -194,6 +196,10 @@ class GleeAdapter extends EventEmitter { return this._channelNames } + get channelAddresses(): string[] { + return this._channelAddresses + } + get connections(): GleeConnection[] { return this._connections }