mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Do not use url.includes to check for domain names (#13802)
This commit is contained in:
committed by
GitHub
parent
9d698edceb
commit
d3bc80c22b
@@ -104,8 +104,8 @@ export class LmChatOpenAi implements INodeType {
|
|||||||
properties: {
|
properties: {
|
||||||
// If the baseURL is not set or is set to api.openai.com, include only chat models
|
// If the baseURL is not set or is set to api.openai.com, include only chat models
|
||||||
pass: `={{
|
pass: `={{
|
||||||
($parameter.options?.baseURL && !$parameter.options?.baseURL?.includes('api.openai.com')) ||
|
($parameter.options?.baseURL && !$parameter.options?.baseURL?.startsWith('https://api.openai.com/')) ||
|
||||||
($credentials?.url && !$credentials.url.includes('api.openai.com')) ||
|
($credentials?.url && !$credentials.url.startsWith('https://api.openai.com/')) ||
|
||||||
$responseItem.id.startsWith('ft:') ||
|
$responseItem.id.startsWith('ft:') ||
|
||||||
$responseItem.id.startsWith('o1') ||
|
$responseItem.id.startsWith('o1') ||
|
||||||
$responseItem.id.startsWith('o3') ||
|
$responseItem.id.startsWith('o3') ||
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ export async function searchModels(
|
|||||||
const { data: models = [] } = await openai.models.list();
|
const { data: models = [] } = await openai.models.list();
|
||||||
|
|
||||||
const filteredModels = models.filter((model: { id: string }) => {
|
const filteredModels = models.filter((model: { id: string }) => {
|
||||||
|
const url = baseURL && new URL(baseURL);
|
||||||
const isValidModel =
|
const isValidModel =
|
||||||
(baseURL && !baseURL.includes('api.openai.com')) ||
|
(url && url.hostname !== 'api.openai.com') ||
|
||||||
model.id.startsWith('ft:') ||
|
model.id.startsWith('ft:') ||
|
||||||
model.id.startsWith('o1') ||
|
model.id.startsWith('o1') ||
|
||||||
model.id.startsWith('o3') ||
|
model.id.startsWith('o3') ||
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ export async function modelSearch(
|
|||||||
filter?: string,
|
filter?: string,
|
||||||
): Promise<INodeListSearchResult> {
|
): Promise<INodeListSearchResult> {
|
||||||
const credentials = await this.getCredentials<{ url: string }>('openAiApi');
|
const credentials = await this.getCredentials<{ url: string }>('openAiApi');
|
||||||
const isCustomAPI = credentials.url && !credentials.url.includes('api.openai.com');
|
const url = credentials.url && new URL(credentials.url);
|
||||||
|
const isCustomAPI = url && url.hostname !== 'api.openai.com';
|
||||||
|
|
||||||
return await getModelSearch(
|
return await getModelSearch(
|
||||||
(model) =>
|
(model) =>
|
||||||
|
|||||||
@@ -64,14 +64,14 @@ export class CustomerIoApi implements ICredentialType {
|
|||||||
requestOptions: IHttpRequestOptions,
|
requestOptions: IHttpRequestOptions,
|
||||||
): Promise<IHttpRequestOptions> {
|
): Promise<IHttpRequestOptions> {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
||||||
if (url.includes('track') || url.includes('api.customer.io')) {
|
if (url.hostname === 'track.customer.io' || url.hostname === 'api.customer.io') {
|
||||||
const basicAuthKey = Buffer.from(
|
const basicAuthKey = Buffer.from(
|
||||||
`${credentials.trackingSiteId}:${credentials.trackingApiKey}`,
|
`${credentials.trackingSiteId}:${credentials.trackingApiKey}`,
|
||||||
).toString('base64');
|
).toString('base64');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
Object.assign(requestOptions.headers, { Authorization: `Basic ${basicAuthKey}` });
|
Object.assign(requestOptions.headers, { Authorization: `Basic ${basicAuthKey}` });
|
||||||
} else if (url.includes('beta-api.customer.io')) {
|
} else if (url.hostname === 'beta-api.customer.io') {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
Object.assign(requestOptions.headers, {
|
Object.assign(requestOptions.headers, {
|
||||||
Authorization: `Bearer ${credentials.appApiKey as string}`,
|
Authorization: `Bearer ${credentials.appApiKey as string}`,
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export class MindeeInvoiceApi implements ICredentialType {
|
|||||||
requestOptions: IHttpRequestOptions,
|
requestOptions: IHttpRequestOptions,
|
||||||
): Promise<IHttpRequestOptions> {
|
): Promise<IHttpRequestOptions> {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
||||||
if (url.includes('https://api.mindee.net/v1/')) {
|
if (url.hostname === 'api.mindee.net' && url.pathname.startsWith('/v1/')) {
|
||||||
requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`;
|
requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`;
|
||||||
} else {
|
} else {
|
||||||
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export class MindeeReceiptApi implements ICredentialType {
|
|||||||
requestOptions: IHttpRequestOptions,
|
requestOptions: IHttpRequestOptions,
|
||||||
): Promise<IHttpRequestOptions> {
|
): Promise<IHttpRequestOptions> {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
||||||
if (url.includes('https://api.mindee.net/v1/')) {
|
if (url.hostname === 'api.mindee.net' && url.pathname.startsWith('/v1/')) {
|
||||||
requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`;
|
requestOptions.headers!.Authorization = `Token ${credentials.apiKey}`;
|
||||||
} else {
|
} else {
|
||||||
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
requestOptions.headers!['X-Inferuser-Token'] = `${credentials.apiKey}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user