customer-chat-sdk 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/customer-sdk.cjs.js
CHANGED
|
@@ -27473,7 +27473,7 @@ let CustomerSDK$1 = class CustomerSDK {
|
|
|
27473
27473
|
console.log('Raw Device ID:', rawDeviceId);
|
|
27474
27474
|
}
|
|
27475
27475
|
// 计算返回给前端的 deviceId:md5(deviceId + getReferrer())
|
|
27476
|
-
const referrer =
|
|
27476
|
+
const referrer = document.location.href;
|
|
27477
27477
|
let host = '';
|
|
27478
27478
|
try {
|
|
27479
27479
|
host = new URL(referrer).hostname;
|
package/dist/customer-sdk.esm.js
CHANGED
|
@@ -27469,7 +27469,7 @@ let CustomerSDK$1 = class CustomerSDK {
|
|
|
27469
27469
|
console.log('Raw Device ID:', rawDeviceId);
|
|
27470
27470
|
}
|
|
27471
27471
|
// 计算返回给前端的 deviceId:md5(deviceId + getReferrer())
|
|
27472
|
-
const referrer =
|
|
27472
|
+
const referrer = document.location.href;
|
|
27473
27473
|
let host = '';
|
|
27474
27474
|
try {
|
|
27475
27475
|
host = new URL(referrer).hostname;
|
package/dist/customer-sdk.min.js
CHANGED
|
@@ -35,4 +35,4 @@ e.mode.CTRGladman=function(){var A=e.lib.BlockCipherMode.extend();function t(A){
|
|
|
35
35
|
|
|
36
36
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
37
|
*/
|
|
38
|
-
function(){var A=e,t=A.lib,n=t.WordArray,r=t.Hasher,o=A.algo,i=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=n.create([0,1518500249,1859775393,2400959708,2840853838]),u=n.create([1352829926,1548603684,1836072691,2053994217,0]),B=o.RIPEMD160=r.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(A,e){for(var t=0;t<16;t++){var n=e+t,r=A[n];A[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o,B,m,Q,C,y,U,F,b,v,E,H=this._hash.words,I=l.words,x=u.words,S=i.words,L=s.words,K=a.words,k=c.words;for(y=o=H[0],U=B=H[1],F=m=H[2],b=Q=H[3],v=C=H[4],t=0;t<80;t+=1)E=o+A[e+S[t]]|0,E+=t<16?h(B,m,Q)+I[0]:t<32?g(B,m,Q)+I[1]:t<48?d(B,m,Q)+I[2]:t<64?f(B,m,Q)+I[3]:w(B,m,Q)+I[4],E=(E=p(E|=0,K[t]))+C|0,o=C,C=Q,Q=p(m,10),m=B,B=E,E=y+A[e+L[t]]|0,E+=t<16?w(U,F,b)+x[0]:t<32?f(U,F,b)+x[1]:t<48?d(U,F,b)+x[2]:t<64?g(U,F,b)+x[3]:h(U,F,b)+x[4],E=(E=p(E|=0,k[t]))+v|0,y=v,v=b,b=p(F,10),F=U,U=E;E=H[1]+m+b|0,H[1]=H[2]+Q+v|0,H[2]=H[3]+C+y|0,H[3]=H[4]+o+U|0,H[4]=H[0]+B+F|0,H[0]=E},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,n=8*A.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(t<<8|t>>>24)|4278255360&(t<<24|t>>>8),A.sigBytes=4*(e.length+1),this._process();for(var r=this._hash,o=r.words,i=0;i<5;i++){var s=o[i];o[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return r},clone:function(){var A=r.clone.call(this);return A._hash=this._hash.clone(),A}});function h(A,e,t){return A^e^t}function g(A,e,t){return A&e|~A&t}function d(A,e,t){return(A|~e)^t}function f(A,e,t){return A&t|e&~t}function w(A,e,t){return A^(e|~t)}function p(A,e){return A<<e|A>>>32-e}A.RIPEMD160=r._createHelper(B),A.HmacRIPEMD160=r._createHmacHelper(B)}(),e.RIPEMD160)}(Ir)),Lr(),Kr||(Kr=1,function(A){var e,t,n,r,o,i,s,a,c;A.exports=(c=Jn(),wr(),Lr(),n=(t=(e=c).lib).Base,r=t.WordArray,i=(o=e.algo).SHA256,s=o.HMAC,a=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:i,iterations:25e4}),init:function(A){this.cfg=this.cfg.extend(A)},compute:function(A,e){for(var t=this.cfg,n=s.create(t.hasher,A),o=r.create(),i=r.create([1]),a=o.words,c=i.words,l=t.keySize,u=t.iterations;a.length<l;){var B=n.update(e).finalize(i);n.reset();for(var h=B.words,g=h.length,d=B,f=1;f<u;f++){d=n.finalize(d),n.reset();for(var w=d.words,p=0;p<g;p++)h[p]^=w[p]}o.concat(B),c[0]++}return o.sigBytes=4*l,o}}),e.PBKDF2=function(A,e,t){return a.create(t).compute(A,e)},c.PBKDF2)}(kr)),Tr(),Pr(),Gr(),Xr(),Yr(),zr(),qr||(qr=1,function(A){var e,t;A.exports=(t=Jn(),Pr(),t.mode.ECB=((e=t.lib.BlockCipherMode.extend()).Encryptor=e.extend({processBlock:function(A,e){this._cipher.encryptBlock(A,e)}}),e.Decryptor=e.extend({processBlock:function(A,e){this._cipher.decryptBlock(A,e)}}),e),t.mode.ECB)}(Ao)),eo||(eo=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.AnsiX923={pad:function(A,e){var t=A.sigBytes,n=4*e,r=n-t%n,o=t+r-1;A.clamp(),A.words[o>>>2]|=r<<24-o%4*8,A.sigBytes+=r},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Ansix923)}(to)),no||(no=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.Iso10126={pad:function(A,t){var n=4*t,r=n-A.sigBytes%n;A.concat(e.lib.WordArray.random(r-1)).concat(e.lib.WordArray.create([r<<24],1))},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Iso10126)}(ro)),oo||(oo=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.Iso97971={pad:function(A,t){A.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(A,t)},unpad:function(A){e.pad.ZeroPadding.unpad(A),A.sigBytes--}},e.pad.Iso97971)}(io)),so||(so=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.ZeroPadding={pad:function(A,e){var t=4*e;A.clamp(),A.sigBytes+=t-(A.sigBytes%t||t)},unpad:function(A){var e=A.words,t=A.sigBytes-1;for(t=A.sigBytes-1;t>=0;t--)if(e[t>>>2]>>>24-t%4*8&255){A.sigBytes=t+1;break}}},e.pad.ZeroPadding)}(ao)),co||(co=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)}(lo)),uo||(uo=1,function(A){var e,t,n,r;A.exports=(r=Jn(),Pr(),t=(e=r).lib.CipherParams,n=e.enc.Hex,e.format.Hex={stringify:function(A){return A.ciphertext.toString(n)},parse:function(A){var e=n.parse(A);return t.create({ciphertext:e})}},r.format.Hex)}(Bo)),ho||(ho=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.BlockCipher,n=A.algo,r=[],o=[],i=[],s=[],a=[],c=[],l=[],u=[],B=[],h=[];!function(){for(var A=[],e=0;e<256;e++)A[e]=e<128?e<<1:e<<1^283;var t=0,n=0;for(e=0;e<256;e++){var g=n^n<<1^n<<2^n<<3^n<<4;g=g>>>8^255&g^99,r[t]=g,o[g]=t;var d=A[t],f=A[d],w=A[f],p=257*A[g]^16843008*g;i[t]=p<<24|p>>>8,s[t]=p<<16|p>>>16,a[t]=p<<8|p>>>24,c[t]=p,p=16843009*w^65537*f^257*d^16843008*t,l[g]=p<<24|p>>>8,u[g]=p<<16|p>>>16,B[g]=p<<8|p>>>24,h[g]=p,t?(t=d^A[A[A[w^d]]],n^=A[A[n]]):t=n=1}}();var g=[0,1,2,4,8,16,32,64,128,27,54],d=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var A=this._keyPriorReset=this._key,e=A.words,t=A.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i<n;i++)i<t?o[i]=e[i]:(c=o[i-1],i%t?t>6&&i%t==4&&(c=r[c>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c]):(c=r[(c=c<<8|c>>>24)>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c],c^=g[i/t|0]<<24),o[i]=o[i-t]^c);for(var s=this._invKeySchedule=[],a=0;a<n;a++){if(i=n-a,a%4)var c=o[i];else c=o[i-4];s[a]=a<4||i<=4?c:l[r[c>>>24]]^u[r[c>>>16&255]]^B[r[c>>>8&255]]^h[r[255&c]]}}},encryptBlock:function(A,e){this._doCryptBlock(A,e,this._keySchedule,i,s,a,c,r)},decryptBlock:function(A,e){var t=A[e+1];A[e+1]=A[e+3],A[e+3]=t,this._doCryptBlock(A,e,this._invKeySchedule,l,u,B,h,o),t=A[e+1],A[e+1]=A[e+3],A[e+3]=t},_doCryptBlock:function(A,e,t,n,r,o,i,s){for(var a=this._nRounds,c=A[e]^t[0],l=A[e+1]^t[1],u=A[e+2]^t[2],B=A[e+3]^t[3],h=4,g=1;g<a;g++){var d=n[c>>>24]^r[l>>>16&255]^o[u>>>8&255]^i[255&B]^t[h++],f=n[l>>>24]^r[u>>>16&255]^o[B>>>8&255]^i[255&c]^t[h++],w=n[u>>>24]^r[B>>>16&255]^o[c>>>8&255]^i[255&l]^t[h++],p=n[B>>>24]^r[c>>>16&255]^o[l>>>8&255]^i[255&u]^t[h++];c=d,l=f,u=w,B=p}d=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&B])^t[h++],f=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[B>>>8&255]<<8|s[255&c])^t[h++],w=(s[u>>>24]<<24|s[B>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^t[h++],p=(s[B>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^t[h++],A[e]=d,A[e+1]=f,A[e+2]=w,A[e+3]=p},keySize:8});A.AES=t._createHelper(d)}(),e.AES)}(go)),po(),mo||(mo=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=n.RC4=t.extend({_doReset:function(){for(var A=this._key,e=A.words,t=A.sigBytes,n=this._S=[],r=0;r<256;r++)n[r]=r;r=0;for(var o=0;r<256;r++){var i=r%t,s=e[i>>>2]>>>24-i%4*8&255;o=(o+n[r]+s)%256;var a=n[r];n[r]=n[o],n[o]=a}this._i=this._j=0},_doProcessBlock:function(A,e){A[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var A=this._S,e=this._i,t=this._j,n=0,r=0;r<4;r++){t=(t+A[e=(e+1)%256])%256;var o=A[e];A[e]=A[t],A[t]=o,n|=A[(A[e]+A[t])%256]<<24-8*r}return this._i=e,this._j=t,n}A.RC4=t._createHelper(r);var i=n.RC4Drop=r.extend({cfg:r.cfg.extend({drop:192}),_doReset:function(){r._doReset.call(this);for(var A=this.cfg.drop;A>0;A--)o.call(this)}});A.RC4Drop=t._createHelper(i)}(),e.RC4)}(Qo)),Co||(Co=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.Rabbit=t.extend({_doReset:function(){for(var A=this._key.words,e=this.cfg.iv,t=0;t<4;t++)A[t]=16711935&(A[t]<<8|A[t]>>>24)|4278255360&(A[t]<<24|A[t]>>>8);var n=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],r=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];for(this._b=0,t=0;t<4;t++)a.call(this);for(t=0;t<8;t++)r[t]^=n[t+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,B=l<<16|65535&c;for(r[0]^=c,r[1]^=u,r[2]^=l,r[3]^=B,r[4]^=c,r[5]^=u,r[6]^=l,r[7]^=B,t=0;t<4;t++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.Rabbit=t._createHelper(s)}(),e.Rabbit)}(yo)),Uo||(Uo=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.RabbitLegacy=t.extend({_doReset:function(){var A=this._key.words,e=this.cfg.iv,t=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],n=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];this._b=0;for(var r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)n[r]^=t[r+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,B=l<<16|65535&c;for(n[0]^=c,n[1]^=u,n[2]^=l,n[3]^=B,n[4]^=c,n[5]^=u,n[6]^=l,n[7]^=B,r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.RabbitLegacy=t._createHelper(s)}(),e.RabbitLegacy)}(Fo)),Eo(),e)}(Gn);var Ho=Gn.exports;let Io=class{constructor(){this.screenshotManager=null,this.debug=!1,this.deviceId=null,this.initResult=null,this.config=null,this.screenshotCallback=null,this.initCallback=null}async init(A,e,t){try{this.config=A,this.screenshotCallback=e||null,this.initCallback=t||null,this.debug=A.debug??!1;const n=await this.getRawDeviceId();this.debug&&console.log("Raw Device ID:",n);const r=A.referrer||document.referrer||document.location.href;let o="";try{o=new URL(r).hostname}catch(A){o=""}this.deviceId=Ho.MD5(n+o).toString(),this.debug&&(console.log("MD5 Device ID (for frontend):",this.deviceId),console.log("Referrer used:",r));const i={deviceId:this.deviceId,referrer:r,agent:A.agent,timestamp:Date.now()},s=A.target||void 0;if(A.screenshot){const t="string"==typeof s?document.querySelector(s):s||document.body,n=e?.sendData;this.debug&&(console.log("[CustomerSDK] 初始化截图管理器:"),console.log(" screenshotCallback:",e?"存在":"null/undefined",e),console.log(" screenshotCallback?.sendData:",e?.sendData?"存在":"null/undefined",typeof e?.sendData,e?.sendData),console.log(" sendToExternal:",n?"存在":"undefined",typeof n,n),console.log(" 即将传递给 ScreenshotManager 的参数:",{targetElement:t?"存在":"null",screenshot:A.screenshot?"存在":"null",sendToExternal:n?"存在":"undefined"})),this.screenshotManager=new ht(t,A.screenshot,n),e?.onConfig&&this.setupScreenshotConfigListener(e.onConfig)}return this.initResult=i,this.debug&&console.log("CustomerSDK initialized successfully (screenshot only)"),i}catch(A){throw console.error("Failed to initialize CustomerSDK:",A),A}}setupScreenshotConfigListener(A){const e=e=>{try{if(!e.data||"checkScreenshot"!==e.data.type)return;this.debug&&console.log("[CustomerSDK] Received screenshot config message:",e.data),e.data.data&&"string"==typeof e.data.data&&A(e.data.data)}catch(A){this.debug&&console.error("[CustomerSDK] Error handling screenshot config message:",A)}};window.addEventListener("message",e),this._screenshotConfigHandler=e}triggerScreenshotConfig(A){this.screenshotManager?this.screenshotManager.handleScreenshotConfig(A):this.debug&&console.warn("[CustomerSDK] ScreenshotManager not initialized")}getScreenshotManager(){return this.screenshotManager}getDeviceId(){return this.deviceId}getInitResult(){return this.initResult}async updateToken(A,e,t){if(!this.config)throw new Error("SDK not initialized. Call init() first.");this.debug&&console.log("Updating token:",A?"Token provided":"Token removed");const n={...this.config,token:A&&""!==A.trim()?A:void 0};return this.destroy(),await this.init(n,e||this.screenshotCallback||void 0,t||this.initCallback||void 0)}async getRawDeviceId(){this.debug&&console.log("🔍 Starting to get device fingerprint...");try{this.debug&&console.log("📦 Loading FingerprintJS...");const A=await Nn.load();this.debug&&console.log("🎯 Getting device fingerprint...");const e=await A.get();return this.debug&&(console.log("✅ FingerprintJS result:",e),console.log("🆔 Device ID obtained:",e.visitorId)),e.visitorId}catch(A){this.debug&&console.warn("❌ Failed to get device fingerprint, using fallback:",A);const e="device_"+Date.now()+"_"+Math.random().toString(36).substr(2,9);return this.debug&&console.log("🆔 Fallback Device ID:",e),e}}destroy(){this.screenshotManager?.destroy(),this._screenshotConfigHandler&&(window.removeEventListener("message",this._screenshotConfigHandler),this._screenshotConfigHandler=null),this.screenshotManager=null,this.initResult=null,this.deviceId=null,this.debug&&console.log("CustomerSDK destroyed")}},xo=null;function So(){return xo||(xo=new Io),xo}const Lo=async(A,e,t)=>{const n=So();return await n.init(A,e,t)},Ko=A=>{So().triggerScreenshotConfig(A)},ko=()=>{So().destroy(),xo=null},Mo=()=>So().getDeviceId(),Do=()=>So(),To=Io;var Ro={init:Lo,triggerScreenshotConfig:Ko,destroy:ko,getDeviceId:Mo,getInstance:Do,CustomerSDK:To};A.CustomerSDK=To,A.default=Ro,A.destroy=ko,A.getDeviceId=Mo,A.getInstance=Do,A.init=Lo,A.triggerScreenshotConfig=Ko,Object.defineProperty(A,"__esModule",{value:!0})});
|
|
38
|
+
function(){var A=e,t=A.lib,n=t.WordArray,r=t.Hasher,o=A.algo,i=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=n.create([0,1518500249,1859775393,2400959708,2840853838]),u=n.create([1352829926,1548603684,1836072691,2053994217,0]),B=o.RIPEMD160=r.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(A,e){for(var t=0;t<16;t++){var n=e+t,r=A[n];A[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o,B,m,Q,C,y,U,F,b,v,E,H=this._hash.words,I=l.words,x=u.words,S=i.words,L=s.words,K=a.words,k=c.words;for(y=o=H[0],U=B=H[1],F=m=H[2],b=Q=H[3],v=C=H[4],t=0;t<80;t+=1)E=o+A[e+S[t]]|0,E+=t<16?h(B,m,Q)+I[0]:t<32?g(B,m,Q)+I[1]:t<48?d(B,m,Q)+I[2]:t<64?f(B,m,Q)+I[3]:w(B,m,Q)+I[4],E=(E=p(E|=0,K[t]))+C|0,o=C,C=Q,Q=p(m,10),m=B,B=E,E=y+A[e+L[t]]|0,E+=t<16?w(U,F,b)+x[0]:t<32?f(U,F,b)+x[1]:t<48?d(U,F,b)+x[2]:t<64?g(U,F,b)+x[3]:h(U,F,b)+x[4],E=(E=p(E|=0,k[t]))+v|0,y=v,v=b,b=p(F,10),F=U,U=E;E=H[1]+m+b|0,H[1]=H[2]+Q+v|0,H[2]=H[3]+C+y|0,H[3]=H[4]+o+U|0,H[4]=H[0]+B+F|0,H[0]=E},_doFinalize:function(){var A=this._data,e=A.words,t=8*this._nDataBytes,n=8*A.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(t<<8|t>>>24)|4278255360&(t<<24|t>>>8),A.sigBytes=4*(e.length+1),this._process();for(var r=this._hash,o=r.words,i=0;i<5;i++){var s=o[i];o[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return r},clone:function(){var A=r.clone.call(this);return A._hash=this._hash.clone(),A}});function h(A,e,t){return A^e^t}function g(A,e,t){return A&e|~A&t}function d(A,e,t){return(A|~e)^t}function f(A,e,t){return A&t|e&~t}function w(A,e,t){return A^(e|~t)}function p(A,e){return A<<e|A>>>32-e}A.RIPEMD160=r._createHelper(B),A.HmacRIPEMD160=r._createHmacHelper(B)}(),e.RIPEMD160)}(Ir)),Lr(),Kr||(Kr=1,function(A){var e,t,n,r,o,i,s,a,c;A.exports=(c=Jn(),wr(),Lr(),n=(t=(e=c).lib).Base,r=t.WordArray,i=(o=e.algo).SHA256,s=o.HMAC,a=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:i,iterations:25e4}),init:function(A){this.cfg=this.cfg.extend(A)},compute:function(A,e){for(var t=this.cfg,n=s.create(t.hasher,A),o=r.create(),i=r.create([1]),a=o.words,c=i.words,l=t.keySize,u=t.iterations;a.length<l;){var B=n.update(e).finalize(i);n.reset();for(var h=B.words,g=h.length,d=B,f=1;f<u;f++){d=n.finalize(d),n.reset();for(var w=d.words,p=0;p<g;p++)h[p]^=w[p]}o.concat(B),c[0]++}return o.sigBytes=4*l,o}}),e.PBKDF2=function(A,e,t){return a.create(t).compute(A,e)},c.PBKDF2)}(kr)),Tr(),Pr(),Gr(),Xr(),Yr(),zr(),qr||(qr=1,function(A){var e,t;A.exports=(t=Jn(),Pr(),t.mode.ECB=((e=t.lib.BlockCipherMode.extend()).Encryptor=e.extend({processBlock:function(A,e){this._cipher.encryptBlock(A,e)}}),e.Decryptor=e.extend({processBlock:function(A,e){this._cipher.decryptBlock(A,e)}}),e),t.mode.ECB)}(Ao)),eo||(eo=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.AnsiX923={pad:function(A,e){var t=A.sigBytes,n=4*e,r=n-t%n,o=t+r-1;A.clamp(),A.words[o>>>2]|=r<<24-o%4*8,A.sigBytes+=r},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Ansix923)}(to)),no||(no=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.Iso10126={pad:function(A,t){var n=4*t,r=n-A.sigBytes%n;A.concat(e.lib.WordArray.random(r-1)).concat(e.lib.WordArray.create([r<<24],1))},unpad:function(A){var e=255&A.words[A.sigBytes-1>>>2];A.sigBytes-=e}},e.pad.Iso10126)}(ro)),oo||(oo=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.Iso97971={pad:function(A,t){A.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(A,t)},unpad:function(A){e.pad.ZeroPadding.unpad(A),A.sigBytes--}},e.pad.Iso97971)}(io)),so||(so=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.ZeroPadding={pad:function(A,e){var t=4*e;A.clamp(),A.sigBytes+=t-(A.sigBytes%t||t)},unpad:function(A){var e=A.words,t=A.sigBytes-1;for(t=A.sigBytes-1;t>=0;t--)if(e[t>>>2]>>>24-t%4*8&255){A.sigBytes=t+1;break}}},e.pad.ZeroPadding)}(ao)),co||(co=1,function(A){var e;A.exports=(e=Jn(),Pr(),e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding)}(lo)),uo||(uo=1,function(A){var e,t,n,r;A.exports=(r=Jn(),Pr(),t=(e=r).lib.CipherParams,n=e.enc.Hex,e.format.Hex={stringify:function(A){return A.ciphertext.toString(n)},parse:function(A){var e=n.parse(A);return t.create({ciphertext:e})}},r.format.Hex)}(Bo)),ho||(ho=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.BlockCipher,n=A.algo,r=[],o=[],i=[],s=[],a=[],c=[],l=[],u=[],B=[],h=[];!function(){for(var A=[],e=0;e<256;e++)A[e]=e<128?e<<1:e<<1^283;var t=0,n=0;for(e=0;e<256;e++){var g=n^n<<1^n<<2^n<<3^n<<4;g=g>>>8^255&g^99,r[t]=g,o[g]=t;var d=A[t],f=A[d],w=A[f],p=257*A[g]^16843008*g;i[t]=p<<24|p>>>8,s[t]=p<<16|p>>>16,a[t]=p<<8|p>>>24,c[t]=p,p=16843009*w^65537*f^257*d^16843008*t,l[g]=p<<24|p>>>8,u[g]=p<<16|p>>>16,B[g]=p<<8|p>>>24,h[g]=p,t?(t=d^A[A[A[w^d]]],n^=A[A[n]]):t=n=1}}();var g=[0,1,2,4,8,16,32,64,128,27,54],d=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var A=this._keyPriorReset=this._key,e=A.words,t=A.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i<n;i++)i<t?o[i]=e[i]:(c=o[i-1],i%t?t>6&&i%t==4&&(c=r[c>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c]):(c=r[(c=c<<8|c>>>24)>>>24]<<24|r[c>>>16&255]<<16|r[c>>>8&255]<<8|r[255&c],c^=g[i/t|0]<<24),o[i]=o[i-t]^c);for(var s=this._invKeySchedule=[],a=0;a<n;a++){if(i=n-a,a%4)var c=o[i];else c=o[i-4];s[a]=a<4||i<=4?c:l[r[c>>>24]]^u[r[c>>>16&255]]^B[r[c>>>8&255]]^h[r[255&c]]}}},encryptBlock:function(A,e){this._doCryptBlock(A,e,this._keySchedule,i,s,a,c,r)},decryptBlock:function(A,e){var t=A[e+1];A[e+1]=A[e+3],A[e+3]=t,this._doCryptBlock(A,e,this._invKeySchedule,l,u,B,h,o),t=A[e+1],A[e+1]=A[e+3],A[e+3]=t},_doCryptBlock:function(A,e,t,n,r,o,i,s){for(var a=this._nRounds,c=A[e]^t[0],l=A[e+1]^t[1],u=A[e+2]^t[2],B=A[e+3]^t[3],h=4,g=1;g<a;g++){var d=n[c>>>24]^r[l>>>16&255]^o[u>>>8&255]^i[255&B]^t[h++],f=n[l>>>24]^r[u>>>16&255]^o[B>>>8&255]^i[255&c]^t[h++],w=n[u>>>24]^r[B>>>16&255]^o[c>>>8&255]^i[255&l]^t[h++],p=n[B>>>24]^r[c>>>16&255]^o[l>>>8&255]^i[255&u]^t[h++];c=d,l=f,u=w,B=p}d=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&B])^t[h++],f=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[B>>>8&255]<<8|s[255&c])^t[h++],w=(s[u>>>24]<<24|s[B>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^t[h++],p=(s[B>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^t[h++],A[e]=d,A[e+1]=f,A[e+2]=w,A[e+3]=p},keySize:8});A.AES=t._createHelper(d)}(),e.AES)}(go)),po(),mo||(mo=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=n.RC4=t.extend({_doReset:function(){for(var A=this._key,e=A.words,t=A.sigBytes,n=this._S=[],r=0;r<256;r++)n[r]=r;r=0;for(var o=0;r<256;r++){var i=r%t,s=e[i>>>2]>>>24-i%4*8&255;o=(o+n[r]+s)%256;var a=n[r];n[r]=n[o],n[o]=a}this._i=this._j=0},_doProcessBlock:function(A,e){A[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var A=this._S,e=this._i,t=this._j,n=0,r=0;r<4;r++){t=(t+A[e=(e+1)%256])%256;var o=A[e];A[e]=A[t],A[t]=o,n|=A[(A[e]+A[t])%256]<<24-8*r}return this._i=e,this._j=t,n}A.RC4=t._createHelper(r);var i=n.RC4Drop=r.extend({cfg:r.cfg.extend({drop:192}),_doReset:function(){r._doReset.call(this);for(var A=this.cfg.drop;A>0;A--)o.call(this)}});A.RC4Drop=t._createHelper(i)}(),e.RC4)}(Qo)),Co||(Co=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.Rabbit=t.extend({_doReset:function(){for(var A=this._key.words,e=this.cfg.iv,t=0;t<4;t++)A[t]=16711935&(A[t]<<8|A[t]>>>24)|4278255360&(A[t]<<24|A[t]>>>8);var n=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],r=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];for(this._b=0,t=0;t<4;t++)a.call(this);for(t=0;t<8;t++)r[t]^=n[t+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,B=l<<16|65535&c;for(r[0]^=c,r[1]^=u,r[2]^=l,r[3]^=B,r[4]^=c,r[5]^=u,r[6]^=l,r[7]^=B,t=0;t<4;t++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.Rabbit=t._createHelper(s)}(),e.Rabbit)}(yo)),Uo||(Uo=1,function(A){var e;A.exports=(e=Jn(),or(),ur(),Tr(),Pr(),function(){var A=e,t=A.lib.StreamCipher,n=A.algo,r=[],o=[],i=[],s=n.RabbitLegacy=t.extend({_doReset:function(){var A=this._key.words,e=this.cfg.iv,t=this._X=[A[0],A[3]<<16|A[2]>>>16,A[1],A[0]<<16|A[3]>>>16,A[2],A[1]<<16|A[0]>>>16,A[3],A[2]<<16|A[1]>>>16],n=this._C=[A[2]<<16|A[2]>>>16,4294901760&A[0]|65535&A[1],A[3]<<16|A[3]>>>16,4294901760&A[1]|65535&A[2],A[0]<<16|A[0]>>>16,4294901760&A[2]|65535&A[3],A[1]<<16|A[1]>>>16,4294901760&A[3]|65535&A[0]];this._b=0;for(var r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)n[r]^=t[r+4&7];if(e){var o=e.words,i=o[0],s=o[1],c=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=c>>>16|4294901760&l,B=l<<16|65535&c;for(n[0]^=c,n[1]^=u,n[2]^=l,n[3]^=B,n[4]^=c,n[5]^=u,n[6]^=l,n[7]^=B,r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(A,e){var t=this._X;a.call(this),r[0]=t[0]^t[5]>>>16^t[3]<<16,r[1]=t[2]^t[7]>>>16^t[5]<<16,r[2]=t[4]^t[1]>>>16^t[7]<<16,r[3]=t[6]^t[3]>>>16^t[1]<<16;for(var n=0;n<4;n++)r[n]=16711935&(r[n]<<8|r[n]>>>24)|4278255360&(r[n]<<24|r[n]>>>8),A[e+n]^=r[n]},blockSize:4,ivSize:2});function a(){for(var A=this._X,e=this._C,t=0;t<8;t++)o[t]=e[t];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<o[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<o[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<o[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<o[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<o[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<o[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<o[6]>>>0?1:0)|0,this._b=e[7]>>>0<o[7]>>>0?1:0,t=0;t<8;t++){var n=A[t]+e[t],r=65535&n,s=n>>>16,a=((r*r>>>17)+r*s>>>15)+s*s,c=((4294901760&n)*n|0)+((65535&n)*n|0);i[t]=a^c}A[0]=i[0]+(i[7]<<16|i[7]>>>16)+(i[6]<<16|i[6]>>>16)|0,A[1]=i[1]+(i[0]<<8|i[0]>>>24)+i[7]|0,A[2]=i[2]+(i[1]<<16|i[1]>>>16)+(i[0]<<16|i[0]>>>16)|0,A[3]=i[3]+(i[2]<<8|i[2]>>>24)+i[1]|0,A[4]=i[4]+(i[3]<<16|i[3]>>>16)+(i[2]<<16|i[2]>>>16)|0,A[5]=i[5]+(i[4]<<8|i[4]>>>24)+i[3]|0,A[6]=i[6]+(i[5]<<16|i[5]>>>16)+(i[4]<<16|i[4]>>>16)|0,A[7]=i[7]+(i[6]<<8|i[6]>>>24)+i[5]|0}A.RabbitLegacy=t._createHelper(s)}(),e.RabbitLegacy)}(Fo)),Eo(),e)}(Gn);var Ho=Gn.exports;let Io=class{constructor(){this.screenshotManager=null,this.debug=!1,this.deviceId=null,this.initResult=null,this.config=null,this.screenshotCallback=null,this.initCallback=null}async init(A,e,t){try{this.config=A,this.screenshotCallback=e||null,this.initCallback=t||null,this.debug=A.debug??!1;const n=await this.getRawDeviceId();this.debug&&console.log("Raw Device ID:",n);const r=document.location.href;let o="";try{o=new URL(r).hostname}catch(A){o=""}this.deviceId=Ho.MD5(n+o).toString(),this.debug&&(console.log("MD5 Device ID (for frontend):",this.deviceId),console.log("Referrer used:",r));const i={deviceId:this.deviceId,referrer:r,agent:A.agent,timestamp:Date.now()},s=A.target||void 0;if(A.screenshot){const t="string"==typeof s?document.querySelector(s):s||document.body,n=e?.sendData;this.debug&&(console.log("[CustomerSDK] 初始化截图管理器:"),console.log(" screenshotCallback:",e?"存在":"null/undefined",e),console.log(" screenshotCallback?.sendData:",e?.sendData?"存在":"null/undefined",typeof e?.sendData,e?.sendData),console.log(" sendToExternal:",n?"存在":"undefined",typeof n,n),console.log(" 即将传递给 ScreenshotManager 的参数:",{targetElement:t?"存在":"null",screenshot:A.screenshot?"存在":"null",sendToExternal:n?"存在":"undefined"})),this.screenshotManager=new ht(t,A.screenshot,n),e?.onConfig&&this.setupScreenshotConfigListener(e.onConfig)}return this.initResult=i,this.debug&&console.log("CustomerSDK initialized successfully (screenshot only)"),i}catch(A){throw console.error("Failed to initialize CustomerSDK:",A),A}}setupScreenshotConfigListener(A){const e=e=>{try{if(!e.data||"checkScreenshot"!==e.data.type)return;this.debug&&console.log("[CustomerSDK] Received screenshot config message:",e.data),e.data.data&&"string"==typeof e.data.data&&A(e.data.data)}catch(A){this.debug&&console.error("[CustomerSDK] Error handling screenshot config message:",A)}};window.addEventListener("message",e),this._screenshotConfigHandler=e}triggerScreenshotConfig(A){this.screenshotManager?this.screenshotManager.handleScreenshotConfig(A):this.debug&&console.warn("[CustomerSDK] ScreenshotManager not initialized")}getScreenshotManager(){return this.screenshotManager}getDeviceId(){return this.deviceId}getInitResult(){return this.initResult}async updateToken(A,e,t){if(!this.config)throw new Error("SDK not initialized. Call init() first.");this.debug&&console.log("Updating token:",A?"Token provided":"Token removed");const n={...this.config,token:A&&""!==A.trim()?A:void 0};return this.destroy(),await this.init(n,e||this.screenshotCallback||void 0,t||this.initCallback||void 0)}async getRawDeviceId(){this.debug&&console.log("🔍 Starting to get device fingerprint...");try{this.debug&&console.log("📦 Loading FingerprintJS...");const A=await Nn.load();this.debug&&console.log("🎯 Getting device fingerprint...");const e=await A.get();return this.debug&&(console.log("✅ FingerprintJS result:",e),console.log("🆔 Device ID obtained:",e.visitorId)),e.visitorId}catch(A){this.debug&&console.warn("❌ Failed to get device fingerprint, using fallback:",A);const e="device_"+Date.now()+"_"+Math.random().toString(36).substr(2,9);return this.debug&&console.log("🆔 Fallback Device ID:",e),e}}destroy(){this.screenshotManager?.destroy(),this._screenshotConfigHandler&&(window.removeEventListener("message",this._screenshotConfigHandler),this._screenshotConfigHandler=null),this.screenshotManager=null,this.initResult=null,this.deviceId=null,this.debug&&console.log("CustomerSDK destroyed")}},xo=null;function So(){return xo||(xo=new Io),xo}const Lo=async(A,e,t)=>{const n=So();return await n.init(A,e,t)},Ko=A=>{So().triggerScreenshotConfig(A)},ko=()=>{So().destroy(),xo=null},Mo=()=>So().getDeviceId(),Do=()=>So(),To=Io;var Ro={init:Lo,triggerScreenshotConfig:Ko,destroy:ko,getDeviceId:Mo,getInstance:Do,CustomerSDK:To};A.CustomerSDK=To,A.default=Ro,A.destroy=ko,A.getDeviceId=Mo,A.getInstance=Do,A.init=Lo,A.triggerScreenshotConfig=Ko,Object.defineProperty(A,"__esModule",{value:!0})});
|
package/package.json
CHANGED