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

hsdk

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hsdk - npm Package Compare versions

Comparing version 2.0.3 to 3.0.0

source/wrapResources/resource/request/identify/index.js

2

package.json
{
"name": "hsdk",
"version": "2.0.3",
"version": "3.0.0",
"description": "A hypermedia standard development kit for knowing about home api endpoints",

@@ -5,0 +5,0 @@ "main": "transpiled/source/index.js",

@@ -19,3 +19,3 @@ # hsdk

hsdk({protocol: "http", host: "hsdkjs.getsandbox.com", root: "v1/resources"})
hsdk({home: "http://hsdkjs.getsandbox.com/v1/resources"})
.then((client) => client.accounts.v1.list())

@@ -30,3 +30,3 @@ .then((value) => console.log(value))

Using the example above, we need a HTTP server running on `hsdkjs.getsandbox.com` that responds to `http` requests to `GET /v1/resources`.
Using the example above, we need a HTTP server running at `http://hsdkjs.getsandbox.com` that responds to `GET /v1/resources` requests.

@@ -33,0 +33,0 @@ Here is a sample CURL-based request (an example of what hsdk does under the hood):

import axios from "axios"
import {prop} from "ramda"
import wrapResources from "./wrapResources"
import handleResponse from "./handleResponse"
import treeify from "./treeify"
export default function hsdk ({protocol, host, root}) {
export default function hsdk ({home}) {
return axios({
url: `${protocol}://${host}/${root}`,
url: home,
headers: {

@@ -15,5 +15,5 @@ Accept: "application/vnd.api+json"

})
.then(handleResponse)
.then(prop("data"))
.then(wrapResources)
.then(treeify)
}
import axois from "axios"
import urlTemplate from "url-template"
import {isNil} from "ramda"
import {always} from "ramda"
import {ifElse} from "ramda"
import {omit} from "ramda"
const authorize = ({key, secret}) => ({Authorization: `Basic ${window.btoa(`${key}:${secret}`)}`})
const authorization = ifElse(isNil, always({}), authorize)
import identify from "./identify"
export default function request ({method, href, mediatype}) {
return (configuration = {}) => {
const {authentication = {}} = configuration
const {payload = null} = configuration
const url = urlTemplate.parse(href).expand(omit(["authentication", "payload"], configuration))
const properties = {

@@ -22,3 +16,3 @@ method,

"Accept": mediatype,
...authorization(authentication)
...identify(configuration)
}

@@ -25,0 +19,0 @@ }

@@ -12,2 +12,4 @@ "use strict";

var _ramda = require("ramda");
var _wrapResources = require("./wrapResources");

@@ -17,6 +19,2 @@

var _handleResponse = require("./handleResponse");
var _handleResponse2 = _interopRequireDefault(_handleResponse);
var _treeify = require("./treeify");

@@ -29,8 +27,6 @@

function hsdk(_ref) {
var protocol = _ref.protocol,
host = _ref.host,
root = _ref.root;
var home = _ref.home;
return (0, _axios2.default)({
url: protocol + "://" + host + "/" + root,
url: home,
headers: {

@@ -40,3 +36,3 @@ Accept: "application/vnd.api+json"

responseType: "json"
}).then(_handleResponse2.default).then(_wrapResources2.default).then(_treeify2.default);
}).then((0, _ramda.prop)("data")).then(_wrapResources2.default).then(_treeify2.default);
}

@@ -21,20 +21,15 @@ "use strict";

var _identify = require("./identify");
var _identify2 = _interopRequireDefault(_identify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var authorize = function authorize(_ref) {
var key = _ref.key,
secret = _ref.secret;
return { Authorization: "Basic " + window.btoa(key + ":" + secret) };
};
var authorization = (0, _ramda.ifElse)(_ramda.isNil, (0, _ramda.always)({}), authorize);
function request(_ref) {
var method = _ref.method,
href = _ref.href,
mediatype = _ref.mediatype;
function request(_ref2) {
var method = _ref2.method,
href = _ref2.href,
mediatype = _ref2.mediatype;
return function () {
var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _configuration$authen = configuration.authentication,
authentication = _configuration$authen === undefined ? {} : _configuration$authen;
var _configuration$payloa = configuration.payload,

@@ -44,3 +39,2 @@ payload = _configuration$payloa === undefined ? null : _configuration$payloa;

var url = _urlTemplate2.default.parse(href).expand((0, _ramda.omit)(["authentication", "payload"], configuration));
var properties = {

@@ -51,3 +45,3 @@ method: method,

"Accept": mediatype
}, authorization(authentication))
}, (0, _identify2.default)(configuration))
};

@@ -54,0 +48,0 @@

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