@settlemint/dalp-cli 3.1.4-main.32581911907 → 3.1.4-main.32583419224

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/dalp.js CHANGED
@@ -45817,6 +45817,127 @@ function serializeDalpQuery(query) {
45817
45817
  return search.toString();
45818
45818
  }
45819
45819
 
45820
+ // ../sdk/src/client/request-compression.ts
45821
+ var DALP_SDK_REQUEST_COMPRESSION_MIN_BODY_BYTES = 1024;
45822
+ var DALP_SDK_REQUEST_COMPRESSION_MAX_BODY_BYTES = 16777216;
45823
+ var NO_BODY_METHODS = new Set(["GET", "HEAD"]);
45824
+ function bufferedBodySize(body) {
45825
+ if (typeof body === "string") {
45826
+ return Buffer.byteLength(body);
45827
+ }
45828
+ if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
45829
+ return body.byteLength;
45830
+ }
45831
+ if (body instanceof Blob) {
45832
+ return body.size;
45833
+ }
45834
+ return;
45835
+ }
45836
+ function isCompressibleMediaType(contentType) {
45837
+ const mediaType = contentType?.split(";")[0]?.trim().toLowerCase();
45838
+ if (mediaType === undefined || mediaType === "") {
45839
+ return false;
45840
+ }
45841
+ return mediaType === "application/json" || mediaType.endsWith("+json") || mediaType.startsWith("text/");
45842
+ }
45843
+ async function cancelReaderBestEffort(reader) {
45844
+ try {
45845
+ await reader.cancel();
45846
+ } catch {}
45847
+ }
45848
+ async function readRequestBodyWithinCap(request2, maxBodyBytes) {
45849
+ let body;
45850
+ try {
45851
+ const { body: clonedBody } = request2.clone();
45852
+ body = clonedBody;
45853
+ } catch {
45854
+ return;
45855
+ }
45856
+ if (body === null) {
45857
+ return Buffer.alloc(0);
45858
+ }
45859
+ const reader = body.getReader();
45860
+ const chunks = [];
45861
+ let totalBytes = 0;
45862
+ try {
45863
+ while (true) {
45864
+ const next = await reader.read();
45865
+ if (next.done) {
45866
+ return Buffer.concat(chunks, totalBytes);
45867
+ }
45868
+ totalBytes += next.value.byteLength;
45869
+ if (totalBytes > maxBodyBytes) {
45870
+ cancelReaderBestEffort(reader);
45871
+ return;
45872
+ }
45873
+ chunks.push(next.value);
45874
+ }
45875
+ } catch {
45876
+ return;
45877
+ } finally {
45878
+ reader.releaseLock();
45879
+ }
45880
+ }
45881
+ function withRequestBodyCompression(fetchImpl2, options) {
45882
+ const minBodyBytes = options?.minBodyBytes ?? DALP_SDK_REQUEST_COMPRESSION_MIN_BODY_BYTES;
45883
+ const maxBodyBytes = options?.maxBodyBytes ?? DALP_SDK_REQUEST_COMPRESSION_MAX_BODY_BYTES;
45884
+ const requestCompressionFetch = async (input, init) => {
45885
+ if (init?.compress !== undefined) {
45886
+ return fetchImpl2(input, init);
45887
+ }
45888
+ let request2;
45889
+ if (input instanceof Request) {
45890
+ request2 = init === undefined ? input : new Request(input, init);
45891
+ }
45892
+ const method = (request2?.method ?? init?.method ?? "GET").toUpperCase();
45893
+ if (NO_BODY_METHODS.has(method)) {
45894
+ return fetchImpl2(input, init);
45895
+ }
45896
+ const headers = new Headers(request2?.headers ?? init?.headers);
45897
+ if (headers.get("content-encoding") !== null) {
45898
+ return fetchImpl2(input, init);
45899
+ }
45900
+ let compress;
45901
+ let bufferedRequestBody;
45902
+ if (request2 !== undefined && request2.body !== null && isCompressibleMediaType(headers.get("content-type"))) {
45903
+ bufferedRequestBody = await readRequestBodyWithinCap(request2, maxBodyBytes);
45904
+ if (bufferedRequestBody !== undefined && bufferedRequestBody.byteLength >= minBodyBytes) {
45905
+ compress = "gzip";
45906
+ }
45907
+ } else if (init?.body !== null && init?.body !== undefined) {
45908
+ const size = bufferedBodySize(init.body);
45909
+ if (size !== undefined && size >= minBodyBytes && size <= maxBodyBytes) {
45910
+ compress = "gzip";
45911
+ }
45912
+ }
45913
+ if (compress === undefined) {
45914
+ return fetchImpl2(input, init);
45915
+ }
45916
+ if (request2 !== undefined && bufferedRequestBody !== undefined) {
45917
+ return fetchImpl2(request2.url, {
45918
+ ...init,
45919
+ body: bufferedRequestBody,
45920
+ cache: init?.cache ?? request2.cache,
45921
+ compress,
45922
+ credentials: init?.credentials ?? request2.credentials,
45923
+ headers: request2.headers,
45924
+ integrity: init?.integrity ?? request2.integrity,
45925
+ keepalive: init?.keepalive ?? request2.keepalive,
45926
+ method: request2.method,
45927
+ mode: init?.mode ?? request2.mode,
45928
+ redirect: init?.redirect ?? request2.redirect,
45929
+ referrer: init?.referrer ?? request2.referrer,
45930
+ referrerPolicy: init?.referrerPolicy ?? request2.referrerPolicy,
45931
+ signal: init?.signal ?? request2.signal
45932
+ });
45933
+ }
45934
+ return fetchImpl2(input, { ...init, compress });
45935
+ };
45936
+ return Object.assign(requestCompressionFetch, {
45937
+ preconnect: fetchImpl2.preconnect
45938
+ });
45939
+ }
45940
+
45820
45941
  // ../sdk/src/client/ssr-fetch.ts
45821
45942
  class DalpSsrSecurityError extends Error {
45822
45943
  name = "DalpSsrSecurityError";
@@ -45953,8 +46074,9 @@ function createDalpContextHeaders(context) {
45953
46074
  }
45954
46075
  function createDalpClient(options) {
45955
46076
  const baseUrl = normalizeDalpBaseUrl(String(options.baseUrl));
45956
- const fetchImpl2 = options.fetch ?? globalThis.fetch;
45957
46077
  const runtime = options.runtime ?? (globalThis.window === undefined ? "server" : "browser");
46078
+ const baseFetch = options.fetch ?? globalThis.fetch;
46079
+ const transportFetch = runtime === "browser" ? baseFetch : withRequestBodyCompression(baseFetch);
45958
46080
  const { apiKey: apiKeyOption } = options;
45959
46081
  let apiKey;
45960
46082
  if (apiKeyOption === undefined) {
@@ -45971,10 +46093,10 @@ function createDalpClient(options) {
45971
46093
  fix: "Keep the API key on the server or CLI process; browser clients authenticate with the session cookie."
45972
46094
  });
45973
46095
  }
45974
- const resolvedFetch = options.ssr === undefined ? fetchImpl2 : createSsrFetch({
46096
+ const resolvedFetch = options.ssr === undefined ? transportFetch : createSsrFetch({
45975
46097
  allowedOrigins: options.ssr.allowedOrigins,
45976
46098
  baseUrl,
45977
- fetch: fetchImpl2,
46099
+ fetch: transportFetch,
45978
46100
  requestHeaders: options.ssr.requestHeaders
45979
46101
  });
45980
46102
  const client = createClient({
@@ -46079,7 +46201,7 @@ var API_ERROR_CATEGORIES = new Set([
46079
46201
  // ../sdk/package.json
46080
46202
  var package_default = {
46081
46203
  name: "@settlemint/dalp-sdk",
46082
- version: "3.1.4-main.32581911907",
46204
+ version: "3.1.4-main.32583419224",
46083
46205
  private: false,
46084
46206
  description: "Fully typed SDK for the DALP tokenization platform API",
46085
46207
  homepage: "https://settlemint.com",
@@ -160438,7 +160560,7 @@ async function runCommand(context, operation, errorContext = UNKNOWN_COMMAND_ERR
160438
160560
  // package.json
160439
160561
  var package_default2 = {
160440
160562
  name: "@settlemint/dalp-cli",
160441
- version: "3.1.4-main.32581911907",
160563
+ version: "3.1.4-main.32583419224",
160442
160564
  private: false,
160443
160565
  description: "CLI for the Digital Asset Lifecycle Platform \u2014 manage tokens, identities, compliance, and more from the command line.",
160444
160566
  homepage: "https://settlemint.com",
@@ -161112,7 +161234,9 @@ var withCliUserAgent = (fetchImpl2) => Object.assign(async (input, init) => {
161112
161234
  const request2 = new Request(input, init);
161113
161235
  const headers = new Headers(request2.headers);
161114
161236
  headers.set("User-Agent", CLI_USER_AGENT);
161115
- return fetchImpl2(new Request(request2, { headers }));
161237
+ const compress = init?.compress;
161238
+ const transportInit = compress === undefined ? undefined : { compress };
161239
+ return fetchImpl2(new Request(request2, { headers }), transportInit);
161116
161240
  }, fetchImpl2);
161117
161241
  function resolveActiveOrganizationId(credentials, defaultOrg, override) {
161118
161242
  if (override !== undefined && override.trim() !== "") {
@@ -162167,4 +162291,4 @@ if (false) {}
162167
162291
  // src/bin.ts
162168
162292
  await cli.serve();
162169
162293
 
162170
- //# debugId=9255E7516738F3D064756E2164756E21
162294
+ //# debugId=5D970B8202EA420264756E2164756E21