@affinidi-tdk/iota-browser
Version:
Browser module to fetch data through Affinidi Iota Framework
50 lines (49 loc) • 1.63 kB
TypeScript
import { iot, mqtt5 } from 'aws-iot-device-sdk-v2/dist/browser';
import { IotaError } from '../validators/error';
export interface IotaCredentials {
readonly credentials: Credentials;
readonly connectionClientId: string;
}
export interface Credentials {
readonly accessKeyId?: string;
readonly secretKey?: string;
readonly sessionToken?: string;
readonly expiration?: Date;
}
export type ChannelProviderParams = {
credentials: IotaCredentials;
iotEndpoint?: string;
region?: string;
};
export type PrepareRequestParams = {
queryId: string;
correlationId?: string;
audience?: string;
};
export type IotaChannelRequest = {
correlationId: string;
payload: {
request: string;
client_id: string;
};
};
export type IotaChannelRequestCallbackFunction = (err: IotaError | null, data: IotaChannelRequest | null) => void;
export declare class ChannelProvider {
iotEndpoint: string;
region: string;
iotaConfigBuilder?: iot.AwsIotMqtt5ClientConfigBuilder;
iotaClient?: mqtt5.Mqtt5Client;
topicName?: string;
constructor(params?: ChannelProviderParams);
getClient(): mqtt5.Mqtt5Client;
getTopicName(): string;
initialize(credentials: IotaCredentials): Promise<void>;
private startClient;
private createConfigBuilder;
private startMqttClient;
private subscribeToTopic;
private getRequest;
prepareRequest(params: PrepareRequestParams): Promise<IotaChannelRequest>;
prepareRequestWithCallback(params: PrepareRequestParams, callback: IotaChannelRequestCallbackFunction): void;
private addDebugListeners;
}