Class: AppServiceRegistration

AppServiceRegistration

new AppServiceRegistration(appServiceUrl)

Construct a new application service registration.
Parameters:
Name Type Description
appServiceUrl string The base URL the AS can be reached via.
Source:

Methods

(static) fromObject(obj) → (nullable) {AppServiceRegistration}

Convert a JSON object to an AppServiceRegistration object.
Parameters:
Name Type Description
obj Object The registration object
Source:
Returns:
The registration or null if the object cannot be coerced into a registration.
Type
AppServiceRegistration

(static) generateToken() → {string}

Generate a random token.
Source:
Returns:
A randomly generated token.
Type
string

addRegexPattern(type, regex, exclusive)

Add a regex pattern to be registered.
Parameters:
Name Type Description
type String : The type of regex pattern. Must be 'users', 'rooms', or 'aliases'.
regex String : The regex pattern.
exclusive Boolean : True to reserve the matched namespace.
Source:
Throws:
If given an invalid type or regex.

getAppServiceToken() → (nullable) {string}

Get the token the app service will use to communicate with the homeserver.
Source:
Returns:
The token
Type
string

getHomeserverToken() → (nullable) {string}

Get the token the homeserver will use to communicate with the app service.
Source:
Returns:
The token
Type
string

getOutput() → {Object}

Get the key-value output which should be written to a YAML file.
Source:
Throws:
If required fields hs_token, as-token, url, sender_localpart are missing.
Returns:
Type
Object

getSenderLocalpart() → (nullable) {string}

Get the desired user_id localpart for the app service itself.
Source:
Returns:
The user_id localpart ("alice" in "@alice:domain")
Type
string

isAliasMatch(alias, onlyExclusive) → {boolean}

Check if a room alias meets this registration regex.
Parameters:
Name Type Description
alias string The room alias
onlyExclusive boolean True to restrict matching to only exclusive regexes. False to allow exclusive or non-exlusive regexes to match.
Source:
Returns:
True if there is a match.
Type
boolean

isRoomMatch(roomId, onlyExclusive) → {boolean}

Check if a room ID meets this registration regex.
Parameters:
Name Type Description
roomId string The room ID
onlyExclusive boolean True to restrict matching to only exclusive regexes. False to allow exclusive or non-exlusive regexes to match.
Source:
Returns:
True if there is a match.
Type
boolean

isUserMatch(userId, onlyExclusive) → {boolean}

Check if a user_id meets this registration regex.
Parameters:
Name Type Description
userId string The user ID
onlyExclusive boolean True to restrict matching to only exclusive regexes. False to allow exclusive or non-exlusive regexes to match.
Source:
Returns:
True if there is a match.
Type
boolean

outputAsYaml(filename)

Output this registration to the given file name.
Parameters:
Name Type Description
filename String The file name to write the yaml to.
Source:
Throws:
If required fields hs_token, as_token, url are missing.

setAppServiceToken(token)

Set the token the app service will use to communicate with the homeserver.
Parameters:
Name Type Description
token string The token
Source:

setAppServiceUrl(url)

Set the URL which the home server will hit in order to talk to the AS.
Parameters:
Name Type Description
url string The application service url
Source:

setHomeserverToken(token)

Set the token the homeserver will use to communicate with the app service.
Parameters:
Name Type Description
token string The token
Source:

setSenderLocalpart(localpart)

Set the desired user_id localpart for the app service itself.
Parameters:
Name Type Description
localpart string The user_id localpart ("alice" in "@alice:domain")
Source: