affixio-yesno
v1.0.0
Published
NPM SDK for pure yes/no decisions with sandbox, protection and live API — proof from any yes-no layer
Downloads
107
Maintainers
Readme
affixio-yesno
NPM SDK for pure yes/no decisions with sandbox, protection and live API — proof from any yes-no layer.
Install
npm install affixio-yesnoAPI Key (sandbox)
const { ApiClient } = require('affixio-yesno');
const apiKey = await ApiClient.generateSandboxKey('https://api.affix-io.com');Usage
const { YesNoDecision, ApiClient } = require('affixio-yesno');
const apiKey = await ApiClient.generateSandboxKey('https://api.affix-io.com');
const client = new YesNoDecision({ apiKey, terminalId: 'TERM-001' });
const result = await client.decide({
userId: 'user-123',
rules: ['allowed', 'verified'],
data: { score: 100, threshold: 80 }
});
if (result.success) {
console.log(result.decision ? 'yes' : 'no', result.synced ? 'synced' : 'pending sync');
}
const { synced, failed } = await client.sync();
client.stop();Config
- apiKey (required): from
ApiClient.generateSandboxKey(baseUrl) - baseUrl (optional): default
https://api.affix-io.com - terminalId (optional): default
'terminal'
Decide request
- userId: string (required)
- rules: string[] (required)
- data: object (required) — inputs for the yes/no circuit
- decisionId: string (optional) — omit for auto-generated; set for idempotency
Decide result
- success, decision (boolean), decisionId, proofId, synced, offline, error
Protection
Double-spend protection: same decisionId cannot be used twice. Offline proofs sync to the live API when back online.
Exports
YesNoDecision, ApiClient, DoubleSpendGuard, SyncEngine, generateOfflineYesNoProof, and types (YesNoRequest, YesNoResult, PendingProof, etc.).
