[TASK] vault client: add parameters to attest

This commit is contained in:
Matthew Fettig
2014-09-03 17:17:31 -07:00
parent d5e32db954
commit dce15bc579
2 changed files with 80 additions and 9 deletions

View File

@@ -563,7 +563,6 @@ BlobObj.prototype.get2FA = function (fn) {
* @params {boolean} options.enabled
* @params {string} options.phone
* @params {string} options.country_code
* @params {string} options.via //sms, etc
*/
BlobObj.prototype.set2FA = function(options, fn) {
@@ -574,8 +573,7 @@ BlobObj.prototype.set2FA = function(options, fn) {
data : {
enabled : options.enabled,
phone : options.phone,
country_code : options.country_code,
via : options.via
country_code : options.country_code
}
};
@@ -1371,6 +1369,7 @@ BlobClient.updateProfile = function (opts, fn) {
fn(null, resp.body);
} else if (resp.body) {
log.error('updateProfile:', resp.body);
fn(new Error('Failed to update profile'));
} else {
fn(new Error('Failed to update profile'));
}
@@ -1405,6 +1404,7 @@ BlobClient.getProfile = function (opts, fn) {
fn(null, resp.body);
} else if (resp.body) {
log.error('getProfile:', resp.body);
fn(new Error('Failed to get profile'));
} else {
fn(new Error('Failed to get profile'));
}
@@ -1439,6 +1439,7 @@ BlobClient.getAttestations = function (opts, fn) {
fn(null, resp.body);
} else if (resp.body) {
log.error('getAttestations:', resp.body);
fn(new Error('Failed to get attestations'));
} else {
fn(new Error('Failed to get attestations'));
}
@@ -1450,16 +1451,31 @@ BlobClient.getAttestations = function (opts, fn) {
* @param {Object} opts
* @param {string} opts.url
* @param {string} opts.auth_secret
* @param {srring} opts.blob_id
* @param {srring} opts.identity_id
* @param {srring} opts.type (email,phone,basic_identity)
* @param {string} opts.blob_id
* @param {string} opts.identity_id
* @param {string} opts.type (email,phone,basic_identity)
* @param {object} opts.phone (required for type 'phone')
* @param {object} opts.identity (optional)
* @param {string} opts.email (required for type 'email')
* @param {string} opts.attestation_id (required for completing email or phone attestations)
* @param {string} opts.token (required for completing email or phone attestations)
*/
BlobClient.attest = function (opts, fn) {
var params = {
type: opts.type
};
if (opts.phone) params.phone = opts.phone;
if (opts.identity) params.identity = opts.identity;
if (opts.email) params.email = opts.email;
if (opts.attestation_id) params.attestation_id = opts.attestation_id;
if (opts.token) params.token = opts.token;
var config = {
method: 'POST',
url: opts.url + '/v1/profile/' + opts.identity_id + '/attest',
dataType: 'json',
data: {type:opts.type}
data: params
};
var signedRequest = new SignedRequest(config);
@@ -1476,6 +1492,7 @@ BlobClient.attest = function (opts, fn) {
fn(null, resp.body);
} else if (resp.body) {
log.error('attest:', resp.body);
fn(new Error('Failed to get attest'));
} else {
fn(new Error('Failed to attest'));
}

View File

@@ -20,6 +20,7 @@ var exampleData = {
email_token : '77825040-9096-4695-9cbc-76720f6a8649',
activateLink : 'https://staging.ripple.com/client/#/register/activate/',
device_id : "ac1b6f6dbca98190eb9687ba06f0e066",
identity_id : "17fddb71-a5c2-44ce-8b50-4b381339d4f2",
blob: {
url: 'https://id.staging.ripple.com',
id: 'ef203d3e76552c0592384f909e6f61f1d1f02f61f07643ce015d8b0c9710dd2f',
@@ -104,11 +105,28 @@ var recoverRes = {
}
}
var getProfileRes = {
"result":"success",
"addresses":[],
"attributes":[{
"attribute_id":"4034e477-ffc9-48c4-bcbc-058293f081d8",
"identity_id":"17fddb71-a5c2-44ce-8b50-4b381339d4f2",
"name":"email",
"type":"default",
"domain":null,
"value":"example@example.com",
"visibility":"public",
"updated":null
}
]
};
var blob = new Blob();
blob.url = exampleData.blob.url;
blob.id = exampleData.blob.id;
blob.device_id = exampleData.device_id;
blob.key = exampleData.blob.key;
blob.identity_id = exampleData.blob.identity_id;
blob.data = exampleData.blob.data;
blob.revision = exampleData.blob.data.revision;
@@ -694,6 +712,42 @@ describe('Blob', function () {
});
});
describe('identityVault', function() {
it('#identity-getProfile', function (done) {
var options = {
url : blob.url,
auth_secret : blob.data.auth_secret,
blob_id :blob.id,
identity_id : blob.identity_id,
};
options.profile = {
attributes : [{
name : 'email',
value : 'example@example.com',
visibility : 'public'
}]
};
client.getProfile(options, function(err, resp) {
console.log(err, resp);
done();
});
});
it('#identity-updateProfile', function (done) {
done();
});
it('#identity-getAttestations', function (done) {
done();
});
it('#identity-attest', function (done) {
done();
});
});
//only do these offline
if (!online) {