Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const body: string = bodyParts.join();
// eslint-disable-next-line @typescript-eslint/tslint/config
const activity: Activity = JSON.parse(body);
if (activity === undefined) {
throw new Error('Error deserializing activity response!');
}
if (activity.type === ActivityTypes.Event && activity.name === TokenEvents.tokenRequestEventName) {
if (this.tokenRequestHandler !== undefined) {
await this.tokenRequestHandler(activity);
return { id: '' };
} else {
throw new Error('Skill is requesting for token but there\'s no handler on the calling side!');
}
} else if (activity.type === ActivityTypes.Handoff) {
if (this.handoffActivityHandler !== undefined) {
await this.handoffActivityHandler(activity);
return { id: '' };
} else {
throw new Error('Skill is sending handoff activity but there\'s no handler on the calling side!');
}
} else {
return this.turnContext.sendActivity(activity);
}
}
}