
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
dg.js is javascript library for dynamic geometry. DG helps you visualize and explore relationship between geometry objects in intuitve and interactive way.
via npm
npm install dglib
Everything in dg is scoped under dg namespace
DG uses semantic versioning. You can find current version of dg as dg.version
Constructor: dg.Canvas(string elementID, ?object options)
Canvasoptions object
{ border: "1px solid #ccc", width: 800, height: 600 }Canvas creation example: dg.Canvas("testcanvas", { border: '1px solid #ccc;' })
width() gets canvas width in pixels
numberheight() gets canvas height in pixels
numberConstructor: dg.Axes(Vector v)
Axesdg.Axes([ canvas.width() / 4, canvas.height()/ 1.5 ]).hide(false);canvas is reference to created canvas before calling dg.Axes constructor!
dg.Axes([ 250 , 300 ]), 200 & 300 represent begining of cartesian plane in pixels.
see dg.geom.Vector class under helping classes & functions.
Constructor:
dg.Function(function f)dg.Function(function f, string color)dg.Function( function(x) { return Math.cos(x); } );note that function refers to javascript function & Function refers to dg.f.Function class
color(string color) sets function drawing color
Functionf(number x) evaluates function value at x
numberstep(number s) precision of function drawing (careful if you use dg.Intersect on functions)
FunctionsetF(function f) set function to f (use for animation, calls dg_repaint())
Functiondg.Function( function(x) { return 0; } ).setF( function(y) { return Math.sin(y); } );dg.Angle draws angle between 3 points on canvas. ** Angles are calculated and drawn up to PI radians or 180 degrees.**
Constructor: dg.Angle(Point p0, Point p1, Point p2)
Angledeg() returns created angle in degrees
numberdg.Angle(p0, p1, p2).deg();Constructor: Point ([number: x,number: y])
x(?number n) gets/sets x coordinate not to be used in animation
number | Pointdg.Point([0,0]).x();y(?number n) gets/sets y coordinate not to be used in animation
number | Pointdg.Point([0,0]).y(2); sets y coordinate to 2.translate(Point p) translate point by vector built by [0,0], Point
Pointdg.Point([0,0]).translate(new dg.geom.Point([1,1]))rotate(?(Point p,) number theta) if p supplied rotates around a Point p, otherwise around coordinate begining (counterclockwise)
Pointdg.Point([1,1]).rotate(Math.PI);dg.Point([1,1]).rotate(new dg.geom.Point([1,0]), Math.PI));free(boolean b) Locks point interaction on canvas
Pointdg.Point([0,0]).free(false);label(?string s) get/sets point label
Pointdg.Point([0,0]).size(4);color() get/set point color
String|Pointdg.Point([0,0]).color('rgb(255,0,0)');size(number s) get/sets point size in pixels
String|Pointdg.Point([0,0]).size(4);xy() gets point coordinates as array
[number, number]dg.Point([0,0]).xy();dist(Point p) returns euclid distance between two points
Pointdg.Point([0,0]).dist(dg.Point([1,1]));setX(number n) sets x coordinate of a point use for animation (calls repaint)
PointsetY(number n) sets y coordinate of a point use for animation (calls repaint)
PointaddEvent(string eventName, function callback) registers event listener
Pointclick moveddg.geom.Midpoint inherits dg.geom.Point
Constructor: Midpoint (Point p0, Point p1)
p0, p1dg.Midpoint(dg.Point([0,0]), dg.Point([1,0]));Constructor: Segment (Point p0, Point p1)
p0, p1dg.Segment(dg.Point([0,0]), dg.Point([1,0]));p0() gets first point defining line segment
Pointdg.Segment(dg.Point([0,0]), dg.Point([1,0])).p0();p1() gets second point defining line segment
Pointdg.Segment(dg.Point([0,0]), dg.Point([1,0])).p1();color(string c) set segment color
Segmentattach(Point p) attach point p to line.
Segmentdg.geom.MapPoint inherits dg.geom.Point
Constructor: MapPoint (Point p, function f)
dg.MapPoint(p, function(x){ return x*x;});Constructor: Line (Point p0, Point p1)
p0, p1dg.Line(dg.Point([0,0]), dg.Point([1,0]));p0() gets first point defining line
Pointdg.Line(dg.Point([0,0]), dg.Point([1,0])).p0();p1() gets second point defining line
Pointdg.Line(dg.Point([0,0]), dg.Point([1,0])).p1();color(string c) set line color
Lineattach(Point p) attach point p to line.
Linedg.geom.PerpendicularLine inherits dg.geom.Line
Constructor: PerpendicularLine (Point p, Line l)
p, ldg.geom.PerpendicularBisector inherits dg.geom.PerpendicularLine
Constructor:
PerpendicularBisector (Point p, Segment s)PerpendicularBisector (Segment s)p, s | sdg.geom.AngleBisector inherits dg.geom.Line
Constructor: AngleBisector(Point p0, Point p1, Point p2)
p0, p1, p2dg.geom.ParallelLine inherits dg.geom.Line
Constructor: ParallelLine(Point p, Line l)
p, lConstructor: Circle(Point p0, Point p1)
color(String c) sets circle line color
CircleConstructor: Tangent(Point p, Circle c)
Constructor: Polygon([Point p0, Point p1 (?,number n)])
Polygon([p0, p1], 6) regular poly 6 sidesPolygon([p0, p1, p2]) poly created from Points p0, p1, p2color(String c) sets poly fill color
Polygondg.Polygon([p0, p1], 6).color("rgba(255,0,0,0.2)");stroke(String s) sets poly stroke color
PolygonIn this library dg.geom.Vector class turned out to be helping class to do various calculations.
Vector class does lots of calculations regarding 2d vectors.
Constructor: dg.geom.Vector([number p, number q])
str() returns nice string representation of a vector. For debugging.
translate(Vector v) translates vector position by Vector v.
dot(Vector v) returns vector dot products of current vector & vector v.
norm() returns norm of a vector.
add(Vector v) adds with current vector and returns a new vector, imutable.
mul(number t) scalar multiplication of a vector.
label(?string s) gets/sets vector label.
xy() returns vector coordinates as an array.
x() returns x coordinate of a vector.
y() returns y coordinate of a vector.
dg.geom.transform & dg.geom.transform_inverse are used as mapping functions from canvas to created coordinate system & vice versa.
dg.geom.transform returns array of coordinates on canvas in pixels.
dg.geom.transform_inverse returns array of coordinates in our plane.
dg.geom.transform_scalar(s) returns scalar in canvas pixels.
dg.abs(x) returns absolute value of x.
dg.max(array d) returns max value of array d.
dg.min(array d) returns min value of array d.
dg.rotate(array d, number theta) returns array of coordinates rotated by angle theta
dg.square(array d) returns squared array.
dg.centroid(array[Points]) returns centroid Point of an array of points.
dg.color.rand() returns random color as string in rgb format.
rgb(241,124,252)FAQs
dynamic geometry javascript library
We found that dglib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.