@delopay/sdk 0.180.0 → 0.182.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OTLLSSM7.js → chunk-3GSFUNXW.js} +36 -4
- package/dist/{chunk-OTLLSSM7.js.map → chunk-3GSFUNXW.js.map} +1 -1
- package/dist/index.cjs +35 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -36
- package/dist/index.d.ts +134 -36
- package/dist/index.js +1 -1
- package/dist/internal.cjs +35 -3
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +67 -2
- package/dist/internal.d.ts +67 -2
- package/dist/internal.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9460,6 +9460,18 @@ function withoutHeader(headers, name) {
|
|
|
9460
9460
|
}
|
|
9461
9461
|
return out;
|
|
9462
9462
|
}
|
|
9463
|
+
async function gzipJson(value) {
|
|
9464
|
+
const ctor = globalThis.CompressionStream;
|
|
9465
|
+
if (typeof ctor !== "function") return null;
|
|
9466
|
+
try {
|
|
9467
|
+
const bytes = new TextEncoder().encode(JSON.stringify(value));
|
|
9468
|
+
return await new Response(
|
|
9469
|
+
new Blob([bytes]).stream().pipeThrough(new ctor("gzip"))
|
|
9470
|
+
).arrayBuffer();
|
|
9471
|
+
} catch {
|
|
9472
|
+
return null;
|
|
9473
|
+
}
|
|
9474
|
+
}
|
|
9463
9475
|
var CheckoutSession = class {
|
|
9464
9476
|
constructor(options) {
|
|
9465
9477
|
this.merchantId = options.merchantId;
|
|
@@ -9611,18 +9623,38 @@ var CheckoutSession = class {
|
|
|
9611
9623
|
* away (a redirect rail); browsers refuse keepalive bodies over ~64 KiB, so
|
|
9612
9624
|
* only a small final slice should carry it.
|
|
9613
9625
|
*
|
|
9626
|
+
* Pass `compress: true` to send the slice gzipped. Recorded page events
|
|
9627
|
+
* compress heavily, so this is mostly a saving on the buyer's connection. It
|
|
9628
|
+
* is opt-in and degrades silently: a runtime without `CompressionStream`
|
|
9629
|
+
* sends the same slice uncompressed rather than failing, so a caller never
|
|
9630
|
+
* has to feature-test before asking for it.
|
|
9631
|
+
*
|
|
9632
|
+
* ⚠️ `keepalive` overrides it. Compressing means awaiting a stream read
|
|
9633
|
+
* before the request is made, and `keepalive` protects a request only once
|
|
9634
|
+
* it has been initiated — so a page torn down mid-compression would drop the
|
|
9635
|
+
* final slice altogether. A slice sent with `keepalive` therefore always
|
|
9636
|
+
* travels uncompressed, whatever `compress` says. Passing both is allowed and
|
|
9637
|
+
* is what a recorder should do: every ordinary slice compresses, and the last
|
|
9638
|
+
* one is sent the way that actually arrives.
|
|
9639
|
+
*
|
|
9614
9640
|
* `POST /payments/{paymentId}/replay/slice` (publishable key)
|
|
9615
9641
|
*/
|
|
9616
9642
|
async storeReplaySlice(params, options) {
|
|
9617
|
-
const { keepalive, ...extras } = options ?? {};
|
|
9643
|
+
const { keepalive, compress, ...extras } = options ?? {};
|
|
9644
|
+
const body = { ...params, client_secret: this.requireClientSecret() };
|
|
9645
|
+
const headers = this.pkHeaders(extras.headers);
|
|
9646
|
+
const gzipped = compress === true && keepalive !== true ? await gzipJson(body) : null;
|
|
9618
9647
|
return this.client.request(
|
|
9619
9648
|
"POST",
|
|
9620
9649
|
`/payments/${encodeURIComponent(this.paymentId)}/replay/slice`,
|
|
9621
9650
|
{
|
|
9622
|
-
body:
|
|
9651
|
+
body: gzipped ?? body,
|
|
9623
9652
|
...keepalive !== void 0 ? { keepalive } : {},
|
|
9624
9653
|
...extras,
|
|
9625
|
-
|
|
9654
|
+
// `Content-Type` has to be stated for the compressed body: the client
|
|
9655
|
+
// only sets it for a body it serialises itself, and the bytes are
|
|
9656
|
+
// still JSON — gzip is how they travel, not what they are.
|
|
9657
|
+
headers: gzipped === null ? headers : { ...headers, "Content-Type": "application/json", "Content-Encoding": "gzip" }
|
|
9626
9658
|
}
|
|
9627
9659
|
);
|
|
9628
9660
|
}
|