@facto-to/connect 0.0.1-beta.1 → 0.0.1-beta.5
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 +128 -20
- package/dist/browser/index.cjs +5 -6
- package/dist/browser/index.d.cts +1 -31
- package/dist/browser/index.d.ts +1 -31
- package/dist/browser/index.js +4 -5
- package/dist/index.d-DE9GmLfU.d.cts +114 -0
- package/dist/index.d-DE9GmLfU.d.ts +114 -0
- package/dist/react/index.cjs +0 -1
- package/dist/react/index.js +0 -1
- package/dist/server/index.cjs +1 -2
- package/dist/server/index.d.cts +33 -227
- package/dist/server/index.d.ts +33 -227
- package/dist/server/index.js +1 -2
- package/dist/testing/index.cjs +1 -2
- package/dist/testing/index.d.cts +1 -12
- package/dist/testing/index.d.ts +1 -12
- package/dist/testing/index.js +1 -2
- package/package.json +51 -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,80 @@
|
|
|
1
|
-
import { MandateUseCase, MandateLimitPeriod, ExchangeLinkCodeResponse, PaymentCapabilityRequestProperties, PaymentCapabilityResponse, MandateAuthorizationSessionStatus, MandateStatus, MandatePaymentStatus, MandateDeclineReason } from '
|
|
2
|
-
export {
|
|
1
|
+
import { M as MandatePayment$1, C as CreateMandatePaymentRequest$1, a as MandateUseCase, b as MandateLimitPeriod, E as ExchangeLinkCodeResponse, P as PaymentCapabilityRequestProperties, c as PaymentCapabilityResponse, d as MandateAuthorizationSessionStatus, e as MandateStatus, f as MandatePaymentStatus, g as MandateDeclineReason } from '../index.d-DE9GmLfU.js';
|
|
2
|
+
export { h as PaymentReadinessNotReadyReason, i as PaymentReadinessScope } from '../index.d-DE9GmLfU.js';
|
|
3
|
+
|
|
4
|
+
declare const PSP_CAPABILITY_TEMPLATES: readonly ["psp_connect_sandbox", "psp_mandate_sandbox", "psp_billing_sandbox"];
|
|
5
|
+
type PspCapabilityTemplate = (typeof PSP_CAPABILITY_TEMPLATES)[number];
|
|
6
|
+
declare const PSP_CREDENTIAL_SCOPES: Record<PspCapabilityTemplate, readonly string[]>;
|
|
7
|
+
declare function carriesMoneyVerb(template: PspCapabilityTemplate): boolean;
|
|
8
|
+
declare const PSP_CREDENTIAL_KEYSPACE: {
|
|
9
|
+
readonly dev: {
|
|
10
|
+
readonly clientIdPrefix: "dev_pspid_";
|
|
11
|
+
readonly clientSecretPrefix: "dev_pspsk_";
|
|
12
|
+
};
|
|
13
|
+
readonly test: {
|
|
14
|
+
readonly clientIdPrefix: "test_pspid_";
|
|
15
|
+
};
|
|
16
|
+
readonly lab: {
|
|
17
|
+
readonly clientIdPrefix: "lab_pspid_";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
declare const PSP_PARTNER_ROLE_TYPE = "psp";
|
|
21
|
+
declare function withSubMerchant(request: CreateMandatePaymentRequest$1, subMerchant: {
|
|
22
|
+
ref?: string;
|
|
23
|
+
displayName?: string;
|
|
24
|
+
}): CreateMandatePaymentRequest$1;
|
|
25
|
+
declare function subMerchantOf(payment: MandatePayment$1): {
|
|
26
|
+
ref?: string;
|
|
27
|
+
displayName?: string;
|
|
28
|
+
};
|
|
3
29
|
|
|
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
30
|
type FactoConnectEnvironment = 'dev' | 'production' | 'sandbox';
|
|
20
|
-
/** Canonical infrastructure names keying the published endpoint tables. */
|
|
21
31
|
type PublishedFactoConnectEnvironment = 'dev' | 'production';
|
|
22
32
|
type FactoConnectTransport = (input: string, init?: RequestInit) => Promise<Response>;
|
|
23
33
|
declare const FACTO_CONNECT_API_BASE_URLS: Readonly<Record<PublishedFactoConnectEnvironment, string>>;
|
|
24
34
|
declare const FACTO_CONNECT_HOSTED_URLS: Readonly<Record<PublishedFactoConnectEnvironment, string>>;
|
|
35
|
+
declare function factoConnectEnvironmentFromClientId(clientId: string): PublishedFactoConnectEnvironment | undefined;
|
|
25
36
|
interface FactoConnectServerOptions {
|
|
26
37
|
appId: string;
|
|
27
38
|
clientId: string;
|
|
28
39
|
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
|
-
*/
|
|
40
|
+
environment?: FactoConnectEnvironment;
|
|
58
41
|
apiBaseUrl?: string;
|
|
59
42
|
hostedConnectUrl?: string;
|
|
60
|
-
/** Injectable server-side transport. Defaults to `globalThis.fetch`. */
|
|
61
43
|
transport?: FactoConnectTransport;
|
|
62
|
-
/** Alias for `transport`, matching the public Dev SDK contract. */
|
|
63
44
|
fetch?: FactoConnectTransport;
|
|
64
|
-
/** Per-request deadline in milliseconds. Omit to leave deadline control to the caller transport. */
|
|
65
45
|
timeoutMs?: number;
|
|
66
|
-
/** Retry policy for safe GET requests and POST requests carrying an idempotency key. */
|
|
67
46
|
retry?: ServerRetryOptions;
|
|
68
|
-
/** Cancels in-flight requests and retry delays. */
|
|
69
47
|
signal?: AbortSignal;
|
|
70
48
|
}
|
|
71
49
|
interface HostedConnectUrlInput {
|
|
72
50
|
appId: string;
|
|
73
51
|
state: string;
|
|
74
52
|
nonce: string;
|
|
75
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
76
53
|
customerEmail?: string;
|
|
77
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
78
54
|
customerUsername?: string;
|
|
79
|
-
/** Hosted Connect origin for the target environment. Required: there is no implicit default. */
|
|
80
55
|
hostedConnectUrl: string;
|
|
56
|
+
merchantOrigin: string;
|
|
81
57
|
}
|
|
82
58
|
interface CreateHostedConnectUrlInput {
|
|
83
59
|
state: string;
|
|
84
60
|
nonce: string;
|
|
85
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
86
61
|
customerEmail?: string;
|
|
87
|
-
/** Display-only merchant identity for the shopper. Not used for authentication or exchange. */
|
|
88
62
|
customerUsername?: string;
|
|
89
63
|
hostedConnectUrl?: string;
|
|
64
|
+
merchantOrigin: string;
|
|
90
65
|
}
|
|
91
66
|
interface ExchangeLinkCodeInput {
|
|
92
67
|
code: string;
|
|
93
68
|
state: string;
|
|
94
69
|
nonce: string;
|
|
95
70
|
}
|
|
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
71
|
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
72
|
type PaymentCapability = PaymentCapabilityResponse;
|
|
114
73
|
|
|
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
74
|
interface PaymentCapabilityInputProperties {
|
|
121
|
-
/** GA shape: opaque user-link reference minted by the link-code exchange. */
|
|
122
75
|
userLinkRef?: PaymentCapabilityRequestProperties['userLinkRef'];
|
|
123
|
-
/** Legacy shape: Facto server wallet address of the linked user. */
|
|
124
76
|
factoServerWalletAddress?: PaymentCapabilityRequestProperties['facto_server_wallet_address'];
|
|
125
77
|
}
|
|
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
78
|
type PaymentCapabilityInput = PaymentCapabilityInputProperties & (Required<Pick<PaymentCapabilityInputProperties, 'factoServerWalletAddress'>> | Required<Pick<PaymentCapabilityInputProperties, 'userLinkRef'>>);
|
|
133
79
|
type PaymentOptionsInput = ({
|
|
134
80
|
userLinkRef: string;
|
|
@@ -137,8 +83,6 @@ type PaymentOptionsInput = ({
|
|
|
137
83
|
userLinkRef?: never;
|
|
138
84
|
grantRef: string;
|
|
139
85
|
}) & {
|
|
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
86
|
amount?: string;
|
|
143
87
|
assetSymbol?: string;
|
|
144
88
|
};
|
|
@@ -151,14 +95,7 @@ interface MerchantPaymentOption {
|
|
|
151
95
|
chainLabel: string;
|
|
152
96
|
protocolLabel: string;
|
|
153
97
|
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
98
|
spendMode: string;
|
|
161
|
-
/** How an accepted payment settles. Direct-only on the merchant surface. */
|
|
162
99
|
settlementPath: string;
|
|
163
100
|
blockingReason?: string;
|
|
164
101
|
}
|
|
@@ -205,12 +142,6 @@ interface MandateLimits {
|
|
|
205
142
|
interface CreateMandateAuthorizationSessionRequest {
|
|
206
143
|
appId: string;
|
|
207
144
|
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
145
|
customerEmail?: string;
|
|
215
146
|
customerUsername?: string;
|
|
216
147
|
requestedUseCases: MandateUseCase[];
|
|
@@ -224,9 +155,6 @@ interface MandateAuthorizationSession {
|
|
|
224
155
|
authorizationUrl: string;
|
|
225
156
|
status: MandateAuthorizationSessionStatus;
|
|
226
157
|
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
158
|
userLinkRef?: string;
|
|
231
159
|
expiresAt: string;
|
|
232
160
|
state: string;
|
|
@@ -268,30 +196,21 @@ interface MandatePayment {
|
|
|
268
196
|
currency: string;
|
|
269
197
|
useCase: MandateUseCase;
|
|
270
198
|
chargeId?: string;
|
|
271
|
-
/** On-chain settlement tx hash, present once the payment reaches a terminal status. */
|
|
272
199
|
txHash?: string;
|
|
273
200
|
declineReason?: MandateDeclineReason;
|
|
274
201
|
finalityEtaSeconds?: number;
|
|
275
|
-
/** Timestamp the payment reached a terminal status. */
|
|
276
202
|
terminalAt?: string;
|
|
277
203
|
createdAt: string;
|
|
278
204
|
updatedAt?: string;
|
|
279
205
|
}
|
|
280
206
|
type MandatePaymentStatusListener = (payment: MandatePayment) => void;
|
|
281
207
|
interface OnMandatePaymentStatusOptions {
|
|
282
|
-
/** Delay before the first poll and the base for backoff, in ms (default 1000). */
|
|
283
208
|
initialIntervalMs?: number;
|
|
284
|
-
/** Upper bound on the poll delay after backoff, in ms (default 8000). */
|
|
285
209
|
maxIntervalMs?: number;
|
|
286
|
-
/** Multiplier applied to the delay after each poll (default 1.5). */
|
|
287
210
|
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
211
|
timeoutMs?: number;
|
|
291
|
-
/** Cancels polling; the returned promise rejects with an AbortError. */
|
|
292
212
|
signal?: AbortSignal;
|
|
293
213
|
}
|
|
294
|
-
/** Cursor page envelope shared by every GA list endpoint. */
|
|
295
214
|
interface Page<T> {
|
|
296
215
|
data: T[];
|
|
297
216
|
hasMore: boolean;
|
|
@@ -314,7 +233,6 @@ type RefundReason = 'requested_by_customer' | 'duplicate' | 'fraudulent' | 'othe
|
|
|
314
233
|
type RefundStatus = 'pending' | 'succeeded' | 'failed';
|
|
315
234
|
interface CreateRefundInput {
|
|
316
235
|
paymentId: string;
|
|
317
|
-
/** Omit for a full refund of the remaining amount. */
|
|
318
236
|
amount?: string;
|
|
319
237
|
reason?: RefundReason;
|
|
320
238
|
merchantRefundRef?: string;
|
|
@@ -346,13 +264,11 @@ interface WebhookEndpoint {
|
|
|
346
264
|
createdAt: string;
|
|
347
265
|
}
|
|
348
266
|
interface WebhookEndpointWithSecret extends WebhookEndpoint {
|
|
349
|
-
/** Returned exactly once from create/rotate. Store server-side only. */
|
|
350
267
|
secret: string;
|
|
351
268
|
}
|
|
352
269
|
type DevCapabilityName = 'fixtures' | 'synthetic_identity' | 'faucet' | 'simulation' | 'money_loop' | 'webhook_test_delivery';
|
|
353
270
|
type DevCapabilityStatus = 'unavailable' | 'degraded' | 'ready';
|
|
354
271
|
type DevEvidenceLevel = 'contract' | 'implemented' | 'deployed' | 'verified';
|
|
355
|
-
/** Current public evidence projection for one Dev capability. */
|
|
356
272
|
interface DevCapability {
|
|
357
273
|
name: DevCapabilityName;
|
|
358
274
|
status: DevCapabilityStatus;
|
|
@@ -361,14 +277,12 @@ interface DevCapability {
|
|
|
361
277
|
verifiedAt?: string | null;
|
|
362
278
|
limits?: Record<string, string | number | boolean | null>;
|
|
363
279
|
}
|
|
364
|
-
/** Read-only Dev availability and evidence projection. */
|
|
365
280
|
interface DevCapabilities {
|
|
366
281
|
environment: 'dev';
|
|
367
282
|
contractVersion: '2026-07-09';
|
|
368
283
|
capabilities: DevCapability[];
|
|
369
284
|
checkedAt: string;
|
|
370
285
|
}
|
|
371
|
-
/** Dev endpoints accept USDC decimal strings only. */
|
|
372
286
|
interface DevMoney {
|
|
373
287
|
amount: string;
|
|
374
288
|
currency: 'USDC';
|
|
@@ -389,7 +303,6 @@ interface SimulateDevChargeInput {
|
|
|
389
303
|
merchantReference?: string;
|
|
390
304
|
idempotencyKey: string;
|
|
391
305
|
}
|
|
392
|
-
/** A Dev simulation is not a MerchantPayment and has no production settlement meaning. */
|
|
393
306
|
interface DevSimulation {
|
|
394
307
|
simulationId: string;
|
|
395
308
|
scenario: DevSimulationScenario;
|
|
@@ -420,71 +333,39 @@ interface WebhookTestDeliveryAccepted {
|
|
|
420
333
|
}
|
|
421
334
|
interface FactoConnectServerClient {
|
|
422
335
|
createHostedConnectUrl(input: CreateHostedConnectUrlInput): string;
|
|
423
|
-
/** GA operation name for exchanging a one-time user-link code. */
|
|
424
336
|
exchangeUserLinkCode(input: ExchangeLinkCodeInput): Promise<ExchangeLinkCodeResult>;
|
|
425
|
-
/** GA operation name for reading payment readiness. */
|
|
426
337
|
getPaymentReadiness(input: PaymentCapabilityInput): Promise<PaymentCapability>;
|
|
427
|
-
/** GA operation name for creating a payment authorization session. */
|
|
428
338
|
createAuthorizationSession(input: CreateMandateAuthorizationSessionInput): Promise<MandateAuthorizationSession>;
|
|
429
|
-
/** GA operation name for reading a payment authorization session. */
|
|
430
339
|
getAuthorizationSession(sessionId: string): Promise<MandateAuthorizationSession>;
|
|
431
|
-
/** GA operation name for reading one payment authorization. */
|
|
432
340
|
getPaymentAuthorization(authorizationId: string): Promise<MerchantMandate>;
|
|
433
|
-
/** GA operation name for creating an authorized merchant payment. */
|
|
434
341
|
createMerchantPayment(input: CreateMandatePaymentInput): Promise<MandatePayment>;
|
|
435
|
-
/** GA operation name for reading one merchant payment. */
|
|
436
342
|
getMerchantPayment(paymentId: string): Promise<MandatePayment>;
|
|
437
|
-
/** @deprecated Use `exchangeUserLinkCode`. */
|
|
438
343
|
exchangeLinkCode(input: ExchangeLinkCodeInput): Promise<ExchangeLinkCodeResult>;
|
|
439
|
-
/** @deprecated Use `getPaymentReadiness`. */
|
|
440
344
|
getPaymentCapability(input: PaymentCapabilityInput): Promise<PaymentCapability>;
|
|
441
345
|
createCheckoutSession(input: CreateCheckoutSessionInput): Promise<CheckoutSession>;
|
|
442
346
|
getCheckoutSession(id: string): Promise<CheckoutSessionStatus>;
|
|
443
|
-
/** @deprecated Use `createAuthorizationSession`. */
|
|
444
347
|
createMandateAuthorizationSession(input: CreateMandateAuthorizationSessionInput): Promise<MandateAuthorizationSession>;
|
|
445
|
-
/** @deprecated Use `getAuthorizationSession`. */
|
|
446
348
|
getMandateAuthorizationSession(sessionId: string): Promise<MandateAuthorizationSession>;
|
|
447
|
-
/** @deprecated Use `getPaymentAuthorization`. */
|
|
448
349
|
getMerchantMandate(mandateId: string): Promise<MerchantMandate>;
|
|
449
350
|
listPaymentOptions(input: PaymentOptionsInput): Promise<MerchantPaymentOptions>;
|
|
450
|
-
/** @deprecated Use `createMerchantPayment`. */
|
|
451
351
|
createMandatePayment(input: CreateMandatePaymentInput): Promise<MandatePayment>;
|
|
452
|
-
/** @deprecated Use `getMerchantPayment`. */
|
|
453
352
|
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
353
|
onStatus(paymentId: string, listener: MandatePaymentStatusListener, options?: OnMandatePaymentStatusOptions): Promise<MandatePayment>;
|
|
462
|
-
/** Revoke a user link the merchant no longer needs (GA-only). */
|
|
463
354
|
revokeUserLink(userLinkRef: string): Promise<void>;
|
|
464
|
-
/** List merchant payments (reconciliation source of truth). */
|
|
465
355
|
listMerchantPayments(filter?: MerchantPaymentListFilter): Promise<Page<MandatePayment>>;
|
|
466
|
-
/** List payment authorizations (mandates) for this app. */
|
|
467
356
|
listPaymentAuthorizations(filter?: PaymentAuthorizationListFilter): Promise<Page<MerchantMandate>>;
|
|
468
|
-
/** Create a refund against a succeeded payment (partial-capable). */
|
|
469
357
|
createRefund(input: CreateRefundInput): Promise<Refund>;
|
|
470
358
|
getRefund(refundId: string): Promise<Refund>;
|
|
471
359
|
listRefunds(filter?: RefundListFilter): Promise<Page<Refund>>;
|
|
472
|
-
/** Register a webhook endpoint. The signing secret is returned exactly once. */
|
|
473
360
|
createWebhookEndpoint(input: CreateWebhookEndpointInput): Promise<WebhookEndpointWithSecret>;
|
|
474
361
|
listWebhookEndpoints(): Promise<WebhookEndpoint[]>;
|
|
475
362
|
getWebhookEndpoint(webhookEndpointId: string): Promise<WebhookEndpoint>;
|
|
476
363
|
deleteWebhookEndpoint(webhookEndpointId: string): Promise<void>;
|
|
477
|
-
/** Rotate the signing secret; the previous secret verifies for 24h. */
|
|
478
364
|
rotateWebhookSecret(webhookEndpointId: string): Promise<WebhookEndpointWithSecret>;
|
|
479
|
-
/** Read the Dev capability/evidence projection. Dev environment only. */
|
|
480
365
|
getDevCapabilities(): Promise<DevCapabilities>;
|
|
481
|
-
/** Request test-only USDC for an app-owned synthetic linked user. Dev only. */
|
|
482
366
|
fundDevUser(input: FundDevUserInput): Promise<DevFaucetTransfer>;
|
|
483
|
-
/** Create a Dev simulation, distinct from a MerchantPayment. Dev only. */
|
|
484
367
|
simulateDevCharge(input: SimulateDevChargeInput): Promise<DevSimulation>;
|
|
485
|
-
/** Read an app-owned Dev simulation. Dev only. */
|
|
486
368
|
getDevSimulation(simulationId: string): Promise<DevSimulation>;
|
|
487
|
-
/** Queue a signed no-business-state `test.ping`. Dev environment only. */
|
|
488
369
|
sendWebhookTestDelivery(input: SendWebhookTestDeliveryInput): Promise<WebhookTestDeliveryAccepted>;
|
|
489
370
|
}
|
|
490
371
|
type FactoConnectServerErrorCode = 'FACTO_CONFIG_INVALID' | 'FACTO_ENGINE_REQUEST_FAILED' | 'FACTO_ENGINE_RESPONSE_INVALID' | 'FACTO_REQUEST_ABORTED' | 'FACTO_STATUS_POLL_ABORTED';
|
|
@@ -493,7 +374,6 @@ declare class FactoConnectServerError extends Error {
|
|
|
493
374
|
readonly retryable: boolean;
|
|
494
375
|
readonly status?: number;
|
|
495
376
|
readonly details?: unknown;
|
|
496
|
-
/** Seconds from the `Retry-After` response header on a 429, when present. */
|
|
497
377
|
readonly retryAfterSeconds?: number;
|
|
498
378
|
constructor(code: FactoConnectServerErrorCode, message: string, options: {
|
|
499
379
|
retryable: boolean;
|
|
@@ -502,68 +382,25 @@ declare class FactoConnectServerError extends Error {
|
|
|
502
382
|
retryAfterSeconds?: number;
|
|
503
383
|
});
|
|
504
384
|
}
|
|
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
385
|
interface ServerRetryOptions {
|
|
510
|
-
/** Max retry attempts after the first try (default 2). */
|
|
511
386
|
maxRetries?: number;
|
|
512
|
-
/** Base backoff in ms for the exponential fallback (default 200). */
|
|
513
387
|
baseDelayMs?: number;
|
|
514
|
-
/** Backoff cap in ms (default 5000). */
|
|
515
388
|
maxDelayMs?: number;
|
|
516
|
-
/** Honor the server's `Retry-After` when present (default true). */
|
|
517
389
|
respectRetryAfter?: boolean;
|
|
518
|
-
/** Abort waiting/retrying. */
|
|
519
390
|
signal?: AbortSignal;
|
|
520
|
-
/** Invoked before each retry sleep. */
|
|
521
391
|
onRetry?: (info: {
|
|
522
392
|
attempt: number;
|
|
523
393
|
error: FactoConnectServerError;
|
|
524
394
|
delayMs: number;
|
|
525
395
|
}) => void;
|
|
526
|
-
/** Injectable delay (tests). Defaults to a `setTimeout` sleep that respects `signal`. */
|
|
527
396
|
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
528
397
|
}
|
|
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
398
|
declare function withServerRetry<T>(fn: () => Promise<T>, options?: ServerRetryOptions): Promise<T>;
|
|
543
399
|
declare function buildHostedConnectUrl(input: HostedConnectUrlInput): string;
|
|
544
400
|
declare function createFactoConnectServer(options: FactoConnectServerOptions): FactoConnectServerClient;
|
|
545
|
-
/** Whether a mandate payment status is terminal (no further transitions). */
|
|
546
401
|
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
402
|
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
403
|
declare function verifyWebhookSignature(rawBody: string | Uint8Array, header: string, secret: string, toleranceSeconds?: number): boolean;
|
|
566
|
-
/** A public Ed25519 JWK (OKP) as served by the Facto connect-hint JWKS. */
|
|
567
404
|
interface FactoCardProgramConnectJwk {
|
|
568
405
|
kty: string;
|
|
569
406
|
crv: string;
|
|
@@ -572,44 +409,22 @@ interface FactoCardProgramConnectJwk {
|
|
|
572
409
|
alg?: string;
|
|
573
410
|
use?: string;
|
|
574
411
|
}
|
|
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
412
|
interface FactoCardProgramConnectJwks {
|
|
580
413
|
keys: FactoCardProgramConnectJwk[];
|
|
581
414
|
}
|
|
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
415
|
type FactoCardProgramConnectJwksInput = FactoCardProgramConnectJwks | string | (() => FactoCardProgramConnectJwks | Promise<FactoCardProgramConnectJwks>);
|
|
587
416
|
interface VerifyFactoCardProgramConnectHintInput {
|
|
588
|
-
/** The compact EdDSA JWS the Facto user handed the partner. */
|
|
589
417
|
connectHint: string;
|
|
590
|
-
/** The Facto JWKS: an in-memory `{ keys }` set, a JWKS URL to fetch, or a resolver. */
|
|
591
418
|
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
419
|
audience: string;
|
|
598
|
-
/** Expected issuer. Defaults to `'facto'`. */
|
|
599
420
|
issuer?: string;
|
|
600
|
-
/** Verification clock (unix milliseconds or `Date`). Defaults to `Date.now()`. */
|
|
601
421
|
now?: number | Date;
|
|
602
|
-
/** Clock-skew tolerance in seconds applied to the expiry check. Defaults to `0`. */
|
|
603
422
|
clockToleranceSeconds?: number;
|
|
604
423
|
}
|
|
605
424
|
interface FactoCardProgramConnectHint {
|
|
606
|
-
/** The opaque program the hint is scoped to (`cprog_...`). */
|
|
607
425
|
programRef: string;
|
|
608
|
-
/** Pairwise-opaque subject (`facto-user:<hex>`); NEVER the raw Facto user id. */
|
|
609
426
|
pairwiseSubject: string;
|
|
610
|
-
/** Single-use nonce; the caller MUST enforce single-use against its own store. */
|
|
611
427
|
nonce: string;
|
|
612
|
-
/** Absolute expiry (`exp`) as an RFC 3339 / ISO-8601 timestamp. */
|
|
613
428
|
expiresAt: string;
|
|
614
429
|
}
|
|
615
430
|
type FactoConnectHintErrorCode = 'FACTO_HINT_INPUT_INVALID' | 'FACTO_HINT_JWKS_INVALID' | 'FACTO_HINT_MALFORMED' | 'FACTO_HINT_UNSUPPORTED_ALG' | 'FACTO_HINT_SIGNATURE_INVALID' | 'FACTO_HINT_ISSUER_MISMATCH' | 'FACTO_HINT_AUDIENCE_MISMATCH' | 'FACTO_HINT_EXPIRED' | 'FACTO_HINT_CLAIMS_INVALID';
|
|
@@ -620,15 +435,6 @@ declare class FactoConnectHintError extends Error {
|
|
|
620
435
|
details?: unknown;
|
|
621
436
|
});
|
|
622
437
|
}
|
|
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
438
|
declare function verifyFactoCardProgramConnectHint(input: VerifyFactoCardProgramConnectHintInput): Promise<FactoCardProgramConnectHint>;
|
|
633
439
|
|
|
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 };
|
|
440
|
+
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, MandateAuthorizationSessionStatus as MandateAuthorizationStatus, MandateDeclineReason, MandateLimitPeriod, type MandateLimits, type MandatePayment, MandatePaymentStatus, type MandatePaymentStatusListener, MandateStatus, MandateUseCase, type MerchantMandate, type MerchantPaymentListFilter, type MerchantPaymentOption, type MerchantPaymentOptions, type MerchantPaymentPathProjection, type OnMandatePaymentStatusOptions, PSP_CAPABILITY_TEMPLATES, PSP_CREDENTIAL_KEYSPACE, PSP_CREDENTIAL_SCOPES, PSP_PARTNER_ROLE_TYPE, type Page, type PaymentAuthorizationListFilter, type PaymentCapability, type PaymentCapabilityInput, type PaymentOptionsInput, type PspCapabilityTemplate, 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, carriesMoneyVerb, createFactoConnectServer, createFactoConnectServer as default, factoConnectEnvironmentFromClientId, isTerminalMandatePaymentStatus, signWebhookPayload, subMerchantOf, verifyFactoCardProgramConnectHint, verifyWebhookSignature, withServerRetry, withSubMerchant };
|