Open dcousens opened 1 year ago
The length of cuid2 can be configured. It is base36 encoded with the first character always being a letter.
@DrJume are you saying that we should change the default length?
~Isn't it base26?~ No, it uses .toString(36)
for the rest of the string, amended the OP
Nono, just wanted to inform you that cuid2 is not always 24 characters long. https://github.com/paralleldrive/cuid2#parameterized-length
@tomdo1234 recently reported this as a security vulnerability, and I have opened an advisory in https://github.com/keystonejs/keystone/security/advisories/GHSA-5fp6-4xw3-xqq3 - with the following justification:
You might actually want the features of a monotonically increasing (auto-increment, k-sortable), and timestamp-based id as part of your application, and keystone should support that - but you might not want them by default. This is why this security advisory has been accepted by me (@dcousens) we currently use
cuid
identifiers by default, and that should change.
As of https://github.com/keystonejs/keystone/pull/8648 (to be released soon), you can now use
db: { idField: { kind: 'cuid2' } }
On your lists to use cuid2
as your identifiers, and you can probably upgrade your lists in a non-breaking way if you are using your identifiers relatively opaquely.
In our next major update, we will change the default to cuid2
to resolve https://github.com/keystonejs/keystone/security/advisories/GHSA-5fp6-4xw3-xqq3.
https://github.com/paralleldrive/cuid has been deprecated by @ericelliott in favour of
cuid2
. The reasoning for the deprecation iscuid2
is effectively a random 24 character base36 string. Prisma has an open issue forcuid2
https://github.com/prisma/prisma/issues/17102, which will be an easy transition for us, but is thereby blocking for now.Related