Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@createdreamtech/carti-core
Advanced tools
- [About The Project](#about-the-project) - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Organization](#organization) - [Components](#components) - [Contributing](#contributin
Carti core is a package library that enables Carti to package, install, and store Cartesi built machines in a discoverable way. It also contains the concrete description of the specifications used by the packagemanager.
Install via npm package
npm install -g @createdreamtech/carti-core
Then require it into any module.
import { install, pack, remap } from "../packager"
import * as luaParser from '../parser/lua_parser';
import fs from 'fs-extra';
import {Storage, S3Provider, DiskProvider} from "../storage"
import {expect} from "chai";
import process from "process"
import os from "os"
import { generateLuaConfig } from "../parser";
const secret = process.env["AWS_SECRET_KEY"] || ""
const apiKey = process.env["AWS_API_KEY"] || ""
const region = process.env["AWS_REGION"] || ""
const bucketName = process.env["BUCKET_NAME"] || ""
const storageType = process.argv[2];
const assetDirectory = process.argv[3];
const installationPath = process.argv[4];
// simple loader for our cartesi machine to run the generated config
const luaRunScript =`
-- Load the Cartesi module
local cartesi = require"cartesi"
-- Instantiate machine from configuration
local machine = cartesi.machine(require(arg[1]))
-- Run machine until it halts
while not machine:read_iflags_H() do
machine:run(math.maxinteger)
end
`
const getStorage = async (storageType: string):Promise<Storage>=> {
switch (storageType) {
case "s3":
return new Storage(new S3Provider(bucketName))
case "disk":
await fs.mkdirp(`${assetDirectory}/_disk_storage/`)
return new Storage(new DiskProvider(`${assetDirectory}/_disk_storage/`))
default:
throw Error("Unsupported storage structure")
}
}
(async function(){
// read in a machine config generated from dump-config
const machineConfigFile = fs.readFileSync(`${assetDirectory}/example_machine_config.lua`)
// translate this into a machine config object
let machineConfig = await luaParser.parseLuaMachineConfig(machineConfigFile.toString('utf-8'))
// remap any virtual directories to directies in the context the packager is running in
machineConfig = remap(machineConfig, { "/opt/cartesi/share/images": `${assetDirectory}/images` })
// get the proper storage type for the type of storage you'd like to use
const storage = await getStorage(storageType)
// package/upload assets using the storage type specified
const pkgConfig = await pack(machineConfig, storage)
// write this to disk so you can share it with other people
await fs.writeJSON("example_carti_package.json", pkgConfig)
// read a package file into carti Package Config
const newPkgConfig = await fs.readJSON("example_carti_package.json")
// install package file from disk into the installation path, using a fetcher in this case we are fetching the
// data from the same place we installed it so we can use the same fetcher to retrieve the package
const newConfig = await install(newPkgConfig, storage, installationPath)
// write an example run script that can be mounted into your cartesi machine directory in the location
// -v {installationPath}:/opt/cartesi/packages
await fs.writeFile(`${installationPath}/example_carti_package_run.lua`,generateLuaConfig(newConfig, "return"))
//write a little helper lua script
await fs.writeFile(`${installationPath}/run-config.lua`, luaRunScript)
//to run the package try the following command
console.log(`docker run -v ${installationPath}:/opt/carti/packages cartesi/playground /bin/bash -c 'cd /opt/carti/packages; luapp5.3 run-config.lua example_carti_package_run'`)
})()
.
├── encoders
│ ├── encoders.ts
│ ├── hashers.ts
├── examples
│ ├── README.md
│ ├── generate_package.sh
│ ├── index.ts
│ └── run-config.lua
├── fetcher
│ ├── fetcher.ts
│ ├── index.ts
├── fixtures
├── generated
│ ├── machine_config_pkg_schema.ts
│ ├── machine_config_schema.ts
│ └── mirror_config_schema.ts
├── index.ts
├── machine-config-package-schema.json
├── machine-config-schema.json
├── mirror-config-schema.json
├── packager
│ ├── index.ts
│ ├── fetcher.ts
│ └── utils.ts
├── parser
│ ├── index.ts
│ ├── lua_config_template.ts
│ ├── lua_config_template_test.ts
│ ├── lua_parser.test.ts
│ └── lua_parser.ts
└── storage
├── disk.ts
├── index.ts
├── memory.ts
├── provider.ts
├── s3.ts
└── util.ts
Contains the code to encode data be that CBOR, BASE64, etc...
Contains the code that bundles together file based assets, encodes, and stores the data
Contains the code to store and retrieve data from storage be that Disk, Memory, IPFS, Git, S3
Contains code to resolve package data from URI or other platform, which may or may not intersect with Storage i.e. HTTP might have fetcher and Storage may just implement retrieval from s3 api
Contains the code to parse lua config files and generate lua config files used to run cartesi machines
Contains an example of how this lib can be used to generate cartesi machines and package machine data
Contains code generated from the schemas that describe the various package formats
Contains code to generate tyepscript types from schemas and produces /generated
The schema for carti packages, includes separate section for managing assets and a format that links to them via CIDs it also includes some tenative metadata
The schema that directly translate cartesi machine configurations generated from the cartesi machine lua based output from dump-configuration
A tenative description of the actual storage location of the package in question, with this file it becomes possible to describe where the package can expect to resolve the CIDs( content identifiers ) for the cartesi assets
See the open issues for a list of proposed features (and known issues).
How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.
Apache License 2.0
FAQs
- [About The Project](#about-the-project) - [Getting Started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Organization](#organization) - [Components](#components) - [Contributing](#contributin
The npm package @createdreamtech/carti-core receives a total of 3 weekly downloads. As such, @createdreamtech/carti-core popularity was classified as not popular.
We found that @createdreamtech/carti-core 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
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.