From 34d2fddf49291eb31d03fef98460ee719aef1044 Mon Sep 17 00:00:00 2001 From: jnsdls Date: Tue, 15 Jul 2025 00:12:41 +0000 Subject: [PATCH] Update error response URL for project settings (#7613) # Update error response URL in service-utils This PR updates the error response URLs in the service-utils package to point to the project-specific settings page instead of the generic API key creation page. The new URLs follow the format `https://thirdweb.com/${team.slug}/${project.slug}/settings`, providing users with a direct link to manage restrictions for their specific project. The changes affect error messages for: - Unauthorized domains - Unauthorized bundle IDs - Unauthorized services - Unauthorized service actions ## Summary by CodeRabbit * **Bug Fixes** * Updated error messages for unauthorized access to provide project-specific URLs, directing users to the relevant project settings page for more accurate guidance. * **Chores** * Added documentation to track the patch update related to error response URLs. --- .changeset/ninety-heads-work.md | 5 +++++ packages/service-utils/src/core/authorize/client.test.ts | 4 ++-- packages/service-utils/src/core/authorize/client.ts | 4 ++-- packages/service-utils/src/core/authorize/service.ts | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/ninety-heads-work.md diff --git a/.changeset/ninety-heads-work.md b/.changeset/ninety-heads-work.md new file mode 100644 index 00000000000..3be2d8423c0 --- /dev/null +++ b/.changeset/ninety-heads-work.md @@ -0,0 +1,5 @@ +--- +"@thirdweb-dev/service-utils": patch +--- + +update error response url diff --git a/packages/service-utils/src/core/authorize/client.test.ts b/packages/service-utils/src/core/authorize/client.test.ts index 645103327c5..e9f98986613 100644 --- a/packages/service-utils/src/core/authorize/client.test.ts +++ b/packages/service-utils/src/core/authorize/client.test.ts @@ -80,7 +80,7 @@ describe("authorizeClient", () => { ) as any; expect(result.authorized).toBe(false); expect(result.errorMessage).toBe( - "Invalid request: Unauthorized Bundle ID: com.foo.bar. You can view the restrictions on this API key at https://thirdweb.com/create-api-key", + "Invalid request: Unauthorized Bundle ID: com.foo.bar. You can view the restrictions for this project at https://thirdweb.com/test-team/test-project/settings", ); expect(result.errorCode).toBe("BUNDLE_UNAUTHORIZED"); expect(result.status).toBe(401); @@ -101,7 +101,7 @@ describe("authorizeClient", () => { ) as any; expect(result.authorized).toBe(false); expect(result.errorMessage).toBe( - "Invalid request: Unauthorized domain: unauthorized.com. You can view the restrictions on this API key at https://thirdweb.com/create-api-key", + "Invalid request: Unauthorized domain: unauthorized.com. You can view the restrictions for this project at https://thirdweb.com/test-team/test-project/settings", ); expect(result.errorCode).toBe("ORIGIN_UNAUTHORIZED"); expect(result.status).toBe(401); diff --git a/packages/service-utils/src/core/authorize/client.ts b/packages/service-utils/src/core/authorize/client.ts index 5594e47de01..770948e9536 100644 --- a/packages/service-utils/src/core/authorize/client.ts +++ b/packages/service-utils/src/core/authorize/client.ts @@ -62,7 +62,7 @@ export function authorizeClient( return { authorized: false, errorCode: "ORIGIN_UNAUTHORIZED", - errorMessage: `Invalid request: Unauthorized domain: ${origin}. You can view the restrictions on this API key at https://thirdweb.com/create-api-key`, + errorMessage: `Invalid request: Unauthorized domain: ${origin}. You can view the restrictions for this project at https://thirdweb.com/${team.slug}/${project.slug}/settings`, status: 401, }; } @@ -81,7 +81,7 @@ export function authorizeClient( return { authorized: false, errorCode: "BUNDLE_UNAUTHORIZED", - errorMessage: `Invalid request: Unauthorized Bundle ID: ${bundleId}. You can view the restrictions on this API key at https://thirdweb.com/create-api-key`, + errorMessage: `Invalid request: Unauthorized Bundle ID: ${bundleId}. You can view the restrictions for this project at https://thirdweb.com/${team.slug}/${project.slug}/settings`, status: 401, }; } diff --git a/packages/service-utils/src/core/authorize/service.ts b/packages/service-utils/src/core/authorize/service.ts index f95fe83da55..94a9036f5dc 100644 --- a/packages/service-utils/src/core/authorize/service.ts +++ b/packages/service-utils/src/core/authorize/service.ts @@ -43,7 +43,7 @@ export function authorizeService( return { authorized: false, errorCode: "SERVICE_UNAUTHORIZED", - errorMessage: `Invalid request: Unauthorized service: ${serviceConfig.serviceScope} for project: ${project.name} (${project.publishableKey}). You can view the restrictions on this project in your dashboard: https://thirdweb.com`, + errorMessage: `Invalid request: Unauthorized service: ${serviceConfig.serviceScope} for project: ${project.name} (${project.publishableKey}). You can view the restrictions for this project at https://thirdweb.com/${team.slug}/${project.slug}/settings`, status: 403, }; } @@ -57,7 +57,7 @@ export function authorizeService( return { authorized: false, errorCode: "SERVICE_ACTION_UNAUTHORIZED", - errorMessage: `Invalid request: Unauthorized action: ${serviceConfig.serviceScope} ${serviceConfig.serviceAction} for project: ${project.name} (${project.publishableKey}). You can view the restrictions on this API key in your dashboard: https://thirdweb.com/create-api-key`, + errorMessage: `Invalid request: Unauthorized action: ${serviceConfig.serviceScope} ${serviceConfig.serviceAction} for project: ${project.name} (${project.publishableKey}). You can view the restrictions for this project at https://thirdweb.com/${team.slug}/${project.slug}/settings`, status: 403, }; }