@facto-to/connect 0.0.1-beta.1 → 0.0.1-beta.13
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 +140 -81
- package/dist/browser/index.cjs +29 -20
- package/dist/browser/index.d.cts +1 -31
- package/dist/browser/index.d.ts +1 -31
- package/dist/browser/index.js +28 -19
- package/dist/card-transport-Zh-6EMPi.d.cts +63 -0
- package/dist/card-transport-Zh-6EMPi.d.ts +63 -0
- package/dist/chunk-2WJ3CACP.js +1 -0
- package/dist/chunk-MSUNZ66U.js +2 -0
- package/dist/cli/index.cjs +6 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/index.d-BikZSd0p.d.cts +1030 -0
- package/dist/index.d-BikZSd0p.d.ts +1030 -0
- package/dist/react/index.cjs +0 -1
- package/dist/react/index.js +0 -1
- package/dist/server/card-connect-admin-client.cjs +2 -0
- package/dist/server/card-connect-admin-client.d.cts +318 -0
- package/dist/server/card-connect-admin-client.d.ts +318 -0
- package/dist/server/card-connect-admin-client.js +1 -0
- package/dist/server/index.cjs +1 -2
- package/dist/server/index.d.cts +1186 -291
- package/dist/server/index.d.ts +1186 -291
- package/dist/server/index.js +1 -2
- package/dist/testing/index.cjs +1 -2
- package/dist/testing/index.d.cts +2 -12
- package/dist/testing/index.d.ts +2 -12
- package/dist/testing/index.js +1 -2
- package/package.json +64 -17
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.js.map +0 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -1,134 +1,1211 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { C as CardEnvironment, S as ServerRetryOptions } from '../card-transport-Zh-6EMPi.js';
|
|
2
|
+
export { F as FactoConnectServerError, b as FactoConnectServerErrorCode, w as withServerRetry } from '../card-transport-Zh-6EMPi.js';
|
|
3
|
+
import { Q as MandatePayment$1, R as CreateMandatePaymentRequest$1, T as MandateUseCase, U as MandateLimitPeriod, E as ExchangeLinkCodeResponse, V as PaymentCapabilityRequestProperties, W as PaymentCapabilityResponse, X as MandateAuthorizationSessionStatus, Y as MandateStatus, Z as MandatePaymentStatus, _ as MandateDeclineReason } from '../index.d-BikZSd0p.js';
|
|
4
|
+
export { $ as PaymentReadinessNotReadyReason, a0 as PaymentReadinessScope } from '../index.d-BikZSd0p.js';
|
|
5
|
+
|
|
6
|
+
declare const CARD_INTENT_JWKS_PATH: "/.well-known/facto/card/connect/jwks.json";
|
|
7
|
+
interface CardIntentJwk {
|
|
8
|
+
kty: string;
|
|
9
|
+
crv: string;
|
|
10
|
+
x: string;
|
|
11
|
+
kid?: string;
|
|
12
|
+
alg?: string;
|
|
13
|
+
use?: string;
|
|
14
|
+
}
|
|
15
|
+
interface CardIntentJwks {
|
|
16
|
+
keys: CardIntentJwk[];
|
|
17
|
+
}
|
|
18
|
+
type CardIntentJwksInput = CardIntentJwks | string | (() => CardIntentJwks | Promise<CardIntentJwks>);
|
|
19
|
+
interface VerifyCardIntentTokenInput {
|
|
20
|
+
intentToken: string;
|
|
21
|
+
jwks?: CardIntentJwksInput;
|
|
22
|
+
apiBaseUrl?: string;
|
|
23
|
+
environment?: CardEnvironment;
|
|
24
|
+
audience: string;
|
|
25
|
+
issuer?: string;
|
|
26
|
+
nowMs?: number | Date;
|
|
27
|
+
clockToleranceSeconds?: number;
|
|
28
|
+
}
|
|
29
|
+
interface ConnectVerifyCardIntentTokenInput extends Omit<VerifyCardIntentTokenInput, 'environment'> {
|
|
30
|
+
environment?: CardEnvironment | 'sandbox';
|
|
31
|
+
}
|
|
32
|
+
interface VerifiedCardIntentToken {
|
|
33
|
+
programId: string;
|
|
34
|
+
pairwiseSubject: string;
|
|
35
|
+
nonce: string;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
}
|
|
38
|
+
type FactoIntentTokenErrorCode = 'FACTO_INTENT_TOKEN_INPUT_INVALID' | 'FACTO_INTENT_TOKEN_JWKS_INVALID' | 'FACTO_INTENT_TOKEN_MALFORMED' | 'FACTO_INTENT_TOKEN_UNSUPPORTED_ALG' | 'FACTO_INTENT_TOKEN_SIGNATURE_INVALID' | 'FACTO_INTENT_TOKEN_ISSUER_MISMATCH' | 'FACTO_INTENT_TOKEN_AUDIENCE_MISMATCH' | 'FACTO_INTENT_TOKEN_EXPIRED' | 'FACTO_INTENT_TOKEN_CLAIMS_INVALID';
|
|
39
|
+
declare class FactoIntentTokenError extends Error {
|
|
40
|
+
readonly code: FactoIntentTokenErrorCode;
|
|
41
|
+
readonly details?: unknown;
|
|
42
|
+
constructor(code: FactoIntentTokenErrorCode, message: string, options?: {
|
|
43
|
+
details?: unknown;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
declare function verifyCardIntentTokenForConnect(input: ConnectVerifyCardIntentTokenInput): Promise<VerifiedCardIntentToken>;
|
|
47
|
+
|
|
48
|
+
declare const PSP_CAPABILITY_TEMPLATES: readonly ["psp_connect_sandbox", "psp_mandate_sandbox", "psp_billing_sandbox"];
|
|
49
|
+
type PspCapabilityTemplate = (typeof PSP_CAPABILITY_TEMPLATES)[number];
|
|
50
|
+
declare const PSP_CREDENTIAL_SCOPES: Record<PspCapabilityTemplate, readonly string[]>;
|
|
51
|
+
declare function carriesMoneyVerb(template: PspCapabilityTemplate): boolean;
|
|
52
|
+
declare const PSP_CREDENTIAL_KEYSPACE: {
|
|
53
|
+
readonly dev: {
|
|
54
|
+
readonly clientIdPrefix: "dev_pspid_";
|
|
55
|
+
readonly clientSecretPrefix: "dev_pspsk_";
|
|
56
|
+
};
|
|
57
|
+
readonly test: {
|
|
58
|
+
readonly clientIdPrefix: "test_pspid_";
|
|
59
|
+
};
|
|
60
|
+
readonly lab: {
|
|
61
|
+
readonly clientIdPrefix: "lab_pspid_";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
declare const PSP_PARTNER_ROLE_TYPE = "psp";
|
|
65
|
+
type SubMerchantFields = 'subMerchantRef' | 'subMerchantDisplayName';
|
|
66
|
+
declare function withSubMerchant<const T extends CreateMandatePaymentRequest$1>(request: T, subMerchant: {
|
|
67
|
+
ref?: string;
|
|
68
|
+
displayName?: string;
|
|
69
|
+
}): Omit<T, SubMerchantFields> & Pick<CreateMandatePaymentRequest$1, SubMerchantFields>;
|
|
70
|
+
declare function subMerchantOf(payment: Pick<MandatePayment$1, SubMerchantFields>): {
|
|
71
|
+
ref?: string;
|
|
72
|
+
displayName?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type EnterpriseCasDecimalString = string;
|
|
76
|
+
type EnterpriseCommandCasTriple = readonly [
|
|
77
|
+
EnterpriseCasDecimalString,
|
|
78
|
+
EnterpriseCasDecimalString,
|
|
79
|
+
EnterpriseCasDecimalString
|
|
80
|
+
];
|
|
81
|
+
interface EnterpriseJournalOwnerScope {
|
|
82
|
+
readonly audience: string;
|
|
83
|
+
readonly principalId: string;
|
|
84
|
+
readonly appId: string;
|
|
85
|
+
readonly organizationId: string;
|
|
86
|
+
readonly targetRealm: string;
|
|
87
|
+
readonly opaqueIdentityRef?: string;
|
|
88
|
+
}
|
|
89
|
+
interface EnterpriseCallerSessionContext {
|
|
90
|
+
readonly ownerScope: EnterpriseJournalOwnerScope;
|
|
91
|
+
readonly sessionId: string;
|
|
92
|
+
readonly authEpoch: number;
|
|
93
|
+
readonly canRead: boolean;
|
|
94
|
+
readonly canExecute: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface EnterpriseOriginalCommandEnvelope {
|
|
97
|
+
readonly ownerScope: EnterpriseJournalOwnerScope;
|
|
98
|
+
readonly commandRef: string;
|
|
99
|
+
readonly idempotencyKey: string;
|
|
100
|
+
readonly kind: string;
|
|
101
|
+
readonly scopeRef: string;
|
|
102
|
+
readonly businessRef: string;
|
|
103
|
+
readonly canonicalRequestBytes: Uint8Array;
|
|
104
|
+
readonly inputDigest: string;
|
|
105
|
+
readonly casTriple: EnterpriseCommandCasTriple;
|
|
106
|
+
}
|
|
107
|
+
type EnterpriseJournalEntryStatus = 'send_permitted' | 'unknown' | 'parked' | 'resolved';
|
|
108
|
+
interface EnterpriseResolvedCommandOutcome {
|
|
109
|
+
readonly completionRef: string;
|
|
110
|
+
readonly observedAtIso: string;
|
|
111
|
+
readonly currentResourceCasTriple?: EnterpriseCommandCasTriple;
|
|
112
|
+
}
|
|
113
|
+
interface EnterprisePersistedJournalRecord {
|
|
114
|
+
readonly schemaVersion: 1;
|
|
115
|
+
readonly storageKey: string;
|
|
116
|
+
readonly revision: number;
|
|
117
|
+
readonly envelope: {
|
|
118
|
+
readonly ownerScope: EnterpriseJournalOwnerScope;
|
|
119
|
+
readonly commandRef: string;
|
|
120
|
+
readonly idempotencyKey: string;
|
|
121
|
+
readonly kind: string;
|
|
122
|
+
readonly scopeRef: string;
|
|
123
|
+
readonly businessRef: string;
|
|
124
|
+
readonly canonicalRequestBytesBase64: string;
|
|
125
|
+
readonly canonicalRequestByteLength: number;
|
|
126
|
+
readonly inputDigest: string;
|
|
127
|
+
readonly casTriple: EnterpriseCommandCasTriple;
|
|
128
|
+
};
|
|
129
|
+
readonly state: {
|
|
130
|
+
readonly status: EnterpriseJournalEntryStatus;
|
|
131
|
+
readonly firstPostMarked: true;
|
|
132
|
+
readonly firstPostPermitToken: string;
|
|
133
|
+
readonly sendAttempted: boolean;
|
|
134
|
+
readonly lastObservationKind?: string;
|
|
135
|
+
readonly resolvedOutcome?: EnterpriseResolvedCommandOutcome;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
type EnterpriseJournalCasResult = {
|
|
139
|
+
readonly applied: true;
|
|
140
|
+
readonly record: EnterprisePersistedJournalRecord;
|
|
141
|
+
} | {
|
|
142
|
+
readonly applied: false;
|
|
143
|
+
readonly currentRecord: EnterprisePersistedJournalRecord | null;
|
|
144
|
+
};
|
|
145
|
+
interface EnterpriseCommandJournalStorePort {
|
|
146
|
+
readonly durabilityContract: 'atomic-durable-cas-v1';
|
|
147
|
+
load(storageKey: string): Promise<EnterprisePersistedJournalRecord | null>;
|
|
148
|
+
compareAndSwap(input: {
|
|
149
|
+
readonly storageKey: string;
|
|
150
|
+
readonly expectedRevision: number | null;
|
|
151
|
+
readonly nextRecord: EnterprisePersistedJournalRecord;
|
|
152
|
+
}): Promise<EnterpriseJournalCasResult>;
|
|
153
|
+
}
|
|
154
|
+
interface EnterpriseCommandJournalSnapshot {
|
|
155
|
+
readonly storageKey: string;
|
|
156
|
+
readonly revision: number;
|
|
157
|
+
readonly envelope: EnterpriseOriginalCommandEnvelope;
|
|
158
|
+
readonly status: 'unknown' | 'parked' | 'resolved';
|
|
159
|
+
readonly firstPostMarked: true;
|
|
160
|
+
readonly firstPostPermitToken: string;
|
|
161
|
+
readonly sendAttempted: boolean;
|
|
162
|
+
readonly shouldPollPending: boolean;
|
|
163
|
+
readonly grantsExecutionAuthority: false;
|
|
164
|
+
readonly lastObservationKind?: string;
|
|
165
|
+
readonly resolvedOutcome?: EnterpriseResolvedCommandOutcome;
|
|
166
|
+
}
|
|
167
|
+
type EnterpriseCommandAdapterObservation = {
|
|
168
|
+
readonly kind: 'accepted_pending';
|
|
169
|
+
readonly httpStatus?: 202;
|
|
170
|
+
} | {
|
|
171
|
+
readonly kind: 'missing_original';
|
|
172
|
+
readonly httpStatus?: 404;
|
|
173
|
+
} | {
|
|
174
|
+
readonly kind: 'corrupted_or_unclosed';
|
|
175
|
+
readonly reason?: string;
|
|
176
|
+
} | {
|
|
177
|
+
readonly kind: 'completed';
|
|
178
|
+
readonly commandRef: string;
|
|
179
|
+
readonly idempotencyKey: string;
|
|
180
|
+
readonly commandKind: string;
|
|
181
|
+
readonly scopeRef: string;
|
|
182
|
+
readonly businessRef: string;
|
|
183
|
+
readonly inputDigest: string;
|
|
184
|
+
readonly originalCasTriple: EnterpriseCommandCasTriple;
|
|
185
|
+
readonly currentResourceCasTriple?: EnterpriseCommandCasTriple;
|
|
186
|
+
readonly completionRef: string;
|
|
187
|
+
readonly observedAtIso: string;
|
|
188
|
+
};
|
|
189
|
+
declare class EnterpriseJournalValidationError extends Error {
|
|
190
|
+
readonly code: "ENTERPRISE_JOURNAL_VALIDATION_ERROR";
|
|
191
|
+
constructor(message: string);
|
|
192
|
+
}
|
|
193
|
+
declare class EnterpriseJournalConflictError extends Error {
|
|
194
|
+
readonly code: "ENTERPRISE_JOURNAL_CONFLICT_ERROR";
|
|
195
|
+
readonly idempotencyKey: string;
|
|
196
|
+
readonly conflictingField: string;
|
|
197
|
+
constructor(idempotencyKey: string, conflictingField: string);
|
|
198
|
+
}
|
|
199
|
+
declare class EnterpriseJournalAccessDeniedError extends Error {
|
|
200
|
+
readonly code: "ENTERPRISE_JOURNAL_ACCESS_DENIED";
|
|
201
|
+
constructor(reason: string);
|
|
202
|
+
}
|
|
203
|
+
declare class EnterpriseJournalIntegrityError extends Error {
|
|
204
|
+
readonly code: "ENTERPRISE_JOURNAL_INTEGRITY_ERROR";
|
|
205
|
+
constructor(message: string);
|
|
206
|
+
}
|
|
207
|
+
declare class EnterpriseJournalStoreError extends Error {
|
|
208
|
+
readonly code: "ENTERPRISE_JOURNAL_STORE_ERROR";
|
|
209
|
+
constructor(message: string, options?: {
|
|
210
|
+
cause?: unknown;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
type EnterpriseProjectionApplyResult<TProjection> = {
|
|
214
|
+
readonly applied: true;
|
|
215
|
+
readonly action: 'updated_projection';
|
|
216
|
+
readonly projection: TProjection;
|
|
217
|
+
readonly watermarkTicket: number;
|
|
218
|
+
} | {
|
|
219
|
+
readonly applied: true;
|
|
220
|
+
readonly action: 'cleared_projection';
|
|
221
|
+
readonly projection: null;
|
|
222
|
+
readonly watermarkTicket: number;
|
|
223
|
+
} | {
|
|
224
|
+
readonly applied: false;
|
|
225
|
+
readonly reason: 'duplicate_or_unknown_ticket' | 'context_mismatch' | 'stale_ticket' | 'corrupted_ok_body';
|
|
226
|
+
readonly projection: TProjection | null;
|
|
227
|
+
readonly watermarkTicket: number;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
declare const ENTERPRISE_COMMAND_PROTOCOL_V1: "facto.enterprise-command.v1";
|
|
231
|
+
declare const ENTERPRISE_SCOPE_REF_PREFIX_V1: "enterprise-scope:v1:";
|
|
232
|
+
declare const ENTERPRISE_COMMERCIAL_REDUCTION_REF_PREFIX_V1: "efcreduce_";
|
|
233
|
+
type UInt256DecimalString = string;
|
|
234
|
+
type PositiveUInt64Revision = string;
|
|
235
|
+
type RevisionDecimalString = PositiveUInt64Revision;
|
|
236
|
+
type ScopedObjectRef = string;
|
|
237
|
+
type Sha256HexDigest = string;
|
|
238
|
+
type PrefixedSha256Digest = `sha256:${string}`;
|
|
239
|
+
type OpaqueOperationRef = string;
|
|
240
|
+
declare const ENTERPRISE_COMMAND_KINDS: readonly ["create_or_transition_source_hold", "bind_or_transition_guarantee", "record_prefund_or_partner_fact", "apply_qualified_cash", "dispatch_or_observe_execution_family", "settle_commercial_reduction"];
|
|
241
|
+
type EnterpriseCommandKind = (typeof ENTERPRISE_COMMAND_KINDS)[number];
|
|
242
|
+
declare const ENTERPRISE_SERVER_DERIVED_COMMAND_KINDS: readonly ["bind_or_transition_guarantee", "apply_qualified_cash", "dispatch_or_observe_execution_family"];
|
|
243
|
+
type EnterpriseServerDerivedCommandKind = (typeof ENTERPRISE_SERVER_DERIVED_COMMAND_KINDS)[number];
|
|
244
|
+
declare const ENTERPRISE_PUBLIC_MERCHANT_COMMAND_KINDS: readonly ["create_or_transition_source_hold", "record_prefund_or_partner_fact", "settle_commercial_reduction"];
|
|
245
|
+
type EnterprisePublicMerchantCommandKind = (typeof ENTERPRISE_PUBLIC_MERCHANT_COMMAND_KINDS)[number];
|
|
246
|
+
declare function isServerDerivedEnterpriseCommandKind(kind: unknown): kind is EnterpriseServerDerivedCommandKind;
|
|
247
|
+
declare const ENTERPRISE_CLOSURE_TARGET_TABLES: readonly ["source_holds", "guarantee_links", "prefund_partner_facts", "cash_applications", "execution_families", "commercial_reductions"];
|
|
248
|
+
type EnterpriseClosureTargetTable = (typeof ENTERPRISE_CLOSURE_TARGET_TABLES)[number];
|
|
249
|
+
declare const ENTERPRISE_TRACKED_UNKNOWN_REASONS: readonly ["source_observation_unconfirmed", "source_observation_expired", "unclosed_unknown_hold_or_attempt", "prefund_observation_unconfirmed", "prefund_observation_expired", "unresolved_reorganization", "cash_basis_disputed_or_revoked", "qualification_unconfirmed", "reconciliation_required", "current_snapshot_unavailable", "pending_commit_observation"];
|
|
250
|
+
type EnterpriseTrackedUnknownReason = (typeof ENTERPRISE_TRACKED_UNKNOWN_REASONS)[number];
|
|
251
|
+
type TrackedDecimalAmount = {
|
|
252
|
+
readonly knowledgeState: 'known';
|
|
253
|
+
readonly knownAmountRaw: UInt256DecimalString;
|
|
254
|
+
readonly unknownReason: null;
|
|
255
|
+
} | {
|
|
256
|
+
readonly knowledgeState: 'unknown';
|
|
257
|
+
readonly knownAmountRaw: null;
|
|
258
|
+
readonly unknownReason: EnterpriseTrackedUnknownReason;
|
|
259
|
+
};
|
|
260
|
+
declare const ENTERPRISE_ASSET_KINDS: readonly ["erc20", "native_gas", "fiat_minor"];
|
|
261
|
+
type EnterpriseAssetKind = (typeof ENTERPRISE_ASSET_KINDS)[number];
|
|
262
|
+
interface AssetIdentifier {
|
|
263
|
+
readonly assetKind: EnterpriseAssetKind;
|
|
264
|
+
readonly chainId: number;
|
|
265
|
+
readonly assetAddress: string;
|
|
266
|
+
readonly decimals: number;
|
|
267
|
+
}
|
|
268
|
+
declare const ENTERPRISE_SOURCE_PROTOCOLS: readonly ["credit_vault_v1", "compound_v2", "aave_v3", "morpho_blue", "custody_direct"];
|
|
269
|
+
type EnterpriseSourceProtocolId = (typeof ENTERPRISE_SOURCE_PROTOCOLS)[number];
|
|
270
|
+
interface NormalizedSourceRootKey {
|
|
271
|
+
readonly chainId: number;
|
|
272
|
+
readonly protocolId: EnterpriseSourceProtocolId;
|
|
273
|
+
readonly sourceAssetId: string;
|
|
274
|
+
readonly sourceDecimals: number;
|
|
275
|
+
readonly protectedResourceRef: string;
|
|
276
|
+
readonly positionDigest: Sha256HexDigest;
|
|
277
|
+
}
|
|
278
|
+
interface OriginalThreeCasInput {
|
|
279
|
+
readonly expectedContextRevision: PositiveUInt64Revision;
|
|
280
|
+
readonly expectedSourceRevision: PositiveUInt64Revision;
|
|
281
|
+
readonly expectedBudgetRevision: PositiveUInt64Revision;
|
|
282
|
+
}
|
|
283
|
+
interface SharedPrefundAdmissionGuard {
|
|
284
|
+
readonly prefundAccountRef: ScopedObjectRef;
|
|
285
|
+
readonly riskCapRef: ScopedObjectRef;
|
|
286
|
+
readonly allocationRef: ScopedObjectRef;
|
|
287
|
+
readonly budgetEpoch: PositiveUInt64Revision;
|
|
288
|
+
readonly expectedAllocationRevision: PositiveUInt64Revision;
|
|
289
|
+
}
|
|
290
|
+
declare const ENTERPRISE_PRODUCER_KINDS: readonly ["merchant_mandate_charge", "partner_settlement_observation", "partner_payout_order", "credit_vault_protocol_receipt", "consumer_direct_transfer_receipt", "partner_funding_capture", "original_execution_initiation_observation", "original_execution_unused_observation"];
|
|
291
|
+
type EnterpriseProducerKind = (typeof ENTERPRISE_PRODUCER_KINDS)[number];
|
|
292
|
+
interface ProducerVerificationEnvelope {
|
|
293
|
+
readonly producerKind: EnterpriseProducerKind;
|
|
294
|
+
readonly providerAuthority: ScopedObjectRef;
|
|
295
|
+
readonly upstreamRecordRef: ScopedObjectRef;
|
|
296
|
+
readonly externalEffectRef: ScopedObjectRef;
|
|
297
|
+
readonly evidenceDigest: Sha256HexDigest;
|
|
298
|
+
readonly callerRequestedValidUntil?: string;
|
|
299
|
+
}
|
|
300
|
+
interface CacheCoordinationEnvelope {
|
|
301
|
+
readonly ownerPartitionHash: Sha256HexDigest;
|
|
302
|
+
readonly sessionFenceRef: ScopedObjectRef;
|
|
303
|
+
readonly authEpoch: PositiveUInt64Revision;
|
|
304
|
+
readonly projectionTicket: PositiveUInt64Revision;
|
|
305
|
+
readonly pendingPollRequired: boolean;
|
|
306
|
+
readonly auditIdentityRetentionRequired: true;
|
|
307
|
+
}
|
|
308
|
+
declare const ENTERPRISE_TARGET_HOLD_STATES: readonly ["active", "executing", "unknown", "settled_verified_effect", "released_verified_unused", "expired_verified_unused"];
|
|
309
|
+
type EnterpriseTargetHoldState = (typeof ENTERPRISE_TARGET_HOLD_STATES)[number];
|
|
310
|
+
declare const ENTERPRISE_TERMINAL_HOLD_STATES: readonly ["settled_verified_effect", "released_verified_unused", "expired_verified_unused"];
|
|
311
|
+
type EnterpriseTerminalHoldState = (typeof ENTERPRISE_TERMINAL_HOLD_STATES)[number];
|
|
312
|
+
interface CreateOrTransitionSourceHoldRequest {
|
|
313
|
+
readonly commandKind: 'create_or_transition_source_hold';
|
|
314
|
+
readonly inputDigest: Sha256HexDigest;
|
|
315
|
+
readonly cas: OriginalThreeCasInput;
|
|
316
|
+
readonly sourceRoot: NormalizedSourceRootKey;
|
|
317
|
+
readonly holdRef: ScopedObjectRef;
|
|
318
|
+
readonly targetHoldState: EnterpriseTargetHoldState;
|
|
319
|
+
readonly settlementAsset: AssetIdentifier;
|
|
320
|
+
readonly heldUnitsRaw: UInt256DecimalString;
|
|
321
|
+
readonly heldCashRaw: UInt256DecimalString;
|
|
322
|
+
readonly scaleNumerator: UInt256DecimalString;
|
|
323
|
+
readonly scaleDenominator: UInt256DecimalString;
|
|
324
|
+
readonly slippageBufferBps: number;
|
|
325
|
+
readonly quoteExpiresAt: string;
|
|
326
|
+
readonly authorityGrantRef: ScopedObjectRef;
|
|
327
|
+
readonly scopeBindingRef: ScopedObjectRef;
|
|
328
|
+
readonly producerVerification?: ProducerVerificationEnvelope;
|
|
329
|
+
readonly commandRef: ScopedObjectRef;
|
|
330
|
+
}
|
|
331
|
+
declare const ENTERPRISE_TARGET_GUARANTEE_STATES: readonly ["active", "fulfilled", "released_unused", "expired_unused"];
|
|
332
|
+
type EnterpriseTargetGuaranteeState = (typeof ENTERPRISE_TARGET_GUARANTEE_STATES)[number];
|
|
333
|
+
interface BindOrTransitionGuaranteeRequest {
|
|
334
|
+
readonly commandKind: 'bind_or_transition_guarantee';
|
|
335
|
+
readonly inputDigest: Sha256HexDigest;
|
|
336
|
+
readonly cas: OriginalThreeCasInput;
|
|
337
|
+
readonly sharedPrefundGuard: SharedPrefundAdmissionGuard;
|
|
338
|
+
readonly guaranteeRef: ScopedObjectRef;
|
|
339
|
+
readonly commitmentRef: ScopedObjectRef;
|
|
340
|
+
readonly targetGuaranteeState: EnterpriseTargetGuaranteeState;
|
|
341
|
+
readonly asset: AssetIdentifier;
|
|
342
|
+
readonly guaranteedAmountRaw: UInt256DecimalString;
|
|
343
|
+
readonly authorityGrantRef: ScopedObjectRef;
|
|
344
|
+
readonly scopeBindingRef: ScopedObjectRef;
|
|
345
|
+
readonly producerVerification: ProducerVerificationEnvelope;
|
|
346
|
+
readonly commandRef: ScopedObjectRef;
|
|
347
|
+
}
|
|
348
|
+
declare const ENTERPRISE_PARTNER_FACT_KINDS: readonly ["prefund_deposit_observation", "partner_actual_capture_principal", "partner_settlement_debit", "partner_payout_disbursement"];
|
|
349
|
+
type EnterprisePartnerFactKind = (typeof ENTERPRISE_PARTNER_FACT_KINDS)[number];
|
|
350
|
+
interface RecordPrefundOrPartnerFactRequest {
|
|
351
|
+
readonly commandKind: 'record_prefund_or_partner_fact';
|
|
352
|
+
readonly inputDigest: Sha256HexDigest;
|
|
353
|
+
readonly cas: OriginalThreeCasInput;
|
|
354
|
+
readonly sharedPrefundGuard: SharedPrefundAdmissionGuard;
|
|
355
|
+
readonly factRef: ScopedObjectRef;
|
|
356
|
+
readonly factKind: EnterprisePartnerFactKind;
|
|
357
|
+
readonly producerVerification: ProducerVerificationEnvelope;
|
|
358
|
+
readonly commandRef: ScopedObjectRef;
|
|
359
|
+
}
|
|
360
|
+
interface ApplyQualifiedCashRequest {
|
|
361
|
+
readonly commandKind: 'apply_qualified_cash';
|
|
362
|
+
readonly inputDigest: Sha256HexDigest;
|
|
363
|
+
readonly cas: OriginalThreeCasInput;
|
|
364
|
+
readonly cashBasisRef: ScopedObjectRef;
|
|
365
|
+
readonly applicationRef: ScopedObjectRef;
|
|
366
|
+
readonly asset: AssetIdentifier;
|
|
367
|
+
readonly applyToPrincipalAmountRaw: UInt256DecimalString;
|
|
368
|
+
readonly commandRef: ScopedObjectRef;
|
|
369
|
+
}
|
|
370
|
+
interface DispatchOrObserveExecutionFamilyRequest {
|
|
371
|
+
readonly commandKind: 'dispatch_or_observe_execution_family';
|
|
372
|
+
readonly inputDigest: Sha256HexDigest;
|
|
373
|
+
readonly cas: OriginalThreeCasInput;
|
|
374
|
+
readonly sourceRoot: NormalizedSourceRootKey;
|
|
375
|
+
readonly holdRef: ScopedObjectRef;
|
|
376
|
+
readonly executionIntentRef: ScopedObjectRef;
|
|
377
|
+
readonly familyRef: ScopedObjectRef;
|
|
378
|
+
readonly exactUnitsRaw: UInt256DecimalString;
|
|
379
|
+
readonly exactCashRaw: UInt256DecimalString;
|
|
380
|
+
readonly commandRef: ScopedObjectRef;
|
|
381
|
+
}
|
|
382
|
+
interface SettleCommercialReductionRequest {
|
|
383
|
+
readonly commandKind: 'settle_commercial_reduction';
|
|
384
|
+
readonly inputDigest: Sha256HexDigest;
|
|
385
|
+
readonly cas: OriginalThreeCasInput;
|
|
386
|
+
readonly decisionRef: ScopedObjectRef;
|
|
387
|
+
readonly decisionDigest: Sha256HexDigest;
|
|
388
|
+
readonly reductionRef: ScopedObjectRef;
|
|
389
|
+
readonly cancelledAmountRaw: UInt256DecimalString;
|
|
390
|
+
readonly ruleVersion: ScopedObjectRef;
|
|
391
|
+
readonly authorityGrantRef: ScopedObjectRef;
|
|
392
|
+
readonly scopeBindingRef: ScopedObjectRef;
|
|
393
|
+
readonly feeEffectRef?: ScopedObjectRef;
|
|
394
|
+
readonly commandRef: ScopedObjectRef;
|
|
395
|
+
}
|
|
396
|
+
type EnterpriseWireCommandRequest = CreateOrTransitionSourceHoldRequest | BindOrTransitionGuaranteeRequest | RecordPrefundOrPartnerFactRequest | ApplyQualifiedCashRequest | DispatchOrObserveExecutionFamilyRequest | SettleCommercialReductionRequest;
|
|
397
|
+
type EnterprisePublicMerchantWireCommandRequest = Extract<EnterpriseWireCommandRequest, {
|
|
398
|
+
readonly commandKind: EnterprisePublicMerchantCommandKind;
|
|
399
|
+
}>;
|
|
400
|
+
type EnterpriseCanonicalRequestPayload<TRequest extends EnterpriseWireCommandRequest = EnterpriseWireCommandRequest> = TRequest extends unknown ? Omit<TRequest, 'inputDigest'> : never;
|
|
401
|
+
type EnterpriseCommandRequestInput<TRequest extends EnterpriseWireCommandRequest = EnterpriseWireCommandRequest> = TRequest extends unknown ? Omit<TRequest, 'inputDigest'> & {
|
|
402
|
+
readonly inputDigest?: Sha256HexDigest;
|
|
403
|
+
} : never;
|
|
404
|
+
interface EnterpriseCommandPathParams {
|
|
405
|
+
readonly purchaseRef: ScopedObjectRef;
|
|
406
|
+
readonly economicIntentRef: ScopedObjectRef;
|
|
407
|
+
readonly commandRef: ScopedObjectRef;
|
|
408
|
+
}
|
|
409
|
+
interface CanonicalOwnerScope {
|
|
410
|
+
readonly targetRealm: string;
|
|
411
|
+
readonly organizationId: string;
|
|
412
|
+
readonly appId: string;
|
|
413
|
+
readonly audience: 'merchant_s2s';
|
|
414
|
+
readonly principalId: string;
|
|
415
|
+
}
|
|
416
|
+
interface CanonicalEnterpriseCommandObject<TRequest extends EnterpriseWireCommandRequest = EnterpriseWireCommandRequest> {
|
|
417
|
+
readonly protocol: typeof ENTERPRISE_COMMAND_PROTOCOL_V1;
|
|
418
|
+
readonly method: 'POST';
|
|
419
|
+
readonly routeTemplate: string;
|
|
420
|
+
readonly path: EnterpriseCommandPathParams;
|
|
421
|
+
readonly ownerScope: CanonicalOwnerScope;
|
|
422
|
+
readonly idempotencyKey: ScopedObjectRef;
|
|
423
|
+
readonly request: EnterpriseCanonicalRequestPayload<TRequest>;
|
|
424
|
+
}
|
|
425
|
+
type CommandClosureTarget = {
|
|
426
|
+
readonly commandKind: 'create_or_transition_source_hold';
|
|
427
|
+
readonly targetTable: 'source_holds';
|
|
428
|
+
readonly targetRecordRef: ScopedObjectRef;
|
|
429
|
+
} | {
|
|
430
|
+
readonly commandKind: 'bind_or_transition_guarantee';
|
|
431
|
+
readonly targetTable: 'guarantee_links';
|
|
432
|
+
readonly targetRecordRef: ScopedObjectRef;
|
|
433
|
+
} | {
|
|
434
|
+
readonly commandKind: 'record_prefund_or_partner_fact';
|
|
435
|
+
readonly targetTable: 'prefund_partner_facts';
|
|
436
|
+
readonly targetRecordRef: ScopedObjectRef;
|
|
437
|
+
} | {
|
|
438
|
+
readonly commandKind: 'apply_qualified_cash';
|
|
439
|
+
readonly targetTable: 'cash_applications';
|
|
440
|
+
readonly targetRecordRef: ScopedObjectRef;
|
|
441
|
+
} | {
|
|
442
|
+
readonly commandKind: 'dispatch_or_observe_execution_family';
|
|
443
|
+
readonly targetTable: 'execution_families';
|
|
444
|
+
readonly targetRecordRef: ScopedObjectRef;
|
|
445
|
+
} | {
|
|
446
|
+
readonly commandKind: 'settle_commercial_reduction';
|
|
447
|
+
readonly targetTable: 'commercial_reductions';
|
|
448
|
+
readonly targetRecordRef: ScopedObjectRef;
|
|
449
|
+
};
|
|
450
|
+
interface MerchantCommandReceipt {
|
|
451
|
+
readonly commandRef: ScopedObjectRef;
|
|
452
|
+
readonly purchaseRef: ScopedObjectRef;
|
|
453
|
+
readonly economicIntentRef: ScopedObjectRef;
|
|
454
|
+
readonly inputDigest: Sha256HexDigest;
|
|
455
|
+
readonly commitConfirmationLevel: 'outer_commit_driver_confirmed';
|
|
456
|
+
readonly closedAt: string;
|
|
457
|
+
readonly resultContextRevision: RevisionDecimalString;
|
|
458
|
+
readonly closureTarget: CommandClosureTarget;
|
|
459
|
+
}
|
|
460
|
+
interface PublicOperationSummary {
|
|
461
|
+
readonly operationRef: OpaqueOperationRef;
|
|
462
|
+
readonly operationState: 'pending' | 'unknown' | 'closed';
|
|
463
|
+
}
|
|
464
|
+
declare const ENTERPRISE_GUARANTEE_STATES: readonly ["none", "active", "fulfilled", "released_unused", "expired_unused", "unknown"];
|
|
465
|
+
type EnterpriseGuaranteeState = (typeof ENTERPRISE_GUARANTEE_STATES)[number];
|
|
466
|
+
declare const ENTERPRISE_BUSINESS_PROGRESS_UNKNOWN_REASONS: readonly ["awaiting_trusted_observation", "effect_unconfirmed", "evidence_expired", "outbound_result_unknown", "provisional_effect", "unresolved_reorganization", "reconciliation_required"];
|
|
467
|
+
type BusinessProgressUnknownReason = (typeof ENTERPRISE_BUSINESS_PROGRESS_UNKNOWN_REASONS)[number];
|
|
468
|
+
declare const ENTERPRISE_SOURCE_EXECUTION_PROGRESS_STATES: readonly ["none", "planned", "dispatch_claimed", "awaiting_user_signature", "relayer_submitted", "broadcast_confirmed", "settled_verified_effect"];
|
|
469
|
+
type SourceExecutionProgressKnownState = (typeof ENTERPRISE_SOURCE_EXECUTION_PROGRESS_STATES)[number];
|
|
470
|
+
type SourceExecutionProgress = {
|
|
471
|
+
readonly knowledgeState: 'known';
|
|
472
|
+
readonly state: SourceExecutionProgressKnownState;
|
|
473
|
+
readonly unknownReason: null;
|
|
474
|
+
} | {
|
|
475
|
+
readonly knowledgeState: 'unknown';
|
|
476
|
+
readonly state: null;
|
|
477
|
+
readonly unknownReason: BusinessProgressUnknownReason;
|
|
478
|
+
};
|
|
479
|
+
declare const ENTERPRISE_GUARANTEE_PROGRESS_STATES: readonly ["none", "active", "fulfilled", "released_unused", "expired_unused"];
|
|
480
|
+
type GuaranteeProgressKnownState = (typeof ENTERPRISE_GUARANTEE_PROGRESS_STATES)[number];
|
|
481
|
+
type GuaranteeProgress = {
|
|
482
|
+
readonly knowledgeState: 'known';
|
|
483
|
+
readonly state: GuaranteeProgressKnownState;
|
|
484
|
+
readonly unknownReason: null;
|
|
485
|
+
} | {
|
|
486
|
+
readonly knowledgeState: 'unknown';
|
|
487
|
+
readonly state: null;
|
|
488
|
+
readonly unknownReason: BusinessProgressUnknownReason;
|
|
489
|
+
};
|
|
490
|
+
declare const ENTERPRISE_PARTNER_CAPTURE_PAYOUT_PROGRESS_STATES: readonly ["none", "pending", "partially_confirmed", "confirmed", "failed_no_effect"];
|
|
491
|
+
type PartnerCapturePayoutProgressKnownState = (typeof ENTERPRISE_PARTNER_CAPTURE_PAYOUT_PROGRESS_STATES)[number];
|
|
492
|
+
type PartnerCaptureProgress = {
|
|
493
|
+
readonly knowledgeState: 'known';
|
|
494
|
+
readonly state: PartnerCapturePayoutProgressKnownState;
|
|
495
|
+
readonly unknownReason: null;
|
|
496
|
+
} | {
|
|
497
|
+
readonly knowledgeState: 'unknown';
|
|
498
|
+
readonly state: null;
|
|
499
|
+
readonly unknownReason: BusinessProgressUnknownReason;
|
|
500
|
+
};
|
|
501
|
+
type PartnerPayoutProgress = {
|
|
502
|
+
readonly knowledgeState: 'known';
|
|
503
|
+
readonly state: PartnerCapturePayoutProgressKnownState;
|
|
504
|
+
readonly unknownReason: null;
|
|
505
|
+
} | {
|
|
506
|
+
readonly knowledgeState: 'unknown';
|
|
507
|
+
readonly state: null;
|
|
508
|
+
readonly unknownReason: BusinessProgressUnknownReason;
|
|
509
|
+
};
|
|
510
|
+
interface PartnerBusinessProgress {
|
|
511
|
+
readonly sourceExecution: SourceExecutionProgress;
|
|
512
|
+
readonly guarantee: GuaranteeProgress;
|
|
513
|
+
readonly partnerCapture: PartnerCaptureProgress;
|
|
514
|
+
readonly partnerPayout: PartnerPayoutProgress;
|
|
515
|
+
}
|
|
516
|
+
declare const ENTERPRISE_FULFILLMENT_QUALIFICATIONS: readonly ["qualified", "not_qualified", "unknown"];
|
|
517
|
+
type EnterpriseFulfillmentQualification = (typeof ENTERPRISE_FULFILLMENT_QUALIFICATIONS)[number];
|
|
518
|
+
interface PartnerOrderProjection {
|
|
519
|
+
readonly audience: 'partner_workspace' | 'merchant_s2s';
|
|
520
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
521
|
+
readonly appId: ScopedObjectRef;
|
|
522
|
+
readonly environment: string;
|
|
523
|
+
readonly settlementAsset: AssetIdentifier;
|
|
524
|
+
readonly authorizedOrderCeiling: UInt256DecimalString;
|
|
525
|
+
readonly principalEstablished: UInt256DecimalString;
|
|
526
|
+
readonly guaranteeState: EnterpriseGuaranteeState;
|
|
527
|
+
readonly effectiveGuaranteedAmount: TrackedDecimalAmount;
|
|
528
|
+
readonly partnerSettledFactAmount: UInt256DecimalString;
|
|
529
|
+
readonly appAvailableServiceAllocation: TrackedDecimalAmount;
|
|
530
|
+
readonly appActiveCommitments: UInt256DecimalString;
|
|
531
|
+
readonly budgetEpoch: PositiveUInt64Revision;
|
|
532
|
+
readonly allocationRevision: PositiveUInt64Revision;
|
|
533
|
+
readonly fulfillmentPermitted: boolean;
|
|
534
|
+
readonly cacheCoordination: CacheCoordinationEnvelope;
|
|
535
|
+
readonly projectionRevision: RevisionDecimalString;
|
|
536
|
+
readonly asOf: string;
|
|
537
|
+
readonly fulfillmentQualification: EnterpriseFulfillmentQualification;
|
|
538
|
+
readonly operations: readonly PublicOperationSummary[];
|
|
539
|
+
readonly businessProgress: PartnerBusinessProgress;
|
|
540
|
+
}
|
|
541
|
+
interface MerchantS2sOrderProjection extends PartnerOrderProjection {
|
|
542
|
+
readonly audience: 'merchant_s2s';
|
|
543
|
+
readonly operations: readonly [];
|
|
544
|
+
}
|
|
545
|
+
interface MerchantCommandEnvelopeResponse {
|
|
546
|
+
readonly outcomeStatus: 'applied' | 'replayed_identical';
|
|
547
|
+
readonly receipt: MerchantCommandReceipt;
|
|
548
|
+
readonly projection: MerchantS2sOrderProjection;
|
|
549
|
+
readonly pendingPollRequired: false;
|
|
550
|
+
readonly auditIdentityRetentionRequired: true;
|
|
551
|
+
}
|
|
552
|
+
interface MerchantCommandRecoveryResponse {
|
|
553
|
+
readonly outcomeStatus: 'closed_recovered';
|
|
554
|
+
readonly receipt: MerchantCommandReceipt;
|
|
555
|
+
readonly projection: MerchantS2sOrderProjection;
|
|
556
|
+
readonly pendingPollRequired: false;
|
|
557
|
+
readonly auditIdentityRetentionRequired: true;
|
|
558
|
+
}
|
|
559
|
+
interface PublicOperationReceipt {
|
|
560
|
+
readonly operationRef: OpaqueOperationRef;
|
|
561
|
+
readonly closedAt: string;
|
|
562
|
+
readonly completion: 'this_operation_closed';
|
|
563
|
+
}
|
|
564
|
+
declare const ENTERPRISE_OPERATION_UNKNOWN_REASONS: readonly ["operation_pending", "external_outcome_unknown", "closure_not_confirmed", "original_operation_not_observed"];
|
|
565
|
+
type EnterpriseOperationUnknownReason = (typeof ENTERPRISE_OPERATION_UNKNOWN_REASONS)[number];
|
|
566
|
+
interface PartnerWorkspaceOrderProjection extends PartnerOrderProjection {
|
|
567
|
+
readonly audience: 'partner_workspace';
|
|
568
|
+
}
|
|
569
|
+
interface PartnerProjectionResponse {
|
|
570
|
+
readonly projection: PartnerWorkspaceOrderProjection;
|
|
571
|
+
}
|
|
572
|
+
interface PartnerOperationRecoveryResponse {
|
|
573
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
574
|
+
readonly operationRef: OpaqueOperationRef;
|
|
575
|
+
readonly outcomeStatus: 'closed_recovered';
|
|
576
|
+
readonly receipt: PublicOperationReceipt;
|
|
577
|
+
readonly projection: PartnerWorkspaceOrderProjection;
|
|
578
|
+
readonly pendingPollRequired: false;
|
|
579
|
+
readonly auditIdentityRetentionRequired: true;
|
|
580
|
+
}
|
|
581
|
+
interface PartnerOperationUnknownRecoveryResponse {
|
|
582
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
583
|
+
readonly operationRef: OpaqueOperationRef;
|
|
584
|
+
readonly outcomeStatus: 'unknown';
|
|
585
|
+
readonly unknownReason: EnterpriseOperationUnknownReason;
|
|
586
|
+
readonly receipt: null;
|
|
587
|
+
readonly projection: PartnerWorkspaceOrderProjection | null;
|
|
588
|
+
readonly pendingPollRequired: true;
|
|
589
|
+
readonly auditIdentityRetentionRequired: true;
|
|
590
|
+
readonly retryAction: 'retain_journal_and_poll_readonly_recovery';
|
|
591
|
+
}
|
|
592
|
+
type ConsumerCollectionProgress = {
|
|
593
|
+
readonly knowledgeState: 'known';
|
|
594
|
+
readonly state: 'partially_received';
|
|
595
|
+
readonly unknownReason: null;
|
|
596
|
+
} | {
|
|
597
|
+
readonly knowledgeState: 'unknown';
|
|
598
|
+
readonly state: null;
|
|
599
|
+
readonly unknownReason: BusinessProgressUnknownReason;
|
|
600
|
+
};
|
|
601
|
+
interface ConsumerBusinessProgress {
|
|
602
|
+
readonly sourceExecution: SourceExecutionProgress;
|
|
603
|
+
readonly guarantee: GuaranteeProgress;
|
|
604
|
+
readonly partnerCapture: PartnerCaptureProgress;
|
|
605
|
+
readonly partnerPayout: PartnerPayoutProgress;
|
|
606
|
+
readonly userCollection: ConsumerCollectionProgress;
|
|
607
|
+
}
|
|
608
|
+
declare const ENTERPRISE_CONSUMER_EXECUTION_STATES: readonly ["none", "planned", "dispatch_claimed", "awaiting_user_signature", "relayer_submitted", "broadcast_confirmed", "unknown", "settled_verified_effect"];
|
|
609
|
+
type EnterpriseConsumerExecutionState = (typeof ENTERPRISE_CONSUMER_EXECUTION_STATES)[number];
|
|
610
|
+
interface ConsumerOrderProjection {
|
|
611
|
+
readonly audience: 'consumer';
|
|
612
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
613
|
+
readonly settlementAsset: AssetIdentifier;
|
|
614
|
+
readonly authorizedPaymentCeiling: UInt256DecimalString;
|
|
615
|
+
readonly establishedPrincipal: UInt256DecimalString;
|
|
616
|
+
readonly confirmedCollectedFromMe: UInt256DecimalString;
|
|
617
|
+
readonly appliedToPrincipal: TrackedDecimalAmount;
|
|
618
|
+
readonly unappliedOwnCash: TrackedDecimalAmount;
|
|
619
|
+
readonly remainingMyDebt: TrackedDecimalAmount;
|
|
620
|
+
readonly mySourceWithdrawableSnapshot: TrackedDecimalAmount;
|
|
621
|
+
readonly myActiveHoldAmount: UInt256DecimalString;
|
|
622
|
+
readonly myEffectiveAvailableSource: TrackedDecimalAmount;
|
|
623
|
+
readonly executionState: EnterpriseConsumerExecutionState;
|
|
624
|
+
readonly fulfillmentPermitted: boolean;
|
|
625
|
+
readonly cacheCoordination: CacheCoordinationEnvelope;
|
|
626
|
+
readonly projectionRevision: RevisionDecimalString;
|
|
627
|
+
readonly asOf: string;
|
|
628
|
+
readonly fulfillmentQualification: EnterpriseFulfillmentQualification;
|
|
629
|
+
readonly operations: readonly PublicOperationSummary[];
|
|
630
|
+
readonly businessProgress: ConsumerBusinessProgress;
|
|
631
|
+
}
|
|
632
|
+
interface ConsumerProjectionResponse {
|
|
633
|
+
readonly projection: ConsumerOrderProjection;
|
|
634
|
+
}
|
|
635
|
+
interface ConsumerOperationRecoveryResponse {
|
|
636
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
637
|
+
readonly operationRef: OpaqueOperationRef;
|
|
638
|
+
readonly outcomeStatus: 'closed_recovered';
|
|
639
|
+
readonly receipt: PublicOperationReceipt;
|
|
640
|
+
readonly projection: ConsumerOrderProjection;
|
|
641
|
+
readonly pendingPollRequired: false;
|
|
642
|
+
readonly auditIdentityRetentionRequired: true;
|
|
643
|
+
}
|
|
644
|
+
interface ConsumerOperationUnknownRecoveryResponse {
|
|
645
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
646
|
+
readonly operationRef: OpaqueOperationRef;
|
|
647
|
+
readonly outcomeStatus: 'unknown';
|
|
648
|
+
readonly unknownReason: EnterpriseOperationUnknownReason;
|
|
649
|
+
readonly receipt: null;
|
|
650
|
+
readonly projection: ConsumerOrderProjection | null;
|
|
651
|
+
readonly pendingPollRequired: true;
|
|
652
|
+
readonly auditIdentityRetentionRequired: true;
|
|
653
|
+
readonly retryAction: 'retain_journal_and_poll_readonly_recovery';
|
|
654
|
+
}
|
|
655
|
+
interface ConsoleBusinessProgress extends ConsumerBusinessProgress {
|
|
656
|
+
}
|
|
657
|
+
interface ConsoleOrderProjection {
|
|
658
|
+
readonly audience: 'console_admin';
|
|
659
|
+
readonly purchaseRef: ScopedObjectRef;
|
|
660
|
+
readonly economicIntentRef: ScopedObjectRef;
|
|
661
|
+
readonly appId: ScopedObjectRef;
|
|
662
|
+
readonly organizationId: string;
|
|
663
|
+
readonly contextRevision: RevisionDecimalString;
|
|
664
|
+
readonly sourceRevision: RevisionDecimalString;
|
|
665
|
+
readonly budgetRevision: RevisionDecimalString;
|
|
666
|
+
readonly authorizedCeilingRaw: UInt256DecimalString;
|
|
667
|
+
readonly principalEstablishedRaw: UInt256DecimalString;
|
|
668
|
+
readonly consumerCollectedRaw: UInt256DecimalString;
|
|
669
|
+
readonly consumerAppliedToPrincipalRaw: TrackedDecimalAmount;
|
|
670
|
+
readonly consumerUnappliedRaw: TrackedDecimalAmount;
|
|
671
|
+
readonly remainingRecoverablePrincipalRaw: TrackedDecimalAmount;
|
|
672
|
+
readonly sharedPrefundAccountAvailableRaw: TrackedDecimalAmount;
|
|
673
|
+
readonly appAllocationRemainingRaw: TrackedDecimalAmount;
|
|
674
|
+
readonly sourceWithdrawableSnapshotRaw: TrackedDecimalAmount;
|
|
675
|
+
readonly sourceRepresentedHoldRaw: UInt256DecimalString;
|
|
676
|
+
readonly sourceUnrepresentedHoldRaw: UInt256DecimalString;
|
|
677
|
+
readonly sourceEffectiveAvailableRaw: TrackedDecimalAmount;
|
|
678
|
+
readonly fulfillmentPermitted: boolean;
|
|
679
|
+
readonly cacheCoordination: CacheCoordinationEnvelope;
|
|
680
|
+
readonly projectionRevision: RevisionDecimalString;
|
|
681
|
+
readonly asOf: string;
|
|
682
|
+
readonly fulfillmentQualification: EnterpriseFulfillmentQualification;
|
|
683
|
+
readonly settlementAsset: AssetIdentifier;
|
|
684
|
+
readonly businessProgress: ConsoleBusinessProgress;
|
|
685
|
+
}
|
|
686
|
+
interface ConsoleProjectionResponse {
|
|
687
|
+
readonly projection: ConsoleOrderProjection;
|
|
688
|
+
}
|
|
689
|
+
interface ConsoleCommandReceipt {
|
|
690
|
+
readonly commandRef: ScopedObjectRef;
|
|
691
|
+
readonly purchaseRef: ScopedObjectRef;
|
|
692
|
+
readonly economicIntentRef: ScopedObjectRef;
|
|
693
|
+
readonly inputDigest: Sha256HexDigest;
|
|
694
|
+
readonly commitConfirmationLevel: 'outer_commit_driver_confirmed';
|
|
695
|
+
readonly closedAt: string;
|
|
696
|
+
readonly resultContextRevision: RevisionDecimalString;
|
|
697
|
+
readonly closureTarget: CommandClosureTarget;
|
|
698
|
+
readonly resultSourceRevision: RevisionDecimalString;
|
|
699
|
+
readonly resultBudgetRevision: RevisionDecimalString;
|
|
700
|
+
readonly originalCas: OriginalThreeCasInput;
|
|
701
|
+
}
|
|
702
|
+
interface ConsoleCommandRecoveryResponse {
|
|
703
|
+
readonly outcomeStatus: 'closed_recovered';
|
|
704
|
+
readonly receipt: ConsoleCommandReceipt;
|
|
705
|
+
readonly projection: ConsoleOrderProjection;
|
|
706
|
+
readonly pendingPollRequired: false;
|
|
707
|
+
readonly auditIdentityRetentionRequired: true;
|
|
708
|
+
}
|
|
709
|
+
interface ConsoleCommandUnknownRecoveryResponse {
|
|
710
|
+
readonly commandRef: ScopedObjectRef;
|
|
711
|
+
readonly inputDigest: Sha256HexDigest;
|
|
712
|
+
readonly outcomeStatus: 'unknown';
|
|
713
|
+
readonly unknownReason: EnterpriseCommandUnknownReason;
|
|
714
|
+
readonly receipt: null;
|
|
715
|
+
readonly pendingPollRequired: true;
|
|
716
|
+
readonly auditIdentityRetentionRequired: true;
|
|
717
|
+
readonly retryAction: 'retain_journal_and_poll_readonly_recovery';
|
|
718
|
+
readonly projection: ConsoleOrderProjection;
|
|
719
|
+
}
|
|
720
|
+
declare const ENTERPRISE_COMMERCIAL_REDUCTION_COVERAGES: readonly ["complete", "incomplete"];
|
|
721
|
+
type CommercialReductionCoverage = (typeof ENTERPRISE_COMMERCIAL_REDUCTION_COVERAGES)[number];
|
|
722
|
+
interface MerchantS2sCollectedFeeEffect {
|
|
723
|
+
readonly feeEffectRef: ScopedObjectRef;
|
|
724
|
+
readonly collectedFeeRaw: UInt256DecimalString | null;
|
|
725
|
+
readonly feeEntitlementCumulativeRaw: UInt256DecimalString | null;
|
|
726
|
+
readonly feeEntitlementIncrementRaw: UInt256DecimalString | null;
|
|
727
|
+
}
|
|
728
|
+
interface MerchantS2sCommercialReduction {
|
|
729
|
+
readonly reductionRef: ScopedObjectRef;
|
|
730
|
+
readonly decisionRef: ScopedObjectRef;
|
|
731
|
+
readonly decisionBusinessRef: ScopedObjectRef;
|
|
732
|
+
readonly decisionDigest: Sha256HexDigest;
|
|
733
|
+
readonly decisionRuleVersion: ScopedObjectRef;
|
|
734
|
+
readonly decisionValidUntil: string;
|
|
735
|
+
readonly cancelledAmountRaw: UInt256DecimalString;
|
|
736
|
+
readonly cumulativeCancelledAmountRaw: UInt256DecimalString;
|
|
737
|
+
readonly actualCaptureBasisRaw: UInt256DecimalString;
|
|
738
|
+
readonly commercialPrincipalNetRaw: UInt256DecimalString;
|
|
739
|
+
readonly principalRefundEntitlementRaw: UInt256DecimalString;
|
|
740
|
+
readonly reverseReapplyCoverage: CommercialReductionCoverage;
|
|
741
|
+
readonly settledAt: string;
|
|
742
|
+
readonly collectedFeeEffect: MerchantS2sCollectedFeeEffect | null;
|
|
743
|
+
}
|
|
744
|
+
interface MerchantS2sCommercialReductionProjection {
|
|
745
|
+
readonly audience: 'merchant_s2s';
|
|
746
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
747
|
+
readonly appId: ScopedObjectRef;
|
|
748
|
+
readonly environment: string;
|
|
749
|
+
readonly settlementAsset: AssetIdentifier;
|
|
750
|
+
readonly projectionRevision: RevisionDecimalString;
|
|
751
|
+
readonly cacheCoordination: CacheCoordinationEnvelope;
|
|
752
|
+
readonly commercialReduction: MerchantS2sCommercialReduction;
|
|
753
|
+
readonly asOf: string;
|
|
754
|
+
}
|
|
755
|
+
interface MerchantCommercialReductionEnvelopeResponse {
|
|
756
|
+
readonly outcomeStatus: 'applied' | 'replayed_identical';
|
|
757
|
+
readonly receipt: MerchantCommandReceipt;
|
|
758
|
+
readonly projection: MerchantS2sCommercialReductionProjection;
|
|
759
|
+
readonly pendingPollRequired: false;
|
|
760
|
+
readonly auditIdentityRetentionRequired: true;
|
|
761
|
+
}
|
|
762
|
+
interface MerchantCommercialReductionRecoveryResponse {
|
|
763
|
+
readonly outcomeStatus: 'closed_recovered';
|
|
764
|
+
readonly receipt: MerchantCommandReceipt;
|
|
765
|
+
readonly projection: MerchantS2sCommercialReductionProjection;
|
|
766
|
+
readonly pendingPollRequired: false;
|
|
767
|
+
readonly auditIdentityRetentionRequired: true;
|
|
768
|
+
}
|
|
769
|
+
type CommercialReductionDisclosureWithheldReason = 'stale_or_out_of_order_response';
|
|
770
|
+
declare const ENTERPRISE_COMMAND_UNKNOWN_REASONS: readonly ["open_unclosed_command", "missing_original_observation", "outbound_dispatch_in_doubt", "commit_outcome_unknown", "target_closure_unconfirmed", "awaiting_user_signature", "awaiting_trusted_observation"];
|
|
771
|
+
type EnterpriseCommandUnknownReason = (typeof ENTERPRISE_COMMAND_UNKNOWN_REASONS)[number];
|
|
772
|
+
interface CommandUnknownRecoveryResponse {
|
|
773
|
+
readonly commandRef: ScopedObjectRef;
|
|
774
|
+
readonly inputDigest: Sha256HexDigest;
|
|
775
|
+
readonly outcomeStatus: 'unknown';
|
|
776
|
+
readonly unknownReason: EnterpriseCommandUnknownReason;
|
|
777
|
+
readonly receipt: null;
|
|
778
|
+
readonly pendingPollRequired: true;
|
|
779
|
+
readonly auditIdentityRetentionRequired: true;
|
|
780
|
+
readonly retryAction: 'retain_journal_and_poll_readonly_recovery';
|
|
781
|
+
readonly projection: MerchantS2sOrderProjection | null;
|
|
782
|
+
}
|
|
783
|
+
declare const ENTERPRISE_AUTH_REVOKED_ERROR_CODES: readonly ["unauthenticated_session", "authority_grant_expired_at_commit", "source_quote_expired_at_commit", "risk_cap_expired_at_commit", "authority_grant_revoked", "scope_binding_revoked", "cross_audience_or_owner_forbidden", "current_session_expired_or_revoked", "current_read_authority_denied"];
|
|
784
|
+
type EnterpriseAuthRevokedErrorCode = (typeof ENTERPRISE_AUTH_REVOKED_ERROR_CODES)[number];
|
|
785
|
+
interface AuthRevokedErrorResponse {
|
|
786
|
+
readonly errorCode: EnterpriseAuthRevokedErrorCode;
|
|
787
|
+
readonly message: string;
|
|
788
|
+
readonly outcomeDisclosure: 'undisclosed';
|
|
789
|
+
readonly protectedCacheMustClear: true;
|
|
790
|
+
readonly localContextAnchorRequired: true;
|
|
791
|
+
readonly auditIdentityRetentionRequired: true;
|
|
792
|
+
}
|
|
793
|
+
declare const ENTERPRISE_DETERMINISTIC_ERROR_CODES: readonly ["invalid_uint256_or_schema", "cas_context_revision_mismatch", "cas_source_revision_mismatch", "cas_budget_revision_mismatch", "shared_prefund_cash_exhausted", "app_service_allocation_exceeded", "period_limit_exceeded", "per_tx_limit_exceeded", "shared_risk_cap_exceeded", "reserve_floor_breached", "native_gas_reserve_insufficient", "source_effective_available_insufficient", "unknown_hold_release_forbidden", "command_input_digest_mismatch", "producer_verification_failed", "caller_valid_until_exceeds_grant", "cash_application_exceeds_collected_or_principal", "commercial_decision_fact_unavailable", "commercial_decision_already_settled", "commercial_reduction_exceeds_actual_capture_or_limit", "commercial_reduction_net_not_conserved", "PF_CAS_CONFLICT", "original_input_conflict", "source_or_authority_unavailable", "verified_execution_plan_mismatch"];
|
|
794
|
+
type EnterpriseDeterministicErrorCode = (typeof ENTERPRISE_DETERMINISTIC_ERROR_CODES)[number];
|
|
795
|
+
interface DeterministicCommandErrorResponse {
|
|
796
|
+
readonly errorCode: EnterpriseDeterministicErrorCode;
|
|
797
|
+
readonly message: string;
|
|
798
|
+
readonly currentContextRevision?: PositiveUInt64Revision;
|
|
799
|
+
readonly preservePendingCommandJournal: true;
|
|
800
|
+
}
|
|
801
|
+
interface InfrastructureUnavailableResponse {
|
|
802
|
+
readonly errorCode: 'PF_SERVICE_UNAVAILABLE';
|
|
803
|
+
readonly message: string;
|
|
804
|
+
readonly outcomeDisclosure: 'unknown';
|
|
805
|
+
readonly preservePendingCommandJournal: true;
|
|
806
|
+
readonly retryAction: 'retain_journal_and_poll_readonly_recovery';
|
|
807
|
+
}
|
|
808
|
+
interface EnterpriseS2sOwnerBindingInput {
|
|
809
|
+
readonly targetRealm: string;
|
|
810
|
+
readonly organizationId: string;
|
|
811
|
+
readonly appId?: string;
|
|
812
|
+
readonly audience?: 'merchant_s2s';
|
|
813
|
+
readonly principalId?: string;
|
|
814
|
+
}
|
|
815
|
+
interface EnterpriseHostCallerSessionContext extends EnterpriseCallerSessionContext {
|
|
816
|
+
readonly contextGeneration: number;
|
|
817
|
+
}
|
|
818
|
+
interface EnterpriseSubmitCommandInput<TRequest extends EnterprisePublicMerchantWireCommandRequest = EnterprisePublicMerchantWireCommandRequest> {
|
|
819
|
+
readonly path: EnterpriseCommandPathParams;
|
|
820
|
+
readonly idempotencyKey?: ScopedObjectRef;
|
|
821
|
+
readonly body: EnterpriseCommandRequestInput<TRequest>;
|
|
822
|
+
readonly caller?: EnterpriseHostCallerSessionContext;
|
|
823
|
+
readonly projectionTicketNumber?: number;
|
|
824
|
+
}
|
|
825
|
+
interface EnterpriseRecoverCommandInput {
|
|
826
|
+
readonly commandRef: ScopedObjectRef;
|
|
827
|
+
readonly purchaseRef?: ScopedObjectRef;
|
|
828
|
+
readonly economicIntentRef?: ScopedObjectRef;
|
|
829
|
+
readonly caller?: EnterpriseHostCallerSessionContext;
|
|
830
|
+
readonly projectionTicketNumber?: number;
|
|
831
|
+
}
|
|
832
|
+
interface EnterpriseLoadPendingInput {
|
|
833
|
+
readonly commandRef: ScopedObjectRef;
|
|
834
|
+
readonly caller?: EnterpriseHostCallerSessionContext;
|
|
835
|
+
}
|
|
836
|
+
interface EnterpriseOrderScopeSelector {
|
|
837
|
+
readonly purchaseRef: ScopedObjectRef;
|
|
838
|
+
readonly economicIntentRef: ScopedObjectRef;
|
|
839
|
+
}
|
|
840
|
+
interface EnterpriseCommandActiveExecutionResult {
|
|
841
|
+
readonly resultKind: 'active';
|
|
842
|
+
readonly staleOrDenied: false;
|
|
843
|
+
readonly snapshot: EnterpriseCommandJournalSnapshot;
|
|
844
|
+
readonly sendInvoked: boolean;
|
|
845
|
+
readonly httpStatus?: number;
|
|
846
|
+
readonly wireOutcomeStatus?: 'applied' | 'replayed_identical' | 'unknown';
|
|
847
|
+
readonly receipt: MerchantCommandReceipt | null;
|
|
848
|
+
readonly originalCasTriple: EnterpriseCommandCasTriple;
|
|
849
|
+
readonly projection: MerchantS2sOrderProjection | null;
|
|
850
|
+
readonly commercialReductionProjection?: MerchantS2sCommercialReductionProjection | null;
|
|
851
|
+
readonly commercialReductionDisclosureWithheld?: CommercialReductionDisclosureWithheldReason;
|
|
852
|
+
readonly projectionFenceResult?: EnterpriseProjectionApplyResult<MerchantS2sOrderProjection>;
|
|
853
|
+
readonly deterministicError?: DeterministicCommandErrorResponse;
|
|
854
|
+
readonly authRevokedError?: AuthRevokedErrorResponse | {
|
|
855
|
+
readonly malformedBody: true;
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
interface EnterpriseCommandStaleOrDeniedExecutionResult {
|
|
859
|
+
readonly resultKind: 'stale_or_denied';
|
|
860
|
+
readonly staleOrDenied: true;
|
|
861
|
+
readonly snapshot: null;
|
|
862
|
+
readonly sendInvoked: boolean;
|
|
863
|
+
readonly httpStatus?: number;
|
|
864
|
+
readonly wireOutcomeStatus?: undefined;
|
|
865
|
+
readonly receipt: null;
|
|
866
|
+
readonly originalCasTriple: null;
|
|
867
|
+
readonly projection: null;
|
|
868
|
+
readonly projectionFenceResult: Extract<EnterpriseProjectionApplyResult<null>, {
|
|
869
|
+
readonly applied: false;
|
|
870
|
+
}>;
|
|
871
|
+
readonly deterministicError?: undefined;
|
|
872
|
+
readonly authRevokedError?: undefined;
|
|
873
|
+
}
|
|
874
|
+
type EnterpriseCommandExecutionResult = EnterpriseCommandActiveExecutionResult | EnterpriseCommandStaleOrDeniedExecutionResult;
|
|
875
|
+
interface EnterpriseCommandActiveRecoveryResult {
|
|
876
|
+
readonly resultKind: 'active';
|
|
877
|
+
readonly staleOrDenied: false;
|
|
878
|
+
readonly snapshot: EnterpriseCommandJournalSnapshot;
|
|
879
|
+
readonly lookupInvoked: boolean;
|
|
880
|
+
readonly httpStatus?: number;
|
|
881
|
+
readonly wireOutcomeStatus?: 'closed_recovered' | 'unknown';
|
|
882
|
+
readonly receipt: MerchantCommandReceipt | null;
|
|
883
|
+
readonly originalCasTriple: EnterpriseCommandCasTriple;
|
|
884
|
+
readonly projection: MerchantS2sOrderProjection | null;
|
|
885
|
+
readonly commercialReductionProjection?: MerchantS2sCommercialReductionProjection | null;
|
|
886
|
+
readonly commercialReductionDisclosureWithheld?: CommercialReductionDisclosureWithheldReason;
|
|
887
|
+
readonly projectionFenceResult?: EnterpriseProjectionApplyResult<MerchantS2sOrderProjection>;
|
|
888
|
+
readonly deterministicError?: DeterministicCommandErrorResponse;
|
|
889
|
+
readonly authRevokedError?: AuthRevokedErrorResponse | {
|
|
890
|
+
readonly malformedBody: true;
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
interface EnterpriseCommandStaleOrDeniedRecoveryResult {
|
|
894
|
+
readonly resultKind: 'stale_or_denied';
|
|
895
|
+
readonly staleOrDenied: true;
|
|
896
|
+
readonly snapshot: null;
|
|
897
|
+
readonly lookupInvoked: boolean;
|
|
898
|
+
readonly httpStatus?: number;
|
|
899
|
+
readonly wireOutcomeStatus?: undefined;
|
|
900
|
+
readonly receipt: null;
|
|
901
|
+
readonly originalCasTriple: null;
|
|
902
|
+
readonly projection: null;
|
|
903
|
+
readonly projectionFenceResult: Extract<EnterpriseProjectionApplyResult<null>, {
|
|
904
|
+
readonly applied: false;
|
|
905
|
+
}>;
|
|
906
|
+
readonly deterministicError?: undefined;
|
|
907
|
+
readonly authRevokedError?: undefined;
|
|
908
|
+
}
|
|
909
|
+
type EnterpriseCommandRecoveryResult = EnterpriseCommandActiveRecoveryResult | EnterpriseCommandStaleOrDeniedRecoveryResult;
|
|
910
|
+
type EnterpriseCommandStaleOrDeniedResult = EnterpriseCommandStaleOrDeniedExecutionResult | EnterpriseCommandStaleOrDeniedRecoveryResult;
|
|
911
|
+
interface EnterpriseFundsServerClient {
|
|
912
|
+
readonly ownerScope: CanonicalOwnerScope;
|
|
913
|
+
executeCommand<TRequest extends EnterprisePublicMerchantWireCommandRequest>(input: EnterpriseSubmitCommandInput<TRequest>): Promise<EnterpriseCommandExecutionResult>;
|
|
914
|
+
recoverCommand(input: EnterpriseRecoverCommandInput): Promise<EnterpriseCommandRecoveryResult>;
|
|
915
|
+
loadPending(input: EnterpriseLoadPendingInput): Promise<EnterpriseCommandJournalSnapshot | null>;
|
|
916
|
+
getProjectedOrder(scope: EnterpriseOrderScopeSelector): MerchantS2sOrderProjection | null;
|
|
917
|
+
getProjectionWatermark(scope: EnterpriseOrderScopeSelector): number;
|
|
918
|
+
switchCallerContext(nextCaller: EnterpriseHostCallerSessionContext): void;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
interface EnterprisePurchaseHostContext {
|
|
922
|
+
readonly subject: string;
|
|
923
|
+
readonly requestFenceRef: string;
|
|
924
|
+
readonly contextGeneration: number;
|
|
925
|
+
readonly active: boolean;
|
|
926
|
+
}
|
|
927
|
+
interface EnterprisePurchasePreparationRequest {
|
|
928
|
+
readonly merchantPaymentRef: string;
|
|
929
|
+
readonly mandateId: string;
|
|
930
|
+
readonly userLinkRef: string;
|
|
931
|
+
readonly amount: string;
|
|
932
|
+
readonly currency: 'USDC';
|
|
933
|
+
readonly useCase: 'immediate' | 'recurring' | 'top_up' | 'metered';
|
|
934
|
+
readonly cartDigest: PrefixedSha256Digest;
|
|
935
|
+
readonly description?: string;
|
|
936
|
+
}
|
|
937
|
+
interface EnterprisePurchaseFirstHoldCandidate {
|
|
938
|
+
readonly method: 'POST';
|
|
939
|
+
readonly routeTemplate: '/api/merchant/enterprise-funds/purchases/{purchaseRef}/intents/{economicIntentRef}/commands/{commandRef}/holds';
|
|
940
|
+
readonly path: EnterpriseCommandPathParams;
|
|
941
|
+
readonly request: CreateOrTransitionSourceHoldRequest & {
|
|
942
|
+
readonly targetHoldState: 'active';
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
interface EnterprisePurchasePreparation {
|
|
946
|
+
readonly preparationRef: string;
|
|
947
|
+
readonly requestFingerprint: PrefixedSha256Digest;
|
|
948
|
+
readonly appId: string;
|
|
949
|
+
readonly organizationId: string;
|
|
950
|
+
readonly targetRealm: 'test' | 'dev' | 'external' | 'mainnet_staging' | 'production';
|
|
951
|
+
readonly purchaseRef: ScopedObjectRef;
|
|
952
|
+
readonly economicIntentRef: ScopedObjectRef;
|
|
953
|
+
readonly publicOrderRef: ScopedObjectRef;
|
|
954
|
+
readonly mandateId: string;
|
|
955
|
+
readonly userLinkRef: string;
|
|
956
|
+
readonly pinRevision: PositiveUInt64Revision;
|
|
957
|
+
readonly pinnedRouteRef: string;
|
|
958
|
+
readonly executionPlanRef: string;
|
|
959
|
+
readonly firstCommandCandidate: EnterprisePurchaseFirstHoldCandidate | null;
|
|
960
|
+
}
|
|
961
|
+
type PurchasePreparationEnvelopeBase<S extends number, O extends string, D extends string, R, P, V, Poll extends boolean, Clear extends boolean, Reason> = Readonly<{
|
|
962
|
+
protocolId: 'facto.enterprise-purchase-preparation.v1';
|
|
963
|
+
httpStatus: S;
|
|
964
|
+
merchantPaymentRef: R;
|
|
965
|
+
outcome: O;
|
|
966
|
+
preparation: P;
|
|
967
|
+
projection: V;
|
|
968
|
+
receipt: null;
|
|
969
|
+
outcomeDisclosure: D;
|
|
970
|
+
pendingPollRequired: Poll;
|
|
971
|
+
protectedCacheMustClear: Clear;
|
|
972
|
+
reasonCode: Reason;
|
|
973
|
+
}>;
|
|
974
|
+
type EnterprisePurchasePreparedEnvelope = PurchasePreparationEnvelopeBase<200, 'prepared', 'disclosed', string, EnterprisePurchasePreparation, MerchantS2sOrderProjection | null, false, false, null>;
|
|
975
|
+
type EnterprisePurchasePendingEnvelope = PurchasePreparationEnvelopeBase<202, 'pending', 'unknown', string, null, null, true, true, 'not_observed' | 'preparation_commit_unknown' | 'current_snapshot_unavailable' | 'preparation_pending'>;
|
|
976
|
+
type EnterprisePurchaseConflictEnvelope = PurchasePreparationEnvelopeBase<409, 'conflict', 'disclosed', string, null, null, false, true, 'original_input_conflict' | 'original_binding_conflict'> | PurchasePreparationEnvelopeBase<409, 'legacy_conflict', 'disclosed', string, null, null, false, true, 'legacy_payment_exists'> | PurchasePreparationEnvelopeBase<409, 'blocked', 'disclosed', string, null, null, false, true, 'current_admission_blocked' | 'required_configuration_unavailable' | 'trusted_source_or_plan_unavailable'>;
|
|
977
|
+
type EnterprisePurchaseErrorEnvelope = PurchasePreparationEnvelopeBase<400, 'invalid_request', 'unknown', string | null, null, null, true, true, 'invalid_preparation_request'> | PurchasePreparationEnvelopeBase<401, 'access_denied', 'undisclosed', null, null, null, true, true, 'current_authentication_required'> | PurchasePreparationEnvelopeBase<403, 'access_denied', 'undisclosed', null, null, null, true, true, 'current_access_denied'> | PurchasePreparationEnvelopeBase<503, 'pending', 'unknown', string | null, null, null, true, true, 'temporarily_unavailable'>;
|
|
978
|
+
type EnterprisePurchasePreparationEnvelope = EnterprisePurchasePreparedEnvelope | EnterprisePurchasePendingEnvelope | EnterprisePurchaseConflictEnvelope | EnterprisePurchaseErrorEnvelope;
|
|
979
|
+
type EnterprisePurchaseActiveResult = Readonly<{
|
|
980
|
+
resultKind: 'active';
|
|
981
|
+
httpStatus: EnterprisePurchasePreparationEnvelope['httpStatus'];
|
|
982
|
+
envelope: EnterprisePurchasePreparationEnvelope;
|
|
983
|
+
preparation: EnterprisePurchasePreparation | null;
|
|
984
|
+
projection: MerchantS2sOrderProjection | null;
|
|
985
|
+
receipt: null;
|
|
986
|
+
requestFingerprint: PrefixedSha256Digest | null;
|
|
987
|
+
firstCommandCandidate: EnterprisePurchaseFirstHoldCandidate | null;
|
|
988
|
+
merchantPaymentRef: string | null;
|
|
989
|
+
originalRequest: null;
|
|
990
|
+
protectedCacheMustClear: boolean;
|
|
991
|
+
pendingPollRequired: boolean;
|
|
992
|
+
}>;
|
|
993
|
+
type EnterprisePurchaseSafeEmptyResult = Readonly<{
|
|
994
|
+
resultKind: 'stale_or_denied' | 'unknown';
|
|
995
|
+
httpStatus: number | null;
|
|
996
|
+
envelope: null;
|
|
997
|
+
preparation: null;
|
|
998
|
+
projection: null;
|
|
999
|
+
receipt: null;
|
|
1000
|
+
requestFingerprint: null;
|
|
1001
|
+
firstCommandCandidate: null;
|
|
1002
|
+
merchantPaymentRef: null;
|
|
1003
|
+
originalRequest: null;
|
|
1004
|
+
protectedCacheMustClear: boolean;
|
|
1005
|
+
pendingPollRequired: true;
|
|
1006
|
+
reasonCode: 'stale_context_or_response' | 'current_access_denied' | 'transport_or_response_unknown';
|
|
1007
|
+
}>;
|
|
1008
|
+
type EnterprisePurchasePreparationResult = EnterprisePurchaseActiveResult | EnterprisePurchaseSafeEmptyResult;
|
|
1009
|
+
interface EnterprisePurchaseServerClient {
|
|
1010
|
+
preparePurchaseOnce(request: EnterprisePurchasePreparationRequest): Promise<EnterprisePurchasePreparationResult>;
|
|
1011
|
+
getPreparation(originalRequest: EnterprisePurchasePreparationRequest): Promise<EnterprisePurchasePreparationResult>;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
declare const MAX_UINT256_DECIMAL = "115792089237316195423570985008687907853269984665640564039457584007913129639935";
|
|
1015
|
+
declare const ENTERPRISE_MERCHANT_COMMAND_ROUTE_TEMPLATES: Readonly<Record<EnterprisePublicMerchantCommandKind, string>>;
|
|
1016
|
+
declare const ENTERPRISE_MERCHANT_RECOVERY_ROUTE_TEMPLATE: "/api/merchant/enterprise-funds/purchases/{purchaseRef}/intents/{economicIntentRef}/commands/{commandRef}";
|
|
1017
|
+
declare const ENTERPRISE_KIND_TO_TARGET_TABLE: Readonly<Record<EnterpriseCommandKind, EnterpriseClosureTargetTable>>;
|
|
1018
|
+
declare class EnterpriseWireValidationError extends EnterpriseJournalValidationError {
|
|
1019
|
+
readonly wireCode: "ENTERPRISE_WIRE_VALIDATION_ERROR";
|
|
1020
|
+
constructor(message: string);
|
|
1021
|
+
}
|
|
1022
|
+
declare function wireDigestToCoreDigest(wireDigest: unknown, label?: string): PrefixedSha256Digest;
|
|
1023
|
+
declare function coreDigestToWireDigest(coreDigest: unknown, label?: string): Sha256HexDigest;
|
|
1024
|
+
declare function serializeCanonicalJson(value: unknown, label?: string): string;
|
|
1025
|
+
declare function encodeCanonicalUtf8Bytes(value: unknown, label?: string): {
|
|
1026
|
+
readonly canonicalJson: string;
|
|
1027
|
+
readonly canonicalBytes: Uint8Array;
|
|
1028
|
+
};
|
|
1029
|
+
declare function validateAndNormalizeS2sOwnerScope(input: unknown, configuredAppId: string): CanonicalOwnerScope;
|
|
1030
|
+
declare function computeEnterpriseScopeRef(ownerScope: Pick<CanonicalOwnerScope, 'targetRealm' | 'organizationId' | 'appId'>, purchaseRef: ScopedObjectRef, economicIntentRef: ScopedObjectRef): string;
|
|
1031
|
+
declare function buildMerchantCommandPath(kind: EnterpriseCommandKind, path: EnterpriseCommandPathParams): string;
|
|
1032
|
+
declare function buildMerchantRecoveryPath(path: EnterpriseCommandPathParams): string;
|
|
1033
|
+
declare function deriveCommercialReductionRef(commandRef: unknown): ScopedObjectRef;
|
|
1034
|
+
interface CanonicalizedEnterpriseCommandBundle<TRequest extends EnterpriseWireCommandRequest = EnterpriseWireCommandRequest> {
|
|
1035
|
+
readonly canonicalObject: CanonicalEnterpriseCommandObject<TRequest>;
|
|
1036
|
+
readonly canonicalJson: string;
|
|
1037
|
+
readonly canonicalRequestBytes: Uint8Array;
|
|
1038
|
+
readonly wireInputDigest: Sha256HexDigest;
|
|
1039
|
+
readonly coreInputDigest: PrefixedSha256Digest;
|
|
1040
|
+
readonly sdkScopeRef: string;
|
|
1041
|
+
readonly casTriple: EnterpriseCommandCasTriple;
|
|
1042
|
+
readonly expectedClosureTarget: CommandClosureTarget;
|
|
1043
|
+
readonly routeTemplate: string;
|
|
1044
|
+
readonly requestPath: string;
|
|
1045
|
+
readonly recoveryPath: string;
|
|
1046
|
+
readonly headers: Readonly<{
|
|
1047
|
+
'Idempotency-Key': ScopedObjectRef;
|
|
1048
|
+
}>;
|
|
1049
|
+
readonly wireRequestBody: TRequest;
|
|
1050
|
+
readonly journalEnvelope: EnterpriseOriginalCommandEnvelope;
|
|
1051
|
+
}
|
|
1052
|
+
declare function canonicalizeAndMapEnterpriseCommand<TRequest extends EnterprisePublicMerchantWireCommandRequest = EnterprisePublicMerchantWireCommandRequest>(input: {
|
|
1053
|
+
readonly ownerScope: CanonicalOwnerScope;
|
|
1054
|
+
readonly path: EnterpriseCommandPathParams;
|
|
1055
|
+
readonly idempotencyKey?: string;
|
|
1056
|
+
readonly body: EnterpriseCommandRequestInput<TRequest>;
|
|
1057
|
+
}): CanonicalizedEnterpriseCommandBundle<TRequest>;
|
|
1058
|
+
declare function decodeCanonicalCommandFromEnvelope(envelope: EnterpriseOriginalCommandEnvelope): CanonicalizedEnterpriseCommandBundle;
|
|
1059
|
+
declare function parsePartnerBusinessProgress(value: unknown, label?: string): PartnerBusinessProgress;
|
|
1060
|
+
declare function parseMerchantS2sOrderProjection(value: unknown, label?: string, expectedAppId?: string): MerchantS2sOrderProjection;
|
|
1061
|
+
declare function parseMerchantS2sCollectedFeeEffect(value: unknown, label?: string): MerchantS2sCollectedFeeEffect | null;
|
|
1062
|
+
declare function parseMerchantS2sCommercialReduction(value: unknown, label?: string): MerchantS2sCommercialReduction;
|
|
1063
|
+
declare function parseMerchantS2sCommercialReductionProjection(value: unknown, label?: string, expectedAppId?: string): MerchantS2sCommercialReductionProjection;
|
|
1064
|
+
declare function parseMerchantCommandEnvelopeResponse(value: unknown, expectedAppId?: string): MerchantCommandEnvelopeResponse;
|
|
1065
|
+
declare function parseMerchantCommandRecoveryResponse(value: unknown, expectedAppId?: string): MerchantCommandRecoveryResponse;
|
|
1066
|
+
declare function parseMerchantCommercialReductionEnvelopeResponse(value: unknown, expectedAppId?: string): MerchantCommercialReductionEnvelopeResponse;
|
|
1067
|
+
declare function parseMerchantCommercialReductionRecoveryResponse(value: unknown, expectedAppId?: string): MerchantCommercialReductionRecoveryResponse;
|
|
1068
|
+
declare function parseCommandUnknownRecoveryResponse(value: unknown, expectedAppId?: string): CommandUnknownRecoveryResponse;
|
|
1069
|
+
declare function parseAuthRevokedErrorResponse(value: unknown): AuthRevokedErrorResponse;
|
|
1070
|
+
declare function parseDeterministicCommandErrorResponse(value: unknown): DeterministicCommandErrorResponse;
|
|
1071
|
+
declare function parseInfrastructureUnavailableResponse(value: unknown): InfrastructureUnavailableResponse;
|
|
1072
|
+
interface EvaluatedMerchantWireResponse {
|
|
1073
|
+
readonly httpStatus: number;
|
|
1074
|
+
readonly observation: EnterpriseCommandAdapterObservation;
|
|
1075
|
+
readonly wireOutcomeStatus?: 'applied' | 'replayed_identical' | 'closed_recovered' | 'unknown';
|
|
1076
|
+
readonly receipt: MerchantCommandReceipt | null;
|
|
1077
|
+
readonly projection: MerchantS2sOrderProjection | null;
|
|
1078
|
+
readonly commercialReductionProjection?: MerchantS2sCommercialReductionProjection;
|
|
1079
|
+
readonly deterministicError?: DeterministicCommandErrorResponse;
|
|
1080
|
+
readonly authRevokedError?: AuthRevokedErrorResponse | {
|
|
1081
|
+
readonly malformedBody: true;
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
declare function evaluateMerchantWireResponseAgainstEnvelope(input: {
|
|
1085
|
+
readonly method: 'POST' | 'GET';
|
|
1086
|
+
readonly httpStatus: number;
|
|
1087
|
+
readonly rawBodyText: string;
|
|
1088
|
+
readonly envelope: EnterpriseOriginalCommandEnvelope;
|
|
1089
|
+
}): EvaluatedMerchantWireResponse;
|
|
1090
|
+
|
|
1091
|
+
declare const ENTERPRISE_AUDIENCE_READ_ROUTE_TEMPLATES: Readonly<{
|
|
1092
|
+
readonly partnerProjection: "/api/partner/enterprise-funds/orders/{publicOrderRef}/projection";
|
|
1093
|
+
readonly partnerOperation: "/api/partner/enterprise-funds/orders/{publicOrderRef}/operations/{operationRef}";
|
|
1094
|
+
readonly consumerProjection: "/api/consumer/enterprise-funds/orders/{publicOrderRef}/projection";
|
|
1095
|
+
readonly consumerOperation: "/api/consumer/enterprise-funds/orders/{publicOrderRef}/operations/{operationRef}";
|
|
1096
|
+
readonly consoleProjection: "/api/console/enterprise-funds/purchases/{purchaseRef}/intents/{economicIntentRef}/projection";
|
|
1097
|
+
readonly consoleCommand: "/api/console/enterprise-funds/purchases/{purchaseRef}/intents/{economicIntentRef}/commands/{commandRef}";
|
|
1098
|
+
}>;
|
|
1099
|
+
type EnterpriseAudienceReadRoute = keyof typeof ENTERPRISE_AUDIENCE_READ_ROUTE_TEMPLATES;
|
|
1100
|
+
interface EnterpriseAudienceReadPathParams {
|
|
1101
|
+
readonly publicOrderRef?: string;
|
|
1102
|
+
readonly operationRef?: string;
|
|
1103
|
+
readonly purchaseRef?: string;
|
|
1104
|
+
readonly economicIntentRef?: string;
|
|
1105
|
+
readonly commandRef?: string;
|
|
1106
|
+
}
|
|
1107
|
+
declare function buildAudienceReadPath(route: EnterpriseAudienceReadRoute, params: EnterpriseAudienceReadPathParams): string;
|
|
1108
|
+
type EnterpriseAudienceReadResult<TClosed, TUnknown> = {
|
|
1109
|
+
readonly resultKind: 'closed';
|
|
1110
|
+
readonly httpStatus: 200;
|
|
1111
|
+
readonly body: TClosed;
|
|
1112
|
+
} | {
|
|
1113
|
+
readonly resultKind: 'unknown';
|
|
1114
|
+
readonly httpStatus: 202;
|
|
1115
|
+
readonly body: TUnknown;
|
|
1116
|
+
} | {
|
|
1117
|
+
readonly resultKind: 'auth_revoked';
|
|
1118
|
+
readonly httpStatus: 401 | 403;
|
|
1119
|
+
readonly error: AuthRevokedErrorResponse | null;
|
|
1120
|
+
readonly malformedBody: boolean;
|
|
1121
|
+
} | {
|
|
1122
|
+
readonly resultKind: 'invalid_reference';
|
|
1123
|
+
readonly httpStatus: 400;
|
|
1124
|
+
readonly errorCode: string | null;
|
|
1125
|
+
} | {
|
|
1126
|
+
readonly resultKind: 'unavailable';
|
|
1127
|
+
readonly httpStatus: 503;
|
|
1128
|
+
readonly error: AudienceProjectionUnavailableResponse | null;
|
|
1129
|
+
readonly malformedBody: boolean;
|
|
1130
|
+
} | {
|
|
1131
|
+
readonly resultKind: 'unexpected';
|
|
1132
|
+
readonly httpStatus: number;
|
|
1133
|
+
readonly malformedBody: boolean;
|
|
1134
|
+
};
|
|
1135
|
+
interface AudienceProjectionUnavailableResponse {
|
|
1136
|
+
readonly code: 'audience_projection_unavailable';
|
|
1137
|
+
readonly message: string;
|
|
1138
|
+
readonly preservePendingCommandJournal: true;
|
|
1139
|
+
readonly retryAction: 'retain_journal_and_poll_readonly_recovery';
|
|
1140
|
+
}
|
|
1141
|
+
declare function parsePartnerProjectionResponse(value: unknown, label?: string): PartnerProjectionResponse;
|
|
1142
|
+
declare function parsePartnerOperationRecoveryResponse(value: unknown, label?: string): PartnerOperationRecoveryResponse;
|
|
1143
|
+
declare function parsePartnerOperationUnknownRecoveryResponse(value: unknown, label?: string): PartnerOperationUnknownRecoveryResponse;
|
|
1144
|
+
declare function parseConsumerOrderProjection(value: unknown, label?: string): ConsumerOrderProjection;
|
|
1145
|
+
declare function parseConsumerBusinessProgress(value: unknown, label?: string): ConsumerBusinessProgress;
|
|
1146
|
+
declare function parseConsumerProjectionResponse(value: unknown, label?: string): ConsumerProjectionResponse;
|
|
1147
|
+
declare function parseConsumerOperationRecoveryResponse(value: unknown, label?: string): ConsumerOperationRecoveryResponse;
|
|
1148
|
+
declare function parseConsumerOperationUnknownRecoveryResponse(value: unknown, label?: string): ConsumerOperationUnknownRecoveryResponse;
|
|
1149
|
+
declare function parseConsoleOrderProjection(value: unknown, label?: string): ConsoleOrderProjection;
|
|
1150
|
+
declare function parseConsoleProjectionResponse(value: unknown, label?: string): ConsoleProjectionResponse;
|
|
1151
|
+
declare function parseConsoleCommandReceipt(value: unknown, label?: string): ConsoleCommandReceipt;
|
|
1152
|
+
declare function parseConsoleCommandRecoveryResponse(value: unknown, label?: string): ConsoleCommandRecoveryResponse;
|
|
1153
|
+
declare function parseConsoleCommandUnknownRecoveryResponse(value: unknown, label?: string): ConsoleCommandUnknownRecoveryResponse;
|
|
1154
|
+
declare function readPartnerProjectionResult(httpStatus: number, body: unknown): EnterpriseAudienceReadResult<PartnerProjectionResponse, never>;
|
|
1155
|
+
declare function readPartnerOperationResult(httpStatus: number, body: unknown): EnterpriseAudienceReadResult<PartnerOperationRecoveryResponse, PartnerOperationUnknownRecoveryResponse>;
|
|
1156
|
+
declare function readConsumerProjectionResult(httpStatus: number, body: unknown): EnterpriseAudienceReadResult<ConsumerProjectionResponse, never>;
|
|
1157
|
+
declare function readConsumerOperationResult(httpStatus: number, body: unknown): EnterpriseAudienceReadResult<ConsumerOperationRecoveryResponse, ConsumerOperationUnknownRecoveryResponse>;
|
|
1158
|
+
declare function readConsoleProjectionResult(httpStatus: number, body: unknown): EnterpriseAudienceReadResult<ConsoleProjectionResponse, never>;
|
|
1159
|
+
declare function readConsoleCommandResult(httpStatus: number, body: unknown): EnterpriseAudienceReadResult<ConsoleCommandRecoveryResponse, ConsoleCommandUnknownRecoveryResponse>;
|
|
3
1160
|
|
|
4
|
-
/**
|
|
5
|
-
* Customer-facing environment vocabulary (ADR-0077): the published Facto
|
|
6
|
-
* environments are `dev` and `production`, and `'sandbox'` is the documented
|
|
7
|
-
* public name for the dev environment — "sandbox naming, dev interface".
|
|
8
|
-
* `'sandbox'` and `'dev'` are interchangeable selectors for one environment:
|
|
9
|
-
* both resolve the dev endpoints (`https://dev-api.facto.to`, hosted Connect
|
|
10
|
-
* `https://dev.facto.to`) and the `/api/dev/*` route family. `'sandbox'` is
|
|
11
|
-
* the recommended spelling in public documentation; `'dev'` is the
|
|
12
|
-
* infrastructure name passed through unchanged.
|
|
13
|
-
*
|
|
14
|
-
* `staging` and the former `'custom'` selector are retired. Local, private,
|
|
15
|
-
* and staging deployments pass explicit `apiBaseUrl` and `hostedConnectUrl`
|
|
16
|
-
* overrides, which are valid with any environment value and take precedence
|
|
17
|
-
* over the published endpoint tables.
|
|
18
|
-
*/
|
|
19
1161
|
type FactoConnectEnvironment = 'dev' | 'production' | 'sandbox';
|
|
20
|
-
/** Canonical infrastructure names keying the published endpoint tables. */
|
|
21
1162
|
type PublishedFactoConnectEnvironment = 'dev' | 'production';
|
|
22
1163
|
type FactoConnectTransport = (input: string, init?: RequestInit) => Promise<Response>;
|
|
23
1164
|
declare const FACTO_CONNECT_API_BASE_URLS: Readonly<Record<PublishedFactoConnectEnvironment, string>>;
|
|
24
1165
|
declare const FACTO_CONNECT_HOSTED_URLS: Readonly<Record<PublishedFactoConnectEnvironment, string>>;
|
|
1166
|
+
declare function factoConnectEnvironmentFromClientId(clientId: string): PublishedFactoConnectEnvironment | undefined;
|
|
25
1167
|
interface FactoConnectServerOptions {
|
|
26
1168
|
appId: string;
|
|
27
1169
|
clientId: string;
|
|
28
1170
|
clientSecret: string;
|
|
29
|
-
|
|
30
|
-
* Required. `'sandbox'` (the documented public test environment name) and
|
|
31
|
-
* `'dev'` select the same environment and resolve the same published dev
|
|
32
|
-
* endpoints; `'production'` resolves the production endpoints. ADR-0077:
|
|
33
|
-
* "sandbox naming, dev interface". There is no default: omission throws at
|
|
34
|
-
* construction instead of silently targeting production over the retired
|
|
35
|
-
* legacy `/api/external/*` routes, and `'staging'` is retired from the
|
|
36
|
-
* customer-facing vocabulary.
|
|
37
|
-
*
|
|
38
|
-
* The former `'custom'` selector is retired. For a local, private, or
|
|
39
|
-
* staging deployment keep any environment value and pass both explicit
|
|
40
|
-
* URL overrides, e.g.:
|
|
41
|
-
*
|
|
42
|
-
* ```ts
|
|
43
|
-
* createFactoConnectServer({
|
|
44
|
-
* ...credentials,
|
|
45
|
-
* environment: 'sandbox',
|
|
46
|
-
* apiBaseUrl: 'http://127.0.0.1:8080',
|
|
47
|
-
* hostedConnectUrl: 'http://127.0.0.1:5173',
|
|
48
|
-
* })
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
environment: FactoConnectEnvironment;
|
|
52
|
-
/**
|
|
53
|
-
* Explicit endpoint overrides for local, private, or staging deployments.
|
|
54
|
-
* Valid with any `environment` value and take precedence over the
|
|
55
|
-
* published endpoint tables (an override naming a *different* published
|
|
56
|
-
* environment's endpoint is still rejected as a conflict).
|
|
57
|
-
*/
|
|
1171
|
+
environment?: FactoConnectEnvironment;
|
|
58
1172
|
apiBaseUrl?: string;
|
|
59
1173
|
hostedConnectUrl?: string;
|
|
60
|
-
/** Injectable server-side transport. Defaults to `globalThis.fetch`. */
|
|
61
1174
|
transport?: FactoConnectTransport;
|
|
62
|
-
/** Alias for `transport`, matching the public Dev SDK contract. */
|
|
63
1175
|
fetch?: FactoConnectTransport;
|
|
64
|
-
/** Per-request deadline in milliseconds. Omit to leave deadline control to the caller transport. */
|
|
65
1176
|
timeoutMs?: number;
|
|
66
|
-
/** Retry policy for safe GET requests and POST requests carrying an idempotency key. */
|
|
67
1177
|
retry?: ServerRetryOptions;
|
|
68
|
-
/** Cancels in-flight requests and retry delays. */
|
|
69
1178
|
signal?: AbortSignal;
|
|
70
1179
|
}
|
|
71
1180
|
interface HostedConnectUrlInput {
|
|
72
1181
|
appId: string;
|
|
73
1182
|
state: string;
|
|
74
1183
|
nonce: string;
|
|
75
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
76
1184
|
customerEmail?: string;
|
|
77
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
78
1185
|
customerUsername?: string;
|
|
79
|
-
/** Hosted Connect origin for the target environment. Required: there is no implicit default. */
|
|
80
1186
|
hostedConnectUrl: string;
|
|
1187
|
+
merchantOrigin: string;
|
|
81
1188
|
}
|
|
82
1189
|
interface CreateHostedConnectUrlInput {
|
|
83
1190
|
state: string;
|
|
84
1191
|
nonce: string;
|
|
85
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
86
1192
|
customerEmail?: string;
|
|
87
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
88
1193
|
customerUsername?: string;
|
|
89
1194
|
hostedConnectUrl?: string;
|
|
1195
|
+
merchantOrigin: string;
|
|
90
1196
|
}
|
|
91
1197
|
interface ExchangeLinkCodeInput {
|
|
92
1198
|
code: string;
|
|
93
1199
|
state: string;
|
|
94
1200
|
nonce: string;
|
|
95
1201
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Merchant-safe link-code exchange result.
|
|
98
|
-
*
|
|
99
|
-
* This is the pinned engine `ExchangeLinkCodeResponse` verbatim — see
|
|
100
|
-
* `./generated/engine-wire`. New integrations persist `userLinkRef` (and the
|
|
101
|
-
* Dev-only `cardRef` when present); `factoUserId`,
|
|
102
|
-
* `factoServerWalletAddress`, and `cardRef` are transition-only and the wire
|
|
103
|
-
* declares each one independently optional AND nullable, so `null` is a legal
|
|
104
|
-
* value here and must not be narrowed away.
|
|
105
|
-
*/
|
|
106
1202
|
type ExchangeLinkCodeResult = ExchangeLinkCodeResponse;
|
|
107
|
-
/**
|
|
108
|
-
* Payment-readiness response. The pinned engine `PaymentCapabilityResponse`
|
|
109
|
-
* verbatim: `notReadyReason` carries the closed
|
|
110
|
-
* `PaymentReadinessNotReadyReason` enum and is optional + nullable, and the
|
|
111
|
-
* legacy identity pair is optional + nullable.
|
|
112
|
-
*/
|
|
113
1203
|
type PaymentCapability = PaymentCapabilityResponse;
|
|
114
1204
|
|
|
115
|
-
/**
|
|
116
|
-
* Caller-facing shape of the wire `PaymentCapabilityRequest` target. The SDK
|
|
117
|
-
* injects `app_id` from its own configuration, so callers supply the wallet
|
|
118
|
-
* address alone for the legacy shape.
|
|
119
|
-
*/
|
|
120
1205
|
interface PaymentCapabilityInputProperties {
|
|
121
|
-
/** GA shape: opaque user-link reference minted by the link-code exchange. */
|
|
122
1206
|
userLinkRef?: PaymentCapabilityRequestProperties['userLinkRef'];
|
|
123
|
-
/** Legacy shape: Facto server wallet address of the linked user. */
|
|
124
1207
|
factoServerWalletAddress?: PaymentCapabilityRequestProperties['facto_server_wallet_address'];
|
|
125
1208
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Mirrors the wire's INCLUSIVE sibling `anyOf`: legacy-only, GA-only, and the
|
|
128
|
-
* mixed migration shape are all accepted, and only an empty target is rejected.
|
|
129
|
-
* Do not collapse this into an exclusive union with `never` members — the
|
|
130
|
-
* engine contract has no `oneOf` and no `additionalProperties: false`.
|
|
131
|
-
*/
|
|
132
1209
|
type PaymentCapabilityInput = PaymentCapabilityInputProperties & (Required<Pick<PaymentCapabilityInputProperties, 'factoServerWalletAddress'>> | Required<Pick<PaymentCapabilityInputProperties, 'userLinkRef'>>);
|
|
133
1210
|
type PaymentOptionsInput = ({
|
|
134
1211
|
userLinkRef: string;
|
|
@@ -137,8 +1214,6 @@ type PaymentOptionsInput = ({
|
|
|
137
1214
|
userLinkRef?: never;
|
|
138
1215
|
grantRef: string;
|
|
139
1216
|
}) & {
|
|
140
|
-
/** Intended charge amount (decimal-USDC string). When set, the engine returns
|
|
141
|
-
* only options that can actually clear this amount (balance/allowance/limits). */
|
|
142
1217
|
amount?: string;
|
|
143
1218
|
assetSymbol?: string;
|
|
144
1219
|
};
|
|
@@ -151,16 +1226,13 @@ interface MerchantPaymentOption {
|
|
|
151
1226
|
chainLabel: string;
|
|
152
1227
|
protocolLabel: string;
|
|
153
1228
|
assetSymbol: string;
|
|
154
|
-
/**
|
|
155
|
-
* @deprecated Read `settlementPath`. The engine marks this field a duplicate
|
|
156
|
-
* of the settlement axis kept only for wire compatibility
|
|
157
|
-
* (Facto-to/facto#265), and it is the field that will be removed. When a
|
|
158
|
-
* response carries only `settlementPath`, this mirrors it.
|
|
159
|
-
*/
|
|
160
1229
|
spendMode: string;
|
|
161
|
-
/** How an accepted payment settles. Direct-only on the merchant surface. */
|
|
162
1230
|
settlementPath: string;
|
|
163
1231
|
blockingReason?: string;
|
|
1232
|
+
balanceStatus?: string | null;
|
|
1233
|
+
holdingBalance?: string | null;
|
|
1234
|
+
availableBalance?: string | null;
|
|
1235
|
+
assetDecimals?: number | null;
|
|
164
1236
|
}
|
|
165
1237
|
interface MerchantPaymentOptions {
|
|
166
1238
|
paymentOptions: MerchantPaymentOption[];
|
|
@@ -205,12 +1277,6 @@ interface MandateLimits {
|
|
|
205
1277
|
interface CreateMandateAuthorizationSessionRequest {
|
|
206
1278
|
appId: string;
|
|
207
1279
|
externalCustomerRef: string;
|
|
208
|
-
/**
|
|
209
|
-
* Display-only shopper identity, shown on the consent screens and copied
|
|
210
|
-
* onto the grant if the shopper connects inline (reversed-order flow).
|
|
211
|
-
* Never an identifier: not matched against Facto accounts and not part of
|
|
212
|
-
* any authorization decision. Mirrors the pinned engine wire request.
|
|
213
|
-
*/
|
|
214
1280
|
customerEmail?: string;
|
|
215
1281
|
customerUsername?: string;
|
|
216
1282
|
requestedUseCases: MandateUseCase[];
|
|
@@ -224,9 +1290,6 @@ interface MandateAuthorizationSession {
|
|
|
224
1290
|
authorizationUrl: string;
|
|
225
1291
|
status: MandateAuthorizationSessionStatus;
|
|
226
1292
|
mandateId?: string;
|
|
227
|
-
/** Present once a shopper has approved. In the reversed-order flow this
|
|
228
|
-
* poll response is the only channel where the merchant backend learns the
|
|
229
|
-
* link ref — no link-code exchange happens. */
|
|
230
1293
|
userLinkRef?: string;
|
|
231
1294
|
expiresAt: string;
|
|
232
1295
|
state: string;
|
|
@@ -255,6 +1318,8 @@ interface CreateMandatePaymentRequest {
|
|
|
255
1318
|
paymentOptionId?: string;
|
|
256
1319
|
description?: string;
|
|
257
1320
|
metadata?: Record<string, string>;
|
|
1321
|
+
subMerchantRef?: string | null;
|
|
1322
|
+
subMerchantDisplayName?: string | null;
|
|
258
1323
|
}
|
|
259
1324
|
interface CreateMandatePaymentInput extends CreateMandatePaymentRequest {
|
|
260
1325
|
idempotencyKey: string;
|
|
@@ -265,33 +1330,27 @@ interface MandatePayment {
|
|
|
265
1330
|
merchantPaymentRef: string;
|
|
266
1331
|
status: MandatePaymentStatus;
|
|
267
1332
|
amount: string;
|
|
1333
|
+
amountRefunded?: string;
|
|
268
1334
|
currency: string;
|
|
269
1335
|
useCase: MandateUseCase;
|
|
1336
|
+
subMerchantRef?: string | null;
|
|
1337
|
+
subMerchantDisplayName?: string | null;
|
|
270
1338
|
chargeId?: string;
|
|
271
|
-
/** On-chain settlement tx hash, present once the payment reaches a terminal status. */
|
|
272
1339
|
txHash?: string;
|
|
273
1340
|
declineReason?: MandateDeclineReason;
|
|
274
1341
|
finalityEtaSeconds?: number;
|
|
275
|
-
/** Timestamp the payment reached a terminal status. */
|
|
276
1342
|
terminalAt?: string;
|
|
277
1343
|
createdAt: string;
|
|
278
1344
|
updatedAt?: string;
|
|
279
1345
|
}
|
|
280
|
-
type
|
|
281
|
-
interface
|
|
282
|
-
/** Delay before the first poll and the base for backoff, in ms (default 1000). */
|
|
1346
|
+
type MerchantPaymentStatusListener = (payment: MandatePayment) => void;
|
|
1347
|
+
interface PollMerchantPaymentOptions {
|
|
283
1348
|
initialIntervalMs?: number;
|
|
284
|
-
/** Upper bound on the poll delay after backoff, in ms (default 8000). */
|
|
285
1349
|
maxIntervalMs?: number;
|
|
286
|
-
/** Multiplier applied to the delay after each poll (default 1.5). */
|
|
287
1350
|
backoffFactor?: number;
|
|
288
|
-
/** Hard cap on total polling time, in ms (default 300000). Resolves with the
|
|
289
|
-
* latest (possibly non-terminal) payment when hit. */
|
|
290
1351
|
timeoutMs?: number;
|
|
291
|
-
/** Cancels polling; the returned promise rejects with an AbortError. */
|
|
292
1352
|
signal?: AbortSignal;
|
|
293
1353
|
}
|
|
294
|
-
/** Cursor page envelope shared by every GA list endpoint. */
|
|
295
1354
|
interface Page<T> {
|
|
296
1355
|
data: T[];
|
|
297
1356
|
hasMore: boolean;
|
|
@@ -314,7 +1373,6 @@ type RefundReason = 'requested_by_customer' | 'duplicate' | 'fraudulent' | 'othe
|
|
|
314
1373
|
type RefundStatus = 'pending' | 'succeeded' | 'failed';
|
|
315
1374
|
interface CreateRefundInput {
|
|
316
1375
|
paymentId: string;
|
|
317
|
-
/** Omit for a full refund of the remaining amount. */
|
|
318
1376
|
amount?: string;
|
|
319
1377
|
reason?: RefundReason;
|
|
320
1378
|
merchantRefundRef?: string;
|
|
@@ -346,13 +1404,11 @@ interface WebhookEndpoint {
|
|
|
346
1404
|
createdAt: string;
|
|
347
1405
|
}
|
|
348
1406
|
interface WebhookEndpointWithSecret extends WebhookEndpoint {
|
|
349
|
-
/** Returned exactly once from create/rotate. Store server-side only. */
|
|
350
1407
|
secret: string;
|
|
351
1408
|
}
|
|
352
1409
|
type DevCapabilityName = 'fixtures' | 'synthetic_identity' | 'faucet' | 'simulation' | 'money_loop' | 'webhook_test_delivery';
|
|
353
1410
|
type DevCapabilityStatus = 'unavailable' | 'degraded' | 'ready';
|
|
354
1411
|
type DevEvidenceLevel = 'contract' | 'implemented' | 'deployed' | 'verified';
|
|
355
|
-
/** Current public evidence projection for one Dev capability. */
|
|
356
1412
|
interface DevCapability {
|
|
357
1413
|
name: DevCapabilityName;
|
|
358
1414
|
status: DevCapabilityStatus;
|
|
@@ -361,14 +1417,12 @@ interface DevCapability {
|
|
|
361
1417
|
verifiedAt?: string | null;
|
|
362
1418
|
limits?: Record<string, string | number | boolean | null>;
|
|
363
1419
|
}
|
|
364
|
-
/** Read-only Dev availability and evidence projection. */
|
|
365
1420
|
interface DevCapabilities {
|
|
366
1421
|
environment: 'dev';
|
|
367
1422
|
contractVersion: '2026-07-09';
|
|
368
1423
|
capabilities: DevCapability[];
|
|
369
1424
|
checkedAt: string;
|
|
370
1425
|
}
|
|
371
|
-
/** Dev endpoints accept USDC decimal strings only. */
|
|
372
1426
|
interface DevMoney {
|
|
373
1427
|
amount: string;
|
|
374
1428
|
currency: 'USDC';
|
|
@@ -389,7 +1443,6 @@ interface SimulateDevChargeInput {
|
|
|
389
1443
|
merchantReference?: string;
|
|
390
1444
|
idempotencyKey: string;
|
|
391
1445
|
}
|
|
392
|
-
/** A Dev simulation is not a MerchantPayment and has no production settlement meaning. */
|
|
393
1446
|
interface DevSimulation {
|
|
394
1447
|
simulationId: string;
|
|
395
1448
|
scenario: DevSimulationScenario;
|
|
@@ -420,215 +1473,57 @@ interface WebhookTestDeliveryAccepted {
|
|
|
420
1473
|
}
|
|
421
1474
|
interface FactoConnectServerClient {
|
|
422
1475
|
createHostedConnectUrl(input: CreateHostedConnectUrlInput): string;
|
|
423
|
-
/** GA operation name for exchanging a one-time user-link code. */
|
|
424
1476
|
exchangeUserLinkCode(input: ExchangeLinkCodeInput): Promise<ExchangeLinkCodeResult>;
|
|
425
|
-
/** GA operation name for reading payment readiness. */
|
|
426
1477
|
getPaymentReadiness(input: PaymentCapabilityInput): Promise<PaymentCapability>;
|
|
427
|
-
/** GA operation name for creating a payment authorization session. */
|
|
428
1478
|
createAuthorizationSession(input: CreateMandateAuthorizationSessionInput): Promise<MandateAuthorizationSession>;
|
|
429
|
-
/** GA operation name for reading a payment authorization session. */
|
|
430
1479
|
getAuthorizationSession(sessionId: string): Promise<MandateAuthorizationSession>;
|
|
431
|
-
/** GA operation name for reading one payment authorization. */
|
|
432
1480
|
getPaymentAuthorization(authorizationId: string): Promise<MerchantMandate>;
|
|
433
|
-
/** GA operation name for creating an authorized merchant payment. */
|
|
434
1481
|
createMerchantPayment(input: CreateMandatePaymentInput): Promise<MandatePayment>;
|
|
435
|
-
/** GA operation name for reading one merchant payment. */
|
|
436
1482
|
getMerchantPayment(paymentId: string): Promise<MandatePayment>;
|
|
437
|
-
/** @deprecated Use `exchangeUserLinkCode`. */
|
|
438
1483
|
exchangeLinkCode(input: ExchangeLinkCodeInput): Promise<ExchangeLinkCodeResult>;
|
|
439
|
-
/** @deprecated Use `getPaymentReadiness`. */
|
|
440
1484
|
getPaymentCapability(input: PaymentCapabilityInput): Promise<PaymentCapability>;
|
|
441
1485
|
createCheckoutSession(input: CreateCheckoutSessionInput): Promise<CheckoutSession>;
|
|
442
1486
|
getCheckoutSession(id: string): Promise<CheckoutSessionStatus>;
|
|
443
|
-
/** @deprecated Use `createAuthorizationSession`. */
|
|
444
1487
|
createMandateAuthorizationSession(input: CreateMandateAuthorizationSessionInput): Promise<MandateAuthorizationSession>;
|
|
445
|
-
/** @deprecated Use `getAuthorizationSession`. */
|
|
446
1488
|
getMandateAuthorizationSession(sessionId: string): Promise<MandateAuthorizationSession>;
|
|
447
|
-
/** @deprecated Use `getPaymentAuthorization`. */
|
|
448
1489
|
getMerchantMandate(mandateId: string): Promise<MerchantMandate>;
|
|
449
1490
|
listPaymentOptions(input: PaymentOptionsInput): Promise<MerchantPaymentOptions>;
|
|
450
|
-
/** @deprecated Use `createMerchantPayment`. */
|
|
451
1491
|
createMandatePayment(input: CreateMandatePaymentInput): Promise<MandatePayment>;
|
|
452
|
-
/** @deprecated Use `getMerchantPayment`. */
|
|
453
1492
|
getMandatePayment(paymentId: string): Promise<MandatePayment>;
|
|
454
|
-
|
|
455
|
-
* Short-poll a mandate payment until it reaches a terminal status. `listener`
|
|
456
|
-
* is invoked with the payment on the first poll and on every status change;
|
|
457
|
-
* the returned promise resolves with the terminal payment (or the latest
|
|
458
|
-
* payment if `timeoutMs` elapses first). Polling backs off between requests
|
|
459
|
-
* and stops on terminal status, timeout, or abort.
|
|
460
|
-
*/
|
|
461
|
-
onStatus(paymentId: string, listener: MandatePaymentStatusListener, options?: OnMandatePaymentStatusOptions): Promise<MandatePayment>;
|
|
462
|
-
/** Revoke a user link the merchant no longer needs (GA-only). */
|
|
1493
|
+
pollMerchantPayment(paymentId: string, onUpdate: MerchantPaymentStatusListener, options?: PollMerchantPaymentOptions): Promise<MandatePayment>;
|
|
463
1494
|
revokeUserLink(userLinkRef: string): Promise<void>;
|
|
464
|
-
/** List merchant payments (reconciliation source of truth). */
|
|
465
1495
|
listMerchantPayments(filter?: MerchantPaymentListFilter): Promise<Page<MandatePayment>>;
|
|
466
|
-
/** List payment authorizations (mandates) for this app. */
|
|
467
1496
|
listPaymentAuthorizations(filter?: PaymentAuthorizationListFilter): Promise<Page<MerchantMandate>>;
|
|
468
|
-
/** Create a refund against a succeeded payment (partial-capable). */
|
|
469
1497
|
createRefund(input: CreateRefundInput): Promise<Refund>;
|
|
470
1498
|
getRefund(refundId: string): Promise<Refund>;
|
|
471
1499
|
listRefunds(filter?: RefundListFilter): Promise<Page<Refund>>;
|
|
472
|
-
/** Register a webhook endpoint. The signing secret is returned exactly once. */
|
|
473
1500
|
createWebhookEndpoint(input: CreateWebhookEndpointInput): Promise<WebhookEndpointWithSecret>;
|
|
474
1501
|
listWebhookEndpoints(): Promise<WebhookEndpoint[]>;
|
|
475
1502
|
getWebhookEndpoint(webhookEndpointId: string): Promise<WebhookEndpoint>;
|
|
476
1503
|
deleteWebhookEndpoint(webhookEndpointId: string): Promise<void>;
|
|
477
|
-
/** Rotate the signing secret; the previous secret verifies for 24h. */
|
|
478
1504
|
rotateWebhookSecret(webhookEndpointId: string): Promise<WebhookEndpointWithSecret>;
|
|
479
|
-
/** Read the Dev capability/evidence projection. Dev environment only. */
|
|
480
1505
|
getDevCapabilities(): Promise<DevCapabilities>;
|
|
481
|
-
/** Request test-only USDC for an app-owned synthetic linked user. Dev only. */
|
|
482
1506
|
fundDevUser(input: FundDevUserInput): Promise<DevFaucetTransfer>;
|
|
483
|
-
/** Create a Dev simulation, distinct from a MerchantPayment. Dev only. */
|
|
484
1507
|
simulateDevCharge(input: SimulateDevChargeInput): Promise<DevSimulation>;
|
|
485
|
-
/** Read an app-owned Dev simulation. Dev only. */
|
|
486
1508
|
getDevSimulation(simulationId: string): Promise<DevSimulation>;
|
|
487
|
-
/** Queue a signed no-business-state `test.ping`. Dev environment only. */
|
|
488
1509
|
sendWebhookTestDelivery(input: SendWebhookTestDeliveryInput): Promise<WebhookTestDeliveryAccepted>;
|
|
489
1510
|
}
|
|
490
|
-
type FactoConnectServerErrorCode = 'FACTO_CONFIG_INVALID' | 'FACTO_ENGINE_REQUEST_FAILED' | 'FACTO_ENGINE_RESPONSE_INVALID' | 'FACTO_REQUEST_ABORTED' | 'FACTO_STATUS_POLL_ABORTED';
|
|
491
|
-
declare class FactoConnectServerError extends Error {
|
|
492
|
-
readonly code: FactoConnectServerErrorCode;
|
|
493
|
-
readonly retryable: boolean;
|
|
494
|
-
readonly status?: number;
|
|
495
|
-
readonly details?: unknown;
|
|
496
|
-
/** Seconds from the `Retry-After` response header on a 429, when present. */
|
|
497
|
-
readonly retryAfterSeconds?: number;
|
|
498
|
-
constructor(code: FactoConnectServerErrorCode, message: string, options: {
|
|
499
|
-
retryable: boolean;
|
|
500
|
-
status?: number;
|
|
501
|
-
details?: unknown;
|
|
502
|
-
retryAfterSeconds?: number;
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Options for {@link withServerRetry} and the server client's safe automatic
|
|
507
|
-
* retry policy. GET calls and idempotency-keyed POST calls use these defaults.
|
|
508
|
-
*/
|
|
509
|
-
interface ServerRetryOptions {
|
|
510
|
-
/** Max retry attempts after the first try (default 2). */
|
|
511
|
-
maxRetries?: number;
|
|
512
|
-
/** Base backoff in ms for the exponential fallback (default 200). */
|
|
513
|
-
baseDelayMs?: number;
|
|
514
|
-
/** Backoff cap in ms (default 5000). */
|
|
515
|
-
maxDelayMs?: number;
|
|
516
|
-
/** Honor the server's `Retry-After` when present (default true). */
|
|
517
|
-
respectRetryAfter?: boolean;
|
|
518
|
-
/** Abort waiting/retrying. */
|
|
519
|
-
signal?: AbortSignal;
|
|
520
|
-
/** Invoked before each retry sleep. */
|
|
521
|
-
onRetry?: (info: {
|
|
522
|
-
attempt: number;
|
|
523
|
-
error: FactoConnectServerError;
|
|
524
|
-
delayMs: number;
|
|
525
|
-
}) => void;
|
|
526
|
-
/** Injectable delay (tests). Defaults to a `setTimeout` sleep that respects `signal`. */
|
|
527
|
-
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Opt-in retry wrapper for any server-client call. Retries a
|
|
531
|
-
* {@link FactoConnectServerError} whose `retryable` is true (429 / 5xx),
|
|
532
|
-
* honoring `Retry-After` when the server sent it, otherwise exponential backoff
|
|
533
|
-
* with jitter. Non-retryable errors and non-Facto errors are rethrown
|
|
534
|
-
* immediately. The server client applies the same policy only to GET calls and
|
|
535
|
-
* POST calls carrying `Idempotency-Key`; this standalone wrapper remains useful
|
|
536
|
-
* for callers composing their own safe operation:
|
|
537
|
-
*
|
|
538
|
-
* ```ts
|
|
539
|
-
* const payment = await withServerRetry(() => facto.createMandatePayment(input))
|
|
540
|
-
* ```
|
|
541
|
-
*/
|
|
542
|
-
declare function withServerRetry<T>(fn: () => Promise<T>, options?: ServerRetryOptions): Promise<T>;
|
|
543
1511
|
declare function buildHostedConnectUrl(input: HostedConnectUrlInput): string;
|
|
544
1512
|
declare function createFactoConnectServer(options: FactoConnectServerOptions): FactoConnectServerClient;
|
|
545
|
-
/** Whether a mandate payment status is terminal (no further transitions). */
|
|
546
1513
|
declare function isTerminalMandatePaymentStatus(status: MandatePaymentStatus): boolean;
|
|
547
|
-
/**
|
|
548
|
-
* Sign a raw Facto webhook payload using the same `t/v1` format accepted by
|
|
549
|
-
* {@link verifyWebhookSignature}. This helper is server-only and intended for
|
|
550
|
-
* deterministic fixtures and partner webhook tests.
|
|
551
|
-
*/
|
|
552
1514
|
declare function signWebhookPayload(rawBody: string | Uint8Array, secret: string, timestamp?: number): string;
|
|
553
|
-
/**
|
|
554
|
-
* Verify a Facto webhook `Facto-Signature` header against the raw request body
|
|
555
|
-
* (spec 012 webhook contract). Recompute `HMAC-SHA256(secret, "{t}.{raw_body}")`
|
|
556
|
-
* over the EXACT raw bytes, compare in constant time, and reject stale
|
|
557
|
-
* timestamps. Verify BEFORE parsing JSON. During a secret rotation the header
|
|
558
|
-
* may carry two `v1` entries; verification passes if any matches.
|
|
559
|
-
*
|
|
560
|
-
* @param rawBody the exact request body bytes (string or Buffer)
|
|
561
|
-
* @param header the `Facto-Signature` header value (`t=..,v1=..[,v1=..]`)
|
|
562
|
-
* @param secret the endpoint signing secret
|
|
563
|
-
* @param toleranceSeconds max clock skew (default 300s)
|
|
564
|
-
*/
|
|
565
1515
|
declare function verifyWebhookSignature(rawBody: string | Uint8Array, header: string, secret: string, toleranceSeconds?: number): boolean;
|
|
566
|
-
|
|
567
|
-
interface
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
kid?: string;
|
|
572
|
-
alg?: string;
|
|
573
|
-
use?: string;
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* The Facto connect-hint JWK set, served (public, no auth) at
|
|
577
|
-
* `GET /.well-known/facto-card-program-connect/jwks.json`.
|
|
578
|
-
*/
|
|
579
|
-
interface FactoCardProgramConnectJwks {
|
|
580
|
-
keys: FactoCardProgramConnectJwk[];
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* How the caller supplies the Facto JWKS: an in-memory `{ keys }` set, a JWKS URL
|
|
584
|
-
* string to fetch (public GET, no auth), or a resolver that returns the set.
|
|
585
|
-
*/
|
|
586
|
-
type FactoCardProgramConnectJwksInput = FactoCardProgramConnectJwks | string | (() => FactoCardProgramConnectJwks | Promise<FactoCardProgramConnectJwks>);
|
|
587
|
-
interface VerifyFactoCardProgramConnectHintInput {
|
|
588
|
-
/** The compact EdDSA JWS the Facto user handed the partner. */
|
|
589
|
-
connectHint: string;
|
|
590
|
-
/** The Facto JWKS: an in-memory `{ keys }` set, a JWKS URL to fetch, or a resolver. */
|
|
591
|
-
jwks: FactoCardProgramConnectJwksInput;
|
|
592
|
-
/**
|
|
593
|
-
* The partner's own connection audience — its environment-unique program code.
|
|
594
|
-
* The hint's `aud` MUST equal this; a mismatch is rejected. Required, because a
|
|
595
|
-
* hint is only meaningful for the program it was scoped to.
|
|
596
|
-
*/
|
|
597
|
-
audience: string;
|
|
598
|
-
/** Expected issuer. Defaults to `'facto'`. */
|
|
599
|
-
issuer?: string;
|
|
600
|
-
/** Verification clock (unix milliseconds or `Date`). Defaults to `Date.now()`. */
|
|
601
|
-
now?: number | Date;
|
|
602
|
-
/** Clock-skew tolerance in seconds applied to the expiry check. Defaults to `0`. */
|
|
603
|
-
clockToleranceSeconds?: number;
|
|
604
|
-
}
|
|
605
|
-
interface FactoCardProgramConnectHint {
|
|
606
|
-
/** The opaque program the hint is scoped to (`cprog_...`). */
|
|
607
|
-
programRef: string;
|
|
608
|
-
/** Pairwise-opaque subject (`facto-user:<hex>`); NEVER the raw Facto user id. */
|
|
609
|
-
pairwiseSubject: string;
|
|
610
|
-
/** Single-use nonce; the caller MUST enforce single-use against its own store. */
|
|
611
|
-
nonce: string;
|
|
612
|
-
/** Absolute expiry (`exp`) as an RFC 3339 / ISO-8601 timestamp. */
|
|
613
|
-
expiresAt: string;
|
|
1516
|
+
|
|
1517
|
+
interface EnterpriseFundsServerOptions extends Omit<FactoConnectServerOptions, 'retry'> {
|
|
1518
|
+
readonly store: EnterpriseCommandJournalStorePort;
|
|
1519
|
+
readonly ownerScope: EnterpriseS2sOwnerBindingInput;
|
|
1520
|
+
readonly getCallerContext: () => EnterpriseHostCallerSessionContext;
|
|
614
1521
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
readonly
|
|
619
|
-
constructor(code: FactoConnectHintErrorCode, message: string, options?: {
|
|
620
|
-
details?: unknown;
|
|
621
|
-
});
|
|
1522
|
+
declare function createEnterpriseFundsServerClient(options: EnterpriseFundsServerOptions): EnterpriseFundsServerClient;
|
|
1523
|
+
|
|
1524
|
+
interface EnterprisePurchaseServerOptions extends Omit<FactoConnectServerOptions, 'retry'> {
|
|
1525
|
+
readonly getHostContext: () => EnterprisePurchaseHostContext;
|
|
622
1526
|
}
|
|
623
|
-
|
|
624
|
-
* Verify a Facto-initiated card-program connect-hint (Feature 020 slice C2).
|
|
625
|
-
*
|
|
626
|
-
* Validates the Ed25519 signature against the Facto JWKS, enforces `iss` / `aud`
|
|
627
|
-
* / `exp`, and returns the safe claims. The returned `pairwiseSubject` is the
|
|
628
|
-
* pairwise-opaque HMAC subject (never the raw Facto user id) the partner binds to
|
|
629
|
-
* its own cardholder; the returned `nonce` MUST be enforced single-use by the
|
|
630
|
-
* caller against its own store.
|
|
631
|
-
*/
|
|
632
|
-
declare function verifyFactoCardProgramConnectHint(input: VerifyFactoCardProgramConnectHintInput): Promise<FactoCardProgramConnectHint>;
|
|
1527
|
+
declare function createEnterprisePurchaseServerClient(options: EnterprisePurchaseServerOptions): EnterprisePurchaseServerClient;
|
|
633
1528
|
|
|
634
|
-
export { type CheckoutSession, type CheckoutSessionStatus, type CheckoutStatus, type CreateCheckoutSessionInput, type CreateHostedConnectUrlInput, type CreateMandateAuthorizationSessionInput, type CreateMandateAuthorizationSessionRequest, type CreateMandatePaymentInput, type CreateMandatePaymentRequest, type CreateRefundInput, type CreateWebhookEndpointInput, type CursorListFilter, type DevCapabilities, type DevCapability, type DevCapabilityName, type DevCapabilityStatus, type DevEvidenceLevel, type DevFaucetTransfer, type DevMoney, type DevSimulation, type DevSimulationExecutionMode, type DevSimulationScenario, type DevSimulationStatus, type ExchangeLinkCodeInput, type ExchangeLinkCodeResult, FACTO_CONNECT_API_BASE_URLS, FACTO_CONNECT_HOSTED_URLS, type FactoCardProgramConnectHint, type FactoCardProgramConnectJwk, type FactoCardProgramConnectJwks, type FactoCardProgramConnectJwksInput, type FactoConnectEnvironment, FactoConnectHintError, type FactoConnectHintErrorCode, type FactoConnectServerClient, FactoConnectServerError, type FactoConnectServerErrorCode, type FactoConnectServerOptions, type FactoConnectTransport, type FundDevUserInput, type HostedConnectUrlInput, type MandateAuthorizationSession, type MandateLimits, type MandatePayment, type MandatePaymentStatusListener, type MerchantMandate, type MerchantPaymentListFilter, type MerchantPaymentOption, type MerchantPaymentOptions, type MerchantPaymentPathProjection, type OnMandatePaymentStatusOptions, type Page, type PaymentAuthorizationListFilter, type PaymentCapability, type PaymentCapabilityInput, type PaymentOptionsInput, type Refund, type RefundListFilter, type RefundReason, type RefundStatus, type SendWebhookTestDeliveryInput, type ServerRetryOptions, type SimulateDevChargeInput, type VerifyFactoCardProgramConnectHintInput, type WebhookEndpoint, type WebhookEndpointWithSecret, type WebhookEventType, type WebhookTestDeliveryAccepted, buildHostedConnectUrl, createFactoConnectServer, createFactoConnectServer as default, isTerminalMandatePaymentStatus, signWebhookPayload, verifyFactoCardProgramConnectHint, verifyWebhookSignature, withServerRetry };
|
|
1529
|
+
export { type ApplyQualifiedCashRequest, type AssetIdentifier, type AudienceProjectionUnavailableResponse, type AuthRevokedErrorResponse, type BindOrTransitionGuaranteeRequest, type BusinessProgressUnknownReason, CARD_INTENT_JWKS_PATH, type CacheCoordinationEnvelope, type CanonicalEnterpriseCommandObject, type CanonicalOwnerScope, type CanonicalizedEnterpriseCommandBundle, type CardIntentJwk, type CardIntentJwks, type CardIntentJwksInput, type CheckoutSession, type CheckoutSessionStatus, type CheckoutStatus, type CommandClosureTarget, type CommandUnknownRecoveryResponse, type CommercialReductionCoverage, type CommercialReductionDisclosureWithheldReason, type ConsoleBusinessProgress, type ConsoleCommandReceipt, type ConsoleCommandRecoveryResponse, type ConsoleCommandUnknownRecoveryResponse, type ConsoleOrderProjection, type ConsoleProjectionResponse, type ConsumerBusinessProgress, type ConsumerCollectionProgress, type ConsumerOperationRecoveryResponse, type ConsumerOperationUnknownRecoveryResponse, type ConsumerOrderProjection, type ConsumerProjectionResponse, type CreateCheckoutSessionInput, type CreateHostedConnectUrlInput, type CreateMandateAuthorizationSessionInput, type CreateMandateAuthorizationSessionRequest, type CreateMandatePaymentInput, type CreateMandatePaymentRequest, type CreateOrTransitionSourceHoldRequest, type CreateRefundInput, type CreateWebhookEndpointInput, type CursorListFilter, type DeterministicCommandErrorResponse, type DevCapabilities, type DevCapability, type DevCapabilityName, type DevCapabilityStatus, type DevEvidenceLevel, type DevFaucetTransfer, type DevMoney, type DevSimulation, type DevSimulationExecutionMode, type DevSimulationScenario, type DevSimulationStatus, type DispatchOrObserveExecutionFamilyRequest, ENTERPRISE_ASSET_KINDS, ENTERPRISE_AUDIENCE_READ_ROUTE_TEMPLATES, ENTERPRISE_AUTH_REVOKED_ERROR_CODES, ENTERPRISE_BUSINESS_PROGRESS_UNKNOWN_REASONS, ENTERPRISE_CLOSURE_TARGET_TABLES, ENTERPRISE_COMMAND_KINDS, ENTERPRISE_COMMAND_PROTOCOL_V1, ENTERPRISE_COMMAND_UNKNOWN_REASONS, ENTERPRISE_COMMERCIAL_REDUCTION_COVERAGES, ENTERPRISE_COMMERCIAL_REDUCTION_REF_PREFIX_V1, ENTERPRISE_CONSUMER_EXECUTION_STATES, ENTERPRISE_DETERMINISTIC_ERROR_CODES, ENTERPRISE_FULFILLMENT_QUALIFICATIONS, ENTERPRISE_GUARANTEE_PROGRESS_STATES, ENTERPRISE_GUARANTEE_STATES, ENTERPRISE_KIND_TO_TARGET_TABLE, ENTERPRISE_MERCHANT_COMMAND_ROUTE_TEMPLATES, ENTERPRISE_MERCHANT_RECOVERY_ROUTE_TEMPLATE, ENTERPRISE_OPERATION_UNKNOWN_REASONS, ENTERPRISE_PARTNER_CAPTURE_PAYOUT_PROGRESS_STATES, ENTERPRISE_PARTNER_FACT_KINDS, ENTERPRISE_PRODUCER_KINDS, ENTERPRISE_PUBLIC_MERCHANT_COMMAND_KINDS, ENTERPRISE_SCOPE_REF_PREFIX_V1, ENTERPRISE_SERVER_DERIVED_COMMAND_KINDS, ENTERPRISE_SOURCE_EXECUTION_PROGRESS_STATES, ENTERPRISE_SOURCE_PROTOCOLS, ENTERPRISE_TARGET_GUARANTEE_STATES, ENTERPRISE_TARGET_HOLD_STATES, ENTERPRISE_TERMINAL_HOLD_STATES, ENTERPRISE_TRACKED_UNKNOWN_REASONS, type EnterpriseAssetKind, type EnterpriseAudienceReadPathParams, type EnterpriseAudienceReadResult, type EnterpriseAudienceReadRoute, type EnterpriseAuthRevokedErrorCode, type EnterpriseCallerSessionContext, type EnterpriseCanonicalRequestPayload, type EnterpriseClosureTargetTable, type EnterpriseCommandActiveExecutionResult, type EnterpriseCommandActiveRecoveryResult, type EnterpriseCommandCasTriple, type EnterpriseCommandExecutionResult, type EnterpriseCommandJournalSnapshot, type EnterpriseCommandJournalStorePort, type EnterpriseCommandKind, type EnterpriseCommandPathParams, type EnterpriseCommandRecoveryResult, type EnterpriseCommandRequestInput, type EnterpriseCommandStaleOrDeniedExecutionResult, type EnterpriseCommandStaleOrDeniedRecoveryResult, type EnterpriseCommandStaleOrDeniedResult, type EnterpriseCommandUnknownReason, type EnterpriseConsumerExecutionState, type EnterpriseDeterministicErrorCode, type EnterpriseFulfillmentQualification, type EnterpriseFundsServerClient, type EnterpriseFundsServerOptions, type EnterpriseGuaranteeState, type EnterpriseHostCallerSessionContext, EnterpriseJournalAccessDeniedError, EnterpriseJournalConflictError, EnterpriseJournalIntegrityError, type EnterpriseJournalOwnerScope, EnterpriseJournalStoreError, EnterpriseJournalValidationError, type EnterpriseLoadPendingInput, type EnterpriseOperationUnknownReason, type EnterpriseOrderScopeSelector, type EnterprisePartnerFactKind, type EnterpriseProducerKind, type EnterpriseProjectionApplyResult, type EnterprisePublicMerchantCommandKind, type EnterprisePublicMerchantWireCommandRequest, type EnterprisePurchaseActiveResult, type EnterprisePurchaseConflictEnvelope, type EnterprisePurchaseErrorEnvelope, type EnterprisePurchaseFirstHoldCandidate, type EnterprisePurchaseHostContext, type EnterprisePurchasePendingEnvelope, type EnterprisePurchasePreparation, type EnterprisePurchasePreparationEnvelope, type EnterprisePurchasePreparationRequest, type EnterprisePurchasePreparationResult, type EnterprisePurchasePreparedEnvelope, type EnterprisePurchaseSafeEmptyResult, type EnterprisePurchaseServerClient, type EnterprisePurchaseServerOptions, type EnterpriseRecoverCommandInput, type EnterpriseS2sOwnerBindingInput, type EnterpriseServerDerivedCommandKind, type EnterpriseSourceProtocolId, type EnterpriseSubmitCommandInput, type EnterpriseTargetGuaranteeState, type EnterpriseTargetHoldState, type EnterpriseTerminalHoldState, type EnterpriseTrackedUnknownReason, type EnterpriseWireCommandRequest, EnterpriseWireValidationError, type EvaluatedMerchantWireResponse, type ExchangeLinkCodeInput, type ExchangeLinkCodeResult, FACTO_CONNECT_API_BASE_URLS, FACTO_CONNECT_HOSTED_URLS, type FactoConnectEnvironment, type FactoConnectServerClient, type FactoConnectServerOptions, type FactoConnectTransport, FactoIntentTokenError, type FactoIntentTokenErrorCode, type FundDevUserInput, type GuaranteeProgress, type GuaranteeProgressKnownState, type HostedConnectUrlInput, type InfrastructureUnavailableResponse, MAX_UINT256_DECIMAL, type MandateAuthorizationSession, MandateAuthorizationSessionStatus as MandateAuthorizationStatus, MandateDeclineReason, MandateLimitPeriod, type MandateLimits, type MandatePayment, MandatePaymentStatus, MandateStatus, MandateUseCase, type MerchantCommandEnvelopeResponse, type MerchantCommandReceipt, type MerchantCommandRecoveryResponse, type MerchantCommercialReductionEnvelopeResponse, type MerchantCommercialReductionRecoveryResponse, type MerchantMandate, type MerchantPaymentListFilter, type MerchantPaymentOption, type MerchantPaymentOptions, type MerchantPaymentPathProjection, type MerchantPaymentStatusListener, type MerchantS2sCollectedFeeEffect, type MerchantS2sCommercialReduction, type MerchantS2sCommercialReductionProjection, type MerchantS2sOrderProjection, type NormalizedSourceRootKey, type OpaqueOperationRef, type OriginalThreeCasInput, PSP_CAPABILITY_TEMPLATES, PSP_CREDENTIAL_KEYSPACE, PSP_CREDENTIAL_SCOPES, PSP_PARTNER_ROLE_TYPE, type Page, type PartnerBusinessProgress, type PartnerCapturePayoutProgressKnownState, type PartnerCaptureProgress, type PartnerOperationRecoveryResponse, type PartnerOperationUnknownRecoveryResponse, type PartnerOrderProjection, type PartnerPayoutProgress, type PartnerProjectionResponse, type PartnerWorkspaceOrderProjection, type PaymentAuthorizationListFilter, type PaymentCapability, type PaymentCapabilityInput, type PaymentOptionsInput, type PollMerchantPaymentOptions, type PositiveUInt64Revision, type PrefixedSha256Digest, type ProducerVerificationEnvelope, type PspCapabilityTemplate, type PublicOperationReceipt, type PublicOperationSummary, type RecordPrefundOrPartnerFactRequest, type Refund, type RefundListFilter, type RefundReason, type RefundStatus, type RevisionDecimalString, type ScopedObjectRef, type SendWebhookTestDeliveryInput, ServerRetryOptions, type SettleCommercialReductionRequest, type Sha256HexDigest, type SharedPrefundAdmissionGuard, type SimulateDevChargeInput, type SourceExecutionProgress, type SourceExecutionProgressKnownState, type TrackedDecimalAmount, type UInt256DecimalString, type VerifiedCardIntentToken, type ConnectVerifyCardIntentTokenInput as VerifyCardIntentTokenInput, type WebhookEndpoint, type WebhookEndpointWithSecret, type WebhookEventType, type WebhookTestDeliveryAccepted, buildAudienceReadPath, buildHostedConnectUrl, buildMerchantCommandPath, buildMerchantRecoveryPath, canonicalizeAndMapEnterpriseCommand, carriesMoneyVerb, computeEnterpriseScopeRef, coreDigestToWireDigest, createEnterpriseFundsServerClient as createEnterpriseFundsClient, createEnterpriseFundsServerClient, createEnterprisePurchaseServerClient, createFactoConnectServer, decodeCanonicalCommandFromEnvelope, createFactoConnectServer as default, deriveCommercialReductionRef, encodeCanonicalUtf8Bytes, evaluateMerchantWireResponseAgainstEnvelope, factoConnectEnvironmentFromClientId, isServerDerivedEnterpriseCommandKind, isTerminalMandatePaymentStatus, parseAuthRevokedErrorResponse, parseCommandUnknownRecoveryResponse, parseConsoleCommandReceipt, parseConsoleCommandRecoveryResponse, parseConsoleCommandUnknownRecoveryResponse, parseConsoleOrderProjection, parseConsoleProjectionResponse, parseConsumerBusinessProgress, parseConsumerOperationRecoveryResponse, parseConsumerOperationUnknownRecoveryResponse, parseConsumerOrderProjection, parseConsumerProjectionResponse, parseDeterministicCommandErrorResponse, parseInfrastructureUnavailableResponse, parseMerchantCommandEnvelopeResponse, parseMerchantCommandRecoveryResponse, parseMerchantCommercialReductionEnvelopeResponse, parseMerchantCommercialReductionRecoveryResponse, parseMerchantS2sCollectedFeeEffect, parseMerchantS2sCommercialReduction, parseMerchantS2sCommercialReductionProjection, parseMerchantS2sOrderProjection, parsePartnerBusinessProgress, parsePartnerOperationRecoveryResponse, parsePartnerOperationUnknownRecoveryResponse, parsePartnerProjectionResponse, readConsoleCommandResult, readConsoleProjectionResult, readConsumerOperationResult, readConsumerProjectionResult, readPartnerOperationResult, readPartnerProjectionResult, serializeCanonicalJson, signWebhookPayload, subMerchantOf, validateAndNormalizeS2sOwnerScope, verifyCardIntentTokenForConnect as verifyCardIntentToken, verifyWebhookSignature, wireDigestToCoreDigest, withSubMerchant };
|