@devizovaburza/payments-api-sdk 1.1.0 → 1.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ The SDK exports a type-safe client generated from the Payments API schema:
19
19
  ```typescript
20
20
  import { createPartnerApiClient } from '@devizovaburza/payments-api-sdk/v1';
21
21
 
22
- const client = createPartnerApiClient('https://api.payments.devizovka.cz');
22
+ const client = createPartnerApiClient('https://api.payments.devizovaburza.cz');
23
23
 
24
24
  // Authenticate
25
25
  const { accessToken } = await client.v1.auth.token.$post({
@@ -42,7 +42,7 @@ You can infer request and response types from any endpoint using Hono's built-in
42
42
  import type { InferRequestType, InferResponseType } from 'hono/client';
43
43
  import { createPartnerApiClient } from '@devizovaburza/payments-api-sdk/v1';
44
44
 
45
- const client = createPartnerApiClient('https://api.payments.devizovka.cz');
45
+ const client = createPartnerApiClient('https://api.payments.devizovaburza.cz');
46
46
 
47
47
  // Infer types from a specific endpoint
48
48
  type SendPaymentRequest = InferRequestType<typeof client.v1.organizations[':id'].payments.$post>;
package/dist/v1/index.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const webhook = require('@apps/gateway/src/types/webhook');
4
+
3
5
  // src/utils/cookie.ts
4
6
  var _serialize = (name, value, opt = {}) => {
5
7
  let cookie = `${name}=${value}`;
@@ -17,6 +19,11 @@ var _serialize = (name, value, opt = {}) => {
17
19
  throw new Error("__Host- Cookie must not have Domain attributes");
18
20
  }
19
21
  }
22
+ for (const key of ["domain", "path"]) {
23
+ if (opt[key] && /[;\r\n]/.test(opt[key])) {
24
+ throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
25
+ }
26
+ }
20
27
  if (opt && typeof opt.maxAge === "number" && opt.maxAge >= 0) {
21
28
  if (opt.maxAge > 3456e4) {
22
29
  throw new Error(
@@ -167,6 +174,9 @@ var ClientRequestImpl = class {
167
174
  if (args.form) {
168
175
  const form = new FormData();
169
176
  for (const [k, v] of Object.entries(args.form)) {
177
+ if (v === void 0) {
178
+ continue;
179
+ }
170
180
  if (Array.isArray(v)) {
171
181
  for (const v2 of v) {
172
182
  form.append(k, v2);
@@ -242,7 +252,7 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
242
252
  }
243
253
  const path = parts.join("/");
244
254
  const url = mergePath(baseUrl, path);
245
- if (method === "url") {
255
+ if (method === "url" || method === "path") {
246
256
  let result = url;
247
257
  if (opts.args[0]) {
248
258
  if (opts.args[0].param) {
@@ -253,7 +263,10 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
253
263
  }
254
264
  }
255
265
  result = removeIndexString(result);
256
- return new URL(result);
266
+ if (method === "url") {
267
+ return new URL(result);
268
+ }
269
+ return result.slice(baseUrl.replace(/\/+$/, "").length).replace(/^\/?/, "/");
257
270
  }
258
271
  if (method === "ws") {
259
272
  const webSocketUrl = replaceUrlProtocol(
@@ -371,6 +384,7 @@ const verifyPayloadSignature = async ({
371
384
  return isValid;
372
385
  };
373
386
 
387
+ exports.WebhookEventType = webhook.WebhookEventType;
374
388
  exports.createPartnerApiClient = createPartnerApiClient;
375
389
  exports.signPayload = signPayload;
376
390
  exports.verifyPayloadSignature = verifyPayloadSignature;