Skip to content

[TA-4892]: delegate action modal#26

Merged
AdriaCarrera merged 15 commits intomainfrom
auth0/feat/delegate-action-modal
Jul 23, 2025
Merged

[TA-4892]: delegate action modal#26
AdriaCarrera merged 15 commits intomainfrom
auth0/feat/delegate-action-modal

Conversation

@GuillemGarciaDev
Copy link
Collaborator

@GuillemGarciaDev GuillemGarciaDev commented Jun 19, 2025

[TA-4892]: delegate action modal

Changes 🛠️

packages/auth0

  • Add Delegate action form code (index.js, index.css and schema.json).
  • Add support to authorize-app.action to support delegate action form trigger

Summary by CodeRabbit

  • New Features
    • Added support for delegate action authorization with a new prompt displaying detailed delegate action information after login.
    • Introduced a component to display detailed transaction actions with warnings and an accordion interface.
  • Enhancements
    • Improved transaction detail display with structured content and consistent JSON formatting.
  • Style
    • Added styles for delegate action and transaction details components to enhance layout and readability.
  • Chores
    • Specified the package manager and version for the project.
    • Expanded workspace configuration to include new SDKs and example projects.

@coderabbitai
Copy link

coderabbitai bot commented Jun 19, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes introduce support for delegate action authorization in the authentication flow. This includes new Borsh schema definitions, decoding utilities, and UI components for displaying delegate action details. The transaction details UI is enhanced with detailed action descriptions and warnings. The workspace configuration is updated to include additional packages, and the package manager is explicitly specified in the project configuration.

Changes

File(s) Change Summary
package.json Added "packageManager": "pnpm@9.14.2" to specify the package manager and version.
pnpm-workspace.yaml Included "packages/sdks/*" and "examples/spa" in the workspace packages list.
packages/auth0/src/actions/authorize-app.action.js Added Borsh schemas, delegate action decoding, new control flow for delegate actions, and utilities for JSON serialization of actions.
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js Introduced AuthorizeAppTransactionDetails component for rendering delegate action details in the UI.
packages/auth0/src/forms/authorize-app/delegate-action-details/index.css Added CSS classes for styling the delegate action details component.
packages/auth0/src/forms/authorize-app/delegate-action-details/schema.json Added an empty JSON schema file for the delegate action details form component.
packages/auth0/src/forms/authorize-app/transaction-details/index.js Expanded AuthorizeAppTransactionDetails to parse and display detailed NEAR transaction actions with warnings and accordion UI.
packages/auth0/src/forms/authorize-app/transaction-details/index.css Added CSS styles for accordion UI and related elements for transaction details.
packages/auth0/src/forms/authorize-app/dapp-connector/index.js Updated left avatar image source URL.
packages/sdks/browser/package.json Added typescript as a devDependency and @near-js/transactions as a dependency.
packages/sdks/browser/src/providers/auth0/utils/index.ts Added explicit TypeScript type annotations in reduce callbacks for encodeTransaction and encodeDelegateAction functions.
examples/spa/package.json Downgraded eslint version from ^9.22.0 to ^8.26.1.
contracts/auth0-guard/src/lib.rs Changed string formatting syntax in verify_token method to use Rust named arguments formatting.
docs/docusaurus.config.ts Removed Mermaid theme and markdown support; added local search plugin with hashed indexing.
docs/package.json Removed several Docusaurus themes and Mermaid package; added local search plugin; upgraded React and ReactDOM versions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Auth0
    participant API
    participant UI

    User->>Auth0: Initiates login with delegateAction, imageUrl, name
    Auth0->>API: onExecutePostLogin(event, api)
    API->>API: Detects delegateAction in query
    API->>API: Decodes delegateAction bytes
    API->>UI: Renders delegate_action_modal with details (imageUrl, name, receiverId, senderId, maxBlockHeight, actions)
    UI->>User: Prompts user with delegate action details
    API->>API: Sets delegate action bytes in access token claims ("fatxn")
Loading

Estimated code review effort

4 (~90 minutes)

Suggested labels

feature, shared/auth


📜 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 d0788f8 and 314976e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • docs/docusaurus.config.ts (1 hunks)
  • docs/package.json (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

@notion-workspace
Copy link

delegate action modal

@socket-security
Copy link

socket-security bot commented Jun 19, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

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: 6

🧹 Nitpick comments (3)
packages/auth0/src/forms/authorize-app/delegate-action-details/schema.json (1)

1-1: Implement proper JSON schema or remove placeholder file.

The empty schema file provides no validation for the delegate action details form. Consider implementing proper schema validation rules or removing this placeholder file until the schema is ready.

Would you like me to generate a JSON schema based on the parameters used in the component (senderId, receiverId, actions, maxBlockHeight)?

packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (2)

1-4: Fix misleading comment block.

The comment references imask.js and currency symbols, which are not relevant to this delegate action details component.

-/**
- * This custom field uses imask.js to mask an input with a currency symbol
- * Add "symbol" param using a value like "€" to see the difference
- */
+/**
+ * Custom field component for displaying delegate action transaction details
+ * Shows sender ID, receiver ID, max block height, and actions in a structured format
+ */

74-81: Document or implement stub methods.

The stub methods (block, unblock, getValue) are empty. Either implement them with proper functionality or document why they're intentionally empty.

        /** Invoked when field has to be blocked */
-        block() {},
+        block() {
+            // No blocking behavior required for read-only display component
+        },

        /** Invoked when field has to be unblocked */
-        unblock() {},
+        unblock() {
+            // No unblocking behavior required for read-only display component
+        },

        /** Invoked when the SDK needs to get the value (possibly several times) */
-        getValue() {},
+        getValue() {
+            // This component displays data only and doesn't collect user input
+            return null;
+        },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ff1c763 and 51b3265.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • package.json (1 hunks)
  • packages/auth0/src/actions/authorize-app.action.js (3 hunks)
  • packages/auth0/src/forms/authorize-app/delegate-action-details/index.css (1 hunks)
  • packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (1 hunks)
  • packages/auth0/src/forms/authorize-app/delegate-action-details/schema.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🔇 Additional comments (7)
package.json (1)

27-27: Verify the pnpm version is current and secure.

The specified pnpm version should be verified to ensure it's the latest stable version and doesn't have known security vulnerabilities.

What is the latest stable version of pnpm package manager and are there any known security issues with version 9.14.2?
pnpm-workspace.yaml (1)

6-6: LGTM!

The workspace configuration updates correctly add new package paths using proper pnpm workspace syntax.

Also applies to: 9-9

packages/auth0/src/actions/authorize-app.action.js (5)

1-2: LGTM: Required dependencies for NEAR blockchain integration.

The imports are appropriate for handling NEAR transactions and Borsh serialization/deserialization.


9-9: LGTM: Consistent constant naming.

The new constant follows the same pattern as existing keys.


212-223: LGTM: Proper bigint handling for JSON serialization.

The function correctly handles bigint values that can't be directly JSON.stringify'd, which is essential for blockchain data containing large numbers.


245-245: Good refactor: Consistent action serialization.

Using the new stringifyActions utility ensures consistent handling of bigint values across both transaction and delegate action flows.


11-182: Comprehensive schema definitions - verify against NEAR protocol specification.

The Borsh schema definitions are extensive and appear to cover all necessary NEAR blockchain data structures. The nested structure and enum definitions look correct for handling various action types and cryptographic primitives.

Please verify that these schema definitions match the current NEAR protocol specification:

What are the current Borsh schema definitions for NEAR protocol transactions and delegate actions?

Comment on lines +17 to +18
align-items: left;
justify-content: left;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix invalid flexbox alignment values.

The values align-items: left and justify-content: left are invalid for flexbox. Use flex-start for left alignment in flexbox.

-.text-content {
-    display: flex;
-    flex-direction: column;
-    align-items: left;
-    justify-content: left;
-    width: 100%;
-}
+.text-content {
+    display: flex;
+    flex-direction: column;
+    align-items: flex-start;
+    justify-content: flex-start;
+    width: 100%;
+}
📝 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
align-items: left;
justify-content: left;
.text-content {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
}
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.css at
lines 17 to 18, the CSS properties align-items and justify-content are
incorrectly set to 'left', which is not valid for flexbox. Replace both 'left'
values with 'flex-start' to correctly align items to the left in a flex
container.

Comment on lines +38 to +39
align-items: left;
justify-content: left;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix invalid flexbox alignment values in json-content.

Same issue here - align-items: left and justify-content: left are invalid flexbox values.

-.json-content {
-    display: flex;
-    padding: 0.5rem;
-    flex-direction: column;
-    align-items: left;
-    justify-content: left;
-    width: 100%;
-    border-radius: 12px;
-    background-color: #fafafa;
-
-    color: #3f4246;
-    font-size: 0.875rem;
-    font-weight: 500;
-}
+.json-content {
+    display: flex;
+    padding: 0.5rem;
+    flex-direction: column;
+    align-items: flex-start;
+    justify-content: flex-start;
+    width: 100%;
+    border-radius: 12px;
+    background-color: #fafafa;
+
+    color: #3f4246;
+    font-size: 0.875rem;
+    font-weight: 500;
+}
📝 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
align-items: left;
justify-content: left;
.json-content {
display: flex;
padding: 0.5rem;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
border-radius: 12px;
background-color: #fafafa;
color: #3f4246;
font-size: 0.875rem;
font-weight: 500;
}
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.css at
lines 38 to 39, replace the invalid flexbox values 'align-items: left' and
'justify-content: left' with valid ones. Use 'align-items: flex-start' and
'justify-content: flex-start' to align items to the left correctly within the
flex container.

Comment on lines +18 to +22
if (link) {
valueElement.classList.add("link");
valueElement.setAttribute("href", link);
valueElement.setAttribute("target", "_blank");
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect link implementation.

The code attempts to set href and target attributes on a div element, which won't create a functional link. If you need clickable links, create an anchor element instead.

        if (link) {
-            valueElement.classList.add("link");
-            valueElement.setAttribute("href", link);
-            valueElement.setAttribute("target", "_blank");
+            const linkElement = document.createElement("a");
+            linkElement.href = link;
+            linkElement.target = "_blank";
+            linkElement.textContent = value;
+            linkElement.classList.add("value", "link");
+            textContent.appendChild(labelElement);
+            textContent.appendChild(linkElement);
+            return textContent;
        }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.js
around lines 18 to 22, the code incorrectly sets href and target attributes on a
div element, which does not create a clickable link. To fix this, replace the
div with an anchor (a) element when a link is present, and set the href and
target attributes on this anchor element to make it a functional clickable link.

Comment on lines +54 to +55
const config = context.custom.getParams();
const { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString } = config;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for missing configuration parameters.

The component doesn't validate that required parameters exist in the config, which could lead to runtime errors.

            const config = context.custom.getParams();
+            if (!config) {
+                throw new Error('Configuration parameters are required');
+            }
            const { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString } = config;
+            
+            // Validate required parameters
+            const requiredParams = { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString };
+            const missingParams = Object.entries(requiredParams)
+                .filter(([key, value]) => value === undefined || value === null)
+                .map(([key]) => key);
+            
+            if (missingParams.length > 0) {
+                throw new Error(`Missing required parameters: ${missingParams.join(', ')}`);
+            }
📝 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
const config = context.custom.getParams();
const { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString } = config;
const config = context.custom.getParams();
if (!config) {
throw new Error('Configuration parameters are required');
}
const { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString } = config;
// Validate required parameters
const requiredParams = { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString };
const missingParams = Object.entries(requiredParams)
.filter(([key, value]) => value === undefined || value === null)
.map(([key]) => key);
if (missingParams.length > 0) {
throw new Error(`Missing required parameters: ${missingParams.join(', ')}`);
}
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.js
around lines 54 to 55, the code destructures parameters from config without
checking if they exist, risking runtime errors. Add validation to confirm that
senderId, receiverId, actions, and maxBlockHeightString are present in config
before using them. If any are missing, handle the error gracefully, such as by
throwing an informative error or providing fallback behavior.

Comment on lines +252 to 268
} else if (hasKeys(query, [DELEGATE_ACTION_KEY, IMAGE_URL_KEY, NAME_KEY])) {
const delegateAction = decodeDelegateAction(event.request.query.delegateAction);
api.prompt.render(event.secrets.delegate_action_modal, {
fields: {
imageUrl: event.request.query.imageUrl,
name: event.request.query.name,
receiverId: delegateAction.receiverId,
senderId: delegateAction.senderId,
maxBlockHeight: delegateAction.maxBlockHeight.toString(),
actions: stringifyActions(delegateAction.actions),
},
});
api.accessToken.setCustomClaim(
"fatxn",
event.request.query.delegateAction.split(",").map((value) => Number(value)),
);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add input validation for delegate action parameters.

The delegate action handling should validate query parameters before processing, similar to security best practices for handling external input.

Consider adding validation before processing the delegate action:

 } else if (hasKeys(query, [DELEGATE_ACTION_KEY, IMAGE_URL_KEY, NAME_KEY])) {
+    // Validate delegate action parameter
+    if (!query.delegateAction || typeof query.delegateAction !== 'string') {
+        console.error("Invalid delegate action parameter");
+        return;
+    }
+    
     const delegateAction = decodeDelegateAction(event.request.query.delegateAction);

Additionally, consider validating the imageUrl and name parameters to prevent potential XSS or injection attacks in the UI rendering.

📝 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
} else if (hasKeys(query, [DELEGATE_ACTION_KEY, IMAGE_URL_KEY, NAME_KEY])) {
const delegateAction = decodeDelegateAction(event.request.query.delegateAction);
api.prompt.render(event.secrets.delegate_action_modal, {
fields: {
imageUrl: event.request.query.imageUrl,
name: event.request.query.name,
receiverId: delegateAction.receiverId,
senderId: delegateAction.senderId,
maxBlockHeight: delegateAction.maxBlockHeight.toString(),
actions: stringifyActions(delegateAction.actions),
},
});
api.accessToken.setCustomClaim(
"fatxn",
event.request.query.delegateAction.split(",").map((value) => Number(value)),
);
}
} else if (hasKeys(query, [DELEGATE_ACTION_KEY, IMAGE_URL_KEY, NAME_KEY])) {
// Validate delegate action parameter
if (!query.delegateAction || typeof query.delegateAction !== 'string') {
console.error("Invalid delegate action parameter");
return;
}
const delegateAction = decodeDelegateAction(event.request.query.delegateAction);
api.prompt.render(event.secrets.delegate_action_modal, {
fields: {
imageUrl: event.request.query.imageUrl,
name: event.request.query.name,
receiverId: delegateAction.receiverId,
senderId: delegateAction.senderId,
maxBlockHeight: delegateAction.maxBlockHeight.toString(),
actions: stringifyActions(delegateAction.actions),
},
});
api.accessToken.setCustomClaim(
"fatxn",
event.request.query.delegateAction.split(",").map((value) => Number(value)),
);
}
🤖 Prompt for AI Agents
In packages/auth0/src/actions/authorize-app.action.js around lines 252 to 268,
the code processes delegateAction and related query parameters without
validating them, which risks security issues. Add validation checks to ensure
delegateAction, imageUrl, and name parameters conform to expected formats and
types before decoding or rendering. Implement input sanitization or use
validation libraries to prevent XSS or injection attacks when rendering these
values in the UI.

Comment on lines +194 to +210
function decodeDelegateAction(encodedDelegateAction) {
encodedDelegateAction = Uint8Array.from(encodedDelegateAction.split(",").map((value) => Number(value)));
// Create a view of the data for parsing
let offset = 0;

// First, deserialize the DelegateActionPrefix
// The prefix is a u32, so it should consume 4 bytes
const prefixBytes = encodedDelegateAction.slice(offset, offset + 4);
const prefix = deserialize(SCHEMA.DelegateActionPrefix, prefixBytes);
offset += 4;

// Now deserialize the actual DelegateAction from the remaining bytes
const delegateActionBytes = encodedDelegateAction.slice(offset);
const delegateAction = deserialize(SCHEMA.DelegateAction, delegateActionBytes);

return delegateAction;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for malformed delegate action data.

The function assumes the input data is well-formed but could throw runtime errors if the encoded string is malformed or has incorrect format.

Apply this diff to add proper error handling:

 function decodeDelegateAction(encodedDelegateAction) {
+    try {
         encodedDelegateAction = Uint8Array.from(encodedDelegateAction.split(",").map((value) => Number(value)));
         // Create a view of the data for parsing
         let offset = 0;
 
         // First, deserialize the DelegateActionPrefix
         // The prefix is a u32, so it should consume 4 bytes
+        if (encodedDelegateAction.length < 4) {
+            throw new Error("Invalid delegate action: insufficient data for prefix");
+        }
         const prefixBytes = encodedDelegateAction.slice(offset, offset + 4);
         const prefix = deserialize(SCHEMA.DelegateActionPrefix, prefixBytes);
         offset += 4;
 
         // Now deserialize the actual DelegateAction from the remaining bytes
+        if (offset >= encodedDelegateAction.length) {
+            throw new Error("Invalid delegate action: insufficient data for delegate action");
+        }
         const delegateActionBytes = encodedDelegateAction.slice(offset);
         const delegateAction = deserialize(SCHEMA.DelegateAction, delegateActionBytes);
 
         return delegateAction;
+    } catch (error) {
+        console.error("Failed to decode delegate action:", error);
+        throw new Error(`Invalid delegate action format: ${error.message}`);
+    }
 }
📝 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
function decodeDelegateAction(encodedDelegateAction) {
encodedDelegateAction = Uint8Array.from(encodedDelegateAction.split(",").map((value) => Number(value)));
// Create a view of the data for parsing
let offset = 0;
// First, deserialize the DelegateActionPrefix
// The prefix is a u32, so it should consume 4 bytes
const prefixBytes = encodedDelegateAction.slice(offset, offset + 4);
const prefix = deserialize(SCHEMA.DelegateActionPrefix, prefixBytes);
offset += 4;
// Now deserialize the actual DelegateAction from the remaining bytes
const delegateActionBytes = encodedDelegateAction.slice(offset);
const delegateAction = deserialize(SCHEMA.DelegateAction, delegateActionBytes);
return delegateAction;
}
function decodeDelegateAction(encodedDelegateAction) {
try {
encodedDelegateAction = Uint8Array.from(
encodedDelegateAction.split(",").map((value) => Number(value))
);
// Create a view of the data for parsing
let offset = 0;
// First, deserialize the DelegateActionPrefix
// The prefix is a u32, so it should consume 4 bytes
if (encodedDelegateAction.length < 4) {
throw new Error("Invalid delegate action: insufficient data for prefix");
}
const prefixBytes = encodedDelegateAction.slice(offset, offset + 4);
const prefix = deserialize(SCHEMA.DelegateActionPrefix, prefixBytes);
offset += 4;
// Now deserialize the actual DelegateAction from the remaining bytes
if (offset >= encodedDelegateAction.length) {
throw new Error("Invalid delegate action: insufficient data for delegate action");
}
const delegateActionBytes = encodedDelegateAction.slice(offset);
const delegateAction = deserialize(SCHEMA.DelegateAction, delegateActionBytes);
return delegateAction;
} catch (error) {
console.error("Failed to decode delegate action:", error);
throw new Error(`Invalid delegate action format: ${error.message}`);
}
}
🤖 Prompt for AI Agents
In packages/auth0/src/actions/authorize-app.action.js around lines 194 to 210,
the decodeDelegateAction function lacks error handling for malformed or
incorrectly formatted input data, which can cause runtime errors. Wrap the
decoding logic in a try-catch block to catch any exceptions during parsing, and
throw a clear, descriptive error if the input is invalid. This will prevent
unhandled exceptions and improve robustness when processing delegate action
data.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51b3265 and 4deb5f5.

⛔ Files ignored due to path filters (2)
  • packages/shared/test/dist/create-global-mock.d.ts is excluded by !**/dist/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • packages/sdks/browser/package.json (1 hunks)
  • packages/sdks/browser/src/providers/auth0/utils/index.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: integration-packages / Build
  • GitHub Check: integration-contracts / integration
🔇 Additional comments (2)
packages/sdks/browser/src/providers/auth0/utils/index.ts (1)

14-14: LGTM! Explicit type annotations improve code clarity.

The added type annotations for the reduce callback parameters enhance code readability and make the types explicit, even though TypeScript could infer them from context.

Also applies to: 26-26

packages/sdks/browser/package.json (1)

24-24: LGTM! Dependency addition aligns with usage.

The @near-js/transactions dependency is correctly added and aligns with the imports used in the TypeScript utilities.

"@types/jest": "^29.5.12",
"@types/node": "^22.15.30",
"jest": "^29.7.0",
"typescript": "latest",
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use a specific TypeScript version instead of "latest".

Using "latest" for TypeScript can lead to inconsistent builds and unexpected breaking changes. Consider pinning to a specific version for reproducible builds.

-        "typescript": "latest",
+        "typescript": "^5.6.0",
📝 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
"typescript": "latest",
"typescript": "^5.6.0",
🤖 Prompt for AI Agents
In packages/sdks/browser/package.json at line 19, the TypeScript dependency is
set to "latest", which can cause inconsistent builds. Replace "latest" with a
specific, stable TypeScript version number to ensure reproducible and
predictable builds.

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: 8

🔭 Outside diff range comments (2)
packages/auth0/src/forms/authorize-app/transaction-details/index.js (2)

1-405: Significant code duplication detected.

This file contains nearly identical code to delegate-action-details/index.js. Consider refactoring to share common functionality between both components to improve maintainability and reduce duplication.

Consider creating a shared module that exports:

  • Base58 encoding utilities
  • Public key formatting
  • Action content generators
  • Accordion UI components

Then both transaction-details and delegate-action-details can import and use these shared functions.

Would you like me to generate a refactored structure that eliminates this duplication?


358-359: Add error handling for missing configuration parameters.

The component doesn't validate that required parameters exist in the config.

            const config = context.custom.getParams();
+            if (!config) {
+                throw new Error('Configuration parameters are required');
+            }
            const { signerId, receiverId, actions } = config;
+            
+            // Validate required parameters
+            const requiredParams = { signerId, receiverId, actions };
+            const missingParams = Object.entries(requiredParams)
+                .filter(([key, value]) => value === undefined || value === null)
+                .map(([key]) => key);
+            
+            if (missingParams.length > 0) {
+                throw new Error(`Missing required parameters: ${missingParams.join(', ')}`);
+            }
♻️ Duplicate comments (2)
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (2)

340-344: Fix incorrect link implementation.

The code attempts to set href and target attributes on a div element, which won't create a functional link. If you need clickable links, create an anchor element instead.

        if (link) {
-            valueElement.classList.add("link");
-            valueElement.setAttribute("href", link);
-            valueElement.setAttribute("target", "_blank");
+            const linkElement = document.createElement("a");
+            linkElement.href = link;
+            linkElement.target = "_blank";
+            linkElement.textContent = value;
+            linkElement.classList.add("value", "link");
+            textContent.appendChild(labelElement);
+            textContent.appendChild(linkElement);
+            return textContent;
        }

376-377: Add error handling for missing configuration parameters.

The component doesn't validate that required parameters exist in the config, which could lead to runtime errors.

            const config = context.custom.getParams();
+            if (!config) {
+                throw new Error('Configuration parameters are required');
+            }
            const { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString } = config;
+            
+            // Validate required parameters
+            const requiredParams = { senderId, receiverId, actions, maxBlockHeight: maxBlockHeightString };
+            const missingParams = Object.entries(requiredParams)
+                .filter(([key, value]) => value === undefined || value === null)
+                .map(([key]) => key);
+            
+            if (missingParams.length > 0) {
+                throw new Error(`Missing required parameters: ${missingParams.join(', ')}`);
+            }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 542c120 and 40cd1f5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • package.json (1 hunks)
  • packages/auth0/src/forms/authorize-app/dapp-connector/index.js (1 hunks)
  • packages/auth0/src/forms/authorize-app/delegate-action-details/index.css (1 hunks)
  • packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (1 hunks)
  • packages/auth0/src/forms/authorize-app/transaction-details/index.css (1 hunks)
  • packages/auth0/src/forms/authorize-app/transaction-details/index.js (3 hunks)
  • pnpm-workspace.yaml (1 hunks)
🧠 Learnings (1)
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (7)

Learnt from: AgustinMJ
PR: Peersyst/near-mobile#0
File: :0-0
Timestamp: 2025-03-13T11:43:39.510Z
Learning: When reviewing PRs, check commit message formats (excluding merge commits) and remind authors to follow the format: [scope] action: msg

  • scope: Package name from package.json, app folder name, or "generic" for monorepo root changes
  • action: "feat", "fix", "refactor", or "chore"
  • msg: Clear and well-written commit message

Learnt from: AgustinMJ
PR: Peersyst/near-mobile#0
File: :0-0
Timestamp: 2025-03-13T11:43:39.510Z
Learning: When reviewing PRs, check commit message formats (excluding merge commits) and remind authors to follow the format: [scope] action: msg

  • scope: Package name from package.json, app folder name, or "generic" for monorepo root changes
  • action: "feat", "fix", "refactor", or "chore"
  • msg: Clear and well-written commit message

Learnt from: AgustinMJ
PR: Peersyst/near-mobile#0
File: :0-0
Timestamp: 2025-03-13T11:45:51.749Z
Learning: When reviewing PRs, check commit message formats (excluding merge commits) and remind authors to follow the format: [scope] action: msg. Valid scopes include:

  • Package name from package.json
  • App folder name
  • "generic" for monorepo root changes
  • PR numbers (e.g., #123)
  • Issue numbers
    Valid actions include: "feat", "fix", "refactor", or "chore". The message should be clear and well-written.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#327
File: packages/frontend/swap/src/ui/queries/use-update-swap-tokens-result-status.ts:41-41
Timestamp: 2025-06-09T08:17:23.835Z
Learning: In the NEAR mobile project, type safety checks for configuration values retrieved with useConfig() are not necessary and should not be added when the user indicates they are not needed.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#93
File: packages/shared/blockchain/src/wci/chains/near/clients/staking/near-staking-client.ts:30-45
Timestamp: 2025-03-14T12:05:34.665Z
Learning: The error handling and BigInt validation approach suggested for NearStakingClient.getValidatorStakingBalance method was declined as it does not apply to this codebase's requirements.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#214
File: packages/frontend/account/src/domain/controllers/account.controller.ts:73-83
Timestamp: 2025-04-25T08:28:52.443Z
Learning: The team prefers to rely on TypeScript's static type checking for parameter validation rather than adding explicit runtime validation checks.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#214
File: packages/frontend/account/src/domain/controllers/account.controller.ts:73-83
Timestamp: 2025-04-25T08:28:52.443Z
Learning: The team prefers to rely on TypeScript's static type checking for parameter validation rather than adding explicit runtime validation checks.

🧬 Code Graph Analysis (1)
packages/auth0/src/forms/authorize-app/transaction-details/index.js (2)
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (16)
  • ALPHABET (6-6)
  • formatPublicKey (31-36)
  • createAccountContent (38-42)
  • deployContractContent (44-54)
  • createTextContent (328-350)
  • functionCallContent (56-72)
  • transferContent (74-84)
  • stakeContent (86-98)
  • addKeyContent (100-123)
  • deleteKeyContent (125-142)
  • deleteAccountContent (144-159)
  • signedDelegateContent (161-171)
  • deployGlobalContractContent (173-186)
  • useGlobalContractContent (188-198)
  • handleNearAction (200-273)
  • createAccordion (275-326)
packages/auth0/src/actions/authorize-app.action.js (2)
  • delegateAction (207-207)
  • delegateAction (253-253)
✅ Files skipped from review due to trivial changes (2)
  • packages/auth0/src/forms/authorize-app/transaction-details/index.css
  • packages/auth0/src/forms/authorize-app/dapp-connector/index.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • pnpm-workspace.yaml
  • package.json
  • packages/auth0/src/forms/authorize-app/delegate-action-details/index.css
🧰 Additional context used
🧠 Learnings (1)
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (7)

Learnt from: AgustinMJ
PR: Peersyst/near-mobile#0
File: :0-0
Timestamp: 2025-03-13T11:43:39.510Z
Learning: When reviewing PRs, check commit message formats (excluding merge commits) and remind authors to follow the format: [scope] action: msg

  • scope: Package name from package.json, app folder name, or "generic" for monorepo root changes
  • action: "feat", "fix", "refactor", or "chore"
  • msg: Clear and well-written commit message

Learnt from: AgustinMJ
PR: Peersyst/near-mobile#0
File: :0-0
Timestamp: 2025-03-13T11:43:39.510Z
Learning: When reviewing PRs, check commit message formats (excluding merge commits) and remind authors to follow the format: [scope] action: msg

  • scope: Package name from package.json, app folder name, or "generic" for monorepo root changes
  • action: "feat", "fix", "refactor", or "chore"
  • msg: Clear and well-written commit message

Learnt from: AgustinMJ
PR: Peersyst/near-mobile#0
File: :0-0
Timestamp: 2025-03-13T11:45:51.749Z
Learning: When reviewing PRs, check commit message formats (excluding merge commits) and remind authors to follow the format: [scope] action: msg. Valid scopes include:

  • Package name from package.json
  • App folder name
  • "generic" for monorepo root changes
  • PR numbers (e.g., #123)
  • Issue numbers
    Valid actions include: "feat", "fix", "refactor", or "chore". The message should be clear and well-written.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#327
File: packages/frontend/swap/src/ui/queries/use-update-swap-tokens-result-status.ts:41-41
Timestamp: 2025-06-09T08:17:23.835Z
Learning: In the NEAR mobile project, type safety checks for configuration values retrieved with useConfig() are not necessary and should not be added when the user indicates they are not needed.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#93
File: packages/shared/blockchain/src/wci/chains/near/clients/staking/near-staking-client.ts:30-45
Timestamp: 2025-03-14T12:05:34.665Z
Learning: The error handling and BigInt validation approach suggested for NearStakingClient.getValidatorStakingBalance method was declined as it does not apply to this codebase's requirements.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#214
File: packages/frontend/account/src/domain/controllers/account.controller.ts:73-83
Timestamp: 2025-04-25T08:28:52.443Z
Learning: The team prefers to rely on TypeScript's static type checking for parameter validation rather than adding explicit runtime validation checks.

Learnt from: JordiParraCrespo
PR: Peersyst/near-mobile#214
File: packages/frontend/account/src/domain/controllers/account.controller.ts:73-83
Timestamp: 2025-04-25T08:28:52.443Z
Learning: The team prefers to rely on TypeScript's static type checking for parameter validation rather than adding explicit runtime validation checks.

🧬 Code Graph Analysis (1)
packages/auth0/src/forms/authorize-app/transaction-details/index.js (2)
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (16)
  • ALPHABET (6-6)
  • formatPublicKey (31-36)
  • createAccountContent (38-42)
  • deployContractContent (44-54)
  • createTextContent (328-350)
  • functionCallContent (56-72)
  • transferContent (74-84)
  • stakeContent (86-98)
  • addKeyContent (100-123)
  • deleteKeyContent (125-142)
  • deleteAccountContent (144-159)
  • signedDelegateContent (161-171)
  • deployGlobalContractContent (173-186)
  • useGlobalContractContent (188-198)
  • handleNearAction (200-273)
  • createAccordion (275-326)
packages/auth0/src/actions/authorize-app.action.js (2)
  • delegateAction (207-207)
  • delegateAction (253-253)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: integration-packages / Build
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (2)
packages/auth0/src/forms/authorize-app/delegate-action-details/index.js (2)

6-29: LGTM!

The Base58 encoding implementation is correct and properly handles leading zeros.


31-36: LGTM!

The public key formatting correctly handles both secp256k1 and ed25519 key types.

Comment on lines +1 to +4
/**
* This custom field uses imask.js to mask an input with a currency symbol
* Add "symbol" param using a value like "€" to see the difference
*/
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect documentation header.

The comment refers to currency masking functionality, but this component actually handles delegate action transaction details.

 /**
- * This custom field uses imask.js to mask an input with a currency symbol
- * Add "symbol" param using a value like "€" to see the difference
+ * This custom field displays detailed transaction information for NEAR blockchain delegate actions.
+ * It parses and presents various action types with appropriate warnings and details.
  */
📝 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
/**
* This custom field uses imask.js to mask an input with a currency symbol
* Add "symbol" param using a value like "€" to see the difference
*/
/**
* This custom field displays detailed transaction information for NEAR blockchain delegate actions.
* It parses and presents various action types with appropriate warnings and details.
*/
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.js at
lines 1 to 4, the documentation comment incorrectly describes currency masking
functionality. Update the comment to accurately describe that this component
handles delegate action transaction details, removing any references to imask.js
or currency symbols.

const text = document.createElement("p");
text.textContent = `By approving this request, the following amount will be staked to the public key.`;
const fields = createTextContent("Stake", `${action.stake.stake?.toString()} yoctoNEAR`);
const publicKey = createTextContent("Public Key", action.stake.publicKey?.toString());
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Format public key consistently.

The public key should be formatted using formatPublicKey for consistency with other action handlers.

-        const publicKey = createTextContent("Public Key", action.stake.publicKey?.toString());
+        const publicKey = createTextContent("Public Key", formatPublicKey(action.stake.publicKey));
📝 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
const publicKey = createTextContent("Public Key", action.stake.publicKey?.toString());
const publicKey = createTextContent("Public Key", formatPublicKey(action.stake.publicKey));
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.js at
line 92, the public key is currently converted to a string directly, which lacks
consistent formatting. Replace the direct toString() call with the
formatPublicKey function to ensure the public key is formatted consistently with
other action handlers.


const text = document.createElement("p");
text.textContent = `By approving this request, the following delegate action will be executed.`;
const delegateAction = createTextContent("Delegate Action", action.signedDelegate.delegateAction);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Format delegate action data for better readability.

The delegate action data should be properly formatted for display.

-        const delegateAction = createTextContent("Delegate Action", action.signedDelegate.delegateAction);
+        const delegateAction = createTextContent("Delegate Action", JSON.stringify(action.signedDelegate.delegateAction, null, 2));
📝 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
const delegateAction = createTextContent("Delegate Action", action.signedDelegate.delegateAction);
const delegateAction = createTextContent(
"Delegate Action",
JSON.stringify(action.signedDelegate.delegateAction, null, 2)
);
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.js at
line 166, the delegate action data is currently displayed without formatting.
Update the code to format the delegateAction value for better readability, such
as converting it to a more user-friendly string or applying JSON formatting if
it is an object, before passing it to createTextContent.

const receiver = createTextContent("Receiver ID", receiverId);
const maxBlockHeight = createTextContent("Max Block Height", maxBlockHeightString);

const parsedActions = JSON.parse(actions);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for JSON parsing.

JSON parsing can throw errors if the data is malformed.

-            const parsedActions = JSON.parse(actions);
+            let parsedActions;
+            try {
+                parsedActions = JSON.parse(actions);
+            } catch (error) {
+                throw new Error(`Failed to parse actions: ${error.message}`);
+            }
📝 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
const parsedActions = JSON.parse(actions);
let parsedActions;
try {
parsedActions = JSON.parse(actions);
} catch (error) {
throw new Error(`Failed to parse actions: ${error.message}`);
}
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/delegate-action-details/index.js at
line 383, the JSON.parse call on the actions variable can throw an error if the
input is malformed. Wrap the JSON.parse call in a try-catch block to handle
potential parsing errors gracefully. In the catch block, handle the error
appropriately, such as logging the error or providing a fallback value, to
prevent the application from crashing.

const text = document.createElement("p");
text.textContent = `By approving this request, the following amount will be staked to the public key.`;
const fields = createTextContent("Stake", `${action.stake.stake?.toString()} yoctoNEAR`);
const publicKey = createTextContent("Public Key", action.stake.publicKey?.toString());
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Format public key consistently.

The public key should be formatted using formatPublicKey for consistency with other action handlers.

-        const publicKey = createTextContent("Public Key", action.stake.publicKey?.toString());
+        const publicKey = createTextContent("Public Key", formatPublicKey(action.stake.publicKey));
📝 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
const publicKey = createTextContent("Public Key", action.stake.publicKey?.toString());
const publicKey = createTextContent("Public Key", formatPublicKey(action.stake.publicKey));
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/transaction-details/index.js at line
92, the public key is currently converted to string directly. Replace the direct
toString call with the formatPublicKey function to ensure consistent formatting
of the public key across all action handlers.


const text = document.createElement("p");
text.textContent = `By approving this request, the following delegate action will be executed.`;
const delegateAction = createTextContent("Delegate Action", action.signedDelegate.delegateAction);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Format delegate action data for better readability.

The delegate action data should be properly formatted for display.

-        const delegateAction = createTextContent("Delegate Action", action.signedDelegate.delegateAction);
+        const delegateAction = createTextContent("Delegate Action", JSON.stringify(action.signedDelegate.delegateAction, null, 2));
📝 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
const delegateAction = createTextContent("Delegate Action", action.signedDelegate.delegateAction);
const delegateAction = createTextContent(
"Delegate Action",
JSON.stringify(action.signedDelegate.delegateAction, null, 2)
);
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/transaction-details/index.js at line
166, the delegateAction data is currently displayed without formatting, which
reduces readability. Update the code to format the delegateAction data, for
example by converting it to a JSON string with indentation or applying a
suitable formatting function before passing it to createTextContent, so it is
easier to read in the UI.

Comment on lines +340 to +344
if (link) {
valueElement.classList.add("link");
valueElement.setAttribute("href", link);
valueElement.setAttribute("target", "_blank");
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect link implementation.

The code attempts to set href and target attributes on a div element, which won't create a functional link.

        if (link) {
-            valueElement.classList.add("link");
-            valueElement.setAttribute("href", link);
-            valueElement.setAttribute("target", "_blank");
+            const linkElement = document.createElement("a");
+            linkElement.href = link;
+            linkElement.target = "_blank";
+            linkElement.textContent = value;
+            linkElement.classList.add("value", "link");
+            textContent.appendChild(labelElement);
+            textContent.appendChild(linkElement);
+            return textContent;
        }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/transaction-details/index.js around
lines 340 to 344, the code incorrectly sets href and target attributes on a div
element, which does not create a clickable link. To fix this, replace the div
with an anchor (<a>) element when a link is present, then set the href and
target attributes on that anchor element to make it a functional link.

const receiver = createTextContent("Receiver ID", receiverId);
const actionsContent = createJsonContent("Actions", actions);

const parsedActions = JSON.parse(actions);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for JSON parsing.

JSON parsing can throw errors if the data is malformed.

-            const parsedActions = JSON.parse(actions);
+            let parsedActions;
+            try {
+                parsedActions = JSON.parse(actions);
+            } catch (error) {
+                throw new Error(`Failed to parse actions: ${error.message}`);
+            }
📝 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
const parsedActions = JSON.parse(actions);
let parsedActions;
try {
parsedActions = JSON.parse(actions);
} catch (error) {
throw new Error(`Failed to parse actions: ${error.message}`);
}
🤖 Prompt for AI Agents
In packages/auth0/src/forms/authorize-app/transaction-details/index.js at line
364, the JSON.parse call on the actions variable can throw an error if the input
is malformed. Wrap the JSON.parse call in a try-catch block to handle potential
parsing errors gracefully. In the catch block, handle the error appropriately,
such as logging the error or providing a fallback value, to prevent the
application from crashing.

@AdriaCarrera AdriaCarrera merged commit c9bbb3a into main Jul 23, 2025
3 of 6 checks passed
@AdriaCarrera AdriaCarrera deleted the auth0/feat/delegate-action-modal branch July 23, 2025 14:13
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

Comments