2023-01-27 03:22:44 -08:00
|
|
|
import type { ICredentialType, IDisplayOptions, INodeProperties } from 'n8n-workflow';
|
2020-09-01 08:40:18 -07:00
|
|
|
|
|
|
|
export class Mqtt implements ICredentialType {
|
|
|
|
name = 'mqtt';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2020-09-01 08:40:18 -07:00
|
|
|
displayName = 'MQTT';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2020-09-14 04:06:28 -07:00
|
|
|
documentationUrl = 'mqtt';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2020-09-01 08:40:18 -07:00
|
|
|
{
|
|
|
|
displayName: 'Protocol',
|
|
|
|
name: 'protocol',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'options',
|
2020-10-01 05:01:39 -07:00
|
|
|
options: [
|
2020-09-01 08:40:18 -07:00
|
|
|
{
|
2022-04-13 23:32:27 -07:00
|
|
|
name: 'Mqtt',
|
2020-09-01 08:40:18 -07:00
|
|
|
value: 'mqtt',
|
|
|
|
},
|
2021-06-25 01:27:06 -07:00
|
|
|
{
|
2022-04-13 23:32:27 -07:00
|
|
|
name: 'Mqtts',
|
2021-06-25 01:27:06 -07:00
|
|
|
value: 'mqtts',
|
|
|
|
},
|
2020-09-01 08:40:18 -07:00
|
|
|
{
|
2022-04-13 23:32:27 -07:00
|
|
|
name: 'Ws',
|
2020-09-01 08:40:18 -07:00
|
|
|
value: 'ws',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'mqtt',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Host',
|
|
|
|
name: 'host',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-09-01 08:40:18 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Port',
|
|
|
|
name: 'port',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'number',
|
2020-09-01 08:40:18 -07:00
|
|
|
default: 1883,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Username',
|
|
|
|
name: 'username',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-09-01 08:40:18 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Password',
|
|
|
|
name: 'password',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-09-01 08:40:18 -07:00
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
},
|
2021-04-30 18:23:25 -07:00
|
|
|
{
|
|
|
|
displayName: 'Clean Session',
|
|
|
|
name: 'clean',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'boolean',
|
2021-04-30 18:23:25 -07:00
|
|
|
default: true,
|
2022-07-24 08:36:17 -07:00
|
|
|
description:
|
|
|
|
'Whether to use clean session - set to false to receive QoS 1 and 2 messages while offline',
|
2021-04-30 18:23:25 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Client ID',
|
|
|
|
name: 'clientId',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2021-04-30 18:23:25 -07:00
|
|
|
default: '',
|
2022-04-13 23:32:27 -07:00
|
|
|
description: 'Client ID. If left empty, one is autogenerated for you.',
|
2021-04-30 18:23:25 -07:00
|
|
|
},
|
2021-09-03 05:37:19 -07:00
|
|
|
{
|
|
|
|
displayName: 'SSL',
|
|
|
|
name: 'ssl',
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Passwordless',
|
|
|
|
name: 'passwordless',
|
|
|
|
type: 'boolean',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-07-24 08:36:17 -07:00
|
|
|
ssl: [true],
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: true,
|
2022-07-24 08:36:17 -07:00
|
|
|
description:
|
|
|
|
'Whether to use passwordless connection with certificates (SASL mechanism EXTERNAL)',
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'CA Certificates',
|
|
|
|
name: 'ca',
|
|
|
|
type: 'string',
|
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-07-24 08:36:17 -07:00
|
|
|
ssl: [true],
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: '',
|
2022-04-13 23:32:27 -07:00
|
|
|
description: 'SSL CA Certificates to use',
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Reject Unauthorized Certificate',
|
|
|
|
name: 'rejectUnauthorized',
|
2022-04-13 23:32:27 -07:00
|
|
|
type: 'boolean',
|
2021-09-03 05:37:19 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-07-24 08:36:17 -07:00
|
|
|
ssl: [true],
|
|
|
|
passwordless: [true],
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
} as IDisplayOptions,
|
2022-04-13 23:32:27 -07:00
|
|
|
default: false,
|
|
|
|
description: 'Whether to validate Certificate',
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Client Certificate',
|
|
|
|
name: 'cert',
|
|
|
|
type: 'string',
|
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-07-24 08:36:17 -07:00
|
|
|
ssl: [true],
|
|
|
|
passwordless: [true],
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
} as IDisplayOptions,
|
|
|
|
default: '',
|
2022-04-13 23:32:27 -07:00
|
|
|
description: 'SSL Client Certificate to use',
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Client Key',
|
|
|
|
name: 'key',
|
|
|
|
type: 'string',
|
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2022-07-24 08:36:17 -07:00
|
|
|
ssl: [true],
|
|
|
|
passwordless: [true],
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
default: '',
|
2022-04-13 23:32:27 -07:00
|
|
|
description: 'SSL Client Key to use',
|
2021-09-03 05:37:19 -07:00
|
|
|
},
|
2020-09-01 08:40:18 -07:00
|
|
|
];
|
|
|
|
}
|