-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix security problem * Add IPreRoomUserJoined event * Add the IPostRoomUserJoined event * New "essentials" mechanism (#269)
- Loading branch information
Showing
23 changed files
with
341 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* The internal exception from the framework | ||
* | ||
* It's used to signal to the outside world that | ||
* a _known_ exception has happened during the execution | ||
* of the apps. | ||
* | ||
* It's the base exception for other known classes | ||
* such as UserNotAllowedException, which is used | ||
* to inform the host that an app identified | ||
* that a user cannot perform some action, e.g. | ||
* join a room | ||
*/ | ||
export class AppsEngineException extends Error {} |
17 changes: 17 additions & 0 deletions
17
src/definition/exceptions/EssentialAppDisabledException.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { AppsEngineException } from '.'; | ||
|
||
/** | ||
* This exception informs the host system that an | ||
* app essential to the execution of a system action | ||
* is disabled, so the action should be halted. | ||
* | ||
* Apps can register to be considered essential to | ||
* the execution of internal events of the framework | ||
* such as `IPreMessageSentPrevent`, `IPreRoomUserJoined`, | ||
* etc. | ||
* | ||
* This is used interally by the framework and is not | ||
* intended to be thrown manually by apps. | ||
*/ | ||
export class EssentialAppDisabledException extends AppsEngineException { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AppsEngineException } from '.'; | ||
|
||
/** | ||
* This exception informs the host system that an | ||
* app has determined that an user is not allowed | ||
* to perform a specific action. | ||
* | ||
* Currently it is expected to be thrown by the | ||
* following events: | ||
* - IPreRoomCreatePrevent | ||
* - IPreRoomUserJoined | ||
*/ | ||
export class UserNotAllowedException extends AppsEngineException { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './AppsEngineException'; | ||
export * from './EssentialAppDisabledException'; | ||
export * from './UserNotAllowedException'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export enum AppInterface { | ||
// Messages | ||
IPreMessageSentPrevent = 'IPreMessageSentPrevent', | ||
IPreMessageSentExtend = 'IPreMessageSentExtend', | ||
IPreMessageSentModify = 'IPreMessageSentModify', | ||
IPostMessageSent = 'IPostMessageSent', | ||
IPreMessageDeletePrevent = 'IPreMessageDeletePrevent', | ||
IPostMessageDeleted = 'IPostMessageDeleted', | ||
IPreMessageUpdatedPrevent = 'IPreMessageUpdatedPrevent', | ||
IPreMessageUpdatedExtend = 'IPreMessageUpdatedExtend', | ||
IPreMessageUpdatedModify = 'IPreMessageUpdatedModify', | ||
IPostMessageUpdated = 'IPostMessageUpdated', | ||
// Rooms | ||
IPreRoomCreatePrevent = 'IPreRoomCreatePrevent', | ||
IPreRoomCreateExtend = 'IPreRoomCreateExtend', | ||
IPreRoomCreateModify = 'IPreRoomCreateModify', | ||
IPostRoomCreate = 'IPostRoomCreate', | ||
IPreRoomDeletePrevent = 'IPreRoomDeletePrevent', | ||
IPostRoomDeleted = 'IPostRoomDeleted', | ||
IPreRoomUserJoined = 'IPreRoomUserJoined', | ||
IPostRoomUserJoined = 'IPostRoomUserJoined', | ||
// External Components | ||
IPostExternalComponentOpened = 'IPostExternalComponentOpened', | ||
IPostExternalComponentClosed = 'IPostExternalComponentClosed', | ||
// Blocks | ||
IUIKitInteractionHandler = 'IUIKitInteractionHandler', | ||
// Livechat | ||
IPostLivechatRoomStarted = 'IPostLivechatRoomStarted', | ||
IPostLivechatRoomClosed = 'IPostLivechatRoomClosed', | ||
/** | ||
* @deprecated please use the AppMethod.EXECUTE_POST_LIVECHAT_ROOM_CLOSED method | ||
*/ | ||
ILivechatRoomClosedHandler = 'ILivechatRoomClosedHandler', | ||
IPostLivechatAgentAssigned = 'IPostLivechatAgentAssigned', | ||
IPostLivechatAgentUnassigned = 'IPostLivechatAgentUnassigned', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IHttp, IPersistence, IRead } from '../accessors'; | ||
import { IRoomUserJoinedContext } from './IRoomUserJoinedContext'; | ||
|
||
/** | ||
* Event interface that allows an app to | ||
* register as a handler of the `IPostRoomUserJoined` | ||
* event | ||
* | ||
* This event is triggered after an user succcessfully joined | ||
* a room. | ||
* | ||
* This event does not allow an app to prevent any action from | ||
* happening. For that, see its "pre counterpart(s)": | ||
* | ||
* - IPreRoomUserJoined | ||
*/ | ||
export interface IPostRoomUserJoined { | ||
executePostRoomUserJoined(context: IRoomUserJoinedContext, read: IRead, http: IHttp, persistence: IPersistence): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IHttp, IPersistence, IRead } from '../accessors'; | ||
import { IRoomUserJoinedContext } from './IRoomUserJoinedContext'; | ||
|
||
/** | ||
* Event interface that allows an app to | ||
* register as a handler of the `IPreRoomUserJoined` | ||
* event | ||
* | ||
* This event is triggered prior to an user succcessfully | ||
* joining a room. To prevent the user from executing | ||
* such action, an app should throw the `UserNotAllowedException`. | ||
* | ||
* This event is not triggered before a room has been created. For that, | ||
* check the `IPreRoomCreate` events | ||
*/ | ||
export interface IPreRoomUserJoined { | ||
executePreRoomUserJoined(context: IRoomUserJoinedContext, read: IRead, http: IHttp, persistence: IPersistence): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IUser } from '../users'; | ||
import { IRoom } from './IRoom'; | ||
|
||
/** | ||
* The context of execution for the following events: | ||
* - IPreRoomUserJoined | ||
* - IPostRoomUserJoined | ||
*/ | ||
export interface IRoomUserJoinedContext { | ||
/** | ||
* The user that is being added to the room | ||
*/ | ||
joiningUser: IUser; | ||
/** | ||
* The room to which the user is being added | ||
*/ | ||
room: IRoom; | ||
/** | ||
* The user that has invited `joiningUser` to `room`, | ||
* if any. | ||
*/ | ||
inviter?: IUser; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.