n8n-nodes-openpgp 0.0.1 → 0.2.1
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.
- package/README.md +1 -4
- package/dist/credentials/OpenPgpPrivateKeyApi.credentials.d.ts +8 -0
- package/dist/credentials/OpenPgpPrivateKeyApi.credentials.js +39 -0
- package/dist/credentials/OpenPgpPrivateKeyApi.credentials.js.map +1 -0
- package/dist/credentials/openPgpPrivateKeyApi.svg +6 -0
- package/dist/nodes/OpenPgp/OpenPgp.node.d.ts +10 -0
- package/dist/nodes/OpenPgp/OpenPgp.node.js +683 -0
- package/dist/nodes/OpenPgp/OpenPgp.node.js.map +1 -0
- package/dist/nodes/OpenPgp/helpers.d.ts +76 -0
- package/dist/nodes/OpenPgp/helpers.js +290 -0
- package/dist/nodes/OpenPgp/helpers.js.map +1 -0
- package/dist/nodes/OpenPgp/openPgp.svg +5 -0
- package/dist/nodes/OpenPgp/operations.d.ts +5 -0
- package/dist/nodes/OpenPgp/operations.js +236 -0
- package/dist/nodes/OpenPgp/operations.js.map +1 -0
- package/dist/package.json +77 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +75 -9
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.OpenPgp = void 0;
|
|
37
|
+
const openpgp = __importStar(require("openpgp"));
|
|
38
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
39
|
+
const helpers_1 = require("./helpers");
|
|
40
|
+
const operations_1 = require("./operations");
|
|
41
|
+
const OPERATIONS = { decrypt: operations_1.decrypt, encrypt: operations_1.encrypt, sign: operations_1.sign, verify: operations_1.verify };
|
|
42
|
+
const ARMORED_KEY_HINT = 'Copy the key from its BEGIN line through its END line. Binary key files must be exported as armored text first';
|
|
43
|
+
const armorOutputOption = (description, displayOptions) => ({
|
|
44
|
+
displayName: 'Armor Output',
|
|
45
|
+
name: 'armorOutput',
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: true,
|
|
48
|
+
description,
|
|
49
|
+
...(displayOptions ? { displayOptions } : {}),
|
|
50
|
+
});
|
|
51
|
+
const compressionOption = {
|
|
52
|
+
displayName: 'Compression',
|
|
53
|
+
name: 'compression',
|
|
54
|
+
type: 'options',
|
|
55
|
+
default: 'none',
|
|
56
|
+
description: 'The compression algorithm applied to the message before it is encrypted. With public keys the recipients must support the chosen algorithm, otherwise the message is left uncompressed.',
|
|
57
|
+
options: [
|
|
58
|
+
{ name: 'None', value: 'none' },
|
|
59
|
+
{ name: 'ZIP', value: 'zip' },
|
|
60
|
+
{ name: 'ZLIB', value: 'zlib' },
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
const hideRecipientsOption = (displayOptions) => ({
|
|
64
|
+
displayName: 'Hide Recipients',
|
|
65
|
+
name: 'hideRecipients',
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
default: false,
|
|
68
|
+
description: 'Whether to encrypt without recording the recipient key IDs in the message',
|
|
69
|
+
...(displayOptions ? { displayOptions } : {}),
|
|
70
|
+
});
|
|
71
|
+
const legacyCompatibilityOption = {
|
|
72
|
+
displayName: 'Legacy Compatibility',
|
|
73
|
+
name: 'legacyCompatibility',
|
|
74
|
+
type: 'boolean',
|
|
75
|
+
default: false,
|
|
76
|
+
description: 'Whether to accept legacy OpenPGP material that modern defaults reject: keys without usage flags, v5 entities, and v4 keys AEAD-encrypted by OpenPGP.js v5. The last case is only correct for keys that OpenPGP.js v5 encrypted.',
|
|
77
|
+
};
|
|
78
|
+
const optionsProperty = (operation, items) => ({
|
|
79
|
+
displayName: 'Options',
|
|
80
|
+
name: 'options',
|
|
81
|
+
type: 'collection',
|
|
82
|
+
placeholder: 'Add option',
|
|
83
|
+
default: {},
|
|
84
|
+
displayOptions: { show: { operation: [operation] } },
|
|
85
|
+
options: items,
|
|
86
|
+
});
|
|
87
|
+
class OpenPgp {
|
|
88
|
+
constructor() {
|
|
89
|
+
this.description = {
|
|
90
|
+
displayName: 'OpenPGP',
|
|
91
|
+
name: 'openPgp',
|
|
92
|
+
icon: 'file:openPgp.svg',
|
|
93
|
+
group: ['transform'],
|
|
94
|
+
version: 1,
|
|
95
|
+
subtitle: '={{ $parameter["operation"] }}',
|
|
96
|
+
description: 'Encrypt, decrypt, sign, and verify data with OpenPGP — key-based or password-based',
|
|
97
|
+
defaults: {
|
|
98
|
+
name: 'OpenPGP',
|
|
99
|
+
},
|
|
100
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
101
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
102
|
+
usableAsTool: true,
|
|
103
|
+
credentials: [
|
|
104
|
+
{
|
|
105
|
+
name: 'openPgpPrivateKeyApi',
|
|
106
|
+
required: false,
|
|
107
|
+
testedBy: 'openPgpPrivateKeyTest',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
properties: [
|
|
111
|
+
{
|
|
112
|
+
displayName: 'Operation',
|
|
113
|
+
name: 'operation',
|
|
114
|
+
type: 'options',
|
|
115
|
+
noDataExpression: true,
|
|
116
|
+
default: 'encrypt',
|
|
117
|
+
options: [
|
|
118
|
+
{
|
|
119
|
+
name: 'Decrypt',
|
|
120
|
+
value: 'decrypt',
|
|
121
|
+
action: 'Decrypt data',
|
|
122
|
+
description: 'Decrypt a message with a private key or password',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'Encrypt',
|
|
126
|
+
value: 'encrypt',
|
|
127
|
+
action: 'Encrypt data',
|
|
128
|
+
description: 'Encrypt data with a public key or password',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'Sign',
|
|
132
|
+
value: 'sign',
|
|
133
|
+
action: 'Sign data',
|
|
134
|
+
description: 'Sign data with a private key',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'Verify',
|
|
138
|
+
value: 'verify',
|
|
139
|
+
action: 'Verify a signature',
|
|
140
|
+
description: 'Verify a signature with a public key',
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
displayName: 'Source Data',
|
|
146
|
+
name: 'sourceData',
|
|
147
|
+
type: 'options',
|
|
148
|
+
default: 'binary',
|
|
149
|
+
description: 'Where the data to encrypt comes from',
|
|
150
|
+
displayOptions: { show: { operation: ['encrypt'] } },
|
|
151
|
+
options: [
|
|
152
|
+
{ name: 'Text', value: 'text' },
|
|
153
|
+
{ name: 'Binary', value: 'binary' },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
displayName: 'Text to Encrypt',
|
|
158
|
+
name: 'textToEncrypt',
|
|
159
|
+
type: 'string',
|
|
160
|
+
typeOptions: { rows: 4 },
|
|
161
|
+
default: '',
|
|
162
|
+
required: true,
|
|
163
|
+
description: 'The inline text to encrypt, taken exactly as typed',
|
|
164
|
+
displayOptions: { show: { operation: ['encrypt'], sourceData: ['text'] } },
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
displayName: 'Input Binary Field',
|
|
168
|
+
name: 'binaryPropertyName',
|
|
169
|
+
type: 'string',
|
|
170
|
+
default: 'data',
|
|
171
|
+
required: true,
|
|
172
|
+
placeholder: 'e.g. data',
|
|
173
|
+
hint: 'The name of the binary field holding the file to encrypt',
|
|
174
|
+
description: 'The file name of the input file is embedded in the encrypted message',
|
|
175
|
+
displayOptions: { show: { operation: ['encrypt'], sourceData: ['binary'] } },
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
displayName: 'Encrypt Using',
|
|
179
|
+
name: 'encryptUsing',
|
|
180
|
+
type: 'options',
|
|
181
|
+
default: 'publicKeys',
|
|
182
|
+
description: 'How the data is encrypted: for one or more public keys, or with a shared password',
|
|
183
|
+
displayOptions: { show: { operation: ['encrypt'] } },
|
|
184
|
+
options: [
|
|
185
|
+
{ name: 'Public Keys', value: 'publicKeys' },
|
|
186
|
+
{ name: 'Password', value: 'password' },
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
displayName: 'Public Key(s)',
|
|
191
|
+
name: 'publicKeys',
|
|
192
|
+
type: 'string',
|
|
193
|
+
typeOptions: { rows: 6 },
|
|
194
|
+
default: '',
|
|
195
|
+
required: true,
|
|
196
|
+
placeholder: 'e.g. -----BEGIN PGP PUBLIC KEY BLOCK-----',
|
|
197
|
+
hint: ARMORED_KEY_HINT,
|
|
198
|
+
description: 'One or more armored public keys to encrypt for, one recipient per key',
|
|
199
|
+
displayOptions: { show: { operation: ['encrypt'], encryptUsing: ['publicKeys'] } },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
displayName: 'Password',
|
|
203
|
+
name: 'password',
|
|
204
|
+
type: 'string',
|
|
205
|
+
typeOptions: { password: true },
|
|
206
|
+
default: '',
|
|
207
|
+
required: true,
|
|
208
|
+
placeholder: 'e.g. the shared password',
|
|
209
|
+
description: 'The shared password the message is encrypted with',
|
|
210
|
+
displayOptions: { show: { operation: ['encrypt'], encryptUsing: ['password'] } },
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Also Sign',
|
|
214
|
+
name: 'alsoSign',
|
|
215
|
+
type: 'boolean',
|
|
216
|
+
default: false,
|
|
217
|
+
description: "Whether to sign the message with the credential's private key as well. Works with both public keys and a password.",
|
|
218
|
+
displayOptions: { show: { operation: ['encrypt'] } },
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
displayName: 'Output As',
|
|
222
|
+
name: 'outputAs',
|
|
223
|
+
type: 'options',
|
|
224
|
+
default: 'binary',
|
|
225
|
+
description: 'Where the encrypted result is written: a text field or a binary field',
|
|
226
|
+
displayOptions: { show: { operation: ['encrypt'] } },
|
|
227
|
+
options: [
|
|
228
|
+
{ name: 'Text', value: 'text' },
|
|
229
|
+
{ name: 'Binary', value: 'binary' },
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
displayName: 'Output Field Name',
|
|
234
|
+
name: 'outputFieldName',
|
|
235
|
+
type: 'string',
|
|
236
|
+
default: 'data',
|
|
237
|
+
placeholder: 'e.g. data',
|
|
238
|
+
description: 'The name of the field to write the armored result to',
|
|
239
|
+
displayOptions: { show: { operation: ['encrypt'], outputAs: ['text'] } },
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
displayName: 'Put Output File in Field',
|
|
243
|
+
name: 'outputBinaryFieldName',
|
|
244
|
+
type: 'string',
|
|
245
|
+
default: 'data',
|
|
246
|
+
placeholder: 'e.g. data',
|
|
247
|
+
hint: 'The name of the binary field to write the encrypted file to',
|
|
248
|
+
description: 'The output file is named after the input file, with an .asc or .pgp suffix',
|
|
249
|
+
displayOptions: { show: { operation: ['encrypt'], outputAs: ['binary'] } },
|
|
250
|
+
},
|
|
251
|
+
optionsProperty('encrypt', [
|
|
252
|
+
armorOutputOption('Whether to write armored output instead of raw OpenPGP packets', {
|
|
253
|
+
show: { '/outputAs': ['binary'] },
|
|
254
|
+
}),
|
|
255
|
+
compressionOption,
|
|
256
|
+
hideRecipientsOption({ show: { '/encryptUsing': ['publicKeys'] } }),
|
|
257
|
+
legacyCompatibilityOption,
|
|
258
|
+
]),
|
|
259
|
+
{
|
|
260
|
+
displayName: 'Source Data',
|
|
261
|
+
name: 'sourceData',
|
|
262
|
+
type: 'options',
|
|
263
|
+
default: 'binary',
|
|
264
|
+
description: 'Where the message to decrypt comes from',
|
|
265
|
+
displayOptions: { show: { operation: ['decrypt'] } },
|
|
266
|
+
options: [
|
|
267
|
+
{ name: 'Text', value: 'text' },
|
|
268
|
+
{ name: 'Binary', value: 'binary' },
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
displayName: 'Text to Decrypt',
|
|
273
|
+
name: 'textToDecrypt',
|
|
274
|
+
type: 'string',
|
|
275
|
+
typeOptions: { rows: 4 },
|
|
276
|
+
default: '',
|
|
277
|
+
required: true,
|
|
278
|
+
description: 'The armored message to decrypt',
|
|
279
|
+
displayOptions: { show: { operation: ['decrypt'], sourceData: ['text'] } },
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Input Binary Field',
|
|
283
|
+
name: 'binaryPropertyName',
|
|
284
|
+
type: 'string',
|
|
285
|
+
default: 'data',
|
|
286
|
+
required: true,
|
|
287
|
+
placeholder: 'e.g. data',
|
|
288
|
+
hint: 'The name of the binary field holding the message to decrypt',
|
|
289
|
+
description: 'Armored and binary messages are both accepted',
|
|
290
|
+
displayOptions: { show: { operation: ['decrypt'], sourceData: ['binary'] } },
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
displayName: 'Decrypt Using',
|
|
294
|
+
name: 'decryptUsing',
|
|
295
|
+
type: 'options',
|
|
296
|
+
default: 'privateKey',
|
|
297
|
+
description: 'How the message is decrypted: with the credential private key, or with a shared password',
|
|
298
|
+
displayOptions: { show: { operation: ['decrypt'] } },
|
|
299
|
+
options: [
|
|
300
|
+
{ name: 'Private Key (Credential)', value: 'privateKey' },
|
|
301
|
+
{ name: 'Password', value: 'password' },
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
displayName: 'Password',
|
|
306
|
+
name: 'password',
|
|
307
|
+
type: 'string',
|
|
308
|
+
typeOptions: { password: true },
|
|
309
|
+
default: '',
|
|
310
|
+
required: true,
|
|
311
|
+
placeholder: 'e.g. the shared password',
|
|
312
|
+
description: 'The shared password the message was encrypted with',
|
|
313
|
+
displayOptions: { show: { operation: ['decrypt'], decryptUsing: ['password'] } },
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
displayName: 'Public Key(s)',
|
|
317
|
+
name: 'publicKeys',
|
|
318
|
+
type: 'string',
|
|
319
|
+
typeOptions: { rows: 6 },
|
|
320
|
+
default: '',
|
|
321
|
+
placeholder: 'e.g. -----BEGIN PGP PUBLIC KEY BLOCK-----',
|
|
322
|
+
hint: ARMORED_KEY_HINT,
|
|
323
|
+
description: 'One or more armored public keys to verify the message signature with',
|
|
324
|
+
displayOptions: { show: { operation: ['decrypt'] } },
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
displayName: 'Require Valid Signature',
|
|
328
|
+
name: 'requireValidSignature',
|
|
329
|
+
type: 'boolean',
|
|
330
|
+
default: false,
|
|
331
|
+
description: 'Whether to fail instead of returning data when the message is not signed by one of the provided Public Key(s)',
|
|
332
|
+
displayOptions: { show: { operation: ['decrypt'] } },
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
displayName: 'Output As',
|
|
336
|
+
name: 'outputAs',
|
|
337
|
+
type: 'options',
|
|
338
|
+
default: 'binary',
|
|
339
|
+
description: 'Where the decrypted result is written: a text field or a binary field',
|
|
340
|
+
displayOptions: { show: { operation: ['decrypt'] } },
|
|
341
|
+
options: [
|
|
342
|
+
{ name: 'Text', value: 'text' },
|
|
343
|
+
{ name: 'Binary', value: 'binary' },
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
displayName: 'Output Field Name',
|
|
348
|
+
name: 'outputFieldName',
|
|
349
|
+
type: 'string',
|
|
350
|
+
default: 'data',
|
|
351
|
+
placeholder: 'e.g. data',
|
|
352
|
+
description: 'The name of the field to write the decrypted text to',
|
|
353
|
+
displayOptions: { show: { operation: ['decrypt'], outputAs: ['text'] } },
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
displayName: 'Put Output File in Field',
|
|
357
|
+
name: 'outputBinaryFieldName',
|
|
358
|
+
type: 'string',
|
|
359
|
+
default: 'data',
|
|
360
|
+
placeholder: 'e.g. data',
|
|
361
|
+
hint: 'The name of the binary field to write the decrypted file to',
|
|
362
|
+
description: 'The output file is named after the name embedded in the message',
|
|
363
|
+
displayOptions: { show: { operation: ['decrypt'], outputAs: ['binary'] } },
|
|
364
|
+
},
|
|
365
|
+
optionsProperty('decrypt', [legacyCompatibilityOption]),
|
|
366
|
+
{
|
|
367
|
+
displayName: 'Signature Type',
|
|
368
|
+
name: 'signatureType',
|
|
369
|
+
type: 'options',
|
|
370
|
+
default: 'detached',
|
|
371
|
+
description: 'The kind of signature to create: detached, cleartext or inline',
|
|
372
|
+
displayOptions: { show: { operation: ['sign'] } },
|
|
373
|
+
options: [
|
|
374
|
+
{ name: 'Detached', value: 'detached' },
|
|
375
|
+
{ name: 'Cleartext', value: 'cleartext' },
|
|
376
|
+
{ name: 'Inline', value: 'inline' },
|
|
377
|
+
],
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
displayName: 'Source Data',
|
|
381
|
+
name: 'sourceData',
|
|
382
|
+
type: 'options',
|
|
383
|
+
default: 'binary',
|
|
384
|
+
description: 'Where the data to sign comes from',
|
|
385
|
+
displayOptions: { show: { operation: ['sign'], signatureType: ['detached', 'inline'] } },
|
|
386
|
+
options: [
|
|
387
|
+
{ name: 'Text', value: 'text' },
|
|
388
|
+
{ name: 'Binary', value: 'binary' },
|
|
389
|
+
],
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
displayName: 'Text to Sign',
|
|
393
|
+
name: 'textToSign',
|
|
394
|
+
type: 'string',
|
|
395
|
+
typeOptions: { rows: 4 },
|
|
396
|
+
default: '',
|
|
397
|
+
required: true,
|
|
398
|
+
description: 'The text to sign in place, which stays readable in the output',
|
|
399
|
+
displayOptions: { show: { operation: ['sign'], signatureType: ['cleartext'] } },
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
displayName: 'Text to Sign',
|
|
403
|
+
name: 'textToSign',
|
|
404
|
+
type: 'string',
|
|
405
|
+
typeOptions: { rows: 4 },
|
|
406
|
+
default: '',
|
|
407
|
+
required: true,
|
|
408
|
+
description: 'The inline text to sign',
|
|
409
|
+
displayOptions: {
|
|
410
|
+
show: { operation: ['sign'], signatureType: ['detached', 'inline'], sourceData: ['text'] },
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
displayName: 'Input Binary Field',
|
|
415
|
+
name: 'binaryPropertyName',
|
|
416
|
+
type: 'string',
|
|
417
|
+
default: 'data',
|
|
418
|
+
required: true,
|
|
419
|
+
placeholder: 'e.g. data',
|
|
420
|
+
hint: 'The name of the binary field holding the file to sign',
|
|
421
|
+
description: 'The file name of the input file is embedded in an inline signed message',
|
|
422
|
+
displayOptions: {
|
|
423
|
+
show: { operation: ['sign'], signatureType: ['detached', 'inline'], sourceData: ['binary'] },
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
displayName: 'Output As',
|
|
428
|
+
name: 'outputAs',
|
|
429
|
+
type: 'options',
|
|
430
|
+
default: 'text',
|
|
431
|
+
description: 'Where the signature is written: a text field or a binary field',
|
|
432
|
+
displayOptions: { show: { operation: ['sign'], signatureType: ['detached', 'inline'] } },
|
|
433
|
+
options: [
|
|
434
|
+
{ name: 'Text', value: 'text' },
|
|
435
|
+
{ name: 'Binary', value: 'binary' },
|
|
436
|
+
],
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
displayName: 'Output Field Name',
|
|
440
|
+
name: 'outputFieldName',
|
|
441
|
+
type: 'string',
|
|
442
|
+
default: 'data',
|
|
443
|
+
placeholder: 'e.g. data',
|
|
444
|
+
description: 'The name of the field to write the signature to',
|
|
445
|
+
displayOptions: { show: { operation: ['sign'], signatureType: ['cleartext'] } },
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
displayName: 'Output Field Name',
|
|
449
|
+
name: 'outputFieldName',
|
|
450
|
+
type: 'string',
|
|
451
|
+
default: 'data',
|
|
452
|
+
placeholder: 'e.g. data',
|
|
453
|
+
description: 'The name of the field to write the signature to',
|
|
454
|
+
displayOptions: {
|
|
455
|
+
show: { operation: ['sign'], signatureType: ['detached', 'inline'], outputAs: ['text'] },
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
displayName: 'Put Output File in Field',
|
|
460
|
+
name: 'outputBinaryFieldName',
|
|
461
|
+
type: 'string',
|
|
462
|
+
default: 'data',
|
|
463
|
+
placeholder: 'e.g. data',
|
|
464
|
+
hint: 'The name of the binary field to write the signature to',
|
|
465
|
+
description: 'The output file is named after the input file, with a .sig, .asc or .pgp suffix',
|
|
466
|
+
displayOptions: { show: { operation: ['sign'], signatureType: ['detached', 'inline'], outputAs: ['binary'] } },
|
|
467
|
+
},
|
|
468
|
+
optionsProperty('sign', [
|
|
469
|
+
armorOutputOption('Whether to write an armored signature instead of raw OpenPGP packets', {
|
|
470
|
+
show: { '/signatureType': ['detached', 'inline'], '/outputAs': ['binary'] },
|
|
471
|
+
}),
|
|
472
|
+
legacyCompatibilityOption,
|
|
473
|
+
]),
|
|
474
|
+
{
|
|
475
|
+
displayName: 'Signature Type',
|
|
476
|
+
name: 'signatureType',
|
|
477
|
+
type: 'options',
|
|
478
|
+
default: 'detached',
|
|
479
|
+
description: 'Whether the signature travels separately from the message, or is embedded in it',
|
|
480
|
+
displayOptions: { show: { operation: ['verify'] } },
|
|
481
|
+
options: [
|
|
482
|
+
{ name: 'Detached', value: 'detached' },
|
|
483
|
+
{ name: 'Embedded', value: 'embedded' },
|
|
484
|
+
],
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
displayName: 'Message Source',
|
|
488
|
+
name: 'messageSource',
|
|
489
|
+
type: 'options',
|
|
490
|
+
default: 'binary',
|
|
491
|
+
description: 'Where the signed message comes from',
|
|
492
|
+
displayOptions: { show: { operation: ['verify'], signatureType: ['detached'] } },
|
|
493
|
+
options: [
|
|
494
|
+
{ name: 'Text', value: 'text' },
|
|
495
|
+
{ name: 'Binary', value: 'binary' },
|
|
496
|
+
],
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
displayName: 'Message Text',
|
|
500
|
+
name: 'messageText',
|
|
501
|
+
type: 'string',
|
|
502
|
+
typeOptions: { rows: 4 },
|
|
503
|
+
default: '',
|
|
504
|
+
required: true,
|
|
505
|
+
description: 'The text the signature was created for',
|
|
506
|
+
displayOptions: {
|
|
507
|
+
show: { operation: ['verify'], signatureType: ['detached'], messageSource: ['text'] },
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
displayName: 'Input Binary Field',
|
|
512
|
+
name: 'messageBinaryPropertyName',
|
|
513
|
+
type: 'string',
|
|
514
|
+
default: 'data',
|
|
515
|
+
required: true,
|
|
516
|
+
placeholder: 'e.g. data',
|
|
517
|
+
hint: 'The name of the binary field holding the message the signature was created for',
|
|
518
|
+
description: 'The exact bytes of the message are verified, so use the unmodified file',
|
|
519
|
+
displayOptions: {
|
|
520
|
+
show: { operation: ['verify'], signatureType: ['detached'], messageSource: ['binary'] },
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
displayName: 'Signature Source',
|
|
525
|
+
name: 'signatureSource',
|
|
526
|
+
type: 'options',
|
|
527
|
+
default: 'text',
|
|
528
|
+
description: 'Where the detached signature comes from',
|
|
529
|
+
displayOptions: { show: { operation: ['verify'], signatureType: ['detached'] } },
|
|
530
|
+
options: [
|
|
531
|
+
{ name: 'Text', value: 'text' },
|
|
532
|
+
{ name: 'Binary', value: 'binary' },
|
|
533
|
+
],
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
displayName: 'Signature Text',
|
|
537
|
+
name: 'signatureText',
|
|
538
|
+
type: 'string',
|
|
539
|
+
typeOptions: { rows: 4 },
|
|
540
|
+
default: '',
|
|
541
|
+
required: true,
|
|
542
|
+
description: 'The armored detached signature to verify',
|
|
543
|
+
displayOptions: {
|
|
544
|
+
show: { operation: ['verify'], signatureType: ['detached'], signatureSource: ['text'] },
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
displayName: 'Input Binary Field',
|
|
549
|
+
name: 'signatureBinaryPropertyName',
|
|
550
|
+
type: 'string',
|
|
551
|
+
default: 'data',
|
|
552
|
+
required: true,
|
|
553
|
+
placeholder: 'e.g. data',
|
|
554
|
+
hint: 'The name of the binary field holding the detached signature',
|
|
555
|
+
description: 'Armored and binary signatures are both accepted',
|
|
556
|
+
displayOptions: {
|
|
557
|
+
show: { operation: ['verify'], signatureType: ['detached'], signatureSource: ['binary'] },
|
|
558
|
+
},
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
displayName: 'Source Data',
|
|
562
|
+
name: 'sourceData',
|
|
563
|
+
type: 'options',
|
|
564
|
+
default: 'binary',
|
|
565
|
+
description: 'Where the signed message comes from',
|
|
566
|
+
displayOptions: { show: { operation: ['verify'], signatureType: ['embedded'] } },
|
|
567
|
+
options: [
|
|
568
|
+
{ name: 'Text', value: 'text' },
|
|
569
|
+
{ name: 'Binary', value: 'binary' },
|
|
570
|
+
],
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
displayName: 'Message Text',
|
|
574
|
+
name: 'messageText',
|
|
575
|
+
type: 'string',
|
|
576
|
+
typeOptions: { rows: 4 },
|
|
577
|
+
default: '',
|
|
578
|
+
required: true,
|
|
579
|
+
description: 'The signed message, either a cleartext signature or an armored signed message',
|
|
580
|
+
displayOptions: {
|
|
581
|
+
show: { operation: ['verify'], signatureType: ['embedded'], sourceData: ['text'] },
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
displayName: 'Input Binary Field',
|
|
586
|
+
name: 'messageBinaryPropertyName',
|
|
587
|
+
type: 'string',
|
|
588
|
+
default: 'data',
|
|
589
|
+
required: true,
|
|
590
|
+
placeholder: 'e.g. data',
|
|
591
|
+
hint: 'The name of the binary field holding the signed message',
|
|
592
|
+
description: 'Armored and binary signed messages are both accepted',
|
|
593
|
+
displayOptions: {
|
|
594
|
+
show: { operation: ['verify'], signatureType: ['embedded'], sourceData: ['binary'] },
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
displayName: 'Public Key(s)',
|
|
599
|
+
name: 'publicKeys',
|
|
600
|
+
type: 'string',
|
|
601
|
+
typeOptions: { rows: 6 },
|
|
602
|
+
default: '',
|
|
603
|
+
required: true,
|
|
604
|
+
placeholder: 'e.g. -----BEGIN PGP PUBLIC KEY BLOCK-----',
|
|
605
|
+
hint: ARMORED_KEY_HINT,
|
|
606
|
+
description: 'One or more armored public keys to verify the signature with',
|
|
607
|
+
displayOptions: { show: { operation: ['verify'] } },
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
displayName: 'Throw on Invalid Signature',
|
|
611
|
+
name: 'throwOnInvalidSignature',
|
|
612
|
+
type: 'boolean',
|
|
613
|
+
default: true,
|
|
614
|
+
description: 'Whether to fail when the signature does not verify against the provided Public Key(s). Turn this off to branch on the verified field instead.',
|
|
615
|
+
displayOptions: { show: { operation: ['verify'] } },
|
|
616
|
+
},
|
|
617
|
+
optionsProperty('verify', [legacyCompatibilityOption]),
|
|
618
|
+
],
|
|
619
|
+
};
|
|
620
|
+
this.methods = {
|
|
621
|
+
credentialTest: {
|
|
622
|
+
async openPgpPrivateKeyTest(credential) {
|
|
623
|
+
const { privateKey, passphrase } = credential.data;
|
|
624
|
+
const config = (0, helpers_1.buildConfig)({});
|
|
625
|
+
try {
|
|
626
|
+
const blocks = (0, helpers_1.splitArmoredBlocks)(String(privateKey !== null && privateKey !== void 0 ? privateKey : ''));
|
|
627
|
+
if (blocks.length === 0) {
|
|
628
|
+
return { status: 'Error', message: 'No private key was provided' };
|
|
629
|
+
}
|
|
630
|
+
const keys = [];
|
|
631
|
+
for (const block of blocks) {
|
|
632
|
+
keys.push(...(await openpgp.readKeys({ armoredKeys: block, config })));
|
|
633
|
+
}
|
|
634
|
+
const privateKeys = keys.filter((key) => key.isPrivate());
|
|
635
|
+
if (privateKeys.length === 0) {
|
|
636
|
+
return {
|
|
637
|
+
status: 'Error',
|
|
638
|
+
message: 'The provided key block does not contain a private key',
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
for (const key of privateKeys) {
|
|
642
|
+
if (!key.isDecrypted()) {
|
|
643
|
+
await openpgp.decryptKey({ privateKey: key, passphrase: passphrase !== null && passphrase !== void 0 ? passphrase : '', config });
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
status: 'OK',
|
|
648
|
+
message: `Private key is usable (key ID ${privateKeys[0].getKeyID().toHex()})`,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
catch (error) {
|
|
652
|
+
return { status: 'Error', message: error.message };
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
async execute() {
|
|
659
|
+
var _a;
|
|
660
|
+
const items = this.getInputData();
|
|
661
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
662
|
+
const returnItems = [];
|
|
663
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
664
|
+
try {
|
|
665
|
+
returnItems.push(await OPERATIONS[operation](this, itemIndex));
|
|
666
|
+
}
|
|
667
|
+
catch (error) {
|
|
668
|
+
const message = `${error.message} [Item ${itemIndex}]`;
|
|
669
|
+
if (this.continueOnFail()) {
|
|
670
|
+
returnItems.push({ json: { error: message }, pairedItem: { item: itemIndex } });
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), message, {
|
|
674
|
+
itemIndex,
|
|
675
|
+
description: (_a = error.description) !== null && _a !== void 0 ? _a : undefined,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
return [returnItems];
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
exports.OpenPgp = OpenPgp;
|
|
683
|
+
//# sourceMappingURL=OpenPgp.node.js.map
|