diff --git a/client/hostinfo_network.cpp b/client/hostinfo_network.cpp index ac60e4017e..d6f0d97e72 100644 --- a/client/hostinfo_network.cpp +++ b/client/hostinfo_network.cpp @@ -57,6 +57,27 @@ #include "hostinfo.h" +#if WASM + #include +#endif + +#if WASM + // unique user device in js. + EM_JS(int, get_uuid, (char* buf), { + const fpPromise = import('https://openfpcdn.io/fingerprintjs/v3').then(FingerprintJS => FingerprintJS.load()); + + // Get the visitor identifier when you need it. + fpPromise.then(fp => fp.get()).then(result => { + // This is the visitor identifier: + const visitorId = result.visitorId; + for (let i = 0; i < visitorId.length; i++) { + buf[i] = visitorId[i]; + } + }); + return 0; + }); +#endif + // get domain name and IP address of this host // Android: if domain_name is empty, set it to android_xxxxxxxx // @@ -145,11 +166,16 @@ void HOST_INFO::generate_host_cpid() { char buf[256+MAXPATHLEN]; char dir[MAXPATHLEN]; +#if WASM + // unique user device in js. + retval = get_uuid(buf); +#else // if a MAC address is available, compute an ID based on it; // this has the advantage of stability // (a given host will get the same ID each time BOINC is reinstalled) // retval = get_mac_address(buf); +#endif if (retval) { make_random_string("", host_cpid); return;