
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
jsonldjs
A powerful, generic JSON-LD builder with comprehensive entity and property filtering capabilities. Provides both immutable configuration building and mutable graph processing with a fluent interface.
# Using pnpm (recommended)
pnpm add jsonldjs
# Using npm
npm install jsonldjs
# Using yarn
yarn add jsonldjs
import { createJsonLdBuilder } from 'jsonldjs';
import { jsonldGraph } from '@/data/jsonld';
// Simple filtering
const result = createJsonLdBuilder()
.baseGraph(jsonldGraph)
.includeTypes(['Organization', 'Person'])
.excludeTypes(['ImageObject'])
.maxEntities(10)
.build({
prettyPrint: true,
withScriptTag: true,
scriptId: 'json-ld',
});
import { createJsonLdBuilder, createJsonLdConfig } from 'jsonldjs';
// Create reusable configurations
const globalConfig = createJsonLdConfig()
.baseGraph(jsonldGraph)
.includeIds(['org:hyperweb', 'website:hyperweb.io'])
.filterPropertiesByIds(['org:hyperweb'], { exclude: ['subjectOf'] });
// Extend configurations immutably
const homeConfig = globalConfig.excludeTypes(['ImageObject']);
const blogConfig = globalConfig.includeTypes(['Article']);
// Use configurations
const result = createJsonLdBuilder()
.mergeConfig(homeConfig.getConfig())
.excludeIds(['runtime:override']) // Runtime overrides
.build({ prettyPrint: true });
All configuration methods merge by default instead of replacing. This provides predictable behavior across all methods:
const config = createJsonLdConfig()
.includeIds(['a', 'b'])
.includeIds(['c', 'd']) // Result: ['a', 'b', 'c', 'd']
.includeTypes(['Person'])
.includeTypes(['Organization']); // Result: ['Person', 'Organization']
When you need to replace instead of merge, use the clear methods:
const config = createJsonLdConfig()
.includeIds(['old1', 'old2'])
.clearIds() // Clear both includeIds and excludeIds
.includeIds(['new1', 'new2']); // Result: ['new1', 'new2']
clearIds()
- Clears both includeIds
and excludeIds
clearTypes()
- Clears both includeTypes
and excludeTypes
clearPropertyRequirements()
- Clears both requiredProperties
and excludeEntitiesWithProperties
clearPropertyFilters()
- Clears both propertyFiltersByIds
and propertyFiltersByTypes
clearSubgraph()
- Clears subgraphRoots
clearAll()
- Clears entire configuration (except baseGraph
)createJsonLdConfig()
Creates a new immutable configuration builder.
const config = createJsonLdConfig()
.baseGraph(graph)
.includeIds(['org:hyperweb'])
.excludeTypes(['ImageObject']);
createJsonLdBuilder()
Creates a new builder that extends the configuration builder with graph processing capabilities.
const builder = createJsonLdBuilder().baseGraph(graph).mergeConfig(config);
All methods are inherited by the builder from the configuration builder:
.includeIds(ids: string[])
- Include entities with these IDs (merges with existing).excludeIds(ids: string[])
- Exclude entities with these IDs (merges with existing).includeTypes(types: string[])
- Include these entity types (merges with existing).excludeTypes(types: string[])
- Exclude these entity types (merges with existing).customFilter(fn: JsonLdFilter)
- Apply custom filter function.maxEntities(max: number)
- Limit maximum number of entities.requiredProperties(props: string[])
- Include entities with these properties (merges with existing).excludeEntitiesWithProperties(props: string[])
- Exclude entities with these properties (merges with existing).clearIds()
- Clear both includeIds and excludeIds.clearTypes()
- Clear both includeTypes and excludeTypes.clearPropertyRequirements()
- Clear both requiredProperties and excludeEntitiesWithProperties.clearPropertyFilters()
- Clear both propertyFiltersByIds and propertyFiltersByTypes.clearSubgraph()
- Clear subgraphRoots.clearAll()
- Clear entire configuration (except baseGraph).mergeConfig(config: JsonLdConfig)
- Merge with another complete configuration.mergeFilters(filters: JsonLdFilterOptions)
- Merge only the filters part of another configurationAvailable in both config builder and main builder - These methods work the same way in both classes.
// Config builder usage
const baseConfig = createJsonLdConfig().includeTypes(['Person']);
const otherConfig = createJsonLdConfig()
.includeTypes(['Organization'])
.excludeIds(['test'])
.getConfig();
const merged = baseConfig.mergeConfig(otherConfig);
// Result: includeTypes: ['Person', 'Organization'], excludeIds: ['test']
// Main builder usage (processes graph immediately)
const result = createJsonLdBuilder()
.baseGraph(graph)
.includeTypes(['Person'])
.mergeConfig(otherConfig)
.build({ prettyPrint: true });
// Merge only filters
const baseConfig = createJsonLdConfig().includeTypes(['Person']).addEntities([entity]);
const otherFilters = { includeTypes: ['Organization'], maxEntities: 10 };
const merged = baseConfig.mergeFilters(otherFilters);
// Result: includeTypes: ['Person', 'Organization'], maxEntities: 10, additionalEntities preserved
.filterPropertiesByIds(entityIds, rule)
- Filter properties for specific entity IDs.filterPropertiesByTypes(entityTypes, rule)
- Filter properties for specific entity types// Filter properties by entity ID
.filterPropertiesByIds(['org:hyperweb'], {
exclude: ['subjectOf', 'member']
})
// Filter properties by entity type
.filterPropertiesByTypes(['Article'], {
include: ['headline', 'author', 'datePublished']
})
.baseGraph(graph: JsonLdGraph)
- Set the base graph to process.subgraph(rootIds: string[])
- Extract subgraph starting from these root IDs.addEntities(entities: JsonLdEntity[])
- Add additional entities.pipe(fn: PipeFunction)
- Add custom transformation function.getCurrentGraph()
- Get the current graph state.build(options?: BuildOptions)
- Build the final JSON-LD outputinterface BuildOptions {
prettyPrint?: boolean; // Pretty-print JSON output (default: true)
contextUrl?: string; // Custom context URL (default: 'https://schema.org')
withScriptTag?: boolean; // Wrap in script tag (default: false)
scriptId?: string; // Script tag ID
}
The builder implements three distinct filtering paths based on configuration:
subgraph()
is used, property filtering is applied during traversalincludeIds()
is used, entities are filtered first, then additional filters applied// Subgraph mode - follows references with property filtering
const result = createJsonLdBuilder()
.baseGraph(graph)
.subgraph(['org:hyperweb'])
.filterPropertiesByIds(['org:hyperweb'], { exclude: ['subjectOf'] })
.build();
// IncludeIds mode - simple entity filtering
const result = createJsonLdBuilder()
.baseGraph(graph)
.includeIds(['org:hyperweb', 'person:john'])
.excludeTypes(['ImageObject'])
.build();
const result = createJsonLdBuilder()
.baseGraph(graph)
.includeTypes(['Person'])
.pipe((graph) =>
graph.map((entity) => ({
...entity,
processed: true,
}))
)
.pipe((graph) => graph.filter((entity) => entity.name))
.build();
// Base configuration
const baseConfig = createJsonLdConfig()
.baseGraph(jsonldGraph)
.filterPropertiesByIds(['org:hyperweb'], { exclude: ['subjectOf'] });
// Page-specific configurations
const homeConfig = baseConfig.excludeTypes(['ImageObject']);
const blogConfig = baseConfig.includeTypes(['Article']);
const personConfig = baseConfig.includeTypes(['Person', 'Organization']);
// Use with different base graphs
const articlesConfig = baseConfig.baseGraph(articlesGraph);
The JSON-LD builder processes options in a specific order defined by the processGraph
method. Understanding this order is crucial for predicting the final output when multiple filtering options are applied.
The builder processes options in the following sequential layers:
subgraphRoots
are configured via .subgraph(rootIds)
// Example: Subgraph extraction with property filtering
const result = createJsonLdBuilder()
.baseGraph(graph)
.subgraph(['org:hyperweb']) // Layer 1: Extract subgraph
.filterPropertiesByIds(['org:hyperweb'], { exclude: ['subjectOf'] }) // Applied during traversal
.build();
filterGraphProperties()
functionfilterJsonLdGraph()
function// Example: Property filtering followed by entity filtering
const result = createJsonLdBuilder()
.baseGraph(graph)
.filterPropertiesByTypes(['Article'], { include: ['headline', 'author'] }) // 3a: Property filtering
.includeTypes(['Article', 'Person']) // 3b: Entity filtering
.excludeIds(['unwanted:id']) // 3b: Additional entity filtering
.build();
populateConfig
is setapplyPopulateConfig()
.addEntities()
.pipe(fn)
// Example: Custom pipes applied last
const result = createJsonLdBuilder()
.baseGraph(graph)
.includeTypes(['Person'])
.pipe((graph) => graph.map((entity) => ({ ...entity, processed: true }))) // Applied last
.pipe((graph) => graph.filter((entity) => entity.name)) // Applied after previous pipe
.build();
Property Filters Before Entity Filters: Property filtering always happens before entity filtering (except in subgraph mode where they're combined)
Subgraph Mode Optimization: When using subgraphs, property filtering is applied during traversal for better performance
Single Property Filter Application: Property filters are only applied once to avoid duplicate processing
Additive Additional Entities: Entities added via .addEntities()
are appended after all filtering
Sequential Pipe Execution: Custom pipes are executed in the order they were added
build()
or getCurrentGraph()
is calledgit clone https://github.com/hyperweb-io/jsonld-tools.git
cd jsonld-tools
pnpm install
pnpm run build
FAQs
JSON-LD Tooling
The npm package jsonldjs receives a total of 3 weekly downloads. As such, jsonldjs popularity was classified as not popular.
We found that jsonldjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.