@panora/shared
Advanced tools
Comparing version 1.3.0 to 1.4.0
RELEASE 1.0.0 | ||
## 1.4.0 | ||
### Minor Changes | ||
- 773c515: update minor for npm packages | ||
## 1.3.0 | ||
@@ -4,0 +10,0 @@ |
@@ -8,4 +8,5 @@ interface AuthParams { | ||
vertical: string; | ||
redirectUrlIngressWhenLocalDev?: string; | ||
} | ||
export declare const constructAuthUrl: ({ projectId, linkedUserId, providerName, returnUrl, apiUrl, vertical }: AuthParams) => Promise<string | void>; | ||
export {}; |
@@ -18,6 +18,9 @@ "use strict"; | ||
const constructAuthUrl = (_a) => __awaiter(void 0, [_a], void 0, function* ({ projectId, linkedUserId, providerName, returnUrl, apiUrl, vertical }) { | ||
const encodedRedirectUrl = encodeURIComponent(`${apiUrl}/connections/oauth/callback`); | ||
var _b; | ||
const redirectUrlIngressWhenLocalDev = ((_b = metadata_1.CONNECTORS_METADATA[vertical][providerName].options) === null || _b === void 0 ? void 0 : _b.local_redirect_uri_in_https) === true && 'https://prepared-wildcat-infinitely.ngrok-free.app'; | ||
const localEnv = apiUrl.startsWith('http://localhost:3000') || apiUrl.includes('localhost'); | ||
const encodedRedirectUrl = encodeURIComponent(`${localEnv && redirectUrlIngressWhenLocalDev ? redirectUrlIngressWhenLocalDev : apiUrl}/connections/oauth/callback`); | ||
const state = encodeURIComponent(JSON.stringify({ projectId, linkedUserId, providerName, vertical, returnUrl })); | ||
if (vertical == null) { | ||
throw new Error('vertical is null'); | ||
throw new ReferenceError('vertical is null'); | ||
} | ||
@@ -28,3 +31,3 @@ const config = metadata_1.CONNECTORS_METADATA[vertical.toLowerCase()][providerName]; | ||
} | ||
const authStrategy = config.authStrategy; | ||
const authStrategy = config.authStrategy.strategy; | ||
switch (authStrategy) { | ||
@@ -56,3 +59,3 @@ case types_1.AuthStrategy.oauth2: | ||
if (!clientId) | ||
throw new Error(`No client id for type ${type}`); | ||
throw new ReferenceError(`No client id for type ${type}`); | ||
const scopes = data.SCOPE; | ||
@@ -62,17 +65,48 @@ const { urls: urls } = config; | ||
if (!baseUrl) | ||
throw new Error(`No authBaseUrl found for type ${type}`); | ||
const BASE_URL = providerName === 'gorgias' ? `${apiUrl}${baseUrl}` : | ||
data.SUBDOMAIN ? data.SUBDOMAIN + baseUrl : baseUrl; | ||
throw new ReferenceError(`No authBaseUrl found for type ${type}`); | ||
let BASE_URL; | ||
if ((0, envConfig_1.needsSubdomain)(providerName, vertical)) { | ||
if (typeof baseUrl === 'string') { | ||
BASE_URL = baseUrl; | ||
} | ||
else { | ||
BASE_URL = baseUrl(data.SUBDOMAIN); | ||
} | ||
} | ||
else if ((0, envConfig_1.needsEndUserSubdomain)(providerName, vertical)) { | ||
if (typeof baseUrl === 'string') { | ||
BASE_URL = baseUrl; | ||
} | ||
else { | ||
BASE_URL = baseUrl('END_USER_SUBDOMAIN'); | ||
} | ||
} | ||
else { | ||
BASE_URL = baseUrl; | ||
} | ||
if (!baseUrl || !BASE_URL) { | ||
throw new Error(`Unsupported provider: ${providerName}`); | ||
} | ||
let params = `client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodedRedirectUrl}&state=${state}`; | ||
if (scopes) { | ||
params += `&scope=${encodeURIComponent(scopes)}`; | ||
let params = `response_type=code&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodedRedirectUrl}&state=${state}`; | ||
if (providerName === 'helpscout') { | ||
params = `client_id=${encodeURIComponent(clientId)}&state=${state}`; | ||
} | ||
if (providerName === 'pipedrive') { | ||
params = `client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodedRedirectUrl}&state=${state}`; | ||
} | ||
if ((0, envConfig_1.needsScope)(providerName, vertical) && scopes) { | ||
if (providerName === 'slack') { | ||
params += `&scope=&user_scope=${encodeURIComponent(scopes)}`; | ||
} | ||
else { | ||
params += `&scope=${encodeURIComponent(scopes)}`; | ||
} | ||
} | ||
switch (providerName) { | ||
case 'zoho': | ||
params += '&response_type=code&access_type=offline'; | ||
params += '&access_type=offline'; | ||
break; | ||
case 'jira': | ||
params = `audience=api.atlassian.com&${params}&prompt=consent`; | ||
break; | ||
case 'jira_service_mgmt': | ||
@@ -82,9 +116,27 @@ params = `audience=api.atlassian.com&${params}&prompt=consent`; | ||
case 'gitlab': | ||
params += '&response_type=code&code_challenge=&code_challenge_method='; | ||
params += '&code_challenge=&code_challenge_method='; | ||
break; | ||
case 'gorgias': | ||
params = `&response_type=code&nonce=${(0, utils_1.randomString)()}`; | ||
params = `&nonce=${(0, utils_1.randomString)()}`; | ||
break; | ||
case 'googledrive': | ||
params = `${params}&access_type=offline`; | ||
break; | ||
case 'dropbox': | ||
params = `${params}&token_access_type=offline`; | ||
break; | ||
case 'basecamp': | ||
params += `&type=web_server`; | ||
break; | ||
case 'lever': | ||
params += `&audience=https://api.lever.co/v1/`; | ||
break; | ||
case 'notion': | ||
params += `&owner=user`; | ||
break; | ||
case 'klaviyo': | ||
params += `&code_challenge_method=S256&code_challenge=`; | ||
break; | ||
default: | ||
params += '&response_type=code'; | ||
break; | ||
} | ||
@@ -91,0 +143,0 @@ const finalAuthUrl = `${BASE_URL}?${params}`; |
@@ -8,4 +8,5 @@ export declare enum ConnectorCategory { | ||
MarketingAutomation = "marketingautomation", | ||
FileStorage = "filestorage" | ||
FileStorage = "filestorage", | ||
Management = "management" | ||
} | ||
export declare const categoriesVerticals: ConnectorCategory[]; |
@@ -13,3 +13,4 @@ "use strict"; | ||
ConnectorCategory["FileStorage"] = "filestorage"; | ||
ConnectorCategory["Management"] = "management"; | ||
})(ConnectorCategory || (exports.ConnectorCategory = ConnectorCategory = {})); | ||
exports.categoriesVerticals = Object.values(ConnectorCategory); |
@@ -6,3 +6,4 @@ export declare enum CrmConnectors { | ||
PIPEDRIVE = "pipedrive", | ||
ATTIO = "attio" | ||
ATTIO = "attio", | ||
CLOSE = "close" | ||
} | ||
@@ -12,7 +13,5 @@ export declare enum TicketingConnectors { | ||
FRONT = "front", | ||
GITHUB = "github", | ||
JIRA = "jira", | ||
GORGIAS = "gorgias", | ||
GITLAB = "gitlab", | ||
HUBSPOT = "hubspot" | ||
GITLAB = "gitlab" | ||
} | ||
@@ -19,0 +18,0 @@ export declare enum AccountingConnectors { |
@@ -11,2 +11,3 @@ "use strict"; | ||
CrmConnectors["ATTIO"] = "attio"; | ||
CrmConnectors["CLOSE"] = "close"; | ||
})(CrmConnectors || (exports.CrmConnectors = CrmConnectors = {})); | ||
@@ -17,7 +18,5 @@ var TicketingConnectors; | ||
TicketingConnectors["FRONT"] = "front"; | ||
TicketingConnectors["GITHUB"] = "github"; | ||
TicketingConnectors["JIRA"] = "jira"; | ||
TicketingConnectors["GORGIAS"] = "gorgias"; | ||
TicketingConnectors["GITLAB"] = "gitlab"; | ||
TicketingConnectors["HUBSPOT"] = "hubspot"; | ||
})(TicketingConnectors || (exports.TicketingConnectors = TicketingConnectors = {})); | ||
@@ -24,0 +23,0 @@ var AccountingConnectors; |
export declare const CRM_PROVIDERS: string[]; | ||
export declare const HRIS_PROVIDERS: string[]; | ||
export declare const ATS_PROVIDERS: string[]; | ||
export declare const ACCOUNTING_PROVIDERS: string[]; | ||
export declare const HRIS_PROVIDERS: any[]; | ||
export declare const ATS_PROVIDERS: any[]; | ||
export declare const ACCOUNTING_PROVIDERS: any[]; | ||
export declare const TICKETING_PROVIDERS: string[]; | ||
export declare const MARKETINGAUTOMATION_PROVIDERS: string[]; | ||
export declare const FILESTORAGE_PROVIDERS: string[]; | ||
export declare const MARKETINGAUTOMATION_PROVIDERS: any[]; | ||
export declare const FILESTORAGE_PROVIDERS: any[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FILESTORAGE_PROVIDERS = exports.MARKETINGAUTOMATION_PROVIDERS = exports.TICKETING_PROVIDERS = exports.ACCOUNTING_PROVIDERS = exports.ATS_PROVIDERS = exports.HRIS_PROVIDERS = exports.CRM_PROVIDERS = void 0; | ||
exports.CRM_PROVIDERS = ['zoho', 'zendesk', 'hubspot', 'pipedrive', 'attio']; | ||
exports.HRIS_PROVIDERS = ['']; | ||
exports.ATS_PROVIDERS = ['']; | ||
exports.ACCOUNTING_PROVIDERS = ['']; | ||
exports.TICKETING_PROVIDERS = ['zendesk', 'front', 'github', 'jira', 'gorgias', 'gitlab', 'hubspot']; | ||
exports.MARKETINGAUTOMATION_PROVIDERS = ['']; | ||
exports.FILESTORAGE_PROVIDERS = ['']; | ||
exports.CRM_PROVIDERS = ['zoho', 'zendesk', 'hubspot', 'pipedrive', 'attio', 'close']; | ||
exports.HRIS_PROVIDERS = []; | ||
exports.ATS_PROVIDERS = []; | ||
exports.ACCOUNTING_PROVIDERS = []; | ||
exports.TICKETING_PROVIDERS = ['zendesk', 'front', 'jira', 'gorgias', 'gitlab']; | ||
exports.MARKETINGAUTOMATION_PROVIDERS = []; | ||
exports.FILESTORAGE_PROVIDERS = []; |
@@ -24,1 +24,3 @@ import { AuthStrategy, SoftwareMode } from './types'; | ||
export declare function needsSubdomain(provider: string, vertical: string): boolean; | ||
export declare function needsScope(provider: string, vertical: string): boolean; | ||
export declare function needsEndUserSubdomain(provider: string, vertical: string): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.needsSubdomain = exports.extractAuthMode = exports.providerToType = exports.extractSoftwareMode = exports.extractVertical = exports.extractProvider = void 0; | ||
exports.needsEndUserSubdomain = exports.needsScope = exports.needsSubdomain = exports.extractAuthMode = exports.providerToType = exports.extractSoftwareMode = exports.extractVertical = exports.extractProvider = void 0; | ||
const metadata_1 = require("./connectors/metadata"); | ||
@@ -44,3 +44,3 @@ const types_1 = require("./types"); | ||
default: | ||
throw new Error('Auth mode not found'); | ||
throw new ReferenceError('Auth mode not found'); | ||
} | ||
@@ -59,7 +59,39 @@ } | ||
const providerConfig = metadata_1.CONNECTORS_METADATA[vertical][provider]; | ||
const authBaseUrlStartsWithSlash = providerConfig.urls.authBaseUrl.substring(0, 1) === '/'; | ||
const apiUrlStartsWithSlash = providerConfig.urls.apiUrl.substring(0, 1) === '/'; | ||
const apiUrlIsBlank = providerConfig.urls.apiUrl === ''; | ||
return authBaseUrlStartsWithSlash || apiUrlStartsWithSlash || apiUrlIsBlank; | ||
if (providerConfig.options && providerConfig.options.company_subdomain) { | ||
return providerConfig.options.company_subdomain; | ||
} | ||
return false; | ||
} | ||
exports.needsSubdomain = needsSubdomain; | ||
function needsScope(provider, vertical) { | ||
if (!metadata_1.CONNECTORS_METADATA[vertical]) { | ||
console.error(`Vertical ${vertical} not found in CONNECTORS_METADATA.`); | ||
return false; | ||
} | ||
if (!metadata_1.CONNECTORS_METADATA[vertical][provider]) { | ||
console.error(`Provider ${provider} not found under vertical ${vertical}.`); | ||
return false; | ||
} | ||
const providerConfig = metadata_1.CONNECTORS_METADATA[vertical][provider]; | ||
if (!providerConfig.scopes) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
exports.needsScope = needsScope; | ||
function needsEndUserSubdomain(provider, vertical) { | ||
if (!metadata_1.CONNECTORS_METADATA[vertical]) { | ||
console.error(`Vertical ${vertical} not found in CONNECTORS_METADATA.`); | ||
return false; | ||
} | ||
if (!metadata_1.CONNECTORS_METADATA[vertical][provider]) { | ||
console.error(`Provider ${provider} not found under vertical ${vertical}.`); | ||
return false; | ||
} | ||
const providerConfig = metadata_1.CONNECTORS_METADATA[vertical][provider]; | ||
if (providerConfig.options && providerConfig.options.end_user_domain) { | ||
return providerConfig.options.end_user_domain; | ||
} | ||
return false; | ||
} | ||
exports.needsEndUserSubdomain = needsEndUserSubdomain; |
@@ -6,5 +6,13 @@ export declare enum AuthStrategy { | ||
} | ||
export type AuthType = { | ||
strategy: AuthStrategy; | ||
properties?: string[]; | ||
}; | ||
export declare enum SoftwareMode { | ||
cloud = "CLOUD" | ||
} | ||
export type StringAuthorization = string; | ||
export type DynamicAuthorization = ((...args: string[]) => string); | ||
export type StaticApiUrl = string; | ||
export type DynamicApiUrl = ((...args: string[]) => string); | ||
export type ProviderConfig = { | ||
@@ -16,9 +24,18 @@ scopes?: string; | ||
customPropertiesUrl?: string; | ||
authStrategy?: AuthStrategy; | ||
authStrategy: AuthType; | ||
urls: { | ||
docsUrl: string; | ||
apiUrl: string; | ||
authBaseUrl?: string; | ||
apiUrl: StaticApiUrl | DynamicApiUrl; | ||
authBaseUrl?: StringAuthorization | DynamicAuthorization; | ||
customPropertiesUrl?: string; | ||
}; | ||
options?: { | ||
end_user_domain?: boolean; | ||
company_subdomain?: boolean; | ||
local_redirect_uri_in_https?: boolean; | ||
}; | ||
realTimeWebhookMetadata?: { | ||
method?: 'API' | 'MANUAL'; | ||
events?: string[]; | ||
}; | ||
}; | ||
@@ -25,0 +42,0 @@ export type VerticalConfig = { |
@@ -1,2 +0,2 @@ | ||
import { AuthStrategy } from './types'; | ||
import { AuthType, DynamicApiUrl, DynamicAuthorization, StaticApiUrl, StringAuthorization } from './types'; | ||
import { ConnectorCategory } from './categories'; | ||
@@ -10,4 +10,4 @@ export declare const randomString: () => string; | ||
docsUrl: string; | ||
apiUrl: string; | ||
authBaseUrl?: string | null; | ||
apiUrl: StaticApiUrl | DynamicApiUrl; | ||
authBaseUrl?: StringAuthorization | DynamicAuthorization; | ||
}; | ||
@@ -17,3 +17,3 @@ scopes?: string; | ||
description?: string; | ||
authStrategy?: AuthStrategy; | ||
authStrategy: AuthType; | ||
} | ||
@@ -32,3 +32,3 @@ export declare function providersArray(vertical?: string): Provider[]; | ||
}[]; | ||
export declare function slugFromCategory(category: ConnectorCategory): "crm" | "hris" | "ats" | "tcg" | "mktg" | "fstg" | "actng"; | ||
export declare function slugFromCategory(category: ConnectorCategory): "crm" | "hris" | "ats" | "tcg" | "mktg" | "fs" | "actng"; | ||
export declare function categoryFromSlug(slug: string): ConnectorCategory | null; |
@@ -55,3 +55,6 @@ "use strict"; | ||
description: config.description, | ||
authStrategy: config.authStrategy, | ||
authStrategy: { | ||
strategy: config.authStrategy.strategy, | ||
properties: config.authStrategy.properties ? config.authStrategy.properties : [], | ||
} | ||
})); | ||
@@ -74,3 +77,6 @@ } | ||
description: config.description, | ||
authStrategy: config.authStrategy, | ||
authStrategy: { | ||
strategy: config.authStrategy.strategy, | ||
properties: config.authStrategy.properties ? config.authStrategy.properties : [], | ||
} | ||
})); | ||
@@ -140,3 +146,3 @@ allProviders = allProviders.concat(providersForVertical); | ||
case categories_1.ConnectorCategory.FileStorage: | ||
return 'fstg'; | ||
return 'fs'; | ||
case categories_1.ConnectorCategory.Accounting: | ||
@@ -161,3 +167,3 @@ return 'actng'; | ||
return categories_1.ConnectorCategory.MarketingAutomation; | ||
case 'fstg': | ||
case 'fs': | ||
return categories_1.ConnectorCategory.FileStorage; | ||
@@ -164,0 +170,0 @@ case 'actng': |
{ | ||
"name": "@panora/shared", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Shared Package of Panora", | ||
@@ -5,0 +5,0 @@ "author": "Panora", |
Sorry, the diff of this file is too big to display
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
155228
3573
1