Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
blazer is a node js library for BackBlaze B2. Note that this is currently a work in progress and not all api is implemented yet.
Status:
0.0.3
npm install --save blazer
const { authorize_account, createB2 } = require('blazer-b2');
/**
* authorize_account is used to retrieve a b2 token which you can use
* to create a b2Api via the b2 function. You can try to store this token once
* retrieved an you can pass it to the b2 function to return an api
*/
//sample initialize to create a b2 Token
authorize_account(accountId, applicationKey).then ( token => {
const b2 = createB2(token);
//you can now use b2Api
b2.upload_file(...);
b2.create_bucket(...);
//etc
});
Create a B2 Bucket. The required argument is bucketName and bucketType.
const bucketName = "myBucket";
const bucketType = "allPublic";
b2.create_bucket({bucketName, bucketType}).then( res => {
console.log("bucket created ", res);
}).catch ( err => {
console.log("error creating bucket");
});
You can also use it directly, without passing from the b2 instance.
const { buckets } = require('blazer-b2/buckets');
const { create_bucket } = buckets;
create_bucket(token)({bucketName, bucketType}).then( res => {
console.log('bucket created ', res);
}).catch ( err => {
console.log('error creating bucket');
});
You can use the createB2 function to manually call a b2 api but if you use blazer from some sort of a server app, then it would be convenient to have some facility to help you do automatic retries and token keys management. The createB2Session calls does that exactly.
To create a b2Session object, call createB2Session passing in your accountId and applicationKey
const { createB2Session } = require('blazer-b2');
const b2Session = createB2Session( { accountId, applicationKey} );
//use the api normally, b2session will automatically create token and
//retry if needed
b2Session.create_bucket(..)
The second argument to createB2Session is a config file with the following attribute
if set to true, then more verbose log is outputted.
the maximum number of calls when there is a failure before giving up.
The store instance to use. By default it uses a memory store. You can pass your own store object which is required to have the following attributes.
A function that returns the current token object.
A function that accepts the newToken object and returns a promise which gets resolved once the token has been persisted by the store.
Invalidate the current active token. You need to set it to undefined such that calls to token() will return falsy.
A sample implementation below
const createMemoryStore = () => {
var token;
return {
token() {
return token;
},
persistToken(newToken) {
token = newToken;
return Promise.resolve(newToken);
},
invalidate() {
token = undefined;
}
};
};
Api Call | Status |
---|---|
create_bucket | done |
list_buckets | done |
upload_file | done |
authorized_account | done |
get_upload_url | done |
cancel_large_file | pending |
delete_bucket | done |
delete_file_version | done |
download_file_by_id | pending |
download_file_by_name | pending |
finish_large_file | pending |
get_file_info | done |
get_upload_part_url | pending |
hide_file | done |
list_file_names | done |
list_file_versions | done |
list_parts | pending |
list_unfinished_large_files | pending |
start_large_file | pending |
update_bucket | done |
upload_part | pending |
Node 5+ is required at the moment.
npm run test
No. Functions on the B2 object are not dependent on the this context. You will be able to pass the member around without worrying on binding b2
someHandler( b2.create_bucket.bind(b2) ) //<--- you don't need to do this
someHandler( b2.create_bucket ); //<-- works fine
FAQs
Node API for BackBlaze B2
The npm package blazer-b2 receives a total of 1 weekly downloads. As such, blazer-b2 popularity was classified as not popular.
We found that blazer-b2 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.