npm install truevault
Require truevault:
var truevault = require('truevault')('your-user-api-key');
Each resource call returns a q promise and accepts an optional callback argument:
truevault.documents.retrieve({
'vault_id' : 'my-vault-uuid',
'id' : 'my-document-uuid'
}, function myCallback(err, document){
//err is null if response is a success
});
Or with a promise:
truevault.documents.retrieve({
'vault_id' : 'my-vault-uuid',
'id' : 'my-document-uuid'
}).then(function(document){
//success!
}, function(err){
//error!
});
options.vault_id
vault uuidoptions.per_page
items per pageoptions.page
page to returnoptions.full
if true, return full document instead of uuidcallback
is optional, this method returns a q promise
truevault.documents.list({
'vault_id':'my-vault-uuid',
'per_page':50,
'page':1,
'full': false //true to return full documents vs uuids
}, function myCallback(err, document){
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
document uuid, or array of document uuidscallback
is optional, this method returns a q promise
truevault.documents.retrieve({
'vault_id' : 'my-vault-uuid',
'id' : 'my-document-uuid'
}, function myCallback(err, document){
//err is null if response is a success
});
options.vault_id
vault uuidoptions.schema_id
schema uuid to index against (optional)options.document
a js objcallback
is optional, this method returns a q promise
truevault.documents.create({
'vault_id':'my-vault-uuid',
'schema_id' : 'my-schema-uuid',
'document' : {
'Hello' : 'World'
}
}, function(err, transaction) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.schema_id
schema uuid to index against (optional)options.id
document uuid to updateoptions.document
a js objcallback
is optional, this method returns a q promise
truevault.documents.update({
'vault_id':'my-vault-uuid',
'id':'my-document-uuid',
'document' : {'changed':'wow!'}
},function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
document uuidcallback
is optional, this method returns a q promise
truevault.documents.del({
'vault_id':'my-vault-uuid',
'id':'my-document-uuid'
},function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.schema_id
schema uuid to search against (optional)options.filter
- js object of field filtersoptions.case_sensitive
- true or falseoptions.page
- an integer of the page results you wantoptions.per_page
- an integer of the number of results you want from each pageoptions.filter_type
- a string specifying the filter typeoptions.full_document
- boolean (id vs full obj)options.sort
- An object of field name and sort directions.callback
is optional, this method returns a q promise
truevault.documents.search({
'vault_id' : 'my-vault-uuid',
'schema_id' : 'my-schema-uuid',
'filter' : { 'first': {
"type": "wildcard",
"value": "Hello"
}
}
}, function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
blob uuidcallback
is optional, this method returns a q promise
truevault.blobs.retrieve({
'vault_id' : 'my-vault-uuid',
'id' : 'my-blob-uuid'
}, function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.blob
a Buffer or Stringcallback
is optional, this method returns a q promise
truevault.blobs.create({
'vault_id' : 'my-vault-uuid',
'blob' : myBuffer
}, function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
blob uuid to updateoptions.blob
Buffer or Stringcallback
is optional, this method returns a q promise
truevault.blobs.update({
'vault_id' : 'my-vault-uuid',
'id' : 'my-blob-uuid',
'blob' : myBuffer
}, function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
blob uuidcallback
is optional, this method returns a q promise
truevault.blobs.del({
'vault_id' : 'my-vault-uuid',
'id' : 'my-blob-uuid'
}, function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidcallback
is optional, this method returns a q promise
truevault.schemas.list({
'vault_id' : 'my-vault-uuid'
}, function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
schema uuidoptions.per_page
items per pageoptions.page
page to returnoptions.full
if true, return full document instead of uuidcallback
is optional, this method returns a q promise
truevault.documents.listDocuments({
'vault_id':'my-vault-uuid',
'id':'my-schema-uuid',
'per_page':50,
'page':1,
'full': false //true to return full documents vs uuids
}, function myCallback(err, document){
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
schema uuidcallback
is optional, this method returns a q promise
truevault.schemas.retrieve({
'vault_id':'my-vault-uuid',
'id':'my-schema-uuid'
},function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.schema
js objcallback
is optional, this method returns a q promise
truevault.schemas.create({
'vault_id':'my-vault-uuid',
'schema' : {
"name":"test",
"fields":[
{
"name":"first",
"index":true,
"type" : "string"
}
]
}
},function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
schema uuid to updateoptions.schema
a js objcallback
is optional, this method returns a q promise
truevault.schemas.update({
'vault_id':'my-vault-uuid',
'id' : "my-schema-uuid"
'schema' : {
"name":"test",
"fields":[
{
"name":"first",
"index":true,
"type" : "string"
}
]
}
},function(err, value) {
//err is null if response is a success
});
options.vault_id
vault uuidoptions.id
schema uuidcallback
is optional, this method returns a q promise
truevault.schemas.del({
'vault_id':'my-vault-uuid',
'id':'my-schema-uuid'
}, function(err, value) {
//err is null if response is a success
});
options.username
string(req’d) - username for the User being createdoptions.password
string(req’d) - password for the User being createdoptions.attributes
b64 string(optional) - base64 encoded JSON document describing the User attributesoptions.schema_id
uuid(optional) - UUID of the Schema to associate the attributes Document with
truevault.users.create({
username: 'username',
password: 'password'
}).then(function(res) {
// do something with response
});
del(userId, callback) - deactivates a user, freeing the assocaited username, all ACCESS_TOKENs, and removes user_id from all Groups
options.id
string(req’d) - username for the User being deleted
truevault.users.del({
id: 'user-id'
}).then(function(res) {
// do something with response
});
options.id
string(req’d)
truevault.users.createAccessToken({
id: 'user-id'
}).then(function(res) {
// do something with response
});
options.username
string(req’d) - username of active useroptions.password
string(req’d) - password of active useroptions.account_id
string(req’d) - account_id
truevault.authorization.login({
username: 'username',
password: 'password',
account_id: 'account-id'
}).then(function(res) {
// do something with response
});
truevault.authorization.logout().then(function(res) {
// do something with response
});
truevault.authorization.verify().then(function(res) {
// do something with response
});
options.name
string(req'd) - new name for Groupoptions.policy
object(optional) - new policy for Group, base64 encodedoptions.user_ids
array(optional) - comma separated list of user_id for this update request
truevault.groups.create({
name: 'group-name',
user_ids: ['1','2','3'],
}).then(function(res) {
// do something with response
});
options.id
string(req'd) - id of group to updateoptions.name
string(optional) - new name for Groupoptions.policy
object(optional) - new policy for Group, base64 encodedoptions.user_ids
array(optional) - array of user ids for this update requestoptions.operation
string(optional) - ‘APPEND’ or ‘REMOVE’ this group for the provided list of user_id
truevault.groups.update({
name: 'group-name',
user_ids: ['1','2','3'],
operation: 'REMOVE'
}).then(function(res) {
// do something with response
});
options.id
string(req’d)
truevault.group.delete({
id: 'group-id'
}).then(function(res) {
// do something with response
});
options.page
– int(optional, default: 1) - page number in paginated responseoptions.per_page
– int(optional, default: 100) - results per page in paginated responscallback
is optional, this method returns a q promise
truevault.vaults.list({
'per_page':50,
'page':1,
}, function myCallback(err, document){
//err is null if response is a success
});
options.name
– string(req'd) - new name for Vaultcallback
is optional, this method returns a q promise
truevault.vaults.create({
'name':'my-vault'
}, function(err, transaction) {
//err is null if response is a success
});
options.id
- string(req'd) - Vault IDcallback
is optional, this method returns a q promise
truevault.vaults.retrieve({
'id' : 'my-vault-id'
}, function myCallback(err, vault){
//err is null if response is a success
});
options.id
– string(req’d) - Vault ID to updateoptions.name
– string(optional) - new Vault namecallback
is optional, this method returns a q promise
truevault.vaults.update({
'id':'my-vault-id',
'name' : 'my-new-vault-name'
},function(err, value) {
//err is null if response is a success
});
options.id
– string(req’d) - Vault IDcallback
is optional, this method returns a q promise
truevault.vaults.del({
'id':'my-vault-id'
},function(err, value) {
//err is null if response is a success
});
MIT