Unique machine id UXP

Hello,
we have an external service to handle subscriptions and we need some way to extract a unique identifier of the machine where the license key (provided by us) is activated. In CEP we used to run a shell command. We can’t seem to find a similar functionality, how do we do it in UXP?
We need this because we also give free video courses on our website to whoever is subscribed.
Thank you

Did you ever find a solution?

It seems that to use UXP fully you need to create a separate application, for example on Electron and use it via Websocket. However, I have not checked if WS works on UXP. It is quite possible that only half works. lol

Yes, there is also Hybrid Plugins. But this is a completely dark forest for me. Does anyone use it here?

1 Like

Guys, with the

const os = require('os');

you have so many options to build a unique ID yourself combining os functionalities.

You have:

os.platform();
os.totalmem();
os.cpus();
os.homedir();

Mind that sometimes the

os.homedir();

has special characters that you would need to handle but you can use something like:

os.homedir().split("/")[2]).replace(/[äëïöüãõ]/g, "");

to get the user name in the computer and use some other os things to build the unique ID.

This is the way.

Here’re the docs:
https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/os/OS/

Hope this helps.

1 Like

That’s pretty much what I figured and use now

export const generateInstanceName = (): string => {
    let osDataList = `${os.platform()}_${os.arch()}_${formatBytes(os.totalmem(), 0)}`
    const hash = HmacMD5(
        `${osDataList}_${os.homedir()}_${JSON.stringify(os.cpus())}_${userInfo.userId()}`,
        salt,
    )

    return `${osDataList}_${hash}`
}
1 Like

What if the user renames their homedir or installs more RAM in their computer—will you make them buy a new license? And it’s simply difficult to handle such requests from users who have made changes to their system and as a result lost their license. We need the good old spawn process/exec—at least that way we could retrieve MAC addresses.

Users don’t need necessary to lose their licenses. I don’t know your workflow but what I did with our users, they have a “reset” button in their dashboard so they can reset the license computers slots to 0 and install the license in a new computer if they change hardware or update computer information. Is pretty straightforward and nothing difficult about it. They do it themselves and support is right on the website.

It was some of back-end work to make it work as we wanted but works perfectly for more than 4 years now.

If you want to have full user license control you definitely need to build your own server and manage the logic there. It really worth it like 1000%.

I went a tiny step further. Currently I have set up, that a license has 2 seats. If the limit is reached and 3rd machine tries to activate license, I show a list with checkboxes which instance(s) they want to deactivate, so that they wouldn’t need to re-enter license details on the machine they still use

2 Likes

That’s the way! The better user experience, the better your product / service will be, great choice.