Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@travetto/asset
Advanced tools
Modular library for storing and retrieving binary assets with additional support for image modification at runtime
This module provides the framework for storing/retrieving assets. It also provides additional image functionality for on-the-fly resizing.
The asset module requires an AssetSource
to provide functionality for reading and writing files. The AssetSource
will need to be configured to be picked up by the AssetService
Code: Registering Asset Source
class AppConfig {
@InjectableFactory()
static getSource(): AssetSource {
return new CustomAssetSource();
}
}
After that, both AssetService
and ImageService
will rely upon the AssetSource
to do their work. Below you can see an example of storing and retrieving a user's profile image.
Install: primary
$ npm install @travetto/asset
You will need to select one of the available providers to serve as your AssetSource
.
Install: secondary
$ npm install @travetto/asset-{provider}
Storing of all assets uses the AssetService
, but retrieval can either be from AssetService
or ImageService
depending on whether or not you want to perform image optimizations on retrieval. The ImageService
users GraphicsMagick
for image transformation. If the binary is not installed the framework will spin up a docker
container to provide needed functionality.
Code: Storing images
@Injectable()
class UserProfileService {
constructor(
private asset: AssetService,
private image: ImageService,
private model: ModelService
) {}
async saveProfileImage(userId: string, image: Asset) {
const path = await this.asset.store(image);
const user = await this.model.getById(User, userId);
user.profileImage = path;
await this.model.update(User, user);
}
async getProfileImage(userId:string) {
const user = await this.model.getById(userId);
return await this.image.getImage(user.profileImage, { w: 100, h: 100 });
}
}
Additionally, the ImageService
currently supports the ability to resize an image on the fly, while auto orienting.
FAQs
Modular library for storing and retrieving binary assets
The npm package @travetto/asset receives a total of 39 weekly downloads. As such, @travetto/asset popularity was classified as not popular.
We found that @travetto/asset demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.