mirror of
https://github.com/strapi/strapi.git
synced 2025-10-20 04:24:23 +00:00
15 lines
433 B
TypeScript
15 lines
433 B
TypeScript
![]() |
import crypto from 'crypto';
|
||
|
import { machineIdSync } from 'node-machine-id';
|
||
|
|
||
|
export const generateInstallId = (projectId: string, installId: string) => {
|
||
|
if (installId) return installId;
|
||
|
try {
|
||
|
const machineId = machineIdSync();
|
||
|
return projectId
|
||
|
? crypto.createHash('sha256').update(`${machineId}-${projectId}`).digest('hex')
|
||
|
: crypto.randomUUID();
|
||
|
} catch (error) {
|
||
|
return crypto.randomUUID();
|
||
|
}
|
||
|
};
|