n8n-nodes-proofofauthenticity 1.0.4 → 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',
@@ -384,6 +396,64 @@ class ProofOfAuthenticity {
384
396
  default: 100,
385
397
  description: 'Maximum number of results to return',
386
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
+ },
387
457
  ],
388
458
  };
389
459
  }
@@ -513,6 +583,96 @@ class ProofOfAuthenticity {
513
583
  });
514
584
  responseData = response.data;
515
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
+ }
516
676
  // Return data
517
677
  returnData.push({
518
678
  json: responseData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-proofofauthenticity",
3
- "version": "1.0.4",
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
  },