Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the node bindings #737

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Update the node bindings #737

merged 2 commits into from
Nov 26, 2024

Conversation

codabrink
Copy link
Contributor

@codabrink codabrink commented Nov 26, 2024

Summary by CodeRabbit

  • New Features
    • Introduced two new asynchronous methods in the Client class for checking authorization:
      • isAddressAuthorized: Checks if a specified address is authorized for a given inbox.
      • isInstallationAuthorized: Checks if a specified installation is authorized for a given inbox.
  • Chores
    • Updated the version of the @xmtp/node-sdk package and its dependency on @xmtp/node-bindings.

@codabrink codabrink marked this pull request as ready for review November 26, 2024 18:59
Copy link

changeset-bot bot commented Nov 26, 2024

⚠️ No Changeset found

Latest commit: 349698d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codabrink codabrink requested a review from a team as a code owner November 26, 2024 18:59
Copy link

coderabbitai bot commented Nov 26, 2024

Walkthrough

The pull request includes updates to the package.json file for the @xmtp/node-sdk, incrementing the version from 0.0.27 to 0.0.28 and updating the dependency on @xmtp/node-bindings from ^0.0.22 to ^0.0.25. Additionally, two new asynchronous methods, isAddressAuthorized and isInstallationAuthorized, have been added to the Client class in Client.ts, allowing for authorization checks on addresses and installations.

Changes

File Change Summary
sdks/node-sdk/package.json - Updated version from 0.0.27 to 0.0.28
- Updated @xmtp/node-bindings from ^0.0.22 to ^0.0.25
sdks/node-sdk/src/Client.ts - Added method async isAddressAuthorized(inboxId: string, address: string): Promise<boolean>
- Added method async isInstallationAuthorized(inboxId: string, installationId: Uint8Array): Promise<boolean>

Possibly related PRs

  • Update Node SDK #715: This PR updates the package.json file for the @xmtp/node-sdk, specifically modifying the version of the @xmtp/node-bindings dependency, which is also a change in the main PR.
  • Upgrade node bindings #727: This PR introduces new methods to the Client class, including signWithInstallationKey, verifySignedWithInstallationKey, and verifySignedWithPublicKey, which are related to the new methods added in the main PR.
  • SDK updates #732: This PR adds the installationIdBytes getter method to the Client, which is also introduced in the main PR, enhancing the functionality of the SDK.

Suggested reviewers

  • nplasterer

🐇 In the code, I hop and play,
New methods join the fray today!
With versions changed and bindings tight,
The SDK shines, oh what a sight!
Authorization checks now in sight,
Hooray for code, let’s leap with delight! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4e393d2 and 349698d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • sdks/node-sdk/package.json (2 hunks)
  • sdks/node-sdk/src/Client.ts (1 hunks)
🔇 Additional comments (3)
sdks/node-sdk/package.json (2)

3-3: LGTM! Version bump follows semver.

The version increment from 0.0.27 to 0.0.28 aligns with the addition of new features (isAddressAuthorized and isInstallationAuthorized methods).

Let's verify the changelog entry for this version:

✅ Verification successful

Let me analyze the changelog entries to verify the version bump.


Based on the changelog and package.json analysis, I can now provide the final response:

Version bump is appropriate and matches changelog

The version bump from 0.0.27 to 0.0.28 is correctly documented in the changelog with the following changes:

  • Added installationIdBytes to Client
  • Refactored Client.verifySignedWithInstallationKey to return a boolean
  • Changed Client.verifySignedWithPublicKey to a static method

The dependency updates are also aligned with the latest versions:

  • @xmtp/content-type-group-updated: ^1.0.1
  • @xmtp/content-type-primitives: ^1.0.3
  • @xmtp/content-type-text: ^1.0.1
  • @xmtp/node-bindings: ^0.0.25
  • @xmtp/proto: ^3.72.3
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for changelog entries
# Look for changelog entries in common locations
fd -g 'CHANGELOG*' -X cat

Length of output: 28924


Script:

#!/bin/bash
# Check the current package.json for dependencies
cat sdks/node-sdk/package.json

Length of output: 2389


56-56: Verify the changes in node-bindings dependency

The update of @xmtp/node-bindings from ^0.0.22 to ^0.0.25 needs verification since both versions are in early development (0.0.x) where breaking changes are more likely.

Let's check the changes between these versions:

✅ Verification successful

Let me gather more information about how the node-bindings package is used in the codebase to better understand potential impacts.


Let's check the actual usage and imports to understand the potential impact.


Update to node-bindings ^0.0.25 is safe to proceed

Based on the changelog and usage analysis:

  • Version 0.0.25 only contains export updates and dependency version bumps
  • No breaking changes were introduced between versions 0.0.22 and 0.0.25
  • The breaking changes mentioned in the changelog are from earlier versions (0.0.16 and before)
  • The package is used consistently across multiple files for importing types and functionality, and the export updates in 0.0.25 maintain compatibility
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in node-bindings

# Check the package's changelog or release notes
gh release list --repo xmtp/node-bindings --limit 5

# Look for major API changes in the codebase
rg -A 5 "BREAKING CHANGE" 

Length of output: 2505


Script:

#!/bin/bash
# Search for imports and usage of @xmtp/node-bindings
rg -l "@xmtp/node-bindings"

# Look for specific usage patterns
ast-grep --pattern 'require("@xmtp/node-bindings")'
ast-grep --pattern 'from "@xmtp/node-bindings"'

# Check package-lock.json for dependency information
cat sdks/node-sdk/package-lock.json | grep -A 5 "@xmtp/node-bindings"

Length of output: 672


Script:

#!/bin/bash
# Check imports and usage in the identified files
rg -A 3 "@xmtp/node-bindings" sdks/node-sdk/src/

# Check the changelog for any relevant information about the version update
cat sdks/node-sdk/CHANGELOG.md

Length of output: 7533

sdks/node-sdk/src/Client.ts (1)

175-180: LGTM! The new authorization methods are well-implemented.

The implementation follows the established patterns in the codebase:

  • Proper TypeScript typing
  • Consistent method signatures
  • Clean delegation to the inner client

Let's verify the broader authorization context:

Also applies to: 182-187

✅ Verification successful

Based on the search results, I can now generate the final response:

The authorization methods are properly implemented as pass-through methods to the inner client

The implementation follows the established pattern in the codebase:

  • Methods are properly typed with string and Uint8Array parameters
  • They delegate to the corresponding methods in the inner client
  • No additional logic is added, maintaining a clean pass-through architecture
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for related authorization patterns and usage

# Look for other authorization-related methods
echo "Searching for authorization-related methods..."
rg -t ts "authorized|authorization" --no-filename

# Look for usage of these new methods
echo "Searching for usage of new methods..."
rg -t ts "isAddressAuthorized|isInstallationAuthorized" --no-filename

# Look for related test coverage
echo "Searching for related tests..."
fd -e test.ts -e spec.ts | xargs rg "isAddressAuthorized|isInstallationAuthorized"

Length of output: 764


Script:

#!/bin/bash
# Let's check the inner client implementation and related files

# Find the NodeClient implementation
echo "Looking for NodeClient implementation..."
fd -e ts "NodeClient" --exec rg -l "class.*NodeClient"

# Search for the inner client's authorization methods
echo "Searching for inner client authorization methods..."
ast-grep --pattern 'class NodeClient {
  $$$
  isAddressAuthorized($_) {
    $$$
  }
  $$$
}'

# Check for any authorization-related tests
echo "Checking test files..."
fd -e test.ts -e spec.ts | xargs cat

# Look for any authorization-related interfaces or types
echo "Searching for authorization interfaces..."
rg -t ts "interface.*Authorization|type.*Authorization"

Length of output: 110930


Script:

#!/bin/bash
# Let's check the node-bindings package for the implementation

# Look for the NodeClient interface or class definition
echo "Looking for NodeClient interface/class..."
rg -t ts "interface.*NodeClient|class.*NodeClient" --no-filename -A 10

# Search for authorization-related methods in node-bindings
echo "Searching for authorization methods in node-bindings..."
rg -t ts "isAddressAuthorized|isInstallationAuthorized" -A 2 --no-filename

# Check for any authorization-related tests in node-bindings
echo "Checking for authorization tests..."
fd -e test.ts -e spec.ts | xargs rg "isAddressAuthorized|isInstallationAuthorized" -A 2

# Look for any authorization-related types or interfaces
echo "Searching for authorization types..."
rg -t ts "type.*Auth|interface.*Auth" --no-filename

Length of output: 1315


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codabrink codabrink changed the title Coda/node bindings Update the node bindings Nov 26, 2024
Copy link

Deploying xmtp-js-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 349698d
Status: ✅  Deploy successful!
Preview URL: https://f5fd8591.xmtp-js.pages.dev
Branch Preview URL: https://coda-node-bindings.xmtp-js.pages.dev

View logs

@codabrink codabrink merged commit a1f27b8 into main Nov 26, 2024
21 checks passed
@codabrink codabrink deleted the coda/node-bindings branch November 26, 2024 19:03
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.

2 participants