hs-playlib 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/http_client.d.ts +5 -13
- package/dist/src/http_client.js +9 -13
- package/dist/src/index.d.ts +2 -180
- package/dist/src/index.js +6 -93
- package/dist/src/payments/_generated_connector_client_flows.d.ts +43 -9
- package/dist/src/payments/_generated_connector_client_flows.js +78 -16
- package/dist/src/payments/_generated_flows.js +44 -7
- package/dist/src/payments/_generated_uniffi_client_flows.d.ts +54 -12
- package/dist/src/payments/_generated_uniffi_client_flows.js +108 -24
- package/dist/src/payments/connector_client.d.ts +19 -15
- package/dist/src/payments/connector_client.js +64 -39
- package/dist/src/payments/generated/libconnector_service_ffi.dylib +0 -0
- package/dist/src/payments/generated/proto.d.ts +22069 -21901
- package/dist/src/payments/generated/proto.js +76914 -76263
- package/dist/src/payments/uniffi_client.d.ts +8 -2
- package/dist/src/payments/uniffi_client.js +32 -37
- package/package.json +2 -14
|
@@ -3,24 +3,61 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
5
|
const FLOWS = {
|
|
6
|
+
// authenticate: PaymentMethodAuthenticationService.Authenticate — Execute 3DS challenge or frictionless verification. Authenticates customer via bank challenge or behind-the-scenes verification for fraud prevention.
|
|
7
|
+
authenticate : { request: "PaymentMethodAuthenticationServiceAuthenticateRequest", response: "PaymentMethodAuthenticationServiceAuthenticateResponse" },
|
|
8
|
+
|
|
6
9
|
// authorize: PaymentService.Authorize — Authorize a payment amount on a payment method. This reserves funds without capturing them, essential for verifying availability before finalizing.
|
|
7
|
-
authorize
|
|
10
|
+
authorize : { request: "PaymentServiceAuthorizeRequest", response: "PaymentServiceAuthorizeResponse" },
|
|
8
11
|
|
|
9
12
|
// capture: PaymentService.Capture — Finalize an authorized payment transaction. Transfers reserved funds from customer to merchant account, completing the payment lifecycle.
|
|
10
|
-
capture
|
|
13
|
+
capture : { request: "PaymentServiceCaptureRequest", response: "PaymentServiceCaptureResponse" },
|
|
14
|
+
|
|
15
|
+
// charge: RecurringPaymentService.Charge — Charge using an existing stored recurring payment instruction. Processes repeat payments for subscriptions or recurring billing without collecting payment details.
|
|
16
|
+
charge : { request: "RecurringPaymentServiceChargeRequest", response: "RecurringPaymentServiceChargeResponse" },
|
|
17
|
+
|
|
18
|
+
// create: CustomerService.Create — Create customer record in the payment processor system. Stores customer details for future payment operations without re-sending personal information.
|
|
19
|
+
create : { request: "CustomerServiceCreateRequest", response: "CustomerServiceCreateResponse" },
|
|
11
20
|
|
|
12
21
|
// create_access_token: MerchantAuthenticationService.CreateAccessToken — Generate short-lived connector authentication token. Provides secure credentials for connector API access without storing secrets client-side.
|
|
13
|
-
create_access_token
|
|
22
|
+
create_access_token : { request: "MerchantAuthenticationServiceCreateAccessTokenRequest", response: "MerchantAuthenticationServiceCreateAccessTokenResponse" },
|
|
23
|
+
|
|
24
|
+
// create_order: PaymentService.CreateOrder — Initialize an order in the payment processor system. Sets up payment context before customer enters card details for improved authorization rates.
|
|
25
|
+
create_order : { request: "PaymentServiceCreateOrderRequest", response: "PaymentServiceCreateOrderResponse" },
|
|
26
|
+
|
|
27
|
+
// create_session_token: MerchantAuthenticationService.CreateSessionToken — Create session token for payment processing. Maintains session state across multiple payment operations for improved security and tracking.
|
|
28
|
+
create_session_token : { request: "MerchantAuthenticationServiceCreateSessionTokenRequest", response: "MerchantAuthenticationServiceCreateSessionTokenResponse" },
|
|
14
29
|
|
|
15
30
|
// get: PaymentService.Get — Retrieve current payment status from the payment processor. Enables synchronization between your system and payment processors for accurate state tracking.
|
|
16
|
-
get
|
|
31
|
+
get : { request: "PaymentServiceGetRequest", response: "PaymentServiceGetResponse" },
|
|
32
|
+
|
|
33
|
+
// post_authenticate: PaymentMethodAuthenticationService.PostAuthenticate — Validate authentication results with the issuing bank. Processes bank's authentication decision to determine if payment can proceed.
|
|
34
|
+
post_authenticate : { request: "PaymentMethodAuthenticationServicePostAuthenticateRequest", response: "PaymentMethodAuthenticationServicePostAuthenticateResponse" },
|
|
35
|
+
|
|
36
|
+
// pre_authenticate: PaymentMethodAuthenticationService.PreAuthenticate — Initiate 3DS flow before payment authorization. Collects device data and prepares authentication context for frictionless or challenge-based verification.
|
|
37
|
+
pre_authenticate : { request: "PaymentMethodAuthenticationServicePreAuthenticateRequest", response: "PaymentMethodAuthenticationServicePreAuthenticateResponse" },
|
|
17
38
|
|
|
18
39
|
// refund: PaymentService.Refund — Initiate a refund to customer's payment method. Returns funds for returns, cancellations, or service adjustments after original payment.
|
|
19
|
-
refund
|
|
40
|
+
refund : { request: "PaymentServiceRefundRequest", response: "RefundResponse" },
|
|
41
|
+
|
|
42
|
+
// reverse: PaymentService.Reverse — Reverse a captured payment before settlement. Recovers funds after capture but before bank settlement, used for corrections or cancellations.
|
|
43
|
+
reverse : { request: "PaymentServiceReverseRequest", response: "PaymentServiceReverseResponse" },
|
|
44
|
+
|
|
45
|
+
// setup_recurring: PaymentService.SetupRecurring — Setup a recurring payment instruction for future payments/ debits. This could be for SaaS subscriptions, monthly bill payments, insurance payments and similar use cases.
|
|
46
|
+
setup_recurring : { request: "PaymentServiceSetupRecurringRequest", response: "PaymentServiceSetupRecurringResponse" },
|
|
47
|
+
|
|
48
|
+
// tokenize: PaymentMethodService.Tokenize — Tokenize payment method for secure storage. Replaces raw card details with secure token for one-click payments and recurring billing.
|
|
49
|
+
tokenize : { request: "PaymentMethodServiceTokenizeRequest", response: "PaymentMethodServiceTokenizeResponse" },
|
|
20
50
|
|
|
21
51
|
// void: PaymentService.Void — Cancel an authorized payment before capture. Releases held funds back to customer, typically used when orders are cancelled or abandoned.
|
|
22
|
-
void
|
|
52
|
+
void : { request: "PaymentServiceVoidRequest", response: "PaymentServiceVoidResponse" },
|
|
53
|
+
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Single-step flows: no HTTP round-trip.
|
|
57
|
+
const SINGLE_FLOWS = {
|
|
58
|
+
// handle_event: EventService.HandleEvent — Process webhook notifications from connectors. Translates connector events into standardized responses for asynchronous payment state updates.
|
|
59
|
+
handle_event : { request: "EventServiceHandleRequest", response: "EventServiceHandleResponse" },
|
|
23
60
|
|
|
24
61
|
};
|
|
25
62
|
|
|
26
|
-
module.exports = { FLOWS };
|
|
63
|
+
module.exports = { FLOWS, SINGLE_FLOWS };
|
|
@@ -1,27 +1,69 @@
|
|
|
1
1
|
import { UniffiClient as _UniffiClientBase } from "./uniffi_client";
|
|
2
2
|
export declare class UniffiClient extends _UniffiClientBase {
|
|
3
|
+
/** Build connector HTTP request for authenticate flow. */
|
|
4
|
+
authenticateReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
5
|
+
/** Parse connector HTTP response for authenticate flow. */
|
|
6
|
+
authenticateRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
3
7
|
/** Build connector HTTP request for authorize flow. */
|
|
4
|
-
authorizeReq(requestBytes: Buffer | Uint8Array,
|
|
8
|
+
authorizeReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
5
9
|
/** Parse connector HTTP response for authorize flow. */
|
|
6
|
-
authorizeRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array,
|
|
10
|
+
authorizeRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
7
11
|
/** Build connector HTTP request for capture flow. */
|
|
8
|
-
captureReq(requestBytes: Buffer | Uint8Array,
|
|
12
|
+
captureReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
9
13
|
/** Parse connector HTTP response for capture flow. */
|
|
10
|
-
captureRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array,
|
|
14
|
+
captureRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
15
|
+
/** Build connector HTTP request for charge flow. */
|
|
16
|
+
chargeReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
17
|
+
/** Parse connector HTTP response for charge flow. */
|
|
18
|
+
chargeRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
19
|
+
/** Build connector HTTP request for create flow. */
|
|
20
|
+
createReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
21
|
+
/** Parse connector HTTP response for create flow. */
|
|
22
|
+
createRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
11
23
|
/** Build connector HTTP request for create_access_token flow. */
|
|
12
|
-
createAccessTokenReq(requestBytes: Buffer | Uint8Array,
|
|
24
|
+
createAccessTokenReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
13
25
|
/** Parse connector HTTP response for create_access_token flow. */
|
|
14
|
-
createAccessTokenRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array,
|
|
26
|
+
createAccessTokenRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
27
|
+
/** Build connector HTTP request for create_order flow. */
|
|
28
|
+
createOrderReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
29
|
+
/** Parse connector HTTP response for create_order flow. */
|
|
30
|
+
createOrderRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
31
|
+
/** Build connector HTTP request for create_session_token flow. */
|
|
32
|
+
createSessionTokenReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
33
|
+
/** Parse connector HTTP response for create_session_token flow. */
|
|
34
|
+
createSessionTokenRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
15
35
|
/** Build connector HTTP request for get flow. */
|
|
16
|
-
getReq(requestBytes: Buffer | Uint8Array,
|
|
36
|
+
getReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
17
37
|
/** Parse connector HTTP response for get flow. */
|
|
18
|
-
getRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array,
|
|
38
|
+
getRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
39
|
+
/** Build connector HTTP request for post_authenticate flow. */
|
|
40
|
+
postAuthenticateReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
41
|
+
/** Parse connector HTTP response for post_authenticate flow. */
|
|
42
|
+
postAuthenticateRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
43
|
+
/** Build connector HTTP request for pre_authenticate flow. */
|
|
44
|
+
preAuthenticateReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
45
|
+
/** Parse connector HTTP response for pre_authenticate flow. */
|
|
46
|
+
preAuthenticateRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
19
47
|
/** Build connector HTTP request for refund flow. */
|
|
20
|
-
refundReq(requestBytes: Buffer | Uint8Array,
|
|
48
|
+
refundReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
21
49
|
/** Parse connector HTTP response for refund flow. */
|
|
22
|
-
refundRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array,
|
|
50
|
+
refundRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
51
|
+
/** Build connector HTTP request for reverse flow. */
|
|
52
|
+
reverseReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
53
|
+
/** Parse connector HTTP response for reverse flow. */
|
|
54
|
+
reverseRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
55
|
+
/** Build connector HTTP request for setup_recurring flow. */
|
|
56
|
+
setupRecurringReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
57
|
+
/** Parse connector HTTP response for setup_recurring flow. */
|
|
58
|
+
setupRecurringRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
59
|
+
/** Build connector HTTP request for tokenize flow. */
|
|
60
|
+
tokenizeReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
61
|
+
/** Parse connector HTTP response for tokenize flow. */
|
|
62
|
+
tokenizeRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
23
63
|
/** Build connector HTTP request for void flow. */
|
|
24
|
-
voidReq(requestBytes: Buffer | Uint8Array,
|
|
64
|
+
voidReq(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
25
65
|
/** Parse connector HTTP response for void flow. */
|
|
26
|
-
voidRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array,
|
|
66
|
+
voidRes(responseBytes: Buffer | Uint8Array, requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
67
|
+
/** Direct single-step transform for handle_event (no HTTP round-trip). */
|
|
68
|
+
handleEventDirect(requestBytes: Buffer | Uint8Array, optionsBytes: Buffer | Uint8Array): Buffer;
|
|
27
69
|
}
|
|
@@ -5,53 +5,137 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.UniffiClient = void 0;
|
|
6
6
|
const uniffi_client_1 = require("./uniffi_client");
|
|
7
7
|
class UniffiClient extends uniffi_client_1.UniffiClient {
|
|
8
|
+
/** Build connector HTTP request for authenticate flow. */
|
|
9
|
+
authenticateReq(requestBytes, optionsBytes) {
|
|
10
|
+
return this.callReq('authenticate', requestBytes, optionsBytes);
|
|
11
|
+
}
|
|
12
|
+
/** Parse connector HTTP response for authenticate flow. */
|
|
13
|
+
authenticateRes(responseBytes, requestBytes, optionsBytes) {
|
|
14
|
+
return this.callRes('authenticate', responseBytes, requestBytes, optionsBytes);
|
|
15
|
+
}
|
|
8
16
|
/** Build connector HTTP request for authorize flow. */
|
|
9
|
-
authorizeReq(requestBytes,
|
|
10
|
-
return this.callReq('authorize', requestBytes,
|
|
17
|
+
authorizeReq(requestBytes, optionsBytes) {
|
|
18
|
+
return this.callReq('authorize', requestBytes, optionsBytes);
|
|
11
19
|
}
|
|
12
20
|
/** Parse connector HTTP response for authorize flow. */
|
|
13
|
-
authorizeRes(responseBytes, requestBytes,
|
|
14
|
-
return this.callRes('authorize', responseBytes, requestBytes,
|
|
21
|
+
authorizeRes(responseBytes, requestBytes, optionsBytes) {
|
|
22
|
+
return this.callRes('authorize', responseBytes, requestBytes, optionsBytes);
|
|
15
23
|
}
|
|
16
24
|
/** Build connector HTTP request for capture flow. */
|
|
17
|
-
captureReq(requestBytes,
|
|
18
|
-
return this.callReq('capture', requestBytes,
|
|
25
|
+
captureReq(requestBytes, optionsBytes) {
|
|
26
|
+
return this.callReq('capture', requestBytes, optionsBytes);
|
|
19
27
|
}
|
|
20
28
|
/** Parse connector HTTP response for capture flow. */
|
|
21
|
-
captureRes(responseBytes, requestBytes,
|
|
22
|
-
return this.callRes('capture', responseBytes, requestBytes,
|
|
29
|
+
captureRes(responseBytes, requestBytes, optionsBytes) {
|
|
30
|
+
return this.callRes('capture', responseBytes, requestBytes, optionsBytes);
|
|
31
|
+
}
|
|
32
|
+
/** Build connector HTTP request for charge flow. */
|
|
33
|
+
chargeReq(requestBytes, optionsBytes) {
|
|
34
|
+
return this.callReq('charge', requestBytes, optionsBytes);
|
|
35
|
+
}
|
|
36
|
+
/** Parse connector HTTP response for charge flow. */
|
|
37
|
+
chargeRes(responseBytes, requestBytes, optionsBytes) {
|
|
38
|
+
return this.callRes('charge', responseBytes, requestBytes, optionsBytes);
|
|
39
|
+
}
|
|
40
|
+
/** Build connector HTTP request for create flow. */
|
|
41
|
+
createReq(requestBytes, optionsBytes) {
|
|
42
|
+
return this.callReq('create', requestBytes, optionsBytes);
|
|
43
|
+
}
|
|
44
|
+
/** Parse connector HTTP response for create flow. */
|
|
45
|
+
createRes(responseBytes, requestBytes, optionsBytes) {
|
|
46
|
+
return this.callRes('create', responseBytes, requestBytes, optionsBytes);
|
|
23
47
|
}
|
|
24
48
|
/** Build connector HTTP request for create_access_token flow. */
|
|
25
|
-
createAccessTokenReq(requestBytes,
|
|
26
|
-
return this.callReq('create_access_token', requestBytes,
|
|
49
|
+
createAccessTokenReq(requestBytes, optionsBytes) {
|
|
50
|
+
return this.callReq('create_access_token', requestBytes, optionsBytes);
|
|
27
51
|
}
|
|
28
52
|
/** Parse connector HTTP response for create_access_token flow. */
|
|
29
|
-
createAccessTokenRes(responseBytes, requestBytes,
|
|
30
|
-
return this.callRes('create_access_token', responseBytes, requestBytes,
|
|
53
|
+
createAccessTokenRes(responseBytes, requestBytes, optionsBytes) {
|
|
54
|
+
return this.callRes('create_access_token', responseBytes, requestBytes, optionsBytes);
|
|
55
|
+
}
|
|
56
|
+
/** Build connector HTTP request for create_order flow. */
|
|
57
|
+
createOrderReq(requestBytes, optionsBytes) {
|
|
58
|
+
return this.callReq('create_order', requestBytes, optionsBytes);
|
|
59
|
+
}
|
|
60
|
+
/** Parse connector HTTP response for create_order flow. */
|
|
61
|
+
createOrderRes(responseBytes, requestBytes, optionsBytes) {
|
|
62
|
+
return this.callRes('create_order', responseBytes, requestBytes, optionsBytes);
|
|
63
|
+
}
|
|
64
|
+
/** Build connector HTTP request for create_session_token flow. */
|
|
65
|
+
createSessionTokenReq(requestBytes, optionsBytes) {
|
|
66
|
+
return this.callReq('create_session_token', requestBytes, optionsBytes);
|
|
67
|
+
}
|
|
68
|
+
/** Parse connector HTTP response for create_session_token flow. */
|
|
69
|
+
createSessionTokenRes(responseBytes, requestBytes, optionsBytes) {
|
|
70
|
+
return this.callRes('create_session_token', responseBytes, requestBytes, optionsBytes);
|
|
31
71
|
}
|
|
32
72
|
/** Build connector HTTP request for get flow. */
|
|
33
|
-
getReq(requestBytes,
|
|
34
|
-
return this.callReq('get', requestBytes,
|
|
73
|
+
getReq(requestBytes, optionsBytes) {
|
|
74
|
+
return this.callReq('get', requestBytes, optionsBytes);
|
|
35
75
|
}
|
|
36
76
|
/** Parse connector HTTP response for get flow. */
|
|
37
|
-
getRes(responseBytes, requestBytes,
|
|
38
|
-
return this.callRes('get', responseBytes, requestBytes,
|
|
77
|
+
getRes(responseBytes, requestBytes, optionsBytes) {
|
|
78
|
+
return this.callRes('get', responseBytes, requestBytes, optionsBytes);
|
|
79
|
+
}
|
|
80
|
+
/** Build connector HTTP request for post_authenticate flow. */
|
|
81
|
+
postAuthenticateReq(requestBytes, optionsBytes) {
|
|
82
|
+
return this.callReq('post_authenticate', requestBytes, optionsBytes);
|
|
83
|
+
}
|
|
84
|
+
/** Parse connector HTTP response for post_authenticate flow. */
|
|
85
|
+
postAuthenticateRes(responseBytes, requestBytes, optionsBytes) {
|
|
86
|
+
return this.callRes('post_authenticate', responseBytes, requestBytes, optionsBytes);
|
|
87
|
+
}
|
|
88
|
+
/** Build connector HTTP request for pre_authenticate flow. */
|
|
89
|
+
preAuthenticateReq(requestBytes, optionsBytes) {
|
|
90
|
+
return this.callReq('pre_authenticate', requestBytes, optionsBytes);
|
|
91
|
+
}
|
|
92
|
+
/** Parse connector HTTP response for pre_authenticate flow. */
|
|
93
|
+
preAuthenticateRes(responseBytes, requestBytes, optionsBytes) {
|
|
94
|
+
return this.callRes('pre_authenticate', responseBytes, requestBytes, optionsBytes);
|
|
39
95
|
}
|
|
40
96
|
/** Build connector HTTP request for refund flow. */
|
|
41
|
-
refundReq(requestBytes,
|
|
42
|
-
return this.callReq('refund', requestBytes,
|
|
97
|
+
refundReq(requestBytes, optionsBytes) {
|
|
98
|
+
return this.callReq('refund', requestBytes, optionsBytes);
|
|
43
99
|
}
|
|
44
100
|
/** Parse connector HTTP response for refund flow. */
|
|
45
|
-
refundRes(responseBytes, requestBytes,
|
|
46
|
-
return this.callRes('refund', responseBytes, requestBytes,
|
|
101
|
+
refundRes(responseBytes, requestBytes, optionsBytes) {
|
|
102
|
+
return this.callRes('refund', responseBytes, requestBytes, optionsBytes);
|
|
103
|
+
}
|
|
104
|
+
/** Build connector HTTP request for reverse flow. */
|
|
105
|
+
reverseReq(requestBytes, optionsBytes) {
|
|
106
|
+
return this.callReq('reverse', requestBytes, optionsBytes);
|
|
107
|
+
}
|
|
108
|
+
/** Parse connector HTTP response for reverse flow. */
|
|
109
|
+
reverseRes(responseBytes, requestBytes, optionsBytes) {
|
|
110
|
+
return this.callRes('reverse', responseBytes, requestBytes, optionsBytes);
|
|
111
|
+
}
|
|
112
|
+
/** Build connector HTTP request for setup_recurring flow. */
|
|
113
|
+
setupRecurringReq(requestBytes, optionsBytes) {
|
|
114
|
+
return this.callReq('setup_recurring', requestBytes, optionsBytes);
|
|
115
|
+
}
|
|
116
|
+
/** Parse connector HTTP response for setup_recurring flow. */
|
|
117
|
+
setupRecurringRes(responseBytes, requestBytes, optionsBytes) {
|
|
118
|
+
return this.callRes('setup_recurring', responseBytes, requestBytes, optionsBytes);
|
|
119
|
+
}
|
|
120
|
+
/** Build connector HTTP request for tokenize flow. */
|
|
121
|
+
tokenizeReq(requestBytes, optionsBytes) {
|
|
122
|
+
return this.callReq('tokenize', requestBytes, optionsBytes);
|
|
123
|
+
}
|
|
124
|
+
/** Parse connector HTTP response for tokenize flow. */
|
|
125
|
+
tokenizeRes(responseBytes, requestBytes, optionsBytes) {
|
|
126
|
+
return this.callRes('tokenize', responseBytes, requestBytes, optionsBytes);
|
|
47
127
|
}
|
|
48
128
|
/** Build connector HTTP request for void flow. */
|
|
49
|
-
voidReq(requestBytes,
|
|
50
|
-
return this.callReq('void', requestBytes,
|
|
129
|
+
voidReq(requestBytes, optionsBytes) {
|
|
130
|
+
return this.callReq('void', requestBytes, optionsBytes);
|
|
51
131
|
}
|
|
52
132
|
/** Parse connector HTTP response for void flow. */
|
|
53
|
-
voidRes(responseBytes, requestBytes,
|
|
54
|
-
return this.callRes('void', responseBytes, requestBytes,
|
|
133
|
+
voidRes(responseBytes, requestBytes, optionsBytes) {
|
|
134
|
+
return this.callRes('void', responseBytes, requestBytes, optionsBytes);
|
|
135
|
+
}
|
|
136
|
+
/** Direct single-step transform for handle_event (no HTTP round-trip). */
|
|
137
|
+
handleEventDirect(requestBytes, optionsBytes) {
|
|
138
|
+
return this.callDirect('handle_event', requestBytes, optionsBytes);
|
|
55
139
|
}
|
|
56
140
|
}
|
|
57
141
|
exports.UniffiClient = UniffiClient;
|
|
@@ -9,33 +9,37 @@
|
|
|
9
9
|
* 5. Deserialize protobuf response from bytes
|
|
10
10
|
*
|
|
11
11
|
* Flow methods (authorize, capture, void, refund, …) are in _generated_connector_client_flows.ts.
|
|
12
|
-
* To add a new flow:
|
|
12
|
+
* To add a new flow: edit sdk/flows.yaml and run `make codegen`.
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { types } from "./generated/proto";
|
|
15
15
|
export declare class ConnectorClient {
|
|
16
16
|
private uniffi;
|
|
17
|
-
private
|
|
17
|
+
private config;
|
|
18
|
+
private defaults;
|
|
18
19
|
private dispatcher;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Initialize the client with mandatory config and optional request defaults.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Immutable connector identity and environment (Connector, Auth, Environment).
|
|
24
|
+
* @param defaults - Optional per-request defaults (Http, Vault).
|
|
25
|
+
* @param libPath - optional path to the UniFFI shared library.
|
|
22
26
|
*/
|
|
23
|
-
constructor(
|
|
27
|
+
constructor(config: types.IConnectorConfig, defaults?: types.IRequestConfig, libPath?: string);
|
|
24
28
|
/**
|
|
25
|
-
*
|
|
29
|
+
* Merges request-level options with client defaults. Environment comes from config (immutable).
|
|
26
30
|
*/
|
|
27
|
-
private
|
|
31
|
+
private _resolveConfig;
|
|
28
32
|
/**
|
|
29
33
|
* Execute a full round-trip for any registered payment flow.
|
|
30
34
|
*
|
|
31
|
-
* Looks up the request/response protobuf type names from FLOWS, encodes the
|
|
32
|
-
* request, calls callReq → HTTP → callRes via the generic FFI dispatcher,
|
|
33
|
-
* then decodes and returns the response.
|
|
34
|
-
*
|
|
35
35
|
* @param flow - Flow name matching the FFI transformer prefix (e.g. "authorize").
|
|
36
36
|
* @param requestMsg - Protobuf request message object.
|
|
37
|
-
* @param
|
|
38
|
-
|
|
37
|
+
* @param options - Optional ConfigOptions override (Environment, Http).
|
|
38
|
+
*/
|
|
39
|
+
_executeFlow(flow: string, requestMsg: object, options?: types.IRequestConfig | null, reqTypeName?: string, resTypeName?: string): Promise<unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Execute a single-step flow directly via FFI (no HTTP round-trip).
|
|
42
|
+
* Used for inbound flows like webhook processing where the connector sends data to us.
|
|
39
43
|
*/
|
|
40
|
-
|
|
44
|
+
_executeDirect(flow: string, requestMsg: object, options?: types.IRequestConfig | null, reqTypeName?: string, resTypeName?: string): Promise<unknown>;
|
|
41
45
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 5. Deserialize protobuf response from bytes
|
|
11
11
|
*
|
|
12
12
|
* Flow methods (authorize, capture, void, refund, …) are in _generated_connector_client_flows.ts.
|
|
13
|
-
* To add a new flow:
|
|
13
|
+
* To add a new flow: edit sdk/flows.yaml and run `make codegen`.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.ConnectorClient = void 0;
|
|
@@ -18,65 +18,71 @@ const uniffi_client_1 = require("./uniffi_client");
|
|
|
18
18
|
const http_client_1 = require("../http_client");
|
|
19
19
|
// @ts-ignore - protobuf generated files might not have types yet
|
|
20
20
|
const proto_1 = require("./generated/proto");
|
|
21
|
-
const v2 = proto_1.
|
|
21
|
+
const v2 = proto_1.types;
|
|
22
22
|
class ConnectorClient {
|
|
23
23
|
uniffi;
|
|
24
|
-
|
|
24
|
+
config;
|
|
25
|
+
defaults;
|
|
25
26
|
dispatcher;
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
28
|
+
* Initialize the client with mandatory config and optional request defaults.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Immutable connector identity and environment (Connector, Auth, Environment).
|
|
31
|
+
* @param defaults - Optional per-request defaults (Http, Vault).
|
|
32
|
+
* @param libPath - optional path to the UniFFI shared library.
|
|
29
33
|
*/
|
|
30
|
-
constructor(
|
|
34
|
+
constructor(config, defaults = {}, libPath) {
|
|
31
35
|
this.uniffi = new uniffi_client_1.UniffiClient(libPath);
|
|
32
|
-
this.
|
|
36
|
+
this.config = proto_1.types.ConnectorConfig.create(config);
|
|
37
|
+
this.defaults = defaults;
|
|
38
|
+
if (config.connector === undefined) {
|
|
39
|
+
throw new http_client_1.ConnectorError("Connector is required in ConnectorConfig", 400, "CLIENT_INITIALIZATION");
|
|
40
|
+
}
|
|
33
41
|
// Instance-level cache: create the primary connection pool at startup
|
|
34
|
-
this.dispatcher = (0, http_client_1.createDispatcher)(
|
|
42
|
+
this.dispatcher = (0, http_client_1.createDispatcher)(defaults.http || {});
|
|
35
43
|
}
|
|
36
44
|
/**
|
|
37
|
-
*
|
|
45
|
+
* Merges request-level options with client defaults. Environment comes from config (immutable).
|
|
38
46
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
bypassUrls: proto.proxy.bypassUrls ?? undefined,
|
|
51
|
-
} : undefined,
|
|
52
|
-
caCert: proto.caCert ?? undefined,
|
|
47
|
+
_resolveConfig(overrides) {
|
|
48
|
+
const opt = overrides || {};
|
|
49
|
+
const clientHttp = this.defaults.http || {};
|
|
50
|
+
const overrideHttp = opt.http || {};
|
|
51
|
+
const http = {
|
|
52
|
+
totalTimeoutMs: overrideHttp.totalTimeoutMs ?? clientHttp.totalTimeoutMs,
|
|
53
|
+
connectTimeoutMs: overrideHttp.connectTimeoutMs ?? clientHttp.connectTimeoutMs,
|
|
54
|
+
responseTimeoutMs: overrideHttp.responseTimeoutMs ?? clientHttp.responseTimeoutMs,
|
|
55
|
+
keepAliveTimeoutMs: overrideHttp.keepAliveTimeoutMs ?? clientHttp.keepAliveTimeoutMs,
|
|
56
|
+
proxy: overrideHttp.proxy ?? clientHttp.proxy,
|
|
57
|
+
caCert: overrideHttp.caCert ?? clientHttp.caCert,
|
|
53
58
|
};
|
|
59
|
+
const ffi = proto_1.types.FfiOptions.create({
|
|
60
|
+
environment: this.config.environment ?? proto_1.types.Environment.SANDBOX,
|
|
61
|
+
connector: this.config.connector,
|
|
62
|
+
auth: this.config.auth,
|
|
63
|
+
});
|
|
64
|
+
return { ffi, http };
|
|
54
65
|
}
|
|
55
66
|
/**
|
|
56
67
|
* Execute a full round-trip for any registered payment flow.
|
|
57
68
|
*
|
|
58
|
-
* Looks up the request/response protobuf type names from FLOWS, encodes the
|
|
59
|
-
* request, calls callReq → HTTP → callRes via the generic FFI dispatcher,
|
|
60
|
-
* then decodes and returns the response.
|
|
61
|
-
*
|
|
62
69
|
* @param flow - Flow name matching the FFI transformer prefix (e.g. "authorize").
|
|
63
70
|
* @param requestMsg - Protobuf request message object.
|
|
64
|
-
* @param
|
|
65
|
-
* @param ffiOptions - Optional IFfiOptions override.
|
|
71
|
+
* @param options - Optional ConfigOptions override (Environment, Http).
|
|
66
72
|
*/
|
|
67
|
-
async _executeFlow(flow, requestMsg,
|
|
73
|
+
async _executeFlow(flow, requestMsg, options, reqTypeName, resTypeName) {
|
|
68
74
|
const reqType = reqTypeName ? v2[reqTypeName] : undefined;
|
|
69
75
|
const resType = resTypeName ? v2[resTypeName] : undefined;
|
|
70
76
|
if (!reqType || !resType) {
|
|
71
77
|
throw new Error(`Unknown flow: '${flow}' or missing type names.`);
|
|
72
78
|
}
|
|
73
|
-
// 1.
|
|
79
|
+
// 1. Resolve final configuration
|
|
80
|
+
const { ffi, http } = this._resolveConfig(options);
|
|
81
|
+
const optionsBytes = Buffer.from(v2.FfiOptions.encode(ffi).finish());
|
|
82
|
+
// 2. Serialize domain request
|
|
74
83
|
const requestBytes = Buffer.from(reqType.encode(requestMsg).finish());
|
|
75
|
-
//
|
|
76
|
-
const
|
|
77
|
-
const optionsBytes = ffi ? Buffer.from(v2.FfiOptions.encode(ffi).finish()) : Buffer.alloc(0);
|
|
78
|
-
// 3. Build connector HTTP request via FFI (returns FfiConnectorHttpRequest protobuf bytes)
|
|
79
|
-
const resultBytes = this.uniffi.callReq(flow, requestBytes, metadata, optionsBytes);
|
|
84
|
+
// 3. Build connector HTTP request via FFI
|
|
85
|
+
const resultBytes = this.uniffi.callReq(flow, requestBytes, optionsBytes);
|
|
80
86
|
const connectorReq = v2.FfiConnectorHttpRequest.decode(resultBytes);
|
|
81
87
|
const connectorRequest = {
|
|
82
88
|
url: connectorReq.url,
|
|
@@ -85,8 +91,8 @@ class ConnectorClient {
|
|
|
85
91
|
body: connectorReq.body ?? undefined
|
|
86
92
|
};
|
|
87
93
|
// 4. Execute HTTP using the instance-owned connection pool
|
|
88
|
-
const response = await (0, http_client_1.execute)(connectorRequest,
|
|
89
|
-
// 5. Encode HTTP response
|
|
94
|
+
const response = await (0, http_client_1.execute)(connectorRequest, http, this.dispatcher);
|
|
95
|
+
// 5. Encode HTTP response for FFI
|
|
90
96
|
const resProto = v2.FfiConnectorHttpResponse.create({
|
|
91
97
|
statusCode: response.statusCode,
|
|
92
98
|
headers: response.headers,
|
|
@@ -94,9 +100,28 @@ class ConnectorClient {
|
|
|
94
100
|
});
|
|
95
101
|
const resBytes = Buffer.from(v2.FfiConnectorHttpResponse.encode(resProto).finish());
|
|
96
102
|
// 6. Parse connector response via FFI and decode
|
|
97
|
-
const resultBytesRes = this.uniffi.callRes(flow, resBytes, requestBytes,
|
|
103
|
+
const resultBytesRes = this.uniffi.callRes(flow, resBytes, requestBytes, optionsBytes);
|
|
98
104
|
return resType.decode(resultBytesRes);
|
|
99
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Execute a single-step flow directly via FFI (no HTTP round-trip).
|
|
108
|
+
* Used for inbound flows like webhook processing where the connector sends data to us.
|
|
109
|
+
*/
|
|
110
|
+
async _executeDirect(flow, requestMsg, options, reqTypeName, resTypeName) {
|
|
111
|
+
const reqType = reqTypeName ? v2[reqTypeName] : undefined;
|
|
112
|
+
const resType = resTypeName ? v2[resTypeName] : undefined;
|
|
113
|
+
if (!reqType || !resType) {
|
|
114
|
+
throw new Error(`Unknown flow: '${flow}' or missing type names.`);
|
|
115
|
+
}
|
|
116
|
+
// 1. Serialize request
|
|
117
|
+
const requestBytes = Buffer.from(reqType.encode(requestMsg).finish());
|
|
118
|
+
// 2. Resolve FFI options from identity + defaults + request override
|
|
119
|
+
const { ffi } = this._resolveConfig(options);
|
|
120
|
+
const optionsBytes = Buffer.from(v2.FfiOptions.encode(ffi).finish());
|
|
121
|
+
// 3. Call the single-step transformer directly (no HTTP)
|
|
122
|
+
const resultBytes = this.uniffi.callDirect(flow, requestBytes, optionsBytes);
|
|
123
|
+
return resType.decode(resultBytes);
|
|
124
|
+
}
|
|
100
125
|
}
|
|
101
126
|
exports.ConnectorClient = ConnectorClient;
|
|
102
127
|
//# sourceMappingURL=connector_client.js.map
|
|
Binary file
|