Skip to content

Commit 5e529e4

Browse files
committed
feat: enhance package configuration and global exposure
- Updated package.json to include module and exports fields for better compatibility with ESM and CommonJS. - Added build scripts for generating type declarations and bundling the library in multiple formats (esm, cjs, iife). - Introduced tsup as a development dependency for efficient bundling. - Modified src/index.ts to expose getCurrentBrowserFingerPrint as a global function for UMD/IIFE builds, ensuring compatibility with classic script usage.
1 parent 8665be2 commit 5e529e4

File tree

11 files changed

+3104
-291
lines changed

11 files changed

+3104
-291
lines changed

lib/code/EncryptDecrypt.js

Lines changed: 0 additions & 86 deletions
This file was deleted.

lib/code/FingerPrint.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

lib/code/GenerateCanvasFingerprint.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

lib/code/generateTheAudioPrints.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

lib/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
* @return {Promise<string>} - resolve(string)
55
*/
66
export declare const getCurrentBrowserFingerPrint: () => Promise<string>;
7+
declare global {
8+
interface Navigator {
9+
brave: {
10+
isBrave: () => {};
11+
};
12+
}
13+
}

lib/index.global.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 1 addition & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var m=(t,r,e)=>new Promise((f,n)=>{var a=i=>{try{s(e.next(i))}catch(u){n(u)}},d=i=>{try{s(e.throw(i))}catch(u){n(u)}},s=i=>i.done?f(i.value):Promise.resolve(i.value).then(a,d);s((e=e.apply(t,r)).next())});var g=function(t,r=0){let e=3735928559^r,f=1103547991^r;for(let n=0,a;n<t.length;n++)a=t.charCodeAt(n),e=Math.imul(e^a,2654435761),f=Math.imul(f^a,1597334677);return e=Math.imul(e^e>>>16,2246822507)^Math.imul(f^f>>>13,3266489909),f=Math.imul(f^f>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),4294967296*(2097151&f)+(e>>>0)};var A=()=>{var t=document.createElement("canvas");return!!(t.getContext&&t.getContext("2d"))},h=()=>{if(!A())return"broprint.js";var t=document.createElement("canvas"),r=t.getContext("2d"),e="BroPrint.65@345876";return r.textBaseline="top",r.font="14px 'Arial'",r.textBaseline="alphabetic",r.fillStyle="#f60",r.fillRect(125,1,62,20),r.fillStyle="#069",r.fillText(e,2,15),r.fillStyle="rgba(102, 204, 0, 0.7)",r.fillText(e,4,17),t.toDataURL()};var p=function(){var t=null,r=null,e=null,f=null,n=null,a=null;function d(o,l=!1){a=o;try{s(),e.connect(f),f.connect(t.destination),e.start(0),t.startRendering(),t.oncomplete=b}catch(x){if(l)throw x}}function s(){i(),r=t.currentTime,u(),v()}function i(){var o=window.OfflineAudioContext||window.webkitOfflineAudioContext;t=new o(1,44100,44100)}function u(){e=t.createOscillator(),e.type="triangle",e.frequency.setValueAtTime(1e4,r)}function v(){f=t.createDynamicsCompressor(),c("threshold",-50),c("knee",40),c("ratio",12),c("reduction",-20),c("attack",0),c("release",.25)}function c(o,l){f[o]!==void 0&&typeof f[o].setValueAtTime=="function"&&f[o].setValueAtTime(l,t.currentTime)}function b(o){w(o),f.disconnect()}function w(o){for(var l=null,x=4500;5e3>x;x++){var C=o.renderedBuffer.getChannelData(0)[x];l+=Math.abs(C)}if(n=l.toString(),typeof a=="function")return a(n)}return{run:d}}();var P=()=>{let t=new Promise((e,f)=>{p.run(function(n){e(n)})});return new Promise((e,f)=>{t.then(n=>m(null,null,function*(){let a="";navigator.brave&&(yield navigator.brave.isBrave())?a=window.btoa(n)+h():a=window.btoa(n)+h(),e(g(a,0))})).catch(()=>{try{e(g(h()).toString())}catch(n){f("Failed to generate the finger print of this browser")}})})};try{typeof window!="undefined"&&!window.getCurrentBrowserFingerPrint&&(window.getCurrentBrowserFingerPrint=P)}catch(t){}export{P as getCurrentBrowserFingerPrint};

0 commit comments

Comments
 (0)