fix(core): Fix candidate handling in PDF generation
This commit is contained in:
		| @@ -1,5 +1,12 @@ | ||||
| # Changelog | ||||
|  | ||||
| ## 2024-11-30 - 3.1.8 - fix(core) | ||||
| Fix candidate handling in PDF generation | ||||
|  | ||||
| - Added error handling for missing PDF candidates in server requests. | ||||
| - Updated devDependencies and dependencies to latest versions for better stability and new features. | ||||
| - Patched header retrieval logic during PDF generation for security check. | ||||
|  | ||||
| ## 2024-09-27 - 3.1.7 - fix(dependencies) | ||||
| Update dependencies to latest versions | ||||
|  | ||||
|   | ||||
							
								
								
									
										16
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								package.json
									
									
									
									
									
								
							| @@ -14,12 +14,12 @@ | ||||
|     "buildDocs": "tsdoc" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@git.zone/tsbuild": "^2.1.84", | ||||
|     "@git.zone/tsdoc": "^1.3.12", | ||||
|     "@git.zone/tsrun": "^1.2.49", | ||||
|     "@git.zone/tsbuild": "^2.2.0", | ||||
|     "@git.zone/tsdoc": "^1.4.2", | ||||
|     "@git.zone/tsrun": "^1.3.3", | ||||
|     "@git.zone/tstest": "^1.0.77", | ||||
|     "@push.rocks/tapbundle": "^5.3.0", | ||||
|     "@types/node": "^22.7.4" | ||||
|     "@push.rocks/tapbundle": "^5.5.3", | ||||
|     "@types/node": "^22.10.1" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@push.rocks/smartbuffer": "^3.0.4", | ||||
| @@ -31,10 +31,10 @@ | ||||
|     "@push.rocks/smartpuppeteer": "^2.0.2", | ||||
|     "@push.rocks/smartunique": "^3.0.9", | ||||
|     "@tsclass/tsclass": "^4.1.2", | ||||
|     "@types/express": "^4.17.21", | ||||
|     "express": "^4.21.0", | ||||
|     "@types/express": "^5.0.0", | ||||
|     "express": "^4.21.1", | ||||
|     "pdf-lib": "^1.17.1", | ||||
|     "pdf2json": "3.0.5", | ||||
|     "pdf2json": "3.1.4", | ||||
|     "pdf2pic": "^3.1.3" | ||||
|   }, | ||||
|   "files": [ | ||||
|   | ||||
							
								
								
									
										4126
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4126
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -3,6 +3,6 @@ | ||||
|  */ | ||||
| export const commitinfo = { | ||||
|   name: '@push.rocks/smartpdf', | ||||
|   version: '3.1.7', | ||||
|   version: '3.1.8', | ||||
|   description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.' | ||||
| } | ||||
|   | ||||
| @@ -41,8 +41,13 @@ export class SmartPdf { | ||||
|     // setup server | ||||
|     const app = plugins.express(); | ||||
|     app.get('/:pdfId', (req, res) => { | ||||
|       res.setHeader('PDF-ID', this._candidates[req.params.pdfId].pdfId); | ||||
|       res.send(this._candidates[req.params.pdfId].htmlString); | ||||
|       const wantedCandidate = this._candidates[req.params.pdfId]; | ||||
|       if (!wantedCandidate) { | ||||
|         console.log(`${req.url} not attached to a candidate`); | ||||
|         return; | ||||
|       } | ||||
|       res.setHeader('pdf-id', wantedCandidate.pdfId); | ||||
|       res.send(wantedCandidate.htmlString); | ||||
|     }); | ||||
|     this.htmlServerInstance = plugins.http.createServer(app); | ||||
|     const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork(); | ||||
| @@ -84,7 +89,6 @@ export class SmartPdf { | ||||
|     const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, { | ||||
|       waitUntil: 'networkidle2', | ||||
|     }); | ||||
|     // await plugins.smartdelay.delayFor(1000); | ||||
|     const headers = response.headers(); | ||||
|     if (headers['pdf-id'] !== pdfCandidate.pdfId) { | ||||
|       console.log('Error! Headers do not match. For security reasons no pdf is being emitted!'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user