Skip to content

Commit 9da5cd7

Browse files
committed
Add insight service and expose cacheOptions for node auth (#5072)
## Problem solved This update adds the "insight" scope to API keys and exposes cacheOptions for node authentication. It also includes the "insight" service in the SERVICE_DEFINITIONS object and adds it to the HIDDEN_SERVICES array. The authorizeNode function now accepts an optional cacheOptions parameter, allowing for more flexible caching strategies in node authentication. <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `@thirdweb-dev/service-utils` by adding an `insight` service, modifying the `CacheOptions` type, and updating the `authorizeNode` function to accept `cacheOptions`. It also includes changes to the `HIDDEN_SERVICES` constant. ### Detailed summary - Added `insight` service with properties `name`, `title`, and `description`. - Updated `HIDDEN_SERVICES` to include `insight`. - Changed `CacheOptions` from a local type to an exported type. - Modified `authorizeNode` to accept `cacheOptions` as an argument. - Updated the call to `authorize` to include `cacheOptions`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 0dd1438 commit 9da5cd7

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

.changeset/popular-dragons-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
Adds insight scope to api key and exposes cacheOptions for node auth

apps/dashboard/src/components/settings/ApiKeys/validations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,4 @@ export type ApiKeyPayConfigValidationSchema = z.infer<
149149
>;
150150

151151
// FIXME: Remove
152-
export const HIDDEN_SERVICES = ["relayer", "chainsaw"];
152+
export const HIDDEN_SERVICES = ["relayer", "chainsaw", "insight"];

packages/service-utils/src/core/authorize/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type AuthorizationInput = {
2222
useWalletAuth?: string | null;
2323
};
2424

25-
type CacheOptions = {
25+
export type CacheOptions = {
2626
get: (clientId: string) => Promise<string | null>;
2727
put: (
2828
clientId: string,

packages/service-utils/src/core/services.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ export const SERVICE_DEFINITIONS = {
5858
// all actions allowed
5959
actions: [],
6060
},
61+
insight: {
62+
name: "insight",
63+
title: "Insight",
64+
description: "Insight services",
65+
// all actions allowed
66+
actions: [],
67+
},
6168
} as const;
6269

6370
export const SERVICE_NAMES = Object.keys(

packages/service-utils/src/node/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import type {
66
} from "node:http";
77
import type { CoreServiceConfig } from "../core/api.js";
88
import { authorize } from "../core/authorize/index.js";
9-
import type { AuthorizationInput } from "../core/authorize/index.js";
9+
import type {
10+
AuthorizationInput,
11+
CacheOptions,
12+
} from "../core/authorize/index.js";
1013
import type { AuthorizationResult } from "../core/authorize/types.js";
1114
import type { CoreAuthInput } from "../core/types.js";
1215
export * from "../core/usage.js";
@@ -39,6 +42,7 @@ export type AuthInput = CoreAuthInput & {
3942
export async function authorizeNode(
4043
authInput: AuthInput,
4144
serviceConfig: NodeServiceConfig,
45+
cacheOptions?: CacheOptions,
4246
): Promise<AuthorizationResult> {
4347
let authData: AuthorizationInput;
4448
try {
@@ -60,7 +64,7 @@ export async function authorizeNode(
6064
};
6165
}
6266

63-
return await authorize(authData, serviceConfig);
67+
return await authorize(authData, serviceConfig, cacheOptions);
6468
}
6569

6670
function getHeader(

0 commit comments

Comments
 (0)