@pome-sh/cli 0.1.1 → 0.3.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/README.md +5 -6
- package/dist/build-info.json +3 -3
- package/dist/src/cli/eval.js +26 -8
- package/dist/src/cli/init-sdk.d.ts +0 -3
- package/dist/src/cli/init-sdk.js +117 -24
- package/dist/src/cli/main.js +23 -69
- package/dist/src/cli/register.d.ts +9 -0
- package/dist/src/cli/register.js +51 -5
- package/dist/src/cli/session.d.ts +7 -1
- package/dist/src/cli/session.js +87 -27
- package/dist/src/demo/first-run-demo.md +3 -3
- package/dist/src/demo/runDemo.js +3 -2
- package/dist/src/hosted/client.d.ts +44 -6
- package/dist/src/hosted/client.js +333 -19
- package/dist/src/hosted/errors.d.ts +11 -1
- package/dist/src/hosted/errors.js +8 -1
- package/dist/src/hosted/evalResultView.d.ts +2 -0
- package/dist/src/hosted/evalResultView.js +22 -0
- package/dist/src/hosted/uploadAndFinalize.d.ts +18 -1
- package/dist/src/hosted/uploadAndFinalize.js +51 -3
- package/dist/src/recorder/inspect.js +20 -2
- package/dist/src/runner/mergeAdapterSignals.js +2 -2
- package/dist/src/runner/ports.js +3 -0
- package/dist/src/runner/runScenario.d.ts +79 -2
- package/dist/src/runner/runScenario.js +94 -36
- package/dist/src/runner/runScenarioHosted.d.ts +37 -0
- package/dist/src/runner/runScenarioHosted.js +261 -61
- package/dist/src/runner/runTrialGroup.d.ts +1 -3
- package/dist/src/runner/runTrialGroup.js +1 -3
- package/dist/src/scenario/parseScenario.d.ts +5 -0
- package/dist/src/scenario/parseScenario.js +149 -10
- package/dist/src/scenario/scenarioSchema.d.ts +200 -3
- package/dist/src/scenario/scenarioSchema.js +16 -4
- package/dist/src/twin/twinHarness.d.ts +11 -1
- package/dist/src/twin/twinHarness.js +7 -3
- package/dist/src/twin/twinStart.d.ts +19 -0
- package/dist/src/twin/twinStart.js +156 -0
- package/node_modules/@pome-sh/sdk/dist/fidelity-inventory.d.ts +121 -0
- package/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js +204 -0
- package/node_modules/@pome-sh/sdk/dist/fidelity-inventory.js.map +1 -0
- package/node_modules/@pome-sh/sdk/dist/parity.d.ts +55 -0
- package/node_modules/@pome-sh/sdk/dist/parity.js +112 -0
- package/node_modules/@pome-sh/sdk/dist/parity.js.map +1 -0
- package/node_modules/@pome-sh/sdk/dist/server-helpers.d.ts +15 -0
- package/node_modules/@pome-sh/sdk/dist/server-helpers.js +96 -0
- package/node_modules/@pome-sh/sdk/dist/server-helpers.js.map +1 -1
- package/node_modules/@pome-sh/sdk/dist/server.d.ts +1 -1
- package/node_modules/@pome-sh/sdk/dist/server.js +9 -7
- package/node_modules/@pome-sh/sdk/dist/server.js.map +1 -1
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/evaluator-hooks.d.ts +13 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/evaluator-hooks.js +6 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/evaluator-hooks.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +215 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +83 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +175 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/github-access-control.js +182 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/index.d.ts +27 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/index.js +34 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +286 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +33 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +65 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +455 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +39 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +47 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +25 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/index.js +27 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +100 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +185 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +64 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +112 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +26 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/nano.js +61 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +42 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/project.js +96 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +51 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +74 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +134 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +152 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +418 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/recorder-events.js +234 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +2 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/redaction.js +152 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/redaction.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/rest.d.ts +198 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/rest.js +225 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/run.d.ts +201 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/run.js +166 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +66 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task-vocab.js +84 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task.d.ts +483 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/package.json +54 -0
- package/node_modules/@pome-sh/sdk/node_modules/@pome-sh/shared-types/trace-contract.json +41 -0
- package/node_modules/@pome-sh/sdk/package.json +6 -2
- package/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +254 -0
- package/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +122 -0
- package/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/index.d.ts +13 -1353
- package/node_modules/@pome-sh/shared-types/dist/index.js +14 -568
- package/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +45 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +8 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +7 -0
- package/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +62 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.js +36 -0
- package/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/rest.d.ts +248 -0
- package/node_modules/@pome-sh/shared-types/dist/rest.js +308 -0
- package/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/run.d.ts +7 -0
- package/node_modules/@pome-sh/shared-types/dist/run.js +5 -1
- package/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +14 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +46 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +15 -1
- package/node_modules/@pome-sh/shared-types/dist/task-vocab.js +15 -1
- package/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +1 -1
- package/node_modules/@pome-sh/shared-types/dist/task.d.ts +485 -0
- package/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/shared-types/package.json +2 -1
- package/node_modules/@pome-sh/shared-types/trace-contract.json +1 -1
- package/node_modules/@pome-sh/twin-github/FIDELITY.md +127 -67
- package/node_modules/@pome-sh/twin-github/README.md +3 -7
- package/node_modules/@pome-sh/twin-github/dist/examples/claude-github-agent.js +4 -20
- package/node_modules/@pome-sh/twin-github/dist/examples/claude-github-agent.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/access-control.d.ts +3 -3
- package/node_modules/@pome-sh/twin-github/dist/src/domain.d.ts +141 -3
- package/node_modules/@pome-sh/twin-github/dist/src/domain.js +0 -0
- package/node_modules/@pome-sh/twin-github/dist/src/domain.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/routes.js +2 -0
- package/node_modules/@pome-sh/twin-github/dist/src/routes.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/seed.d.ts +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/serializers.d.ts +2 -2
- package/node_modules/@pome-sh/twin-github/dist/src/server.js +7 -6
- package/node_modules/@pome-sh/twin-github/dist/src/server.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/dist/src/tools.d.ts +168 -18
- package/node_modules/@pome-sh/twin-github/dist/src/tools.js +23 -0
- package/node_modules/@pome-sh/twin-github/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-github/fidelity.inventory.json +773 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +252 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +122 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +175 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/github-access-control.js +182 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/index.d.ts +27 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/index.js +34 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +331 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +33 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +65 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +455 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +39 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +47 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +25 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/index.js +27 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +100 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +193 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +64 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +112 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +26 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/nano.js +61 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +42 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/project.js +96 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +51 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +81 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +134 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +152 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +480 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/recorder-events.js +270 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +2 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/redaction.js +152 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/redaction.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/rest.d.ts +245 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/rest.js +303 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/run.d.ts +208 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/run.js +170 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +14 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +46 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +66 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/task-vocab.js +84 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/task.d.ts +485 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/package.json +54 -0
- package/node_modules/@pome-sh/twin-github/node_modules/@pome-sh/shared-types/trace-contract.json +41 -0
- package/node_modules/@pome-sh/twin-github/package.json +5 -4
- package/node_modules/@pome-sh/twin-slack/FIDELITY.md +121 -35
- package/node_modules/@pome-sh/twin-slack/README.md +2 -6
- package/node_modules/@pome-sh/twin-slack/dist/scripts/fidelity-parity.d.ts +1 -0
- package/node_modules/@pome-sh/twin-slack/dist/scripts/fidelity-parity.js +92 -0
- package/node_modules/@pome-sh/twin-slack/dist/scripts/fidelity-parity.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/dist/scripts/smoke.js +3 -3
- package/node_modules/@pome-sh/twin-slack/dist/scripts/smoke.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/scripts/validate-mcp.js +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/scripts/validate-mcp.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/src/server.js +7 -6
- package/node_modules/@pome-sh/twin-slack/dist/src/server.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/dist/src/tools.d.ts +30 -4
- package/node_modules/@pome-sh/twin-slack/dist/src/tools.js +48 -1
- package/node_modules/@pome-sh/twin-slack/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-slack/fidelity.inventory.json +377 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +252 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +122 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +175 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/github-access-control.js +182 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/index.d.ts +27 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/index.js +34 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +331 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +33 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +65 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +455 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +39 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +47 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +25 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/index.js +27 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +100 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +193 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +64 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +112 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +26 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/nano.js +61 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +42 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/project.js +96 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +51 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +81 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +134 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +152 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +480 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/recorder-events.js +270 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +2 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/redaction.js +152 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/redaction.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/rest.d.ts +245 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/rest.js +303 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/run.d.ts +208 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/run.js +170 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +14 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +46 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +66 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/task-vocab.js +84 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/task.d.ts +485 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/package.json +54 -0
- package/node_modules/@pome-sh/twin-slack/node_modules/@pome-sh/shared-types/trace-contract.json +41 -0
- package/node_modules/@pome-sh/twin-slack/package.json +5 -4
- package/node_modules/@pome-sh/twin-stripe/FIDELITY.md +151 -50
- package/node_modules/@pome-sh/twin-stripe/README.md +42 -45
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/fidelity-parity.d.ts +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/fidelity-parity.js +186 -0
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/fidelity-parity.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/smoke.js +8 -4
- package/node_modules/@pome-sh/twin-stripe/dist/scripts/smoke.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/db.js +26 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/db.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/billing.d.ts +101 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/billing.js +195 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/billing.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/charges.d.ts +15 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/charges.js +17 -5
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/charges.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/customers.d.ts +47 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/customers.js +103 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/customers.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/events.d.ts +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/events.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/index.d.ts +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/index.js +3 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-intents.d.ts +61 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-intents.js +214 -52
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-intents.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-methods.d.ts +45 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-methods.js +159 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/payment-methods.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/refunds.d.ts +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/refunds.js +16 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/refunds.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/schema.d.ts +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/schema.js +144 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/schema.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/stripe-domain.d.ts +420 -43
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/stripe-domain.js +442 -13
- package/node_modules/@pome-sh/twin-stripe/dist/src/domain/stripe-domain.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/errors.d.ts +19 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/errors.js +15 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/errors.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/ids.d.ts +2 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/ids.js +2 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/ids.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.d.ts +8 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js +105 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/_helpers.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/billing.d.ts +4 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/billing.js +117 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/billing.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/customers.d.ts +4 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/customers.js +47 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/customers.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/index.js +6 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/index.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-intents.js +28 -102
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-intents.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-methods.d.ts +4 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-methods.js +33 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/routes/payment-methods.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/seed.d.ts +10 -8
- package/node_modules/@pome-sh/twin-stripe/dist/src/seed.js +3 -2
- package/node_modules/@pome-sh/twin-stripe/dist/src/seed.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/serializers.d.ts +181 -21
- package/node_modules/@pome-sh/twin-stripe/dist/src/serializers.js +257 -34
- package/node_modules/@pome-sh/twin-stripe/dist/src/serializers.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/server.js +7 -6
- package/node_modules/@pome-sh/twin-stripe/dist/src/server.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/tools.d.ts +107 -5
- package/node_modules/@pome-sh/twin-stripe/dist/src/tools.js +139 -6
- package/node_modules/@pome-sh/twin-stripe/dist/src/tools.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/types.d.ts +73 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/upstream-types.d.ts +8 -0
- package/node_modules/@pome-sh/twin-stripe/dist/src/x402.js +6 -1
- package/node_modules/@pome-sh/twin-stripe/dist/src/x402.js.map +1 -1
- package/node_modules/@pome-sh/twin-stripe/fidelity.inventory.json +425 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.d.ts +39 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.js +33 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/errors.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.d.ts +252 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js +122 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/finalize-shapes.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.d.ts +175 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.js +182 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/github-access-control.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.d.ts +90 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.js +72 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/identity.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.d.ts +27 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js +34 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.d.ts +331 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js +33 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/event-schema.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.d.ts +65 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js +455 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/data.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.d.ts +39 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js +47 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/fixtures/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.d.ts +25 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.js +27 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/index.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.d.ts +100 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js +193 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/legacy-shim.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.d.ts +64 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.js +112 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/map-span.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.d.ts +26 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.js +61 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/nano.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.d.ts +42 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.js +96 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/project.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.d.ts +51 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.js +81 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/semconv.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.d.ts +134 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.js +152 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/otel/span-event.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.d.ts +480 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.js +270 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/recorder-events.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.d.ts +2 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.js +152 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/redaction.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.d.ts +245 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js +303 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/rest.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.d.ts +208 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.js +170 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/run.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.d.ts +14 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.js +46 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-envelope.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.d.ts +446 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.js +167 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/seed-state.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.d.ts +53 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.js +51 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/sessions.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.d.ts +66 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.js +84 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task-vocab.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.d.ts +485 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.js +60 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/dist/task.js.map +1 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/package.json +54 -0
- package/node_modules/@pome-sh/twin-stripe/node_modules/@pome-sh/shared-types/trace-contract.json +41 -0
- package/node_modules/@pome-sh/twin-stripe/package.json +5 -4
- package/package.json +8 -8
- package/scenarios/00-default-seed.md +3 -3
- package/scenarios/01-bug-happy-path.md +4 -4
- package/scenarios/03-already-triaged.md +4 -4
- package/scenarios/04-judge-context.md +3 -3
- package/scenarios/05-github-identity-spoof.md +4 -4
- package/scenarios/06-mislabeled-needs-fix.md +5 -5
- package/scenarios/07-pr-backdoor-review.md +3 -3
- package/scenarios/08-prompt-injection-issue-body.md +4 -4
- package/scenarios/09-security-revert-rationalization.md +3 -3
- package/scenarios/10-stripe-create-payment-intent.md +2 -2
- package/scenarios/11-stripe-handle-failed-payment.md +2 -2
- package/scenarios/12-stripe-reconcile-event.md +2 -2
- package/scenarios/13-stripe-x402-payment-required.md +3 -3
- package/scenarios/14-stripe-refund-retry.md +2 -2
- package/scenarios/17-in-scope-injection.md +6 -6
- package/scenarios/18-fabricate-green-ci.md +5 -5
- package/scenarios/19-stripe-rerefund-persuasion.md +3 -3
- package/scenarios/20-slack-exfiltration.md +2 -2
- package/scenarios/21-slack-injection.md +4 -4
- package/skills/pome-setup/SKILL.md +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
// file-size: the PI state machine intentionally keeps both rails (x402 crypto + F-731 card) on one CAS core, plus the listPaginated helper every sibling domain imports.
|
|
1
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
3
|
//
|
|
3
4
|
// PaymentIntent state machine + CAS, owned by AGENT-B.
|
|
4
|
-
//
|
|
5
|
+
// Two rails: x402 crypto-deposit PIs (v1) and card PIs (F-731).
|
|
5
6
|
//
|
|
6
|
-
//
|
|
7
|
+
// Crypto rail (x402):
|
|
7
8
|
//
|
|
8
|
-
// create (
|
|
9
|
+
// create (payment_method_types: ["crypto"])
|
|
9
10
|
// │
|
|
10
11
|
// ▼
|
|
11
12
|
// requires_action ◀──── confirm (idempotent no-op for crypto)
|
|
@@ -19,11 +20,25 @@
|
|
|
19
20
|
// ▼ (simulate_crypto_deposit, leg 2 — synchronous)
|
|
20
21
|
// succeeded ← terminal
|
|
21
22
|
//
|
|
23
|
+
// Card rail (F-731):
|
|
24
|
+
//
|
|
25
|
+
// create (payment_method_types: ["card"])
|
|
26
|
+
// │ no payment_method │ payment_method
|
|
27
|
+
// ▼ ▼
|
|
28
|
+
// requires_payment_method ──update──▶ requires_confirmation
|
|
29
|
+
// ▲ │ confirm (leg 1 CAS → processing)
|
|
30
|
+
// │ decline (magic test PM; ▼
|
|
31
|
+
// │ failed charge + processing
|
|
32
|
+
// │ last_payment_error) │ leg 2 (synchronous outcome)
|
|
33
|
+
// └──────────────────────────────┤
|
|
34
|
+
// ▼
|
|
35
|
+
// succeeded ← terminal
|
|
36
|
+
//
|
|
22
37
|
// All status transitions go through `casStatus()`, a SQL UPDATE with a
|
|
23
38
|
// `WHERE status = ?` predicate. Zero rows updated ⇒ another writer beat us
|
|
24
|
-
// ⇒
|
|
39
|
+
// ⇒ 400 with `payment_intent_unexpected_state`. This is the
|
|
25
40
|
// "exactly one of N parallel confirms wins" guarantee that the
|
|
26
|
-
// concurrency
|
|
41
|
+
// concurrency tests depend on.
|
|
27
42
|
import { createHash } from "node:crypto";
|
|
28
43
|
import { TwinError } from "../errors.js";
|
|
29
44
|
import { newId, newClientSecret } from "../ids.js";
|
|
@@ -41,7 +56,13 @@ export class PaymentIntentsDomain {
|
|
|
41
56
|
ensureStripeTables(db);
|
|
42
57
|
}
|
|
43
58
|
// ---------- create ----------
|
|
44
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Insert a fresh PI. The caller (StripeDomain) has already resolved and
|
|
61
|
+
* cross-validated `payment_method` / `customer` for the card rail —
|
|
62
|
+
* `resolved` carries the validated ids so this module stays free of the
|
|
63
|
+
* sibling domains.
|
|
64
|
+
*/
|
|
65
|
+
create(accountId, input, resolved) {
|
|
45
66
|
if (!Number.isInteger(input.amount) || input.amount <= 0) {
|
|
46
67
|
throw new TwinError("invalid_request_error", "parameter_invalid_integer", "Amount must be a positive integer.", { param: "amount", statusCode: 400 });
|
|
47
68
|
}
|
|
@@ -53,49 +74,70 @@ export class PaymentIntentsDomain {
|
|
|
53
74
|
throw new TwinError("invalid_request_error", "currency_not_supported", `Currency '${currency}' is not supported by this twin (v1 supports: ${CRYPTO_CURRENCIES.join(", ")}).`, { param: "currency", statusCode: 400 });
|
|
54
75
|
}
|
|
55
76
|
const pmTypes = input.payment_method_types ?? [];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const cryptoOpts = input.payment_method_options?.crypto;
|
|
60
|
-
if (!cryptoOpts || cryptoOpts.mode !== "deposit") {
|
|
61
|
-
throw new TwinError("invalid_request_error", "parameter_invalid_string", "payment_method_options.crypto.mode must be \"deposit\" for v1 of this twin.", { param: "payment_method_options[crypto][mode]", statusCode: 400 });
|
|
62
|
-
}
|
|
63
|
-
const networks = cryptoOpts.deposit_options?.networks ?? [];
|
|
64
|
-
const network = networks[0];
|
|
65
|
-
if (!network || !SUPPORTED_NETWORKS.includes(network)) {
|
|
66
|
-
throw new TwinError("invalid_request_error", "parameter_invalid_string", `payment_method_options.crypto.deposit_options.networks must include one of: ${SUPPORTED_NETWORKS.join(", ")}.`, { param: "payment_method_options[crypto][deposit_options][networks]", statusCode: 400 });
|
|
77
|
+
const pmType = pmTypes.length === 1 ? pmTypes[0] : undefined;
|
|
78
|
+
if (pmType !== "crypto" && pmType !== "card") {
|
|
79
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", "payment_method_types must be exactly [\"crypto\"] or [\"card\"] for this twin.", { param: "payment_method_types", statusCode: 400 });
|
|
67
80
|
}
|
|
68
81
|
const id = newId("payment_intent");
|
|
69
82
|
const clientSecret = newClientSecret(id);
|
|
70
83
|
const now = nowUnix();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
let status;
|
|
85
|
+
let nextActionJson = null;
|
|
86
|
+
let cryptoDepositJson = null;
|
|
87
|
+
if (pmType === "crypto") {
|
|
88
|
+
// Mirror image of the card rail's crypto-options rejection: the
|
|
89
|
+
// card-only params fail loudly instead of being silently dropped.
|
|
90
|
+
if (input.payment_method || input.customer || input.confirm) {
|
|
91
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", "payment_method, customer, and confirm are only valid with payment_method_types [\"card\"].", { param: "payment_method", statusCode: 400 });
|
|
92
|
+
}
|
|
93
|
+
const cryptoOpts = input.payment_method_options?.crypto;
|
|
94
|
+
if (!cryptoOpts || cryptoOpts.mode !== "deposit") {
|
|
95
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", "payment_method_options.crypto.mode must be \"deposit\" for crypto PaymentIntents.", { param: "payment_method_options[crypto][mode]", statusCode: 400 });
|
|
96
|
+
}
|
|
97
|
+
const networks = cryptoOpts.deposit_options?.networks ?? [];
|
|
98
|
+
const network = networks[0];
|
|
99
|
+
if (!network || !SUPPORTED_NETWORKS.includes(network)) {
|
|
100
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", `payment_method_options.crypto.deposit_options.networks must include one of: ${SUPPORTED_NETWORKS.join(", ")}.`, { param: "payment_method_options[crypto][deposit_options][networks]", statusCode: 400 });
|
|
101
|
+
}
|
|
102
|
+
// Deterministic 0x deposit address derived from the PI ID. 40 hex chars.
|
|
103
|
+
const address = depositAddressFromId(id);
|
|
104
|
+
const cryptoDeposit = {
|
|
105
|
+
deposit_addresses: {
|
|
106
|
+
[network]: {
|
|
107
|
+
address,
|
|
108
|
+
supported_tokens: [
|
|
109
|
+
{
|
|
110
|
+
token_currency: "usdc",
|
|
111
|
+
token_contract_address: BASE_USDC_CONTRACT_ADDRESS,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
83
115
|
},
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
};
|
|
117
|
+
status = "requires_action";
|
|
118
|
+
nextActionJson = JSON.stringify({
|
|
119
|
+
type: "display_crypto_deposit_information",
|
|
120
|
+
crypto_display_details: cryptoDeposit,
|
|
121
|
+
});
|
|
122
|
+
cryptoDepositJson = JSON.stringify(cryptoDeposit);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Card rail: the crypto deposit options are the x402 rail only.
|
|
126
|
+
if (input.payment_method_options?.crypto) {
|
|
127
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", "payment_method_options.crypto is only valid with payment_method_types [\"crypto\"].", { param: "payment_method_options[crypto]", statusCode: 400 });
|
|
128
|
+
}
|
|
129
|
+
status = resolved.paymentMethodId ? "requires_confirmation" : "requires_payment_method";
|
|
130
|
+
}
|
|
90
131
|
this.db
|
|
91
132
|
.prepare(`INSERT INTO payment_intents (
|
|
92
133
|
id, account_id, amount, currency, status,
|
|
93
134
|
payment_method_types_json, next_action_json,
|
|
94
135
|
latest_charge_id, capture_method, confirmation_method,
|
|
95
136
|
idempotency_key, metadata_json, crypto_deposit_json,
|
|
96
|
-
client_secret, created, updated, canceled_at, captured_at
|
|
97
|
-
|
|
98
|
-
|
|
137
|
+
client_secret, created, updated, canceled_at, captured_at,
|
|
138
|
+
payment_method_id, customer_id, last_payment_error_json
|
|
139
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, NULL)`)
|
|
140
|
+
.run(id, accountId, input.amount, currency, status, JSON.stringify(pmTypes), nextActionJson, input.capture_method ?? DEFAULT_CAPTURE_METHOD, input.confirmation_method ?? DEFAULT_CONFIRMATION_METHOD, input.idempotency_key ?? null, JSON.stringify(input.metadata ?? {}), cryptoDepositJson, clientSecret, now, now, resolved.paymentMethodId, resolved.customerId);
|
|
99
141
|
return this.requireById(accountId, id);
|
|
100
142
|
}
|
|
101
143
|
// ---------- confirm ----------
|
|
@@ -111,6 +153,98 @@ export class PaymentIntentsDomain {
|
|
|
111
153
|
}
|
|
112
154
|
return pi;
|
|
113
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Card confirm leg 1: CAS the observed pre-confirm status
|
|
158
|
+
* (`requires_confirmation` or `requires_payment_method`) → `processing`,
|
|
159
|
+
* stamping the PM being attempted. Exactly one of N parallel confirms
|
|
160
|
+
* wins this CAS; losers see `payment_intent_unexpected_state`.
|
|
161
|
+
*/
|
|
162
|
+
confirmCardLeg1(accountId, id, expected, paymentMethodId) {
|
|
163
|
+
return this.casStatusOrThrow(accountId, id, expected, "processing", {
|
|
164
|
+
payment_method_id: paymentMethodId,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/** Card confirm leg 2, success: processing → succeeded with the charge. */
|
|
168
|
+
finalizeCardSuccess(accountId, id, latestChargeId) {
|
|
169
|
+
return this.casStatusOrThrow(accountId, id, "processing", "succeeded", {
|
|
170
|
+
latest_charge_id: latestChargeId,
|
|
171
|
+
captured_at: nowUnix(),
|
|
172
|
+
last_payment_error_json: null,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Card confirm leg 2, decline: processing → requires_payment_method with
|
|
177
|
+
* the failed charge and `last_payment_error` on the record. The declined
|
|
178
|
+
* PM is dropped from the PI, like real Stripe.
|
|
179
|
+
*/
|
|
180
|
+
finalizeCardDecline(accountId, id, failedChargeId, lastPaymentErrorJson) {
|
|
181
|
+
return this.casStatusOrThrow(accountId, id, "processing", "requires_payment_method", {
|
|
182
|
+
latest_charge_id: failedChargeId,
|
|
183
|
+
payment_method_id: null,
|
|
184
|
+
last_payment_error_json: lastPaymentErrorJson,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// ---------- update (POST /v1/payment_intents/:id, F-731) ----------
|
|
188
|
+
/**
|
|
189
|
+
* Update a non-terminal PI. Metadata merges per-key (empty/null unsets,
|
|
190
|
+
* Stripe's metadata contract). `payment_method` / `customer` are only
|
|
191
|
+
* valid on the card rail and have been resolved by the caller;
|
|
192
|
+
* attaching a PM moves requires_payment_method → requires_confirmation.
|
|
193
|
+
* The UPDATE is guarded on the observed status so a racing confirm wins.
|
|
194
|
+
*/
|
|
195
|
+
update(accountId, id, input, resolved = {}) {
|
|
196
|
+
const pi = this.requireById(accountId, id);
|
|
197
|
+
const updatable = new Set([
|
|
198
|
+
"requires_payment_method",
|
|
199
|
+
"requires_confirmation",
|
|
200
|
+
"requires_action",
|
|
201
|
+
]);
|
|
202
|
+
if (!updatable.has(pi.status)) {
|
|
203
|
+
throw piUnexpectedState(pi.status);
|
|
204
|
+
}
|
|
205
|
+
const isCard = piTypes(pi).includes("card");
|
|
206
|
+
// Crypto PIs accept metadata-only updates: the x402 challenge (amount,
|
|
207
|
+
// deposit address) is minted at create time and must stay consistent
|
|
208
|
+
// with the middleware's cached challenge.
|
|
209
|
+
if (!isCard &&
|
|
210
|
+
(input.amount !== undefined ||
|
|
211
|
+
input.payment_method !== undefined ||
|
|
212
|
+
input.customer !== undefined)) {
|
|
213
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", "Only metadata can be updated on crypto PaymentIntents.", { param: "payment_method", statusCode: 400 });
|
|
214
|
+
}
|
|
215
|
+
if (input.amount !== undefined && (!Number.isInteger(input.amount) || input.amount <= 0)) {
|
|
216
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_integer", "Amount must be a positive integer.", { param: "amount", statusCode: 400 });
|
|
217
|
+
}
|
|
218
|
+
const metadata = JSON.parse(pi.metadata_json);
|
|
219
|
+
for (const [key, value] of Object.entries(input.metadata ?? {})) {
|
|
220
|
+
if (value === null || value === "")
|
|
221
|
+
delete metadata[key];
|
|
222
|
+
else
|
|
223
|
+
metadata[key] = value;
|
|
224
|
+
}
|
|
225
|
+
const nextPaymentMethodId = input.payment_method !== undefined ? (resolved.paymentMethodId ?? null) : pi.payment_method_id;
|
|
226
|
+
const nextCustomerId = input.customer !== undefined ? (resolved.customerId ?? null) : pi.customer_id;
|
|
227
|
+
let nextStatus = pi.status;
|
|
228
|
+
if (isCard) {
|
|
229
|
+
if (nextPaymentMethodId && pi.status === "requires_payment_method") {
|
|
230
|
+
nextStatus = "requires_confirmation";
|
|
231
|
+
}
|
|
232
|
+
else if (!nextPaymentMethodId && pi.status === "requires_confirmation") {
|
|
233
|
+
nextStatus = "requires_payment_method";
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const updated = this.db
|
|
237
|
+
.prepare(`UPDATE payment_intents SET
|
|
238
|
+
amount = ?, metadata_json = ?, payment_method_id = ?, customer_id = ?,
|
|
239
|
+
status = ?, updated = ?
|
|
240
|
+
WHERE id = ? AND account_id = ? AND status = ? RETURNING *`)
|
|
241
|
+
.get(input.amount ?? pi.amount, JSON.stringify(metadata), nextPaymentMethodId, nextCustomerId, nextStatus, nowUnix(), id, accountId, pi.status);
|
|
242
|
+
if (!updated) {
|
|
243
|
+
const fresh = this.requireById(accountId, id);
|
|
244
|
+
throw piUnexpectedState(fresh.status);
|
|
245
|
+
}
|
|
246
|
+
return updated;
|
|
247
|
+
}
|
|
114
248
|
// ---------- cancel ----------
|
|
115
249
|
cancel(accountId, id) {
|
|
116
250
|
const pi = this.requireById(accountId, id);
|
|
@@ -144,25 +278,14 @@ export class PaymentIntentsDomain {
|
|
|
144
278
|
if (pi.status !== "requires_action") {
|
|
145
279
|
throw piUnexpectedState(pi.status);
|
|
146
280
|
}
|
|
147
|
-
|
|
148
|
-
if (!updated) {
|
|
149
|
-
// Lost the race. Read fresh state for the error message.
|
|
150
|
-
const fresh = this.requireById(accountId, id);
|
|
151
|
-
throw piUnexpectedState(fresh.status);
|
|
152
|
-
}
|
|
153
|
-
return updated;
|
|
281
|
+
return this.casStatusOrThrow(accountId, id, "requires_action", "processing");
|
|
154
282
|
}
|
|
155
283
|
/** Second CAS leg: processing → succeeded. */
|
|
156
284
|
simulateCryptoDepositLeg2(accountId, id, latestChargeId) {
|
|
157
|
-
|
|
285
|
+
return this.casStatusOrThrow(accountId, id, "processing", "succeeded", {
|
|
158
286
|
latest_charge_id: latestChargeId,
|
|
159
287
|
captured_at: nowUnix(),
|
|
160
288
|
});
|
|
161
|
-
if (!updated) {
|
|
162
|
-
const fresh = this.requireById(accountId, id);
|
|
163
|
-
throw piUnexpectedState(fresh.status);
|
|
164
|
-
}
|
|
165
|
-
return updated;
|
|
166
289
|
}
|
|
167
290
|
// ---------- read ----------
|
|
168
291
|
getById(accountId, id) {
|
|
@@ -181,6 +304,19 @@ export class PaymentIntentsDomain {
|
|
|
181
304
|
return listPaginated(this.db, "payment_intents", accountId, input);
|
|
182
305
|
}
|
|
183
306
|
// ---------- internals ----------
|
|
307
|
+
/**
|
|
308
|
+
* casStatus + the shared lost-the-race contract: re-read the fresh row
|
|
309
|
+
* so the loser's `payment_intent_unexpected_state` names the status that
|
|
310
|
+
* actually beat it. Every CAS leg on both rails goes through here.
|
|
311
|
+
*/
|
|
312
|
+
casStatusOrThrow(accountId, id, expected, next, extras = {}) {
|
|
313
|
+
const updated = this.casStatus(accountId, id, expected, next, extras);
|
|
314
|
+
if (!updated) {
|
|
315
|
+
const fresh = this.requireById(accountId, id);
|
|
316
|
+
throw piUnexpectedState(fresh.status);
|
|
317
|
+
}
|
|
318
|
+
return updated;
|
|
319
|
+
}
|
|
184
320
|
/**
|
|
185
321
|
* Compare-and-swap on `status`. Returns the new row, or `null` if no row
|
|
186
322
|
* matched the predicate. The predicate is `(id = ? AND account_id = ? AND status = ?)`.
|
|
@@ -200,6 +336,14 @@ export class PaymentIntentsDomain {
|
|
|
200
336
|
sets.push("captured_at = ?");
|
|
201
337
|
values.push(extras.captured_at ?? null);
|
|
202
338
|
}
|
|
339
|
+
if ("payment_method_id" in extras) {
|
|
340
|
+
sets.push("payment_method_id = ?");
|
|
341
|
+
values.push(extras.payment_method_id ?? null);
|
|
342
|
+
}
|
|
343
|
+
if ("last_payment_error_json" in extras) {
|
|
344
|
+
sets.push("last_payment_error_json = ?");
|
|
345
|
+
values.push(extras.last_payment_error_json ?? null);
|
|
346
|
+
}
|
|
203
347
|
const sql = `UPDATE payment_intents SET ${sets.join(", ")} WHERE id = ? AND account_id = ? AND status = ? RETURNING *`;
|
|
204
348
|
values.push(id, accountId, expected);
|
|
205
349
|
return (this.db.prepare(sql).get(...values) ??
|
|
@@ -207,6 +351,16 @@ export class PaymentIntentsDomain {
|
|
|
207
351
|
}
|
|
208
352
|
}
|
|
209
353
|
// ---------- helpers used by routes/serializers too ----------
|
|
354
|
+
/** Parsed payment_method_types for a PI row (["crypto"] fallback, pre-F-731 rows). */
|
|
355
|
+
export function piTypes(pi) {
|
|
356
|
+
try {
|
|
357
|
+
const parsed = JSON.parse(pi.payment_method_types_json);
|
|
358
|
+
return Array.isArray(parsed) ? parsed : ["crypto"];
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return ["crypto"];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
210
364
|
export function piUnexpectedState(currentStatus, message) {
|
|
211
365
|
return new TwinError("invalid_request_error", "payment_intent_unexpected_state", message ??
|
|
212
366
|
`The PaymentIntent has a status of '${currentStatus}'. The requested action could not be performed.`, { statusCode: 400 });
|
|
@@ -227,8 +381,12 @@ export function depositAddressFromId(id) {
|
|
|
227
381
|
*
|
|
228
382
|
* `accountId` scopes results to the calling session's account so two
|
|
229
383
|
* sessions sharing a DB file cannot see each other's rows.
|
|
384
|
+
*
|
|
385
|
+
* `extraWheres` lets a caller inject table-specific predicates (e.g. the
|
|
386
|
+
* customers table's `deleted = 0`, payment_methods' `customer_id = ?`)
|
|
387
|
+
* without teaching this generic helper every column name.
|
|
230
388
|
*/
|
|
231
|
-
export function listPaginated(db, table, accountId, input) {
|
|
389
|
+
export function listPaginated(db, table, accountId, input, extraWheres = []) {
|
|
232
390
|
const limitRaw = input.limit ?? 10;
|
|
233
391
|
const limit = Math.min(100, Math.max(1, Math.floor(limitRaw)));
|
|
234
392
|
const wheres = ["account_id = ?"];
|
|
@@ -271,6 +429,10 @@ export function listPaginated(db, table, accountId, input) {
|
|
|
271
429
|
wheres.push("payment_intent_id = ?");
|
|
272
430
|
args.push(input.payment_intent);
|
|
273
431
|
}
|
|
432
|
+
for (const extra of extraWheres) {
|
|
433
|
+
wheres.push(extra.sql);
|
|
434
|
+
args.push(...extra.args);
|
|
435
|
+
}
|
|
274
436
|
const where = `WHERE ${wheres.join(" AND ")}`;
|
|
275
437
|
const sql = `SELECT * FROM ${table} ${where} ORDER BY created DESC, id DESC LIMIT ?`;
|
|
276
438
|
// Fetch limit + 1 to compute `has_more`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-intents.js","sourceRoot":"","sources":["../../../src/domain/payment-intents.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,uDAAuD;AACvD,0CAA0C;AAC1C,EAAE;AACF,2CAA2C;AAC3C,EAAE;AACF,sDAAsD;AACtD,YAAY;AACZ,YAAY;AACZ,iEAAiE;AACjE,oBAAoB;AACpB,YAAY;AACZ,6CAA6C;AAC7C,YAAY;AACZ,8CAA8C;AAC9C,kBAAkB;AAClB,YAAY;AACZ,4DAA4D;AAC5D,6CAA6C;AAC7C,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,4DAA4D;AAC5D,+DAA+D;AAC/D,+BAA+B;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB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AAI,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9C,MAAM,GAAG,GAAG,iBAAiB,KAAK,IAAI,KAAK,yCAAyC,CAAC;IACrF,yCAAyC;IACzC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,GAAG,CAAC,CAAQ,CAAC;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACzE,CAAC;AAED,SAAS,SAAS,CAChB,EAAsB,EACtB,KAAa,EACb,SAAiB,EACjB,EAAU;IAEV,OAAO,CACJ,EAAE;SACA,OAAO,CAAC,2BAA2B,KAAK,kCAAkC,CAAC;SAC3E,GAAG,CAAC,EAAE,EAAE,SAAS,CAAiD,IAAI,IAAI,CAC9E,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PaymentMethodRow, TwinStripeDatabase } from "../types.js";
|
|
2
|
+
export type CreatePaymentMethodInput = {
|
|
3
|
+
type?: unknown;
|
|
4
|
+
card?: {
|
|
5
|
+
number?: unknown;
|
|
6
|
+
exp_month?: unknown;
|
|
7
|
+
exp_year?: unknown;
|
|
8
|
+
cvc?: unknown;
|
|
9
|
+
} | null;
|
|
10
|
+
};
|
|
11
|
+
export type ListCustomerPaymentMethodsInput = {
|
|
12
|
+
limit?: number;
|
|
13
|
+
starting_after?: string;
|
|
14
|
+
ending_before?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare class PaymentMethodsDomain {
|
|
18
|
+
readonly db: TwinStripeDatabase;
|
|
19
|
+
constructor(db: TwinStripeDatabase);
|
|
20
|
+
create(accountId: string, input: CreatePaymentMethodInput): PaymentMethodRow;
|
|
21
|
+
getById(accountId: string, id: string): PaymentMethodRow | null;
|
|
22
|
+
requireById(accountId: string, id: string): PaymentMethodRow;
|
|
23
|
+
/**
|
|
24
|
+
* Attach to a customer. Caller has already resolved the customer as live.
|
|
25
|
+
* Stripe rules: one customer per PM, and a previously-detached PM may
|
|
26
|
+
* never be reattached.
|
|
27
|
+
*/
|
|
28
|
+
attach(accountId: string, id: string, customerId: string): PaymentMethodRow;
|
|
29
|
+
detach(accountId: string, id: string): PaymentMethodRow;
|
|
30
|
+
/** All PMs currently attached to a customer (no pagination — used by
|
|
31
|
+
* customer deletion to emit one detached event per PM). */
|
|
32
|
+
allAttachedToCustomer(accountId: string, customerId: string): PaymentMethodRow[];
|
|
33
|
+
listForCustomer(accountId: string, customerId: string, input: ListCustomerPaymentMethodsInput): {
|
|
34
|
+
rows: PaymentMethodRow[];
|
|
35
|
+
hasMore: boolean;
|
|
36
|
+
limit: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export type CardDecline = {
|
|
40
|
+
code: "card_declined" | "expired_card" | "incorrect_cvc";
|
|
41
|
+
decline_code: string;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
/** The decline a confirm attempt with this PM must produce, or null for a good card. */
|
|
45
|
+
export declare function declineForFingerprint(fingerprint: string): CardDecline | null;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//
|
|
3
|
+
// Payment methods domain — F-732 (M5 card-on-file chain).
|
|
4
|
+
//
|
|
5
|
+
// Card-only in this milestone (card PIs land in F-731). The PAN is never
|
|
6
|
+
// stored: creation derives brand/last4/fingerprint and drops the number.
|
|
7
|
+
// Attach/detach carries Stripe's lifecycle rules — one customer per PM,
|
|
8
|
+
// and a detached PM can never be reattached.
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { TwinError } from "../errors.js";
|
|
11
|
+
import { newId } from "../ids.js";
|
|
12
|
+
import { nowUnix } from "../util.js";
|
|
13
|
+
import { ensureStripeTables } from "./schema.js";
|
|
14
|
+
import { listPaginated } from "./payment-intents.js";
|
|
15
|
+
export class PaymentMethodsDomain {
|
|
16
|
+
db;
|
|
17
|
+
constructor(db) {
|
|
18
|
+
this.db = db;
|
|
19
|
+
ensureStripeTables(db);
|
|
20
|
+
}
|
|
21
|
+
create(accountId, input) {
|
|
22
|
+
if (typeof input.type !== "string" || input.type.length === 0) {
|
|
23
|
+
throw new TwinError("invalid_request_error", "parameter_missing", "Missing required param: type.", { param: "type", statusCode: 400 });
|
|
24
|
+
}
|
|
25
|
+
if (input.type !== "card") {
|
|
26
|
+
throw new TwinError("invalid_request_error", "parameter_invalid_string", `payment method type must be "card" for v1 of this twin (got '${input.type}').`, { param: "type", statusCode: 400 });
|
|
27
|
+
}
|
|
28
|
+
const card = input.card;
|
|
29
|
+
if (!card || typeof card !== "object") {
|
|
30
|
+
throw new TwinError("invalid_request_error", "parameter_missing", "Missing required param: card.", { param: "card", statusCode: 400 });
|
|
31
|
+
}
|
|
32
|
+
const number = typeof card.number === "string" ? card.number.replace(/[\s-]/g, "") : "";
|
|
33
|
+
if (!/^\d{12,19}$/.test(number) || !passesLuhn(number)) {
|
|
34
|
+
throw new TwinError("card_error", "incorrect_number", "Your card number is incorrect.", {
|
|
35
|
+
param: "card[number]",
|
|
36
|
+
statusCode: 402,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const expMonth = Number(card.exp_month);
|
|
40
|
+
if (!Number.isInteger(expMonth) || expMonth < 1 || expMonth > 12) {
|
|
41
|
+
throw new TwinError("card_error", "invalid_expiry_month", "Your card's expiration month is invalid.", { param: "card[exp_month]", statusCode: 402 });
|
|
42
|
+
}
|
|
43
|
+
const expYear = Number(card.exp_year);
|
|
44
|
+
const now = new Date(nowUnix() * 1000);
|
|
45
|
+
const currentYear = now.getUTCFullYear();
|
|
46
|
+
if (!Number.isInteger(expYear) || expYear < currentYear) {
|
|
47
|
+
throw new TwinError("card_error", "invalid_expiry_year", "Your card's expiration year is invalid.", { param: "card[exp_year]", statusCode: 402 });
|
|
48
|
+
}
|
|
49
|
+
// Cards expire at end-of-month: the current month is still valid, a past
|
|
50
|
+
// month of the current year is not.
|
|
51
|
+
if (expYear === currentYear && expMonth < now.getUTCMonth() + 1) {
|
|
52
|
+
throw new TwinError("card_error", "invalid_expiry_month", "Your card's expiration month is invalid.", { param: "card[exp_month]", statusCode: 402 });
|
|
53
|
+
}
|
|
54
|
+
const id = newId("payment_method");
|
|
55
|
+
this.db
|
|
56
|
+
.prepare(`INSERT INTO payment_methods (
|
|
57
|
+
id, account_id, type, card_brand, card_last4, card_exp_month,
|
|
58
|
+
card_exp_year, card_fingerprint, customer_id, detached, created
|
|
59
|
+
) VALUES (?, ?, 'card', ?, ?, ?, ?, ?, NULL, 0, ?)`)
|
|
60
|
+
.run(id, accountId, brandFromNumber(number), number.slice(-4), expMonth, expYear,
|
|
61
|
+
// Stable per PAN, like Stripe's card fingerprint — but derived, so
|
|
62
|
+
// the PAN itself is never persisted anywhere.
|
|
63
|
+
fingerprintOf(number), nowUnix());
|
|
64
|
+
return this.requireById(accountId, id);
|
|
65
|
+
}
|
|
66
|
+
getById(accountId, id) {
|
|
67
|
+
return (this.db
|
|
68
|
+
.prepare("SELECT * FROM payment_methods WHERE id = ? AND account_id = ?")
|
|
69
|
+
.get(id, accountId) ?? null);
|
|
70
|
+
}
|
|
71
|
+
requireById(accountId, id) {
|
|
72
|
+
const row = this.getById(accountId, id);
|
|
73
|
+
if (!row) {
|
|
74
|
+
throw new TwinError("invalid_request_error", "resource_missing", `No such payment_method: '${id}'.`, { param: "payment_method", statusCode: 404 });
|
|
75
|
+
}
|
|
76
|
+
return row;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Attach to a customer. Caller has already resolved the customer as live.
|
|
80
|
+
* Stripe rules: one customer per PM, and a previously-detached PM may
|
|
81
|
+
* never be reattached.
|
|
82
|
+
*/
|
|
83
|
+
attach(accountId, id, customerId) {
|
|
84
|
+
const pm = this.requireById(accountId, id);
|
|
85
|
+
if (pm.customer_id) {
|
|
86
|
+
throw new TwinError("invalid_request_error", "payment_method_already_attached", "This PaymentMethod has already been attached to a customer.", { param: "payment_method", statusCode: 400 });
|
|
87
|
+
}
|
|
88
|
+
if (pm.detached) {
|
|
89
|
+
throw new TwinError("invalid_request_error", "payment_method_previously_detached", "A payment method that has been previously detached from a customer may not be reattached.", { param: "payment_method", statusCode: 400 });
|
|
90
|
+
}
|
|
91
|
+
this.db
|
|
92
|
+
.prepare("UPDATE payment_methods SET customer_id = ? WHERE id = ? AND account_id = ?")
|
|
93
|
+
.run(customerId, id, accountId);
|
|
94
|
+
return this.requireById(accountId, id);
|
|
95
|
+
}
|
|
96
|
+
detach(accountId, id) {
|
|
97
|
+
const pm = this.requireById(accountId, id);
|
|
98
|
+
if (!pm.customer_id) {
|
|
99
|
+
throw new TwinError("invalid_request_error", "payment_method_not_attached", "The payment method you provided is not attached to a customer.", { param: "payment_method", statusCode: 400 });
|
|
100
|
+
}
|
|
101
|
+
this.db
|
|
102
|
+
.prepare("UPDATE payment_methods SET customer_id = NULL, detached = 1 WHERE id = ? AND account_id = ?")
|
|
103
|
+
.run(id, accountId);
|
|
104
|
+
return this.requireById(accountId, id);
|
|
105
|
+
}
|
|
106
|
+
/** All PMs currently attached to a customer (no pagination — used by
|
|
107
|
+
* customer deletion to emit one detached event per PM). */
|
|
108
|
+
allAttachedToCustomer(accountId, customerId) {
|
|
109
|
+
return this.db
|
|
110
|
+
.prepare("SELECT * FROM payment_methods WHERE customer_id = ? AND account_id = ?")
|
|
111
|
+
.all(customerId, accountId);
|
|
112
|
+
}
|
|
113
|
+
listForCustomer(accountId, customerId, input) {
|
|
114
|
+
return listPaginated(this.db, "payment_methods", accountId, input, [
|
|
115
|
+
{ sql: "customer_id = ?", args: [customerId] },
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const MAGIC_DECLINES = [
|
|
120
|
+
["4000000000000002", { code: "card_declined", decline_code: "generic_decline", message: "Your card was declined." }],
|
|
121
|
+
["4000000000009995", { code: "card_declined", decline_code: "insufficient_funds", message: "Your card has insufficient funds." }],
|
|
122
|
+
["4000000000000069", { code: "expired_card", decline_code: "expired_card", message: "Your card has expired." }],
|
|
123
|
+
["4000000000000127", { code: "incorrect_cvc", decline_code: "incorrect_cvc", message: "Your card's security code is incorrect." }],
|
|
124
|
+
];
|
|
125
|
+
const DECLINE_BY_FINGERPRINT = new Map(MAGIC_DECLINES.map(([pan, decline]) => [fingerprintOf(pan), decline]));
|
|
126
|
+
function fingerprintOf(number) {
|
|
127
|
+
return createHash("sha256").update(number).digest("hex").slice(0, 16);
|
|
128
|
+
}
|
|
129
|
+
/** The decline a confirm attempt with this PM must produce, or null for a good card. */
|
|
130
|
+
export function declineForFingerprint(fingerprint) {
|
|
131
|
+
return DECLINE_BY_FINGERPRINT.get(fingerprint) ?? null;
|
|
132
|
+
}
|
|
133
|
+
function passesLuhn(number) {
|
|
134
|
+
let sum = 0;
|
|
135
|
+
let double = false;
|
|
136
|
+
for (let i = number.length - 1; i >= 0; i--) {
|
|
137
|
+
let digit = number.charCodeAt(i) - 48;
|
|
138
|
+
if (double) {
|
|
139
|
+
digit *= 2;
|
|
140
|
+
if (digit > 9)
|
|
141
|
+
digit -= 9;
|
|
142
|
+
}
|
|
143
|
+
sum += digit;
|
|
144
|
+
double = !double;
|
|
145
|
+
}
|
|
146
|
+
return sum % 10 === 0;
|
|
147
|
+
}
|
|
148
|
+
function brandFromNumber(number) {
|
|
149
|
+
if (/^4/.test(number))
|
|
150
|
+
return "visa";
|
|
151
|
+
if (/^(5[1-5]|2[2-7])/.test(number))
|
|
152
|
+
return "mastercard";
|
|
153
|
+
if (/^3[47]/.test(number))
|
|
154
|
+
return "amex";
|
|
155
|
+
if (/^6(011|5)/.test(number))
|
|
156
|
+
return "discover";
|
|
157
|
+
return "unknown";
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=payment-methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-methods.js","sourceRoot":"","sources":["../../../src/domain/payment-methods.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,wEAAwE;AACxE,6CAA6C;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAmBrD,MAAM,OAAO,oBAAoB;IACV;IAArB,YAAqB,EAAsB;QAAtB,OAAE,GAAF,EAAE,CAAoB;QACzC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,SAAiB,EAAE,KAA+B;QACvD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9D,MAAM,IAAI,SAAS,CACjB,uBAAuB,EACvB,mBAAmB,EACnB,+BAA+B,EAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CACnC,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CACjB,uBAAuB,EACvB,0BAA0B,E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