1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/lib/uuid.ts

19 lines
586 B
TypeScript
Raw Normal View History

2022-11-17 17:19:32 +02:00
import { v4 as uuidv4 } from 'uuid';
import { customAlphabet } from 'nanoid/non-secure';
// https://zelark.github.io/nano-id-cc/
// https://security.stackexchange.com/a/41749/1873
// > On the other hand, 128 bits (between 21 and 22 characters
// > alphanumeric) is beyond the reach of brute-force attacks pretty much
// > indefinitely
const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 22);
export default {
create: function(): string {
2022-11-17 17:19:32 +02:00
return uuidv4().replace(/-/g, '');
},
createNano: function(): string {
return nanoid();
},
};