@dodoex/wallet-web3 0.0.42 → 0.0.43-10
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/__tslib-f431f494.js +1 -0
- package/dist/alchemy-provider-5870b6fa-031aa534.js +1 -0
- package/dist/alchemy-websocket-provider-213da986-9c604721.js +1 -0
- package/dist/blocto-3a3f2a16.js +1 -0
- package/dist/ccip-1ab01249.js +1 -0
- package/dist/cjs/__tslib-aa1ec370.cjs +1 -0
- package/dist/cjs/alchemy-provider-5870b6fa-d45451fd.cjs +1 -0
- package/dist/cjs/alchemy-websocket-provider-213da986-10a4b9e7.cjs +1 -0
- package/dist/cjs/blocto-f0c00f7e.cjs +1 -0
- package/dist/cjs/ccip-b407d523.cjs +1 -0
- package/dist/cjs/{draggabilly-0280fdd9.cjs → draggabilly-5bb01089.cjs} +1 -1
- package/dist/cjs/ethers-d83228c8.cjs +1 -0
- package/dist/cjs/id-36ab9f54.cjs +1 -0
- package/dist/cjs/index-05d4740c.cjs +1 -0
- package/dist/cjs/index-12d8477a.cjs +1 -0
- package/dist/cjs/{index-9c3d3910.cjs → index-169ca3cc.cjs} +3 -3
- package/dist/cjs/index-264347ec.cjs +1 -0
- package/dist/cjs/{index-eb09e54d.cjs → index-35edc6a0.cjs} +1 -1
- package/dist/cjs/index-4f989ef8.cjs +1 -0
- package/dist/cjs/{index-7c8afb3d.cjs → index-58fb77bb.cjs} +1 -1
- package/dist/cjs/index-8aff1799.cjs +6 -0
- package/dist/cjs/{index-df8e5839.cjs → index-9f2a69d5.cjs} +1 -1
- package/dist/{index-66448990.js → cjs/index-a56bd128.cjs} +2 -2
- package/dist/cjs/index-dac27dde.cjs +1 -0
- package/dist/cjs/index-e628770e.cjs +15 -0
- package/dist/cjs/index-f21b6f0e.cjs +28 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.es-4b60988b.cjs +9 -0
- package/dist/cjs/{interface-32ec049c.cjs → interface-fe98cff9.cjs} +1 -1
- package/dist/cjs/{lib-typedarrays-c773181b.cjs → lib-typedarrays-bdffcb4b.cjs} +1 -1
- package/dist/cjs/{portis-7b794882.cjs → portis-9753b80e.cjs} +1 -1
- package/dist/cjs/provider-4316abb1.cjs +1 -0
- package/dist/cjs/providers/connector/alchemy/index.d.ts +136 -0
- package/dist/cjs/providers/connector/alchemy/provider.d.ts +138 -0
- package/dist/cjs/providers/connector/alchemy/signer.d.ts +23 -0
- package/dist/cjs/providers/connector/index.d.ts +175 -43
- package/dist/cjs/providers/connector/ledgerUSB/index.d.ts +43 -43
- package/dist/cjs/providers/connector/ledgerUSB/provider.d.ts +10 -10
- package/dist/cjs/providers/connector/types.d.ts +4 -0
- package/dist/cjs/providers/connector/uniPass/index.d.ts +43 -43
- package/dist/cjs/providers/connector/uniPass/provider.d.ts +10 -10
- package/dist/cjs/providers/wallets/index.d.ts +2 -1
- package/dist/cjs/providers/wallets/standalone.d.ts +1 -0
- package/dist/cjs/providers/wallets/types.d.ts +1 -0
- package/dist/cjs/rainbow-a0174e93.cjs +1 -0
- package/dist/cjs/{sha224-c7a50394.cjs → sha224-c50de689.cjs} +1 -1
- package/dist/cjs/sha256-42051c0c.cjs +1 -0
- package/dist/cjs/typed-data-0289b33b.cjs +1 -0
- package/dist/cjs/uAuth-f3a2ae4c.cjs +1 -0
- package/dist/cjs/walletConnect-8352f639.cjs +1 -0
- package/dist/cjs/walletLink-9d46eb6c.cjs +3 -0
- package/dist/{draggabilly-186183f4.js → draggabilly-61827e22.js} +1 -1
- package/dist/ethers-f88617c3.js +1 -0
- package/dist/id-25fee670.js +1 -0
- package/dist/index-1f8e0dfc.js +1 -0
- package/dist/{cjs/index-47b72555.cjs → index-253349c9.js} +2 -2
- package/dist/{index-687aa034.js → index-47f5d198.js} +3 -3
- package/dist/index-4a956840.js +15 -0
- package/dist/{index-0ee5ef8d.js → index-65d96278.js} +1 -1
- package/dist/index-81bcae82.js +1 -0
- package/dist/{index-ec768c82.js → index-ccba79a0.js} +1 -1
- package/dist/index-d7a9192b.js +28 -0
- package/dist/index-d95400e0.js +1 -0
- package/dist/index-eaf1a7e1.js +1 -0
- package/dist/{index-e0d3617a.js → index-f08d6a6b.js} +1 -1
- package/dist/index-f7199a2b.js +1 -0
- package/dist/index-f99975f1.js +6 -0
- package/dist/index.es-4b977259.js +9 -0
- package/dist/index.js +1 -1
- package/dist/{interface-cd17b51d.js → interface-1e8a49c4.js} +1 -1
- package/dist/{lib-typedarrays-b049d0e6.js → lib-typedarrays-fa31fa82.js} +1 -1
- package/dist/{portis-eedfe5a8.js → portis-6f76b8e1.js} +1 -1
- package/dist/provider-036433d0.js +1 -0
- package/dist/providers/connector/alchemy/index.d.ts +136 -0
- package/dist/providers/connector/alchemy/provider.d.ts +138 -0
- package/dist/providers/connector/alchemy/signer.d.ts +23 -0
- package/dist/providers/connector/index.d.ts +175 -43
- package/dist/providers/connector/ledgerUSB/index.d.ts +43 -43
- package/dist/providers/connector/ledgerUSB/provider.d.ts +10 -10
- package/dist/providers/connector/types.d.ts +4 -0
- package/dist/providers/connector/uniPass/index.d.ts +43 -43
- package/dist/providers/connector/uniPass/provider.d.ts +10 -10
- package/dist/providers/wallets/index.d.ts +2 -1
- package/dist/providers/wallets/standalone.d.ts +1 -0
- package/dist/providers/wallets/types.d.ts +1 -0
- package/dist/rainbow-3661e3f6.js +1 -0
- package/dist/sha224-8a20d072.js +1 -0
- package/dist/sha256-bfa39a7c.js +1 -0
- package/dist/typed-data-78d999f6.js +1 -0
- package/dist/uAuth-f0f55294.js +1 -0
- package/dist/walletConnect-9def1feb.js +1 -0
- package/dist/walletLink-ec8614d0.js +3 -0
- package/package.json +10 -3
- package/dist/DefaultJsonRpcProvider-470545c2.js +0 -1
- package/dist/__node-resolve_empty-f90bb206.js +0 -1
- package/dist/__tslib-041a522f.js +0 -1
- package/dist/blocto-a613e3ea.js +0 -1
- package/dist/bn-a73d500d.js +0 -1
- package/dist/browser-ponyfill-5a72503b.js +0 -1
- package/dist/cjs/DefaultJsonRpcProvider-1b124fcf.cjs +0 -1
- package/dist/cjs/__node-resolve_empty-c6c4d691.cjs +0 -1
- package/dist/cjs/__tslib-74b92aa0.cjs +0 -1
- package/dist/cjs/blocto-54eeaf0e.cjs +0 -1
- package/dist/cjs/bn-5799deeb.cjs +0 -1
- package/dist/cjs/browser-ponyfill-98c87b2b.cjs +0 -1
- package/dist/cjs/ethers-1f3c68c5.cjs +0 -1
- package/dist/cjs/id-f0a49000.cjs +0 -1
- package/dist/cjs/index-1334a219.cjs +0 -9
- package/dist/cjs/index-26ef8efb.cjs +0 -1
- package/dist/cjs/index-5d2a4d45.cjs +0 -1
- package/dist/cjs/index-876f807b.cjs +0 -15
- package/dist/cjs/index-965f574d.cjs +0 -1
- package/dist/cjs/index-ade355c8.cjs +0 -1
- package/dist/cjs/index-dbfff00c.cjs +0 -1
- package/dist/cjs/index-eeb0556a.cjs +0 -6
- package/dist/cjs/index.es-d8a23b8c.cjs +0 -9
- package/dist/cjs/provider-73c10a83.cjs +0 -1
- package/dist/cjs/rainbow-59104eb0.cjs +0 -1
- package/dist/cjs/sha256-33ca448e.cjs +0 -1
- package/dist/cjs/uAuth-2de77cf5.cjs +0 -1
- package/dist/cjs/walletConnect-23c4ab09.cjs +0 -1
- package/dist/cjs/walletLink-e9532414.cjs +0 -3
- package/dist/ethers-5bf5b00b.js +0 -1
- package/dist/id-f73e9185.js +0 -1
- package/dist/index-4a260eae.js +0 -1
- package/dist/index-4a2d9b19.js +0 -1
- package/dist/index-8cc67274.js +0 -9
- package/dist/index-9ef93cee.js +0 -6
- package/dist/index-b7b5de53.js +0 -1
- package/dist/index-d18b1515.js +0 -1
- package/dist/index-fca1a0c3.js +0 -15
- package/dist/index-fdf822d6.js +0 -1
- package/dist/index.es-d0dcd244.js +0 -9
- package/dist/provider-cc8e4040.js +0 -1
- package/dist/rainbow-bc431cfa.js +0 -1
- package/dist/sha224-882535a5.js +0 -1
- package/dist/sha256-081247ed.js +0 -1
- package/dist/uAuth-acbb6033.js +0 -1
- package/dist/walletConnect-622e5dfc.js +0 -1
- package/dist/walletLink-90f5ac8d.js +0 -3
package/dist/index-fdf822d6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getAddress as t}from"@ethersproject/address";import{arrayify as e,hexZeroPad as r,hexConcat as n,isHexString as o,hexlify as i,isBytesLike as s}from"@ethersproject/bytes";import{k as a}from"./index-8cc67274.js";import{defineReadOnly as c,deepCopy as u,shallowCopy as l}from"@ethersproject/properties";import{L as f,B as h,i as d,t as y,a as m}from"./id-f73e9185.js";const p="hash/5.7.0";function g(t){t=atob(t);const r=[];for(let e=0;e<t.length;e++)r.push(t.charCodeAt(e));return e(r)}function v(t){t=e(t);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)}var E=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};const w=new f(p),b=new Uint8Array(32);b.fill(0);const S=h.from(-1),C=h.from(0),O=h.from(1),R=h.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const A=r(O.toHexString(),32),x=r(C.toHexString(),32),T={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},k=["name","version","chainId","verifyingContract","salt"];function _(t){return function(e){return"string"!=typeof e&&w.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const I={name:_("name"),version:_("version"),chainId:function(t){try{return h.from(t).toString()}catch(t){}return w.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(e){try{return t(e).toLowerCase()}catch(t){}return w.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",e)},salt:function(t){try{const r=e(t);if(32!==r.length)throw new Error("bad length");return i(r)}catch(t){}return w.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function j(o){{const t=o.match(/^(u?)int(\d*)$/);if(t){const e=""===t[1],n=parseInt(t[2]||"256");(n%8!=0||n>256||t[2]&&t[2]!==String(n))&&w.throwArgumentError("invalid numeric width","type",o);const i=R.mask(e?n-1:n),s=e?i.add(O).mul(S):C;return function(t){const e=h.from(t);return(e.lt(s)||e.gt(i))&&w.throwArgumentError(`value out-of-bounds for ${o}`,"value",t),r(e.toTwos(256).toHexString(),32)}}}{const t=o.match(/^bytes(\d+)$/);if(t){const r=parseInt(t[1]);return(0===r||r>32||t[1]!==String(r))&&w.throwArgumentError("invalid bytes width","type",o),function(t){return e(t).length!==r&&w.throwArgumentError(`invalid length for ${o}`,"value",t),function(t){const r=e(t),o=r.length%32;return o?n([r,b.slice(o)]):i(r)}(t)}}}switch(o){case"address":return function(e){return r(t(e),32)};case"bool":return function(t){return t?A:x};case"bytes":return function(t){return a(t)};case"string":return function(t){return d(t)}}return null}function $(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class P{constructor(t){c(this,"types",Object.freeze(u(t))),c(this,"_encoderCache",{}),c(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],n[t]={}}));for(const n in t){const o={};t[n].forEach((i=>{o[i.name]&&w.throwArgumentError(`duplicate variable name ${JSON.stringify(i.name)} in ${JSON.stringify(n)}`,"types",t),o[i.name]=!0;const s=i.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&w.throwArgumentError(`circular type reference to ${JSON.stringify(s)}`,"types",t);j(s)||(r[s]||w.throwArgumentError(`unknown type ${JSON.stringify(s)}`,"types",t),r[s].push(n),e[n][s]=!0)}))}const o=Object.keys(r).filter((t=>0===r[t].length));0===o.length?w.throwArgumentError("missing primary type","types",t):o.length>1&&w.throwArgumentError(`ambiguous primary types or unused types: ${o.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),c(this,"primaryType",o[0]),function o(i,s){s[i]&&w.throwArgumentError(`circular type reference to ${JSON.stringify(i)}`,"types",t),s[i]=!0,Object.keys(e[i]).forEach((t=>{r[t]&&(o(t,s),Object.keys(s).forEach((e=>{n[e][t]=!0})))})),delete s[i]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=$(e,t[e])+r.map((e=>$(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=j(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),o=parseInt(e[3]);return e=>{o>=0&&e.length!==o&&w.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(a)),a(n(i))}}const r=this.types[t];if(r){const e=d(this._types[t]);return t=>{const o=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?a(n):n}));return o.unshift(e),n(o)}}return w.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||w.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return a(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(j(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],o=parseInt(n[3]);return o>=0&&e.length!==o&&w.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const o=this.types[t];return o?o.reduce(((t,{name:n,type:o})=>(t[n]=this._visit(o,e[n],r),t)),{}):w.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new P(t)}static getPrimaryType(t){return P.from(t).primaryType}static hashStruct(t,e,r){return P.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=T[r];n||w.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>k.indexOf(t.name)-k.indexOf(e.name))),P.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return n(["0x1901",P.hashDomain(t),P.from(e).hash(r)])}static hash(t,e,r){return a(P.encode(t,e,r))}static resolveNames(t,e,r,n){return E(this,void 0,void 0,(function*(){t=l(t);const i={};t.verifyingContract&&!o(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const s=P.from(e);s.visit(r,((t,e)=>("address"!==t||o(e,20)||(i[e]="0x"),e)));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=s.visit(r,((t,e)=>"address"===t&&i[e]?i[e]:e)),{domain:t,value:r}}))}static getPayload(t,r,n){P.hashDomain(t);const o={},s=[];k.forEach((e=>{const r=t[e];null!=r&&(o[e]=I[e](r),s.push({name:e,type:T[e]}))}));const a=P.from(r),c=l(r);return c.EIP712Domain?w.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",r):c.EIP712Domain=s,a.encode(n),{types:c,domain:o,primaryType:a.primaryType,message:a.visit(n,((t,r)=>{if(t.match(/^bytes(\d*)/))return i(e(r));if(t.match(/^u?int/))return h.from(r).toString();switch(t){case"address":return r.toLowerCase();case"bool":return!!r;case"string":return"string"!=typeof r&&w.throwArgumentError("invalid string","value",r),r}return w.throwArgumentError("unsupported type","type",t)}))}}}var L=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};function D(t,r){return L(this,void 0,void 0,(function*(){null==r&&(r={});const n={method:r.method||"GET",headers:r.headers||{},body:r.body||void 0};if(!0!==r.skipFetchSetup&&(n.mode="cors",n.cache="no-cache",n.credentials="same-origin",n.redirect="follow",n.referrer="client"),null!=r.fetchOptions){const t=r.fetchOptions;t.mode&&(n.mode=t.mode),t.cache&&(n.cache=t.cache),t.credentials&&(n.credentials=t.credentials),t.redirect&&(n.redirect=t.redirect),t.referrer&&(n.referrer=t.referrer)}const o=yield fetch(t,n),i=yield o.arrayBuffer(),s={};return o.headers.forEach?o.headers.forEach(((t,e)=>{s[e.toLowerCase()]=t})):o.headers.keys().forEach((t=>{s[t.toLowerCase()]=o.headers.get(t)})),{headers:s,statusCode:o.status,statusMessage:o.statusText,body:e(new Uint8Array(i))}}))}var M=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};const N=new f("web/5.7.1");function q(t){return new Promise((e=>{setTimeout(e,t)}))}function J(t,e){if(null==t)return null;if("string"==typeof t)return t;if(s(t)){if(e&&("text"===e.split("/")[0]||"application/json"===e.split(";")[0].trim()))try{return m(t)}catch(t){}return i(t)}return t}function B(t,e,r){const n="object"==typeof t&&null!=t.throttleLimit?t.throttleLimit:12;N.assertArgument(n>0&&n%1==0,"invalid connection throttle limit","connection.throttleLimit",n);const o="object"==typeof t?t.throttleCallback:null,i="object"==typeof t&&"number"==typeof t.throttleSlotInterval?t.throttleSlotInterval:100;N.assertArgument(i>0&&i%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",i);const s="object"==typeof t&&!!t.errorPassThrough,a={};let c=null;const u={method:"GET"};let h=!1,d=12e4;if("string"==typeof t)c=t;else if("object"==typeof t){if(null!=t&&null!=t.url||N.throwArgumentError("missing URL","connection.url",t),c=t.url,"number"==typeof t.timeout&&t.timeout>0&&(d=t.timeout),t.headers)for(const e in t.headers)a[e.toLowerCase()]={key:e,value:String(t.headers[e])},["if-none-match","if-modified-since"].indexOf(e.toLowerCase())>=0&&(h=!0);if(u.allowGzip=!!t.allowGzip,null!=t.user&&null!=t.password){"https:"!==c.substring(0,6)&&!0!==t.allowInsecureAuthentication&&N.throwError("basic authentication requires a secure https url",f.errors.INVALID_ARGUMENT,{argument:"url",url:c,user:t.user,password:"[REDACTED]"});const e=t.user+":"+t.password;a.authorization={key:"Authorization",value:"Basic "+v(y(e))}}null!=t.skipFetchSetup&&(u.skipFetchSetup=!!t.skipFetchSetup),null!=t.fetchOptions&&(u.fetchOptions=l(t.fetchOptions))}const m=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),p=c?c.match(m):null;if(p)try{const t={statusCode:200,statusMessage:"OK",headers:{"content-type":p[1]||"text/plain"},body:p[2]?g(p[3]):(E=p[3],y(E.replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))};let e=t.body;return r&&(e=r(t.body,t)),Promise.resolve(e)}catch(t){N.throwError("processing response error",f.errors.SERVER_ERROR,{body:J(p[1],p[2]),error:t,requestBody:null,requestMethod:"GET",url:c})}var E;e&&(u.method="POST",u.body=e,null==a["content-type"]&&(a["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==a["content-length"]&&(a["content-length"]={key:"Content-Length",value:String(e.length)}));const w={};Object.keys(a).forEach((t=>{const e=a[t];w[e.key]=e.value})),u.headers=w;const b=function(){let t=null;return{promise:new Promise((function(e,r){d&&(t=setTimeout((()=>{null!=t&&(t=null,r(N.makeError("timeout",f.errors.TIMEOUT,{requestBody:J(u.body,w["content-type"]),requestMethod:u.method,timeout:d,url:c})))}),d))})),cancel:function(){null!=t&&(clearTimeout(t),t=null)}}}(),S=function(){return M(this,void 0,void 0,(function*(){for(let t=0;t<n;t++){let e=null;try{if(e=yield D(c,u),t<n)if(301===e.statusCode||302===e.statusCode){const t=e.headers.location||"";if("GET"===u.method&&t.match(/^https:/)){c=e.headers.location;continue}}else if(429===e.statusCode){let r=!0;if(o&&(r=yield o(t,c)),r){let r=0;const n=e.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):i*parseInt(String(Math.random()*Math.pow(2,t))),yield q(r);continue}}}catch(t){e=t.response,null==e&&(b.cancel(),N.throwError("missing response",f.errors.SERVER_ERROR,{requestBody:J(u.body,w["content-type"]),requestMethod:u.method,serverError:t,url:c}))}let a=e.body;if(h&&304===e.statusCode?a=null:!s&&(e.statusCode<200||e.statusCode>=300)&&(b.cancel(),N.throwError("bad response",f.errors.SERVER_ERROR,{status:e.statusCode,headers:e.headers,body:J(a,e.headers?e.headers["content-type"]:null),requestBody:J(u.body,w["content-type"]),requestMethod:u.method,url:c})),r)try{const t=yield r(a,e);return b.cancel(),t}catch(r){if(r.throttleRetry&&t<n){let e=!0;if(o&&(e=yield o(t,c)),e){const e=i*parseInt(String(Math.random()*Math.pow(2,t)));yield q(e);continue}}b.cancel(),N.throwError("processing response error",f.errors.SERVER_ERROR,{body:J(a,e.headers?e.headers["content-type"]:null),error:r,requestBody:J(u.body,w["content-type"]),requestMethod:u.method,url:c})}return b.cancel(),a}return N.throwError("failed response",f.errors.SERVER_ERROR,{requestBody:J(u.body,w["content-type"]),requestMethod:u.method,url:c})}))}();return Promise.race([b.promise,S])}function G(t,e,r){let n=null;if(null!=e){n=y(e);const r="string"==typeof t?{url:t}:l(t);if(r.headers){0!==Object.keys(r.headers).filter((t=>"content-type"===t.toLowerCase())).length||(r.headers=l(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};t=r}return B(t,n,((t,e)=>{let n=null;if(null!=t)try{n=JSON.parse(m(t))}catch(e){N.throwError("invalid JSON",f.errors.SERVER_ERROR,{body:t,error:e})}return r&&(n=r(n,e)),n}))}function V(t,e){return e||(e={}),null==(e=l(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise((function(r,n){let o=null,i=!1;const s=()=>!i&&(i=!0,o&&clearTimeout(o),!0);e.timeout&&(o=setTimeout((()=>{s()&&n(new Error("timeout"))}),e.timeout));const a=e.retryLimit;let c=0;!function o(){return t().then((function(t){if(void 0!==t)s()&&r(t);else if(e.oncePoll)e.oncePoll.once("poll",o);else if(e.onceBlock)e.onceBlock.once("block",o);else if(!i){if(c++,c>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,c)));t<e.floor&&(t=e.floor),t>e.ceiling&&(t=e.ceiling),setTimeout(o,t)}return null}),(function(t){s()&&n(t)}))}()}))}var z=Object.freeze({__proto__:null,_fetchData:B,fetchJson:G,poll:V});export{P as T,B as _,g as d,v as e,G as f,z as l,V as p,p as v};
|