@provian/cli 0.0.0-stage → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +267 -2
  4. package/bin/provian.mjs +15 -0
  5. package/dist/cli/agent-config.d.ts +32 -0
  6. package/dist/cli/agent-config.d.ts.map +1 -0
  7. package/dist/cli/agent-config.js +48 -0
  8. package/dist/cli/agent-config.js.map +1 -0
  9. package/dist/cli/commands.d.ts +32 -0
  10. package/dist/cli/commands.d.ts.map +1 -0
  11. package/dist/cli/commands.js +528 -0
  12. package/dist/cli/commands.js.map +1 -0
  13. package/dist/cli/commons-institutions-commands.d.ts +161 -0
  14. package/dist/cli/commons-institutions-commands.d.ts.map +1 -0
  15. package/dist/cli/commons-institutions-commands.js +1580 -0
  16. package/dist/cli/commons-institutions-commands.js.map +1 -0
  17. package/dist/cli/git-identity-commands.d.ts +30 -0
  18. package/dist/cli/git-identity-commands.d.ts.map +1 -0
  19. package/dist/cli/git-identity-commands.js +176 -0
  20. package/dist/cli/git-identity-commands.js.map +1 -0
  21. package/dist/cli/parse-args.d.ts +26 -0
  22. package/dist/cli/parse-args.d.ts.map +1 -0
  23. package/dist/cli/parse-args.js +55 -0
  24. package/dist/cli/parse-args.js.map +1 -0
  25. package/dist/cli/pes-commands.d.ts +37 -0
  26. package/dist/cli/pes-commands.d.ts.map +1 -0
  27. package/dist/cli/pes-commands.js +137 -0
  28. package/dist/cli/pes-commands.js.map +1 -0
  29. package/dist/cli/presentation-commands.d.ts +113 -0
  30. package/dist/cli/presentation-commands.d.ts.map +1 -0
  31. package/dist/cli/presentation-commands.js +851 -0
  32. package/dist/cli/presentation-commands.js.map +1 -0
  33. package/dist/cli/relay-http.d.ts +31 -0
  34. package/dist/cli/relay-http.d.ts.map +1 -0
  35. package/dist/cli/relay-http.js +73 -0
  36. package/dist/cli/relay-http.js.map +1 -0
  37. package/dist/cli/runtime-detect.d.ts +51 -0
  38. package/dist/cli/runtime-detect.d.ts.map +1 -0
  39. package/dist/cli/runtime-detect.js +78 -0
  40. package/dist/cli/runtime-detect.js.map +1 -0
  41. package/dist/cli/session.d.ts +39 -0
  42. package/dist/cli/session.d.ts.map +1 -0
  43. package/dist/cli/session.js +166 -0
  44. package/dist/cli/session.js.map +1 -0
  45. package/dist/cli/sovereign-key-intake.d.ts +17 -0
  46. package/dist/cli/sovereign-key-intake.d.ts.map +1 -0
  47. package/dist/cli/sovereign-key-intake.js +47 -0
  48. package/dist/cli/sovereign-key-intake.js.map +1 -0
  49. package/dist/index.d.ts +14 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +16 -0
  52. package/dist/index.js.map +1 -0
  53. package/package.json +57 -4
@@ -0,0 +1,851 @@
1
+ "use strict";
2
+ /**
3
+ * Burn-to-present CLI verbs — signed challenges, the pre-burn requester
4
+ * check, and the replay-safe verifier.
5
+ *
6
+ * requester side: challenge, verify, requester-key
7
+ * presenter side: check-challenge, respond, present
8
+ *
9
+ * Every presenter path verifies the challenge BEFORE any burn and prints one of
10
+ * Requester: <identity> — VERIFIED
11
+ * Requester: <audience> — UNVERIFIED (unsigned challenge)
12
+ * A SIGNED challenge that is invalid, expired, or addressed to another presenter
13
+ * is REFUSED (exit non-zero) and nothing is burned (Unknown = Block).
14
+ *
15
+ * All protocol logic lives in @provian/agent-sdk — envelope verification
16
+ * (`verifyChallengeEnvelope` / `CommonsInstitutions.checkChallengeBeforeBurn`), the burn +
17
+ * present sequence (`CommonsInstitutions.respondToChallenge`), and the presentation
18
+ * verifier (`verifyPresentationToken`, which enforces predicates-require-
19
+ * reputation, presenter binding, the challenge deadline, and accept-once). This
20
+ * module only parses flags, prints the requester line, and asks for confirmation.
21
+ *
22
+ * Human-readable lines go to stderr (deps.log); stdout stays the one JSON result
23
+ * the bin prints, so the output can be piped.
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.DEFAULT_REQUESTER_KID = void 0;
27
+ exports.defaultPresentationDeps = defaultPresentationDeps;
28
+ exports.burnHandle = burnHandle;
29
+ exports.parsePredicateExpression = parsePredicateExpression;
30
+ exports.readJsonArg = readJsonArg;
31
+ exports.collectDisclosures = collectDisclosures;
32
+ exports.collectDisclosureAnswers = collectDisclosureAnswers;
33
+ exports.collectPredicates = collectPredicates;
34
+ exports.collectPeTokens = collectPeTokens;
35
+ exports.resolvePeFacts = resolvePeFacts;
36
+ exports.parseChallengeArg = parseChallengeArg;
37
+ exports.requesterLine = requesterLine;
38
+ exports.cmdPresentationChallenge = cmdPresentationChallenge;
39
+ exports.cmdCheckChallenge = cmdCheckChallenge;
40
+ exports.cmdRespond = cmdRespond;
41
+ exports.cmdPresent = cmdPresent;
42
+ exports.defaultSeenStorePath = defaultSeenStorePath;
43
+ exports.cmdVerifyPresentation = cmdVerifyPresentation;
44
+ exports.cmdRequesterKey = cmdRequesterKey;
45
+ exports.printPresentationHelp = printPresentationHelp;
46
+ const fs_1 = require("fs");
47
+ const os_1 = require("os");
48
+ const path_1 = require("path");
49
+ const readline_1 = require("readline");
50
+ const agent_sdk_1 = require("@provian/agent-sdk");
51
+ const commons_institutions_commands_1 = require("./commons-institutions-commands");
52
+ const sovereign_key_intake_1 = require("./sovereign-key-intake");
53
+ const DEFAULT_RELAY_URL = 'https://api.provian.ai';
54
+ /** Default kid for a domain requester key (`provian requester-key`, `provian challenge --domain`). */
55
+ exports.DEFAULT_REQUESTER_KID = 'k1';
56
+ async function promptConfirm(question) {
57
+ const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stderr });
58
+ try {
59
+ const answer = await new Promise((r) => rl.question(question, r));
60
+ return /^y(es)?$/i.test(answer.trim());
61
+ }
62
+ finally {
63
+ rl.close();
64
+ }
65
+ }
66
+ function defaultPresentationDeps() {
67
+ return {
68
+ makeInstitutions: (cfg) => new agent_sdk_1.CommonsInstitutions(cfg),
69
+ log: (line) => console.error(line),
70
+ confirm: promptConfirm,
71
+ isInteractive: () => Boolean(process.stdin.isTTY),
72
+ homeDir: () => (0, os_1.homedir)(),
73
+ verifyToken: agent_sdk_1.verifyPresentationToken,
74
+ openPeStore: () => (0, agent_sdk_1.resolveLocalPeStore)({ deviceId: (0, agent_sdk_1.loadCredentials)()?.deviceId ?? null }),
75
+ openArchive: agent_sdk_1.openLocalArchiveKeeper,
76
+ };
77
+ }
78
+ function withDefaults(deps) {
79
+ return { ...defaultPresentationDeps(), ...(deps ?? {}) };
80
+ }
81
+ function relayUrl() {
82
+ return process.env.PROVIAN_RELAY_URL || DEFAULT_RELAY_URL;
83
+ }
84
+ function str(flags, key) {
85
+ const v = flags[key];
86
+ return typeof v === 'string' && v.length > 0 ? v : undefined;
87
+ }
88
+ function requireStr(flags, key, usage) {
89
+ const v = str(flags, key);
90
+ if (v === undefined)
91
+ throw new Error(`Missing --${key}. ${usage}`);
92
+ return v;
93
+ }
94
+ function fail(err, extra = {}) {
95
+ return { status: 'error', ...extra, ...burnHandle(err), error: err.message };
96
+ }
97
+ /**
98
+ * a burn that was broadcast but not presented (BurnNotPresentedError) — print its handle so
99
+ * the operator resumes with --burn-tx instead of burning again.
100
+ */
101
+ function burnHandle(err) {
102
+ const e = err;
103
+ if (e?.code !== 'BURN_NOT_PRESENTED' || !e.txHash)
104
+ return {};
105
+ return {
106
+ burned: true,
107
+ burn_tx: e.txHash,
108
+ burn_id: e.burnId,
109
+ burn_amount_atomic: e.amountAtomic,
110
+ resume: `re-run with --burn-tx ${e.txHash} --burn-amount-atomic ${e.amountAtomic} — do not burn again`,
111
+ };
112
+ }
113
+ // ---------------------------------------------------------------------------
114
+ // Predicate flags (item 4)
115
+ // ---------------------------------------------------------------------------
116
+ const FIELD = '([A-Za-z0-9_.-]+)';
117
+ const NUMBER_RE = /^-?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;
118
+ const COMPARISON_RE = new RegExp(`^\\s*${FIELD}\\s*(>=|<=|==|=|>|<)\\s*(\\S+)\\s*$`);
119
+ const MEMBERSHIP_RE = new RegExp(`^\\s*${FIELD}(?:\\s+|\\s*=\\s*)in:\\s*\\{([^}]*)\\}\\s*$`);
120
+ const OP_MAP = { '>=': 'gte', '>': 'gt', '<=': 'lte', '<': 'lt', '=': 'eq', '==': 'eq' };
121
+ function parseNumber(tok, expr) {
122
+ const t = tok.trim();
123
+ if (!NUMBER_RE.test(t))
124
+ throw new Error(`predicate "${expr}": "${t}" is not a number`);
125
+ return Number(t);
126
+ }
127
+ /**
128
+ * Parse one `--predicate` expression:
129
+ * work.total>=10 work.total>10 work.total<=10 work.total<10 work.total=10
130
+ * 'standing.adverse_events in:{0}' (membership in a numeric set)
131
+ */
132
+ function parsePredicateExpression(expr) {
133
+ const m = MEMBERSHIP_RE.exec(expr);
134
+ if (m) {
135
+ const items = m[2].split(',').map((s) => s.trim()).filter((s) => s.length > 0);
136
+ if (items.length === 0)
137
+ throw new Error(`predicate "${expr}": in:{…} needs at least one number`);
138
+ return { field: m[1], op: 'in', set: items.map((i) => parseNumber(i, expr)) };
139
+ }
140
+ const c = COMPARISON_RE.exec(expr);
141
+ if (c) {
142
+ if (c[3].startsWith('in:'))
143
+ throw new Error(`predicate "${expr}": write membership as '<field> in:{a,b}'`);
144
+ return { field: c[1], op: OP_MAP[c[2]], threshold: parseNumber(c[3], expr) };
145
+ }
146
+ throw new Error(`predicate "${expr}" is not understood — use <field><op><number> with op one of >= > <= < =, or '<field> in:{a,b}'`);
147
+ }
148
+ /** Read a flag value that is inline JSON or `@<path>` to a JSON file. */
149
+ function readJsonArg(value, flagName) {
150
+ const text = value.startsWith('@') ? (0, fs_1.readFileSync)(value.slice(1), 'utf8') : value;
151
+ try {
152
+ return JSON.parse(text);
153
+ }
154
+ catch {
155
+ throw new Error(`--${flagName} is not valid JSON${value.startsWith('@') ? ` (file ${value.slice(1)})` : ''}`);
156
+ }
157
+ }
158
+ /**
159
+ * Every predicate the caller named: `--predicates-json '[…]'` (or `@file`) first,
160
+ * then each `--predicate <expr>` in order. Validated by the SDK's
161
+ * normalizePredicateRequests (fail-closed: one malformed entry refuses them all).
162
+ */
163
+ /**
164
+ * 2026-10-10: the requester-named disclosure requests: `--disclosures-json '[…]'` (or `@file`).
165
+ * Validated by the SDK's normalizeDisclosureRequests (fail-closed).
166
+ */
167
+ function collectDisclosures(flags) {
168
+ const json = str(flags, 'disclosures-json');
169
+ if (json === undefined)
170
+ return [];
171
+ const parsed = readJsonArg(json, 'disclosures-json');
172
+ if (!Array.isArray(parsed))
173
+ throw new Error('--disclosures-json must be a JSON array of {kind:pe, output_digest, issuer?, fields?, content?} | {kind:witness, issuer?|signer?, limit?, fields?, content?}');
174
+ const normalized = (0, agent_sdk_1.normalizeDisclosureRequests)(parsed);
175
+ if (normalized === null) {
176
+ throw new Error('disclosure requests are malformed (a pe request names a 64-hex output_digest; a witness request names an issuer or signer; limit 1..50; fields are dotted paths; content is description|intent|artifacts|fact_tier; at most 16)');
177
+ }
178
+ return normalized;
179
+ }
180
+ /**
181
+ * 2026-10-10: the presenter's answers to a challenge's disclosure requests. Without `--disclose`
182
+ * every request is DECLINED (signed as declined); `--disclose` elects every request, `--disclose
183
+ * <n>[,<n>…]` elects by 0-based index; elected requests are answered from this machine's PE store.
184
+ */
185
+ async function collectDisclosureAnswers(flags, env, deps) {
186
+ const asked = env?.disclosures ?? [];
187
+ if (asked.length === 0)
188
+ return undefined;
189
+ const flag = flags.disclose;
190
+ const elected = new Set();
191
+ if (flag === true || flag === 'all' || flag === '')
192
+ asked.forEach((_, i) => elected.add(i));
193
+ else if (typeof flag === 'string') {
194
+ for (const tok of flag.split(',')) {
195
+ const n = Number(tok.trim());
196
+ if (!Number.isInteger(n) || n < 0 || n >= asked.length)
197
+ throw new Error(`--disclose names request #${tok.trim()}, but the challenge names ${asked.length} (0..${asked.length - 1})`);
198
+ elected.add(n);
199
+ }
200
+ }
201
+ const out = [];
202
+ let store = null;
203
+ let archive;
204
+ for (let i = 0; i < asked.length; i++) {
205
+ if (!elected.has(i)) {
206
+ out.push({ request: asked[i], election: 'declined' });
207
+ continue;
208
+ }
209
+ if (store === null) {
210
+ const opened = deps.openPeStore();
211
+ if (!opened.ok)
212
+ throw new Error(`Cannot disclose: ${opened.detail}`);
213
+ store = opened.store;
214
+ archive = deps.openArchive ? ((await deps.openArchive()) ?? undefined) : undefined;
215
+ }
216
+ const found = await (0, agent_sdk_1.findDisclosureRecords)(store, asked[i], archive);
217
+ out.push({ request: asked[i], election: 'disclosed', records: found.records });
218
+ }
219
+ return out;
220
+ }
221
+ function collectPredicates(flags, lists = {}) {
222
+ const out = [];
223
+ const json = str(flags, 'predicates-json');
224
+ if (json !== undefined) {
225
+ const parsed = readJsonArg(json, 'predicates-json');
226
+ if (!Array.isArray(parsed))
227
+ throw new Error('--predicates-json must be a JSON array of {field, op, threshold|set}');
228
+ out.push(...parsed);
229
+ }
230
+ const exprs = lists.predicate ?? (typeof flags.predicate === 'string' ? [flags.predicate] : []);
231
+ for (const e of exprs)
232
+ out.push(parsePredicateExpression(e));
233
+ const normalized = (0, agent_sdk_1.normalizePredicateRequests)(out);
234
+ if (normalized === null) {
235
+ throw new Error('predicates are malformed (each needs a field, op gte|gt|lte|lt|eq with a numeric threshold, or op in with a non-empty numeric set; at most 64)');
236
+ }
237
+ return normalized;
238
+ }
239
+ /** `--pe <pe_id>[:<pe_hash>]` (repeatable) → the tokens, syntax-checked. */
240
+ function collectPeTokens(flags, lists = {}) {
241
+ const raw = lists.pe ?? (typeof flags.pe === 'string' ? [flags.pe] : []);
242
+ return raw.map((entry) => {
243
+ const token = entry.trim();
244
+ const i = token.lastIndexOf(':');
245
+ const peId = i === -1 ? token : token.slice(0, i);
246
+ const hash = i === -1 ? null : token.slice(i + 1).toLowerCase();
247
+ if (!/^[A-Za-z0-9_.-]{1,200}$/.test(peId) || (hash !== null && !/^(0x)?[0-9a-f]{64}$/.test(hash))) {
248
+ throw new Error(`--pe "${entry}" must be <pe_id> or <pe_id>:<pe_hash> (a PE in this machine's store)`);
249
+ }
250
+ return hash === null ? peId : `${peId}:${hash.replace(/^0x/, '')}`;
251
+ });
252
+ }
253
+ /**
254
+ * PE meter: the relay keeps no PE, so a pe_fact carries the PE itself and its two-hop inclusion
255
+ * proof, both from THIS machine's store. A PE not held here, not batched, or whose day is not yet
256
+ * anchored on Base cannot be presented, and is refused before anything is burned or signed.
257
+ */
258
+ async function resolvePeFacts(tokens, deps) {
259
+ if (tokens.length === 0)
260
+ return [];
261
+ const opened = deps.openPeStore();
262
+ if (!opened.ok)
263
+ throw new Error(`Cannot present PEs: ${opened.detail}`);
264
+ const facts = [];
265
+ let archive;
266
+ for (const token of tokens) {
267
+ const peId = token.split(':')[0];
268
+ if (archive === undefined && deps.openArchive && (await opened.store.findPe(peId)) === null && (await opened.store.findArchived?.(peId))) {
269
+ archive = (await deps.openArchive()) ?? undefined;
270
+ }
271
+ const r = await (0, agent_sdk_1.peFactFromStore)(opened.store, token, archive);
272
+ if (!r.ok)
273
+ throw new Error(`Cannot present: ${r.detail}`);
274
+ facts.push(r.fact);
275
+ }
276
+ return facts;
277
+ }
278
+ function parseTtl(flags) {
279
+ const raw = str(flags, 'ttl');
280
+ if (raw === undefined)
281
+ return undefined;
282
+ const n = Number(raw);
283
+ if (!Number.isInteger(n) || n < agent_sdk_1.CHALLENGE_MIN_TTL_SECONDS || n > agent_sdk_1.CHALLENGE_MAX_TTL_SECONDS) {
284
+ throw new Error(`--ttl must be a whole number of seconds from ${agent_sdk_1.CHALLENGE_MIN_TTL_SECONDS} to ${agent_sdk_1.CHALLENGE_MAX_TTL_SECONDS}`);
285
+ }
286
+ return n;
287
+ }
288
+ function parseTier(flags) {
289
+ const t = flags.tier;
290
+ if (t === undefined)
291
+ return undefined;
292
+ if (t === 'reputation' || t === 'pe_fact')
293
+ return t;
294
+ throw new Error('--tier must be reputation or pe_fact');
295
+ }
296
+ /**
297
+ * Parse `--challenge-json` (inline JSON or @file). Accepts the bare wire
298
+ * envelope or the object `provian challenge` prints (whose `challenge` field is
299
+ * the envelope). Structural only — the caller verifies it.
300
+ */
301
+ function parseChallengeArg(value) {
302
+ let obj = readJsonArg(value, 'challenge-json');
303
+ if (typeof obj === 'object' && obj !== null && !Array.isArray(obj)) {
304
+ const inner = obj.challenge;
305
+ if (typeof inner === 'object' && inner !== null && !Array.isArray(inner))
306
+ obj = inner;
307
+ }
308
+ const env = (0, agent_sdk_1.parseChallengeEnvelope)(obj);
309
+ if (!env)
310
+ throw new Error('--challenge-json is not a well-formed challenge ({audience, challenge, predicates?} or a signed provian-challenge-v1 envelope)');
311
+ return env;
312
+ }
313
+ // ---------------------------------------------------------------------------
314
+ // The requester line (A.3) — printed on every presenter path before any burn
315
+ // ---------------------------------------------------------------------------
316
+ function requesterLine(v) {
317
+ switch (v.status) {
318
+ case 'verified':
319
+ return v.requester.type === 'wallet'
320
+ ? `Requester: ${v.requester.id} (${v.requester.address}) — VERIFIED`
321
+ : `Requester: ${v.requester.id} — VERIFIED`;
322
+ case 'unverified':
323
+ return `Requester: ${v.envelope.audience} — UNVERIFIED (unsigned challenge)`;
324
+ case 'expired':
325
+ return `Requester: ${v.requester.id} — REFUSED (challenge expired; nothing burned)`;
326
+ case 'not_addressed':
327
+ return `Requester: ${v.requester.id} — REFUSED (challenge is addressed to a different presenter; nothing burned)`;
328
+ default:
329
+ return `Requester: ${v.envelope?.audience ?? 'unknown'} (claimed) — REFUSED (invalid signed challenge: ${v.reason}; nothing burned)`;
330
+ }
331
+ }
332
+ function isChallengeRefused(err) {
333
+ return typeof err === 'object' && err !== null
334
+ && (err.code === 'CHALLENGE_REFUSED' || err.name === 'ChallengeRefusedError')
335
+ && typeof err.verdict === 'object';
336
+ }
337
+ function refusalResult(err, deps, declineNote) {
338
+ const v = err.verdict;
339
+ const line = requesterLine(v);
340
+ if (err.declined) {
341
+ return {
342
+ status: 'error',
343
+ refused: true,
344
+ declined: true,
345
+ burned: false,
346
+ requester: line,
347
+ verdict: v.status,
348
+ error: declineNote ?? 'Declined — nothing was burned.',
349
+ };
350
+ }
351
+ deps.log(line);
352
+ return {
353
+ status: 'error',
354
+ refused: true,
355
+ burned: false,
356
+ requester: line,
357
+ verdict: v.status,
358
+ ...(v.status === 'invalid' ? { reason: v.reason } : {}),
359
+ error: `${line}`,
360
+ };
361
+ }
362
+ // ---------------------------------------------------------------------------
363
+ // provian challenge — issue a SIGNED challenge (requester step 1)
364
+ // ---------------------------------------------------------------------------
365
+ async function cmdPresentationChallenge(flags, lists = {}, depsIn) {
366
+ if (flags.help) {
367
+ printPresentationHelp();
368
+ return null;
369
+ }
370
+ const deps = withDefaults(depsIn);
371
+ try {
372
+ const predicates = collectPredicates(flags, lists);
373
+ const disclosures = collectDisclosures(flags);
374
+ const ttlSeconds = parseTtl(flags);
375
+ const presenter = str(flags, 'presenter');
376
+ const audience = str(flags, 'audience');
377
+ const unsigned = flags.unsigned === true;
378
+ const domainRaw = str(flags, 'domain');
379
+ const keyFile = str(flags, 'key-file');
380
+ let env;
381
+ let signer;
382
+ if (domainRaw !== undefined || keyFile !== undefined) {
383
+ if (unsigned)
384
+ throw new Error('--unsigned cannot be combined with --domain/--key-file');
385
+ if (domainRaw === undefined || keyFile === undefined) {
386
+ throw new Error('Domain signing needs both --domain <host> and --key-file <pem> (make one with: provian requester-key --domain <host> --out <path>)');
387
+ }
388
+ const domain = domainRaw.toLowerCase();
389
+ if (audience !== undefined && audience !== domain)
390
+ throw new Error('A domain-signed challenge\'s audience is the domain itself (drop --audience)');
391
+ const kid = str(flags, 'kid') ?? exports.DEFAULT_REQUESTER_KID;
392
+ const privateKeyPem = (0, fs_1.readFileSync)(keyFile, 'utf8');
393
+ env = (0, agent_sdk_1.issuePresentationChallenge)({ requester: { domain, kid, privateKeyPem }, predicates, ...(disclosures.length > 0 ? { disclosures } : {}), presenter, ttlSeconds });
394
+ signer = `${domain} — SIGNED (domain key ${kid}; presenters verify it at https://${domain}${agent_sdk_1.REQUESTER_WELL_KNOWN_PATH})`;
395
+ }
396
+ else if (unsigned) {
397
+ const aud = audience ?? process.env.PROVIAN_AGENT_WALLET_ID;
398
+ if (!aud)
399
+ throw new Error('An --unsigned challenge needs --audience <your-id>');
400
+ env = (0, agent_sdk_1.issuePresentationChallenge)({ audience: aud, predicates, ...(disclosures.length > 0 ? { disclosures } : {}), presenter, ttlSeconds });
401
+ signer = 'UNSIGNED — presenters will see this challenge as UNVERIFIED (anyone could have issued it)';
402
+ }
403
+ else {
404
+ const cfg = (0, commons_institutions_commands_1.loadCommonsInstitutionsConfig)();
405
+ if (!cfg) {
406
+ return {
407
+ ...(0, commons_institutions_commands_1.missingCredentialsError)(),
408
+ error: `${String((0, commons_institutions_commands_1.missingCredentialsError)().error)} Or sign as a domain with --domain <host> --key-file <pem> (no Provian account), or pass --unsigned.`,
409
+ };
410
+ }
411
+ const bank = deps.makeInstitutions(cfg);
412
+ env = await bank.issuePresentationChallenge({ predicates, ...(disclosures.length > 0 ? { disclosures } : {}), presenter, ttlSeconds, ...(audience !== undefined ? { audience } : {}) });
413
+ signer = `${cfg.walletId}${env.requester?.address ? ` (${env.requester.address})` : ''} — SIGNED (wallet-signed by the Provian relay)`;
414
+ }
415
+ const signed = (0, agent_sdk_1.isSignedChallenge)(env);
416
+ deps.log(`Challenge: ${signer}`);
417
+ if (flags['envelope-only'] === true)
418
+ return env;
419
+ return {
420
+ status: 'ok',
421
+ signed,
422
+ requester: signer,
423
+ expires_at: env.expiresAt ?? null,
424
+ next: 'Hand the "challenge" object (the wire envelope) to the presenter over any channel; keep it for: provian verify --token <token> --challenge-json <this JSON>',
425
+ challenge: env,
426
+ };
427
+ }
428
+ catch (err) {
429
+ return fail(err);
430
+ }
431
+ }
432
+ // ---------------------------------------------------------------------------
433
+ // provian check-challenge — the pre-burn verdict, no burn (presenter)
434
+ // ---------------------------------------------------------------------------
435
+ async function cmdCheckChallenge(flags, _lists = {}, depsIn) {
436
+ if (flags.help) {
437
+ printPresentationHelp();
438
+ return null;
439
+ }
440
+ const deps = withDefaults(depsIn);
441
+ try {
442
+ const env = parseChallengeArg(requireStr(flags, 'challenge-json', 'Usage: provian check-challenge --challenge-json <json|@file> [--as <your-address>]'));
443
+ let presenterAddress = str(flags, 'as');
444
+ if (presenterAddress === undefined && process.env.PROVIAN_AGENT_PRIVATE_KEY) {
445
+ presenterAddress = (0, agent_sdk_1.deriveAddressFromPrivateKey)(process.env.PROVIAN_AGENT_PRIVATE_KEY);
446
+ }
447
+ const verdict = await (0, agent_sdk_1.verifyChallengeEnvelope)(env, {
448
+ relayUrl: relayUrl(),
449
+ ...(deps.fetchRequesterKeys ? { fetchRequesterKeys: deps.fetchRequesterKeys } : {}),
450
+ ...(deps.fetchFn ? { fetchFn: deps.fetchFn } : {}),
451
+ ...(presenterAddress ? { presenterAddress } : {}),
452
+ });
453
+ const line = requesterLine(verdict);
454
+ deps.log(line);
455
+ const refused = verdict.status === 'invalid' || verdict.status === 'expired' || verdict.status === 'not_addressed';
456
+ const predicates = env.predicates ?? [];
457
+ return {
458
+ status: refused ? 'error' : 'ok',
459
+ verdict: verdict.status,
460
+ ...(verdict.status === 'invalid' ? { reason: verdict.reason } : {}),
461
+ requester: line,
462
+ audience: env.audience,
463
+ predicates,
464
+ disclosures: env.disclosures ?? [],
465
+ tier: predicates.length > 0 || (env.disclosures ?? []).length > 0 ? 'reputation (the challenge names predicates / disclosure requests)' : 'pe_fact or reputation',
466
+ expires_at: env.expiresAt ?? null,
467
+ addressed_to: env.presenter ?? null,
468
+ ...(env.presenter && !presenterAddress ? { note: 'The challenge names a presenter; pass --as <your-address> (or set PROVIAN_AGENT_PRIVATE_KEY) to check it is you.' } : {}),
469
+ burned: false,
470
+ ...(refused ? { error: line } : {}),
471
+ };
472
+ }
473
+ catch (err) {
474
+ return fail(err);
475
+ }
476
+ }
477
+ // ---------------------------------------------------------------------------
478
+ // provian respond — verify → requester line → confirm → burn → present
479
+ // ---------------------------------------------------------------------------
480
+ async function cmdRespond(flags, lists = {}, depsIn) {
481
+ if (flags.help) {
482
+ printPresentationHelp();
483
+ return null;
484
+ }
485
+ const deps = withDefaults(depsIn);
486
+ const cfg = (0, commons_institutions_commands_1.loadCommonsInstitutionsConfig)();
487
+ if (!cfg)
488
+ return (0, commons_institutions_commands_1.missingCredentialsError)();
489
+ try {
490
+ const env = parseChallengeArg(requireStr(flags, 'challenge-json', 'Usage: provian respond --challenge-json <json|@file> [--tier reputation|pe_fact] [--pe <pe_id>]... [--yes]'));
491
+ const tierFlag = parseTier(flags);
492
+ const peTokens = collectPeTokens(flags, lists);
493
+ const predicates = env.predicates ?? [];
494
+ const askedDisclosures = env.disclosures ?? [];
495
+ const tier = tierFlag ?? (predicates.length > 0 || askedDisclosures.length > 0 ? 'reputation' : 'pe_fact');
496
+ if (tier === 'pe_fact' && predicates.length > 0) {
497
+ throw new Error('This challenge names predicates, which only the reputation tier answers — drop --tier pe_fact.');
498
+ }
499
+ if (tier === 'pe_fact' && askedDisclosures.length > 0) {
500
+ throw new Error('This challenge names disclosure requests, which only the reputation tier answers — drop --tier pe_fact.');
501
+ }
502
+ if (tier === 'pe_fact' && peTokens.length === 0) {
503
+ throw new Error('A pe_fact presentation presents specific PEs: pass --pe <pe_id> (repeatable; a PE in this machine\'s store — `provian pes`), or --tier reputation.');
504
+ }
505
+ const peFacts = await resolvePeFacts(peTokens, deps);
506
+ const disclosures = await collectDisclosureAnswers(flags, env, deps);
507
+ const rpcUrl = str(flags, 'rpc-url') ?? (process.env.PROVIAN_BASE_RPC_URL || '');
508
+ if (!rpcUrl)
509
+ throw new Error('Set --rpc-url (or PROVIAN_BASE_RPC_URL) — a Base RPC to broadcast the burn.');
510
+ // resume: a burn already broadcast for this (printed by an earlier run) — present it, never burn again.
511
+ const burnTxHash = str(flags, 'burn-tx');
512
+ const burnTxAmount = str(flags, 'burn-amount-atomic');
513
+ if (burnTxHash && !burnTxAmount)
514
+ throw new Error('--burn-tx needs --burn-amount-atomic');
515
+ if (burnTxAmount && !/^[1-9][0-9]*$/.test(burnTxAmount))
516
+ throw new Error('--burn-amount-atomic must be a positive atomic integer');
517
+ const fromStdin = flags['from-stdin'] === true || flags['from-stdin'] === 'true';
518
+ const privateKeyHex = await (0, sovereign_key_intake_1.resolveSovereignPrivateKey)(flags, deps.stdin);
519
+ if (!privateKeyHex) {
520
+ throw new Error('Set PROVIAN_AGENT_PRIVATE_KEY (or pass --from-stdin and pipe the key) — the sovereign key that burns and signs. It is never accepted on argv.');
521
+ }
522
+ const yes = flags.yes === true;
523
+ const canPrompt = !fromStdin && deps.isInteractive();
524
+ let declineNote;
525
+ let line = '';
526
+ const bank = deps.makeInstitutions(cfg);
527
+ try {
528
+ const out = await bank.respondToChallenge(env, {
529
+ privateKeyHex,
530
+ rpcUrl,
531
+ tier,
532
+ ...(burnTxHash && burnTxAmount ? { burnTx: { txHash: burnTxHash, amountAtomic: burnTxAmount } } : {}),
533
+ ...(!burnTxHash && burnTxAmount ? { burnAmountAtomic: burnTxAmount } : {}),
534
+ ...(peFacts.length > 0 ? { peFacts } : {}),
535
+ ...(disclosures ? { disclosures } : {}),
536
+ ...(deps.fetchRequesterKeys ? { fetchRequesterKeys: deps.fetchRequesterKeys } : {}),
537
+ // Called with an ACCEPTABLE verdict (verified / unverified) BEFORE the burn.
538
+ onRequester: async (verdict) => {
539
+ line = requesterLine(verdict);
540
+ deps.log(line);
541
+ if (yes)
542
+ return true;
543
+ if (!canPrompt) {
544
+ declineNote = 'Confirmation required before burning PVT: re-run with --yes (a non-interactive shell or --from-stdin cannot answer the prompt). Nothing was burned.';
545
+ return false;
546
+ }
547
+ const ok = await deps.confirm(`Burn PVT (the ${tier} floor) and present to this requester? [y/N] `);
548
+ if (!ok)
549
+ declineNote = 'Declined at the prompt — nothing was burned.';
550
+ return ok;
551
+ },
552
+ });
553
+ return {
554
+ status: 'ok',
555
+ requester: line || requesterLine(out.requesterVerdict),
556
+ verdict: out.requesterVerdict.status,
557
+ tier: out.tier,
558
+ token: out.token,
559
+ presentation_id: out.burnId,
560
+ burn_id: out.burnId,
561
+ burn_tx: out.txHash,
562
+ burn_amount_atomic: out.burnAmountAtomic,
563
+ ...(disclosures ? { disclosures: disclosures.map((d) => ({ request: d.request, election: d.election, records: (d.records ?? []).length })) } : {}),
564
+ };
565
+ }
566
+ catch (err) {
567
+ if (isChallengeRefused(err))
568
+ return refusalResult(err, deps, declineNote);
569
+ throw err;
570
+ }
571
+ }
572
+ catch (err) {
573
+ return fail(err);
574
+ }
575
+ }
576
+ // ---------------------------------------------------------------------------
577
+ // provian present — present against an existing burn (verifies first)
578
+ // ---------------------------------------------------------------------------
579
+ async function cmdPresent(flags, lists = {}, depsIn) {
580
+ if (flags.help) {
581
+ printPresentationHelp();
582
+ return null;
583
+ }
584
+ const deps = withDefaults(depsIn);
585
+ const cfg = (0, commons_institutions_commands_1.loadCommonsInstitutionsConfig)();
586
+ if (!cfg)
587
+ return (0, commons_institutions_commands_1.missingCredentialsError)();
588
+ try {
589
+ const privateKeyHex = await (0, sovereign_key_intake_1.resolveSovereignPrivateKey)(flags, deps.stdin);
590
+ if (!privateKeyHex) {
591
+ return { status: 'error', error: 'Set PROVIAN_AGENT_PRIVATE_KEY (or pass --from-stdin and pipe the key) — the sovereign key that signs the presentation binding. It is never accepted on argv.' };
592
+ }
593
+ const burnId = requireStr(flags, 'burn-id', 'Usage: provian present --burn-id <id> --challenge-json <json|@file> [--tier pe_fact|reputation] [--pe <pe_id>]...');
594
+ const envRaw = str(flags, 'challenge-json');
595
+ const env = envRaw !== undefined ? parseChallengeArg(envRaw) : undefined;
596
+ const audienceFlag = str(flags, 'audience');
597
+ const challengeFlag = str(flags, 'challenge');
598
+ if (env) {
599
+ if (audienceFlag !== undefined && audienceFlag !== env.audience)
600
+ throw new Error('--audience does not match the challenge envelope');
601
+ if (challengeFlag !== undefined && challengeFlag !== env.challenge)
602
+ throw new Error('--challenge does not match the challenge envelope');
603
+ }
604
+ const audience = env?.audience ?? requireStr(flags, 'audience', 'Pass --challenge-json <envelope> (preferred), or --audience + --challenge for a legacy unsigned challenge');
605
+ const challenge = env?.challenge ?? requireStr(flags, 'challenge', 'The challenge the requester issued');
606
+ const predicates = env?.predicates ?? [];
607
+ const askedDisclosures = env?.disclosures ?? [];
608
+ const tier = parseTier(flags) ?? (predicates.length > 0 || askedDisclosures.length > 0 ? 'reputation' : 'pe_fact');
609
+ if (tier === 'pe_fact' && predicates.length > 0) {
610
+ throw new Error('This challenge names predicates, which only the reputation tier answers — drop --tier pe_fact.');
611
+ }
612
+ if (tier === 'pe_fact' && askedDisclosures.length > 0) {
613
+ throw new Error('This challenge names disclosure requests, which only the reputation tier answers — drop --tier pe_fact.');
614
+ }
615
+ const disclosures = await collectDisclosureAnswers(flags, env, deps);
616
+ const peTokens = collectPeTokens(flags, lists);
617
+ if (tier === 'pe_fact' && peTokens.length === 0) {
618
+ throw new Error('A pe_fact presentation presents specific PEs: pass --pe <pe_id> (repeatable; a PE in this machine\'s store — `provian pes`), or --tier reputation.');
619
+ }
620
+ const peFacts = await resolvePeFacts(peTokens, deps);
621
+ const bank = deps.makeInstitutions(cfg);
622
+ // Verify BEFORE presenting (presenting consumes the burn). Refused → throws, nothing consumed.
623
+ const probe = env ?? { audience, challenge };
624
+ let verdict;
625
+ try {
626
+ verdict = await bank.checkChallengeBeforeBurn(probe, {
627
+ privateKeyHex,
628
+ ...(deps.fetchRequesterKeys ? { fetchRequesterKeys: deps.fetchRequesterKeys } : {}),
629
+ });
630
+ }
631
+ catch (err) {
632
+ if (isChallengeRefused(err))
633
+ return refusalResult(err, deps);
634
+ throw err;
635
+ }
636
+ const line = requesterLine(verdict);
637
+ deps.log(line);
638
+ const out = await bank.present({
639
+ privateKeyHex,
640
+ tier,
641
+ burnId,
642
+ audience,
643
+ challenge,
644
+ ...(tier === 'pe_fact' ? { peFacts } : { disclosure: { redact: [], predicates: [...predicates] }, ...(disclosures ? { disclosures } : {}) }),
645
+ ...(env && (0, agent_sdk_1.isSignedChallenge)(env) ? { challengeEnvelope: env, requesterVerdict: verdict } : {}),
646
+ });
647
+ return { status: 'ok', requester: line, verdict: verdict.status, tier: out.tier, token: out.token, presentation_id: burnId, ...(disclosures ? { disclosures: disclosures.map((d) => ({ request: d.request, election: d.election, records: (d.records ?? []).length })) } : {}) };
648
+ }
649
+ catch (err) {
650
+ return fail(err);
651
+ }
652
+ }
653
+ // ---------------------------------------------------------------------------
654
+ // provian verify — trustless, accept-once, on-chain by default (requester step 2)
655
+ // ---------------------------------------------------------------------------
656
+ function defaultSeenStorePath(deps) {
657
+ return (0, path_1.join)(deps.homeDir(), '.provian', 'presentations-seen.json');
658
+ }
659
+ async function cmdVerifyPresentation(flags, lists = {}, depsIn) {
660
+ if (flags.help) {
661
+ printPresentationHelp();
662
+ return null;
663
+ }
664
+ const deps = withDefaults(depsIn);
665
+ try {
666
+ const token = requireStr(flags, 'token', 'Usage: provian verify --token <token> --challenge-json <the challenge you issued> (or --audience <id> --challenge <nonce>)');
667
+ const envRaw = str(flags, 'challenge-json');
668
+ const env = envRaw !== undefined ? parseChallengeArg(envRaw) : undefined;
669
+ const audience = str(flags, 'audience');
670
+ const challenge = str(flags, 'challenge');
671
+ if (!env && (audience === undefined || challenge === undefined)) {
672
+ throw new Error('Pass --challenge-json <the challenge you issued>, or both --audience and --challenge.');
673
+ }
674
+ const predicates = collectPredicates(flags, lists);
675
+ const expectedPresenter = str(flags, 'expected-presenter');
676
+ const acceptOnce = flags['accept-again'] !== true;
677
+ const seenPath = str(flags, 'seen-store') ?? defaultSeenStorePath(deps);
678
+ const requireOnchain = flags['no-onchain'] !== true;
679
+ const rpcUrl = str(flags, 'rpc-url') ?? (process.env.PROVIAN_BASE_RPC_URL || undefined);
680
+ const result = await deps.verifyToken(token, {
681
+ ...(env ? { challenge: env } : {}),
682
+ ...(audience !== undefined ? { expectedAudience: audience } : {}),
683
+ ...(challenge !== undefined ? { expectedChallenge: challenge } : {}),
684
+ ...(predicates.length > 0 ? { expectedPredicates: predicates } : {}),
685
+ ...(expectedPresenter !== undefined ? { expectedPresenter } : {}),
686
+ jwksUrl: `${relayUrl()}/v1/present/jwks`,
687
+ ...(rpcUrl ? { rpcUrl } : {}),
688
+ requireOnchain,
689
+ acceptOnce,
690
+ ...(acceptOnce ? { seenStore: (0, agent_sdk_1.createFileSeenStore)(seenPath) } : {}),
691
+ ...(deps.fetchFn ? { fetchFn: deps.fetchFn } : {}),
692
+ });
693
+ if (!result.valid) {
694
+ return {
695
+ status: 'error',
696
+ valid: false,
697
+ reason: result.reason,
698
+ error: result.reason === 'replayed'
699
+ ? `presentation refused: replayed — this presentation was already accepted (seen-store ${seenPath}); pass --accept-again to re-check without the replay guard`
700
+ : `presentation refused: ${result.reason}`,
701
+ };
702
+ }
703
+ return {
704
+ status: 'ok',
705
+ valid: true,
706
+ presentation_id: result.presentationId,
707
+ tier: result.tier,
708
+ presenter_address: result.presenterAddress,
709
+ sub: result.sub,
710
+ requester: result.requester,
711
+ challenge_expires_at: result.challengeExpiresAt,
712
+ onchain_checked: result.onchainChecked,
713
+ ...(result.predicates ? { predicates: result.predicates } : {}),
714
+ ...(result.standing ? { standing: result.standing } : {}),
715
+ accepted_once: acceptOnce,
716
+ ...(acceptOnce ? { seen_store: seenPath } : { note: '--accept-again: the replay guard was OFF for this check' }),
717
+ ...(!requireOnchain ? { onchain_note: '--no-onchain: the pe_fact anchor was NOT checked on Base' } : {}),
718
+ };
719
+ }
720
+ catch (err) {
721
+ return fail(err, { valid: false });
722
+ }
723
+ }
724
+ // ---------------------------------------------------------------------------
725
+ // provian requester-key — a domain requester's Ed25519 key (no Provian account)
726
+ // ---------------------------------------------------------------------------
727
+ async function cmdRequesterKey(flags, _lists = {}, depsIn) {
728
+ if (flags.help) {
729
+ printPresentationHelp();
730
+ return null;
731
+ }
732
+ const deps = withDefaults(depsIn);
733
+ try {
734
+ const domain = requireStr(flags, 'domain', 'Usage: provian requester-key --domain <host> [--kid k1] --out <path>').toLowerCase();
735
+ const out = (0, path_1.resolve)(requireStr(flags, 'out', 'Where to write the private key (PEM, mode 0600)'));
736
+ const kid = str(flags, 'kid') ?? exports.DEFAULT_REQUESTER_KID;
737
+ const force = flags.force === true;
738
+ if ((0, fs_1.existsSync)(out) && !force)
739
+ throw new Error(`${out} already exists — refusing to overwrite a key (pass --force to replace it)`);
740
+ const key = (0, agent_sdk_1.generateRequesterKey)({ kid });
741
+ // Validate the domain with the SDK's own rule by signing a throwaway challenge BEFORE
742
+ // anything is written (throws on a non-hostname).
743
+ const now = Math.floor(Date.now() / 1000);
744
+ (0, agent_sdk_1.signDomainChallenge)({ domain, kid, privateKeyPem: key.privateKeyPem, challenge: '0'.repeat(64), issuedAt: now, expiresAt: now + 900 });
745
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(out), { recursive: true, mode: 0o700 });
746
+ (0, fs_1.writeFileSync)(out, key.privateKeyPem, { mode: 0o600, flag: force ? 'w' : 'wx' });
747
+ (0, fs_1.chmodSync)(out, 0o600); // an overwritten file keeps its old mode; pin it.
748
+ const doc = (0, agent_sdk_1.requesterWellKnownDocument)([key.publicJwk]);
749
+ const publishAt = `https://${domain}${agent_sdk_1.REQUESTER_WELL_KNOWN_PATH}`;
750
+ deps.log(`Publish this at ${publishAt} (application/json, no redirects):`);
751
+ deps.log(JSON.stringify(doc, null, 2));
752
+ return {
753
+ status: 'ok',
754
+ domain,
755
+ kid,
756
+ key_file: out,
757
+ key_file_mode: '0600',
758
+ publish_at: publishAt,
759
+ well_known_document: doc,
760
+ next: `provian challenge --domain ${domain} --key-file ${out} --kid ${kid}`,
761
+ };
762
+ }
763
+ catch (err) {
764
+ return fail(err);
765
+ }
766
+ }
767
+ // ---------------------------------------------------------------------------
768
+ // Help
769
+ // ---------------------------------------------------------------------------
770
+ function printPresentationHelp() {
771
+ console.log(`Burn-to-present — the counterparty trust loop.
772
+
773
+ The requester asks with a SIGNED challenge; the presenter checks who is asking,
774
+ then proves by burning PVT; the requester verifies (once).
775
+
776
+ Most requesters are gates and counterparties Provian does not run; they need no
777
+ Provian account and do not register with Provian. Provian proves the presentation
778
+ is real; the gate decides what it grants, how long it trusts the presenter, and
779
+ when it asks again. One presentation opens the relationship, not one per transaction.
780
+
781
+ REQUESTER
782
+ provian challenge [--predicate <expr>]... [--predicates-json <json|@file>]
783
+ [--presenter <0x address>] [--ttl <seconds>]
784
+ Issue a challenge and print it as JSON. Hand the "challenge" object (the wire
785
+ envelope) to the presenter over any channel. It is SIGNED:
786
+ default wallet-signed by the Provian relay (needs agent
787
+ credentials: PROVIAN_API_KEY/SECRET/AGENT_WALLET_ID);
788
+ the audience is your wallet id
789
+ --domain <host> --key-file <pem> [--kid k1]
790
+ domain-signed locally with your own key — no
791
+ Provian account (make the key with requester-key)
792
+ --unsigned --audience <id> UNSIGNED — presenters see it as UNVERIFIED
793
+ --presenter addresses it to one presenter; --ttl 60..604800 (default 900).
794
+ --envelope-only prints just the wire envelope.
795
+
796
+ provian requester-key --domain <host> [--kid k1] --out <path> [--force]
797
+ Generate a domain requester's Ed25519 key. Writes the private PEM with mode
798
+ 0600 and prints the document to publish at
799
+ https://<host>/.well-known/provian-requester.json (to rotate, publish the new
800
+ key beside the old one).
801
+
802
+ provian verify --token <token> --challenge-json <json|@file>
803
+ [--expected-presenter <0x address|wallet id>] [--predicate <expr>]...
804
+ [--rpc-url <Base RPC>] [--no-onchain] [--accept-again]
805
+ Verify a presentation. TRUSTLESS, no credentials. --challenge-json (the
806
+ challenge you issued) fills audience, challenge, predicates, presenter,
807
+ deadline and requester; or pass --audience + --challenge (+ --predicate).
808
+ ACCEPTS ONCE: a presentation already accepted is refused "replayed"
809
+ (remembered in ~/.provian/presentations-seen.json; --seen-store <path> to
810
+ move it, --accept-again to disable). pe_fact is checked ON-CHAIN on Base by
811
+ default (--rpc-url, default https://mainnet.base.org; --no-onchain opts out).
812
+ Predicates are answered only by the reputation tier. Prints presentation_id,
813
+ requester, predicate results, and standing. Exits non-zero when refused.
814
+
815
+ PRESENTER (every path verifies the challenge BEFORE any burn)
816
+ provian check-challenge --challenge-json <json|@file> [--as <your 0x address>]
817
+ Show who is asking — no burn:
818
+ Requester: <identity> — VERIFIED
819
+ Requester: <audience> — UNVERIFIED (unsigned challenge)
820
+ A signed challenge that is invalid, expired, or addressed to someone else is
821
+ REFUSED (exit non-zero).
822
+
823
+ provian respond --challenge-json <json|@file> [--tier reputation|pe_fact]
824
+ [--pe <pe_id>]... --rpc-url <Base RPC> [--yes]
825
+ verify → print the requester → confirm (skip with --yes) → burn the tier
826
+ floor → present. Prints the token, presentation_id, and the burn tx. Tier
827
+ defaults to reputation when the challenge names predicates, else pe_fact
828
+ (which needs --pe). Refusals exit non-zero and never burn.
829
+ --pe names a PE in THIS machine's store (\`provian pes\`): the relay keeps no
830
+ PE, so the presentation carries the PE and its proof into the day's root on
831
+ Base. Only a PE whose day is anchored can be presented.
832
+
833
+ provian present --burn-id <id> --challenge-json <json|@file>
834
+ [--tier pe_fact|reputation] [--pe <pe_id>]...
835
+ Present against a burn you already made (provian burn). Verifies the
836
+ challenge first. Legacy: --audience + --challenge instead of --challenge-json
837
+ (shown UNVERIFIED).
838
+
839
+ respond / present sign with the sovereign key from PROVIAN_AGENT_PRIVATE_KEY or
840
+ --from-stdin (never argv) and need agent credentials.
841
+
842
+ PREDICATES (--predicate, repeatable; quote them in the shell)
843
+ 'work.total>=10' 'work.total>10' 'work.total<=10' 'work.total<10' 'work.total=10'
844
+ 'standing.adverse_events in:{0}' (membership in a numeric set)
845
+ maps to ops gte, gt, lte, lt, eq, in. Or --predicates-json
846
+ '[{"field":"work.total","op":"gte","threshold":10}]' (or @file).
847
+
848
+ The presentation binds to the exact (audience, challenge) you issued and is
849
+ accepted once, so it can never be replayed to another requester or moment.`);
850
+ }
851
+ //# sourceMappingURL=presentation-commands.js.map