Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful-sdk-core

Package Overview
Dependencies
Maintainers
4
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-sdk-core - npm Package Compare versions

Comparing version 6.6.0 to 6.7.0

dist/types/async-token.d.ts

51

dist/index.es-modules.js

@@ -283,2 +283,13 @@ import copy from 'fast-copy';

function asyncToken(instance, getToken) {
instance.interceptors.request.use(function (config) {
return getToken().then(function (accessToken) {
config.headers = _objectSpread2(_objectSpread2({}, config.headers), {}, {
Authorization: "Bearer ".concat(accessToken)
});
return config;
});
});
}
function isNode() {

@@ -294,5 +305,11 @@ /**

}
function isReactNative() {
return typeof window !== 'undefined' && 'navigator' in window && 'product' in window.navigator && window.navigator.product === 'ReactNative';
}
function getNodeVersion() {
return process.versions && process.versions.node ? "v".concat(process.versions.node) : process.version;
}
function getWindow() {
return window;
}

@@ -374,3 +391,3 @@ // Also enforces toplevel domain specified, no spaces and no protocol

if (!config.headers.Authorization) {
if (!config.headers.Authorization && typeof config.accessToken !== 'function') {
config.headers.Authorization = 'Bearer ' + config.accessToken;

@@ -420,4 +437,24 @@ } // Set these headers only for node because browsers don't like it when you

};
/**
* Apply interceptors.
* Please note that the order of interceptors is important
*/
if (config.onBeforeRequest) {
instance.interceptors.request.use(config.onBeforeRequest);
}
if (typeof config.accessToken === 'function') {
asyncToken(instance, config.accessToken);
}
rateLimit(instance, config.retryLimit);
if (config.onError) {
instance.interceptors.response.use(function (response) {
return response;
}, config.onError);
}
return instance;

@@ -486,13 +523,11 @@ }

function isReactNative() {
return typeof window !== 'undefined' && 'navigator' in window && 'product' in window.navigator && window.navigator.product === 'ReactNative';
}
function getBrowserOS() {
var win = getWindow();
function getBrowserOS() {
if (!window) {
if (!win) {
return null;
}
var userAgent = window.navigator.userAgent;
var platform = window.navigator.platform;
var userAgent = win.navigator.userAgent;
var platform = win.navigator.platform;
var macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];

@@ -499,0 +534,0 @@ var windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];

@@ -292,2 +292,13 @@ 'use strict';

function asyncToken(instance, getToken) {
instance.interceptors.request.use(function (config) {
return getToken().then(function (accessToken) {
config.headers = _objectSpread2(_objectSpread2({}, config.headers), {}, {
Authorization: "Bearer ".concat(accessToken)
});
return config;
});
});
}
function isNode() {

@@ -303,5 +314,11 @@ /**

}
function isReactNative() {
return typeof window !== 'undefined' && 'navigator' in window && 'product' in window.navigator && window.navigator.product === 'ReactNative';
}
function getNodeVersion() {
return process.versions && process.versions.node ? "v".concat(process.versions.node) : process.version;
}
function getWindow() {
return window;
}

@@ -383,3 +400,3 @@ // Also enforces toplevel domain specified, no spaces and no protocol

if (!config.headers.Authorization) {
if (!config.headers.Authorization && typeof config.accessToken !== 'function') {
config.headers.Authorization = 'Bearer ' + config.accessToken;

@@ -429,4 +446,24 @@ } // Set these headers only for node because browsers don't like it when you

};
/**
* Apply interceptors.
* Please note that the order of interceptors is important
*/
if (config.onBeforeRequest) {
instance.interceptors.request.use(config.onBeforeRequest);
}
if (typeof config.accessToken === 'function') {
asyncToken(instance, config.accessToken);
}
rateLimit(instance, config.retryLimit);
if (config.onError) {
instance.interceptors.response.use(function (response) {
return response;
}, config.onError);
}
return instance;

@@ -495,13 +532,11 @@ }

function isReactNative() {
return typeof window !== 'undefined' && 'navigator' in window && 'product' in window.navigator && window.navigator.product === 'ReactNative';
}
function getBrowserOS() {
var win = getWindow();
function getBrowserOS() {
if (!window) {
if (!win) {
return null;
}
var userAgent = window.navigator.userAgent;
var platform = window.navigator.platform;
var userAgent = win.navigator.userAgent;
var platform = win.navigator.platform;
var macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];

@@ -508,0 +543,0 @@ var windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];

8

dist/types/types.d.ts

@@ -14,4 +14,4 @@ import type { AxiosInstance as OriginalAxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';

export declare type CreateHttpClientParams = {
/** Access Token */
accessToken: string;
/** Access Token or an async function that returns Access Token */
accessToken: string | (() => Promise<string>);
/** Space ID */

@@ -40,2 +40,6 @@ space?: string;

responseLogger?: DefaultOptions['responseLogger'];
/** Request interceptor */
onBeforeRequest?: (value: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>;
/** Error handler */
onError?: (error: any) => any;
/** A log handler function to process given log messages & errors. Receives the log level (error, warning & info) and the actual log data (Error object or string). (Default can be found here: https://github.com/contentful/contentful-sdk-core/blob/master/lib/create-http-client.js) */

@@ -42,0 +46,0 @@ logHandler?: DefaultOptions['logHandler'];

export declare function isNode(): boolean;
export declare function isReactNative(): boolean;
export declare function getNodeVersion(): string;
export declare function getWindow(): Window;
{
"name": "contentful-sdk-core",
"version": "6.6.0",
"version": "6.7.0",
"description": "Core modules for the Contentful JS SDKs",

@@ -24,9 +24,7 @@ "homepage": "https://www.contentful.com/developers/docs/javascript/",

"build": "npm run clean && npm run build:types && npm run build:js",
"lint": "eslint lib test --ext '.ts,.js'",
"lint": "eslint src test --ext '.ts,.js'",
"pretest": "npm run lint",
"test": "npm run test:cover",
"test:ci-emulate": "trevor",
"test:cover": "babel-node --extensions .ts --extensions .js ./node_modules/istanbul/lib/cli.js cover ./test/runner | tap-spec",
"test:unit": "babel-node --extensions .ts --extensions .js ./test/runner | tap-spec",
"test:debug": "babel-node --extensions .ts --extensions .js debug ./test/runner",
"test": "tsdx test",
"test:watch": "tsdx test --watch",
"test:cover": "tsdx test --coverage",
"browser-coverage": "npm run test:cover && opener coverage/lcov-report/index.html",

@@ -38,2 +36,3 @@ "prepublish": "in-publish && npm run build || not-in-publish",

"precommit": "npm run lint",
"tsc": "tsc --noEmit",
"prepush": "npm run test:unit"

@@ -53,3 +52,2 @@ },

"devDependencies": {
"@types/qs": "^6.9.5",
"@babel/cli": "^7.12.8",

@@ -62,2 +60,3 @@ "@babel/core": "^7.12.9",

"@rollup/plugin-node-resolve": "^11.0.0",
"@types/qs": "^6.9.5",
"@typescript-eslint/eslint-plugin": "2.34.0",

@@ -68,8 +67,7 @@ "@typescript-eslint/parser": "2.34.0",

"babel-eslint": "^10.1.0",
"babel-plugin-rewire-ts": "1.3.3",
"blue-tape": "^1.0.0",
"codecov": "^3.0.4",
"core-js": "^3.8.0",
"cz-conventional-changelog": "^3.1.0",
"eslint": "^7.2.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-config-standard": "^16.0.0",

@@ -83,3 +81,2 @@ "eslint-plugin-babel": "^5.1.0",

"in-publish": "^2.0.0",
"istanbul": "^1.0.0-alpha.2",
"lint-staged": "^10.5.2",

@@ -90,2 +87,3 @@ "mkdirp": "^1.0.4",

"prettier": "^2.2.1",
"regenerator-runtime": "^0.13.7",
"require-all": "^3.0.0",

@@ -96,5 +94,3 @@ "rimraf": "^3.0.2",

"semantic-release": "^17.0.7",
"sinon": "^9.0.2",
"tap-spec": "^5.0.0",
"trevor": "^2.3.0",
"tsdx": "^0.14.1",
"tslib": "^2.0.3",

@@ -101,0 +97,0 @@ "typescript": "4.1.2"

@@ -17,3 +17,2 @@ # contentful-sdk-core

## About

@@ -25,3 +24,3 @@

* Make sure you use at least Node 4.7
- Make sure you use at least Node 4.7

@@ -50,2 +49,3 @@ ## Installation

### Create the default and the es-modules build:
```

@@ -58,7 +58,9 @@ npm run build

Run only the unit tests:
```
npm run test:unit
npm run test
```
Run unit tests including coverage report:
```

@@ -69,2 +71,3 @@ npm run test:cover

Run unit tests with coverage report and display the result in your browser:
```

@@ -75,2 +78,3 @@ npm run browser-coverage

Emulate a CI test run:
```

@@ -81,4 +85,5 @@ npm run test:ci-emulate

Enable debug mode for tests:
```
npm run test:debug
```
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