@facto-to/card 0.0.0-stage → 0.0.1-beta.1
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/CHANGELOG.md +12 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +63 -2
- package/dist/card-inbox-DzsHFRPT.d.cts +312 -0
- package/dist/card-inbox-DzsHFRPT.d.ts +312 -0
- package/dist/chunk-52SWPAJL.js +2 -0
- package/dist/cli/index.js +6 -0
- package/dist/docs/README.md +9 -0
- package/dist/docs/authentication.md +96 -0
- package/dist/docs/authorizations.md +182 -0
- package/dist/docs/concepts.md +35 -0
- package/dist/docs/deliveries.md +170 -0
- package/dist/docs/errors.md +100 -0
- package/dist/docs/getting-access.md +56 -0
- package/dist/docs/idempotency.md +78 -0
- package/dist/docs/integration-checklist.md +15 -0
- package/dist/docs/integration.zh.md +59 -0
- package/dist/docs/interlace-adapter-v1.md +87 -0
- package/dist/docs/interlace-adapter-v1.zh.md +87 -0
- package/dist/docs/not-yet-available.md +13 -0
- package/dist/docs/quickstart.md +126 -0
- package/dist/docs/reconciliation.md +86 -0
- package/dist/docs/reference/api.md +1728 -0
- package/dist/docs/reference/events.md +639 -0
- package/dist/docs/reference/schemas.json +5000 -0
- package/dist/docs/reference/schemas.md +865 -0
- package/dist/docs/simulator.md +235 -0
- package/dist/docs/versioning.md +9 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +840 -0
- package/dist/index.d.ts +840 -0
- package/dist/index.js +2 -0
- package/dist/source/build.mjs +5 -0
- package/dist/source/package.json +16 -0
- package/dist/source/src/connect/cli/deliveries.ts +48 -0
- package/dist/source/src/connect/cli/index.ts +57 -0
- package/dist/source/src/connect/server/card-client.ts +834 -0
- package/dist/source/src/connect/server/card-delivery.ts +301 -0
- package/dist/source/src/connect/server/card-events.ts +473 -0
- package/dist/source/src/connect/server/card-idempotency.ts +27 -0
- package/dist/source/src/connect/server/card-inbox.ts +82 -0
- package/dist/source/src/connect/server/card-intent-token.ts +588 -0
- package/dist/source/src/connect/server/card-polling.ts +69 -0
- package/dist/source/src/connect/server/card-signing.ts +115 -0
- package/dist/source/src/connect/server/card-transport.ts +282 -0
- package/dist/source/src/connect/server/errors.ts +280 -0
- package/dist/source/src/connect/server/fixtures/engine/card-events.synthetic.ts +84 -0
- package/dist/source/src/connect/server/retry-after.ts +12 -0
- package/dist/source/src/connect/testing/card-inbox.ts +124 -0
- package/dist/source/src/connect/testing/card-scenarios.ts +243 -0
- package/dist/source/src/connect/testing/card-simulator-vectors.ts +262 -0
- package/dist/source/src/connect/testing/card-simulator.ts +531 -0
- package/dist/source/src/connect/testing/interlace-card-transactions.ts +704 -0
- package/dist/source/src/connect/testing/pure-sha256.ts +123 -0
- package/dist/source/src/connect/wire.d.ts +472 -0
- package/dist/source/src/index.ts +135 -0
- package/dist/source/src/testing-browser.ts +24 -0
- package/dist/source/src/testing.ts +26 -0
- package/dist/source/tsconfig.json +20 -0
- package/dist/testing-browser.d.ts +220 -0
- package/dist/testing-browser.js +5 -0
- package/dist/testing.cjs +6 -0
- package/dist/testing.d.cts +199 -0
- package/dist/testing.d.ts +199 -0
- package/dist/testing.js +5 -0
- package/package.json +60 -4
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Reconciliation and recovery
|
|
2
|
+
|
|
3
|
+
This page explains how to inspect delivery history, request replay, recover dead letters, and report lifecycle changes.
|
|
4
|
+
|
|
5
|
+
## Page through a fixed snapshot
|
|
6
|
+
|
|
7
|
+
1. Select an approved fixed `selection_id` or a time window within your approved coverage, a target revision and a page size from 1 to 100. Sequence ranges are not a query option.
|
|
8
|
+
2. Call `card.deliveries.list`. Retain the returned snapshot token and cursor.
|
|
9
|
+
3. For every next page, send the same selection and snapshot token with the returned cursor. Do not widen the time window or change target revision midway.
|
|
10
|
+
4. Stop when `complete` is true. `snapshot_at` identifies the snapshot; it is not a sequence watermark.
|
|
11
|
+
|
|
12
|
+
Results contain delivery metadata such as `event_id`, origin connection, nullable `connection_sequence`, event digest, target revision and `delivery_state`. They do **not** return the event kind, original body or signature, and cannot be used as independently verifiable event deliveries. A missing sequence does not prove an event will never be delivered: it may be invisible, outside the selected range or outside your authorization.
|
|
13
|
+
|
|
14
|
+
Reconciliation `event_sha256` includes the `sha256:` prefix; `verifyEventDelivery` returns `bodyDigest` as bare hexadecimal. Normalize before comparison using the tested `sameDeliveryDigest` function below.
|
|
15
|
+
|
|
16
|
+
| `delivery_state` | Meaning |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `pending` | Awaiting delivery. |
|
|
19
|
+
| `held` | Delivery is held. |
|
|
20
|
+
| `accepted` | The target accepted a delivery; this does not prove the recipient's business processing succeeded. |
|
|
21
|
+
| `failed` | An attempt failed and is awaiting retry. |
|
|
22
|
+
| `dead_lettered` | Retry processing has ended in a dead letter. |
|
|
23
|
+
| `indeterminate` | The result of an attempt is unknown. |
|
|
24
|
+
|
|
25
|
+
## Request historical replay
|
|
26
|
+
|
|
27
|
+
Submit only the program reference and an already approved selection ID with `card.deliveryReplays.create` and a stable idempotency key; the SDK supplies the program reference. Replay needs a separately approved grant. You cannot select individual events or a sequence range in this request. HTTP 202 means the request was accepted, not that any event was returned or delivered, and it guarantees neither delivery nor timing. Events are sent later through the normal delivery channel, using the normal sending budget. Their event ID and body stay the same; timestamp and signature change. Verify every arriving replay. Replay is an operational action, not a synchronous way to fill a gap during a delivery handler.
|
|
28
|
+
|
|
29
|
+
## Recover a dead letter
|
|
30
|
+
|
|
31
|
+
`card.deadLetters.list` and `card.deadLetters.replay` cover the legacy binding-event channel within your authorized connection. They do not cover charge events or the newer fixed-selection replay. A successful request does not prove that the event has been delivered again; an out-of-scope ID does not provide cross-tenant discovery.
|
|
32
|
+
|
|
33
|
+
## Operational reconciliation
|
|
34
|
+
|
|
35
|
+
Process and deduplicate deliveries as they arrive. Periodically compare your records with the approved reconciliation view. If you find `dead_lettered`, `failed`, `indeterminate`, or an expected event absent from your records, use the onboarding contact channel to arrange an appropriate replay with Facto.
|
|
36
|
+
|
|
37
|
+
Original delivery and replay share one sending budget for the same event and target. Once exhausted, replay to that same target will not send again; contact Facto through the onboarding channel.
|
|
38
|
+
|
|
39
|
+
## Report a lifecycle event
|
|
40
|
+
|
|
41
|
+
Use `card.events.record` with the original certified provider assertion. The SDK does not mint that assertion. The local simulator accepts a synthetic assertion only for demonstration; it does not certify a provider signature or perform a real lifecycle effect.
|
|
42
|
+
|
|
43
|
+
The tested example covers pagination, historical replay, dead-letter lookup and replay, and lifecycle submission. Supply actual approved IDs and assertions from your integration.
|
|
44
|
+
|
|
45
|
+
<!-- example:reconciliation -->
|
|
46
|
+
```typescript
|
|
47
|
+
import type { CardInboundEventInput, CardClient } from '@facto-to/card'
|
|
48
|
+
|
|
49
|
+
export function sameDeliveryDigest(eventSha256: string, bodySha256: string): boolean {
|
|
50
|
+
return eventSha256 === bodySha256
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function reconcileAndReplay(card: CardClient, targetRevision: string, selectionId: string, replayKey: string) {
|
|
54
|
+
let cursor: string | undefined
|
|
55
|
+
let snapshot: string | undefined
|
|
56
|
+
const items = []
|
|
57
|
+
do {
|
|
58
|
+
const page = await card.deliveries.list({
|
|
59
|
+
target_revision: targetRevision,
|
|
60
|
+
selection_id: selectionId,
|
|
61
|
+
page_size: 100,
|
|
62
|
+
...(snapshot ? { snapshot_token: snapshot } : {}),
|
|
63
|
+
...(cursor ? { cursor } : {}),
|
|
64
|
+
})
|
|
65
|
+
items.push(...page.items)
|
|
66
|
+
snapshot = page.snapshot_token
|
|
67
|
+
cursor = page.next_cursor ?? undefined
|
|
68
|
+
if (page.complete) break
|
|
69
|
+
if (!cursor) throw new Error('incomplete_page_without_cursor')
|
|
70
|
+
} while (true)
|
|
71
|
+
const replay = await card.deliveryReplays.create({ selection_id: selectionId }, { idempotencyKey: replayKey })
|
|
72
|
+
return { items, replay }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function recoverDeadLetter(card: CardClient, deadLetterId: string) {
|
|
76
|
+
const page = await card.deadLetters.list({ limit: 10 })
|
|
77
|
+
const replay = await card.deadLetters.replay(deadLetterId)
|
|
78
|
+
return { page, replay }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function recordInboundEvent(card: CardClient, event: CardInboundEventInput) {
|
|
82
|
+
// Supply the original certified provider JWS assertion; the SDK does not mint it.
|
|
83
|
+
return card.events.record(event)
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
<!-- /example:reconciliation -->
|