n8n-nodes-idb2b 3.2.9 → 3.3.0

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.
@@ -1,8 +1,10 @@
1
- import { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import { ICredentialTestRequest, ICredentialType, INodeProperties, IHttpRequestOptions } from "n8n-workflow";
2
2
  export declare class IDB2BApi implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
5
5
  documentationUrl: string;
6
+ icon: "file:IDB2B.svg";
7
+ authenticate: (this: any, credentials: any, requestOptions: IHttpRequestOptions) => Promise<IHttpRequestOptions>;
6
8
  properties: INodeProperties[];
7
9
  test: ICredentialTestRequest;
8
10
  }
@@ -1,45 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IDB2BApi = void 0;
4
+ const httpClient_1 = require("../nodes/IDB2B/utils/httpClient");
4
5
  class IDB2BApi {
5
6
  constructor() {
6
- this.name = 'idb2bApi';
7
- this.displayName = 'IDB2B WhatsApp AI Agents';
8
- this.documentationUrl = 'https://idb2b.com/en';
7
+ this.name = "idb2bApi";
8
+ this.displayName = "IDB2B WhatsApp AI Agents";
9
+ this.documentationUrl = "https://idb2b.com/en";
10
+ this.icon = "file:IDB2B.svg";
11
+ this.authenticate = async function (credentials, requestOptions) {
12
+ const accessToken = await (0, httpClient_1.getAccessToken)(this, credentials);
13
+ requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), { Authorization: `Bearer ${accessToken}` });
14
+ return requestOptions;
15
+ };
9
16
  this.properties = [
10
17
  {
11
- displayName: 'Email',
12
- name: 'email',
13
- type: 'string',
14
- default: '',
18
+ displayName: "Email",
19
+ name: "email",
20
+ type: "string",
21
+ default: "",
15
22
  required: true,
16
- placeholder: 'your@email.com',
23
+ placeholder: "your@email.com",
17
24
  },
18
25
  {
19
- displayName: 'Password',
20
- name: 'password',
21
- type: 'string',
26
+ displayName: "Password",
27
+ name: "password",
28
+ type: "string",
22
29
  typeOptions: { password: true },
23
- default: '',
30
+ default: "",
24
31
  required: true,
25
32
  },
26
33
  {
27
- displayName: 'Base URL',
28
- name: 'baseUrl',
29
- type: 'string',
30
- default: 'https://api.idb2b.com',
34
+ displayName: "Base URL",
35
+ name: "baseUrl",
36
+ type: "string",
37
+ default: "https://api.idb2b.com",
31
38
  required: true,
32
- description: 'The IDB2B API base URL. Use https://api-stage.idb2b.com for staging environment.',
39
+ description: "The IDB2B API base URL. Use https://api-stage.idb2b.com for staging environment.",
33
40
  },
34
41
  ];
35
42
  this.test = {
36
43
  request: {
37
- baseURL: '={{$credentials.baseUrl}}',
38
- url: '/login',
39
- method: 'POST',
44
+ baseURL: "={{$credentials.baseUrl}}",
45
+ url: "/login",
46
+ method: "POST",
40
47
  body: {
41
- email: '={{$credentials.email}}',
42
- password: '={{$credentials.password}}',
48
+ email: "={{$credentials.email}}",
49
+ password: "={{$credentials.password}}",
43
50
  },
44
51
  },
45
52
  };
@@ -25,8 +25,8 @@ class IDB2B {
25
25
  defaults: {
26
26
  name: "IDB2B",
27
27
  },
28
- inputs: ["main"],
29
- outputs: ["main"],
28
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
29
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
30
30
  credentials: [
31
31
  {
32
32
  name: "idb2bApi",
@@ -78,7 +78,6 @@ class IDB2B {
78
78
  if (!credentialsValidation.isValid) {
79
79
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), credentialsValidation.error || "Invalid credentials");
80
80
  }
81
- const accessToken = await (0, httpClient_1.getAccessToken)(this, credentials);
82
81
  const httpClient = new httpClient_1.HttpClient(this);
83
82
  for (let i = 0; i < items.length; i++) {
84
83
  try {
@@ -190,7 +189,9 @@ class IDB2B {
190
189
  if (!subject || !subject.trim()) {
191
190
  throw new Error("Subject is required to create an activity");
192
191
  }
193
- const formPayload = { subject: subject.trim() };
192
+ const formPayload = {
193
+ subject: subject.trim(),
194
+ };
194
195
  if (associateWith === "company") {
195
196
  const companyId = this.getNodeParameter("activityCompanyId", i);
196
197
  endpoint = `/leads/${(0, common_1.sanitizeId)(companyId)}/activities`;
@@ -304,9 +305,7 @@ class IDB2B {
304
305
  endpoint = `${constants_1.ENDPOINTS.COMPANIES}/${(0, common_1.sanitizeId)(companyId)}`;
305
306
  }
306
307
  }
307
- const response = await httpClient.makeRequest(Object.assign(Object.assign({ method, url: `${credentials.baseUrl}${endpoint}`, headers: {
308
- Authorization: `Bearer ${accessToken}`,
309
- } }, (useFormData ? { formData: body } : { body })), { qs, json: true }));
308
+ const response = await httpClient.makeRequest(Object.assign(Object.assign({ method, url: `${credentials.baseUrl}${endpoint}` }, (useFormData ? { formData: body } : { body })), { qs, json: true }));
310
309
  let processedResponse = (0, common_1.processResponse)(response, operation, initialBody);
311
310
  // Apply field filtering for getAll operations
312
311
  if (operation === "getAll") {
@@ -344,7 +343,7 @@ class IDB2B {
344
343
  });
345
344
  continue;
346
345
  }
347
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
346
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
348
347
  itemIndex: i,
349
348
  });
350
349
  }
@@ -11,6 +11,7 @@ export interface RequestOptions {
11
11
  formData?: any;
12
12
  qs?: any;
13
13
  json?: boolean;
14
+ skipAuth?: boolean;
14
15
  }
15
16
  export interface HttpClientConfig {
16
17
  maxRetries: number;
@@ -28,7 +28,10 @@ class HttpClient {
28
28
  let lastError;
29
29
  for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
30
30
  try {
31
- return await this.executeFunctions.helpers.httpRequest(options);
31
+ if (options.skipAuth) {
32
+ return await this.executeFunctions.helpers.httpRequest(options);
33
+ }
34
+ return await this.executeFunctions.helpers.httpRequestWithAuthentication.call(this.executeFunctions, "idb2bApi", options);
32
35
  }
33
36
  catch (error) {
34
37
  lastError = error;
@@ -113,6 +116,7 @@ async function getAccessToken(executeFunctions, credentials) {
113
116
  password: credentials.password,
114
117
  },
115
118
  json: true,
119
+ skipAuth: true,
116
120
  });
117
121
  // Try to extract token from various possible response formats
118
122
  const accessToken = ((_b = (_a = loginResponse === null || loginResponse === void 0 ? void 0 : loginResponse.data) === null || _a === void 0 ? void 0 : _a.session) === null || _b === void 0 ? void 0 : _b.access_token) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-idb2b",
3
- "version": "3.2.9",
3
+ "version": "3.3.0",
4
4
  "description": "n8n community node for IDB2B - WhatsApp AI Agents",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -47,5 +47,8 @@
47
47
  },
48
48
  "peerDependencies": {
49
49
  "n8n-workflow": "*"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
50
53
  }
51
54
  }