Skip to content

feat: support versioned providers #35

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

Merged
merged 6 commits into from
Jun 9, 2025
Merged

Conversation

ChinmayMhatre
Copy link
Contributor

@ChinmayMhatre ChinmayMhatre commented Jun 4, 2025

Description

Testing (ignore for documentation update)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist:

Additional Notes:

Summary by CodeRabbit

  • New Features

    • Added support for specifying and tracking provider version information throughout proof request processes.
    • Users can now provide a provider version, which is validated and included in session initialization and request URLs.
    • Updated UI text to simplify instructions on starting the claim process.
  • Bug Fixes

    • Improved validation to ensure the provider version, if provided, is a valid string.
  • Documentation

    • Updated type definitions to reflect new version-related fields for improved clarity.

Copy link

coderabbitai bot commented Jun 4, 2025

Walkthrough

The changes introduce support for providerVersion and resolvedProviderVersion fields throughout the proof request lifecycle. These fields are added to relevant types, validated, serialized, and propagated during initialization, session handling, and template data construction. Function signatures and internal logic are updated to handle these versioning fields consistently.

Changes

File(s) Change Summary
src/Reclaim.ts Added handling, validation, serialization, and propagation of providerVersion and resolvedProviderVersion in the ReclaimProofRequest class and related methods.
src/utils/sessionUtils.ts Updated initSession function to accept and forward an optional versionNumber parameter in API requests.
src/utils/types.ts Extended types to include providerVersion and resolvedProviderVersion fields in relevant interfaces.
src/utils/validationUtils.ts Added type validation for providerVersion in the validateOptions function.
package.json Updated package version from "4.1.0" to "4.2.0".
example/src/app/page.tsx Updated UI text: changed heading and simplified instructional paragraph.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ReclaimProofRequest
    participant SessionUtils
    participant Backend

    Client->>ReclaimProofRequest: init(applicationId, appSecret, providerId, {providerVersion})
    ReclaimProofRequest->>SessionUtils: initSession(providerId, appId, timestamp, signature, providerVersion)
    SessionUtils->>Backend: POST /api/sdk/init/session/ (with versionNumber)
    Backend-->>SessionUtils: { resolvedProviderVersion }
    SessionUtils-->>ReclaimProofRequest: InitSessionResponse
    ReclaimProofRequest-->>Client: ReclaimProofRequest instance (with resolvedProviderVersion)
Loading

Poem

In fields of code, new versions bloom,
With providerVersion now in every room.
Requests and sessions, all in line,
Carry their versions—oh, how fine!
The rabbit hops with glee and cheer,
For versioned proofs are finally here.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8bf7be4 and b3bf088.

📒 Files selected for processing (1)
  • example/src/app/page.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • example/src/app/page.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/utils/sessionUtils.ts (1)

25-26: Consider adding validation for the new parameter.

The optional versionNumber parameter maintains backward compatibility, but consider adding validation within this function to ensure type safety.

export async function initSession(
  providerId: string,
  appId: string,
  timestamp: string,
  signature: string,
  versionNumber?: string
): Promise<InitSessionResponse> {
  logger.info(`Initializing session for providerId: ${providerId}, appId: ${appId}`);
+  
+  // Validate versionNumber if provided
+  if (versionNumber !== undefined) {
+    validateFunctionParams([
+      { input: versionNumber, paramName: 'versionNumber', isString: true }
+    ], 'initSession');
+  }
+  
  try {
src/Reclaim.ts (1)

512-513: Consider handling undefined resolvedProviderVersion more explicitly.

Defaulting to empty string might mask cases where resolvedProviderVersion should be present but isn't set.

-  jsonProofResponse: this.jsonProofResponse,
-  resolvedProviderVersion: this.resolvedProviderVersion ?? ''
+  jsonProofResponse: this.jsonProofResponse,
+  resolvedProviderVersion: this.resolvedProviderVersion || ''

Consider logging a warning when resolvedProviderVersion is undefined:

+  if (!this.resolvedProviderVersion) {
+    logger.info('Warning: resolvedProviderVersion is undefined during serialization');
+  }
   resolvedProviderVersion: this.resolvedProviderVersion ?? ''
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1db6380 and cf7bfdd.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • src/Reclaim.ts (11 hunks)
  • src/utils/sessionUtils.ts (1 hunks)
  • src/utils/types.ts (4 hunks)
  • src/utils/validationUtils.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/utils/sessionUtils.ts (2)
src/utils/types.ts (1)
  • InitSessionResponse (69-72)
src/utils/constants.ts (1)
  • BACKEND_BASE_URL (2-2)
src/utils/validationUtils.ts (1)
src/utils/errors.ts (1)
  • InvalidParamError (28-28)
🔇 Additional comments (10)
src/utils/validationUtils.ts (1)

152-155: LGTM! Validation follows established patterns.

The providerVersion validation is correctly implemented using the same pattern as existing option validations, with proper type checking and error handling.

src/utils/sessionUtils.ts (1)

33-33: JSON payload correctly includes version information.

The versionNumber is appropriately included in the request body and will be sent to the backend API.

src/utils/types.ts (3)

34-34: Comprehensive type support for version options.

The ProofRequestOptions type correctly includes both versionNumber and providerVersion as optional fields, supporting flexible version specification.

Also applies to: 41-41


71-71: Appropriate addition of version tracking in session response.

The resolvedProviderVersion field in InitSessionResponse enables the backend to communicate the resolved version information back to the client.


107-107: Consistent version field integration across data structures.

Both ProofPropertiesJSON and TemplateData types are properly updated to include version fields, ensuring consistent serialization and template data handling.

Also applies to: 123-124

src/Reclaim.ts (5)

142-143: Proper initialization of version fields in template data.

The empty template data correctly includes the new version fields with appropriate default values.


156-156: Appropriate private property for resolved version.

The resolvedProviderVersion property is correctly defined as optional since it's set after session initialization.


225-229: Consistent validation pattern for provider version.

The validation follows the established pattern used for other options in the constructor.


268-270: Proper integration with session initialization.

The providerVersion is correctly passed to initSession and the resolvedProviderVersion response is properly stored.


529-530: Consistent version field propagation in template data.

Both getRequestUrl and triggerReclaimFlow methods correctly include the version fields in their template data, ensuring consistency across different flow paths.

Also applies to: 586-587

Comment on lines +337 to +347
if (options?.providerVersion) {
validateFunctionParams([
{ input: options.providerVersion, paramName: 'providerVersion', isString: true }
], 'fromJsonString');
}

if (resolvedProviderVersion) {
validateFunctionParams([
{ input: resolvedProviderVersion, paramName: 'resolvedProviderVersion', isString: true }
], 'fromJsonString');
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider making resolvedProviderVersion validation mandatory.

The validation only occurs if resolvedProviderVersion exists, but according to the type definition in ProofPropertiesJSON, it's a required field.

-  if (resolvedProviderVersion) {
-    validateFunctionParams([
-      { input: resolvedProviderVersion, paramName: 'resolvedProviderVersion', isString: true }
-    ], 'fromJsonString');
-  }
+  validateFunctionParams([
+    { input: resolvedProviderVersion, paramName: 'resolvedProviderVersion', isString: true }
+  ], 'fromJsonString');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (options?.providerVersion) {
validateFunctionParams([
{ input: options.providerVersion, paramName: 'providerVersion', isString: true }
], 'fromJsonString');
}
if (resolvedProviderVersion) {
validateFunctionParams([
{ input: resolvedProviderVersion, paramName: 'resolvedProviderVersion', isString: true }
], 'fromJsonString');
}
if (options?.providerVersion) {
validateFunctionParams([
{ input: options.providerVersion, paramName: 'providerVersion', isString: true }
], 'fromJsonString');
}
validateFunctionParams([
{ input: resolvedProviderVersion, paramName: 'resolvedProviderVersion', isString: true }
], 'fromJsonString');
🤖 Prompt for AI Agents
In src/Reclaim.ts around lines 337 to 347, the validation for
resolvedProviderVersion is conditional but it should be mandatory since the type
definition requires it. Remove the conditional check so that
validateFunctionParams is always called for resolvedProviderVersion, ensuring it
is validated regardless of its presence check.

@ChinmayMhatre ChinmayMhatre merged commit eff5789 into main Jun 9, 2025
1 check passed
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.

3 participants