mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
Created 11 packagerepo-specific workflow plugins: - auth_verify_jwt - JWT token verification - auth_check_scopes - Scope-based authorization - parse_path - URL path parameter extraction (Express-style) - normalize_entity - Field normalization (trim, lower, unique, sort) - validate_entity - JSON schema validation - kv_get/kv_put - RocksDB key-value operations - blob_put - Filesystem blob storage with SHA-256 hashing - index_upsert - Index entry management - respond_json/respond_error - Response formatting Created string.sha256 plugin: - Compute SHA256 hash of strings/bytes - Optional "sha256:" prefix - Used by packagerepo for content-addressed storage All plugins follow standard pattern: - Class extending NodeExecutor - Factory with create() function - package.json with metadata - Access external state via runtime parameter Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""Workflow plugin: compute SHA256 hash of string/bytes."""
|
|
|
|
import hashlib
|
|
from ...base import NodeExecutor
|
|
|
|
|
|
class StringSha256(NodeExecutor):
|
|
"""Compute SHA256 hash of input string or bytes."""
|
|
|
|
node_type = "string.sha256"
|
|
category = "string"
|
|
description = "Compute SHA256 hash of input string or bytes"
|
|
|
|
def execute(self, inputs, runtime=None):
|
|
"""
|
|
Compute SHA256 hash.
|
|
|
|
Args:
|
|
inputs: Dict with:
|
|
- input: String or bytes to hash
|
|
- prefix: Optional bool, whether to prepend "sha256:" (default: False)
|
|
|
|
Returns:
|
|
Dict with 'result' containing hex hash string
|
|
"""
|
|
input_value = inputs.get("input", "")
|
|
prefix = inputs.get("prefix", False)
|
|
|
|
# Convert to bytes if string
|
|
if isinstance(input_value, str):
|
|
input_bytes = input_value.encode('utf-8')
|
|
else:
|
|
input_bytes = input_value
|
|
|
|
# Compute hash
|
|
hash_obj = hashlib.sha256(input_bytes)
|
|
hex_hash = hash_obj.hexdigest()
|
|
|
|
# Add prefix if requested
|
|
if prefix:
|
|
result = f"sha256:{hex_hash}"
|
|
else:
|
|
result = hex_hash
|
|
|
|
return {"result": result}
|