@marcohefti/request-network-api-client 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +97 -0
- package/dist/cjs/domains/client-ids/index.js +309 -0
- package/dist/cjs/domains/client-ids/index.js.map +1 -0
- package/dist/cjs/domains/currencies/index.js +347 -0
- package/dist/cjs/domains/currencies/index.js.map +1 -0
- package/dist/cjs/domains/payer/index.js +450 -0
- package/dist/cjs/domains/payer/index.js.map +1 -0
- package/dist/cjs/domains/payouts/index.js +304 -0
- package/dist/cjs/domains/payouts/index.js.map +1 -0
- package/dist/cjs/domains/requests/index.js +544 -0
- package/dist/cjs/domains/requests/index.js.map +1 -0
- package/dist/cjs/index.js +3466 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/domains/client-ids/index.d.mts +2 -0
- package/dist/esm/domains/client-ids/index.js +307 -0
- package/dist/esm/domains/client-ids/index.js.map +1 -0
- package/dist/esm/domains/currencies/index.d.mts +3 -0
- package/dist/esm/domains/currencies/index.js +344 -0
- package/dist/esm/domains/currencies/index.js.map +1 -0
- package/dist/esm/domains/payer/index.d.mts +2 -0
- package/dist/esm/domains/payer/index.js +446 -0
- package/dist/esm/domains/payer/index.js.map +1 -0
- package/dist/esm/domains/payouts/index.d.mts +2 -0
- package/dist/esm/domains/payouts/index.js +302 -0
- package/dist/esm/domains/payouts/index.js.map +1 -0
- package/dist/esm/domains/requests/index.d.mts +2 -0
- package/dist/esm/domains/requests/index.js +542 -0
- package/dist/esm/domains/requests/index.js.map +1 -0
- package/dist/esm/index-BmWmfcnn.d.mts +113 -0
- package/dist/esm/index-CNK36ZX5.d.mts +26 -0
- package/dist/esm/index-Cd7x0Hv-.d.mts +39 -0
- package/dist/esm/index-Q2g0D7V8.d.mts +79 -0
- package/dist/esm/index-ziziGrHN.d.mts +220 -0
- package/dist/esm/index.d.mts +5478 -0
- package/dist/esm/index.js +3435 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/openapi-types-CtUFCrk4.d.mts +3368 -0
- package/package.json +168 -0
|
@@ -0,0 +1,3435 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { timingSafeEqual, createHmac } from 'crypto';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/core/errors/request-api.error.ts
|
|
12
|
+
var REQUEST_ERROR_NAME = "RequestApiError";
|
|
13
|
+
var RequestApiError = class extends Error {
|
|
14
|
+
status;
|
|
15
|
+
code;
|
|
16
|
+
detail;
|
|
17
|
+
errors;
|
|
18
|
+
requestId;
|
|
19
|
+
correlationId;
|
|
20
|
+
retryAfterMs;
|
|
21
|
+
headers;
|
|
22
|
+
meta;
|
|
23
|
+
constructor(metadata) {
|
|
24
|
+
super(metadata.message, { cause: metadata.cause });
|
|
25
|
+
this.name = REQUEST_ERROR_NAME;
|
|
26
|
+
this.status = metadata.status;
|
|
27
|
+
this.code = metadata.code;
|
|
28
|
+
this.detail = metadata.detail;
|
|
29
|
+
this.errors = metadata.errors;
|
|
30
|
+
this.requestId = metadata.requestId;
|
|
31
|
+
this.correlationId = metadata.correlationId;
|
|
32
|
+
this.retryAfterMs = metadata.retryAfterMs;
|
|
33
|
+
this.headers = metadata.headers;
|
|
34
|
+
this.meta = metadata.meta;
|
|
35
|
+
}
|
|
36
|
+
toJSON() {
|
|
37
|
+
return {
|
|
38
|
+
name: this.name,
|
|
39
|
+
message: this.message,
|
|
40
|
+
status: this.status,
|
|
41
|
+
code: this.code,
|
|
42
|
+
detail: this.detail,
|
|
43
|
+
errors: this.errors,
|
|
44
|
+
requestId: this.requestId,
|
|
45
|
+
correlationId: this.correlationId,
|
|
46
|
+
retryAfterMs: this.retryAfterMs,
|
|
47
|
+
headers: this.headers,
|
|
48
|
+
meta: this.meta
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var REQUEST_ID_HEADER = "x-request-id";
|
|
53
|
+
var CORRELATION_ID_HEADER = "x-correlation-id";
|
|
54
|
+
var RETRY_AFTER_HEADER = "retry-after";
|
|
55
|
+
function normaliseHeaders(headers) {
|
|
56
|
+
if (!headers) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
if (typeof headers.get === "function") {
|
|
60
|
+
const lookup = headers;
|
|
61
|
+
return {
|
|
62
|
+
[REQUEST_ID_HEADER]: lookup.get(REQUEST_ID_HEADER),
|
|
63
|
+
[CORRELATION_ID_HEADER]: lookup.get(CORRELATION_ID_HEADER),
|
|
64
|
+
[RETRY_AFTER_HEADER]: lookup.get(RETRY_AFTER_HEADER)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
[REQUEST_ID_HEADER]: headers[REQUEST_ID_HEADER],
|
|
69
|
+
[CORRELATION_ID_HEADER]: headers[CORRELATION_ID_HEADER],
|
|
70
|
+
[RETRY_AFTER_HEADER]: headers[RETRY_AFTER_HEADER]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function parseRetryAfter(headerValue) {
|
|
74
|
+
if (!headerValue) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
const numeric = Number(headerValue);
|
|
78
|
+
if (!Number.isNaN(numeric)) {
|
|
79
|
+
return numeric * 1e3;
|
|
80
|
+
}
|
|
81
|
+
const parsedDate = Date.parse(headerValue);
|
|
82
|
+
if (Number.isNaN(parsedDate)) {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
const delay = parsedDate - Date.now();
|
|
86
|
+
return delay > 0 ? delay : 0;
|
|
87
|
+
}
|
|
88
|
+
function buildRequestApiError(options) {
|
|
89
|
+
const { payload, status, headers, fallbackMessage, meta, cause } = options;
|
|
90
|
+
const normalisedHeaders = normaliseHeaders(headers);
|
|
91
|
+
const retryAfterHeader = normalisedHeaders?.[RETRY_AFTER_HEADER];
|
|
92
|
+
const retryAfterMs = parseRetryAfter(retryAfterHeader);
|
|
93
|
+
const code = typeof payload?.code === "string" && payload.code.length > 0 ? payload.code : `HTTP_${String(status)}`;
|
|
94
|
+
const message = typeof payload?.message === "string" && payload.message.length > 0 ? payload.message : fallbackMessage ?? "Request Network API error";
|
|
95
|
+
const maybeErrors = Array.isArray(payload?.errors) ? payload.errors : void 0;
|
|
96
|
+
const errors = maybeErrors?.filter(Boolean);
|
|
97
|
+
return new RequestApiError({
|
|
98
|
+
status,
|
|
99
|
+
code,
|
|
100
|
+
message,
|
|
101
|
+
detail: payload?.detail,
|
|
102
|
+
errors,
|
|
103
|
+
requestId: normalisedHeaders?.[REQUEST_ID_HEADER],
|
|
104
|
+
correlationId: normalisedHeaders?.[CORRELATION_ID_HEADER],
|
|
105
|
+
retryAfterMs,
|
|
106
|
+
headers: normalisedHeaders,
|
|
107
|
+
meta,
|
|
108
|
+
cause
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function isRequestApiError(error) {
|
|
112
|
+
return error instanceof RequestApiError || typeof error === "object" && error !== null && error.name === REQUEST_ERROR_NAME;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/core/http/retry.policy.ts
|
|
116
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
117
|
+
maxAttempts: 3,
|
|
118
|
+
initialDelayMs: 250,
|
|
119
|
+
maxDelayMs: 5e3,
|
|
120
|
+
backoffFactor: 2,
|
|
121
|
+
jitter: "full",
|
|
122
|
+
retryStatusCodes: [408, 425, 429, 500, 502, 503, 504],
|
|
123
|
+
allowedMethods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
|
|
124
|
+
};
|
|
125
|
+
function shouldRetryRequest(config, input) {
|
|
126
|
+
if (config.maxAttempts <= 1) {
|
|
127
|
+
return { retry: false, reason: "retries-disabled" };
|
|
128
|
+
}
|
|
129
|
+
if (input.attempt >= config.maxAttempts) {
|
|
130
|
+
return { retry: false, reason: "max-attempts-exceeded" };
|
|
131
|
+
}
|
|
132
|
+
if (config.shouldRetry) {
|
|
133
|
+
const decision = config.shouldRetry(input);
|
|
134
|
+
if (!decision) {
|
|
135
|
+
return { retry: false, reason: "predicate-declined" };
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
const statusFromError = isRequestApiError(input.error) ? input.error.status : void 0;
|
|
139
|
+
const status = input.response?.status ?? statusFromError;
|
|
140
|
+
if (typeof status !== "number" || !config.retryStatusCodes.includes(status)) {
|
|
141
|
+
return { retry: false, reason: "status-not-retriable" };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const delay = computeRetryDelay(config, input);
|
|
145
|
+
return { retry: true, delayMs: delay, reason: "retry-scheduled" };
|
|
146
|
+
}
|
|
147
|
+
function computeRetryDelay(config, input) {
|
|
148
|
+
const retryAfter = input.response?.retryAfterMs ?? extractRetryAfterFromError(input.error);
|
|
149
|
+
if (retryAfter !== void 0 && retryAfter >= 0) {
|
|
150
|
+
return clampDelay(retryAfter, config.maxDelayMs);
|
|
151
|
+
}
|
|
152
|
+
const attemptIndex = input.attempt - 1;
|
|
153
|
+
const exponential = config.initialDelayMs * Math.pow(config.backoffFactor, attemptIndex);
|
|
154
|
+
const jittered = applyJitter(exponential, config.jitter);
|
|
155
|
+
return clampDelay(jittered, config.maxDelayMs);
|
|
156
|
+
}
|
|
157
|
+
function hasRetryAfter(x) {
|
|
158
|
+
return typeof x === "object" && x !== null && "retryAfterMs" in x;
|
|
159
|
+
}
|
|
160
|
+
function extractRetryAfterFromError(err) {
|
|
161
|
+
if (isRequestApiError(err)) {
|
|
162
|
+
return err.retryAfterMs;
|
|
163
|
+
}
|
|
164
|
+
if (hasRetryAfter(err) && typeof err.retryAfterMs === "number") {
|
|
165
|
+
return err.retryAfterMs;
|
|
166
|
+
}
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
function clampDelay(delay, maxDelay) {
|
|
170
|
+
if (delay < 0) {
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
return delay > maxDelay ? maxDelay : delay;
|
|
174
|
+
}
|
|
175
|
+
function applyJitter(delay, jitter) {
|
|
176
|
+
if (delay <= 0) {
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
switch (jitter) {
|
|
180
|
+
case "none": {
|
|
181
|
+
return delay;
|
|
182
|
+
}
|
|
183
|
+
case "half": {
|
|
184
|
+
const min = delay / 2;
|
|
185
|
+
return randomInRange(min, delay);
|
|
186
|
+
}
|
|
187
|
+
case "full":
|
|
188
|
+
default: {
|
|
189
|
+
return randomInRange(0, delay);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function randomInRange(min, max) {
|
|
194
|
+
if (min >= max) {
|
|
195
|
+
return min;
|
|
196
|
+
}
|
|
197
|
+
return min + Math.random() * (max - min);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/validation/schema.registry.ts
|
|
201
|
+
function serialiseKey(key) {
|
|
202
|
+
const variant = key.variant ?? "default";
|
|
203
|
+
const status = key.status?.toString() ?? "any";
|
|
204
|
+
return `${key.operationId}|${key.kind}|${variant}|${status}`;
|
|
205
|
+
}
|
|
206
|
+
var SchemaRegistry = class {
|
|
207
|
+
store = /* @__PURE__ */ new Map();
|
|
208
|
+
register(entry) {
|
|
209
|
+
const id = serialiseKey(entry.key);
|
|
210
|
+
this.store.set(id, entry);
|
|
211
|
+
}
|
|
212
|
+
get(key) {
|
|
213
|
+
const id = serialiseKey(key);
|
|
214
|
+
return this.store.get(id)?.schema;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Removes every registered schema — primarily useful in tests.
|
|
218
|
+
*/
|
|
219
|
+
clear() {
|
|
220
|
+
this.store.clear();
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var schemaRegistry = new SchemaRegistry();
|
|
224
|
+
|
|
225
|
+
// src/validation/zod.helpers.ts
|
|
226
|
+
var ValidationError = class extends Error {
|
|
227
|
+
constructor(message, cause) {
|
|
228
|
+
super(message, { cause });
|
|
229
|
+
this.cause = cause;
|
|
230
|
+
this.name = "ClientValidationError";
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
function parseWithSchema(options) {
|
|
234
|
+
const { schema, value, description } = options;
|
|
235
|
+
const outcome = schema.safeParse(value);
|
|
236
|
+
if (outcome.success) {
|
|
237
|
+
return { success: true, data: outcome.data };
|
|
238
|
+
}
|
|
239
|
+
const error = new ValidationError(description ?? "Validation failed", outcome.error);
|
|
240
|
+
return { success: false, error };
|
|
241
|
+
}
|
|
242
|
+
function parseWithRegistry(options) {
|
|
243
|
+
const schema = schemaRegistry.get(options.key);
|
|
244
|
+
if (!schema) {
|
|
245
|
+
if (options.skipOnMissingSchema) {
|
|
246
|
+
return { success: true, data: options.value };
|
|
247
|
+
}
|
|
248
|
+
return { success: false, error: new ValidationError(`No schema registered for ${options.key.operationId}`) };
|
|
249
|
+
}
|
|
250
|
+
return parseWithSchema({ schema, value: options.value, description: options.description });
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/core/http/http.types.ts
|
|
254
|
+
function toQueryItems(value) {
|
|
255
|
+
const items = Array.isArray(value) ? value : [value];
|
|
256
|
+
return items.map((item) => String(item));
|
|
257
|
+
}
|
|
258
|
+
function resolveQuerySerializer(serializer) {
|
|
259
|
+
if (!serializer || serializer === "comma") {
|
|
260
|
+
return ({ key, value, set }) => {
|
|
261
|
+
const joined = toQueryItems(value).join(",");
|
|
262
|
+
set(key, joined);
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
if (serializer === "repeat") {
|
|
266
|
+
return ({ key, value, append }) => {
|
|
267
|
+
const items = toQueryItems(value);
|
|
268
|
+
for (const item of items) {
|
|
269
|
+
append(key, item);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return serializer;
|
|
274
|
+
}
|
|
275
|
+
function buildUrl(baseUrl, path, query, serializer) {
|
|
276
|
+
const base = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
277
|
+
const cleanPath = path.startsWith("/") ? path : `/${path}`;
|
|
278
|
+
const url = new URL(base + cleanPath);
|
|
279
|
+
if (!query) return url.toString();
|
|
280
|
+
const serialize = resolveQuerySerializer(serializer);
|
|
281
|
+
const params = url.searchParams;
|
|
282
|
+
for (const key of Object.keys(query)) {
|
|
283
|
+
const raw = query[key];
|
|
284
|
+
if (raw === void 0) continue;
|
|
285
|
+
serialize({
|
|
286
|
+
key,
|
|
287
|
+
value: raw,
|
|
288
|
+
set: (k, value) => {
|
|
289
|
+
params.delete(k);
|
|
290
|
+
params.set(k, value);
|
|
291
|
+
},
|
|
292
|
+
append: (k, value) => {
|
|
293
|
+
params.append(k, value);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
return url.toString();
|
|
298
|
+
}
|
|
299
|
+
function composeInterceptors(terminal, interceptors = []) {
|
|
300
|
+
return interceptors.reduceRight((next, interceptor) => {
|
|
301
|
+
return (req) => interceptor(req, next);
|
|
302
|
+
}, terminal);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/core/auth/credential-header.builder.ts
|
|
306
|
+
function buildCredentialHeaders(options) {
|
|
307
|
+
const headers = {};
|
|
308
|
+
if (options.apiKey) headers["x-api-key"] = options.apiKey;
|
|
309
|
+
if (options.clientId) headers["x-client-id"] = options.clientId;
|
|
310
|
+
if (options.origin) headers["Origin"] = options.origin;
|
|
311
|
+
return headers;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/core/http/adapters/adapter.utils.ts
|
|
315
|
+
function headersToRecord(headers) {
|
|
316
|
+
const out = {};
|
|
317
|
+
headers.forEach((value, key) => {
|
|
318
|
+
out[key.toLowerCase()] = value;
|
|
319
|
+
});
|
|
320
|
+
return out;
|
|
321
|
+
}
|
|
322
|
+
function resolveSignal(options) {
|
|
323
|
+
const { signal, timeoutMs } = options;
|
|
324
|
+
if (timeoutMs === void 0) {
|
|
325
|
+
return { signal, dispose: () => {
|
|
326
|
+
} };
|
|
327
|
+
}
|
|
328
|
+
const controller = new AbortController();
|
|
329
|
+
let timer;
|
|
330
|
+
const abortForTimeout = () => {
|
|
331
|
+
controller.abort(new Error(`Request timed out after ${String(timeoutMs)}ms`));
|
|
332
|
+
};
|
|
333
|
+
if (timeoutMs <= 0) {
|
|
334
|
+
abortForTimeout();
|
|
335
|
+
} else {
|
|
336
|
+
timer = setTimeout(abortForTimeout, timeoutMs);
|
|
337
|
+
}
|
|
338
|
+
const cleanupTimer = () => {
|
|
339
|
+
if (timer) clearTimeout(timer);
|
|
340
|
+
};
|
|
341
|
+
controller.signal.addEventListener("abort", cleanupTimer, { once: true });
|
|
342
|
+
let removeAbortListener;
|
|
343
|
+
if (signal) {
|
|
344
|
+
if (signal.aborted) {
|
|
345
|
+
cleanupTimer();
|
|
346
|
+
controller.abort(signal.reason);
|
|
347
|
+
} else {
|
|
348
|
+
const onAbort = () => {
|
|
349
|
+
cleanupTimer();
|
|
350
|
+
controller.abort(signal.reason);
|
|
351
|
+
};
|
|
352
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
353
|
+
removeAbortListener = () => {
|
|
354
|
+
signal.removeEventListener("abort", onAbort);
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const dispose = () => {
|
|
359
|
+
cleanupTimer();
|
|
360
|
+
if (removeAbortListener) {
|
|
361
|
+
removeAbortListener();
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
return { signal: controller.signal, dispose };
|
|
365
|
+
}
|
|
366
|
+
function createFetchInit(request) {
|
|
367
|
+
const headers = { ...request.headers ?? {} };
|
|
368
|
+
const init = {
|
|
369
|
+
method: request.method,
|
|
370
|
+
headers
|
|
371
|
+
};
|
|
372
|
+
if (request.body !== void 0) {
|
|
373
|
+
const body = request.body;
|
|
374
|
+
const isFormData = typeof FormData !== "undefined" && body instanceof FormData;
|
|
375
|
+
const isBlob = typeof Blob !== "undefined" && body instanceof Blob;
|
|
376
|
+
const isUint8 = body instanceof Uint8Array;
|
|
377
|
+
const isArrayBuffer = typeof ArrayBuffer !== "undefined" && body instanceof ArrayBuffer;
|
|
378
|
+
if (typeof body === "string" || isFormData || isBlob || isUint8 || isArrayBuffer) {
|
|
379
|
+
init.body = body;
|
|
380
|
+
} else {
|
|
381
|
+
init.body = JSON.stringify(body);
|
|
382
|
+
headers["content-type"] ??= "application/json";
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const { signal, dispose } = resolveSignal({ signal: request.signal, timeoutMs: request.timeoutMs });
|
|
386
|
+
if (signal) {
|
|
387
|
+
init.signal = signal;
|
|
388
|
+
}
|
|
389
|
+
return { init, dispose };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// src/core/http/adapters/node-fetch.adapter.ts
|
|
393
|
+
var nodeFetchAdapter = {
|
|
394
|
+
async send(request) {
|
|
395
|
+
const { init, dispose } = createFetchInit(request);
|
|
396
|
+
try {
|
|
397
|
+
const res = await fetch(request.url, init);
|
|
398
|
+
const respHeaders = headersToRecord(res.headers);
|
|
399
|
+
const contentType = respHeaders["content-type"] ?? "";
|
|
400
|
+
let data;
|
|
401
|
+
let text;
|
|
402
|
+
if (res.status !== 204) {
|
|
403
|
+
try {
|
|
404
|
+
if (contentType.includes("application/json")) {
|
|
405
|
+
data = await res.json();
|
|
406
|
+
} else {
|
|
407
|
+
text = await res.text();
|
|
408
|
+
}
|
|
409
|
+
} catch {
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const normalized = {
|
|
413
|
+
status: res.status,
|
|
414
|
+
ok: res.ok,
|
|
415
|
+
headers: respHeaders,
|
|
416
|
+
data,
|
|
417
|
+
text
|
|
418
|
+
};
|
|
419
|
+
return normalized;
|
|
420
|
+
} finally {
|
|
421
|
+
dispose();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// src/core/http/interceptors/logger.utils.ts
|
|
427
|
+
var LEVEL_RANK = {
|
|
428
|
+
silent: 0,
|
|
429
|
+
error: 1,
|
|
430
|
+
info: 2,
|
|
431
|
+
debug: 3
|
|
432
|
+
};
|
|
433
|
+
function shouldLog(level, threshold) {
|
|
434
|
+
return LEVEL_RANK[level] >= LEVEL_RANK[threshold];
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/core/http/interceptors/logging.interceptor.ts
|
|
438
|
+
function createLoggingInterceptor(options) {
|
|
439
|
+
const log = options?.logger;
|
|
440
|
+
const level = options?.level ?? "info";
|
|
441
|
+
const EVENT_LEVEL = {
|
|
442
|
+
"request:start": "debug",
|
|
443
|
+
"request:response": "info",
|
|
444
|
+
"request:error": "error"
|
|
445
|
+
};
|
|
446
|
+
const emit = (event, meta) => {
|
|
447
|
+
if (!log) return;
|
|
448
|
+
const threshold = EVENT_LEVEL[event];
|
|
449
|
+
if (!shouldLog(level, threshold)) return;
|
|
450
|
+
log(event, meta);
|
|
451
|
+
};
|
|
452
|
+
return async (req, next) => {
|
|
453
|
+
const startedAt = Date.now();
|
|
454
|
+
emit("request:start", { method: req.method, url: req.url, meta: req.meta });
|
|
455
|
+
try {
|
|
456
|
+
const res = await next(req);
|
|
457
|
+
const durationMs = Date.now() - startedAt;
|
|
458
|
+
emit("request:response", { method: req.method, url: req.url, status: res.status, ok: res.ok, durationMs, meta: req.meta });
|
|
459
|
+
return res;
|
|
460
|
+
} catch (error) {
|
|
461
|
+
const durationMs = Date.now() - startedAt;
|
|
462
|
+
emit("request:error", { method: req.method, url: req.url, durationMs, error, meta: req.meta });
|
|
463
|
+
throw error;
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// src/core/http/interceptors/retry.interceptor.ts
|
|
469
|
+
function sleep(ms) {
|
|
470
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
471
|
+
}
|
|
472
|
+
function createRetryInterceptor(options) {
|
|
473
|
+
const cfg = { ...DEFAULT_RETRY_CONFIG, ...options?.config ?? {} };
|
|
474
|
+
const allowed = new Set(cfg.allowedMethods ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
|
|
475
|
+
const log = options?.logger;
|
|
476
|
+
const level = options?.logLevel ?? "info";
|
|
477
|
+
const RETRY_EVENT = "request:retry";
|
|
478
|
+
const RATE_LIMIT_EVENT = "rate-limit";
|
|
479
|
+
const DEFAULT_RETRY_REASON = "retry-scheduled";
|
|
480
|
+
const emit = (event, meta) => {
|
|
481
|
+
const threshold = event === RETRY_EVENT ? "info" : "info";
|
|
482
|
+
if (!log) return;
|
|
483
|
+
if (!shouldLog(level, threshold)) return;
|
|
484
|
+
log(event, meta);
|
|
485
|
+
};
|
|
486
|
+
const parseRetryAfterMs = (headers) => {
|
|
487
|
+
if (!headers) return void 0;
|
|
488
|
+
const header = headers["retry-after"] ?? headers["Retry-After"];
|
|
489
|
+
return parseRetryAfter(header);
|
|
490
|
+
};
|
|
491
|
+
const scheduleRetry = async (delayMs, meta) => {
|
|
492
|
+
emit(RETRY_EVENT, { ...meta, reason: meta.reason ?? DEFAULT_RETRY_REASON });
|
|
493
|
+
if (delayMs > 0) {
|
|
494
|
+
await sleep(delayMs);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
const maybeHandleResponse = async ({
|
|
498
|
+
res,
|
|
499
|
+
attempt,
|
|
500
|
+
context,
|
|
501
|
+
isAllowedMethod
|
|
502
|
+
}) => {
|
|
503
|
+
if (res.ok) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
const retryAfterMs = parseRetryAfterMs(res.headers);
|
|
507
|
+
if (res.status === 429) {
|
|
508
|
+
emit(RATE_LIMIT_EVENT, { ...context, status: res.status, attempt, retryAfterMs });
|
|
509
|
+
}
|
|
510
|
+
const decision = isAllowedMethod ? shouldRetryRequest(cfg, { attempt, response: { status: res.status, headers: res.headers, retryAfterMs } }) : { retry: false };
|
|
511
|
+
if (!decision.retry) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
const delay = decision.delayMs ?? computeRetryDelay(cfg, { attempt, response: { status: res.status, headers: res.headers, retryAfterMs } });
|
|
515
|
+
await scheduleRetry(delay, {
|
|
516
|
+
...context,
|
|
517
|
+
attempt,
|
|
518
|
+
nextAttempt: attempt + 1,
|
|
519
|
+
status: res.status,
|
|
520
|
+
delayMs: delay,
|
|
521
|
+
reason: decision.reason,
|
|
522
|
+
retryAfterMs
|
|
523
|
+
});
|
|
524
|
+
return true;
|
|
525
|
+
};
|
|
526
|
+
const maybeHandleError = async ({
|
|
527
|
+
error,
|
|
528
|
+
attempt,
|
|
529
|
+
context
|
|
530
|
+
}) => {
|
|
531
|
+
const decision = shouldRetryRequest(cfg, { attempt, error });
|
|
532
|
+
if (!decision.retry) {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
const delay = decision.delayMs ?? computeRetryDelay(cfg, { attempt, error });
|
|
536
|
+
await scheduleRetry(delay, {
|
|
537
|
+
...context,
|
|
538
|
+
attempt,
|
|
539
|
+
nextAttempt: attempt + 1,
|
|
540
|
+
delayMs: delay,
|
|
541
|
+
reason: decision.reason,
|
|
542
|
+
error
|
|
543
|
+
});
|
|
544
|
+
return true;
|
|
545
|
+
};
|
|
546
|
+
return async function retryInterceptor(req, next) {
|
|
547
|
+
const isAllowedMethod = allowed.has(req.method);
|
|
548
|
+
for (let attempt = 1; attempt <= cfg.maxAttempts; attempt++) {
|
|
549
|
+
try {
|
|
550
|
+
const res = await next(req);
|
|
551
|
+
const shouldRetry = await maybeHandleResponse({
|
|
552
|
+
res,
|
|
553
|
+
attempt,
|
|
554
|
+
context: { method: req.method, url: req.url, meta: req.meta },
|
|
555
|
+
isAllowedMethod
|
|
556
|
+
});
|
|
557
|
+
if (!shouldRetry) {
|
|
558
|
+
return res;
|
|
559
|
+
}
|
|
560
|
+
continue;
|
|
561
|
+
} catch (error) {
|
|
562
|
+
const shouldRetry = await maybeHandleError({
|
|
563
|
+
error,
|
|
564
|
+
attempt,
|
|
565
|
+
context: { method: req.method, url: req.url, meta: req.meta }
|
|
566
|
+
});
|
|
567
|
+
if (shouldRetry) {
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return next(req);
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/core/http/validation.config.ts
|
|
578
|
+
var DEFAULT_RUNTIME_VALIDATION = {
|
|
579
|
+
requests: true,
|
|
580
|
+
responses: true,
|
|
581
|
+
errors: true
|
|
582
|
+
};
|
|
583
|
+
function normaliseBoolean(flag, fallback) {
|
|
584
|
+
return typeof flag === "boolean" ? flag : fallback;
|
|
585
|
+
}
|
|
586
|
+
function normaliseRuntimeValidation(option) {
|
|
587
|
+
if (typeof option === "boolean") {
|
|
588
|
+
return {
|
|
589
|
+
requests: option,
|
|
590
|
+
responses: option,
|
|
591
|
+
errors: option
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
requests: normaliseBoolean(option?.requests, DEFAULT_RUNTIME_VALIDATION.requests),
|
|
596
|
+
responses: normaliseBoolean(option?.responses, DEFAULT_RUNTIME_VALIDATION.responses),
|
|
597
|
+
errors: normaliseBoolean(option?.errors, DEFAULT_RUNTIME_VALIDATION.errors)
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function mergeRuntimeValidation(base, override) {
|
|
601
|
+
if (override === void 0) {
|
|
602
|
+
return base;
|
|
603
|
+
}
|
|
604
|
+
if (typeof override === "boolean") {
|
|
605
|
+
return {
|
|
606
|
+
requests: override,
|
|
607
|
+
responses: override,
|
|
608
|
+
errors: override
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
return {
|
|
612
|
+
requests: normaliseBoolean(override.requests, base.requests),
|
|
613
|
+
responses: normaliseBoolean(override.responses, base.responses),
|
|
614
|
+
errors: normaliseBoolean(override.errors, base.errors)
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function cloneRuntimeValidation(config) {
|
|
618
|
+
return { ...config };
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// src/core/http/client.factory.ts
|
|
622
|
+
var DEFAULT_BASE_URL = "https://api.request.network";
|
|
623
|
+
function buildTelemetryHeaders(userAgent, sdkInfo) {
|
|
624
|
+
const headers = {};
|
|
625
|
+
if (userAgent) headers["user-agent"] = userAgent;
|
|
626
|
+
if (sdkInfo?.name) headers["x-sdk"] = sdkInfo.version ? `${sdkInfo.name}/${sdkInfo.version}` : sdkInfo.name;
|
|
627
|
+
return headers;
|
|
628
|
+
}
|
|
629
|
+
function buildHeaders(credentials, defaults, extra) {
|
|
630
|
+
return {
|
|
631
|
+
...buildCredentialHeaders(credentials),
|
|
632
|
+
...defaults ?? {},
|
|
633
|
+
...{}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function asRecord(value) {
|
|
637
|
+
if (value && typeof value === "object" || Array.isArray(value)) {
|
|
638
|
+
return value;
|
|
639
|
+
}
|
|
640
|
+
return void 0;
|
|
641
|
+
}
|
|
642
|
+
function mapToError(res, req, validation) {
|
|
643
|
+
const operationId = req.meta?.operationId;
|
|
644
|
+
const rawPayload = asRecord(res.data);
|
|
645
|
+
let payload = rawPayload;
|
|
646
|
+
if (validation.errors && operationId) {
|
|
647
|
+
const schemaKey = { operationId, kind: "response", status: res.status };
|
|
648
|
+
const parsed = parseWithRegistry({
|
|
649
|
+
key: schemaKey,
|
|
650
|
+
value: rawPayload ?? res.data,
|
|
651
|
+
description: `Error response for ${operationId}`,
|
|
652
|
+
skipOnMissingSchema: true
|
|
653
|
+
});
|
|
654
|
+
if (!parsed.success) {
|
|
655
|
+
throw parsed.error;
|
|
656
|
+
}
|
|
657
|
+
payload = asRecord(parsed.data);
|
|
658
|
+
}
|
|
659
|
+
const error = buildRequestApiError({
|
|
660
|
+
payload,
|
|
661
|
+
status: res.status,
|
|
662
|
+
headers: res.headers,
|
|
663
|
+
fallbackMessage: res.text ?? `HTTP ${String(res.status)}`
|
|
664
|
+
});
|
|
665
|
+
throw error;
|
|
666
|
+
}
|
|
667
|
+
function createHttpClient(options = {}) {
|
|
668
|
+
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
669
|
+
const adapter = options.adapter ?? nodeFetchAdapter;
|
|
670
|
+
const defaults = { ...buildTelemetryHeaders(options.userAgent, options.sdkInfo), ...options.headers ?? {} };
|
|
671
|
+
const creds = { apiKey: options.apiKey, clientId: options.clientId, origin: options.origin };
|
|
672
|
+
const userInterceptors = options.interceptors ?? [];
|
|
673
|
+
const logLevel = options.logLevel ?? (options.logger ? "info" : "silent");
|
|
674
|
+
const runtimeValidation = normaliseRuntimeValidation(options.runtimeValidation);
|
|
675
|
+
function buildBaseInterceptors(meta) {
|
|
676
|
+
const retryCfg = meta?.retry ?? options.retry?.config;
|
|
677
|
+
const retryOptions = {
|
|
678
|
+
...options.retry ?? {},
|
|
679
|
+
logger: options.retry?.logger ?? options.logger,
|
|
680
|
+
logLevel: options.retry?.logLevel ?? logLevel
|
|
681
|
+
};
|
|
682
|
+
if (retryCfg) {
|
|
683
|
+
retryOptions.config = retryCfg;
|
|
684
|
+
}
|
|
685
|
+
return [createRetryInterceptor(retryOptions), createLoggingInterceptor({ logger: options.logger, level: logLevel })];
|
|
686
|
+
}
|
|
687
|
+
const cfg = {
|
|
688
|
+
baseUrl,
|
|
689
|
+
defaultHeaders: buildHeaders(creds, defaults),
|
|
690
|
+
adapter,
|
|
691
|
+
logger: options.logger,
|
|
692
|
+
querySerializer: options.querySerializer};
|
|
693
|
+
async function dispatch(req) {
|
|
694
|
+
const perRequestInterceptors = req.meta?.interceptors ?? [];
|
|
695
|
+
const baseInterceptors = buildBaseInterceptors(req.meta);
|
|
696
|
+
const all = [...perRequestInterceptors, ...userInterceptors, ...baseInterceptors];
|
|
697
|
+
const terminal = (r) => cfg.adapter.send(r);
|
|
698
|
+
const chain = composeInterceptors(terminal, all);
|
|
699
|
+
return chain(req);
|
|
700
|
+
}
|
|
701
|
+
async function request(init) {
|
|
702
|
+
const serializer = init.querySerializer ?? cfg.querySerializer;
|
|
703
|
+
const url = buildUrl(cfg.baseUrl, init.path, init.query, serializer);
|
|
704
|
+
const headers = { ...cfg.defaultHeaders ?? {}, ...init.headers ?? {} };
|
|
705
|
+
const req = {
|
|
706
|
+
method: init.method,
|
|
707
|
+
url,
|
|
708
|
+
headers,
|
|
709
|
+
body: init.body,
|
|
710
|
+
signal: init.signal,
|
|
711
|
+
timeoutMs: init.timeoutMs,
|
|
712
|
+
meta: init.meta
|
|
713
|
+
};
|
|
714
|
+
const res = await dispatch(req);
|
|
715
|
+
const effectiveValidation = mergeRuntimeValidation(runtimeValidation, req.meta?.validation);
|
|
716
|
+
if (!res.ok) {
|
|
717
|
+
mapToError(res, req, effectiveValidation);
|
|
718
|
+
}
|
|
719
|
+
return { status: res.status, headers: res.headers, data: res.data };
|
|
720
|
+
}
|
|
721
|
+
return {
|
|
722
|
+
request,
|
|
723
|
+
get: (path, init) => request({ ...init ?? {}, path, method: "GET" }),
|
|
724
|
+
post: (path, body, init) => request({ ...init ?? {}, path, method: "POST", body }),
|
|
725
|
+
put: (path, body, init) => request({ ...init ?? {}, path, method: "PUT", body }),
|
|
726
|
+
patch: (path, body, init) => request({ ...init ?? {}, path, method: "PATCH", body }),
|
|
727
|
+
delete: (path, init) => {
|
|
728
|
+
const { body, ...rest } = init ?? {};
|
|
729
|
+
return request({ ...rest, path, method: "DELETE", body });
|
|
730
|
+
},
|
|
731
|
+
head: (path, init) => request({ ...init ?? {}, path, method: "HEAD" }),
|
|
732
|
+
options: (path, init) => request({ ...init ?? {}, path, method: "OPTIONS" }),
|
|
733
|
+
getRuntimeValidationConfig: () => cloneRuntimeValidation(runtimeValidation)
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/core/http/adapters/browser-fetch.adapter.ts
|
|
738
|
+
var browserFetchAdapter = {
|
|
739
|
+
async send(request) {
|
|
740
|
+
const { init, dispose } = createFetchInit(request);
|
|
741
|
+
try {
|
|
742
|
+
const res = await fetch(request.url, init);
|
|
743
|
+
const respHeaders = headersToRecord(res.headers);
|
|
744
|
+
const contentType = respHeaders["content-type"] ?? "";
|
|
745
|
+
let data;
|
|
746
|
+
let text;
|
|
747
|
+
if (res.status !== 204) {
|
|
748
|
+
try {
|
|
749
|
+
if (contentType.includes("application/json")) {
|
|
750
|
+
data = await res.json();
|
|
751
|
+
} else {
|
|
752
|
+
text = await res.text();
|
|
753
|
+
}
|
|
754
|
+
} catch {
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
const normalized = {
|
|
758
|
+
status: res.status,
|
|
759
|
+
ok: res.ok,
|
|
760
|
+
headers: respHeaders,
|
|
761
|
+
data,
|
|
762
|
+
text
|
|
763
|
+
};
|
|
764
|
+
return normalized;
|
|
765
|
+
} finally {
|
|
766
|
+
dispose();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// src/domains/client-ids/index.ts
|
|
772
|
+
var client_ids_exports = {};
|
|
773
|
+
__export(client_ids_exports, {
|
|
774
|
+
createClientIdsApi: () => createClientIdsApi
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
// src/core/http/operation.helper.ts
|
|
778
|
+
async function requestJson(http, params) {
|
|
779
|
+
const {
|
|
780
|
+
operationId,
|
|
781
|
+
method,
|
|
782
|
+
path,
|
|
783
|
+
query,
|
|
784
|
+
body,
|
|
785
|
+
schemaKey,
|
|
786
|
+
requestSchemaKey,
|
|
787
|
+
description,
|
|
788
|
+
querySerializer,
|
|
789
|
+
signal,
|
|
790
|
+
timeoutMs,
|
|
791
|
+
validation,
|
|
792
|
+
meta
|
|
793
|
+
} = params;
|
|
794
|
+
const runtimeValidation = mergeRuntimeValidation(http.getRuntimeValidationConfig(), validation);
|
|
795
|
+
let requestBody = body;
|
|
796
|
+
if (runtimeValidation.requests && requestSchemaKey && body !== void 0) {
|
|
797
|
+
const parsedRequest = parseWithRegistry({
|
|
798
|
+
key: requestSchemaKey,
|
|
799
|
+
value: body,
|
|
800
|
+
description: `${description ?? operationId} request`,
|
|
801
|
+
skipOnMissingSchema: true
|
|
802
|
+
});
|
|
803
|
+
if (!parsedRequest.success) {
|
|
804
|
+
throw parsedRequest.error;
|
|
805
|
+
}
|
|
806
|
+
requestBody = parsedRequest.data;
|
|
807
|
+
}
|
|
808
|
+
const metaValidation = validation ?? meta?.validation;
|
|
809
|
+
const requestMeta = {
|
|
810
|
+
...meta ?? {},
|
|
811
|
+
operationId,
|
|
812
|
+
validation: metaValidation
|
|
813
|
+
};
|
|
814
|
+
const res = await http.request({
|
|
815
|
+
method,
|
|
816
|
+
path,
|
|
817
|
+
query,
|
|
818
|
+
body: requestBody,
|
|
819
|
+
querySerializer,
|
|
820
|
+
signal,
|
|
821
|
+
timeoutMs,
|
|
822
|
+
meta: requestMeta
|
|
823
|
+
});
|
|
824
|
+
if (!runtimeValidation.responses) {
|
|
825
|
+
return res.data;
|
|
826
|
+
}
|
|
827
|
+
const parsedResponse = parseWithRegistry({ key: schemaKey, value: res.data, description });
|
|
828
|
+
if (!parsedResponse.success) throw parsedResponse.error;
|
|
829
|
+
return parsedResponse.data;
|
|
830
|
+
}
|
|
831
|
+
async function requestVoid(http, params) {
|
|
832
|
+
const { operationId, method, path, query, body, querySerializer, signal, timeoutMs, requestSchemaKey, validation, meta } = params;
|
|
833
|
+
const runtimeValidation = mergeRuntimeValidation(http.getRuntimeValidationConfig(), validation);
|
|
834
|
+
let requestBody = body;
|
|
835
|
+
if (runtimeValidation.requests && requestSchemaKey && body !== void 0) {
|
|
836
|
+
const parsedRequest = parseWithRegistry({
|
|
837
|
+
key: requestSchemaKey,
|
|
838
|
+
value: body,
|
|
839
|
+
description: `${operationId} request`,
|
|
840
|
+
skipOnMissingSchema: true
|
|
841
|
+
});
|
|
842
|
+
if (!parsedRequest.success) {
|
|
843
|
+
throw parsedRequest.error;
|
|
844
|
+
}
|
|
845
|
+
requestBody = parsedRequest.data;
|
|
846
|
+
}
|
|
847
|
+
const metaValidation = validation ?? meta?.validation;
|
|
848
|
+
const requestMeta = {
|
|
849
|
+
...meta ?? {},
|
|
850
|
+
operationId,
|
|
851
|
+
validation: metaValidation
|
|
852
|
+
};
|
|
853
|
+
await http.request({
|
|
854
|
+
method,
|
|
855
|
+
path,
|
|
856
|
+
query,
|
|
857
|
+
body: requestBody,
|
|
858
|
+
querySerializer,
|
|
859
|
+
signal,
|
|
860
|
+
timeoutMs,
|
|
861
|
+
meta: requestMeta
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// src/core/http/path.builder.ts
|
|
866
|
+
function buildPath(template, params) {
|
|
867
|
+
return template.replace(/\{(.*?)\}/g, (_, key) => encodeURIComponent(String(params[key] ?? "")));
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// src/domains/client-ids/client-ids.facade.ts
|
|
871
|
+
function createClientIdsApi(http) {
|
|
872
|
+
const PATH_BASE = "/v2/client-ids";
|
|
873
|
+
return {
|
|
874
|
+
async list() {
|
|
875
|
+
const OP = "ClientIdV2Controller_findAll_v2";
|
|
876
|
+
return requestJson(http, {
|
|
877
|
+
operationId: OP,
|
|
878
|
+
method: "GET",
|
|
879
|
+
path: PATH_BASE,
|
|
880
|
+
schemaKey: { operationId: OP, kind: "response", status: 200 },
|
|
881
|
+
description: "List client IDs"
|
|
882
|
+
});
|
|
883
|
+
},
|
|
884
|
+
async create(body) {
|
|
885
|
+
const OP = "ClientIdV2Controller_create_v2";
|
|
886
|
+
return requestJson(http, {
|
|
887
|
+
operationId: OP,
|
|
888
|
+
method: "POST",
|
|
889
|
+
path: PATH_BASE,
|
|
890
|
+
body,
|
|
891
|
+
requestSchemaKey: { operationId: OP, kind: "request", variant: "application/json" },
|
|
892
|
+
schemaKey: { operationId: OP, kind: "response", status: 201 },
|
|
893
|
+
description: "Create client ID"
|
|
894
|
+
});
|
|
895
|
+
},
|
|
896
|
+
async findOne(id) {
|
|
897
|
+
const path = buildPath(`${PATH_BASE}/{id}`, { id });
|
|
898
|
+
const OP = "ClientIdV2Controller_findOne_v2";
|
|
899
|
+
return requestJson(http, {
|
|
900
|
+
operationId: OP,
|
|
901
|
+
method: "GET",
|
|
902
|
+
path,
|
|
903
|
+
schemaKey: { operationId: OP, kind: "response", status: 200 },
|
|
904
|
+
description: "Get client ID"
|
|
905
|
+
});
|
|
906
|
+
},
|
|
907
|
+
async update(id, body) {
|
|
908
|
+
const path = buildPath(`${PATH_BASE}/{id}`, { id });
|
|
909
|
+
const OP = "ClientIdV2Controller_update_v2";
|
|
910
|
+
return requestJson(http, {
|
|
911
|
+
operationId: OP,
|
|
912
|
+
method: "PUT",
|
|
913
|
+
path,
|
|
914
|
+
body,
|
|
915
|
+
requestSchemaKey: { operationId: OP, kind: "request", variant: "application/json" },
|
|
916
|
+
schemaKey: { operationId: OP, kind: "response", status: 200 },
|
|
917
|
+
description: "Update client ID"
|
|
918
|
+
});
|
|
919
|
+
},
|
|
920
|
+
async revoke(id) {
|
|
921
|
+
const path = buildPath(`${PATH_BASE}/{id}`, { id });
|
|
922
|
+
const OP = "ClientIdV2Controller_delete_v2";
|
|
923
|
+
await requestVoid(http, {
|
|
924
|
+
operationId: OP,
|
|
925
|
+
method: "DELETE",
|
|
926
|
+
path
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
var ErrorDetailSchema = z.object({
|
|
932
|
+
message: z.string(),
|
|
933
|
+
code: z.string().optional(),
|
|
934
|
+
field: z.string().optional(),
|
|
935
|
+
source: z.object({
|
|
936
|
+
pointer: z.string().optional(),
|
|
937
|
+
parameter: z.string().optional()
|
|
938
|
+
}).passthrough().optional(),
|
|
939
|
+
meta: z.record(z.unknown()).optional()
|
|
940
|
+
}).passthrough();
|
|
941
|
+
var ErrorEnvelopeSchema = z.object({
|
|
942
|
+
status: z.number().optional(),
|
|
943
|
+
statusCode: z.number().optional(),
|
|
944
|
+
code: z.string().optional(),
|
|
945
|
+
error: z.string().optional(),
|
|
946
|
+
message: z.union([
|
|
947
|
+
z.string(),
|
|
948
|
+
z.array(z.union([z.string(), ErrorDetailSchema])),
|
|
949
|
+
ErrorDetailSchema
|
|
950
|
+
]).optional(),
|
|
951
|
+
detail: z.unknown().optional(),
|
|
952
|
+
errors: z.array(ErrorDetailSchema).optional(),
|
|
953
|
+
requestId: z.string().optional(),
|
|
954
|
+
correlationId: z.string().optional(),
|
|
955
|
+
retryAfter: z.union([z.number(), z.string()]).optional(),
|
|
956
|
+
retryAfterMs: z.number().optional(),
|
|
957
|
+
meta: z.record(z.unknown()).optional()
|
|
958
|
+
}).passthrough();
|
|
959
|
+
var ClientIdV2Controller_findAll_v2_200 = z.array(z.object({ "id": z.string().optional(), "clientId": z.string().optional(), "label": z.string().optional(), "allowedDomains": z.array(z.string()).optional(), "status": z.string().optional(), "createdAt": z.string().optional(), "lastUsedAt": z.string().nullable().optional() }).passthrough());
|
|
960
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findAll_v2", kind: "response", status: 200 }, schema: ClientIdV2Controller_findAll_v2_200 });
|
|
961
|
+
var ClientIdV2Controller_findAll_v2_401 = ErrorEnvelopeSchema;
|
|
962
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findAll_v2", kind: "response", status: 401 }, schema: ClientIdV2Controller_findAll_v2_401 });
|
|
963
|
+
var ClientIdV2Controller_findAll_v2_429 = ErrorEnvelopeSchema;
|
|
964
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findAll_v2", kind: "response", status: 429 }, schema: ClientIdV2Controller_findAll_v2_429 });
|
|
965
|
+
var ClientIdV2Controller_create_v2_Request = z.object({ "label": z.string(), "allowedDomains": z.array(z.string()), "feePercentage": z.string().optional(), "feeAddress": z.string().optional() }).passthrough();
|
|
966
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_create_v2", kind: "request", variant: "application/json" }, schema: ClientIdV2Controller_create_v2_Request });
|
|
967
|
+
var ClientIdV2Controller_create_v2_201 = z.object({ "id": z.string().optional(), "clientId": z.string().optional(), "label": z.string().optional(), "allowedDomains": z.array(z.string()).optional(), "feePercentage": z.string().nullable().optional(), "feeAddress": z.string().nullable().optional(), "status": z.string().optional(), "createdAt": z.string().optional() }).passthrough();
|
|
968
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_create_v2", kind: "response", status: 201 }, schema: ClientIdV2Controller_create_v2_201 });
|
|
969
|
+
var ClientIdV2Controller_create_v2_400 = ErrorEnvelopeSchema;
|
|
970
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_create_v2", kind: "response", status: 400 }, schema: ClientIdV2Controller_create_v2_400 });
|
|
971
|
+
var ClientIdV2Controller_create_v2_401 = ErrorEnvelopeSchema;
|
|
972
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_create_v2", kind: "response", status: 401 }, schema: ClientIdV2Controller_create_v2_401 });
|
|
973
|
+
var ClientIdV2Controller_create_v2_429 = ErrorEnvelopeSchema;
|
|
974
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_create_v2", kind: "response", status: 429 }, schema: ClientIdV2Controller_create_v2_429 });
|
|
975
|
+
var ClientIdV2Controller_findOne_v2_200 = z.object({ "id": z.string().optional(), "clientId": z.string().optional(), "label": z.string().optional(), "allowedDomains": z.array(z.string()).optional(), "feePercentage": z.string().nullable().optional(), "feeAddress": z.string().nullable().optional(), "status": z.string().optional(), "createdAt": z.string().optional(), "updatedAt": z.string().optional(), "lastUsedAt": z.string().nullable().optional() }).passthrough();
|
|
976
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findOne_v2", kind: "response", status: 200 }, schema: ClientIdV2Controller_findOne_v2_200 });
|
|
977
|
+
var ClientIdV2Controller_findOne_v2_401 = ErrorEnvelopeSchema;
|
|
978
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findOne_v2", kind: "response", status: 401 }, schema: ClientIdV2Controller_findOne_v2_401 });
|
|
979
|
+
var ClientIdV2Controller_findOne_v2_404 = ErrorEnvelopeSchema;
|
|
980
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findOne_v2", kind: "response", status: 404 }, schema: ClientIdV2Controller_findOne_v2_404 });
|
|
981
|
+
var ClientIdV2Controller_findOne_v2_429 = ErrorEnvelopeSchema;
|
|
982
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_findOne_v2", kind: "response", status: 429 }, schema: ClientIdV2Controller_findOne_v2_429 });
|
|
983
|
+
var ClientIdV2Controller_update_v2_Request = z.object({ "label": z.string().optional(), "allowedDomains": z.array(z.string()).optional(), "feePercentage": z.string().nullable().optional(), "feeAddress": z.string().nullable().optional(), "status": z.enum(["active", "inactive", "revoked"]).optional() }).passthrough();
|
|
984
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_update_v2", kind: "request", variant: "application/json" }, schema: ClientIdV2Controller_update_v2_Request });
|
|
985
|
+
var ClientIdV2Controller_update_v2_200 = z.object({ "id": z.string().optional(), "clientId": z.string().optional(), "label": z.string().optional(), "allowedDomains": z.array(z.string()).optional(), "feePercentage": z.string().nullable().optional(), "feeAddress": z.string().nullable().optional(), "status": z.string().optional(), "updatedAt": z.string().optional() }).passthrough();
|
|
986
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_update_v2", kind: "response", status: 200 }, schema: ClientIdV2Controller_update_v2_200 });
|
|
987
|
+
var ClientIdV2Controller_update_v2_400 = ErrorEnvelopeSchema;
|
|
988
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_update_v2", kind: "response", status: 400 }, schema: ClientIdV2Controller_update_v2_400 });
|
|
989
|
+
var ClientIdV2Controller_update_v2_401 = ErrorEnvelopeSchema;
|
|
990
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_update_v2", kind: "response", status: 401 }, schema: ClientIdV2Controller_update_v2_401 });
|
|
991
|
+
var ClientIdV2Controller_update_v2_404 = ErrorEnvelopeSchema;
|
|
992
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_update_v2", kind: "response", status: 404 }, schema: ClientIdV2Controller_update_v2_404 });
|
|
993
|
+
var ClientIdV2Controller_update_v2_429 = ErrorEnvelopeSchema;
|
|
994
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_update_v2", kind: "response", status: 429 }, schema: ClientIdV2Controller_update_v2_429 });
|
|
995
|
+
var ClientIdV2Controller_delete_v2_200 = z.unknown();
|
|
996
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_delete_v2", kind: "response", status: 200 }, schema: ClientIdV2Controller_delete_v2_200 });
|
|
997
|
+
var ClientIdV2Controller_delete_v2_401 = ErrorEnvelopeSchema;
|
|
998
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_delete_v2", kind: "response", status: 401 }, schema: ClientIdV2Controller_delete_v2_401 });
|
|
999
|
+
var ClientIdV2Controller_delete_v2_404 = ErrorEnvelopeSchema;
|
|
1000
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_delete_v2", kind: "response", status: 404 }, schema: ClientIdV2Controller_delete_v2_404 });
|
|
1001
|
+
var ClientIdV2Controller_delete_v2_429 = ErrorEnvelopeSchema;
|
|
1002
|
+
schemaRegistry.register({ key: { operationId: "ClientIdV2Controller_delete_v2", kind: "response", status: 429 }, schema: ClientIdV2Controller_delete_v2_429 });
|
|
1003
|
+
|
|
1004
|
+
// src/domains/currencies/index.ts
|
|
1005
|
+
var currencies_exports = {};
|
|
1006
|
+
__export(currencies_exports, {
|
|
1007
|
+
createCurrenciesApi: () => createCurrenciesApi,
|
|
1008
|
+
createCurrenciesV1Api: () => createCurrenciesV1Api
|
|
1009
|
+
});
|
|
1010
|
+
var ErrorDetailSchema2 = z.object({
|
|
1011
|
+
message: z.string(),
|
|
1012
|
+
code: z.string().optional(),
|
|
1013
|
+
field: z.string().optional(),
|
|
1014
|
+
source: z.object({
|
|
1015
|
+
pointer: z.string().optional(),
|
|
1016
|
+
parameter: z.string().optional()
|
|
1017
|
+
}).passthrough().optional(),
|
|
1018
|
+
meta: z.record(z.unknown()).optional()
|
|
1019
|
+
}).passthrough();
|
|
1020
|
+
var ErrorEnvelopeSchema2 = z.object({
|
|
1021
|
+
status: z.number().optional(),
|
|
1022
|
+
statusCode: z.number().optional(),
|
|
1023
|
+
code: z.string().optional(),
|
|
1024
|
+
error: z.string().optional(),
|
|
1025
|
+
message: z.union([
|
|
1026
|
+
z.string(),
|
|
1027
|
+
z.array(z.union([z.string(), ErrorDetailSchema2])),
|
|
1028
|
+
ErrorDetailSchema2
|
|
1029
|
+
]).optional(),
|
|
1030
|
+
detail: z.unknown().optional(),
|
|
1031
|
+
errors: z.array(ErrorDetailSchema2).optional(),
|
|
1032
|
+
requestId: z.string().optional(),
|
|
1033
|
+
correlationId: z.string().optional(),
|
|
1034
|
+
retryAfter: z.union([z.number(), z.string()]).optional(),
|
|
1035
|
+
retryAfterMs: z.number().optional(),
|
|
1036
|
+
meta: z.record(z.unknown()).optional()
|
|
1037
|
+
}).passthrough();
|
|
1038
|
+
var CurrenciesV1Controller_getNetworkTokens_v1_200 = z.unknown();
|
|
1039
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getNetworkTokens_v1", kind: "response", status: 200 }, schema: CurrenciesV1Controller_getNetworkTokens_v1_200 });
|
|
1040
|
+
var CurrenciesV1Controller_getNetworkTokens_v1_400 = ErrorEnvelopeSchema2;
|
|
1041
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getNetworkTokens_v1", kind: "response", status: 400 }, schema: CurrenciesV1Controller_getNetworkTokens_v1_400 });
|
|
1042
|
+
var CurrenciesV1Controller_getNetworkTokens_v1_404 = ErrorEnvelopeSchema2;
|
|
1043
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getNetworkTokens_v1", kind: "response", status: 404 }, schema: CurrenciesV1Controller_getNetworkTokens_v1_404 });
|
|
1044
|
+
var CurrenciesV1Controller_getNetworkTokens_v1_429 = ErrorEnvelopeSchema2;
|
|
1045
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getNetworkTokens_v1", kind: "response", status: 429 }, schema: CurrenciesV1Controller_getNetworkTokens_v1_429 });
|
|
1046
|
+
var CurrenciesV1Controller_getConversionRoutes_v1_200 = z.unknown();
|
|
1047
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getConversionRoutes_v1", kind: "response", status: 200 }, schema: CurrenciesV1Controller_getConversionRoutes_v1_200 });
|
|
1048
|
+
var CurrenciesV1Controller_getConversionRoutes_v1_404 = ErrorEnvelopeSchema2;
|
|
1049
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getConversionRoutes_v1", kind: "response", status: 404 }, schema: CurrenciesV1Controller_getConversionRoutes_v1_404 });
|
|
1050
|
+
var CurrenciesV1Controller_getConversionRoutes_v1_429 = ErrorEnvelopeSchema2;
|
|
1051
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV1Controller_getConversionRoutes_v1", kind: "response", status: 429 }, schema: CurrenciesV1Controller_getConversionRoutes_v1_429 });
|
|
1052
|
+
var CurrenciesV2Controller_getNetworkTokens_v2_200 = z.unknown();
|
|
1053
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getNetworkTokens_v2", kind: "response", status: 200 }, schema: CurrenciesV2Controller_getNetworkTokens_v2_200 });
|
|
1054
|
+
var CurrenciesV2Controller_getNetworkTokens_v2_400 = ErrorEnvelopeSchema2;
|
|
1055
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getNetworkTokens_v2", kind: "response", status: 400 }, schema: CurrenciesV2Controller_getNetworkTokens_v2_400 });
|
|
1056
|
+
var CurrenciesV2Controller_getNetworkTokens_v2_404 = ErrorEnvelopeSchema2;
|
|
1057
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getNetworkTokens_v2", kind: "response", status: 404 }, schema: CurrenciesV2Controller_getNetworkTokens_v2_404 });
|
|
1058
|
+
var CurrenciesV2Controller_getNetworkTokens_v2_429 = ErrorEnvelopeSchema2;
|
|
1059
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getNetworkTokens_v2", kind: "response", status: 429 }, schema: CurrenciesV2Controller_getNetworkTokens_v2_429 });
|
|
1060
|
+
var CurrenciesV2Controller_getConversionRoutes_v2_200 = z.unknown();
|
|
1061
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getConversionRoutes_v2", kind: "response", status: 200 }, schema: CurrenciesV2Controller_getConversionRoutes_v2_200 });
|
|
1062
|
+
var CurrenciesV2Controller_getConversionRoutes_v2_404 = ErrorEnvelopeSchema2;
|
|
1063
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getConversionRoutes_v2", kind: "response", status: 404 }, schema: CurrenciesV2Controller_getConversionRoutes_v2_404 });
|
|
1064
|
+
var CurrenciesV2Controller_getConversionRoutes_v2_429 = ErrorEnvelopeSchema2;
|
|
1065
|
+
schemaRegistry.register({ key: { operationId: "CurrenciesV2Controller_getConversionRoutes_v2", kind: "response", status: 429 }, schema: CurrenciesV2Controller_getConversionRoutes_v2_429 });
|
|
1066
|
+
|
|
1067
|
+
// src/domains/currencies/currencies.schemas.ts
|
|
1068
|
+
var OP_LIST = "CurrenciesV2Controller_getNetworkTokens_v2";
|
|
1069
|
+
var OP_CONVERSION_ROUTES = "CurrenciesV2Controller_getConversionRoutes_v2";
|
|
1070
|
+
var CurrencyTokenSchema = z.object({
|
|
1071
|
+
id: z.string(),
|
|
1072
|
+
name: z.string(),
|
|
1073
|
+
symbol: z.string(),
|
|
1074
|
+
decimals: z.number(),
|
|
1075
|
+
address: z.string().optional(),
|
|
1076
|
+
network: z.string().optional(),
|
|
1077
|
+
type: z.string().optional(),
|
|
1078
|
+
hash: z.string().optional(),
|
|
1079
|
+
chainId: z.number().optional()
|
|
1080
|
+
}).passthrough();
|
|
1081
|
+
var CurrenciesListSchema = z.array(CurrencyTokenSchema);
|
|
1082
|
+
var ConversionRoutesSchema = z.object({
|
|
1083
|
+
currencyId: z.string(),
|
|
1084
|
+
network: z.string().nullable().optional(),
|
|
1085
|
+
conversionRoutes: z.array(CurrencyTokenSchema)
|
|
1086
|
+
}).passthrough();
|
|
1087
|
+
schemaRegistry.register({ key: { operationId: OP_LIST, kind: "response", status: 200 }, schema: CurrenciesListSchema });
|
|
1088
|
+
schemaRegistry.register({ key: { operationId: OP_CONVERSION_ROUTES, kind: "response", status: 200 }, schema: ConversionRoutesSchema });
|
|
1089
|
+
|
|
1090
|
+
// src/domains/currencies/v1/index.ts
|
|
1091
|
+
var v1_exports = {};
|
|
1092
|
+
__export(v1_exports, {
|
|
1093
|
+
createCurrenciesV1Api: () => createCurrenciesV1Api
|
|
1094
|
+
});
|
|
1095
|
+
var OP_LIST_V1 = "CurrenciesV1Controller_getNetworkTokens_v1";
|
|
1096
|
+
var OP_CONVERSION_ROUTES_V1 = "CurrenciesV1Controller_getConversionRoutes_v1";
|
|
1097
|
+
var DESCRIPTION_LIST = "Legacy currencies list";
|
|
1098
|
+
var DESCRIPTION_CONVERSION_ROUTES = "Legacy conversion routes";
|
|
1099
|
+
var CurrenciesV1ListSchema = z.union([CurrenciesListSchema, CurrencyTokenSchema]);
|
|
1100
|
+
schemaRegistry.register({ key: { operationId: OP_LIST_V1, kind: "response", status: 200 }, schema: CurrenciesV1ListSchema });
|
|
1101
|
+
schemaRegistry.register({
|
|
1102
|
+
key: { operationId: OP_CONVERSION_ROUTES_V1, kind: "response", status: 200 },
|
|
1103
|
+
schema: ConversionRoutesSchema
|
|
1104
|
+
});
|
|
1105
|
+
var DESCRIPTIONS = {
|
|
1106
|
+
list: DESCRIPTION_LIST,
|
|
1107
|
+
conversionRoutes: DESCRIPTION_CONVERSION_ROUTES
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// src/domains/currencies/v1/currencies.v1.facade.ts
|
|
1111
|
+
var CURRENCIES_V1_PATH = "/v1/currencies";
|
|
1112
|
+
var CONVERSION_ROUTES_SEGMENT = "conversion-routes";
|
|
1113
|
+
function toQuery(input) {
|
|
1114
|
+
return input;
|
|
1115
|
+
}
|
|
1116
|
+
function createCurrenciesV1Api(http) {
|
|
1117
|
+
return {
|
|
1118
|
+
async list(query, options) {
|
|
1119
|
+
const data = await requestJson(http, {
|
|
1120
|
+
operationId: OP_LIST_V1,
|
|
1121
|
+
method: "GET",
|
|
1122
|
+
path: CURRENCIES_V1_PATH,
|
|
1123
|
+
query: toQuery(query ?? void 0),
|
|
1124
|
+
schemaKey: { operationId: OP_LIST_V1, kind: "response", status: 200 },
|
|
1125
|
+
description: DESCRIPTIONS.list,
|
|
1126
|
+
signal: options?.signal,
|
|
1127
|
+
timeoutMs: options?.timeoutMs,
|
|
1128
|
+
validation: options?.validation
|
|
1129
|
+
});
|
|
1130
|
+
const parsed = parseWithSchema({
|
|
1131
|
+
schema: CurrenciesV1ListSchema,
|
|
1132
|
+
value: data,
|
|
1133
|
+
description: DESCRIPTIONS.list
|
|
1134
|
+
});
|
|
1135
|
+
if (!parsed.success) throw parsed.error;
|
|
1136
|
+
const payload = parsed.data;
|
|
1137
|
+
const tokens = Array.isArray(payload) ? payload : [payload];
|
|
1138
|
+
return tokens;
|
|
1139
|
+
},
|
|
1140
|
+
async getConversionRoutes(currencyId, query, options) {
|
|
1141
|
+
const path = `${CURRENCIES_V1_PATH}/${encodeURIComponent(currencyId)}/${CONVERSION_ROUTES_SEGMENT}`;
|
|
1142
|
+
const data = await requestJson(http, {
|
|
1143
|
+
operationId: OP_CONVERSION_ROUTES_V1,
|
|
1144
|
+
method: "GET",
|
|
1145
|
+
path,
|
|
1146
|
+
query: toQuery(query ?? void 0),
|
|
1147
|
+
schemaKey: { operationId: OP_CONVERSION_ROUTES_V1, kind: "response", status: 200 },
|
|
1148
|
+
description: DESCRIPTIONS.conversionRoutes,
|
|
1149
|
+
signal: options?.signal,
|
|
1150
|
+
timeoutMs: options?.timeoutMs,
|
|
1151
|
+
validation: options?.validation
|
|
1152
|
+
});
|
|
1153
|
+
const parsed = parseWithSchema({
|
|
1154
|
+
schema: ConversionRoutesSchema,
|
|
1155
|
+
value: data,
|
|
1156
|
+
description: DESCRIPTIONS.conversionRoutes
|
|
1157
|
+
});
|
|
1158
|
+
if (!parsed.success) throw parsed.error;
|
|
1159
|
+
return parsed.data;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// src/domains/currencies/currencies.facade.ts
|
|
1165
|
+
var CURRENCIES_PATH = "/v2/currencies";
|
|
1166
|
+
var CONVERSION_ROUTES_SEGMENT2 = "conversion-routes";
|
|
1167
|
+
var DESCRIPTION_LIST2 = "Currencies list";
|
|
1168
|
+
var DESCRIPTION_CONVERSION_ROUTES2 = "Conversion routes";
|
|
1169
|
+
function createCurrenciesApi(http) {
|
|
1170
|
+
const legacy = createCurrenciesV1Api(http);
|
|
1171
|
+
function toQuery2(input) {
|
|
1172
|
+
return input;
|
|
1173
|
+
}
|
|
1174
|
+
return {
|
|
1175
|
+
legacy,
|
|
1176
|
+
async list(query, options) {
|
|
1177
|
+
const data = await requestJson(http, {
|
|
1178
|
+
operationId: OP_LIST,
|
|
1179
|
+
method: "GET",
|
|
1180
|
+
path: CURRENCIES_PATH,
|
|
1181
|
+
query: toQuery2(query ?? void 0),
|
|
1182
|
+
schemaKey: { operationId: OP_LIST, kind: "response", status: 200 },
|
|
1183
|
+
description: DESCRIPTION_LIST2,
|
|
1184
|
+
signal: options?.signal,
|
|
1185
|
+
timeoutMs: options?.timeoutMs,
|
|
1186
|
+
validation: options?.validation
|
|
1187
|
+
});
|
|
1188
|
+
const parsed = parseWithSchema({
|
|
1189
|
+
schema: CurrenciesListSchema,
|
|
1190
|
+
value: data,
|
|
1191
|
+
description: DESCRIPTION_LIST2
|
|
1192
|
+
});
|
|
1193
|
+
if (!parsed.success) throw parsed.error;
|
|
1194
|
+
const list = parsed.data;
|
|
1195
|
+
return list;
|
|
1196
|
+
},
|
|
1197
|
+
async getConversionRoutes(currencyId, query, options) {
|
|
1198
|
+
const path = `${CURRENCIES_PATH}/${encodeURIComponent(currencyId)}/${CONVERSION_ROUTES_SEGMENT2}`;
|
|
1199
|
+
const data = await requestJson(http, {
|
|
1200
|
+
operationId: OP_CONVERSION_ROUTES,
|
|
1201
|
+
method: "GET",
|
|
1202
|
+
path,
|
|
1203
|
+
query: toQuery2(query ?? void 0),
|
|
1204
|
+
schemaKey: { operationId: OP_CONVERSION_ROUTES, kind: "response", status: 200 },
|
|
1205
|
+
description: DESCRIPTION_CONVERSION_ROUTES2,
|
|
1206
|
+
signal: options?.signal,
|
|
1207
|
+
timeoutMs: options?.timeoutMs,
|
|
1208
|
+
validation: options?.validation
|
|
1209
|
+
});
|
|
1210
|
+
const parsed = parseWithSchema({
|
|
1211
|
+
schema: ConversionRoutesSchema,
|
|
1212
|
+
value: data,
|
|
1213
|
+
description: DESCRIPTION_CONVERSION_ROUTES2
|
|
1214
|
+
});
|
|
1215
|
+
if (!parsed.success) throw parsed.error;
|
|
1216
|
+
const routes = parsed.data;
|
|
1217
|
+
return routes;
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// src/domains/pay/index.ts
|
|
1223
|
+
var pay_exports = {};
|
|
1224
|
+
__export(pay_exports, {
|
|
1225
|
+
createPayApi: () => createPayApi,
|
|
1226
|
+
createPayV1Api: () => createPayV1Api
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1229
|
+
// src/domains/pay/v1/index.ts
|
|
1230
|
+
var v1_exports2 = {};
|
|
1231
|
+
__export(v1_exports2, {
|
|
1232
|
+
createPayV1Api: () => createPayV1Api
|
|
1233
|
+
});
|
|
1234
|
+
|
|
1235
|
+
// src/domains/pay/v1/pay.v1.facade.ts
|
|
1236
|
+
var OP_PAY_REQUEST = "PayV1Controller_payRequest_v1";
|
|
1237
|
+
var PAY_PATH = "/v1/pay";
|
|
1238
|
+
var DESCRIPTION_PAY_REQUEST = "Legacy pay request";
|
|
1239
|
+
function createPayV1Api(http) {
|
|
1240
|
+
return {
|
|
1241
|
+
async payRequest(body, options) {
|
|
1242
|
+
return requestJson(http, {
|
|
1243
|
+
operationId: OP_PAY_REQUEST,
|
|
1244
|
+
method: "POST",
|
|
1245
|
+
path: PAY_PATH,
|
|
1246
|
+
body,
|
|
1247
|
+
requestSchemaKey: { operationId: OP_PAY_REQUEST, kind: "request", variant: "application/json" },
|
|
1248
|
+
schemaKey: { operationId: OP_PAY_REQUEST, kind: "response", status: 201 },
|
|
1249
|
+
description: DESCRIPTION_PAY_REQUEST,
|
|
1250
|
+
signal: options?.signal,
|
|
1251
|
+
timeoutMs: options?.timeoutMs,
|
|
1252
|
+
validation: options?.validation,
|
|
1253
|
+
meta: options?.meta
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
var ErrorDetailSchema3 = z.object({
|
|
1259
|
+
message: z.string(),
|
|
1260
|
+
code: z.string().optional(),
|
|
1261
|
+
field: z.string().optional(),
|
|
1262
|
+
source: z.object({
|
|
1263
|
+
pointer: z.string().optional(),
|
|
1264
|
+
parameter: z.string().optional()
|
|
1265
|
+
}).passthrough().optional(),
|
|
1266
|
+
meta: z.record(z.unknown()).optional()
|
|
1267
|
+
}).passthrough();
|
|
1268
|
+
var ErrorEnvelopeSchema3 = z.object({
|
|
1269
|
+
status: z.number().optional(),
|
|
1270
|
+
statusCode: z.number().optional(),
|
|
1271
|
+
code: z.string().optional(),
|
|
1272
|
+
error: z.string().optional(),
|
|
1273
|
+
message: z.union([
|
|
1274
|
+
z.string(),
|
|
1275
|
+
z.array(z.union([z.string(), ErrorDetailSchema3])),
|
|
1276
|
+
ErrorDetailSchema3
|
|
1277
|
+
]).optional(),
|
|
1278
|
+
detail: z.unknown().optional(),
|
|
1279
|
+
errors: z.array(ErrorDetailSchema3).optional(),
|
|
1280
|
+
requestId: z.string().optional(),
|
|
1281
|
+
correlationId: z.string().optional(),
|
|
1282
|
+
retryAfter: z.union([z.number(), z.string()]).optional(),
|
|
1283
|
+
retryAfterMs: z.number().optional(),
|
|
1284
|
+
meta: z.record(z.unknown()).optional()
|
|
1285
|
+
}).passthrough();
|
|
1286
|
+
var PayV1Controller_payRequest_v1_Request = z.object({ "payee": z.string(), "amount": z.string(), "invoiceCurrency": z.string(), "paymentCurrency": z.string() }).passthrough();
|
|
1287
|
+
schemaRegistry.register({ key: { operationId: "PayV1Controller_payRequest_v1", kind: "request", variant: "application/json" }, schema: PayV1Controller_payRequest_v1_Request });
|
|
1288
|
+
var PayV1Controller_payRequest_v1_201 = z.object({ "requestId": z.string() }).passthrough();
|
|
1289
|
+
schemaRegistry.register({ key: { operationId: "PayV1Controller_payRequest_v1", kind: "response", status: 201 }, schema: PayV1Controller_payRequest_v1_201 });
|
|
1290
|
+
var PayV1Controller_payRequest_v1_401 = ErrorEnvelopeSchema3;
|
|
1291
|
+
schemaRegistry.register({ key: { operationId: "PayV1Controller_payRequest_v1", kind: "response", status: 401 }, schema: PayV1Controller_payRequest_v1_401 });
|
|
1292
|
+
var PayV1Controller_payRequest_v1_404 = ErrorEnvelopeSchema3;
|
|
1293
|
+
schemaRegistry.register({ key: { operationId: "PayV1Controller_payRequest_v1", kind: "response", status: 404 }, schema: PayV1Controller_payRequest_v1_404 });
|
|
1294
|
+
var PayV1Controller_payRequest_v1_429 = ErrorEnvelopeSchema3;
|
|
1295
|
+
schemaRegistry.register({ key: { operationId: "PayV1Controller_payRequest_v1", kind: "response", status: 429 }, schema: PayV1Controller_payRequest_v1_429 });
|
|
1296
|
+
var PayoutV2Controller_payRequest_v2_Request = z.object({ "payee": z.string(), "amount": z.string(), "invoiceCurrency": z.string(), "paymentCurrency": z.string(), "feePercentage": z.string().optional(), "feeAddress": z.string().optional(), "recurrence": z.object({ "startDate": z.string(), "frequency": z.enum(["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]), "totalPayments": z.number(), "payer": z.string() }).passthrough().optional(), "payerWallet": z.string().optional(), "customerInfo": z.object({ "firstName": z.string().optional(), "lastName": z.string().optional(), "email": z.string().optional(), "address": z.object({ "street": z.string().optional(), "city": z.string().optional(), "state": z.string().optional(), "postalCode": z.string().optional(), "country": z.string().optional() }).passthrough().optional() }).passthrough().optional(), "reference": z.string().optional() }).passthrough();
|
|
1297
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payRequest_v2", kind: "request", variant: "application/json" }, schema: PayoutV2Controller_payRequest_v2_Request });
|
|
1298
|
+
var PayoutV2Controller_payRequest_v2_201 = z.object({ "requestId": z.string() }).passthrough();
|
|
1299
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payRequest_v2", kind: "response", status: 201 }, schema: PayoutV2Controller_payRequest_v2_201 });
|
|
1300
|
+
var PayoutV2Controller_payRequest_v2_404 = ErrorEnvelopeSchema3;
|
|
1301
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payRequest_v2", kind: "response", status: 404 }, schema: PayoutV2Controller_payRequest_v2_404 });
|
|
1302
|
+
var PayoutV2Controller_payRequest_v2_429 = ErrorEnvelopeSchema3;
|
|
1303
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payRequest_v2", kind: "response", status: 429 }, schema: PayoutV2Controller_payRequest_v2_429 });
|
|
1304
|
+
var PayoutV2Controller_payBatchRequest_v2_Request = z.object({ "requests": z.array(z.object({ "payee": z.string(), "amount": z.string(), "invoiceCurrency": z.string(), "paymentCurrency": z.string() }).passthrough()).optional(), "requestIds": z.array(z.string()).optional(), "payer": z.string().optional() }).passthrough();
|
|
1305
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payBatchRequest_v2", kind: "request", variant: "application/json" }, schema: PayoutV2Controller_payBatchRequest_v2_Request });
|
|
1306
|
+
var PayoutV2Controller_payBatchRequest_v2_201 = z.object({ "ERC20ApprovalTransactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.number() }).passthrough()).optional(), "ERC20BatchPaymentTransaction": z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]), "hex": z.string() }).passthrough() }).passthrough().optional(), "ETHBatchPaymentTransaction": z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]), "hex": z.string() }).passthrough() }).passthrough().optional() }).passthrough();
|
|
1307
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payBatchRequest_v2", kind: "response", status: 201 }, schema: PayoutV2Controller_payBatchRequest_v2_201 });
|
|
1308
|
+
var PayoutV2Controller_payBatchRequest_v2_400 = ErrorEnvelopeSchema3;
|
|
1309
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payBatchRequest_v2", kind: "response", status: 400 }, schema: PayoutV2Controller_payBatchRequest_v2_400 });
|
|
1310
|
+
var PayoutV2Controller_payBatchRequest_v2_429 = ErrorEnvelopeSchema3;
|
|
1311
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_payBatchRequest_v2", kind: "response", status: 429 }, schema: PayoutV2Controller_payBatchRequest_v2_429 });
|
|
1312
|
+
var PayoutV2Controller_getRecurringPaymentStatus_v2_200 = z.unknown();
|
|
1313
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_getRecurringPaymentStatus_v2", kind: "response", status: 200 }, schema: PayoutV2Controller_getRecurringPaymentStatus_v2_200 });
|
|
1314
|
+
var PayoutV2Controller_getRecurringPaymentStatus_v2_404 = ErrorEnvelopeSchema3;
|
|
1315
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_getRecurringPaymentStatus_v2", kind: "response", status: 404 }, schema: PayoutV2Controller_getRecurringPaymentStatus_v2_404 });
|
|
1316
|
+
var PayoutV2Controller_getRecurringPaymentStatus_v2_429 = ErrorEnvelopeSchema3;
|
|
1317
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_getRecurringPaymentStatus_v2", kind: "response", status: 429 }, schema: PayoutV2Controller_getRecurringPaymentStatus_v2_429 });
|
|
1318
|
+
var PayoutV2Controller_submitRecurringPaymentSignature_v2_Request = z.object({ "permitSignature": z.string() }).passthrough();
|
|
1319
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_submitRecurringPaymentSignature_v2", kind: "request", variant: "application/json" }, schema: PayoutV2Controller_submitRecurringPaymentSignature_v2_Request });
|
|
1320
|
+
var PayoutV2Controller_submitRecurringPaymentSignature_v2_201 = z.unknown();
|
|
1321
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_submitRecurringPaymentSignature_v2", kind: "response", status: 201 }, schema: PayoutV2Controller_submitRecurringPaymentSignature_v2_201 });
|
|
1322
|
+
var PayoutV2Controller_submitRecurringPaymentSignature_v2_400 = ErrorEnvelopeSchema3;
|
|
1323
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_submitRecurringPaymentSignature_v2", kind: "response", status: 400 }, schema: PayoutV2Controller_submitRecurringPaymentSignature_v2_400 });
|
|
1324
|
+
var PayoutV2Controller_submitRecurringPaymentSignature_v2_404 = ErrorEnvelopeSchema3;
|
|
1325
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_submitRecurringPaymentSignature_v2", kind: "response", status: 404 }, schema: PayoutV2Controller_submitRecurringPaymentSignature_v2_404 });
|
|
1326
|
+
var PayoutV2Controller_submitRecurringPaymentSignature_v2_429 = ErrorEnvelopeSchema3;
|
|
1327
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_submitRecurringPaymentSignature_v2", kind: "response", status: 429 }, schema: PayoutV2Controller_submitRecurringPaymentSignature_v2_429 });
|
|
1328
|
+
var PayoutV2Controller_updateRecurringPayment_v2_Request = z.object({ "action": z.enum(["cancel", "unpause"]) }).passthrough();
|
|
1329
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_updateRecurringPayment_v2", kind: "request", variant: "application/json" }, schema: PayoutV2Controller_updateRecurringPayment_v2_Request });
|
|
1330
|
+
var PayoutV2Controller_updateRecurringPayment_v2_200 = z.unknown();
|
|
1331
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_updateRecurringPayment_v2", kind: "response", status: 200 }, schema: PayoutV2Controller_updateRecurringPayment_v2_200 });
|
|
1332
|
+
var PayoutV2Controller_updateRecurringPayment_v2_400 = ErrorEnvelopeSchema3;
|
|
1333
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_updateRecurringPayment_v2", kind: "response", status: 400 }, schema: PayoutV2Controller_updateRecurringPayment_v2_400 });
|
|
1334
|
+
var PayoutV2Controller_updateRecurringPayment_v2_404 = ErrorEnvelopeSchema3;
|
|
1335
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_updateRecurringPayment_v2", kind: "response", status: 404 }, schema: PayoutV2Controller_updateRecurringPayment_v2_404 });
|
|
1336
|
+
var PayoutV2Controller_updateRecurringPayment_v2_429 = ErrorEnvelopeSchema3;
|
|
1337
|
+
schemaRegistry.register({ key: { operationId: "PayoutV2Controller_updateRecurringPayment_v2", kind: "response", status: 429 }, schema: PayoutV2Controller_updateRecurringPayment_v2_429 });
|
|
1338
|
+
|
|
1339
|
+
// src/domains/pay/pay.facade.ts
|
|
1340
|
+
function createPayApi(http) {
|
|
1341
|
+
const legacy = createPayV1Api(http);
|
|
1342
|
+
return {
|
|
1343
|
+
...legacy,
|
|
1344
|
+
legacy
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// src/domains/payer/index.ts
|
|
1349
|
+
var payer_exports = {};
|
|
1350
|
+
__export(payer_exports, {
|
|
1351
|
+
createPayerApi: () => createPayerApi,
|
|
1352
|
+
createPayerV1Api: () => createPayerV1Api,
|
|
1353
|
+
createPayerV2Api: () => createPayerV2Api
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
// src/domains/payer/v1/index.ts
|
|
1357
|
+
var v1_exports3 = {};
|
|
1358
|
+
__export(v1_exports3, {
|
|
1359
|
+
createPayerV1Api: () => createPayerV1Api
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
// src/domains/payer/v1/payer.v1.facade.ts
|
|
1363
|
+
var OP_CREATE_COMPLIANCE = "PayerV1Controller_getComplianceData_v1";
|
|
1364
|
+
var OP_GET_STATUS = "PayerV1Controller_getComplianceStatus_v1";
|
|
1365
|
+
var OP_UPDATE_STATUS = "PayerV1Controller_updateComplianceStatus_v1";
|
|
1366
|
+
var OP_CREATE_PAYMENT_DETAILS = "PayerV1Controller_createPaymentDetails_v1";
|
|
1367
|
+
var OP_GET_PAYMENT_DETAILS = "PayerV1Controller_getPaymentDetails_v1";
|
|
1368
|
+
function createPayerV1Api(http) {
|
|
1369
|
+
return {
|
|
1370
|
+
async createComplianceData(body, options) {
|
|
1371
|
+
return requestJson(http, {
|
|
1372
|
+
operationId: OP_CREATE_COMPLIANCE,
|
|
1373
|
+
method: "POST",
|
|
1374
|
+
path: "/v1/payer",
|
|
1375
|
+
body,
|
|
1376
|
+
requestSchemaKey: { operationId: OP_CREATE_COMPLIANCE, kind: "request", variant: "application/json" },
|
|
1377
|
+
schemaKey: { operationId: OP_CREATE_COMPLIANCE, kind: "response", status: 200 },
|
|
1378
|
+
description: "Legacy create compliance data",
|
|
1379
|
+
signal: options?.signal,
|
|
1380
|
+
timeoutMs: options?.timeoutMs,
|
|
1381
|
+
validation: options?.validation,
|
|
1382
|
+
meta: options?.meta
|
|
1383
|
+
});
|
|
1384
|
+
},
|
|
1385
|
+
async getComplianceStatus(clientUserId, options) {
|
|
1386
|
+
const path = `/v1/payer/${encodeURIComponent(clientUserId)}`;
|
|
1387
|
+
return requestJson(http, {
|
|
1388
|
+
operationId: OP_GET_STATUS,
|
|
1389
|
+
method: "GET",
|
|
1390
|
+
path,
|
|
1391
|
+
schemaKey: { operationId: OP_GET_STATUS, kind: "response", status: 200 },
|
|
1392
|
+
description: "Legacy get compliance status",
|
|
1393
|
+
signal: options?.signal,
|
|
1394
|
+
timeoutMs: options?.timeoutMs,
|
|
1395
|
+
validation: options?.validation,
|
|
1396
|
+
meta: options?.meta
|
|
1397
|
+
});
|
|
1398
|
+
},
|
|
1399
|
+
async updateComplianceStatus(clientUserId, body, options) {
|
|
1400
|
+
const path = `/v1/payer/${encodeURIComponent(clientUserId)}`;
|
|
1401
|
+
return requestJson(http, {
|
|
1402
|
+
operationId: OP_UPDATE_STATUS,
|
|
1403
|
+
method: "PATCH",
|
|
1404
|
+
path,
|
|
1405
|
+
body,
|
|
1406
|
+
requestSchemaKey: { operationId: OP_UPDATE_STATUS, kind: "request", variant: "application/json" },
|
|
1407
|
+
schemaKey: { operationId: OP_UPDATE_STATUS, kind: "response", status: 200 },
|
|
1408
|
+
description: "Legacy update compliance status",
|
|
1409
|
+
signal: options?.signal,
|
|
1410
|
+
timeoutMs: options?.timeoutMs,
|
|
1411
|
+
validation: options?.validation,
|
|
1412
|
+
meta: options?.meta
|
|
1413
|
+
});
|
|
1414
|
+
},
|
|
1415
|
+
async createPaymentDetails(clientUserId, body, options) {
|
|
1416
|
+
const path = `/v1/payer/${encodeURIComponent(clientUserId)}/payment-details`;
|
|
1417
|
+
return requestJson(http, {
|
|
1418
|
+
operationId: OP_CREATE_PAYMENT_DETAILS,
|
|
1419
|
+
method: "POST",
|
|
1420
|
+
path,
|
|
1421
|
+
body,
|
|
1422
|
+
requestSchemaKey: { operationId: OP_CREATE_PAYMENT_DETAILS, kind: "request", variant: "application/json" },
|
|
1423
|
+
schemaKey: { operationId: OP_CREATE_PAYMENT_DETAILS, kind: "response", status: 201 },
|
|
1424
|
+
description: "Legacy create payment details",
|
|
1425
|
+
signal: options?.signal,
|
|
1426
|
+
timeoutMs: options?.timeoutMs,
|
|
1427
|
+
validation: options?.validation,
|
|
1428
|
+
meta: options?.meta
|
|
1429
|
+
});
|
|
1430
|
+
},
|
|
1431
|
+
async getPaymentDetails(clientUserId, options) {
|
|
1432
|
+
const path = `/v1/payer/${encodeURIComponent(clientUserId)}/payment-details`;
|
|
1433
|
+
return requestJson(http, {
|
|
1434
|
+
operationId: OP_GET_PAYMENT_DETAILS,
|
|
1435
|
+
method: "GET",
|
|
1436
|
+
path,
|
|
1437
|
+
schemaKey: { operationId: OP_GET_PAYMENT_DETAILS, kind: "response", status: 200 },
|
|
1438
|
+
description: "Legacy get payment details",
|
|
1439
|
+
signal: options?.signal,
|
|
1440
|
+
timeoutMs: options?.timeoutMs,
|
|
1441
|
+
validation: options?.validation,
|
|
1442
|
+
meta: options?.meta
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
var ErrorDetailSchema4 = z.object({
|
|
1448
|
+
message: z.string(),
|
|
1449
|
+
code: z.string().optional(),
|
|
1450
|
+
field: z.string().optional(),
|
|
1451
|
+
source: z.object({
|
|
1452
|
+
pointer: z.string().optional(),
|
|
1453
|
+
parameter: z.string().optional()
|
|
1454
|
+
}).passthrough().optional(),
|
|
1455
|
+
meta: z.record(z.unknown()).optional()
|
|
1456
|
+
}).passthrough();
|
|
1457
|
+
var ErrorEnvelopeSchema4 = z.object({
|
|
1458
|
+
status: z.number().optional(),
|
|
1459
|
+
statusCode: z.number().optional(),
|
|
1460
|
+
code: z.string().optional(),
|
|
1461
|
+
error: z.string().optional(),
|
|
1462
|
+
message: z.union([
|
|
1463
|
+
z.string(),
|
|
1464
|
+
z.array(z.union([z.string(), ErrorDetailSchema4])),
|
|
1465
|
+
ErrorDetailSchema4
|
|
1466
|
+
]).optional(),
|
|
1467
|
+
detail: z.unknown().optional(),
|
|
1468
|
+
errors: z.array(ErrorDetailSchema4).optional(),
|
|
1469
|
+
requestId: z.string().optional(),
|
|
1470
|
+
correlationId: z.string().optional(),
|
|
1471
|
+
retryAfter: z.union([z.number(), z.string()]).optional(),
|
|
1472
|
+
retryAfterMs: z.number().optional(),
|
|
1473
|
+
meta: z.record(z.unknown()).optional()
|
|
1474
|
+
}).passthrough();
|
|
1475
|
+
var PayerV1Controller_getComplianceData_v1_Request = z.object({ "clientUserId": z.string(), "email": z.string(), "firstName": z.string(), "lastName": z.string(), "beneficiaryType": z.enum(["individual", "business"]), "companyName": z.string().optional(), "dateOfBirth": z.string(), "addressLine1": z.string(), "addressLine2": z.string().optional(), "city": z.string(), "state": z.string(), "postcode": z.string(), "country": z.string(), "nationality": z.string(), "phone": z.string(), "ssn": z.string(), "sourceOfFunds": z.string().optional(), "businessActivity": z.string().optional() }).passthrough();
|
|
1476
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceData_v1", kind: "request", variant: "application/json" }, schema: PayerV1Controller_getComplianceData_v1_Request });
|
|
1477
|
+
var PayerV1Controller_getComplianceData_v1_200 = z.object({ "agreementUrl": z.string().optional(), "kycUrl": z.string().optional(), "status": z.object({ "agreementStatus": z.enum(["not_started", "completed"]), "kycStatus": z.enum(["not_started", "completed"]) }).passthrough(), "userId": z.string().optional() }).passthrough();
|
|
1478
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceData_v1", kind: "response", status: 200 }, schema: PayerV1Controller_getComplianceData_v1_200 });
|
|
1479
|
+
var PayerV1Controller_getComplianceData_v1_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1480
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceData_v1", kind: "response", status: 400 }, schema: PayerV1Controller_getComplianceData_v1_400 });
|
|
1481
|
+
var PayerV1Controller_getComplianceData_v1_401 = ErrorEnvelopeSchema4;
|
|
1482
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceData_v1", kind: "response", status: 401 }, schema: PayerV1Controller_getComplianceData_v1_401 });
|
|
1483
|
+
var PayerV1Controller_getComplianceData_v1_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1484
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceData_v1", kind: "response", status: 404 }, schema: PayerV1Controller_getComplianceData_v1_404 });
|
|
1485
|
+
var PayerV1Controller_getComplianceData_v1_429 = ErrorEnvelopeSchema4;
|
|
1486
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceData_v1", kind: "response", status: 429 }, schema: PayerV1Controller_getComplianceData_v1_429 });
|
|
1487
|
+
var PayerV1Controller_getComplianceStatus_v1_200 = z.object({ "kycStatus": z.string().optional(), "agreementStatus": z.string().optional(), "isCompliant": z.boolean().optional(), "userId": z.string().optional() }).passthrough();
|
|
1488
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceStatus_v1", kind: "response", status: 200 }, schema: PayerV1Controller_getComplianceStatus_v1_200 });
|
|
1489
|
+
var PayerV1Controller_getComplianceStatus_v1_401 = ErrorEnvelopeSchema4;
|
|
1490
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceStatus_v1", kind: "response", status: 401 }, schema: PayerV1Controller_getComplianceStatus_v1_401 });
|
|
1491
|
+
var PayerV1Controller_getComplianceStatus_v1_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1492
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceStatus_v1", kind: "response", status: 404 }, schema: PayerV1Controller_getComplianceStatus_v1_404 });
|
|
1493
|
+
var PayerV1Controller_getComplianceStatus_v1_429 = ErrorEnvelopeSchema4;
|
|
1494
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getComplianceStatus_v1", kind: "response", status: 429 }, schema: PayerV1Controller_getComplianceStatus_v1_429 });
|
|
1495
|
+
var PayerV1Controller_updateComplianceStatus_v1_Request = z.object({ "agreementCompleted": z.boolean() }).passthrough();
|
|
1496
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_updateComplianceStatus_v1", kind: "request", variant: "application/json" }, schema: PayerV1Controller_updateComplianceStatus_v1_Request });
|
|
1497
|
+
var PayerV1Controller_updateComplianceStatus_v1_200 = z.object({ "success": z.boolean().optional() }).passthrough();
|
|
1498
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_updateComplianceStatus_v1", kind: "response", status: 200 }, schema: PayerV1Controller_updateComplianceStatus_v1_200 });
|
|
1499
|
+
var PayerV1Controller_updateComplianceStatus_v1_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1500
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_updateComplianceStatus_v1", kind: "response", status: 400 }, schema: PayerV1Controller_updateComplianceStatus_v1_400 });
|
|
1501
|
+
var PayerV1Controller_updateComplianceStatus_v1_401 = ErrorEnvelopeSchema4;
|
|
1502
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_updateComplianceStatus_v1", kind: "response", status: 401 }, schema: PayerV1Controller_updateComplianceStatus_v1_401 });
|
|
1503
|
+
var PayerV1Controller_updateComplianceStatus_v1_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1504
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_updateComplianceStatus_v1", kind: "response", status: 404 }, schema: PayerV1Controller_updateComplianceStatus_v1_404 });
|
|
1505
|
+
var PayerV1Controller_updateComplianceStatus_v1_429 = ErrorEnvelopeSchema4;
|
|
1506
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_updateComplianceStatus_v1", kind: "response", status: 429 }, schema: PayerV1Controller_updateComplianceStatus_v1_429 });
|
|
1507
|
+
var PayerV1Controller_getPaymentDetails_v1_200 = z.object({ "paymentDetails": z.array(z.object({ "id": z.string().optional(), "userId": z.string().optional(), "bankName": z.string().optional(), "accountName": z.string().optional(), "beneficiaryType": z.string().optional(), "accountNumber": z.string().optional(), "routingNumber": z.string().optional(), "currency": z.string().optional(), "status": z.string().optional(), "rails": z.string().optional() }).passthrough()).optional() }).passthrough();
|
|
1508
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getPaymentDetails_v1", kind: "response", status: 200 }, schema: PayerV1Controller_getPaymentDetails_v1_200 });
|
|
1509
|
+
var PayerV1Controller_getPaymentDetails_v1_401 = ErrorEnvelopeSchema4;
|
|
1510
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getPaymentDetails_v1", kind: "response", status: 401 }, schema: PayerV1Controller_getPaymentDetails_v1_401 });
|
|
1511
|
+
var PayerV1Controller_getPaymentDetails_v1_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1512
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getPaymentDetails_v1", kind: "response", status: 404 }, schema: PayerV1Controller_getPaymentDetails_v1_404 });
|
|
1513
|
+
var PayerV1Controller_getPaymentDetails_v1_429 = ErrorEnvelopeSchema4;
|
|
1514
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_getPaymentDetails_v1", kind: "response", status: 429 }, schema: PayerV1Controller_getPaymentDetails_v1_429 });
|
|
1515
|
+
var PayerV1Controller_createPaymentDetails_v1_Request = z.object({ "bankName": z.string(), "accountName": z.string(), "accountNumber": z.string().optional(), "routingNumber": z.string().optional(), "beneficiaryType": z.enum(["individual", "business"]), "currency": z.string(), "addressLine1": z.string(), "addressLine2": z.string().optional(), "city": z.string(), "state": z.string().optional(), "country": z.string(), "dateOfBirth": z.string(), "postalCode": z.string(), "rails": z.enum(["local", "swift", "wire"]).optional(), "sortCode": z.string().optional(), "iban": z.string().optional(), "swiftBic": z.string().optional(), "documentNumber": z.string().optional(), "documentType": z.string().optional(), "accountType": z.enum(["checking", "savings"]).optional(), "ribNumber": z.string().optional(), "bsbNumber": z.string().optional(), "ncc": z.string().optional(), "branchCode": z.string().optional(), "bankCode": z.string().optional(), "ifsc": z.string().optional() }).passthrough();
|
|
1516
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_createPaymentDetails_v1", kind: "request", variant: "application/json" }, schema: PayerV1Controller_createPaymentDetails_v1_Request });
|
|
1517
|
+
var PayerV1Controller_createPaymentDetails_v1_201 = z.object({ "payment_detail": z.object({ "id": z.string().optional(), "clientUserId": z.string().optional(), "bankName": z.string().optional(), "accountName": z.string().optional(), "currency": z.string().optional(), "beneficiaryType": z.enum(["individual", "business"]).optional() }).passthrough().optional() }).passthrough();
|
|
1518
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_createPaymentDetails_v1", kind: "response", status: 201 }, schema: PayerV1Controller_createPaymentDetails_v1_201 });
|
|
1519
|
+
var PayerV1Controller_createPaymentDetails_v1_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1520
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_createPaymentDetails_v1", kind: "response", status: 400 }, schema: PayerV1Controller_createPaymentDetails_v1_400 });
|
|
1521
|
+
var PayerV1Controller_createPaymentDetails_v1_401 = ErrorEnvelopeSchema4;
|
|
1522
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_createPaymentDetails_v1", kind: "response", status: 401 }, schema: PayerV1Controller_createPaymentDetails_v1_401 });
|
|
1523
|
+
var PayerV1Controller_createPaymentDetails_v1_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1524
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_createPaymentDetails_v1", kind: "response", status: 404 }, schema: PayerV1Controller_createPaymentDetails_v1_404 });
|
|
1525
|
+
var PayerV1Controller_createPaymentDetails_v1_429 = ErrorEnvelopeSchema4;
|
|
1526
|
+
schemaRegistry.register({ key: { operationId: "PayerV1Controller_createPaymentDetails_v1", kind: "response", status: 429 }, schema: PayerV1Controller_createPaymentDetails_v1_429 });
|
|
1527
|
+
var PayerV2Controller_getComplianceData_v2_Request = z.object({ "clientUserId": z.string(), "email": z.string(), "firstName": z.string(), "lastName": z.string(), "beneficiaryType": z.enum(["individual", "business"]), "companyName": z.string().optional(), "dateOfBirth": z.string(), "addressLine1": z.string(), "addressLine2": z.string().optional(), "city": z.string(), "state": z.string(), "postcode": z.string(), "country": z.string(), "nationality": z.string(), "phone": z.string(), "ssn": z.string(), "sourceOfFunds": z.string().optional(), "businessActivity": z.string().optional() }).passthrough();
|
|
1528
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceData_v2", kind: "request", variant: "application/json" }, schema: PayerV2Controller_getComplianceData_v2_Request });
|
|
1529
|
+
var PayerV2Controller_getComplianceData_v2_200 = z.object({ "agreementUrl": z.string().optional(), "kycUrl": z.string().optional(), "status": z.object({ "agreementStatus": z.enum(["not_started", "completed"]), "kycStatus": z.enum(["not_started", "completed"]) }).passthrough(), "userId": z.string().optional() }).passthrough();
|
|
1530
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceData_v2", kind: "response", status: 200 }, schema: PayerV2Controller_getComplianceData_v2_200 });
|
|
1531
|
+
var PayerV2Controller_getComplianceData_v2_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1532
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceData_v2", kind: "response", status: 400 }, schema: PayerV2Controller_getComplianceData_v2_400 });
|
|
1533
|
+
var PayerV2Controller_getComplianceData_v2_401 = ErrorEnvelopeSchema4;
|
|
1534
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceData_v2", kind: "response", status: 401 }, schema: PayerV2Controller_getComplianceData_v2_401 });
|
|
1535
|
+
var PayerV2Controller_getComplianceData_v2_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1536
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceData_v2", kind: "response", status: 404 }, schema: PayerV2Controller_getComplianceData_v2_404 });
|
|
1537
|
+
var PayerV2Controller_getComplianceData_v2_429 = ErrorEnvelopeSchema4;
|
|
1538
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceData_v2", kind: "response", status: 429 }, schema: PayerV2Controller_getComplianceData_v2_429 });
|
|
1539
|
+
var PayerV2Controller_getComplianceStatus_v2_200 = z.object({ "kycStatus": z.string().optional(), "agreementStatus": z.string().optional(), "isCompliant": z.boolean().optional(), "userId": z.string().optional() }).passthrough();
|
|
1540
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceStatus_v2", kind: "response", status: 200 }, schema: PayerV2Controller_getComplianceStatus_v2_200 });
|
|
1541
|
+
var PayerV2Controller_getComplianceStatus_v2_401 = ErrorEnvelopeSchema4;
|
|
1542
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceStatus_v2", kind: "response", status: 401 }, schema: PayerV2Controller_getComplianceStatus_v2_401 });
|
|
1543
|
+
var PayerV2Controller_getComplianceStatus_v2_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1544
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceStatus_v2", kind: "response", status: 404 }, schema: PayerV2Controller_getComplianceStatus_v2_404 });
|
|
1545
|
+
var PayerV2Controller_getComplianceStatus_v2_429 = ErrorEnvelopeSchema4;
|
|
1546
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getComplianceStatus_v2", kind: "response", status: 429 }, schema: PayerV2Controller_getComplianceStatus_v2_429 });
|
|
1547
|
+
var PayerV2Controller_updateComplianceStatus_v2_Request = z.object({ "agreementCompleted": z.boolean() }).passthrough();
|
|
1548
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_updateComplianceStatus_v2", kind: "request", variant: "application/json" }, schema: PayerV2Controller_updateComplianceStatus_v2_Request });
|
|
1549
|
+
var PayerV2Controller_updateComplianceStatus_v2_200 = z.object({ "success": z.boolean().optional() }).passthrough();
|
|
1550
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_updateComplianceStatus_v2", kind: "response", status: 200 }, schema: PayerV2Controller_updateComplianceStatus_v2_200 });
|
|
1551
|
+
var PayerV2Controller_updateComplianceStatus_v2_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1552
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_updateComplianceStatus_v2", kind: "response", status: 400 }, schema: PayerV2Controller_updateComplianceStatus_v2_400 });
|
|
1553
|
+
var PayerV2Controller_updateComplianceStatus_v2_401 = ErrorEnvelopeSchema4;
|
|
1554
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_updateComplianceStatus_v2", kind: "response", status: 401 }, schema: PayerV2Controller_updateComplianceStatus_v2_401 });
|
|
1555
|
+
var PayerV2Controller_updateComplianceStatus_v2_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1556
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_updateComplianceStatus_v2", kind: "response", status: 404 }, schema: PayerV2Controller_updateComplianceStatus_v2_404 });
|
|
1557
|
+
var PayerV2Controller_updateComplianceStatus_v2_429 = ErrorEnvelopeSchema4;
|
|
1558
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_updateComplianceStatus_v2", kind: "response", status: 429 }, schema: PayerV2Controller_updateComplianceStatus_v2_429 });
|
|
1559
|
+
var PayerV2Controller_getPaymentDetails_v2_200 = z.object({ "paymentDetails": z.array(z.object({ "id": z.string().optional(), "userId": z.string().optional(), "bankName": z.string().optional(), "accountName": z.string().optional(), "beneficiaryType": z.string().optional(), "accountNumber": z.string().optional(), "routingNumber": z.string().optional(), "currency": z.string().optional(), "status": z.string().optional(), "rails": z.string().optional() }).passthrough()).optional() }).passthrough();
|
|
1560
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getPaymentDetails_v2", kind: "response", status: 200 }, schema: PayerV2Controller_getPaymentDetails_v2_200 });
|
|
1561
|
+
var PayerV2Controller_getPaymentDetails_v2_401 = ErrorEnvelopeSchema4;
|
|
1562
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getPaymentDetails_v2", kind: "response", status: 401 }, schema: PayerV2Controller_getPaymentDetails_v2_401 });
|
|
1563
|
+
var PayerV2Controller_getPaymentDetails_v2_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1564
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getPaymentDetails_v2", kind: "response", status: 404 }, schema: PayerV2Controller_getPaymentDetails_v2_404 });
|
|
1565
|
+
var PayerV2Controller_getPaymentDetails_v2_429 = ErrorEnvelopeSchema4;
|
|
1566
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_getPaymentDetails_v2", kind: "response", status: 429 }, schema: PayerV2Controller_getPaymentDetails_v2_429 });
|
|
1567
|
+
var PayerV2Controller_createPaymentDetails_v2_Request = z.object({ "bankName": z.string(), "accountName": z.string(), "accountNumber": z.string().optional(), "routingNumber": z.string().optional(), "beneficiaryType": z.enum(["individual", "business"]), "currency": z.string(), "addressLine1": z.string(), "addressLine2": z.string().optional(), "city": z.string(), "state": z.string().optional(), "country": z.string(), "dateOfBirth": z.string(), "postalCode": z.string(), "rails": z.enum(["local", "swift", "wire"]).optional(), "sortCode": z.string().optional(), "iban": z.string().optional(), "swiftBic": z.string().optional(), "documentNumber": z.string().optional(), "documentType": z.string().optional(), "accountType": z.enum(["checking", "savings"]).optional(), "ribNumber": z.string().optional(), "bsbNumber": z.string().optional(), "ncc": z.string().optional(), "branchCode": z.string().optional(), "bankCode": z.string().optional(), "ifsc": z.string().optional() }).passthrough();
|
|
1568
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_createPaymentDetails_v2", kind: "request", variant: "application/json" }, schema: PayerV2Controller_createPaymentDetails_v2_Request });
|
|
1569
|
+
var PayerV2Controller_createPaymentDetails_v2_201 = z.object({ "payment_detail": z.object({ "id": z.string().optional(), "clientUserId": z.string().optional(), "bankName": z.string().optional(), "accountName": z.string().optional(), "currency": z.string().optional(), "beneficiaryType": z.enum(["individual", "business"]).optional() }).passthrough().optional() }).passthrough();
|
|
1570
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_createPaymentDetails_v2", kind: "response", status: 201 }, schema: PayerV2Controller_createPaymentDetails_v2_201 });
|
|
1571
|
+
var PayerV2Controller_createPaymentDetails_v2_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1572
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_createPaymentDetails_v2", kind: "response", status: 400 }, schema: PayerV2Controller_createPaymentDetails_v2_400 });
|
|
1573
|
+
var PayerV2Controller_createPaymentDetails_v2_401 = ErrorEnvelopeSchema4;
|
|
1574
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_createPaymentDetails_v2", kind: "response", status: 401 }, schema: PayerV2Controller_createPaymentDetails_v2_401 });
|
|
1575
|
+
var PayerV2Controller_createPaymentDetails_v2_404 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1576
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_createPaymentDetails_v2", kind: "response", status: 404 }, schema: PayerV2Controller_createPaymentDetails_v2_404 });
|
|
1577
|
+
var PayerV2Controller_createPaymentDetails_v2_429 = ErrorEnvelopeSchema4;
|
|
1578
|
+
schemaRegistry.register({ key: { operationId: "PayerV2Controller_createPaymentDetails_v2", kind: "response", status: 429 }, schema: PayerV2Controller_createPaymentDetails_v2_429 });
|
|
1579
|
+
|
|
1580
|
+
// src/domains/payer/v2/index.ts
|
|
1581
|
+
var v2_exports = {};
|
|
1582
|
+
__export(v2_exports, {
|
|
1583
|
+
createPayerV2Api: () => createPayerV2Api
|
|
1584
|
+
});
|
|
1585
|
+
|
|
1586
|
+
// src/domains/payer/v2/payer.v2.facade.ts
|
|
1587
|
+
var OP_CREATE_COMPLIANCE2 = "PayerV2Controller_getComplianceData_v2";
|
|
1588
|
+
var OP_GET_STATUS2 = "PayerV2Controller_getComplianceStatus_v2";
|
|
1589
|
+
var OP_UPDATE_STATUS2 = "PayerV2Controller_updateComplianceStatus_v2";
|
|
1590
|
+
var OP_CREATE_PAYMENT_DETAILS2 = "PayerV2Controller_createPaymentDetails_v2";
|
|
1591
|
+
var OP_GET_PAYMENT_DETAILS2 = "PayerV2Controller_getPaymentDetails_v2";
|
|
1592
|
+
function createPayerV2Api(http) {
|
|
1593
|
+
return {
|
|
1594
|
+
async createComplianceData(body, options) {
|
|
1595
|
+
return requestJson(http, {
|
|
1596
|
+
operationId: OP_CREATE_COMPLIANCE2,
|
|
1597
|
+
method: "POST",
|
|
1598
|
+
path: "/v2/payer",
|
|
1599
|
+
body,
|
|
1600
|
+
requestSchemaKey: { operationId: OP_CREATE_COMPLIANCE2, kind: "request", variant: "application/json" },
|
|
1601
|
+
schemaKey: { operationId: OP_CREATE_COMPLIANCE2, kind: "response", status: 200 },
|
|
1602
|
+
description: "Create compliance data",
|
|
1603
|
+
signal: options?.signal,
|
|
1604
|
+
timeoutMs: options?.timeoutMs,
|
|
1605
|
+
validation: options?.validation,
|
|
1606
|
+
meta: options?.meta
|
|
1607
|
+
});
|
|
1608
|
+
},
|
|
1609
|
+
async getComplianceStatus(clientUserId, options) {
|
|
1610
|
+
const path = `/v2/payer/${encodeURIComponent(clientUserId)}`;
|
|
1611
|
+
return requestJson(http, {
|
|
1612
|
+
operationId: OP_GET_STATUS2,
|
|
1613
|
+
method: "GET",
|
|
1614
|
+
path,
|
|
1615
|
+
schemaKey: { operationId: OP_GET_STATUS2, kind: "response", status: 200 },
|
|
1616
|
+
description: "Get compliance status",
|
|
1617
|
+
signal: options?.signal,
|
|
1618
|
+
timeoutMs: options?.timeoutMs,
|
|
1619
|
+
validation: options?.validation,
|
|
1620
|
+
meta: options?.meta
|
|
1621
|
+
});
|
|
1622
|
+
},
|
|
1623
|
+
async updateComplianceStatus(clientUserId, body, options) {
|
|
1624
|
+
const path = `/v2/payer/${encodeURIComponent(clientUserId)}`;
|
|
1625
|
+
return requestJson(http, {
|
|
1626
|
+
operationId: OP_UPDATE_STATUS2,
|
|
1627
|
+
method: "PATCH",
|
|
1628
|
+
path,
|
|
1629
|
+
body,
|
|
1630
|
+
requestSchemaKey: { operationId: OP_UPDATE_STATUS2, kind: "request", variant: "application/json" },
|
|
1631
|
+
schemaKey: { operationId: OP_UPDATE_STATUS2, kind: "response", status: 200 },
|
|
1632
|
+
description: "Update compliance status",
|
|
1633
|
+
signal: options?.signal,
|
|
1634
|
+
timeoutMs: options?.timeoutMs,
|
|
1635
|
+
validation: options?.validation,
|
|
1636
|
+
meta: options?.meta
|
|
1637
|
+
});
|
|
1638
|
+
},
|
|
1639
|
+
async createPaymentDetails(clientUserId, body, options) {
|
|
1640
|
+
const path = `/v2/payer/${encodeURIComponent(clientUserId)}/payment-details`;
|
|
1641
|
+
return requestJson(http, {
|
|
1642
|
+
operationId: OP_CREATE_PAYMENT_DETAILS2,
|
|
1643
|
+
method: "POST",
|
|
1644
|
+
path,
|
|
1645
|
+
body,
|
|
1646
|
+
requestSchemaKey: { operationId: OP_CREATE_PAYMENT_DETAILS2, kind: "request", variant: "application/json" },
|
|
1647
|
+
schemaKey: { operationId: OP_CREATE_PAYMENT_DETAILS2, kind: "response", status: 201 },
|
|
1648
|
+
description: "Create payment details",
|
|
1649
|
+
signal: options?.signal,
|
|
1650
|
+
timeoutMs: options?.timeoutMs,
|
|
1651
|
+
validation: options?.validation,
|
|
1652
|
+
meta: options?.meta
|
|
1653
|
+
});
|
|
1654
|
+
},
|
|
1655
|
+
async getPaymentDetails(clientUserId, options) {
|
|
1656
|
+
const path = `/v2/payer/${encodeURIComponent(clientUserId)}/payment-details`;
|
|
1657
|
+
return requestJson(http, {
|
|
1658
|
+
operationId: OP_GET_PAYMENT_DETAILS2,
|
|
1659
|
+
method: "GET",
|
|
1660
|
+
path,
|
|
1661
|
+
schemaKey: { operationId: OP_GET_PAYMENT_DETAILS2, kind: "response", status: 200 },
|
|
1662
|
+
description: "Get payment details",
|
|
1663
|
+
signal: options?.signal,
|
|
1664
|
+
timeoutMs: options?.timeoutMs,
|
|
1665
|
+
validation: options?.validation,
|
|
1666
|
+
meta: options?.meta
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
// src/domains/payer/payer.facade.ts
|
|
1673
|
+
function createPayerApi(http) {
|
|
1674
|
+
const v2 = createPayerV2Api(http);
|
|
1675
|
+
const legacy = createPayerV1Api(http);
|
|
1676
|
+
return Object.assign({ legacy }, v2);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
// src/domains/payments/index.ts
|
|
1680
|
+
var payments_exports = {};
|
|
1681
|
+
__export(payments_exports, {
|
|
1682
|
+
createPaymentsApi: () => createPaymentsApi
|
|
1683
|
+
});
|
|
1684
|
+
var ErrorDetailSchema5 = z.object({
|
|
1685
|
+
message: z.string(),
|
|
1686
|
+
code: z.string().optional(),
|
|
1687
|
+
field: z.string().optional(),
|
|
1688
|
+
source: z.object({
|
|
1689
|
+
pointer: z.string().optional(),
|
|
1690
|
+
parameter: z.string().optional()
|
|
1691
|
+
}).passthrough().optional(),
|
|
1692
|
+
meta: z.record(z.unknown()).optional()
|
|
1693
|
+
}).passthrough();
|
|
1694
|
+
var ErrorEnvelopeSchema5 = z.object({
|
|
1695
|
+
status: z.number().optional(),
|
|
1696
|
+
statusCode: z.number().optional(),
|
|
1697
|
+
code: z.string().optional(),
|
|
1698
|
+
error: z.string().optional(),
|
|
1699
|
+
message: z.union([
|
|
1700
|
+
z.string(),
|
|
1701
|
+
z.array(z.union([z.string(), ErrorDetailSchema5])),
|
|
1702
|
+
ErrorDetailSchema5
|
|
1703
|
+
]).optional(),
|
|
1704
|
+
detail: z.unknown().optional(),
|
|
1705
|
+
errors: z.array(ErrorDetailSchema5).optional(),
|
|
1706
|
+
requestId: z.string().optional(),
|
|
1707
|
+
correlationId: z.string().optional(),
|
|
1708
|
+
retryAfter: z.union([z.number(), z.string()]).optional(),
|
|
1709
|
+
retryAfterMs: z.number().optional(),
|
|
1710
|
+
meta: z.record(z.unknown()).optional()
|
|
1711
|
+
}).passthrough();
|
|
1712
|
+
var PaymentV2Controller_searchPayments_v2_200 = z.object({ "payments": z.array(z.object({ "id": z.string(), "amount": z.string(), "sourceNetwork": z.string(), "destinationNetwork": z.string(), "sourceTxHash": z.string().nullable().optional(), "destinationTxHash": z.string().nullable().optional(), "timestamp": z.string(), "type": z.enum(["direct", "conversion", "crosschain", "recurring"]), "conversionRateSource": z.string().nullable().optional(), "conversionRateDestination": z.string().nullable().optional(), "convertedAmountSource": z.string().nullable().optional(), "convertedAmountDestination": z.string().nullable().optional(), "currency": z.string(), "paymentCurrency": z.string(), "fees": z.array(z.object({ "type": z.enum(["gas", "platform", "crosschain", "crypto-to-fiat", "offramp"]).optional(), "stage": z.enum(["sending", "receiving", "proxying", "refunding"]).optional(), "provider": z.string().optional(), "amount": z.string().optional(), "amountInUSD": z.string().optional(), "currency": z.string().optional(), "receiverAddress": z.string().optional(), "network": z.string().optional(), "rateProvider": z.string().optional() }).passthrough()).nullable().optional(), "recurringPaymentId": z.string().nullable().optional(), "rateProvider": z.enum(["lifi", "chainlink", "coingecko", "unknown"]).optional(), "request": z.object({ "requestId": z.string().optional(), "paymentReference": z.string().optional(), "hasBeenPaid": z.boolean().optional(), "customerInfo": z.object({ "firstName": z.string().optional(), "lastName": z.string().optional(), "email": z.string().optional(), "address": z.object({ "street": z.string().optional(), "city": z.string().optional(), "state": z.string().optional(), "postalCode": z.string().optional(), "country": z.string().optional() }).passthrough().optional() }).passthrough().nullable().optional(), "reference": z.string().nullable().optional() }).passthrough().optional() }).passthrough()), "pagination": z.object({ "total": z.number(), "limit": z.number(), "offset": z.number(), "hasMore": z.boolean() }).passthrough() }).passthrough();
|
|
1713
|
+
schemaRegistry.register({ key: { operationId: "PaymentV2Controller_searchPayments_v2", kind: "response", status: 200 }, schema: PaymentV2Controller_searchPayments_v2_200 });
|
|
1714
|
+
var PaymentV2Controller_searchPayments_v2_400 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "errors": z.array(z.object({ "field": z.string().optional(), "message": z.string().optional() }).passthrough()).optional() }).passthrough();
|
|
1715
|
+
schemaRegistry.register({ key: { operationId: "PaymentV2Controller_searchPayments_v2", kind: "response", status: 400 }, schema: PaymentV2Controller_searchPayments_v2_400 });
|
|
1716
|
+
var PaymentV2Controller_searchPayments_v2_401 = z.object({ "statusCode": z.number().optional(), "message": z.string().optional(), "error": z.string().optional() }).passthrough();
|
|
1717
|
+
schemaRegistry.register({ key: { operationId: "PaymentV2Controller_searchPayments_v2", kind: "response", status: 401 }, schema: PaymentV2Controller_searchPayments_v2_401 });
|
|
1718
|
+
var PaymentV2Controller_searchPayments_v2_429 = ErrorEnvelopeSchema5;
|
|
1719
|
+
schemaRegistry.register({ key: { operationId: "PaymentV2Controller_searchPayments_v2", kind: "response", status: 429 }, schema: PaymentV2Controller_searchPayments_v2_429 });
|
|
1720
|
+
|
|
1721
|
+
// src/domains/payments/payments.schemas.ts
|
|
1722
|
+
var OP_SEARCH_PAYMENTS = "PaymentV2Controller_searchPayments_v2";
|
|
1723
|
+
var AddressSchema = z.object({
|
|
1724
|
+
street: z.string().optional(),
|
|
1725
|
+
city: z.string().optional(),
|
|
1726
|
+
state: z.string().optional(),
|
|
1727
|
+
postalCode: z.string().optional(),
|
|
1728
|
+
country: z.string().optional()
|
|
1729
|
+
}).passthrough();
|
|
1730
|
+
var CustomerInfoSchema = z.object({
|
|
1731
|
+
firstName: z.string().optional(),
|
|
1732
|
+
lastName: z.string().optional(),
|
|
1733
|
+
email: z.string().optional(),
|
|
1734
|
+
address: AddressSchema.optional()
|
|
1735
|
+
}).passthrough();
|
|
1736
|
+
var FeeSchema = z.object({
|
|
1737
|
+
type: z.enum(["gas", "platform", "crosschain", "crypto-to-fiat", "offramp"]).optional(),
|
|
1738
|
+
stage: z.enum(["sending", "receiving", "proxying", "refunding"]).optional(),
|
|
1739
|
+
provider: z.string().optional(),
|
|
1740
|
+
amount: z.string().optional(),
|
|
1741
|
+
amountInUSD: z.string().optional(),
|
|
1742
|
+
currency: z.string().optional(),
|
|
1743
|
+
receiverAddress: z.string().optional(),
|
|
1744
|
+
network: z.string().optional(),
|
|
1745
|
+
rateProvider: z.string().optional()
|
|
1746
|
+
}).passthrough();
|
|
1747
|
+
var RequestInfoSchema = z.object({
|
|
1748
|
+
requestId: z.string().optional(),
|
|
1749
|
+
paymentReference: z.string().optional(),
|
|
1750
|
+
hasBeenPaid: z.boolean().optional(),
|
|
1751
|
+
customerInfo: CustomerInfoSchema.nullable().optional(),
|
|
1752
|
+
reference: z.string().nullable().optional()
|
|
1753
|
+
}).passthrough();
|
|
1754
|
+
var PaymentRecordSchema = z.object({
|
|
1755
|
+
id: z.string(),
|
|
1756
|
+
amount: z.string(),
|
|
1757
|
+
sourceNetwork: z.string(),
|
|
1758
|
+
destinationNetwork: z.string(),
|
|
1759
|
+
sourceTxHash: z.string().nullable().optional(),
|
|
1760
|
+
destinationTxHash: z.string().nullable().optional(),
|
|
1761
|
+
timestamp: z.string(),
|
|
1762
|
+
type: z.enum(["direct", "conversion", "crosschain", "recurring"]),
|
|
1763
|
+
conversionRateSource: z.string().nullable().optional(),
|
|
1764
|
+
conversionRateDestination: z.string().nullable().optional(),
|
|
1765
|
+
convertedAmountSource: z.string().nullable().optional(),
|
|
1766
|
+
convertedAmountDestination: z.string().nullable().optional(),
|
|
1767
|
+
currency: z.string(),
|
|
1768
|
+
paymentCurrency: z.string(),
|
|
1769
|
+
fees: z.array(FeeSchema).nullable().optional(),
|
|
1770
|
+
recurringPaymentId: z.string().nullable().optional(),
|
|
1771
|
+
rateProvider: z.enum(["lifi", "chainlink", "coingecko", "unknown"]).nullable().optional(),
|
|
1772
|
+
request: RequestInfoSchema.optional()
|
|
1773
|
+
}).passthrough();
|
|
1774
|
+
var PaginationSchema = z.object({
|
|
1775
|
+
total: z.number(),
|
|
1776
|
+
limit: z.number(),
|
|
1777
|
+
offset: z.number(),
|
|
1778
|
+
hasMore: z.boolean()
|
|
1779
|
+
}).passthrough();
|
|
1780
|
+
var PaymentSearchResponseSchema = z.object({
|
|
1781
|
+
payments: z.array(PaymentRecordSchema),
|
|
1782
|
+
pagination: PaginationSchema
|
|
1783
|
+
}).passthrough();
|
|
1784
|
+
schemaRegistry.register({
|
|
1785
|
+
key: { operationId: OP_SEARCH_PAYMENTS, kind: "response", status: 200 },
|
|
1786
|
+
schema: PaymentSearchResponseSchema
|
|
1787
|
+
});
|
|
1788
|
+
|
|
1789
|
+
// src/domains/requests/request.helpers.ts
|
|
1790
|
+
function buildRequestQuery(input) {
|
|
1791
|
+
if (!input) return void 0;
|
|
1792
|
+
const entries = Object.entries(input).filter(([, value]) => value !== void 0);
|
|
1793
|
+
if (entries.length === 0) return void 0;
|
|
1794
|
+
return Object.fromEntries(entries);
|
|
1795
|
+
}
|
|
1796
|
+
var STATUS_KIND_MAP = {
|
|
1797
|
+
paid: "paid",
|
|
1798
|
+
completed: "paid",
|
|
1799
|
+
settled: "paid",
|
|
1800
|
+
pending: "pending",
|
|
1801
|
+
processing: "pending",
|
|
1802
|
+
open: "pending",
|
|
1803
|
+
awaitingpayment: "pending",
|
|
1804
|
+
awaiting_payment: "pending",
|
|
1805
|
+
cancelled: "cancelled",
|
|
1806
|
+
canceled: "cancelled",
|
|
1807
|
+
voided: "cancelled",
|
|
1808
|
+
overdue: "overdue",
|
|
1809
|
+
expired: "overdue"
|
|
1810
|
+
};
|
|
1811
|
+
function normalizeReference(value) {
|
|
1812
|
+
if (value === void 0) return void 0;
|
|
1813
|
+
return value;
|
|
1814
|
+
}
|
|
1815
|
+
function normalizeCustomerInfo(value) {
|
|
1816
|
+
if (value === void 0) return void 0;
|
|
1817
|
+
if (value === null) return null;
|
|
1818
|
+
return {
|
|
1819
|
+
firstName: value.firstName ?? void 0,
|
|
1820
|
+
lastName: value.lastName ?? void 0,
|
|
1821
|
+
email: value.email ?? void 0,
|
|
1822
|
+
address: value.address ? {
|
|
1823
|
+
street: value.address.street ?? void 0,
|
|
1824
|
+
city: value.address.city ?? void 0,
|
|
1825
|
+
state: value.address.state ?? void 0,
|
|
1826
|
+
postalCode: value.address.postalCode ?? void 0,
|
|
1827
|
+
country: value.address.country ?? void 0
|
|
1828
|
+
} : void 0
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
function normalizePayments(payments) {
|
|
1832
|
+
if (!payments) return void 0;
|
|
1833
|
+
return payments.map((payment) => ({ ...payment }));
|
|
1834
|
+
}
|
|
1835
|
+
function buildStatusBase(raw, overrides) {
|
|
1836
|
+
return {
|
|
1837
|
+
paymentReference: raw.paymentReference ?? void 0,
|
|
1838
|
+
requestId: raw.requestId ?? void 0,
|
|
1839
|
+
isListening: "isListening" in raw ? raw.isListening ?? void 0 : void 0,
|
|
1840
|
+
txHash: raw.txHash ?? null,
|
|
1841
|
+
hasBeenPaid: raw.hasBeenPaid ?? false,
|
|
1842
|
+
status: "status" in raw ? raw.status ?? void 0 : void 0,
|
|
1843
|
+
recurrence: "recurrence" in raw ? raw.recurrence : void 0,
|
|
1844
|
+
originalRequestId: "originalRequestId" in raw ? raw.originalRequestId ?? void 0 : void 0,
|
|
1845
|
+
originalRequestPaymentReference: "originalRequestPaymentReference" in raw ? raw.originalRequestPaymentReference ?? void 0 : void 0,
|
|
1846
|
+
isRecurrenceStopped: "isRecurrenceStopped" in raw ? raw.isRecurrenceStopped ?? void 0 : void 0,
|
|
1847
|
+
isCryptoToFiatAvailable: "isCryptoToFiatAvailable" in raw ? raw.isCryptoToFiatAvailable ?? void 0 : void 0,
|
|
1848
|
+
payments: "payments" in raw ? normalizePayments(raw.payments) : void 0,
|
|
1849
|
+
customerInfo: "customerInfo" in raw ? normalizeCustomerInfo(
|
|
1850
|
+
raw.customerInfo
|
|
1851
|
+
) : void 0,
|
|
1852
|
+
reference: "reference" in raw ? normalizeReference(raw.reference ?? null) : void 0,
|
|
1853
|
+
...overrides
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
function normalizeLegacyStatusResponse(raw) {
|
|
1857
|
+
if (raw.hasBeenPaid) {
|
|
1858
|
+
return {
|
|
1859
|
+
kind: "paid",
|
|
1860
|
+
...buildStatusBase(raw, { hasBeenPaid: true }),
|
|
1861
|
+
hasBeenPaid: true
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
return {
|
|
1865
|
+
kind: "pending",
|
|
1866
|
+
...buildStatusBase(raw, { hasBeenPaid: false }),
|
|
1867
|
+
hasBeenPaid: false
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
function normalizeRequestStatusResponse(raw) {
|
|
1871
|
+
const statusKey = raw.status?.trim().toLowerCase();
|
|
1872
|
+
const mapped = statusKey ? STATUS_KIND_MAP[statusKey] : void 0;
|
|
1873
|
+
const kind = raw.hasBeenPaid ? "paid" : mapped ?? (statusKey ? "unknown" : "pending");
|
|
1874
|
+
if (kind === "paid") {
|
|
1875
|
+
return {
|
|
1876
|
+
kind,
|
|
1877
|
+
...buildStatusBase(raw, { hasBeenPaid: true }),
|
|
1878
|
+
hasBeenPaid: true
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
return {
|
|
1882
|
+
kind,
|
|
1883
|
+
...buildStatusBase(raw, { hasBeenPaid: false }),
|
|
1884
|
+
hasBeenPaid: false
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// src/domains/payments/payments.facade.ts
|
|
1889
|
+
function createPaymentsApi(http) {
|
|
1890
|
+
return {
|
|
1891
|
+
async search(query, options) {
|
|
1892
|
+
const requestQuery = buildRequestQuery(query ? { ...query } : void 0);
|
|
1893
|
+
return requestJson(http, {
|
|
1894
|
+
operationId: OP_SEARCH_PAYMENTS,
|
|
1895
|
+
method: "GET",
|
|
1896
|
+
path: "/v2/payments",
|
|
1897
|
+
query: requestQuery,
|
|
1898
|
+
schemaKey: { operationId: OP_SEARCH_PAYMENTS, kind: "response", status: 200 },
|
|
1899
|
+
description: "Search payments",
|
|
1900
|
+
signal: options?.signal,
|
|
1901
|
+
timeoutMs: options?.timeoutMs,
|
|
1902
|
+
validation: options?.validation,
|
|
1903
|
+
meta: options?.meta
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
// src/domains/payouts/index.ts
|
|
1910
|
+
var payouts_exports = {};
|
|
1911
|
+
__export(payouts_exports, {
|
|
1912
|
+
createPayoutsApi: () => createPayoutsApi
|
|
1913
|
+
});
|
|
1914
|
+
|
|
1915
|
+
// src/domains/payouts/payouts.facade.ts
|
|
1916
|
+
var OP_CREATE = "PayoutV2Controller_payRequest_v2";
|
|
1917
|
+
var OP_CREATE_BATCH = "PayoutV2Controller_payBatchRequest_v2";
|
|
1918
|
+
var OP_RECURRING_STATUS = "PayoutV2Controller_getRecurringPaymentStatus_v2";
|
|
1919
|
+
var OP_SUBMIT_SIGNATURE = "PayoutV2Controller_submitRecurringPaymentSignature_v2";
|
|
1920
|
+
var OP_UPDATE_RECURRING = "PayoutV2Controller_updateRecurringPayment_v2";
|
|
1921
|
+
function createPayoutsApi(http) {
|
|
1922
|
+
return {
|
|
1923
|
+
async create(body, options) {
|
|
1924
|
+
return requestJson(http, {
|
|
1925
|
+
operationId: OP_CREATE,
|
|
1926
|
+
method: "POST",
|
|
1927
|
+
path: "/v2/payouts",
|
|
1928
|
+
body,
|
|
1929
|
+
requestSchemaKey: { operationId: OP_CREATE, kind: "request", variant: "application/json" },
|
|
1930
|
+
schemaKey: { operationId: OP_CREATE, kind: "response", status: 201 },
|
|
1931
|
+
description: "Create payout",
|
|
1932
|
+
signal: options?.signal,
|
|
1933
|
+
timeoutMs: options?.timeoutMs,
|
|
1934
|
+
validation: options?.validation,
|
|
1935
|
+
meta: options?.meta
|
|
1936
|
+
});
|
|
1937
|
+
},
|
|
1938
|
+
async createBatch(body, options) {
|
|
1939
|
+
return requestJson(http, {
|
|
1940
|
+
operationId: OP_CREATE_BATCH,
|
|
1941
|
+
method: "POST",
|
|
1942
|
+
path: "/v2/payouts/batch",
|
|
1943
|
+
body,
|
|
1944
|
+
requestSchemaKey: { operationId: OP_CREATE_BATCH, kind: "request", variant: "application/json" },
|
|
1945
|
+
schemaKey: { operationId: OP_CREATE_BATCH, kind: "response", status: 201 },
|
|
1946
|
+
description: "Create payout batch",
|
|
1947
|
+
signal: options?.signal,
|
|
1948
|
+
timeoutMs: options?.timeoutMs,
|
|
1949
|
+
validation: options?.validation,
|
|
1950
|
+
meta: options?.meta
|
|
1951
|
+
});
|
|
1952
|
+
},
|
|
1953
|
+
async getRecurringStatus(recurringId, options) {
|
|
1954
|
+
const path = `/v2/payouts/recurring/${encodeURIComponent(recurringId)}`;
|
|
1955
|
+
return requestJson(http, {
|
|
1956
|
+
operationId: OP_RECURRING_STATUS,
|
|
1957
|
+
method: "GET",
|
|
1958
|
+
path,
|
|
1959
|
+
schemaKey: { operationId: OP_RECURRING_STATUS, kind: "response", status: 200 },
|
|
1960
|
+
description: "Get recurring payout status",
|
|
1961
|
+
signal: options?.signal,
|
|
1962
|
+
timeoutMs: options?.timeoutMs,
|
|
1963
|
+
validation: options?.validation,
|
|
1964
|
+
meta: options?.meta
|
|
1965
|
+
});
|
|
1966
|
+
},
|
|
1967
|
+
async submitRecurringSignature(recurringId, body, options) {
|
|
1968
|
+
const path = `/v2/payouts/recurring/${encodeURIComponent(recurringId)}`;
|
|
1969
|
+
return requestJson(http, {
|
|
1970
|
+
operationId: OP_SUBMIT_SIGNATURE,
|
|
1971
|
+
method: "POST",
|
|
1972
|
+
path,
|
|
1973
|
+
body,
|
|
1974
|
+
requestSchemaKey: { operationId: OP_SUBMIT_SIGNATURE, kind: "request", variant: "application/json" },
|
|
1975
|
+
schemaKey: { operationId: OP_SUBMIT_SIGNATURE, kind: "response", status: 201 },
|
|
1976
|
+
description: "Submit recurring payout signature",
|
|
1977
|
+
signal: options?.signal,
|
|
1978
|
+
timeoutMs: options?.timeoutMs,
|
|
1979
|
+
validation: options?.validation,
|
|
1980
|
+
meta: options?.meta
|
|
1981
|
+
});
|
|
1982
|
+
},
|
|
1983
|
+
async updateRecurring(recurringId, body, options) {
|
|
1984
|
+
const path = `/v2/payouts/recurring/${encodeURIComponent(recurringId)}`;
|
|
1985
|
+
return requestJson(http, {
|
|
1986
|
+
operationId: OP_UPDATE_RECURRING,
|
|
1987
|
+
method: "PATCH",
|
|
1988
|
+
path,
|
|
1989
|
+
body,
|
|
1990
|
+
requestSchemaKey: { operationId: OP_UPDATE_RECURRING, kind: "request", variant: "application/json" },
|
|
1991
|
+
schemaKey: { operationId: OP_UPDATE_RECURRING, kind: "response", status: 200 },
|
|
1992
|
+
description: "Update recurring payout",
|
|
1993
|
+
signal: options?.signal,
|
|
1994
|
+
timeoutMs: options?.timeoutMs,
|
|
1995
|
+
validation: options?.validation,
|
|
1996
|
+
meta: options?.meta
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
// src/domains/requests/index.ts
|
|
2003
|
+
var requests_exports = {};
|
|
2004
|
+
__export(requests_exports, {
|
|
2005
|
+
createRequestsApi: () => createRequestsApi
|
|
2006
|
+
});
|
|
2007
|
+
|
|
2008
|
+
// src/domains/requests/requests.facade.ts
|
|
2009
|
+
var OP_CREATE2 = "RequestControllerV2_createRequest_v2";
|
|
2010
|
+
var OP_PAYMENT_ROUTES = "RequestControllerV2_getRequestPaymentRoutes_v2";
|
|
2011
|
+
var OP_PAYMENT_CALLDATA = "RequestControllerV2_getPaymentCalldata_v2";
|
|
2012
|
+
var OP_UPDATE = "RequestControllerV2_updateRequest_v2";
|
|
2013
|
+
var OP_SEND_PAYMENT_INTENT = "RequestControllerV2_sendPaymentIntent_v2";
|
|
2014
|
+
var OP_REQUEST_STATUS = "RequestControllerV2_getRequestStatus_v2";
|
|
2015
|
+
var KIND_CALLDATA = "calldata";
|
|
2016
|
+
var KIND_PAYMENT_INTENT = "paymentIntent";
|
|
2017
|
+
function isPaymentIntentPayload(payload) {
|
|
2018
|
+
return "paymentIntentId" in payload;
|
|
2019
|
+
}
|
|
2020
|
+
function isCalldataPayload(payload) {
|
|
2021
|
+
return "transactions" in payload;
|
|
2022
|
+
}
|
|
2023
|
+
function createRequestsApi(http) {
|
|
2024
|
+
return {
|
|
2025
|
+
async create(body, options) {
|
|
2026
|
+
return requestJson(http, {
|
|
2027
|
+
operationId: OP_CREATE2,
|
|
2028
|
+
method: "POST",
|
|
2029
|
+
path: "/v2/request",
|
|
2030
|
+
body,
|
|
2031
|
+
requestSchemaKey: { operationId: OP_CREATE2, kind: "request", variant: "application/json" },
|
|
2032
|
+
schemaKey: { operationId: OP_CREATE2, kind: "response", status: 201 },
|
|
2033
|
+
description: "Create request",
|
|
2034
|
+
signal: options?.signal,
|
|
2035
|
+
timeoutMs: options?.timeoutMs,
|
|
2036
|
+
validation: options?.validation,
|
|
2037
|
+
meta: options?.meta
|
|
2038
|
+
});
|
|
2039
|
+
},
|
|
2040
|
+
async getRequestStatus(requestId, options) {
|
|
2041
|
+
const path = `/v2/request/${encodeURIComponent(requestId)}`;
|
|
2042
|
+
const raw = await requestJson(http, {
|
|
2043
|
+
operationId: OP_REQUEST_STATUS,
|
|
2044
|
+
method: "GET",
|
|
2045
|
+
path,
|
|
2046
|
+
schemaKey: { operationId: OP_REQUEST_STATUS, kind: "response", status: 200 },
|
|
2047
|
+
description: "Request status",
|
|
2048
|
+
signal: options?.signal,
|
|
2049
|
+
timeoutMs: options?.timeoutMs,
|
|
2050
|
+
validation: options?.validation,
|
|
2051
|
+
meta: options?.meta
|
|
2052
|
+
});
|
|
2053
|
+
return normalizeRequestStatusResponse(raw);
|
|
2054
|
+
},
|
|
2055
|
+
async getPaymentRoutes(requestId, options) {
|
|
2056
|
+
const path = `/v2/request/${encodeURIComponent(requestId)}/routes`;
|
|
2057
|
+
return requestJson(http, {
|
|
2058
|
+
operationId: OP_PAYMENT_ROUTES,
|
|
2059
|
+
method: "GET",
|
|
2060
|
+
path,
|
|
2061
|
+
query: buildRequestQuery({
|
|
2062
|
+
wallet: options.wallet,
|
|
2063
|
+
amount: options.amount,
|
|
2064
|
+
feePercentage: options.feePercentage,
|
|
2065
|
+
feeAddress: options.feeAddress
|
|
2066
|
+
}),
|
|
2067
|
+
schemaKey: { operationId: OP_PAYMENT_ROUTES, kind: "response", status: 200 },
|
|
2068
|
+
description: "Payment routes",
|
|
2069
|
+
signal: options.signal,
|
|
2070
|
+
timeoutMs: options.timeoutMs,
|
|
2071
|
+
validation: options.validation,
|
|
2072
|
+
meta: options.meta
|
|
2073
|
+
});
|
|
2074
|
+
},
|
|
2075
|
+
async getPaymentCalldata(requestId, options) {
|
|
2076
|
+
const path = `/v2/request/${encodeURIComponent(requestId)}/pay`;
|
|
2077
|
+
const queryInput = {
|
|
2078
|
+
wallet: options?.wallet,
|
|
2079
|
+
chain: options?.chain,
|
|
2080
|
+
token: options?.token,
|
|
2081
|
+
amount: options?.amount,
|
|
2082
|
+
clientUserId: options?.clientUserId,
|
|
2083
|
+
paymentDetailsId: options?.paymentDetailsId,
|
|
2084
|
+
feePercentage: options?.feePercentage,
|
|
2085
|
+
feeAddress: options?.feeAddress
|
|
2086
|
+
};
|
|
2087
|
+
const raw = await requestJson(http, {
|
|
2088
|
+
operationId: OP_PAYMENT_CALLDATA,
|
|
2089
|
+
method: "GET",
|
|
2090
|
+
path,
|
|
2091
|
+
query: buildRequestQuery(queryInput),
|
|
2092
|
+
schemaKey: { operationId: OP_PAYMENT_CALLDATA, kind: "response", status: 200 },
|
|
2093
|
+
description: "Payment calldata",
|
|
2094
|
+
signal: options?.signal,
|
|
2095
|
+
timeoutMs: options?.timeoutMs,
|
|
2096
|
+
validation: options?.validation,
|
|
2097
|
+
meta: options?.meta
|
|
2098
|
+
});
|
|
2099
|
+
if (isCalldataPayload(raw)) {
|
|
2100
|
+
return { kind: KIND_CALLDATA, ...raw };
|
|
2101
|
+
}
|
|
2102
|
+
if (isPaymentIntentPayload(raw)) {
|
|
2103
|
+
return { kind: KIND_PAYMENT_INTENT, ...raw };
|
|
2104
|
+
}
|
|
2105
|
+
throw new ValidationError("Unexpected payment calldata response", raw);
|
|
2106
|
+
},
|
|
2107
|
+
async update(requestId, options) {
|
|
2108
|
+
const path = `/v2/request/${encodeURIComponent(requestId)}`;
|
|
2109
|
+
await requestVoid(http, {
|
|
2110
|
+
operationId: OP_UPDATE,
|
|
2111
|
+
method: "PATCH",
|
|
2112
|
+
path,
|
|
2113
|
+
signal: options?.signal,
|
|
2114
|
+
timeoutMs: options?.timeoutMs,
|
|
2115
|
+
validation: options?.validation,
|
|
2116
|
+
meta: options?.meta
|
|
2117
|
+
});
|
|
2118
|
+
},
|
|
2119
|
+
async sendPaymentIntent(paymentIntentId, body, options) {
|
|
2120
|
+
const path = `/v2/request/payment-intents/${encodeURIComponent(paymentIntentId)}`;
|
|
2121
|
+
await requestVoid(http, {
|
|
2122
|
+
operationId: OP_SEND_PAYMENT_INTENT,
|
|
2123
|
+
method: "POST",
|
|
2124
|
+
path,
|
|
2125
|
+
body,
|
|
2126
|
+
requestSchemaKey: { operationId: OP_SEND_PAYMENT_INTENT, kind: "request", variant: "application/json" },
|
|
2127
|
+
signal: options?.signal,
|
|
2128
|
+
timeoutMs: options?.timeoutMs,
|
|
2129
|
+
validation: options?.validation,
|
|
2130
|
+
meta: options?.meta
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
var ErrorDetailSchema6 = z.object({
|
|
2136
|
+
message: z.string(),
|
|
2137
|
+
code: z.string().optional(),
|
|
2138
|
+
field: z.string().optional(),
|
|
2139
|
+
source: z.object({
|
|
2140
|
+
pointer: z.string().optional(),
|
|
2141
|
+
parameter: z.string().optional()
|
|
2142
|
+
}).passthrough().optional(),
|
|
2143
|
+
meta: z.record(z.unknown()).optional()
|
|
2144
|
+
}).passthrough();
|
|
2145
|
+
var ErrorEnvelopeSchema6 = z.object({
|
|
2146
|
+
status: z.number().optional(),
|
|
2147
|
+
statusCode: z.number().optional(),
|
|
2148
|
+
code: z.string().optional(),
|
|
2149
|
+
error: z.string().optional(),
|
|
2150
|
+
message: z.union([
|
|
2151
|
+
z.string(),
|
|
2152
|
+
z.array(z.union([z.string(), ErrorDetailSchema6])),
|
|
2153
|
+
ErrorDetailSchema6
|
|
2154
|
+
]).optional(),
|
|
2155
|
+
detail: z.unknown().optional(),
|
|
2156
|
+
errors: z.array(ErrorDetailSchema6).optional(),
|
|
2157
|
+
requestId: z.string().optional(),
|
|
2158
|
+
correlationId: z.string().optional(),
|
|
2159
|
+
retryAfter: z.union([z.number(), z.string()]).optional(),
|
|
2160
|
+
retryAfterMs: z.number().optional(),
|
|
2161
|
+
meta: z.record(z.unknown()).optional()
|
|
2162
|
+
}).passthrough();
|
|
2163
|
+
var RequestControllerV1_createRequest_v1_Request = z.object({ "payer": z.string().optional(), "payee": z.string(), "amount": z.string(), "invoiceCurrency": z.string(), "paymentCurrency": z.string(), "recurrence": z.object({ "startDate": z.string(), "frequency": z.enum(["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]) }).passthrough().optional() }).passthrough();
|
|
2164
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_createRequest_v1", kind: "request", variant: "application/json" }, schema: RequestControllerV1_createRequest_v1_Request });
|
|
2165
|
+
var RequestControllerV1_createRequest_v1_201 = z.object({ "paymentReference": z.string().optional(), "requestID": z.string().optional() }).passthrough();
|
|
2166
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_createRequest_v1", kind: "response", status: 201 }, schema: RequestControllerV1_createRequest_v1_201 });
|
|
2167
|
+
var RequestControllerV1_createRequest_v1_400 = ErrorEnvelopeSchema6;
|
|
2168
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_createRequest_v1", kind: "response", status: 400 }, schema: RequestControllerV1_createRequest_v1_400 });
|
|
2169
|
+
var RequestControllerV1_createRequest_v1_401 = ErrorEnvelopeSchema6;
|
|
2170
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_createRequest_v1", kind: "response", status: 401 }, schema: RequestControllerV1_createRequest_v1_401 });
|
|
2171
|
+
var RequestControllerV1_createRequest_v1_404 = ErrorEnvelopeSchema6;
|
|
2172
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_createRequest_v1", kind: "response", status: 404 }, schema: RequestControllerV1_createRequest_v1_404 });
|
|
2173
|
+
var RequestControllerV1_createRequest_v1_429 = ErrorEnvelopeSchema6;
|
|
2174
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_createRequest_v1", kind: "response", status: 429 }, schema: RequestControllerV1_createRequest_v1_429 });
|
|
2175
|
+
var RequestControllerV1_getRequestStatus_v1_200 = z.object({ "hasBeenPaid": z.boolean().optional(), "paymentReference": z.string().optional(), "requestId": z.string().optional(), "isListening": z.boolean().optional(), "txHash": z.string().nullable().optional() }).passthrough();
|
|
2176
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestStatus_v1", kind: "response", status: 200 }, schema: RequestControllerV1_getRequestStatus_v1_200 });
|
|
2177
|
+
var RequestControllerV1_getRequestStatus_v1_401 = ErrorEnvelopeSchema6;
|
|
2178
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestStatus_v1", kind: "response", status: 401 }, schema: RequestControllerV1_getRequestStatus_v1_401 });
|
|
2179
|
+
var RequestControllerV1_getRequestStatus_v1_404 = ErrorEnvelopeSchema6;
|
|
2180
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestStatus_v1", kind: "response", status: 404 }, schema: RequestControllerV1_getRequestStatus_v1_404 });
|
|
2181
|
+
var RequestControllerV1_getRequestStatus_v1_429 = ErrorEnvelopeSchema6;
|
|
2182
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestStatus_v1", kind: "response", status: 429 }, schema: RequestControllerV1_getRequestStatus_v1_429 });
|
|
2183
|
+
var RequestControllerV1_stopRecurrenceRequest_v1_200 = z.unknown();
|
|
2184
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_stopRecurrenceRequest_v1", kind: "response", status: 200 }, schema: RequestControllerV1_stopRecurrenceRequest_v1_200 });
|
|
2185
|
+
var RequestControllerV1_stopRecurrenceRequest_v1_401 = ErrorEnvelopeSchema6;
|
|
2186
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_stopRecurrenceRequest_v1", kind: "response", status: 401 }, schema: RequestControllerV1_stopRecurrenceRequest_v1_401 });
|
|
2187
|
+
var RequestControllerV1_stopRecurrenceRequest_v1_404 = ErrorEnvelopeSchema6;
|
|
2188
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_stopRecurrenceRequest_v1", kind: "response", status: 404 }, schema: RequestControllerV1_stopRecurrenceRequest_v1_404 });
|
|
2189
|
+
var RequestControllerV1_stopRecurrenceRequest_v1_429 = ErrorEnvelopeSchema6;
|
|
2190
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_stopRecurrenceRequest_v1", kind: "response", status: 429 }, schema: RequestControllerV1_stopRecurrenceRequest_v1_429 });
|
|
2191
|
+
var RequestControllerV1_getPaymentCalldata_v1_200 = z.union([z.object({ "transactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]).optional(), "hex": z.string().optional() }).passthrough() }).passthrough()), "metadata": z.object({ "stepsRequired": z.number(), "needsApproval": z.boolean(), "approvalTransactionIndex": z.number().nullable().optional(), "hasEnoughBalance": z.boolean(), "hasEnoughGas": z.boolean() }).passthrough() }).passthrough(), z.object({ "paymentIntentId": z.string(), "paymentIntent": z.string(), "approvalPermitPayload": z.string().nullable().optional(), "approvalCalldata": z.object({ "to": z.string().optional(), "data": z.string().optional(), "value": z.string().optional() }).passthrough().nullable().optional(), "metadata": z.object({ "supportsEIP2612": z.boolean() }).passthrough() }).passthrough()]);
|
|
2192
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 200 }, schema: RequestControllerV1_getPaymentCalldata_v1_200 });
|
|
2193
|
+
var RequestControllerV1_getPaymentCalldata_v1_400 = ErrorEnvelopeSchema6;
|
|
2194
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 400 }, schema: RequestControllerV1_getPaymentCalldata_v1_400 });
|
|
2195
|
+
var RequestControllerV1_getPaymentCalldata_v1_401 = ErrorEnvelopeSchema6;
|
|
2196
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 401 }, schema: RequestControllerV1_getPaymentCalldata_v1_401 });
|
|
2197
|
+
var RequestControllerV1_getPaymentCalldata_v1_404 = ErrorEnvelopeSchema6;
|
|
2198
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 404 }, schema: RequestControllerV1_getPaymentCalldata_v1_404 });
|
|
2199
|
+
var RequestControllerV1_getPaymentCalldata_v1_429 = ErrorEnvelopeSchema6;
|
|
2200
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getPaymentCalldata_v1", kind: "response", status: 429 }, schema: RequestControllerV1_getPaymentCalldata_v1_429 });
|
|
2201
|
+
var RequestControllerV1_getRequestPaymentRoutes_v1_200 = z.object({ "routes": z.array(z.object({ "id": z.string(), "fee": z.number(), "feeBreakdown": z.array(z.object({ "type": z.enum(["gas", "platform", "crosschain", "crypto-to-fiat", "offramp"]).optional(), "stage": z.enum(["sending", "receiving", "proxying", "refunding", "overall"]).optional(), "provider": z.string().optional(), "amount": z.string().optional(), "amountInUSD": z.string().optional(), "currency": z.string().optional(), "receiverAddress": z.string().optional(), "network": z.string().optional(), "rateProvider": z.string().optional() }).passthrough()).optional(), "speed": z.union([z.string(), z.number()]), "price_impact": z.number().optional(), "chain": z.string(), "token": z.string() }).passthrough()) }).passthrough();
|
|
2202
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestPaymentRoutes_v1", kind: "response", status: 200 }, schema: RequestControllerV1_getRequestPaymentRoutes_v1_200 });
|
|
2203
|
+
var RequestControllerV1_getRequestPaymentRoutes_v1_400 = ErrorEnvelopeSchema6;
|
|
2204
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestPaymentRoutes_v1", kind: "response", status: 400 }, schema: RequestControllerV1_getRequestPaymentRoutes_v1_400 });
|
|
2205
|
+
var RequestControllerV1_getRequestPaymentRoutes_v1_401 = ErrorEnvelopeSchema6;
|
|
2206
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestPaymentRoutes_v1", kind: "response", status: 401 }, schema: RequestControllerV1_getRequestPaymentRoutes_v1_401 });
|
|
2207
|
+
var RequestControllerV1_getRequestPaymentRoutes_v1_404 = ErrorEnvelopeSchema6;
|
|
2208
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestPaymentRoutes_v1", kind: "response", status: 404 }, schema: RequestControllerV1_getRequestPaymentRoutes_v1_404 });
|
|
2209
|
+
var RequestControllerV1_getRequestPaymentRoutes_v1_429 = ErrorEnvelopeSchema6;
|
|
2210
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_getRequestPaymentRoutes_v1", kind: "response", status: 429 }, schema: RequestControllerV1_getRequestPaymentRoutes_v1_429 });
|
|
2211
|
+
var RequestControllerV1_sendPaymentIntent_v1_Request = z.object({ "signedPaymentIntent": z.object({ "signature": z.string(), "nonce": z.string(), "deadline": z.string() }).passthrough(), "signedApprovalPermit": z.object({ "signature": z.string(), "nonce": z.string(), "deadline": z.string() }).passthrough().optional() }).passthrough();
|
|
2212
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_sendPaymentIntent_v1", kind: "request", variant: "application/json" }, schema: RequestControllerV1_sendPaymentIntent_v1_Request });
|
|
2213
|
+
var RequestControllerV1_sendPaymentIntent_v1_401 = ErrorEnvelopeSchema6;
|
|
2214
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_sendPaymentIntent_v1", kind: "response", status: 401 }, schema: RequestControllerV1_sendPaymentIntent_v1_401 });
|
|
2215
|
+
var RequestControllerV1_sendPaymentIntent_v1_404 = ErrorEnvelopeSchema6;
|
|
2216
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_sendPaymentIntent_v1", kind: "response", status: 404 }, schema: RequestControllerV1_sendPaymentIntent_v1_404 });
|
|
2217
|
+
var RequestControllerV1_sendPaymentIntent_v1_429 = ErrorEnvelopeSchema6;
|
|
2218
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV1_sendPaymentIntent_v1", kind: "response", status: 429 }, schema: RequestControllerV1_sendPaymentIntent_v1_429 });
|
|
2219
|
+
var RequestControllerV2_createRequest_v2_Request = z.object({ "payer": z.string().optional(), "payee": z.string().optional(), "amount": z.string(), "invoiceCurrency": z.string(), "paymentCurrency": z.string(), "recurrence": z.object({ "startDate": z.string(), "frequency": z.enum(["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]) }).passthrough().optional(), "isCryptoToFiatAvailable": z.boolean().optional(), "customerInfo": z.object({ "firstName": z.string().optional(), "lastName": z.string().optional(), "email": z.string().optional(), "address": z.object({ "street": z.string().optional(), "city": z.string().optional(), "state": z.string().optional(), "postalCode": z.string().optional(), "country": z.string().optional() }).passthrough().optional() }).passthrough().optional(), "reference": z.string().optional(), "originalRequestId": z.string().optional(), "originalRequestPaymentReference": z.string().optional() }).passthrough();
|
|
2220
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_createRequest_v2", kind: "request", variant: "application/json" }, schema: RequestControllerV2_createRequest_v2_Request });
|
|
2221
|
+
var RequestControllerV2_createRequest_v2_201 = z.object({ "paymentReference": z.string().optional(), "requestId": z.string().optional() }).passthrough();
|
|
2222
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_createRequest_v2", kind: "response", status: 201 }, schema: RequestControllerV2_createRequest_v2_201 });
|
|
2223
|
+
var RequestControllerV2_createRequest_v2_400 = ErrorEnvelopeSchema6;
|
|
2224
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_createRequest_v2", kind: "response", status: 400 }, schema: RequestControllerV2_createRequest_v2_400 });
|
|
2225
|
+
var RequestControllerV2_createRequest_v2_404 = ErrorEnvelopeSchema6;
|
|
2226
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_createRequest_v2", kind: "response", status: 404 }, schema: RequestControllerV2_createRequest_v2_404 });
|
|
2227
|
+
var RequestControllerV2_createRequest_v2_429 = ErrorEnvelopeSchema6;
|
|
2228
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_createRequest_v2", kind: "response", status: 429 }, schema: RequestControllerV2_createRequest_v2_429 });
|
|
2229
|
+
var RequestControllerV2_getRequestStatus_v2_200 = z.object({ "hasBeenPaid": z.boolean().optional(), "paymentReference": z.string().optional(), "requestId": z.string().optional(), "isListening": z.boolean().optional(), "txHash": z.string().nullable().optional(), "recurrence": z.object({}).passthrough().optional(), "originalRequestId": z.string().optional(), "status": z.string().optional(), "isCryptoToFiatAvailable": z.boolean().optional(), "originalRequestPaymentReference": z.string().optional(), "payments": z.array(z.object({}).passthrough()).optional(), "isRecurrenceStopped": z.boolean().optional(), "customerInfo": z.object({ "firstName": z.string().optional(), "lastName": z.string().optional(), "email": z.string().optional(), "address": z.object({ "street": z.string().optional(), "city": z.string().optional(), "state": z.string().optional(), "postalCode": z.string().optional(), "country": z.string().optional() }).passthrough().optional() }).passthrough().nullable().optional(), "reference": z.string().nullable().optional() }).passthrough();
|
|
2230
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestStatus_v2", kind: "response", status: 200 }, schema: RequestControllerV2_getRequestStatus_v2_200 });
|
|
2231
|
+
var RequestControllerV2_getRequestStatus_v2_404 = ErrorEnvelopeSchema6;
|
|
2232
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestStatus_v2", kind: "response", status: 404 }, schema: RequestControllerV2_getRequestStatus_v2_404 });
|
|
2233
|
+
var RequestControllerV2_getRequestStatus_v2_429 = ErrorEnvelopeSchema6;
|
|
2234
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestStatus_v2", kind: "response", status: 429 }, schema: RequestControllerV2_getRequestStatus_v2_429 });
|
|
2235
|
+
var RequestControllerV2_updateRequest_v2_200 = z.unknown();
|
|
2236
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_updateRequest_v2", kind: "response", status: 200 }, schema: RequestControllerV2_updateRequest_v2_200 });
|
|
2237
|
+
var RequestControllerV2_updateRequest_v2_404 = ErrorEnvelopeSchema6;
|
|
2238
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_updateRequest_v2", kind: "response", status: 404 }, schema: RequestControllerV2_updateRequest_v2_404 });
|
|
2239
|
+
var RequestControllerV2_updateRequest_v2_429 = ErrorEnvelopeSchema6;
|
|
2240
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_updateRequest_v2", kind: "response", status: 429 }, schema: RequestControllerV2_updateRequest_v2_429 });
|
|
2241
|
+
var RequestControllerV2_getPaymentCalldata_v2_200 = z.union([z.object({ "transactions": z.array(z.object({ "data": z.string(), "to": z.string(), "value": z.object({ "type": z.enum(["BigNumber"]).optional(), "hex": z.string().optional() }).passthrough() }).passthrough()), "metadata": z.object({ "stepsRequired": z.number(), "needsApproval": z.boolean(), "approvalTransactionIndex": z.number().nullable().optional(), "hasEnoughBalance": z.boolean(), "hasEnoughGas": z.boolean() }).passthrough() }).passthrough(), z.object({ "paymentIntentId": z.string(), "paymentIntent": z.string(), "approvalPermitPayload": z.string().nullable().optional(), "approvalCalldata": z.object({ "to": z.string().optional(), "data": z.string().optional(), "value": z.string().optional() }).passthrough().nullable().optional(), "metadata": z.object({ "supportsEIP2612": z.boolean() }).passthrough() }).passthrough()]);
|
|
2242
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getPaymentCalldata_v2", kind: "response", status: 200 }, schema: RequestControllerV2_getPaymentCalldata_v2_200 });
|
|
2243
|
+
var RequestControllerV2_getPaymentCalldata_v2_400 = ErrorEnvelopeSchema6;
|
|
2244
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getPaymentCalldata_v2", kind: "response", status: 400 }, schema: RequestControllerV2_getPaymentCalldata_v2_400 });
|
|
2245
|
+
var RequestControllerV2_getPaymentCalldata_v2_404 = ErrorEnvelopeSchema6;
|
|
2246
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getPaymentCalldata_v2", kind: "response", status: 404 }, schema: RequestControllerV2_getPaymentCalldata_v2_404 });
|
|
2247
|
+
var RequestControllerV2_getPaymentCalldata_v2_429 = ErrorEnvelopeSchema6;
|
|
2248
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getPaymentCalldata_v2", kind: "response", status: 429 }, schema: RequestControllerV2_getPaymentCalldata_v2_429 });
|
|
2249
|
+
var RequestControllerV2_getRequestPaymentRoutes_v2_200 = z.object({ "routes": z.array(z.object({ "id": z.string(), "fee": z.number(), "feeBreakdown": z.array(z.object({ "type": z.enum(["gas", "platform", "crosschain", "crypto-to-fiat", "offramp"]).optional(), "stage": z.enum(["sending", "receiving", "proxying", "refunding", "overall"]).optional(), "provider": z.string().optional(), "amount": z.string().optional(), "amountInUSD": z.string().optional(), "currency": z.string().optional(), "receiverAddress": z.string().optional(), "network": z.string().optional(), "rateProvider": z.string().optional() }).passthrough()).optional(), "speed": z.union([z.string(), z.number()]), "price_impact": z.number().optional(), "chain": z.string(), "token": z.string() }).passthrough()) }).passthrough();
|
|
2250
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestPaymentRoutes_v2", kind: "response", status: 200 }, schema: RequestControllerV2_getRequestPaymentRoutes_v2_200 });
|
|
2251
|
+
var RequestControllerV2_getRequestPaymentRoutes_v2_400 = ErrorEnvelopeSchema6;
|
|
2252
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestPaymentRoutes_v2", kind: "response", status: 400 }, schema: RequestControllerV2_getRequestPaymentRoutes_v2_400 });
|
|
2253
|
+
var RequestControllerV2_getRequestPaymentRoutes_v2_404 = ErrorEnvelopeSchema6;
|
|
2254
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestPaymentRoutes_v2", kind: "response", status: 404 }, schema: RequestControllerV2_getRequestPaymentRoutes_v2_404 });
|
|
2255
|
+
var RequestControllerV2_getRequestPaymentRoutes_v2_429 = ErrorEnvelopeSchema6;
|
|
2256
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_getRequestPaymentRoutes_v2", kind: "response", status: 429 }, schema: RequestControllerV2_getRequestPaymentRoutes_v2_429 });
|
|
2257
|
+
var RequestControllerV2_sendPaymentIntent_v2_Request = z.object({ "signedPaymentIntent": z.object({ "signature": z.string(), "nonce": z.string(), "deadline": z.string() }).passthrough(), "signedApprovalPermit": z.object({ "signature": z.string(), "nonce": z.string(), "deadline": z.string() }).passthrough().optional() }).passthrough();
|
|
2258
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_sendPaymentIntent_v2", kind: "request", variant: "application/json" }, schema: RequestControllerV2_sendPaymentIntent_v2_Request });
|
|
2259
|
+
var RequestControllerV2_sendPaymentIntent_v2_200 = z.unknown();
|
|
2260
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_sendPaymentIntent_v2", kind: "response", status: 200 }, schema: RequestControllerV2_sendPaymentIntent_v2_200 });
|
|
2261
|
+
var RequestControllerV2_sendPaymentIntent_v2_404 = ErrorEnvelopeSchema6;
|
|
2262
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_sendPaymentIntent_v2", kind: "response", status: 404 }, schema: RequestControllerV2_sendPaymentIntent_v2_404 });
|
|
2263
|
+
var RequestControllerV2_sendPaymentIntent_v2_429 = ErrorEnvelopeSchema6;
|
|
2264
|
+
schemaRegistry.register({ key: { operationId: "RequestControllerV2_sendPaymentIntent_v2", kind: "response", status: 429 }, schema: RequestControllerV2_sendPaymentIntent_v2_429 });
|
|
2265
|
+
var NullableRequestStatusSchema = z.preprocess((value) => {
|
|
2266
|
+
if (!value || typeof value !== "object") {
|
|
2267
|
+
return value;
|
|
2268
|
+
}
|
|
2269
|
+
const next = { ...value };
|
|
2270
|
+
if (next.recurrence === null) {
|
|
2271
|
+
delete next.recurrence;
|
|
2272
|
+
}
|
|
2273
|
+
if (next.originalRequestId === null) {
|
|
2274
|
+
next.originalRequestId = void 0;
|
|
2275
|
+
}
|
|
2276
|
+
if (next.originalRequestPaymentReference === null) {
|
|
2277
|
+
next.originalRequestPaymentReference = void 0;
|
|
2278
|
+
}
|
|
2279
|
+
return next;
|
|
2280
|
+
}, RequestControllerV2_getRequestStatus_v2_200);
|
|
2281
|
+
schemaRegistry.register({
|
|
2282
|
+
key: { operationId: "RequestControllerV2_getRequestStatus_v2", kind: "response", status: 200 },
|
|
2283
|
+
schema: NullableRequestStatusSchema
|
|
2284
|
+
});
|
|
2285
|
+
var FlexibleRoutesSchema = z.object({
|
|
2286
|
+
routes: z.array(
|
|
2287
|
+
z.object({
|
|
2288
|
+
fee: z.union([z.number(), z.string()]).optional()
|
|
2289
|
+
}).passthrough()
|
|
2290
|
+
)
|
|
2291
|
+
}).passthrough();
|
|
2292
|
+
schemaRegistry.register({
|
|
2293
|
+
key: { operationId: "RequestControllerV2_getRequestPaymentRoutes_v2", kind: "response", status: 200 },
|
|
2294
|
+
schema: FlexibleRoutesSchema
|
|
2295
|
+
});
|
|
2296
|
+
|
|
2297
|
+
// src/request.client.ts
|
|
2298
|
+
function createRequestClient(options) {
|
|
2299
|
+
const http = createHttpClient(options);
|
|
2300
|
+
return {
|
|
2301
|
+
http,
|
|
2302
|
+
currencies: createCurrenciesApi(http),
|
|
2303
|
+
clientIds: createClientIdsApi(http),
|
|
2304
|
+
requests: createRequestsApi(http),
|
|
2305
|
+
payouts: createPayoutsApi(http),
|
|
2306
|
+
payments: createPaymentsApi(http),
|
|
2307
|
+
payer: createPayerApi(http),
|
|
2308
|
+
pay: createPayApi(http)
|
|
2309
|
+
};
|
|
2310
|
+
}
|
|
2311
|
+
function createRequestClientFromEnv(options) {
|
|
2312
|
+
const env = options?.env ?? process.env;
|
|
2313
|
+
const baseUrl = env.REQUEST_API_URL ?? env.REQUEST_SDK_BASE_URL;
|
|
2314
|
+
const apiKey = env.REQUEST_API_KEY ?? env.REQUEST_SDK_API_KEY;
|
|
2315
|
+
const clientId = env.REQUEST_CLIENT_ID ?? env.REQUEST_SDK_CLIENT_ID;
|
|
2316
|
+
return createRequestClient({ baseUrl, apiKey, clientId });
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
// src/core/config/request-environment.config.ts
|
|
2320
|
+
var RequestEnvironment = {
|
|
2321
|
+
production: "https://api.request.network",
|
|
2322
|
+
// Legacy placeholder for partner-managed sandboxes; Request does not operate a public staging host.
|
|
2323
|
+
staging: "https://api.stage.request.network",
|
|
2324
|
+
local: "http://127.0.0.1:8080"
|
|
2325
|
+
};
|
|
2326
|
+
|
|
2327
|
+
// src/domains/requests/v1/index.ts
|
|
2328
|
+
var v1_exports4 = {};
|
|
2329
|
+
__export(v1_exports4, {
|
|
2330
|
+
createRequestsV1Api: () => createRequestsV1Api
|
|
2331
|
+
});
|
|
2332
|
+
|
|
2333
|
+
// src/domains/requests/v1/requests.v1.facade.ts
|
|
2334
|
+
var OP_CREATE3 = "RequestControllerV1_createRequest_v1";
|
|
2335
|
+
var OP_PAYMENT_ROUTES2 = "RequestControllerV1_getRequestPaymentRoutes_v1";
|
|
2336
|
+
var OP_PAYMENT_CALLDATA2 = "RequestControllerV1_getPaymentCalldata_v1";
|
|
2337
|
+
var OP_REQUEST_STATUS2 = "RequestControllerV1_getRequestStatus_v1";
|
|
2338
|
+
var OP_SEND_PAYMENT_INTENT2 = "RequestControllerV1_sendPaymentIntent_v1";
|
|
2339
|
+
var OP_STOP_RECURRENCE = "RequestControllerV1_stopRecurrenceRequest_v1";
|
|
2340
|
+
var KIND_CALLDATA2 = "calldata";
|
|
2341
|
+
var KIND_PAYMENT_INTENT2 = "paymentIntent";
|
|
2342
|
+
function isPaymentIntentPayload2(payload) {
|
|
2343
|
+
return "paymentIntentId" in payload;
|
|
2344
|
+
}
|
|
2345
|
+
function isCalldataPayload2(payload) {
|
|
2346
|
+
return "transactions" in payload;
|
|
2347
|
+
}
|
|
2348
|
+
function createRequestsV1Api(http) {
|
|
2349
|
+
return {
|
|
2350
|
+
async create(body, options) {
|
|
2351
|
+
return requestJson(http, {
|
|
2352
|
+
operationId: OP_CREATE3,
|
|
2353
|
+
method: "POST",
|
|
2354
|
+
path: "/v1/request",
|
|
2355
|
+
body,
|
|
2356
|
+
requestSchemaKey: { operationId: OP_CREATE3, kind: "request", variant: "application/json" },
|
|
2357
|
+
schemaKey: { operationId: OP_CREATE3, kind: "response", status: 201 },
|
|
2358
|
+
description: "Create legacy request",
|
|
2359
|
+
signal: options?.signal,
|
|
2360
|
+
timeoutMs: options?.timeoutMs,
|
|
2361
|
+
validation: options?.validation,
|
|
2362
|
+
meta: options?.meta
|
|
2363
|
+
});
|
|
2364
|
+
},
|
|
2365
|
+
async getPaymentRoutes(paymentReference, options) {
|
|
2366
|
+
const path = `/v1/request/${encodeURIComponent(paymentReference)}/routes`;
|
|
2367
|
+
return requestJson(http, {
|
|
2368
|
+
operationId: OP_PAYMENT_ROUTES2,
|
|
2369
|
+
method: "GET",
|
|
2370
|
+
path,
|
|
2371
|
+
query: buildRequestQuery({
|
|
2372
|
+
wallet: options.wallet,
|
|
2373
|
+
amount: options.amount,
|
|
2374
|
+
feePercentage: options.feePercentage,
|
|
2375
|
+
feeAddress: options.feeAddress
|
|
2376
|
+
}),
|
|
2377
|
+
schemaKey: { operationId: OP_PAYMENT_ROUTES2, kind: "response", status: 200 },
|
|
2378
|
+
description: "Legacy payment routes",
|
|
2379
|
+
signal: options.signal,
|
|
2380
|
+
timeoutMs: options.timeoutMs,
|
|
2381
|
+
validation: options.validation,
|
|
2382
|
+
meta: options.meta
|
|
2383
|
+
});
|
|
2384
|
+
},
|
|
2385
|
+
async getPaymentCalldata(paymentReference, options) {
|
|
2386
|
+
const path = `/v1/request/${encodeURIComponent(paymentReference)}/pay`;
|
|
2387
|
+
const query = buildRequestQuery({
|
|
2388
|
+
wallet: options?.wallet,
|
|
2389
|
+
chain: options?.chain,
|
|
2390
|
+
token: options?.token,
|
|
2391
|
+
amount: options?.amount
|
|
2392
|
+
});
|
|
2393
|
+
const raw = await requestJson(http, {
|
|
2394
|
+
operationId: OP_PAYMENT_CALLDATA2,
|
|
2395
|
+
method: "GET",
|
|
2396
|
+
path,
|
|
2397
|
+
query,
|
|
2398
|
+
schemaKey: { operationId: OP_PAYMENT_CALLDATA2, kind: "response", status: 200 },
|
|
2399
|
+
description: "Legacy payment calldata",
|
|
2400
|
+
signal: options?.signal,
|
|
2401
|
+
timeoutMs: options?.timeoutMs,
|
|
2402
|
+
validation: options?.validation,
|
|
2403
|
+
meta: options?.meta
|
|
2404
|
+
});
|
|
2405
|
+
if (isCalldataPayload2(raw)) {
|
|
2406
|
+
return { kind: KIND_CALLDATA2, ...raw };
|
|
2407
|
+
}
|
|
2408
|
+
if (isPaymentIntentPayload2(raw)) {
|
|
2409
|
+
return { kind: KIND_PAYMENT_INTENT2, ...raw };
|
|
2410
|
+
}
|
|
2411
|
+
throw new ValidationError("Unexpected payment calldata response", raw);
|
|
2412
|
+
},
|
|
2413
|
+
async getRequestStatus(paymentReference, options) {
|
|
2414
|
+
const path = `/v1/request/${encodeURIComponent(paymentReference)}`;
|
|
2415
|
+
const rawStatus = await requestJson(http, {
|
|
2416
|
+
operationId: OP_REQUEST_STATUS2,
|
|
2417
|
+
method: "GET",
|
|
2418
|
+
path,
|
|
2419
|
+
schemaKey: { operationId: OP_REQUEST_STATUS2, kind: "response", status: 200 },
|
|
2420
|
+
description: "Legacy request status",
|
|
2421
|
+
signal: options?.signal,
|
|
2422
|
+
timeoutMs: options?.timeoutMs,
|
|
2423
|
+
validation: options?.validation,
|
|
2424
|
+
meta: options?.meta
|
|
2425
|
+
});
|
|
2426
|
+
return normalizeLegacyStatusResponse(rawStatus);
|
|
2427
|
+
},
|
|
2428
|
+
async sendPaymentIntent(paymentIntentId, body, options) {
|
|
2429
|
+
const path = `/v1/request/${encodeURIComponent(paymentIntentId)}/send`;
|
|
2430
|
+
await requestVoid(http, {
|
|
2431
|
+
operationId: OP_SEND_PAYMENT_INTENT2,
|
|
2432
|
+
method: "POST",
|
|
2433
|
+
path,
|
|
2434
|
+
body,
|
|
2435
|
+
requestSchemaKey: { operationId: OP_SEND_PAYMENT_INTENT2, kind: "request", variant: "application/json" },
|
|
2436
|
+
signal: options?.signal,
|
|
2437
|
+
timeoutMs: options?.timeoutMs,
|
|
2438
|
+
validation: options?.validation,
|
|
2439
|
+
meta: options?.meta
|
|
2440
|
+
});
|
|
2441
|
+
},
|
|
2442
|
+
async stopRecurrence(paymentReference, options) {
|
|
2443
|
+
const path = `/v1/request/${encodeURIComponent(paymentReference)}/stop-recurrence`;
|
|
2444
|
+
await requestVoid(http, {
|
|
2445
|
+
operationId: OP_STOP_RECURRENCE,
|
|
2446
|
+
method: "PATCH",
|
|
2447
|
+
path,
|
|
2448
|
+
signal: options?.signal,
|
|
2449
|
+
timeoutMs: options?.timeoutMs,
|
|
2450
|
+
validation: options?.validation,
|
|
2451
|
+
meta: options?.meta
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
// src/webhooks/index.ts
|
|
2458
|
+
var webhooks_exports = {};
|
|
2459
|
+
__export(webhooks_exports, {
|
|
2460
|
+
DEFAULT_SIGNATURE_ALGORITHM: () => DEFAULT_SIGNATURE_ALGORITHM,
|
|
2461
|
+
DEFAULT_SIGNATURE_HEADER: () => DEFAULT_SIGNATURE_HEADER,
|
|
2462
|
+
RequestWebhookSignatureError: () => RequestWebhookSignatureError,
|
|
2463
|
+
WEBHOOK_EVENT_NAMES: () => WEBHOOK_EVENT_NAMES,
|
|
2464
|
+
WebhookDispatcher: () => WebhookDispatcher,
|
|
2465
|
+
createWebhookDispatcher: () => createWebhookDispatcher,
|
|
2466
|
+
createWebhookMiddleware: () => createWebhookMiddleware,
|
|
2467
|
+
events: () => events_exports,
|
|
2468
|
+
getWebhookSchema: () => getWebhookSchema,
|
|
2469
|
+
isRequestWebhookSignatureError: () => isRequestWebhookSignatureError,
|
|
2470
|
+
parseWebhookEvent: () => parseWebhookEvent,
|
|
2471
|
+
testing: () => testing_webhook_exports,
|
|
2472
|
+
verifyWebhookSignature: () => verifyWebhookSignature
|
|
2473
|
+
});
|
|
2474
|
+
|
|
2475
|
+
// src/webhooks/errors.webhook.ts
|
|
2476
|
+
var RequestWebhookSignatureError = class _RequestWebhookSignatureError extends Error {
|
|
2477
|
+
static code = "ERR_REQUEST_WEBHOOK_SIGNATURE_VERIFICATION_FAILED";
|
|
2478
|
+
code = _RequestWebhookSignatureError.code;
|
|
2479
|
+
statusCode = 401;
|
|
2480
|
+
headerName;
|
|
2481
|
+
signature;
|
|
2482
|
+
timestamp;
|
|
2483
|
+
reason;
|
|
2484
|
+
constructor(message, options) {
|
|
2485
|
+
const { headerName, signature, timestamp, reason, cause } = options;
|
|
2486
|
+
super(message, { cause });
|
|
2487
|
+
this.name = "RequestWebhookSignatureError";
|
|
2488
|
+
this.headerName = headerName;
|
|
2489
|
+
this.signature = signature;
|
|
2490
|
+
this.timestamp = timestamp ?? null;
|
|
2491
|
+
this.reason = reason;
|
|
2492
|
+
}
|
|
2493
|
+
};
|
|
2494
|
+
function isRequestWebhookSignatureError(error) {
|
|
2495
|
+
return error instanceof RequestWebhookSignatureError;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
// src/webhooks/headers.webhook.ts
|
|
2499
|
+
function coerceHeaderValue(value) {
|
|
2500
|
+
if (value == null) return void 0;
|
|
2501
|
+
if (Array.isArray(value)) {
|
|
2502
|
+
const first = value.find((item) => item.length > 0);
|
|
2503
|
+
return first ?? void 0;
|
|
2504
|
+
}
|
|
2505
|
+
return typeof value === "string" ? value : String(value);
|
|
2506
|
+
}
|
|
2507
|
+
function isFetchHeaders(input) {
|
|
2508
|
+
return typeof Headers !== "undefined" && input instanceof Headers;
|
|
2509
|
+
}
|
|
2510
|
+
function normaliseHeaders2(headers) {
|
|
2511
|
+
const result = {};
|
|
2512
|
+
if (!headers) return result;
|
|
2513
|
+
if (isFetchHeaders(headers)) {
|
|
2514
|
+
headers.forEach((value, key) => {
|
|
2515
|
+
result[key.toLowerCase()] = value;
|
|
2516
|
+
});
|
|
2517
|
+
return result;
|
|
2518
|
+
}
|
|
2519
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
2520
|
+
const coerced = coerceHeaderValue(value);
|
|
2521
|
+
if (coerced != null) {
|
|
2522
|
+
result[key.toLowerCase()] = coerced;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
return result;
|
|
2526
|
+
}
|
|
2527
|
+
function pickHeader(headers, headerName) {
|
|
2528
|
+
if (!headers) return void 0;
|
|
2529
|
+
const lower = headerName.toLowerCase();
|
|
2530
|
+
if (isFetchHeaders(headers)) {
|
|
2531
|
+
const value = headers.get(headerName);
|
|
2532
|
+
return value ?? void 0;
|
|
2533
|
+
}
|
|
2534
|
+
const record = headers;
|
|
2535
|
+
const direct = record[headerName];
|
|
2536
|
+
if (typeof direct === "string") {
|
|
2537
|
+
return direct;
|
|
2538
|
+
}
|
|
2539
|
+
if (direct != null) {
|
|
2540
|
+
const coercedDirect = coerceHeaderValue(direct);
|
|
2541
|
+
if (coercedDirect) return coercedDirect;
|
|
2542
|
+
}
|
|
2543
|
+
const fallback = record[lower];
|
|
2544
|
+
if (typeof fallback === "string") {
|
|
2545
|
+
return fallback;
|
|
2546
|
+
}
|
|
2547
|
+
if (fallback != null) {
|
|
2548
|
+
return coerceHeaderValue(fallback);
|
|
2549
|
+
}
|
|
2550
|
+
return void 0;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
// src/webhooks/signature.webhook.ts
|
|
2554
|
+
var DEFAULT_SIGNATURE_HEADER = "x-request-network-signature";
|
|
2555
|
+
var DEFAULT_SIGNATURE_ALGORITHM = "sha256";
|
|
2556
|
+
var HEX_SIGNATURE_PATTERN = /^[0-9a-f]+$/i;
|
|
2557
|
+
function toBuffer(rawBody) {
|
|
2558
|
+
if (typeof rawBody === "string") {
|
|
2559
|
+
return Buffer.from(rawBody, "utf8");
|
|
2560
|
+
}
|
|
2561
|
+
if (rawBody instanceof ArrayBuffer) {
|
|
2562
|
+
return Buffer.from(rawBody);
|
|
2563
|
+
}
|
|
2564
|
+
return Buffer.from(rawBody.buffer, rawBody.byteOffset, rawBody.byteLength);
|
|
2565
|
+
}
|
|
2566
|
+
function stripAlgorithmPrefix(signature, headerName) {
|
|
2567
|
+
const trimmed = signature.trim();
|
|
2568
|
+
const equalityIndex = trimmed.indexOf("=");
|
|
2569
|
+
if (equalityIndex === -1) {
|
|
2570
|
+
return trimmed;
|
|
2571
|
+
}
|
|
2572
|
+
const prefix = trimmed.slice(0, equalityIndex).toLowerCase();
|
|
2573
|
+
if (prefix !== DEFAULT_SIGNATURE_ALGORITHM) {
|
|
2574
|
+
throw new RequestWebhookSignatureError("Unsupported signature algorithm", {
|
|
2575
|
+
headerName,
|
|
2576
|
+
signature,
|
|
2577
|
+
timestamp: null,
|
|
2578
|
+
reason: "invalid_format"
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
return trimmed.slice(equalityIndex + 1);
|
|
2582
|
+
}
|
|
2583
|
+
function parseSignatureValue(signature, headerName) {
|
|
2584
|
+
const stripped = stripAlgorithmPrefix(signature, headerName);
|
|
2585
|
+
const trimmed = stripped.trim();
|
|
2586
|
+
if (!trimmed || !HEX_SIGNATURE_PATTERN.test(trimmed)) {
|
|
2587
|
+
throw new RequestWebhookSignatureError("Invalid webhook signature format", {
|
|
2588
|
+
headerName,
|
|
2589
|
+
signature,
|
|
2590
|
+
timestamp: null,
|
|
2591
|
+
reason: "invalid_format"
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
const lower = trimmed.toLowerCase();
|
|
2595
|
+
if (lower.length % 2 !== 0) {
|
|
2596
|
+
throw new RequestWebhookSignatureError("Invalid webhook signature length", {
|
|
2597
|
+
headerName,
|
|
2598
|
+
signature,
|
|
2599
|
+
timestamp: null,
|
|
2600
|
+
reason: "invalid_format"
|
|
2601
|
+
});
|
|
2602
|
+
}
|
|
2603
|
+
const digest = Buffer.from(lower, "hex");
|
|
2604
|
+
return { normalisedHex: lower, buffer: digest };
|
|
2605
|
+
}
|
|
2606
|
+
function computeHmac(secret, body) {
|
|
2607
|
+
return createHmac(DEFAULT_SIGNATURE_ALGORITHM, secret).update(body).digest();
|
|
2608
|
+
}
|
|
2609
|
+
function isReadonlyStringArray(value) {
|
|
2610
|
+
return Array.isArray(value);
|
|
2611
|
+
}
|
|
2612
|
+
function toSecretArray(secret) {
|
|
2613
|
+
return isReadonlyStringArray(secret) ? [...secret] : [secret];
|
|
2614
|
+
}
|
|
2615
|
+
function parseTimestamp(value) {
|
|
2616
|
+
const trimmed = value.trim();
|
|
2617
|
+
if (!trimmed) {
|
|
2618
|
+
return null;
|
|
2619
|
+
}
|
|
2620
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
2621
|
+
const numeric = Number(trimmed);
|
|
2622
|
+
if (!Number.isFinite(numeric)) {
|
|
2623
|
+
return null;
|
|
2624
|
+
}
|
|
2625
|
+
if (numeric > 1e12) {
|
|
2626
|
+
return Math.trunc(numeric);
|
|
2627
|
+
}
|
|
2628
|
+
if (numeric > 1e9) {
|
|
2629
|
+
return Math.trunc(numeric);
|
|
2630
|
+
}
|
|
2631
|
+
return Math.trunc(numeric * 1e3);
|
|
2632
|
+
}
|
|
2633
|
+
const parsed = Date.parse(trimmed);
|
|
2634
|
+
if (Number.isNaN(parsed)) {
|
|
2635
|
+
return null;
|
|
2636
|
+
}
|
|
2637
|
+
return parsed;
|
|
2638
|
+
}
|
|
2639
|
+
function resolveTimestamp(options, headers, headerName) {
|
|
2640
|
+
if (typeof options.timestamp === "number") {
|
|
2641
|
+
return options.timestamp;
|
|
2642
|
+
}
|
|
2643
|
+
if (!options.timestampHeader) {
|
|
2644
|
+
return null;
|
|
2645
|
+
}
|
|
2646
|
+
const headerValue = pickHeader(headers, options.timestampHeader);
|
|
2647
|
+
if (!headerValue) {
|
|
2648
|
+
return null;
|
|
2649
|
+
}
|
|
2650
|
+
const parsed = parseTimestamp(headerValue);
|
|
2651
|
+
if (parsed == null) {
|
|
2652
|
+
throw new RequestWebhookSignatureError("Invalid webhook timestamp header", {
|
|
2653
|
+
headerName: options.timestampHeader,
|
|
2654
|
+
signature: pickHeader(headers, headerName) ?? null,
|
|
2655
|
+
timestamp: null,
|
|
2656
|
+
reason: "invalid_format"
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
return parsed;
|
|
2660
|
+
}
|
|
2661
|
+
function verifyWebhookSignature(options) {
|
|
2662
|
+
const {
|
|
2663
|
+
rawBody,
|
|
2664
|
+
secret,
|
|
2665
|
+
headers: rawHeaders,
|
|
2666
|
+
signature: explicitSignature,
|
|
2667
|
+
headerName = DEFAULT_SIGNATURE_HEADER,
|
|
2668
|
+
toleranceMs,
|
|
2669
|
+
now = () => Date.now()
|
|
2670
|
+
} = options;
|
|
2671
|
+
const headers = normaliseHeaders2(rawHeaders);
|
|
2672
|
+
const signatureValue = explicitSignature ?? pickHeader(headers, headerName);
|
|
2673
|
+
if (!signatureValue) {
|
|
2674
|
+
throw new RequestWebhookSignatureError(`Missing webhook signature header: ${headerName}`, {
|
|
2675
|
+
headerName,
|
|
2676
|
+
signature: null,
|
|
2677
|
+
timestamp: null,
|
|
2678
|
+
reason: "missing_signature"
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
const { normalisedHex, buffer: signatureBuffer } = parseSignatureValue(signatureValue, headerName);
|
|
2682
|
+
const timestamp = resolveTimestamp(options, headers, headerName);
|
|
2683
|
+
if (typeof toleranceMs === "number" && toleranceMs >= 0 && timestamp != null) {
|
|
2684
|
+
const distance = Math.abs(now() - timestamp);
|
|
2685
|
+
if (distance > toleranceMs) {
|
|
2686
|
+
throw new RequestWebhookSignatureError("Webhook signature timestamp outside tolerance", {
|
|
2687
|
+
headerName,
|
|
2688
|
+
signature: normalisedHex,
|
|
2689
|
+
timestamp,
|
|
2690
|
+
reason: "tolerance_exceeded"
|
|
2691
|
+
});
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
const bodyBuffer = toBuffer(rawBody);
|
|
2695
|
+
const secrets = toSecretArray(secret);
|
|
2696
|
+
if (secrets.length === 0) {
|
|
2697
|
+
throw new RequestWebhookSignatureError("No webhook secrets configured", {
|
|
2698
|
+
headerName,
|
|
2699
|
+
signature: normalisedHex,
|
|
2700
|
+
timestamp,
|
|
2701
|
+
reason: "invalid_signature"
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
const digests = secrets.map((candidate) => computeHmac(candidate, bodyBuffer));
|
|
2705
|
+
const digestLength = digests[0].length;
|
|
2706
|
+
if (signatureBuffer.length !== digestLength) {
|
|
2707
|
+
throw new RequestWebhookSignatureError("Webhook signature length mismatch", {
|
|
2708
|
+
headerName,
|
|
2709
|
+
signature: normalisedHex,
|
|
2710
|
+
timestamp,
|
|
2711
|
+
reason: "invalid_format"
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
for (let index = 0; index < digests.length; index += 1) {
|
|
2715
|
+
const digest = digests[index];
|
|
2716
|
+
if (timingSafeEqual(signatureBuffer, digest)) {
|
|
2717
|
+
return {
|
|
2718
|
+
signature: normalisedHex,
|
|
2719
|
+
matchedSecret: secrets[index],
|
|
2720
|
+
timestamp: timestamp ?? null,
|
|
2721
|
+
headers
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
throw new RequestWebhookSignatureError("Invalid webhook signature", {
|
|
2726
|
+
headerName,
|
|
2727
|
+
signature: normalisedHex,
|
|
2728
|
+
timestamp,
|
|
2729
|
+
reason: "invalid_signature"
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
var COMPLIANCE_KYC_STATUSES = [
|
|
2733
|
+
"not_started",
|
|
2734
|
+
"initiated",
|
|
2735
|
+
"pending",
|
|
2736
|
+
"approved",
|
|
2737
|
+
"rejected",
|
|
2738
|
+
"failed",
|
|
2739
|
+
"completed"
|
|
2740
|
+
];
|
|
2741
|
+
var COMPLIANCE_AGREEMENT_STATUSES = [
|
|
2742
|
+
"not_started",
|
|
2743
|
+
"pending",
|
|
2744
|
+
"completed",
|
|
2745
|
+
"rejected",
|
|
2746
|
+
"failed",
|
|
2747
|
+
"signed"
|
|
2748
|
+
];
|
|
2749
|
+
var PAYMENT_FAILED_SUB_STATUSES = ["failed", "bounced", "insufficient_funds"];
|
|
2750
|
+
var PAYMENT_PROCESSING_SUB_STATUSES = [
|
|
2751
|
+
"initiated",
|
|
2752
|
+
"pending_internal_assessment",
|
|
2753
|
+
"ongoing_checks",
|
|
2754
|
+
"sending_fiat",
|
|
2755
|
+
"fiat_sent",
|
|
2756
|
+
"bounced",
|
|
2757
|
+
"retry_required",
|
|
2758
|
+
"processing"
|
|
2759
|
+
];
|
|
2760
|
+
var PAYMENT_DETAIL_STATUSES = ["approved", "failed", "pending", "verified"];
|
|
2761
|
+
var webhookBaseSchema = z.object({
|
|
2762
|
+
event: z.string()
|
|
2763
|
+
}).passthrough();
|
|
2764
|
+
var paymentConfirmedSchema = webhookBaseSchema.extend({
|
|
2765
|
+
event: z.literal("payment.confirmed")
|
|
2766
|
+
});
|
|
2767
|
+
var paymentFailedSchema = webhookBaseSchema.extend({
|
|
2768
|
+
event: z.literal("payment.failed"),
|
|
2769
|
+
subStatus: z.enum(PAYMENT_FAILED_SUB_STATUSES).optional(),
|
|
2770
|
+
failureReason: z.string().optional(),
|
|
2771
|
+
retryAfter: z.string().optional()
|
|
2772
|
+
});
|
|
2773
|
+
var paymentProcessingSchema = webhookBaseSchema.extend({
|
|
2774
|
+
event: z.literal("payment.processing"),
|
|
2775
|
+
subStatus: z.enum(PAYMENT_PROCESSING_SUB_STATUSES)
|
|
2776
|
+
});
|
|
2777
|
+
var paymentDetailUpdatedSchema = webhookBaseSchema.extend({
|
|
2778
|
+
event: z.literal("payment_detail.updated"),
|
|
2779
|
+
status: z.enum(PAYMENT_DETAIL_STATUSES),
|
|
2780
|
+
paymentDetailsId: z.string().optional(),
|
|
2781
|
+
paymentAccountId: z.string().optional(),
|
|
2782
|
+
rejectionMessage: z.string().optional()
|
|
2783
|
+
});
|
|
2784
|
+
var complianceUpdatedSchema = webhookBaseSchema.extend({
|
|
2785
|
+
event: z.literal("compliance.updated"),
|
|
2786
|
+
kycStatus: z.enum(COMPLIANCE_KYC_STATUSES).optional(),
|
|
2787
|
+
agreementStatus: z.enum(COMPLIANCE_AGREEMENT_STATUSES).optional(),
|
|
2788
|
+
isCompliant: z.boolean().optional()
|
|
2789
|
+
});
|
|
2790
|
+
var paymentPartialSchema = webhookBaseSchema.extend({
|
|
2791
|
+
event: z.literal("payment.partial")
|
|
2792
|
+
});
|
|
2793
|
+
var paymentRefundedSchema = webhookBaseSchema.extend({
|
|
2794
|
+
event: z.literal("payment.refunded"),
|
|
2795
|
+
refundedTo: z.string(),
|
|
2796
|
+
refundAmount: z.string()
|
|
2797
|
+
});
|
|
2798
|
+
var requestRecurringSchema = webhookBaseSchema.extend({
|
|
2799
|
+
event: z.literal("request.recurring"),
|
|
2800
|
+
originalRequestId: z.string(),
|
|
2801
|
+
originalRequestPaymentReference: z.string()
|
|
2802
|
+
});
|
|
2803
|
+
var webhookEventSchemas = {
|
|
2804
|
+
"payment.confirmed": paymentConfirmedSchema,
|
|
2805
|
+
"payment.failed": paymentFailedSchema,
|
|
2806
|
+
"payment.processing": paymentProcessingSchema,
|
|
2807
|
+
"payment_detail.updated": paymentDetailUpdatedSchema,
|
|
2808
|
+
"compliance.updated": complianceUpdatedSchema,
|
|
2809
|
+
"payment.partial": paymentPartialSchema,
|
|
2810
|
+
"payment.refunded": paymentRefundedSchema,
|
|
2811
|
+
"request.recurring": requestRecurringSchema
|
|
2812
|
+
};
|
|
2813
|
+
var WEBHOOK_EVENT_NAMES = Object.freeze(Object.keys(webhookEventSchemas));
|
|
2814
|
+
for (const [eventName, schema] of Object.entries(webhookEventSchemas)) {
|
|
2815
|
+
schemaRegistry.register({
|
|
2816
|
+
key: { operationId: eventName, kind: "webhook" },
|
|
2817
|
+
schema
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2820
|
+
function getWebhookSchema(event) {
|
|
2821
|
+
return webhookEventSchemas[event];
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
// src/webhooks/parser.webhook.ts
|
|
2825
|
+
function ensureBuffer(rawBody) {
|
|
2826
|
+
if (typeof rawBody === "string") {
|
|
2827
|
+
return Buffer.from(rawBody, "utf8");
|
|
2828
|
+
}
|
|
2829
|
+
if (rawBody instanceof ArrayBuffer) {
|
|
2830
|
+
return Buffer.from(rawBody);
|
|
2831
|
+
}
|
|
2832
|
+
return Buffer.from(rawBody.buffer, rawBody.byteOffset, rawBody.byteLength);
|
|
2833
|
+
}
|
|
2834
|
+
function normaliseBody(rawBody) {
|
|
2835
|
+
const buffer = ensureBuffer(rawBody);
|
|
2836
|
+
const view = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
2837
|
+
return { buffer, view };
|
|
2838
|
+
}
|
|
2839
|
+
function parseJsonBody(buffer) {
|
|
2840
|
+
try {
|
|
2841
|
+
const text = buffer.toString("utf8");
|
|
2842
|
+
return JSON.parse(text);
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
throw new ValidationError("Invalid webhook JSON payload", error);
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
function resolveEventName(body) {
|
|
2848
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
2849
|
+
throw new ValidationError("Webhook payload must be a JSON object");
|
|
2850
|
+
}
|
|
2851
|
+
const candidate = body.event;
|
|
2852
|
+
if (typeof candidate !== "string" || candidate.length === 0) {
|
|
2853
|
+
throw new ValidationError("Webhook payload missing `event` field");
|
|
2854
|
+
}
|
|
2855
|
+
return candidate;
|
|
2856
|
+
}
|
|
2857
|
+
function assertWebhookEventName(name) {
|
|
2858
|
+
if (!WEBHOOK_EVENT_NAMES.includes(name)) {
|
|
2859
|
+
throw new ValidationError(`Unknown webhook event: ${name}`);
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
function verifySignatureIfRequired(options, buffer, headers) {
|
|
2863
|
+
if (options.skipSignatureVerification) {
|
|
2864
|
+
return null;
|
|
2865
|
+
}
|
|
2866
|
+
return verifyWebhookSignature({
|
|
2867
|
+
rawBody: buffer,
|
|
2868
|
+
secret: options.secret,
|
|
2869
|
+
headers,
|
|
2870
|
+
signature: options.signature,
|
|
2871
|
+
headerName: options.headerName,
|
|
2872
|
+
toleranceMs: options.toleranceMs,
|
|
2873
|
+
timestampHeader: options.timestampHeader,
|
|
2874
|
+
now: options.now
|
|
2875
|
+
});
|
|
2876
|
+
}
|
|
2877
|
+
function parseWebhookEvent(options) {
|
|
2878
|
+
const { buffer, view } = normaliseBody(options.rawBody);
|
|
2879
|
+
const headers = options.skipSignatureVerification ? normaliseHeaders2(options.headers) : void 0;
|
|
2880
|
+
const verification = verifySignatureIfRequired(options, buffer, options.headers);
|
|
2881
|
+
const normalisedHeaders = verification?.headers ?? headers ?? normaliseHeaders2(options.headers);
|
|
2882
|
+
const signature = verification?.signature ?? options.signature ?? pickHeader(normalisedHeaders, options.headerName ?? DEFAULT_SIGNATURE_HEADER) ?? null;
|
|
2883
|
+
const matchedSecret = verification?.matchedSecret ?? null;
|
|
2884
|
+
const timestamp = verification?.timestamp ?? null;
|
|
2885
|
+
const jsonBody = parseJsonBody(buffer);
|
|
2886
|
+
const eventName = resolveEventName(jsonBody);
|
|
2887
|
+
assertWebhookEventName(eventName);
|
|
2888
|
+
const schema = getWebhookSchema(eventName);
|
|
2889
|
+
if (!schema) {
|
|
2890
|
+
throw new ValidationError(`No schema registered for webhook event ${eventName}`);
|
|
2891
|
+
}
|
|
2892
|
+
const parsed = parseWithSchema({
|
|
2893
|
+
schema,
|
|
2894
|
+
value: jsonBody,
|
|
2895
|
+
description: `Webhook event ${eventName}`
|
|
2896
|
+
});
|
|
2897
|
+
if (!parsed.success || !parsed.data) {
|
|
2898
|
+
const cause = parsed.error instanceof Error ? parsed.error : new ValidationError(`Invalid payload for webhook event ${eventName}`, parsed.error);
|
|
2899
|
+
throw cause;
|
|
2900
|
+
}
|
|
2901
|
+
const typedEventName = eventName;
|
|
2902
|
+
const payload = parsed.data;
|
|
2903
|
+
return {
|
|
2904
|
+
event: typedEventName,
|
|
2905
|
+
payload,
|
|
2906
|
+
signature,
|
|
2907
|
+
matchedSecret,
|
|
2908
|
+
timestamp,
|
|
2909
|
+
rawBody: view,
|
|
2910
|
+
headers: normalisedHeaders
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
// src/webhooks/dispatcher.webhook.ts
|
|
2915
|
+
function ensureHandlerSet(store, event) {
|
|
2916
|
+
let set = store.get(event);
|
|
2917
|
+
if (!set) {
|
|
2918
|
+
set = /* @__PURE__ */ new Set();
|
|
2919
|
+
store.set(event, set);
|
|
2920
|
+
}
|
|
2921
|
+
return set;
|
|
2922
|
+
}
|
|
2923
|
+
var WebhookDispatcher = class {
|
|
2924
|
+
handlers = /* @__PURE__ */ new Map();
|
|
2925
|
+
on(event, handler) {
|
|
2926
|
+
const set = ensureHandlerSet(this.handlers, event);
|
|
2927
|
+
const wrapped = handler;
|
|
2928
|
+
set.add(wrapped);
|
|
2929
|
+
return () => {
|
|
2930
|
+
const existing = this.handlers.get(event);
|
|
2931
|
+
if (!existing) return;
|
|
2932
|
+
existing.delete(wrapped);
|
|
2933
|
+
if (existing.size === 0) {
|
|
2934
|
+
this.handlers.delete(event);
|
|
2935
|
+
}
|
|
2936
|
+
};
|
|
2937
|
+
}
|
|
2938
|
+
once(event, handler) {
|
|
2939
|
+
const disposeRef = {};
|
|
2940
|
+
const wrapped = async (evt, context) => {
|
|
2941
|
+
disposeRef.dispose?.();
|
|
2942
|
+
await handler(evt, context);
|
|
2943
|
+
};
|
|
2944
|
+
const dispose = this.on(event, wrapped);
|
|
2945
|
+
disposeRef.dispose = dispose;
|
|
2946
|
+
return dispose;
|
|
2947
|
+
}
|
|
2948
|
+
off(event, handler) {
|
|
2949
|
+
const set = this.handlers.get(event);
|
|
2950
|
+
if (!set) return;
|
|
2951
|
+
set.delete(handler);
|
|
2952
|
+
if (set.size === 0) {
|
|
2953
|
+
this.handlers.delete(event);
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
clear() {
|
|
2957
|
+
this.handlers.clear();
|
|
2958
|
+
}
|
|
2959
|
+
handlerCount(event) {
|
|
2960
|
+
if (event) {
|
|
2961
|
+
return this.handlers.get(event)?.size ?? 0;
|
|
2962
|
+
}
|
|
2963
|
+
let total = 0;
|
|
2964
|
+
for (const set of this.handlers.values()) {
|
|
2965
|
+
total += set.size;
|
|
2966
|
+
}
|
|
2967
|
+
return total;
|
|
2968
|
+
}
|
|
2969
|
+
async dispatch(event, context = {}) {
|
|
2970
|
+
const set = this.handlers.get(event.event);
|
|
2971
|
+
if (!set || set.size === 0) {
|
|
2972
|
+
return;
|
|
2973
|
+
}
|
|
2974
|
+
const handlers = Array.from(set);
|
|
2975
|
+
for (const handler of handlers) {
|
|
2976
|
+
await handler(event, context);
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
/**
|
|
2980
|
+
* Syntactic sugar for strongly typed handler registration that returns the original handler for chaining.
|
|
2981
|
+
*/
|
|
2982
|
+
register(event, handler) {
|
|
2983
|
+
this.on(event, handler);
|
|
2984
|
+
return handler;
|
|
2985
|
+
}
|
|
2986
|
+
};
|
|
2987
|
+
function createWebhookDispatcher() {
|
|
2988
|
+
return new WebhookDispatcher();
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
// src/webhooks/testing.webhook.ts
|
|
2992
|
+
var testing_webhook_exports = {};
|
|
2993
|
+
__export(testing_webhook_exports, {
|
|
2994
|
+
DEFAULT_TEST_WEBHOOK_SECRET: () => DEFAULT_TEST_WEBHOOK_SECRET,
|
|
2995
|
+
createMockWebhookRequest: () => createMockWebhookRequest,
|
|
2996
|
+
createMockWebhookResponse: () => createMockWebhookResponse,
|
|
2997
|
+
generateTestWebhookSignature: () => generateTestWebhookSignature,
|
|
2998
|
+
isWebhookVerificationBypassed: () => isWebhookVerificationBypassed,
|
|
2999
|
+
setWebhookVerificationBypass: () => setWebhookVerificationBypass,
|
|
3000
|
+
withWebhookVerificationDisabled: () => withWebhookVerificationDisabled
|
|
3001
|
+
});
|
|
3002
|
+
var DEFAULT_TEST_WEBHOOK_SECRET = "whsec_test_secret";
|
|
3003
|
+
var inMemoryBypass = false;
|
|
3004
|
+
function toBuffer2(body) {
|
|
3005
|
+
if (typeof body === "string") {
|
|
3006
|
+
return Buffer.from(body, "utf8");
|
|
3007
|
+
}
|
|
3008
|
+
if (body instanceof ArrayBuffer) {
|
|
3009
|
+
return Buffer.from(body);
|
|
3010
|
+
}
|
|
3011
|
+
if (ArrayBuffer.isView(body)) {
|
|
3012
|
+
const view = body;
|
|
3013
|
+
return Buffer.from(view.buffer, view.byteOffset, view.byteLength);
|
|
3014
|
+
}
|
|
3015
|
+
return Buffer.from(JSON.stringify(body));
|
|
3016
|
+
}
|
|
3017
|
+
function generateTestWebhookSignature(rawBody, secret = DEFAULT_TEST_WEBHOOK_SECRET) {
|
|
3018
|
+
const buffer = toBuffer2(rawBody);
|
|
3019
|
+
return createHmac(DEFAULT_SIGNATURE_ALGORITHM, secret).update(buffer).digest("hex");
|
|
3020
|
+
}
|
|
3021
|
+
function isWebhookVerificationBypassed() {
|
|
3022
|
+
if (typeof process !== "undefined" && process.env.REQUEST_WEBHOOK_DISABLE_VERIFICATION === "true") {
|
|
3023
|
+
return true;
|
|
3024
|
+
}
|
|
3025
|
+
return inMemoryBypass;
|
|
3026
|
+
}
|
|
3027
|
+
function setWebhookVerificationBypass(enabled) {
|
|
3028
|
+
inMemoryBypass = enabled;
|
|
3029
|
+
}
|
|
3030
|
+
async function withWebhookVerificationDisabled(fn) {
|
|
3031
|
+
const previous = inMemoryBypass;
|
|
3032
|
+
inMemoryBypass = true;
|
|
3033
|
+
try {
|
|
3034
|
+
return await fn();
|
|
3035
|
+
} finally {
|
|
3036
|
+
inMemoryBypass = previous;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
function createMockWebhookRequest(options) {
|
|
3040
|
+
const { payload, secret = DEFAULT_TEST_WEBHOOK_SECRET, headerName = DEFAULT_SIGNATURE_HEADER, headers } = options;
|
|
3041
|
+
const rawBody = toBuffer2(payload);
|
|
3042
|
+
const signature = generateTestWebhookSignature(rawBody, secret);
|
|
3043
|
+
const req = {
|
|
3044
|
+
headers: {
|
|
3045
|
+
...headers ?? {},
|
|
3046
|
+
[headerName]: signature
|
|
3047
|
+
},
|
|
3048
|
+
rawBody,
|
|
3049
|
+
body: rawBody
|
|
3050
|
+
};
|
|
3051
|
+
return req;
|
|
3052
|
+
}
|
|
3053
|
+
function createMockWebhookResponse() {
|
|
3054
|
+
return {
|
|
3055
|
+
statusCode: 200,
|
|
3056
|
+
body: void 0,
|
|
3057
|
+
headersSent: false,
|
|
3058
|
+
status(code) {
|
|
3059
|
+
this.statusCode = code;
|
|
3060
|
+
return this;
|
|
3061
|
+
},
|
|
3062
|
+
json(payload) {
|
|
3063
|
+
this.body = payload;
|
|
3064
|
+
this.headersSent = true;
|
|
3065
|
+
return this;
|
|
3066
|
+
},
|
|
3067
|
+
send(payload) {
|
|
3068
|
+
this.body = payload;
|
|
3069
|
+
this.headersSent = true;
|
|
3070
|
+
return this;
|
|
3071
|
+
}
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
// src/webhooks/middleware.webhook.ts
|
|
3076
|
+
var DEFAULT_ATTACH_PROPERTY = "webhook";
|
|
3077
|
+
function isArrayBufferView(value) {
|
|
3078
|
+
return Boolean(value) && ArrayBuffer.isView(value);
|
|
3079
|
+
}
|
|
3080
|
+
function isBinaryLike(value) {
|
|
3081
|
+
return typeof value === "string" || value instanceof ArrayBuffer || isArrayBufferView(value);
|
|
3082
|
+
}
|
|
3083
|
+
var defaultGetRawBody = (req) => {
|
|
3084
|
+
const carrier = req;
|
|
3085
|
+
if (isBinaryLike(carrier.rawBody)) {
|
|
3086
|
+
return carrier.rawBody;
|
|
3087
|
+
}
|
|
3088
|
+
if (isBinaryLike(carrier.body)) {
|
|
3089
|
+
return carrier.body;
|
|
3090
|
+
}
|
|
3091
|
+
return null;
|
|
3092
|
+
};
|
|
3093
|
+
var defaultDispatchContext = (req, res, event) => ({
|
|
3094
|
+
req,
|
|
3095
|
+
res,
|
|
3096
|
+
event
|
|
3097
|
+
});
|
|
3098
|
+
async function handleSuccess(parsed, req, res, options) {
|
|
3099
|
+
const {
|
|
3100
|
+
dispatcher,
|
|
3101
|
+
onEvent,
|
|
3102
|
+
logger,
|
|
3103
|
+
attachProperty = DEFAULT_ATTACH_PROPERTY,
|
|
3104
|
+
buildDispatchContext = defaultDispatchContext
|
|
3105
|
+
} = options;
|
|
3106
|
+
Reflect.set(req, attachProperty, parsed);
|
|
3107
|
+
if (logger?.debug) {
|
|
3108
|
+
logger.debug("Webhook event verified", { event: parsed.event, signature: parsed.signature });
|
|
3109
|
+
}
|
|
3110
|
+
if (dispatcher) {
|
|
3111
|
+
const context = buildDispatchContext(req, res, parsed);
|
|
3112
|
+
await dispatcher.dispatch(parsed, context);
|
|
3113
|
+
}
|
|
3114
|
+
if (onEvent) {
|
|
3115
|
+
await onEvent(parsed, req, res);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
async function handleError(error, req, res, options) {
|
|
3119
|
+
const { logger, onError } = options;
|
|
3120
|
+
if (error instanceof RequestWebhookSignatureError) {
|
|
3121
|
+
logger?.warn?.("Webhook signature verification failed", {
|
|
3122
|
+
error,
|
|
3123
|
+
header: error.headerName,
|
|
3124
|
+
reason: error.reason
|
|
3125
|
+
});
|
|
3126
|
+
if (!res.headersSent) {
|
|
3127
|
+
res.status(error.statusCode).json({
|
|
3128
|
+
error: "invalid_webhook_signature",
|
|
3129
|
+
reason: error.reason
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
logger?.error?.("Webhook middleware error", { error });
|
|
3135
|
+
if (onError) {
|
|
3136
|
+
await onError(error, req, res);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
function createWebhookMiddleware(options) {
|
|
3140
|
+
const {
|
|
3141
|
+
secret,
|
|
3142
|
+
headerName,
|
|
3143
|
+
timestampHeader,
|
|
3144
|
+
toleranceMs,
|
|
3145
|
+
getRawBody = defaultGetRawBody,
|
|
3146
|
+
skipVerification,
|
|
3147
|
+
autoNext = true
|
|
3148
|
+
} = options;
|
|
3149
|
+
if (!secret || Array.isArray(secret) && secret.length === 0) {
|
|
3150
|
+
throw new Error("createWebhookMiddleware requires at least one webhook secret");
|
|
3151
|
+
}
|
|
3152
|
+
const handler = async (req, res, next) => {
|
|
3153
|
+
const rawBody = getRawBody(req);
|
|
3154
|
+
if (!isBinaryLike(rawBody)) {
|
|
3155
|
+
const bodyError = new Error("Webhook middleware requires the raw request body. Configure express.raw() or supply getRawBody.");
|
|
3156
|
+
await handleError(bodyError, req, res, options);
|
|
3157
|
+
if (!res.headersSent && autoNext) {
|
|
3158
|
+
next(bodyError);
|
|
3159
|
+
}
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3162
|
+
const shouldSkip = skipVerification?.(req) ?? isWebhookVerificationBypassed();
|
|
3163
|
+
try {
|
|
3164
|
+
const parsed = parseWebhookEvent({
|
|
3165
|
+
rawBody,
|
|
3166
|
+
headers: req.headers,
|
|
3167
|
+
secret,
|
|
3168
|
+
headerName,
|
|
3169
|
+
timestampHeader,
|
|
3170
|
+
toleranceMs,
|
|
3171
|
+
skipSignatureVerification: shouldSkip
|
|
3172
|
+
});
|
|
3173
|
+
await handleSuccess(parsed, req, res, options);
|
|
3174
|
+
if (autoNext) {
|
|
3175
|
+
next();
|
|
3176
|
+
}
|
|
3177
|
+
} catch (error) {
|
|
3178
|
+
await handleError(error, req, res, options);
|
|
3179
|
+
if (!res.headersSent && autoNext) {
|
|
3180
|
+
const err = error instanceof Error ? error : new Error("Webhook middleware handler failed", { cause: error });
|
|
3181
|
+
next(err);
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
return handler;
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
// src/webhooks/events/index.ts
|
|
3189
|
+
var events_exports = {};
|
|
3190
|
+
__export(events_exports, {
|
|
3191
|
+
COMPLIANCE_AGREEMENT_STATUSES: () => COMPLIANCE_AGREEMENT_STATUSES2,
|
|
3192
|
+
COMPLIANCE_KYC_STATUSES: () => COMPLIANCE_KYC_STATUSES2,
|
|
3193
|
+
COMPLIANCE_UPDATED_EVENT: () => COMPLIANCE_UPDATED_EVENT,
|
|
3194
|
+
PAYMENT_CONFIRMED_EVENT: () => PAYMENT_CONFIRMED_EVENT,
|
|
3195
|
+
PAYMENT_DETAIL_STATUSES: () => PAYMENT_DETAIL_STATUSES2,
|
|
3196
|
+
PAYMENT_DETAIL_UPDATED_EVENT: () => PAYMENT_DETAIL_UPDATED_EVENT,
|
|
3197
|
+
PAYMENT_FAILED_EVENT: () => PAYMENT_FAILED_EVENT,
|
|
3198
|
+
PAYMENT_FAILED_SUB_STATUSES: () => PAYMENT_FAILED_SUB_STATUSES2,
|
|
3199
|
+
PAYMENT_PARTIAL_EVENT: () => PAYMENT_PARTIAL_EVENT,
|
|
3200
|
+
PAYMENT_PROCESSING_EVENT: () => PAYMENT_PROCESSING_EVENT,
|
|
3201
|
+
PAYMENT_PROCESSING_STAGES: () => PAYMENT_PROCESSING_STAGES,
|
|
3202
|
+
PAYMENT_REFUNDED_EVENT: () => PAYMENT_REFUNDED_EVENT,
|
|
3203
|
+
REQUEST_RECURRING_EVENT: () => REQUEST_RECURRING_EVENT,
|
|
3204
|
+
assertComplianceUpdatedEvent: () => assertComplianceUpdatedEvent,
|
|
3205
|
+
assertPaymentConfirmedEvent: () => assertPaymentConfirmedEvent,
|
|
3206
|
+
assertPaymentDetailUpdatedEvent: () => assertPaymentDetailUpdatedEvent,
|
|
3207
|
+
assertPaymentFailedEvent: () => assertPaymentFailedEvent,
|
|
3208
|
+
assertPaymentPartialEvent: () => assertPaymentPartialEvent,
|
|
3209
|
+
assertPaymentProcessingEvent: () => assertPaymentProcessingEvent,
|
|
3210
|
+
assertPaymentRefundedEvent: () => assertPaymentRefundedEvent,
|
|
3211
|
+
assertRequestRecurringEvent: () => assertRequestRecurringEvent,
|
|
3212
|
+
complianceStatusSummary: () => complianceStatusSummary,
|
|
3213
|
+
createEventPredicate: () => createEventPredicate,
|
|
3214
|
+
isAgreementRejected: () => isAgreementRejected,
|
|
3215
|
+
isBouncedFailure: () => isBouncedFailure,
|
|
3216
|
+
isComplianceUpdatedEvent: () => isComplianceUpdatedEvent,
|
|
3217
|
+
isInsufficientFundsFailure: () => isInsufficientFundsFailure,
|
|
3218
|
+
isKycComplete: () => isKycComplete,
|
|
3219
|
+
isPaymentConfirmedEvent: () => isPaymentConfirmedEvent,
|
|
3220
|
+
isPaymentDetailApproved: () => isPaymentDetailApproved,
|
|
3221
|
+
isPaymentDetailPending: () => isPaymentDetailPending,
|
|
3222
|
+
isPaymentDetailRejected: () => isPaymentDetailRejected,
|
|
3223
|
+
isPaymentDetailUpdatedEvent: () => isPaymentDetailUpdatedEvent,
|
|
3224
|
+
isPaymentDetailVerified: () => isPaymentDetailVerified,
|
|
3225
|
+
isPaymentFailedEvent: () => isPaymentFailedEvent,
|
|
3226
|
+
isPaymentPartialEvent: () => isPaymentPartialEvent,
|
|
3227
|
+
isPaymentProcessingEvent: () => isPaymentProcessingEvent,
|
|
3228
|
+
isPaymentRefundedEvent: () => isPaymentRefundedEvent,
|
|
3229
|
+
isProcessingTerminalStatus: () => isProcessingTerminalStatus,
|
|
3230
|
+
isRequestRecurringEvent: () => isRequestRecurringEvent,
|
|
3231
|
+
isRetryRequired: () => isRetryRequired,
|
|
3232
|
+
onComplianceUpdated: () => onComplianceUpdated,
|
|
3233
|
+
onPaymentConfirmed: () => onPaymentConfirmed,
|
|
3234
|
+
onPaymentDetailUpdated: () => onPaymentDetailUpdated,
|
|
3235
|
+
onPaymentFailed: () => onPaymentFailed,
|
|
3236
|
+
onPaymentPartial: () => onPaymentPartial,
|
|
3237
|
+
onPaymentProcessing: () => onPaymentProcessing,
|
|
3238
|
+
onPaymentRefunded: () => onPaymentRefunded,
|
|
3239
|
+
onRequestRecurring: () => onRequestRecurring,
|
|
3240
|
+
processingStageLabel: () => processingStageLabel,
|
|
3241
|
+
registerEventHandler: () => registerEventHandler
|
|
3242
|
+
});
|
|
3243
|
+
|
|
3244
|
+
// src/webhooks/events/base.event.ts
|
|
3245
|
+
function registerEventHandler(dispatcher, event, handler) {
|
|
3246
|
+
return dispatcher.on(event, async (parsed, dispatchContext) => {
|
|
3247
|
+
await handler(parsed.payload, { event: parsed, dispatchContext });
|
|
3248
|
+
});
|
|
3249
|
+
}
|
|
3250
|
+
function createEventPredicate(event) {
|
|
3251
|
+
return (parsed) => parsed.event === event;
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
// src/webhooks/events/payment-confirmed.event.ts
|
|
3255
|
+
var PAYMENT_CONFIRMED_EVENT = "payment.confirmed";
|
|
3256
|
+
var isPaymentConfirmedEvent = createEventPredicate(PAYMENT_CONFIRMED_EVENT);
|
|
3257
|
+
function onPaymentConfirmed(dispatcher, handler) {
|
|
3258
|
+
return registerEventHandler(dispatcher, PAYMENT_CONFIRMED_EVENT, handler);
|
|
3259
|
+
}
|
|
3260
|
+
function assertPaymentConfirmedEvent(event) {
|
|
3261
|
+
if (event.event !== PAYMENT_CONFIRMED_EVENT) {
|
|
3262
|
+
throw new TypeError(`Expected payment.confirmed event. Received ${event.event}.`);
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
// src/webhooks/events/payment-failed.event.ts
|
|
3267
|
+
var PAYMENT_FAILED_EVENT = "payment.failed";
|
|
3268
|
+
var PAYMENT_FAILED_SUB_STATUSES2 = Object.freeze(["failed", "bounced", "insufficient_funds"]);
|
|
3269
|
+
var isPaymentFailedEvent = createEventPredicate(PAYMENT_FAILED_EVENT);
|
|
3270
|
+
function onPaymentFailed(dispatcher, handler) {
|
|
3271
|
+
return registerEventHandler(dispatcher, PAYMENT_FAILED_EVENT, handler);
|
|
3272
|
+
}
|
|
3273
|
+
function assertPaymentFailedEvent(event) {
|
|
3274
|
+
if (event.event !== PAYMENT_FAILED_EVENT) {
|
|
3275
|
+
throw new TypeError(`Expected payment.failed event. Received ${event.event}.`);
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
function isBouncedFailure(payload) {
|
|
3279
|
+
return payload.subStatus === "bounced";
|
|
3280
|
+
}
|
|
3281
|
+
function isInsufficientFundsFailure(payload) {
|
|
3282
|
+
return payload.subStatus === "insufficient_funds";
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
// src/webhooks/events/payment-processing.event.ts
|
|
3286
|
+
var PAYMENT_PROCESSING_EVENT = "payment.processing";
|
|
3287
|
+
var PAYMENT_PROCESSING_STAGES = Object.freeze([
|
|
3288
|
+
"initiated",
|
|
3289
|
+
"pending_internal_assessment",
|
|
3290
|
+
"ongoing_checks",
|
|
3291
|
+
"processing",
|
|
3292
|
+
"sending_fiat",
|
|
3293
|
+
"fiat_sent",
|
|
3294
|
+
"bounced",
|
|
3295
|
+
"retry_required"
|
|
3296
|
+
]);
|
|
3297
|
+
var TERMINAL_STAGES = /* @__PURE__ */ new Set(["fiat_sent", "bounced", "retry_required"]);
|
|
3298
|
+
var STAGE_LABELS = {
|
|
3299
|
+
initiated: "Transfer initiated",
|
|
3300
|
+
pending_internal_assessment: "Pending internal assessment",
|
|
3301
|
+
ongoing_checks: "Ongoing compliance checks",
|
|
3302
|
+
processing: "Processing payment",
|
|
3303
|
+
sending_fiat: "Sending fiat to recipient",
|
|
3304
|
+
fiat_sent: "Fiat delivered",
|
|
3305
|
+
bounced: "Payment bounced",
|
|
3306
|
+
retry_required: "Retry required"
|
|
3307
|
+
};
|
|
3308
|
+
var isPaymentProcessingEvent = createEventPredicate(PAYMENT_PROCESSING_EVENT);
|
|
3309
|
+
function onPaymentProcessing(dispatcher, handler) {
|
|
3310
|
+
return registerEventHandler(dispatcher, PAYMENT_PROCESSING_EVENT, handler);
|
|
3311
|
+
}
|
|
3312
|
+
function assertPaymentProcessingEvent(event) {
|
|
3313
|
+
if (event.event !== PAYMENT_PROCESSING_EVENT) {
|
|
3314
|
+
throw new TypeError(`Expected payment.processing event. Received ${event.event}.`);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
function isProcessingTerminalStatus(stage) {
|
|
3318
|
+
return TERMINAL_STAGES.has(stage);
|
|
3319
|
+
}
|
|
3320
|
+
function processingStageLabel(stage) {
|
|
3321
|
+
return STAGE_LABELS[stage];
|
|
3322
|
+
}
|
|
3323
|
+
function isRetryRequired(stage) {
|
|
3324
|
+
return stage === "retry_required";
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
// src/webhooks/events/payment-detail-updated.event.ts
|
|
3328
|
+
var PAYMENT_DETAIL_UPDATED_EVENT = "payment_detail.updated";
|
|
3329
|
+
var PAYMENT_DETAIL_STATUSES2 = Object.freeze(["approved", "failed", "pending", "verified"]);
|
|
3330
|
+
var isPaymentDetailUpdatedEvent = createEventPredicate(PAYMENT_DETAIL_UPDATED_EVENT);
|
|
3331
|
+
function onPaymentDetailUpdated(dispatcher, handler) {
|
|
3332
|
+
return registerEventHandler(dispatcher, PAYMENT_DETAIL_UPDATED_EVENT, handler);
|
|
3333
|
+
}
|
|
3334
|
+
function assertPaymentDetailUpdatedEvent(event) {
|
|
3335
|
+
if (event.event !== PAYMENT_DETAIL_UPDATED_EVENT) {
|
|
3336
|
+
throw new TypeError(`Expected payment_detail.updated event. Received ${event.event}.`);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
function isPaymentDetailApproved(payload) {
|
|
3340
|
+
return payload.status === "approved";
|
|
3341
|
+
}
|
|
3342
|
+
function isPaymentDetailRejected(payload) {
|
|
3343
|
+
return payload.status === "failed";
|
|
3344
|
+
}
|
|
3345
|
+
function isPaymentDetailPending(payload) {
|
|
3346
|
+
return payload.status === "pending";
|
|
3347
|
+
}
|
|
3348
|
+
function isPaymentDetailVerified(payload) {
|
|
3349
|
+
return payload.status === "verified";
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
// src/webhooks/events/compliance-updated.event.ts
|
|
3353
|
+
var COMPLIANCE_UPDATED_EVENT = "compliance.updated";
|
|
3354
|
+
var COMPLIANCE_KYC_STATUSES2 = Object.freeze([
|
|
3355
|
+
"initiated",
|
|
3356
|
+
"pending",
|
|
3357
|
+
"approved",
|
|
3358
|
+
"rejected",
|
|
3359
|
+
"failed"
|
|
3360
|
+
]);
|
|
3361
|
+
var COMPLIANCE_AGREEMENT_STATUSES2 = Object.freeze([
|
|
3362
|
+
"not_started",
|
|
3363
|
+
"pending",
|
|
3364
|
+
"completed",
|
|
3365
|
+
"rejected",
|
|
3366
|
+
"failed",
|
|
3367
|
+
"signed"
|
|
3368
|
+
]);
|
|
3369
|
+
var isComplianceUpdatedEvent = createEventPredicate(COMPLIANCE_UPDATED_EVENT);
|
|
3370
|
+
function onComplianceUpdated(dispatcher, handler) {
|
|
3371
|
+
return registerEventHandler(dispatcher, COMPLIANCE_UPDATED_EVENT, handler);
|
|
3372
|
+
}
|
|
3373
|
+
function assertComplianceUpdatedEvent(event) {
|
|
3374
|
+
if (event.event !== COMPLIANCE_UPDATED_EVENT) {
|
|
3375
|
+
throw new TypeError(`Expected compliance.updated event. Received ${event.event}.`);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
function isKycComplete(payload) {
|
|
3379
|
+
return payload.kycStatus === "approved";
|
|
3380
|
+
}
|
|
3381
|
+
function isAgreementRejected(payload) {
|
|
3382
|
+
return payload.agreementStatus === "rejected" || payload.agreementStatus === "failed";
|
|
3383
|
+
}
|
|
3384
|
+
function complianceStatusSummary(payload) {
|
|
3385
|
+
const parts = [];
|
|
3386
|
+
const kyc = payload.kycStatus ? String(payload.kycStatus).replace(/_/g, " ") : "unknown";
|
|
3387
|
+
const agreement = payload.agreementStatus ? String(payload.agreementStatus).replace(/_/g, " ") : "unknown";
|
|
3388
|
+
parts.push(`KYC: ${kyc}`);
|
|
3389
|
+
parts.push(`Agreement: ${agreement}`);
|
|
3390
|
+
if (payload.clientUserId) {
|
|
3391
|
+
const clientUserId = JSON.stringify(payload.clientUserId);
|
|
3392
|
+
parts.push(`Client user: ${clientUserId}`);
|
|
3393
|
+
}
|
|
3394
|
+
return parts.join(" | ");
|
|
3395
|
+
}
|
|
3396
|
+
|
|
3397
|
+
// src/webhooks/events/payment-partial.event.ts
|
|
3398
|
+
var PAYMENT_PARTIAL_EVENT = "payment.partial";
|
|
3399
|
+
var isPaymentPartialEvent = createEventPredicate(PAYMENT_PARTIAL_EVENT);
|
|
3400
|
+
function onPaymentPartial(dispatcher, handler) {
|
|
3401
|
+
return registerEventHandler(dispatcher, PAYMENT_PARTIAL_EVENT, handler);
|
|
3402
|
+
}
|
|
3403
|
+
function assertPaymentPartialEvent(event) {
|
|
3404
|
+
if (event.event !== PAYMENT_PARTIAL_EVENT) {
|
|
3405
|
+
throw new TypeError(`Expected payment.partial event. Received ${event.event}.`);
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
// src/webhooks/events/payment-refunded.event.ts
|
|
3410
|
+
var PAYMENT_REFUNDED_EVENT = "payment.refunded";
|
|
3411
|
+
var isPaymentRefundedEvent = createEventPredicate(PAYMENT_REFUNDED_EVENT);
|
|
3412
|
+
function onPaymentRefunded(dispatcher, handler) {
|
|
3413
|
+
return registerEventHandler(dispatcher, PAYMENT_REFUNDED_EVENT, handler);
|
|
3414
|
+
}
|
|
3415
|
+
function assertPaymentRefundedEvent(event) {
|
|
3416
|
+
if (event.event !== PAYMENT_REFUNDED_EVENT) {
|
|
3417
|
+
throw new TypeError(`Expected payment.refunded event. Received ${event.event}.`);
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
// src/webhooks/events/request-recurring.event.ts
|
|
3422
|
+
var REQUEST_RECURRING_EVENT = "request.recurring";
|
|
3423
|
+
var isRequestRecurringEvent = createEventPredicate(REQUEST_RECURRING_EVENT);
|
|
3424
|
+
function onRequestRecurring(dispatcher, handler) {
|
|
3425
|
+
return registerEventHandler(dispatcher, REQUEST_RECURRING_EVENT, handler);
|
|
3426
|
+
}
|
|
3427
|
+
function assertRequestRecurringEvent(event) {
|
|
3428
|
+
if (event.event !== REQUEST_RECURRING_EVENT) {
|
|
3429
|
+
throw new TypeError(`Expected request.recurring event. Received ${event.event}.`);
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
export { DEFAULT_RETRY_CONFIG, RequestApiError, RequestEnvironment, SchemaRegistry, ValidationError, browserFetchAdapter, buildRequestApiError, client_ids_exports as clientIds, computeRetryDelay, createHttpClient, createRequestClient, createRequestClientFromEnv, currencies_exports as currencies, v1_exports as currenciesV1, isRequestApiError, nodeFetchAdapter, parseWithRegistry, parseWithSchema, pay_exports as pay, v1_exports2 as payV1, payer_exports as payer, v1_exports3 as payerV1, v2_exports as payerV2, payments_exports as payments, payouts_exports as payouts, requests_exports as requests, v1_exports4 as requestsV1, schemaRegistry, shouldRetryRequest, webhooks_exports as webhooks };
|
|
3434
|
+
//# sourceMappingURL=index.js.map
|
|
3435
|
+
//# sourceMappingURL=index.js.map
|