
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
tinspector
Advanced tools
TypeScript type inspector library
tinspector is a type inspector library, it can parse all exported functions and classes inside a module into Abstract Syntax Tree.
Example you have a file with classes like below:
//filename: src/mock.ts
export function myFun(firstPar: string, secondPar: string) { }
export function myOtherFun() { }
export class MyClass {
myMethod(firstPar: string, secondPar: string) { }
myOtherMethod(){}
}
You can retrieve AST from above module using:
//filename: src/index.ts
import {reflect} from "./reflect"
const result = reflect("./mock")
The result will be like below:
{
type: 'Object',
name: 'module',
members: [{
type: 'Function',
name: 'myFun',
parameters:
[{ type: 'Parameter', name: 'firstPar' },
{ type: 'Parameter', name: 'secondPar' }]
},
{ type: 'Function', name: 'myOtherFun', parameters: [] },
{
type: 'Class',
name: 'MyClass',
methods:
[{
type: 'Function',
name: 'myMethod',
parameters:
[{ type: 'Parameter', name: 'firstPar' },
{ type: 'Parameter', name: 'secondPar' }]
},
{ type: 'Function', name: 'myOtherMethod', parameters: [] }]
}]
}
The parameter of the reflect
method is the path of the module that will be parsed, it is respect the JavaScript import naming such as absolute "./module"
, "/path/of/module"
, relative "../../module"
or global "module"
tinspector can handle TypeScript style decorator properly
import {decorateClass, decorateMethod, decorateParameter} from "./reflect"
@decorateClass({ url: "/animal" })
export class AnimalClass {
@decorateMethod({ url: "/get" })
myMethod(@decorateParameter({ required: true }) firstPar: string, @decorateParameter({ required: false }) secondPar: string) { }
myOtherMethod(@decorateParameter({ required: true }) par1: string, par2: string) { }
}
The reflection result is like below:
{
type: 'Class',
name: 'AnimalClass',
methods:
[{
type: 'Function',
name: 'myMethod',
parameters:
[{
type: 'Parameter',
name: 'firstPar',
decorators:
[{ required: true }]
},
{
type: 'Parameter',
name: 'secondPar',
decorators:
[{ required: false }]
}],
decorators:
[{ url: '/get' }]
},
{
type: 'Function',
name: 'myOtherMethod',
parameters:
[{
type: 'Parameter',
name: 'par1',
decorators:
[{ required: true }]
},
{ type: 'Parameter', name: 'par2', decorators: [] }],
decorators: []
}],
decorators:
[{ url: '/animal' }]
}
FAQs
TypeScript type inspector
The npm package tinspector receives a total of 589 weekly downloads. As such, tinspector popularity was classified as not popular.
We found that tinspector 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.