@appunto/ejabberd-api-client
is a simple client library created to access ejabberd administration REST API.
You can find more information on ejabberd API here.
npm install @appunto/ejabberd-api-client
const Client = require('@appunto/ejabberd-api-client');
const client = new Client('https://localhost:5443');
client.status().then(
result => console.log(result);
);
// This prints:
// The node ejabberd@1cb0f68fe610 is started. Status: startedejabberd 19.8.0 is running in that node
client.registeredUsers('localhost').then(
result => console.log(result.join(', ')):
);
// This prints:
// user1, user2, ...
- Start the ejabberd server using docker-compose:
npm run jabberd
- Run the tests:
npm test
or start a mocha watch:npm run test:watch
Creates a new client. If not specified, following default values apply:
host = localhost
port = 5443
;
executes:
POST /api/change_password
{
"user" : <some_value>,
"host" : <some_value>,
"newpass" : <some_value>
}
executes:
POST /api/change_room_option
{
"name" : <some_value>,
"service" : <some_value>,
"option" : <some_value>,
"value" : <some_value>
}
executes:
POST /api/check_account
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/check_password
{
"user" : <some_value>,
"host" : <some_value>,
"password" : <some_value>
}
executes:
POST /api/connected_users
{
}
executes:
POST /api/connected_users_info
{
}
executes:
POST /api/connected_users_number
{
}
executes:
POST /api/connected_users_vhost
{
"host" : <some_value>
}
executes:
POST /api/create_room
{
"name" : <some_value>,
"service" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/create_room_with_opts
{
"name" : <some_value>,
"service" : <some_value>,
"host" : <some_value>,
"options" : <some_value>
}
executes:
POST /api/delete_expired_messages
{
}
executes:
POST /api/delete_old_mam_messages
{
"type" : <some_value>,
"days" : <some_value>
}
executes:
POST /api/delete_old_messages
{
"days" : <some_value>
}
executes:
POST /api/delete_old_push_sessions
{
"days" : <some_value>
}
executes:
POST /api/delete_old_users
{
"days" : <some_value>
}
executes:
POST /api/delete_old_users_vhost
{
"host" : <some_value>,
"days" : <some_value>
}
executes:
POST /api/delete_rosteritem
{
"localuser" : <some_value>,
"localserver" : <some_value>,
"user" : <some_value>,
"server" : <some_value>
}
executes:
POST /api/destroy_room
{
"name" : <some_value>,
"service" : <some_value>
}
executes:
POST /api/get_last
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/get_loglevel
{
}
executes:
POST /api/get_offline_count
{
"user" : <some_value>,
"server" : <some_value>
}
executes:
POST /api/get_presence
{
"user" : <some_value>,
"server" : <some_value>
}
executes:
POST /api/get_room_affiliation
{
"name" : <some_value>,
"service" : <some_value>,
"jid" : <some_value>
}
executes:
POST /api/get_room_affiliations
{
"name" : <some_value>,
"service" : <some_value>
}
executes:
POST /api/get_room_occupants
{
"name" : <some_value>,
"service" : <some_value>
}
executes:
POST /api/get_room_occupants_number
{
"name" : <some_value>,
"service" : <some_value>
}
executes:
POST /api/get_room_options
{
"name" : <some_value>,
"service" : <some_value>
}
executes:
POST /api/get_roster
{
"user" : <some_value>,
"server" : <some_value>
}
executes:
POST /api/get_subscribers
{
"name" : <some_value>,
"service" : <some_value>
}
executes:
POST /api/get_user_rooms
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/get_vcard
{
"user" : <some_value>,
"host" : <some_value>,
"name" : <some_value>
}
executes:
POST /api/get_vcard2
{
"user" : <some_value>,
"host" : <some_value>,
"name" : <some_value>,
"subname" : <some_value>
}
executes:
POST /api/get_vcard2_multi
{
"user" : <some_value>,
"host" : <some_value>,
"name" : <some_value>,
"subname" : <some_value>
}
executes:
POST /api/kick_session
{
"user" : <some_value>,
"host" : <some_value>,
"resource" : <some_value>,
"reason" : <some_value>
}
executes:
POST /api/kick_user
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/muc_online_rooms
{
"host" : <some_value>
}
executes:
POST /api/muc_online_rooms_by_regex
{
"host" : <some_value>,
"regex" : <some_value>
}
executes:
POST /api/muc_register_nick
{
"nick" : <some_value>,
"jid" : <some_value>,
"serverhost" : <some_value>
}
executes:
POST /api/muc_unregister_nick
{
"jid" : <some_value>,
"serverhost" : <some_value>
}
executes:
POST /api/num_active_users
{
"host" : <some_value>,
"days" : <some_value>
}
executes:
POST /api/num_resources
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/oauth_issue_token
{
"jid" : <some_value>,
"ttl" : <some_value>,
"scopes" : <some_value>
}
executes:
POST /api/oauth_list_tokens
{
}
executes:
POST /api/oauth_revoke_token
{
"token" : <some_value>
}
executes:
POST /api/privacy_set
{
"user" : <some_value>,
"host" : <some_value>,
"xmlquery" : <some_value>
}
executes:
POST /api/private_get
{
"user" : <some_value>,
"host" : <some_value>,
"element" : <some_value>,
"ns" : <some_value>
}
executes:
POST /api/private_set
{
"user" : <some_value>,
"host" : <some_value>,
"element" : <some_value>
}
executes:
POST /api/push_alltoall
{
"host" : <some_value>,
"group" : <some_value>
}
executes:
POST /api/register
{
"user" : <some_value>,
"host" : <some_value>,
"password" : <some_value>
}
executes:
POST /api/registered_users
{
"host" : <some_value>
}
executes:
POST /api/registered_vhosts
{
}
executes:
POST /api/remove_mam_for_user
{
"user" : <some_value>,
"server" : <some_value>
}
executes:
POST /api/remove_mam_for_user_with_peer
{
"user" : <some_value>,
"server" : <some_value>,
"with" : <some_value>
}
executes:
POST /api/resource_num
{
}
executes:
POST /api/rooms_unused_destroy
{
"host" : <some_value>,
"days" : <some_value>
}
executes:
POST /api/rooms_unused_list
{
"host" : <some_value>,
"days" : <some_value>
}
executes:
POST /api/send_direct_invitation
{
"name" : <some_value>,
"service" : <some_value>,
"password" : <some_value>,
"reason" : <some_value>,
"users" : <some_value>
}
executes:
POST /api/send_message
{
"type" : <some_value>,
"from" : <some_value>,
"to" : <some_value>,
"subject" : <some_value>,
"body" : <some_value>
}
executes:
POST /api/send_stanza
{
"from" : <some_value>,
"to" : <some_value>,
"stanza" : <some_value>
}
executes:
POST /api/set_nickname
{
"user" : <some_value>,
"host" : <some_value>,
"nickname" : <some_value>
}
executes:
POST /api/set_presence
{
"user" : <some_value>,
"host" : <some_value>,
"resource" : <some_value>,
"type" : <some_value>,
"show" : <some_value>,
"status" : <some_value>,
"priority" : <some_value>
}
executes:
POST /api/set_room_affiliation
{
"name" : <some_value>,
"server" : <some_value>,
"jid" : <some_value>,
"affiliation" : <some_value>
}
executes:
POST /api/set_vcard
{
"user" : <some_value>,
"host" : <some_value>,
"name" : <some_value>,
"content" : <some_value>
}
executes:
POST /api/set_vcard2
{
"user" : <some_value>,
"host" : <some_value>,
"name" : <some_value>,
"subname" : <some_value>,
"content" : <some_value>
}
executes:
POST /api/set_vcard2_multi
{
"user" : <some_value>,
"host" : <some_value>,
"name" : <some_value>,
"subname" : <some_value>,
"contents" : <some_value>
}
executes:
POST /api/srg_create
{
"group" : <some_value>,
"host" : <some_value>,
"name" : <some_value>,
"description" : <some_value>,
"display" : <some_value>
}
executes:
POST /api/srg_delete
{
"group" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/srg_get_info
{
"group" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/srg_get_members
{
"group" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/srg_list
{
"host" : <some_value>
}
executes:
POST /api/srg_user_add
{
"user" : <some_value>,
"host" : <some_value>,
"group" : <some_value>,
"grouphost" : <some_value>
}
executes:
POST /api/srg_user_del
{
"user" : <some_value>,
"host" : <some_value>,
"group" : <some_value>,
"grouphost" : <some_value>
}
executes:
POST /api/stats
{
"name" : <some_value>
}
executes:
POST /api/stats_host
{
"name" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/status
{
}
executes:
POST /api/status_list
{
"status" : <some_value>
}
executes:
POST /api/status_list_host
{
"host" : <some_value>,
"status" : <some_value>
}
executes:
POST /api/status_num
{
"status" : <some_value>
}
executes:
POST /api/status_num_host
{
"host" : <some_value>,
"status" : <some_value>
}
executes:
POST /api/subscribe_room
{
"user" : <some_value>,
"nick" : <some_value>,
"room" : <some_value>,
"nodes" : <some_value>
}
executes:
POST /api/unregister
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/unsubscribe_room
{
"user" : <some_value>,
"room" : <some_value>
}
executes:
POST /api/user_resources
{
"user" : <some_value>,
"host" : <some_value>
}
executes:
POST /api/user_sessions_info
{
"user" : <some_value>,
"host" : <some_value>
}
MIT