@zerohash-sdk/crypto-sell-js 1.16.11 → 1.16.12
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/index.js +2 -2
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,10 +266,10 @@ var e = {
|
|
|
266
266
|
};
|
|
267
267
|
return i && (s.sandbox = o(p.cert), s.production = o(p.prod)), r && (s["eu-cert"] = o(p["eu-cert"]), s["eu-prod"] = o(p["eu-prod"])), s;
|
|
268
268
|
};
|
|
269
|
-
({
|
|
269
|
+
[...Object.entries(p).filter(([e]) => e !== "local").map(([, e]) => e)], {
|
|
270
270
|
LOADED: "travel_rule_loaded",
|
|
271
271
|
COMPLETED: "travel_rule_completed"
|
|
272
|
-
}
|
|
272
|
+
}.LOADED;
|
|
273
273
|
//#endregion
|
|
274
274
|
//#region ../../../common/callbacks/dist/shared/models.js
|
|
275
275
|
var g;
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.CryptoSell={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=`JWT token is required and must be a string.`,n={dev:`https://grafana-faro-collector.dev.0hash.com/collect`,cert:`https://grafana-faro-collector.cert.zerohash.com/collect`,prod:`https://grafana-faro-collector.zerohash.com/collect`,"eu-cert":`https://grafana-faro-collector.cert.zerohash.eu/collect`,"eu-prod":`https://grafana-faro-collector.zerohash.eu/collect`,sandbox:`https://grafana-faro-collector.cert.zerohash.com/collect`,production:`https://grafana-faro-collector.zerohash.com/collect`},r=e=>{if(!e||typeof e!=`string`)return null;let t=e.split(`.`);if(t.length<2)return null;try{let e=t[1].replace(/-/g,`+`).replace(/_/g,`/`),n=e+`===`.slice(0,(4-e.length%4)%4),r=typeof atob<`u`?atob(n):Buffer.from(n,`base64`).toString(`utf-8`),i=JSON.parse(r)?.payload?.region;if(typeof i!=`string`)return null;let a=i.toLowerCase();return a===`us`||a===`eu`?a:null}catch{return null}},i=(e,t)=>r(t)===`eu`?e===`cert`?`eu-cert`:e===`prod`?`eu-prod`:e:e,a=e=>{if(!e||typeof e!=`string`)return{};let t=e.split(`.`);if(t.length<2)return{};try{let e=t[1].replace(/-/g,`+`).replace(/_/g,`/`),n=e+`===`.slice(0,(4-e.length%4)%4),r=typeof atob<`u`?atob(n):Buffer.from(n,`base64`).toString(`utf-8`),i=JSON.parse(r),a=i?.payload??{},o=e=>typeof e==`string`&&e.length>0?e:void 0;return{participantCode:o(a.participant_code),platformName:o(a.platform_name),platformCode:o(i.platform_code),region:o(a.region)}}catch{return{}}},o=(e,t,n)=>e[i(t,n)]??e[t]??e.prod,s=(e,t,n)=>e[i(t,n)]??e[t],c=()=>void 0,l=()=>{let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)},u=(e,t)=>{let n=l(),r=globalThis.__ZH_WEB_SDK_VERSION__,i={};return e.claims.participantCode&&(i.participant_code=e.claims.participantCode),e.claims.platformName&&(i.platform_name=e.claims.platformName),e.claims.platformCode&&(i.platform_code=e.claims.platformCode),e.claims.region&&(i.region=e.claims.region),r&&(i.zh_web_sdk_version=r),{sessionId:n,payload:{meta:{app:{name:e.appName,version:t??`unknown`,environment:e.env},session:{id:n,attributes:i},browser:typeof navigator<`u`?{userAgent:navigator.userAgent}:void 0,page:typeof window<`u`?{url:window.location.origin}:void 0},logs:[{message:`Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,level:`error`,timestamp:new Date().toISOString(),context:{web_component:e.webComponentTag,script_url:e.scriptUrl,reason:e.reason,tried_fallback:String(e.triedFallback),elapsed_ms:String(e.elapsedMs)}}]}}},d=(e,t,n)=>{if(!e||typeof fetch>`u`)return;let{sessionId:r,payload:i}=u(t,n);try{fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,"x-faro-session-id":r},body:JSON.stringify(i),keepalive:!0}).catch(()=>void 0)}catch{}},f=e=>{let{webComponentTag:t,appName:n,appVersion:r,scriptUrls:i,fallbackScriptUrls:l,collectorUrls:u,env:f,jwt:p,timeoutMs:m=15e3,onLoad:h,onError:g}=e;if(typeof document>`u`)return c;let _=`${t}-script-${f}`;if(customElements.get(t)||document.getElementById(_))return c;let v=a(p),y=e.report??(e=>d(u&&s(u,f,p),e,r)),b=!1,x=0,S,C=()=>{S!==void 0&&clearTimeout(S)},w=(e,r,i)=>{if(b)return;let a=Math.round(performance.now()-x),s={webComponentTag:t,appName:n,env:f,scriptUrl:r,reason:e,triedFallback:i,elapsedMs:a,claims:v};y(s);let c=i?void 0:o(l??{},f,p);if(c&&c!==r){T(c,!0);return}b=!0,C(),document.getElementById(_)?.remove(),g?.(s)},T=(e,n)=>{C(),x=performance.now();let r=document.createElement(`script`);r.id=_,r.src=e,r.type=`module`,r.async=!0,r.onload=()=>{setTimeout(()=>{b||(customElements.get(t)?(b=!0,C(),h?.()):w(`not-defined`,e,n))},0)},r.onerror=()=>w(`network`,e,n),S=setTimeout(()=>w(`timeout`,e,n),m),document.getElementById(_)?.remove(),document.head.appendChild(r)},E=o(i,f,p);return E?(T(E,!1),()=>{b=!0,C()}):c},p=1e4,m=class{config;state;scriptLoadingPromise;constructor(e){if(!e.jwt||typeof e.jwt!=`string`)throw Error(t);this.config={...e,env:e.env||`production`,theme:e.theme},this.state={initialized:!1,scriptLoaded:!1,container:null,element:null}}async render(e){if(!e||!(e instanceof HTMLElement))throw Error(this.errorMessages.INVALID_CONTAINER);if(this.state.initialized)throw Error(this.errorMessages.ALREADY_RENDERED);try{await this.ensureScriptLoaded();let t=this.createWebComponent();e.innerHTML=``,e.appendChild(t),this.state.container=e,this.state.element=t,this.state.initialized=!0}catch(e){throw console.error(`Failed to render widget:`,e),e}}updateConfig(e){if(!this.state.initialized||!this.state.element)throw Error(this.errorMessages.NOT_RENDERED);let t=this.state.element;Object.entries(e).forEach(([e,n])=>{n&&(this.config[e]=n,t[e]=n)})}destroy(){this.state.initialized&&(this.state.element&&this.state.element.parentNode&&this.state.element.parentNode.removeChild(this.state.element),this.state.container&&(this.state.container.innerHTML=``),this.state.container=null,this.state.element=null,this.state.initialized=!1)}isRendered(){return this.state.initialized}getConfig(){return{...this.config}}getEnvironment(){return this.config.env||`production`}getScriptId(){return`${this.webComponentTag}-script-${this.getEnvironment()}`}isScriptLoaded(){return!!document.getElementById(this.getScriptId())}getWebComponent(){return customElements.get(this.webComponentTag)}getEffectiveScriptUrls(){return this.scriptUrls}async loadScript(){if(!(this.getWebComponent()||this.isScriptLoaded())){if(this.scriptLoadingPromise)return this.scriptLoadingPromise;this.scriptLoadingPromise=new Promise((e,t)=>{f({webComponentTag:this.webComponentTag,appName:this.webComponentTag,scriptUrls:this.getEffectiveScriptUrls(),collectorUrls:n,env:this.getEnvironment(),jwt:this.config.jwt,onLoad:e,onError:e=>{t(Error(e.reason===`not-defined`?this.errorMessages.WEB_COMPONENT_NOT_DEFINED:`${this.errorMessages.SCRIPT_LOAD_FAILED} (${this.getEnvironment()})`))}})});try{await this.scriptLoadingPromise}catch(e){throw this.scriptLoadingPromise=void 0,e}return this.scriptLoadingPromise}}async waitForWebComponent(){if(!this.getWebComponent())return new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout waiting for ${this.webComponentTag} to be defined`))},p);customElements.whenDefined(this.webComponentTag).then(()=>{clearTimeout(n),e()}).catch(e=>{clearTimeout(n),t(e)})})}async ensureScriptLoaded(){if(!this.state.scriptLoaded)try{await this.loadScript(),await this.waitForWebComponent(),this.state.scriptLoaded=!0}catch(e){throw console.error(`Failed to load Connect script:`,e),e}}createWebComponent(){let e=document.createElement(this.webComponentTag);return Object.entries(this.config).forEach(([t,n])=>{n&&(e[t]=n)}),e}},h={local:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_ASSETS_SERVICE_URL:`http://localhost:5173/assets`,VITE_CONNECT_API_BASE_URL:`/api/v1`,VITE_CONNECT_ENV:`local`,VITE_CONNECT_SDK_API_BASE_URL:`/sdk/v1`,VITE_DYNAMIC_ENVIRONMENT_ID:`38ce0330-c85e-414a-80b4-6129c548018f`,VITE_FARO_COLLECTOR_URL:`https://grafana-faro-collector.dev.0hash.com/collect`,VITE_FEATURE_SERVER_PROXY_URL:`https://ff-edge.dev.0hash.com/api/frontend`,VITE_INTERNAL_BUILD:`false`,VITE_ONBOARDING_API_BASE_URL:`/onboarding`,VITE_POST_MESSAGE_COMMUNICATION_PLATFORMS:`UW6VWU`,VITE_REDIRECT_HANDLER_URL:`http://localhost:4202/redirect-handler/index.html`,VITE_SCRAPER_EXTENSION_ID_CHROMIUM:`kofibejdfkmnbobmbogndbiimkflcllf`,VITE_TRADE_API_BASE_URL:`/trade`,VITE_UNLEASH_APIKEY:`zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34`}.VITE_LOCAL_CDN_HOST||`http://localhost:5173`,dev:`https://sdk-cdn.dev.0hash.com`,cert:`https://sdk-cdn.cert.zerohash.com`,prod:`https://sdk-cdn.zerohash.com`,"eu-cert":`https://sdk-cdn.cert.zerohash.eu`,"eu-prod":`https://sdk-cdn.zerohash.eu`},g=`https://sdk-cdn.gating.0hash.com`,_=(e,t,n={})=>{let{eu:r=!1,legacyAliases:i=!1,local:a=h.local}=n,o=n=>`${n}/${e}/${t}`,s={local:o(a),dev:o(h.dev),gating:o(g),cert:o(h.cert),prod:o(h.prod)};return i&&(s.sandbox=o(h.cert),s.production=o(h.prod)),r&&(s[`eu-cert`]=o(h[`eu-cert`]),s[`eu-prod`]=o(h[`eu-prod`])),s};({LOADED:`travel_rule_loaded`,COMPLETED:`travel_rule_completed`}
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.CryptoSell={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=`JWT token is required and must be a string.`,n={dev:`https://grafana-faro-collector.dev.0hash.com/collect`,cert:`https://grafana-faro-collector.cert.zerohash.com/collect`,prod:`https://grafana-faro-collector.zerohash.com/collect`,"eu-cert":`https://grafana-faro-collector.cert.zerohash.eu/collect`,"eu-prod":`https://grafana-faro-collector.zerohash.eu/collect`,sandbox:`https://grafana-faro-collector.cert.zerohash.com/collect`,production:`https://grafana-faro-collector.zerohash.com/collect`},r=e=>{if(!e||typeof e!=`string`)return null;let t=e.split(`.`);if(t.length<2)return null;try{let e=t[1].replace(/-/g,`+`).replace(/_/g,`/`),n=e+`===`.slice(0,(4-e.length%4)%4),r=typeof atob<`u`?atob(n):Buffer.from(n,`base64`).toString(`utf-8`),i=JSON.parse(r)?.payload?.region;if(typeof i!=`string`)return null;let a=i.toLowerCase();return a===`us`||a===`eu`?a:null}catch{return null}},i=(e,t)=>r(t)===`eu`?e===`cert`?`eu-cert`:e===`prod`?`eu-prod`:e:e,a=e=>{if(!e||typeof e!=`string`)return{};let t=e.split(`.`);if(t.length<2)return{};try{let e=t[1].replace(/-/g,`+`).replace(/_/g,`/`),n=e+`===`.slice(0,(4-e.length%4)%4),r=typeof atob<`u`?atob(n):Buffer.from(n,`base64`).toString(`utf-8`),i=JSON.parse(r),a=i?.payload??{},o=e=>typeof e==`string`&&e.length>0?e:void 0;return{participantCode:o(a.participant_code),platformName:o(a.platform_name),platformCode:o(i.platform_code),region:o(a.region)}}catch{return{}}},o=(e,t,n)=>e[i(t,n)]??e[t]??e.prod,s=(e,t,n)=>e[i(t,n)]??e[t],c=()=>void 0,l=()=>{let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)},u=(e,t)=>{let n=l(),r=globalThis.__ZH_WEB_SDK_VERSION__,i={};return e.claims.participantCode&&(i.participant_code=e.claims.participantCode),e.claims.platformName&&(i.platform_name=e.claims.platformName),e.claims.platformCode&&(i.platform_code=e.claims.platformCode),e.claims.region&&(i.region=e.claims.region),r&&(i.zh_web_sdk_version=r),{sessionId:n,payload:{meta:{app:{name:e.appName,version:t??`unknown`,environment:e.env},session:{id:n,attributes:i},browser:typeof navigator<`u`?{userAgent:navigator.userAgent}:void 0,page:typeof window<`u`?{url:window.location.origin}:void 0},logs:[{message:`Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,level:`error`,timestamp:new Date().toISOString(),context:{web_component:e.webComponentTag,script_url:e.scriptUrl,reason:e.reason,tried_fallback:String(e.triedFallback),elapsed_ms:String(e.elapsedMs)}}]}}},d=(e,t,n)=>{if(!e||typeof fetch>`u`)return;let{sessionId:r,payload:i}=u(t,n);try{fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,"x-faro-session-id":r},body:JSON.stringify(i),keepalive:!0}).catch(()=>void 0)}catch{}},f=e=>{let{webComponentTag:t,appName:n,appVersion:r,scriptUrls:i,fallbackScriptUrls:l,collectorUrls:u,env:f,jwt:p,timeoutMs:m=15e3,onLoad:h,onError:g}=e;if(typeof document>`u`)return c;let _=`${t}-script-${f}`;if(customElements.get(t)||document.getElementById(_))return c;let v=a(p),y=e.report??(e=>d(u&&s(u,f,p),e,r)),b=!1,x=0,S,C=()=>{S!==void 0&&clearTimeout(S)},w=(e,r,i)=>{if(b)return;let a=Math.round(performance.now()-x),s={webComponentTag:t,appName:n,env:f,scriptUrl:r,reason:e,triedFallback:i,elapsedMs:a,claims:v};y(s);let c=i?void 0:o(l??{},f,p);if(c&&c!==r){T(c,!0);return}b=!0,C(),document.getElementById(_)?.remove(),g?.(s)},T=(e,n)=>{C(),x=performance.now();let r=document.createElement(`script`);r.id=_,r.src=e,r.type=`module`,r.async=!0,r.onload=()=>{setTimeout(()=>{b||(customElements.get(t)?(b=!0,C(),h?.()):w(`not-defined`,e,n))},0)},r.onerror=()=>w(`network`,e,n),S=setTimeout(()=>w(`timeout`,e,n),m),document.getElementById(_)?.remove(),document.head.appendChild(r)},E=o(i,f,p);return E?(T(E,!1),()=>{b=!0,C()}):c},p=1e4,m=class{config;state;scriptLoadingPromise;constructor(e){if(!e.jwt||typeof e.jwt!=`string`)throw Error(t);this.config={...e,env:e.env||`production`,theme:e.theme},this.state={initialized:!1,scriptLoaded:!1,container:null,element:null}}async render(e){if(!e||!(e instanceof HTMLElement))throw Error(this.errorMessages.INVALID_CONTAINER);if(this.state.initialized)throw Error(this.errorMessages.ALREADY_RENDERED);try{await this.ensureScriptLoaded();let t=this.createWebComponent();e.innerHTML=``,e.appendChild(t),this.state.container=e,this.state.element=t,this.state.initialized=!0}catch(e){throw console.error(`Failed to render widget:`,e),e}}updateConfig(e){if(!this.state.initialized||!this.state.element)throw Error(this.errorMessages.NOT_RENDERED);let t=this.state.element;Object.entries(e).forEach(([e,n])=>{n&&(this.config[e]=n,t[e]=n)})}destroy(){this.state.initialized&&(this.state.element&&this.state.element.parentNode&&this.state.element.parentNode.removeChild(this.state.element),this.state.container&&(this.state.container.innerHTML=``),this.state.container=null,this.state.element=null,this.state.initialized=!1)}isRendered(){return this.state.initialized}getConfig(){return{...this.config}}getEnvironment(){return this.config.env||`production`}getScriptId(){return`${this.webComponentTag}-script-${this.getEnvironment()}`}isScriptLoaded(){return!!document.getElementById(this.getScriptId())}getWebComponent(){return customElements.get(this.webComponentTag)}getEffectiveScriptUrls(){return this.scriptUrls}async loadScript(){if(!(this.getWebComponent()||this.isScriptLoaded())){if(this.scriptLoadingPromise)return this.scriptLoadingPromise;this.scriptLoadingPromise=new Promise((e,t)=>{f({webComponentTag:this.webComponentTag,appName:this.webComponentTag,scriptUrls:this.getEffectiveScriptUrls(),collectorUrls:n,env:this.getEnvironment(),jwt:this.config.jwt,onLoad:e,onError:e=>{t(Error(e.reason===`not-defined`?this.errorMessages.WEB_COMPONENT_NOT_DEFINED:`${this.errorMessages.SCRIPT_LOAD_FAILED} (${this.getEnvironment()})`))}})});try{await this.scriptLoadingPromise}catch(e){throw this.scriptLoadingPromise=void 0,e}return this.scriptLoadingPromise}}async waitForWebComponent(){if(!this.getWebComponent())return new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout waiting for ${this.webComponentTag} to be defined`))},p);customElements.whenDefined(this.webComponentTag).then(()=>{clearTimeout(n),e()}).catch(e=>{clearTimeout(n),t(e)})})}async ensureScriptLoaded(){if(!this.state.scriptLoaded)try{await this.loadScript(),await this.waitForWebComponent(),this.state.scriptLoaded=!0}catch(e){throw console.error(`Failed to load Connect script:`,e),e}}createWebComponent(){let e=document.createElement(this.webComponentTag);return Object.entries(this.config).forEach(([t,n])=>{n&&(e[t]=n)}),e}},h={local:{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_ASSETS_SERVICE_URL:`http://localhost:5173/assets`,VITE_CONNECT_API_BASE_URL:`/api/v1`,VITE_CONNECT_ENV:`local`,VITE_CONNECT_SDK_API_BASE_URL:`/sdk/v1`,VITE_DYNAMIC_ENVIRONMENT_ID:`38ce0330-c85e-414a-80b4-6129c548018f`,VITE_FARO_COLLECTOR_URL:`https://grafana-faro-collector.dev.0hash.com/collect`,VITE_FEATURE_SERVER_PROXY_URL:`https://ff-edge.dev.0hash.com/api/frontend`,VITE_INTERNAL_BUILD:`false`,VITE_ONBOARDING_API_BASE_URL:`/onboarding`,VITE_POST_MESSAGE_COMMUNICATION_PLATFORMS:`UW6VWU`,VITE_REDIRECT_HANDLER_URL:`http://localhost:4202/redirect-handler/index.html`,VITE_SCRAPER_EXTENSION_ID_CHROMIUM:`kofibejdfkmnbobmbogndbiimkflcllf`,VITE_TRADE_API_BASE_URL:`/trade`,VITE_UNLEASH_APIKEY:`zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34`}.VITE_LOCAL_CDN_HOST||`http://localhost:5173`,dev:`https://sdk-cdn.dev.0hash.com`,cert:`https://sdk-cdn.cert.zerohash.com`,prod:`https://sdk-cdn.zerohash.com`,"eu-cert":`https://sdk-cdn.cert.zerohash.eu`,"eu-prod":`https://sdk-cdn.zerohash.eu`},g=`https://sdk-cdn.gating.0hash.com`,_=(e,t,n={})=>{let{eu:r=!1,legacyAliases:i=!1,local:a=h.local}=n,o=n=>`${n}/${e}/${t}`,s={local:o(a),dev:o(h.dev),gating:o(g),cert:o(h.cert),prod:o(h.prod)};return i&&(s.sandbox=o(h.cert),s.production=o(h.prod)),r&&(s[`eu-cert`]=o(h[`eu-cert`]),s[`eu-prod`]=o(h[`eu-prod`])),s};[...Object.entries(h).filter(([e])=>e!==`local`).map(([,e])=>e)],{LOADED:`travel_rule_loaded`,COMPLETED:`travel_rule_completed`}.LOADED;var v;(function(e){e.NETWORK_ERROR=`network_error`,e.AUTH_ERROR=`auth_error`,e.NOT_FOUND_ERROR=`not_found_error`,e.VALIDATION_ERROR=`validation_error`,e.SERVER_ERROR=`server_error`,e.CLIENT_ERROR=`client_error`,e.UNKNOWN_ERROR=`unknown_error`})(v||={});var y=class extends m{errorMessages={ALREADY_RENDERED:`CryptoSell widget is already rendered. Call destroy() before rendering again.`,NOT_RENDERED:`CryptoSell widget is not rendered. Call render() first.`,INVALID_CONTAINER:`Invalid container element provided.`,SCRIPT_LOAD_FAILED:`Failed to load the Connect CryptoSell script.`,WEB_COMPONENT_NOT_DEFINED:`Web component is not defined. Script may not be loaded.`};scriptUrls=_(`crypto-sell-web`,`index.js`,{legacyAliases:!0,eu:!0});webComponentTag=`zerohash-crypto-sell`;render(e){return super.render(e)}updateConfig(e){return super.updateConfig(e)}getConfig(){return super.getConfig()}isRendered(){return super.isRendered()}destroy(){return super.destroy()}};e.CryptoSell=y,e.default=y,Object.defineProperty(e,"ErrorCode",{enumerable:!0,get:function(){return v}})});
|