Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Convenient library for TDA REST API.
Please review the contributing documentation.
https://localhost:8443/
.npm install node-tda
npm install node-tda --no-optional
if you don't need puppeteer for oauth authentication in a headless browserFor CLI usage, also install node-tda as a global package npm install -g node-tda
The cli uses an https server to retrieve access tokens from the tda oauth login. For convenience, self-signed certs are generated automatically upon install. If your system is missing openssl
from its path, the certs will not be generated and the cli won't work.
For automated oauth login:
tda_authenticate --CONSUMER_KEY='<CONSUMER_KEY>' --UID='<userid>' --PW='<password>'
For manual oauth login:
tda_authenticate --CONSUMER_KEY='<CONSUMER_KEY>'
All functions names are a camelCase reflection their respective names found in the TDA API documentation. As of the writing of this document, all of the functions published in TDA's web api have been implemented.
Examples:
// Get Accounts
// https://developer.tdameritrade.com/account-access/apis/get/accounts-0
const { getAccounts } = require('node-tda');
// Place Order
// https://developer.tdameritrade.com/account-access/apis/post/accounts/%7BaccountId%7D/orders-0
const { placeOrder } = require('node-tda');
The REST API function signatures apiFunc(options, [callback])
include an optional callback, which when omitted, returns a promise.
const { authenticate, generateTokens, refreshToken, getAccounts } = require('node-tda');
async function auth(consumerKey) {
const grant = await authenticate({
consumerKey
});
const token = await generateTokens({
consumerKey,
grant
});
return token['access_token'];
}
const consumerKey = "someKey";
auth(consumerKey)
.then(async (token) => {
const accounts = await getAccounts({ token });
console.log(JSON.stringify(accounts));
setInterval(async () => {
// refresh token
const newToken = refreshTokenToken({
...token,
consumerKey
});
console.log(JSON.stringify(newToken));
}, 1800000);
})
.catch((err) => {
console.log(err);
});
const { authenticate, generateTokens, refreshToken, getAccounts } = require('node-tda');
function auth(consumerKey, callback) {
authenticate({
consumerKey
}, (grant) => {
generateTokens({
consumerKey,
grant
}, (token) => {
callback(null, token['access_token']);
});
});
}
const consumerKey = "someKey";
auth(consumerKey, (err, token) => {
getAccounts({ token }, (accounts) => {
console.log(JSON.stringify(accounts));
setInterval(async () => {
// refresh token
const newToken = refreshTokenToken({
...token,
consumerKey
});
console.log(JSON.stringify(newToken));
}, 1800000);
});
});
The Streamer Class extends EventEmitter and facilitates the use of the streaming API. See TDA's Streaming API documentation here.
const consumerKey = 'YourAppKey';
const refreshToken = 'YourRefreshToken';
async function streamingFun() {
// refresh token:
const { access_token } = await tda.refreshToken({
consumerKey,
refreshToken,
});
const userPrincipalsResponse = await tda.getUserPrincipals({
token: access_token,
fields: 'streamerSubscriptionKeys,streamerConnectionInfo',
});
const tdaStreamer = new tda.Streamer({
userPrincipalsResponse,
});
tdaStreamer.on('connected', () => {
tdaStreamer.request({
requests: [
{
service: 'CHART_EQUITY',
requestid: '2',
command: 'SUBS',
account: 'your_account',
source: 'your_source_id',
parameters: {
keys: 'AAPL',
fields: '0,1,2,3,4,5,6,7,8',
},
},
],
});
});
tdaStreamer.on('message', (message) => {
console.log(JSON.stringify(message));
});
}
streamingFun();
event | emits |
---|---|
error | Error |
message | message object |
connected | n/a |
disconnected | n/a |
FAQs
Library for accessing TDA Web API
We found that node-tda 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.