velirapay 0.1.0 → 0.2.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +699 -51
  3. package/dist/cjs/client.d.ts +1 -1
  4. package/dist/cjs/enums.d.ts +159 -27
  5. package/dist/cjs/enums.js +150 -25
  6. package/dist/cjs/errors.d.ts +10 -1
  7. package/dist/cjs/errors.js +12 -1
  8. package/dist/cjs/http/transport.js +18 -3
  9. package/dist/cjs/index.d.ts +4 -4
  10. package/dist/cjs/index.js +12 -2
  11. package/dist/cjs/page.d.ts +14 -2
  12. package/dist/cjs/page.js +19 -2
  13. package/dist/cjs/params.d.ts +17 -10
  14. package/dist/cjs/resources/account.d.ts +13 -13
  15. package/dist/cjs/resources/account.js +7 -7
  16. package/dist/cjs/resources/activity.d.ts +4 -3
  17. package/dist/cjs/resources/activity.js +1 -1
  18. package/dist/cjs/resources/api-key.d.ts +3 -2
  19. package/dist/cjs/resources/api-resource.d.ts +2 -0
  20. package/dist/cjs/resources/api-resource.js +5 -0
  21. package/dist/cjs/resources/charge.d.ts +10 -2
  22. package/dist/cjs/resources/charge.js +6 -0
  23. package/dist/cjs/resources/coupon.d.ts +2 -1
  24. package/dist/cjs/resources/event.d.ts +3 -3
  25. package/dist/cjs/resources/event.js +1 -1
  26. package/dist/cjs/resources/invoice.d.ts +4 -4
  27. package/dist/cjs/resources/member.d.ts +5 -4
  28. package/dist/cjs/resources/member.js +2 -2
  29. package/dist/cjs/resources/overview.d.ts +116 -4
  30. package/dist/cjs/resources/overview.js +76 -3
  31. package/dist/cjs/resources/payment-link.d.ts +3 -3
  32. package/dist/cjs/resources/payout.d.ts +5 -5
  33. package/dist/cjs/resources/payout.js +1 -1
  34. package/dist/cjs/resources/pro-payment.d.ts +3 -2
  35. package/dist/cjs/resources/supported-asset.d.ts +2 -2
  36. package/dist/cjs/resources/webhook-endpoint.d.ts +5 -4
  37. package/dist/cjs/resources/webhook-endpoint.js +3 -2
  38. package/dist/cjs/services/account.js +1 -1
  39. package/dist/cjs/services/api-keys.d.ts +7 -1
  40. package/dist/cjs/services/api-keys.js +7 -1
  41. package/dist/cjs/services/assets.d.ts +3 -4
  42. package/dist/cjs/services/assets.js +3 -2
  43. package/dist/cjs/services/charges.d.ts +10 -10
  44. package/dist/cjs/services/charges.js +12 -8
  45. package/dist/cjs/services/coupons.js +1 -1
  46. package/dist/cjs/services/invoices.js +5 -1
  47. package/dist/cjs/services/members.d.ts +2 -2
  48. package/dist/cjs/services/members.js +2 -2
  49. package/dist/cjs/services/overview.d.ts +1 -1
  50. package/dist/cjs/services/overview.js +3 -2
  51. package/dist/cjs/services/payment-links.js +4 -2
  52. package/dist/cjs/services/payout-addresses.d.ts +9 -4
  53. package/dist/cjs/services/payout-addresses.js +6 -2
  54. package/dist/cjs/services/service.d.ts +8 -3
  55. package/dist/cjs/services/service.js +45 -10
  56. package/dist/cjs/services/webhook-endpoints.d.ts +15 -2
  57. package/dist/cjs/services/webhook-endpoints.js +15 -2
  58. package/dist/cjs/version.d.ts +1 -1
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/client.d.ts +1 -1
  61. package/dist/esm/enums.d.ts +159 -27
  62. package/dist/esm/enums.js +149 -24
  63. package/dist/esm/errors.d.ts +10 -1
  64. package/dist/esm/errors.js +12 -1
  65. package/dist/esm/http/transport.js +18 -3
  66. package/dist/esm/index.d.ts +4 -4
  67. package/dist/esm/index.js +3 -3
  68. package/dist/esm/page.d.ts +14 -2
  69. package/dist/esm/page.js +17 -1
  70. package/dist/esm/params.d.ts +17 -10
  71. package/dist/esm/resources/account.d.ts +13 -13
  72. package/dist/esm/resources/account.js +8 -8
  73. package/dist/esm/resources/activity.d.ts +4 -3
  74. package/dist/esm/resources/activity.js +1 -1
  75. package/dist/esm/resources/api-key.d.ts +3 -2
  76. package/dist/esm/resources/api-resource.d.ts +2 -0
  77. package/dist/esm/resources/api-resource.js +4 -0
  78. package/dist/esm/resources/charge.d.ts +10 -2
  79. package/dist/esm/resources/charge.js +6 -0
  80. package/dist/esm/resources/coupon.d.ts +2 -1
  81. package/dist/esm/resources/event.d.ts +3 -3
  82. package/dist/esm/resources/event.js +1 -1
  83. package/dist/esm/resources/invoice.d.ts +4 -4
  84. package/dist/esm/resources/member.d.ts +5 -4
  85. package/dist/esm/resources/member.js +2 -2
  86. package/dist/esm/resources/overview.d.ts +116 -4
  87. package/dist/esm/resources/overview.js +77 -4
  88. package/dist/esm/resources/payment-link.d.ts +3 -3
  89. package/dist/esm/resources/payout.d.ts +5 -5
  90. package/dist/esm/resources/payout.js +1 -1
  91. package/dist/esm/resources/pro-payment.d.ts +3 -2
  92. package/dist/esm/resources/supported-asset.d.ts +2 -2
  93. package/dist/esm/resources/webhook-endpoint.d.ts +5 -4
  94. package/dist/esm/resources/webhook-endpoint.js +3 -2
  95. package/dist/esm/services/account.js +2 -2
  96. package/dist/esm/services/api-keys.d.ts +7 -1
  97. package/dist/esm/services/api-keys.js +7 -1
  98. package/dist/esm/services/assets.d.ts +3 -4
  99. package/dist/esm/services/assets.js +3 -2
  100. package/dist/esm/services/charges.d.ts +10 -10
  101. package/dist/esm/services/charges.js +13 -9
  102. package/dist/esm/services/coupons.js +2 -2
  103. package/dist/esm/services/invoices.js +6 -2
  104. package/dist/esm/services/members.d.ts +2 -2
  105. package/dist/esm/services/members.js +2 -2
  106. package/dist/esm/services/overview.d.ts +1 -1
  107. package/dist/esm/services/overview.js +4 -3
  108. package/dist/esm/services/payment-links.js +5 -3
  109. package/dist/esm/services/payout-addresses.d.ts +9 -4
  110. package/dist/esm/services/payout-addresses.js +6 -2
  111. package/dist/esm/services/service.d.ts +8 -3
  112. package/dist/esm/services/service.js +44 -10
  113. package/dist/esm/services/webhook-endpoints.d.ts +15 -2
  114. package/dist/esm/services/webhook-endpoints.js +15 -2
  115. package/dist/esm/version.d.ts +1 -1
  116. package/dist/esm/version.js +1 -1
  117. package/package.json +12 -2
@@ -5,9 +5,10 @@ const overview_ts_1 = require("../resources/overview.js");
5
5
  const service_ts_1 = require("./service.js");
6
6
  /** The /v1/overview endpoint. Needs overview:read. */
7
7
  class OverviewService extends service_ts_1.Service {
8
- /** Retrieve the dashboard's figures for the last 30 days, in the API key's mode. */
8
+ /** Retrieve the dashboard's figures for the last 30 days, in the API key's mode, and what needs attention now. */
9
9
  async retrieve() {
10
- return new overview_ts_1.Overview(await this.request('GET', '/v1/overview'));
10
+ const response = await this.respond('GET', '/v1/overview');
11
+ return new overview_ts_1.Overview((0, service_ts_1.data)(response), (0, service_ts_1.meta)(response));
11
12
  }
12
13
  }
13
14
  exports.OverviewService = OverviewService;
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentLinkService = void 0;
4
4
  const payment_link_ts_1 = require("../resources/payment-link.js");
5
5
  const service_ts_1 = require("./service.js");
6
+ /** The amounts a payment link takes, which go out as decimal strings. */
7
+ const AMOUNTS = ['amount', 'suggested_amounts', 'min_amount', 'max_amount'];
6
8
  /** The /v1/payment-links endpoints. */
7
9
  class PaymentLinkService extends service_ts_1.Service {
8
10
  /** Create a payment link: one reusable public page, never one per customer. */
9
11
  async create(params, options) {
10
- return new payment_link_ts_1.PaymentLink(await this.request('POST', '/v1/payment-links', params, options));
12
+ return new payment_link_ts_1.PaymentLink(await this.request('POST', '/v1/payment-links', (0, service_ts_1.withDecimalAmounts)(params, ...AMOUNTS), options));
11
13
  }
12
14
  /** Retrieve a payment link by its id. */
13
15
  async retrieve(id) {
@@ -15,7 +17,7 @@ class PaymentLinkService extends service_ts_1.Service {
15
17
  }
16
18
  /** Change any of a payment link's fields. */
17
19
  async update(id, params, options) {
18
- return new payment_link_ts_1.PaymentLink(await this.request('PATCH', (0, service_ts_1.path)('/v1/payment-links/%s', id), params, options));
20
+ return new payment_link_ts_1.PaymentLink(await this.request('PATCH', (0, service_ts_1.path)('/v1/payment-links/%s', id), (0, service_ts_1.withDecimalAmounts)(params, ...AMOUNTS), options));
19
21
  }
20
22
  /** List payment links, newest first. */
21
23
  async list(params = {}) {
@@ -1,12 +1,17 @@
1
+ import type { AddressNetwork, OrString } from '../enums.ts';
1
2
  import type { PayoutAddressUpdateParams, RequestOptions } from '../params.ts';
2
3
  import { PayoutAddress } from '../resources/payout.ts';
3
4
  import { Service } from './service.ts';
4
- /** The /v1/payout-addresses endpoints. Reading needs payout_addresses:read; changing needs payout_addresses:write and an owner's switch under Payment settings. */
5
+ /**
6
+ * The /v1/payout-addresses endpoints, one address per network family: bitcoin, litecoin, dogecoin, bitcoincash, evm (Ethereum),
7
+ * bsc (BNB Chain), base, arbitrum, polygon, tron, monero, solana or lightning, as the AddressNetwork values name them.
8
+ * Reading needs payout_addresses:read; changing needs payout_addresses:write and an owner's switch under Payment settings.
9
+ */
5
10
  export declare class PayoutAddressService extends Service {
6
11
  /** List where payouts go in the API key's mode: one entry per network with coins on offer, its address null while there is none. */
7
12
  list(): Promise<PayoutAddress[]>;
8
- /** Point the payouts of one network, such as "bitcoin" or "evm", at an address. */
9
- update(network: string, params: PayoutAddressUpdateParams, options?: RequestOptions): Promise<PayoutAddress>;
13
+ /** Point the payouts of one network, such as AddressNetwork.Bitcoin or "evm", at an address. */
14
+ update(network: OrString<AddressNetwork>, params: PayoutAddressUpdateParams, options?: RequestOptions): Promise<PayoutAddress>;
10
15
  /** Remove the address of one network, so its payouts wait for a new one. */
11
- delete(network: string, options?: RequestOptions): Promise<PayoutAddress>;
16
+ delete(network: OrString<AddressNetwork>, options?: RequestOptions): Promise<PayoutAddress>;
12
17
  }
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PayoutAddressService = void 0;
4
4
  const payout_ts_1 = require("../resources/payout.js");
5
5
  const service_ts_1 = require("./service.js");
6
- /** The /v1/payout-addresses endpoints. Reading needs payout_addresses:read; changing needs payout_addresses:write and an owner's switch under Payment settings. */
6
+ /**
7
+ * The /v1/payout-addresses endpoints, one address per network family: bitcoin, litecoin, dogecoin, bitcoincash, evm (Ethereum),
8
+ * bsc (BNB Chain), base, arbitrum, polygon, tron, monero, solana or lightning, as the AddressNetwork values name them.
9
+ * Reading needs payout_addresses:read; changing needs payout_addresses:write and an owner's switch under Payment settings.
10
+ */
7
11
  class PayoutAddressService extends service_ts_1.Service {
8
12
  /** List where payouts go in the API key's mode: one entry per network with coins on offer, its address null while there is none. */
9
13
  async list() {
10
14
  return (0, service_ts_1.list)(await this.respond('GET', '/v1/payout-addresses')).map((address) => new payout_ts_1.PayoutAddress(address));
11
15
  }
12
- /** Point the payouts of one network, such as "bitcoin" or "evm", at an address. */
16
+ /** Point the payouts of one network, such as AddressNetwork.Bitcoin or "evm", at an address. */
13
17
  async update(network, params, options) {
14
18
  return new payout_ts_1.PayoutAddress(await this.request('PUT', (0, service_ts_1.path)('/v1/payout-addresses/%s', network), params, options));
15
19
  }
@@ -1,8 +1,10 @@
1
1
  import type { ApiResponse } from '../http/api-response.ts';
2
2
  import type { HttpTransport } from '../http/transport.ts';
3
- import { Page } from '../page.ts';
3
+ import { Page, type PagePosition } from '../page.ts';
4
4
  import type { RequestOptions } from '../params.ts';
5
5
  import { type ApiResource, type Attributes } from '../resources/api-resource.ts';
6
+ /** A class of page, such as Page itself or one that reads more of the list's meta. */
7
+ type PageKind<T extends ApiResource, P extends Page<T>> = new (data: T[], position: PagePosition, fetch: (page: number) => Promise<P>, meta: Attributes) => P;
6
8
  /** The requests shared by every group of endpoints. */
7
9
  export declare abstract class Service {
8
10
  protected readonly transport: HttpTransport;
@@ -11,8 +13,8 @@ export declare abstract class Service {
11
13
  protected request(method: string, path: string, body?: object, options?: RequestOptions): Promise<Attributes>;
12
14
  /** Send a request and return the whole response, for answers whose meta matters too. */
13
15
  protected respond(method: string, path: string, body?: object, options?: RequestOptions): Promise<ApiResponse>;
14
- /** Fetch one page of a list. */
15
- protected page<T extends ApiResource>(path: string, params: object, hydrate: (attributes: Attributes) => T): Promise<Page<T>>;
16
+ /** Fetch one page of a list, as a Page unless another kind is given. */
17
+ protected page<T extends ApiResource, P extends Page<T> = Page<T>>(path: string, params: object, hydrate: (attributes: Attributes) => T, kind?: PageKind<T, P>): Promise<P>;
16
18
  }
17
19
  /** Read the object under a response's "data" key. */
18
20
  export declare function data(response: ApiResponse): Attributes;
@@ -20,5 +22,8 @@ export declare function data(response: ApiResponse): Attributes;
20
22
  export declare function meta(response: ApiResponse): Attributes;
21
23
  /** Read the objects of the list under a response's "data" key. */
22
24
  export declare function list(response: ApiResponse): Attributes[];
25
+ /** A copy of the params with the amounts under the given keys, alone or in a list, written as the API reads them. */
26
+ export declare function withDecimalAmounts<T extends object>(params: T, ...keys: string[]): T;
23
27
  /** Build a path with the given ids escaped into its %s placeholders. */
24
28
  export declare function path(format: string, ...ids: string[]): string;
29
+ export {};
@@ -4,6 +4,7 @@ exports.Service = void 0;
4
4
  exports.data = data;
5
5
  exports.meta = meta;
6
6
  exports.list = list;
7
+ exports.withDecimalAmounts = withDecimalAmounts;
7
8
  exports.path = path;
8
9
  const errors_ts_1 = require("../errors.js");
9
10
  const page_ts_1 = require("../page.js");
@@ -22,19 +23,18 @@ class Service {
22
23
  respond(method, path, body, options) {
23
24
  return this.transport.request(method, path, {}, body, options?.idempotencyKey);
24
25
  }
25
- /** Fetch one page of a list. */
26
- async page(path, params, hydrate) {
26
+ /** Fetch one page of a list, as a Page unless another kind is given. */
27
+ async page(path, params, hydrate, kind = page_ts_1.Page) {
27
28
  const response = await this.transport.request('GET', path, params);
28
29
  const data = list(response).map(hydrate);
29
- const json = response.json();
30
- const meta = (0, api_resource_ts_1.isRecord)(json['meta']) ? json['meta'] : {};
31
- const currentPage = integer(meta['current_page'], 1);
32
- return new page_ts_1.Page(data, {
30
+ const metadata = meta(response);
31
+ const currentPage = integer(metadata['current_page'], 1);
32
+ return new kind(data, {
33
33
  currentPage,
34
- lastPage: integer(meta['last_page'], currentPage),
35
- perPage: integer(meta['per_page'], data.length),
36
- total: integer(meta['total'], data.length),
37
- }, (page) => this.page(path, { ...params, page }, hydrate));
34
+ lastPage: integer(metadata['last_page'], currentPage),
35
+ perPage: integer(metadata['per_page'], data.length),
36
+ total: integer(metadata['total'], data.length),
37
+ }, (page) => this.page(path, { ...params, page }, hydrate, kind), metadata);
38
38
  }
39
39
  }
40
40
  exports.Service = Service;
@@ -59,6 +59,41 @@ function list(response) {
59
59
  }
60
60
  return value.filter(api_resource_ts_1.isRecord);
61
61
  }
62
+ /** A copy of the params with the amounts under the given keys, alone or in a list, written as the API reads them. */
63
+ function withDecimalAmounts(params, ...keys) {
64
+ const copy = { ...params };
65
+ for (const key of keys) {
66
+ if (Object.hasOwn(copy, key)) {
67
+ const value = copy[key];
68
+ copy[key] = Array.isArray(value) ? value.map((item) => decimalAmount(item, key)) : decimalAmount(value, key);
69
+ }
70
+ }
71
+ return copy;
72
+ }
73
+ /** An amount as the API reads it: a string as it is, and a number rounded to 14 significant digits, as the API read JSON numbers, and written without an exponent, which the API refuses. */
74
+ function decimalAmount(value, key) {
75
+ if (typeof value !== 'number') {
76
+ return value;
77
+ }
78
+ if (!Number.isFinite(value)) {
79
+ throw new errors_ts_1.InvalidArgumentError(`The ${key} must be a finite number, or a string such as "49.90", not ${value}.`);
80
+ }
81
+ if (!Number.isInteger(value) && Math.abs(value) >= 1e14) {
82
+ throw new errors_ts_1.InvalidArgumentError(`The ${key} ${value} has too many digits to be sent as a number: pass it as a string.`);
83
+ }
84
+ // Rounding drops the binary noise of a float, so 0.1 + 0.2 goes out as 0.3.
85
+ const rounded = Number.isInteger(value) ? value : Number(value.toPrecision(14));
86
+ const [, sign = '', whole = '', fraction = '', exponent] = /^(-?)(\d+)(?:\.(\d+))?e([+-]\d+)$/.exec(String(rounded)) ?? [];
87
+ if (exponent === undefined) {
88
+ return String(rounded);
89
+ }
90
+ const digits = whole + fraction;
91
+ const point = whole.length + Number(exponent);
92
+ if (point <= 0) {
93
+ return `${sign}0.${'0'.repeat(-point)}${digits}`;
94
+ }
95
+ return point >= digits.length ? `${sign}${digits}${'0'.repeat(point - digits.length)}` : `${sign}${digits.slice(0, point)}.${digits.slice(point)}`;
96
+ }
62
97
  /** Build a path with the given ids escaped into its %s placeholders. */
63
98
  function path(format, ...ids) {
64
99
  let index = 0;
@@ -10,7 +10,13 @@ export declare class WebhookEndpointService extends Service {
10
10
  iterator(params?: Omit<PageParams, 'page'>): AsyncGenerator<WebhookEndpoint, void, undefined>;
11
11
  /** Retrieve one webhook endpoint. */
12
12
  retrieve(id: string): Promise<WebhookEndpoint>;
13
- /** Add an endpoint and send it its verification challenge. The answer carries its signing secret, shown this once, and verificationError while it has not answered. */
13
+ /**
14
+ * Add an endpoint and send it its verification challenge. The answer carries its signing secret, shown this once, and verificationError while it has not answered.
15
+ *
16
+ * The answer is never kept for the idempotency key, so when it is lost, the library's retry or a repeat throws a ConflictError whose
17
+ * wasReplayed() is true: the endpoint was added, but its secret cannot be shown again. Find it with list() and call rotateSecret(),
18
+ * since nothing relies on its first secret yet, or delete() it and add it again.
19
+ */
14
20
  create(params: WebhookEndpointCreateParams, options?: RequestOptions): Promise<WebhookEndpoint>;
15
21
  /** Change an endpoint's url, events, description or active, only those given. A new url is verified again. */
16
22
  update(id: string, params: WebhookEndpointUpdateParams, options?: RequestOptions): Promise<WebhookEndpoint>;
@@ -20,7 +26,14 @@ export declare class WebhookEndpointService extends Service {
20
26
  verify(id: string, options?: RequestOptions): Promise<WebhookEndpoint>;
21
27
  /** Queue a sample charge.paid event, marked as a test, to a verified endpoint. */
22
28
  test(id: string, options?: RequestOptions): Promise<WebhookDelivery>;
23
- /** Replace the endpoint's signing secret. The answer carries the new one, shown this once; the old one keeps signing for a day, until previousSecretExpiresAt. */
29
+ /**
30
+ * Replace the endpoint's signing secret. The answer carries the new one, shown this once; the old one keeps signing for a day, until previousSecretExpiresAt.
31
+ *
32
+ * The answer is never kept for the idempotency key, so when it is lost, the library's retry or a repeat throws a ConflictError whose
33
+ * wasReplayed() is true: the secret was rotated, but the new one cannot be shown again. The secret your receiver holds keeps
34
+ * verifying for a day as the previous one. Rotating again makes the lost secret the previous one and drops the one you hold at once,
35
+ * so only rotate again, with a fresh idempotency key, when you can deploy the new secret straight away; deliveries that fail meanwhile are retried.
36
+ */
24
37
  rotateSecret(id: string, options?: RequestOptions): Promise<WebhookEndpoint>;
25
38
  /** List what the endpoint was sent, newest first, kept for 30 days. */
26
39
  deliveries(id: string, params?: WebhookDeliveryListParams): Promise<Page<WebhookDelivery>>;
@@ -17,7 +17,13 @@ class WebhookEndpointService extends service_ts_1.Service {
17
17
  async retrieve(id) {
18
18
  return new webhook_endpoint_ts_1.WebhookEndpoint(await this.request('GET', (0, service_ts_1.path)('/v1/webhook-endpoints/%s', id)));
19
19
  }
20
- /** Add an endpoint and send it its verification challenge. The answer carries its signing secret, shown this once, and verificationError while it has not answered. */
20
+ /**
21
+ * Add an endpoint and send it its verification challenge. The answer carries its signing secret, shown this once, and verificationError while it has not answered.
22
+ *
23
+ * The answer is never kept for the idempotency key, so when it is lost, the library's retry or a repeat throws a ConflictError whose
24
+ * wasReplayed() is true: the endpoint was added, but its secret cannot be shown again. Find it with list() and call rotateSecret(),
25
+ * since nothing relies on its first secret yet, or delete() it and add it again.
26
+ */
21
27
  async create(params, options) {
22
28
  return endpoint(await this.respond('POST', '/v1/webhook-endpoints', params, options));
23
29
  }
@@ -37,7 +43,14 @@ class WebhookEndpointService extends service_ts_1.Service {
37
43
  async test(id, options) {
38
44
  return new webhook_endpoint_ts_1.WebhookDelivery(await this.request('POST', (0, service_ts_1.path)('/v1/webhook-endpoints/%s/test', id), undefined, options));
39
45
  }
40
- /** Replace the endpoint's signing secret. The answer carries the new one, shown this once; the old one keeps signing for a day, until previousSecretExpiresAt. */
46
+ /**
47
+ * Replace the endpoint's signing secret. The answer carries the new one, shown this once; the old one keeps signing for a day, until previousSecretExpiresAt.
48
+ *
49
+ * The answer is never kept for the idempotency key, so when it is lost, the library's retry or a repeat throws a ConflictError whose
50
+ * wasReplayed() is true: the secret was rotated, but the new one cannot be shown again. The secret your receiver holds keeps
51
+ * verifying for a day as the previous one. Rotating again makes the lost secret the previous one and drops the one you hold at once,
52
+ * so only rotate again, with a fresh idempotency key, when you can deploy the new secret straight away; deliveries that fail meanwhile are retried.
53
+ */
41
54
  async rotateSecret(id, options) {
42
55
  return endpoint(await this.respond('POST', (0, service_ts_1.path)('/v1/webhook-endpoints/%s/secret', id), undefined, options));
43
56
  }
@@ -1,2 +1,2 @@
1
1
  /** The version of this library. */
2
- export declare const VERSION = "0.1.0";
2
+ export declare const VERSION = "0.2.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  /** The version of this library. */
5
- exports.VERSION = '0.1.0';
5
+ exports.VERSION = '0.2.0';
@@ -36,7 +36,7 @@ export interface ClientOptions {
36
36
  export declare class VeliraPayClient {
37
37
  #private;
38
38
  /** The version of this library. */
39
- static readonly VERSION = "0.1.0";
39
+ static readonly VERSION = "0.2.0";
40
40
  /** The address of the VeliraPay API. */
41
41
  static readonly DEFAULT_BASE_URL = "https://api.velirapay.com";
42
42
  /** The account the API key belongs to. */
@@ -1,7 +1,7 @@
1
1
  /** A value the API defines, or one it adds after this version of the library. */
2
2
  export type OrString<T extends string> = T | (string & {});
3
3
  /** A coin on one particular network, such as USDT on Ethereum or USDT_TRON on Tron. The account lists the ones it accepts right now. */
4
- export declare const Asset: {
4
+ export declare const Asset: Readonly<{
5
5
  readonly BTC: 'BTC';
6
6
  readonly BTC_LIGHTNING: 'BTC_LIGHTNING';
7
7
  readonly LTC: 'LTC';
@@ -25,47 +25,47 @@ export declare const Asset: {
25
25
  readonly ETH_BASE: 'ETH_BASE';
26
26
  readonly ETH_ARBITRUM: 'ETH_ARBITRUM';
27
27
  readonly POL: 'POL';
28
- };
28
+ }>;
29
29
  export type Asset = (typeof Asset)[keyof typeof Asset];
30
30
  /** The states a charge moves through. */
31
- export declare const ChargeStatus: {
31
+ export declare const ChargeStatus: Readonly<{
32
32
  readonly Pending: 'pending';
33
33
  readonly Underpaid: 'underpaid';
34
34
  readonly Paid: 'paid';
35
35
  readonly Expired: 'expired';
36
36
  readonly Canceled: 'canceled';
37
- };
37
+ }>;
38
38
  export type ChargeStatus = (typeof ChargeStatus)[keyof typeof ChargeStatus];
39
39
  /** The states an invoice moves through. */
40
- export declare const InvoiceStatus: {
40
+ export declare const InvoiceStatus: Readonly<{
41
41
  readonly Open: 'open';
42
42
  readonly Paid: 'paid';
43
43
  readonly Void: 'void';
44
- };
44
+ }>;
45
45
  export type InvoiceStatus = (typeof InvoiceStatus)[keyof typeof InvoiceStatus];
46
46
  /** Where a payout has got to. */
47
- export declare const PayoutStatus: {
47
+ export declare const PayoutStatus: Readonly<{
48
48
  readonly Pending: 'pending';
49
49
  readonly Sending: 'sending';
50
50
  readonly Sent: 'sent';
51
51
  readonly Failed: 'failed';
52
52
  readonly Manual: 'manual';
53
- };
53
+ }>;
54
54
  export type PayoutStatus = (typeof PayoutStatus)[keyof typeof PayoutStatus];
55
55
  /** Whether a payment link takes payments. */
56
- export declare const PaymentLinkStatus: {
56
+ export declare const PaymentLinkStatus: Readonly<{
57
57
  readonly Active: 'active';
58
58
  readonly Archived: 'archived';
59
- };
59
+ }>;
60
60
  export type PaymentLinkStatus = (typeof PaymentLinkStatus)[keyof typeof PaymentLinkStatus];
61
61
  /** How a payment link is priced: at a set amount, or at one the customer names. */
62
- export declare const PricingType: {
62
+ export declare const PricingType: Readonly<{
63
63
  readonly Fixed: 'fixed';
64
64
  readonly Open: 'open';
65
- };
65
+ }>;
66
66
  export type PricingType = (typeof PricingType)[keyof typeof PricingType];
67
67
  /** The events a charge, an invoice or a payout reports, through webhooks and the events API. */
68
- export declare const EventType: {
68
+ export declare const EventType: Readonly<{
69
69
  readonly ChargeCreated: 'charge.created';
70
70
  readonly ChargePaymentDetected: 'charge.payment_detected';
71
71
  readonly ChargePaid: 'charge.paid';
@@ -81,23 +81,23 @@ export declare const EventType: {
81
81
  readonly InvoiceVoided: 'invoice.voided';
82
82
  readonly PayoutSent: 'payout.sent';
83
83
  readonly PayoutConfirmed: 'payout.confirmed';
84
- };
84
+ }>;
85
85
  export type EventType = (typeof EventType)[keyof typeof EventType];
86
86
  /** The mode an API key, object or webhook belongs to. */
87
- export declare const Mode: {
87
+ export declare const Mode: Readonly<{
88
88
  readonly Live: 'live';
89
89
  readonly Test: 'test';
90
- };
90
+ }>;
91
91
  export type Mode = (typeof Mode)[keyof typeof Mode];
92
92
  /** What kind of legal entity runs an account. */
93
- export declare const BusinessType: {
93
+ export declare const BusinessType: Readonly<{
94
94
  readonly Individual: 'individual';
95
95
  readonly Company: 'company';
96
96
  readonly NonProfit: 'non_profit';
97
- };
97
+ }>;
98
98
  export type BusinessType = (typeof BusinessType)[keyof typeof BusinessType];
99
99
  /** What an account sells, broadly. */
100
- export declare const Industry: {
100
+ export declare const Industry: Readonly<{
101
101
  readonly DigitalProducts: 'digital_products';
102
102
  readonly Software: 'software';
103
103
  readonly Hosting: 'hosting';
@@ -110,19 +110,19 @@ export declare const Industry: {
110
110
  readonly Travel: 'travel';
111
111
  readonly Donations: 'donations';
112
112
  readonly Other: 'other';
113
- };
113
+ }>;
114
114
  export type Industry = (typeof Industry)[keyof typeof Industry];
115
115
  /** How much an account expects to take in a month, in US dollars. */
116
- export declare const MonthlyVolume: {
116
+ export declare const MonthlyVolume: Readonly<{
117
117
  readonly Under1k: 'under_1k';
118
118
  readonly Under10k: '1k_10k';
119
119
  readonly Under50k: '10k_50k';
120
120
  readonly Under250k: '50k_250k';
121
121
  readonly Over250k: 'over_250k';
122
- };
122
+ }>;
123
123
  export type MonthlyVolume = (typeof MonthlyVolume)[keyof typeof MonthlyVolume];
124
124
  /** What a restricted API key may do. Full access gives every permission but the sensitive ones, which have to be ticked. */
125
- export declare const ApiKeyPermission: {
125
+ export declare const ApiKeyPermission: Readonly<{
126
126
  readonly ChargesRead: 'charges:read';
127
127
  readonly ChargesWrite: 'charges:write';
128
128
  readonly ChargesAccept: 'charges:accept';
@@ -148,9 +148,141 @@ export declare const ApiKeyPermission: {
148
148
  readonly MembersRead: 'members:read';
149
149
  readonly MembersWrite: 'members:write';
150
150
  readonly BillingWrite: 'billing:write';
151
- };
151
+ }>;
152
152
  export type ApiKeyPermission = (typeof ApiKeyPermission)[keyof typeof ApiKeyPermission];
153
153
  /** The fiat currencies prices can be set in. */
154
- export type Currency = 'USD' | 'EUR' | 'GBP' | 'CAD' | 'AUD' | 'CHF' | 'TRY';
155
- /** The roles a member can be given; an owner is never made through the API. */
156
- export type MemberRole = 'admin' | 'finance' | 'support' | 'viewer';
154
+ export declare const Currency: Readonly<{
155
+ readonly USD: 'USD';
156
+ readonly EUR: 'EUR';
157
+ readonly GBP: 'GBP';
158
+ readonly CAD: 'CAD';
159
+ readonly AUD: 'AUD';
160
+ readonly CHF: 'CHF';
161
+ readonly TRY: 'TRY';
162
+ }>;
163
+ export type Currency = (typeof Currency)[keyof typeof Currency];
164
+ /** The roles people have in an account. Owner only appears in answers: invitations and role changes take the others. */
165
+ export declare const MemberRole: Readonly<{
166
+ readonly Owner: 'owner';
167
+ readonly Admin: 'admin';
168
+ readonly Finance: 'finance';
169
+ readonly Support: 'support';
170
+ readonly Viewer: 'viewer';
171
+ }>;
172
+ export type MemberRole = (typeof MemberRole)[keyof typeof MemberRole];
173
+ /** The roles an invitation or a role change can give: every one but owner, which is never given through the API. */
174
+ export type AssignableMemberRole = Exclude<MemberRole, typeof MemberRole.Owner>;
175
+ /** The network families that each have one payout address, as payoutAddresses.update() and delete() name them. */
176
+ export declare const AddressNetwork: Readonly<{
177
+ readonly Bitcoin: 'bitcoin';
178
+ readonly Litecoin: 'litecoin';
179
+ readonly Dogecoin: 'dogecoin';
180
+ readonly BitcoinCash: 'bitcoincash';
181
+ readonly Evm: 'evm';
182
+ readonly Bsc: 'bsc';
183
+ readonly Base: 'base';
184
+ readonly Arbitrum: 'arbitrum';
185
+ readonly Polygon: 'polygon';
186
+ readonly Tron: 'tron';
187
+ readonly Monero: 'monero';
188
+ readonly Solana: 'solana';
189
+ readonly Lightning: 'lightning';
190
+ }>;
191
+ export type AddressNetwork = (typeof AddressNetwork)[keyof typeof AddressNetwork];
192
+ /** How the checkout looks: following the customer's device, or always light or dark. */
193
+ export declare const CheckoutAppearance: Readonly<{
194
+ readonly Auto: 'auto';
195
+ readonly Light: 'light';
196
+ readonly Dark: 'dark';
197
+ }>;
198
+ export type CheckoutAppearance = (typeof CheckoutAppearance)[keyof typeof CheckoutAppearance];
199
+ /** Where a webhook delivery has got to. */
200
+ export declare const WebhookDeliveryStatus: Readonly<{
201
+ readonly Pending: 'pending';
202
+ readonly Succeeded: 'succeeded';
203
+ readonly Failed: 'failed';
204
+ }>;
205
+ export type WebhookDeliveryStatus = (typeof WebhookDeliveryStatus)[keyof typeof WebhookDeliveryStatus];
206
+ /** The plans an account can be on: Free keeps a fee of every payment, Pro keeps none. */
207
+ export declare const PlanName: Readonly<{
208
+ readonly Free: 'free';
209
+ readonly Pro: 'pro';
210
+ }>;
211
+ export type PlanName = (typeof PlanName)[keyof typeof PlanName];
212
+ /** Whether an account is one person's or an organization's. */
213
+ export declare const AccountType: Readonly<{
214
+ readonly Personal: 'personal';
215
+ readonly Organization: 'organization';
216
+ }>;
217
+ export type AccountType = (typeof AccountType)[keyof typeof AccountType];
218
+ /** The languages the checkout can fall back on when the customer's browser asks for none of them. */
219
+ export declare const CheckoutLocale: Readonly<{
220
+ readonly English: 'en';
221
+ readonly French: 'fr';
222
+ readonly German: 'de';
223
+ readonly Spanish: 'es';
224
+ readonly Turkish: 'tr';
225
+ readonly Portuguese: 'pt';
226
+ readonly Russian: 'ru';
227
+ readonly Arabic: 'ar';
228
+ }>;
229
+ export type CheckoutLocale = (typeof CheckoutLocale)[keyof typeof CheckoutLocale];
230
+ /** What the activity log records. The API adds actions from time to time, so expect others too. */
231
+ export declare const ActivityAction: Readonly<{
232
+ readonly WalletsChanged: 'wallets.changed';
233
+ readonly PayoutAddressAccessChanged: 'wallets.api_access_changed';
234
+ readonly SecondFactorRequirementChanged: 'team.second_factor_requirement_changed';
235
+ readonly PaymentSettingsUpdated: 'payment_settings.updated';
236
+ readonly ProfileUpdated: 'profile.updated';
237
+ readonly BusinessDetailsUpdated: 'business_details.updated';
238
+ readonly ApiKeyCreated: 'api_key.created';
239
+ readonly ApiKeyUpdated: 'api_key.updated';
240
+ readonly ApiKeyRevoked: 'api_key.revoked';
241
+ readonly WebhookCreated: 'webhook.created';
242
+ readonly WebhookUpdated: 'webhook.updated';
243
+ readonly WebhookDeleted: 'webhook.deleted';
244
+ readonly WebhookSecretRotated: 'webhook.secret_rotated';
245
+ readonly MemberInvited: 'member.invited';
246
+ readonly MemberJoined: 'member.joined';
247
+ readonly MemberRoleChanged: 'member.role_changed';
248
+ readonly MemberRemoved: 'member.removed';
249
+ readonly PaymentLinkCreated: 'payment_link.created';
250
+ readonly PaymentLinkUpdated: 'payment_link.updated';
251
+ readonly PaymentLinkArchived: 'payment_link.archived';
252
+ readonly PaymentLinkRestored: 'payment_link.restored';
253
+ readonly InvitationCanceled: 'member.invitation_canceled';
254
+ readonly ChargePaymentRequested: 'charge.payment_requested';
255
+ readonly WebhookDisabled: 'webhook.disabled';
256
+ readonly ChargeCanceled: 'charge.canceled';
257
+ readonly ChargeAccepted: 'charge.accepted';
258
+ readonly RefundRecorded: 'refund.recorded';
259
+ readonly InvoiceVoided: 'invoice.voided';
260
+ readonly PlanPaymentStarted: 'plan.payment_started';
261
+ readonly SubscriptionCanceled: 'plan.subscription_canceled';
262
+ readonly SubscriptionResumed: 'plan.subscription_resumed';
263
+ readonly SignedIn: 'auth.signed_in';
264
+ readonly SignInFailed: 'auth.sign_in_failed';
265
+ readonly PasswordChanged: 'auth.password_changed';
266
+ readonly TwoFactorEnabled: 'auth.two_factor_enabled';
267
+ readonly TwoFactorDisabled: 'auth.two_factor_disabled';
268
+ readonly SignedOutElsewhere: 'auth.signed_out_elsewhere';
269
+ readonly TwoFactorFailed: 'auth.two_factor_failed';
270
+ readonly EmailChanged: 'auth.email_changed';
271
+ readonly PasskeyAdded: 'auth.passkey_added';
272
+ readonly PasskeyRemoved: 'auth.passkey_removed';
273
+ readonly CouponCreated: 'coupon.created';
274
+ readonly CouponUpdated: 'coupon.updated';
275
+ readonly CouponDeleted: 'coupon.deleted';
276
+ readonly AppConnected: 'auth.app_connected';
277
+ readonly AppDisconnected: 'auth.app_disconnected';
278
+ readonly ChatConnected: 'chat.connected';
279
+ readonly ChatUpdated: 'chat.updated';
280
+ readonly ChatRemoved: 'chat.removed';
281
+ readonly ChatDisabled: 'chat.disabled';
282
+ readonly SanctionsMatched: 'sanctions.matched';
283
+ readonly SanctionsAccepted: 'sanctions.accepted';
284
+ readonly SanctionsReturnRequested: 'sanctions.return_requested';
285
+ readonly SocialAccountConnected: 'auth.social_connected';
286
+ readonly SocialAccountDisconnected: 'auth.social_disconnected';
287
+ }>;
288
+ export type ActivityAction = (typeof ActivityAction)[keyof typeof ActivityAction];