JavaScript SDK for JEP: A Judgment Event Protocol.
Implements all 4 core primitives: Judgment, Delegation, Termination, Verification.
npm install @hjs/sdk-jsconst JEPClient = require('@JEP/sdk-js');
const client = new JEPClient({
baseURL: 'https://api.jep.sh',
apiKey: 'your-api-key' // Optional
});
async function example() {
// 1. Record a judgment
const record = await client.judgment({
entity: 'alice@bank.com',
action: 'loan_approved',
scope: { amount: 100000 }
});
console.log('✅ Judgment recorded:', record.id);
// 2. Create a delegation
const delegation = await client.delegation({
delegator: 'manager@company.com',
delegatee: 'employee@company.com',
scope: { permissions: ['approve_under_1000'] }
});
console.log('✅ Delegation created:', delegation.id);
// 3. Verify any record
const verify = await client.verify(delegation.id);
console.log('✅ Verification result:', verify.status); // 'VALID' or 'INVALID'
}
example();const client = new JEPClient(options);Options:
| Option | Type | Default | Description |
|---|---|---|---|
baseURL |
string | 'https://api.jep.sh' |
API base URL |
apiKey |
string | null |
API key for authentication |
const result = await client.judgment({
entity: 'user@example.com', // Required: who is making the judgment
action: 'approve', // Required: what action
scope: { amount: 1000 }, // Optional: additional context
immutability: { type: 'ots' } // Optional: anchor to blockchain
});Returns:
{
id: 'jgd_1234567890abcd',
status: 'recorded',
protocol: 'JEP/1.0',
timestamp: '2026-02-23T12:00:00.000Z',
immutability_anchor: {
type: 'ots',
reference: '...',
anchored_at: '...'
}
}const result = await client.delegation({
delegator: 'manager@company.com', // Required: who delegates
delegatee: 'employee@company.com', // Required: who receives
judgmentId: 'jgd_xxx', // Optional: linked judgment
scope: { permissions: ['approve'] }, // Optional: delegation scope
expiry: '2026-12-31T23:59:59Z' // Optional: expiration time
});Returns:
{
id: 'dlg_1234567890abcd',
status: 'active',
delegator: 'manager@company.com',
delegatee: 'employee@company.com',
scope: { permissions: ['approve'] },
created_at: '2026-02-23T12:00:00.000Z'
}const result = await client.termination({
terminator: 'admin@company.com', // Required: who terminates
targetId: 'dlg_1234567890abcd', // Required: what to terminate
targetType: 'delegation', // Required: 'judgment' or 'delegation'
reason: 'Employee left company' // Optional: reason for termination
});Returns:
{
id: 'trm_1234567890abcd',
terminator: 'admin@company.com',
target_id: 'dlg_1234567890abcd',
target_type: 'delegation',
reason: 'Employee left company',
created_at: '2026-02-23T12:00:00.000Z'
}// Method 1: Detailed verification
const result = await client.verification({
verifier: 'auditor@company.com',
targetId: 'dlg_1234567890abcd',
targetType: 'delegation' // 'judgment', 'delegation', or 'termination'
});
// Method 2: Quick verify (auto-detects type from ID)
const result = await client.verify('dlg_1234567890abcd');Returns:
{
id: 'vfy_1234567890abcd',
result: 'VALID', // or 'INVALID'
details: {
valid: true,
delegation: {...},
judgment: {...}
},
verified_at: '2026-02-23T12:00:00.000Z'
}const judgment = await client.getJudgment('jgd_xxx');
const delegation = await client.getDelegation('dlg_xxx');
const termination = await client.getTermination('trm_xxx');// List judgments
const judgments = await client.listJudgments({
entity: 'user@example.com',
page: 1,
limit: 20
});
// List delegations
const delegations = await client.listDelegations({
delegator: 'manager@company.com',
status: 'active'
});const health = await client.health();
// Returns: { status: 'healthy', version: '1.0.0', ... }const docs = await client.docs();
// Returns complete API documentationconst key = await client.generateKey('user@example.com', 'my-app');
// Returns: { key: '...', email: '...', created: '...' }# Clone the repository
git clone https://github.com/jep-protocol/sdk-js.git
cd sdk-js
# Install dependencies
npm install
# Run tests
node test.jsThe SDK works in both Node.js and browsers:
<script src="https://cdn.jsdelivr.net/npm/@hjs/sdk-js@latest"></script>
<script>
const client = new JEPClient({ apiKey: 'your-key' });
client.judgment({
entity: 'user@example.com',
action: 'test'
}).then(result => {
console.log('Recorded:', result.id);
});
</script>MIT License — see LICENSE for details.