@frak-labs/core-sdk 0.0.8 → 0.0.9
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/cdn/bundle.js +5 -5
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +39 -24
- package/dist/actions.d.ts +39 -24
- package/dist/actions.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +76 -21
- package/dist/index.d.ts +76 -21
- package/dist/index.js +1 -1
- package/dist/interactions.cjs +1 -1
- package/package.json +4 -4
package/cdn/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FrakSDK=t():e.FrakSDK=t()}(globalThis,()=>(()=>{var e={"../../node_modules/async-lz-string/libs/async-lz-string.js":function(e){var t;t=()=>{var e,t;return e={48:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.decompressFromUTF16=t.compressToUTF16=t.decompressFromBase64=t.compressToBase64=void 0;var a=r(304),o=r(134),s=new a.CompressorImpl,c=new o.DecompressorImpl,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u={};t.compressToBase64=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return null===e?[2,""]:[4,s.compress(e,6,function(e){return l.charAt(e)})];case 1:switch((t=r.sent()).length%4){default:case 0:return[2,t];case 1:return[2,t+"==="];case 2:return[2,t+"=="];case 3:return[2,t+"="]}return[2]}})})},t.decompressFromBase64=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return null===e?[2,""]:""===e?[2,null]:[4,c.decompress(e.length,32,function(t){return function(e,t){if(!u[e]){u[e]={};for(var r=0;r<e.length;r++)u[e][e.charAt(r)]=r}return u[e][t]}(l,e.charAt(t))})];case 1:return[2,t.sent()]}})})},t.compressToUTF16=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return null===e?[2,""]:[4,s.compress(e,15,function(e){return String.fromCharCode(e+32)})];case 1:return[2,t.sent()+" "]}})})},t.decompressFromUTF16=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return null===e?[2,""]:""===e?[2,null]:[4,c.decompress(e.length,16384,function(t){return e.charCodeAt(t)-32})];case 1:return[2,t.sent()]}})})}},304:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompressorImpl=void 0;var a=r(658),o=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],s=function(){function e(){}return e.writeValueToData=function(e,t,r,n,i){if(r%4!=0||e.dataPosition+r>n-1)for(var a=0;a<r;a++)e.dataVal=e.dataVal<<1|1&t,e.dataPosition==n-1?(e.dataPosition=0,e.data.push(i(e.dataVal)),e.dataVal=0):e.dataPosition++,t>>=1;else e.dataVal<<=r,e.dataVal|=function(e,t){for(var r=0,n=0;n<t;++n)r<<=4,r|=o[15&e],e>>=4;return r}(t,r/4),e.dataPosition+=r},e.writeWToDataVal=function(t,r,n){t.dictionaryToCreate.has(t.w)?(256>t.w.charCodeAt(0)?(e.writeValueToData(t,0,t.numBits,r,n),e.writeValueToData(t,t.w.charCodeAt(0),8,r,n)):(e.writeValueToData(t,1,t.numBits,r,n),e.writeValueToData(t,t.w.charCodeAt(0),16,r,n)),t.enlargeIn--,0==t.enlargeIn&&(t.enlargeIn=Math.pow(2,t.numBits),t.numBits++),t.dictionaryToCreate.delete(t.w)):e.writeValueToData(t,t.dictionary.get(t.w),t.numBits,r,n),t.enlargeIn--,0==t.enlargeIn&&(t.enlargeIn=Math.pow(2,t.numBits),t.numBits++)},e.loopIteration=function(e,t,r,n,i){var a=e.charAt(t);i.dictionary.has(a)||(i.dictionary.set(a,i.dictSize++),i.dictionaryToCreate.set(a,!0));var o=i.w+a;i.dictionary.has(o)?i.w=o:(this.writeWToDataVal(i,r,n),i.dictionary.set(o,i.dictSize++),i.w=String(a))},e.prototype.compress=function(t,r,o){var s=this;return new Promise(function(c){return n(s,void 0,void 0,function(){var n,s;return i(this,function(i){switch(i.label){case 0:if(null==t)return c(""),[2];n={data:[],dataPosition:0,dataVal:0,dictionary:new Map,dictionaryToCreate:new Map,dictSize:3,enlargeIn:2,numBits:2,w:""},s=0,i.label=1;case 1:return s<t.length?(e.loopIteration(t,s,r,o,n),s%1e4!=0?[3,3]:[4,(0,a.wait)()]):[3,4];case 2:i.sent(),i.label=3;case 3:return s+=1,[3,1];case 4:return""!==n.w&&e.writeWToDataVal(n,r,o),e.writeValueToData(n,2,n.numBits,r,o),n.dataVal<<=r-n.dataPosition,n.data.push(o(n.dataVal)),c(n.data.join("")),[2]}})})})},e}();t.CompressorImpl=s},134:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DecompressorImpl=void 0;var a=r(658),o=function(){function e(){}return e.prototype.decompress=function(e,t,r){var o=this;return new Promise(function(s){return n(o,void 0,void 0,function(){var n,o,c;return i(this,function(i){switch(i.label){case 0:for(n={bits:0,c:null,dataIndex:1,dataPosition:t,dataVal:r(0),dictionary:new Map,dictSize:4,enlargeIn:4,entry:"",maxPower:4,numBits:3,power:1,resb:null,result:[],w:null},o=0;o<3;o+=1)n.dictionary.set(o,o);for(;n.power!=n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;switch(n.bits){case 0:for(n.bits=0,n.maxPower=256,n.power=1;n.power!=n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.c=String.fromCharCode(n.bits);break;case 1:for(n.bits=0,n.maxPower=65536,n.power=1;n.power!==n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0===n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.c=String.fromCharCode(n.bits);break;case 2:return s(""),[2]}n.dictionary[3]=n.c,n.w=n.c,n.result.push(n.c),c=1,i.label=1;case 1:return c%2e4!=0?[3,3]:[4,(0,a.wait)()];case 2:i.sent(),i.label=3;case 3:if(n.dataIndex>e)return s(""),[2];for(n.bits=0,n.maxPower=Math.pow(2,n.numBits),n.power=1;n.power!=n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;switch(n.c=n.bits){case 0:for(n.bits=0,n.maxPower=256,n.power=1;n.power!==n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.dictionary[n.dictSize++]=String.fromCharCode(n.bits),n.c=n.dictSize-1,n.enlargeIn--;break;case 1:for(n.bits=0,n.maxPower=65536,n.power=1;n.power!==n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.dictionary[n.dictSize++]=String.fromCharCode(n.bits),n.c=n.dictSize-1,n.enlargeIn--;break;case 2:return s(n.result.join("")),[2]}if(0==n.enlargeIn&&(n.enlargeIn=Math.pow(2,n.numBits),n.numBits++),n.dictionary[n.c])n.entry=n.dictionary[n.c];else{if(n.c!==n.dictSize)return s(null),[2];n.entry=n.w+n.w.charAt(0)}return n.result.push(n.entry),n.dictionary[n.dictSize++]=n.w+n.entry.charAt(0),n.enlargeIn--,n.w=n.entry,0==n.enlargeIn&&(n.enlargeIn=Math.pow(2,n.numBits),n.numBits++),c++,[3,1];case 4:return[2]}})})})},e}();t.DecompressorImpl=o},658:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.wait=void 0,t.wait=function(){return r(this,void 0,void 0,function(){return n(this,function(e){return[2,new Promise(function(e){setTimeout(e,0)})]})})}}},t={},function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(48)},e.exports=t()},"../../node_modules/js-sha256/src/sha256.js":function(e,t,r){!function(){"use strict";var t="input is invalid type",n="object"==typeof window,i=n?window:{};i.JS_SHA256_NO_WINDOW&&(n=!1);var a=!n&&"object"==typeof self,o=!i.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;o?i=r.g:a&&(i=self);var s=!i.JS_SHA256_NO_COMMON_JS&&e.exports,c="function"==typeof define&&define.amd,l=!i.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),f=[-0x80000000,8388608,32768,128],h=[24,16,8,0],d=[0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2],p=["hex","array","digest","arrayBuffer"],w=[];(i.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),l&&(i.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var y=function(e,t){return function(r){return new v(t,!0).update(r)[e]()}},g=function(e){var t=y("hex",e);o&&(t=m(t,e)),t.create=function(){return new v(e)},t.update=function(e){return t.create().update(e)};for(var r=0;r<p.length;++r){var n=p[r];t[n]=y(n,e)}return t},m=function(e,n){var a,o=r("?81fa"),s=r("?2fd0").Buffer,c=n?"sha224":"sha256";return a=s.from&&!i.JS_SHA256_NO_BUFFER_FROM?s.from:function(e){return new s(e)},function(r){if("string"==typeof r)return o.createHash(c).update(r,"utf8").digest("hex");if(null==r)throw Error(t);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===s?o.createHash(c).update(a(r)).digest("hex"):e(r)}},b=function(e,t){return function(r,n){return new S(r,t,!0).update(n)[e]()}},x=function(e){var t=b("hex",e);t.create=function(t){return new S(t,e)},t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<p.length;++r){var n=p[r];t[n]=b(n,e)}return t};function v(e,t){t?(w[0]=w[16]=w[1]=w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=w[12]=w[13]=w[14]=w[15]=0,this.blocks=w):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=0xc1059ed8,this.h1=0x367cd507,this.h2=0x3070dd17,this.h3=0xf70e5939,this.h4=0xffc00b31,this.h5=0x68581511,this.h6=0x64f98fa7,this.h7=0xbefa4fa4):(this.h0=0x6a09e667,this.h1=0xbb67ae85,this.h2=0x3c6ef372,this.h3=0xa54ff53a,this.h4=0x510e527f,this.h5=0x9b05688c,this.h6=0x1f83d9ab,this.h7=0x5be0cd19),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function S(e,r,n){var i,a=typeof e;if("string"===a){var o,s=[],c=e.length,u=0;for(i=0;i<c;++i)(o=e.charCodeAt(i))<128?s[u++]=o:(o<2048?s[u++]=192|o>>>6:(o<55296||o>=57344?s[u++]=224|o>>>12:(o=65536+((1023&o)<<10|1023&e.charCodeAt(++i)),s[u++]=240|o>>>18,s[u++]=128|o>>>12&63),s[u++]=128|o>>>6&63),s[u++]=128|63&o);e=s}else if("object"===a){if(null===e)throw Error(t);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!l||!ArrayBuffer.isView(e)))throw Error(t)}else throw Error(t);e.length>64&&(e=new v(r,!0).update(e).array());var f=[],h=[];for(i=0;i<64;++i){var d=e[i]||0;f[i]=92^d,h[i]=54^d}v.call(this,r,n),this.update(h),this.oKeyPad=f,this.inner=!0,this.sharedMemory=n}v.prototype.update=function(e){if(!this.finalized){var r,n=typeof e;if("string"!==n){if("object"===n){if(null===e)throw Error(t);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!l||!ArrayBuffer.isView(e)))throw Error(t)}else throw Error(t);r=!0}for(var i,a,o=0,s=e.length,c=this.blocks;o<s;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),r)for(a=this.start;o<s&&a<64;++o)c[a>>>2]|=e[o]<<h[3&a++];else for(a=this.start;o<s&&a<64;++o)(i=e.charCodeAt(o))<128?c[a>>>2]|=i<<h[3&a++]:(i<2048?c[a>>>2]|=(192|i>>>6)<<h[3&a++]:(i<55296||i>=57344?c[a>>>2]|=(224|i>>>12)<<h[3&a++]:(i=65536+((1023&i)<<10|1023&e.charCodeAt(++o)),c[a>>>2]|=(240|i>>>18)<<h[3&a++],c[a>>>2]|=(128|i>>>12&63)<<h[3&a++]),c[a>>>2]|=(128|i>>>6&63)<<h[3&a++]),c[a>>>2]|=(128|63&i)<<h[3&a++]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=c[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>0xffffffff&&(this.hBytes+=this.bytes/0x100000000<<0,this.bytes=this.bytes%0x100000000),this}},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=f[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},v.prototype.hash=function(){var e,t,r,n,i,a,o,s,c,l,u,f=this.h0,h=this.h1,p=this.h2,w=this.h3,y=this.h4,g=this.h5,m=this.h6,b=this.h7,x=this.blocks;for(e=16;e<64;++e)t=((i=x[e-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,r=((i=x[e-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,x[e]=x[e-16]+t+x[e-7]+r<<0;for(e=0,u=h&p;e<64;e+=4)this.first?(this.is224?(s=300032,b=(i=x[0]-0x543c9a5b)-0x8f1a6c7<<0,w=i+0x170e9b5<<0):(s=0x2a01a605,b=(i=x[0]-0xc881298)-0x5ab00ac6<<0,w=i+0x8909ae5<<0),this.first=!1):(t=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),r=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),n=(s=f&h)^f&p^u,i=b+r+(y&g^~y&m)+d[e]+x[e],a=t+n,b=w+i<<0,w=i+a<<0),t=(w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10),r=(b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7),n=(c=w&f)^w&h^s,i=m+r+(b&y^~b&g)+d[e+1]+x[e+1],a=t+n,m=p+i<<0,t=((p=i+a<<0)>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),r=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),n=(l=p&w)^p&f^c,i=g+r+(m&b^~m&y)+d[e+2]+x[e+2],a=t+n,g=h+i<<0,t=((h=i+a<<0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),r=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7),n=(u=h&p)^h&w^l,i=y+r+(g&m^~g&b)+d[e+3]+x[e+3],a=t+n,y=f+i<<0,f=i+a<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+f<<0,this.h1=this.h1+h<<0,this.h2=this.h2+p<<0,this.h3=this.h3+w<<0,this.h4=this.h4+y<<0,this.h5=this.h5+g<<0,this.h6=this.h6+m<<0,this.h7=this.h7+b<<0},v.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=u[e>>>28&15]+u[e>>>24&15]+u[e>>>20&15]+u[e>>>16&15]+u[e>>>12&15]+u[e>>>8&15]+u[e>>>4&15]+u[15&e]+u[t>>>28&15]+u[t>>>24&15]+u[t>>>20&15]+u[t>>>16&15]+u[t>>>12&15]+u[t>>>8&15]+u[t>>>4&15]+u[15&t]+u[r>>>28&15]+u[r>>>24&15]+u[r>>>20&15]+u[r>>>16&15]+u[r>>>12&15]+u[r>>>8&15]+u[r>>>4&15]+u[15&r]+u[n>>>28&15]+u[n>>>24&15]+u[n>>>20&15]+u[n>>>16&15]+u[n>>>12&15]+u[n>>>8&15]+u[n>>>4&15]+u[15&n]+u[i>>>28&15]+u[i>>>24&15]+u[i>>>20&15]+u[i>>>16&15]+u[i>>>12&15]+u[i>>>8&15]+u[i>>>4&15]+u[15&i]+u[a>>>28&15]+u[a>>>24&15]+u[a>>>20&15]+u[a>>>16&15]+u[a>>>12&15]+u[a>>>8&15]+u[a>>>4&15]+u[15&a]+u[o>>>28&15]+u[o>>>24&15]+u[o>>>20&15]+u[o>>>16&15]+u[o>>>12&15]+u[o>>>8&15]+u[o>>>4&15]+u[15&o];return this.is224||(c+=u[s>>>28&15]+u[s>>>24&15]+u[s>>>20&15]+u[s>>>16&15]+u[s>>>12&15]+u[s>>>8&15]+u[s>>>4&15]+u[15&s]),c},v.prototype.toString=v.prototype.hex,v.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,255&s),c},v.prototype.array=v.prototype.digest,v.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},S.prototype=new v,S.prototype.finalize=function(){if(v.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();v.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),v.prototype.finalize.call(this)}};var I=g();I.sha256=I,I.sha224=g(!0),I.sha256.hmac=x(),I.sha224.hmac=x(!0),s?e.exports=I:(i.sha256=I.sha256,i.sha224=I.sha224,c&&define(function(){return I}))}()},"?2fd0":function(){},"?81fa":function(){}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";let e;r.r(n),r.d(n,{DebugInfoGatherer:()=>s,productTypesMask:()=>ee,watchWalletStatus:()=>er,getProductInformation:()=>eR,trackPurchaseStatus:()=>eM,FrakContextManager:()=>Q,PressInteractionEncoder:()=>e2,createIFrameFrakClient:()=>b,baseIframeProps:()=>y,processReferral:()=>eQ,productTypes:()=>Z,RetailInteractionEncoder:()=>ti,openSso:()=>eL,setupClient:()=>v,interactionTypes:()=>et,createIframe:()=>g,decompressDataAndCheckHash:()=>f,displayEmbededWallet:()=>eO,WebShopInteractionEncoder:()=>tn,PurchaseInteractionEncoder:()=>tr,hashAndCompressData:()=>d,sendInteraction:()=>eT,decompressJson:()=>h,Deferred:()=>c,ClientNotFound:()=>a,displayModal:()=>eU,ReferralInteractionEncoder:()=>eY,compressJson:()=>p,referralInteraction:()=>e1,RpcErrorCodes:()=>o,sendTransaction:()=>ej,FrakRpcError:()=>t,siweAuthenticate:()=>eD,modalBuilder:()=>eN});class t extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}}class i extends t{constructor(e){super(o.internalError,e)}}class a extends t{constructor(){super(o.clientNotConnected,"Client not found")}}let o={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class s{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn("Failed to encode debug data",e),btoa("Failed to encode data")}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute("loading"),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?+("complete"===this.iframe.contentDocument.readyState):-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let r=this.getIframeStatus(),n=this.getNavigatorInfo(),i="Unknown";return e instanceof t?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:"string"==typeof e&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):"no-config",navigatorInfo:n?this.base64Encode(n):"no-navigator",iframeStatus:r?this.base64Encode(r):"not-iframe",lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):"No Frak request logged",lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):"No Frak response logged",clientStatus:this.isSetupDone?"setup":"not-setup",error:i}}static empty(){return new s}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FrakSDK=t():e.FrakSDK=t()}(globalThis,()=>(()=>{var e={"../../node_modules/async-lz-string/libs/async-lz-string.js":function(e){var t;t=()=>{var e,t;return e={48:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.decompressFromUTF16=t.compressToUTF16=t.decompressFromBase64=t.compressToBase64=void 0;var a=r(304),o=r(134),s=new a.CompressorImpl,c=new o.DecompressorImpl,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u={};t.compressToBase64=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return null===e?[2,""]:[4,s.compress(e,6,function(e){return l.charAt(e)})];case 1:switch((t=r.sent()).length%4){default:case 0:return[2,t];case 1:return[2,t+"==="];case 2:return[2,t+"=="];case 3:return[2,t+"="]}return[2]}})})},t.decompressFromBase64=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return null===e?[2,""]:""===e?[2,null]:[4,c.decompress(e.length,32,function(t){return function(e,t){if(!u[e]){u[e]={};for(var r=0;r<e.length;r++)u[e][e.charAt(r)]=r}return u[e][t]}(l,e.charAt(t))})];case 1:return[2,t.sent()]}})})},t.compressToUTF16=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return null===e?[2,""]:[4,s.compress(e,15,function(e){return String.fromCharCode(e+32)})];case 1:return[2,t.sent()+" "]}})})},t.decompressFromUTF16=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return null===e?[2,""]:""===e?[2,null]:[4,c.decompress(e.length,16384,function(t){return e.charCodeAt(t)-32})];case 1:return[2,t.sent()]}})})}},304:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompressorImpl=void 0;var a=r(658),o=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],s=function(){function e(){}return e.writeValueToData=function(e,t,r,n,i){if(r%4!=0||e.dataPosition+r>n-1)for(var a=0;a<r;a++)e.dataVal=e.dataVal<<1|1&t,e.dataPosition==n-1?(e.dataPosition=0,e.data.push(i(e.dataVal)),e.dataVal=0):e.dataPosition++,t>>=1;else e.dataVal<<=r,e.dataVal|=function(e,t){for(var r=0,n=0;n<t;++n)r<<=4,r|=o[15&e],e>>=4;return r}(t,r/4),e.dataPosition+=r},e.writeWToDataVal=function(t,r,n){t.dictionaryToCreate.has(t.w)?(256>t.w.charCodeAt(0)?(e.writeValueToData(t,0,t.numBits,r,n),e.writeValueToData(t,t.w.charCodeAt(0),8,r,n)):(e.writeValueToData(t,1,t.numBits,r,n),e.writeValueToData(t,t.w.charCodeAt(0),16,r,n)),t.enlargeIn--,0==t.enlargeIn&&(t.enlargeIn=Math.pow(2,t.numBits),t.numBits++),t.dictionaryToCreate.delete(t.w)):e.writeValueToData(t,t.dictionary.get(t.w),t.numBits,r,n),t.enlargeIn--,0==t.enlargeIn&&(t.enlargeIn=Math.pow(2,t.numBits),t.numBits++)},e.loopIteration=function(e,t,r,n,i){var a=e.charAt(t);i.dictionary.has(a)||(i.dictionary.set(a,i.dictSize++),i.dictionaryToCreate.set(a,!0));var o=i.w+a;i.dictionary.has(o)?i.w=o:(this.writeWToDataVal(i,r,n),i.dictionary.set(o,i.dictSize++),i.w=String(a))},e.prototype.compress=function(t,r,o){var s=this;return new Promise(function(c){return n(s,void 0,void 0,function(){var n,s;return i(this,function(i){switch(i.label){case 0:if(null==t)return c(""),[2];n={data:[],dataPosition:0,dataVal:0,dictionary:new Map,dictionaryToCreate:new Map,dictSize:3,enlargeIn:2,numBits:2,w:""},s=0,i.label=1;case 1:return s<t.length?(e.loopIteration(t,s,r,o,n),s%1e4!=0?[3,3]:[4,(0,a.wait)()]):[3,4];case 2:i.sent(),i.label=3;case 3:return s+=1,[3,1];case 4:return""!==n.w&&e.writeWToDataVal(n,r,o),e.writeValueToData(n,2,n.numBits,r,o),n.dataVal<<=r-n.dataPosition,n.data.push(o(n.dataVal)),c(n.data.join("")),[2]}})})})},e}();t.CompressorImpl=s},134:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DecompressorImpl=void 0;var a=r(658),o=function(){function e(){}return e.prototype.decompress=function(e,t,r){var o=this;return new Promise(function(s){return n(o,void 0,void 0,function(){var n,o,c;return i(this,function(i){switch(i.label){case 0:for(n={bits:0,c:null,dataIndex:1,dataPosition:t,dataVal:r(0),dictionary:new Map,dictSize:4,enlargeIn:4,entry:"",maxPower:4,numBits:3,power:1,resb:null,result:[],w:null},o=0;o<3;o+=1)n.dictionary.set(o,o);for(;n.power!=n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;switch(n.bits){case 0:for(n.bits=0,n.maxPower=256,n.power=1;n.power!=n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.c=String.fromCharCode(n.bits);break;case 1:for(n.bits=0,n.maxPower=65536,n.power=1;n.power!==n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0===n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.c=String.fromCharCode(n.bits);break;case 2:return s(""),[2]}n.dictionary[3]=n.c,n.w=n.c,n.result.push(n.c),c=1,i.label=1;case 1:return c%2e4!=0?[3,3]:[4,(0,a.wait)()];case 2:i.sent(),i.label=3;case 3:if(n.dataIndex>e)return s(""),[2];for(n.bits=0,n.maxPower=Math.pow(2,n.numBits),n.power=1;n.power!=n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;switch(n.c=n.bits){case 0:for(n.bits=0,n.maxPower=256,n.power=1;n.power!==n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.dictionary[n.dictSize++]=String.fromCharCode(n.bits),n.c=n.dictSize-1,n.enlargeIn--;break;case 1:for(n.bits=0,n.maxPower=65536,n.power=1;n.power!==n.maxPower;)n.resb=n.dataVal&n.dataPosition,n.dataPosition>>=1,0==n.dataPosition&&(n.dataPosition=t,n.dataVal=r(n.dataIndex++)),n.bits|=+(n.resb>0)*n.power,n.power<<=1;n.dictionary[n.dictSize++]=String.fromCharCode(n.bits),n.c=n.dictSize-1,n.enlargeIn--;break;case 2:return s(n.result.join("")),[2]}if(0==n.enlargeIn&&(n.enlargeIn=Math.pow(2,n.numBits),n.numBits++),n.dictionary[n.c])n.entry=n.dictionary[n.c];else{if(n.c!==n.dictSize)return s(null),[2];n.entry=n.w+n.w.charAt(0)}return n.result.push(n.entry),n.dictionary[n.dictSize++]=n.w+n.entry.charAt(0),n.enlargeIn--,n.w=n.entry,0==n.enlargeIn&&(n.enlargeIn=Math.pow(2,n.numBits),n.numBits++),c++,[3,1];case 4:return[2]}})})})},e}();t.DecompressorImpl=o},658:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,s)}c((n=n.apply(e,t||[])).next())})},n=this&&this.__generator||function(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.wait=void 0,t.wait=function(){return r(this,void 0,void 0,function(){return n(this,function(e){return[2,new Promise(function(e){setTimeout(e,0)})]})})}}},t={},function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(48)},e.exports=t()},"../../node_modules/js-sha256/src/sha256.js":function(e,t,r){!function(){"use strict";var t="input is invalid type",n="object"==typeof window,i=n?window:{};i.JS_SHA256_NO_WINDOW&&(n=!1);var a=!n&&"object"==typeof self,o=!i.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;o?i=r.g:a&&(i=self);var s=!i.JS_SHA256_NO_COMMON_JS&&e.exports,c="function"==typeof define&&define.amd,l=!i.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),f=[-0x80000000,8388608,32768,128],h=[24,16,8,0],d=[0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2],p=["hex","array","digest","arrayBuffer"],w=[];(i.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),l&&(i.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var y=function(e,t){return function(r){return new v(t,!0).update(r)[e]()}},m=function(e){var t=y("hex",e);o&&(t=g(t,e)),t.create=function(){return new v(e)},t.update=function(e){return t.create().update(e)};for(var r=0;r<p.length;++r){var n=p[r];t[n]=y(n,e)}return t},g=function(e,n){var a,o=r("?81fa"),s=r("?2fd0").Buffer,c=n?"sha224":"sha256";return a=s.from&&!i.JS_SHA256_NO_BUFFER_FROM?s.from:function(e){return new s(e)},function(r){if("string"==typeof r)return o.createHash(c).update(r,"utf8").digest("hex");if(null==r)throw Error(t);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===s?o.createHash(c).update(a(r)).digest("hex"):e(r)}},b=function(e,t){return function(r,n){return new S(r,t,!0).update(n)[e]()}},x=function(e){var t=b("hex",e);t.create=function(t){return new S(t,e)},t.update=function(e,r){return t.create(e).update(r)};for(var r=0;r<p.length;++r){var n=p[r];t[n]=b(n,e)}return t};function v(e,t){t?(w[0]=w[16]=w[1]=w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=w[12]=w[13]=w[14]=w[15]=0,this.blocks=w):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=0xc1059ed8,this.h1=0x367cd507,this.h2=0x3070dd17,this.h3=0xf70e5939,this.h4=0xffc00b31,this.h5=0x68581511,this.h6=0x64f98fa7,this.h7=0xbefa4fa4):(this.h0=0x6a09e667,this.h1=0xbb67ae85,this.h2=0x3c6ef372,this.h3=0xa54ff53a,this.h4=0x510e527f,this.h5=0x9b05688c,this.h6=0x1f83d9ab,this.h7=0x5be0cd19),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function S(e,r,n){var i,a=typeof e;if("string"===a){var o,s=[],c=e.length,u=0;for(i=0;i<c;++i)(o=e.charCodeAt(i))<128?s[u++]=o:(o<2048?s[u++]=192|o>>>6:(o<55296||o>=57344?s[u++]=224|o>>>12:(o=65536+((1023&o)<<10|1023&e.charCodeAt(++i)),s[u++]=240|o>>>18,s[u++]=128|o>>>12&63),s[u++]=128|o>>>6&63),s[u++]=128|63&o);e=s}else if("object"===a){if(null===e)throw Error(t);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!l||!ArrayBuffer.isView(e)))throw Error(t)}else throw Error(t);e.length>64&&(e=new v(r,!0).update(e).array());var f=[],h=[];for(i=0;i<64;++i){var d=e[i]||0;f[i]=92^d,h[i]=54^d}v.call(this,r,n),this.update(h),this.oKeyPad=f,this.inner=!0,this.sharedMemory=n}v.prototype.update=function(e){if(!this.finalized){var r,n=typeof e;if("string"!==n){if("object"===n){if(null===e)throw Error(t);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!l||!ArrayBuffer.isView(e)))throw Error(t)}else throw Error(t);r=!0}for(var i,a,o=0,s=e.length,c=this.blocks;o<s;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),r)for(a=this.start;o<s&&a<64;++o)c[a>>>2]|=e[o]<<h[3&a++];else for(a=this.start;o<s&&a<64;++o)(i=e.charCodeAt(o))<128?c[a>>>2]|=i<<h[3&a++]:(i<2048?c[a>>>2]|=(192|i>>>6)<<h[3&a++]:(i<55296||i>=57344?c[a>>>2]|=(224|i>>>12)<<h[3&a++]:(i=65536+((1023&i)<<10|1023&e.charCodeAt(++o)),c[a>>>2]|=(240|i>>>18)<<h[3&a++],c[a>>>2]|=(128|i>>>12&63)<<h[3&a++]),c[a>>>2]|=(128|i>>>6&63)<<h[3&a++]),c[a>>>2]|=(128|63&i)<<h[3&a++]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=c[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>0xffffffff&&(this.hBytes+=this.bytes/0x100000000<<0,this.bytes=this.bytes%0x100000000),this}},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=f[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},v.prototype.hash=function(){var e,t,r,n,i,a,o,s,c,l,u,f=this.h0,h=this.h1,p=this.h2,w=this.h3,y=this.h4,m=this.h5,g=this.h6,b=this.h7,x=this.blocks;for(e=16;e<64;++e)t=((i=x[e-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,r=((i=x[e-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,x[e]=x[e-16]+t+x[e-7]+r<<0;for(e=0,u=h&p;e<64;e+=4)this.first?(this.is224?(s=300032,b=(i=x[0]-0x543c9a5b)-0x8f1a6c7<<0,w=i+0x170e9b5<<0):(s=0x2a01a605,b=(i=x[0]-0xc881298)-0x5ab00ac6<<0,w=i+0x8909ae5<<0),this.first=!1):(t=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),r=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),n=(s=f&h)^f&p^u,i=b+r+(y&m^~y&g)+d[e]+x[e],a=t+n,b=w+i<<0,w=i+a<<0),t=(w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10),r=(b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7),n=(c=w&f)^w&h^s,i=g+r+(b&y^~b&m)+d[e+1]+x[e+1],a=t+n,g=p+i<<0,t=((p=i+a<<0)>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),r=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7),n=(l=p&w)^p&f^c,i=m+r+(g&b^~g&y)+d[e+2]+x[e+2],a=t+n,m=h+i<<0,t=((h=i+a<<0)>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),r=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),n=(u=h&p)^h&w^l,i=y+r+(m&g^~m&b)+d[e+3]+x[e+3],a=t+n,y=f+i<<0,f=i+a<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+f<<0,this.h1=this.h1+h<<0,this.h2=this.h2+p<<0,this.h3=this.h3+w<<0,this.h4=this.h4+y<<0,this.h5=this.h5+m<<0,this.h6=this.h6+g<<0,this.h7=this.h7+b<<0},v.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=u[e>>>28&15]+u[e>>>24&15]+u[e>>>20&15]+u[e>>>16&15]+u[e>>>12&15]+u[e>>>8&15]+u[e>>>4&15]+u[15&e]+u[t>>>28&15]+u[t>>>24&15]+u[t>>>20&15]+u[t>>>16&15]+u[t>>>12&15]+u[t>>>8&15]+u[t>>>4&15]+u[15&t]+u[r>>>28&15]+u[r>>>24&15]+u[r>>>20&15]+u[r>>>16&15]+u[r>>>12&15]+u[r>>>8&15]+u[r>>>4&15]+u[15&r]+u[n>>>28&15]+u[n>>>24&15]+u[n>>>20&15]+u[n>>>16&15]+u[n>>>12&15]+u[n>>>8&15]+u[n>>>4&15]+u[15&n]+u[i>>>28&15]+u[i>>>24&15]+u[i>>>20&15]+u[i>>>16&15]+u[i>>>12&15]+u[i>>>8&15]+u[i>>>4&15]+u[15&i]+u[a>>>28&15]+u[a>>>24&15]+u[a>>>20&15]+u[a>>>16&15]+u[a>>>12&15]+u[a>>>8&15]+u[a>>>4&15]+u[15&a]+u[o>>>28&15]+u[o>>>24&15]+u[o>>>20&15]+u[o>>>16&15]+u[o>>>12&15]+u[o>>>8&15]+u[o>>>4&15]+u[15&o];return this.is224||(c+=u[s>>>28&15]+u[s>>>24&15]+u[s>>>20&15]+u[s>>>16&15]+u[s>>>12&15]+u[s>>>8&15]+u[s>>>4&15]+u[15&s]),c},v.prototype.toString=v.prototype.hex,v.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o];return this.is224||c.push(s>>>24&255,s>>>16&255,s>>>8&255,255&s),c},v.prototype.array=v.prototype.digest,v.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},S.prototype=new v,S.prototype.finalize=function(){if(v.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();v.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),v.prototype.finalize.call(this)}};var A=m();A.sha256=A,A.sha224=m(!0),A.sha256.hmac=x(),A.sha224.hmac=x(!0),s?e.exports=A:(i.sha256=A.sha256,i.sha224=A.sha224,c&&define(function(){return A}))}()},"?2fd0":function(){},"?81fa":function(){}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},(()=>{r.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})()})(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";let e;r.r(n),r.d(n,{Deferred:()=>s,ReferralInteractionEncoder:()=>e2,getProductInformation:()=>eN,getSupportedLocale:()=>I,openSso:()=>ej,productTypes:()=>ei,PurchaseInteractionEncoder:()=>ts,FrakRpcError:()=>t,referralInteraction:()=>e4,trackPurchaseStatus:()=>eV,productTypesMask:()=>ea,interactionTypes:()=>eo,processReferral:()=>e5,PressInteractionEncoder:()=>e8,sendTransaction:()=>eH,WebShopInteractionEncoder:()=>tc,displayEmbededWallet:()=>eM,hashAndCompressData:()=>h,decompressJson:()=>f,watchWalletStatus:()=>es,RpcErrorCodes:()=>o,setupClient:()=>A,RetailInteractionEncoder:()=>tl,getCurrencyAmountKey:()=>E,siweAuthenticate:()=>eq,getSupportedCurrency:()=>S,decompressDataAndCheckHash:()=>u,displayModal:()=>eD,FrakContextManager:()=>en,locales:()=>v,ClientNotFound:()=>a,baseIframeProps:()=>y,createIframe:()=>m,modalBuilder:()=>eJ,compressJson:()=>d,sendInteraction:()=>eF,DebugInfoGatherer:()=>w,createIFrameFrakClient:()=>b,formatAmount:()=>k});class t extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}}class i extends t{constructor(e){super(o.internalError,e)}}class a extends t{constructor(){super(o.clientNotConnected,"Client not found")}}let o={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class s{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}var c=r("../../node_modules/async-lz-string/libs/async-lz-string.js"),l=r("../../node_modules/js-sha256/src/sha256.js");async function u(e){if(!(e?.compressed&&e?.compressedHash))throw new t(o.corruptedResponse,"Missing compressed data");let r=await f(e.compressed);if(!r)throw new t(o.corruptedResponse,"Invalid compressed data");if(!r?.validationHash)throw new t(o.corruptedResponse,"Missing validation hash");if((0,l.sha256)(e.compressed)!==e.compressedHash)throw new t(o.corruptedResponse,"Invalid compressed hash");let{validationHash:n,...i}=r;if((0,l.sha256)(JSON.stringify(i))!==r.validationHash)throw new t(o.corruptedResponse,"Invalid data validation hash");return r}async function f(e){let t=await (0,c.decompressFromBase64)(e);try{return JSON.parse(t)}catch(e){return console.error("Invalid compressed data",{e,decompressed:t}),null}}async function h(e){let t=(0,l.sha256)(JSON.stringify(e)),r={...e,validationHash:t},n=await d(r),i=(0,l.sha256)(n);return{compressed:n,compressedHash:i}}async function d(e){return(0,c.compressToBase64)(JSON.stringify(e))}let p="nexus-wallet-backup";class w{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn("Failed to encode debug data",e),btoa("Failed to encode data")}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute("loading"),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?+("complete"===this.iframe.contentDocument.readyState):-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let r=this.getIframeStatus(),n=this.getNavigatorInfo(),i="Unknown";return e instanceof t?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:"string"==typeof e&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):"no-config",navigatorInfo:n?this.base64Encode(n):"no-navigator",iframeStatus:r?this.base64Encode(r):"not-iframe",lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):"No Frak request logged",lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):"No Frak response logged",clientStatus:this.isSetupDone?"setup":"not-setup",error:i}}static empty(){return new w}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
|
|
3
3
|
Debug Information:
|
|
4
4
|
-----------------
|
|
5
5
|
Timestamp: ${t.timestamp}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
Last Response: ${t.lastResponse}
|
|
12
12
|
Client Status: ${t.clientStatus}
|
|
13
13
|
Error: ${t.error}
|
|
14
|
-
`.trim()}}class c{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}var l=r("../../node_modules/async-lz-string/libs/async-lz-string.js"),u=r("../../node_modules/js-sha256/src/sha256.js");async function f(e){if(!(e?.compressed&&e?.compressedHash))throw new t(o.corruptedResponse,"Missing compressed data");let r=await h(e.compressed);if(!r)throw new t(o.corruptedResponse,"Invalid compressed data");if(!r?.validationHash)throw new t(o.corruptedResponse,"Missing validation hash");if((0,u.sha256)(e.compressed)!==e.compressedHash)throw new t(o.corruptedResponse,"Invalid compressed hash");let{validationHash:n,...i}=r;if((0,u.sha256)(JSON.stringify(i))!==r.validationHash)throw new t(o.corruptedResponse,"Invalid data validation hash");return r}async function h(e){let t=await (0,l.decompressFromBase64)(e);try{return JSON.parse(t)}catch(e){return console.error("Invalid compressed data",{e,decompressed:t}),null}}async function d(e){let t=(0,u.sha256)(JSON.stringify(e)),r={...e,validationHash:t},n=await p(r),i=(0,u.sha256)(n);return{compressed:n,compressedHash:i}}async function p(e){return(0,l.compressToBase64)(JSON.stringify(e))}let w="nexus-wallet-backup",y={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function g({walletBaseUrl:e,config:t}){let r=document.querySelector("#nexus-wallet");r&&r.remove();let n=document.createElement("iframe");return n.id=y.id,n.name=y.name,n.allow=y.allow,n.style.zIndex=y.style.zIndex.toString(),m({iframe:n,isVisible:!1}),document.body.appendChild(n),new Promise(r=>{n?.addEventListener("load",()=>r(n)),n.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function m({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function b({config:e,iframe:r}){let n=function(){let e=new Map;return{createChannel:t=>{let r=Math.random().toString(36).substring(7);return e.set(r,t),r},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),a=function({iframe:e}){let t=new c;return{handleEvent:async r=>{switch(r.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":r.data.backup?localStorage.setItem(w,r.data.backup):localStorage.removeItem(w);break;case"remove-backup":localStorage.removeItem(w);break;case"show":case"hide":m({iframe:e,isVisible:"show"===r.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:r.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:r}),l=new s(e,r),u=function({frakWalletUrl:e,iframe:r,channelManager:n,iframeLifecycleManager:i,debugInfo:a}){if("undefined"==typeof window)throw new t(o.configError,"iframe client should be used in the browser");if(!r.contentWindow)throw new t(o.configError,"The iframe does not have a product window");let s=r.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(a.setLastResponse(t),"iframeLifecycle"in t.data){await i.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let r=t.data.id,o=n.getRpcResolver(r);o&&await o(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){s.postMessage(t,{targetOrigin:e}),a.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:r,channelManager:n,iframeLifecycleManager:a,debugInfo:l}),h=async e=>{if(!await a.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let r=new c,i=n.createChannel(async e=>{let a=await f(e.data);a.error?r.reject(new t(a.error.code,a.error.message,a.error?.data)):r.resolve(a.result),n.removeChannel(i)}),s=await d(e);return u.sendEvent({id:i,topic:e.method,data:s}),r.promise},p=async(e,r)=>{if(!await a.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let s=n.createChannel(async e=>{let t=await f(e.data);if(t.result)r(t.result);else throw new i("No valid result in the response")}),c=await d(e);u.sendEvent({id:s,topic:e.method,data:c})},y=function(e,t){let r,n;let i=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){r&&clearInterval(r),n&&clearTimeout(n)}return async function(){i(),r=setInterval(i,100),n=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,a()}(),a}(u,a),g=async()=>{y(),n.destroy(),u.cleanup(),r.remove()},b=x({config:e,messageHandler:u,lifecycleManager:a}).then(()=>l.updateSetupStatus(!0));return{config:e,debugInfo:l,waitForConnection:a.isConnected,waitForSetup:b,request:h,listenerRequest:p,destroy:g}}async function x({config:e,messageHandler:t,lifecycleManager:r}){await r.isConnected;let n=async()=>{let r=e.metadata.css;r&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:r}})},i=async()=>{if("undefined"==typeof window)return;let e=window.localStorage.getItem(w);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})};await Promise.all([n(),i()])}async function v({config:e}){let t=await g({config:e});if(!t){console.error("Failed to create iframe");return}let r=b({config:e,iframe:t});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}let S="2.22.23",I={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${S}`};class A extends Error{constructor(e,t={}){let r=t.cause instanceof A?t.cause.details:t.cause?.message?t.cause.message:t.details,n=t.cause instanceof A&&t.cause.docsPath||t.docsPath,i=I.getDocsUrl?.({...t,docsPath:n});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...I.version?[`Version: ${I.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=S}walk(e){return function e(t,r){return r?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,r):r?null:t}(this,e)}}function k(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}class E extends A{constructor({offset:e,position:t,size:r}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class z extends A{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function P(e,{dir:t,size:r=32}={}){return"string"==typeof e?$(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new z({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let i=0;i<r;i++){let a="right"===t;n[a?i:r-i-1]=e[a?i:e.length-i-1]}return n}(e,{dir:t,size:r})}function $(e,{dir:t,size:r=32}={}){if(null===r)return e;let n=e.replace("0x","");if(n.length>2*r)throw new z({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n["right"===t?"padEnd":"padStart"](2*r,"0")}`}class C extends A{constructor({max:e,min:t,signed:r,size:n,value:i}){super(`Number "${i}" is not in safe ${n?`${8*n}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class _ extends A{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function B(e){return k(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function T(e,{size:t}){if(B(e)>t)throw new _({givenSize:B(e),maxSize:t})}let U=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function O(e,t={}){return"number"==typeof e||"bigint"==typeof e?M(e,t):"string"==typeof e?D(e,t):"boolean"==typeof e?L(e,t):R(e,t)}function L(e,t={}){let r=`0x${Number(e)}`;return"number"==typeof t.size?(T(r,{size:t.size}),P(r,{size:t.size})):r}function R(e,t={}){let r="";for(let t=0;t<e.length;t++)r+=U[e[t]];let n=`0x${r}`;return"number"==typeof t.size?(T(n,{size:t.size}),P(n,{dir:"right",size:t.size})):n}function M(e,t={}){let r;let{signed:n,size:i}=t,a=BigInt(e);i?r=n?(1n<<8n*BigInt(i)-1n)-1n:2n**(8n*BigInt(i))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));let o="bigint"==typeof r&&n?-r-1n:0;if(r&&a>r||a<o){let t="bigint"==typeof e?"n":"";throw new C({max:r?`${r}${t}`:void 0,min:`${o}${t}`,signed:n,size:i,value:`${e}${t}`})}let s=`0x${(n&&a<0?(1n<<BigInt(8*i))+BigInt(a):a).toString(16)}`;return i?P(s,{size:i}):s}let F=new TextEncoder;function D(e,t={}){return R(F.encode(e),t)}let j=new TextEncoder,N={zero:48,nine:57,A:65,F:70,a:97,f:102};function V(e){return e>=N.zero&&e<=N.nine?e-N.zero:e>=N.A&&e<=N.F?e-(N.A-10):e>=N.a&&e<=N.f?e-(N.a-10):void 0}function W(e,t={}){let r=e;t.size&&(T(r,{size:t.size}),r=P(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let i=n.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let r=V(n.charCodeAt(t++)),i=V(n.charCodeAt(t++));if(void 0===r||void 0===i)throw new A(`Invalid byte sequence ("${n[t-2]}${n[t-1]}" in "${n}").`);a[e]=16*r+i}return a}function q(e,t={}){let r=j.encode(e);return"number"==typeof t.size?(T(r,{size:t.size}),P(r,{dir:"right",size:t.size})):r}let H="fCtx";function J(e){if(e?.r)try{var t;return t=W(e.r),btoa(Array.from(t,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function G(e){if(e&&0!==e.length)try{let t=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(e);return{r:R(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function X({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(H);return t?G(t):null}function K({url:e,context:t}){if(!e)return null;let r=X({url:e}),n=r?{...r,...t}:t;if(!n.r)return null;let i=J(n);if(!i)return null;let a=new URL(e);return a.searchParams.set(H,i),a.toString()}function Y(e){let t=new URL(e);return t.searchParams.delete(H),t.toString()}let Q={compress:J,decompress:G,parse:X,update:K,remove:Y,replaceUrl:function({url:e,context:t}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(r=null!==t?K({url:n,context:t}):Y(n))&&window.history.replaceState(null,"",r.toString())}},Z={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},ee=Object.entries(Z).reduce((e,[t,r])=>(e[t]=BigInt(1)<<BigInt(r),e),{}),et={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};function er(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(en(e.interactionToken),e));let r=new c,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),en(e.interactionToken),n||(r.resolve(e),n=!0)}).then(()=>r.promise)}function en(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}function ei(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function ea(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function eo(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}let es=BigInt(0x100000000-1),ec=BigInt(32),el=(e,t,r)=>e<<r|t>>>32-r,eu=(e,t,r)=>t<<r|e>>>32-r,ef=(e,t,r)=>t<<r-32|e>>>64-r,eh=(e,t,r)=>e<<r-32|t>>>64-r,ed=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function ep(e){for(let r=0;r<e.length;r++){var t;e[r]=(t=e[r])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function ew(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),ea(e),e}class ey{clone(){return this._cloneInto()}}let eg=[],em=[],eb=[],ex=BigInt(0),ev=BigInt(1),eS=BigInt(2),eI=BigInt(7),eA=BigInt(256),ek=BigInt(113);for(let e=0,t=ev,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],eg.push(2*(5*n+r)),em.push((e+1)*(e+2)/2%64);let i=ex;for(let e=0;e<7;e++)(t=(t<<ev^(t>>eI)*ek)%eA)&eS&&(i^=ev<<(ev<<BigInt(e))-ev);eb.push(i)}let[eE,ez]=function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=function(e,t=!1){return t?{h:Number(e&es),l:Number(e>>ec&es)}:{h:0|Number(e>>ec&es),l:0|Number(e&es)}}(e[i],t);[r[i],n[i]]=[a,o]}return[r,n]}(eb,!0),eP=(e,t,r)=>r>32?ef(e,t,r):el(e,t,r),e$=(e,t,r)=>r>32?eh(e,t,r):eu(e,t,r);class eC extends ey{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ei(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}(this.state)}keccak(){ed||ep(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,i=(t+2)%10,a=r[i],o=r[i+1],s=eP(a,o,1)^r[n],c=e$(a,o,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=s,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){let n=em[r],a=eP(t,i,n),o=e$(t,i,n),s=eg[r];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=eE[n],e[1]^=ez[n]}r.fill(0)}(this.state32,this.rounds),ed||ep(this.state32),this.posOut=0,this.pos=0}update(e){eo(this);let{blockLen:t,state:r}=this,n=(e=ew(e)).length;for(let i=0;i<n;){let a=Math.min(t-this.pos,n-i);for(let t=0;t<a;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,(128&t)!=0&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){eo(this,!1),ea(e),this.finish();let t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();let a=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+a),n),this.posOut+=a,n+=a}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ei(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){ea(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:a}=this;return e||(e=new eC(t,r,n,a,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=a,e.destroyed=this.destroyed,e}}let e_=function(e){let t=t=>e().update(ew(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}(()=>new eC(136,1,32));function eB(e,t){let r=e_(k(e,{strict:!1})?function(e,t={}){return"number"==typeof e||"bigint"==typeof e?W(M(e,t)):"boolean"==typeof e?function(e,t={}){let r=new Uint8Array(1);return(r[0]=Number(e),"number"==typeof t.size)?(T(r,{size:t.size}),P(r,{size:t.size})):r}(e,t):k(e)?W(e,t):q(e,t)}(e):e);return"bytes"===(t||"hex")?r:O(r)}async function eT(e,{productId:t,interaction:r,validation:n}){let i=t??function({domain:e}){return eB(O(e??window.location.host))}(e.config);return await e.request({method:"frak_sendInteraction",params:[i,r,n]})}async function eU(e,{steps:t,metadata:r}){return await e.request({method:"frak_displayModal",params:[t,e.config.metadata.name,r]})}async function eO(e,t){await e.request({method:"frak_displayEmbededWallet",params:[t,e.config.metadata.name]})}async function eL(e,t){let{metadata:r}=e.config;await e.request({method:"frak_sso",params:[t,r.name,r.css]})}async function eR(e){return await e.request({method:"frak_getProductInformation"})}async function eM(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}let eF=256;async function eD(t,{siwe:r,metadata:n}){let i=t.config?.domain??window.location.host,a=r?.statement??`I confirm that I want to use my Frak wallet on: ${t.config.metadata.name}`,o={...r,statement:a,nonce:r?.nonce??function(t=11){if(!e||eF+t>512){e="",eF=0;for(let t=0;t<256;t++)e+=(256+256*Math.random()|0).toString(16).substring(1)}return e.substring(eF,eF+++t)}(96),uri:r?.uri??`https://${i}`,version:r?.version??"1",domain:i};return(await eU(t,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function ej(e,{tx:t,metadata:r}){return(await eU(e,{metadata:r,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function eN(e,{metadata:t,login:r,openSession:n}){return function e(t,r){async function n(e){return e&&(r.metadata=e(r.metadata??{})),await eU(t,r)}return{params:r,sendTx:function(n){return e(t,{...r,steps:{...r.steps,sendTransaction:n}})},reward:function(n){return e(t,{...r,steps:{...r.steps,final:{...n,action:{key:"reward"}}}})},sharing:function(n,i){return e(t,{...r,steps:{...r.steps,final:{...i,action:{key:"sharing",options:n}}}})},display:n}}(e,{steps:{login:r??{},openSession:n??{}},metadata:t})}class eV extends A{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class eW extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}let eq=new eW(8192),eH=/^0x[a-fA-F0-9]{40}$/,eJ=new eW(8192);function eG(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(eJ.has(n))return eJ.get(n);let i=!!eH.test(e)&&(e.toLowerCase()===e||!r||function(e,t){if(eq.has(`${e}.${void 0}`))return eq.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=eB(q(r),"bytes"),i=(t?r.substring(`${t}0x`.length):r).split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&n[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let a=`0x${i.join("")}`;return eq.set(`${e}.${t}`,a),a}(e)===e);return eJ.set(n,i),i}function eX(e){return"string"==typeof e[0]?eK(e):function(e){let t=0;for(let r of e)t+=r.length;let r=new Uint8Array(t),n=0;for(let t of e)r.set(t,n),n+=t.length;return r}(e)}function eK(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}let eY={createLink:()=>({handlerTypeDenominator:O(Z.referral),interactionData:et.referral.createLink}),referred({referrer:e}){let t=eK([et.referral.referred,P(e,{size:32})]);return{handlerTypeDenominator:O(Z.referral),interactionData:t}}};async function eQ(e,{walletStatus:r,frakContext:n,modalConfig:i,productId:a,options:s}){let c=!1;async function l(){if(!c)return c=!0,e0(e,{modalConfig:i,walletStatus:r})}async function u(t){let r=eY.referred({referrer:t});await eT(e,{productId:a,interaction:r})}try{let{status:e,currentWallet:t}=await eZ({initialWalletStatus:r,getFreshWalletStatus:l,pushReferralInteraction:u,frakContext:n});return Q.replaceUrl({url:window.location?.href,context:s?.alwaysAppendUrl?{r:t}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),Q.replaceUrl({url:window.location?.href,context:s?.alwaysAppendUrl?{r:r?.wallet}:null}),function(e){if(e instanceof t)switch(e.code){case o.walletNotConnected:return"no-wallet";case o.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function eZ({initialWalletStatus:e,getFreshWalletStatus:t,pushReferralInteraction:r,frakContext:n}){let i=e?.wallet;return n?.r?(i||(i=await t()),i&&function(e,t){if(!eG(e,{strict:!1}))throw new eV({address:e});if(!eG(t,{strict:!1}))throw new eV({address:t});return e.toLowerCase()===t.toLowerCase()}(n.r,i))?{status:"self-referral",currentWallet:i}:(e?.interactionSession||(i=await t()),await r(n.r),{status:"success",currentWallet:i}):{status:"no-referrer",currentWallet:i}}async function e0(e,{modalConfig:t,walletStatus:r}){if(!r?.interactionSession){if(!t)return;let r=await eU(e,t);return r?.login?.wallet??void 0}return r.wallet??void 0}async function e1(e,{productId:t,modalConfig:r,options:n}={}){let i=Q.parse({url:window.location.href}),a=await er(e);try{return await eQ(e,{walletStatus:a,frakContext:i,modalConfig:r,productId:t,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}let e2={openArticle({articleId:e}){let t=eK([et.press.openArticle,P(e,{size:32})]);return{handlerTypeDenominator:O(Z.press),interactionData:t}},readArticle({articleId:e}){let t=eK([et.press.readArticle,P(e,{size:32})]);return{handlerTypeDenominator:O(Z.press),interactionData:t}}};class e5 extends A{constructor({expectedLength:e,givenLength:t,type:r}){super(`ABI encoding array length mismatch for type ${r}.
|
|
14
|
+
`.trim()}}let y={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function m({walletBaseUrl:e,config:t}){let r=document.querySelector("#nexus-wallet");r&&r.remove();let n=document.createElement("iframe");return n.id=y.id,n.name=y.name,n.allow=y.allow,n.style.zIndex=y.style.zIndex.toString(),g({iframe:n,isVisible:!1}),document.body.appendChild(n),new Promise(r=>{n?.addEventListener("load",()=>r(n)),n.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function g({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function b({config:e,iframe:r}){let n=function(){let e=new Map;return{createChannel:t=>{let r=Math.random().toString(36).substring(7);return e.set(r,t),r},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),a=function({iframe:e}){let t=new s;return{handleEvent:async r=>{switch(r.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":r.data.backup?localStorage.setItem(p,r.data.backup):localStorage.removeItem(p);break;case"remove-backup":localStorage.removeItem(p);break;case"show":case"hide":g({iframe:e,isVisible:"show"===r.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:r.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:r}),c=new w(e,r),l=function({frakWalletUrl:e,iframe:r,channelManager:n,iframeLifecycleManager:i,debugInfo:a}){if("undefined"==typeof window)throw new t(o.configError,"iframe client should be used in the browser");if(!r.contentWindow)throw new t(o.configError,"The iframe does not have a product window");let s=r.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(a.setLastResponse(t),"iframeLifecycle"in t.data){await i.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let r=t.data.id,o=n.getRpcResolver(r);o&&await o(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){s.postMessage(t,{targetOrigin:e}),a.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:r,channelManager:n,iframeLifecycleManager:a,debugInfo:c}),f=async e=>{if(!await a.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let r=new s,i=n.createChannel(async e=>{let a=await u(e.data);a.error?r.reject(new t(a.error.code,a.error.message,a.error?.data)):r.resolve(a.result),n.removeChannel(i)}),c=await h(e);return l.sendEvent({id:i,topic:e.method,data:c}),r.promise},d=async(e,r)=>{if(!await a.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let s=n.createChannel(async e=>{let t=await u(e.data);if(t.result)r(t.result);else throw new i("No valid result in the response")}),c=await h(e);l.sendEvent({id:s,topic:e.method,data:c})},y=function(e,t){let r,n;let i=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){r&&clearInterval(r),n&&clearTimeout(n)}return async function(){i(),r=setInterval(i,100),n=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,a()}(),a}(l,a),m=async()=>{y(),n.destroy(),l.cleanup(),r.remove()},b=x({config:e,messageHandler:l,lifecycleManager:a}).then(()=>c.updateSetupStatus(!0));return{config:e,debugInfo:c,waitForConnection:a.isConnected,waitForSetup:b,request:f,listenerRequest:d,destroy:m}}async function x({config:e,messageHandler:t,lifecycleManager:r}){await r.isConnected;let n=async()=>{let r=e.metadata.css;r&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:r}})},i=async()=>{if("undefined"==typeof window)return;let e=window.localStorage.getItem(p);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})};await Promise.all([n(),i()])}let v={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function S(e){return e&&e in v?e:"eur"}async function A({config:e}){let t=function(e){let t=S(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),r=await m({config:t});if(!r){console.error("Failed to create iframe");return}let n=b({config:t,iframe:r});if(await n.waitForSetup,!await n.waitForConnection){console.error("Failed to connect to client");return}return n}function I(e){return e?v[e]??v.eur:v.eur}function k(e,t){let r=I(t),n=S(t);return e.toLocaleString(r,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2})}function E(e){return e?`${e}Amount`:"eurAmount"}let z="2.23.9",P={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${z}`};class $ extends Error{constructor(e,t={}){let r=t.cause instanceof $?t.cause.details:t.cause?.message?t.cause.message:t.details,n=t.cause instanceof $&&t.cause.docsPath||t.docsPath,i=P.getDocsUrl?.({...t,docsPath:n});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...P.version?[`Version: ${P.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=z}walk(e){return function e(t,r){return r?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,r):r?null:t}(this,e)}}function C(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}class _ extends ${constructor({offset:e,position:t,size:r}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class B extends ${constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function T(e,{dir:t,size:r=32}={}){return"string"==typeof e?U(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new B({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let i=0;i<r;i++){let a="right"===t;n[a?i:r-i-1]=e[a?i:e.length-i-1]}return n}(e,{dir:t,size:r})}function U(e,{dir:t,size:r=32}={}){if(null===r)return e;let n=e.replace("0x","");if(n.length>2*r)throw new B({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n["right"===t?"padEnd":"padStart"](2*r,"0")}`}class O extends ${constructor({max:e,min:t,signed:r,size:n,value:i}){super(`Number "${i}" is not in safe ${n?`${8*n}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class L extends ${constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function R(e){return C(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function F(e,{size:t}){if(R(e)>t)throw new L({givenSize:R(e),maxSize:t})}let D=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function M(e,t={}){return"number"==typeof e||"bigint"==typeof e?V(e,t):"string"==typeof e?q(e,t):"boolean"==typeof e?j(e,t):N(e,t)}function j(e,t={}){let r=`0x${Number(e)}`;return"number"==typeof t.size?(F(r,{size:t.size}),T(r,{size:t.size})):r}function N(e,t={}){let r="";for(let t=0;t<e.length;t++)r+=D[e[t]];let n=`0x${r}`;return"number"==typeof t.size?(F(n,{size:t.size}),T(n,{dir:"right",size:t.size})):n}function V(e,t={}){let r;let{signed:n,size:i}=t,a=BigInt(e);i?r=n?(1n<<8n*BigInt(i)-1n)-1n:2n**(8n*BigInt(i))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));let o="bigint"==typeof r&&n?-r-1n:0;if(r&&a>r||a<o){let t="bigint"==typeof e?"n":"";throw new O({max:r?`${r}${t}`:void 0,min:`${o}${t}`,signed:n,size:i,value:`${e}${t}`})}let s=`0x${(n&&a<0?(1n<<BigInt(8*i))+BigInt(a):a).toString(16)}`;return i?T(s,{size:i}):s}let W=new TextEncoder;function q(e,t={}){return N(W.encode(e),t)}let H=new TextEncoder,J={zero:48,nine:57,A:65,F:70,a:97,f:102};function G(e){return e>=J.zero&&e<=J.nine?e-J.zero:e>=J.A&&e<=J.F?e-(J.A-10):e>=J.a&&e<=J.f?e-(J.a-10):void 0}function K(e,t={}){let r=e;t.size&&(F(r,{size:t.size}),r=T(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let i=n.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let r=G(n.charCodeAt(t++)),i=G(n.charCodeAt(t++));if(void 0===r||void 0===i)throw new $(`Invalid byte sequence ("${n[t-2]}${n[t-1]}" in "${n}").`);a[e]=16*r+i}return a}function X(e,t={}){let r=H.encode(e);return"number"==typeof t.size?(F(r,{size:t.size}),T(r,{dir:"right",size:t.size})):r}let Y="fCtx";function Q(e){if(e?.r)try{var t;return t=K(e.r),btoa(Array.from(t,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function Z(e){if(e&&0!==e.length)try{let t=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(e);return{r:N(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function ee({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(Y);return t?Z(t):null}function et({url:e,context:t}){if(!e)return null;let r=ee({url:e}),n=r?{...r,...t}:t;if(!n.r)return null;let i=Q(n);if(!i)return null;let a=new URL(e);return a.searchParams.set(Y,i),a.toString()}function er(e){let t=new URL(e);return t.searchParams.delete(Y),t.toString()}let en={compress:Q,decompress:Z,parse:ee,update:et,remove:er,replaceUrl:function({url:e,context:t}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(r=null!==t?et({url:n,context:t}):er(n))&&window.history.replaceState(null,"",r.toString())}},ei={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},ea=Object.entries(ei).reduce((e,[t,r])=>(e[t]=BigInt(1)<<BigInt(r),e),{}),eo={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};function es(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(ec(e.interactionToken),e));let r=new s,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),ec(e.interactionToken),n||(r.resolve(e),n=!0)}).then(()=>r.promise)}function ec(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}function el(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function eu(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function ef(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}let eh=BigInt(0x100000000-1),ed=BigInt(32),ep=(e,t,r)=>e<<r|t>>>32-r,ew=(e,t,r)=>t<<r|e>>>32-r,ey=(e,t,r)=>t<<r-32|e>>>64-r,em=(e,t,r)=>e<<r-32|t>>>64-r,eg=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function eb(e){for(let r=0;r<e.length;r++){var t;e[r]=(t=e[r])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function ex(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),eu(e),e}class ev{clone(){return this._cloneInto()}}let eS=[],eA=[],eI=[],ek=BigInt(0),eE=BigInt(1),ez=BigInt(2),eP=BigInt(7),e$=BigInt(256),eC=BigInt(113);for(let e=0,t=eE,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],eS.push(2*(5*n+r)),eA.push((e+1)*(e+2)/2%64);let i=ek;for(let e=0;e<7;e++)(t=(t<<eE^(t>>eP)*eC)%e$)&ez&&(i^=eE<<(eE<<BigInt(e))-eE);eI.push(i)}let[e_,eB]=function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=function(e,t=!1){return t?{h:Number(e&eh),l:Number(e>>ed&eh)}:{h:0|Number(e>>ed&eh),l:0|Number(e&eh)}}(e[i],t);[r[i],n[i]]=[a,o]}return[r,n]}(eI,!0),eT=(e,t,r)=>r>32?ey(e,t,r):ep(e,t,r),eU=(e,t,r)=>r>32?em(e,t,r):ew(e,t,r);class eO extends ev{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,el(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}(this.state)}keccak(){eg||eb(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,i=(t+2)%10,a=r[i],o=r[i+1],s=eT(a,o,1)^r[n],c=eU(a,o,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=s,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){let n=eA[r],a=eT(t,i,n),o=eU(t,i,n),s=eS[r];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=e_[n],e[1]^=eB[n]}r.fill(0)}(this.state32,this.rounds),eg||eb(this.state32),this.posOut=0,this.pos=0}update(e){ef(this);let{blockLen:t,state:r}=this,n=(e=ex(e)).length;for(let i=0;i<n;){let a=Math.min(t-this.pos,n-i);for(let t=0;t<a;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,(128&t)!=0&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){ef(this,!1),eu(e),this.finish();let t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();let a=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+a),n),this.posOut+=a,n+=a}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return el(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){eu(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:a}=this;return e||(e=new eO(t,r,n,a,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=a,e.destroyed=this.destroyed,e}}let eL=function(e){let t=t=>e().update(ex(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}(()=>new eO(136,1,32));function eR(e,t){let r=eL(C(e,{strict:!1})?function(e,t={}){return"number"==typeof e||"bigint"==typeof e?K(V(e,t)):"boolean"==typeof e?function(e,t={}){let r=new Uint8Array(1);return(r[0]=Number(e),"number"==typeof t.size)?(F(r,{size:t.size}),T(r,{size:t.size})):r}(e,t):C(e)?K(e,t):X(e,t)}(e):e);return"bytes"===(t||"hex")?r:M(r)}async function eF(e,{productId:t,interaction:r,validation:n}){let i=t??function({domain:e}){return eR(M(e??window.location.host))}(e.config);return await e.request({method:"frak_sendInteraction",params:[i,r,n]})}async function eD(e,{steps:t,metadata:r}){return await e.request({method:"frak_displayModal",params:[t,{...r,...e.config.metadata}]})}async function eM(e,t){await e.request({method:"frak_displayEmbededWallet",params:[t,e.config.metadata]})}async function ej(e,t){let{metadata:r}=e.config;await e.request({method:"frak_sso",params:[t,r.name,r.css]})}async function eN(e){return await e.request({method:"frak_getProductInformation"})}async function eV(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}let eW=256;async function eq(t,{siwe:r,metadata:n}){let i=t.config?.domain??window.location.host,a=r?.statement??`I confirm that I want to use my Frak wallet on: ${t.config.metadata.name}`,o={...r,statement:a,nonce:r?.nonce??function(t=11){if(!e||eW+t>512){e="",eW=0;for(let t=0;t<256;t++)e+=(256+256*Math.random()|0).toString(16).substring(1)}return e.substring(eW,eW+++t)}(96),uri:r?.uri??`https://${i}`,version:r?.version??"1",domain:i};return(await eD(t,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function eH(e,{tx:t,metadata:r}){return(await eD(e,{metadata:r,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function eJ(e,{metadata:t,login:r,openSession:n}){return function e(t,r){async function n(e){return e&&(r.metadata=e(r.metadata??{})),await eD(t,r)}return{params:r,sendTx:function(n){return e(t,{...r,steps:{...r.steps,sendTransaction:n}})},reward:function(n){return e(t,{...r,steps:{...r.steps,final:{...n,action:{key:"reward"}}}})},sharing:function(n,i){return e(t,{...r,steps:{...r.steps,final:{...i,action:{key:"sharing",options:n}}}})},display:n}}(e,{steps:{login:r??{},openSession:n??{}},metadata:t})}class eG extends ${constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class eK extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}let eX=new eK(8192),eY=/^0x[a-fA-F0-9]{40}$/,eQ=new eK(8192);function eZ(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(eQ.has(n))return eQ.get(n);let i=!!eY.test(e)&&(e.toLowerCase()===e||!r||function(e,t){if(eX.has(`${e}.${void 0}`))return eX.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=eR(X(r),"bytes"),i=(t?r.substring(`${t}0x`.length):r).split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&n[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let a=`0x${i.join("")}`;return eX.set(`${e}.${t}`,a),a}(e)===e);return eQ.set(n,i),i}function e0(e){return"string"==typeof e[0]?e1(e):function(e){let t=0;for(let r of e)t+=r.length;let r=new Uint8Array(t),n=0;for(let t of e)r.set(t,n),n+=t.length;return r}(e)}function e1(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}let e2={createLink:()=>({handlerTypeDenominator:M(ei.referral),interactionData:eo.referral.createLink}),referred({referrer:e}){let t=e1([eo.referral.referred,T(e,{size:32})]);return{handlerTypeDenominator:M(ei.referral),interactionData:t}}};async function e5(e,{walletStatus:r,frakContext:n,modalConfig:i,productId:a,options:s}){let c=!1;async function l(){if(!c)return c=!0,e3(e,{modalConfig:i,walletStatus:r})}async function u(t){let r=e2.referred({referrer:t});await eF(e,{productId:a,interaction:r})}try{let{status:e,currentWallet:t}=await e6({initialWalletStatus:r,getFreshWalletStatus:l,pushReferralInteraction:u,frakContext:n});return en.replaceUrl({url:window.location?.href,context:s?.alwaysAppendUrl?{r:t}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),en.replaceUrl({url:window.location?.href,context:s?.alwaysAppendUrl?{r:r?.wallet}:null}),function(e){if(e instanceof t)switch(e.code){case o.walletNotConnected:return"no-wallet";case o.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function e6({initialWalletStatus:e,getFreshWalletStatus:t,pushReferralInteraction:r,frakContext:n}){let i=e?.wallet;return n?.r?(i||(i=await t()),i&&function(e,t){if(!eZ(e,{strict:!1}))throw new eG({address:e});if(!eZ(t,{strict:!1}))throw new eG({address:t});return e.toLowerCase()===t.toLowerCase()}(n.r,i))?{status:"self-referral",currentWallet:i}:(e?.interactionSession||(i=await t()),await r(n.r),{status:"success",currentWallet:i}):{status:"no-referrer",currentWallet:i}}async function e3(e,{modalConfig:t,walletStatus:r}){if(!r?.interactionSession){if(!t)return;let r=await eD(e,t);return r?.login?.wallet??void 0}return r.wallet??void 0}async function e4(e,{productId:t,modalConfig:r,options:n}={}){let i=en.parse({url:window.location.href}),a=await es(e);try{return await e5(e,{walletStatus:a,frakContext:i,modalConfig:r,productId:t,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}let e8={openArticle({articleId:e}){let t=e1([eo.press.openArticle,T(e,{size:32})]);return{handlerTypeDenominator:M(ei.press),interactionData:t}},readArticle({articleId:e}){let t=e1([eo.press.readArticle,T(e,{size:32})]);return{handlerTypeDenominator:M(ei.press),interactionData:t}}};class e7 extends ${constructor({expectedLength:e,givenLength:t,type:r}){super(`ABI encoding array length mismatch for type ${r}.
|
|
15
15
|
Expected length: ${e}
|
|
16
|
-
Given length: ${t}`,{name:"AbiEncodingArrayLengthMismatchError"})}}class
|
|
16
|
+
Given length: ${t}`,{name:"AbiEncodingArrayLengthMismatchError"})}}class e9 extends ${constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${R(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class te extends ${constructor({expectedLength:e,givenLength:t}){super(`ABI encoding params/values length mismatch.
|
|
17
17
|
Expected length (params): ${e}
|
|
18
|
-
Given length (values): ${t}`,{name:"AbiEncodingLengthMismatchError"})}}class
|
|
19
|
-
Please provide a valid ABI type.`,{docsPath:t,name:"InvalidAbiEncodingType"})}}class
|
|
18
|
+
Given length (values): ${t}`,{name:"AbiEncodingLengthMismatchError"})}}class tt extends ${constructor(e,{docsPath:t}){super(`Type "${e}" is not a valid encoding type.
|
|
19
|
+
Please provide a valid ABI type.`,{docsPath:t,name:"InvalidAbiEncodingType"})}}class tr extends ${constructor(e){super(`Value "${e}" is not a valid array.`,{name:"InvalidArrayError"})}}function tn(e,t){if("number"==typeof t&&t>0&&t>R(e)-1)throw new _({offset:t,position:"start",size:R(e)})}function ti(e,t,r){if("number"==typeof t&&"number"==typeof r&&R(e)!==r-t)throw new _({offset:r,position:"end",size:R(e)})}let ta=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function to(e){let t=0;for(let r=0;r<e.length;r++){let{dynamic:n,encoded:i}=e[r];n?t+=32:t+=R(i)}let r=[],n=[],i=0;for(let a=0;a<e.length;a++){let{dynamic:o,encoded:s}=e[a];o?(r.push(V(t+i,{size:32})),n.push(s),i+=R(s)):r.push(s)}return e0([...r,...n])}let ts={startPurchase({purchaseId:e}){let t=e1([eo.purchase.started,T(e,{size:32})]);return{handlerTypeDenominator:M(ei.purchase),interactionData:t}},completedPurchase({purchaseId:e,proof:t}){let r=function(e,t){if(e.length!==t.length)throw new te({expectedLength:e.length,givenLength:t.length});let r=to(function({params:e,values:t}){let r=[];for(let n=0;n<e.length;n++)r.push(function e({param:t,value:r}){let n=function(e){let t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}(t.type);if(n){let[i,a]=n;return function(t,{length:r,param:n}){let i=null===r;if(!Array.isArray(t))throw new tr(t);if(!i&&t.length!==r)throw new e7({expectedLength:r,givenLength:t.length,type:`${n.type}[${r}]`});let a=!1,o=[];for(let r=0;r<t.length;r++){let i=e({param:n,value:t[r]});i.dynamic&&(a=!0),o.push(i)}if(i||a){let e=to(o);if(i){let t=V(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?e0([t,e]):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:e0(o.map(({encoded:e})=>e))}}(r,{length:i,param:{...t,type:a}})}if("tuple"===t.type)return function(t,{param:r}){let n=!1,i=[];for(let a=0;a<r.components.length;a++){let o=r.components[a],s=Array.isArray(t)?a:o.name,c=e({param:o,value:t[s]});i.push(c),c.dynamic&&(n=!0)}return{dynamic:n,encoded:n?to(i):e0(i.map(({encoded:e})=>e))}}(r,{param:t});if("address"===t.type)return function(e){if(!eZ(e))throw new eG({address:e});return{dynamic:!1,encoded:U(e.toLowerCase())}}(r);if("bool"===t.type)return function(e){if("boolean"!=typeof e)throw new $(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:U(j(e))}}(r);if(t.type.startsWith("uint")||t.type.startsWith("int")){let e=t.type.startsWith("int"),[,,n="256"]=ta.exec(t.type)??[];return function(e,{signed:t,size:r=256}){if("number"==typeof r){let n=2n**(BigInt(r)-(t?1n:0n))-1n,i=t?-n-1n:0n;if(e>n||e<i)throw new O({max:n.toString(),min:i.toString(),signed:t,size:r/8,value:e.toString()})}return{dynamic:!1,encoded:V(e,{size:32,signed:t})}}(r,{signed:e,size:Number(n)})}if(t.type.startsWith("bytes"))return function(e,{param:t}){let[,r]=t.type.split("bytes"),n=R(e);if(!r){let t=e;return n%32!=0&&(t=U(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:e0([U(V(n,{size:32})),t])}}if(n!==Number.parseInt(r))throw new e9({expectedSize:Number.parseInt(r),value:e});return{dynamic:!1,encoded:U(e,{dir:"right"})}}(r,{param:t});if("string"===t.type)return function(e){let t=q(e),r=Math.ceil(R(t)/32),n=[];for(let e=0;e<r;e++)n.push(U(function(e,t,r,{strict:n}={}){return C(e,{strict:!1})?function(e,t,r,{strict:n}={}){tn(e,t);let i=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&ti(i,t,r),i}(e,t,r,{strict:n}):function(e,t,r,{strict:n}={}){tn(e,t);let i=e.slice(t,r);return n&&ti(i,t,r),i}(e,t,r,{strict:n})}(t,32*e,(e+1)*32),{dir:"right"}));return{dynamic:!0,encoded:e0([U(V(R(t),{size:32})),...n])}}(r);throw new tt(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}({param:e[n],value:t[n]}));return r}({params:e,values:t}));return 0===r.length?"0x":r}([{type:"uint256"},{type:"bytes32[]"}],[BigInt(e),t]),n=e1([eo.purchase.completed,r]);return{handlerTypeDenominator:M(ei.purchase),interactionData:n}},unsafeCompletedPurchase({purchaseId:e}){let t=e1([eo.purchase.unsafeCompleted,T(e,{size:32})]);return{handlerTypeDenominator:M(ei.purchase),interactionData:t}}},tc={open:()=>({handlerTypeDenominator:M(ei.webshop),interactionData:eo.webshop.open})},tl={customerMeeting({agencyId:e}){let t=e1([eo.retail.customerMeeting,T(e,{size:32})]);return{handlerTypeDenominator:M(ei.retail),interactionData:t}}}})(),n})());
|
package/dist/actions.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=function(e,r){for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{processReferral:()=>processReferral,openSso:()=>openSso,sendInteraction:()=>sendInteraction,watchWalletStatus:()=>watchWalletStatus,referralInteraction:()=>referralInteraction,getProductInformation:()=>getProductInformation,displayModal:()=>displayModal,trackPurchaseStatus:()=>trackPurchaseStatus,sendTransaction:()=>sendTransaction,displayEmbededWallet:()=>displayEmbededWallet,siweAuthenticate:()=>siweAuthenticate,modalBuilder:()=>modalBuilder});class Deferred{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function watchWalletStatus(e,r){if(!r)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(savePotentialToken(e.interactionToken),e));let t=new Deferred,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{r(e),savePotentialToken(e.interactionToken),n||(t.resolve(e),n=!0)}).then(()=>t.promise)}function savePotentialToken(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}let external_viem_namespaceObject=require("viem");function computeProductId({domain:e}){let r=e??window.location.host;return(0,external_viem_namespaceObject.keccak256)((0,external_viem_namespaceObject.toHex)(r))}async function sendInteraction(e,{productId:r,interaction:t,validation:n}){let a=r??computeProductId(e.config);return await e.request({method:"frak_sendInteraction",params:[a,t,n]})}async function displayModal(e,{steps:r,metadata:t}){return await e.request({method:"frak_displayModal",params:[r,e.config.metadata.name,t]})}async function displayEmbededWallet(e,r){await e.request({method:"frak_displayEmbededWallet",params:[r,e.config.metadata.name]})}async function openSso(e,r){let{metadata:t}=e.config;await e.request({method:"frak_sso",params:[r,t.name,t.css]})}async function getProductInformation(e){return await e.request({method:"frak_getProductInformation"})}async function trackPurchaseStatus(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let r=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!r){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":r},body:JSON.stringify(e)})}let siwe_namespaceObject=require("viem/siwe");async function siweAuthenticate(e,{siwe:r,metadata:t}){let n=e.config?.domain??window.location.host,a=r?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,o={...r,statement:a,nonce:r?.nonce??(0,siwe_namespaceObject.generateSiweNonce)(),uri:r?.uri??`https://${n}`,version:r?.version??"1",domain:n};return(await displayModal(e,{metadata:t,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function sendTransaction(e,{tx:r,metadata:t}){return(await displayModal(e,{metadata:t,steps:{login:{},sendTransaction:{tx:r}}})).sendTransaction}function modalBuilder(e,{metadata:r,login:t,openSession:n}){return modalStepsBuilder(e,{steps:{login:t??{},openSession:n??{}},metadata:r})}function modalStepsBuilder(e,r){async function t(t){return t&&(r.metadata=t(r.metadata??{})),await displayModal(e,r)}return{params:r,sendTx:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,sendTransaction:t}})},reward:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...t,action:{key:"reward"}}}})},sharing:function(t,n){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...n,action:{key:"sharing",options:t}}}})},display:t}}let contextKey="fCtx";function base64url_encode(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function base64url_decode(e){let r=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===r?0:4-r),"=")),e=>e.charCodeAt(0))}function compress(e){if(e?.r)try{let r=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64url_encode(r)}catch(r){console.error("Error compressing Frak context",{e:r,context:e})}}function decompress(e){if(e&&0!==e.length)try{let r=base64url_decode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(r,{size:20})}}catch(r){console.error("Error decompressing Frak context",{e:r,context:e})}}function parse({url:e}){if(!e)return null;let r=new URL(e).searchParams.get(contextKey);return r?decompress(r):null}function update({url:e,context:r}){if(!e)return null;let t=parse({url:e}),n=t?{...t,...r}:r;if(!n.r)return null;let a=compress(n);if(!a)return null;let o=new URL(e);return o.searchParams.set(contextKey,a),o.toString()}function remove(e){let r=new URL(e);return r.searchParams.delete(contextKey),r.toString()}function replaceUrl({url:e,context:r}){let t;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(t=null!==r?update({url:n,context:r}):remove(n))&&window.history.replaceState(null,"",t.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl},interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}};class FrakRpcError extends Error{code;data;constructor(e,r,t){super(r),this.code=e,this.data=t}}class MethodNotFoundError extends FrakRpcError{constructor(e,r){super(RpcErrorCodes.methodNotFound,e,{method:r})}}class InternalError extends FrakRpcError{constructor(e){super(RpcErrorCodes.internalError,e)}}class ClientNotFound extends FrakRpcError{constructor(){super(RpcErrorCodes.clientNotConnected,"Client not found")}}let RpcErrorCodes={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function processReferral(e,{walletStatus:r,frakContext:t,modalConfig:n,productId:a,options:o}){let s=!1;async function c(){if(!s)return s=!0,ensureWalletConnected(e,{modalConfig:n,walletStatus:r})}async function i(r){let t=ReferralInteractionEncoder.referred({referrer:r});await sendInteraction(e,{productId:a,interaction:t})}try{let{status:e,currentWallet:n}=await processReferralLogic({initialWalletStatus:r,getFreshWalletStatus:c,pushReferralInteraction:i,frakContext:t});return FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:n}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:r?.wallet}:null}),mapErrorToState(e)}}async function processReferralLogic({initialWalletStatus:e,getFreshWalletStatus:r,pushReferralInteraction:t,frakContext:n}){let a=e?.wallet;return n?.r?(a||(a=await r()),a&&(0,external_viem_namespaceObject.isAddressEqual)(n.r,a))?{status:"self-referral",currentWallet:a}:(e?.interactionSession||(a=await r()),await t(n.r),{status:"success",currentWallet:a}):{status:"no-referrer",currentWallet:a}}async function ensureWalletConnected(e,{modalConfig:r,walletStatus:t}){if(!t?.interactionSession){if(!r)return;let t=await displayModal(e,r);return t?.login?.wallet??void 0}return t.wallet??void 0}function mapErrorToState(e){if(e instanceof FrakRpcError)switch(e.code){case RpcErrorCodes.walletNotConnected:return"no-wallet";case RpcErrorCodes.serverErrorForInteractionDelegation:return"no-session"}return"error"}async function referralInteraction(e,{productId:r,modalConfig:t,options:n}={}){let a=FrakContextManager.parse({url:window.location.href}),o=await watchWalletStatus(e);try{return await processReferral(e,{walletStatus:o,frakContext:a,modalConfig:t,productId:r,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
|
|
1
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{openSso:()=>openSso,referralInteraction:()=>referralInteraction,trackPurchaseStatus:()=>trackPurchaseStatus,modalBuilder:()=>modalBuilder,processReferral:()=>processReferral,sendTransaction:()=>sendTransaction,displayModal:()=>displayModal,getProductInformation:()=>getProductInformation,displayEmbededWallet:()=>displayEmbededWallet,sendInteraction:()=>sendInteraction,siweAuthenticate:()=>siweAuthenticate,watchWalletStatus:()=>watchWalletStatus});class Deferred{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function watchWalletStatus(e,r){if(!r)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(savePotentialToken(e.interactionToken),e));let t=new Deferred,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{r(e),savePotentialToken(e.interactionToken),n||(t.resolve(e),n=!0)}).then(()=>t.promise)}function savePotentialToken(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}let external_viem_namespaceObject=require("viem");function computeProductId({domain:e}){let r=e??window.location.host;return(0,external_viem_namespaceObject.keccak256)((0,external_viem_namespaceObject.toHex)(r))}async function sendInteraction(e,{productId:r,interaction:t,validation:n}){let a=r??computeProductId(e.config);return await e.request({method:"frak_sendInteraction",params:[a,t,n]})}async function displayModal(e,{steps:r,metadata:t}){return await e.request({method:"frak_displayModal",params:[r,{...t,...e.config.metadata}]})}async function displayEmbededWallet(e,r){await e.request({method:"frak_displayEmbededWallet",params:[r,e.config.metadata]})}async function openSso(e,r){let{metadata:t}=e.config;await e.request({method:"frak_sso",params:[r,t.name,t.css]})}async function getProductInformation(e){return await e.request({method:"frak_getProductInformation"})}async function trackPurchaseStatus(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let r=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!r){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":r},body:JSON.stringify(e)})}let siwe_namespaceObject=require("viem/siwe");async function siweAuthenticate(e,{siwe:r,metadata:t}){let n=e.config?.domain??window.location.host,a=r?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,o={...r,statement:a,nonce:r?.nonce??(0,siwe_namespaceObject.generateSiweNonce)(),uri:r?.uri??`https://${n}`,version:r?.version??"1",domain:n};return(await displayModal(e,{metadata:t,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function sendTransaction(e,{tx:r,metadata:t}){return(await displayModal(e,{metadata:t,steps:{login:{},sendTransaction:{tx:r}}})).sendTransaction}function modalBuilder(e,{metadata:r,login:t,openSession:n}){return modalStepsBuilder(e,{steps:{login:t??{},openSession:n??{}},metadata:r})}function modalStepsBuilder(e,r){async function t(t){return t&&(r.metadata=t(r.metadata??{})),await displayModal(e,r)}return{params:r,sendTx:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,sendTransaction:t}})},reward:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...t,action:{key:"reward"}}}})},sharing:function(t,n){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...n,action:{key:"sharing",options:t}}}})},display:t}}let contextKey="fCtx";function base64url_encode(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function base64url_decode(e){let r=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===r?0:4-r),"=")),e=>e.charCodeAt(0))}function compress(e){if(e?.r)try{let r=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64url_encode(r)}catch(r){console.error("Error compressing Frak context",{e:r,context:e})}}function decompress(e){if(e&&0!==e.length)try{let r=base64url_decode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(r,{size:20})}}catch(r){console.error("Error decompressing Frak context",{e:r,context:e})}}function parse({url:e}){if(!e)return null;let r=new URL(e).searchParams.get(contextKey);return r?decompress(r):null}function update({url:e,context:r}){if(!e)return null;let t=parse({url:e}),n=t?{...t,...r}:r;if(!n.r)return null;let a=compress(n);if(!a)return null;let o=new URL(e);return o.searchParams.set(contextKey,a),o.toString()}function remove(e){let r=new URL(e);return r.searchParams.delete(contextKey),r.toString()}function replaceUrl({url:e,context:r}){let t;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(t=null!==r?update({url:n,context:r}):remove(n))&&window.history.replaceState(null,"",t.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl},interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}};class FrakRpcError extends Error{code;data;constructor(e,r,t){super(r),this.code=e,this.data=t}}class MethodNotFoundError extends FrakRpcError{constructor(e,r){super(RpcErrorCodes.methodNotFound,e,{method:r})}}class InternalError extends FrakRpcError{constructor(e){super(RpcErrorCodes.internalError,e)}}class ClientNotFound extends FrakRpcError{constructor(){super(RpcErrorCodes.clientNotConnected,"Client not found")}}let RpcErrorCodes={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function processReferral(e,{walletStatus:r,frakContext:t,modalConfig:n,productId:a,options:o}){let s=!1;async function c(){if(!s)return s=!0,ensureWalletConnected(e,{modalConfig:n,walletStatus:r})}async function i(r){let t=ReferralInteractionEncoder.referred({referrer:r});await sendInteraction(e,{productId:a,interaction:t})}try{let{status:e,currentWallet:n}=await processReferralLogic({initialWalletStatus:r,getFreshWalletStatus:c,pushReferralInteraction:i,frakContext:t});return FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:n}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:r?.wallet}:null}),mapErrorToState(e)}}async function processReferralLogic({initialWalletStatus:e,getFreshWalletStatus:r,pushReferralInteraction:t,frakContext:n}){let a=e?.wallet;return n?.r?(a||(a=await r()),a&&(0,external_viem_namespaceObject.isAddressEqual)(n.r,a))?{status:"self-referral",currentWallet:a}:(e?.interactionSession||(a=await r()),await t(n.r),{status:"success",currentWallet:a}):{status:"no-referrer",currentWallet:a}}async function ensureWalletConnected(e,{modalConfig:r,walletStatus:t}){if(!t?.interactionSession){if(!r)return;let t=await displayModal(e,r);return t?.login?.wallet??void 0}return t.wallet??void 0}function mapErrorToState(e){if(e instanceof FrakRpcError)switch(e.code){case RpcErrorCodes.walletNotConnected:return"no-wallet";case RpcErrorCodes.serverErrorForInteractionDelegation:return"no-session"}return"error"}async function referralInteraction(e,{productId:r,modalConfig:t,options:n}={}){let a=FrakContextManager.parse({url:window.location.href}),o=await watchWalletStatus(e);try{return await processReferral(e,{walletStatus:o,frakContext:a,modalConfig:t,productId:r,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
|
package/dist/actions.d.cts
CHANGED
|
@@ -4,6 +4,11 @@ import type { Prettify } from 'viem/chains';
|
|
|
4
4
|
import type { RpcSchema } from 'viem';
|
|
5
5
|
import type { SiweMessage } from 'viem/siwe';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* All the currencies available
|
|
9
|
+
*/
|
|
10
|
+
declare type Currency = "eur" | "usd" | "gbp";
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* Function used to display the Frak embeded wallet popup
|
|
9
14
|
* @param client - The current Frak Client
|
|
@@ -29,11 +34,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
29
34
|
* Some metadata to customise the embeded view
|
|
30
35
|
*/
|
|
31
36
|
metadata?: {
|
|
32
|
-
/**
|
|
33
|
-
* Language of the embeded wallet
|
|
34
|
-
* If undefined, will default to the browser language
|
|
35
|
-
*/
|
|
36
|
-
lang?: "fr" | "en";
|
|
37
37
|
/**
|
|
38
38
|
* The logo to display on the embeded wallet
|
|
39
39
|
* If undefined, will default to no logo displayed
|
|
@@ -60,7 +60,7 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
60
60
|
* @param client - The current Frak Client
|
|
61
61
|
* @param args
|
|
62
62
|
* @param args.steps - The different steps of the modal
|
|
63
|
-
* @param args.metadata - The metadata for the modal (customisation,
|
|
63
|
+
* @param args.metadata - The metadata for the modal (customisation, etc)
|
|
64
64
|
* @returns The result of each modal steps
|
|
65
65
|
*
|
|
66
66
|
* @description This function will display a modal to the user with the provided steps and metadata.
|
|
@@ -183,8 +183,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
183
183
|
* },
|
|
184
184
|
* // Context that will be present in every modal steps
|
|
185
185
|
* context: "My-app overkill flow",
|
|
186
|
-
* // Language of the modal
|
|
187
|
-
* lang: "fr",
|
|
188
186
|
* },
|
|
189
187
|
* });
|
|
190
188
|
* ```
|
|
@@ -326,6 +324,16 @@ declare type FrakWalletSdkConfig = {
|
|
|
326
324
|
* Custom CSS styles to apply to the modals and components
|
|
327
325
|
*/
|
|
328
326
|
css?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Language to display in the modal
|
|
329
|
+
* If undefined, will default to the browser language
|
|
330
|
+
*/
|
|
331
|
+
lang?: "fr" | "en";
|
|
332
|
+
/**
|
|
333
|
+
* The currency to display in the modal
|
|
334
|
+
* @defaultValue `"eur"`
|
|
335
|
+
*/
|
|
336
|
+
currency?: Currency;
|
|
329
337
|
};
|
|
330
338
|
/**
|
|
331
339
|
* The domain name of your application
|
|
@@ -387,9 +395,13 @@ declare type GetProductInformationReturnType = {
|
|
|
387
395
|
productTypes: ProductTypesKey[];
|
|
388
396
|
};
|
|
389
397
|
/**
|
|
390
|
-
* The max potential reward
|
|
398
|
+
* The max potential reward for the referrer
|
|
399
|
+
*/
|
|
400
|
+
maxReferrer?: TokenAmountType;
|
|
401
|
+
/**
|
|
402
|
+
* The max potential reward for the referee
|
|
391
403
|
*/
|
|
392
|
-
|
|
404
|
+
maxReferee?: TokenAmountType;
|
|
393
405
|
/**
|
|
394
406
|
* List of all the potentials reward arround this product
|
|
395
407
|
*/
|
|
@@ -397,16 +409,8 @@ declare type GetProductInformationReturnType = {
|
|
|
397
409
|
token: Address;
|
|
398
410
|
campaign: Address;
|
|
399
411
|
interactionTypeKey: FullInteractionTypesKey;
|
|
400
|
-
referrer:
|
|
401
|
-
|
|
402
|
-
eurAmount: number;
|
|
403
|
-
usdAmount: number;
|
|
404
|
-
};
|
|
405
|
-
referee: {
|
|
406
|
-
amount: number;
|
|
407
|
-
eurAmount: number;
|
|
408
|
-
usdAmount: number;
|
|
409
|
-
};
|
|
412
|
+
referrer: TokenAmountType;
|
|
413
|
+
referee: TokenAmountType;
|
|
410
414
|
}[];
|
|
411
415
|
};
|
|
412
416
|
|
|
@@ -460,8 +464,7 @@ declare type IFrameRpcSchema = [
|
|
|
460
464
|
Method: "frak_displayModal";
|
|
461
465
|
Parameters: [
|
|
462
466
|
requests: ModalRpcStepsInput,
|
|
463
|
-
|
|
464
|
-
metadata?: ModalRpcMetadata
|
|
467
|
+
metadata: FrakWalletSdkConfig["metadata"] & ModalRpcMetadata
|
|
465
468
|
];
|
|
466
469
|
ReturnType: ModalRpcStepsResultType;
|
|
467
470
|
},
|
|
@@ -506,7 +509,10 @@ declare type IFrameRpcSchema = [
|
|
|
506
509
|
*/
|
|
507
510
|
{
|
|
508
511
|
Method: "frak_displayEmbededWallet";
|
|
509
|
-
Parameters: [
|
|
512
|
+
Parameters: [
|
|
513
|
+
DisplayEmbededWalletParamsType,
|
|
514
|
+
metadata: FrakWalletSdkConfig["metadata"]
|
|
515
|
+
];
|
|
510
516
|
ReturnType: undefined;
|
|
511
517
|
}
|
|
512
518
|
];
|
|
@@ -696,7 +702,6 @@ declare type ModalRpcMetadata = {
|
|
|
696
702
|
icon?: string;
|
|
697
703
|
};
|
|
698
704
|
context?: string;
|
|
699
|
-
lang?: "en" | "fr";
|
|
700
705
|
targetInteraction?: FullInteractionTypesKey;
|
|
701
706
|
} & ({
|
|
702
707
|
isDismissible: true;
|
|
@@ -1200,6 +1205,16 @@ declare type SsoMetadata = {
|
|
|
1200
1205
|
homepageLink?: string;
|
|
1201
1206
|
};
|
|
1202
1207
|
|
|
1208
|
+
/**
|
|
1209
|
+
* The type for the amount of tokens
|
|
1210
|
+
*/
|
|
1211
|
+
declare type TokenAmountType = {
|
|
1212
|
+
amount: number;
|
|
1213
|
+
eurAmount: number;
|
|
1214
|
+
usdAmount: number;
|
|
1215
|
+
gbpAmount: number;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1203
1218
|
/**
|
|
1204
1219
|
* Function used to track the status of a purchase
|
|
1205
1220
|
* when a purchase is tracked, the `purchaseCompleted` interactions will be automatically send for the user when we receive the purchase confirmation via webhook.
|
package/dist/actions.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import type { Prettify } from 'viem/chains';
|
|
|
4
4
|
import type { RpcSchema } from 'viem';
|
|
5
5
|
import type { SiweMessage } from 'viem/siwe';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* All the currencies available
|
|
9
|
+
*/
|
|
10
|
+
declare type Currency = "eur" | "usd" | "gbp";
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* Function used to display the Frak embeded wallet popup
|
|
9
14
|
* @param client - The current Frak Client
|
|
@@ -29,11 +34,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
29
34
|
* Some metadata to customise the embeded view
|
|
30
35
|
*/
|
|
31
36
|
metadata?: {
|
|
32
|
-
/**
|
|
33
|
-
* Language of the embeded wallet
|
|
34
|
-
* If undefined, will default to the browser language
|
|
35
|
-
*/
|
|
36
|
-
lang?: "fr" | "en";
|
|
37
37
|
/**
|
|
38
38
|
* The logo to display on the embeded wallet
|
|
39
39
|
* If undefined, will default to no logo displayed
|
|
@@ -60,7 +60,7 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
60
60
|
* @param client - The current Frak Client
|
|
61
61
|
* @param args
|
|
62
62
|
* @param args.steps - The different steps of the modal
|
|
63
|
-
* @param args.metadata - The metadata for the modal (customisation,
|
|
63
|
+
* @param args.metadata - The metadata for the modal (customisation, etc)
|
|
64
64
|
* @returns The result of each modal steps
|
|
65
65
|
*
|
|
66
66
|
* @description This function will display a modal to the user with the provided steps and metadata.
|
|
@@ -183,8 +183,6 @@ declare type DisplayEmbededWalletParamsType = {
|
|
|
183
183
|
* },
|
|
184
184
|
* // Context that will be present in every modal steps
|
|
185
185
|
* context: "My-app overkill flow",
|
|
186
|
-
* // Language of the modal
|
|
187
|
-
* lang: "fr",
|
|
188
186
|
* },
|
|
189
187
|
* });
|
|
190
188
|
* ```
|
|
@@ -326,6 +324,16 @@ declare type FrakWalletSdkConfig = {
|
|
|
326
324
|
* Custom CSS styles to apply to the modals and components
|
|
327
325
|
*/
|
|
328
326
|
css?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Language to display in the modal
|
|
329
|
+
* If undefined, will default to the browser language
|
|
330
|
+
*/
|
|
331
|
+
lang?: "fr" | "en";
|
|
332
|
+
/**
|
|
333
|
+
* The currency to display in the modal
|
|
334
|
+
* @defaultValue `"eur"`
|
|
335
|
+
*/
|
|
336
|
+
currency?: Currency;
|
|
329
337
|
};
|
|
330
338
|
/**
|
|
331
339
|
* The domain name of your application
|
|
@@ -387,9 +395,13 @@ declare type GetProductInformationReturnType = {
|
|
|
387
395
|
productTypes: ProductTypesKey[];
|
|
388
396
|
};
|
|
389
397
|
/**
|
|
390
|
-
* The max potential reward
|
|
398
|
+
* The max potential reward for the referrer
|
|
399
|
+
*/
|
|
400
|
+
maxReferrer?: TokenAmountType;
|
|
401
|
+
/**
|
|
402
|
+
* The max potential reward for the referee
|
|
391
403
|
*/
|
|
392
|
-
|
|
404
|
+
maxReferee?: TokenAmountType;
|
|
393
405
|
/**
|
|
394
406
|
* List of all the potentials reward arround this product
|
|
395
407
|
*/
|
|
@@ -397,16 +409,8 @@ declare type GetProductInformationReturnType = {
|
|
|
397
409
|
token: Address;
|
|
398
410
|
campaign: Address;
|
|
399
411
|
interactionTypeKey: FullInteractionTypesKey;
|
|
400
|
-
referrer:
|
|
401
|
-
|
|
402
|
-
eurAmount: number;
|
|
403
|
-
usdAmount: number;
|
|
404
|
-
};
|
|
405
|
-
referee: {
|
|
406
|
-
amount: number;
|
|
407
|
-
eurAmount: number;
|
|
408
|
-
usdAmount: number;
|
|
409
|
-
};
|
|
412
|
+
referrer: TokenAmountType;
|
|
413
|
+
referee: TokenAmountType;
|
|
410
414
|
}[];
|
|
411
415
|
};
|
|
412
416
|
|
|
@@ -460,8 +464,7 @@ declare type IFrameRpcSchema = [
|
|
|
460
464
|
Method: "frak_displayModal";
|
|
461
465
|
Parameters: [
|
|
462
466
|
requests: ModalRpcStepsInput,
|
|
463
|
-
|
|
464
|
-
metadata?: ModalRpcMetadata
|
|
467
|
+
metadata: FrakWalletSdkConfig["metadata"] & ModalRpcMetadata
|
|
465
468
|
];
|
|
466
469
|
ReturnType: ModalRpcStepsResultType;
|
|
467
470
|
},
|
|
@@ -506,7 +509,10 @@ declare type IFrameRpcSchema = [
|
|
|
506
509
|
*/
|
|
507
510
|
{
|
|
508
511
|
Method: "frak_displayEmbededWallet";
|
|
509
|
-
Parameters: [
|
|
512
|
+
Parameters: [
|
|
513
|
+
DisplayEmbededWalletParamsType,
|
|
514
|
+
metadata: FrakWalletSdkConfig["metadata"]
|
|
515
|
+
];
|
|
510
516
|
ReturnType: undefined;
|
|
511
517
|
}
|
|
512
518
|
];
|
|
@@ -696,7 +702,6 @@ declare type ModalRpcMetadata = {
|
|
|
696
702
|
icon?: string;
|
|
697
703
|
};
|
|
698
704
|
context?: string;
|
|
699
|
-
lang?: "en" | "fr";
|
|
700
705
|
targetInteraction?: FullInteractionTypesKey;
|
|
701
706
|
} & ({
|
|
702
707
|
isDismissible: true;
|
|
@@ -1200,6 +1205,16 @@ declare type SsoMetadata = {
|
|
|
1200
1205
|
homepageLink?: string;
|
|
1201
1206
|
};
|
|
1202
1207
|
|
|
1208
|
+
/**
|
|
1209
|
+
* The type for the amount of tokens
|
|
1210
|
+
*/
|
|
1211
|
+
declare type TokenAmountType = {
|
|
1212
|
+
amount: number;
|
|
1213
|
+
eurAmount: number;
|
|
1214
|
+
usdAmount: number;
|
|
1215
|
+
gbpAmount: number;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1203
1218
|
/**
|
|
1204
1219
|
* Function used to track the status of a purchase
|
|
1205
1220
|
* when a purchase is tracked, the `purchaseCompleted` interactions will be automatically send for the user when we receive the purchase confirmation via webhook.
|
package/dist/actions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"viem";import*as t from"viem/siwe";class n{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function r(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(a(e.interactionToken),e));let r=new n,o=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),a(e.interactionToken),o||(r.resolve(e),o=!0)}).then(()=>r.promise)}function a(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}async function o(t,{productId:n,interaction:r,validation:a}){let o=n??function({domain:t}){let n=t??window.location.host;return(0,e.keccak256)((0,e.toHex)(n))}(t.config);return await t.request({method:"frak_sendInteraction",params:[o,r,a]})}async function i(e,{steps:t,metadata:n}){return await e.request({method:"frak_displayModal",params:[t,e.config.metadata
|
|
1
|
+
import*as e from"viem";import*as t from"viem/siwe";class n{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function r(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(a(e.interactionToken),e));let r=new n,o=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),a(e.interactionToken),o||(r.resolve(e),o=!0)}).then(()=>r.promise)}function a(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}async function o(t,{productId:n,interaction:r,validation:a}){let o=n??function({domain:t}){let n=t??window.location.host;return(0,e.keccak256)((0,e.toHex)(n))}(t.config);return await t.request({method:"frak_sendInteraction",params:[o,r,a]})}async function i(e,{steps:t,metadata:n}){return await e.request({method:"frak_displayModal",params:[t,{...n,...e.config.metadata}]})}async function s(e,t){await e.request({method:"frak_displayEmbededWallet",params:[t,e.config.metadata]})}async function c(e,t){let{metadata:n}=e.config;await e.request({method:"frak_sso",params:[t,n.name,n.css]})}async function l(e){return await e.request({method:"frak_getProductInformation"})}async function u(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}async function f(e,{siwe:n,metadata:r}){let a=e.config?.domain??window.location.host,o=n?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,s={...n,statement:o,nonce:n?.nonce??(0,t.generateSiweNonce)(),uri:n?.uri??`https://${a}`,version:n?.version??"1",domain:a};return(await i(e,{metadata:r,steps:{login:{},siweAuthenticate:{siwe:s}}})).siweAuthenticate}async function d(e,{tx:t,metadata:n}){return(await i(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function w(e,{metadata:t,login:n,openSession:r}){return function e(t,n){async function r(e){return e&&(n.metadata=e(n.metadata??{})),await i(t,n)}return{params:n,sendTx:function(r){return e(t,{...n,steps:{...n.steps,sendTransaction:r}})},reward:function(r){return e(t,{...n,steps:{...n.steps,final:{...r,action:{key:"reward"}}}})},sharing:function(r,a){return e(t,{...n,steps:{...n.steps,final:{...a,action:{key:"sharing",options:r}}}})},display:r}}(e,{steps:{login:n??{},openSession:r??{}},metadata:t})}let p="fCtx";function h({url:t}){if(!t)return null;let n=new URL(t).searchParams.get(p);return n?function(t){if(t&&0!==t.length)try{let n=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(t);return{r:(0,e.bytesToHex)(n,{size:20})}}catch(e){console.error("Error decompressing Frak context",{e,context:t})}}(n):null}let m={parse:h,replaceUrl:function({url:t,context:n}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let a=t??window.location.href;(r=null!==n?function({url:t,context:n}){if(!t)return null;let r=h({url:t}),a=r?{...r,...n}:n;if(!a.r)return null;let o=function(t){if(t?.r)try{var n;return n=(0,e.hexToBytes)(t.r),btoa(Array.from(n,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){console.error("Error compressing Frak context",{e,context:t})}}(a);if(!o)return null;let i=new URL(t);return i.searchParams.set(p,o),i.toString()}({url:a,context:n}):function(e){let t=new URL(e);return t.searchParams.delete(p),t.toString()}(a))&&window.history.replaceState(null,"",r.toString())}},g="0x010cc3b9",y="0xb2c0f17c",k={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31};Object.entries(k).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{});let S={createLink:()=>({handlerTypeDenominator:(0,e.toHex)(k.referral),interactionData:y}),referred({referrer:t}){let n=(0,e.concatHex)([g,(0,e.pad)(t,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(k.referral),interactionData:n}}};class x extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}}let _={walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function v(e,{walletStatus:t,frakContext:n,modalConfig:r,productId:a,options:i}){let s=!1;async function c(){if(!s)return s=!0,I(e,{modalConfig:r,walletStatus:t})}async function l(t){let n=S.referred({referrer:t});await o(e,{productId:a,interaction:n})}try{let{status:e,currentWallet:r}=await T({initialWalletStatus:t,getFreshWalletStatus:c,pushReferralInteraction:l,frakContext:n});return m.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:r}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),m.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),function(e){if(e instanceof x)switch(e.code){case _.walletNotConnected:return"no-wallet";case _.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function T({initialWalletStatus:t,getFreshWalletStatus:n,pushReferralInteraction:r,frakContext:a}){let o=t?.wallet;return a?.r?(o||(o=await n()),o&&(0,e.isAddressEqual)(a.r,o))?{status:"self-referral",currentWallet:o}:(t?.interactionSession||(o=await n()),await r(a.r),{status:"success",currentWallet:o}):{status:"no-referrer",currentWallet:o}}async function I(e,{modalConfig:t,walletStatus:n}){if(!n?.interactionSession){if(!t)return;let n=await i(e,t);return n?.login?.wallet??void 0}return n.wallet??void 0}async function b(e,{productId:t,modalConfig:n,options:a}={}){let o=m.parse({url:window.location.href}),i=await r(e);try{return await v(e,{walletStatus:i,frakContext:o,modalConfig:n,productId:t,options:a})}catch(e){console.warn("Error processing referral",{error:e})}}export{s as displayEmbededWallet,i as displayModal,l as getProductInformation,w as modalBuilder,c as openSso,v as processReferral,b as referralInteraction,o as sendInteraction,d as sendTransaction,f as siweAuthenticate,u as trackPurchaseStatus,r as watchWalletStatus};
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=
|
|
1
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{hashAndCompressData:()=>hashAndCompressData,RpcErrorCodes:()=>RpcErrorCodes,setupClient:()=>setupClient,Deferred:()=>Deferred,getCurrencyAmountKey:()=>getCurrencyAmountKey,getSupportedCurrency:()=>getSupportedCurrency,decompressDataAndCheckHash:()=>decompressDataAndCheckHash,FrakContextManager:()=>FrakContextManager,getSupportedLocale:()=>getSupportedLocale,locales:()=>locales,productTypes:()=>productTypes,ClientNotFound:()=>ClientNotFound,baseIframeProps:()=>baseIframeProps,FrakRpcError:()=>FrakRpcError,createIframe:()=>createIframe,productTypesMask:()=>productTypesMask,interactionTypes:()=>interactionTypes,compressJson:()=>compressJson,decompressJson:()=>decompressJson,DebugInfoGatherer:()=>DebugInfoGatherer,createIFrameFrakClient:()=>createIFrameFrakClient,formatAmount:()=>formatAmount});class FrakRpcError extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}}class MethodNotFoundError extends FrakRpcError{constructor(e,t){super(RpcErrorCodes.methodNotFound,e,{method:t})}}class InternalError extends FrakRpcError{constructor(e){super(RpcErrorCodes.internalError,e)}}class ClientNotFound extends FrakRpcError{constructor(){super(RpcErrorCodes.clientNotConnected,"Client not found")}}let RpcErrorCodes={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class DebugInfoGatherer{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn("Failed to encode debug data",e),btoa("Failed to encode data")}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute("loading"),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?+("complete"===this.iframe.contentDocument.readyState):-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),r=this.getNavigatorInfo(),a="Unknown";return e instanceof FrakRpcError?a=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?a=e.message:"string"==typeof e&&(a=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):"no-config",navigatorInfo:r?this.base64Encode(r):"no-navigator",iframeStatus:t?this.base64Encode(t):"not-iframe",lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):"No Frak request logged",lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):"No Frak response logged",clientStatus:this.isSetupDone?"setup":"not-setup",error:a}}static empty(){return new DebugInfoGatherer}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
|
|
2
2
|
Debug Information:
|
|
3
3
|
-----------------
|
|
4
4
|
Timestamp: ${t.timestamp}
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
Last Response: ${t.lastResponse}
|
|
11
11
|
Client Status: ${t.clientStatus}
|
|
12
12
|
Error: ${t.error}
|
|
13
|
-
`.trim()}}function createIFrameChannelManager(){let e=new Map;return{createChannel:t=>{let r=Math.random().toString(36).substring(7);return e.set(r,t),r},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}let baseIframeProps={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function createIframe({walletBaseUrl:e,config:t}){let r=document.querySelector("#nexus-wallet");r&&r.remove();let a=document.createElement("iframe");return a.id=baseIframeProps.id,a.name=baseIframeProps.name,a.allow=baseIframeProps.allow,a.style.zIndex=baseIframeProps.style.zIndex.toString(),changeIframeVisibility({iframe:a,isVisible:!1}),document.body.appendChild(a),new Promise(r=>{a?.addEventListener("load",()=>r(a)),a.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function changeIframeVisibility({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function createIFrameLifecycleManager({iframe:e}){let t=new Deferred;return{handleEvent:async r=>{switch(r.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":r.data.backup?localStorage.setItem(BACKUP_KEY,r.data.backup):localStorage.removeItem(BACKUP_KEY);break;case"remove-backup":localStorage.removeItem(BACKUP_KEY);break;case"show":case"hide":changeIframeVisibility({iframe:e,isVisible:"show"===r.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:r.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}function createIFrameMessageHandler({frakWalletUrl:e,iframe:t,channelManager:r,iframeLifecycleManager:a,debugInfo:n}){if("undefined"==typeof window)throw new FrakRpcError(RpcErrorCodes.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new FrakRpcError(RpcErrorCodes.configError,"The iframe does not have a product window");let o=t.contentWindow;async function s(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(n.setLastResponse(t),"iframeLifecycle"in t.data){await a.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let o=t.data.id,s=r.getRpcResolver(o);s&&await s(t.data)}return window.addEventListener("message",s),{sendEvent:function(t){o.postMessage(t,{targetOrigin:e}),n.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",s)}}}function createIFrameFrakClient({config:e,iframe:t}){let r=createIFrameChannelManager(),a=createIFrameLifecycleManager({iframe:t}),n=new DebugInfoGatherer(e,t),o=createIFrameMessageHandler({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:r,iframeLifecycleManager:a,debugInfo:n}),s=async e=>{if(!await a.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let t=new Deferred,n=r.createChannel(async e=>{let a=await decompressDataAndCheckHash(e.data);a.error?t.reject(new FrakRpcError(a.error.code,a.error.message,a.error?.data)):t.resolve(a.result),r.removeChannel(n)}),s=await hashAndCompressData(e);return o.sendEvent({id:n,topic:e.method,data:s}),t.promise},i=async(e,t)=>{if(!await a.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let n=r.createChannel(async e=>{let r=await decompressDataAndCheckHash(e.data);if(r.result)t(r.result);else throw new InternalError("No valid result in the response")}),s=await hashAndCompressData(e);o.sendEvent({id:n,topic:e.method,data:s})},c=setupHeartbeat(o,a),l=async()=>{c(),r.destroy(),o.cleanup(),t.remove()},d=postConnectionSetup({config:e,messageHandler:o,lifecycleManager:a}).then(()=>n.updateSetupStatus(!0));return{config:e,debugInfo:n,waitForConnection:a.isConnected,waitForSetup:d,request:s,listenerRequest:i,destroy:l}}function setupHeartbeat(e,t){let r,a;let n=()=>e.sendEvent({clientLifecycle:"heartbeat"});function o(){r&&clearInterval(r),a&&clearTimeout(a)}return async function(){n(),r=setInterval(n,100),a=setTimeout(()=>{o(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,o()}(),o}async function postConnectionSetup({config:e,messageHandler:t,lifecycleManager:r}){await r.isConnected;let a=async()=>{let r=e.metadata.css;r&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:r}})},n=async()=>{if("undefined"==typeof window)return;let e=window.localStorage.getItem(BACKUP_KEY);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})};await Promise.all([a(),n()])}async function setupClient({config:e}){let t=await createIframe({config:e});if(!t){console.error("Failed to create iframe");return}let r=createIFrameFrakClient({config:e,iframe:t});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}let external_viem_namespaceObject=require("viem"),contextKey="fCtx";function base64url_encode(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function base64url_decode(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}function compress(e){if(e?.r)try{let t=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64url_encode(t)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function decompress(e){if(e&&0!==e.length)try{let t=base64url_decode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function parse({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(contextKey);return t?decompress(t):null}function update({url:e,context:t}){if(!e)return null;let r=parse({url:e}),a=r?{...r,...t}:t;if(!a.r)return null;let n=compress(a);if(!n)return null;let o=new URL(e);return o.searchParams.set(contextKey,n),o.toString()}function remove(e){let t=new URL(e);return t.searchParams.delete(contextKey),t.toString()}function replaceUrl({url:e,context:t}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let a=e??window.location.href;(r=null!==t?update({url:a,context:t}):remove(a))&&window.history.replaceState(null,"",r.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[t,r])=>(e[t]=BigInt(1)<<BigInt(r),e),{}),interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
|
|
13
|
+
`.trim()}}class Deferred{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}let external_async_lz_string_namespaceObject=require("async-lz-string"),external_js_sha256_namespaceObject=require("js-sha256");async function decompressDataAndCheckHash(e){if(!(e?.compressed&&e?.compressedHash))throw new FrakRpcError(RpcErrorCodes.corruptedResponse,"Missing compressed data");let t=await decompressJson(e.compressed);if(!t)throw new FrakRpcError(RpcErrorCodes.corruptedResponse,"Invalid compressed data");if(!t?.validationHash)throw new FrakRpcError(RpcErrorCodes.corruptedResponse,"Missing validation hash");if((0,external_js_sha256_namespaceObject.sha256)(e.compressed)!==e.compressedHash)throw new FrakRpcError(RpcErrorCodes.corruptedResponse,"Invalid compressed hash");let{validationHash:r,...a}=t;if((0,external_js_sha256_namespaceObject.sha256)(JSON.stringify(a))!==t.validationHash)throw new FrakRpcError(RpcErrorCodes.corruptedResponse,"Invalid data validation hash");return t}async function decompressJson(e){let t=await (0,external_async_lz_string_namespaceObject.decompressFromBase64)(e);try{return JSON.parse(t)}catch(e){return console.error("Invalid compressed data",{e,decompressed:t}),null}}async function hashAndCompressData(e){let t=(0,external_js_sha256_namespaceObject.sha256)(JSON.stringify(e)),r={...e,validationHash:t},a=await compressJson(r),n=(0,external_js_sha256_namespaceObject.sha256)(a);return{compressed:a,compressedHash:n}}async function compressJson(e){return(0,external_async_lz_string_namespaceObject.compressToBase64)(JSON.stringify(e))}let BACKUP_KEY="nexus-wallet-backup";function createIFrameChannelManager(){let e=new Map;return{createChannel:t=>{let r=Math.random().toString(36).substring(7);return e.set(r,t),r},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}let baseIframeProps={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function createIframe({walletBaseUrl:e,config:t}){let r=document.querySelector("#nexus-wallet");r&&r.remove();let a=document.createElement("iframe");return a.id=baseIframeProps.id,a.name=baseIframeProps.name,a.allow=baseIframeProps.allow,a.style.zIndex=baseIframeProps.style.zIndex.toString(),changeIframeVisibility({iframe:a,isVisible:!1}),document.body.appendChild(a),new Promise(r=>{a?.addEventListener("load",()=>r(a)),a.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function changeIframeVisibility({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function createIFrameLifecycleManager({iframe:e}){let t=new Deferred;return{handleEvent:async r=>{switch(r.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":r.data.backup?localStorage.setItem(BACKUP_KEY,r.data.backup):localStorage.removeItem(BACKUP_KEY);break;case"remove-backup":localStorage.removeItem(BACKUP_KEY);break;case"show":case"hide":changeIframeVisibility({iframe:e,isVisible:"show"===r.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:r.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}function createIFrameMessageHandler({frakWalletUrl:e,iframe:t,channelManager:r,iframeLifecycleManager:a,debugInfo:n}){if("undefined"==typeof window)throw new FrakRpcError(RpcErrorCodes.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new FrakRpcError(RpcErrorCodes.configError,"The iframe does not have a product window");let o=t.contentWindow;async function s(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(n.setLastResponse(t),"iframeLifecycle"in t.data){await a.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let o=t.data.id,s=r.getRpcResolver(o);s&&await s(t.data)}return window.addEventListener("message",s),{sendEvent:function(t){o.postMessage(t,{targetOrigin:e}),n.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",s)}}}function createIFrameFrakClient({config:e,iframe:t}){let r=createIFrameChannelManager(),a=createIFrameLifecycleManager({iframe:t}),n=new DebugInfoGatherer(e,t),o=createIFrameMessageHandler({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:r,iframeLifecycleManager:a,debugInfo:n}),s=async e=>{if(!await a.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let t=new Deferred,n=r.createChannel(async e=>{let a=await decompressDataAndCheckHash(e.data);a.error?t.reject(new FrakRpcError(a.error.code,a.error.message,a.error?.data)):t.resolve(a.result),r.removeChannel(n)}),s=await hashAndCompressData(e);return o.sendEvent({id:n,topic:e.method,data:s}),t.promise},i=async(e,t)=>{if(!await a.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let n=r.createChannel(async e=>{let r=await decompressDataAndCheckHash(e.data);if(r.result)t(r.result);else throw new InternalError("No valid result in the response")}),s=await hashAndCompressData(e);o.sendEvent({id:n,topic:e.method,data:s})},c=setupHeartbeat(o,a),l=async()=>{c(),r.destroy(),o.cleanup(),t.remove()},d=postConnectionSetup({config:e,messageHandler:o,lifecycleManager:a}).then(()=>n.updateSetupStatus(!0));return{config:e,debugInfo:n,waitForConnection:a.isConnected,waitForSetup:d,request:s,listenerRequest:i,destroy:l}}function setupHeartbeat(e,t){let r,a;let n=()=>e.sendEvent({clientLifecycle:"heartbeat"});function o(){r&&clearInterval(r),a&&clearTimeout(a)}return async function(){n(),r=setInterval(n,100),a=setTimeout(()=>{o(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,o()}(),o}async function postConnectionSetup({config:e,messageHandler:t,lifecycleManager:r}){await r.isConnected;let a=async()=>{let r=e.metadata.css;r&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:r}})},n=async()=>{if("undefined"==typeof window)return;let e=window.localStorage.getItem(BACKUP_KEY);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})};await Promise.all([a(),n()])}let locales={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function getSupportedCurrency(e){return e&&e in locales?e:"eur"}async function setupClient({config:e}){let t=prepareConfig(e),r=await createIframe({config:t});if(!r){console.error("Failed to create iframe");return}let a=createIFrameFrakClient({config:t,iframe:r});if(await a.waitForSetup,!await a.waitForConnection){console.error("Failed to connect to client");return}return a}function prepareConfig(e){let t=getSupportedCurrency(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}function getCurrencyAmountKey(e){return e?`${e}Amount`:"eurAmount"}function getSupportedLocale(e){return e?locales[e]??locales.eur:locales.eur}let external_viem_namespaceObject=require("viem"),contextKey="fCtx";function base64url_encode(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function base64url_decode(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}function compress(e){if(e?.r)try{let t=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64url_encode(t)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function decompress(e){if(e&&0!==e.length)try{let t=base64url_decode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function parse({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(contextKey);return t?decompress(t):null}function update({url:e,context:t}){if(!e)return null;let r=parse({url:e}),a=r?{...r,...t}:t;if(!a.r)return null;let n=compress(a);if(!n)return null;let o=new URL(e);return o.searchParams.set(contextKey,n),o.toString()}function remove(e){let t=new URL(e);return t.searchParams.delete(contextKey),t.toString()}function replaceUrl({url:e,context:t}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let a=e??window.location.href;(r=null!==t?update({url:a,context:t}):remove(a))&&window.history.replaceState(null,"",r.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl};function formatAmount(e,t){let r=getSupportedLocale(t),a=getSupportedCurrency(t);return e.toLocaleString(r,{style:"currency",currency:a,minimumFractionDigits:0,maximumFractionDigits:2})}let productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[t,r])=>(e[t]=BigInt(1)<<BigInt(r),e),{}),interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
|
package/dist/index.d.cts
CHANGED
|
@@ -90,6 +90,11 @@ export declare function createIFrameFrakClient({ config, iframe, }: {
|
|
|
90
90
|
iframe: HTMLIFrameElement;
|
|
91
91
|
}): FrakClient;
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* All the currencies available
|
|
95
|
+
*/
|
|
96
|
+
export declare type Currency = "eur" | "usd" | "gbp";
|
|
97
|
+
|
|
93
98
|
declare type CustomCssEvent = {
|
|
94
99
|
clientLifecycle: "modal-css";
|
|
95
100
|
data: {
|
|
@@ -175,11 +180,6 @@ export declare type DisplayEmbededWalletParamsType = {
|
|
|
175
180
|
* Some metadata to customise the embeded view
|
|
176
181
|
*/
|
|
177
182
|
metadata?: {
|
|
178
|
-
/**
|
|
179
|
-
* Language of the embeded wallet
|
|
180
|
-
* If undefined, will default to the browser language
|
|
181
|
-
*/
|
|
182
|
-
lang?: "fr" | "en";
|
|
183
183
|
/**
|
|
184
184
|
* The logo to display on the embeded wallet
|
|
185
185
|
* If undefined, will default to no logo displayed
|
|
@@ -303,6 +303,8 @@ export declare type FinalModalStepType = GenericModalStepType<"final", {
|
|
|
303
303
|
autoSkip?: boolean;
|
|
304
304
|
}, object>;
|
|
305
305
|
|
|
306
|
+
export declare function formatAmount(amount: number, currency?: Currency): string;
|
|
307
|
+
|
|
306
308
|
/**
|
|
307
309
|
* Representing a Frak client, used to interact with the Frak Wallet
|
|
308
310
|
*/
|
|
@@ -365,6 +367,16 @@ export declare type FrakWalletSdkConfig = {
|
|
|
365
367
|
* Custom CSS styles to apply to the modals and components
|
|
366
368
|
*/
|
|
367
369
|
css?: string;
|
|
370
|
+
/**
|
|
371
|
+
* Language to display in the modal
|
|
372
|
+
* If undefined, will default to the browser language
|
|
373
|
+
*/
|
|
374
|
+
lang?: "fr" | "en";
|
|
375
|
+
/**
|
|
376
|
+
* The currency to display in the modal
|
|
377
|
+
* @defaultValue `"eur"`
|
|
378
|
+
*/
|
|
379
|
+
currency?: Currency;
|
|
368
380
|
};
|
|
369
381
|
/**
|
|
370
382
|
* The domain name of your application
|
|
@@ -392,6 +404,13 @@ declare type GenericModalStepType<TKey, TParams, TReturns> = {
|
|
|
392
404
|
returns: TReturns;
|
|
393
405
|
};
|
|
394
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Get the currency amount key for a given currency
|
|
409
|
+
* @param currency - The currency to use
|
|
410
|
+
* @returns The currency amount key
|
|
411
|
+
*/
|
|
412
|
+
export declare function getCurrencyAmountKey(currency?: Currency): keyof TokenAmountType;
|
|
413
|
+
|
|
395
414
|
/**
|
|
396
415
|
* Response of the `frak_getProductInformation` RPC method
|
|
397
416
|
* @group RPC Schema
|
|
@@ -419,9 +438,13 @@ export declare type GetProductInformationReturnType = {
|
|
|
419
438
|
productTypes: ProductTypesKey[];
|
|
420
439
|
};
|
|
421
440
|
/**
|
|
422
|
-
* The max potential reward
|
|
441
|
+
* The max potential reward for the referrer
|
|
442
|
+
*/
|
|
443
|
+
maxReferrer?: TokenAmountType;
|
|
444
|
+
/**
|
|
445
|
+
* The max potential reward for the referee
|
|
423
446
|
*/
|
|
424
|
-
|
|
447
|
+
maxReferee?: TokenAmountType;
|
|
425
448
|
/**
|
|
426
449
|
* List of all the potentials reward arround this product
|
|
427
450
|
*/
|
|
@@ -429,19 +452,25 @@ export declare type GetProductInformationReturnType = {
|
|
|
429
452
|
token: Address;
|
|
430
453
|
campaign: Address;
|
|
431
454
|
interactionTypeKey: FullInteractionTypesKey;
|
|
432
|
-
referrer:
|
|
433
|
-
|
|
434
|
-
eurAmount: number;
|
|
435
|
-
usdAmount: number;
|
|
436
|
-
};
|
|
437
|
-
referee: {
|
|
438
|
-
amount: number;
|
|
439
|
-
eurAmount: number;
|
|
440
|
-
usdAmount: number;
|
|
441
|
-
};
|
|
455
|
+
referrer: TokenAmountType;
|
|
456
|
+
referee: TokenAmountType;
|
|
442
457
|
}[];
|
|
443
458
|
};
|
|
444
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Get the supported currency for a given currency
|
|
462
|
+
* @param currency - The currency to use
|
|
463
|
+
* @returns The supported currency
|
|
464
|
+
*/
|
|
465
|
+
export declare function getSupportedCurrency(currency?: Currency): Currency;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Get the supported locale for a given currency
|
|
469
|
+
* @param currency - The currency to use
|
|
470
|
+
* @returns The supported locale
|
|
471
|
+
*/
|
|
472
|
+
export declare function getSupportedLocale(currency?: Currency): (typeof locales)[LocalesKey];
|
|
473
|
+
|
|
445
474
|
declare type HandshakeRequestEvent = {
|
|
446
475
|
iframeLifecycle: "handshake";
|
|
447
476
|
data: {
|
|
@@ -552,8 +581,7 @@ export declare type IFrameRpcSchema = [
|
|
|
552
581
|
Method: "frak_displayModal";
|
|
553
582
|
Parameters: [
|
|
554
583
|
requests: ModalRpcStepsInput,
|
|
555
|
-
|
|
556
|
-
metadata?: ModalRpcMetadata
|
|
584
|
+
metadata: FrakWalletSdkConfig["metadata"] & ModalRpcMetadata
|
|
557
585
|
];
|
|
558
586
|
ReturnType: ModalRpcStepsResultType;
|
|
559
587
|
},
|
|
@@ -598,7 +626,10 @@ export declare type IFrameRpcSchema = [
|
|
|
598
626
|
*/
|
|
599
627
|
{
|
|
600
628
|
Method: "frak_displayEmbededWallet";
|
|
601
|
-
Parameters: [
|
|
629
|
+
Parameters: [
|
|
630
|
+
DisplayEmbededWalletParamsType,
|
|
631
|
+
metadata: FrakWalletSdkConfig["metadata"]
|
|
632
|
+
];
|
|
602
633
|
ReturnType: undefined;
|
|
603
634
|
}
|
|
604
635
|
];
|
|
@@ -678,6 +709,21 @@ export declare type KeyProvider<DataType> = (value: DataType) => string[];
|
|
|
678
709
|
*/
|
|
679
710
|
declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
680
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Map the currency to the locale
|
|
714
|
+
*/
|
|
715
|
+
export declare const locales: {
|
|
716
|
+
readonly eur: "fr-FR";
|
|
717
|
+
readonly usd: "en-US";
|
|
718
|
+
readonly gbp: "en-GB";
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* The keys for each locales
|
|
723
|
+
* @inline
|
|
724
|
+
*/
|
|
725
|
+
export declare type LocalesKey = keyof typeof locales;
|
|
726
|
+
|
|
681
727
|
/**
|
|
682
728
|
* Some configuration options for the embeded view
|
|
683
729
|
*
|
|
@@ -753,7 +799,6 @@ export declare type ModalRpcMetadata = {
|
|
|
753
799
|
icon?: string;
|
|
754
800
|
};
|
|
755
801
|
context?: string;
|
|
756
|
-
lang?: "en" | "fr";
|
|
757
802
|
targetInteraction?: FullInteractionTypesKey;
|
|
758
803
|
} & ({
|
|
759
804
|
isDismissible: true;
|
|
@@ -1106,6 +1151,16 @@ export declare type SsoMetadata = {
|
|
|
1106
1151
|
homepageLink?: string;
|
|
1107
1152
|
};
|
|
1108
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* The type for the amount of tokens
|
|
1156
|
+
*/
|
|
1157
|
+
export declare type TokenAmountType = {
|
|
1158
|
+
amount: number;
|
|
1159
|
+
eurAmount: number;
|
|
1160
|
+
usdAmount: number;
|
|
1161
|
+
gbpAmount: number;
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1109
1164
|
/**
|
|
1110
1165
|
* Populate the current url with the given Frak context
|
|
1111
1166
|
* @param args
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,11 @@ export declare function createIFrameFrakClient({ config, iframe, }: {
|
|
|
90
90
|
iframe: HTMLIFrameElement;
|
|
91
91
|
}): FrakClient;
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* All the currencies available
|
|
95
|
+
*/
|
|
96
|
+
export declare type Currency = "eur" | "usd" | "gbp";
|
|
97
|
+
|
|
93
98
|
declare type CustomCssEvent = {
|
|
94
99
|
clientLifecycle: "modal-css";
|
|
95
100
|
data: {
|
|
@@ -175,11 +180,6 @@ export declare type DisplayEmbededWalletParamsType = {
|
|
|
175
180
|
* Some metadata to customise the embeded view
|
|
176
181
|
*/
|
|
177
182
|
metadata?: {
|
|
178
|
-
/**
|
|
179
|
-
* Language of the embeded wallet
|
|
180
|
-
* If undefined, will default to the browser language
|
|
181
|
-
*/
|
|
182
|
-
lang?: "fr" | "en";
|
|
183
183
|
/**
|
|
184
184
|
* The logo to display on the embeded wallet
|
|
185
185
|
* If undefined, will default to no logo displayed
|
|
@@ -303,6 +303,8 @@ export declare type FinalModalStepType = GenericModalStepType<"final", {
|
|
|
303
303
|
autoSkip?: boolean;
|
|
304
304
|
}, object>;
|
|
305
305
|
|
|
306
|
+
export declare function formatAmount(amount: number, currency?: Currency): string;
|
|
307
|
+
|
|
306
308
|
/**
|
|
307
309
|
* Representing a Frak client, used to interact with the Frak Wallet
|
|
308
310
|
*/
|
|
@@ -365,6 +367,16 @@ export declare type FrakWalletSdkConfig = {
|
|
|
365
367
|
* Custom CSS styles to apply to the modals and components
|
|
366
368
|
*/
|
|
367
369
|
css?: string;
|
|
370
|
+
/**
|
|
371
|
+
* Language to display in the modal
|
|
372
|
+
* If undefined, will default to the browser language
|
|
373
|
+
*/
|
|
374
|
+
lang?: "fr" | "en";
|
|
375
|
+
/**
|
|
376
|
+
* The currency to display in the modal
|
|
377
|
+
* @defaultValue `"eur"`
|
|
378
|
+
*/
|
|
379
|
+
currency?: Currency;
|
|
368
380
|
};
|
|
369
381
|
/**
|
|
370
382
|
* The domain name of your application
|
|
@@ -392,6 +404,13 @@ declare type GenericModalStepType<TKey, TParams, TReturns> = {
|
|
|
392
404
|
returns: TReturns;
|
|
393
405
|
};
|
|
394
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Get the currency amount key for a given currency
|
|
409
|
+
* @param currency - The currency to use
|
|
410
|
+
* @returns The currency amount key
|
|
411
|
+
*/
|
|
412
|
+
export declare function getCurrencyAmountKey(currency?: Currency): keyof TokenAmountType;
|
|
413
|
+
|
|
395
414
|
/**
|
|
396
415
|
* Response of the `frak_getProductInformation` RPC method
|
|
397
416
|
* @group RPC Schema
|
|
@@ -419,9 +438,13 @@ export declare type GetProductInformationReturnType = {
|
|
|
419
438
|
productTypes: ProductTypesKey[];
|
|
420
439
|
};
|
|
421
440
|
/**
|
|
422
|
-
* The max potential reward
|
|
441
|
+
* The max potential reward for the referrer
|
|
442
|
+
*/
|
|
443
|
+
maxReferrer?: TokenAmountType;
|
|
444
|
+
/**
|
|
445
|
+
* The max potential reward for the referee
|
|
423
446
|
*/
|
|
424
|
-
|
|
447
|
+
maxReferee?: TokenAmountType;
|
|
425
448
|
/**
|
|
426
449
|
* List of all the potentials reward arround this product
|
|
427
450
|
*/
|
|
@@ -429,19 +452,25 @@ export declare type GetProductInformationReturnType = {
|
|
|
429
452
|
token: Address;
|
|
430
453
|
campaign: Address;
|
|
431
454
|
interactionTypeKey: FullInteractionTypesKey;
|
|
432
|
-
referrer:
|
|
433
|
-
|
|
434
|
-
eurAmount: number;
|
|
435
|
-
usdAmount: number;
|
|
436
|
-
};
|
|
437
|
-
referee: {
|
|
438
|
-
amount: number;
|
|
439
|
-
eurAmount: number;
|
|
440
|
-
usdAmount: number;
|
|
441
|
-
};
|
|
455
|
+
referrer: TokenAmountType;
|
|
456
|
+
referee: TokenAmountType;
|
|
442
457
|
}[];
|
|
443
458
|
};
|
|
444
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Get the supported currency for a given currency
|
|
462
|
+
* @param currency - The currency to use
|
|
463
|
+
* @returns The supported currency
|
|
464
|
+
*/
|
|
465
|
+
export declare function getSupportedCurrency(currency?: Currency): Currency;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Get the supported locale for a given currency
|
|
469
|
+
* @param currency - The currency to use
|
|
470
|
+
* @returns The supported locale
|
|
471
|
+
*/
|
|
472
|
+
export declare function getSupportedLocale(currency?: Currency): (typeof locales)[LocalesKey];
|
|
473
|
+
|
|
445
474
|
declare type HandshakeRequestEvent = {
|
|
446
475
|
iframeLifecycle: "handshake";
|
|
447
476
|
data: {
|
|
@@ -552,8 +581,7 @@ export declare type IFrameRpcSchema = [
|
|
|
552
581
|
Method: "frak_displayModal";
|
|
553
582
|
Parameters: [
|
|
554
583
|
requests: ModalRpcStepsInput,
|
|
555
|
-
|
|
556
|
-
metadata?: ModalRpcMetadata
|
|
584
|
+
metadata: FrakWalletSdkConfig["metadata"] & ModalRpcMetadata
|
|
557
585
|
];
|
|
558
586
|
ReturnType: ModalRpcStepsResultType;
|
|
559
587
|
},
|
|
@@ -598,7 +626,10 @@ export declare type IFrameRpcSchema = [
|
|
|
598
626
|
*/
|
|
599
627
|
{
|
|
600
628
|
Method: "frak_displayEmbededWallet";
|
|
601
|
-
Parameters: [
|
|
629
|
+
Parameters: [
|
|
630
|
+
DisplayEmbededWalletParamsType,
|
|
631
|
+
metadata: FrakWalletSdkConfig["metadata"]
|
|
632
|
+
];
|
|
602
633
|
ReturnType: undefined;
|
|
603
634
|
}
|
|
604
635
|
];
|
|
@@ -678,6 +709,21 @@ export declare type KeyProvider<DataType> = (value: DataType) => string[];
|
|
|
678
709
|
*/
|
|
679
710
|
declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
680
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Map the currency to the locale
|
|
714
|
+
*/
|
|
715
|
+
export declare const locales: {
|
|
716
|
+
readonly eur: "fr-FR";
|
|
717
|
+
readonly usd: "en-US";
|
|
718
|
+
readonly gbp: "en-GB";
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* The keys for each locales
|
|
723
|
+
* @inline
|
|
724
|
+
*/
|
|
725
|
+
export declare type LocalesKey = keyof typeof locales;
|
|
726
|
+
|
|
681
727
|
/**
|
|
682
728
|
* Some configuration options for the embeded view
|
|
683
729
|
*
|
|
@@ -753,7 +799,6 @@ export declare type ModalRpcMetadata = {
|
|
|
753
799
|
icon?: string;
|
|
754
800
|
};
|
|
755
801
|
context?: string;
|
|
756
|
-
lang?: "en" | "fr";
|
|
757
802
|
targetInteraction?: FullInteractionTypesKey;
|
|
758
803
|
} & ({
|
|
759
804
|
isDismissible: true;
|
|
@@ -1106,6 +1151,16 @@ export declare type SsoMetadata = {
|
|
|
1106
1151
|
homepageLink?: string;
|
|
1107
1152
|
};
|
|
1108
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* The type for the amount of tokens
|
|
1156
|
+
*/
|
|
1157
|
+
export declare type TokenAmountType = {
|
|
1158
|
+
amount: number;
|
|
1159
|
+
eurAmount: number;
|
|
1160
|
+
usdAmount: number;
|
|
1161
|
+
gbpAmount: number;
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1109
1164
|
/**
|
|
1110
1165
|
* Populate the current url with the given Frak context
|
|
1111
1166
|
* @param args
|
package/dist/index.js
CHANGED
|
@@ -10,4 +10,4 @@ import*as e from"async-lz-string";import*as t from"js-sha256";import*as n from"v
|
|
|
10
10
|
Last Response: ${t.lastResponse}
|
|
11
11
|
Client Status: ${t.clientStatus}
|
|
12
12
|
Error: ${t.error}
|
|
13
|
-
`.trim()}}class c{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}async function l(e){if(!(e?.compressed&&e?.compressedHash))throw new r(s.corruptedResponse,"Missing compressed data");let n=await d(e.compressed);if(!n)throw new r(s.corruptedResponse,"Invalid compressed data");if(!n?.validationHash)throw new r(s.corruptedResponse,"Missing validation hash");if((0,t.sha256)(e.compressed)!==e.compressedHash)throw new r(s.corruptedResponse,"Invalid compressed hash");let{validationHash:a,...o}=n;if((0,t.sha256)(JSON.stringify(o))!==n.validationHash)throw new r(s.corruptedResponse,"Invalid data validation hash");return n}async function d(t){let n=await (0,e.decompressFromBase64)(t);try{return JSON.parse(n)}catch(e){return console.error("Invalid compressed data",{e,decompressed:n}),null}}async function u(e){let n=(0,t.sha256)(JSON.stringify(e)),r={...e,validationHash:n},a=await f(r),o=(0,t.sha256)(a);return{compressed:a,compressedHash:o}}async function f(t){return(0,e.compressToBase64)(JSON.stringify(t))}let p="nexus-wallet-backup",h={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function m({walletBaseUrl:e,config:t}){let n=document.querySelector("#nexus-wallet");n&&n.remove();let r=document.createElement("iframe");return r.id=h.id,r.name=h.name,r.allow=h.allow,r.style.zIndex=h.style.zIndex.toString(),
|
|
13
|
+
`.trim()}}class c{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}async function l(e){if(!(e?.compressed&&e?.compressedHash))throw new r(s.corruptedResponse,"Missing compressed data");let n=await d(e.compressed);if(!n)throw new r(s.corruptedResponse,"Invalid compressed data");if(!n?.validationHash)throw new r(s.corruptedResponse,"Missing validation hash");if((0,t.sha256)(e.compressed)!==e.compressedHash)throw new r(s.corruptedResponse,"Invalid compressed hash");let{validationHash:a,...o}=n;if((0,t.sha256)(JSON.stringify(o))!==n.validationHash)throw new r(s.corruptedResponse,"Invalid data validation hash");return n}async function d(t){let n=await (0,e.decompressFromBase64)(t);try{return JSON.parse(n)}catch(e){return console.error("Invalid compressed data",{e,decompressed:n}),null}}async function u(e){let n=(0,t.sha256)(JSON.stringify(e)),r={...e,validationHash:n},a=await f(r),o=(0,t.sha256)(a);return{compressed:a,compressedHash:o}}async function f(t){return(0,e.compressToBase64)(JSON.stringify(t))}let p="nexus-wallet-backup",h={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function m({walletBaseUrl:e,config:t}){let n=document.querySelector("#nexus-wallet");n&&n.remove();let r=document.createElement("iframe");return r.id=h.id,r.name=h.name,r.allow=h.allow,r.style.zIndex=h.style.zIndex.toString(),g({iframe:r,isVisible:!1}),document.body.appendChild(r),new Promise(n=>{r?.addEventListener("load",()=>n(r)),r.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function g({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function w({config:e,iframe:t}){let n=function(){let e=new Map;return{createChannel:t=>{let n=Math.random().toString(36).substring(7);return e.set(n,t),n},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),o=function({iframe:e}){let t=new c;return{handleEvent:async n=>{switch(n.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":n.data.backup?localStorage.setItem(p,n.data.backup):localStorage.removeItem(p);break;case"remove-backup":localStorage.removeItem(p);break;case"show":case"hide":g({iframe:e,isVisible:"show"===n.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:n.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:t}),d=new i(e,t),f=function({frakWalletUrl:e,iframe:t,channelManager:n,iframeLifecycleManager:a,debugInfo:o}){if("undefined"==typeof window)throw new r(s.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new r(s.configError,"The iframe does not have a product window");let i=t.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(o.setLastResponse(t),"iframeLifecycle"in t.data){await a.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let r=t.data.id,s=n.getRpcResolver(r);s&&await s(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){i.postMessage(t,{targetOrigin:e}),o.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:n,iframeLifecycleManager:o,debugInfo:d}),h=async e=>{if(!await o.isConnected)throw new r(s.clientNotConnected,"The iframe provider isn't connected yet");let t=new c,a=n.createChannel(async e=>{let o=await l(e.data);o.error?t.reject(new r(o.error.code,o.error.message,o.error?.data)):t.resolve(o.result),n.removeChannel(a)}),i=await u(e);return f.sendEvent({id:a,topic:e.method,data:i}),t.promise},m=async(e,t)=>{if(!await o.isConnected)throw new r(s.clientNotConnected,"The iframe provider isn't connected yet");let i=n.createChannel(async e=>{let n=await l(e.data);if(n.result)t(n.result);else throw new a("No valid result in the response")}),c=await u(e);f.sendEvent({id:i,topic:e.method,data:c})},w=function(e,t){let n,r;let a=()=>e.sendEvent({clientLifecycle:"heartbeat"});function o(){n&&clearInterval(n),r&&clearTimeout(r)}return async function(){a(),n=setInterval(a,100),r=setTimeout(()=>{o(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,o()}(),o}(f,o),b=async()=>{w(),n.destroy(),f.cleanup(),t.remove()},v=y({config:e,messageHandler:f,lifecycleManager:o}).then(()=>d.updateSetupStatus(!0));return{config:e,debugInfo:d,waitForConnection:o.isConnected,waitForSetup:v,request:h,listenerRequest:m,destroy:b}}async function y({config:e,messageHandler:t,lifecycleManager:n}){await n.isConnected;let r=async()=>{let n=e.metadata.css;n&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:n}})},a=async()=>{if("undefined"==typeof window)return;let e=window.localStorage.getItem(p);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})};await Promise.all([r(),a()])}let b={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function v(e){return e&&e in b?e:"eur"}async function S({config:e}){let t=function(e){let t=v(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),n=await m({config:t});if(!n){console.error("Failed to create iframe");return}let r=w({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}function C(e){return e?b[e]??b.eur:b.eur}function R(e,t){let n=C(t),r=v(t);return e.toLocaleString(n,{style:"currency",currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function x(e){return e?`${e}Amount`:"eurAmount"}let E="fCtx";function I(e){if(e?.r)try{var t;return t=(0,n.hexToBytes)(e.r),btoa(Array.from(t,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function k(e){if(e&&0!==e.length)try{let t=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(e);return{r:(0,n.bytesToHex)(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function L({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(E);return t?k(t):null}function F({url:e,context:t}){if(!e)return null;let n=L({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let a=I(r);if(!a)return null;let o=new URL(e);return o.searchParams.set(E,a),o.toString()}function D(e){let t=new URL(e);return t.searchParams.delete(E),t.toString()}let N={compress:I,decompress:k,parse:L,update:F,remove:D,replaceUrl:function({url:e,context:t}){let n;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let r=e??window.location.href;(n=null!==t?F({url:r,context:t}):D(r))&&window.history.replaceState(null,"",n.toString())}},U={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},A=Object.entries(U).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{}),$={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};export{o as ClientNotFound,i as DebugInfoGatherer,c as Deferred,N as FrakContextManager,r as FrakRpcError,s as RpcErrorCodes,h as baseIframeProps,f as compressJson,w as createIFrameFrakClient,m as createIframe,l as decompressDataAndCheckHash,d as decompressJson,R as formatAmount,x as getCurrencyAmountKey,v as getSupportedCurrency,C as getSupportedLocale,u as hashAndCompressData,$ as interactionTypes,b as locales,U as productTypes,A as productTypesMask,S as setupClient};
|
package/dist/interactions.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=
|
|
1
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ReferralInteractionEncoder:()=>ReferralInteractionEncoder,PressInteractionEncoder:()=>PressInteractionEncoder,PurchaseInteractionEncoder:()=>PurchaseInteractionEncoder,RetailInteractionEncoder:()=>RetailInteractionEncoder,WebShopInteractionEncoder:()=>WebShopInteractionEncoder});let external_viem_namespaceObject=require("viem"),interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),PressInteractionEncoder={openArticle({articleId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.press.openArticle,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.press),interactionData:r}},readArticle({articleId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.press.readArticle,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.press),interactionData:r}}},ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}},PurchaseInteractionEncoder={startPurchase({purchaseId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.started,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:r}},completedPurchase({purchaseId:e,proof:r}){let t=(0,external_viem_namespaceObject.encodeAbiParameters)([{type:"uint256"},{type:"bytes32[]"}],[BigInt(e),r]),a=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.completed,t]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:a}},unsafeCompletedPurchase({purchaseId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.unsafeCompleted,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:r}}},WebShopInteractionEncoder={open:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.webshop),interactionData:interactionTypes.webshop.open})},RetailInteractionEncoder={customerMeeting({agencyId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.retail.customerMeeting,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.retail),interactionData:r}}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.9",
|
|
15
15
|
"description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"js-sha256": "^0.11.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@arethetypeswrong/cli": "^0.17.
|
|
93
|
-
"@microsoft/api-extractor": "^7.
|
|
94
|
-
"@rslib/core": "^0.5.
|
|
92
|
+
"@arethetypeswrong/cli": "^0.17.4",
|
|
93
|
+
"@microsoft/api-extractor": "^7.52.1",
|
|
94
|
+
"@rslib/core": "^0.5.4",
|
|
95
95
|
"@types/node": "^22",
|
|
96
96
|
"ts-checker-rspack-plugin": "^1.1.1",
|
|
97
97
|
"typescript": "^5"
|