@hubspot/api-auth-lib
Advanced tools
Comparing version 1.1.1 to 1.1.3-beta.0
@@ -7,3 +7,9 @@ const express = require('express'); | ||
const { HubSpotAuthError } = require('./Errors'); | ||
const { ENVIRONMENTS } = require('@hubspot/cms-lib/lib/constants'); | ||
const { handleExit } = require('@hubspot/cms-lib/lib/process'); | ||
const { | ||
getHubSpotWebsiteOrigin, | ||
getHubSpotApiOrigin, | ||
} = require('@hubspot/cms-lib/lib/urls'); | ||
const { getValidEnv } = require('@hubspot/cms-lib/lib/environment'); | ||
@@ -20,3 +26,3 @@ const PORT = 3000; | ||
scopes, | ||
environment = 'prod', | ||
environment = ENVIRONMENTS.PROD, | ||
tokenInfo = { expiresAt: null, refreshToken: null, accessToken: null }, | ||
@@ -32,3 +38,3 @@ }, | ||
this.portalId = portalId; | ||
this.env = environment.toLowerCase() === 'prod' ? '' : 'qa'; | ||
this.env = getValidEnv(environment, true); | ||
this.logger = logger; | ||
@@ -41,3 +47,3 @@ this.writeTokenInfo = writeTokenInfo; | ||
return ( | ||
`https://app.hubspot${this.env}.com/oauth/${this.portalId}/authorize` + | ||
`${getHubSpotWebsiteOrigin(this.env)}/oauth/${this.portalId}/authorize` + | ||
`?client_id=${encodeURIComponent(this.clientId)}` + // app's client ID | ||
@@ -131,3 +137,3 @@ `&scope=${encodeURIComponent(this.scopes.join(' '))}` + // scopes being requested by the app | ||
this.refreshTokenRequest = request.post( | ||
`https://api.hubapi${this.env}.com/oauth/v1/token`, | ||
`${getHubSpotApiOrigin(this.env)}/oauth/v1/token`, | ||
{ | ||
@@ -197,3 +203,3 @@ form: exchangeProof, | ||
return { | ||
environment: this.env ? 'qa' : 'prod', | ||
environment: this.env ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD, | ||
clientSecret: this.clientSecret, | ||
@@ -212,3 +218,3 @@ clientId: this.clientId, | ||
...rest, | ||
environment: env && env.toLowerCase() === 'qa' ? 'qa' : 'prod', | ||
environment: getValidEnv(env), | ||
...auth, | ||
@@ -215,0 +221,0 @@ }, |
{ | ||
"name": "@hubspot/api-auth-lib", | ||
"version": "1.1.1", | ||
"version": "1.1.3-beta.0", | ||
"license": "Apache-2.0", | ||
@@ -23,3 +23,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "c0aac7dd9ec92e3ae28e0f4cb2820f8a5834a58f" | ||
"gitHead": "6b6fd557ef9a25ad91065ccd3a2b0db1c3b3d267" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7975
7
213
2