@commercetools/ts-client 2.1.0 → 2.1.1

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @commercetools/ts-client
2
2
 
3
+ ## 2.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#835](https://github.com/commercetools/commercetools-sdk-typescript/pull/835) [`b2c62ba`](https://github.com/commercetools/commercetools-sdk-typescript/commit/b2c62ba105b7fb9fe2eb6a4ae1b95c8d5b67d428) Thanks [@ajimae](https://github.com/ajimae)! - Fix issues with counting special characters' length
8
+
3
9
  ## 2.1.0
4
10
 
5
11
  ### Minor Changes
@@ -35,6 +35,17 @@ function _defineProperty(e, r, t) {
35
35
  }) : e[r] = t, e;
36
36
  }
37
37
 
38
+ var Buffer = require('buffer/').Buffer;
39
+ function byteLength(body) {
40
+ if (body && (typeof body === 'string' || body instanceof Uint8Array)) {
41
+ return Buffer.byteLength(body).toString();
42
+ }
43
+ if (body && typeof body === 'object') {
44
+ return new TextEncoder().encode(JSON.stringify(body)).length.toString();
45
+ }
46
+ return '0';
47
+ }
48
+
38
49
  const HEADERS_CONTENT_TYPES = ['application/json', 'application/graphql'];
39
50
  const CONCURRENCT_REQUEST = 20;
40
51
  const CTP_API_URL = 'https://api.europe-west1.gcp.commercetools.com';
@@ -450,13 +461,6 @@ function createUserAgent(options) {
450
461
  return [baseInfo, systemInfo, libraryInfo, contactInfo, customAgent].filter(Boolean).join(' ');
451
462
  }
452
463
 
453
- function byteLength(body) {
454
- if (typeof body === 'string') return body.length.toString();
455
- if (body && typeof body === 'object') return new TextEncoder().encode(JSON.stringify(body)).length.toString();
456
- if (body instanceof Uint8Array) return body.length.toString();
457
- return '0';
458
- }
459
-
460
464
  /**
461
465
  * validate some essential http options
462
466
  * @param options
@@ -1247,7 +1251,7 @@ function createQueueMiddleware$1({
1247
1251
 
1248
1252
  var packageJson = {
1249
1253
  name: "@commercetools/ts-client",
1250
- version: "2.1.0",
1254
+ version: "2.1.1",
1251
1255
  engines: {
1252
1256
  node: ">=14"
1253
1257
  },
@@ -1281,6 +1285,7 @@ var packageJson = {
1281
1285
  },
1282
1286
  dependencies: {
1283
1287
  "abort-controller": "3.0.0",
1288
+ buffer: "^6.0.3",
1284
1289
  "node-fetch": "^2.6.1"
1285
1290
  },
1286
1291
  files: [
@@ -26,6 +26,17 @@ function _defineProperty(e, r, t) {
26
26
  }) : e[r] = t, e;
27
27
  }
28
28
 
29
+ var Buffer = require('buffer/').Buffer;
30
+ function byteLength(body) {
31
+ if (body && (typeof body === 'string' || body instanceof Uint8Array)) {
32
+ return Buffer.byteLength(body).toString();
33
+ }
34
+ if (body && typeof body === 'object') {
35
+ return new TextEncoder().encode(JSON.stringify(body)).length.toString();
36
+ }
37
+ return '0';
38
+ }
39
+
29
40
  const HEADERS_CONTENT_TYPES = ['application/json', 'application/graphql'];
30
41
  const CONCURRENCT_REQUEST = 20;
31
42
  const CTP_API_URL = 'https://api.europe-west1.gcp.commercetools.com';
@@ -441,13 +452,6 @@ function createUserAgent(options) {
441
452
  return [baseInfo, systemInfo, libraryInfo, contactInfo, customAgent].filter(Boolean).join(' ');
442
453
  }
443
454
 
444
- function byteLength(body) {
445
- if (typeof body === 'string') return body.length.toString();
446
- if (body && typeof body === 'object') return new TextEncoder().encode(JSON.stringify(body)).length.toString();
447
- if (body instanceof Uint8Array) return body.length.toString();
448
- return '0';
449
- }
450
-
451
455
  /**
452
456
  * validate some essential http options
453
457
  * @param options
@@ -1238,7 +1242,7 @@ function createQueueMiddleware$1({
1238
1242
 
1239
1243
  var packageJson = {
1240
1244
  name: "@commercetools/ts-client",
1241
- version: "2.1.0",
1245
+ version: "2.1.1",
1242
1246
  engines: {
1243
1247
  node: ">=14"
1244
1248
  },
@@ -1272,6 +1276,7 @@ var packageJson = {
1272
1276
  },
1273
1277
  dependencies: {
1274
1278
  "abort-controller": "3.0.0",
1279
+ buffer: "^6.0.3",
1275
1280
  "node-fetch": "^2.6.1"
1276
1281
  },
1277
1282
  files: [
@@ -35,6 +35,17 @@ function _defineProperty(e, r, t) {
35
35
  }) : e[r] = t, e;
36
36
  }
37
37
 
38
+ var Buffer = require('buffer/').Buffer;
39
+ function byteLength(body) {
40
+ if (body && (typeof body === 'string' || body instanceof Uint8Array)) {
41
+ return Buffer.byteLength(body).toString();
42
+ }
43
+ if (body && typeof body === 'object') {
44
+ return new TextEncoder().encode(JSON.stringify(body)).length.toString();
45
+ }
46
+ return '0';
47
+ }
48
+
38
49
  const HEADERS_CONTENT_TYPES = ['application/json', 'application/graphql'];
39
50
  const CONCURRENCT_REQUEST = 20;
40
51
  const CTP_API_URL = 'https://api.europe-west1.gcp.commercetools.com';
@@ -450,13 +461,6 @@ function createUserAgent(options) {
450
461
  return [baseInfo, systemInfo, libraryInfo, contactInfo, customAgent].filter(Boolean).join(' ');
451
462
  }
452
463
 
453
- function byteLength(body) {
454
- if (typeof body === 'string') return body.length.toString();
455
- if (body && typeof body === 'object') return new TextEncoder().encode(JSON.stringify(body)).length.toString();
456
- if (body instanceof Uint8Array) return body.length.toString();
457
- return '0';
458
- }
459
-
460
464
  /**
461
465
  * validate some essential http options
462
466
  * @param options
@@ -1247,7 +1251,7 @@ function createQueueMiddleware$1({
1247
1251
 
1248
1252
  var packageJson = {
1249
1253
  name: "@commercetools/ts-client",
1250
- version: "2.1.0",
1254
+ version: "2.1.1",
1251
1255
  engines: {
1252
1256
  node: ">=14"
1253
1257
  },
@@ -1281,6 +1285,7 @@ var packageJson = {
1281
1285
  },
1282
1286
  dependencies: {
1283
1287
  "abort-controller": "3.0.0",
1288
+ buffer: "^6.0.3",
1284
1289
  "node-fetch": "^2.6.1"
1285
1290
  },
1286
1291
  files: [
@@ -35,6 +35,17 @@ function _defineProperty(e, r, t) {
35
35
  }) : e[r] = t, e;
36
36
  }
37
37
 
38
+ var Buffer = require('buffer/').Buffer;
39
+ function byteLength(body) {
40
+ if (body && (typeof body === 'string' || body instanceof Uint8Array)) {
41
+ return Buffer.byteLength(body).toString();
42
+ }
43
+ if (body && typeof body === 'object') {
44
+ return new TextEncoder().encode(JSON.stringify(body)).length.toString();
45
+ }
46
+ return '0';
47
+ }
48
+
38
49
  const HEADERS_CONTENT_TYPES = ['application/json', 'application/graphql'];
39
50
  const CONCURRENCT_REQUEST = 20;
40
51
  const CTP_API_URL = 'https://api.europe-west1.gcp.commercetools.com';
@@ -450,13 +461,6 @@ function createUserAgent(options) {
450
461
  return [baseInfo, systemInfo, libraryInfo, contactInfo, customAgent].filter(Boolean).join(' ');
451
462
  }
452
463
 
453
- function byteLength(body) {
454
- if (typeof body === 'string') return body.length.toString();
455
- if (body && typeof body === 'object') return new TextEncoder().encode(JSON.stringify(body)).length.toString();
456
- if (body instanceof Uint8Array) return body.length.toString();
457
- return '0';
458
- }
459
-
460
464
  /**
461
465
  * validate some essential http options
462
466
  * @param options
@@ -1247,7 +1251,7 @@ function createQueueMiddleware$1({
1247
1251
 
1248
1252
  var packageJson = {
1249
1253
  name: "@commercetools/ts-client",
1250
- version: "2.1.0",
1254
+ version: "2.1.1",
1251
1255
  engines: {
1252
1256
  node: ">=14"
1253
1257
  },
@@ -1281,6 +1285,7 @@ var packageJson = {
1281
1285
  },
1282
1286
  dependencies: {
1283
1287
  "abort-controller": "3.0.0",
1288
+ buffer: "^6.0.3",
1284
1289
  "node-fetch": "^2.6.1"
1285
1290
  },
1286
1291
  files: [
@@ -26,6 +26,17 @@ function _defineProperty(e, r, t) {
26
26
  }) : e[r] = t, e;
27
27
  }
28
28
 
29
+ var Buffer = require('buffer/').Buffer;
30
+ function byteLength(body) {
31
+ if (body && (typeof body === 'string' || body instanceof Uint8Array)) {
32
+ return Buffer.byteLength(body).toString();
33
+ }
34
+ if (body && typeof body === 'object') {
35
+ return new TextEncoder().encode(JSON.stringify(body)).length.toString();
36
+ }
37
+ return '0';
38
+ }
39
+
29
40
  const HEADERS_CONTENT_TYPES = ['application/json', 'application/graphql'];
30
41
  const CONCURRENCT_REQUEST = 20;
31
42
  const CTP_API_URL = 'https://api.europe-west1.gcp.commercetools.com';
@@ -441,13 +452,6 @@ function createUserAgent(options) {
441
452
  return [baseInfo, systemInfo, libraryInfo, contactInfo, customAgent].filter(Boolean).join(' ');
442
453
  }
443
454
 
444
- function byteLength(body) {
445
- if (typeof body === 'string') return body.length.toString();
446
- if (body && typeof body === 'object') return new TextEncoder().encode(JSON.stringify(body)).length.toString();
447
- if (body instanceof Uint8Array) return body.length.toString();
448
- return '0';
449
- }
450
-
451
455
  /**
452
456
  * validate some essential http options
453
457
  * @param options
@@ -1238,7 +1242,7 @@ function createQueueMiddleware$1({
1238
1242
 
1239
1243
  var packageJson = {
1240
1244
  name: "@commercetools/ts-client",
1241
- version: "2.1.0",
1245
+ version: "2.1.1",
1242
1246
  engines: {
1243
1247
  node: ">=14"
1244
1248
  },
@@ -1272,6 +1276,7 @@ var packageJson = {
1272
1276
  },
1273
1277
  dependencies: {
1274
1278
  "abort-controller": "3.0.0",
1279
+ buffer: "^6.0.3",
1275
1280
  "node-fetch": "^2.6.1"
1276
1281
  },
1277
1282
  files: [
@@ -1 +1,14 @@
1
- var window;(window||={})["@commercetools/ts-client"]=(()=>{var $e=Object.create;var ie=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Qe=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),me=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Oe=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qe(t))!Ge.call(e,i)&&i!==r&&ie(e,i,{get:()=>t[i],enumerable:!(o=ze(t,i))||o.enumerable});return e};var G=(e,t,r)=>(r=e!=null?$e(Je(e)):{},Oe(t||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e)),Ve=e=>Oe(ie({},"__esModule",{value:!0}),e);var V=Ee((H,Pe)=>{"use strict";var Ye=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},F=Ye();Pe.exports=H=F.fetch;F.fetch&&(H.default=F.fetch.bind(F));H.Headers=F.Headers;H.Request=F.Request;H.Response=F.Response});var _e=Ee((Xr,pe)=>{"use strict";var{AbortController:ve,AbortSignal:yt}=typeof self<"u"?self:typeof window<"u"?window:void 0;pe.exports=ve;pe.exports.AbortSignal=yt;pe.exports.default=ve});var Ft={};me(Ft,{ClientBuilder:()=>z,Process:()=>we,createAuthMiddlewareForAnonymousSessionFlow:()=>K,createAuthMiddlewareForClientCredentialsFlow:()=>B,createAuthMiddlewareForExistingTokenFlow:()=>L,createAuthMiddlewareForPasswordFlow:()=>D,createAuthMiddlewareForRefreshTokenFlow:()=>$,createClient:()=>j,createConcurrentModificationMiddleware:()=>W,createCorrelationIdMiddleware:()=>X,createHttpMiddleware:()=>Z,createLoggerMiddleware:()=>ee,createQueueMiddleware:()=>te,createUserAgentMiddleware:()=>re});var q=G(V());var ke={};me(ke,{createAuthMiddlewareForAnonymousSessionFlow:()=>K,createAuthMiddlewareForClientCredentialsFlow:()=>B,createAuthMiddlewareForExistingTokenFlow:()=>L,createAuthMiddlewareForPasswordFlow:()=>D,createAuthMiddlewareForRefreshTokenFlow:()=>$,createConcurrentModificationMiddleware:()=>W,createCorrelationIdMiddleware:()=>X,createErrorMiddleware:()=>xe,createHttpMiddleware:()=>Z,createLoggerMiddleware:()=>ee,createQueueMiddleware:()=>te,createUserAgentMiddleware:()=>re});var Ue=G(V());var y={};me(y,{CONCURRENCT_REQUEST:()=>Xe,CTP_API_URL:()=>Ze,CTP_AUTH_URL:()=>et,DEFAULT_HEADERS:()=>ye,HEADERS_CONTENT_TYPES:()=>We});var We=["application/json","application/graphql"],Xe=20,Ze="https://api.europe-west1.gcp.commercetools.com",et="https://auth.europe-west1.gcp.commercetools.com",ye=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function k(e,t,r={}){this.status=this.statusCode=this.code=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function Se(...e){k.call(this,0,...e)}function Fe(...e){k.call(this,...e)}function tt(...e){k.call(this,400,...e)}function rt(...e){k.call(this,401,...e)}function ot(...e){k.call(this,403,...e)}function it(...e){k.call(this,404,...e)}function nt(...e){k.call(this,409,...e)}function at(...e){k.call(this,500,...e)}function st(...e){k.call(this,503,...e)}function Me(e){switch(e){case 0:return Se;case 400:return tt;case 401:return rt;case 403:return ot;case 404:return it;case 409:return nt;case 500:return at;case 503:return st;default:return}}function lt({statusCode:e,message:t,...r}){let o=t||"Unexpected non-JSON error response";e===404&&(o=`URI not found: ${r.originalRequest?.uri||r.uri}`);let i=Me(e);return i?new i(o,r):new Fe(e,o,r)}var N=lt;function dt(e,t){return[503,...e].includes(t?.status||t?.statusCode)}async function ut(e,t){async function r(){return await e({...t,headers:{...t.headers}})}return r().catch(o=>Promise.reject(o))}async function v(e){let{url:t,httpClient:r,...o}=e;return await ut(async n=>{let{enableRetry:a,retryConfig:l,abortController:d}=o,{retryCodes:u=[],maxDelay:s=1/0,maxRetries:h=3,backoff:f=!0,retryDelay:M=200,retryOnAbort:c=!0}=l||{},g,x,w=0;ge(u);async function C(){return r(t,{...o,...n,headers:{...o.headers,...n.headers,"Accept-Encoding":"application/json"},...o.body?{data:o.body}:{},withCredentials:n.credentialsMode==="include"})}async function R(){let O=async(S,Q)=>{let J={};try{if(J=await C(),J.status>399&&dt(S,J))return{_response:J,shouldRetry:!0}}catch(fe){if(fe.name.includes("AbortError")&&Q)return{_response:fe,shouldRetry:!0};throw fe}return{_response:J,shouldRetry:!1}},P=c||!d||!d.signal,{_response:oe,shouldRetry:U}=await O(u,P);for(;a&&U&&w<h;){w++;let S=await O(u,P);oe=S._response,U=S.shouldRetry;let Q=ne({retryCount:w,retryDelay:M,maxRetries:h,backoff:f,maxDelay:s});await ae(Q)}return oe}let p=await R();try{p.text&&typeof p.text=="function"?(g=await p.text()||p[Object.getOwnPropertySymbols(p)[1]],x=JSON.parse(g)):x=p.data||p}catch{x=g}return{data:x,retryCount:w,statusCode:p.status||p.statusCode||x.statusCode,headers:p.headers}},{})}function se(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,e=>(parseInt(e)^Math.floor(Math.random()*256)&15>>parseInt(e)/4).toString(16))}function ct(e){return ye.reduce((t,r)=>{let o=e[r]?e[r]:typeof e.get=="function"?e.get(r):null;return o&&(t[r]=o),t},{})}function b(e){if(!e)return null;if(e.raw&&typeof e.raw=="function")return e.raw();if(!e.forEach)return ct(e);let t={};return e.forEach((r,o)=>t[o]=r)}function Y(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function I(e){let t=Object.assign({},e);return t?.headers&&(t.headers.Authorization&&(t.headers.Authorization="Bearer ********"),t.headers.authorization&&(t.headers.authorization="Bearer ********")),t}function m(e,t){return{...t,headers:{...t.headers,Authorization:`Bearer ${e}`}}}var Ce=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function ne({retryCount:e,retryDelay:t,backoff:r,maxDelay:o}){return r&&e!==0?Math.min(Math.round((Math.random()+1)*t*2**e),o):t}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function ae(e){return new Promise(t=>{setTimeout(t,e)})}function A(e){if(!e?.credentials?.clientId||!e.projectKey||!e.host)throw new Error("Missing required options.");return{clientId:e.credentials.clientId,host:e.host,projectKey:e.projectKey}}function le(e){return Date.now()+e*1e3-5*60*1e3}function T(e){let t=e;return{get:r=>t,set:(r,o)=>{t=r}}}function Ie(e){return typeof e<"u"&&e!==null}function ht(e){return Ie(e)?typeof e=="string"?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>![null,void 0,""].includes(r))):""}function pt(e){let t={},r=new URLSearchParams(e);for(let o of r.keys())r.getAll(o).length>1?t[o]=r.getAll(o):t[o]=r.get(o);return t}function wt(e){if(e=ht(e),!e)return"";let t=new URLSearchParams(e);for(let[r,o]of Object.entries(e))Array.isArray(o)&&(t.delete(r),o.filter(Ie).forEach(i=>t.append(r,i)));return t.toString()}function Re(e,t=pt){return t(e)}function de(e,t=wt){return t(e)}var ft=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function mt(){if(ft())return window.navigator.userAgent;let e=process?.version.slice(1)||"unknow",t=`(${process.platform}; ${process.arch})`;return`node.js/${e} ${t}`}function ue(e){let t=null,r=null;if(!e)throw new Error("Missing required option `name`");let o=e.version?`${e.name}/${e.version}`:e.name;e.libraryName&&!e.libraryVersion?t=e.libraryName:e.libraryName&&e.libraryVersion&&(t=`${e.libraryName}/${e.libraryVersion}`),e.contactUrl&&!e.contactEmail?r=`(+${e.contactUrl})`:!e.contactUrl&&e.contactEmail?r=`(+${e.contactEmail})`:e.contactUrl&&e.contactEmail&&(r=`(+${e.contactUrl}; +${e.contactEmail})`);let i=mt(),n=e.customAgent||"";return[o,i,t,r,n].filter(Boolean).join(" ")}function _(e){return typeof e=="string"?e.length.toString():e&&typeof e=="object"?new TextEncoder().encode(JSON.stringify(e)).length.toString():e instanceof Uint8Array?e.length.toString():"0"}function be(e){if(!e.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!e.httpClient&&typeof e.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.")}function ge(e){if(!Array.isArray(e))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Ae(e){if(!e)throw new Error("Missing required options");if(e.middlewares&&!Array.isArray(e.middlewares))throw new Error("Middlewares should be an array");if(!e.middlewares||!Array.isArray(e.middlewares)||!e.middlewares.length)throw new Error("You need to provide at least one middleware")}function ce(e,t,r={allowedMethods:Ce}){if(!t)throw new Error(`The "${e}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof t.uri!="string")throw new Error(`The "${e}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!r.allowedMethods.includes(t.method))throw new Error(`The "${e}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function Te(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");let{clientId:t,clientSecret:r}=e.credentials||{};if(!(t&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let o=e.scopes?e.scopes.join(" "):void 0,i=btoa(`${t}:${r}`),n=e.oauthUri||"/oauth/token",a=e.host.replace(/\/$/,"")+n,l=`grant_type=client_credentials${o?`&scope=${o}`:""}`;return{url:a,body:l,basicAuth:i}}function je(e){if(!e)throw new Error("Missing required options");if(!e.projectKey)throw new Error("Missing required option (projectKey)");let t=e.projectKey;e.oauthUri=e.oauthUri||`/oauth/${t}/anonymous/token`;let r=Te(e);return e.credentials.anonymousId&&(r.body+=`&anonymous_id=${e.credentials.anonymousId}`),{...r}}function he(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");if(!e.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:t,clientSecret:r}=e.credentials;if(!(t&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let o=btoa(`${t}:${r}`),i=e.oauthUri||"/oauth/token",n=e.host.replace(/\/$/,"")+i,a=`grant_type=refresh_token&refresh_token=${encodeURIComponent(e.refreshToken)}`;return{basicAuth:o,url:n,body:a}}function qe(e){if(!e)throw new Error("Missing required options");if(!e.host)throw new Error("Missing required option (host)");if(!e.projectKey)throw new Error("Missing required option (projectKey)");if(!e.credentials)throw new Error("Missing required option (credentials)");let{clientId:t,clientSecret:r,user:o}=e.credentials,i=e.projectKey;if(!(t&&r&&o))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:n,password:a}=o;if(!(n&&a))throw new Error("Missing required user credentials (username, password)");let l=(e.scopes||[]).join(" "),d=l?`&scope=${l}`:"",u=btoa(`${t}:${r}`),s=e.oauthUri||`/oauth/${i}/customers/token`,h=e.host.replace(/\/$/,"")+s,f=`grant_type=password&username=${encodeURIComponent(n)}&password=${encodeURIComponent(a)}${d}`;return{basicAuth:u,url:h,body:f}}async function E(e){let{httpClient:t,tokenCache:r,userOption:o,tokenCacheObject:i}=e,n=e.url,a=e.body,l=e.basicAuth;if(!t||typeof t!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(i&&i.refreshToken&&(!i.token||i.token&&Date.now()>i.expirationTime)){if(!o)throw new Error("Missing required options.");let u={...he({...o,refreshToken:i.refreshToken})};n=u.url,a=u.body,l=u.basicAuth}let d;try{if(d=await v({url:n,method:"POST",headers:{Authorization:`Basic ${l}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":_(a)},httpClient:t,body:a}),d.statusCode>=200&&d.statusCode<300){let{access_token:u,expires_in:s,refresh_token:h}=d?.data,f=le(s);return r.set({token:u,expirationTime:f,refreshToken:h}),Promise.resolve(!0)}throw N({code:d.data.error,statusCode:d.data.statusCode,message:d.data.message,error:d.data.errors})}catch(u){throw u}}function K(e){let t=e.tokenCache||T({token:"",expirationTime:-1}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(m(r.token,a));let l={request:a,tokenCache:t,tokenCacheKey:i,httpClient:e.httpClient||Ue.default,...je(e),userOption:e,next:n};return o?await o:(o=E(l),await o,o=null),r=t.get(i),n(m(r.token,a))}}var He=G(V());function B(e){let t=e.tokenCache||T({token:"",expirationTime:-1}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(m(r.token,a));let l={request:a,tokenCache:t,tokenCacheKey:i,tokenCacheObject:r,httpClient:e.httpClient||He.default,...Te(e),next:n};return o?await o:(o=E(l),await o,o=null),r=t.get(i),n(m(r.token,a))}}function L(e,t){return r=>async o=>{if(typeof e!="string")throw new Error("authorization must be a string");let i=t?.force===void 0?!0:t.force;if(!e||o.headers&&(o.headers.Authorization||o.headers.authorization)&&i===!1)return r(o);let n={...o,headers:{...o.headers,Authorization:e}};return r(n)}}var Ne=G(V());function D(e){let t=e.tokenCache||T({token:"",expirationTime:-1}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(m(r.token,a));let l={request:a,tokenCache:t,tokenCacheKey:i,httpClient:e.httpClient||Ne.default,...qe(e),userOption:e,next:n};return o?await o:(o=E(l),await o,o=null),r=t.get(i),n(m(r.token,a))}}function $(e){let t=e.tokenCache||T({token:"",tokenCacheKey:null}),r,o=null,i=A(e);return n=>async a=>{if(a.headers&&(a.headers.Authorization||a.headers.authorization))return n(a);if(r=t.get(i),r&&r.token&&Date.now()<r.expirationTime)return n(m(r.token,a));let l={request:a,tokenCache:t,httpClient:e.httpClient||fetch,...he(e),next:n};return o?await o:(o=E(l),await o,o=null),r=t.get(i),n(m(r.token,a))}}function W(e){return t=>async r=>{let o=await t(r);if(o.statusCode==409){let i=o.error.body?.errors?.[0]?.currentVersion;if(i)return e&&typeof e=="function"?r.body=await e(i,r,o):r.body=typeof r.body=="string"?{...JSON.parse(r.body),version:i}:{...r.body,version:i},t(r)}return o}}function X(e){return t=>r=>{let o={...r,headers:{...r.headers,"X-Correlation-ID":e.generate&&typeof e.generate=="function"?e.generate():se()}};return t(o)}}function xe(e){return t=>async r=>{let o=await t(r);if(o.error){let{error:i}=o;return{...o,statusCode:i.statusCode||0,headers:i.headers||b({}),error:{...i,body:i.data||i}}}return o}}var Ke=G(_e());async function Mt({url:e,httpClient:t,clientOptions:r}){let o,{timeout:i,request:n,abortController:a,maskSensitiveHeaderData:l,includeRequestInErrorResponse:d,includeResponseHeaders:u}=r;try{i&&(o=setTimeout(()=>{a.abort()},i));let s=await v({url:e,...r,httpClient:t,method:r.method,...r.body?{body:r.body}:{}});if(u||(s.headers=null),s.statusCode>=200&&s.statusCode<300)return r.method=="HEAD"?{body:null,statusCode:s.statusCode,retryCount:s.retryCount,headers:b(s.headers)}:{body:s.data,statusCode:s.statusCode,retryCount:s.retryCount,headers:b(s.headers)};let h=N({message:s?.data?.message||s?.message,statusCode:s.statusCode||s?.data?.statusCode,headers:b(s.headers),method:r.method,body:s.data,retryCount:s.retryCount,...d?{originalRequest:l?I(n):n}:{uri:n.uri}});return{body:s.data,code:s.statusCode,statusCode:s.statusCode,headers:b(s.headers),error:h}}catch(s){let h=u?b(s.response?.headers):null,f=s.response?.status||s.response?.data0||0,M=s.response?.data?.message,c=N({statusCode:f,code:f,status:f,message:M||s.message,headers:h,body:s.response?.data||s,error:s.response?.data,...d?{originalRequest:l?I(n):n}:{uri:n.uri}});throw{body:c,error:c}}finally{clearTimeout(o)}}function Z(e){be(e);let{host:t,credentialsMode:r,httpClient:o,timeout:i,enableRetry:n,retryConfig:a,getAbortController:l,includeOriginalRequest:d,includeRequestInErrorResponse:u=!0,includeResponseHeaders:s=!0,maskSensitiveHeaderData:h,httpClientOptions:f}=e;return M=>async c=>{let g;(i||l)&&(g=(l?l():null)||new Ke.default);let x=t.replace(/\/$/,"")+c.uri,w={...c.headers};Object.prototype.hasOwnProperty.call(w,"Content-Type")||Object.prototype.hasOwnProperty.call(w,"content-type")||(w["Content-Type"]="application/json"),w["Content-Type"]===null&&delete w["Content-Type"];let C=y.HEADERS_CONTENT_TYPES.indexOf(w["Content-Type"])>-1&&typeof c.body=="string"||Y(c.body)?c.body:JSON.stringify(c.body||void 0);C&&(typeof C=="string"||Y(C))&&(w["Content-Length"]=_(C));let R={enableRetry:n,retryConfig:a,request:c,method:c.method,headers:w,includeRequestInErrorResponse:u,maskSensitiveHeaderData:h,includeResponseHeaders:s,...f};r&&(R.credentialsMode=r),g&&(R.signal=g.signal),i&&(R.timeout=i,R.abortController=g),C&&(R.body=C);let p=await Mt({url:x,clientOptions:R,httpClient:o}),O={...c,includeOriginalRequest:d,maskSensitiveHeaderData:h,response:p};return M(O)}}function ee(e){return t=>async r=>{let o=await t(r),i=Object.assign({},o),{loggerFn:n=console.log}=e||{};return n&&typeof n=="function"&&n(o),i}}function te({concurrency:e=20}){let t=0,r=[],o=()=>0>=e?Promise.resolve():new Promise(n=>{let a=()=>{t<e?(t++,n()):r.push(a)};a()}),i=()=>{if(t--,r.length>0){let n=r.shift();n&&n()}};return n=>a=>o().then(()=>{let l={...a,resolve(d){a.resolve(d),i()},reject(d){a.reject(d),i()}};return n(l).finally(()=>{i()})})}var Be={name:"@commercetools/ts-client",version:"2.1.0",engines:{node:">=14"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{"abort-controller":"3.0.0","node-fetch":"^2.6.1"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.5",jest:"29.7.0",nock:"12.0.3","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function re(e){return t=>async r=>{let o=ue({...e,name:`${e.name?e.name+"/":""}commercetools-sdk-javascript-v3/${Be.version}`}),i={...r,headers:{...r.headers,"User-Agent":o}};return t(i)}}function Ct({middlewares:e}){return e.length===1?e[0]:e.slice().reduce((r,o)=>(...i)=>r(o.apply(null,i)))}var Le;function we(e,t,r){if(ce("process",e,{allowedMethods:["GET"]}),typeof t!="function")throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');let o={total:Number.POSITIVE_INFINITY,accumulate:!0,...r};return new Promise((i,n)=>{let a,l="";if(e&&e.uri){let[M,c]=e.uri.split("?");a=M,l=c}let u={limit:20,...{...Re(l)}},s=o.total,h=!1,f=async(M,c=[])=>{let g=u.limit<s?u.limit:s,x=de({...u,limit:g}),w={sort:"id asc",withTotal:!1,...M?{where:`id > "${M}"`}:{}},C=de(w),R={...e,uri:`${a}?${C}&${x}`};try{let p=await j(Le).execute(R),{results:O,count:P}=p?.body||{};if(!P&&h)return i(c||[]);let oe=await Promise.resolve(t(p)),U;if(h=!0,o.accumulate&&(U=c.concat(oe||[])),s-=P,P<u.limit||!s)return i(U||[]);let S=O[P-1],Q=S&&S.id;f(Q,U)}catch(p){n(p)}};f()})}function j(e){Le=e,Ae(e);let t=!1,r={async resolve(i){let{response:n,includeOriginalRequest:a,maskSensitiveHeaderData:l,...d}=i,{retryCount:u,...s}=n;return t=l,{body:null,error:null,reject:i.reject,resolve:i.resolve,...s,...a?{originalRequest:d}:{},...n?.retryCount?{retryCount:n.retryCount}:{}}}},o=Ct(e)(r.resolve);return{process:we,execute(i){return ce("exec",i),new Promise(async(n,a)=>{try{let l=await o({reject:a,resolve:n,...i});if(l.error)return a(l.error);l.originalRequest&&t&&(l.originalRequest=I(l.originalRequest)),n(l)}catch(l){a(l)}})}}}var{createAuthMiddlewareForPasswordFlow:Rt,createAuthMiddlewareForAnonymousSessionFlow:bt,createAuthMiddlewareForClientCredentialsFlow:At,createAuthMiddlewareForRefreshTokenFlow:Tt,createAuthMiddlewareForExistingTokenFlow:xt,createCorrelationIdMiddleware:kt,createHttpMiddleware:Et,createLoggerMiddleware:Ot,createQueueMiddleware:Pt,createUserAgentMiddleware:De,createConcurrentModificationMiddleware:St}=ke,z=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=De({})}withProjectKey(t){return this.projectKey=t,this}defaultClient(t,r,o,i,n,a){return this.withClientCredentialsFlow({host:o,projectKey:i||this.projectKey,credentials:r,scopes:n}).withHttpMiddleware({host:t,httpClient:a||q.default})}withAuthMiddleware(t){return this.authMiddleware=t,this}withMiddleware(t){return this.middlewares.push(t),this}withClientCredentialsFlow(t){return this.withAuthMiddleware(At({host:t.host||y.CTP_AUTH_URL,projectKey:t.projectKey||this.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null},oauthUri:t.oauthUri||null,scopes:t.scopes,httpClient:t.httpClient||q.default,...t}))}withPasswordFlow(t){return this.withAuthMiddleware(Rt({host:t.host||y.CTP_AUTH_URL,projectKey:t.projectKey||this.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null,user:{username:t.credentials.user.username||null,password:t.credentials.user.password||null}},httpClient:t.httpClient||q.default,...t}))}withAnonymousSessionFlow(t){return this.withAuthMiddleware(bt({host:t.host||y.CTP_AUTH_URL,projectKey:this.projectKey||t.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null,anonymousId:t.credentials.anonymousId||null},httpClient:t.httpClient||q.default,...t}))}withRefreshTokenFlow(t){return this.withAuthMiddleware(Tt({host:t.host||y.CTP_AUTH_URL,projectKey:this.projectKey||t.projectKey,credentials:{clientId:t.credentials.clientId||null,clientSecret:t.credentials.clientSecret||null},httpClient:t.httpClient||q.default,refreshToken:t.refreshToken||null,...t}))}withExistingTokenFlow(t,r){return this.withAuthMiddleware(xt(t,{force:r.force||!0,...r}))}withHttpMiddleware(t){return this.httpMiddleware=Et({host:t.host||y.CTP_API_URL,httpClient:t.httpClient||q.default,...t}),this}withUserAgentMiddleware(t){return this.userAgentMiddleware=De(t),this}withQueueMiddleware(t){return this.queueMiddleware=Pt({concurrency:t.concurrency||y.CONCURRENCT_REQUEST,...t}),this}withLoggerMiddleware(t){return this.loggerMiddleware=Ot(t),this}withCorrelationIdMiddleware(t){return this.correlationIdMiddleware=kt({generate:t?.generate,...t}),this}withConcurrentModificationMiddleware(t){return this.concurrentMiddleware=St(t?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(t){let{createTelemetryMiddleware:r,...o}=t;return this.withUserAgentMiddleware({customAgent:o?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=r(o),this}withBeforeExecutionMiddleware(t){let{middleware:r,...o}=t||{};return this.beforeMiddleware=t.middleware(o),this}withAfterExecutionMiddleware(t){let{middleware:r,...o}=t||{};return this.afterMiddleware=t.middleware(o),this}build(){let t=this.middlewares.slice();return this.telemetryMiddleware&&t.push(this.telemetryMiddleware),this.correlationIdMiddleware&&t.push(this.correlationIdMiddleware),this.userAgentMiddleware&&t.push(this.userAgentMiddleware),this.authMiddleware&&t.push(this.authMiddleware),this.beforeMiddleware&&t.push(this.beforeMiddleware),this.queueMiddleware&&t.push(this.queueMiddleware),this.loggerMiddleware&&t.push(this.loggerMiddleware),this.concurrentMiddleware&&t.push(this.concurrentMiddleware),this.httpMiddleware&&t.push(this.httpMiddleware),this.afterMiddleware&&t.push(this.afterMiddleware),j({middlewares:t})}};return Ve(Ft);})();
1
+ var window;(window||={})["@commercetools/ts-client"]=(()=>{var Lr=Object.create;var Me=Object.defineProperty;var Hr=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var $r=Object.getPrototypeOf,Kr=Object.prototype.hasOwnProperty;var ue=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ne=(t,e)=>{for(var r in e)Me(t,r,{get:e[r],enumerable:!0})},tr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dr(e))!Kr.call(t,n)&&n!==r&&Me(t,n,{get:()=>e[n],enumerable:!(i=Hr(e,n))||i.enumerable});return t};var le=(t,e,r)=>(r=t!=null?Lr($r(t)):{},tr(e||!t||!t.__esModule?Me(r,"default",{value:t,enumerable:!0}):r,t)),zr=t=>tr(Me({},"__esModule",{value:!0}),t);var ce=ue((Q,ir)=>{"use strict";var Gr=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},L=Gr();ir.exports=Q=L.fetch;L.fetch&&(Q.default=L.fetch.bind(L));Q.Headers=L.Headers;Q.Request=L.Request;Q.Response=L.Response});var sr=ue(Ee=>{"use strict";Ee.byteLength=Jr;Ee.toByteArray=Yr;Ee.fromByteArray=Xr;var T=[],C=[],Qr=typeof Uint8Array<"u"?Uint8Array:Array,_e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(H=0,nr=_e.length;H<nr;++H)T[H]=_e[H],C[_e.charCodeAt(H)]=H;var H,nr;C[45]=62;C[95]=63;function or(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function Jr(t){var e=or(t),r=e[0],i=e[1];return(r+i)*3/4-i}function Vr(t,e,r){return(e+r)*3/4-r}function Yr(t){var e,r=or(t),i=r[0],n=r[1],o=new Qr(Vr(t,i,n)),s=0,u=n>0?i-4:i,c;for(c=0;c<u;c+=4)e=C[t.charCodeAt(c)]<<18|C[t.charCodeAt(c+1)]<<12|C[t.charCodeAt(c+2)]<<6|C[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return n===2&&(e=C[t.charCodeAt(c)]<<2|C[t.charCodeAt(c+1)]>>4,o[s++]=e&255),n===1&&(e=C[t.charCodeAt(c)]<<10|C[t.charCodeAt(c+1)]<<4|C[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Wr(t){return T[t>>18&63]+T[t>>12&63]+T[t>>6&63]+T[t&63]}function vr(t,e,r){for(var i,n=[],o=e;o<r;o+=3)i=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),n.push(Wr(i));return n.join("")}function Xr(t){for(var e,r=t.length,i=r%3,n=[],o=16383,s=0,u=r-i;s<u;s+=o)n.push(vr(t,s,s+o>u?u:s+o));return i===1?(e=t[r-1],n.push(T[e>>2]+T[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],n.push(T[e>>10]+T[e>>4&63]+T[e<<2&63]+"=")),n.join("")}});var ar=ue(qe=>{qe.read=function(t,e,r,i,n){var o,s,u=n*8-i-1,c=(1<<u)-1,h=c>>1,l=-7,d=r?n-1:0,p=r?-1:1,w=t[e+d];for(d+=p,o=w&(1<<-l)-1,w>>=-l,l+=u;l>0;o=o*256+t[e+d],d+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=s*256+t[e+d],d+=p,l-=8);if(o===0)o=1-h;else{if(o===c)return s?NaN:(w?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-h}return(w?-1:1)*s*Math.pow(2,o-i)};qe.write=function(t,e,r,i,n,o){var s,u,c,h=o*8-n-1,l=(1<<h)-1,d=l>>1,p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=i?0:o-1,f=i?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=p/c:e+=p*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=l?(u=0,s=l):s+d>=1?(u=(e*c-1)*Math.pow(2,n),s=s+d):(u=e*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;t[r+w]=u&255,w+=f,u/=256,n-=8);for(s=s<<n|u,h+=n;h>0;t[r+w]=s&255,w+=f,s/=256,h-=8);t[r+w-f]|=E*128}});var Rr=ue(W=>{"use strict";var je=sr(),V=ar(),ur=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;W.Buffer=a;W.SlowBuffer=nt;W.INSPECT_MAX_BYTES=50;var Ce=2147483647;W.kMaxLength=Ce;a.TYPED_ARRAY_SUPPORT=Zr();!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Zr(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}});Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function O(t){if(t>Ce)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return $e(t)}return hr(t,e,r)}a.poolSize=8192;function hr(t,e,r){if(typeof t=="string")return rt(t,e);if(ArrayBuffer.isView(t))return tt(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(b(t,ArrayBuffer)||t&&b(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(t,SharedArrayBuffer)||t&&b(t.buffer,SharedArrayBuffer)))return He(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=t.valueOf&&t.valueOf();if(i!=null&&i!==t)return a.from(i,e,r);let n=it(t);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}a.from=function(t,e,r){return hr(t,e,r)};Object.setPrototypeOf(a.prototype,Uint8Array.prototype);Object.setPrototypeOf(a,Uint8Array);function fr(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function et(t,e,r){return fr(t),t<=0?O(t):e!==void 0?typeof r=="string"?O(t).fill(e,r):O(t).fill(e):O(t)}a.alloc=function(t,e,r){return et(t,e,r)};function $e(t){return fr(t),O(t<0?0:Ke(t)|0)}a.allocUnsafe=function(t){return $e(t)};a.allocUnsafeSlow=function(t){return $e(t)};function rt(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=pr(t,e)|0,i=O(r),n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}function Le(t){let e=t.length<0?0:Ke(t.length)|0,r=O(e);for(let i=0;i<e;i+=1)r[i]=t[i]&255;return r}function tt(t){if(b(t,Uint8Array)){let e=new Uint8Array(t);return He(e.buffer,e.byteOffset,e.byteLength)}return Le(t)}function He(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&r===void 0?i=new Uint8Array(t):r===void 0?i=new Uint8Array(t,e):i=new Uint8Array(t,e,r),Object.setPrototypeOf(i,a.prototype),i}function it(t){if(a.isBuffer(t)){let e=Ke(t.length)|0,r=O(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Ge(t.length)?O(0):Le(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Le(t.data)}function Ke(t){if(t>=Ce)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ce.toString(16)+" bytes");return t|0}function nt(t){return+t!=t&&(t=0),a.alloc(+t)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype};a.compare=function(e,r){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),b(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),!a.isBuffer(e)||!a.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let i=e.length,n=r.length;for(let o=0,s=Math.min(i,n);o<s;++o)if(e[o]!==r[o]){i=e[o],n=r[o];break}return i<n?-1:n<i?1:0};a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let i;if(r===void 0)for(r=0,i=0;i<e.length;++i)r+=e[i].length;let n=a.allocUnsafe(r),o=0;for(i=0;i<e.length;++i){let s=e[i];if(b(s,Uint8Array))o+s.length>n.length?(a.isBuffer(s)||(s=a.from(s)),s.copy(n,o)):Uint8Array.prototype.set.call(n,s,o);else if(a.isBuffer(s))s.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return n};function pr(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||b(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&r===0)return 0;let n=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return De(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ar(t).length;default:if(n)return i?-1:De(t).length;e=(""+e).toLowerCase(),n=!0}}a.byteLength=pr;function ot(t,e,r){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return wt(this,e,r);case"utf8":case"utf-8":return mr(this,e,r);case"ascii":return ft(this,e,r);case"latin1":case"binary":return pt(this,e,r);case"base64":return dt(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mt(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}a.prototype._isBuffer=!0;function D(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)D(this,r,r+1);return this};a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)D(this,r,r+3),D(this,r+1,r+2);return this};a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)D(this,r,r+7),D(this,r+1,r+6),D(this,r+2,r+5),D(this,r+3,r+4);return this};a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?mr(this,0,e):ot.apply(this,arguments)};a.prototype.toLocaleString=a.prototype.toString;a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0};a.prototype.inspect=function(){let e="",r=W.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ur&&(a.prototype[ur]=a.prototype.inspect);a.prototype.compare=function(e,r,i,n,o){if(b(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),r<0||i>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=i)return 0;if(n>=o)return-1;if(r>=i)return 1;if(r>>>=0,i>>>=0,n>>>=0,o>>>=0,this===e)return 0;let s=o-n,u=i-r,c=Math.min(s,u),h=this.slice(n,o),l=e.slice(r,i);for(let d=0;d<c;++d)if(h[d]!==l[d]){s=h[d],u=l[d];break}return s<u?-1:u<s?1:0};function wr(t,e,r,i,n){if(t.length===0)return-1;if(typeof r=="string"?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Ge(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0)if(n)r=0;else return-1;if(typeof e=="string"&&(e=a.from(e,i)),a.isBuffer(e))return e.length===0?-1:lr(t,e,r,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):lr(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function lr(t,e,r,i,n){let o=1,s=t.length,u=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,u/=2,r/=2}function c(l,d){return o===1?l[d]:l.readUInt16BE(d*o)}let h;if(n){let l=-1;for(h=r;h<s;h++)if(c(t,h)===c(e,l===-1?0:h-l)){if(l===-1&&(l=h),h-l+1===u)return l*o}else l!==-1&&(h-=h-l),l=-1}else for(r+u>s&&(r=s-u),h=r;h>=0;h--){let l=!0;for(let d=0;d<u;d++)if(c(t,h+d)!==c(e,d)){l=!1;break}if(l)return h}return-1}a.prototype.includes=function(e,r,i){return this.indexOf(e,r,i)!==-1};a.prototype.indexOf=function(e,r,i){return wr(this,e,r,i,!0)};a.prototype.lastIndexOf=function(e,r,i){return wr(this,e,r,i,!1)};function st(t,e,r,i){r=Number(r)||0;let n=t.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;let o=e.length;i>o/2&&(i=o/2);let s;for(s=0;s<i;++s){let u=parseInt(e.substr(s*2,2),16);if(Ge(u))return s;t[r+s]=u}return s}function at(t,e,r,i){return Ae(De(e,t.length-r),t,r,i)}function ut(t,e,r,i){return Ae(Mt(e),t,r,i)}function lt(t,e,r,i){return Ae(Ar(e),t,r,i)}function ct(t,e,r,i){return Ae(Et(e,t.length-r),t,r,i)}a.prototype.write=function(e,r,i,n){if(r===void 0)n="utf8",i=this.length,r=0;else if(i===void 0&&typeof r=="string")n=r,i=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((i===void 0||i>o)&&(i=o),e.length>0&&(i<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return st(this,e,r,i);case"utf8":case"utf-8":return at(this,e,r,i);case"ascii":case"latin1":case"binary":return ut(this,e,r,i);case"base64":return lt(this,e,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ct(this,e,r,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dt(t,e,r){return e===0&&r===t.length?je.fromByteArray(t):je.fromByteArray(t.slice(e,r))}function mr(t,e,r){r=Math.min(t.length,r);let i=[],n=e;for(;n<r;){let o=t[n],s=null,u=o>239?4:o>223?3:o>191?2:1;if(n+u<=r){let c,h,l,d;switch(u){case 1:o<128&&(s=o);break;case 2:c=t[n+1],(c&192)===128&&(d=(o&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[n+1],h=t[n+2],(c&192)===128&&(h&192)===128&&(d=(o&15)<<12|(c&63)<<6|h&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=t[n+1],h=t[n+2],l=t[n+3],(c&192)===128&&(h&192)===128&&(l&192)===128&&(d=(o&15)<<18|(c&63)<<12|(h&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|s&1023),i.push(s),n+=u}return ht(i)}var cr=4096;function ht(t){let e=t.length;if(e<=cr)return String.fromCharCode.apply(String,t);let r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=cr));return r}function ft(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]&127);return i}function pt(t,e,r){let i="";r=Math.min(t.length,r);for(let n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function wt(t,e,r){let i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);let n="";for(let o=e;o<r;++o)n+=Ct[t[o]];return n}function mt(t,e,r){let i=t.slice(e,r),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}a.prototype.slice=function(e,r){let i=this.length;e=~~e,r=r===void 0?i:~~r,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),r<e&&(r=e);let n=this.subarray(e,r);return Object.setPrototypeOf(n,a.prototype),n};function m(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=this[e],o=1,s=0;for(;++s<r&&(o*=256);)n+=this[e+s]*o;return n};a.prototype.readUintBE=a.prototype.readUIntBE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=this[e+--r],o=1;for(;r>0&&(o*=256);)n+=this[e+--r]*o;return n};a.prototype.readUint8=a.prototype.readUInt8=function(e,r){return e=e>>>0,r||m(e,1,this.length),this[e]};a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||m(e,2,this.length),this[e]|this[e+1]<<8};a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||m(e,2,this.length),this[e]<<8|this[e+1]};a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||m(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||m(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};a.prototype.readBigUInt64LE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});a.prototype.readBigUInt64BE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});a.prototype.readIntLE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=this[e],o=1,s=0;for(;++s<r&&(o*=256);)n+=this[e+s]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*r)),n};a.prototype.readIntBE=function(e,r,i){e=e>>>0,r=r>>>0,i||m(e,r,this.length);let n=r,o=1,s=this[e+--n];for(;n>0&&(o*=256);)s+=this[e+--n]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};a.prototype.readInt8=function(e,r){return e=e>>>0,r||m(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};a.prototype.readInt16LE=function(e,r){e=e>>>0,r||m(e,2,this.length);let i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};a.prototype.readInt16BE=function(e,r){e=e>>>0,r||m(e,2,this.length);let i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};a.prototype.readInt32LE=function(e,r){return e=e>>>0,r||m(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};a.prototype.readInt32BE=function(e,r){return e=e>>>0,r||m(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};a.prototype.readBigInt64LE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});a.prototype.readBigInt64BE=P(function(e){e=e>>>0,Y(e,"offset");let r=this[e],i=this[e+7];(r===void 0||i===void 0)&&de(e,this.length-8);let n=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)});a.prototype.readFloatLE=function(e,r){return e=e>>>0,r||m(e,4,this.length),V.read(this,e,!0,23,4)};a.prototype.readFloatBE=function(e,r){return e=e>>>0,r||m(e,4,this.length),V.read(this,e,!1,23,4)};a.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||m(e,8,this.length),V.read(this,e,!0,52,8)};a.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||m(e,8,this.length),V.read(this,e,!1,52,8)};function x(t,e,r,i,n,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,r,i,n){if(e=+e,r=r>>>0,i=i>>>0,!n){let u=Math.pow(2,8*i)-1;x(this,e,r,i,u,0)}let o=1,s=0;for(this[r]=e&255;++s<i&&(o*=256);)this[r+s]=e/o&255;return r+i};a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,r,i,n){if(e=+e,r=r>>>0,i=i>>>0,!n){let u=Math.pow(2,8*i)-1;x(this,e,r,i,u,0)}let o=i-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+i};a.prototype.writeUint8=a.prototype.writeUInt8=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,1,255,0),this[r]=e&255,r+1};a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function yr(t,e,r,i,n){Cr(e,i,n,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function gr(t,e,r,i,n){Cr(e,i,n,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}a.prototype.writeBigUInt64LE=P(function(e,r=0){return yr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeBigUInt64BE=P(function(e,r=0){return gr(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});a.prototype.writeIntLE=function(e,r,i,n){if(e=+e,r=r>>>0,!n){let c=Math.pow(2,8*i-1);x(this,e,r,i,c-1,-c)}let o=0,s=1,u=0;for(this[r]=e&255;++o<i&&(s*=256);)e<0&&u===0&&this[r+o-1]!==0&&(u=1),this[r+o]=(e/s>>0)-u&255;return r+i};a.prototype.writeIntBE=function(e,r,i,n){if(e=+e,r=r>>>0,!n){let c=Math.pow(2,8*i-1);x(this,e,r,i,c-1,-c)}let o=i-1,s=1,u=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&u===0&&this[r+o+1]!==0&&(u=1),this[r+o]=(e/s>>0)-u&255;return r+i};a.prototype.writeInt8=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};a.prototype.writeInt16LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};a.prototype.writeInt16BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};a.prototype.writeInt32LE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};a.prototype.writeInt32BE=function(e,r,i){return e=+e,r=r>>>0,i||x(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};a.prototype.writeBigInt64LE=P(function(e,r=0){return yr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});a.prototype.writeBigInt64BE=P(function(e,r=0){return gr(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function xr(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Mr(t,e,r,i,n){return e=+e,r=r>>>0,n||xr(t,e,r,4,34028234663852886e22,-34028234663852886e22),V.write(t,e,r,i,23,4),r+4}a.prototype.writeFloatLE=function(e,r,i){return Mr(this,e,r,!0,i)};a.prototype.writeFloatBE=function(e,r,i){return Mr(this,e,r,!1,i)};function Er(t,e,r,i,n){return e=+e,r=r>>>0,n||xr(t,e,r,8,17976931348623157e292,-17976931348623157e292),V.write(t,e,r,i,52,8),r+8}a.prototype.writeDoubleLE=function(e,r,i){return Er(this,e,r,!0,i)};a.prototype.writeDoubleBE=function(e,r,i){return Er(this,e,r,!1,i)};a.prototype.copy=function(e,r,i,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),r>=e.length&&(r=e.length),r||(r=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-r<n-i&&(n=e.length-r+i);let o=n-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),r),o};a.prototype.fill=function(e,r,i,n){if(typeof e=="string"){if(typeof r=="string"?(n=r,r=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){let s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<i)throw new RangeError("Out of range index");if(i<=r)return this;r=r>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<i;++o)this[o]=e;else{let s=a.isBuffer(e)?e:a.from(e,n),u=s.length;if(u===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-r;++o)this[o+r]=s[o%u]}return this};var J={};function ze(t,e,r){J[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}ze("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ze("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ze("ERR_OUT_OF_RANGE",function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=dr(String(r)):typeof r=="bigint"&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=dr(n)),n+="n"),i+=` It must be ${e}. Received ${n}`,i},RangeError);function dr(t){let e="",r=t.length,i=t[0]==="-"?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function yt(t,e,r){Y(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&de(e,t.length-(r+1))}function Cr(t,e,r,i,n,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",u;throw o>3?e===0||e===BigInt(0)?u=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:u=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:u=`>= ${e}${s} and <= ${r}${s}`,new J.ERR_OUT_OF_RANGE("value",u,t)}yt(i,n,o)}function Y(t,e){if(typeof t!="number")throw new J.ERR_INVALID_ARG_TYPE(e,"number",t)}function de(t,e,r){throw Math.floor(t)!==t?(Y(t,r),new J.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var gt=/[^+/0-9A-Za-z-_]/g;function xt(t){if(t=t.split("=")[0],t=t.trim().replace(gt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function De(t,e){e=e||1/0;let r,i=t.length,n=null,o=[];for(let s=0;s<i;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Mt(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Et(t,e){let r,i,n,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),i=r>>8,n=r%256,o.push(n),o.push(i);return o}function Ar(t){return je.toByteArray(xt(t))}function Ae(t,e,r,i){let n;for(n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function b(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Ge(t){return t!==t}var Ct=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let i=r*16;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function P(t){return typeof BigInt>"u"?At:t}function At(){throw new Error("BigInt not supported")}});var Pr=ue((kn,Oe)=>{"use strict";var{AbortController:Sr,AbortSignal:Gt}=typeof self<"u"?self:typeof window<"u"?window:void 0;Oe.exports=Sr;Oe.exports.AbortSignal=Gt;Oe.exports.default=Sr});var oi={};Ne(oi,{ClientBuilder:()=>oe,Process:()=>Se,createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>re,createAuthMiddlewareForExistingTokenFlow:()=>te,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createClient:()=>K,createConcurrentModificationMiddleware:()=>fe,createCorrelationIdMiddleware:()=>pe,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var z=le(ce());var rr={};Ne(rr,{createAuthMiddlewareForAnonymousSessionFlow:()=>ee,createAuthMiddlewareForClientCredentialsFlow:()=>re,createAuthMiddlewareForExistingTokenFlow:()=>te,createAuthMiddlewareForPasswordFlow:()=>ie,createAuthMiddlewareForRefreshTokenFlow:()=>ne,createConcurrentModificationMiddleware:()=>fe,createCorrelationIdMiddleware:()=>pe,createErrorMiddleware:()=>er,createHttpMiddleware:()=>we,createLoggerMiddleware:()=>me,createQueueMiddleware:()=>ye,createUserAgentMiddleware:()=>ge});var Ur=le(ce());var Rt=Rr().Buffer;function v(t){return t&&(typeof t=="string"||t instanceof Uint8Array)?Rt.byteLength(t).toString():t&&typeof t=="object"?new TextEncoder().encode(JSON.stringify(t)).length.toString():"0"}var A={};Ne(A,{CONCURRENCT_REQUEST:()=>Tt,CTP_API_URL:()=>bt,CTP_AUTH_URL:()=>It,DEFAULT_HEADERS:()=>Qe,HEADERS_CONTENT_TYPES:()=>Bt});var Bt=["application/json","application/graphql"],Tt=20,bt="https://api.europe-west1.gcp.commercetools.com",It="https://auth.europe-west1.gcp.commercetools.com",Qe=["content-type","access-control-allow-origin","access-control-allow-headers","access-control-allow-methods","access-control-expose-headers","access-control-max-ag","x-correlation-id","server-timing","date","server","transfer-encoding","access-control-max-age","content-encoding","x-envoy-upstream-service-time","via","alt-svc","connection"];function S(t,e,r={}){this.status=this.statusCode=this.code=t,this.message=e,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function Br(...t){S.call(this,0,...t)}function Tr(...t){S.call(this,...t)}function Ft(...t){S.call(this,400,...t)}function Ut(...t){S.call(this,401,...t)}function kt(...t){S.call(this,403,...t)}function Ot(...t){S.call(this,404,...t)}function St(...t){S.call(this,409,...t)}function Pt(...t){S.call(this,500,...t)}function Nt(...t){S.call(this,503,...t)}function Je(t){switch(t){case 0:return Br;case 400:return Ft;case 401:return Ut;case 403:return kt;case 404:return Ot;case 409:return St;case 500:return Pt;case 503:return Nt;default:return}}function _t({statusCode:t,message:e,...r}){let i=e||"Unexpected non-JSON error response";t===404&&(i=`URI not found: ${r.originalRequest?.uri||r.uri}`);let n=Je(t);return n?new n(i,r):new Tr(t,i,r)}var X=_t;function qt(t,e){return[503,...t].includes(e?.status||e?.statusCode)}async function jt(t,e){async function r(){return await t({...e,headers:{...e.headers}})}return r().catch(i=>Promise.reject(i))}async function Z(t){let{url:e,httpClient:r,...i}=t;return await jt(async o=>{let{enableRetry:s,retryConfig:u,abortController:c}=i,{retryCodes:h=[],maxDelay:l=1/0,maxRetries:d=3,backoff:p=!0,retryDelay:w=200,retryOnAbort:f=!0}=u||{},E,k,g=0;Ve(h);async function R(){return r(e,{...i,...o,headers:{...i.headers,...o.headers,"Accept-Encoding":"application/json"},...i.body?{data:i.body}:{},withCredentials:o.credentialsMode==="include"})}async function B(){let _=async(j,se)=>{let ae={};try{if(ae=await R(),ae.status>399&&qt(j,ae))return{_response:ae,shouldRetry:!0}}catch(Pe){if(Pe.name.includes("AbortError")&&se)return{_response:Pe,shouldRetry:!0};throw Pe}return{_response:ae,shouldRetry:!1}},q=f||!c||!c.signal,{_response:xe,shouldRetry:G}=await _(h,q);for(;s&&G&&g<d;){g++;let j=await _(h,q);xe=j._response,G=j.shouldRetry;let se=Re({retryCount:g,retryDelay:w,maxRetries:d,backoff:p,maxDelay:l});await Be(se)}return xe}let y=await B();try{y.text&&typeof y.text=="function"?(E=await y.text()||y[Object.getOwnPropertySymbols(y)[1]],k=JSON.parse(E)):k=y.data||y}catch{k=E}return{data:k,retryCount:g,statusCode:y.status||y.statusCode||k.statusCode,headers:y.headers}},{})}function Te(){return("1000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(parseInt(t)^Math.floor(Math.random()*256)&15>>parseInt(t)/4).toString(16))}function Lt(t){return Qe.reduce((e,r)=>{let i=t[r]?t[r]:typeof t.get=="function"?t.get(r):null;return i&&(e[r]=i),e},{})}function I(t){if(!t)return null;if(t.raw&&typeof t.raw=="function")return t.raw();if(!t.forEach)return Lt(t);let e={};return t.forEach((r,i)=>e[i]=r)}function he(t){return t!=null&&t.constructor!=null&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function $(t){let e=Object.assign({},t);return e?.headers&&(e.headers.Authorization&&(e.headers.Authorization="Bearer ********"),e.headers.authorization&&(e.headers.authorization="Bearer ********")),e}function M(t,e){return{...e,headers:{...e.headers,Authorization:`Bearer ${t}`}}}var Ye=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];function Re({retryCount:t,retryDelay:e,backoff:r,maxDelay:i}){return r&&t!==0?Math.min(Math.round((Math.random()+1)*e*2**t),i):e}Math.min(Math.round((Math.random()+1)*200*2**10),1/0);function Be(t){return new Promise(e=>{setTimeout(e,t)})}function F(t){if(!t?.credentials?.clientId||!t.projectKey||!t.host)throw new Error("Missing required options.");return{clientId:t.credentials.clientId,host:t.host,projectKey:t.projectKey}}function be(t){return Date.now()+t*1e3-5*60*1e3}function U(t){let e=t;return{get:r=>e,set:(r,i)=>{e=r}}}function br(t){return typeof t<"u"&&t!==null}function Ht(t){return br(t)?typeof t=="string"?t:Object.fromEntries(Object.entries(t).filter(([e,r])=>![null,void 0,""].includes(r))):""}function Dt(t){let e={},r=new URLSearchParams(t);for(let i of r.keys())r.getAll(i).length>1?e[i]=r.getAll(i):e[i]=r.get(i);return e}function $t(t){if(t=Ht(t),!t)return"";let e=new URLSearchParams(t);for(let[r,i]of Object.entries(t))Array.isArray(i)&&(e.delete(r),i.filter(br).forEach(n=>e.append(r,n)));return e.toString()}function We(t,e=Dt){return e(t)}function Ie(t,e=$t){return e(t)}var Kt=()=>typeof window<"u"&&window.document&&window.document.nodeType===9;function zt(){if(Kt())return window.navigator.userAgent;let t=process?.version.slice(1)||"unknow",e=`(${process.platform}; ${process.arch})`;return`node.js/${t} ${e}`}function Fe(t){let e=null,r=null;if(!t)throw new Error("Missing required option `name`");let i=t.version?`${t.name}/${t.version}`:t.name;t.libraryName&&!t.libraryVersion?e=t.libraryName:t.libraryName&&t.libraryVersion&&(e=`${t.libraryName}/${t.libraryVersion}`),t.contactUrl&&!t.contactEmail?r=`(+${t.contactUrl})`:!t.contactUrl&&t.contactEmail?r=`(+${t.contactEmail})`:t.contactUrl&&t.contactEmail&&(r=`(+${t.contactUrl}; +${t.contactEmail})`);let n=zt(),o=t.customAgent||"";return[i,n,e,r,o].filter(Boolean).join(" ")}function ve(t){if(!t.host)throw new Error("Request `host` or `url` is missing or invalid, please pass in a valid host e.g `host: http://a-valid-host-url`");if(!t.httpClient&&typeof t.httpClient!="function")throw new Error("An `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.")}function Ve(t){if(!Array.isArray(t))throw new Error("`retryCodes` option must be an array of retry status (error) codes and/or messages.")}function Xe(t){if(!t)throw new Error("Missing required options");if(t.middlewares&&!Array.isArray(t.middlewares))throw new Error("Middlewares should be an array");if(!t.middlewares||!Array.isArray(t.middlewares)||!t.middlewares.length)throw new Error("You need to provide at least one middleware")}function Ue(t,e,r={allowedMethods:Ye}){if(!e)throw new Error(`The "${t}" function requires a "Request" object as an argument. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(typeof e.uri!="string")throw new Error(`The "${t}" Request object requires a valid uri. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`);if(!r.allowedMethods.includes(e.method))throw new Error(`The "${t}" Request object requires a valid method. See https://commercetools.github.io/nodejs/sdk/Glossary.html#clientrequest`)}function Ze(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.projectKey)throw new Error("Missing required option (projectKey)");if(!t.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:r}=t.credentials||{};if(!(e&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let i=t.scopes?t.scopes.join(" "):void 0,n=btoa(`${e}:${r}`),o=t.oauthUri||"/oauth/token",s=t.host.replace(/\/$/,"")+o,u=`grant_type=client_credentials${i?`&scope=${i}`:""}`;return{url:s,body:u,basicAuth:n}}function Ir(t){if(!t)throw new Error("Missing required options");if(!t.projectKey)throw new Error("Missing required option (projectKey)");let e=t.projectKey;t.oauthUri=t.oauthUri||`/oauth/${e}/anonymous/token`;let r=Ze(t);return t.credentials.anonymousId&&(r.body+=`&anonymous_id=${t.credentials.anonymousId}`),{...r}}function ke(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.projectKey)throw new Error("Missing required option (projectKey)");if(!t.credentials)throw new Error("Missing required option (credentials)");if(!t.refreshToken)throw new Error("Missing required option (refreshToken)");let{clientId:e,clientSecret:r}=t.credentials;if(!(e&&r))throw new Error("Missing required credentials (clientId, clientSecret)");let i=btoa(`${e}:${r}`),n=t.oauthUri||"/oauth/token",o=t.host.replace(/\/$/,"")+n,s=`grant_type=refresh_token&refresh_token=${encodeURIComponent(t.refreshToken)}`;return{basicAuth:i,url:o,body:s}}function Fr(t){if(!t)throw new Error("Missing required options");if(!t.host)throw new Error("Missing required option (host)");if(!t.projectKey)throw new Error("Missing required option (projectKey)");if(!t.credentials)throw new Error("Missing required option (credentials)");let{clientId:e,clientSecret:r,user:i}=t.credentials,n=t.projectKey;if(!(e&&r&&i))throw new Error("Missing required credentials (clientId, clientSecret, user)");let{username:o,password:s}=i;if(!(o&&s))throw new Error("Missing required user credentials (username, password)");let u=(t.scopes||[]).join(" "),c=u?`&scope=${u}`:"",h=btoa(`${e}:${r}`),l=t.oauthUri||`/oauth/${n}/customers/token`,d=t.host.replace(/\/$/,"")+l,p=`grant_type=password&username=${encodeURIComponent(o)}&password=${encodeURIComponent(s)}${c}`;return{basicAuth:h,url:d,body:p}}async function N(t){let{httpClient:e,tokenCache:r,userOption:i,tokenCacheObject:n}=t,o=t.url,s=t.body,u=t.basicAuth;if(!e||typeof e!="function")throw new Error("an `httpClient` is not available, please pass in a `fetch` or `axios` instance as an option or have them globally available.");if(n&&n.refreshToken&&(!n.token||n.token&&Date.now()>n.expirationTime)){if(!i)throw new Error("Missing required options.");let h={...ke({...i,refreshToken:n.refreshToken})};o=h.url,s=h.body,u=h.basicAuth}let c;try{if(c=await Z({url:o,method:"POST",headers:{Authorization:`Basic ${u}`,"Content-Type":"application/x-www-form-urlencoded","Content-Length":v(s)},httpClient:e,body:s}),c.statusCode>=200&&c.statusCode<300){let{access_token:h,expires_in:l,refresh_token:d}=c?.data,p=be(l);return r.set({token:h,expirationTime:p,refreshToken:d}),Promise.resolve(!0)}throw X({code:c.data.error,statusCode:c.data.statusCode,message:c.data.message,error:c.data.errors})}catch(h){throw h}}function ee(t){let e=t.tokenCache||U({token:"",expirationTime:-1}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,tokenCacheKey:n,httpClient:t.httpClient||Ur.default,...Ir(t),userOption:t,next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}var kr=le(ce());function re(t){let e=t.tokenCache||U({token:"",expirationTime:-1}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,tokenCacheKey:n,tokenCacheObject:r,httpClient:t.httpClient||kr.default,...Ze(t),next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}function te(t,e){return r=>async i=>{if(typeof t!="string")throw new Error("authorization must be a string");let n=e?.force===void 0?!0:e.force;if(!t||i.headers&&(i.headers.Authorization||i.headers.authorization)&&n===!1)return r(i);let o={...i,headers:{...i.headers,Authorization:t}};return r(o)}}var Or=le(ce());function ie(t){let e=t.tokenCache||U({token:"",expirationTime:-1}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,tokenCacheKey:n,httpClient:t.httpClient||Or.default,...Fr(t),userOption:t,next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}function ne(t){let e=t.tokenCache||U({token:"",tokenCacheKey:null}),r,i=null,n=F(t);return o=>async s=>{if(s.headers&&(s.headers.Authorization||s.headers.authorization))return o(s);if(r=e.get(n),r&&r.token&&Date.now()<r.expirationTime)return o(M(r.token,s));let u={request:s,tokenCache:e,httpClient:t.httpClient||fetch,...ke(t),next:o};return i?await i:(i=N(u),await i,i=null),r=e.get(n),o(M(r.token,s))}}function fe(t){return e=>async r=>{let i=await e(r);if(i.statusCode==409){let n=i.error.body?.errors?.[0]?.currentVersion;if(n)return t&&typeof t=="function"?r.body=await t(n,r,i):r.body=typeof r.body=="string"?{...JSON.parse(r.body),version:n}:{...r.body,version:n},e(r)}return i}}function pe(t){return e=>r=>{let i={...r,headers:{...r.headers,"X-Correlation-ID":t.generate&&typeof t.generate=="function"?t.generate():Te()}};return e(i)}}function er(t){return e=>async r=>{let i=await e(r);if(i.error){let{error:n}=i;return{...i,statusCode:n.statusCode||0,headers:n.headers||I({}),error:{...n,body:n.data||n}}}return i}}var Nr=le(Pr());async function Qt({url:t,httpClient:e,clientOptions:r}){let i,{timeout:n,request:o,abortController:s,maskSensitiveHeaderData:u,includeRequestInErrorResponse:c,includeResponseHeaders:h}=r;try{n&&(i=setTimeout(()=>{s.abort()},n));let l=await Z({url:t,...r,httpClient:e,method:r.method,...r.body?{body:r.body}:{}});if(h||(l.headers=null),l.statusCode>=200&&l.statusCode<300)return r.method=="HEAD"?{body:null,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)}:{body:l.data,statusCode:l.statusCode,retryCount:l.retryCount,headers:I(l.headers)};let d=X({message:l?.data?.message||l?.message,statusCode:l.statusCode||l?.data?.statusCode,headers:I(l.headers),method:r.method,body:l.data,retryCount:l.retryCount,...c?{originalRequest:u?$(o):o}:{uri:o.uri}});return{body:l.data,code:l.statusCode,statusCode:l.statusCode,headers:I(l.headers),error:d}}catch(l){let d=h?I(l.response?.headers):null,p=l.response?.status||l.response?.data0||0,w=l.response?.data?.message,f=X({statusCode:p,code:p,status:p,message:w||l.message,headers:d,body:l.response?.data||l,error:l.response?.data,...c?{originalRequest:u?$(o):o}:{uri:o.uri}});throw{body:f,error:f}}finally{clearTimeout(i)}}function we(t){ve(t);let{host:e,credentialsMode:r,httpClient:i,timeout:n,enableRetry:o,retryConfig:s,getAbortController:u,includeOriginalRequest:c,includeRequestInErrorResponse:h=!0,includeResponseHeaders:l=!0,maskSensitiveHeaderData:d,httpClientOptions:p}=t;return w=>async f=>{let E;(n||u)&&(E=(u?u():null)||new Nr.default);let k=e.replace(/\/$/,"")+f.uri,g={...f.headers};Object.prototype.hasOwnProperty.call(g,"Content-Type")||Object.prototype.hasOwnProperty.call(g,"content-type")||(g["Content-Type"]="application/json"),g["Content-Type"]===null&&delete g["Content-Type"];let R=A.HEADERS_CONTENT_TYPES.indexOf(g["Content-Type"])>-1&&typeof f.body=="string"||he(f.body)?f.body:JSON.stringify(f.body||void 0);R&&(typeof R=="string"||he(R))&&(g["Content-Length"]=v(R));let B={enableRetry:o,retryConfig:s,request:f,method:f.method,headers:g,includeRequestInErrorResponse:h,maskSensitiveHeaderData:d,includeResponseHeaders:l,...p};r&&(B.credentialsMode=r),E&&(B.signal=E.signal),n&&(B.timeout=n,B.abortController=E),R&&(B.body=R);let y=await Qt({url:k,clientOptions:B,httpClient:i}),_={...f,includeOriginalRequest:c,maskSensitiveHeaderData:d,response:y};return w(_)}}function me(t){return e=>async r=>{let i=await e(r),n=Object.assign({},i),{loggerFn:o=console.log}=t||{};return o&&typeof o=="function"&&o(i),n}}function ye({concurrency:t=20}){let e=0,r=[],i=()=>0>=t?Promise.resolve():new Promise(o=>{let s=()=>{e<t?(e++,o()):r.push(s)};s()}),n=()=>{if(e--,r.length>0){let o=r.shift();o&&o()}};return o=>s=>i().then(()=>{let u={...s,resolve(c){s.resolve(c),n()},reject(c){s.reject(c),n()}};return o(u).finally(()=>{n()})})}var _r={name:"@commercetools/ts-client",version:"2.1.1",engines:{node:">=14"},description:"commercetools Composable Commerce TypeScript SDK client.",keywords:["commercetools","composable commerce","sdk","typescript","client","middleware","http","oauth","auth"],homepage:"https://github.com/commercetools/commercetools-sdk-typescript",license:"MIT",directories:{lib:"lib",test:"test"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/commercetools/commercetools-sdk-typescript.git"},bugs:{url:"https://github.com/commercetools/commercetools-sdk-typescript/issues"},dependencies:{"abort-controller":"3.0.0",buffer:"^6.0.3","node-fetch":"^2.6.1"},files:["dist","CHANGELOG.md"],author:"Chukwuemeka Ajima <meeky.ae@gmail.com>",main:"dist/commercetools-ts-client.cjs.js",module:"dist/commercetools-ts-client.esm.js",browser:{"./dist/commercetools-ts-client.cjs.js":"./dist/commercetools-ts-client.browser.cjs.js","./dist/commercetools-ts-client.esm.js":"./dist/commercetools-ts-client.browser.esm.js"},devDependencies:{"common-tags":"1.8.2",dotenv:"16.4.5",jest:"29.7.0",nock:"12.0.3","organize-imports-cli":"0.10.0"},scripts:{organize_imports:"find src -type f -name '*.ts' | xargs organize-imports-cli",postbuild:"yarn organize_imports",post_process_generate:"yarn organize_imports",docs:"typedoc --out docs"}};function ge(t){return e=>async r=>{let i=Fe({...t,name:`${t.name?t.name+"/":""}commercetools-sdk-javascript-v3/${_r.version}`}),n={...r,headers:{...r.headers,"User-Agent":i}};return e(n)}}function Vt({middlewares:t}){return t.length===1?t[0]:t.slice().reduce((r,i)=>(...n)=>r(i.apply(null,n)))}var qr;function Se(t,e,r){if(Ue("process",t,{allowedMethods:["GET"]}),typeof e!="function")throw new Error('The "process" function accepts a "Function" as a second argument that returns a Promise. See https://commercetools.github.io/nodejs/sdk/api/sdkClient.html#processrequest-processfn-options');let i={total:Number.POSITIVE_INFINITY,accumulate:!0,...r};return new Promise((n,o)=>{let s,u="";if(t&&t.uri){let[w,f]=t.uri.split("?");s=w,u=f}let h={limit:20,...{...We(u)}},l=i.total,d=!1,p=async(w,f=[])=>{let E=h.limit<l?h.limit:l,k=Ie({...h,limit:E}),g={sort:"id asc",withTotal:!1,...w?{where:`id > "${w}"`}:{}},R=Ie(g),B={...t,uri:`${s}?${R}&${k}`};try{let y=await K(qr).execute(B),{results:_,count:q}=y?.body||{};if(!q&&d)return n(f||[]);let xe=await Promise.resolve(e(y)),G;if(d=!0,i.accumulate&&(G=f.concat(xe||[])),l-=q,q<h.limit||!l)return n(G||[]);let j=_[q-1],se=j&&j.id;p(se,G)}catch(y){o(y)}};p()})}function K(t){qr=t,Xe(t);let e=!1,r={async resolve(n){let{response:o,includeOriginalRequest:s,maskSensitiveHeaderData:u,...c}=n,{retryCount:h,...l}=o;return e=u,{body:null,error:null,reject:n.reject,resolve:n.resolve,...l,...s?{originalRequest:c}:{},...o?.retryCount?{retryCount:o.retryCount}:{}}}},i=Vt(t)(r.resolve);return{process:Se,execute(n){return Ue("exec",n),new Promise(async(o,s)=>{try{let u=await i({reject:s,resolve:o,...n});if(u.error)return s(u.error);u.originalRequest&&e&&(u.originalRequest=$(u.originalRequest)),o(u)}catch(u){s(u)}})}}}var{createAuthMiddlewareForPasswordFlow:Yt,createAuthMiddlewareForAnonymousSessionFlow:Wt,createAuthMiddlewareForClientCredentialsFlow:vt,createAuthMiddlewareForRefreshTokenFlow:Xt,createAuthMiddlewareForExistingTokenFlow:Zt,createCorrelationIdMiddleware:ei,createHttpMiddleware:ri,createLoggerMiddleware:ti,createQueueMiddleware:ii,createUserAgentMiddleware:jr,createConcurrentModificationMiddleware:ni}=rr,oe=class{projectKey;authMiddleware;httpMiddleware;userAgentMiddleware;correlationIdMiddleware;loggerMiddleware;queueMiddleware;concurrentMiddleware;telemetryMiddleware;beforeMiddleware;afterMiddleware;middlewares=[];constructor(){this.userAgentMiddleware=jr({})}withProjectKey(e){return this.projectKey=e,this}defaultClient(e,r,i,n,o,s){return this.withClientCredentialsFlow({host:i,projectKey:n||this.projectKey,credentials:r,scopes:o}).withHttpMiddleware({host:e,httpClient:s||z.default})}withAuthMiddleware(e){return this.authMiddleware=e,this}withMiddleware(e){return this.middlewares.push(e),this}withClientCredentialsFlow(e){return this.withAuthMiddleware(vt({host:e.host||A.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},oauthUri:e.oauthUri||null,scopes:e.scopes,httpClient:e.httpClient||z.default,...e}))}withPasswordFlow(e){return this.withAuthMiddleware(Yt({host:e.host||A.CTP_AUTH_URL,projectKey:e.projectKey||this.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,user:{username:e.credentials.user.username||null,password:e.credentials.user.password||null}},httpClient:e.httpClient||z.default,...e}))}withAnonymousSessionFlow(e){return this.withAuthMiddleware(Wt({host:e.host||A.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null,anonymousId:e.credentials.anonymousId||null},httpClient:e.httpClient||z.default,...e}))}withRefreshTokenFlow(e){return this.withAuthMiddleware(Xt({host:e.host||A.CTP_AUTH_URL,projectKey:this.projectKey||e.projectKey,credentials:{clientId:e.credentials.clientId||null,clientSecret:e.credentials.clientSecret||null},httpClient:e.httpClient||z.default,refreshToken:e.refreshToken||null,...e}))}withExistingTokenFlow(e,r){return this.withAuthMiddleware(Zt(e,{force:r.force||!0,...r}))}withHttpMiddleware(e){return this.httpMiddleware=ri({host:e.host||A.CTP_API_URL,httpClient:e.httpClient||z.default,...e}),this}withUserAgentMiddleware(e){return this.userAgentMiddleware=jr(e),this}withQueueMiddleware(e){return this.queueMiddleware=ii({concurrency:e.concurrency||A.CONCURRENCT_REQUEST,...e}),this}withLoggerMiddleware(e){return this.loggerMiddleware=ti(e),this}withCorrelationIdMiddleware(e){return this.correlationIdMiddleware=ei({generate:e?.generate,...e}),this}withConcurrentModificationMiddleware(e){return this.concurrentMiddleware=ni(e?.concurrentModificationHandlerFn),this}withTelemetryMiddleware(e){let{createTelemetryMiddleware:r,...i}=e;return this.withUserAgentMiddleware({customAgent:i?.userAgent||"typescript-sdk-apm-middleware"}),this.telemetryMiddleware=r(i),this}withBeforeExecutionMiddleware(e){let{middleware:r,...i}=e||{};return this.beforeMiddleware=e.middleware(i),this}withAfterExecutionMiddleware(e){let{middleware:r,...i}=e||{};return this.afterMiddleware=e.middleware(i),this}build(){let e=this.middlewares.slice();return this.telemetryMiddleware&&e.push(this.telemetryMiddleware),this.correlationIdMiddleware&&e.push(this.correlationIdMiddleware),this.userAgentMiddleware&&e.push(this.userAgentMiddleware),this.authMiddleware&&e.push(this.authMiddleware),this.beforeMiddleware&&e.push(this.beforeMiddleware),this.queueMiddleware&&e.push(this.queueMiddleware),this.loggerMiddleware&&e.push(this.loggerMiddleware),this.concurrentMiddleware&&e.push(this.concurrentMiddleware),this.httpMiddleware&&e.push(this.httpMiddleware),this.afterMiddleware&&e.push(this.afterMiddleware),K({middlewares:e})}};return zr(oi);})();
2
+ /*! Bundled license information:
3
+
4
+ ieee754/index.js:
5
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
6
+
7
+ buffer/index.js:
8
+ (*!
9
+ * The buffer module from node.js, for the browser.
10
+ *
11
+ * @author Feross Aboukhadijeh <https://feross.org>
12
+ * @license MIT
13
+ *)
14
+ */
@@ -1 +1 @@
1
- {"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,CA4DZ"}
1
+ {"version":3,"file":"password-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["password-flow.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAIV,6BAA6B,EAE9B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,OAAO,EAAE,6BAA6B,GACrC,UAAU,CA4DZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-token-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["refresh-token-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAIV,4BAA4B,EAE7B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,uCAAuC,CAC7D,OAAO,EAAE,4BAA4B,GACpC,UAAU,CA0DZ"}
1
+ {"version":3,"file":"refresh-token-flow.d.ts","sourceRoot":"../../../../../src/middleware/auth-middleware","sources":["refresh-token-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAIV,4BAA4B,EAE7B,6BAAyB;AAK1B,MAAM,CAAC,OAAO,UAAU,uCAAuC,CAC7D,OAAO,EAAE,4BAA4B,GACpC,UAAU,CA0DZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-queue-middleware.d.ts","sourceRoot":"../../../../src/middleware","sources":["create-queue-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAGV,sBAAsB,EACvB,0BAAsB;AAEvB,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,WAAgB,GACjB,EAAE,sBAAsB,GAAG,UAAU,CAkDrC"}
1
+ {"version":3,"file":"create-queue-middleware.d.ts","sourceRoot":"../../../../src/middleware","sources":["create-queue-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGV,sBAAsB,EACvB,0BAAsB;AAEvB,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,WAAgB,GACjB,EAAE,sBAAsB,GAAG,UAAU,CAkDrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/ts-client",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "engines": {
5
5
  "node": ">=14"
6
6
  },
@@ -34,6 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "abort-controller": "3.0.0",
37
+ "buffer": "^6.0.3",
37
38
  "node-fetch": "^2.6.1"
38
39
  },
39
40
  "files": ["dist", "CHANGELOG.md"],