n8n-nodes-a2a-protocol
Version:
Agent2Agent (A2A) Protocol nodes for n8n - Enable agent interoperability, communication, and MCP integration
195 lines (194 loc) • 6.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.A2AApi = void 0;
class A2AApi {
constructor() {
this.name = 'a2aApi';
this.displayName = 'Agent2Agent API';
this.documentationUrl = 'a2a';
this.icon = 'file:a2a.svg';
this.properties = [
{
displayName: 'Authentication Method',
name: 'authMethod',
type: 'options',
options: [
{
name: 'Bearer Token',
value: 'bearer',
},
{
name: 'API Key',
value: 'apiKey',
},
{
name: 'OAuth 2.0',
value: 'oauth2',
},
{
name: 'Basic Auth',
value: 'basic',
},
],
default: 'bearer',
description: 'Choose the authentication method for A2A protocol',
},
{
displayName: 'Bearer Token',
name: 'bearerToken',
type: 'string',
typeOptions: { password: true },
displayOptions: {
show: {
authMethod: ['bearer'],
},
},
default: '',
required: true,
description: 'Bearer token for A2A authentication',
},
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: { password: true },
displayOptions: {
show: {
authMethod: ['apiKey'],
},
},
default: '',
required: true,
description: 'API key for A2A authentication',
},
{
displayName: 'API Key Header Name',
name: 'apiKeyHeaderName',
type: 'string',
displayOptions: {
show: {
authMethod: ['apiKey'],
},
},
default: 'X-API-Key',
description: 'Header name for the API key',
},
{
displayName: 'Username',
name: 'username',
type: 'string',
displayOptions: {
show: {
authMethod: ['basic'],
},
},
default: '',
required: true,
description: 'Username for basic authentication',
},
{
displayName: 'Password',
name: 'password',
type: 'string',
typeOptions: { password: true },
displayOptions: {
show: {
authMethod: ['basic'],
},
},
default: '',
required: true,
description: 'Password for basic authentication',
},
{
displayName: 'Client ID',
name: 'clientId',
type: 'string',
displayOptions: {
show: {
authMethod: ['oauth2'],
},
},
default: '',
required: true,
description: 'OAuth 2.0 client ID',
},
{
displayName: 'Client Secret',
name: 'clientSecret',
type: 'string',
typeOptions: { password: true },
displayOptions: {
show: {
authMethod: ['oauth2'],
},
},
default: '',
required: true,
description: 'OAuth 2.0 client secret',
},
{
displayName: 'Token URL',
name: 'tokenUrl',
type: 'string',
displayOptions: {
show: {
authMethod: ['oauth2'],
},
},
default: '',
required: true,
description: 'OAuth 2.0 token endpoint URL',
},
{
displayName: 'Scope',
name: 'scope',
type: 'string',
displayOptions: {
show: {
authMethod: ['oauth2'],
},
},
default: '',
description: 'OAuth 2.0 scope (optional)',
},
];
this.authenticate = {
type: 'generic',
properties: {
headers: {
'Authorization': {
'@if': {
'condition': '={{$credentials.authMethod === "bearer"}}',
'true': '=Bearer {{$credentials.bearerToken}}',
'false': {
'@if': {
'condition': '={{$credentials.authMethod === "basic"}}',
'true': '=Basic {{Buffer.from($credentials.username + ":" + $credentials.password).toString("base64")}}',
'false': undefined,
},
},
},
},
'={{$credentials.apiKeyHeaderName || "X-API-Key"}}': {
'@if': {
'condition': '={{$credentials.authMethod === "apiKey"}}',
'true': '={{$credentials.apiKey}}',
'false': undefined,
},
},
},
},
};
this.test = {
request: {
baseURL: 'https://a2a-registry.googleapis.com',
url: '/health',
headers: {
'A2A-Version': '1.0',
},
},
};
}
}
exports.A2AApi = A2AApi;