UNPKG

@mdf.js/openc2

Version:

MMS - API - Observability

58 lines 2.19 kB
/** * Copyright 2024 Mytra Control S.L. All rights reserved. * * Use of this source code is governed by an MIT-style license that can be found in the LICENSE file * or at https://opensource.org/licenses/MIT. */ export declare class AddressMapper { /** Address resolution map */ private readonly addressMap; /** Reverse address resolution map */ private readonly reverseAddressMap; /** Create a new instance of AddressMapper */ constructor(); /** * Update or create a new address entry in the map * @param socketId - Socket.IO to be mapped * @param openC2Id - OpenC2 identification to be mapped */ update(socketId: string, openC2Id: string): void; /** * Delete an entry from the address map * @param socketId - Socket.IO id to be removed */ delete(socketId: string): void; /** * Get the OpenC2 id that match with the provided Socket.IO id * @param socketId - socket identification to be mapped * @returns OpenC2 id * @throws if no valid URL is provided URL * @example * ```typescript * const mapper = new AddressMapper(); * mapper.update('CmFw2HksBDH5Q6VMAAAC', 'myId'); * mapper.update('mK8mSuq2R0QxLDdHAAAF', 'myOtherId'); * mapper.getBySocketId('otherId'); // undefined * mapper.getBySocketId('CmFw2HksBDH5Q6VMAAAC'); // 'myId' * mapper.getBySocketId('mK8mSuq2R0QxLDdHAAAF'); // 'myOtherId' * ``` */ getBySocketId(socketId: string): string | undefined; /** * Get the Socket.IO id from the OpenC2 id * @param openC2Id - OpenC2 id to be mapped * @returns Socket.IO id * @throws if no valid OpenC2 id is provided * @example * ```typescript * const mapper = new AddressMapper(); * mapper.update('CmFw2HksBDH5Q6VMAAAC', 'myId'); * mapper.update('mK8mSuq2R0QxLDdHAAAF', 'myOtherId'); * mapper.getByOpenC2Id('otherId'); // undefined * mapper.getByOpenC2Id('CmFw2HksBDH5Q6VMAAAC'); // 'myId' * mapper.getByOpenC2Id('mK8mSuq2R0QxLDdHAAAF'); // 'myOtherId' * ``` */ getByOpenC2Id(openC2Id: string): string | undefined; } //# sourceMappingURL=AddressMapper.d.ts.map