Skip to content

Commit

Permalink
Merge pull request #33 from truevault/fix-doc-create-json-attributes
Browse files Browse the repository at this point in the history
Fix doc create json attributes
  • Loading branch information
alamottemitchell authored Aug 21, 2018
2 parents 29f136d + bd3775c commit 0c976bb
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 49 deletions.
286 changes: 242 additions & 44 deletions build/index-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4630,28 +4630,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
/* 127 */
/***/ (function(module, exports) {

module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};


/***/ }),
Expand Down Expand Up @@ -6752,11 +6752,11 @@ var TrueVaultClient = function () {


if (typeof schemaId === 'string') {
body.schemaId = schemaId;
body.schema_id = schemaId;
}

if (typeof ownerId === 'string') {
body.ownerId = ownerId;
body.owner_id = ownerId;
}
_context45.next = 5;
return this.performJSONRequest('v2/vaults/' + vaultId + '/documents', {
Expand Down Expand Up @@ -7834,6 +7834,204 @@ var TrueVaultClient = function () {

return sendPasswordResetEmail;
}()

/**
* Link a Scoped Access Token to a Password Reset Flow. See https://docs.truevault.com/passwordresetflow#link-a-scoped-access-token-to-a-password-reset-flow
* @param {string} flowId
* @param {string} tokenId
* @returns {Promise.<undefined>}
*/

}, {
key: 'linkScopedAccessTokenToPasswordResetFlow',
value: function () {
var _ref67 = _asyncToGenerator(regeneratorRuntime.mark(function _callee67(flowId, tokenId) {
return regeneratorRuntime.wrap(function _callee67$(_context67) {
while (1) {
switch (_context67.prev = _context67.next) {
case 0:
_context67.next = 2;
return this.performJSONRequest('v1/password_reset_flows/' + flowId + '/link_sat', {
method: 'POST',
body: JSON.stringify({
scoped_access_token_id: tokenId
})
});

case 2:
case 'end':
return _context67.stop();
}
}
}, _callee67, this);
}));

function linkScopedAccessTokenToPasswordResetFlow(_x159, _x160) {
return _ref67.apply(this, arguments);
}

return linkScopedAccessTokenToPasswordResetFlow;
}()

/**
* Create a new Scoped Access Token. See: https://docs.truevault.com/scopedaccesstokens#create-a-scoped-access-token
* @param {string} name
* @param {Array} policy See https://docs.truevault.com/groups for policy definition documentation
* @param {Date} [notValidAfter] notValidAfter optional parameter specifying when the returned access token expires
* @param {number} [allowedUses] allowedUses optional parameter specifying number of allowed uses
* @returns {Promise.<Object>}
*/

}, {
key: 'createScopedAccessToken',
value: function () {
var _ref68 = _asyncToGenerator(regeneratorRuntime.mark(function _callee68(name, policy, notValidAfter, allowedUses) {
var jsonPayload;
return regeneratorRuntime.wrap(function _callee68$(_context68) {
while (1) {
switch (_context68.prev = _context68.next) {
case 0:
jsonPayload = {
name: name,
policy: policy
};


if (!!notValidAfter) {
jsonPayload['not_valid_after'] = notValidAfter.toISOString();
}

if (!!allowedUses) {
jsonPayload['allowed_uses'] = allowedUses;
}

_context68.next = 5;
return this.performJSONRequest('v1/scoped_access_tokens', {
method: 'POST',
body: JSON.stringify(jsonPayload)
});

case 5:
case 'end':
return _context68.stop();
}
}
}, _callee68, this);
}));

function createScopedAccessToken(_x161, _x162, _x163, _x164) {
return _ref68.apply(this, arguments);
}

return createScopedAccessToken;
}()

/**
* Get a Scoped Access Token. See https://docs.truevault.com/scopedaccesstokens#get-a-scoped-access-token
* @param {string} tokenId the token to get
* @returns {Promise.<Object>}
*/

}, {
key: 'getScopedAccessToken',
value: function () {
var _ref69 = _asyncToGenerator(regeneratorRuntime.mark(function _callee69(tokenId) {
var response;
return regeneratorRuntime.wrap(function _callee69$(_context69) {
while (1) {
switch (_context69.prev = _context69.next) {
case 0:
_context69.next = 2;
return this.performJSONRequest('v1/scoped_access_tokens/' + tokenId);

case 2:
response = _context69.sent;
return _context69.abrupt('return', resonse.scoped_access_token);

case 4:
case 'end':
return _context69.stop();
}
}
}, _callee69, this);
}));

function getScopedAccessToken(_x165) {
return _ref69.apply(this, arguments);
}

return getScopedAccessToken;
}()

/**
* List all Scoped Access Tokens. See https://docs.truevault.com/scopedaccesstokens#list-scoped-access-tokens
* @returns {Promise.<Array>}
*/

}, {
key: 'listScopedAccessTokens',
value: function () {
var _ref70 = _asyncToGenerator(regeneratorRuntime.mark(function _callee70() {
var response;
return regeneratorRuntime.wrap(function _callee70$(_context70) {
while (1) {
switch (_context70.prev = _context70.next) {
case 0:
_context70.next = 2;
return this.performJSONRequest('v1/scoped_access_tokens');

case 2:
response = _context70.sent;
return _context70.abrupt('return', response.data.items);

case 4:
case 'end':
return _context70.stop();
}
}
}, _callee70, this);
}));

function listScopedAccessTokens() {
return _ref70.apply(this, arguments);
}

return listScopedAccessTokens;
}()

/**
* Delete a Scoped Access Token. See https://docs.truevault.com/scopedaccesstokens#delete-a-scoped-access-token
* @param {string} tokenId the token to delete
* @returns {Promise.<undefined>}
*/

}, {
key: 'deleteScopedAccessToken',
value: function () {
var _ref71 = _asyncToGenerator(regeneratorRuntime.mark(function _callee71(tokenId) {
return regeneratorRuntime.wrap(function _callee71$(_context71) {
while (1) {
switch (_context71.prev = _context71.next) {
case 0:
_context71.next = 2;
return this.performJSONRequest('v1/scoped_access_tokens/' + tokenId, {
method: 'DELETE'
});

case 2:
case 'end':
return _context71.stop();
}
}
}, _callee71, this);
}));

function deleteScopedAccessToken(_x166) {
return _ref71.apply(this, arguments);
}

return deleteScopedAccessToken;
}()
}, {
key: 'accessToken',
get: function get() {
Expand All @@ -7857,29 +8055,29 @@ var TrueVaultClient = function () {
}], [{
key: 'login',
value: function () {
var _ref67 = _asyncToGenerator(regeneratorRuntime.mark(function _callee67(accountId, username, password, mfaCode, host, notValidAfter) {
var _ref72 = _asyncToGenerator(regeneratorRuntime.mark(function _callee72(accountId, username, password, mfaCode, host, notValidAfter) {
var accessToken;
return regeneratorRuntime.wrap(function _callee67$(_context67) {
return regeneratorRuntime.wrap(function _callee72$(_context72) {
while (1) {
switch (_context67.prev = _context67.next) {
switch (_context72.prev = _context72.next) {
case 0:
_context67.next = 2;
_context72.next = 2;
return TrueVaultClient.generateAccessToken(accountId, username, password, mfaCode, host, notValidAfter);

case 2:
accessToken = _context67.sent;
return _context67.abrupt('return', new TrueVaultClient({ 'accessToken': accessToken }, host));
accessToken = _context72.sent;
return _context72.abrupt('return', new TrueVaultClient({ 'accessToken': accessToken }, host));

case 4:
case 'end':
return _context67.stop();
return _context72.stop();
}
}
}, _callee67, this);
}, _callee72, this);
}));

function login(_x159, _x160, _x161, _x162, _x163, _x164) {
return _ref67.apply(this, arguments);
function login(_x167, _x168, _x169, _x170, _x171, _x172) {
return _ref72.apply(this, arguments);
}

return login;
Expand All @@ -7900,11 +8098,11 @@ var TrueVaultClient = function () {
}, {
key: 'generateAccessToken',
value: function () {
var _ref68 = _asyncToGenerator(regeneratorRuntime.mark(function _callee68(accountId, username, password, mfaCode, host, notValidAfter) {
var _ref73 = _asyncToGenerator(regeneratorRuntime.mark(function _callee73(accountId, username, password, mfaCode, host, notValidAfter) {
var formData, tvClient, response;
return regeneratorRuntime.wrap(function _callee68$(_context68) {
return regeneratorRuntime.wrap(function _callee73$(_context73) {
while (1) {
switch (_context68.prev = _context68.next) {
switch (_context73.prev = _context73.next) {
case 0:
formData = new tvFormData();

Expand All @@ -7919,26 +8117,26 @@ var TrueVaultClient = function () {
}

tvClient = new TrueVaultClient(null, host);
_context68.next = 9;
_context73.next = 9;
return tvClient.performLegacyRequest('v1/auth/login', {
method: 'POST',
body: formData
});

case 9:
response = _context68.sent;
return _context68.abrupt('return', response.user.access_token);
response = _context73.sent;
return _context73.abrupt('return', response.user.access_token);

case 11:
case 'end':
return _context68.stop();
return _context73.stop();
}
}
}, _callee68, this);
}, _callee73, this);
}));

function generateAccessToken(_x165, _x166, _x167, _x168, _x169, _x170) {
return _ref68.apply(this, arguments);
function generateAccessToken(_x173, _x174, _x175, _x176, _x177, _x178) {
return _ref73.apply(this, arguments);
}

return generateAccessToken;
Expand Down
Loading

0 comments on commit 0c976bb

Please sign in to comment.