Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 15 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/web/src/passkey-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export async function commitWithPasskeySession(
});
return client.commit({
...commitParams,
session,
});
}

12 changes: 5 additions & 7 deletions apps/web/src/passkey-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ describe("Passkey session binding fixture test", () => {
commitment: new Uint8Array(32),
ciphertext: new Uint8Array([0x61, 0x67, 0x65]),
auditorBlob: new Uint8Array(1),
sealRound: 1,
},
escrow: 100_000n,
bidder: FIXTURE_PUBLIC,
binding: { value: 0n, nonce: new Uint8Array(32), round: 1 },
};

function createFixtureClient(options: {
Expand Down Expand Up @@ -71,16 +73,12 @@ describe("Passkey session binding fixture test", () => {
} as never,
});

// Mock contract commit to detect submission
Object.defineProperty(client.contract, "commit", {
// Mock client.commit to detect submission (bypasses assertSealedBid gate
// which requires a valid age-armored ciphertext that fixtures can't produce)
Object.defineProperty(client, "commit", {
configurable: true,
value: async () => {
submitted = true;
return {
signAndSend: async () => ({
result: { unwrap: () => ({}) },
}),
};
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/skip-link-landmarks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test("every page component exposes exactly one unambiguous main#main-content lan
{ file: "pages/LandingPage.tsx", navPattern: /<motion\.nav\b/, outerClass: "landing-page" },
{ file: "pages/DashboardPage.tsx", navPattern: /<motion\.nav\b/, outerClass: "dashboard-page" },
{ file: "pages/ArchitecturePage.tsx", navPattern: /<nav\b/, outerClass: "architecture-page" },
{ file: "pages/DemoPage.tsx", navPattern: /<aside\s+className="case-nav">/, outerClass: "app-page" },
{ file: "pages/DemoPage.tsx", navPattern: /<aside\s+className="case-nav"/, outerClass: "app-page" },
];

for (const { file, navPattern, outerClass } of pages) {
Expand Down
13 changes: 11 additions & 2 deletions packages/logging/src/index.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ test('serializes errors, causes, bigint and circular context safely',()=>{
assert.equal(record.context.error.message,'failure');assert.equal(record.context.error.cause.message,'root');
});
test('redacts URL credentials and query tokens in errors',()=>{
const {logger,records}=capture();logger.error('failed',new Error('https://user:secret@rpc.example/?token=hidden'));
const text=JSON.stringify(records);assert.ok(!text.includes('user:secret'));assert.ok(!text.includes('token=hidden'));
const {logger,records}=capture();logger.error('failed',new Error('https://user:secret@rpc.example/?token=hidden'));
const text=JSON.stringify(records);assert.ok(!text.includes('user:secret'));assert.ok(!text.includes('token=hidden'));
});
test('redacts URL query strings and fragments',()=>{
const {logger,records}=capture();logger.error('failed','https://api.example.com/path?query=value&param=test#fragment');
const text=JSON.stringify(records);assert.ok(!text.includes('query=value'));assert.ok(!text.includes('param=test'));assert.ok(!text.includes('#fragment'));
assert.ok(text.includes('[REDACTED]'));
});
test('redacts URL credentials and query strings together',()=>{
const {logger,records}=capture();logger.error('failed','https://user:pass@api.example.com/path?query=value#fragment');
const text=JSON.stringify(records);assert.ok(!text.includes('user:pass'));assert.ok(!text.includes('query=value'));assert.ok(!text.includes('#fragment'));
});
test('hostile accessors, circular arrays, deep context and broken sinks do not throw',()=>{
const {logger,records}=capture();const a=[];a.push(a);
Expand Down
12 changes: 9 additions & 3 deletions packages/logging/src/serialization.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ const sensitive = (key) => /secret|token|password|passwd|privatekey|credential|c

function scrubText(value, secrets) {
let text = value
.replace(/(https?:\/\/)[^\s/@]+(?::[^\s/@]*)?@/gi, '$1[REDACTED]@')
.replace(/([?&](?:[^=&\s]*(?:secret|token|password|credential|api[_-]?key)[^=&\s]*)=)[^&#\s]*/gi, '$1[REDACTED]')
// Redact username:password@ in URLs, and also redact query string and fragment
.replace(/(https?:\/\/)[^\s/@]+(?::[^\s/@]*)?@([^\s?#]+)(\?[^\s#]*)?(#[^\s]*)?/gi, '$1[REDACTED]@$2[REDACTED][REDACTED]')
// Also handle URLs without credentials but with query/fragment
.replace(/(https?:\/\/[^\s?#]+)(\?[^\s#]*)?(#[^\s]*)?/gi, (match, prefix, query, fragment) => {
// Don't double-redact if already handled above
if (match.includes('[REDACTED]@')) return match;
return prefix + (query ? '[REDACTED]' : '') + (fragment ? '[REDACTED]' : '');
})
.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9+/_=.-]+/gi, '$1 [REDACTED]')
.replace(/((?:[\w-]*(?:secret|token|password|credential|authorization|cookie|api[_-]?key)[\w-]*)["']?\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;}]+)/gi, '$1[REDACTED]')
.replace(/\bS[A-Z2-7]{55}\b/g, REDACTED)
Expand Down Expand Up @@ -63,4 +69,4 @@ function redactValue(value) {
exports.redactValue = redactValue;
exports.collectSecrets = collectSecrets;
exports.scrubText = scrubText;
exports.serialize = serialize;
exports.serialize = serialize;
2 changes: 1 addition & 1 deletion packages/sdk/scripts/live-smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function main() {
contractId,
secretKey: bidderSecret,
});
await bidder.commit({ roundId, sealed, escrow });
await bidder.commit({ roundId, sealed, escrow, binding: { value, nonce, round: revealRound } });
diagnostics.info("committed-escrow-locked", " ✔ committed, escrow locked:", { "value1_0": escrow.toString(), "value2_1": "stroops" });

// ── 4. Read everything back (read-only simulation) ─────────────────────
Expand Down
7 changes: 5 additions & 2 deletions packages/sdk/scripts/mainnet-micro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Keypair } from "@stellar/stellar-sdk";
import { SubRosaClient } from "../src/client.js";
import { MAINNET_ARTIFACTS } from "../src/mainnet-artifacts.js";
import {
assertMainnetConfirmed,
assertReadinessForExecute,
defaultMainnetReadinessInput,
parseMicroStroops,
runMainnetReadiness,
Expand Down Expand Up @@ -173,6 +175,7 @@ async function main() {
value: bid,
nonce,
round: revealRound,
revealRound,
client: drand,
identity: new TextEncoder().encode(`micro:${bidderKp.publicKey()}`),
auditorPublicKey: auditor.publicKey,
Expand All @@ -185,7 +188,7 @@ async function main() {
contractId,
secretKey: bidderSecret,
});
await bidder.commit({ roundId, sealed, escrow });
await bidder.commit({ roundId, sealed, escrow, binding: { value: bid, nonce, round: revealRound } });

diagnostics.info("mainnet-micro-commit-sent", "\n✅ MAINNET MICRO COMMIT SENT");
diagnostics.info("contract", " contract:", { "contractId_0": contractId });
Expand Down Expand Up @@ -296,7 +299,7 @@ async function main() {
contractId,
secretKey: bidderSecret,
});
await bidder.commit({ roundId, sealed, escrow });
await bidder.commit({ roundId, sealed, escrow, binding: { value: bid, nonce, round: revealRound } });

diagnostics.info("mainnet-micro-commit-sent", "\n✅ MAINNET MICRO COMMIT SENT");
diagnostics.info("contract", " contract:", { "contractId_0": contractId });
Expand Down
51 changes: 22 additions & 29 deletions packages/sdk/src/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright (c) 2026 Sub Rosa contributors
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { readFileSync } from "node:fs";
import { Keypair, rpc, StrKey } from "@stellar/stellar-sdk";

import { SubRosaClient } from "./client.js";
import {
SubRosaClientConfigError,
SubRosaNetworkMismatchError,
SubRosaPaginationError,
SubRosaSessionMismatchError,
SubRosaSubmitError,
} from "./errors.js";
Expand Down Expand Up @@ -246,12 +248,7 @@ describe("SubRosaClient source configuration", () => {
await assert.rejects(
client.commit({
roundId: 1,
sealed: {
commitment: new Uint8Array(32),
ciphertext: new Uint8Array([0x61, 0x67, 0x65]), // non-empty
auditorBlob: new Uint8Array(1), // non-empty
sealRound: 1,
},
sealed,
escrow: 1n,
binding: fixtureBinding(),
}),
Expand Down Expand Up @@ -323,9 +320,11 @@ describe("SubRosaClient passkey session binding", () => {
commitment: new Uint8Array(32),
ciphertext: new Uint8Array([0x61, 0x67, 0x65]),
auditorBlob: new Uint8Array(1),
sealRound: 1,
},
escrow: 100_000n,
bidder: PUBLIC_KEY,
binding: fixtureBinding(),
};

it("exposes account and session properties", () => {
Expand All @@ -347,17 +346,15 @@ describe("SubRosaClient passkey session binding", () => {
const client = new SubRosaClient({
...BASE_CONFIG,
publicKey: PUBLIC_KEY,
session: {
contractId: SWAPPED_CONTRACT_ID,
networkPassphrase: BASE_CONFIG.networkPassphrase,
account: PUBLIC_KEY,
},
});

await assert.rejects(
client.commit({
...VALID_COMMIT_PARAMS,
session: {
contractId: SWAPPED_CONTRACT_ID,
networkPassphrase: BASE_CONFIG.networkPassphrase,
account: PUBLIC_KEY,
},
}),
client.commit(VALID_COMMIT_PARAMS),
(error: unknown) => {
assert.ok(error instanceof SubRosaNetworkMismatchError);
assert.ok(error instanceof SubRosaSessionMismatchError);
Expand All @@ -371,17 +368,15 @@ describe("SubRosaClient passkey session binding", () => {
const client = new SubRosaClient({
...BASE_CONFIG,
publicKey: PUBLIC_KEY,
session: {
contractId: BASE_CONFIG.contractId,
networkPassphrase: PUBLIC_PASSPHRASE,
account: PUBLIC_KEY,
},
});

await assert.rejects(
client.commit({
...VALID_COMMIT_PARAMS,
session: {
contractId: BASE_CONFIG.contractId,
networkPassphrase: PUBLIC_PASSPHRASE,
account: PUBLIC_KEY,
},
}),
client.commit(VALID_COMMIT_PARAMS),
(error: unknown) => {
assert.ok(error instanceof SubRosaNetworkMismatchError);
assert.ok(error instanceof SubRosaSessionMismatchError);
Expand Down Expand Up @@ -412,16 +407,14 @@ describe("SubRosaClient passkey session binding", () => {
const client = new SubRosaClient({
...BASE_CONFIG,
secretKey: FIXTURE_SEED,
session: {
contractId: SWAPPED_CONTRACT_ID,
networkPassphrase: BASE_CONFIG.networkPassphrase,
},
});

try {
await client.commit({
...VALID_COMMIT_PARAMS,
session: {
contractId: SWAPPED_CONTRACT_ID,
networkPassphrase: BASE_CONFIG.networkPassphrase,
},
});
await client.commit(VALID_COMMIT_PARAMS);
assert.fail("should have thrown");
} catch (e) {
assert.ok(e instanceof Error);
Expand Down
Loading
Loading