
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@universal-packages/adapter-resolver
Advanced tools
Module loader based on adapter parameters.
npm install @universal-packages/adapter-resolver
classJust instantiate the class and start resolving adapters.
import { AdapterResolver } from '@universal-packages/adapter-resolver'
const resolver = new AdapterResolver({ domain: 'token-registry', type: 'engine' })
const adapter = await resolver.resolve('redis')
console.log(adapter)
// > [class RedisEngine]
constructornew AdapterResolver(options: AdapterResolverOptions)
Creates a new AdapterResolver instance.
Adapters need to follow the convention in order to be found. domain and name are use to infer the package name and type is used to infer the export name.
domain String
The domain for which the adapter will work for example if the adapter is redis and is meant to work with @universal-packages/token-registry you provide here token-registry.
type String
The package needs to export something in the format <name><type>, for example if the adapter is an "engine", you provide here engine and it will internally will come up with different case variations of the format to find the export ex: redisEngine, RedisEngine, redis_engine.
internal Object optional
An object which keys match an internal adapter provided by the root library.
import { AdapterResolver } from '@universal-packages/adapter-resolver'
const resolver = new AdapterResolver({
domain: 'token-registry',
type: 'engine',
internal: { local: LocalAdapter }
})
const adapter = await resolver.resolve('local')
console.log(adapter)
// > [class LocalAdapter]
resolver.resolve(name: string): Promise<A>
Tries to infer an installed module name based on the provided name and resolver options, imports it and infers the desired export based on name and options.
import { AdapterResolver } from '@universal-packages/adapter-resolver'
const resolver = new AdapterResolver({ domain: 'token-registry', type: 'engine' })
const adapter = await resolver.resolve('redis')
console.log(adapter)
// > [class RedisEngine]
resolver.gather(): Promise<GatheredAdapters<A>>
Gather all the adapters of the configured type under the same domain.
import { AdapterResolver } from '@universal-packages/adapter-resolver'
const resolver = new AdapterResolver({ domain: 'token-registry', type: 'engine' })
const adapters = await resolver.gather()
console.log(adapters)
// > { redis: [class RedisEngine], local: [class LocalEngine] }
When using the internal option, internal adapters will be mixed with the gathered adapters:
import { AdapterResolver } from '@universal-packages/adapter-resolver'
const resolver = new AdapterResolver({
domain: 'token-registry',
type: 'engine',
internal: { local: InternalAdapter }
})
const adapters = await resolver.gather()
console.log(adapters)
// > { local: [class InternalAdapter], redis: [class RedisEngine] }
This library is developed in TypeScript and shipped fully typed.
The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.
FAQs
Module loader based on adapter parameters.
We found that @universal-packages/adapter-resolver demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.