
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
node-nextcloud
Advanced tools
node-nextcloud is a node wrapper for the nextcloud API. It's designed to be a lightweight module and a hassle-free experience.
const NextCloud = require('nextcloud');
var nc = NextCloud("mydomain.net", "username", "password");
// Create user "toto"
nc.users.add("toto", "awesomePassword!", (err, ocs) => {
// Check for server error
if (err) {
console.error(err);
}
// Check API status code
else if (ocs.meta.statuscode != 100) {
console.error(`Nextcloud error ${ocs.meta.statuscode}: ${ocs.meta.message}`);
}
else {
console.log("User created!");
}
}
WARNING: This module was developped as part of a larger project, which ended up not being completed. It has therefore never run in production. I've tested the users namespace fairly exhaustively, but not groups and apps. Please test it before using in production and make issues with any problems you encounter 💖
Important notes:
ocs parameter, it is already a JS object, you don't need to parse anything. It is the JS equivalent of the XML in the documentation, starting at the top-level "ocs".err simply indicates HTTP header errors, if you want Nextcloud's errors you have to check the header Nextcloud provides you in ocs.meta.NextCloud(<domain name>, <userid>, <password>, [https=true])
This method returns the object hereafter referred to as nc, which we use to interact with the nextcloud API.const NextCloud = require('nextcloud');
var nc = NextCloud("mydomain.net", "username", "password");
All these methods are accessed through the nc.users object. These methods all match the API calls here.
add(<userid>, <password>, [callback(err, ocs)])
Create a new user with the given userid and password. If you intend to test this, remember this call can fail if the password is too common! If err is null, everything went fine.
nc.users.add("toto", "awesomePassword!", (err) => {
if (err) {
console.error(err);
return;
}
else
console.log("User added!");
}
list(<options>, <callback(err, ocs)>)
This method, without any options, returns a list of all users. Options is an object which can have three keys set:
// Get all users
nc.users.list(null, (err, ocs)=>{
if (err) {
console.error(err);
return;
}
// Prints the user list
console.log(ocs.data.users);
});
// Get the three top users matching "tom"
nc.users.list({"search":"tom", "limit": 3}, (err, ocs)=> {
if (err) {
console.error(err);
return;
}
// ocs contains the server's response if err == null
console.log(ocs.data.users);
});
get(<userid>, <callback(err, ocs)>)disable(<userid>, [callback(err, ocs)])
enable(<userid>, [callback(err, ocs)])
delete(<userid>, [callback(err, ocs)])
edit(<userid>, <key>, <value>, [callback(err, ocs)])
Key and value follow the possible values in the documentation. Note that all values are strings, even the quota (It shoudld be the string "5G", not the number 5).
nc.users.edit("toto", "email", "new_mail@domain.net", (err)=>{
if (err)
console.error(err);
else
console.log("Email edited");
});
getGroups(<userid>, <callback(err, ocs)>)nc.users.getGroups("admin", (err, ocs) =>{
if (err) {
console.error("Error:");
console.error(err);
return;
}
console.log(ocs.data.groups);
});
addToGroup(<userid>, <groupid>, [callback(err, ocs)])
rmFromGroup(<userid>, <groupid>, [callback(err, ocs)])
subadminPromote(<userid>, <groupid>, [callback(err, ocs)])
subadminDemote(<userid>, <groupid>, [callback(err, ocs)])
subadminGetGroups(<userid>, <callback(err, ocs)>)
welcome(<userid>, [callback(err, ocs)])user(<userid>) returns an object which can be used for shorthand methods. Most methods in this namespace can either be used with a long or a short method. The short methods allow for chaining and shorten multiple calls to the API greatly. This function does not cause an API call.
// Get the "username" user object
var user = nc.users.user("username");
// Call the shorthand email editing function
user.email("user@mail.com");
// All shorthand functions can be chained, and most of them have no data to show, making the calls very clean
user.address("8 Placeholder Rd.").phone("0742424242").quota("5GB");
// Call shorthand "get" function
user.get((err, ocs)=>{
// ocs.data contains the user's information if the call was successful
});
// Call shorthand delete function
user.delete(); // We don't have to provide a callback if we don't care to wait for the call to be done, nor care about the result being positive.
All these methods are accessed through the nc.groups object. These methods all match the API calls here.
list(<options>, <callback(err, ocs)>)
This method, without any options, returns a list of all groups. Options is an object which can have three keys set:
add(<groupid>, <callback(err, ocs)>)
members(<groupid>, <callback(err, ocs)>)
subadmins(<groupid>, <callback(err, ocs)>)
delete(<groupid>, <callback(err, ocs)>)
All these methods are accessed through the nc.groups object. These methods all match the API calls here.
list(<options>, <callback(err, ocs)>)
This method, without any options, returns a list of all apps. Options is an object which can only have one key:
info(<appid>, <callback(err, ocs)>)
enable(<appid>, [callback(err, ocs)])
disable(<appid>, [callback(err, ocs)])
This module was developed by Blackfoot and is licensed under the MIT License.
FAQs
A node package to interact with nextcloud applications
We found that node-nextcloud demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.