This module provides configuration and utility functions for interacting with Isometrik's API and MQTT services. The configuration is dynamically loaded from a global configuration object, which allows it to be easily customized for different projects.
The configuration properties are loaded from the global window.__stream_player_config object. Ensure this object is not altered in your project.
Example Configuration Object
-
isometrikBaseApiUrl:
"https://apis.isometrik.io"
-
baseApiUrl:
"https://api.soldlive.eu"
-
liveKitUrl:
"wss://streaming.isometrik.io"
-
MQTTHost:
"connections.isometrik.io"
-
projectCreds:
-
accountId:
"652f9ad3e24477cce4a025d5"
-
projectId:
"88cad458-e9a0-4109-a2d6-df520e56b4f7"
-
keySetId:
"b17b380d-153e-4017-8a8f-26b61f5c23c8"
-
licenseKey:
"lic-IMKm3wNSIeSnxmdj/lOy4mB55sziy2A1NhU"
-
appSecret:
"SFMyNTY.g3QAAAACZAAEZGF0YXQAAAADbQAAAAlhY2NvdW50SWRtAAAAGDY1MmY5YWQzZTI0NDc3Y2NlNGEwMjVkNW0AAAAIa2V5c2V0SWRtAAAAJGIxN2IzODBkLTE1M2UtNDAxNy04YThmLTI2YjYxZjVjMjNjOG0AAAAJcHJvamVjdElkbQAAACQ4OGNhZDQ1OC1lOWEwLTQxMDktYTJkNi1kZjUyMGU1NmI0ZjdkAAZzaWduZWRuBgAyh_ZBiwE.u0RqujyPa8EB036aYWH50kME2sMLgjC7faUtYTJxHFM"
-
userSecret:
"SFMyNTY.g3QAAAACZAAEZGF0YXQAAAADbQAAAAlhY2NvdW50SWRtAAAAGDY1MmY5YWQzZTI0NDc3Y2NlNGEwMjVkNW0AAAAIa2V5c2V0SWRtAAAAJGIxN2IzODBkLTE1M2UtNDAxNy04YThmLTI2YjYxZjVjMjNjOG0AAAAJcHJvamVjdElkbQAAACQ4OGNhZDQ1OC1lOWEwLTQxMDktYTJkNi1kZjUyMGU1NmI0ZjdkAAZzaWduZWRuBgAyh_ZBiwE.nWn8_aZvCwqH1smL9Mp8tgYeG4S04WWSrbwczusX5Cg"
-
accountId:
-
userProfileData:
- userId & _id
- name
- firstName
- lastName
- profilePic
- senderIdentifier
- isomatricChatUserId
-
diaData:
-
status:
"STARTED"/"SCHEDULED"/"ENDED"
- isScheduledStream
- streamId
- _id
- metaData
- isStreamActive
- streamDescription
-
status:
-
noUserCallBack:
() => {}
-
callBackFunction:
() => {}
This constant holds the base URL for the Isometrik API, loaded from the configuration.
This constant holds the base URL for project API, loaded from the configuration.
This constant holds the project credentials required for API and MQTT authentication, loaded from the configuration.
This function handles restriction middleware It is used if stream viewer is a guest and u want to add some type of restriction Tries to buy a product you can move it to signIn screen / dialog
const noUserCallBack = () => { document.getElementById('profile_svg_header')?.click(); } const callBackFunction = (type, data) => { if (type == 'showSnackbar') { showSnackbar(data); } }
The MQTT credentials are constructed using the project credentials. These credentials are used to connect to the Isometrik MQTT broker.
const ISOMETRIK_MQTT_CREDS = { URL: 'connections.isometrik.io', Username: '2' + PROJECTS_CREDS.accountId + PROJECTS_CREDS.projectId, Password: PROJECTS_CREDS.licenseKey + PROJECTS_CREDS.keySetId, API_URL: 'https://apis.isometrik.io', };
The MQTT topics are constructed using the project credentials. These topics are used to subscribe to various events and messages.
const ISOMETRIK_MQTT_TOPICS = {
Message: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/Message/
,
PresenceEvents: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/Status/
,
NewMessageEvent: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/
,
userEvents: /${PROJECTS_CREDS.accountId}/${PROJECTS_CREDS.projectId}/Users/
,
};
A function to construct the full API URL for a given endpoint.
const getUrl = (endpoint) => { return ISOMETRIK_BASE_API_URL + endpoint; };
The common headers required for API requests, including authorization details.
const commonHeader = { licenseKey: PROJECTS_CREDS.licenseKey, appSecret: PROJECTS_CREDS.appSecret, "Content-Type": "application/json" };
An asynchronous function to make GET requests to the Isometrik API with the necessary headers.
const getIsometrik = async (endpoint = "", otherHeaders = {}) => fetch(getUrl(endpoint), { method: "GET", headers: { ...commonHeader, ...otherHeaders, }, }); Usage Ensure your project includes the necessary configuration in window.__stream_player_config. Import the module and use the provided constants and functions as needed.