@volter/twin-stripe 0.1.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/LICENSE +202 -0
- package/README.md +110 -0
- package/client/stripe-mirror.css +162 -0
- package/client/stripe-mirror.tsx +691 -0
- package/package.json +71 -0
- package/src/cli.ts +29 -0
- package/src/index.ts +52 -0
- package/src/stripe-capabilities.ts +3304 -0
- package/src/stripe-conformance.ts +110 -0
- package/src/stripe-connector.ts +373 -0
- package/src/stripe-events.ts +202 -0
- package/src/stripe-form.ts +35 -0
- package/src/stripe-mirror-ui.ts +345 -0
- package/src/stripe-server.ts +46 -0
- package/src/stripe-twin.ts +5227 -0
- package/src/stripe-ui-conformance.ts +125 -0
- package/src/stripe-ui-structure.ts +406 -0
- package/test-fixtures/stripe-known-deviations.json +85 -0
- package/test-fixtures/stripe-schemas.json +3364 -0
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volter/twin-stripe",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local Stripe twin \u2014 a faithful, stateful local Stripe API your real `stripe` SDK talks to unmodified. Mirror, simulate, and fork. Built on @volter/twin.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"twin",
|
|
7
|
+
"local",
|
|
8
|
+
"mock",
|
|
9
|
+
"mirror",
|
|
10
|
+
"simulator",
|
|
11
|
+
"fixtures",
|
|
12
|
+
"testing",
|
|
13
|
+
"sdk",
|
|
14
|
+
"api",
|
|
15
|
+
"localstack",
|
|
16
|
+
"stripe",
|
|
17
|
+
"payments"
|
|
18
|
+
],
|
|
19
|
+
"author": "Volter (https://github.com/volter-ai)",
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"client",
|
|
27
|
+
"test-fixtures",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"!test-fixtures/*.SOURCE.md",
|
|
31
|
+
"!**/*.test.ts",
|
|
32
|
+
"!**/*.test.tsx"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/volter-ai/twin.git",
|
|
37
|
+
"directory": "packages/twin/stripe"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/volter-ai/twin/tree/main/packages/twin/stripe#readme",
|
|
40
|
+
"type": "module",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": "./src/index.ts"
|
|
43
|
+
},
|
|
44
|
+
"bin": {
|
|
45
|
+
"world-stripe": "src/cli.ts"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"test": "bun test src/*.test.ts",
|
|
49
|
+
"typecheck": "tsc --noEmit"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"react": "^19.2.7",
|
|
53
|
+
"react-dom": "^19.2.7"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@volter/twin": "0.1.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@volter/twin": "0.1.0",
|
|
60
|
+
"@volter/twin-tooling": "0.1.0",
|
|
61
|
+
"@types/bun": "^1.2.20",
|
|
62
|
+
"@types/node": "^24.0.0",
|
|
63
|
+
"@types/react": "^19.2.17",
|
|
64
|
+
"@types/react-dom": "^19.2.3",
|
|
65
|
+
"stripe": "^22.2.1",
|
|
66
|
+
"typescript": "^5.9.0"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"bun": ">=1.2.0"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// world-stripe CLI: serve the Stripe API twin, the mirror UI, or run conformance.
|
|
3
|
+
import { hasFlag, optionValue } from '@volter/twin/args';
|
|
4
|
+
import { createStripeTwinServer } from './stripe-server.ts';
|
|
5
|
+
import { createStripeMirrorServer } from './stripe-mirror-ui.ts';
|
|
6
|
+
|
|
7
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
8
|
+
const port = Number(optionValue(rest, '--port', '0')) || undefined;
|
|
9
|
+
const root = optionValue(rest, '--root') || undefined;
|
|
10
|
+
const readOnly = hasFlag(rest, '--read-only'); // a twin accepts writes unless started read-only
|
|
11
|
+
|
|
12
|
+
if (cmd === 'serve') {
|
|
13
|
+
const s = createStripeTwinServer({ readOnly, ...(root ? { root } : {}), ...(port ? { port } : {}) });
|
|
14
|
+
process.stdout.write(`stripe twin (spec-correct API)${readOnly ? ' [read-only]' : ''} at http://127.0.0.1:${s.port}\n`);
|
|
15
|
+
await new Promise(() => {});
|
|
16
|
+
} else if (cmd === 'mirror') {
|
|
17
|
+
const s = createStripeMirrorServer({ ...(root ? { root } : {}), ...(port ? { port } : {}) });
|
|
18
|
+
process.stdout.write(`stripe mirror UI (dashboard) at http://127.0.0.1:${s.port}\n`);
|
|
19
|
+
await new Promise(() => {});
|
|
20
|
+
} else if (cmd === 'conformance') {
|
|
21
|
+
// dev-only; lazy so the bin runs without @volter/twin-tooling
|
|
22
|
+
const { checkStripeConformance, loadStripeKnownDeviations, loadStripeSchemas, stripeCoverage } = await import('./stripe-conformance.ts');
|
|
23
|
+
const [schemas, known] = await Promise.all([loadStripeSchemas(), loadStripeKnownDeviations()]);
|
|
24
|
+
const report = checkStripeConformance(schemas, { ...(root ? { root } : {}), known });
|
|
25
|
+
process.stdout.write(`${JSON.stringify({ ...report, coverage: stripeCoverage(schemas, { ...(root ? { root } : {}) }) }, null, 2)}\n`);
|
|
26
|
+
if (!report.ok) process.exitCode = 1;
|
|
27
|
+
} else {
|
|
28
|
+
process.stdout.write('Usage: world-stripe serve|mirror|conformance [--port N] [--root DIR] [--read-only]\n');
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @volter/twin-stripe — the Stripe twin (one vendor, one package), built on the
|
|
2
|
+
// shared @volter/twin kernel. REST transport, spec-correct shapes, event/webhook
|
|
3
|
+
// emission, and a React dashboard UI mirror. (Conformance tooling lives in
|
|
4
|
+
// @volter/twin-tooling, a dev dependency — not shipped in the runtime API.)
|
|
5
|
+
export { handleStripeTwinRequest } from './stripe-twin.ts';
|
|
6
|
+
export type { StripeRequest, StripeResponse } from './stripe-twin.ts';
|
|
7
|
+
export { createStripeTwinServer } from './stripe-server.ts';
|
|
8
|
+
export { parseStripeForm } from './stripe-form.ts';
|
|
9
|
+
export {
|
|
10
|
+
clearStripeWebhooks,
|
|
11
|
+
computeStripeSignature,
|
|
12
|
+
constructEvent,
|
|
13
|
+
emitStripeEvent,
|
|
14
|
+
eventTypeFor,
|
|
15
|
+
generateTestHeaderString,
|
|
16
|
+
listStripeWebhooks,
|
|
17
|
+
registerStripeWebhook,
|
|
18
|
+
StripeSignatureVerificationError,
|
|
19
|
+
} from './stripe-events.ts';
|
|
20
|
+
export type { StripeEvent, StripeEventDelivery } from './stripe-events.ts';
|
|
21
|
+
export {
|
|
22
|
+
fullSyncStripe,
|
|
23
|
+
liveStripeExecute,
|
|
24
|
+
mapCustomer,
|
|
25
|
+
mapScalarResource,
|
|
26
|
+
mapSubscription,
|
|
27
|
+
pullStripeAll,
|
|
28
|
+
pullStripeCustomers,
|
|
29
|
+
pullStripeSubscriptions,
|
|
30
|
+
pullStripeWebhookEndpoints,
|
|
31
|
+
pushPendingStripeActions,
|
|
32
|
+
pushStripeAction,
|
|
33
|
+
stripeRequestForAction,
|
|
34
|
+
syncStripeFromReal,
|
|
35
|
+
} from './stripe-connector.ts';
|
|
36
|
+
export type { StripeExecute } from './stripe-connector.ts';
|
|
37
|
+
export { buildStripeMirrorClient, createStripeMirrorServer, stripeMirrorHtml } from './stripe-mirror-ui.ts';
|
|
38
|
+
|
|
39
|
+
// Registry descriptor (#1): the pack self-describes so tooling can discover it.
|
|
40
|
+
// A consumer does `registerPack(pack)` after importing this package.
|
|
41
|
+
import type { TwinPack } from '@volter/twin';
|
|
42
|
+
export const pack: TwinPack = {
|
|
43
|
+
vendor: 'stripe',
|
|
44
|
+
transport: 'rest',
|
|
45
|
+
bin: 'world-stripe',
|
|
46
|
+
resources: ['charge', 'customer', 'payment_intent', 'setup_intent', 'payment_method', 'subscription', 'price', 'product', 'invoice', 'invoiceitem', 'refund'],
|
|
47
|
+
specSource: 'test-fixtures/stripe-schemas.json (per-object JSON Schemas from Stripe OpenAPI)',
|
|
48
|
+
description: 'Stripe REST twin — spec-correct shapes, events, dashUI mirror.',
|
|
49
|
+
// Stripe.js calls the same-origin '/v1/…' and loads from api.stripe.com — the dev proxy
|
|
50
|
+
// forwards '/v1/' to the twin and strips the absolute host so calls come back same-origin.
|
|
51
|
+
browserRouting: { apiPathPrefix: '/v1/', loaderHost: 'https://api.stripe.com' },
|
|
52
|
+
};
|