Merge branch 'v1' into 0xsequence/master#105
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
|
Reviewer's GuideBumps all Sequence monorepo packages from 1.10.14 to 1.10.15 and records the 1.10.15 patch release in each package’s changelog, centering around a new shared utility Flow diagram for the 1.10.15 patch release and version bumpflowchart LR
A["Codebase at version 1.10.14"] --> B["Implement utils.extractProjectIdFromAccessKey in @0xsequence/utils"]
B --> C["Update internal packages to use the shared utility where needed"]
C --> D["Bump package versions from 1.10.14 to 1.10.15 in package.json"]
D --> E["Record 1.10.15 entries in each package CHANGELOG (mentioning extractProjectIdFromAccessKey)"]
E --> F["Update core VERSION constant to 1.10.15"]
F --> G["Publish 1.10.15 packages to registry"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Summary of ChangesHello @Dargon789, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on a routine version increment for all packages in the 0xsequence monorepo, moving them to "1.10.15". This update incorporates a new utility function, "extractProjectIdFromAccessKey", within the "utils" package, and ensures that all internal package dependencies are aligned with this new version. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request primarily consists of version bumps for the 1.10.15 release and updates to changelogs. The main functional change is the introduction of the extractProjectIdFromAccessKey utility.
My review found a critical issue in the implementation of this new utility. The function for extracting the project ID from an access key is flawed and will produce incorrect results for many keys due to improper handling of 64-bit integers in JavaScript and the use of a non-portable atob function. I've left a detailed comment with a suggested fix on the relevant changelog entry, as the source file itself was not part of the provided patch. It is crucial to address this before the release.
|
|
||
| ### Patch Changes | ||
|
|
||
| - utils: extractProjectIdFromAccessKey |
There was a problem hiding this comment.
The new extractProjectIdFromAccessKey utility in packages/utils/src/access-key.ts has a critical bug.
- Incorrect 64-bit number reconstruction: The current implementation uses bitwise left shifts (
<<) on JavaScriptnumbertypes. These operators work on 32-bit signed integers, so any shift of 32 or more bits will produce incorrect results. This will lead to incorrect project IDs for many access keys. - Non-portable
atobfunction: The use ofatobis not portable as it's a browser-specific API and is deprecated in Node.js. The@0xsequence/utilspackage already hasjs-base64as a dependency, which should be used. - Incorrect return type: The function is declared to return a
number, but a 64-bit project ID can exceedNumber.MAX_SAFE_INTEGER. The return type should bebigint.
Here is a corrected version of the function that addresses these issues:
import { toUint8Array } from 'js-base64'
export const extractProjectIdFromAccessKey = (accessKey: string): bigint => {
// Convert URL-safe base64 string to standard base64 string
const base64String = accessKey.replace(/-/g, '+').replace(/_/g, '/')
// Decode the base64 string to a byte array
const byteArray = toUint8Array(base64String)
if (byteArray.length < 9) {
throw new Error('InvalidAccessKey: too short')
}
if (byteArray[0] !== 1) {
throw new Error('UnsupportedVersion')
}
// Extract the project ID from bytes 1 to 8 (8 bytes for a 64-bit integer)
const projectIdBytes = byteArray.slice(1, 9)
// Use DataView to read a 64-bit unsigned integer from the byte array
const view = new DataView(projectIdBytes.buffer, projectIdBytes.byteOffset, projectIdBytes.byteLength);
// false for big-endian, which matches the original logic's intent
const projectId = view.getBigUint64(0, false);
return projectId
}
Summary by Sourcery
Release version 1.10.15 across the monorepo packages.
New Features:
Enhancements: