@hubspot/local-dev-lib 3.5.3 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/localDevAuth.d.ts +1 -0
- package/api/localDevAuth.js +3 -2
- package/http/index.js +58 -2
- package/package.json +2 -2
package/api/localDevAuth.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Environment } from '../types/Config';
|
|
|
2
2
|
import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts';
|
|
3
3
|
import { PublicAppInstallationData } from '../types/Apps';
|
|
4
4
|
import { HubSpotPromise } from '../types/Http';
|
|
5
|
+
export declare const LOCALDEVAUTH_ACCESS_TOKEN_PATH: string;
|
|
5
6
|
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
|
|
6
7
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
|
|
7
8
|
export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
|
package/api/localDevAuth.js
CHANGED
|
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeAuthorizationData = exports.fetchScopeData = exports.fetchAccessToken = void 0;
|
|
6
|
+
exports.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeAuthorizationData = exports.fetchScopeData = exports.fetchAccessToken = exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH = void 0;
|
|
7
7
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
8
8
|
const http_1 = require("../http");
|
|
9
9
|
const environments_1 = require("../constants/environments");
|
|
10
10
|
const axios_1 = __importDefault(require("axios"));
|
|
11
11
|
const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
|
|
12
|
+
exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH = `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`;
|
|
12
13
|
function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
|
|
13
14
|
const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
|
|
14
15
|
env,
|
|
15
16
|
localHostOverride: true,
|
|
16
|
-
url:
|
|
17
|
+
url: exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH,
|
|
17
18
|
data: {
|
|
18
19
|
encodedOAuthRefreshToken: personalAccessKey,
|
|
19
20
|
},
|
package/http/index.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
@@ -7,7 +30,7 @@ exports.http = exports.addUserAgentHeader = void 0;
|
|
|
7
30
|
const path_1 = __importDefault(require("path"));
|
|
8
31
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
32
|
const content_disposition_1 = __importDefault(require("content-disposition"));
|
|
10
|
-
const axios_1 =
|
|
33
|
+
const axios_1 = __importStar(require("axios"));
|
|
11
34
|
const config_1 = require("../config");
|
|
12
35
|
const getAxiosConfig_1 = require("./getAxiosConfig");
|
|
13
36
|
const addQueryParams_1 = require("./addQueryParams");
|
|
@@ -16,8 +39,41 @@ const oauth_1 = require("../lib/oauth");
|
|
|
16
39
|
const logger_1 = require("../lib/logger");
|
|
17
40
|
const lang_1 = require("../utils/lang");
|
|
18
41
|
const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
|
|
42
|
+
const localDevAuth_1 = require("../api/localDevAuth");
|
|
43
|
+
const util = __importStar(require("util"));
|
|
19
44
|
const i18nKey = 'http.index';
|
|
20
|
-
|
|
45
|
+
function logRequest(response) {
|
|
46
|
+
try {
|
|
47
|
+
if (process.env.HUBSPOT_NETWORK_LOGGING) {
|
|
48
|
+
if (response.config.url === localDevAuth_1.LOCALDEVAUTH_ACCESS_TOKEN_PATH) {
|
|
49
|
+
// Don't log access tokens
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
logger_1.logger.debug(util.inspect({
|
|
53
|
+
method: response.config.method,
|
|
54
|
+
baseURL: response.config.baseURL,
|
|
55
|
+
url: response.config.url,
|
|
56
|
+
data: response.data,
|
|
57
|
+
status: response.status,
|
|
58
|
+
}, false, null, true));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// Ignore any errors that occur while logging the response
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
axios_1.default.interceptors.response.use((response) => {
|
|
66
|
+
logRequest(response);
|
|
67
|
+
return response;
|
|
68
|
+
}, error => {
|
|
69
|
+
try {
|
|
70
|
+
if ((0, axios_1.isAxiosError)(error) && error.response) {
|
|
71
|
+
logRequest(error.response);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
// Ignore any errors that occur while logging the response
|
|
76
|
+
}
|
|
21
77
|
// Wrap all axios errors in our own Error class. Attach the error
|
|
22
78
|
// as the cause for the new error, so we maintain the stack trace
|
|
23
79
|
return Promise.reject(new HubSpotHttpError_1.HubSpotHttpError(error.message, { cause: error }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"address": "2.0.2",
|
|
64
|
-
"axios": "1.8.
|
|
64
|
+
"axios": "1.8.4",
|
|
65
65
|
"chalk": "2.4.2",
|
|
66
66
|
"chokidar": "3.6.0",
|
|
67
67
|
"content-disposition": "0.5.4",
|