@evervault/sdk
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -77,3 +77,15 @@ const { errors } = require('../utils'); | ||
return { getCageKey, runCage, getCert }; | ||
const createRunToken = (cageName, payload) => { | ||
return post( | ||
`v2/functions/${cageName}/run-token`, | ||
{ | ||
...payload, | ||
}, | ||
{ | ||
'Content-Type': 'application/json', | ||
} | ||
); | ||
}; | ||
return { getCageKey, runCage, getCert, createRunToken }; | ||
}; |
@@ -16,2 +16,3 @@ const crypto = require('crypto'); | ||
certHelper, | ||
validationHelper, | ||
} = require('./utils'); | ||
@@ -306,14 +307,5 @@ const Config = require('./config'); | ||
async run(cageName, payload, options = {}) { | ||
if (!Datatypes.isObjectStrict(payload)) { | ||
throw new errors.EvervaultError('Cages must be given an object to run'); | ||
} | ||
if (!Datatypes.isString(cageName)) | ||
throw new errors.EvervaultError('Cage name invalid'); | ||
if ( | ||
Datatypes.isObjectStrict(options) && | ||
Datatypes.isDefined(options.version) && | ||
!Datatypes.isNumber(options.version) | ||
) { | ||
throw new errors.EvervaultError('Cage version must be a number'); | ||
} | ||
validationHelper.validatePayload(payload); | ||
validationHelper.validateCageName(cageName); | ||
validationHelper.validateOptions(options); | ||
@@ -402,8 +394,5 @@ if (this.retry) { | ||
async encryptAndRun(cageName, data, options) { | ||
if (!Datatypes.isString(cageName)) { | ||
throw new errors.EvervaultError('Cage name invalid'); | ||
} | ||
if (!Datatypes.isObjectStrict(data)) { | ||
throw new errors.EvervaultError('Cages must be given an object to run'); | ||
} | ||
validationHelper.validatePayload(data); | ||
validationHelper.validateCageName(cageName); | ||
validationHelper.validateOptions(options); | ||
@@ -415,2 +404,15 @@ const payload = await this.encrypt(data); | ||
/** | ||
* @param {String} cageName | ||
* @param {Object} payload | ||
* @returns {Promise<*>} | ||
*/ | ||
async createRunToken(cageName, payload) { | ||
validationHelper.validatePayload(payload); | ||
validationHelper.validateCageName(cageName); | ||
const response = await this.http.createRunToken(cageName, payload); | ||
return response.body; | ||
} | ||
defineHiddenProperty(property, value) { | ||
@@ -417,0 +419,0 @@ Object.defineProperty(this, property, { |
@@ -9,2 +9,3 @@ module.exports = { | ||
certHelper: require('./certHelper'), | ||
validationHelper: require('./validationHelper'), | ||
}; |
{ | ||
"name": "@evervault/sdk", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "Node.js SDK for Evervault", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -93,2 +93,15 @@ [![Evervault](https://evervault.com/evervault.svg)](https://evervault.com/) | ||
### evervault.createRunToken() | ||
`evervault.createRunToken()` creates a single use, time bound token for invoking a cage. | ||
```javascript | ||
async evervault.createRunToken(cageName: String, payload: Object); | ||
``` | ||
| Parameter | Type | Description | | ||
| --------- | ------ | ---------------------------------------------------- | | ||
| cageName | String | Name of the Cage the run token should be created for | | ||
| data | Object | Payload that the token can be used with | | ||
## Contributing | ||
@@ -95,0 +108,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49906
24
1432
115