n8n-nodes-proofofauthenticity 1.0.3 → 1.0.5

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.
@@ -181,6 +181,18 @@ class ProofOfAuthenticity {
181
181
  description: 'Create blockchain certificate with optional AI analysis and C2PA',
182
182
  action: 'Create certificate',
183
183
  },
184
+ {
185
+ name: 'Download C2PA File',
186
+ value: 'downloadC2paFile',
187
+ description: 'Download the C2PA signed image file as binary',
188
+ action: 'Download C2PA file',
189
+ },
190
+ {
191
+ name: 'Download PDF Certificate',
192
+ value: 'downloadPdfCertificate',
193
+ description: 'Download the PDF certificate as binary',
194
+ action: 'Download PDF certificate',
195
+ },
184
196
  {
185
197
  name: 'List Certificates',
186
198
  value: 'listCertificates',
@@ -230,6 +242,11 @@ class ProofOfAuthenticity {
230
242
  },
231
243
  },
232
244
  options: [
245
+ {
246
+ name: 'Binary (from previous node)',
247
+ value: 'binary',
248
+ description: 'Use binary data from previous node (e.g., Form Trigger)',
249
+ },
233
250
  {
234
251
  name: 'URL',
235
252
  value: 'url',
@@ -241,9 +258,23 @@ class ProofOfAuthenticity {
241
258
  description: 'File content as base64 encoded string',
242
259
  },
243
260
  ],
244
- default: 'url',
261
+ default: 'binary',
245
262
  description: 'How to provide the file content',
246
263
  },
264
+ {
265
+ displayName: 'Binary Property',
266
+ name: 'binaryPropertyName',
267
+ type: 'string',
268
+ displayOptions: {
269
+ show: {
270
+ operation: ['createCertificate'],
271
+ inputType: ['binary'],
272
+ },
273
+ },
274
+ default: 'data',
275
+ placeholder: 'data',
276
+ description: 'Name of the binary property containing the file (default: "data" for Form Trigger)',
277
+ },
247
278
  {
248
279
  displayName: 'File URL',
249
280
  name: 'fileUrl',
@@ -365,6 +396,64 @@ class ProofOfAuthenticity {
365
396
  default: 100,
366
397
  description: 'Maximum number of results to return',
367
398
  },
399
+ // ============================================
400
+ // DOWNLOAD C2PA FILE PARAMETERS
401
+ // ============================================
402
+ {
403
+ displayName: 'C2PA Download URL',
404
+ name: 'c2paDownloadUrl',
405
+ type: 'string',
406
+ displayOptions: {
407
+ show: {
408
+ operation: ['downloadC2paFile'],
409
+ },
410
+ },
411
+ default: '',
412
+ required: true,
413
+ placeholder: '/api/c2pa/download/abc123',
414
+ description: 'The c2pa_download_url returned by createCertificate (AI mode). Will be appended to DigiCryptoStore URL.',
415
+ },
416
+ {
417
+ displayName: 'Binary Property Name',
418
+ name: 'c2paBinaryProperty',
419
+ type: 'string',
420
+ displayOptions: {
421
+ show: {
422
+ operation: ['downloadC2paFile'],
423
+ },
424
+ },
425
+ default: 'c2pa_file',
426
+ description: 'Name of the binary property to store the downloaded C2PA file',
427
+ },
428
+ // ============================================
429
+ // DOWNLOAD PDF CERTIFICATE PARAMETERS
430
+ // ============================================
431
+ {
432
+ displayName: 'C2PA File ID',
433
+ name: 'c2paFileId',
434
+ type: 'string',
435
+ displayOptions: {
436
+ show: {
437
+ operation: ['downloadPdfCertificate'],
438
+ },
439
+ },
440
+ default: '',
441
+ required: true,
442
+ placeholder: 'abc123-def456-ghi789',
443
+ description: 'The c2pa_file_id returned by createCertificate (AI mode)',
444
+ },
445
+ {
446
+ displayName: 'Binary Property Name',
447
+ name: 'pdfBinaryProperty',
448
+ type: 'string',
449
+ displayOptions: {
450
+ show: {
451
+ operation: ['downloadPdfCertificate'],
452
+ },
453
+ },
454
+ default: 'pdf_certificate',
455
+ description: 'Name of the binary property to store the downloaded PDF certificate',
456
+ },
368
457
  ],
369
458
  };
370
459
  }
@@ -392,7 +481,16 @@ class ProofOfAuthenticity {
392
481
  // Map certification mode to API parameters
393
482
  const usageType = certificationMode === 'simple' ? 'simple' : 'ai';
394
483
  let fileData;
395
- if (inputType === 'url') {
484
+ if (inputType === 'binary') {
485
+ // Read binary data from previous node (e.g., Form Trigger)
486
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i, 'data');
487
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
488
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
489
+ const mimeType = binaryData.mimeType || 'application/octet-stream';
490
+ const base64Data = buffer.toString('base64');
491
+ fileData = `data:${mimeType};base64,${base64Data}`;
492
+ }
493
+ else if (inputType === 'url') {
396
494
  const fileUrl = this.getNodeParameter('fileUrl', i);
397
495
  // Validate URL to prevent SSRF
398
496
  validateUrl(fileUrl);
@@ -485,6 +583,96 @@ class ProofOfAuthenticity {
485
583
  });
486
584
  responseData = response.data;
487
585
  }
586
+ // ============================================
587
+ // DOWNLOAD C2PA FILE OPERATION
588
+ // ============================================
589
+ else if (operation === 'downloadC2paFile') {
590
+ const c2paDownloadUrl = this.getNodeParameter('c2paDownloadUrl', i);
591
+ const binaryPropertyName = this.getNodeParameter('c2paBinaryProperty', i, 'c2pa_file');
592
+ // Build full URL: baseUrl + c2paDownloadUrl
593
+ const fullUrl = c2paDownloadUrl.startsWith('http')
594
+ ? c2paDownloadUrl
595
+ : `${baseUrl}${c2paDownloadUrl.startsWith('/') ? '' : '/'}${c2paDownloadUrl}`;
596
+ const response = await axios_1.default.get(fullUrl, {
597
+ timeout: DOWNLOAD_TIMEOUT,
598
+ responseType: 'arraybuffer',
599
+ maxContentLength: MAX_FILE_SIZE,
600
+ maxBodyLength: MAX_FILE_SIZE,
601
+ headers: {
602
+ 'Authorization': `Bearer ${apiKey}`,
603
+ },
604
+ ...getAxiosConfig(baseUrl),
605
+ });
606
+ const contentType = response.headers['content-type'] || 'image/jpeg';
607
+ const contentDisposition = response.headers['content-disposition'] || '';
608
+ let fileName = 'c2pa_file';
609
+ // Extract filename from Content-Disposition header if available
610
+ const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
611
+ if (filenameMatch && filenameMatch[1]) {
612
+ fileName = filenameMatch[1].replace(/['"]/g, '');
613
+ }
614
+ else {
615
+ // Generate filename based on content type
616
+ const ext = contentType.split('/')[1] || 'jpg';
617
+ fileName = `c2pa_file.${ext}`;
618
+ }
619
+ const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.data), fileName, contentType);
620
+ returnData.push({
621
+ json: {
622
+ success: true,
623
+ fileName,
624
+ mimeType: contentType,
625
+ fileSize: response.data.byteLength,
626
+ },
627
+ binary: {
628
+ [binaryPropertyName]: binaryData,
629
+ },
630
+ pairedItem: { item: i },
631
+ });
632
+ continue;
633
+ }
634
+ // ============================================
635
+ // DOWNLOAD PDF CERTIFICATE OPERATION
636
+ // ============================================
637
+ else if (operation === 'downloadPdfCertificate') {
638
+ const c2paFileId = this.getNodeParameter('c2paFileId', i);
639
+ const binaryPropertyName = this.getNodeParameter('pdfBinaryProperty', i, 'pdf_certificate');
640
+ // Build PDF download URL
641
+ const pdfUrl = `${baseUrl}/api/c2pa/certificate/${c2paFileId}/pdf`;
642
+ const response = await axios_1.default.get(pdfUrl, {
643
+ timeout: DOWNLOAD_TIMEOUT,
644
+ responseType: 'arraybuffer',
645
+ maxContentLength: MAX_FILE_SIZE,
646
+ maxBodyLength: MAX_FILE_SIZE,
647
+ headers: {
648
+ 'Authorization': `Bearer ${apiKey}`,
649
+ },
650
+ ...getAxiosConfig(baseUrl),
651
+ });
652
+ const contentType = response.headers['content-type'] || 'application/pdf';
653
+ const contentDisposition = response.headers['content-disposition'] || '';
654
+ let fileName = `certificate_${c2paFileId}.pdf`;
655
+ // Extract filename from Content-Disposition header if available
656
+ const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
657
+ if (filenameMatch && filenameMatch[1]) {
658
+ fileName = filenameMatch[1].replace(/['"]/g, '');
659
+ }
660
+ const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.data), fileName, contentType);
661
+ returnData.push({
662
+ json: {
663
+ success: true,
664
+ fileName,
665
+ mimeType: contentType,
666
+ fileSize: response.data.byteLength,
667
+ c2paFileId,
668
+ },
669
+ binary: {
670
+ [binaryPropertyName]: binaryData,
671
+ },
672
+ pairedItem: { item: i },
673
+ });
674
+ continue;
675
+ }
488
676
  // Return data
489
677
  returnData.push({
490
678
  json: responseData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-proofofauthenticity",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "ProofOfAuthenticity by CHECKHC - Blockchain timestamping with AI detection and C2PA content authenticity.",
5
5
  "keywords": [
6
6
  "n8n",
@@ -49,7 +49,7 @@
49
49
  "@types/node": "^20.0.0",
50
50
  "eslint": "^8.0.0",
51
51
  "gulp": "^4.0.2",
52
- "n8n-workflow": "^1.0.0",
52
+ "n8n-workflow": "^2.2.2",
53
53
  "prettier": "^3.0.0",
54
54
  "typescript": "^5.0.0"
55
55
  },