Skip to content

feat: add base64id to replacements#595

Merged
43081j merged 1 commit intoe18e:mainfrom
gameroman:base64id
Apr 14, 2026
Merged

feat: add base64id to replacements#595
43081j merged 1 commit intoe18e:mainfrom
gameroman:base64id

Conversation

@gameroman
Copy link
Copy Markdown
Contributor

🔗 Linked issue

Closes #552

📚 Description

add base64id to replacements

@43081j 43081j merged commit 4579976 into e18e:main Apr 14, 2026
4 checks passed
@gameroman gameroman deleted the base64id branch April 14, 2026 20:46
Copy link
Copy Markdown

@Dustin4444 Dustin4444 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ #600

Comment on lines +72 to +73
"description": "You can use `crypto.randomBytes` with `Buffer.prototype.toString` to generate a random base64 id",
"example": "import crypto from 'node:crypto'\nconst id = crypto.randomBytes(15).toString('base64').replaceAll('+', '-').replaceAll('/', '_')"
Copy link
Copy Markdown
Contributor

@SuperchupuDev SuperchupuDev Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late comment but we should probably recommend Uint8Array over Buffer due to it being a built-in javascript feature, now that it has base64 support

sindre has a blog post that goes in depth about this topic: https://sindresorhus.com/blog/goodbye-nodejs-buffer

example with Uint8Array + web crypto api (no imports needed):

crypto.getRandomValues(new Uint8Array(15)).toBase64();

Copy link
Copy Markdown
Contributor Author

@gameroman gameroman Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the original package also uses node:crypto module I decided to keep it simple

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can one of you open an issue so we can look into it?

i think you may be right and we should just use uint8arrays but lets track it in a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Replacement]: base64id

4 participants