1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-06 08:36:52 +02:00
joplin/packages/lib/uuid.ts
2020-12-28 11:48:47 +00:00

19 lines
585 B
TypeScript

const createUuidV4 = require('uuid/v4');
const { customAlphabet } = require('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() {
return createUuidV4().replace(/-/g, '');
},
createNano: function() {
return nanoid();
},
};