Socket
Socket
Sign inDemoInstall

@hubspot/cms-lib

Package Overview
Dependencies
Maintainers
13
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hubspot/cms-lib - npm Package Compare versions

Comparing version 2.0.0-beta.2 to 2.0.0

api/localDevAuth/authenticated.js

4

__tests__/personalAccessKey.js
const moment = require('moment');
const { getAndLoadConfigIfNeeded, getPortalConfig } = require('../lib/config');
const { fetchAccessToken } = require('../api/localDevAuth');
const { fetchAccessToken } = require('../api/localDevAuth/unauthenticated');
const { ENVIRONMENTS } = require('../lib/constants');

@@ -10,3 +10,3 @@

jest.mock('../logger');
jest.mock('../api/localDevAuth');
jest.mock('../api/localDevAuth/unauthenticated');

@@ -13,0 +13,0 @@ describe('personalAccessKey', () => {

@@ -17,2 +17,6 @@ const { HubSpotAuthError } = require('@hubspot/api-auth-lib/Errors');

const isFatalError = err => err instanceof HubSpotAuthError;
const isMissingScopeError = err =>
err.name === 'StatusCodeError' &&
err.statusCode === 403 &&
err.error.category === 'MISSING_SCOPES';
const contactSupportString =

@@ -304,2 +308,45 @@ 'Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.';

/**
* Logs a message for an error instance resulting from API interaction
* related to serverless function.
*
* @param {Error|SystemError|Object} error
* @param {ApiErrorContext} context
*/
function logServerlessFunctionApiErrorInstance(error, scopesData, context) {
if (!scopesData) {
return;
}
if (isMissingScopeError(error)) {
const { portalScopesInGroup, userScopesInGroup } = scopesData;
if (!portalScopesInGroup.length) {
logger.error(
'Your account does not have access to this action. Talk to an account admin to request it.'
);
return;
}
if (!portalScopesInGroup.every(s => userScopesInGroup.includes(s))) {
logger.error(
"You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
);
return;
} else {
logger.error(
'Your access key does not allow this action. Please generate a new access key by running "hs auth personalaccesskey".'
);
return;
}
}
// StatusCodeError
if (isApiStatusCodeError(error)) {
logApiStatusCodeError(error, context);
return;
}
logErrorInstance(error, context);
}
module.exports = {

@@ -315,2 +362,3 @@ ErrorContext,

logFileSystemErrorInstance,
logServerlessFunctionApiErrorInstance,
};

@@ -90,2 +90,6 @@ const ENVIRONMENTS = {

const SCOPE_GROUPS = {
functions: 'cms.functions.read_write',
};
module.exports = {

@@ -108,2 +112,3 @@ Mode,

ENVIRONMENT_VARIABLES,
SCOPE_GROUPS,
};
{
"name": "@hubspot/cms-lib",
"version": "2.0.0-beta.2",
"version": "2.0.0",
"description": "Library for working with the HubSpot CMS",

@@ -34,3 +34,3 @@ "license": "Apache-2.0",

},
"gitHead": "3a35a937f255ad1934694aca25cc96a351713f2f"
"gitHead": "16b34f98fff4688a6442623bc8d645e994f14395"
}

@@ -16,3 +16,3 @@ const moment = require('moment');

} = require('./lib/constants');
const { fetchAccessToken } = require('./api/localDevAuth');
const { fetchAccessToken } = require('./api/localDevAuth/unauthenticated');
const { logErrorInstance } = require('./errorHandlers');

@@ -19,0 +19,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