@bachsproof/cli 1.1.0 → 2.0.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.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/init.ts","../src/runner.ts","../src/cli.ts"],"names":["resolve"],"mappings":";;;;;;;;AAIA,IAAM,cAAA,GAAiB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AA4CvB,IAAM,YAAA,GAAe,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA,CAAA;AA+DrB,IAAM,aAAA,GAAgB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAiCtB,IAAM,gBAAA,GAAmB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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BAAA,CAAuB,KAAK,CAAA,EAAG,MAAA,CAAO,OAAA,EAAS,MAAM,CAAA,CAAE,UAAA,CAAW,IAAA,EAAM,MAAM,CAAC,CAAA,CAAE,CAAA;AAAA,MAC3G;AAAA,IACF;AACA,IAAA,OAAA,CAAQ,GAAA,CAAI,YAAY,OAAA,CAAQ,MAAM,IAAI,OAAA,CAAQ,KAAK,CAAA,SAAA,EAAY,OAAA,CAAQ,MAAM,CAAA,SAAA,EAAY,QAAQ,mBAAmB,CAAA,uBAAA,EAA0B,QAAQ,qBAAqB,CAAA,aAAA,EAAgB,QAAQ,mBAAmB,CAAA,uBAAA,EAA0B,OAAA,CAAQ,UAAU,CAAA,EAAA,CAAI,CAAA;AAC1Q,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,OAAA,CAAQ,IAAI,4HAA4H,CAAA;AAAA,IAC1I;AAAA,EACF;AACA,EAAA,OAAO,SAAS,CAAA,GAAI,CAAA;AACtB;AAEA,IAAA,EAAK,CAAE,IAAA,CAAK,CAAC,IAAA,KAAS;AACpB,EAAA,OAAA,CAAQ,QAAA,GAAW,IAAA;AACrB,CAAC,CAAA,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC3B,EAAA,OAAA,CAAQ,KAAA,CAAM,sBAAA,CAAuB,KAAK,CAAC,CAAA;AAC3C,EAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AACrB,CAAC,CAAA","file":"cli.js","sourcesContent":["import { access, mkdir, writeFile } from \"node:fs/promises\";\nimport { constants } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\nconst configTemplate = `/**\n * BachsProof test configuration.\n *\n * Follow the two application-specific steps:\n * 1. createPayment prepares a fresh test payment or order;\n * 2. verify reads the committed payment and ledger state.\n *\n * Both helpers are test-only. BachsProof does not add routes or modify the\n * production application.\n */\nimport { bachsAdapter } from \"@bachsproof/cli\";\nimport { tests } from \"./tests/bachsproof.test.mjs\";\n\nconst provider = bachsAdapter({ mode: \"mock\" });\nconst target = {\n baseUrl: process.env.BACHSPROOF_TARGET_URL ?? \"http://127.0.0.1:3000\",\n webhookPath: process.env.BACHSPROOF_WEBHOOK_PATH ?? \"/webhooks/bachs\"\n};\n\nconst signingSecret = process.env.BACHS_WEBHOOK_SECRET;\nconst signing = signingSecret ? { type: \"bachs\", secret: signingSecret } : undefined;\n\n// Uncomment after implementing tests/bachsproof.setup.mjs.\n// import { createPayment } from \"./tests/bachsproof.setup.mjs\";\n\n// Uncomment after implementing tests/bachsproof.verify.mjs.\n// import { verify } from \"./tests/bachsproof.verify.mjs\";\n\nexport default {\n provider,\n target,\n ...(signing ? { signing } : {}),\n // createPayment,\n // verify,\n // requireFinancialVerification: true,\n // financialVerification: {\n // completionDeadlineMs: 10_000,\n // pollIntervalMs: 25,\n // negativeObservationWindowMs: 250\n // },\n tests\n};\n`;\n\nconst testTemplate = `/**\n * BachsProof scenarios.\n *\n * Real application references are the default. Implement createPayment in\n * bachsproof.setup.mjs to create fresh test records automatically, or put an\n * explicit reference on a selected test. Synthetic references are only for\n * isolated fixture tests.\n *\n * Run one: pnpm exec bachsproof test --name \"sequential duplicate webhook\"\n * Run all: pnpm exec bachsproof test\n */\nconst amountMinor = Number(process.env.BACHSPROOF_AMOUNT_MINOR ?? 5_000_000);\nconst currency = process.env.BACHSPROOF_CURRENCY ?? \"NGN\";\nconst syntheticReferences = process.env.BACHSPROOF_USE_SYNTHETIC_REFERENCES === \"true\";\n\nexport const tests = [\n // Same successful payment twice in sequence: tests idempotency.\n { name: \"sequential duplicate webhook\", scenario: \"sequential-duplicate-webhook\", amountMinor, currency, syntheticReferences },\n\n // Same successful payment concurrently: tests duplicate-credit races.\n { name: \"concurrent duplicate credit\", scenario: \"concurrent-duplicate-credit\", concurrency: 3, amountMinor, currency, syntheticReferences },\n\n // Distinct payments concurrently: tests cross-payment interference.\n { name: \"concurrent unique payments\", scenario: \"concurrent-unique-payments\", amountMinor, currency, syntheticReferences },\n\n // checkout.completed plus collection.succeeded for one payment.\n { name: \"cross-event duplicate payment\", scenario: \"cross-event-duplicate-payment\", amountMinor, currency, syntheticReferences },\n\n // Newer success followed by older expiry: tests state ordering.\n { name: \"out-of-order events\", scenario: \"out-of-order-events\", amountMinor, currency, syntheticReferences },\n\n // Expiry followed by delayed success: tests eventual payment confirmation.\n { name: \"delayed payment confirmation\", scenario: \"delayed-payment-confirmation\", delayMs: 50, amountMinor, currency, syntheticReferences },\n\n // Completed checkout without a collected payment: must not credit.\n { name: \"incomplete checkout\", scenario: \"incomplete-checkout\", amountMinor, currency, syntheticReferences },\n\n // Expired checkout: must not credit.\n { name: \"expired checkout\", scenario: \"expired-checkout\", amountMinor, currency, syntheticReferences },\n\n // Changed body after signing: normally expects a 4xx rejection.\n { name: \"tampered webhook\", scenario: \"tampered-webhook\", expectedStatus: \"4xx\", amountMinor, currency, syntheticReferences },\n\n // Invalid signature: normally expects a 4xx rejection.\n { name: \"invalid webhook signature\", scenario: \"invalid-webhook-signature\", expectedStatus: \"4xx\", amountMinor, currency, syntheticReferences },\n\n // Malformed JSON: normally expects a 4xx rejection.\n { name: \"malformed webhook\", scenario: \"malformed-webhook\", expectedStatus: \"4xx\", amountMinor, currency, syntheticReferences },\n\n // Successful-looking event with the wrong amount: must not credit.\n { name: \"incorrect payment amount\", scenario: \"incorrect-payment-amount\", amountMinor, currency, syntheticReferences },\n\n // Successful-looking event with the wrong currency: must not credit.\n { name: \"incorrect payment currency\", scenario: \"incorrect-payment-currency\", amountMinor, currency, syntheticReferences },\n\n // Underpaid collection: must not credit before the shortfall is paid.\n { name: \"underpaid payment\", scenario: \"underpaid-payment\", amountMinor, currency, syntheticReferences },\n\n // Failed collection: must not credit.\n { name: \"failed payment\", scenario: \"failed-payment\", amountMinor, currency, syntheticReferences }\n];\n`;\n\nconst setupTemplate = `/**\n * Create isolated application payment records for BachsProof.\n *\n * This callback is optional when tests provide real references directly. It is\n * recommended for repeatedly running the complete suite.\n *\n * BachsProof calls it only for selected scenarios that need a reference. Every\n * call must create a fresh test payment or order and return its reference.\n * It must not charge a card, call a live provider, or move real money.\n *\n * Context: scenario, amountMinor, currency, paymentIndex, paymentCount.\n *\n * Use an existing isolated test API, application service, ORM, or seed helper.\n */\nexport async function createPayment(context) {\n throw new Error(\n \"Implement createPayment in tests/bachsproof.setup.mjs. \" +\n \"Create an isolated test payment and return its fresh reference for \" +\n context.scenario + \" (\" + (context.paymentIndex + 1) + \" of \" +\n context.paymentCount + \").\"\n );\n\n // Example:\n // const payment = await testSupport.createPayment({\n // scenario: context.scenario,\n // amountMinor: context.amountMinor,\n // currency: context.currency,\n // paymentIndex: context.paymentIndex\n // });\n // return payment.reference;\n}\n`;\n\nconst verifierTemplate = `/**\n * Read committed financial state for BachsProof.\n *\n * HTTP 200 only proves that the webhook route acknowledged a request. This\n * callback must read the payment and actual credit or ledger records.\n * Do not return hardcoded expected values.\n *\n * Return reference, creditCount, creditedAmountMinor, currency, and optional\n * status, pending, and ledgerEntries fields.\n */\nexport async function verify(reference, context) {\n throw new Error(\n \"Implement verify in tests/bachsproof.verify.mjs by reading committed \" +\n \"financial records for \" + reference + \" before enabling it.\"\n );\n\n // Example:\n // const state = await testSupport.readCommittedFinancialState(reference);\n // return {\n // reference,\n // creditCount: state.credits.length,\n // creditedAmountMinor: state.credits.reduce(\n // (total, credit) => total + credit.amountMinor,\n // 0\n // ),\n // currency: state.currency,\n // status: state.status,\n // pending: state.pending,\n // ledgerEntries: state.credits\n // };\n}\n`;\n\nasync function exists(path: string): Promise<boolean> {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\nexport async function initProject(directory = process.cwd(), force = false): Promise<string[]> {\n const root = resolve(directory);\n const configPath = join(root, \"bachsproof.config.mjs\");\n const testDirectory = join(root, \"tests\");\n const testPath = join(testDirectory, \"bachsproof.test.mjs\");\n const setupPath = join(testDirectory, \"bachsproof.setup.mjs\");\n const verifierPath = join(testDirectory, \"bachsproof.verify.mjs\");\n const paths = [configPath, testPath, setupPath, verifierPath];\n if (!force) {\n const existing = [];\n for (const path of paths) if (await exists(path)) existing.push(path);\n if (existing.length > 0) {\n throw new Error(\"Refusing to overwrite existing BachsProof files: \" + existing.join(\", \") + \". Use --force to replace them.\");\n }\n }\n await mkdir(testDirectory, { recursive: true });\n await writeFile(configPath, configTemplate, \"utf8\");\n await writeFile(testPath, testTemplate, \"utf8\");\n await writeFile(setupPath, setupTemplate, \"utf8\");\n await writeFile(verifierPath, verifierTemplate, \"utf8\");\n return paths;\n}\n","import { createJiti } from \"jiti\";\nimport { resolve } from \"node:path\";\nimport { BachsProof, type PaymentEvent, type PaymentReferenceCreator, type ProviderAdapter } from \"@bachsproof/core\";\nimport { signBachsWebhook } from \"@bachsproof/bachs\";\nimport type { BachsProofCliRun, BachsProofConfig, BachsProofSummary, RunConfigOptions } from \"./types.js\";\n\nfunction assertConfig(value: unknown): asserts value is BachsProofConfig {\n if (!value || typeof value !== \"object\") throw new Error(\"BachsProof config must export a default object\");\n const config = value as Partial<BachsProofConfig>;\n if (!config.provider || typeof config.provider !== \"object\") throw new Error(\"BachsProof config requires a provider adapter\");\n if (!config.target || typeof config.target !== \"object\" || typeof config.target.baseUrl !== \"string\" || typeof config.target.webhookPath !== \"string\") {\n throw new Error(\"BachsProof config requires target.baseUrl and target.webhookPath\");\n }\n if (!Array.isArray(config.tests) || config.tests.length === 0) throw new Error(\"BachsProof config requires at least one test\");\n}\n\n/** Load .mjs, .js, .cjs, or TypeScript config without requiring a repo-local loader. */\nexport async function loadConfig(configPath = \"bachsproof.config.mjs\"): Promise<BachsProofConfig> {\n const absolutePath = resolve(process.cwd(), configPath);\n const jiti = createJiti(absolutePath, { interopDefault: true });\n const loaded = await jiti.import(absolutePath, { default: true }) as unknown;\n assertConfig(loaded);\n return loaded;\n}\n\nfunction withBachsSigning<TEvent extends PaymentEvent>(provider: ProviderAdapter<TEvent>, config: BachsProofConfig<TEvent>): ProviderAdapter<TEvent> {\n if (!config.signing) return provider;\n if (config.signing.type !== \"bachs\") throw new Error(`Unsupported signing type ${String(config.signing.type)}`);\n if (!config.signing.secret) throw new Error(\"Bachs signing is configured but its secret is empty\");\n return {\n ...provider,\n headers(event) {\n const rawBody = provider.serialize(event);\n return {\n ...(provider.headers?.(event) ?? {}),\n ...signBachsWebhook(rawBody, config.signing?.secret ?? \"\", config.signing?.timestamp)\n };\n },\n headersForBody(event, body) {\n return {\n ...(provider.headersForBody?.(event, body) ?? provider.headers?.(event) ?? {}),\n ...signBachsWebhook(body, config.signing?.secret ?? \"\", config.signing?.timestamp)\n };\n }\n };\n}\n\nexport async function runConfig(config: BachsProofConfig, options: RunConfigOptions = {}): Promise<BachsProofCliRun[]> {\n const tests = options.testName ? config.tests.filter((test) => test.name === options.testName) : config.tests;\n if (tests.length === 0) throw new Error(options.testName ? `No BachsProof test named ${options.testName}` : \"BachsProof config contains no tests\");\n if (config.requireFinancialVerification && !config.verify) {\n throw new Error(\"Financial verification is required, but the config has no verify callback\");\n }\n\n const provider = withBachsSigning(config.provider, config);\n const results: BachsProofCliRun[] = [];\n const usedReferences = new Set<string>();\n for (const test of tests) {\n const { name, ...runOptions } = test;\n const normalizedRunOptions = {\n ...runOptions,\n ...(runOptions.reference !== undefined ? { reference: typeof runOptions.reference === \"string\" ? runOptions.reference.trim() : runOptions.reference } : {}),\n ...(runOptions.references !== undefined ? { references: runOptions.references.map((reference) => typeof reference === \"string\" ? reference.trim() : reference) } : {})\n };\n const explicitReferences = normalizedRunOptions.scenario === \"concurrent-unique-payments\"\n ? normalizedRunOptions.references ?? []\n : normalizedRunOptions.reference ? [normalizedRunOptions.reference] : [];\n const normalizedExplicitReferences = explicitReferences.map((reference) => typeof reference === \"string\" ? reference.trim() : reference);\n const conflictingReference = normalizedExplicitReferences.find((reference) => typeof reference === \"string\" && usedReferences.has(reference));\n let preparationFailure: string | undefined;\n if (conflictingReference) {\n preparationFailure = `Payment preparation failed for ${runOptions.scenario}: reference ${conflictingReference} is already assigned to another selected scenario`;\n } else {\n for (const reference of normalizedExplicitReferences) {\n if (typeof reference === \"string\" && reference.trim().length > 0) usedReferences.add(reference.trim());\n }\n }\n const createPayment: PaymentReferenceCreator | undefined = preparationFailure\n ? async () => { throw new Error(preparationFailure); }\n : config.createPayment\n ? async (context) => {\n const reference = await config.createPayment?.(context);\n if (typeof reference !== \"string\" || reference.trim().length === 0) return reference as string;\n const normalized = reference.trim();\n if (usedReferences.has(normalized)) {\n throw new Error(`reference ${normalized} is already assigned to another selected scenario`);\n }\n usedReferences.add(normalized);\n return normalized;\n }\n : undefined;\n const runner = new BachsProof({\n provider,\n target: config.target,\n createPayment,\n verify: config.verify,\n financialVerification: config.financialVerification,\n checkpoint: config.checkpoint\n });\n const input = preparationFailure\n ? { ...normalizedRunOptions, reference: undefined, references: undefined, syntheticReferences: false }\n : normalizedRunOptions;\n const result = await runner.run(input);\n if (config.requireFinancialVerification && !result.report.financiallyVerified) {\n result.report.errors.push(\"Financial verification was required but did not run\");\n result.passed = false;\n }\n results.push({ name, result });\n }\n return results;\n}\n\nexport function summarizeRuns(results: BachsProofCliRun[]): BachsProofSummary {\n const durationMs = results.reduce((total, { result }) => {\n if (!result.report.completedAt) return total;\n return total + Math.max(0, Date.parse(result.report.completedAt) - Date.parse(result.report.startedAt));\n }, 0);\n return {\n total: results.length,\n passed: results.filter(({ result }) => result.passed).length,\n failed: results.filter(({ result }) => !result.passed).length,\n financiallyVerified: results.filter(({ result }) => result.report.financiallyVerified).length,\n financiallyUnverified: results.filter(({ result }) => !result.report.financiallyVerified).length,\n financialViolations: results.reduce((total, { result }) => total + (result.report.verification?.violations.length ?? 0), 0),\n durationMs\n };\n}\n\n","import { resolve } from \"node:path\";\nimport { initProject } from \"./init.js\";\nimport { loadConfig, runConfig, summarizeRuns } from \"./runner.js\";\n\nfunction usage(): string {\n return `BachsProof payment correctness testing\n\nUsage:\n bachsproof init [directory] [--force]\n bachsproof test [--config <path>] [--name <test-name>] [--json]\n\ninit creates bachsproof.config.mjs, tests/bachsproof.test.mjs,\ntests/bachsproof.setup.mjs, and a hard-fail tests/bachsproof.verify.mjs template.\ntest sends configured provider events to the target webhook and reports delivery\nand, when configured, committed financial verification results.\n`;\n}\n\nfunction explainOnboardingError(error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"Refusing to overwrite existing BachsProof files\")) {\n return `${message}\\nOpen the listed files if you want to keep them, or run \"bachsproof init --force\" only when replacing them is intentional.`;\n }\n if (message.includes(\"real application reference is required\") || message.includes(\"A real application reference is required\")) {\n return `${message}\\nOpen tests/bachsproof.setup.mjs and implement createPayment, or add a real reference to the selected test. Use BACHSPROOF_USE_SYNTHETIC_REFERENCES=true only for an isolated fixture run.`;\n }\n if (message.includes(\"Payment preparation failed\") || message.includes(\"createPayment must return\")) {\n return `${message}\\nOpen tests/bachsproof.setup.mjs. Create an isolated test payment and return its non-empty order or payment reference. BachsProof will not send a webhook until preparation succeeds.`;\n }\n if (message.includes(\"already assigned to another selected scenario\")) {\n return `${message}\\nOpen tests/bachsproof.setup.mjs or tests/bachsproof.test.mjs and make each selected scenario use a fresh payment reference.`;\n }\n if (message.includes(\"Financial verification is required\")) {\n return `${message}\\nOpen tests/bachsproof.verify.mjs, implement verify(reference, context) by reading committed financial records, then enable verify and requireFinancialVerification in bachsproof.config.mjs.`;\n }\n if (message.includes(\"requires target.baseUrl\") || message.includes(\"requires a provider adapter\") || message.includes(\"requires at least one test\")) {\n return `${message}\\nOpen bachsproof.config.mjs and follow its numbered STEP sections. The provider, target URL/path, and tests are required.`;\n }\n if (message.includes(\"Financial verification returned\")) {\n return `${message}\\nOpen tests/bachsproof.verify.mjs and return the requested reference plus the actual creditCount, creditedAmountMinor, and currency from committed test data.`;\n }\n if (message.includes(\"Webhook delivery\") && message.includes(\"HTTP 4\")) {\n return `${message}\\nOpen bachsproof.config.mjs STEP 2 and check BACHSPROOF_TARGET_URL, BACHSPROOF_WEBHOOK_PATH, and BACHS_WEBHOOK_SECRET. Your application may also be rejecting the test event as expected; set expectedStatus in tests/bachsproof.test.mjs when that rejection is part of the scenario.`;\n }\n if (message.includes(\"Webhook delivery\") && message.includes(\"HTTP 5\")) {\n return `${message}\\nOpen your application's test webhook handler and logs. The application returned a server error while handling the simulated event.`;\n }\n if (message.includes(\"No BachsProof test named\")) {\n return `${message}\\nOpen tests/bachsproof.test.mjs and copy the exact value from the test's name property, for example \"sequential duplicate webhook\".`;\n }\n return message;\n}\n\nfunction printInitializationGuide(): void {\n console.log(`\nBachsProof initialized successfully!\n\nWHAT IS BACHSPROOF?\nBachsProof sends simulated payment webhooks to your application and checks\nwhether your application handles money correctly. It does not move real money.\n\nGET STARTED\n\nStep 1: Open bachsproof.config.mjs\n Set your application's base URL, webhook path, and test-only signing secret.\n\nStep 2: Open tests/bachsproof.setup.mjs\n Show BachsProof how to create an isolated test payment and return its reference.\n This is optional when you provide references manually in the test file.\n\nStep 3: Open tests/bachsproof.verify.mjs\n Show BachsProof how to read the actual payment and credit records from your test data.\n\nStep 4: Enable the two functions\n Uncomment createPayment in bachsproof.config.mjs. If you want financial\n correctness checks, also uncomment verify and requireFinancialVerification.\n\nStep 5: Run your first test\n pnpm exec bachsproof test --name \"sequential duplicate webhook\"\n\nStep 6: Run all payment scenarios\n pnpm exec bachsproof test\n\nIMPORTANT\nOnly use BachsProof against an isolated test environment.\nNever send simulated payment webhooks to a production application.\n`);\n}\n\nfunction valueAfter(args: string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n if (index >= 0) return args[index + 1];\n const inline = args.find((arg) => arg.startsWith(`${flag}=`));\n if (!inline) return undefined;\n return inline.slice(flag.length + 1).replace(/^(\"|')(.*)\\1$/, \"$2\");\n}\n\nfunction has(args: string[], flag: string): boolean {\n return args.includes(flag);\n}\n\nfunction redact(value: string, secret?: string): string {\n return secret ? value.replaceAll(secret, \"[redacted]\") : value;\n}\n\nexport async function main(args = process.argv.slice(2)): Promise<number> {\n const command = args[0];\n if (!command || command === \"--help\" || command === \"-h\") {\n console.log(usage());\n return 0;\n }\n if (command === \"init\") {\n const directory = args.find((arg, index) => index > 0 && !arg.startsWith(\"-\")) ?? process.cwd();\n const paths = await initProject(directory, has(args, \"--force\"));\n for (const path of paths) console.log(`created ${path}`);\n printInitializationGuide();\n return 0;\n }\n if (command !== \"test\") throw new Error(`Unknown command ${command}\\n\\n${usage()}`);\n\n const configPath = valueAfter(args, \"--config\") ?? \"bachsproof.config.mjs\";\n const testName = valueAfter(args, \"--name\");\n const config = await loadConfig(configPath);\n const results = await runConfig(config, { testName });\n const summary = summarizeRuns(results);\n const failed = results.some(({ result }) => !result.passed);\n if (has(args, \"--json\")) {\n const json = JSON.stringify(results, null, 2);\n console.log(redact(json, config.signing?.secret));\n } else {\n console.log(`BachsProof: ${resolve(configPath)}`);\n for (const { name, result } of results) {\n const verification = result.report.financiallyVerified ? \"financially verified\" : \"delivery-only; financial verification not configured\";\n const duration = result.report.completedAt ? Math.max(0, Date.parse(result.report.completedAt) - Date.parse(result.report.startedAt)) : 0;\n const violations = result.report.verification?.violations.length ?? 0;\n console.log(`${result.passed ? \"PASS\" : \"FAIL\"} ${name} (${verification}; ${duration}ms; ${violations} financial violations)`);\n for (const error of result.report.errors) {\n console.log(` ${redact(explainOnboardingError(error), config.signing?.secret).replaceAll(\"\\n\", \"\\n \")}`);\n }\n }\n console.log(`Summary: ${summary.passed}/${summary.total} passed, ${summary.failed} failed, ${summary.financiallyVerified} financially verified, ${summary.financiallyUnverified} unverified, ${summary.financialViolations} financial violations, ${summary.durationMs}ms`);\n if (!config.verify) {\n console.log(\"WARNING: black-box delivery success is not deterministic race coverage and does not prove committed financial correctness.\");\n }\n }\n return failed ? 1 : 0;\n}\n\nmain().then((code) => {\n process.exitCode = code;\n}).catch((error: unknown) => {\n console.error(explainOnboardingError(error));\n process.exitCode = 1;\n});\n"]}
1
+ {"version":3,"sources":["../src/init.ts","../src/runner.ts","../src/cli.ts"],"names":["resolve"],"mappings":";;;;;;;;AAIA,IAAM,cAAA,GAAiB,CAAA;AAAA;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,EAAA,OAAO,SAAS,CAAA,GAAI,CAAA;AACtB;AAEA,IAAA,EAAK,CAAE,IAAA,CAAK,CAAC,IAAA,KAAS;AACpB,EAAA,OAAA,CAAQ,QAAA,GAAW,IAAA;AACrB,CAAC,CAAA,CAAE,KAAA,CAAM,CAAC,KAAA,KAAmB;AAC3B,EAAA,OAAA,CAAQ,KAAA,CAAM,YAAA,CAAa,KAAK,CAAC,CAAA;AACjC,EAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AACrB,CAAC,CAAA","file":"cli.js","sourcesContent":["import { access, writeFile } from \"node:fs/promises\";\nimport { constants } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\nconst configTemplate = `/**\n * BachsProof v2 configuration.\n *\n * Use only an isolated application, test database, queue, and webhook secret.\n * BachsProof creates local simulated events. It never calls Bachs or moves money.\n */\nimport { defineConfig } from \"@bachsproof/cli\";\n\nexport default defineConfig({\n // The complete URL of your isolated application's Bachs webhook route.\n webhookUrl: process.env.BACHSPROOF_WEBHOOK_URL ?? \"http://127.0.0.1:3000/webhooks/bachs\",\n\n // Use a secret that belongs only to your test application.\n secret: process.env.BACHS_WEBHOOK_SECRET ?? \"\",\n\n // 500,000 NGN minor units means NGN 5,000.00.\n amountMinor: 500_000,\n currency: \"NGN\",\n\n // Before BachsProof sends a webhook, create a fresh payment record and\n // return its reference. Replace the example error with your test helper.\n async createPayment({ scenario, amountMinor, currency, paymentIndex, paymentCount }) {\n throw new Error(\n \"Implement createPayment in bachsproof.config.mjs. \" +\n \"Create an isolated test payment and return its non-empty reference for \" +\n scenario + \" (\" + (paymentIndex + 1) + \" of \" + paymentCount + \").\"\n );\n // Example:\n // const payment = await testApplication.createPayment({ amountMinor, currency });\n // return payment.reference;\n },\n\n // Read the application's committed payment and ledger records. Do not return\n // the expected values from this file; return what the database contains.\n async verify(reference) {\n throw new Error(\n \"Implement verify in bachsproof.config.mjs by reading committed \" +\n \"financial records for \" + reference + \".\"\n );\n // Example result:\n // return {\n // reference,\n // creditCount: credits.length,\n // creditedAmountMinor: credits.reduce((sum, credit) => sum + credit.amountMinor, 0),\n // currency: payment.currency,\n // status: payment.status,\n // pending: false,\n // ledgerEntries: credits.map((credit) => ({\n // id: String(credit.id),\n // type: String(credit.type),\n // amountMinor: credit.amountMinor,\n // currency: credit.currency\n // }))\n // };\n }\n\n // Optional: run only selected scenario identifiers. Omit to run all eleven.\n // scenarios: [\"sequential-duplicate-webhook\"],\n\n // Optional: increase this only when your isolated application processes\n // webhooks asynchronously. The default is 10 seconds.\n // verificationTimeoutMs: 10_000\n});\n`;\n\nasync function exists(path: string): Promise<boolean> {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Create exactly one config file and never overwrite it accidentally. */\nexport async function initProject(directory = process.cwd(), force = false): Promise<string[]> {\n const configPath = join(resolve(directory), \"bachsproof.config.mjs\");\n if (!force && await exists(configPath)) {\n throw new Error(`Refusing to overwrite existing BachsProof file: ${configPath}. Use --force only when replacement is intentional.`);\n }\n await writeFile(configPath, configTemplate, \"utf8\");\n return [configPath];\n}\n","import { createJiti } from \"jiti\";\nimport { resolve } from \"node:path\";\nimport { BachsProof, SUPPORTED_SCENARIOS, type PaymentEvent, type PaymentReferenceCreator, type ProviderAdapter, type ScenarioName } from \"@bachsproof/core\";\nimport { bachsAdapter, signBachsWebhook } from \"@bachsproof/bachs\";\nimport type { BachsProofCliRun, BachsProofConfig, BachsProofSummary, RunConfigOptions } from \"./types.js\";\n\nconst SCENARIO_LABELS: Record<ScenarioName, string> = {\n \"sequential-duplicate-webhook\": \"Sequential duplicate webhook\",\n \"concurrent-duplicate-credit\": \"Concurrent duplicate credit\",\n \"concurrent-unique-payments\": \"Concurrent unique payments\",\n \"cross-event-duplicate-payment\": \"Cross-event duplicate payment\",\n \"out-of-order-events\": \"Out-of-order events\",\n \"incomplete-checkout\": \"Incomplete checkout\",\n \"expired-checkout\": \"Expired checkout\",\n \"incorrect-payment-amount\": \"Incorrect payment amount\",\n \"incorrect-payment-currency\": \"Incorrect payment currency\",\n \"underpaid-payment\": \"Underpaid payment\",\n \"failed-payment\": \"Failed payment\"\n};\n\nexport function scenarioLabel(scenario: ScenarioName): string {\n return SCENARIO_LABELS[scenario];\n}\n\nfunction assertConfig(value: unknown): asserts value is BachsProofConfig {\n if (!value || typeof value !== \"object\") throw new Error(\"BachsProof config must export a default object\");\n const config = value as Partial<BachsProofConfig>;\n if (typeof config.webhookUrl !== \"string\" || config.webhookUrl.trim().length === 0) {\n throw new Error(\"BachsProof config requires a complete webhookUrl\");\n }\n try {\n const url = new URL(config.webhookUrl);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") throw new Error(\"webhookUrl must use http or https\");\n } catch (error) {\n throw new Error(`BachsProof config webhookUrl is invalid: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (typeof config.secret !== \"string\" || config.secret.trim().length === 0) {\n throw new Error(\"BachsProof config requires a non-empty test webhook secret\");\n }\n if (!Number.isSafeInteger(config.amountMinor) || (config.amountMinor as number) < 0) {\n throw new Error(\"BachsProof config amountMinor must be a non-negative safe integer\");\n }\n if (typeof config.currency !== \"string\" || !/^[A-Z]{3}$/.test(config.currency)) {\n throw new Error(\"BachsProof config currency must be a three-letter ISO currency code\");\n }\n if (typeof config.createPayment !== \"function\") throw new Error(\"BachsProof config requires a createPayment callback\");\n if (typeof config.verify !== \"function\") throw new Error(\"BachsProof config requires a verify callback\");\n if (config.verificationTimeoutMs !== undefined && (!Number.isSafeInteger(config.verificationTimeoutMs) || config.verificationTimeoutMs < 1)) {\n throw new Error(\"BachsProof config verificationTimeoutMs must be a positive safe integer\");\n }\n if (config.scenarios !== undefined) {\n if (!Array.isArray(config.scenarios) || config.scenarios.length === 0) throw new Error(\"BachsProof config scenarios must contain at least one scenario\");\n for (const scenario of config.scenarios) {\n if (!(SUPPORTED_SCENARIOS as readonly string[]).includes(scenario)) {\n throw new Error(`Unknown BachsProof scenario: ${String(scenario)}`);\n }\n }\n }\n}\n\n/** Load a JavaScript, MJS, CJS, or TypeScript config file. */\nexport async function loadConfig(configPath = \"bachsproof.config.mjs\"): Promise<BachsProofConfig> {\n const absolutePath = resolve(process.cwd(), configPath);\n const jiti = createJiti(absolutePath, { interopDefault: true });\n const loaded = await jiti.import(absolutePath, { default: true }) as unknown;\n assertConfig(loaded);\n return loaded;\n}\n\nfunction withBachsSigning(provider: ProviderAdapter, secret: string): ProviderAdapter {\n return {\n ...provider,\n headers(event) {\n const body = provider.serialize(event);\n return {\n ...(provider.headers?.(event) ?? {}),\n ...signBachsWebhook(body, secret)\n };\n },\n headersForBody(event, body) {\n return {\n ...(provider.headersForBody?.(event, body) ?? provider.headers?.(event) ?? {}),\n ...signBachsWebhook(body, secret)\n };\n }\n };\n}\n\nfunction selectedScenarios(config: BachsProofConfig, testName?: string): ScenarioName[] {\n const scenarios = config.scenarios ?? [...SUPPORTED_SCENARIOS];\n if (!testName) return scenarios;\n const selected = scenarios.find((scenario) => scenarioLabel(scenario) === testName || scenario === testName);\n if (!selected) throw new Error(`Unknown BachsProof scenario or test name \"${testName}\". Use one of: ${scenarios.map(scenarioLabel).join(\", \")}`);\n return [selected];\n}\n\nexport async function runConfig(config: BachsProofConfig, options: RunConfigOptions = {}): Promise<BachsProofCliRun[]> {\n assertConfig(config);\n const scenarios = selectedScenarios(config, options.testName);\n const provider = withBachsSigning(bachsAdapter({ mode: \"mock\" }), config.secret);\n const usedReferences = new Set<string>();\n const createPayment: PaymentReferenceCreator = async (context) => {\n const reference = await config.createPayment(context);\n if (typeof reference !== \"string\" || reference.trim().length === 0) return reference as string;\n const normalized = reference.trim();\n if (usedReferences.has(normalized)) {\n throw new Error(`createPayment returned reference ${normalized}, which was already used by another selected scenario`);\n }\n usedReferences.add(normalized);\n return normalized;\n };\n const runner = new BachsProof({\n provider,\n webhookUrl: config.webhookUrl,\n createPayment,\n verify: config.verify,\n financialVerification: config.verificationTimeoutMs === undefined ? undefined : { completionDeadlineMs: config.verificationTimeoutMs }\n });\n const results: BachsProofCliRun[] = [];\n for (const scenario of scenarios) {\n const result = await runner.run({\n scenario,\n amountMinor: config.amountMinor,\n currency: config.currency\n });\n results.push({ name: scenarioLabel(scenario), scenario, result });\n }\n return results;\n}\n\nexport function summarizeRuns(results: BachsProofCliRun[]): BachsProofSummary {\n const durationMs = results.reduce((total, { result }) => {\n if (!result.report.completedAt) return total;\n return total + Math.max(0, Date.parse(result.report.completedAt) - Date.parse(result.report.startedAt));\n }, 0);\n return {\n total: results.length,\n passed: results.filter(({ result }) => result.passed).length,\n failed: results.filter(({ result }) => !result.passed).length,\n financiallyVerified: results.filter(({ result }) => result.report.financiallyVerified).length,\n financiallyUnverified: results.filter(({ result }) => !result.report.financiallyVerified).length,\n financialViolations: results.reduce((total, { result }) => total + (result.report.verification?.violations.length ?? 0), 0),\n durationMs\n };\n}\n\nexport { bachsAdapter, signBachsWebhook } from \"@bachsproof/bachs\";\n","import { resolve } from \"node:path\";\nimport { initProject } from \"./init.js\";\nimport { loadConfig, runConfig, scenarioLabel, summarizeRuns } from \"./runner.js\";\n\nfunction usage(): string {\n return `BachsProof\nBeyond webhook delivery. Verify financial correctness.\n\nUsage:\n bachsproof init [directory] [--force]\n bachsproof test [--config <path>] [--name <scenario-name>] [--json]\n\ninit creates one bachsproof.config.mjs file.\ntest runs all eleven financial correctness scenarios unless --name or\nscenarios in the config selects a subset.\n`;\n}\n\nfunction explainError(error: unknown): string {\n const message = error instanceof Error ? error.message : String(error);\n if (message.includes(\"Refusing to overwrite existing BachsProof file\")) {\n return `${message}\\nOpen the existing file if you want to keep it. Use --force only when replacement is intentional.`;\n }\n if (message.includes(\"Implement createPayment\")) {\n return `${message}\\nThe callback must create a fresh record in your isolated test application and return its reference.`;\n }\n if (message.includes(\"Implement verify\")) {\n return `${message}\\nThe callback must read committed payment and ledger records. HTTP success alone is not financial proof.`;\n }\n if (message.includes(\"already used\") || message.includes(\"duplicate payment references\")) {\n return `${message}\\nEvery selected scenario needs a fresh isolated payment record.`;\n }\n if (message.includes(\"Unknown BachsProof scenario\")) {\n return `${message}\\nUse the exact scenario identifier from the generated configuration comments.`;\n }\n if (message.includes(\"Webhook delivery\")) {\n return `${message}\\nCheck the isolated webhook URL and application logs. BachsProof still verifies financial state when it is safe to do so.`;\n }\n if (message.includes(\"Financial verification\")) {\n return `${message}\\nCheck that verify() reads the requested reference and reports actual committed financial state.`;\n }\n return message;\n}\n\nfunction printInitializationGuide(): void {\n console.log(`\nBachsProof initialized successfully.\n\nOpen bachsproof.config.mjs and implement two callbacks:\n\n1. createPayment() creates a fresh payment in your isolated test application.\n2. verify() reads the committed payment and ledger records.\n\nThen run:\n pnpm exec bachsproof test --name \"sequential duplicate webhook\"\n pnpm exec bachsproof test\n\nUse a test-only application, database, queue, and webhook secret.\n`);\n}\n\nfunction valueAfter(args: string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n if (index >= 0) return args[index + 1];\n const inline = args.find((arg) => arg.startsWith(`${flag}=`));\n return inline?.slice(flag.length + 1).replace(/^(\"|')(.*)\\1$/, \"$2\");\n}\n\nfunction has(args: string[], flag: string): boolean {\n return args.includes(flag);\n}\n\nfunction redact(value: string, secret: string): string {\n return secret ? value.replaceAll(secret, \"[redacted]\") : value;\n}\n\nfunction reasonFor(report: import(\"@bachsproof/core\").BachsProofReport): string | undefined {\n const violation = report.verification?.violations[0];\n if (violation) {\n switch (violation.id) {\n case \"INV-001\": return \"The same payment was credited more than once.\";\n case \"INV-002\":\n case \"INV-005\": return \"The credited amount or currency does not match the payment.\";\n case \"INV-003\": return \"The successful payment did not produce the required credit.\";\n case \"INV-004\": return \"An ineligible payment created a credit.\";\n }\n }\n return report.errors[0];\n}\n\nfunction formatState(state: import(\"@bachsproof/core\").ObservedPaymentState | undefined): string {\n return state ? `${state.creditCount} credit(s) totalling ${state.creditedAmountMinor} ${state.currency} minor units` : \"not available\";\n}\n\nexport async function main(args = process.argv.slice(2)): Promise<number> {\n const command = args[0];\n if (!command || command === \"--help\" || command === \"-h\") {\n console.log(usage());\n return 0;\n }\n if (command === \"init\") {\n const directory = args.find((arg, index) => index > 0 && !arg.startsWith(\"-\")) ?? process.cwd();\n const paths = await initProject(directory, has(args, \"--force\"));\n for (const path of paths) console.log(`created ${path}`);\n printInitializationGuide();\n return 0;\n }\n if (command !== \"test\") throw new Error(`Unknown command ${command}\\n\\n${usage()}`);\n\n const configPath = valueAfter(args, \"--config\") ?? \"bachsproof.config.mjs\";\n const testName = valueAfter(args, \"--name\");\n const config = await loadConfig(configPath);\n const results = await runConfig(config, { testName });\n const summary = summarizeRuns(results);\n const failed = results.some(({ result }) => !result.passed);\n if (has(args, \"--json\")) {\n console.log(redact(JSON.stringify(results, null, 2), config.secret));\n } else {\n console.log(\"BachsProof\\n\");\n for (const { name, result } of results) {\n const duration = result.report.completedAt ? Math.max(0, Date.parse(result.report.completedAt) - Date.parse(result.report.startedAt)) : 0;\n console.log(`${result.passed ? \"PASS\" : \"FAIL\"} ${name}`);\n if (!result.passed) {\n console.log(` Payment reference: ${result.report.paymentReference}`);\n console.log(` Expected: one credit of ${result.report.expected.amountMinor} ${result.report.expected.currency} minor units when eligible`);\n console.log(` Observed: ${formatState(result.report.observed)}`);\n const reason = reasonFor(result.report);\n if (reason) console.log(` Reason: ${redact(reason, config.secret)}`);\n }\n console.log(` ${result.report.financiallyVerified ? \"Financial verification completed\" : \"Financial verification did not complete\"} (${duration}ms)\\n`);\n }\n console.log(\"Summary\");\n console.log(`${summary.total} scenarios`);\n console.log(`${summary.passed} passed`);\n console.log(`${summary.failed} failed`);\n }\n return failed ? 1 : 0;\n}\n\nmain().then((code) => {\n process.exitCode = code;\n}).catch((error: unknown) => {\n console.error(explainError(error));\n process.exitCode = 1;\n});\n"]}
package/dist/index.d.ts CHANGED
@@ -1,35 +1,29 @@
1
- export { bachsAdapter, signBachsWebhook } from '@bachsproof/bachs';
2
1
  import * as _bachsproof_core from '@bachsproof/core';
3
- import { RunOptions, PaymentEvent, ProviderAdapter, BachsProofTarget, PaymentReferenceCreator, FinancialVerifier, FinancialVerificationOptions } from '@bachsproof/core';
4
- export { PaymentPreparationContext, PaymentReferenceCreator } from '@bachsproof/core';
2
+ import { ScenarioName, PaymentEvent, PaymentReferenceCreator, FinancialVerifier } from '@bachsproof/core';
3
+ export { FinancialVerificationContext, FinancialVerificationInput, FinancialVerifier, PaymentPreparationContext, PaymentReferenceCreator, ScenarioName } from '@bachsproof/core';
5
4
 
6
- interface BachsProofCliTest extends Omit<RunOptions, "scenario"> {
7
- name: string;
8
- scenario: RunOptions["scenario"];
9
- }
10
- interface BachsSigningConfig {
11
- type: "bachs";
12
- secret: string;
13
- timestamp?: number;
14
- }
5
+ /** The only developer-facing configuration supported by BachsProof v2. */
15
6
  interface BachsProofConfig<TEvent extends PaymentEvent = PaymentEvent> {
16
- provider: ProviderAdapter<TEvent>;
17
- target: BachsProofTarget;
18
- tests: BachsProofCliTest[];
19
- /** Optional test-only callback that creates fresh application payments. */
20
- createPayment?: PaymentReferenceCreator;
21
- verify?: FinancialVerifier;
22
- financialVerification?: FinancialVerificationOptions;
23
- checkpoint?: {
24
- name: string;
25
- timeoutMs?: number;
26
- };
27
- signing?: BachsSigningConfig;
28
- /** Fail the CLI when the config has no committed-state verifier. */
29
- requireFinancialVerification?: boolean;
7
+ /** Complete URL of the isolated application's Bachs webhook route. */
8
+ webhookUrl: string;
9
+ /** Test-only secret used to sign every generated webhook automatically. */
10
+ secret: string;
11
+ /** Default integer amount in minor units. */
12
+ amountMinor: number;
13
+ /** Default three-letter ISO currency code. */
14
+ currency: string;
15
+ /** Creates a fresh application payment and returns its reference. */
16
+ createPayment: PaymentReferenceCreator;
17
+ /** Reads the committed payment and ledger state for a prepared reference. */
18
+ verify: FinancialVerifier;
19
+ /** Run a subset; omitted means all eleven scenarios. */
20
+ scenarios?: ScenarioName[];
21
+ /** Increase the default asynchronous financial observation deadline if needed. */
22
+ verificationTimeoutMs?: number;
30
23
  }
31
24
  interface BachsProofCliRun {
32
25
  name: string;
26
+ scenario: ScenarioName;
33
27
  result: _bachsproof_core.BachsProofResult;
34
28
  }
35
29
  interface BachsProofSummary {
@@ -46,13 +40,15 @@ interface RunConfigOptions {
46
40
  }
47
41
 
48
42
  /** Type helper for bachsproof.config.mjs and bachsproof.config.ts files. */
49
- declare function defineConfig<TEvent extends PaymentEvent>(config: BachsProofConfig<TEvent>): BachsProofConfig<TEvent>;
43
+ declare function defineConfig<TEvent extends PaymentEvent = PaymentEvent>(config: BachsProofConfig<TEvent>): BachsProofConfig<TEvent>;
50
44
 
45
+ /** Create exactly one config file and never overwrite it accidentally. */
51
46
  declare function initProject(directory?: string, force?: boolean): Promise<string[]>;
52
47
 
53
- /** Load .mjs, .js, .cjs, or TypeScript config without requiring a repo-local loader. */
48
+ declare function scenarioLabel(scenario: ScenarioName): string;
49
+ /** Load a JavaScript, MJS, CJS, or TypeScript config file. */
54
50
  declare function loadConfig(configPath?: string): Promise<BachsProofConfig>;
55
51
  declare function runConfig(config: BachsProofConfig, options?: RunConfigOptions): Promise<BachsProofCliRun[]>;
56
52
  declare function summarizeRuns(results: BachsProofCliRun[]): BachsProofSummary;
57
53
 
58
- export { type BachsProofCliRun, type BachsProofCliTest, type BachsProofConfig, type BachsProofSummary, type BachsSigningConfig, type RunConfigOptions, defineConfig, initProject, loadConfig, runConfig, summarizeRuns };
54
+ export { type BachsProofCliRun, type BachsProofConfig, type BachsProofSummary, type RunConfigOptions, defineConfig, initProject, loadConfig, runConfig, scenarioLabel, summarizeRuns };