New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@oneblink/sdk

Package Overview
Dependencies
Maintainers
4
Versions
511
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oneblink/sdk - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

lib/pre-fill-data.js

10

changelog.md

@@ -5,2 +5,12 @@ # Changelog

## 0.2.1 (2018-09-04)
### Added
- Pre filled data argument to `forms.generateFormUrl()` function
### Fixed
- Path of forms renderer URL to match `/forms/{formId}`
## 0.2.0 (2018-08-07)

@@ -7,0 +17,0 @@

52

lib/forms.js

@@ -17,2 +17,3 @@ // @flow

const OneBlinkAPI = require('./one-blink-api.js')
const setPreFillData = require('./pre-fill-data')

@@ -31,32 +32,37 @@ module.exports = class Forms extends OneBlinkAPI {

generateFormUrl (
async generateFormUrl (
formId /* : ?mixed */,
externalId /* : ?mixed */
externalId /* : ?mixed */,
preFillData /* : ?mixed */
) /* : Promise<{ expiry: string, formUrl: string }> */ {
return super.searchRequest(`/organisations`)
.then((results) => {
if (typeof formId !== 'number') {
throw new TypeError('Must supply "formId" as a number')
}
if (externalId && typeof externalId !== 'string') {
throw new TypeError('Must supply "externalId" as a string or not at all')
}
if (!results.organisations || !results.organisations.length) {
throw new Error('Access Denied. The "accessKey" and "secretKey" provided may have been revoked.')
}
const organisationsResults = await super.searchRequest(`/organisations`)
if (typeof formId !== 'number') {
throw new TypeError('Must supply "formId" as a number')
}
if (externalId && typeof externalId !== 'string') {
throw new TypeError('Must supply "externalId" as a string or not at all')
}
if (!organisationsResults.organisations || !organisationsResults.organisations.length) {
throw new Error('Access Denied. The "accessKey" and "secretKey" provided may have been revoked.')
}
// Default expiry for token is 8 hours
const jwtExpiry = 28800
let preFillFormDataId
if (preFillData) {
const preFillMeta = await super.getRequest(`/forms/${formId}/pre-fill-credentials`)
await setPreFillData(preFillMeta, preFillData)
preFillFormDataId = preFillMeta.preFillFormDataId
}
// Default expiry for token is 8 hours
const jwtExpiry = 28800
const token = generateJWT(this.accessKey, this.secretKey, jwtExpiry)
const token = generateJWT(this.accessKey, this.secretKey, jwtExpiry)
const formUrl = generateFormUrl(`https://${results.organisations[0].formsHostname}`, formId, token, externalId)
const formUrl = generateFormUrl(`https://${organisationsResults.organisations[0].formsHostname}/forms`, formId, token, externalId, preFillFormDataId)
const expiry = new Date(Date.now() + (jwtExpiry * 1000)).toISOString()
const expiry = new Date(Date.now() + (jwtExpiry * 1000)).toISOString()
return {
formUrl,
expiry
}
})
return {
formUrl,
expiry
}
}

@@ -63,0 +69,0 @@

@@ -10,3 +10,4 @@ // @flow

token /* : string */,
externalId /* : mixed */
externalId /* : mixed */,
preFillFormDataId /* : ?string */
) {

@@ -22,2 +23,5 @@ if (!formId) {

}
if (preFillFormDataId) {
searchParams = Object.assign({}, searchParams, { preFillFormDataId })
}
const search = querystring.stringify(searchParams)

@@ -24,0 +28,0 @@ return `${endpoint}/${formId}?${search}`

{
"name": "@oneblink/sdk",
"description": "OneBlink SDK to serve as an entry point for all OneBlink Services in NodeJS",
"version": "0.2.0",
"version": "0.2.1",
"bugs": {

@@ -6,0 +6,0 @@ "url": "https://github.com/blinkmobile/oneblink-sdk-js/issues"

@@ -26,2 +26,11 @@ // @flow

export type PreFillMeta = {
credentials: AWSCredentials,
s3: {
bucket: string,
key: string,
region: string
}
}
export type BaseSearchResult = {

@@ -28,0 +37,0 @@ meta: {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc