n8n-nodes-proofofauthenticity 1.0.4 → 1.0.6

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 Create Certificate (AI mode)',
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 Create Certificate (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,91 @@ 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
+ const fullUrl = c2paDownloadUrl.startsWith('http')
593
+ ? c2paDownloadUrl
594
+ : `${baseUrl}${c2paDownloadUrl.startsWith('/') ? '' : '/'}${c2paDownloadUrl}`;
595
+ const response = await axios_1.default.get(fullUrl, {
596
+ timeout: DOWNLOAD_TIMEOUT,
597
+ responseType: 'arraybuffer',
598
+ maxContentLength: MAX_FILE_SIZE,
599
+ maxBodyLength: MAX_FILE_SIZE,
600
+ headers: {
601
+ 'Authorization': `Bearer ${apiKey}`,
602
+ },
603
+ ...getAxiosConfig(baseUrl),
604
+ });
605
+ const contentType = response.headers['content-type'] || 'image/jpeg';
606
+ const contentDisposition = response.headers['content-disposition'] || '';
607
+ let fileName = 'c2pa_file';
608
+ const filenameMatch = contentDisposition.match(/filename[^;=\n]*=(['"]?)([^'"\n;]*)['"]?/);
609
+ if (filenameMatch && filenameMatch[2]) {
610
+ fileName = filenameMatch[2];
611
+ }
612
+ else {
613
+ const ext = contentType.split('/')[1] || 'jpg';
614
+ fileName = `c2pa_file.${ext}`;
615
+ }
616
+ const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.data), fileName, contentType);
617
+ returnData.push({
618
+ json: {
619
+ success: true,
620
+ fileName,
621
+ mimeType: contentType,
622
+ fileSize: response.data.byteLength,
623
+ },
624
+ binary: {
625
+ [binaryPropertyName]: binaryData,
626
+ },
627
+ pairedItem: { item: i },
628
+ });
629
+ continue;
630
+ }
631
+ // ============================================
632
+ // DOWNLOAD PDF CERTIFICATE OPERATION
633
+ // ============================================
634
+ else if (operation === 'downloadPdfCertificate') {
635
+ const c2paFileId = this.getNodeParameter('c2paFileId', i);
636
+ const binaryPropertyName = this.getNodeParameter('pdfBinaryProperty', i, 'pdf_certificate');
637
+ const pdfUrl = `${baseUrl}/api/c2pa/certificate/${c2paFileId}/pdf`;
638
+ const response = await axios_1.default.get(pdfUrl, {
639
+ timeout: DOWNLOAD_TIMEOUT,
640
+ responseType: 'arraybuffer',
641
+ maxContentLength: MAX_FILE_SIZE,
642
+ maxBodyLength: MAX_FILE_SIZE,
643
+ headers: {
644
+ 'Authorization': `Bearer ${apiKey}`,
645
+ },
646
+ ...getAxiosConfig(baseUrl),
647
+ });
648
+ const contentType = response.headers['content-type'] || 'application/pdf';
649
+ const contentDisposition = response.headers['content-disposition'] || '';
650
+ let fileName = `certificate_${c2paFileId}.pdf`;
651
+ const filenameMatch = contentDisposition.match(/filename[^;=\n]*=(['"]?)([^'"\n;]*)['"]?/);
652
+ if (filenameMatch && filenameMatch[2]) {
653
+ fileName = filenameMatch[2];
654
+ }
655
+ const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.data), fileName, contentType);
656
+ returnData.push({
657
+ json: {
658
+ success: true,
659
+ fileName,
660
+ mimeType: contentType,
661
+ fileSize: response.data.byteLength,
662
+ c2paFileId,
663
+ },
664
+ binary: {
665
+ [binaryPropertyName]: binaryData,
666
+ },
667
+ pairedItem: { item: i },
668
+ });
669
+ continue;
670
+ }
516
671
  // Return data
517
672
  returnData.push({
518
673
  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.6",
4
4
  "description": "ProofOfAuthenticity by CHECKHC - Blockchain timestamping with AI detection and C2PA content authenticity.",
5
5
  "keywords": [
6
6
  "n8n",