n8n-nodes-agnicwallet 1.0.5 → 1.0.7

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.
@@ -5,134 +5,135 @@ const n8n_workflow_1 = require("n8n-workflow");
5
5
  class X402HttpRequest {
6
6
  constructor() {
7
7
  this.description = {
8
- displayName: 'AgnicWallet X402 Request',
9
- name: 'agnicWalletX402Request',
10
- group: ['transform'],
8
+ displayName: "AgnicWallet X402 Request",
9
+ name: "agnicWalletX402Request",
10
+ group: ["transform"],
11
11
  version: 1,
12
- description: 'Make HTTP requests to X402-enabled APIs with automatic payment via AgnicWallet',
12
+ description: "Make HTTP requests to X402-enabled APIs with automatic payment via AgnicWallet",
13
13
  defaults: {
14
- name: 'AgnicWallet X402',
14
+ name: "AgnicWallet X402",
15
15
  },
16
+ icon: "file:X402HttpRequest.png",
16
17
  usableAsTool: true,
17
- inputs: ['main'],
18
- outputs: ['main'],
18
+ inputs: ["main"],
19
+ outputs: ["main"],
19
20
  credentials: [
20
21
  {
21
- name: 'agnicWalletOAuth2Api',
22
+ name: "agnicWalletOAuth2Api",
22
23
  required: false,
23
24
  displayOptions: {
24
25
  show: {
25
- authentication: ['oAuth2'],
26
+ authentication: ["oAuth2"],
26
27
  },
27
28
  },
28
29
  },
29
30
  {
30
- name: 'agnicWalletApi',
31
+ name: "agnicWalletApi",
31
32
  required: false,
32
33
  displayOptions: {
33
34
  show: {
34
- authentication: ['apiKey'],
35
+ authentication: ["apiKey"],
35
36
  },
36
37
  },
37
38
  },
38
39
  ],
39
40
  properties: [
40
41
  {
41
- displayName: 'Authentication',
42
- name: 'authentication',
43
- type: 'options',
42
+ displayName: "Authentication",
43
+ name: "authentication",
44
+ type: "options",
44
45
  options: [
45
46
  {
46
- name: 'OAuth2',
47
- value: 'oAuth2',
48
- description: 'Recommended: Connect your account',
47
+ name: "OAuth2",
48
+ value: "oAuth2",
49
+ description: "Recommended: Connect your account",
49
50
  },
50
51
  {
51
- name: 'API Key',
52
- value: 'apiKey',
53
- description: 'For CI/CD or programmatic access',
52
+ name: "API Key",
53
+ value: "apiKey",
54
+ description: "For CI/CD or programmatic access",
54
55
  },
55
56
  ],
56
- default: 'oAuth2',
57
- description: 'How to authenticate with AgnicWallet',
57
+ default: "oAuth2",
58
+ description: "How to authenticate with AgnicWallet",
58
59
  },
59
60
  {
60
- displayName: 'Method',
61
- name: 'method',
62
- type: 'options',
61
+ displayName: "Method",
62
+ name: "method",
63
+ type: "options",
63
64
  options: [
64
65
  {
65
- name: 'GET',
66
- value: 'GET',
66
+ name: "GET",
67
+ value: "GET",
67
68
  },
68
69
  {
69
- name: 'POST',
70
- value: 'POST',
70
+ name: "POST",
71
+ value: "POST",
71
72
  },
72
73
  {
73
- name: 'PUT',
74
- value: 'PUT',
74
+ name: "PUT",
75
+ value: "PUT",
75
76
  },
76
77
  {
77
- name: 'DELETE',
78
- value: 'DELETE',
78
+ name: "DELETE",
79
+ value: "DELETE",
79
80
  },
80
81
  ],
81
- default: 'GET',
82
- description: 'The HTTP method to use',
82
+ default: "GET",
83
+ description: "The HTTP method to use",
83
84
  },
84
85
  {
85
- displayName: 'URL',
86
- name: 'url',
87
- type: 'string',
88
- default: '',
86
+ displayName: "URL",
87
+ name: "url",
88
+ type: "string",
89
+ default: "",
89
90
  required: true,
90
- placeholder: 'https://api.example.com/endpoint',
91
- description: 'The URL of the X402-enabled API',
91
+ placeholder: "https://api.example.com/endpoint",
92
+ description: "The URL of the X402-enabled API",
92
93
  },
93
94
  {
94
- displayName: 'Headers',
95
- name: 'headers',
96
- type: 'fixedCollection',
95
+ displayName: "Headers",
96
+ name: "headers",
97
+ type: "fixedCollection",
97
98
  typeOptions: {
98
99
  multipleValues: true,
99
100
  },
100
101
  default: {},
101
102
  options: [
102
103
  {
103
- name: 'header',
104
- displayName: 'Header',
104
+ name: "header",
105
+ displayName: "Header",
105
106
  values: [
106
107
  {
107
- displayName: 'Name',
108
- name: 'name',
109
- type: 'string',
110
- default: '',
111
- description: 'Name of the header',
108
+ displayName: "Name",
109
+ name: "name",
110
+ type: "string",
111
+ default: "",
112
+ description: "Name of the header",
112
113
  },
113
114
  {
114
- displayName: 'Value',
115
- name: 'value',
116
- type: 'string',
117
- default: '',
118
- description: 'Value of the header',
115
+ displayName: "Value",
116
+ name: "value",
117
+ type: "string",
118
+ default: "",
119
+ description: "Value of the header",
119
120
  },
120
121
  ],
121
122
  },
122
123
  ],
123
- description: 'Additional headers to send with the request',
124
+ description: "Additional headers to send with the request",
124
125
  },
125
126
  {
126
- displayName: 'Body',
127
- name: 'body',
128
- type: 'json',
129
- default: '{}',
127
+ displayName: "Body",
128
+ name: "body",
129
+ type: "json",
130
+ default: "{}",
130
131
  displayOptions: {
131
132
  show: {
132
- method: ['POST', 'PUT'],
133
+ method: ["POST", "PUT"],
133
134
  },
134
135
  },
135
- description: 'JSON body to send with the request',
136
+ description: "JSON body to send with the request",
136
137
  },
137
138
  ],
138
139
  };
@@ -143,31 +144,30 @@ class X402HttpRequest {
143
144
  for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
144
145
  try {
145
146
  // Get authentication type
146
- const authentication = this.getNodeParameter('authentication', itemIndex);
147
+ const authentication = this.getNodeParameter("authentication", itemIndex);
147
148
  let apiBaseUrl;
148
149
  let authHeader;
149
- // Use AgnicWallet backend API endpoint (production cloud by default)
150
- // Can override with AGNICWALLET_API_URL environment variable for local development
151
- apiBaseUrl = process.env.AGNICWALLET_API_URL || 'https://api.agnicpay.xyz';
152
- if (authentication === 'oAuth2') {
150
+ // Use AgnicWallet backend API endpoint (production cloud)
151
+ apiBaseUrl = "https://api.agnicpay.xyz";
152
+ if (authentication === "oAuth2") {
153
153
  // OAuth2 authentication
154
- const credentials = await this.getCredentials('agnicWalletOAuth2Api', itemIndex);
154
+ const credentials = (await this.getCredentials("agnicWalletOAuth2Api", itemIndex));
155
155
  authHeader = `Bearer ${credentials.oauthTokenData.access_token}`;
156
156
  }
157
157
  else {
158
158
  // API Key authentication
159
- const credentials = await this.getCredentials('agnicWalletApi', itemIndex);
159
+ const credentials = await this.getCredentials("agnicWalletApi", itemIndex);
160
160
  const { apiToken } = credentials;
161
161
  authHeader = apiToken;
162
162
  }
163
163
  // Get parameters
164
- const method = this.getNodeParameter('method', itemIndex);
165
- const url = this.getNodeParameter('url', itemIndex);
166
- const headersConfig = this.getNodeParameter('headers', itemIndex, {});
167
- const body = this.getNodeParameter('body', itemIndex, '{}');
164
+ const method = this.getNodeParameter("method", itemIndex);
165
+ const url = this.getNodeParameter("url", itemIndex);
166
+ const headersConfig = this.getNodeParameter("headers", itemIndex, {});
167
+ const body = this.getNodeParameter("body", itemIndex, "{}");
168
168
  // Build headers
169
169
  const headers = {
170
- 'Content-Type': 'application/json',
170
+ "Content-Type": "application/json",
171
171
  };
172
172
  if (headersConfig.header) {
173
173
  headersConfig.header.forEach((h) => {
@@ -179,10 +179,12 @@ class X402HttpRequest {
179
179
  url,
180
180
  method,
181
181
  headers,
182
- body: method === 'POST' || method === 'PUT' ? JSON.parse(body) : undefined,
182
+ body: method === "POST" || method === "PUT"
183
+ ? JSON.parse(body)
184
+ : undefined,
183
185
  agnicWalletApi: apiBaseUrl,
184
186
  authHeader,
185
- isOAuth: authentication === 'oAuth2',
187
+ isOAuth: authentication === "oAuth2",
186
188
  });
187
189
  returnData.push({
188
190
  json: response,
@@ -192,7 +194,7 @@ class X402HttpRequest {
192
194
  });
193
195
  }
194
196
  catch (error) {
195
- const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
197
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
196
198
  if (this.continueOnFail()) {
197
199
  returnData.push({
198
200
  json: {
@@ -227,7 +229,7 @@ async function makeX402Request(context, config) {
227
229
  context.logger.info(`Response status: ${response.status}`);
228
230
  // 2. If 402 Payment Required, use AgnicWallet to sign
229
231
  if (response.status === 402) {
230
- context.logger.info('402 Payment Required detected, parsing payment requirements...');
232
+ context.logger.info("402 Payment Required detected, parsing payment requirements...");
231
233
  // Get response text first for debugging
232
234
  const responseText = await response.text();
233
235
  context.logger.info(`Payment requirements response: ${responseText}`);
@@ -236,25 +238,25 @@ async function makeX402Request(context, config) {
236
238
  paymentRequirements = JSON.parse(responseText);
237
239
  }
238
240
  catch (parseError) {
239
- throw new Error(`Failed to parse payment requirements: ${parseError instanceof Error ? parseError.message : 'Unknown error'}. Response: ${responseText}`);
241
+ throw new Error(`Failed to parse payment requirements: ${parseError instanceof Error ? parseError.message : "Unknown error"}. Response: ${responseText}`);
240
242
  }
241
243
  context.logger.info(`Payment required: ${JSON.stringify(paymentRequirements)}`);
242
244
  // 3. Call AgnicWallet signing API
243
245
  context.logger.info(`Calling AgnicWallet API at: ${agnicWalletApi}/api/sign-payment`);
244
246
  // Build auth headers based on auth type
245
247
  const authHeaders = {
246
- 'Content-Type': 'application/json',
248
+ "Content-Type": "application/json",
247
249
  };
248
250
  if (isOAuth) {
249
251
  // OAuth: Use Authorization header with Bearer token
250
- authHeaders['Authorization'] = authHeader;
252
+ authHeaders["Authorization"] = authHeader;
251
253
  }
252
254
  else {
253
255
  // API Key: Use X-Agnic-Token header
254
- authHeaders['X-Agnic-Token'] = authHeader;
256
+ authHeaders["X-Agnic-Token"] = authHeader;
255
257
  }
256
258
  const signingResponse = await fetch(`${agnicWalletApi}/api/sign-payment`, {
257
- method: 'POST',
259
+ method: "POST",
258
260
  headers: authHeaders,
259
261
  body: JSON.stringify({
260
262
  paymentRequirements,
@@ -266,18 +268,18 @@ async function makeX402Request(context, config) {
266
268
  context.logger.error(`AgnicWallet signing failed: ${errorText}`);
267
269
  throw new Error(`Payment signing failed (${signingResponse.status}): ${errorText}`);
268
270
  }
269
- const signingResult = await signingResponse.json();
271
+ const signingResult = (await signingResponse.json());
270
272
  const { paymentHeader, amountPaid } = signingResult;
271
273
  context.logger.info(`Payment signed successfully: $${amountPaid}`);
272
274
  context.logger.info(`Payment header (Base64): ${paymentHeader}`);
273
275
  // 4. Retry original request with payment header
274
276
  // The paymentHeader is already Base64-encoded and X402-compliant
275
- context.logger.info('Retrying request with X402 payment header...');
277
+ context.logger.info("Retrying request with X402 payment header...");
276
278
  response = await fetch(url, {
277
279
  method,
278
280
  headers: {
279
281
  ...headers,
280
- 'X-PAYMENT': paymentHeader,
282
+ "X-PAYMENT": paymentHeader,
281
283
  },
282
284
  body: body ? JSON.stringify(body) : undefined,
283
285
  });
@@ -296,7 +298,7 @@ async function makeX402Request(context, config) {
296
298
  result = { data: resultText };
297
299
  }
298
300
  return {
299
- ...(typeof result === 'object' && result !== null ? result : {}),
301
+ ...(typeof result === "object" && result !== null ? result : {}),
300
302
  _agnicWallet: {
301
303
  paymentMade: true,
302
304
  amountPaid,
@@ -319,7 +321,7 @@ async function makeX402Request(context, config) {
319
321
  }
320
322
  }
321
323
  catch (error) {
322
- context.logger.error(`Error in makeX402Request: ${error instanceof Error ? error.message : 'Unknown error'}`);
324
+ context.logger.error(`Error in makeX402Request: ${error instanceof Error ? error.message : "Unknown error"}`);
323
325
  throw error;
324
326
  }
325
327
  }
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
3
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
5
+ width="44.000000pt" height="45.000000pt" viewBox="0 0 44.000000 45.000000"
6
+ preserveAspectRatio="xMidYMid meet">
7
+
8
+ <g transform="translate(0.000000,45.000000) scale(0.100000,-0.100000)"
9
+ fill="#000000" stroke="none">
10
+ <path d="M175 380 l-39 -40 42 -43 42 -42 42 42 42 43 -39 40 c-21 22 -42 40
11
+ -45 40 -3 0 -24 -18 -45 -40z"/>
12
+ <path d="M55 260 l-39 -40 42 -43 42 -42 42 42 42 43 -39 40 c-21 22 -42 40
13
+ -45 40 -3 0 -24 -18 -45 -40z"/>
14
+ <path d="M295 260 l-39 -40 42 -43 42 -42 42 42 42 43 -39 40 c-21 22 -42 40
15
+ -45 40 -3 0 -24 -18 -45 -40z"/>
16
+ <path d="M175 140 l-39 -40 42 -43 42 -42 42 42 42 43 -39 40 c-21 22 -42 40
17
+ -45 40 -3 0 -24 -18 -45 -40z"/>
18
+ </g>
19
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-agnicwallet",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "n8n community node for AgnicWallet - automated Web3 payments for X402 APIs",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -15,7 +15,10 @@
15
15
  "automation",
16
16
  "workflow",
17
17
  "base",
18
- "solana"
18
+ "solana",
19
+ "mcp",
20
+ "model-context-protocol",
21
+ "ai-agent"
19
22
  ],
20
23
  "license": "MIT",
21
24
  "homepage": "https://github.com/agnicpay/n8n-X402-AgnicWallet#readme",
@@ -35,10 +38,8 @@
35
38
  "build": "tsc && gulp build:icons",
36
39
  "dev": "tsc --watch",
37
40
  "format": "prettier nodes credentials --write",
38
- "lint": "tslint -p tsconfig.json -c tslint.json",
39
- "lintfix": "tslint --fix -p tsconfig.json -c tslint.json",
40
- "prepublishOnly": "npm run build",
41
- "test": "jest"
41
+ "format:check": "prettier nodes credentials --check",
42
+ "prepublishOnly": "npm run build"
42
43
  },
43
44
  "files": [
44
45
  "dist"
@@ -50,21 +51,33 @@
50
51
  "dist/credentials/AgnicWalletOAuth2Api.credentials.js"
51
52
  ],
52
53
  "nodes": [
53
- "dist/nodes/X402HttpRequest/X402HttpRequest.node.js"
54
+ "dist/nodes/X402HttpRequest/X402HttpRequest.node.js",
55
+ "dist/nodes/AgnicAILanguageModel/AgnicAILanguageModel.node.js",
56
+ "dist/nodes/AgnicAI/AgnicAI.node.js",
57
+ "dist/nodes/AgnicMCPTool/AgnicMCPTool.node.js"
54
58
  ]
55
59
  },
60
+ "dependencies": {
61
+ "@modelcontextprotocol/sdk": "^1.24.0",
62
+ "@n8n/json-schema-to-zod": "^1.6.0",
63
+ "zod": "^3.23.0"
64
+ },
56
65
  "devDependencies": {
66
+ "@langchain/core": "^0.3.68",
67
+ "@langchain/openai": "^0.6.16",
57
68
  "@types/node": "^20.10.0",
69
+ "langchain": "^0.3.33",
58
70
  "@typescript-eslint/parser": "^6.13.0",
59
71
  "eslint": "^8.54.0",
60
72
  "eslint-plugin-n8n-nodes-base": "^1.16.1",
61
73
  "gulp": "^4.0.2",
62
74
  "n8n-workflow": "^1.40.0",
63
75
  "prettier": "^3.1.0",
64
- "tslint": "^5.20.1",
65
76
  "typescript": "^5.3.0"
66
77
  },
67
78
  "peerDependencies": {
79
+ "@langchain/core": "*",
80
+ "langchain": "*",
68
81
  "n8n-workflow": "*"
69
82
  }
70
83
  }