EFF-809: Add platform Crypto service#2180
Conversation
🦋 Changeset detectedLatest commit: 5f5e452 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bundle Size Analysis
|
📊 JSDoc Documentation Analysis📈 Current Analysis ResultsThis comment is automatically updated on each push. View the analysis script for details. |
|
https://www.postgresql.org/docs/current/release-18.html, it supports UUIDv7 too. is it possible to include UUIDv7 generation? |
4803bd9 to
b61217b
Compare
|
@tim-smart another thing I was thinking about in this PR is we should make sure that the JSDocs line up with the range of random numbers generated and keep that consistent in the crypto service. For example, Also, I think the const nextDoubleUnsafe = (): number => {
const array = new Uint32Array(1)
NodeCrypto.getRandomValues(array)
return array[0] / (0xFFFFFFFF + 1)
}In addition, the function getSecureRandomNumber() {
const buffer = crypto.randomBytes(4)
return buffer.readUInt32BE(0)
} but that would imply a random range of 0 to 2^32 - 1, which is different than the range that In summary, I think we first need to standardize the random ranges we are targeting and then we can bring all the methods into sync and clean them up. @tim-smart lmk what you think. |
8e36cee to
d4ceff9
Compare
Summary
Cryptoservice with random bytes, UUIDv4/UUIDv7 generation, random helpers, and digest operations.Random.nextUUIDv4and document/test the new Crypto service replacement.DigestAlgorithma string literal union and moving derived random helpers / UUIDv4 onto theCryptoservice viaCrypto.make.Crypto.randomUUIDv7, derived from platformrandomBytes(16)andClock.currentTimeMillisfor the UUIDv7 timestamp.node:cryptocreateHashand use Web Crypto digest algorithm strings directly in the browser implementation.Verification
pnpm lint-fixpnpm codegen(ran; unrelated generated barrel churn was restored, with focused Crypto barrel docs kept)pnpm test packages/effect/test/Crypto.test.ts packages/effect/test/Random.test.ts packages/platform-browser/test/BrowserCrypto.test.ts packages/platform-node/test/NodeCrypto.test.tspnpm check:tsgocd packages/effect && pnpm docgen