@getmanza/sdk 1.0.0 → 1.1.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/CHANGELOG.md +57 -0
- package/README.md +74 -18
- package/dist/client.d.ts +14 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/env.d.ts +3 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/errors.d.ts +15 -15
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +203 -66
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +203 -66
- package/dist/page.d.ts +3 -3
- package/dist/page.d.ts.map +1 -1
- package/dist/resources/accounts.d.ts +3 -3
- package/dist/resources/accounts.d.ts.map +1 -1
- package/dist/resources/base.d.ts +8 -8
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/beneficiaries.d.ts +5 -5
- package/dist/resources/beneficiaries.d.ts.map +1 -1
- package/dist/resources/checkout_sessions.d.ts +3 -3
- package/dist/resources/checkout_sessions.d.ts.map +1 -1
- package/dist/resources/customers.d.ts +5 -5
- package/dist/resources/customers.d.ts.map +1 -1
- package/dist/resources/entity.d.ts +2 -2
- package/dist/resources/entity.d.ts.map +1 -1
- package/dist/resources/invoices.d.ts +10 -10
- package/dist/resources/invoices.d.ts.map +1 -1
- package/dist/resources/payee_trust_requests.d.ts +3 -3
- package/dist/resources/payee_trust_requests.d.ts.map +1 -1
- package/dist/resources/payment_links.d.ts +4 -4
- package/dist/resources/payment_links.d.ts.map +1 -1
- package/dist/resources/payments.d.ts +15 -0
- package/dist/resources/payments.d.ts.map +1 -0
- package/dist/resources/transfer_authorizer.d.ts +6 -0
- package/dist/resources/transfer_authorizer.d.ts.map +1 -0
- package/dist/resources/transfer_drafts.d.ts +8 -14
- package/dist/resources/transfer_drafts.d.ts.map +1 -1
- package/dist/resources/webhook_endpoints.d.ts +9 -9
- package/dist/resources/webhook_endpoints.d.ts.map +1 -1
- package/dist/response.d.ts +1 -1
- package/dist/response.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/webhook.d.ts +32 -0
- package/dist/webhook.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
+
// src/env.ts
|
|
2
|
+
var WARNED = Symbol.for("@getmanza/sdk.warnedLegacyEnv");
|
|
3
|
+
var store = globalThis;
|
|
4
|
+
store[WARNED] ??= new Set;
|
|
5
|
+
var warned = store[WARNED];
|
|
6
|
+
function rawEnv(name) {
|
|
7
|
+
if (typeof process !== "undefined" && process.env)
|
|
8
|
+
return process.env[name];
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
function readEnv(name) {
|
|
12
|
+
const value = rawEnv(`MANZA_${name}`);
|
|
13
|
+
if (value !== undefined)
|
|
14
|
+
return value;
|
|
15
|
+
const legacy = `ZAZU_${name}`;
|
|
16
|
+
const legacyValue = rawEnv(legacy);
|
|
17
|
+
if (legacyValue !== undefined && !warned.has(legacy)) {
|
|
18
|
+
warned.add(legacy);
|
|
19
|
+
console.warn(`[manza] ${legacy} is deprecated and will be removed in 2.0. Use MANZA_${name} instead.`);
|
|
20
|
+
}
|
|
21
|
+
return legacyValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
1
24
|
// src/errors.ts
|
|
2
|
-
class
|
|
25
|
+
class ManzaError extends Error {
|
|
3
26
|
status;
|
|
4
27
|
requestId;
|
|
5
28
|
type;
|
|
@@ -18,25 +41,25 @@ class ZazuError extends Error {
|
|
|
18
41
|
}
|
|
19
42
|
}
|
|
20
43
|
|
|
21
|
-
class
|
|
44
|
+
class ManzaConfigurationError extends ManzaError {
|
|
22
45
|
}
|
|
23
46
|
|
|
24
|
-
class
|
|
47
|
+
class ManzaConnectionError extends ManzaError {
|
|
25
48
|
}
|
|
26
49
|
|
|
27
|
-
class
|
|
50
|
+
class ManzaAuthenticationError extends ManzaError {
|
|
28
51
|
}
|
|
29
52
|
|
|
30
|
-
class
|
|
53
|
+
class ManzaForbiddenError extends ManzaError {
|
|
31
54
|
}
|
|
32
55
|
|
|
33
|
-
class
|
|
56
|
+
class ManzaNotFoundError extends ManzaError {
|
|
34
57
|
}
|
|
35
58
|
|
|
36
|
-
class
|
|
59
|
+
class ManzaValidationError extends ManzaError {
|
|
37
60
|
}
|
|
38
61
|
|
|
39
|
-
class
|
|
62
|
+
class ManzaRateLimitError extends ManzaError {
|
|
40
63
|
retryAfter;
|
|
41
64
|
constructor(message, options = {}) {
|
|
42
65
|
super(message, options);
|
|
@@ -44,13 +67,13 @@ class ZazuRateLimitError extends ZazuError {
|
|
|
44
67
|
}
|
|
45
68
|
}
|
|
46
69
|
|
|
47
|
-
class
|
|
70
|
+
class ManzaServerError extends ManzaError {
|
|
48
71
|
}
|
|
49
72
|
|
|
50
|
-
class
|
|
73
|
+
class ManzaArgumentError extends ManzaError {
|
|
51
74
|
}
|
|
52
75
|
|
|
53
|
-
class
|
|
76
|
+
class ManzaConflictError extends ManzaError {
|
|
54
77
|
paymentId;
|
|
55
78
|
constructor(message, options = {}) {
|
|
56
79
|
super(message, options);
|
|
@@ -70,7 +93,7 @@ class Page {
|
|
|
70
93
|
constructor(response, fetcher) {
|
|
71
94
|
const body = response.body;
|
|
72
95
|
if (!body || !Array.isArray(body.data)) {
|
|
73
|
-
throw new
|
|
96
|
+
throw new ManzaArgumentError("Page response body has no `data` array — was this a list endpoint?", { body });
|
|
74
97
|
}
|
|
75
98
|
this.response = response;
|
|
76
99
|
this.data = body.data;
|
|
@@ -124,10 +147,10 @@ class ResourceBase {
|
|
|
124
147
|
if (limit === undefined || limit === null)
|
|
125
148
|
return MAX_PER_PAGE;
|
|
126
149
|
if (!Number.isInteger(limit) || limit <= 0) {
|
|
127
|
-
throw new
|
|
150
|
+
throw new ManzaArgumentError(`limit must be a positive integer (got ${JSON.stringify(limit)})`);
|
|
128
151
|
}
|
|
129
152
|
if (limit > MAX_PER_PAGE) {
|
|
130
|
-
throw new
|
|
153
|
+
throw new ManzaArgumentError(`limit cannot exceed ${MAX_PER_PAGE} (got ${limit})`);
|
|
131
154
|
}
|
|
132
155
|
return limit;
|
|
133
156
|
}
|
|
@@ -135,7 +158,7 @@ class ResourceBase {
|
|
|
135
158
|
const encoded = segments.map((s) => {
|
|
136
159
|
const str = String(s);
|
|
137
160
|
if (str.length === 0) {
|
|
138
|
-
throw new
|
|
161
|
+
throw new ManzaArgumentError("path segment cannot be blank");
|
|
139
162
|
}
|
|
140
163
|
return str.replace(/[^A-Za-z0-9._~-]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`);
|
|
141
164
|
});
|
|
@@ -306,19 +329,19 @@ class PaymentLinks extends ResourceBase {
|
|
|
306
329
|
}
|
|
307
330
|
}
|
|
308
331
|
|
|
309
|
-
// src/resources/
|
|
310
|
-
class
|
|
332
|
+
// src/resources/payments.ts
|
|
333
|
+
class Payments extends ResourceBase {
|
|
311
334
|
create(attributes) {
|
|
312
|
-
return this.httpPost("api/
|
|
335
|
+
return this.httpPost("api/payments", attributes);
|
|
313
336
|
}
|
|
314
337
|
get(id) {
|
|
315
|
-
return this.httpGet(this.encodePath("api/
|
|
338
|
+
return this.httpGet(this.encodePath("api/payments", id));
|
|
316
339
|
}
|
|
317
340
|
authorize(id, params) {
|
|
318
341
|
if (!params.signature || params.signature.trim() === "") {
|
|
319
|
-
throw new
|
|
342
|
+
throw new ManzaArgumentError("signature cannot be blank");
|
|
320
343
|
}
|
|
321
|
-
return this.httpPost(this.encodePath("api/
|
|
344
|
+
return this.httpPost(this.encodePath("api/payments", id, "authorize"), {
|
|
322
345
|
authorization_id: params.authorization_id,
|
|
323
346
|
signature: params.signature
|
|
324
347
|
});
|
|
@@ -327,7 +350,14 @@ class TransferDrafts extends ResourceBase {
|
|
|
327
350
|
const body = { authorization_id: params.authorization_id };
|
|
328
351
|
if (params.reason !== undefined && params.reason !== null)
|
|
329
352
|
body.reason = params.reason;
|
|
330
|
-
return this.httpPost(this.encodePath("api/
|
|
353
|
+
return this.httpPost(this.encodePath("api/payments", id, "decline"), body);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// src/resources/transfer_authorizer.ts
|
|
358
|
+
class TransferAuthorizer extends ResourceBase {
|
|
359
|
+
get() {
|
|
360
|
+
return this.httpGet("api/transfer_authorizer");
|
|
331
361
|
}
|
|
332
362
|
}
|
|
333
363
|
|
|
@@ -364,7 +394,7 @@ class WebhookEndpoints extends ResourceBase {
|
|
|
364
394
|
}
|
|
365
395
|
|
|
366
396
|
// src/response.ts
|
|
367
|
-
class
|
|
397
|
+
class ManzaResponse {
|
|
368
398
|
status;
|
|
369
399
|
headers;
|
|
370
400
|
body;
|
|
@@ -384,14 +414,14 @@ class ZazuResponse {
|
|
|
384
414
|
}
|
|
385
415
|
|
|
386
416
|
// src/version.ts
|
|
387
|
-
var VERSION = "
|
|
417
|
+
var VERSION = "1.1.0";
|
|
388
418
|
|
|
389
419
|
// src/client.ts
|
|
390
420
|
var DEFAULT_BASE_URL = "https://ma.manza.finance";
|
|
391
421
|
var DEFAULT_TIMEOUT_MS = 30000;
|
|
392
|
-
var USER_AGENT = `
|
|
422
|
+
var USER_AGENT = `manza-ts/${VERSION}`;
|
|
393
423
|
|
|
394
|
-
class
|
|
424
|
+
class Manza {
|
|
395
425
|
apiKey;
|
|
396
426
|
baseUrl;
|
|
397
427
|
apiVersion;
|
|
@@ -405,17 +435,19 @@ class Zazu {
|
|
|
405
435
|
invoices;
|
|
406
436
|
payeeTrustRequests;
|
|
407
437
|
paymentLinks;
|
|
438
|
+
payments;
|
|
439
|
+
transferAuthorizer;
|
|
408
440
|
transferDrafts;
|
|
409
441
|
webhookEndpoints;
|
|
410
442
|
constructor(options = {}) {
|
|
411
|
-
const apiKey = options.apiKey ?? readEnv("
|
|
443
|
+
const apiKey = options.apiKey ?? readEnv("API_KEY");
|
|
412
444
|
if (!apiKey) {
|
|
413
|
-
throw new
|
|
445
|
+
throw new ManzaConfigurationError("Missing apiKey. Pass apiKey or set MANZA_API_KEY.");
|
|
414
446
|
}
|
|
415
447
|
this.apiKey = apiKey;
|
|
416
|
-
this.baseUrl = (options.baseUrl ?? readEnv("
|
|
417
|
-
this.apiVersion = options.apiVersion ?? readEnv("
|
|
418
|
-
this.timeoutMs = options.timeoutMs ?? (Number(readEnv("
|
|
448
|
+
this.baseUrl = (options.baseUrl ?? readEnv("BASE_URL") ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
449
|
+
this.apiVersion = options.apiVersion ?? readEnv("API_VERSION") ?? null;
|
|
450
|
+
this.timeoutMs = options.timeoutMs ?? (Number(readEnv("TIMEOUT_MS")) || DEFAULT_TIMEOUT_MS);
|
|
419
451
|
this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
420
452
|
this.accounts = new Accounts(this);
|
|
421
453
|
this.beneficiaries = new Beneficiaries(this);
|
|
@@ -425,7 +457,9 @@ class Zazu {
|
|
|
425
457
|
this.invoices = new Invoices(this);
|
|
426
458
|
this.payeeTrustRequests = new PayeeTrustRequests(this);
|
|
427
459
|
this.paymentLinks = new PaymentLinks(this);
|
|
428
|
-
this.
|
|
460
|
+
this.payments = new Payments(this);
|
|
461
|
+
this.transferAuthorizer = new TransferAuthorizer(this);
|
|
462
|
+
this.transferDrafts = this.payments;
|
|
429
463
|
this.webhookEndpoints = new WebhookEndpoints(this);
|
|
430
464
|
}
|
|
431
465
|
async request(method, path, options = {}) {
|
|
@@ -436,7 +470,7 @@ class Zazu {
|
|
|
436
470
|
Accept: "application/json"
|
|
437
471
|
});
|
|
438
472
|
if (this.apiVersion)
|
|
439
|
-
headers.set("
|
|
473
|
+
headers.set("Manza-Version", this.apiVersion);
|
|
440
474
|
if (options.headers) {
|
|
441
475
|
for (const [k, v] of Object.entries(options.headers))
|
|
442
476
|
headers.set(k, v);
|
|
@@ -454,14 +488,14 @@ class Zazu {
|
|
|
454
488
|
raw = await this.#fetch(url, init);
|
|
455
489
|
} catch (err) {
|
|
456
490
|
if (err instanceof Error && err.name === "AbortError") {
|
|
457
|
-
throw new
|
|
491
|
+
throw new ManzaConnectionError(`Request timed out after ${this.timeoutMs}ms`);
|
|
458
492
|
}
|
|
459
|
-
throw new
|
|
493
|
+
throw new ManzaConnectionError(`Connection failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
460
494
|
} finally {
|
|
461
495
|
clearTimeout(timeout);
|
|
462
496
|
}
|
|
463
497
|
const body = await parseBody(raw);
|
|
464
|
-
const response = new
|
|
498
|
+
const response = new ManzaResponse(raw, body);
|
|
465
499
|
if (response.success)
|
|
466
500
|
return response;
|
|
467
501
|
throw buildError(response);
|
|
@@ -513,43 +547,40 @@ function buildError(response) {
|
|
|
513
547
|
};
|
|
514
548
|
switch (response.status) {
|
|
515
549
|
case 400:
|
|
516
|
-
return new
|
|
550
|
+
return new ManzaValidationError(message ?? "Bad request", opts);
|
|
517
551
|
case 401:
|
|
518
|
-
return new
|
|
552
|
+
return new ManzaAuthenticationError(message ?? "Authentication failed", opts);
|
|
519
553
|
case 403:
|
|
520
|
-
return new
|
|
554
|
+
return new ManzaForbiddenError(message ?? "Forbidden", opts);
|
|
521
555
|
case 404:
|
|
522
|
-
return new
|
|
556
|
+
return new ManzaNotFoundError(message ?? "Not found", opts);
|
|
523
557
|
case 409:
|
|
524
|
-
return new
|
|
558
|
+
return new ManzaConflictError(message ?? "Conflict", {
|
|
525
559
|
...opts,
|
|
526
560
|
paymentId: payload.payment_id ?? null
|
|
527
561
|
});
|
|
528
562
|
case 422:
|
|
529
|
-
return new
|
|
563
|
+
return new ManzaValidationError(message ?? "Validation failed", opts);
|
|
530
564
|
case 429: {
|
|
531
565
|
const retryAfter = Number(response.headers.get("retry-after"));
|
|
532
|
-
return new
|
|
566
|
+
return new ManzaRateLimitError(message ?? "Rate limited", {
|
|
533
567
|
...opts,
|
|
534
568
|
retryAfter: Number.isFinite(retryAfter) ? retryAfter : null
|
|
535
569
|
});
|
|
536
570
|
}
|
|
537
571
|
}
|
|
538
572
|
if (response.status >= 500 && response.status < 600) {
|
|
539
|
-
return new
|
|
573
|
+
return new ManzaServerError(message ?? `Server error (${response.status})`, opts);
|
|
540
574
|
}
|
|
541
|
-
return new
|
|
542
|
-
}
|
|
543
|
-
function readEnv(name) {
|
|
544
|
-
if (typeof process !== "undefined" && process.env)
|
|
545
|
-
return process.env[name];
|
|
546
|
-
return;
|
|
575
|
+
return new ManzaError(message ?? `Unexpected status ${response.status}`, opts);
|
|
547
576
|
}
|
|
577
|
+
// src/resources/transfer_drafts.ts
|
|
578
|
+
var TransferDrafts = Payments;
|
|
548
579
|
// src/transfer_authorization.ts
|
|
549
580
|
var SIGNATURE_VERSION = "manza.transfer-authorization.v1";
|
|
550
581
|
function signatureInput(fields) {
|
|
551
582
|
if (typeof fields.amount !== "string") {
|
|
552
|
-
throw new
|
|
583
|
+
throw new ManzaArgumentError(`amount must be the API's decimal string (got ${JSON.stringify(fields.amount)})`);
|
|
553
584
|
}
|
|
554
585
|
return [
|
|
555
586
|
SIGNATURE_VERSION,
|
|
@@ -572,7 +603,7 @@ function payeeFor(params) {
|
|
|
572
603
|
const ext = params.external_account_id ?? null;
|
|
573
604
|
const own = params.destination_account_id ?? null;
|
|
574
605
|
if (ext === null === (own === null)) {
|
|
575
|
-
throw new
|
|
606
|
+
throw new ManzaArgumentError("pass exactly one of external_account_id or destination_account_id");
|
|
576
607
|
}
|
|
577
608
|
return own !== null ? `own:${own}` : `ext:${ext}`;
|
|
578
609
|
}
|
|
@@ -582,6 +613,109 @@ var TransferAuthorization = {
|
|
|
582
613
|
sign,
|
|
583
614
|
payeeFor
|
|
584
615
|
};
|
|
616
|
+
// src/webhook.ts
|
|
617
|
+
var DEFAULT_TOLERANCE = 300;
|
|
618
|
+
function sign2(params) {
|
|
619
|
+
if (params.secret === "") {
|
|
620
|
+
return Promise.reject(new ManzaArgumentError("secret cannot be empty"));
|
|
621
|
+
}
|
|
622
|
+
return sign({
|
|
623
|
+
secret: params.secret,
|
|
624
|
+
signature_input: `${params.timestamp}.${params.payload}`
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
async function verify(params) {
|
|
628
|
+
return await signatureMatches(params.payload, params.signature, params.timestamp, params.secret) && timestampFresh(params.timestamp, params.tolerance, params.now);
|
|
629
|
+
}
|
|
630
|
+
async function constructEvent(params) {
|
|
631
|
+
const normalized = normalizeHeaders(params.headers);
|
|
632
|
+
const signature = header(normalized, "signature");
|
|
633
|
+
const timestamp = header(normalized, "timestamp");
|
|
634
|
+
if (!await signatureMatches(params.payload, signature, timestamp, params.secret)) {
|
|
635
|
+
throw new ManzaArgumentError("invalid webhook signature");
|
|
636
|
+
}
|
|
637
|
+
if (!timestampFresh(timestamp, params.tolerance, params.now)) {
|
|
638
|
+
throw new ManzaArgumentError("webhook timestamp outside tolerance");
|
|
639
|
+
}
|
|
640
|
+
let event;
|
|
641
|
+
try {
|
|
642
|
+
event = JSON.parse(params.payload);
|
|
643
|
+
} catch {
|
|
644
|
+
throw new ManzaArgumentError("webhook payload is not JSON");
|
|
645
|
+
}
|
|
646
|
+
if (event === null || typeof event !== "object" || Array.isArray(event)) {
|
|
647
|
+
throw new ManzaArgumentError("webhook payload is not a JSON object");
|
|
648
|
+
}
|
|
649
|
+
return event;
|
|
650
|
+
}
|
|
651
|
+
async function signatureMatches(payload, signature, timestamp, secret) {
|
|
652
|
+
if (typeof payload !== "string" || typeof secret !== "string" || secret === "")
|
|
653
|
+
return false;
|
|
654
|
+
if (typeof signature !== "string")
|
|
655
|
+
return false;
|
|
656
|
+
if (typeof timestamp !== "string" && typeof timestamp !== "number")
|
|
657
|
+
return false;
|
|
658
|
+
if (parseTimestamp(timestamp) === null)
|
|
659
|
+
return false;
|
|
660
|
+
const expected = await sign2({ payload, timestamp, secret });
|
|
661
|
+
return constantTimeEqual(expected, signature);
|
|
662
|
+
}
|
|
663
|
+
function constantTimeEqual(a, b) {
|
|
664
|
+
if (a.length !== b.length)
|
|
665
|
+
return false;
|
|
666
|
+
let diff = 0;
|
|
667
|
+
for (let i = 0;i < a.length; i++)
|
|
668
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
669
|
+
return diff === 0;
|
|
670
|
+
}
|
|
671
|
+
function timestampFresh(timestamp, tolerance, now) {
|
|
672
|
+
if (tolerance === null)
|
|
673
|
+
return true;
|
|
674
|
+
const seconds = parseTimestamp(timestamp);
|
|
675
|
+
if (seconds === null)
|
|
676
|
+
return false;
|
|
677
|
+
const nowSeconds = Math.floor((now ?? new Date).getTime() / 1000);
|
|
678
|
+
return Math.abs(nowSeconds - seconds) <= (tolerance ?? DEFAULT_TOLERANCE);
|
|
679
|
+
}
|
|
680
|
+
function parseTimestamp(timestamp) {
|
|
681
|
+
if (typeof timestamp === "number")
|
|
682
|
+
return Number.isInteger(timestamp) ? timestamp : null;
|
|
683
|
+
if (typeof timestamp !== "string" || !/^[+-]?\d+$/.test(timestamp.trim()))
|
|
684
|
+
return null;
|
|
685
|
+
return Number.parseInt(timestamp, 10);
|
|
686
|
+
}
|
|
687
|
+
function normalizeHeaders(headers) {
|
|
688
|
+
const entries = [];
|
|
689
|
+
if (headers instanceof Headers) {
|
|
690
|
+
headers.forEach((value, name) => {
|
|
691
|
+
entries.push([name, value]);
|
|
692
|
+
});
|
|
693
|
+
} else {
|
|
694
|
+
entries.push(...Object.entries(headers ?? {}));
|
|
695
|
+
}
|
|
696
|
+
const normalized = new Map;
|
|
697
|
+
for (const [name, raw] of entries) {
|
|
698
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
699
|
+
if (value === undefined || value === null)
|
|
700
|
+
continue;
|
|
701
|
+
normalized.set(name.replace(/^HTTP_/i, "").replace(/_/g, "-").toLowerCase(), String(value));
|
|
702
|
+
}
|
|
703
|
+
return normalized;
|
|
704
|
+
}
|
|
705
|
+
function header(normalized, suffix) {
|
|
706
|
+
const manza = `x-manza-${suffix}`;
|
|
707
|
+
const value = normalized.has(manza) ? normalized.get(manza) : normalized.get(`x-zazu-${suffix}`);
|
|
708
|
+
if (value)
|
|
709
|
+
return value;
|
|
710
|
+
const name = suffix.charAt(0).toUpperCase() + suffix.slice(1);
|
|
711
|
+
throw new ManzaArgumentError(`missing X-Manza-${name} header`);
|
|
712
|
+
}
|
|
713
|
+
var Webhook = {
|
|
714
|
+
DEFAULT_TOLERANCE,
|
|
715
|
+
sign: sign2,
|
|
716
|
+
verify,
|
|
717
|
+
constructEvent
|
|
718
|
+
};
|
|
585
719
|
export {
|
|
586
720
|
Accounts,
|
|
587
721
|
Beneficiaries,
|
|
@@ -590,24 +724,27 @@ export {
|
|
|
590
724
|
Entity,
|
|
591
725
|
Invoices,
|
|
592
726
|
MAX_PER_PAGE,
|
|
727
|
+
Manza,
|
|
728
|
+
ManzaArgumentError,
|
|
729
|
+
ManzaAuthenticationError,
|
|
730
|
+
ManzaConfigurationError,
|
|
731
|
+
ManzaConflictError,
|
|
732
|
+
ManzaConnectionError,
|
|
733
|
+
ManzaError,
|
|
734
|
+
ManzaForbiddenError,
|
|
735
|
+
ManzaNotFoundError,
|
|
736
|
+
ManzaRateLimitError,
|
|
737
|
+
ManzaResponse,
|
|
738
|
+
ManzaServerError,
|
|
739
|
+
ManzaValidationError,
|
|
593
740
|
Page,
|
|
594
741
|
PayeeTrustRequests,
|
|
595
742
|
PaymentLinks,
|
|
743
|
+
Payments,
|
|
596
744
|
TransferAuthorization,
|
|
745
|
+
TransferAuthorizer,
|
|
597
746
|
TransferDrafts,
|
|
598
747
|
VERSION,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
ZazuArgumentError,
|
|
602
|
-
ZazuAuthenticationError,
|
|
603
|
-
ZazuConfigurationError,
|
|
604
|
-
ZazuConflictError,
|
|
605
|
-
ZazuConnectionError,
|
|
606
|
-
ZazuError,
|
|
607
|
-
ZazuForbiddenError,
|
|
608
|
-
ZazuNotFoundError,
|
|
609
|
-
ZazuRateLimitError,
|
|
610
|
-
ZazuResponse,
|
|
611
|
-
ZazuServerError,
|
|
612
|
-
ZazuValidationError
|
|
748
|
+
Webhook,
|
|
749
|
+
WebhookEndpoints
|
|
613
750
|
};
|
package/dist/page.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ManzaResponse } from "./response.js";
|
|
2
2
|
export declare const MAX_PER_PAGE = 100;
|
|
3
3
|
export interface PageBody<T> {
|
|
4
4
|
data: T[];
|
|
@@ -11,8 +11,8 @@ export declare class Page<T> {
|
|
|
11
11
|
readonly data: T[];
|
|
12
12
|
readonly hasMore: boolean;
|
|
13
13
|
readonly nextCursor: string | null;
|
|
14
|
-
readonly response:
|
|
15
|
-
constructor(response:
|
|
14
|
+
readonly response: ManzaResponse<PageBody<T>>;
|
|
15
|
+
constructor(response: ManzaResponse<PageBody<T>>, fetcher: PageFetcher<T>);
|
|
16
16
|
next(): Promise<Page<T> | null>;
|
|
17
17
|
records(): AsyncIterableIterator<T>;
|
|
18
18
|
}
|
package/dist/page.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzE,qBAAa,IAAI,CAAC,CAAC;;IACjB,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAGlC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAenE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAM9B,OAAO,IAAI,qBAAqB,CAAC,CAAC,CAAC;CAQ3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Page } from "../page.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ManzaResponse } from "../response.js";
|
|
3
3
|
import { type ListParams, ResourceBase } from "./base.js";
|
|
4
4
|
export interface AccountListParams extends ListParams {
|
|
5
5
|
status?: string;
|
|
@@ -12,8 +12,8 @@ export interface TransactionListParams extends ListParams {
|
|
|
12
12
|
}
|
|
13
13
|
export declare class Accounts extends ResourceBase {
|
|
14
14
|
list(params?: AccountListParams): Promise<Page<unknown>>;
|
|
15
|
-
get(id: string): Promise<
|
|
15
|
+
get(id: string): Promise<ManzaResponse>;
|
|
16
16
|
listTransactions(accountId: string, params?: TransactionListParams): Promise<Page<unknown>>;
|
|
17
|
-
getTransaction(accountId: string, transactionId: string): Promise<
|
|
17
|
+
getTransaction(accountId: string, transactionId: string): Promise<ManzaResponse>;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,qBAAa,QAAS,SAAQ,YAAY;IACxC,IAAI,CAAC,MAAM,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAK5D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAa/F,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAGjF"}
|
package/dist/resources/base.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Manza } from "../client.js";
|
|
2
2
|
import { Page } from "../page.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ManzaResponse } from "../response.js";
|
|
4
4
|
export interface ListParams {
|
|
5
5
|
limit?: number | undefined;
|
|
6
6
|
cursor?: string | null | undefined;
|
|
7
7
|
}
|
|
8
8
|
export declare abstract class ResourceBase {
|
|
9
|
-
protected readonly client:
|
|
10
|
-
constructor(client:
|
|
11
|
-
protected httpGet<T>(path: string, params?: Record<string, unknown>): Promise<
|
|
12
|
-
protected httpPost<T>(path: string, body?: unknown): Promise<
|
|
13
|
-
protected httpPatch<T>(path: string, body?: unknown): Promise<
|
|
14
|
-
protected httpDelete<T>(path: string): Promise<
|
|
9
|
+
protected readonly client: Manza;
|
|
10
|
+
constructor(client: Manza);
|
|
11
|
+
protected httpGet<T>(path: string, params?: Record<string, unknown>): Promise<ManzaResponse<T>>;
|
|
12
|
+
protected httpPost<T>(path: string, body?: unknown): Promise<ManzaResponse<T>>;
|
|
13
|
+
protected httpPatch<T>(path: string, body?: unknown): Promise<ManzaResponse<T>>;
|
|
14
|
+
protected httpDelete<T>(path: string): Promise<ManzaResponse<T>>;
|
|
15
15
|
protected listPage<T>(path: string, params?: Record<string, unknown>, listOpts?: ListParams): Promise<Page<T>>;
|
|
16
16
|
protected validateLimit(limit: number | undefined): number;
|
|
17
17
|
protected encodePath(base: string, ...segments: string[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/resources/base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/resources/base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAgB,IAAI,EAAiB,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACpC;AAED,8BAAsB,YAAY;IAChC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;gBAErB,MAAM,EAAE,KAAK;IAIzB,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI/F,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI9E,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI/E,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;cAIhD,QAAQ,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACpC,QAAQ,GAAE,UAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAYnB,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IAiB1D,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM;CAalE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Page } from "../page.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ManzaResponse } from "../response.js";
|
|
3
3
|
import { type ListParams, ResourceBase } from "./base.js";
|
|
4
4
|
export declare class Beneficiaries extends ResourceBase {
|
|
5
5
|
list(params?: ListParams): Promise<Page<unknown>>;
|
|
6
|
-
get(id: string): Promise<
|
|
7
|
-
create(attributes: Record<string, unknown>): Promise<
|
|
6
|
+
get(id: string): Promise<ManzaResponse>;
|
|
7
|
+
create(attributes: Record<string, unknown>): Promise<ManzaResponse>;
|
|
8
8
|
listExternalAccounts(beneficiaryId: string, params?: ListParams): Promise<Page<unknown>>;
|
|
9
|
-
getExternalAccount(beneficiaryId: string, id: string): Promise<
|
|
10
|
-
createExternalAccount(beneficiaryId: string, attributes: Record<string, unknown>): Promise<
|
|
9
|
+
getExternalAccount(beneficiaryId: string, id: string): Promise<ManzaResponse>;
|
|
10
|
+
createExternalAccount(beneficiaryId: string, attributes: Record<string, unknown>): Promise<ManzaResponse>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=beneficiaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/resources/beneficiaries.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"beneficiaries.d.ts","sourceRoot":"","sources":["../../src/resources/beneficiaries.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1D,qBAAa,aAAc,SAAQ,YAAY;IAC7C,IAAI,CAAC,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAKrD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAQvC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAInE,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAS5F,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAS7E,qBAAqB,CACnB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,aAAa,CAAC;CAM1B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ManzaResponse } from "../response.js";
|
|
2
2
|
import { ResourceBase } from "./base.js";
|
|
3
3
|
export declare class CheckoutSessions extends ResourceBase {
|
|
4
|
-
get(id: string): Promise<
|
|
5
|
-
create(attributes: Record<string, unknown>): Promise<
|
|
4
|
+
get(id: string): Promise<ManzaResponse>;
|
|
5
|
+
create(attributes: Record<string, unknown>): Promise<ManzaResponse>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=checkout_sessions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout_sessions.d.ts","sourceRoot":"","sources":["../../src/resources/checkout_sessions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"checkout_sessions.d.ts","sourceRoot":"","sources":["../../src/resources/checkout_sessions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;CAGpE"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Page } from "../page.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ManzaResponse } from "../response.js";
|
|
3
3
|
import { type ListParams, ResourceBase } from "./base.js";
|
|
4
4
|
export interface CustomerListParams extends ListParams {
|
|
5
5
|
q?: string;
|
|
6
6
|
}
|
|
7
7
|
export declare class Customers extends ResourceBase {
|
|
8
8
|
list(params?: CustomerListParams): Promise<Page<unknown>>;
|
|
9
|
-
get(id: string): Promise<
|
|
10
|
-
create(attributes: Record<string, unknown>): Promise<
|
|
11
|
-
update(id: string, attributes: Record<string, unknown>): Promise<
|
|
12
|
-
delete(id: string): Promise<
|
|
9
|
+
get(id: string): Promise<ManzaResponse>;
|
|
10
|
+
create(attributes: Record<string, unknown>): Promise<ManzaResponse>;
|
|
11
|
+
update(id: string, attributes: Record<string, unknown>): Promise<ManzaResponse>;
|
|
12
|
+
delete(id: string): Promise<ManzaResponse>;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/resources/customers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/resources/customers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,qBAAa,SAAU,SAAQ,YAAY;IACzC,IAAI,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAK7D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAInE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAI/E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAG3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ManzaResponse } from "../response.js";
|
|
2
2
|
import { ResourceBase } from "./base.js";
|
|
3
3
|
export declare class Entity extends ResourceBase {
|
|
4
|
-
get(): Promise<
|
|
4
|
+
get(): Promise<ManzaResponse>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/resources/entity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/resources/entity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,qBAAa,MAAO,SAAQ,YAAY;IACtC,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;CAG9B"}
|