Skip to content

Commit 8a7cc43

Browse files
fix: align CLI auth compatibility checks (#1)
* fix: align CLI auth compatibility checks * ci(connect): sync DataConnect download version * fix: preserve relay body hash compatibility * fix: point SDK gateway defaults at DP RPC --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 95bf60b commit 8a7cc43

13 files changed

Lines changed: 110 additions & 16 deletions

File tree

‎connect/src/app/admin/_lib/register-builder.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const BUILDER_REGISTRATION_TYPES = {
1717
],
1818
} as const;
1919

20-
const GATEWAY_URL = "https://data-gateway.vana.org";
20+
const GATEWAY_URL = process.env.DATA_GATEWAY_URL ?? "https://dp-rpc.vana.org";
2121

2222
export type RegisterBuilderErrorCode =
2323
| "ALREADY_REGISTERED"

‎connect/src/config/config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type DownloadAsset = {
88
comingSoon?: boolean;
99
};
1010

11-
const DOWNLOAD_VERSION = "0.7.35";
11+
const DOWNLOAD_VERSION = "0.7.52";
1212
const DATA_CONNECT_GITHUB_RELEASES_URL =
1313
"https://github.com/vana-com/data-connect/releases";
1414

‎connect/src/lib/server-provider/register-on-chain.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ const SERVER_REGISTRATION_TYPES = {
3636
],
3737
} as const;
3838

39-
const GATEWAY_URL =
40-
process.env.DATA_GATEWAY_URL ?? "https://data-gateway.vana.org";
39+
const GATEWAY_URL = process.env.DATA_GATEWAY_URL ?? "https://dp-rpc.vana.org";
4140

4241
export type RegisterServerErrorCode =
4342
| "ALREADY_REGISTERED"

‎src/cli/index.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ async function runConnect(
12741274
let ingestFailureMessage: string | null = null;
12751275
let resultPath = getSourceResultPath(source);
12761276
let collectedResult = false;
1277+
let blockedByRequiredInput = false;
12771278
let ingestScopeResults:
12781279
| Array<{
12791280
scope: string;
@@ -1348,6 +1349,9 @@ async function runConnect(
13481349
}
13491350

13501351
if (event.type === "needs-input") {
1352+
if (options.noInput && !options.ipc) {
1353+
blockedByRequiredInput = true;
1354+
}
13511355
await updateSourceState(resolution.source, {
13521356
lastRunAt: new Date().toISOString(),
13531357
lastRunOutcome: CliOutcomeStatus.NEEDS_INPUT,
@@ -1448,6 +1452,10 @@ async function runConnect(
14481452
}
14491453

14501454
if (event.type === "collection-complete" && event.resultPath) {
1455+
if (blockedByRequiredInput) {
1456+
continue;
1457+
}
1458+
14511459
// Check if the result is actually an error object
14521460
try {
14531461
const raw = await fsp.readFile(event.resultPath, "utf8");

‎src/core/constants.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ export type VanaEnvironment = "dev" | "prod";
55
export const ENV_CONFIG = {
66
dev: {
77
sessionRelayUrl: "https://dev.session-relay.vana.org",
8-
gatewayUrl: "https://dev.data-gateway.vana.org",
8+
gatewayUrl: "https://dp-rpc-dev.vana.org",
99
accountUrl: "https://account-dev.vana.org",
1010
},
1111
prod: {
1212
sessionRelayUrl: "https://session-relay.vana.org",
13-
gatewayUrl: "https://data-gateway.vana.org",
13+
gatewayUrl: "https://dp-rpc.vana.org",
1414
accountUrl: "https://account.vana.org",
1515
},
1616
} as const;

‎src/core/types.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export interface DataFetchParams {
7272
export interface RequestSignerConfig {
7373
/** Builder private key in hex format. */
7474
privateKey: `0x${string}`;
75+
/**
76+
* Body hash wire format.
77+
* - `"legacy"`: bare sha256 hex, with `""` for empty bodies. Required by the current Session Relay.
78+
* - `"prefixed"`: `sha256:<hex>`, including the canonical empty-body hash.
79+
*/
80+
bodyHashFormat?: "legacy" | "prefixed";
7581
}
7682

7783
/** Configuration for {@link createSessionRelay}. */

‎src/server/data-client.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ export interface DataClient {
2828
*/
2929
export function createDataClient(config: DataClientConfig): DataClient {
3030
const gatewayBase = config.gatewayUrl.replace(/\/+$/, "");
31-
const signer = createRequestSigner({ privateKey: config.privateKey });
31+
const signer = createRequestSigner({
32+
privateKey: config.privateKey,
33+
bodyHashFormat: "prefixed",
34+
});
3235

3336
return {
3437
async resolveServerUrl(userAddress: string): Promise<string> {

‎src/server/request-signer.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { createHash } from "node:crypto";
22
import { privateKeyToAccount } from "viem/accounts";
33
import type { RequestSignerConfig } from "../core/types.js";
44

5+
const EMPTY_BODY_HASH =
6+
"sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
7+
type BodyHashFormat = NonNullable<RequestSignerConfig["bodyHashFormat"]>;
8+
59
function base64urlEncode(input: string): string {
610
return Buffer.from(input, "utf-8")
711
.toString("base64")
@@ -21,14 +25,18 @@ function canonicalizeJson(obj: unknown): unknown {
2125
return sorted;
2226
}
2327

24-
function computeBodyHash(body?: string): string {
28+
function computeBodyHash(
29+
body: string | undefined,
30+
format: BodyHashFormat,
31+
): string {
2532
if (!body || body.length === 0) {
26-
return "";
33+
return format === "prefixed" ? EMPTY_BODY_HASH : "";
2734
}
2835
const parsed = JSON.parse(body);
2936
const canonical = canonicalizeJson(parsed);
3037
const canonicalStr = JSON.stringify(canonical);
31-
return createHash("sha256").update(canonicalStr).digest("hex");
38+
const hash = createHash("sha256").update(canonicalStr).digest("hex");
39+
return format === "prefixed" ? `sha256:${hash}` : hash;
3240
}
3341

3442
/**
@@ -64,6 +72,7 @@ export function createRequestSigner(
6472
config: RequestSignerConfig,
6573
): RequestSigner {
6674
const account = privateKeyToAccount(config.privateKey);
75+
const bodyHashFormat = config.bodyHashFormat ?? "legacy";
6776

6877
return {
6978
address: account.address,
@@ -73,7 +82,7 @@ export function createRequestSigner(
7382

7483
const payload: Record<string, unknown> = {
7584
aud: params.aud,
76-
bodyHash: computeBodyHash(params.body),
85+
bodyHash: computeBodyHash(params.body, bodyHashFormat),
7786
exp: now + 300,
7887
iat: now,
7988
method: params.method,

‎test/cli/index.test.ts‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,12 @@ describe("runCli", () => {
10701070
account: {
10711071
address: "0x2ab394e4be7c43ac360d226a31e1c90bc01aafa1",
10721072
session_token: "vana_account_session",
1073-
expires_at: "2026-04-22T19:25:14.420Z",
1073+
expires_at: "2027-04-22T19:25:14.420Z",
10741074
},
10751075
personal_server: {
10761076
url: "https://0x2ab394e4be7c43ac360d226a31e1c90bc01aafa1.myvana.app",
10771077
session_token: "vana_ps_session",
1078-
expires_at: "2026-04-22T19:25:14.420Z",
1078+
expires_at: "2027-04-22T19:25:14.420Z",
10791079
},
10801080
});
10811081
}
@@ -1137,6 +1137,12 @@ describe("runCli", () => {
11371137
message: "Steam needs credentials",
11381138
fields: ["username", "password"],
11391139
},
1140+
{
1141+
type: "collection-complete",
1142+
source: "steam",
1143+
resultPath: "/tmp/.vana/steam-result.json",
1144+
logPath: "/tmp/logs/run.log",
1145+
},
11401146
];
11411147

11421148
const { runCli } = await import("../../src/cli/index.js");
@@ -1168,6 +1174,19 @@ describe("runCli", () => {
11681174
source: "steam",
11691175
}),
11701176
);
1177+
expect(lines).not.toContainEqual(
1178+
expect.objectContaining({
1179+
type: "outcome",
1180+
status: "connected_local_only",
1181+
source: "steam",
1182+
}),
1183+
);
1184+
expect(mockUpdateSourceState).not.toHaveBeenCalledWith(
1185+
"steam",
1186+
expect.objectContaining({
1187+
lastRunOutcome: "connected_local_only",
1188+
}),
1189+
);
11711190
});
11721191

11731192
it("shows a clear human message when input is required in no-input mode", async () => {

‎test/core/constants.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ describe("getEnvConfig", () => {
1010
const config = getEnvConfig("dev");
1111
expect(config).toBe(ENV_CONFIG.dev);
1212
expect(config.sessionRelayUrl).toContain("session-relay");
13-
expect(config.gatewayUrl).toContain("data-gateway");
13+
expect(config.gatewayUrl).toBe("https://dp-rpc-dev.vana.org");
1414
expect(config.accountUrl).toBe("https://account-dev.vana.org");
1515
});
1616

1717
it("returns prod config for 'prod'", () => {
1818
const config = getEnvConfig("prod");
1919
expect(config).toBe(ENV_CONFIG.prod);
20+
expect(config.gatewayUrl).toBe("https://dp-rpc.vana.org");
2021
expect(config.accountUrl).toBe("https://account.vana.org");
2122
});
2223

0 commit comments

Comments
 (0)