
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
acs-node-sdk-deprecated
Advanced tools
The SDK of ACS for NodeJS
git clone git+https://github.com/appcelerator/acs-node-sdk.git
cd acs-node-sdk
npm install
You can get an overview of ACS Node SDK example from examples/basic.js
cd acs-node-sdk/examples
export ACS_APPKEY=YOUR_ACS_TEST_APPKEY
node basic.js
There is another example for ACS Node SDK to show how to run on Node.ACS as a service.
Make sure you have installed Node.ACS command line tool first:
sudo npm -g install acs
Then you can try:
cd acs-node-sdk/examples/over_nodeacs
# Update config.json to fill in your ACS app key
vi config.json
acs run
Open another session and try:
curl -b cookie.txt -c cookie.txt -X POST -F "login=YOUR_USERNAME" -F "password=YOUR_PASSWORD" http://localhost:8080/login
curl -b cookie.txt -c cookie.txt -X GET http://localhost:8080/showMe
var ACSNode = require('acs-node');
var acsApp = new ACSNode('Your_ACS_APPKEY');
acsApp.usersLogin({
login: ACS_USERNAME,
password: ACS_PASSWORD
}, function(err, result) {
if (err) {
console.error(err);
return;
}
console.log('Logged in user: %j', result.body);
acsApp.usersShowMe(function(err, result) {
if (err) {
console.error(err);
return;
}
console.log('Show user: %j', result.body);
});
});
// HTTP call 1 with cookie:
var acsApp = new ACSNode('Your_ACS_APPKEY');
acsApp.usersLogin({
login: req.body.login,
password: req.body.password,
req: req,
res: res
}, function(err, result) {
if (err) {
console.error(err);
return;
}
res.end(result.body);
});
// HTTP call 2 with cookie, after HTTP call 1:
var ACSNode = require('acs-node');
var acsApp = new ACSNode('Your_ACS_APPKEY');
acsApp.usersShowMe(ACS_APPKEY, {
req: req,
res: res
}, function(err, result) {
if (err) {
console.error(err);
return;
}
res.end(result.body);
});
var acsApp = new ACSNode('Your_ACS_APPKEY');
acsApp.post(ACS_APPKEY, '/v1/users/login.json', {
login: ACS_USERNAME,
password: ACS_PASSWORD
}, function(err, result) {
if (err) {
console.error(err);
return;
}
console.log('ACS returned body: %j', result.body);
console.log('Cookie string returned: %s', result.cookieString);
acsApp.get(ACS_APPKEY, '/v1/users/show/me.json', function(err, result) {
if (err) {
console.error(err);
return;
}
console.log('ACS returned user: %j', result.body);
});
});
By default, acs-node-sdk will manage sessions for you automatically when you
log in and out. You can create a new ACSNode
instance for each authenticated
session. You can also reuse an existing instance by calling usersLogin()
again,
however this simply overwrites the existing session cookie and will not log out
the previous session.
However, if you'd prefer to manually manage the session cookie, then you can set
the autoSessionManagement
option to false
when the ACSNode
instance is
created.
var acsApp = new ACSNode('Your_ACS_APPKEY', {
autoSessionManagement: false
});
This means once you log in, you must track the session cookie yourself:
acsApp.usersLogin({
login: ACS_USERNAME,
password: ACS_PASSWORD
}, function(err, result) {
if (err) {
console.error(err);
return;
}
console.log('Logged in user');
console.log('Cookie string returned: %s', result.cookieString);
// IMPORTANT! You must set the sessionCookieString or else all privileged calls will fail
acsApp.sessionCookieString = result.cookieString;
});
To run the unit tests, simply run:
export ACS_APPKEY=ONE_OF_YOUR_ACS_TEST_APPKEY
npm test
This project is open source and provided under the Apache Public License
(version 2). Please make sure you see the LICENSE
file included in this
distribution for more details on the license. Also, please take notice of the
privacy notice at the end of the file.
FAQs
Appcelerator ACS SDK for NodeJS
The npm package acs-node-sdk-deprecated receives a total of 2 weekly downloads. As such, acs-node-sdk-deprecated popularity was classified as not popular.
We found that acs-node-sdk-deprecated 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
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.