Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@autonomys/auto-dag-data
Advanced tools
![Autonomys Banner](https://github.com/autonomys/auto-sdk/blob/main/.github/images/autonomys-banner.webp)
The Autonomys Auto DAG Data SDK (@autonomys/auto-dag-data
) provides utilities for creating and managing IPLD DAGs (InterPlanetary Linked Data Directed Acyclic Graphs) for files and folders. It facilitates chunking large files, handling metadata, and creating folder structures suitable for distributed storage systems like IPFS.
You can install Auto-DAG-Data using npm or yarn:
npm install @autonomys/auto-dag-data
or
yarn add @autonomys/auto-dag-data
To create an IPLD DAG from a file, you can use the createFileIPLDDag
function:
import { createFileIPLDDag } from '@autonomys/auto-dag-data'
import fs from 'fs'
const fileBuffer = fs.readFileSync('path/to/your/file.txt')
const dag = createFileIPLDDag(fileBuffer, 'file.txt')
To create an IPLD DAG from a folder, you can use the createFolderIPLDDag
function:
import { createFolderIPLDDag } from '@autonomys/auto-dag-data'
import { CID } from 'multiformats'
// Example child CIDs and folder information
const childCIDs: CID[] = [
/* array of CIDs */
]
const folderName = 'my-folder'
const folderSize = 1024 // size in bytes
const folderDag = createFolderIPLDDag(childCIDs, folderName, folderSize)
You can use functions from the cid
module to work with CIDs:
import { cidOfNode, cidToString, stringToCid } from '@autonomys/auto-dag-data'
// Create a CID from a node
const cid = cidOfNode(dag.head)
// Convert the CID to a string
const cidString = cidToString(cid)
// Parse a string back into a CID
const parsedCID = stringToCid(cidString)
You can encode and decode IPLD nodes:
import { encodeNode, decodeNode } from '@autonomys/auto-dag-data'
// Encode a node
const encodedNode = encodeNode(dag.head)
// Decode a node
const decodedNode = decodeNode(encodedNode)
To add metadata to a node, you can create a metadata node:
import { createMetadataNode } from '@autonomys/auto-dag-data'
const metadata = {
name: 'My File',
description: 'This is a sample file',
// ... other metadata fields
}
const metadataNode = createMetadataNode(metadata)
import { createFileIPLDDag, cidOfNode, cidToString } from '@autonomys/auto-dag-data'
import fs from 'fs'
const fileBuffer = fs.readFileSync('path/to/your/file.txt')
const dag = createFileIPLDDag(fileBuffer, 'file.txt')
const cid = cidOfNode(dag.headCID)
const cidString = cidToString(cid)
console.log(`CID of the file DAG: ${cidString}`)
import {
createMetadataIPLDDag,
cidOfNode,
cidToString,
type OffchainMetadata,
} from '@autonomys/auto-dag-data'
import fs from 'fs'
const metadata: OffchainMetadata = fs.readFileSync('path/to/your/metadata.json')
const dag = createMetadataIPLDDag(metadata)
const cid = cidOfNode(dag.headCID)
const cidString = cidToString(cid)
console.log(`CID of the metadata DAG: ${cidString}`)
This project is licensed under the MIT License. See the LICENSE file for details.
auto-dag-data
can be found in @autonomys/auto-utils
.If you have any questions or need support, feel free to reach out:
We appreciate your feedback and contributions!
FAQs
![Autonomys Banner](https://github.com/autonomys/auto-sdk/blob/main/.github/images/autonomys-banner.webp)
The npm package @autonomys/auto-dag-data receives a total of 233 weekly downloads. As such, @autonomys/auto-dag-data popularity was classified as not popular.
We found that @autonomys/auto-dag-data 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.